@nylas/react 1.1.0-canary.18 → 1.1.0-canary.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{add-circle-icon_2.entry-3b13ee64.js → add-circle-icon_2.entry-3ca337a6.js} +5 -5
- package/dist/{add-circle-icon_2.entry-3091976b.cjs → add-circle-icon_2.entry-adde5fdf.cjs} +1 -1
- package/dist/{archive-icon_7.entry-c2b6d860.cjs → archive-icon_7.entry-2b56ef80.cjs} +1 -1
- package/dist/{archive-icon_7.entry-8932618a.js → archive-icon_7.entry-896a1054.js} +13 -13
- package/dist/{arrow-icon.entry-a159bee8.cjs → arrow-icon.entry-0288f3fc.cjs} +1 -1
- package/dist/arrow-icon.entry-9aaa93fd.js +15 -0
- package/dist/{bold-icon_3.entry-447d0537.js → bold-icon_3.entry-0061cf1f.js} +4 -4
- package/dist/{bold-icon_3.entry-c51e1af3.cjs → bold-icon_3.entry-e7810620.cjs} +1 -1
- package/dist/button-component_4.entry-276606e6.js +115 -0
- package/dist/button-component_4.entry-e53a8f37.cjs +1 -0
- package/dist/calendar-agenda-fill-icon_35.entry-a19cae9c.js +4178 -0
- package/dist/calendar-agenda-fill-icon_35.entry-fa968081.cjs +7 -0
- package/dist/{calendar-cancel-icon.entry-a78f27bc.js → calendar-cancel-icon.entry-71eae711.js} +1 -1
- package/dist/{calendar-cancel-icon.entry-805febcc.cjs → calendar-cancel-icon.entry-8e8b25b6.cjs} +1 -1
- package/dist/{calendar-check-icon_2.entry-4a0fd7bd.cjs → calendar-check-icon_2.entry-562e98cf.cjs} +1 -1
- package/dist/{calendar-check-icon_2.entry-7c8b6c92.js → calendar-check-icon_2.entry-6f971ca2.js} +1 -1
- package/dist/{calendar-icon.entry-1fc018b4.cjs → calendar-icon.entry-3a59af30.cjs} +1 -1
- package/dist/{calendar-icon.entry-96f9727f.js → calendar-icon.entry-3e496896.js} +1 -1
- package/dist/{chevron-icon_3.entry-25d90239.js → chevron-icon_3.entry-7eac0ed5.js} +37 -34
- package/dist/chevron-icon_3.entry-7ff10540.cjs +1 -0
- package/dist/{clock-icon_2.entry-c1b22ed4.js → clock-icon_2.entry-120d672e.js} +5 -5
- package/dist/{clock-icon_2.entry-2406c3d0.cjs → clock-icon_2.entry-43873262.cjs} +1 -1
- package/dist/{constants-f34b9c6e-b774916c.cjs → constants-7ce66b44-a951d78c.cjs} +5 -5
- package/dist/{constants-f34b9c6e-f1c4dd0d.js → constants-7ce66b44-e7ca66c2.js} +484 -383
- package/dist/copy-icon_4.entry-57874c4f.cjs +1 -0
- package/dist/copy-icon_4.entry-9a949d24.js +45 -0
- package/dist/{document-refresh-icon.entry-570f9c9d.js → document-refresh-icon.entry-f0d95ac8.js} +5 -5
- package/dist/document-refresh-icon.entry-f1d3f32d.cjs +1 -0
- package/dist/elements/index.d.ts +14 -0
- package/dist/{elements-dc5b338e-550a6cb1.cjs → elements-dc5b338e-62b53496.cjs} +1 -1
- package/dist/{elements-dc5b338e-cafa7a55.js → elements-dc5b338e-974e2077.js} +1 -1
- package/dist/{focus-visible-e8093c16-022799ce.js → focus-visible-e8093c16-7a512fc0.js} +1 -1
- package/dist/{focus-visible-e8093c16-c14162e8.cjs → focus-visible-e8093c16-923e1041.cjs} +1 -1
- package/dist/{forward-icon_6.entry-55752b23.cjs → forward-icon_6.entry-45b70066.cjs} +3 -3
- package/dist/{forward-icon_6.entry-9b832146.js → forward-icon_6.entry-675c0b73.js} +9 -9
- package/dist/{globe-icon.entry-2b61820e.js → globe-icon.entry-3296e427.js} +2 -2
- package/dist/{globe-icon.entry-dabe7b8b.cjs → globe-icon.entry-7ecd6221.cjs} +1 -1
- package/dist/google-logo-icon_4.entry-aa9f8b35.js +584 -0
- package/dist/google-logo-icon_4.entry-fd734a59.cjs +1 -0
- package/dist/index-53420959-1c0d390d.js +5 -0
- package/dist/index-53420959-8e7b10db.cjs +1 -0
- package/dist/{index-812162da.js → index-5efb84b8.js} +813 -793
- package/dist/{index-6d9eeb53-3edef246.js → index-6d9eeb53-4e2a7f9f.js} +2 -2
- package/dist/{index-6d9eeb53-3049fc04.cjs → index-6d9eeb53-aa1dfa96.cjs} +1 -1
- package/dist/index-d36b8fb8.cjs +42 -0
- package/dist/{index.es-9cc0eb3c-52226859.js → index.es-9cc0eb3c-65f8af0c.js} +1 -1
- package/dist/{index.es-9cc0eb3c-0c99c055.cjs → index.es-9cc0eb3c-8eefd4fc.cjs} +1 -1
- package/dist/{info-icon_2.entry-5f6b9af8.cjs → info-icon_2.entry-e612f1d6.cjs} +1 -1
- package/dist/{info-icon_2.entry-2fe6c16c.js → info-icon_2.entry-f06c8dd0.js} +8 -8
- package/dist/{input-dropdown_2.entry-dbdb5aa3.cjs → input-dropdown_2.entry-ad380260.cjs} +1 -1
- package/dist/{input-dropdown_2.entry-dbd0d6f4.js → input-dropdown_2.entry-ccd95678.js} +3 -3
- package/dist/{loading-icon.entry-e179f122.cjs → loading-icon.entry-678a6b3f.cjs} +1 -1
- package/dist/loading-icon.entry-9e6670d5.js +15 -0
- package/dist/{mailbox-store-64b4ef7c-0eac526c.cjs → mailbox-store-64b4ef7c-9bd02ffd.cjs} +1 -1
- package/dist/{mailbox-store-64b4ef7c-22a6c565.js → mailbox-store-64b4ef7c-b56d5e78.js} +2 -2
- package/dist/multi-select-dropdown.entry-5bb80d89.cjs +1 -0
- package/dist/multi-select-dropdown.entry-edf10867.js +91 -0
- package/dist/{nylas-booked-event-card_10.entry-e0990f5b.js → nylas-booked-event-card_10.entry-92f6e85d.js} +267 -235
- package/dist/nylas-booked-event-card_10.entry-ad4671b2.cjs +1 -0
- package/dist/{nylas-custom-booking-flow.entry-bc64af5f.js → nylas-custom-booking-flow.entry-b39a2bf2.js} +3 -3
- package/dist/{nylas-custom-booking-flow.entry-898c8cc9.cjs → nylas-custom-booking-flow.entry-cef0041a.cjs} +1 -1
- package/dist/{nylas-form-card.entry-c564b52e.js → nylas-form-card.entry-bf4545e2.js} +11 -11
- package/dist/{nylas-form-card.entry-0c71f4fc.cjs → nylas-form-card.entry-fba5d623.cjs} +1 -1
- package/dist/{nylas-if-state.entry-e9486e12.js → nylas-if-state.entry-2739dc10.js} +3 -3
- package/dist/{nylas-if-state.entry-ff6a2046.cjs → nylas-if-state.entry-d7b818a6.cjs} +1 -1
- package/dist/{nylas-list-folders.entry-90716d2b.cjs → nylas-list-folders.entry-0ec6ba20.cjs} +1 -1
- package/dist/{nylas-list-folders.entry-0258af1e.js → nylas-list-folders.entry-3197e390.js} +7 -7
- package/dist/{nylas-list-threads.entry-21edf012.cjs → nylas-list-threads.entry-2a7e1e84.cjs} +1 -1
- package/dist/{nylas-list-threads.entry-1abcdd30.js → nylas-list-threads.entry-9004c490.js} +3 -3
- package/dist/{nylas-login.entry-2e0ce95e.cjs → nylas-login.entry-c2ffd6a5.cjs} +1 -1
- package/dist/{nylas-login.entry-ba7383ac.js → nylas-login.entry-f2927406.js} +3 -3
- package/dist/{nylas-mailbox-pagination.entry-ba6beb08.cjs → nylas-mailbox-pagination.entry-839c9ad3.cjs} +1 -1
- package/dist/{nylas-mailbox-pagination.entry-f6186560.js → nylas-mailbox-pagination.entry-e9356835.js} +2 -2
- package/dist/{nylas-mailbox-toolbar-button.entry-e18059b0.js → nylas-mailbox-toolbar-button.entry-298a3c47.js} +10 -10
- package/dist/{nylas-mailbox-toolbar-button.entry-0875aadb.cjs → nylas-mailbox-toolbar-button.entry-43812d51.cjs} +1 -1
- package/dist/{nylas-mailbox.entry-2e3815ed.js → nylas-mailbox.entry-aa42f6c4.js} +4 -4
- package/dist/{nylas-mailbox.entry-bb2905bf.cjs → nylas-mailbox.entry-cf13ddf5.cjs} +1 -1
- package/dist/{nylas-provider.entry-69ee5061.js → nylas-provider.entry-1a3a195f.js} +39 -39
- package/dist/{nylas-provider.entry-51c5cdbf.cjs → nylas-provider.entry-843b5593.cjs} +1 -1
- package/dist/nylas-scheduler-editor.entry-048e7a8f.cjs +2 -0
- package/dist/{nylas-scheduler-editor.entry-d4a9afb1.js → nylas-scheduler-editor.entry-d56d6d2a.js} +138 -119
- package/dist/nylas-scheduling.entry-0ad9b1d0.cjs +1 -0
- package/dist/{nylas-scheduling.entry-f82a2822.js → nylas-scheduling.entry-7039a890.js} +52 -52
- package/dist/{nylas-threads-refresh.entry-99001756.cjs → nylas-threads-refresh.entry-9cae6ac8.cjs} +1 -1
- package/dist/{nylas-threads-refresh.entry-72482d2f.js → nylas-threads-refresh.entry-d951050a.js} +10 -10
- package/dist/nylas-threads-search.entry-0d34c5a8.cjs +1 -0
- package/dist/{nylas-threads-search.entry-c5fe50e5.js → nylas-threads-search.entry-7a4bbc75.js} +17 -17
- package/dist/{nylas-time-window-picker.entry-ccffcf2b.cjs → nylas-time-window-picker.entry-062bc8c1.cjs} +1 -1
- package/dist/{nylas-time-window-picker.entry-0d93e7cc.js → nylas-time-window-picker.entry-210c3f1a.js} +2 -2
- package/dist/{nylas-view-thread.entry-2d34b41c.js → nylas-view-thread.entry-8b39a997.js} +6 -6
- package/dist/{nylas-view-thread.entry-58432a52.cjs → nylas-view-thread.entry-db78ed9c.cjs} +1 -1
- package/dist/play-icon_2.entry-19271982.cjs +1 -0
- package/dist/play-icon_2.entry-c53f3cac.js +25 -0
- package/dist/react.cjs +1 -1
- package/dist/react.js +115 -101
- package/dist/{refresh-icon.entry-a041136d.js → refresh-icon.entry-75139a0c.js} +4 -4
- package/dist/{refresh-icon.entry-1e670732.cjs → refresh-icon.entry-e695cf7f.cjs} +1 -1
- package/dist/{register-component-a5a9ca5d-a5c01c35.js → register-component-a5a9ca5d-d69a7a05.js} +1 -1
- package/dist/{register-component-a5a9ca5d-b68b6039.cjs → register-component-a5a9ca5d-eebf89e7.cjs} +1 -1
- package/dist/scheduler-config-store-9ccfba4d-22a58b7d.cjs +1 -0
- package/dist/{scheduler-config-store-4a50a03d-ee42ff96.js → scheduler-config-store-9ccfba4d-fd62a421.js} +8 -6
- package/dist/{scheduler-store-f02ce045-23a14e3f.js → scheduler-store-8a400448-3b007d4d.js} +125 -96
- package/dist/scheduler-store-8a400448-44e0edad.cjs +1 -0
- package/dist/{textarea-component.entry-24a830c1.cjs → textarea-component.entry-48feabb3.cjs} +1 -1
- package/dist/{textarea-component.entry-1b4c771b.js → textarea-component.entry-ead5ab00.js} +7 -6
- package/dist/{translate-icon.entry-44bde57b.js → translate-icon.entry-55043beb.js} +2 -2
- package/dist/{translate-icon.entry-0c0add25.cjs → translate-icon.entry-5f62bc61.cjs} +1 -1
- package/dist/{warning-icon.entry-9a77ab01.cjs → warning-icon.entry-2e0a80da.cjs} +1 -1
- package/dist/{warning-icon.entry-8956cba2.js → warning-icon.entry-fa644462.js} +5 -5
- package/package.json +3 -3
- package/dist/arrow-icon.entry-1f54c377.js +0 -15
- package/dist/button-component.entry-52ccb6d9.js +0 -16
- package/dist/button-component.entry-e79b2d08.cjs +0 -1
- package/dist/calendar-info-icon_28.entry-2054703c.cjs +0 -1
- package/dist/calendar-info-icon_28.entry-e7bebd13.js +0 -2083
- package/dist/chevron-icon_3.entry-7bd4a4b5.cjs +0 -1
- package/dist/document-refresh-icon.entry-a0293858.cjs +0 -1
- package/dist/google-logo-icon_4.entry-60c0d39a.cjs +0 -1
- package/dist/google-logo-icon_4.entry-a0dc33da.js +0 -467
- package/dist/index-53420959-67beefed.js +0 -5
- package/dist/index-53420959-d3254a34.cjs +0 -1
- package/dist/index-e3e9b594.cjs +0 -42
- package/dist/input-component.entry-1195d579.js +0 -45
- package/dist/input-component.entry-2b6e44c4.cjs +0 -1
- package/dist/loading-icon.entry-027a2ad1.js +0 -15
- package/dist/nylas-booked-event-card_10.entry-84f64ba5.cjs +0 -1
- package/dist/nylas-scheduler-editor.entry-923b8566.cjs +0 -2
- package/dist/nylas-scheduling.entry-54f1a5e9.cjs +0 -1
- package/dist/nylas-threads-search.entry-462527fd.cjs +0 -1
- package/dist/play-icon_2.entry-1ea3fd6b.cjs +0 -1
- package/dist/play-icon_2.entry-d08adf17.js +0 -25
- package/dist/scheduler-config-store-4a50a03d-884e6df8.cjs +0 -1
- package/dist/scheduler-store-f02ce045-42e3647c.cjs +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-e3e9b594.cjs"),f=require("./register-component-a5a9ca5d-b68b6039.cjs"),h=require("./constants-f34b9c6e-b774916c.cjs"),w=require("./index-6d9eeb53-3049fc04.cjs");require("./index-53420959-d3254a34.cjs");require("react");require("react-dom");const X=':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif}sp-theme{height:inherit;display:flex;flex-direction:column;justify-content:space-between;align-items:center;font-family:var(--nylas-font-family)}.event-card-wrapper{display:flex;align-items:center;flex-direction:column;background-color:var(--nylas-base-0);color:var(--nylas-base-900);border-radius:var(--nylas-border-radius-3x);position:relative;margin-top:1rem;margin-bottom:2rem;width:424px;box-shadow:0px 1px 4px rgba(0, 0, 0, 0.1), 0px 3px 6px rgba(0, 0, 0, 0.06)}@media screen and (max-width: 768px){.event-card-wrapper{width:100%;border-radius:0px}}.calendar-icon{display:flex;align-items:center;justify-content:center;width:3rem;height:3rem;border-radius:50%;position:absolute;top:-1.25rem;left:50%;transform:translateX(-50%);background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);color:var(--nylas-base-700)}.booked-event-header{margin:1.5rem 4rem;overflow-wrap:anywhere;display:flex;align-items:center;flex-direction:column;font-size:1rem;font-weight:400}.booked-event-header h2{color:var(--nylas-base-600);margin-top:1.5rem;margin-bottom:0.25rem;font-size:1.125rem;font-weight:600}.booking-date-time,.booking-participants{padding:0 1rem;margin-top:1.5rem;margin-left:3rem;display:flex;flex-direction:column;justify-content:space-between;align-self:flex-start;position:relative}.booking-date-time svg,.booking-participants svg{color:var(--nylas-base-700);position:absolute;left:-10px}.booking-date-time .block,.booking-participants .block{display:block}.booking-date-time h3,.booking-participants h3{color:var(--nylas-base-600);margin:0;font-size:16px;font-weight:600;line-height:1.25rem;text-align:justify;margin-bottom:4px}.booking-date-time p,.booking-participants p{font-size:16px;margin:0;font-weight:400;text-align:justify;color:var(--nylas-base-800)}.booking-participants{margin-bottom:1.5rem}.booked-event-timezone{display:flex;color:var(--nylas-base-600);margin-bottom:1.5rem;gap:4px;margin:2rem;align-items:center;align-self:flex-end}.footer{padding:0.5rem;display:grid;grid-template-columns:1fr 1fr;gap:0.5rem;box-sizing:border-box;background-color:var(--nylas-base-25);width:100%;border-radius:0 0 var(--nylas-border-radius-2x) var(--nylas-border-radius-2x)}.footer.no-template-cols{grid-template-columns:1fr}.footer.no-footer{display:none}sp-button{background-color:var(--nylas-base-0);color:var(--nylas-base-700);border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-2x);font-size:16px;padding:8px;font-family:var(--nylas-font-family);font-weight:600;height:48px;line-height:24px}sp-button.cancel{color:var(--nylas-error)}sp-button.cancel:hover,sp-button.cancel:focus{border-color:var(--nylas-error)}sp-button.cancel:active{color:var(--nylas-error-pressed);border-color:var(--nylas-error-pressed)}sp-button.reschedule:hover,sp-button.reschedule:focus{border-color:var(--nylas-primary)}sp-button.reschedule:active{border-color:var(--nylas-base-600)}sp-divider{background-color:var(--nylas-base-200);height:1px}calendar-check-icon{display:flex;align-items:center;justify-content:center;height:100%}',J=X;var K=function(e,a,i,o){var s=arguments.length,n=s<3?a:o===null?o=Object.getOwnPropertyDescriptor(a,i):o,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,a,i,o);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(n=(s<3?r(n):s>3?r(a,i,n):r(a,i))||n);return s>3&&n&&Object.defineProperty(a,i,n),n},_=function(e,a){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,a)};const M=class{constructor(e){t.registerInstance(this,e),this.cancelBookingButtonClicked=t.createEvent(this,"cancelBookingButtonClicked",7),this.rescheduleButtonClicked=t.createEvent(this,"rescheduleButtonClicked",7),this.rescheduleBookedEventError=t.createEvent(this,"rescheduleBookedEventError",7),this.cancelBookedEventValidationError=t.createEvent(this,"cancelBookedEventValidationError",7),this.handleCancelBookingButtonClicked=()=>{var s;const a=new Date(this.selectedTimeslot.start_time),i=(s=this.configSettings)==null?void 0:s.scheduler.min_cancellation_notice,o=a.getTime()-i*60*1e3;a.getTime()<o?this.cancelBookedEventValidationError.emit({error:{title:"Cancellation Error",message:`You cannot cancel the booking within ${i} minutes of the event.`}}):this.cancelBookingButtonClicked.emit({bookingId:this.eventInfo.booking_id})},this.handleRescheduleButtonClicked=()=>{const a=i=>{this.rescheduleBookedEventError.emit(i)};this.rescheduleButtonClicked.emit({bookingId:this.eventInfo.booking_id,errorHandler:a})},this.getOrganizer=a=>a==null?void 0:a.organizer,this.getPaticipantType=a=>{switch(a){case"host":return"Host";case"you":return"You";default:return""}},this.eventInfo=void 0,this.rescheduleBookingId=void 0,this.bookingInfo=void 0,this.selectedTimezone=Intl.DateTimeFormat().resolvedOptions().timeZone,this.selectedTimeslot=void 0,this.configSettings=void 0}connectedCallback(){}disconnectedCallback(){}async componentWillLoad(){t.debug("[nylas-booked-event-card] Component will load")}async componentDidLoad(){t.debug("[nylas-booked-event-card] Component did load"),this.eventInfo||console.warn('[nylas-booked-event-card] "eventInfo" prop missing. Please provide the event info to display the event details in the booked event card component.'),this.bookingInfo||console.warn('[nylas-booked-event-card] "bookingInfo" prop missing. Please provide the booking info to display the guest details in the booked event card component.')}render(){var e,a,i,o,s,n,r,l,c,d,u,p,y,g,m,b,v,$,G,q,V;return t.h(t.Host,{key:"25f461e554d352c8b62341f77c84d61521a40472",part:"nbec"},t.h("sp-theme",{key:"fa7ae9d97b3c334d71a64076bd6c5787b48b124b",theme:"spectrum",color:"dark",scale:"medium"},t.h("div",{key:"731d9d89bfc2f63b8a1095ea671f39d1a99dc4a4",class:"booked-event-timezone"},t.h("globe-icon",{key:"e7a7d73d7c9461f34145ddf3e99bf5640b39ab56"}),h.TIMEZONE_MAP[this.selectedTimezone]),t.h("div",{key:"dbb07cac45a1528a2633119af6050a630f8df173",class:"event-card-wrapper",part:"nbec__card"},t.h("div",{key:"79b6b636707f8e867358da1b4340e6f0bfeb386e",class:"calendar-icon"},t.h("calendar-check-icon",{key:"a268b01ecbf64976dc61c9e3c66a67cade9d2227"})),t.h("div",{key:"52c4c97407582b05bfb87e1379930f7cf149c013",class:"booked-event-header"},t.h("h2",{key:"ed4631c601b4920b20c27d158063dcbef92084d4",slot:"card-title",part:"nbec__title"},"Booking ",this.rescheduleBookingId?"rescheduled":"confirmed","!"),t.h("div",{key:"f5e93f73c4828764cb7e27cc3d5ab2b761e66fdc",part:"nbec__description"},((e=this.getOrganizer(this.eventInfo))==null?void 0:e.name)||((a=this.getOrganizer(this.eventInfo))==null?void 0:a.email)," & ",((o=(i=this.bookingInfo)==null?void 0:i.primaryParticipant)==null?void 0:o.name)||((n=(s=this.bookingInfo)==null?void 0:s.primaryParticipant)==null?void 0:n.email))),t.h("sp-divider",{key:"d9f14eeb24c4935f131edebb3102ffd69d2bde43"}),t.h("div",{key:"57f6f7877162eb8de8898d6523dac452b3c841e9",class:"booking-date-time"},t.h("checkmark-circle-icon",{key:"5bd672ae7c70b0102d6a14e2761b8ecc222ce488"}),t.h("h3",{key:"5e8ca582a26a51f790ca111648381a10f8ef917c"},"Booking date and time"),t.h("p",{key:"0b98f73c94add678003f63cd1e59352f7acd29b3"},new Date((r=this.selectedTimeslot)==null?void 0:r.start_time).toLocaleDateString(void 0,{dateStyle:"full"})," ",t.h("br",{key:"cc2a50917760651ca2e015fa22f264740b545a58"}),new Date((l=this.selectedTimeslot)==null?void 0:l.start_time).toLocaleTimeString(void 0,{timeStyle:"short"})," -"," ",new Date((c=this.selectedTimeslot)==null?void 0:c.end_time).toLocaleTimeString(void 0,{timeStyle:"short"}))),t.h("div",{key:"5ccf1dbc6002c9eaf60b3bd9211e590ab9135d68",class:"booking-participants"}),t.h("sp-divider",{key:"7ff9b9f4fa4bfc19da47d358ddda325b13b1a465"}),t.h("div",{key:"2c3d69854b255864cca3782a9ad87175a18d8cf9",class:{footer:!0,"no-footer":((u=(d=this.configSettings)==null?void 0:d.scheduler)==null?void 0:u.hide_cancellation_options)&&((y=(p=this.configSettings)==null?void 0:p.scheduler)==null?void 0:y.hide_rescheduling_options),"no-template-cols":((m=(g=this.configSettings)==null?void 0:g.scheduler)==null?void 0:m.hide_cancellation_options)||((v=(b=this.configSettings)==null?void 0:b.scheduler)==null?void 0:v.hide_rescheduling_options)}},!((G=($=this.configSettings)==null?void 0:$.scheduler)!=null&&G.hide_cancellation_options)&&t.h("sp-button",{variant:"secondary",treatment:"outline",class:"cancel",onClick:this.handleCancelBookingButtonClicked,part:"nbec__button-outline nbec__cancel-cta"},"Cancel booking"),!((V=(q=this.configSettings)==null?void 0:q.scheduler)!=null&&V.hide_rescheduling_options)&&t.h("sp-button",{variant:"secondary",treatment:"outline",class:"reschedule",onClick:this.handleRescheduleButtonClicked,part:"nbec__button-outline nbec__reschedule-cta"},"Reschedule")))))}};K([f.RegisterComponent({name:"nylas-booked-event-card",stateToProps:new Map([["scheduler.bookingInfo","bookingInfo"],["scheduler.rescheduleBookingId","rescheduleBookingId"],["scheduler.selectedTimezone","selectedTimezone"],["scheduler.selectedTimeslot","selectedTimeslot"],["scheduler.configSettings","configSettings"]]),eventToProps:{cancelBookingButtonClicked:async(e,a)=>{a.scheduler.setCancel(e.detail.bookingId)},rescheduleButtonClicked:async(e,a)=>{const i=await a.scheduler.setReschedule(e.detail.bookingId),{errorHandler:o}=e.detail;o&&(!i||"error"in i)&&o(i)}},fireRegisterEvent:!0}),_("design:type",Function),_("design:paramtypes",[]),_("design:returntype",void 0)],M.prototype,"render",null);M.style=J;const Q=':host{display:block;height:100%;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif}.nylas-booking-form{width:100%;padding:1.5rem;box-sizing:border-box;height:450px;overflow-y:auto;height:100%}form{height:100%;display:flex;flex-direction:column;justify-content:space-between;align-items:center}sp-textfield{--spectrum-corner-radius-100:var(--nylas-border-radius-2x);--spectrum-textfield-border-color:var(--nylas-base-300);position:relative;width:100%;height:48px;margin-bottom:16px;color:var(--nylas-base-500)}.cta{width:100%;display:flex;flex-direction:row;align-items:flex-start;justify-content:space-between;gap:0.5rem;padding:14px;box-sizing:border-box;border-top:1px solid var(--nylas-base-200)}@media screen and (max-width: 768px){.cta{flex-direction:column-reverse}}sp-button{background-color:transparent;color:var(--nylas-base-800);border-radius:var(--nylas-border-radius-2x);--button-width:50%;font-family:var(--nylas-font-family);font-size:16px;font-weight:600;border:none;height:48px;padding:14px}@media screen and (max-width: 768px){sp-button{--button-width:100%}}sp-button:hover,sp-button:focus{background-color:var(--nylas-base-100);color:var(--nylas-primary);border-radius:var(--nylas-border-radius-2x)}sp-button:active{background-color:var(--nylas-base-200);color:var(--nylas-base-800)}sp-button.back{width:var(--button-width);background-color:transparent;color:var(--nylas-base-700);outline:1px solid var(--nylas-base-300)}sp-button.back:hover,sp-button.back:focus{outline-color:var(--nylas-primary)}sp-button.back:active{outline:2px solid var(--nylas-base-600)}sp-button.book{width:var(--button-width);background-color:var(--nylas-primary);color:var(--nylas-base-0)}sp-button.book:hover,sp-button.book:focus{background-color:var(--nylas-base-600)}sp-button.book:active{background-color:var(--nylas-base-800)}.input-wrapper{width:100%;display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin-bottom:1rem}.input-wrapper input::placeholder{color:var(--nylas-base-300)}.input-wrapper label,.input-wrapper input{font-family:var(--nylas-font-family);font-size:16px}.input-wrapper .help-text{margin:0;color:var(--nylas-error)}.button-wrapper{width:100%;align-items:flex-start;height:max-content;position:relative}.button-content{display:flex;gap:4px;align-items:center}sp-infield-button{--spectrum-infield-button-background-color:transparent;--spectrum-infield-button-background-color-hover:transparent;--spectrum-infield-button-background-color-active:transparent;--spectrum-infield-button-border-color:transparent;--spectrum-infield-button-border-width:1px;--spectrum-infield-button-border-radius:0;color:var(--nylas-base-600);background:transparent;border:none;outline:1px solid var(--nylas-base-300);border-radius:0 var(--nylas-border-radius-2x) var(--nylas-border-radius-2x) 0;height:52px;width:52px;display:flex;position:absolute;right:0;align-items:center;justify-content:center;cursor:pointer}sp-infield-button sp-icon-cross300{color:var(--nylas-base-600)}sp-infield-button.error{border-width:2px;border-color:var(--nylas-error)}input[type=text],input[type=email]{display:flex;height:48px;padding-left:16px;align-items:center;gap:8px;align-self:stretch;border-radius:var(--nylas-border-radius-2x);border:1px solid var(--nylas-base-300);background:var(--nylas-base-0);width:-webkit-fill-available;color:var(--nylas-base-900);font-size:16px;font-style:normal;font-weight:400;line-height:150%}input[type=text]:focus,input[type=email]:focus{outline-color:var(--nylas-primary)}input[type=text].error,input[type=email].error{border-radius:var(--nylas-border-radius-2x);font-weight:600;border-color:var(--nylas-error);border-width:2px}input[type=text].error::placeholder,input[type=email].error::placeholder{font-weight:400}input[type=text]::placeholder,input[type=email]::placeholder{color:var(--nylas-base-300)}input[type=text].guest-email,input[type=email].guest-email{color:var(--nylas-base-900);padding-right:52px}label{display:flex;color:var(--nylas-base-800, #293056);font-size:14px;font-style:normal;font-weight:400;line-height:150%}label.error{color:var(--nylas-error)}label span.required{color:var(--nylas-error);padding:0 0.25rem}button-component.remove-guest{position:absolute;height:51px;right:0}button-component.remove-guest.error button{border-color:var(--nylas-error)}button-component.remove-guest button{height:inherit;border-top-left-radius:initial;border-bottom-left-radius:initial;border:none !important;border-left:1px solid var(--nylas-base-300) !important}button-component.remove-guest button:hover,button-component.remove-guest button:focus{outline:1px solid var(--nylas-primary) !important;color:var(--nylas-primary)}.guest-email-input{position:relative;display:flex;width:100%}',ee=Q;var te=function(e,a,i,o){var s=arguments.length,n=s<3?a:o===null?o=Object.getOwnPropertyDescriptor(a,i):o,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,a,i,o);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(n=(s<3?r(n):s>3?r(a,i,n):r(a,i))||n);return s>3&&n&&Object.defineProperty(a,i,n),n},E=function(e,a){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,a)};const k=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,F=class{constructor(e){t.registerInstance(this,e),this.nameChanged=t.createEvent(this,"nameChanged",7),this.emailChanged=t.createEvent(this,"emailChanged",7),this.backButtonClicked=t.createEvent(this,"backButtonClicked",7),this.detailsConfirmed=t.createEvent(this,"detailsConfirmed",7),this.bookingFormError=t.createEvent(this,"bookingFormError",7),this.bookingFormSubmitted=t.createEvent(this,"bookingFormSubmitted",7),this.handleGuestChange=(a,i)=>{this.resetGuestEmailError(a);const o=[...this.guestEmails];o[a]=w.sanitizeHtml$1(i),this.guestEmails=[...o]},this.handleGuestBlur=(a,i)=>{if(this.resetGuestEmailError(a),i===""){this.guestEmailErrors[a]="Email is required";return}if(!k.test(i)){this.guestEmailErrors[a]="Enter a valid email address";return}this.handleGuestChange(a,i)},this.addGuestButtonClickedHandler=a=>{a.preventDefault(),this.guestEmails=[...this.guestEmails,""]},this.removeGuestButtonClickHandler=(a,i)=>{a.preventDefault(),this.resetGuestEmailError(i);const o=[...this.guestEmails];o.splice(i,1),this.guestEmails=[...o]},this.handleBackButtonClicked=()=>{this.backButtonClicked.emit()},this.bookButtonClickedHandler=async a=>{var l,c,d,u,p,y,g;if(a.preventDefault(),this.bookingFormSubmitted.emit().defaultPrevented)return;t.debug("nylas-booking-form","bookButtonClickedHandler",this.bookingInfo);const o=this.name||((c=(l=this.bookingInfo)==null?void 0:l.primaryParticipant)==null?void 0:c.name),s=this.email||((u=(d=this.bookingInfo)==null?void 0:d.primaryParticipant)==null?void 0:u.email);if(!o||o===""){this.isNameValid=!1,this.validationError.name="Name is required",this.bookingFormError.emit({title:"Booking form error",description:"Name is required"});return}if(!s||s===""){this.isEmailValid=!1,this.validationError.email="Email is required",this.bookingFormError.emit({title:"Booking form error",description:"Email is required"});return}if(!k.test(s)){this.isEmailValid=!1,this.validationError.email="Enter a valid email address",this.bookingFormError.emit({title:"Booking form error",description:"Invalid email"});return}let n=[];if(this.guestEmails.length>0){let m=!1;if(this.guestEmails.forEach((b,v)=>{b===""?(m=!0,this.guestEmailErrors={...this.guestEmailErrors,[v]:"Email is required"}):k.test(b)||(m=!0,this.guestEmailErrors={...this.guestEmailErrors,[v]:"Enter a valid email address"})}),m){this.bookingFormError.emit({title:"Booking form error",description:"Invalid guest email"});return}n=this.guestEmails.map(b=>({name:b.trim(),email:b.trim()}))}else(p=this.bookingInfo)!=null&&p.guests&&(n=(y=this.bookingInfo)==null?void 0:y.guests);const r=((g=this.bookingInfo)==null?void 0:g.additionalFields)||[];this.detailsConfirmed.emit({primaryParticipant:{name:o,email:s},guests:n,additionalFields:[...r,...this.additionalFields]})},this.updateAdditionalFields=(a,i,o)=>{const s=this.additionalFields.findIndex(n=>n.name===a);s>-1?this.additionalFields[s].value=i:this.additionalFields.push({name:a,value:i,type:o||"text"})},this.isLoading=void 0,this.bookingInfo=void 0,this.eventInfo=void 0,this.configSettings=void 0,this.name="",this.email="",this.guestEmails=[],this.guestEmailErrors={},this.isNameValid=!0,this.isEmailValid=!0,this.additionalFields=[],this.validationError={name:"",email:""}}connectedCallback(){}disconnectedCallback(){}componentWillLoad(){var e,a,i;t.debug("nylas-booking-form","componentWillLoad",this.bookingInfo),this.bookingInfo&&((e=this.bookingInfo)!=null&&e.primaryParticipant)&&(this.name=(a=this.bookingInfo.primaryParticipant)==null?void 0:a.name,this.email=(i=this.bookingInfo.primaryParticipant)==null?void 0:i.email)}bookingInfoChangedHandler(e){e&&e.primaryParticipant&&(this.name=e.primaryParticipant.name,this.email=e.primaryParticipant.email)}changeName(e){this.isNameValid=!0,this.validationError.name="",this.name=w.sanitizeHtml$1(e),this.nameChanged.emit(e)}changeEmail(e){this.isEmailValid=!0,this.validationError.email="",this.email=w.sanitizeHtml$1(e),this.emailChanged.emit(e)}resetGuestEmailError(e){const a={...this.guestEmailErrors};delete a[e],this.guestEmailErrors={...a}}nylasFormInputChangedHandler(e){switch(e.detail.name){case"name":this.changeName(e.detail.value);break;case"email":this.changeEmail(e.detail.value);break;default:if(e.detail.error){this.bookingFormError.emit({title:"Booking form error",description:e.detail.error});return}this.updateAdditionalFields(e.detail.label,e.detail.value,e.detail.type);break}e.detail.name==="name"?this.changeName(e.detail.value):e.detail.name==="email"&&this.changeEmail(e.detail.value)}selectOptionChangedHandler(e){if(e.detail.error){this.bookingFormError.emit({title:"Booking form error",description:e.detail.error});return}this.updateAdditionalFields(e.detail.label,e.detail.value,"dropdown")}switchToggledHandler(e){this.updateAdditionalFields(e.detail.label,e.detail.checked?"true":"false","checkbox")}checkboxToggledHandler(e){this.updateAdditionalFields(e.detail.label,e.detail.checked?"true":"false","checkbox")}render(){var e,a,i,o,s,n;return t.h(t.Host,{key:"1b81fd4591cd90c85a578a8d957ed561e457cba5"},t.h("form",{key:"4a4fef983332d1752ccf44823620ec2b906bf71e",onSubmit:r=>this.bookButtonClickedHandler(r),noValidate:!0},t.h("div",{key:"e55ebf5bb6fbb5175e6175d06ce0e0a5266962cf",class:"nylas-booking-form"},t.h("div",{key:"d50d5fdbc7b68b3c54098a6dde600ed52c607eed",class:"input-wrapper"},t.h("input-component",{key:"a299cb5d2043e5fedd6f5f66889d7640e74b8b55",label:"Name",name:"name",id:"name",defaultValue:((a=(e=this.bookingInfo)==null?void 0:e.primaryParticipant)==null?void 0:a.name)||this.name,placeholder:"Enter your name",type:"text",required:!0,part:"nbf__input-textfield"})),t.h("div",{key:"0d095468473009d67120d668f5e961ca4d90c16d",class:"input-wrapper"},t.h("input-component",{key:"e81345e3aca7fa9cd0a90be50f81cfa544a23336",label:"Email",name:"email",id:"email",pattern:k,defaultValue:((o=(i=this.bookingInfo)==null?void 0:i.primaryParticipant)==null?void 0:o.email)||this.email,placeholder:"Enter your email",type:"email",required:!0,part:"nbf__input-textfield"})),((n=(s=this.configSettings)==null?void 0:s.scheduler)==null?void 0:n.hide_additional_guests)!==!0&&t.h("div",{class:"input-wrapper"},this.guestEmails.map((r,l)=>t.h("div",{class:"input-wrapper button-wrapper"},t.h("label",{class:{error:!!this.guestEmailErrors[l]}},"Guest email"),t.h("div",{class:"guest-email-input"},t.h("input",{type:"email",id:`guest-email-${l}`,maxLength:100,class:{"guest-email":!0,error:!!this.guestEmailErrors[l]},placeholder:"Enter guest email",value:r,"data-index":l,part:"nbf__input-textfield",onBlur:c=>{var d;return this.handleGuestBlur(l,(d=c.target)==null?void 0:d.value)},onInput:c=>{var d;return this.handleGuestChange(l,(d=c.target)==null?void 0:d.value)}}),t.h("button-component",{variant:"basic",onClick:c=>this.removeGuestButtonClickHandler(c,l),class:{"remove-guest":!0,error:!!this.guestEmailErrors[l]}},t.h("close-icon",null))),t.h("p",{class:"help-text"},this.guestEmailErrors[l]))),t.h("button-component",{class:"add-guest",variant:"invisible",part:"nbf__button-ghost",onClick:r=>this.addGuestButtonClickedHandler(r)},t.h("div",{class:"button-content"},t.h("add-circle-icon",{slot:"icon"}),"Add ",this.guestEmails.length>0?"another ":"","guest"))),t.h("slot",{key:"f47bffdf6a15943c78d4bb75051d0f6704afd623",name:"custom-booking-form"})),t.h("div",{key:"12631d6648d7ebdc9e6714a54690486d53c8c623",class:"cta"},t.h("sp-button",{key:"a72caa2eb6b5d95ee83600aa37e89730bfd68fdb",treatment:"outline",variant:"secondary",class:"back",part:"nbf__button-outline",onClick:this.handleBackButtonClicked},t.h("slot",{key:"be107ab400cb5802c6153217cde54b75ccede466",name:"booking-form-back-label"},"Back")),t.h("sp-button",{key:"d6f322389050d4cbbb1aada135b27b6bc4d34d6d",variant:"primary",class:"book",part:"nbf__button-primary",type:"submit"},this.isLoading&&t.h("loading-icon",{slot:"icon"}),t.h("slot",{key:"17ee459bee19ba620505e9931ccd4a485f530ecc",name:"booking-form-book-label"},"Book now")))))}get host(){return t.getElement(this)}static get watchers(){return{bookingInfo:["bookingInfoChangedHandler"]}}};te([f.RegisterComponent({name:"nylas-booking-form",stateToProps:new Map([["scheduler.isLoading","isLoading"],["scheduler.bookingInfo","bookingInfo"],["scheduler.eventInfo","eventInfo"],["scheduler.configSettings","configSettings"]]),eventToProps:{backButtonClicked:async(e,a)=>{a.scheduler.toggleAdditionalData(!1)},nameChanged:async(e,a)=>{a.scheduler.setParticipantName(e.detail)},emailChanged:async(e,a)=>{a.scheduler.setParticipantEmail(e.detail)}},fireRegisterEvent:!0}),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",void 0)],F.prototype,"render",null);F.style=ee;const ae=':host{display:block;width:400px;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif}sp-theme{height:inherit;display:flex;flex-direction:column;justify-content:space-between;align-items:center;font-family:var(--nylas-font-family)}.nylas-cancel-booking-form{display:flex;align-items:center;flex-direction:column;background-color:var(--nylas-base-0);color:var(--nylas-base-800);border-radius:var(--nylas-border-radius-2x);padding:1.5rem;position:relative;box-shadow:0px 1px 4px rgba(0, 0, 0, 0.1), 0px 3px 6px rgba(0, 0, 0, 0.06)}.nylas-cancel-booking-form__title{font-size:18px;font-weight:600;margin-bottom:0;color:var(--nylas-base-900)}.nylas-cancel-booking-form__description{font-size:1rem;font-style:normal;font-weight:400;line-height:140%;color:var(--nylas-base-600)}.nylas-cancel-booking-form__calendar-icon{width:3rem;height:3rem;border-radius:50%;position:absolute;top:-1.25rem;left:50%;transform:translateX(-50%);background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200)}calendar-cancel-icon{display:flex;align-items:center;justify-content:center;height:100%}sp-button{background-color:var(--nylas-base-0);color:var(--nylas-base-700);border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-2x);font-size:16px;font-weight:600;width:100%;height:48px;padding:8px;line-height:24px;font-family:var(--nylas-font-family)}sp-button.cancel{margin-top:1.25rem;background-color:var(--nylas-primary);color:var(--nylas-base-0)}sp-button.cancel:hover,sp-button.cancel:focus{background-color:var(--nylas-base-600)}sp-button.cancel:active{background-color:var(--nylas-base-800)}sp-button.back{margin-top:0.5rem}sp-button.back:hover,sp-button.back:focus{border-color:var(--nylas-primary)}sp-button.back:active{border-color:var(--nylas-base-600)}sp-field-label{margin-top:1rem;display:flex;color:var(--nylas-base-800);font-size:14px}sp-field-label.error{color:var(--nylas-error)}sp-field-label span.required{color:var(--nylas-error)}sp-textfield{--spectrum-textfield-border-color:var(--nylas-base-300);--spectrum-textfield-icon-color-invalid:var(--nylas-error);position:relative;width:100%;height:48px;margin-bottom:16px;background-color:var(--nylas-base-0);color:var(--nylas-base-500)}sp-textfield.error{--spectrum-textfield-border-color:var(--nylas-error)}sp-help-text{margin:0.25rem 0 1rem 0;color:var(--nylas-error)}',ne=ae;var ie=function(e,a,i,o){var s=arguments.length,n=s<3?a:o===null?o=Object.getOwnPropertyDescriptor(a,i):o,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,a,i,o);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(n=(s<3?r(n):s>3?r(a,i,n):r(a,i))||n);return s>3&&n&&Object.defineProperty(a,i,n),n},D=function(e,a){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,a)};const j=class{constructor(e){var a,i;t.registerInstance(this,e),this.goBackButtonClicked=t.createEvent(this,"goBackButtonClicked",7),this.cancelBookingFormSubmitted=t.createEvent(this,"cancelBookingFormSubmitted",7),this.cancelBookedEventError=t.createEvent(this,"cancelBookedEventError",7),this.cancelBookingFormError=t.createEvent(this,"cancelBookingFormError",7),this.handleGoBackClicked=()=>{this.goBackButtonClicked.emit()},this.handleSubmitCancelBooking=o=>{if(o.preventDefault(),!this.cancellationReason){this.cancellationError="Please provide a reason for cancellation.",this.cancelBookingFormError.emit({title:"Cancel booking form error",description:"Please provide a reason for cancellation."});return}t.debug(`[nylas-cancel-booking-form] Cancel booking form submitted with reason: ${this.cancellationReason}`);const s=n=>{this.cancelBookedEventError.emit(n)};this.cancelBookingFormSubmitted.emit({bookingId:this.cancelBookingId,reason:this.cancellationReason,errorHandler:s})},this.handleOnChangeCancellationReason=o=>{this.cancellationError="",this.cancellationReason=o.target.value},this.cancelBookingId=void 0,this.configSettings=void 0,this.cancellationReason="",this.cancellationError="",this.cancellationPolicy=((i=(a=this.configSettings)==null?void 0:a.scheduler)==null?void 0:i.cancellation_policy)||"Your current timeslot will become available to others."}configSettingsChangedHandler(e){var a;this.cancellationPolicy=((a=e==null?void 0:e.scheduler)==null?void 0:a.cancellation_policy)||"Your current timeslot will become available to others."}connectedCallback(){t.debug("[nylas-cancel-booking-form] Component connected")}async componentWillLoad(){t.debug("[nylas-cancel-booking-form] Component will load")}async componentDidLoad(){t.debug("[nylas-cancel-booking-form] Component did load"),this.cancelBookingId||console.warn('[nylas-cancel-booking-form] No booking ID provided, "cancelBookingId" prop is required.')}disconnectedCallback(){t.debug("[nylas-cancel-booking-form] Component disconnected")}render(){return t.h(t.Host,{key:"83015809da357a47d70c5bae845c8608924b6a31",part:"ncec"},t.h("sp-theme",{key:"11d3b28a88081d5ecccfbb78ee6347a7856899e3",theme:"spectrum",scale:"medium"},t.h("div",{key:"5d2750f253c1aff61c1d973529ce2f7fa65c4206",class:"nylas-cancel-booking-form",part:"ncec__card"},t.h("div",{key:"36a8dd00a5eda62f2f8f9740bf447f0b50e81b9e",class:"nylas-cancel-booking-form__calendar-icon",part:"ncec__icon"},t.h("calendar-cancel-icon",{key:"7bfaf1ffaa9a3bb288bc0e3f11c8c9ed7a4d2c9a"})),t.h("h3",{key:"74fff12d4aa0311d817348a4694042d2242f30cd",class:"nylas-cancel-booking-form__title",part:"ncec__title"},"Cancel booking?"),t.h("div",{key:"647a02657fe9570c87b14ef7de0cc0fc713efb21",class:"nylas-cancel-booking-form__description",part:"ncec__description"},this.cancellationPolicy),t.h("form",{key:"bb680b4a5a7203d44d08529b0d8b3224b51c2986",onSubmit:this.handleSubmitCancelBooking},t.h("sp-field-label",{key:"401994e31c7f7bf65b8403a42b14a56e928d92f3",for:"cancel-reason",class:this.cancellationError?"error":""},"Reason for cancellation ",t.h("span",{key:"361907af2362f4fd09af7638c82de7320efe0072",class:"required"},"*")),t.h("sp-textfield",{key:"d7e672672f0a7250104080f69f4e96de9321c537",id:"cancel-reason",class:this.cancellationError?"error":"",part:"ncec__reason-textarea",multiline:!0,value:this.cancellationReason,onInput:this.handleOnChangeCancellationReason,onFocus:this.handleOnChangeCancellationReason,invalid:!!this.cancellationError},t.h("sp-help-text",{key:"d3bcfae8ae55ec910005c128f24d74ed34f1bf48",slot:"negative-help-text"},this.cancellationError)),t.h("sp-button",{key:"23efceafbfcb073b0808f65ae110f31bcbfb7722",variant:"primary",class:"cancel",type:"submit",part:"ncec__button-cta"},"Cancel booking"),t.h("sp-button",{key:"7030276dae50deab5549a64a3def7b4cb783e8d5",variant:"secondary",class:"back",treatment:"outline",part:"ncec__button-outline",onClick:this.handleGoBackClicked},"Go back")))))}static get watchers(){return{configSettings:["configSettingsChangedHandler"]}}};ie([f.RegisterComponent({name:"nylas-cancel-booking-form",stateToProps:new Map([["scheduler.configSettings","configSettings"]]),eventToProps:{cancelBookingFormSubmitted:async(e,a)=>{const i=await a.scheduler.cancelBooking(e.detail.bookingId,e.detail.reason),{errorHandler:o}=e.detail;o&&(!i||"error"in i)&&o(i)}},fireRegisterEvent:!0}),D("design:type",Function),D("design:paramtypes",[]),D("design:returntype",void 0)],j.prototype,"render",null);j.style=ne;const oe=':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif}sp-theme{height:inherit;display:flex;flex-direction:column;justify-content:space-between;align-items:center;font-family:var(--nylas-font-family)}.nylas-cancelled-event-card{display:flex;align-items:center;flex-direction:column;width:400px;background-color:var(--nylas-base-0);color:var(--nylas-base-800);border-radius:var(--nylas-border-radius-2x);padding:1.5rem;position:relative;box-shadow:0px 1px 4px rgba(0, 0, 0, 0.1), 0px 3px 6px rgba(0, 0, 0, 0.06)}@media screen and (max-width: 768px){.nylas-cancelled-event-card{width:inherit}}.nylas-cancelled-event-card__title{font-size:18px;font-weight:600;line-height:24px;color:var(--nylas-base-900);text-align:center}.nylas-cancelled-event-description{font-size:16px;font-weight:500;color:var(--nylas-base-600)}.nylas-cancelled-event-card__calendar-icon{width:3rem;height:3rem;border-radius:50%;position:absolute;top:-1.25rem;left:50%;transform:translateX(-50%);background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200)}.nylas-cancelled-event-card__cta{width:100%;display:flex;flex-direction:row;align-items:flex-start;margin-top:1rem}calendar-cancel-icon{display:flex;align-items:center;justify-content:center;height:100%}sp-button{background-color:var(--nylas-base-0);color:var(--nylas-base-700);border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-2x);font-size:1rem;height:48px;padding:8px;line-height:24px;width:100%}sp-button:hover,sp-button:focus{border-color:var(--nylas-primary)}sp-button:active{border-color:var(--nylas-base-600)}',se=oe;var re=function(e,a,i,o){var s=arguments.length,n=s<3?a:o===null?o=Object.getOwnPropertyDescriptor(a,i):o,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,a,i,o);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(n=(s<3?r(n):s>3?r(a,i,n):r(a,i))||n);return s>3&&n&&Object.defineProperty(a,i,n),n},T=function(e,a){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,a)};const N=class{constructor(e){t.registerInstance(this,e),this.closeCancelEventCardClicked=t.createEvent(this,"closeCancelEventCardClicked",7),this.cancelledEventCardError=t.createEvent(this,"cancelledEventCardError",7),this.handleCloseClicked=()=>{this.isClosing=!0;const a=i=>{this.cancelledEventCardError.emit(i),this.isClosing=!1};this.closeCancelEventCardClicked.emit({errorHandler:a})},this.cancelledEventInfo=void 0,this.isClosing=!1,this.configSettings=void 0}connectedCallback(){t.debug("[nylas-cancelled-event-card] Component connected")}async componentWillLoad(){t.debug("[nylas-cancelled-event-card] Component will load")}async componentDidLoad(){t.debug("[nylas-cancelled-event-card] Component did load"),this.cancelledEventInfo||console.warn('[nylas-cancelled-event-card] No cancelled event info provided, "cancelledEventInfo" prop is required.')}disconnectedCallback(){t.debug("[nylas-cancelled-event-card] Component disconnected")}render(){var e,a;return t.h(t.Host,{key:"89bfb6419aea7fffc32726e4db26642ca810b3a4",part:"ncec"},t.h("sp-theme",{key:"265e08ab9c6d4c7c7071353a35e2a8e69bd3875e",theme:"spectrum",color:"dark",scale:"medium"},t.h("div",{key:"bd23802e8cd5bf923ed43f223eac30041ead9a2e",class:"nylas-cancelled-event-card",part:"ncec__card"},t.h("div",{key:"270d9e2a65ee1a3a7d34aaa99bf1059b891929ae",class:"nylas-cancelled-event-card__calendar-icon",part:"ncec__icon"},t.h("calendar-cancel-icon",{key:"e04e9bf8f7278265160c3a58c0a37c880faed0cc"})),t.h("h3",{key:"046647bd93284e280d5fb62f9488b6ed5ed9dea2",class:"nylas-cancelled-event-card__title",part:"ncec__title"},"Your booking has been cancelled successfully!"),t.h("div",{key:"f85c31f7718fe5266b2d175afff46c7b63495c11",class:"nylas-cancelled-event-card__description",part:"ncec__description"},"A cancellation email has been sent to ",((a=(e=this.configSettings)==null?void 0:e.organizer)==null?void 0:a.name)||"the participants","."),t.h("div",{key:"aa36cf4bbcb432334903a0b9ba2782ecf6abbe4c",class:"nylas-cancelled-event-card__cta"},t.h("sp-button",{key:"65009ac918324e109b0b5a52331bea5a9b8c1a14",variant:"secondary",treatment:"outline",disabled:this.isClosing,part:"ncec__button-outline",onClick:this.handleCloseClicked},this.isClosing?"Closing...":"Close")))))}};re([f.RegisterComponent({name:"nylas-cancelled-event-card",stateToProps:new Map([["scheduler.configSettings","configSettings"]]),eventToProps:{closeCancelEventCardClicked:async(e,a)=>{const i=await a.scheduler.resetCancel(),{errorHandler:o}=e.detail;o&&(!i||"error"in i)&&o(i)}},fireRegisterEvent:!0}),T("design:type",Function),T("design:paramtypes",[]),T("design:returntype",void 0)],N.prototype,"render",null);N.style=se;const S=new Date,z=new Date;function C(e,a,i,o){function s(n){return e(n=arguments.length===0?new Date:new Date(+n)),n}return s.floor=n=>(e(n=new Date(+n)),n),s.ceil=n=>(e(n=new Date(n-1)),a(n,1),e(n),n),s.round=n=>{const r=s(n),l=s.ceil(n);return n-r<l-n?r:l},s.offset=(n,r)=>(a(n=new Date(+n),r==null?1:Math.floor(r)),n),s.range=(n,r,l)=>{const c=[];if(n=s.ceil(n),l=l==null?1:Math.floor(l),!(n<r)||!(l>0))return c;let d;do c.push(d=new Date(+n)),a(n,l),e(n);while(d<n&&n<r);return c},s.filter=n=>C(r=>{if(r>=r)for(;e(r),!n(r);)r.setTime(r-1)},(r,l)=>{if(r>=r)if(l<0)for(;++l<=0;)for(;a(r,-1),!n(r););else for(;--l>=0;)for(;a(r,1),!n(r););}),i&&(s.count=(n,r)=>(S.setTime(+n),z.setTime(+r),e(S),e(z),Math.floor(i(S,z))),s.every=n=>(n=Math.floor(n),!isFinite(n)||!(n>0)?null:n>1?s.filter(o?r=>o(r)%n===0:r=>s.count(0,r)%n===0):s)),s}const le=1e3,U=le*60,ce=U*60,x=ce*24,B=C(e=>e.setHours(0,0,0,0),(e,a)=>e.setDate(e.getDate()+a),(e,a)=>(a-e-(a.getTimezoneOffset()-e.getTimezoneOffset())*U)/x,e=>e.getDate()-1);C(e=>{e.setUTCHours(0,0,0,0)},(e,a)=>{e.setUTCDate(e.getUTCDate()+a)},(e,a)=>(a-e)/x,e=>e.getUTCDate()-1);C(e=>{e.setUTCHours(0,0,0,0)},(e,a)=>{e.setUTCDate(e.getUTCDate()+a)},(e,a)=>(a-e)/x,e=>Math.floor(e/x));const de=':host{display:block;min-height:444px;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif}@media screen and (max-width: 768px){:host{min-height:auto}}.nylas-date-picker{display:flex;gap:1rem;flex-direction:column}.header{margin:0 0.5rem;height:48px}.header h2{font-size:1.3125rem;font-weight:400;line-height:1rem;color:var(--nylas-base-800)}.header h2 strong{font-weight:600}.title{margin:0 -1.25rem;display:flex;flex-direction:column;padding:0 1.5rem;gap:0.5rem;border-bottom:1px solid var(--nylas-base-200);font-family:var(--nylas-font-family)}.title h1{margin-bottom:0;font-size:18px;line-height:20px;font-weight:600;display:flex;gap:0.5rem;align-items:center}.title p{margin-top:0;font-size:16px;display:flex;gap:0.5rem;align-items:center}@keyframes pulsate{0%{background-color:var(--nylas-base-50)}50%{background-color:var(--nylas-base-100)}100%{background-color:var(--nylas-base-50)}}.dates{display:grid;justify-items:center;grid-template-columns:repeat(7, 1fr);gap:0.5rem;margin-bottom:24px}.dates .date{position:relative;display:flex;flex-direction:row;justify-content:center;align-items:center;height:48px;width:48px;min-width:2rem;min-height:2rem;cursor:pointer;border-radius:var(--nylas-border-radius-2x);font-size:16px;font-weight:600;font-family:inherit;color:var(--nylas-base-text);background-color:var(--nylas-base-100);cursor:pointer;border:none}@media screen and (max-width: 412px){.dates .date{width:38px;height:38px;min-width:none}}.dates .date:hover:not(:disabled){box-shadow:0 0 0 2px var(--nylas-base-500) inset}.dates .date.date.current-month{color:var(--nylas-base-800)}.dates .date.date.selected{background-color:var(--nylas-primary);color:var(--nylas-base-0);font-weight:700}.dates .date.date.day-skeleton{color:var(--nylas-base-300)}.dates .date:disabled{color:var(--nylas-base-300);background-color:transparent;font-weight:400;cursor:not-allowed}.dates .day{font-size:12px;color:var(--nylas-base-800);font-weight:600;letter-spacing:0.5px;height:32px;display:flex;align-items:center}@media screen and (max-width: 768px){.dates .day{font-size:14px}}.dates .date.day-skeleton{height:48px;width:48px;border-radius:var(--nylas-border-radius-2x);animation:pulsate 1.5s infinite ease-in-out;background-color:var(--nylas-base-50)}@media screen and (max-width: 412px){.dates .date.day-skeleton{width:38px;height:38px;min-width:none}}.dates .date.current-day::after{content:"";position:absolute;bottom:6px;left:50%;transform:translateX(-50%);width:6px;height:6px;border-radius:50%;background-color:var(--nylas-base-500)}.dates .date.current-day.selected::after{background-color:var(--nylas-base-100)}.pagination{display:flex;flex-direction:row;justify-content:space-between;align-items:center;min-width:92px}.pagination .chevron-right{transform:rotate(180deg)}.pagination .button{display:flex;flex-direction:row;justify-content:center;align-items:center;height:3vh;width:3vh;min-width:3em;min-height:3em;cursor:pointer;border-radius:var(--nylas-border-radius-2x);background-color:transparent;color:var(--nylas-base-800);cursor:pointer;border:none}.pagination .button:hover{background-color:var(--nylas-base-50)}.pagination .button:active{background-color:var(--nylas-base-100)}.pagination .button:disabled{background-color:transparent;color:var(--nylas-base-300);cursor:not-allowed}.flex-row{display:flex;flex-direction:row;justify-content:space-between;align-items:center;color:var(--nylas-base-500)}',be=de;var he=function(e,a,i,o){var s=arguments.length,n=s<3?a:o===null?o=Object.getOwnPropertyDescriptor(a,i):o,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,a,i,o);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(n=(s<3?r(n):s>3?r(a,i,n):r(a,i))||n);return s>3&&n&&Object.defineProperty(a,i,n),n},I=function(e,a){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,a)};const H=class{constructor(e){t.registerInstance(this,e),this.dateSelected=t.createEvent(this,"dateSelected",7),this.monthChanged=t.createEvent(this,"monthChanged",7),this.selectableDates=void 0,this.selectedDate=void 0,this.configSettings=void 0,this.isLoading=void 0,this.eventDuration=void 0,this.month=this.selectedDate||new Date,this.dates=this.getDates(),this.disableNextMonthButton=!1}configSettingsChanged(e){var s;const a=new Date(this.month.getFullYear(),this.month.getMonth()+1,1),i=(s=e==null?void 0:e.scheduler)==null?void 0:s.available_days_in_future;if(i===void 0)return;t.addDaysToCurrentDate(new Date,i).getTime()<a.getTime()?this.disableNextMonthButton=!0:this.disableNextMonthButton=!1}connectedCallback(){}disconnectedCallback(){}componentWillLoad(){}getDates(){const e=t.getLastDayOfMonth(this.month),a=t.getFirstDayOfMonth(this.month);return B.range(B.offset(a,-a.getDay()),B.offset(e,7-e.getDay()))}selectDate(e){this.dateSelected.emit(e)}changeMonth(e){var s,n;this.month=new Date(this.month.getFullYear(),this.month.getMonth()+e,1);const a=new Date(this.month.getFullYear(),this.month.getMonth()+1,1),i=(n=(s=this.configSettings)==null?void 0:s.scheduler)==null?void 0:n.available_days_in_future;t.addDaysToCurrentDate(new Date,i).getTime()<a.getTime()?this.disableNextMonthButton=!0:this.disableNextMonthButton=!1,this.dates=this.getDates(),this.monthChanged.emit(this.month),this.selectDate()}isSelected(e,a,i){return e&&a&&t.isSameDay(e,a)&&i&&(i==null?void 0:i.length)>0}isDisabled(e,a){return e&&(a==null?void 0:a.find(i=>t.isSameDay(i,e)))===void 0}render(){var e,a,i,o,s;return t.h(t.Host,{key:"bc2d37f59dc4cc59c9659a15ce640d3f3c738239",part:"ndp"},t.h("div",{key:"7b39c6ff3b5c820d6ee4cc3419a80f9803011deb",class:"nylas-date-picker"},t.h("div",{key:"e7e08bbe189da82d187241b1025633f9ea690bbe",class:"title",part:"'ndp__title"},((a=(e=this.configSettings)==null?void 0:e.organizer)==null?void 0:a.name)&&t.h("h1",null,t.h("person-icon",null),((o=(i=this.configSettings)==null?void 0:i.organizer)==null?void 0:o.name)||"Organizer"),t.h("p",{key:"7a952faa33c2421f9b6d25a4d56ec7a510d42ab5"},t.h("clock-icon",{key:"35561bc9866d9c75e676b3ef589b1506a6d273c6"}),this.eventDuration?t.convertMinutesToHoursAndMinutes(this.eventDuration):"- minutes")),t.h("div",{key:"b3799870aa76c6e54b3ec5a32dda0b684a817e1d",class:"header flex-row"},t.h("h2",{key:"bb00822464f175aa9b9c5f66f8fa79e95363b33d",part:"ndp__month-header"},t.h("strong",{key:"3cdeb9340334fabb6ee1ef09ffb28a6e75177275"},this.month.toLocaleDateString(void 0,{month:"long"}))," ",this.month.toLocaleDateString(void 0,{year:"numeric"})),t.h("div",{key:"ad6b090bdff3470d1f7381cce6d5734a698c7af9",class:"pagination"},t.h("button",{key:"90621e82962b012b50dedb9ec4c49bc7cdff0936",onClick:()=>this.changeMonth(-1),class:{"chevron-left":!0,button:!0},disabled:!((s=this.selectableDates)!=null&&s.length)||this.month<=new Date,part:"ndp__month-button"},t.h("chevron-icon",{key:"7596ada39a388b9570a3a783ff5cdf7bb3f252c1"})),t.h("button",{key:"e7bbf331f680b0c6f2538639235a008e213b52ee",onClick:()=>this.changeMonth(1),class:{"chevron-right":!0,button:!0},disabled:this.disableNextMonthButton,part:"ndp__month-button"},t.h("chevron-icon",{key:"898e3a4609bf204bdf4d375cd53c23d5ac52bc50"})))),t.h("div",{key:"e41bd3d09ef9c8bc48dd8aa5db6554af8b31faa8",class:"dates"},["SUN","MON","TUE","WED","THU","FRI","SAT"].map(n=>t.h("div",{class:"day",part:"ndp__day"},n)),this.dates.map((n,r)=>{var c;const l=this.isDisabled(n,this.selectableDates);return this.isLoading?t.h("button",{disabled:!0,class:{"date day-skeleton":!0,"current-month":t.isSameMonth(n,this.month)},style:{animationDelay:`${r*20}ms`},part:"ndp__date"},n.getDate()):t.h("button",{class:{date:!0,selected:!!(this.selectedDate&&t.isSameDay(n,this.selectedDate)&&this.selectableDates&&((c=this.selectableDates)==null?void 0:c.length)>0),"current-day":t.isSameDay(n,new Date),"current-month":t.isSameMonth(n,this.month)},"aria-lang":n.toLocaleDateString(void 0,{dateStyle:"full"}),disabled:l,onClick:()=>this.selectDate(n),part:`ndp__date ${this.isSelected(n,this.selectedDate,this.selectableDates)?"ndp__date--selected":""} ${t.isSameDay(n,new Date)?"ndp__date--current-day":""} ${t.isSameMonth(n,this.month)?"ndp__date--current-month":""}`},n.getDate())}))))}static get watchers(){return{configSettings:["configSettingsChanged"]}}};he([f.RegisterComponent({name:"nylas-date-picker",stateToProps:new Map([["scheduler.selectableDates","selectableDates"],["scheduler.selectedDate","selectedDate"],["scheduler.isLoading","isLoading"],["scheduler.configSettings","configSettings"],["scheduler.eventDuration","eventDuration"]]),eventToProps:{dateSelected:async(e,a)=>{a.scheduler.selectDate(e.detail)}},fireRegisterEvent:!0}),I("design:type",Function),I("design:paramtypes",[]),I("design:returntype",void 0)],H.prototype,"render",null);H.style=be;const fe=':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif}.nylas-locale-switch{display:flex;flex-direction:row;justify-content:space-between;align-items:center;border-left:none;border-right:none;color:var(--nylas-base-50);font-size:14px;font-weight:600;cursor:pointer;transition:all 0.2s ease-in-out;font-family:inherit}@media screen and (max-width: 768px){.nylas-locale-switch{font-size:16px}}.select-wrapper{display:flex;align-items:center;gap:0.5rem}select{border:none;background:transparent;cursor:pointer;outline:none;background-color:transparent;margin:0 0 1px;padding:4px;vertical-align:middle}select#timezone{width:140px}select#language{width:80px}span.timezone-label{display:flex;width:-webkit-fill-available;justify-content:space-between}select-dropdown{width:auto}select-dropdown::part(sd_dropdown-button){border:none;padding:10px}select-dropdown::part(sd_dropdown-content){max-width:306px}',me=fe;var ue=function(e,a,i,o){var s=arguments.length,n=s<3?a:o===null?o=Object.getOwnPropertyDescriptor(a,i):o,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,a,i,o);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(n=(s<3?r(n):s>3?r(a,i,n):r(a,i))||n);return s>3&&n&&Object.defineProperty(a,i,n),n},L=function(e,a){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,a)};const O=class{constructor(e){t.registerInstance(this,e),this.timezoneChanged=t.createEvent(this,"timezoneChanged",7),this.languageChanged=t.createEvent(this,"languageChanged",7),this.selectedTimezone=Intl.DateTimeFormat().resolvedOptions().timeZone,this.selectedLanguage=navigator.language}connectedCallback(){}disconnectedCallback(){}componentWillLoad(){}changeTimezone(e){this.selectedTimezone=e,this.timezoneChanged.emit(e)}changeLanguage(e){this.selectedLanguage=e,this.languageChanged.emit(e)}nylasFormDropdownChangedHandler(e){const{name:a,value:i}=e.detail;a==="timezone"?this.changeTimezone(i):a==="language"&&this.changeLanguage(i)}getTimezoneLabelHTML(e){const a=h.getTimezoneOffset(e);return t.h("span",{class:"timezone-label",style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"-webkit-fill-available"}},h.TIMEZONE_MAP[e]," ",t.h("span",{class:"timezone-offset",style:{fontSize:"14px",fontWeight:"400",color:"var(--nylas-base-500)"}},a))}render(){const e=Object.keys(h.TIMEZONE_MAP).map(i=>({labelHTML:this.getTimezoneLabelHTML(i),label:h.TIMEZONE_MAP[i],value:i})),a=Object.keys(h.LANGUAGE_MAP).map(i=>({label:h.LANGUAGE_MAP[i],value:i}));return t.h(t.Host,{key:"2d50a22ae8502ec3c6062da3cbbeb0bb6f0fcb8b"},t.h("div",{key:"8725370edb7b3fb70264586c8d6bf4cc7c8f6220",class:"nylas-locale-switch"},t.h("div",{key:"da5375359f87b3f1fc5c3ec9f094c76886a1a401",class:{"select-wrapper":!0,timezone:!0}},t.h("select-dropdown",{key:"3633e969f27a301b59ad64afb9f63a0bf19afcc6",name:"timezone",options:e,defaultSelectedOption:e.find(i=>i.value==this.selectedTimezone)},t.h("span",{key:"97db913cf64de05eb986fdea378a17948ead2527",slot:"select-icon"},t.h("globe-icon",{key:"ee73e4c113c23614a7084cb1f19e2d6149fd3185",width:"20",height:"20"})))),t.h("div",{key:"04245f7d6c51994197ff107f064632d5c8050e65",class:{"select-wrapper":!0,language:!0}},t.h("select-dropdown",{key:"55ed837e54b69f9db0548c9c4e4c6e5211ef577a",name:"language",options:a,defaultSelectedOption:a.find(i=>i.value==this.selectedLanguage)},t.h("span",{key:"43b4d67e865a27842998a796f8d12e0d9b5171eb",slot:"select-icon"},t.h("translate-icon",{key:"c393677712c3528f162bc5700368deb4dd6a197c",width:"20",height:"20"}))))))}};ue([f.RegisterComponent({name:"nylas-locale-switch",stateToProps:new Map([["scheduler.selectedLanguage","selectedLanguage"],["scheduler.selectedTimezone","selectedTimezone"]]),eventToProps:{timezoneChanged:async(e,a)=>{a.scheduler.selectTimezone(e.detail)}},fireRegisterEvent:!0}),L("design:type",Function),L("design:paramtypes",[]),L("design:returntype",void 0)],O.prototype,"render",null);O.style=me;const pe=".sc-nylas-logo-h{display:flex}",ye=pe,W=class{constructor(e){t.registerInstance(this,e),this.width="69",this.height="24"}render(){return t.h("svg",{key:"6e6bbcafcedbb912945dd29a383b809dd1295683",width:this.width,height:this.height,viewBox:"0 0 69 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t.h("g",{key:"361bd69757205d793a7619841a425fabbf075475","clip-path":"url(#clip0_455_3543)"},t.h("path",{key:"9f56ecacf7401c2f04a56dc4b0d201b008dc9c52",d:"M15.8092 3.03248C14.6497 1.86996 13.1076 1.23047 11.4646 1.23047C9.82156 1.23047 8.27753 1.86996 7.11999 3.03248L0.835347 9.33381C0.686846 9.4827 0.60498 9.68123 0.60498 9.89312C0.60498 10.105 0.686846 10.3035 0.835347 10.4524C0.983848 10.6013 1.18185 10.6834 1.39318 10.6834C1.60451 10.6834 1.80251 10.6013 1.95101 10.4524L8.23374 4.15111C10.0139 2.36627 12.9134 2.36627 14.6935 4.15111C16.4736 5.93785 16.4756 8.84322 14.6935 10.6281L8.4108 16.9275C8.10428 17.2348 8.10428 17.7368 8.4108 18.0461C8.5593 18.195 8.75731 18.2771 8.96863 18.2771C9.17996 18.2771 9.37796 18.195 9.52646 18.0461L15.8092 11.7467C16.9687 10.5841 17.6064 9.03793 17.6064 7.39053C17.6064 5.74314 16.9687 4.19501 15.8092 3.03439V3.03248Z",fill:"currentColor"}),t.h("path",{key:"f3b85c6d9c447bf55c3299de0084894d6f4b405a",d:"M14.9296 7.39038C14.9296 6.46074 14.5698 5.58837 13.9148 4.93361C12.5631 3.57828 10.3641 3.57828 9.01239 4.93361L0.663961 13.3023C0.51546 13.4512 0.433594 13.6497 0.433594 13.8616C0.433594 14.0735 0.51546 14.272 0.663961 14.4209C0.812462 14.5698 1.01046 14.6519 1.22179 14.6519C1.43312 14.6519 1.63112 14.5698 1.77962 14.4209L10.0367 6.1515L10.05 6.13623C10.0747 6.10759 10.1014 6.07705 10.128 6.05033C10.1585 6.01978 10.1928 5.99115 10.2251 5.96252L10.2442 5.94534C10.9886 5.31349 12.1119 5.3593 12.8011 6.05033C13.4903 6.74135 13.536 7.78171 12.9705 8.53192L12.9648 8.53955C12.9058 8.61591 12.8544 8.67699 12.8011 8.73044C12.7497 8.78198 12.6906 8.83352 12.6069 8.90033L4.45264 17.0991C4.30414 17.248 4.22227 17.4465 4.22227 17.6584C4.22227 17.8703 4.30414 18.0689 4.45264 18.2177C4.60114 18.3666 4.79914 18.4487 5.01047 18.4487C5.2218 18.4487 5.4198 18.3666 5.5683 18.2177L13.9167 9.84716C14.5698 9.1924 14.9315 8.31812 14.9315 7.39038H14.9296Z",fill:"currentColor"}),t.h("path",{key:"2d1f7045c261de3721c5b8b27403c8258310ae4c",d:"M10.6821 9.11238C10.4727 9.01694 10.2861 8.88904 10.1281 8.7306C9.97008 8.57216 9.84252 8.38508 9.74733 8.1751L9.69021 8.05103L0.467916 17.2978C0.287049 17.4792 0.174721 17.7082 0.149971 17.9411C0.125221 18.1778 0.19376 18.3897 0.344165 18.5405C0.471724 18.6684 0.65259 18.739 0.850592 18.739C1.11142 18.739 1.37796 18.6207 1.58358 18.4145L10.8059 9.16774L10.6821 9.11047V9.11238Z",fill:"currentColor"}),t.h("path",{key:"a6a34de523ff685dd51372f44b4c47d038419ed4",d:"M68.401 10.6185C68.2126 10.2692 67.9593 9.97334 67.6433 9.73854C67.3235 9.49993 66.956 9.31094 66.5486 9.17541C66.1316 9.03606 65.7033 8.91771 65.2749 8.81844C64.7951 8.70582 64.3039 8.57983 63.8165 8.44811C63.3196 8.31258 62.9065 8.14269 62.5905 7.94225C62.4743 7.88689 62.3391 7.76663 62.3391 7.50129C62.3391 7.39821 62.3639 7.29704 62.4153 7.19587L62.4248 7.18059C62.5352 7.02216 62.7142 6.8828 62.975 6.75109C63.234 6.62128 63.609 6.55829 64.1231 6.55829C64.5286 6.55829 64.877 6.61365 65.1569 6.72436C65.4348 6.83508 65.6652 6.96871 65.8442 7.12524C66.0212 7.27986 66.1659 7.45357 66.2782 7.63873C66.3563 7.76854 66.4267 7.89262 66.4858 8.00525L68.2754 6.84081C68.1669 6.59456 68.0146 6.33495 67.8204 6.0677C67.6033 5.768 67.3254 5.4893 66.9922 5.23732C66.659 4.98534 66.2516 4.77345 65.7813 4.60929C65.3111 4.44512 64.7532 4.36304 64.1231 4.36304C63.3844 4.36304 62.7599 4.46421 62.2706 4.66083C61.7813 4.85935 61.3815 5.09988 61.0845 5.37667C60.7875 5.65346 60.5628 5.95125 60.4143 6.2605C60.2639 6.57547 60.1611 6.85799 60.1078 7.10233C60.0945 7.18059 60.0812 7.27031 60.0678 7.36767C60.0545 7.4593 60.0469 7.5452 60.0469 7.62537C60.0469 8.13314 60.1745 8.56074 60.4239 8.89671C60.679 9.24222 61.0045 9.53429 61.391 9.76336C61.7813 9.99624 62.2116 10.1852 62.6704 10.3227C63.1388 10.462 63.5862 10.5823 64.0012 10.6796C64.4067 10.777 64.7932 10.8782 65.1531 10.9774C65.5224 11.0786 65.8289 11.2122 66.0631 11.3745C66.2801 11.5425 66.3887 11.7448 66.3887 11.9777C66.3887 12.2278 66.2916 12.4263 66.0993 12.5695C65.9279 12.6954 65.7261 12.7985 65.4958 12.8711C65.273 12.9436 65.0407 12.9913 64.8066 13.0142C64.58 13.0352 64.3915 13.0467 64.2468 13.0467C63.8032 13.0467 63.4224 13.0028 63.1197 12.915C62.8151 12.8272 62.5638 12.7241 62.3734 12.6057C62.1811 12.4874 62.0288 12.3614 61.9222 12.2316C61.8213 12.1094 61.747 12.0082 61.7014 11.9319L61.4957 11.6303L59.708 12.7928C59.8508 13.0161 60.0298 13.2643 60.2392 13.5296C60.4772 13.8293 60.7837 14.1138 61.153 14.3734C61.5224 14.633 61.966 14.8525 62.4724 15.0243C62.9788 15.1961 63.5748 15.282 64.2468 15.282C64.797 15.282 65.2901 15.2324 65.7166 15.137C66.1412 15.0396 66.5162 14.9117 66.8285 14.7552C67.1388 14.6005 67.4015 14.4192 67.6109 14.2149C67.8223 14.0107 67.9974 13.8026 68.1326 13.6003C68.4563 13.1135 68.6409 12.5504 68.6828 11.9262C68.6828 11.4069 68.5876 10.9641 68.401 10.6166V10.6185Z",fill:"currentColor"}),t.h("path",{key:"127937c688ac0410b9b3a53ee76fd962a4f4b407",d:"M26.3585 4.27905C23.7901 4.27905 21.6997 6.37504 21.6997 8.95017V15.0701H23.9291V8.95017C23.9291 7.6082 25.0181 6.5163 26.3565 6.5163C27.695 6.5163 28.784 7.6082 28.784 8.95017V15.0701H31.0134V8.95017C31.0134 6.37504 28.9229 4.27905 26.3546 4.27905H26.3585Z",fill:"currentColor"}),t.h("path",{key:"7336b38c7bcb388276b886e6792ad173327142d5",d:"M53.4522 4.27905C50.4251 4.27905 47.9634 6.74728 47.9634 9.78245C47.9634 12.8176 50.427 15.2859 53.4522 15.2859C54.5545 15.2859 55.6188 14.9594 56.5288 14.3409L56.7116 14.2169V15.0682H58.941V9.78245C58.941 6.74728 56.4793 4.27905 53.4522 4.27905ZM53.4522 13.0505C51.655 13.0505 50.1928 11.5845 50.1928 9.78245C50.1928 7.98044 51.655 6.51439 53.4522 6.51439C55.2494 6.51439 56.7116 7.98044 56.7116 9.78245C56.7116 11.5845 55.2494 13.0505 53.4522 13.0505Z",fill:"currentColor"}),t.h("path",{key:"904bbd6f937f00c2ae6e2269235f2adc2afbc6e4",d:"M45.5795 10.6166V0.356201H43.3501V10.6166C43.3501 13.1517 45.3758 15.2228 47.8908 15.2858V13.0486C46.6057 12.9875 45.5795 11.9204 45.5795 10.6166Z",fill:"currentColor"}),t.h("path",{key:"9425f2b121d23319942fa5d4daa9ce53173cbcf9",d:"M39.5428 4.4967V10.63C39.5428 11.6761 38.8669 12.621 37.9016 12.9284C37.1249 13.1746 36.3157 13.0486 35.6817 12.5829C35.0592 12.1247 34.6879 11.3917 34.6879 10.6186V4.4967H32.4585V10.5995C32.4585 12.7165 33.8388 14.57 35.8131 15.1084C37.0354 15.4424 38.2995 15.2973 39.3695 14.7037L39.5428 14.6063V14.9747C39.5428 16.2766 38.5166 17.3437 37.2315 17.4067V19.6439C39.7465 19.5809 41.7722 17.5117 41.7722 14.9747V4.4967H39.5428Z",fill:"currentColor"})),t.h("defs",{key:"7c41827bdfde9ce70fbcb353d98991e37e2a99fe"},t.h("clipPath",{key:"5e29b38dc325426fdb3284275f74c1c46485eb1c",id:"clip0_455_3543"},t.h("rect",{key:"c63515b41fb503c621fb26917befbcf503e26262",width:"68.7123",height:"19.2877",fill:"white",transform:"translate(0.144043 0.356201)"}))))}};W.style=ye;const ge=':host{display:block;margin-bottom:-12px;width:100%;z-index:1;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif}.notif{display:flex;padding:17px;align-items:flex-start;justify-content:space-between;gap:16px;border-radius:var(--nylas-border-radius-2x);border:1.5px solid var(--nylas-error);background:var(--nylas-base-0)}@media screen and (max-width: 768px){.notif{width:auto}}.notif .content{display:flex;flex-direction:row;gap:8px}.notif .content .message{font-size:14px;font-weight:400;color:var(--nylas-base-800)}.notif .content .message .title{font-size:16px;font-weight:600;color:var(--nylas-base-950);display:block}.notif .content .message .description{font-size:14px;font-weight:400;color:var(--nylas-base-800);display:block}.notif .content .icon.error{color:var(--nylas-error)}.notif.error{border-color:var(--nylas-error);background:rgb(255, 248, 248)}.notif.warning{border-color:var(--nylas-warning)}.notif.info{border-color:var(--nylas-info)}.notif.success{border-color:var(--nylas-success)}.notif .dismiss-btn{background:none;border:none;color:var(--nylas-base-950);cursor:pointer}',ve=ge,Y=class{constructor(e){t.registerInstance(this,e),this.ttl=5e3,this.allowedCategories=["component","api","validation","invalid_session"],this.notifications=[]}onError(e){t.debug(`[nylas-notification] Error: ${e.detail.title}`),this.handleNotification(e)}onWarning(e){t.debug(`[nylas-notification] Warning: ${e.detail.title}`),this.handleNotification(e)}onInfo(e){t.debug(`[nylas-notification] Info: ${e.detail.title}`),this.handleNotification(e)}onSuccess(e){t.debug(`[nylas-notification] Success: ${e.detail.title}`),this.handleNotification(e)}handleNotification(e){if(e.defaultPrevented){t.debug("[nylas-notification] Event default prevented");return}if(this.ttl===0){t.debug("[nylas-notification] TTL is 0");return}if(this.allowedCategories.length>0&&!this.allowedCategories.includes(e.detail.category)){t.debug("[nylas-notification] Category not allowed");return}if(this.notifications=[...this.notifications,{...e.detail}],e.detail.ttl!=="none"){const a=e.detail.ttl?e.detail.ttl:this.ttl;window.setTimeout(()=>{this.notifications=this.notifications.filter(i=>i.id!==e.detail.id)},a)}}dismissNotification(e){this.notifications=this.notifications.filter(a=>a.id!==e)}render(){return t.h(t.Host,{key:"b86593ead0279b9e2213c2554d1153379470880e"},t.h(t.Fragment,{key:"860f23f3c6a0636b408d56806b11129c0a697418"},this.notifications.map(e=>t.h("div",{class:`notif ${e.type}`,key:e.id},t.h("div",{class:"content"},t.h("span",{class:`icon ${e.type}`},(e.type==="error"||e.type==="warning")&&t.h("warning-icon",null)),t.h("span",{class:"message"},t.h("span",{class:"title"},e.title),e.description&&t.h("span",{class:"description"},e.description))),t.h("button",{class:"dismiss-btn",onClick:()=>this.dismissNotification(e.id)},t.h("close-icon",null)))),t.h("slot",{key:"6125314e051684b396d99a3c8bb9ba99392f2729"})))}};Y.style=ve;const ke=":host{display:block}sp-theme{position:relative;height:inherit;display:flex;flex-direction:column;justify-content:center;align-items:center;font-family:var(--nylas-font-family)}.event-card{display:flex;align-items:center;flex-direction:column;width:calc(100% - 3rem);background-color:var(--nylas-base-0);color:var(--nylas-base-800);border-radius:var(--nylas-border-radius-2x);padding:3rem 1.5rem 1.5rem 1.5rem;position:relative;box-shadow:0px 1px 3px 0px rgba(0, 0, 0, 0.1), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)}@media screen and (max-width: 768px){.event-card{margin-bottom:2rem}}.nylas-selected-event-card__date{font-size:min(max(16px, 3vw), 18px);font-weight:600}.nylas-selected-event-card__time{font-size:16px;font-weight:500}.calendar-icon{width:3rem;height:3rem;border-radius:50%;position:absolute;top:-1.25rem;left:50%;transform:translateX(-50%);background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200)}calendar-icon{display:flex;align-items:center;justify-content:center;height:100%}.event-timezone{display:flex;color:var(--nylas-base-600);margin-bottom:8px;gap:4px;align-items:center}@media screen and (max-width: 768px){.event-timezone{margin-bottom:16px}}",xe=ke;var Ce=function(e,a,i,o){var s=arguments.length,n=s<3?a:o===null?o=Object.getOwnPropertyDescriptor(a,i):o,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,a,i,o);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(n=(s<3?r(n):s>3?r(a,i,n):r(a,i))||n);return s>3&&n&&Object.defineProperty(a,i,n),n},R=function(e,a){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,a)};const A=class{constructor(e){t.registerInstance(this,e),this.selectedDate=void 0,this.selectedTimeslot=void 0,this.selectedTimezone=Intl.DateTimeFormat().resolvedOptions().timeZone,this.startTime="",this.endTime=""}connectedCallback(){}disconnectedCallback(){}async componentWillLoad(){t.debug("[nylas-selected-event-card] Component will load")}async componentDidLoad(){t.debug("[nylas-selected-event-card] Component did load"),this.selectedDate||console.warn('[nylas-selected-event-card] "selectedDate" prop is not provided.'),this.selectedTimeslot||console.warn('[nylas-selected-event-card] "selectedTimeslot" prop is not provided.')}handleSelectedTimeslotChange(e){this.startTime=new Date(e==null?void 0:e.start_time).toLocaleString(void 0,{timeStyle:"short"}),this.endTime=new Date(e==null?void 0:e.end_time).toLocaleString(void 0,{timeStyle:"short"})}render(){var e;return t.h(t.Host,{key:"ae635bed01604ece8f012b82c00fa7d4b6bc4c3d",part:"nsec"},t.h("sp-theme",{key:"edcbe79ce2a87e920bd88714b3a5a747d4a80747",theme:"spectrum",color:"dark",scale:"medium"},t.h("div",{key:"8c736e8a7ea756b2ef8ba316e0f2c0f38f3821fd",class:"event-card",part:"nsec__card"},t.h("div",{key:"06c33c0fc54e893cbeb8c685503f73a74109ab33",class:"calendar-icon",part:"nsec__icon"},t.h("calendar-icon",{key:"69617d50f58122aea2dd92e7ea26d5b2a984c2bf"})),t.h("div",{key:"e4e53019bba6e23f2c5f0a5b8cde5336973d795d",class:"nylas-selected-event-card__date",part:"nsec__date"},(e=this.selectedDate)==null?void 0:e.toLocaleDateString(void 0,{dateStyle:"full"})),t.h("div",{key:"c838e6987d4c932471d27dca86c295f549f06a5d",class:"nylas-selected-event-card__time",part:"nsec__time"},this.startTime," - ",this.endTime)),t.h("div",{key:"3e0f9d170e593f39516d49e31fe0da1db49fe828",class:"event-timezone",part:"nsec__timezone"},t.h("globe-icon",{key:"12f52fc23ec7d60d046078aceeb6fffba7283078"}),h.TIMEZONE_MAP[this.selectedTimezone])))}static get watchers(){return{selectedTimeslot:["handleSelectedTimeslotChange"]}}};Ce([f.RegisterComponent({name:"nylas-selected-event-card",stateToProps:new Map([["scheduler.selectedDate","selectedDate"],["scheduler.selectedTimeslot","selectedTimeslot"],["scheduler.selectedTimezone","selectedTimezone"]]),eventToProps:{},fireRegisterEvent:!0}),R("design:type",Function),R("design:paramtypes",[]),R("design:returntype",void 0)],A.prototype,"render",null);A.style=xe;const we=":host{display:block;height:calc(100% - 48px)}.time-picker-wrapper{display:flex;flex-direction:column;height:100%}.time-slots{position:relative;display:flex;flex-direction:column;gap:0.75rem;align-items:center;overflow-y:scroll;padding:0.5rem 1.5rem 1.5rem;flex:1}.time{box-sizing:border-box;display:flex;flex-direction:column;justify-content:center;align-items:center;padding:4px 12px;gap:0.5rem;font-size:16px;font-weight:500;font-family:inherit;width:100%;height:48px;color:var(--nylas-base-800);background:var(--nylas-base-0);border:none;outline:1.5px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-2x);flex:none;order:4;align-self:stretch;flex-grow:0;cursor:pointer}.time:hover,.time:focus{color:var(--nylas-primary);outline-color:var(--nylas-primary)}.time.selected{font-weight:600;color:var(--nylas-primary);outline:2px solid var(--nylas-primary);border-color:transparent;box-shadow:0 0 0 2px var(--nylas-primary)}.empty{text-align:center;padding:0 1.5rem;color:var(--nylas-base-600);font-size:min(max(12px, 2vw), 14px);height:450px;display:flex;align-items:center;justify-content:center}@keyframes pulsate{0%{background-color:var(--nylas-base-50)}50%{background-color:var(--nylas-base-100)}100%{background-color:var(--nylas-base-50)}}.loading{padding:0 1.5rem}.loading .time-slot-skeleton{width:100%;height:4rem;background-color:var(--nylas-base-50);margin-bottom:0.5rem;border-radius:var(--nylas-border-radius-2x);animation:pulsate 1.5s infinite ease-in-out}.footer{width:100%;padding:14px;box-sizing:border-box;border-top:1px solid var(--nylas-base-200)}.footer sp-button{padding:14px;color:var(--nylas-base-100);border-radius:var(--nylas-border-radius-2x);width:100%;height:48px;font-weight:600;font-size:16px;background-color:var(--nylas-primary);border:none}.footer sp-button:hover,.footer sp-button:focus{background-color:var(--nylas-base-600)}.footer sp-button:active{background-color:var(--nylas-base-800)}",_e=we;var Ee=function(e,a,i,o){var s=arguments.length,n=s<3?a:o===null?o=Object.getOwnPropertyDescriptor(a,i):o,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,a,i,o);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(n=(s<3?r(n):s>3?r(a,i,n):r(a,i))||n);return s>3&&n&&Object.defineProperty(a,i,n),n},P=function(e,a){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,a)};const Z=class{constructor(e){t.registerInstance(this,e),this.timeslotSelected=t.createEvent(this,"timeslotSelected",7),this.timeslotConfirmed=t.createEvent(this,"timeslotConfirmed",7),this.handleConfirmedTimeslot=async(a,i)=>{a.preventDefault(),t.debug("[nylas-timeslot-picker] Confirm timeslot",i),this.timeslotConfirmed.emit(i)},this.handleMouseEnter=a=>{this.hoveredTimeslotIndex=a},this.handleMouseLeave=()=>{this.hoveredTimeslotIndex=-1},this.selectedDate=new Date,this.availability=void 0,this.selectedTimeslot=void 0,this.isLoading=void 0,this.selectedTimezone=Intl.DateTimeFormat().resolvedOptions().timeZone,this.times=[],this.hoveredTimeslotIndex=void 0,this.selectedTimeslotIndex=void 0}connectedCallback(){}disconnectedCallback(){}async componentWillLoad(){var a;const e=(a=this.availability)==null?void 0:a.filter(i=>this.selectedDate&&t.isSameDay(i.start_time,this.selectedDate)).map(i=>i);this.times=e||[],t.debug("[nylas-timeslot-picker] Component will load",{selectedDate:this.selectedDate,availability:this.availability,times:this.times})}async componentDidLoad(){t.debug("[nylas-timeslot-picker] Component did load")}getTimeslotId(e,a){return`${e.toLocaleDateString()}-${a}`}onClickSelectTime(e,a){t.debug("[nylas-timeslot-picker] Time selected",e,a),this.selectedTimeslotIndex=this.getTimeslotId(e.start_time,a),this.timeslotSelected.emit({start_time:e.start_time,end_time:e.end_time})}getTimeSlotLabel(e){const a=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"numeric",timeZone:this.selectedTimezone});return`${a.format(e.start_time)} - ${a.format(e.end_time)}`}selectedDateChanged(e){var a;if(t.debug("[nylas-timeslot-picker] Selected date changed",{newVal:e}),e&&(this.selectedTimeslotIndex="",typeof e<"u")){const i=(a=this.availability)==null?void 0:a.filter(o=>t.isSameDay(o.start_time,e)).map(o=>o);this.times=i||[]}}availabilityChanged(e){if(t.debug("[nylas-timeslot-picker] Available times changed",{newVal:e,selectedDate:this.selectedDate}),typeof e<"u"){const a=e==null?void 0:e.filter(i=>this.selectedDate&&t.isSameDay(i.start_time,this.selectedDate)).map(i=>i);this.times=a||[]}}render(){return this.isLoading?t.h(t.Host,null,t.h("div",{class:"loading"},new Array(6).fill(0).map((e,a)=>t.h("div",{class:"time-slot-skeleton",style:{animationDelay:`${a*20}ms`}})))):this.availability&&this.availability.length===0?t.h(t.Host,null,t.h("div",{class:"empty"},t.h("span",null,"No dates available"))):(!this.times||this.times.length===0)&&this.selectedDate?t.h(t.Host,null,t.h("div",{class:"empty"},t.h("span",null,"No time slots available for selected date"))):this.selectedDate?t.h(t.Host,{part:"ntp"},t.h("div",{class:"time-picker-wrapper"},t.h("div",{class:"time-slots"},this.times.map((e,a)=>{var i,o,s,n;return t.h("button",{part:`ntp__timeslot ${((o=(i=this.selectedTimeslot)==null?void 0:i.start_time)==null?void 0:o.getTime())===e.start_time.getTime()?"ntp__timeslot--selected":""}`,"aria-role":"button",class:{time:!0,selected:typeof this.selectedTimeslot<"u"&&((n=(s=this.selectedTimeslot)==null?void 0:s.start_time)==null?void 0:n.getTime())===e.start_time.getTime()},onClick:()=>this.onClickSelectTime(e,a),onMouseEnter:()=>this.handleMouseEnter(a),onMouseLeave:()=>this.handleMouseLeave()},this.hoveredTimeslotIndex==a||this.selectedTimeslotIndex==this.getTimeslotId(e.start_time,a)?this.getTimeSlotLabel(e):e.start_time.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",timeZone:this.selectedTimezone}))})),this.selectedTimeslot&&t.h("div",{class:"footer"},t.h("sp-button",{variant:"primary",onClick:e=>this.handleConfirmedTimeslot(e,this.selectedTimeslot),part:"ntp__button-primary"},t.h("slot",{name:"timeslot-picker-cta-label"},"Next"))))):t.h(t.Host,null)}static get watchers(){return{selectedDate:["selectedDateChanged"],availability:["availabilityChanged"]}}};Ee([f.RegisterComponent({name:"nylas-timeslot-picker",stateToProps:new Map([["scheduler.selectedDate","selectedDate"],["scheduler.availability","availability"],["scheduler.selectedTimeslot","selectedTimeslot"],["scheduler.selectedTimezone","selectedTimezone"],["scheduler.isLoading","isLoading"]]),eventToProps:{timeslotSelected:async(e,a)=>{a.scheduler.selectTime(e.detail)},timeslotConfirmed:async(e,a)=>{e.detail&&a.scheduler.toggleAdditionalData(!0)}},fireRegisterEvent:!0}),P("design:type",Function),P("design:paramtypes",[]),P("design:returntype",void 0)],Z.prototype,"render",null);Z.style=_e;exports.nylas_booked_event_card=M;exports.nylas_booking_form=F;exports.nylas_cancel_booking_form=j;exports.nylas_cancelled_event_card=N;exports.nylas_date_picker=H;exports.nylas_locale_switch=O;exports.nylas_logo=W;exports.nylas_notification=Y;exports.nylas_selected_event_card=A;exports.nylas_timeslot_picker=Z;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var I=Object.defineProperty;var P=(r,t,n)=>t in r?I(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n;var w=(r,t,n)=>(P(r,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const index=require("./index-e3e9b594.cjs"),index_es9cc0eb3c=require("./index.es-9cc0eb3c-0c99c055.cjs"),schedulerConfigStore4a50a03d=require("./scheduler-config-store-4a50a03d-884e6df8.cjs"),index53420959=require("./index-53420959-d3254a34.cjs");require("react");require("react-dom");class NylasSchedulerConfigAPIConnector{constructor({nylasApiRequest:t,nylasSchedulerConfigStore:n}){this.nylasApiRequest=t,this.nylasSchedulerConfigStore=n}async currentUser(){return this.nylasApiRequest?this.nylasApiRequest.currentUser():(console.warn("Nylas API Request is not initialized"),null)}async getCalendars(){var s;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error fetching calendars: Nylas API Request is not initialized"});const[t,n]=await this.nylasApiRequest.request({method:"GET",path:"calendars"});return n?index.dataResponse(null,{message:"Error fetching calendars: "+n.message}):index_es9cc0eb3c.Xr(t)?index.dataResponse(null,{message:"Error fetching calendars: "+((s=t.error)==null?void 0:s.message)}):(this.nylasSchedulerConfigStore.state.calendars=t.data,index.dataResponse(t.data))}async getConfigurationById(t,n=!1){var a;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error fetching configuration: Nylas API Request is not initialized"});if(!n){const l=this.nylasSchedulerConfigStore.state.configurations.find(d=>d.id===t);if(l)return this.nylasSchedulerConfigStore.state.selectedConfiguration=l,index.dataResponse(l)}const[s,c]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${t}`});return c?index.dataResponse(null,{message:"Error fetching configuration: "+c.message}):index_es9cc0eb3c.Xr(s)?index.dataResponse(null,{message:"Error fetching configuration: "+((a=s.error)==null?void 0:a.message)}):(this.nylasSchedulerConfigStore.state.selectedConfiguration=s.data,this.nylasSchedulerConfigStore.state.configurations.find(l=>l.id===t)?this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map(l=>l.id===t?s.data:l):this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,s.data],index.dataResponse(s.data))}async getConfigurations(){var s;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error fetching configurations: Nylas API Request is not initialized"});const[t,n]=await this.nylasApiRequest.request({method:"GET",path:"scheduling/configurations"});return n?index.dataResponse(null,{message:"Error fetching configurations: "+n.message}):index_es9cc0eb3c.Xr(t)?index.dataResponse(null,{message:"Error fetching configurations: "+((s=t.error)==null?void 0:s.message)}):(this.nylasSchedulerConfigStore.state.configurations=t.data,index.dataResponse(t.data))}async createConfiguration(t){var c;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error creating configuration: Nylas API Request is not initialized"});const[n,s]=await this.nylasApiRequest.request({method:"POST",path:"scheduling/configurations",body:t});return s?index.dataResponse(null,{message:"Error creating configuration: "+s.message}):index_es9cc0eb3c.Xr(n)?index.dataResponse(null,{message:"Error creating configuration: "+((c=n.error)==null?void 0:c.message)}):(this.nylasSchedulerConfigStore.state.selectedConfiguration=n.data,this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,n.data],index.dataResponse(n.data))}async updateConfiguration(t){var c;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error updating configuration: Nylas API Request is not initialized"});const[n,s]=await this.nylasApiRequest.request({method:"PUT",path:`scheduling/configurations/${t.id}`,body:t});return s?index.dataResponse(null,{message:"Error updating configuration: "+s.message}):index_es9cc0eb3c.Xr(n)?index.dataResponse(null,{message:"Error updating configuration: "+((c=n.error)==null?void 0:c.message)}):(this.nylasSchedulerConfigStore.state.selectedConfiguration=n.data,this.nylasSchedulerConfigStore.state.configurations.find(a=>a.id===t.id)?this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map(a=>a.id===t.id?n.data:a):this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,n.data],index.dataResponse(n.data))}async deleteConfiguration(t){var c,a;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error deleting configuration: Nylas API Request is not initialized"});const[n,s]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${t}`});return s?index.dataResponse(null,{message:"Error deleting configuration: "+s.message}):index_es9cc0eb3c.Xr(n)?index.dataResponse(null,{message:"Error deleting configuration: "+((c=n.error)==null?void 0:c.message)}):(this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.filter(l=>l.id!==t),((a=this.nylasSchedulerConfigStore.state.selectedConfiguration)==null?void 0:a.id)===t&&this.nylasSchedulerConfigStore.resetSelectedConfiguration(),index.dataResponse(n.data))}}class NylasSchedulerConfigConnector{constructor({nylasApiRequest:t,nylasSchedulerConfigStore:n}){this.nylasApiRequest=t,this.nylasSchedulerConfigStore=n}init(){index.debug("NylasSchedulerConfigConnector init")}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get schedulerConfig(){return this._schedulerConfigConnector?this._schedulerConfigConnector:(this._schedulerConfigConnector=new NylasSchedulerConfigAPIConnector({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore}),this._schedulerConfigConnector)}resetStores(){index.debug("NylasSchedulerConfigConnector resetStores"),this.nylasSchedulerConfigStore.reset()}async logout(){index.debug("NylasSchedulerConfigConnector logout"),this.resetStores()}}class LocalStorage{get(t){return new Promise(n=>{const s=window.localStorage.getItem(t);n(s?JSON.parse(s):null)})}async remove(t){return window.localStorage.removeItem(t),new Promise(n=>{n(null)})}set(t,n){return window.localStorage.setItem(t,JSON.stringify(n)),new Promise(s=>{s(null)})}}const PKCE_KEY="pkce",GRANT_KEY="grant",USER_KEY="user";class Storage{constructor(t){w(this,"Storage",new LocalStorage);if(t){this.Storage=t;return}}setPKCE(t){const n=index.Buffer.from(t);this.Storage.set(PKCE_KEY,n.toString("base64"))}async getPKCE(){try{const t=await this.Storage.get(PKCE_KEY);if(t)return index.Buffer.from(t,"base64").toString("utf8")}catch{return null}return null}removePKCE(){this.Storage.remove(PKCE_KEY)}setGrant(t,n=!1){const{grant_id:s}=t;this.Storage.set(`${GRANT_KEY}${n?"-"+s:""}`,t)}removeGrant(t,n=!1){this.Storage.remove(`${GRANT_KEY}${n?"-"+t:""}`)}async getGrant(t,n=!1){const s=await this.Storage.get(`${GRANT_KEY}${n?"-"+t:""}`);return s||null}async setUserToken(t){const n=await this.getUserTokens();if(n)if(n.find(c=>c.sub===t.sub)){const c=n.map(a=>(a.sub===t.sub&&(a=t),a));this.Storage.set(USER_KEY,c)}else{const c=[...n,t];this.Storage.set(USER_KEY,c)}else this.Storage.set(USER_KEY,[t])}async getUserToken(t=""){const n=await this.Storage.get(USER_KEY);return n?t===""?n[0]:n.find(c=>c.sub===t):null}async getUserTokens(){const t=await this.Storage.get(USER_KEY);return t||null}removeUserTokens(){this.Storage.remove(USER_KEY)}async removeUserToken(t){const n=await this.getUserTokens(),s=n==null?void 0:n.filter(c=>c.sub!==t);this.Storage.set(USER_KEY,s)}async clearSession(){const t=await this.getUserTokens();t==null||t.forEach(n=>{this.removeGrant(n.sub)}),this.removePKCE(),this.removeUserTokens()}}class IndexedDBStorage{constructor(){w(this,"databaseName","identity-db");w(this,"storeName","identity")}get(t){const n=this;return new Promise((s,c)=>{n.openDatabase().then(function(a){const l=a.transaction(n.storeName,"readwrite"),h=l.objectStore(n.storeName).get(t);h.onsuccess=()=>{s(h.result)},h.onerror=()=>{c(h.error)},l.oncomplete=()=>{a.close()}})})}async remove(t){const n=this;return new Promise((s,c)=>{const a=indexedDB.open(this.databaseName);a.onupgradeneeded=function(l){l.target.result.createObjectStore(n.storeName)},a.onerror=()=>{c(a.error)},a.onsuccess=l=>{const d=l.target.result,h=d.transaction(this.storeName,"readwrite"),f=h.objectStore(this.storeName).delete(t);f.onsuccess=()=>{s(null)},f.onerror=()=>{c(f.error)},h.oncomplete=()=>{d.close()}}})}set(t,n){return new Promise((s,c)=>{const a=indexedDB.open(this.databaseName);a.onerror=()=>{c(a.error)},a.onupgradeneeded=l=>{l.target.result.createObjectStore(this.storeName)},a.onsuccess=l=>{const d=l.target.result,h=d.transaction(this.storeName,"readwrite"),f=h.objectStore(this.storeName).put(n,t);f.onsuccess=()=>{s(n)},f.onerror=()=>{c(f.error)},h.oncomplete=()=>{d.close()}}})}openDatabase(){const t=this;return new Promise(function(n,s){const c=indexedDB.open(t.databaseName,2);c.onupgradeneeded=function(a){a.target.result.createObjectStore(t.storeName)},c.onsuccess=function(a){n(a.target.result)},c.onerror=function(a){s(a.error)}})}}var sha256={exports:{}};(function(module){(function(){var ERROR="input is invalid type",WINDOW=typeof window=="object",root=WINDOW?window:{};root.JS_SHA256_NO_WINDOW&&(WINDOW=!1);var WEB_WORKER=!WINDOW&&typeof self=="object",NODE_JS=!root.JS_SHA256_NO_NODE_JS&&typeof index53420959.process=="object"&&index53420959.process.versions&&index53420959.process.versions.node;NODE_JS?root=index.commonjsGlobal:WEB_WORKER&&(root=self);var COMMON_JS=!root.JS_SHA256_NO_COMMON_JS&&!0&&module.exports,ARRAY_BUFFER=!root.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",HEX_CHARS="0123456789abcdef".split(""),EXTRA=[-2147483648,8388608,32768,128],SHIFT=[24,16,8,0],K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],OUTPUT_TYPES=["hex","array","digest","arrayBuffer"],blocks=[];(root.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(r){return Object.prototype.toString.call(r)==="[object Array]"}),ARRAY_BUFFER&&(root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(r){return typeof r=="object"&&r.buffer&&r.buffer.constructor===ArrayBuffer});var createOutputMethod=function(r,t){return function(n){return new Sha256(t,!0).update(n)[r]()}},createMethod=function(r){var t=createOutputMethod("hex",r);NODE_JS&&(t=nodeWrap(t,r)),t.create=function(){return new Sha256(r)},t.update=function(c){return t.create().update(c)};for(var n=0;n<OUTPUT_TYPES.length;++n){var s=OUTPUT_TYPES[n];t[s]=createOutputMethod(s,r)}return t},nodeWrap=function(method,is224){var crypto=eval("require('crypto')"),Buffer=eval("require('buffer').Buffer"),algorithm=is224?"sha224":"sha256",nodeMethod=function(r){if(typeof r=="string")return crypto.createHash(algorithm).update(r,"utf8").digest("hex");if(r==null)throw new Error(ERROR);return r.constructor===ArrayBuffer&&(r=new Uint8Array(r)),Array.isArray(r)||ArrayBuffer.isView(r)||r.constructor===Buffer?crypto.createHash(algorithm).update(new Buffer(r)).digest("hex"):method(r)};return nodeMethod},createHmacOutputMethod=function(r,t){return function(n,s){return new HmacSha256(n,t,!0).update(s)[r]()}},createHmacMethod=function(r){var t=createHmacOutputMethod("hex",r);t.create=function(c){return new HmacSha256(c,r)},t.update=function(c,a){return t.create(c).update(a)};for(var n=0;n<OUTPUT_TYPES.length;++n){var s=OUTPUT_TYPES[n];t[s]=createHmacOutputMethod(s,r)}return t};function Sha256(r,t){t?(blocks[0]=blocks[16]=blocks[1]=blocks[2]=blocks[3]=blocks[4]=blocks[5]=blocks[6]=blocks[7]=blocks[8]=blocks[9]=blocks[10]=blocks[11]=blocks[12]=blocks[13]=blocks[14]=blocks[15]=0,this.blocks=blocks):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=r}Sha256.prototype.update=function(r){if(!this.finalized){var t,n=typeof r;if(n!=="string"){if(n==="object"){if(r===null)throw new Error(ERROR);if(ARRAY_BUFFER&&r.constructor===ArrayBuffer)r=new Uint8Array(r);else if(!Array.isArray(r)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(r)))throw new Error(ERROR)}else throw new Error(ERROR);t=!0}for(var s,c=0,a,l=r.length,d=this.blocks;c<l;){if(this.hashed&&(this.hashed=!1,d[0]=this.block,d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0),t)for(a=this.start;c<l&&a<64;++c)d[a>>2]|=r[c]<<SHIFT[a++&3];else for(a=this.start;c<l&&a<64;++c)s=r.charCodeAt(c),s<128?d[a>>2]|=s<<SHIFT[a++&3]:s<2048?(d[a>>2]|=(192|s>>6)<<SHIFT[a++&3],d[a>>2]|=(128|s&63)<<SHIFT[a++&3]):s<55296||s>=57344?(d[a>>2]|=(224|s>>12)<<SHIFT[a++&3],d[a>>2]|=(128|s>>6&63)<<SHIFT[a++&3],d[a>>2]|=(128|s&63)<<SHIFT[a++&3]):(s=65536+((s&1023)<<10|r.charCodeAt(++c)&1023),d[a>>2]|=(240|s>>18)<<SHIFT[a++&3],d[a>>2]|=(128|s>>12&63)<<SHIFT[a++&3],d[a>>2]|=(128|s>>6&63)<<SHIFT[a++&3],d[a>>2]|=(128|s&63)<<SHIFT[a++&3]);this.lastByteIndex=a,this.bytes+=a-this.start,a>=64?(this.block=d[16],this.start=a-64,this.hash(),this.hashed=!0):this.start=a}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Sha256.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var r=this.blocks,t=this.lastByteIndex;r[16]=this.block,r[t>>2]|=EXTRA[t&3],this.block=r[16],t>=56&&(this.hashed||this.hash(),r[0]=this.block,r[16]=r[1]=r[2]=r[3]=r[4]=r[5]=r[6]=r[7]=r[8]=r[9]=r[10]=r[11]=r[12]=r[13]=r[14]=r[15]=0),r[14]=this.hBytes<<3|this.bytes>>>29,r[15]=this.bytes<<3,this.hash()}},Sha256.prototype.hash=function(){var r=this.h0,t=this.h1,n=this.h2,s=this.h3,c=this.h4,a=this.h5,l=this.h6,d=this.h7,h=this.blocks,u,f,p,y,g,x,S,m,v,R,_;for(u=16;u<64;++u)g=h[u-15],f=(g>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,g=h[u-2],p=(g>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,h[u]=h[u-16]+f+h[u-7]+p<<0;for(_=t&n,u=0;u<64;u+=4)this.first?(this.is224?(m=300032,g=h[0]-1413257819,d=g-150054599<<0,s=g+24177077<<0):(m=704751109,g=h[0]-210244248,d=g-1521486534<<0,s=g+143694565<<0),this.first=!1):(f=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),p=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),m=r&t,y=m^r&n^_,S=c&a^~c&l,g=d+p+S+K[u]+h[u],x=f+y,d=s+g<<0,s=g+x<<0),f=(s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10),p=(d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7),v=s&r,y=v^s&t^m,S=d&c^~d&a,g=l+p+S+K[u+1]+h[u+1],x=f+y,l=n+g<<0,n=g+x<<0,f=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),p=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),R=n&s,y=R^n&r^v,S=l&d^~l&c,g=a+p+S+K[u+2]+h[u+2],x=f+y,a=t+g<<0,t=g+x<<0,f=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),p=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),_=t&n,y=_^t&s^R,S=a&l^~a&d,g=c+p+S+K[u+3]+h[u+3],x=f+y,c=r+g<<0,r=g+x<<0;this.h0=this.h0+r<<0,this.h1=this.h1+t<<0,this.h2=this.h2+n<<0,this.h3=this.h3+s<<0,this.h4=this.h4+c<<0,this.h5=this.h5+a<<0,this.h6=this.h6+l<<0,this.h7=this.h7+d<<0},Sha256.prototype.hex=function(){this.finalize();var r=this.h0,t=this.h1,n=this.h2,s=this.h3,c=this.h4,a=this.h5,l=this.h6,d=this.h7,h=HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[r&15]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[t&15]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[n&15]+HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[s&15]+HEX_CHARS[c>>28&15]+HEX_CHARS[c>>24&15]+HEX_CHARS[c>>20&15]+HEX_CHARS[c>>16&15]+HEX_CHARS[c>>12&15]+HEX_CHARS[c>>8&15]+HEX_CHARS[c>>4&15]+HEX_CHARS[c&15]+HEX_CHARS[a>>28&15]+HEX_CHARS[a>>24&15]+HEX_CHARS[a>>20&15]+HEX_CHARS[a>>16&15]+HEX_CHARS[a>>12&15]+HEX_CHARS[a>>8&15]+HEX_CHARS[a>>4&15]+HEX_CHARS[a&15]+HEX_CHARS[l>>28&15]+HEX_CHARS[l>>24&15]+HEX_CHARS[l>>20&15]+HEX_CHARS[l>>16&15]+HEX_CHARS[l>>12&15]+HEX_CHARS[l>>8&15]+HEX_CHARS[l>>4&15]+HEX_CHARS[l&15];return this.is224||(h+=HEX_CHARS[d>>28&15]+HEX_CHARS[d>>24&15]+HEX_CHARS[d>>20&15]+HEX_CHARS[d>>16&15]+HEX_CHARS[d>>12&15]+HEX_CHARS[d>>8&15]+HEX_CHARS[d>>4&15]+HEX_CHARS[d&15]),h},Sha256.prototype.toString=Sha256.prototype.hex,Sha256.prototype.digest=function(){this.finalize();var r=this.h0,t=this.h1,n=this.h2,s=this.h3,c=this.h4,a=this.h5,l=this.h6,d=this.h7,h=[r>>24&255,r>>16&255,r>>8&255,r&255,t>>24&255,t>>16&255,t>>8&255,t&255,n>>24&255,n>>16&255,n>>8&255,n&255,s>>24&255,s>>16&255,s>>8&255,s&255,c>>24&255,c>>16&255,c>>8&255,c&255,a>>24&255,a>>16&255,a>>8&255,a&255,l>>24&255,l>>16&255,l>>8&255,l&255];return this.is224||h.push(d>>24&255,d>>16&255,d>>8&255,d&255),h},Sha256.prototype.array=Sha256.prototype.digest,Sha256.prototype.arrayBuffer=function(){this.finalize();var r=new ArrayBuffer(this.is224?28:32),t=new DataView(r);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),r};function HmacSha256(r,t,n){var s,c=typeof r;if(c==="string"){var a=[],l=r.length,d=0,h;for(s=0;s<l;++s)h=r.charCodeAt(s),h<128?a[d++]=h:h<2048?(a[d++]=192|h>>6,a[d++]=128|h&63):h<55296||h>=57344?(a[d++]=224|h>>12,a[d++]=128|h>>6&63,a[d++]=128|h&63):(h=65536+((h&1023)<<10|r.charCodeAt(++s)&1023),a[d++]=240|h>>18,a[d++]=128|h>>12&63,a[d++]=128|h>>6&63,a[d++]=128|h&63);r=a}else if(c==="object"){if(r===null)throw new Error(ERROR);if(ARRAY_BUFFER&&r.constructor===ArrayBuffer)r=new Uint8Array(r);else if(!Array.isArray(r)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(r)))throw new Error(ERROR)}else throw new Error(ERROR);r.length>64&&(r=new Sha256(t,!0).update(r).array());var u=[],f=[];for(s=0;s<64;++s){var p=r[s]||0;u[s]=92^p,f[s]=54^p}Sha256.call(this,t,n),this.update(f),this.oKeyPad=u,this.inner=!0,this.sharedMemory=n}HmacSha256.prototype=new Sha256,HmacSha256.prototype.finalize=function(){if(Sha256.prototype.finalize.call(this),this.inner){this.inner=!1;var r=this.array();Sha256.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(r),Sha256.prototype.finalize.call(this)}};var exports=createMethod();exports.sha256=exports,exports.sha224=createMethod(!0),exports.sha256.hmac=createHmacMethod(),exports.sha224.hmac=createHmacMethod(!0),COMMON_JS?module.exports=exports:(root.sha256=exports.sha256,root.sha224=exports.sha224)})()})(sha256);var getRandomValues,rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&(getRandomValues=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!getRandomValues))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}const REGEX=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate(r){return typeof r=="string"&®EX.test(r)}var byteToHex=[];for(var i=0;i<256;++i)byteToHex.push((i+256).toString(16).substr(1));function stringify(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(byteToHex[r[t+0]]+byteToHex[r[t+1]]+byteToHex[r[t+2]]+byteToHex[r[t+3]]+"-"+byteToHex[r[t+4]]+byteToHex[r[t+5]]+"-"+byteToHex[r[t+6]]+byteToHex[r[t+7]]+"-"+byteToHex[r[t+8]]+byteToHex[r[t+9]]+"-"+byteToHex[r[t+10]]+byteToHex[r[t+11]]+byteToHex[r[t+12]]+byteToHex[r[t+13]]+byteToHex[r[t+14]]+byteToHex[r[t+15]]).toLowerCase();if(!validate(n))throw TypeError("Stringified UUID is invalid");return n}function v4(r,t,n){r=r||{};var s=r.random||(r.rng||rng)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,t){n=n||0;for(var c=0;c<16;++c)t[n+c]=s[c];return t}return stringify(s)}async function getBytes(r,t){const n=r.getReader();let s;for(;!(s=await n.read()).done;)t(s.value)}function getLines(r){let t,n,s,c=!1;return function(l){t===void 0?(t=l,n=0,s=-1):t=concat(t,l);const d=t.length;let h=0;for(;n<d;){c&&(t[n]===10&&(h=++n),c=!1);let u=-1;for(;n<d&&u===-1;++n)switch(t[n]){case 58:s===-1&&(s=n-h);break;case 13:c=!0;case 10:u=n;break}if(u===-1)break;r(t.subarray(h,u),s),h=n,s=-1}h===d?t=void 0:h!==0&&(t=t.subarray(h),n-=h)}}function getMessages(r,t,n){let s=newMessage();const c=new TextDecoder;return function(l,d){if(l.length===0)n==null||n(s),s=newMessage();else if(d>0){const h=c.decode(l.subarray(0,d)),u=d+(l[d+1]===32?2:1),f=c.decode(l.subarray(u));switch(h){case"data":s.data=s.data?s.data+`
|
|
2
|
-
`+f:f;break;case"event":s.event=f;break;case"id":r(s.id=f);break;case"retry":const p=parseInt(f,10);isNaN(p)||t(s.retry=p);break}}}}function concat(r,t){const n=new Uint8Array(r.length+t.length);return n.set(r),n.set(t,r.length),n}function newMessage(){return{data:"",event:"",id:"",retry:void 0}}var __rest=function(r,t){var n={};for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&t.indexOf(s)<0&&(n[s]=r[s]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var c=0,s=Object.getOwnPropertySymbols(r);c<s.length;c++)t.indexOf(s[c])<0&&Object.prototype.propertyIsEnumerable.call(r,s[c])&&(n[s[c]]=r[s[c]]);return n};const EventStreamContentType="text/event-stream",DefaultRetryInterval=1e3,LastEventId="last-event-id";function fetchEventSource(r,t){var{signal:n,headers:s,onopen:c,onmessage:a,onclose:l,onerror:d,openWhenHidden:h,fetch:u}=t,f=__rest(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((p,y)=>{const g=Object.assign({},s);g.accept||(g.accept=EventStreamContentType);let x;function S(){x.abort(),document.hidden||T()}h||document.addEventListener("visibilitychange",S);let m=DefaultRetryInterval,v=0;function R(){document.removeEventListener("visibilitychange",S),window.clearTimeout(v),x.abort()}n==null||n.addEventListener("abort",()=>{R(),p()});const _=u??window.fetch,U=c??defaultOnOpen;async function T(){var k;x=new AbortController;try{const A=await _(r,Object.assign(Object.assign({},f),{headers:g,signal:x.signal}));await U(A),await getBytes(A.body,getLines(getMessages(b=>{b?g[LastEventId]=b:delete g[LastEventId]},b=>{m=b},a))),l==null||l(),R(),p()}catch(A){if(!x.signal.aborted)try{const b=(k=d==null?void 0:d(A))!==null&&k!==void 0?k:m;window.clearTimeout(v),v=window.setTimeout(T,b)}catch(b){R(),y(b)}}}T()})}function defaultOnOpen(r){const t=r.headers.get("content-type");if(!(t!=null&&t.startsWith(EventStreamContentType)))throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${t}`)}function Base64EncodeUrl(r){return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function getTimestamp(){return Math.floor(Date.now()/1e3)}function e(r){this.message=r}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r$1=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(r){var t=String(r).replace(/=+$/,"");if(t.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,s,c=0,a=0,l="";s=t.charAt(a++);~s&&(n=c%4?64*n+s:s,c++%4)?l+=String.fromCharCode(255&n>>(-2*c&6)):0)s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(s);return l};function t$1(r){var t=r.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(n){return decodeURIComponent(r$1(n).replace(/(.)/g,function(s,c){var a=c.charCodeAt(0).toString(16).toUpperCase();return a.length<2&&(a="0"+a),"%"+a}))}(t)}catch{return r$1(t)}}function n$1(r){this.message=r}function o(r,t){if(typeof r!="string")throw new n$1("Invalid token specified");var n=(t=t||{}).header===!0?0:1;try{return JSON.parse(t$1(r.split(".")[n]))}catch(s){throw new n$1("Invalid token specified: "+s.message)}}n$1.prototype=new Error,n$1.prototype.name="InvalidTokenError";class NylasSessions{constructor(t){w(this,"clientId");w(this,"redirectUri");w(this,"accessType","online");w(this,"domain","http://api.nylas.com");w(this,"versioned",!1);w(this,"Storage");w(this,"hosted",!1);w(this,"multiAccount",!1);w(this,"loginId","");if(this.clientId=t.clientId,this.redirectUri=t.redirectUri,t.domain&&(this.domain=t.domain,this.domain.substring(this.domain.length-3).includes("/v")&&(this.versioned=!0)),t.multiAccount&&(this.multiAccount=t.multiAccount),t.sw){const n=new IndexedDBStorage;this.Storage=new Storage(n)}else this.Storage=new Storage;t.accessType&&(this.accessType=t.accessType),t.loginId&&(this.loginId=t.loginId),t.hosted&&(this.hosted=t.hosted),this.codeExchange(null)}async validateAccessToken(t=""){const n=await this.Storage.getGrant(t,this.multiAccount);if(!n)return!1;const{access_token:s}=n;try{return!!(await(await fetch(`${this.domain}/connect/tokeninfo?access_token=${s}`,{method:"GET"})).json()).data}catch{return!1}}async validateIDToken(t=""){const n=await this.Storage.getGrant(t,this.multiAccount);if(!n)return!1;const{id_token:s}=n;try{const c=await fetch(`${this.domain}/connect/tokeninfo?id_token=${s}`,{method:"GET"});return!(c.status!==200||!(await c.json()).data)}catch{return!1}}getDomain(){return this.domain}async auth(t){this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))&&await this.hostedSetCodeChallenge();const n=await this.generateAuthURL(t);if(t.popup){this.popUp(n);return}return n}async generateAuthURL(t){const n=await this.getCodeChallege();let s=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;return n&&(s+=`&code_challenge=${n}&code_challenge_method=S256&options=rotate_refresh_token`),t.provider&&(s+=`&provider=${t.provider}`),t.loginHint&&(s+=`&login_hint=${t.loginHint}`,t.includeGrantScopes&&(s+=`&include_grant_scopes=${t.includeGrantScopes}`)),t.scope&&(s+=`&scope=${t.scope.join(" ")}`),t.prompt&&(s+=`&prompt=${t.prompt}`),t.metadata&&(s+=`&metadata=${t.metadata}`),(t.state||this.loginId)&&(s+=`&state=${this.loginId?this.loginId:t.state}`),s}async generateReauthURL(t,n){if(!t)throw new Error("Grant ID is required");const s=await this.Storage.getUserToken(t),c=await this.getCodeChallege();let a=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;return c&&(a+=`&code_challenge=${c}&code_challenge_method=S256&options=rotate_refresh_token`),s!=null&&s.provider&&(a+=`&provider=${s.provider}`),s!=null&&s.email&&(a+=`&login_hint=${s.email}`),n&&(a+=`&scope=${n.join(" ")}`),a}async generateCodeChallenge(){if(await this.Storage.getPKCE())return;const n=v4();this.Storage.setPKCE(n)}async hostedSetCodeChallenge(){if(!this.hosted)throw console.error("Method only used with hosted flag enabled");const n=new URLSearchParams(window.location.search).get("code_challenge");if(!n){if(await this.Storage.getPKCE())return;console.warn("Code challenge is recomended");return}this.Storage.setPKCE(n)}async getCodeChallege(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))){const s=new URLSearchParams(window.location.search).get("code_challenge");return s||(console.warn("Code challenge is recomended"),"")}const t=await this.Storage.getPKCE();if(t){const n=sha256.exports.sha256(t);let s=index.Buffer.from(n).toString("base64");return s=Base64EncodeUrl(s),s}return""}async isLoggedIn(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin)))return!1;const t=await this.Storage.getUserTokens();return t&&t.length>0?(this.multiAccount&&await this.generateCodeChallenge(),!0):(await this.generateCodeChallenge(),!1)}isMultiAccount(){return this.multiAccount}async logout(){const t=await this.getProfile();await this.Storage.clearSession();const n={detail:t};window.dispatchEvent(new CustomEvent("onLogoutSuccess",n))}async getProfile(t=""){let n;return t?n=await this.Storage.getUserToken(t):n=await this.Storage.getUserToken(),n||null}async getProfiles(){const t=await this.Storage.getUserTokens();return t||null}async removeProfile(t){return await this.Storage.removeUserToken(t),await this.Storage.removeGrant(t),null}async authIMAP(t){const n=await this.getCodeChallege(),s={imap_username:t.username,imap_password:t.password,imap_host:t.hostIMAP,imap_port:t.portIMAP,type:t.type,smtp_host:t.hostSMTP,smtp_port:t.portSMTP,provider:t.provider,redirect_uri:this.redirectUri,state:t.state,public_application_id:this.clientId,access_type:this.accessType};return this.loginId&&(s.id=this.loginId),n!=""&&(s.code_challenge=n,s.code_challenge_method="S256"),await(await fetch(`${this.domain}/connect/login/imap`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(s)})).json()}async authEWS(t){const n=await this.getCodeChallege(),s={...t,redirect_uri:this.redirectUri,public_application_id:this.clientId,access_type:this.accessType};return this.loginId&&(s.id=this.loginId),n!=""&&(s.code_challenge=n,s.code_challenge_method="S256"),await(await fetch(`${this.domain}/connect/login/ews`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(s)})).json()}async detectEmail(t){return(await(await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/providers/detect?client_id=${this.clientId}&email=${t}`,{method:"POST",headers:new Headers({"content-type":"application/json"})})).json()).data}async applicationInfo(){return(await(await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/applications?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})})).json()).data}async getAvailableProviders(){const t=await fetch(`${this.domain}/connect/providers/find?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});return t?(await t.json()).data:null}onLoginSuccess(t){window.addEventListener("onLoginSuccess",n=>t(n))}onLogoutSuccess(t){window.addEventListener("onLogoutSuccess",n=>t(n))}onLoginFail(t){window.addEventListener("onLoginFail",n=>t(n))}onTokenRefreshSuccess(t){window.addEventListener("onTokenRefreshSuccess",n=>t(n))}onTokenRefreshFail(t){window.addEventListener("onTokenRefreshFail",n=>t(n))}onSessionExpired(t){window.addEventListener("onSessionExpired",n=>t(n))}async codeExchange(t){let n=new URLSearchParams(window.location.search);t&&(n=new URLSearchParams(t));const s=n.get("code"),c=n.get("state"),a=n.get("error"),l=n.get("error_description"),d=n.get("error_code");if(a&&l&&d){const u={detail:{error:a,error_description:l,error_code:d}};return window.dispatchEvent(new CustomEvent("onLoginFail",u)),window.history.pushState({},document.title,window.location.pathname),!1}if(!s)return console.warn("No code found"),!1;if(window.opener&&window.name==="uas-popup")return console.warn("Popup window detected"),!1;const h=await this.Storage.getPKCE();if(!h)return console.warn("No code verifier found"),!1;try{const u={client_id:this.clientId,redirect_uri:this.redirectUri,code:s,grant_type:"authorization_code",code_verifier:h},p=await(await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(u)})).json();if(p){if(p.error){const g={detail:p};return window.dispatchEvent(new CustomEvent("onLoginFail",g)),!0}const y=await this.handleCodeExchangeResponse(p);if(y.valid){c&&(y.data.state=c);const g={detail:y.data};window.dispatchEvent(new CustomEvent("onLoginSuccess",g)),window.history.pushState({},document.title,window.location.pathname)}else{const g={detail:y.data};return window.dispatchEvent(new CustomEvent("onLoginFail",g)),!0}}return this.Storage.removePKCE(),!0}catch(u){const f={detail:u};return window.dispatchEvent(new CustomEvent("onLoginFail",f)),window.history.pushState({},document.title,window.location.pathname),!1}}async tokenExchange(t=""){const n=await this.Storage.getGrant(t,this.multiAccount);if(!n)return!1;const s=n.refresh_token;try{const c={client_id:this.clientId,redirect_uri:this.redirectUri,refresh_token:s,grant_type:"refresh_token"},l=await(await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(c)})).json();if(l){if(l.error){const f={detail:l};return window.dispatchEvent(new CustomEvent("onTokenRefreshFail",f)),!0}const d=getTimestamp();if(l.expires_in=d+l.expires_in,this.Storage.setGrant(l,this.multiAccount),!await this.validateIDToken(t)){const f={detail:l};return window.dispatchEvent(new CustomEvent("onTokenRefreshFail",f)),!0}const u={detail:l};return window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess",u)),!0}this.Storage.removePKCE()}catch(c){const a={detail:c};return window.dispatchEvent(new CustomEvent("onTokenRefreshFail",a)),!1}}async handleCodeExchangeResponse(t){if(t.error)return{data:t,valid:!1};const s=getTimestamp();t.expires_in=s+t.expires_in,this.Storage.setGrant(t,this.multiAccount);const c=o(t.id_token);return c.status="authenticated",this.Storage.setUserToken(c),await this.validateIDToken(c.sub)?{data:t,valid:!0}:{data:t,valid:!1}}async popUp(t){const c=window.screenX+(window.outerWidth-500)/2,a=window.screenY+(window.outerHeight-600)/2.5,l="uas-popup",d=t,h=window.open(d,l,`width=500,height=600,left=${c},top=${a}`);if(!h)return;const u=setInterval(async()=>{if(h.closed){const f={detail:{error_description:"OAuth provider window closed"}};window.dispatchEvent(new CustomEvent("onLoginFail",f)),u&&clearInterval(u);return}try{const f=h.location.href.split("?");if(!f[0])return;const p=h.location.search;if(h.history.pushState({},document.title,window.location.pathname),f[0]===this.redirectUri&&f.length>1){const y=await this.codeExchange(p);h.close(),y&&location.reload(),u&&clearInterval(u);return}}catch{return}},1e3)}async getAccessToken(t=""){const n=getTimestamp(),s=await this.Storage.getGrant(t,this.multiAccount);if(!s)return null;const{access_token:c,expires_in:a}=s,l=c;return l&&a&&a>getTimestamp()&&a-n>30?l:(await this.tokenExchange(t),(await this.Storage.getGrant(t,this.multiAccount)).access_token)}async sse(t,n){const s=n.headers||{},c=s["Grant-ID"];let a="";if(this.multiAccount){if(!c)throw this.logout(),new Error("Grant ID is required for multi account calls");a=await this.getAccessToken(c)}else a=await this.getAccessToken();return delete s["Grant-ID"],s.Authorization=`Bearer ${a}`,s["content-type"]||(s["content-type"]="application/json"),fetchEventSource(`${this.domain}/${t}`,{...n,headers:s})}async fetch(t,n,s=!0,c){let a="",l=1;if(this.multiAccount){if(!n.grant_id)throw this.logout(),new Error("Grant ID is required for multi account calls");const h=await this.getProfiles();l=h?h.length:1,a=await this.getAccessToken(n.grant_id)}else a=await this.getAccessToken();if(!a)throw new Error("Access token not found");let d=n.headers;Headers.prototype.isPrototypeOf(d)?(d.append("Authorization",`Bearer ${a}`),d.has("content-type")||d.append("content-type","application/json")):d=new Headers({Authorization:`Bearer ${a}`,"content-type":"application/json"});try{n!=null&&n.body&&(n.body=JSON.stringify(n==null?void 0:n.body));const h=await fetch(`${c||this.domain}/${t}`,{...n,headers:d});if(!s)return h;const u=await(h==null?void 0:h.json());if(!await this.isAuthenticatedResponse(h.status,u)){if(l>1){const p=await this.getProfile(n.grant_id);if(p){p.status="unauthorized",await this.Storage.setUserToken(p);const y={detail:{user:p}};window.dispatchEvent(new CustomEvent("onSessionExpired",y))}}else{const y={detail:{user:await this.Storage.getUserToken()}};window.dispatchEvent(new CustomEvent("onSessionExpired",y))}this.logout();return}return u}catch(h){throw h}}async fetchRequest(t,n,s,c=!0,a,l){const d=await this.isLoggedIn(),h=new URL(t,a??this.domain),u=new Headers;if(u.append("Accept","application/json"),u.append("Content-Type","application/json"),u.append("User-Agent","nylas-identity"),d){const y=await this.getAccessToken();u.append("Authorization",`Bearer ${y}`)}const f=await fetch(h.toString(),{method:n||"GET",headers:u,mode:"cors",referrer:location.origin,body:s?JSON.stringify(s):void 0,...l||{}});return c?await f.json():f.body}async isAuthenticatedResponse(t,n){var s;return!(t==401&&((s=n==null?void 0:n.error)==null?void 0:s.type)=="token.unauthorized_access")}addAPIKey(t,n,s){this.Storage.setUserToken({aud:"https://api-staging.us.nylas.com/",exp:2e9,email_verified:!0,iat:getTimestamp(),iss:"",email:n,provider:"virtual-calendar",status:"authenticated",name:n,sub:t}),this.Storage.setGrant({grant_id:t,access_token:s,expires_in:2e9},this.multiAccount)}}var B={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,D={};function E(r,t,n){this.props=r,this.context=t,this.refs=D,this.updater=n||B}E.prototype.isReactComponent={};E.prototype.setState=function(r,t){if(typeof r!="object"&&typeof r!="function"&&r!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,r,t,"setState")};E.prototype.forceUpdate=function(r){this.updater.enqueueForceUpdate(this,r,"forceUpdate")};function F(){}F.prototype=E.prototype;function G(r,t,n){this.props=r,this.context=t,this.refs=D,this.updater=n||B}var H=G.prototype=new F;H.constructor=G;C(H,E.prototype);H.isPureReactComponent=!0;const LoginRequired=({authenticationUrl:r})=>index.h("div",{class:"login-required"},index.h("div",{class:"card"},index.h("p",null,"Log into your account to use the Scheduler Editor."),index.h("button",{class:"google-button",onClick:async t=>{t.preventDefault();const n=await r("google");n?window.location.href=n:console.error("[nylas-scheduler-editor] Unable to get authentication URL.")}},index.h("span",{class:"icon"},index.h("google-logo-icon",{width:"15",height:"15"})),"Continue with Google"),index.h("button",{class:"microsoft-button",onClick:async t=>{t.preventDefault();const n=await r("microsoft");n?window.location.href=n:console.error("[nylas-scheduler-editor] Unable to get authentication URL.")}},index.h("span",{class:"icon"},index.h("microsoft-logo-icon",{width:"15",height:"15"})),"Continue with Microsoft"),index.h("button",{class:"other-provider-button",onClick:async t=>{t.preventDefault();const n=await r();n?window.location.href=n:console.error("[nylas-scheduler-editor] Unable to get authentication URL.")}},"View all providers ",index.h("chevron-icon",{width:"17",height:"17"})),index.h("small",{class:"disclaimer-text"},"* You will be redirected to authenticate your account."))),ExpressFlow=()=>index.h(index.Fragment,null,index.h("nylas-event-info",null,index.h("div",{slot:"inputs"},index.h("nylas-event-title",null),index.h("nylas-event-duration",null),index.h("nylas-event-location",null))),index.h("nylas-booking-calendar-picker",null)),nylasSchedulerEditorCss=':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 0px 6px -2px rgba(0, 0, 0, 0.05), 0px 5px 15px -3px rgba(0, 0, 0, 0.1);--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif}@media screen and (max-width: 768px){:host{width:auto;min-width:325px}}div.scheduler-editor-header{display:flex;align-items:center;justify-content:space-between;padding:1rem;border-bottom:1px solid var(--nylas-base-200);color:var(--nylas-base-900)}div.scheduler-editor-header h1.scheduler-editor-title{display:flex;align-items:center;gap:0.5rem;width:858px;margin:0;font-size:18px;line-height:24px;font-weight:600}@media screen and (max-width: 768px){div.scheduler-editor-header h1.scheduler-editor-title{width:auto;min-width:calc(325px - 1rem)}}div.scheduler-editor-header button{background:transparent;border:none;cursor:pointer}div.scheduler-editor-header button:hover,div.scheduler-editor-header button:active{color:var(--nylas-primary)}div.scheduler-editor-header button:disabled{cursor:not-allowed}nylas-editor-tabs{width:auto}nylas-editor-tabs nylas-event-info div[slot=inputs],nylas-editor-tabs nylas-event-limits div[slot=inputs]{display:flex;flex-direction:column;gap:1rem}.card{display:flex;flex-direction:column;padding:2rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;max-width:fit-content;align-self:center}.login-required{height:554px;overflow-y:auto;display:flex;flex-direction:column;justify-content:center;padding:2rem 1rem;background-color:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}@media screen and (max-width: 768px){.login-required{height:auto}}.login-required p{margin:0 0 1rem}.login-required .microsoft-button,.login-required .google-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:1rem;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;margin-bottom:1rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;justify-content:center;gap:0.5rem;align-items:center}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:1rem;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;border:0;background-color:var(--nylas-base-0);height:48px;margin-bottom:1rem;font-size:0.95rem;justify-content:center;gap:0.25rem;align-items:center}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button svg{transform:rotate(180deg)}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .disclaimer-text{font-size:0.75rem;color:var(--nylas-base-600);align-self:center}.list-configurations{padding:2rem;height:554px;background:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}@media screen and (max-width: 768px){.list-configurations{height:auto}}.list-configurations nylas-list-configurations{height:inherit;display:flex;flex-direction:column}',NylasSchedulerEditorStyle0=nylasSchedulerEditorCss,NylasSchedulerEditor=class{constructor(r){index.registerInstance(this,r),this.init=index.createEvent(this,"init",7),this.loggedIn=index.createEvent(this,"loggedIn",7),this.loggedOut=index.createEvent(this,"loggedOut",7),this.schedulerConfigCloseClicked=index.createEvent(this,"schedulerConfigCloseClicked",7),this.handleSchedulerConfigCloseClicked=t=>{this.schedulerConfigCloseClicked.emit(this.host).defaultPrevented||(localStorage.removeItem("grant"),localStorage.removeItem("user"),window.location.reload())},this.authenticationUrl=async t=>this.nylasApiRequest?await this.nylasApiRequest.authenticationUrl({provider:t})||"":(console.error("[nylas-scheduler-editor] Nylas API Request is not initialized."),""),this.configurationId=void 0,this.nylasApiRequest=void 0,this.nylasSessionsConfig=void 0,this.defaultAuthArgs=void 0,this.eventOverrides={},this.schedulerPreviewLink="",this.defaultSchedulerConfigState=void 0,this.mode="app",this.additionalParticipants=void 0,this.automaticComponentRegistration=!0}connectedCallback(){index.debug("[nylas-scheduler-editor] connectedCallback")}async componentWillLoad(){var n,s,c,a,l,d,h;if(index.debug("[nylas-scheduler-editor] componentWillLoad"),this.stores={schedulerConfig:schedulerConfigStore4a50a03d.CreateNylasSchedulerConfigStore({...this.defaultSchedulerConfigState,additionalParticipants:this.additionalParticipants})},!this.nylasApiRequest&&this.nylasSessionsConfig){const u=new NylasSessions(this.nylasSessionsConfig);await u.isLoggedIn(),u.onLoginSuccess(async()=>{var p,y;const f=await((y=(p=this.nylasSchedulerConfigConnector)==null?void 0:p.schedulerConfig)==null?void 0:y.currentUser());f&&(this.loggedIn.emit(this.host),this.loggedInHandler(f))}),u.onLoginFail(async()=>{var f,p;(p=(f=this.stores)==null?void 0:f.schedulerConfig)==null||p.set("currentUser",null),this.loggedOut.emit(this.host)}),this.nylasApiRequest=new index.NylasIdentityRequestWrapper(u)}this.nylasApiRequest&&this.defaultAuthArgs&&this.nylasApiRequest.setDefaultAuthArgs(this.defaultAuthArgs),this.baseProvider=new index_es9cc0eb3c.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);const r=this.baseProvider.getStore("schedulerConfig");if(this.nylasSchedulerConfigConnector=new NylasSchedulerConfigConnector({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:r}),!this.init.emit(this.host).defaultPrevented){const u=await((s=(n=this.nylasSchedulerConfigConnector)==null?void 0:n.schedulerConfig)==null?void 0:s.currentUser());u?(this.loggedIn.emit(this.host),await this.loggedInHandler(u)):((a=(c=this.stores)==null?void 0:c.schedulerConfig)==null||a.set("currentUser",null),this.loggedOut.emit(this.host))}(d=(l=this.stores)==null?void 0:l.schedulerConfig)==null||d.onChange("selectedConfiguration",async u=>{u&&u.id&&(this.configurationId=u.id)}),(h=this.baseProvider)==null||h.componentWillLoad(this.nylasSchedulerConfigConnector)}async componentDidLoad(){var r;index.debug("[nylas-scheduler-editor] componentDidLoad"),(r=this.baseProvider)==null||r.componentDidLoad()}componentDisconnected(){var r;(r=this.baseProvider)==null||r.componentDisconnected()}async configurationIdChanged(r){var t,n,s,c,a,l,d,h;r?(await((n=(t=this.nylasSchedulerConfigConnector)==null?void 0:t.schedulerConfig)==null?void 0:n.getConfigurationById(r)),(c=(s=this.stores)==null?void 0:s.schedulerConfig)==null||c.set("action","edit")):((l=(a=this.stores)==null?void 0:a.schedulerConfig)==null||l.set("selectedConfiguration",{}),(h=(d=this.stores)==null?void 0:d.schedulerConfig)==null||h.set("action",null))}async store(){var r;return(r=this.stores)==null?void 0:r.schedulerConfig}async schedulerConnector(){return this.nylasSchedulerConfigConnector}async registerComponentHandler(r){var t;(t=this.baseProvider)==null||t.registerComponent(r.detail)}async unregisterComponentHandler(r){var t;(t=this.baseProvider)==null||t.unregisterComponent(r.detail)}async loggedInHandler(r){var t,n,s,c,a,l,d;if((n=(t=this.stores)==null?void 0:t.schedulerConfig)==null||n.set("currentUser",r),!!this.nylasSchedulerConfigConnector){if(this.configurationId){const h=await((s=this.nylasSchedulerConfigConnector.schedulerConfig)==null?void 0:s.getConfigurationById(this.configurationId));h&&((c=h[0])!=null&&c.id)&&((l=(a=this.stores)==null?void 0:a.schedulerConfig)==null||l.set("action","edit"))}await((d=this.nylasSchedulerConfigConnector.schedulerConfig)==null?void 0:d.getCalendars())}}render(){var r,t,n,s,c,a,l,d;return index.h(index.Host,{key:"9cff01340fae6ec631ddeaa1656eeedc47af9179"},index.h("div",{key:"1c79bfbdf35dd6a1ebb7624d4b9f660e6e5acf14",class:"scheduler-editor-header",part:"nse__header"},index.h("h1",{key:"cc5b67f761d7f00ad88ec0d22a983d9e72634df2",class:"scheduler-editor-title",part:"nse__title"},index.h("calendar-icon",{key:"730375a8d474dc546a33e6fd264b51576562292c",width:"18",height:"18"}),"Scheduler editor"),index.h("button",{key:"41b1c5604d6f4c4e6c057f69241e4aab92682396",class:"scheduler-editor-close",title:"logout",onClick:h=>this.handleSchedulerConfigCloseClicked(h),part:"nse__close-button"},index.h("close-icon",{key:"09f961c3ab6601edf9bfbc89b97bd7fdbff90a6b",width:"18",height:"18"}))),((t=(r=this.stores)==null?void 0:r.schedulerConfig)==null?void 0:t.state.currentUser)&&this.stores.schedulerConfig.state.action===null&&index.h("div",{class:"list-configurations"},index.h("nylas-list-configurations",null)),((s=(n=this.stores)==null?void 0:n.schedulerConfig)==null?void 0:s.state.currentUser)&&this.stores.schedulerConfig.state.action==="create"&&index.h("nylas-editor-tabs",{mode:"composable"},index.h(ExpressFlow,null)),((a=(c=this.stores)==null?void 0:c.schedulerConfig)==null?void 0:a.state.currentUser)&&this.stores.schedulerConfig.state.action==="edit"&&index.h("nylas-editor-tabs",{mode:this.mode},this.mode==="composable"&&index.h("slot",null)),!((d=(l=this.stores)==null?void 0:l.schedulerConfig)!=null&&d.state.currentUser)&&index.h("slot",{name:"login-required"},index.h(LoginRequired,{authenticationUrl:this.authenticationUrl})))}get host(){return index.getElement(this)}static get watchers(){return{configurationId:["configurationIdChanged"]}}};NylasSchedulerEditor.style=NylasSchedulerEditorStyle0;exports.nylas_scheduler_editor=NylasSchedulerEditor;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-e3e9b594.cjs"),m=require("./index.es-9cc0eb3c-0c99c055.cjs"),y=require("./scheduler-store-f02ce045-42e3647c.cjs");require("react");require("react-dom");class C{constructor({schedulerAPIURL:e,nylasSchedulerStore:o,sessionId:i,configId:s}){if(!e)throw new Error("schedulerAPIURL is required");if(!o)throw new Error("nylasSchedulerStore is required");if(!i&&!s)throw new Error("sessionId is required for private configs, if not config id is required for public configs");e==="/"&&(e=new URL(window.location.href).origin),this.configId=s,this.sessionId=i,this.schedulerAPIURL=e,this.nylasSchedulerStore=o}init(){t.debug("NylasConnector init")}get schedulerStore(){return this.nylasSchedulerStore}get scheduler(){return this._schedulerAPIConnector?this._schedulerAPIConnector:(this._schedulerAPIConnector=new y.NylaSchedulerAPIConnector({schedulerAPIURL:this.schedulerAPIURL,schedulerStore:this.schedulerStore,sessionId:this.sessionId,configId:this.configId}),this._schedulerAPIConnector)}resetStores(){this.nylasSchedulerStore.reset()}}const b=(n,e)=>{const o=n.isLoading,i=n.showNotification,s=n.nylasBranding;return t.h(t.Fragment,null,i&&t.h("nylas-notification",null),o&&t.h("div",{class:"loading"},t.h("div",{class:"left"},t.h("div",{class:"skeleton"})),t.h("div",{class:"right"},t.h("div",{class:"skeleton"}),t.h("div",{class:"skeleton"}),t.h("div",{class:"skeleton"}),t.h("div",{class:"skeleton"}),t.h("div",{class:"skeleton"}))),!o&&e,t.h("div",{class:"footer"},s&&t.h(t.Fragment,null,"Powered by ",t.h("nylas-logo",null))))},x=(n,e)=>t.h("div",{class:"message-banner"},e),E=':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 6px -2px rgba(0, 0, 0, 0.05), 0px 10px 15px -3px rgba(0, 0, 0, 0.1);--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;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-top:1rem}.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,.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{background-color:var(--nylas-base-50)}.cancelled-event-page,.cancel-flow-page{padding:1rem;height:496px;display:flex;justify-content:center;align-items:center}.booked-event-page,.cancelled-event-page,.cancel-flow-page{min-width:784px;background:var(--nylas-base-50)}@media screen and (max-width: 768px){.booked-event-page,.cancelled-event-page,.cancel-flow-page{min-width:90%}}.left-panel{display:flex;flex-direction:column;min-width:384px;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{padding:0.5rem 4px 0;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}@media screen and (max-width: 768px){.right-panel{border-top-right-radius:0px;width:inherit;min-width:unset;height:auto}}.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:496px}@media screen and (max-width: 768px){nylas-selected-event-card{height:250px}}.footer{display:flex;justify-content:flex-end;align-items:center;padding:16px;font-size:14px;font-weight:300;color:var(--nylas-base-500);border-top:1px solid var(--nylas-base-200);min-height:24px}.footer svg{fill:var(--nylas-base-500)}.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;position:absolute}nylas-locale-switch{position:absolute;padding:18px 20px;bottom:0;width:-webkit-fill-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}',D=E,I={title:"Something went wrong...",type:m.nr.Error,category:y.ErrorCategory.Component},w=class{constructor(n){t.registerInstance(this,n),this.init=t.createEvent(this,"init",7),this.schedulerWillLoad=t.createEvent(this,"schedulerWillLoad",7),this.schedulerDidLoad=t.createEvent(this,"schedulerDidLoad",7),this.nylasSchedulerError=t.createEvent(this,"nylasSchedulerError",7),this.bookingRefExtracted=t.createEvent(this,"bookingRefExtracted",7),this.mode="app",this.defaultSchedulerState=void 0,this.sessionId=void 0,this.schedulerApiUrl="https://api.us.nylas.com",this.bookingInfo=void 0,this.rescheduleBookingRef=void 0,this.cancelBookingRef=void 0,this.configurationId=void 0,this.nylasBranding=!0,this.eventOverrides={},this.isLoading=void 0,this.themeConfig=void 0,this.showNotification=!0,this.automaticComponentRegistration=!0,this.selectedDateLabel=new Date().toLocaleDateString(void 0,{dateStyle:"full"})||"No date selected",this.refConfigId=void 0}connectedCallback(){t.debug("[nylas-scheduler] connectedCallback")}async componentWillLoad(){var o,i;if(t.debug("[nylas-scheduler] Component will load"),this.schedulerWillLoad.emit(this.host).defaultPrevented)return;if(this.stores={scheduler:y.CreateNylasSchedulerStore({bookingInfo:this.bookingInfo,nylasBranding:this.nylasBranding,...this.defaultSchedulerState})},this.baseProvider=new m.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides),this.refConfigId=this.configurationId,this.rescheduleBookingRef){const[s,a]=t.compactStringToUUIDs(this.rescheduleBookingRef);this.refConfigId=s,this.stores.scheduler.set("rescheduleBookingId",a),this.bookingRefExtracted.emit({configurationId:s,bookingId:a})}else if(this.cancelBookingRef){const[s,a]=t.compactStringToUUIDs(this.cancelBookingRef);this.refConfigId=s,this.stores.scheduler.set("cancelBookingId",a),this.bookingRefExtracted.emit({configurationId:s,bookingId:a})}if(!this.checkIfSessionIdOrConfigIdExists())return;const e=(o=this.baseProvider)==null?void 0:o.getStore("scheduler");if(this.nylasSchedulerConnector=new C({schedulerAPIURL:this.schedulerApiUrl,sessionId:this.sessionId,configId:this.refConfigId,nylasSchedulerStore:e}),this.init.emit(this.host),(i=this.baseProvider)==null||i.componentWillLoad(this.nylasSchedulerConnector),this.themeConfig)for(const[s,a]of Object.entries(this.themeConfig))this.host.style.setProperty(`${s}`,a)}async componentDidLoad(){var d,l,h,g,c,v,k;if((d=this.baseProvider)==null||d.componentDidLoad(),!this.checkIfSessionIdOrConfigIdExists())return;const n=await((l=this.nylasSchedulerConnector)==null?void 0:l.scheduler.getUISettings());(!n||"error"in n)&&this.nylasSchedulerError.emit({...this.getErrorObject(n==null?void 0:n.error)});const e=(h=this.baseProvider)==null?void 0:h.getStore("scheduler"),o=(c=(g=e==null?void 0:e.get("configSettings"))==null?void 0:g.scheduler)==null?void 0:c.available_days_in_future,i=e==null?void 0:e.get("selectedTimeslot");if(i&&(i!=null&&i.start_time)){if(!this.isTimeslotValid(i))return;if(e!=null&&e.get("showBookingForm")){e==null||e.set("selectedDate",i.start_time);return}}const s=e==null?void 0:e.get("selectedDate"),a=e==null?void 0:e.get("availability");let r;if(!(a&&a.length>0)){if(s){const{startTime:u,endTime:f,endTimeForAvailableDaysInFuture:p}=this.validateAvailableDaysInFuture(s,o||30);s.getTime()<p*1e3&&(r=await((k=this.nylasSchedulerConnector)==null?void 0:k.scheduler.getAvailability(u,f)))}else{const u=new Date,{startTime:f,endTime:p,endTimeForAvailableDaysInFuture:_}=this.validateAvailableDaysInFuture(u,o||30);u.getTime()<_*1e3&&(r=await((v=this.nylasSchedulerConnector)==null?void 0:v.scheduler.getAvailability(f,p)))}if((!r||"error"in r)&&this.nylasSchedulerError.emit({...this.getErrorObject(r==null?void 0:r.error)}),!s){let u=new Date;const f=e==null?void 0:e.get("availability").find(p=>new Date(p.start_time)>new Date);f&&(u=f.start_time),e==null||e.set("selectedDate",u)}}}componentDisconnected(){var n;(n=this.baseProvider)==null||n.componentDisconnected()}bookingInfoChanged(n){var e;(e=this.stores)==null||e.scheduler.set("bookingInfo",n)}rescheduleBookingRefChanged(n){var e,o;if(n){const[i,s]=t.compactStringToUUIDs(n);(e=this.stores)==null||e.scheduler.set("rescheduleBookingId",s),this.refConfigId=i,(o=this.nylasSchedulerConnector)==null||o.scheduler.setConfigId(i)}}cancelBookingRefChanged(n){var e,o;if(n){const[i,s]=t.compactStringToUUIDs(n);(e=this.stores)==null||e.scheduler.set("cancelBookingId",s),this.refConfigId=i,(o=this.nylasSchedulerConnector)==null||o.scheduler.setConfigId(i)}}async registerComponentHandler(n){var e;(e=this.baseProvider)==null||e.registerComponent(n.detail)}async unregisterComponentHandler(n){var e;(e=this.baseProvider)==null||e.unregisterComponent(n.detail)}async monthChangedHandler(n){var r,d,l,h,g;const e=n.detail,o=(h=(l=(d=(r=this.nylasSchedulerConnector)==null?void 0:r.schedulerStore)==null?void 0:d.get("configSettings"))==null?void 0:l.scheduler)==null?void 0:h.available_days_in_future,{startTime:i,endTime:s,endTimeForAvailableDaysInFuture:a}=this.validateAvailableDaysInFuture(e,o||30);if(i<a&&e.getTime()<a*1e3){const c=await((g=this.nylasSchedulerConnector)==null?void 0:g.scheduler.getAvailability(i,s));(!c||"error"in c)&&this.nylasSchedulerError.emit({...this.getErrorObject(c==null?void 0:c.error)})}}async bookButtonClickedHandler(n){var s,a,r,d;const o=(a=(s=this.nylasSchedulerConnector)==null?void 0:s.schedulerStore)==null?void 0:a.get("rescheduleBookingId");if(o){const l=await((r=this.nylasSchedulerConnector)==null?void 0:r.scheduler.rescheduleBooking(o,n.detail));(!l||"error"in l)&&this.nylasSchedulerError.emit({...this.getErrorObject(l==null?void 0:l.error)});return}const i=await((d=this.nylasSchedulerConnector)==null?void 0:d.scheduler.bookTimeslot(n.detail));(!i||"error"in i)&&this.nylasSchedulerError.emit({...this.getErrorObject(i==null?void 0:i.error)})}dateSelectedHandler(n){const e=n.detail;this.selectedDateLabel=e?e.toLocaleDateString(void 0,{dateStyle:"full"}):"No date selected"}cancelBookedEventErrorHandler(n){this.nylasSchedulerError.emit({...this.getErrorObject(n.detail.error)})}cancelBookedEventValidationErrorHandler(n){this.nylasSchedulerError.emit({...this.getErrorObject(n.detail.error)})}rescheduleBookedEventErrorHandler(n){this.nylasSchedulerError.emit({...this.getErrorObject(n.detail.error)})}async getNylasSchedulerStore(){var n;return(n=this.baseProvider)==null?void 0:n.getStore("scheduler")}async getNylasSchedulerConnector(){return this.nylasSchedulerConnector}async getRef(){return this.host}getErrorObject(n){return{title:(n==null?void 0:n.title)||I.title,category:(n==null?void 0:n.category)||I.category,type:m.nr.Error,description:(n==null?void 0:n.message)||"",id:new Date().getTime().toString(),ttl:"none"}}checkIfSessionIdOrConfigIdExists(){return!this.sessionId&&!this.refConfigId?(this.nylasSchedulerError.emit({title:"No sessionId!",category:y.ErrorCategory.Component,type:m.nr.Error,description:"Session ID is required",id:new Date().getTime().toString(),ttl:"none"}),!1):!0}isTimeslotValid(n){return new Date(n.start_time)<new Date?(this.nylasSchedulerError.emit({title:"Invalid tiemslot!",category:y.ErrorCategory.Component,type:m.nr.Error,description:"The selected timeslot is invalid.",id:new Date().getTime().toString(),ttl:"none"}),!1):!0}validateAvailableDaysInFuture(n,e){const o=new Date,i=new Date(n.getFullYear(),n.getMonth(),1).getTime()/1e3,s=new Date(n.getFullYear(),n.getMonth()+1,1).getTime()/1e3,a=Math.floor(t.addDaysToCurrentDate(o,e).getTime()/1e3),r=Math.min(a,s);return{startTime:i<o.getTime()/1e3?Math.floor(o.getTime()/1e3):i,endTime:r,endTimeForAvailableDaysInFuture:a}}render(){var g;const n=this.mode==="app",e=(g=this.baseProvider)==null?void 0:g.getStore("scheduler"),o=e==null?void 0:e.get("eventInfo"),i=e==null?void 0:e.get("showBookingForm"),s=e==null?void 0:e.get("cancelledEventInfo"),a=e==null?void 0:e.get("cancelBookingId"),r=e==null?void 0:e.get("selectedTimeslot"),d=e==null?void 0:e.get("rescheduleBookingId"),l=(e==null?void 0:e.get("nylasBranding"))||this.nylasBranding,h=e==null?void 0:e.get("selectedDate");if(this.selectedDateLabel=h?h.toLocaleDateString(void 0,{dateStyle:"full"}):"No date selected",n&&a&&!s)return t.h(t.Host,null,t.h(b,{nylasBranding:l,isLoading:this.isLoading,showNotification:this.showNotification},t.h("div",{class:"cancel-flow-page",part:"cancel-flow-page"},t.h("nylas-cancel-booking-form",{cancelBookingId:a,exportparts:"ncbf, ncbf__input-textfield, ncbf__button-cta, ncbf__button-outline, ncbf__input-label"}))));if(n&&s)return t.h(t.Host,null,t.h(b,{nylasBranding:l,isLoading:this.isLoading,showNotification:this.showNotification},t.h("div",{class:"cancelled-event-page",part:"cancelled-event-page"},t.h("nylas-cancelled-event-card",{cancelledEventInfo:s,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))));if(n&&o)return t.h(t.Host,null,t.h(b,{nylasBranding:l,isLoading:this.isLoading,showNotification:this.showNotification},t.h("div",{class:"booked-event-page",part:"booked-event-page"},t.h("nylas-booked-event-card",{selectedTimeslot:r,eventInfo:o,exportparts:"nbec, nbec__title, nbec__card, nbec__description, nbec__button-outline, nbec__cancel-cta, nbec__reschedule-cta"}))));if(n&&(!o||d)&&!i){const c=this.host.querySelector('[slot="timeslot-picker-cta-label"]');return t.h(t.Host,null,t.h(b,{nylasBranding:l,isLoading:this.isLoading,showNotification:this.showNotification},d&&t.h(x,null,"Choose another time slot to reschedule your meeting"),t.h("div",{class:"select-date-page",part:"select-date-page"},t.h("div",{class:"left-panel"},t.h("nylas-date-picker",{exportparts:"ndp, ndp__month-header, ndp__month-button, ndp__day, ndp__date, ndp__date--selected, ndp__date--current-day, ndp__date--current-month"}),t.h("nylas-locale-switch",null)),t.h("div",{class:"right-panel"},t.h("h2",null,t.h("calendar-icon",null),t.h("span",{id:"selectedDate"},this.selectedDateLabel)),t.h("nylas-timeslot-picker",{exportparts:"ntp, ntp__timeslot, ntp__timeslot--selected, ntp__button-primary"},c&&t.h("span",{slot:"timeslot-picker-cta-label"},t.h("slot",{name:"timeslot-picker-cta-label"})))))))}if(n&&!o&&i){const c=this.host.querySelector('[slot="custom-booking-form"]');return t.h(t.Host,null,t.h(b,{nylasBranding:l,isLoading:this.isLoading,showNotification:this.showNotification},d&&t.h(x,null,"Choose another time slot to reschedule your meeting"),t.h("div",{class:"additional-data-page",part:"additional-data-page"},t.h("div",{class:"left-panel"},t.h("div",{class:"wrapper"},t.h("nylas-selected-event-card",{exportparts:"nsec, nsec__card, nsec__icon, nsec__date, nsec__time"}))),t.h("div",{class:"right-panel"},t.h("nylas-booking-form",{exportparts:"nbf, nbf__input-label, nbf__input-textfield, nbf__button-ghost, nbf__button-primary, nbf__button-outline"},c&&t.h("div",{slot:"custom-booking-form"},t.h("slot",{name:"custom-booking-form"})))))))}return t.h(t.Host,null,t.h("slot",null))}get host(){return t.getElement(this)}static get watchers(){return{bookingInfo:["bookingInfoChanged"],rescheduleBookingRef:["rescheduleBookingRefChanged"],cancelBookingRef:["cancelBookingRefChanged"]}}};w.style=D;exports.nylas_scheduling=w;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index-e3e9b594.cjs"),h=require("./register-component-a5a9ca5d-b68b6039.cjs");require("react");require("react-dom");const u=":host{display:block}sp-search{width:100%;border:0}",y=u;var f=function(t,e,s,n){var o=arguments.length,r=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,s):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,s,n);else for(var i=t.length-1;i>=0;i--)(c=t[i])&&(r=(o<3?c(r):o>3?c(e,s,r):c(e,s))||r);return o>3&&r&&Object.defineProperty(e,s,r),r},d=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)};const l=class{constructor(t){a.registerInstance(this,t),this.search=a.createEvent(this,"search",7),this.onSearch=async e=>{e.preventDefault(),e.stopPropagation();const n=e.target.value;n!==this.internalQuery&&(this.internalQuery=n,this.search.emit(this.internalQuery))},this.query="",this.internalQuery=""}connectedCallback(){}disconnectedCallback(){}async componentWillLoad(){a.debug("[nylas-threads-search] Component will load")}async componentDidLoad(){a.debug("[nylas-threads-search] Component did load")}onQueryChange(){this.internalQuery=this.query}render(){return a.h(a.Host,{key:"b8f5ab7d60d06cb54da56d0362f8590d71646dca"},a.h("sp-theme",{key:"3d90db95bcbfee7eed4187caa97c76fb7727f58b",scale:"medium",color:"dark"},a.h("sp-search",{key:"d47bd5ee54845a0889f742b8ab76bb56b74fb147",quiet:!0,onSubmit:this.onSearch,onBlur:this.onSearch,value:this.internalQuery})))}static get watchers(){return{query:["onQueryChange"]}}};f([h.RegisterComponent({name:"nylas-pagination",stateToProps:new Map([["mailbox.searchQuery","query"]]),eventToProps:{search:async(t,e)=>{await e.threads.getThreads({search_query_native:t.detail||void 0,page_token:void 0})}},fireRegisterEvent:!0}),d("design:type",Function),d("design:paramtypes",[]),d("design:returntype",void 0)],l.prototype,"render",null);l.style=y;exports.nylas_threads_search=l;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-e3e9b594.cjs");require("react");require("react-dom");const o=".sc-play-icon-h{display:flex}",c=o,s=class{constructor(e){t.registerInstance(this,e),this.width="15",this.height="15"}render(){return t.h("svg",{key:"1b5bba2078843e9faf11f53d9bc851c66d1f7532",width:this.width,height:this.height,viewBox:"0 0 24 24",fill:"auto",xmlns:"http://www.w3.org/2000/svg"},t.h("path",{key:"9729442ffb92522f0c035cf51ed4a0db56650e49",d:"M21 12L3 21V3L21 12Z",stroke:"auto","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}))}};s.style=c;const n=".sc-stop-icon-h{display:flex}",h=n,i=class{constructor(e){t.registerInstance(this,e),this.width="15",this.height="15"}render(){return t.h("svg",{key:"8b5933c45a744cde84b5f7e8d11f9ed7a0beafc1",width:this.width,height:this.height,viewBox:"0 0 24 24",fill:"auto",xmlns:"http://www.w3.org/2000/svg"},t.h("path",{key:"a7c58dc851d448fffc8b152c97900b22bbff8910",d:"M4 4H20V20H4V4Z",stroke:"auto","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}))}};i.style=h;exports.play_icon=s;exports.stop_icon=i;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { r as o, h as t } from "./index-812162da.js";
|
|
2
|
-
import "react";
|
|
3
|
-
import "react-dom";
|
|
4
|
-
const e = ".sc-play-icon-h{display:flex}", i = e, c = class {
|
|
5
|
-
constructor(s) {
|
|
6
|
-
o(this, s), this.width = "15", this.height = "15";
|
|
7
|
-
}
|
|
8
|
-
render() {
|
|
9
|
-
return t("svg", { key: "1b5bba2078843e9faf11f53d9bc851c66d1f7532", width: this.width, height: this.height, viewBox: "0 0 24 24", fill: "auto", xmlns: "http://www.w3.org/2000/svg" }, t("path", { key: "9729442ffb92522f0c035cf51ed4a0db56650e49", d: "M21 12L3 21V3L21 12Z", stroke: "auto", "stroke-width": "1.5", "stroke-linecap": "round", "stroke-linejoin": "round" }));
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
c.style = i;
|
|
13
|
-
const h = ".sc-stop-icon-h{display:flex}", n = h, r = class {
|
|
14
|
-
constructor(s) {
|
|
15
|
-
o(this, s), this.width = "15", this.height = "15";
|
|
16
|
-
}
|
|
17
|
-
render() {
|
|
18
|
-
return t("svg", { key: "8b5933c45a744cde84b5f7e8d11f9ed7a0beafc1", width: this.width, height: this.height, viewBox: "0 0 24 24", fill: "auto", xmlns: "http://www.w3.org/2000/svg" }, t("path", { key: "a7c58dc851d448fffc8b152c97900b22bbff8910", d: "M4 4H20V20H4V4Z", stroke: "auto", "stroke-width": "1.5", "stroke-linecap": "round", "stroke-linejoin": "round" }));
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
r.style = n;
|
|
22
|
-
export {
|
|
23
|
-
c as play_icon,
|
|
24
|
-
r as stop_icon
|
|
25
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const i=require("./index-e3e9b594.cjs");function c(n={}){const o={selectedConfiguration:{},configurations:[],calendars:[],currentUser:null,action:null,additionalParticipants:[],...n},e=i.createStore(o);function t(){e.set("selectedConfiguration",{...n.selectedConfiguration})}return e.onChange("action",async r=>{r||t()}),{...e,resetSelectedConfiguration:t}}exports.CreateNylasSchedulerConfigStore=c;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const S=require("./index-e3e9b594.cjs");exports.ErrorCategory=void 0;(function(o){o.Component="component",o.Api="api",o.Auth="auth"})(exports.ErrorCategory||(exports.ErrorCategory={}));var T;(function(o){o.endtime_not_in_future="endtime_not_in_future",o.no_booking_info="no_booking_info",o.no_timeslot_selected="no_timeslot_selected",o.no_timezone_selected="no_timezone_selected",o.no_booking_id="no_booking_id",o.invalid_start_time="invalid_start_time",o.invalid_end_time="invalid_end_time",o.invalid_timezone="invalid_timezone"})(T||(T={}));var k;(function(o){o.invalid_session="invalid_session",o.general_error="general_error",o.internal_error="internal_error",o.invalid_request_error="invalid_request_error",o.timeslot_not_available="timeslot_not_available",o.provider_error="provider_error",o.not_found_error="not_found_error"})(k||(k={}));class M{constructor(){this.component=e=>{const t=exports.ErrorCategory.Component,s=`${e} Error`;return{endtime_not_in_future:(i='"endtime" can not be in the future')=>({title:s,message:i,category:t}),no_booking_info:(i="No booking info provided")=>({title:s,message:i,category:t}),no_timeslot_selected:(i="No timeslot selected")=>({title:s,message:i,category:t}),no_timezone_selected:(i="No timezone selected")=>({title:s,message:i,category:t}),no_booking_id:(i="No booking id provided")=>({title:s,message:i,category:t}),invalid_start_time:(i="Invalid start time")=>({title:s,message:i,category:t}),invalid_end_time:(i="Invalid end time")=>({title:s,message:i,category:t}),invalid_timezone:(i="Invalid timezone")=>({title:s,message:i,category:t})}},this.api=e=>{const t=exports.ErrorCategory.Api,s=`${e} Error`;return{invalid_session:i=>({title:s,message:i,category:t}),general_error:i=>({title:s,message:i,category:t}),internal_error:i=>({title:s,message:i,category:t}),invalid_request_error:i=>({title:s,message:i,category:t}),timeslot_not_available:i=>({title:s,message:i,category:t}),provider_error:i=>({title:s,message:i,category:t}),not_found_error:i=>({title:s,message:i,category:t})}}}}class C{constructor({schedulerAPIURL:e,schedulerStore:t,sessionId:s,configId:i}){this.errors=new M,this.schedulerStore=t,this.schedulerAPIURL=e,this.sessionId=s,this.configId=i}getHeaders(){return this.sessionId?{Authorization:`Bearer ${this.sessionId}`}:{}}async makeAPIRequest(e,t,s,i={}){try{const r=new URL(this.schedulerAPIURL);return r.pathname=e,await(await fetch(decodeURIComponent(r.toString()),{method:t,headers:{"Content-Type":"application/json",Origin:window.location.origin,...i},body:s})).json()}catch(r){return{error:{message:r.message,title:"API request failed",type:"api"}}}}getErrorMessage(e){var s,i,r,n;let t=(e==null?void 0:e.message)||(e==null?void 0:e.title)||"Something went wrong";return(e==null?void 0:e.type)==="provider_error"&&(t=((i=(s=e==null?void 0:e.provider_error)==null?void 0:s.error)==null?void 0:i.message)||((n=(r=e==null?void 0:e.provider_error)==null?void 0:r.error)==null?void 0:n.title)||"Something went wrong"),t}setConfigId(e){this.configId=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)}async toggleAdditionalData(e){e||await this.refetchAvailability(),this.schedulerStore.set("showBookingForm",e)}setParticipantName(e){const{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...t==null?void 0:t.primaryParticipant,name:e}})}setParticipantEmail(e){const{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...t==null?void 0:t.primaryParticipant,email:e}})}async refetchAvailability(){const e=new Date,t=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3,s=t<e.getTime()/1e3?Math.floor(e.getTime()/1e3):t,i=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3;return await this.getAvailability(s,i)}async resetStoreStateAndFetchAvailability(){const e=new Date,t=await this.refetchAvailability(),s=this.schedulerStore.get("availability").find(r=>new Date(r.start_time)>new Date);let i=e;return s&&(i=s.start_time),this.schedulerStore.set("selectedDate",i),this.schedulerStore.set("eventInfo",null),this.schedulerStore.set("showBookingForm",!1),this.schedulerStore.set("selectedTimeslot",null),t}async setReschedule(e){const t=this.schedulerStore.state.eventInfo;t&&this.schedulerStore.set("reschedulingEventInfo",t);const s=await this.resetStoreStateAndFetchAvailability();return this.schedulerStore.set("rescheduleBookingId",e),s}async setCancel(e){this.schedulerStore.set("cancelBookingId",e)}async resetCancel(){const e=await this.resetStoreStateAndFetchAvailability();return this.schedulerStore.set("cancelBookingId",""),this.schedulerStore.set("cancelledEventInfo",null),e}async bookTimeslot(e){var h;this.schedulerStore.set("isLoading",!0);const{selectedTimeslot:t,selectedTimezone:s,bookingInfo:i}=this.schedulerStore.state;if(!e&&!i)return{error:this.errors.component("Booking").no_booking_info()};const r=(e==null?void 0:e.timeslot)||t;if(!r)return{error:this.errors.component("Create Booking").no_timeslot_selected()};const n=e&&(e!=null&&e.timezone)?e==null?void 0:e.timezone:s;if(!n)return{error:this.errors.component("Create Booking").no_timezone_selected()};const a=e?e==null?void 0:e.primaryParticipant:i==null?void 0:i.primaryParticipant,u=e?(e==null?void 0:e.guests)||[]:(i==null?void 0:i.guests)||[],c=e?e==null?void 0:e.additionalFields:i==null?void 0:i.additionalFields,g=this.getHeaders(),_=`/v3/scheduling/bookings${!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:""}`,l=await this.makeAPIRequest(decodeURIComponent(_),"POST",JSON.stringify({additional_fields:c,additional_guests:u,guest:{...a},start_time:r.start_time.getTime()/1e3,end_time:r.end_time.getTime()/1e3,timezone:n}),g);if("error"in l){this.schedulerStore.set("isLoading",!1);const d=(h=l.error)==null?void 0:h.type;let v=l.error;if(d&&d in this.errors.api("Create Booking")){const y=this.getErrorMessage(v);v=this.errors.api("Create Booking")[d](y)}return{error:v}}return"data"in l&&this.schedulerStore.set("eventInfo",l==null?void 0:l.data),this.schedulerStore.set("isLoading",!1),l}async getUISettings(){var r;this.schedulerStore.set("isLoading",!0);const e=this.getHeaders(),s=`/v3/scheduling/ui-settings${!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:""}`,i=await this.makeAPIRequest(s,"GET",void 0,e);if("error"in i){this.schedulerStore.set("isLoading",!1);const n=(r=i.error)==null?void 0:r.type;let a=i.error;return n&&n in this.errors.api("Get UI Settings")&&(a=this.errors.api("Get UI Settings")[n]((a==null?void 0:a.message)||(a==null?void 0:a.title)||"Something went wrong")),{error:a}}return"data"in i&&this.schedulerStore.set("configSettings",i.data),this.schedulerStore.set("isLoading",!1),i}getStartTimeWithMinBookingNotice(e){var i;const t=(i=this.schedulerStore.get("configSettings"))==null?void 0:i.scheduler,s=t==null?void 0:t.min_booking_notice;return s?e+s*60:e}getEndTimeForAvailableDaysInFuture(e){var n,a;const t=new Date,s=(a=(n=this.schedulerStore.get("configSettings"))==null?void 0:n.scheduler)==null?void 0:a.available_days_in_future,i=Math.floor(S.addDaysToCurrentDate(t,s).getTime()/1e3);return Math.min(i,e)}async getAvailability(e=0,t=0){var g,f,_;this.schedulerStore.set("isLoading",!0);const s=new URLSearchParams,i=new Date,r=i.getTime();if(t&&t<r/1e3)return this.schedulerStore.set("isLoading",!1),{error:this.errors.component("Get Availability").endtime_not_in_future()};if(!e){const l=new Date(i.getFullYear(),i.getMonth(),1);e=Math.floor(l.getTime()/1e3)}if(e=this.getStartTimeWithMinBookingNotice(e),!t){const l=new Date(i.getFullYear(),i.getMonth()+1,0);t=Math.floor(l.getTime()/1e3)}t=this.getEndTimeForAvailableDaysInFuture(t),s.append("start_time",encodeURIComponent(e.toString())),s.append("end_time",encodeURIComponent(t.toString())),this.configId&&!this.sessionId&&s.append("configuration_id",encodeURIComponent(this.configId));const n=s.toString(),a=`/v3/scheduling/availability${n?`?${n}`:""}`,u=this.getHeaders(),c=await this.makeAPIRequest(decodeURIComponent(a),"GET",void 0,u);if("error"in c){this.schedulerStore.set("availability",[]),this.schedulerStore.set("isLoading",!1);const l=(g=c.error)==null?void 0:g.type;let h=c.error;if(l&&l in this.errors.api("Get Availability")){const d=this.getErrorMessage(h);h=this.errors.api("Get Availability")[l](d)}return{error:h}}if("data"in c){const h=(((_=(f=c.data)==null?void 0:f.time_slots)==null?void 0:_.map(d=>({...d,start_time:new Date(d.start_time*1e3),end_time:new Date(d.end_time*1e3)})))||[]).filter(d=>d.start_time.getTime()>r);this.schedulerStore.set("availability",h)}return this.schedulerStore.set("isLoading",!1),c}async cancelBooking(e,t){var a;if(this.schedulerStore.set("isLoading",!0),!e)return{error:this.errors.component("Cancel Booking").no_booking_id()};const s=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:"",i=`/v3/scheduling/bookings/${e}${s}`,r=this.getHeaders(),n=await this.makeAPIRequest(decodeURIComponent(i),"DELETE",JSON.stringify({action:"cancel",cancellation_reason:t}),r);if("error"in n){this.schedulerStore.set("isLoading",!1);const u=(a=n.error)==null?void 0:a.type;let c=n.error;if(u&&u in this.errors.api("Cancel Booking")){const g=this.getErrorMessage(c);c=this.errors.api("Cancel Booking")[u](g)}return{error:c}}return this.schedulerStore.set("cancelledEventInfo",{booking_id:e}),this.schedulerStore.set("isLoading",!1),n}async rescheduleBooking(e,t){var w;if(this.schedulerStore.set("isLoading",!0),!e)return{error:this.errors.component("Reschedule Booking").no_booking_id()};const s=this.errors.api("Reschedule Booking"),i=this.errors.component("Reschedule Booking"),{bookingInfo:r,selectedTimeslot:n,selectedTimezone:a}=this.schedulerStore.state,{startTime:u,endTime:c,timezone:g}=t,f=u||(n==null?void 0:n.start_time);if(!f)return{error:i.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')};const _=c||(n==null?void 0:n.end_time);if(!_)return{error:i.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')};const l=g||a;if(!l)return{error:i.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.')};const h=t?t==null?void 0:t.primaryParticipant:r==null?void 0:r.primaryParticipant,d=t?(t==null?void 0:t.guests)||[]:(r==null?void 0:r.guests)||[],v=t?{...t==null?void 0:t.additionalFields,guests:d}:{...r==null?void 0:r.additionalFields,guests:d},y=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:"",D=`/v3/scheduling/bookings/${e}${y}`,A=this.getHeaders(),m=await this.makeAPIRequest(decodeURIComponent(D),"PATCH",JSON.stringify({start_time:f.getTime()/1e3,end_time:_.getTime()/1e3,time_zone:l,additional_fields:v,guest:{...h}}),A);if("error"in m){this.schedulerStore.set("isLoading",!1);const p=(w=m.error)==null?void 0:w.type;let I=m.error;if(p&&p in s){const P=this.getErrorMessage(I);I=s[p](P)}return{error:I}}const b=this.schedulerStore.get("reschedulingEventInfo");if("data"in m)this.schedulerStore.set("eventInfo",m==null?void 0:m.data);else if(b)this.schedulerStore.set("eventInfo",b);else{const p={booking_id:e};this.schedulerStore.set("eventInfo",p)}return this.schedulerStore.set("isLoading",!1),m}}function z(o={}){const e={selectedDate:null,selectedLanguage:navigator.language,selectedTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTimeslot:null,showBookingForm:!1,selectableDates:null,availability:[],eventDuration:0,state:"ready",eventInfo:null,cancelledEventInfo:null,isLoading:!1,nylasBranding:!0,...o};S.debug("[defaultNylasStoreState]: ",e);const t=S.createStore(e);return t.onChange("availability",s=>{S.debug("[availability]: ",s);const i=s.map(a=>a.start_time);S.debug("[selectableDates]: ",i),t.set("selectableDates",i);const r=s[0];if(!r)return;const n=Math.floor((r.end_time.getTime()-r.start_time.getTime())/6e4);S.debug("[durationMinutes]: ",n),t.set("eventDuration",n)}),t.reset=()=>{for(const s in e){const i=e[s];t.set(s,i)}},t}exports.CreateNylasSchedulerStore=z;exports.NylaSchedulerAPIConnector=C;
|