@meetelise/chat 1.53.2 → 1.53.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/public/dist/index.js
CHANGED
|
@@ -6125,7 +6125,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
6125
6125
|
${Ja}
|
|
6126
6126
|
${es}
|
|
6127
6127
|
${ts}
|
|
6128
|
-
`,Yl([ue({attribute:!0})],Kl.prototype,"isMinimized",void 0),Yl([ue()],Kl.prototype,"mobileStyles",void 0),Yl([ue({type:Boolean})],Kl.prototype,"isFirstMount",void 0),Yl([ue({attribute:!1})],Kl.prototype,"openSSTWindowOnLoad",void 0),Yl([ue({attribute:!1})],Kl.prototype,"autoOpenChatWidget",void 0),Yl([ue()],Kl.prototype,"phoneNumber",void 0),Yl([ue({attribute:!0})],Kl.prototype,"buildingName",void 0),Yl([ue({attribute:!0})],Kl.prototype,"chatId",void 0),Yl([ue({attribute:!0})],Kl.prototype,"orgLegalName",void 0),Yl([ue({attribute:!1})],Kl.prototype,"country",void 0),Yl([ue({attribute:!1})],Kl.prototype,"buildingState",void 0),Yl([ue({attribute:!0})],Kl.prototype,"chatCallUsHeader",void 0),Yl([ue({attribute:!1})],Kl.prototype,"buildingId",void 0),Yl([ue({type:Number})],Kl.prototype,"orgId",void 0),Yl([ue({attribute:!1})],Kl.prototype,"leadSourceParams",void 0),Yl([ue({attribute:!0})],Kl.prototype,"buildingSlug",void 0),Yl([ue({attribute:!0})],Kl.prototype,"orgSlug",void 0),Yl([ue({attribute:!0})],Kl.prototype,"sgtUrl",void 0),Yl([ue({attribute:!0})],Kl.prototype,"selfGuidedTourEnabled",void 0),Yl([ue({attribute:!0})],Kl.prototype,"selfGuidedToursTypeOffered",void 0),Yl([ue({attribute:!0})],Kl.prototype,"designConcept",void 0),Yl([ue({attribute:!0})],Kl.prototype,"featureFlagShowDropdown",void 0),Yl([ue({attribute:!1})],Kl.prototype,"leadSources",void 0),Yl([ue({attribute:!0})],Kl.prototype,"currentLeadSource",void 0),Yl([ue({attribute:!0})],Kl.prototype,"escortedToursLink",void 0),Yl([ue({attribute:!0})],Kl.prototype,"escortedToursTypeOffered",void 0),Yl([ue({attribute:!0})],Kl.prototype,"virtualToursLink",void 0),Yl([ue({attribute:!0})],Kl.prototype,"virtualToursTypeOffered",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasChatEnabledDesktop",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasChatEnabledMobile",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasEmailEnabledDesktop",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasEmailEnabledMobile",void 0),Yl([ue({attribute:!0})],Kl.prototype,"hasApplyNowEnabledDesktop",void 0),Yl([ue({attribute:!0})],Kl.prototype,"hasApplyNowEnabledMobile",void 0),Yl([ue({attribute:!0})],Kl.prototype,"applicationLink",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasCallUsEnabledDesktop",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasCallUsEnabledMobile",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasTextUsEnabledDesktop",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasTextUsEnabledMobile",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasSSTEnabledDesktop",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasSSTEnabledMobile",void 0),Yl([ue({attribute:!1})],Kl.prototype,"tourTypeOptions",void 0),Yl([ue({attribute:!1})],Kl.prototype,"layoutOptions",void 0),Yl([ue({attribute:!0})],Kl.prototype,"bedroomPreferenceRequired",void 0),Yl([ue({attribute:!0})],Kl.prototype,"hasDynamicSchedulingEnabled",void 0),Yl([ue({attribute:!0})],Kl.prototype,"hasPricingCalculatorEnabledDesktop",void 0),Yl([ue({attribute:!0})],Kl.prototype,"hasPricingCalculatorEnabledMobile",void 0),Yl([ue({attribute:!1})],Kl.prototype,"hasHideMobileFeatures",void 0),Yl([ue({type:Number})],Kl.prototype,"right",void 0),Yl([ue({type:Number})],Kl.prototype,"bottom",void 0),Yl([ue({type:Number})],Kl.prototype,"top",void 0),Yl([ue({type:Number})],Kl.prototype,"left",void 0),Yl([ue({attribute:!0})],Kl.prototype,"showTourNextToChat",void 0),Yl([ue({attribute:!1})],Kl.prototype,"onChatTapped",void 0),Yl([ue({attribute:!0})],Kl.prototype,"onClickMinimize",void 0),Yl([ue({attribute:!0})],Kl.prototype,"onSstClose",void 0),Yl([ue({attribute:!0})],Kl.prototype,"overrideRentgrata",void 0),Yl([ue({attribute:!1})],Kl.prototype,"launcherStyles",void 0),Yl([ue({attribute:!0})],Kl.prototype,"primaryColor",void 0),Yl([ue({attribute:!0})],Kl.prototype,"backgroundColor",void 0),Yl([ue({attribute:!0})],Kl.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),Yl([ue({attribute:!0})],Kl.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),Yl([ue({attribute:!0})],Kl.prototype,"leadSourceClient",void 0),Yl([de()],Kl.prototype,"leadSourceMultitouchClient",void 0),Yl([de()],Kl.prototype,"_isMobile",void 0),Yl([de()],Kl.prototype,"isEmailWindowOpen",void 0),Yl([de()],Kl.prototype,"isCallUsWindowOpen",void 0),Yl([de()],Kl.prototype,"isSSTWindowOpen",void 0),Yl([de()],Kl.prototype,"isTextUsWindowOpen",void 0),Yl([de()],Kl.prototype,"isCalculatorWindowOpen",void 0),Yl([de()],Kl.prototype,"isMobileFeaturesExpanded",void 0),Kl=Yl([se("meetelise-launcher")],Kl);const Xl=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",Kl)},Zl=["app.meetelise.com","staging.eliseai.com","localhost"],Jl={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"}},eu=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 Jl&&(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=Jl[e];n&&(i[n.desktop]=t,i[n.mobile]=t)}),i};var tu=n(5072),nu=n.n(tu),iu=n(7825),ru=n.n(iu),ou=n(7659),au=n.n(ou),su=n(5056),lu=n.n(su),uu=n(540),du=n.n(uu),cu=n(1113),hu=n.n(cu),pu=n(5541),fu={};fu.styleTagTransform=hu(),fu.setAttributes=lu(),fu.insert=au().bind(null,"head"),fu.domAPI=ru(),fu.insertStyleElement=du();nu()(pu.A,fu);pu.A&&pu.A.locals&&pu.A.locals;async function gu(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 mu(n.data,t)}return[]}catch(e){return[]}}const mu=(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 yu(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 bu,vu=n(8805),wu=n.n(vu),Cu=new Uint8Array(16);function xu(){if(!bu&&!(bu="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 bu(Cu)}const $u=/^(?:[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 Su=function(e){return"string"==typeof e&&$u.test(e)};for(var Au=[],Eu=0;Eu<256;++Eu)Au.push((Eu+256).toString(16).substr(1));const Tu=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(Au[e[t+0]]+Au[e[t+1]]+Au[e[t+2]]+Au[e[t+3]]+"-"+Au[e[t+4]]+Au[e[t+5]]+"-"+Au[e[t+6]]+Au[e[t+7]]+"-"+Au[e[t+8]]+Au[e[t+9]]+"-"+Au[e[t+10]]+Au[e[t+11]]+Au[e[t+12]]+Au[e[t+13]]+Au[e[t+14]]+Au[e[t+15]]).toLowerCase();if(!Su(n))throw TypeError("Stringified UUID is invalid");return n};const ku=function(e,t,n){var i=(e=e||{}).random||(e.rng||xu)();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 Tu(i)},_u=e=>localStorage.removeItem("com.elise.webchat.slug="+e),Ou=(e,t,n)=>{const i=Br(new Date),r=n||`lead_${ku()}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:i,initiatedChat:t})),{leadId:r,timestamp:qr(i),buildingSlug:e,initiatedChat:t}},Pu=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(Iu(e,i))return i}catch(e){}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},Iu=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if($r(t.timestamp,e))return!1}}catch(e){}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp)&&!Ir(t.timestamp,24)};var Mu;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(Mu||(Mu={}));const Nu=e=>e.type===Lu.text,Du=e=>e.type===Lu.media;var Lu;!function(e){e.text="text",e.media="media"}(Lu||(Lu={}));const Uu=class{constructor(e,t,n,i=null,r,o,a=null,s=jc.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=jc.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!==Mu.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(()=>{Vo({logTitle:"PUBNUB_WARN_DELAYED_STREAMING_MESSAGES",logData:{channel:this.channel},logType:qo.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),$o("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;$o("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)===Mu.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&&Vo({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:qo.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=Ou(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&&Vo({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:qo.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===jc.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=>Tr({...e}))}}),null===(a=this.leadSourceClient)||void 0===a||a.resetLeadSource(),null===(s=this.leadSourceMultitouchClient)||void 0===s||s.resetLeadSourceTouchpoints()),this.isFirstChatMessageSent||($o("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),$o("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)?(Vo({logTitle:"PUBNUB_WARN_DUPLICATE_MESSAGE",logData:{message:e,channel:this.channel},logType:qo.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:Lu.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:Lu.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:Lu.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&&Vo({logTitle:"WEBCHAT_INIT_SESSION_ERROR",logData:{error:e},logType:qo.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(wu())({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&&Vo({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:qo.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&&Vo({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:qo.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&&Vo({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:qo.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!==Mu.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&&Vo({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:qo.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")}},Ru=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"]),Bu=e=>{const t=e.replace(/\D/g,"").replace(/^1(\d{10})$/,"$1");return Ru.has(t)},ju=(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.-]?)?(?:\([2-9]\d{2}\)[\s.-]?|[2-9]\d{2}[\s.-])[2-9]\d{2}[\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(Bu(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,Bu(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&&Vo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:v,website:window.location.href},logType:qo.info,buildingSlug:n,orgSlug:t}),C&&Vo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:v,website:window.location.href},logType:qo.info,buildingSlug:n,orgSlug:t}),b||Vo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:qo.warn,buildingSlug:n,orgSlug:t}),x}catch(e){return Vo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"insertion-error",error:e instanceof Error?e.message:String(e),website:window.location.href},logType:qo.error,buildingSlug:n,orgSlug:t,error:e}),0}},Fu=(e,t,n,i)=>{document.querySelectorAll("a").forEach(function(r){const o=r.getAttribute("href");o&&o.startsWith("https://app.meetelise.com/")&&((e,t,n)=>{const[i,r,o,...a]=new URL(e).pathname.split("/").filter(Boolean).map(e=>e.toLowerCase());return 0===a.length&&"tour"===o&&i===t.toLowerCase()&&r===n.toLowerCase()})(o,t,n)&&r.addEventListener("click",t=>{i()&&(t.preventDefault(),e(t))})})};var Hu=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 Gu=class extends oe{constructor(){super(...arguments),this.onClick=()=>{},this.primaryColor=Vn,this.foregroundColorOnPrimaryBackgroundColor="white",this.toExpand=!1}render(){return R`
|
|
6128
|
+
`,Yl([ue({attribute:!0})],Kl.prototype,"isMinimized",void 0),Yl([ue()],Kl.prototype,"mobileStyles",void 0),Yl([ue({type:Boolean})],Kl.prototype,"isFirstMount",void 0),Yl([ue({attribute:!1})],Kl.prototype,"openSSTWindowOnLoad",void 0),Yl([ue({attribute:!1})],Kl.prototype,"autoOpenChatWidget",void 0),Yl([ue()],Kl.prototype,"phoneNumber",void 0),Yl([ue({attribute:!0})],Kl.prototype,"buildingName",void 0),Yl([ue({attribute:!0})],Kl.prototype,"chatId",void 0),Yl([ue({attribute:!0})],Kl.prototype,"orgLegalName",void 0),Yl([ue({attribute:!1})],Kl.prototype,"country",void 0),Yl([ue({attribute:!1})],Kl.prototype,"buildingState",void 0),Yl([ue({attribute:!0})],Kl.prototype,"chatCallUsHeader",void 0),Yl([ue({attribute:!1})],Kl.prototype,"buildingId",void 0),Yl([ue({type:Number})],Kl.prototype,"orgId",void 0),Yl([ue({attribute:!1})],Kl.prototype,"leadSourceParams",void 0),Yl([ue({attribute:!0})],Kl.prototype,"buildingSlug",void 0),Yl([ue({attribute:!0})],Kl.prototype,"orgSlug",void 0),Yl([ue({attribute:!0})],Kl.prototype,"sgtUrl",void 0),Yl([ue({attribute:!0})],Kl.prototype,"selfGuidedTourEnabled",void 0),Yl([ue({attribute:!0})],Kl.prototype,"selfGuidedToursTypeOffered",void 0),Yl([ue({attribute:!0})],Kl.prototype,"designConcept",void 0),Yl([ue({attribute:!0})],Kl.prototype,"featureFlagShowDropdown",void 0),Yl([ue({attribute:!1})],Kl.prototype,"leadSources",void 0),Yl([ue({attribute:!0})],Kl.prototype,"currentLeadSource",void 0),Yl([ue({attribute:!0})],Kl.prototype,"escortedToursLink",void 0),Yl([ue({attribute:!0})],Kl.prototype,"escortedToursTypeOffered",void 0),Yl([ue({attribute:!0})],Kl.prototype,"virtualToursLink",void 0),Yl([ue({attribute:!0})],Kl.prototype,"virtualToursTypeOffered",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasChatEnabledDesktop",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasChatEnabledMobile",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasEmailEnabledDesktop",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasEmailEnabledMobile",void 0),Yl([ue({attribute:!0})],Kl.prototype,"hasApplyNowEnabledDesktop",void 0),Yl([ue({attribute:!0})],Kl.prototype,"hasApplyNowEnabledMobile",void 0),Yl([ue({attribute:!0})],Kl.prototype,"applicationLink",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasCallUsEnabledDesktop",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasCallUsEnabledMobile",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasTextUsEnabledDesktop",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasTextUsEnabledMobile",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasSSTEnabledDesktop",void 0),Yl([ue({type:Boolean})],Kl.prototype,"hasSSTEnabledMobile",void 0),Yl([ue({attribute:!1})],Kl.prototype,"tourTypeOptions",void 0),Yl([ue({attribute:!1})],Kl.prototype,"layoutOptions",void 0),Yl([ue({attribute:!0})],Kl.prototype,"bedroomPreferenceRequired",void 0),Yl([ue({attribute:!0})],Kl.prototype,"hasDynamicSchedulingEnabled",void 0),Yl([ue({attribute:!0})],Kl.prototype,"hasPricingCalculatorEnabledDesktop",void 0),Yl([ue({attribute:!0})],Kl.prototype,"hasPricingCalculatorEnabledMobile",void 0),Yl([ue({attribute:!1})],Kl.prototype,"hasHideMobileFeatures",void 0),Yl([ue({type:Number})],Kl.prototype,"right",void 0),Yl([ue({type:Number})],Kl.prototype,"bottom",void 0),Yl([ue({type:Number})],Kl.prototype,"top",void 0),Yl([ue({type:Number})],Kl.prototype,"left",void 0),Yl([ue({attribute:!0})],Kl.prototype,"showTourNextToChat",void 0),Yl([ue({attribute:!1})],Kl.prototype,"onChatTapped",void 0),Yl([ue({attribute:!0})],Kl.prototype,"onClickMinimize",void 0),Yl([ue({attribute:!0})],Kl.prototype,"onSstClose",void 0),Yl([ue({attribute:!0})],Kl.prototype,"overrideRentgrata",void 0),Yl([ue({attribute:!1})],Kl.prototype,"launcherStyles",void 0),Yl([ue({attribute:!0})],Kl.prototype,"primaryColor",void 0),Yl([ue({attribute:!0})],Kl.prototype,"backgroundColor",void 0),Yl([ue({attribute:!0})],Kl.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),Yl([ue({attribute:!0})],Kl.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),Yl([ue({attribute:!0})],Kl.prototype,"leadSourceClient",void 0),Yl([de()],Kl.prototype,"leadSourceMultitouchClient",void 0),Yl([de()],Kl.prototype,"_isMobile",void 0),Yl([de()],Kl.prototype,"isEmailWindowOpen",void 0),Yl([de()],Kl.prototype,"isCallUsWindowOpen",void 0),Yl([de()],Kl.prototype,"isSSTWindowOpen",void 0),Yl([de()],Kl.prototype,"isTextUsWindowOpen",void 0),Yl([de()],Kl.prototype,"isCalculatorWindowOpen",void 0),Yl([de()],Kl.prototype,"isMobileFeaturesExpanded",void 0),Kl=Yl([se("meetelise-launcher")],Kl);const Xl=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",Kl)},Zl=["app.meetelise.com","staging.eliseai.com","localhost"],Jl={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"}},eu=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 Jl&&(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=Jl[e];n&&(i[n.desktop]=t,i[n.mobile]=t)}),i};var tu=n(5072),nu=n.n(tu),iu=n(7825),ru=n.n(iu),ou=n(7659),au=n.n(ou),su=n(5056),lu=n.n(su),uu=n(540),du=n.n(uu),cu=n(1113),hu=n.n(cu),pu=n(5541),fu={};fu.styleTagTransform=hu(),fu.setAttributes=lu(),fu.insert=au().bind(null,"head"),fu.domAPI=ru(),fu.insertStyleElement=du();nu()(pu.A,fu);pu.A&&pu.A.locals&&pu.A.locals;async function gu(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 mu(n.data,t)}return[]}catch(e){return[]}}const mu=(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 yu(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 bu,vu=n(8805),wu=n.n(vu),Cu=new Uint8Array(16);function xu(){if(!bu&&!(bu="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 bu(Cu)}const $u=/^(?:[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 Su=function(e){return"string"==typeof e&&$u.test(e)};for(var Au=[],Eu=0;Eu<256;++Eu)Au.push((Eu+256).toString(16).substr(1));const Tu=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(Au[e[t+0]]+Au[e[t+1]]+Au[e[t+2]]+Au[e[t+3]]+"-"+Au[e[t+4]]+Au[e[t+5]]+"-"+Au[e[t+6]]+Au[e[t+7]]+"-"+Au[e[t+8]]+Au[e[t+9]]+"-"+Au[e[t+10]]+Au[e[t+11]]+Au[e[t+12]]+Au[e[t+13]]+Au[e[t+14]]+Au[e[t+15]]).toLowerCase();if(!Su(n))throw TypeError("Stringified UUID is invalid");return n};const ku=function(e,t,n){var i=(e=e||{}).random||(e.rng||xu)();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 Tu(i)},_u=e=>localStorage.removeItem("com.elise.webchat.slug="+e),Ou=(e,t,n)=>{const i=Br(new Date),r=n||`lead_${ku()}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:i,initiatedChat:t})),{leadId:r,timestamp:qr(i),buildingSlug:e,initiatedChat:t}},Pu=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(Iu(e,i))return i}catch(e){}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},Iu=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if($r(t.timestamp,e))return!1}}catch(e){}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp)&&!Ir(t.timestamp,24)};var Mu;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(Mu||(Mu={}));const Nu=e=>e.type===Lu.text,Du=e=>e.type===Lu.media;var Lu;!function(e){e.text="text",e.media="media"}(Lu||(Lu={}));const Uu=class{constructor(e,t,n,i=null,r,o,a=null,s=jc.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=jc.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!==Mu.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){const t=e.message.stream_id,i=null!=t?t:String(+e.timetoken);(t?this.reconstructStreamText(t):null!==(n=e.message.text)&&void 0!==n?n:"").includes("confirmed for your")&&this.fireScheduledTourEventOnce(i,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(()=>{Vo({logTitle:"PUBNUB_WARN_DELAYED_STREAMING_MESSAGES",logData:{channel:this.channel},logType:qo.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),$o("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;$o("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)===Mu.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&&Vo({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:qo.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=Ou(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&&Vo({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:qo.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===jc.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=>Tr({...e}))}}),null===(a=this.leadSourceClient)||void 0===a||a.resetLeadSource(),null===(s=this.leadSourceMultitouchClient)||void 0===s||s.resetLeadSourceTouchpoints()),this.isFirstChatMessageSent||($o("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),$o("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)?(Vo({logTitle:"PUBNUB_WARN_DUPLICATE_MESSAGE",logData:{message:e,channel:this.channel},logType:qo.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:Lu.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:Lu.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:Lu.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&&Vo({logTitle:"WEBCHAT_INIT_SESSION_ERROR",logData:{error:e},logType:qo.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(wu())({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&&Vo({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:qo.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&&Vo({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:qo.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&&Vo({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:qo.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!==Mu.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&&Vo({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:qo.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")}},Ru=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"]),Bu=e=>{const t=e.replace(/\D/g,"").replace(/^1(\d{10})$/,"$1");return Ru.has(t)},ju=(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.-]?)?(?:\([2-9]\d{2}\)[\s.-]?|[2-9]\d{2}[\s.-])[2-9]\d{2}[\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(Bu(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,Bu(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&&Vo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:v,website:window.location.href},logType:qo.info,buildingSlug:n,orgSlug:t}),C&&Vo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:v,website:window.location.href},logType:qo.info,buildingSlug:n,orgSlug:t}),b||Vo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:qo.warn,buildingSlug:n,orgSlug:t}),x}catch(e){return Vo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"insertion-error",error:e instanceof Error?e.message:String(e),website:window.location.href},logType:qo.error,buildingSlug:n,orgSlug:t,error:e}),0}},Fu=(e,t,n,i)=>{document.querySelectorAll("a").forEach(function(r){const o=r.getAttribute("href");o&&o.startsWith("https://app.meetelise.com/")&&((e,t,n)=>{const[i,r,o,...a]=new URL(e).pathname.split("/").filter(Boolean).map(e=>e.toLowerCase());return 0===a.length&&"tour"===o&&i===t.toLowerCase()&&r===n.toLowerCase()})(o,t,n)&&r.addEventListener("click",t=>{i()&&(t.preventDefault(),e(t))})})};var Hu=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 Gu=class extends oe{constructor(){super(...arguments),this.onClick=()=>{},this.primaryColor=Vn,this.foregroundColorOnPrimaryBackgroundColor="white",this.toExpand=!1}render(){return R`
|
|
6129
6129
|
<button
|
|
6130
6130
|
class=${this.toExpand?"button-container mini":"button-container"}
|
|
6131
6131
|
@click=${this.onClick}
|
|
@@ -6749,6 +6749,12 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
6749
6749
|
><img class=${"displayed-message-image"} src=${e.url} alt=""
|
|
6750
6750
|
/></a>`)}
|
|
6751
6751
|
</div>`:R``}};ic.styles=[Oe,Wu,u`
|
|
6752
|
+
/* This element is a flex item in a bubble capped below the chat width.
|
|
6753
|
+
Without min-width: 0 it is at least as wide as all slides' captions
|
|
6754
|
+
side by side, so the carousel spills out of the bubble and the chat. */
|
|
6755
|
+
:host {
|
|
6756
|
+
min-width: 0;
|
|
6757
|
+
}
|
|
6752
6758
|
.carousel {
|
|
6753
6759
|
position: relative;
|
|
6754
6760
|
max-width: 400px;
|
package/src/MyPubnub.ts
CHANGED
|
@@ -164,9 +164,10 @@ class MyPubnub {
|
|
|
164
164
|
const streamId = messageEvent.message.stream_id;
|
|
165
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
166
|
const confirmationId = streamId ?? String(+messageEvent.timetoken);
|
|
167
|
+
// Media messages carry no text.
|
|
167
168
|
const currentMessageText = streamId
|
|
168
169
|
? this.reconstructStreamText(streamId)
|
|
169
|
-
: messageEvent.message.text;
|
|
170
|
+
: messageEvent.message.text ?? "";
|
|
170
171
|
if (currentMessageText.includes("confirmed for your")) {
|
|
171
172
|
this.fireScheduledTourEventOnce(confirmationId, messageEvent.message);
|
|
172
173
|
}
|
|
@@ -11,6 +11,12 @@ export class PubnubMedia extends LitElement {
|
|
|
11
11
|
InputStyles,
|
|
12
12
|
pubnubChatStyles,
|
|
13
13
|
css`
|
|
14
|
+
/* This element is a flex item in a bubble capped below the chat width.
|
|
15
|
+
Without min-width: 0 it is at least as wide as all slides' captions
|
|
16
|
+
side by side, so the carousel spills out of the bubble and the chat. */
|
|
17
|
+
:host {
|
|
18
|
+
min-width: 0;
|
|
19
|
+
}
|
|
14
20
|
.carousel {
|
|
15
21
|
position: relative;
|
|
16
22
|
max-width: 400px;
|
package/src/pubnub-chat.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { expect } from "@esm-bundle/chai";
|
|
2
2
|
import "../public/dist/index";
|
|
3
3
|
import { BuildingWebchatView } from "./fetchBuildingWebchatView";
|
|
4
|
-
import type { SimpleTextChatMessage } from "./MyPubnub";
|
|
4
|
+
import type { SimpleMediaChatMessage, SimpleTextChatMessage } from "./MyPubnub";
|
|
5
5
|
import type { PubnubChat } from "./WebComponent/pubnub-chat";
|
|
6
6
|
|
|
7
7
|
declare const afterEach: (callback: () => void) => void;
|
|
@@ -190,3 +190,55 @@ it("follows the conversation again when the reader sends a message", async () =>
|
|
|
190
190
|
|
|
191
191
|
expectOnlyAutoScrollsTo(scrollCalls, 600);
|
|
192
192
|
});
|
|
193
|
+
|
|
194
|
+
it("keeps a photo carousel and its arrows inside the message bubble", async () => {
|
|
195
|
+
const { chat } = await createScrollableChat();
|
|
196
|
+
// Wide photos, like real floor plan images, inlined so the test needs no network.
|
|
197
|
+
const widePhoto = `data:image/svg+xml,${encodeURIComponent(
|
|
198
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="900"/>'
|
|
199
|
+
)}`;
|
|
200
|
+
const photos: SimpleMediaChatMessage = {
|
|
201
|
+
timestamp: 100,
|
|
202
|
+
// Eight captioned photos, as one floor plan can have: the overflow came
|
|
203
|
+
// from the slides' combined caption widths, so a few short ones hide it.
|
|
204
|
+
media: [
|
|
205
|
+
"Living Room",
|
|
206
|
+
"Dining Area",
|
|
207
|
+
"Kitchen",
|
|
208
|
+
"Pantry",
|
|
209
|
+
"Bedroom",
|
|
210
|
+
"Closet",
|
|
211
|
+
"Hallway",
|
|
212
|
+
"Bathroom",
|
|
213
|
+
].map((title) => ({
|
|
214
|
+
title,
|
|
215
|
+
description: `${title} with refrigerator, cabinetry and shelving`,
|
|
216
|
+
url: widePhoto,
|
|
217
|
+
})),
|
|
218
|
+
isLeadMessage: false,
|
|
219
|
+
type: "media" as SimpleMediaChatMessage["type"],
|
|
220
|
+
};
|
|
221
|
+
chat.messages = [photos];
|
|
222
|
+
await waitForRender(chat);
|
|
223
|
+
const media = chat.shadowRoot?.querySelector("pubnub-media") as
|
|
224
|
+
| (HTMLElement & { updateComplete: Promise<boolean> })
|
|
225
|
+
| null;
|
|
226
|
+
if (!media) throw new Error("Expected the photo message to render");
|
|
227
|
+
await media.updateComplete;
|
|
228
|
+
await Promise.all(
|
|
229
|
+
Array.from(media.shadowRoot?.querySelectorAll("img") ?? []).map((img) =>
|
|
230
|
+
img.decode()
|
|
231
|
+
)
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
const bubble = media.closest("li")?.getBoundingClientRect();
|
|
235
|
+
const carousel = media.shadowRoot
|
|
236
|
+
?.querySelector(".carousel")
|
|
237
|
+
?.getBoundingClientRect();
|
|
238
|
+
const next = media.shadowRoot
|
|
239
|
+
?.querySelector(".next")
|
|
240
|
+
?.getBoundingClientRect();
|
|
241
|
+
if (!bubble || !carousel || !next) throw new Error("Expected a carousel");
|
|
242
|
+
expect(carousel.right).to.be.at.most(bubble.right);
|
|
243
|
+
expect(next.right).to.be.at.most(bubble.right);
|
|
244
|
+
});
|