@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.
Files changed (57) hide show
  1. package/dist/cdn/nylas-scheduler-editor/nylas-scheduler-editor.es.js +954 -953
  2. package/dist/cdn/nylas-scheduling/nylas-scheduling.es.js +10 -9
  3. package/dist/cjs/{abstract-provider-CH5yXWmY.js → abstract-provider-NL9mvsRm.js} +3 -3
  4. package/dist/cjs/abstract-provider-NL9mvsRm.js.map +1 -0
  5. package/dist/cjs/google-logo-icon_6.cjs.entry.js +1 -1
  6. package/dist/cjs/nylas-scheduler-editor.cjs.entry.js +2 -2
  7. package/dist/cjs/nylas-scheduling.cjs.entry.js +3 -3
  8. package/dist/cjs/nylas-scheduling.cjs.entry.js.map +1 -1
  9. package/dist/cjs/nylas-scheduling.entry.cjs.js.map +1 -1
  10. package/dist/cjs/{version-COw2dh2E.js → version-y-IXeOX1.js} +3 -3
  11. package/dist/cjs/{version-COw2dh2E.js.map → version-y-IXeOX1.js.map} +1 -1
  12. package/dist/collection/common/abstract-provider.js +1 -1
  13. package/dist/collection/common/abstract-provider.js.map +1 -1
  14. package/dist/collection/components/scheduler/nylas-scheduling/nylas-scheduling.js +6 -1
  15. package/dist/collection/components/scheduler/nylas-scheduling/nylas-scheduling.js.map +1 -1
  16. package/dist/collection/version.js +1 -1
  17. package/dist/collection/version.js.map +1 -1
  18. package/dist/components/nylas-editor-tabs-group.js +1 -1
  19. package/dist/components/nylas-editor-tabs.js +1 -1
  20. package/dist/components/nylas-scheduler-editor.js +4 -4
  21. package/dist/components/nylas-scheduling.js +3 -3
  22. package/dist/components/nylas-scheduling.js.map +1 -1
  23. package/dist/components/{p-Bd0cKEr-.js → p-677FcYj-.js} +3 -3
  24. package/dist/components/{p-Bd0cKEr-.js.map → p-677FcYj-.js.map} +1 -1
  25. package/dist/components/{p-DTmxwCTa.js → p-BW6mh3NI.js} +3 -3
  26. package/dist/components/{p-DTmxwCTa.js.map → p-BW6mh3NI.js.map} +1 -1
  27. package/dist/components/{p-BvQ13Bty.js → p-CigXeIp5.js} +3 -3
  28. package/dist/components/p-CigXeIp5.js.map +1 -0
  29. package/dist/components/{p-ejCgVZ9o.js → p-CzVKC2Lf.js} +3 -3
  30. package/dist/components/{p-ejCgVZ9o.js.map → p-CzVKC2Lf.js.map} +1 -1
  31. package/dist/esm/{abstract-provider-KowNUOZM.js → abstract-provider-Bxd_4MUD.js} +3 -3
  32. package/dist/esm/abstract-provider-Bxd_4MUD.js.map +1 -0
  33. package/dist/esm/google-logo-icon_6.entry.js +1 -1
  34. package/dist/esm/nylas-scheduler-editor.entry.js +2 -2
  35. package/dist/esm/nylas-scheduling.entry.js +3 -3
  36. package/dist/esm/nylas-scheduling.entry.js.map +1 -1
  37. package/dist/esm/{version-DDixcvI0.js → version-CqK6_Oc7.js} +3 -3
  38. package/dist/esm/{version-DDixcvI0.js.map → version-CqK6_Oc7.js.map} +1 -1
  39. package/dist/nylas-web-elements/nylas-scheduling.entry.esm.js.map +1 -1
  40. package/dist/nylas-web-elements/nylas-web-elements.esm.js +1 -1
  41. package/dist/nylas-web-elements/{p-a6d5e357.entry.js → p-196717a0.entry.js} +3 -3
  42. package/dist/nylas-web-elements/{p-DDixcvI0.js → p-CqK6_Oc7.js} +2 -2
  43. package/dist/nylas-web-elements/{p-DDixcvI0.js.map → p-CqK6_Oc7.js.map} +1 -1
  44. package/dist/nylas-web-elements/{p--bAq8KLi.js → p-DGwaF706.js} +2 -2
  45. package/dist/nylas-web-elements/p-DGwaF706.js.map +1 -0
  46. package/dist/nylas-web-elements/{p-937127a0.entry.js → p-ca41de7e.entry.js} +2 -2
  47. package/dist/nylas-web-elements/{p-f5cf4c30.entry.js → p-d1dc06a1.entry.js} +2 -2
  48. package/dist/nylas-web-elements/p-d1dc06a1.entry.js.map +1 -0
  49. package/dist/types/version.d.ts +1 -1
  50. package/package.json +1 -1
  51. package/dist/cjs/abstract-provider-CH5yXWmY.js.map +0 -1
  52. package/dist/components/p-BvQ13Bty.js.map +0 -1
  53. package/dist/esm/abstract-provider-KowNUOZM.js.map +0 -1
  54. package/dist/nylas-web-elements/p--bAq8KLi.js.map +0 -1
  55. package/dist/nylas-web-elements/p-f5cf4c30.entry.js.map +0 -1
  56. /package/dist/nylas-web-elements/{p-a6d5e357.entry.js.map → p-196717a0.entry.js.map} +0 -0
  57. /package/dist/nylas-web-elements/{p-937127a0.entry.js.map → p-ca41de7e.entry.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{h as e,F as t,r as i,c as n,H as s,a as o}from"./p-0EQQA0nE.js";import{N as a}from"./p--bAq8KLi.js";import{i as r,n as l,f as c,a as d,L as h,h as g,j as f,k as u,c as p}from"./p-BW6igRcf.js";import{E as m,v as b,u as y}from"./p-DDixcvI0.js";import{c as _}from"./p-_i6H-yQH.js";import{i as w,a as v,f as k,c as I,b as x}from"./p-B8tfyAQm.js";class C{constructor(){this.component=e=>{const t=m.Component;const i=`${e} Error`;return{endtime_not_in_future:(e='"endtime" can not be in the future')=>({title:i,message:e,category:t}),no_booking_info:(e="No booking info provided")=>({title:i,message:e,category:t}),no_timeslot_selected:(e="No timeslot selected")=>({title:i,message:e,category:t}),no_timezone_selected:(e="No timezone selected")=>({title:i,message:e,category:t}),no_booking_id:(e="No booking id provided")=>({title:i,message:e,category:t}),no_salt:(e="No salt provided")=>({title:i,message:e,category:t}),invalid_start_time:(e="Invalid start time")=>({title:i,message:e,category:t}),invalid_end_time:(e="Invalid end time")=>({title:i,message:e,category:t}),invalid_timezone:(e="Invalid timezone")=>({title:i,message:e,category:t}),no_config_id:(e="No configuration id provided")=>({title:i,message:e,category:t})}};this.api=e=>{const t=m.Api;const i=`${e} Error`;return{invalid_session:e=>({title:i,message:e,category:t}),general_error:e=>({title:i,message:e,category:t}),internal_error:e=>({title:i,message:e,category:t}),invalid_request_error:e=>({title:i,message:e,category:t}),timeslot_not_available:e=>({title:i,message:e,category:t}),provider_error:e=>({title:i,message:e,category:t}),not_found_error:e=>({title:i,message:e,category:t})}}}}class T{constructor({schedulerAPIURL:e,schedulerStore:t,sessionId:i,configId:n,slug:s,clientId:o}){this.errors=new C;this.schedulerStore=t;this.schedulerAPIURL=e;this.sessionId=i;this.configId=n;this.slug=s;this.clientId=o}getHeaders(){return this.sessionId?{Authorization:`Bearer ${this.sessionId}`}:{}}async makeAPIRequest(e,t,i,n={},s){try{const o=new URL(this.schedulerAPIURL);o.pathname=e;const a=await fetch(decodeURIComponent(o.toString()),{method:t,headers:{"Content-Type":"application/json",Origin:window.location.origin,"X-Source":"nylas-scheduling","X-Nylas-Web-Elements-Version":b,...this.clientId&&{"X-Nylas-Application-Public-Id":this.clientId},...n},body:i,signal:s});const r=await a.json();return r}catch(e){if(e.name==="AbortError"){throw e}return{error:{message:e.message,title:"API request failed",type:"api"}}}}getErrorMessage(e){let t=e?.message||e?.title||"Something went wrong";if(e?.type==="provider_error"){t=e?.provider_error?.error?.message||e?.provider_error?.error?.title||"Something went wrong"}return t}setConfigId(e){this.configId=e}setSchedulerAPIURL(e){if(e==="/"){e=new URL(window.location.href).origin}this.schedulerAPIURL=e}setSessionId(e){this.sessionId=e}selectDate(e){this.schedulerStore.set("selectedDate",e);this.schedulerStore.set("selectedTimeslot",null)}selectTime(e){this.schedulerStore.set("selectedTimeslot",e)}selectTimezone(e){this.schedulerStore.set("selectedTimezone",e)}selectLanguage(e){this.schedulerStore.set("selectedLanguage",e);r.changeLanguage(e)}async toggleAdditionalData(e){if(!e){await this.refetchAvailability()}this.schedulerStore.set("showBookingForm",e)}setParticipantName(e){const{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...t?.primaryParticipant,name:e}})}setParticipantEmail(e){const{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...t?.primaryParticipant,email:e}})}async refetchAvailability(){const e=new Date;const t=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3;const i=t<e.getTime()/1e3?Math.floor(e.getTime()/1e3):t;const n=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3;const s=await this.getAvailability(i,n);return s}async resetStoreStateAndFetchAvailability(){const e=new Date;const t=await this.refetchAvailability();const i=this.schedulerStore.get("availability").find((e=>{const t=l(e.start_time);return t?t>new Date:false}));let n=e;if(i){n=l(i.start_time)||e}this.schedulerStore.set("selectedDate",n);this.schedulerStore.set("eventInfo",null);this.schedulerStore.set("showBookingForm",false);this.schedulerStore.set("selectedTimeslot",null);return t}async setReschedule(e){this.schedulerStore.set("isLoading",true);const t=this.schedulerStore.state.eventInfo;if(t){this.schedulerStore.set("reschedulingEventInfo",t)}this.schedulerStore.set("rescheduleBookingId",e);await this.getUISettings();const i=await this.resetStoreStateAndFetchAvailability().finally((()=>{this.schedulerStore.set("isLoading",false)}));return i}async setCancel(e){this.schedulerStore.set("cancelBookingId",e)}async setReject(e){this.schedulerStore.set("rejectBookingId",e)}async resetCancel(){const e=await this.resetStoreStateAndFetchAvailability();this.schedulerStore.set("cancelBookingId","");this.schedulerStore.set("rejectBookingId","");this.schedulerStore.set("cancelledEventInfo",null);return e}async goBack(){this.schedulerStore.set("cancelBookingId","");return}async resetConfirm(){const e=await this.resetStoreStateAndFetchAvailability();this.schedulerStore.set("organizerConfirmationBookingId","");this.schedulerStore.set("confirmedEventInfo",undefined);return e}async bookTimeslot(e){this.schedulerStore.set("isLoading",true);const{selectedTimeslot:t,selectedTimezone:i,bookingInfo:n,selectedLanguage:s}=this.schedulerStore.state;if(!e&&!n){return{error:this.errors.component(r.t("createBookingErrorTitle")).no_booking_info()}}const o=e?.timeslot||t;if(!o){return{error:this.errors.component(r.t("createBookingErrorTitle")).no_timeslot_selected()}}const a=e&&e?.timezone?e?.timezone:i;const l=s||"en-US";if(!a){return{error:this.errors.component(r.t("createBookingErrorTitle")).no_timezone_selected()}}const c=[...this.schedulerStore.get("availabilityOrderEmails")];let d="";const h=o?.emails||[];const g={};Object.entries(n?.additionalFields||{}).forEach((([e,t])=>{g[e]=t.value}));const f=e?e?.primaryParticipant:n?.primaryParticipant;const u=e?e?.guests||[]:n?.guests||[];const p=e?e?.additionalFields:g;const m=this.getHeaders();const b=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const y=`/v3/scheduling/bookings${b}`;if(c.length===0){const e=await this.makeAPIRequest(decodeURIComponent(y),"POST",JSON.stringify({additional_fields:p,additional_guests:u,guest:{...f},start_time:o.start_time.getTime()/1e3,end_time:o.end_time.getTime()/1e3,timezone:a,event_id:o?.event_id||undefined,master_id:o?.master_id||undefined,calendar_id:o?.calendar_id||undefined,email_language:this.getTwoLetterLanguageCode(l)}),m);this.schedulerStore.set("isLoading",false);if("data"in e){this.schedulerStore.set("eventInfo",e.data);return e}return{error:e.error}}while(c.length>0){d=c.shift();if(!h.includes(d)){continue}const e=await this.makeAPIRequest(decodeURIComponent(y),"POST",JSON.stringify({participants:d?[{email:d}]:undefined,additional_fields:p,additional_guests:u,guest:{...f},start_time:o.start_time.getTime()/1e3,end_time:o.end_time.getTime()/1e3,timezone:a,email_language:this.getTwoLetterLanguageCode(l)}),m);if("data"in e){this.schedulerStore.set("isLoading",false);this.schedulerStore.set("eventInfo",e?.data);return e}else if(e.error?.message?.startsWith("The selected timeslot is unavailable")){continue}else{this.schedulerStore.set("isLoading",false);const t=e.error?.type;let i=e.error;if(t&&t in this.errors.api(r.t("createBookingErrorTitle"))){const e=this.getErrorMessage(i);i=this.errors.api(r.t("createBookingErrorTitle"))[t](e)}return{error:i}}}this.schedulerStore.set("isLoading",false);return{error:this.errors.api(r.t("createBookingErrorTitle")).timeslot_not_available("The selected timeslot is unavailable")}}async getUISettings(e){this.schedulerStore.set("isLoading",true);const t=this.schedulerStore.get("rescheduleBookingId");const i=this.getHeaders();let n=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";if(t&&!!n){n+=`&booking_id=${t}`}else if(t){n+=`?booking_id=${t}`}const s=`/v3/scheduling/ui-settings${n}`;const o=await this.makeAPIRequest(s,"GET",undefined,i,e);if("error"in o){this.schedulerStore.set("isLoading",false);const e=o.error?.type;let t=o.error;if(e&&e in this.errors.api(r.t("getUISettingErrorTitle"))){t=this.errors.api(r.t("getUISettingErrorTitle"))[e](t?.message||t?.title||"Something went wrong")}return{error:t}}if("data"in o){this.schedulerStore.set("configSettings",o.data);this.clientId=o.data.app_client_id||this.clientId}this.schedulerStore.set("isLoading",false);return o}getTwoLetterLanguageCode(e){return e.split("-")[0]}getStartTimeWithMinBookingNotice(e){const t=this.schedulerStore.get("configSettings")?.scheduler;const i=t?.min_booking_notice;if(!i){return e}const n=(new Date).getTime();if(e<(n+i*60*1e3)/1e3){return Math.floor((n+i*60*1e3)/1e3)}else{return e}}getEndTimeForAvailableDaysInFuture(e){const t=new Date;const i=this.schedulerStore.get("configSettings")?.scheduler?.available_days_in_future;const n=Math.floor(c(t,i).getTime()/1e3);const s=Math.min(n,e);return s}async getAvailability(e=0,t=0,i){this.schedulerStore.set("isLoading",true);const n=new URLSearchParams;const s=new Date;const o=s.getTime();if(t&&t<o/1e3){this.schedulerStore.set("isLoading",false);const e=this.errors.component(r.t("getAvailabilityErrorTitle")).endtime_not_in_future();return{error:e}}if(!e){const t=new Date(s.getFullYear(),s.getMonth(),1);e=Math.floor(t.getTime()/1e3)}if(!t){const e=new Date(s.getFullYear(),s.getMonth()+1,0);t=Math.floor(e.getTime()/1e3)}t=this.getEndTimeForAvailableDaysInFuture(t);const a=this.getStartTimeWithMinBookingNotice(e);e=a;t=a>t?a+1:t;n.append("start_time",encodeURIComponent(e.toString()));n.append("end_time",encodeURIComponent(t.toString()));if(this.configId&&!this.sessionId){n.append("configuration_id",encodeURIComponent(this.configId))}else if(this.slug&&this.clientId&&!this.sessionId){n.append("slug",encodeURIComponent(this.slug));n.append("client_id",encodeURIComponent(this.clientId))}const l=this.schedulerStore.get("rescheduleBookingId");if(l){n.append("booking_id",encodeURIComponent(l))}const c=n.toString();const d=`/v3/scheduling/availability${c?`?${c}`:""}`;const h=this.getHeaders();const g=await this.makeAPIRequest(decodeURIComponent(d),"GET",undefined,h,i);if("error"in g){this.schedulerStore.set("availability",[]);this.schedulerStore.set("isLoading",false);const e=g.error?.type;let t=g.error;if(t?.message?.toLowerCase().includes("Failed to find a valid Grant")){const e=r.t("invalidGrantError");return{error:{title:r.t("invalidGrantErrorTitle"),message:e,category:m.Api}}}if(e&&e in this.errors.api(r.t("getAvailabilityErrorTitle"))){const i=this.getErrorMessage(t);t=this.errors.api(r.t("getAvailabilityErrorTitle"))[e](i)}return{error:t}}if("data"in g){const e=g.data?.time_slots?.map((e=>({...e,start_time:new Date(e.start_time*1e3),end_time:new Date(e.end_time*1e3)})))||[];const t=e.filter((e=>e.start_time.getTime()>o));const i=t.sort(((e,t)=>e.start_time.getTime()-t.start_time.getTime()));this.schedulerStore.set("availability",i);const n=g.data?.order||[];this.schedulerStore.set("availabilityOrderEmails",n)}this.schedulerStore.set("isLoading",false);return g}async cancelBooking(e,t){this.schedulerStore.set("isLoading",true);if(!e){return{error:this.errors.component(r.t("cancelBookingErrorTitle")).no_booking_id()}}const i=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const n=`/v3/scheduling/bookings/${e}${i}`;const s=this.getHeaders();const o=await this.makeAPIRequest(decodeURIComponent(n),"DELETE",JSON.stringify({action:"cancel",cancellation_reason:t}),s);if("error"in o){this.schedulerStore.set("isLoading",false);const e=o.error?.type;let t=o.error;if(e&&e in this.errors.api(r.t("cancelBookingErrorTitle"))){const i=this.getErrorMessage(t);t=this.errors.api(r.t("cancelBookingErrorTitle"))[e](i)}return{error:t}}this.schedulerStore.set("cancelledEventInfo",{booking_id:e});this.schedulerStore.set("rescheduleBookingId","");this.schedulerStore.set("isLoading",false);return o}async rescheduleBooking(e,t){this.schedulerStore.set("isLoading",true);if(!e){return{error:this.errors.component(r.t("rescheduleBookingErrorTitle")).no_booking_id()}}const i=this.errors.api(r.t("rescheduleBookingErrorTitle"));const n=this.errors.component(r.t("rescheduleBookingErrorTitle"));const{bookingInfo:s,selectedTimeslot:o,selectedTimezone:a,selectedLanguage:l}=this.schedulerStore.state;const{startTime:c,endTime:d,timezone:h}=t;const g=c||o?.start_time;if(!g){return{error:n.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')}}const f=d||o?.end_time;if(!f){return{error:n.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')}}const u=this.schedulerStore.get("availabilityOrderEmails");let p="";if(u.length>0){const e=o?.emails||[];for(let t=0;t<u.length;t++){if(e.includes(u[t])){p=u[t];break}}}const m=h||a;if(!m){return{error:n.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.')}}const b=o?.event_id||undefined;const y=o?.master_id||undefined;const _=o?.calendar_id||undefined;const w={};Object.entries(s?.additionalFields||{}).forEach((([e,t])=>{w[e]=t.value}));const v=t?t?.primaryParticipant:s?.primaryParticipant;const k=t?t?.guests||[]:s?.guests||[];const I=t?t?.additionalFields:w;const x=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const C=`/v3/scheduling/bookings/${e}${x}`;const T=this.getHeaders();const S=await this.makeAPIRequest(decodeURIComponent(C),"PATCH",JSON.stringify({start_time:g.getTime()/1e3,end_time:f.getTime()/1e3,timezone:m,additional_fields:I,guest:{...v},additional_guests:k,participants:p?[{email:p}]:undefined,email_language:this.getTwoLetterLanguageCode(l),event_id:b,master_id:y,calendar_id:_}),T);if("error"in S){this.schedulerStore.set("isLoading",false);const e=S.error?.type;let t=S.error;if(e&&e in i){const n=this.getErrorMessage(t);t=i[e](n)}return{error:t}}const E=this.schedulerStore.get("reschedulingEventInfo");if("data"in S){this.schedulerStore.set("eventInfo",S?.data);if(S.data?.booking_id){this.schedulerStore.set("rescheduleBookingId",S.data.booking_id)}}else if(E){this.schedulerStore.set("eventInfo",E)}else{const t={booking_id:e};this.schedulerStore.set("eventInfo",t)}this.schedulerStore.set("reschedulingEventInfo",undefined);this.schedulerStore.set("isLoading",false);return S}async updateBooking(e){this.schedulerStore.set("isLoading",true);const{bookingId:t,status:i,reason:n}=e;const s=this.schedulerStore.get("organizerConfirmationSalt");const o=i==="confirmed"?r.t("confirmBookingErrorTitle"):r.t("rejectBookingErrorTitle");if(!t){return{error:this.errors.component(o).no_booking_id()}}if(!s){return{error:this.errors.component(o).no_salt()}}const a=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const l=`/v3/scheduling/bookings/${t}${a}`;const c=this.getHeaders();const d=await this.makeAPIRequest(decodeURIComponent(l),"PUT",JSON.stringify({status:i,cancellation_reason:n,salt:s}),c);if("error"in d){this.schedulerStore.set("isLoading",false);const e=d.error?.type;let t=d.error;if(e&&e in this.errors.api(o)){const i=this.getErrorMessage(t);t=this.errors.api(o)[e](i)}return{error:t}}if("data"in d&&i==="confirmed"){this.schedulerStore.set("confirmedEventInfo",d?.data)}else if("request_id"in d&&i==="cancelled"){this.schedulerStore.set("cancelledEventInfo",{booking_id:t})}this.schedulerStore.set("organizerConfirmationBookingId","");this.schedulerStore.set("isLoading",false);return d}async validateGroupEventTimeslot(e){this.schedulerStore.set("isLoading",true);const t=this.schedulerStore.get("configSettings")?.configuration_id;if(!t){return{error:this.errors.component(r.t("validateTimeslotErrorTitle")).no_config_id()}}const i=this.getHeaders();const n=`/v3/scheduling/configurations/${t}/group-events/validate-timeslot`;const s=await this.makeAPIRequest(decodeURIComponent(n),"POST",JSON.stringify({...e,start_time:e.start_time.getTime()/1e3,end_time:e.end_time.getTime()/1e3}),i);if("error"in s){this.schedulerStore.set("isLoading",false);const e=s.error?.type;let t=s.error;if(e&&e in this.errors.api(r.t("validateTimeslotErrorTitle"))){const i=this.getErrorMessage(t);t=this.errors.api(r.t("validateTimeslotErrorTitle"))[e](i)}this.refetchAvailability();return{error:t}}this.schedulerStore.set("selectedTimeslot",e);this.schedulerStore.set("showBookingForm",true);this.schedulerStore.set("isLoading",false);return s}}class S{constructor({schedulerAPIURL:e,nylasSchedulerStore:t,sessionId:i,configId:n,slug:s,clientId:o}){if(!e){throw new Error("schedulerAPIURL is required")}if(!t){throw new Error("nylasSchedulerStore is required")}if(!i&&!n&&!(s&&o)){throw new Error("sessionId is required for private configs. If using public config either pass a configurationId or a combination of slug and clientId.")}if(e==="/"){const t=new URL(window.location.href);e=t.origin}this.configId=n;this.sessionId=i;this.schedulerAPIURL=e;this.nylasSchedulerStore=t;this.slug=s;this.clientId=o}init(){d("NylasConnector init")}get schedulerStore(){return this.nylasSchedulerStore}setSchedulerAPIURL(e){if(e==="/"){e=new URL(window.location.href).origin}this.schedulerAPIURL=e;if(this._schedulerAPIConnector){this._schedulerAPIConnector.setSchedulerAPIURL(e)}}get scheduler(){if(this._schedulerAPIConnector){return this._schedulerAPIConnector}this._schedulerAPIConnector=new T({schedulerAPIURL:this.schedulerAPIURL,schedulerStore:this.schedulerStore,sessionId:this.sessionId,configId:this.configId,slug:this.slug,clientId:this.clientId});return this._schedulerAPIConnector}resetStores(){this.nylasSchedulerStore.reset()}}function E(e={}){const t={selectedDate:null,selectedLanguage:navigator.language,selectedTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTimeslot:null,showBookingForm:false,availabilityOrderEmails:[],selectableDates:null,availability:[],eventDuration:0,state:"ready",eventInfo:null,cancelledEventInfo:null,isLoading:false,nylasBranding:true,...e};d(`[defaultNylasStoreState]: `,t);const i=_(t);i.onChange("availability",(e=>{d(`[availability]: `,e);const t=e.map((e=>e.start_time));d(`[selectableDates]: `,t);i.set("selectableDates",t);const n=e[0];if(!n)return;const s=Math.floor((n.end_time.getTime()-n.start_time.getTime())/6e4);d(`[durationMinutes]: `,s);i.set("eventDuration",s)}));i.reset=()=>{for(const e in t){const n=t[e];i.set(e,n)}};return i}const L=(i,n)=>{const s=i.isLoading;const o=i.showNotification;const a=i.nylasBranding;const r=i.version;return e(t,null,o&&e("nylas-notification",null),s&&e("div",{class:"loading"},e("div",{class:"left"},e("div",{class:"skeleton"})),e("div",{class:"right"},e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}))),!s&&n,e("div",{key:"ns-footer",class:"footer",part:"ns_footer"},a&&e("a",{href:"https://scheduler.nylas.com?utm_source=powered-by-nylas-logoutm_medium=link&utm_campaign=get-scheduler&utm_id=get-scheduler",class:"powered-by-nylas",target:"_blank",rel:"noreferrer noopener"},"Powered by ",e("span",{class:"sr-only"},"Nylas"),e("nylas-logo",{"aria-hidden":true})),e("tooltip-component",null,e("info-icon",{slot:"tooltip-icon"}),e("span",{slot:"tooltip-content"},r))))};const B=(t,i)=>e("div",{class:"message-banner"},i);const D=':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 4px 8px 2px rgba(0, 0, 0, 0.05), 0px 8px 16px -2px rgba(0, 0, 0, 0.1);--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-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;font-family:var(--nylas-font-family);font-optical-sizing:auto;font-style:normal;font-variation-settings:"slnt" 0}@media screen and (max-width: 768px){:host{width:auto;min-width:325px}}:root{font-family:inherit}.error{padding:8rem 12rem;color:var(--nylas-base-0);background-color:var(--nylas-error);margin:1.5rem;border-radius:var(--nylas-border-radius-2x)}.message-banner{text-align:right;color:var(--nylas-base-800);padding:1rem;border-bottom:1px solid var(--nylas-color-primary-200);margin:0}.loading{margin:1.5rem;display:flex;gap:1rem}.loading .skeleton{border-radius:var(--nylas-border-radius-2x);animation:pulsate 1.5s infinite}.loading .skeleton:nth-child(2){animation-delay:-100ms}.loading .skeleton:nth-child(3){animation-delay:-200ms}.loading .skeleton:nth-child(4){animation-delay:-300ms}.loading .skeleton:nth-child(5){animation-delay:-400ms}.loading .left .skeleton{height:100%;width:400px}.loading .right .skeleton{height:5rem;width:300px;margin-bottom:1rem}.loading .right .skeleton:last-child{margin-bottom:0}@keyframes pulsate{0%{background-color:var(--nylas-base-50)}50%{background-color:var(--nylas-base-100)}100%{background-color:var(--nylas-base-50)}}.select-date-page,.additional-data-page,.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{border-top-left-radius:var(--nylas-border-radius-2x);border-top-right-radius:var(--nylas-border-radius-2x)}.select-date-page,.additional-data-page{display:flex}@media screen and (max-width: 768px){.select-date-page,.additional-data-page{flex-direction:column}}.booked-event-page,.manual-confirmation-page{background-color:var(--nylas-base-50)}.cancelled-event-page,.manual-confirmation-page,.cancel-flow-page{padding:1rem;height:496px;display:flex;justify-content:center;align-items:center}.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{min-width:784px;background:var(--nylas-base-50)}@media screen and (max-width: 768px){.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{min-width:90%}}.left-panel{display:flex;flex-direction:column;min-width:424px;border-top-left-radius:inherit;background:var(--nylas-base-0);position:relative;padding:1rem 0 0 0;height:624px}@media screen and (max-width: 768px){.left-panel{border-top-right-radius:inherit;min-width:unset;height:auto}}@media screen and (max-width: 768px){.select-date-page .left-panel{height:624px}}.border{margin-left:-20px;margin-right:-20px;border-top-width:1px;height:0.5px;background-color:var(--nylas-base-200)}@media screen and (max-width: 768px){.border{display:none}}.right-panel{min-width:360px;width:360px;background-color:var(--nylas-base-50);height:624px;padding-top:16px;border-left:1px solid var(--nylas-base-200);border-top-right-radius:inherit}.right-panel.reschedule{border-top-right-radius:0px}@media screen and (max-width: 768px){.right-panel{border-top-right-radius:0px;width:inherit;min-width:unset;height:auto;border-left:none}}.right-panel h2{display:flex;margin:0;height:48px;gap:0.5rem;justify-content:center;align-items:center;width:auto;font-size:1.125rem;line-height:1.5rem;font-weight:500;text-align:center;color:var(--nylas-base-800)}.additional-data-page .left-panel{background-color:var(--nylas-base-50)}.additional-data-page .right-panel{background-color:var(--nylas-base-0)}nylas-selected-event-card{height:604px;padding:0 1rem}@media screen and (max-width: 768px){nylas-selected-event-card{height:250px}}.footer{display:flex;justify-content:flex-end;align-items:center;gap:8px;padding:16px;font-size:14px;font-weight:300;color:var(--nylas-base-500);border-top:1px solid var(--nylas-base-200);min-height:24px}.footer .powered-by-nylas{display:flex;align-items:center;text-decoration:none;color:var(--nylas-base-500)}.footer .powered-by-nylas:hover{color:var(--nylas-base-800)}.footer svg{fill:var(--nylas-base-500)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}.footer svg{margin-top:1px}nylas-selected-event-card::part(nsec__timezone){position:absolute;bottom:0}nylas-notification{margin:1.5rem;width:-webkit-fill-available;width:-moz-available;position:absolute}nylas-locale-switch{position:absolute;padding:18px 20px;bottom:0;width:-webkit-fill-available;width:-moz-available;border-top:1px solid var(--nylas-base-200)}@media screen and (max-width: 768px){nylas-locale-switch{height:auto}}nylas-date-picker{padding:0 20px}button-component#report-issue{width:auto;position:absolute;bottom:4px;left:16px}.language-feedback-container{width:auto;position:absolute;bottom:4px;left:16px;display:flex;gap:8px;align-items:center}.language-feedback-container button-component#report-issue{position:initial}nylas-feedback-form{position:absolute;top:0;height:100%;width:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(0, 0, 0, 0.6);z-index:2;border-radius:inherit}';const z={title:r.t("genericErrorTitle"),category:m.Component};const R=class{constructor(e){i(this,e);this.init=n(this,"init",7);this.schedulerWillLoad=n(this,"schedulerWillLoad",7);this.schedulerDidLoad=n(this,"schedulerDidLoad",7);this.nylasSchedulerError=n(this,"nylasSchedulerError",7);this.nylasSchedulerInfo=n(this,"nylasSchedulerInfo",7);this.configSettingsLoaded=n(this,"configSettingsLoaded",7);this.bookingRefExtracted=n(this,"bookingRefExtracted",7);this.bookedEventInfo=n(this,"bookedEventInfo",7);this.initDeferred=false;this.mode="app";this.schedulerApiUrl="https://api.us.nylas.com";this.nylasBranding=true;this.eventOverrides={};this.showNotification=true;this.enableUserFeedback=true;this.automaticComponentRegistration=true;this.selectedDateLabel=(new Date).toLocaleDateString(navigator.language,{dateStyle:"full"})||`${r.t("noDateSelected")}`;this.language=navigator.language;this.showFeedbackModal=false;this.bookingInfoConfirmed=null;this.version=b}connectedCallback(){d(`[nylas-scheduler] connectedCallback`)}async componentWillLoad(){d(`[nylas-scheduler] Component will load`);this.version=b;await Promise.resolve();if(this.enableUserFeedback&&!w()){v({dsn:"https://9d5731f1c77ca84c9ed3fb9b3ccf7ee1@o74852.ingest.us.sentry.io/4507889638178816",release:this.version,integrations:e=>[...e.filter((e=>false)),k({colorScheme:"system",autoInject:false})],autoSessionTracking:false,beforeSend:()=>null})}const e=this.schedulerWillLoad.emit(this.host);if("schedulerWillLoad"in this.eventOverrides){await this.eventOverrides.schedulerWillLoad(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}const t=new URLSearchParams(window.location.search);const i=t.get("lang");const n=i&&Object.values(h).includes(i)?i:null;this.stores={scheduler:E({bookingInfo:this.bookingInfo,nylasBranding:this.nylasBranding,themeConfig:this.themeConfig,hour12:this.hour12,selectedLanguage:n||this.defaultLanguage||this.bookingInfo?.language||g()||h.en,...this.defaultSchedulerState})};this.baseProvider=new a(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);this.refConfigId=this.configurationId;let s;try{if(this.rescheduleBookingRef){const[e,t,i]=f(this.rescheduleBookingRef);this.refConfigId=e;this.stores.scheduler.set("rescheduleBookingId",t);s=this.bookingRefExtracted.emit({configurationId:e,bookingId:t})}else if(this.cancelBookingRef){const[e,t,i]=f(this.cancelBookingRef);this.refConfigId=e;this.stores.scheduler.set("cancelBookingId",t);s=this.bookingRefExtracted.emit({configurationId:e,bookingId:t})}else if(this.organizerConfirmationBookingRef){const[e,t,i]=f(this.organizerConfirmationBookingRef);this.refConfigId=e;this.stores.scheduler.set("organizerConfirmationBookingId",t);this.stores.scheduler.set("organizerConfirmationSalt",i);s=this.bookingRefExtracted.emit({configurationId:e,bookingId:t,salt:i})}}catch(e){d(e);const t=this.rescheduleBookingRef||this.cancelBookingRef||this.organizerConfirmationBookingRef;this.nylasSchedulerError.emit({notification:{...this.getErrorObject({message:`Invalid booking reference: ${t}`})},host:this.host})}this.applyThemeConfig(this.themeConfig);if("bookingRefExtracted"in this.eventOverrides){await this.eventOverrides.bookingRefExtracted(s,this.nylasSchedulerConnector);if(s.defaultPrevented){return}}if(!this.checkIfSessionIdOrConfigIdExists(false)){this.initDeferred=true;return}const o=this.baseProvider?.getStore("scheduler");this.nylasSchedulerConnector=new S({schedulerAPIURL:this.schedulerApiUrl,sessionId:this.sessionId,configId:this.refConfigId,slug:this.slug,clientId:this.clientId,nylasSchedulerStore:o});const r=this.init.emit(this.host);if("init"in this.eventOverrides){await this.eventOverrides.init(r,this.nylasSchedulerConnector);if(r.defaultPrevented){return}}this.baseProvider?.componentWillLoad(this.nylasSchedulerConnector)}async componentDidLoad(){if(this.initDeferred){return}this.baseProvider?.componentDidLoad();await Promise.resolve();const e=this.schedulerDidLoad.emit(this.host);if("schedulerDidLoad"in this.eventOverrides){await this.eventOverrides.schedulerDidLoad(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}if(!this.checkIfSessionIdOrConfigIdExists()){return}await this.performSchedulerDataFetch()}async performSchedulerDataFetch(){this.fetchAbortController?.abort();this.fetchAbortController=new AbortController;const{signal:e}=this.fetchAbortController;try{if(this.nylasSchedulerConnector){if(this.schedulerApiUrl){this.nylasSchedulerConnector.setSchedulerAPIURL(this.schedulerApiUrl)}if(this.sessionId){this.nylasSchedulerConnector.sessionId=this.sessionId;this.nylasSchedulerConnector.scheduler.setSessionId(this.sessionId)}}this.localizationChanged(this.localization);const t=await(this.nylasSchedulerConnector?.scheduler.getUISettings(e));if(e.aborted)return;if(!t||"error"in t){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(t?.error)},host:this.host});return}else{if("data"in t&&t.data?.appearance){d("Appearance settings have been returned from the configuration used byt his scheduling page; please remember to grab them from the configSettingsLoaded event and apply them as desired.")}const i=this.configSettingsLoaded.emit({settings:t});if("configSettingsLoaded"in this.eventOverrides){await this.eventOverrides.configSettingsLoaded(i,this.nylasSchedulerConnector);if(e.aborted)return;if(i.defaultPrevented){return}}}const i=this.baseProvider?.getStore("scheduler");const n=i?.get("configSettings")?.scheduler?.available_days_in_future;const s=i?.get("selectedTimeslot");if(s&&s?.start_time){if(!this.isTimeslotValid(s)){return}if(i?.get("showBookingForm")){i?.set("selectedDate",s.start_time);return}}const o=l(i?.get("selectedDate"));const a=i?.get("availability");let r;if(a&&a.length>0){return}if(!o){const t=new Date;const{startTime:i,endTime:s,endTimeForAvailableDaysInFuture:o}=this.validateAvailableDaysInFuture(t,n||30);if(t.getTime()<o*1e3){r=await(this.nylasSchedulerConnector?.scheduler.getAvailability(i,s,e))}}else{const{startTime:t,endTime:i,endTimeForAvailableDaysInFuture:s}=this.validateAvailableDaysInFuture(o,n||30);if(o.getTime()<s*1e3){r=await(this.nylasSchedulerConnector?.scheduler.getAvailability(t,i,e))}}if(e.aborted)return;if(!r||"error"in r){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(r?.error)},host:this.host})}if(!o){let e=new Date;const t=i?.get("availability").find((e=>{const t=l(e.start_time);return t?t>new Date:false}));if(t){e=l(t.start_time)||e}i?.set("selectedDate",e)}}catch(e){if(e.name==="AbortError")return;throw e}}hasValidAuthConfig(){return!!(this.sessionId||this.refConfigId||this.slug&&this.clientId)}async performDeferredInit(){if(!this.hasValidAuthConfig()||!this.initDeferred||!this.baseProvider){return}document.body.dispatchEvent(new CustomEvent("nylasSchedulerClearNotifications",{detail:{host:this.host},bubbles:true}));this.initDeferred=false;this.refConfigId=this.refConfigId||this.configurationId;this.baseProvider.eventOverrides=this.eventOverrides;const e=this.baseProvider.getStore("scheduler");this.nylasSchedulerConnector=new S({schedulerAPIURL:this.schedulerApiUrl,sessionId:this.sessionId,configId:this.refConfigId,slug:this.slug,clientId:this.clientId,nylasSchedulerStore:e});const t=this.init.emit(this.host);if("init"in this.eventOverrides){await this.eventOverrides.init(t,this.nylasSchedulerConnector);if(t.defaultPrevented){return}}await this.baseProvider.componentWillLoad(this.nylasSchedulerConnector);this.baseProvider.componentDidLoad();await Promise.resolve();const i=this.schedulerDidLoad.emit(this.host);if("schedulerDidLoad"in this.eventOverrides){await this.eventOverrides.schedulerDidLoad(i,this.nylasSchedulerConnector);if(i.defaultPrevented){return}}await this.performSchedulerDataFetch()}async authPropsChanged(e){if(e&&"bookingRefExtracted"in this.eventOverrides){await this.eventOverrides.bookingRefExtracted(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}if(this.initDeferred&&this.hasValidAuthConfig()){this.performDeferredInit()}}configurationIdChanged(){if(!this.rescheduleBookingRef&&!this.cancelBookingRef&&!this.organizerConfirmationBookingRef){this.refConfigId=this.configurationId}this.authPropsChanged()}schedulerApiUrlChanged(){if(this.nylasSchedulerConnector&&this.schedulerApiUrl){this.nylasSchedulerConnector.setSchedulerAPIURL(this.schedulerApiUrl);document.body.dispatchEvent(new CustomEvent("nylasSchedulerClearNotifications",{detail:{host:this.host},bubbles:true}));this.stores?.scheduler.set("availability",[]);this.performSchedulerDataFetch()}}sessionIdChanged(){if(this.nylasSchedulerConnector&&this.sessionId){this.nylasSchedulerConnector.sessionId=this.sessionId;this.nylasSchedulerConnector.scheduler.setSessionId(this.sessionId);document.body.dispatchEvent(new CustomEvent("nylasSchedulerClearNotifications",{detail:{host:this.host},bubbles:true}));this.performSchedulerDataFetch()}this.authPropsChanged()}slugChanged(){this.authPropsChanged()}clientIdChanged(){this.authPropsChanged()}componentDisconnected(){this.baseProvider?.componentDisconnected()}bookingInfoChanged(e){this.stores?.scheduler.set("bookingInfo",e);if(e?.language&&!this.defaultLanguage){this.stores?.scheduler.set("selectedLanguage",e.language)}}rescheduleBookingRefChanged(e){let t;if(e){try{const[i,n]=f(e);this.stores?.scheduler.set("rescheduleBookingId",n);this.refConfigId=i;this.nylasSchedulerConnector?.scheduler.setConfigId(i);t=this.bookingRefExtracted.emit({configurationId:i,bookingId:n})}catch(t){d(t);this.nylasSchedulerError.emit({notification:{...this.getErrorObject({message:`Invalid booking reference: ${e}`})},host:this.host})}}this.authPropsChanged(t)}cancelBookingRefChanged(e){let t;if(e){try{const[i,n]=f(e);this.stores?.scheduler.set("cancelBookingId",n);this.refConfigId=i;this.nylasSchedulerConnector?.scheduler.setConfigId(i);t=this.bookingRefExtracted.emit({configurationId:i,bookingId:n})}catch(t){d(t);this.nylasSchedulerError.emit({notification:{...this.getErrorObject({message:`Invalid booking reference: ${e}`})},host:this.host})}}this.authPropsChanged(t)}organizerConfirmationBookingRefChanged(e){let t;if(e){try{const[i,n,s]=f(e);this.stores?.scheduler.set("organizerConfirmationBookingId",n);this.stores?.scheduler.set("organizerConfirmationSalt",s);this.refConfigId=i;this.nylasSchedulerConnector?.scheduler.setConfigId(i);t=this.bookingRefExtracted.emit({configurationId:i,bookingId:n,salt:s})}catch(t){d(t);this.nylasSchedulerError.emit({notification:{...this.getErrorObject({message:`Invalid booking reference: ${e}`})},host:this.host})}}this.authPropsChanged(t)}localizationChanged(e){if(!e){return}Object.keys(e).forEach((t=>{if(!(t in h)){return}r.addResourceBundle(t,"translation",e[t],false,true)}))}defaultLanguageChanged(e){if(e){this.stores?.scheduler.set("selectedLanguage",e);r.changeLanguage(e)}}themeConfigChanged(e){this.baseProvider?.getStore("scheduler")?.set("themeConfig",e);this.applyThemeConfig(e)}languageChanged(e){const t=e.detail;this.language=t;r.changeLanguage(t)}async registerComponentHandler(e){this.baseProvider?.registerComponent(e.detail)}async unregisterComponentHandler(e){this.baseProvider?.unregisterComponent(e.detail)}async monthChangedHandler(e){const t=e.detail;const i=this.nylasSchedulerConnector?.schedulerStore?.get("configSettings")?.scheduler?.available_days_in_future;const{startTime:n,endTime:s,endTimeForAvailableDaysInFuture:o}=this.validateAvailableDaysInFuture(t,i||30);if(e.defaultPrevented){return}if(n<o&&t.getTime()<o*1e3){const e=await(this.nylasSchedulerConnector?.scheduler.getAvailability(n,s));if(!e||"error"in e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e?.error)},host:this.host})}const t=this.stores?.scheduler.get("selectableDates");if(t&&t.length>0){this.stores?.scheduler.set("selectedDate",t[0])}}}mapToBookingData(e){const t=this.stores?.scheduler.get("selectedTimeslot");const i=this.stores?.scheduler.get("selectedLanguage");const n=this.stores?.scheduler.get("selectedTimezone");const s=t?.start_time?new Date(t?.start_time).getTime()/1e3:"";const o=t?.end_time?new Date(t?.end_time).getTime()/1e3:"";return{additional_guests:e.guests,guest:{...e.primaryParticipant},additional_fields:{...e.additionalFields},start_time:s,end_time:o,email_language:i,timezone:n}}async bookButtonClickedHandler(e){if(e.defaultPrevented){return}const t=e.detail;const i=this.mapToBookingData(t);this.bookingInfoConfirmed=t;const n=this.nylasSchedulerConnector?.schedulerStore?.get("rescheduleBookingId");const s=n;if(s){const e=await(this.nylasSchedulerConnector?.scheduler.rescheduleBooking(s,t));if(!e||"error"in e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e?.error)},host:this.host})}const n=e?.data;const o=this.bookedEventInfo.emit({...e,data:{...n,...i}});this.bookingInfoConfirmed={...this.bookingInfoConfirmed,...n};if("bookedEventInfo"in this.eventOverrides){await this.eventOverrides.bookedEventInfo(o,this.nylasSchedulerConnector)}return}const o=await(this.nylasSchedulerConnector?.scheduler.bookTimeslot(t));if(!o||"error"in o){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(o?.error)},host:this.host})}const a=o?.data;const r=this.bookedEventInfo.emit({...o,data:{...a,...i}});this.bookingInfoConfirmed={...this.bookingInfoConfirmed,...a};if("bookedEventInfo"in this.eventOverrides){await this.eventOverrides.bookedEventInfo(r,this.nylasSchedulerConnector)}}dateSelectedHandler(e){const t=l(e.detail);this.selectedDateLabel=t?t.toLocaleDateString(this.language,{dateStyle:"full"}):`${r.t("noDateSelected")}`}cancelBookedEventErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}cancelBookedEventValidationErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}rescheduleBookedEventErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}confirmBookingErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}feedbackModalClosedHandler(){this.showFeedbackModal=false}eventIsFullHandler(e){const t=e.detail.error;const i=e.detail.type;if(i==="error"){this.nylasSchedulerError.emit({notification:{...this.getErrorObject({message:t})},host:this.host})}else{this.nylasSchedulerInfo.emit({notification:{title:"Event is full",category:m.Component,type:y.Info,description:"The event you selected is full. Please try a different time.",id:(new Date).getTime().toString(),ttl:3e3},host:this.host})}}feedbackSubmittedHandler(e){I("Scheduling Page User Feedback",{extra:{configId:this.configurationId,slug:this.slug}});const t={message:e.detail.feedback};x(t,{includeReplay:true,captureContext:{tags:{"nylas-web-element":"nylas-scheduling","nylas-web-element-version":this.version,"nylas-config-id":this.configurationId,"nylas-slug":this.slug,"host-url":window.location.href},extra:{configId:this.configurationId,slug:this.slug,version:this.version}}});this.showFeedbackModal=false}async getNylasSchedulerStore(){return this.baseProvider?.getStore("scheduler")}async getNylasSchedulerConnector(){return this.nylasSchedulerConnector}async getRef(){return this.host}getErrorObject(e){return{title:e?.title||z.title,category:e?.category||z.category,type:y.Error,description:e?.message||"",id:(new Date).getTime().toString(),ttl:"none"}}checkIfSessionIdOrConfigIdExists(e=true){if(!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)){if(e){let e="";if(!this.sessionId){e+=r.t("sessionIdRequiredErrorMessage")}if(!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)){e=r.t("sessionIdRequiredErrorMessage")+" "+r.t("publicConfigErrorMessage")}this.nylasSchedulerError.emit({notification:{title:r.t("schedulingComponentErrorTitle"),category:m.Component,type:y.Error,description:e,id:(new Date).getTime().toString(),ttl:"none"},host:this.host})}return false}return true}isTimeslotValid(e){const t=new Date(e.start_time);if(t<new Date){this.nylasSchedulerError.emit({notification:{title:r.t("invalidTimeslotErrorTitle"),category:m.Component,type:y.Error,description:r.t("invalidTimeslotErrorMessage"),id:(new Date).getTime().toString(),ttl:"none"},host:this.host});return false}return true}validateAvailableDaysInFuture(e,t){const i=new Date;const n=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3;const s=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3;const o=Math.floor(c(i,t).getTime()/1e3);const a=Math.min(o,s);const r=n<i.getTime()/1e3?Math.floor(i.getTime()/1e3):n;return{startTime:r,endTime:a,endTimeForAvailableDaysInFuture:o}}applyThemeConfig(e){if(e){for(const[t,i]of Object.entries(e)){this.host.style.setProperty(`${t}`,i)}}}onFeedbackClick(e){e.preventDefault();this.showFeedbackModal=true}redirectToCustomUrl(e){window.location.assign(e)}nylasFormDropdownChangedHandler(e){const{name:t,value:i}=e.detail;if(t==="language"){const e=h[i];r.changeLanguage(e);this.stores?.scheduler?.set("selectedLanguage",e)}}render(){const t=this.mode==="app";const i=this.baseProvider?.getStore("scheduler");const n=i?.get("eventInfo");const o=i?.get("showBookingForm");const a=i?.get("cancelledEventInfo");const c=i?.get("cancelBookingId");const d=i?.get("selectedTimeslot");const f=i?.get("rescheduleBookingId");const m=i?.get("organizerConfirmationBookingId");const b=i?.get("rejectBookingId");const y=i?.get("confirmedEventInfo");const _=i?.get("nylasBranding")||this.nylasBranding;const w=l(i?.get("selectedDate"));const v=i?.get("configSettings")?.scheduler?.confirmation_redirect_url;this.selectedDateLabel=w&&this.language?u(w.toLocaleDateString(this.language,{dateStyle:"full"})):`${r.t("noDateSelected")}`;const k=Object.keys(p).map((e=>({label:p[e],value:e})));const I=i?.get("selectedLanguage")||this.defaultLanguage||g()||h.en;if(t&&(c||b)&&!a){return e(s,null,e(L,{version:this.version,nylasBranding:_,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancel-flow-page",part:"cancel-flow-page"},e("nylas-cancel-booking-form",{selectedTimeslot:d,cancelBookingId:c,rejectBookingId:b,exportparts:"ncbf, ncbf__icon, ncbf__title, ncbf__description, ncbf__reason-textarea, ncbf__button-cta, ncbf__button-outline, ncbf__card"}))),e("div",{class:"language-feedback-container"},this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),e("select-dropdown",{name:"language",searchPlaceholder:r.t("search"),options:k,withChevron:false,themeConfig:this.themeConfig,defaultSelectedOption:k.find((e=>e.value==I)),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",{slot:"select-icon"},e("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&m){return e(s,null,e(L,null,e("div",{class:"manual-confirmation-page",part:"manual-confirmation-page"},e("nylas-organizer-confirmation-card",{organizerConfirmationBookingId:m,exportparts:"nmcc, nmcc__title, nmcc__description, nmcc__button-cta, nmcc__button-outline"}))),e("div",{class:"language-feedback-container"},this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),e("select-dropdown",{name:"language",searchPlaceholder:r.t("search"),options:k,withChevron:false,themeConfig:this.themeConfig,defaultSelectedOption:k.find((e=>e.value==I)),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",{slot:"select-icon"},e("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&a){return e(s,null,e(L,{version:this.version,nylasBranding:_,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancelled-event-page",part:"cancelled-event-page"},e("nylas-cancelled-event-card",{cancelledEventInfo:a,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))),e("div",{class:"language-feedback-container"},this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),e("select-dropdown",{name:"language",searchPlaceholder:r.t("search"),options:k,withChevron:false,themeConfig:this.themeConfig,defaultSelectedOption:k.find((e=>e.value==I)),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",{slot:"select-icon"},e("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&y){return e(s,null,e(L,{version:this.version,nylasBranding:_,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancelled-event-page",part:"confirmed-event-page"},e("nylas-confirmed-event-card",{confirmedEventInfo:y,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))),e("div",{class:"language-feedback-container"},this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),e("select-dropdown",{name:"language",searchPlaceholder:r.t("search"),options:k,withChevron:false,themeConfig:this.themeConfig,defaultSelectedOption:k.find((e=>e.value==I)),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",{slot:"select-icon"},e("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&n&&v){const e=this.bookingInfoConfirmed?.primaryParticipant;const t=this.bookingInfoConfirmed?.location;const i=this.bookingInfoConfirmed?.booking_ref;const s=this.bookingInfoConfirmed?.additionalFields||{};if(this.bookingInfo&&typeof this.bookingInfo?.additionalFields!=="undefined"){const e=this.bookingInfo.additionalFields;Object.keys(e).forEach((t=>{if(!s[t]&&e?.[t]){s[t]=e[t].value}}))}const o=this.stores?.scheduler.get("selectedTimeslot");const a=this.stores?.scheduler.get("selectedTimezone");const r=this.stores?.scheduler.get("selectedLanguage");const l=this.stores?.scheduler.get("configSettings");const c=this.configurationId?this.configurationId:l?.configuration_id;const d=window.location.search;const h=new URLSearchParams(d);h.set("booking_id",n.booking_id);e?.name&&h.set("name",e.name);e?.email&&h.set("email",e.email);o?.start_time&&h.set("start_time",(new Date(o.start_time).getTime()/1e3).toString());o?.end_time&&h.set("end_time",(new Date(o.end_time).getTime()/1e3).toString());a&&h.set("tz",a);r&&h.set("language",r);s&&h.set("additional_values",JSON.stringify(s));this.slug&&h.set("page_slug",this.slug);c&&h.set("config_id",c);t&&h.set("location",t);i&&h.set("booking_ref",i);const g=new URL(v,window.location.origin);h.forEach(((e,t)=>{g.searchParams.set(t,e)}));this.redirectToCustomUrl(g.toString());return}if(t&&n){return e(s,null,e(L,{version:this.version,nylasBranding:_,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"booked-event-page",part:"booked-event-page ns_booked-event-page"},e("nylas-booked-event-card",{selectedTimeslot:d,eventInfo:n,exportparts:"nbec, nbec__title, nbec__card, nbec__description, nbec__button-outline, nbec__cancel-cta, nbec__reschedule-cta"}))),e("div",{class:"language-feedback-container"},this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),e("select-dropdown",{name:"language",searchPlaceholder:r.t("search"),options:k,withChevron:false,themeConfig:this.themeConfig,defaultSelectedOption:k.find((e=>e.value==I)),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",{slot:"select-icon"},e("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&(!n||!!f)&&!o){const t=this.host.querySelector('[slot="timeslot-picker-cta-label"]');return e(s,null,e(L,{version:this.version,nylasBranding:_,isLoading:this.isLoading,showNotification:this.showNotification},f&&e(B,null,`${r.t("rescheduleTitle")}`),e("div",{class:"select-date-page",part:"select-date-page ns_select-date-page"},e("div",{class:"left-panel",part:"ns_left-panel"},e("nylas-date-picker",{exportparts:"ndp, ndp__title, ndp__month-header, ndp__month-button, ndp__day, ndp__date, ndp__date--disabled, ndp__date--selected, ndp__date--current-day, ndp__date--current-month"}),e("nylas-locale-switch",{exportparts:"nls, nls__timezone, nls__timezone-dropdown, nls__timezone-drop-button, nls__timezone-drop-button-selected-label, nls__timezone-drop-content, nls__timezone-drop-label, nls__language, nls__language-dropdown, nls__language-drop-button, nls__language-drop-content, nls__language-drop-label"})),e("div",{class:`right-panel ${f?"reschedule":""}`,part:`ns_right-panel ${f?"ns_reschedule":""}`},e("h2",{part:"ns_right-panel__title"},e("calendar-icon",{part:"ns_right-panel__calendar-icon"}),e("span",{id:"selectedDate",part:"ns_right-panel__selected-date"},this.selectedDateLabel)),e("nylas-timeslot-picker",{exportparts:"ntp, ntp__time-picker-wrapper, ntp__timeslots, ntp__timeslot, ntp__timeslot--selected, ntp__button-primary"},t&&e("span",{slot:"timeslot-picker-cta-label"},e("slot",{name:"timeslot-picker-cta-label"})))))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&!n&&o){return e(s,null,e(L,{version:this.version,nylasBranding:_,isLoading:this.isLoading,showNotification:this.showNotification},f&&e(B,null,`${r.t("rescheduleTitle")}`),e("div",{class:"additional-data-page",part:"additional-data-page ns_additional-data-page"},e("div",{class:"left-panel ns_left-panel",part:"ns_left-panel"},e("div",{class:"wrapper",part:"ns_left-panel__wrapper"},e("nylas-selected-event-card",{exportparts:"nsec, nsec__card, nsec__icon, nsec__date, nsec__time, nsec__timezone"}))),e("div",{class:`right-panel ${f?"reschedule":""}`,part:`ns_right-panel ${f?"ns_reschedule":""}`},e("nylas-booking-form",{exportparts:"nbf, nbf__input-textfield, nbf__button-ghost, nbf__button-outline, nbf__button-primary, nbf__input-wrapper, nbf__checkbox-component, nbf__radio-button-group, nbf__textarea-component, nbf__dropdown, nbf__dropdown-button, nbf__dropdown-content"})))),e("div",{class:"language-feedback-container"},this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),e("select-dropdown",{name:"language",searchPlaceholder:r.t("search"),options:k,withChevron:false,themeConfig:this.themeConfig,defaultSelectedOption:k.find((e=>e.value==I)),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",{slot:"select-icon"},e("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&e("nylas-feedback-form",null))}return e(s,null,e("slot",null))}get host(){return o(this)}static get watchers(){return{configurationId:["configurationIdChanged"],schedulerApiUrl:["schedulerApiUrlChanged"],sessionId:["sessionIdChanged"],slug:["slugChanged"],clientId:["clientIdChanged"],bookingInfo:["bookingInfoChanged"],rescheduleBookingRef:["rescheduleBookingRefChanged"],cancelBookingRef:["cancelBookingRefChanged"],organizerConfirmationBookingRef:["organizerConfirmationBookingRefChanged"],localization:["localizationChanged"],defaultLanguage:["defaultLanguageChanged"],themeConfig:["themeConfigChanged"]}}};R.style=D;export{R as nylas_scheduling};
2
- //# sourceMappingURL=p-f5cf4c30.entry.js.map
1
+ import{h as e,F as t,r as i,c as n,H as s,a as o}from"./p-0EQQA0nE.js";import{N as a}from"./p-DGwaF706.js";import{i as r,n as l,f as c,a as d,L as h,h as g,j as f,k as u,c as p}from"./p-BW6igRcf.js";import{E as m,v as b,u as y}from"./p-CqK6_Oc7.js";import{c as _}from"./p-_i6H-yQH.js";import{i as w,a as v,f as k,c as I,b as x}from"./p-B8tfyAQm.js";class C{constructor(){this.component=e=>{const t=m.Component;const i=`${e} Error`;return{endtime_not_in_future:(e='"endtime" can not be in the future')=>({title:i,message:e,category:t}),no_booking_info:(e="No booking info provided")=>({title:i,message:e,category:t}),no_timeslot_selected:(e="No timeslot selected")=>({title:i,message:e,category:t}),no_timezone_selected:(e="No timezone selected")=>({title:i,message:e,category:t}),no_booking_id:(e="No booking id provided")=>({title:i,message:e,category:t}),no_salt:(e="No salt provided")=>({title:i,message:e,category:t}),invalid_start_time:(e="Invalid start time")=>({title:i,message:e,category:t}),invalid_end_time:(e="Invalid end time")=>({title:i,message:e,category:t}),invalid_timezone:(e="Invalid timezone")=>({title:i,message:e,category:t}),no_config_id:(e="No configuration id provided")=>({title:i,message:e,category:t})}};this.api=e=>{const t=m.Api;const i=`${e} Error`;return{invalid_session:e=>({title:i,message:e,category:t}),general_error:e=>({title:i,message:e,category:t}),internal_error:e=>({title:i,message:e,category:t}),invalid_request_error:e=>({title:i,message:e,category:t}),timeslot_not_available:e=>({title:i,message:e,category:t}),provider_error:e=>({title:i,message:e,category:t}),not_found_error:e=>({title:i,message:e,category:t})}}}}class T{constructor({schedulerAPIURL:e,schedulerStore:t,sessionId:i,configId:n,slug:s,clientId:o}){this.errors=new C;this.schedulerStore=t;this.schedulerAPIURL=e;this.sessionId=i;this.configId=n;this.slug=s;this.clientId=o}getHeaders(){return this.sessionId?{Authorization:`Bearer ${this.sessionId}`}:{}}async makeAPIRequest(e,t,i,n={},s){try{const o=new URL(this.schedulerAPIURL);o.pathname=e;const a=await fetch(decodeURIComponent(o.toString()),{method:t,headers:{"Content-Type":"application/json",Origin:window.location.origin,"X-Source":"nylas-scheduling","X-Nylas-Web-Elements-Version":b,...this.clientId&&{"X-Nylas-Application-Public-Id":this.clientId},...n},body:i,signal:s});const r=await a.json();return r}catch(e){if(e.name==="AbortError"){throw e}return{error:{message:e.message,title:"API request failed",type:"api"}}}}getErrorMessage(e){let t=e?.message||e?.title||"Something went wrong";if(e?.type==="provider_error"){t=e?.provider_error?.error?.message||e?.provider_error?.error?.title||"Something went wrong"}return t}setConfigId(e){this.configId=e}setSchedulerAPIURL(e){if(e==="/"){e=new URL(window.location.href).origin}this.schedulerAPIURL=e}setSessionId(e){this.sessionId=e}selectDate(e){this.schedulerStore.set("selectedDate",e);this.schedulerStore.set("selectedTimeslot",null)}selectTime(e){this.schedulerStore.set("selectedTimeslot",e)}selectTimezone(e){this.schedulerStore.set("selectedTimezone",e)}selectLanguage(e){this.schedulerStore.set("selectedLanguage",e);r.changeLanguage(e)}async toggleAdditionalData(e){if(!e){await this.refetchAvailability()}this.schedulerStore.set("showBookingForm",e)}setParticipantName(e){const{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...t?.primaryParticipant,name:e}})}setParticipantEmail(e){const{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...t?.primaryParticipant,email:e}})}async refetchAvailability(){const e=new Date;const t=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3;const i=t<e.getTime()/1e3?Math.floor(e.getTime()/1e3):t;const n=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3;const s=await this.getAvailability(i,n);return s}async resetStoreStateAndFetchAvailability(){const e=new Date;const t=await this.refetchAvailability();const i=this.schedulerStore.get("availability").find((e=>{const t=l(e.start_time);return t?t>new Date:false}));let n=e;if(i){n=l(i.start_time)||e}this.schedulerStore.set("selectedDate",n);this.schedulerStore.set("eventInfo",null);this.schedulerStore.set("showBookingForm",false);this.schedulerStore.set("selectedTimeslot",null);return t}async setReschedule(e){this.schedulerStore.set("isLoading",true);const t=this.schedulerStore.state.eventInfo;if(t){this.schedulerStore.set("reschedulingEventInfo",t)}this.schedulerStore.set("rescheduleBookingId",e);await this.getUISettings();const i=await this.resetStoreStateAndFetchAvailability().finally((()=>{this.schedulerStore.set("isLoading",false)}));return i}async setCancel(e){this.schedulerStore.set("cancelBookingId",e)}async setReject(e){this.schedulerStore.set("rejectBookingId",e)}async resetCancel(){const e=await this.resetStoreStateAndFetchAvailability();this.schedulerStore.set("cancelBookingId","");this.schedulerStore.set("rejectBookingId","");this.schedulerStore.set("cancelledEventInfo",null);return e}async goBack(){this.schedulerStore.set("cancelBookingId","");return}async resetConfirm(){const e=await this.resetStoreStateAndFetchAvailability();this.schedulerStore.set("organizerConfirmationBookingId","");this.schedulerStore.set("confirmedEventInfo",undefined);return e}async bookTimeslot(e){this.schedulerStore.set("isLoading",true);const{selectedTimeslot:t,selectedTimezone:i,bookingInfo:n,selectedLanguage:s}=this.schedulerStore.state;if(!e&&!n){return{error:this.errors.component(r.t("createBookingErrorTitle")).no_booking_info()}}const o=e?.timeslot||t;if(!o){return{error:this.errors.component(r.t("createBookingErrorTitle")).no_timeslot_selected()}}const a=e&&e?.timezone?e?.timezone:i;const l=s||"en-US";if(!a){return{error:this.errors.component(r.t("createBookingErrorTitle")).no_timezone_selected()}}const c=[...this.schedulerStore.get("availabilityOrderEmails")];let d="";const h=o?.emails||[];const g={};Object.entries(n?.additionalFields||{}).forEach((([e,t])=>{g[e]=t.value}));const f=e?e?.primaryParticipant:n?.primaryParticipant;const u=e?e?.guests||[]:n?.guests||[];const p=e?e?.additionalFields:g;const m=this.getHeaders();const b=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const y=`/v3/scheduling/bookings${b}`;if(c.length===0){const e=await this.makeAPIRequest(decodeURIComponent(y),"POST",JSON.stringify({additional_fields:p,additional_guests:u,guest:{...f},start_time:o.start_time.getTime()/1e3,end_time:o.end_time.getTime()/1e3,timezone:a,event_id:o?.event_id||undefined,master_id:o?.master_id||undefined,calendar_id:o?.calendar_id||undefined,email_language:this.getTwoLetterLanguageCode(l)}),m);this.schedulerStore.set("isLoading",false);if("data"in e){this.schedulerStore.set("eventInfo",e.data);return e}return{error:e.error}}while(c.length>0){d=c.shift();if(!h.includes(d)){continue}const e=await this.makeAPIRequest(decodeURIComponent(y),"POST",JSON.stringify({participants:d?[{email:d}]:undefined,additional_fields:p,additional_guests:u,guest:{...f},start_time:o.start_time.getTime()/1e3,end_time:o.end_time.getTime()/1e3,timezone:a,email_language:this.getTwoLetterLanguageCode(l)}),m);if("data"in e){this.schedulerStore.set("isLoading",false);this.schedulerStore.set("eventInfo",e?.data);return e}else if(e.error?.message?.startsWith("The selected timeslot is unavailable")){continue}else{this.schedulerStore.set("isLoading",false);const t=e.error?.type;let i=e.error;if(t&&t in this.errors.api(r.t("createBookingErrorTitle"))){const e=this.getErrorMessage(i);i=this.errors.api(r.t("createBookingErrorTitle"))[t](e)}return{error:i}}}this.schedulerStore.set("isLoading",false);return{error:this.errors.api(r.t("createBookingErrorTitle")).timeslot_not_available("The selected timeslot is unavailable")}}async getUISettings(e){this.schedulerStore.set("isLoading",true);const t=this.schedulerStore.get("rescheduleBookingId");const i=this.getHeaders();let n=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";if(t&&!!n){n+=`&booking_id=${t}`}else if(t){n+=`?booking_id=${t}`}const s=`/v3/scheduling/ui-settings${n}`;const o=await this.makeAPIRequest(s,"GET",undefined,i,e);if("error"in o){this.schedulerStore.set("isLoading",false);const e=o.error?.type;let t=o.error;if(e&&e in this.errors.api(r.t("getUISettingErrorTitle"))){t=this.errors.api(r.t("getUISettingErrorTitle"))[e](t?.message||t?.title||"Something went wrong")}return{error:t}}if("data"in o){this.schedulerStore.set("configSettings",o.data);this.clientId=o.data.app_client_id||this.clientId}this.schedulerStore.set("isLoading",false);return o}getTwoLetterLanguageCode(e){return e.split("-")[0]}getStartTimeWithMinBookingNotice(e){const t=this.schedulerStore.get("configSettings")?.scheduler;const i=t?.min_booking_notice;if(!i){return e}const n=(new Date).getTime();if(e<(n+i*60*1e3)/1e3){return Math.floor((n+i*60*1e3)/1e3)}else{return e}}getEndTimeForAvailableDaysInFuture(e){const t=new Date;const i=this.schedulerStore.get("configSettings")?.scheduler?.available_days_in_future;const n=Math.floor(c(t,i).getTime()/1e3);const s=Math.min(n,e);return s}async getAvailability(e=0,t=0,i){this.schedulerStore.set("isLoading",true);const n=new URLSearchParams;const s=new Date;const o=s.getTime();if(t&&t<o/1e3){this.schedulerStore.set("isLoading",false);const e=this.errors.component(r.t("getAvailabilityErrorTitle")).endtime_not_in_future();return{error:e}}if(!e){const t=new Date(s.getFullYear(),s.getMonth(),1);e=Math.floor(t.getTime()/1e3)}if(!t){const e=new Date(s.getFullYear(),s.getMonth()+1,0);t=Math.floor(e.getTime()/1e3)}t=this.getEndTimeForAvailableDaysInFuture(t);const a=this.getStartTimeWithMinBookingNotice(e);e=a;t=a>t?a+1:t;n.append("start_time",encodeURIComponent(e.toString()));n.append("end_time",encodeURIComponent(t.toString()));if(this.configId&&!this.sessionId){n.append("configuration_id",encodeURIComponent(this.configId))}else if(this.slug&&this.clientId&&!this.sessionId){n.append("slug",encodeURIComponent(this.slug));n.append("client_id",encodeURIComponent(this.clientId))}const l=this.schedulerStore.get("rescheduleBookingId");if(l){n.append("booking_id",encodeURIComponent(l))}const c=n.toString();const d=`/v3/scheduling/availability${c?`?${c}`:""}`;const h=this.getHeaders();const g=await this.makeAPIRequest(decodeURIComponent(d),"GET",undefined,h,i);if("error"in g){this.schedulerStore.set("availability",[]);this.schedulerStore.set("isLoading",false);const e=g.error?.type;let t=g.error;if(t?.message?.toLowerCase().includes("Failed to find a valid Grant")){const e=r.t("invalidGrantError");return{error:{title:r.t("invalidGrantErrorTitle"),message:e,category:m.Api}}}if(e&&e in this.errors.api(r.t("getAvailabilityErrorTitle"))){const i=this.getErrorMessage(t);t=this.errors.api(r.t("getAvailabilityErrorTitle"))[e](i)}return{error:t}}if("data"in g){const e=g.data?.time_slots?.map((e=>({...e,start_time:new Date(e.start_time*1e3),end_time:new Date(e.end_time*1e3)})))||[];const t=e.filter((e=>e.start_time.getTime()>o));const i=t.sort(((e,t)=>e.start_time.getTime()-t.start_time.getTime()));this.schedulerStore.set("availability",i);const n=g.data?.order||[];this.schedulerStore.set("availabilityOrderEmails",n)}this.schedulerStore.set("isLoading",false);return g}async cancelBooking(e,t){this.schedulerStore.set("isLoading",true);if(!e){return{error:this.errors.component(r.t("cancelBookingErrorTitle")).no_booking_id()}}const i=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const n=`/v3/scheduling/bookings/${e}${i}`;const s=this.getHeaders();const o=await this.makeAPIRequest(decodeURIComponent(n),"DELETE",JSON.stringify({action:"cancel",cancellation_reason:t}),s);if("error"in o){this.schedulerStore.set("isLoading",false);const e=o.error?.type;let t=o.error;if(e&&e in this.errors.api(r.t("cancelBookingErrorTitle"))){const i=this.getErrorMessage(t);t=this.errors.api(r.t("cancelBookingErrorTitle"))[e](i)}return{error:t}}this.schedulerStore.set("cancelledEventInfo",{booking_id:e});this.schedulerStore.set("rescheduleBookingId","");this.schedulerStore.set("isLoading",false);return o}async rescheduleBooking(e,t){this.schedulerStore.set("isLoading",true);if(!e){return{error:this.errors.component(r.t("rescheduleBookingErrorTitle")).no_booking_id()}}const i=this.errors.api(r.t("rescheduleBookingErrorTitle"));const n=this.errors.component(r.t("rescheduleBookingErrorTitle"));const{bookingInfo:s,selectedTimeslot:o,selectedTimezone:a,selectedLanguage:l}=this.schedulerStore.state;const{startTime:c,endTime:d,timezone:h}=t;const g=c||o?.start_time;if(!g){return{error:n.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')}}const f=d||o?.end_time;if(!f){return{error:n.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')}}const u=this.schedulerStore.get("availabilityOrderEmails");let p="";if(u.length>0){const e=o?.emails||[];for(let t=0;t<u.length;t++){if(e.includes(u[t])){p=u[t];break}}}const m=h||a;if(!m){return{error:n.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.')}}const b=o?.event_id||undefined;const y=o?.master_id||undefined;const _=o?.calendar_id||undefined;const w={};Object.entries(s?.additionalFields||{}).forEach((([e,t])=>{w[e]=t.value}));const v=t?t?.primaryParticipant:s?.primaryParticipant;const k=t?t?.guests||[]:s?.guests||[];const I=t?t?.additionalFields:w;const x=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const C=`/v3/scheduling/bookings/${e}${x}`;const T=this.getHeaders();const S=await this.makeAPIRequest(decodeURIComponent(C),"PATCH",JSON.stringify({start_time:g.getTime()/1e3,end_time:f.getTime()/1e3,timezone:m,additional_fields:I,guest:{...v},additional_guests:k,participants:p?[{email:p}]:undefined,email_language:this.getTwoLetterLanguageCode(l),event_id:b,master_id:y,calendar_id:_}),T);if("error"in S){this.schedulerStore.set("isLoading",false);const e=S.error?.type;let t=S.error;if(e&&e in i){const n=this.getErrorMessage(t);t=i[e](n)}return{error:t}}const E=this.schedulerStore.get("reschedulingEventInfo");if("data"in S){this.schedulerStore.set("eventInfo",S?.data);if(S.data?.booking_id){this.schedulerStore.set("rescheduleBookingId",S.data.booking_id)}}else if(E){this.schedulerStore.set("eventInfo",E)}else{const t={booking_id:e};this.schedulerStore.set("eventInfo",t)}this.schedulerStore.set("reschedulingEventInfo",undefined);this.schedulerStore.set("isLoading",false);return S}async updateBooking(e){this.schedulerStore.set("isLoading",true);const{bookingId:t,status:i,reason:n}=e;const s=this.schedulerStore.get("organizerConfirmationSalt");const o=i==="confirmed"?r.t("confirmBookingErrorTitle"):r.t("rejectBookingErrorTitle");if(!t){return{error:this.errors.component(o).no_booking_id()}}if(!s){return{error:this.errors.component(o).no_salt()}}const a=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";const l=`/v3/scheduling/bookings/${t}${a}`;const c=this.getHeaders();const d=await this.makeAPIRequest(decodeURIComponent(l),"PUT",JSON.stringify({status:i,cancellation_reason:n,salt:s}),c);if("error"in d){this.schedulerStore.set("isLoading",false);const e=d.error?.type;let t=d.error;if(e&&e in this.errors.api(o)){const i=this.getErrorMessage(t);t=this.errors.api(o)[e](i)}return{error:t}}if("data"in d&&i==="confirmed"){this.schedulerStore.set("confirmedEventInfo",d?.data)}else if("request_id"in d&&i==="cancelled"){this.schedulerStore.set("cancelledEventInfo",{booking_id:t})}this.schedulerStore.set("organizerConfirmationBookingId","");this.schedulerStore.set("isLoading",false);return d}async validateGroupEventTimeslot(e){this.schedulerStore.set("isLoading",true);const t=this.schedulerStore.get("configSettings")?.configuration_id;if(!t){return{error:this.errors.component(r.t("validateTimeslotErrorTitle")).no_config_id()}}const i=this.getHeaders();const n=`/v3/scheduling/configurations/${t}/group-events/validate-timeslot`;const s=await this.makeAPIRequest(decodeURIComponent(n),"POST",JSON.stringify({...e,start_time:e.start_time.getTime()/1e3,end_time:e.end_time.getTime()/1e3}),i);if("error"in s){this.schedulerStore.set("isLoading",false);const e=s.error?.type;let t=s.error;if(e&&e in this.errors.api(r.t("validateTimeslotErrorTitle"))){const i=this.getErrorMessage(t);t=this.errors.api(r.t("validateTimeslotErrorTitle"))[e](i)}this.refetchAvailability();return{error:t}}this.schedulerStore.set("selectedTimeslot",e);this.schedulerStore.set("showBookingForm",true);this.schedulerStore.set("isLoading",false);return s}}class S{constructor({schedulerAPIURL:e,nylasSchedulerStore:t,sessionId:i,configId:n,slug:s,clientId:o}){if(!e){throw new Error("schedulerAPIURL is required")}if(!t){throw new Error("nylasSchedulerStore is required")}if(!i&&!n&&!(s&&o)){throw new Error("sessionId is required for private configs. If using public config either pass a configurationId or a combination of slug and clientId.")}if(e==="/"){const t=new URL(window.location.href);e=t.origin}this.configId=n;this.sessionId=i;this.schedulerAPIURL=e;this.nylasSchedulerStore=t;this.slug=s;this.clientId=o}init(){d("NylasConnector init")}get schedulerStore(){return this.nylasSchedulerStore}setSchedulerAPIURL(e){if(e==="/"){e=new URL(window.location.href).origin}this.schedulerAPIURL=e;if(this._schedulerAPIConnector){this._schedulerAPIConnector.setSchedulerAPIURL(e)}}get scheduler(){if(this._schedulerAPIConnector){return this._schedulerAPIConnector}this._schedulerAPIConnector=new T({schedulerAPIURL:this.schedulerAPIURL,schedulerStore:this.schedulerStore,sessionId:this.sessionId,configId:this.configId,slug:this.slug,clientId:this.clientId});return this._schedulerAPIConnector}resetStores(){this.nylasSchedulerStore.reset()}}function E(e={}){const t={selectedDate:null,selectedLanguage:navigator.language,selectedTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTimeslot:null,showBookingForm:false,availabilityOrderEmails:[],selectableDates:null,availability:[],eventDuration:0,state:"ready",eventInfo:null,cancelledEventInfo:null,isLoading:false,nylasBranding:true,...e};d(`[defaultNylasStoreState]: `,t);const i=_(t);i.onChange("availability",(e=>{d(`[availability]: `,e);const t=e.map((e=>e.start_time));d(`[selectableDates]: `,t);i.set("selectableDates",t);const n=e[0];if(!n)return;const s=Math.floor((n.end_time.getTime()-n.start_time.getTime())/6e4);d(`[durationMinutes]: `,s);i.set("eventDuration",s)}));i.reset=()=>{for(const e in t){const n=t[e];i.set(e,n)}};return i}const B=(i,n)=>{const s=i.isLoading;const o=i.showNotification;const a=i.nylasBranding;const r=i.version;return e(t,null,o&&e("nylas-notification",null),s&&e("div",{class:"loading"},e("div",{class:"left"},e("div",{class:"skeleton"})),e("div",{class:"right"},e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}))),!s&&n,e("div",{key:"ns-footer",class:"footer",part:"ns_footer"},a&&e("a",{href:"https://scheduler.nylas.com?utm_source=powered-by-nylas-logoutm_medium=link&utm_campaign=get-scheduler&utm_id=get-scheduler",class:"powered-by-nylas",target:"_blank",rel:"noreferrer noopener"},"Powered by ",e("span",{class:"sr-only"},"Nylas"),e("nylas-logo",{"aria-hidden":true})),e("tooltip-component",null,e("info-icon",{slot:"tooltip-icon"}),e("span",{slot:"tooltip-content"},r))))};const L=(t,i)=>e("div",{class:"message-banner"},i);const D=':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 4px 8px 2px rgba(0, 0, 0, 0.05), 0px 8px 16px -2px rgba(0, 0, 0, 0.1);--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-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;font-family:var(--nylas-font-family);font-optical-sizing:auto;font-style:normal;font-variation-settings:"slnt" 0}@media screen and (max-width: 768px){:host{width:auto;min-width:325px}}:root{font-family:inherit}.error{padding:8rem 12rem;color:var(--nylas-base-0);background-color:var(--nylas-error);margin:1.5rem;border-radius:var(--nylas-border-radius-2x)}.message-banner{text-align:right;color:var(--nylas-base-800);padding:1rem;border-bottom:1px solid var(--nylas-color-primary-200);margin:0}.loading{margin:1.5rem;display:flex;gap:1rem}.loading .skeleton{border-radius:var(--nylas-border-radius-2x);animation:pulsate 1.5s infinite}.loading .skeleton:nth-child(2){animation-delay:-100ms}.loading .skeleton:nth-child(3){animation-delay:-200ms}.loading .skeleton:nth-child(4){animation-delay:-300ms}.loading .skeleton:nth-child(5){animation-delay:-400ms}.loading .left .skeleton{height:100%;width:400px}.loading .right .skeleton{height:5rem;width:300px;margin-bottom:1rem}.loading .right .skeleton:last-child{margin-bottom:0}@keyframes pulsate{0%{background-color:var(--nylas-base-50)}50%{background-color:var(--nylas-base-100)}100%{background-color:var(--nylas-base-50)}}.select-date-page,.additional-data-page,.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{border-top-left-radius:var(--nylas-border-radius-2x);border-top-right-radius:var(--nylas-border-radius-2x)}.select-date-page,.additional-data-page{display:flex}@media screen and (max-width: 768px){.select-date-page,.additional-data-page{flex-direction:column}}.booked-event-page,.manual-confirmation-page{background-color:var(--nylas-base-50)}.cancelled-event-page,.manual-confirmation-page,.cancel-flow-page{padding:1rem;height:496px;display:flex;justify-content:center;align-items:center}.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{min-width:784px;background:var(--nylas-base-50)}@media screen and (max-width: 768px){.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{min-width:90%}}.left-panel{display:flex;flex-direction:column;min-width:424px;border-top-left-radius:inherit;background:var(--nylas-base-0);position:relative;padding:1rem 0 0 0;height:624px}@media screen and (max-width: 768px){.left-panel{border-top-right-radius:inherit;min-width:unset;height:auto}}@media screen and (max-width: 768px){.select-date-page .left-panel{height:624px}}.border{margin-left:-20px;margin-right:-20px;border-top-width:1px;height:0.5px;background-color:var(--nylas-base-200)}@media screen and (max-width: 768px){.border{display:none}}.right-panel{min-width:360px;width:360px;background-color:var(--nylas-base-50);height:624px;padding-top:16px;border-left:1px solid var(--nylas-base-200);border-top-right-radius:inherit}.right-panel.reschedule{border-top-right-radius:0px}@media screen and (max-width: 768px){.right-panel{border-top-right-radius:0px;width:inherit;min-width:unset;height:auto;border-left:none}}.right-panel h2{display:flex;margin:0;height:48px;gap:0.5rem;justify-content:center;align-items:center;width:auto;font-size:1.125rem;line-height:1.5rem;font-weight:500;text-align:center;color:var(--nylas-base-800)}.additional-data-page .left-panel{background-color:var(--nylas-base-50)}.additional-data-page .right-panel{background-color:var(--nylas-base-0)}nylas-selected-event-card{height:604px;padding:0 1rem}@media screen and (max-width: 768px){nylas-selected-event-card{height:250px}}.footer{display:flex;justify-content:flex-end;align-items:center;gap:8px;padding:16px;font-size:14px;font-weight:300;color:var(--nylas-base-500);border-top:1px solid var(--nylas-base-200);min-height:24px}.footer .powered-by-nylas{display:flex;align-items:center;text-decoration:none;color:var(--nylas-base-500)}.footer .powered-by-nylas:hover{color:var(--nylas-base-800)}.footer svg{fill:var(--nylas-base-500)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}.footer svg{margin-top:1px}nylas-selected-event-card::part(nsec__timezone){position:absolute;bottom:0}nylas-notification{margin:1.5rem;width:-webkit-fill-available;width:-moz-available;position:absolute}nylas-locale-switch{position:absolute;padding:18px 20px;bottom:0;width:-webkit-fill-available;width:-moz-available;border-top:1px solid var(--nylas-base-200)}@media screen and (max-width: 768px){nylas-locale-switch{height:auto}}nylas-date-picker{padding:0 20px}button-component#report-issue{width:auto;position:absolute;bottom:4px;left:16px}.language-feedback-container{width:auto;position:absolute;bottom:4px;left:16px;display:flex;gap:8px;align-items:center}.language-feedback-container button-component#report-issue{position:initial}nylas-feedback-form{position:absolute;top:0;height:100%;width:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(0, 0, 0, 0.6);z-index:2;border-radius:inherit}';const z={title:r.t("genericErrorTitle"),category:m.Component};const R=class{constructor(e){i(this,e);this.init=n(this,"init",7);this.schedulerWillLoad=n(this,"schedulerWillLoad",7);this.schedulerDidLoad=n(this,"schedulerDidLoad",7);this.nylasSchedulerError=n(this,"nylasSchedulerError",7);this.nylasSchedulerInfo=n(this,"nylasSchedulerInfo",7);this.configSettingsLoaded=n(this,"configSettingsLoaded",7);this.bookingRefExtracted=n(this,"bookingRefExtracted",7);this.bookedEventInfo=n(this,"bookedEventInfo",7);this.initDeferred=false;this.mode="app";this.schedulerApiUrl="https://api.us.nylas.com";this.nylasBranding=true;this.eventOverrides={};this.showNotification=true;this.enableUserFeedback=true;this.automaticComponentRegistration=true;this.selectedDateLabel=(new Date).toLocaleDateString(navigator.language,{dateStyle:"full"})||`${r.t("noDateSelected")}`;this.language=navigator.language;this.showFeedbackModal=false;this.bookingInfoConfirmed=null;this.version=b}connectedCallback(){d(`[nylas-scheduler] connectedCallback`)}async componentWillLoad(){d(`[nylas-scheduler] Component will load`);this.version=b;await new Promise((e=>setTimeout(e,0)));if(this.enableUserFeedback&&!w()){v({dsn:"https://9d5731f1c77ca84c9ed3fb9b3ccf7ee1@o74852.ingest.us.sentry.io/4507889638178816",release:this.version,integrations:e=>[...e.filter((e=>false)),k({colorScheme:"system",autoInject:false})],autoSessionTracking:false,beforeSend:()=>null})}const e=this.schedulerWillLoad.emit(this.host);if("schedulerWillLoad"in this.eventOverrides){await this.eventOverrides.schedulerWillLoad(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}const t=new URLSearchParams(window.location.search);const i=t.get("lang");const n=i&&Object.values(h).includes(i)?i:null;this.stores={scheduler:E({bookingInfo:this.bookingInfo,nylasBranding:this.nylasBranding,themeConfig:this.themeConfig,hour12:this.hour12,selectedLanguage:n||this.defaultLanguage||this.bookingInfo?.language||g()||h.en,...this.defaultSchedulerState})};this.baseProvider=new a(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);this.refConfigId=this.configurationId;let s;try{if(this.rescheduleBookingRef){const[e,t,i]=f(this.rescheduleBookingRef);this.refConfigId=e;this.stores.scheduler.set("rescheduleBookingId",t);s=this.bookingRefExtracted.emit({configurationId:e,bookingId:t})}else if(this.cancelBookingRef){const[e,t,i]=f(this.cancelBookingRef);this.refConfigId=e;this.stores.scheduler.set("cancelBookingId",t);s=this.bookingRefExtracted.emit({configurationId:e,bookingId:t})}else if(this.organizerConfirmationBookingRef){const[e,t,i]=f(this.organizerConfirmationBookingRef);this.refConfigId=e;this.stores.scheduler.set("organizerConfirmationBookingId",t);this.stores.scheduler.set("organizerConfirmationSalt",i);s=this.bookingRefExtracted.emit({configurationId:e,bookingId:t,salt:i})}}catch(e){d(e);const t=this.rescheduleBookingRef||this.cancelBookingRef||this.organizerConfirmationBookingRef;this.nylasSchedulerError.emit({notification:{...this.getErrorObject({message:`Invalid booking reference: ${t}`})},host:this.host})}this.applyThemeConfig(this.themeConfig);if("bookingRefExtracted"in this.eventOverrides){await this.eventOverrides.bookingRefExtracted(s,this.nylasSchedulerConnector);if(s.defaultPrevented){return}}if(!this.checkIfSessionIdOrConfigIdExists(false)){this.initDeferred=true;return}const o=this.baseProvider?.getStore("scheduler");this.nylasSchedulerConnector=new S({schedulerAPIURL:this.schedulerApiUrl,sessionId:this.sessionId,configId:this.refConfigId,slug:this.slug,clientId:this.clientId,nylasSchedulerStore:o});const r=this.init.emit(this.host);if("init"in this.eventOverrides){await this.eventOverrides.init(r,this.nylasSchedulerConnector);if(r.defaultPrevented){return}}this.baseProvider?.componentWillLoad(this.nylasSchedulerConnector)}async componentDidLoad(){if(this.initDeferred){return}this.baseProvider?.componentDidLoad();await Promise.resolve();const e=this.schedulerDidLoad.emit(this.host);if("schedulerDidLoad"in this.eventOverrides){await this.eventOverrides.schedulerDidLoad(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}if(!this.checkIfSessionIdOrConfigIdExists()){return}await this.performSchedulerDataFetch()}async performSchedulerDataFetch(){this.fetchAbortController?.abort();this.fetchAbortController=new AbortController;const{signal:e}=this.fetchAbortController;try{if(this.nylasSchedulerConnector){if(this.schedulerApiUrl){this.nylasSchedulerConnector.setSchedulerAPIURL(this.schedulerApiUrl)}if(this.sessionId){this.nylasSchedulerConnector.sessionId=this.sessionId;this.nylasSchedulerConnector.scheduler.setSessionId(this.sessionId)}}this.localizationChanged(this.localization);const t=await(this.nylasSchedulerConnector?.scheduler.getUISettings(e));if(e.aborted)return;if(!t||"error"in t){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(t?.error)},host:this.host});return}else{if("data"in t&&t.data?.appearance){d("Appearance settings have been returned from the configuration used byt his scheduling page; please remember to grab them from the configSettingsLoaded event and apply them as desired.")}const i=this.configSettingsLoaded.emit({settings:t});if("configSettingsLoaded"in this.eventOverrides){await this.eventOverrides.configSettingsLoaded(i,this.nylasSchedulerConnector);if(e.aborted)return;if(i.defaultPrevented){return}}}const i=this.baseProvider?.getStore("scheduler");const n=i?.get("configSettings")?.scheduler?.available_days_in_future;const s=i?.get("selectedTimeslot");if(s&&s?.start_time){if(!this.isTimeslotValid(s)){return}if(i?.get("showBookingForm")){i?.set("selectedDate",s.start_time);return}}const o=l(i?.get("selectedDate"));const a=i?.get("availability");let r;if(a&&a.length>0){return}if(!o){const t=new Date;const{startTime:i,endTime:s,endTimeForAvailableDaysInFuture:o}=this.validateAvailableDaysInFuture(t,n||30);if(t.getTime()<o*1e3){r=await(this.nylasSchedulerConnector?.scheduler.getAvailability(i,s,e))}}else{const{startTime:t,endTime:i,endTimeForAvailableDaysInFuture:s}=this.validateAvailableDaysInFuture(o,n||30);if(o.getTime()<s*1e3){r=await(this.nylasSchedulerConnector?.scheduler.getAvailability(t,i,e))}}if(e.aborted)return;if(!r||"error"in r){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(r?.error)},host:this.host})}if(!o){let e=new Date;const t=i?.get("availability").find((e=>{const t=l(e.start_time);return t?t>new Date:false}));if(t){e=l(t.start_time)||e}i?.set("selectedDate",e)}}catch(e){if(e.name==="AbortError")return;throw e}}hasValidAuthConfig(){return!!(this.sessionId||this.refConfigId||this.slug&&this.clientId)}async performDeferredInit(){if(!this.hasValidAuthConfig()||!this.initDeferred||!this.baseProvider){return}document.body.dispatchEvent(new CustomEvent("nylasSchedulerClearNotifications",{detail:{host:this.host},bubbles:true}));this.initDeferred=false;this.refConfigId=this.refConfigId||this.configurationId;this.baseProvider.eventOverrides=this.eventOverrides;const e=this.baseProvider.getStore("scheduler");this.nylasSchedulerConnector=new S({schedulerAPIURL:this.schedulerApiUrl,sessionId:this.sessionId,configId:this.refConfigId,slug:this.slug,clientId:this.clientId,nylasSchedulerStore:e});const t=this.init.emit(this.host);if("init"in this.eventOverrides){await this.eventOverrides.init(t,this.nylasSchedulerConnector);if(t.defaultPrevented){return}}await this.baseProvider.componentWillLoad(this.nylasSchedulerConnector);this.baseProvider.componentDidLoad();await Promise.resolve();const i=this.schedulerDidLoad.emit(this.host);if("schedulerDidLoad"in this.eventOverrides){await this.eventOverrides.schedulerDidLoad(i,this.nylasSchedulerConnector);if(i.defaultPrevented){return}}await this.performSchedulerDataFetch()}async authPropsChanged(e){if(e&&"bookingRefExtracted"in this.eventOverrides){await this.eventOverrides.bookingRefExtracted(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}if(this.initDeferred&&this.hasValidAuthConfig()){this.performDeferredInit()}}configurationIdChanged(){if(!this.rescheduleBookingRef&&!this.cancelBookingRef&&!this.organizerConfirmationBookingRef){this.refConfigId=this.configurationId}this.authPropsChanged()}schedulerApiUrlChanged(){if(this.nylasSchedulerConnector&&this.schedulerApiUrl){this.nylasSchedulerConnector.setSchedulerAPIURL(this.schedulerApiUrl);document.body.dispatchEvent(new CustomEvent("nylasSchedulerClearNotifications",{detail:{host:this.host},bubbles:true}));this.stores?.scheduler.set("availability",[]);this.performSchedulerDataFetch()}}sessionIdChanged(){if(this.nylasSchedulerConnector&&this.sessionId){this.nylasSchedulerConnector.sessionId=this.sessionId;this.nylasSchedulerConnector.scheduler.setSessionId(this.sessionId);document.body.dispatchEvent(new CustomEvent("nylasSchedulerClearNotifications",{detail:{host:this.host},bubbles:true}));this.performSchedulerDataFetch()}this.authPropsChanged()}slugChanged(){this.authPropsChanged()}clientIdChanged(){this.authPropsChanged()}componentDisconnected(){this.baseProvider?.componentDisconnected()}bookingInfoChanged(e){this.stores?.scheduler.set("bookingInfo",e);if(e?.language&&!this.defaultLanguage){this.stores?.scheduler.set("selectedLanguage",e.language)}}rescheduleBookingRefChanged(e){let t;if(e){try{const[i,n]=f(e);this.stores?.scheduler.set("rescheduleBookingId",n);this.refConfigId=i;this.nylasSchedulerConnector?.scheduler.setConfigId(i);t=this.bookingRefExtracted.emit({configurationId:i,bookingId:n})}catch(t){d(t);this.nylasSchedulerError.emit({notification:{...this.getErrorObject({message:`Invalid booking reference: ${e}`})},host:this.host})}}this.authPropsChanged(t)}cancelBookingRefChanged(e){let t;if(e){try{const[i,n]=f(e);this.stores?.scheduler.set("cancelBookingId",n);this.refConfigId=i;this.nylasSchedulerConnector?.scheduler.setConfigId(i);t=this.bookingRefExtracted.emit({configurationId:i,bookingId:n})}catch(t){d(t);this.nylasSchedulerError.emit({notification:{...this.getErrorObject({message:`Invalid booking reference: ${e}`})},host:this.host})}}this.authPropsChanged(t)}organizerConfirmationBookingRefChanged(e){let t;if(e){try{const[i,n,s]=f(e);this.stores?.scheduler.set("organizerConfirmationBookingId",n);this.stores?.scheduler.set("organizerConfirmationSalt",s);this.refConfigId=i;this.nylasSchedulerConnector?.scheduler.setConfigId(i);t=this.bookingRefExtracted.emit({configurationId:i,bookingId:n,salt:s})}catch(t){d(t);this.nylasSchedulerError.emit({notification:{...this.getErrorObject({message:`Invalid booking reference: ${e}`})},host:this.host})}}this.authPropsChanged(t)}localizationChanged(e){if(!e){return}Object.keys(e).forEach((t=>{if(!(t in h)){return}r.addResourceBundle(t,"translation",e[t],false,true)}))}defaultLanguageChanged(e){if(e){this.stores?.scheduler.set("selectedLanguage",e);r.changeLanguage(e)}}themeConfigChanged(e){this.baseProvider?.getStore("scheduler")?.set("themeConfig",e);this.applyThemeConfig(e)}languageChanged(e){const t=e.detail;this.language=t;r.changeLanguage(t)}async registerComponentHandler(e){this.baseProvider?.registerComponent(e.detail)}async unregisterComponentHandler(e){this.baseProvider?.unregisterComponent(e.detail)}async monthChangedHandler(e){const t=e.detail;const i=this.nylasSchedulerConnector?.schedulerStore?.get("configSettings")?.scheduler?.available_days_in_future;const{startTime:n,endTime:s,endTimeForAvailableDaysInFuture:o}=this.validateAvailableDaysInFuture(t,i||30);if(e.defaultPrevented){return}if(n<o&&t.getTime()<o*1e3){const e=await(this.nylasSchedulerConnector?.scheduler.getAvailability(n,s));if(!e||"error"in e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e?.error)},host:this.host})}const t=this.stores?.scheduler.get("selectableDates");if(t&&t.length>0){this.stores?.scheduler.set("selectedDate",t[0])}}}mapToBookingData(e){const t=this.stores?.scheduler.get("selectedTimeslot");const i=this.stores?.scheduler.get("selectedLanguage");const n=this.stores?.scheduler.get("selectedTimezone");const s=t?.start_time?new Date(t?.start_time).getTime()/1e3:"";const o=t?.end_time?new Date(t?.end_time).getTime()/1e3:"";return{additional_guests:e.guests,guest:{...e.primaryParticipant},additional_fields:{...e.additionalFields},start_time:s,end_time:o,email_language:i,timezone:n}}async bookButtonClickedHandler(e){if(e.defaultPrevented){return}const t=e.detail;const i=this.mapToBookingData(t);this.bookingInfoConfirmed=t;const n=this.nylasSchedulerConnector?.schedulerStore?.get("rescheduleBookingId");const s=n;if(s){const e=await(this.nylasSchedulerConnector?.scheduler.rescheduleBooking(s,t));if(!e||"error"in e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e?.error)},host:this.host})}const n=e?.data;const o=this.bookedEventInfo.emit({...e,data:{...n,...i}});this.bookingInfoConfirmed={...this.bookingInfoConfirmed,...n};if("bookedEventInfo"in this.eventOverrides){await this.eventOverrides.bookedEventInfo(o,this.nylasSchedulerConnector)}return}const o=await(this.nylasSchedulerConnector?.scheduler.bookTimeslot(t));if(!o||"error"in o){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(o?.error)},host:this.host})}const a=o?.data;const r=this.bookedEventInfo.emit({...o,data:{...a,...i}});this.bookingInfoConfirmed={...this.bookingInfoConfirmed,...a};if("bookedEventInfo"in this.eventOverrides){await this.eventOverrides.bookedEventInfo(r,this.nylasSchedulerConnector)}}dateSelectedHandler(e){const t=l(e.detail);this.selectedDateLabel=t?t.toLocaleDateString(this.language,{dateStyle:"full"}):`${r.t("noDateSelected")}`}cancelBookedEventErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}cancelBookedEventValidationErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}rescheduleBookedEventErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}confirmBookingErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}feedbackModalClosedHandler(){this.showFeedbackModal=false}eventIsFullHandler(e){const t=e.detail.error;const i=e.detail.type;if(i==="error"){this.nylasSchedulerError.emit({notification:{...this.getErrorObject({message:t})},host:this.host})}else{this.nylasSchedulerInfo.emit({notification:{title:"Event is full",category:m.Component,type:y.Info,description:"The event you selected is full. Please try a different time.",id:(new Date).getTime().toString(),ttl:3e3},host:this.host})}}feedbackSubmittedHandler(e){I("Scheduling Page User Feedback",{extra:{configId:this.configurationId,slug:this.slug}});const t={message:e.detail.feedback};x(t,{includeReplay:true,captureContext:{tags:{"nylas-web-element":"nylas-scheduling","nylas-web-element-version":this.version,"nylas-config-id":this.configurationId,"nylas-slug":this.slug,"host-url":window.location.href},extra:{configId:this.configurationId,slug:this.slug,version:this.version}}});this.showFeedbackModal=false}async getNylasSchedulerStore(){return this.baseProvider?.getStore("scheduler")}async getNylasSchedulerConnector(){return this.nylasSchedulerConnector}async getRef(){return this.host}getErrorObject(e){return{title:e?.title||z.title,category:e?.category||z.category,type:y.Error,description:e?.message||"",id:(new Date).getTime().toString(),ttl:"none"}}checkIfSessionIdOrConfigIdExists(e=true){if(!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)){if(e){let e="";if(!this.sessionId){e+=r.t("sessionIdRequiredErrorMessage")}if(!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)){e=r.t("sessionIdRequiredErrorMessage")+" "+r.t("publicConfigErrorMessage")}this.nylasSchedulerError.emit({notification:{title:r.t("schedulingComponentErrorTitle"),category:m.Component,type:y.Error,description:e,id:(new Date).getTime().toString(),ttl:"none"},host:this.host})}return false}return true}isTimeslotValid(e){const t=new Date(e.start_time);if(t<new Date){this.nylasSchedulerError.emit({notification:{title:r.t("invalidTimeslotErrorTitle"),category:m.Component,type:y.Error,description:r.t("invalidTimeslotErrorMessage"),id:(new Date).getTime().toString(),ttl:"none"},host:this.host});return false}return true}validateAvailableDaysInFuture(e,t){const i=new Date;const n=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3;const s=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3;const o=Math.floor(c(i,t).getTime()/1e3);const a=Math.min(o,s);const r=n<i.getTime()/1e3?Math.floor(i.getTime()/1e3):n;return{startTime:r,endTime:a,endTimeForAvailableDaysInFuture:o}}applyThemeConfig(e){if(e){for(const[t,i]of Object.entries(e)){this.host.style.setProperty(`${t}`,i)}}}onFeedbackClick(e){e.preventDefault();this.showFeedbackModal=true}redirectToCustomUrl(e){window.location.assign(e)}nylasFormDropdownChangedHandler(e){const{name:t,value:i}=e.detail;if(t==="language"){const e=h[i];r.changeLanguage(e);this.stores?.scheduler?.set("selectedLanguage",e)}}render(){const t=this.mode==="app";const i=this.baseProvider?.getStore("scheduler");const n=i?.get("eventInfo");const o=i?.get("showBookingForm");const a=i?.get("cancelledEventInfo");const c=i?.get("cancelBookingId");const d=i?.get("selectedTimeslot");const f=i?.get("rescheduleBookingId");const m=i?.get("organizerConfirmationBookingId");const b=i?.get("rejectBookingId");const y=i?.get("confirmedEventInfo");const _=i?.get("nylasBranding")||this.nylasBranding;const w=l(i?.get("selectedDate"));const v=i?.get("configSettings")?.scheduler?.confirmation_redirect_url;this.selectedDateLabel=w&&this.language?u(w.toLocaleDateString(this.language,{dateStyle:"full"})):`${r.t("noDateSelected")}`;const k=Object.keys(p).map((e=>({label:p[e],value:e})));const I=i?.get("selectedLanguage")||this.defaultLanguage||g()||h.en;if(t&&(c||b)&&!a){return e(s,null,e(B,{version:this.version,nylasBranding:_,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancel-flow-page",part:"cancel-flow-page"},e("nylas-cancel-booking-form",{selectedTimeslot:d,cancelBookingId:c,rejectBookingId:b,exportparts:"ncbf, ncbf__icon, ncbf__title, ncbf__description, ncbf__reason-textarea, ncbf__button-cta, ncbf__button-outline, ncbf__card"}))),e("div",{class:"language-feedback-container"},this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),e("select-dropdown",{name:"language",searchPlaceholder:r.t("search"),options:k,withChevron:false,themeConfig:this.themeConfig,defaultSelectedOption:k.find((e=>e.value==I)),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",{slot:"select-icon"},e("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&m){return e(s,null,e(B,null,e("div",{class:"manual-confirmation-page",part:"manual-confirmation-page"},e("nylas-organizer-confirmation-card",{organizerConfirmationBookingId:m,exportparts:"nmcc, nmcc__title, nmcc__description, nmcc__button-cta, nmcc__button-outline"}))),e("div",{class:"language-feedback-container"},this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),e("select-dropdown",{name:"language",searchPlaceholder:r.t("search"),options:k,withChevron:false,themeConfig:this.themeConfig,defaultSelectedOption:k.find((e=>e.value==I)),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",{slot:"select-icon"},e("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&a){return e(s,null,e(B,{version:this.version,nylasBranding:_,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancelled-event-page",part:"cancelled-event-page"},e("nylas-cancelled-event-card",{cancelledEventInfo:a,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))),e("div",{class:"language-feedback-container"},this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),e("select-dropdown",{name:"language",searchPlaceholder:r.t("search"),options:k,withChevron:false,themeConfig:this.themeConfig,defaultSelectedOption:k.find((e=>e.value==I)),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",{slot:"select-icon"},e("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&y){return e(s,null,e(B,{version:this.version,nylasBranding:_,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancelled-event-page",part:"confirmed-event-page"},e("nylas-confirmed-event-card",{confirmedEventInfo:y,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))),e("div",{class:"language-feedback-container"},this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),e("select-dropdown",{name:"language",searchPlaceholder:r.t("search"),options:k,withChevron:false,themeConfig:this.themeConfig,defaultSelectedOption:k.find((e=>e.value==I)),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",{slot:"select-icon"},e("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&n&&v){const e=this.bookingInfoConfirmed?.primaryParticipant;const t=this.bookingInfoConfirmed?.location;const i=this.bookingInfoConfirmed?.booking_ref;const s=this.bookingInfoConfirmed?.additionalFields||{};if(this.bookingInfo&&typeof this.bookingInfo?.additionalFields!=="undefined"){const e=this.bookingInfo.additionalFields;Object.keys(e).forEach((t=>{if(!s[t]&&e?.[t]){s[t]=e[t].value}}))}const o=this.stores?.scheduler.get("selectedTimeslot");const a=this.stores?.scheduler.get("selectedTimezone");const r=this.stores?.scheduler.get("selectedLanguage");const l=this.stores?.scheduler.get("configSettings");const c=this.configurationId?this.configurationId:l?.configuration_id;const d=window.location.search;const h=new URLSearchParams(d);h.set("booking_id",n.booking_id);e?.name&&h.set("name",e.name);e?.email&&h.set("email",e.email);o?.start_time&&h.set("start_time",(new Date(o.start_time).getTime()/1e3).toString());o?.end_time&&h.set("end_time",(new Date(o.end_time).getTime()/1e3).toString());a&&h.set("tz",a);r&&h.set("language",r);s&&h.set("additional_values",JSON.stringify(s));this.slug&&h.set("page_slug",this.slug);c&&h.set("config_id",c);t&&h.set("location",t);i&&h.set("booking_ref",i);const g=new URL(v,window.location.origin);h.forEach(((e,t)=>{g.searchParams.set(t,e)}));this.redirectToCustomUrl(g.toString());return}if(t&&n){return e(s,null,e(B,{version:this.version,nylasBranding:_,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"booked-event-page",part:"booked-event-page ns_booked-event-page"},e("nylas-booked-event-card",{selectedTimeslot:d,eventInfo:n,exportparts:"nbec, nbec__title, nbec__card, nbec__description, nbec__button-outline, nbec__cancel-cta, nbec__reschedule-cta"}))),e("div",{class:"language-feedback-container"},this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),e("select-dropdown",{name:"language",searchPlaceholder:r.t("search"),options:k,withChevron:false,themeConfig:this.themeConfig,defaultSelectedOption:k.find((e=>e.value==I)),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",{slot:"select-icon"},e("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&(!n||!!f)&&!o){const t=this.host.querySelector('[slot="timeslot-picker-cta-label"]');return e(s,null,e(B,{version:this.version,nylasBranding:_,isLoading:this.isLoading,showNotification:this.showNotification},f&&e(L,null,`${r.t("rescheduleTitle")}`),e("div",{class:"select-date-page",part:"select-date-page ns_select-date-page"},e("div",{class:"left-panel",part:"ns_left-panel"},e("nylas-date-picker",{exportparts:"ndp, ndp__title, ndp__month-header, ndp__month-button, ndp__day, ndp__date, ndp__date--disabled, ndp__date--selected, ndp__date--current-day, ndp__date--current-month"}),e("nylas-locale-switch",{exportparts:"nls, nls__timezone, nls__timezone-dropdown, nls__timezone-drop-button, nls__timezone-drop-button-selected-label, nls__timezone-drop-content, nls__timezone-drop-label, nls__language, nls__language-dropdown, nls__language-drop-button, nls__language-drop-content, nls__language-drop-label"})),e("div",{class:`right-panel ${f?"reschedule":""}`,part:`ns_right-panel ${f?"ns_reschedule":""}`},e("h2",{part:"ns_right-panel__title"},e("calendar-icon",{part:"ns_right-panel__calendar-icon"}),e("span",{id:"selectedDate",part:"ns_right-panel__selected-date"},this.selectedDateLabel)),e("nylas-timeslot-picker",{exportparts:"ntp, ntp__time-picker-wrapper, ntp__timeslots, ntp__timeslot, ntp__timeslot--selected, ntp__button-primary"},t&&e("span",{slot:"timeslot-picker-cta-label"},e("slot",{name:"timeslot-picker-cta-label"})))))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&!n&&o){return e(s,null,e(B,{version:this.version,nylasBranding:_,isLoading:this.isLoading,showNotification:this.showNotification},f&&e(L,null,`${r.t("rescheduleTitle")}`),e("div",{class:"additional-data-page",part:"additional-data-page ns_additional-data-page"},e("div",{class:"left-panel ns_left-panel",part:"ns_left-panel"},e("div",{class:"wrapper",part:"ns_left-panel__wrapper"},e("nylas-selected-event-card",{exportparts:"nsec, nsec__card, nsec__icon, nsec__date, nsec__time, nsec__timezone"}))),e("div",{class:`right-panel ${f?"reschedule":""}`,part:`ns_right-panel ${f?"ns_reschedule":""}`},e("nylas-booking-form",{exportparts:"nbf, nbf__input-textfield, nbf__button-ghost, nbf__button-outline, nbf__button-primary, nbf__input-wrapper, nbf__checkbox-component, nbf__radio-button-group, nbf__textarea-component, nbf__dropdown, nbf__dropdown-button, nbf__dropdown-content"})))),e("div",{class:"language-feedback-container"},this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),e("select-dropdown",{name:"language",searchPlaceholder:r.t("search"),options:k,withChevron:false,themeConfig:this.themeConfig,defaultSelectedOption:k.find((e=>e.value==I)),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",{slot:"select-icon"},e("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&e("nylas-feedback-form",null))}return e(s,null,e("slot",null))}get host(){return o(this)}static get watchers(){return{configurationId:["configurationIdChanged"],schedulerApiUrl:["schedulerApiUrlChanged"],sessionId:["sessionIdChanged"],slug:["slugChanged"],clientId:["clientIdChanged"],bookingInfo:["bookingInfoChanged"],rescheduleBookingRef:["rescheduleBookingRefChanged"],cancelBookingRef:["cancelBookingRefChanged"],organizerConfirmationBookingRef:["organizerConfirmationBookingRefChanged"],localization:["localizationChanged"],defaultLanguage:["defaultLanguageChanged"],themeConfig:["themeConfigChanged"]}}};R.style=D;export{R as nylas_scheduling};
2
+ //# sourceMappingURL=p-d1dc06a1.entry.js.map