@meetelise/chat 1.70.0 → 1.70.1

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.
@@ -82,7 +82,9 @@ export declare class MEChat extends LitElement {
82
82
  private hideMobileFeatures;
83
83
  private privacyPolicyUrl;
84
84
  launcherRef: Ref<Launcher>;
85
+ private dniNumber;
85
86
  firstUpdated: () => Promise<void>;
87
+ reinsertDNIIntoWebsite(): void;
86
88
  private setupWebchat;
87
89
  setBuildingDerivedInfo: () => Promise<void>;
88
90
  private initializeChatVariables;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.70.0",
3
+ "version": "1.70.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/MeetElise/chat-ui#readme",
@@ -9001,7 +9001,7 @@ xmlns="http://www.w3.org/2000/svg"
9001
9001
  cursor: pointer;
9002
9002
  filter: brightness(90%);
9003
9003
  }
9004
- `],Vh([pe({attribute:!0})],Wh.prototype,"onClick",void 0),Vh([pe({attribute:!0})],Wh.prototype,"primaryColor",void 0),Vh([pe({attribute:!0})],Wh.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),Vh([pe({attribute:!0})],Wh.prototype,"toExpand",void 0),Wh=Vh([ce("minimize-expand-button")],Wh);const Qh="cdn.skypack.dev/@meetelise/chat",qh="cdn.eliseai.com/@meetelise/chat",Yh=async(e,t)=>{try{if(Math.random()>=.15)return;const i=(()=>{try{const e=document.getElementsByTagName("script");for(const t of e){const e=t.src||"",i=t.textContent||"";if(e.includes(Qh)||i.includes(Qh))return"skypack";if(e.includes(qh)||i.includes(qh))return"eliseai"}return"unknown"}catch(e){return"unknown"}})();await r().post("https://app.meetelise.com/platformApi/webchat/cdn-version",{cdn_version:i},{params:{cdn_version:i},headers:{"Content-Type":"application/json","building-slug":t,"org-slug":e}})}catch(e){}},Kh=(e,t)=>["floor plan","floorplan","floor plans","floorplans","apply here"].some(t=>e.toLowerCase().includes(t))?t.endsWith("/units")?t:`${t}/units`:t,Xh={"95ae958e-95db-11ed-9862-6f4db5533d3f":"8008db60-45b7-11f1-88ac-635f686365da","95ae96b0-95db-11ed-9863-a7aa664fd985":"72ed27c4-45b7-11f1-82d9-37b7db547687"},Zh="https://applications.eliseai.com",Jh=["Check Availability","Apply Now"],ep=(e,t,i,n)=>{if(!(e=>{var t;if(!e.classList.contains("floorplan-button"))return!1;const i=e.getElementsByTagName("span");if(1!==i.length)return!1;const n=null===(t=i[0].textContent)||void 0===t?void 0:t.trim();return null!=n&&Jh.includes(n)})(e))return!1;if(e.getAttribute("href")===t)return!1;const r=e.getAttribute("href");return e.setAttribute("href",t),e.setAttribute("target","_blank"),ra({logTitle:"CHECK_AVAIL_OVERWRITE",logData:{oldHref:r,newHref:t,website:window.location.href},logType:na.info,buildingSlug:n,orgSlug:i}),!0},tp=(e,t,i,n)=>{for(let r=0;r<e.length;r++){const o=e[r];if(o.nodeType!==Node.ELEMENT_NODE)continue;const a=o;"A"===a.tagName&&ep(a,t,i,n);const s=a.getElementsByTagName("a");for(let e=0;e<s.length;e++)ep(s[e],t,i,n)}},ip=(e,t,i)=>{((e,t,i)=>{const n=document.body.getElementsByTagName("a");for(let r=0;r<n.length;r++)ep(n[r],e,t,i)})(i,e,t);new MutationObserver(n=>{for(const r of n)tp(r.addedNodes,i,e,t)}).observe(document.body,{childList:!0,subtree:!0})};class np{constructor(e,t){this.persistLeadSourceTTLDays=30,this.maxSourcesNonPropertyWebsiteCount=3,this._generateLeadSourceLocalStorageKey=()=>`com.eliseai.webchat.leadsources.v2.buildingslug=${this.buildingSlug}`,this._generateNewExpirationTimestamp=()=>Fr(zr(new Date,this.persistLeadSourceTTLDays)),this._generateLeadSourceParameters=()=>{const e=$o();return{websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:e,referrer:document.referrer,parsedUtmSource:e?e.utm_source:null,campaignSources:Object.values(ia()).filter(e=>e)}},this.addSafeLeadSourceTouchpoint=e=>{const t=this.getLocalStorageMultitouchValue(),i=this._generateLeadSourceLocalStorageKey();if(!t||this.isExpiredTimestamp(t.timestampExpires)){const t={timestampExpires:this._generateNewExpirationTimestamp(),leadSources:[{parameters:this._generateLeadSourceParameters(),leadSourceValue:e,timestampInitiallyLogged:Fr(new Date),type:"touchpoint"}]};localStorage.setItem(i,JSON.stringify(t))}else{if(t.leadSources.find(t=>t.leadSourceValue===e))return;if(t.leadSources.length<this.maxSourcesNonPropertyWebsiteCount)return t.leadSources.push({parameters:this._generateLeadSourceParameters(),leadSourceValue:e,timestampInitiallyLogged:Fr(new Date),type:"touchpoint"}),t.timestampExpires=this._generateNewExpirationTimestamp(),void localStorage.setItem(i,JSON.stringify(t));ra({logType:na.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,logTitle:"TOO_MANY_LEAD_SOURCES",logData:{buildingSlug:this.buildingSlug}})}},this.getSafeLeadSourceTouchpointsWithDefault=({includedUserSelectedLeadSource:e})=>{const t=this.getLocalStorageMultitouchValue(),i=la(this.orgSlug);if(!t){const t=[{leadSourceValue:i,timestampInitiallyLogged:Fr(new Date),type:"default"}];return e&&t.push({leadSourceValue:e,timestampInitiallyLogged:Fr(new Date),type:"user-selected"}),t}const n=t.leadSources.length>0?t.leadSources.sort((e,t)=>Yr(e.timestampInitiallyLogged).getTime()-Yr(t.timestampInitiallyLogged).getTime())[0].timestampInitiallyLogged:Fr(new Date),r=[{timestampInitiallyLogged:n,leadSourceValue:i,type:"default"},...t.leadSources.map(e=>({timestampInitiallyLogged:e.timestampInitiallyLogged,leadSourceValue:e.leadSourceValue,type:e.type}))];return e&&r.push({leadSourceValue:e,timestampInitiallyLogged:Fr(new Date),type:"user-selected"}),r},this.getLocalStorageMultitouchValue=()=>{const e=this._generateLeadSourceLocalStorageKey(),t=localStorage.getItem(e);if(!t)return null;return JSON.parse(t)},this.isExpiredTimestamp=e=>Yr(e)<new Date,this.resetLeadSourceTouchpoints=()=>{const e=this._generateLeadSourceLocalStorageKey();return localStorage.removeItem(e),!0},this.orgSlug=e,this.buildingSlug=t}}var rp=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 op=class extends ue{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.centralConvo=!1,this.declaredBuildingSlug="",this.hostDeclaredBuildingId=void 0,this.orgLevel=!1,this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.primaryColor=null,this.backgroundColor=null,this.foregroundColorOnPrimaryBackgroundColor=null,this.foregroundColorOnSecondaryBackgroundColor=null,this._isMobile=Ir(),this.chatId="",this.analytics=null,this.launcher=null,this.buildingWebchatView=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=bo.always,this.bedroomPreferenceRequired=!1,this.tourSchedulerV2=!1,this.brokerIntakeEnabled=!1,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.showTourNextToChat=!1,this.openTourSchedulerOnLoad=!1,this.displayPubnubChat=!1,this.launcherButton=null,this.focusChatOnMount=!1,this.myPubnub=null,this.getSessionToken=()=>{var e,t;return null!==(t=null===(e=this.myPubnub)||void 0===e?void 0:e.getSessionToken())&&void 0!==t?t:null},this.LeadSourceClient=null,this.LeadSourceMultitouchClient=null,this.sampleRateToUse=.05,this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.overrideRentgrata=!1,this.widgetType=Cp.Default,this.onWidgetLoaded=mh(),this.onSstClose=mh(),this.enabledChatWidgets={callDesktop:!1,callMobile:!1,chatMobile:!1,chatDesktop:!1,emailDesktop:!1,emailMobile:!1,textDesktop:!1,textMobile:!1,sstDesktop:!1,sstMobile:!1,calcDesktop:!1,calcMobile:!1},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.hideMobileFeatures=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.launcherRef=Oe(),this.firstUpdated=async()=>this.setupWebchat(),this.setupWebchat=async()=>{var e,t;if(!this.orgSlug)return;if(!this.centralConvo&&!this.buildingSlug)return;this.centralConvo&&!this.buildingSlug&&(this.orgLevel=!0);const i=this.centralConvo?await async function(e){const t=`https://app.meetelise.com/api/pub/v1/organization/${e}/webchat/v2`,i=await r().get(t);return va(i.data)}(this.orgSlug):await ya(this.orgSlug,this.buildingSlug);if(!this.isOrgMode()){if(Math.random()<.2)try{(async(e,t)=>{const i=window.rentgrata;if(!i)return;const n=i.Widget;if(!n)return;const o=n.config;if(!o)return;const a=o.widgetKey;a&&await r().post(`https://app.meetelise.com/platformApi/webchat/rentgrata?token=${a}`,{},{headers:{"Content-Type":"application/json","building-slug":null!=e?e:"","org-slug":null!=t?t:""}})})(this.buildingSlug,this.orgSlug)}catch(e){}try{Yh(this.orgSlug,this.buildingSlug)}catch(e){}}if(!await Tu(i,this.buildingSlug,this.orgSlug))return;oa({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!0},sampleRate:(null==i?void 0:i.launchedDateTime)?.01:.05}),this.buildingWebchatView=i;const n=(()=>{try{const e="true"===sessionStorage.getItem(Cs);return sessionStorage.removeItem(Cs),e}catch{return!1}})();await this.initializeChatVariables(),await this.handleChatInitializeAnalytics(),await this.setBuildingDerivedInfo(),this.attachOnClickToLauncher(),(e=>{const t=new URLSearchParams(window.location.search),i=t.get("rwg_token"),n=t.get("elise_google_env");if(!i||!n||!e)return;const r={rwgToken:i,environment:n,buildingId:e,expiresAt:Date.now()+2592e6};localStorage.setItem(ts,JSON.stringify(r))})(null!==(t=null===(e=this.buildingWebchatView)||void 0===e?void 0:e.id)&&void 0!==t?t:0),n?(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0):"tour"===new URLSearchParams(window.location.search).get("elise_open")&&(this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile)?this.openTourSchedulerOnLoad=!0:this.shouldAutoOpenChat(this.webchatConfigHasAutoOpenChat)?(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.rememberChatAutoOpenDismissed()):"true"===localStorage.getItem("isChatOpen")&&(this.hideLauncher=!0,this.displayPubnubChat=!0),this.isLoading=!1},this.setBuildingDerivedInfo=async()=>{var e,t,i,n,o,a,s,l,u,d,c,h,p,f,g,m,b,y,v,w,C,x,$,S,k,A,T,E,_,O,P,I,N,M,D,L,R,B,U,j,F,H,z,G,V,W,Q,q,Y,K,X;const Z=this.buildingWebchatView;if(!Z)return;Z&&this.orgSlug&&!this.orgLevel&&sp(this.orgSlug,null!==(t=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.chatId)&&void 0!==t?t:null,this.sampleRateToUse,this.buildingSlug,null!==(n=null===(i=this.LeadSourceClient)||void 0===i?void 0:i.leadSource)&&void 0!==n?n:null);const J=Z.featureFlagWebchatMarketingSourceDropdownConfiguration,ee=Z.featureFlagWebchatUseDniPhoneNumberBySource,te=Z.featureFlagInsertDniIntoWebsite,ie=Z.featureFlagWebchatReplaceAnyScheduleTourCtaWebsite;var ne;ne=Ao.includes(Z.orgId),Eo=ne;const[re,oe,ae,se,le,ue]=await Promise.all([this.isOrgMode()?Promise.resolve([]):Bh(this.orgSlug,this.buildingSlug),yo(this.buildingSlug),jh(this.buildingSlug),wo(this.buildingSlug),xo(this.buildingSlug),Co(this.buildingSlug)]);this.buildingWebchatView&&(this.buildingWebchatView.phoneNumber=Wi(Z.phoneNumber),this.buildingWebchatView.isAip=ae),this.leadSources=re,this.featureFlagShowDropdown=J,this.bedroomPreferenceRequired=se,this.brokerIntakeEnabled=le,this.tourSchedulerV2=ue;const de=this.orgLevel?null:Z.textWithUsPhoneNumber?Z.textWithUsPhoneNumber:await(async e=>{try{const t="https://app.meetelise.com",i=await r().get(`${t}/platformApi/webchat/${e}/phone-number`);if(i.data)return i.data}catch(t){return ra({logType:na.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t},error:t}),null}return null})(this.buildingSlug),ce=null!==(a=null===(o=this.buildingWebchatView)||void 0===o?void 0:o.shouldShowPricingCalculatorDesktop)&&void 0!==a&&a,he=null!==(l=null===(s=this.buildingWebchatView)||void 0===s?void 0:s.shouldShowPricingCalculatorMobile)&&void 0!==l&&l,pe={callDesktop:null!==(d=null===(u=this.buildingWebchatView)||void 0===u?void 0:u.shouldShowPhoneDesktop)&&void 0!==d&&d,callMobile:null!==(h=null===(c=this.buildingWebchatView)||void 0===c?void 0:c.shouldShowPhoneMobile)&&void 0!==h&&h,chatDesktop:null!==(f=null===(p=this.buildingWebchatView)||void 0===p?void 0:p.shouldShowChatDesktop)&&void 0!==f&&f,chatMobile:null!==(m=null===(g=this.buildingWebchatView)||void 0===g?void 0:g.shouldShowChatMobile)&&void 0!==m&&m,emailDesktop:null!==(y=null===(b=this.buildingWebchatView)||void 0===b?void 0:b.shouldShowEmailDesktop)&&void 0!==y&&y,emailMobile:null!==(w=null===(v=this.buildingWebchatView)||void 0===v?void 0:v.shouldShowEmailMobile)&&void 0!==w&&w,textDesktop:null!==(x=(null===(C=this.buildingWebchatView)||void 0===C?void 0:C.shouldShowTextDesktop)&&!!de)&&void 0!==x&&x,textMobile:null!==(S=(null===($=this.buildingWebchatView)||void 0===$?void 0:$.shouldShowTextMobile)&&!!de)&&void 0!==S&&S,sstDesktop:null!==(A=null===(k=this.buildingWebchatView)||void 0===k?void 0:k.shouldShowSstDesktop)&&void 0!==A&&A,sstMobile:null!==(E=null===(T=this.buildingWebchatView)||void 0===T?void 0:T.shouldShowSstMobile)&&void 0!==E&&E,calcDesktop:ce,calcMobile:he};var fe,ge;this.enabledChatWidgets=this.withOrgLevelContactOptions($h(pe),null!==(O=null===(_=this.buildingWebchatView)||void 0===_?void 0:_.phoneNumber)&&void 0!==O?O:""),this.orgLevel||(this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile||"radco"===this.orgSlug?(Gh(this.handleTourClicked,this.orgSlug,this.buildingSlug,()=>this.isConnected),ie&&(ge=this.handleTourClicked,document.querySelectorAll('a[href$="schedule-a-tour"]').forEach(e=>{e&&e.addEventListener("click",e=>{e.preventDefault(),ge(e)})})),"radco"===this.orgSlug&&(e=>{document.querySelectorAll('a[href^="#leaseleads-tour-open"]').forEach(t=>{var i;if(!t)return;const n=document.createElement("a");n.textContent=t.textContent,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===(P=this.LeadSourceClient)||void 0===P?void 0:P.leadSource)&&(fe=null!==(N=null===(I=this.LeadSourceClient)||void 0===I?void 0:I.leadSource)&&void 0!==N?N: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(fe)}`)}}))),this.buildingWebchatView&&(this.primaryColor=null!==(M=this.buildingWebchatView.primaryColor)&&void 0!==M?M:null,this.backgroundColor=null!==(D=this.buildingWebchatView.secondaryColor)&&void 0!==D?D:null,this.foregroundColorOnPrimaryBackgroundColor=null!==(L=this.buildingWebchatView.foregroundColorOnPrimaryBackgroundColor)&&void 0!==L?L:null,this.foregroundColorOnSecondaryBackgroundColor=null!==(R=this.buildingWebchatView.foregroundColorOnSecondaryBackgroundColor)&&void 0!==R?R:null,this.webchatConfigHasAutoOpenChat=null!==(B=this.buildingWebchatView.autoOpenChat)&&void 0!==B&&B,this.requiresConsent=null!==(U=this.buildingWebchatView.requiresConsentForChat)&&void 0!==U&&U,this.hideMobileFeatures=null!==(j=this.buildingWebchatView.collapseMobileFeatures)&&void 0!==j&&j,this.privacyPolicyUrl=null!==(F=this.buildingWebchatView.privacyPolicyUrlForChat)&&void 0!==F?F:this.privacyPolicyUrl,this.buildingWebchatView.displayStyle===fa.MINIMIZED&&(this.isMinimized=!0),this.buildingWebchatView.displayStyle===fa.PILLS&&(this.designConcept=null),this.buildingWebchatView.displayStyle===fa.EMOJI&&(this.designConcept=fa.EMOJI),this.onWidgetLoaded()),null===this.primaryColor&&(this.primaryColor=Xi),null===this.backgroundColor&&(this.backgroundColor=Zi);const me=null!==(z=null===(H=this.buildingWebchatView)||void 0===H?void 0:H.phoneNumber)&&void 0!==z?z:"";let be=null;if(ee&&!this.orgLevel&&(be=await async function(e,t){try{const i=await r().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source`,{params:{source:t}});return i.data?{number:Wi(i.data.number),isMatch:i.data.match,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(V=null===(G=this.LeadSourceClient)||void 0===G?void 0:G.leadSource)&&void 0!==V?V:null),be&&!be.isMatch&&(be.number=me)),te&&(null==be?void 0:be.number)){const e=zh(be.number,this.orgSlug,this.buildingSlug);e>0&&oa({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_dni_insert_override_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}const ye=localStorage.getItem("eliseai_phone_number_devtest");ye&&zh(ye,this.orgSlug,this.buildingSlug),this.phoneNumberForSource=be||{number:me,isMatch:!1,isPropertyWebsiteCatchall:!0};const ve=null!==(Q=null===(W=this.LeadSourceClient)||void 0===W?void 0:W.leadSource)&&void 0!==Q?Q:null;ve&&(this.leadSources.includes(ve)||this.leadSources.push(ve)),this.isOrgMode()||ao(Z.id);if((oe||(null===(q=this.buildingWebchatView)||void 0===q?void 0:q.isAip))&&(null===(Y=this.buildingWebchatView)||void 0===Y?void 0:Y.isLiveOnApplications)&&this.buildingSlug&&!this.orgLevel){const e=((e,t,i)=>{var n;const r=[/thehavenatgreenhill\.securecafe\.com\/onlineleasing\/the-haven-at-greenhill\/oleapplication\.aspx(\?.*)?$/,/securecafe\.com\/onlineleasing.*\/oleapplication\.aspx(\?.*)?$/,/\/onlineleasing.*\/oleapplication\.aspx(\?.*)?$/,/\/content\/apply/,/\/apply-now/,/\/apply/,/vsc\.myresman\.com\/Portal\/Applicants\/Availability(\?.*)?$/,/vsc\.myresman\.com\/Portal\/Applicants\/New\/.*(\?.*)?$/,/busboomgroup\.myresman\.com\/Portal\/Applicants\/Availability(\?.*)?$/],o=document.body.getElementsByTagName("a");let a=0;for(let s=0;s<o.length;s++){const l=o[s];if(l.nodeType===Node.ELEMENT_NODE&&r.some(e=>e.test(l.href))){const r=l.getAttribute("href"),o=(null===(n=l.textContent)||void 0===n?void 0:n.toLowerCase())||"",s=Kh(o,e);l.setAttribute("href",s),a++,ra({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"link-replacement",oldHref:r,newHref:s,website:window.location.href},logType:na.info,buildingSlug:i,orgSlug:t})}}return 0===a&&ra({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"no-select-buttons-found",website:window.location.href},logType:na.warn,buildingSlug:i,orgSlug:t}),a})(`https://applications.eliseai.com/building/${this.buildingSlug}/units`,this.orgSlug,this.buildingSlug);e>0&&oa({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_application_link_replacement_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}if(this.buildingSlug&&this.orgSlug&&!this.orgLevel)try{(e=>{const t=Xh[e];if(!t)return 0;const i=`${Zh}/building/${t}/units`,n=`${Zh}/building/${e}/units`,r=new RegExp(`https://applications\\.eliseai\\.com/building/${t}/units`,"g");let o=0;const a=document.body.getElementsByTagName("a");for(let e=0;e<a.length;e++){const t=a[e],s=t.getAttribute("href");if(!s||!s.includes(i))continue;const l=s.replace(r,n);l!==s&&(t.setAttribute("href",l),o++)}document.body.querySelectorAll("[onclick]").forEach(e=>{const t=e.getAttribute("onclick");if(!t||!t.includes(i))return;const a=t.replace(r,n);a!==t&&(e.setAttribute("onclick",a),o++)})})(this.buildingSlug)}catch{}this.buildingSlug&&!this.orgLevel&&(null===(K=this.buildingWebchatView)||void 0===K?void 0:K.isLiveOnApplications)&&(null===(X=this.buildingWebchatView)||void 0===X?void 0:X.applicationLink)&&"c954426c-12ab-4f8e-8384-8218e79eaf72"===this.orgSlug&&ip(this.orgSlug,this.buildingSlug,this.buildingWebchatView.applicationLink)},this.initializeChatVariables=async()=>{var e,t,i,n,r,o,a,s,l,u;if(!this.buildingWebchatView)return;const d=this.chatStorageSlug(),c=ys(d),h=vs(d,c),p=h?c:bs(d,!1);if(!p.leadId)throw new Error("Lead ID is null");if(this.LeadSourceClient=new ua,this.LeadSourceClient.orgId=null!==(t=null===(e=this.buildingWebchatView)||void 0===e?void 0:e.orgId)&&void 0!==t?t:0,this.LeadSourceMultitouchClient=new np(this.orgSlug,this.buildingSlug),this.myPubnub=new Os(this.buildingSlug,this.buildingWebchatView,this.orgSlug,null,p.leadId,this.LeadSourceMultitouchClient,this.LeadSourceClient,this.widgetType),this.myPubnub.chatStorageSlug=d,this.centralConvo){const e=this.myPubnub;e.centralConvo=!0,void 0!==this.hostDeclaredBuildingId?e.declaredBuildingId=this.hostDeclaredBuildingId:this.fetchDeclaredBuildingId().then(t=>{void 0===this.hostDeclaredBuildingId&&(e.declaredBuildingId=t)})}else this.myPubnub.declaredBuildingId=this.buildingWebchatView.id;const f=await this.myPubnub.initSession(this.buildingSlug,this.orgSlug,h&&null!==(i=p.leadId)&&void 0!==i?i:void 0);f&&(bs(d,p.initiatedChat,f.lead_id),this.isOrgMode()&&f.building_slug&&await this.adoptBuilding(f.building_slug)),this.LeadSourceClient.chatId=this.myPubnub.channel;const g=await(null===(n=this.LeadSourceClient)||void 0===n?void 0:n.generateUserLeadSource({leadId:null!==(o=null===(r=this.myPubnub)||void 0===r?void 0:r.leadUserId)&&void 0!==o?o:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug}));g&&this.LeadSourceMultitouchClient.addSafeLeadSourceTouchpoint(g),"property-website"!==la(this.orgSlug)?this.myPubnub.leadSource=null!==(s=null===(a=this.LeadSourceClient)||void 0===a?void 0:a.leadSource)&&void 0!==s?s:la(this.orgSlug):this.myPubnub.leadSource=null!==(u=null===(l=this.LeadSourceClient)||void 0===l?void 0:l.leadSource)&&void 0!==u?u:null;const m=ys(d);m.initiatedChat&&await this.myPubnub.initializePubnub(m)},this.isOrgMode=()=>this.centralConvo&&!this.buildingSlug,this.chatStorageSlug=()=>this.orgLevel?"":this.buildingSlug,this.adoptBuilding=async e=>{var t;try{const i=await ya(this.orgSlug,e);if(!(null==i?void 0:i.id))return;this.buildingSlug=e,this.buildingWebchatView=i,null===(t=this.myPubnub)||void 0===t||t.adoptBuilding(e,i)}catch(e){}},this.withOrgLevelContactOptions=(e,t)=>this.orgLevel?{...e,emailDesktop:!1,emailMobile:!1,textDesktop:!1,textMobile:!1,callDesktop:e.callDesktop&&!!t,callMobile:e.callMobile&&!!t}:e,this.fetchDeclaredBuildingId=async()=>{if(!this.declaredBuildingSlug||!this.orgSlug)return null;try{const e=await ya(this.orgSlug,this.declaredBuildingSlug);return"number"==typeof(null==e?void 0:e.id)&&e.id>0?e.id:null}catch{return null}},this.chatAutoOpenDismissedStorageKey=()=>{const{orgSlug:e,buildingSlug:t}=this;return e&&t?`com.elise.webchat.autoOpenDismissed=${e}=${t}`:t?`com.elise.webchat.autoOpenDismissed=${t}`:e?`com.elise.webchat.autoOpenDismissed=${e}`:null},this.shouldAutoOpenChat=e=>{if(!e||Ir())return!1;const t=this.chatAutoOpenDismissedStorageKey();return!t||"true"!==localStorage.getItem(t)},this.rememberChatAutoOpenDismissed=()=>{const e=this.chatAutoOpenDismissedStorageKey();e&&localStorage.setItem(e,"true")},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.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.focusChatOnMount=!0,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.rememberChatAutoOpenDismissed()},this.focusLauncherButton=()=>{var e,t;const i=(null===(e=this.launcherButton)||void 0===e?void 0:e.isConnected)?this.launcherButton:null;null===(t=null!=i?i:this.currentLauncherButton())||void 0===t||t.focus()},this.focusMessageFieldOnOpen=()=>{var e,t;const i=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("pubnub-chat"),n=null==i?void 0:i.shadowRoot;i&&n&&(i.focusMessageField()||null===(t=n.getElementById("pubnub-chat-container"))||void 0===t||t.focus(),setTimeout(()=>{i.focusMessageField()},0))},this.closeChatAndRestoreFocus=()=>{this.onExitChat(),this.updateComplete.then(()=>{this.focusLauncherButton(),requestAnimationFrame(()=>this.focusLauncherButton())})}}setDeclaredBuildingId(e){this.hostDeclaredBuildingId=e,this.myPubnub&&(this.myPubnub.declaredBuildingId=e)}async handleChatInitializeAnalytics(){var e,t,i,n;this.analytics=new ta(this.orgSlug,this.buildingSlug,null!==(t=null===(e=this.myPubnub)||void 0===e?void 0:e.channel)&&void 0!==t?t:"",null!==(n=null===(i=this.LeadSourceClient)||void 0===i?void 0:i.leadSource)&&void 0!==n?n:null),Math.random()<.05&&this.analytics.ping("webchat_heartbeat")}async restartConversation(){var e;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),ms(this.chatStorageSlug()),this.orgLevel&&(this.buildingSlug=""),this.myPubnub=null,this.displayPubnubChat=!1,await this.setupWebchat(),this.hideLauncher=!1}show(){this.launcher&&(this.launcher.style.display="")}hide(){this.launcher&&(this.launcher.style.display="none")}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.adjustPositionChatAdditionalActions),this._cleanupMobileListener=Nr(e=>{this._isMobile=e})}updated(){this.adjustPositionChatAdditionalActions()}disconnectedCallback(){var e,t;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),window.removeEventListener("resize",this.adjustPositionChatAdditionalActions),null===(t=this._cleanupMobileListener)||void 0===t||t.call(this),super.disconnectedCallback()}currentLauncherButton(){var e,t,i,n;const r=null===(t=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("meetelise-launcher"))||void 0===t?void 0:t.shadowRoot,o=null==r?void 0:r.querySelector("#type-hey__ask-prompt, button[aria-label='Chat with us']"),a=null===(n=null===(i=null==r?void 0:r.querySelector("mobile-launcher"))||void 0===i?void 0:i.shadowRoot)||void 0===n?void 0:n.querySelector("button[aria-label='Chat with us']");return o instanceof HTMLElement?o:a instanceof HTMLElement?a:null}render(){var e,t,i,n,r,o,a,s,l,u,d,c,h,p,f,g,m,b,y,v,w,C,x,$,S,k,A,T,E,_,O,P,I,N,M,D,L,R,B,U,j,F,z,G,V,W,Q;wh();const q=this.hideLauncher&&!this.isLoading&&!this._isMobile;return H`
9004
+ `],Vh([pe({attribute:!0})],Wh.prototype,"onClick",void 0),Vh([pe({attribute:!0})],Wh.prototype,"primaryColor",void 0),Vh([pe({attribute:!0})],Wh.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),Vh([pe({attribute:!0})],Wh.prototype,"toExpand",void 0),Wh=Vh([ce("minimize-expand-button")],Wh);const Qh="cdn.skypack.dev/@meetelise/chat",qh="cdn.eliseai.com/@meetelise/chat",Yh=async(e,t)=>{try{if(Math.random()>=.15)return;const i=(()=>{try{const e=document.getElementsByTagName("script");for(const t of e){const e=t.src||"",i=t.textContent||"";if(e.includes(Qh)||i.includes(Qh))return"skypack";if(e.includes(qh)||i.includes(qh))return"eliseai"}return"unknown"}catch(e){return"unknown"}})();await r().post("https://app.meetelise.com/platformApi/webchat/cdn-version",{cdn_version:i},{params:{cdn_version:i},headers:{"Content-Type":"application/json","building-slug":t,"org-slug":e}})}catch(e){}},Kh=(e,t)=>["floor plan","floorplan","floor plans","floorplans","apply here"].some(t=>e.toLowerCase().includes(t))?t.endsWith("/units")?t:`${t}/units`:t,Xh={"95ae958e-95db-11ed-9862-6f4db5533d3f":"8008db60-45b7-11f1-88ac-635f686365da","95ae96b0-95db-11ed-9863-a7aa664fd985":"72ed27c4-45b7-11f1-82d9-37b7db547687"},Zh="https://applications.eliseai.com",Jh=["Check Availability","Apply Now"],ep=(e,t,i,n)=>{if(!(e=>{var t;if(!e.classList.contains("floorplan-button"))return!1;const i=e.getElementsByTagName("span");if(1!==i.length)return!1;const n=null===(t=i[0].textContent)||void 0===t?void 0:t.trim();return null!=n&&Jh.includes(n)})(e))return!1;if(e.getAttribute("href")===t)return!1;const r=e.getAttribute("href");return e.setAttribute("href",t),e.setAttribute("target","_blank"),ra({logTitle:"CHECK_AVAIL_OVERWRITE",logData:{oldHref:r,newHref:t,website:window.location.href},logType:na.info,buildingSlug:n,orgSlug:i}),!0},tp=(e,t,i,n)=>{for(let r=0;r<e.length;r++){const o=e[r];if(o.nodeType!==Node.ELEMENT_NODE)continue;const a=o;"A"===a.tagName&&ep(a,t,i,n);const s=a.getElementsByTagName("a");for(let e=0;e<s.length;e++)ep(s[e],t,i,n)}},ip=(e,t,i)=>{((e,t,i)=>{const n=document.body.getElementsByTagName("a");for(let r=0;r<n.length;r++)ep(n[r],e,t,i)})(i,e,t);new MutationObserver(n=>{for(const r of n)tp(r.addedNodes,i,e,t)}).observe(document.body,{childList:!0,subtree:!0})};class np{constructor(e,t){this.persistLeadSourceTTLDays=30,this.maxSourcesNonPropertyWebsiteCount=3,this._generateLeadSourceLocalStorageKey=()=>`com.eliseai.webchat.leadsources.v2.buildingslug=${this.buildingSlug}`,this._generateNewExpirationTimestamp=()=>Fr(zr(new Date,this.persistLeadSourceTTLDays)),this._generateLeadSourceParameters=()=>{const e=$o();return{websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:e,referrer:document.referrer,parsedUtmSource:e?e.utm_source:null,campaignSources:Object.values(ia()).filter(e=>e)}},this.addSafeLeadSourceTouchpoint=e=>{const t=this.getLocalStorageMultitouchValue(),i=this._generateLeadSourceLocalStorageKey();if(!t||this.isExpiredTimestamp(t.timestampExpires)){const t={timestampExpires:this._generateNewExpirationTimestamp(),leadSources:[{parameters:this._generateLeadSourceParameters(),leadSourceValue:e,timestampInitiallyLogged:Fr(new Date),type:"touchpoint"}]};localStorage.setItem(i,JSON.stringify(t))}else{if(t.leadSources.find(t=>t.leadSourceValue===e))return;if(t.leadSources.length<this.maxSourcesNonPropertyWebsiteCount)return t.leadSources.push({parameters:this._generateLeadSourceParameters(),leadSourceValue:e,timestampInitiallyLogged:Fr(new Date),type:"touchpoint"}),t.timestampExpires=this._generateNewExpirationTimestamp(),void localStorage.setItem(i,JSON.stringify(t));ra({logType:na.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,logTitle:"TOO_MANY_LEAD_SOURCES",logData:{buildingSlug:this.buildingSlug}})}},this.getSafeLeadSourceTouchpointsWithDefault=({includedUserSelectedLeadSource:e})=>{const t=this.getLocalStorageMultitouchValue(),i=la(this.orgSlug);if(!t){const t=[{leadSourceValue:i,timestampInitiallyLogged:Fr(new Date),type:"default"}];return e&&t.push({leadSourceValue:e,timestampInitiallyLogged:Fr(new Date),type:"user-selected"}),t}const n=t.leadSources.length>0?t.leadSources.sort((e,t)=>Yr(e.timestampInitiallyLogged).getTime()-Yr(t.timestampInitiallyLogged).getTime())[0].timestampInitiallyLogged:Fr(new Date),r=[{timestampInitiallyLogged:n,leadSourceValue:i,type:"default"},...t.leadSources.map(e=>({timestampInitiallyLogged:e.timestampInitiallyLogged,leadSourceValue:e.leadSourceValue,type:e.type}))];return e&&r.push({leadSourceValue:e,timestampInitiallyLogged:Fr(new Date),type:"user-selected"}),r},this.getLocalStorageMultitouchValue=()=>{const e=this._generateLeadSourceLocalStorageKey(),t=localStorage.getItem(e);if(!t)return null;return JSON.parse(t)},this.isExpiredTimestamp=e=>Yr(e)<new Date,this.resetLeadSourceTouchpoints=()=>{const e=this._generateLeadSourceLocalStorageKey();return localStorage.removeItem(e),!0},this.orgSlug=e,this.buildingSlug=t}}var rp=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 op=class extends ue{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.centralConvo=!1,this.declaredBuildingSlug="",this.hostDeclaredBuildingId=void 0,this.orgLevel=!1,this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.primaryColor=null,this.backgroundColor=null,this.foregroundColorOnPrimaryBackgroundColor=null,this.foregroundColorOnSecondaryBackgroundColor=null,this._isMobile=Ir(),this.chatId="",this.analytics=null,this.launcher=null,this.buildingWebchatView=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=bo.always,this.bedroomPreferenceRequired=!1,this.tourSchedulerV2=!1,this.brokerIntakeEnabled=!1,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.showTourNextToChat=!1,this.openTourSchedulerOnLoad=!1,this.displayPubnubChat=!1,this.launcherButton=null,this.focusChatOnMount=!1,this.myPubnub=null,this.getSessionToken=()=>{var e,t;return null!==(t=null===(e=this.myPubnub)||void 0===e?void 0:e.getSessionToken())&&void 0!==t?t:null},this.LeadSourceClient=null,this.LeadSourceMultitouchClient=null,this.sampleRateToUse=.05,this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.overrideRentgrata=!1,this.widgetType=Cp.Default,this.onWidgetLoaded=mh(),this.onSstClose=mh(),this.enabledChatWidgets={callDesktop:!1,callMobile:!1,chatMobile:!1,chatDesktop:!1,emailDesktop:!1,emailMobile:!1,textDesktop:!1,textMobile:!1,sstDesktop:!1,sstMobile:!1,calcDesktop:!1,calcMobile:!1},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.hideMobileFeatures=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.launcherRef=Oe(),this.dniNumber=null,this.firstUpdated=async()=>this.setupWebchat(),this.setupWebchat=async()=>{var e,t;if(!this.orgSlug)return;if(!this.centralConvo&&!this.buildingSlug)return;this.centralConvo&&!this.buildingSlug&&(this.orgLevel=!0);const i=this.centralConvo?await async function(e){const t=`https://app.meetelise.com/api/pub/v1/organization/${e}/webchat/v2`,i=await r().get(t);return va(i.data)}(this.orgSlug):await ya(this.orgSlug,this.buildingSlug);if(!this.isOrgMode()){if(Math.random()<.2)try{(async(e,t)=>{const i=window.rentgrata;if(!i)return;const n=i.Widget;if(!n)return;const o=n.config;if(!o)return;const a=o.widgetKey;a&&await r().post(`https://app.meetelise.com/platformApi/webchat/rentgrata?token=${a}`,{},{headers:{"Content-Type":"application/json","building-slug":null!=e?e:"","org-slug":null!=t?t:""}})})(this.buildingSlug,this.orgSlug)}catch(e){}try{Yh(this.orgSlug,this.buildingSlug)}catch(e){}}if(!await Tu(i,this.buildingSlug,this.orgSlug))return;oa({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!0},sampleRate:(null==i?void 0:i.launchedDateTime)?.01:.05}),this.buildingWebchatView=i;const n=(()=>{try{const e="true"===sessionStorage.getItem(Cs);return sessionStorage.removeItem(Cs),e}catch{return!1}})();await this.initializeChatVariables(),await this.handleChatInitializeAnalytics(),await this.setBuildingDerivedInfo(),this.attachOnClickToLauncher(),(e=>{const t=new URLSearchParams(window.location.search),i=t.get("rwg_token"),n=t.get("elise_google_env");if(!i||!n||!e)return;const r={rwgToken:i,environment:n,buildingId:e,expiresAt:Date.now()+2592e6};localStorage.setItem(ts,JSON.stringify(r))})(null!==(t=null===(e=this.buildingWebchatView)||void 0===e?void 0:e.id)&&void 0!==t?t:0),n?(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0):"tour"===new URLSearchParams(window.location.search).get("elise_open")&&(this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile)?this.openTourSchedulerOnLoad=!0:this.shouldAutoOpenChat(this.webchatConfigHasAutoOpenChat)?(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.rememberChatAutoOpenDismissed()):"true"===localStorage.getItem("isChatOpen")&&(this.hideLauncher=!0,this.displayPubnubChat=!0),this.isLoading=!1},this.setBuildingDerivedInfo=async()=>{var e,t,i,n,o,a,s,l,u,d,c,h,p,f,g,m,b,y,v,w,C,x,$,S,k,A,T,E,_,O,P,I,N,M,D,L,R,B,U,j,F,H,z,G,V,W,Q,q,Y,K,X;const Z=this.buildingWebchatView;if(!Z)return;Z&&this.orgSlug&&!this.orgLevel&&sp(this.orgSlug,null!==(t=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.chatId)&&void 0!==t?t:null,this.sampleRateToUse,this.buildingSlug,null!==(n=null===(i=this.LeadSourceClient)||void 0===i?void 0:i.leadSource)&&void 0!==n?n:null);const J=Z.featureFlagWebchatMarketingSourceDropdownConfiguration,ee=Z.featureFlagWebchatUseDniPhoneNumberBySource,te=Z.featureFlagInsertDniIntoWebsite,ie=Z.featureFlagWebchatReplaceAnyScheduleTourCtaWebsite;var ne;ne=Ao.includes(Z.orgId),Eo=ne;const[re,oe,ae,se,le,ue]=await Promise.all([this.isOrgMode()?Promise.resolve([]):Bh(this.orgSlug,this.buildingSlug),yo(this.buildingSlug),jh(this.buildingSlug),wo(this.buildingSlug),xo(this.buildingSlug),Co(this.buildingSlug)]);this.buildingWebchatView&&(this.buildingWebchatView.phoneNumber=Wi(Z.phoneNumber),this.buildingWebchatView.isAip=ae),this.leadSources=re,this.featureFlagShowDropdown=J,this.bedroomPreferenceRequired=se,this.brokerIntakeEnabled=le,this.tourSchedulerV2=ue;const de=this.orgLevel?null:Z.textWithUsPhoneNumber?Z.textWithUsPhoneNumber:await(async e=>{try{const t="https://app.meetelise.com",i=await r().get(`${t}/platformApi/webchat/${e}/phone-number`);if(i.data)return i.data}catch(t){return ra({logType:na.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t},error:t}),null}return null})(this.buildingSlug),ce=null!==(a=null===(o=this.buildingWebchatView)||void 0===o?void 0:o.shouldShowPricingCalculatorDesktop)&&void 0!==a&&a,he=null!==(l=null===(s=this.buildingWebchatView)||void 0===s?void 0:s.shouldShowPricingCalculatorMobile)&&void 0!==l&&l,pe={callDesktop:null!==(d=null===(u=this.buildingWebchatView)||void 0===u?void 0:u.shouldShowPhoneDesktop)&&void 0!==d&&d,callMobile:null!==(h=null===(c=this.buildingWebchatView)||void 0===c?void 0:c.shouldShowPhoneMobile)&&void 0!==h&&h,chatDesktop:null!==(f=null===(p=this.buildingWebchatView)||void 0===p?void 0:p.shouldShowChatDesktop)&&void 0!==f&&f,chatMobile:null!==(m=null===(g=this.buildingWebchatView)||void 0===g?void 0:g.shouldShowChatMobile)&&void 0!==m&&m,emailDesktop:null!==(y=null===(b=this.buildingWebchatView)||void 0===b?void 0:b.shouldShowEmailDesktop)&&void 0!==y&&y,emailMobile:null!==(w=null===(v=this.buildingWebchatView)||void 0===v?void 0:v.shouldShowEmailMobile)&&void 0!==w&&w,textDesktop:null!==(x=(null===(C=this.buildingWebchatView)||void 0===C?void 0:C.shouldShowTextDesktop)&&!!de)&&void 0!==x&&x,textMobile:null!==(S=(null===($=this.buildingWebchatView)||void 0===$?void 0:$.shouldShowTextMobile)&&!!de)&&void 0!==S&&S,sstDesktop:null!==(A=null===(k=this.buildingWebchatView)||void 0===k?void 0:k.shouldShowSstDesktop)&&void 0!==A&&A,sstMobile:null!==(E=null===(T=this.buildingWebchatView)||void 0===T?void 0:T.shouldShowSstMobile)&&void 0!==E&&E,calcDesktop:ce,calcMobile:he};var fe,ge;this.enabledChatWidgets=this.withOrgLevelContactOptions($h(pe),null!==(O=null===(_=this.buildingWebchatView)||void 0===_?void 0:_.phoneNumber)&&void 0!==O?O:""),this.orgLevel||(this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile||"radco"===this.orgSlug?(Gh(this.handleTourClicked,this.orgSlug,this.buildingSlug,()=>this.isConnected),ie&&(ge=this.handleTourClicked,document.querySelectorAll('a[href$="schedule-a-tour"]').forEach(e=>{e&&e.addEventListener("click",e=>{e.preventDefault(),ge(e)})})),"radco"===this.orgSlug&&(e=>{document.querySelectorAll('a[href^="#leaseleads-tour-open"]').forEach(t=>{var i;if(!t)return;const n=document.createElement("a");n.textContent=t.textContent,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===(P=this.LeadSourceClient)||void 0===P?void 0:P.leadSource)&&(fe=null!==(N=null===(I=this.LeadSourceClient)||void 0===I?void 0:I.leadSource)&&void 0!==N?N: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(fe)}`)}}))),this.buildingWebchatView&&(this.primaryColor=null!==(M=this.buildingWebchatView.primaryColor)&&void 0!==M?M:null,this.backgroundColor=null!==(D=this.buildingWebchatView.secondaryColor)&&void 0!==D?D:null,this.foregroundColorOnPrimaryBackgroundColor=null!==(L=this.buildingWebchatView.foregroundColorOnPrimaryBackgroundColor)&&void 0!==L?L:null,this.foregroundColorOnSecondaryBackgroundColor=null!==(R=this.buildingWebchatView.foregroundColorOnSecondaryBackgroundColor)&&void 0!==R?R:null,this.webchatConfigHasAutoOpenChat=null!==(B=this.buildingWebchatView.autoOpenChat)&&void 0!==B&&B,this.requiresConsent=null!==(U=this.buildingWebchatView.requiresConsentForChat)&&void 0!==U&&U,this.hideMobileFeatures=null!==(j=this.buildingWebchatView.collapseMobileFeatures)&&void 0!==j&&j,this.privacyPolicyUrl=null!==(F=this.buildingWebchatView.privacyPolicyUrlForChat)&&void 0!==F?F:this.privacyPolicyUrl,this.buildingWebchatView.displayStyle===fa.MINIMIZED&&(this.isMinimized=!0),this.buildingWebchatView.displayStyle===fa.PILLS&&(this.designConcept=null),this.buildingWebchatView.displayStyle===fa.EMOJI&&(this.designConcept=fa.EMOJI),this.onWidgetLoaded()),null===this.primaryColor&&(this.primaryColor=Xi),null===this.backgroundColor&&(this.backgroundColor=Zi);const me=null!==(z=null===(H=this.buildingWebchatView)||void 0===H?void 0:H.phoneNumber)&&void 0!==z?z:"";let be=null;if(ee&&!this.orgLevel&&(be=await async function(e,t){try{const i=await r().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source`,{params:{source:t}});return i.data?{number:Wi(i.data.number),isMatch:i.data.match,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(V=null===(G=this.LeadSourceClient)||void 0===G?void 0:G.leadSource)&&void 0!==V?V:null),be&&!be.isMatch&&(be.number=me)),te&&(null==be?void 0:be.number)){this.dniNumber=be.number;const e=zh(be.number,this.orgSlug,this.buildingSlug);e>0&&oa({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_dni_insert_override_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}const ye=localStorage.getItem("eliseai_phone_number_devtest");ye&&(this.dniNumber=ye,zh(ye,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=be||{number:me,isMatch:!1,isPropertyWebsiteCatchall:!0};const ve=null!==(Q=null===(W=this.LeadSourceClient)||void 0===W?void 0:W.leadSource)&&void 0!==Q?Q:null;ve&&(this.leadSources.includes(ve)||this.leadSources.push(ve)),this.isOrgMode()||ao(Z.id);if((oe||(null===(q=this.buildingWebchatView)||void 0===q?void 0:q.isAip))&&(null===(Y=this.buildingWebchatView)||void 0===Y?void 0:Y.isLiveOnApplications)&&this.buildingSlug&&!this.orgLevel){const e=((e,t,i)=>{var n;const r=[/thehavenatgreenhill\.securecafe\.com\/onlineleasing\/the-haven-at-greenhill\/oleapplication\.aspx(\?.*)?$/,/securecafe\.com\/onlineleasing.*\/oleapplication\.aspx(\?.*)?$/,/\/onlineleasing.*\/oleapplication\.aspx(\?.*)?$/,/\/content\/apply/,/\/apply-now/,/\/apply/,/vsc\.myresman\.com\/Portal\/Applicants\/Availability(\?.*)?$/,/vsc\.myresman\.com\/Portal\/Applicants\/New\/.*(\?.*)?$/,/busboomgroup\.myresman\.com\/Portal\/Applicants\/Availability(\?.*)?$/],o=document.body.getElementsByTagName("a");let a=0;for(let s=0;s<o.length;s++){const l=o[s];if(l.nodeType===Node.ELEMENT_NODE&&r.some(e=>e.test(l.href))){const r=l.getAttribute("href"),o=(null===(n=l.textContent)||void 0===n?void 0:n.toLowerCase())||"",s=Kh(o,e);l.setAttribute("href",s),a++,ra({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"link-replacement",oldHref:r,newHref:s,website:window.location.href},logType:na.info,buildingSlug:i,orgSlug:t})}}return 0===a&&ra({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"no-select-buttons-found",website:window.location.href},logType:na.warn,buildingSlug:i,orgSlug:t}),a})(`https://applications.eliseai.com/building/${this.buildingSlug}/units`,this.orgSlug,this.buildingSlug);e>0&&oa({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_application_link_replacement_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}if(this.buildingSlug&&this.orgSlug&&!this.orgLevel)try{(e=>{const t=Xh[e];if(!t)return 0;const i=`${Zh}/building/${t}/units`,n=`${Zh}/building/${e}/units`,r=new RegExp(`https://applications\\.eliseai\\.com/building/${t}/units`,"g");let o=0;const a=document.body.getElementsByTagName("a");for(let e=0;e<a.length;e++){const t=a[e],s=t.getAttribute("href");if(!s||!s.includes(i))continue;const l=s.replace(r,n);l!==s&&(t.setAttribute("href",l),o++)}document.body.querySelectorAll("[onclick]").forEach(e=>{const t=e.getAttribute("onclick");if(!t||!t.includes(i))return;const a=t.replace(r,n);a!==t&&(e.setAttribute("onclick",a),o++)})})(this.buildingSlug)}catch{}this.buildingSlug&&!this.orgLevel&&(null===(K=this.buildingWebchatView)||void 0===K?void 0:K.isLiveOnApplications)&&(null===(X=this.buildingWebchatView)||void 0===X?void 0:X.applicationLink)&&"c954426c-12ab-4f8e-8384-8218e79eaf72"===this.orgSlug&&ip(this.orgSlug,this.buildingSlug,this.buildingWebchatView.applicationLink)},this.initializeChatVariables=async()=>{var e,t,i,n,r,o,a,s,l,u;if(!this.buildingWebchatView)return;const d=this.chatStorageSlug(),c=ys(d),h=vs(d,c),p=h?c:bs(d,!1);if(!p.leadId)throw new Error("Lead ID is null");if(this.LeadSourceClient=new ua,this.LeadSourceClient.orgId=null!==(t=null===(e=this.buildingWebchatView)||void 0===e?void 0:e.orgId)&&void 0!==t?t:0,this.LeadSourceMultitouchClient=new np(this.orgSlug,this.buildingSlug),this.myPubnub=new Os(this.buildingSlug,this.buildingWebchatView,this.orgSlug,null,p.leadId,this.LeadSourceMultitouchClient,this.LeadSourceClient,this.widgetType),this.myPubnub.chatStorageSlug=d,this.centralConvo){const e=this.myPubnub;e.centralConvo=!0,void 0!==this.hostDeclaredBuildingId?e.declaredBuildingId=this.hostDeclaredBuildingId:this.fetchDeclaredBuildingId().then(t=>{void 0===this.hostDeclaredBuildingId&&(e.declaredBuildingId=t)})}else this.myPubnub.declaredBuildingId=this.buildingWebchatView.id;const f=await this.myPubnub.initSession(this.buildingSlug,this.orgSlug,h&&null!==(i=p.leadId)&&void 0!==i?i:void 0);f&&(bs(d,p.initiatedChat,f.lead_id),this.isOrgMode()&&f.building_slug&&await this.adoptBuilding(f.building_slug)),this.LeadSourceClient.chatId=this.myPubnub.channel;const g=await(null===(n=this.LeadSourceClient)||void 0===n?void 0:n.generateUserLeadSource({leadId:null!==(o=null===(r=this.myPubnub)||void 0===r?void 0:r.leadUserId)&&void 0!==o?o:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug}));g&&this.LeadSourceMultitouchClient.addSafeLeadSourceTouchpoint(g),"property-website"!==la(this.orgSlug)?this.myPubnub.leadSource=null!==(s=null===(a=this.LeadSourceClient)||void 0===a?void 0:a.leadSource)&&void 0!==s?s:la(this.orgSlug):this.myPubnub.leadSource=null!==(u=null===(l=this.LeadSourceClient)||void 0===l?void 0:l.leadSource)&&void 0!==u?u:null;const m=ys(d);m.initiatedChat&&await this.myPubnub.initializePubnub(m)},this.isOrgMode=()=>this.centralConvo&&!this.buildingSlug,this.chatStorageSlug=()=>this.orgLevel?"":this.buildingSlug,this.adoptBuilding=async e=>{var t;try{const i=await ya(this.orgSlug,e);if(!(null==i?void 0:i.id))return;this.buildingSlug=e,this.buildingWebchatView=i,null===(t=this.myPubnub)||void 0===t||t.adoptBuilding(e,i)}catch(e){}},this.withOrgLevelContactOptions=(e,t)=>this.orgLevel?{...e,emailDesktop:!1,emailMobile:!1,textDesktop:!1,textMobile:!1,callDesktop:e.callDesktop&&!!t,callMobile:e.callMobile&&!!t}:e,this.fetchDeclaredBuildingId=async()=>{if(!this.declaredBuildingSlug||!this.orgSlug)return null;try{const e=await ya(this.orgSlug,this.declaredBuildingSlug);return"number"==typeof(null==e?void 0:e.id)&&e.id>0?e.id:null}catch{return null}},this.chatAutoOpenDismissedStorageKey=()=>{const{orgSlug:e,buildingSlug:t}=this;return e&&t?`com.elise.webchat.autoOpenDismissed=${e}=${t}`:t?`com.elise.webchat.autoOpenDismissed=${t}`:e?`com.elise.webchat.autoOpenDismissed=${e}`:null},this.shouldAutoOpenChat=e=>{if(!e||Ir())return!1;const t=this.chatAutoOpenDismissedStorageKey();return!t||"true"!==localStorage.getItem(t)},this.rememberChatAutoOpenDismissed=()=>{const e=this.chatAutoOpenDismissedStorageKey();e&&localStorage.setItem(e,"true")},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.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.focusChatOnMount=!0,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.rememberChatAutoOpenDismissed()},this.focusLauncherButton=()=>{var e,t;const i=(null===(e=this.launcherButton)||void 0===e?void 0:e.isConnected)?this.launcherButton:null;null===(t=null!=i?i:this.currentLauncherButton())||void 0===t||t.focus()},this.focusMessageFieldOnOpen=()=>{var e,t;const i=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("pubnub-chat"),n=null==i?void 0:i.shadowRoot;i&&n&&(i.focusMessageField()||null===(t=n.getElementById("pubnub-chat-container"))||void 0===t||t.focus(),setTimeout(()=>{i.focusMessageField()},0))},this.closeChatAndRestoreFocus=()=>{this.onExitChat(),this.updateComplete.then(()=>{this.focusLauncherButton(),requestAnimationFrame(()=>this.focusLauncherButton())})}}reinsertDNIIntoWebsite(){this.dniNumber&&zh(this.dniNumber,this.orgSlug,this.buildingSlug)}setDeclaredBuildingId(e){this.hostDeclaredBuildingId=e,this.myPubnub&&(this.myPubnub.declaredBuildingId=e)}async handleChatInitializeAnalytics(){var e,t,i,n;this.analytics=new ta(this.orgSlug,this.buildingSlug,null!==(t=null===(e=this.myPubnub)||void 0===e?void 0:e.channel)&&void 0!==t?t:"",null!==(n=null===(i=this.LeadSourceClient)||void 0===i?void 0:i.leadSource)&&void 0!==n?n:null),Math.random()<.05&&this.analytics.ping("webchat_heartbeat")}async restartConversation(){var e;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),ms(this.chatStorageSlug()),this.orgLevel&&(this.buildingSlug=""),this.myPubnub=null,this.displayPubnubChat=!1,await this.setupWebchat(),this.hideLauncher=!1}show(){this.launcher&&(this.launcher.style.display="")}hide(){this.launcher&&(this.launcher.style.display="none")}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.adjustPositionChatAdditionalActions),this._cleanupMobileListener=Nr(e=>{this._isMobile=e})}updated(){this.adjustPositionChatAdditionalActions()}disconnectedCallback(){var e,t;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),window.removeEventListener("resize",this.adjustPositionChatAdditionalActions),null===(t=this._cleanupMobileListener)||void 0===t||t.call(this),super.disconnectedCallback()}currentLauncherButton(){var e,t,i,n;const r=null===(t=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("meetelise-launcher"))||void 0===t?void 0:t.shadowRoot,o=null==r?void 0:r.querySelector("#type-hey__ask-prompt, button[aria-label='Chat with us']"),a=null===(n=null===(i=null==r?void 0:r.querySelector("mobile-launcher"))||void 0===i?void 0:i.shadowRoot)||void 0===n?void 0:n.querySelector("button[aria-label='Chat with us']");return o instanceof HTMLElement?o:a instanceof HTMLElement?a:null}render(){var e,t,i,n,r,o,a,s,l,u,d,c,h,p,f,g,m,b,y,v,w,C,x,$,S,k,A,T,E,_,O,P,I,N,M,D,L,R,B,U,j,F,z,G,V,W,Q;wh();const q=this.hideLauncher&&!this.isLoading&&!this._isMobile;return H`
9005
9005
  <meta name="viewport" content="width=device-width, initial-scale=1">
9006
9006
  ${this.displayPubnubChat?H`
9007
9007
  <pubnub-chat
@@ -9422,4 +9422,4 @@ xmlns="http://www.w3.org/2000/svg"
9422
9422
  line-height: 150%;
9423
9423
  font-size: 16px;
9424
9424
  }
9425
- `,fp([pe({type:String})],gp.prototype,"orgSlug",void 0),fp([pe({type:Number})],gp.prototype,"right",void 0),fp([pe({type:Number})],gp.prototype,"bottom",void 0),fp([pe({type:Number})],gp.prototype,"top",void 0),fp([pe({type:Number})],gp.prototype,"left",void 0),fp([fe()],gp.prototype,"launcher",void 0),fp([fe()],gp.prototype,"currentLeadSource",void 0),fp([fe()],gp.prototype,"displayPubnubChat",void 0),fp([fe()],gp.prototype,"myPubnub",void 0),fp([fe()],gp.prototype,"requiresConsent",void 0),fp([fe()],gp.prototype,"privacyPolicyUrl",void 0),fp([fe()],gp.prototype,"isLoading",void 0),gp=fp([ce("utilities-chat")],gp);const mp=async e=>{const t=window.location.href,i=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(t)}`,n=await r().get(i,{headers:{"org-slug":e}});return Math.random()<.2&&ra({logType:n&&n.data?na.info:na.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${n?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:n.data,url:t,orgSlug:e,givenBuildingSlug:null,reason:n&&n.data?null:"No match found"}}),n.data},bp=async(e,t=5e3)=>new Promise((i,n)=>{const r=new MutationObserver((t,n)=>{const r=document.getElementById(e);r&&(n.disconnect(),i(r))});r.observe(document.body,{childList:!0,subtree:!0});const o=setTimeout(()=>{r.disconnect(),n(new Error(`Element ${e} did not appear within ${t}ms`))},t),a=document.querySelector(e);a&&(clearTimeout(o),r.disconnect(),i(a))});class yp{static healthcareStart(e,t=!0){var i,n,r,o;t&&(this.healthcareId=e.id,this.overridePlacement={right:e.right,bottom:e.bottom,top:e.top,left:e.left}),xp();const a=document.createElement("health-chat");a.setAttribute("class","health-chat"),a.setAttribute("role","region"),a.setAttribute("aria-label","EliseAI Healthcare Widget"),a.setAttribute("healthcareId",e.id),a.setAttribute("right",(null===(i=e.right)||void 0===i?void 0:i.toString())||"unset"),a.setAttribute("bottom",(null===(n=e.bottom)||void 0===n?void 0:n.toString())||"unset"),a.setAttribute("top",(null===(r=e.top)||void 0===r?void 0:r.toString())||"unset"),a.setAttribute("left",(null===(o=e.left)||void 0===o?void 0:o.toString())||"unset"),document.body.appendChild(a),yp.healthChat=a}static start(e,t=!0){var i,n,r,o,a,s,l,u;if(window.location.pathname.includes("residentservices")||window.location.pathname.includes("onlineleasing"))return;if(t&&(this.orgSlug="Pacific Urban Residential"===e.organization?"cbc11aba-21c4-4571-bc43-ff9d86a029e3":e.organization||"",this.hasBuildingSlug=!!e.building,this.overridePlacement={right:null===(i=null==e?void 0:e.position)||void 0===i?void 0:i.right,bottom:null===(n=null==e?void 0:e.position)||void 0===n?void 0:n.bottom,top:null===(r=null==e?void 0:e.position)||void 0===r?void 0:r.top,left:null===(o=null==e?void 0:e.position)||void 0===o?void 0:o.left}),xp(),e.studio&&!e.building)return void this.handleStudioContext(e);let d=null;switch(e.widgetType){case Cp.Healthcare:throw new Error("Healthcare widget is not supported yet, please use the healthcareStart method instead.");case Cp.Default:d=document.createElement("me-chat");break;case Cp.Utilities:d=document.createElement("utilities-chat");break;default:d=document.createElement("me-chat")}if(!d)throw new Error("Invalid widget type");d.setAttribute("orgSlug","Pacific Urban Residential"===e.organization?"cbc11aba-21c4-4571-bc43-ff9d86a029e3":e.organization||""),d.setAttribute("widgetType",e.widgetType||Cp.Default),d.setAttribute("class","meetelise-chat"),d.setAttribute("role","region"),d.setAttribute("aria-label","EliseAI Widget"),e.brandColor&&(this.brandColor=e.brandColor,d.setAttribute("primaryColor",((e,t)=>{const i=Ji(e),n=0,r=0,o=0,a={r:i.r+Math.round((n-i.r)*t),g:i.g+Math.round((r-i.g)*t),b:i.b+Math.round((o-i.b)*t)};return en(a.r,a.g,a.b)})(e.brandColor,.3))),e.backgroundColor&&(this.backgroundColor=e.backgroundColor),d instanceof op&&(e.centralConvo?(d.setAttribute("centralConvo","true"),e.building&&d.setAttribute("declaredBuildingSlug",e.building)):this.handleBuildingslug(d,e.organization,e.building,e),e.launcherStyles&&(d.launcherStyles=e.launcherStyles),e.mobileStyles&&(d.mobileStyles=e.mobileStyles),e.onWidgetLoaded&&(d.onWidgetLoaded=e.onWidgetLoaded),e.overrideRentgrata&&((async()=>{const e=await bp("rg-widget-compact");e&&e.setAttribute("style","display: none")})(),d.overrideRentgrata=!0),e.onSstClose&&(d.onSstClose=e.onSstClose)),e.position&&(d.setAttribute("right",(null===(a=e.position.right)||void 0===a?void 0:a.toString())||"unset"),d.setAttribute("bottom",(null===(s=e.position.bottom)||void 0===s?void 0:s.toString())||"unset"),d.setAttribute("top",(null===(l=e.position.top)||void 0===l?void 0:l.toString())||"unset"),d.setAttribute("left",(null===(u=e.position.left)||void 0===u?void 0:u.toString())||"unset")),window.eliseAi={},document.body.appendChild(d),d instanceof op&&(yp.meChat=d),d instanceof gp&&(yp.utilitiesChat=d)}static async restartConversation(){this.meChat&&await this.meChat.restartConversation()}static async remove(){this.studioUpdateToken+=1,await this.removeWidget(),this.activeStudioOrgSlug="",this.activeStudioBuildingSlug="",this.activeStudioSessionScopeKey="",this.activeStudioOptions=null}static async removeWidget(){var e;if(!this.meChat)return;const t=this.meChat;await t.remove(),null===(e=t.parentNode)||void 0===e||e.removeChild(t),yp.meChat===t&&(yp.meChat=null)}static handleStudioContext(e){e.studio&&(this.activeStudioOptions=e)}static updateStudioContext(e){var t;const i=this.activeStudioOptions;if(!(null==i?void 0:i.studio))return;const n=++this.studioUpdateToken;if(e.siteId&&e.siteId!==i.studio.siteId)return void ra({logType:na.warn,logTitle:"[STUDIO_WEBCHAT_CONTEXT_SITE_MISMATCH]",logData:{activeSiteId:i.studio.siteId,contextSiteId:e.siteId,url:window.location.href}});if("org"===(null===(t=e.sessionScope)||void 0===t?void 0:t.type))return void this.updateStudioOrgContext(e,i,n);const r=vp(e.organization),o=vp(e.building);if(!r||!o)return void this.clearStudioContext({source:"elise_studio",reason:"missing_context",preserveCache:!0});const a=function(e,t){if(!(null==e?void 0:e.key))return`building:${t}`;return e.key}(e.sessionScope,o),s=wp(r);this.activeStudioOrgSlug===s&&this.activeStudioBuildingSlug===o&&this.activeStudioSessionScopeKey===a||this.removeWidget().then(()=>{n===this.studioUpdateToken&&(this.activeStudioOrgSlug=s,this.activeStudioBuildingSlug=o,this.activeStudioSessionScopeKey=a,this.orgSlug=s,this.start({...i,organization:r,building:o},!1))})}static updateStudioOrgContext(e,t,i){var n;const r=vp(e.organization);if(!r)return void this.clearStudioContext({source:"elise_studio",reason:"missing_context",preserveCache:!0});const o=wp(r),a=(null===(n=e.sessionScope)||void 0===n?void 0:n.key)||`org:${r}`,s=function(e){const t="string"==typeof e?Number(e):e;return"number"==typeof t&&Number.isInteger(t)&&t>0?t:null}(e.declaredBuildingId);!this.meChat||this.activeStudioOrgSlug!==o||this.activeStudioBuildingSlug||this.activeStudioSessionScopeKey!==a?this.removeWidget().then(()=>{var e;i===this.studioUpdateToken&&(this.activeStudioOrgSlug=o,this.activeStudioBuildingSlug="",this.activeStudioSessionScopeKey=a,this.orgSlug=o,this.start({...t,studio:void 0,organization:r,building:void 0,centralConvo:!0},!1),null===(e=this.meChat)||void 0===e||e.setDeclaredBuildingId(s))}):this.meChat.setDeclaredBuildingId(s)}static clearStudioContext(e){this.studioUpdateToken+=1,this.activeStudioOrgSlug="",this.activeStudioBuildingSlug="",this.activeStudioSessionScopeKey="",this.removeWidget()}static async handleBuildingslug(e,t,i,n){if(i)return void e.setAttribute("buildingSlug",i);if(this.mutationObserver)return;if(!t)return;const r=await mp(t);if(r){const e={...n,organization:t,building:r};this.start(e,!1)}this.previousUrl=window.location.href,document.body.addEventListener("click",()=>{requestAnimationFrame(()=>{this.previousUrl===window.location.href||this.hasBuildingSlug||(this.previousUrl=window.location.href,mp(t).then(e=>{if(!e)return;const i={...n,organization:t,building:e};this.start(i,!1)}))})},!0)}static async handleSingleFamilyUrl(){if(this.hasBuildingSlug)return;this.remove();const e=window.location.href,t=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(e)}`,i=await r().get(t,{headers:{"org-slug":this.orgSlug}});if(Math.random()<.2&&ra({logType:i&&i.data?na.info:na.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${i?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:i.data,url:e,orgSlug:this.orgSlug,givenBuildingSlug:null,reason:i&&i.data?null:"No match found"}}),!i||!i.data)return;const n={organization:this.orgSlug,building:i.data,brandColor:this.brandColor,backgroundColor:this.backgroundColor};this.start(n,!1)}static async calculateBuildingSlugForLogging(e){const t=window.location.href,i=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(t)}`,n=await r().get(i,{headers:{"org-slug":this.orgSlug}});Math.random()<.2&&ra({logType:n&&n.data===e?na.info:na.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${n&&n.data===e?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:n.data,url:t,orgSlug:this.orgSlug,givenBuildingSlug:e,reason:n&&n.data===e?null:n&&!n.data?"No match found":n&&n.data!==e?"Mismatch":"No match found"}}),n&&n.data}}function vp(e){return"string"!=typeof e?"":e.trim()}function wp(e){return"Pacific Urban Residential"===e?"cbc11aba-21c4-4571-bc43-ff9d86a029e3":e}var Cp;yp.meChat=null,yp.healthChat=null,yp.utilitiesChat=null,yp.orgSlug="",yp.mutationObserver=null,yp.previousUrl="",yp.hasBuildingSlug=null,yp.brandColor="",yp.backgroundColor="",yp.healthcareId="",yp.activeStudioOrgSlug="",yp.activeStudioBuildingSlug="",yp.activeStudioSessionScopeKey="",yp.activeStudioOptions=null,yp.studioUpdateToken=0,yp.overridePlacement={},function(e){e.Default="default",e.Healthcare="healthcare",e.Utilities="utilities"}(Cp||(Cp={}));const xp=()=>{const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),document.head.appendChild(e)};export{Cp as WidgetType,yp as default};
9425
+ `,fp([pe({type:String})],gp.prototype,"orgSlug",void 0),fp([pe({type:Number})],gp.prototype,"right",void 0),fp([pe({type:Number})],gp.prototype,"bottom",void 0),fp([pe({type:Number})],gp.prototype,"top",void 0),fp([pe({type:Number})],gp.prototype,"left",void 0),fp([fe()],gp.prototype,"launcher",void 0),fp([fe()],gp.prototype,"currentLeadSource",void 0),fp([fe()],gp.prototype,"displayPubnubChat",void 0),fp([fe()],gp.prototype,"myPubnub",void 0),fp([fe()],gp.prototype,"requiresConsent",void 0),fp([fe()],gp.prototype,"privacyPolicyUrl",void 0),fp([fe()],gp.prototype,"isLoading",void 0),gp=fp([ce("utilities-chat")],gp);const mp=async e=>{const t=window.location.href,i=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(t)}`,n=await r().get(i,{headers:{"org-slug":e}});return Math.random()<.2&&ra({logType:n&&n.data?na.info:na.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${n?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:n.data,url:t,orgSlug:e,givenBuildingSlug:null,reason:n&&n.data?null:"No match found"}}),n.data},bp=async(e,t=5e3)=>new Promise((i,n)=>{const r=new MutationObserver((t,n)=>{const r=document.getElementById(e);r&&(n.disconnect(),i(r))});r.observe(document.body,{childList:!0,subtree:!0});const o=setTimeout(()=>{r.disconnect(),n(new Error(`Element ${e} did not appear within ${t}ms`))},t),a=document.querySelector(e);a&&(clearTimeout(o),r.disconnect(),i(a))});class yp{static healthcareStart(e,t=!0){var i,n,r,o;t&&(this.healthcareId=e.id,this.overridePlacement={right:e.right,bottom:e.bottom,top:e.top,left:e.left}),xp();const a=document.createElement("health-chat");a.setAttribute("class","health-chat"),a.setAttribute("role","region"),a.setAttribute("aria-label","EliseAI Healthcare Widget"),a.setAttribute("healthcareId",e.id),a.setAttribute("right",(null===(i=e.right)||void 0===i?void 0:i.toString())||"unset"),a.setAttribute("bottom",(null===(n=e.bottom)||void 0===n?void 0:n.toString())||"unset"),a.setAttribute("top",(null===(r=e.top)||void 0===r?void 0:r.toString())||"unset"),a.setAttribute("left",(null===(o=e.left)||void 0===o?void 0:o.toString())||"unset"),document.body.appendChild(a),yp.healthChat=a}static start(e,t=!0){var i,n,r,o,a,s,l,u;if(window.location.pathname.includes("residentservices")||window.location.pathname.includes("onlineleasing"))return;if(t&&(this.orgSlug="Pacific Urban Residential"===e.organization?"cbc11aba-21c4-4571-bc43-ff9d86a029e3":e.organization||"",this.hasBuildingSlug=!!e.building,this.overridePlacement={right:null===(i=null==e?void 0:e.position)||void 0===i?void 0:i.right,bottom:null===(n=null==e?void 0:e.position)||void 0===n?void 0:n.bottom,top:null===(r=null==e?void 0:e.position)||void 0===r?void 0:r.top,left:null===(o=null==e?void 0:e.position)||void 0===o?void 0:o.left}),xp(),e.studio&&!e.building)return void this.handleStudioContext(e);let d=null;switch(e.widgetType){case Cp.Healthcare:throw new Error("Healthcare widget is not supported yet, please use the healthcareStart method instead.");case Cp.Default:d=document.createElement("me-chat");break;case Cp.Utilities:d=document.createElement("utilities-chat");break;default:d=document.createElement("me-chat")}if(!d)throw new Error("Invalid widget type");d.setAttribute("orgSlug","Pacific Urban Residential"===e.organization?"cbc11aba-21c4-4571-bc43-ff9d86a029e3":e.organization||""),d.setAttribute("widgetType",e.widgetType||Cp.Default),d.setAttribute("class","meetelise-chat"),d.setAttribute("role","region"),d.setAttribute("aria-label","EliseAI Widget"),e.brandColor&&(this.brandColor=e.brandColor,d.setAttribute("primaryColor",((e,t)=>{const i=Ji(e),n=0,r=0,o=0,a={r:i.r+Math.round((n-i.r)*t),g:i.g+Math.round((r-i.g)*t),b:i.b+Math.round((o-i.b)*t)};return en(a.r,a.g,a.b)})(e.brandColor,.3))),e.backgroundColor&&(this.backgroundColor=e.backgroundColor),d instanceof op&&(e.centralConvo?(d.setAttribute("centralConvo","true"),e.building&&d.setAttribute("declaredBuildingSlug",e.building)):this.handleBuildingslug(d,e.organization,e.building,e),e.launcherStyles&&(d.launcherStyles=e.launcherStyles),e.mobileStyles&&(d.mobileStyles=e.mobileStyles),e.onWidgetLoaded&&(d.onWidgetLoaded=e.onWidgetLoaded),e.overrideRentgrata&&((async()=>{const e=await bp("rg-widget-compact");e&&e.setAttribute("style","display: none")})(),d.overrideRentgrata=!0),e.onSstClose&&(d.onSstClose=e.onSstClose)),e.position&&(d.setAttribute("right",(null===(a=e.position.right)||void 0===a?void 0:a.toString())||"unset"),d.setAttribute("bottom",(null===(s=e.position.bottom)||void 0===s?void 0:s.toString())||"unset"),d.setAttribute("top",(null===(l=e.position.top)||void 0===l?void 0:l.toString())||"unset"),d.setAttribute("left",(null===(u=e.position.left)||void 0===u?void 0:u.toString())||"unset")),window.eliseAi={},document.body.appendChild(d),d instanceof op&&(yp.meChat=d),d instanceof gp&&(yp.utilitiesChat=d)}static async restartConversation(){this.meChat&&await this.meChat.restartConversation()}static async remove(){this.studioUpdateToken+=1,await this.removeWidget(),this.activeStudioOrgSlug="",this.activeStudioBuildingSlug="",this.activeStudioSessionScopeKey="",this.activeStudioOptions=null}static async removeWidget(){var e;if(!this.meChat)return;const t=this.meChat;await t.remove(),null===(e=t.parentNode)||void 0===e||e.removeChild(t),yp.meChat===t&&(yp.meChat=null)}static handleStudioContext(e){e.studio&&(this.activeStudioOptions=e)}static updateStudioContext(e){var t;const i=this.activeStudioOptions;if(!(null==i?void 0:i.studio))return;const n=++this.studioUpdateToken;if(e.siteId&&e.siteId!==i.studio.siteId)return void ra({logType:na.warn,logTitle:"[STUDIO_WEBCHAT_CONTEXT_SITE_MISMATCH]",logData:{activeSiteId:i.studio.siteId,contextSiteId:e.siteId,url:window.location.href}});if("org"===(null===(t=e.sessionScope)||void 0===t?void 0:t.type))return void this.updateStudioOrgContext(e,i,n);const r=vp(e.organization),o=vp(e.building);if(!r||!o)return void this.clearStudioContext({source:"elise_studio",reason:"missing_context",preserveCache:!0});const a=function(e,t){if(!(null==e?void 0:e.key))return`building:${t}`;return e.key}(e.sessionScope,o),s=wp(r);this.activeStudioOrgSlug!==s||this.activeStudioBuildingSlug!==o||this.activeStudioSessionScopeKey!==a?this.removeWidget().then(()=>{n===this.studioUpdateToken&&(this.activeStudioOrgSlug=s,this.activeStudioBuildingSlug=o,this.activeStudioSessionScopeKey=a,this.orgSlug=s,this.start({...i,organization:r,building:o},!1))}):requestAnimationFrame(()=>{var e;return null===(e=this.meChat)||void 0===e?void 0:e.reinsertDNIIntoWebsite()})}static updateStudioOrgContext(e,t,i){var n;const r=vp(e.organization);if(!r)return void this.clearStudioContext({source:"elise_studio",reason:"missing_context",preserveCache:!0});const o=wp(r),a=(null===(n=e.sessionScope)||void 0===n?void 0:n.key)||`org:${r}`,s=function(e){const t="string"==typeof e?Number(e):e;return"number"==typeof t&&Number.isInteger(t)&&t>0?t:null}(e.declaredBuildingId);!this.meChat||this.activeStudioOrgSlug!==o||this.activeStudioBuildingSlug||this.activeStudioSessionScopeKey!==a?this.removeWidget().then(()=>{var e;i===this.studioUpdateToken&&(this.activeStudioOrgSlug=o,this.activeStudioBuildingSlug="",this.activeStudioSessionScopeKey=a,this.orgSlug=o,this.start({...t,studio:void 0,organization:r,building:void 0,centralConvo:!0},!1),null===(e=this.meChat)||void 0===e||e.setDeclaredBuildingId(s))}):this.meChat.setDeclaredBuildingId(s)}static clearStudioContext(e){this.studioUpdateToken+=1,this.activeStudioOrgSlug="",this.activeStudioBuildingSlug="",this.activeStudioSessionScopeKey="",this.removeWidget()}static async handleBuildingslug(e,t,i,n){if(i)return void e.setAttribute("buildingSlug",i);if(this.mutationObserver)return;if(!t)return;const r=await mp(t);if(r){const e={...n,organization:t,building:r};this.start(e,!1)}this.previousUrl=window.location.href,document.body.addEventListener("click",()=>{requestAnimationFrame(()=>{this.previousUrl===window.location.href||this.hasBuildingSlug||(this.previousUrl=window.location.href,mp(t).then(e=>{if(!e)return;const i={...n,organization:t,building:e};this.start(i,!1)}))})},!0)}static async handleSingleFamilyUrl(){if(this.hasBuildingSlug)return;this.remove();const e=window.location.href,t=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(e)}`,i=await r().get(t,{headers:{"org-slug":this.orgSlug}});if(Math.random()<.2&&ra({logType:i&&i.data?na.info:na.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${i?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:i.data,url:e,orgSlug:this.orgSlug,givenBuildingSlug:null,reason:i&&i.data?null:"No match found"}}),!i||!i.data)return;const n={organization:this.orgSlug,building:i.data,brandColor:this.brandColor,backgroundColor:this.backgroundColor};this.start(n,!1)}static async calculateBuildingSlugForLogging(e){const t=window.location.href,i=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(t)}`,n=await r().get(i,{headers:{"org-slug":this.orgSlug}});Math.random()<.2&&ra({logType:n&&n.data===e?na.info:na.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${n&&n.data===e?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:n.data,url:t,orgSlug:this.orgSlug,givenBuildingSlug:e,reason:n&&n.data===e?null:n&&!n.data?"No match found":n&&n.data!==e?"Mismatch":"No match found"}}),n&&n.data}}function vp(e){return"string"!=typeof e?"":e.trim()}function wp(e){return"Pacific Urban Residential"===e?"cbc11aba-21c4-4571-bc43-ff9d86a029e3":e}var Cp;yp.meChat=null,yp.healthChat=null,yp.utilitiesChat=null,yp.orgSlug="",yp.mutationObserver=null,yp.previousUrl="",yp.hasBuildingSlug=null,yp.brandColor="",yp.backgroundColor="",yp.healthcareId="",yp.activeStudioOrgSlug="",yp.activeStudioBuildingSlug="",yp.activeStudioSessionScopeKey="",yp.activeStudioOptions=null,yp.studioUpdateToken=0,yp.overridePlacement={},function(e){e.Default="default",e.Healthcare="healthcare",e.Utilities="utilities"}(Cp||(Cp={}));const xp=()=>{const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),document.head.appendChild(e)};export{Cp as WidgetType,yp as default};
@@ -309,8 +309,16 @@ export class MEChat extends LitElement {
309
309
 
310
310
  launcherRef: Ref<Launcher> = createRef();
311
311
 
312
+ private dniNumber: string | null = null;
313
+
312
314
  firstUpdated = async (): Promise<void> => this.setupWebchat();
313
315
 
316
+ reinsertDNIIntoWebsite(): void {
317
+ if (this.dniNumber) {
318
+ insertDNIIntoWebsite(this.dniNumber, this.orgSlug, this.buildingSlug);
319
+ }
320
+ }
321
+
314
322
  private setupWebchat = async (): Promise<void> => {
315
323
  if (!this.orgSlug) return;
316
324
  if (!this.centralConvo && !this.buildingSlug) return;
@@ -575,6 +583,7 @@ export class MEChat extends LitElement {
575
583
  }
576
584
  }
577
585
  if (featureFlagInsertDNIWebsite && phoneNumberForSource?.number) {
586
+ this.dniNumber = phoneNumberForSource.number;
578
587
  const totalReplacements = insertDNIIntoWebsite(
579
588
  phoneNumberForSource.number,
580
589
  this.orgSlug,
@@ -601,6 +610,7 @@ export class MEChat extends LitElement {
601
610
  if (devTestPhoneNumber) {
602
611
  // eslint-disable-next-line no-console
603
612
  console.info("Using dev test phone number: ", devTestPhoneNumber);
613
+ this.dniNumber = devTestPhoneNumber;
604
614
  insertDNIIntoWebsite(devTestPhoneNumber, this.orgSlug, this.buildingSlug);
605
615
  }
606
616
 
@@ -360,6 +360,7 @@ export default class MEChat {
360
360
  this.activeStudioBuildingSlug === buildingSlug &&
361
361
  this.activeStudioSessionScopeKey === sessionScopeKey
362
362
  ) {
363
+ requestAnimationFrame(() => this.meChat?.reinsertDNIIntoWebsite());
363
364
  return;
364
365
  }
365
366
 
@@ -722,6 +722,43 @@ it("swaps a Studio site's building widget for org-level webchat", async () => {
722
722
  }
723
723
  });
724
724
 
725
+ it("swaps the number again on a Studio page reached without a reload", async () => {
726
+ fakeBackend();
727
+ localStorage.setItem("eliseai_phone_number_devtest", "3035550123");
728
+ const page = document.createElement("main");
729
+ page.innerHTML = "<p>(855) 383-2298</p>";
730
+ document.body.appendChild(page);
731
+ const buildingContext = {
732
+ source: "elise_studio" as const,
733
+ siteId: STUDIO_SITE,
734
+ organization: "test-org",
735
+ building: "test-building",
736
+ sessionScope: { type: "building" as const, key: "building:test-building" },
737
+ };
738
+ MEChat.start({
739
+ studio: { siteId: STUDIO_SITE, mode: "host_managed_context" },
740
+ });
741
+ try {
742
+ MEChat.updateStudioContext(buildingContext);
743
+ const meChat = await studioWidget();
744
+ expect(page.textContent).to.equal("(303) 555-0123");
745
+
746
+ // Hidden test pages never paint, so run the frame callback right away.
747
+ stub(window, "requestAnimationFrame").callsFake((callback) => {
748
+ callback(0);
749
+ return 0;
750
+ });
751
+ page.innerHTML = "<p>Call (855) 383-2298</p>";
752
+ MEChat.updateStudioContext(buildingContext);
753
+
754
+ expect(document.querySelector("me-chat")).to.equal(meChat);
755
+ expect(page.textContent).to.equal("Call (303) 555-0123");
756
+ } finally {
757
+ page.remove();
758
+ await MEChat.remove();
759
+ }
760
+ });
761
+
725
762
  it("clears a Studio site's org scope without an organization", async () => {
726
763
  fakeBackend(inRollout);
727
764
  MEChat.start({