@meetelise/chat 1.22.49 → 1.22.50
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
|
@@ -4499,7 +4499,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
4499
4499
|
I agree
|
|
4500
4500
|
</button>
|
|
4501
4501
|
</div>
|
|
4502
|
-
`;var xo=function(e,t,i,n){var r,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,i,a):r(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a};let Ao=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.brandColor=null,this.backgroundColor=null,this.chatId="",this.analytics=null,this.launcher=null,this.building=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=Xi.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.showTourNextToChat=!1,this.displayPubnubChat=!1,this.myPubnub=null,this.LeadSourceClient=null,this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.overrideRentgrata=!1,this.widgetType=Uo.Default,this.onWidgetLoaded=pr(),this.onSstClose=pr(),this.enabledChatWidgets={callDesktop:!0,callMobile:!0,chatMobile:!0,chatDesktop:!0,emailDesktop:!0,emailMobile:!0,textDesktop:!0,textMobile:!0,sstDesktop:!0,sstMobile:!0},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.hideMobileFeatures=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.launcherRef=xe(),this.firstUpdated=async()=>this.setupWebchat(),this.setupWebchat=async()=>{if(!this.buildingSlug||!this.orgSlug)return;const e=await Tn(this.orgSlug,this.buildingSlug);if(Math.random()<.2)try{(async(e,i)=>{const n=window.rentgrata;if(!n)return;const r=n.Widget;if(!r)return;const o=r.config;if(!o)return;const a=o.widgetKey;a&&await t().post(`https://app.meetelise.com/platformApi/webchat/rentgrata?token=${a}`,{},{headers:{"Content-Type":"application/json","building-slug":null!=e?e:"","org-slug":null!=i?i:""}})})(this.buildingSlug,this.orgSlug)}catch(e){console.warn("Error updating rentgrata token",e)}await async function(e){if(!e)return!1;try{return(await t().get(Ki(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-leasing-in-maintenance-mode",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(this.buildingSlug)?console.warn("MeetElise Chat is in leasing maintenance mode. Chat icon will not appear."):1===e.active?72036!==e.id?(this.building=e,await this.initializeChatVariables(),await this.handleChatInitializeAnalytics(),await this.setBuildingDerivedInfo(),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(this.webchatConfigHasAutoOpenChat)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1,"true"===localStorage.getItem("isChatOpen")&&(this.hideLauncher=!0,this.displayPubnubChat=!0)):console.warn("MeetElise has detected this building is NOT active (custom). Chat icon will not appear."):console.warn("MeetElise has detected this building is NOT active. Chat icon will not appear.")},this.setBuildingDerivedInfo=async()=>{var e,i,n,r,o,a,s,l,u,d,c,p,h,f,m,g,v,y,b,w,S,T,x,A,C,O,I,N,E,R,_,P,M,F,D;const k=this.building;if(!k)return;k&&this.orgSlug&&Oo(this.orgSlug,this.buildingSlug,null!==(i=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.leadSource)&&void 0!==i?i:null);const[U,L,B,q,J,j,H]=await Promise.all([In(this.buildingSlug),_r(this.orgSlug,this.buildingSlug),$i(this.buildingSlug),Yi(this.buildingSlug),On(k.id),Zi(this.buildingSlug),en(this.buildingSlug)]);this.building&&(this.building.phoneNumber=Ne(k.phoneNumber)),this.designConcept=null!==(n=null==U?void 0:U.abTestType)&&void 0!==n?n:"",this.leadSources=L,this.featureFlagShowDropdown=B;const G=k.textWithUsPhoneNumber?k.textWithUsPhoneNumber:await(async e=>{try{const i="https://app.meetelise.com",n=await t().get(`${i}/platformApi/webchat/${e}/phone-number`);if(n.data)return n.data}catch(t){return dn({logType:un.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var z,W;this.enabledChatWidgets={callDesktop:!(null===(r=null==J?void 0:J.config.shouldShowPhone)||void 0===r||!r)||null!==(o=null==J?void 0:J.config.shouldShowPhoneDesktop)&&void 0!==o&&o,callMobile:!(null===(a=null==J?void 0:J.config.shouldShowPhone)||void 0===a||!a)||null!==(s=null==J?void 0:J.config.shouldShowPhoneMobile)&&void 0!==s&&s,chatDesktop:!(null===(l=null==J?void 0:J.config.shouldShowChat)||void 0===l||!l)||null!==(u=null==J?void 0:J.config.shouldShowChatDesktop)&&void 0!==u&&u,chatMobile:!(null===(d=null==J?void 0:J.config.shouldShowChat)||void 0===d||!d)||null!==(c=null==J?void 0:J.config.shouldShowChatMobile)&&void 0!==c&&c,emailDesktop:!(null===(p=null==J?void 0:J.config.shouldShowEmail)||void 0===p||!p)||null!==(h=null==J?void 0:J.config.shouldShowEmailDesktop)&&void 0!==h&&h,emailMobile:!(null===(f=null==J?void 0:J.config.shouldShowEmail)||void 0===f||!f)||null!==(m=null==J?void 0:J.config.shouldShowEmailMobile)&&void 0!==m&&m,textDesktop:(!(null===(g=null==J?void 0:J.config.shouldShowText)||void 0===g||!g)||null!==(v=null==J?void 0:J.config.shouldShowTextDesktop)&&void 0!==v&&v)&&!!G,textMobile:(!(null===(y=null==J?void 0:J.config.shouldShowText)||void 0===y||!y)||null!==(b=null==J?void 0:J.config.shouldShowTextMobile)&&void 0!==b&&b)&&!!G,sstDesktop:!(null===(w=null==J?void 0:J.config.shouldShowSst)||void 0===w||!w)||null!==(S=null==J?void 0:J.config.shouldShowSstDesktop)&&void 0!==S&&S,sstMobile:!(null===(T=null==J?void 0:J.config.shouldShowSst)||void 0===T||!T)||null!==(x=null==J?void 0:J.config.shouldShowSstMobile)&&void 0!==x&&x},this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile||"radco"===this.orgSlug?(W=this.handleTourClicked,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");t&&t.startsWith("https://app.meetelise.com/")&&e.addEventListener("click",(e=>{e.preventDefault(),W(e)}))})),H&&(e=>{document.querySelectorAll('a[href$="schedule-a-tour"]').forEach((t=>{t&&t.addEventListener("click",(t=>{t.preventDefault(),e(t)}))}))})(this.handleTourClicked),"radco"===this.orgSlug&&(e=>{document.querySelectorAll('a[href^="#leaseleads-tour-open"]').forEach((t=>{var i;if(!t)return;const n=document.createElement("a");n.innerHTML=t.innerHTML,n.style.cursor="pointer",n.addEventListener("click",(t=>{t.preventDefault(),e(t)})),null===(i=t.parentNode)||void 0===i||i.replaceChild(n,t)}))})(this.handleTourClicked)):(null===(A=this.LeadSourceClient)||void 0===A?void 0:A.leadSource)&&(z=null!==(O=null===(C=this.LeadSourceClient)||void 0===C?void 0:C.leadSource)&&void 0!==O?O:null,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");if(t&&t.startsWith("https://app.meetelise.com/")){const i=t.includes("?")?"&":"?";e.setAttribute("href",t+i+`eliseParsedLeadSource=${encodeURIComponent(z)}`)}}))),J&&J.config&&(this.brandColor=null!==(I=J.config.primaryColor)&&void 0!==I?I:null,this.backgroundColor=null!==(N=J.config.backgroundColor)&&void 0!==N?N:null,this.webchatConfigHasAutoOpenChat=J.config.autoOpenChat,this.requiresConsent=J.config.requiresConsent,this.hideMobileFeatures=J.config.hideMobileFeatures,this.privacyPolicyUrl=null!==(E=J.config.privacyPolicyUrl)&&void 0!==E?E:this.privacyPolicyUrl,J.config.displayStyle===An.MINIMIZED&&(this.isMinimized=!0),J.config.displayStyle===An.PILLS&&(this.designConcept=null),J.config.displayStyle===An.EMOJI&&(this.designConcept=An.EMOJI),this.onWidgetLoaded()),null===this.brandColor&&(this.brandColor=Me),null===this.backgroundColor&&(this.backgroundColor=Fe);const V=null!==(_=null===(R=this.building)||void 0===R?void 0:R.phoneNumber)&&void 0!==_?_:"";let Q=null;q&&(Q=await async function(e,i){try{const n=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${i}`);return n.data?{number:Ne(n.data.number),isMatch:n.data.match,isPropertyWebsiteCatchall:n.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(M=null===(P=this.LeadSourceClient)||void 0===P?void 0:P.leadSource)&&void 0!==M?M:null),Q&&!Q.isMatch&&(Q.number=V)),j&&(null==Q?void 0:Q.number)&&Yr(Q.number,this.orgSlug,this.buildingSlug);const K=localStorage.getItem("eliseai_phone_number_devtest");K&&(console.info("Using dev test phone number: ",K),Yr(K,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=Q||{number:V,isMatch:!1,isPropertyWebsiteCatchall:!0};const X=null!==(D=null===(F=this.LeadSourceClient)||void 0===F?void 0:F.leadSource)&&void 0!==D?D:null;X&&(this.leadSources.includes(X)||this.leadSources.push(X)),qi(k.id)},this.initializeChatVariables=async()=>{var e,i,n,r,o,a,s,l;if(!this.building)return;const u=zr(this.buildingSlug),d=Wr(this.buildingSlug,u)?u:Gr(this.buildingSlug,!1);if(!d.leadId)throw new Error("Lead ID is null");this.LeadSourceClient=new class{constructor(){this.chatId=null,this.apiHost="https://app.meetelise.com",this.leadSource=null,this.localStorageTTLDays=30,this.buildingId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,i,n,r)=>{const o=cn();if(this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:o,referrer:document.referrer,parsedUtmSource:o?o.utm_source:null,campaignSources:Object.values(ln()).filter((e=>e))},n)return;if(!r){const t=this.getLeadSourceBodyIfValid(e);if(t&&!pi(t.timestamp,24*this.localStorageTTLDays))return{...t,timestamp:Ci(t.timestamp)}}const a={leadSource:t,leadId:i,buildingSlug:e,timestamp:yi(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(a)),{...a,timestamp:Ci(a.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const i=JSON.parse(t);if(i.buildingSlug===e&&i.leadSource&&i.leadId&&i.timestamp&&!pi(Ci(i.timestamp),24*this.localStorageTTLDays)){try{this.leadSourceInput=i.leadSourceInput}catch(e){console.error("Error parsing leadSourceInput from localStorage")}return i}}catch(e){return null}return null}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:i,referrer:n,campaignSources:r}){try{return(await t().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,{query_params:i,building_slug:e,referrer:n,campaign_sources:r})).data}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:i}){var n,r,o,a,s,l,u;try{if(!this.chatId)return console.error("chatId is not set"),null;if(!this.orgSlug)return console.error("orgId is not set"),null;let d=null,c=null;try{if("f1ba5a20-d207-4e5a-879e-65199e7d0a53"===this.orgSlug){const e=await this.getCookieValue("_ga");e&&(d=e),c=null===(n=window.dataLayer.find((e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)})))||void 0===n?void 0:n.value}}catch(e){console.error("error getting cookie")}return await t().post(`${this.apiHost}/platformApi/webchat/log/lead-source`,{chat_id:this.chatId,webchat_action:e,state_id:i,building_id:this.buildingId,org_slug:this.orgSlug,building_slug:this.buildingSlug,website_origin:null===(r=this.leadSourceInput)||void 0===r?void 0:r.websiteOrigin,website_search:null===(o=this.leadSourceInput)||void 0===o?void 0:o.websiteSearch,query_parameters:null===(a=this.leadSourceInput)||void 0===a?void 0:a.queryParameters,referrer:null===(s=this.leadSourceInput)||void 0===s?void 0:s.referrer,parsed_utm_source:null===(l=this.leadSourceInput)||void 0===l?void 0:l.parsedUtmSource,campaign_sources:null===(u=this.leadSourceInput)||void 0===u?void 0:u.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:fn()(d)?null:d,extras:null!=c?c:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let i=0;i<t.length;i++){const n=t[i].trim();if(n.startsWith(e+"="))return n.substring((e+"=").length,-1===n.indexOf(";")?void 0:n.indexOf(";"))}return null}catch(e){console.error("error getting cookie value")}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:i}){try{const n={queryParams:cn(),buildingSlug:i,referrer:document.referrer,campaignSources:ln()};let r=!1;const o=i?this.getLeadSourceBodyIfValid(i):null;if(o){if(!["test-company","daf00bd2-1ecb-482c-b6f4-e1c5511a01be"].includes(t))return this.leadSource=o.leadSource,this.leadSource;{const e=await this.fetchCurrentParsedLeadSource(n);if(!e)return this.leadSource=o.leadSource,this.leadSource;this.leadSource=e,r=!0}}const a=await this.fetchCurrentParsedLeadSource(n);if(this.leadSource=a,this.buildingId=null,this.orgSlug=t,this.buildingSlug=i,i&&!a){const e=this.getLeadSourceBodyIfValid(i);if(e)return this.leadSource=e.leadSource,this.leadSource}if(i){const t=!!a&&a.length>0;this.updateLeadSourceLocalStorage(i,a,e,!t&&!r,r)}return a}catch(e){console.error(e)}return null}},this.myPubnub=new $r(this.buildingSlug,this.building,this.orgSlug,null,d.leadId,this.LeadSourceClient,this.widgetType),this.LeadSourceClient.chatId=this.myPubnub.channel,await(null===(e=this.LeadSourceClient)||void 0===e?void 0:e.generateUserLeadSource({leadId:null!==(n=null===(i=this.myPubnub)||void 0===i?void 0:i.leadUserId)&&void 0!==n?n:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug})),console.log("EliseAI Mapped Lead Source source: ",null===(r=this.LeadSourceClient)||void 0===r?void 0:r.leadSource),"property-website"!==mn(this.orgSlug)?this.myPubnub.leadSource=null!==(a=null===(o=this.LeadSourceClient)||void 0===o?void 0:o.leadSource)&&void 0!==a?a:mn(this.orgSlug):this.myPubnub.leadSource=null!==(l=null===(s=this.LeadSourceClient)||void 0===s?void 0:s.leadSource)&&void 0!==l?l:null,d.initiatedChat&&await this.myPubnub.initializePubnub(u)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),i=!t||!(t&&!xi(Ci(t)));return!!e&&!!i&&!ci()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",yi(function(e,t){Be(2,arguments);var i=it(t);return nt(e,6e4*i)}(new Date,15)))},this.handleContactClicked=e=>{var t;this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickEmailOption(e)},this.handleTourClicked=e=>{var t,i;this.showTourNextToChat?null===(t=this.launcherRef.value)||void 0===t||t.onClickSSTOption(e):(this.hideLauncher?this.showTourNextToChat=!0:this.displayPubnubChat=!1,this.hideLauncher=!1,null===(i=this.launcherRef.value)||void 0===i||i.onClickSSTOption(e))},this.handleContactTabClicked=e=>{var t;this.displayPubnubChat=!1,this.showTourNextToChat=!1,this.hideLauncher=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickPhoneOption(e)},this.adjustPositionChatAdditionalActions=()=>{var e,t,i,n;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!r)return;const o=null===(n=null===(i=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===i?void 0:i.shadowRoot)||void 0===n?void 0:n.getElementById("pubnub-chat-container"),a=null==o?void 0:o.getBoundingClientRect();a&&(r.style.left=`${a.left}px`,r.style.top=`${a.bottom}px`)},this.handleKeydownTab=e=>{var t,i,n,r,o,a,s,l,u,d,c,p,h,f,m,g,v,y,b,w;if("Tab"===e.key){const S=this.displayPubnubChat?null===(n=null===(i=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===i?void 0:i.shadowRoot)||void 0===n?void 0:n.getElementById("pubnub-chat-container"):null!==(m=null!==(u=null===(l=null===(s=null===(a=null===(o=null===(r=this.shadowRoot)||void 0===r?void 0:r.getElementById("meetelise-launcher"))||void 0===o?void 0:o.shadowRoot)||void 0===a?void 0:a.getElementById("email-us-window"))||void 0===s?void 0:s.shadowRoot)||void 0===l?void 0:l.getElementById("email-us-form"))&&void 0!==u?u:null===(f=null===(h=null===(p=null===(c=null===(d=this.shadowRoot)||void 0===d?void 0:d.getElementById("meetelise-launcher"))||void 0===c?void 0:c.shadowRoot)||void 0===p?void 0:p.getElementById("tour-scheduler-window"))||void 0===h?void 0:h.shadowRoot)||void 0===f?void 0:f.getElementById("scheduler-container"))&&void 0!==m?m:null===(w=null===(b=null===(y=null===(v=null===(g=this.shadowRoot)||void 0===g?void 0:g.getElementById("meetelise-launcher"))||void 0===v?void 0:v.shadowRoot)||void 0===y?void 0:y.getElementById("call-us-window"))||void 0===b?void 0:b.shadowRoot)||void 0===w?void 0:w.getElementById("details-window");if(!S)return;e.preventDefault();const T=S.querySelectorAll("input, me-select, textarea, action-confirm-button, [tabindex]"),x=Array.from(T),A=x.findIndex((e=>e.matches(":focus")));x[(A+1)%x.length].focus()}},this.onClickMinimize=e=>{e.preventDefault(),e.stopPropagation(),this.isMinimized=!this.isMinimized,this.showTourNextToChat=!1},this.attachOnClickToLauncher=()=>{const e=this.launcherRef.value;e&&(e.onChatTapped=async()=>{this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,localStorage.setItem("isChatOpen","true")},e.onExitChat=this.onExitChat)},this.onExitChat=()=>{this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,localStorage.setItem("isChatOpen","false")},this.renderChatAdditionalActions=(e,t)=>{const i=this.building&&ke(this.building.orgId,this.building.id)&&this.brandColor&&this.brandColor!==Me?De(this.brandColor,.6):"black";return U` <style>
|
|
4502
|
+
`;var xo=function(e,t,i,n){var r,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,i,a):r(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a};let Ao=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.brandColor=null,this.backgroundColor=null,this.chatId="",this.analytics=null,this.launcher=null,this.building=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=Xi.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.showTourNextToChat=!1,this.displayPubnubChat=!1,this.myPubnub=null,this.LeadSourceClient=null,this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.overrideRentgrata=!1,this.widgetType=Uo.Default,this.onWidgetLoaded=pr(),this.onSstClose=pr(),this.enabledChatWidgets={callDesktop:!0,callMobile:!0,chatMobile:!0,chatDesktop:!0,emailDesktop:!0,emailMobile:!0,textDesktop:!0,textMobile:!0,sstDesktop:!0,sstMobile:!0},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.hideMobileFeatures=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.launcherRef=xe(),this.firstUpdated=async()=>this.setupWebchat(),this.setupWebchat=async()=>{if(!this.buildingSlug||!this.orgSlug)return;const e=await Tn(this.orgSlug,this.buildingSlug);if(Math.random()<.2)try{(async(e,i)=>{const n=window.rentgrata;if(!n)return;const r=n.Widget;if(!r)return;const o=r.config;if(!o)return;const a=o.widgetKey;a&&await t().post(`https://app.meetelise.com/platformApi/webchat/rentgrata?token=${a}`,{},{headers:{"Content-Type":"application/json","building-slug":null!=e?e:"","org-slug":null!=i?i:""}})})(this.buildingSlug,this.orgSlug)}catch(e){console.warn("Error updating rentgrata token",e)}await async function(e){if(!e)return!1;try{return(await t().get(Ki(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-leasing-in-maintenance-mode",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(this.buildingSlug)?console.warn("MeetElise Chat is in leasing maintenance mode. Chat icon will not appear."):1===e.active?(this.building=e,await this.initializeChatVariables(),await this.handleChatInitializeAnalytics(),await this.setBuildingDerivedInfo(),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(this.webchatConfigHasAutoOpenChat)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1,"true"===localStorage.getItem("isChatOpen")&&(this.hideLauncher=!0,this.displayPubnubChat=!0)):console.warn("MeetElise has detected this building is NOT active. Chat icon will not appear.")},this.setBuildingDerivedInfo=async()=>{var e,i,n,r,o,a,s,l,u,d,c,p,h,f,m,g,v,y,b,w,S,T,x,A,C,O,I,N,E,R,_,P,M,F,D;const k=this.building;if(!k)return;k&&this.orgSlug&&Oo(this.orgSlug,this.buildingSlug,null!==(i=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.leadSource)&&void 0!==i?i:null);const[U,L,B,q,J,j,H]=await Promise.all([In(this.buildingSlug),_r(this.orgSlug,this.buildingSlug),$i(this.buildingSlug),Yi(this.buildingSlug),On(k.id),Zi(this.buildingSlug),en(this.buildingSlug)]);this.building&&(this.building.phoneNumber=Ne(k.phoneNumber)),this.designConcept=null!==(n=null==U?void 0:U.abTestType)&&void 0!==n?n:"",this.leadSources=L,this.featureFlagShowDropdown=B;const G=k.textWithUsPhoneNumber?k.textWithUsPhoneNumber:await(async e=>{try{const i="https://app.meetelise.com",n=await t().get(`${i}/platformApi/webchat/${e}/phone-number`);if(n.data)return n.data}catch(t){return dn({logType:un.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var z,W;this.enabledChatWidgets={callDesktop:!(null===(r=null==J?void 0:J.config.shouldShowPhone)||void 0===r||!r)||null!==(o=null==J?void 0:J.config.shouldShowPhoneDesktop)&&void 0!==o&&o,callMobile:!(null===(a=null==J?void 0:J.config.shouldShowPhone)||void 0===a||!a)||null!==(s=null==J?void 0:J.config.shouldShowPhoneMobile)&&void 0!==s&&s,chatDesktop:!(null===(l=null==J?void 0:J.config.shouldShowChat)||void 0===l||!l)||null!==(u=null==J?void 0:J.config.shouldShowChatDesktop)&&void 0!==u&&u,chatMobile:!(null===(d=null==J?void 0:J.config.shouldShowChat)||void 0===d||!d)||null!==(c=null==J?void 0:J.config.shouldShowChatMobile)&&void 0!==c&&c,emailDesktop:!(null===(p=null==J?void 0:J.config.shouldShowEmail)||void 0===p||!p)||null!==(h=null==J?void 0:J.config.shouldShowEmailDesktop)&&void 0!==h&&h,emailMobile:!(null===(f=null==J?void 0:J.config.shouldShowEmail)||void 0===f||!f)||null!==(m=null==J?void 0:J.config.shouldShowEmailMobile)&&void 0!==m&&m,textDesktop:(!(null===(g=null==J?void 0:J.config.shouldShowText)||void 0===g||!g)||null!==(v=null==J?void 0:J.config.shouldShowTextDesktop)&&void 0!==v&&v)&&!!G,textMobile:(!(null===(y=null==J?void 0:J.config.shouldShowText)||void 0===y||!y)||null!==(b=null==J?void 0:J.config.shouldShowTextMobile)&&void 0!==b&&b)&&!!G,sstDesktop:!(null===(w=null==J?void 0:J.config.shouldShowSst)||void 0===w||!w)||null!==(S=null==J?void 0:J.config.shouldShowSstDesktop)&&void 0!==S&&S,sstMobile:!(null===(T=null==J?void 0:J.config.shouldShowSst)||void 0===T||!T)||null!==(x=null==J?void 0:J.config.shouldShowSstMobile)&&void 0!==x&&x},this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile||"radco"===this.orgSlug?(W=this.handleTourClicked,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");t&&t.startsWith("https://app.meetelise.com/")&&e.addEventListener("click",(e=>{e.preventDefault(),W(e)}))})),H&&(e=>{document.querySelectorAll('a[href$="schedule-a-tour"]').forEach((t=>{t&&t.addEventListener("click",(t=>{t.preventDefault(),e(t)}))}))})(this.handleTourClicked),"radco"===this.orgSlug&&(e=>{document.querySelectorAll('a[href^="#leaseleads-tour-open"]').forEach((t=>{var i;if(!t)return;const n=document.createElement("a");n.innerHTML=t.innerHTML,n.style.cursor="pointer",n.addEventListener("click",(t=>{t.preventDefault(),e(t)})),null===(i=t.parentNode)||void 0===i||i.replaceChild(n,t)}))})(this.handleTourClicked)):(null===(A=this.LeadSourceClient)||void 0===A?void 0:A.leadSource)&&(z=null!==(O=null===(C=this.LeadSourceClient)||void 0===C?void 0:C.leadSource)&&void 0!==O?O:null,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");if(t&&t.startsWith("https://app.meetelise.com/")){const i=t.includes("?")?"&":"?";e.setAttribute("href",t+i+`eliseParsedLeadSource=${encodeURIComponent(z)}`)}}))),J&&J.config&&(this.brandColor=null!==(I=J.config.primaryColor)&&void 0!==I?I:null,this.backgroundColor=null!==(N=J.config.backgroundColor)&&void 0!==N?N:null,this.webchatConfigHasAutoOpenChat=J.config.autoOpenChat,this.requiresConsent=J.config.requiresConsent,this.hideMobileFeatures=J.config.hideMobileFeatures,this.privacyPolicyUrl=null!==(E=J.config.privacyPolicyUrl)&&void 0!==E?E:this.privacyPolicyUrl,J.config.displayStyle===An.MINIMIZED&&(this.isMinimized=!0),J.config.displayStyle===An.PILLS&&(this.designConcept=null),J.config.displayStyle===An.EMOJI&&(this.designConcept=An.EMOJI),this.onWidgetLoaded()),null===this.brandColor&&(this.brandColor=Me),null===this.backgroundColor&&(this.backgroundColor=Fe);const V=null!==(_=null===(R=this.building)||void 0===R?void 0:R.phoneNumber)&&void 0!==_?_:"";let Q=null;q&&(Q=await async function(e,i){try{const n=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${i}`);return n.data?{number:Ne(n.data.number),isMatch:n.data.match,isPropertyWebsiteCatchall:n.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(M=null===(P=this.LeadSourceClient)||void 0===P?void 0:P.leadSource)&&void 0!==M?M:null),Q&&!Q.isMatch&&(Q.number=V)),j&&(null==Q?void 0:Q.number)&&Yr(Q.number,this.orgSlug,this.buildingSlug);const K=localStorage.getItem("eliseai_phone_number_devtest");K&&(console.info("Using dev test phone number: ",K),Yr(K,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=Q||{number:V,isMatch:!1,isPropertyWebsiteCatchall:!0};const X=null!==(D=null===(F=this.LeadSourceClient)||void 0===F?void 0:F.leadSource)&&void 0!==D?D:null;X&&(this.leadSources.includes(X)||this.leadSources.push(X)),qi(k.id)},this.initializeChatVariables=async()=>{var e,i,n,r,o,a,s,l;if(!this.building)return;const u=zr(this.buildingSlug),d=Wr(this.buildingSlug,u)?u:Gr(this.buildingSlug,!1);if(!d.leadId)throw new Error("Lead ID is null");this.LeadSourceClient=new class{constructor(){this.chatId=null,this.apiHost="https://app.meetelise.com",this.leadSource=null,this.localStorageTTLDays=30,this.buildingId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,i,n,r)=>{const o=cn();if(this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:o,referrer:document.referrer,parsedUtmSource:o?o.utm_source:null,campaignSources:Object.values(ln()).filter((e=>e))},n)return;if(!r){const t=this.getLeadSourceBodyIfValid(e);if(t&&!pi(t.timestamp,24*this.localStorageTTLDays))return{...t,timestamp:Ci(t.timestamp)}}const a={leadSource:t,leadId:i,buildingSlug:e,timestamp:yi(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(a)),{...a,timestamp:Ci(a.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const i=JSON.parse(t);if(i.buildingSlug===e&&i.leadSource&&i.leadId&&i.timestamp&&!pi(Ci(i.timestamp),24*this.localStorageTTLDays)){try{this.leadSourceInput=i.leadSourceInput}catch(e){console.error("Error parsing leadSourceInput from localStorage")}return i}}catch(e){return null}return null}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:i,referrer:n,campaignSources:r}){try{return(await t().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,{query_params:i,building_slug:e,referrer:n,campaign_sources:r})).data}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:i}){var n,r,o,a,s,l,u;try{if(!this.chatId)return console.error("chatId is not set"),null;if(!this.orgSlug)return console.error("orgId is not set"),null;let d=null,c=null;try{if("f1ba5a20-d207-4e5a-879e-65199e7d0a53"===this.orgSlug){const e=await this.getCookieValue("_ga");e&&(d=e),c=null===(n=window.dataLayer.find((e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)})))||void 0===n?void 0:n.value}}catch(e){console.error("error getting cookie")}return await t().post(`${this.apiHost}/platformApi/webchat/log/lead-source`,{chat_id:this.chatId,webchat_action:e,state_id:i,building_id:this.buildingId,org_slug:this.orgSlug,building_slug:this.buildingSlug,website_origin:null===(r=this.leadSourceInput)||void 0===r?void 0:r.websiteOrigin,website_search:null===(o=this.leadSourceInput)||void 0===o?void 0:o.websiteSearch,query_parameters:null===(a=this.leadSourceInput)||void 0===a?void 0:a.queryParameters,referrer:null===(s=this.leadSourceInput)||void 0===s?void 0:s.referrer,parsed_utm_source:null===(l=this.leadSourceInput)||void 0===l?void 0:l.parsedUtmSource,campaign_sources:null===(u=this.leadSourceInput)||void 0===u?void 0:u.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:fn()(d)?null:d,extras:null!=c?c:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let i=0;i<t.length;i++){const n=t[i].trim();if(n.startsWith(e+"="))return n.substring((e+"=").length,-1===n.indexOf(";")?void 0:n.indexOf(";"))}return null}catch(e){console.error("error getting cookie value")}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:i}){try{const n={queryParams:cn(),buildingSlug:i,referrer:document.referrer,campaignSources:ln()};let r=!1;const o=i?this.getLeadSourceBodyIfValid(i):null;if(o){if(!["test-company","daf00bd2-1ecb-482c-b6f4-e1c5511a01be"].includes(t))return this.leadSource=o.leadSource,this.leadSource;{const e=await this.fetchCurrentParsedLeadSource(n);if(!e)return this.leadSource=o.leadSource,this.leadSource;this.leadSource=e,r=!0}}const a=await this.fetchCurrentParsedLeadSource(n);if(this.leadSource=a,this.buildingId=null,this.orgSlug=t,this.buildingSlug=i,i&&!a){const e=this.getLeadSourceBodyIfValid(i);if(e)return this.leadSource=e.leadSource,this.leadSource}if(i){const t=!!a&&a.length>0;this.updateLeadSourceLocalStorage(i,a,e,!t&&!r,r)}return a}catch(e){console.error(e)}return null}},this.myPubnub=new $r(this.buildingSlug,this.building,this.orgSlug,null,d.leadId,this.LeadSourceClient,this.widgetType),this.LeadSourceClient.chatId=this.myPubnub.channel,await(null===(e=this.LeadSourceClient)||void 0===e?void 0:e.generateUserLeadSource({leadId:null!==(n=null===(i=this.myPubnub)||void 0===i?void 0:i.leadUserId)&&void 0!==n?n:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug})),console.log("EliseAI Mapped Lead Source source: ",null===(r=this.LeadSourceClient)||void 0===r?void 0:r.leadSource),"property-website"!==mn(this.orgSlug)?this.myPubnub.leadSource=null!==(a=null===(o=this.LeadSourceClient)||void 0===o?void 0:o.leadSource)&&void 0!==a?a:mn(this.orgSlug):this.myPubnub.leadSource=null!==(l=null===(s=this.LeadSourceClient)||void 0===s?void 0:s.leadSource)&&void 0!==l?l:null,d.initiatedChat&&await this.myPubnub.initializePubnub(u)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),i=!t||!(t&&!xi(Ci(t)));return!!e&&!!i&&!ci()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",yi(function(e,t){Be(2,arguments);var i=it(t);return nt(e,6e4*i)}(new Date,15)))},this.handleContactClicked=e=>{var t;this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickEmailOption(e)},this.handleTourClicked=e=>{var t,i;this.showTourNextToChat?null===(t=this.launcherRef.value)||void 0===t||t.onClickSSTOption(e):(this.hideLauncher?this.showTourNextToChat=!0:this.displayPubnubChat=!1,this.hideLauncher=!1,null===(i=this.launcherRef.value)||void 0===i||i.onClickSSTOption(e))},this.handleContactTabClicked=e=>{var t;this.displayPubnubChat=!1,this.showTourNextToChat=!1,this.hideLauncher=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickPhoneOption(e)},this.adjustPositionChatAdditionalActions=()=>{var e,t,i,n;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!r)return;const o=null===(n=null===(i=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===i?void 0:i.shadowRoot)||void 0===n?void 0:n.getElementById("pubnub-chat-container"),a=null==o?void 0:o.getBoundingClientRect();a&&(r.style.left=`${a.left}px`,r.style.top=`${a.bottom}px`)},this.handleKeydownTab=e=>{var t,i,n,r,o,a,s,l,u,d,c,p,h,f,m,g,v,y,b,w;if("Tab"===e.key){const S=this.displayPubnubChat?null===(n=null===(i=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===i?void 0:i.shadowRoot)||void 0===n?void 0:n.getElementById("pubnub-chat-container"):null!==(m=null!==(u=null===(l=null===(s=null===(a=null===(o=null===(r=this.shadowRoot)||void 0===r?void 0:r.getElementById("meetelise-launcher"))||void 0===o?void 0:o.shadowRoot)||void 0===a?void 0:a.getElementById("email-us-window"))||void 0===s?void 0:s.shadowRoot)||void 0===l?void 0:l.getElementById("email-us-form"))&&void 0!==u?u:null===(f=null===(h=null===(p=null===(c=null===(d=this.shadowRoot)||void 0===d?void 0:d.getElementById("meetelise-launcher"))||void 0===c?void 0:c.shadowRoot)||void 0===p?void 0:p.getElementById("tour-scheduler-window"))||void 0===h?void 0:h.shadowRoot)||void 0===f?void 0:f.getElementById("scheduler-container"))&&void 0!==m?m:null===(w=null===(b=null===(y=null===(v=null===(g=this.shadowRoot)||void 0===g?void 0:g.getElementById("meetelise-launcher"))||void 0===v?void 0:v.shadowRoot)||void 0===y?void 0:y.getElementById("call-us-window"))||void 0===b?void 0:b.shadowRoot)||void 0===w?void 0:w.getElementById("details-window");if(!S)return;e.preventDefault();const T=S.querySelectorAll("input, me-select, textarea, action-confirm-button, [tabindex]"),x=Array.from(T),A=x.findIndex((e=>e.matches(":focus")));x[(A+1)%x.length].focus()}},this.onClickMinimize=e=>{e.preventDefault(),e.stopPropagation(),this.isMinimized=!this.isMinimized,this.showTourNextToChat=!1},this.attachOnClickToLauncher=()=>{const e=this.launcherRef.value;e&&(e.onChatTapped=async()=>{this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,localStorage.setItem("isChatOpen","true")},e.onExitChat=this.onExitChat)},this.onExitChat=()=>{this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,localStorage.setItem("isChatOpen","false")},this.renderChatAdditionalActions=(e,t)=>{const i=this.building&&ke(this.building.orgId,this.building.id)&&this.brandColor&&this.brandColor!==Me?De(this.brandColor,.6):"black";return U` <style>
|
|
4503
4503
|
#{id}::after {
|
|
4504
4504
|
border-right-color: ${i} !important;
|
|
4505
4505
|
}
|
|
@@ -271,13 +271,7 @@ export class MEChat extends LitElement {
|
|
|
271
271
|
);
|
|
272
272
|
return;
|
|
273
273
|
}
|
|
274
|
-
|
|
275
|
-
// eslint-disable-next-line no-console
|
|
276
|
-
console.warn(
|
|
277
|
-
"MeetElise has detected this building is NOT active (custom). Chat icon will not appear."
|
|
278
|
-
);
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
274
|
+
|
|
281
275
|
this.building = building;
|
|
282
276
|
|
|
283
277
|
await this.initializeChatVariables();
|