@nylas/react 1.1.0-canary.20 → 1.1.0-canary.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/dist/add-circle-icon_2.entry-404b178a.js +69 -0
  2. package/dist/add-circle-icon_2.entry-d44a0d4b.cjs +1 -0
  3. package/dist/archive-icon_7.entry-1c2e5b68.cjs +1 -0
  4. package/dist/{archive-icon_7.entry-2f418a3e.js → archive-icon_7.entry-d14abebc.js} +21 -21
  5. package/dist/{arrow-icon.entry-ac5e1a47.cjs → arrow-icon.entry-61290104.cjs} +1 -1
  6. package/dist/arrow-icon.entry-8dd5bfb5.js +15 -0
  7. package/dist/{bold-icon_3.entry-4fff7400.cjs → bold-icon_3.entry-c5502b92.cjs} +1 -1
  8. package/dist/{bold-icon_3.entry-18507c82.js → bold-icon_3.entry-cc7319da.js} +4 -4
  9. package/dist/button-component.entry-71de5b6b.js +16 -0
  10. package/dist/button-component.entry-92c46833.cjs +1 -0
  11. package/dist/calendar-agenda-fill-icon_40.entry-242956c2.cjs +10 -0
  12. package/dist/{calendar-agenda-fill-icon_35.entry-db989ce0.js → calendar-agenda-fill-icon_40.entry-b33080d8.js} +1461 -1068
  13. package/dist/{calendar-cancel-icon.entry-d2e10dfc.cjs → calendar-cancel-icon.entry-bbf56125.cjs} +1 -1
  14. package/dist/{calendar-cancel-icon.entry-31caeae1.js → calendar-cancel-icon.entry-fcc89777.js} +2 -2
  15. package/dist/{calendar-check-icon_2.entry-d32551e9.cjs → calendar-check-icon_2.entry-64d553de.cjs} +1 -1
  16. package/dist/{calendar-check-icon_2.entry-7f67c003.js → calendar-check-icon_2.entry-e7691b84.js} +5 -5
  17. package/dist/{calendar-icon.entry-6e89816b.js → calendar-icon.entry-6375e3ed.js} +4 -4
  18. package/dist/{calendar-icon.entry-f3f1c623.cjs → calendar-icon.entry-9cea89bc.cjs} +1 -1
  19. package/dist/checkbox-component_2.entry-751f4638.js +56 -0
  20. package/dist/checkbox-component_2.entry-9a89cf14.cjs +1 -0
  21. package/dist/checkmark-icon.entry-136b682c.js +15 -0
  22. package/dist/checkmark-icon.entry-6bca8604.cjs +1 -0
  23. package/dist/{chevron-icon_3.entry-3be68846.cjs → chevron-icon_3.entry-97c91007.cjs} +1 -1
  24. package/dist/{chevron-icon_3.entry-2e20a83e.js → chevron-icon_3.entry-b4995425.js} +7 -7
  25. package/dist/clock-icon_4.entry-cd6ac47d.cjs +1 -0
  26. package/dist/clock-icon_4.entry-d2e007e5.js +45 -0
  27. package/dist/close-icon.entry-d1348fa8.cjs +1 -0
  28. package/dist/close-icon.entry-d4d4da48.js +15 -0
  29. package/dist/{constants-7ce66b44-3952e81c.js → constants-67de2eec-31cbc722.js} +37 -17
  30. package/dist/{constants-7ce66b44-a6b777d4.cjs → constants-67de2eec-8286f29c.cjs} +5 -5
  31. package/dist/{copy-icon_4.entry-187edab9.js → copy-icon_3.entry-e41eb1a0.js} +9 -19
  32. package/dist/copy-icon_3.entry-f614fc20.cjs +1 -0
  33. package/dist/{document-refresh-icon.entry-ea0e1ab9.cjs → document-refresh-icon.entry-12833775.cjs} +1 -1
  34. package/dist/{document-refresh-icon.entry-9d7900d7.js → document-refresh-icon.entry-817322ba.js} +5 -5
  35. package/dist/elements/index.d.ts +8 -0
  36. package/dist/{elements-dc5b338e-edf63aa6.cjs → elements-dc5b338e-3a8522b8.cjs} +1 -1
  37. package/dist/{elements-dc5b338e-e6271e48.js → elements-dc5b338e-d885666f.js} +1 -1
  38. package/dist/{focus-visible-e8093c16-84e41b3b.cjs → focus-visible-e8093c16-17bb48f2.cjs} +1 -1
  39. package/dist/{focus-visible-e8093c16-4c45967c.js → focus-visible-e8093c16-78717e30.js} +1 -1
  40. package/dist/{forward-icon_6.entry-4cb6eb63.cjs → forward-icon_6.entry-074fd345.cjs} +2 -2
  41. package/dist/{forward-icon_6.entry-949d0cfb.js → forward-icon_6.entry-39b55b30.js} +9 -9
  42. package/dist/{globe-icon.entry-04b35395.js → globe-icon.entry-a1875d7e.js} +2 -2
  43. package/dist/{globe-icon.entry-741f8ad4.cjs → globe-icon.entry-dee4c2b0.cjs} +1 -1
  44. package/dist/google-logo-icon_4.entry-3c3101ea.js +637 -0
  45. package/dist/google-logo-icon_4.entry-44c3f539.cjs +1 -0
  46. package/dist/index-26f8bbeb.cjs +42 -0
  47. package/dist/index-53420959-a444c1cf.cjs +1 -0
  48. package/dist/index-53420959-b26d1293.js +5 -0
  49. package/dist/index-5da0aff3.js +7638 -0
  50. package/dist/{index-6d9eeb53-8b16e3b5.cjs → index-6d9eeb53-b71b16c5.cjs} +1 -1
  51. package/dist/{index-6d9eeb53-b15263de.js → index-6d9eeb53-f37ff819.js} +2 -2
  52. package/dist/{index.es-9cc0eb3c-2e0f7d11.cjs → index.es-b16d0cf5-4ce1fb63.cjs} +1 -1
  53. package/dist/{index.es-9cc0eb3c-e6c5dd2d.js → index.es-b16d0cf5-b1cecbdd.js} +1 -1
  54. package/dist/{info-icon_2.entry-c3468951.cjs → info-icon_2.entry-67a3e2c3.cjs} +1 -1
  55. package/dist/{info-icon_2.entry-d0270899.js → info-icon_2.entry-6fd10047.js} +7 -7
  56. package/dist/input-dropdown.entry-701ab8b7.cjs +1 -0
  57. package/dist/input-dropdown.entry-e677224a.js +132 -0
  58. package/dist/{loading-icon.entry-96d9d1be.js → loading-icon.entry-3f54b204.js} +4 -4
  59. package/dist/loading-icon.entry-558c2382.cjs +1 -0
  60. package/dist/{mailbox-store-64b4ef7c-7c793d9a.js → mailbox-store-f11de360-79ba75b1.js} +2 -2
  61. package/dist/{mailbox-store-64b4ef7c-c609ac6d.cjs → mailbox-store-f11de360-8f269e26.cjs} +1 -1
  62. package/dist/{multi-select-dropdown.entry-f298ca2c.cjs → multi-select-dropdown.entry-d053b2fb.cjs} +1 -1
  63. package/dist/{multi-select-dropdown.entry-2ca73c71.js → multi-select-dropdown.entry-e46f5cfb.js} +2 -2
  64. package/dist/nylas-booked-event-card_10.entry-32911b16.cjs +1 -0
  65. package/dist/{nylas-booked-event-card_10.entry-2b01df7e.js → nylas-booked-event-card_10.entry-545261f6.js} +364 -323
  66. package/dist/{nylas-custom-booking-flow.entry-05b9522a.cjs → nylas-custom-booking-flow.entry-49b82a11.cjs} +1 -1
  67. package/dist/{nylas-custom-booking-flow.entry-66beff43.js → nylas-custom-booking-flow.entry-6639c5fb.js} +31 -31
  68. package/dist/{nylas-form-card.entry-3de9f477.js → nylas-form-card.entry-7d69820f.js} +18 -18
  69. package/dist/{nylas-form-card.entry-3e1331c9.cjs → nylas-form-card.entry-a063402d.cjs} +1 -1
  70. package/dist/{nylas-if-state.entry-a734df46.cjs → nylas-if-state.entry-54a6948f.cjs} +1 -1
  71. package/dist/{nylas-if-state.entry-a0689083.js → nylas-if-state.entry-9e7df799.js} +3 -3
  72. package/dist/{nylas-list-folders.entry-4fb9d4c2.js → nylas-list-folders.entry-013ffceb.js} +4 -4
  73. package/dist/{nylas-list-folders.entry-74a56187.cjs → nylas-list-folders.entry-d08423d4.cjs} +1 -1
  74. package/dist/{nylas-list-threads.entry-0addc621.cjs → nylas-list-threads.entry-be9bc422.cjs} +1 -1
  75. package/dist/{nylas-list-threads.entry-9a6d4c33.js → nylas-list-threads.entry-d3f575a5.js} +3 -3
  76. package/dist/{nylas-login.entry-beb6e0d9.js → nylas-login.entry-d82e8ee0.js} +3 -3
  77. package/dist/{nylas-login.entry-bdac29c0.cjs → nylas-login.entry-e7015d8f.cjs} +1 -1
  78. package/dist/{nylas-mailbox-pagination.entry-c5d07bbe.cjs → nylas-mailbox-pagination.entry-22866764.cjs} +1 -1
  79. package/dist/{nylas-mailbox-pagination.entry-1d71850a.js → nylas-mailbox-pagination.entry-99339476.js} +2 -2
  80. package/dist/{nylas-mailbox-toolbar-button.entry-7d9d6293.cjs → nylas-mailbox-toolbar-button.entry-09faed21.cjs} +1 -1
  81. package/dist/{nylas-mailbox-toolbar-button.entry-882c97a0.js → nylas-mailbox-toolbar-button.entry-b8929b00.js} +7 -7
  82. package/dist/{nylas-mailbox.entry-d810adba.js → nylas-mailbox.entry-6e8d4f9c.js} +4 -4
  83. package/dist/{nylas-mailbox.entry-94eb97ec.cjs → nylas-mailbox.entry-91ca6af1.cjs} +1 -1
  84. package/dist/{nylas-provider.entry-5a4bb86e.cjs → nylas-provider.entry-b80d5e74.cjs} +1 -1
  85. package/dist/{nylas-provider.entry-fcaf9e1c.js → nylas-provider.entry-cc32369c.js} +34 -34
  86. package/dist/{nylas-scheduler-editor.entry-1ca566d3.js → nylas-scheduler-editor.entry-5e0475d8.js} +8 -11
  87. package/dist/{nylas-scheduler-editor.entry-30597812.cjs → nylas-scheduler-editor.entry-c7f7bf6c.cjs} +2 -2
  88. package/dist/nylas-scheduling.entry-047cd53a.cjs +1 -0
  89. package/dist/{nylas-scheduling.entry-aefefe3d.js → nylas-scheduling.entry-c79596db.js} +82 -73
  90. package/dist/{nylas-threads-refresh.entry-a85222e2.js → nylas-threads-refresh.entry-e200efb9.js} +4 -4
  91. package/dist/{nylas-threads-refresh.entry-f3b9fdf2.cjs → nylas-threads-refresh.entry-ef2ad409.cjs} +1 -1
  92. package/dist/{nylas-threads-search.entry-b1bf455b.js → nylas-threads-search.entry-85a0bc7d.js} +6 -6
  93. package/dist/{nylas-threads-search.entry-2c8ac7dc.cjs → nylas-threads-search.entry-a260ce6f.cjs} +1 -1
  94. package/dist/{nylas-time-window-picker.entry-6d664a05.js → nylas-time-window-picker.entry-c9b2a7ca.js} +18 -18
  95. package/dist/{nylas-time-window-picker.entry-3a34b29b.cjs → nylas-time-window-picker.entry-cb33b696.cjs} +1 -1
  96. package/dist/{nylas-view-thread.entry-bf6cab2a.cjs → nylas-view-thread.entry-219511ac.cjs} +1 -1
  97. package/dist/{nylas-view-thread.entry-ddcb042f.js → nylas-view-thread.entry-f302c441.js} +6 -6
  98. package/dist/person-icon.entry-6b20ac42.cjs +1 -0
  99. package/dist/person-icon.entry-8f8b928f.js +15 -0
  100. package/dist/play-icon_2.entry-3aa92414.js +25 -0
  101. package/dist/play-icon_2.entry-c8114634.cjs +1 -0
  102. package/dist/react.cjs +1 -1
  103. package/dist/react.js +116 -108
  104. package/dist/{refresh-icon.entry-0fdcb7af.js → refresh-icon.entry-0d80c9c5.js} +2 -2
  105. package/dist/{refresh-icon.entry-99761cb6.cjs → refresh-icon.entry-de5001c7.cjs} +1 -1
  106. package/dist/{register-component-a5a9ca5d-4439e573.cjs → register-component-b2a51b20-09664950.cjs} +1 -1
  107. package/dist/{register-component-a5a9ca5d-ddae10b3.js → register-component-b2a51b20-ea46761a.js} +1 -1
  108. package/dist/{scheduler-config-store-9ccfba4d-84025740.js → scheduler-config-store-9ccfba4d-92cb99d1.js} +1 -1
  109. package/dist/{scheduler-config-store-9ccfba4d-b774bfee.cjs → scheduler-config-store-9ccfba4d-a677e77b.cjs} +1 -1
  110. package/dist/scheduler-store-db06b30a-08429fc9.cjs +1 -0
  111. package/dist/{scheduler-store-8a400448-8ab7b63e.js → scheduler-store-db06b30a-cee61c58.js} +119 -116
  112. package/dist/{textarea-component.entry-359e4665.cjs → textarea-component.entry-670f72a7.cjs} +1 -1
  113. package/dist/{textarea-component.entry-193d29fd.js → textarea-component.entry-c2d1900c.js} +4 -4
  114. package/dist/time-period-selector.entry-3ccfc000.cjs +1 -0
  115. package/dist/time-period-selector.entry-a03b1ce1.js +93 -0
  116. package/dist/{translate-icon.entry-22a3e72e.js → translate-icon.entry-8a2878ba.js} +4 -4
  117. package/dist/{translate-icon.entry-32ec36de.cjs → translate-icon.entry-b483f6b3.cjs} +1 -1
  118. package/dist/{warning-icon.entry-8d9b59c0.js → warning-icon.entry-68b3f25e.js} +5 -5
  119. package/dist/{warning-icon.entry-b8d483e1.cjs → warning-icon.entry-784f7818.cjs} +1 -1
  120. package/package.json +3 -3
  121. package/dist/add-circle-icon_2.entry-5cefae99.js +0 -25
  122. package/dist/add-circle-icon_2.entry-85523420.cjs +0 -1
  123. package/dist/archive-icon_7.entry-eb90a353.cjs +0 -1
  124. package/dist/arrow-icon.entry-753eb942.js +0 -15
  125. package/dist/button-component_4.entry-3c508e3b.js +0 -115
  126. package/dist/button-component_4.entry-f8ab53dc.cjs +0 -1
  127. package/dist/calendar-agenda-fill-icon_35.entry-b56841a0.cjs +0 -7
  128. package/dist/clock-icon_2.entry-074eb053.cjs +0 -1
  129. package/dist/clock-icon_2.entry-bc938936.js +0 -25
  130. package/dist/copy-icon_4.entry-f704b2f1.cjs +0 -1
  131. package/dist/google-logo-icon_4.entry-8e87cf66.cjs +0 -1
  132. package/dist/google-logo-icon_4.entry-f50de25f.js +0 -598
  133. package/dist/index-53420959-507f0a27.js +0 -5
  134. package/dist/index-53420959-e6c2e510.cjs +0 -1
  135. package/dist/index-a4831dfe.cjs +0 -42
  136. package/dist/index-a68236be.js +0 -5011
  137. package/dist/input-dropdown_2.entry-2485dcc3.cjs +0 -1
  138. package/dist/input-dropdown_2.entry-2cd6cfc7.js +0 -220
  139. package/dist/loading-icon.entry-5ed52afe.cjs +0 -1
  140. package/dist/nylas-booked-event-card_10.entry-97977ac7.cjs +0 -1
  141. package/dist/nylas-scheduling.entry-00c418c8.cjs +0 -1
  142. package/dist/play-icon_2.entry-4f316c3d.cjs +0 -1
  143. package/dist/play-icon_2.entry-d55a018a.js +0 -25
  144. package/dist/scheduler-store-8a400448-eaa566fa.cjs +0 -1
@@ -0,0 +1 @@
1
+ "use strict";const c=require("./index-26f8bbeb.cjs");exports.ErrorCategory=void 0;(function(a){a.Component="component",a.Api="api",a.Auth="auth"})(exports.ErrorCategory||(exports.ErrorCategory={}));var D;(function(a){a.endtime_not_in_future="endtime_not_in_future",a.no_booking_info="no_booking_info",a.no_timeslot_selected="no_timeslot_selected",a.no_timezone_selected="no_timezone_selected",a.no_booking_id="no_booking_id",a.invalid_start_time="invalid_start_time",a.invalid_end_time="invalid_end_time",a.invalid_timezone="invalid_timezone"})(D||(D={}));var E;(function(a){a.invalid_session="invalid_session",a.general_error="general_error",a.internal_error="internal_error",a.invalid_request_error="invalid_request_error",a.timeslot_not_available="timeslot_not_available",a.provider_error="provider_error",a.not_found_error="not_found_error"})(E||(E={}));class P{constructor(){this.component=e=>{const t=exports.ErrorCategory.Component,s=`${e} Error`;return{endtime_not_in_future:(i='"endtime" can not be in the future')=>({title:s,message:i,category:t}),no_booking_info:(i="No booking info provided")=>({title:s,message:i,category:t}),no_timeslot_selected:(i="No timeslot selected")=>({title:s,message:i,category:t}),no_timezone_selected:(i="No timezone selected")=>({title:s,message:i,category:t}),no_booking_id:(i="No booking id provided")=>({title:s,message:i,category:t}),invalid_start_time:(i="Invalid start time")=>({title:s,message:i,category:t}),invalid_end_time:(i="Invalid end time")=>({title:s,message:i,category:t}),invalid_timezone:(i="Invalid timezone")=>({title:s,message:i,category:t})}},this.api=e=>{const t=exports.ErrorCategory.Api,s=`${e} Error`;return{invalid_session:i=>({title:s,message:i,category:t}),general_error:i=>({title:s,message:i,category:t}),internal_error:i=>({title:s,message:i,category:t}),invalid_request_error:i=>({title:s,message:i,category:t}),timeslot_not_available:i=>({title:s,message:i,category:t}),provider_error:i=>({title:s,message:i,category:t}),not_found_error:i=>({title:s,message:i,category:t})}}}}class M{constructor({schedulerAPIURL:e,schedulerStore:t,sessionId:s,configId:i}){this.errors=new P,this.schedulerStore=t,this.schedulerAPIURL=e,this.sessionId=s,this.configId=i}getHeaders(){return this.sessionId?{Authorization:`Bearer ${this.sessionId}`}:{}}async makeAPIRequest(e,t,s,i={}){try{const r=new URL(this.schedulerAPIURL);return r.pathname=e,await(await fetch(decodeURIComponent(r.toString()),{method:t,headers:{"Content-Type":"application/json",Origin:window.location.origin,...i},body:s})).json()}catch(r){return{error:{message:r.message,title:"API request failed",type:"api"}}}}getErrorMessage(e){var s,i,r,n;let t=(e==null?void 0:e.message)||(e==null?void 0:e.title)||"Something went wrong";return(e==null?void 0:e.type)==="provider_error"&&(t=((i=(s=e==null?void 0:e.provider_error)==null?void 0:s.error)==null?void 0:i.message)||((n=(r=e==null?void 0:e.provider_error)==null?void 0:r.error)==null?void 0:n.title)||"Something went wrong"),t}setConfigId(e){this.configId=e}selectDate(e){this.schedulerStore.set("selectedDate",e),this.schedulerStore.set("selectedTimeslot",null)}selectTime(e){this.schedulerStore.set("selectedTimeslot",e)}selectTimezone(e){this.schedulerStore.set("selectedTimezone",e)}selectLanguage(e){this.schedulerStore.set("selectedLanguage",e),c.instance.changeLanguage(e)}async toggleAdditionalData(e){e||await this.refetchAvailability(),this.schedulerStore.set("showBookingForm",e)}setParticipantName(e){const{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...t==null?void 0:t.primaryParticipant,name:e}})}setParticipantEmail(e){const{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...t==null?void 0:t.primaryParticipant,email:e}})}async refetchAvailability(){const e=new Date,t=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3,s=t<e.getTime()/1e3?Math.floor(e.getTime()/1e3):t,i=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3;return await this.getAvailability(s,i)}async resetStoreStateAndFetchAvailability(){const e=new Date,t=await this.refetchAvailability(),s=this.schedulerStore.get("availability").find(r=>new Date(r.start_time)>new Date);let i=e;return s&&(i=s.start_time),this.schedulerStore.set("selectedDate",i),this.schedulerStore.set("eventInfo",null),this.schedulerStore.set("showBookingForm",!1),this.schedulerStore.set("selectedTimeslot",null),t}async setReschedule(e){this.schedulerStore.set("isLoading",!0);const t=this.schedulerStore.state.eventInfo;return t&&this.schedulerStore.set("reschedulingEventInfo",t),this.schedulerStore.set("rescheduleBookingId",e),await this.resetStoreStateAndFetchAvailability().finally(()=>{this.schedulerStore.set("isLoading",!1)})}async setCancel(e){this.schedulerStore.set("cancelBookingId",e)}async resetCancel(){const e=await this.resetStoreStateAndFetchAvailability();return this.schedulerStore.set("cancelBookingId",""),this.schedulerStore.set("cancelledEventInfo",null),e}async bookTimeslot(e){var m;this.schedulerStore.set("isLoading",!0);const{selectedTimeslot:t,selectedTimezone:s,bookingInfo:i}=this.schedulerStore.state;if(!e&&!i)return{error:this.errors.component(c.instance.t("createBookingErrorTitle")).no_booking_info()};const r=(e==null?void 0:e.timeslot)||t;if(!r)return{error:this.errors.component(c.instance.t("createBookingErrorTitle")).no_timeslot_selected()};const n=e&&(e!=null&&e.timezone)?e==null?void 0:e.timezone:s;if(!n)return{error:this.errors.component(c.instance.t("createBookingErrorTitle")).no_timezone_selected()};const o=this.schedulerStore.get("availabilityOrderEmails");let u="";if(o.length>0){const g=r.emails;for(let d=0;d<o.length;d++)if(g.includes(o[d])){u=o[d];break}}const _=e?e==null?void 0:e.primaryParticipant:i==null?void 0:i.primaryParticipant,h=e?(e==null?void 0:e.guests)||[]:(i==null?void 0:i.guests)||[],y=e?e==null?void 0:e.additionalFields:i==null?void 0:i.additionalFields,I=this.getHeaders(),S=`/v3/scheduling/bookings${!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:""}`,l=await this.makeAPIRequest(decodeURIComponent(S),"POST",JSON.stringify({participants:u?[{email:u}]:void 0,additional_fields:y,additional_guests:h,guest:{..._},start_time:r.start_time.getTime()/1e3,end_time:r.end_time.getTime()/1e3,timezone:n}),I);if("error"in l){this.schedulerStore.set("isLoading",!1);const g=(m=l.error)==null?void 0:m.type;let d=l.error;if(g&&g in this.errors.api("Create Booking")){const T=this.getErrorMessage(d);d=this.errors.api("Create Booking")[g](T)}return{error:d}}return"data"in l&&this.schedulerStore.set("eventInfo",l==null?void 0:l.data),this.schedulerStore.set("isLoading",!1),l}async getUISettings(){var r;this.schedulerStore.set("isLoading",!0);const e=this.getHeaders(),s=`/v3/scheduling/ui-settings${!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:""}`,i=await this.makeAPIRequest(s,"GET",void 0,e);if("error"in i){this.schedulerStore.set("isLoading",!1);const n=(r=i.error)==null?void 0:r.type;let o=i.error;return n&&n in this.errors.api(c.instance.t("getUISettingErrorTitle"))&&(o=this.errors.api(c.instance.t("getUISettingErrorTitle"))[n]((o==null?void 0:o.message)||(o==null?void 0:o.title)||"Something went wrong")),{error:o}}return"data"in i&&this.schedulerStore.set("configSettings",i.data),this.schedulerStore.set("isLoading",!1),i}getStartTimeWithMinBookingNotice(e){var i;const t=(i=this.schedulerStore.get("configSettings"))==null?void 0:i.scheduler,s=t==null?void 0:t.min_booking_notice;return s?e+s*60:e}getEndTimeForAvailableDaysInFuture(e){var n,o;const t=new Date,s=(o=(n=this.schedulerStore.get("configSettings"))==null?void 0:n.scheduler)==null?void 0:o.available_days_in_future,i=Math.floor(c.addDaysToCurrentDate(t,s).getTime()/1e3);return Math.min(i,e)}async getAvailability(e=0,t=0){var y,I,f,S;this.schedulerStore.set("isLoading",!0);const s=new URLSearchParams,i=new Date,r=i.getTime();if(t&&t<r/1e3)return this.schedulerStore.set("isLoading",!1),{error:this.errors.component(c.instance.t("getAvailabilityErrorTitle")).endtime_not_in_future()};if(!e){const l=new Date(i.getFullYear(),i.getMonth(),1);e=Math.floor(l.getTime()/1e3)}if(e=this.getStartTimeWithMinBookingNotice(e),!t){const l=new Date(i.getFullYear(),i.getMonth()+1,0);t=Math.floor(l.getTime()/1e3)}t=this.getEndTimeForAvailableDaysInFuture(t),s.append("start_time",encodeURIComponent(e.toString())),s.append("end_time",encodeURIComponent(t.toString())),this.configId&&!this.sessionId&&s.append("configuration_id",encodeURIComponent(this.configId));const n=this.schedulerStore.get("rescheduleBookingId");n&&s.append("booking_id",encodeURIComponent(n));const o=s.toString(),u=`/v3/scheduling/availability${o?`?${o}`:""}`,_=this.getHeaders(),h=await this.makeAPIRequest(decodeURIComponent(u),"GET",void 0,_);if("error"in h){this.schedulerStore.set("availability",[]),this.schedulerStore.set("isLoading",!1);const l=(y=h.error)==null?void 0:y.type;let m=h.error;if(l&&l in this.errors.api(c.instance.t("getAvailabilityErrorTitle"))){const g=this.getErrorMessage(m);m=this.errors.api(c.instance.t("getAvailabilityErrorTitle"))[l](g)}return{error:m}}if("data"in h){const m=(((f=(I=h.data)==null?void 0:I.time_slots)==null?void 0:f.map(d=>({...d,start_time:new Date(d.start_time*1e3),end_time:new Date(d.end_time*1e3)})))||[]).filter(d=>d.start_time.getTime()>r);this.schedulerStore.set("availability",m);const g=((S=h.data)==null?void 0:S.order)||[];this.schedulerStore.set("availabilityOrderEmails",g)}return this.schedulerStore.set("isLoading",!1),h}async cancelBooking(e,t){var o;if(this.schedulerStore.set("isLoading",!0),!e)return{error:this.errors.component(c.instance.t("cancelBookingErrorTitle")).no_booking_id()};const s=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:"",i=`/v3/scheduling/bookings/${e}${s}`,r=this.getHeaders(),n=await this.makeAPIRequest(decodeURIComponent(i),"DELETE",JSON.stringify({action:"cancel",cancellation_reason:t}),r);if("error"in n){this.schedulerStore.set("isLoading",!1);const u=(o=n.error)==null?void 0:o.type;let _=n.error;if(u&&u in this.errors.api(c.instance.t("cancelBookingErrorTitle"))){const h=this.getErrorMessage(_);_=this.errors.api(c.instance.t("cancelBookingErrorTitle"))[u](h)}return{error:_}}return this.schedulerStore.set("cancelledEventInfo",{booking_id:e}),this.schedulerStore.set("rescheduleBookingId",""),this.schedulerStore.set("isLoading",!1),n}async rescheduleBooking(e,t){var w;if(this.schedulerStore.set("isLoading",!0),!e)return{error:this.errors.component(c.instance.t("rescheduleBookingErrorTitle")).no_booking_id()};const s=this.errors.api(c.instance.t("rescheduleBookingErrorTitle")),i=this.errors.component(c.instance.t("rescheduleBookingErrorTitle")),{bookingInfo:r,selectedTimeslot:n,selectedTimezone:o}=this.schedulerStore.state,{startTime:u,endTime:_,timezone:h}=t,y=u||(n==null?void 0:n.start_time);if(!y)return{error:i.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')};const I=_||(n==null?void 0:n.end_time);if(!I)return{error:i.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')};const f=this.schedulerStore.get("availabilityOrderEmails");let S="";if(f.length>0){const b=(n==null?void 0:n.emails)||[];for(let v=0;v<f.length;v++)if(b.includes(f[v])){S=f[v];break}}const l=h||o;if(!l)return{error:i.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.')};const m=t?t==null?void 0:t.primaryParticipant:r==null?void 0:r.primaryParticipant,g=t?(t==null?void 0:t.guests)||[]:(r==null?void 0:r.guests)||[],d=t?t==null?void 0:t.additionalFields:r==null?void 0:r.additionalFields,T=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:"",A=`/v3/scheduling/bookings/${e}${T}`,L=this.getHeaders(),p=await this.makeAPIRequest(decodeURIComponent(A),"PATCH",JSON.stringify({start_time:y.getTime()/1e3,end_time:I.getTime()/1e3,time_zone:l,additional_fields:d,guest:{...m},additional_guests:g,participants:S?[{email:S}]:void 0}),L);if("error"in p){this.schedulerStore.set("isLoading",!1);const b=(w=p.error)==null?void 0:w.type;let v=p.error;if(b&&b in s){const B=this.getErrorMessage(v);v=s[b](B)}return{error:v}}const k=this.schedulerStore.get("reschedulingEventInfo");if("data"in p)this.schedulerStore.set("eventInfo",p==null?void 0:p.data);else if(k)this.schedulerStore.set("eventInfo",k);else{const b={booking_id:e};this.schedulerStore.set("eventInfo",b)}return this.schedulerStore.set("isLoading",!1),p}}function z(a={}){const e={selectedDate:null,selectedLanguage:navigator.language,selectedTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTimeslot:null,showBookingForm:!1,availabilityOrderEmails:[],selectableDates:null,availability:[],eventDuration:0,state:"ready",eventInfo:null,cancelledEventInfo:null,isLoading:!1,nylasBranding:!0,...a};c.debug("[defaultNylasStoreState]: ",e);const t=c.createStore(e);return t.onChange("availability",s=>{c.debug("[availability]: ",s);const i=s.map(o=>o.start_time);c.debug("[selectableDates]: ",i),t.set("selectableDates",i);const r=s[0];if(!r)return;const n=Math.floor((r.end_time.getTime()-r.start_time.getTime())/6e4);c.debug("[durationMinutes]: ",n),t.set("eventDuration",n)}),t.reset=()=>{for(const s in e){const i=e[s];t.set(s,i)}},t}exports.CreateNylasSchedulerStore=z;exports.NylaSchedulerAPIConnector=M;
@@ -1,4 +1,4 @@
1
- import { d as b, e as z, l as R } from "./index-a68236be.js";
1
+ import { d as b, e as z, k as d, m as F } from "./index-5da0aff3.js";
2
2
  var k;
3
3
  (function(a) {
4
4
  a.Component = "component", a.Api = "api", a.Auth = "auth";
@@ -7,11 +7,11 @@ var A;
7
7
  (function(a) {
8
8
  a.endtime_not_in_future = "endtime_not_in_future", a.no_booking_info = "no_booking_info", a.no_timeslot_selected = "no_timeslot_selected", a.no_timezone_selected = "no_timezone_selected", a.no_booking_id = "no_booking_id", a.invalid_start_time = "invalid_start_time", a.invalid_end_time = "invalid_end_time", a.invalid_timezone = "invalid_timezone";
9
9
  })(A || (A = {}));
10
- var B;
10
+ var L;
11
11
  (function(a) {
12
12
  a.invalid_session = "invalid_session", a.general_error = "general_error", a.internal_error = "internal_error", a.invalid_request_error = "invalid_request_error", a.timeslot_not_available = "timeslot_not_available", a.provider_error = "provider_error", a.not_found_error = "not_found_error";
13
- })(B || (B = {}));
14
- class F {
13
+ })(L || (L = {}));
14
+ class R {
15
15
  constructor() {
16
16
  this.component = (e) => {
17
17
  const t = k.Component, s = `${e} Error`;
@@ -99,9 +99,9 @@ class F {
99
99
  };
100
100
  }
101
101
  }
102
- class U {
102
+ class C {
103
103
  constructor({ schedulerAPIURL: e, schedulerStore: t, sessionId: s, configId: i }) {
104
- this.errors = new F(), this.schedulerStore = t, this.schedulerAPIURL = e, this.sessionId = s, this.configId = i;
104
+ this.errors = new R(), this.schedulerStore = t, this.schedulerAPIURL = e, this.sessionId = s, this.configId = i;
105
105
  }
106
106
  getHeaders() {
107
107
  return this.sessionId ? {
@@ -110,8 +110,8 @@ class U {
110
110
  }
111
111
  async makeAPIRequest(e, t, s, i = {}) {
112
112
  try {
113
- const n = new URL(this.schedulerAPIURL);
114
- return n.pathname = e, await (await fetch(decodeURIComponent(n.toString()), {
113
+ const r = new URL(this.schedulerAPIURL);
114
+ return r.pathname = e, await (await fetch(decodeURIComponent(r.toString()), {
115
115
  method: t,
116
116
  headers: {
117
117
  "Content-Type": "application/json",
@@ -120,10 +120,10 @@ class U {
120
120
  },
121
121
  body: s
122
122
  })).json();
123
- } catch (n) {
123
+ } catch (r) {
124
124
  return {
125
125
  error: {
126
- message: n.message,
126
+ message: r.message,
127
127
  title: "API request failed",
128
128
  type: "api"
129
129
  }
@@ -131,9 +131,9 @@ class U {
131
131
  }
132
132
  }
133
133
  getErrorMessage(e) {
134
- var s, i, n, r;
134
+ var s, i, r, n;
135
135
  let t = (e == null ? void 0 : e.message) || (e == null ? void 0 : e.title) || "Something went wrong";
136
- return (e == null ? void 0 : e.type) === "provider_error" && (t = ((i = (s = e == null ? void 0 : e.provider_error) == null ? void 0 : s.error) == null ? void 0 : i.message) || ((r = (n = e == null ? void 0 : e.provider_error) == null ? void 0 : n.error) == null ? void 0 : r.title) || "Something went wrong"), t;
136
+ return (e == null ? void 0 : e.type) === "provider_error" && (t = ((i = (s = e == null ? void 0 : e.provider_error) == null ? void 0 : s.error) == null ? void 0 : i.message) || ((n = (r = e == null ? void 0 : e.provider_error) == null ? void 0 : r.error) == null ? void 0 : n.title) || "Something went wrong"), t;
137
137
  }
138
138
  setConfigId(e) {
139
139
  this.configId = e;
@@ -147,6 +147,9 @@ class U {
147
147
  selectTimezone(e) {
148
148
  this.schedulerStore.set("selectedTimezone", e);
149
149
  }
150
+ selectLanguage(e) {
151
+ this.schedulerStore.set("selectedLanguage", e), d.changeLanguage(e);
152
+ }
150
153
  async toggleAdditionalData(e) {
151
154
  e || await this.refetchAvailability(), this.schedulerStore.set("showBookingForm", e);
152
155
  }
@@ -175,7 +178,7 @@ class U {
175
178
  return await this.getAvailability(s, i);
176
179
  }
177
180
  async resetStoreStateAndFetchAvailability() {
178
- const e = /* @__PURE__ */ new Date(), t = await this.refetchAvailability(), s = this.schedulerStore.get("availability").find((n) => new Date(n.start_time) > /* @__PURE__ */ new Date());
181
+ const e = /* @__PURE__ */ new Date(), t = await this.refetchAvailability(), s = this.schedulerStore.get("availability").find((r) => new Date(r.start_time) > /* @__PURE__ */ new Date());
179
182
  let i = e;
180
183
  return s && (i = s.start_time), this.schedulerStore.set("selectedDate", i), this.schedulerStore.set("eventInfo", null), this.schedulerStore.set("showBookingForm", !1), this.schedulerStore.set("selectedTimeslot", null), t;
181
184
  }
@@ -194,57 +197,57 @@ class U {
194
197
  return this.schedulerStore.set("cancelBookingId", ""), this.schedulerStore.set("cancelledEventInfo", null), e;
195
198
  }
196
199
  async bookTimeslot(e) {
197
- var g;
200
+ var m;
198
201
  this.schedulerStore.set("isLoading", !0);
199
202
  const { selectedTimeslot: t, selectedTimezone: s, bookingInfo: i } = this.schedulerStore.state;
200
203
  if (!e && !i)
201
- return { error: this.errors.component("Booking").no_booking_info() };
202
- const n = (e == null ? void 0 : e.timeslot) || t;
203
- if (!n)
204
- return { error: this.errors.component("Create Booking").no_timeslot_selected() };
205
- const r = e && (e != null && e.timezone) ? e == null ? void 0 : e.timezone : s;
204
+ return { error: this.errors.component(d.t("createBookingErrorTitle")).no_booking_info() };
205
+ const r = (e == null ? void 0 : e.timeslot) || t;
206
206
  if (!r)
207
- return { error: this.errors.component("Create Booking").no_timezone_selected() };
207
+ return { error: this.errors.component(d.t("createBookingErrorTitle")).no_timeslot_selected() };
208
+ const n = e && (e != null && e.timezone) ? e == null ? void 0 : e.timezone : s;
209
+ if (!n)
210
+ return { error: this.errors.component(d.t("createBookingErrorTitle")).no_timezone_selected() };
208
211
  const o = this.schedulerStore.get("availabilityOrderEmails");
209
- let h = "";
212
+ let u = "";
210
213
  if (o.length > 0) {
211
- const u = n.emails;
214
+ const g = r.emails;
212
215
  for (let c = 0; c < o.length; c++)
213
- if (u.includes(o[c])) {
214
- h = o[c];
216
+ if (g.includes(o[c])) {
217
+ u = o[c];
215
218
  break;
216
219
  }
217
220
  }
218
- const m = e ? e == null ? void 0 : e.primaryParticipant : i == null ? void 0 : i.primaryParticipant, d = e ? (e == null ? void 0 : e.guests) || [] : (i == null ? void 0 : i.guests) || [], v = e ? e == null ? void 0 : e.additionalFields : i == null ? void 0 : i.additionalFields, y = this.getHeaders(), f = `/v3/scheduling/bookings${!this.sessionId && this.configId ? `?configuration_id=${this.configId}` : ""}`, l = await this.makeAPIRequest(decodeURIComponent(f), "POST", JSON.stringify({
219
- participants: h ? [{ email: h }] : void 0,
220
- additional_fields: v,
221
- additional_guests: d,
222
- guest: { ...m },
223
- start_time: n.start_time.getTime() / 1e3,
224
- end_time: n.end_time.getTime() / 1e3,
225
- timezone: r
226
- }), y);
221
+ const _ = e ? e == null ? void 0 : e.primaryParticipant : i == null ? void 0 : i.primaryParticipant, h = e ? (e == null ? void 0 : e.guests) || [] : (i == null ? void 0 : i.guests) || [], y = e ? e == null ? void 0 : e.additionalFields : i == null ? void 0 : i.additionalFields, I = this.getHeaders(), S = `/v3/scheduling/bookings${!this.sessionId && this.configId ? `?configuration_id=${this.configId}` : ""}`, l = await this.makeAPIRequest(decodeURIComponent(S), "POST", JSON.stringify({
222
+ participants: u ? [{ email: u }] : void 0,
223
+ additional_fields: y,
224
+ additional_guests: h,
225
+ guest: { ..._ },
226
+ start_time: r.start_time.getTime() / 1e3,
227
+ end_time: r.end_time.getTime() / 1e3,
228
+ timezone: n
229
+ }), I);
227
230
  if ("error" in l) {
228
231
  this.schedulerStore.set("isLoading", !1);
229
- const u = (g = l.error) == null ? void 0 : g.type;
232
+ const g = (m = l.error) == null ? void 0 : m.type;
230
233
  let c = l.error;
231
- if (u && u in this.errors.api("Create Booking")) {
234
+ if (g && g in this.errors.api("Create Booking")) {
232
235
  const w = this.getErrorMessage(c);
233
- c = this.errors.api("Create Booking")[u](w);
236
+ c = this.errors.api("Create Booking")[g](w);
234
237
  }
235
238
  return { error: c };
236
239
  }
237
240
  return "data" in l && this.schedulerStore.set("eventInfo", l == null ? void 0 : l.data), this.schedulerStore.set("isLoading", !1), l;
238
241
  }
239
242
  async getUISettings() {
240
- var n;
243
+ var r;
241
244
  this.schedulerStore.set("isLoading", !0);
242
245
  const e = this.getHeaders(), s = `/v3/scheduling/ui-settings${!this.sessionId && this.configId ? `?configuration_id=${this.configId}` : ""}`, i = await this.makeAPIRequest(s, "GET", void 0, e);
243
246
  if ("error" in i) {
244
247
  this.schedulerStore.set("isLoading", !1);
245
- const r = (n = i.error) == null ? void 0 : n.type;
248
+ const n = (r = i.error) == null ? void 0 : r.type;
246
249
  let o = i.error;
247
- return r && r in this.errors.api("Get UI Settings") && (o = this.errors.api("Get UI Settings")[r]((o == null ? void 0 : o.message) || (o == null ? void 0 : o.title) || "Something went wrong")), { error: o };
250
+ return n && n in this.errors.api(d.t("getUISettingErrorTitle")) && (o = this.errors.api(d.t("getUISettingErrorTitle"))[n]((o == null ? void 0 : o.message) || (o == null ? void 0 : o.title) || "Something went wrong")), { error: o };
248
251
  }
249
252
  return "data" in i && this.schedulerStore.set("configSettings", i.data), this.schedulerStore.set("isLoading", !1), i;
250
253
  }
@@ -254,16 +257,16 @@ class U {
254
257
  return s ? e + s * 60 : e;
255
258
  }
256
259
  getEndTimeForAvailableDaysInFuture(e) {
257
- var r, o;
258
- const t = /* @__PURE__ */ new Date(), s = (o = (r = this.schedulerStore.get("configSettings")) == null ? void 0 : r.scheduler) == null ? void 0 : o.available_days_in_future, i = Math.floor(R(t, s).getTime() / 1e3);
260
+ var n, o;
261
+ const t = /* @__PURE__ */ new Date(), s = (o = (n = this.schedulerStore.get("configSettings")) == null ? void 0 : n.scheduler) == null ? void 0 : o.available_days_in_future, i = Math.floor(F(t, s).getTime() / 1e3);
259
262
  return Math.min(i, e);
260
263
  }
261
264
  async getAvailability(e = 0, t = 0) {
262
- var v, y, _, f;
265
+ var y, I, f, S;
263
266
  this.schedulerStore.set("isLoading", !0);
264
- const s = new URLSearchParams(), i = /* @__PURE__ */ new Date(), n = i.getTime();
265
- if (t && t < n / 1e3)
266
- return this.schedulerStore.set("isLoading", !1), { error: this.errors.component("Get Availability").endtime_not_in_future() };
267
+ const s = new URLSearchParams(), i = /* @__PURE__ */ new Date(), r = i.getTime();
268
+ if (t && t < r / 1e3)
269
+ return this.schedulerStore.set("isLoading", !1), { error: this.errors.component(d.t("getAvailabilityErrorTitle")).endtime_not_in_future() };
267
270
  if (!e) {
268
271
  const l = new Date(i.getFullYear(), i.getMonth(), 1);
269
272
  e = Math.floor(l.getTime() / 1e3);
@@ -273,110 +276,110 @@ class U {
273
276
  t = Math.floor(l.getTime() / 1e3);
274
277
  }
275
278
  t = this.getEndTimeForAvailableDaysInFuture(t), s.append("start_time", encodeURIComponent(e.toString())), s.append("end_time", encodeURIComponent(t.toString())), this.configId && !this.sessionId && s.append("configuration_id", encodeURIComponent(this.configId));
276
- const r = this.schedulerStore.get("rescheduleBookingId");
277
- r && s.append("booking_id", encodeURIComponent(r));
278
- const o = s.toString(), h = `/v3/scheduling/availability${o ? `?${o}` : ""}`, m = this.getHeaders(), d = await this.makeAPIRequest(decodeURIComponent(h), "GET", void 0, m);
279
- if ("error" in d) {
279
+ const n = this.schedulerStore.get("rescheduleBookingId");
280
+ n && s.append("booking_id", encodeURIComponent(n));
281
+ const o = s.toString(), u = `/v3/scheduling/availability${o ? `?${o}` : ""}`, _ = this.getHeaders(), h = await this.makeAPIRequest(decodeURIComponent(u), "GET", void 0, _);
282
+ if ("error" in h) {
280
283
  this.schedulerStore.set("availability", []), this.schedulerStore.set("isLoading", !1);
281
- const l = (v = d.error) == null ? void 0 : v.type;
282
- let g = d.error;
283
- if (l && l in this.errors.api("Get Availability")) {
284
- const u = this.getErrorMessage(g);
285
- g = this.errors.api("Get Availability")[l](u);
284
+ const l = (y = h.error) == null ? void 0 : y.type;
285
+ let m = h.error;
286
+ if (l && l in this.errors.api(d.t("getAvailabilityErrorTitle"))) {
287
+ const g = this.getErrorMessage(m);
288
+ m = this.errors.api(d.t("getAvailabilityErrorTitle"))[l](g);
286
289
  }
287
- return { error: g };
290
+ return { error: m };
288
291
  }
289
- if ("data" in d) {
290
- const g = (((_ = (y = d.data) == null ? void 0 : y.time_slots) == null ? void 0 : _.map((c) => ({
292
+ if ("data" in h) {
293
+ const m = (((f = (I = h.data) == null ? void 0 : I.time_slots) == null ? void 0 : f.map((c) => ({
291
294
  ...c,
292
295
  start_time: new Date(c.start_time * 1e3),
293
296
  end_time: new Date(c.end_time * 1e3)
294
- }))) || []).filter((c) => c.start_time.getTime() > n);
295
- this.schedulerStore.set("availability", g);
296
- const u = ((f = d.data) == null ? void 0 : f.order) || [];
297
- this.schedulerStore.set("availabilityOrderEmails", u);
297
+ }))) || []).filter((c) => c.start_time.getTime() > r);
298
+ this.schedulerStore.set("availability", m);
299
+ const g = ((S = h.data) == null ? void 0 : S.order) || [];
300
+ this.schedulerStore.set("availabilityOrderEmails", g);
298
301
  }
299
- return this.schedulerStore.set("isLoading", !1), d;
302
+ return this.schedulerStore.set("isLoading", !1), h;
300
303
  }
301
304
  async cancelBooking(e, t) {
302
305
  var o;
303
306
  if (this.schedulerStore.set("isLoading", !0), !e)
304
- return { error: this.errors.component("Cancel Booking").no_booking_id() };
305
- const s = !this.sessionId && this.configId ? `?configuration_id=${this.configId}` : "", i = `/v3/scheduling/bookings/${e}${s}`, n = this.getHeaders(), r = await this.makeAPIRequest(decodeURIComponent(i), "DELETE", JSON.stringify({
307
+ return { error: this.errors.component(d.t("cancelBookingErrorTitle")).no_booking_id() };
308
+ const s = !this.sessionId && this.configId ? `?configuration_id=${this.configId}` : "", i = `/v3/scheduling/bookings/${e}${s}`, r = this.getHeaders(), n = await this.makeAPIRequest(decodeURIComponent(i), "DELETE", JSON.stringify({
306
309
  action: "cancel",
307
310
  cancellation_reason: t
308
- }), n);
309
- if ("error" in r) {
311
+ }), r);
312
+ if ("error" in n) {
310
313
  this.schedulerStore.set("isLoading", !1);
311
- const h = (o = r.error) == null ? void 0 : o.type;
312
- let m = r.error;
313
- if (h && h in this.errors.api("Cancel Booking")) {
314
- const d = this.getErrorMessage(m);
315
- m = this.errors.api("Cancel Booking")[h](d);
314
+ const u = (o = n.error) == null ? void 0 : o.type;
315
+ let _ = n.error;
316
+ if (u && u in this.errors.api(d.t("cancelBookingErrorTitle"))) {
317
+ const h = this.getErrorMessage(_);
318
+ _ = this.errors.api(d.t("cancelBookingErrorTitle"))[u](h);
316
319
  }
317
- return { error: m };
320
+ return { error: _ };
318
321
  }
319
322
  return this.schedulerStore.set("cancelledEventInfo", {
320
323
  booking_id: e
321
- }), this.schedulerStore.set("rescheduleBookingId", ""), this.schedulerStore.set("isLoading", !1), r;
324
+ }), this.schedulerStore.set("rescheduleBookingId", ""), this.schedulerStore.set("isLoading", !1), n;
322
325
  }
323
326
  async rescheduleBooking(e, t) {
324
- var D;
327
+ var E;
325
328
  if (this.schedulerStore.set("isLoading", !0), !e)
326
- return { error: this.errors.component("Reschedule Booking").no_booking_id() };
327
- const s = this.errors.api("Reschedule Booking"), i = this.errors.component("Reschedule Booking"), { bookingInfo: n, selectedTimeslot: r, selectedTimezone: o } = this.schedulerStore.state, { startTime: h, endTime: m, timezone: d } = t, v = h || (r == null ? void 0 : r.start_time);
328
- if (!v)
329
- return { error: i.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.') };
330
- const y = m || (r == null ? void 0 : r.end_time);
329
+ return { error: this.errors.component(d.t("rescheduleBookingErrorTitle")).no_booking_id() };
330
+ const s = this.errors.api(d.t("rescheduleBookingErrorTitle")), i = this.errors.component(d.t("rescheduleBookingErrorTitle")), { bookingInfo: r, selectedTimeslot: n, selectedTimezone: o } = this.schedulerStore.state, { startTime: u, endTime: _, timezone: h } = t, y = u || (n == null ? void 0 : n.start_time);
331
331
  if (!y)
332
+ return { error: i.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.') };
333
+ const I = _ || (n == null ? void 0 : n.end_time);
334
+ if (!I)
332
335
  return { error: i.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.') };
333
- const _ = this.schedulerStore.get("availabilityOrderEmails");
334
- let f = "";
335
- if (_.length > 0) {
336
- const I = (r == null ? void 0 : r.emails) || [];
337
- for (let p = 0; p < _.length; p++)
338
- if (I.includes(_[p])) {
339
- f = _[p];
336
+ const f = this.schedulerStore.get("availabilityOrderEmails");
337
+ let S = "";
338
+ if (f.length > 0) {
339
+ const T = (n == null ? void 0 : n.emails) || [];
340
+ for (let v = 0; v < f.length; v++)
341
+ if (T.includes(f[v])) {
342
+ S = f[v];
340
343
  break;
341
344
  }
342
345
  }
343
- const l = d || o;
346
+ const l = h || o;
344
347
  if (!l)
345
348
  return { error: i.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.') };
346
- const g = t ? t == null ? void 0 : t.primaryParticipant : n == null ? void 0 : n.primaryParticipant, u = t ? (t == null ? void 0 : t.guests) || [] : (n == null ? void 0 : n.guests) || [], c = t ? t == null ? void 0 : t.additionalFields : n == null ? void 0 : n.additionalFields, w = !this.sessionId && this.configId ? `?configuration_id=${this.configId}` : "", P = `/v3/scheduling/bookings/${e}${w}`, L = this.getHeaders(), S = await this.makeAPIRequest(decodeURIComponent(P), "PATCH", JSON.stringify({
347
- start_time: v.getTime() / 1e3,
348
- end_time: y.getTime() / 1e3,
349
+ const m = t ? t == null ? void 0 : t.primaryParticipant : r == null ? void 0 : r.primaryParticipant, g = t ? (t == null ? void 0 : t.guests) || [] : (r == null ? void 0 : r.guests) || [], c = t ? t == null ? void 0 : t.additionalFields : r == null ? void 0 : r.additionalFields, w = !this.sessionId && this.configId ? `?configuration_id=${this.configId}` : "", B = `/v3/scheduling/bookings/${e}${w}`, P = this.getHeaders(), p = await this.makeAPIRequest(decodeURIComponent(B), "PATCH", JSON.stringify({
350
+ start_time: y.getTime() / 1e3,
351
+ end_time: I.getTime() / 1e3,
349
352
  time_zone: l,
350
353
  additional_fields: c,
351
- guest: { ...g },
352
- additional_guests: u,
353
- participants: f ? [{ email: f }] : void 0
354
- }), L);
355
- if ("error" in S) {
354
+ guest: { ...m },
355
+ additional_guests: g,
356
+ participants: S ? [{ email: S }] : void 0
357
+ }), P);
358
+ if ("error" in p) {
356
359
  this.schedulerStore.set("isLoading", !1);
357
- const I = (D = S.error) == null ? void 0 : D.type;
358
- let p = S.error;
359
- if (I && I in s) {
360
- const M = this.getErrorMessage(p);
361
- p = s[I](M);
360
+ const T = (E = p.error) == null ? void 0 : E.type;
361
+ let v = p.error;
362
+ if (T && T in s) {
363
+ const M = this.getErrorMessage(v);
364
+ v = s[T](M);
362
365
  }
363
- return { error: p };
366
+ return { error: v };
364
367
  }
365
- const T = this.schedulerStore.get("reschedulingEventInfo");
366
- if ("data" in S)
367
- this.schedulerStore.set("eventInfo", S == null ? void 0 : S.data);
368
- else if (T)
369
- this.schedulerStore.set("eventInfo", T);
368
+ const D = this.schedulerStore.get("reschedulingEventInfo");
369
+ if ("data" in p)
370
+ this.schedulerStore.set("eventInfo", p == null ? void 0 : p.data);
371
+ else if (D)
372
+ this.schedulerStore.set("eventInfo", D);
370
373
  else {
371
- const I = {
374
+ const T = {
372
375
  booking_id: e
373
376
  };
374
- this.schedulerStore.set("eventInfo", I);
377
+ this.schedulerStore.set("eventInfo", T);
375
378
  }
376
- return this.schedulerStore.set("isLoading", !1), S;
379
+ return this.schedulerStore.set("isLoading", !1), p;
377
380
  }
378
381
  }
379
- function E(a = {}) {
382
+ function N(a = {}) {
380
383
  const e = {
381
384
  selectedDate: null,
382
385
  selectedLanguage: navigator.language,
@@ -400,11 +403,11 @@ function E(a = {}) {
400
403
  b("[availability]: ", s);
401
404
  const i = s.map((o) => o.start_time);
402
405
  b("[selectableDates]: ", i), t.set("selectableDates", i);
403
- const n = s[0];
404
- if (!n)
406
+ const r = s[0];
407
+ if (!r)
405
408
  return;
406
- const r = Math.floor((n.end_time.getTime() - n.start_time.getTime()) / 6e4);
407
- b("[durationMinutes]: ", r), t.set("eventDuration", r);
409
+ const n = Math.floor((r.end_time.getTime() - r.start_time.getTime()) / 6e4);
410
+ b("[durationMinutes]: ", n), t.set("eventDuration", n);
408
411
  }), t.reset = () => {
409
412
  for (const s in e) {
410
413
  const i = e[s];
@@ -413,7 +416,7 @@ function E(a = {}) {
413
416
  }, t;
414
417
  }
415
418
  export {
416
- E as C,
419
+ N as C,
417
420
  k as E,
418
- U as N
421
+ C as N
419
422
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index-a4831dfe.cjs"),r=require("./index-6d9eeb53-8b16e3b5.cjs");require("./index-53420959-e6c2e510.cjs");require("react");require("react-dom");const l=':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;width:100%}label{display:flex;color:var(--nylas-base-800, #293056);font-size:14px;font-style:normal;font-weight:400;line-height:150%;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)}textarea{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%;padding:12px 16px;border-width:1;resize:vertical;border-radius:8px;font-family:var(--nylas-font-family);font-size:16px;line-height:24px}textarea:focus{outline-color:var(--nylas-primary)}textarea.error{border-radius:var(--nylas-border-radius-2x);font-weight:600;border-color:var(--nylas-error);border-width:2px}textarea.error::placeholder{font-weight:400}textarea::placeholder{color:var(--nylas-base-300)}textarea::-webkit-resizer{display:none}',n=l,t=class{constructor(e){a.registerInstance(this,e),this.nylasFormInputChanged=a.createEvent(this,"nylasFormInputChanged",7),this.name="textarea",this.defaultValue="",this.label="",this.placeholder="",this.required=!1,this.readOnly=!1,this.autoFocus=!1,this.maxLength=255,this.type="multi_line_text",this.value="",this.error=""}componentWillLoad(){this.value=r.sanitizeHtml$1(this.defaultValue)}handleBookingFormSubmitted(e){this.validate(this.value),this.error&&e.preventDefault()}handleInput(e){const s=e.target;this.value=r.sanitizeHtml$1(s.value),this.nylasFormInputChanged.emit({value:this.value,name:this.name,error:this.error,label:this.label,type:this.type})}validate(e){this.required&&!e?this.error=`${this.label} is required.`:e.length>this.maxLength?this.error=`${this.label} cannot exceed ${this.maxLength} characters.`:this.error=""}render(){return a.h("label",{key:"d3b47fecea63bd4674d4d9e67e7f74697004b03e",part:"tc__label",class:{error:!!this.error}},a.h("p",{key:"81b682db7ded02d9111661e2ffe1cc0650546bfc"},a.h("span",{key:"2e2120f1d32af6b5fffff7ee913f01c6d73155eb",class:"label"},this.label),this.required&&a.h("span",{class:"required"},"*")),a.h("textarea",{key:"bc7426f389b42a25a251a3b8b878e3b2ee8fd5a0",name:this.name,placeholder:this.placeholder,readOnly:this.readOnly,autoFocus:this.autoFocus,value:this.value,maxLength:this.maxLength,onInput:e=>this.handleInput(e),class:{error:!!this.error},part:"tc__textarea"}),this.error&&a.h("span",{class:"error help-text"},this.error))}};t.style=n;exports.textarea_component=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index-26f8bbeb.cjs"),r=require("./index-6d9eeb53-b71b16c5.cjs");require("./index-53420959-a444c1cf.cjs");require("react");require("react-dom");const l=':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;width:100%}label{display:flex;color:var(--nylas-base-800, #293056);font-size:14px;font-style:normal;font-weight:400;line-height:150%;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)}textarea{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%;padding:12px 16px;border-width:1;resize:vertical;border-radius:8px;font-family:var(--nylas-font-family);font-size:16px;line-height:24px}textarea:focus{outline-color:var(--nylas-primary)}textarea.error{border-radius:var(--nylas-border-radius-2x);font-weight:600;border-color:var(--nylas-error);border-width:2px}textarea.error::placeholder{font-weight:400}textarea::placeholder{color:var(--nylas-base-300)}textarea::-webkit-resizer{display:none}',n=l,t=class{constructor(e){a.registerInstance(this,e),this.nylasFormInputChanged=a.createEvent(this,"nylasFormInputChanged",7),this.name="textarea",this.defaultValue="",this.label="",this.placeholder="",this.required=!1,this.readOnly=!1,this.autoFocus=!1,this.maxLength=255,this.type="multi_line_text",this.value="",this.error=""}componentWillLoad(){this.value=r.sanitizeHtml$1(this.defaultValue)}handleBookingFormSubmitted(e){this.validate(this.value),this.error&&e.preventDefault()}handleInput(e){const s=e.target;this.value=r.sanitizeHtml$1(s.value),this.nylasFormInputChanged.emit({value:this.value,name:this.name,error:this.error,label:this.label,type:this.type})}validate(e){this.required&&!e?this.error=`${this.label} is required.`:e.length>this.maxLength?this.error=`${this.label} cannot exceed ${this.maxLength} characters.`:this.error=""}render(){return a.h("label",{key:"a978b00a76d7c20e2b08540d7c655dfc0ad309d4",part:"tc__label",class:{error:!!this.error}},a.h("p",{key:"3331bdfb7132894af453277f25c0692b55ebc619"},a.h("span",{key:"b8efb94cf4d405da1c49a9c0c626c2e8a5e6be0f",class:"label"},this.label),this.required&&a.h("span",{class:"required"},"*")),a.h("textarea",{key:"73a06473baabd4d1f29250110a0f34ca37ffb135",name:this.name,placeholder:this.placeholder,readOnly:this.readOnly,autoFocus:this.autoFocus,value:this.value,maxLength:this.maxLength,onInput:e=>this.handleInput(e),class:{error:!!this.error},part:"tc__textarea"}),this.error&&a.h("span",{class:"error help-text"},this.error))}};t.style=n;exports.textarea_component=t;
@@ -1,6 +1,6 @@
1
- import { r as t, c as l, h as a } from "./index-a68236be.js";
2
- import { s as r } from "./index-6d9eeb53-b15263de.js";
3
- import "./index-53420959-507f0a27.js";
1
+ import { r as t, c as l, h as a } from "./index-5da0aff3.js";
2
+ import { s as r } from "./index-6d9eeb53-f37ff819.js";
3
+ import "./index-53420959-b26d1293.js";
4
4
  import "react";
5
5
  import "react-dom";
6
6
  const n = ':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;width:100%}label{display:flex;color:var(--nylas-base-800, #293056);font-size:14px;font-style:normal;font-weight:400;line-height:150%;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)}textarea{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%;padding:12px 16px;border-width:1;resize:vertical;border-radius:8px;font-family:var(--nylas-font-family);font-size:16px;line-height:24px}textarea:focus{outline-color:var(--nylas-primary)}textarea.error{border-radius:var(--nylas-border-radius-2x);font-weight:600;border-color:var(--nylas-error);border-width:2px}textarea.error::placeholder{font-weight:400}textarea::placeholder{color:var(--nylas-base-300)}textarea::-webkit-resizer{display:none}', i = n, o = class {
@@ -27,7 +27,7 @@ const n = ':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--n
27
27
  this.required && !e ? this.error = `${this.label} is required.` : e.length > this.maxLength ? this.error = `${this.label} cannot exceed ${this.maxLength} characters.` : this.error = "";
28
28
  }
29
29
  render() {
30
- return a("label", { key: "d3b47fecea63bd4674d4d9e67e7f74697004b03e", part: "tc__label", class: { error: !!this.error } }, a("p", { key: "81b682db7ded02d9111661e2ffe1cc0650546bfc" }, a("span", { key: "2e2120f1d32af6b5fffff7ee913f01c6d73155eb", class: "label" }, this.label), this.required && a("span", { class: "required" }, "*")), a("textarea", { key: "bc7426f389b42a25a251a3b8b878e3b2ee8fd5a0", name: this.name, placeholder: this.placeholder, readOnly: this.readOnly, autoFocus: this.autoFocus, value: this.value, maxLength: this.maxLength, onInput: (e) => this.handleInput(e), class: { error: !!this.error }, part: "tc__textarea" }), this.error && a("span", { class: "error help-text" }, this.error));
30
+ return a("label", { key: "a978b00a76d7c20e2b08540d7c655dfc0ad309d4", part: "tc__label", class: { error: !!this.error } }, a("p", { key: "3331bdfb7132894af453277f25c0692b55ebc619" }, a("span", { key: "b8efb94cf4d405da1c49a9c0c626c2e8a5e6be0f", class: "label" }, this.label), this.required && a("span", { class: "required" }, "*")), a("textarea", { key: "73a06473baabd4d1f29250110a0f34ca37ffb135", name: this.name, placeholder: this.placeholder, readOnly: this.readOnly, autoFocus: this.autoFocus, value: this.value, maxLength: this.maxLength, onInput: (e) => this.handleInput(e), class: { error: !!this.error }, part: "tc__textarea" }), this.error && a("span", { class: "error help-text" }, this.error));
31
31
  }
32
32
  };
33
33
  o.style = i;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./index-26f8bbeb.cjs");require("react");require("react-dom");const s=".time-period-selector.sc-time-period-selector{display:grid;gap:0.5rem;grid-template-columns:auto 1fr}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector,.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector{border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-2x)}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector{width:116px}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector{width:84px;display:flex;align-items:center}.time-period-selector.sc-time-period-selector select-dropdown#time-period.sc-time-period-selector::part(sd_dropdown-button){width:100%}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown){width:inherit;height:100%}.time-period-selector.sc-time-period-selector input-dropdown#time-number.sc-time-period-selector::part(id_dropdown-input){border:none;border-radius:var(--nylas-border-radius-2x)}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown-input){padding:17px;gap:1rem}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown-content){width:100%;max-height:200px}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown){width:inherit}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown-button){padding:1rem;gap:1rem;justify-content:space-between}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown-content){width:100%;max-height:200px}",n=s,p={hours:"hour",days:"day",weeks:"week",months:"month"},o=class{constructor(e){d.registerInstance(this,e),this.timePeriodChanged=d.createEvent(this,"timePeriodChanged",7),this.timePeriods=["hour","day","week","month"],this.defaultSelectedPeriod="hour",this.defaultSelectedNumber=1,this.selectedPeriod=this.defaultSelectedPeriod,this.selectedNumber=this.defaultSelectedNumber,this.numberOptions=this.calculateOptions(this.defaultSelectedPeriod||"hour").map(t=>({label:t.toString(),value:t.toString()})),this.timePeriodOptions=this.timePeriods.map(t=>({label:t,value:t}))}defaultSelectedPeriodChangedHandler(e){this.selectedPeriod=e;const t=p[e]??e;this.updateNumberOptionsAndSelectedNumber(t)}defaultSelectedNumberChangedHandler(e){this.selectedNumber=e}timePeriodsChangedHandler(e){this.timePeriodOptions=e.map(t=>({label:t,value:t}))}calculateOptions(e){switch(e){case"hour":return Array.from({length:23},(t,r)=>r+1);case"minute":return Array.from({length:13},(t,r)=>r*5);case"day":return Array.from({length:30},(t,r)=>r+1);case"week":return Array.from({length:4},(t,r)=>r+1);case"month":return Array.from({length:12},(t,r)=>r+1);default:return[]}}inputOptionChangedHandler(e){d.debug("time-period-selector","inputOptionChangedHandler",e.detail);const{value:t,name:r}=e.detail;r==="time-number"&&(this.selectedNumber=parseInt(t));const i={number:this.selectedNumber,period:this.selectedPeriod};this.timePeriodChanged.emit(i)}nylasFormDropdownChangedHandler(e){d.debug("time-period-selector","nylasFormDropdownChangedHandler",e.detail);const{value:t,name:r}=e.detail;r==="time-period"?(this.selectedPeriod=t,this.updateNumberOptionsAndSelectedNumber(t)):r==="time-number"&&(this.selectedNumber=parseInt(t));const i={number:this.selectedNumber,period:this.selectedPeriod};this.timePeriodChanged.emit(i)}updateNumberOptionsAndSelectedNumber(e){const t=this.calculateOptions(e);this.numberOptions=t.map(r=>({label:r.toString(),value:r.toString()})),this.selectedNumber=parseInt(this.numberOptions[0].value)}render(){return d.h("div",{key:"216eccd8453c89f66463c99bfc18018f98732671",class:"time-period-selector"},d.h("input-dropdown",{key:"985debdbe86850c13f26450b9e1a5e29b3b04594",id:"time-number",name:"time-number",inputValue:this.selectedNumber.toString(),exportparts:"sd_dropdown: tps__number-dropdown, sd_dropdown-button: tps__number-dropdown-button, sd_dropdown-content: tps__number-dropdown-content",options:this.numberOptions,defaultInputOption:this.numberOptions.find(e=>e.value==this.selectedNumber.toString())??this.numberOptions[0]}),d.h("select-dropdown",{key:"5039a6dcad6b8e426875a20f690dc5898536a8ba",id:"time-period",name:"time-period",options:this.timePeriodOptions,exportparts:"sd_dropdown: tps__period-dropdown, sd_dropdown-button: tps__period-dropdown-button, sd_dropdown-content: tps__period-dropdown-content",pluralizedLabel:this.selectedNumber>1?"s":"",defaultSelectedOption:this.timePeriodOptions.find(e=>e.value==this.selectedPeriod)??this.timePeriodOptions[0],withSearch:!1}))}get host(){return d.getElement(this)}static get watchers(){return{defaultSelectedPeriod:["defaultSelectedPeriodChangedHandler"],defaultSelectedNumber:["defaultSelectedNumberChangedHandler"],timePeriods:["timePeriodsChangedHandler"]}}};o.style=n;exports.time_period_selector=o;
@@ -0,0 +1,93 @@
1
+ import { r as s, c as n, d as i, h as o, g as p } from "./index-5da0aff3.js";
2
+ import "react";
3
+ import "react-dom";
4
+ const l = ".time-period-selector.sc-time-period-selector{display:grid;gap:0.5rem;grid-template-columns:auto 1fr}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector,.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector{border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-2x)}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector{width:116px}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector{width:84px;display:flex;align-items:center}.time-period-selector.sc-time-period-selector select-dropdown#time-period.sc-time-period-selector::part(sd_dropdown-button){width:100%}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown){width:inherit;height:100%}.time-period-selector.sc-time-period-selector input-dropdown#time-number.sc-time-period-selector::part(id_dropdown-input){border:none;border-radius:var(--nylas-border-radius-2x)}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown-input){padding:17px;gap:1rem}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown-content){width:100%;max-height:200px}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown){width:inherit}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown-button){padding:1rem;gap:1rem;justify-content:space-between}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown-content){width:100%;max-height:200px}", c = l, a = {
5
+ hours: "hour",
6
+ days: "day",
7
+ weeks: "week",
8
+ months: "month"
9
+ }, m = class {
10
+ constructor(e) {
11
+ s(this, e), this.timePeriodChanged = n(this, "timePeriodChanged", 7), this.timePeriods = ["hour", "day", "week", "month"], this.defaultSelectedPeriod = "hour", this.defaultSelectedNumber = 1, this.selectedPeriod = this.defaultSelectedPeriod, this.selectedNumber = this.defaultSelectedNumber, this.numberOptions = this.calculateOptions(this.defaultSelectedPeriod || "hour").map((t) => ({
12
+ label: t.toString(),
13
+ value: t.toString()
14
+ })), this.timePeriodOptions = this.timePeriods.map((t) => ({
15
+ label: t,
16
+ value: t
17
+ }));
18
+ }
19
+ defaultSelectedPeriodChangedHandler(e) {
20
+ this.selectedPeriod = e;
21
+ const t = a[e] ?? e;
22
+ this.updateNumberOptionsAndSelectedNumber(t);
23
+ }
24
+ defaultSelectedNumberChangedHandler(e) {
25
+ this.selectedNumber = e;
26
+ }
27
+ timePeriodsChangedHandler(e) {
28
+ this.timePeriodOptions = e.map((t) => ({
29
+ label: t,
30
+ value: t
31
+ }));
32
+ }
33
+ calculateOptions(e) {
34
+ switch (e) {
35
+ case "hour":
36
+ return Array.from({ length: 23 }, (t, r) => r + 1);
37
+ case "minute":
38
+ return Array.from({ length: 13 }, (t, r) => r * 5);
39
+ case "day":
40
+ return Array.from({ length: 30 }, (t, r) => r + 1);
41
+ case "week":
42
+ return Array.from({ length: 4 }, (t, r) => r + 1);
43
+ case "month":
44
+ return Array.from({ length: 12 }, (t, r) => r + 1);
45
+ default:
46
+ return [];
47
+ }
48
+ }
49
+ inputOptionChangedHandler(e) {
50
+ i("time-period-selector", "inputOptionChangedHandler", e.detail);
51
+ const { value: t, name: r } = e.detail;
52
+ r === "time-number" && (this.selectedNumber = parseInt(t));
53
+ const d = {
54
+ number: this.selectedNumber,
55
+ period: this.selectedPeriod
56
+ };
57
+ this.timePeriodChanged.emit(d);
58
+ }
59
+ nylasFormDropdownChangedHandler(e) {
60
+ i("time-period-selector", "nylasFormDropdownChangedHandler", e.detail);
61
+ const { value: t, name: r } = e.detail;
62
+ r === "time-period" ? (this.selectedPeriod = t, this.updateNumberOptionsAndSelectedNumber(t)) : r === "time-number" && (this.selectedNumber = parseInt(t));
63
+ const d = {
64
+ number: this.selectedNumber,
65
+ period: this.selectedPeriod
66
+ };
67
+ this.timePeriodChanged.emit(d);
68
+ }
69
+ updateNumberOptionsAndSelectedNumber(e) {
70
+ const t = this.calculateOptions(e);
71
+ this.numberOptions = t.map((r) => ({
72
+ label: r.toString(),
73
+ value: r.toString()
74
+ })), this.selectedNumber = parseInt(this.numberOptions[0].value);
75
+ }
76
+ render() {
77
+ return o("div", { key: "216eccd8453c89f66463c99bfc18018f98732671", class: "time-period-selector" }, o("input-dropdown", { key: "985debdbe86850c13f26450b9e1a5e29b3b04594", id: "time-number", name: "time-number", inputValue: this.selectedNumber.toString(), exportparts: "sd_dropdown: tps__number-dropdown, sd_dropdown-button: tps__number-dropdown-button, sd_dropdown-content: tps__number-dropdown-content", options: this.numberOptions, defaultInputOption: this.numberOptions.find((e) => e.value == this.selectedNumber.toString()) ?? this.numberOptions[0] }), o("select-dropdown", { key: "5039a6dcad6b8e426875a20f690dc5898536a8ba", id: "time-period", name: "time-period", options: this.timePeriodOptions, exportparts: "sd_dropdown: tps__period-dropdown, sd_dropdown-button: tps__period-dropdown-button, sd_dropdown-content: tps__period-dropdown-content", pluralizedLabel: this.selectedNumber > 1 ? "s" : "", defaultSelectedOption: this.timePeriodOptions.find((e) => e.value == this.selectedPeriod) ?? this.timePeriodOptions[0], withSearch: !1 }));
78
+ }
79
+ get host() {
80
+ return p(this);
81
+ }
82
+ static get watchers() {
83
+ return {
84
+ defaultSelectedPeriod: ["defaultSelectedPeriodChangedHandler"],
85
+ defaultSelectedNumber: ["defaultSelectedNumberChangedHandler"],
86
+ timePeriods: ["timePeriodsChangedHandler"]
87
+ };
88
+ }
89
+ };
90
+ m.style = c;
91
+ export {
92
+ m as time_period_selector
93
+ };
@@ -1,12 +1,12 @@
1
- import { r as e, h as C } from "./index-a68236be.js";
1
+ import { r as s, h as C } from "./index-5da0aff3.js";
2
2
  import "react";
3
3
  import "react-dom";
4
- const s = ".sc-translate-icon-h{display:flex}", i = s, o = class {
4
+ const e = ".sc-translate-icon-h{display:flex}", i = e, o = class {
5
5
  constructor(t) {
6
- e(this, t), this.width = "16", this.height = "16";
6
+ s(this, t), this.width = "16", this.height = "16";
7
7
  }
8
8
  render() {
9
- return C("svg", { key: "2adb873677c4e43f26bdf53a8fbd1ff10bef2619", xmlns: "http://www.w3.org/2000/svg", width: this.width, height: this.height, viewBox: "0 0 20 20", fill: "none" }, C("path", { key: "489eca5f087f8b46dff5554e6a88ab6e2ddadf42", fill: "currentColor", d: "M14.1663 4.02867C14.4267 4.12081 14.563 4.40654 14.4709 4.66685C14.3501 5.00788 14.2182 5.4771 14.1178 5.86047C14.6877 5.77587 15.2665 5.65653 15.8867 5.51288C16.1557 5.45058 16.4243 5.61815 16.4866 5.88717C16.5489 6.15619 16.3814 6.42479 16.1123 6.4871C15.339 6.66621 14.6101 6.81289 13.8717 6.90283C13.7759 7.35654 13.7014 7.77084 13.6451 8.15021C14.1202 8.04599 14.5738 8.00553 14.9996 8.02075L14.9996 8C14.9996 7.72386 15.2235 7.5 15.4996 7.5C15.7758 7.5 15.9996 7.72386 15.9996 8C15.9996 8.05657 15.9991 8.11281 15.9979 8.16871C17.1392 8.47838 17.9781 9.23987 18.3435 10.2263C18.9579 11.8853 18.1287 13.8787 15.7027 14.9569C15.4504 15.069 15.1549 14.9554 15.0427 14.7031C14.9306 14.4507 15.0442 14.1552 15.2966 14.0431C17.3705 13.1213 17.7913 11.6147 17.4057 10.5737C17.1874 9.984 16.6776 9.44916 15.9129 9.18633C15.6829 10.7237 15.021 11.9466 14.229 12.7925C14.3126 12.9656 14.3958 13.1436 14.4641 13.3151C14.5662 13.5717 14.441 13.8625 14.1844 13.9646C13.9278 14.0667 13.637 13.9415 13.5349 13.6849C13.5066 13.6137 13.4777 13.5463 13.448 13.4802C13.028 13.7794 12.5905 13.9869 12.1705 14.0835C11.5942 14.2161 10.963 14.1517 10.534 13.6942C9.88917 13.0053 9.84361 11.8611 10.2855 10.8412C10.6652 9.96479 11.4186 9.11781 12.5848 8.54034C12.6387 8.07338 12.7199 7.55894 12.8332 6.98891C12.3926 7.00755 11.9403 7.00326 11.4659 6.97127C11.1904 6.95269 10.9821 6.71428 11.0007 6.43876C11.0192 6.16325 11.2577 5.95496 11.5332 5.97353C12.0633 6.00928 12.5641 6.00772 13.0566 5.97553C13.1605 5.55444 13.3512 4.8331 13.5282 4.33317C13.6203 4.07286 13.906 3.93653 14.1663 4.02867ZM12.501 9.74109C11.8436 10.1821 11.427 10.7219 11.2031 11.2387C10.8542 12.0439 10.9881 12.716 11.2638 13.0105C11.2637 13.0104 11.2639 13.0106 11.2638 13.0105C11.3573 13.11 11.5624 13.1973 11.9463 13.109C12.2578 13.0373 12.6311 12.8571 13.0121 12.5576C12.8658 12.22 12.7272 11.8324 12.6313 11.353C12.5405 10.8996 12.4899 10.3743 12.501 9.74109ZM13.7808 11.7797C14.316 11.0956 14.759 10.1665 14.9271 9.01632C14.539 9.00681 14.1111 9.05601 13.6457 9.17854C13.605 9.19274 13.5647 9.20726 13.525 9.22209C13.4663 10.0545 13.5146 10.671 13.6118 11.1568C13.6578 11.3868 13.7156 11.5913 13.7808 11.7797ZM6.92028 5.2159C5.77942 4.88398 4.78409 5.00841 4.07616 5.21575C3.72264 5.3193 3.439 5.44393 3.24121 5.5443C3.14215 5.59457 3.0641 5.63901 3.00903 5.67212C2.98147 5.68868 2.95962 5.70244 2.9437 5.71271L2.92429 5.72542L2.91797 5.72966L2.91566 5.73123L2.91393 5.73241C2.91384 5.73249 2.91436 5.73325 2.94925 5.78397C3.23698 6.20225 3.1703 6.10548 2.91393 5.73241C2.68634 5.88881 2.62863 6.20009 2.78502 6.42767C2.94134 6.65514 3.25207 6.71313 3.47963 6.55703L3.4788 6.5576L3.48576 6.55305C3.49318 6.54826 3.50608 6.5401 3.52423 6.52919C3.56057 6.50735 3.6177 6.47463 3.69373 6.43605C3.84612 6.35872 4.07228 6.2589 4.35724 6.17544C4.92619 6.0088 5.72242 5.90898 6.64043 6.17595C7.35305 6.38517 7.66747 6.76919 7.82692 7.16112C7.98173 7.54163 8.0026 7.95751 8.00531 8.33243C7.46199 8.18407 6.79336 8.03682 6.08385 8.00744C5.04808 7.96456 3.8874 8.17096 2.87738 9.01102C1.98877 9.75011 1.78345 10.8818 2.07014 11.853C2.35713 12.8252 3.14925 13.692 4.31803 13.9348C5.22351 14.123 6.18016 13.8639 6.9599 13.5212C7.3403 13.354 7.69572 13.1594 8.0057 12.9665V13.5C8.0057 13.7761 8.22956 14 8.5057 14C8.78184 14 9.0057 13.7754 9.0057 13.4993L9.0057 8.44586C9.0058 8.05404 9.00595 7.40554 8.7532 6.78428C8.48142 6.11625 7.93342 5.51313 6.92136 5.21622L6.92028 5.2159ZM6.04249 9.00659C6.76366 9.03645 7.44769 9.209 8.0057 9.37205V11.757C7.65814 12.0182 7.13927 12.35 6.55757 12.6057C5.85264 12.9155 5.12729 13.0816 4.52148 12.9557C3.75127 12.7957 3.22322 12.2271 3.02922 11.5699C2.83491 10.9116 2.98777 10.2199 3.51683 9.77985C4.27958 9.14545 5.16917 8.97043 6.04249 9.00659Z" }));
9
+ return C("svg", { key: "9d3c7c6029b2e01687265bf2519dd6bcb30fe40b", xmlns: "http://www.w3.org/2000/svg", width: this.width, height: this.height, viewBox: "0 0 20 20", fill: "none" }, C("path", { key: "31ffa926f994ace5b8f4c646417d5a8105caa696", fill: "currentColor", d: "M14.1663 4.02867C14.4267 4.12081 14.563 4.40654 14.4709 4.66685C14.3501 5.00788 14.2182 5.4771 14.1178 5.86047C14.6877 5.77587 15.2665 5.65653 15.8867 5.51288C16.1557 5.45058 16.4243 5.61815 16.4866 5.88717C16.5489 6.15619 16.3814 6.42479 16.1123 6.4871C15.339 6.66621 14.6101 6.81289 13.8717 6.90283C13.7759 7.35654 13.7014 7.77084 13.6451 8.15021C14.1202 8.04599 14.5738 8.00553 14.9996 8.02075L14.9996 8C14.9996 7.72386 15.2235 7.5 15.4996 7.5C15.7758 7.5 15.9996 7.72386 15.9996 8C15.9996 8.05657 15.9991 8.11281 15.9979 8.16871C17.1392 8.47838 17.9781 9.23987 18.3435 10.2263C18.9579 11.8853 18.1287 13.8787 15.7027 14.9569C15.4504 15.069 15.1549 14.9554 15.0427 14.7031C14.9306 14.4507 15.0442 14.1552 15.2966 14.0431C17.3705 13.1213 17.7913 11.6147 17.4057 10.5737C17.1874 9.984 16.6776 9.44916 15.9129 9.18633C15.6829 10.7237 15.021 11.9466 14.229 12.7925C14.3126 12.9656 14.3958 13.1436 14.4641 13.3151C14.5662 13.5717 14.441 13.8625 14.1844 13.9646C13.9278 14.0667 13.637 13.9415 13.5349 13.6849C13.5066 13.6137 13.4777 13.5463 13.448 13.4802C13.028 13.7794 12.5905 13.9869 12.1705 14.0835C11.5942 14.2161 10.963 14.1517 10.534 13.6942C9.88917 13.0053 9.84361 11.8611 10.2855 10.8412C10.6652 9.96479 11.4186 9.11781 12.5848 8.54034C12.6387 8.07338 12.7199 7.55894 12.8332 6.98891C12.3926 7.00755 11.9403 7.00326 11.4659 6.97127C11.1904 6.95269 10.9821 6.71428 11.0007 6.43876C11.0192 6.16325 11.2577 5.95496 11.5332 5.97353C12.0633 6.00928 12.5641 6.00772 13.0566 5.97553C13.1605 5.55444 13.3512 4.8331 13.5282 4.33317C13.6203 4.07286 13.906 3.93653 14.1663 4.02867ZM12.501 9.74109C11.8436 10.1821 11.427 10.7219 11.2031 11.2387C10.8542 12.0439 10.9881 12.716 11.2638 13.0105C11.2637 13.0104 11.2639 13.0106 11.2638 13.0105C11.3573 13.11 11.5624 13.1973 11.9463 13.109C12.2578 13.0373 12.6311 12.8571 13.0121 12.5576C12.8658 12.22 12.7272 11.8324 12.6313 11.353C12.5405 10.8996 12.4899 10.3743 12.501 9.74109ZM13.7808 11.7797C14.316 11.0956 14.759 10.1665 14.9271 9.01632C14.539 9.00681 14.1111 9.05601 13.6457 9.17854C13.605 9.19274 13.5647 9.20726 13.525 9.22209C13.4663 10.0545 13.5146 10.671 13.6118 11.1568C13.6578 11.3868 13.7156 11.5913 13.7808 11.7797ZM6.92028 5.2159C5.77942 4.88398 4.78409 5.00841 4.07616 5.21575C3.72264 5.3193 3.439 5.44393 3.24121 5.5443C3.14215 5.59457 3.0641 5.63901 3.00903 5.67212C2.98147 5.68868 2.95962 5.70244 2.9437 5.71271L2.92429 5.72542L2.91797 5.72966L2.91566 5.73123L2.91393 5.73241C2.91384 5.73249 2.91436 5.73325 2.94925 5.78397C3.23698 6.20225 3.1703 6.10548 2.91393 5.73241C2.68634 5.88881 2.62863 6.20009 2.78502 6.42767C2.94134 6.65514 3.25207 6.71313 3.47963 6.55703L3.4788 6.5576L3.48576 6.55305C3.49318 6.54826 3.50608 6.5401 3.52423 6.52919C3.56057 6.50735 3.6177 6.47463 3.69373 6.43605C3.84612 6.35872 4.07228 6.2589 4.35724 6.17544C4.92619 6.0088 5.72242 5.90898 6.64043 6.17595C7.35305 6.38517 7.66747 6.76919 7.82692 7.16112C7.98173 7.54163 8.0026 7.95751 8.00531 8.33243C7.46199 8.18407 6.79336 8.03682 6.08385 8.00744C5.04808 7.96456 3.8874 8.17096 2.87738 9.01102C1.98877 9.75011 1.78345 10.8818 2.07014 11.853C2.35713 12.8252 3.14925 13.692 4.31803 13.9348C5.22351 14.123 6.18016 13.8639 6.9599 13.5212C7.3403 13.354 7.69572 13.1594 8.0057 12.9665V13.5C8.0057 13.7761 8.22956 14 8.5057 14C8.78184 14 9.0057 13.7754 9.0057 13.4993L9.0057 8.44586C9.0058 8.05404 9.00595 7.40554 8.7532 6.78428C8.48142 6.11625 7.93342 5.51313 6.92136 5.21622L6.92028 5.2159ZM6.04249 9.00659C6.76366 9.03645 7.44769 9.209 8.0057 9.37205V11.757C7.65814 12.0182 7.13927 12.35 6.55757 12.6057C5.85264 12.9155 5.12729 13.0816 4.52148 12.9557C3.75127 12.7957 3.22322 12.2271 3.02922 11.5699C2.83491 10.9116 2.98777 10.2199 3.51683 9.77985C4.27958 9.14545 5.16917 8.97043 6.04249 9.00659Z" }));
10
10
  }
11
11
  };
12
12
  o.style = i;