PageSourceSearch

https://www.trainwithkickoff.com/_next/static/chunks/7503.2e8e939cb558c360.js

js trainwithkickoff.com collected 2026-10-04 00:03:01 UTC 91,184 bytes, 3 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7503],{52937:function(e,t,n){n.d(t,{N:function(){return r}});var i=n(39986);class o{constructor(e,t,n=!0,o){this.automaticComponentRegistration=!0,this.registeredComponents={},this.propStateRegistrations=new Map,this.eventListenerRegistrations=new Map,this.host=e,this.stores=t,this.automaticComponentRegistration=n,this.eventOverrides=o,(0,i.b)(`[${this.hostTagName}] Initializing (abstract) provider.`,{eventOverrides:o}),this.registerComponent=this.registerComponent.bind(this),this.getStore=this.getStore.bind(this),Object.keys(this.stores).forEach(e=>{this.propStateRegistrations.set(e,new Map)})}async componentWillLoad(e){(0,i.b)(`[${this.hostTagName}] Will load`),this.setupStoreListeners(),this.nylasConnector=e;let t=Array.from(this.host.querySelectorAll("*")).filter(e=>e.tagName.toLowerCase().startsWith("nylas-"));(0,i.b)(`[${this.hostTagName}] Found ${t.length} child component(s).`,{childComponents:t});let n=t.map(async e=>{let t=e;if(!t){(0,i.b)(`[~${this.hostTagName}] (componentWillLoad) Component ${t.tagName} does not have a name. Skipping.`);return}if(!t.registerNylasComponent){(0,i.b)(`[~${this.hostTagName}] (componentWillLoad) Component ${t.tagName} is not a component that can be registered. Skipping.`,{component:t});return}let n={element:t,name:t.tagName.toLowerCase(),getStoresToProp:t.getStoresToProp,storeToProps:t.storeToProps,stateToProps:t.stateToProps,authToProp:t.authToProp,eventToProps:t.eventToProps,connectorToProp:t.connectorToProp,localPropsToProp:t.localPropsToProp};await this.registerComponent(n)});await Promise.all(n)}async componentDidLoad(){(0,i.b)(`[~${this.hostTagName}] (componentDidLoad) Did load`)}async componentDisconnected(){Object.values(this.stores).forEach(e=>{e.dispose()})}async registerComponentHandler(e){if(e.stopPropagation(),!this.automaticComponentRegistration){(0,i.b)(`~[${this.hostTagName}] (registerComponentHandler) Automatic component registration disabled. Skipping registration of ${e.detail.name}.`);return}await this.registerComponent(e.detail)}async unregisterComponentHandler(e){if(e.stopPropagation(),!this.automaticComponentRegistration){(0,i.b)(`~[${this.hostTagName}] (unregisterComponentHandler) Automatic component registration disabled. Skipping unregistration of ${e.detail.name}.`);return}this.unregisterComponent(e.detail)}async registerComponent(e){(0,i.b)(`~[${this.hostTagName}] (registerComponent) Registering component ${e.name}.`);let t=e.element.dataset.nylasId;t&&this.registeredComponents[t]?((0,i.b)(`[${this.hostTagName}] (registerComponent) Component ${e.name} already registered. Updating registration.`),this.cleanupComponentRegistration(t,!1)):e.element.dataset.nylasId=t||(0,i.n)();let n=e.element.dataset.nylasId;n&&(this.registeredComponents[n]=e),(0,i.b)(`[${this.hostTagName}] (registerComponent) Waiting for "${e.element.localName}" component to be defined`,{component:e});try{await customElements.whenDefined(e.element.tagName.toLowerCase()),(0,i.b)(`[${this.hostTagName}] (registerComponent) Component "${e.element.localName}" is now defined`)}catch(t){(0,i.b)(`[${this.hostTagName}] (registerComponent) Error waiting for component "${e.element.localName}" to be defined:`,t)}let o=this.eventOverrides,{stateToProps:r,getStoresToProp:s,eventToProps:a,storeToProps:l,connectorToProp:d,localPropsToProp:c,element:u}=e;null==a||a.forEach((t,n)=>{var r;let s=this.nylasConnector,a=async r=>{(0,i.b)(`[${this.hostTagName}] (registerComponent) Handling "${e.name}" prop "${String(n)}" event.`,{event:r}),n in o&&((0,i.b)(`[${this.hostTagName}] (registerComponent) Found event override for "${String(n)}" event. Calling override.`),await o[n](r,s)),r.defaultPrevented||await t(r,s)},l=e.element.dataset.nylasId;l&&!this.eventListenerRegistrations.has(l)&&this.eventListenerRegistrations.set(l,[]),l&&(null==(r=this.eventListenerRegistrations.get(l))||r.push([u,n,a])),(0,i.b)(`[${this.hostTagName}] (registerComponent) Setting "${e.name}" event "${String(n)}" to automcially call NylasConnector method.`);let d=(0,i.o)(n.toString());(0,i.b)(`[${this.hostTagName}] (registerComponent) Adding event listener for "${d}" on "${u.tagName}"`),u.addEventListener(d,a)}),null==r||r.forEach((t,n)=>{var o,r,s,a;let[l,d]=n.split("."),c=this.getStore(l).state[d];if(!u.dataset.nylasId){(0,i.b)(`[${this.hostTagName}] (registerComponent) Component "${e.name}" not registered. Skipping.`,{component:e});return}this.propStateRegistrations.has(l)||this.propStateRegistrations.set(l,new Map),null!=(o=this.propStateRegistrations.get(l))&&o.has(d)?null==(a=null==(s=this.propStateRegistrations.get(l))?void 0:s.get(d))||a.push({elementId:u.dataset.nylasId,propKey:t}):null==(r=this.propStateRegistrations.get(l))||r.set(d,[{elementId:u.dataset.nylasId,propKey:t}]),u[t.toString()]=c,(0,i.b)(`[${this.hostTagName}] Setting "${e.name}" prop "${t.toString()}" to "${n}" value.`,{stateValue:c})}
1),null==c||c.forEach((t,n)=>{let o=this.host[n];u[t.toString()]=o,(0,i.b)(`[${this.hostTagName}] Setting "${e.name}" prop "${t.toString()}" to the value of "${n}" value.`,{value:n,mappedPropValue:o})}),s&&(u[null==s?void 0:s.toString()]=this.getStore,(0,i.b)(`[${this.hostTagName}] Setting "${e.name}" prop "${s.toString()}" to "getStore" method.`)),null==l||l.forEach((t,n)=>{let o=this.getStore(n);u[t.toString()]=o,(0,i.b)(`[${this.hostTagName}] Setting "${e.name}" prop "${t.toString()}" to "${n}" store.`,{store:o})}),d&&(u[null==d?void 0:d.toString()]=this.nylasConnector,(0,i.b)(`[${this.hostTagName}] Setting "${e.name}" prop "${d.toString()}" to "nylasConnector" value.`,{connectorToProp:d})),"function"==typeof u.registerCallback&&((0,i.b)(`[${this.hostTagName}] (registerComponent) Calling registerCallback method for "${e.name}".`),await u.registerCallback()),(0,i.b)(`[${this.hostTagName}] (registerComponent) Component ${e.name} registered.`)}cleanupComponentRegistration(e,t=!0){let n=this.eventListenerRegistrations.get(e);n&&(n.forEach(([e,t,n])=>{let o=(0,i.o)(t.toString());(0,i.b)(`[${this.hostTagName}] (cleanupComponentRegistration) Removing event listener for "${o}" on "${e.tagName}"`),e.removeEventListener(o,n)}),this.eventListenerRegistrations.delete(e)),this.propStateRegistrations.forEach((t,n)=>{t.forEach((t,i)=>{var o;let r=t.filter(t=>t.elementId!==e);r.length!==t.length&&(null==(o=this.propStateRegistrations.get(n))||o.set(i,r))})}),t&&delete this.registeredComponents[e]}unregisterComponent(e){(0,i.b)(`[${this.hostTagName}] Unregistering component ${e.name}.`);let t=e.element.dataset.nylasId;if(!t){(0,i.b)(`[${this.hostTagName}] (unregisterComponent) Unregistering component ${e.name}.`);return}if(this.registeredComponents[t]){(0,i.b)(`[${this.hostTagName}] (unregisterComponent) Component ${e.name} not registered. Skipping.`);return}this.propStateRegistrations.forEach((e,n)=>{e.forEach((e,i)=>{var o,r;let s=null==(o=this.propStateRegistrations.get(n))?void 0:o.get(i),a=null==s?void 0:s.filter(e=>e.elementId!==t);a&&(null==(r=this.propStateRegistrations.get(n))||r.set(i,a))})});let n=this.eventListenerRegistrations.get(t);null==n||n.forEach(([e,t,n])=>{let o=(0,i.o)(t.toString());(0,i.b)(`[${this.hostTagName}] (unregisterComponent) Removing event listener for "${o}" on "${e.tagName}"`),e.removeEventListener(o,n)}),delete this.registeredComponents[t]}getStore(e){let t=this.stores[e];if(!t)throw Error(`[${this.hostTagName}] Store "${e.toString()}" not found.`);return t}async setupStoreListeners(){let e=this;Object.entries(this.stores).forEach(([t,n])=>{(0,i.b)(`[${e.hostTagName}] (setupStoreListeners) Listening for changes in "${t}" store.`),n.use({set(n,o,r){var s;if((0,i.b)(`[${e.hostTagName}] (setupStoreListeners) Store "${t}" state "${n.toString()}" changed`,{newValue:o,oldValue:r}),o===r){(0,i.b)(`[${e.hostTagName}] (setupStoreListeners) Store "${t}" state "${n.toString()}" unchanged. Skipping.`);return}let a=e.registeredComponents;if(!a){(0,i.b)(`[${e.hostTagName}] (setupStoreListeners) No registered components found. Skipping.`);return}let l=(null==(s=e.propStateRegistrations.get(t))?void 0:s.get(n.toString()))||[];(0,i.b)(`[${e.hostTagName}] (setupStoreListeners) Found ${l.length} prop(s) registered for "${n.toString()}" store.`,{props:l,propStateRegistrations:e.propStateRegistrations}),l.forEach(({elementId:o,propKey:r})=>{let s=a[o];if(!s){(0,i.b)(`[${e.hostTagName}] (setupStoreListeners) Component "${o}" not found. Skipping.`,{component:s});return}let l=e.getStore(t).state[n];s.element[r.toString()]=l,(0,i.b)(`[${e.hostTagName}] (setupStoreListeners) Setting "${s.name}" prop "${r.toString()}" to "${n.toString()}" value.`,{stateValue:l})})}})})}get hostTagName(){var e,t;return(null==(t=null==(e=this.host)?void 0:e.tagName)?void 0:t.toLowerCase())??"nylas-provider"}}class r extends o{}},87503:function(__unused_webpack___webpack_module__,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{nylas_scheduler_editor:function(){return NylasSchedulerEditor}});var _index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(39986),_abstract_provider_bdb7d9b4_22cf4a74_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(52937),_index_es_ccb2a286_dfa2bfbe_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(99091),_constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(38182),react__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(67294),react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(85893),react_dom__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(73935),le=Object.defineProperty,ce=(e,t,n)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,N=(e,t,n)=>(ce(e,"symbol"!=typeof t?t+"":t,n),n);_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.d.extend(_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.u),_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.d.extend(_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.t);class NylasSchedulerConfigAPIConnector{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.groupEventsCache=new Map,this.CACHE_DURATION=6e4,this.nylasApiRequest=e,this.nylasSchedulerConfigStore=t}async currentUser(){return this.nylasApiRequest?this.nylasApiRequest.currentUser():(console.warn("Nylas API Request is not initialized"),null)}async getCalendars(){var e;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching calendars: Nylas API Request is not initialized"});let t=[],n=null,i=50;do{let[o,r]=await this.nylasApiRequest.request({method:"GET",path:`calendars?limit=${i}${n?`&page_token=${n}`:""}`});if(r)return(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching calendars: "+r.message});if((0,_index_es_ccb2a286_dfa2bfbe_js__WEBPACK_IMPORTED_MODULE_2__.X)(o))return(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching calendars: "+(null==(e=o.error)?void 0:e.message)});t.push(...o.data),n=o.next_cursor||null}while(n);return this.nylasSchedulerConfigStore.state.calendars=t,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(t)}async getConfigurationById(e,t=!1){var n;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching configuration: Nylas API Request is not initialized"});if(!t){let t=this.nylasSchedulerConfigStore.state.configurations.find(t=>
1t.id===e);if(t)return this.nylasSchedulerConfigStore.state.selectedConfiguration=t,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(t)}let[i,o]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}`});return o?(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching configuration: "+o.message}):(0,_index_es_ccb2a286_dfa2bfbe_js__WEBPACK_IMPORTED_MODULE_2__.X)(i)?(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching configuration: "+(null==(n=i.error)?void 0:n.message)}):(this.nylasSchedulerConfigStore.state.selectedConfiguration=i.data,this.nylasSchedulerConfigStore.state.configurations.find(t=>t.id===e)?this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map(t=>t.id===e?i.data:t):this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,i.data],(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(i.data))}async getConfigurations(e){var t;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching configurations: Nylas API Request is not initialized"});let n=50,[i,o]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations?limit=${n}${e?`&page_token=${e}`:""}`});return o?(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching configurations: "+o.message}):(0,_index_es_ccb2a286_dfa2bfbe_js__WEBPACK_IMPORTED_MODULE_2__.X)(i)?(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching configurations: "+(null==(t=i.error)?void 0:t.message)}):(this.nylasSchedulerConfigStore.state.configurations=i.data,this.nylasSchedulerConfigStore.state.listConfigurationsNextCursor=i.next_cursor||null,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(i.data))}async getMasterEventById(e){var t,n;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching master event: Nylas API Request is not initialized"});let i=this.nylasSchedulerConfigStore.state.selectedGroupEvent,o=null==(t=null==i?void 0:i.event)?void 0:t.calendar_id;if(!o)return console.warn("Calendar ID is not present"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching master event: Calendar ID is not present"});let r=new URLSearchParams;r.append("calendar_id",o);let[s,a]=await this.nylasApiRequest.request({method:"GET",path:`events/${e}?${r.toString()}`});if(a)return(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching master event: "+a.message});if((0,_index_es_ccb2a286_dfa2bfbe_js__WEBPACK_IMPORTED_MODULE_2__.X)(s))return(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching master event: "+(null==(n=s.error)?void 0:n.message)});let l=this.nylasSchedulerConfigStore.state.masterGroupEvents;return l[e]?this.nylasSchedulerConfigStore.state.masterGroupEvents[e]=s.data:this.nylasSchedulerConfigStore.state.masterGroupEvents={...l,[e]:s.data},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(s.data)}async createConfiguration(e){var t;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error creating configuration: Nylas API Request is not initialized"});let[n,i]=await this.nylasApiRequest.request({method:"POST",path:"scheduling/configurations",body:e});return i?(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error creating configuration: "+i.message}):(0,_index_es_ccb2a286_dfa2bfbe_js__WEBPACK_IMPORTED_MODULE_2__.X)(n)?(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error creating configuration: "+(null==(t=n.error)?void 0:t.message)}):(this.nylasSchedulerConfigStore.state.selectedConfiguration=n.data,this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,n.data],(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(n.data))}async updateConfiguration(e){var t;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error updating configuration: Nylas API Request is not initialized"});let[n,i]=await this.nylasApiRequest.request({method:"PUT",path:`scheduling/configurations/${e.id}`,body:e});return i?(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error updating configuration: "+i.message}):(0,_index_es_ccb2a286_dfa2bfbe_js__WEBPACK_IMPORTED_MODULE_2__.X)(n)?(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error updating configuration: "+(null==(t=n.error)?void 0:t.message)}):(this.nylasSchedulerConfigStore.state.selectedConfiguration=n.data,this.nylasSchedulerConfigStore.state.configurations.find(t=>
1t.id===e.id)?this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map(t=>t.id===e.id?n.data:t):this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,n.data],(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(n.data))}async deleteConfiguration(e){var t,n;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error deleting configuration: Nylas API Request is not initialized"});let[i,o]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${e}`});return o?(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error deleting configuration: "+o.message}):(0,_index_es_ccb2a286_dfa2bfbe_js__WEBPACK_IMPORTED_MODULE_2__.X)(i)?(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error deleting configuration: "+(null==(t=i.error)?void 0:t.message)}):(this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.filter(t=>t.id!==e),(null==(n=this.nylasSchedulerConfigStore.state.selectedConfiguration)?void 0:n.id)===e&&this.nylasSchedulerConfigStore.resetSelectedConfiguration(),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(i.data))}async createGroupEvent(e,t){var n;if(this.nylasSchedulerConfigStore.state.isLoading=!0,!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error creating group event: Nylas API Request is not initialized"});let[i,o]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/group-events`,body:e});return o?(this.nylasSchedulerConfigStore.state.isLoading=!1,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error creating group event: "+o.message})):(0,_index_es_ccb2a286_dfa2bfbe_js__WEBPACK_IMPORTED_MODULE_2__.X)(i)?(this.nylasSchedulerConfigStore.state.isLoading=!1,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error creating group event: "+(null==(n=i.error)?void 0:n.message)})):(this.nylasSchedulerConfigStore.state.selectedGroupEvent=i.data,await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration),this.nylasSchedulerConfigStore.state.isLoading=!1,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(i.data))}async getGroupEvents(e,t){var n,i;let o,r;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching group events: Nylas API Request is not initialized"});let s=new URLSearchParams;s.append("show_all","true");let a=this.nylasSchedulerConfigStore.state.calendarViewDateRange;if(a)o=a.start_time,r=a.end_time;else{let e=(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.j)(new Date().toISOString(),"week");o=e.startTime.toString(),r=e.endTime.toString()}let l=`${e}-${o}-${r}`,d=this.groupEventsCache.get(l);if(d&&Date.now()-d.timestamp<this.CACHE_DURATION)return this.nylasSchedulerConfigStore.state.groupEvents=d.data,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(d.data);s.append("start_time",o),s.append("end_time",r);let c=null==(n=null==t?void 0:t.group_booking)?void 0:n.calendar_id;c&&s.append("calendar_id",c);let[u,h]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}/group-events?${s.toString()}`});return h?(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching group events: "+h.message}):(0,_index_es_ccb2a286_dfa2bfbe_js__WEBPACK_IMPORTED_MODULE_2__.X)(u)?(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error fetching group events: "+(null==(i=u.error)?void 0:i.message)}):(this.groupEventsCache.set(l,{data:u.data,timestamp:Date.now()}),this.cleanupExpiredCache(),this.nylasSchedulerConfigStore.state.groupEvents=u.data,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(u.data))}cleanupExpiredCache(){let e=Date.now();for(let[t,n]of this.groupEventsCache.entries())e-n.timestamp>this.CACHE_DURATION&&this.groupEventsCache.delete(t)}async updateGroupEventById(e,t){var n;if(this.nylasSchedulerConfigStore.state.isLoading=!0,!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error updating group event: Nylas API Request is not initialized"});let i=e.id;delete e.id;let[o,r]=await this.nylasApiRequest.request({method:"PATCH",path:`scheduling/configurations/${t}/group-events/${i}`,body:e});return r?(this.nylasSchedulerConfigStore.state.isLoading=!1,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error updating group event: "+r.message})):(0,_index_es_ccb2a286_dfa2bfbe_js__WEBPACK_IMPORTED_MODULE_2__.X)(o)?(this.nylasSchedulerConfigStore.state.isLoading=!1,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error updating group event: "+(null==(n=o.error)?void 0:n.message)})):(this.nylasSchedulerConfigStore.state.selectedGroupEvent=o.data,await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration),this.nylasSchedulerConfigStore.state.isLoading=!1,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(o.data))}async updateGroupEvent(e,t,n){var i,o,r,s,a,l,d,c,u,h,g,p,f,y;this.nylasSchedulerConfigStore.state.isLoading=!0;let v=this.nylasSchedulerConfigStore.state.selectedGroupEvent,m=null==(i=null==v?void 0:v.event)?void 0:i.master_event_id,w=null==(o=null==v?void 0:v.event)?void 0:o.id,b=null==(s=null==(r=null==v?void 0:v.event)?void 0:r.when)?void 0:s.start_time,S=null==(l=null==(a=null==v?void 0:v.group_event_info)?void 0:a.rrule)?void 0:l[0],C=S?S.split(";").filter(e=>!e.startsWith("UNTIL")).join(";"):"",_=b?(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.d)(1e3*b).subtract(1,"minute").format("YYYYMMDDTHHmmss[Z]"):"";if("this"===t)return this.updateGroupEventById({...e,id:w,recurrence:m?void 0:e.recurrence},n);if("future"===t&&m){let t=await this.createGroupEvent(e,n),i={location:null==(d=null==v?void 0:v.event)?void 0:d.location,conferencing:null==(c=null==v?void 0:v.event)?void 0:c.conferencing,title:null==(u=null==v?void 0:v.event)?void 0:u.title,de
1scription:null==(h=null==v?void 0:v.event)?void 0:h.description,capacity:null==(g=null==v?void 0:v.group_event_info)?void 0:g.capacity,calendar_id:null==(p=null==v?void 0:v.event)?void 0:p.calendar_id,recurrence:C?[C+";UNTIL="+_]:[`RRULE:FREQ=DAILY;UNTIL=${_}`]};return await this.updateGroupEventById({...i,id:m},n),[i,t]}if("all"===t){let t=null==e?void 0:e.when,i=null==(f=null==v?void 0:v.event)?void 0:f.when,o=null==(y=this.nylasSchedulerConfigStore.state.masterGroupEvents)?void 0:y[m],r=null==o?void 0:o.when;return(null==t?void 0:t.start_time)!==(null==i?void 0:i.start_time)&&(r={...r,start_time:(null==t?void 0:t.start_time)||(null==r?void 0:r.start_time)}),(null==t?void 0:t.end_time)!==(null==i?void 0:i.end_time)&&(r={...r,end_time:(null==t?void 0:t.end_time)||(null==r?void 0:r.end_time)}),(null==t?void 0:t.start_timezone)!==(null==i?void 0:i.start_timezone)&&(r={...r,start_timezone:(null==t?void 0:t.start_timezone)||(null==r?void 0:r.start_timezone)}),(null==t?void 0:t.end_timezone)!==(null==i?void 0:i.end_timezone)&&(r={...r,end_timezone:(null==t?void 0:t.end_timezone)||(null==r?void 0:r.end_timezone)}),this.updateGroupEventById({...e,when:r,id:m},n)}throw this.nylasSchedulerConfigStore.state.isLoading=!1,Error("Invalid option")}async deleteGroupEvent(e,t,n){var i,o,r,s,a,l,d,c,u,h,g,p;this.nylasSchedulerConfigStore.state.isLoading=!0;let f=this.nylasSchedulerConfigStore.state.selectedGroupEvent,y=null==(i=null==f?void 0:f.event)?void 0:i.master_event_id,v=null==(o=null==f?void 0:f.event)?void 0:o.id,m=null==(s=null==(r=null==f?void 0:f.event)?void 0:r.when)?void 0:s.start_time,w=null==(l=null==(a=null==f?void 0:f.group_event_info)?void 0:a.rrule)?void 0:l[0],b=w?w.split(";").filter(e=>!e.startsWith("UNTIL")).join(";"):"",S=m?(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.d)(1e3*m).format("YYYYMMDDTHHmmss[Z]"):"",C={location:null==(d=null==f?void 0:f.event)?void 0:d.location,conferencing:null==(c=null==f?void 0:f.event)?void 0:c.conferencing,title:null==(u=null==f?void 0:f.event)?void 0:u.title,description:null==(h=null==f?void 0:f.event)?void 0:h.description,capacity:null==(g=null==f?void 0:f.group_event_info)?void 0:g.capacity,calendar_id:null==(p=null==f?void 0:f.event)?void 0:p.calendar_id,recurrence:b?[b+";UNTIL="+S]:[`RRULE:UNTIL=${S}`]};if("this"===t&&v)return this.deleteGroupEventById(v,n);if("future"===t&&y&&v)return await this.deleteGroupEventById(v,n),await this.updateGroupEventById({...C,id:y},n);if("all"===t&&y)return this.deleteGroupEventById(y,n);throw this.nylasSchedulerConfigStore.state.isLoading=!1,Error("Invalid option")}async deleteGroupEventById(e,t){var n,i,o;if(this.nylasSchedulerConfigStore.state.isLoading=!0,!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error deleting group event: Nylas API Request is not initialized"});let r=new URLSearchParams,s=null==(i=null==(n=this.nylasSchedulerConfigStore.state.selectedConfiguration)?void 0:n.group_booking)?void 0:i.calendar_id;s&&r.append("calendar_id",s);let[a,l]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${t}/group-events/${e}?calendar_id=${s}`});return l?(this.nylasSchedulerConfigStore.state.isLoading=!1,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error deleting group event: "+l.message})):(0,_index_es_ccb2a286_dfa2bfbe_js__WEBPACK_IMPORTED_MODULE_2__.X)(a)?(this.nylasSchedulerConfigStore.state.isLoading=!1,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error deleting group event: "+(null==(o=a.error)?void 0:o.message)})):(await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration),this.nylasSchedulerConfigStore.state.isLoading=!1,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(a.data))}async importGroupEvent(e,t){var n,i,o,r,s;if(this.nylasSchedulerConfigStore.state.isLoading=!0,!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error importing group event: Nylas API Request is not initialized"});let a=new URLSearchParams,l=null==(i=null==(n=this.nylasSchedulerConfigStore.state.selectedConfiguration)?void 0:n.group_booking)?void 0:i.calendar_id;l&&a.append("calendar_id",l);let[d,c]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/import-group-events?${a.toString()}`,body:e});return c?(this.nylasSchedulerConfigStore.state.isLoading=!1,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error importing group event: "+c.message})):(0,_index_es_ccb2a286_dfa2bfbe_js__WEBPACK_IMPORTED_MODULE_2__.X)(d)?(this.nylasSchedulerConfigStore.state.isLoading=!1,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(null,{message:"Error importing group event: "+(null==(o=d.error)?void 0:o.message)})):((null==(s=null==(r=d.data)?void 0:r.imported_events)?void 0:s.length)>0&&await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration),this.nylasSchedulerConfigStore.state.isLoading=!1,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.f)(d.data))}}class NylasSchedulerConfigConnector{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.nylasApiRequest=e,this.nylasSchedulerConfigStore=t}init(){(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.b)("NylasSchedulerConfigConnector init")}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get schedulerConfig(){return this._schedulerConfigConnector||(this._schedulerConfigConnector=new NylasSchedulerConfigAPIConnector({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore})),this._schedulerConfigConnector}resetStores(){(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.b)("NylasSchedulerConfigConnector resetStores"),this.nylasSchedulerConfigStore.reset()}async logout(){(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.b)("NylasSchedulerConfigConnector logout"),this.resetStores()}}function CreateNylasSchedulerConfigStore(e={}){let t={selectedConfiguration:{},configurations:[],groupEvents:[],listConfigurationsNextCursor:null,calendars:[],currentUser:null,action:null,additionalParticipants:[],requiresSlug:!1,masterGroupEvents:{},isLoading:!1,...e},n=(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.e)(t);function i(){n.set("selectedConfiguration",{...e.selectedConfiguration})}return n.onChange("action",async e=>{e||i()}),{...n,resetSelectedConfiguration:i}}class LocalStorage{get(e){return new Promise(t=>{let n=window.localStorage.getItem(e);t(n?JSON.parse(n):null)})}async remove(e){return window.localStorage.removeItem(e),new Promise(e=>{e(null)})}set(e,t){return window.localStorage.setItem(e,JSON.stringify(t)),new Promise(e=>{e(null)})}}let PKCE_KEY="pkce",GRANT_KEY="grant",USER_KEY="user";class Storage{constructor(e){if(N(this,"Storage",new LocalStorage),e){this.Storage=e;return}}setPKCE(e){let t=_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.B.from(e);this.Storage.set(PKCE_KEY,t.toString("base64"))}async getPKCE(){try{let e=await this.Storage.get(PKCE_KEY);if(e)return _index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.B.from(e,"base64").toString("utf8")}catch{}return null}removePKCE(){this.Storage.remove(PKCE_KEY)}setGrant(e,t=!1){let{grant_id:n}=e;this.Storage.set(`${GRANT_KEY}${t?"-"+n:""}`,e)}removeGrant(e,t=!1){this.Storage.remove(`${GRANT_KEY}${t?"-"+e:""}`)}async getGrant(e,t=!1){return await this.Storage.get(`${GRANT_KEY}${t?"-"+e:""}`)||null}async setUserToken(e){let t=await this.getUserTokens();if(t){if(t.find(t=>t.sub===e.sub)){let n=t.map(t=>(t.sub===e.sub&&(t=e),t));this.Storage.set(USER_KEY,n)}else{let n=[...t,e];this.Storage.set(USER_KEY,n)}}else this.Storage.set(USER_KEY,[e])}async getUserToken(e=""){let t=await this.Storage.get(USER_KEY);return t?""===e?t[0]:t.find(t=>t.sub===e):null}async getUserTokens(){return await this.Storage.get(USER_KEY)||null}removeUserTokens(){this.Storage.remove(USER_KEY)}async removeUserToken(e){let t=await this.getUserTokens(),n=null==t?void 0:t.filter(t=>t.sub!==e);this.Storage.set(USER_KEY,n)}async clearSession(){let e=await this.getUserTokens();
1null==e||e.forEach(e=>{this.removeGrant(e.sub)}),this.removePKCE(),this.removeUserTokens()}}class IndexedDBStorage{constructor(){N(this,"databaseName","identity-db"),N(this,"storeName","identity")}get(e){let t=this;return new Promise((n,i)=>{t.openDatabase().then(function(o){let r=o.transaction(t.storeName,"readwrite"),s=r.objectStore(t.storeName).get(e);s.onsuccess=()=>{n(s.result)},s.onerror=()=>{i(s.error)},r.oncomplete=()=>{o.close()}})})}async remove(e){let t=this;return new Promise((n,i)=>{let o=indexedDB.open(this.databaseName);o.onupgradeneeded=function(e){e.target.result.createObjectStore(t.storeName)},o.onerror=()=>{i(o.error)},o.onsuccess=t=>{let o=t.target.result,r=o.transaction(this.storeName,"readwrite"),s=r.objectStore(this.storeName).delete(e);s.onsuccess=()=>{n(null)},s.onerror=()=>{i(s.error)},r.oncomplete=()=>{o.close()}}})}set(e,t){return new Promise((n,i)=>{let o=indexedDB.open(this.databaseName);o.onerror=()=>{i(o.error)},o.onupgradeneeded=e=>{e.target.result.createObjectStore(this.storeName)},o.onsuccess=o=>{let r=o.target.result,s=r.transaction(this.storeName,"readwrite"),a=s.objectStore(this.storeName).put(t,e);a.onsuccess=()=>{n(t)},a.onerror=()=>{i(a.error)},s.oncomplete=()=>{r.close()}}})}openDatabase(){let e=this;return new Promise(function(t,n){let i=indexedDB.open(e.databaseName,2);i.onupgradeneeded=function(t){t.target.result.createObjectStore(e.storeName)},i.onsuccess=function(e){t(e.target.result)},i.onerror=function(e){n(e.error)}})}}var sha256={exports:{}};!function(module){!function(){var ERROR="input is invalid type",WINDOW="object"==typeof window,root=WINDOW?window:{};root.JS_SHA256_NO_WINDOW&&(WINDOW=!1);var WEB_WORKER=!WINDOW&&"object"==typeof self,NODE_JS=!root.JS_SHA256_NO_NODE_JS&&"object"==typeof _index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.p&&_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.p.versions&&_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.p.versions.node;NODE_JS?root=_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.c:WEB_WORKER&&(root=self);var COMMON_JS=!root.JS_SHA256_NO_COMMON_JS&&module.exports,ARRAY_BUFFER=!root.JS_SHA256_NO_ARRAY_BUFFER&&"u">typeof ArrayBuffer,HEX_CHARS="0123456789abcdef".split(""),EXTRA=[-2147483648,8388608,32768,128],SHIFT=[24,16,8,0],K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],OUTPUT_TYPES=["hex","array","digest","arrayBuffer"],blocks=[];(root.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),ARRAY_BUFFER&&(root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var createOutputMethod=function(e,t){return function(n){return new Sha256(t,!0).update(n)[e]()}},createMethod=function(e){var t=createOutputMethod("hex",e);NODE_JS&&(t=nodeWrap(t,e)),t.create=function(){return new Sha256(e)},t.update=function(e){return t.create().update(e)};for(var n=0;n<OUTPUT_TYPES.length;++n){var i=OUTPUT_TYPES[n];t[i]=createOutputMethod(i,e)}return t},nodeWrap=function(method,is224){var crypto=eval("require('crypto')"),Buffer=eval("require('buffer').Buffer"),algorithm=is224?"sha224":"sha256",nodeMethod=function(e){if("string"==typeof e)return crypto.createHash(algorithm).update(e,"utf8").digest("hex");if(null==e)throw Error(ERROR);return e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),Array.isArray(e)||ArrayBuffer.isView(e)||e.constructor===Buffer?crypto.createHash(algorithm).update(new Buffer(e)).digest("hex"):method(e)};return nodeMethod},createHmacOutputMethod=function(e,t){return function(n,i){return new HmacSha256(n,t,!0).update(i)[e]()}},createHmacMethod=function(e){var t=createHmacOutputMethod("hex",e);t.create=function(t){return new HmacSha256(t,e)},t.update=function(e,n){return t.create(e).update(n)};for(var n=0;n<OUTPUT_TYPES.length;++n){var i=OUTPUT_TYPES[n];t[i]=createHmacOutputMethod(i,e)}return t};function Sha256(e,t){t?(blocks[0]=blocks[16]=blocks[1]=blocks[2]=blocks[3]=blocks[4]=blocks[5]=blocks[6]=blocks[7]=blocks[8]=blocks[9]=blocks[10]=blocks[11]=blocks[12]=blocks[13]=blocks[14]=blocks[15]=0,this.blocks=blocks):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}function HmacSha256(e,t,n){var i,o=typeof e;if("string"===o){var r,s=[],a=e.length,l=0;for(i=0;i<a;++i)(r=e.charCodeAt(i))<128?s[l++]=r:(r<2048?s[l++]=192|r>>6:(r<55296||r>=57344?s[l++]=224|r>>12:(r=65536+((1023&r)<<10|1023&e.charCodeAt(++i)),s[l++]=240|r>>18,s[l++]=128|r>>12&63),s[l++]=128|r>>6&63),s[l++]=128|63&r);e=s}else if("object"===o){if(null===e)throw Error(ERROR);
1if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw Error(ERROR)}else throw Error(ERROR);e.length>64&&(e=new Sha256(t,!0).update(e).array());var d=[],c=[];for(i=0;i<64;++i){var u=e[i]||0;d[i]=92^u,c[i]=54^u}Sha256.call(this,t,n),this.update(c),this.oKeyPad=d,this.inner=!0,this.sharedMemory=n}Sha256.prototype.update=function(e){if(!this.finalized){var t,n=typeof e;if("string"!==n){if("object"===n){if(null===e)throw Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw Error(ERROR)}else throw Error(ERROR);t=!0}for(var i,o,r=0,s=e.length,a=this.blocks;r<s;){if(this.hashed&&(this.hashed=!1,a[0]=this.block,a[16]=a[1]=a[2]=a[3]=a[4]=a[5]=a[6]=a[7]=a[8]=a[9]=a[10]=a[11]=a[12]=a[13]=a[14]=a[15]=0),t)for(o=this.start;r<s&&o<64;++r)a[o>>2]|=e[r]<<SHIFT[3&o++];else for(o=this.start;r<s&&o<64;++r)(i=e.charCodeAt(r))<128?a[o>>2]|=i<<SHIFT[3&o++]:(i<2048?a[o>>2]|=(192|i>>6)<<SHIFT[3&o++]:(i<55296||i>=57344?a[o>>2]|=(224|i>>12)<<SHIFT[3&o++]:(i=65536+((1023&i)<<10|1023&e.charCodeAt(++r)),a[o>>2]|=(240|i>>18)<<SHIFT[3&o++],a[o>>2]|=(128|i>>12&63)<<SHIFT[3&o++]),a[o>>2]|=(128|i>>6&63)<<SHIFT[3&o++]),a[o>>2]|=(128|63&i)<<SHIFT[3&o++]);this.lastByteIndex=o,this.bytes+=o-this.start,o>=64?(this.block=a[16],this.start=o-64,this.hash(),this.hashed=!0):this.start=o}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Sha256.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=EXTRA[3&t],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}},Sha256.prototype.hash=function(){var e,t,n,i,o,r,s,a,l,d,c,u=this.h0,h=this.h1,g=this.h2,p=this.h3,f=this.h4,y=this.h5,v=this.h6,m=this.h7,w=this.blocks;for(e=16;e<64;++e)t=((o=w[e-15])>>>7|o<<25)^(o>>>18|o<<14)^o>>>3,n=((o=w[e-2])>>>17|o<<15)^(o>>>19|o<<13)^o>>>10,w[e]=w[e-16]+t+w[e-7]+n<<0;
1for(c=h&g,e=0;e<64;e+=4)this.first?(this.is224?(a=300032,m=(o=w[0]-1413257819)-150054599<<0,p=o+24177077<<0):(a=704751109,m=(o=w[0]-210244248)-1521486534<<0,p=o+143694565<<0),this.first=!1):(t=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),n=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7),i=(a=u&h)^u&g^c,o=m+n+(s=f&y^~f&v)+K[e]+w[e],r=t+i,m=p+o<<0,p=o+r<<0),t=(p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),n=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7),i=(l=p&u)^p&h^a,o=v+n+(s=m&f^~m&y)+K[e+1]+w[e+1],r=t+i,v=g+o<<0,t=((g=o+r<<0)>>>2|g<<30)^(g>>>13|g<<19)^(g>>>22|g<<10),n=(v>>>6|v<<26)^(v>>>11|v<<21)^(v>>>25|v<<7),i=(d=g&p)^g&u^l,o=y+n+(s=v&m^~v&f)+K[e+2]+w[e+2],r=t+i,y=h+o<<0,t=((h=o+r<<0)>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),n=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),i=(c=h&g)^h&p^d,o=f+n+(s=y&v^~y&m)+K[e+3]+w[e+3],r=t+i,f=u+o<<0,u=o+r<<0;this.h0=this.h0+u<<0,this.h1=this.h1+h<<0,this.h2=this.h2+g<<0,this.h3=this.h3+p<<0,this.h4=this.h4+f<<0,this.h5=this.h5+y<<0,this.h6=this.h6+v<<0,this.h7=this.h7+m<<0},Sha256.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,i=this.h3,o=this.h4,r=this.h5,s=this.h6,a=this.h7,l=HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[15&e]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[15&t]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[15&n]+HEX_CHARS[i>>28&15]+HEX_CHARS[i>>24&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[15&i]+HEX_CHARS[o>>28&15]+HEX_CHARS[o>>24&15]+HEX_CHARS[o>>20&15]+HEX_CHARS[o>>16&15]+HEX_CHARS[o>>12&15]+HEX_CHARS[o>>8&15]+HEX_CHARS[o>>4&15]+HEX_CHARS[15&o]+HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[15&r]+HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[15&s];return this.is224||(l+=HEX_CHARS[a>>28&15]+HEX_CHARS[a>>24&15]+HEX_CHARS[a>>20&15]+HEX_CHARS[a>>16&15]+HEX_CHARS[a>>12&15]+HEX_CHARS[a>>8&15]+HEX_CHARS[a>>4&15]+HEX_CHARS[15&a]),l},Sha256.prototype.toString=Sha256.prototype.hex,Sha256.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,i=this.h3,o=this.h4,r=this.h5,s=this.h6,a=this.h7,l=[e>>24&255,e>>16&255,e>>8&255,255&e,t>>24&255,t>>16&255,t>>8&255,255&t,n>>24&255,n>>16&255,n>>8&255,255&n,i>>24&255,i>>16&255,i>>8&255,255&i,o>>24&255,o>>16&255,o>>8&255,255&o,r>>24&255,r>>16&255,r>>8&255,255&r,s>>24&255,s>>16&255,s>>8&255,255&s];return this.is224||l.push(a>>24&255,a>>16&255,a>>8&255,255&a),l},Sha256.prototype.array=Sha256.prototype.digest,Sha256.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e},HmacSha256.prototype=new Sha256,HmacSha256.prototype.finalize=function(){if(Sha256.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();Sha256.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),Sha256.prototype.finalize.call(this)}};var exports=createMethod();exports.sha256=exports,exports.sha224=createMethod(!0),exports.sha256.hmac=createHmacMethod(),exports.sha224.hmac=createHmacMethod(!0),COMMON_JS?module.exports=exports:(root.sha256=exports.sha256,root.sha224=exports.sha224)}()}(sha256);var getRandomValues,rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&!(getRandomValues="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"u">typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}let REGEX=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate(e){return"string"==typeof e&&REGEX.test(e)}for(var byteToHex=[],i=0;i<256;++i)byteToHex.push((i+256).toString(16).substr(1));function stringify(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(byteToHex[e[t+0]]+byteToHex[e[t+1]]+byteToHex[e[t+2]]+byteToHex[e[t+3]]+"-"+byteToHex[e[t+4]]+byteToHex[e[t+5]]+"-"+byteToHex[e[t+6]]+byteToHex[e[t+7]]+"-"+byteToHex[e[t+8]]+byteToHex[e[t+9]]+"-"+byteToHex[e[t+10]]+byteToHex[e[t+11]]+byteToHex[e[t+12]]+byteToHex[e[t+13]]+byteToHex[e[t+14]]+byteToHex[e[t+15]]).toLowerCase();
1if(!validate(n))throw TypeError("Stringified UUID is invalid");return n}function v4(e,t,n){var i=(e=e||{}).random||(e.rng||rng)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=i[o];return t}return stringify(i)}async function getBytes(e,t){let n;let i=e.getReader();for(;!(n=await i.read()).done;)t(n.value)}function getLines(e){let t,n,i,o=!1;return function(r){void 0===t?(t=r,n=0,i=-1):t=concat(t,r);let s=t.length,a=0;for(;n<s;){o&&(10===t[n]&&(a=++n),o=!1);let r=-1;for(;n<s&&-1===r;++n)switch(t[n]){case 58:-1===i&&(i=n-a);break;case 13:o=!0;case 10:r=n}if(-1===r)break;e(t.subarray(a,r),i),a=n,i=-1}a===s?t=void 0:0!==a&&(t=t.subarray(a),n-=a)}}function getMessages(e,t,n){let i=newMessage(),o=new TextDecoder;return function(r,s){if(0===r.length)null==n||n(i),i=newMessage();else if(s>0){let n=o.decode(r.subarray(0,s)),a=s+(32===r[s+1]?2:1),l=o.decode(r.subarray(a));switch(n){case"data":i.data=i.data?i.data+`
2`+l:l;break;case"event":i.event=l;break;case"id":e(i.id=l);break;case"retry":let d=parseInt(l,10);isNaN(d)||t(i.retry=d)}}}}function concat(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function newMessage(){return{data:"",event:"",id:"",retry:void 0}}var __rest=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)0>t.indexOf(i[o])&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]]);return n};let EventStreamContentType="text/event-stream",DefaultRetryInterval=1e3,LastEventId="last-event-id";function fetchEventSource(e,t){var{signal:n,headers:i,onopen:o,onmessage:r,onclose:s,onerror:a,openWhenHidden:l,fetch:d}=t,c=__rest(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((t,u)=>{let h;let g=Object.assign({},i);function p(){h.abort(),document.hidden||b()}g.accept||(g.accept=EventStreamContentType),l||document.addEventListener("visibilitychange",p);let f=DefaultRetryInterval,y=0;function v(){document.removeEventListener("visibilitychange",p),window.clearTimeout(y),h.abort()}null==n||n.addEventListener("abort",()=>{v(),t()});let m=d??window.fetch,w=o??defaultOnOpen;async function b(){var n;h=new AbortController;try{let n=await m(e,Object.assign(Object.assign({},c),{headers:g,signal:h.signal}));await w(n),await getBytes(n.body,getLines(getMessages(e=>{e?g[LastEventId]=e:delete g[LastEventId]},e=>{f=e},r))),null==s||s(),v(),t()}catch(e){if(!h.signal.aborted)try{let t=null!==(n=null==a?void 0:a(e))&&void 0!==n?n:f;window.clearTimeout(y),y=window.setTimeout(b,t)}catch(e){v(),u(e)}}}b()})}function defaultOnOpen(e){let t=e.headers.get("content-type");if(!(null!=t&&t.startsWith(EventStreamContentType)))throw Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${t}`)}function Base64EncodeUrl(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function getTimestamp(){return Math.floor(Date.now()/1e3)}function e(e){this.message=e}e.prototype=Error(),e.prototype.name="InvalidCharacterError";var r$1="u">typeof window&&window.atob&&window.atob.bind(window)||function(t){var n=String(t).replace(/=+$/,"");if(n.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var i,o,r=0,s=0,a="";o=n.charAt(s++);~o&&(i=r%4?64*i+o:o,r++%4)&&(a+=String.fromCharCode(255&i>>(-2*r&6))))o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return a};function t$1(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(r$1(e).replace(/(.)/g,function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n}))}(t)}catch{return r$1(t)}}function n$1(e){this.message=e}function o(e,t){if("string"!=typeof e)throw new n$1("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(t$1(e.split(".")[n]))}catch(e){throw new n$1("Invalid token specified: "+e.message)}}n$1.prototype=Error(),n$1.prototype.name="InvalidTokenError";class NylasSessions{constructor(e){if(N(this,"clientId"),N(this,"redirectUri"),N(this,"accessType","online"),N(this,"domain","http://api.nylas.com"),N(this,"versioned",!1),N(this,"Storage"),N(this,"hosted",!1),N(this,"multiAccount",!1),N(this,"loginId",""),this.clientId=e.clientId,this.redirectUri=e.redirectUri,e.domain&&(this.domain=e.domain,this.domain.substring(this.domain.length-3).includes("/v")&&(this.versioned=!0)),e.multiAccount&&(this.multiAccount=e.multiAccount),e.sw){let e=new IndexedDBStorage;this.Storage=new Storage(e)}else this.Storage=new Storage;e.accessType&&(this.accessType=e.accessType),e.loginId&&(this.loginId=e.loginId),e.hosted&&(this.hosted=e.hosted),!0!==e.disableInitCodeExchange&&this.codeExchange(null)}async validateAccessToken(e=""){let t=await this.Storage.getGrant(e,this.multiAccount);if(!t)return!1;let{access_token:n}=t;try{return!!(await (await fetch(`${this.domain}/connect/tokeninfo?access_token=${n}`,{method:"GET"})).json()).data}catch{return!1}}async validateIDToken(e=""){let t=await this.Storage.getGrant(e,this.multiAccount);if(!t)return!1;let{id_token:n}=t;try{let e=await fetch(`${this.domain}/connect/tokeninfo?id_token=${n}`,{method:"GET"});return!(200!==e.status||!(await e.json()).data)}catch{return!1}}getDomain(){return this.domain}async auth(e){this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))&&await this.hostedSetCodeChallenge(
2);let t=await this.generateAuthURL(e);if(e.popup){this.popUp(t);return}return t}async generateAuthURL(e){let t=await this.getCodeChallege(),n=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;return t&&(n+=`&code_challenge=${t}&code_challenge_method=S256&options=rotate_refresh_token`),e.provider&&(n+=`&provider=${e.provider}`),e.loginHint&&(n+=`&login_hint=${e.loginHint}`,e.includeGrantScopes&&(n+=`&include_grant_scopes=${e.includeGrantScopes}`)),e.scope&&(n+=`&scope=${e.scope.join(" ")}`),e.prompt&&(n+=`&prompt=${e.prompt}`),e.metadata&&(n+=`&metadata=${e.metadata}`),(e.state||this.loginId)&&(n+=`&state=${this.loginId?this.loginId:e.state}`),n}async generateReauthURL(e,t){if(!e)throw Error("Grant ID is required");let n=await this.Storage.getUserToken(e),i=await this.getCodeChallege(),r=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;return i&&(r+=`&code_challenge=${i}&code_challenge_method=S256&options=rotate_refresh_token`),null!=n&&n.provider&&(r+=`&provider=${n.provider}`),null!=n&&n.email&&(r+=`&login_hint=${n.email}`),t&&(r+=`&scope=${t.join(" ")}`),r}async generateCodeChallenge(){if(await this.Storage.getPKCE())return;let e=v4();this.Storage.setPKCE(e)}async hostedSetCodeChallenge(){if(!this.hosted)throw console.error("Method only used with hosted flag enabled");let e=new URLSearchParams(window.location.search).get("code_challenge");if(!e){if(await this.Storage.getPKCE())return;console.warn("Code challenge is recomended");return}this.Storage.setPKCE(e)}async getCodeChallege(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin)))return new URLSearchParams(window.location.search).get("code_challenge")||(console.warn("Code challenge is recomended"),"");let e=await this.Storage.getPKCE();if(e){let t=sha256.exports.sha256(e);return Base64EncodeUrl(_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.B.from(t).toString("base64"))}return""}async isLoggedIn(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin)))return!1;let e=await this.Storage.getUserTokens();return e&&e.length>0?(this.multiAccount&&await this.generateCodeChallenge(),!0):(await this.generateCodeChallenge(),!1)}isMultiAccount(){return this.multiAccount}async logout(){let e=await this.getProfile();await this.Storage.clearSession();let t={detail:e};window.dispatchEvent(new CustomEvent("onLogoutSuccess",t))}async getProfile(e=""){let t;return(t=e?await this.Storage.getUserToken(e):await this.Storage.getUserToken())||null}async getProfiles(){return await this.Storage.getUserTokens()||null}async removeProfile(e){return await this.Storage.removeUserToken(e),await this.Storage.removeGrant(e),null}async authIMAP(e){let t=await this.getCodeChallege(),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};return this.loginId&&(n.id=this.loginId),e.smtp_username&&e.smtp_password&&(n.smtp_username=e.smtp_username,n.smtp_password=e.smtp_password),""!=t&&(n.code_challenge=t,n.code_challenge_method="S256"),await (await fetch(`${this.domain}/connect/login/imap`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(n)})).json()}async authEWS(e){let t=await this.getCodeChallege(),n={...e,provider:"ews",redirect_uri:this.redirectUri,public_application_id:this.clientId,access_type:this.accessType};return this.loginId&&(n.id=this.loginId),""!=t&&(n.code_challenge=t,n.code_challenge_method="S256"),await (await fetch(`${this.domain}/connect/login/ews`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(n)})).json()}async detectEmail(e){return await (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"})})).json()}async applicationInfo(){return(await (await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/applications?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})})).json()).data}async getAvailableProviders(){let e=await fetch(`${this.domain}/connect/providers/find?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});
2return e?(await e.json()).data:null}onLoginSuccess(e){window.addEventListener("onLoginSuccess",t=>e(t))}onLogoutSuccess(e){window.addEventListener("onLogoutSuccess",t=>e(t))}onLoginFail(e){window.addEventListener("onLoginFail",t=>e(t))}onTokenRefreshSuccess(e){window.addEventListener("onTokenRefreshSuccess",t=>e(t))}onTokenRefreshFail(e){window.addEventListener("onTokenRefreshFail",t=>e(t))}onSessionExpired(e){window.addEventListener("onSessionExpired",t=>e(t))}async codeExchange(e){let t=new URLSearchParams(window.location.search);e&&(t=new URLSearchParams(e));let n=t.get("code"),i=t.get("state"),r=t.get("error"),s=t.get("error_description"),a=t.get("error_code");if(r&&s&&a){let e={detail:{error:r,error_description:s,error_code:a}};return window.dispatchEvent(new CustomEvent("onLoginFail",e)),window.history.pushState({},document.title,window.location.pathname),!1}if(!n)return console.warn("No code found"),!1;if(window.opener&&"uas-popup"===window.name)return console.warn("Popup window detected"),!1;let l=await this.Storage.getPKCE();if(!l)return console.warn("No code verifier found"),!1;try{let e={client_id:this.clientId,redirect_uri:this.redirectUri,code:n,grant_type:"authorization_code",code_verifier:l},t=await (await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(e)})).json();if(t){if(t.error){let e={detail:t};return window.dispatchEvent(new CustomEvent("onLoginFail",e)),!0}let e=await this.handleCodeExchangeResponse(t);if(e.valid){i&&(e.data.state=i);let t={detail:e.data};window.dispatchEvent(new CustomEvent("onLoginSuccess",t)),window.history.pushState({},document.title,window.location.pathname)}else{let t={detail:e.data};return window.dispatchEvent(new CustomEvent("onLoginFail",t)),!0}}return this.Storage.removePKCE(),!0}catch(t){let e={detail:t};return window.dispatchEvent(new CustomEvent("onLoginFail",e)),window.history.pushState({},document.title,window.location.pathname),!1}}async tokenExchange(e=""){let t=await this.Storage.getGrant(e,this.multiAccount);if(!t)return!1;let n=t.refresh_token;try{let t={client_id:this.clientId,redirect_uri:this.redirectUri,refresh_token:n,grant_type:"refresh_token"},i=await (await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(t)})).json();if(i){if(i.error){let e={detail:i};return window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e)),!0}let t=getTimestamp();if(i.expires_in=t+i.expires_in,this.Storage.setGrant(i,this.multiAccount),!await this.validateIDToken(e)){let e={detail:i};return window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e)),!0}let n={detail:i};return window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess",n)),!0}this.Storage.removePKCE()}catch(t){let e={detail:t};return window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e)),!1}}async handleCodeExchangeResponse(e){if(e.error)return{data:e,valid:!1};let t=getTimestamp();e.expires_in=t+e.expires_in,this.Storage.setGrant(e,this.multiAccount);let n=o(e.id_token);return n.status="authenticated",this.Storage.setUserToken(n),await this.validateIDToken(n.sub)?{data:e,valid:!0}:{data:e,valid:!1}}async popUp(e){let t=window.screenX+(window.outerWidth-500)/2,n=window.screenY+(window.outerHeight-600)/2.5,i="uas-popup",r=e,s=window.open(r,i,`width=500,height=600,left=${t},top=${n}`);if(!s)return;let a=setInterval(async()=>{if(s.closed){let e={detail:{error_description:"OAuth provider window closed"}};window.dispatchEvent(new CustomEvent("onLoginFail",e)),a&&clearInterval(a);return}try{let e=s.location.href.split("?");if(!e[0])return;let t=s.location.search;if(s.history.pushState({},document.title,window.location.pathname),e[0]===this.redirectUri&&e.length>1){let e=await this.codeExchange(t);s.close(),e&&location.reload(),a&&clearInterval(a);return}}catch{return}},1e3)}async getAccessToken(e=""){let t=getTimestamp(),n=await this.Storage.getGrant(e,this.multiAccount);if(!n)return null;let{access_token:i,expires_in:r}=n,s=i;return s&&r&&r>getTimestamp()&&r-t>30?s:(await this.tokenExchange(e),(await this.Storage.getGrant(e,this.multiAccount)).access_token)}async sse(e,t){let n=t.headers||{},i=n["Grant-ID"],r="";if(this.multiAccount){if(!i)throw this.logout(),Error("Grant ID is required for multi account calls");r=await this.getAccessToken(i)}else r=await this.getAccessToken();return delete n["Grant-ID"],n.Authorization=`Bearer ${r}`,n["content-type"]||(n["content-type"]="application/json"),fetchEventSource(`${this.domain}/${e}`,{...t,headers:n})}async fetch(e,t,n=!0,i){let r="",s=1;if(this.multiAccount){if(!t.grant_id)throw this.logout(),Error("Grant ID is required for multi account calls");let e=await this.getProfiles();s=e?e.length:1,r=await this.getAccessToken(t.grant_id)}else r=await this.getAccessToken();if(!r)throw Error("Access token not found");let a=t.headers;Headers.prototype.isPrototypeOf(a)?(a.append("Authorization",`Bearer ${r}`),a.has("content-type")||a.append("content-type","application/json")):a=new Headers({Authorization:`Bearer ${r}`,"content-type":"application/json"});try{null!=t&&t.body&&(t.body=JSON.stringify(null==t?void 0:t.body));let r=await fetch(`${i||this.domain}/${e}`,{...t,headers:a});if(!n)return r;let l=await (null==r?void 0:r.json());if(!await this.isAuthenticatedResponse(r.status,l)){if(s>1){let e=await this.getProfile(t.grant_id);if(e){e.status="unauthorized",await this.Storage.setUserToken(e);
2let t={detail:{user:e}};window.dispatchEvent(new CustomEvent("onSessionExpired",t))}}else{let e={detail:{user:await this.Storage.getUserToken()}};window.dispatchEvent(new CustomEvent("onSessionExpired",e))}this.logout();return}return l}catch(e){throw e}}async fetchRequest(e,t,n,i=!0,r,s){let a=await this.isLoggedIn(),l=new URL(e,r??this.domain),d=new Headers;if(d.append("Accept","application/json"),d.append("Content-Type","application/json"),d.append("User-Agent","nylas-identity"),a){let e=await this.getAccessToken();d.append("Authorization",`Bearer ${e}`)}let c=await fetch(l.toString(),{method:t||"GET",headers:d,mode:"cors",referrer:location.origin,body:n?JSON.stringify(n):void 0,...s||{}});return i?await c.json():c.body}async isAuthenticatedResponse(e,t){var n;return!(401==e&&(null==(n=null==t?void 0:t.error)?void 0:n.type)=="token.unauthorized_access")}addAPIKey(e,t,n){this.Storage.setUserToken({aud:"https://api-staging.us.nylas.com/",exp:2e9,email_verified:!0,iat:getTimestamp(),iss:"",email:t,provider:"virtual-calendar",status:"authenticated",name:t,sub:e}),this.Storage.setGrant({grant_id:e,access_token:n,expires_in:2e9},this.multiAccount)}}var B={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,D={};function E(e,t,n){this.props=e,this.context=t,this.refs=D,this.updater=n||B}function F(){}function G(e,t,n){this.props=e,this.context=t,this.refs=D,this.updater=n||B}E.prototype.isReactComponent={},E.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")},E.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},F.prototype=E.prototype;var H=G.prototype=new F;H.constructor=G,C(H,E.prototype),H.isPureReactComponent=!0;let LoginRequired=({authenticationUrl:e})=>(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("div",{class:"login-required",part:"nse__login-required login-component"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("div",{class:"card",part:"nse__login-required-card"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("p",{part:"nse__login-required-text"},"Log into your account to use the Scheduler Editor."),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("button",{class:"google-button",part:"nse__login-required-google-button",onClick:async t=>{t.preventDefault();let n=await e("google");n?window.location.href=n:console.error("[nylas-scheduler-editor] Unable to get authentication URL.")}},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("span",{class:"icon"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("google-logo-icon",{width:"15",height:"15"})),"Continue with Google"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("button",{class:"microsoft-button",part:"nse__login-required-microsoft-button",onClick:async t=>{t.preventDefault();let n=await e("microsoft");n?window.location.href=n:console.error("[nylas-scheduler-editor] Unable to get authentication URL.")}},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("span",{class:"icon"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("microsoft-logo-icon",{width:"15",height:"15"})),"Continue with Microsoft"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("button",{class:"other-provider-button",part:"nse__login-required-other-provider-button",onClick:async t=>{t.preventDefault();let n=await e();n?window.location.href=n:console.error("[nylas-scheduler-editor] Unable to get authentication URL.")}},"View all providers ",(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("chevron-icon",{width:"17",height:"17"})),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("small",{class:"disclaimer-text",part:"nse__login-required-disclaimer-text"},"* You will be redirected to authenticate your account.")));function ExpressFlow({currentUser:e,calendars:t,selectedEventType:n}){let i=(null==t?void 0:t.find(e=>e.is_primary))||(null==t?void 0:t[0]);switch(n){case _constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__.C.one_on_one:case _constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__.C.max_availability:case _constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__.C.max_fairness:return(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)(_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.F,null,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-event-info",null,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("div",{slot:"inputs"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-event-title",null),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-event-duration",null),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-event-location",{userProvider:e.provider}))),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-booking-calendar-picker",{exportparts:"nbcp, nbcp__header, nbcp__dropdown, nbcp__dropdown-button, nbcp__dropdown-content",expressFlow:!0,calendars:t,currentUser:e,defaultBookingCalendar:null==i?void 0:i.id}),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-custom-event-slug",{name:"custom-event-slug",exportparts:"nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield"}));case _constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__.C.collective:return(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)(_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.F,null,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-event-info",null,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("div",{slot:"inputs"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-event-title",null),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-event-duration",null),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-event-location",{userProvider:e.provider}))),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-booking-calendar-picker",{exportparts:"nbcp, nbcp__header, nbcp__dropdown, nbcp__dropdown-button, nbcp__dropdown-content",expressFlow:!0,calendars:t,currentUser:e,defaultBookingCalendar:null==i?void 0:i.id}),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-custom-event-slug",{name:"custom-event-slug",exportparts:"nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield"}),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-additional-participants",{name:"participants",eventParticipants:[{name:(null==e?void 0:e.name)||(null==e?void 0:e.email),email:(null==e?void 0:e.email)||"",is_organizer:!0}],exportparts:"nadtnlpart, nadtnlpart__title, nadtnlpart__subtitle, nadtnlpart__content, nadtnlpart__input_group, nadtnlpart__input_wrapper, nadtnlpart__input, nadtnlpart__remove-participant"}));case _constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__.C.group:return(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)(_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.F,null,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-event-info",null,(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("div",{slot:"inputs"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-event-title",{noTemplates:!0}),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-event-description",{noTemplates:!0,hideAutoPopulateButton:!0}),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-event-location",{userProvider:e.provider}),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-event-timeslot",{name:"event-timeslot"}),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-event-capacity",null))),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-booking-calendar-picker",{exportparts:"nbcp, nbcp__header, nbcp__dropdown, nbcp__dropdown-button, nbcp__dropdown-content",expressFlow:!0,calendars:t,currentUser:e,defaultBookingCalendar:null==i?void 0:i.id}),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-additional-participants",{name:"participants",eventParticipants:[{name:(null==e?void 0:e.name)||(null==e?void 0:e.email),email:(null==e?void 0:e.email)||"",is_organizer:!0}],exportparts:"nadtnlpart, nadtnlpart__title, nadtnlpart__subtitle, nadtnlpart__content, nadtnlpart__input_group, nadtnlpart__input_wrapper, nadtnlpart__input, nadtnlpart__remove-participant"}),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-page-name",{requirePageName:!0,pageName:"Group events page"}),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-custom-event-slug",{name:"custom-event-slug",exportparts:"nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield"}))}}let nylasSchedulerEditorCss=':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 0px 6px -2px rgba(0, 0, 0, 0.05), 0px 5px 15px -3px rgba(0, 0, 0, 0.1);--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-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}@media screen and (max-width: 768px){:host{width:-moz-available;width:-webkit-fill-available;width:fill-available;min-width:325px}}:host nylas-notification{position:absolute;top:0;right:0}div.scheduler-editor-content{height:800px}@media screen and (max-width: 768px){div.scheduler-editor-content{height:auto}}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}
2div.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;max-width:fit-content;align-self:center}.login-required{height:inherit;overflow-y:auto;display:flex;flex-direction:column;justify-content:center;padding:2rem 1rem;background-color:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}@media screen and (max-width: 768px){.login-required{height:auto}}.login-required p{margin:0 0 1rem}.login-required .microsoft-button,.login-required .google-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size: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}.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}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button svg{transform:rotate(180deg)}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .disclaimer-text{font-size:0.75rem;color:var(--nylas-base-600);align-self:center}.list-configurations{padding:2rem;height:inherit;background:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}@media screen and (max-width: 768px){.list-configurations{height:auto;padding:2rem 1rem}}.list-configurations nylas-list-configurations{height:inherit;display:flex;flex-direction:column}',NylasSchedulerEditorStyle0=nylasSchedulerEditorCss,NylasSchedulerEditor=class{constructor(e){(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.r)(this,e),this.init=(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.a)(this,"init",7),this.loggedIn=(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.a)(this,"loggedIn",7),this.loggedOut=(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.a)(this,"loggedOut",7),this.schedulerConfigCloseClicked=(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.a)(this,"schedulerConfigCloseClicked",7),this.handleSchedulerConfigCloseClicked=e=>
2{let t=this.schedulerConfigCloseClicked.emit(this.host);"schedulerConfigCloseClicked"in this.eventOverrides&&this.eventOverrides.schedulerConfigCloseClicked(t,this.nylasSchedulerConfigConnector),t.defaultPrevented||(localStorage.removeItem("grant"),localStorage.removeItem("user"),window.location.reload())},this.authenticationUrl=async e=>this.nylasApiRequest?await this.nylasApiRequest.authenticationUrl({provider:e})||"":(console.error("[nylas-scheduler-editor] Nylas API Request is not initialized."),""),this.configurationId=void 0,this.nylasApiRequest=void 0,this.nylasSessionsConfig=void 0,this.defaultAuthArgs=void 0,this.eventOverrides={},this.schedulerPreviewLink="",this.defaultSchedulerConfigState=void 0,this.mode="app",this.additionalParticipants=void 0,this.hideEditorTabs=[],this.conferenceProviders=void 0,this.requiresSlug=!1,this.enableUserFeedback=!0,this.defaultLanguage=void 0,this.localization=void 0,this.nylasBranding=!0,this.experimentalFeatures=void 0,this.enableEventTypes={one_on_one:!0,collective:!0,max_fairness:!0,max_availability:!0,group:!0},this.automaticComponentRegistration=!0,this.selectedLanguage=this.defaultLanguage||_constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__.L.en,this.langVersion=0,this.version="2.0.2"}connectedCallback(){(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.b)("[nylas-scheduler-editor] connectedCallback")}async componentWillLoad(){var e,t,n,i,o,r,s,a;(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.b)("[nylas-scheduler-editor] componentWillLoad");let l=null==(e=this.additionalParticipants)?void 0:e.filter(e=>{var t;let n=(null==(t=e.calendars)?void 0:t.length)>0?e.calendars.filter(e=>e.id&&e.name):[];if(e.name&&e.email&&n.length>0)return{name:e.name,email:e.email,calendars:n}});if(this.stores={schedulerConfig:CreateNylasSchedulerConfigStore({...this.defaultSchedulerConfigState,additionalParticipants:l,conferenceProviders:this.conferenceProviders,requiresSlug:this.requiresSlug,selectedLanguage:this.defaultLanguage||_constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__.L.en,nylasBranding:this.nylasBranding,experimentalFeatures:this.experimentalFeatures,enableEventTypes:this.enableEventTypes})},!this.nylasApiRequest&&this.nylasSessionsConfig){let e=new NylasSessions(this.nylasSessionsConfig);await e.isLoggedIn(),e.onLoginSuccess(async()=>{var e,t;let n=await (null==(t=null==(e=this.nylasSchedulerConfigConnector)?void 0:e.schedulerConfig)?void 0:t.currentUser());if(n){let e=this.loggedIn.emit(this.host);"loggedIn"in this.eventOverrides&&await this.eventOverrides.loggedIn(e,this.nylasSchedulerConfigConnector),e.defaultPrevented||await this.loggedInHandler(n)}}),e.onLoginFail(async()=>{var e,t;null==(t=null==(e=this.stores)?void 0:e.schedulerConfig)||t.set("currentUser",null);let n=this.loggedOut.emit(this.host);"loggedOut"in this.eventOverrides&&(await this.eventOverrides.loggedOut(n,this.nylasSchedulerConfigConnector),n.defaultPrevented)}),this.nylasApiRequest=new _index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.N(e)}this.nylasApiRequest&&this.defaultAuthArgs&&this.nylasApiRequest.setDefaultAuthArgs(this.defaultAuthArgs),this.baseProvider=new _abstract_provider_bdb7d9b4_22cf4a74_js__WEBPACK_IMPORTED_MODULE_1__.N(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);let d=this.baseProvider.getStore("schedulerConfig");this.nylasSchedulerConfigConnector=new NylasSchedulerConfigConnector({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:d});let c=this.init.emit(this.host);if("init"in this.eventOverrides&&await this.eventOverrides.init(c,this.nylasSchedulerConfigConnector),!c.defaultPrevented){let e=await (null==(n=null==(t=this.nylasSchedulerConfigConnector)?void 0:t.schedulerConfig)?void 0:n.currentUser());if(e){let t=this.loggedIn.emit(this.host);"loggedIn"in this.eventOverrides&&await this.eventOverrides.loggedIn(t,this.nylasSchedulerConfigConnector),t.defaultPrevented||await this.loggedInHandler(e)}else{null==(o=null==(i=this.stores)?void 0:i.schedulerConfig)||o.set("currentUser",null);let e=this.loggedOut.emit(this.host);if("loggedOut"in this.eventOverrides&&(await this.eventOverrides.loggedOut(e,this.nylasSchedulerConfigConnector),e.defaultPrevented))return}}null==(s=null==(r=this.stores)?void 0:r.schedulerConfig)||s.onChange("selectedConfiguration",async e=>
2{e&&e.id&&(this.configurationId=e.id)}),null==(a=this.baseProvider)||a.componentWillLoad(this.nylasSchedulerConfigConnector)}async componentDidLoad(){var e;(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.b)("[nylas-scheduler-editor] componentDidLoad"),await (null==(e=this.baseProvider)?void 0:e.componentDidLoad()),this.updateLocalization(this.localization),this.version="2.0.2"}async componentDisconnected(){var e;await (null==(e=this.baseProvider)?void 0:e.componentDisconnected())}async configurationIdChanged(e){var t,n,i,o,r,s,a,l;e?(await (null==(n=null==(t=this.nylasSchedulerConfigConnector)?void 0:t.schedulerConfig)?void 0:n.getConfigurationById(e)),null==(o=null==(i=this.stores)?void 0:i.schedulerConfig)||o.set("action","edit")):(null==(s=null==(r=this.stores)?void 0:r.schedulerConfig)||s.set("selectedConfiguration",{}),null==(l=null==(a=this.stores)?void 0:a.schedulerConfig)||l.set("action",null))}updateLocalization(e){e&&(Object.keys(e).forEach(t=>{t in _constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__.L&&_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.i.addResourceBundle(t,"translation",e[t],!1,!0)}),this.langVersion++)}updateNylasBranding(e){var t,n;null==(n=null==(t=this.stores)?void 0:t.schedulerConfig)||n.set("nylasBranding",e)}updateExperimentalFeatures(e){var t,n;null==(n=null==(t=this.stores)?void 0:t.schedulerConfig)||n.set("experimentalFeatures",e)}updateEnableEventTypes(e){var t,n;null==(n=null==(t=this.stores)?void 0:t.schedulerConfig)||n.set("enableEventTypes",e)}async store(){var e;return null==(e=this.stores)?void 0:e.schedulerConfig}async schedulerConnector(){return this.nylasSchedulerConfigConnector}async registerComponentHandler(e){var t;null==(t=this.baseProvider)||t.registerComponent(e.detail)}async unregisterComponentHandler(e){var t;null==(t=this.baseProvider)||t.unregisterComponent(e.detail)}nylasFormDropdownChangedHandler(e){var t,n;let{name:i,value:o}=e.detail;"language"===i&&(this.selectedLanguage=_constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__.L[o],_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.i.changeLanguage(this.selectedLanguage),null==(n=null==(t=this.stores)?void 0:t.schedulerConfig)||n.set("selectedLanguage",this.selectedLanguage))}async loggedInHandler(e){var t,n,i,o,r,s,a;if(null==(n=null==(t=this.stores)?void 0:t.schedulerConfig)||n.set("currentUser",e),this.nylasSchedulerConfigConnector&&(await (null==(i=this.nylasSchedulerConfigConnector.schedulerConfig)?void 0:i.getCalendars()),this.configurationId)){let e=await (null==(o=this.nylasSchedulerConfigConnector.schedulerConfig)?void 0:o.getConfigurationById(this.configurationId));e&&null!=(r=e[0])&&r.id&&(null==(a=null==(s=this.stores)?void 0:s.schedulerConfig)||a.set("action","edit"))}}render(){var e,t,n,i,o,r,s,a,l,d,c,u,h,g,p,f,y,v,m,w,b,S,C,_,E,A,k,$,T,R,x,I,P,N,L,q,U,O,z,j,G,B,D,H;let F=this.host.querySelector('[slot="custom-page-style-inputs"]'),V=null==(n=null==(t=null==(e=this.stores)?void 0:e.schedulerConfig)?void 0:t.state.selectedConfiguration)?void 0:n.id,M=Object.keys(_constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__.a).map(e=>({label:_constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__.a[e],value:e})),W=(null==(o=null==(i=this.stores)?void 0:i.schedulerConfig)?void 0:o.state.selectedEventType)===_constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__.C.group||(null==(a=null==(s=null==(r=this.stores)?void 0:r.schedulerConfig)?void 0:s.state.selectedConfiguration)?void 0:a.type)===_constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__.C.group;return(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)(_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.H,{key:"f2ff98b69f59cf94f68e0a72750db304d5f5781c"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("div",{key:"382bac7a0ba7735ce0c6704f825d8a18a3faf412",class:"scheduler-editor-header",part:"nse__header"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("h1",{key:"eb011947ed70b8f7b2bd73a1d57c8de743782acd",class:"scheduler-editor-title",part:"nse__title"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("calendar-icon",{key:"d6a3bdf5d3c7501e865c363a58cbfd78b9ee10b1",
2width:"18",height:"18"}),_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.i.t("schedulerEditorTitle"),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("tooltip-component",{key:"d2cde09b0b5ac91a306d81dba57838ce373cda92"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("info-icon",{key:"af00e8fa6ca5ef8baaaf5a9abdf14a7138b030fd",slot:"tooltip-icon"}),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("span",{key:"24a185bac54f44abf7ffe9bf3cd2723dc363a12f",slot:"tooltip-content"},this.version))),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("div",{key:"6fdf10c991b049d0a96a09faddf056de7b80a1de",class:{language:!0},part:"nse__language"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("select-dropdown",{key:"d733d65ad4fd639f94b5fde41ae32725949fe429",name:"language",searchPlaceholder:_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.i.t("search"),options:M,withChevron:!1,defaultSelectedOption:M.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"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("span",{key:"9ae3abafd8aa09ec54f70c9d950eb1569eff6870",slot:"select-icon"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("translate-icon",{key:"e435ec08d11c784caca91cf97887e261409b559b",width:"20",height:"20"})))),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("button",{key:"2bd03fa6333f11f3da17f8ce1db6516a4f936a6f",class:"scheduler-editor-close",title:"logout",onClick:e=>this.handleSchedulerConfigCloseClicked(e),part:"nse__close-button"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("close-icon",{key:"b7e1ab191b7bfd4c892e101c5662ebeb42ad67a2",width:"18",height:"18"}))),(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("div",{key:"3a19a2dde27979aa7428a388e68b9eb8c8d266a2",class:{"scheduler-editor-content":!0,"scheduler-editor-content--group":W},part:"nse__content"},(null==(d=null==(l=this.stores)?void 0:l.schedulerConfig)?void 0:d.state.currentUser)&&null===this.stores.schedulerConfig.state.action&&(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("div",{class:"list-configurations",part:"nse__list-configurations"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-list-configurations",{exportparts:"nlc__create-new-cta, actions__dropdown,  actions__dropdown-button, actions__dropdown-content, actions-Copy, actions-Preview, actions-Delete"})),(null==(u=null==(c=this.stores)?void 0:c.schedulerConfig)?void 0:u.state.currentUser)&&"create-select"===this.stores.schedulerConfig.state.action&&(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-select-event-type",null),(null==(g=null==(h=this.stores)?void 0:h.schedulerConfig)?void 0:g.state.currentUser)&&"create"===this.stores.schedulerConfig.state.action&&W&&(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-editor-tabs-group",{mode:"composable"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)(ExpressFlow,{selectedEventType:(null==(y=null==(f=null==(p=this.stores)?void 0:p.schedulerConfig)?void 0:f.state)?void 0:y.selectedEventType)||_constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__.C.one_on_one,currentUser:null==(m=null==(v=this.stores)?void 0:v.schedulerConfig)?void 0:m.state.currentUser,calendars:null==(S=null==(b=null==(w=this.stores)?void 0:w.schedulerConfig)?void 0:b.state)?void 0:S.calendars,selectedConfiguration:null==(E=null==(_=null==(C=this.stores)?void 0:C.schedulerConfig)?void 0:_.state)?void 0:E.selectedConfiguration})),(null==(k=null==(A=this.stores)?void 0:A.schedulerConfig)?void 0:k.state.currentUser)&&"create"===this.stores.schedulerConfig.state.action&&!W&&(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-editor-tabs",{mode:"composable"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)(ExpressFlow,{selectedEventType:(null==(R=null==(T=null==($=this.stores)?void 0:$.schedulerConfig)?void 0:T.state)?void 0:R.selectedEventType)||_constants_f51538ef_e0a5f026_js__WEBPACK_IMPORTED_MODULE_3__.C.one_on_one,currentUser:null==(I=null==(x=this.stores)?void 0:x.schedulerConfig)?void 0:I.state.currentUser,calendars:null==(L=null==(N=null==(P=this.stores)?void 0:P.schedulerConfig)?void 0:N.state)?void 0:L.calendars,selectedConfiguration:null==(O=null==(U=null==(q=this.stores)?void 0:q.schedulerConfig)?void 0:U.state)?void 0:O.selectedConfiguration})),(null==(j=null==(z=this.stores)?void 0:z.schedulerConfig)?void 0:j.state.currentUser)&&"edit"===this.stores.schedulerConfig.state.action&&W&&(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-editor-tabs-group",{key:V,mode:this.mode},"composable"===this.mode&&(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("slot",null),"app"===this.mode&&F&&(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("div",{style:{display:"none"},slot:"custom-page-style-inputs",key:V},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("slot",{name:"custom-page-style-inputs"}))),(null==(B=null==(G=this.stores)?void 0:G.schedulerConfig)?void 0:B.state.currentUser)&&"edit"===this.stores.schedulerConfig.state.action&&!W&&(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("nylas-editor-tabs",{key:V,mode:this.mode},"composable"===this.mode&&(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("slot",null),"app"===this.mode&&F&&(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("div",{style:{display:"none"},slot:"custom-page-style-inputs",key:V},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("slot",{name:"custom-page-style-inputs"}))),!(null!=(H=null==(D=this.stores)?void 0:D.schedulerConfig)&&H.state.currentUser)&&(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)("slot",{name:"login-required"},(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.h)(LoginRequired,{authenticationUrl:this.authenticationUrl}))))}get host(){return(0,_index_ad781fbc_js__WEBPACK_IMPORTED_MODULE_0__.g)(this)}static get watchers(){return{configurationId:["configurationIdChanged"],localization:["updateLocalization"],nylasBranding:["updateNylasBranding"],experimentalFeatures:["updateExperimentalFeatures"],enableEventTypes:["updateEnableEventTypes"]}}};NylasSchedulerEditor.style=NylasSchedulerEditorStyle0}}]);
3//# sourceMappingURL=7503.2e8e939cb558c360.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.