@meetelise/chat 1.20.232 → 1.20.233

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.20.232",
3
+ "version": "1.20.233",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -132,7 +132,6 @@
132
132
 
133
133
  MEChat.start({
134
134
  organization: "elise-ai",
135
- //building: "test-yardi-building",
136
135
  building: "930196d8-3527-11ee-a65a-b70940a36fe6",
137
136
  onWidgetLoaded: onWidgetLoaded,
138
137
  // organization: "00f18938-9632-40b9-8d7f-f30e219c94fc",
@@ -3511,7 +3511,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3511
3511
  transform: rotate(360deg);
3512
3512
  }
3513
3513
  }
3514
- `,Qr=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}([ae("mini-loader")],Qr);var Vr=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 Kr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.loadingPreviews=!0,this.websitePreviewInfo=[],this.imagesToDisplay=[],this.imageUrlError=[]}isMessageStillStreamingChunks(){if(!this.message)return!1;const e=this.message.chunks.find((e=>e.isDone));return!e||this.message.chunks.length===e.order}updated(e){if(this.onMount(),!e.has("message"))return;if(!this.message)return;const{hyperlinks:t,markedText:n}=this.mapAndMarkHyperLinks(this.message.message),i=/(https?:\/\/[^\s]+)/g,r=[],o=[];this.parsedMessage=U`${n.trim().split("\n").map((e=>{const n=this.sanitizeMarkdownText(e),a=this.preserveHTMLTags(n);return a?U`${a.map((e=>{if(t.find((t=>t.id===e))){const n=t.find((t=>t.id===e));if(!n)return;return o.push({redirectTo:null==n?void 0:n.link,source:null==n?void 0:n.link}),U`<a
3514
+ `,Qr=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}([ae("mini-loader")],Qr);var Vr=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 Kr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.loadingPreviews=!0,this.websitePreviewInfo=[],this.imagesToDisplay=[],this.imageUrlError=[],this.isLeadMessage=!1}isMessageStillStreamingChunks(){if(!this.message)return!1;const e=this.message.chunks.find((e=>e.isDone));return!e||this.message.chunks.length===e.order}updated(e){if(this.onMount(),!e.has("message"))return;if(!this.message)return;const{hyperlinks:t,markedText:n}=this.mapAndMarkHyperLinks(this.message.message),i=/(https?:\/\/[^\s]+)/g,r=[],o=[];this.parsedMessage=U`${n.trim().split("\n").map((e=>{const n=this.sanitizeMarkdownText(e),a=this.preserveHTMLTags(n);return a?U`${a.map((e=>{if(t.find((t=>t.id===e))){const n=t.find((t=>t.id===e));if(!n)return;return o.push({redirectTo:null==n?void 0:n.link,source:null==n?void 0:n.link}),U`<a
3515
3515
  class="redirect-link"
3516
3516
  href="${null==n?void 0:n.link}"
3517
3517
  target="_blank"
@@ -3523,7 +3523,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3523
3523
  target="_blank"
3524
3524
  rel="noopener noreferrer"
3525
3525
  >${t}
3526
- </a>`}return U`${Wr(Gr().sanitize(e))} `}))}<br />`:U``}))}`,this.imagesToDisplay=o,Promise.all(r).then((e=>{this.websitePreviewInfo=e}))}preserveHTMLTags(e){var t;const n=e.match(/(<\/?[a-z][^>]*>[^<]*<\/?[a-z]*>|[\w':#$()-]+[.,?!]?|\S)/gi);return null!==(t=null==n?void 0:n.filter((e=>""!==e.trim())))&&void 0!==t?t:[]}sanitizeMarkdownText(e){return e.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*?)\*\*/gim,"<b>$1</b>").replace(/\*(.*?)\*/gim,"<i>$1</i>").trim()}removeTrailingPunctuation(e){return[".",",","!","?",":",";"].includes(e[e.length-1])?this.removeTrailingPunctuation(e.slice(0,-1)):e}mapAndMarkHyperLinks(e){const t=Array.from(e.matchAll(/<https?:\/\/[^|]+\|[^>]+>|<a href="[^"]+"(?: target="[^"]*")?>[^<]+<\/a>|\[.*?\]\([^)]*\.[^)]*\)/g)),n=[],i=t.map((t=>{const n=t[0];if(void 0===t.index)return;const i=e[t.index-1],r=e[t.index+n.length];if(n.startsWith("<https")||n.startsWith("<http"))return{matchedLink:n,link:n.split("|")[0].replace("<",""),hyperlink:n.split("|")[1].replace(">",""),addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)};if(n.startsWith("<a href=")){const e=n.match(/href="([^"]+)"/),t=n.match(/>[^<]+</);return{matchedLink:n,link:e?e[1]:"",hyperlink:t?t[0].slice(1,-1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}{const[e,t]=n.split("](");return{matchedLink:n,link:t?t.slice(0,-1):"",hyperlink:e?e.slice(1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}}));return i.forEach((t=>{if(t&&t.link&&t.hyperlink){const i=Ir().replace(/-/g,"");n.push({link:this.removeTrailingPunctuation(t.link),hyperlink:this.removeTrailingPunctuation(t.hyperlink),mark:t.matchedLink,id:i}),e=e.replace(t.matchedLink,`${t.addSpaceBefore?" ":""}${i}${t.addSpaceAfter?" ":""}`)}})),{hyperlinks:n,markedText:e}}async getLinkData(e){var n,i,r,o;try{const a=(await t().get(e)).data,s=(new DOMParser).parseFromString(a,"text/html");return s?{title:null!==(i=null===(n=s.querySelector("title"))||void 0===n?void 0:n.textContent)&&void 0!==i?i:null,description:(null===(r=s.querySelector('meta[name="description"]'))||void 0===r?void 0:r.getAttribute("content"))||null,image:(null===(o=s.querySelector('meta[property="og:image"]'))||void 0===o?void 0:o.getAttribute("content"))||null,favicon:null,link:e}:{title:null,description:null,image:null,favicon:null,link:e}}catch(t){return console.error("Error fetching website details:",t),{title:null,description:null,image:null,favicon:null,link:e}}}render(){return this.message?U`<div class="message-inner-body">
3526
+ </a>`}return!this.isLeadMessage&&this.invalidMarkdownText(e)?(si({logType:ai.error,logTitle:"[IMPROPER_MARKDOWN]",logData:{message:this.message,word:e}}),U``):U`${Wr(Gr().sanitize(e))} `}))}<br />`:U``}))}`,this.imagesToDisplay=o,Promise.all(r).then((e=>{this.websitePreviewInfo=e}))}invalidMarkdownText(e){return["*","_","`","~",">","<"].some((t=>e===t))}preserveHTMLTags(e){var t;const n=e.match(/(<\/?[a-z][^>]*>[^<]*<\/?[a-z]*>|[^\s]+[.,?!]?|\S)/gi);return null!==(t=null==n?void 0:n.filter((e=>""!==e.trim())))&&void 0!==t?t:[]}sanitizeMarkdownText(e){return e.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*?)\*\*/gim,"<b>$1</b>").replace(/\*(.*?)\*/gim,"<i>$1</i>").trim()}removeTrailingPunctuation(e){return[".",",","!","?",":",";"].includes(e[e.length-1])?this.removeTrailingPunctuation(e.slice(0,-1)):e}mapAndMarkHyperLinks(e){const t=Array.from(e.matchAll(/<https?:\/\/[^|]+\|[^>]+>|<a href="[^"]+"(?: target="[^"]*")?>[^<]+<\/a>|\[.*?\]\([^)]*\.[^)]*\)/g)),n=[],i=t.map((t=>{const n=t[0];if(void 0===t.index)return;const i=e[t.index-1],r=e[t.index+n.length];if(n.startsWith("<https")||n.startsWith("<http"))return{matchedLink:n,link:n.split("|")[0].replace("<",""),hyperlink:n.split("|")[1].replace(">",""),addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)};if(n.startsWith("<a href=")){const e=n.match(/href="([^"]+)"/),t=n.match(/>[^<]+</);return{matchedLink:n,link:e?e[1]:"",hyperlink:t?t[0].slice(1,-1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}{const[e,t]=n.split("](");return{matchedLink:n,link:t?t.slice(0,-1):"",hyperlink:e?e.slice(1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}}));return i.forEach((t=>{if(t&&t.link&&t.hyperlink){const i=Ir().replace(/-/g,"");n.push({link:this.removeTrailingPunctuation(t.link),hyperlink:this.removeTrailingPunctuation(t.hyperlink),mark:t.matchedLink,id:i}),e=e.replace(t.matchedLink,`${t.addSpaceBefore?" ":""}${i}${t.addSpaceAfter?" ":""}`)}})),{hyperlinks:n,markedText:e}}async getLinkData(e){var n,i,r,o;try{const a=(await t().get(e)).data,s=(new DOMParser).parseFromString(a,"text/html");return s?{title:null!==(i=null===(n=s.querySelector("title"))||void 0===n?void 0:n.textContent)&&void 0!==i?i:null,description:(null===(r=s.querySelector('meta[name="description"]'))||void 0===r?void 0:r.getAttribute("content"))||null,image:(null===(o=s.querySelector('meta[property="og:image"]'))||void 0===o?void 0:o.getAttribute("content"))||null,favicon:null,link:e}:{title:null,description:null,image:null,favicon:null,link:e}}catch(t){return console.error("Error fetching website details:",t),{title:null,description:null,image:null,favicon:null,link:e}}}render(){return this.message?U`<div class="message-inner-body">
3527
3527
  ${this.isMessageStillStreamingChunks()?U`<div class="message-loader"><mini-loader></mini-loader></div>`:""}
3528
3528
  <p
3529
3529
  class=${fe({"message-text":!0,"webchat-font__desktop":!dn(),"webchat-font__mobile":dn()})}
@@ -3575,7 +3575,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3575
3575
  bottom: -2px;
3576
3576
  right: -2px;
3577
3577
  }
3578
- `],Vr([ue({attribute:!0})],Kr.prototype,"message",void 0),Vr([ue({attribute:!0})],Kr.prototype,"myPubnub",void 0),Vr([ue({attribute:!0})],Kr.prototype,"onMount",void 0),Vr([le()],Kr.prototype,"loadingPreviews",void 0),Vr([le()],Kr.prototype,"parsedMessage",void 0),Vr([le()],Kr.prototype,"websitePreviewInfo",void 0),Vr([le()],Kr.prototype,"imagesToDisplay",void 0),Vr([le()],Kr.prototype,"imageUrlError",void 0),Kr=Vr([ae("pubnub-message")],Kr);var Xr=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 Yr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.showMediaAsCarousel=!0,this.activeIndex=0}updated(e){this.onMount(),e.has("message")}prevImage(){this.message&&(0===this.activeIndex?this.activeIndex=this.message.media.length-1:this.activeIndex-=1)}nextImage(){this.message&&(this.activeIndex===this.message.media.length-1?this.activeIndex=0:this.activeIndex+=1)}render(){return this.message?this.showMediaAsCarousel?U`<div class="message-inner-body">
3578
+ `],Vr([ue({attribute:!0})],Kr.prototype,"message",void 0),Vr([ue({attribute:!0})],Kr.prototype,"myPubnub",void 0),Vr([ue({attribute:!0})],Kr.prototype,"onMount",void 0),Vr([le()],Kr.prototype,"loadingPreviews",void 0),Vr([le()],Kr.prototype,"parsedMessage",void 0),Vr([le()],Kr.prototype,"websitePreviewInfo",void 0),Vr([le()],Kr.prototype,"imagesToDisplay",void 0),Vr([le()],Kr.prototype,"imageUrlError",void 0),Vr([ue({type:Boolean})],Kr.prototype,"isLeadMessage",void 0),Kr=Vr([ae("pubnub-message")],Kr);var Xr=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 Yr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.showMediaAsCarousel=!0,this.activeIndex=0}updated(e){this.onMount(),e.has("message")}prevImage(){this.message&&(0===this.activeIndex?this.activeIndex=this.message.media.length-1:this.activeIndex-=1)}nextImage(){this.message&&(this.activeIndex===this.message.media.length-1?this.activeIndex=0:this.activeIndex+=1)}render(){return this.message?this.showMediaAsCarousel?U`<div class="message-inner-body">
3579
3579
  <div class="carousel">
3580
3580
  <div
3581
3581
  class="image-container"
@@ -3772,11 +3772,12 @@ otherwise there's some empty space at the bottom of the button, which interferes
3772
3772
  .myPubnub=${this.myPubnub}
3773
3773
  .onMount=${()=>this.scrollToChatBottom()}
3774
3774
  >
3775
- </pubnub-message>`:""}
3775
+ </pubnub-media>`:""}
3776
3776
  ${Mr(e)?U` <pubnub-message
3777
3777
  .message=${e}
3778
3778
  .myPubnub=${this.myPubnub}
3779
3779
  .onMount=${()=>this.scrollToChatBottom()}
3780
+ .isLeadMessage=${e.isLeadMessage}
3780
3781
  >
3781
3782
  </pubnub-message>`:""}
3782
3783
  </li>
@@ -3863,15 +3864,16 @@ otherwise there's some empty space at the bottom of the button, which interferes
3863
3864
  key=${e.timestamp}
3864
3865
  >
3865
3866
  ${Fr(e)?U` <pubnub-media
3866
- .message=${e}
3867
- .myPubnub=${this.myPubnub}
3868
- .onMount=${()=>this.scrollToChatBottom()}
3869
- >
3870
- </pubnub-message>`:""}
3867
+ .message=${e}
3868
+ .myPubnub=${this.myPubnub}
3869
+ .onMount=${()=>this.scrollToChatBottom()}
3870
+ >
3871
+ </pubnub-media>`:""}
3871
3872
  ${Mr(e)?U` <pubnub-message
3872
3873
  .message=${e}
3873
3874
  .myPubnub=${this.myPubnub}
3874
3875
  .onMount=${()=>this.scrollToChatBottom()}
3876
+ .isLeadMessage=${e.isLeadMessage}
3875
3877
  >
3876
3878
  </pubnub-message>`:""}
3877
3879
  </li>
@@ -4022,7 +4024,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
4022
4024
  I agree
4023
4025
  </button>
4024
4026
  </div>
4025
- `;function ao(){return so()?function(){const e=window.location.search,t={};return e.split("?").slice(1).join("&").split("&").forEach((e=>{const[n,i]=e.split("=");n&&i&&(t[decodeURIComponent(n)]=decodeURIComponent(i))})),t}():function(){const e=new URLSearchParams(window.location.search),t=e.has("utm_content"),n=e.has("utm_source");if(t&&!n){const t=e.get("utm_content");e.delete("utm_content"),e.set("utm_source",t)}return Object.fromEntries(e)}()}const so=()=>(window.location.search.match(/\?/g)||[]).length>1;var uo=n(8367),lo=n.n(uo);var co=n(308),po=n.n(co),ho=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 fo=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.mobileStyles={},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=Kn.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.showTourNextToChat=!1,this.displayPubnubChat=!1,this.myPubnub=null,this.LeadSourceClient=null,this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.onWidgetLoaded=po(),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=xe(),this.firstUpdated=async()=>this.setupWebchat(),this.setupWebchat=async()=>{if(!this.buildingSlug||!this.orgSlug)return;const e=await fi(this.orgSlug,this.buildingSlug);e.conversationMaintenanceMode?console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear."):1===e.active?(this.building=e,await this.initializeChatVariables(),await this.handleChatInitializeAnalytics(),await this.setBuildingDerivedInfo(),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(this.webchatConfigHasAutoOpenChat)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1,"true"===localStorage.getItem("isChatOpen")&&(this.hideLauncher=!0,this.displayPubnubChat=!0)):console.warn("MeetElise has detected this building is NOT active. Chat icon will not appear.")},this.setBuildingDerivedInfo=async()=>{var e,n,i,r,o,a,s,u,l,d,c,p,h,f,m,g,v,y,b,w,S,T,x,A,O,C,I,N,E;const R=this.building;if(!R)return;R&&this.orgSlug&&go(this.orgSlug,this.buildingSlug,null!==(n=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.leadSource)&&void 0!==n?n:null);const[_,P,M,F,D,k]=await Promise.all([bi(this.buildingSlug),gr(this.buildingSlug),Xn(this.buildingSlug),Yn(this.buildingSlug),yi(R.id),$n(this.buildingSlug)]);this.building&&(this.building.phoneNumber=Ne(R.phoneNumber)),this.designConcept=null!==(i=null==_?void 0:_.abTestType)&&void 0!==i?i:"",this.leadSources=P,this.featureFlagShowDropdown=M;const U=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 si({logType:ai.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var q,B;this.enabledChatWidgets={call:D&&!D.isGlobalDefault?D.config.shouldShowPhone:null===(a=null===(o=null===(r=this.building)||void 0===r?void 0:r.chatWidgets)||void 0===o?void 0:o.includes("CALL"))||void 0===a||a,chat:D&&!D.isGlobalDefault?D.config.shouldShowChat:null===(l=null===(u=null===(s=this.building)||void 0===s?void 0:s.chatWidgets)||void 0===u?void 0:u.includes("CHAT"))||void 0===l||l,email:D&&!D.isGlobalDefault?D.config.shouldShowEmail:null===(p=null===(c=null===(d=this.building)||void 0===d?void 0:d.chatWidgets)||void 0===c?void 0:c.includes("EMAIL"))||void 0===p||p,text:(D&&!D.isGlobalDefault?D.config.shouldShowText:null===(m=null===(f=null===(h=this.building)||void 0===h?void 0:h.chatWidgets)||void 0===f?void 0:f.includes("SMS"))||void 0===m||m)&&!!U,sst:D&&!D.isGlobalDefault?D.config.shouldShowSst:null===(y=null===(v=null===(g=this.building)||void 0===g?void 0:g.chatWidgets)||void 0===v?void 0:v.includes("SST"))||void 0===y||y},this.enabledChatWidgets.sst?(B=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(),B(e)}))})),((e,t,n)=>{if("be948f76-d8f9-11eb-b710-2bc5b16e7492"===t){const e=document.querySelector('a[href="/schedule-a-tour/"]');e&&e.addEventListener("click",(e=>{e.preventDefault(),n(e)}))}})(this.orgSlug,this.buildingSlug,this.handleTourClicked)):(null===(b=this.LeadSourceClient)||void 0===b?void 0:b.leadSource)&&(q=null!==(S=null===(w=this.LeadSourceClient)||void 0===w?void 0:w.leadSource)&&void 0!==S?S:null,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(q)}`)}}))),D&&D.config&&(this.brandColor=null!==(T=D.config.primaryColor)&&void 0!==T?T:null,this.webchatConfigHasAutoOpenChat=D.config.autoOpenChat,this.requiresConsent=D.config.requiresConsent,this.privacyPolicyUrl=null!==(x=D.config.privacyPolicyUrl)&&void 0!==x?x:this.privacyPolicyUrl,D.config.displayStyle===gi.MINIMIZED&&(this.isMinimized=!0),D.config.displayStyle===gi.PILLS&&(this.designConcept=null),D.config.displayStyle===gi.EMOJI&&(this.designConcept=gi.EMOJI),this.onWidgetLoaded()),null===this.brandColor&&(this.brandColor=Me);const L=null!==(O=null===(A=this.building)||void 0===A?void 0:A.phoneNumber)&&void 0!==O?O:"";let J=null;F&&(J=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.match,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(I=null===(C=this.LeadSourceClient)||void 0===C?void 0:C.leadSource)&&void 0!==I?I:null),J&&!J.isMatch&&(J.number=L)),k&&(null==J?void 0:J.number)&&Ur(J.number,this.orgSlug,this.buildingSlug);const j=localStorage.getItem("eliseai_phone_number_devtest");j&&(console.info("Using dev test phone number: ",j),Ur(j,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=J||{number:L,isMatch:!1,isPropertyWebsiteCatchall:!0};const H=null!==(E=null===(N=this.LeadSourceClient)||void 0===N?void 0:N.leadSource)&&void 0!==E?E:null;H&&(this.leadSources.includes(H)||this.leadSources.push(H)),Bn(R.id)},this.initializeChatVariables=async()=>{var e,n,i,r,o;if(!this.building)return;const a=Rr(this.buildingSlug),s=_r(this.buildingSlug,a)?a:Er(this.buildingSlug,!1);if(!s.leadId)throw new Error("Lead ID is null");this.LeadSourceClient=new class{constructor(){this.chatId=null,this.apiHost="https://app.meetelise.com",this.leadSource=null,this.localStorageTTLHours=4,this.buildingId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,n)=>{const i=ao();this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:i,referrer:document.referrer,parsedUtmSource:i?i.utm_source:null,campaignSources:Object.values(oi()).filter((e=>e))};const r={leadSource:t,leadId:n,buildingSlug:e,timestamp:vn(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(r)),{...r,timestamp:An(r.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const n=JSON.parse(t);if(n.buildingSlug===e&&n.leadSource&&n.leadId&&n.timestamp&&!cn(An(n.timestamp),this.localStorageTTLHours)){try{this.leadSourceInput=n.leadSourceInput}catch(e){console.error("Error parsing leadSourceInput from localStorage")}return n}}catch(e){return null}return null}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:n,referrer:i,campaignSources:r}){try{return(await t().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,{query_params:n,building_slug:e,referrer:i,campaign_sources:r})).data}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:n}){var i,r,o,a,s,u,l;try{if(!this.chatId)return console.error("chatId is not set"),null;if(!this.orgSlug)return console.error("orgId is not set"),null;let d=null,c=null;try{if("f1ba5a20-d207-4e5a-879e-65199e7d0a53"===this.orgSlug){const e=await this.getCookieValue("_ga");e&&(d=e),c=null===(i=window.dataLayer.find((e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)})))||void 0===i?void 0:i.value}}catch(e){console.error("error getting cookie")}return await t().post(`${this.apiHost}/platformApi/webchat/log/lead-source`,{chat_id:this.chatId,webchat_action:e,state_id:n,building_id:this.buildingId,org_slug:this.orgSlug,building_slug:this.buildingSlug,website_origin:null===(r=this.leadSourceInput)||void 0===r?void 0:r.websiteOrigin,website_search:null===(o=this.leadSourceInput)||void 0===o?void 0:o.websiteSearch,query_parameters:null===(a=this.leadSourceInput)||void 0===a?void 0:a.queryParameters,referrer:null===(s=this.leadSourceInput)||void 0===s?void 0:s.referrer,parsed_utm_source:null===(u=this.leadSourceInput)||void 0===u?void 0:u.parsedUtmSource,campaign_sources:null===(l=this.leadSourceInput)||void 0===l?void 0:l.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:lo()(d)?null:d,extras:null!=c?c:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const i=t[n].trim();if(i.startsWith(e+"="))return i.substring((e+"=").length,-1===i.indexOf(";")?void 0:i.indexOf(";"))}return null}catch(e){console.error("error getting cookie value")}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:n}){try{const i={queryParams:ao(),buildingSlug:n,referrer:document.referrer,campaignSources:oi()},r=await this.fetchCurrentParsedLeadSource(i);if(this.leadSource=r,this.buildingId=null,this.orgSlug=t,this.buildingSlug=n,n&&!r){const e=this.getLeadSourceBodyIfValid(n);if(e)return this.leadSource=e.leadSource,this.leadSource}return n&&this.updateLeadSourceLocalStorage(n,r,e),r}catch(e){console.error(e)}return null}},this.myPubnub=new kr(this.buildingSlug,this.building,this.orgSlug,null,s.leadId,this.LeadSourceClient),this.LeadSourceClient.chatId=this.myPubnub.channel,await(null===(e=this.LeadSourceClient)||void 0===e?void 0:e.generateUserLeadSource({leadId:null!==(i=null===(n=this.myPubnub)||void 0===n?void 0:n.leadUserId)&&void 0!==i?i:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug})),this.myPubnub.leadSource=null!==(o=null===(r=this.LeadSourceClient)||void 0===r?void 0:r.leadSource)&&void 0!==o?o:null,s.initiatedChat&&await this.myPubnub.initializePubnub(a)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!Tn(An(t)));return!!e&&!!n&&!dn()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",vn(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.handleKeydownTab=e=>{var t,n,i,r,o,a,s,u,l,d,c,p,h,f,m,g,v,y,b,w;if("Tab"===e.key){const S=this.displayPubnubChat?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"):null!==(m=null!==(l=null===(u=null===(s=null===(a=null===(o=null===(r=this.shadowRoot)||void 0===r?void 0:r.getElementById("meetelise-launcher"))||void 0===o?void 0:o.shadowRoot)||void 0===a?void 0:a.getElementById("email-us-window"))||void 0===s?void 0:s.shadowRoot)||void 0===u?void 0:u.getElementById("email-us-form"))&&void 0!==l?l:null===(f=null===(h=null===(p=null===(c=null===(d=this.shadowRoot)||void 0===d?void 0:d.getElementById("meetelise-launcher"))||void 0===c?void 0:c.shadowRoot)||void 0===p?void 0:p.getElementById("tour-scheduler-window"))||void 0===h?void 0:h.shadowRoot)||void 0===f?void 0:f.getElementById("scheduler-container"))&&void 0!==m?m:null===(w=null===(b=null===(y=null===(v=null===(g=this.shadowRoot)||void 0===g?void 0:g.getElementById("meetelise-launcher"))||void 0===v?void 0:v.shadowRoot)||void 0===y?void 0:y.getElementById("call-us-window"))||void 0===b?void 0:b.shadowRoot)||void 0===w?void 0:w.getElementById("details-window");if(!S)return;e.preventDefault();const T=S.querySelectorAll("input, me-select, textarea, action-confirm-button, [tabindex]"),x=Array.from(T),A=x.findIndex((e=>e.matches(":focus")));x[(A+1)%x.length].focus()}},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,localStorage.setItem("isChatOpen","true")},e.onExitChat=this.onExitChat)},this.onExitChat=()=>{this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,localStorage.setItem("isChatOpen","false")},this.renderChatAdditionalActions=(e,t)=>U` <div
4027
+ `;function ao(){return so()?function(){const e=window.location.search,t={};return e.split("?").slice(1).join("&").split("&").forEach((e=>{const[n,i]=e.split("=");n&&i&&(t[decodeURIComponent(n)]=decodeURIComponent(i))})),t}():function(){const e=new URLSearchParams(window.location.search),t=e.has("utm_content"),n=e.has("utm_source");if(t&&!n){const t=e.get("utm_content");e.delete("utm_content"),e.set("utm_source",t)}return Object.fromEntries(e)}()}const so=()=>(window.location.search.match(/\?/g)||[]).length>1;var uo=n(8367),lo=n.n(uo);var co=n(308),po=n.n(co),ho=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 fo=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.mobileStyles={},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=Kn.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.showTourNextToChat=!1,this.displayPubnubChat=!1,this.myPubnub=null,this.LeadSourceClient=null,this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.onWidgetLoaded=po(),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=xe(),this.firstUpdated=async()=>this.setupWebchat(),this.setupWebchat=async()=>{if(!this.buildingSlug||!this.orgSlug)return;const e=await fi(this.orgSlug,this.buildingSlug);e.conversationMaintenanceMode?console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear."):1===e.active?(this.building=e,await this.initializeChatVariables(),await this.handleChatInitializeAnalytics(),await this.setBuildingDerivedInfo(),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(this.webchatConfigHasAutoOpenChat)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1,"true"===localStorage.getItem("isChatOpen")&&(this.hideLauncher=!0,this.displayPubnubChat=!0)):console.warn("MeetElise has detected this building is NOT active. Chat icon will not appear.")},this.setBuildingDerivedInfo=async()=>{var e,n,i,r,o,a,s,u,l,d,c,p,h,f,m,g,v,y,b,w,S,T,x,A,O,C,I,N,E;const R=this.building;if(!R)return;R&&this.orgSlug&&go(this.orgSlug,this.buildingSlug,null!==(n=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.leadSource)&&void 0!==n?n:null);const[_,P,M,F,D,k]=await Promise.all([bi(this.buildingSlug),gr(this.buildingSlug),Xn(this.buildingSlug),Yn(this.buildingSlug),yi(R.id),$n(this.buildingSlug)]);this.building&&(this.building.phoneNumber=Ne(R.phoneNumber)),this.designConcept=null!==(i=null==_?void 0:_.abTestType)&&void 0!==i?i:"",this.leadSources=P,this.featureFlagShowDropdown=M;const U=R.textWithUsPhoneNumber?R.textWithUsPhoneNumber: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 si({logType:ai.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var q,B;this.enabledChatWidgets={call:D&&!D.isGlobalDefault?D.config.shouldShowPhone:null===(a=null===(o=null===(r=this.building)||void 0===r?void 0:r.chatWidgets)||void 0===o?void 0:o.includes("CALL"))||void 0===a||a,chat:D&&!D.isGlobalDefault?D.config.shouldShowChat:null===(l=null===(u=null===(s=this.building)||void 0===s?void 0:s.chatWidgets)||void 0===u?void 0:u.includes("CHAT"))||void 0===l||l,email:D&&!D.isGlobalDefault?D.config.shouldShowEmail:null===(p=null===(c=null===(d=this.building)||void 0===d?void 0:d.chatWidgets)||void 0===c?void 0:c.includes("EMAIL"))||void 0===p||p,text:(D&&!D.isGlobalDefault?D.config.shouldShowText:null===(m=null===(f=null===(h=this.building)||void 0===h?void 0:h.chatWidgets)||void 0===f?void 0:f.includes("SMS"))||void 0===m||m)&&!!U,sst:D&&!D.isGlobalDefault?D.config.shouldShowSst:null===(y=null===(v=null===(g=this.building)||void 0===g?void 0:g.chatWidgets)||void 0===v?void 0:v.includes("SST"))||void 0===y||y},this.enabledChatWidgets.sst?(B=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(),B(e)}))})),((e,t,n)=>{if("be948f76-d8f9-11eb-b710-2bc5b16e7492"===t){const e=document.querySelector('a[href="/schedule-a-tour/"]');e&&e.addEventListener("click",(e=>{e.preventDefault(),n(e)}))}})(this.orgSlug,this.buildingSlug,this.handleTourClicked)):(null===(b=this.LeadSourceClient)||void 0===b?void 0:b.leadSource)&&(q=null!==(S=null===(w=this.LeadSourceClient)||void 0===w?void 0:w.leadSource)&&void 0!==S?S:null,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(q)}`)}}))),D&&D.config&&(this.brandColor=null!==(T=D.config.primaryColor)&&void 0!==T?T:null,this.webchatConfigHasAutoOpenChat=D.config.autoOpenChat,this.requiresConsent=D.config.requiresConsent,this.privacyPolicyUrl=null!==(x=D.config.privacyPolicyUrl)&&void 0!==x?x:this.privacyPolicyUrl,D.config.displayStyle===gi.MINIMIZED&&(this.isMinimized=!0),D.config.displayStyle===gi.PILLS&&(this.designConcept=null),D.config.displayStyle===gi.EMOJI&&(this.designConcept=gi.EMOJI),this.onWidgetLoaded()),null===this.brandColor&&(this.brandColor=Me);const L=null!==(O=null===(A=this.building)||void 0===A?void 0:A.phoneNumber)&&void 0!==O?O:"";let J=null;F&&(J=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.match,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(I=null===(C=this.LeadSourceClient)||void 0===C?void 0:C.leadSource)&&void 0!==I?I:null),J&&!J.isMatch&&(J.number=L)),k&&(null==J?void 0:J.number)&&Ur(J.number,this.orgSlug,this.buildingSlug);const j=localStorage.getItem("eliseai_phone_number_devtest");j&&(console.info("Using dev test phone number: ",j),Ur(j,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=J||{number:L,isMatch:!1,isPropertyWebsiteCatchall:!0};const H=null!==(E=null===(N=this.LeadSourceClient)||void 0===N?void 0:N.leadSource)&&void 0!==E?E:null;H&&(this.leadSources.includes(H)||this.leadSources.push(H)),Bn(R.id)},this.initializeChatVariables=async()=>{var e,n,i,r,o;if(!this.building)return;const a=Rr(this.buildingSlug),s=_r(this.buildingSlug,a)?a:Er(this.buildingSlug,!1);if(!s.leadId)throw new Error("Lead ID is null");this.LeadSourceClient=new class{constructor(){this.chatId=null,this.apiHost="https://app.meetelise.com",this.leadSource=null,this.localStorageTTLHours=4,this.buildingId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,n)=>{const i=ao();this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:i,referrer:document.referrer,parsedUtmSource:i?i.utm_source:null,campaignSources:Object.values(oi()).filter((e=>e))};const r={leadSource:t,leadId:n,buildingSlug:e,timestamp:vn(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(r)),{...r,timestamp:An(r.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const n=JSON.parse(t);if(n.buildingSlug===e&&n.leadSource&&n.leadId&&n.timestamp&&!cn(An(n.timestamp),this.localStorageTTLHours)){try{this.leadSourceInput=n.leadSourceInput}catch(e){console.error("Error parsing leadSourceInput from localStorage")}return n}}catch(e){return null}return null}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:n,referrer:i,campaignSources:r}){try{return(await t().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,{query_params:n,building_slug:e,referrer:i,campaign_sources:r})).data}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:n}){var i,r,o,a,s,u,l;try{if(!this.chatId)return console.error("chatId is not set"),null;if(!this.orgSlug)return console.error("orgId is not set"),null;let d=null,c=null;try{if("f1ba5a20-d207-4e5a-879e-65199e7d0a53"===this.orgSlug){const e=await this.getCookieValue("_ga");e&&(d=e),c=null===(i=window.dataLayer.find((e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)})))||void 0===i?void 0:i.value}}catch(e){console.error("error getting cookie")}return await t().post(`${this.apiHost}/platformApi/webchat/log/lead-source`,{chat_id:this.chatId,webchat_action:e,state_id:n,building_id:this.buildingId,org_slug:this.orgSlug,building_slug:this.buildingSlug,website_origin:null===(r=this.leadSourceInput)||void 0===r?void 0:r.websiteOrigin,website_search:null===(o=this.leadSourceInput)||void 0===o?void 0:o.websiteSearch,query_parameters:null===(a=this.leadSourceInput)||void 0===a?void 0:a.queryParameters,referrer:null===(s=this.leadSourceInput)||void 0===s?void 0:s.referrer,parsed_utm_source:null===(u=this.leadSourceInput)||void 0===u?void 0:u.parsedUtmSource,campaign_sources:null===(l=this.leadSourceInput)||void 0===l?void 0:l.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:lo()(d)?null:d,extras:null!=c?c:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const i=t[n].trim();if(i.startsWith(e+"="))return i.substring((e+"=").length,-1===i.indexOf(";")?void 0:i.indexOf(";"))}return null}catch(e){console.error("error getting cookie value")}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:n}){try{const i={queryParams:ao(),buildingSlug:n,referrer:document.referrer,campaignSources:oi()},r=await this.fetchCurrentParsedLeadSource(i);if(this.leadSource=r,this.buildingId=null,this.orgSlug=t,this.buildingSlug=n,n&&!r){const e=this.getLeadSourceBodyIfValid(n);if(e)return this.leadSource=e.leadSource,this.leadSource}return n&&this.updateLeadSourceLocalStorage(n,r,e),r}catch(e){console.error(e)}return null}},this.myPubnub=new kr(this.buildingSlug,this.building,this.orgSlug,null,s.leadId,this.LeadSourceClient),this.LeadSourceClient.chatId=this.myPubnub.channel,await(null===(e=this.LeadSourceClient)||void 0===e?void 0:e.generateUserLeadSource({leadId:null!==(i=null===(n=this.myPubnub)||void 0===n?void 0:n.leadUserId)&&void 0!==i?i:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug})),this.myPubnub.leadSource=null!==(o=null===(r=this.LeadSourceClient)||void 0===r?void 0:r.leadSource)&&void 0!==o?o:null,s.initiatedChat&&await this.myPubnub.initializePubnub(a)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!Tn(An(t)));return!!e&&!!n&&!dn()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",vn(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.handleKeydownTab=e=>{var t,n,i,r,o,a,s,u,l,d,c,p,h,f,m,g,v,y,b,w;if("Tab"===e.key){const S=this.displayPubnubChat?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"):null!==(m=null!==(l=null===(u=null===(s=null===(a=null===(o=null===(r=this.shadowRoot)||void 0===r?void 0:r.getElementById("meetelise-launcher"))||void 0===o?void 0:o.shadowRoot)||void 0===a?void 0:a.getElementById("email-us-window"))||void 0===s?void 0:s.shadowRoot)||void 0===u?void 0:u.getElementById("email-us-form"))&&void 0!==l?l:null===(f=null===(h=null===(p=null===(c=null===(d=this.shadowRoot)||void 0===d?void 0:d.getElementById("meetelise-launcher"))||void 0===c?void 0:c.shadowRoot)||void 0===p?void 0:p.getElementById("tour-scheduler-window"))||void 0===h?void 0:h.shadowRoot)||void 0===f?void 0:f.getElementById("scheduler-container"))&&void 0!==m?m:null===(w=null===(b=null===(y=null===(v=null===(g=this.shadowRoot)||void 0===g?void 0:g.getElementById("meetelise-launcher"))||void 0===v?void 0:v.shadowRoot)||void 0===y?void 0:y.getElementById("call-us-window"))||void 0===b?void 0:b.shadowRoot)||void 0===w?void 0:w.getElementById("details-window");if(!S)return;e.preventDefault();const T=S.querySelectorAll("input, me-select, textarea, action-confirm-button, [tabindex]"),x=Array.from(T),A=x.findIndex((e=>e.matches(":focus")));x[(A+1)%x.length].focus()}},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,localStorage.setItem("isChatOpen","true")},e.onExitChat=this.onExitChat)},this.onExitChat=()=>{this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,localStorage.setItem("isChatOpen","false")},this.renderChatAdditionalActions=(e,t)=>U` <div
4026
4028
  id=${e}
4027
4029
  class=${fe({showTab:t,hideTab:!t})}
4028
4030
  >
@@ -280,7 +280,10 @@ export class MEChat extends LitElement {
280
280
  this.leadSources = leadSources;
281
281
  this.featureFlagShowDropdown = featureFlagShowDropdown;
282
282
 
283
- const buildingPhoneNumber = await getBuildingPhoneNumber(this.buildingSlug);
283
+ // The backend is cached for ~4 hours, so falling back to the existing api request until the cache propagates all the changes.
284
+ const buildingPhoneNumber = buildingDetails.textWithUsPhoneNumber
285
+ ? buildingDetails.textWithUsPhoneNumber
286
+ : await getBuildingPhoneNumber(this.buildingSlug);
284
287
 
285
288
  this.enabledChatWidgets = {
286
289
  call:
@@ -316,13 +316,14 @@ export class PubnubChat extends LitElement {
316
316
  .myPubnub=${this.myPubnub}
317
317
  .onMount=${() => this.scrollToChatBottom()}
318
318
  >
319
- </pubnub-message>`
319
+ </pubnub-media>`
320
320
  : ""}
321
321
  ${isSimpleTextChatMessage(message)
322
322
  ? html` <pubnub-message
323
323
  .message=${message}
324
324
  .myPubnub=${this.myPubnub}
325
325
  .onMount=${() => this.scrollToChatBottom()}
326
+ .isLeadMessage=${message.isLeadMessage}
326
327
  >
327
328
  </pubnub-message>`
328
329
  : ""}
@@ -477,17 +478,18 @@ export class PubnubChat extends LitElement {
477
478
  >
478
479
  ${isSimpleMediaChatMessage(message)
479
480
  ? html` <pubnub-media
480
- .message=${message}
481
- .myPubnub=${this.myPubnub}
482
- .onMount=${() => this.scrollToChatBottom()}
483
- >
484
- </pubnub-message>`
481
+ .message=${message}
482
+ .myPubnub=${this.myPubnub}
483
+ .onMount=${() => this.scrollToChatBottom()}
484
+ >
485
+ </pubnub-media>`
485
486
  : ""}
486
487
  ${isSimpleTextChatMessage(message)
487
488
  ? html` <pubnub-message
488
489
  .message=${message}
489
490
  .myPubnub=${this.myPubnub}
490
491
  .onMount=${() => this.scrollToChatBottom()}
492
+ .isLeadMessage=${message.isLeadMessage}
491
493
  >
492
494
  </pubnub-message>`
493
495
  : ""}
@@ -8,6 +8,7 @@ import axios from "axios";
8
8
  import { classMap } from "lit/directives/class-map.js";
9
9
  import { InputStyles } from "./actions/InputStyles";
10
10
  import { isMobile } from "../utils";
11
+ import { LogType, sendLoggingEvent } from "../analytics";
11
12
  import { pubnubChatStyles } from "./pubnub-chat-styles";
12
13
  import "./mini-loader";
13
14
 
@@ -66,6 +67,9 @@ export class PubnubMessage extends LitElement {
66
67
  @state()
67
68
  imageUrlError: string[] = [];
68
69
 
70
+ @property({ type: Boolean })
71
+ isLeadMessage = false;
72
+
69
73
  isMessageStillStreamingChunks(): boolean {
70
74
  if (!this.message) return false;
71
75
  const messageChunkMarkedAsDone = this.message.chunks.find(
@@ -123,6 +127,15 @@ export class PubnubMessage extends LitElement {
123
127
  >${link}
124
128
  </a>`;
125
129
  } else {
130
+ if (!this.isLeadMessage && this.invalidMarkdownText(word)) {
131
+ sendLoggingEvent({
132
+ logType: LogType.error,
133
+ logTitle: "[IMPROPER_MARKDOWN]",
134
+ logData: { message: this.message, word },
135
+ });
136
+ return html``;
137
+ }
138
+
126
139
  return html`${unsafeHTML(DOMPurify.sanitize(word))} `;
127
140
  }
128
141
  })}<br />`;
@@ -133,9 +146,13 @@ export class PubnubMessage extends LitElement {
133
146
  });
134
147
  }
135
148
 
149
+ private invalidMarkdownText(text: string): boolean {
150
+ const invalidChars = ["*", "_", "`", "~", ">", "<"];
151
+ return invalidChars.some((char) => text === char);
152
+ }
153
+
136
154
  private preserveHTMLTags(text: string): string[] {
137
- const tagRegex =
138
- /(<\/?[a-z][^>]*>[^<]*<\/?[a-z]*>|[\w':#$()-]+[.,?!]?|\S)/gi;
155
+ const tagRegex = /(<\/?[a-z][^>]*>[^<]*<\/?[a-z]*>|[^\s]+[.,?!]?|\S)/gi;
139
156
  const splitTags = text.match(tagRegex);
140
157
 
141
158
  return splitTags?.filter((str) => str.trim() !== "") ?? [];
@@ -35,6 +35,7 @@ export interface Building {
35
35
  virtualToursLink: string;
36
36
  active: number;
37
37
  usesDynamicScheduling: boolean;
38
+ textWithUsPhoneNumber: string | null;
38
39
  }
39
40
 
40
41
  export type UnitV2 = {