@meetelise/chat 1.22.71 → 1.22.73

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.22.71",
3
+ "version": "1.22.73",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -173,8 +173,9 @@
173
173
  };
174
174
 
175
175
  MEChat.start({
176
- organization: "lindy",
177
- building: "c4cfc3ec-c4da-11ec-bda4-43aed00ca1b2",
176
+ organization: "a55b5275-cfe6-44a3-ac17-b10f6fe85cce",
177
+ building: "ce4ab608-2e7c-11ef-910a-873d6fb25892",
178
+
178
179
  // organization: "Pacific Urban Residential",
179
180
  // building: "c06117dc-7a80-11ed-bc9a-c3e28c7281ff",
180
181
 
@@ -3213,7 +3213,7 @@ xmlns="http://www.w3.org/2000/svg"
3213
3213
  ${Sn}
3214
3214
  ${Tn}
3215
3215
  ${xn}
3216
- `,Zn([le({attribute:!0})],er.prototype,"isMinimized",void 0),Zn([le()],er.prototype,"mobileStyles",void 0),Zn([le({type:Boolean})],er.prototype,"isFirstMount",void 0),Zn([le({attribute:!1})],er.prototype,"autoOpenChatWidget",void 0),Zn([le()],er.prototype,"phoneNumber",void 0),Zn([le({attribute:!0})],er.prototype,"buildingName",void 0),Zn([le({attribute:!0})],er.prototype,"chatId",void 0),Zn([le({attribute:!0})],er.prototype,"orgLegalName",void 0),Zn([le({attribute:!0})],er.prototype,"chatCallUsHeader",void 0),Zn([le({attribute:!1})],er.prototype,"buildingId",void 0),Zn([le({attribute:!0})],er.prototype,"buildingSlug",void 0),Zn([le({attribute:!0})],er.prototype,"orgSlug",void 0),Zn([le({attribute:!0})],er.prototype,"sgtUrl",void 0),Zn([le({attribute:!0})],er.prototype,"selfGuidedTourEnabled",void 0),Zn([le({attribute:!0})],er.prototype,"selfGuidedToursTypeOffered",void 0),Zn([le({attribute:!0})],er.prototype,"designConcept",void 0),Zn([le({attribute:!0})],er.prototype,"featureFlagShowDropdown",void 0),Zn([le({attribute:!1})],er.prototype,"leadSources",void 0),Zn([le({attribute:!0})],er.prototype,"currentLeadSource",void 0),Zn([le({attribute:!0})],er.prototype,"escortedToursLink",void 0),Zn([le({attribute:!0})],er.prototype,"virtualToursLink",void 0),Zn([le({type:Boolean})],er.prototype,"hasChatEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasChatEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasEmailEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasEmailEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasCallUsEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasCallUsEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasTextUsEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasTextUsEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasSSTEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasSSTEnabledMobile",void 0),Zn([le({attribute:!1})],er.prototype,"tourTypeOptions",void 0),Zn([le({attribute:!0})],er.prototype,"hasDynamicSchedulingEnabled",void 0),Zn([le({attribute:!0})],er.prototype,"onExitChat",void 0),Zn([le({attribute:!1})],er.prototype,"hasHideMobileFeatures",void 0),Zn([le({type:Number})],er.prototype,"right",void 0),Zn([le({type:Number})],er.prototype,"bottom",void 0),Zn([le({type:Number})],er.prototype,"top",void 0),Zn([le({type:Number})],er.prototype,"left",void 0),Zn([le({attribute:!0})],er.prototype,"showTourNextToChat",void 0),Zn([le({attribute:!1})],er.prototype,"onChatTapped",void 0),Zn([le({attribute:!0})],er.prototype,"onClickMinimize",void 0),Zn([le({attribute:!0})],er.prototype,"onSstClose",void 0),Zn([le({attribute:!0})],er.prototype,"overrideRentgrata",void 0),Zn([le({attribute:!1})],er.prototype,"launcherStyles",void 0),Zn([le({attribute:!0})],er.prototype,"primaryColor",void 0),Zn([le({attribute:!0})],er.prototype,"backgroundColor",void 0),Zn([le({attribute:!0})],er.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),Zn([le({attribute:!0})],er.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),Zn([le({attribute:!0})],er.prototype,"leadSourceClient",void 0),Zn([ue()],er.prototype,"isEmailWindowOpen",void 0),Zn([ue()],er.prototype,"isCallUsWindowOpen",void 0),Zn([ue()],er.prototype,"isSSTWindowOpen",void 0),Zn([ue()],er.prototype,"isTextUsWindowOpen",void 0),Zn([ue()],er.prototype,"isMobileFeaturesExpanded",void 0),er=Zn([ae("meetelise-launcher")],er);const tr=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",er)};var ir=i(3379),nr=i.n(ir),rr=i(7795),or=i.n(rr),ar=i(569),sr=i.n(ar),lr=i(3565),ur=i.n(lr),dr=i(9216),cr=i.n(dr),pr=i(4589),hr=i.n(pr),fr=i(3631),mr={};async function gr(e,i){try{const n=await t().get(`https://app.meetelise.com/platformApi/webchat/${i}/lead-sources`);if(n.data){if("7e352741-1120-4ccf-9929-5dc99193a908"===e){const e=["Zillow","Apartments.com","Google PPC","Google Maps","Apple Maps","Social Media","Print Marketing"];return n.data.filter((t=>e.includes(t)))}return vr(n.data,i)}return[]}catch(e){return[]}}mr.styleTagTransform=hr(),mr.setAttributes=ur(),mr.insert=sr().bind(null,"head"),mr.domAPI=or(),mr.insertStyleElement=cr(),nr()(fr.Z,mr),fr.Z&&fr.Z.locals&&fr.Z.locals;const vr=(e,t)=>{let i=[];switch(t){case"d41619ec-0f79-11ee-8439-93855926ad58":i=["Forthea - PPC","HotPads","Forthea","Locator","Website-apartmentguide.com","Forthea - organic search","Tdc employee","University newspaper","Nashville apartment locators","Forthea - paid social","Apartment list","Off campus partners","Waze ads","Athletic event","Website-apartment guide"];break;case"d4160560-0f79-11ee-8438-fba837bf3a46":i=["Forthea - PPC","Rentgrata","Website-ApartmentFinder.com","Word of Mouth","Texas A&M A-Frame on Campus","Rent.com","Website-craigslist","Apartment List","Website-apartments.com","Forthea - paid social","Forthea - organic search","Website-apartmentguide.com","Forthea","Uhomes","Phone book","Property - website"];break;default:i=[]}return e.sort(),e.filter((e=>{const t=e.toLowerCase();return!i.map((e=>e.toLowerCase())).includes(t)}))};var yr,br=i(9594),wr=i.n(br),Sr=new Uint8Array(16);function Tr(){if(!yr&&!(yr="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return yr(Sr)}const xr=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,Ar=function(e){return"string"==typeof e&&xr.test(e)};for(var Cr=[],Or=0;Or<256;++Or)Cr.push((Or+256).toString(16).substr(1));const Ir=function(e,t,i){var n=(e=e||{}).random||(e.rng||Tr)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){i=i||0;for(var r=0;r<16;++r)t[i+r]=n[r];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=(Cr[e[t+0]]+Cr[e[t+1]]+Cr[e[t+2]]+Cr[e[t+3]]+"-"+Cr[e[t+4]]+Cr[e[t+5]]+"-"+Cr[e[t+6]]+Cr[e[t+7]]+"-"+Cr[e[t+8]]+Cr[e[t+9]]+"-"+Cr[e[t+10]]+Cr[e[t+11]]+Cr[e[t+12]]+Cr[e[t+13]]+Cr[e[t+14]]+Cr[e[t+15]]).toLowerCase();if(!Ar(i))throw TypeError("Stringified UUID is invalid");return i}(n)},Nr=e=>localStorage.removeItem("com.elise.webchat.slug="+e),Er=(e,t,i)=>{const n=ui(new Date),r=i||`lead_${Ir()}_${e}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:n,initiatedChat:t})),{leadId:r,timestamp:gi(n),buildingSlug:e,initiatedChat:t}},Rr=e=>{const t=localStorage.getItem("com.elise.webchat.slug="+e);if(t)try{const i=JSON.parse(t),n={leadId:i.leadId,timestamp:new Date(i.timestamp),buildingSlug:i.buildingSlug,initiatedChat:i.initiatedChat};if(_r(e,n))return n}catch(e){console.warn("Error getting chat storage key")}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},_r=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if(ti(t.timestamp,e))return!1}}catch(e){console.warn("Error checking chat storage key validity")}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp||ni(t.timestamp,24))};var Pr;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(Pr||(Pr={}));const Mr=e=>e.type===Dr.text,Fr=e=>e.type===Dr.media;var Dr;!function(e){e.text="text",e.media="media"}(Dr||(Dr={}));const kr=class{constructor(e,t,i,n=null,r,o=null,a=Oo.Default){this.apiHost="https://app.meetelise.com",this.leadSourceClient=null,this.buildingWebchatView=null,this.eliseResponseTimeout=null,this.isWaitingForStreamingMessages=!1,this.widgetType=Oo.Default,this.pubnub=null,this.leadUserId="",this.channel="",this.leadSource=null,this.isCurrentlyStreamingMessage=!1,this.chatListener=null,this.rawPubnubMessages=[],this.simpleChatMessages=[],this.listenerParams={message:e=>{var t,i;const n={channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken};this.rawPubnubMessages=[...this.rawPubnubMessages,n],this.markEveryPreviousNoReplyMessageDone(this.rawPubnubMessages),this.rawPubnubMessages=this.rawPubnubMessages.filter((e=>e.message.messageType!==Pr.noReply)),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),this.checkAndHandleDelayStreamingMessages();const r="eliseai"!==e.publisher&&"elise_health_ai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:r}),!r&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=r,"ai_message"===e.message.customType&&this.simpleChatMessages.some((e=>e.type===Dr.text&&e.message.includes("confirmed for your tour")))&&Wi("scheduledTourEvent",{tourDetails:e.message,buildingId:null===(i=this.buildingWebchatView)||void 0===i?void 0:i.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.checkAndHandleGTMForLeadEmail(e)}},this.isLoadingMessages=!1,this.isFirstChatMessageSent=!1,this.streamingMessageTimeout=null,this.checkAndHandleDelayStreamingMessages=({delayToFetchHistoryInMs:e=1e4}={})=>{this.streamingMessageTimeout&&(clearTimeout(this.streamingMessageTimeout),this.streamingMessageTimeout=null);const t=this.simpleChatMessages.some((e=>{if(!Mr(e))return!1;const t=e.chunks.find((e=>e.isDone));return!t||e.chunks.length===t.order}));t&&(this.streamingMessageTimeout=setTimeout((()=>{en({logTitle:"PUBNUB_WARN_DELAYED_STREAMING_MESSAGES",logData:{channel:this.channel},logType:Zi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),console.warn(`PUBNUB_WARN_DELAYED_STREAMING_MESSAGES: ${e}`),this.getChannelHistory()}),e))},this.checkAndHandleGTMForLeadEmail=e=>{var t;try{if("lead_message"!==e.message.customType)return;if(!(e=>{try{return/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b/.test(e)}catch(e){return console.warn("Error checking if message contains email",e),!1}})(e.message.text))return;Wi("leadProvidedEmail",{buildingId:null===(t=this.buildingWebchatView)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel})}catch(e){return}},this.markEveryPreviousNoReplyMessageDone=e=>{var t,i;for(let n=e.length-1;n>=0;n--){const r=null===(t=e[n])||void 0===t?void 0:t.message,o=n>0&&(null===(i=e[n-1])||void 0===i?void 0:i.message);(null==r?void 0:r.messageType)===Pr.noReply&&o&&(o.is_done=!0)}},this.checkMessageChunkValid=e=>{try{return!!e.message&&!!e.message.text&&e.message.text.length>0&&!!e.message.customType}catch(e){return!1}},this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.handleDisconnect=()=>{this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.streamingMessageTimeout&&(clearTimeout(this.streamingMessageTimeout),this.streamingMessageTimeout=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=Er(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken((async()=>{var t,i,n,r,o;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}),9e4),0===this.simpleChatMessages.length&&(null===(t=this.leadSourceClient)||void 0===t||t.checkAndHandleForLogLeadSource({webchatAction:"chat",stateId:null})),this.widgetType===Oo.Utilities?await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",widgetType:this.widgetType,isDevState:this.shouldCreateAsDevState(),orgSlug:this.orgSlug}}):await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(i=this.buildingWebchatView)||void 0===i?void 0:i.id,buildingSlug:this.buildingSlug,userId:null===(n=this.buildingWebchatView)||void 0===n?void 0:n.userId,leadSource:this.leadSource,widgetType:this.widgetType,isDevState:this.shouldCreateAsDevState()}}),this.isFirstChatMessageSent||(Wi("firstChatMessageSent",{message:e,buildingId:null===(r=this.buildingWebchatView)||void 0===r?void 0:r.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.isFirstChatMessageSent=!0),Wi("chatMessageSent",{message:e,buildingId:null===(o=this.buildingWebchatView)||void 0===o?void 0:o.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}))})),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.removeDuplicatedRawPubnubMessages=e=>{const t=new Set;return e.filter((e=>{if("lead_message"===e.message.customType||!e.message.stream_id||!e.message.order)return!0;const i=`${e.message.stream_id}-${e.message.order}-${e.message.messageType}`;return t.has(i)?(en({logTitle:"PUBNUB_WARN_DUPLICATE_MESSAGE",logData:{message:e,channel:this.channel},logType:Zi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),!1):(t.add(i),!0)}))},this.translatePubnubMessagesIntoSimpleChatMessages=e=>{const t=[],i={};return this.removeDuplicatedRawPubnubMessages(e).forEach((e=>{var n;"media"===e.message.messageType?t.push({timestamp:e.timetoken,media:null!==(n=e.message.media)&&void 0!==n?n:[],isLeadMessage:this.isLeadMessage(e),type:Dr.media}):!e.message.stream_id||e.message.is_done&&0===e.message.order?t.push({timestamp:e.timetoken,message:e.message.text,isLeadMessage:this.isLeadMessage(e),chunks:[{text:e.message.text,order:0,isDone:!0}],type:Dr.text}):i[e.message.stream_id]?i[e.message.stream_id].push(e):i[e.message.stream_id]=[e]})),Object.keys(i).forEach((e=>{const n=i[e],r=this.getConsecutiveChunks(n.sort(((e,t)=>{var i,n;return(null!==(i=e.message.order)&&void 0!==i?i:0)-(null!==(n=t.message.order)&&void 0!==n?n:0)}))),o=r.map((e=>e.message.text)).join(""),a=r[0],s={timestamp:a.timetoken,message:o,isLeadMessage:this.isLeadMessage(a),chunks:r.map((e=>{var t,i;return{text:e.message.text,order:null!==(t=e.message.order)&&void 0!==t?t:0,isDone:null!==(i=e.message.is_done)&&void 0!==i&&i}})),type:Dr.text};this.isCurrentlyStreamingMessage=this.isMessageStillStreamingChunks(r),t.push(s)})),t.sort(((e,t)=>e.timestamp-t.timestamp)),t},this.getConsecutiveChunks=e=>{var t,i;const n=e.sort(((e,t)=>{var i,n;return(null!==(i=e.message.order)&&void 0!==i?i:0)-(null!==(n=t.message.order)&&void 0!==n?n:0)})),r=[];let o=null!==(t=n[0].message.order)&&void 0!==t?t:0;for(const e of n){if((null!==(i=e.message.order)&&void 0!==i?i:-1)!==o)break;r.push(e),o++}return r},this.isMessageStillStreamingChunks=e=>{const t=e.find((e=>e.message.is_done));return!t||e.length===t.message.order},this.buildingSlug=e,this.buildingWebchatView=t,this.orgSlug=i,this.leadSource=n,this.leadUserId=r,this.channel=`webchat_${r}`,this.leadSourceClient=o,this.widgetType=a}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(wr())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token,origin:"meetelise.pubnubapi.com"}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,i){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${i}&${"healthcare"===this.widgetType?"industry=health_care":""}`)).data}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:Zi.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){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(i){if(i instanceof e.AxiosError&&i&&i.response&&403===i.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){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(e=1500){var t;try{let i=[],n=null;const r=100;for(let t=0;t<e;t+=r){const o=await new Promise(((i,o)=>{if(!this.pubnub||!this.channel)return[];const a=Math.min(r,e-t);this.pubnub.fetchMessages({channels:[this.channel],count:a,start:null!=n?n:void 0},((e,t)=>{e.error?o(e):i(t)}))})),a=o.channels[this.channel];if(!a)break;if(a.sort(((e,t)=>+e.timetoken-+t.timetoken)),!a||0===a.length)break;if(this.channel&&0!==Object.keys(o.channels).length){const e=o.channels[this.channel],t=[];e.forEach((e=>{e.uuid&&t.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})})),this.markEveryPreviousNoReplyMessageDone(t),i=i.concat(t.filter((e=>e.message.messageType!==Pr.noReply)))}if(n=a[0].timetoken,i.length>=e||a.length<r)break}this.rawPubnubMessages=i.slice(0,e),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:!1})}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:Zi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}shouldCreateAsDevState(){return location.href.startsWith("https://app.meetelise.com/settings/widgets")||location.href.includes("demo/utilities")}},Ur=(e,t,i)=>{const n=`tel:${e}`,r=`sms:${e}`,o=`whatsapp://send?phone=${e}}`,a=`facetime:${e}`,s=`facetime-audio:${e}`,l=/(?:\(\d{3}\)\s|\d{3}-)\d{3}-\d{4}/g,u=/(tel|sms):(?:\(\d{3}\)\s|\d{3}-)\d{3}-\d{4}/g,d=/whatsapp:\/\/send\?phone=\d+/g,c=/(facetime|facetime-audio):\d+/g,p=document.body.getElementsByTagName("*");let h=!1;const f=e.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3");let m=!1,g=!1,v=0;for(let e=0;e<p.length;e++)if(p[e].nodeType===Node.ELEMENT_NODE){if(1===p[e].childNodes.length&&p[e].childNodes[0].nodeType==Node.TEXT_NODE){const t=p[e].innerHTML,i=t.replace(l,f);t!==i&&v++,p[e].innerHTML=i,h=!0,m||(m=!0)}if(p[e].hasAttribute("href")){const t=p[e].getAttribute("href");if(!t)continue;let i="",l=u;t.startsWith("sms:")?i=r:t.startsWith("whatsapp:")?(i=o,l=d):t.startsWith("facetime:")?(i=a,l=c):t.startsWith("facetime-audio:")?(i=s,l=c):i=n;const h=t.replace(l,i);p[e].setAttribute("href",h),g||(g=!0)}}return m&&en({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:f,website:window.location.href},logType:Zi.info,buildingSlug:i,orgSlug:t}),g&&en({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:f,website:window.location.href},logType:Zi.info,buildingSlug:i,orgSlug:t}),h||en({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:Zi.warn,buildingSlug:i,orgSlug:t}),v},Br=(e="black")=>B`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none">
3216
+ `,Zn([le({attribute:!0})],er.prototype,"isMinimized",void 0),Zn([le()],er.prototype,"mobileStyles",void 0),Zn([le({type:Boolean})],er.prototype,"isFirstMount",void 0),Zn([le({attribute:!1})],er.prototype,"autoOpenChatWidget",void 0),Zn([le()],er.prototype,"phoneNumber",void 0),Zn([le({attribute:!0})],er.prototype,"buildingName",void 0),Zn([le({attribute:!0})],er.prototype,"chatId",void 0),Zn([le({attribute:!0})],er.prototype,"orgLegalName",void 0),Zn([le({attribute:!0})],er.prototype,"chatCallUsHeader",void 0),Zn([le({attribute:!1})],er.prototype,"buildingId",void 0),Zn([le({attribute:!0})],er.prototype,"buildingSlug",void 0),Zn([le({attribute:!0})],er.prototype,"orgSlug",void 0),Zn([le({attribute:!0})],er.prototype,"sgtUrl",void 0),Zn([le({attribute:!0})],er.prototype,"selfGuidedTourEnabled",void 0),Zn([le({attribute:!0})],er.prototype,"selfGuidedToursTypeOffered",void 0),Zn([le({attribute:!0})],er.prototype,"designConcept",void 0),Zn([le({attribute:!0})],er.prototype,"featureFlagShowDropdown",void 0),Zn([le({attribute:!1})],er.prototype,"leadSources",void 0),Zn([le({attribute:!0})],er.prototype,"currentLeadSource",void 0),Zn([le({attribute:!0})],er.prototype,"escortedToursLink",void 0),Zn([le({attribute:!0})],er.prototype,"virtualToursLink",void 0),Zn([le({type:Boolean})],er.prototype,"hasChatEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasChatEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasEmailEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasEmailEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasCallUsEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasCallUsEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasTextUsEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasTextUsEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasSSTEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasSSTEnabledMobile",void 0),Zn([le({attribute:!1})],er.prototype,"tourTypeOptions",void 0),Zn([le({attribute:!0})],er.prototype,"hasDynamicSchedulingEnabled",void 0),Zn([le({attribute:!0})],er.prototype,"onExitChat",void 0),Zn([le({attribute:!1})],er.prototype,"hasHideMobileFeatures",void 0),Zn([le({type:Number})],er.prototype,"right",void 0),Zn([le({type:Number})],er.prototype,"bottom",void 0),Zn([le({type:Number})],er.prototype,"top",void 0),Zn([le({type:Number})],er.prototype,"left",void 0),Zn([le({attribute:!0})],er.prototype,"showTourNextToChat",void 0),Zn([le({attribute:!1})],er.prototype,"onChatTapped",void 0),Zn([le({attribute:!0})],er.prototype,"onClickMinimize",void 0),Zn([le({attribute:!0})],er.prototype,"onSstClose",void 0),Zn([le({attribute:!0})],er.prototype,"overrideRentgrata",void 0),Zn([le({attribute:!1})],er.prototype,"launcherStyles",void 0),Zn([le({attribute:!0})],er.prototype,"primaryColor",void 0),Zn([le({attribute:!0})],er.prototype,"backgroundColor",void 0),Zn([le({attribute:!0})],er.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),Zn([le({attribute:!0})],er.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),Zn([le({attribute:!0})],er.prototype,"leadSourceClient",void 0),Zn([ue()],er.prototype,"isEmailWindowOpen",void 0),Zn([ue()],er.prototype,"isCallUsWindowOpen",void 0),Zn([ue()],er.prototype,"isSSTWindowOpen",void 0),Zn([ue()],er.prototype,"isTextUsWindowOpen",void 0),Zn([ue()],er.prototype,"isMobileFeaturesExpanded",void 0),er=Zn([ae("meetelise-launcher")],er);const tr=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",er)};var ir=i(3379),nr=i.n(ir),rr=i(7795),or=i.n(rr),ar=i(569),sr=i.n(ar),lr=i(3565),ur=i.n(lr),dr=i(9216),cr=i.n(dr),pr=i(4589),hr=i.n(pr),fr=i(3631),mr={};async function gr(e,i){try{const n=await t().get(`https://app.meetelise.com/platformApi/webchat/${i}/lead-sources`);if(n.data){if("7e352741-1120-4ccf-9929-5dc99193a908"===e){const e=["Zillow","Apartments.com","Google PPC","Google Maps","Apple Maps","Social Media","Print Marketing"];return n.data.filter((t=>e.includes(t)))}return vr(n.data,i)}return[]}catch(e){return[]}}mr.styleTagTransform=hr(),mr.setAttributes=ur(),mr.insert=sr().bind(null,"head"),mr.domAPI=or(),mr.insertStyleElement=cr(),nr()(fr.Z,mr),fr.Z&&fr.Z.locals&&fr.Z.locals;const vr=(e,t)=>{let i=[];switch(t){case"d41619ec-0f79-11ee-8439-93855926ad58":i=["Forthea - PPC","HotPads","Forthea","Locator","Website-apartmentguide.com","Forthea - organic search","Tdc employee","University newspaper","Nashville apartment locators","Forthea - paid social","Apartment list","Off campus partners","Waze ads","Athletic event","Website-apartment guide"];break;case"d4160560-0f79-11ee-8438-fba837bf3a46":i=["Forthea - PPC","Rentgrata","Website-ApartmentFinder.com","Word of Mouth","Texas A&M A-Frame on Campus","Rent.com","Website-craigslist","Apartment List","Website-apartments.com","Forthea - paid social","Forthea - organic search","Website-apartmentguide.com","Forthea","Uhomes","Phone book","Property - website"];break;default:i=[]}return e.sort(),e.filter((e=>{const t=e.toLowerCase();return!i.map((e=>e.toLowerCase())).includes(t)}))};var yr,br=i(9594),wr=i.n(br),Sr=new Uint8Array(16);function Tr(){if(!yr&&!(yr="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return yr(Sr)}const xr=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,Ar=function(e){return"string"==typeof e&&xr.test(e)};for(var Cr=[],Or=0;Or<256;++Or)Cr.push((Or+256).toString(16).substr(1));const Ir=function(e,t,i){var n=(e=e||{}).random||(e.rng||Tr)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){i=i||0;for(var r=0;r<16;++r)t[i+r]=n[r];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=(Cr[e[t+0]]+Cr[e[t+1]]+Cr[e[t+2]]+Cr[e[t+3]]+"-"+Cr[e[t+4]]+Cr[e[t+5]]+"-"+Cr[e[t+6]]+Cr[e[t+7]]+"-"+Cr[e[t+8]]+Cr[e[t+9]]+"-"+Cr[e[t+10]]+Cr[e[t+11]]+Cr[e[t+12]]+Cr[e[t+13]]+Cr[e[t+14]]+Cr[e[t+15]]).toLowerCase();if(!Ar(i))throw TypeError("Stringified UUID is invalid");return i}(n)},Nr=e=>localStorage.removeItem("com.elise.webchat.slug="+e),Er=(e,t,i)=>{const n=ui(new Date),r=i||`lead_${Ir()}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:n,initiatedChat:t})),{leadId:r,timestamp:gi(n),buildingSlug:e,initiatedChat:t}},Rr=e=>{const t=localStorage.getItem("com.elise.webchat.slug="+e);if(t)try{const i=JSON.parse(t),n={leadId:i.leadId,timestamp:new Date(i.timestamp),buildingSlug:i.buildingSlug,initiatedChat:i.initiatedChat};if(_r(e,n))return n}catch(e){console.warn("Error getting chat storage key")}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},_r=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if(ti(t.timestamp,e))return!1}}catch(e){console.warn("Error checking chat storage key validity")}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp||ni(t.timestamp,24))};var Pr;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(Pr||(Pr={}));const Mr=e=>e.type===Dr.text,Fr=e=>e.type===Dr.media;var Dr;!function(e){e.text="text",e.media="media"}(Dr||(Dr={}));const kr=class{constructor(e,t,i,n=null,r,o=null,a=Oo.Default){this.apiHost="https://app.meetelise.com",this.leadSourceClient=null,this.buildingWebchatView=null,this.eliseResponseTimeout=null,this.isWaitingForStreamingMessages=!1,this.widgetType=Oo.Default,this.pubnub=null,this.leadUserId="",this.channel="",this.leadSource=null,this.isCurrentlyStreamingMessage=!1,this.chatListener=null,this.rawPubnubMessages=[],this.simpleChatMessages=[],this.listenerParams={message:e=>{var t,i;const n={channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken};this.rawPubnubMessages=[...this.rawPubnubMessages,n],this.markEveryPreviousNoReplyMessageDone(this.rawPubnubMessages),this.rawPubnubMessages=this.rawPubnubMessages.filter((e=>e.message.messageType!==Pr.noReply)),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),this.checkAndHandleDelayStreamingMessages();const r="eliseai"!==e.publisher&&"elise_health_ai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:r}),!r&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=r,"ai_message"===e.message.customType&&this.simpleChatMessages.some((e=>e.type===Dr.text&&e.message.includes("confirmed for your tour")))&&Wi("scheduledTourEvent",{tourDetails:e.message,buildingId:null===(i=this.buildingWebchatView)||void 0===i?void 0:i.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.checkAndHandleGTMForLeadEmail(e)}},this.isLoadingMessages=!1,this.isFirstChatMessageSent=!1,this.streamingMessageTimeout=null,this.checkAndHandleDelayStreamingMessages=({delayToFetchHistoryInMs:e=1e4}={})=>{this.streamingMessageTimeout&&(clearTimeout(this.streamingMessageTimeout),this.streamingMessageTimeout=null);const t=this.simpleChatMessages.some((e=>{if(!Mr(e))return!1;const t=e.chunks.find((e=>e.isDone));return!t||e.chunks.length===t.order}));t&&(this.streamingMessageTimeout=setTimeout((()=>{en({logTitle:"PUBNUB_WARN_DELAYED_STREAMING_MESSAGES",logData:{channel:this.channel},logType:Zi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),console.warn(`PUBNUB_WARN_DELAYED_STREAMING_MESSAGES: ${e}`),this.getChannelHistory()}),e))},this.checkAndHandleGTMForLeadEmail=e=>{var t;try{if("lead_message"!==e.message.customType)return;if(!(e=>{try{return/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b/.test(e)}catch(e){return console.warn("Error checking if message contains email",e),!1}})(e.message.text))return;Wi("leadProvidedEmail",{buildingId:null===(t=this.buildingWebchatView)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel})}catch(e){return}},this.markEveryPreviousNoReplyMessageDone=e=>{var t,i;for(let n=e.length-1;n>=0;n--){const r=null===(t=e[n])||void 0===t?void 0:t.message,o=n>0&&(null===(i=e[n-1])||void 0===i?void 0:i.message);(null==r?void 0:r.messageType)===Pr.noReply&&o&&(o.is_done=!0)}},this.checkMessageChunkValid=e=>{try{return!!e.message&&!!e.message.text&&e.message.text.length>0&&!!e.message.customType}catch(e){return!1}},this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.handleDisconnect=()=>{this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.streamingMessageTimeout&&(clearTimeout(this.streamingMessageTimeout),this.streamingMessageTimeout=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=Er(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken((async()=>{var t,i,n,r,o;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}),9e4),0===this.simpleChatMessages.length&&(null===(t=this.leadSourceClient)||void 0===t||t.checkAndHandleForLogLeadSource({webchatAction:"chat",stateId:null})),this.widgetType===Oo.Utilities?await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",widgetType:this.widgetType,isDevState:this.shouldCreateAsDevState(),orgSlug:this.orgSlug}}):await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(i=this.buildingWebchatView)||void 0===i?void 0:i.id,buildingSlug:this.buildingSlug,userId:null===(n=this.buildingWebchatView)||void 0===n?void 0:n.userId,leadSource:this.leadSource,widgetType:this.widgetType,isDevState:this.shouldCreateAsDevState()}}),this.isFirstChatMessageSent||(Wi("firstChatMessageSent",{message:e,buildingId:null===(r=this.buildingWebchatView)||void 0===r?void 0:r.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.isFirstChatMessageSent=!0),Wi("chatMessageSent",{message:e,buildingId:null===(o=this.buildingWebchatView)||void 0===o?void 0:o.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}))})),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.removeDuplicatedRawPubnubMessages=e=>{const t=new Set;return e.filter((e=>{if("lead_message"===e.message.customType||!e.message.stream_id||!e.message.order)return!0;const i=`${e.message.stream_id}-${e.message.order}-${e.message.messageType}`;return t.has(i)?(en({logTitle:"PUBNUB_WARN_DUPLICATE_MESSAGE",logData:{message:e,channel:this.channel},logType:Zi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),!1):(t.add(i),!0)}))},this.translatePubnubMessagesIntoSimpleChatMessages=e=>{const t=[],i={};return this.removeDuplicatedRawPubnubMessages(e).forEach((e=>{var n;"media"===e.message.messageType?t.push({timestamp:e.timetoken,media:null!==(n=e.message.media)&&void 0!==n?n:[],isLeadMessage:this.isLeadMessage(e),type:Dr.media}):!e.message.stream_id||e.message.is_done&&0===e.message.order?t.push({timestamp:e.timetoken,message:e.message.text,isLeadMessage:this.isLeadMessage(e),chunks:[{text:e.message.text,order:0,isDone:!0}],type:Dr.text}):i[e.message.stream_id]?i[e.message.stream_id].push(e):i[e.message.stream_id]=[e]})),Object.keys(i).forEach((e=>{const n=i[e],r=this.getConsecutiveChunks(n.sort(((e,t)=>{var i,n;return(null!==(i=e.message.order)&&void 0!==i?i:0)-(null!==(n=t.message.order)&&void 0!==n?n:0)}))),o=r.map((e=>e.message.text)).join(""),a=r[0],s={timestamp:a.timetoken,message:o,isLeadMessage:this.isLeadMessage(a),chunks:r.map((e=>{var t,i;return{text:e.message.text,order:null!==(t=e.message.order)&&void 0!==t?t:0,isDone:null!==(i=e.message.is_done)&&void 0!==i&&i}})),type:Dr.text};this.isCurrentlyStreamingMessage=this.isMessageStillStreamingChunks(r),t.push(s)})),t.sort(((e,t)=>e.timestamp-t.timestamp)),t},this.getConsecutiveChunks=e=>{var t,i;const n=e.sort(((e,t)=>{var i,n;return(null!==(i=e.message.order)&&void 0!==i?i:0)-(null!==(n=t.message.order)&&void 0!==n?n:0)})),r=[];let o=null!==(t=n[0].message.order)&&void 0!==t?t:0;for(const e of n){if((null!==(i=e.message.order)&&void 0!==i?i:-1)!==o)break;r.push(e),o++}return r},this.isMessageStillStreamingChunks=e=>{const t=e.find((e=>e.message.is_done));return!t||e.length===t.message.order},this.buildingSlug=e,this.buildingWebchatView=t,this.orgSlug=i,this.leadSource=n,this.leadUserId=r,this.channel=`webchat_${r}`,this.leadSourceClient=o,this.widgetType=a}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(wr())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token,origin:"meetelise.pubnubapi.com"}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,i){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${i}&${"healthcare"===this.widgetType?"industry=health_care":""}`)).data}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:Zi.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){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(i){if(i instanceof e.AxiosError&&i&&i.response&&403===i.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){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(e=1500){var t;try{let i=[],n=null;const r=100;for(let t=0;t<e;t+=r){const o=await new Promise(((i,o)=>{if(!this.pubnub||!this.channel)return[];const a=Math.min(r,e-t);this.pubnub.fetchMessages({channels:[this.channel],count:a,start:null!=n?n:void 0},((e,t)=>{e.error?o(e):i(t)}))})),a=o.channels[this.channel];if(!a)break;if(a.sort(((e,t)=>+e.timetoken-+t.timetoken)),!a||0===a.length)break;if(this.channel&&0!==Object.keys(o.channels).length){const e=o.channels[this.channel],t=[];e.forEach((e=>{e.uuid&&t.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})})),this.markEveryPreviousNoReplyMessageDone(t),i=i.concat(t.filter((e=>e.message.messageType!==Pr.noReply)))}if(n=a[0].timetoken,i.length>=e||a.length<r)break}this.rawPubnubMessages=i.slice(0,e),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:!1})}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:Zi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}shouldCreateAsDevState(){return location.href.startsWith("https://app.meetelise.com/settings/widgets")||location.href.includes("demo/utilities")}},Ur=(e,t,i)=>{const n=`tel:${e}`,r=`sms:${e}`,o=`whatsapp://send?phone=${e}}`,a=`facetime:${e}`,s=`facetime-audio:${e}`,l=/(?:\(\d{3}\)\s|\d{3}-)\d{3}-\d{4}/g,u=/(tel|sms):(?:\(\d{3}\)\s|\d{3}-)\d{3}-\d{4}/g,d=/whatsapp:\/\/send\?phone=\d+/g,c=/(facetime|facetime-audio):\d+/g,p=document.body.getElementsByTagName("*");let h=!1;const f=e.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3");let m=!1,g=!1,v=0;for(let e=0;e<p.length;e++)if(p[e].nodeType===Node.ELEMENT_NODE){if(1===p[e].childNodes.length&&p[e].childNodes[0].nodeType==Node.TEXT_NODE){const t=p[e].innerHTML,i=t.replace(l,f);t!==i&&v++,p[e].innerHTML=i,h=!0,m||(m=!0)}if(p[e].hasAttribute("href")){const t=p[e].getAttribute("href");if(!t)continue;let i="",l=u;t.startsWith("sms:")?i=r:t.startsWith("whatsapp:")?(i=o,l=d):t.startsWith("facetime:")?(i=a,l=c):t.startsWith("facetime-audio:")?(i=s,l=c):i=n;const h=t.replace(l,i);p[e].setAttribute("href",h),g||(g=!0)}}return m&&en({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:f,website:window.location.href},logType:Zi.info,buildingSlug:i,orgSlug:t}),g&&en({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:f,website:window.location.href},logType:Zi.info,buildingSlug:i,orgSlug:t}),h||en({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:Zi.warn,buildingSlug:i,orgSlug:t}),v},Br=(e="black")=>B`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none">
3217
3217
  <line x1="1.70782" y1="13.2254" x2="13.2376" y2="1.69554" stroke="${e}" stroke-width="2.13401"/>
3218
3218
  <path d="M2.00929 1.99996L13.3328 13.3421" stroke="${e}" stroke-width="2.13401"/>
3219
3219
  </svg>`;var Lr=function(e,t,i,n){var r,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,i,a):r(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a};let qr=class extends re{constructor(){super(...arguments),this.onClick=()=>{},this.primaryColor=Me,this.toExpand=!1}render(){return U`
@@ -4313,7 +4313,7 @@ xmlns="http://www.w3.org/2000/svg"
4313
4313
  <p
4314
4314
  class=${fe({"message-text":!0,"webchat-font__desktop":!ii(),"webchat-font__mobile":ii()})}
4315
4315
  >
4316
- ${this.building.welcomeMessage}
4316
+ ${this.building.welcomeMessage.split("\n").map((e=>U`${e}<br />`))}
4317
4317
  </p>
4318
4318
  </li>`:""}
4319
4319
  ${this.messages.map((e=>U`
@@ -4397,7 +4397,7 @@ xmlns="http://www.w3.org/2000/svg"
4397
4397
  <div>
4398
4398
  <span style="font-weight: 600">Confirm to continue</span>
4399
4399
  <p>
4400
- Hello! Im your virtual assistant, Milly, and I am here to help you
4400
+ Hello! I'm your virtual assistant, Milly, and I am here to help you
4401
4401
  today. Before I can answer any questions, it is important that you
4402
4402
  know I am a third-party bot, and I will be collecting our
4403
4403
  communications and other information you provide, consistent with our
@@ -4420,7 +4420,7 @@ xmlns="http://www.w3.org/2000/svg"
4420
4420
  >
4421
4421
  privacy policy</a
4422
4422
  >
4423
- and terms and conditions, Lets go!
4423
+ and terms and conditions, Let's go!
4424
4424
  </p>
4425
4425
  </div>
4426
4426
  </div>
@@ -4429,7 +4429,7 @@ xmlns="http://www.w3.org/2000/svg"
4429
4429
  <div>
4430
4430
  <span style="font-weight: 600">Confirm to continue</span>
4431
4431
  <p>
4432
- Hello, before I can answer questions for you, its important that I let
4432
+ Hello, before I can answer questions for you, it's important that I let
4433
4433
  you know that I am a third-party AI Assistant that will collect our
4434
4434
  conversation and other information you provide, consistent with our
4435
4435
  <a
@@ -664,7 +664,9 @@ export class PubnubChat extends LitElement {
664
664
  ["webchat-font__mobile"]: isMobile(),
665
665
  })}
666
666
  >
667
- ${this.building.welcomeMessage}
667
+ ${this.building.welcomeMessage
668
+ .split("\n")
669
+ .map((line) => html`${line}<br />`)}
668
670
  </p>
669
671
  </li>`
670
672
  : ""}
@@ -865,7 +867,7 @@ const getConsentPreChatDisclaimer = (
865
867
  <div>
866
868
  <span style="font-weight: 600">Confirm to continue</span>
867
869
  <p>
868
- Hello! Im your virtual assistant, Milly, and I am here to help you
870
+ Hello! I'm your virtual assistant, Milly, and I am here to help you
869
871
  today. Before I can answer any questions, it is important that you
870
872
  know I am a third-party bot, and I will be collecting our
871
873
  communications and other information you provide, consistent with our
@@ -890,7 +892,7 @@ const getConsentPreChatDisclaimer = (
890
892
  >
891
893
  privacy policy</a
892
894
  >
893
- and terms and conditions, Lets go!
895
+ and terms and conditions, Let's go!
894
896
  </p>
895
897
  </div>
896
898
  </div>
@@ -901,7 +903,7 @@ const getConsentPreChatDisclaimer = (
901
903
  <div>
902
904
  <span style="font-weight: 600">Confirm to continue</span>
903
905
  <p>
904
- Hello, before I can answer questions for you, its important that I let
906
+ Hello, before I can answer questions for you, it's important that I let
905
907
  you know that I am a third-party AI Assistant that will collect our
906
908
  conversation and other information you provide, consistent with our
907
909
  <a
@@ -24,7 +24,7 @@ export const createChatStorageKey = (
24
24
  const storageTimestamp = formatISO(new Date());
25
25
 
26
26
  // must preface with lead for BE to extract lead id
27
- const leadUserId = leadId ? leadId : `lead_${uuid()}_${buildingSlug}`;
27
+ const leadUserId = leadId ? leadId : `lead_${uuid()}`;
28
28
  localStorage.setItem(
29
29
  "com.elise.webchat.slug=" + buildingSlug,
30
30
  JSON.stringify({