@nylas/web-elements 2.5.4 → 2.5.5
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.
- package/dist/cdn/nylas-scheduler-editor/nylas-scheduler-editor.es.js +954 -953
- package/dist/cdn/nylas-scheduling/nylas-scheduling.es.js +10 -9
- package/dist/cjs/{abstract-provider-CH5yXWmY.js → abstract-provider-NL9mvsRm.js} +3 -3
- package/dist/cjs/abstract-provider-NL9mvsRm.js.map +1 -0
- package/dist/cjs/google-logo-icon_6.cjs.entry.js +1 -1
- package/dist/cjs/nylas-scheduler-editor.cjs.entry.js +2 -2
- package/dist/cjs/nylas-scheduling.cjs.entry.js +3 -3
- package/dist/cjs/nylas-scheduling.cjs.entry.js.map +1 -1
- package/dist/cjs/nylas-scheduling.entry.cjs.js.map +1 -1
- package/dist/cjs/{version-COw2dh2E.js → version-y-IXeOX1.js} +3 -3
- package/dist/cjs/{version-COw2dh2E.js.map → version-y-IXeOX1.js.map} +1 -1
- package/dist/collection/common/abstract-provider.js +1 -1
- package/dist/collection/common/abstract-provider.js.map +1 -1
- package/dist/collection/components/scheduler/nylas-scheduling/nylas-scheduling.js +6 -1
- package/dist/collection/components/scheduler/nylas-scheduling/nylas-scheduling.js.map +1 -1
- package/dist/collection/version.js +1 -1
- package/dist/collection/version.js.map +1 -1
- package/dist/components/nylas-editor-tabs-group.js +1 -1
- package/dist/components/nylas-editor-tabs.js +1 -1
- package/dist/components/nylas-scheduler-editor.js +4 -4
- package/dist/components/nylas-scheduling.js +3 -3
- package/dist/components/nylas-scheduling.js.map +1 -1
- package/dist/components/{p-Bd0cKEr-.js → p-677FcYj-.js} +3 -3
- package/dist/components/{p-Bd0cKEr-.js.map → p-677FcYj-.js.map} +1 -1
- package/dist/components/{p-DTmxwCTa.js → p-BW6mh3NI.js} +3 -3
- package/dist/components/{p-DTmxwCTa.js.map → p-BW6mh3NI.js.map} +1 -1
- package/dist/components/{p-BvQ13Bty.js → p-CigXeIp5.js} +3 -3
- package/dist/components/p-CigXeIp5.js.map +1 -0
- package/dist/components/{p-ejCgVZ9o.js → p-CzVKC2Lf.js} +3 -3
- package/dist/components/{p-ejCgVZ9o.js.map → p-CzVKC2Lf.js.map} +1 -1
- package/dist/esm/{abstract-provider-KowNUOZM.js → abstract-provider-Bxd_4MUD.js} +3 -3
- package/dist/esm/abstract-provider-Bxd_4MUD.js.map +1 -0
- package/dist/esm/google-logo-icon_6.entry.js +1 -1
- package/dist/esm/nylas-scheduler-editor.entry.js +2 -2
- package/dist/esm/nylas-scheduling.entry.js +3 -3
- package/dist/esm/nylas-scheduling.entry.js.map +1 -1
- package/dist/esm/{version-DDixcvI0.js → version-CqK6_Oc7.js} +3 -3
- package/dist/esm/{version-DDixcvI0.js.map → version-CqK6_Oc7.js.map} +1 -1
- package/dist/nylas-web-elements/nylas-scheduling.entry.esm.js.map +1 -1
- package/dist/nylas-web-elements/nylas-web-elements.esm.js +1 -1
- package/dist/nylas-web-elements/{p-a6d5e357.entry.js → p-196717a0.entry.js} +3 -3
- package/dist/nylas-web-elements/{p-DDixcvI0.js → p-CqK6_Oc7.js} +2 -2
- package/dist/nylas-web-elements/{p-DDixcvI0.js.map → p-CqK6_Oc7.js.map} +1 -1
- package/dist/nylas-web-elements/{p--bAq8KLi.js → p-DGwaF706.js} +2 -2
- package/dist/nylas-web-elements/p-DGwaF706.js.map +1 -0
- package/dist/nylas-web-elements/{p-937127a0.entry.js → p-ca41de7e.entry.js} +2 -2
- package/dist/nylas-web-elements/{p-f5cf4c30.entry.js → p-d1dc06a1.entry.js} +2 -2
- package/dist/nylas-web-elements/p-d1dc06a1.entry.js.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/abstract-provider-CH5yXWmY.js.map +0 -1
- package/dist/components/p-BvQ13Bty.js.map +0 -1
- package/dist/esm/abstract-provider-KowNUOZM.js.map +0 -1
- package/dist/nylas-web-elements/p--bAq8KLi.js.map +0 -1
- package/dist/nylas-web-elements/p-f5cf4c30.entry.js.map +0 -1
- /package/dist/nylas-web-elements/{p-a6d5e357.entry.js.map → p-196717a0.entry.js.map} +0 -0
- /package/dist/nylas-web-elements/{p-937127a0.entry.js.map → p-ca41de7e.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 r,a as s}from"./p-0EQQA0nE.js";import{N as o}from"./p--bAq8KLi.js";import{N as a}from"./p-dlIPw-hO.js";import{d as c,u as l,t as d,a as u,b as h,g as f,e as p,C as g,L as y,i as w,c as b}from"./p-BW6igRcf.js";import{o as m,v,E as _,N as E}from"./p-DDixcvI0.js";import{c as k}from"./p-_i6H-yQH.js";c.extend(l);c.extend(d);class x{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){u("Nylas API Request is not initialized");return null}return this.nylasApiRequest.currentUser()}async getCalendars(){if(!this.nylasApiRequest){u("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,r]=await this.nylasApiRequest.request({method:"GET",path:`calendars?limit=${n}${t?`&page_token=${t}`:""}`});if(r){return h(null,{message:"Error fetching calendars: "+r.message})}if(m(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){u("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(m(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){u("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(m(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){u("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){u("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[r,s]=await this.nylasApiRequest.request({method:"GET",path:`events/${e}?${i.toString()}`});if(s){return h(null,{message:"Error fetching master event: "+s.message})}if(m(r)){return h(null,{message:"Error fetching master event: "+r.error?.message})}const o=this.nylasSchedulerConfigStore.state.masterGroupEvents;if(o[e]){this.nylasSchedulerConfigStore.state.masterGroupEvents[e]=r.data}else{this.nylasSchedulerConfigStore.state.masterGroupEvents={...o,[e]:r.data}}return h(r.data)}async createConfiguration(e){if(!this.nylasApiRequest){u("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(m(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){u("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(m(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){u("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(m(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){u("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(m(n)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error creating group event: "+n.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=n.data;this.invalidateGroupEventsCache();await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(n.data)}async getGroupEvents(e,t){if(!this.nylasApiRequest){u("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 r;let s;if(i){r=i.start_time;s=i.end_time}else{const e=f((new Date).toISOString(),"week");r=e.startTime.toString();s=e.endTime.toString()}const o=`${e}-${r}-${s}`;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",r);n.append("end_time",s);const c=t?.group_booking?.calendar_id;if(c){n.append("calendar_id",c)}const[l,d]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}/group-events?${n.toString()}`});if(d){return h(null,{message:"Error fetching group events: "+d.message})}if(m(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)}invalidateGroupEventsCache(){this.groupEventsCache.clear()}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){u("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,r]=await this.nylasApiRequest.request({method:"PATCH",path:`scheduling/configurations/${t}/group-events/${n}`,body:e});if(r){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error updating group event: "+r.message})}if(m(i)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error updating group event: "+i.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=i.data;this.invalidateGroupEventsCache();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 r=i?.event?.master_event_id;const s=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 d=o?c(o*1e3).subtract(1,"minute").format("YYYYMMDDTHHmmss[Z]"):"";if(t==="this"){return this.updateGroupEventById({...e,id:s,recurrence:r?undefined:e.recurrence},n)}else if(t==="future"&&r){const t=await this.createGroupEvent(e,n);const s={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="+d]:[`RRULE:FREQ=DAILY;UNTIL=${d}`]};await this.updateGroupEventById({...s,id:r},n);return[s,t]}else if(t==="all"){const t=e?.when;const s=i?.event?.when;const o=this.nylasSchedulerConfigStore.state.masterGroupEvents?.[r];let a=o?.when;if(t?.start_time!==s?.start_time){a={...a,start_time:t?.start_time||a?.start_time}}if(t?.end_time!==s?.end_time){a={...a,end_time:t?.end_time||a?.end_time}}if(t?.start_timezone!==s?.start_timezone){a={...a,start_timezone:t?.start_timezone||a?.start_timezone}}if(t?.end_timezone!==s?.end_timezone){a={...a,end_timezone:t?.end_timezone||a?.end_timezone}}return this.updateGroupEventById({...e,when:a,id:r},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 r=i?.event?.master_event_id;const s=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 d=o?c(o*1e3).format("YYYYMMDDTHHmmss[Z]"):"";const u={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="+d]:[`RRULE:UNTIL=${d}`]};if(t==="this"&&s){return this.deleteGroupEventById(s,n)}else if(t==="future"&&r&&s){await this.deleteGroupEventById(s,n);return await this.updateGroupEventById({...u,id:r},n)}else if(t==="all"&&r){return this.deleteGroupEventById(r,n)}this.nylasSchedulerConfigStore.state.isLoading=false;throw new Error("Invalid option")}async deleteGroupEventById(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){u("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[r,s]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${t}/group-events/${e}?calendar_id=${i}`});if(s){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error deleting group event: "+s.message})}if(m(r)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error deleting group event: "+r.error?.message})}this.invalidateGroupEventsCache();await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(r.data)}async importGroupEvent(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){u("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[r,s]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/import-group-events?${n.toString()}`,body:e});if(s){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error importing group event: "+s.message})}if(m(r)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error importing group event: "+r.error?.message})}if(r.data?.imported_events?.length>0){this.invalidateGroupEventsCache();await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration)}this.nylasSchedulerConfigStore.state.isLoading=false;return h(r.data)}}class C{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}init(){u("NylasSchedulerConfigConnector init")}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get schedulerConfig(){if(this._schedulerConfigConnector){return this._schedulerConfigConnector}this._schedulerConfigConnector=new x({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore});return this._schedulerConfigConnector}resetStores(){u("NylasSchedulerConfigConnector resetStores");this.nylasSchedulerConfigStore.reset()}async logout(){u("NylasSchedulerConfigConnector logout");this.resetStores()}}function $(e={}){const t={selectedConfiguration:{},configurations:[],groupEvents:[],listConfigurationsNextCursor:null,calendars:[],currentUser:null,action:null,additionalParticipants:[],requiresSlug:false,masterGroupEvents:{},isLoading:false,...e};const n=k(t);function i(){n.set("selectedConfiguration",{...e["selectedConfiguration"]})}n.onChange("action",(async e=>{if(!e){i()}}));n.onChange("selectedConfiguration",(async e=>{const t=n.state.participantFetch;const i=e?.participants;if(!t||!i?.length)return;const r=i.filter((e=>!e.is_organizer&&!!e.email)).map((e=>e.email));if(r.length===0)return;try{const e=n.state.participantFetchGrantId;const i=await t({emails:r,grantId:e});if(!i?.length)return;const s=n.state.additionalParticipants||[];const o=new Set(s.map((e=>e.email)));const a=i.filter((e=>!o.has(e.email)));if(a.length>0){n.set("additionalParticipants",[...s,...a])}}catch(e){u("[scheduler-config-store] participantFetch failed",e)}}));return{...n,resetSelectedConfiguration:i}}class S{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 T="pkce";const P="grant";const I="user";const R=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 A=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 q{Storage=new S;constructor(e){if(e){this.Storage=e;return}}setPKCE(e){const t=R(e);this.Storage.set(T,t)}async getPKCE(){try{const e=await this.Storage.get(T);if(e){return A(e)}}catch(e){return null}return null}removePKCE(){this.Storage.remove(T)}setGrant(e,t=false){const{grant_id:n}=e;this.Storage.set(`${P}${t?"-"+n:""}`,e)}removeGrant(e,t=false){this.Storage.remove(`${P}${t?"-"+e:""}`)}async getGrant(e,t=false){const n=await this.Storage.get(`${P}${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(I,n)}else{const n=t.map((t=>{if(t.sub===e.sub){t=e}return t}));this.Storage.set(I,n)}}else{this.Storage.set(I,[e])}}async getUserToken(e=""){const t=await this.Storage.get(I);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(I);if(e){return e}return null}removeUserTokens(){this.Storage.remove(I)}async removeUserToken(e){const t=await this.getUserTokens();const n=t?.filter((t=>t.sub!==e));this.Storage.set(I,n)}async clearSession(){const e=await this.getUserTokens();e?.forEach((e=>{this.removeGrant(e.sub)}));this.removePKCE();this.removeUserTokens()}}class U{databaseName="identity-db";storeName="identity";get(e){const t=this;return new Promise(((n,i)=>{t.openDatabase().then((function(r){const s=r.transaction(t.storeName,"readwrite");const o=s.objectStore(t.storeName);const a=o.get(e);a.onsuccess=()=>{n(a.result)};a.onerror=()=>{i(a.error)};s.oncomplete=()=>{r.close()}}))}))}async remove(e){const t=this;return new Promise(((n,i)=>{const r=indexedDB.open(this.databaseName);r.onupgradeneeded=function(e){const n=e.target.result;n.createObjectStore(t.storeName)};r.onerror=()=>{i(r.error)};r.onsuccess=t=>{const r=t.target.result;const s=r.transaction(this.storeName,"readwrite");const o=s.objectStore(this.storeName);const a=o.delete(e);a.onsuccess=()=>{n(null)};a.onerror=()=>{i(a.error)};s.oncomplete=()=>{r.close()}}}))}set(e,t){return new Promise(((n,i)=>{const r=indexedDB.open(this.databaseName);r.onerror=()=>{i(r.error)};r.onupgradeneeded=e=>{const t=e.target.result;t.createObjectStore(this.storeName)};r.onsuccess=r=>{const s=r.target.result;const o=s.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=()=>{s.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 N;var L=new Uint8Array(16);function z(){if(!N){N=typeof crypto!=="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!=="undefined"&&typeof msCrypto.getRandomValues==="function"&&msCrypto.getRandomValues.bind(msCrypto);if(!N){throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported")}}return N(L)}var j=/^(?:[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 O(e){return typeof e==="string"&&j.test(e)}var D=[];for(var F=0;F<256;++F){D.push((F+256).toString(16).substr(1))}function G(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var n=(D[e[t+0]]+D[e[t+1]]+D[e[t+2]]+D[e[t+3]]+"-"+D[e[t+4]]+D[e[t+5]]+"-"+D[e[t+6]]+D[e[t+7]]+"-"+D[e[t+8]]+D[e[t+9]]+"-"+D[e[t+10]]+D[e[t+11]]+D[e[t+12]]+D[e[t+13]]+D[e[t+14]]+D[e[t+15]]).toLowerCase();if(!O(n)){throw TypeError("Stringified UUID is invalid")}return n}function H(e,t,n){e=e||{};var i=e.random||(e.rng||z)();i[6]=i[6]&15|64;i[8]=i[8]&63|128;return G(i)}async function B(e,t){const n=e.getReader();let i;while(!(i=await n.read()).done){t(i.value)}}function M(e){let t;let n;let i;let r=false;return function s(o){if(t===undefined){t=o;n=0;i=-1}else{t=J(t,o)}const a=t.length;let c=0;while(n<a){if(r){if(t[n]===10){c=++n}r=false}let s=-1;for(;n<a&&s===-1;++n){switch(t[n]){case 58:if(i===-1){i=n-c}break;case 13:r=true;case 10:s=n;break}}if(s===-1){break}e(t.subarray(c,s),i);c=n;i=-1}if(c===a){t=undefined}else if(c!==0){t=t.subarray(c);n-=c}}}function Y(e,t,n){let i=W();const r=new TextDecoder;return function s(o,a){if(o.length===0){n===null||n===void 0?void 0:n(i);i=W()}else if(a>0){const n=r.decode(o.subarray(0,a));const s=a+(o[a+1]===32?2:1);const c=r.decode(o.subarray(s));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 J(e,t){const n=new Uint8Array(e.length+t.length);n.set(e);n.set(t,e.length);return n}function W(){return{data:"",event:"",id:"",retry:undefined}}var K=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 r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++){if(t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r]))n[i[r]]=e[i[r]]}return n};const V="text/event-stream";const Q=1e3;const Z="last-event-id";function X(e,t){var{signal:n,headers:i,onopen:r,onmessage:s,onclose:o,onerror:a,openWhenHidden:c,fetch:l}=t,d=K(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise(((t,u)=>{const h=Object.assign({},i);if(!h.accept){h.accept=V}let f;function p(){f.abort();if(!document.hidden){v()}}if(!c){document.addEventListener("visibilitychange",p)}let g=Q;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=r!==null&&r!==void 0?r:ee;async function v(){var n;f=new AbortController;try{const n=await b(e,Object.assign(Object.assign({},d),{headers:h,signal:f.signal}));await m(n);await B(n.body,M(Y((e=>{if(e){h[Z]=e}else{delete h[Z]}}),(e=>{g=e}),s)));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();u(e)}}}}v()}))}function ee(e){const t=e.headers.get("content-type");if(!(t===null||t===void 0?void 0:t.startsWith(V))){throw new Error(`Expected content-type to be ${V}, Actual: ${t}`)}}function te(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function ne(){return Math.floor(Date.now()/1e3)}async function ie(e){const t=(new TextEncoder).encode(e);const n=await crypto.subtle.digest("SHA-256",t);const i=Array.from(new Uint8Array(n));const r=i.map((e=>e.toString(16).padStart(2,"0"))).join("");return r}function re(e){this.message=e}re.prototype=new Error,re.prototype.name="InvalidCharacterError";var se="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new re("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,r=0,s=0,o="";i=t.charAt(s++);~i&&(n=r%4?64*n+i:i,r++%4)?o+=String.fromCharCode(255&n>>(-2*r&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return o};function oe(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(se(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 se(t)}}function ae(e){this.message=e}function ce(e,t){if("string"!=typeof e)throw new ae("Invalid token specified");var n=true===(t=t||{}).header?0:1;try{return JSON.parse(oe(e.split(".")[n]))}catch(e){throw new ae("Invalid token specified: "+e.message)}}ae.prototype=new Error,ae.prototype.name="InvalidTokenError";class le{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 U;this.Storage=new q(e)}else{this.Storage=new q}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 r=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(i){r+=`&code_challenge=${i}&code_challenge_method=S256&options=rotate_refresh_token`}if(n?.provider){r+=`&provider=${n.provider}`}if(n?.email){r+=`&login_hint=${n.email}`}if(t){r+=`&scope=${t.join(" ")}`}return r}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 ie(e);let n=btoa(unescape(encodeURIComponent(t)));n=te(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 r=await i.json();return r}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 r=await i.json();return r}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 r=t.get("error");const s=t.get("error_description");const o=t.get("error_code");if(r&&s&&o){const e={detail:{error:r,error_description:s,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 r=await t.json();if(r){if(r.error){const e={detail:r};window.dispatchEvent(new CustomEvent("onLoginFail",e));return true}const e=await this.handleCodeExchangeResponse(r);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(r){const e={detail:r};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 r=await i.json();if(r){if(r.error){const e={detail:r};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const t=ne();r.expires_in=t+r.expires_in;this.Storage.setGrant(r,this.multiAccount);const n=await this.validateIDToken(e);if(!n){const e={detail:r};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const i={detail:r};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=ne();e.expires_in=n+e.expires_in;this.Storage.setGrant(e,this.multiAccount);const i=ce(e.id_token);i.status="authenticated";this.Storage.setUserToken(i);const r=await this.validateIDToken(i.sub);if(!r){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 r=window.screenY+(window.outerHeight-n)/2.5;const s=`uas-popup`;const o=e;const a=window.open(o,s,`width=${t},height=${n},left=${i},top=${r}`);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=ne();const n=await this.Storage.getGrant(e,this.multiAccount);if(!n){return null}const{access_token:i,expires_in:r}=n;const s=i;if(s){if(r&&r>ne()){const e=r-t;if(e>30){return s}}}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 r="";if(this.multiAccount){if(!i){this.logout();throw new Error("Grant ID is required for multi account calls")}r=await this.getAccessToken(i)}else{r=await this.getAccessToken()}delete n["Grant-ID"];n["Authorization"]=`Bearer ${r}`;if(!n["content-type"]){n["content-type"]="application/json"}return X(`${this.domain}/${e}`,{...t,headers:n})}async fetch(e,t,n=true,i){let r="";let s=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();s=e?e.length:1;r=await this.getAccessToken(t.grant_id)}else{r=await this.getAccessToken()}if(!r){throw new Error("Access token not found")}let o=t.headers;if(!Headers.prototype.isPrototypeOf(o)){o=new Headers({Authorization:`Bearer ${r}`,"content-type":"application/json"})}else{o.append("Authorization",`Bearer ${r}`);if(!o.has("content-type")){o.append("content-type","application/json")}}try{if(t?.body){t.body=JSON.stringify(t?.body)}const r=await fetch(`${i||this.domain}/${e}`,{...t,headers:o});if(!n){return r}const a=await(r?.json());const c=await this.isAuthenticatedResponse(r.status,a);if(!c){if(s>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,r,s){const o=await this.isLoggedIn();const a=new URL(e,r??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,...s||{}});if(!i){return l.body}const d=await l.json();return d}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:ne(),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 de={exports:{}};var ue={};
|
|
1
|
+
import{h as e,F as t,r as n,c as i,H as r,a as s}from"./p-0EQQA0nE.js";import{N as o}from"./p-DGwaF706.js";import{N as a}from"./p-dlIPw-hO.js";import{d as c,u as l,t as d,a as u,b as h,g as f,e as p,C as g,L as y,i as w,c as b}from"./p-BW6igRcf.js";import{o as m,v,E as _,N as E}from"./p-CqK6_Oc7.js";import{c as k}from"./p-_i6H-yQH.js";c.extend(l);c.extend(d);class x{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){u("Nylas API Request is not initialized");return null}return this.nylasApiRequest.currentUser()}async getCalendars(){if(!this.nylasApiRequest){u("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,r]=await this.nylasApiRequest.request({method:"GET",path:`calendars?limit=${n}${t?`&page_token=${t}`:""}`});if(r){return h(null,{message:"Error fetching calendars: "+r.message})}if(m(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){u("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(m(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){u("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(m(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){u("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){u("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[r,s]=await this.nylasApiRequest.request({method:"GET",path:`events/${e}?${i.toString()}`});if(s){return h(null,{message:"Error fetching master event: "+s.message})}if(m(r)){return h(null,{message:"Error fetching master event: "+r.error?.message})}const o=this.nylasSchedulerConfigStore.state.masterGroupEvents;if(o[e]){this.nylasSchedulerConfigStore.state.masterGroupEvents[e]=r.data}else{this.nylasSchedulerConfigStore.state.masterGroupEvents={...o,[e]:r.data}}return h(r.data)}async createConfiguration(e){if(!this.nylasApiRequest){u("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(m(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){u("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(m(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){u("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(m(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){u("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(m(n)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error creating group event: "+n.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=n.data;this.invalidateGroupEventsCache();await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(n.data)}async getGroupEvents(e,t){if(!this.nylasApiRequest){u("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 r;let s;if(i){r=i.start_time;s=i.end_time}else{const e=f((new Date).toISOString(),"week");r=e.startTime.toString();s=e.endTime.toString()}const o=`${e}-${r}-${s}`;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",r);n.append("end_time",s);const c=t?.group_booking?.calendar_id;if(c){n.append("calendar_id",c)}const[l,d]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}/group-events?${n.toString()}`});if(d){return h(null,{message:"Error fetching group events: "+d.message})}if(m(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)}invalidateGroupEventsCache(){this.groupEventsCache.clear()}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){u("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,r]=await this.nylasApiRequest.request({method:"PATCH",path:`scheduling/configurations/${t}/group-events/${n}`,body:e});if(r){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error updating group event: "+r.message})}if(m(i)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error updating group event: "+i.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=i.data;this.invalidateGroupEventsCache();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 r=i?.event?.master_event_id;const s=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 d=o?c(o*1e3).subtract(1,"minute").format("YYYYMMDDTHHmmss[Z]"):"";if(t==="this"){return this.updateGroupEventById({...e,id:s,recurrence:r?undefined:e.recurrence},n)}else if(t==="future"&&r){const t=await this.createGroupEvent(e,n);const s={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="+d]:[`RRULE:FREQ=DAILY;UNTIL=${d}`]};await this.updateGroupEventById({...s,id:r},n);return[s,t]}else if(t==="all"){const t=e?.when;const s=i?.event?.when;const o=this.nylasSchedulerConfigStore.state.masterGroupEvents?.[r];let a=o?.when;if(t?.start_time!==s?.start_time){a={...a,start_time:t?.start_time||a?.start_time}}if(t?.end_time!==s?.end_time){a={...a,end_time:t?.end_time||a?.end_time}}if(t?.start_timezone!==s?.start_timezone){a={...a,start_timezone:t?.start_timezone||a?.start_timezone}}if(t?.end_timezone!==s?.end_timezone){a={...a,end_timezone:t?.end_timezone||a?.end_timezone}}return this.updateGroupEventById({...e,when:a,id:r},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 r=i?.event?.master_event_id;const s=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 d=o?c(o*1e3).format("YYYYMMDDTHHmmss[Z]"):"";const u={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="+d]:[`RRULE:UNTIL=${d}`]};if(t==="this"&&s){return this.deleteGroupEventById(s,n)}else if(t==="future"&&r&&s){await this.deleteGroupEventById(s,n);return await this.updateGroupEventById({...u,id:r},n)}else if(t==="all"&&r){return this.deleteGroupEventById(r,n)}this.nylasSchedulerConfigStore.state.isLoading=false;throw new Error("Invalid option")}async deleteGroupEventById(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){u("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[r,s]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${t}/group-events/${e}?calendar_id=${i}`});if(s){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error deleting group event: "+s.message})}if(m(r)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error deleting group event: "+r.error?.message})}this.invalidateGroupEventsCache();await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(r.data)}async importGroupEvent(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){u("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[r,s]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/import-group-events?${n.toString()}`,body:e});if(s){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error importing group event: "+s.message})}if(m(r)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error importing group event: "+r.error?.message})}if(r.data?.imported_events?.length>0){this.invalidateGroupEventsCache();await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration)}this.nylasSchedulerConfigStore.state.isLoading=false;return h(r.data)}}class C{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}init(){u("NylasSchedulerConfigConnector init")}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get schedulerConfig(){if(this._schedulerConfigConnector){return this._schedulerConfigConnector}this._schedulerConfigConnector=new x({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore});return this._schedulerConfigConnector}resetStores(){u("NylasSchedulerConfigConnector resetStores");this.nylasSchedulerConfigStore.reset()}async logout(){u("NylasSchedulerConfigConnector logout");this.resetStores()}}function $(e={}){const t={selectedConfiguration:{},configurations:[],groupEvents:[],listConfigurationsNextCursor:null,calendars:[],currentUser:null,action:null,additionalParticipants:[],requiresSlug:false,masterGroupEvents:{},isLoading:false,...e};const n=k(t);function i(){n.set("selectedConfiguration",{...e["selectedConfiguration"]})}n.onChange("action",(async e=>{if(!e){i()}}));n.onChange("selectedConfiguration",(async e=>{const t=n.state.participantFetch;const i=e?.participants;if(!t||!i?.length)return;const r=i.filter((e=>!e.is_organizer&&!!e.email)).map((e=>e.email));if(r.length===0)return;try{const e=n.state.participantFetchGrantId;const i=await t({emails:r,grantId:e});if(!i?.length)return;const s=n.state.additionalParticipants||[];const o=new Set(s.map((e=>e.email)));const a=i.filter((e=>!o.has(e.email)));if(a.length>0){n.set("additionalParticipants",[...s,...a])}}catch(e){u("[scheduler-config-store] participantFetch failed",e)}}));return{...n,resetSelectedConfiguration:i}}class S{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 T="pkce";const P="grant";const I="user";const R=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 q=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 A{Storage=new S;constructor(e){if(e){this.Storage=e;return}}setPKCE(e){const t=R(e);this.Storage.set(T,t)}async getPKCE(){try{const e=await this.Storage.get(T);if(e){return q(e)}}catch(e){return null}return null}removePKCE(){this.Storage.remove(T)}setGrant(e,t=false){const{grant_id:n}=e;this.Storage.set(`${P}${t?"-"+n:""}`,e)}removeGrant(e,t=false){this.Storage.remove(`${P}${t?"-"+e:""}`)}async getGrant(e,t=false){const n=await this.Storage.get(`${P}${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(I,n)}else{const n=t.map((t=>{if(t.sub===e.sub){t=e}return t}));this.Storage.set(I,n)}}else{this.Storage.set(I,[e])}}async getUserToken(e=""){const t=await this.Storage.get(I);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(I);if(e){return e}return null}removeUserTokens(){this.Storage.remove(I)}async removeUserToken(e){const t=await this.getUserTokens();const n=t?.filter((t=>t.sub!==e));this.Storage.set(I,n)}async clearSession(){const e=await this.getUserTokens();e?.forEach((e=>{this.removeGrant(e.sub)}));this.removePKCE();this.removeUserTokens()}}class U{databaseName="identity-db";storeName="identity";get(e){const t=this;return new Promise(((n,i)=>{t.openDatabase().then((function(r){const s=r.transaction(t.storeName,"readwrite");const o=s.objectStore(t.storeName);const a=o.get(e);a.onsuccess=()=>{n(a.result)};a.onerror=()=>{i(a.error)};s.oncomplete=()=>{r.close()}}))}))}async remove(e){const t=this;return new Promise(((n,i)=>{const r=indexedDB.open(this.databaseName);r.onupgradeneeded=function(e){const n=e.target.result;n.createObjectStore(t.storeName)};r.onerror=()=>{i(r.error)};r.onsuccess=t=>{const r=t.target.result;const s=r.transaction(this.storeName,"readwrite");const o=s.objectStore(this.storeName);const a=o.delete(e);a.onsuccess=()=>{n(null)};a.onerror=()=>{i(a.error)};s.oncomplete=()=>{r.close()}}}))}set(e,t){return new Promise(((n,i)=>{const r=indexedDB.open(this.databaseName);r.onerror=()=>{i(r.error)};r.onupgradeneeded=e=>{const t=e.target.result;t.createObjectStore(this.storeName)};r.onsuccess=r=>{const s=r.target.result;const o=s.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=()=>{s.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 N;var L=new Uint8Array(16);function z(){if(!N){N=typeof crypto!=="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!=="undefined"&&typeof msCrypto.getRandomValues==="function"&&msCrypto.getRandomValues.bind(msCrypto);if(!N){throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported")}}return N(L)}var j=/^(?:[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 O(e){return typeof e==="string"&&j.test(e)}var D=[];for(var F=0;F<256;++F){D.push((F+256).toString(16).substr(1))}function G(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var n=(D[e[t+0]]+D[e[t+1]]+D[e[t+2]]+D[e[t+3]]+"-"+D[e[t+4]]+D[e[t+5]]+"-"+D[e[t+6]]+D[e[t+7]]+"-"+D[e[t+8]]+D[e[t+9]]+"-"+D[e[t+10]]+D[e[t+11]]+D[e[t+12]]+D[e[t+13]]+D[e[t+14]]+D[e[t+15]]).toLowerCase();if(!O(n)){throw TypeError("Stringified UUID is invalid")}return n}function H(e,t,n){e=e||{};var i=e.random||(e.rng||z)();i[6]=i[6]&15|64;i[8]=i[8]&63|128;return G(i)}async function B(e,t){const n=e.getReader();let i;while(!(i=await n.read()).done){t(i.value)}}function M(e){let t;let n;let i;let r=false;return function s(o){if(t===undefined){t=o;n=0;i=-1}else{t=J(t,o)}const a=t.length;let c=0;while(n<a){if(r){if(t[n]===10){c=++n}r=false}let s=-1;for(;n<a&&s===-1;++n){switch(t[n]){case 58:if(i===-1){i=n-c}break;case 13:r=true;case 10:s=n;break}}if(s===-1){break}e(t.subarray(c,s),i);c=n;i=-1}if(c===a){t=undefined}else if(c!==0){t=t.subarray(c);n-=c}}}function Y(e,t,n){let i=W();const r=new TextDecoder;return function s(o,a){if(o.length===0){n===null||n===void 0?void 0:n(i);i=W()}else if(a>0){const n=r.decode(o.subarray(0,a));const s=a+(o[a+1]===32?2:1);const c=r.decode(o.subarray(s));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 J(e,t){const n=new Uint8Array(e.length+t.length);n.set(e);n.set(t,e.length);return n}function W(){return{data:"",event:"",id:"",retry:undefined}}var K=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 r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++){if(t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r]))n[i[r]]=e[i[r]]}return n};const V="text/event-stream";const Q=1e3;const Z="last-event-id";function X(e,t){var{signal:n,headers:i,onopen:r,onmessage:s,onclose:o,onerror:a,openWhenHidden:c,fetch:l}=t,d=K(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise(((t,u)=>{const h=Object.assign({},i);if(!h.accept){h.accept=V}let f;function p(){f.abort();if(!document.hidden){v()}}if(!c){document.addEventListener("visibilitychange",p)}let g=Q;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=r!==null&&r!==void 0?r:ee;async function v(){var n;f=new AbortController;try{const n=await b(e,Object.assign(Object.assign({},d),{headers:h,signal:f.signal}));await m(n);await B(n.body,M(Y((e=>{if(e){h[Z]=e}else{delete h[Z]}}),(e=>{g=e}),s)));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();u(e)}}}}v()}))}function ee(e){const t=e.headers.get("content-type");if(!(t===null||t===void 0?void 0:t.startsWith(V))){throw new Error(`Expected content-type to be ${V}, Actual: ${t}`)}}function te(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function ne(){return Math.floor(Date.now()/1e3)}async function ie(e){const t=(new TextEncoder).encode(e);const n=await crypto.subtle.digest("SHA-256",t);const i=Array.from(new Uint8Array(n));const r=i.map((e=>e.toString(16).padStart(2,"0"))).join("");return r}function re(e){this.message=e}re.prototype=new Error,re.prototype.name="InvalidCharacterError";var se="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new re("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,r=0,s=0,o="";i=t.charAt(s++);~i&&(n=r%4?64*n+i:i,r++%4)?o+=String.fromCharCode(255&n>>(-2*r&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return o};function oe(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(se(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 se(t)}}function ae(e){this.message=e}function ce(e,t){if("string"!=typeof e)throw new ae("Invalid token specified");var n=true===(t=t||{}).header?0:1;try{return JSON.parse(oe(e.split(".")[n]))}catch(e){throw new ae("Invalid token specified: "+e.message)}}ae.prototype=new Error,ae.prototype.name="InvalidTokenError";class le{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 U;this.Storage=new A(e)}else{this.Storage=new A}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 r=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(i){r+=`&code_challenge=${i}&code_challenge_method=S256&options=rotate_refresh_token`}if(n?.provider){r+=`&provider=${n.provider}`}if(n?.email){r+=`&login_hint=${n.email}`}if(t){r+=`&scope=${t.join(" ")}`}return r}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 ie(e);let n=btoa(unescape(encodeURIComponent(t)));n=te(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 r=await i.json();return r}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 r=await i.json();return r}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 r=t.get("error");const s=t.get("error_description");const o=t.get("error_code");if(r&&s&&o){const e={detail:{error:r,error_description:s,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 r=await t.json();if(r){if(r.error){const e={detail:r};window.dispatchEvent(new CustomEvent("onLoginFail",e));return true}const e=await this.handleCodeExchangeResponse(r);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(r){const e={detail:r};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 r=await i.json();if(r){if(r.error){const e={detail:r};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const t=ne();r.expires_in=t+r.expires_in;this.Storage.setGrant(r,this.multiAccount);const n=await this.validateIDToken(e);if(!n){const e={detail:r};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const i={detail:r};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=ne();e.expires_in=n+e.expires_in;this.Storage.setGrant(e,this.multiAccount);const i=ce(e.id_token);i.status="authenticated";this.Storage.setUserToken(i);const r=await this.validateIDToken(i.sub);if(!r){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 r=window.screenY+(window.outerHeight-n)/2.5;const s=`uas-popup`;const o=e;const a=window.open(o,s,`width=${t},height=${n},left=${i},top=${r}`);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=ne();const n=await this.Storage.getGrant(e,this.multiAccount);if(!n){return null}const{access_token:i,expires_in:r}=n;const s=i;if(s){if(r&&r>ne()){const e=r-t;if(e>30){return s}}}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 r="";if(this.multiAccount){if(!i){this.logout();throw new Error("Grant ID is required for multi account calls")}r=await this.getAccessToken(i)}else{r=await this.getAccessToken()}delete n["Grant-ID"];n["Authorization"]=`Bearer ${r}`;if(!n["content-type"]){n["content-type"]="application/json"}return X(`${this.domain}/${e}`,{...t,headers:n})}async fetch(e,t,n=true,i){let r="";let s=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();s=e?e.length:1;r=await this.getAccessToken(t.grant_id)}else{r=await this.getAccessToken()}if(!r){throw new Error("Access token not found")}let o=t.headers;if(!Headers.prototype.isPrototypeOf(o)){o=new Headers({Authorization:`Bearer ${r}`,"content-type":"application/json"})}else{o.append("Authorization",`Bearer ${r}`);if(!o.has("content-type")){o.append("content-type","application/json")}}try{if(t?.body){t.body=JSON.stringify(t?.body)}const r=await fetch(`${i||this.domain}/${e}`,{...t,headers:o});if(!n){return r}const a=await(r?.json());const c=await this.isAuthenticatedResponse(r.status,a);if(!c){if(s>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,r,s){const o=await this.isLoggedIn();const a=new URL(e,r??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,...s||{}});if(!i){return l.body}const d=await l.json();return d}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:ne(),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 de={exports:{}};var ue={};
|
|
2
2
|
/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react.production.min.js
|
|
@@ -7,5 +7,5 @@ import{h as e,F as t,r as n,c as i,H as r,a as s}from"./p-0EQQA0nE.js";import{N
|
|
|
7
7
|
*
|
|
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
|
-
*/var he;function fe(){if(he)return ue;he=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=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"),d=Symbol.for("react.lazy"),u=Symbol.iterator;function h(e){if(null===e||"object"!==typeof e)return null;e=u&&e[u]||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 r,s={},o=null,a=null;if(null!=n)for(r in void 0!==n.ref&&(a=n.ref),void 0!==n.key&&(o=""+n.key),n)_.call(n,r)&&!k.hasOwnProperty(r)&&(s[r]=n[r]);var c=arguments.length-2;if(1===c)s.children=i;else if(1<c){for(var l=Array(c),d=0;d<c;d++)l[d]=arguments[d+2];s.children=l}if(t&&t.defaultProps)for(r in c=t.defaultProps,c)void 0===s[r]&&(s[r]=c[r]);return{$$typeof:e,type:t,key:o,ref:a,props:s,_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 I(n,i,r,s,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=""===s?"."+P(c,0):s,v(o)?(r="",null!=n&&(r=n.replace(T,"$&/")+"/"),I(o,i,r,"",(function(e){return e}))):null!=o&&($(o)&&(o=C(o,r+(!o.key||c&&c.key===o.key?"":(""+o.key).replace(T,"$&/")+"/")+n)),i.push(o)),1;c=0;s=""===s?".":s+":";if(v(n))for(var l=0;l<n.length;l++){a=n[l];var d=s+P(a,l);c+=I(a,i,r,d,o)}else if(d=h(n),"function"===typeof d)for(n=d.call(n),l=0;!(a=n.next()).done;)a=a.value,d=s+P(a,l++),c+=I(a,i,r,d,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 R(e,t,n){if(null==e)return e;var i=[],r=0;I(e,i,"","",(function(e){return t.call(n,e,r++)}));return i}function A(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 q={current:null},U={transition:null},N={ReactCurrentDispatcher:q,ReactCurrentBatchConfig:U,ReactCurrentOwner:E};ue.Children={map:R,forEach:function(e,t,n){R(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;R(e,(function(){t++}));return t},toArray:function(e){return R(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}};ue.Component=y;ue.Fragment=n;ue.Profiler=r;ue.PureComponent=b;ue.StrictMode=i;ue.Suspense=c;ue.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=N;ue.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 r=p({},t.props),s=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&&(s=""+n.key);if(t.type&&t.type.defaultProps)var c=t.type.defaultProps;for(l in n)_.call(n,l)&&!k.hasOwnProperty(l)&&(r[l]=void 0===n[l]&&void 0!==c?c[l]:n[l])}var l=arguments.length-2;if(1===l)r.children=i;else if(1<l){c=Array(l);for(var d=0;d<l;d++)c[d]=arguments[d+2];r.children=c}return{$$typeof:e,type:t.type,key:s,ref:o,props:r,_owner:a}};ue.createContext=function(e){e={$$typeof:o,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null};e.Provider={$$typeof:s,_context:e};return e.Consumer=e};ue.createElement=x;ue.createFactory=function(e){var t=x.bind(null,e);t.type=e;return t};ue.createRef=function(){return{current:null}};ue.forwardRef=function(e){return{$$typeof:a,render:e}};ue.isValidElement=$;ue.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:A}};ue.memo=function(e,t){return{$$typeof:l,type:e,compare:void 0===t?null:t}};ue.startTransition=function(e){var t=U.transition;U.transition={};try{e()}finally{U.transition=t}};ue.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")};ue.useCallback=function(e,t){return q.current.useCallback(e,t)};ue.useContext=function(e){return q.current.useContext(e)};ue.useDebugValue=function(){};ue.useDeferredValue=function(e){return q.current.useDeferredValue(e)};ue.useEffect=function(e,t){return q.current.useEffect(e,t)};ue.useId=function(){return q.current.useId()};ue.useImperativeHandle=function(e,t,n){return q.current.useImperativeHandle(e,t,n)};ue.useInsertionEffect=function(e,t){return q.current.useInsertionEffect(e,t)};ue.useLayoutEffect=function(e,t){return q.current.useLayoutEffect(e,t)};ue.useMemo=function(e,t){return q.current.useMemo(e,t)};ue.useReducer=function(e,t,n){return q.current.useReducer(e,t,n)};ue.useRef=function(e){return q.current.useRef(e)};ue.useState=function(e){return q.current.useState(e)};ue.useSyncExternalStore=function(e,t,n){return q.current.useSyncExternalStore(e,t,n)};ue.useTransition=function(){return q.current.useTransition()};ue.version="18.2.0";return ue}var pe;function ge(){if(pe)return de.exports;pe=1;{de.exports=fe()}return de.exports}ge();const ye=({authenticationUrl:t,authError:n})=>e("div",{class:"login-required",part:"nse__login-required login-component"},e("div",{class:"card",part:"nse__login-required-card"},n&&e("div",{class:"login-error-banner",part:"nse__login-required-error",role:"alert"},e("warning-icon",{width:"16",height:"16"}),e("span",null,n)),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 we({currentUser:n,calendars:i,selectedEventType:r}){const s=i?.find((e=>e.is_primary))||i?.[0];switch(r){case g.one_on_one:case g.max_availability:case g.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:s?.id}),e("nylas-custom-event-slug",{name:"custom-event-slug",exportparts:"nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield"}))}case g.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:s?.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 g.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:s?.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 be=':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 .login-error-banner{display:flex;align-items:center;gap:0.5rem;padding:0.75rem 1rem;margin-bottom:1rem;background-color:var(--nylas-error-50, #fef2f2);border:1px solid var(--nylas-error-200, #fecaca);border-radius:5px;color:var(--nylas-error-700, #b91c1c);font-size:0.875rem;line-height:1.25rem}.login-required .login-error-banner svg{flex-shrink:0;color:var(--nylas-error-500, #ef4444)}.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 me=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.nylasSchedulerEditorError=i(this,"nylasSchedulerEditorError",6);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||y.en;this.langVersion=0;this.version=v;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){const e="Unable to authenticate. API request handler is not initialized.";p(`[nylas-scheduler-editor] ${e}`);this.authError=e;this.nylasSchedulerEditorError.emit({notification:{id:"auth-not-initialized",type:E.Error,title:"Authentication Error",category:_.Auth,description:e,ttl:"none"},host:this.host});return""}try{const t=await this.nylasApiRequest.authenticationUrl({provider:e});if(!t){const e="Unable to get authentication URL. Please check your configuration and try again.";this.authError=e;this.nylasSchedulerEditorError.emit({notification:{id:"auth-url-failed",type:E.Error,title:"Authentication Error",category:_.Auth,description:e,ttl:"none"},host:this.host})}return t||""}catch(e){const t=`Authentication failed: ${e instanceof Error?e.message:"Unknown error"}`;p(`[nylas-scheduler-editor] ${t}`);this.authError=t;this.nylasSchedulerEditorError.emit({notification:{id:"auth-url-exception",type:E.Error,title:"Authentication Error",category:_.Auth,description:t,ttl:"none"},host:this.host});return""}}}connectedCallback(){u(`[nylas-scheduler-editor] connectedCallback`);queueMicrotask((()=>{if(this.themeConfig){this.applyThemeConfig(this.themeConfig);this.host.setAttribute("data-themed","")}}))}async componentWillLoad(){u(`[nylas-scheduler-editor] componentWillLoad`);await Promise.resolve();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:$({...this.defaultSchedulerConfigState,additionalParticipants:e||[],participantFetch:this.participantFetch,participantFetchGrantId:this.participantFetchGrantId,participantSearch:this.participantSearch,conferenceProviders:this.conferenceProviders,requiresSlug:this.requiresSlug,selectedLanguage:this.defaultLanguage||y.en,nylasBranding:this.nylasBranding,experimentalFeatures:this.experimentalFeatures,enableEventTypes:this.enableEventTypes,themeConfig:this.themeConfig})};if(!this.nylasApiRequest&&this.nylasSessionsConfig){const e=new le(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);this.authError="Authentication failed. Please try again.";this.nylasSchedulerEditorError.emit({notification:{id:"auth-login-failed",type:E.Error,title:"Authentication Error",category:_.Auth,description:"Authentication failed. Please try again.",ttl:"none"},host:this.host});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 C({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(){u(`[nylas-scheduler-editor] componentDidLoad`);await(this.baseProvider?.componentDidLoad());this.updateLocalization(this.localization);this.version=v}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)}}participantPropsChanged(){this.stores?.schedulerConfig?.set("participantFetch",this.participantFetch);this.stores?.schedulerConfig?.set("participantFetchGrantId",this.participantFetchGrantId);this.stores?.schedulerConfig?.set("participantSearch",this.participantSearch)}updateLocalization(e){if(!e){return}Object.keys(e).forEach((t=>{if(!(t in y)){return}w.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)}handleChildSchedulerError(e){this.nylasSchedulerEditorError.emit({notification:e.detail.notification,host:this.host})}nylasFormDropdownChangedHandler(e){const{name:t,value:n}=e.detail;if(t==="language"){this.selectedLanguage=y[n];w.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(b).map((e=>({label:b[e],value:e})));const s=this.stores?.schedulerConfig?.state.selectedEventType===g.group||this.stores?.schedulerConfig?.state.selectedConfiguration?.type===g.group;u(`[nylas-scheduler-editor] render mode: ${this.mode}`);return e(r,{key:"bd34e24975197c26bf6e08430c8434c40441c367"},e("div",{key:"5c1bb57eb7dbd13f879dcbe7de251e6d8687c470",class:"scheduler-editor-header",part:"nse__header"},e("h1",{key:"ecf284b9c4c39129233c977b978d8069e448367e",class:"scheduler-editor-title",part:"nse__title"},e("calendar-icon",{key:"44b73dbff4441d72ceda5281f6bf07bfb2134dae",width:"18",height:"18"}),w.t("schedulerEditorTitle"),e("tooltip-component",{key:"bc20294846164811db22d185e52f50f848d59bd5"},e("info-icon",{key:"22955828856eae5f4f7e5d7d51e8e73f11f9805d",slot:"tooltip-icon"}),e("span",{key:"9178f588fa8ffe60865b8c6c632ec4dafd91a00d",slot:"tooltip-content"},this.version))),e("div",{key:"a67874094ff69226349d1ee0274e27da0da38ad6",class:{language:true},part:"nse__language"},e("select-dropdown",{key:"e47566a2f832d90baa93701afe8efea71476ecec",name:"language",searchPlaceholder:w.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:"1c7c9d93808786f7e4a1b5ecee414e289074366f",slot:"select-icon"},e("translate-icon",{key:"c9b8adee3195f4a50f0ed7c4929b972e59236558",width:"20",height:"20"})))),e("button",{key:"fe8c5481fbd2ac6da51fe1420caf973d79d01857",class:"scheduler-editor-close",title:"logout",onClick:e=>this.handleSchedulerConfigCloseClicked(e),part:"nse__close-button"},e("close-icon",{key:"ead618a2acc222ff1ec4ca9c552cd81a8c86a57f",width:"18",height:"18"}))),e("div",{key:"dffa964669c0b5ca0155ddd3b351a6bb164f7463",class:{"scheduler-editor-content":true,"scheduler-editor-content--group":s},part:"nse__content"},this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action===null&&this.mode==="composable"&&e("slot",{key:"bf58230869a3326fa9cf6ee8b7c18586cc41a074"}),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action===null&&this.mode!=="composable"&&e("div",{key:"edb06ecb33d8f3713da228d70fa72d3db2183235",class:"list-configurations",part:"nse__list-configurations"},e("nylas-list-configurations",{key:"ffdcd2304ce49e29aa74da69bad90af9d237a6e8",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:"a5bff89ece1dd30afea1c014d162797bfa7d1df5",themeConfig:this.themeConfig}),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="create"&&s&&e("nylas-editor-tabs-group",{key:"08241ae21a7df72079cc49312b4272d2a8cd0b2a",mode:"composable",themeConfig:this.themeConfig},e(we,{key:"86d73811907bfe16c255642fb0755baa9766cf00",selectedEventType:this.stores?.schedulerConfig?.state?.selectedEventType||g.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"&&!s&&e("nylas-editor-tabs",{key:"5b85bf26f6243f723a1f0cad821d719cff3f776b",mode:"composable",enableNotetaker:this.enableNotetaker,themeConfig:this.themeConfig},e(we,{key:"5afa9f82b0cb0b495d26b134688c49d82743d7cf",selectedEventType:this.stores?.schedulerConfig?.state?.selectedEventType||g.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"&&s&&e("nylas-editor-tabs-group",{key:n,mode:this.mode,themeConfig:this.themeConfig},this.mode==="composable"&&e("slot",{key:"6ec0c1b4daad2d875f8f3cdbb465eb0721133947"}),this.mode==="app"&&t&&e("div",{style:{display:"none"},slot:"custom-page-style-inputs",key:n},e("slot",{key:"b3c580772253a6a7d5dc3e7f8fd2be2f9a23f247",name:"custom-page-style-inputs"}))),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="edit"&&!s&&e("nylas-editor-tabs",{key:n,mode:this.mode,enableNotetaker:this.enableNotetaker,themeConfig:this.themeConfig},this.mode==="composable"&&e("slot",{key:"48a71a45b5271485a4f136cb4afa52df94ee469b"}),this.mode==="app"&&t&&e("div",{style:{display:"none"},slot:"custom-page-style-inputs",key:n},e("slot",{key:"f81fede8cc3d3686056e5222798494fdc76d419f",name:"custom-page-style-inputs"}))),!this.stores?.schedulerConfig?.state.currentUser&&e("slot",{key:"968207fdadd383d6da1e8188d0960901e38e949d",name:"login-required"},e(ye,{key:"e0c275ef713bd4040c07083898918d1b8e39e171",authenticationUrl:this.authenticationUrl,authError:this.authError}))))}get host(){return s(this)}static get watchers(){return{configurationId:["configurationIdChanged"],participantFetch:["participantPropsChanged"],participantFetchGrantId:["participantPropsChanged"],participantSearch:["participantPropsChanged"],localization:["updateLocalization"],nylasBranding:["updateNylasBranding"],experimentalFeatures:["updateExperimentalFeatures"],enableEventTypes:["updateEnableEventTypes"],themeConfig:["themeConfigChanged"]}}};me.style=be;export{me as nylas_scheduler_editor};
|
|
11
|
-
//# sourceMappingURL=p-
|
|
10
|
+
*/var he;function fe(){if(he)return ue;he=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=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"),d=Symbol.for("react.lazy"),u=Symbol.iterator;function h(e){if(null===e||"object"!==typeof e)return null;e=u&&e[u]||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 r,s={},o=null,a=null;if(null!=n)for(r in void 0!==n.ref&&(a=n.ref),void 0!==n.key&&(o=""+n.key),n)_.call(n,r)&&!k.hasOwnProperty(r)&&(s[r]=n[r]);var c=arguments.length-2;if(1===c)s.children=i;else if(1<c){for(var l=Array(c),d=0;d<c;d++)l[d]=arguments[d+2];s.children=l}if(t&&t.defaultProps)for(r in c=t.defaultProps,c)void 0===s[r]&&(s[r]=c[r]);return{$$typeof:e,type:t,key:o,ref:a,props:s,_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 I(n,i,r,s,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=""===s?"."+P(c,0):s,v(o)?(r="",null!=n&&(r=n.replace(T,"$&/")+"/"),I(o,i,r,"",(function(e){return e}))):null!=o&&($(o)&&(o=C(o,r+(!o.key||c&&c.key===o.key?"":(""+o.key).replace(T,"$&/")+"/")+n)),i.push(o)),1;c=0;s=""===s?".":s+":";if(v(n))for(var l=0;l<n.length;l++){a=n[l];var d=s+P(a,l);c+=I(a,i,r,d,o)}else if(d=h(n),"function"===typeof d)for(n=d.call(n),l=0;!(a=n.next()).done;)a=a.value,d=s+P(a,l++),c+=I(a,i,r,d,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 R(e,t,n){if(null==e)return e;var i=[],r=0;I(e,i,"","",(function(e){return t.call(n,e,r++)}));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},U={transition:null},N={ReactCurrentDispatcher:A,ReactCurrentBatchConfig:U,ReactCurrentOwner:E};ue.Children={map:R,forEach:function(e,t,n){R(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;R(e,(function(){t++}));return t},toArray:function(e){return R(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}};ue.Component=y;ue.Fragment=n;ue.Profiler=r;ue.PureComponent=b;ue.StrictMode=i;ue.Suspense=c;ue.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=N;ue.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 r=p({},t.props),s=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&&(s=""+n.key);if(t.type&&t.type.defaultProps)var c=t.type.defaultProps;for(l in n)_.call(n,l)&&!k.hasOwnProperty(l)&&(r[l]=void 0===n[l]&&void 0!==c?c[l]:n[l])}var l=arguments.length-2;if(1===l)r.children=i;else if(1<l){c=Array(l);for(var d=0;d<l;d++)c[d]=arguments[d+2];r.children=c}return{$$typeof:e,type:t.type,key:s,ref:o,props:r,_owner:a}};ue.createContext=function(e){e={$$typeof:o,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null};e.Provider={$$typeof:s,_context:e};return e.Consumer=e};ue.createElement=x;ue.createFactory=function(e){var t=x.bind(null,e);t.type=e;return t};ue.createRef=function(){return{current:null}};ue.forwardRef=function(e){return{$$typeof:a,render:e}};ue.isValidElement=$;ue.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:q}};ue.memo=function(e,t){return{$$typeof:l,type:e,compare:void 0===t?null:t}};ue.startTransition=function(e){var t=U.transition;U.transition={};try{e()}finally{U.transition=t}};ue.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")};ue.useCallback=function(e,t){return A.current.useCallback(e,t)};ue.useContext=function(e){return A.current.useContext(e)};ue.useDebugValue=function(){};ue.useDeferredValue=function(e){return A.current.useDeferredValue(e)};ue.useEffect=function(e,t){return A.current.useEffect(e,t)};ue.useId=function(){return A.current.useId()};ue.useImperativeHandle=function(e,t,n){return A.current.useImperativeHandle(e,t,n)};ue.useInsertionEffect=function(e,t){return A.current.useInsertionEffect(e,t)};ue.useLayoutEffect=function(e,t){return A.current.useLayoutEffect(e,t)};ue.useMemo=function(e,t){return A.current.useMemo(e,t)};ue.useReducer=function(e,t,n){return A.current.useReducer(e,t,n)};ue.useRef=function(e){return A.current.useRef(e)};ue.useState=function(e){return A.current.useState(e)};ue.useSyncExternalStore=function(e,t,n){return A.current.useSyncExternalStore(e,t,n)};ue.useTransition=function(){return A.current.useTransition()};ue.version="18.2.0";return ue}var pe;function ge(){if(pe)return de.exports;pe=1;{de.exports=fe()}return de.exports}ge();const ye=({authenticationUrl:t,authError:n})=>e("div",{class:"login-required",part:"nse__login-required login-component"},e("div",{class:"card",part:"nse__login-required-card"},n&&e("div",{class:"login-error-banner",part:"nse__login-required-error",role:"alert"},e("warning-icon",{width:"16",height:"16"}),e("span",null,n)),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 we({currentUser:n,calendars:i,selectedEventType:r}){const s=i?.find((e=>e.is_primary))||i?.[0];switch(r){case g.one_on_one:case g.max_availability:case g.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:s?.id}),e("nylas-custom-event-slug",{name:"custom-event-slug",exportparts:"nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield"}))}case g.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:s?.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 g.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:s?.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 be=':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 .login-error-banner{display:flex;align-items:center;gap:0.5rem;padding:0.75rem 1rem;margin-bottom:1rem;background-color:var(--nylas-error-50, #fef2f2);border:1px solid var(--nylas-error-200, #fecaca);border-radius:5px;color:var(--nylas-error-700, #b91c1c);font-size:0.875rem;line-height:1.25rem}.login-required .login-error-banner svg{flex-shrink:0;color:var(--nylas-error-500, #ef4444)}.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 me=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.nylasSchedulerEditorError=i(this,"nylasSchedulerEditorError",6);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||y.en;this.langVersion=0;this.version=v;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){const e="Unable to authenticate. API request handler is not initialized.";p(`[nylas-scheduler-editor] ${e}`);this.authError=e;this.nylasSchedulerEditorError.emit({notification:{id:"auth-not-initialized",type:E.Error,title:"Authentication Error",category:_.Auth,description:e,ttl:"none"},host:this.host});return""}try{const t=await this.nylasApiRequest.authenticationUrl({provider:e});if(!t){const e="Unable to get authentication URL. Please check your configuration and try again.";this.authError=e;this.nylasSchedulerEditorError.emit({notification:{id:"auth-url-failed",type:E.Error,title:"Authentication Error",category:_.Auth,description:e,ttl:"none"},host:this.host})}return t||""}catch(e){const t=`Authentication failed: ${e instanceof Error?e.message:"Unknown error"}`;p(`[nylas-scheduler-editor] ${t}`);this.authError=t;this.nylasSchedulerEditorError.emit({notification:{id:"auth-url-exception",type:E.Error,title:"Authentication Error",category:_.Auth,description:t,ttl:"none"},host:this.host});return""}}}connectedCallback(){u(`[nylas-scheduler-editor] connectedCallback`);queueMicrotask((()=>{if(this.themeConfig){this.applyThemeConfig(this.themeConfig);this.host.setAttribute("data-themed","")}}))}async componentWillLoad(){u(`[nylas-scheduler-editor] componentWillLoad`);await Promise.resolve();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:$({...this.defaultSchedulerConfigState,additionalParticipants:e||[],participantFetch:this.participantFetch,participantFetchGrantId:this.participantFetchGrantId,participantSearch:this.participantSearch,conferenceProviders:this.conferenceProviders,requiresSlug:this.requiresSlug,selectedLanguage:this.defaultLanguage||y.en,nylasBranding:this.nylasBranding,experimentalFeatures:this.experimentalFeatures,enableEventTypes:this.enableEventTypes,themeConfig:this.themeConfig})};if(!this.nylasApiRequest&&this.nylasSessionsConfig){const e=new le(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);this.authError="Authentication failed. Please try again.";this.nylasSchedulerEditorError.emit({notification:{id:"auth-login-failed",type:E.Error,title:"Authentication Error",category:_.Auth,description:"Authentication failed. Please try again.",ttl:"none"},host:this.host});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 C({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(){u(`[nylas-scheduler-editor] componentDidLoad`);await(this.baseProvider?.componentDidLoad());this.updateLocalization(this.localization);this.version=v}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)}}participantPropsChanged(){this.stores?.schedulerConfig?.set("participantFetch",this.participantFetch);this.stores?.schedulerConfig?.set("participantFetchGrantId",this.participantFetchGrantId);this.stores?.schedulerConfig?.set("participantSearch",this.participantSearch)}updateLocalization(e){if(!e){return}Object.keys(e).forEach((t=>{if(!(t in y)){return}w.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)}handleChildSchedulerError(e){this.nylasSchedulerEditorError.emit({notification:e.detail.notification,host:this.host})}nylasFormDropdownChangedHandler(e){const{name:t,value:n}=e.detail;if(t==="language"){this.selectedLanguage=y[n];w.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(b).map((e=>({label:b[e],value:e})));const s=this.stores?.schedulerConfig?.state.selectedEventType===g.group||this.stores?.schedulerConfig?.state.selectedConfiguration?.type===g.group;u(`[nylas-scheduler-editor] render mode: ${this.mode}`);return e(r,{key:"bd34e24975197c26bf6e08430c8434c40441c367"},e("div",{key:"5c1bb57eb7dbd13f879dcbe7de251e6d8687c470",class:"scheduler-editor-header",part:"nse__header"},e("h1",{key:"ecf284b9c4c39129233c977b978d8069e448367e",class:"scheduler-editor-title",part:"nse__title"},e("calendar-icon",{key:"44b73dbff4441d72ceda5281f6bf07bfb2134dae",width:"18",height:"18"}),w.t("schedulerEditorTitle"),e("tooltip-component",{key:"bc20294846164811db22d185e52f50f848d59bd5"},e("info-icon",{key:"22955828856eae5f4f7e5d7d51e8e73f11f9805d",slot:"tooltip-icon"}),e("span",{key:"9178f588fa8ffe60865b8c6c632ec4dafd91a00d",slot:"tooltip-content"},this.version))),e("div",{key:"a67874094ff69226349d1ee0274e27da0da38ad6",class:{language:true},part:"nse__language"},e("select-dropdown",{key:"e47566a2f832d90baa93701afe8efea71476ecec",name:"language",searchPlaceholder:w.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:"1c7c9d93808786f7e4a1b5ecee414e289074366f",slot:"select-icon"},e("translate-icon",{key:"c9b8adee3195f4a50f0ed7c4929b972e59236558",width:"20",height:"20"})))),e("button",{key:"fe8c5481fbd2ac6da51fe1420caf973d79d01857",class:"scheduler-editor-close",title:"logout",onClick:e=>this.handleSchedulerConfigCloseClicked(e),part:"nse__close-button"},e("close-icon",{key:"ead618a2acc222ff1ec4ca9c552cd81a8c86a57f",width:"18",height:"18"}))),e("div",{key:"dffa964669c0b5ca0155ddd3b351a6bb164f7463",class:{"scheduler-editor-content":true,"scheduler-editor-content--group":s},part:"nse__content"},this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action===null&&this.mode==="composable"&&e("slot",{key:"bf58230869a3326fa9cf6ee8b7c18586cc41a074"}),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action===null&&this.mode!=="composable"&&e("div",{key:"edb06ecb33d8f3713da228d70fa72d3db2183235",class:"list-configurations",part:"nse__list-configurations"},e("nylas-list-configurations",{key:"ffdcd2304ce49e29aa74da69bad90af9d237a6e8",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:"a5bff89ece1dd30afea1c014d162797bfa7d1df5",themeConfig:this.themeConfig}),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="create"&&s&&e("nylas-editor-tabs-group",{key:"08241ae21a7df72079cc49312b4272d2a8cd0b2a",mode:"composable",themeConfig:this.themeConfig},e(we,{key:"86d73811907bfe16c255642fb0755baa9766cf00",selectedEventType:this.stores?.schedulerConfig?.state?.selectedEventType||g.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"&&!s&&e("nylas-editor-tabs",{key:"5b85bf26f6243f723a1f0cad821d719cff3f776b",mode:"composable",enableNotetaker:this.enableNotetaker,themeConfig:this.themeConfig},e(we,{key:"5afa9f82b0cb0b495d26b134688c49d82743d7cf",selectedEventType:this.stores?.schedulerConfig?.state?.selectedEventType||g.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"&&s&&e("nylas-editor-tabs-group",{key:n,mode:this.mode,themeConfig:this.themeConfig},this.mode==="composable"&&e("slot",{key:"6ec0c1b4daad2d875f8f3cdbb465eb0721133947"}),this.mode==="app"&&t&&e("div",{style:{display:"none"},slot:"custom-page-style-inputs",key:n},e("slot",{key:"b3c580772253a6a7d5dc3e7f8fd2be2f9a23f247",name:"custom-page-style-inputs"}))),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="edit"&&!s&&e("nylas-editor-tabs",{key:n,mode:this.mode,enableNotetaker:this.enableNotetaker,themeConfig:this.themeConfig},this.mode==="composable"&&e("slot",{key:"48a71a45b5271485a4f136cb4afa52df94ee469b"}),this.mode==="app"&&t&&e("div",{style:{display:"none"},slot:"custom-page-style-inputs",key:n},e("slot",{key:"f81fede8cc3d3686056e5222798494fdc76d419f",name:"custom-page-style-inputs"}))),!this.stores?.schedulerConfig?.state.currentUser&&e("slot",{key:"968207fdadd383d6da1e8188d0960901e38e949d",name:"login-required"},e(ye,{key:"e0c275ef713bd4040c07083898918d1b8e39e171",authenticationUrl:this.authenticationUrl,authError:this.authError}))))}get host(){return s(this)}static get watchers(){return{configurationId:["configurationIdChanged"],participantFetch:["participantPropsChanged"],participantFetchGrantId:["participantPropsChanged"],participantSearch:["participantPropsChanged"],localization:["updateLocalization"],nylasBranding:["updateNylasBranding"],experimentalFeatures:["updateExperimentalFeatures"],enableEventTypes:["updateEnableEventTypes"],themeConfig:["themeConfigChanged"]}}};me.style=be;export{me as nylas_scheduler_editor};
|
|
11
|
+
//# sourceMappingURL=p-196717a0.entry.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var n=(n=>(n.Error="error",n.Warning="warning",n.Info="info",n.Success="success",n))(n||{});const o=n=>n!==null&&typeof n=="object"&&"error"in n;var i;(function(n){n["Error"]="error";n["Warning"]="warning";n["Info"]="info";n["Success"]="success"})(i||(i={}));var e;(function(n){n["Component"]="component";n["Api"]="api";n["Auth"]="auth"})(e||(e={}));var t;(function(n){n["endtime_not_in_future"]="endtime_not_in_future";n["no_booking_info"]="no_booking_info";n["no_timeslot_selected"]="no_timeslot_selected";n["no_timezone_selected"]="no_timezone_selected";n["no_booking_id"]="no_booking_id";n["no_salt"]="no_salt";n["invalid_start_time"]="invalid_start_time";n["invalid_end_time"]="invalid_end_time";n["invalid_timezone"]="invalid_timezone";n["no_config_id"]="no_config_id"})(t||(t={}));const _="2.5.
|
|
2
|
-
//# sourceMappingURL=p-
|
|
1
|
+
var n=(n=>(n.Error="error",n.Warning="warning",n.Info="info",n.Success="success",n))(n||{});const o=n=>n!==null&&typeof n=="object"&&"error"in n;var i;(function(n){n["Error"]="error";n["Warning"]="warning";n["Info"]="info";n["Success"]="success"})(i||(i={}));var e;(function(n){n["Component"]="component";n["Api"]="api";n["Auth"]="auth"})(e||(e={}));var t;(function(n){n["endtime_not_in_future"]="endtime_not_in_future";n["no_booking_info"]="no_booking_info";n["no_timeslot_selected"]="no_timeslot_selected";n["no_timezone_selected"]="no_timezone_selected";n["no_booking_id"]="no_booking_id";n["no_salt"]="no_salt";n["invalid_start_time"]="invalid_start_time";n["invalid_end_time"]="invalid_end_time";n["invalid_timezone"]="invalid_timezone";n["no_config_id"]="no_config_id"})(t||(t={}));const _="2.5.5";export{e as E,i as N,o,n as u,_ as v};
|
|
2
|
+
//# sourceMappingURL=p-CqK6_Oc7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p-DDixcvI0.js","sources":["../nylas-js-core/dist/index.es.js","src/types/index.ts","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 interface NylasResponse<Data = any> {\n request_id: string;\n data?: Data;\n error?: {\n message: string;\n type: string;\n };\n}\n\n// Avaliability\nexport interface OpenHours {\n days: number[];\n exDates: string[];\n timezone: string;\n start: string;\n end: string;\n}\n\nexport interface SpecificTimeAvailability {\n date: string;\n start: string;\n end: string;\n}\n\nexport interface MeetingBuffer {\n before: number;\n after: number;\n}\n\n// Scheduling\nexport interface UpdateConfiguration extends Omit<Configuration, 'id'> {}\n\nexport interface ParticipantAvailability {\n calendar_ids: string[];\n open_hours?: OpenHours[];\n}\n\nexport type NylasSchedulerBookingParticipant = { name: string; email: string; nameReadOnly?: boolean; emailReadOnly?: boolean };\n\nexport type NylasSchedulerBookingData = {\n primaryParticipant: NylasSchedulerBookingParticipant;\n startTime?: Date;\n endTime?: Date;\n timezone?: string;\n language?: string;\n guests?: NylasSchedulerBookingParticipant[];\n additionalFields?: Record<\n string,\n {\n value: string;\n type?: string;\n readOnly?: boolean;\n }\n >;\n};\n\nexport type OpenHour = {\n days: number[]; // [1, 2, 3, 4, 5]\n start: string; // \"09:00\"\n end: string; // \"17:00\"\n timezone: string; // \"America/Los_Angeles\"\n};\n\nexport type Timeslot = {\n start_time: Date;\n end_time: Date;\n emails?: string[];\n capacity?: number;\n event_id?: string;\n master_id?: string;\n calendar_id?: string;\n};\n\nexport type ThemeConfig = Partial<{\n '--nylas-primary': string;\n '--nylas-info': string;\n '--nylas-success': string;\n '--nylas-warning': string;\n '--nylas-error': string;\n '--nylas-error-pressed': string;\n '--nylas-base-0': string;\n '--nylas-base-25': string;\n '--nylas-base-50': string;\n '--nylas-base-100': string;\n '--nylas-base-200': string;\n '--nylas-base-300': string;\n '--nylas-base-400': string;\n '--nylas-base-500': string;\n '--nylas-base-600': string;\n '--nylas-base-700': string;\n '--nylas-base-800': string;\n '--nylas-base-900': string;\n '--nylas-base-950': string;\n '--nylas-color-blue-50': string;\n '--nylas-color-blue-100': string;\n '--nylas-color-blue-300': string;\n '--nylas-color-blue-500': string;\n '--nylas-color-blue-700': string;\n '--nylas-color-blue-900': string;\n '--nylas-color-red-50': string;\n '--nylas-color-red-100': string;\n '--nylas-color-red-300': string;\n '--nylas-color-red-500': string;\n '--nylas-color-red-700': string;\n '--nylas-color-red-900': string;\n '--nylas-color-green-50': string;\n '--nylas-color-green-100': string;\n '--nylas-color-green-300': string;\n '--nylas-color-green-500': string;\n '--nylas-color-green-700': string;\n '--nylas-color-green-900': string;\n '--nylas-color-yellow-50': string;\n '--nylas-color-yellow-100': string;\n '--nylas-color-yellow-300': string;\n '--nylas-color-yellow-500': string;\n '--nylas-color-yellow-700': string;\n '--nylas-color-yellow-900': string;\n '--nylas-color-purple-50': string;\n '--nylas-color-purple-100': string;\n '--nylas-color-purple-300': string;\n '--nylas-color-purple-500': string;\n '--nylas-color-purple-700': string;\n '--nylas-color-purple-900': string;\n '--nylas-color-sky-50': string;\n '--nylas-color-sky-100': string;\n '--nylas-color-sky-300': string;\n '--nylas-color-sky-500': string;\n '--nylas-color-sky-700': string;\n '--nylas-color-sky-900': string;\n '--nylas-color-black': string;\n '--nylas-color-grey-900': string;\n '--nylas-color-grey-800': string;\n '--nylas-color-grey-700': string;\n '--nylas-color-grey-600': string;\n '--nylas-color-grey-500': string;\n '--nylas-color-grey-400': string;\n '--nylas-color-grey-300': string;\n '--nylas-color-grey-200': string;\n '--nylas-color-grey-100': string;\n '--nylas-color-grey-50': string;\n '--nylas-color-white': string;\n '--nylas-font-family': string;\n '--nylas-font-size': string;\n '--nylas-border-radius': string;\n '--nylas-border-radius-2x': string;\n '--nylas-border-radius-3x': string;\n}>;\n\nexport enum NotificationType {\n Error = 'error',\n Warning = 'warning',\n Info = 'info',\n Success = 'success',\n}\n\nexport type Notification = {\n id: string;\n type: NotificationType;\n title: string;\n code?: number;\n category: string;\n description?: string;\n ttl?: number | 'none';\n};\n\nexport type BookingType = 'booking' | 'organizer-confirmation' | 'custom-confirmation';\n\nexport type AvailabilityMethod = 'max-fairness' | 'max-availability' | 'collective';\n\nexport type ConferenceProvider = 'GoogleMeetConferenceProvider' | 'MicrosoftTeamsConferenceProvider' | 'ZoomConferenceProvider' | 'OnlineMeetingProviderMicrosoftTeams';\n\nexport type ReminderMethod = 'email' | 'webhook';\n\nexport interface Rules {\n availability_method: AvailabilityMethod;\n buffer: MeetingBuffer;\n default_open_hours: OpenHours[];\n round_robin_group_id: string;\n}\n\nexport interface ConferenceDetail {\n meeting_code?: string; // zoom, GTM, microsoft teams\n password?: string; // zoom, webex\n url?: string; // zoom, webex, GTM, meet, microsoft teams\n pin?: string; // webex, meet\n phone?: string[]; // GTM, meet, microsoft teams\n}\n\nexport interface Conference {\n provider?: ConferenceProvider;\n details?: ConferenceDetail;\n autocreate?: { [key: string]: any };\n}\n\nexport interface ParticipantBooking {\n calendar_id: string;\n}\n\nexport interface Participant {\n email: string;\n name?: string;\n is_organizer?: boolean;\n availability?: ParticipantAvailability;\n booking?: ParticipantBooking;\n specific_time_availability?: SpecificTimeAvailability[];\n timezone?: string;\n}\n\nexport interface EventReminder {\n type: ReminderMethod;\n minutes_before_event: number;\n recipient?: string;\n email_subject?: string;\n}\n\nexport interface Availability {\n duration_minutes: number;\n interval_minutes?: number;\n round_to?: number;\n availability_rules?: Rules;\n}\n\nexport interface NotetakerActionItemsSettings {\n custom_instructions?: string;\n}\n\nexport interface NotetakerSummarySettings {\n custom_instructions?: string;\n}\n\nexport interface NotetakerMeetingSettings {\n action_items?: boolean;\n action_items_settings?: NotetakerActionItemsSettings;\n audio_recording?: boolean;\n summary?: boolean;\n summary_settings?: NotetakerSummarySettings;\n transcription?: boolean;\n video_recording?: boolean;\n}\n\nexport interface Notetaker {\n visible?: boolean; // default is false\n enabled?: boolean; // default is false\n name?: string;\n meeting_settings?: NotetakerMeetingSettings;\n}\n\nexport interface EventBooking {\n title: string;\n description?: string;\n location?: string;\n timezone?: string;\n booking_type: BookingType;\n conferencing?: Conference;\n hide_participants?: boolean;\n disable_emails?: boolean;\n reminders?: EventReminder[];\n notetaker?: Notetaker;\n}\n\nexport interface Appearance {\n color?: string;\n submit_button_label?: string;\n thank_you_message?: string;\n company_logo_url?: string;\n}\n\nexport interface Scheduler {\n available_days_in_future?: number;\n min_cancellation_notice: number;\n min_booking_notice?: number;\n rescheduling_url?: string;\n cancellation_url?: string;\n organizer_confirmation_url?: string;\n cancellation_policy?: string;\n hide_additional_guests?: boolean;\n hide_cancellation_options?: boolean;\n hide_rescheduling_options?: boolean;\n additional_fields?: Record<string, AdditionalFields>;\n email_template?: EmailTemplate;\n confirmation_redirect_url?: string;\n}\nexport interface AdditionalFields {\n type: string;\n required: boolean;\n order: number;\n options?: string[];\n label?: string;\n default?: string;\n}\n\nexport interface EmailTemplate {\n logo: string;\n booking_confirmed: BookingConfirmed;\n show_nylas_branding: boolean;\n organizer_locale: string;\n}\n\nexport interface BookingConfirmed {\n title: string;\n body: string;\n}\n\nexport interface Configuration {\n id: string;\n version: string;\n type?: string;\n requires_session_auth?: boolean;\n participants: Participant[];\n availability: Availability;\n event_booking: EventBooking;\n scheduler: Partial<Scheduler>;\n slug: string;\n appearance: Appearance;\n name: string;\n}\n\nexport interface GroupBooking {\n booking_type: BookingType; // Only 'booking' is supported\n disable_emails?: boolean;\n reminders?: EventReminder[];\n conferencing?: Conference;\n calendar_id: string;\n default_capacity: number;\n}\n\nexport interface GroupConfiguration {\n id: string;\n name: string;\n slug: string;\n requires_session_auth?: boolean;\n type: 'group';\n group_booking: GroupBooking;\n scheduler: Scheduler;\n appearance: Appearance;\n}\n\nexport interface Creator {\n name: string;\n email: string;\n}\nexport interface AdditionalParticipant {\n name: string;\n email: string;\n grant_id?: string;\n calendars: {\n id: string;\n name: string;\n object?: 'calendar';\n is_primary?: boolean;\n is_owned_by_user?: boolean;\n read_only?: boolean;\n timezone?: string;\n }[];\n}\n\n/**\n * Parameters for fetching participant info when loading an existing config for edit.\n * Used when the config has participants (emails) but full AdditionalParticipant\n * data (calendars, etc.) needs to be fetched from an external source.\n */\nexport interface ParticipantFetchParams {\n /** Emails of participants to fetch full info for */\n emails: string[];\n /** Optional grant ID to scope the fetch (e.g. for multi-account) */\n grantId?: string;\n}\n\n/**\n * Callback to fetch full participant info by emails.\n * Called when loading an existing config for edit.\n */\nexport type ParticipantFetch = (params: ParticipantFetchParams) => Promise<AdditionalParticipant[]>;\n\n/**\n * Callback to search participants by query (for autocomplete).\n */\nexport type ParticipantSearch = (query: string) => Promise<AdditionalParticipant[]>;\n\nexport interface GroupEvent {\n id?: string;\n title: string;\n busy: boolean;\n participants: NylasSchedulerBookingParticipant[];\n resources: {\n name: string;\n email: string;\n }[];\n description: string;\n when: {\n start_time: number;\n end_time: number;\n start_timezone?: string;\n end_timezone?: string;\n };\n location: string;\n recurrence: string[];\n capacity: number;\n}\n\nexport type RecurrenceUpdateOption = 'this' | 'future' | 'all';\nexport type RecurrenceDeleteOption = 'this' | 'future' | 'all';\n\nexport type Snapshot = {\n busy: boolean;\n calendar_id: string;\n hide_participants: boolean;\n ical_uid: string;\n organizer: {\n name: string;\n email: string;\n };\n participants: {\n email: string;\n status: string;\n }[];\n resources: any[];\n read_only: boolean;\n recurrence: string[];\n reminders: {\n use_default: boolean;\n overrides: any[];\n };\n title: string;\n description?: string;\n location?: string;\n conferencing?: Conference;\n visibility: string;\n creator: {\n name: string;\n email: string;\n };\n html_link: string;\n grant_id: string;\n id: string;\n object: string;\n status: string;\n when: {\n start_timezone: string;\n end_timezone: string;\n object: string;\n start_time: number; // Unix timestamp\n end_time: number; // Unix timestamp\n };\n created_at: number; // Unix timestamp\n updated_at: number; // Unix timestamp\n};\n\nexport interface GroupEventAPIData {\n event: EventDetails;\n group_event_info?: GroupEventInfo;\n}\n\nexport type EventDetails = {\n busy: boolean;\n calendar_id: string;\n conferencing: {\n provider: ConferenceProvider;\n details: {\n meeting_code: string;\n url: string;\n pin: string;\n phone: string[];\n };\n };\n hide_participants: boolean;\n ical_uid: string;\n organizer: {\n name: string;\n email: string;\n };\n participants: Array<{\n email: string;\n status: 'yes' | 'no' | 'noreply';\n comment?: string;\n }>;\n resources: string[];\n read_only: boolean;\n reminders: {\n use_default: boolean;\n overrides: Array<{\n method?: string;\n minutes?: number;\n }>;\n };\n title: string;\n description?: string;\n location?: string;\n visibility: 'default' | 'public' | 'private';\n creator: {\n name: string;\n email: string;\n };\n html_link: string;\n master_event_id: string;\n color_id: string;\n grant_id: string;\n id: string;\n object: 'event';\n status: 'confirmed' | 'tentative' | 'cancelled';\n when: {\n start_timezone: string;\n end_timezone: string;\n object: 'timespan';\n start_time: number;\n end_time: number;\n };\n created_at: number;\n updated_at: number;\n original_start_time: number;\n};\n\nexport type GroupEventInfo = {\n event_id: string;\n calendar_id: string;\n master_id: string;\n config_id: string;\n capacity: number;\n type: 'updated_event' | 'single_event' | 'master_event';\n booked: boolean;\n finished: boolean;\n participants: Array<{\n email: string;\n is_organizer: boolean;\n name: string;\n timezone: string;\n }>;\n snapshot: any | null;\n snapshot_expires_at: number;\n rrule: string[] | null;\n exceptions: {\n event_id: string;\n capacity: number;\n participants: Array<{\n email: string;\n is_organizer: boolean;\n name: string;\n timezone: string;\n }>;\n }[];\n};\n\nexport type ImportGroupEventDetails = {\n event_id: string;\n calendar_id: string;\n capacity: number;\n participants: Participant[];\n organizer: {\n name: string;\n email: string;\n };\n};\n\nexport type ImportGroupEventResponse = {\n imported_events: string[];\n import_failed: {\n event_id: string;\n reason: string;\n }[];\n};\n\nexport enum ErrorCategory {\n Component = 'component',\n Api = 'api',\n Auth = 'auth',\n}\n\nexport interface ErrorDetails {\n title: string;\n message: string;\n category: ErrorCategory;\n}\n\nexport enum ComponentErrorType {\n endtime_not_in_future = 'endtime_not_in_future',\n no_booking_info = 'no_booking_info',\n no_timeslot_selected = 'no_timeslot_selected',\n no_timezone_selected = 'no_timezone_selected',\n no_booking_id = 'no_booking_id',\n no_salt = 'no_salt',\n invalid_start_time = 'invalid_start_time',\n invalid_end_time = 'invalid_end_time',\n invalid_timezone = 'invalid_timezone',\n no_config_id = 'no_config_id',\n}\n\nexport interface KeyPoint {\n time: number;\n text: string;\n active?: boolean;\n}\n","export const version = '2.5.4';\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;;ICgJpH;AAAZ,CAAA,UAAY,gBAAgB,EAAA;AAC1B,IAAA,gBAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,gBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,gBAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,gBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACrB,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,GAK3B,EAAA,CAAA,CAAA;IAwZW;AAAZ,CAAA,UAAY,aAAa,EAAA;AACvB,IAAA,aAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,aAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,aAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACf,CAAC,EAJW,aAAa,KAAb,aAAa,GAIxB,EAAA,CAAA,CAAA;AAQD,IAAY,kBAWX;AAXD,CAAA,UAAY,kBAAkB,EAAA;AAC5B,IAAA,kBAAA,CAAA,uBAAA,CAAA,GAAA,uBAA+C;AAC/C,IAAA,kBAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC;AACnC,IAAA,kBAAA,CAAA,sBAAA,CAAA,GAAA,sBAA6C;AAC7C,IAAA,kBAAA,CAAA,sBAAA,CAAA,GAAA,sBAA6C;AAC7C,IAAA,kBAAA,CAAA,eAAA,CAAA,GAAA,eAA+B;AAC/B,IAAA,kBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,kBAAA,CAAA,oBAAA,CAAA,GAAA,oBAAyC;AACzC,IAAA,kBAAA,CAAA,kBAAA,CAAA,GAAA,kBAAqC;AACrC,IAAA,kBAAA,CAAA,kBAAA,CAAA,GAAA,kBAAqC;AACrC,IAAA,kBAAA,CAAA,cAAA,CAAA,GAAA,cAA6B;AAC/B,CAAC,EAXW,kBAAkB,KAAlB,kBAAkB,GAW7B,EAAA,CAAA,CAAA;;ACxkBM,MAAM,OAAO,GAAG;;;;"}
|
|
1
|
+
{"version":3,"file":"p-CqK6_Oc7.js","sources":["../nylas-js-core/dist/index.es.js","src/types/index.ts","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 interface NylasResponse<Data = any> {\n request_id: string;\n data?: Data;\n error?: {\n message: string;\n type: string;\n };\n}\n\n// Avaliability\nexport interface OpenHours {\n days: number[];\n exDates: string[];\n timezone: string;\n start: string;\n end: string;\n}\n\nexport interface SpecificTimeAvailability {\n date: string;\n start: string;\n end: string;\n}\n\nexport interface MeetingBuffer {\n before: number;\n after: number;\n}\n\n// Scheduling\nexport interface UpdateConfiguration extends Omit<Configuration, 'id'> {}\n\nexport interface ParticipantAvailability {\n calendar_ids: string[];\n open_hours?: OpenHours[];\n}\n\nexport type NylasSchedulerBookingParticipant = { name: string; email: string; nameReadOnly?: boolean; emailReadOnly?: boolean };\n\nexport type NylasSchedulerBookingData = {\n primaryParticipant: NylasSchedulerBookingParticipant;\n startTime?: Date;\n endTime?: Date;\n timezone?: string;\n language?: string;\n guests?: NylasSchedulerBookingParticipant[];\n additionalFields?: Record<\n string,\n {\n value: string;\n type?: string;\n readOnly?: boolean;\n }\n >;\n};\n\nexport type OpenHour = {\n days: number[]; // [1, 2, 3, 4, 5]\n start: string; // \"09:00\"\n end: string; // \"17:00\"\n timezone: string; // \"America/Los_Angeles\"\n};\n\nexport type Timeslot = {\n start_time: Date;\n end_time: Date;\n emails?: string[];\n capacity?: number;\n event_id?: string;\n master_id?: string;\n calendar_id?: string;\n};\n\nexport type ThemeConfig = Partial<{\n '--nylas-primary': string;\n '--nylas-info': string;\n '--nylas-success': string;\n '--nylas-warning': string;\n '--nylas-error': string;\n '--nylas-error-pressed': string;\n '--nylas-base-0': string;\n '--nylas-base-25': string;\n '--nylas-base-50': string;\n '--nylas-base-100': string;\n '--nylas-base-200': string;\n '--nylas-base-300': string;\n '--nylas-base-400': string;\n '--nylas-base-500': string;\n '--nylas-base-600': string;\n '--nylas-base-700': string;\n '--nylas-base-800': string;\n '--nylas-base-900': string;\n '--nylas-base-950': string;\n '--nylas-color-blue-50': string;\n '--nylas-color-blue-100': string;\n '--nylas-color-blue-300': string;\n '--nylas-color-blue-500': string;\n '--nylas-color-blue-700': string;\n '--nylas-color-blue-900': string;\n '--nylas-color-red-50': string;\n '--nylas-color-red-100': string;\n '--nylas-color-red-300': string;\n '--nylas-color-red-500': string;\n '--nylas-color-red-700': string;\n '--nylas-color-red-900': string;\n '--nylas-color-green-50': string;\n '--nylas-color-green-100': string;\n '--nylas-color-green-300': string;\n '--nylas-color-green-500': string;\n '--nylas-color-green-700': string;\n '--nylas-color-green-900': string;\n '--nylas-color-yellow-50': string;\n '--nylas-color-yellow-100': string;\n '--nylas-color-yellow-300': string;\n '--nylas-color-yellow-500': string;\n '--nylas-color-yellow-700': string;\n '--nylas-color-yellow-900': string;\n '--nylas-color-purple-50': string;\n '--nylas-color-purple-100': string;\n '--nylas-color-purple-300': string;\n '--nylas-color-purple-500': string;\n '--nylas-color-purple-700': string;\n '--nylas-color-purple-900': string;\n '--nylas-color-sky-50': string;\n '--nylas-color-sky-100': string;\n '--nylas-color-sky-300': string;\n '--nylas-color-sky-500': string;\n '--nylas-color-sky-700': string;\n '--nylas-color-sky-900': string;\n '--nylas-color-black': string;\n '--nylas-color-grey-900': string;\n '--nylas-color-grey-800': string;\n '--nylas-color-grey-700': string;\n '--nylas-color-grey-600': string;\n '--nylas-color-grey-500': string;\n '--nylas-color-grey-400': string;\n '--nylas-color-grey-300': string;\n '--nylas-color-grey-200': string;\n '--nylas-color-grey-100': string;\n '--nylas-color-grey-50': string;\n '--nylas-color-white': string;\n '--nylas-font-family': string;\n '--nylas-font-size': string;\n '--nylas-border-radius': string;\n '--nylas-border-radius-2x': string;\n '--nylas-border-radius-3x': string;\n}>;\n\nexport enum NotificationType {\n Error = 'error',\n Warning = 'warning',\n Info = 'info',\n Success = 'success',\n}\n\nexport type Notification = {\n id: string;\n type: NotificationType;\n title: string;\n code?: number;\n category: string;\n description?: string;\n ttl?: number | 'none';\n};\n\nexport type BookingType = 'booking' | 'organizer-confirmation' | 'custom-confirmation';\n\nexport type AvailabilityMethod = 'max-fairness' | 'max-availability' | 'collective';\n\nexport type ConferenceProvider = 'GoogleMeetConferenceProvider' | 'MicrosoftTeamsConferenceProvider' | 'ZoomConferenceProvider' | 'OnlineMeetingProviderMicrosoftTeams';\n\nexport type ReminderMethod = 'email' | 'webhook';\n\nexport interface Rules {\n availability_method: AvailabilityMethod;\n buffer: MeetingBuffer;\n default_open_hours: OpenHours[];\n round_robin_group_id: string;\n}\n\nexport interface ConferenceDetail {\n meeting_code?: string; // zoom, GTM, microsoft teams\n password?: string; // zoom, webex\n url?: string; // zoom, webex, GTM, meet, microsoft teams\n pin?: string; // webex, meet\n phone?: string[]; // GTM, meet, microsoft teams\n}\n\nexport interface Conference {\n provider?: ConferenceProvider;\n details?: ConferenceDetail;\n autocreate?: { [key: string]: any };\n}\n\nexport interface ParticipantBooking {\n calendar_id: string;\n}\n\nexport interface Participant {\n email: string;\n name?: string;\n is_organizer?: boolean;\n availability?: ParticipantAvailability;\n booking?: ParticipantBooking;\n specific_time_availability?: SpecificTimeAvailability[];\n timezone?: string;\n}\n\nexport interface EventReminder {\n type: ReminderMethod;\n minutes_before_event: number;\n recipient?: string;\n email_subject?: string;\n}\n\nexport interface Availability {\n duration_minutes: number;\n interval_minutes?: number;\n round_to?: number;\n availability_rules?: Rules;\n}\n\nexport interface NotetakerActionItemsSettings {\n custom_instructions?: string;\n}\n\nexport interface NotetakerSummarySettings {\n custom_instructions?: string;\n}\n\nexport interface NotetakerMeetingSettings {\n action_items?: boolean;\n action_items_settings?: NotetakerActionItemsSettings;\n audio_recording?: boolean;\n summary?: boolean;\n summary_settings?: NotetakerSummarySettings;\n transcription?: boolean;\n video_recording?: boolean;\n}\n\nexport interface Notetaker {\n visible?: boolean; // default is false\n enabled?: boolean; // default is false\n name?: string;\n meeting_settings?: NotetakerMeetingSettings;\n}\n\nexport interface EventBooking {\n title: string;\n description?: string;\n location?: string;\n timezone?: string;\n booking_type: BookingType;\n conferencing?: Conference;\n hide_participants?: boolean;\n disable_emails?: boolean;\n reminders?: EventReminder[];\n notetaker?: Notetaker;\n}\n\nexport interface Appearance {\n color?: string;\n submit_button_label?: string;\n thank_you_message?: string;\n company_logo_url?: string;\n}\n\nexport interface Scheduler {\n available_days_in_future?: number;\n min_cancellation_notice: number;\n min_booking_notice?: number;\n rescheduling_url?: string;\n cancellation_url?: string;\n organizer_confirmation_url?: string;\n cancellation_policy?: string;\n hide_additional_guests?: boolean;\n hide_cancellation_options?: boolean;\n hide_rescheduling_options?: boolean;\n additional_fields?: Record<string, AdditionalFields>;\n email_template?: EmailTemplate;\n confirmation_redirect_url?: string;\n}\nexport interface AdditionalFields {\n type: string;\n required: boolean;\n order: number;\n options?: string[];\n label?: string;\n default?: string;\n}\n\nexport interface EmailTemplate {\n logo: string;\n booking_confirmed: BookingConfirmed;\n show_nylas_branding: boolean;\n organizer_locale: string;\n}\n\nexport interface BookingConfirmed {\n title: string;\n body: string;\n}\n\nexport interface Configuration {\n id: string;\n version: string;\n type?: string;\n requires_session_auth?: boolean;\n participants: Participant[];\n availability: Availability;\n event_booking: EventBooking;\n scheduler: Partial<Scheduler>;\n slug: string;\n appearance: Appearance;\n name: string;\n}\n\nexport interface GroupBooking {\n booking_type: BookingType; // Only 'booking' is supported\n disable_emails?: boolean;\n reminders?: EventReminder[];\n conferencing?: Conference;\n calendar_id: string;\n default_capacity: number;\n}\n\nexport interface GroupConfiguration {\n id: string;\n name: string;\n slug: string;\n requires_session_auth?: boolean;\n type: 'group';\n group_booking: GroupBooking;\n scheduler: Scheduler;\n appearance: Appearance;\n}\n\nexport interface Creator {\n name: string;\n email: string;\n}\nexport interface AdditionalParticipant {\n name: string;\n email: string;\n grant_id?: string;\n calendars: {\n id: string;\n name: string;\n object?: 'calendar';\n is_primary?: boolean;\n is_owned_by_user?: boolean;\n read_only?: boolean;\n timezone?: string;\n }[];\n}\n\n/**\n * Parameters for fetching participant info when loading an existing config for edit.\n * Used when the config has participants (emails) but full AdditionalParticipant\n * data (calendars, etc.) needs to be fetched from an external source.\n */\nexport interface ParticipantFetchParams {\n /** Emails of participants to fetch full info for */\n emails: string[];\n /** Optional grant ID to scope the fetch (e.g. for multi-account) */\n grantId?: string;\n}\n\n/**\n * Callback to fetch full participant info by emails.\n * Called when loading an existing config for edit.\n */\nexport type ParticipantFetch = (params: ParticipantFetchParams) => Promise<AdditionalParticipant[]>;\n\n/**\n * Callback to search participants by query (for autocomplete).\n */\nexport type ParticipantSearch = (query: string) => Promise<AdditionalParticipant[]>;\n\nexport interface GroupEvent {\n id?: string;\n title: string;\n busy: boolean;\n participants: NylasSchedulerBookingParticipant[];\n resources: {\n name: string;\n email: string;\n }[];\n description: string;\n when: {\n start_time: number;\n end_time: number;\n start_timezone?: string;\n end_timezone?: string;\n };\n location: string;\n recurrence: string[];\n capacity: number;\n}\n\nexport type RecurrenceUpdateOption = 'this' | 'future' | 'all';\nexport type RecurrenceDeleteOption = 'this' | 'future' | 'all';\n\nexport type Snapshot = {\n busy: boolean;\n calendar_id: string;\n hide_participants: boolean;\n ical_uid: string;\n organizer: {\n name: string;\n email: string;\n };\n participants: {\n email: string;\n status: string;\n }[];\n resources: any[];\n read_only: boolean;\n recurrence: string[];\n reminders: {\n use_default: boolean;\n overrides: any[];\n };\n title: string;\n description?: string;\n location?: string;\n conferencing?: Conference;\n visibility: string;\n creator: {\n name: string;\n email: string;\n };\n html_link: string;\n grant_id: string;\n id: string;\n object: string;\n status: string;\n when: {\n start_timezone: string;\n end_timezone: string;\n object: string;\n start_time: number; // Unix timestamp\n end_time: number; // Unix timestamp\n };\n created_at: number; // Unix timestamp\n updated_at: number; // Unix timestamp\n};\n\nexport interface GroupEventAPIData {\n event: EventDetails;\n group_event_info?: GroupEventInfo;\n}\n\nexport type EventDetails = {\n busy: boolean;\n calendar_id: string;\n conferencing: {\n provider: ConferenceProvider;\n details: {\n meeting_code: string;\n url: string;\n pin: string;\n phone: string[];\n };\n };\n hide_participants: boolean;\n ical_uid: string;\n organizer: {\n name: string;\n email: string;\n };\n participants: Array<{\n email: string;\n status: 'yes' | 'no' | 'noreply';\n comment?: string;\n }>;\n resources: string[];\n read_only: boolean;\n reminders: {\n use_default: boolean;\n overrides: Array<{\n method?: string;\n minutes?: number;\n }>;\n };\n title: string;\n description?: string;\n location?: string;\n visibility: 'default' | 'public' | 'private';\n creator: {\n name: string;\n email: string;\n };\n html_link: string;\n master_event_id: string;\n color_id: string;\n grant_id: string;\n id: string;\n object: 'event';\n status: 'confirmed' | 'tentative' | 'cancelled';\n when: {\n start_timezone: string;\n end_timezone: string;\n object: 'timespan';\n start_time: number;\n end_time: number;\n };\n created_at: number;\n updated_at: number;\n original_start_time: number;\n};\n\nexport type GroupEventInfo = {\n event_id: string;\n calendar_id: string;\n master_id: string;\n config_id: string;\n capacity: number;\n type: 'updated_event' | 'single_event' | 'master_event';\n booked: boolean;\n finished: boolean;\n participants: Array<{\n email: string;\n is_organizer: boolean;\n name: string;\n timezone: string;\n }>;\n snapshot: any | null;\n snapshot_expires_at: number;\n rrule: string[] | null;\n exceptions: {\n event_id: string;\n capacity: number;\n participants: Array<{\n email: string;\n is_organizer: boolean;\n name: string;\n timezone: string;\n }>;\n }[];\n};\n\nexport type ImportGroupEventDetails = {\n event_id: string;\n calendar_id: string;\n capacity: number;\n participants: Participant[];\n organizer: {\n name: string;\n email: string;\n };\n};\n\nexport type ImportGroupEventResponse = {\n imported_events: string[];\n import_failed: {\n event_id: string;\n reason: string;\n }[];\n};\n\nexport enum ErrorCategory {\n Component = 'component',\n Api = 'api',\n Auth = 'auth',\n}\n\nexport interface ErrorDetails {\n title: string;\n message: string;\n category: ErrorCategory;\n}\n\nexport enum ComponentErrorType {\n endtime_not_in_future = 'endtime_not_in_future',\n no_booking_info = 'no_booking_info',\n no_timeslot_selected = 'no_timeslot_selected',\n no_timezone_selected = 'no_timezone_selected',\n no_booking_id = 'no_booking_id',\n no_salt = 'no_salt',\n invalid_start_time = 'invalid_start_time',\n invalid_end_time = 'invalid_end_time',\n invalid_timezone = 'invalid_timezone',\n no_config_id = 'no_config_id',\n}\n\nexport interface KeyPoint {\n time: number;\n text: string;\n active?: boolean;\n}\n","export const version = '2.5.5';\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;;ICgJpH;AAAZ,CAAA,UAAY,gBAAgB,EAAA;AAC1B,IAAA,gBAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,gBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,gBAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,gBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACrB,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,GAK3B,EAAA,CAAA,CAAA;IAwZW;AAAZ,CAAA,UAAY,aAAa,EAAA;AACvB,IAAA,aAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,aAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,aAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACf,CAAC,EAJW,aAAa,KAAb,aAAa,GAIxB,EAAA,CAAA,CAAA;AAQD,IAAY,kBAWX;AAXD,CAAA,UAAY,kBAAkB,EAAA;AAC5B,IAAA,kBAAA,CAAA,uBAAA,CAAA,GAAA,uBAA+C;AAC/C,IAAA,kBAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC;AACnC,IAAA,kBAAA,CAAA,sBAAA,CAAA,GAAA,sBAA6C;AAC7C,IAAA,kBAAA,CAAA,sBAAA,CAAA,GAAA,sBAA6C;AAC7C,IAAA,kBAAA,CAAA,eAAA,CAAA,GAAA,eAA+B;AAC/B,IAAA,kBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,kBAAA,CAAA,oBAAA,CAAA,GAAA,oBAAyC;AACzC,IAAA,kBAAA,CAAA,kBAAA,CAAA,GAAA,kBAAqC;AACrC,IAAA,kBAAA,CAAA,kBAAA,CAAA,GAAA,kBAAqC;AACrC,IAAA,kBAAA,CAAA,cAAA,CAAA,GAAA,cAA6B;AAC/B,CAAC,EAXW,kBAAkB,KAAlB,kBAAkB,GAW7B,EAAA,CAAA,CAAA;;ACxkBM,MAAM,OAAO,GAAG;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as t,l as e,m as n,o}from"./p-BW6igRcf.js";function i(t,e){if(t===e)return true;if(t==null||e==null)return false;if(typeof t!=="object"||typeof e!=="object")return false;if(t instanceof Date&&e instanceof Date){return t.getTime()===e.getTime()}if(t instanceof Date||e instanceof Date){return false}if(t instanceof RegExp&&e instanceof RegExp){return t.source===e.source&&t.flags===e.flags}if(t instanceof RegExp||e instanceof RegExp){return false}if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return false;for(const[n,o]of t){if(!e.has(n)||!i(o,e.get(n)))return false}return true}if(t instanceof Map||e instanceof Map){return false}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return false;for(const n of t){if(!e.has(n))return false}return true}if(t instanceof Set||e instanceof Set){return false}if(Array.isArray(t)!==Array.isArray(e))return false;if(Array.isArray(t)){if(t.length!==e.length)return false;for(let n=0;n<t.length;n++){if(!i(t[n],e[n]))return false}return true}const n=Object.keys(t);const o=Object.keys(e);if(n.length!==o.length)return false;for(const s of n){if(!o.includes(s))return false;if(!i(t[s],e[s]))return false}return true}class s{constructor(e,n,o=true,i){this.automaticComponentRegistration=true;this.registeredComponents={};this.propStateRegistrations=new Map;this.eventListenerRegistrations=new Map;this.propUpdateQueue=new Map;this.propUpdateScheduled=false;this.host=e;this.stores=n;this.automaticComponentRegistration=o;this.eventOverrides=i;t(`[${this.hostTagName}] Initializing (abstract) provider.`,{eventOverrides:i});this.registerComponent=this.registerComponent.bind(this);this.getStore=this.getStore.bind(this);Object.keys(this.stores).forEach((t=>{this.propStateRegistrations.set(t,new Map)}))}async componentWillLoad(e){t(`[${this.hostTagName}] Will load`);this.setupStoreListeners();this.nylasConnector=e;const n=Array.from(this.host.querySelectorAll("*")).filter((t=>t.tagName.toLowerCase().startsWith("nylas-")));t(`[${this.hostTagName}] Found ${n.length} child component(s).`,{childComponents:n});const o=n.map((async e=>{const n=e;if(!n){t(`[~${this.hostTagName}] (componentWillLoad) Component ${n.tagName} does not have a name. Skipping.`);return}if(!n.registerNylasComponent){t(`[~${this.hostTagName}] (componentWillLoad) Component ${n.tagName} is not a component that can be registered. Skipping.`,{component:n});return}const o={element:n,name:n.tagName.toLowerCase(),getStoresToProp:n.getStoresToProp,storeToProps:n.storeToProps,stateToProps:n.stateToProps,authToProp:n.authToProp,eventToProps:n.eventToProps,connectorToProp:n.connectorToProp,localPropsToProp:n.localPropsToProp};await this.registerComponent(o)}));await Promise.all(o)}async componentDidLoad(){t(`[~${this.hostTagName}] (componentDidLoad) Did load`)}async componentDisconnected(){Object.values(this.stores).forEach((t=>{t.dispose()}))}async registerComponentHandler(e){e.stopPropagation();if(!this.automaticComponentRegistration){t(`~[${this.hostTagName}] (registerComponentHandler) Automatic component registration disabled. Skipping registration of ${e.detail.name}.`);return}await this.registerComponent(e.detail)}async unregisterComponentHandler(e){e.stopPropagation();if(!this.automaticComponentRegistration){t(`~[${this.hostTagName}] (unregisterComponentHandler) Automatic component registration disabled. Skipping unregistration of ${e.detail.name}.`);return}this.unregisterComponent(e.detail)}async registerComponent(i){t(`~[${this.hostTagName}] (registerComponent) Registering component ${i.name}.`);const s=i.element.dataset.nylasId;const r=s&&this.registeredComponents[s];if(r){t(`[${this.hostTagName}] (registerComponent) Component ${i.name} already registered. Updating registration.`);this.cleanupComponentRegistration(s,false)}else{const t=e()?this.computeDeterministicId(i.element):undefined;i.element.dataset.nylasId=s||t||n()}const a=i.element.dataset.nylasId;if(a){this.registeredComponents[a]=i}t(`[${this.hostTagName}] (registerComponent) Waiting for "${i.element.localName}" component to be defined`,{component:i});try{await customElements.whenDefined(i.element.tagName.toLowerCase());t(`[${this.hostTagName}] (registerComponent) Component "${i.element.localName}" is now defined`);if(typeof i.element.componentOnReady==="function"){try{await i.element.componentOnReady();t(`[${this.hostTagName}] (registerComponent) Component "${i.element.localName}" is now ready`)}catch(e){t(`[${this.hostTagName}] (registerComponent) Error waiting for component "${i.element.localName}" to be ready:`,e)}}else{await new Promise((t=>{const e=()=>{if(i.element.classList?.contains("hydrated")){t()}else{setTimeout((()=>{if(i.element.classList?.contains("hydrated")){t()}else{t()}}),10)}};e()}))}}catch(e){t(`[${this.hostTagName}] (registerComponent) Error waiting for component "${i.element.localName}" to be defined:`,e)}const p=this.eventOverrides;const{stateToProps:c,getStoresToProp:f,eventToProps:h,storeToProps:u,connectorToProp:$,localPropsToProp:l,element:g}=i;h?.forEach(((e,n)=>{const s=this.nylasConnector;const r=async o=>{t(`[${this.hostTagName}] (registerComponent) Handling "${i.name}" prop "${String(n)}" event.`,{event:o});if(n in p){t(`[${this.hostTagName}] (registerComponent) Found event override for "${String(n)}" event. Calling override.`);await p[n](o,s)}if(!o.defaultPrevented){await e(o,s)}return};const a=i.element.dataset.nylasId;if(a&&!this.eventListenerRegistrations.has(a)){this.eventListenerRegistrations.set(a,[])}if(a){this.eventListenerRegistrations.get(a)?.push([g,n,r])}t(`[${this.hostTagName}] (registerComponent) Setting "${i.name}" event "${String(n)}" to automcially call NylasConnector method.`);const c=o(n.toString());t(`[${this.hostTagName}] (registerComponent) Adding event listener for "${c}" on "${g.tagName}"`);g.addEventListener(c,r)}));c?.forEach(((e,n)=>{const[o,s]=n.split(".");const r=this.getStore(o);const a=r.state[s];if(!g.dataset.nylasId){t(`[${this.hostTagName}] (registerComponent) Component "${i.name}" not registered. Skipping.`,{component:i});return}if(!this.propStateRegistrations.has(o)){this.propStateRegistrations.set(o,new Map)}if(!this.propStateRegistrations.get(o)?.has(s)){this.propStateRegistrations.get(o)?.set(s,[{elementId:g.dataset.nylasId,propKey:e}])}else{this.propStateRegistrations.get(o)?.get(s)?.push({elementId:g.dataset.nylasId,propKey:e})}g[e.toString()]=a;t(`[${this.hostTagName}] Setting "${i.name}" prop "${e.toString()}" to "${n}" value.`,{stateValue:a})}));l?.forEach(((e,n)=>{const o=this.host[n];g[e.toString()]=o;t(`[${this.hostTagName}] Setting "${i.name}" prop "${e.toString()}" to the value of "${n}" value.`,{value:n,mappedPropValue:o})}));if(f){g[f?.toString()]=this.getStore;t(`[${this.hostTagName}] Setting "${i.name}" prop "${f.toString()}" to "getStore" method.`)}u?.forEach(((e,n)=>{const o=this.getStore(n);g[e.toString()]=o;t(`[${this.hostTagName}] Setting "${i.name}" prop "${e.toString()}" to "${n}" store.`,{store:o})}));if($){g[$?.toString()]=this.nylasConnector;t(`[${this.hostTagName}] Setting "${i.name}" prop "${$.toString()}" to "nylasConnector" value.`,{connectorToProp:$})}if(typeof g.registerCallback==="function"){t(`[${this.hostTagName}] (registerComponent) Calling registerCallback method for "${i.name}".`);await g.registerCallback()}t(`[${this.hostTagName}] (registerComponent) Component ${i.name} registered.`)}computeDeterministicId(t){const e=t.getAttribute("id");if(e&&e.trim().length>0)return e.trim();const n=t.getAttribute("name");if(n&&n.trim().length>0)return n.trim();const o=t.tagName.toLowerCase();try{const e=Array.from(this.host?.querySelectorAll(o)||[]);const n=e.indexOf(t);const i=n>=0?n+1:e.length+1;return`${o}-${i}`}catch(t){return`${o}-1`}}cleanupComponentRegistration(e,n=true){const i=this.eventListenerRegistrations.get(e);if(i){i.forEach((([e,n,i])=>{const s=o(n.toString());t(`[${this.hostTagName}] (cleanupComponentRegistration) Removing event listener for "${s}" on "${e.tagName}"`);e.removeEventListener(s,i)}));this.eventListenerRegistrations.delete(e)}this.propStateRegistrations.forEach(((t,n)=>{t.forEach(((t,o)=>{const i=t.filter((t=>t.elementId!==e));if(i.length!==t.length){this.propStateRegistrations.get(n)?.set(o,i)}}))}));if(n){delete this.registeredComponents[e]}}unregisterComponent(e){t(`[${this.hostTagName}] Unregistering component ${e.name}.`);const n=e.element.dataset.nylasId;if(!n){t(`[${this.hostTagName}] (unregisterComponent) Unregistering component ${e.name}.`);return}if(this.registeredComponents[n]){t(`[${this.hostTagName}] (unregisterComponent) Component ${e.name} not registered. Skipping.`);return}this.propStateRegistrations.forEach(((t,e)=>{t.forEach(((t,o)=>{const i=this.propStateRegistrations.get(e)?.get(o);const s=i?.filter((t=>t.elementId!==n));if(s){this.propStateRegistrations.get(e)?.set(o,s)}}))}));const i=this.eventListenerRegistrations.get(n);i?.forEach((([e,n,i])=>{const s=o(n.toString());t(`[${this.hostTagName}] (unregisterComponent) Removing event listener for "${s}" on "${e.tagName}"`);e.removeEventListener(s,i)}));delete this.registeredComponents[n]}getStore(t){const e=this.stores[t];if(!e){throw new Error(`[${this.hostTagName}] Store "${t.toString()}" not found.`)}return e}async setupStoreListeners(){const e=this;Object.entries(this.stores).forEach((([n,o])=>{t(`[${e.hostTagName}] (setupStoreListeners) Listening for changes in "${n}" store.`);o.use({set(o,s,r){t(`[${e.hostTagName}] (setupStoreListeners) Store "${n}" state "${o.toString()}" changed`,{newValue:s,oldValue:r});if(i(s,r)){t(`[${e.hostTagName}] (setupStoreListeners) Store "${n}" state "${o.toString()}" unchanged. Skipping.`);return}const a=e.registeredComponents;if(!a){t(`[${e.hostTagName}] (setupStoreListeners) No registered components found. Skipping.`);return}const p=e.propStateRegistrations.get(n)?.get(o.toString())||[];t(`[${e.hostTagName}] (setupStoreListeners) Found ${p.length} prop(s) registered for "${o.toString()}" store.`,{props:p,propStateRegistrations:e.propStateRegistrations});const c=e.getStore(n);const f=c.state[o];p.forEach((({elementId:n,propKey:i})=>{const s=a[n];if(!s){t(`[${e.hostTagName}] (setupStoreListeners) Component "${n}" not found. Skipping.`,{component:s});return}e.queuePropUpdate(n,i.toString(),f);t(`[${e.hostTagName}] (setupStoreListeners) Queued "${s.name}" prop "${i.toString()}" update for "${o.toString()}" value.`,{stateValue:f})}))}})}))}queuePropUpdate(t,e,n){if(!this.propUpdateQueue.has(t)){this.propUpdateQueue.set(t,new Map)}this.propUpdateQueue.get(t).set(e,n);if(!this.propUpdateScheduled){this.propUpdateScheduled=true;Promise.resolve().then((()=>{this.flushPropUpdates()}))}}flushPropUpdates(){this.propUpdateScheduled=false;const e=new Map(this.propUpdateQueue);this.propUpdateQueue.clear();e.forEach(((e,n)=>{const o=this.registeredComponents[n];if(!o){t(`[${this.hostTagName}] (flushPropUpdates) Component "${n}" not found. Skipping.`);return}e.forEach(((e,n)=>{o.element[n]=e;t(`[${this.hostTagName}] (flushPropUpdates) Setting "${o.name}" prop "${n}" to batched value.`,{value:e})}))}))}get hostTagName(){return this.host?.tagName?.toLowerCase()??"nylas-provider"}}class r extends s{}export{r as N};
|
|
2
|
-
//# sourceMappingURL=p
|
|
1
|
+
import{a as t,l as e,m as n,o}from"./p-BW6igRcf.js";function i(t,e){if(t===e)return true;if(t==null||e==null)return false;if(typeof t!=="object"||typeof e!=="object")return false;if(t instanceof Date&&e instanceof Date){return t.getTime()===e.getTime()}if(t instanceof Date||e instanceof Date){return false}if(t instanceof RegExp&&e instanceof RegExp){return t.source===e.source&&t.flags===e.flags}if(t instanceof RegExp||e instanceof RegExp){return false}if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return false;for(const[n,o]of t){if(!e.has(n)||!i(o,e.get(n)))return false}return true}if(t instanceof Map||e instanceof Map){return false}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return false;for(const n of t){if(!e.has(n))return false}return true}if(t instanceof Set||e instanceof Set){return false}if(Array.isArray(t)!==Array.isArray(e))return false;if(Array.isArray(t)){if(t.length!==e.length)return false;for(let n=0;n<t.length;n++){if(!i(t[n],e[n]))return false}return true}const n=Object.keys(t);const o=Object.keys(e);if(n.length!==o.length)return false;for(const s of n){if(!o.includes(s))return false;if(!i(t[s],e[s]))return false}return true}class s{constructor(e,n,o=true,i){this.automaticComponentRegistration=true;this.registeredComponents={};this.propStateRegistrations=new Map;this.eventListenerRegistrations=new Map;this.propUpdateQueue=new Map;this.propUpdateScheduled=false;this.host=e;this.stores=n;this.automaticComponentRegistration=o;this.eventOverrides=i;t(`[${this.hostTagName}] Initializing (abstract) provider.`,{eventOverrides:i});this.registerComponent=this.registerComponent.bind(this);this.getStore=this.getStore.bind(this);Object.keys(this.stores).forEach((t=>{this.propStateRegistrations.set(t,new Map)}))}async componentWillLoad(e){t(`[${this.hostTagName}] Will load`);this.setupStoreListeners();this.nylasConnector=e;const n=Array.from(this.host.querySelectorAll("*")).filter((t=>t.tagName.toLowerCase().startsWith("nylas-")));t(`[${this.hostTagName}] Found ${n.length} child component(s).`,{childComponents:n});const o=n.map((async e=>{const n=e;if(!n){t(`[~${this.hostTagName}] (componentWillLoad) Component ${n.tagName} does not have a name. Skipping.`);return}if(!n.registerNylasComponent){t(`[~${this.hostTagName}] (componentWillLoad) Component ${n.tagName} is not a component that can be registered. Skipping.`,{component:n});return}const o={element:n,name:n.tagName.toLowerCase(),getStoresToProp:n.getStoresToProp,storeToProps:n.storeToProps,stateToProps:n.stateToProps,authToProp:n.authToProp,eventToProps:n.eventToProps,connectorToProp:n.connectorToProp,localPropsToProp:n.localPropsToProp};await this.registerComponent(o)}));await Promise.all(o)}async componentDidLoad(){t(`[~${this.hostTagName}] (componentDidLoad) Did load`)}async componentDisconnected(){Object.values(this.stores).forEach((t=>{t.dispose()}))}async registerComponentHandler(e){e.stopPropagation();if(!this.automaticComponentRegistration){t(`~[${this.hostTagName}] (registerComponentHandler) Automatic component registration disabled. Skipping registration of ${e.detail.name}.`);return}await this.registerComponent(e.detail)}async unregisterComponentHandler(e){e.stopPropagation();if(!this.automaticComponentRegistration){t(`~[${this.hostTagName}] (unregisterComponentHandler) Automatic component registration disabled. Skipping unregistration of ${e.detail.name}.`);return}this.unregisterComponent(e.detail)}async registerComponent(i){t(`~[${this.hostTagName}] (registerComponent) Registering component ${i.name}.`);const s=i.element.dataset.nylasId;const r=s&&this.registeredComponents[s];if(r){t(`[${this.hostTagName}] (registerComponent) Component ${i.name} already registered. Updating registration.`);this.cleanupComponentRegistration(s,false)}else{const t=e()?this.computeDeterministicId(i.element):undefined;i.element.dataset.nylasId=s||t||n()}const a=i.element.dataset.nylasId;if(a){this.registeredComponents[a]=i}t(`[${this.hostTagName}] (registerComponent) Waiting for "${i.element.localName}" component to be defined`,{component:i});try{await customElements.whenDefined(i.element.tagName.toLowerCase());t(`[${this.hostTagName}] (registerComponent) Component "${i.element.localName}" is now defined`);if(typeof i.element.componentOnReady==="function"){try{await i.element.componentOnReady();t(`[${this.hostTagName}] (registerComponent) Component "${i.element.localName}" is now ready`)}catch(e){t(`[${this.hostTagName}] (registerComponent) Error waiting for component "${i.element.localName}" to be ready:`,e)}}else{await new Promise((t=>{const e=()=>{if(i.element.classList?.contains("hydrated")){t()}else{setTimeout((()=>{if(i.element.classList?.contains("hydrated")){t()}else{t()}}),10)}};e()}))}}catch(e){t(`[${this.hostTagName}] (registerComponent) Error waiting for component "${i.element.localName}" to be defined:`,e)}const p=this.eventOverrides;const{stateToProps:c,getStoresToProp:f,eventToProps:h,storeToProps:u,connectorToProp:$,localPropsToProp:l,element:g}=i;h?.forEach(((e,n)=>{const s=async o=>{const s=this.nylasConnector;t(`[${this.hostTagName}] (registerComponent) Handling "${i.name}" prop "${String(n)}" event.`,{event:o});if(n in p){t(`[${this.hostTagName}] (registerComponent) Found event override for "${String(n)}" event. Calling override.`);await p[n](o,s)}if(!o.defaultPrevented){await e(o,s)}return};const r=i.element.dataset.nylasId;if(r&&!this.eventListenerRegistrations.has(r)){this.eventListenerRegistrations.set(r,[])}if(r){this.eventListenerRegistrations.get(r)?.push([g,n,s])}t(`[${this.hostTagName}] (registerComponent) Setting "${i.name}" event "${String(n)}" to automcially call NylasConnector method.`);const a=o(n.toString());t(`[${this.hostTagName}] (registerComponent) Adding event listener for "${a}" on "${g.tagName}"`);g.addEventListener(a,s)}));c?.forEach(((e,n)=>{const[o,s]=n.split(".");const r=this.getStore(o);const a=r.state[s];if(!g.dataset.nylasId){t(`[${this.hostTagName}] (registerComponent) Component "${i.name}" not registered. Skipping.`,{component:i});return}if(!this.propStateRegistrations.has(o)){this.propStateRegistrations.set(o,new Map)}if(!this.propStateRegistrations.get(o)?.has(s)){this.propStateRegistrations.get(o)?.set(s,[{elementId:g.dataset.nylasId,propKey:e}])}else{this.propStateRegistrations.get(o)?.get(s)?.push({elementId:g.dataset.nylasId,propKey:e})}g[e.toString()]=a;t(`[${this.hostTagName}] Setting "${i.name}" prop "${e.toString()}" to "${n}" value.`,{stateValue:a})}));l?.forEach(((e,n)=>{const o=this.host[n];g[e.toString()]=o;t(`[${this.hostTagName}] Setting "${i.name}" prop "${e.toString()}" to the value of "${n}" value.`,{value:n,mappedPropValue:o})}));if(f){g[f?.toString()]=this.getStore;t(`[${this.hostTagName}] Setting "${i.name}" prop "${f.toString()}" to "getStore" method.`)}u?.forEach(((e,n)=>{const o=this.getStore(n);g[e.toString()]=o;t(`[${this.hostTagName}] Setting "${i.name}" prop "${e.toString()}" to "${n}" store.`,{store:o})}));if($){g[$?.toString()]=this.nylasConnector;t(`[${this.hostTagName}] Setting "${i.name}" prop "${$.toString()}" to "nylasConnector" value.`,{connectorToProp:$})}if(typeof g.registerCallback==="function"){t(`[${this.hostTagName}] (registerComponent) Calling registerCallback method for "${i.name}".`);await g.registerCallback()}t(`[${this.hostTagName}] (registerComponent) Component ${i.name} registered.`)}computeDeterministicId(t){const e=t.getAttribute("id");if(e&&e.trim().length>0)return e.trim();const n=t.getAttribute("name");if(n&&n.trim().length>0)return n.trim();const o=t.tagName.toLowerCase();try{const e=Array.from(this.host?.querySelectorAll(o)||[]);const n=e.indexOf(t);const i=n>=0?n+1:e.length+1;return`${o}-${i}`}catch(t){return`${o}-1`}}cleanupComponentRegistration(e,n=true){const i=this.eventListenerRegistrations.get(e);if(i){i.forEach((([e,n,i])=>{const s=o(n.toString());t(`[${this.hostTagName}] (cleanupComponentRegistration) Removing event listener for "${s}" on "${e.tagName}"`);e.removeEventListener(s,i)}));this.eventListenerRegistrations.delete(e)}this.propStateRegistrations.forEach(((t,n)=>{t.forEach(((t,o)=>{const i=t.filter((t=>t.elementId!==e));if(i.length!==t.length){this.propStateRegistrations.get(n)?.set(o,i)}}))}));if(n){delete this.registeredComponents[e]}}unregisterComponent(e){t(`[${this.hostTagName}] Unregistering component ${e.name}.`);const n=e.element.dataset.nylasId;if(!n){t(`[${this.hostTagName}] (unregisterComponent) Unregistering component ${e.name}.`);return}if(this.registeredComponents[n]){t(`[${this.hostTagName}] (unregisterComponent) Component ${e.name} not registered. Skipping.`);return}this.propStateRegistrations.forEach(((t,e)=>{t.forEach(((t,o)=>{const i=this.propStateRegistrations.get(e)?.get(o);const s=i?.filter((t=>t.elementId!==n));if(s){this.propStateRegistrations.get(e)?.set(o,s)}}))}));const i=this.eventListenerRegistrations.get(n);i?.forEach((([e,n,i])=>{const s=o(n.toString());t(`[${this.hostTagName}] (unregisterComponent) Removing event listener for "${s}" on "${e.tagName}"`);e.removeEventListener(s,i)}));delete this.registeredComponents[n]}getStore(t){const e=this.stores[t];if(!e){throw new Error(`[${this.hostTagName}] Store "${t.toString()}" not found.`)}return e}async setupStoreListeners(){const e=this;Object.entries(this.stores).forEach((([n,o])=>{t(`[${e.hostTagName}] (setupStoreListeners) Listening for changes in "${n}" store.`);o.use({set(o,s,r){t(`[${e.hostTagName}] (setupStoreListeners) Store "${n}" state "${o.toString()}" changed`,{newValue:s,oldValue:r});if(i(s,r)){t(`[${e.hostTagName}] (setupStoreListeners) Store "${n}" state "${o.toString()}" unchanged. Skipping.`);return}const a=e.registeredComponents;if(!a){t(`[${e.hostTagName}] (setupStoreListeners) No registered components found. Skipping.`);return}const p=e.propStateRegistrations.get(n)?.get(o.toString())||[];t(`[${e.hostTagName}] (setupStoreListeners) Found ${p.length} prop(s) registered for "${o.toString()}" store.`,{props:p,propStateRegistrations:e.propStateRegistrations});const c=e.getStore(n);const f=c.state[o];p.forEach((({elementId:n,propKey:i})=>{const s=a[n];if(!s){t(`[${e.hostTagName}] (setupStoreListeners) Component "${n}" not found. Skipping.`,{component:s});return}e.queuePropUpdate(n,i.toString(),f);t(`[${e.hostTagName}] (setupStoreListeners) Queued "${s.name}" prop "${i.toString()}" update for "${o.toString()}" value.`,{stateValue:f})}))}})}))}queuePropUpdate(t,e,n){if(!this.propUpdateQueue.has(t)){this.propUpdateQueue.set(t,new Map)}this.propUpdateQueue.get(t).set(e,n);if(!this.propUpdateScheduled){this.propUpdateScheduled=true;Promise.resolve().then((()=>{this.flushPropUpdates()}))}}flushPropUpdates(){this.propUpdateScheduled=false;const e=new Map(this.propUpdateQueue);this.propUpdateQueue.clear();e.forEach(((e,n)=>{const o=this.registeredComponents[n];if(!o){t(`[${this.hostTagName}] (flushPropUpdates) Component "${n}" not found. Skipping.`);return}e.forEach(((e,n)=>{o.element[n]=e;t(`[${this.hostTagName}] (flushPropUpdates) Setting "${o.name}" prop "${n}" to batched value.`,{value:e})}))}))}get hostTagName(){return this.host?.tagName?.toLowerCase()??"nylas-provider"}}class r extends s{}export{r as N};
|
|
2
|
+
//# sourceMappingURL=p-DGwaF706.js.map
|