@meetelise/chat 1.59.1 → 1.59.2
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/dist/src/WebComponent/me-chat.d.ts +7 -0
- package/dist/src/WebComponent/pubnub-chat.d.ts +2 -0
- package/package.json +1 -1
- package/public/dist/index.js +4 -4
- package/src/WebComponent/me-chat.ts +22 -4
- package/src/WebComponent/pubnub-chat.ts +11 -0
- package/src/chatKeyboard.test.ts +132 -2
- package/src/disclaimers.ts +17 -3
|
@@ -129,6 +129,13 @@ export declare class MEChat extends LitElement {
|
|
|
129
129
|
private attachOnClickToLauncher;
|
|
130
130
|
onExitChat: () => void;
|
|
131
131
|
private focusLauncherButton;
|
|
132
|
+
/**
|
|
133
|
+
* User-initiated open. The caret belongs in the message field.
|
|
134
|
+
* While consent hides the composer, keep focus on the dialog so the agree
|
|
135
|
+
* control is reachable. Stored consent is applied after onMount, so try
|
|
136
|
+
* again once that paint has committed.
|
|
137
|
+
*/
|
|
138
|
+
private focusMessageFieldOnOpen;
|
|
132
139
|
private closeChatAndRestoreFocus;
|
|
133
140
|
private currentLauncherButton;
|
|
134
141
|
render(): TemplateResult;
|
|
@@ -60,6 +60,8 @@ export declare class PubnubChat extends LitElement {
|
|
|
60
60
|
updated(): Promise<void>;
|
|
61
61
|
autoResizeMessageInput: () => void;
|
|
62
62
|
needsConsent: () => boolean;
|
|
63
|
+
/** Caret in the message field when the composer is on screen. */
|
|
64
|
+
focusMessageField(): boolean;
|
|
63
65
|
/** Tab cycles inside the fullscreen mobile dialog. Desktop stays non-modal. */
|
|
64
66
|
private trapTabInMobileDialog;
|
|
65
67
|
render(): TemplateResult;
|
package/package.json
CHANGED
package/public/dist/index.js
CHANGED
|
@@ -838,7 +838,7 @@ var e={2:(e,t,n)=>{var i=n(2199),r=n(4664),o=n(5950);e.exports=function(e){retur
|
|
|
838
838
|
${"textUs"===e||n?H`<p style=${o}>
|
|
839
839
|
Msg freq varies. Text STOP to opt-out of messages. Text HELP for
|
|
840
840
|
assistance.
|
|
841
|
-
</p>`:""}`},Go="currentConsentId",zo=(e,t,n,i,r)=>{const o=Ro(r)?Lo:t,a=e=>{var t;const n=null===(t=e.currentTarget)||void 0===t?void 0:t.getRootNode();if(!(n instanceof ShadowRoot))return;const i=n.host,r=()=>{
|
|
841
|
+
</p>`:""}`},Go="currentConsentId",zo=(e,t,n,i,r)=>{const o=Ro(r)?Lo:t,a=e=>{var t;const n=null===(t=e.currentTarget)||void 0===t?void 0:t.getRootNode();if(!(n instanceof ShadowRoot))return;const i=n.host,r=()=>{if("function"==typeof i.focusMessageField)return void i.focusMessageField();const e=n.getElementById("message-input");e instanceof HTMLElement&&e.getClientRects().length>0&&e.focus()},o=()=>{r(),setTimeout(r,0)};i.updateComplete?i.updateComplete.then(o):o()};return"avb"!==e||localStorage.getItem(null!=n?n:"")?"mill-creek"===e?H`<div class="legal-confirmation-inner-container">
|
|
842
842
|
<div>${Po()}</div>
|
|
843
843
|
<div>
|
|
844
844
|
<span style="font-weight: 600">Confirm to continue</span>
|
|
@@ -2414,7 +2414,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
2414
2414
|
aria-atomic="true"
|
|
2415
2415
|
>
|
|
2416
2416
|
${this._replyAnnouncement}
|
|
2417
|
-
</div>`}async updated(){this.scrollToChatBottom();try{const e=document.getElementById("#healthchat-container");if(!e)return;e.focus()}catch(e){}}trapTabInMobileDialog(e){var t;if(!this._isMobile)return;const n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat-container");n&&Xl(e,n)}render(){var e,t,n,i,r,o,a,s,l,u,d,c,h,p,f,g,m,b,y,v,w,C,x,$;if(!this.buildingSlug&&!this.centralConvo)return H``;const S=(null===(e=this.building)||void 0===e?void 0:e.userFirstName)||"Elise",A=null===(t=this.building)||void 0===t?void 0:t.id;let k={};if(k=this._isMobile?{top:void 0,bottom:0,left:void 0,right:0}:{top:void 0===this.top||isNaN(this.top)?void 0:`${this.top}px`,bottom:void 0===this.bottom||isNaN(this.bottom)?"130px":`${this.bottom}px`,left:void 0===this.left||isNaN(this.left)?void 0:`${this.left}px`,right:void 0===this.right||isNaN(this.right)?"18px":`${this.right}px`},22320===A&&(k={...k,fontFamily:'"Helvetica Neue", Arial'}),this.widgetType===fh.Utilities)return H`
|
|
2417
|
+
</div>`}async updated(){this.scrollToChatBottom();try{const e=document.getElementById("#healthchat-container");if(!e)return;e.focus()}catch(e){}}focusMessageField(){const e=this.shadowRoot,t=null==e?void 0:e.getElementById("message-input");return!!(t instanceof HTMLTextAreaElement&&e)&&(0!==t.getClientRects().length&&(e.activeElement!==t&&t.focus(),e.activeElement===t))}trapTabInMobileDialog(e){var t;if(!this._isMobile)return;const n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat-container");n&&Xl(e,n)}render(){var e,t,n,i,r,o,a,s,l,u,d,c,h,p,f,g,m,b,y,v,w,C,x,$;if(!this.buildingSlug&&!this.centralConvo)return H``;const S=(null===(e=this.building)||void 0===e?void 0:e.userFirstName)||"Elise",A=null===(t=this.building)||void 0===t?void 0:t.id;let k={};if(k=this._isMobile?{top:void 0,bottom:0,left:void 0,right:0}:{top:void 0===this.top||isNaN(this.top)?void 0:`${this.top}px`,bottom:void 0===this.bottom||isNaN(this.bottom)?"130px":`${this.bottom}px`,left:void 0===this.left||isNaN(this.left)?void 0:`${this.left}px`,right:void 0===this.right||isNaN(this.right)?"18px":`${this.right}px`},22320===A&&(k={...k,fontFamily:'"Helvetica Neue", Arial'}),this.widgetType===fh.Utilities)return H`
|
|
2418
2418
|
<div
|
|
2419
2419
|
id="utilities-container"
|
|
2420
2420
|
class=${Ce({"pubnub-container__mobile":this._isMobile,"utilities-container__desktop":!this._isMobile})}
|
|
@@ -7663,7 +7663,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7663
7663
|
cursor: pointer;
|
|
7664
7664
|
filter: brightness(90%);
|
|
7665
7665
|
}
|
|
7666
|
-
`],Uc([pe({attribute:!0})],Bc.prototype,"onClick",void 0),Uc([pe({attribute:!0})],Bc.prototype,"primaryColor",void 0),Uc([pe({attribute:!0})],Bc.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),Uc([pe({attribute:!0})],Bc.prototype,"toExpand",void 0),Bc=Uc([ce("minimize-expand-button")],Bc);const jc="cdn.skypack.dev/@meetelise/chat",Fc="cdn.eliseai.com/@meetelise/chat",Hc=async(e,t)=>{try{if(Math.random()>=.15)return;const n=(()=>{try{const e=document.getElementsByTagName("script");for(const t of e){const e=t.src||"",n=t.textContent||"";if(e.includes(jc)||n.includes(jc))return"skypack";if(e.includes(Fc)||n.includes(Fc))return"eliseai"}return"unknown"}catch(e){return"unknown"}})();await r().post("https://app.meetelise.com/platformApi/webchat/cdn-version",{cdn_version:n},{params:{cdn_version:n},headers:{"Content-Type":"application/json","building-slug":t,"org-slug":e}})}catch(e){}},Gc=(e,t)=>["floor plan","floorplan","floor plans","floorplans","apply here"].some(t=>e.toLowerCase().includes(t))?t.endsWith("/units")?t:`${t}/units`:t,zc={"95ae958e-95db-11ed-9862-6f4db5533d3f":"8008db60-45b7-11f1-88ac-635f686365da","95ae96b0-95db-11ed-9863-a7aa664fd985":"72ed27c4-45b7-11f1-82d9-37b7db547687"},Qc="https://applications.eliseai.com",Wc=["Check Availability","Apply Now"],Vc=(e,t,n,i)=>{if(!(e=>{var t;if(!e.classList.contains("floorplan-button"))return!1;const n=e.getElementsByTagName("span");if(1!==n.length)return!1;const i=null===(t=n[0].textContent)||void 0===t?void 0:t.trim();return null!=i&&Wc.includes(i)})(e))return!1;if(e.getAttribute("href")===t)return!1;const r=e.getAttribute("href");return e.setAttribute("href",t),e.setAttribute("target","_blank"),na({logTitle:"CHECK_AVAIL_OVERWRITE",logData:{oldHref:r,newHref:t,website:window.location.href},logType:ta.info,buildingSlug:i,orgSlug:n}),!0},qc=(e,t,n,i)=>{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&&Vc(a,t,n,i);const s=a.getElementsByTagName("a");for(let e=0;e<s.length;e++)Vc(s[e],t,n,i)}},Yc=(e,t,n)=>{((e,t,n)=>{const i=document.body.getElementsByTagName("a");for(let r=0;r<i.length;r++)Vc(i[r],e,t,n)})(n,e,t);new MutationObserver(i=>{for(const r of i)qc(r.addedNodes,n,e,t)}).observe(document.body,{childList:!0,subtree:!0})};class Kc{constructor(e,t){this.persistLeadSourceTTLDays=30,this.maxSourcesNonPropertyWebsiteCount=3,this._generateLeadSourceLocalStorageKey=()=>`com.eliseai.webchat.leadsources.v2.buildingslug=${this.buildingSlug}`,this._generateNewExpirationTimestamp=()=>Fr(Gr(new Date,this.persistLeadSourceTTLDays)),this._generateLeadSourceParameters=()=>{const e=xo();return{websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:e,referrer:document.referrer,parsedUtmSource:e?e.utm_source:null,campaignSources:Object.values(ea()).filter(e=>e)}},this.addSafeLeadSourceTouchpoint=e=>{const t=this.getLocalStorageMultitouchValue(),n=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(n,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(n,JSON.stringify(t));na({logType:ta.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,logTitle:"TOO_MANY_LEAD_SOURCES",logData:{buildingSlug:this.buildingSlug}})}},this.getSafeLeadSourceTouchpointsWithDefault=({includedUserSelectedLeadSource:e})=>{const t=this.getLocalStorageMultitouchValue(),n=aa(this.orgSlug);if(!t){const t=[{leadSourceValue:n,timestampInitiallyLogged:Fr(new Date),type:"default"}];return e&&t.push({leadSourceValue:e,timestampInitiallyLogged:Fr(new Date),type:"user-selected"}),t}const i=t.leadSources.length>0?t.leadSources.sort((e,t)=>Yr(e.timestampInitiallyLogged).getTime()-Yr(t.timestampInitiallyLogged).getTime())[0].timestampInitiallyLogged:Fr(new Date),r=[{timestampInitiallyLogged:i,leadSourceValue:n,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 Xc=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let Zc=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.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.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=fh.Default,this.onWidgetLoaded=uc(),this.onSstClose=uc(),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 n=this.centralConvo?await async function(e){const t=`https://app.meetelise.com/api/pub/v1/organization/${e}/webchat/v2`,n=await r().get(t);return fa(n.data)}(this.orgSlug):await pa(this.orgSlug,this.buildingSlug);if(!this.isOrgMode()){if(Math.random()<.2)try{(async(e,t)=>{const n=window.rentgrata;if(!n)return;const i=n.Widget;if(!i)return;const o=i.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{Hc(this.orgSlug,this.buildingSlug)}catch(e){}}if(!await du(n,this.buildingSlug,this.orgSlug))return;ia({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!0},sampleRate:(null==n?void 0:n.launchedDateTime)?.01:.05}),this.buildingWebchatView=n;const i=(()=>{try{const e="true"===sessionStorage.getItem(gs);return sessionStorage.removeItem(gs),e}catch{return!1}})();await this.initializeChatVariables(),await this.handleChatInitializeAnalytics(),await this.setBuildingDerivedInfo(),this.attachOnClickToLauncher(),(e=>{const t=new URLSearchParams(window.location.search),n=t.get("rwg_token"),i=t.get("elise_google_env");if(!n||!i||!e)return;const r={rwgToken:n,environment:i,buildingId:e,expiresAt:Date.now()+2592e6};localStorage.setItem(Ka,JSON.stringify(r))})(null!==(t=null===(e=this.buildingWebchatView)||void 0===e?void 0:e.id)&&void 0!==t?t:0),i?(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,n,i,o,a,s,l,u,d,c,h,p,f,g,m,b,y,v,w,C,x,$,S,A,k,E,T,_,O,P,I,N,M,D,L,R,U,B,j,F,H,G,z,Q,W,V,q,Y,K,X;const Z=this.buildingWebchatView;if(!Z)return;Z&&this.orgSlug&&!this.orgLevel&&eh(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!==(i=null===(n=this.LeadSourceClient)||void 0===n?void 0:n.leadSource)&&void 0!==i?i:null);const J=Z.featureFlagWebchatMarketingSourceDropdownConfiguration,ee=Z.featureFlagWebchatUseDniPhoneNumberBySource,te=Z.featureFlagInsertDniIntoWebsite,ne=Z.featureFlagWebchatReplaceAnyScheduleTourCtaWebsite;var ie;ie=So.includes(Z.orgId),ko=ie;const[re,oe,ae,se,le]=await Promise.all([this.isOrgMode()?Promise.resolve([]):Pc(this.orgSlug,this.buildingSlug),yo(this.buildingSlug),Nc(this.buildingSlug),wo(this.buildingSlug),Co(this.buildingSlug)]);this.buildingWebchatView&&(this.buildingWebchatView.phoneNumber=Vn(Z.phoneNumber),this.buildingWebchatView.isAip=ae),this.leadSources=re,this.featureFlagShowDropdown=J,this.bedroomPreferenceRequired=se,this.brokerIntakeEnabled=le;const ue=this.orgLevel?null:Z.textWithUsPhoneNumber?Z.textWithUsPhoneNumber:await(async e=>{try{const t="https://app.meetelise.com",n=await r().get(`${t}/platformApi/webchat/${e}/phone-number`);if(n.data)return n.data}catch(t){return na({logType:ta.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t},error:t}),null}return null})(this.buildingSlug),de=null!==(a=null===(o=this.buildingWebchatView)||void 0===o?void 0:o.shouldShowPricingCalculatorDesktop)&&void 0!==a&&a,ce=null!==(l=null===(s=this.buildingWebchatView)||void 0===s?void 0:s.shouldShowPricingCalculatorMobile)&&void 0!==l&&l,he={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)&&!!ue)&&void 0!==x&&x,textMobile:null!==(S=(null===($=this.buildingWebchatView)||void 0===$?void 0:$.shouldShowTextMobile)&&!!ue)&&void 0!==S&&S,sstDesktop:null!==(k=null===(A=this.buildingWebchatView)||void 0===A?void 0:A.shouldShowSstDesktop)&&void 0!==k&&k,sstMobile:null!==(T=null===(E=this.buildingWebchatView)||void 0===E?void 0:E.shouldShowSstMobile)&&void 0!==T&&T,calcDesktop:de,calcMobile:ce};var pe,fe;this.enabledChatWidgets=this.withOrgLevelContactOptions(mc(he),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?(Rc(this.handleTourClicked,this.orgSlug,this.buildingSlug,()=>this.isConnected),ne&&(fe=this.handleTourClicked,document.querySelectorAll('a[href$="schedule-a-tour"]').forEach(e=>{e&&e.addEventListener("click",e=>{e.preventDefault(),fe(e)})})),"radco"===this.orgSlug&&(e=>{document.querySelectorAll('a[href^="#leaseleads-tour-open"]').forEach(t=>{var n;if(!t)return;const i=document.createElement("a");i.textContent=t.textContent,i.style.cursor="pointer",i.addEventListener("click",t=>{t.preventDefault(),e(t)}),null===(n=t.parentNode)||void 0===n||n.replaceChild(i,t)})})(this.handleTourClicked)):(null===(P=this.LeadSourceClient)||void 0===P?void 0:P.leadSource)&&(pe=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 n=t.includes("?")?"&":"?";e.setAttribute("href",t+n+`eliseParsedLeadSource=${encodeURIComponent(pe)}`)}}))),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!==(U=this.buildingWebchatView.autoOpenChat)&&void 0!==U&&U,this.requiresConsent=null!==(B=this.buildingWebchatView.requiresConsentForChat)&&void 0!==B&&B,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===ua.MINIMIZED&&(this.isMinimized=!0),this.buildingWebchatView.displayStyle===ua.PILLS&&(this.designConcept=null),this.buildingWebchatView.displayStyle===ua.EMOJI&&(this.designConcept=ua.EMOJI),this.onWidgetLoaded()),null===this.primaryColor&&(this.primaryColor=Zn),null===this.backgroundColor&&(this.backgroundColor=Jn);const ge=null!==(G=null===(H=this.buildingWebchatView)||void 0===H?void 0:H.phoneNumber)&&void 0!==G?G:"";let me=null;if(ee&&!this.orgLevel&&(me=await async function(e,t){try{const n=await r().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source`,{params:{source:t}});return n.data?{number:Vn(n.data.number),isMatch:n.data.match,isPropertyWebsiteCatchall:n.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(Q=null===(z=this.LeadSourceClient)||void 0===z?void 0:z.leadSource)&&void 0!==Q?Q:null),me&&!me.isMatch&&(me.number=ge)),te&&(null==me?void 0:me.number)){const e=Lc(me.number,this.orgSlug,this.buildingSlug);e>0&&ia({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_dni_insert_override_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}const be=localStorage.getItem("eliseai_phone_number_devtest");be&&Lc(be,this.orgSlug,this.buildingSlug),this.phoneNumberForSource=me||{number:ge,isMatch:!1,isPropertyWebsiteCatchall:!0};const ye=null!==(V=null===(W=this.LeadSourceClient)||void 0===W?void 0:W.leadSource)&&void 0!==V?V:null;ye&&(this.leadSources.includes(ye)||this.leadSources.push(ye)),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,n)=>{var i;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===(i=l.textContent)||void 0===i?void 0:i.toLowerCase())||"",s=Gc(o,e);l.setAttribute("href",s),a++,na({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"link-replacement",oldHref:r,newHref:s,website:window.location.href},logType:ta.info,buildingSlug:n,orgSlug:t})}}return 0===a&&na({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"no-select-buttons-found",website:window.location.href},logType:ta.warn,buildingSlug:n,orgSlug:t}),a})(`https://applications.eliseai.com/building/${this.buildingSlug}/units`,this.orgSlug,this.buildingSlug);e>0&&ia({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=zc[e];if(!t)return 0;const n=`${Qc}/building/${t}/units`,i=`${Qc}/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(n))continue;const l=s.replace(r,i);l!==s&&(t.setAttribute("href",l),o++)}document.body.querySelectorAll("[onclick]").forEach(e=>{const t=e.getAttribute("onclick");if(!t||!t.includes(n))return;const a=t.replace(r,i);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&&Yc(this.orgSlug,this.buildingSlug,this.buildingWebchatView.applicationLink)},this.initializeChatVariables=async()=>{var e,t,n,i,r,o,a,s,l,u;if(!this.buildingWebchatView)return;const d=this.chatStorageSlug(),c=hs(d),h=ps(d,c),p=h?c:cs(d,!1);if(!p.leadId)throw new Error("Lead ID is null");if(this.LeadSourceClient=new sa,this.LeadSourceClient.orgId=null!==(t=null===(e=this.buildingWebchatView)||void 0===e?void 0:e.orgId)&&void 0!==t?t:0,this.LeadSourceMultitouchClient=new Kc(this.orgSlug,this.buildingSlug),this.myPubnub=new Ss(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!==(n=p.leadId)&&void 0!==n?n:void 0);f&&(cs(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===(i=this.LeadSourceClient)||void 0===i?void 0:i.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"!==aa(this.orgSlug)?this.myPubnub.leadSource=null!==(s=null===(a=this.LeadSourceClient)||void 0===a?void 0:a.leadSource)&&void 0!==s?s:aa(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=hs(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 n=await pa(this.orgSlug,e);if(!(null==n?void 0:n.id))return;this.buildingSlug=e,this.buildingWebchatView=n,null===(t=this.myPubnub)||void 0===t||t.adoptBuilding(e,n)}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 pa(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,n;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===(n=this.launcherRef.value)||void 0===n||n.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,n,i;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!r)return;const o=null===(i=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.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 n=(null===(e=this.launcherButton)||void 0===e?void 0:e.isConnected)?this.launcherButton:null;null===(t=null!=n?n:this.currentLauncherButton())||void 0===t||t.focus()},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,n,i;this.analytics=new Jo(this.orgSlug,this.buildingSlug,null!==(t=null===(e=this.myPubnub)||void 0===e?void 0:e.channel)&&void 0!==t?t:"",null!==(i=null===(n=this.LeadSourceClient)||void 0===n?void 0:n.leadSource)&&void 0!==i?i:null),Math.random()<.05&&this.analytics.ping("webchat_heartbeat")}async restartConversation(){var e;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),ds(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,n,i;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===(i=null===(n=null==r?void 0:r.querySelector("mobile-launcher"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.querySelector("button[aria-label='Chat with us']");return o instanceof HTMLElement?o:a instanceof HTMLElement?a:null}render(){var e,t,n,i,r,o,a,s,l,u,d,c,h,p,f,g,m,b,y,v,w,C,x,$,S,A,k,E,T,_,O,P,I,N,M,D,L,R,U,B,j,F,G,z,Q,W,V;pc();const q=this.hideLauncher&&!this.isLoading&&!this._isMobile;return H`
|
|
7666
|
+
`],Uc([pe({attribute:!0})],Bc.prototype,"onClick",void 0),Uc([pe({attribute:!0})],Bc.prototype,"primaryColor",void 0),Uc([pe({attribute:!0})],Bc.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),Uc([pe({attribute:!0})],Bc.prototype,"toExpand",void 0),Bc=Uc([ce("minimize-expand-button")],Bc);const jc="cdn.skypack.dev/@meetelise/chat",Fc="cdn.eliseai.com/@meetelise/chat",Hc=async(e,t)=>{try{if(Math.random()>=.15)return;const n=(()=>{try{const e=document.getElementsByTagName("script");for(const t of e){const e=t.src||"",n=t.textContent||"";if(e.includes(jc)||n.includes(jc))return"skypack";if(e.includes(Fc)||n.includes(Fc))return"eliseai"}return"unknown"}catch(e){return"unknown"}})();await r().post("https://app.meetelise.com/platformApi/webchat/cdn-version",{cdn_version:n},{params:{cdn_version:n},headers:{"Content-Type":"application/json","building-slug":t,"org-slug":e}})}catch(e){}},Gc=(e,t)=>["floor plan","floorplan","floor plans","floorplans","apply here"].some(t=>e.toLowerCase().includes(t))?t.endsWith("/units")?t:`${t}/units`:t,zc={"95ae958e-95db-11ed-9862-6f4db5533d3f":"8008db60-45b7-11f1-88ac-635f686365da","95ae96b0-95db-11ed-9863-a7aa664fd985":"72ed27c4-45b7-11f1-82d9-37b7db547687"},Qc="https://applications.eliseai.com",Wc=["Check Availability","Apply Now"],Vc=(e,t,n,i)=>{if(!(e=>{var t;if(!e.classList.contains("floorplan-button"))return!1;const n=e.getElementsByTagName("span");if(1!==n.length)return!1;const i=null===(t=n[0].textContent)||void 0===t?void 0:t.trim();return null!=i&&Wc.includes(i)})(e))return!1;if(e.getAttribute("href")===t)return!1;const r=e.getAttribute("href");return e.setAttribute("href",t),e.setAttribute("target","_blank"),na({logTitle:"CHECK_AVAIL_OVERWRITE",logData:{oldHref:r,newHref:t,website:window.location.href},logType:ta.info,buildingSlug:i,orgSlug:n}),!0},qc=(e,t,n,i)=>{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&&Vc(a,t,n,i);const s=a.getElementsByTagName("a");for(let e=0;e<s.length;e++)Vc(s[e],t,n,i)}},Yc=(e,t,n)=>{((e,t,n)=>{const i=document.body.getElementsByTagName("a");for(let r=0;r<i.length;r++)Vc(i[r],e,t,n)})(n,e,t);new MutationObserver(i=>{for(const r of i)qc(r.addedNodes,n,e,t)}).observe(document.body,{childList:!0,subtree:!0})};class Kc{constructor(e,t){this.persistLeadSourceTTLDays=30,this.maxSourcesNonPropertyWebsiteCount=3,this._generateLeadSourceLocalStorageKey=()=>`com.eliseai.webchat.leadsources.v2.buildingslug=${this.buildingSlug}`,this._generateNewExpirationTimestamp=()=>Fr(Gr(new Date,this.persistLeadSourceTTLDays)),this._generateLeadSourceParameters=()=>{const e=xo();return{websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:e,referrer:document.referrer,parsedUtmSource:e?e.utm_source:null,campaignSources:Object.values(ea()).filter(e=>e)}},this.addSafeLeadSourceTouchpoint=e=>{const t=this.getLocalStorageMultitouchValue(),n=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(n,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(n,JSON.stringify(t));na({logType:ta.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,logTitle:"TOO_MANY_LEAD_SOURCES",logData:{buildingSlug:this.buildingSlug}})}},this.getSafeLeadSourceTouchpointsWithDefault=({includedUserSelectedLeadSource:e})=>{const t=this.getLocalStorageMultitouchValue(),n=aa(this.orgSlug);if(!t){const t=[{leadSourceValue:n,timestampInitiallyLogged:Fr(new Date),type:"default"}];return e&&t.push({leadSourceValue:e,timestampInitiallyLogged:Fr(new Date),type:"user-selected"}),t}const i=t.leadSources.length>0?t.leadSources.sort((e,t)=>Yr(e.timestampInitiallyLogged).getTime()-Yr(t.timestampInitiallyLogged).getTime())[0].timestampInitiallyLogged:Fr(new Date),r=[{timestampInitiallyLogged:i,leadSourceValue:n,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 Xc=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let Zc=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.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.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=fh.Default,this.onWidgetLoaded=uc(),this.onSstClose=uc(),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 n=this.centralConvo?await async function(e){const t=`https://app.meetelise.com/api/pub/v1/organization/${e}/webchat/v2`,n=await r().get(t);return fa(n.data)}(this.orgSlug):await pa(this.orgSlug,this.buildingSlug);if(!this.isOrgMode()){if(Math.random()<.2)try{(async(e,t)=>{const n=window.rentgrata;if(!n)return;const i=n.Widget;if(!i)return;const o=i.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{Hc(this.orgSlug,this.buildingSlug)}catch(e){}}if(!await du(n,this.buildingSlug,this.orgSlug))return;ia({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!0},sampleRate:(null==n?void 0:n.launchedDateTime)?.01:.05}),this.buildingWebchatView=n;const i=(()=>{try{const e="true"===sessionStorage.getItem(gs);return sessionStorage.removeItem(gs),e}catch{return!1}})();await this.initializeChatVariables(),await this.handleChatInitializeAnalytics(),await this.setBuildingDerivedInfo(),this.attachOnClickToLauncher(),(e=>{const t=new URLSearchParams(window.location.search),n=t.get("rwg_token"),i=t.get("elise_google_env");if(!n||!i||!e)return;const r={rwgToken:n,environment:i,buildingId:e,expiresAt:Date.now()+2592e6};localStorage.setItem(Ka,JSON.stringify(r))})(null!==(t=null===(e=this.buildingWebchatView)||void 0===e?void 0:e.id)&&void 0!==t?t:0),i?(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,n,i,o,a,s,l,u,d,c,h,p,f,g,m,b,y,v,w,C,x,$,S,A,k,E,T,_,O,P,I,N,M,D,L,R,U,B,j,F,H,G,z,Q,W,V,q,Y,K,X;const Z=this.buildingWebchatView;if(!Z)return;Z&&this.orgSlug&&!this.orgLevel&&eh(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!==(i=null===(n=this.LeadSourceClient)||void 0===n?void 0:n.leadSource)&&void 0!==i?i:null);const J=Z.featureFlagWebchatMarketingSourceDropdownConfiguration,ee=Z.featureFlagWebchatUseDniPhoneNumberBySource,te=Z.featureFlagInsertDniIntoWebsite,ne=Z.featureFlagWebchatReplaceAnyScheduleTourCtaWebsite;var ie;ie=So.includes(Z.orgId),ko=ie;const[re,oe,ae,se,le]=await Promise.all([this.isOrgMode()?Promise.resolve([]):Pc(this.orgSlug,this.buildingSlug),yo(this.buildingSlug),Nc(this.buildingSlug),wo(this.buildingSlug),Co(this.buildingSlug)]);this.buildingWebchatView&&(this.buildingWebchatView.phoneNumber=Vn(Z.phoneNumber),this.buildingWebchatView.isAip=ae),this.leadSources=re,this.featureFlagShowDropdown=J,this.bedroomPreferenceRequired=se,this.brokerIntakeEnabled=le;const ue=this.orgLevel?null:Z.textWithUsPhoneNumber?Z.textWithUsPhoneNumber:await(async e=>{try{const t="https://app.meetelise.com",n=await r().get(`${t}/platformApi/webchat/${e}/phone-number`);if(n.data)return n.data}catch(t){return na({logType:ta.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t},error:t}),null}return null})(this.buildingSlug),de=null!==(a=null===(o=this.buildingWebchatView)||void 0===o?void 0:o.shouldShowPricingCalculatorDesktop)&&void 0!==a&&a,ce=null!==(l=null===(s=this.buildingWebchatView)||void 0===s?void 0:s.shouldShowPricingCalculatorMobile)&&void 0!==l&&l,he={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)&&!!ue)&&void 0!==x&&x,textMobile:null!==(S=(null===($=this.buildingWebchatView)||void 0===$?void 0:$.shouldShowTextMobile)&&!!ue)&&void 0!==S&&S,sstDesktop:null!==(k=null===(A=this.buildingWebchatView)||void 0===A?void 0:A.shouldShowSstDesktop)&&void 0!==k&&k,sstMobile:null!==(T=null===(E=this.buildingWebchatView)||void 0===E?void 0:E.shouldShowSstMobile)&&void 0!==T&&T,calcDesktop:de,calcMobile:ce};var pe,fe;this.enabledChatWidgets=this.withOrgLevelContactOptions(mc(he),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?(Rc(this.handleTourClicked,this.orgSlug,this.buildingSlug,()=>this.isConnected),ne&&(fe=this.handleTourClicked,document.querySelectorAll('a[href$="schedule-a-tour"]').forEach(e=>{e&&e.addEventListener("click",e=>{e.preventDefault(),fe(e)})})),"radco"===this.orgSlug&&(e=>{document.querySelectorAll('a[href^="#leaseleads-tour-open"]').forEach(t=>{var n;if(!t)return;const i=document.createElement("a");i.textContent=t.textContent,i.style.cursor="pointer",i.addEventListener("click",t=>{t.preventDefault(),e(t)}),null===(n=t.parentNode)||void 0===n||n.replaceChild(i,t)})})(this.handleTourClicked)):(null===(P=this.LeadSourceClient)||void 0===P?void 0:P.leadSource)&&(pe=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 n=t.includes("?")?"&":"?";e.setAttribute("href",t+n+`eliseParsedLeadSource=${encodeURIComponent(pe)}`)}}))),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!==(U=this.buildingWebchatView.autoOpenChat)&&void 0!==U&&U,this.requiresConsent=null!==(B=this.buildingWebchatView.requiresConsentForChat)&&void 0!==B&&B,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===ua.MINIMIZED&&(this.isMinimized=!0),this.buildingWebchatView.displayStyle===ua.PILLS&&(this.designConcept=null),this.buildingWebchatView.displayStyle===ua.EMOJI&&(this.designConcept=ua.EMOJI),this.onWidgetLoaded()),null===this.primaryColor&&(this.primaryColor=Zn),null===this.backgroundColor&&(this.backgroundColor=Jn);const ge=null!==(G=null===(H=this.buildingWebchatView)||void 0===H?void 0:H.phoneNumber)&&void 0!==G?G:"";let me=null;if(ee&&!this.orgLevel&&(me=await async function(e,t){try{const n=await r().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source`,{params:{source:t}});return n.data?{number:Vn(n.data.number),isMatch:n.data.match,isPropertyWebsiteCatchall:n.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(Q=null===(z=this.LeadSourceClient)||void 0===z?void 0:z.leadSource)&&void 0!==Q?Q:null),me&&!me.isMatch&&(me.number=ge)),te&&(null==me?void 0:me.number)){const e=Lc(me.number,this.orgSlug,this.buildingSlug);e>0&&ia({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_dni_insert_override_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}const be=localStorage.getItem("eliseai_phone_number_devtest");be&&Lc(be,this.orgSlug,this.buildingSlug),this.phoneNumberForSource=me||{number:ge,isMatch:!1,isPropertyWebsiteCatchall:!0};const ye=null!==(V=null===(W=this.LeadSourceClient)||void 0===W?void 0:W.leadSource)&&void 0!==V?V:null;ye&&(this.leadSources.includes(ye)||this.leadSources.push(ye)),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,n)=>{var i;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===(i=l.textContent)||void 0===i?void 0:i.toLowerCase())||"",s=Gc(o,e);l.setAttribute("href",s),a++,na({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"link-replacement",oldHref:r,newHref:s,website:window.location.href},logType:ta.info,buildingSlug:n,orgSlug:t})}}return 0===a&&na({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"no-select-buttons-found",website:window.location.href},logType:ta.warn,buildingSlug:n,orgSlug:t}),a})(`https://applications.eliseai.com/building/${this.buildingSlug}/units`,this.orgSlug,this.buildingSlug);e>0&&ia({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=zc[e];if(!t)return 0;const n=`${Qc}/building/${t}/units`,i=`${Qc}/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(n))continue;const l=s.replace(r,i);l!==s&&(t.setAttribute("href",l),o++)}document.body.querySelectorAll("[onclick]").forEach(e=>{const t=e.getAttribute("onclick");if(!t||!t.includes(n))return;const a=t.replace(r,i);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&&Yc(this.orgSlug,this.buildingSlug,this.buildingWebchatView.applicationLink)},this.initializeChatVariables=async()=>{var e,t,n,i,r,o,a,s,l,u;if(!this.buildingWebchatView)return;const d=this.chatStorageSlug(),c=hs(d),h=ps(d,c),p=h?c:cs(d,!1);if(!p.leadId)throw new Error("Lead ID is null");if(this.LeadSourceClient=new sa,this.LeadSourceClient.orgId=null!==(t=null===(e=this.buildingWebchatView)||void 0===e?void 0:e.orgId)&&void 0!==t?t:0,this.LeadSourceMultitouchClient=new Kc(this.orgSlug,this.buildingSlug),this.myPubnub=new Ss(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!==(n=p.leadId)&&void 0!==n?n:void 0);f&&(cs(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===(i=this.LeadSourceClient)||void 0===i?void 0:i.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"!==aa(this.orgSlug)?this.myPubnub.leadSource=null!==(s=null===(a=this.LeadSourceClient)||void 0===a?void 0:a.leadSource)&&void 0!==s?s:aa(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=hs(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 n=await pa(this.orgSlug,e);if(!(null==n?void 0:n.id))return;this.buildingSlug=e,this.buildingWebchatView=n,null===(t=this.myPubnub)||void 0===t||t.adoptBuilding(e,n)}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 pa(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,n;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===(n=this.launcherRef.value)||void 0===n||n.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,n,i;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!r)return;const o=null===(i=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.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 n=(null===(e=this.launcherButton)||void 0===e?void 0:e.isConnected)?this.launcherButton:null;null===(t=null!=n?n:this.currentLauncherButton())||void 0===t||t.focus()},this.focusMessageFieldOnOpen=()=>{var e,t;const n=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("pubnub-chat"),i=null==n?void 0:n.shadowRoot;n&&i&&(n.focusMessageField()||null===(t=i.getElementById("pubnub-chat-container"))||void 0===t||t.focus(),setTimeout(()=>{n.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,n,i;this.analytics=new Jo(this.orgSlug,this.buildingSlug,null!==(t=null===(e=this.myPubnub)||void 0===e?void 0:e.channel)&&void 0!==t?t:"",null!==(i=null===(n=this.LeadSourceClient)||void 0===n?void 0:n.leadSource)&&void 0!==i?i:null),Math.random()<.05&&this.analytics.ping("webchat_heartbeat")}async restartConversation(){var e;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),ds(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,n,i;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===(i=null===(n=null==r?void 0:r.querySelector("mobile-launcher"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.querySelector("button[aria-label='Chat with us']");return o instanceof HTMLElement?o:a instanceof HTMLElement?a:null}render(){var e,t,n,i,r,o,a,s,l,u,d,c,h,p,f,g,m,b,y,v,w,C,x,$,S,A,k,E,T,_,O,P,I,N,M,D,L,R,U,B,j,F,G,z,Q,W,V;pc();const q=this.hideLauncher&&!this.isLoading&&!this._isMobile;return H`
|
|
7667
7667
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7668
7668
|
${this.displayPubnubChat?H`
|
|
7669
7669
|
<pubnub-chat
|
|
@@ -7678,7 +7678,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7678
7678
|
.primaryColor=${this.primaryColor}
|
|
7679
7679
|
.backgroundColor=${this.backgroundColor}
|
|
7680
7680
|
.onClickExit=${this.closeChatAndRestoreFocus}
|
|
7681
|
-
.onMount=${()=>{
|
|
7681
|
+
.onMount=${()=>{this.adjustPositionChatAdditionalActions(),this.launcherButton=this.currentLauncherButton(),this.focusChatOnMount&&(this.focusChatOnMount=!1,this.focusMessageFieldOnOpen())}}
|
|
7682
7682
|
.requiresConsent=${this.requiresConsent}
|
|
7683
7683
|
.hideMobileFeatures=${this.hideMobileFeatures}
|
|
7684
7684
|
.privacyPolicyUrl=${this.privacyPolicyUrl}
|
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
import "./actions/minimize-expand-button";
|
|
47
47
|
import "./launcher/mobile-launcher";
|
|
48
48
|
import "./pubnub-chat";
|
|
49
|
+
import type { PubnubChat } from "./pubnub-chat";
|
|
49
50
|
import { getBuildingPhoneNumber } from "../getBuildingPhoneNumber";
|
|
50
51
|
import {
|
|
51
52
|
clearChatStorageKey,
|
|
@@ -1029,6 +1030,26 @@ export class MEChat extends LitElement {
|
|
|
1029
1030
|
(stored ?? this.currentLauncherButton())?.focus();
|
|
1030
1031
|
};
|
|
1031
1032
|
|
|
1033
|
+
/**
|
|
1034
|
+
* User-initiated open. The caret belongs in the message field.
|
|
1035
|
+
* While consent hides the composer, keep focus on the dialog so the agree
|
|
1036
|
+
* control is reachable. Stored consent is applied after onMount, so try
|
|
1037
|
+
* again once that paint has committed.
|
|
1038
|
+
*/
|
|
1039
|
+
private focusMessageFieldOnOpen = (): void => {
|
|
1040
|
+
const chat = this.shadowRoot?.getElementById(
|
|
1041
|
+
"pubnub-chat"
|
|
1042
|
+
) as PubnubChat | null;
|
|
1043
|
+
const root = chat?.shadowRoot;
|
|
1044
|
+
if (!chat || !root) return;
|
|
1045
|
+
if (!chat.focusMessageField()) {
|
|
1046
|
+
root.getElementById("pubnub-chat-container")?.focus();
|
|
1047
|
+
}
|
|
1048
|
+
setTimeout(() => {
|
|
1049
|
+
chat.focusMessageField();
|
|
1050
|
+
}, 0);
|
|
1051
|
+
};
|
|
1052
|
+
|
|
1032
1053
|
private closeChatAndRestoreFocus = (): void => {
|
|
1033
1054
|
this.onExitChat();
|
|
1034
1055
|
void this.updateComplete.then(() => {
|
|
@@ -1078,10 +1099,7 @@ export class MEChat extends LitElement {
|
|
|
1078
1099
|
this.launcherButton = this.currentLauncherButton();
|
|
1079
1100
|
if (!this.focusChatOnMount) return;
|
|
1080
1101
|
this.focusChatOnMount = false;
|
|
1081
|
-
this.
|
|
1082
|
-
?.getElementById("pubnub-chat")
|
|
1083
|
-
?.shadowRoot?.getElementById("pubnub-chat-container")
|
|
1084
|
-
?.focus();
|
|
1102
|
+
this.focusMessageFieldOnOpen();
|
|
1085
1103
|
}}
|
|
1086
1104
|
.requiresConsent=${this.requiresConsent}
|
|
1087
1105
|
.hideMobileFeatures=${this.hideMobileFeatures}
|
|
@@ -301,6 +301,17 @@ export class PubnubChat extends LitElement {
|
|
|
301
301
|
return this.requiresConsent && !this.hasReceivedConsent;
|
|
302
302
|
};
|
|
303
303
|
|
|
304
|
+
/** Caret in the message field when the composer is on screen. */
|
|
305
|
+
focusMessageField(): boolean {
|
|
306
|
+
const root = this.shadowRoot;
|
|
307
|
+
const input = root?.getElementById("message-input");
|
|
308
|
+
if (!(input instanceof HTMLTextAreaElement) || !root) return false;
|
|
309
|
+
// Consent hides the footer with display:none. Focusing it would no-op.
|
|
310
|
+
if (input.getClientRects().length === 0) return false;
|
|
311
|
+
if (root.activeElement !== input) input.focus();
|
|
312
|
+
return root.activeElement === input;
|
|
313
|
+
}
|
|
314
|
+
|
|
304
315
|
/** Tab cycles inside the fullscreen mobile dialog. Desktop stays non-modal. */
|
|
305
316
|
private trapTabInMobileDialog(event: KeyboardEvent): void {
|
|
306
317
|
if (!this._isMobile) return;
|
package/src/chatKeyboard.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { expect } from "@esm-bundle/chai";
|
|
2
2
|
import { sendKeys } from "@web/test-runner-commands";
|
|
3
3
|
import "../public/dist/index";
|
|
4
|
+
import { CURRENT_CONSENT_ID } from "./disclaimers";
|
|
4
5
|
import type { BuildingWebchatView } from "./fetchBuildingWebchatView";
|
|
5
6
|
import type { MEChat } from "./WebComponent/me-chat";
|
|
6
7
|
import type { MESelect } from "./WebComponent/me-select";
|
|
@@ -17,6 +18,7 @@ type MeChatTest = MEChat & {
|
|
|
17
18
|
buildingSlug: string;
|
|
18
19
|
orgSlug: string;
|
|
19
20
|
focusChatOnMount: boolean;
|
|
21
|
+
requiresConsent: boolean;
|
|
20
22
|
launcherButton: HTMLElement | null;
|
|
21
23
|
hideLauncher: boolean;
|
|
22
24
|
isLoading: boolean;
|
|
@@ -34,6 +36,11 @@ const building = {
|
|
|
34
36
|
tourTypeOptions: [],
|
|
35
37
|
} as unknown as BuildingWebchatView;
|
|
36
38
|
|
|
39
|
+
const nextTask = (): Promise<void> =>
|
|
40
|
+
new Promise((resolve) => {
|
|
41
|
+
setTimeout(resolve, 0);
|
|
42
|
+
});
|
|
43
|
+
|
|
37
44
|
const deepActive = (): Element | null => {
|
|
38
45
|
let active: Element | null = document.activeElement;
|
|
39
46
|
while (active?.shadowRoot?.activeElement) {
|
|
@@ -203,7 +210,7 @@ it("makes the mobile dialog modal and wraps Tab inside it", async () => {
|
|
|
203
210
|
expect(deepActive()).to.equal(outside);
|
|
204
211
|
});
|
|
205
212
|
|
|
206
|
-
it("focuses the
|
|
213
|
+
it("focuses the message field on a user open and not on auto-open", async () => {
|
|
207
214
|
const pageInput = document.createElement("input");
|
|
208
215
|
document.body.appendChild(pageInput);
|
|
209
216
|
pageInput.focus();
|
|
@@ -234,10 +241,90 @@ it("focuses the chat on a user open and not on auto-open", async () => {
|
|
|
234
241
|
"pubnub-chat"
|
|
235
242
|
) as PubnubChat;
|
|
236
243
|
await reopened.updateComplete;
|
|
237
|
-
|
|
244
|
+
await nextTask();
|
|
245
|
+
expect(deepActive()?.id).to.equal("message-input");
|
|
238
246
|
expect(widget.focusChatOnMount).to.equal(false);
|
|
239
247
|
});
|
|
240
248
|
|
|
249
|
+
it("focuses the message field on open when consent is already stored", async () => {
|
|
250
|
+
const consentKey = "stored-consent-orgConsent";
|
|
251
|
+
localStorage.setItem(
|
|
252
|
+
consentKey,
|
|
253
|
+
JSON.stringify({
|
|
254
|
+
consentGiven: true,
|
|
255
|
+
timestamp: Date.now(),
|
|
256
|
+
consentId: CURRENT_CONSENT_ID,
|
|
257
|
+
})
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
const pageInput = document.createElement("input");
|
|
261
|
+
document.body.appendChild(pageInput);
|
|
262
|
+
pageInput.focus();
|
|
263
|
+
|
|
264
|
+
(window as unknown as { eliseAi: Record<string, unknown> }).eliseAi = {};
|
|
265
|
+
const widget = document.createElement("me-chat") as MeChatTest;
|
|
266
|
+
document.body.appendChild(widget);
|
|
267
|
+
await widget.updateComplete;
|
|
268
|
+
widget.buildingSlug = "test-building";
|
|
269
|
+
widget.orgSlug = "stored-consent-org";
|
|
270
|
+
widget.primaryColor = "#646987";
|
|
271
|
+
widget.backgroundColor = "#ffffff";
|
|
272
|
+
widget.buildingWebchatView = building;
|
|
273
|
+
widget.requiresConsent = true;
|
|
274
|
+
widget.focusChatOnMount = false;
|
|
275
|
+
widget.displayPubnubChat = true;
|
|
276
|
+
await widget.updateComplete;
|
|
277
|
+
const pubnub = widget.shadowRoot?.getElementById("pubnub-chat") as PubnubChat;
|
|
278
|
+
await pubnub.updateComplete;
|
|
279
|
+
await nextTask();
|
|
280
|
+
expect(deepActive()).to.equal(pageInput);
|
|
281
|
+
|
|
282
|
+
widget.displayPubnubChat = false;
|
|
283
|
+
await widget.updateComplete;
|
|
284
|
+
widget.focusChatOnMount = true;
|
|
285
|
+
widget.displayPubnubChat = true;
|
|
286
|
+
await widget.updateComplete;
|
|
287
|
+
const reopened = widget.shadowRoot?.getElementById(
|
|
288
|
+
"pubnub-chat"
|
|
289
|
+
) as PubnubChat;
|
|
290
|
+
await reopened.updateComplete;
|
|
291
|
+
await nextTask();
|
|
292
|
+
expect(deepActive()?.id).to.equal("message-input");
|
|
293
|
+
localStorage.removeItem(consentKey);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it("focuses the dialog until consent, then the message field", async () => {
|
|
297
|
+
localStorage.removeItem("consent-gate-orgConsent");
|
|
298
|
+
(window as unknown as { eliseAi: Record<string, unknown> }).eliseAi = {};
|
|
299
|
+
const widget = document.createElement("me-chat") as MeChatTest;
|
|
300
|
+
document.body.appendChild(widget);
|
|
301
|
+
await widget.updateComplete;
|
|
302
|
+
widget.buildingSlug = "test-building";
|
|
303
|
+
widget.orgSlug = "consent-gate-org";
|
|
304
|
+
widget.primaryColor = "#646987";
|
|
305
|
+
widget.backgroundColor = "#ffffff";
|
|
306
|
+
widget.buildingWebchatView = building;
|
|
307
|
+
widget.requiresConsent = true;
|
|
308
|
+
widget.focusChatOnMount = true;
|
|
309
|
+
widget.displayPubnubChat = true;
|
|
310
|
+
await widget.updateComplete;
|
|
311
|
+
const pubnub = widget.shadowRoot?.getElementById("pubnub-chat") as PubnubChat;
|
|
312
|
+
await pubnub.updateComplete;
|
|
313
|
+
await nextTask();
|
|
314
|
+
expect(deepActive()?.id).to.equal("pubnub-chat-container");
|
|
315
|
+
|
|
316
|
+
const agree = pubnub.shadowRoot?.querySelector(
|
|
317
|
+
".agreeButton"
|
|
318
|
+
) as HTMLButtonElement | null;
|
|
319
|
+
expect(agree?.textContent?.trim()).to.equal("I agree");
|
|
320
|
+
agree?.click();
|
|
321
|
+
await pubnub.updateComplete;
|
|
322
|
+
await nextTask();
|
|
323
|
+
expect(deepActive()?.id).to.equal("message-input");
|
|
324
|
+
const footer = pubnub.shadowRoot?.getElementById("footer");
|
|
325
|
+
expect(footer?.classList.contains("hidden")).to.equal(false);
|
|
326
|
+
});
|
|
327
|
+
|
|
241
328
|
it("returns focus to the launcher from Minimize chat", async () => {
|
|
242
329
|
const launcher = document.createElement("button");
|
|
243
330
|
launcher.textContent = "Chat with us";
|
|
@@ -274,6 +361,49 @@ it("returns focus to the launcher from Minimize chat", async () => {
|
|
|
274
361
|
expect(deepActive()).to.equal(launcher);
|
|
275
362
|
});
|
|
276
363
|
|
|
364
|
+
it("returns focus to the launcher on Escape", async () => {
|
|
365
|
+
const launcher = document.createElement("button");
|
|
366
|
+
launcher.setAttribute("aria-label", "Chat with us");
|
|
367
|
+
launcher.textContent = "Chat with us";
|
|
368
|
+
document.body.appendChild(launcher);
|
|
369
|
+
|
|
370
|
+
(window as unknown as { eliseAi: Record<string, unknown> }).eliseAi = {};
|
|
371
|
+
const widget = document.createElement("me-chat") as MeChatTest;
|
|
372
|
+
document.body.appendChild(widget);
|
|
373
|
+
await widget.updateComplete;
|
|
374
|
+
widget.buildingSlug = "test-building";
|
|
375
|
+
widget.orgSlug = "test-org";
|
|
376
|
+
widget.primaryColor = "#646987";
|
|
377
|
+
widget.backgroundColor = "#ffffff";
|
|
378
|
+
widget.buildingWebchatView = building;
|
|
379
|
+
widget._isMobile = false;
|
|
380
|
+
widget.isLoading = false;
|
|
381
|
+
widget.hideLauncher = true;
|
|
382
|
+
widget.displayPubnubChat = true;
|
|
383
|
+
await widget.updateComplete;
|
|
384
|
+
widget.launcherButton = launcher;
|
|
385
|
+
|
|
386
|
+
const pubnub = widget.shadowRoot?.getElementById("pubnub-chat") as PubnubChat;
|
|
387
|
+
await pubnub.updateComplete;
|
|
388
|
+
const container = pubnub.shadowRoot?.getElementById(
|
|
389
|
+
"pubnub-chat-container"
|
|
390
|
+
) as HTMLElement;
|
|
391
|
+
const input = pubnub.shadowRoot?.getElementById(
|
|
392
|
+
"message-input"
|
|
393
|
+
) as HTMLTextAreaElement;
|
|
394
|
+
input.focus();
|
|
395
|
+
container.dispatchEvent(
|
|
396
|
+
new KeyboardEvent("keydown", {
|
|
397
|
+
key: "Escape",
|
|
398
|
+
bubbles: true,
|
|
399
|
+
composed: true,
|
|
400
|
+
})
|
|
401
|
+
);
|
|
402
|
+
await widget.updateComplete;
|
|
403
|
+
expect(widget.displayPubnubChat).to.equal(false);
|
|
404
|
+
expect(deepActive()).to.equal(launcher);
|
|
405
|
+
});
|
|
406
|
+
|
|
277
407
|
it("moves Tab from an open, scrolling select to the next control", async () => {
|
|
278
408
|
const select = document.createElement("me-select") as MESelect & {
|
|
279
409
|
updateComplete: Promise<boolean>;
|
package/src/disclaimers.ts
CHANGED
|
@@ -319,14 +319,28 @@ export const getConsentPreChatDisclaimer = (
|
|
|
319
319
|
if (!(root instanceof ShadowRoot)) return;
|
|
320
320
|
const host = root.host as HTMLElement & {
|
|
321
321
|
updateComplete?: Promise<unknown>;
|
|
322
|
+
focusMessageField?: () => boolean;
|
|
322
323
|
};
|
|
324
|
+
// The agree control is what has focus. Hiding it sends focus to the dialog
|
|
325
|
+
// (tabindex=-1). Move the caret to the message field after that.
|
|
323
326
|
const focus = (): void => {
|
|
324
|
-
|
|
327
|
+
if (typeof host.focusMessageField === "function") {
|
|
328
|
+
host.focusMessageField();
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
const input = root.getElementById("message-input");
|
|
332
|
+
if (input instanceof HTMLElement && input.getClientRects().length > 0) {
|
|
333
|
+
input.focus();
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
const afterUpdate = (): void => {
|
|
337
|
+
focus();
|
|
338
|
+
setTimeout(focus, 0);
|
|
325
339
|
};
|
|
326
340
|
if (host.updateComplete) {
|
|
327
|
-
void host.updateComplete.then(
|
|
341
|
+
void host.updateComplete.then(afterUpdate);
|
|
328
342
|
} else {
|
|
329
|
-
|
|
343
|
+
afterUpdate();
|
|
330
344
|
}
|
|
331
345
|
};
|
|
332
346
|
|