@meetelise/chat 1.51.6 → 1.51.8
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/README.md +25 -1
- package/declarations.d.ts +1 -0
- package/dist/src/MyPubnub.d.ts +6 -0
- package/package.json +1 -1
- package/public/dist/index.js +2 -2
- package/src/MyPubnub.ts +78 -26
- package/src/WebComponent/launcher/Launcher.ts +8 -0
package/README.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# MeetElise Webchat
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
### Installation
|
|
5
4
|
|
|
6
5
|
To install MeetElise webchat on your site, add the following code:
|
|
@@ -44,6 +43,7 @@ You can open any of the widgets via the functions given in the window.eliseAi na
|
|
|
44
43
|
`onOpenCallUsWindow`
|
|
45
44
|
`onOpenChat`
|
|
46
45
|
`onOpenEmailUsWindow`
|
|
46
|
+
`onOpenPriceCalculatorWindow`
|
|
47
47
|
`onOpenSST`
|
|
48
48
|
|
|
49
49
|
Example usage with an `<a>` tag would be:
|
|
@@ -60,6 +60,30 @@ While an example with a `<button>` tag would be
|
|
|
60
60
|
<button onclick="window.eliseAi.onOpenSST()">Open SST</button>
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
+
And to open the cost calculator:
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<button onclick="window.eliseAi.onOpenPriceCalculatorWindow()">
|
|
67
|
+
Calculate your cost
|
|
68
|
+
</button>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Each of these functions is only defined when the corresponding option is
|
|
72
|
+
enabled for the building in
|
|
73
|
+
https://app.meetelise.com/settings/widgets — e.g.
|
|
74
|
+
`onOpenPriceCalculatorWindow` only exists when the cost calculator is turned
|
|
75
|
+
on. If you're calling one from a page that may be served for buildings without
|
|
76
|
+
it, guard the call:
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<button onclick="window.eliseAi.onOpenPriceCalculatorWindow?.()">
|
|
80
|
+
Calculate your cost
|
|
81
|
+
</button>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Opening one of these windows closes any other widget window that's currently
|
|
85
|
+
open.
|
|
86
|
+
|
|
63
87
|
### Rentgrata Integration
|
|
64
88
|
|
|
65
89
|
Assuming you've followed [these instructions](https://widget.rentgrata.com/) to install Rengrata on your site, you can add the `overrideRentgrata` option to your snippet to
|
package/declarations.d.ts
CHANGED
package/dist/src/MyPubnub.d.ts
CHANGED
|
@@ -74,6 +74,7 @@ declare class MyPubnub {
|
|
|
74
74
|
private orgSlug;
|
|
75
75
|
private eliseResponseTimeout;
|
|
76
76
|
private isWaitingForStreamingMessages;
|
|
77
|
+
private firedScheduledTourConfirmationIds;
|
|
77
78
|
private widgetType;
|
|
78
79
|
pubnub: Pubnub | null;
|
|
79
80
|
leadUserId: string;
|
|
@@ -99,6 +100,11 @@ declare class MyPubnub {
|
|
|
99
100
|
expires_in_seconds: number;
|
|
100
101
|
} | null>;
|
|
101
102
|
private checkAndHandleDelayStreamingMessages;
|
|
103
|
+
private isStreamComplete;
|
|
104
|
+
private getStreamChunks;
|
|
105
|
+
private reconstructStreamText;
|
|
106
|
+
private fireScheduledTourEventOnce;
|
|
107
|
+
private checkAndFireTourConfirmationForStream;
|
|
102
108
|
checkAndHandleGTMForLeadEmail: (messageEvent: Pubnub.MessageEvent) => void;
|
|
103
109
|
addChatListener(listener: (response: {
|
|
104
110
|
messages: SimpleChatMessage[];
|
package/package.json
CHANGED
package/public/dist/index.js
CHANGED
|
@@ -5917,7 +5917,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
5917
5917
|
<div class="chevron-down">${Il("black")}</div>
|
|
5918
5918
|
</button>`:""}
|
|
5919
5919
|
</div>
|
|
5920
|
-
`}}connectedCallback(){super.connectedCallback(),this._cleanupMobileListener=Or(e=>{this._isMobile=e})}disconnectedCallback(){var e;null===(e=this._cleanupMobileListener)||void 0===e||e.call(this),super.disconnectedCallback()}render(){window.customElements.get("email-us-window")||window.customElements.define("email-us-window",Ja),window.customElements.get("call-us-window")||window.customElements.define("call-us-window",as),window.eliseAi.onOpenSST=e=>{this.isSSTWindowOpen=!0,this.isCallUsWindowOpen=!1,this.isEmailWindowOpen=!1,this.onExitChat(),e&&e()},(this.hasChatEnabledDesktop||this.hasChatEnabledMobile)&&(window.eliseAi.onOpenChat=e=>{this.handleChatTapped(),this.isSSTWindowOpen=!1,this.isCallUsWindowOpen=!1,this.isEmailWindowOpen=!1,e&&e()}),(this.hasCallUsEnabledDesktop||this.hasCallUsEnabledMobile)&&(window.eliseAi.onOpenCallUsWindow=e=>{this.isCallUsWindowOpen=!0,this.isSSTWindowOpen=!1,this.isEmailWindowOpen=!1,this.onExitChat(),e&&e()}),(this.hasEmailEnabledDesktop||this.hasEmailEnabledMobile)&&(window.eliseAi.onOpenEmailUsWindow=e=>{this.isEmailWindowOpen=!0,this.isSSTWindowOpen=!1,this.isCallUsWindowOpen=!1,this.onExitChat(),e&&e()}),(this.hasPricingCalculatorEnabledDesktop||this.hasPricingCalculatorEnabledMobile)&&(window.eliseAi.onOpenPriceCalculatorWindow=e=>{this.isCalculatorWindowOpen=!0,e&&e()});const e={top:this._isMobile||void 0===this.top||isNaN(this.top)?void 0:`${this.top}px`,bottom:this._isMobile||void 0===this.bottom||isNaN(this.bottom)?void 0:`${this.bottom}px`,left:this._isMobile||void 0===this.left||isNaN(this.left)?void 0:`${this.left}px`,right:this._isMobile||void 0===this.right||isNaN(this.right)?void 0:`${this.right}px`};return R`
|
|
5920
|
+
`}}connectedCallback(){super.connectedCallback(),this._cleanupMobileListener=Or(e=>{this._isMobile=e})}disconnectedCallback(){var e;null===(e=this._cleanupMobileListener)||void 0===e||e.call(this),super.disconnectedCallback()}render(){window.customElements.get("email-us-window")||window.customElements.define("email-us-window",Ja),window.customElements.get("call-us-window")||window.customElements.define("call-us-window",as),window.eliseAi.onOpenSST=e=>{this.isSSTWindowOpen=!0,this.isCallUsWindowOpen=!1,this.isEmailWindowOpen=!1,this.isCalculatorWindowOpen=!1,this.onExitChat(),e&&e()},(this.hasChatEnabledDesktop||this.hasChatEnabledMobile)&&(window.eliseAi.onOpenChat=e=>{this.handleChatTapped(),this.isSSTWindowOpen=!1,this.isCallUsWindowOpen=!1,this.isEmailWindowOpen=!1,this.isCalculatorWindowOpen=!1,e&&e()}),(this.hasCallUsEnabledDesktop||this.hasCallUsEnabledMobile)&&(window.eliseAi.onOpenCallUsWindow=e=>{this.isCallUsWindowOpen=!0,this.isSSTWindowOpen=!1,this.isEmailWindowOpen=!1,this.isCalculatorWindowOpen=!1,this.onExitChat(),e&&e()}),(this.hasEmailEnabledDesktop||this.hasEmailEnabledMobile)&&(window.eliseAi.onOpenEmailUsWindow=e=>{this.isEmailWindowOpen=!0,this.isSSTWindowOpen=!1,this.isCallUsWindowOpen=!1,this.isCalculatorWindowOpen=!1,this.onExitChat(),e&&e()}),(this.hasPricingCalculatorEnabledDesktop||this.hasPricingCalculatorEnabledMobile)&&(window.eliseAi.onOpenPriceCalculatorWindow=e=>{this.isCalculatorWindowOpen=!0,this.isSSTWindowOpen=!1,this.isCallUsWindowOpen=!1,this.isEmailWindowOpen=!1,this.onExitChat(),e&&e()});const e={top:this._isMobile||void 0===this.top||isNaN(this.top)?void 0:`${this.top}px`,bottom:this._isMobile||void 0===this.bottom||isNaN(this.bottom)?void 0:`${this.bottom}px`,left:this._isMobile||void 0===this.left||isNaN(this.left)?void 0:`${this.left}px`,right:this._isMobile||void 0===this.right||isNaN(this.right)?void 0:`${this.right}px`};return R`
|
|
5921
5921
|
<div
|
|
5922
5922
|
class=${ho()({"launcher__mobile-launcher-wrapper":this._isMobile||this.isMinimized,"launcher__mini-launcher-wrapper":!this._isMobile&&!this.isMinimized,"launcher__mini-elevated":"livcor"===this.orgSlug.toLowerCase()&&(this._isMobile||this.isMinimized)})}
|
|
5923
5923
|
style=${Vn({...this.launcherStyles,...this.mobileStyles,top:this._isMobile||void 0===this.top||isNaN(this.top)?void 0!==this.mobileStyles.top?`${this.mobileStyles.top}px`:void 0:this.top-700+"px",bottom:this._isMobile||void 0===this.bottom||isNaN(this.bottom)?void 0!==this.mobileStyles.bottom?`${this.mobileStyles.bottom}px`:"72px":`${this.bottom}px`,left:this._isMobile||void 0===this.left||isNaN(this.left)?void 0!==this.mobileStyles.left?`${this.mobileStyles.left}px`:void 0:`${this.left}px`,right:this._isMobile||void 0===this.right||isNaN(this.right)?void 0!==this.mobileStyles.right?`${this.mobileStyles.right}px`:"18px":`${this.right}px`})}
|
|
@@ -6032,7 +6032,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
6032
6032
|
${Qa}
|
|
6033
6033
|
${Wa}
|
|
6034
6034
|
${Va}
|
|
6035
|
-
`,Fl([ue({attribute:!0})],Hl.prototype,"isMinimized",void 0),Fl([ue()],Hl.prototype,"mobileStyles",void 0),Fl([ue({type:Boolean})],Hl.prototype,"isFirstMount",void 0),Fl([ue({attribute:!1})],Hl.prototype,"autoOpenChatWidget",void 0),Fl([ue()],Hl.prototype,"phoneNumber",void 0),Fl([ue({attribute:!0})],Hl.prototype,"buildingName",void 0),Fl([ue({attribute:!0})],Hl.prototype,"chatId",void 0),Fl([ue({attribute:!0})],Hl.prototype,"orgLegalName",void 0),Fl([ue({attribute:!1})],Hl.prototype,"country",void 0),Fl([ue({attribute:!0})],Hl.prototype,"chatCallUsHeader",void 0),Fl([ue({attribute:!1})],Hl.prototype,"buildingId",void 0),Fl([ue({type:Number})],Hl.prototype,"orgId",void 0),Fl([ue({attribute:!1})],Hl.prototype,"leadSourceParams",void 0),Fl([ue({attribute:!0})],Hl.prototype,"buildingSlug",void 0),Fl([ue({attribute:!0})],Hl.prototype,"orgSlug",void 0),Fl([ue({attribute:!0})],Hl.prototype,"sgtUrl",void 0),Fl([ue({attribute:!0})],Hl.prototype,"selfGuidedTourEnabled",void 0),Fl([ue({attribute:!0})],Hl.prototype,"selfGuidedToursTypeOffered",void 0),Fl([ue({attribute:!0})],Hl.prototype,"designConcept",void 0),Fl([ue({attribute:!0})],Hl.prototype,"featureFlagShowDropdown",void 0),Fl([ue({attribute:!1})],Hl.prototype,"leadSources",void 0),Fl([ue({attribute:!0})],Hl.prototype,"currentLeadSource",void 0),Fl([ue({attribute:!0})],Hl.prototype,"escortedToursLink",void 0),Fl([ue({attribute:!0})],Hl.prototype,"escortedToursTypeOffered",void 0),Fl([ue({attribute:!0})],Hl.prototype,"virtualToursLink",void 0),Fl([ue({attribute:!0})],Hl.prototype,"virtualToursTypeOffered",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasChatEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasChatEnabledMobile",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasEmailEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasEmailEnabledMobile",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasApplyNowEnabledDesktop",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasApplyNowEnabledMobile",void 0),Fl([ue({attribute:!0})],Hl.prototype,"applicationLink",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasCallUsEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasCallUsEnabledMobile",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasTextUsEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasTextUsEnabledMobile",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasSSTEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasSSTEnabledMobile",void 0),Fl([ue({attribute:!1})],Hl.prototype,"tourTypeOptions",void 0),Fl([ue({attribute:!1})],Hl.prototype,"layoutOptions",void 0),Fl([ue({attribute:!0})],Hl.prototype,"bedroomPreferenceRequired",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasDynamicSchedulingEnabled",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasPricingCalculatorEnabledDesktop",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasPricingCalculatorEnabledMobile",void 0),Fl([ue({attribute:!1})],Hl.prototype,"hasHideMobileFeatures",void 0),Fl([ue({type:Number})],Hl.prototype,"right",void 0),Fl([ue({type:Number})],Hl.prototype,"bottom",void 0),Fl([ue({type:Number})],Hl.prototype,"top",void 0),Fl([ue({type:Number})],Hl.prototype,"left",void 0),Fl([ue({attribute:!0})],Hl.prototype,"showTourNextToChat",void 0),Fl([ue({attribute:!1})],Hl.prototype,"onChatTapped",void 0),Fl([ue({attribute:!0})],Hl.prototype,"onClickMinimize",void 0),Fl([ue({attribute:!0})],Hl.prototype,"onSstClose",void 0),Fl([ue({attribute:!0})],Hl.prototype,"overrideRentgrata",void 0),Fl([ue({attribute:!1})],Hl.prototype,"launcherStyles",void 0),Fl([ue({attribute:!0})],Hl.prototype,"primaryColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"backgroundColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"leadSourceClient",void 0),Fl([de()],Hl.prototype,"leadSourceMultitouchClient",void 0),Fl([de()],Hl.prototype,"_isMobile",void 0),Fl([de()],Hl.prototype,"isEmailWindowOpen",void 0),Fl([de()],Hl.prototype,"isCallUsWindowOpen",void 0),Fl([de()],Hl.prototype,"isSSTWindowOpen",void 0),Fl([de()],Hl.prototype,"isTextUsWindowOpen",void 0),Fl([de()],Hl.prototype,"isCalculatorWindowOpen",void 0),Fl([de()],Hl.prototype,"isMobileFeaturesExpanded",void 0),Hl=Fl([se("meetelise-launcher")],Hl);const Gl=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",Hl)},zl=["app.meetelise.com","staging.eliseai.com","localhost"],Ql={calculator:{desktop:"calcDesktop",mobile:"calcMobile"},email:{desktop:"emailDesktop",mobile:"emailMobile"},call:{desktop:"callDesktop",mobile:"callMobile"},text:{desktop:"textDesktop",mobile:"textMobile"},sst:{desktop:"sstDesktop",mobile:"sstMobile"}},Wl=e=>{const t=window.location.hostname;if(!zl.includes(t))return e;const n=(e=>{if(!e)return{};try{return e.split(",").reduce((e,t)=>{const[n,i]=t.split(":");return n&&i&&n in Ql&&(e[n]="true"===i.toLowerCase()),e},{})}catch(e){return{}}})(new URLSearchParams(window.location.search).get("widgets"));if(0===Object.keys(n).length)return e;const i={...e};return Object.entries(n).forEach(([e,t])=>{const n=Ql[e];n&&(i[n.desktop]=t,i[n.mobile]=t)}),i};var Vl=n(5072),ql=n.n(Vl),Yl=n(7825),Kl=n.n(Yl),Xl=n(7659),Zl=n.n(Xl),Jl=n(5056),eu=n.n(Jl),tu=n(540),nu=n.n(tu),iu=n(1113),ru=n.n(iu),ou=n(5541),au={};au.styleTagTransform=ru(),au.setAttributes=eu(),au.insert=Zl().bind(null,"head"),au.domAPI=Kl(),au.insertStyleElement=nu();ql()(ou.A,au);ou.A&&ou.A.locals&&ou.A.locals;async function su(e,t){try{const n=await r().get(`https://app.meetelise.com/platformApi/webchat/${t}/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 lu(n.data,t)}return[]}catch(e){return[]}}const lu=(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)})};async function uu(e){var t,n;if(!e)return!1;try{return null!==(n=null===(t=(await r().get(`https://app.meetelise.com/platformApi/webchat/${e}/aip`)).data)||void 0===t?void 0:t.is_aip)&&void 0!==n&&n}catch(e){return!1}}var du,cu=n(8805),hu=n.n(cu),pu=new Uint8Array(16);function fu(){if(!du&&!(du="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 du(pu)}const gu=/^(?:[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;const mu=function(e){return"string"==typeof e&&gu.test(e)};for(var yu=[],bu=0;bu<256;++bu)yu.push((bu+256).toString(16).substr(1));const vu=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(yu[e[t+0]]+yu[e[t+1]]+yu[e[t+2]]+yu[e[t+3]]+"-"+yu[e[t+4]]+yu[e[t+5]]+"-"+yu[e[t+6]]+yu[e[t+7]]+"-"+yu[e[t+8]]+yu[e[t+9]]+"-"+yu[e[t+10]]+yu[e[t+11]]+yu[e[t+12]]+yu[e[t+13]]+yu[e[t+14]]+yu[e[t+15]]).toLowerCase();if(!mu(n))throw TypeError("Stringified UUID is invalid");return n};const wu=function(e,t,n){var i=(e=e||{}).random||(e.rng||fu)();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 vu(i)},Cu=e=>localStorage.removeItem("com.elise.webchat.slug="+e),xu=(e,t,n)=>{const i=Rr(new Date),r=n||`lead_${wu()}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:i,initiatedChat:t})),{leadId:r,timestamp:Wr(i),buildingSlug:e,initiatedChat:t}},$u=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(Su(e,i))return i}catch(e){}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},Su=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if(xr(t.timestamp,e))return!1}}catch(e){}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp)&&!Pr(t.timestamp,24)};var Au;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(Au||(Au={}));const Eu=e=>e.type===ku.text,Tu=e=>e.type===ku.media;var ku;!function(e){e.text="text",e.media="media"}(ku||(ku={}));const _u=class{constructor(e,t,n,i=null,r,o,a=null,s=Pc.Default){this.apiHost="https://app.meetelise.com",this.leadSourceClient=null,this.leadSourceMultitouchClient=null,this.buildingWebchatView=null,this.eliseResponseTimeout=null,this.isWaitingForStreamingMessages=!1,this.widgetType=Pc.Default,this.pubnub=null,this.leadUserId="",this.channel="",this.leadSource=null,this.sessionToken=null,this.isCurrentlyStreamingMessage=!1,this.chatListener=null,this.rawPubnubMessages=[],this.simpleChatMessages=[],this.listenerParams={message:e=>{var t,n;const i={channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken};this.rawPubnubMessages=[...this.rawPubnubMessages,i],this.markEveryPreviousNoReplyMessageDone(this.rawPubnubMessages),this.rawPubnubMessages=this.rawPubnubMessages.filter(e=>e.message.messageType!==Au.noReply),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),this.checkAndHandleDelayStreamingMessages();const r="eliseai"!==e.publisher&&"elise_health_ai"!==e.publisher;if(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===ku.text&&e.message.includes("confirmed for your"))&&xo("scheduledTourEvent",{tourDetails:e.message,buildingId:null===(n=this.buildingWebchatView)||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.streamingMessageTimeout=null,this.checkAndHandleDelayStreamingMessages=({delayToFetchHistoryInMs:e=1e4}={})=>{this.streamingMessageTimeout&&(clearTimeout(this.streamingMessageTimeout),this.streamingMessageTimeout=null);const t=this.simpleChatMessages.some(e=>{if(!Eu(e))return!1;const t=e.chunks.find(e=>e.isDone);return!t||e.chunks.length===t.order});t&&(this.streamingMessageTimeout=setTimeout(()=>{Fo({logTitle:"PUBNUB_WARN_DELAYED_STREAMING_MESSAGES",logData:{channel:this.channel},logType:jo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),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!1}})(e.message.text))return;xo("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,n;for(let i=e.length-1;i>=0;i--){const r=null===(t=e[i])||void 0===t?void 0:t.message,o=i>0&&(null===(n=e[i-1])||void 0===n?void 0:n.message);(null==r?void 0:r.messageType)===Au.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&&Fo({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}},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=xu(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken(async()=>{var t,n,i,r,o,a,s,l,u;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout(()=>{this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:jo.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===Pc.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===(n=this.buildingWebchatView)||void 0===n?void 0:n.id,buildingSlug:this.buildingSlug,userId:null===(i=this.buildingWebchatView)||void 0===i?void 0:i.userId,leadSource:this.leadSource,widgetType:this.widgetType,isDevState:this.shouldCreateAsDevState(),lead_sources_with_timestamps:(null!==(o=null===(r=this.leadSourceMultitouchClient)||void 0===r?void 0:r.getSafeLeadSourceTouchpointsWithDefault({includedUserSelectedLeadSource:null}))&&void 0!==o?o:[]).map(e=>Er({...e}))}}),null===(a=this.leadSourceClient)||void 0===a||a.resetLeadSource(),null===(s=this.leadSourceMultitouchClient)||void 0===s||s.resetLeadSourceTouchpoints()),this.isFirstChatMessageSent||(xo("firstChatMessageSent",{message:e,buildingId:null===(l=this.buildingWebchatView)||void 0===l?void 0:l.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.isFirstChatMessageSent=!0),xo("chatMessageSent",{message:e,buildingId:null===(u=this.buildingWebchatView)||void 0===u?void 0:u.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 n=`${e.message.stream_id}-${e.message.order}-${e.message.messageType}`;return t.has(n)?(Fo({logTitle:"PUBNUB_WARN_DUPLICATE_MESSAGE",logData:{message:e,channel:this.channel},logType:jo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),!1):(t.add(n),!0)})},this.translatePubnubMessagesIntoSimpleChatMessages=e=>{const t=[],n={};return this.removeDuplicatedRawPubnubMessages(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:ku.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:ku.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:ku.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.buildingWebchatView=t,this.orgSlug=n,this.leadSource=i,this.leadUserId=r,this.channel=`webchat_${r}`,this.leadSourceClient=a,this.leadSourceMultitouchClient=o,this.widgetType=s}async initSession(e,t,n){try{const i={building_slug:e,org_slug:t};n&&(i.lead_id=n);const o=await r().post(`${this.apiHost}/platformApi/webchat/init`,i);return this.sessionToken=o.data.session_token,this.leadUserId=o.data.lead_id,this.channel=o.data.channel,o.data}catch(e){return this.buildingWebchatView&&Fo({logTitle:"WEBCHAT_INIT_SESSION_ERROR",logData:{error:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e}),null}}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(hu())({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,t){try{if(this.sessionToken){const e="healthcare"===this.widgetType?"?industry=health_care":"";return(await r().get(`${this.apiHost}/platformApi/webchat/pn/v2/request-token${e}`,{headers:{"X-Session-Token":this.sessionToken}})).data}return(await r().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${t}&${"healthcare"===this.widgetType?"industry=health_care":""}`)).data}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}return null}async fetchChannelExists(e){try{return(await r().get(`${this.apiHost}/platformApi/webchat/check-channel-exists?channel_name=${e}`)).data}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}return!1}async withAuthToken(e){try{await e()}catch(t){if(t instanceof i.AxiosError&&t&&t.response&&403===t.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const t=await this.fetchToken(this.leadUserId,this.channel);if(!t)return;this.pubnub.setAuthKey(t.auth.result.token),await e()}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}}}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})}),this.markEveryPreviousNoReplyMessageDone(t),n=n.concat(t.filter(e=>e.message.messageType!==Au.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.buildingWebchatView&&Fo({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:jo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}}shouldCreateAsDevState(){return location.href.startsWith("https://app.meetelise.com/settings/widgets")||location.href.includes("demo/utilities")}},Ou=new Set(["8009855990","8338526262","8002221222","8006624357","8002738255","8007997233","8007874889","8006564673","8004224453","8883737888","8006213362","8009506264","8558272736","8008435678","8007862929","8008523836","8007849433","8007729100","8006699777","8006858470","8004322209","8003473735","8008778339","8009552232","8002255342","8009272891","8003049320","8007937724","8002382333","8003353863","8776858878","8003329227","8776554371","8772944357","8772944356","6092925760","6092926735","8007928339","8008329173","8882853036","6092921210","8007929773","8003561561","8003826717","8005727233","8009291040","8888958179","8006879512","8004262537","8773475463","8774149251","8005103102","8889372835","8007010710","8007010720","8774288844","8007929745","8003283838","6092927060","6092928319","8008527899","8662401347","8009923678","8776522873","8776527624","8003313937","8008435437","8776536783","8778392339","8003676274","8006896411"]),Pu=e=>{const t=e.replace(/\D/g,"").replace(/^1(\d{10})$/,"$1");return Ou.has(t)},Iu=(e,t,n)=>{try{const i=e.replace(/\D/g,"").replace(/^1(\d{10})$/,"$1"),r=`tel:${i}`,o=`sms:${i}`,a=`whatsapp://send?phone=${i}`,s=`facetime:${i}`,l=`facetime-audio:${i}`,u=/(?:\+1[\s.-]?)?(?:\(\d{3}\)[\s.-]?|\d{3}[\s.-])\d{3}[\s.-]?\d{4}/g,d=/(tel|sms):(?:\+1\s)?(?:(?:\(\d{3}\)\s|\d{3}-)\d{3}-\d{4}|\d{10,11})/g,c=/whatsapp:\/\/send\?phone=\d+/g,h=/(facetime|facetime-audio):\d+/g,p=/emergency|emergencia/i,f=300,g=e=>!(!e||e.length>f)&&p.test(e),m=e=>{var t,n,i,r;if(g(e.textContent))return!0;if(g(null===(t=e.previousElementSibling)||void 0===t?void 0:t.textContent)||g(null===(n=e.nextElementSibling)||void 0===n?void 0:n.textContent))return!0;const o=e.parentElement;return!(!o||!g(null===(i=o.previousElementSibling)||void 0===i?void 0:i.textContent)&&!g(null===(r=o.nextElementSibling)||void 0===r?void 0:r.textContent))},y=document.body.getElementsByTagName("*");let b=!1;const v=i.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3");let w=!1,C=!1,x=0;for(let e=0;e<y.length;e++)if(y[e].nodeType===Node.ELEMENT_NODE&&!m(y[e])){if(1===y[e].childNodes.length&&y[e].childNodes[0].nodeType==Node.TEXT_NODE){const t=y[e].textContent;if(!t)continue;const n=t.replace(u,e=>{if(Pu(e))return e;return e.startsWith("+1 ")?`+1 ${v}`:v});t!==n&&(x++,y[e].textContent=n),b=!0,w||(w=!0)}if(y[e].hasAttribute("href")){const t=y[e].getAttribute("href");if(!t)continue;let n="",i=d;if(t.startsWith("sms:")?n=o:t.startsWith("whatsapp:")?(n=a,i=c):t.startsWith("facetime:")?(n=s,i=h):t.startsWith("facetime-audio:")?(n=l,i=h):n=r,Pu(t))continue;const u=t.replace(i,n);if(y[e].setAttribute("href",u),(t.startsWith("tel:")||t.startsWith("sms:"))&&u===t&&u!==n){t.replace(/\D/g,"").length>=7&&y[e].setAttribute("href",t.startsWith("tel:")?r:o)}C||(C=!0)}}return w&&Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:v,website:window.location.href},logType:jo.info,buildingSlug:n,orgSlug:t}),C&&Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:v,website:window.location.href},logType:jo.info,buildingSlug:n,orgSlug:t}),b||Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:jo.warn,buildingSlug:n,orgSlug:t}),x}catch(e){return Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"insertion-error",error:e instanceof Error?e.message:String(e),website:window.location.href},logType:jo.error,buildingSlug:n,orgSlug:t,error:e}),0}};var Nu=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 Mu=class extends oe{constructor(){super(...arguments),this.onClick=()=>{},this.primaryColor=qn,this.toExpand=!1}render(){return R`
|
|
6035
|
+
`,Fl([ue({attribute:!0})],Hl.prototype,"isMinimized",void 0),Fl([ue()],Hl.prototype,"mobileStyles",void 0),Fl([ue({type:Boolean})],Hl.prototype,"isFirstMount",void 0),Fl([ue({attribute:!1})],Hl.prototype,"autoOpenChatWidget",void 0),Fl([ue()],Hl.prototype,"phoneNumber",void 0),Fl([ue({attribute:!0})],Hl.prototype,"buildingName",void 0),Fl([ue({attribute:!0})],Hl.prototype,"chatId",void 0),Fl([ue({attribute:!0})],Hl.prototype,"orgLegalName",void 0),Fl([ue({attribute:!1})],Hl.prototype,"country",void 0),Fl([ue({attribute:!0})],Hl.prototype,"chatCallUsHeader",void 0),Fl([ue({attribute:!1})],Hl.prototype,"buildingId",void 0),Fl([ue({type:Number})],Hl.prototype,"orgId",void 0),Fl([ue({attribute:!1})],Hl.prototype,"leadSourceParams",void 0),Fl([ue({attribute:!0})],Hl.prototype,"buildingSlug",void 0),Fl([ue({attribute:!0})],Hl.prototype,"orgSlug",void 0),Fl([ue({attribute:!0})],Hl.prototype,"sgtUrl",void 0),Fl([ue({attribute:!0})],Hl.prototype,"selfGuidedTourEnabled",void 0),Fl([ue({attribute:!0})],Hl.prototype,"selfGuidedToursTypeOffered",void 0),Fl([ue({attribute:!0})],Hl.prototype,"designConcept",void 0),Fl([ue({attribute:!0})],Hl.prototype,"featureFlagShowDropdown",void 0),Fl([ue({attribute:!1})],Hl.prototype,"leadSources",void 0),Fl([ue({attribute:!0})],Hl.prototype,"currentLeadSource",void 0),Fl([ue({attribute:!0})],Hl.prototype,"escortedToursLink",void 0),Fl([ue({attribute:!0})],Hl.prototype,"escortedToursTypeOffered",void 0),Fl([ue({attribute:!0})],Hl.prototype,"virtualToursLink",void 0),Fl([ue({attribute:!0})],Hl.prototype,"virtualToursTypeOffered",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasChatEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasChatEnabledMobile",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasEmailEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasEmailEnabledMobile",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasApplyNowEnabledDesktop",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasApplyNowEnabledMobile",void 0),Fl([ue({attribute:!0})],Hl.prototype,"applicationLink",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasCallUsEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasCallUsEnabledMobile",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasTextUsEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasTextUsEnabledMobile",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasSSTEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasSSTEnabledMobile",void 0),Fl([ue({attribute:!1})],Hl.prototype,"tourTypeOptions",void 0),Fl([ue({attribute:!1})],Hl.prototype,"layoutOptions",void 0),Fl([ue({attribute:!0})],Hl.prototype,"bedroomPreferenceRequired",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasDynamicSchedulingEnabled",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasPricingCalculatorEnabledDesktop",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasPricingCalculatorEnabledMobile",void 0),Fl([ue({attribute:!1})],Hl.prototype,"hasHideMobileFeatures",void 0),Fl([ue({type:Number})],Hl.prototype,"right",void 0),Fl([ue({type:Number})],Hl.prototype,"bottom",void 0),Fl([ue({type:Number})],Hl.prototype,"top",void 0),Fl([ue({type:Number})],Hl.prototype,"left",void 0),Fl([ue({attribute:!0})],Hl.prototype,"showTourNextToChat",void 0),Fl([ue({attribute:!1})],Hl.prototype,"onChatTapped",void 0),Fl([ue({attribute:!0})],Hl.prototype,"onClickMinimize",void 0),Fl([ue({attribute:!0})],Hl.prototype,"onSstClose",void 0),Fl([ue({attribute:!0})],Hl.prototype,"overrideRentgrata",void 0),Fl([ue({attribute:!1})],Hl.prototype,"launcherStyles",void 0),Fl([ue({attribute:!0})],Hl.prototype,"primaryColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"backgroundColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"leadSourceClient",void 0),Fl([de()],Hl.prototype,"leadSourceMultitouchClient",void 0),Fl([de()],Hl.prototype,"_isMobile",void 0),Fl([de()],Hl.prototype,"isEmailWindowOpen",void 0),Fl([de()],Hl.prototype,"isCallUsWindowOpen",void 0),Fl([de()],Hl.prototype,"isSSTWindowOpen",void 0),Fl([de()],Hl.prototype,"isTextUsWindowOpen",void 0),Fl([de()],Hl.prototype,"isCalculatorWindowOpen",void 0),Fl([de()],Hl.prototype,"isMobileFeaturesExpanded",void 0),Hl=Fl([se("meetelise-launcher")],Hl);const Gl=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",Hl)},zl=["app.meetelise.com","staging.eliseai.com","localhost"],Ql={calculator:{desktop:"calcDesktop",mobile:"calcMobile"},email:{desktop:"emailDesktop",mobile:"emailMobile"},call:{desktop:"callDesktop",mobile:"callMobile"},text:{desktop:"textDesktop",mobile:"textMobile"},sst:{desktop:"sstDesktop",mobile:"sstMobile"}},Wl=e=>{const t=window.location.hostname;if(!zl.includes(t))return e;const n=(e=>{if(!e)return{};try{return e.split(",").reduce((e,t)=>{const[n,i]=t.split(":");return n&&i&&n in Ql&&(e[n]="true"===i.toLowerCase()),e},{})}catch(e){return{}}})(new URLSearchParams(window.location.search).get("widgets"));if(0===Object.keys(n).length)return e;const i={...e};return Object.entries(n).forEach(([e,t])=>{const n=Ql[e];n&&(i[n.desktop]=t,i[n.mobile]=t)}),i};var Vl=n(5072),ql=n.n(Vl),Yl=n(7825),Kl=n.n(Yl),Xl=n(7659),Zl=n.n(Xl),Jl=n(5056),eu=n.n(Jl),tu=n(540),nu=n.n(tu),iu=n(1113),ru=n.n(iu),ou=n(5541),au={};au.styleTagTransform=ru(),au.setAttributes=eu(),au.insert=Zl().bind(null,"head"),au.domAPI=Kl(),au.insertStyleElement=nu();ql()(ou.A,au);ou.A&&ou.A.locals&&ou.A.locals;async function su(e,t){try{const n=await r().get(`https://app.meetelise.com/platformApi/webchat/${t}/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 lu(n.data,t)}return[]}catch(e){return[]}}const lu=(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)})};async function uu(e){var t,n;if(!e)return!1;try{return null!==(n=null===(t=(await r().get(`https://app.meetelise.com/platformApi/webchat/${e}/aip`)).data)||void 0===t?void 0:t.is_aip)&&void 0!==n&&n}catch(e){return!1}}var du,cu=n(8805),hu=n.n(cu),pu=new Uint8Array(16);function fu(){if(!du&&!(du="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 du(pu)}const gu=/^(?:[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;const mu=function(e){return"string"==typeof e&&gu.test(e)};for(var yu=[],bu=0;bu<256;++bu)yu.push((bu+256).toString(16).substr(1));const vu=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(yu[e[t+0]]+yu[e[t+1]]+yu[e[t+2]]+yu[e[t+3]]+"-"+yu[e[t+4]]+yu[e[t+5]]+"-"+yu[e[t+6]]+yu[e[t+7]]+"-"+yu[e[t+8]]+yu[e[t+9]]+"-"+yu[e[t+10]]+yu[e[t+11]]+yu[e[t+12]]+yu[e[t+13]]+yu[e[t+14]]+yu[e[t+15]]).toLowerCase();if(!mu(n))throw TypeError("Stringified UUID is invalid");return n};const wu=function(e,t,n){var i=(e=e||{}).random||(e.rng||fu)();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 vu(i)},Cu=e=>localStorage.removeItem("com.elise.webchat.slug="+e),xu=(e,t,n)=>{const i=Rr(new Date),r=n||`lead_${wu()}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:i,initiatedChat:t})),{leadId:r,timestamp:Wr(i),buildingSlug:e,initiatedChat:t}},$u=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(Su(e,i))return i}catch(e){}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},Su=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if(xr(t.timestamp,e))return!1}}catch(e){}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp)&&!Pr(t.timestamp,24)};var Au;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(Au||(Au={}));const Eu=e=>e.type===ku.text,Tu=e=>e.type===ku.media;var ku;!function(e){e.text="text",e.media="media"}(ku||(ku={}));const _u=class{constructor(e,t,n,i=null,r,o,a=null,s=Pc.Default){this.apiHost="https://app.meetelise.com",this.leadSourceClient=null,this.leadSourceMultitouchClient=null,this.buildingWebchatView=null,this.eliseResponseTimeout=null,this.isWaitingForStreamingMessages=!1,this.firedScheduledTourConfirmationIds=new Set,this.widgetType=Pc.Default,this.pubnub=null,this.leadUserId="",this.channel="",this.leadSource=null,this.sessionToken=null,this.isCurrentlyStreamingMessage=!1,this.chatListener=null,this.rawPubnubMessages=[],this.simpleChatMessages=[],this.listenerParams={message:e=>{var t;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!==Au.noReply),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),this.checkAndHandleDelayStreamingMessages();const i="eliseai"!==e.publisher&&"elise_health_ai"!==e.publisher;if(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){const t=e.message.stream_id,n=null!=t?t:String(+e.timetoken);(t?this.reconstructStreamText(t):e.message.text).includes("confirmed for your")&&this.fireScheduledTourEventOnce(n,e.message)}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=new Map;this.rawPubnubMessages.forEach(e=>{var n;const i=e.message.stream_id;i&&t.set(i,[...null!==(n=t.get(i))&&void 0!==n?n:[],e])});const n=[...t.entries()].filter(([,e])=>!this.isStreamComplete(e)).map(([e])=>e);n.length>0&&(this.streamingMessageTimeout=setTimeout(()=>{Fo({logTitle:"PUBNUB_WARN_DELAYED_STREAMING_MESSAGES",logData:{channel:this.channel},logType:jo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),this.getChannelHistory().then(()=>n.forEach(e=>this.checkAndFireTourConfirmationForStream(e)))},e))},this.isStreamComplete=e=>{var t;const n=e.find(e=>e.message.is_done);if(!n)return!1;const i=new Set(e.map(e=>{var t;return null!==(t=e.message.order)&&void 0!==t?t:0}));for(let e=0;e<=(null!==(t=n.message.order)&&void 0!==t?t:0);e++)if(!i.has(e))return!1;return!0},this.getStreamChunks=e=>this.removeDuplicatedRawPubnubMessages(this.rawPubnubMessages).filter(t=>t.message.stream_id===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)}),this.reconstructStreamText=e=>this.getStreamChunks(e).map(e=>e.message.text).join(""),this.fireScheduledTourEventOnce=(e,t)=>{var n;this.firedScheduledTourConfirmationIds.has(e)||(this.firedScheduledTourConfirmationIds.add(e),xo("scheduledTourEvent",{tourDetails:t,buildingId:null===(n=this.buildingWebchatView)||void 0===n?void 0:n.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}))},this.checkAndFireTourConfirmationForStream=e=>{var t;if(this.reconstructStreamText(e).includes("confirmed for your")){const n=this.getStreamChunks(e);this.fireScheduledTourEventOnce(e,null===(t=n[n.length-1])||void 0===t?void 0:t.message)}},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!1}})(e.message.text))return;xo("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,n;for(let i=e.length-1;i>=0;i--){const r=null===(t=e[i])||void 0===t?void 0:t.message,o=i>0&&(null===(n=e[i-1])||void 0===n?void 0:n.message);(null==r?void 0:r.messageType)===Au.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&&Fo({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}},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=xu(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken(async()=>{var t,n,i,r,o,a,s,l,u;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout(()=>{this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:jo.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===Pc.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===(n=this.buildingWebchatView)||void 0===n?void 0:n.id,buildingSlug:this.buildingSlug,userId:null===(i=this.buildingWebchatView)||void 0===i?void 0:i.userId,leadSource:this.leadSource,widgetType:this.widgetType,isDevState:this.shouldCreateAsDevState(),lead_sources_with_timestamps:(null!==(o=null===(r=this.leadSourceMultitouchClient)||void 0===r?void 0:r.getSafeLeadSourceTouchpointsWithDefault({includedUserSelectedLeadSource:null}))&&void 0!==o?o:[]).map(e=>Er({...e}))}}),null===(a=this.leadSourceClient)||void 0===a||a.resetLeadSource(),null===(s=this.leadSourceMultitouchClient)||void 0===s||s.resetLeadSourceTouchpoints()),this.isFirstChatMessageSent||(xo("firstChatMessageSent",{message:e,buildingId:null===(l=this.buildingWebchatView)||void 0===l?void 0:l.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.isFirstChatMessageSent=!0),xo("chatMessageSent",{message:e,buildingId:null===(u=this.buildingWebchatView)||void 0===u?void 0:u.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 n=`${e.message.stream_id}-${e.message.order}-${e.message.messageType}`;return t.has(n)?(Fo({logTitle:"PUBNUB_WARN_DUPLICATE_MESSAGE",logData:{message:e,channel:this.channel},logType:jo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),!1):(t.add(n),!0)})},this.translatePubnubMessagesIntoSimpleChatMessages=e=>{const t=[],n={};return this.removeDuplicatedRawPubnubMessages(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:ku.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:ku.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:ku.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.buildingWebchatView=t,this.orgSlug=n,this.leadSource=i,this.leadUserId=r,this.channel=`webchat_${r}`,this.leadSourceClient=a,this.leadSourceMultitouchClient=o,this.widgetType=s}async initSession(e,t,n){try{const i={building_slug:e,org_slug:t};n&&(i.lead_id=n);const o=await r().post(`${this.apiHost}/platformApi/webchat/init`,i);return this.sessionToken=o.data.session_token,this.leadUserId=o.data.lead_id,this.channel=o.data.channel,o.data}catch(e){return this.buildingWebchatView&&Fo({logTitle:"WEBCHAT_INIT_SESSION_ERROR",logData:{error:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e}),null}}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(hu())({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,t){try{if(this.sessionToken){const e="healthcare"===this.widgetType?"?industry=health_care":"";return(await r().get(`${this.apiHost}/platformApi/webchat/pn/v2/request-token${e}`,{headers:{"X-Session-Token":this.sessionToken}})).data}return(await r().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${t}&${"healthcare"===this.widgetType?"industry=health_care":""}`)).data}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}return null}async fetchChannelExists(e){try{return(await r().get(`${this.apiHost}/platformApi/webchat/check-channel-exists?channel_name=${e}`)).data}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}return!1}async withAuthToken(e){try{await e()}catch(t){if(t instanceof i.AxiosError&&t&&t.response&&403===t.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const t=await this.fetchToken(this.leadUserId,this.channel);if(!t)return;this.pubnub.setAuthKey(t.auth.result.token),await e()}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}}}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})}),this.markEveryPreviousNoReplyMessageDone(t),n=n.concat(t.filter(e=>e.message.messageType!==Au.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.buildingWebchatView&&Fo({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:jo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}}shouldCreateAsDevState(){return location.href.startsWith("https://app.meetelise.com/settings/widgets")||location.href.includes("demo/utilities")}},Ou=new Set(["8009855990","8338526262","8002221222","8006624357","8002738255","8007997233","8007874889","8006564673","8004224453","8883737888","8006213362","8009506264","8558272736","8008435678","8007862929","8008523836","8007849433","8007729100","8006699777","8006858470","8004322209","8003473735","8008778339","8009552232","8002255342","8009272891","8003049320","8007937724","8002382333","8003353863","8776858878","8003329227","8776554371","8772944357","8772944356","6092925760","6092926735","8007928339","8008329173","8882853036","6092921210","8007929773","8003561561","8003826717","8005727233","8009291040","8888958179","8006879512","8004262537","8773475463","8774149251","8005103102","8889372835","8007010710","8007010720","8774288844","8007929745","8003283838","6092927060","6092928319","8008527899","8662401347","8009923678","8776522873","8776527624","8003313937","8008435437","8776536783","8778392339","8003676274","8006896411"]),Pu=e=>{const t=e.replace(/\D/g,"").replace(/^1(\d{10})$/,"$1");return Ou.has(t)},Iu=(e,t,n)=>{try{const i=e.replace(/\D/g,"").replace(/^1(\d{10})$/,"$1"),r=`tel:${i}`,o=`sms:${i}`,a=`whatsapp://send?phone=${i}`,s=`facetime:${i}`,l=`facetime-audio:${i}`,u=/(?:\+1[\s.-]?)?(?:\(\d{3}\)[\s.-]?|\d{3}[\s.-])\d{3}[\s.-]?\d{4}/g,d=/(tel|sms):(?:\+1\s)?(?:(?:\(\d{3}\)\s|\d{3}-)\d{3}-\d{4}|\d{10,11})/g,c=/whatsapp:\/\/send\?phone=\d+/g,h=/(facetime|facetime-audio):\d+/g,p=/emergency|emergencia/i,f=300,g=e=>!(!e||e.length>f)&&p.test(e),m=e=>{var t,n,i,r;if(g(e.textContent))return!0;if(g(null===(t=e.previousElementSibling)||void 0===t?void 0:t.textContent)||g(null===(n=e.nextElementSibling)||void 0===n?void 0:n.textContent))return!0;const o=e.parentElement;return!(!o||!g(null===(i=o.previousElementSibling)||void 0===i?void 0:i.textContent)&&!g(null===(r=o.nextElementSibling)||void 0===r?void 0:r.textContent))},y=document.body.getElementsByTagName("*");let b=!1;const v=i.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3");let w=!1,C=!1,x=0;for(let e=0;e<y.length;e++)if(y[e].nodeType===Node.ELEMENT_NODE&&!m(y[e])){if(1===y[e].childNodes.length&&y[e].childNodes[0].nodeType==Node.TEXT_NODE){const t=y[e].textContent;if(!t)continue;const n=t.replace(u,e=>{if(Pu(e))return e;return e.startsWith("+1 ")?`+1 ${v}`:v});t!==n&&(x++,y[e].textContent=n),b=!0,w||(w=!0)}if(y[e].hasAttribute("href")){const t=y[e].getAttribute("href");if(!t)continue;let n="",i=d;if(t.startsWith("sms:")?n=o:t.startsWith("whatsapp:")?(n=a,i=c):t.startsWith("facetime:")?(n=s,i=h):t.startsWith("facetime-audio:")?(n=l,i=h):n=r,Pu(t))continue;const u=t.replace(i,n);if(y[e].setAttribute("href",u),(t.startsWith("tel:")||t.startsWith("sms:"))&&u===t&&u!==n){t.replace(/\D/g,"").length>=7&&y[e].setAttribute("href",t.startsWith("tel:")?r:o)}C||(C=!0)}}return w&&Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:v,website:window.location.href},logType:jo.info,buildingSlug:n,orgSlug:t}),C&&Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:v,website:window.location.href},logType:jo.info,buildingSlug:n,orgSlug:t}),b||Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:jo.warn,buildingSlug:n,orgSlug:t}),x}catch(e){return Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"insertion-error",error:e instanceof Error?e.message:String(e),website:window.location.href},logType:jo.error,buildingSlug:n,orgSlug:t,error:e}),0}};var Nu=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 Mu=class extends oe{constructor(){super(...arguments),this.onClick=()=>{},this.primaryColor=qn,this.toExpand=!1}render(){return R`
|
|
6036
6036
|
<button
|
|
6037
6037
|
class=${this.toExpand?"button-container mini":"button-container"}
|
|
6038
6038
|
@click=${this.onClick}
|
package/src/MyPubnub.ts
CHANGED
|
@@ -105,6 +105,9 @@ class MyPubnub {
|
|
|
105
105
|
|
|
106
106
|
private isWaitingForStreamingMessages = false;
|
|
107
107
|
|
|
108
|
+
// Confirmations already reported (by stream_id, or timetoken for a non-streamed message), so a lingering confirmation doesn't re-fire on later messages.
|
|
109
|
+
private firedScheduledTourConfirmationIds = new Set<string>();
|
|
110
|
+
|
|
108
111
|
private widgetType: WidgetType = WidgetType.Default;
|
|
109
112
|
|
|
110
113
|
pubnub: Pubnub | null = null;
|
|
@@ -158,23 +161,14 @@ class MyPubnub {
|
|
|
158
161
|
this.isLoadingMessages = isWaitingForEliseResponse;
|
|
159
162
|
|
|
160
163
|
if (messageEvent.message.customType === "ai_message") {
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
if (containsConfirmedTour) {
|
|
170
|
-
pushGtmEvent("scheduledTourEvent", {
|
|
171
|
-
tourDetails: messageEvent.message,
|
|
172
|
-
buildingId: this.buildingWebchatView?.id,
|
|
173
|
-
buildingSlug: this.buildingSlug,
|
|
174
|
-
orgSlug: this.orgSlug,
|
|
175
|
-
leadUserId: this.leadUserId,
|
|
176
|
-
channel: this.channel,
|
|
177
|
-
});
|
|
164
|
+
const streamId = messageEvent.message.stream_id;
|
|
165
|
+
// A stream_id is a stable identity for the whole reply regardless of chunk arrival order, unlike any timetoken derived from its chunks.
|
|
166
|
+
const confirmationId = streamId ?? String(+messageEvent.timetoken);
|
|
167
|
+
const currentMessageText = streamId
|
|
168
|
+
? this.reconstructStreamText(streamId)
|
|
169
|
+
: messageEvent.message.text;
|
|
170
|
+
if (currentMessageText.includes("confirmed for your")) {
|
|
171
|
+
this.fireScheduledTourEventOnce(confirmationId, messageEvent.message);
|
|
178
172
|
}
|
|
179
173
|
}
|
|
180
174
|
|
|
@@ -256,16 +250,20 @@ class MyPubnub {
|
|
|
256
250
|
this.streamingMessageTimeout = null;
|
|
257
251
|
}
|
|
258
252
|
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
253
|
+
const streamIdToChunks = new Map<string, RawPubnubMessage[]>();
|
|
254
|
+
this.rawPubnubMessages.forEach((message) => {
|
|
255
|
+
const streamId = message.message.stream_id;
|
|
256
|
+
if (!streamId) return;
|
|
257
|
+
streamIdToChunks.set(streamId, [
|
|
258
|
+
...(streamIdToChunks.get(streamId) ?? []),
|
|
259
|
+
message,
|
|
260
|
+
]);
|
|
266
261
|
});
|
|
262
|
+
const stuckStreamIds = [...streamIdToChunks.entries()]
|
|
263
|
+
.filter(([, chunks]) => !this.isStreamComplete(chunks))
|
|
264
|
+
.map(([streamId]) => streamId);
|
|
267
265
|
|
|
268
|
-
if (
|
|
266
|
+
if (stuckStreamIds.length > 0) {
|
|
269
267
|
this.streamingMessageTimeout = setTimeout(() => {
|
|
270
268
|
sendLoggingEvent({
|
|
271
269
|
logTitle: "PUBNUB_WARN_DELAYED_STREAMING_MESSAGES",
|
|
@@ -278,11 +276,65 @@ class MyPubnub {
|
|
|
278
276
|
console.warn(
|
|
279
277
|
`PUBNUB_WARN_DELAYED_STREAMING_MESSAGES: ${delayToFetchHistoryInMs}`
|
|
280
278
|
);
|
|
281
|
-
this
|
|
279
|
+
// Only re-checks the specific stream(s) that were actually stuck, so an older confirmation from before this session (or already fired live) is never rescanned.
|
|
280
|
+
this.getChannelHistory().then(() =>
|
|
281
|
+
stuckStreamIds.forEach((streamId) =>
|
|
282
|
+
this.checkAndFireTourConfirmationForStream(streamId)
|
|
283
|
+
)
|
|
284
|
+
);
|
|
282
285
|
}, delayToFetchHistoryInMs);
|
|
283
286
|
}
|
|
284
287
|
};
|
|
285
288
|
|
|
289
|
+
// Complete only once every order from 0 through the done chunk's order has arrived at least once -- a Set of order values is immune to duplicate or out-of-order chunk arrival, unlike a running consecutive-count.
|
|
290
|
+
private isStreamComplete = (chunks: RawPubnubMessage[]): boolean => {
|
|
291
|
+
const doneChunk = chunks.find((c) => c.message.is_done);
|
|
292
|
+
if (!doneChunk) return false;
|
|
293
|
+
const ordersPresent = new Set(chunks.map((c) => c.message.order ?? 0));
|
|
294
|
+
for (let order = 0; order <= (doneChunk.message.order ?? 0); order++) {
|
|
295
|
+
if (!ordersPresent.has(order)) return false;
|
|
296
|
+
}
|
|
297
|
+
return true;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
private getStreamChunks = (streamId: string): RawPubnubMessage[] =>
|
|
301
|
+
this.removeDuplicatedRawPubnubMessages(this.rawPubnubMessages)
|
|
302
|
+
.filter((m) => m.message.stream_id === streamId)
|
|
303
|
+
.sort((a, b) => (a.message.order ?? 0) - (b.message.order ?? 0));
|
|
304
|
+
|
|
305
|
+
private reconstructStreamText = (streamId: string): string =>
|
|
306
|
+
this.getStreamChunks(streamId)
|
|
307
|
+
.map((m) => m.message.text)
|
|
308
|
+
.join("");
|
|
309
|
+
|
|
310
|
+
private fireScheduledTourEventOnce = (
|
|
311
|
+
confirmationId: string,
|
|
312
|
+
tourDetails: unknown
|
|
313
|
+
): void => {
|
|
314
|
+
if (this.firedScheduledTourConfirmationIds.has(confirmationId)) return;
|
|
315
|
+
this.firedScheduledTourConfirmationIds.add(confirmationId);
|
|
316
|
+
pushGtmEvent("scheduledTourEvent", {
|
|
317
|
+
tourDetails,
|
|
318
|
+
buildingId: this.buildingWebchatView?.id,
|
|
319
|
+
buildingSlug: this.buildingSlug,
|
|
320
|
+
orgSlug: this.orgSlug,
|
|
321
|
+
leadUserId: this.leadUserId,
|
|
322
|
+
channel: this.channel,
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
private checkAndFireTourConfirmationForStream = (streamId: string): void => {
|
|
327
|
+
const text = this.reconstructStreamText(streamId);
|
|
328
|
+
if (text.includes("confirmed for your")) {
|
|
329
|
+
const chunks = this.getStreamChunks(streamId);
|
|
330
|
+
// Matches the live listener's tourDetails shape (a raw PubNub message object) instead of a synthetic { text } payload.
|
|
331
|
+
this.fireScheduledTourEventOnce(
|
|
332
|
+
streamId,
|
|
333
|
+
chunks[chunks.length - 1]?.message
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
|
|
286
338
|
checkAndHandleGTMForLeadEmail = (messageEvent: Pubnub.MessageEvent): void => {
|
|
287
339
|
try {
|
|
288
340
|
if (messageEvent.message.customType !== "lead_message") {
|
|
@@ -1151,6 +1151,7 @@ export class Launcher extends LitElement {
|
|
|
1151
1151
|
this.isSSTWindowOpen = true;
|
|
1152
1152
|
this.isCallUsWindowOpen = false;
|
|
1153
1153
|
this.isEmailWindowOpen = false;
|
|
1154
|
+
this.isCalculatorWindowOpen = false;
|
|
1154
1155
|
this.onExitChat();
|
|
1155
1156
|
if (callBack) {
|
|
1156
1157
|
callBack();
|
|
@@ -1164,6 +1165,7 @@ export class Launcher extends LitElement {
|
|
|
1164
1165
|
this.isSSTWindowOpen = false;
|
|
1165
1166
|
this.isCallUsWindowOpen = false;
|
|
1166
1167
|
this.isEmailWindowOpen = false;
|
|
1168
|
+
this.isCalculatorWindowOpen = false;
|
|
1167
1169
|
if (callBack) {
|
|
1168
1170
|
callBack();
|
|
1169
1171
|
}
|
|
@@ -1175,6 +1177,7 @@ export class Launcher extends LitElement {
|
|
|
1175
1177
|
this.isCallUsWindowOpen = true;
|
|
1176
1178
|
this.isSSTWindowOpen = false;
|
|
1177
1179
|
this.isEmailWindowOpen = false;
|
|
1180
|
+
this.isCalculatorWindowOpen = false;
|
|
1178
1181
|
this.onExitChat();
|
|
1179
1182
|
if (callBack) {
|
|
1180
1183
|
callBack();
|
|
@@ -1187,6 +1190,7 @@ export class Launcher extends LitElement {
|
|
|
1187
1190
|
this.isEmailWindowOpen = true;
|
|
1188
1191
|
this.isSSTWindowOpen = false;
|
|
1189
1192
|
this.isCallUsWindowOpen = false;
|
|
1193
|
+
this.isCalculatorWindowOpen = false;
|
|
1190
1194
|
this.onExitChat();
|
|
1191
1195
|
if (callBack) {
|
|
1192
1196
|
callBack();
|
|
@@ -1202,6 +1206,10 @@ export class Launcher extends LitElement {
|
|
|
1202
1206
|
callBack?: () => void
|
|
1203
1207
|
) => {
|
|
1204
1208
|
this.isCalculatorWindowOpen = true;
|
|
1209
|
+
this.isSSTWindowOpen = false;
|
|
1210
|
+
this.isCallUsWindowOpen = false;
|
|
1211
|
+
this.isEmailWindowOpen = false;
|
|
1212
|
+
this.onExitChat();
|
|
1205
1213
|
if (callBack) {
|
|
1206
1214
|
callBack();
|
|
1207
1215
|
}
|