@meetelise/chat 1.21.8 → 1.21.9

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.21.8",
3
+ "version": "1.21.9",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -3240,7 +3240,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3240
3240
  ${Oi}
3241
3241
  ${Ii}
3242
3242
  ${Ni}
3243
- `,pr([le({attribute:!0})],hr.prototype,"isMinimized",void 0),pr([le()],hr.prototype,"mobileStyles",void 0),pr([le({type:Boolean})],hr.prototype,"isFirstMount",void 0),pr([le({attribute:!1})],hr.prototype,"autoOpenChatWidget",void 0),pr([le()],hr.prototype,"phoneNumber",void 0),pr([le({attribute:!0})],hr.prototype,"buildingName",void 0),pr([le({attribute:!0})],hr.prototype,"chatId",void 0),pr([le({attribute:!0})],hr.prototype,"chatCallUsHeader",void 0),pr([le({attribute:!1})],hr.prototype,"buildingId",void 0),pr([le({attribute:!0})],hr.prototype,"buildingSlug",void 0),pr([le({attribute:!0})],hr.prototype,"orgSlug",void 0),pr([le({attribute:!0})],hr.prototype,"sgtUrl",void 0),pr([le({attribute:!0})],hr.prototype,"designConcept",void 0),pr([le({attribute:!0})],hr.prototype,"featureFlagShowDropdown",void 0),pr([le({attribute:!1})],hr.prototype,"leadSources",void 0),pr([le({attribute:!0})],hr.prototype,"currentLeadSource",void 0),pr([le({attribute:!0})],hr.prototype,"escortedToursLink",void 0),pr([le({attribute:!0})],hr.prototype,"virtualToursLink",void 0),pr([le({type:Boolean})],hr.prototype,"hasChatEnabledDesktop",void 0),pr([le({type:Boolean})],hr.prototype,"hasChatEnabledMobile",void 0),pr([le({type:Boolean})],hr.prototype,"hasEmailEnabledDesktop",void 0),pr([le({type:Boolean})],hr.prototype,"hasEmailEnabledMobile",void 0),pr([le({type:Boolean})],hr.prototype,"hasCallUsEnabledDesktop",void 0),pr([le({type:Boolean})],hr.prototype,"hasCallUsEnabledMobile",void 0),pr([le({type:Boolean})],hr.prototype,"hasTextUsEnabledDesktop",void 0),pr([le({type:Boolean})],hr.prototype,"hasTextUsEnabledMobile",void 0),pr([le({type:Boolean})],hr.prototype,"hasSSTEnabledDesktop",void 0),pr([le({type:Boolean})],hr.prototype,"hasSSTEnabledMobile",void 0),pr([le({attribute:!1})],hr.prototype,"tourTypeOptions",void 0),pr([le({attribute:!0})],hr.prototype,"hasDynamicSchedulingEnabled",void 0),pr([le({attribute:!0})],hr.prototype,"onExitChat",void 0),pr([le({attribute:!1})],hr.prototype,"hasHideMobileFeatures",void 0),pr([le({type:Number})],hr.prototype,"right",void 0),pr([le({type:Number})],hr.prototype,"bottom",void 0),pr([le({type:Number})],hr.prototype,"top",void 0),pr([le({type:Number})],hr.prototype,"left",void 0),pr([le({attribute:!0})],hr.prototype,"showTourNextToChat",void 0),pr([le({attribute:!1})],hr.prototype,"onChatTapped",void 0),pr([le({attribute:!0})],hr.prototype,"onClickMinimize",void 0),pr([le({attribute:!0})],hr.prototype,"overrideRentgrata",void 0),pr([le({attribute:!1})],hr.prototype,"launcherStyles",void 0),pr([le({attribute:!0})],hr.prototype,"brandColor",void 0),pr([le({attribute:!0})],hr.prototype,"backgroundColor",void 0),pr([le({attribute:!0})],hr.prototype,"leadSourceClient",void 0),pr([ue()],hr.prototype,"isEmailWindowOpen",void 0),pr([ue()],hr.prototype,"isCallUsWindowOpen",void 0),pr([ue()],hr.prototype,"isSSTWindowOpen",void 0),pr([ue()],hr.prototype,"isTextUsWindowOpen",void 0),pr([ue()],hr.prototype,"isMobileFeaturesExpanded",void 0),hr=pr([ae("meetelise-launcher")],hr);const fr=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",hr)};var mr=n(3379),gr=n.n(mr),vr=n(7795),yr=n.n(vr),br=n(569),wr=n.n(br),Sr=n(3565),Tr=n.n(Sr),xr=n(9216),Ar=n.n(xr),Cr=n(4589),Or=n.n(Cr),Ir=n(3631),Nr={};async function Er(e){try{const n=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/lead-sources`);return n.data?Rr(n.data,e):[]}catch(e){return[]}}Nr.styleTagTransform=Or(),Nr.setAttributes=Tr(),Nr.insert=wr().bind(null,"head"),Nr.domAPI=yr(),Nr.insertStyleElement=Ar(),gr()(Ir.Z,Nr),Ir.Z&&Ir.Z.locals&&Ir.Z.locals;const Rr=(e,t)=>{let n=[];switch(t){case"d41619ec-0f79-11ee-8439-93855926ad58":n=["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":n=["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:n=[]}return e.sort(),e.filter((e=>{const t=e.toLowerCase();return!n.map((e=>e.toLowerCase())).includes(t)}))};var _r,Pr=n(9594),Mr=n.n(Pr),Fr=new Uint8Array(16);function Dr(){if(!_r&&!(_r="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 _r(Fr)}const kr=/^(?:[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,Ur=function(e){return"string"==typeof e&&kr.test(e)};for(var Lr=[],qr=0;qr<256;++qr)Lr.push((qr+256).toString(16).substr(1));const Br=function(e,t,n){var i=(e=e||{}).random||(e.rng||Dr)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var r=0;r<16;++r)t[n+r]=i[r];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(Lr[e[t+0]]+Lr[e[t+1]]+Lr[e[t+2]]+Lr[e[t+3]]+"-"+Lr[e[t+4]]+Lr[e[t+5]]+"-"+Lr[e[t+6]]+Lr[e[t+7]]+"-"+Lr[e[t+8]]+Lr[e[t+9]]+"-"+Lr[e[t+10]]+Lr[e[t+11]]+Lr[e[t+12]]+Lr[e[t+13]]+Lr[e[t+14]]+Lr[e[t+15]]).toLowerCase();if(!Ur(n))throw TypeError("Stringified UUID is invalid");return n}(i)},Jr=e=>localStorage.removeItem("com.elise.webchat.slug="+e),jr=(e,t,n)=>{const i=yn(new Date),r=n||`lead_${Br()}_${e}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:i,initiatedChat:t})),{leadId:r,timestamp:Cn(i),buildingSlug:e,initiatedChat:t}},Hr=e=>{const t=localStorage.getItem("com.elise.webchat.slug="+e);if(t)try{const n=JSON.parse(t),i={leadId:n.leadId,timestamp:new Date(n.timestamp),buildingSlug:n.buildingSlug,initiatedChat:n.initiatedChat};if(Gr(e,i))return i}catch(e){console.warn("Error getting chat storage key")}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},Gr=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if(un(t.timestamp,e))return!1}}catch(e){console.warn("Error checking chat storage key validity")}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp||pn(t.timestamp,24))};var zr;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(zr||(zr={}));const Wr=e=>e.type===Qr.text,Vr=e=>e.type===Qr.media;var Qr;!function(e){e.text="text",e.media="media"}(Qr||(Qr={}));const Kr=class{constructor(e,t,n,i=null,r,o=null){this.apiHost="https://app.meetelise.com",this.leadSourceClient=null,this.building=null,this.eliseResponseTimeout=null,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,n;e.message.messageType!==zr.noReply&&(this.rawPubnubMessages=[...this.rawPubnubMessages,{channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken}],this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages));const i="eliseai"!==e.publisher&&"elise_health_ai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:i}),!i&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=i,"ai_message"===e.message.customType&&this.simpleChatMessages.some((e=>e.type===Qr.text&&e.message.includes("confirmed for your tour")))&&ei("scheduledTourEvent",{tourDetails:e.message,buildingId:null===(n=this.building)||void 0===n?void 0:n.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.checkAndHandleGTMForLeadEmail(e)}},this.isLoadingMessages=!1,this.isFirstChatMessageSent=!1,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;ei("leadProvidedEmail",{buildingId:null===(t=this.building)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel})}catch(e){return}},this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){this.building&&li({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:si.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.handleDisconnect=()=>{this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.removeChatListeners()},this.removeChatListeners=()=>{this.pubnub&&this.channel&&(this.pubnub.unsubscribe({channels:[this.channel]}),this.pubnub.removeListener(this.listenerParams))},this.sendMessage=async e=>{if(e){if(!this.pubnub){const e=jr(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken((async()=>{var t,n,i,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.building&&li({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:si.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})),await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(n=this.building)||void 0===n?void 0:n.id,buildingSlug:this.buildingSlug,userId:null===(i=this.building)||void 0===i?void 0:i.userId,leadSource:this.leadSource,isDevState:this.shouldCreateAsDevState()}}),this.isFirstChatMessageSent||(ei("firstChatMessageSent",{message:e,buildingId:null===(r=this.building)||void 0===r?void 0:r.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.isFirstChatMessageSent=!0),ei("chatMessageSent",{message:e,buildingId:null===(o=this.building)||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.translatePubnubMessagesIntoSimpleChatMessages=e=>{const t=[],n={};return e.forEach((e=>{var i;"media"===e.message.messageType?t.push({timestamp:e.timetoken,media:null!==(i=e.message.media)&&void 0!==i?i:[],isLeadMessage:this.isLeadMessage(e),type:Qr.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:Qr.text}):n[e.message.stream_id]?n[e.message.stream_id].push(e):n[e.message.stream_id]=[e]})),Object.keys(n).forEach((e=>{const i=n[e],r=this.getConsecutiveChunks(i.sort(((e,t)=>{var n,i;return(null!==(n=e.message.order)&&void 0!==n?n:0)-(null!==(i=t.message.order)&&void 0!==i?i: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,n;return{text:e.message.text,order:null!==(t=e.message.order)&&void 0!==t?t:0,isDone:null!==(n=e.message.is_done)&&void 0!==n&&n}})),type:Qr.text};this.isCurrentlyStreamingMessage=this.isMessageStillStreamingChunks(r),t.push(s)})),t.sort(((e,t)=>e.timestamp-t.timestamp)),t},this.getConsecutiveChunks=e=>{var t,n;const i=e.sort(((e,t)=>{var n,i;return(null!==(n=e.message.order)&&void 0!==n?n:0)-(null!==(i=t.message.order)&&void 0!==i?i:0)})),r=[];let o=null!==(t=i[0].message.order)&&void 0!==t?t:0;for(const e of i){if((null!==(n=e.message.order)&&void 0!==n?n:-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.building=t,this.orgSlug=n,this.leadSource=i,this.leadUserId=r,this.channel=`webchat_${r}`,this.leadSourceClient=o}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(Mr())({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,n){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${n}&${this.building?"":"industry=health_care"}`)).data}catch(e){this.building&&li({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:si.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.building&&li({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:si.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(n){if(n instanceof e.AxiosError&&n&&n.response&&403===n.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const e=await this.fetchToken(this.leadUserId,this.channel);if(!e)return;this.pubnub.setAuthKey(e.auth.result.token),await t()}catch(e){this.building&&li({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:si.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(e=1500){var t;try{let n=[],i=null;const r=100;for(let t=0;t<e;t+=r){const o=await new Promise(((n,o)=>{if(!this.pubnub||!this.channel)return[];const a=Math.min(r,e-t);this.pubnub.fetchMessages({channels:[this.channel],count:a,start:null!=i?i:void 0},((e,t)=>{e.error?o(e):n(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})})),n=n.concat(t.filter((e=>e.message.messageType!==zr.noReply)))}if(i=a[0].timetoken,n.length>=e||a.length<r)break}this.rawPubnubMessages=n.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.building&&li({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:si.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}shouldCreateAsDevState(){return location.href.startsWith("https://app.meetelise.com/settings/widgets")}},Xr=(e,t,n)=>{const i=`tel:${e}`,r=`sms:${e}`,o=`whatsapp://send?phone=${e}}`,a=`facetime:${e}`,s=`facetime-audio:${e}`,l=/\(\d{3}\)\s\d{3}-\d{4}/g,u=/(tel|sms):\(\d{3}\)\s\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;for(let e=0;e<p.length;e++)if(p[e].nodeType===Node.ELEMENT_NODE&&(1===p[e].childNodes.length&&p[e].childNodes[0].nodeType==Node.TEXT_NODE&&(p[e].innerHTML=p[e].innerHTML.replace(l,f),h=!0,m||(m=!0)),p[e].hasAttribute("href"))){const t=p[e].getAttribute("href");if(!t)continue;let n="",l=u;t.startsWith("sms:")?n=r:t.startsWith("whatsapp:")?(n=o,l=d):t.startsWith("facetime:")?(n=a,l=c):t.startsWith("facetime-audio:")?(n=s,l=c):n=i;const h=t.replace(l,n);p[e].setAttribute("href",h),g||(g=!0)}m&&li({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:f,website:window.location.href},logType:si.info,buildingSlug:n,orgSlug:t}),g&&li({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:f,website:window.location.href},logType:si.info,buildingSlug:n,orgSlug:t}),h||li({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:si.warn,buildingSlug:n,orgSlug:t})};var Yr=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 $r=class extends re{constructor(){super(...arguments),this.onClick=()=>{},this.brandColor=Me,this.toExpand=!1}render(){return U`
3243
+ `,pr([le({attribute:!0})],hr.prototype,"isMinimized",void 0),pr([le()],hr.prototype,"mobileStyles",void 0),pr([le({type:Boolean})],hr.prototype,"isFirstMount",void 0),pr([le({attribute:!1})],hr.prototype,"autoOpenChatWidget",void 0),pr([le()],hr.prototype,"phoneNumber",void 0),pr([le({attribute:!0})],hr.prototype,"buildingName",void 0),pr([le({attribute:!0})],hr.prototype,"chatId",void 0),pr([le({attribute:!0})],hr.prototype,"chatCallUsHeader",void 0),pr([le({attribute:!1})],hr.prototype,"buildingId",void 0),pr([le({attribute:!0})],hr.prototype,"buildingSlug",void 0),pr([le({attribute:!0})],hr.prototype,"orgSlug",void 0),pr([le({attribute:!0})],hr.prototype,"sgtUrl",void 0),pr([le({attribute:!0})],hr.prototype,"designConcept",void 0),pr([le({attribute:!0})],hr.prototype,"featureFlagShowDropdown",void 0),pr([le({attribute:!1})],hr.prototype,"leadSources",void 0),pr([le({attribute:!0})],hr.prototype,"currentLeadSource",void 0),pr([le({attribute:!0})],hr.prototype,"escortedToursLink",void 0),pr([le({attribute:!0})],hr.prototype,"virtualToursLink",void 0),pr([le({type:Boolean})],hr.prototype,"hasChatEnabledDesktop",void 0),pr([le({type:Boolean})],hr.prototype,"hasChatEnabledMobile",void 0),pr([le({type:Boolean})],hr.prototype,"hasEmailEnabledDesktop",void 0),pr([le({type:Boolean})],hr.prototype,"hasEmailEnabledMobile",void 0),pr([le({type:Boolean})],hr.prototype,"hasCallUsEnabledDesktop",void 0),pr([le({type:Boolean})],hr.prototype,"hasCallUsEnabledMobile",void 0),pr([le({type:Boolean})],hr.prototype,"hasTextUsEnabledDesktop",void 0),pr([le({type:Boolean})],hr.prototype,"hasTextUsEnabledMobile",void 0),pr([le({type:Boolean})],hr.prototype,"hasSSTEnabledDesktop",void 0),pr([le({type:Boolean})],hr.prototype,"hasSSTEnabledMobile",void 0),pr([le({attribute:!1})],hr.prototype,"tourTypeOptions",void 0),pr([le({attribute:!0})],hr.prototype,"hasDynamicSchedulingEnabled",void 0),pr([le({attribute:!0})],hr.prototype,"onExitChat",void 0),pr([le({attribute:!1})],hr.prototype,"hasHideMobileFeatures",void 0),pr([le({type:Number})],hr.prototype,"right",void 0),pr([le({type:Number})],hr.prototype,"bottom",void 0),pr([le({type:Number})],hr.prototype,"top",void 0),pr([le({type:Number})],hr.prototype,"left",void 0),pr([le({attribute:!0})],hr.prototype,"showTourNextToChat",void 0),pr([le({attribute:!1})],hr.prototype,"onChatTapped",void 0),pr([le({attribute:!0})],hr.prototype,"onClickMinimize",void 0),pr([le({attribute:!0})],hr.prototype,"overrideRentgrata",void 0),pr([le({attribute:!1})],hr.prototype,"launcherStyles",void 0),pr([le({attribute:!0})],hr.prototype,"brandColor",void 0),pr([le({attribute:!0})],hr.prototype,"backgroundColor",void 0),pr([le({attribute:!0})],hr.prototype,"leadSourceClient",void 0),pr([ue()],hr.prototype,"isEmailWindowOpen",void 0),pr([ue()],hr.prototype,"isCallUsWindowOpen",void 0),pr([ue()],hr.prototype,"isSSTWindowOpen",void 0),pr([ue()],hr.prototype,"isTextUsWindowOpen",void 0),pr([ue()],hr.prototype,"isMobileFeaturesExpanded",void 0),hr=pr([ae("meetelise-launcher")],hr);const fr=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",hr)};var mr=n(3379),gr=n.n(mr),vr=n(7795),yr=n.n(vr),br=n(569),wr=n.n(br),Sr=n(3565),Tr=n.n(Sr),xr=n(9216),Ar=n.n(xr),Cr=n(4589),Or=n.n(Cr),Ir=n(3631),Nr={};async function Er(e,n){try{const i=await t().get(`https://app.meetelise.com/platformApi/webchat/${n}/lead-sources`);if(i.data){if("7e352741-1120-4ccf-9929-5dc99193a908"===e){const e=["Zillow","Apartments.com","Google PPC","Google Maps","Apple Maps","Social Media","Print Marketing"];return i.data.filter((t=>e.includes(t)))}return Rr(i.data,n)}return[]}catch(e){return[]}}Nr.styleTagTransform=Or(),Nr.setAttributes=Tr(),Nr.insert=wr().bind(null,"head"),Nr.domAPI=yr(),Nr.insertStyleElement=Ar(),gr()(Ir.Z,Nr),Ir.Z&&Ir.Z.locals&&Ir.Z.locals;const Rr=(e,t)=>{let n=[];switch(t){case"d41619ec-0f79-11ee-8439-93855926ad58":n=["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":n=["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"]}return e.sort(),e.filter((e=>{const t=e.toLowerCase();return!n.map((e=>e.toLowerCase())).includes(t)}))};var _r,Pr=n(9594),Mr=n.n(Pr),Fr=new Uint8Array(16);function Dr(){if(!_r&&!(_r="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 _r(Fr)}const kr=/^(?:[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,Ur=function(e){return"string"==typeof e&&kr.test(e)};for(var Lr=[],qr=0;qr<256;++qr)Lr.push((qr+256).toString(16).substr(1));const Br=function(e,t,n){var i=(e=e||{}).random||(e.rng||Dr)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var r=0;r<16;++r)t[n+r]=i[r];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(Lr[e[t+0]]+Lr[e[t+1]]+Lr[e[t+2]]+Lr[e[t+3]]+"-"+Lr[e[t+4]]+Lr[e[t+5]]+"-"+Lr[e[t+6]]+Lr[e[t+7]]+"-"+Lr[e[t+8]]+Lr[e[t+9]]+"-"+Lr[e[t+10]]+Lr[e[t+11]]+Lr[e[t+12]]+Lr[e[t+13]]+Lr[e[t+14]]+Lr[e[t+15]]).toLowerCase();if(!Ur(n))throw TypeError("Stringified UUID is invalid");return n}(i)},Jr=e=>localStorage.removeItem("com.elise.webchat.slug="+e),jr=(e,t,n)=>{const i=yn(new Date),r=n||`lead_${Br()}_${e}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:i,initiatedChat:t})),{leadId:r,timestamp:Cn(i),buildingSlug:e,initiatedChat:t}},Hr=e=>{const t=localStorage.getItem("com.elise.webchat.slug="+e);if(t)try{const n=JSON.parse(t),i={leadId:n.leadId,timestamp:new Date(n.timestamp),buildingSlug:n.buildingSlug,initiatedChat:n.initiatedChat};if(Gr(e,i))return i}catch(e){console.warn("Error getting chat storage key")}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},Gr=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if(un(t.timestamp,e))return!1}}catch(e){console.warn("Error checking chat storage key validity")}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp||pn(t.timestamp,24))};var zr;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(zr||(zr={}));const Wr=e=>e.type===Qr.text,Vr=e=>e.type===Qr.media;var Qr;!function(e){e.text="text",e.media="media"}(Qr||(Qr={}));const Kr=class{constructor(e,t,n,i=null,r,o=null){this.apiHost="https://app.meetelise.com",this.leadSourceClient=null,this.building=null,this.eliseResponseTimeout=null,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,n;e.message.messageType!==zr.noReply&&(this.rawPubnubMessages=[...this.rawPubnubMessages,{channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken}],this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages));const i="eliseai"!==e.publisher&&"elise_health_ai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:i}),!i&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=i,"ai_message"===e.message.customType&&this.simpleChatMessages.some((e=>e.type===Qr.text&&e.message.includes("confirmed for your tour")))&&ei("scheduledTourEvent",{tourDetails:e.message,buildingId:null===(n=this.building)||void 0===n?void 0:n.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.checkAndHandleGTMForLeadEmail(e)}},this.isLoadingMessages=!1,this.isFirstChatMessageSent=!1,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;ei("leadProvidedEmail",{buildingId:null===(t=this.building)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel})}catch(e){return}},this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){this.building&&li({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:si.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.handleDisconnect=()=>{this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.removeChatListeners()},this.removeChatListeners=()=>{this.pubnub&&this.channel&&(this.pubnub.unsubscribe({channels:[this.channel]}),this.pubnub.removeListener(this.listenerParams))},this.sendMessage=async e=>{if(e){if(!this.pubnub){const e=jr(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken((async()=>{var t,n,i,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.building&&li({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:si.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})),await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(n=this.building)||void 0===n?void 0:n.id,buildingSlug:this.buildingSlug,userId:null===(i=this.building)||void 0===i?void 0:i.userId,leadSource:this.leadSource,isDevState:this.shouldCreateAsDevState()}}),this.isFirstChatMessageSent||(ei("firstChatMessageSent",{message:e,buildingId:null===(r=this.building)||void 0===r?void 0:r.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.isFirstChatMessageSent=!0),ei("chatMessageSent",{message:e,buildingId:null===(o=this.building)||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.translatePubnubMessagesIntoSimpleChatMessages=e=>{const t=[],n={};return e.forEach((e=>{var i;"media"===e.message.messageType?t.push({timestamp:e.timetoken,media:null!==(i=e.message.media)&&void 0!==i?i:[],isLeadMessage:this.isLeadMessage(e),type:Qr.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:Qr.text}):n[e.message.stream_id]?n[e.message.stream_id].push(e):n[e.message.stream_id]=[e]})),Object.keys(n).forEach((e=>{const i=n[e],r=this.getConsecutiveChunks(i.sort(((e,t)=>{var n,i;return(null!==(n=e.message.order)&&void 0!==n?n:0)-(null!==(i=t.message.order)&&void 0!==i?i: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,n;return{text:e.message.text,order:null!==(t=e.message.order)&&void 0!==t?t:0,isDone:null!==(n=e.message.is_done)&&void 0!==n&&n}})),type:Qr.text};this.isCurrentlyStreamingMessage=this.isMessageStillStreamingChunks(r),t.push(s)})),t.sort(((e,t)=>e.timestamp-t.timestamp)),t},this.getConsecutiveChunks=e=>{var t,n;const i=e.sort(((e,t)=>{var n,i;return(null!==(n=e.message.order)&&void 0!==n?n:0)-(null!==(i=t.message.order)&&void 0!==i?i:0)})),r=[];let o=null!==(t=i[0].message.order)&&void 0!==t?t:0;for(const e of i){if((null!==(n=e.message.order)&&void 0!==n?n:-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.building=t,this.orgSlug=n,this.leadSource=i,this.leadUserId=r,this.channel=`webchat_${r}`,this.leadSourceClient=o}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(Mr())({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,n){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${n}&${this.building?"":"industry=health_care"}`)).data}catch(e){this.building&&li({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:si.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.building&&li({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:si.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(n){if(n instanceof e.AxiosError&&n&&n.response&&403===n.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const e=await this.fetchToken(this.leadUserId,this.channel);if(!e)return;this.pubnub.setAuthKey(e.auth.result.token),await t()}catch(e){this.building&&li({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:si.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(e=1500){var t;try{let n=[],i=null;const r=100;for(let t=0;t<e;t+=r){const o=await new Promise(((n,o)=>{if(!this.pubnub||!this.channel)return[];const a=Math.min(r,e-t);this.pubnub.fetchMessages({channels:[this.channel],count:a,start:null!=i?i:void 0},((e,t)=>{e.error?o(e):n(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})})),n=n.concat(t.filter((e=>e.message.messageType!==zr.noReply)))}if(i=a[0].timetoken,n.length>=e||a.length<r)break}this.rawPubnubMessages=n.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.building&&li({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:si.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}shouldCreateAsDevState(){return location.href.startsWith("https://app.meetelise.com/settings/widgets")}},Xr=(e,t,n)=>{const i=`tel:${e}`,r=`sms:${e}`,o=`whatsapp://send?phone=${e}}`,a=`facetime:${e}`,s=`facetime-audio:${e}`,l=/\(\d{3}\)\s\d{3}-\d{4}/g,u=/(tel|sms):\(\d{3}\)\s\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;for(let e=0;e<p.length;e++)if(p[e].nodeType===Node.ELEMENT_NODE&&(1===p[e].childNodes.length&&p[e].childNodes[0].nodeType==Node.TEXT_NODE&&(p[e].innerHTML=p[e].innerHTML.replace(l,f),h=!0,m||(m=!0)),p[e].hasAttribute("href"))){const t=p[e].getAttribute("href");if(!t)continue;let n="",l=u;t.startsWith("sms:")?n=r:t.startsWith("whatsapp:")?(n=o,l=d):t.startsWith("facetime:")?(n=a,l=c):t.startsWith("facetime-audio:")?(n=s,l=c):n=i;const h=t.replace(l,n);p[e].setAttribute("href",h),g||(g=!0)}m&&li({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:f,website:window.location.href},logType:si.info,buildingSlug:n,orgSlug:t}),g&&li({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:f,website:window.location.href},logType:si.info,buildingSlug:n,orgSlug:t}),h||li({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:si.warn,buildingSlug:n,orgSlug:t})};var Yr=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 $r=class extends re{constructor(){super(...arguments),this.onClick=()=>{},this.brandColor=Me,this.toExpand=!1}render(){return U`
3244
3244
  <div
3245
3245
  class=${this.toExpand?"button-container mini":"button-container"}
3246
3246
  @click=${this.onClick}
@@ -4250,7 +4250,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
4250
4250
  I agree
4251
4251
  </button>
4252
4252
  </div>
4253
- `;var wo=n(308),So=n.n(wo),To=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 xo=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.brandColor=null,this.backgroundColor=null,this.chatId="",this.analytics=null,this.launcher=null,this.building=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=Xn.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.overrideRentgrata=!1,this.onWidgetLoaded=So(),this.enabledChatWidgets={callDesktop:!0,callMobile:!0,chatMobile:!0,chatDesktop:!0,emailDesktop:!0,emailMobile:!0,textDesktop:!0,textMobile:!0,sstDesktop:!0,sstMobile:!0},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.hideMobileFeatures=!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 wi(this.orgSlug,this.buildingSlug);if(Math.random()<.2)try{(async(e,n)=>{const i=window.rentgrata;if(!i)return;const r=i.Widget;if(!r)return;const o=r.config;if(!o)return;const a=o.widgetKey;a&&await t().post(`https://app.meetelise.com/platformApi/webchat/rentgrata?token=${a}`,{},{headers:{"Content-Type":"application/json","building-slug":null!=e?e:"","org-slug":null!=n?n:""}})})(this.buildingSlug,this.orgSlug)}catch(e){console.warn("Error updating rentgrata token",e)}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,l,u,d,c,p,h,f,m,g,v,y,b,w,S,T,x,A,C,O,I,N,E,R,_,P,M,F,D;const k=this.building;if(!k)return;k&&this.orgSlug&&Co(this.orgSlug,this.buildingSlug,null!==(n=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.leadSource)&&void 0!==n?n:null);const[U,L,q,B,J,j]=await Promise.all([Ci(this.buildingSlug),Er(this.buildingSlug),Yn(this.buildingSlug),$n(this.buildingSlug),Ai(k.id),Zn(this.buildingSlug)]);this.building&&(this.building.phoneNumber=Ne(k.phoneNumber)),this.designConcept=null!==(i=null==U?void 0:U.abTestType)&&void 0!==i?i:"",this.leadSources=L,this.featureFlagShowDropdown=q;const H=k.textWithUsPhoneNumber?k.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 li({logType:si.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var G,z;this.enabledChatWidgets={callDesktop:!(null===(r=null==J?void 0:J.config.shouldShowPhone)||void 0===r||!r)||null!==(o=null==J?void 0:J.config.shouldShowPhoneDesktop)&&void 0!==o&&o,callMobile:!(null===(a=null==J?void 0:J.config.shouldShowPhone)||void 0===a||!a)||null!==(s=null==J?void 0:J.config.shouldShowPhoneMobile)&&void 0!==s&&s,chatDesktop:!(null===(l=null==J?void 0:J.config.shouldShowChat)||void 0===l||!l)||null!==(u=null==J?void 0:J.config.shouldShowChatDesktop)&&void 0!==u&&u,chatMobile:!(null===(d=null==J?void 0:J.config.shouldShowChat)||void 0===d||!d)||null!==(c=null==J?void 0:J.config.shouldShowChatMobile)&&void 0!==c&&c,emailDesktop:!(null===(p=null==J?void 0:J.config.shouldShowEmail)||void 0===p||!p)||null!==(h=null==J?void 0:J.config.shouldShowEmailDesktop)&&void 0!==h&&h,emailMobile:!(null===(f=null==J?void 0:J.config.shouldShowEmail)||void 0===f||!f)||null!==(m=null==J?void 0:J.config.shouldShowEmailMobile)&&void 0!==m&&m,textDesktop:(!(null===(g=null==J?void 0:J.config.shouldShowText)||void 0===g||!g)||null!==(v=null==J?void 0:J.config.shouldShowTextDesktop)&&void 0!==v&&v)&&!!H,textMobile:(!(null===(y=null==J?void 0:J.config.shouldShowText)||void 0===y||!y)||null!==(b=null==J?void 0:J.config.shouldShowTextMobile)&&void 0!==b&&b)&&!!H,sstDesktop:!(null===(w=null==J?void 0:J.config.shouldShowSst)||void 0===w||!w)||null!==(S=null==J?void 0:J.config.shouldShowSstDesktop)&&void 0!==S&&S,sstMobile:!(null===(T=null==J?void 0:J.config.shouldShowSst)||void 0===T||!T)||null!==(x=null==J?void 0:J.config.shouldShowSstMobile)&&void 0!==x&&x},this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile?(z=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(),z(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===(A=this.LeadSourceClient)||void 0===A?void 0:A.leadSource)&&(G=null!==(O=null===(C=this.LeadSourceClient)||void 0===C?void 0:C.leadSource)&&void 0!==O?O: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(G)}`)}}))),J&&J.config&&(this.brandColor=null!==(I=J.config.primaryColor)&&void 0!==I?I:null,this.backgroundColor=null!==(N=J.config.backgroundColor)&&void 0!==N?N:null,this.webchatConfigHasAutoOpenChat=J.config.autoOpenChat,this.requiresConsent=J.config.requiresConsent,this.hideMobileFeatures=J.config.hideMobileFeatures,this.privacyPolicyUrl=null!==(E=J.config.privacyPolicyUrl)&&void 0!==E?E:this.privacyPolicyUrl,J.config.displayStyle===Ti.MINIMIZED&&(this.isMinimized=!0),J.config.displayStyle===Ti.PILLS&&(this.designConcept=null),J.config.displayStyle===Ti.EMOJI&&(this.designConcept=Ti.EMOJI),this.onWidgetLoaded()),null===this.brandColor&&(this.brandColor=Me),null===this.backgroundColor&&(this.backgroundColor=Fe);const W=null!==(_=null===(R=this.building)||void 0===R?void 0:R.phoneNumber)&&void 0!==_?_:"";let V=null;B&&(V=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!==(M=null===(P=this.LeadSourceClient)||void 0===P?void 0:P.leadSource)&&void 0!==M?M:null),V&&!V.isMatch&&(V.number=W)),j&&(null==V?void 0:V.number)&&Xr(V.number,this.orgSlug,this.buildingSlug);const Q=localStorage.getItem("eliseai_phone_number_devtest");Q&&(console.info("Using dev test phone number: ",Q),Xr(Q,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=V||{number:W,isMatch:!1,isPropertyWebsiteCatchall:!0};const K=null!==(D=null===(F=this.LeadSourceClient)||void 0===F?void 0:F.leadSource)&&void 0!==D?D:null;K&&(this.leadSources.includes(K)||this.leadSources.push(K)),Bn(k.id)},this.initializeChatVariables=async()=>{var e,n,i,r,o,a,s;if(!this.building)return;const l=Hr(this.buildingSlug),u=Gr(this.buildingSlug,l)?l:jr(this.buildingSlug,!1);if(!u.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.localStorageTTLDays=30,this.buildingId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,n)=>{const i=this.getLeadSourceBodyIfValid(e);if(i&&!pn(i.timestamp,24*this.localStorageTTLDays))return{...i,timestamp:Cn(i.timestamp)};const r=ui();this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:r,referrer:document.referrer,parsedUtmSource:r?r.utm_source:null,campaignSources:Object.values(ai()).filter((e=>e))};const o={leadSource:t,leadId:n,buildingSlug:e,timestamp:yn(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(o)),{...o,timestamp:Cn(o.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&&!pn(Cn(n.timestamp),24*this.localStorageTTLDays)){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,l,u;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===(l=this.leadSourceInput)||void 0===l?void 0:l.parsedUtmSource,campaign_sources:null===(u=this.leadSourceInput)||void 0===u?void 0:u.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:pi()(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:ui(),buildingSlug:n,referrer:document.referrer,campaignSources:ai()},r=n?this.getLeadSourceBodyIfValid(n):null;if(r)return this.leadSource=r.leadSource,this.leadSource;const o=await this.fetchCurrentParsedLeadSource(i);if(this.leadSource=o,this.buildingId=null,this.orgSlug=t,this.buildingSlug=n,n&&!o){const e=this.getLeadSourceBodyIfValid(n);if(e)return this.leadSource=e.leadSource,this.leadSource}return n&&o&&this.updateLeadSourceLocalStorage(n,o,e),o}catch(e){console.error(e)}return null}},this.myPubnub=new Kr(this.buildingSlug,this.building,this.orgSlug,null,u.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})),"property-website"!==hi(this.orgSlug)?this.myPubnub.leadSource=null!==(o=null===(r=this.LeadSourceClient)||void 0===r?void 0:r.leadSource)&&void 0!==o?o:hi(this.orgSlug):this.myPubnub.leadSource=null!==(s=null===(a=this.LeadSourceClient)||void 0===a?void 0:a.leadSource)&&void 0!==s?s:null,u.initiatedChat&&await this.myPubnub.initializePubnub(l)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!xn(Cn(t)));return!!e&&!!n&&!cn()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",yn(function(e,t){Le(2,arguments);var n=tt(t);return nt(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,l,u,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!==(u=null===(l=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===l?void 0:l.getElementById("email-us-form"))&&void 0!==u?u: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
4253
+ `;var wo=n(308),So=n.n(wo),To=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 xo=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.brandColor=null,this.backgroundColor=null,this.chatId="",this.analytics=null,this.launcher=null,this.building=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=Xn.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.overrideRentgrata=!1,this.onWidgetLoaded=So(),this.enabledChatWidgets={callDesktop:!0,callMobile:!0,chatMobile:!0,chatDesktop:!0,emailDesktop:!0,emailMobile:!0,textDesktop:!0,textMobile:!0,sstDesktop:!0,sstMobile:!0},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.hideMobileFeatures=!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 wi(this.orgSlug,this.buildingSlug);if(Math.random()<.2)try{(async(e,n)=>{const i=window.rentgrata;if(!i)return;const r=i.Widget;if(!r)return;const o=r.config;if(!o)return;const a=o.widgetKey;a&&await t().post(`https://app.meetelise.com/platformApi/webchat/rentgrata?token=${a}`,{},{headers:{"Content-Type":"application/json","building-slug":null!=e?e:"","org-slug":null!=n?n:""}})})(this.buildingSlug,this.orgSlug)}catch(e){console.warn("Error updating rentgrata token",e)}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,l,u,d,c,p,h,f,m,g,v,y,b,w,S,T,x,A,C,O,I,N,E,R,_,P,M,F,D;const k=this.building;if(!k)return;k&&this.orgSlug&&Co(this.orgSlug,this.buildingSlug,null!==(n=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.leadSource)&&void 0!==n?n:null);const[U,L,q,B,J,j]=await Promise.all([Ci(this.buildingSlug),Er(this.orgSlug,this.buildingSlug),Yn(this.buildingSlug),$n(this.buildingSlug),Ai(k.id),Zn(this.buildingSlug)]);this.building&&(this.building.phoneNumber=Ne(k.phoneNumber)),this.designConcept=null!==(i=null==U?void 0:U.abTestType)&&void 0!==i?i:"",this.leadSources=L,this.featureFlagShowDropdown=q;const H=k.textWithUsPhoneNumber?k.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 li({logType:si.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var G,z;this.enabledChatWidgets={callDesktop:!(null===(r=null==J?void 0:J.config.shouldShowPhone)||void 0===r||!r)||null!==(o=null==J?void 0:J.config.shouldShowPhoneDesktop)&&void 0!==o&&o,callMobile:!(null===(a=null==J?void 0:J.config.shouldShowPhone)||void 0===a||!a)||null!==(s=null==J?void 0:J.config.shouldShowPhoneMobile)&&void 0!==s&&s,chatDesktop:!(null===(l=null==J?void 0:J.config.shouldShowChat)||void 0===l||!l)||null!==(u=null==J?void 0:J.config.shouldShowChatDesktop)&&void 0!==u&&u,chatMobile:!(null===(d=null==J?void 0:J.config.shouldShowChat)||void 0===d||!d)||null!==(c=null==J?void 0:J.config.shouldShowChatMobile)&&void 0!==c&&c,emailDesktop:!(null===(p=null==J?void 0:J.config.shouldShowEmail)||void 0===p||!p)||null!==(h=null==J?void 0:J.config.shouldShowEmailDesktop)&&void 0!==h&&h,emailMobile:!(null===(f=null==J?void 0:J.config.shouldShowEmail)||void 0===f||!f)||null!==(m=null==J?void 0:J.config.shouldShowEmailMobile)&&void 0!==m&&m,textDesktop:(!(null===(g=null==J?void 0:J.config.shouldShowText)||void 0===g||!g)||null!==(v=null==J?void 0:J.config.shouldShowTextDesktop)&&void 0!==v&&v)&&!!H,textMobile:(!(null===(y=null==J?void 0:J.config.shouldShowText)||void 0===y||!y)||null!==(b=null==J?void 0:J.config.shouldShowTextMobile)&&void 0!==b&&b)&&!!H,sstDesktop:!(null===(w=null==J?void 0:J.config.shouldShowSst)||void 0===w||!w)||null!==(S=null==J?void 0:J.config.shouldShowSstDesktop)&&void 0!==S&&S,sstMobile:!(null===(T=null==J?void 0:J.config.shouldShowSst)||void 0===T||!T)||null!==(x=null==J?void 0:J.config.shouldShowSstMobile)&&void 0!==x&&x},this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile?(z=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(),z(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===(A=this.LeadSourceClient)||void 0===A?void 0:A.leadSource)&&(G=null!==(O=null===(C=this.LeadSourceClient)||void 0===C?void 0:C.leadSource)&&void 0!==O?O: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(G)}`)}}))),J&&J.config&&(this.brandColor=null!==(I=J.config.primaryColor)&&void 0!==I?I:null,this.backgroundColor=null!==(N=J.config.backgroundColor)&&void 0!==N?N:null,this.webchatConfigHasAutoOpenChat=J.config.autoOpenChat,this.requiresConsent=J.config.requiresConsent,this.hideMobileFeatures=J.config.hideMobileFeatures,this.privacyPolicyUrl=null!==(E=J.config.privacyPolicyUrl)&&void 0!==E?E:this.privacyPolicyUrl,J.config.displayStyle===Ti.MINIMIZED&&(this.isMinimized=!0),J.config.displayStyle===Ti.PILLS&&(this.designConcept=null),J.config.displayStyle===Ti.EMOJI&&(this.designConcept=Ti.EMOJI),this.onWidgetLoaded()),null===this.brandColor&&(this.brandColor=Me),null===this.backgroundColor&&(this.backgroundColor=Fe);const W=null!==(_=null===(R=this.building)||void 0===R?void 0:R.phoneNumber)&&void 0!==_?_:"";let V=null;B&&(V=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!==(M=null===(P=this.LeadSourceClient)||void 0===P?void 0:P.leadSource)&&void 0!==M?M:null),V&&!V.isMatch&&(V.number=W)),j&&(null==V?void 0:V.number)&&Xr(V.number,this.orgSlug,this.buildingSlug);const Q=localStorage.getItem("eliseai_phone_number_devtest");Q&&(console.info("Using dev test phone number: ",Q),Xr(Q,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=V||{number:W,isMatch:!1,isPropertyWebsiteCatchall:!0};const K=null!==(D=null===(F=this.LeadSourceClient)||void 0===F?void 0:F.leadSource)&&void 0!==D?D:null;K&&(this.leadSources.includes(K)||this.leadSources.push(K)),Bn(k.id)},this.initializeChatVariables=async()=>{var e,n,i,r,o,a,s;if(!this.building)return;const l=Hr(this.buildingSlug),u=Gr(this.buildingSlug,l)?l:jr(this.buildingSlug,!1);if(!u.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.localStorageTTLDays=30,this.buildingId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,n)=>{const i=this.getLeadSourceBodyIfValid(e);if(i&&!pn(i.timestamp,24*this.localStorageTTLDays))return{...i,timestamp:Cn(i.timestamp)};const r=ui();this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:r,referrer:document.referrer,parsedUtmSource:r?r.utm_source:null,campaignSources:Object.values(ai()).filter((e=>e))};const o={leadSource:t,leadId:n,buildingSlug:e,timestamp:yn(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(o)),{...o,timestamp:Cn(o.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&&!pn(Cn(n.timestamp),24*this.localStorageTTLDays)){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,l,u;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===(l=this.leadSourceInput)||void 0===l?void 0:l.parsedUtmSource,campaign_sources:null===(u=this.leadSourceInput)||void 0===u?void 0:u.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:pi()(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:ui(),buildingSlug:n,referrer:document.referrer,campaignSources:ai()},r=n?this.getLeadSourceBodyIfValid(n):null;if(r)return this.leadSource=r.leadSource,this.leadSource;const o=await this.fetchCurrentParsedLeadSource(i);if(this.leadSource=o,this.buildingId=null,this.orgSlug=t,this.buildingSlug=n,n&&!o){const e=this.getLeadSourceBodyIfValid(n);if(e)return this.leadSource=e.leadSource,this.leadSource}return n&&o&&this.updateLeadSourceLocalStorage(n,o,e),o}catch(e){console.error(e)}return null}},this.myPubnub=new Kr(this.buildingSlug,this.building,this.orgSlug,null,u.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})),"property-website"!==hi(this.orgSlug)?this.myPubnub.leadSource=null!==(o=null===(r=this.LeadSourceClient)||void 0===r?void 0:r.leadSource)&&void 0!==o?o:hi(this.orgSlug):this.myPubnub.leadSource=null!==(s=null===(a=this.LeadSourceClient)||void 0===a?void 0:a.leadSource)&&void 0!==s?s:null,u.initiatedChat&&await this.myPubnub.initializePubnub(l)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!xn(Cn(t)));return!!e&&!!n&&!cn()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",yn(function(e,t){Le(2,arguments);var n=tt(t);return nt(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,l,u,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!==(u=null===(l=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===l?void 0:l.getElementById("email-us-form"))&&void 0!==u?u: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
4254
4254
  id=${e}
4255
4255
  class=${fe({showTab:t,hideTab:!t})}
4256
4256
  >
@@ -295,7 +295,7 @@ export class MEChat extends LitElement {
295
295
  featureFlagInsertDNIWebsite,
296
296
  ] = await Promise.all([
297
297
  fetchBuildingABTestType(this.buildingSlug),
298
- fetchLeadSources(this.buildingSlug),
298
+ fetchLeadSources(this.orgSlug, this.buildingSlug),
299
299
  fetchFeatureFlagShowMarketingSourceDropdown(this.buildingSlug),
300
300
  fetchFeatureFlagUsePhoneNumberBySource(this.buildingSlug),
301
301
  fetchWebchatPreferences(buildingDetails.id),
@@ -3,6 +3,7 @@ export interface BuildingABType {
3
3
  abTestType: string;
4
4
  }
5
5
  export default async function fetchLeadSources(
6
+ orgSlug: string,
6
7
  buildingSlug: string
7
8
  ): Promise<string[]> {
8
9
  const host = "https://app.meetelise.com";
@@ -11,6 +12,20 @@ export default async function fetchLeadSources(
11
12
  `${host}/platformApi/webchat/${buildingSlug}/lead-sources`
12
13
  );
13
14
  if (leadSourcesResponse.data) {
15
+ if (orgSlug === "7e352741-1120-4ccf-9929-5dc99193a908") {
16
+ const onlyIncludeSources = [
17
+ "Zillow",
18
+ "Apartments.com",
19
+ "Google PPC",
20
+ "Google Maps",
21
+ "Apple Maps",
22
+ "Social Media",
23
+ "Print Marketing",
24
+ ];
25
+ return leadSourcesResponse.data.filter((source: string) =>
26
+ onlyIncludeSources.includes(source)
27
+ );
28
+ }
14
29
  return filterOutBuildingSpecificLeadSources(
15
30
  leadSourcesResponse.data,
16
31
  buildingSlug
@@ -28,6 +43,7 @@ const filterOutBuildingSpecificLeadSources = (
28
43
  ): string[] => {
29
44
  // Dinerstien asked to filter out some sources based on their buildings
30
45
  let removeLeadSources: string[] = [];
46
+
31
47
  switch (buildingSlug) {
32
48
  case "d41619ec-0f79-11ee-8439-93855926ad58": // Infinity Lofts in the Gulch
33
49
  removeLeadSources = [
@@ -69,7 +85,7 @@ const filterOutBuildingSpecificLeadSources = (
69
85
  ];
70
86
  break;
71
87
  default:
72
- removeLeadSources = [];
88
+ break;
73
89
  }
74
90
  leadSources.sort();
75
91
  return leadSources.filter((leadSource) => {