@meetelise/chat 1.51.1 → 1.51.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.51.1",
3
+ "version": "1.51.2",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/MeetElise/chat-ui#readme",
@@ -1478,7 +1478,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
1478
1478
  gap: 12px;
1479
1479
  align-items: center;
1480
1480
  }
1481
- `;class Uo{constructor(e,t,n,i){this.org=e,this.building=t,this.chatId=n,this.incomingProcessedLeadSource=i,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:Ro(),incomingProcessedLeadSource:this.incomingProcessedLeadSource,webchatVersion:null!==(t="MISSING_ENV_VAR".npm_package_version)&&void 0!==t?t:"1.20.155"})})}}const Ro=()=>{var e,t,n,i,r,o;try{const i=new URL(window.location.href).searchParams,r=null!==(n=null===(t=null===(e=window.RCTPCampaign)||void 0===e?void 0:e.CampaignDetails)||void 0===t?void 0:t.Source)&&void 0!==n?n:null,o=i.get("switch_cls[id]"),a=i.get("ilm"),s=i.get("utm_source");return{entrataCampaignSource:o,realpageCampaignSource:a,utmCampaignSource:s,yardiCampaignSource:r,bozzutoAdSource:Ir("bozzuto_ad_source")}}catch(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 n=t.contentWindow.URL;if(!n)return{entrataCampaignSource:null,realpageCampaignSource:null,utmCampaignSource:null,yardiCampaignSource:null,bozzutoAdSource:null};const a=new n(window.location.href).searchParams,s=null!==(o=null===(r=null===(i=window.RCTPCampaign)||void 0===i?void 0:i.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:Ir("bozzuto_ad_source")}}};var Bo;!function(e){e.error="error",e.info="info",e.warn="warn"}(Bo||(Bo={}));const jo=async({logType:e,buildingSlug:t,orgSlug:n,logTitle:i,logData:o})=>{await r().post("https://app.meetelise.com/platformApi/webchat/logging",{...o},{headers:{"Content-Type":"application/json","building-slug":null!=t?t:"","org-slug":null!=n?n:"","log-type":null!=e?e:Bo.error,"log-title":i.toUpperCase().replace(/\s/g,"_")}})},Fo=async({params:e,sampleRate:t})=>{try{if(Math.random()>=t)return;await r().post("https://app.meetelise.com/platformApi/webchat/log/signal",{...e,website_origin:window.location.origin,website_search:window.location.search})}catch(e){}};var Ho=n(2193),Go=n.n(Ho);function zo(e){return"avb"===e?"AVB Company Website":"windsor"===e?"Windsorcommunities.com":"property-website"}const Qo=class{constructor(){this.chatId=null,this.apiHost="https://app.meetelise.com",this.leadSource=null,this.leadSourceParams=null,this.localStorageTTLDays=30,this.buildingId=null,this.orgId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,n,i,r)=>{const o=mo();if(this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:o,referrer:document.referrer,parsedUtmSource:o?o.utm_source:null,campaignSources:Object.values(Ro()).filter(e=>e)},i)return;if(!r){const t=this.getLeadSourceBodyIfValid(e);if(t){if(!Pr(t.timestamp,24*this.localStorageTTLDays))return{...t,timestamp:Wr(t.timestamp)}}}const a={leadSource:t,leadSourceParams:this.leadSourceParams,leadId:n,buildingSlug:e,timestamp:Rr(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(a)),{...a,timestamp:Wr(a.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const n=JSON.parse(t);if(n.buildingSlug===e&&n.leadSource&&n.leadId&&n.timestamp&&!Pr(Wr(n.timestamp),24*this.localStorageTTLDays)){try{this.leadSourceInput=n.leadSourceInput}catch(e){}return n}}catch(e){return null}return null},this.resetLeadSource=()=>{if(!this.buildingSlug)return!1;const e="com.elise.webchat.leadsource.slug="+this.buildingSlug;return localStorage.removeItem(e),!0}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:t,referrer:n,campaignSources:i}){var o,a;const s={query_params:t,building_slug:e,referrer:n,campaign_sources:i};try{if(52!==this.orgId){return(await r().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,s)).data}const e=(await r().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source-with-params`,s)).data;return this.leadSourceParams=null!==(o=null==e?void 0:e.utm_params)&&void 0!==o?o:null,null!==(a=null==e?void 0:e.source)&&void 0!==a?a:null}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:t}){var n,i,o,a,s,l,u;try{if(!this.chatId)return null;if(!this.orgSlug)return null;let d=null,c=null;try{if("f1ba5a20-d207-4e5a-879e-65199e7d0a53"===this.orgSlug){const e=await this.getCookieValue("_ga");e&&(d=e),c=null===(n=window.dataLayer.find(e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)}))||void 0===n?void 0:n.value}}catch(e){}return await r().post(`${this.apiHost}/platformApi/webchat/log/lead-source`,{chat_id:this.chatId,webchat_action:e,state_id:t,building_id:this.buildingId,org_slug:this.orgSlug,building_slug:this.buildingSlug,website_origin:null===(i=this.leadSourceInput)||void 0===i?void 0:i.websiteOrigin,website_search:null===(o=this.leadSourceInput)||void 0===o?void 0:o.websiteSearch,query_parameters:null===(a=this.leadSourceInput)||void 0===a?void 0:a.queryParameters,referrer:null===(s=this.leadSourceInput)||void 0===s?void 0:s.referrer,parsed_utm_source:null===(l=this.leadSourceInput)||void 0===l?void 0:l.parsedUtmSource,campaign_sources:null===(u=this.leadSourceInput)||void 0===u?void 0:u.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:Go()(d)?null:d,extras:null!=c?c:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const i=t[n].trim();if(i.startsWith(e+"=")){return i.substring((e+"=").length,-1===i.indexOf(";")?void 0:i.indexOf(";"))}}return null}catch(e){}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:n}){var i,r,o;try{const a={queryParams:mo(),buildingSlug:n,referrer:document.referrer,campaignSources:Ro()};let s=!1;const l=n?this.getLeadSourceBodyIfValid(n):null;if(l){if(!["test-company","daf00bd2-1ecb-482c-b6f4-e1c5511a01be"].includes(t))return this.leadSource=l.leadSource,this.leadSourceParams=null!==(r=l.leadSourceParams)&&void 0!==r?r:null,this.leadSource;{const e=await this.fetchCurrentParsedLeadSource(a);if(!e)return this.leadSource=l.leadSource,this.leadSourceParams=null!==(i=l.leadSourceParams)&&void 0!==i?i:null,this.leadSource;this.leadSource=e,s=!0}}const u=await this.fetchCurrentParsedLeadSource(a);if(this.leadSource=u,this.buildingId=null,this.orgSlug=t,this.buildingSlug=n,n&&!u){const e=this.getLeadSourceBodyIfValid(n);if(e)return this.leadSource=e.leadSource,this.leadSourceParams=null!==(o=e.leadSourceParams)&&void 0!==o?o:null,this.leadSource}if(n){const t=!!u&&u.length>0;this.updateLeadSourceLocalStorage(n,u,e,!t&&!s,s)}return u}catch(e){}return null}},Wo=async(e,t=!1)=>{const n=`https://app.meetelise.com/eliseCrmApi/building/${e}/scheduling_status?observe_dynamic_scheduling=${t}`;try{return(await r().get(n)).data.is_enabled}catch(e){return!1}};var Vo,qo,Yo;!function(e){e.EMOJI="emoji",e.PILLS="pills",e.MINIMIZED="minimized"}(Vo||(Vo={})),function(e){e.UNKNOWN="UNKNOWN",e.SELF_GUIDED="SELF_GUIDED",e.VIRTUAL_SHOWING="VIRTUAL_SHOWING",e.WITH_AGENT="WITH_AGENT",e.MEDIA_TOUR="MEDIA_TOUR",e.OPEN_HOUSE_STUDIO="OPEN_HOUSE_STUDIO",e.OPEN_HOUSE_1BR="OPEN_HOUSE_1BR",e.OPEN_HOUSE_2BR="OPEN_HOUSE_2BR",e.OPEN_HOUSE_3BR="OPEN_HOUSE_3BR",e.OPEN_HOUSE_4BR="OPEN_HOUSE_4BR",e.OPEN_HOUSE_5BR="OPEN_HOUSE_5BR"}(qo||(qo={})),function(e){e.LINK="link",e.CLIENT_SCHEDULED="client_scheduled",e.SCHEDULED_BY_ME_MANAGED_BY_ME="scheduled_by_ME_managed_by_ME",e.SCHEDULED_BY_ME_MANAGED_BY_CLIENT="scheduled_by_ME_managed_by_client",e.SCHEDULED_BY_ME_MANAGED_BY_CONCIERGE="scheduled_by_ME_managed_by_concierge"}(Yo||(Yo={}));const Ko=(e,t)=>"link"===(null==t?void 0:t.toLowerCase());async function Xo(e,t){const n=`https://app.meetelise.com/api/pub/v1/organization/${e}/building/${t}/v2`,i=await r().get(n);return Zo(i.data)}const Zo=e=>{var t;try{e.welcomeMessage=Jo(null!==(t=e.welcomeMessage)&&void 0!==t?t:"",e.userFirstName)}catch(e){}return e},Jo=(e,t)=>e.replace(/elise/gi,t);var ea=n(7035),ta=n(6353);function na(e,t,n){var i=function(e,t,n){if(n&&!n.code)throw new Error("date-fns-tz error: Please set a language code on the locale object imported from date-fns, e.g. `locale.code = 'en-US'`");return new Intl.DateTimeFormat(n?[n.code,"en-US"]:void 0,{timeZone:t,timeZoneName:e})}(e,n.timeZone,n.locale);return i.formatToParts?function(e,t){for(var n=e.formatToParts(t),i=n.length-1;i>=0;--i)if("timeZoneName"===n[i].type)return n[i].value}(i,t):function(e,t){var n=e.format(t).replace(/\u200E/g,""),i=/ [\w-+ ]+$/.exec(n);return i?i[0].substr(1):""}(i,t)}function ia(e,t){var n=function(e){if(!oa[e]){var t=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),n="06/25/2014, 00:00:00"===t||"‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00"===t;oa[e]=n?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return oa[e]}(t);return n.formatToParts?function(e,t){try{for(var n=e.formatToParts(t),i=[],r=0;r<n.length;r++){var o=ra[n[r].type];o>=0&&(i[o]=parseInt(n[r].value,10))}return i}catch(e){if(e instanceof RangeError)return[NaN];throw e}}(n,e):function(e,t){var n=e.format(t),i=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(n);return[i[3],i[1],i[2],i[4],i[5],i[6]]}(n,e)}var ra={year:0,month:1,day:2,hour:3,minute:4,second:5};var oa={};function aa(e,t,n,i,r,o,a){var s=new Date(0);return s.setUTCFullYear(e,t,n),s.setUTCHours(i,r,o,a),s}var sa=36e5,la={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function ua(e,t,n){var i,r,o;if(!e)return 0;if(i=la.timezoneZ.exec(e))return 0;if(i=la.timezoneHH.exec(e))return ca(o=parseInt(i[1],10))?-o*sa:NaN;if(i=la.timezoneHHMM.exec(e)){o=parseInt(i[2],10);var a=parseInt(i[3],10);return ca(o,a)?(r=Math.abs(o)*sa+6e4*a,"+"===i[1]?-r:r):NaN}if(function(e){if(ha[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),ha[e]=!0,!0}catch(e){return!1}}(e)){t=new Date(t||Date.now());var s=n?t:function(e){return aa(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t),l=da(s,e),u=n?l:function(e,t,n){var i=e.getTime(),r=i-t,o=da(new Date(r),n);if(t===o)return t;r-=o-t;var a=da(new Date(r),n);if(o===a)return o;return Math.max(o,a)}(t,l,e);return-u}return NaN}function da(e,t){var n=ia(e,t),i=aa(n[0],n[1]-1,n[2],n[3]%24,n[4],n[5],0).getTime(),r=e.getTime(),o=r%1e3;return i-(r-=o>=0?o:1e3+o)}function ca(e,t){return-23<=e&&e<=23&&(null==t||0<=t&&t<=59)}var ha={};var pa={X:function(e,t,n,i){var r=fa(i.timeZone,e);if(0===r)return"Z";switch(t){case"X":return ya(r);case"XXXX":case"XX":return ma(r);default:return ma(r,":")}},x:function(e,t,n,i){var r=fa(i.timeZone,e);switch(t){case"x":return ya(r);case"xxxx":case"xx":return ma(r);default:return ma(r,":")}},O:function(e,t,n,i){var r=fa(i.timeZone,e);switch(t){case"O":case"OO":case"OOO":return"GMT"+function(e,t){var n=e>0?"-":"+",i=Math.abs(e),r=Math.floor(i/60),o=i%60;if(0===o)return n+String(r);var a=t||"";return n+String(r)+a+ga(o,2)}(r,":");default:return"GMT"+ma(r,":")}},z:function(e,t,n,i){switch(t){case"z":case"zz":case"zzz":return na("short",e,i);default:return na("long",e,i)}}};function fa(e,t){var n=e?ua(e,t,!0)/6e4:t.getTimezoneOffset();if(Number.isNaN(n))throw new RangeError("Invalid time zone specified: "+e);return n}function ga(e,t){for(var n=e<0?"-":"",i=Math.abs(e).toString();i.length<t;)i="0"+i;return n+i}function ma(e,t){var n=t||"",i=e>0?"-":"+",r=Math.abs(e);return i+ga(Math.floor(r/60),2)+n+ga(Math.floor(r%60),2)}function ya(e,t){return e%60==0?(e>0?"-":"+")+ga(Math.abs(e)/60,2):ma(e,t)}const ba=pa;var va=n(9784),wa=n(9720);var Ca=36e5,xa=6e4,$a={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/};function Sa(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(null===e)return new Date(NaN);var n=t||{},i=null==n.additionalDigits?2:va(n.additionalDigits);if(2!==i&&1!==i&&0!==i)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))return new Date(e.getTime());if("number"==typeof e||"[object Number]"===Object.prototype.toString.call(e))return new Date(e);if("string"!=typeof e&&"[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);var r=function(e){var t,n={},i=$a.dateTimePattern.exec(e);i?(n.date=i[1],t=i[3]):(i=$a.datePattern.exec(e))?(n.date=i[1],t=i[2]):(n.date=null,t=e);if(t){var r=$a.timeZone.exec(t);r?(n.time=t.replace(r[1],""),n.timeZone=r[1].trim()):n.time=t}return n}(e),o=function(e,t){var n,i=$a.YYY[t],r=$a.YYYYY[t];if(n=$a.YYYY.exec(e)||r.exec(e)){var o=n[1];return{year:parseInt(o,10),restDateString:e.slice(o.length)}}if(n=$a.YY.exec(e)||i.exec(e)){var a=n[1];return{year:100*parseInt(a,10),restDateString:e.slice(a.length)}}return{year:null}}(r.date,i),a=o.year,s=function(e,t){if(null===t)return null;var n,i,r,o;if(0===e.length)return(i=new Date(0)).setUTCFullYear(t),i;if(n=$a.MM.exec(e))return i=new Date(0),_a(t,r=parseInt(n[1],10)-1)?(i.setUTCFullYear(t,r),i):new Date(NaN);if(n=$a.DDD.exec(e)){i=new Date(0);var a=parseInt(n[1],10);return function(e,t){if(t<1)return!1;var n=ka(e);if(n&&t>366)return!1;if(!n&&t>365)return!1;return!0}(t,a)?(i.setUTCFullYear(t,0,a),i):new Date(NaN)}if(n=$a.MMDD.exec(e)){i=new Date(0),r=parseInt(n[1],10)-1;var s=parseInt(n[2],10);return _a(t,r,s)?(i.setUTCFullYear(t,r,s),i):new Date(NaN)}if(n=$a.Www.exec(e))return Oa(t,o=parseInt(n[1],10)-1)?Aa(t,o):new Date(NaN);if(n=$a.WwwD.exec(e)){o=parseInt(n[1],10)-1;var l=parseInt(n[2],10)-1;return Oa(t,o,l)?Aa(t,o,l):new Date(NaN)}return null}(o.restDateString,a);if(isNaN(s))return new Date(NaN);if(s){var l,u=s.getTime(),d=0;if(r.time&&(d=function(e){var t,n,i;if(t=$a.HH.exec(e))return Pa(n=parseFloat(t[1].replace(",",".")))?n%24*Ca:NaN;if(t=$a.HHMM.exec(e))return Pa(n=parseInt(t[1],10),i=parseFloat(t[2].replace(",",".")))?n%24*Ca+i*xa:NaN;if(t=$a.HHMMSS.exec(e)){n=parseInt(t[1],10),i=parseInt(t[2],10);var r=parseFloat(t[3].replace(",","."));return Pa(n,i,r)?n%24*Ca+i*xa+1e3*r:NaN}return null}(r.time),isNaN(d)))return new Date(NaN);if(r.timeZone||n.timeZone){if(l=ua(r.timeZone||n.timeZone,new Date(u+d)),isNaN(l))return new Date(NaN)}else l=wa(new Date(u+d)),l=wa(new Date(u+d+l));return new Date(u+d+l)}return new Date(NaN)}function Aa(e,t,n){t=t||0,n=n||0;var i=new Date(0);i.setUTCFullYear(e,0,4);var r=7*t+n+1-(i.getUTCDay()||7);return i.setUTCDate(i.getUTCDate()+r),i}var Ea=[31,28,31,30,31,30,31,31,30,31,30,31],Ta=[31,29,31,30,31,30,31,31,30,31,30,31];function ka(e){return e%400==0||e%4==0&&e%100!=0}function _a(e,t,n){if(t<0||t>11)return!1;if(null!=n){if(n<1)return!1;var i=ka(e);if(i&&n>Ta[t])return!1;if(!i&&n>Ea[t])return!1}return!0}function Oa(e,t,n){return!(t<0||t>52)&&(null==n||!(n<0||n>6))}function Pa(e,t,n){return(null==e||!(e<0||e>=25))&&((null==t||!(t<0||t>=60))&&(null==n||!(n<0||n>=60)))}var Ia=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function Na(e,t,n,i){var r=ea(i);return r.timeZone=t,r.originalDate=e,function(e,t,n){var i=String(t),r=n||{},o=i.match(Ia);if(o){var a=Sa(r.originalDate||e,r);i=o.reduce(function(e,t){if("'"===t[0])return e;var n=e.indexOf(t),i="'"===e[n-1],o=e.replace(t,"'"+ba[t[0]](a,t,null,r)+"'");return i?o.substring(0,n-1)+o.substring(n+1):o},i)}return ta(e,i,r)}(function(e,t,n){var i=Sa(e,n),r=ua(t,i,!0),o=new Date(i.getTime()-r),a=new Date(0);return a.setFullYear(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()),a.setHours(o.getUTCHours(),o.getUTCMinutes(),o.getUTCSeconds(),o.getUTCMilliseconds()),a}(e,t),n,r)}const Ma=async({buildingSlug:e})=>{try{const t=await r().get(`${$r}/platformApi/webchat/${e}/units/summary`);if(t.data)return Ar(t.data)}catch(t){jo({logType:Bo.error,buildingSlug:e,logTitle:"[ERROR_GETTING_UNITS_SUMMARY]",logData:{error:t}})}return[]};var Da=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 La=class extends oe{constructor(){super(...arguments),this.tourTypeOptions=[],this.layoutOptions=[],this.chatId="",this.buildingId=0,this.orgId=0,this.leadSourceParams=null,this.buildingSlug="",this.sgtUrl="",this.selfGuidedToursTypeOffered="",this.selfGuidedTourEnabled=!1,this.escortedToursLink="",this.escortedToursTypeOffered="",this.virtualToursLink="",this.virtualToursTypeOffered="",this.orgSlug="",this.hasDynamicSchedulingEnabled=!1,this.leadSourceClient=null,this.leadSourceMultitouchClient=null,this.buildingName="",this.tourType=null,this.shouldShowTourType={[Ua.Guided]:!0,[Ua.Self]:!0,[Ua.Virtual]:!0},this.email="",this.phoneNumber="",this.phoneNumberE164=null,this.phoneCountry=null,this.phoneNumberIsValid=!1,this.phoneNumberHasBlurred=!1,this.availabilitiesGroupedByDay={},this.calendarTimeZone=Intl.DateTimeFormat().resolvedOptions().timeZone,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.country=null,this.currentLeadSource="",this.featureFlagShowDropdown="",this.compactDesign=!1,this.primaryColor=qn,this.backgroundColor=Yn,this.foregroundColorOnPrimaryBackgroundColor="white",this.foregroundColorOnSecondaryBackgroundColor="black",this.firstNameInputValue="",this.lastNameInputValue="",this.leadSourceInputValue="",this.selectedLayoutValue="",this.selectedUnitValue="",this.units=[],this.allowOccupiedUnitTours=!1,this.errorGettingAvailabilities=!1,this.centralConvoBuildings=[],this.isGeneralBuilding=!1,this.statusMessage="",this._setAvailabilities=async()=>{try{const[e,t]=await Promise.all([Wo(this.buildingId,this.hasDynamicSchedulingEnabled),oo()]);this.shouldAllowScheduling=e,this.shouldAllowScheduleLoading=!1,this.calendarTimeZone=await(async e=>{var t;return null!==(t=(await io(e)).calendarTimeZone)&&void 0!==t?t:Intl.DateTimeFormat().resolvedOptions().timeZone})(this.buildingId),jo({logTitle:"AVAILABILITIES_EXIST_FOR_TOUR_TYPE",logData:t,logType:Bo.info,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});const n=Object.values(t).every(e=>!1===e),i=!this.sgtUrl&&!this.escortedToursLink&&!this.virtualToursLink;if(n&&i)return this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,void jo({logTitle:"NO_AVAILABILITIES_EXIST",logData:null,logType:Bo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});this.shouldShowTourType={[Ua.Guided]:this.tourTypeOptions.map(e=>e.value).includes("WITH_AGENT")&&(t[Ua.Guided]||!!this.escortedToursLink),[Ua.Self]:this.tourTypeOptions.map(e=>e.value).includes("SELF_GUIDED")&&(t[Ua.Self]||!!this.sgtUrl),[Ua.Virtual]:this.tourTypeOptions.map(e=>e.value).includes("VIRTUAL_SHOWING")&&(t[Ua.Virtual]||!!this.virtualToursLink)};const r=1===Object.values(this.shouldShowTourType).reduce((e,t)=>!0===t?e+1:e,0);if(this._setDefaultSelectedDateAndTimes(),r&&(this.tourType=Object.keys(this.shouldShowTourType).find(e=>this.shouldShowTourType[e])),null===this.tourType)return void(this.waitingForAvailabilities=!1);this.availabilitiesGroupedByDay=await ao(Ra[this.tourType]),this.waitingForAvailabilities=!1}catch(e){this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,jo({logTitle:"ERROR_LOADING_AVAILABILITIES",logData:{error:e},logType:Bo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this._setDefaultSelectedDateAndTimes=async(e,t)=>{var n,i,r;const o=await io(this.buildingId),a=null!=e?e:this._getHighestRankedTourType(o),s=a?null===(r=null===(i=null===(n=o.availability)||void 0===n?void 0:n[a])||void 0===i?void 0:i.availableTourStartTimes)||void 0===r?void 0:r.filter(e=>{if(!t)return!0;return rr("string"==typeof e?Wr(e):e,t)}):[],l=null==s?void 0:s[0];a&&l&&a!==jr.Unknown&&a!==jr.MediaTour&&(this.selectedDate=ir("string"==typeof l?Wr(l):l),this.tourType=Ba[a],this.selectedTime="string"==typeof l?so(l):(e=>({datetime:Zi(e,"yyyy-MM-dd'T'HH:mm:ss"),offset:Zi(e,"xxx")}))(l))},this._getHighestRankedTourType=e=>{var t;const n=(null!==(t=e.rankOrderedSupportedTourTypes)&&void 0!==t?t:[]).map(t=>{var n,i;return{tourType:t,availabilities:null===(i=null===(n=e.availability)||void 0===n?void 0:n[t])||void 0===i?void 0:i.availableTourStartTimes}}).filter(e=>{if(e.tourType===jr.Unknown||e.tourType===jr.MediaTour)return!1;const t=Ba[e.tourType],n=this._getTourTypeOffered(t);return!!n&&(!Ko(0,n)&&e.availabilities&&e.availabilities.length>0)}),i=n[0];return i?i.tourType:null},this._getTourTypeOffered=e=>e===Ua.Guided?this.escortedToursTypeOffered:e===Ua.Self?this.selfGuidedToursTypeOffered:e===Ua.Virtual?this.virtualToursTypeOffered:null,this._getUnitOptions=()=>{const e=this.selectedLayoutValue?this.units.filter(e=>Fa(10*e.numberOfBedrooms)===this.selectedLayoutValue):this.units,t=e.map(e=>({label:e.unitNumber,value:e.unitNumber}));return t},this._fetchUnits=async()=>{if(this.buildingSlug)try{this.units=await Ma({buildingSlug:this.buildingSlug})}catch(e){this.units=[],jo({logTitle:"ERROR_LOADING_UNITS_FOR_TOUR_SCHEDULER",logData:{error:e},logType:Bo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.firstUpdated=async()=>{if(await this._fetchCentralConvoBuildings(),this.isGeneralBuilding)return this.waitingForAvailabilities=!1,this.shouldAllowScheduleLoading=!1,void(this.statusMessage="Please select a building to see tour availabilities.");await this._loadForCurrentBuilding()},this._loadForCurrentBuilding=async()=>{try{await io(this.buildingId)}catch(e){}await Promise.all([this._setAvailabilities().then(async()=>{try{const e=await io(this.buildingId);this.allowOccupiedUnitTours=!!e.allowOccupiedUnitTours}catch(e){this.allowOccupiedUnitTours=!1}}),this._fetchUnits()])},this._fetchCentralConvoBuildings=async()=>{if(this.orgSlug&&this.buildingSlug)try{const e=await async function(e,t){var n,i;const o=(await r().get("https://app.meetelise.com/platformApi/webchat/central-convo-buildings-v2",{headers:{"building-slug":t,"org-slug":e}})).data;return{is_general_building:null!==(n=null==o?void 0:o.is_general_building)&&void 0!==n&&n,buildings:null!==(i=null==o?void 0:o.buildings)&&void 0!==i?i:[]}}(this.orgSlug,this.buildingSlug);this.centralConvoBuildings=e.buildings,this.isGeneralBuilding=e.is_general_building}catch(e){this.centralConvoBuildings=[],this.isGeneralBuilding=!1}},this._onBuildingChange=async()=>{var e;const t=null===(e=this.selectedBuildingEl)||void 0===e?void 0:e.value;if(!t||t===this.buildingSlug)return;const n=this.centralConvoBuildings.find(e=>e.slug===t);if(n){this.isGeneralBuilding=!1,this.waitingForAvailabilities=!0,this.errorGettingAvailabilities=!1,this.tourType=null,this.selectedDate=void 0,this.selectedTime=void 0,this.availabilitiesGroupedByDay={},this.mobilePageIndex=0,this.units=[],this.selectedLayoutValue="",this.selectedUnitValue="",this.buildingId=n.building_id,this.buildingSlug=n.slug,this.buildingName=n.name,this.statusMessage=`Loading tours for ${n.name}…`,Co("tourBuildingSelected",{buildingId:n.building_id});try{const e=await Xo(this.orgSlug,n.slug);this.sgtUrl=e.sgtUrl,this.selfGuidedToursTypeOffered=e.selfGuidedToursTypeOffered,this.selfGuidedTourEnabled=e.isSelfGuidedTourEnabled,this.escortedToursLink=e.escortedToursLink,this.escortedToursTypeOffered=e.escortedToursTypeOffered,this.virtualToursLink=e.virtualToursLink,this.virtualToursTypeOffered=e.virtualToursTypeOffered,this.tourTypeOptions=e.tourTypeOptions.map(e=>({label:e.label,value:e.value})),this.hasDynamicSchedulingEnabled=e.usesDynamicScheduling}catch(e){}if(await this._loadForCurrentBuilding(),!this.shouldAllowScheduling||this.errorGettingAvailabilities)this.statusMessage=`No tour availabilities for ${n.name}.`;else{const e=Object.values(this.shouldShowTourType).filter(Boolean).length;this.statusMessage=`Showing tours for ${n.name}. ${e} tour type${1===e?"":"s"} available.`}}},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await ao(Ra[this.tourType]))},this.onChangePhoneNumber=e=>{this.phoneNumber=e.detail.formattedValue,this.phoneNumberE164=e.detail.e164,this.phoneCountry=e.detail.country,this.phoneNumberIsValid=e.detail.isValid},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,n,i;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&Nr(null!==(i=null===(n=this.emailInput)||void 0===n?void 0:n.value)&&void 0!==i?i:"")&&!!this.phoneNumber&&!!this.phoneNumberE164}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,n]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(n)]},this.submit=async()=>{var e,t,n,i,o,a,s,l,u,d,c,h,p,f,g,m,y,b,v,w,C,x,$;if(!this.selectedDate||!this.selectedTime||null===this.tourType)return;const S=this.phoneNumberE164;if(!S)return void(this.phoneNumberIsValid=!1);const A=new URLSearchParams(window.location.search);let E=null;E=this.selectedLeadSource&&this.selectedLeadSource.value&&this.selectedLeadSource.value.length>0?this.selectedLeadSource.value:this.leadSourceInputValue&&this.leadSourceInputValue.length>0?this.leadSourceInputValue:this.currentLeadSource;const T=[...new Set(E?[E,"property-website"]:["property-website"])];this.firstNameInput&&(this.firstNameInputValue=this.firstNameInput.value),this.lastNameInput&&(this.lastNameInputValue=this.lastNameInput.value),this.leadSourceInputValue=E;const k=(null===(e=this.selectedLayoutEl)||void 0===e?void 0:e.value)||this.selectedLayoutValue||null,_=(null===(t=this.selectedUnitEl)||void 0===t?void 0:t.value)||this.selectedUnitValue||null;Co("scheduleTourSubmitted",{email:this.email,phone:S,firstName:null!==(i=null===(n=this.firstNameInput)||void 0===n?void 0:n.value)&&void 0!==i?i:this.firstNameInputValue,lastName:null!==(a=null===(o=this.lastNameInput)||void 0===o?void 0:o.value)&&void 0!==a?a:this.lastNameInputValue,tourType:ja[this.tourType],tourTime:`${this.selectedTime.datetime}${this.selectedTime.offset}`,originatingSource:T.find(e=>"property-website"!==e)||null,layout:k,unit:_,conversationTrackingId:null!==(l=null===(s=this.leadSourceClient)||void 0===s?void 0:s.chatId)&&void 0!==l?l:null});const O={referrer:document.referrer,email_address:this.email,phone_number:S,building_id:this.buildingId,first_name:null!==(d=null===(u=this.firstNameInput)||void 0===u?void 0:u.value)&&void 0!==d?d:this.firstNameInputValue,last_name:null!==(h=null===(c=this.lastNameInput)||void 0===c?void 0:c.value)&&void 0!==h?h:this.lastNameInputValue,tour_type:ja[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,cancel_existing_tours:this.promptForReschedule,lead_sources:[...new Set(E?[E,zo(this.orgSlug)]:[zo(this.orgSlug)])],query_params:Object.fromEntries(A.entries()),conversation_tracking_id:null===(p=this.leadSourceClient)||void 0===p?void 0:p.chatId,layouts:k?[k]:void 0,unit_numbers:_?[_]:void 0,lead_sources_with_timestamps:(null!==(m=null===(f=this.leadSourceMultitouchClient)||void 0===f?void 0:f.getSafeLeadSourceTouchpointsWithDefault({includedUserSelectedLeadSource:(null===(g=this.selectedLeadSource)||void 0===g?void 0:g.value)&&this.selectedLeadSource.value.length>0?this.selectedLeadSource.value:null}))&&void 0!==m?m:[]).map(e=>Er({...e}))};this.isSubmitting=!0;try{await r().post("https://app.meetelise.com/platformApi/state/create/v2/scheduleMe",O,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"webchatkey-wkjcWAKZjqhLStvP8L6SN8y4FbYmPhdE","org-slug":this.orgSlug}}),null===(y=this.leadSourceClient)||void 0===y||y.checkAndHandleForLogLeadSource({webchatAction:"tour-scheduler",stateId:null}),null===(b=this.leadSourceClient)||void 0===b||b.resetLeadSource(),null===(v=this.leadSourceMultitouchClient)||void 0===v||v.resetLeadSourceTouchpoints(),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e,n=(null===(C=null===(w=t.response)||void 0===w?void 0:w.data)||void 0===C?void 0:C.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[Zi(this.selectedDate,"yyyy-MM-dd")];e&&(this.availabilitiesGroupedByDay[Zi(this.selectedDate,"yyyy-MM-dd")]=e.filter(e=>e!==this.selectedTime))}}else{if(409===(null===(x=t.response)||void 0===x?void 0:x.status)&&!this.promptForReschedule&&"User already has a tour scheduled for this building"===n)return this.promptForReschedule=!0,this.isSubmitting=!1,void(this.tourIsBooked=!1);if(409===(null===($=t.response)||void 0===$?void 0:$.status)&&!this.promptForReschedule)return this.isSubmitting=!1,this.tourIsBooked=!1,no(),this.availabilitiesGroupedByDay=await ao(Ra[this.tourType],this.buildingId),void alert("This timeslot is no longer available. Please select a different time.")}alert(n),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>R`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>R`${this.dateAndTimeMenu()}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>R` <action-confirm-button
1481
+ `;class Uo{constructor(e,t,n,i){this.org=e,this.building=t,this.chatId=n,this.incomingProcessedLeadSource=i,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:Ro(),incomingProcessedLeadSource:this.incomingProcessedLeadSource,webchatVersion:null!==(t="MISSING_ENV_VAR".npm_package_version)&&void 0!==t?t:"1.20.155"})})}}const Ro=()=>{var e,t,n,i,r,o;try{const i=new URL(window.location.href).searchParams,r=null!==(n=null===(t=null===(e=window.RCTPCampaign)||void 0===e?void 0:e.CampaignDetails)||void 0===t?void 0:t.Source)&&void 0!==n?n:null,o=i.get("switch_cls[id]"),a=i.get("ilm"),s=i.get("utm_source");return{entrataCampaignSource:o,realpageCampaignSource:a,utmCampaignSource:s,yardiCampaignSource:r,bozzutoAdSource:Ir("bozzuto_ad_source")}}catch(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 n=t.contentWindow.URL;if(!n)return{entrataCampaignSource:null,realpageCampaignSource:null,utmCampaignSource:null,yardiCampaignSource:null,bozzutoAdSource:null};const a=new n(window.location.href).searchParams,s=null!==(o=null===(r=null===(i=window.RCTPCampaign)||void 0===i?void 0:i.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:Ir("bozzuto_ad_source")}}};var Bo;!function(e){e.error="error",e.info="info",e.warn="warn"}(Bo||(Bo={}));const jo=async({logType:e,buildingSlug:t,orgSlug:n,logTitle:i,logData:o})=>{await r().post("https://app.meetelise.com/platformApi/webchat/logging",{...o},{headers:{"Content-Type":"application/json","building-slug":null!=t?t:"","org-slug":null!=n?n:"","log-type":null!=e?e:Bo.error,"log-title":i.toUpperCase().replace(/\s/g,"_")}})},Fo=async({params:e,sampleRate:t})=>{try{if(Math.random()>=t)return;await r().post("https://app.meetelise.com/platformApi/webchat/log/signal",{...e,website_origin:window.location.origin,website_search:window.location.search})}catch(e){}};var Ho=n(2193),Go=n.n(Ho);function zo(e){return"avb"===e?"AVB Company Website":"windsor"===e?"Windsorcommunities.com":"property-website"}const Qo=class{constructor(){this.chatId=null,this.apiHost="https://app.meetelise.com",this.leadSource=null,this.leadSourceParams=null,this.localStorageTTLDays=30,this.buildingId=null,this.orgId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,n,i,r)=>{const o=mo();if(this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:o,referrer:document.referrer,parsedUtmSource:o?o.utm_source:null,campaignSources:Object.values(Ro()).filter(e=>e)},i)return;if(!r){const t=this.getLeadSourceBodyIfValid(e);if(t){if(!Pr(t.timestamp,24*this.localStorageTTLDays))return{...t,timestamp:Wr(t.timestamp)}}}const a={leadSource:t,leadSourceParams:this.leadSourceParams,leadId:n,buildingSlug:e,timestamp:Rr(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(a)),{...a,timestamp:Wr(a.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const n=JSON.parse(t);if(n.buildingSlug===e&&n.leadSource&&n.leadId&&n.timestamp&&!Pr(Wr(n.timestamp),24*this.localStorageTTLDays)){try{this.leadSourceInput=n.leadSourceInput}catch(e){}return n}}catch(e){return null}return null},this.resetLeadSource=()=>{if(!this.buildingSlug)return!1;const e="com.elise.webchat.leadsource.slug="+this.buildingSlug;return localStorage.removeItem(e),!0}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:t,referrer:n,campaignSources:i}){const o={query_params:t,building_slug:e,referrer:n,campaign_sources:i};try{return(await r().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,o)).data}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:t}){var n,i,o,a,s,l,u;try{if(!this.chatId)return null;if(!this.orgSlug)return null;let d=null,c=null;try{if("f1ba5a20-d207-4e5a-879e-65199e7d0a53"===this.orgSlug){const e=await this.getCookieValue("_ga");e&&(d=e),c=null===(n=window.dataLayer.find(e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)}))||void 0===n?void 0:n.value}}catch(e){}return await r().post(`${this.apiHost}/platformApi/webchat/log/lead-source`,{chat_id:this.chatId,webchat_action:e,state_id:t,building_id:this.buildingId,org_slug:this.orgSlug,building_slug:this.buildingSlug,website_origin:null===(i=this.leadSourceInput)||void 0===i?void 0:i.websiteOrigin,website_search:null===(o=this.leadSourceInput)||void 0===o?void 0:o.websiteSearch,query_parameters:null===(a=this.leadSourceInput)||void 0===a?void 0:a.queryParameters,referrer:null===(s=this.leadSourceInput)||void 0===s?void 0:s.referrer,parsed_utm_source:null===(l=this.leadSourceInput)||void 0===l?void 0:l.parsedUtmSource,campaign_sources:null===(u=this.leadSourceInput)||void 0===u?void 0:u.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:Go()(d)?null:d,extras:null!=c?c:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const i=t[n].trim();if(i.startsWith(e+"=")){return i.substring((e+"=").length,-1===i.indexOf(";")?void 0:i.indexOf(";"))}}return null}catch(e){}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:n}){var i,r,o;try{const a={queryParams:mo(),buildingSlug:n,referrer:document.referrer,campaignSources:Ro()};let s=!1;const l=n?this.getLeadSourceBodyIfValid(n):null;if(l){if(!["test-company","daf00bd2-1ecb-482c-b6f4-e1c5511a01be"].includes(t))return this.leadSource=l.leadSource,this.leadSourceParams=null!==(r=l.leadSourceParams)&&void 0!==r?r:null,this.leadSource;{const e=await this.fetchCurrentParsedLeadSource(a);if(!e)return this.leadSource=l.leadSource,this.leadSourceParams=null!==(i=l.leadSourceParams)&&void 0!==i?i:null,this.leadSource;this.leadSource=e,s=!0}}const u=await this.fetchCurrentParsedLeadSource(a);if(this.leadSource=u,this.buildingId=null,this.orgSlug=t,this.buildingSlug=n,n&&!u){const e=this.getLeadSourceBodyIfValid(n);if(e)return this.leadSource=e.leadSource,this.leadSourceParams=null!==(o=e.leadSourceParams)&&void 0!==o?o:null,this.leadSource}if(n){const t=!!u&&u.length>0;this.updateLeadSourceLocalStorage(n,u,e,!t&&!s,s)}return u}catch(e){}return null}},Wo=async(e,t=!1)=>{const n=`https://app.meetelise.com/eliseCrmApi/building/${e}/scheduling_status?observe_dynamic_scheduling=${t}`;try{return(await r().get(n)).data.is_enabled}catch(e){return!1}};var Vo,qo,Yo;!function(e){e.EMOJI="emoji",e.PILLS="pills",e.MINIMIZED="minimized"}(Vo||(Vo={})),function(e){e.UNKNOWN="UNKNOWN",e.SELF_GUIDED="SELF_GUIDED",e.VIRTUAL_SHOWING="VIRTUAL_SHOWING",e.WITH_AGENT="WITH_AGENT",e.MEDIA_TOUR="MEDIA_TOUR",e.OPEN_HOUSE_STUDIO="OPEN_HOUSE_STUDIO",e.OPEN_HOUSE_1BR="OPEN_HOUSE_1BR",e.OPEN_HOUSE_2BR="OPEN_HOUSE_2BR",e.OPEN_HOUSE_3BR="OPEN_HOUSE_3BR",e.OPEN_HOUSE_4BR="OPEN_HOUSE_4BR",e.OPEN_HOUSE_5BR="OPEN_HOUSE_5BR"}(qo||(qo={})),function(e){e.LINK="link",e.CLIENT_SCHEDULED="client_scheduled",e.SCHEDULED_BY_ME_MANAGED_BY_ME="scheduled_by_ME_managed_by_ME",e.SCHEDULED_BY_ME_MANAGED_BY_CLIENT="scheduled_by_ME_managed_by_client",e.SCHEDULED_BY_ME_MANAGED_BY_CONCIERGE="scheduled_by_ME_managed_by_concierge"}(Yo||(Yo={}));const Ko=(e,t)=>"link"===(null==t?void 0:t.toLowerCase());async function Xo(e,t){const n=`https://app.meetelise.com/api/pub/v1/organization/${e}/building/${t}/v2`,i=await r().get(n);return Zo(i.data)}const Zo=e=>{var t;try{e.welcomeMessage=Jo(null!==(t=e.welcomeMessage)&&void 0!==t?t:"",e.userFirstName)}catch(e){}return e},Jo=(e,t)=>e.replace(/elise/gi,t);var ea=n(7035),ta=n(6353);function na(e,t,n){var i=function(e,t,n){if(n&&!n.code)throw new Error("date-fns-tz error: Please set a language code on the locale object imported from date-fns, e.g. `locale.code = 'en-US'`");return new Intl.DateTimeFormat(n?[n.code,"en-US"]:void 0,{timeZone:t,timeZoneName:e})}(e,n.timeZone,n.locale);return i.formatToParts?function(e,t){for(var n=e.formatToParts(t),i=n.length-1;i>=0;--i)if("timeZoneName"===n[i].type)return n[i].value}(i,t):function(e,t){var n=e.format(t).replace(/\u200E/g,""),i=/ [\w-+ ]+$/.exec(n);return i?i[0].substr(1):""}(i,t)}function ia(e,t){var n=function(e){if(!oa[e]){var t=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),n="06/25/2014, 00:00:00"===t||"‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00"===t;oa[e]=n?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return oa[e]}(t);return n.formatToParts?function(e,t){try{for(var n=e.formatToParts(t),i=[],r=0;r<n.length;r++){var o=ra[n[r].type];o>=0&&(i[o]=parseInt(n[r].value,10))}return i}catch(e){if(e instanceof RangeError)return[NaN];throw e}}(n,e):function(e,t){var n=e.format(t),i=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(n);return[i[3],i[1],i[2],i[4],i[5],i[6]]}(n,e)}var ra={year:0,month:1,day:2,hour:3,minute:4,second:5};var oa={};function aa(e,t,n,i,r,o,a){var s=new Date(0);return s.setUTCFullYear(e,t,n),s.setUTCHours(i,r,o,a),s}var sa=36e5,la={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function ua(e,t,n){var i,r,o;if(!e)return 0;if(i=la.timezoneZ.exec(e))return 0;if(i=la.timezoneHH.exec(e))return ca(o=parseInt(i[1],10))?-o*sa:NaN;if(i=la.timezoneHHMM.exec(e)){o=parseInt(i[2],10);var a=parseInt(i[3],10);return ca(o,a)?(r=Math.abs(o)*sa+6e4*a,"+"===i[1]?-r:r):NaN}if(function(e){if(ha[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),ha[e]=!0,!0}catch(e){return!1}}(e)){t=new Date(t||Date.now());var s=n?t:function(e){return aa(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t),l=da(s,e),u=n?l:function(e,t,n){var i=e.getTime(),r=i-t,o=da(new Date(r),n);if(t===o)return t;r-=o-t;var a=da(new Date(r),n);if(o===a)return o;return Math.max(o,a)}(t,l,e);return-u}return NaN}function da(e,t){var n=ia(e,t),i=aa(n[0],n[1]-1,n[2],n[3]%24,n[4],n[5],0).getTime(),r=e.getTime(),o=r%1e3;return i-(r-=o>=0?o:1e3+o)}function ca(e,t){return-23<=e&&e<=23&&(null==t||0<=t&&t<=59)}var ha={};var pa={X:function(e,t,n,i){var r=fa(i.timeZone,e);if(0===r)return"Z";switch(t){case"X":return ya(r);case"XXXX":case"XX":return ma(r);default:return ma(r,":")}},x:function(e,t,n,i){var r=fa(i.timeZone,e);switch(t){case"x":return ya(r);case"xxxx":case"xx":return ma(r);default:return ma(r,":")}},O:function(e,t,n,i){var r=fa(i.timeZone,e);switch(t){case"O":case"OO":case"OOO":return"GMT"+function(e,t){var n=e>0?"-":"+",i=Math.abs(e),r=Math.floor(i/60),o=i%60;if(0===o)return n+String(r);var a=t||"";return n+String(r)+a+ga(o,2)}(r,":");default:return"GMT"+ma(r,":")}},z:function(e,t,n,i){switch(t){case"z":case"zz":case"zzz":return na("short",e,i);default:return na("long",e,i)}}};function fa(e,t){var n=e?ua(e,t,!0)/6e4:t.getTimezoneOffset();if(Number.isNaN(n))throw new RangeError("Invalid time zone specified: "+e);return n}function ga(e,t){for(var n=e<0?"-":"",i=Math.abs(e).toString();i.length<t;)i="0"+i;return n+i}function ma(e,t){var n=t||"",i=e>0?"-":"+",r=Math.abs(e);return i+ga(Math.floor(r/60),2)+n+ga(Math.floor(r%60),2)}function ya(e,t){return e%60==0?(e>0?"-":"+")+ga(Math.abs(e)/60,2):ma(e,t)}const ba=pa;var va=n(9784),wa=n(9720);var Ca=36e5,xa=6e4,$a={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/};function Sa(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(null===e)return new Date(NaN);var n=t||{},i=null==n.additionalDigits?2:va(n.additionalDigits);if(2!==i&&1!==i&&0!==i)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))return new Date(e.getTime());if("number"==typeof e||"[object Number]"===Object.prototype.toString.call(e))return new Date(e);if("string"!=typeof e&&"[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);var r=function(e){var t,n={},i=$a.dateTimePattern.exec(e);i?(n.date=i[1],t=i[3]):(i=$a.datePattern.exec(e))?(n.date=i[1],t=i[2]):(n.date=null,t=e);if(t){var r=$a.timeZone.exec(t);r?(n.time=t.replace(r[1],""),n.timeZone=r[1].trim()):n.time=t}return n}(e),o=function(e,t){var n,i=$a.YYY[t],r=$a.YYYYY[t];if(n=$a.YYYY.exec(e)||r.exec(e)){var o=n[1];return{year:parseInt(o,10),restDateString:e.slice(o.length)}}if(n=$a.YY.exec(e)||i.exec(e)){var a=n[1];return{year:100*parseInt(a,10),restDateString:e.slice(a.length)}}return{year:null}}(r.date,i),a=o.year,s=function(e,t){if(null===t)return null;var n,i,r,o;if(0===e.length)return(i=new Date(0)).setUTCFullYear(t),i;if(n=$a.MM.exec(e))return i=new Date(0),_a(t,r=parseInt(n[1],10)-1)?(i.setUTCFullYear(t,r),i):new Date(NaN);if(n=$a.DDD.exec(e)){i=new Date(0);var a=parseInt(n[1],10);return function(e,t){if(t<1)return!1;var n=ka(e);if(n&&t>366)return!1;if(!n&&t>365)return!1;return!0}(t,a)?(i.setUTCFullYear(t,0,a),i):new Date(NaN)}if(n=$a.MMDD.exec(e)){i=new Date(0),r=parseInt(n[1],10)-1;var s=parseInt(n[2],10);return _a(t,r,s)?(i.setUTCFullYear(t,r,s),i):new Date(NaN)}if(n=$a.Www.exec(e))return Oa(t,o=parseInt(n[1],10)-1)?Aa(t,o):new Date(NaN);if(n=$a.WwwD.exec(e)){o=parseInt(n[1],10)-1;var l=parseInt(n[2],10)-1;return Oa(t,o,l)?Aa(t,o,l):new Date(NaN)}return null}(o.restDateString,a);if(isNaN(s))return new Date(NaN);if(s){var l,u=s.getTime(),d=0;if(r.time&&(d=function(e){var t,n,i;if(t=$a.HH.exec(e))return Pa(n=parseFloat(t[1].replace(",",".")))?n%24*Ca:NaN;if(t=$a.HHMM.exec(e))return Pa(n=parseInt(t[1],10),i=parseFloat(t[2].replace(",",".")))?n%24*Ca+i*xa:NaN;if(t=$a.HHMMSS.exec(e)){n=parseInt(t[1],10),i=parseInt(t[2],10);var r=parseFloat(t[3].replace(",","."));return Pa(n,i,r)?n%24*Ca+i*xa+1e3*r:NaN}return null}(r.time),isNaN(d)))return new Date(NaN);if(r.timeZone||n.timeZone){if(l=ua(r.timeZone||n.timeZone,new Date(u+d)),isNaN(l))return new Date(NaN)}else l=wa(new Date(u+d)),l=wa(new Date(u+d+l));return new Date(u+d+l)}return new Date(NaN)}function Aa(e,t,n){t=t||0,n=n||0;var i=new Date(0);i.setUTCFullYear(e,0,4);var r=7*t+n+1-(i.getUTCDay()||7);return i.setUTCDate(i.getUTCDate()+r),i}var Ea=[31,28,31,30,31,30,31,31,30,31,30,31],Ta=[31,29,31,30,31,30,31,31,30,31,30,31];function ka(e){return e%400==0||e%4==0&&e%100!=0}function _a(e,t,n){if(t<0||t>11)return!1;if(null!=n){if(n<1)return!1;var i=ka(e);if(i&&n>Ta[t])return!1;if(!i&&n>Ea[t])return!1}return!0}function Oa(e,t,n){return!(t<0||t>52)&&(null==n||!(n<0||n>6))}function Pa(e,t,n){return(null==e||!(e<0||e>=25))&&((null==t||!(t<0||t>=60))&&(null==n||!(n<0||n>=60)))}var Ia=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function Na(e,t,n,i){var r=ea(i);return r.timeZone=t,r.originalDate=e,function(e,t,n){var i=String(t),r=n||{},o=i.match(Ia);if(o){var a=Sa(r.originalDate||e,r);i=o.reduce(function(e,t){if("'"===t[0])return e;var n=e.indexOf(t),i="'"===e[n-1],o=e.replace(t,"'"+ba[t[0]](a,t,null,r)+"'");return i?o.substring(0,n-1)+o.substring(n+1):o},i)}return ta(e,i,r)}(function(e,t,n){var i=Sa(e,n),r=ua(t,i,!0),o=new Date(i.getTime()-r),a=new Date(0);return a.setFullYear(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()),a.setHours(o.getUTCHours(),o.getUTCMinutes(),o.getUTCSeconds(),o.getUTCMilliseconds()),a}(e,t),n,r)}const Ma=async({buildingSlug:e})=>{try{const t=await r().get(`${$r}/platformApi/webchat/${e}/units/summary`);if(t.data)return Ar(t.data)}catch(t){jo({logType:Bo.error,buildingSlug:e,logTitle:"[ERROR_GETTING_UNITS_SUMMARY]",logData:{error:t}})}return[]};var Da=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 La=class extends oe{constructor(){super(...arguments),this.tourTypeOptions=[],this.layoutOptions=[],this.chatId="",this.buildingId=0,this.orgId=0,this.leadSourceParams=null,this.buildingSlug="",this.sgtUrl="",this.selfGuidedToursTypeOffered="",this.selfGuidedTourEnabled=!1,this.escortedToursLink="",this.escortedToursTypeOffered="",this.virtualToursLink="",this.virtualToursTypeOffered="",this.orgSlug="",this.hasDynamicSchedulingEnabled=!1,this.leadSourceClient=null,this.leadSourceMultitouchClient=null,this.buildingName="",this.tourType=null,this.shouldShowTourType={[Ua.Guided]:!0,[Ua.Self]:!0,[Ua.Virtual]:!0},this.email="",this.phoneNumber="",this.phoneNumberE164=null,this.phoneCountry=null,this.phoneNumberIsValid=!1,this.phoneNumberHasBlurred=!1,this.availabilitiesGroupedByDay={},this.calendarTimeZone=Intl.DateTimeFormat().resolvedOptions().timeZone,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.country=null,this.currentLeadSource="",this.featureFlagShowDropdown="",this.compactDesign=!1,this.primaryColor=qn,this.backgroundColor=Yn,this.foregroundColorOnPrimaryBackgroundColor="white",this.foregroundColorOnSecondaryBackgroundColor="black",this.firstNameInputValue="",this.lastNameInputValue="",this.leadSourceInputValue="",this.selectedLayoutValue="",this.selectedUnitValue="",this.units=[],this.allowOccupiedUnitTours=!1,this.errorGettingAvailabilities=!1,this.centralConvoBuildings=[],this.isGeneralBuilding=!1,this.statusMessage="",this._setAvailabilities=async()=>{try{const[e,t]=await Promise.all([Wo(this.buildingId,this.hasDynamicSchedulingEnabled),oo()]);this.shouldAllowScheduling=e,this.shouldAllowScheduleLoading=!1,this.calendarTimeZone=await(async e=>{var t;return null!==(t=(await io(e)).calendarTimeZone)&&void 0!==t?t:Intl.DateTimeFormat().resolvedOptions().timeZone})(this.buildingId),jo({logTitle:"AVAILABILITIES_EXIST_FOR_TOUR_TYPE",logData:t,logType:Bo.info,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});const n=Object.values(t).every(e=>!1===e),i=!this.sgtUrl&&!this.escortedToursLink&&!this.virtualToursLink;if(n&&i)return this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,void jo({logTitle:"NO_AVAILABILITIES_EXIST",logData:null,logType:Bo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});this.shouldShowTourType={[Ua.Guided]:this.tourTypeOptions.map(e=>e.value).includes("WITH_AGENT")&&(t[Ua.Guided]||!!this.escortedToursLink),[Ua.Self]:this.tourTypeOptions.map(e=>e.value).includes("SELF_GUIDED")&&(t[Ua.Self]||!!this.sgtUrl),[Ua.Virtual]:this.tourTypeOptions.map(e=>e.value).includes("VIRTUAL_SHOWING")&&(t[Ua.Virtual]||!!this.virtualToursLink)};const r=1===Object.values(this.shouldShowTourType).reduce((e,t)=>!0===t?e+1:e,0);if(this._setDefaultSelectedDateAndTimes(),r&&(this.tourType=Object.keys(this.shouldShowTourType).find(e=>this.shouldShowTourType[e])),null===this.tourType)return void(this.waitingForAvailabilities=!1);this.availabilitiesGroupedByDay=await ao(Ra[this.tourType]),this.waitingForAvailabilities=!1}catch(e){this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,jo({logTitle:"ERROR_LOADING_AVAILABILITIES",logData:{error:e},logType:Bo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this._setDefaultSelectedDateAndTimes=async(e,t)=>{var n,i,r;const o=await io(this.buildingId),a=null!=e?e:this._getHighestRankedTourType(o),s=a?null===(r=null===(i=null===(n=o.availability)||void 0===n?void 0:n[a])||void 0===i?void 0:i.availableTourStartTimes)||void 0===r?void 0:r.filter(e=>{if(!t)return!0;return rr("string"==typeof e?Wr(e):e,t)}):[],l=null==s?void 0:s[0];a&&l&&a!==jr.Unknown&&a!==jr.MediaTour&&(this.selectedDate=ir("string"==typeof l?Wr(l):l),this.tourType=Ba[a],this.selectedTime="string"==typeof l?so(l):(e=>({datetime:Zi(e,"yyyy-MM-dd'T'HH:mm:ss"),offset:Zi(e,"xxx")}))(l))},this._getHighestRankedTourType=e=>{var t;const n=(null!==(t=e.rankOrderedSupportedTourTypes)&&void 0!==t?t:[]).map(t=>{var n,i;return{tourType:t,availabilities:null===(i=null===(n=e.availability)||void 0===n?void 0:n[t])||void 0===i?void 0:i.availableTourStartTimes}}).filter(e=>{if(e.tourType===jr.Unknown||e.tourType===jr.MediaTour)return!1;const t=Ba[e.tourType],n=this._getTourTypeOffered(t);return!!n&&(!Ko(0,n)&&e.availabilities&&e.availabilities.length>0)}),i=n[0];return i?i.tourType:null},this._getTourTypeOffered=e=>e===Ua.Guided?this.escortedToursTypeOffered:e===Ua.Self?this.selfGuidedToursTypeOffered:e===Ua.Virtual?this.virtualToursTypeOffered:null,this._getUnitOptions=()=>{const e=this.selectedLayoutValue?this.units.filter(e=>Fa(10*e.numberOfBedrooms)===this.selectedLayoutValue):this.units,t=e.map(e=>({label:e.unitNumber,value:e.unitNumber}));return t},this._fetchUnits=async()=>{if(this.buildingSlug)try{this.units=await Ma({buildingSlug:this.buildingSlug})}catch(e){this.units=[],jo({logTitle:"ERROR_LOADING_UNITS_FOR_TOUR_SCHEDULER",logData:{error:e},logType:Bo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.firstUpdated=async()=>{if(await this._fetchCentralConvoBuildings(),this.isGeneralBuilding)return this.waitingForAvailabilities=!1,this.shouldAllowScheduleLoading=!1,void(this.statusMessage="Please select a building to see tour availabilities.");await this._loadForCurrentBuilding()},this._loadForCurrentBuilding=async()=>{try{await io(this.buildingId)}catch(e){}await Promise.all([this._setAvailabilities().then(async()=>{try{const e=await io(this.buildingId);this.allowOccupiedUnitTours=!!e.allowOccupiedUnitTours}catch(e){this.allowOccupiedUnitTours=!1}}),this._fetchUnits()])},this._fetchCentralConvoBuildings=async()=>{if(this.orgSlug&&this.buildingSlug)try{const e=await async function(e,t){var n,i;const o=(await r().get("https://app.meetelise.com/platformApi/webchat/central-convo-buildings-v2",{headers:{"building-slug":t,"org-slug":e}})).data;return{is_general_building:null!==(n=null==o?void 0:o.is_general_building)&&void 0!==n&&n,buildings:null!==(i=null==o?void 0:o.buildings)&&void 0!==i?i:[]}}(this.orgSlug,this.buildingSlug);this.centralConvoBuildings=e.buildings,this.isGeneralBuilding=e.is_general_building}catch(e){this.centralConvoBuildings=[],this.isGeneralBuilding=!1}},this._onBuildingChange=async()=>{var e;const t=null===(e=this.selectedBuildingEl)||void 0===e?void 0:e.value;if(!t||t===this.buildingSlug)return;const n=this.centralConvoBuildings.find(e=>e.slug===t);if(n){this.isGeneralBuilding=!1,this.waitingForAvailabilities=!0,this.errorGettingAvailabilities=!1,this.tourType=null,this.selectedDate=void 0,this.selectedTime=void 0,this.availabilitiesGroupedByDay={},this.mobilePageIndex=0,this.units=[],this.selectedLayoutValue="",this.selectedUnitValue="",this.buildingId=n.building_id,this.buildingSlug=n.slug,this.buildingName=n.name,this.statusMessage=`Loading tours for ${n.name}…`,Co("tourBuildingSelected",{buildingId:n.building_id});try{const e=await Xo(this.orgSlug,n.slug);this.sgtUrl=e.sgtUrl,this.selfGuidedToursTypeOffered=e.selfGuidedToursTypeOffered,this.selfGuidedTourEnabled=e.isSelfGuidedTourEnabled,this.escortedToursLink=e.escortedToursLink,this.escortedToursTypeOffered=e.escortedToursTypeOffered,this.virtualToursLink=e.virtualToursLink,this.virtualToursTypeOffered=e.virtualToursTypeOffered,this.tourTypeOptions=e.tourTypeOptions.map(e=>({label:e.label,value:e.value})),this.hasDynamicSchedulingEnabled=e.usesDynamicScheduling}catch(e){}if(await this._loadForCurrentBuilding(),!this.shouldAllowScheduling||this.errorGettingAvailabilities)this.statusMessage=`No tour availabilities for ${n.name}.`;else{const e=Object.values(this.shouldShowTourType).filter(Boolean).length;this.statusMessage=`Showing tours for ${n.name}. ${e} tour type${1===e?"":"s"} available.`}}},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await ao(Ra[this.tourType]))},this.onChangePhoneNumber=e=>{this.phoneNumber=e.detail.formattedValue,this.phoneNumberE164=e.detail.e164,this.phoneCountry=e.detail.country,this.phoneNumberIsValid=e.detail.isValid},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,n,i;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&Nr(null!==(i=null===(n=this.emailInput)||void 0===n?void 0:n.value)&&void 0!==i?i:"")&&!!this.phoneNumber&&!!this.phoneNumberE164}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,n]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(n)]},this.submit=async()=>{var e,t,n,i,o,a,s,l,u,d,c,h,p,f,g,m,y,b,v,w,C,x,$;if(!this.selectedDate||!this.selectedTime||null===this.tourType)return;const S=this.phoneNumberE164;if(!S)return void(this.phoneNumberIsValid=!1);const A=new URLSearchParams(window.location.search);let E=null;E=this.selectedLeadSource&&this.selectedLeadSource.value&&this.selectedLeadSource.value.length>0?this.selectedLeadSource.value:this.leadSourceInputValue&&this.leadSourceInputValue.length>0?this.leadSourceInputValue:this.currentLeadSource;const T=[...new Set(E?[E,"property-website"]:["property-website"])];this.firstNameInput&&(this.firstNameInputValue=this.firstNameInput.value),this.lastNameInput&&(this.lastNameInputValue=this.lastNameInput.value),this.leadSourceInputValue=E;const k=(null===(e=this.selectedLayoutEl)||void 0===e?void 0:e.value)||this.selectedLayoutValue||null,_=(null===(t=this.selectedUnitEl)||void 0===t?void 0:t.value)||this.selectedUnitValue||null;Co("scheduleTourSubmitted",{email:this.email,phone:S,firstName:null!==(i=null===(n=this.firstNameInput)||void 0===n?void 0:n.value)&&void 0!==i?i:this.firstNameInputValue,lastName:null!==(a=null===(o=this.lastNameInput)||void 0===o?void 0:o.value)&&void 0!==a?a:this.lastNameInputValue,tourType:ja[this.tourType],tourTime:`${this.selectedTime.datetime}${this.selectedTime.offset}`,originatingSource:T.find(e=>"property-website"!==e)||null,layout:k,unit:_,conversationTrackingId:null!==(l=null===(s=this.leadSourceClient)||void 0===s?void 0:s.chatId)&&void 0!==l?l:null});const O={referrer:document.referrer,email_address:this.email,phone_number:S,building_id:this.buildingId,first_name:null!==(d=null===(u=this.firstNameInput)||void 0===u?void 0:u.value)&&void 0!==d?d:this.firstNameInputValue,last_name:null!==(h=null===(c=this.lastNameInput)||void 0===c?void 0:c.value)&&void 0!==h?h:this.lastNameInputValue,tour_type:ja[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,cancel_existing_tours:this.promptForReschedule,lead_sources:[...new Set(E?[E,zo(this.orgSlug)]:[zo(this.orgSlug)])],query_params:Object.fromEntries(A.entries()),conversation_tracking_id:null===(p=this.leadSourceClient)||void 0===p?void 0:p.chatId,layouts:k?[k]:void 0,unit_numbers:_?[_]:void 0,lead_sources_with_timestamps:(null!==(m=null===(f=this.leadSourceMultitouchClient)||void 0===f?void 0:f.getSafeLeadSourceTouchpointsWithDefault({includedUserSelectedLeadSource:(null===(g=this.selectedLeadSource)||void 0===g?void 0:g.value)&&this.selectedLeadSource.value.length>0?this.selectedLeadSource.value:null}))&&void 0!==m?m:[]).map(e=>Er({...e}))};this.isSubmitting=!0;try{await r().post("https://app.meetelise.com/platformApi/state/create/v2/scheduleMe",O,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"webchatkey-wkjcWAKZjqhLStvP8L6SN8y4FbYmPhdE","org-slug":this.orgSlug}}),null===(y=this.leadSourceClient)||void 0===y||y.checkAndHandleForLogLeadSource({webchatAction:"tour-scheduler",stateId:null}),null===(b=this.leadSourceClient)||void 0===b||b.resetLeadSource(),null===(v=this.leadSourceMultitouchClient)||void 0===v||v.resetLeadSourceTouchpoints(),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e,n=(null===(C=null===(w=t.response)||void 0===w?void 0:w.data)||void 0===C?void 0:C.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[Zi(this.selectedDate,"yyyy-MM-dd")];e&&(this.availabilitiesGroupedByDay[Zi(this.selectedDate,"yyyy-MM-dd")]=e.filter(e=>e!==this.selectedTime))}}else{if(409===(null===(x=t.response)||void 0===x?void 0:x.status)&&!this.promptForReschedule&&"User already has a tour scheduled for this building"===n)return this.promptForReschedule=!0,this.isSubmitting=!1,void(this.tourIsBooked=!1);if(409===(null===($=t.response)||void 0===$?void 0:$.status)&&!this.promptForReschedule)return this.isSubmitting=!1,this.tourIsBooked=!1,no(),this.availabilitiesGroupedByDay=await ao(Ra[this.tourType],this.buildingId),void alert("This timeslot is no longer available. Please select a different time.")}alert(n),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>R`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>R`${this.dateAndTimeMenu()}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>R` <action-confirm-button
1482
1482
  id="schedule-bttn"
1483
1483
  .onClick=${this.submit}
1484
1484
  .isLoading=${this.isSubmitting}
@@ -1486,7 +1486,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
1486
1486
  width="145px"
1487
1487
  text="Schedule tour"
1488
1488
  ?disabled=${!this.formIsValidForSubmission()}
1489
- ></action-confirm-button>`,nextButtonAction:null,render:()=>R`${this.userInfoAndLayoutMenu()}`}]}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("aria-modal")||this.setAttribute("aria-modal","true"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Schedule a Tour")}openSelfGuidedTour(){const e=52===this.orgId?function(e,t){if(!e||!t)return e;try{const n=new URL(e);return Object.entries(t).forEach(([e,t])=>{n.searchParams.set(e,t)}),n.toString()}catch(t){return e}}(this.sgtUrl,this.leadSourceParams):this.sgtUrl;window.open(e,"_blank")}buildingSelectMenu(){return R`<me-select
1489
+ ></action-confirm-button>`,nextButtonAction:null,render:()=>R`${this.userInfoAndLayoutMenu()}`}]}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("aria-modal")||this.setAttribute("aria-modal","true"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Schedule a Tour")}openSelfGuidedTour(){const e=52===this.orgId?function(e,t){if(!e||!t)return e;try{const n=new URL(e);return Object.entries(t).forEach(([e,t])=>{n.searchParams.set(e,t)}),n.toString()}catch(t){return e}}(this.sgtUrl,mo()):this.sgtUrl;window.open(e,"_blank")}buildingSelectMenu(){return R`<me-select
1490
1490
  id="building"
1491
1491
  placeholder="Select a property"
1492
1492
  .value=${this.isGeneralBuilding?"":this.buildingSlug}
@@ -32,8 +32,6 @@ class LeadSourceClient {
32
32
 
33
33
  private apiHost = "https://app.meetelise.com";
34
34
  public leadSource: string | null = null;
35
- // UTM params associated with the resolved lead source (e.g. switch_code=<code>
36
- // for AMLI). Forwarded onto external tour-vendor links (e.g. Tour24).
37
35
  public leadSourceParams: { [key: string]: string } | null = null;
38
36
  private localStorageTTLDays = 30;
39
37
 
@@ -152,26 +150,11 @@ class LeadSourceClient {
152
150
  campaign_sources: campaignSources,
153
151
  };
154
152
  try {
155
- // Only AMLI (org 52) needs the resolved source's params forwarded to its
156
- // self-guided tour vendor (Tour24); every other org uses the original
157
- // endpoint that returns just the source string.
158
- if (this.orgId !== 52) {
159
- const response = await axios.post(
160
- `${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,
161
- requestBody
162
- );
163
- return response.data;
164
- }
165
153
  const response = await axios.post(
166
- `${this.apiHost}/platformApi/webchat/current-parsed-lead-source-with-params`,
154
+ `${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,
167
155
  requestBody
168
156
  );
169
- const data = response.data as {
170
- source: string | null;
171
- utm_params: { [key: string]: string } | null;
172
- };
173
- this.leadSourceParams = data?.utm_params ?? null;
174
- return data?.source ?? null;
157
+ return response.data;
175
158
  } catch (_) {
176
159
  return null;
177
160
  }
@@ -36,7 +36,10 @@ import compareAsc from "date-fns/compareAsc";
36
36
  import { InputStyles } from "../actions/InputStyles";
37
37
  import { classMap } from "lit/directives/class-map.js";
38
38
  import { FeatureFlagsShowDropdown } from "../../fetchFeatureFlag";
39
- import { appendParamsToUrl } from "../../postLeadSources";
39
+ import {
40
+ appendParamsToUrl,
41
+ getUrlQueryParameters,
42
+ } from "../../postLeadSources";
40
43
  import { pushGtmEvent } from "../../gtm";
41
44
  import formDisclaimer from "../../disclaimers";
42
45
  import { tourSchedulerStyles } from "./tourSchedulerStyles";
@@ -79,13 +82,12 @@ export class TourScheduler extends LitElement {
79
82
  }
80
83
 
81
84
  // Open the configured self-guided tour (e.g. Tour24) link. For org 52 (AMLI)
82
- // we forward the resolved lead source's params (e.g. switch_code=<code>) onto
83
- // the link so the vendor can attribute the lead; every other org opens the
84
- // link unchanged.
85
+ // we read URL params fresh at open-time so returning visitors (cached lead
86
+ // source) still get the current page's query string forwarded.
85
87
  private openSelfGuidedTour(): void {
86
88
  const url =
87
89
  this.orgId === 52
88
- ? appendParamsToUrl(this.sgtUrl, this.leadSourceParams)
90
+ ? appendParamsToUrl(this.sgtUrl, getUrlQueryParameters())
89
91
  : this.sgtUrl;
90
92
  window.open(url, "_blank");
91
93
  }