@meetelise/chat 1.22.70 → 1.22.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/public/demo/index.html
CHANGED
|
@@ -173,8 +173,9 @@
|
|
|
173
173
|
};
|
|
174
174
|
|
|
175
175
|
MEChat.start({
|
|
176
|
-
organization: "
|
|
177
|
-
building: "
|
|
176
|
+
organization: "bell",
|
|
177
|
+
building: "to-be-updated+12",
|
|
178
|
+
|
|
178
179
|
// organization: "Pacific Urban Residential",
|
|
179
180
|
// building: "c06117dc-7a80-11ed-bc9a-c3e28c7281ff",
|
|
180
181
|
|
package/public/dist/index.js
CHANGED
|
@@ -975,7 +975,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
975
975
|
gap: 12px;
|
|
976
976
|
align-items: center;
|
|
977
977
|
}
|
|
978
|
-
`;class Yi{constructor(e,t,i,n){this.org=e,this.building=t,this.chatId=i,this.incomingProcessedLeadSource=n,this.featureFlags={}}setFeatureFlags(e){this.featureFlags={...this.featureFlags,...e}}ping(e){var t;fetch("https://app.meetelise.com/platformApi/connectors/talk_js/analytics",{method:"POST",credentials:"omit",keepalive:!0,headers:{"content-type":"application/json; charset=UTF-8"},body:JSON.stringify({eventType:e,chatId:this.chatId,url:location.href,org:this.org,building:this.building,referrer:document.referrer,featureFlags:this.featureFlags,campaignSources:$i(),incomingProcessedLeadSource:this.incomingProcessedLeadSource,webchatVersion:null!==(t="MISSING_ENV_VAR".npm_package_version)&&void 0!==t?t:"1.20.155"})})}}const $i=()=>{var e,t,i,n,r,o;try{const n=new URL(window.location.href).searchParams,r=null!==(i=null===(t=null===(e=window.RCTPCampaign)||void 0===e?void 0:e.CampaignDetails)||void 0===t?void 0:t.Source)&&void 0!==i?i:null,o=n.get("switch_cls[id]"),a=n.get("ilm");return{entrataCampaignSource:o,realpageCampaignSource:a,utmCampaignSource:n.get("utm_source"),yardiCampaignSource:r,bozzutoAdSource:ri("bozzuto_ad_source")}}catch(e){console.warn(`Couldnt get campaign sources from url, error: ${e}`);const t=document.createElement("iframe");if(t.style.display="none",document.body.appendChild(t),!t.contentWindow)return{entrataCampaignSource:null,realpageCampaignSource:null,utmCampaignSource:null,yardiCampaignSource:null,bozzutoAdSource:null};const i=t.contentWindow.URL;if(!i)return{entrataCampaignSource:null,realpageCampaignSource:null,utmCampaignSource:null,yardiCampaignSource:null,bozzutoAdSource:null};const a=new i(window.location.href).searchParams,s=null!==(o=null===(r=null===(n=window.RCTPCampaign)||void 0===n?void 0:n.CampaignDetails)||void 0===r?void 0:r.Source)&&void 0!==o?o:null;return{entrataCampaignSource:a.get("switch_cls[id]"),realpageCampaignSource:a.get("ilm"),utmCampaignSource:a.get("utm_source"),yardiCampaignSource:s,bozzutoAdSource:ri("bozzuto_ad_source")}}};var Zi;!function(e){e.error="error",e.info="info",e.warn="warn"}(Zi||(Zi={}));const en=async({logType:e,buildingSlug:i,orgSlug:n,logTitle:r,logData:o})=>{await t().post("https://app.meetelise.com/platformApi/webchat/logging",{...o},{headers:{"Content-Type":"application/json","building-slug":null!=i?i:"","org-slug":null!=n?n:"","log-type":null!=e?e:Zi.error,"log-title":r.toUpperCase().replace(/\s/g,"_")}})},tn=async({params:e,sampleRate:i})=>{try{if(Math.random()>=i)return;await t().post("https://app.meetelise.com/platformApi/webchat/log/signal",{...e,website_origin:window.location.origin,website_search:window.location.search})}catch(e){console.warn(e)}};function nn(){return rn()?function(){const e=window.location.search,t={};return e.split("?").slice(1).join("&").split("&").forEach((e=>{const[i,n]=e.split("=");i&&n&&(t[decodeURIComponent(i)]=decodeURIComponent(n))})),t}():function(){const e=new URLSearchParams(window.location.search),t=e.has("utm_content"),i=e.has("utm_source");if(t&&!i){const t=e.get("utm_content");e.delete("utm_content"),e.set("utm_source",t)}return Object.fromEntries(e)}()}const rn=()=>(window.location.search.match(/\?/g)||[]).length>1;var on=i(8367),an=i.n(on);function sn(e){return"avb"===e?"AVB Company Website":"property-website"}const ln=async(e,i=!1)=>{const n=`https://app.meetelise.com/eliseCrmApi/building/${e}/scheduling_status?observe_dynamic_scheduling=${i}`;try{return(await t().get(n)).data.is_enabled}catch(e){return!1}};var un=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 dn=class extends re{constructor(){super(...arguments),this.tourTypeOptions=[],this.chatId="",this.buildingId=0,this.buildingSlug="",this.sgtUrl="",this.selfGuidedToursTypeOffered="",this.selfGuidedTourEnabled=!1,this.escortedToursLink="",this.virtualToursLink="",this.orgSlug="",this.hasDynamicSchedulingEnabled=!1,this.leadSourceClient=null,this.buildingName="",this.tourType=null,this.shouldShowTourType={[cn.Guided]:!0,[cn.Self]:!0,[cn.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.waitingForAvailabilities=!0,this.mobilePageIndex=0,this.isSubmitting=!1,this.tourIsBooked=!1,this.shouldAllowScheduling=!1,this.shouldAllowScheduleLoading=!0,this.promptForReschedule=!1,this.canceledReschedule=!1,this.leadSources=[],this.orgLegalName="",this.currentLeadSource="",this.featureFlagShowDropdown="",this.compactDesign=!1,this.primaryColor=Me,this.backgroundColor=Fe,this.foregroundColorOnPrimaryBackgroundColor="white",this.foregroundColorOnSecondaryBackgroundColor="black",this.firstNameInputValue="",this.lastNameInputValue="",this.leadSourceInputValue="",this.errorGettingAvailabilities=!1,this.firstUpdated=async()=>{try{const[e,t]=await Promise.all([ln(this.buildingId,this.hasDynamicSchedulingEnabled),Mi()]);this.shouldAllowScheduling=e,this.shouldAllowScheduleLoading=!1,en({logTitle:"AVAILABILITIES_EXIST_FOR_TOUR_TYPE",logData:t,logType:Zi.info,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});const i=Object.values(t).every((e=>!1===e)),n=!this.sgtUrl&&!this.escortedToursLink&&!this.virtualToursLink;if(i&&n)return this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,void en({logTitle:"NO_AVAILABILITIES_EXIST",logData:null,logType:Zi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});if(this.shouldShowTourType={[cn.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&(t[cn.Guided]||!!this.escortedToursLink),[cn.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&(t[cn.Self]||!!this.sgtUrl),[cn.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&(t[cn.Virtual]||!!this.virtualToursLink)},1===Object.values(this.shouldShowTourType).reduce(((e,t)=>!0===t?e+1:e),0)&&(this.tourType=Object.keys(this.shouldShowTourType).find((e=>this.shouldShowTourType[e]))),null===this.tourType)return void(this.waitingForAvailabilities=!1);this.availabilitiesGroupedByDay=await Fi(pn[this.tourType]),this.waitingForAvailabilities=!1}catch(e){this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,en({logTitle:"ERROR_LOADING_AVAILABILITIES",logData:{error:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await Fi(pn[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const i=e.target.selectionStart;if(1!==e.key.length||Re(e)){if("Backspace"===e.key){if(Re(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,n=this.phoneNumber.slice(0,i).replace(/\D/g,""),r=this.phoneNumber.slice(i).replace(/\D/g,""),o=`${n.slice(0,-1)}${r}`;this.phoneNumber=Ie(o),this.phoneInput.value=this.phoneNumber;const a=i-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Re(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,i).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,n=i-e>-1?i-e:0;this.phoneInput.setSelectionRange(n,n)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(i).split(/\d+/)[0].length||0)+1,t=i+e<this.phoneNumber.length?i+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,i)+e.key+this.phoneNumber.slice(i);this.phoneNumber=Ie(t.replace(/\D/g,"")),this.phoneInput.value=this.phoneNumber}},this.handlePhoneKeyup=e=>{var t;if(!e.key)return;if(e.key.includes("Arrow")||["Meta","Shift","Control","Alt"].includes(e.key))return;const i=this.phoneInput.selectionStart,n=i?this.phoneInput.value.slice(i).replace(/\D/g,""):"";this.phoneNumber=Ie(this.phoneInput.value);let r=0,o=n.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>null!==this.tourType,dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t,i;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&(null===(i=this.emailInput)||void 0===i?void 0:i.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length&&oi(this.phoneNumber)}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,i]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(i)]},this.submit=async()=>{var e,i,n,r,o,a,s,l,u,d,c,p,h,f,m;if(!this.selectedDate||!this.selectedTime||null===this.tourType)return;const g=new URLSearchParams(window.location.search);let v=null;v=this.selectedLeadSource&&this.selectedLeadSource.value&&this.selectedLeadSource.value.length>0?this.selectedLeadSource.value:this.leadSourceInputValue&&this.leadSourceInputValue.length>0?this.leadSourceInputValue:this.currentLeadSource;const y=[...new Set(v?[v,"property-website"]:["property-website"])];this.firstNameInput&&(this.firstNameInputValue=this.firstNameInput.value),this.lastNameInput&&(this.lastNameInputValue=this.lastNameInput.value),this.leadSourceInputValue=v,Wi("scheduleTourSubmitted",{email:this.email,phone:`+1${null===(e=this.phoneNumber.match(/\d/g))||void 0===e?void 0:e.join("")}`,firstName:null!==(n=null===(i=this.firstNameInput)||void 0===i?void 0:i.value)&&void 0!==n?n:this.firstNameInputValue,lastName:null!==(o=null===(r=this.lastNameInput)||void 0===r?void 0:r.value)&&void 0!==o?o:this.lastNameInputValue,tourType:hn[this.tourType],tourTime:`${this.selectedTime.datetime}${this.selectedTime.offset}`,originatingSource:y.find((e=>"property-website"!==e))||null});const b={referrer:document.referrer,email_address:this.email,phone_number:`+1${null===(a=this.phoneNumber.match(/\d/g))||void 0===a?void 0:a.join("")}`,building_id:this.buildingId,first_name:null!==(l=null===(s=this.firstNameInput)||void 0===s?void 0:s.value)&&void 0!==l?l:this.firstNameInputValue,last_name:null!==(d=null===(u=this.lastNameInput)||void 0===u?void 0:u.value)&&void 0!==d?d:this.lastNameInputValue,tour_type:hn[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,cancel_existing_tours:this.promptForReschedule,lead_sources:[...new Set(v?[v,sn(this.orgSlug)]:[sn(this.orgSlug)])],query_params:Object.fromEntries(g.entries()),conversation_tracking_id:null===(c=this.leadSourceClient)||void 0===c?void 0:c.chatId};this.isSubmitting=!0;try{await t().post("https://app.meetelise.com/platformApi/state/create/v2/scheduleMe",b,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG","org-slug":this.orgSlug}}),null===(p=this.leadSourceClient)||void 0===p||p.checkAndHandleForLogLeadSource({webchatAction:"tour-scheduler",stateId:null}),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e,i=(null===(f=null===(h=t.response)||void 0===h?void 0:h.data)||void 0===f?void 0:f.detail)||"Failed to book tour";if(t.response&&t.response.headers&&t.response.headers["funnel-prospect-conflicting-appointment-error"]){if(this.selectedDate&&this.selectedTime){const e=this.availabilitiesGroupedByDay[jt(this.selectedDate,"yyyy-MM-dd")];e&&(this.availabilitiesGroupedByDay[jt(this.selectedDate,"yyyy-MM-dd")]=e.filter((e=>e!==this.selectedTime)))}}else if(409===(null===(m=t.response)||void 0===m?void 0:m.status)&&!this.promptForReschedule)return this.promptForReschedule=!0,this.isSubmitting=!1,void(this.tourIsBooked=!1);alert(i),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>U`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>U`${this.dateAndTimeMenu()}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>U` <action-confirm-button
|
|
978
|
+
`;class Yi{constructor(e,t,i,n){this.org=e,this.building=t,this.chatId=i,this.incomingProcessedLeadSource=n,this.featureFlags={}}setFeatureFlags(e){this.featureFlags={...this.featureFlags,...e}}ping(e){var t;fetch("https://app.meetelise.com/platformApi/connectors/talk_js/analytics",{method:"POST",credentials:"omit",keepalive:!0,headers:{"content-type":"application/json; charset=UTF-8"},body:JSON.stringify({eventType:e,chatId:this.chatId,url:location.href,org:this.org,building:this.building,referrer:document.referrer,featureFlags:this.featureFlags,campaignSources:$i(),incomingProcessedLeadSource:this.incomingProcessedLeadSource,webchatVersion:null!==(t="MISSING_ENV_VAR".npm_package_version)&&void 0!==t?t:"1.20.155"})})}}const $i=()=>{var e,t,i,n,r,o;try{const n=new URL(window.location.href).searchParams,r=null!==(i=null===(t=null===(e=window.RCTPCampaign)||void 0===e?void 0:e.CampaignDetails)||void 0===t?void 0:t.Source)&&void 0!==i?i:null,o=n.get("switch_cls[id]"),a=n.get("ilm");return{entrataCampaignSource:o,realpageCampaignSource:a,utmCampaignSource:n.get("utm_source"),yardiCampaignSource:r,bozzutoAdSource:ri("bozzuto_ad_source")}}catch(e){console.warn(`Couldnt get campaign sources from url, error: ${e}`);const t=document.createElement("iframe");if(t.style.display="none",document.body.appendChild(t),!t.contentWindow)return{entrataCampaignSource:null,realpageCampaignSource:null,utmCampaignSource:null,yardiCampaignSource:null,bozzutoAdSource:null};const i=t.contentWindow.URL;if(!i)return{entrataCampaignSource:null,realpageCampaignSource:null,utmCampaignSource:null,yardiCampaignSource:null,bozzutoAdSource:null};const a=new i(window.location.href).searchParams,s=null!==(o=null===(r=null===(n=window.RCTPCampaign)||void 0===n?void 0:n.CampaignDetails)||void 0===r?void 0:r.Source)&&void 0!==o?o:null;return{entrataCampaignSource:a.get("switch_cls[id]"),realpageCampaignSource:a.get("ilm"),utmCampaignSource:a.get("utm_source"),yardiCampaignSource:s,bozzutoAdSource:ri("bozzuto_ad_source")}}};var Zi;!function(e){e.error="error",e.info="info",e.warn="warn"}(Zi||(Zi={}));const en=async({logType:e,buildingSlug:i,orgSlug:n,logTitle:r,logData:o})=>{await t().post("https://app.meetelise.com/platformApi/webchat/logging",{...o},{headers:{"Content-Type":"application/json","building-slug":null!=i?i:"","org-slug":null!=n?n:"","log-type":null!=e?e:Zi.error,"log-title":r.toUpperCase().replace(/\s/g,"_")}})},tn=async({params:e,sampleRate:i})=>{try{if(Math.random()>=i)return;await t().post("https://app.meetelise.com/platformApi/webchat/log/signal",{...e,website_origin:window.location.origin,website_search:window.location.search})}catch(e){console.warn(e)}};function nn(){return rn()?function(){const e=window.location.search,t={};return e.split("?").slice(1).join("&").split("&").forEach((e=>{const[i,n]=e.split("=");i&&n&&(t[decodeURIComponent(i)]=decodeURIComponent(n))})),t}():function(){const e=new URLSearchParams(window.location.search),t=e.has("utm_content"),i=e.has("utm_source");if(t&&!i){const t=e.get("utm_content");e.delete("utm_content"),e.set("utm_source",t)}return Object.fromEntries(e)}()}const rn=()=>(window.location.search.match(/\?/g)||[]).length>1;var on=i(8367),an=i.n(on);function sn(e){return"avb"===e?"AVB Company Website":"windsor"===e?"Windsorcommunities.com":"property-website"}const ln=async(e,i=!1)=>{const n=`https://app.meetelise.com/eliseCrmApi/building/${e}/scheduling_status?observe_dynamic_scheduling=${i}`;try{return(await t().get(n)).data.is_enabled}catch(e){return!1}};var un=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 dn=class extends re{constructor(){super(...arguments),this.tourTypeOptions=[],this.chatId="",this.buildingId=0,this.buildingSlug="",this.sgtUrl="",this.selfGuidedToursTypeOffered="",this.selfGuidedTourEnabled=!1,this.escortedToursLink="",this.virtualToursLink="",this.orgSlug="",this.hasDynamicSchedulingEnabled=!1,this.leadSourceClient=null,this.buildingName="",this.tourType=null,this.shouldShowTourType={[cn.Guided]:!0,[cn.Self]:!0,[cn.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.waitingForAvailabilities=!0,this.mobilePageIndex=0,this.isSubmitting=!1,this.tourIsBooked=!1,this.shouldAllowScheduling=!1,this.shouldAllowScheduleLoading=!0,this.promptForReschedule=!1,this.canceledReschedule=!1,this.leadSources=[],this.orgLegalName="",this.currentLeadSource="",this.featureFlagShowDropdown="",this.compactDesign=!1,this.primaryColor=Me,this.backgroundColor=Fe,this.foregroundColorOnPrimaryBackgroundColor="white",this.foregroundColorOnSecondaryBackgroundColor="black",this.firstNameInputValue="",this.lastNameInputValue="",this.leadSourceInputValue="",this.errorGettingAvailabilities=!1,this.firstUpdated=async()=>{try{const[e,t]=await Promise.all([ln(this.buildingId,this.hasDynamicSchedulingEnabled),Mi()]);this.shouldAllowScheduling=e,this.shouldAllowScheduleLoading=!1,en({logTitle:"AVAILABILITIES_EXIST_FOR_TOUR_TYPE",logData:t,logType:Zi.info,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});const i=Object.values(t).every((e=>!1===e)),n=!this.sgtUrl&&!this.escortedToursLink&&!this.virtualToursLink;if(i&&n)return this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,void en({logTitle:"NO_AVAILABILITIES_EXIST",logData:null,logType:Zi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});if(this.shouldShowTourType={[cn.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&(t[cn.Guided]||!!this.escortedToursLink),[cn.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&(t[cn.Self]||!!this.sgtUrl),[cn.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&(t[cn.Virtual]||!!this.virtualToursLink)},1===Object.values(this.shouldShowTourType).reduce(((e,t)=>!0===t?e+1:e),0)&&(this.tourType=Object.keys(this.shouldShowTourType).find((e=>this.shouldShowTourType[e]))),null===this.tourType)return void(this.waitingForAvailabilities=!1);this.availabilitiesGroupedByDay=await Fi(pn[this.tourType]),this.waitingForAvailabilities=!1}catch(e){this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,en({logTitle:"ERROR_LOADING_AVAILABILITIES",logData:{error:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await Fi(pn[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const i=e.target.selectionStart;if(1!==e.key.length||Re(e)){if("Backspace"===e.key){if(Re(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,n=this.phoneNumber.slice(0,i).replace(/\D/g,""),r=this.phoneNumber.slice(i).replace(/\D/g,""),o=`${n.slice(0,-1)}${r}`;this.phoneNumber=Ie(o),this.phoneInput.value=this.phoneNumber;const a=i-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Re(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,i).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,n=i-e>-1?i-e:0;this.phoneInput.setSelectionRange(n,n)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(i).split(/\d+/)[0].length||0)+1,t=i+e<this.phoneNumber.length?i+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,i)+e.key+this.phoneNumber.slice(i);this.phoneNumber=Ie(t.replace(/\D/g,"")),this.phoneInput.value=this.phoneNumber}},this.handlePhoneKeyup=e=>{var t;if(!e.key)return;if(e.key.includes("Arrow")||["Meta","Shift","Control","Alt"].includes(e.key))return;const i=this.phoneInput.selectionStart,n=i?this.phoneInput.value.slice(i).replace(/\D/g,""):"";this.phoneNumber=Ie(this.phoneInput.value);let r=0,o=n.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>null!==this.tourType,dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t,i;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&(null===(i=this.emailInput)||void 0===i?void 0:i.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length&&oi(this.phoneNumber)}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,i]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(i)]},this.submit=async()=>{var e,i,n,r,o,a,s,l,u,d,c,p,h,f,m;if(!this.selectedDate||!this.selectedTime||null===this.tourType)return;const g=new URLSearchParams(window.location.search);let v=null;v=this.selectedLeadSource&&this.selectedLeadSource.value&&this.selectedLeadSource.value.length>0?this.selectedLeadSource.value:this.leadSourceInputValue&&this.leadSourceInputValue.length>0?this.leadSourceInputValue:this.currentLeadSource;const y=[...new Set(v?[v,"property-website"]:["property-website"])];this.firstNameInput&&(this.firstNameInputValue=this.firstNameInput.value),this.lastNameInput&&(this.lastNameInputValue=this.lastNameInput.value),this.leadSourceInputValue=v,Wi("scheduleTourSubmitted",{email:this.email,phone:`+1${null===(e=this.phoneNumber.match(/\d/g))||void 0===e?void 0:e.join("")}`,firstName:null!==(n=null===(i=this.firstNameInput)||void 0===i?void 0:i.value)&&void 0!==n?n:this.firstNameInputValue,lastName:null!==(o=null===(r=this.lastNameInput)||void 0===r?void 0:r.value)&&void 0!==o?o:this.lastNameInputValue,tourType:hn[this.tourType],tourTime:`${this.selectedTime.datetime}${this.selectedTime.offset}`,originatingSource:y.find((e=>"property-website"!==e))||null});const b={referrer:document.referrer,email_address:this.email,phone_number:`+1${null===(a=this.phoneNumber.match(/\d/g))||void 0===a?void 0:a.join("")}`,building_id:this.buildingId,first_name:null!==(l=null===(s=this.firstNameInput)||void 0===s?void 0:s.value)&&void 0!==l?l:this.firstNameInputValue,last_name:null!==(d=null===(u=this.lastNameInput)||void 0===u?void 0:u.value)&&void 0!==d?d:this.lastNameInputValue,tour_type:hn[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,cancel_existing_tours:this.promptForReschedule,lead_sources:[...new Set(v?[v,sn(this.orgSlug)]:[sn(this.orgSlug)])],query_params:Object.fromEntries(g.entries()),conversation_tracking_id:null===(c=this.leadSourceClient)||void 0===c?void 0:c.chatId};this.isSubmitting=!0;try{await t().post("https://app.meetelise.com/platformApi/state/create/v2/scheduleMe",b,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG","org-slug":this.orgSlug}}),null===(p=this.leadSourceClient)||void 0===p||p.checkAndHandleForLogLeadSource({webchatAction:"tour-scheduler",stateId:null}),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e,i=(null===(f=null===(h=t.response)||void 0===h?void 0:h.data)||void 0===f?void 0:f.detail)||"Failed to book tour";if(t.response&&t.response.headers&&t.response.headers["funnel-prospect-conflicting-appointment-error"]){if(this.selectedDate&&this.selectedTime){const e=this.availabilitiesGroupedByDay[jt(this.selectedDate,"yyyy-MM-dd")];e&&(this.availabilitiesGroupedByDay[jt(this.selectedDate,"yyyy-MM-dd")]=e.filter((e=>e!==this.selectedTime)))}}else if(409===(null===(m=t.response)||void 0===m?void 0:m.status)&&!this.promptForReschedule)return this.promptForReschedule=!0,this.isSubmitting=!1,void(this.tourIsBooked=!1);alert(i),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>U`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>U`${this.dateAndTimeMenu()}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>U` <action-confirm-button
|
|
979
979
|
id="schedule-bttn"
|
|
980
980
|
.onClick=${this.submit}
|
|
981
981
|
.isLoading=${this.isSubmitting}
|
|
@@ -3213,7 +3213,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
3213
3213
|
${Sn}
|
|
3214
3214
|
${Tn}
|
|
3215
3215
|
${xn}
|
|
3216
|
-
`,Zn([le({attribute:!0})],er.prototype,"isMinimized",void 0),Zn([le()],er.prototype,"mobileStyles",void 0),Zn([le({type:Boolean})],er.prototype,"isFirstMount",void 0),Zn([le({attribute:!1})],er.prototype,"autoOpenChatWidget",void 0),Zn([le()],er.prototype,"phoneNumber",void 0),Zn([le({attribute:!0})],er.prototype,"buildingName",void 0),Zn([le({attribute:!0})],er.prototype,"chatId",void 0),Zn([le({attribute:!0})],er.prototype,"orgLegalName",void 0),Zn([le({attribute:!0})],er.prototype,"chatCallUsHeader",void 0),Zn([le({attribute:!1})],er.prototype,"buildingId",void 0),Zn([le({attribute:!0})],er.prototype,"buildingSlug",void 0),Zn([le({attribute:!0})],er.prototype,"orgSlug",void 0),Zn([le({attribute:!0})],er.prototype,"sgtUrl",void 0),Zn([le({attribute:!0})],er.prototype,"selfGuidedTourEnabled",void 0),Zn([le({attribute:!0})],er.prototype,"selfGuidedToursTypeOffered",void 0),Zn([le({attribute:!0})],er.prototype,"designConcept",void 0),Zn([le({attribute:!0})],er.prototype,"featureFlagShowDropdown",void 0),Zn([le({attribute:!1})],er.prototype,"leadSources",void 0),Zn([le({attribute:!0})],er.prototype,"currentLeadSource",void 0),Zn([le({attribute:!0})],er.prototype,"escortedToursLink",void 0),Zn([le({attribute:!0})],er.prototype,"virtualToursLink",void 0),Zn([le({type:Boolean})],er.prototype,"hasChatEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasChatEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasEmailEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasEmailEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasCallUsEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasCallUsEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasTextUsEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasTextUsEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasSSTEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasSSTEnabledMobile",void 0),Zn([le({attribute:!1})],er.prototype,"tourTypeOptions",void 0),Zn([le({attribute:!0})],er.prototype,"hasDynamicSchedulingEnabled",void 0),Zn([le({attribute:!0})],er.prototype,"onExitChat",void 0),Zn([le({attribute:!1})],er.prototype,"hasHideMobileFeatures",void 0),Zn([le({type:Number})],er.prototype,"right",void 0),Zn([le({type:Number})],er.prototype,"bottom",void 0),Zn([le({type:Number})],er.prototype,"top",void 0),Zn([le({type:Number})],er.prototype,"left",void 0),Zn([le({attribute:!0})],er.prototype,"showTourNextToChat",void 0),Zn([le({attribute:!1})],er.prototype,"onChatTapped",void 0),Zn([le({attribute:!0})],er.prototype,"onClickMinimize",void 0),Zn([le({attribute:!0})],er.prototype,"onSstClose",void 0),Zn([le({attribute:!0})],er.prototype,"overrideRentgrata",void 0),Zn([le({attribute:!1})],er.prototype,"launcherStyles",void 0),Zn([le({attribute:!0})],er.prototype,"primaryColor",void 0),Zn([le({attribute:!0})],er.prototype,"backgroundColor",void 0),Zn([le({attribute:!0})],er.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),Zn([le({attribute:!0})],er.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),Zn([le({attribute:!0})],er.prototype,"leadSourceClient",void 0),Zn([ue()],er.prototype,"isEmailWindowOpen",void 0),Zn([ue()],er.prototype,"isCallUsWindowOpen",void 0),Zn([ue()],er.prototype,"isSSTWindowOpen",void 0),Zn([ue()],er.prototype,"isTextUsWindowOpen",void 0),Zn([ue()],er.prototype,"isMobileFeaturesExpanded",void 0),er=Zn([ae("meetelise-launcher")],er);const tr=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",er)};var ir=i(3379),nr=i.n(ir),rr=i(7795),or=i.n(rr),ar=i(569),sr=i.n(ar),lr=i(3565),ur=i.n(lr),dr=i(9216),cr=i.n(dr),pr=i(4589),hr=i.n(pr),fr=i(3631),mr={};async function gr(e,i){try{const n=await t().get(`https://app.meetelise.com/platformApi/webchat/${i}/lead-sources`);if(n.data){if("7e352741-1120-4ccf-9929-5dc99193a908"===e){const e=["Zillow","Apartments.com","Google PPC","Google Maps","Apple Maps","Social Media","Print Marketing"];return n.data.filter((t=>e.includes(t)))}return vr(n.data,i)}return[]}catch(e){return[]}}mr.styleTagTransform=hr(),mr.setAttributes=ur(),mr.insert=sr().bind(null,"head"),mr.domAPI=or(),mr.insertStyleElement=cr(),nr()(fr.Z,mr),fr.Z&&fr.Z.locals&&fr.Z.locals;const vr=(e,t)=>{let i=[];switch(t){case"d41619ec-0f79-11ee-8439-93855926ad58":i=["Forthea - PPC","HotPads","Forthea","Locator","Website-apartmentguide.com","Forthea - organic search","Tdc employee","University newspaper","Nashville apartment locators","Forthea - paid social","Apartment list","Off campus partners","Waze ads","Athletic event","Website-apartment guide"];break;case"d4160560-0f79-11ee-8438-fba837bf3a46":i=["Forthea - PPC","Rentgrata","Website-ApartmentFinder.com","Word of Mouth","Texas A&M A-Frame on Campus","Rent.com","Website-craigslist","Apartment List","Website-apartments.com","Forthea - paid social","Forthea - organic search","Website-apartmentguide.com","Forthea","Uhomes","Phone book","Property - website"];break;default:i=[]}return e.sort(),e.filter((e=>{const t=e.toLowerCase();return!i.map((e=>e.toLowerCase())).includes(t)}))};var yr,br=i(9594),wr=i.n(br),Sr=new Uint8Array(16);function Tr(){if(!yr&&!(yr="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return yr(Sr)}const xr=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,Ar=function(e){return"string"==typeof e&&xr.test(e)};for(var Cr=[],Or=0;Or<256;++Or)Cr.push((Or+256).toString(16).substr(1));const Ir=function(e,t,i){var n=(e=e||{}).random||(e.rng||Tr)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){i=i||0;for(var r=0;r<16;++r)t[i+r]=n[r];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=(Cr[e[t+0]]+Cr[e[t+1]]+Cr[e[t+2]]+Cr[e[t+3]]+"-"+Cr[e[t+4]]+Cr[e[t+5]]+"-"+Cr[e[t+6]]+Cr[e[t+7]]+"-"+Cr[e[t+8]]+Cr[e[t+9]]+"-"+Cr[e[t+10]]+Cr[e[t+11]]+Cr[e[t+12]]+Cr[e[t+13]]+Cr[e[t+14]]+Cr[e[t+15]]).toLowerCase();if(!Ar(i))throw TypeError("Stringified UUID is invalid");return i}(n)},Nr=e=>localStorage.removeItem("com.elise.webchat.slug="+e),Er=(e,t,i)=>{const n=ui(new Date),r=i||`lead_${Ir()}_${e}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:n,initiatedChat:t})),{leadId:r,timestamp:gi(n),buildingSlug:e,initiatedChat:t}},Rr=e=>{const t=localStorage.getItem("com.elise.webchat.slug="+e);if(t)try{const i=JSON.parse(t),n={leadId:i.leadId,timestamp:new Date(i.timestamp),buildingSlug:i.buildingSlug,initiatedChat:i.initiatedChat};if(_r(e,n))return n}catch(e){console.warn("Error getting chat storage key")}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},_r=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if(ti(t.timestamp,e))return!1}}catch(e){console.warn("Error checking chat storage key validity")}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp||ni(t.timestamp,24))};var Pr;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(Pr||(Pr={}));const Mr=e=>e.type===Dr.text,Fr=e=>e.type===Dr.media;var Dr;!function(e){e.text="text",e.media="media"}(Dr||(Dr={}));const kr=class{constructor(e,t,i,n=null,r,o=null,a=Oo.Default){this.apiHost="https://app.meetelise.com",this.leadSourceClient=null,this.buildingWebchatView=null,this.eliseResponseTimeout=null,this.isWaitingForStreamingMessages=!1,this.widgetType=Oo.Default,this.pubnub=null,this.leadUserId="",this.channel="",this.leadSource=null,this.isCurrentlyStreamingMessage=!1,this.chatListener=null,this.rawPubnubMessages=[],this.simpleChatMessages=[],this.listenerParams={message:e=>{var t,i;const n={channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken};this.rawPubnubMessages=[...this.rawPubnubMessages,n],this.markEveryPreviousNoReplyMessageDone(this.rawPubnubMessages),this.rawPubnubMessages=this.rawPubnubMessages.filter((e=>e.message.messageType!==Pr.noReply)),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),this.checkAndHandleDelayStreamingMessages();const r="eliseai"!==e.publisher&&"elise_health_ai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:r}),!r&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=r,"ai_message"===e.message.customType&&this.simpleChatMessages.some((e=>e.type===Dr.text&&e.message.includes("confirmed for your tour")))&&Wi("scheduledTourEvent",{tourDetails:e.message,buildingId:null===(i=this.buildingWebchatView)||void 0===i?void 0:i.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.checkAndHandleGTMForLeadEmail(e)}},this.isLoadingMessages=!1,this.isFirstChatMessageSent=!1,this.streamingMessageTimeout=null,this.checkAndHandleDelayStreamingMessages=({delayToFetchHistoryInMs:e=1e4}={})=>{this.streamingMessageTimeout&&(clearTimeout(this.streamingMessageTimeout),this.streamingMessageTimeout=null);const t=this.simpleChatMessages.some((e=>{if(!Mr(e))return!1;const t=e.chunks.find((e=>e.isDone));return!t||e.chunks.length===t.order}));t&&(this.streamingMessageTimeout=setTimeout((()=>{en({logTitle:"PUBNUB_WARN_DELAYED_STREAMING_MESSAGES",logData:{channel:this.channel},logType:Zi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),console.warn(`PUBNUB_WARN_DELAYED_STREAMING_MESSAGES: ${e}`),this.getChannelHistory()}),e))},this.checkAndHandleGTMForLeadEmail=e=>{var t;try{if("lead_message"!==e.message.customType)return;if(!(e=>{try{return/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b/.test(e)}catch(e){return console.warn("Error checking if message contains email",e),!1}})(e.message.text))return;Wi("leadProvidedEmail",{buildingId:null===(t=this.buildingWebchatView)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel})}catch(e){return}},this.markEveryPreviousNoReplyMessageDone=e=>{var t,i;for(let n=e.length-1;n>=0;n--){const r=null===(t=e[n])||void 0===t?void 0:t.message,o=n>0&&(null===(i=e[n-1])||void 0===i?void 0:i.message);(null==r?void 0:r.messageType)===Pr.noReply&&o&&(o.is_done=!0)}},this.checkMessageChunkValid=e=>{try{return!!e.message&&!!e.message.text&&e.message.text.length>0&&!!e.message.customType}catch(e){return!1}},this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.handleDisconnect=()=>{this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.streamingMessageTimeout&&(clearTimeout(this.streamingMessageTimeout),this.streamingMessageTimeout=null),this.removeChatListeners()},this.removeChatListeners=()=>{this.pubnub&&this.channel&&(this.pubnub.unsubscribe({channels:[this.channel]}),this.pubnub.removeListener(this.listenerParams))},this.sendMessage=async e=>{if(e){if(!this.pubnub){const e=Er(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken((async()=>{var t,i,n,r,o;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}),9e4),0===this.simpleChatMessages.length&&(null===(t=this.leadSourceClient)||void 0===t||t.checkAndHandleForLogLeadSource({webchatAction:"chat",stateId:null})),this.widgetType===Oo.Utilities?await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",widgetType:this.widgetType,isDevState:this.shouldCreateAsDevState(),orgSlug:this.orgSlug}}):await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(i=this.buildingWebchatView)||void 0===i?void 0:i.id,buildingSlug:this.buildingSlug,userId:null===(n=this.buildingWebchatView)||void 0===n?void 0:n.userId,leadSource:this.leadSource,widgetType:this.widgetType,isDevState:this.shouldCreateAsDevState()}}),this.isFirstChatMessageSent||(Wi("firstChatMessageSent",{message:e,buildingId:null===(r=this.buildingWebchatView)||void 0===r?void 0:r.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.isFirstChatMessageSent=!0),Wi("chatMessageSent",{message:e,buildingId:null===(o=this.buildingWebchatView)||void 0===o?void 0:o.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}))})),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.removeDuplicatedRawPubnubMessages=e=>{const t=new Set;return e.filter((e=>{if("lead_message"===e.message.customType||!e.message.stream_id||!e.message.order)return!0;const i=`${e.message.stream_id}-${e.message.order}-${e.message.messageType}`;return t.has(i)?(en({logTitle:"PUBNUB_WARN_DUPLICATE_MESSAGE",logData:{message:e,channel:this.channel},logType:Zi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),!1):(t.add(i),!0)}))},this.translatePubnubMessagesIntoSimpleChatMessages=e=>{const t=[],i={};return this.removeDuplicatedRawPubnubMessages(e).forEach((e=>{var n;"media"===e.message.messageType?t.push({timestamp:e.timetoken,media:null!==(n=e.message.media)&&void 0!==n?n:[],isLeadMessage:this.isLeadMessage(e),type:Dr.media}):!e.message.stream_id||e.message.is_done&&0===e.message.order?t.push({timestamp:e.timetoken,message:e.message.text,isLeadMessage:this.isLeadMessage(e),chunks:[{text:e.message.text,order:0,isDone:!0}],type:Dr.text}):i[e.message.stream_id]?i[e.message.stream_id].push(e):i[e.message.stream_id]=[e]})),Object.keys(i).forEach((e=>{const n=i[e],r=this.getConsecutiveChunks(n.sort(((e,t)=>{var i,n;return(null!==(i=e.message.order)&&void 0!==i?i:0)-(null!==(n=t.message.order)&&void 0!==n?n:0)}))),o=r.map((e=>e.message.text)).join(""),a=r[0],s={timestamp:a.timetoken,message:o,isLeadMessage:this.isLeadMessage(a),chunks:r.map((e=>{var t,i;return{text:e.message.text,order:null!==(t=e.message.order)&&void 0!==t?t:0,isDone:null!==(i=e.message.is_done)&&void 0!==i&&i}})),type:Dr.text};this.isCurrentlyStreamingMessage=this.isMessageStillStreamingChunks(r),t.push(s)})),t.sort(((e,t)=>e.timestamp-t.timestamp)),t},this.getConsecutiveChunks=e=>{var t,i;const n=e.sort(((e,t)=>{var i,n;return(null!==(i=e.message.order)&&void 0!==i?i:0)-(null!==(n=t.message.order)&&void 0!==n?n:0)})),r=[];let o=null!==(t=n[0].message.order)&&void 0!==t?t:0;for(const e of n){if((null!==(i=e.message.order)&&void 0!==i?i:-1)!==o)break;r.push(e),o++}return r},this.isMessageStillStreamingChunks=e=>{const t=e.find((e=>e.message.is_done));return!t||e.length===t.message.order},this.buildingSlug=e,this.buildingWebchatView=t,this.orgSlug=i,this.leadSource=n,this.leadUserId=r,this.channel=`webchat_${r}`,this.leadSourceClient=o,this.widgetType=a}addChatListener(e){this.chatListener=e}async initializePubnub(e){if(!e.leadId)return;this.leadUserId=e.leadId;const t=await this.fetchToken(this.leadUserId,this.channel);return t?(this.pubnub=new(wr())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token,origin:"meetelise.pubnubapi.com"}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,i){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${i}&${"healthcare"===this.widgetType?"industry=health_care":""}`)).data}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return null}async fetchChannelExists(e){try{return(await t().get(`${this.apiHost}/platformApi/webchat/check-channel-exists?channel_name=${e}`)).data}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(i){if(i instanceof e.AxiosError&&i&&i.response&&403===i.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const e=await this.fetchToken(this.leadUserId,this.channel);if(!e)return;this.pubnub.setAuthKey(e.auth.result.token),await t()}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(e=1500){var t;try{let i=[],n=null;const r=100;for(let t=0;t<e;t+=r){const o=await new Promise(((i,o)=>{if(!this.pubnub||!this.channel)return[];const a=Math.min(r,e-t);this.pubnub.fetchMessages({channels:[this.channel],count:a,start:null!=n?n:void 0},((e,t)=>{e.error?o(e):i(t)}))})),a=o.channels[this.channel];if(!a)break;if(a.sort(((e,t)=>+e.timetoken-+t.timetoken)),!a||0===a.length)break;if(this.channel&&0!==Object.keys(o.channels).length){const e=o.channels[this.channel],t=[];e.forEach((e=>{e.uuid&&t.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})})),this.markEveryPreviousNoReplyMessageDone(t),i=i.concat(t.filter((e=>e.message.messageType!==Pr.noReply)))}if(n=a[0].timetoken,i.length>=e||a.length<r)break}this.rawPubnubMessages=i.slice(0,e),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:!1})}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:Zi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}shouldCreateAsDevState(){return location.href.startsWith("https://app.meetelise.com/settings/widgets")||location.href.includes("demo/utilities")}},Ur=(e,t,i)=>{const n=`tel:${e}`,r=`sms:${e}`,o=`whatsapp://send?phone=${e}}`,a=`facetime:${e}`,s=`facetime-audio:${e}`,l=/(?:\(\d{3}\)\s|\d{3}-)\d{3}-\d{4}/g,u=/(tel|sms):(?:\(\d{3}\)\s|\d{3}-)\d{3}-\d{4}/g,d=/whatsapp:\/\/send\?phone=\d+/g,c=/(facetime|facetime-audio):\d+/g,p=document.body.getElementsByTagName("*");let h=!1;const f=e.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3");let m=!1,g=!1,v=0;for(let e=0;e<p.length;e++)if(p[e].nodeType===Node.ELEMENT_NODE){if(1===p[e].childNodes.length&&p[e].childNodes[0].nodeType==Node.TEXT_NODE){const t=p[e].innerHTML,i=t.replace(l,f);t!==i&&v++,p[e].innerHTML=i,h=!0,m||(m=!0)}if(p[e].hasAttribute("href")){const t=p[e].getAttribute("href");if(!t)continue;let i="",l=u;t.startsWith("sms:")?i=r:t.startsWith("whatsapp:")?(i=o,l=d):t.startsWith("facetime:")?(i=a,l=c):t.startsWith("facetime-audio:")?(i=s,l=c):i=n;const h=t.replace(l,i);p[e].setAttribute("href",h),g||(g=!0)}}return m&&en({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:f,website:window.location.href},logType:Zi.info,buildingSlug:i,orgSlug:t}),g&&en({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:f,website:window.location.href},logType:Zi.info,buildingSlug:i,orgSlug:t}),h||en({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:Zi.warn,buildingSlug:i,orgSlug:t}),v},Br=(e="black")=>B`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none">
|
|
3216
|
+
`,Zn([le({attribute:!0})],er.prototype,"isMinimized",void 0),Zn([le()],er.prototype,"mobileStyles",void 0),Zn([le({type:Boolean})],er.prototype,"isFirstMount",void 0),Zn([le({attribute:!1})],er.prototype,"autoOpenChatWidget",void 0),Zn([le()],er.prototype,"phoneNumber",void 0),Zn([le({attribute:!0})],er.prototype,"buildingName",void 0),Zn([le({attribute:!0})],er.prototype,"chatId",void 0),Zn([le({attribute:!0})],er.prototype,"orgLegalName",void 0),Zn([le({attribute:!0})],er.prototype,"chatCallUsHeader",void 0),Zn([le({attribute:!1})],er.prototype,"buildingId",void 0),Zn([le({attribute:!0})],er.prototype,"buildingSlug",void 0),Zn([le({attribute:!0})],er.prototype,"orgSlug",void 0),Zn([le({attribute:!0})],er.prototype,"sgtUrl",void 0),Zn([le({attribute:!0})],er.prototype,"selfGuidedTourEnabled",void 0),Zn([le({attribute:!0})],er.prototype,"selfGuidedToursTypeOffered",void 0),Zn([le({attribute:!0})],er.prototype,"designConcept",void 0),Zn([le({attribute:!0})],er.prototype,"featureFlagShowDropdown",void 0),Zn([le({attribute:!1})],er.prototype,"leadSources",void 0),Zn([le({attribute:!0})],er.prototype,"currentLeadSource",void 0),Zn([le({attribute:!0})],er.prototype,"escortedToursLink",void 0),Zn([le({attribute:!0})],er.prototype,"virtualToursLink",void 0),Zn([le({type:Boolean})],er.prototype,"hasChatEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasChatEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasEmailEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasEmailEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasCallUsEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasCallUsEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasTextUsEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasTextUsEnabledMobile",void 0),Zn([le({type:Boolean})],er.prototype,"hasSSTEnabledDesktop",void 0),Zn([le({type:Boolean})],er.prototype,"hasSSTEnabledMobile",void 0),Zn([le({attribute:!1})],er.prototype,"tourTypeOptions",void 0),Zn([le({attribute:!0})],er.prototype,"hasDynamicSchedulingEnabled",void 0),Zn([le({attribute:!0})],er.prototype,"onExitChat",void 0),Zn([le({attribute:!1})],er.prototype,"hasHideMobileFeatures",void 0),Zn([le({type:Number})],er.prototype,"right",void 0),Zn([le({type:Number})],er.prototype,"bottom",void 0),Zn([le({type:Number})],er.prototype,"top",void 0),Zn([le({type:Number})],er.prototype,"left",void 0),Zn([le({attribute:!0})],er.prototype,"showTourNextToChat",void 0),Zn([le({attribute:!1})],er.prototype,"onChatTapped",void 0),Zn([le({attribute:!0})],er.prototype,"onClickMinimize",void 0),Zn([le({attribute:!0})],er.prototype,"onSstClose",void 0),Zn([le({attribute:!0})],er.prototype,"overrideRentgrata",void 0),Zn([le({attribute:!1})],er.prototype,"launcherStyles",void 0),Zn([le({attribute:!0})],er.prototype,"primaryColor",void 0),Zn([le({attribute:!0})],er.prototype,"backgroundColor",void 0),Zn([le({attribute:!0})],er.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),Zn([le({attribute:!0})],er.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),Zn([le({attribute:!0})],er.prototype,"leadSourceClient",void 0),Zn([ue()],er.prototype,"isEmailWindowOpen",void 0),Zn([ue()],er.prototype,"isCallUsWindowOpen",void 0),Zn([ue()],er.prototype,"isSSTWindowOpen",void 0),Zn([ue()],er.prototype,"isTextUsWindowOpen",void 0),Zn([ue()],er.prototype,"isMobileFeaturesExpanded",void 0),er=Zn([ae("meetelise-launcher")],er);const tr=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",er)};var ir=i(3379),nr=i.n(ir),rr=i(7795),or=i.n(rr),ar=i(569),sr=i.n(ar),lr=i(3565),ur=i.n(lr),dr=i(9216),cr=i.n(dr),pr=i(4589),hr=i.n(pr),fr=i(3631),mr={};async function gr(e,i){try{const n=await t().get(`https://app.meetelise.com/platformApi/webchat/${i}/lead-sources`);if(n.data){if("7e352741-1120-4ccf-9929-5dc99193a908"===e){const e=["Zillow","Apartments.com","Google PPC","Google Maps","Apple Maps","Social Media","Print Marketing"];return n.data.filter((t=>e.includes(t)))}return vr(n.data,i)}return[]}catch(e){return[]}}mr.styleTagTransform=hr(),mr.setAttributes=ur(),mr.insert=sr().bind(null,"head"),mr.domAPI=or(),mr.insertStyleElement=cr(),nr()(fr.Z,mr),fr.Z&&fr.Z.locals&&fr.Z.locals;const vr=(e,t)=>{let i=[];switch(t){case"d41619ec-0f79-11ee-8439-93855926ad58":i=["Forthea - PPC","HotPads","Forthea","Locator","Website-apartmentguide.com","Forthea - organic search","Tdc employee","University newspaper","Nashville apartment locators","Forthea - paid social","Apartment list","Off campus partners","Waze ads","Athletic event","Website-apartment guide"];break;case"d4160560-0f79-11ee-8438-fba837bf3a46":i=["Forthea - PPC","Rentgrata","Website-ApartmentFinder.com","Word of Mouth","Texas A&M A-Frame on Campus","Rent.com","Website-craigslist","Apartment List","Website-apartments.com","Forthea - paid social","Forthea - organic search","Website-apartmentguide.com","Forthea","Uhomes","Phone book","Property - website"];break;default:i=[]}return e.sort(),e.filter((e=>{const t=e.toLowerCase();return!i.map((e=>e.toLowerCase())).includes(t)}))};var yr,br=i(9594),wr=i.n(br),Sr=new Uint8Array(16);function Tr(){if(!yr&&!(yr="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return yr(Sr)}const xr=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,Ar=function(e){return"string"==typeof e&&xr.test(e)};for(var Cr=[],Or=0;Or<256;++Or)Cr.push((Or+256).toString(16).substr(1));const Ir=function(e,t,i){var n=(e=e||{}).random||(e.rng||Tr)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){i=i||0;for(var r=0;r<16;++r)t[i+r]=n[r];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=(Cr[e[t+0]]+Cr[e[t+1]]+Cr[e[t+2]]+Cr[e[t+3]]+"-"+Cr[e[t+4]]+Cr[e[t+5]]+"-"+Cr[e[t+6]]+Cr[e[t+7]]+"-"+Cr[e[t+8]]+Cr[e[t+9]]+"-"+Cr[e[t+10]]+Cr[e[t+11]]+Cr[e[t+12]]+Cr[e[t+13]]+Cr[e[t+14]]+Cr[e[t+15]]).toLowerCase();if(!Ar(i))throw TypeError("Stringified UUID is invalid");return i}(n)},Nr=e=>localStorage.removeItem("com.elise.webchat.slug="+e),Er=(e,t,i)=>{const n=ui(new Date),r=i||`lead_${Ir()}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:n,initiatedChat:t})),{leadId:r,timestamp:gi(n),buildingSlug:e,initiatedChat:t}},Rr=e=>{const t=localStorage.getItem("com.elise.webchat.slug="+e);if(t)try{const i=JSON.parse(t),n={leadId:i.leadId,timestamp:new Date(i.timestamp),buildingSlug:i.buildingSlug,initiatedChat:i.initiatedChat};if(_r(e,n))return n}catch(e){console.warn("Error getting chat storage key")}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},_r=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if(ti(t.timestamp,e))return!1}}catch(e){console.warn("Error checking chat storage key validity")}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp||ni(t.timestamp,24))};var Pr;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(Pr||(Pr={}));const Mr=e=>e.type===Dr.text,Fr=e=>e.type===Dr.media;var Dr;!function(e){e.text="text",e.media="media"}(Dr||(Dr={}));const kr=class{constructor(e,t,i,n=null,r,o=null,a=Oo.Default){this.apiHost="https://app.meetelise.com",this.leadSourceClient=null,this.buildingWebchatView=null,this.eliseResponseTimeout=null,this.isWaitingForStreamingMessages=!1,this.widgetType=Oo.Default,this.pubnub=null,this.leadUserId="",this.channel="",this.leadSource=null,this.isCurrentlyStreamingMessage=!1,this.chatListener=null,this.rawPubnubMessages=[],this.simpleChatMessages=[],this.listenerParams={message:e=>{var t,i;const n={channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken};this.rawPubnubMessages=[...this.rawPubnubMessages,n],this.markEveryPreviousNoReplyMessageDone(this.rawPubnubMessages),this.rawPubnubMessages=this.rawPubnubMessages.filter((e=>e.message.messageType!==Pr.noReply)),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),this.checkAndHandleDelayStreamingMessages();const r="eliseai"!==e.publisher&&"elise_health_ai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:r}),!r&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=r,"ai_message"===e.message.customType&&this.simpleChatMessages.some((e=>e.type===Dr.text&&e.message.includes("confirmed for your tour")))&&Wi("scheduledTourEvent",{tourDetails:e.message,buildingId:null===(i=this.buildingWebchatView)||void 0===i?void 0:i.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.checkAndHandleGTMForLeadEmail(e)}},this.isLoadingMessages=!1,this.isFirstChatMessageSent=!1,this.streamingMessageTimeout=null,this.checkAndHandleDelayStreamingMessages=({delayToFetchHistoryInMs:e=1e4}={})=>{this.streamingMessageTimeout&&(clearTimeout(this.streamingMessageTimeout),this.streamingMessageTimeout=null);const t=this.simpleChatMessages.some((e=>{if(!Mr(e))return!1;const t=e.chunks.find((e=>e.isDone));return!t||e.chunks.length===t.order}));t&&(this.streamingMessageTimeout=setTimeout((()=>{en({logTitle:"PUBNUB_WARN_DELAYED_STREAMING_MESSAGES",logData:{channel:this.channel},logType:Zi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),console.warn(`PUBNUB_WARN_DELAYED_STREAMING_MESSAGES: ${e}`),this.getChannelHistory()}),e))},this.checkAndHandleGTMForLeadEmail=e=>{var t;try{if("lead_message"!==e.message.customType)return;if(!(e=>{try{return/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b/.test(e)}catch(e){return console.warn("Error checking if message contains email",e),!1}})(e.message.text))return;Wi("leadProvidedEmail",{buildingId:null===(t=this.buildingWebchatView)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel})}catch(e){return}},this.markEveryPreviousNoReplyMessageDone=e=>{var t,i;for(let n=e.length-1;n>=0;n--){const r=null===(t=e[n])||void 0===t?void 0:t.message,o=n>0&&(null===(i=e[n-1])||void 0===i?void 0:i.message);(null==r?void 0:r.messageType)===Pr.noReply&&o&&(o.is_done=!0)}},this.checkMessageChunkValid=e=>{try{return!!e.message&&!!e.message.text&&e.message.text.length>0&&!!e.message.customType}catch(e){return!1}},this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.handleDisconnect=()=>{this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.streamingMessageTimeout&&(clearTimeout(this.streamingMessageTimeout),this.streamingMessageTimeout=null),this.removeChatListeners()},this.removeChatListeners=()=>{this.pubnub&&this.channel&&(this.pubnub.unsubscribe({channels:[this.channel]}),this.pubnub.removeListener(this.listenerParams))},this.sendMessage=async e=>{if(e){if(!this.pubnub){const e=Er(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken((async()=>{var t,i,n,r,o;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}),9e4),0===this.simpleChatMessages.length&&(null===(t=this.leadSourceClient)||void 0===t||t.checkAndHandleForLogLeadSource({webchatAction:"chat",stateId:null})),this.widgetType===Oo.Utilities?await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",widgetType:this.widgetType,isDevState:this.shouldCreateAsDevState(),orgSlug:this.orgSlug}}):await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(i=this.buildingWebchatView)||void 0===i?void 0:i.id,buildingSlug:this.buildingSlug,userId:null===(n=this.buildingWebchatView)||void 0===n?void 0:n.userId,leadSource:this.leadSource,widgetType:this.widgetType,isDevState:this.shouldCreateAsDevState()}}),this.isFirstChatMessageSent||(Wi("firstChatMessageSent",{message:e,buildingId:null===(r=this.buildingWebchatView)||void 0===r?void 0:r.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.isFirstChatMessageSent=!0),Wi("chatMessageSent",{message:e,buildingId:null===(o=this.buildingWebchatView)||void 0===o?void 0:o.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}))})),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.removeDuplicatedRawPubnubMessages=e=>{const t=new Set;return e.filter((e=>{if("lead_message"===e.message.customType||!e.message.stream_id||!e.message.order)return!0;const i=`${e.message.stream_id}-${e.message.order}-${e.message.messageType}`;return t.has(i)?(en({logTitle:"PUBNUB_WARN_DUPLICATE_MESSAGE",logData:{message:e,channel:this.channel},logType:Zi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),!1):(t.add(i),!0)}))},this.translatePubnubMessagesIntoSimpleChatMessages=e=>{const t=[],i={};return this.removeDuplicatedRawPubnubMessages(e).forEach((e=>{var n;"media"===e.message.messageType?t.push({timestamp:e.timetoken,media:null!==(n=e.message.media)&&void 0!==n?n:[],isLeadMessage:this.isLeadMessage(e),type:Dr.media}):!e.message.stream_id||e.message.is_done&&0===e.message.order?t.push({timestamp:e.timetoken,message:e.message.text,isLeadMessage:this.isLeadMessage(e),chunks:[{text:e.message.text,order:0,isDone:!0}],type:Dr.text}):i[e.message.stream_id]?i[e.message.stream_id].push(e):i[e.message.stream_id]=[e]})),Object.keys(i).forEach((e=>{const n=i[e],r=this.getConsecutiveChunks(n.sort(((e,t)=>{var i,n;return(null!==(i=e.message.order)&&void 0!==i?i:0)-(null!==(n=t.message.order)&&void 0!==n?n:0)}))),o=r.map((e=>e.message.text)).join(""),a=r[0],s={timestamp:a.timetoken,message:o,isLeadMessage:this.isLeadMessage(a),chunks:r.map((e=>{var t,i;return{text:e.message.text,order:null!==(t=e.message.order)&&void 0!==t?t:0,isDone:null!==(i=e.message.is_done)&&void 0!==i&&i}})),type:Dr.text};this.isCurrentlyStreamingMessage=this.isMessageStillStreamingChunks(r),t.push(s)})),t.sort(((e,t)=>e.timestamp-t.timestamp)),t},this.getConsecutiveChunks=e=>{var t,i;const n=e.sort(((e,t)=>{var i,n;return(null!==(i=e.message.order)&&void 0!==i?i:0)-(null!==(n=t.message.order)&&void 0!==n?n:0)})),r=[];let o=null!==(t=n[0].message.order)&&void 0!==t?t:0;for(const e of n){if((null!==(i=e.message.order)&&void 0!==i?i:-1)!==o)break;r.push(e),o++}return r},this.isMessageStillStreamingChunks=e=>{const t=e.find((e=>e.message.is_done));return!t||e.length===t.message.order},this.buildingSlug=e,this.buildingWebchatView=t,this.orgSlug=i,this.leadSource=n,this.leadUserId=r,this.channel=`webchat_${r}`,this.leadSourceClient=o,this.widgetType=a}addChatListener(e){this.chatListener=e}async initializePubnub(e){if(!e.leadId)return;this.leadUserId=e.leadId;const t=await this.fetchToken(this.leadUserId,this.channel);return t?(this.pubnub=new(wr())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token,origin:"meetelise.pubnubapi.com"}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,i){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${i}&${"healthcare"===this.widgetType?"industry=health_care":""}`)).data}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return null}async fetchChannelExists(e){try{return(await t().get(`${this.apiHost}/platformApi/webchat/check-channel-exists?channel_name=${e}`)).data}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(i){if(i instanceof e.AxiosError&&i&&i.response&&403===i.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const e=await this.fetchToken(this.leadUserId,this.channel);if(!e)return;this.pubnub.setAuthKey(e.auth.result.token),await t()}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:Zi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(e=1500){var t;try{let i=[],n=null;const r=100;for(let t=0;t<e;t+=r){const o=await new Promise(((i,o)=>{if(!this.pubnub||!this.channel)return[];const a=Math.min(r,e-t);this.pubnub.fetchMessages({channels:[this.channel],count:a,start:null!=n?n:void 0},((e,t)=>{e.error?o(e):i(t)}))})),a=o.channels[this.channel];if(!a)break;if(a.sort(((e,t)=>+e.timetoken-+t.timetoken)),!a||0===a.length)break;if(this.channel&&0!==Object.keys(o.channels).length){const e=o.channels[this.channel],t=[];e.forEach((e=>{e.uuid&&t.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})})),this.markEveryPreviousNoReplyMessageDone(t),i=i.concat(t.filter((e=>e.message.messageType!==Pr.noReply)))}if(n=a[0].timetoken,i.length>=e||a.length<r)break}this.rawPubnubMessages=i.slice(0,e),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:!1})}catch(e){this.buildingWebchatView&&en({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:Zi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}shouldCreateAsDevState(){return location.href.startsWith("https://app.meetelise.com/settings/widgets")||location.href.includes("demo/utilities")}},Ur=(e,t,i)=>{const n=`tel:${e}`,r=`sms:${e}`,o=`whatsapp://send?phone=${e}}`,a=`facetime:${e}`,s=`facetime-audio:${e}`,l=/(?:\(\d{3}\)\s|\d{3}-)\d{3}-\d{4}/g,u=/(tel|sms):(?:\(\d{3}\)\s|\d{3}-)\d{3}-\d{4}/g,d=/whatsapp:\/\/send\?phone=\d+/g,c=/(facetime|facetime-audio):\d+/g,p=document.body.getElementsByTagName("*");let h=!1;const f=e.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3");let m=!1,g=!1,v=0;for(let e=0;e<p.length;e++)if(p[e].nodeType===Node.ELEMENT_NODE){if(1===p[e].childNodes.length&&p[e].childNodes[0].nodeType==Node.TEXT_NODE){const t=p[e].innerHTML,i=t.replace(l,f);t!==i&&v++,p[e].innerHTML=i,h=!0,m||(m=!0)}if(p[e].hasAttribute("href")){const t=p[e].getAttribute("href");if(!t)continue;let i="",l=u;t.startsWith("sms:")?i=r:t.startsWith("whatsapp:")?(i=o,l=d):t.startsWith("facetime:")?(i=a,l=c):t.startsWith("facetime-audio:")?(i=s,l=c):i=n;const h=t.replace(l,i);p[e].setAttribute("href",h),g||(g=!0)}}return m&&en({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:f,website:window.location.href},logType:Zi.info,buildingSlug:i,orgSlug:t}),g&&en({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:f,website:window.location.href},logType:Zi.info,buildingSlug:i,orgSlug:t}),h||en({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:Zi.warn,buildingSlug:i,orgSlug:t}),v},Br=(e="black")=>B`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none">
|
|
3217
3217
|
<line x1="1.70782" y1="13.2254" x2="13.2376" y2="1.69554" stroke="${e}" stroke-width="2.13401"/>
|
|
3218
3218
|
<path d="M2.00929 1.99996L13.3328 13.3421" stroke="${e}" stroke-width="2.13401"/>
|
|
3219
3219
|
</svg>`;var Lr=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 qr=class extends re{constructor(){super(...arguments),this.onClick=()=>{},this.primaryColor=Me,this.toExpand=!1}render(){return U`
|
|
@@ -21,6 +21,9 @@ export function getDefaultLeadSourceAttribution(orgSlug: string): string {
|
|
|
21
21
|
// if anything, should read from DB and give clients default ability to set this
|
|
22
22
|
return "AVB Company Website";
|
|
23
23
|
}
|
|
24
|
+
if (orgSlug === "windsor") {
|
|
25
|
+
return "Windsorcommunities.com";
|
|
26
|
+
}
|
|
24
27
|
return "property-website";
|
|
25
28
|
}
|
|
26
29
|
|
package/src/handleChatId.ts
CHANGED
|
@@ -24,7 +24,7 @@ export const createChatStorageKey = (
|
|
|
24
24
|
const storageTimestamp = formatISO(new Date());
|
|
25
25
|
|
|
26
26
|
// must preface with lead for BE to extract lead id
|
|
27
|
-
const leadUserId = leadId ? leadId : `lead_${uuid()}
|
|
27
|
+
const leadUserId = leadId ? leadId : `lead_${uuid()}`;
|
|
28
28
|
localStorage.setItem(
|
|
29
29
|
"com.elise.webchat.slug=" + buildingSlug,
|
|
30
30
|
JSON.stringify({
|