@nylas/web-elements 2.3.2 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/input-color-picker/input-color-picker.es.js +1 -1
- package/dist/cdn/nylas-scheduler-editor/nylas-scheduler-editor.es.js +11 -11
- package/dist/cdn/nylas-scheduling/nylas-scheduling.es.js +8 -8
- package/dist/cjs/calendar-agenda-fill-icon_39.cjs.entry.js +1 -1
- package/dist/cjs/calendar-agenda-fill-icon_39.cjs.entry.js.map +1 -1
- package/dist/cjs/checkbox-component.cjs.entry.js +1 -1
- package/dist/cjs/checkbox-component.cjs.entry.js.map +1 -1
- package/dist/cjs/checkbox-component.entry.cjs.js.map +1 -1
- package/dist/cjs/checkmark-icon_15.cjs.entry.js +3 -3
- package/dist/cjs/checkmark-icon_15.cjs.entry.js.map +1 -1
- package/dist/cjs/chevron-icon.search-icon.select-dropdown.entry.cjs.js.map +1 -1
- package/dist/cjs/chevron-icon_3.cjs.entry.js +1 -1
- package/dist/cjs/chevron-icon_3.cjs.entry.js.map +1 -1
- package/dist/cjs/globe-icon.nylas-date-component.nylas-time-window-picker.entry.cjs.js.map +1 -1
- package/dist/cjs/globe-icon_3.cjs.entry.js +1 -1
- package/dist/cjs/globe-icon_3.cjs.entry.js.map +1 -1
- package/dist/cjs/google-logo-icon_6.cjs.entry.js +1 -1
- package/dist/cjs/input-component.cjs.entry.js +1 -1
- package/dist/cjs/input-component.cjs.entry.js.map +1 -1
- package/dist/cjs/input-component.entry.cjs.js.map +1 -1
- package/dist/cjs/nylas-booked-event-card_11.cjs.entry.js +1 -1
- package/dist/cjs/nylas-booked-event-card_11.cjs.entry.js.map +1 -1
- package/dist/cjs/nylas-scheduler-editor.cjs.entry.js +1 -1
- package/dist/cjs/nylas-scheduling.cjs.entry.js +1 -1
- package/dist/cjs/radio-button-group.cjs.entry.js +1 -1
- package/dist/cjs/radio-button-group.cjs.entry.js.map +1 -1
- package/dist/cjs/radio-button-group.entry.cjs.js.map +1 -1
- package/dist/cjs/textarea-component.cjs.entry.js +1 -1
- package/dist/cjs/textarea-component.cjs.entry.js.map +1 -1
- package/dist/cjs/textarea-component.entry.cjs.js.map +1 -1
- package/dist/cjs/{version-DUyFnawM.js → version-Cwdh5z5t.js} +3 -3
- package/dist/cjs/{version-DUyFnawM.js.map → version-Cwdh5z5t.js.map} +1 -1
- package/dist/collection/components/design-system/checkbox-component/checkbox-component.css +2 -0
- package/dist/collection/components/design-system/input-color-picker/input-color-picker.css +2 -0
- package/dist/collection/components/design-system/input-component/input-component.css +2 -0
- package/dist/collection/components/design-system/nylas-date-component/nylas-date-component.css +2 -0
- package/dist/collection/components/design-system/radio-button-group/radio-button-group.css +4 -0
- package/dist/collection/components/design-system/select-dropdown/select-dropdown.css +2 -0
- package/dist/collection/components/design-system/textarea-component/textarea-component.css +2 -0
- package/dist/collection/components/scheduler/nylas-booking-form/nylas-booking-form.css +2 -0
- package/dist/collection/components/scheduler-editor/nylas-booking-form-config/nylas-booking-form-config.css +2 -0
- package/dist/collection/components/scheduler-editor/nylas-event-description/nylas-event-description.css +2 -0
- package/dist/collection/components/scheduler-editor/nylas-event-title/nylas-event-title.css +2 -0
- package/dist/collection/version.js +1 -1
- package/dist/collection/version.js.map +1 -1
- package/dist/components/checkbox-component.js +1 -1
- package/dist/components/checkbox-group.js +1 -1
- package/dist/components/input-color-picker.js +1 -1
- package/dist/components/input-component.js +1 -1
- package/dist/components/input-image-url.js +1 -1
- package/dist/components/nylas-additional-participants.js +1 -1
- package/dist/components/nylas-availability-picker.js +1 -1
- package/dist/components/nylas-booking-calendar-picker.js +1 -1
- package/dist/components/nylas-booking-confirmation-redirect.js +1 -1
- package/dist/components/nylas-booking-confirmation-type.js +1 -1
- package/dist/components/nylas-booking-form-config.js +1 -1
- package/dist/components/nylas-booking-form.js +1 -1
- package/dist/components/nylas-buffer-time.js +1 -1
- package/dist/components/nylas-cancel-booking-form.js +1 -1
- package/dist/components/nylas-confirmation-email.js +1 -1
- package/dist/components/nylas-custom-event-slug.js +1 -1
- package/dist/components/nylas-customize-booking-settings.js +1 -1
- package/dist/components/nylas-date-component.js +1 -1
- package/dist/components/nylas-disable-emails.js +1 -1
- package/dist/components/nylas-editor-tabs-group.js +1 -1
- package/dist/components/nylas-editor-tabs.js +1 -1
- package/dist/components/nylas-event-calendar.js +1 -1
- package/dist/components/nylas-event-capacity.js +1 -1
- package/dist/components/nylas-event-description.js +1 -1
- package/dist/components/nylas-event-duration.js +1 -1
- package/dist/components/nylas-event-location.js +1 -1
- package/dist/components/nylas-event-timeslot.js +1 -1
- package/dist/components/nylas-event-title.js +1 -1
- package/dist/components/nylas-feedback-form.js +1 -1
- package/dist/components/nylas-limit-future-bookings.js +1 -1
- package/dist/components/nylas-list-configurations.js +1 -1
- package/dist/components/nylas-locale-switch.js +1 -1
- package/dist/components/nylas-min-booking-notice.js +1 -1
- package/dist/components/nylas-min-cancellation-notice.js +1 -1
- package/dist/components/nylas-notetaker-config.js +1 -1
- package/dist/components/nylas-page-name.js +1 -1
- package/dist/components/nylas-page-styling.js +1 -1
- package/dist/components/nylas-participant-booking-calendars.js +1 -1
- package/dist/components/nylas-participants-custom-availability.js +1 -1
- package/dist/components/nylas-reminder-emails.js +1 -1
- package/dist/components/nylas-reminder-time.js +1 -1
- package/dist/components/nylas-scheduler-editor.js +46 -46
- package/dist/components/nylas-scheduling-method.js +1 -1
- package/dist/components/nylas-scheduling.js +11 -11
- package/dist/components/nylas-specific-time-availability-picker.js +1 -1
- package/dist/components/nylas-timeslot-interval.js +1 -1
- package/dist/components/{p-C1X9fzID.js → p-9PlaXlCB.js} +3 -3
- package/dist/components/{p-C1X9fzID.js.map → p-9PlaXlCB.js.map} +1 -1
- package/dist/components/{p-p2By8R7Z.js → p-B-xvNL5X.js} +3 -3
- package/dist/components/{p-p2By8R7Z.js.map → p-B-xvNL5X.js.map} +1 -1
- package/dist/components/{p-DZJAqRR0.js → p-B4C1SvsK.js} +3 -3
- package/dist/components/{p-DZJAqRR0.js.map → p-B4C1SvsK.js.map} +1 -1
- package/dist/components/{p-FyWR7wsG.js → p-B4WU6Ddk.js} +3 -3
- package/dist/components/{p-FyWR7wsG.js.map → p-B4WU6Ddk.js.map} +1 -1
- package/dist/components/{p-a4aWyy2J.js → p-BCNq-vH8.js} +4 -4
- package/dist/components/{p-a4aWyy2J.js.map → p-BCNq-vH8.js.map} +1 -1
- package/dist/components/{p-ClRazYdc.js → p-BGel3qwa.js} +4 -4
- package/dist/components/{p-ClRazYdc.js.map → p-BGel3qwa.js.map} +1 -1
- package/dist/components/{p-CdjkLYNh.js → p-BH0odz_K.js} +34 -34
- package/dist/components/{p-CdjkLYNh.js.map → p-BH0odz_K.js.map} +1 -1
- package/dist/components/{p-BMS02R_Z.js → p-BJ6nYqW1.js} +3 -3
- package/dist/components/{p-BMS02R_Z.js.map → p-BJ6nYqW1.js.map} +1 -1
- package/dist/components/{p-BA8j6G8I.js → p-BJHGQK2p.js} +3 -3
- package/dist/components/{p-BA8j6G8I.js.map → p-BJHGQK2p.js.map} +1 -1
- package/dist/components/{p-Di7xtAN8.js → p-BWgGjFXi.js} +3 -3
- package/dist/components/{p-Di7xtAN8.js.map → p-BWgGjFXi.js.map} +1 -1
- package/dist/components/{p-B4ta0tDN.js → p-BZ_muELE.js} +3 -3
- package/dist/components/{p-B4ta0tDN.js.map → p-BZ_muELE.js.map} +1 -1
- package/dist/components/{p-DDBe0PRD.js → p-B_ZbZ5lK.js} +3 -3
- package/dist/components/{p-DDBe0PRD.js.map → p-B_ZbZ5lK.js.map} +1 -1
- package/dist/components/{p-BBkyE1MS.js → p-BdQ9iWW4.js} +6 -6
- package/dist/components/{p-BBkyE1MS.js.map → p-BdQ9iWW4.js.map} +1 -1
- package/dist/components/{p-DDM3ZlW1.js → p-BdQA_uHk.js} +3 -3
- package/dist/components/{p-DDM3ZlW1.js.map → p-BdQA_uHk.js.map} +1 -1
- package/dist/components/{p-44_g1hcc.js → p-BeGM4wbq.js} +3 -3
- package/dist/components/{p-44_g1hcc.js.map → p-BeGM4wbq.js.map} +1 -1
- package/dist/components/{p-DM_4oTsI.js → p-BjynTcY9.js} +4 -4
- package/dist/components/{p-DM_4oTsI.js.map → p-BjynTcY9.js.map} +1 -1
- package/dist/components/{p-Bz1eTXD6.js → p-BsMclINV.js} +4 -4
- package/dist/components/{p-Bz1eTXD6.js.map → p-BsMclINV.js.map} +1 -1
- package/dist/components/{p-BdG2pZat.js → p-BvCTseDu.js} +5 -5
- package/dist/components/{p-BdG2pZat.js.map → p-BvCTseDu.js.map} +1 -1
- package/dist/components/{p-lLGrGYYy.js → p-C4s3qYGu.js} +3 -3
- package/dist/components/{p-lLGrGYYy.js.map → p-C4s3qYGu.js.map} +1 -1
- package/dist/components/{p-Dkp7GkzI.js → p-CEvUNENN.js} +3 -3
- package/dist/components/{p-Dkp7GkzI.js.map → p-CEvUNENN.js.map} +1 -1
- package/dist/components/{p-BJACsIxp.js → p-CHQ9sLls.js} +6 -6
- package/dist/components/{p-BJACsIxp.js.map → p-CHQ9sLls.js.map} +1 -1
- package/dist/components/{p-CXvH8gEB.js → p-CIm8sd7h.js} +4 -4
- package/dist/components/{p-CXvH8gEB.js.map → p-CIm8sd7h.js.map} +1 -1
- package/dist/components/{p-eMdkzfgI.js → p-CVnhRnUq.js} +6 -6
- package/dist/components/{p-eMdkzfgI.js.map → p-CVnhRnUq.js.map} +1 -1
- package/dist/components/{p-DzNdcHoB.js → p-CZllU8ii.js} +3 -3
- package/dist/components/{p-DzNdcHoB.js.map → p-CZllU8ii.js.map} +1 -1
- package/dist/components/{p-FGJR3D9_.js → p-Ci9dxGLY.js} +5 -5
- package/dist/components/{p-FGJR3D9_.js.map → p-Ci9dxGLY.js.map} +1 -1
- package/dist/components/{p-Cqcd_0tY.js → p-CwBmT52e.js} +41 -41
- package/dist/components/{p-Cqcd_0tY.js.map → p-CwBmT52e.js.map} +1 -1
- package/dist/components/{p-CfqEi00L.js → p-D13lTN27.js} +4 -4
- package/dist/components/{p-CfqEi00L.js.map → p-D13lTN27.js.map} +1 -1
- package/dist/components/{p-CowteGon.js → p-D30KE7uE.js} +3 -3
- package/dist/components/{p-CowteGon.js.map → p-D30KE7uE.js.map} +1 -1
- package/dist/components/{p-DsJUpcxE.js → p-DAr02cfd.js} +3 -3
- package/dist/components/{p-DsJUpcxE.js.map → p-DAr02cfd.js.map} +1 -1
- package/dist/components/{p-D0JQ_-Qx.js → p-DDceIF1-.js} +3 -3
- package/dist/components/{p-D0JQ_-Qx.js.map → p-DDceIF1-.js.map} +1 -1
- package/dist/components/{p-Dy7hoKyo.js → p-DMltEU-a.js} +4 -4
- package/dist/components/{p-Dy7hoKyo.js.map → p-DMltEU-a.js.map} +1 -1
- package/dist/components/{p-OADv0FUZ.js → p-DNm8Z4AY.js} +3 -3
- package/dist/components/{p-OADv0FUZ.js.map → p-DNm8Z4AY.js.map} +1 -1
- package/dist/components/{p-Dd9ZfJbD.js → p-DTF0fIhr.js} +3 -3
- package/dist/components/p-DTF0fIhr.js.map +1 -0
- package/dist/components/{p-6i8K_2Bl.js → p-DVTv2Hp1.js} +3 -3
- package/dist/components/{p-6i8K_2Bl.js.map → p-DVTv2Hp1.js.map} +1 -1
- package/dist/components/{p-DdroMDi7.js → p-DWCPI1lK.js} +3 -3
- package/dist/components/{p-DdroMDi7.js.map → p-DWCPI1lK.js.map} +1 -1
- package/dist/components/{p-P01mLKOx.js → p-Dary9zXr.js} +3 -3
- package/dist/components/{p-P01mLKOx.js.map → p-Dary9zXr.js.map} +1 -1
- package/dist/components/{p-BmXUSpFE.js → p-DgfDGATC.js} +3 -3
- package/dist/components/{p-BmXUSpFE.js.map → p-DgfDGATC.js.map} +1 -1
- package/dist/components/{p-pgYRW1Gn.js → p-Ey-jPikW.js} +3 -3
- package/dist/components/{p-pgYRW1Gn.js.map → p-Ey-jPikW.js.map} +1 -1
- package/dist/components/{p-BYAaHapV.js → p-FFI2InLT.js} +3 -3
- package/dist/components/{p-BYAaHapV.js.map → p-FFI2InLT.js.map} +1 -1
- package/dist/components/{p-C9c9Tc-Q.js → p-FrLX9pVa.js} +6 -6
- package/dist/components/{p-C9c9Tc-Q.js.map → p-FrLX9pVa.js.map} +1 -1
- package/dist/components/{p-EBvHC_aS.js → p-Gyins0o7.js} +9 -9
- package/dist/components/{p-EBvHC_aS.js.map → p-Gyins0o7.js.map} +1 -1
- package/dist/components/{p-Et75ok2y.js → p-MMkYQKuh.js} +3 -3
- package/dist/components/{p-Et75ok2y.js.map → p-MMkYQKuh.js.map} +1 -1
- package/dist/components/{p-ybLp3dGv.js → p-QKc1T_NS.js} +3 -3
- package/dist/components/{p-ybLp3dGv.js.map → p-QKc1T_NS.js.map} +1 -1
- package/dist/components/{p-D2DM2um3.js → p-UahFYa1w.js} +3 -3
- package/dist/components/{p-D2DM2um3.js.map → p-UahFYa1w.js.map} +1 -1
- package/dist/components/{p-kRlkh0g-.js → p-idvnK5Rl.js} +3 -3
- package/dist/components/{p-kRlkh0g-.js.map → p-idvnK5Rl.js.map} +1 -1
- package/dist/components/{p-Bho2Hb_A.js → p-keUQQIah.js} +4 -4
- package/dist/components/{p-Bho2Hb_A.js.map → p-keUQQIah.js.map} +1 -1
- package/dist/components/{p-DAAGx7-h.js → p-pLqfEMSB.js} +3 -3
- package/dist/components/{p-DAAGx7-h.js.map → p-pLqfEMSB.js.map} +1 -1
- package/dist/components/{p-BAZ-jMiz.js → p-pRwtuoW0.js} +4 -4
- package/dist/components/{p-BAZ-jMiz.js.map → p-pRwtuoW0.js.map} +1 -1
- package/dist/components/{p-CJ3feL4K.js → p-whoa2mmo.js} +14 -14
- package/dist/components/{p-CJ3feL4K.js.map → p-whoa2mmo.js.map} +1 -1
- package/dist/components/radio-button-group.js +1 -1
- package/dist/components/select-dropdown.js +1 -1
- package/dist/components/textarea-component.js +1 -1
- package/dist/components/time-period-selector.js +1 -1
- package/dist/esm/calendar-agenda-fill-icon_39.entry.js +1 -1
- package/dist/esm/calendar-agenda-fill-icon_39.entry.js.map +1 -1
- package/dist/esm/checkbox-component.entry.js +1 -1
- package/dist/esm/checkbox-component.entry.js.map +1 -1
- package/dist/esm/checkmark-icon_15.entry.js +3 -3
- package/dist/esm/checkmark-icon_15.entry.js.map +1 -1
- package/dist/esm/chevron-icon.search-icon.select-dropdown.entry.js.map +1 -1
- package/dist/esm/chevron-icon_3.entry.js +1 -1
- package/dist/esm/chevron-icon_3.entry.js.map +1 -1
- package/dist/esm/globe-icon.nylas-date-component.nylas-time-window-picker.entry.js.map +1 -1
- package/dist/esm/globe-icon_3.entry.js +1 -1
- package/dist/esm/globe-icon_3.entry.js.map +1 -1
- package/dist/esm/google-logo-icon_6.entry.js +1 -1
- package/dist/esm/input-component.entry.js +1 -1
- package/dist/esm/input-component.entry.js.map +1 -1
- package/dist/esm/nylas-booked-event-card_11.entry.js +1 -1
- package/dist/esm/nylas-booked-event-card_11.entry.js.map +1 -1
- package/dist/esm/nylas-scheduler-editor.entry.js +1 -1
- package/dist/esm/nylas-scheduling.entry.js +1 -1
- package/dist/esm/radio-button-group.entry.js +1 -1
- package/dist/esm/radio-button-group.entry.js.map +1 -1
- package/dist/esm/textarea-component.entry.js +1 -1
- package/dist/esm/textarea-component.entry.js.map +1 -1
- package/dist/esm/{version-BxqBxG4o.js → version-BI4Pj5VG.js} +3 -3
- package/dist/esm/{version-BxqBxG4o.js.map → version-BI4Pj5VG.js.map} +1 -1
- package/dist/nylas-web-elements/checkbox-component.entry.esm.js.map +1 -1
- package/dist/nylas-web-elements/chevron-icon.search-icon.select-dropdown.entry.esm.js.map +1 -1
- package/dist/nylas-web-elements/globe-icon.nylas-date-component.nylas-time-window-picker.entry.esm.js.map +1 -1
- package/dist/nylas-web-elements/input-component.entry.esm.js.map +1 -1
- package/dist/nylas-web-elements/nylas-web-elements.esm.js +1 -1
- package/dist/nylas-web-elements/{p-428a7363.entry.js → p-1c6af810.entry.js} +2 -2
- package/dist/nylas-web-elements/p-23df6f78.entry.js +8 -0
- package/dist/nylas-web-elements/p-23df6f78.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-34c4bf5b.entry.js +2 -0
- package/dist/nylas-web-elements/{p-2bff143d.entry.js.map → p-34c4bf5b.entry.js.map} +1 -1
- package/dist/nylas-web-elements/{p-70614faf.entry.js → p-4dc6d0dc.entry.js} +2 -2
- package/dist/nylas-web-elements/p-52a66db6.entry.js +2 -0
- package/dist/nylas-web-elements/{p-1ba901b1.entry.js.map → p-52a66db6.entry.js.map} +1 -1
- package/dist/nylas-web-elements/p-5b01e519.entry.js +2 -0
- package/dist/nylas-web-elements/p-5b01e519.entry.js.map +1 -0
- package/dist/nylas-web-elements/{p-2d23ef5e.entry.js → p-81580cc0.entry.js} +2 -2
- package/dist/nylas-web-elements/p-9a5b1cfb.entry.js +2 -0
- package/dist/nylas-web-elements/{p-ab80b127.entry.js.map → p-9a5b1cfb.entry.js.map} +1 -1
- package/dist/nylas-web-elements/p-9c264d62.entry.js +2 -0
- package/dist/nylas-web-elements/{p-7655eeb0.entry.js.map → p-9c264d62.entry.js.map} +1 -1
- package/dist/nylas-web-elements/{p-BxqBxG4o.js → p-BI4Pj5VG.js} +2 -2
- package/dist/nylas-web-elements/{p-BxqBxG4o.js.map → p-BI4Pj5VG.js.map} +1 -1
- package/dist/nylas-web-elements/p-b0306d35.entry.js +2 -0
- package/dist/nylas-web-elements/{p-70762abf.entry.js.map → p-b0306d35.entry.js.map} +1 -1
- package/dist/nylas-web-elements/{p-9c78baa7.entry.js → p-b2c497eb.entry.js} +2 -2
- package/dist/nylas-web-elements/p-b2c497eb.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-c91eb1ba.entry.js +2 -0
- package/dist/nylas-web-elements/{p-e042747e.entry.js.map → p-c91eb1ba.entry.js.map} +1 -1
- package/dist/nylas-web-elements/radio-button-group.entry.esm.js.map +1 -1
- package/dist/nylas-web-elements/textarea-component.entry.esm.js.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/components/p-Dd9ZfJbD.js.map +0 -1
- package/dist/nylas-web-elements/p-1ba901b1.entry.js +0 -2
- package/dist/nylas-web-elements/p-2bff143d.entry.js +0 -2
- package/dist/nylas-web-elements/p-70762abf.entry.js +0 -2
- package/dist/nylas-web-elements/p-7655eeb0.entry.js +0 -2
- package/dist/nylas-web-elements/p-88112606.entry.js +0 -8
- package/dist/nylas-web-elements/p-88112606.entry.js.map +0 -1
- package/dist/nylas-web-elements/p-9c78baa7.entry.js.map +0 -1
- package/dist/nylas-web-elements/p-ab80b127.entry.js +0 -2
- package/dist/nylas-web-elements/p-e042747e.entry.js +0 -2
- package/dist/nylas-web-elements/p-e82826b8.entry.js +0 -2
- package/dist/nylas-web-elements/p-e82826b8.entry.js.map +0 -1
- /package/dist/nylas-web-elements/{p-428a7363.entry.js.map → p-1c6af810.entry.js.map} +0 -0
- /package/dist/nylas-web-elements/{p-70614faf.entry.js.map → p-4dc6d0dc.entry.js.map} +0 -0
- /package/dist/nylas-web-elements/{p-2d23ef5e.entry.js.map → p-81580cc0.entry.js.map} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e,h as s,c as a,a as i,H as t}from"./p-0EQQA0nE.js";import{o as r,d as l,i as o,N as n,O as c,C as h,P as f,Q as d,D as y}from"./p-D7AODx4L.js";import{L as b}from"./p-COJy29df.js";import{c as p}from"./p-D0rHpZDF.js";const u=".sc-globe-icon-h{display:flex}";const m=class{constructor(s){e(this,s);this.width="16";this.height="16"}render(){return s("svg",{key:"56a194e3418b638e1249285506c2ee261f00f11e",xmlns:"http://www.w3.org/2000/svg",width:this.width,height:this.height,viewBox:"0 0 16 16",fill:"none"},s("path",{key:"fcf8257e3a1aff210330b15c20dd3bb23aa59034",d:"M8 14C11.3137 14 14 11.3137 14 8C14 4.68629 11.3137 2 8 2C4.68629 2 2 4.68629 2 8C2 11.3137 4.68629 14 8 14ZM8 3C8.37372 3 8.87543 3.35608 9.31258 4.31781C9.4073 4.52619 9.49448 4.75446 9.57265 5H6.42735C6.50552 4.75446 6.5927 4.52619 6.68742 4.31781C7.12457 3.35608 7.62628 3 8 3ZM5.77705 3.90401C5.62614 4.23601 5.49428 4.6038 5.38411 5H3.99963C4.52341 4.30269 5.22525 3.74677 6.03766 3.39978C5.94287 3.56117 5.85596 3.7304 5.77705 3.90401ZM5.16299 6C5.05694 6.6275 5 7.30146 5 8C5 8.69854 5.05694 9.3725 5.16299 10H3.41604C3.14845 9.38754 3 8.7111 3 8C3 7.2889 3.14845 6.61246 3.41604 6H5.16299ZM5.38411 11C5.49428 11.3962 5.62614 11.764 5.77705 12.096C5.85596 12.2696 5.94287 12.4388 6.03766 12.6002C5.22525 12.2532 4.52341 11.6973 3.99963 11H5.38411ZM6.42735 11H9.57265C9.49448 11.2455 9.4073 11.4738 9.31258 11.6822C8.87543 12.6439 8.37372 13 8 13C7.62628 13 7.12457 12.6439 6.68742 11.6822C6.5927 11.4738 6.50552 11.2455 6.42735 11ZM9.82134 10H6.17866C6.06438 9.3892 6 8.71396 6 8C6 7.28604 6.06438 6.6108 6.17866 6H9.82134C9.93562 6.6108 10 7.28604 10 8C10 8.71396 9.93562 9.3892 9.82134 10ZM10.6159 11H12.0004C11.4766 11.6973 10.7747 12.2532 9.96234 12.6002C10.0571 12.4388 10.144 12.2696 10.2229 12.096C10.3739 11.764 10.5057 11.3962 10.6159 11ZM12.584 10H10.837C10.9431 9.3725 11 8.69854 11 8C11 7.30146 10.9431 6.6275 10.837 6H12.584C12.8516 6.61246 13 7.2889 13 8C13 8.7111 12.8516 9.38754 12.584 10ZM9.96234 3.39978C10.7747 3.74677 11.4766 4.30269 12.0004 5H10.6159C10.5057 4.6038 10.3739 4.23601 10.2229 3.90401C10.144 3.7304 10.0571 3.56117 9.96234 3.39978Z",fill:"currentColor"}))}};m.style=u;const g=':host{display:block;height:auto;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-50:#ffeae8;--nylas-error-100:#ffc5bf;--nylas-error-200:#fecaca;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff;width:100%}label{display:flex;color:var(--nylas-base-800, #293056);font-size:14px;font-style:normal;font-weight:400;line-height:150%;word-break:break-word;overflow-wrap:break-word;flex-direction:column;gap:4px;font-family:var(--nylas-font-family);font-size:16px;color:var(--nylas-base-800)}label.error{color:var(--nylas-error)}label span.required{color:var(--nylas-error);padding:0 0.25rem}label p{margin:0}label .error{color:var(--nylas-error);border-color:var(--nylas-error)}.input_wrapper{display:flex;align-items:center;gap:1rem}input[type=date]{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%;width:100%;width:-moz-available;width:-webkit-fill-available;font-family:var(--nylas-font-family);padding:0 8px;cursor:pointer}input[type=date]:focus{outline-color:var(--nylas-primary)}input[type=date].error{border-radius:var(--nylas-border-radius-2x);font-weight:600;border-color:var(--nylas-error);border-width:2px}input[type=date].error::placeholder{font-weight:400}input[type=date]::placeholder{color:var(--nylas-base-300)}input[type=date]::-webkit-calendar-picker-indicator{filter:invert(37%) sepia(51%) saturate(6324%) hue-rotate(215deg) brightness(94%) contrast(95%);cursor:pointer}input:read-only{background-color:var(--nylas-base-100);cursor:not-allowed}';const k={date:"YYYY-MM-DD"};const x=class{constructor(s){e(this,s);this.nylasFormInputChanged=a(this,"nylasFormInputChanged",7);this.nylasFormInputFocused=a(this,"nylasFormInputFocused",7);this.nylasFormInputBlurred=a(this,"nylasFormInputBlurred",7);this.name="input";this.label="";this.placeholder=k["date"];this.required=false;this.readOnly=false;this.autoFocus=false;this.maxLength=255;this.patternError="";this.requiredError="";this.errorMessage="";this.hasError=false;this.error="";this.isDateValid=true}handleDefaultValueChange(e){this.value=r(e);if(this.value){this.validatePattern(this.value,true)}}themeConfigChangedHandler(e,s){if(e===s)return;this.applyThemeConfig(e)}applyThemeConfig(e){if(e){for(const[s,a]of Object.entries(e)){this.el.style.setProperty(`${s}`,a)}}}connectedCallback(){queueMicrotask((()=>{if(this.themeConfig){this.applyThemeConfig(this.themeConfig);this.el.setAttribute("data-themed","")}}))}componentDidLoad(){this.value=r(this.defaultValue||"");if(this.value){this.validatePattern(this.value,true)}}handleBookingFormSubmitted(e){this.validatePattern(this.value);if(this.error){e.preventDefault()}}async handleFormSubmitted(e){this.validatePattern(this.value);if(this.error){e.preventDefault()}}handleInput(e){this.error="";const s=e.target;this.value=r(s.value);this.isDateValid=s.validity.valid;this.nylasFormInputChanged.emit({value:this.value,name:this.name,label:this.label,error:this.error,type:"date"})}handleBlur(){this.nylasFormInputBlurred.emit({value:this.value,name:this.name})}handleFocus(){this.nylasFormInputFocused.emit({value:this.value,name:this.name})}validatePattern(e,s=false){this.error="";if(!s&&(this.required&&!this.isDateValid||this.minDate&&new Date(this.minDate)>new Date(e))){this.error=this.errorMessage||"Please enter a valid date";this.nylasFormInputChanged.emit({value:this.value,name:this.name,label:this.label,error:this.error,type:"date"});return}if(this.required&&!e){this.error=this.requiredError||"This field is required.";return}if(!this.pattern||!e&&!this.required)return;if(this.pattern.test(e)){this.error=""}else{this.error=this.patternError||"Invalid format."}}render(){return s("label",{key:"cbe14199da81af538dbb83985a8eb452165cc666",part:"ic__label",class:{error:!!this.error||this.hasError}},this.label&&s("p",{key:"44243eced08cadeb43ba11faa4833eeba19fb21a"},s("span",{key:"cb9a4ce6da6db49dc88ad465144bad9074ccf4c7",class:"label"},this.label),this.required&&s("span",{key:"d7f6d15d0f791504726afa69df5f277437ed2004",class:"required"},"*")),s("div",{key:"d7f83a7de404023da5d173574ab03f425694155c",part:"ic__input_wrapper",class:"input_wrapper"},s("input",{key:"6908faeae193668e66840b3ae0d9ddf2faa86a6c",type:"date",min:this.minDate,value:this.value,name:this.name,part:"ic__date",title:this.readOnly?"read-only field":undefined,readOnly:this.readOnly,autoFocus:this.autoFocus,maxLength:this.maxLength,placeholder:this.placeholder,class:{error:!!this.error||this.hasError},onInput:e=>this.handleInput(e),onFocus:()=>this.handleFocus(),onBlur:()=>this.handleBlur()}),s("slot",{key:"b770600413c67fef7bcbf291de3dce3e40844cff",name:"additional-input"})),this.error&&s("span",{key:"7defdbfdd33331a5cfc0f40effb29a2ef29896c6",class:"error help-text"},this.error))}get el(){return i(this)}static get watchers(){return{defaultValue:["handleDefaultValueChange"],themeConfig:["themeConfigChangedHandler"]}}};x.style=g;const w=':host{display:block;position:relative;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-50:#ffeae8;--nylas-error-100:#ffc5bf;--nylas-error-200:#fecaca;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff}.time-picker{display:inline-block;width:150px;font-family:var(--nylas-font-family);position:relative}@media screen and (max-width: 768px){.time-picker{width:auto}}.time-picker input{width:150px;height:48px;text-align:center;font-size:16px;font-family:inherit;color:var(--nylas-base-900);cursor:pointer;background:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-2x)}@media screen and (max-width: 768px){.time-picker input{width:88px}}@media screen and (max-width: 504px){.time-picker input{width:68px;font-size:15px}}.time-picker input.focus{background:var(--nylas-base-0)}.time-picker input:hover,.time-picker input:active{border:1px solid var(--nylas-primary)}.time-picker input:active{outline:2px solid var(--nylas-primary)}.time-picker input span.open{transform:rotate(90deg)}.time-picker input span.closed{transform:rotate(270deg)}.time-picker input.error{border:1px solid var(--nylas-error)}.time-picker p.error{color:var(--nylas-error);font-size:0.875rem;margin:0}.times{display:block;margin-top:0.5rem;background-color:var(--nylas-base-0);width:100%;max-height:336px;overflow:auto;border:1px solid #ddd;z-index:1;border-radius:4px;position:absolute;box-shadow:0px 4px 6px -2px rgba(0, 0, 0, 0.0509803922);box-shadow:0px 10px 15px -3px rgba(0, 0, 0, 0.1019607843)}.times ul{padding:0;list-style-type:none;color:var(--nylas-base-900);max-height:336px}.times ul li{padding:16px, 12px, 16px, 12px;color:var(--nylas-base-900);padding:12px 16px;text-decoration:none;display:block;font-family:inherit;font-size:14px;font-weight:400;line-height:20px;letter-spacing:0px;text-align:center;cursor:pointer}.times ul li.focused{background-color:var(--nylas-base-100)}.times ul li:hover,.times ul li:focus{background-color:var(--nylas-base-100)}.times ul li label{display:flex;align-items:center;gap:0.5rem}.times ul li label input{margin:0}';l.extend(p);const v=class{constructor(s){e(this,s);this.timeChange=a(this,"timeChange",7);this.timeWindowFormError=a(this,"timeWindowFormError",7);this.minimumStartTime=null;this.placeholder="hh:mmam/pm";this.hasError=false;this.language=b.en;this.err="";this.showTimes=false;this.ariaActivedescendant="";this.times=this.generateTimes();this.shouldAutoScroll=false}handleOutsideClick(e){const s=e.composedPath();const a=s.includes(this.el);if(!a&&this.showTimes){this.showTimes=false}}timeChangedHandler(){this.validateTimeAgainstMinimum()}minimumStartTimeChangedHandler(){this.validateTimeAgainstMinimum()}themeConfigChangedHandler(e,s){this.applyThemeConfig(e)}applyThemeConfig(e){if(e){for(const[s,a]of Object.entries(e)){this.el.style.setProperty(`${s}`,a)}}}validateTimeAgainstMinimum(){if(this.minimumStartTime){const e=l(this.minimumStartTime,"hh:mma");const s=l(this.time,"hh:mma");this.times=this.generateTimes();const a=o.t("nylasTimeWindowPicker.errors.invalid");if(s.isBefore(e)){this.err=a;this.timeWindowFormError.emit({key:this.el.id,message:a})}else{this.err="";this.timeWindowFormError.emit({key:this.el.id,message:""})}}else{this.err="";this.timeWindowFormError.emit({key:this.el.id,message:""})}}connectedCallback(){queueMicrotask((()=>{if(this.themeConfig){this.applyThemeConfig(this.themeConfig);this.el.setAttribute("data-themed","")}}))}componentWillLoad(){}componentDidLoad(){this.validateTimeAgainstMinimum()}componentDidRender(){if(this.showTimes&&this.shouldAutoScroll){const e=n(this.time);const s=this.times.findIndex((s=>s.value===e));if(s>-1){this.shouldAutoScroll=false;this.scrollToViewWithinParent(s)}return}}handleTimeChange(e,s){const a=s.split(":");if(a[0]==="00"&&a[1].slice(-2)=="pm"){const e=o.t("nylasTimeWindowPicker.errors.invalid");this.err=e;this.timeWindowFormError.emit({key:this.el.id,message:e})}if(!c(s)){const e=o.t("nylasTimeWindowPicker.errors.invalid");this.err=e;this.timeWindowFormError.emit({key:this.el.id,message:e})}else{this.err="";this.timeWindowFormError.emit({key:this.el.id,message:""})}if(this.err){return}this.timeChange.emit({key:this.el.id,value:s})}handleTimeAutocomplete(e){const s=e.target?.value;const a=this.language!==b.en?h(s):s;const i=o.t("nylasTimeWindowPicker.errors.invalid");if(!c(a)){this.err=i;this.timeWindowFormError.emit({key:this.el.id,message:i});return}if(a===""){const e=f().format("hh:mma");this.timeChange.emit({key:this.el.id,value:e});return}if(!d(a)){const e=n(a);this.timeChange.emit({key:this.el.id,value:e});return}this.timeChange.emit({key:this.el.id,value:a})}handleOnInput(e){const s=e.target?.value;if(!c(s)){return}if(s===""){const e=f().format("hh:mma");const s=this.times.findIndex((s=>s.value===e));if(s>-1){this.scrollToViewWithinParent(s)}return}if(!d(s)){const e=n(s);const a=this.times.findIndex((s=>s.value===e));if(a>-1){this.scrollToViewWithinParent(a)}return}}generateTimes(){const e=[];let s=l().set("hour",0).set("minute",0).set("second",0);if(this.minimumStartTime){s=l(this.minimumStartTime,"hh:mma")}const a=s.endOf("day").diff(s,"minutes");const i=Math.round(a/15);for(let a=0;a<i+1;a++){const t=s.add(a*15,"minute");if(a==i&&t.format("hh:mma").includes("am")){break}e.push({id:a,value:t.format("hh:mma")})}return e}handleComboboxKeyDown(e){if(e.key==="ArrowDown"){e.preventDefault();if(!this.showTimes){this.showTimes=true;this.shouldAutoScroll=true;return}if(this.ariaActivedescendant===""){this.ariaActivedescendant=this.times[0].id.toString();this.focusOption(0)}else{const e=this.times.findIndex((e=>e.id.toString()===this.ariaActivedescendant));const s=e+1<this.times.length?e+1:0;this.ariaActivedescendant=this.times[s].id.toString();this.focusOption(s)}}else if(e.key==="ArrowUp"){e.preventDefault();if(this.ariaActivedescendant===""){this.ariaActivedescendant=this.times[this.times.length-1].id.toString();this.focusOption(this.times.length-1)}else{const e=this.times.findIndex((e=>e.id.toString()===this.ariaActivedescendant));const s=e-1>=0?e-1:this.times.length-1;this.ariaActivedescendant=this.times[s].id.toString();this.focusOption(s)}}else if(e.key==="Escape"){this.showTimes=false;this.timeInput.focus()}}handleListboxKeydown(e){const s=this.times;const a=s.findIndex((e=>e.id.toString()===this.ariaActivedescendant));if(e.key==="ArrowDown"||e.key==="Tab"&&!e.shiftKey){e.preventDefault();const i=a+1<s.length?a+1:0;this.ariaActivedescendant=s[i].id.toString();this.focusOption(i)}else if(e.key==="ArrowUp"||e.key==="Tab"&&e.shiftKey){e.preventDefault();const i=a-1>=0?a-1:s.length-1;this.ariaActivedescendant=s[i].id.toString();this.focusOption(i)}else if(e.key==="Enter"){e.preventDefault();if(this.ariaActivedescendant){const i=s[a];this.handleTimeChange(e,i.value);this.showTimes=false;this.ariaActivedescendant="";this.timeInput.focus()}}else if(e.key==="Escape"){this.showTimes=false;this.timeInput.focus()}}scrollToViewWithinParent(e){const s=this.times[e];const a=this.el.shadowRoot?.getElementById(s.id.toString());const i=this.timeMenu;this.ariaActivedescendant=s.id.toString();const t=a.getBoundingClientRect();const r=i.getBoundingClientRect();if(t.top<r.top){i.scrollTop-=r.top-t.top}else if(t.bottom>r.bottom){i.scrollTop+=t.bottom-r.bottom}if(t.left<r.left){i.scrollLeft-=r.left-t.left}else if(t.right>r.right){i.scrollLeft+=t.right-r.right}}focusOption(e){const s=this.times[e];if(!s)return;const a=s.id.toString();const i=this.el.shadowRoot?.getElementById(a);if(i){i.focus();i.scrollIntoView({behavior:"smooth",block:"nearest"})}}render(){const e=this.language===b.en?false:true;return s(t,{key:"0403cfa3797f932534b4cebc405a20290213e998"},s("div",{key:"8ccffc9783e64048de39e57c319e4293ebdc2a01",class:"time-picker",part:"time-picker"},s("input",{key:"a3b973a69652beea3c5f0edf92d1392531eb2cd4",type:"text",name:this.name,id:this.name,part:"time-input",class:{"time-input":true,error:!!this.err||this.hasError},ref:e=>this.timeInput=e,value:e?y(this.time):this.time,onClick:()=>{this.showTimes=!this.showTimes;this.shouldAutoScroll=true},"aria-haspopup":"listbox","aria-label":this.name,"aria-expanded":this.showTimes?"true":"false",placeholder:this.placeholder,onKeyDown:e=>this.handleComboboxKeyDown(e),onInput:e=>this.handleOnInput(e),onBlur:e=>this.handleTimeAutocomplete(e)}),this.err&&s("div",{key:"d7385a33724b5d41e39bd805f9d71481a6703372",class:"invalid-time-icon"}),this.showTimes&&s("div",{key:"eb865058bed72b5ff418948ed6c98731d52b6f7e",class:"times",part:"times",ref:e=>this.timeMenu=e},s("ul",{key:"e59880009b3c3b854bee6556b04aabe95cc7be69",tabindex:"-1",role:"listbox","aria-label":this.name,"aria-activedescendant":this.ariaActivedescendant,onKeyDown:e=>this.handleListboxKeydown(e)},this.times.map((a=>s("li",{tabindex:"0",key:a.id,id:a.id.toString(),class:{focused:this.ariaActivedescendant===a.id.toString()},onClick:e=>{this.handleTimeChange(e,a.value);this.showTimes=false;this.timeInput.focus()},role:"option"},`${e?y(a.value):a.value}`))))),!this.showTimes&&this.err&&s("p",{key:"5391705ea7e8a3a366889ef8976760383e8f6fe5",class:"error",id:"email-error"},this.err)))}get el(){return i(this)}static get watchers(){return{time:["timeChangedHandler"],minimumStartTime:["minimumStartTimeChangedHandler"],themeConfig:["themeConfigChangedHandler"]}}};v.style=w;export{m as globe_icon,x as nylas_date_component,v as nylas_time_window_picker};
|
|
2
|
+
//# sourceMappingURL=p-34c4bf5b.entry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["iconCss","GlobeIcon","constructor","hostRef","this","width","height","render","h","key","xmlns","viewBox","fill","d","nylasDateComponentCss","DefaultPlaceholder","date","NylasDateComponent","name","label","placeholder","required","readOnly","autoFocus","maxLength","patternError","requiredError","errorMessage","hasError","error","isDateValid","handleDefaultValueChange","newValue","value","sanitize","validatePattern","themeConfigChangedHandler","newVal","oldVal","applyThemeConfig","themeConfig","Object","entries","el","style","setProperty","connectedCallback","queueMicrotask","setAttribute","componentDidLoad","defaultValue","handleBookingFormSubmitted","event","preventDefault","handleFormSubmitted","handleInput","e","target","validity","valid","nylasFormInputChanged","emit","type","handleBlur","nylasFormInputBlurred","handleFocus","nylasFormInputFocused","onLoad","minDate","Date","pattern","test","part","class","min","title","undefined","onInput","onFocus","onBlur","nylasTimeWindowPickerCss","dayjs","extend","customParseFormat","TimeInput","minimumStartTime","language","LANGUAGE_CODE","en","err","showTimes","ariaActivedescendant","times","generateTimes","shouldAutoScroll","handleOutsideClick","path","composedPath","isClickInside","includes","timeChangedHandler","validateTimeAgainstMinimum","minimumStartTimeChangedHandler","_oldVal","minimumTime","selectedTime","time","i18next","t","isBefore","timeWindowFormError","id","message","componentWillLoad","componentDidRender","autocompletedTime","autocompleteTimeFormat","optionIndex","findIndex","scrollToViewWithinParent","handleTimeChange","_e","input","timePart","split","slice","validateTimeFormatInput","timeChange","handleTimeAutocomplete","targetInput","convertTo12HourFormat","newTime","roundToNearest15Minutes","format","validateExactTimeFormat","handleOnInput","startTime","set","diff","endOf","iterations","Math","round","i","add","push","handleComboboxKeyDown","toString","focusOption","currentIndex","nextIndex","length","prevIndex","timeInput","focus","handleListboxKeydown","items","item","shiftKey","option","childElement","shadowRoot","getElementById","parentElement","timeMenu","childRect","getBoundingClientRect","parentRect","top","scrollTop","bottom","left","scrollLeft","right","index","elementId","element","scrollIntoView","behavior","block","is24HourFormat","Host","ref","convertTo24HourFormat","onClick","onKeyDown","tabindex","role","map","focused"],"sources":["src/common/icons/icon.css?tag=globe-icon&encapsulation=scoped","src/common/icons/globe.tsx","src/components/design-system/nylas-date-component/nylas-date-component.scss?tag=nylas-date-component&encapsulation=shadow","src/components/design-system/nylas-date-component/nylas-date-component.tsx","src/components/scheduler-editor/nylas-time-window-picker/nylas-time-window-picker.scss?tag=nylas-time-window-picker&encapsulation=shadow","src/components/scheduler-editor/nylas-time-window-picker/nylas-time-window-picker.tsx"],"sourcesContent":[":host {\n display: flex;\n}\n","import { Component, Prop, h } from '@stencil/core';\n\n@Component({\n tag: 'globe-icon',\n styleUrl: 'icon.css',\n scoped: true,\n})\nexport class GlobeIcon {\n @Prop() width: string = '16';\n @Prop() height: string = '16';\n\n render() {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" width={this.width} height={this.height} viewBox=\"0 0 16 16\" fill=\"none\">\n <path\n d=\"M8 14C11.3137 14 14 11.3137 14 8C14 4.68629 11.3137 2 8 2C4.68629 2 2 4.68629 2 8C2 11.3137 4.68629 14 8 14ZM8 3C8.37372 3 8.87543 3.35608 9.31258 4.31781C9.4073 4.52619 9.49448 4.75446 9.57265 5H6.42735C6.50552 4.75446 6.5927 4.52619 6.68742 4.31781C7.12457 3.35608 7.62628 3 8 3ZM5.77705 3.90401C5.62614 4.23601 5.49428 4.6038 5.38411 5H3.99963C4.52341 4.30269 5.22525 3.74677 6.03766 3.39978C5.94287 3.56117 5.85596 3.7304 5.77705 3.90401ZM5.16299 6C5.05694 6.6275 5 7.30146 5 8C5 8.69854 5.05694 9.3725 5.16299 10H3.41604C3.14845 9.38754 3 8.7111 3 8C3 7.2889 3.14845 6.61246 3.41604 6H5.16299ZM5.38411 11C5.49428 11.3962 5.62614 11.764 5.77705 12.096C5.85596 12.2696 5.94287 12.4388 6.03766 12.6002C5.22525 12.2532 4.52341 11.6973 3.99963 11H5.38411ZM6.42735 11H9.57265C9.49448 11.2455 9.4073 11.4738 9.31258 11.6822C8.87543 12.6439 8.37372 13 8 13C7.62628 13 7.12457 12.6439 6.68742 11.6822C6.5927 11.4738 6.50552 11.2455 6.42735 11ZM9.82134 10H6.17866C6.06438 9.3892 6 8.71396 6 8C6 7.28604 6.06438 6.6108 6.17866 6H9.82134C9.93562 6.6108 10 7.28604 10 8C10 8.71396 9.93562 9.3892 9.82134 10ZM10.6159 11H12.0004C11.4766 11.6973 10.7747 12.2532 9.96234 12.6002C10.0571 12.4388 10.144 12.2696 10.2229 12.096C10.3739 11.764 10.5057 11.3962 10.6159 11ZM12.584 10H10.837C10.9431 9.3725 11 8.69854 11 8C11 7.30146 10.9431 6.6275 10.837 6H12.584C12.8516 6.61246 13 7.2889 13 8C13 8.7111 12.8516 9.38754 12.584 10ZM9.96234 3.39978C10.7747 3.74677 11.4766 4.30269 12.0004 5H10.6159C10.5057 4.6038 10.3739 4.23601 10.2229 3.90401C10.144 3.7304 10.0571 3.56117 9.96234 3.39978Z\"\n fill=\"currentColor\"\n />\n </svg>\n );\n }\n}\n","@use '../../../common/styles/variables' as *;\n@use '../../../common/mixins/inputs' as *;\n\n:host {\n display: block;\n height: auto;\n @include default-css-variables;\n width: 100%;\n}\n\nlabel {\n @include input-label;\n flex-direction: column;\n gap: 4px;\n font-family: var(--nylas-font-family);\n font-size: 16px;\n color: var(--nylas-base-800);\n\n p {\n margin: 0;\n }\n\n .error {\n color: var(--nylas-error);\n border-color: var(--nylas-error);\n }\n}\n\n.input_wrapper {\n display: flex;\n align-items: center;\n gap: 1rem;\n}\n\ninput[type='date'] {\n @include textfield;\n width: 100%;\n width: -moz-available;\n width: -webkit-fill-available;\n font-family: var(--nylas-font-family);\n padding: 0 8px;\n cursor: pointer;\n &::-webkit-calendar-picker-indicator {\n filter: invert(37%) sepia(51%) saturate(6324%) hue-rotate(215deg) brightness(94%) contrast(95%);\n cursor: pointer;\n }\n}\n\ninput:read-only {\n background-color: var(--nylas-base-100);\n cursor: not-allowed;\n}\n","import { Component, h, Prop, State, Event, EventEmitter, Listen, Watch, Element } from '@stencil/core';\nimport { sanitize } from '@/utils/utils';\nimport { ThemeConfig } from '@nylas/core';\n\nconst DefaultPlaceholder = {\n date: 'YYYY-MM-DD',\n};\n\n/**\n * The `nylas-date-component` component is a UI component that allows users to input text, email, or phone number values.\n * This component is used in the scheduling form to input text, email and phone number type inputs.\n */\n\n@Component({\n tag: 'nylas-date-component',\n styleUrl: 'nylas-date-component.scss',\n shadow: true,\n})\nexport class NylasDateComponent {\n /**\n * The host element\n */\n @Element() el!: HTMLElement;\n /**\n * The name of the input. This is used to identify the input when submitting a form.\n */\n @Prop() name: string = 'input';\n /**\n * The default value of the input. This is the value that is displayed when the input is rendered.\n */\n @Prop() defaultValue?: string;\n /**\n * The label of the input. This is displayed above the input.\n */\n @Prop() label: string = '';\n\n /**\n * The placeholder of the input. This is displayed when the input is empty.\n */\n @Prop() placeholder: string = DefaultPlaceholder['date'];\n /**\n * Whether the input is required. If true, the input must have a value when submitting a form.\n * Default is false. If the input is required and the value is empty, an error message is displayed.\n */\n @Prop() required: boolean = false;\n /**\n * Whether the input is read-only. If true, the input cannot be edited.\n * Default is false.\n */\n @Prop() readOnly: boolean = false;\n /**\n * Whether the input should be focused when rendered.\n * Default is false. If true, the input is focused when rendered.\n * Use this to set the focus on the first input in a form.\n */\n @Prop() autoFocus: boolean = false;\n /**\n * The pattern to validate the input value. If the value does not match the pattern, an error message is displayed.\n * Default is null. If the pattern is not set, the pattern is determined by the input type for 'email' and 'phone_number'.\n */\n @Prop() pattern?: RegExp;\n /**\n * The maximum length of the input value. If the value is longer than the maximum length, an error message is displayed.\n * Default is 255.\n */\n @Prop() maxLength: number = 255;\n /**\n * The error message to display when the value does not match the pattern.\n * Default is 'Invalid <field> format.' where <field> is the input label.\n */\n @Prop() patternError: string = '';\n\n /**\n * This error message is displayed when the input value is empty and the input is required.\n */\n @Prop() requiredError: string = '';\n\n /**\n * Error message to display when the date input is required and empty.\n */\n @Prop() errorMessage: string = '';\n\n /**\n * The minimum date that can be selected.\n */\n @Prop() minDate?: string;\n\n /**\n * The flag to indicate if the date input is in error state.\n */\n @Prop() hasError: boolean = false;\n\n /**\n * The theme configuration.\n */\n @Prop({ attribute: 'theme-config' }) readonly themeConfig?: ThemeConfig;\n\n /**\n * The input value state.\n */\n @State() value!: string;\n /**\n * The error message state.\n */\n @State() error: string = '';\n\n /**\n * State to track the validity of the date input.\n */\n @State() isDateValid: boolean = true;\n\n /**\n * This event is fired when the input value is changed.\n * The scheduling form listens for this event to validate the input value and submit the form.\n * If using outside of the scheduling form, listen for this event to validate the input value\n * and handle the input value change.\n */\n @Event() nylasFormInputChanged!: EventEmitter<{\n value: string;\n name: string;\n label: string;\n type: string;\n error: string;\n }>;\n\n @Event() nylasFormInputFocused!: EventEmitter<{\n value: string;\n name: string;\n }>;\n\n @Event() nylasFormInputBlurred!: EventEmitter<{\n value: string;\n name: string;\n }>;\n\n // Lifecycle methods\n @Watch('defaultValue')\n handleDefaultValueChange(newValue: string) {\n this.value = sanitize(newValue);\n if (this.value) {\n this.validatePattern(this.value, true);\n }\n }\n\n @Watch('themeConfig')\n themeConfigChangedHandler(newVal: ThemeConfig, oldVal: ThemeConfig) {\n if (newVal === oldVal) return;\n this.applyThemeConfig(newVal);\n }\n\n applyThemeConfig(themeConfig?: ThemeConfig) {\n if (themeConfig) {\n for (const [key, value] of Object.entries(themeConfig)) {\n this.el.style.setProperty(`${key}`, value);\n }\n }\n }\n\n connectedCallback() {\n // Use queueMicrotask to defer theme application until after React has set props.\n // This fixes the timing issue where connectedCallback fires before React sets themeConfig.\n queueMicrotask(() => {\n if (this.themeConfig) {\n this.applyThemeConfig(this.themeConfig);\n this.el.setAttribute('data-themed', '');\n }\n });\n }\n\n componentDidLoad() {\n this.value = sanitize(this.defaultValue || '');\n if (this.value) {\n this.validatePattern(this.value, true);\n }\n }\n\n // Event listeners\n /**\n * Listen for the bookingFormSubmitted event to validate the input value when the form is submitted.\n */\n @Listen('bookingFormSubmitted', { target: 'document' })\n handleBookingFormSubmitted(event: CustomEvent) {\n this.validatePattern(this.value);\n if (this.error) {\n event.preventDefault();\n }\n }\n\n @Listen('formSubmitted', { target: 'document' })\n async handleFormSubmitted(event: CustomEvent) {\n this.validatePattern(this.value);\n if (this.error) {\n event.preventDefault();\n }\n }\n\n // Methods\n handleInput(e: Event) {\n this.error = '';\n const target = e.target as HTMLInputElement;\n this.value = sanitize(target.value);\n this.isDateValid = target.validity.valid;\n this.nylasFormInputChanged.emit({\n value: this.value,\n name: this.name,\n label: this.label,\n error: this.error,\n type: 'date',\n });\n }\n\n handleBlur() {\n this.nylasFormInputBlurred.emit({\n value: this.value,\n name: this.name,\n });\n }\n\n handleFocus() {\n this.nylasFormInputFocused.emit({\n value: this.value,\n name: this.name,\n });\n }\n\n validatePattern(value: string, onLoad: boolean = false) {\n // Reset error\n this.error = '';\n if (!onLoad && ((this.required && !this.isDateValid) || (this.minDate && new Date(this.minDate) > new Date(value)))) {\n this.error = this.errorMessage || 'Please enter a valid date';\n this.nylasFormInputChanged.emit({\n value: this.value,\n name: this.name,\n label: this.label,\n error: this.error,\n type: 'date',\n });\n return;\n }\n // Check if the field is required and value is empty\n if (this.required && !value) {\n this.error = this.requiredError || 'This field is required.';\n return;\n }\n // Check if value matches pattern\n if (!this.pattern || (!value && !this.required)) return;\n\n if (this.pattern.test(value)) {\n this.error = '';\n } else {\n this.error = this.patternError || 'Invalid format.';\n }\n }\n\n render() {\n return (\n <label part=\"ic__label\" class={{ error: !!this.error || this.hasError }}>\n {this.label && (\n <p>\n <span class=\"label\">{this.label}</span>\n {this.required && <span class=\"required\">*</span>}\n </p>\n )}\n <div part=\"ic__input_wrapper\" class=\"input_wrapper\">\n <input\n type=\"date\"\n min={this.minDate}\n value={this.value}\n name={this.name}\n part=\"ic__date\"\n title={this.readOnly ? 'read-only field' : undefined}\n readOnly={this.readOnly}\n autoFocus={this.autoFocus}\n maxLength={this.maxLength}\n placeholder={this.placeholder}\n class={{ error: !!this.error || this.hasError }}\n onInput={e => this.handleInput(e)}\n onFocus={() => this.handleFocus()}\n onBlur={() => this.handleBlur()}\n />\n <slot name=\"additional-input\"></slot>\n </div>\n {this.error && <span class=\"error help-text\">{this.error}</span>}\n </label>\n );\n }\n}\n","@use '../../../common/styles/variables' as *;\n\n:host {\n display: block;\n position: relative;\n @include default-css-variables;\n}\n\n.time-picker {\n display: inline-block;\n width: 150px;\n font-family: var(--nylas-font-family);\n position: relative;\n\n @media #{$mobile} {\n width: auto;\n }\n\n input {\n width: 150px;\n height: 48px;\n text-align: center;\n font-size: 16px;\n font-family: inherit;\n color: var(--nylas-base-900);\n\n cursor: pointer;\n background: var(--nylas-base-0);\n border: 1px solid var(--nylas-base-200);\n border-radius: var(--nylas-border-radius-2x);\n\n @media #{$mobile} {\n width: 88px;\n }\n\n @media #{$small-mobile} {\n width: 68px;\n font-size: 15px;\n }\n\n &.focus {\n background: var(--nylas-base-0);\n }\n\n &:hover,\n &:active {\n border: 1px solid var(--nylas-primary);\n }\n\n &:active {\n outline: 2px solid var(--nylas-primary);\n }\n\n span {\n &.open {\n transform: rotate(90deg);\n }\n\n &.closed {\n transform: rotate(270deg);\n }\n }\n\n &.error {\n border: 1px solid var(--nylas-error);\n }\n }\n\n p.error {\n color: var(--nylas-error);\n font-size: 0.875rem;\n margin: 0;\n }\n}\n\n.times {\n display: block;\n margin-top: 0.5rem;\n background-color: var(--nylas-base-0);\n width: 100%;\n max-height: 336px;\n overflow: auto;\n border: 1px solid #ddd;\n z-index: 1;\n border-radius: 4px;\n position: absolute;\n box-shadow: 0px 4px 6px -2px #0000000d;\n box-shadow: 0px 10px 15px -3px #0000001a;\n\n ul {\n padding: 0;\n list-style-type: none;\n color: var(--nylas-base-900);\n max-height: 336px;\n\n li {\n padding: 16px, 12px, 16px, 12px;\n color: var(--nylas-base-900);\n padding: 12px 16px;\n text-decoration: none;\n display: block;\n font-family: inherit;\n font-size: 14px;\n font-weight: 400;\n line-height: 20px;\n letter-spacing: 0px;\n text-align: center;\n cursor: pointer;\n\n &.focused {\n background-color: var(--nylas-base-100);\n }\n\n &:hover,\n &:focus {\n background-color: var(--nylas-base-100);\n }\n\n label {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n\n input {\n margin: 0;\n }\n }\n }\n }\n}\n","import { LANGUAGE_CODE } from '@/common/constants';\nimport { autocompleteTimeFormat, convertTo12HourFormat, convertTo24HourFormat, roundToNearest15Minutes, validateExactTimeFormat, validateTimeFormatInput } from '@/utils/utils';\nimport { Component, h, State, Prop, Event, EventEmitter, Listen, Element, Host, Watch } from '@stencil/core';\nimport dayjs from 'dayjs';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport i18next from '@/utils/i18n';\nimport { ThemeConfig } from '@nylas/core';\n\ndayjs.extend(customParseFormat);\n\ntype Time = { id: number; value: string };\n\n/**\n * The `nylas-time-window-picker` component is a time picker that can be used to select a time.\n * @part time-picker - The time picker container\n * @part time-input - The time input\n * @part times - The list of times\n */\n@Component({\n tag: 'nylas-time-window-picker',\n styleUrl: 'nylas-time-window-picker.scss',\n shadow: true,\n})\nexport class TimeInput {\n @Element() el!: HTMLElement;\n private timeInput!: HTMLInputElement;\n private timeMenu!: HTMLElement;\n\n /**\n * The time to display in the input.\n * This is passed by the parent component\n */\n @Prop() time!: string;\n /**\n * This is the start time value if one is set by the parent component.\n * It is useful if this component is used to render an end time which\n * should not be before the start time, defining the earliest selectable time.\n */\n @Prop() minimumStartTime: string | null = null;\n\n /**\n * The placeholder text for the input.\n */\n @Prop() placeholder: string = 'hh:mmam/pm';\n /**\n * The name of the input.\n */\n @Prop() name!: string;\n /**\n * This sets the error state of the input.\n */\n @Prop({ reflect: true }) hasError: boolean = false;\n\n /**\n * The language of the input.\n */\n @Prop() language: LANGUAGE_CODE = LANGUAGE_CODE.en;\n\n /**\n * The theme configuration.\n */\n @Prop({ attribute: 'theme-config' }) readonly themeConfig?: ThemeConfig;\n\n /**\n * The error message to display if the time is invalid.\n */\n @State() err: string = '';\n /**\n * Toggle to show the list of times.\n */\n @State() showTimes: boolean = false;\n /**\n * The aria-activedescendant attribute for the listbox element to indicate the currently active\n * option in the list box to screen readers. The value of aria-activedescendant is the ID of\n * the active option.\n */\n @State() ariaActivedescendant: string = '';\n /**\n * The list of times to display in the dropdown.\n */\n @State() times: Time[] = this.generateTimes();\n /**\n * This is used to scroll to the selected time when the time is changed.\n */\n @State() shouldAutoScroll: boolean = false;\n\n /**\n * This event is fired when the time is changed.\n */\n @Event() timeChange!: EventEmitter<{\n key: string;\n value: string;\n }>;\n\n /**\n * This event is fired when the form has an error. The parent component\n * can listen for this event and display an error message or set form validity.\n */\n @Event() timeWindowFormError!: EventEmitter<{\n key: string;\n message: string;\n }>;\n\n // Event listeners\n @Listen('click', { target: 'document', capture: true })\n handleOutsideClick(event: MouseEvent) {\n // Get the path of the event\n const path = event.composedPath();\n\n // Check if the path includes the host element\n const isClickInside = path.includes(this.el);\n\n if (!isClickInside && this.showTimes) {\n this.showTimes = false;\n }\n }\n\n @Watch('time')\n timeChangedHandler() {\n this.validateTimeAgainstMinimum();\n }\n\n @Watch('minimumStartTime')\n minimumStartTimeChangedHandler() {\n this.validateTimeAgainstMinimum();\n }\n\n @Watch('themeConfig')\n themeConfigChangedHandler(newVal: ThemeConfig, _oldVal: ThemeConfig) {\n this.applyThemeConfig(newVal);\n }\n\n applyThemeConfig(themeConfig?: ThemeConfig) {\n if (themeConfig) {\n for (const [key, value] of Object.entries(themeConfig)) {\n this.el.style.setProperty(`${key}`, value);\n }\n }\n }\n\n private validateTimeAgainstMinimum() {\n if (this.minimumStartTime) {\n // Parse the minimum start time properly using dayjs\n const minimumTime = dayjs(this.minimumStartTime, 'hh:mma');\n const selectedTime = dayjs(this.time, 'hh:mma');\n\n this.times = this.generateTimes();\n const errorMessage = i18next.t('nylasTimeWindowPicker.errors.invalid');\n\n // Check if selected time is before minimum time\n if (selectedTime.isBefore(minimumTime)) {\n this.err = errorMessage;\n this.timeWindowFormError.emit({\n key: this.el.id,\n message: errorMessage,\n });\n } else {\n // Clear the error if the time is valid\n this.err = '';\n this.timeWindowFormError.emit({\n key: this.el.id,\n message: '',\n });\n }\n } else {\n // Clear any existing error if no minimum start time is set\n this.err = '';\n this.timeWindowFormError.emit({\n key: this.el.id,\n message: '',\n });\n }\n }\n\n connectedCallback() {\n // Use queueMicrotask to defer theme application until after React has set props.\n // This fixes the timing issue where connectedCallback fires before React sets themeConfig.\n queueMicrotask(() => {\n if (this.themeConfig) {\n this.applyThemeConfig(this.themeConfig);\n this.el.setAttribute('data-themed', '');\n }\n });\n }\n\n componentWillLoad() {\n // Theme already applied in connectedCallback via queueMicrotask\n }\n\n componentDidLoad() {\n // Validate time against minimum on initial load\n this.validateTimeAgainstMinimum();\n }\n\n componentDidRender() {\n if (this.showTimes && this.shouldAutoScroll) {\n const autocompletedTime = autocompleteTimeFormat(this.time);\n const optionIndex = this.times.findIndex(time => time.value === autocompletedTime);\n if (optionIndex > -1) {\n this.shouldAutoScroll = false;\n this.scrollToViewWithinParent(optionIndex);\n }\n return;\n }\n }\n\n private handleTimeChange(_e: Event, input: string) {\n const timePart = input.split(':');\n if (timePart[0] === '00' && timePart[1].slice(-2) == 'pm') {\n const errorMessage = i18next.t('nylasTimeWindowPicker.errors.invalid');\n this.err = errorMessage;\n this.timeWindowFormError.emit({\n key: this.el.id,\n message: errorMessage,\n });\n }\n if (!validateTimeFormatInput(input)) {\n const errorMessage = i18next.t('nylasTimeWindowPicker.errors.invalid');\n this.err = errorMessage;\n this.timeWindowFormError.emit({\n key: this.el.id,\n message: errorMessage,\n });\n } else {\n this.err = '';\n this.timeWindowFormError.emit({\n key: this.el.id,\n message: '',\n });\n }\n if (this.err) {\n return;\n }\n this.timeChange.emit({\n key: this.el.id,\n value: input,\n });\n }\n\n private handleTimeAutocomplete(event: Event) {\n const targetInput = (event.target as HTMLInputElement)?.value;\n const input = this.language !== LANGUAGE_CODE.en ? convertTo12HourFormat(targetInput) : targetInput;\n const errorMessage = i18next.t('nylasTimeWindowPicker.errors.invalid');\n if (!validateTimeFormatInput(input)) {\n this.err = errorMessage;\n this.timeWindowFormError.emit({\n key: this.el.id,\n message: errorMessage,\n });\n return;\n }\n if (input === '') {\n const newTime = roundToNearest15Minutes().format('hh:mma');\n this.timeChange.emit({\n key: this.el.id,\n value: newTime,\n });\n return;\n }\n if (!validateExactTimeFormat(input)) {\n const autocompletedTime = autocompleteTimeFormat(input);\n this.timeChange.emit({\n key: this.el.id,\n value: autocompletedTime,\n });\n return;\n }\n this.timeChange.emit({\n key: this.el.id,\n value: input,\n });\n }\n\n private handleOnInput(event: Event) {\n const input = (event.target as HTMLInputElement)?.value;\n if (!validateTimeFormatInput(input)) {\n return;\n }\n if (input === '') {\n const newTime = roundToNearest15Minutes().format('hh:mma');\n const optionIndex = this.times.findIndex(time => time.value === newTime);\n if (optionIndex > -1) {\n this.scrollToViewWithinParent(optionIndex);\n }\n return;\n }\n if (!validateExactTimeFormat(input)) {\n const autocompletedTime = autocompleteTimeFormat(input);\n const optionIndex = this.times.findIndex(time => time.value === autocompletedTime);\n if (optionIndex > -1) {\n this.scrollToViewWithinParent(optionIndex);\n }\n return;\n }\n }\n\n private generateTimes() {\n const times: Time[] = [];\n let startTime = dayjs().set('hour', 0).set('minute', 0).set('second', 0); // Set to 12:00 am\n if (this.minimumStartTime) {\n startTime = dayjs(this.minimumStartTime, 'hh:mma');\n }\n const diff = startTime.endOf('day').diff(startTime, 'minutes');\n const iterations = Math.round(diff / 15);\n for (let i = 0; i < iterations + 1; i++) {\n // 96 represents the total number of 15-minute increments in a day (24 hours * 60 minutes / 15 minutes)\n const time = startTime.add(i * 15, 'minute');\n if (i == iterations && time.format('hh:mma').includes('am')) {\n break;\n }\n times.push({ id: i, value: time.format('hh:mma') });\n }\n return times;\n }\n\n private handleComboboxKeyDown(event: KeyboardEvent): void {\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n if (!this.showTimes) {\n this.showTimes = true;\n this.shouldAutoScroll = true;\n return;\n }\n if (this.ariaActivedescendant === '') {\n this.ariaActivedescendant = this.times[0].id.toString();\n this.focusOption(0);\n } else {\n const currentIndex = this.times.findIndex(time => time.id.toString() === this.ariaActivedescendant);\n const nextIndex = currentIndex + 1 < this.times.length ? currentIndex + 1 : 0;\n this.ariaActivedescendant = this.times[nextIndex].id.toString();\n this.focusOption(nextIndex);\n }\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n if (this.ariaActivedescendant === '') {\n this.ariaActivedescendant = this.times[this.times.length - 1].id.toString();\n this.focusOption(this.times.length - 1);\n } else {\n const currentIndex = this.times.findIndex(time => time.id.toString() === this.ariaActivedescendant);\n const prevIndex = currentIndex - 1 >= 0 ? currentIndex - 1 : this.times.length - 1;\n this.ariaActivedescendant = this.times[prevIndex].id.toString();\n this.focusOption(prevIndex);\n }\n } else if (event.key === 'Escape') {\n this.showTimes = false;\n this.timeInput.focus();\n }\n }\n\n private handleListboxKeydown(e: KeyboardEvent) {\n const items = this.times;\n const currentIndex = items.findIndex(item => item.id.toString() === this.ariaActivedescendant);\n\n if (e.key === 'ArrowDown' || (e.key === 'Tab' && !e.shiftKey)) {\n e.preventDefault();\n const nextIndex = currentIndex + 1 < items.length ? currentIndex + 1 : 0;\n this.ariaActivedescendant = items[nextIndex].id.toString();\n this.focusOption(nextIndex);\n } else if (e.key === 'ArrowUp' || (e.key === 'Tab' && e.shiftKey)) {\n e.preventDefault();\n const prevIndex = currentIndex - 1 >= 0 ? currentIndex - 1 : items.length - 1;\n this.ariaActivedescendant = items[prevIndex].id.toString();\n this.focusOption(prevIndex);\n } else if (e.key === 'Enter') {\n e.preventDefault();\n if (this.ariaActivedescendant) {\n const option = items[currentIndex];\n this.handleTimeChange(e, option.value);\n this.showTimes = false;\n this.ariaActivedescendant = '';\n this.timeInput.focus();\n }\n } else if (e.key === 'Escape') {\n this.showTimes = false;\n this.timeInput.focus();\n }\n }\n\n scrollToViewWithinParent(optionIndex: number) {\n const option = this.times[optionIndex];\n const childElement = this.el.shadowRoot?.getElementById(option.id.toString()) as HTMLLIElement;\n const parentElement = this.timeMenu;\n\n this.ariaActivedescendant = option.id.toString();\n\n // Scroll child into view within parent\n const childRect = childElement.getBoundingClientRect();\n const parentRect = parentElement.getBoundingClientRect();\n\n if (childRect.top < parentRect.top) {\n // Child is above the visible area of the parent\n parentElement.scrollTop -= parentRect.top - childRect.top;\n } else if (childRect.bottom > parentRect.bottom) {\n // Child is below the visible area of the parent\n parentElement.scrollTop += childRect.bottom - parentRect.bottom;\n }\n\n if (childRect.left < parentRect.left) {\n // Child is to the left of the visible area of the parent\n parentElement.scrollLeft -= parentRect.left - childRect.left;\n } else if (childRect.right > parentRect.right) {\n // Child is to the right of the visible area of the parent\n parentElement.scrollLeft += childRect.right - parentRect.right;\n }\n }\n\n focusOption(index: number) {\n const option = this.times[index];\n if (!option) return; // Guard clause in case index is out of bounds\n\n const elementId = option.id.toString();\n const element = this.el.shadowRoot?.getElementById(elementId) as HTMLLIElement;\n\n if (element) {\n element.focus(); // Set focus on the element\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n }\n }\n\n render() {\n const is24HourFormat = this.language === LANGUAGE_CODE.en ? false : true;\n return (\n <Host>\n <div class=\"time-picker\" part=\"time-picker\">\n <input\n type=\"text\"\n name={this.name}\n id={this.name}\n part=\"time-input\"\n class={{\n 'time-input': true,\n 'error': !!this.err || this.hasError,\n }}\n ref={el => (this.timeInput = el as HTMLInputElement)}\n value={is24HourFormat ? convertTo24HourFormat(this.time) : this.time}\n onClick={() => {\n this.showTimes = !this.showTimes;\n this.shouldAutoScroll = true;\n }}\n aria-haspopup=\"listbox\"\n aria-label={this.name}\n aria-expanded={this.showTimes ? 'true' : 'false'}\n placeholder={this.placeholder}\n onKeyDown={e => this.handleComboboxKeyDown(e)}\n onInput={event => this.handleOnInput(event)}\n onBlur={event => this.handleTimeAutocomplete(event)}\n />\n {this.err && <div class=\"invalid-time-icon\">{/* Icon here */}</div>}\n {this.showTimes && (\n <div class=\"times\" part=\"times\" ref={el => (this.timeMenu = el as HTMLElement)}>\n <ul tabindex=\"-1\" role=\"listbox\" aria-label={this.name} aria-activedescendant={this.ariaActivedescendant} onKeyDown={e => this.handleListboxKeydown(e)}>\n {this.times.map(option => (\n <li\n tabindex=\"0\"\n key={option.id}\n id={option.id.toString()}\n class={{\n focused: this.ariaActivedescendant === option.id.toString(),\n }}\n onClick={e => {\n this.handleTimeChange(e, option.value);\n this.showTimes = false;\n this.timeInput.focus();\n }}\n role=\"option\"\n >\n {`${is24HourFormat ? convertTo24HourFormat(option.value) : option.value}`}\n </li>\n ))}\n </ul>\n </div>\n )}\n {!this.showTimes && this.err && (\n <p class=\"error\" id=\"email-error\">\n {this.err}\n </p>\n )}\n </div>\n </Host>\n );\n }\n}\n"],"mappings":"oOAAA,MAAMA,EAAU,iC,MCOHC,EAAS,MALtB,WAAAC,CAAAC,G,UAMUC,KAAKC,MAAW,KAChBD,KAAME,OAAW,IAY1B,CAVC,MAAAC,GACE,OACEC,EAAK,OAAAC,IAAA,2CAAAC,MAAM,6BAA6BL,MAAOD,KAAKC,MAAOC,OAAQF,KAAKE,OAAQK,QAAQ,YAAYC,KAAK,QACvGJ,EACE,QAAAC,IAAA,2CAAAI,EAAE,wiDACFD,KAAK,iB,aChBf,MAAME,EAAwB,ipHCI9B,MAAMC,EAAqB,CACzBC,KAAM,c,MAaKC,EAAkB,MAL/B,WAAAf,CAAAC,G,iMAaUC,KAAIc,KAAW,QAQfd,KAAKe,MAAW,GAKhBf,KAAAgB,YAAsBL,EAAmB,QAKzCX,KAAQiB,SAAY,MAKpBjB,KAAQkB,SAAY,MAMpBlB,KAASmB,UAAY,MAUrBnB,KAASoB,UAAW,IAKpBpB,KAAYqB,aAAW,GAKvBrB,KAAasB,cAAW,GAKxBtB,KAAYuB,aAAW,GAUvBvB,KAA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I,wBAAyBd,KAAKuF,qBAAsB8F,UAAWjI,GAAKpD,KAAKuJ,qBAAqBnG,IACjJpD,KAAKwF,MAAMgG,KAAI7B,GACdvJ,EACE,MAAAkL,SAAS,IACTjL,IAAKsJ,EAAOhD,GACZA,GAAIgD,EAAOhD,GAAGoC,WACd1E,MAAO,CACLoH,QAASzL,KAAKuF,uBAAyBoE,EAAOhD,GAAGoC,YAEnDqC,QAAShI,IACPpD,KAAKoH,iBAAiBhE,EAAGuG,EAAO9H,OAChC7B,KAAKsF,UAAY,MACjBtF,KAAKqJ,UAAUC,OAAO,EAExBiC,KAAK,UAEJ,GAAGP,EAAiBG,EAAsBxB,EAAO9H,OAAS8H,EAAO9H,cAM1E7B,KAAKsF,WAAatF,KAAKqF,KACvBjF,EAAG,KAAAC,IAAA,2CAAAgE,MAAM,QAAQsC,GAAG,eACjB3G,KAAKqF,M","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["iconCss","GlobeIcon","constructor","hostRef","this","width","height","render","h","key","xmlns","viewBox","fill","d","nylasDateComponentCss","DefaultPlaceholder","date","NylasDateComponent","name","label","placeholder","required","readOnly","autoFocus","maxLength","patternError","requiredError","errorMessage","hasError","error","isDateValid","handleDefaultValueChange","newValue","value","sanitize","validatePattern","themeConfigChangedHandler","newVal","oldVal","applyThemeConfig","themeConfig","Object","entries","el","style","setProperty","connectedCallback","queueMicrotask","setAttribute","componentDidLoad","defaultValue","handleBookingFormSubmitted","event","preventDefault","handleFormSubmitted","handleInput","e","target","validity","valid","nylasFormInputChanged","emit","type","handleBlur","nylasFormInputBlurred","handleFocus","nylasFormInputFocused","onLoad","minDate","Date","pattern","test","part","class","min","title","undefined","onInput","onFocus","onBlur","nylasTimeWindowPickerCss","dayjs","extend","customParseFormat","TimeInput","minimumStartTime","language","LANGUAGE_CODE","en","err","showTimes","ariaActivedescendant","times","generateTimes","shouldAutoScroll","handleOutsideClick","path","composedPath","isClickInside","includes","timeChangedHandler","validateTimeAgainstMinimum","minimumStartTimeChangedHandler","_oldVal","minimumTime","selectedTime","time","i18next","t","isBefore","timeWindowFormError","id","message","componentWillLoad","componentDidRender","autocompletedTime","autocompleteTimeFormat","optionIndex","findIndex","scrollToViewWithinParent","handleTimeChange","_e","input","timePart","split","slice","validateTimeFormatInput","timeChange","handleTimeAutocomplete","targetInput","convertTo12HourFormat","newTime","roundToNearest15Minutes","format","validateExactTimeFormat","handleOnInput","startTime","set","diff","endOf","iterations","Math","round","i","add","push","handleComboboxKeyDown","toString","focusOption","currentIndex","nextIndex","length","prevIndex","timeInput","focus","handleListboxKeydown","items","item","shiftKey","option","childElement","shadowRoot","getElementById","parentElement","timeMenu","childRect","getBoundingClientRect","parentRect","top","scrollTop","bottom","left","scrollLeft","right","index","elementId","element","scrollIntoView","behavior","block","is24HourFormat","Host","ref","convertTo24HourFormat","onClick","onKeyDown","tabindex","role","map","focused"],"sources":["src/common/icons/icon.css?tag=globe-icon&encapsulation=scoped","src/common/icons/globe.tsx","src/components/design-system/nylas-date-component/nylas-date-component.scss?tag=nylas-date-component&encapsulation=shadow","src/components/design-system/nylas-date-component/nylas-date-component.tsx","src/components/scheduler-editor/nylas-time-window-picker/nylas-time-window-picker.scss?tag=nylas-time-window-picker&encapsulation=shadow","src/components/scheduler-editor/nylas-time-window-picker/nylas-time-window-picker.tsx"],"sourcesContent":[":host {\n display: flex;\n}\n","import { Component, Prop, h } from '@stencil/core';\n\n@Component({\n tag: 'globe-icon',\n styleUrl: 'icon.css',\n scoped: true,\n})\nexport class GlobeIcon {\n @Prop() width: string = '16';\n @Prop() height: string = '16';\n\n render() {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" width={this.width} height={this.height} viewBox=\"0 0 16 16\" fill=\"none\">\n <path\n d=\"M8 14C11.3137 14 14 11.3137 14 8C14 4.68629 11.3137 2 8 2C4.68629 2 2 4.68629 2 8C2 11.3137 4.68629 14 8 14ZM8 3C8.37372 3 8.87543 3.35608 9.31258 4.31781C9.4073 4.52619 9.49448 4.75446 9.57265 5H6.42735C6.50552 4.75446 6.5927 4.52619 6.68742 4.31781C7.12457 3.35608 7.62628 3 8 3ZM5.77705 3.90401C5.62614 4.23601 5.49428 4.6038 5.38411 5H3.99963C4.52341 4.30269 5.22525 3.74677 6.03766 3.39978C5.94287 3.56117 5.85596 3.7304 5.77705 3.90401ZM5.16299 6C5.05694 6.6275 5 7.30146 5 8C5 8.69854 5.05694 9.3725 5.16299 10H3.41604C3.14845 9.38754 3 8.7111 3 8C3 7.2889 3.14845 6.61246 3.41604 6H5.16299ZM5.38411 11C5.49428 11.3962 5.62614 11.764 5.77705 12.096C5.85596 12.2696 5.94287 12.4388 6.03766 12.6002C5.22525 12.2532 4.52341 11.6973 3.99963 11H5.38411ZM6.42735 11H9.57265C9.49448 11.2455 9.4073 11.4738 9.31258 11.6822C8.87543 12.6439 8.37372 13 8 13C7.62628 13 7.12457 12.6439 6.68742 11.6822C6.5927 11.4738 6.50552 11.2455 6.42735 11ZM9.82134 10H6.17866C6.06438 9.3892 6 8.71396 6 8C6 7.28604 6.06438 6.6108 6.17866 6H9.82134C9.93562 6.6108 10 7.28604 10 8C10 8.71396 9.93562 9.3892 9.82134 10ZM10.6159 11H12.0004C11.4766 11.6973 10.7747 12.2532 9.96234 12.6002C10.0571 12.4388 10.144 12.2696 10.2229 12.096C10.3739 11.764 10.5057 11.3962 10.6159 11ZM12.584 10H10.837C10.9431 9.3725 11 8.69854 11 8C11 7.30146 10.9431 6.6275 10.837 6H12.584C12.8516 6.61246 13 7.2889 13 8C13 8.7111 12.8516 9.38754 12.584 10ZM9.96234 3.39978C10.7747 3.74677 11.4766 4.30269 12.0004 5H10.6159C10.5057 4.6038 10.3739 4.23601 10.2229 3.90401C10.144 3.7304 10.0571 3.56117 9.96234 3.39978Z\"\n fill=\"currentColor\"\n />\n </svg>\n );\n }\n}\n","@use '../../../common/styles/variables' as *;\n@use '../../../common/mixins/inputs' as *;\n\n:host {\n display: block;\n height: auto;\n @include default-css-variables;\n width: 100%;\n}\n\nlabel {\n @include input-label;\n flex-direction: column;\n gap: 4px;\n font-family: var(--nylas-font-family);\n font-size: 16px;\n color: var(--nylas-base-800);\n\n p {\n margin: 0;\n }\n\n .error {\n color: var(--nylas-error);\n border-color: var(--nylas-error);\n }\n}\n\n.input_wrapper {\n display: flex;\n align-items: center;\n gap: 1rem;\n}\n\ninput[type='date'] {\n @include textfield;\n width: 100%;\n width: -moz-available;\n width: -webkit-fill-available;\n font-family: var(--nylas-font-family);\n padding: 0 8px;\n cursor: pointer;\n &::-webkit-calendar-picker-indicator {\n filter: invert(37%) sepia(51%) saturate(6324%) hue-rotate(215deg) brightness(94%) contrast(95%);\n cursor: pointer;\n }\n}\n\ninput:read-only {\n background-color: var(--nylas-base-100);\n cursor: not-allowed;\n}\n","import { Component, h, Prop, State, Event, EventEmitter, Listen, Watch, Element } from '@stencil/core';\nimport { sanitize } from '@/utils/utils';\nimport { ThemeConfig } from '@nylas/core';\n\nconst DefaultPlaceholder = {\n date: 'YYYY-MM-DD',\n};\n\n/**\n * The `nylas-date-component` component is a UI component that allows users to input text, email, or phone number values.\n * This component is used in the scheduling form to input text, email and phone number type inputs.\n */\n\n@Component({\n tag: 'nylas-date-component',\n styleUrl: 'nylas-date-component.scss',\n shadow: true,\n})\nexport class NylasDateComponent {\n /**\n * The host element\n */\n @Element() el!: HTMLElement;\n /**\n * The name of the input. This is used to identify the input when submitting a form.\n */\n @Prop() name: string = 'input';\n /**\n * The default value of the input. This is the value that is displayed when the input is rendered.\n */\n @Prop() defaultValue?: string;\n /**\n * The label of the input. This is displayed above the input.\n */\n @Prop() label: string = '';\n\n /**\n * The placeholder of the input. This is displayed when the input is empty.\n */\n @Prop() placeholder: string = DefaultPlaceholder['date'];\n /**\n * Whether the input is required. If true, the input must have a value when submitting a form.\n * Default is false. If the input is required and the value is empty, an error message is displayed.\n */\n @Prop() required: boolean = false;\n /**\n * Whether the input is read-only. If true, the input cannot be edited.\n * Default is false.\n */\n @Prop() readOnly: boolean = false;\n /**\n * Whether the input should be focused when rendered.\n * Default is false. If true, the input is focused when rendered.\n * Use this to set the focus on the first input in a form.\n */\n @Prop() autoFocus: boolean = false;\n /**\n * The pattern to validate the input value. If the value does not match the pattern, an error message is displayed.\n * Default is null. If the pattern is not set, the pattern is determined by the input type for 'email' and 'phone_number'.\n */\n @Prop() pattern?: RegExp;\n /**\n * The maximum length of the input value. If the value is longer than the maximum length, an error message is displayed.\n * Default is 255.\n */\n @Prop() maxLength: number = 255;\n /**\n * The error message to display when the value does not match the pattern.\n * Default is 'Invalid <field> format.' where <field> is the input label.\n */\n @Prop() patternError: string = '';\n\n /**\n * This error message is displayed when the input value is empty and the input is required.\n */\n @Prop() requiredError: string = '';\n\n /**\n * Error message to display when the date input is required and empty.\n */\n @Prop() errorMessage: string = '';\n\n /**\n * The minimum date that can be selected.\n */\n @Prop() minDate?: string;\n\n /**\n * The flag to indicate if the date input is in error state.\n */\n @Prop() hasError: boolean = false;\n\n /**\n * The theme configuration.\n */\n @Prop({ attribute: 'theme-config' }) readonly themeConfig?: ThemeConfig;\n\n /**\n * The input value state.\n */\n @State() value!: string;\n /**\n * The error message state.\n */\n @State() error: string = '';\n\n /**\n * State to track the validity of the date input.\n */\n @State() isDateValid: boolean = true;\n\n /**\n * This event is fired when the input value is changed.\n * The scheduling form listens for this event to validate the input value and submit the form.\n * If using outside of the scheduling form, listen for this event to validate the input value\n * and handle the input value change.\n */\n @Event() nylasFormInputChanged!: EventEmitter<{\n value: string;\n name: string;\n label: string;\n type: string;\n error: string;\n }>;\n\n @Event() nylasFormInputFocused!: EventEmitter<{\n value: string;\n name: string;\n }>;\n\n @Event() nylasFormInputBlurred!: EventEmitter<{\n value: string;\n name: string;\n }>;\n\n // Lifecycle methods\n @Watch('defaultValue')\n handleDefaultValueChange(newValue: string) {\n this.value = sanitize(newValue);\n if (this.value) {\n this.validatePattern(this.value, true);\n }\n }\n\n @Watch('themeConfig')\n themeConfigChangedHandler(newVal: ThemeConfig, oldVal: ThemeConfig) {\n if (newVal === oldVal) return;\n this.applyThemeConfig(newVal);\n }\n\n applyThemeConfig(themeConfig?: ThemeConfig) {\n if (themeConfig) {\n for (const [key, value] of Object.entries(themeConfig)) {\n this.el.style.setProperty(`${key}`, value);\n }\n }\n }\n\n connectedCallback() {\n // Use queueMicrotask to defer theme application until after React has set props.\n // This fixes the timing issue where connectedCallback fires before React sets themeConfig.\n queueMicrotask(() => {\n if (this.themeConfig) {\n this.applyThemeConfig(this.themeConfig);\n this.el.setAttribute('data-themed', '');\n }\n });\n }\n\n componentDidLoad() {\n this.value = sanitize(this.defaultValue || '');\n if (this.value) {\n this.validatePattern(this.value, true);\n }\n }\n\n // Event listeners\n /**\n * Listen for the bookingFormSubmitted event to validate the input value when the form is submitted.\n */\n @Listen('bookingFormSubmitted', { target: 'document' })\n handleBookingFormSubmitted(event: CustomEvent) {\n this.validatePattern(this.value);\n if (this.error) {\n event.preventDefault();\n }\n }\n\n @Listen('formSubmitted', { target: 'document' })\n async handleFormSubmitted(event: CustomEvent) {\n this.validatePattern(this.value);\n if (this.error) {\n event.preventDefault();\n }\n }\n\n // Methods\n handleInput(e: Event) {\n this.error = '';\n const target = e.target as HTMLInputElement;\n this.value = sanitize(target.value);\n this.isDateValid = target.validity.valid;\n this.nylasFormInputChanged.emit({\n value: this.value,\n name: this.name,\n label: this.label,\n error: this.error,\n type: 'date',\n });\n }\n\n handleBlur() {\n this.nylasFormInputBlurred.emit({\n value: this.value,\n name: this.name,\n });\n }\n\n handleFocus() {\n this.nylasFormInputFocused.emit({\n value: this.value,\n name: this.name,\n });\n }\n\n validatePattern(value: string, onLoad: boolean = false) {\n // Reset error\n this.error = '';\n if (!onLoad && ((this.required && !this.isDateValid) || (this.minDate && new Date(this.minDate) > new Date(value)))) {\n this.error = this.errorMessage || 'Please enter a valid date';\n this.nylasFormInputChanged.emit({\n value: this.value,\n name: this.name,\n label: this.label,\n error: this.error,\n type: 'date',\n });\n return;\n }\n // Check if the field is required and value is empty\n if (this.required && !value) {\n this.error = this.requiredError || 'This field is required.';\n return;\n }\n // Check if value matches pattern\n if (!this.pattern || (!value && !this.required)) return;\n\n if (this.pattern.test(value)) {\n this.error = '';\n } else {\n this.error = this.patternError || 'Invalid format.';\n }\n }\n\n render() {\n return (\n <label part=\"ic__label\" class={{ error: !!this.error || this.hasError }}>\n {this.label && (\n <p>\n <span class=\"label\">{this.label}</span>\n {this.required && <span class=\"required\">*</span>}\n </p>\n )}\n <div part=\"ic__input_wrapper\" class=\"input_wrapper\">\n <input\n type=\"date\"\n min={this.minDate}\n value={this.value}\n name={this.name}\n part=\"ic__date\"\n title={this.readOnly ? 'read-only field' : undefined}\n readOnly={this.readOnly}\n autoFocus={this.autoFocus}\n maxLength={this.maxLength}\n placeholder={this.placeholder}\n class={{ error: !!this.error || this.hasError }}\n onInput={e => this.handleInput(e)}\n onFocus={() => this.handleFocus()}\n onBlur={() => this.handleBlur()}\n />\n <slot name=\"additional-input\"></slot>\n </div>\n {this.error && <span class=\"error help-text\">{this.error}</span>}\n </label>\n );\n }\n}\n","@use '../../../common/styles/variables' as *;\n\n:host {\n display: block;\n position: relative;\n @include default-css-variables;\n}\n\n.time-picker {\n display: inline-block;\n width: 150px;\n font-family: var(--nylas-font-family);\n position: relative;\n\n @media #{$mobile} {\n width: auto;\n }\n\n input {\n width: 150px;\n height: 48px;\n text-align: center;\n font-size: 16px;\n font-family: inherit;\n color: var(--nylas-base-900);\n\n cursor: pointer;\n background: var(--nylas-base-0);\n border: 1px solid var(--nylas-base-200);\n border-radius: var(--nylas-border-radius-2x);\n\n @media #{$mobile} {\n width: 88px;\n }\n\n @media #{$small-mobile} {\n width: 68px;\n font-size: 15px;\n }\n\n &.focus {\n background: var(--nylas-base-0);\n }\n\n &:hover,\n &:active {\n border: 1px solid var(--nylas-primary);\n }\n\n &:active {\n outline: 2px solid var(--nylas-primary);\n }\n\n span {\n &.open {\n transform: rotate(90deg);\n }\n\n &.closed {\n transform: rotate(270deg);\n }\n }\n\n &.error {\n border: 1px solid var(--nylas-error);\n }\n }\n\n p.error {\n color: var(--nylas-error);\n font-size: 0.875rem;\n margin: 0;\n }\n}\n\n.times {\n display: block;\n margin-top: 0.5rem;\n background-color: var(--nylas-base-0);\n width: 100%;\n max-height: 336px;\n overflow: auto;\n border: 1px solid #ddd;\n z-index: 1;\n border-radius: 4px;\n position: absolute;\n box-shadow: 0px 4px 6px -2px #0000000d;\n box-shadow: 0px 10px 15px -3px #0000001a;\n\n ul {\n padding: 0;\n list-style-type: none;\n color: var(--nylas-base-900);\n max-height: 336px;\n\n li {\n padding: 16px, 12px, 16px, 12px;\n color: var(--nylas-base-900);\n padding: 12px 16px;\n text-decoration: none;\n display: block;\n font-family: inherit;\n font-size: 14px;\n font-weight: 400;\n line-height: 20px;\n letter-spacing: 0px;\n text-align: center;\n cursor: pointer;\n\n &.focused {\n background-color: var(--nylas-base-100);\n }\n\n &:hover,\n &:focus {\n background-color: var(--nylas-base-100);\n }\n\n label {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n\n input {\n margin: 0;\n }\n }\n }\n }\n}\n","import { LANGUAGE_CODE } from '@/common/constants';\nimport { autocompleteTimeFormat, convertTo12HourFormat, convertTo24HourFormat, roundToNearest15Minutes, validateExactTimeFormat, validateTimeFormatInput } from '@/utils/utils';\nimport { Component, h, State, Prop, Event, EventEmitter, Listen, Element, Host, Watch } from '@stencil/core';\nimport dayjs from 'dayjs';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport i18next from '@/utils/i18n';\nimport { ThemeConfig } from '@nylas/core';\n\ndayjs.extend(customParseFormat);\n\ntype Time = { id: number; value: string };\n\n/**\n * The `nylas-time-window-picker` component is a time picker that can be used to select a time.\n * @part time-picker - The time picker container\n * @part time-input - The time input\n * @part times - The list of times\n */\n@Component({\n tag: 'nylas-time-window-picker',\n styleUrl: 'nylas-time-window-picker.scss',\n shadow: true,\n})\nexport class TimeInput {\n @Element() el!: HTMLElement;\n private timeInput!: HTMLInputElement;\n private timeMenu!: HTMLElement;\n\n /**\n * The time to display in the input.\n * This is passed by the parent component\n */\n @Prop() time!: string;\n /**\n * This is the start time value if one is set by the parent component.\n * It is useful if this component is used to render an end time which\n * should not be before the start time, defining the earliest selectable time.\n */\n @Prop() minimumStartTime: string | null = null;\n\n /**\n * The placeholder text for the input.\n */\n @Prop() placeholder: string = 'hh:mmam/pm';\n /**\n * The name of the input.\n */\n @Prop() name!: string;\n /**\n * This sets the error state of the input.\n */\n @Prop({ reflect: true }) hasError: boolean = false;\n\n /**\n * The language of the input.\n */\n @Prop() language: LANGUAGE_CODE = LANGUAGE_CODE.en;\n\n /**\n * The theme configuration.\n */\n @Prop({ attribute: 'theme-config' }) readonly themeConfig?: ThemeConfig;\n\n /**\n * The error message to display if the time is invalid.\n */\n @State() err: string = '';\n /**\n * Toggle to show the list of times.\n */\n @State() showTimes: boolean = false;\n /**\n * The aria-activedescendant attribute for the listbox element to indicate the currently active\n * option in the list box to screen readers. The value of aria-activedescendant is the ID of\n * the active option.\n */\n @State() ariaActivedescendant: string = '';\n /**\n * The list of times to display in the dropdown.\n */\n @State() times: Time[] = this.generateTimes();\n /**\n * This is used to scroll to the selected time when the time is changed.\n */\n @State() shouldAutoScroll: boolean = false;\n\n /**\n * This event is fired when the time is changed.\n */\n @Event() timeChange!: EventEmitter<{\n key: string;\n value: string;\n }>;\n\n /**\n * This event is fired when the form has an error. The parent component\n * can listen for this event and display an error message or set form validity.\n */\n @Event() timeWindowFormError!: EventEmitter<{\n key: string;\n message: string;\n }>;\n\n // Event listeners\n @Listen('click', { target: 'document', capture: true })\n handleOutsideClick(event: MouseEvent) {\n // Get the path of the event\n const path = event.composedPath();\n\n // Check if the path includes the host element\n const isClickInside = path.includes(this.el);\n\n if (!isClickInside && this.showTimes) {\n this.showTimes = false;\n }\n }\n\n @Watch('time')\n timeChangedHandler() {\n this.validateTimeAgainstMinimum();\n }\n\n @Watch('minimumStartTime')\n minimumStartTimeChangedHandler() {\n this.validateTimeAgainstMinimum();\n }\n\n @Watch('themeConfig')\n themeConfigChangedHandler(newVal: ThemeConfig, _oldVal: ThemeConfig) {\n this.applyThemeConfig(newVal);\n }\n\n applyThemeConfig(themeConfig?: ThemeConfig) {\n if (themeConfig) {\n for (const [key, value] of Object.entries(themeConfig)) {\n this.el.style.setProperty(`${key}`, value);\n }\n }\n }\n\n private validateTimeAgainstMinimum() {\n if (this.minimumStartTime) {\n // Parse the minimum start time properly using dayjs\n const minimumTime = dayjs(this.minimumStartTime, 'hh:mma');\n const selectedTime = dayjs(this.time, 'hh:mma');\n\n this.times = this.generateTimes();\n const errorMessage = i18next.t('nylasTimeWindowPicker.errors.invalid');\n\n // Check if selected time is before minimum time\n if (selectedTime.isBefore(minimumTime)) {\n this.err = errorMessage;\n this.timeWindowFormError.emit({\n key: this.el.id,\n message: errorMessage,\n });\n } else {\n // Clear the error if the time is valid\n this.err = '';\n this.timeWindowFormError.emit({\n key: this.el.id,\n message: '',\n });\n }\n } else {\n // Clear any existing error if no minimum start time is set\n this.err = '';\n this.timeWindowFormError.emit({\n key: this.el.id,\n message: '',\n });\n }\n }\n\n connectedCallback() {\n // Use queueMicrotask to defer theme application until after React has set props.\n // This fixes the timing issue where connectedCallback fires before React sets themeConfig.\n queueMicrotask(() => {\n if (this.themeConfig) {\n this.applyThemeConfig(this.themeConfig);\n this.el.setAttribute('data-themed', '');\n }\n });\n }\n\n componentWillLoad() {\n // Theme already applied in connectedCallback via queueMicrotask\n }\n\n componentDidLoad() {\n // Validate time against minimum on initial load\n this.validateTimeAgainstMinimum();\n }\n\n componentDidRender() {\n if (this.showTimes && this.shouldAutoScroll) {\n const autocompletedTime = autocompleteTimeFormat(this.time);\n const optionIndex = this.times.findIndex(time => time.value === autocompletedTime);\n if (optionIndex > -1) {\n this.shouldAutoScroll = false;\n this.scrollToViewWithinParent(optionIndex);\n }\n return;\n }\n }\n\n private handleTimeChange(_e: Event, input: string) {\n const timePart = input.split(':');\n if (timePart[0] === '00' && timePart[1].slice(-2) == 'pm') {\n const errorMessage = i18next.t('nylasTimeWindowPicker.errors.invalid');\n this.err = errorMessage;\n this.timeWindowFormError.emit({\n key: this.el.id,\n message: errorMessage,\n });\n }\n if (!validateTimeFormatInput(input)) {\n const errorMessage = i18next.t('nylasTimeWindowPicker.errors.invalid');\n this.err = errorMessage;\n this.timeWindowFormError.emit({\n key: this.el.id,\n message: errorMessage,\n });\n } else {\n this.err = '';\n this.timeWindowFormError.emit({\n key: this.el.id,\n message: '',\n });\n }\n if (this.err) {\n return;\n }\n this.timeChange.emit({\n key: this.el.id,\n value: input,\n });\n }\n\n private handleTimeAutocomplete(event: Event) {\n const targetInput = (event.target as HTMLInputElement)?.value;\n const input = this.language !== LANGUAGE_CODE.en ? convertTo12HourFormat(targetInput) : targetInput;\n const errorMessage = i18next.t('nylasTimeWindowPicker.errors.invalid');\n if (!validateTimeFormatInput(input)) {\n this.err = errorMessage;\n this.timeWindowFormError.emit({\n key: this.el.id,\n message: errorMessage,\n });\n return;\n }\n if (input === '') {\n const newTime = roundToNearest15Minutes().format('hh:mma');\n this.timeChange.emit({\n key: this.el.id,\n value: newTime,\n });\n return;\n }\n if (!validateExactTimeFormat(input)) {\n const autocompletedTime = autocompleteTimeFormat(input);\n this.timeChange.emit({\n key: this.el.id,\n value: autocompletedTime,\n });\n return;\n }\n this.timeChange.emit({\n key: this.el.id,\n value: input,\n });\n }\n\n private handleOnInput(event: Event) {\n const input = (event.target as HTMLInputElement)?.value;\n if (!validateTimeFormatInput(input)) {\n return;\n }\n if (input === '') {\n const newTime = roundToNearest15Minutes().format('hh:mma');\n const optionIndex = this.times.findIndex(time => time.value === newTime);\n if (optionIndex > -1) {\n this.scrollToViewWithinParent(optionIndex);\n }\n return;\n }\n if (!validateExactTimeFormat(input)) {\n const autocompletedTime = autocompleteTimeFormat(input);\n const optionIndex = this.times.findIndex(time => time.value === autocompletedTime);\n if (optionIndex > -1) {\n this.scrollToViewWithinParent(optionIndex);\n }\n return;\n }\n }\n\n private generateTimes() {\n const times: Time[] = [];\n let startTime = dayjs().set('hour', 0).set('minute', 0).set('second', 0); // Set to 12:00 am\n if (this.minimumStartTime) {\n startTime = dayjs(this.minimumStartTime, 'hh:mma');\n }\n const diff = startTime.endOf('day').diff(startTime, 'minutes');\n const iterations = Math.round(diff / 15);\n for (let i = 0; i < iterations + 1; i++) {\n // 96 represents the total number of 15-minute increments in a day (24 hours * 60 minutes / 15 minutes)\n const time = startTime.add(i * 15, 'minute');\n if (i == iterations && time.format('hh:mma').includes('am')) {\n break;\n }\n times.push({ id: i, value: time.format('hh:mma') });\n }\n return times;\n }\n\n private handleComboboxKeyDown(event: KeyboardEvent): void {\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n if (!this.showTimes) {\n this.showTimes = true;\n this.shouldAutoScroll = true;\n return;\n }\n if (this.ariaActivedescendant === '') {\n this.ariaActivedescendant = this.times[0].id.toString();\n this.focusOption(0);\n } else {\n const currentIndex = this.times.findIndex(time => time.id.toString() === this.ariaActivedescendant);\n const nextIndex = currentIndex + 1 < this.times.length ? currentIndex + 1 : 0;\n this.ariaActivedescendant = this.times[nextIndex].id.toString();\n this.focusOption(nextIndex);\n }\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n if (this.ariaActivedescendant === '') {\n this.ariaActivedescendant = this.times[this.times.length - 1].id.toString();\n this.focusOption(this.times.length - 1);\n } else {\n const currentIndex = this.times.findIndex(time => time.id.toString() === this.ariaActivedescendant);\n const prevIndex = currentIndex - 1 >= 0 ? currentIndex - 1 : this.times.length - 1;\n this.ariaActivedescendant = this.times[prevIndex].id.toString();\n this.focusOption(prevIndex);\n }\n } else if (event.key === 'Escape') {\n this.showTimes = false;\n this.timeInput.focus();\n }\n }\n\n private handleListboxKeydown(e: KeyboardEvent) {\n const items = this.times;\n const currentIndex = items.findIndex(item => item.id.toString() === this.ariaActivedescendant);\n\n if (e.key === 'ArrowDown' || (e.key === 'Tab' && !e.shiftKey)) {\n e.preventDefault();\n const nextIndex = currentIndex + 1 < items.length ? currentIndex + 1 : 0;\n this.ariaActivedescendant = items[nextIndex].id.toString();\n this.focusOption(nextIndex);\n } else if (e.key === 'ArrowUp' || (e.key === 'Tab' && e.shiftKey)) {\n e.preventDefault();\n const prevIndex = currentIndex - 1 >= 0 ? currentIndex - 1 : items.length - 1;\n this.ariaActivedescendant = items[prevIndex].id.toString();\n this.focusOption(prevIndex);\n } else if (e.key === 'Enter') {\n e.preventDefault();\n if (this.ariaActivedescendant) {\n const option = items[currentIndex];\n this.handleTimeChange(e, option.value);\n this.showTimes = false;\n this.ariaActivedescendant = '';\n this.timeInput.focus();\n }\n } else if (e.key === 'Escape') {\n this.showTimes = false;\n this.timeInput.focus();\n }\n }\n\n scrollToViewWithinParent(optionIndex: number) {\n const option = this.times[optionIndex];\n const childElement = this.el.shadowRoot?.getElementById(option.id.toString()) as HTMLLIElement;\n const parentElement = this.timeMenu;\n\n this.ariaActivedescendant = option.id.toString();\n\n // Scroll child into view within parent\n const childRect = childElement.getBoundingClientRect();\n const parentRect = parentElement.getBoundingClientRect();\n\n if (childRect.top < parentRect.top) {\n // Child is above the visible area of the parent\n parentElement.scrollTop -= parentRect.top - childRect.top;\n } else if (childRect.bottom > parentRect.bottom) {\n // Child is below the visible area of the parent\n parentElement.scrollTop += childRect.bottom - parentRect.bottom;\n }\n\n if (childRect.left < parentRect.left) {\n // Child is to the left of the visible area of the parent\n parentElement.scrollLeft -= parentRect.left - childRect.left;\n } else if (childRect.right > parentRect.right) {\n // Child is to the right of the visible area of the parent\n parentElement.scrollLeft += childRect.right - parentRect.right;\n }\n }\n\n focusOption(index: number) {\n const option = this.times[index];\n if (!option) return; // Guard clause in case index is out of bounds\n\n const elementId = option.id.toString();\n const element = this.el.shadowRoot?.getElementById(elementId) as HTMLLIElement;\n\n if (element) {\n element.focus(); // Set focus on the element\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n }\n }\n\n render() {\n const is24HourFormat = this.language === LANGUAGE_CODE.en ? false : true;\n return (\n <Host>\n <div class=\"time-picker\" part=\"time-picker\">\n <input\n type=\"text\"\n name={this.name}\n id={this.name}\n part=\"time-input\"\n class={{\n 'time-input': true,\n 'error': !!this.err || this.hasError,\n }}\n ref={el => (this.timeInput = el as HTMLInputElement)}\n value={is24HourFormat ? convertTo24HourFormat(this.time) : this.time}\n onClick={() => {\n this.showTimes = !this.showTimes;\n this.shouldAutoScroll = true;\n }}\n aria-haspopup=\"listbox\"\n aria-label={this.name}\n aria-expanded={this.showTimes ? 'true' : 'false'}\n placeholder={this.placeholder}\n onKeyDown={e => this.handleComboboxKeyDown(e)}\n onInput={event => this.handleOnInput(event)}\n onBlur={event => this.handleTimeAutocomplete(event)}\n />\n {this.err && <div class=\"invalid-time-icon\">{/* Icon here */}</div>}\n {this.showTimes && (\n <div class=\"times\" part=\"times\" ref={el => (this.timeMenu = el as HTMLElement)}>\n <ul tabindex=\"-1\" role=\"listbox\" aria-label={this.name} aria-activedescendant={this.ariaActivedescendant} onKeyDown={e => this.handleListboxKeydown(e)}>\n {this.times.map(option => (\n <li\n tabindex=\"0\"\n key={option.id}\n id={option.id.toString()}\n class={{\n focused: this.ariaActivedescendant === option.id.toString(),\n }}\n onClick={e => {\n this.handleTimeChange(e, option.value);\n this.showTimes = false;\n this.timeInput.focus();\n }}\n role=\"option\"\n >\n {`${is24HourFormat ? convertTo24HourFormat(option.value) : option.value}`}\n </li>\n ))}\n </ul>\n </div>\n )}\n {!this.showTimes && this.err && (\n <p class=\"error\" id=\"email-error\">\n {this.err}\n </p>\n )}\n </div>\n </Host>\n );\n }\n}\n"],"mappings":"oOAAA,MAAMA,EAAU,iC,MCOHC,EAAS,MALtB,WAAAC,CAAAC,G,UAMUC,KAAKC,MAAW,KAChBD,KAAME,OAAW,IAY1B,CAVC,MAAAC,GACE,OACEC,EAAK,OAAAC,IAAA,2CAAAC,MAAM,6BAA6BL,MAAOD,KAAKC,MAAOC,OAAQF,KAAKE,OAAQK,QAAQ,YAAYC,KAAK,QACvGJ,E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KAAKgB,YAClBqK,UAAWjI,GAAKpD,KAAK8I,sBAAsB1F,GAC3CqB,QAASzB,GAAShD,KAAKmI,cAAcnF,GACrC2B,OAAQ3B,GAAShD,KAAK4H,uBAAuB5E,KAE9ChD,KAAKqF,KAAOjF,EAAA,OAAAC,IAAA,2CAAKgE,MAAM,sBACvBrE,KAAKsF,WACJlF,EAAA,OAAAC,IAAA,2CAAKgE,MAAM,QAAQD,KAAK,QAAQ8G,IAAK3I,GAAOvC,KAAKgK,SAAWzH,GAC1DnC,EAAA,MAAAC,IAAA,2CAAIiL,SAAS,KAAKC,KAAK,UAAS,aAAavL,KAAKc,KAAI,wBAAyBd,KAAKuF,qBAAsB8F,UAAWjI,GAAKpD,KAAKuJ,qBAAqBnG,IACjJpD,KAAKwF,MAAMgG,KAAI7B,GACdvJ,EACE,MAAAkL,SAAS,IACTjL,IAAKsJ,EAAOhD,GACZA,GAAIgD,EAAOhD,GAAGoC,WACd1E,MAAO,CACLoH,QAASzL,KAAKuF,uBAAyBoE,EAAOhD,GAAGoC,YAEnDqC,QAAShI,IACPpD,KAAKoH,iBAAiBhE,EAAGuG,EAAO9H,OAChC7B,KAAKsF,UAAY,MACjBtF,KAAKqJ,UAAUC,OAAO,EAExBiC,KAAK,UAEJ,GAAGP,EAAiBG,EAAsBxB,EAAO9H,OAAS8H,EAAO9H,cAM1E7B,KAAKsF,WAAatF,KAAKqF,KACvBjF,EAAG,KAAAC,IAAA,2CAAAgE,MAAM,QAAQsC,GAAG,eACjB3G,KAAKqF,M","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as e,F as t,r as n,c as i,H as s,a as r}from"./p-0EQQA0nE.js";import{N as o}from"./p-BS9pAWHt.js";import{N as a}from"./p-Cb2blKKQ.js";import{d as c,u as l,t as u,a as d,b as h,g as f,e as p,i as g}from"./p-D7AODx4L.js";import{o as y,v as w}from"./p-BxqBxG4o.js";import{c as b}from"./p-_i6H-yQH.js";import{C as m,L as v,a as _}from"./p-COJy29df.js";c.extend(l);c.extend(u);class E{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.groupEventsCache=new Map;this.CACHE_DURATION=1*60*1e3;this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}async currentUser(){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return null}return this.nylasApiRequest.currentUser()}async getCalendars(){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching calendars: Nylas API Request is not initialized"})}const e=[];let t=null;const n=50;do{const[i,s]=await this.nylasApiRequest.request({method:"GET",path:`calendars?limit=${n}${t?`&page_token=${t}`:""}`});if(s){return h(null,{message:"Error fetching calendars: "+s.message})}if(y(i)){return h(null,{message:"Error fetching calendars: "+i.error?.message})}e.push(...i.data);t=i.next_cursor||null}while(t);this.nylasSchedulerConfigStore.state.calendars=e;return h(e)}async getConfigurationById(e,t=false){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching configuration: Nylas API Request is not initialized"})}if(!t){const t=this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e));if(t){this.nylasSchedulerConfigStore.state.selectedConfiguration=t;return h(t)}}const[n,i]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}`});if(i){return h(null,{message:"Error fetching configuration: "+i.message})}if(y(n)){return h(null,{message:"Error fetching configuration: "+n.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=n.data;if(this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e))){this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map((t=>t.id===e?n.data:t))}else{this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,n.data]}return h(n.data)}async getConfigurations(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching configurations: Nylas API Request is not initialized"})}const t=50;const[n,i]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations?limit=${t}${e?`&page_token=${e}`:""}`});if(i){return h(null,{message:"Error fetching configurations: "+i.message})}if(y(n)){return h(null,{message:"Error fetching configurations: "+n.error?.message})}this.nylasSchedulerConfigStore.state.configurations=n.data;this.nylasSchedulerConfigStore.state.listConfigurationsNextCursor=n.next_cursor||null;return h(n.data)}async getMasterEventById(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching master event: Nylas API Request is not initialized"})}const t=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const n=t?.event?.calendar_id;if(!n){d("Calendar ID is not present");return h(null,{message:"Error fetching master event: Calendar ID is not present"})}const i=new URLSearchParams;i.append("calendar_id",n);const[s,r]=await this.nylasApiRequest.request({method:"GET",path:`events/${e}?${i.toString()}`});if(r){return h(null,{message:"Error fetching master event: "+r.message})}if(y(s)){return h(null,{message:"Error fetching master event: "+s.error?.message})}const o=this.nylasSchedulerConfigStore.state.masterGroupEvents;if(o[e]){this.nylasSchedulerConfigStore.state.masterGroupEvents[e]=s.data}else{this.nylasSchedulerConfigStore.state.masterGroupEvents={...o,[e]:s.data}}return h(s.data)}async createConfiguration(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error creating configuration: Nylas API Request is not initialized"})}const[t,n]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations`,body:e});if(n){return h(null,{message:"Error creating configuration: "+n.message})}if(y(t)){return h(null,{message:"Error creating configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=t.data;this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,t.data];return h(t.data)}async updateConfiguration(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error updating configuration: Nylas API Request is not initialized"})}const[t,n]=await this.nylasApiRequest.request({method:"PUT",path:`scheduling/configurations/${e.id}`,body:e});if(n){return h(null,{message:"Error updating configuration: "+n.message})}if(y(t)){return h(null,{message:"Error updating configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=t.data;if(this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e.id))){this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map((n=>n.id===e.id?t.data:n))}else{this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,t.data]}return h(t.data)}async deleteConfiguration(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error deleting configuration: Nylas API Request is not initialized"})}const[t,n]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${e}`});if(n){return h(null,{message:"Error deleting configuration: "+n.message})}if(y(t)){return h(null,{message:"Error deleting configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.filter((t=>t.id!==e));if(this.nylasSchedulerConfigStore.state.selectedConfiguration?.id===e){this.nylasSchedulerConfigStore.resetSelectedConfiguration()}return h(t.data)}async createGroupEvent(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error creating group event: Nylas API Request is not initialized"})}const[n,i]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/group-events`,body:e});if(i){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error creating group event: "+i.message})}if(y(n)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error creating group event: "+n.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=n.data;await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(n.data)}async getGroupEvents(e,t){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching group events: Nylas API Request is not initialized"})}const n=new URLSearchParams;n.append("show_all","true");const i=this.nylasSchedulerConfigStore.state.calendarViewDateRange;let s;let r;if(i){s=i.start_time;r=i.end_time}else{const e=f((new Date).toISOString(),"week");s=e.startTime.toString();r=e.endTime.toString()}const o=`${e}-${s}-${r}`;const a=this.groupEventsCache.get(o);if(a&&Date.now()-a.timestamp<this.CACHE_DURATION){this.nylasSchedulerConfigStore.state.groupEvents=a.data;return h(a.data)}n.append("start_time",s);n.append("end_time",r);const c=t?.group_booking?.calendar_id;if(c){n.append("calendar_id",c)}const[l,u]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}/group-events?${n.toString()}`});if(u){return h(null,{message:"Error fetching group events: "+u.message})}if(y(l)){return h(null,{message:"Error fetching group events: "+l.error?.message})}this.groupEventsCache.set(o,{data:l.data,timestamp:Date.now()});this.cleanupExpiredCache();this.nylasSchedulerConfigStore.state.groupEvents=l.data;return h(l.data)}cleanupExpiredCache(){const e=Date.now();for(const[t,n]of this.groupEventsCache.entries()){if(e-n.timestamp>this.CACHE_DURATION){this.groupEventsCache.delete(t)}}}async updateGroupEventById(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error updating group event: Nylas API Request is not initialized"})}const n=e.id;delete e.id;const[i,s]=await this.nylasApiRequest.request({method:"PATCH",path:`scheduling/configurations/${t}/group-events/${n}`,body:e});if(s){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error updating group event: "+s.message})}if(y(i)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error updating group event: "+i.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=i.data;await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(i.data)}async updateGroupEvent(e,t,n){this.nylasSchedulerConfigStore.state.isLoading=true;const i=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const s=i?.event?.master_event_id;const r=i?.event?.id;const o=i?.event?.when?.start_time;const a=i?.group_event_info?.rrule?.[0];const l=a?a.split(";").filter((e=>!e.startsWith("UNTIL"))).join(";"):"";const u=o?c(o*1e3).subtract(1,"minute").format("YYYYMMDDTHHmmss[Z]"):"";if(t==="this"){return this.updateGroupEventById({...e,id:r,recurrence:s?undefined:e.recurrence},n)}else if(t==="future"&&s){const t=await this.createGroupEvent(e,n);const r={location:i?.event?.location,conferencing:i?.event?.conferencing,title:i?.event?.title,description:i?.event?.description,capacity:i?.group_event_info?.capacity,calendar_id:i?.event?.calendar_id,recurrence:l?[l+";UNTIL="+u]:[`RRULE:FREQ=DAILY;UNTIL=${u}`]};await this.updateGroupEventById({...r,id:s},n);return[r,t]}else if(t==="all"){const t=e?.when;const r=i?.event?.when;const o=this.nylasSchedulerConfigStore.state.masterGroupEvents?.[s];let a=o?.when;if(t?.start_time!==r?.start_time){a={...a,start_time:t?.start_time||a?.start_time}}if(t?.end_time!==r?.end_time){a={...a,end_time:t?.end_time||a?.end_time}}if(t?.start_timezone!==r?.start_timezone){a={...a,start_timezone:t?.start_timezone||a?.start_timezone}}if(t?.end_timezone!==r?.end_timezone){a={...a,end_timezone:t?.end_timezone||a?.end_timezone}}return this.updateGroupEventById({...e,when:a,id:s},n)}this.nylasSchedulerConfigStore.state.isLoading=false;throw new Error("Invalid option")}async deleteGroupEvent(e,t,n){this.nylasSchedulerConfigStore.state.isLoading=true;const i=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const s=i?.event?.master_event_id;const r=i?.event?.id;const o=i?.event?.when?.start_time;const a=i?.group_event_info?.rrule?.[0];const l=a?a.split(";").filter((e=>!e.startsWith("UNTIL"))).join(";"):"";const u=o?c(o*1e3).format("YYYYMMDDTHHmmss[Z]"):"";const d={location:i?.event?.location,conferencing:i?.event?.conferencing,title:i?.event?.title,description:i?.event?.description,capacity:i?.group_event_info?.capacity,calendar_id:i?.event?.calendar_id,recurrence:l?[l+";UNTIL="+u]:[`RRULE:UNTIL=${u}`]};if(t==="this"&&r){return this.deleteGroupEventById(r,n)}else if(t==="future"&&s&&r){await this.deleteGroupEventById(r,n);return await this.updateGroupEventById({...d,id:s},n)}else if(t==="all"&&s){return this.deleteGroupEventById(s,n)}this.nylasSchedulerConfigStore.state.isLoading=false;throw new Error("Invalid option")}async deleteGroupEventById(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error deleting group event: Nylas API Request is not initialized"})}const n=new URLSearchParams;const i=this.nylasSchedulerConfigStore.state.selectedConfiguration?.group_booking?.calendar_id;if(i){n.append("calendar_id",i)}const[s,r]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${t}/group-events/${e}?calendar_id=${i}`});if(r){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error deleting group event: "+r.message})}if(y(s)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error deleting group event: "+s.error?.message})}await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(s.data)}async importGroupEvent(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error importing group event: Nylas API Request is not initialized"})}const n=new URLSearchParams;const i=this.nylasSchedulerConfigStore.state.selectedConfiguration?.group_booking?.calendar_id;if(i){n.append("calendar_id",i)}const[s,r]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/import-group-events?${n.toString()}`,body:e});if(r){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error importing group event: "+r.message})}if(y(s)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error importing group event: "+s.error?.message})}if(s.data?.imported_events?.length>0){await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration)}this.nylasSchedulerConfigStore.state.isLoading=false;return h(s.data)}}class k{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}init(){d("NylasSchedulerConfigConnector init")}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get schedulerConfig(){if(this._schedulerConfigConnector){return this._schedulerConfigConnector}this._schedulerConfigConnector=new E({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore});return this._schedulerConfigConnector}resetStores(){d("NylasSchedulerConfigConnector resetStores");this.nylasSchedulerConfigStore.reset()}async logout(){d("NylasSchedulerConfigConnector logout");this.resetStores()}}function x(e={}){const t={selectedConfiguration:{},configurations:[],groupEvents:[],listConfigurationsNextCursor:null,calendars:[],currentUser:null,action:null,additionalParticipants:[],requiresSlug:false,masterGroupEvents:{},isLoading:false,...e};const n=b(t);function i(){n.set("selectedConfiguration",{...e["selectedConfiguration"]})}n.onChange("action",(async e=>{if(!e){i()}}));return{...n,resetSelectedConfiguration:i}}class C{get(e){return new Promise((t=>{const n=globalThis.window?.localStorage.getItem(e);if(!n){t(null)}else{t(JSON.parse(n))}}))}async remove(e){globalThis.window?.localStorage.removeItem(e);return new Promise((e=>{e(null)}))}set(e,t){globalThis.window?.localStorage.setItem(e,JSON.stringify(t));return new Promise((e=>{e(null)}))}}const $="pkce";const S="grant";const T="user";const P=e=>{if(typeof globalThis.btoa==="function"&&typeof TextEncoder!=="undefined"){const t=(new TextEncoder).encode(e);let n="";for(let e=0;e<t.length;e++){n+=String.fromCharCode(t[e])}return globalThis.btoa(n)}if(typeof globalThis.Buffer!=="undefined"){return globalThis.Buffer.from(e,"utf8").toString("base64")}throw new Error("Base64 encoding is not supported in this environment")};const R=e=>{if(typeof globalThis.atob==="function"&&typeof TextDecoder!=="undefined"){const t=globalThis.atob(e);const n=new Uint8Array(t.length);for(let e=0;e<t.length;e++){n[e]=t.charCodeAt(e)}return(new TextDecoder).decode(n)}if(typeof globalThis.Buffer!=="undefined"){return globalThis.Buffer.from(e,"base64").toString("utf8")}throw new Error("Base64 decoding is not supported in this environment")};class I{Storage=new C;constructor(e){if(e){this.Storage=e;return}}setPKCE(e){const t=P(e);this.Storage.set($,t)}async getPKCE(){try{const e=await this.Storage.get($);if(e){return R(e)}}catch(e){return null}return null}removePKCE(){this.Storage.remove($)}setGrant(e,t=false){const{grant_id:n}=e;this.Storage.set(`${S}${t?"-"+n:""}`,e)}removeGrant(e,t=false){this.Storage.remove(`${S}${t?"-"+e:""}`)}async getGrant(e,t=false){const n=await this.Storage.get(`${S}${t?"-"+e:""}`);if(n){return n}return null}async setUserToken(e){const t=await this.getUserTokens();if(t){const n=t.find((t=>t.sub===e.sub));if(!n){const n=[...t,e];this.Storage.set(T,n)}else{const n=t.map((t=>{if(t.sub===e.sub){t=e}return t}));this.Storage.set(T,n)}}else{this.Storage.set(T,[e])}}async getUserToken(e=""){const t=await this.Storage.get(T);if(t){if(e===""){return t[0]}const n=t.find((t=>t.sub===e));return n}return null}async getUserTokens(){const e=await this.Storage.get(T);if(e){return e}return null}removeUserTokens(){this.Storage.remove(T)}async removeUserToken(e){const t=await this.getUserTokens();const n=t?.filter((t=>t.sub!==e));this.Storage.set(T,n)}async clearSession(){const e=await this.getUserTokens();e?.forEach((e=>{this.removeGrant(e.sub)}));this.removePKCE();this.removeUserTokens()}}class q{databaseName="identity-db";storeName="identity";get(e){const t=this;return new Promise(((n,i)=>{t.openDatabase().then((function(s){const r=s.transaction(t.storeName,"readwrite");const o=r.objectStore(t.storeName);const a=o.get(e);a.onsuccess=()=>{n(a.result)};a.onerror=()=>{i(a.error)};r.oncomplete=()=>{s.close()}}))}))}async remove(e){const t=this;return new Promise(((n,i)=>{const s=indexedDB.open(this.databaseName);s.onupgradeneeded=function(e){const n=e.target.result;n.createObjectStore(t.storeName)};s.onerror=()=>{i(s.error)};s.onsuccess=t=>{const s=t.target.result;const r=s.transaction(this.storeName,"readwrite");const o=r.objectStore(this.storeName);const a=o.delete(e);a.onsuccess=()=>{n(null)};a.onerror=()=>{i(a.error)};r.oncomplete=()=>{s.close()}}}))}set(e,t){return new Promise(((n,i)=>{const s=indexedDB.open(this.databaseName);s.onerror=()=>{i(s.error)};s.onupgradeneeded=e=>{const t=e.target.result;t.createObjectStore(this.storeName)};s.onsuccess=s=>{const r=s.target.result;const o=r.transaction(this.storeName,"readwrite");const a=o.objectStore(this.storeName);const c=a.put(t,e);c.onsuccess=()=>{n(t)};c.onerror=()=>{i(c.error)};o.oncomplete=()=>{r.close()}}}))}openDatabase(){const e=this;return new Promise((function(t,n){const i=indexedDB.open(e.databaseName,2);i.onupgradeneeded=function(t){const n=t.target.result;n.createObjectStore(e.storeName)};i.onsuccess=function(e){t(e.target.result)};i.onerror=function(e){n(e.error)}}))}}var A;var N=new Uint8Array(16);function U(){if(!A){A=typeof crypto!=="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!=="undefined"&&typeof msCrypto.getRandomValues==="function"&&msCrypto.getRandomValues.bind(msCrypto);if(!A){throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported")}}return A(N)}var L=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function j(e){return typeof e==="string"&&L.test(e)}var z=[];for(var O=0;O<256;++O){z.push((O+256).toString(16).substr(1))}function D(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var n=(z[e[t+0]]+z[e[t+1]]+z[e[t+2]]+z[e[t+3]]+"-"+z[e[t+4]]+z[e[t+5]]+"-"+z[e[t+6]]+z[e[t+7]]+"-"+z[e[t+8]]+z[e[t+9]]+"-"+z[e[t+10]]+z[e[t+11]]+z[e[t+12]]+z[e[t+13]]+z[e[t+14]]+z[e[t+15]]).toLowerCase();if(!j(n)){throw TypeError("Stringified UUID is invalid")}return n}function G(e,t,n){e=e||{};var i=e.random||(e.rng||U)();i[6]=i[6]&15|64;i[8]=i[8]&63|128;return D(i)}async function B(e,t){const n=e.getReader();let i;while(!(i=await n.read()).done){t(i.value)}}function H(e){let t;let n;let i;let s=false;return function r(o){if(t===undefined){t=o;n=0;i=-1}else{t=M(t,o)}const a=t.length;let c=0;while(n<a){if(s){if(t[n]===10){c=++n}s=false}let r=-1;for(;n<a&&r===-1;++n){switch(t[n]){case 58:if(i===-1){i=n-c}break;case 13:s=true;case 10:r=n;break}}if(r===-1){break}e(t.subarray(c,r),i);c=n;i=-1}if(c===a){t=undefined}else if(c!==0){t=t.subarray(c);n-=c}}}function F(e,t,n){let i=J();const s=new TextDecoder;return function r(o,a){if(o.length===0){n===null||n===void 0?void 0:n(i);i=J()}else if(a>0){const n=s.decode(o.subarray(0,a));const r=a+(o[a+1]===32?2:1);const c=s.decode(o.subarray(r));switch(n){case"data":i.data=i.data?i.data+"\n"+c:c;break;case"event":i.event=c;break;case"id":e(i.id=c);break;case"retry":const n=parseInt(c,10);if(!isNaN(n)){t(i.retry=n)}break}}}}function M(e,t){const n=new Uint8Array(e.length+t.length);n.set(e);n.set(t,e.length);return n}function J(){return{data:"",event:"",id:"",retry:undefined}}var Y=undefined&&undefined.__rest||function(e,t){var n={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0)n[i]=e[i];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var s=0,i=Object.getOwnPropertySymbols(e);s<i.length;s++){if(t.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(e,i[s]))n[i[s]]=e[i[s]]}return n};const K="text/event-stream";const W=1e3;const Q="last-event-id";function V(e,t){var{signal:n,headers:i,onopen:s,onmessage:r,onclose:o,onerror:a,openWhenHidden:c,fetch:l}=t,u=Y(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise(((t,d)=>{const h=Object.assign({},i);if(!h.accept){h.accept=K}let f;function p(){f.abort();if(!document.hidden){v()}}if(!c){document.addEventListener("visibilitychange",p)}let g=W;let y=0;function w(){document.removeEventListener("visibilitychange",p);window.clearTimeout(y);f.abort()}n===null||n===void 0?void 0:n.addEventListener("abort",(()=>{w();t()}));const b=l!==null&&l!==void 0?l:window.fetch;const m=s!==null&&s!==void 0?s:Z;async function v(){var n;f=new AbortController;try{const n=await b(e,Object.assign(Object.assign({},u),{headers:h,signal:f.signal}));await m(n);await B(n.body,H(F((e=>{if(e){h[Q]=e}else{delete h[Q]}}),(e=>{g=e}),r)));o===null||o===void 0?void 0:o();w();t()}catch(e){if(!f.signal.aborted){try{const t=(n=a===null||a===void 0?void 0:a(e))!==null&&n!==void 0?n:g;window.clearTimeout(y);y=window.setTimeout(v,t)}catch(e){w();d(e)}}}}v()}))}function Z(e){const t=e.headers.get("content-type");if(!(t===null||t===void 0?void 0:t.startsWith(K))){throw new Error(`Expected content-type to be ${K}, Actual: ${t}`)}}function X(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function ee(){return Math.floor(Date.now()/1e3)}async function te(e){const t=(new TextEncoder).encode(e);const n=await crypto.subtle.digest("SHA-256",t);const i=Array.from(new Uint8Array(n));const s=i.map((e=>e.toString(16).padStart(2,"0"))).join("");return s}function ne(e){this.message=e}ne.prototype=new Error,ne.prototype.name="InvalidCharacterError";var ie="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new ne("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,s=0,r=0,o="";i=t.charAt(r++);~i&&(n=s%4?64*n+i:i,s++%4)?o+=String.fromCharCode(255&n>>(-2*s&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return o};function se(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(ie(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return ie(t)}}function re(e){this.message=e}function oe(e,t){if("string"!=typeof e)throw new re("Invalid token specified");var n=true===(t=t||{}).header?0:1;try{return JSON.parse(se(e.split(".")[n]))}catch(e){throw new re("Invalid token specified: "+e.message)}}re.prototype=new Error,re.prototype.name="InvalidTokenError";class ae{clientId;redirectUri;accessType="online";domain="http://api.nylas.com";versioned=false;Storage;hosted=false;multiAccount=false;loginId="";constructor(e){this.clientId=e.clientId;this.redirectUri=e.redirectUri;if(e.domain){this.domain=e.domain;const t=this.domain.substring(this.domain.length-3);if(t.includes("/v")){this.versioned=true}}if(e.multiAccount){this.multiAccount=e.multiAccount}if(e.sw){const e=new q;this.Storage=new I(e)}else{this.Storage=new I}if(e.accessType){this.accessType=e.accessType}if(e.loginId){this.loginId=e.loginId}if(e.hosted){this.hosted=e.hosted}if(e.disableInitCodeExchange!==true){this.codeExchange(null)}}async validateAccessToken(e=""){const t=await this.Storage.getGrant(e,this.multiAccount);if(!t){return false}const{access_token:n}=t;try{const e=await fetch(`${this.domain}/connect/tokeninfo?access_token=${n}`,{method:"GET"});const t=await e.json();if(!t.data){return false}return true}catch(e){return false}}async validateIDToken(e=""){const t=await this.Storage.getGrant(e,this.multiAccount);if(!t){return false}const{id_token:n}=t;try{const e=await fetch(`${this.domain}/connect/tokeninfo?id_token=${n}`,{method:"GET"});if(e.status!==200){return false}const t=await e.json();if(!t.data){return false}return true}catch(e){return false}}getDomain(){return this.domain}async auth(e){if(this.hosted&&(this.domain===globalThis.window?.location.origin||this.versioned&&this.domain.includes(globalThis.window?.location.origin))){await this.hostedSetCodeChallenge()}const t=await this.generateAuthURL(e);if(e.popup){this.popUp(t);return}return t}async generateAuthURL(e){const t=await this.getCodeChallege();let n=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(t){n+=`&code_challenge=${t}&code_challenge_method=S256&options=rotate_refresh_token`}if(e.provider){n+=`&provider=${e.provider}`}if(e.loginHint){n+=`&login_hint=${e.loginHint}`;if(e.includeGrantScopes){n+=`&include_grant_scopes=${e.includeGrantScopes}`}}if(e.scope){n+=`&scope=${e.scope.join(" ")}`}if(e.prompt){n+=`&prompt=${e.prompt}`}if(e.metadata){n+=`&metadata=${e.metadata}`}if(e.state||this.loginId){n+=`&state=${this.loginId?this.loginId:e.state}`}return n}async generateReauthURL(e,t){if(!e){throw new Error("Grant ID is required")}const n=await this.Storage.getUserToken(e);const i=await this.getCodeChallege();let s=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(i){s+=`&code_challenge=${i}&code_challenge_method=S256&options=rotate_refresh_token`}if(n?.provider){s+=`&provider=${n.provider}`}if(n?.email){s+=`&login_hint=${n.email}`}if(t){s+=`&scope=${t.join(" ")}`}return s}async generateCodeChallenge(){const e=await this.Storage.getPKCE();if(e){return}const t=G();this.Storage.setPKCE(t);return}async hostedSetCodeChallenge(){if(!this.hosted){throw console.error("Method only used with hosted flag enabled")}const e=new URLSearchParams(globalThis.window?.location.search);const t=e.get("code_challenge");if(!t){const e=await this.Storage.getPKCE();if(e){return}console.warn("Code challenge is recomended");return}this.Storage.setPKCE(t)}async getCodeChallege(){if(this.hosted&&(this.domain===globalThis.window?.location.origin||this.versioned&&this.domain.includes(globalThis.window?.location.origin))){const e=new URLSearchParams(globalThis.window?.location.search);const t=e.get("code_challenge");if(!t){console.warn("Code challenge is recomended");return""}return t}const e=await this.Storage.getPKCE();if(e){const t=await te(e);let n=btoa(unescape(encodeURIComponent(t)));n=X(n);return n}return""}async isLoggedIn(){if(this.hosted&&(this.domain===globalThis.window?.location.origin||this.versioned&&this.domain.includes(globalThis.window?.location.origin))){return false}const e=await this.Storage.getUserTokens();if(e&&e.length>0){if(this.multiAccount){await this.generateCodeChallenge()}return true}await this.generateCodeChallenge();return false}isMultiAccount(){return this.multiAccount}async logout(){const e=await this.getProfile();await this.Storage.clearSession();const t={detail:e};window.dispatchEvent(new CustomEvent("onLogoutSuccess",t))}async getProfile(e=""){let t;if(e){t=await this.Storage.getUserToken(e)}else{t=await this.Storage.getUserToken()}if(t){return t}return null}async getProfiles(){const e=await this.Storage.getUserTokens();if(e){return e}return null}async removeProfile(e){await this.Storage.removeUserToken(e);await this.Storage.removeGrant(e);return null}async authIMAP(e){const t=await this.getCodeChallege();const n={imap_username:e.imap_username,imap_password:e.imap_password,imap_host:e.imap_host,imap_port:e.imap_port,type:e.type,smtp_host:e.smtp_host,smtp_port:e.smtp_port,provider:e.provider,redirect_uri:this.redirectUri,state:e.state,public_application_id:this.clientId,access_type:this.accessType};if(this.loginId){n.id=this.loginId}if(e.smtp_username&&e.smtp_password){n.smtp_username=e.smtp_username;n.smtp_password=e.smtp_password}if(t!=""){n.code_challenge=t;n.code_challenge_method="S256"}const i=await fetch(`${this.domain}/connect/login/imap`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(n)});const s=await i.json();return s}async authEWS(e){const t=await this.getCodeChallege();const n={...e,provider:"ews",redirect_uri:this.redirectUri,public_application_id:this.clientId,access_type:this.accessType};if(this.loginId){n.id=this.loginId}if(t!=""){n.code_challenge=t;n.code_challenge_method="S256"}const i=await fetch(`${this.domain}/connect/login/ews`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(n)});const s=await i.json();return s}async detectEmail(e){const t=await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/providers/detect?client_id=${this.clientId}&email=${e}`,{method:"POST",headers:new Headers({"content-type":"application/json"})});const n=await t.json();return n}async applicationInfo(){const e=await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/applications?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});const t=await e.json();return t.data}async getAvailableProviders(){const e=await fetch(`${this.domain}/connect/providers/find?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});if(e){const t=await e.json();const n=t.data;return n}return null}onLoginSuccess(e){window.addEventListener("onLoginSuccess",(t=>e(t)))}onLogoutSuccess(e){window.addEventListener("onLogoutSuccess",(t=>e(t)))}onLoginFail(e){window.addEventListener("onLoginFail",(t=>e(t)))}onTokenRefreshSuccess(e){window.addEventListener("onTokenRefreshSuccess",(t=>e(t)))}onTokenRefreshFail(e){window.addEventListener("onTokenRefreshFail",(t=>e(t)))}onSessionExpired(e){window.addEventListener("onSessionExpired",(t=>e(t)))}async codeExchange(e){let t=new URLSearchParams(globalThis.window?.location.search);if(e){t=new URLSearchParams(e)}const n=t.get("code");const i=t.get("state");const s=t.get("error");const r=t.get("error_description");const o=t.get("error_code");if(s&&r&&o){const e={detail:{error:s,error_description:r,error_code:o}};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,globalThis.window?.location.pathname);return false}if(!n){console.warn("No code found");return false}if(window.opener&&window.name==="uas-popup"){console.warn("Popup window detected");return false}const a=await this.Storage.getPKCE();if(!a){console.warn("No code verifier found");return false}try{const e={client_id:this.clientId,redirect_uri:this.redirectUri,code:n,grant_type:"authorization_code",code_verifier:a};const t=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(e)});const s=await t.json();if(s){if(s.error){const e={detail:s};window.dispatchEvent(new CustomEvent("onLoginFail",e));return true}const e=await this.handleCodeExchangeResponse(s);if(!e.valid){const t={detail:e.data};window.dispatchEvent(new CustomEvent("onLoginFail",t));return true}else{if(i){e.data.state=i}const t={detail:e.data};window.dispatchEvent(new CustomEvent("onLoginSuccess",t));window.history.pushState({},document.title,window.location.pathname)}}this.Storage.removePKCE();return true}catch(s){const e={detail:s};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,globalThis.window?.location.pathname);return false}}async tokenExchange(e=""){const t=await this.Storage.getGrant(e,this.multiAccount);if(!t){return false}const n=t.refresh_token;try{const t={client_id:this.clientId,redirect_uri:this.redirectUri,refresh_token:n,grant_type:"refresh_token"};const i=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(t)});const s=await i.json();if(s){if(s.error){const e={detail:s};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const t=ee();s.expires_in=t+s.expires_in;this.Storage.setGrant(s,this.multiAccount);const n=await this.validateIDToken(e);if(!n){const e={detail:s};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const i={detail:s};window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess",i));return true}this.Storage.removePKCE()}catch(e){const t={detail:e};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",t));return false}}async handleCodeExchangeResponse(e){const t=true;if(e.error){return{data:e,valid:false}}const n=ee();e.expires_in=n+e.expires_in;this.Storage.setGrant(e,this.multiAccount);const i=oe(e.id_token);i.status="authenticated";this.Storage.setUserToken(i);const s=await this.validateIDToken(i.sub);if(!s){return{data:e,valid:false}}return{data:e,valid:t}}async popUp(e){const t=500;const n=600;const i=window.screenX+(window.outerWidth-t)/2;const s=window.screenY+(window.outerHeight-n)/2.5;const r=`uas-popup`;const o=e;const a=window.open(o,r,`width=${t},height=${n},left=${i},top=${s}`);if(!a){return}const c=setInterval((async()=>{if(a.closed){const e={detail:{error_description:"OAuth provider window closed"}};window.dispatchEvent(new CustomEvent("onLoginFail",e));c&&clearInterval(c);return}try{const e=a.location.href.split("?");if(!e[0]){return}const t=a.location.search;a.history.pushState({},document.title,window.location.pathname);if(e[0]===this.redirectUri&&e.length>1){const e=await this.codeExchange(t);a.close();if(e){location.reload()}c&&clearInterval(c);return}}catch(e){return}}),1e3)}async getAccessToken(e=""){const t=ee();const n=await this.Storage.getGrant(e,this.multiAccount);if(!n){return null}const{access_token:i,expires_in:s}=n;const r=i;if(r){if(s&&s>ee()){const e=s-t;if(e>30){return r}}}await this.tokenExchange(e);const o=await this.Storage.getGrant(e,this.multiAccount);return o.access_token}async sse(e,t){const n=t.headers||{};const i=n["Grant-ID"];let s="";if(this.multiAccount){if(!i){this.logout();throw new Error("Grant ID is required for multi account calls")}s=await this.getAccessToken(i)}else{s=await this.getAccessToken()}delete n["Grant-ID"];n["Authorization"]=`Bearer ${s}`;if(!n["content-type"]){n["content-type"]="application/json"}return V(`${this.domain}/${e}`,{...t,headers:n})}async fetch(e,t,n=true,i){let s="";let r=1;if(this.multiAccount){if(!t.grant_id){this.logout();throw new Error("Grant ID is required for multi account calls")}const e=await this.getProfiles();r=e?e.length:1;s=await this.getAccessToken(t.grant_id)}else{s=await this.getAccessToken()}if(!s){throw new Error("Access token not found")}let o=t.headers;if(!Headers.prototype.isPrototypeOf(o)){o=new Headers({Authorization:`Bearer ${s}`,"content-type":"application/json"})}else{o.append("Authorization",`Bearer ${s}`);if(!o.has("content-type")){o.append("content-type","application/json")}}try{if(t?.body){t.body=JSON.stringify(t?.body)}const s=await fetch(`${i||this.domain}/${e}`,{...t,headers:o});if(!n){return s}const a=await(s?.json());const c=await this.isAuthenticatedResponse(s.status,a);if(!c){if(r>1){const e=await this.getProfile(t.grant_id);if(e){e.status="unauthorized";await this.Storage.setUserToken(e);const t={detail:{user:e}};window.dispatchEvent(new CustomEvent("onSessionExpired",t))}}else{const e=await this.Storage.getUserToken();const t={detail:{user:e}};window.dispatchEvent(new CustomEvent("onSessionExpired",t))}this.logout();return}return a}catch(e){throw e}}async fetchRequest(e,t,n,i=true,s,r){const o=await this.isLoggedIn();const a=new URL(e,s??this.domain);const c=new Headers;c.append("Accept","application/json");c.append("Content-Type","application/json");c.append("User-Agent","nylas-identity");if(o){const e=await this.getAccessToken();c.append("Authorization",`Bearer ${e}`)}const l=await fetch(a.toString(),{method:t||"GET",headers:c,mode:"cors",referrer:globalThis.window?.location.origin,body:n?JSON.stringify(n):undefined,...r||{}});if(!i){return l.body}const u=await l.json();return u}async isAuthenticatedResponse(e,t){if(e==401&&t?.error?.type=="token.unauthorized_access"){return false}return true}addAPIKey(e,t,n){this.Storage.setUserToken({aud:"https://api-staging.us.nylas.com/",exp:2e9,email_verified:true,iat:ee(),iss:"",email:t,provider:"virtual-calendar",status:"authenticated",name:t,sub:e});this.Storage.setGrant({grant_id:e,access_token:n,expires_in:2e9},this.multiAccount)}}var ce={exports:{}};var le={};
|
|
1
|
+
import{h as e,F as t,r as n,c as i,H as s,a as r}from"./p-0EQQA0nE.js";import{N as o}from"./p-BS9pAWHt.js";import{N as a}from"./p-Cb2blKKQ.js";import{d as c,u as l,t as u,a as d,b as h,g as f,e as p,i as g}from"./p-D7AODx4L.js";import{o as y,v as w}from"./p-BI4Pj5VG.js";import{c as b}from"./p-_i6H-yQH.js";import{C as m,L as v,a as _}from"./p-COJy29df.js";c.extend(l);c.extend(u);class E{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.groupEventsCache=new Map;this.CACHE_DURATION=1*60*1e3;this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}async currentUser(){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return null}return this.nylasApiRequest.currentUser()}async getCalendars(){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching calendars: Nylas API Request is not initialized"})}const e=[];let t=null;const n=50;do{const[i,s]=await this.nylasApiRequest.request({method:"GET",path:`calendars?limit=${n}${t?`&page_token=${t}`:""}`});if(s){return h(null,{message:"Error fetching calendars: "+s.message})}if(y(i)){return h(null,{message:"Error fetching calendars: "+i.error?.message})}e.push(...i.data);t=i.next_cursor||null}while(t);this.nylasSchedulerConfigStore.state.calendars=e;return h(e)}async getConfigurationById(e,t=false){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching configuration: Nylas API Request is not initialized"})}if(!t){const t=this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e));if(t){this.nylasSchedulerConfigStore.state.selectedConfiguration=t;return h(t)}}const[n,i]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}`});if(i){return h(null,{message:"Error fetching configuration: "+i.message})}if(y(n)){return h(null,{message:"Error fetching configuration: "+n.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=n.data;if(this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e))){this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map((t=>t.id===e?n.data:t))}else{this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,n.data]}return h(n.data)}async getConfigurations(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching configurations: Nylas API Request is not initialized"})}const t=50;const[n,i]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations?limit=${t}${e?`&page_token=${e}`:""}`});if(i){return h(null,{message:"Error fetching configurations: "+i.message})}if(y(n)){return h(null,{message:"Error fetching configurations: "+n.error?.message})}this.nylasSchedulerConfigStore.state.configurations=n.data;this.nylasSchedulerConfigStore.state.listConfigurationsNextCursor=n.next_cursor||null;return h(n.data)}async getMasterEventById(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching master event: Nylas API Request is not initialized"})}const t=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const n=t?.event?.calendar_id;if(!n){d("Calendar ID is not present");return h(null,{message:"Error fetching master event: Calendar ID is not present"})}const i=new URLSearchParams;i.append("calendar_id",n);const[s,r]=await this.nylasApiRequest.request({method:"GET",path:`events/${e}?${i.toString()}`});if(r){return h(null,{message:"Error fetching master event: "+r.message})}if(y(s)){return h(null,{message:"Error fetching master event: "+s.error?.message})}const o=this.nylasSchedulerConfigStore.state.masterGroupEvents;if(o[e]){this.nylasSchedulerConfigStore.state.masterGroupEvents[e]=s.data}else{this.nylasSchedulerConfigStore.state.masterGroupEvents={...o,[e]:s.data}}return h(s.data)}async createConfiguration(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error creating configuration: Nylas API Request is not initialized"})}const[t,n]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations`,body:e});if(n){return h(null,{message:"Error creating configuration: "+n.message})}if(y(t)){return h(null,{message:"Error creating configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=t.data;this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,t.data];return h(t.data)}async updateConfiguration(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error updating configuration: Nylas API Request is not initialized"})}const[t,n]=await this.nylasApiRequest.request({method:"PUT",path:`scheduling/configurations/${e.id}`,body:e});if(n){return h(null,{message:"Error updating configuration: "+n.message})}if(y(t)){return h(null,{message:"Error updating configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=t.data;if(this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e.id))){this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map((n=>n.id===e.id?t.data:n))}else{this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,t.data]}return h(t.data)}async deleteConfiguration(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error deleting configuration: Nylas API Request is not initialized"})}const[t,n]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${e}`});if(n){return h(null,{message:"Error deleting configuration: "+n.message})}if(y(t)){return h(null,{message:"Error deleting configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.filter((t=>t.id!==e));if(this.nylasSchedulerConfigStore.state.selectedConfiguration?.id===e){this.nylasSchedulerConfigStore.resetSelectedConfiguration()}return h(t.data)}async createGroupEvent(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error creating group event: Nylas API Request is not initialized"})}const[n,i]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/group-events`,body:e});if(i){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error creating group event: "+i.message})}if(y(n)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error creating group event: "+n.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=n.data;await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(n.data)}async getGroupEvents(e,t){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching group events: Nylas API Request is not initialized"})}const n=new URLSearchParams;n.append("show_all","true");const i=this.nylasSchedulerConfigStore.state.calendarViewDateRange;let s;let r;if(i){s=i.start_time;r=i.end_time}else{const e=f((new Date).toISOString(),"week");s=e.startTime.toString();r=e.endTime.toString()}const o=`${e}-${s}-${r}`;const a=this.groupEventsCache.get(o);if(a&&Date.now()-a.timestamp<this.CACHE_DURATION){this.nylasSchedulerConfigStore.state.groupEvents=a.data;return h(a.data)}n.append("start_time",s);n.append("end_time",r);const c=t?.group_booking?.calendar_id;if(c){n.append("calendar_id",c)}const[l,u]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}/group-events?${n.toString()}`});if(u){return h(null,{message:"Error fetching group events: "+u.message})}if(y(l)){return h(null,{message:"Error fetching group events: "+l.error?.message})}this.groupEventsCache.set(o,{data:l.data,timestamp:Date.now()});this.cleanupExpiredCache();this.nylasSchedulerConfigStore.state.groupEvents=l.data;return h(l.data)}cleanupExpiredCache(){const e=Date.now();for(const[t,n]of this.groupEventsCache.entries()){if(e-n.timestamp>this.CACHE_DURATION){this.groupEventsCache.delete(t)}}}async updateGroupEventById(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error updating group event: Nylas API Request is not initialized"})}const n=e.id;delete e.id;const[i,s]=await this.nylasApiRequest.request({method:"PATCH",path:`scheduling/configurations/${t}/group-events/${n}`,body:e});if(s){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error updating group event: "+s.message})}if(y(i)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error updating group event: "+i.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=i.data;await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(i.data)}async updateGroupEvent(e,t,n){this.nylasSchedulerConfigStore.state.isLoading=true;const i=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const s=i?.event?.master_event_id;const r=i?.event?.id;const o=i?.event?.when?.start_time;const a=i?.group_event_info?.rrule?.[0];const l=a?a.split(";").filter((e=>!e.startsWith("UNTIL"))).join(";"):"";const u=o?c(o*1e3).subtract(1,"minute").format("YYYYMMDDTHHmmss[Z]"):"";if(t==="this"){return this.updateGroupEventById({...e,id:r,recurrence:s?undefined:e.recurrence},n)}else if(t==="future"&&s){const t=await this.createGroupEvent(e,n);const r={location:i?.event?.location,conferencing:i?.event?.conferencing,title:i?.event?.title,description:i?.event?.description,capacity:i?.group_event_info?.capacity,calendar_id:i?.event?.calendar_id,recurrence:l?[l+";UNTIL="+u]:[`RRULE:FREQ=DAILY;UNTIL=${u}`]};await this.updateGroupEventById({...r,id:s},n);return[r,t]}else if(t==="all"){const t=e?.when;const r=i?.event?.when;const o=this.nylasSchedulerConfigStore.state.masterGroupEvents?.[s];let a=o?.when;if(t?.start_time!==r?.start_time){a={...a,start_time:t?.start_time||a?.start_time}}if(t?.end_time!==r?.end_time){a={...a,end_time:t?.end_time||a?.end_time}}if(t?.start_timezone!==r?.start_timezone){a={...a,start_timezone:t?.start_timezone||a?.start_timezone}}if(t?.end_timezone!==r?.end_timezone){a={...a,end_timezone:t?.end_timezone||a?.end_timezone}}return this.updateGroupEventById({...e,when:a,id:s},n)}this.nylasSchedulerConfigStore.state.isLoading=false;throw new Error("Invalid option")}async deleteGroupEvent(e,t,n){this.nylasSchedulerConfigStore.state.isLoading=true;const i=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const s=i?.event?.master_event_id;const r=i?.event?.id;const o=i?.event?.when?.start_time;const a=i?.group_event_info?.rrule?.[0];const l=a?a.split(";").filter((e=>!e.startsWith("UNTIL"))).join(";"):"";const u=o?c(o*1e3).format("YYYYMMDDTHHmmss[Z]"):"";const d={location:i?.event?.location,conferencing:i?.event?.conferencing,title:i?.event?.title,description:i?.event?.description,capacity:i?.group_event_info?.capacity,calendar_id:i?.event?.calendar_id,recurrence:l?[l+";UNTIL="+u]:[`RRULE:UNTIL=${u}`]};if(t==="this"&&r){return this.deleteGroupEventById(r,n)}else if(t==="future"&&s&&r){await this.deleteGroupEventById(r,n);return await this.updateGroupEventById({...d,id:s},n)}else if(t==="all"&&s){return this.deleteGroupEventById(s,n)}this.nylasSchedulerConfigStore.state.isLoading=false;throw new Error("Invalid option")}async deleteGroupEventById(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error deleting group event: Nylas API Request is not initialized"})}const n=new URLSearchParams;const i=this.nylasSchedulerConfigStore.state.selectedConfiguration?.group_booking?.calendar_id;if(i){n.append("calendar_id",i)}const[s,r]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${t}/group-events/${e}?calendar_id=${i}`});if(r){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error deleting group event: "+r.message})}if(y(s)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error deleting group event: "+s.error?.message})}await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(s.data)}async importGroupEvent(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error importing group event: Nylas API Request is not initialized"})}const n=new URLSearchParams;const i=this.nylasSchedulerConfigStore.state.selectedConfiguration?.group_booking?.calendar_id;if(i){n.append("calendar_id",i)}const[s,r]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/import-group-events?${n.toString()}`,body:e});if(r){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error importing group event: "+r.message})}if(y(s)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error importing group event: "+s.error?.message})}if(s.data?.imported_events?.length>0){await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration)}this.nylasSchedulerConfigStore.state.isLoading=false;return h(s.data)}}class k{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}init(){d("NylasSchedulerConfigConnector init")}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get schedulerConfig(){if(this._schedulerConfigConnector){return this._schedulerConfigConnector}this._schedulerConfigConnector=new E({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore});return this._schedulerConfigConnector}resetStores(){d("NylasSchedulerConfigConnector resetStores");this.nylasSchedulerConfigStore.reset()}async logout(){d("NylasSchedulerConfigConnector logout");this.resetStores()}}function x(e={}){const t={selectedConfiguration:{},configurations:[],groupEvents:[],listConfigurationsNextCursor:null,calendars:[],currentUser:null,action:null,additionalParticipants:[],requiresSlug:false,masterGroupEvents:{},isLoading:false,...e};const n=b(t);function i(){n.set("selectedConfiguration",{...e["selectedConfiguration"]})}n.onChange("action",(async e=>{if(!e){i()}}));return{...n,resetSelectedConfiguration:i}}class C{get(e){return new Promise((t=>{const n=globalThis.window?.localStorage.getItem(e);if(!n){t(null)}else{t(JSON.parse(n))}}))}async remove(e){globalThis.window?.localStorage.removeItem(e);return new Promise((e=>{e(null)}))}set(e,t){globalThis.window?.localStorage.setItem(e,JSON.stringify(t));return new Promise((e=>{e(null)}))}}const $="pkce";const S="grant";const T="user";const P=e=>{if(typeof globalThis.btoa==="function"&&typeof TextEncoder!=="undefined"){const t=(new TextEncoder).encode(e);let n="";for(let e=0;e<t.length;e++){n+=String.fromCharCode(t[e])}return globalThis.btoa(n)}if(typeof globalThis.Buffer!=="undefined"){return globalThis.Buffer.from(e,"utf8").toString("base64")}throw new Error("Base64 encoding is not supported in this environment")};const R=e=>{if(typeof globalThis.atob==="function"&&typeof TextDecoder!=="undefined"){const t=globalThis.atob(e);const n=new Uint8Array(t.length);for(let e=0;e<t.length;e++){n[e]=t.charCodeAt(e)}return(new TextDecoder).decode(n)}if(typeof globalThis.Buffer!=="undefined"){return globalThis.Buffer.from(e,"base64").toString("utf8")}throw new Error("Base64 decoding is not supported in this environment")};class I{Storage=new C;constructor(e){if(e){this.Storage=e;return}}setPKCE(e){const t=P(e);this.Storage.set($,t)}async getPKCE(){try{const e=await this.Storage.get($);if(e){return R(e)}}catch(e){return null}return null}removePKCE(){this.Storage.remove($)}setGrant(e,t=false){const{grant_id:n}=e;this.Storage.set(`${S}${t?"-"+n:""}`,e)}removeGrant(e,t=false){this.Storage.remove(`${S}${t?"-"+e:""}`)}async getGrant(e,t=false){const n=await this.Storage.get(`${S}${t?"-"+e:""}`);if(n){return n}return null}async setUserToken(e){const t=await this.getUserTokens();if(t){const n=t.find((t=>t.sub===e.sub));if(!n){const n=[...t,e];this.Storage.set(T,n)}else{const n=t.map((t=>{if(t.sub===e.sub){t=e}return t}));this.Storage.set(T,n)}}else{this.Storage.set(T,[e])}}async getUserToken(e=""){const t=await this.Storage.get(T);if(t){if(e===""){return t[0]}const n=t.find((t=>t.sub===e));return n}return null}async getUserTokens(){const e=await this.Storage.get(T);if(e){return e}return null}removeUserTokens(){this.Storage.remove(T)}async removeUserToken(e){const t=await this.getUserTokens();const n=t?.filter((t=>t.sub!==e));this.Storage.set(T,n)}async clearSession(){const e=await this.getUserTokens();e?.forEach((e=>{this.removeGrant(e.sub)}));this.removePKCE();this.removeUserTokens()}}class q{databaseName="identity-db";storeName="identity";get(e){const t=this;return new Promise(((n,i)=>{t.openDatabase().then((function(s){const r=s.transaction(t.storeName,"readwrite");const o=r.objectStore(t.storeName);const a=o.get(e);a.onsuccess=()=>{n(a.result)};a.onerror=()=>{i(a.error)};r.oncomplete=()=>{s.close()}}))}))}async remove(e){const t=this;return new Promise(((n,i)=>{const s=indexedDB.open(this.databaseName);s.onupgradeneeded=function(e){const n=e.target.result;n.createObjectStore(t.storeName)};s.onerror=()=>{i(s.error)};s.onsuccess=t=>{const s=t.target.result;const r=s.transaction(this.storeName,"readwrite");const o=r.objectStore(this.storeName);const a=o.delete(e);a.onsuccess=()=>{n(null)};a.onerror=()=>{i(a.error)};r.oncomplete=()=>{s.close()}}}))}set(e,t){return new Promise(((n,i)=>{const s=indexedDB.open(this.databaseName);s.onerror=()=>{i(s.error)};s.onupgradeneeded=e=>{const t=e.target.result;t.createObjectStore(this.storeName)};s.onsuccess=s=>{const r=s.target.result;const o=r.transaction(this.storeName,"readwrite");const a=o.objectStore(this.storeName);const c=a.put(t,e);c.onsuccess=()=>{n(t)};c.onerror=()=>{i(c.error)};o.oncomplete=()=>{r.close()}}}))}openDatabase(){const e=this;return new Promise((function(t,n){const i=indexedDB.open(e.databaseName,2);i.onupgradeneeded=function(t){const n=t.target.result;n.createObjectStore(e.storeName)};i.onsuccess=function(e){t(e.target.result)};i.onerror=function(e){n(e.error)}}))}}var A;var N=new Uint8Array(16);function U(){if(!A){A=typeof crypto!=="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!=="undefined"&&typeof msCrypto.getRandomValues==="function"&&msCrypto.getRandomValues.bind(msCrypto);if(!A){throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported")}}return A(N)}var L=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function j(e){return typeof e==="string"&&L.test(e)}var z=[];for(var O=0;O<256;++O){z.push((O+256).toString(16).substr(1))}function D(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var n=(z[e[t+0]]+z[e[t+1]]+z[e[t+2]]+z[e[t+3]]+"-"+z[e[t+4]]+z[e[t+5]]+"-"+z[e[t+6]]+z[e[t+7]]+"-"+z[e[t+8]]+z[e[t+9]]+"-"+z[e[t+10]]+z[e[t+11]]+z[e[t+12]]+z[e[t+13]]+z[e[t+14]]+z[e[t+15]]).toLowerCase();if(!j(n)){throw TypeError("Stringified UUID is invalid")}return n}function G(e,t,n){e=e||{};var i=e.random||(e.rng||U)();i[6]=i[6]&15|64;i[8]=i[8]&63|128;return D(i)}async function H(e,t){const n=e.getReader();let i;while(!(i=await n.read()).done){t(i.value)}}function B(e){let t;let n;let i;let s=false;return function r(o){if(t===undefined){t=o;n=0;i=-1}else{t=M(t,o)}const a=t.length;let c=0;while(n<a){if(s){if(t[n]===10){c=++n}s=false}let r=-1;for(;n<a&&r===-1;++n){switch(t[n]){case 58:if(i===-1){i=n-c}break;case 13:s=true;case 10:r=n;break}}if(r===-1){break}e(t.subarray(c,r),i);c=n;i=-1}if(c===a){t=undefined}else if(c!==0){t=t.subarray(c);n-=c}}}function F(e,t,n){let i=J();const s=new TextDecoder;return function r(o,a){if(o.length===0){n===null||n===void 0?void 0:n(i);i=J()}else if(a>0){const n=s.decode(o.subarray(0,a));const r=a+(o[a+1]===32?2:1);const c=s.decode(o.subarray(r));switch(n){case"data":i.data=i.data?i.data+"\n"+c:c;break;case"event":i.event=c;break;case"id":e(i.id=c);break;case"retry":const n=parseInt(c,10);if(!isNaN(n)){t(i.retry=n)}break}}}}function M(e,t){const n=new Uint8Array(e.length+t.length);n.set(e);n.set(t,e.length);return n}function J(){return{data:"",event:"",id:"",retry:undefined}}var Y=undefined&&undefined.__rest||function(e,t){var n={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0)n[i]=e[i];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var s=0,i=Object.getOwnPropertySymbols(e);s<i.length;s++){if(t.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(e,i[s]))n[i[s]]=e[i[s]]}return n};const K="text/event-stream";const V=1e3;const W="last-event-id";function Q(e,t){var{signal:n,headers:i,onopen:s,onmessage:r,onclose:o,onerror:a,openWhenHidden:c,fetch:l}=t,u=Y(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise(((t,d)=>{const h=Object.assign({},i);if(!h.accept){h.accept=K}let f;function p(){f.abort();if(!document.hidden){v()}}if(!c){document.addEventListener("visibilitychange",p)}let g=V;let y=0;function w(){document.removeEventListener("visibilitychange",p);window.clearTimeout(y);f.abort()}n===null||n===void 0?void 0:n.addEventListener("abort",(()=>{w();t()}));const b=l!==null&&l!==void 0?l:window.fetch;const m=s!==null&&s!==void 0?s:Z;async function v(){var n;f=new AbortController;try{const n=await b(e,Object.assign(Object.assign({},u),{headers:h,signal:f.signal}));await m(n);await H(n.body,B(F((e=>{if(e){h[W]=e}else{delete h[W]}}),(e=>{g=e}),r)));o===null||o===void 0?void 0:o();w();t()}catch(e){if(!f.signal.aborted){try{const t=(n=a===null||a===void 0?void 0:a(e))!==null&&n!==void 0?n:g;window.clearTimeout(y);y=window.setTimeout(v,t)}catch(e){w();d(e)}}}}v()}))}function Z(e){const t=e.headers.get("content-type");if(!(t===null||t===void 0?void 0:t.startsWith(K))){throw new Error(`Expected content-type to be ${K}, Actual: ${t}`)}}function X(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function ee(){return Math.floor(Date.now()/1e3)}async function te(e){const t=(new TextEncoder).encode(e);const n=await crypto.subtle.digest("SHA-256",t);const i=Array.from(new Uint8Array(n));const s=i.map((e=>e.toString(16).padStart(2,"0"))).join("");return s}function ne(e){this.message=e}ne.prototype=new Error,ne.prototype.name="InvalidCharacterError";var ie="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new ne("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,s=0,r=0,o="";i=t.charAt(r++);~i&&(n=s%4?64*n+i:i,s++%4)?o+=String.fromCharCode(255&n>>(-2*s&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return o};function se(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(ie(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return ie(t)}}function re(e){this.message=e}function oe(e,t){if("string"!=typeof e)throw new re("Invalid token specified");var n=true===(t=t||{}).header?0:1;try{return JSON.parse(se(e.split(".")[n]))}catch(e){throw new re("Invalid token specified: "+e.message)}}re.prototype=new Error,re.prototype.name="InvalidTokenError";class ae{clientId;redirectUri;accessType="online";domain="http://api.nylas.com";versioned=false;Storage;hosted=false;multiAccount=false;loginId="";constructor(e){this.clientId=e.clientId;this.redirectUri=e.redirectUri;if(e.domain){this.domain=e.domain;const t=this.domain.substring(this.domain.length-3);if(t.includes("/v")){this.versioned=true}}if(e.multiAccount){this.multiAccount=e.multiAccount}if(e.sw){const e=new q;this.Storage=new I(e)}else{this.Storage=new I}if(e.accessType){this.accessType=e.accessType}if(e.loginId){this.loginId=e.loginId}if(e.hosted){this.hosted=e.hosted}if(e.disableInitCodeExchange!==true){this.codeExchange(null)}}async validateAccessToken(e=""){const t=await this.Storage.getGrant(e,this.multiAccount);if(!t){return false}const{access_token:n}=t;try{const e=await fetch(`${this.domain}/connect/tokeninfo?access_token=${n}`,{method:"GET"});const t=await e.json();if(!t.data){return false}return true}catch(e){return false}}async validateIDToken(e=""){const t=await this.Storage.getGrant(e,this.multiAccount);if(!t){return false}const{id_token:n}=t;try{const e=await fetch(`${this.domain}/connect/tokeninfo?id_token=${n}`,{method:"GET"});if(e.status!==200){return false}const t=await e.json();if(!t.data){return false}return true}catch(e){return false}}getDomain(){return this.domain}async auth(e){if(this.hosted&&(this.domain===globalThis.window?.location.origin||this.versioned&&this.domain.includes(globalThis.window?.location.origin))){await this.hostedSetCodeChallenge()}const t=await this.generateAuthURL(e);if(e.popup){this.popUp(t);return}return t}async generateAuthURL(e){const t=await this.getCodeChallege();let n=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(t){n+=`&code_challenge=${t}&code_challenge_method=S256&options=rotate_refresh_token`}if(e.provider){n+=`&provider=${e.provider}`}if(e.loginHint){n+=`&login_hint=${e.loginHint}`;if(e.includeGrantScopes){n+=`&include_grant_scopes=${e.includeGrantScopes}`}}if(e.scope){n+=`&scope=${e.scope.join(" ")}`}if(e.prompt){n+=`&prompt=${e.prompt}`}if(e.metadata){n+=`&metadata=${e.metadata}`}if(e.state||this.loginId){n+=`&state=${this.loginId?this.loginId:e.state}`}return n}async generateReauthURL(e,t){if(!e){throw new Error("Grant ID is required")}const n=await this.Storage.getUserToken(e);const i=await this.getCodeChallege();let s=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(i){s+=`&code_challenge=${i}&code_challenge_method=S256&options=rotate_refresh_token`}if(n?.provider){s+=`&provider=${n.provider}`}if(n?.email){s+=`&login_hint=${n.email}`}if(t){s+=`&scope=${t.join(" ")}`}return s}async generateCodeChallenge(){const e=await this.Storage.getPKCE();if(e){return}const t=G();this.Storage.setPKCE(t);return}async hostedSetCodeChallenge(){if(!this.hosted){throw console.error("Method only used with hosted flag enabled")}const e=new URLSearchParams(globalThis.window?.location.search);const t=e.get("code_challenge");if(!t){const e=await this.Storage.getPKCE();if(e){return}console.warn("Code challenge is recomended");return}this.Storage.setPKCE(t)}async getCodeChallege(){if(this.hosted&&(this.domain===globalThis.window?.location.origin||this.versioned&&this.domain.includes(globalThis.window?.location.origin))){const e=new URLSearchParams(globalThis.window?.location.search);const t=e.get("code_challenge");if(!t){console.warn("Code challenge is recomended");return""}return t}const e=await this.Storage.getPKCE();if(e){const t=await te(e);let n=btoa(unescape(encodeURIComponent(t)));n=X(n);return n}return""}async isLoggedIn(){if(this.hosted&&(this.domain===globalThis.window?.location.origin||this.versioned&&this.domain.includes(globalThis.window?.location.origin))){return false}const e=await this.Storage.getUserTokens();if(e&&e.length>0){if(this.multiAccount){await this.generateCodeChallenge()}return true}await this.generateCodeChallenge();return false}isMultiAccount(){return this.multiAccount}async logout(){const e=await this.getProfile();await this.Storage.clearSession();const t={detail:e};window.dispatchEvent(new CustomEvent("onLogoutSuccess",t))}async getProfile(e=""){let t;if(e){t=await this.Storage.getUserToken(e)}else{t=await this.Storage.getUserToken()}if(t){return t}return null}async getProfiles(){const e=await this.Storage.getUserTokens();if(e){return e}return null}async removeProfile(e){await this.Storage.removeUserToken(e);await this.Storage.removeGrant(e);return null}async authIMAP(e){const t=await this.getCodeChallege();const n={imap_username:e.imap_username,imap_password:e.imap_password,imap_host:e.imap_host,imap_port:e.imap_port,type:e.type,smtp_host:e.smtp_host,smtp_port:e.smtp_port,provider:e.provider,redirect_uri:this.redirectUri,state:e.state,public_application_id:this.clientId,access_type:this.accessType};if(this.loginId){n.id=this.loginId}if(e.smtp_username&&e.smtp_password){n.smtp_username=e.smtp_username;n.smtp_password=e.smtp_password}if(t!=""){n.code_challenge=t;n.code_challenge_method="S256"}const i=await fetch(`${this.domain}/connect/login/imap`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(n)});const s=await i.json();return s}async authEWS(e){const t=await this.getCodeChallege();const n={...e,provider:"ews",redirect_uri:this.redirectUri,public_application_id:this.clientId,access_type:this.accessType};if(this.loginId){n.id=this.loginId}if(t!=""){n.code_challenge=t;n.code_challenge_method="S256"}const i=await fetch(`${this.domain}/connect/login/ews`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(n)});const s=await i.json();return s}async detectEmail(e){const t=await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/providers/detect?client_id=${this.clientId}&email=${e}`,{method:"POST",headers:new Headers({"content-type":"application/json"})});const n=await t.json();return n}async applicationInfo(){const e=await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/applications?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});const t=await e.json();return t.data}async getAvailableProviders(){const e=await fetch(`${this.domain}/connect/providers/find?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});if(e){const t=await e.json();const n=t.data;return n}return null}onLoginSuccess(e){window.addEventListener("onLoginSuccess",(t=>e(t)))}onLogoutSuccess(e){window.addEventListener("onLogoutSuccess",(t=>e(t)))}onLoginFail(e){window.addEventListener("onLoginFail",(t=>e(t)))}onTokenRefreshSuccess(e){window.addEventListener("onTokenRefreshSuccess",(t=>e(t)))}onTokenRefreshFail(e){window.addEventListener("onTokenRefreshFail",(t=>e(t)))}onSessionExpired(e){window.addEventListener("onSessionExpired",(t=>e(t)))}async codeExchange(e){let t=new URLSearchParams(globalThis.window?.location.search);if(e){t=new URLSearchParams(e)}const n=t.get("code");const i=t.get("state");const s=t.get("error");const r=t.get("error_description");const o=t.get("error_code");if(s&&r&&o){const e={detail:{error:s,error_description:r,error_code:o}};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,globalThis.window?.location.pathname);return false}if(!n){console.warn("No code found");return false}if(window.opener&&window.name==="uas-popup"){console.warn("Popup window detected");return false}const a=await this.Storage.getPKCE();if(!a){console.warn("No code verifier found");return false}try{const e={client_id:this.clientId,redirect_uri:this.redirectUri,code:n,grant_type:"authorization_code",code_verifier:a};const t=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(e)});const s=await t.json();if(s){if(s.error){const e={detail:s};window.dispatchEvent(new CustomEvent("onLoginFail",e));return true}const e=await this.handleCodeExchangeResponse(s);if(!e.valid){const t={detail:e.data};window.dispatchEvent(new CustomEvent("onLoginFail",t));return true}else{if(i){e.data.state=i}const t={detail:e.data};window.dispatchEvent(new CustomEvent("onLoginSuccess",t));window.history.pushState({},document.title,window.location.pathname)}}this.Storage.removePKCE();return true}catch(s){const e={detail:s};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,globalThis.window?.location.pathname);return false}}async tokenExchange(e=""){const t=await this.Storage.getGrant(e,this.multiAccount);if(!t){return false}const n=t.refresh_token;try{const t={client_id:this.clientId,redirect_uri:this.redirectUri,refresh_token:n,grant_type:"refresh_token"};const i=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(t)});const s=await i.json();if(s){if(s.error){const e={detail:s};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const t=ee();s.expires_in=t+s.expires_in;this.Storage.setGrant(s,this.multiAccount);const n=await this.validateIDToken(e);if(!n){const e={detail:s};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const i={detail:s};window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess",i));return true}this.Storage.removePKCE()}catch(e){const t={detail:e};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",t));return false}}async handleCodeExchangeResponse(e){const t=true;if(e.error){return{data:e,valid:false}}const n=ee();e.expires_in=n+e.expires_in;this.Storage.setGrant(e,this.multiAccount);const i=oe(e.id_token);i.status="authenticated";this.Storage.setUserToken(i);const s=await this.validateIDToken(i.sub);if(!s){return{data:e,valid:false}}return{data:e,valid:t}}async popUp(e){const t=500;const n=600;const i=window.screenX+(window.outerWidth-t)/2;const s=window.screenY+(window.outerHeight-n)/2.5;const r=`uas-popup`;const o=e;const a=window.open(o,r,`width=${t},height=${n},left=${i},top=${s}`);if(!a){return}const c=setInterval((async()=>{if(a.closed){const e={detail:{error_description:"OAuth provider window closed"}};window.dispatchEvent(new CustomEvent("onLoginFail",e));c&&clearInterval(c);return}try{const e=a.location.href.split("?");if(!e[0]){return}const t=a.location.search;a.history.pushState({},document.title,window.location.pathname);if(e[0]===this.redirectUri&&e.length>1){const e=await this.codeExchange(t);a.close();if(e){location.reload()}c&&clearInterval(c);return}}catch(e){return}}),1e3)}async getAccessToken(e=""){const t=ee();const n=await this.Storage.getGrant(e,this.multiAccount);if(!n){return null}const{access_token:i,expires_in:s}=n;const r=i;if(r){if(s&&s>ee()){const e=s-t;if(e>30){return r}}}await this.tokenExchange(e);const o=await this.Storage.getGrant(e,this.multiAccount);return o.access_token}async sse(e,t){const n=t.headers||{};const i=n["Grant-ID"];let s="";if(this.multiAccount){if(!i){this.logout();throw new Error("Grant ID is required for multi account calls")}s=await this.getAccessToken(i)}else{s=await this.getAccessToken()}delete n["Grant-ID"];n["Authorization"]=`Bearer ${s}`;if(!n["content-type"]){n["content-type"]="application/json"}return Q(`${this.domain}/${e}`,{...t,headers:n})}async fetch(e,t,n=true,i){let s="";let r=1;if(this.multiAccount){if(!t.grant_id){this.logout();throw new Error("Grant ID is required for multi account calls")}const e=await this.getProfiles();r=e?e.length:1;s=await this.getAccessToken(t.grant_id)}else{s=await this.getAccessToken()}if(!s){throw new Error("Access token not found")}let o=t.headers;if(!Headers.prototype.isPrototypeOf(o)){o=new Headers({Authorization:`Bearer ${s}`,"content-type":"application/json"})}else{o.append("Authorization",`Bearer ${s}`);if(!o.has("content-type")){o.append("content-type","application/json")}}try{if(t?.body){t.body=JSON.stringify(t?.body)}const s=await fetch(`${i||this.domain}/${e}`,{...t,headers:o});if(!n){return s}const a=await(s?.json());const c=await this.isAuthenticatedResponse(s.status,a);if(!c){if(r>1){const e=await this.getProfile(t.grant_id);if(e){e.status="unauthorized";await this.Storage.setUserToken(e);const t={detail:{user:e}};window.dispatchEvent(new CustomEvent("onSessionExpired",t))}}else{const e=await this.Storage.getUserToken();const t={detail:{user:e}};window.dispatchEvent(new CustomEvent("onSessionExpired",t))}this.logout();return}return a}catch(e){throw e}}async fetchRequest(e,t,n,i=true,s,r){const o=await this.isLoggedIn();const a=new URL(e,s??this.domain);const c=new Headers;c.append("Accept","application/json");c.append("Content-Type","application/json");c.append("User-Agent","nylas-identity");if(o){const e=await this.getAccessToken();c.append("Authorization",`Bearer ${e}`)}const l=await fetch(a.toString(),{method:t||"GET",headers:c,mode:"cors",referrer:globalThis.window?.location.origin,body:n?JSON.stringify(n):undefined,...r||{}});if(!i){return l.body}const u=await l.json();return u}async isAuthenticatedResponse(e,t){if(e==401&&t?.error?.type=="token.unauthorized_access"){return false}return true}addAPIKey(e,t,n){this.Storage.setUserToken({aud:"https://api-staging.us.nylas.com/",exp:2e9,email_verified:true,iat:ee(),iss:"",email:t,provider:"virtual-calendar",status:"authenticated",name:t,sub:e});this.Storage.setGrant({grant_id:e,access_token:n,expires_in:2e9},this.multiAccount)}}var ce={exports:{}};var le={};
|
|
2
2
|
/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react.production.min.js
|
|
@@ -8,4 +8,4 @@ import{h as e,F as t,r as n,c as i,H as s,a as r}from"./p-0EQQA0nE.js";import{N
|
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
10
|
*/var ue;function de(){if(ue)return le;ue=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),o=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),l=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),d=Symbol.iterator;function h(e){if(null===e||"object"!==typeof e)return null;e=d&&e[d]||e["@@iterator"];return"function"===typeof e?e:null}var f={isMounted:function(){return false},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},p=Object.assign,g={};function y(e,t,n){this.props=e;this.context=t;this.refs=g;this.updater=n||f}y.prototype.isReactComponent={};y.prototype.setState=function(e,t){if("object"!==typeof e&&"function"!==typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function w(){}w.prototype=y.prototype;function b(e,t,n){this.props=e;this.context=t;this.refs=g;this.updater=n||f}var m=b.prototype=new w;m.constructor=b;p(m,y.prototype);m.isPureReactComponent=true;var v=Array.isArray,_=Object.prototype.hasOwnProperty,E={current:null},k={key:true,ref:true,__self:true,__source:true};function x(t,n,i){var s,r={},o=null,a=null;if(null!=n)for(s in void 0!==n.ref&&(a=n.ref),void 0!==n.key&&(o=""+n.key),n)_.call(n,s)&&!k.hasOwnProperty(s)&&(r[s]=n[s]);var c=arguments.length-2;if(1===c)r.children=i;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];r.children=l}if(t&&t.defaultProps)for(s in c=t.defaultProps,c)void 0===r[s]&&(r[s]=c[s]);return{$$typeof:e,type:t,key:o,ref:a,props:r,_owner:E.current}}function C(t,n){return{$$typeof:e,type:t.type,key:n,ref:t.ref,props:t.props,_owner:t._owner}}function $(t){return"object"===typeof t&&null!==t&&t.$$typeof===e}function S(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}var T=/\/+/g;function P(e,t){return"object"===typeof e&&null!==e&&null!=e.key?S(""+e.key):t.toString(36)}function R(n,i,s,r,o){var a=typeof n;if("undefined"===a||"boolean"===a)n=null;var c=false;if(null===n)c=true;else switch(a){case"string":case"number":c=true;break;case"object":switch(n.$$typeof){case e:case t:c=true}}if(c)return c=n,o=o(c),n=""===r?"."+P(c,0):r,v(o)?(s="",null!=n&&(s=n.replace(T,"$&/")+"/"),R(o,i,s,"",(function(e){return e}))):null!=o&&($(o)&&(o=C(o,s+(!o.key||c&&c.key===o.key?"":(""+o.key).replace(T,"$&/")+"/")+n)),i.push(o)),1;c=0;r=""===r?".":r+":";if(v(n))for(var l=0;l<n.length;l++){a=n[l];var u=r+P(a,l);c+=R(a,i,s,u,o)}else if(u=h(n),"function"===typeof u)for(n=u.call(n),l=0;!(a=n.next()).done;)a=a.value,u=r+P(a,l++),c+=R(a,i,s,u,o);else if("object"===a)throw i=String(n),Error("Objects are not valid as a React child (found: "+("[object Object]"===i?"object with keys {"+Object.keys(n).join(", ")+"}":i)+"). If you meant to render a collection of children, use an array instead.");return c}function I(e,t,n){if(null==e)return e;var i=[],s=0;R(e,i,"","",(function(e){return t.call(n,e,s++)}));return i}function q(e){if(-1===e._status){var t=e._result;t=t();t.then((function(t){if(0===e._status||-1===e._status)e._status=1,e._result=t}),(function(t){if(0===e._status||-1===e._status)e._status=2,e._result=t}));-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var A={current:null},N={transition:null},U={ReactCurrentDispatcher:A,ReactCurrentBatchConfig:N,ReactCurrentOwner:E};le.Children={map:I,forEach:function(e,t,n){I(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;I(e,(function(){t++}));return t},toArray:function(e){return I(e,(function(e){return e}))||[]},only:function(e){if(!$(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};le.Component=y;le.Fragment=n;le.Profiler=s;le.PureComponent=b;le.StrictMode=i;le.Suspense=c;le.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=U;le.cloneElement=function(t,n,i){if(null===t||void 0===t)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var s=p({},t.props),r=t.key,o=t.ref,a=t._owner;if(null!=n){void 0!==n.ref&&(o=n.ref,a=E.current);void 0!==n.key&&(r=""+n.key);if(t.type&&t.type.defaultProps)var c=t.type.defaultProps;for(l in n)_.call(n,l)&&!k.hasOwnProperty(l)&&(s[l]=void 0===n[l]&&void 0!==c?c[l]:n[l])}var l=arguments.length-2;if(1===l)s.children=i;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];s.children=c}return{$$typeof:e,type:t.type,key:r,ref:o,props:s,_owner:a}};le.createContext=function(e){e={$$typeof:o,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null};e.Provider={$$typeof:r,_context:e};return e.Consumer=e};le.createElement=x;le.createFactory=function(e){var t=x.bind(null,e);t.type=e;return t};le.createRef=function(){return{current:null}};le.forwardRef=function(e){return{$$typeof:a,render:e}};le.isValidElement=$;le.lazy=function(e){return{$$typeof:u,_payload:{_status:-1,_result:e},_init:q}};le.memo=function(e,t){return{$$typeof:l,type:e,compare:void 0===t?null:t}};le.startTransition=function(e){var t=N.transition;N.transition={};try{e()}finally{N.transition=t}};le.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")};le.useCallback=function(e,t){return A.current.useCallback(e,t)};le.useContext=function(e){return A.current.useContext(e)};le.useDebugValue=function(){};le.useDeferredValue=function(e){return A.current.useDeferredValue(e)};le.useEffect=function(e,t){return A.current.useEffect(e,t)};le.useId=function(){return A.current.useId()};le.useImperativeHandle=function(e,t,n){return A.current.useImperativeHandle(e,t,n)};le.useInsertionEffect=function(e,t){return A.current.useInsertionEffect(e,t)};le.useLayoutEffect=function(e,t){return A.current.useLayoutEffect(e,t)};le.useMemo=function(e,t){return A.current.useMemo(e,t)};le.useReducer=function(e,t,n){return A.current.useReducer(e,t,n)};le.useRef=function(e){return A.current.useRef(e)};le.useState=function(e){return A.current.useState(e)};le.useSyncExternalStore=function(e,t,n){return A.current.useSyncExternalStore(e,t,n)};le.useTransition=function(){return A.current.useTransition()};le.version="18.2.0";return le}var he;function fe(){if(he)return ce.exports;he=1;{ce.exports=de()}return ce.exports}fe();const pe=({authenticationUrl:t})=>e("div",{class:"login-required",part:"nse__login-required login-component"},e("div",{class:"card",part:"nse__login-required-card"},e("p",{part:"nse__login-required-text"},"Log into your account to use the Scheduler Editor."),e("button",{class:"google-button",part:"nse__login-required-google-button",onClick:async e=>{e.preventDefault();const n=await t("google");if(n){window.location.href=n}else{p(`[nylas-scheduler-editor] Unable to get authentication URL.`)}}},e("span",{class:"icon"},e("google-logo-icon",{width:"15",height:"15"})),"Continue with Google"),e("button",{class:"microsoft-button",part:"nse__login-required-microsoft-button",onClick:async e=>{e.preventDefault();const n=await t("microsoft");if(n){window.location.href=n}else{p(`[nylas-scheduler-editor] Unable to get authentication URL.`)}}},e("span",{class:"icon"},e("microsoft-logo-icon",{width:"15",height:"15"})),"Continue with Microsoft"),e("button",{class:"other-provider-button",part:"nse__login-required-other-provider-button",onClick:async e=>{e.preventDefault();const n=await t();if(n){window.location.href=n}else{p(`[nylas-scheduler-editor] Unable to get authentication URL.`)}}},"View all providers ",e("chevron-icon",{width:"17",height:"17"})),e("small",{class:"disclaimer-text",part:"nse__login-required-disclaimer-text"},"* You will be redirected to authenticate your account.")));function ge({currentUser:n,calendars:i,selectedEventType:s}){const r=i?.find((e=>e.is_primary))||i?.[0];switch(s){case m.one_on_one:case m.max_availability:case m.max_fairness:{return e(t,null,e("nylas-event-info",null,e("div",{slot:"inputs"},e("nylas-event-title",null),e("nylas-event-duration",null),e("nylas-event-location",{userProvider:n.provider}))),e("nylas-booking-calendar-picker",{exportparts:"nbcp, nbcp__header, nbcp__dropdown, nbcp__dropdown-button, nbcp__dropdown-content",expressFlow:true,calendars:i,currentUser:n,defaultBookingCalendar:r?.id}),e("nylas-custom-event-slug",{name:"custom-event-slug",exportparts:"nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield"}))}case m.collective:{return e(t,null,e("nylas-event-info",null,e("div",{slot:"inputs"},e("nylas-event-title",null),e("nylas-event-duration",null),e("nylas-event-location",{userProvider:n.provider}))),e("nylas-booking-calendar-picker",{exportparts:"nbcp, nbcp__header, nbcp__dropdown, nbcp__dropdown-button, nbcp__dropdown-content",expressFlow:true,calendars:i,currentUser:n,defaultBookingCalendar:r?.id}),e("nylas-custom-event-slug",{name:"custom-event-slug",exportparts:"nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield"}),e("nylas-additional-participants",{name:"participants",eventParticipants:[{name:n?.name||n?.email,email:n?.email||"",is_organizer:true}],exportparts:"nadtnlpart, nadtnlpart__title, nadtnlpart__subtitle, nadtnlpart__content, nadtnlpart__input_group, nadtnlpart__input_wrapper, nadtnlpart__input, nadtnlpart__remove-participant"}))}case m.group:{return e(t,null,e("nylas-event-info",null,e("div",{slot:"inputs"},e("nylas-event-title",{noTemplates:true}),e("nylas-event-description",{noTemplates:true,hideAutoPopulateButton:true}),e("nylas-event-location",{userProvider:n.provider}),e("nylas-event-timeslot",{name:"event-timeslot"}),e("nylas-event-capacity",null))),e("nylas-booking-calendar-picker",{exportparts:"nbcp, nbcp__header, nbcp__dropdown, nbcp__dropdown-button, nbcp__dropdown-content",expressFlow:true,calendars:i,currentUser:n,defaultBookingCalendar:r?.id}),e("nylas-additional-participants",{name:"participants",eventParticipants:[{name:n?.name||n?.email,email:n?.email||"",is_organizer:true}],exportparts:"nadtnlpart, nadtnlpart__title, nadtnlpart__subtitle, nadtnlpart__content, nadtnlpart__input_group, nadtnlpart__input_wrapper, nadtnlpart__input, nadtnlpart__remove-participant"}),e("nylas-page-name",{requirePageName:true,pageName:"Group events page"}),e("nylas-custom-event-slug",{name:"custom-event-slug",exportparts:"nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield"}))}}}const ye=':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 0px 6px -2px rgba(0, 0, 0, 0.05), 0px 5px 15px -3px rgba(0, 0, 0, 0.1);--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-50:#ffeae8;--nylas-error-100:#ffc5bf;--nylas-error-200:#fecaca;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff}:host nylas-notification{position:absolute;top:0;right:0}@media screen and (max-width: 768px){:host{width:-moz-available;width:-webkit-fill-available;width:fill-available;min-width:325px}}div.scheduler-editor-content{height:800px}@media screen and (max-width: 768px){div.scheduler-editor-content{height:auto}}div.scheduler-editor-content slot[name=login-required]{height:inherit}div.scheduler-editor-content--group{height:800px}@media screen and (max-width: 768px){div.scheduler-editor-content--group{height:auto}}div.scheduler-editor-header{display:grid;grid-template-columns:1fr auto auto;align-items:center;justify-content:space-between;padding:1rem;border-bottom:1px solid var(--nylas-base-200);color:var(--nylas-base-900);min-width:924px}@media screen and (max-width: 768px){div.scheduler-editor-header{width:auto;min-width:calc(325px - 1rem)}}div.scheduler-editor-header h1.scheduler-editor-title{display:flex;align-items:center;gap:0.5rem;margin:0;font-size:18px;line-height:24px;font-weight:600}div.scheduler-editor-header button{background:transparent;border:none;cursor:pointer;color:var(--nylas-base-900)}div.scheduler-editor-header button:hover,div.scheduler-editor-header button:active{color:var(--nylas-primary);background-color:transparent}div.scheduler-editor-header button:disabled{cursor:not-allowed}div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-button){border:none;padding:4px;margin-right:8px}div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-button):hover{outline:none;color:var(--nylas-primary)}div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-content){min-width:132px}@media screen and (max-width: 768px){div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-content){width:-webkit-fill-available;width:fill-available;width:-moz-available}}nylas-select-event-type{height:inherit;width:calc(924px + 2rem)}@media screen and (max-width: 768px){nylas-select-event-type{width:auto}}nylas-editor-tabs,nylas-editor-tabs-group{width:auto;height:inherit}nylas-editor-tabs .row,nylas-editor-tabs-group .row{display:flex;gap:1rem}nylas-editor-tabs .composable,nylas-editor-tabs-group .composable{height:inherit;overflow:auto}nylas-editor-tabs nylas-event-info div[slot=inputs],nylas-editor-tabs nylas-event-limits div[slot=inputs],nylas-editor-tabs-group nylas-event-info div[slot=inputs],nylas-editor-tabs-group nylas-event-limits div[slot=inputs]{display:flex;flex-direction:column;gap:1rem}.card{display:flex;flex-direction:column;padding:2rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;color:var(--nylas-base-900);max-width:fit-content;align-self:center}.login-required{height:inherit;overflow-y:auto;display:flex;flex-direction:column;justify-content:center;padding:2rem 1rem;background-color:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}.login-required p{margin:0 0 1rem}.login-required .microsoft-button,.login-required .google-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:16px;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;margin-bottom:1rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;justify-content:center;gap:0.5rem;align-items:center;color:var(--nylas-base-900)}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:16px;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;border:0;background-color:var(--nylas-base-0);height:48px;margin-bottom:1rem;font-size:0.95rem;justify-content:center;gap:0.25rem;align-items:center;color:var(--nylas-base-900)}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button svg{transform:rotate(180deg)}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .disclaimer-text{font-size:0.75rem;color:var(--nylas-base-600);align-self:center}@media screen and (max-width: 768px){.login-required{height:auto}}.list-configurations{padding:2rem;height:inherit;background:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}.list-configurations nylas-list-configurations{height:inherit;display:flex;flex-direction:column}@media screen and (max-width: 768px){.list-configurations{height:auto;padding:2rem 1rem}}';const we=class{constructor(e){n(this,e);this.init=i(this,"init",7);this.loggedIn=i(this,"loggedIn",7);this.loggedOut=i(this,"loggedOut",7);this.schedulerConfigCloseClicked=i(this,"schedulerConfigCloseClicked",7);this.eventOverrides={};this.schedulerPreviewLink="";this.mode="app";this.hideEditorTabs=[];this.requiresSlug=false;this.enableUserFeedback=true;this.nylasBranding=true;this.enableNotetaker=false;this.enableEventTypes={one_on_one:true,collective:true,max_fairness:true,max_availability:true,group:true};this.automaticComponentRegistration=true;this.selectedLanguage=this.defaultLanguage||v.en;this.langVersion=0;this.version=w;this.handleSchedulerConfigCloseClicked=e=>{const t=this.schedulerConfigCloseClicked.emit(this.host);if("schedulerConfigCloseClicked"in this.eventOverrides){this.eventOverrides.schedulerConfigCloseClicked(t,this.nylasSchedulerConfigConnector)}if(!t.defaultPrevented){localStorage.removeItem("grant");localStorage.removeItem("user");window.location.reload()}};this.authenticationUrl=async e=>{if(!this.nylasApiRequest){p(`[nylas-scheduler-editor] Nylas API Request is not initialized.`);return""}const t=await this.nylasApiRequest.authenticationUrl({provider:e});return t||""}}connectedCallback(){d(`[nylas-scheduler-editor] connectedCallback`);queueMicrotask((()=>{if(this.themeConfig){this.applyThemeConfig(this.themeConfig);this.host.setAttribute("data-themed","")}}))}async componentWillLoad(){d(`[nylas-scheduler-editor] componentWillLoad`);const e=this.additionalParticipants?.filter((e=>{const t=e.calendars?.length>0?e.calendars.filter((e=>e.id&&e.name)):[];if(e.name&&e.email&&t.length>0){return{name:e.name,email:e.email,calendars:t}}}));this.stores={schedulerConfig:x({...this.defaultSchedulerConfigState,additionalParticipants:e,conferenceProviders:this.conferenceProviders,requiresSlug:this.requiresSlug,selectedLanguage:this.defaultLanguage||v.en,nylasBranding:this.nylasBranding,experimentalFeatures:this.experimentalFeatures,enableEventTypes:this.enableEventTypes,themeConfig:this.themeConfig})};if(!this.nylasApiRequest&&this.nylasSessionsConfig){const e=new ae(this.nylasSessionsConfig);await e.isLoggedIn();e.onLoginSuccess((async()=>{const e=await(this.nylasSchedulerConfigConnector?.schedulerConfig?.currentUser());if(e){const t=this.loggedIn.emit(this.host);if("loggedIn"in this.eventOverrides){await this.eventOverrides.loggedIn(t,this.nylasSchedulerConfigConnector)}if(!t.defaultPrevented){await this.loggedInHandler(e)}}}));e.onLoginFail((async()=>{this.stores?.schedulerConfig?.set("currentUser",null);const e=this.loggedOut.emit(this.host);if("loggedOut"in this.eventOverrides){await this.eventOverrides.loggedOut(e,this.nylasSchedulerConfigConnector);if(e.defaultPrevented){return}}}));this.nylasApiRequest=new a(e)}if(this.nylasApiRequest&&this.defaultAuthArgs){this.nylasApiRequest.setDefaultAuthArgs(this.defaultAuthArgs)}this.baseProvider=new o(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);const t=this.baseProvider.getStore("schedulerConfig");this.nylasSchedulerConfigConnector=new k({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:t});const n=this.init.emit(this.host);if("init"in this.eventOverrides){await this.eventOverrides.init(n,this.nylasSchedulerConfigConnector)}if(!n.defaultPrevented){const e=await(this.nylasSchedulerConfigConnector?.schedulerConfig?.currentUser());if(e){const t=this.loggedIn.emit(this.host);if("loggedIn"in this.eventOverrides){await this.eventOverrides.loggedIn(t,this.nylasSchedulerConfigConnector)}if(!t.defaultPrevented){await this.loggedInHandler(e)}}else{this.stores?.schedulerConfig?.set("currentUser",null);const e=this.loggedOut.emit(this.host);if("loggedOut"in this.eventOverrides){await this.eventOverrides.loggedOut(e,this.nylasSchedulerConfigConnector);if(e.defaultPrevented){return}}}}this.stores?.schedulerConfig?.onChange("selectedConfiguration",(async e=>{if(e&&e.id){this.configurationId=e.id}}));this.baseProvider?.componentWillLoad(this.nylasSchedulerConfigConnector);this.applyThemeConfig(this.themeConfig)}async componentDidLoad(){d(`[nylas-scheduler-editor] componentDidLoad`);await(this.baseProvider?.componentDidLoad());this.updateLocalization(this.localization);this.version=w}async componentDisconnected(){await(this.baseProvider?.componentDisconnected())}async configurationIdChanged(e){if(e){await(this.nylasSchedulerConfigConnector?.schedulerConfig?.getConfigurationById(e));this.stores?.schedulerConfig?.set("action","edit")}else{this.stores?.schedulerConfig?.set("selectedConfiguration",{});this.stores?.schedulerConfig?.set("action",null)}}updateLocalization(e){if(!e){return}Object.keys(e).forEach((t=>{if(!(t in v)){return}g.addResourceBundle(t,"translation",e[t],false,true)}));this.langVersion++}updateNylasBranding(e){this.stores?.schedulerConfig?.set("nylasBranding",e)}updateExperimentalFeatures(e){this.stores?.schedulerConfig?.set("experimentalFeatures",e)}updateEnableEventTypes(e){this.stores?.schedulerConfig?.set("enableEventTypes",e)}themeConfigChanged(e){this.baseProvider?.getStore("schedulerConfig")?.set("themeConfig",e);this.applyThemeConfig(e)}applyThemeConfig(e){if(e){for(const[t,n]of Object.entries(e)){this.host.style.setProperty(`${t}`,n)}}}async store(){return this.stores?.schedulerConfig}async schedulerConnector(){return this.nylasSchedulerConfigConnector}async registerComponentHandler(e){this.baseProvider?.registerComponent(e.detail)}async unregisterComponentHandler(e){this.baseProvider?.unregisterComponent(e.detail)}nylasFormDropdownChangedHandler(e){const{name:t,value:n}=e.detail;if(t==="language"){this.selectedLanguage=v[n];g.changeLanguage(this.selectedLanguage);this.stores?.schedulerConfig?.set("selectedLanguage",this.selectedLanguage)}}async loggedInHandler(e){this.stores?.schedulerConfig?.set("currentUser",e);if(!this.nylasSchedulerConfigConnector){return}await(this.nylasSchedulerConfigConnector.schedulerConfig?.getCalendars());if(this.configurationId){const e=await(this.nylasSchedulerConfigConnector.schedulerConfig?.getConfigurationById(this.configurationId));if(e&&e[0]?.id){this.stores?.schedulerConfig?.set("action","edit")}}}render(){const t=this.host.querySelector('[slot="custom-page-style-inputs"]');const n=this.stores?.schedulerConfig?.state.selectedConfiguration?.id;const i=Object.keys(_).map((e=>({label:_[e],value:e})));const r=this.stores?.schedulerConfig?.state.selectedEventType===m.group||this.stores?.schedulerConfig?.state.selectedConfiguration?.type===m.group;d(`[nylas-scheduler-editor] render mode: ${this.mode}`);return e(s,{key:"e37a7571ffe7059afb5e93f1cca2c024921af54b"},e("div",{key:"db5aeb93fe047834ca08c081e8b60d795a2c8f58",class:"scheduler-editor-header",part:"nse__header"},e("h1",{key:"791b19e3332afe4c9115fcab4bf015075b75fc15",class:"scheduler-editor-title",part:"nse__title"},e("calendar-icon",{key:"c3d2d9a0425636707e11bd0292404454b19d4044",width:"18",height:"18"}),g.t("schedulerEditorTitle"),e("tooltip-component",{key:"32d9bfdd5bd963beaee18ed0c48d148601cad216"},e("info-icon",{key:"0a0a30a5338c8f921012c9b8ac88a2189d5a36d6",slot:"tooltip-icon"}),e("span",{key:"1911350bbae0f9f0882ccb345c71781574d6c712",slot:"tooltip-content"},this.version))),e("div",{key:"58f5c778f07a8ff850fb07d2710b94e3a774ae32",class:{language:true},part:"nse__language"},e("select-dropdown",{key:"dbdab8e8f804aed103cf35729d9b658b17ebf3b2",name:"language",searchPlaceholder:g.t("search"),options:i,withChevron:false,themeConfig:this.themeConfig,defaultSelectedOption:i.find((e=>e.value==this.selectedLanguage)),exportparts:"sd_dropdown: nse__language-dropdown, sd_dropdown-button: nse__language-drop-button, sd_dropdown-content: nse__language-drop-content, sd_dropdown_label: nse__language-drop-label"},e("span",{key:"3fb225a7f41b29ef9cce3b358a5aa608066979af",slot:"select-icon"},e("translate-icon",{key:"f7b625277108767d6522180f4107cc1d7399c0e6",width:"20",height:"20"})))),e("button",{key:"376cbc21a8821ac38eb73043dbf9ae8474158371",class:"scheduler-editor-close",title:"logout",onClick:e=>this.handleSchedulerConfigCloseClicked(e),part:"nse__close-button"},e("close-icon",{key:"637eb1d8e03cd45172c7c113800cce0c7cf70cf3",width:"18",height:"18"}))),e("div",{key:"83239494ea1d4efcdb246abd4e9fb14672f78708",class:{"scheduler-editor-content":true,"scheduler-editor-content--group":r},part:"nse__content"},this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action===null&&e("div",{key:"643485cb3f09c40519259e9b0e4064484854edec",class:"list-configurations",part:"nse__list-configurations"},e("nylas-list-configurations",{key:"e0ad49a6e3c61faf5daefcf0a5dc0025056f7d0c",themeConfig:this.themeConfig,exportparts:"nlc__create-new-cta, actions__dropdown, actions__dropdown-button, actions__dropdown-content, actions-Copy, actions-Preview, actions-Delete"})),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="create-select"&&e("nylas-select-event-type",{key:"f28c8ed3d230491b1e0046df33574034bcd857b9",themeConfig:this.themeConfig}),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="create"&&r&&e("nylas-editor-tabs-group",{key:"fcf0896b06e51d28ccd1dba4fbffae98725d3f24",mode:"composable",themeConfig:this.themeConfig},e(ge,{key:"df9c1a25f521d373a80de410066beff0911cffe3",selectedEventType:this.stores?.schedulerConfig?.state?.selectedEventType||m.one_on_one,currentUser:this.stores?.schedulerConfig?.state.currentUser,calendars:this.stores?.schedulerConfig?.state?.calendars,selectedConfiguration:this.stores?.schedulerConfig?.state?.selectedConfiguration})),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="create"&&!r&&e("nylas-editor-tabs",{key:"a9ec4ff97b427a4362b014a478aaf28e7d04b69e",mode:"composable",enableNotetaker:this.enableNotetaker,themeConfig:this.themeConfig},e(ge,{key:"404caffc73cc2ebd5dda111f80fd0648224a372f",selectedEventType:this.stores?.schedulerConfig?.state?.selectedEventType||m.one_on_one,currentUser:this.stores?.schedulerConfig?.state.currentUser,calendars:this.stores?.schedulerConfig?.state?.calendars,selectedConfiguration:this.stores?.schedulerConfig?.state?.selectedConfiguration})),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="edit"&&r&&e("nylas-editor-tabs-group",{key:n,mode:this.mode,themeConfig:this.themeConfig},this.mode==="composable"&&e("slot",{key:"05baa8d7dbe663e237ae2579a12a4ac4bd466626"}),this.mode==="app"&&t&&e("div",{style:{display:"none"},slot:"custom-page-style-inputs",key:n},e("slot",{key:"1235b21d00db6d268f4f5767b4de288ecc891094",name:"custom-page-style-inputs"}))),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="edit"&&!r&&e("nylas-editor-tabs",{key:n,mode:this.mode,enableNotetaker:this.enableNotetaker,themeConfig:this.themeConfig},this.mode==="composable"&&e("slot",{key:"f58a18cb12fb723ef52199a5566d4cae06810c5e"}),this.mode==="app"&&t&&e("div",{style:{display:"none"},slot:"custom-page-style-inputs",key:n},e("slot",{key:"2e19ad87225bcbae1dc70079e8511a35607fe60d",name:"custom-page-style-inputs"}))),!this.stores?.schedulerConfig?.state.currentUser&&e("slot",{key:"c7f1283c363e365f7570dd5c84ec8abc3c974b48",name:"login-required"},e(pe,{key:"f16d4489fc8fbf9d452e117e85bc88ec3ecce321",authenticationUrl:this.authenticationUrl}))))}get host(){return r(this)}static get watchers(){return{configurationId:["configurationIdChanged"],localization:["updateLocalization"],nylasBranding:["updateNylasBranding"],experimentalFeatures:["updateExperimentalFeatures"],enableEventTypes:["updateEnableEventTypes"],themeConfig:["themeConfigChanged"]}}};we.style=ye;export{we as nylas_scheduler_editor};
|
|
11
|
-
//# sourceMappingURL=p-
|
|
11
|
+
//# sourceMappingURL=p-4dc6d0dc.entry.js.map
|