@meetelise/chat 1.20.95 → 1.20.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/public/dist/index.js
CHANGED
|
@@ -472,7 +472,7 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
|
|
|
472
472
|
.option.active {
|
|
473
473
|
background-color: var(--active-option-color);
|
|
474
474
|
}
|
|
475
|
-
`,Zt],$t([de({attribute:!1})],en.prototype,"options",void 0),$t([de({type:String})],en.prototype,"placeholder",void 0),$t([de({type:String})],en.prototype,"value",void 0),$t([ce()],en.prototype,"activeOption",void 0),$t([ce()],en.prototype,"isOpen",void 0),$t([pe("#select",!0)],en.prototype,"meSelect",void 0),en=$t([ue("me-select")],en);var nn=n(9991),rn=n(7739),on=n.n(rn);function an(e){return Ue(1,arguments),qe(e).getTime()<Date.now()}Math.pow(10,8);var sn=36e5;function un(e,t){Ue(1,arguments);var n=t||{},i=null==n.additionalDigits?2:et(n.additionalDigits);if(2!==i&&1!==i&&0!==i)throw new RangeError("additionalDigits must be 0, 1 or 2");if("string"!=typeof e&&"[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);var r,o=hn(e);if(o.date){var a=fn(o.date,i);r=mn(a.restDateString,a.year)}if(!r||isNaN(r.getTime()))return new Date(NaN);var s,u=r.getTime(),l=0;if(o.time&&(l=vn(o.time),isNaN(l)))return new Date(NaN);if(!o.timezone){var d=new Date(u+l),c=new Date(0);return c.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),c.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),c}return s=bn(o.timezone),isNaN(s)?new Date(NaN):new Date(u+l+s)}var ln={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},dn=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,cn=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,pn=/^([+-])(\d{2})(?::?(\d{2}))?$/;function hn(e){var t,n={},i=e.split(ln.dateTimeDelimiter);if(i.length>2)return n;if(/:/.test(i[0])?t=i[0]:(n.date=i[0],t=i[1],ln.timeZoneDelimiter.test(n.date)&&(n.date=e.split(ln.timeZoneDelimiter)[0],t=e.substr(n.date.length,e.length))),t){var r=ln.timezone.exec(t);r?(n.time=t.replace(r[1],""),n.timezone=r[1]):n.time=t}return n}function fn(e,t){var n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),i=e.match(n);if(!i)return{year:NaN,restDateString:""};var r=i[1]?parseInt(i[1]):null,o=i[2]?parseInt(i[2]):null;return{year:null===o?r:100*o,restDateString:e.slice((i[1]||i[2]).length)}}function mn(e,t){if(null===t)return new Date(NaN);var n=e.match(dn);if(!n)return new Date(NaN);var i=!!n[4],r=gn(n[1]),o=gn(n[2])-1,a=gn(n[3]),s=gn(n[4]),u=gn(n[5])-1;if(i)return function(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}(0,s,u)?function(e,t,n){var i=new Date(0);i.setUTCFullYear(e,0,4);var r=7*(t-1)+n+1-(i.getUTCDay()||7);return i.setUTCDate(i.getUTCDate()+r),i}(t,s,u):new Date(NaN);var l=new Date(0);return function(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(wn[t]||(Sn(e)?29:28))}(t,o,a)&&function(e,t){return t>=1&&t<=(Sn(e)?366:365)}(t,r)?(l.setUTCFullYear(t,o,Math.max(r,a)),l):new Date(NaN)}function gn(e){return e?parseInt(e):1}function vn(e){var t=e.match(cn);if(!t)return NaN;var n=yn(t[1]),i=yn(t[2]),r=yn(t[3]);return function(e,t,n){return 24===e?0===t&&0===n:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}(n,i,r)?n*sn+6e4*i+1e3*r:NaN}function yn(e){return e&&parseFloat(e.replace(",","."))||0}function bn(e){if("Z"===e)return 0;var t=e.match(pn);if(!t)return 0;var n="+"===t[1]?-1:1,i=parseInt(t[2]),r=t[3]&&parseInt(t[3])||0;return function(e,t){return t>=0&&t<=59}(0,r)?n*(i*sn+6e4*r):NaN}var wn=[31,null,31,30,31,30,31,31,30,31,30,31];function Sn(e){return e%400==0||e%4==0&&e%100!=0}const Tn={buildingId:null,availabilities:{}},An=async e=>{e&&(Tn.buildingId=e);const n=Tn.buildingId;if(!n)throw new Error("No buildingId was provided to getRawAvailabilities and there is no buildingId cached.");const i=Tn.availabilities;if(i[n])return i[n];const r=function(e){Ue(1,arguments);var t=qe(e);return t.setHours(0,0,0,0),t}(Date.now()),o=tn(function(e){Ue(1,arguments);var t=qe(e);return t.setHours(23,59,59,999),t}(function(e,t){Ue(2,arguments);var n=qe(e),i=et(t);return isNaN(i)?new Date(NaN):i?(n.setDate(n.getDate()+i),n):n}(r,30))),a=`https://app.meetelise.com/api/pub/v1/buildings/${n}/tour/availabilities?startTime=${tn(r)}&endTime=${o}`,s=await t().get(a);return Tn.availabilities[n]=s.data,s.data},xn=async(e,t)=>{var n,i;const r=await An(t),o=(null===(n=r.availability)||void 0===n?void 0:n[e])?null===(i=r.availability)||void 0===i?void 0:i[e].availableTourStartTimes:[];return r.availability?{...r.availability[e],availableTourStartTimes:o}:null},On=async(e,t)=>{var n,i;const r=await xn(e,t);if(!r)return{};const o={availableTourStartTimes:null===(n=r.availableTourStartTimes?r.availableTourStartTimes.filter((e=>Je(un(e))&&!an(un(e)))):[])||void 0===n?void 0:n.map((e=>Cn(e)))};return on()(null!==(i=o.availableTourStartTimes)&&void 0!==i?i:[],(e=>Lt(new Date(e.datetime),"yyyy-MM-dd")))},Cn=e=>({datetime:e.slice(0,19),offset:e.slice(19)});var In=n(1763),Nn=n.n(In),En=n(6604),Rn=n.n(En),Pn=n(7037),_n=n.n(Pn),Fn=n(4184),Mn=n.n(Fn);async function Dn({chatId:e,website:n,referrer:i,buildingSlug:r,selectedLeadSource:o}){try{return(await t().post("https://app.meetelise.com/platformApi/webchat/lead-sourced",{chat_id:e,website:n,referrer:i,query_params:kn(),building_slug:r,timestamp:new Date,selected_lead_source:o})).data}catch(e){return null}}function kn(){return Object.fromEntries(new URLSearchParams(window.location.search))}const Un=e=>`https://app.meetelise.com/platformApi/webchat/${e}/chat-ui-feature-flag`;var qn;async function Bn(e){try{const n=await t().get(Un(e),{params:{building_slug:e,flag_type:"string",feature_flag:"webchat-marketing-source-dropdown-configuration",default_str:"always",default_bool:!0}});return"on-attribution-failure"===n.data?qn.onAttributionFailure:"never"===n.data?qn.never:qn.always}catch(e){return qn.always}}async function Ln(e){try{return(await t().get(Un(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-use-dni-phone-number-by-source",default_str:null,default_bool:!1}})).data}catch(e){return!1}}!function(e){e.onAttributionFailure="on-attribution-failure",e.never="never",e.always="always"}(qn||(qn={}));const Jn=(e,t={})=>{window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:e,...t})},jn=fe(class extends me{constructor(e){var t;if(super(e),1!==e.type||"style"!==e.name||(null===(t=e.strings)||void 0===t?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce(((t,n)=>{const i=e[n];return null==i?t:t+`${n=n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`}),"")}update(e,[t]){const{style:n}=e.element;if(void 0===this.ct){this.ct=new Set;for(const e in t)this.ct.add(e);return this.render(t)}this.ct.forEach((e=>{null==t[e]&&(this.ct.delete(e),e.includes("-")?n.removeProperty(e):n[e]="")}));for(const e in t){const i=t[e];null!=i&&(this.ct.add(e),e.includes("-")?n.setProperty(e,i):n[e]=i)}return J}}),Hn={fontSize:"10px",paddingTop:"4px"},Gn={color:"#4287f5"},zn=({buildingName:e,phoneNumberInput:t,emailInput:n})=>t?B` <div style=${jn(Hn)}>
|
|
475
|
+
`,Zt],$t([de({attribute:!1})],en.prototype,"options",void 0),$t([de({type:String})],en.prototype,"placeholder",void 0),$t([de({type:String})],en.prototype,"value",void 0),$t([ce()],en.prototype,"activeOption",void 0),$t([ce()],en.prototype,"isOpen",void 0),$t([pe("#select",!0)],en.prototype,"meSelect",void 0),en=$t([ue("me-select")],en);var nn=n(9991),rn=n(7739),on=n.n(rn);function an(e){return Ue(1,arguments),qe(e).getTime()<Date.now()}Math.pow(10,8);var sn=36e5;function un(e,t){Ue(1,arguments);var n=t||{},i=null==n.additionalDigits?2:et(n.additionalDigits);if(2!==i&&1!==i&&0!==i)throw new RangeError("additionalDigits must be 0, 1 or 2");if("string"!=typeof e&&"[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);var r,o=hn(e);if(o.date){var a=fn(o.date,i);r=mn(a.restDateString,a.year)}if(!r||isNaN(r.getTime()))return new Date(NaN);var s,u=r.getTime(),l=0;if(o.time&&(l=vn(o.time),isNaN(l)))return new Date(NaN);if(!o.timezone){var d=new Date(u+l),c=new Date(0);return c.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),c.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),c}return s=bn(o.timezone),isNaN(s)?new Date(NaN):new Date(u+l+s)}var ln={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},dn=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,cn=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,pn=/^([+-])(\d{2})(?::?(\d{2}))?$/;function hn(e){var t,n={},i=e.split(ln.dateTimeDelimiter);if(i.length>2)return n;if(/:/.test(i[0])?t=i[0]:(n.date=i[0],t=i[1],ln.timeZoneDelimiter.test(n.date)&&(n.date=e.split(ln.timeZoneDelimiter)[0],t=e.substr(n.date.length,e.length))),t){var r=ln.timezone.exec(t);r?(n.time=t.replace(r[1],""),n.timezone=r[1]):n.time=t}return n}function fn(e,t){var n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),i=e.match(n);if(!i)return{year:NaN,restDateString:""};var r=i[1]?parseInt(i[1]):null,o=i[2]?parseInt(i[2]):null;return{year:null===o?r:100*o,restDateString:e.slice((i[1]||i[2]).length)}}function mn(e,t){if(null===t)return new Date(NaN);var n=e.match(dn);if(!n)return new Date(NaN);var i=!!n[4],r=gn(n[1]),o=gn(n[2])-1,a=gn(n[3]),s=gn(n[4]),u=gn(n[5])-1;if(i)return function(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}(0,s,u)?function(e,t,n){var i=new Date(0);i.setUTCFullYear(e,0,4);var r=7*(t-1)+n+1-(i.getUTCDay()||7);return i.setUTCDate(i.getUTCDate()+r),i}(t,s,u):new Date(NaN);var l=new Date(0);return function(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(wn[t]||(Sn(e)?29:28))}(t,o,a)&&function(e,t){return t>=1&&t<=(Sn(e)?366:365)}(t,r)?(l.setUTCFullYear(t,o,Math.max(r,a)),l):new Date(NaN)}function gn(e){return e?parseInt(e):1}function vn(e){var t=e.match(cn);if(!t)return NaN;var n=yn(t[1]),i=yn(t[2]),r=yn(t[3]);return function(e,t,n){return 24===e?0===t&&0===n:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}(n,i,r)?n*sn+6e4*i+1e3*r:NaN}function yn(e){return e&&parseFloat(e.replace(",","."))||0}function bn(e){if("Z"===e)return 0;var t=e.match(pn);if(!t)return 0;var n="+"===t[1]?-1:1,i=parseInt(t[2]),r=t[3]&&parseInt(t[3])||0;return function(e,t){return t>=0&&t<=59}(0,r)?n*(i*sn+6e4*r):NaN}var wn=[31,null,31,30,31,30,31,31,30,31,30,31];function Sn(e){return e%400==0||e%4==0&&e%100!=0}const Tn={buildingId:null,availabilities:{}},An=async e=>{e&&(Tn.buildingId=e);const n=Tn.buildingId;if(!n)throw new Error("No buildingId was provided to getRawAvailabilities and there is no buildingId cached.");const i=Tn.availabilities;if(i[n])return i[n];const r=function(e){Ue(1,arguments);var t=qe(e);return t.setHours(0,0,0,0),t}(Date.now()),o=tn(function(e){Ue(1,arguments);var t=qe(e);return t.setHours(23,59,59,999),t}(function(e,t){Ue(2,arguments);var n=qe(e),i=et(t);return isNaN(i)?new Date(NaN):i?(n.setDate(n.getDate()+i),n):n}(r,30))),a=`https://app.meetelise.com/api/pub/v1/buildings/${n}/tour/availabilities?startTime=${tn(r)}&endTime=${o}`,s=await t().get(a);return Tn.availabilities[n]=s.data,s.data},xn=async(e,t)=>{var n,i;const r=await An(t),o=(null===(n=r.availability)||void 0===n?void 0:n[e])?null===(i=r.availability)||void 0===i?void 0:i[e].availableTourStartTimes:[];return r.availability?{...r.availability[e],availableTourStartTimes:o}:null},On=async(e,t)=>{var n,i;const r=await xn(e,t);if(!r)return{};const o={availableTourStartTimes:null===(n=r.availableTourStartTimes?r.availableTourStartTimes.filter((e=>Je(un(e))&&!an(un(e)))):[])||void 0===n?void 0:n.map((e=>Cn(e)))};return on()(null!==(i=o.availableTourStartTimes)&&void 0!==i?i:[],(e=>Lt(new Date(e.datetime),"yyyy-MM-dd")))},Cn=e=>({datetime:e.slice(0,19),offset:e.slice(19)});var In=n(1763),Nn=n.n(In),En=n(6604),Rn=n.n(En),Pn=n(7037),_n=n.n(Pn),Fn=n(4184),Mn=n.n(Fn);async function Dn({chatId:e,website:n,referrer:i,buildingSlug:r,selectedLeadSource:o}){try{return(await t().post("https://app.meetelise.com/platformApi/webchat/lead-sourced",{chat_id:e,website:n,referrer:i,query_params:kn(),building_slug:r,timestamp:new Date,selected_lead_source:o})).data}catch(e){return null}}function kn(){return Object.fromEntries(new URLSearchParams(window.location.search))}const Un=e=>`https://app.meetelise.com/platformApi/webchat/${e}/chat-ui-feature-flag`;var qn;async function Bn(e){if(!e)return qn.always;try{const n=await t().get(Un(e),{params:{building_slug:e,flag_type:"string",feature_flag:"webchat-marketing-source-dropdown-configuration",default_str:"always",default_bool:!0}});return"on-attribution-failure"===n.data?qn.onAttributionFailure:"never"===n.data?qn.never:qn.always}catch(e){return qn.always}}async function Ln(e){if(!e)return!1;try{return(await t().get(Un(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-use-dni-phone-number-by-source",default_str:null,default_bool:!1}})).data}catch(e){return!1}}!function(e){e.onAttributionFailure="on-attribution-failure",e.never="never",e.always="always"}(qn||(qn={}));const Jn=(e,t={})=>{window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:e,...t})},jn=fe(class extends me{constructor(e){var t;if(super(e),1!==e.type||"style"!==e.name||(null===(t=e.strings)||void 0===t?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce(((t,n)=>{const i=e[n];return null==i?t:t+`${n=n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`}),"")}update(e,[t]){const{style:n}=e.element;if(void 0===this.ct){this.ct=new Set;for(const e in t)this.ct.add(e);return this.render(t)}this.ct.forEach((e=>{null==t[e]&&(this.ct.delete(e),e.includes("-")?n.removeProperty(e):n[e]="")}));for(const e in t){const i=t[e];null!=i&&(this.ct.add(e),e.includes("-")?n.setProperty(e,i):n[e]=i)}return J}}),Hn={fontSize:"10px",paddingTop:"4px"},Gn={color:"#4287f5"},zn=({buildingName:e,phoneNumberInput:t,emailInput:n})=>t?B` <div style=${jn(Hn)}>
|
|
476
476
|
By providing your number and clicking submit, you consent to recurring
|
|
477
477
|
marketing text messages from or for
|
|
478
478
|
${e.length>0?e:"this building"} at this
|
|
@@ -2068,7 +2068,7 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
|
|
|
2068
2068
|
border-radius: 0px 0px 0px 0px;
|
|
2069
2069
|
}
|
|
2070
2070
|
}
|
|
2071
|
-
`,Di([de({type:String})],ki.prototype,"height",void 0),Di([de({type:String})],ki.prototype,"width",void 0),Di([de({type:Boolean})],ki.prototype,"useRoundedBorders",void 0),Di([de({type:String})],ki.prototype,"headerText",void 0),Di([de({attribute:!1})],ki.prototype,"onCloseClick",void 0),Di([ce()],ki.prototype,"isMobileSized",void 0),Di([de({attribute:!0})],ki.prototype,"useGradientDesign",void 0),ki=Di([ue("details-window")],ki);const Ui=()=>{window.customElements.get("details-window")||window.customElements.define("details-window",ki)};var qi=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 Bi=class extends ae{constructor(){super(...arguments),this.leadSources=[],this.chatId="",this.buildingId=0,this.buildingSlug="",this.orgSlug="",this.buildingName="",this.featureFlagShowDropdown="",this.phoneNumberInputRef=Oe(),this.privatePolicyUrl="https://www.meetelise.com/privacy",this.termsOfServiceUrl="_blank",this.firstName="",this.lastName="",this.email="",this.phoneNumber="",this.message="",this.currentLeadSource="",this.hasNameError=!1,this.hasEmailError=!1,this.hasPhoneNumberError=!1,this.hasMessageError=!1,this.hasSubmittedForm=!1,this.windowHeight=525,this.hasSubmissionError=!1,this.isSubmitting=!1,this.onChangeFirstName=e=>{e.target&&(this.firstName=e.target.value)},this.onChangeLastName=e=>{e.target&&(this.lastName=e.target.value)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.onChangePhoneNumber=e=>{if(!e.target||!this.phoneNumberInputRef.value)return;if(Me(e))return;const t=e.target;this.phoneNumber=Re(t.value),this.phoneNumberInputRef.value.value=this.phoneNumber},this.onChangeMessage=e=>{e.target&&(this.message=e.target.value)},this.enforceFormat=e=>{_e(e)||Me(e)||e.preventDefault()},this.validateFormFields=()=>{this.hasNameError=!1,this.hasEmailError=!1,this.hasPhoneNumberError=!1,this.hasMessageError=!1,this.hasSubmissionError=!1,this.firstName&&this.lastName||(this.hasNameError=!0),this.email
|
|
2071
|
+
`,Di([de({type:String})],ki.prototype,"height",void 0),Di([de({type:String})],ki.prototype,"width",void 0),Di([de({type:Boolean})],ki.prototype,"useRoundedBorders",void 0),Di([de({type:String})],ki.prototype,"headerText",void 0),Di([de({attribute:!1})],ki.prototype,"onCloseClick",void 0),Di([ce()],ki.prototype,"isMobileSized",void 0),Di([de({attribute:!0})],ki.prototype,"useGradientDesign",void 0),ki=Di([ue("details-window")],ki);const Ui=()=>{window.customElements.get("details-window")||window.customElements.define("details-window",ki)};var qi=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 Bi=class extends ae{constructor(){super(...arguments),this.leadSources=[],this.chatId="",this.buildingId=0,this.buildingSlug="",this.orgSlug="",this.buildingName="",this.featureFlagShowDropdown="",this.phoneNumberInputRef=Oe(),this.privatePolicyUrl="https://www.meetelise.com/privacy",this.termsOfServiceUrl="_blank",this.firstName="",this.lastName="",this.email="",this.phoneNumber="",this.message="",this.currentLeadSource="",this.hasNameError=!1,this.hasEmailError=!1,this.hasPhoneNumberError=!1,this.hasMessageError=!1,this.hasSubmittedForm=!1,this.windowHeight=525,this.hasSubmissionError=!1,this.isSubmitting=!1,this.onChangeFirstName=e=>{e.target&&(this.firstName=e.target.value)},this.onChangeLastName=e=>{e.target&&(this.lastName=e.target.value)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.onChangePhoneNumber=e=>{if(!e.target||!this.phoneNumberInputRef.value)return;if(Me(e))return;const t=e.target;this.phoneNumber=Re(t.value),this.phoneNumberInputRef.value.value=this.phoneNumber},this.onChangeMessage=e=>{e.target&&(this.message=e.target.value)},this.enforceFormat=e=>{_e(e)||Me(e)||e.preventDefault()},this.validateFormFields=()=>{this.hasNameError=!1,this.hasEmailError=!1,this.hasPhoneNumberError=!1,this.hasMessageError=!1,this.hasSubmissionError=!1,this.firstName&&this.lastName||(this.hasNameError=!0),this.email&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(this.email)||(this.hasEmailError=!0),this.phoneNumber&&14===this.phoneNumber.length||(this.hasPhoneNumberError=!0),this.message||(this.hasMessageError=!0),this.windowHeight=525+30*this.getNumErrors()},this.onClick=async()=>{if(!(this.isSubmitting||(this.validateFormFields(),this.hasNameError||this.hasEmailError||this.hasPhoneNumberError||this.hasMessageError)))try{this.isSubmitting=!0,this.windowHeight=585;const e=this.selectedLeadSource&&this.selectedLeadSource.value?this.selectedLeadSource.value:this.currentLeadSource;await Li(this.firstName,this.lastName,this.email,this.phoneNumber,this.message,this.buildingId,this.orgSlug,this.buildingSlug,[...new Set(e?[e,"property-website"]:["property-website"])]),Dn({chatId:this.chatId,website:window.location.origin,referrer:document.referrer,buildingSlug:this.buildingSlug,selectedLeadSource:null!=e?e:""}),this.hasSubmittedForm=!0,this.isSubmitting=!1,this.windowHeight=525}catch(e){this.hasSubmissionError=!0,this.isSubmitting=!1,this.windowHeight=525}},this.getNumErrors=()=>[this.hasNameError,this.hasEmailError,this.hasPhoneNumberError,this.hasMessageError,this.hasSubmissionError].filter((e=>e)).length,this.render=()=>(Ui(),Mi(),this.hasSubmittedForm?B`
|
|
2072
2072
|
<details-window
|
|
2073
2073
|
headerText=""
|
|
2074
2074
|
useGradientDesign="true"
|
|
@@ -3249,7 +3249,7 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
|
|
|
3249
3249
|
</button>
|
|
3250
3250
|
</div>
|
|
3251
3251
|
</div>
|
|
3252
|
-
`:B``}};Ur.styles=[Fr],kr([de({attribute:!0})],Ur.prototype,"channel",void 0),kr([de({attribute:!0})],Ur.prototype,"myPubnub",void 0),kr([de({attribute:!0})],Ur.prototype,"buildingSlug",void 0),kr([de({attribute:!0})],Ur.prototype,"building",void 0),kr([de({attribute:!0})],Ur.prototype,"brandColor",void 0),kr([de({attribute:!0})],Ur.prototype,"onClickExit",void 0),kr([de({attribute:!0})],Ur.prototype,"onMount",void 0),kr([pe("#message-input",!0)],Ur.prototype,"messageInput",void 0),kr([pe("#conversation-body",!0)],Ur.prototype,"messageBody",void 0),kr([ce()],Ur.prototype,"messages",void 0),kr([ce()],Ur.prototype,"isMobile",void 0),kr([ce()],Ur.prototype,"isLoadingMessages",void 0),kr([ce()],Ur.prototype,"websitePreviewMapping",void 0),Ur=kr([ue("pubnub-chat")],Ur);var qr,Br,Lr=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};!function(e){e.TALKJS="talkjs",e.PUBNUB="pubnub"}(Br||(Br={}));let Jr=qr=class extends ae{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.themeId="Glass",this.useMiniWidget=!0,this.launcherStyles={},this.isMinimized=!1,this.brandColor=null,this.popup=null,this.theme=Si({themeId:this.themeId,brandColor:this.brandColor}),this.chatId="",this.analytics=null,this.isMobile=r(),this.launcher=null,this.building=null,this.buildingABTestType=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=qn.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.talkjsPopupElement=null,this.chatProvider=Br.TALKJS,this.displayPubnubChat=!1,this.myPubnub=null,this.yardiDNIScriptInterval=null,this.launcherRef=Oe(),this.initializeInstanceVariables=async()=>{qr.session=Ee.ready.then((()=>{const e=new Ee.User({id:"anonymous-"+di(this.orgSlug,this.buildingSlug),name:"Me",email:null,role:"Default"});return new Ee.Session({appId:"ogKIvCor",me:e})})),await this.setBuildingDerivedInfo(),await this.initializeLaunchJS()&&(this.attachOnClickToLauncher(),this.isLoading=!1)},this.setBuildingDerivedInfo=async()=>{var e,n,i;if(!this.buildingSlug||!this.orgSlug)return;const r=await Ai(this.orgSlug,this.buildingSlug);if(1!==r.active)return;const[o,a,s,u,l,d]=await Promise.all([Ii(this.buildingSlug),Cr(this.buildingSlug),Ni(this.buildingSlug,document.referrer),Bn(this.buildingSlug),Ln(this.buildingSlug),Ci(this.buildingSlug)]);r.phoneNumber=Pe(r.phoneNumber),this.building=r,this.buildingABTestType=null!==(e=null==o?void 0:o.abTestType)&&void 0!==e?e:"",this.leadSources=a,this.currentLeadSource=s,this.featureFlagShowDropdown=u,d&&(null===this.brandColor&&(this.brandColor=null!==(n=d.primaryColor)&&void 0!==n?n:null),this.isMinimized=!!d.autoMinimize,d.designConcept&&(d.designConcept===xi.MINIMIZED&&(this.isMobile=!0),d.designConcept===xi.PILLS&&(this.buildingABTestType=null),d.designConcept===xi.EMOJI&&(this.buildingABTestType=Oi.ConceptEmoji))),null===this.brandColor&&(this.brandColor=vi);let c=null;l&&(c=await async function(e,n){try{const i=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${n}`);return i.data?{number:Pe(i.data.number),isMatch:i.data.isMatch,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,this.currentLeadSource)),this.phoneNumberForSource=c||{number:this.building.phoneNumber,isMatch:!1,isPropertyWebsiteCatchall:!0},this.currentLeadSource&&(this.leadSources.includes(this.currentLeadSource)||this.leadSources.push(this.currentLeadSource)),An(this.building.id),this.chatId=di(this.orgSlug,this.buildingSlug),this.avatarSrc=this.avatarSrc||this.building.avatarSrc,this.theme=Si({themeId:null!==(i=this.themeId)&&void 0!==i?i:this.building.themeId,brandColor:this.brandColor}),this.analytics=new Zn(this.orgSlug,this.buildingSlug,this.chatId,this.currentLeadSource),this.analytics.ping("webchat_heartbeat")},this.initializeLaunchJS=async()=>{var e;if(!this.building||!this.theme)return;if(this.popup&&this.launcher)return;const[t,n,i,r]=await Promise.all([this.building,this.theme,this.avatarSrc,qr.session]);return t.conversationMaintenanceMode?(console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear."),!1):r?(await this.configureTalkJSPopup(t,n,r,i),this.configureLauncherElement(),null===(e=this.analytics)||void 0===e||e.ping("load"),this.yardiDNIScriptInterval=setInterval((()=>this.pollForYardiCampaignSource()),1e3),setTimeout(clearInterval,15e3,this.yardiDNIScriptInterval),!0):void 0},this.configureLauncherElement=()=>{this.popup&&this.launcherRef.value&&(this.launcher=this.launcherRef.value)},this.configureTalkJSPopup=async(e,t,n,i)=>{var r;const o=n.createPopup(Ti(n,e,t,i||e.avatarSrc,this.chatId,this.isMobile),{launcher:"never",showCloseInHeader:!0,messageField:{placeholder:"Ask a question..."}});await o.mount({show:!1}),o.on("close",(()=>{this.hideLauncher=!1}));const a=document.querySelector(".__talkjs_popup");if(this.talkjsPopupElement=a,!a)throw new Error("Failed to find chat window");a.classList.add("meetelise-chat","pane"),this.isMobile||a.classList.add("launcher__desktop"),a.style.zIndex="99999999999",this.popup=o,this.shouldAutoOpenChat(e.autoOpenChatWidget)&&(this.popup.show(),this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp(),null===(r=this.analytics)||void 0===r||r.ping("autoOpen"))},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!an(un(t)));return!!e&&!!n&&!r()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",tn(function(e,t){Ue(2,arguments);var n=et(t);return tt(e,6e4*n)}(new Date,15)))},this.firstUpdated=async()=>{await async function(e){try{return(await t().get(Un(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"use-pubnub-chat-provider",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(this.buildingSlug)?(this.chatProvider=Br.PUBNUB,this.initializePubnubVariables()):this.initializeInstanceVariables()},this.initializePubnubVariables=async()=>{await this.setBuildingDerivedInfo(),this.building&&(this.building.conversationMaintenanceMode?console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear."):(this.myPubnub=new class{constructor(e,t,n){this.apiHost="https://app.meetelise.com",this.building=null,this.ttlHours=24,this.eliseResponseTimeout=null,this.pubnub=null,this.leadUserId="",this.channel="",this.chatListener=null,this.messages=[],this.listenerParams={message:e=>{var t;this.messages=[...this.messages,{channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken}];const n="eliseai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.messages,isLoading:n}),!n&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=n}},this.isLoadingMessages=!1,this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){ti({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},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&&!await this.initializePubnub())return;await this.withAuthToken((async()=>{var t,n;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),ti({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}),45e3),await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(t=this.building)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,userId:null===(n=this.building)||void 0===n?void 0:n.userId}}))})),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.createChatStorageKey=e=>{const t=tn(new Date),n=null!=e?e:`lead_${li()}_${this.buildingSlug}`;return localStorage.setItem("com.eliseai.webchat.slug="+this.buildingSlug,JSON.stringify({buildingSlug:this.buildingSlug,leadId:n,timestamp:t})),{leadId:n,timestamp:un(t),buildingSlug:this.buildingSlug}},this.getChatStorageKey=(e=!0)=>{const t=localStorage.getItem("com.eliseai.webchat.slug="+this.buildingSlug);if(t)try{const e=JSON.parse(t),n=e.buildingSlug,i=e.leadId,r=new Date(e.timestamp);if(this.isChatKeyValid({leadId:i,timestamp:r,buildingSlug:n}))return{leadId:i,timestamp:r,buildingSlug:n}}catch(e){console.warn("Error getting chat storage key")}return e?this.createChatStorageKey():{leadId:null,timestamp:null,buildingSlug:null}},this.isChatKeyValid=e=>{if(e.buildingSlug!==this.buildingSlug||!e.leadId||!e.timestamp)return!1;const t=Rr(new Date,this.ttlHours);return function(e,t){Ue(2,arguments);var n=qe(e),i=qe(t);return n.getTime()<i.getTime()}(e.timestamp,t)},this.buildingSlug=e,this.building=t,this.orgSlug=n}addChatListener(e){this.chatListener=e}async initializePubnub(){const e=this.getChatStorageKey();if(!e.leadId)return void ti({logTitle:"PUBNUB_ERROR_FETCHING_STORAGE_KEY",logData:{channel:this.channel,eliseaiLocalStorageValue:e,leadUserId:this.leadUserId},logType:ei.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});this.leadUserId=e.leadId,this.channel=`webchat_${this.leadUserId}`,e.timestamp&&function(e,t){Ue(2,arguments);var n=qe(e),i=qe(t);return n.getTime()>i.getTime()}(e.timestamp,Rr(new Date,this.ttlHours))&&this.createChatStorageKey(this.leadUserId);const t=await this.fetchToken(this.leadUserId,this.channel);return t?(this.pubnub=new(Nr())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,n){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${n}`)).data}catch(e){ti({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:ei.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){ti({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(n){if(n instanceof e.AxiosError&&n&&n.response&&403===n.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const e=await this.fetchToken(this.leadUserId,this.channel);if(!e)return;this.pubnub.setAuthKey(e.auth.result.token),await t()}catch(e){ti({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(){var e;try{const t=await new Promise(((e,t)=>{this.pubnub&&this.channel&&this.pubnub.fetchMessages({channels:[this.channel],count:100},((n,i)=>{n.error?(ti({logTitle:"PUBNUB_ERROR_FETCHING_HISTORY",logData:{channel:this.channel,status:n,response:i},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),t(n)):e(i)}))}));if(this.channel&&0!==Object.keys(t.channels).length){const n=t.channels[this.channel],i=[];n.forEach((e=>{e.uuid&&i.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})})),this.messages=i,null===(e=this.chatListener)||void 0===e||e.call(this,{messages:this.messages,isLoading:!1})}}catch(e){ti({logTitle:"PUBNUB_ERROR_FETCHING_HISTORY",logData:{error:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}(this.buildingSlug,this.building,this.orgSlug),this.myPubnub.isChatKeyValid(this.myPubnub.getChatStorageKey(!1))&&await this.myPubnub.initializePubnub(),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(this.building.autoOpenChatWidget)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1))},this.handleContactClicked=e=>{var t,n;this.chatProvider===Br.TALKJS?null===(t=this.popup)||void 0===t||t.hide():this.chatProvider===Br.PUBNUB&&(this.displayPubnubChat=!1),this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickEmailOption(e)},this.handleTourClicked=e=>{var t,n;this.chatProvider===Br.TALKJS?null===(t=this.popup)||void 0===t||t.hide():this.chatProvider===Br.PUBNUB&&(this.displayPubnubChat=!1),this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickSSTOption(e)},this.handleContactTabClicked=e=>{var t,n;this.chatProvider===Br.TALKJS?null===(t=this.popup)||void 0===t||t.hide():this.chatProvider===Br.PUBNUB&&(this.displayPubnubChat=!1),this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickPhoneOption(e)},this.adjustTopHeaderContactCoords=()=>{var e,t,n,i;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById(this.chatProvider===Br.TALKJS?"chatAdditionalActionsTalkjs":"chatAdditionalActionsPubnub");if(r)if(this.chatProvider===Br.TALKJS&&this.talkjsPopupElement){const e=this.talkjsPopupElement.getBoundingClientRect();r.style.left=`${e.left+20}px`,r.style.top=e.bottom-24+"px"}else if(this.chatProvider===Br.PUBNUB){const e=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"),o=null==e?void 0:e.getBoundingClientRect();if(!o)return;r.style.left=`${o.left}px`,r.style.top=`${o.bottom}px`}},this.onClickMinimize=e=>{e.preventDefault(),e.stopPropagation(),this.isMinimized=!this.isMinimized},this.renderChatAdditionalActions=(e,t)=>{var n,i,r,o,a,s,u,l;return B` <div
|
|
3252
|
+
`:B``}};Ur.styles=[Fr],kr([de({attribute:!0})],Ur.prototype,"channel",void 0),kr([de({attribute:!0})],Ur.prototype,"myPubnub",void 0),kr([de({attribute:!0})],Ur.prototype,"buildingSlug",void 0),kr([de({attribute:!0})],Ur.prototype,"building",void 0),kr([de({attribute:!0})],Ur.prototype,"brandColor",void 0),kr([de({attribute:!0})],Ur.prototype,"onClickExit",void 0),kr([de({attribute:!0})],Ur.prototype,"onMount",void 0),kr([pe("#message-input",!0)],Ur.prototype,"messageInput",void 0),kr([pe("#conversation-body",!0)],Ur.prototype,"messageBody",void 0),kr([ce()],Ur.prototype,"messages",void 0),kr([ce()],Ur.prototype,"isMobile",void 0),kr([ce()],Ur.prototype,"isLoadingMessages",void 0),kr([ce()],Ur.prototype,"websitePreviewMapping",void 0),Ur=kr([ue("pubnub-chat")],Ur);var qr,Br,Lr=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};!function(e){e.TALKJS="talkjs",e.PUBNUB="pubnub"}(Br||(Br={}));let Jr=qr=class extends ae{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.themeId="Glass",this.useMiniWidget=!0,this.launcherStyles={},this.isMinimized=!1,this.brandColor=null,this.popup=null,this.theme=Si({themeId:this.themeId,brandColor:this.brandColor}),this.chatId="",this.analytics=null,this.isMobile=r(),this.launcher=null,this.building=null,this.buildingABTestType=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=qn.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.talkjsPopupElement=null,this.chatProvider=Br.TALKJS,this.displayPubnubChat=!1,this.myPubnub=null,this.yardiDNIScriptInterval=null,this.launcherRef=Oe(),this.initializeInstanceVariables=async()=>{qr.session=Ee.ready.then((()=>{const e=new Ee.User({id:"anonymous-"+di(this.orgSlug,this.buildingSlug),name:"Me",email:null,role:"Default"});return new Ee.Session({appId:"ogKIvCor",me:e})})),await this.setBuildingDerivedInfo(),await this.initializeLaunchJS()&&(this.attachOnClickToLauncher(),this.isLoading=!1)},this.setBuildingDerivedInfo=async()=>{var e,n,i;if(!this.buildingSlug||!this.orgSlug)return;const r=await Ai(this.orgSlug,this.buildingSlug);if(1!==r.active)return;const[o,a,s,u,l,d]=await Promise.all([Ii(this.buildingSlug),Cr(this.buildingSlug),Ni(this.buildingSlug,document.referrer),Bn(this.buildingSlug),Ln(this.buildingSlug),Ci(this.buildingSlug)]);r.phoneNumber=Pe(r.phoneNumber),this.building=r,this.buildingABTestType=null!==(e=null==o?void 0:o.abTestType)&&void 0!==e?e:"",this.leadSources=a,this.currentLeadSource=s,this.featureFlagShowDropdown=u,d&&(null===this.brandColor&&(this.brandColor=null!==(n=d.primaryColor)&&void 0!==n?n:null),this.isMinimized=!!d.autoMinimize,d.designConcept&&(d.designConcept===xi.MINIMIZED&&(this.isMobile=!0),d.designConcept===xi.PILLS&&(this.buildingABTestType=null),d.designConcept===xi.EMOJI&&(this.buildingABTestType=Oi.ConceptEmoji))),null===this.brandColor&&(this.brandColor=vi);let c=null;l&&(c=await async function(e,n){try{const i=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${n}`);return i.data?{number:Pe(i.data.number),isMatch:i.data.isMatch,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,this.currentLeadSource)),this.phoneNumberForSource=c||{number:this.building.phoneNumber,isMatch:!1,isPropertyWebsiteCatchall:!0},this.currentLeadSource&&(this.leadSources.includes(this.currentLeadSource)||this.leadSources.push(this.currentLeadSource)),An(this.building.id),this.chatId=di(this.orgSlug,this.buildingSlug),this.avatarSrc=this.avatarSrc||this.building.avatarSrc,this.theme=Si({themeId:null!==(i=this.themeId)&&void 0!==i?i:this.building.themeId,brandColor:this.brandColor}),this.analytics=new Zn(this.orgSlug,this.buildingSlug,this.chatId,this.currentLeadSource),this.analytics.ping("webchat_heartbeat")},this.initializeLaunchJS=async()=>{var e;if(!this.building||!this.theme)return;if(this.popup&&this.launcher)return;const[t,n,i,r]=await Promise.all([this.building,this.theme,this.avatarSrc,qr.session]);return t.conversationMaintenanceMode?(console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear."),!1):r?(await this.configureTalkJSPopup(t,n,r,i),this.configureLauncherElement(),null===(e=this.analytics)||void 0===e||e.ping("load"),this.yardiDNIScriptInterval=setInterval((()=>this.pollForYardiCampaignSource()),1e3),setTimeout(clearInterval,15e3,this.yardiDNIScriptInterval),!0):void 0},this.configureLauncherElement=()=>{this.popup&&this.launcherRef.value&&(this.launcher=this.launcherRef.value)},this.configureTalkJSPopup=async(e,t,n,i)=>{var r;const o=n.createPopup(Ti(n,e,t,i||e.avatarSrc,this.chatId,this.isMobile),{launcher:"never",showCloseInHeader:!0,messageField:{placeholder:"Ask a question..."}});await o.mount({show:!1}),o.on("close",(()=>{this.hideLauncher=!1}));const a=document.querySelector(".__talkjs_popup");if(this.talkjsPopupElement=a,!a)throw new Error("Failed to find chat window");a.classList.add("meetelise-chat","pane"),this.isMobile||a.classList.add("launcher__desktop"),a.style.zIndex="99999999999",this.popup=o,this.shouldAutoOpenChat(e.autoOpenChatWidget)&&(this.popup.show(),this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp(),null===(r=this.analytics)||void 0===r||r.ping("autoOpen"))},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!an(un(t)));return!!e&&!!n&&!r()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",tn(function(e,t){Ue(2,arguments);var n=et(t);return tt(e,6e4*n)}(new Date,15)))},this.firstUpdated=async()=>{await async function(e){if(!e)return!1;try{return(await t().get(Un(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"use-pubnub-chat-provider",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(this.buildingSlug)?(this.chatProvider=Br.PUBNUB,this.initializePubnubVariables()):this.initializeInstanceVariables()},this.initializePubnubVariables=async()=>{await this.setBuildingDerivedInfo(),this.building&&(this.building.conversationMaintenanceMode?console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear."):(this.myPubnub=new class{constructor(e,t,n){this.apiHost="https://app.meetelise.com",this.building=null,this.ttlHours=24,this.eliseResponseTimeout=null,this.pubnub=null,this.leadUserId="",this.channel="",this.chatListener=null,this.messages=[],this.listenerParams={message:e=>{var t;this.messages=[...this.messages,{channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken}];const n="eliseai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.messages,isLoading:n}),!n&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=n}},this.isLoadingMessages=!1,this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){ti({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},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&&!await this.initializePubnub())return;await this.withAuthToken((async()=>{var t,n;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),ti({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}),45e3),await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(t=this.building)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,userId:null===(n=this.building)||void 0===n?void 0:n.userId}}))})),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.createChatStorageKey=e=>{const t=tn(new Date),n=null!=e?e:`lead_${li()}_${this.buildingSlug}`;return localStorage.setItem("com.eliseai.webchat.slug="+this.buildingSlug,JSON.stringify({buildingSlug:this.buildingSlug,leadId:n,timestamp:t})),{leadId:n,timestamp:un(t),buildingSlug:this.buildingSlug}},this.getChatStorageKey=(e=!0)=>{const t=localStorage.getItem("com.eliseai.webchat.slug="+this.buildingSlug);if(t)try{const e=JSON.parse(t),n=e.buildingSlug,i=e.leadId,r=new Date(e.timestamp);if(this.isChatKeyValid({leadId:i,timestamp:r,buildingSlug:n}))return{leadId:i,timestamp:r,buildingSlug:n}}catch(e){console.warn("Error getting chat storage key")}return e?this.createChatStorageKey():{leadId:null,timestamp:null,buildingSlug:null}},this.isChatKeyValid=e=>{if(e.buildingSlug!==this.buildingSlug||!e.leadId||!e.timestamp)return!1;const t=Rr(new Date,this.ttlHours);return function(e,t){Ue(2,arguments);var n=qe(e),i=qe(t);return n.getTime()<i.getTime()}(e.timestamp,t)},this.buildingSlug=e,this.building=t,this.orgSlug=n}addChatListener(e){this.chatListener=e}async initializePubnub(){const e=this.getChatStorageKey();if(!e.leadId)return void ti({logTitle:"PUBNUB_ERROR_FETCHING_STORAGE_KEY",logData:{channel:this.channel,eliseaiLocalStorageValue:e,leadUserId:this.leadUserId},logType:ei.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});this.leadUserId=e.leadId,this.channel=`webchat_${this.leadUserId}`,e.timestamp&&function(e,t){Ue(2,arguments);var n=qe(e),i=qe(t);return n.getTime()>i.getTime()}(e.timestamp,Rr(new Date,this.ttlHours))&&this.createChatStorageKey(this.leadUserId);const t=await this.fetchToken(this.leadUserId,this.channel);return t?(this.pubnub=new(Nr())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,n){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${n}`)).data}catch(e){ti({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:ei.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){ti({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(n){if(n instanceof e.AxiosError&&n&&n.response&&403===n.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const e=await this.fetchToken(this.leadUserId,this.channel);if(!e)return;this.pubnub.setAuthKey(e.auth.result.token),await t()}catch(e){ti({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(){var e;try{const t=await new Promise(((e,t)=>{this.pubnub&&this.channel&&this.pubnub.fetchMessages({channels:[this.channel],count:100},((n,i)=>{n.error?(ti({logTitle:"PUBNUB_ERROR_FETCHING_HISTORY",logData:{channel:this.channel,status:n,response:i},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),t(n)):e(i)}))}));if(this.channel&&0!==Object.keys(t.channels).length){const n=t.channels[this.channel],i=[];n.forEach((e=>{e.uuid&&i.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})})),this.messages=i,null===(e=this.chatListener)||void 0===e||e.call(this,{messages:this.messages,isLoading:!1})}}catch(e){ti({logTitle:"PUBNUB_ERROR_FETCHING_HISTORY",logData:{error:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}(this.buildingSlug,this.building,this.orgSlug),this.myPubnub.isChatKeyValid(this.myPubnub.getChatStorageKey(!1))&&await this.myPubnub.initializePubnub(),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(this.building.autoOpenChatWidget)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1))},this.handleContactClicked=e=>{var t,n;this.chatProvider===Br.TALKJS?null===(t=this.popup)||void 0===t||t.hide():this.chatProvider===Br.PUBNUB&&(this.displayPubnubChat=!1),this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickEmailOption(e)},this.handleTourClicked=e=>{var t,n;this.chatProvider===Br.TALKJS?null===(t=this.popup)||void 0===t||t.hide():this.chatProvider===Br.PUBNUB&&(this.displayPubnubChat=!1),this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickSSTOption(e)},this.handleContactTabClicked=e=>{var t,n;this.chatProvider===Br.TALKJS?null===(t=this.popup)||void 0===t||t.hide():this.chatProvider===Br.PUBNUB&&(this.displayPubnubChat=!1),this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickPhoneOption(e)},this.adjustTopHeaderContactCoords=()=>{var e,t,n,i;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById(this.chatProvider===Br.TALKJS?"chatAdditionalActionsTalkjs":"chatAdditionalActionsPubnub");if(r)if(this.chatProvider===Br.TALKJS&&this.talkjsPopupElement){const e=this.talkjsPopupElement.getBoundingClientRect();r.style.left=`${e.left+20}px`,r.style.top=e.bottom-24+"px"}else if(this.chatProvider===Br.PUBNUB){const e=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"),o=null==e?void 0:e.getBoundingClientRect();if(!o)return;r.style.left=`${o.left}px`,r.style.top=`${o.bottom}px`}},this.onClickMinimize=e=>{e.preventDefault(),e.stopPropagation(),this.isMinimized=!this.isMinimized},this.renderChatAdditionalActions=(e,t)=>{var n,i,r,o,a,s,u,l;return B` <div
|
|
3253
3253
|
id=${e}
|
|
3254
3254
|
class=${ge({showTab:t,hideTab:!t})}
|
|
3255
3255
|
>
|
|
@@ -209,7 +209,8 @@ export class EmailUsWindow extends LitElement {
|
|
|
209
209
|
if (!this.firstName || !this.lastName) {
|
|
210
210
|
this.hasNameError = true;
|
|
211
211
|
}
|
|
212
|
-
|
|
212
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
213
|
+
if (!this.email || !emailRegex.test(this.email)) {
|
|
213
214
|
this.hasEmailError = true;
|
|
214
215
|
}
|
|
215
216
|
if (!this.phoneNumber || this.phoneNumber.length !== 14) {
|
package/src/fetchFeatureFlag.ts
CHANGED
|
@@ -14,6 +14,9 @@ export enum FeatureFlagsShowDropdown {
|
|
|
14
14
|
export async function fetchFeatureFlagShowMarketingSourceDropdown(
|
|
15
15
|
buildingSlug: string
|
|
16
16
|
): Promise<FeatureFlagsShowDropdown> {
|
|
17
|
+
if (!buildingSlug) {
|
|
18
|
+
return FeatureFlagsShowDropdown.always;
|
|
19
|
+
}
|
|
17
20
|
try {
|
|
18
21
|
const featureFlagResponse = await axios.get(
|
|
19
22
|
featureFlagEndpoint(buildingSlug),
|
|
@@ -42,6 +45,9 @@ export async function fetchFeatureFlagShowMarketingSourceDropdown(
|
|
|
42
45
|
export async function fetchFeatureFlagUsePhoneNumberBySource(
|
|
43
46
|
buildingSlug: string
|
|
44
47
|
): Promise<boolean> {
|
|
48
|
+
if (!buildingSlug) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
45
51
|
try {
|
|
46
52
|
const featureFlagResponse = await axios.get(
|
|
47
53
|
featureFlagEndpoint(buildingSlug),
|
|
@@ -88,6 +94,9 @@ export async function fetchFeatureFlagUseOverrideContactUsForm(
|
|
|
88
94
|
export async function fetchFeatureFlagUsePubnub(
|
|
89
95
|
buildingSlug: string
|
|
90
96
|
): Promise<boolean> {
|
|
97
|
+
if (!buildingSlug) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
91
100
|
try {
|
|
92
101
|
const featureFlagResponse = await axios.get(
|
|
93
102
|
featureFlagEndpoint(buildingSlug),
|