@meetelise/chat 1.20.152 → 1.20.154
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/package.json
CHANGED
package/public/dist/index.js
CHANGED
|
@@ -239,17 +239,22 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
|
|
|
239
239
|
opacity: 30%;
|
|
240
240
|
}
|
|
241
241
|
`,Wt([ue({attribute:"month",type:String})],Qt.prototype,"defaultMonth",void 0),Wt([ue({attribute:"year",type:Number})],Qt.prototype,"defaultYear",void 0),Wt([ue({attribute:!1})],Qt.prototype,"availabilities",void 0),Wt([ue({attribute:!1})],Qt.prototype,"selectedDate",null),Wt([le()],Qt.prototype,"monthShown",null),Wt([le()],Qt.prototype,"yearShown",void 0),Qt=Wt([ae("date-picker")],Qt);const Vt=(e,t)=>{const n=[];for(let i=0;i<t.length;i+=e)n.push(t.slice(i,i+e));return n};var Kt=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};const Xt=(e,t)=>e.reduce((function(e,t){return e[t.displayTime]=t,e}),{})[t];let Yt=class extends re{constructor(){super(...arguments),this.options=[],this.selectedDateExists=!1}get selectedTime(){return this.selected}render(){var e,t;return 1===(null===(e=this.options)||void 0===e?void 0:e.length)&&(this.selected=Xt(this.options,this.options[0].displayTime)),(null===(t=this.options)||void 0===t?void 0:t.length)?U`
|
|
242
|
-
<div
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
242
|
+
<div>
|
|
243
|
+
<div
|
|
244
|
+
id="optionContainer"
|
|
245
|
+
@click="${e=>{const t=e.target;(null==t?void 0:t.closest(".option:not(.selected)"))&&(this.selected=Xt(this.options,t.innerText)),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}}"
|
|
246
|
+
@keydown="${e=>{var t;const n=e.target;[" ","Enter"].includes(e.key)&&(null==n?void 0:n.closest(".option"))&&(e.preventDefault(),this.selected=n.innerText!==(null===(t=this.selected)||void 0===t?void 0:t.displayTime)?Xt(this.options,n.innerText):void 0,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}}"
|
|
247
|
+
>
|
|
248
|
+
${this.options.map((e=>{var t;return U`<div
|
|
249
|
+
class="option ${fe({selected:(null===(t=this.selected)||void 0===t?void 0:t.displayTime)===e.displayTime})}"
|
|
250
|
+
tabindex="0"
|
|
251
|
+
>
|
|
252
|
+
<span>${e.displayTime}</span>
|
|
253
|
+
</div>`}))}
|
|
254
|
+
</div>
|
|
255
|
+
<p class="timezone-display-text">
|
|
256
|
+
*All times displayed in ${(()=>{const e=new Date,t=Intl.DateTimeFormat().resolvedOptions().timeZone,n=(e=>{const t=new Date(e.getFullYear(),0,1),n=new Date(e.getFullYear(),6,1),i=Math.max(t.getTimezoneOffset(),n.getTimezoneOffset());return e.getTimezoneOffset()<i})(e);switch(t){case"America/New_York":case"America/Indiana/Indianapolis":return n?"EDT":"EST";case"America/Chicago":case"America/Indiana/Knox":return n?"CDT":"CST";case"America/Denver":return n?"MDT":"MST";case"America/Los_Angeles":return n?"PDT":"PST";case"America/Anchorage":return n?"AKDT":"AKST";case"America/Honolulu":return"HST";case"America/Phoenix":return"MST";default:return"Unknown"}})()}
|
|
257
|
+
</p>
|
|
253
258
|
</div>
|
|
254
259
|
`:U` <div id="noAvailabilityText">
|
|
255
260
|
${this.selectedDateExists?U`<p>No available appointments for this day</p>`:U`<p>
|
|
@@ -265,6 +270,11 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
|
|
|
265
270
|
font-family: "Helvetica Neue", Arial;
|
|
266
271
|
}
|
|
267
272
|
|
|
273
|
+
.timezone-display-text {
|
|
274
|
+
font-size: 11px;
|
|
275
|
+
opacity: 0.5;
|
|
276
|
+
}
|
|
277
|
+
|
|
268
278
|
#optionContainer {
|
|
269
279
|
display: flex;
|
|
270
280
|
flex-wrap: wrap;
|
|
@@ -981,11 +991,13 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
981
991
|
.availabilities=${qn()(this.availabilitiesGroupedByDay,(e=>e.map((e=>new Date(e.offset)))))}
|
|
982
992
|
@change=${e=>{this.tourType===ai.Self&&this.sgtUrl?window.open(this.sgtUrl,"_blank"):this.tourType===ai.Guided&&this.escortedToursLink?window.open(this.escortedToursLink,"_blank"):this.tourType===ai.Virtual&&this.virtualToursLink?window.open(this.virtualToursLink,"_blank"):e.target instanceof Qt&&(this.selectedDate=e.target.selectedDate)}}
|
|
983
993
|
></date-picker>
|
|
984
|
-
<
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
994
|
+
<div>
|
|
995
|
+
<time-picker
|
|
996
|
+
?selecteddateexists=${!!this.selectedDate}
|
|
997
|
+
.options=${this.selectedDate?null===(e=this.availabilitiesGroupedByDay[Lt(this.selectedDate,"y-MM-dd")])||void 0===e?void 0:e.sort(((e,t)=>function(e,t){Ue(2,arguments);var n=qe(e),i=qe(t),r=n.getTime()-i.getTime();return r<0?-1:r>0?1:r}(yn(e.datetime),yn(t.datetime)))).map((e=>({dateWithTimeZoneOffset:e,displayTime:Lt(yn(`${e.datetime}${e.offset}`),"h:mmaaa")}))):[]}
|
|
998
|
+
@change=${e=>{if(e.target instanceof Yt){if(!this.selectedDate)return;const t=this.availabilitiesGroupedByDay[Lt(new Date(this.selectedDate),"y-MM-dd")],n=e.target.selectedTime?t.indexOf(e.target.selectedTime.dateWithTimeZoneOffset):null;this.selectedTime=null!==n?t[n]:null}}}
|
|
999
|
+
></time-picker>
|
|
1000
|
+
</div>
|
|
989
1001
|
</div>
|
|
990
1002
|
</div>`}closeButton(){return U`<button id="close-button" @click=${this.onCloseClicked}>
|
|
991
1003
|
<svg
|
|
@@ -3542,7 +3554,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
3542
3554
|
>
|
|
3543
3555
|
I agree
|
|
3544
3556
|
</button>
|
|
3545
|
-
</div>`;var Mr=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let Dr=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.isMinimized=!1,this.brandColor=null,this.chatId="",this.analytics=null,this.launcher=null,this.building=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=zn.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.showTourNextToChat=!1,this.displayPubnubChat=!1,this.myPubnub=null,this.enabledChatWidgets={call:!0,chat:!0,email:!0,text:!0,sst:!0},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.launcherRef=Ae(),this.firstUpdated=async()=>{await this.setBuildingDerivedInfo(),await this.initializeChatVariables(),this.handleChatInitializeAnalytics()},this.setBuildingDerivedInfo=async()=>{var e,n,i,r,o,a,s,u,l,d,c,p,h,f,m,g,v,y;if(!this.buildingSlug||!this.orgSlug)return;const b=await li(this.orgSlug,this.buildingSlug);if(b.conversationMaintenanceMode)return void console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear.");if(1!==b.active)return;b&&this.orgSlug&&Ur(this.orgSlug,this.buildingSlug);const[w,S,T,A,x,O,C]=await Promise.all([hi(this.buildingSlug),ur(this.buildingSlug),fi(this.buildingSlug,document.referrer),Wn(this.buildingSlug),Qn(this.buildingSlug),pi(b.id),Vn(this.buildingSlug)]);b.phoneNumber=Ne(b.phoneNumber),this.building=b,this.designConcept=null!==(e=null==w?void 0:w.abTestType)&&void 0!==e?e:"",this.leadSources=S,this.currentLeadSource=T,this.featureFlagShowDropdown=A;const I=await(async e=>{try{const n="https://app.meetelise.com",i=await t().get(`${n}/platformApi/webchat/${e}/phone-number`);if(i.data)return i.data}catch(t){return ii({logType:ni.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var N,E;this.enabledChatWidgets={call:O&&!O.isGlobalDefault?O.config.shouldShowPhone:null===(r=null===(i=null===(n=this.building)||void 0===n?void 0:n.chatWidgets)||void 0===i?void 0:i.includes("CALL"))||void 0===r||r,chat:O&&!O.isGlobalDefault?O.config.shouldShowChat:null===(s=null===(a=null===(o=this.building)||void 0===o?void 0:o.chatWidgets)||void 0===a?void 0:a.includes("CHAT"))||void 0===s||s,email:O&&!O.isGlobalDefault?O.config.shouldShowEmail:null===(d=null===(l=null===(u=this.building)||void 0===u?void 0:u.chatWidgets)||void 0===l?void 0:l.includes("EMAIL"))||void 0===d||d,text:(O&&!O.isGlobalDefault?O.config.shouldShowText:null===(h=null===(p=null===(c=this.building)||void 0===c?void 0:c.chatWidgets)||void 0===p?void 0:p.includes("SMS"))||void 0===h||h)&&!!I,sst:O&&!O.isGlobalDefault?O.config.shouldShowSst:null===(g=null===(m=null===(f=this.building)||void 0===f?void 0:f.chatWidgets)||void 0===m?void 0:m.includes("SST"))||void 0===g||g},this.enabledChatWidgets.sst?(E=this.handleTourClicked,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");t&&t.startsWith("https://app.meetelise.com/")&&e.addEventListener("click",(e=>{e.preventDefault(),E(e)}))}))):this.currentLeadSource&&(N=this.currentLeadSource,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");if(t&&t.startsWith("https://app.meetelise.com/")){const n=t.includes("?")?"&":"?";e.setAttribute("href",t+n+`eliseParsedLeadSource=${encodeURIComponent(N)}`)}}))),O&&O.config&&(this.brandColor=null!==(v=O.config.primaryColor)&&void 0!==v?v:null,this.webchatConfigHasAutoOpenChat=O.config.autoOpenChat,this.requiresConsent=O.config.requiresConsent,this.privacyPolicyUrl=null!==(y=O.config.privacyPolicyUrl)&&void 0!==y?y:this.privacyPolicyUrl,O.config.displayStyle===di.MINIMIZED&&(this.isMinimized=!0),O.config.displayStyle===di.PILLS&&(this.designConcept=null),O.config.displayStyle===di.EMOJI&&(this.designConcept=di.EMOJI)),null===this.brandColor&&(this.brandColor=Fe);let R=null;x&&(R=await async function(e,n){try{const i=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${n}`);return i.data?{number:Ne(i.data.number),isMatch:i.data.isMatch,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,this.currentLeadSource)),C&&(null==R?void 0:R.number)&&xr(R.number,this.orgSlug,this.buildingSlug);const _=localStorage.getItem("eliseai_phone_number_devtest");_&&(console.info("Using dev test phone number: ",_),xr(_,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=R||{number:this.building.phoneNumber,isMatch:!1,isPropertyWebsiteCatchall:!0},this.currentLeadSource&&(this.leadSources.includes(this.currentLeadSource)||this.leadSources.push(this.currentLeadSource)),Fn(this.building.id)},this.initializeChatVariables=async()=>{if(!this.building)return;if(this.building.conversationMaintenanceMode)return void console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear.");const n=(e=>{const t=localStorage.getItem("com.elise.webchat.slug="+e);if(t)try{const n=JSON.parse(t),i={leadId:n.leadId,timestamp:new Date(n.timestamp),buildingSlug:n.buildingSlug,initiatedChat:n.initiatedChat};if(Tr(e,i))return i}catch(e){console.warn("Error getting chat storage key")}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}})(this.buildingSlug),i=Tr(this.buildingSlug,n)?n:Sr(this.buildingSlug,!1);if(!i.leadId)throw new Error("Lead ID is null");this.myPubnub=new class{constructor(e,t,n,i=null,r){this.apiHost="https://app.meetelise.com",this.building=null,this.eliseResponseTimeout=null,this.pubnub=null,this.leadUserId="",this.channel="",this.leadSource=null,this.chatListener=null,this.messages=[],this.listenerParams={message:e=>{var t;e.message.messageType!==Ar.noReply&&(this.messages=[...this.messages,{channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken}]);const n="eliseai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.messages,isLoading:n}),!n&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=n}},this.isLoadingMessages=!1,this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){ii({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:ni.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.handleDisconnect=()=>{this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.removeChatListeners()},this.removeChatListeners=()=>{this.pubnub&&this.channel&&(this.pubnub.unsubscribe({channels:[this.channel]}),this.pubnub.removeListener(this.listenerParams))},this.sendMessage=async e=>{if(e){if(!this.pubnub){const e=Sr(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken((async()=>{var t,n;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),ii({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:ni.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}),6e4),await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(t=this.building)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,userId:null===(n=this.building)||void 0===n?void 0:n.userId,leadSource:this.leadSource}}))})),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.buildingSlug=e,this.building=t,this.orgSlug=n,this.leadSource=i,this.leadUserId=r,this.channel=`webchat_${r}`}addChatListener(e){this.chatListener=e}async initializePubnub(e){if(!e.leadId)return;this.leadUserId=e.leadId;const t=await this.fetchToken(this.leadUserId,this.channel);return t?(this.pubnub=new(pr())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,n){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${n}`)).data}catch(e){ii({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:ni.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return null}async fetchChannelExists(e){try{return(await t().get(`${this.apiHost}/platformApi/webchat/check-channel-exists?channel_name=${e}`)).data}catch(e){ii({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:ni.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(n){if(n instanceof e.AxiosError&&n&&n.response&&403===n.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const e=await this.fetchToken(this.leadUserId,this.channel);if(!e)return;this.pubnub.setAuthKey(e.auth.result.token),await t()}catch(e){ii({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:ni.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(){var e;try{const t=await new Promise(((e,t)=>{this.pubnub&&this.channel&&this.pubnub.fetchMessages({channels:[this.channel],count:100},((n,i)=>{n.error?(ii({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{channel:this.channel,status:n,response:i},logType:ni.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),t(n)):e(i)}))}));if(this.channel&&0!==Object.keys(t.channels).length){const n=t.channels[this.channel],i=[];n.forEach((e=>{e.uuid&&i.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})})),this.messages=i.filter((e=>e.message.messageType!==Ar.noReply)),null===(e=this.chatListener)||void 0===e||e.call(this,{messages:this.messages,isLoading:!1})}}catch(e){ii({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:ni.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}(this.buildingSlug,this.building,this.orgSlug,this.currentLeadSource,i.leadId),i.initiatedChat&&await this.myPubnub.initializePubnub(n),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(this.webchatConfigHasAutoOpenChat)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!gn(yn(t)));return!!e&&!!n&&!un()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",pn(function(e,t){Ue(2,arguments);var n=et(t);return tt(e,6e4*n)}(new Date,15)))},this.handleContactClicked=e=>{var t;this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickEmailOption(e)},this.handleTourClicked=e=>{var t,n;this.showTourNextToChat?null===(t=this.launcherRef.value)||void 0===t||t.onClickSSTOption(e):(this.hideLauncher?this.showTourNextToChat=!0:this.displayPubnubChat=!1,this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickSSTOption(e))},this.handleContactTabClicked=e=>{var t;this.displayPubnubChat=!1,this.showTourNextToChat=!1,this.hideLauncher=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickPhoneOption(e)},this.adjustPositionChatAdditionalActions=()=>{var e,t,n,i;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!r)return;const o=null===(i=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.getElementById("pubnub-chat-container"),a=null==o?void 0:o.getBoundingClientRect();a&&(r.style.left=`${a.left}px`,r.style.top=`${a.bottom}px`)},this.onClickMinimize=e=>{e.preventDefault(),e.stopPropagation(),this.isMinimized=!this.isMinimized,this.showTourNextToChat=!1},this.attachOnClickToLauncher=()=>{const e=this.launcherRef.value;e&&(e.onChatTapped=async()=>{this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0})},this.renderChatAdditionalActions=(e,t)=>U` <div
|
|
3557
|
+
</div>`;var Mr=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let Dr=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.isMinimized=!1,this.brandColor=null,this.chatId="",this.analytics=null,this.launcher=null,this.building=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=zn.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.showTourNextToChat=!1,this.displayPubnubChat=!1,this.myPubnub=null,this.enabledChatWidgets={call:!0,chat:!0,email:!0,text:!0,sst:!0},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.launcherRef=Ae(),this.firstUpdated=async()=>{await this.setBuildingDerivedInfo(),await this.initializeChatVariables(),this.handleChatInitializeAnalytics()},this.setBuildingDerivedInfo=async()=>{var e,n,i,r,o,a,s,u,l,d,c,p,h,f,m,g,v,y;if(!this.buildingSlug||!this.orgSlug)return;const b=await li(this.orgSlug,this.buildingSlug);if(b.conversationMaintenanceMode)return void console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear.");if(1!==b.active)return void console.warn("MeetElise has detected this building is NOT active. Chat icon will not appear.");b&&this.orgSlug&&Ur(this.orgSlug,this.buildingSlug);const[w,S,T,A,x,O,C]=await Promise.all([hi(this.buildingSlug),ur(this.buildingSlug),fi(this.buildingSlug,document.referrer),Wn(this.buildingSlug),Qn(this.buildingSlug),pi(b.id),Vn(this.buildingSlug)]);b.phoneNumber=Ne(b.phoneNumber),this.building=b,this.designConcept=null!==(e=null==w?void 0:w.abTestType)&&void 0!==e?e:"",this.leadSources=S,this.currentLeadSource=T,this.featureFlagShowDropdown=A;const I=await(async e=>{try{const n="https://app.meetelise.com",i=await t().get(`${n}/platformApi/webchat/${e}/phone-number`);if(i.data)return i.data}catch(t){return ii({logType:ni.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var N,E;this.enabledChatWidgets={call:O&&!O.isGlobalDefault?O.config.shouldShowPhone:null===(r=null===(i=null===(n=this.building)||void 0===n?void 0:n.chatWidgets)||void 0===i?void 0:i.includes("CALL"))||void 0===r||r,chat:O&&!O.isGlobalDefault?O.config.shouldShowChat:null===(s=null===(a=null===(o=this.building)||void 0===o?void 0:o.chatWidgets)||void 0===a?void 0:a.includes("CHAT"))||void 0===s||s,email:O&&!O.isGlobalDefault?O.config.shouldShowEmail:null===(d=null===(l=null===(u=this.building)||void 0===u?void 0:u.chatWidgets)||void 0===l?void 0:l.includes("EMAIL"))||void 0===d||d,text:(O&&!O.isGlobalDefault?O.config.shouldShowText:null===(h=null===(p=null===(c=this.building)||void 0===c?void 0:c.chatWidgets)||void 0===p?void 0:p.includes("SMS"))||void 0===h||h)&&!!I,sst:O&&!O.isGlobalDefault?O.config.shouldShowSst:null===(g=null===(m=null===(f=this.building)||void 0===f?void 0:f.chatWidgets)||void 0===m?void 0:m.includes("SST"))||void 0===g||g},this.enabledChatWidgets.sst?(E=this.handleTourClicked,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");t&&t.startsWith("https://app.meetelise.com/")&&e.addEventListener("click",(e=>{e.preventDefault(),E(e)}))}))):this.currentLeadSource&&(N=this.currentLeadSource,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");if(t&&t.startsWith("https://app.meetelise.com/")){const n=t.includes("?")?"&":"?";e.setAttribute("href",t+n+`eliseParsedLeadSource=${encodeURIComponent(N)}`)}}))),O&&O.config&&(this.brandColor=null!==(v=O.config.primaryColor)&&void 0!==v?v:null,this.webchatConfigHasAutoOpenChat=O.config.autoOpenChat,this.requiresConsent=O.config.requiresConsent,this.privacyPolicyUrl=null!==(y=O.config.privacyPolicyUrl)&&void 0!==y?y:this.privacyPolicyUrl,O.config.displayStyle===di.MINIMIZED&&(this.isMinimized=!0),O.config.displayStyle===di.PILLS&&(this.designConcept=null),O.config.displayStyle===di.EMOJI&&(this.designConcept=di.EMOJI)),null===this.brandColor&&(this.brandColor=Fe);let R=null;x&&(R=await async function(e,n){try{const i=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${n}`);return i.data?{number:Ne(i.data.number),isMatch:i.data.isMatch,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,this.currentLeadSource)),C&&(null==R?void 0:R.number)&&xr(R.number,this.orgSlug,this.buildingSlug);const _=localStorage.getItem("eliseai_phone_number_devtest");_&&(console.info("Using dev test phone number: ",_),xr(_,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=R||{number:this.building.phoneNumber,isMatch:!1,isPropertyWebsiteCatchall:!0},this.currentLeadSource&&(this.leadSources.includes(this.currentLeadSource)||this.leadSources.push(this.currentLeadSource)),Fn(this.building.id)},this.initializeChatVariables=async()=>{if(!this.building)return;if(this.building.conversationMaintenanceMode)return void console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear.");const n=(e=>{const t=localStorage.getItem("com.elise.webchat.slug="+e);if(t)try{const n=JSON.parse(t),i={leadId:n.leadId,timestamp:new Date(n.timestamp),buildingSlug:n.buildingSlug,initiatedChat:n.initiatedChat};if(Tr(e,i))return i}catch(e){console.warn("Error getting chat storage key")}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}})(this.buildingSlug),i=Tr(this.buildingSlug,n)?n:Sr(this.buildingSlug,!1);if(!i.leadId)throw new Error("Lead ID is null");this.myPubnub=new class{constructor(e,t,n,i=null,r){this.apiHost="https://app.meetelise.com",this.building=null,this.eliseResponseTimeout=null,this.pubnub=null,this.leadUserId="",this.channel="",this.leadSource=null,this.chatListener=null,this.messages=[],this.listenerParams={message:e=>{var t;e.message.messageType!==Ar.noReply&&(this.messages=[...this.messages,{channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken}]);const n="eliseai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.messages,isLoading:n}),!n&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=n}},this.isLoadingMessages=!1,this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){ii({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:ni.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.handleDisconnect=()=>{this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.removeChatListeners()},this.removeChatListeners=()=>{this.pubnub&&this.channel&&(this.pubnub.unsubscribe({channels:[this.channel]}),this.pubnub.removeListener(this.listenerParams))},this.sendMessage=async e=>{if(e){if(!this.pubnub){const e=Sr(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken((async()=>{var t,n;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),ii({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:ni.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}),6e4),await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(t=this.building)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,userId:null===(n=this.building)||void 0===n?void 0:n.userId,leadSource:this.leadSource}}))})),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.buildingSlug=e,this.building=t,this.orgSlug=n,this.leadSource=i,this.leadUserId=r,this.channel=`webchat_${r}`}addChatListener(e){this.chatListener=e}async initializePubnub(e){if(!e.leadId)return;this.leadUserId=e.leadId;const t=await this.fetchToken(this.leadUserId,this.channel);return t?(this.pubnub=new(pr())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,n){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${n}`)).data}catch(e){ii({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:ni.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return null}async fetchChannelExists(e){try{return(await t().get(`${this.apiHost}/platformApi/webchat/check-channel-exists?channel_name=${e}`)).data}catch(e){ii({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:ni.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(n){if(n instanceof e.AxiosError&&n&&n.response&&403===n.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const e=await this.fetchToken(this.leadUserId,this.channel);if(!e)return;this.pubnub.setAuthKey(e.auth.result.token),await t()}catch(e){ii({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:ni.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(){var e;try{const t=await new Promise(((e,t)=>{this.pubnub&&this.channel&&this.pubnub.fetchMessages({channels:[this.channel],count:100},((n,i)=>{n.error?(ii({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{channel:this.channel,status:n,response:i},logType:ni.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),t(n)):e(i)}))}));if(this.channel&&0!==Object.keys(t.channels).length){const n=t.channels[this.channel],i=[];n.forEach((e=>{e.uuid&&i.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})})),this.messages=i.filter((e=>e.message.messageType!==Ar.noReply)),null===(e=this.chatListener)||void 0===e||e.call(this,{messages:this.messages,isLoading:!1})}}catch(e){ii({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:ni.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}(this.buildingSlug,this.building,this.orgSlug,this.currentLeadSource,i.leadId),i.initiatedChat&&await this.myPubnub.initializePubnub(n),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(this.webchatConfigHasAutoOpenChat)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!gn(yn(t)));return!!e&&!!n&&!un()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",pn(function(e,t){Ue(2,arguments);var n=et(t);return tt(e,6e4*n)}(new Date,15)))},this.handleContactClicked=e=>{var t;this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickEmailOption(e)},this.handleTourClicked=e=>{var t,n;this.showTourNextToChat?null===(t=this.launcherRef.value)||void 0===t||t.onClickSSTOption(e):(this.hideLauncher?this.showTourNextToChat=!0:this.displayPubnubChat=!1,this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickSSTOption(e))},this.handleContactTabClicked=e=>{var t;this.displayPubnubChat=!1,this.showTourNextToChat=!1,this.hideLauncher=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickPhoneOption(e)},this.adjustPositionChatAdditionalActions=()=>{var e,t,n,i;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!r)return;const o=null===(i=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.getElementById("pubnub-chat-container"),a=null==o?void 0:o.getBoundingClientRect();a&&(r.style.left=`${a.left}px`,r.style.top=`${a.bottom}px`)},this.onClickMinimize=e=>{e.preventDefault(),e.stopPropagation(),this.isMinimized=!this.isMinimized,this.showTourNextToChat=!1},this.attachOnClickToLauncher=()=>{const e=this.launcherRef.value;e&&(e.onChatTapped=async()=>{this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0})},this.renderChatAdditionalActions=(e,t)=>U` <div
|
|
3546
3558
|
id=${e}
|
|
3547
3559
|
class=${fe({showTab:t,hideTab:!t})}
|
|
3548
3560
|
>
|
|
@@ -2,6 +2,7 @@ import { LitElement, html, TemplateResult, css } from "lit";
|
|
|
2
2
|
import { customElement, property, state } from "lit/decorators.js";
|
|
3
3
|
import { classMap } from "lit/directives/class-map.js";
|
|
4
4
|
import { DateWithTimeZoneOffset } from "../../getAvailabilities";
|
|
5
|
+
import { getTimezoneAbbreviation } from "../../getTimezoneString";
|
|
5
6
|
|
|
6
7
|
export type TimePickerOption = {
|
|
7
8
|
displayTime: string;
|
|
@@ -44,6 +45,11 @@ export class TimePicker extends LitElement {
|
|
|
44
45
|
font-family: "Helvetica Neue", Arial;
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
.timezone-display-text {
|
|
49
|
+
font-size: 11px;
|
|
50
|
+
opacity: 0.5;
|
|
51
|
+
}
|
|
52
|
+
|
|
47
53
|
#optionContainer {
|
|
48
54
|
display: flex;
|
|
49
55
|
flex-wrap: wrap;
|
|
@@ -113,48 +119,57 @@ export class TimePicker extends LitElement {
|
|
|
113
119
|
}
|
|
114
120
|
return this.options?.length
|
|
115
121
|
? html`
|
|
116
|
-
<div
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
this.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
new Event("change", { bubbles: true, composed: true })
|
|
128
|
-
);
|
|
129
|
-
}}"
|
|
130
|
-
@keydown="${(e: KeyboardEvent) => {
|
|
131
|
-
const target = e.target as HTMLElement | undefined;
|
|
132
|
-
if (
|
|
133
|
-
[" ", "Enter"].includes(e.key) &&
|
|
134
|
-
target?.closest(".option")
|
|
135
|
-
) {
|
|
136
|
-
e.preventDefault();
|
|
137
|
-
this.selected =
|
|
138
|
-
target.innerText !== this.selected?.displayTime
|
|
139
|
-
? getDateWithTimezoneOffset(this.options, target.innerText)
|
|
140
|
-
: undefined;
|
|
122
|
+
<div>
|
|
123
|
+
<div
|
|
124
|
+
id="optionContainer"
|
|
125
|
+
@click="${(e: MouseEvent) => {
|
|
126
|
+
const target = e.target as HTMLElement | undefined;
|
|
127
|
+
|
|
128
|
+
if (target?.closest(".option:not(.selected)"))
|
|
129
|
+
this.selected = getDateWithTimezoneOffset(
|
|
130
|
+
this.options,
|
|
131
|
+
target.innerText
|
|
132
|
+
);
|
|
141
133
|
this.dispatchEvent(
|
|
142
134
|
new Event("change", { bubbles: true, composed: true })
|
|
143
135
|
);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
136
|
+
}}"
|
|
137
|
+
@keydown="${(e: KeyboardEvent) => {
|
|
138
|
+
const target = e.target as HTMLElement | undefined;
|
|
139
|
+
if (
|
|
140
|
+
[" ", "Enter"].includes(e.key) &&
|
|
141
|
+
target?.closest(".option")
|
|
142
|
+
) {
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
this.selected =
|
|
145
|
+
target.innerText !== this.selected?.displayTime
|
|
146
|
+
? getDateWithTimezoneOffset(
|
|
147
|
+
this.options,
|
|
148
|
+
target.innerText
|
|
149
|
+
)
|
|
150
|
+
: undefined;
|
|
151
|
+
this.dispatchEvent(
|
|
152
|
+
new Event("change", { bubbles: true, composed: true })
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}}"
|
|
156
|
+
>
|
|
157
|
+
${this.options.map(
|
|
158
|
+
(option) =>
|
|
159
|
+
html`<div
|
|
160
|
+
class="option ${classMap({
|
|
161
|
+
selected:
|
|
162
|
+
this.selected?.displayTime === option.displayTime,
|
|
163
|
+
})}"
|
|
164
|
+
tabindex="0"
|
|
165
|
+
>
|
|
166
|
+
<span>${option.displayTime}</span>
|
|
167
|
+
</div>`
|
|
168
|
+
)}
|
|
169
|
+
</div>
|
|
170
|
+
<p class="timezone-display-text">
|
|
171
|
+
*All times displayed in ${getTimezoneAbbreviation()}
|
|
172
|
+
</p>
|
|
158
173
|
</div>
|
|
159
174
|
`
|
|
160
175
|
: html` <div id="noAvailabilityText">
|
|
@@ -644,42 +644,44 @@ export class TourScheduler extends LitElement {
|
|
|
644
644
|
}
|
|
645
645
|
}}
|
|
646
646
|
></date-picker>
|
|
647
|
-
<
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
.map((date) => {
|
|
657
|
-
return {
|
|
658
|
-
dateWithTimeZoneOffset: date,
|
|
659
|
-
displayTime: format(
|
|
660
|
-
parseISO(`${date.datetime}${date.offset}`),
|
|
661
|
-
"h:mmaaa"
|
|
662
|
-
),
|
|
663
|
-
};
|
|
664
|
-
})
|
|
665
|
-
: []}
|
|
666
|
-
@change=${(e: Event) => {
|
|
667
|
-
if (e.target instanceof TimePicker) {
|
|
668
|
-
if (!this.selectedDate) return;
|
|
669
|
-
const daysAvailabilities =
|
|
670
|
-
this.availabilitiesGroupedByDay[
|
|
671
|
-
format(new Date(this.selectedDate), "y-MM-dd")
|
|
672
|
-
];
|
|
673
|
-
const index = e.target.selectedTime
|
|
674
|
-
? daysAvailabilities.indexOf(
|
|
675
|
-
e.target.selectedTime.dateWithTimeZoneOffset
|
|
647
|
+
<div>
|
|
648
|
+
<time-picker
|
|
649
|
+
?selecteddateexists=${!!this.selectedDate}
|
|
650
|
+
.options=${this.selectedDate
|
|
651
|
+
? this.availabilitiesGroupedByDay[
|
|
652
|
+
format(this.selectedDate, "y-MM-dd")
|
|
653
|
+
]
|
|
654
|
+
?.sort((a, b) =>
|
|
655
|
+
compareAsc(parseISO(a.datetime), parseISO(b.datetime))
|
|
676
656
|
)
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
657
|
+
.map((date) => {
|
|
658
|
+
return {
|
|
659
|
+
dateWithTimeZoneOffset: date,
|
|
660
|
+
displayTime: format(
|
|
661
|
+
parseISO(`${date.datetime}${date.offset}`),
|
|
662
|
+
"h:mmaaa"
|
|
663
|
+
),
|
|
664
|
+
};
|
|
665
|
+
})
|
|
666
|
+
: []}
|
|
667
|
+
@change=${(e: Event) => {
|
|
668
|
+
if (e.target instanceof TimePicker) {
|
|
669
|
+
if (!this.selectedDate) return;
|
|
670
|
+
const daysAvailabilities =
|
|
671
|
+
this.availabilitiesGroupedByDay[
|
|
672
|
+
format(new Date(this.selectedDate), "y-MM-dd")
|
|
673
|
+
];
|
|
674
|
+
const index = e.target.selectedTime
|
|
675
|
+
? daysAvailabilities.indexOf(
|
|
676
|
+
e.target.selectedTime.dateWithTimeZoneOffset
|
|
677
|
+
)
|
|
678
|
+
: null;
|
|
679
|
+
this.selectedTime =
|
|
680
|
+
index !== null ? daysAvailabilities[index] : null;
|
|
681
|
+
}
|
|
682
|
+
}}
|
|
683
|
+
></time-picker>
|
|
684
|
+
</div>
|
|
683
685
|
</div>
|
|
684
686
|
</div>`;
|
|
685
687
|
}
|
|
@@ -200,6 +200,10 @@ export class MEChat extends LitElement {
|
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
202
|
if (building.active !== 1) {
|
|
203
|
+
// eslint-disable-next-line no-console
|
|
204
|
+
console.warn(
|
|
205
|
+
"MeetElise has detected this building is NOT active. Chat icon will not appear."
|
|
206
|
+
);
|
|
203
207
|
return;
|
|
204
208
|
}
|
|
205
209
|
if (building && this.orgSlug) {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const isDaylightSavingTime = (date: Date): boolean => {
|
|
2
|
+
const jan = new Date(date.getFullYear(), 0, 1);
|
|
3
|
+
const jul = new Date(date.getFullYear(), 6, 1);
|
|
4
|
+
const stdTimezoneOffset = Math.max(
|
|
5
|
+
jan.getTimezoneOffset(),
|
|
6
|
+
jul.getTimezoneOffset()
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
return date.getTimezoneOffset() < stdTimezoneOffset;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const getTimezoneAbbreviation = (): string => {
|
|
13
|
+
const date = new Date();
|
|
14
|
+
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
15
|
+
const isDST = isDaylightSavingTime(date);
|
|
16
|
+
|
|
17
|
+
switch (timeZone) {
|
|
18
|
+
case "America/New_York":
|
|
19
|
+
return isDST ? "EDT" : "EST";
|
|
20
|
+
case "America/Chicago":
|
|
21
|
+
return isDST ? "CDT" : "CST";
|
|
22
|
+
case "America/Denver":
|
|
23
|
+
return isDST ? "MDT" : "MST";
|
|
24
|
+
case "America/Los_Angeles":
|
|
25
|
+
return isDST ? "PDT" : "PST";
|
|
26
|
+
case "America/Anchorage":
|
|
27
|
+
return isDST ? "AKDT" : "AKST";
|
|
28
|
+
case "America/Honolulu":
|
|
29
|
+
return "HST";
|
|
30
|
+
case "America/Phoenix":
|
|
31
|
+
return "MST";
|
|
32
|
+
case "America/Indiana/Indianapolis":
|
|
33
|
+
return isDST ? "EDT" : "EST";
|
|
34
|
+
case "America/Indiana/Knox":
|
|
35
|
+
return isDST ? "CDT" : "CST";
|
|
36
|
+
default:
|
|
37
|
+
return "Unknown";
|
|
38
|
+
}
|
|
39
|
+
};
|