@meetelise/chat 1.20.15 → 1.20.16

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.20.15",
3
+ "version": "1.20.16",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -443,7 +443,7 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
443
443
  .option.active {
444
444
  background-color: var(--active-option-color);
445
445
  }
446
- `,$t([oe({attribute:!1})],zt.prototype,"options",void 0),$t([oe({type:String})],zt.prototype,"placeholder",void 0),$t([oe({type:String})],zt.prototype,"value",void 0),$t([ae()],zt.prototype,"activeOption",void 0),$t([ae()],zt.prototype,"isOpen",void 0),$t([se("#select",!0)],zt.prototype,"meSelect",void 0),zt=$t([ie("me-select")],zt);var Xt=n(9669),Zt=n.n(Xt),Qt=n(9991),Kt=n(7739),Yt=n.n(Kt);function en(e){return Ee(1,arguments),Fe(e).getTime()<Date.now()}Math.pow(10,8);var tn=36e5;function nn(e,t){Ee(1,arguments);var n=t||{},i=null==n.additionalDigits?2:Ve(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=un(e);if(o.date){var a=ln(o.date,i);r=dn(a.restDateString,a.year)}if(!r||isNaN(r.getTime()))return new Date(NaN);var s,u=r.getTime(),l=0;if(o.time&&(l=pn(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=hn(o.timezone),isNaN(s)?new Date(NaN):new Date(u+l+s)}var rn={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},on=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,an=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,sn=/^([+-])(\d{2})(?::?(\d{2}))?$/;function un(e){var t,n={},i=e.split(rn.dateTimeDelimiter);if(i.length>2)return n;if(/:/.test(i[0])?t=i[0]:(n.date=i[0],t=i[1],rn.timeZoneDelimiter.test(n.date)&&(n.date=e.split(rn.timeZoneDelimiter)[0],t=e.substr(n.date.length,e.length))),t){var r=rn.timezone.exec(t);r?(n.time=t.replace(r[1],""),n.timezone=r[1]):n.time=t}return n}function ln(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 dn(e,t){if(null===t)return new Date(NaN);var n=e.match(on);if(!n)return new Date(NaN);var i=!!n[4],r=cn(n[1]),o=cn(n[2])-1,a=cn(n[3]),s=cn(n[4]),u=cn(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<=(mn[t]||(vn(e)?29:28))}(t,o,a)&&function(e,t){return t>=1&&t<=(vn(e)?366:365)}(t,r)?(l.setUTCFullYear(t,o,Math.max(r,a)),l):new Date(NaN)}function cn(e){return e?parseInt(e):1}function pn(e){var t=e.match(an);if(!t)return NaN;var n=fn(t[1]),i=fn(t[2]),r=fn(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*tn+6e4*i+1e3*r:NaN}function fn(e){return e&&parseFloat(e.replace(",","."))||0}function hn(e){if("Z"===e)return 0;var t=e.match(sn);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*tn+6e4*r):NaN}var mn=[31,null,31,30,31,30,31,31,30,31,30,31];function vn(e){return e%400==0||e%4==0&&e%100!=0}const gn={buildingId:null,availabilities:{}},yn=async e=>{e&&(gn.buildingId=e);const t=gn.buildingId;if(!t)throw new Error("No buildingId was provided to getRawAvailabilities and there is no buildingId cached.");const n=gn.availabilities;if(n[t])return n[t];const i=function(e){Ee(1,arguments);var t=Fe(e);return t.setHours(0,0,0,0),t}(Date.now()),r=Vt(function(e){Ee(1,arguments);var t=Fe(e);return t.setHours(23,59,59,999),t}(function(e,t){Ee(2,arguments);var n=Fe(e),i=Ve(t);return isNaN(i)?new Date(NaN):i?(n.setDate(n.getDate()+i),n):n}(i,30))),o=`https://app.meetelise.com/api/pub/v1/buildings/${t}/tour/availabilities?startTime=${Vt(i)}&endTime=${r}`,a=await Zt().get(o);return gn.availabilities[t]=a.data,a.data},bn=async(e,t)=>{var n,i;const r=await yn(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},wn=async(e,t)=>{var n,i;const r=await bn(e,t);if(!r)return{};const o={availableTourStartTimes:null===(n=r.availableTourStartTimes?r.availableTourStartTimes.filter((e=>De(nn(e))&&!en(nn(e)))):[])||void 0===n?void 0:n.map((e=>Sn(e)))};return Yt()(null!==(i=o.availableTourStartTimes)&&void 0!==i?i:[],(e=>Pt(new Date(e.datetime),"yyyy-MM-dd")))},Sn=e=>({datetime:e.slice(0,19),offset:e.slice(19)});n(7294);const Tn=()=>window.matchMedia("(max-width: 767px)").matches;var xn=n(6486),On=n(4184),In=n.n(On),Rn=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 Nn=class extends te{constructor(){super(...arguments),this.layoutOptions=[],this.unitOptions=[],this.tourTypeOptions=[],this.buildingId=0,this.buildingSlug="",this.sgtUrl="",this.orgSlug="",this.tourType=An.Self,this.shouldShowTourType={[An.Guided]:!0,[An.Self]:!0,[An.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.waitingForAvailabilities=!0,this.mobilePageIndex=0,this.isSubmitting=!1,this.tourIsBooked=!1,this.firstUpdated=async()=>{this.availabilitiesGroupedByDay=await wn(Cn[this.tourType]),this.waitingForAvailabilities=!1;const e=await(async()=>{var e,t,n,i,r,o;return{[An.Guided]:!!(null===(t=null===(e=await bn(Qt.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent))||void 0===e?void 0:e.availableTourStartTimes)||void 0===t?void 0:t.length),[An.Self]:!!(null===(i=null===(n=await bn(Qt.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.SelfGuided))||void 0===n?void 0:n.availableTourStartTimes)||void 0===i?void 0:i.length),[An.Virtual]:!!(null===(o=null===(r=await bn(Qt.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing))||void 0===r?void 0:r.availableTourStartTimes)||void 0===o?void 0:o.length)}})();this.shouldShowTourType={[An.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&e[An.Guided],[An.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&e[An.Self],[An.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&e[An.Virtual]}},this.willUpdate=async e=>{e.has("tourType")&&(this.availabilitiesGroupedByDay=await wn(Cn[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const n=e.target.selectionStart;if(1!==e.key.length||Ne(e)){if("Backspace"===e.key){if(Ne(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,i=this.phoneNumber.slice(0,n).replace(/\D/g,""),r=this.phoneNumber.slice(n).replace(/\D/g,""),o=`${i.slice(0,-1)}${r}`;this.phoneNumber=Ie(o),this.phoneInput.value=this.phoneNumber;const a=n-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Ne(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,n).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,i=n-e>-1?n-e:0;this.phoneInput.setSelectionRange(i,i)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(n).split(/\d+/)[0].length||0)+1,t=n+e<this.phoneNumber.length?n+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,n)+e.key+this.phoneNumber.slice(n);this.phoneNumber=Ie(t.replace(/\D/g,"")),this.phoneInput.value=this.phoneNumber}},this.handlePhoneKeyup=e=>{var t;if(!e.key)return;if(e.key.includes("Arrow")||["Meta","Shift","Control","Alt"].includes(e.key))return;const n=this.phoneInput.selectionStart,i=n?this.phoneInput.value.slice(n).replace(/\D/g,""):"";this.phoneNumber=Ie(this.phoneInput.value);let r=0,o=i.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>!isNaN(this.tourType),dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t,n;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&(null===(n=this.emailInput)||void 0===n?void 0:n.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length}},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;if(!this.selectedDate||!this.selectedTime)return;const t={email_address:this.email,phone_number:`+1${null===(e=this.phoneNumber.match(/\d/g))||void 0===e?void 0:e.join("")}`,building_id:this.buildingId,first_name:this.firstNameInput.value,last_name:this.lastNameInput.value,tour_type:_n[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,layouts:this.layoutTypeSelect.value?[this.layoutTypeSelect.value]:null,unit_numbers:this.unitTypeSelect.value?[this.unitTypeSelect.value]:null};this.isSubmitting=!0;try{await Zt().post("https://app.meetelise.com/platformApi/state/create/scheduleMe",t,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG","org-slug":this.orgSlug}}),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e.response.data.detail||"Failed to book tour";alert(t),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>D`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>D`${this.dateAndTimeMenu(!0)}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>D`<action-confirm-button
446
+ `,$t([oe({attribute:!1})],zt.prototype,"options",void 0),$t([oe({type:String})],zt.prototype,"placeholder",void 0),$t([oe({type:String})],zt.prototype,"value",void 0),$t([ae()],zt.prototype,"activeOption",void 0),$t([ae()],zt.prototype,"isOpen",void 0),$t([se("#select",!0)],zt.prototype,"meSelect",void 0),zt=$t([ie("me-select")],zt);var Xt=n(9669),Zt=n.n(Xt),Qt=n(9991),Kt=n(7739),Yt=n.n(Kt);function en(e){return Ee(1,arguments),Fe(e).getTime()<Date.now()}Math.pow(10,8);var tn=36e5;function nn(e,t){Ee(1,arguments);var n=t||{},i=null==n.additionalDigits?2:Ve(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=un(e);if(o.date){var a=ln(o.date,i);r=dn(a.restDateString,a.year)}if(!r||isNaN(r.getTime()))return new Date(NaN);var s,u=r.getTime(),l=0;if(o.time&&(l=pn(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=hn(o.timezone),isNaN(s)?new Date(NaN):new Date(u+l+s)}var rn={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},on=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,an=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,sn=/^([+-])(\d{2})(?::?(\d{2}))?$/;function un(e){var t,n={},i=e.split(rn.dateTimeDelimiter);if(i.length>2)return n;if(/:/.test(i[0])?t=i[0]:(n.date=i[0],t=i[1],rn.timeZoneDelimiter.test(n.date)&&(n.date=e.split(rn.timeZoneDelimiter)[0],t=e.substr(n.date.length,e.length))),t){var r=rn.timezone.exec(t);r?(n.time=t.replace(r[1],""),n.timezone=r[1]):n.time=t}return n}function ln(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 dn(e,t){if(null===t)return new Date(NaN);var n=e.match(on);if(!n)return new Date(NaN);var i=!!n[4],r=cn(n[1]),o=cn(n[2])-1,a=cn(n[3]),s=cn(n[4]),u=cn(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<=(mn[t]||(vn(e)?29:28))}(t,o,a)&&function(e,t){return t>=1&&t<=(vn(e)?366:365)}(t,r)?(l.setUTCFullYear(t,o,Math.max(r,a)),l):new Date(NaN)}function cn(e){return e?parseInt(e):1}function pn(e){var t=e.match(an);if(!t)return NaN;var n=fn(t[1]),i=fn(t[2]),r=fn(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*tn+6e4*i+1e3*r:NaN}function fn(e){return e&&parseFloat(e.replace(",","."))||0}function hn(e){if("Z"===e)return 0;var t=e.match(sn);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*tn+6e4*r):NaN}var mn=[31,null,31,30,31,30,31,31,30,31,30,31];function vn(e){return e%400==0||e%4==0&&e%100!=0}const gn={buildingId:null,availabilities:{}},yn=async e=>{e&&(gn.buildingId=e);const t=gn.buildingId;if(!t)throw new Error("No buildingId was provided to getRawAvailabilities and there is no buildingId cached.");const n=gn.availabilities;if(n[t])return n[t];const i=function(e){Ee(1,arguments);var t=Fe(e);return t.setHours(0,0,0,0),t}(Date.now()),r=Vt(function(e){Ee(1,arguments);var t=Fe(e);return t.setHours(23,59,59,999),t}(function(e,t){Ee(2,arguments);var n=Fe(e),i=Ve(t);return isNaN(i)?new Date(NaN):i?(n.setDate(n.getDate()+i),n):n}(i,30))),o=`https://app.meetelise.com/api/pub/v1/buildings/${t}/tour/availabilities?startTime=${Vt(i)}&endTime=${r}`,a=await Zt().get(o);return gn.availabilities[t]=a.data,a.data},bn=async(e,t)=>{var n,i;const r=await yn(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},wn=async(e,t)=>{var n,i;const r=await bn(e,t);if(!r)return{};const o={availableTourStartTimes:null===(n=r.availableTourStartTimes?r.availableTourStartTimes.filter((e=>De(nn(e))&&!en(nn(e)))):[])||void 0===n?void 0:n.map((e=>Sn(e)))};return Yt()(null!==(i=o.availableTourStartTimes)&&void 0!==i?i:[],(e=>Pt(new Date(e.datetime),"yyyy-MM-dd")))},Sn=e=>({datetime:e.slice(0,19),offset:e.slice(19)});n(7294);const Tn=()=>window.matchMedia("(max-width: 767px)").matches;var xn=n(6486),On=n(4184),In=n.n(On),Rn=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 Nn=class extends te{constructor(){super(...arguments),this.layoutOptions=[],this.unitOptions=[],this.tourTypeOptions=[],this.buildingId=0,this.buildingSlug="",this.sgtUrl="",this.orgSlug="",this.tourType=null,this.shouldShowTourType={[An.Guided]:!0,[An.Self]:!0,[An.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.waitingForAvailabilities=!0,this.mobilePageIndex=0,this.isSubmitting=!1,this.tourIsBooked=!1,this.firstUpdated=async()=>{if(!this.tourType)return;this.availabilitiesGroupedByDay=await wn(Cn[this.tourType]),this.waitingForAvailabilities=!1;const e=await(async()=>{var e,t,n,i,r,o;return{[An.Guided]:!!(null===(t=null===(e=await bn(Qt.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent))||void 0===e?void 0:e.availableTourStartTimes)||void 0===t?void 0:t.length),[An.Self]:!!(null===(i=null===(n=await bn(Qt.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.SelfGuided))||void 0===n?void 0:n.availableTourStartTimes)||void 0===i?void 0:i.length),[An.Virtual]:!!(null===(o=null===(r=await bn(Qt.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing))||void 0===r?void 0:r.availableTourStartTimes)||void 0===o?void 0:o.length)}})();this.shouldShowTourType={[An.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&e[An.Guided],[An.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&e[An.Self],[An.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&e[An.Virtual]}},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await wn(Cn[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const n=e.target.selectionStart;if(1!==e.key.length||Ne(e)){if("Backspace"===e.key){if(Ne(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,i=this.phoneNumber.slice(0,n).replace(/\D/g,""),r=this.phoneNumber.slice(n).replace(/\D/g,""),o=`${i.slice(0,-1)}${r}`;this.phoneNumber=Ie(o),this.phoneInput.value=this.phoneNumber;const a=n-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Ne(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,n).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,i=n-e>-1?n-e:0;this.phoneInput.setSelectionRange(i,i)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(n).split(/\d+/)[0].length||0)+1,t=n+e<this.phoneNumber.length?n+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,n)+e.key+this.phoneNumber.slice(n);this.phoneNumber=Ie(t.replace(/\D/g,"")),this.phoneInput.value=this.phoneNumber}},this.handlePhoneKeyup=e=>{var t;if(!e.key)return;if(e.key.includes("Arrow")||["Meta","Shift","Control","Alt"].includes(e.key))return;const n=this.phoneInput.selectionStart,i=n?this.phoneInput.value.slice(n).replace(/\D/g,""):"";this.phoneNumber=Ie(this.phoneInput.value);let r=0,o=i.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>!!this.tourType&&!isNaN(this.tourType),dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t,n;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&(null===(n=this.emailInput)||void 0===n?void 0:n.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length}},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;if(!this.selectedDate||!this.selectedTime||!this.tourType)return;const t={email_address:this.email,phone_number:`+1${null===(e=this.phoneNumber.match(/\d/g))||void 0===e?void 0:e.join("")}`,building_id:this.buildingId,first_name:this.firstNameInput.value,last_name:this.lastNameInput.value,tour_type:_n[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,layouts:this.layoutTypeSelect.value?[this.layoutTypeSelect.value]:null,unit_numbers:this.unitTypeSelect.value?[this.unitTypeSelect.value]:null};this.isSubmitting=!0;try{await Zt().post("https://app.meetelise.com/platformApi/state/create/scheduleMe",t,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG","org-slug":this.orgSlug}}),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e.response.data.detail||"Failed to book tour";alert(t),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>D`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>D`${this.dateAndTimeMenu(!0)}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>D`<action-confirm-button
447
447
  id="schedule"
448
448
  .onClick=${this.submit}
449
449
  .isLoading=${this.isSubmitting}
@@ -456,7 +456,7 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
456
456
  ${this.shouldShowTourType[An.Guided]?D` <tour-type-option
457
457
  heading="Guided tour"
458
458
  subtitle="with an agent"
459
- @click="${()=>{this.sgtUrl?window.open(this.sgtUrl,"_blank"):this.tourType=An.Guided}}"
459
+ @click="${()=>{this.tourType=An.Guided}}"
460
460
  @keydown="${e=>{[" ","Enter"].includes(e.key)&&(e.preventDefault(),this.tourType=An.Guided)}}"
461
461
  ?selected="${this.tourType===An.Guided}"
462
462
  >
@@ -477,7 +477,7 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
477
477
  ${this.shouldShowTourType[An.Self]?D`<tour-type-option
478
478
  heading="Take a tour"
479
479
  subtitle="on your own"
480
- @click="${()=>{this.tourType=An.Self}}"
480
+ @click="${()=>{this.sgtUrl?window.open(this.sgtUrl,"_blank"):this.tourType=An.Self}}"
481
481
  @keydown="${e=>{[" ","Enter"].includes(e.key)&&(e.preventDefault(),this.tourType=An.Self)}}"
482
482
  ?selected="${this.tourType===An.Self}"
483
483
  >
@@ -629,7 +629,7 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
629
629
  </me-select>
630
630
  </div>
631
631
  </div>`:""}
632
- </div> `}confirmationMessage(){if(!this.selectedDate||!this.selectedTime)return D``;const e=Pt(nn(`${this.selectedTime.datetime}${this.selectedTime.offset}`),"h:mmaaa");return D`
632
+ </div> `}confirmationMessage(){if(!this.selectedDate||!this.selectedTime||!this.tourType)return D``;const e=Pt(nn(`${this.selectedTime.datetime}${this.selectedTime.offset}`),"h:mmaaa");return D`
633
633
  <div id="confirmationMessage">
634
634
  <svg
635
635
  width="20"
@@ -62,7 +62,7 @@ export class TourScheduler extends LitElement {
62
62
  onCloseClicked?: (e: MouseEvent) => void;
63
63
 
64
64
  @state()
65
- private tourType = TourType.Self;
65
+ private tourType: TourType | null = null;
66
66
  @state()
67
67
  private shouldShowTourType = {
68
68
  [TourType.Guided]: true,
@@ -104,6 +104,9 @@ export class TourScheduler extends LitElement {
104
104
  layoutTypeSelect!: MESelect;
105
105
 
106
106
  firstUpdated = async (): Promise<void> => {
107
+ if (!this.tourType) {
108
+ return;
109
+ }
107
110
  this.availabilitiesGroupedByDay = await getAvailabilitiesGroupedByDay(
108
111
  tourTypeMap[this.tourType]
109
112
  );
@@ -131,7 +134,7 @@ export class TourScheduler extends LitElement {
131
134
  | PropertyValueMap<{ tourType: TourType }>
132
135
  | Map<PropertyKey, unknown>
133
136
  ): Promise<void> => {
134
- if (_changedProperties.has("tourType")) {
137
+ if (_changedProperties.has("tourType") && this.tourType) {
135
138
  this.availabilitiesGroupedByDay = await getAvailabilitiesGroupedByDay(
136
139
  tourTypeMap[this.tourType]
137
140
  );
@@ -290,7 +293,7 @@ export class TourScheduler extends LitElement {
290
293
  };
291
294
 
292
295
  validators = {
293
- tourType: (): boolean => !isNaN(this.tourType),
296
+ tourType: (): boolean => !!this.tourType && !isNaN(this.tourType),
294
297
  dateAndTime: (): boolean => !!this.selectedDate && !!this.selectedTime,
295
298
  leadInfo: (): boolean => {
296
299
  return (
@@ -326,7 +329,7 @@ export class TourScheduler extends LitElement {
326
329
  };
327
330
 
328
331
  submit = async (): Promise<void> => {
329
- if (!this.selectedDate || !this.selectedTime) return;
332
+ if (!this.selectedDate || !this.selectedTime || !this.tourType) return;
330
333
  const data = {
331
334
  email_address: this.email,
332
335
  phone_number: `+1${this.phoneNumber.match(/\d/g)?.join("")}`, // e.g. +12125555555
@@ -767,10 +770,6 @@ export class TourScheduler extends LitElement {
767
770
  heading="Guided tour"
768
771
  subtitle="with an agent"
769
772
  @click="${() => {
770
- if (this.sgtUrl) {
771
- window.open(this.sgtUrl, "_blank");
772
- return;
773
- }
774
773
  this.tourType = TourType.Guided;
775
774
  }}"
776
775
  @keydown="${(e: KeyboardEvent) => {
@@ -803,6 +802,10 @@ export class TourScheduler extends LitElement {
803
802
  heading="Take a tour"
804
803
  subtitle="on your own"
805
804
  @click="${() => {
805
+ if (this.sgtUrl) {
806
+ window.open(this.sgtUrl, "_blank");
807
+ return;
808
+ }
806
809
  this.tourType = TourType.Self;
807
810
  }}"
808
811
  @keydown="${(e: KeyboardEvent) => {
@@ -1102,7 +1105,8 @@ export class TourScheduler extends LitElement {
1102
1105
  }
1103
1106
 
1104
1107
  confirmationMessage(): TemplateResult {
1105
- if (!this.selectedDate || !this.selectedTime) return html``;
1108
+ if (!this.selectedDate || !this.selectedTime || !this.tourType)
1109
+ return html``;
1106
1110
  // format example: "November 9th, 2022 at 11:00pm"
1107
1111
  const readableDateAndTime = format(
1108
1112
  parseISO(`${this.selectedTime.datetime}${this.selectedTime.offset}`),