@meetelise/chat 1.20.214 → 1.20.215
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 +1 -1
- package/public/dist/index.js +3 -3
- package/src/MyPubnub.ts +7 -0
- package/src/WebComponent/pubnub-media.ts +1 -11
package/package.json
CHANGED
package/public/dist/index.js
CHANGED
|
@@ -2999,7 +2999,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
2999
2999
|
${bi}
|
|
3000
3000
|
${wi}
|
|
3001
3001
|
${Si}
|
|
3002
|
-
`,Zi([ue({attribute:!0})],$i.prototype,"isMinimized",void 0),Zi([ue()],$i.prototype,"mobileStyles",void 0),Zi([ue({type:Boolean})],$i.prototype,"isFirstMount",void 0),Zi([ue({attribute:!1})],$i.prototype,"autoOpenChatWidget",void 0),Zi([ue()],$i.prototype,"phoneNumber",void 0),Zi([ue({attribute:!0})],$i.prototype,"buildingName",void 0),Zi([ue({attribute:!0})],$i.prototype,"chatId",void 0),Zi([ue({attribute:!0})],$i.prototype,"chatCallUsHeader",void 0),Zi([ue({attribute:!1})],$i.prototype,"buildingId",void 0),Zi([ue({attribute:!0})],$i.prototype,"buildingSlug",void 0),Zi([ue({attribute:!0})],$i.prototype,"orgSlug",void 0),Zi([ue({attribute:!0})],$i.prototype,"sgtUrl",void 0),Zi([ue({attribute:!0})],$i.prototype,"designConcept",void 0),Zi([ue({attribute:!0})],$i.prototype,"featureFlagShowDropdown",void 0),Zi([ue({attribute:!1})],$i.prototype,"leadSources",void 0),Zi([ue({attribute:!0})],$i.prototype,"currentLeadSource",void 0),Zi([ue({attribute:!0})],$i.prototype,"escortedToursLink",void 0),Zi([ue({attribute:!0})],$i.prototype,"virtualToursLink",void 0),Zi([ue({type:Boolean})],$i.prototype,"hasCallUsEnabled",void 0),Zi([ue({type:Boolean})],$i.prototype,"hasChatEnabled",void 0),Zi([ue({type:Boolean})],$i.prototype,"hasEmailEnabled",void 0),Zi([ue({type:Boolean})],$i.prototype,"hasSSTEnabled",void 0),Zi([ue({type:Boolean})],$i.prototype,"hasTextUsEnabled",void 0),Zi([ue({attribute:!1})],$i.prototype,"layoutOptions",void 0),Zi([ue({attribute:!1})],$i.prototype,"unitOptions",void 0),Zi([ue({attribute:!1})],$i.prototype,"tourTypeOptions",void 0),Zi([ue({attribute:!0})],$i.prototype,"hasDynamicSchedulingEnabled",void 0),Zi([ue({attribute:!0})],$i.prototype,"onExitChat",void 0),Zi([ue({type:Number})],$i.prototype,"right",void 0),Zi([ue({type:Number})],$i.prototype,"bottom",void 0),Zi([ue({type:Number})],$i.prototype,"top",void 0),Zi([ue({type:Number})],$i.prototype,"left",void 0),Zi([ue({attribute:!0})],$i.prototype,"showTourNextToChat",void 0),Zi([ue({attribute:!1})],$i.prototype,"onChatTapped",void 0),Zi([ue({attribute:!0})],$i.prototype,"onClickMinimize",void 0),Zi([ue({attribute:!1})],$i.prototype,"launcherStyles",void 0),Zi([ue({attribute:!0})],$i.prototype,"brandColor",void 0),Zi([le()],$i.prototype,"isEmailWindowOpen",void 0),Zi([le()],$i.prototype,"isCallUsWindowOpen",void 0),Zi([le()],$i.prototype,"isSSTWindowOpen",void 0),Zi([le()],$i.prototype,"isTextUsWindowOpen",void 0),$i=Zi([ae("meetelise-launcher")],$i);const er=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",$i)};var tr=n(3379),nr=n.n(tr),ir=n(7795),rr=n.n(ir),or=n(569),ar=n.n(or),sr=n(3565),ur=n.n(sr),lr=n(9216),dr=n.n(lr),cr=n(4589),pr=n.n(cr),hr=n(3631),fr={};async function mr(e){try{const n=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/lead-sources`);return n.data?gr(n.data,e):[]}catch(e){return[]}}fr.styleTagTransform=pr(),fr.setAttributes=ur(),fr.insert=ar().bind(null,"head"),fr.domAPI=rr(),fr.insertStyleElement=dr(),nr()(hr.Z,fr),hr.Z&&hr.Z.locals&&hr.Z.locals;const gr=(e,t)=>{let n=[];switch(t){case"d41619ec-0f79-11ee-8439-93855926ad58":n=["Forthea - PPC","HotPads","Forthea","Locator","Website-apartmentguide.com","Forthea - organic search","Tdc employee","University newspaper","Nashville apartment locators","Forthea - paid social","Apartment list","Off campus partners","Waze ads","Athletic event","Website-apartment guide"];break;case"d4160560-0f79-11ee-8438-fba837bf3a46":n=["Forthea - PPC","Rentgrata","Website-ApartmentFinder.com","Word of Mouth","Texas A&M A-Frame on Campus","Rent.com","Website-craigslist","Apartment List","Website-apartments.com","Forthea - paid social","Forthea - organic search","Website-apartmentguide.com","Forthea","Uhomes","Phone book","Property - website"];break;default:n=[]}return e.sort(),e.filter((e=>{const t=e.toLowerCase();return!n.map((e=>e.toLowerCase())).includes(t)}))};var vr,yr=n(9594),br=n.n(yr),wr=new Uint8Array(16);function Sr(){if(!vr&&!(vr="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 vr(wr)}const Tr=/^(?:[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,xr=function(e){return"string"==typeof e&&Tr.test(e)};for(var Ar=[],Or=0;Or<256;++Or)Ar.push((Or+256).toString(16).substr(1));const Cr=function(e,t,n){var i=(e=e||{}).random||(e.rng||Sr)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var r=0;r<16;++r)t[n+r]=i[r];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(Ar[e[t+0]]+Ar[e[t+1]]+Ar[e[t+2]]+Ar[e[t+3]]+"-"+Ar[e[t+4]]+Ar[e[t+5]]+"-"+Ar[e[t+6]]+Ar[e[t+7]]+"-"+Ar[e[t+8]]+Ar[e[t+9]]+"-"+Ar[e[t+10]]+Ar[e[t+11]]+Ar[e[t+12]]+Ar[e[t+13]]+Ar[e[t+14]]+Ar[e[t+15]]).toLowerCase();if(!xr(n))throw TypeError("Stringified UUID is invalid");return n}(i)},Ir=e=>localStorage.removeItem("com.elise.webchat.slug="+e),Nr=(e,t,n)=>{const i=mn(new Date),r=n||`lead_${Cr()}_${e}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:i,initiatedChat:t})),{leadId:r,timestamp:Tn(i),buildingSlug:e,initiatedChat:t}},Er=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(Rr(e,i))return i}catch(e){console.warn("Error getting chat storage key")}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},Rr=(e,t)=>!(t.buildingSlug!==e||!t.leadId||!t.timestamp||dn(t.timestamp,24));var _r;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(_r||(_r={}));const Pr=e=>e.type===Fr.text,Mr=e=>e.type===Fr.media;var Fr;!function(e){e.text="text",e.media="media"}(Fr||(Fr={}));const Dr=class{constructor(e,t,n,i=null,r){this.apiHost="https://app.meetelise.com",this.building=null,this.eliseResponseTimeout=null,this.pubnub=null,this.leadUserId="",this.channel="",this.leadSource=null,this.isCurrentlyStreamingMessage=!1,this.chatListener=null,this.rawPubnubMessages=[],this.simpleChatMessages=[],this.listenerParams={message:e=>{var t;e.message.messageType!==_r.noReply&&(this.rawPubnubMessages=[...this.rawPubnubMessages,{channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken}],this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages));const n="eliseai"!==e.publisher&&"elise_health_ai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:n}),!n&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=n}},this.isLoadingMessages=!1,this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){this.building&&si({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:ai.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.handleDisconnect=()=>{this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.removeChatListeners()},this.removeChatListeners=()=>{this.pubnub&&this.channel&&(this.pubnub.unsubscribe({channels:[this.channel]}),this.pubnub.removeListener(this.listenerParams))},this.sendMessage=async e=>{if(e){if(!this.pubnub){const e=Nr(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken((async()=>{var t,n;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),this.building&&si({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:ai.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}),9e4),await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(t=this.building)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,userId:null===(n=this.building)||void 0===n?void 0:n.userId,leadSource:this.leadSource}}))})),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.translatePubnubMessagesIntoSimpleChatMessages=e=>{const t=[],n={};return e.forEach((e=>{var i;"media"===e.message.messageType?t.push({timestamp:e.timetoken,media:null!==(i=e.message.media)&&void 0!==i?i:[],isLeadMessage:this.isLeadMessage(e),type:Fr.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:Fr.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:Fr.text};this.isCurrentlyStreamingMessage=this.isMessageStillStreamingChunks(r),t.push(s)})),t.sort(((e,t)=>e.timestamp-t.timestamp)),t},this.getConsecutiveChunks=e=>{var t,n;const i=e.sort(((e,t)=>{var n,i;return(null!==(n=e.message.order)&&void 0!==n?n:0)-(null!==(i=t.message.order)&&void 0!==i?i:0)})),r=[];let o=null!==(t=i[0].message.order)&&void 0!==t?t:0;for(const e of i){if((null!==(n=e.message.order)&&void 0!==n?n:-1)!==o)break;r.push(e),o++}return r},this.isMessageStillStreamingChunks=e=>{const t=e.find((e=>e.message.is_done));return!t||e.length===t.message.order},this.buildingSlug=e,this.building=t,this.orgSlug=n,this.leadSource=i,this.leadUserId=r,this.channel=`webchat_${r}`}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(br())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,n){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${n}&${this.building?"":"industry=health_care"}`)).data}catch(e){this.building&&si({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:ai.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return null}async fetchChannelExists(e){try{return(await t().get(`${this.apiHost}/platformApi/webchat/check-channel-exists?channel_name=${e}`)).data}catch(e){this.building&&si({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:ai.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(n){if(n instanceof e.AxiosError&&n&&n.response&&403===n.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const e=await this.fetchToken(this.leadUserId,this.channel);if(!e)return;this.pubnub.setAuthKey(e.auth.result.token),await t()}catch(e){this.building&&si({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:ai.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(e=1500){var t;try{let n=[],i=null;const r=100;for(let t=0;t<e;t+=r){const o=await new Promise(((n,o)=>{if(!this.pubnub||!this.channel)return[];const a=Math.min(r,e-t);this.pubnub.fetchMessages({channels:[this.channel],count:a,start:null!=i?i:void 0},((e,t)=>{e.error?o(e):n(t)}))})),a=o.channels[this.channel];if(a.sort(((e,t)=>+e.timetoken-+t.timetoken)),!a||0===a.length)break;if(this.channel&&0!==Object.keys(o.channels).length){const e=o.channels[this.channel],t=[];e.forEach((e=>{e.uuid&&t.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})})),n=n.concat(t.filter((e=>e.message.messageType!==_r.noReply)))}if(i=a[0].timetoken,n.length>=e||a.length<r)break}this.rawPubnubMessages=n.slice(0,e),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:!1})}catch(e){this.building&&si({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:ai.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}},kr=(e,t,n)=>{const i=`tel:${e}`,r=`sms:${e}`,o=`whatsapp://send?phone=${e}}`,a=`facetime:${e}`,s=`facetime-audio:${e}`,u=/\(\d{3}\)\s\d{3}-\d{4}/g,l=/(tel|sms):\(\d{3}\)\s\d{3}-\d{4}/g,d=/whatsapp:\/\/send\?phone=\d+/g,c=/(facetime|facetime-audio):\d+/g,p=document.body.getElementsByTagName("*");let h=!1;const f=e.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3");for(let e=0;e<p.length;e++)if(p[e].nodeType===Node.ELEMENT_NODE&&(1===p[e].childNodes.length&&p[e].childNodes[0].nodeType==Node.TEXT_NODE&&(p[e].innerHTML=p[e].innerHTML.replace(u,f),h=!0,si({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",originalPhoneNumber:p[e].innerHTML,newPhoneNumber:f,website:window.location.href},logType:ai.info,buildingSlug:n,orgSlug:t})),p[e].hasAttribute("href"))){const u=p[e].getAttribute("href");if(!u)continue;let h="",m=l;u.startsWith("sms:")?h=r:u.startsWith("whatsapp:")?(h=o,m=d):u.startsWith("facetime:")?(h=a,m=c):u.startsWith("facetime-audio:")?(h=s,m=c):h=i;const g=u.replace(m,h);p[e].setAttribute("href",g),si({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",hrefAttribute:u,originalPhoneNumber:p[e].innerHTML,newPhoneNumber:f,website:window.location.href},logType:ai.info,buildingSlug:n,orgSlug:t})}h||si({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:ai.warn,buildingSlug:n,orgSlug:t})};var Ur=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 qr=class extends re{constructor(){super(...arguments),this.onClick=()=>{},this.brandColor=Me,this.toExpand=!1}render(){return U`
|
|
3002
|
+
`,Zi([ue({attribute:!0})],$i.prototype,"isMinimized",void 0),Zi([ue()],$i.prototype,"mobileStyles",void 0),Zi([ue({type:Boolean})],$i.prototype,"isFirstMount",void 0),Zi([ue({attribute:!1})],$i.prototype,"autoOpenChatWidget",void 0),Zi([ue()],$i.prototype,"phoneNumber",void 0),Zi([ue({attribute:!0})],$i.prototype,"buildingName",void 0),Zi([ue({attribute:!0})],$i.prototype,"chatId",void 0),Zi([ue({attribute:!0})],$i.prototype,"chatCallUsHeader",void 0),Zi([ue({attribute:!1})],$i.prototype,"buildingId",void 0),Zi([ue({attribute:!0})],$i.prototype,"buildingSlug",void 0),Zi([ue({attribute:!0})],$i.prototype,"orgSlug",void 0),Zi([ue({attribute:!0})],$i.prototype,"sgtUrl",void 0),Zi([ue({attribute:!0})],$i.prototype,"designConcept",void 0),Zi([ue({attribute:!0})],$i.prototype,"featureFlagShowDropdown",void 0),Zi([ue({attribute:!1})],$i.prototype,"leadSources",void 0),Zi([ue({attribute:!0})],$i.prototype,"currentLeadSource",void 0),Zi([ue({attribute:!0})],$i.prototype,"escortedToursLink",void 0),Zi([ue({attribute:!0})],$i.prototype,"virtualToursLink",void 0),Zi([ue({type:Boolean})],$i.prototype,"hasCallUsEnabled",void 0),Zi([ue({type:Boolean})],$i.prototype,"hasChatEnabled",void 0),Zi([ue({type:Boolean})],$i.prototype,"hasEmailEnabled",void 0),Zi([ue({type:Boolean})],$i.prototype,"hasSSTEnabled",void 0),Zi([ue({type:Boolean})],$i.prototype,"hasTextUsEnabled",void 0),Zi([ue({attribute:!1})],$i.prototype,"layoutOptions",void 0),Zi([ue({attribute:!1})],$i.prototype,"unitOptions",void 0),Zi([ue({attribute:!1})],$i.prototype,"tourTypeOptions",void 0),Zi([ue({attribute:!0})],$i.prototype,"hasDynamicSchedulingEnabled",void 0),Zi([ue({attribute:!0})],$i.prototype,"onExitChat",void 0),Zi([ue({type:Number})],$i.prototype,"right",void 0),Zi([ue({type:Number})],$i.prototype,"bottom",void 0),Zi([ue({type:Number})],$i.prototype,"top",void 0),Zi([ue({type:Number})],$i.prototype,"left",void 0),Zi([ue({attribute:!0})],$i.prototype,"showTourNextToChat",void 0),Zi([ue({attribute:!1})],$i.prototype,"onChatTapped",void 0),Zi([ue({attribute:!0})],$i.prototype,"onClickMinimize",void 0),Zi([ue({attribute:!1})],$i.prototype,"launcherStyles",void 0),Zi([ue({attribute:!0})],$i.prototype,"brandColor",void 0),Zi([le()],$i.prototype,"isEmailWindowOpen",void 0),Zi([le()],$i.prototype,"isCallUsWindowOpen",void 0),Zi([le()],$i.prototype,"isSSTWindowOpen",void 0),Zi([le()],$i.prototype,"isTextUsWindowOpen",void 0),$i=Zi([ae("meetelise-launcher")],$i);const er=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",$i)};var tr=n(3379),nr=n.n(tr),ir=n(7795),rr=n.n(ir),or=n(569),ar=n.n(or),sr=n(3565),ur=n.n(sr),lr=n(9216),dr=n.n(lr),cr=n(4589),pr=n.n(cr),hr=n(3631),fr={};async function mr(e){try{const n=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/lead-sources`);return n.data?gr(n.data,e):[]}catch(e){return[]}}fr.styleTagTransform=pr(),fr.setAttributes=ur(),fr.insert=ar().bind(null,"head"),fr.domAPI=rr(),fr.insertStyleElement=dr(),nr()(hr.Z,fr),hr.Z&&hr.Z.locals&&hr.Z.locals;const gr=(e,t)=>{let n=[];switch(t){case"d41619ec-0f79-11ee-8439-93855926ad58":n=["Forthea - PPC","HotPads","Forthea","Locator","Website-apartmentguide.com","Forthea - organic search","Tdc employee","University newspaper","Nashville apartment locators","Forthea - paid social","Apartment list","Off campus partners","Waze ads","Athletic event","Website-apartment guide"];break;case"d4160560-0f79-11ee-8438-fba837bf3a46":n=["Forthea - PPC","Rentgrata","Website-ApartmentFinder.com","Word of Mouth","Texas A&M A-Frame on Campus","Rent.com","Website-craigslist","Apartment List","Website-apartments.com","Forthea - paid social","Forthea - organic search","Website-apartmentguide.com","Forthea","Uhomes","Phone book","Property - website"];break;default:n=[]}return e.sort(),e.filter((e=>{const t=e.toLowerCase();return!n.map((e=>e.toLowerCase())).includes(t)}))};var vr,yr=n(9594),br=n.n(yr),wr=new Uint8Array(16);function Sr(){if(!vr&&!(vr="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 vr(wr)}const Tr=/^(?:[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,xr=function(e){return"string"==typeof e&&Tr.test(e)};for(var Ar=[],Or=0;Or<256;++Or)Ar.push((Or+256).toString(16).substr(1));const Cr=function(e,t,n){var i=(e=e||{}).random||(e.rng||Sr)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var r=0;r<16;++r)t[n+r]=i[r];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(Ar[e[t+0]]+Ar[e[t+1]]+Ar[e[t+2]]+Ar[e[t+3]]+"-"+Ar[e[t+4]]+Ar[e[t+5]]+"-"+Ar[e[t+6]]+Ar[e[t+7]]+"-"+Ar[e[t+8]]+Ar[e[t+9]]+"-"+Ar[e[t+10]]+Ar[e[t+11]]+Ar[e[t+12]]+Ar[e[t+13]]+Ar[e[t+14]]+Ar[e[t+15]]).toLowerCase();if(!xr(n))throw TypeError("Stringified UUID is invalid");return n}(i)},Ir=e=>localStorage.removeItem("com.elise.webchat.slug="+e),Nr=(e,t,n)=>{const i=mn(new Date),r=n||`lead_${Cr()}_${e}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:i,initiatedChat:t})),{leadId:r,timestamp:Tn(i),buildingSlug:e,initiatedChat:t}},Er=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(Rr(e,i))return i}catch(e){console.warn("Error getting chat storage key")}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},Rr=(e,t)=>!(t.buildingSlug!==e||!t.leadId||!t.timestamp||dn(t.timestamp,24));var _r;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(_r||(_r={}));const Pr=e=>e.type===Fr.text,Mr=e=>e.type===Fr.media;var Fr;!function(e){e.text="text",e.media="media"}(Fr||(Fr={}));const Dr=class{constructor(e,t,n,i=null,r){this.apiHost="https://app.meetelise.com",this.building=null,this.eliseResponseTimeout=null,this.pubnub=null,this.leadUserId="",this.channel="",this.leadSource=null,this.isCurrentlyStreamingMessage=!1,this.chatListener=null,this.rawPubnubMessages=[],this.simpleChatMessages=[],this.listenerParams={message:e=>{var t;e.message.messageType!==_r.noReply&&(this.rawPubnubMessages=[...this.rawPubnubMessages,{channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken}],this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages));const n="eliseai"!==e.publisher&&"elise_health_ai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:n}),!n&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=n}},this.isLoadingMessages=!1,this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){this.building&&si({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:ai.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.handleDisconnect=()=>{this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.removeChatListeners()},this.removeChatListeners=()=>{this.pubnub&&this.channel&&(this.pubnub.unsubscribe({channels:[this.channel]}),this.pubnub.removeListener(this.listenerParams))},this.sendMessage=async e=>{if(e){if(!this.pubnub){const e=Nr(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken((async()=>{var t,n;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),this.building&&si({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:ai.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}),9e4),await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(t=this.building)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,userId:null===(n=this.building)||void 0===n?void 0:n.userId,leadSource:this.leadSource,isDevState:this.shouldCreateAsDevState()}}))})),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.translatePubnubMessagesIntoSimpleChatMessages=e=>{const t=[],n={};return e.forEach((e=>{var i;"media"===e.message.messageType?t.push({timestamp:e.timetoken,media:null!==(i=e.message.media)&&void 0!==i?i:[],isLeadMessage:this.isLeadMessage(e),type:Fr.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:Fr.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:Fr.text};this.isCurrentlyStreamingMessage=this.isMessageStillStreamingChunks(r),t.push(s)})),t.sort(((e,t)=>e.timestamp-t.timestamp)),t},this.getConsecutiveChunks=e=>{var t,n;const i=e.sort(((e,t)=>{var n,i;return(null!==(n=e.message.order)&&void 0!==n?n:0)-(null!==(i=t.message.order)&&void 0!==i?i:0)})),r=[];let o=null!==(t=i[0].message.order)&&void 0!==t?t:0;for(const e of i){if((null!==(n=e.message.order)&&void 0!==n?n:-1)!==o)break;r.push(e),o++}return r},this.isMessageStillStreamingChunks=e=>{const t=e.find((e=>e.message.is_done));return!t||e.length===t.message.order},this.buildingSlug=e,this.building=t,this.orgSlug=n,this.leadSource=i,this.leadUserId=r,this.channel=`webchat_${r}`}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(br())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,n){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${n}&${this.building?"":"industry=health_care"}`)).data}catch(e){this.building&&si({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:ai.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return null}async fetchChannelExists(e){try{return(await t().get(`${this.apiHost}/platformApi/webchat/check-channel-exists?channel_name=${e}`)).data}catch(e){this.building&&si({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:ai.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(n){if(n instanceof e.AxiosError&&n&&n.response&&403===n.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const e=await this.fetchToken(this.leadUserId,this.channel);if(!e)return;this.pubnub.setAuthKey(e.auth.result.token),await t()}catch(e){this.building&&si({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:ai.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(e=1500){var t;try{let n=[],i=null;const r=100;for(let t=0;t<e;t+=r){const o=await new Promise(((n,o)=>{if(!this.pubnub||!this.channel)return[];const a=Math.min(r,e-t);this.pubnub.fetchMessages({channels:[this.channel],count:a,start:null!=i?i:void 0},((e,t)=>{e.error?o(e):n(t)}))})),a=o.channels[this.channel];if(a.sort(((e,t)=>+e.timetoken-+t.timetoken)),!a||0===a.length)break;if(this.channel&&0!==Object.keys(o.channels).length){const e=o.channels[this.channel],t=[];e.forEach((e=>{e.uuid&&t.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})})),n=n.concat(t.filter((e=>e.message.messageType!==_r.noReply)))}if(i=a[0].timetoken,n.length>=e||a.length<r)break}this.rawPubnubMessages=n.slice(0,e),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:!1})}catch(e){this.building&&si({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:ai.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}shouldCreateAsDevState(){return location.href.startsWith("https://app.meetelise.com/settings/widgets")}},kr=(e,t,n)=>{const i=`tel:${e}`,r=`sms:${e}`,o=`whatsapp://send?phone=${e}}`,a=`facetime:${e}`,s=`facetime-audio:${e}`,u=/\(\d{3}\)\s\d{3}-\d{4}/g,l=/(tel|sms):\(\d{3}\)\s\d{3}-\d{4}/g,d=/whatsapp:\/\/send\?phone=\d+/g,c=/(facetime|facetime-audio):\d+/g,p=document.body.getElementsByTagName("*");let h=!1;const f=e.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3");for(let e=0;e<p.length;e++)if(p[e].nodeType===Node.ELEMENT_NODE&&(1===p[e].childNodes.length&&p[e].childNodes[0].nodeType==Node.TEXT_NODE&&(p[e].innerHTML=p[e].innerHTML.replace(u,f),h=!0,si({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",originalPhoneNumber:p[e].innerHTML,newPhoneNumber:f,website:window.location.href},logType:ai.info,buildingSlug:n,orgSlug:t})),p[e].hasAttribute("href"))){const u=p[e].getAttribute("href");if(!u)continue;let h="",m=l;u.startsWith("sms:")?h=r:u.startsWith("whatsapp:")?(h=o,m=d):u.startsWith("facetime:")?(h=a,m=c):u.startsWith("facetime-audio:")?(h=s,m=c):h=i;const g=u.replace(m,h);p[e].setAttribute("href",g),si({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",hrefAttribute:u,originalPhoneNumber:p[e].innerHTML,newPhoneNumber:f,website:window.location.href},logType:ai.info,buildingSlug:n,orgSlug:t})}h||si({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:ai.warn,buildingSlug:n,orgSlug:t})};var Ur=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 qr=class extends re{constructor(){super(...arguments),this.onClick=()=>{},this.brandColor=Me,this.toExpand=!1}render(){return U`
|
|
3003
3003
|
<div
|
|
3004
3004
|
class=${this.toExpand?"button-container mini":"button-container"}
|
|
3005
3005
|
@click=${this.onClick}
|
|
@@ -3558,7 +3558,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
3558
3558
|
bottom: -2px;
|
|
3559
3559
|
right: -2px;
|
|
3560
3560
|
}
|
|
3561
|
-
`],Hr([ue({attribute:!0})],Gr.prototype,"message",void 0),Hr([ue({attribute:!0})],Gr.prototype,"myPubnub",void 0),Hr([ue({attribute:!0})],Gr.prototype,"onMount",void 0),Hr([le()],Gr.prototype,"loadingPreviews",void 0),Hr([le()],Gr.prototype,"parsedMessage",void 0),Hr([le()],Gr.prototype,"websitePreviewInfo",void 0),Hr([le()],Gr.prototype,"imagesToDisplay",void 0),Hr([le()],Gr.prototype,"imageUrlError",void 0),Gr=Hr([ae("pubnub-message")],Gr);var zr=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 Wr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.showMediaAsCarousel=!0,this.activeIndex=0}updated(e){this.onMount(),e.has("message")}
|
|
3561
|
+
`],Hr([ue({attribute:!0})],Gr.prototype,"message",void 0),Hr([ue({attribute:!0})],Gr.prototype,"myPubnub",void 0),Hr([ue({attribute:!0})],Gr.prototype,"onMount",void 0),Hr([le()],Gr.prototype,"loadingPreviews",void 0),Hr([le()],Gr.prototype,"parsedMessage",void 0),Hr([le()],Gr.prototype,"websitePreviewInfo",void 0),Hr([le()],Gr.prototype,"imagesToDisplay",void 0),Hr([le()],Gr.prototype,"imageUrlError",void 0),Gr=Hr([ae("pubnub-message")],Gr);var zr=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 Wr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.showMediaAsCarousel=!0,this.activeIndex=0}updated(e){this.onMount(),e.has("message")}prevImage(){this.message&&(0===this.activeIndex?this.activeIndex=this.message.media.length-1:this.activeIndex-=1)}nextImage(){this.message&&(this.activeIndex===this.message.media.length-1?this.activeIndex=0:this.activeIndex+=1)}render(){return this.message?this.showMediaAsCarousel?U`<div class="message-inner-body">
|
|
3562
3562
|
<div class="carousel">
|
|
3563
3563
|
<div
|
|
3564
3564
|
class="image-container"
|
|
@@ -3602,7 +3602,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
3602
3602
|
</div>`:U``}};Wr.styles=[pn,Jr,u`
|
|
3603
3603
|
.carousel {
|
|
3604
3604
|
position: relative;
|
|
3605
|
-
max-width:
|
|
3605
|
+
max-width: 400px;
|
|
3606
3606
|
height: max-content;
|
|
3607
3607
|
min-height: 140px;
|
|
3608
3608
|
margin: auto;
|
package/src/MyPubnub.ts
CHANGED
|
@@ -452,12 +452,19 @@ class MyPubnub {
|
|
|
452
452
|
buildingSlug: this.buildingSlug,
|
|
453
453
|
userId: this.building?.userId, // this userid is actually the AI user!
|
|
454
454
|
leadSource: this.leadSource,
|
|
455
|
+
isDevState: this.shouldCreateAsDevState(),
|
|
455
456
|
},
|
|
456
457
|
});
|
|
457
458
|
});
|
|
458
459
|
if (this.isLoadingMessages === false) this.isLoadingMessages = true;
|
|
459
460
|
}
|
|
460
461
|
};
|
|
462
|
+
private shouldCreateAsDevState(): boolean {
|
|
463
|
+
return location.href.startsWith(
|
|
464
|
+
"https://app.meetelise.com/settings/widgets"
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
|
|
461
468
|
isLeadMessage = (message: RawPubnubMessage): boolean =>
|
|
462
469
|
message.publisher.includes("lead_") &&
|
|
463
470
|
message.message.customType === "lead_message";
|
|
@@ -13,7 +13,7 @@ export class PubnubMedia extends LitElement {
|
|
|
13
13
|
css`
|
|
14
14
|
.carousel {
|
|
15
15
|
position: relative;
|
|
16
|
-
max-width:
|
|
16
|
+
max-width: 400px;
|
|
17
17
|
height: max-content;
|
|
18
18
|
min-height: 140px;
|
|
19
19
|
margin: auto;
|
|
@@ -121,16 +121,6 @@ export class PubnubMedia extends LitElement {
|
|
|
121
121
|
if (!changedProperties.has("message")) return;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
firstUpdated(): void {
|
|
125
|
-
document.addEventListener("keydown", (e) => {
|
|
126
|
-
if (e.key === "ArrowLeft") {
|
|
127
|
-
this.prevImage();
|
|
128
|
-
} else if (e.key === "ArrowRight") {
|
|
129
|
-
this.nextImage();
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
124
|
@state()
|
|
135
125
|
showMediaAsCarousel = true;
|
|
136
126
|
|