From 18479cc36adb59f3c987f91b6a1355abff3f87d9 Mon Sep 17 00:00:00 2001 From: yxxh Date: Thu, 29 May 2025 14:11:21 -0700 Subject: [PATCH 1/3] fix: stop double zip code init --- public/preorder-app/before-body.html | 349 ++++ public/preorder-app/bundle.css | 2 +- public/preorder-app/embed.js | 2056 ++++++++++++++++++++++- public/preorder-app/embed.js.map | 2 +- src/PreorderApp.ts | 12 + src/embed.ts | 1 + src/location-input/LocationInput.svelte | 4 +- src/location-input/ZipCodeInput.svelte | 47 +- 8 files changed, 2450 insertions(+), 23 deletions(-) create mode 100644 public/preorder-app/before-body.html diff --git a/public/preorder-app/before-body.html b/public/preorder-app/before-body.html new file mode 100644 index 0000000..ad4bdbe --- /dev/null +++ b/public/preorder-app/before-body.html @@ -0,0 +1,349 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/preorder-app/bundle.css b/public/preorder-app/bundle.css index 1b651cd..4d3c9d5 100644 --- a/public/preorder-app/bundle.css +++ b/public/preorder-app/bundle.css @@ -1 +1 @@ -.input-address-container{display:flex;padding:var(--Spacing-spacing-m, 8px);flex-direction:row;justify-content:center;align-items:flex-start;gap:var(--Spacing-spacing-m, 8px);align-self:stretch;height:66px;background:#fff;border-radius:12px;position:relative;z-index:551}@media screen and (max-width: 768px){.input-address-container{max-width:400px;margin-left:auto;margin-right:auto;height:48px;padding-top:0px}}.input-address-container.focused{outline:2px solid var(--Greyscale-20, #D8D7D5)}.input-address-container.focused:before{content:" ";position:absolute;z-index:-1;top:0px;left:0px;right:0px;bottom:0px;border-radius:12px;border:1px solid var(--Greyscale-90, #54524F)}.input-address-container img{margin:13px 0 9px 10px;position:absolute;left:8px}.submitAddressButton{display:flex;flex-shrink:0;height:48px;flex-direction:column;justify-content:center;align-items:center;gap:var(--Spacing-spacing-m, 8px);border-radius:12px;position:absolute;right:9px;margin-top:-56px;z-index:551;padding:0 20px;font-size:16px;font-weight:600}@media screen and (max-width: 768px){.submitAddressButton{position:relative;width:100%;margin-top:10px;margin-left:10px}}.preorder-address-error-message{color:#c95151;font-size:16px;margin-top:6px}.location-search-input{position:absolute;height:44px;width:100%;border:none;background:none;border-radius:12px;border:none !important;outline:none !important;font-size:16px;font-weight:500;line-height:24px;padding:3px 16px 0 48px}.location-search-input.focused{border-radius:0 0 12px 12px}.location-search-input::-moz-placeholder{color:#7F7D7A;font-size:16px;font-weight:500}.location-search-input::placeholder{color:#7F7D7A;font-size:16px;font-weight:500}.location-search-input.input:focus{box-shadow:none}.hs-form__virality-link{display:none !important}#popup-form{transition:0.2s all}.signup_wrapper{margin-bottom:18px}@media screen and (max-width: 768px){.signup_wrapper{margin-bottom:48px}}.signup_wrapper .paragraph.text-color-white.beta_text{display:inline;position:absolute;left:0;gap:var(--Spacing-spacing-m, 8px);border-radius:4px;background:rgba(28, 40, 41, 0.5);color:var(--Primitives-White, #fff);padding:var(--Spacing-spacing-xs, 2px) var(--Spacing-spacing-m, 8px);margin-top:6px;font-size:14px;font-weight:400;line-height:20px}.button.secondary{color:#084D41;background:#D0F585;max-width:400px;margin-left:auto;margin-right:auto}@media screen and (max-width: 768px){.button.secondary{left:0}}.button.secondary:hover{background:#ECFAD0}.focus_overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(41, 40, 38, 0.8);z-index:50;display:none}.input-zip-wrap{max-width:460px;margin:0 auto;display:flex;flex-direction:column;gap:12px;position:relative}@media screen and (max-width: 768px){.input-zip-wrap{max-width:100%;padding:0 16px}}.input-zip-container{background:#fff;border-radius:var(--Radius-radius-l, 8px);position:relative;z-index:551;padding:8px;display:flex;align-items:center;height:66px;gap:12px}@media screen and (max-width: 768px){.input-zip-container{padding:8px;height:64px;margin:0}}.zip-input-layout{position:relative;height:100%;display:flex;align-items:center;flex:1}@media screen and (max-width: 768px){.zip-input-layout{width:100%;height:48px;margin:4px 0}}.submitZipButton{height:48px;padding:0 20px;background:#D0F585;color:#084D41;border:none;border-radius:var(--Radius-radius-m, 8px);font-size:16px;font-weight:600;cursor:pointer;transition:all 0.2s;white-space:nowrap;min-width:160px}.submitZipButton:hover:not(:disabled){background:#ECFAD0}.submitZipButton:disabled{background:#E6E6E6;color:#A3A3A3;cursor:not-allowed}@media screen and (max-width: 768px){.submitZipButton{position:absolute;width:calc(100% - 32px);left:16px;top:calc(100% + 12px);margin:0}}.zip-boxes{position:absolute;display:flex;gap:8px;pointer-events:none;width:100%;justify-content:flex-start;padding-left:12px}@media screen and (max-width: 768px){.zip-boxes{justify-content:center;padding-left:0}}.zip-box{width:48px;height:40px;background:#EFF1F2;border-radius:var(--Radius-radius-s, 4px);display:flex;align-items:center;justify-content:center;font-size:20px;font-weight:500;color:#090D0F;transition:all 0.2s ease}.zip-box.filled{background:#ECFFC7}.zip-search-input{position:relative;height:44px;width:100%;border:none;background:transparent;font-size:20px;font-weight:500;padding:0;text-align:left;letter-spacing:2.85em;padding-left:0.75em;color:transparent;caret-color:#090D0F}@media screen and (max-width: 768px){.zip-search-input{text-align:center;padding-left:1.5em}}.zip-search-input:focus{outline:none}.preorder-zip-error-message{color:#c95151;font-size:16px;text-align:center;margin-top:8px}.focus_overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(41, 40, 38, 0.8);z-index:50;display:none}.input-zip-container.focused{outline:2px solid var(--Greyscale-20, #D8D7D5)}.input-zip-container.focused:before{content:" ";position:absolute;z-index:-1;top:0;left:0;right:0;bottom:0;border-radius:8px;border:1px solid var(--Greyscale-90, #54524F)}.autocomplete-container{position:relative;font-family:PP Neue Montreal Variable, Arial, sans-serif}.result-list{background:white;position:absolute;bottom:44px;padding:0;margin:0;width:100%;left:0}.pac-container{border-radius:12px;border-top-left-radius:0;border-top-right-radius:0;border:1px solid var(--Greyscale-90, #333E3F);border-top:none;box-shadow:0 2px 0 2px var(--Greyscale-20, #D2D4D4);padding-top:16px}@media screen and (max-width: 768px){.pac-container{margin-top:-6px}}.pac-container .pac-container .pac-item:first-of-type{border-top:red 1px}.pac-container .pac-item,.pac-container .pac-item .pac-item-query{color:var(--Greyscale-95, #283334);border:none;font-family:PP Neue Montreal Variable, Arial, sans-serif;font-size:12px;font-style:normal;font-style:normal;font-style:normal;font-weight:400;font-style:normal;line-height:24px;padding:0 16px;line-height:44px}.pac-container .pac-item .pac-item-query{font-weight:600;font-size:130%}.pac-container:after{display:none !important}.pac-container .pac-item:hover,.pac-container .pac-item:hover .pac-item-query{color:var(--Semantics-secondary, #084D41);background:rgba(236, 250, 208, 0.25)}.pac-icon.pac-icon-marker{display:none} \ No newline at end of file +.input-zip-wrap{max-width:460px;margin:0 auto;display:flex;flex-direction:column;gap:12px;position:relative}@media screen and (max-width: 768px){.input-zip-wrap{max-width:100%;padding:0 16px}}.input-zip-container{background:#fff;border-radius:var(--Radius-radius-l, 8px);position:relative;z-index:551;padding:8px;display:flex;align-items:center;height:66px;gap:12px}@media screen and (max-width: 768px){.input-zip-container{padding:8px;height:64px;margin:0}}.zip-input-layout{position:relative;height:100%;display:flex;align-items:center;flex:1}@media screen and (max-width: 768px){.zip-input-layout{width:100%;height:48px;margin:4px 0}}.submitZipButton{height:48px;padding:0 20px;background:#D0F585;color:#084D41;border:none;border-radius:var(--Radius-radius-m, 8px);font-size:16px;font-weight:600;cursor:pointer;transition:all 0.2s;white-space:nowrap;min-width:160px}.submitZipButton:hover:not(:disabled){background:#ECFAD0}.submitZipButton:disabled{background:#E6E6E6;color:#A3A3A3;cursor:not-allowed}@media screen and (max-width: 768px){.submitZipButton{position:absolute;width:calc(100% - 32px);left:16px;top:calc(100% + 12px);margin:0}}.zip-boxes{position:absolute;display:flex;gap:8px;pointer-events:none;width:100%;justify-content:flex-start;padding-left:12px}@media screen and (max-width: 768px){.zip-boxes{justify-content:center;padding-left:0}}.zip-box{width:48px;height:40px;background:#EFF1F2;border-radius:var(--Radius-radius-s, 4px);display:flex;align-items:center;justify-content:center;font-size:20px;font-weight:500;color:#090D0F;transition:all 0.2s ease}.zip-box.filled{background:#ECFFC7}.zip-search-input{position:relative;height:44px;width:100%;border:none;background:transparent;font-size:20px;font-weight:500;padding:0;text-align:left;letter-spacing:2.85em;padding-left:0.75em;color:transparent;caret-color:#090D0F}@media screen and (max-width: 768px){.zip-search-input{text-align:center;padding-left:1.5em}}.zip-search-input:focus{outline:none}.preorder-zip-error-message{color:#c95151;font-size:16px;text-align:center;margin-top:8px}.focus_overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(41, 40, 38, 0.8);z-index:50;display:none}.input-zip-container.focused{outline:2px solid var(--Greyscale-20, #D8D7D5)}.input-zip-container.focused:before{content:" ";position:absolute;z-index:-1;top:0;left:0;right:0;bottom:0;border-radius:8px;border:1px solid var(--Greyscale-90, #54524F)}.input-address-container{display:flex;padding:var(--Spacing-spacing-m, 8px);flex-direction:row;justify-content:center;align-items:flex-start;gap:var(--Spacing-spacing-m, 8px);align-self:stretch;height:66px;background:#fff;border-radius:12px;position:relative;z-index:551}@media screen and (max-width: 768px){.input-address-container{max-width:400px;margin-left:auto;margin-right:auto;height:48px;padding-top:0px}}.input-address-container.focused{outline:2px solid var(--Greyscale-20, #D8D7D5)}.input-address-container.focused:before{content:" ";position:absolute;z-index:-1;top:0px;left:0px;right:0px;bottom:0px;border-radius:12px;border:1px solid var(--Greyscale-90, #54524F)}.input-address-container img{margin:13px 0 9px 10px;position:absolute;left:8px}.submitAddressButton{display:flex;flex-shrink:0;height:48px;flex-direction:column;justify-content:center;align-items:center;gap:var(--Spacing-spacing-m, 8px);border-radius:12px;position:absolute;right:9px;margin-top:-56px;z-index:551;padding:0 20px;font-size:16px;font-weight:600}@media screen and (max-width: 768px){.submitAddressButton{position:relative;width:100%;margin-top:10px;margin-left:10px}}.preorder-address-error-message{color:#c95151;font-size:16px;margin-top:6px}.location-search-input{position:absolute;height:44px;width:100%;border:none;background:none;border-radius:12px;border:none !important;outline:none !important;font-size:16px;font-weight:500;line-height:24px;padding:3px 16px 0 48px}.location-search-input.focused{border-radius:0 0 12px 12px}.location-search-input::-moz-placeholder{color:#7F7D7A;font-size:16px;font-weight:500}.location-search-input::placeholder{color:#7F7D7A;font-size:16px;font-weight:500}.location-search-input.input:focus{box-shadow:none}.hs-form__virality-link{display:none !important}#popup-form{transition:0.2s all}.signup_wrapper{margin-bottom:18px}@media screen and (max-width: 768px){.signup_wrapper{margin-bottom:48px}}.signup_wrapper .paragraph.text-color-white.beta_text{display:inline;position:absolute;left:0;gap:var(--Spacing-spacing-m, 8px);border-radius:4px;background:rgba(28, 40, 41, 0.5);color:var(--Primitives-White, #fff);padding:var(--Spacing-spacing-xs, 2px) var(--Spacing-spacing-m, 8px);margin-top:6px;font-size:14px;font-weight:400;line-height:20px}.button.secondary{color:#084D41;background:#D0F585;max-width:400px;margin-left:auto;margin-right:auto}@media screen and (max-width: 768px){.button.secondary{left:0}}.button.secondary:hover{background:#ECFAD0}.focus_overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(41, 40, 38, 0.8);z-index:50;display:none}.autocomplete-container{position:relative;font-family:PP Neue Montreal Variable, Arial, sans-serif}.result-list{background:white;position:absolute;bottom:44px;padding:0;margin:0;width:100%;left:0}.pac-container{border-radius:12px;border-top-left-radius:0;border-top-right-radius:0;border:1px solid var(--Greyscale-90, #333E3F);border-top:none;box-shadow:0 2px 0 2px var(--Greyscale-20, #D2D4D4);padding-top:16px}@media screen and (max-width: 768px){.pac-container{margin-top:-6px}}.pac-container .pac-container .pac-item:first-of-type{border-top:red 1px}.pac-container .pac-item,.pac-container .pac-item .pac-item-query{color:var(--Greyscale-95, #283334);border:none;font-family:PP Neue Montreal Variable, Arial, sans-serif;font-size:12px;font-style:normal;font-style:normal;font-style:normal;font-weight:400;font-style:normal;line-height:24px;padding:0 16px;line-height:44px}.pac-container .pac-item .pac-item-query{font-weight:600;font-size:130%}.pac-container:after{display:none !important}.pac-container .pac-item:hover,.pac-container .pac-item:hover .pac-item-query{color:var(--Semantics-secondary, #084D41);background:rgba(236, 250, 208, 0.25)}.pac-icon.pac-icon-marker{display:none} \ No newline at end of file diff --git a/public/preorder-app/embed.js b/public/preorder-app/embed.js index e556828..083807d 100644 --- a/public/preorder-app/embed.js +++ b/public/preorder-app/embed.js @@ -1,2 +1,2056 @@ -!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";function e(){}function t(e,t){for(const n in t)e[n]=t[n];return e}function n(e){return e()}function o(){return Object.create(null)}function s(e){e.forEach(n)}function r(e){return"function"==typeof e}function i(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}let c,a;function l(e){const t={};for(const n in e)"$"!==n[0]&&(t[n]=e[n]);return t}function d(e,t){e.appendChild(t)}function u(e,t,n){e.insertBefore(t,n||null)}function p(e){e.parentNode&&e.parentNode.removeChild(e)}function f(e){return document.createElement(e)}function m(e){return document.createTextNode(e)}function g(){return m(" ")}function y(e,t,n,o){return e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o)}function h(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function b(e,t){t=""+t,e.data!==t&&(e.data=t)}function v(e,t,n){e.classList[n?"add":"remove"](t)}function _(e){a=e}function $(){if(!a)throw new Error("Function called outside component initialization");return a}function S(e){$().$$.on_mount.push(e)}function w(){const e=$();return(t,n,{cancelable:o=!1}={})=>{const s=e.$$.callbacks[t];if(s){const r=function(e,t,{bubbles:n=!1,cancelable:o=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,o,t),s}(t,n,{cancelable:o});return s.slice().forEach((t=>{t.call(e,r)})),!r.defaultPrevented}return!0}}const A=[],E=[];let x=[];const C=[],k=Promise.resolve();let z=!1;function q(e){x.push(e)}const j=new Set;let T=0;function L(){if(0!==T)return;const e=a;do{try{for(;T{const t=e.$$.on_mount.map(n).filter(r);e.$$.on_destroy?e.$$.on_destroy.push(...t):s(t),e.$$.on_mount=[]})),a.forEach(q)}function I(e,t){const n=e.$$;null!==n.fragment&&(!function(e){const t=[],n=[];x.forEach((o=>-1===e.indexOf(o)?t.push(o):n.push(o))),n.forEach((e=>e())),x=t}(n.after_update),s(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Q(e,t){-1===e.$$.dirty[0]&&(A.push(e),z||(z=!0,k.then(L)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const s=o.length?o[0]:n;return m.ctx&&c(m.ctx[e],m.ctx[e]=s)&&(!m.skip_bound&&m.bound[e]&&m.bound[e](s),g&&Q(t,e)),n})):[],m.update(),g=!0,s(m.before_update),m.fragment=!!i&&i(m.ctx),n.target){if(n.hydrate){const e=function(e){return Array.from(e.childNodes)}(n.target);m.fragment&&m.fragment.l(e),e.forEach(p)}else m.fragment&&m.fragment.c();n.intro&&K(t.$$.fragment),O(t,n.target,n.anchor,n.customElement),L()}_(f)}class N{$destroy(){I(this,1),this.$destroy=e}$on(t,n){if(!r(n))return e;const o=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return o.push(n),()=>{const e=o.indexOf(n);-1!==e&&o.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}let U=!1;const M=[];function R(e,t){if(window.google&&window.google.maps&&window.google.maps.places)return void t();if(t&&M.push(t),U)return;U=!0;const n=document.createElement("script");n.async=!0,n.defer=!0,n.onload=F,n.src=`https://maps.googleapis.com/maps/api/js?key=${encodeURIComponent(e)}&libraries=places`,n.type="text/javascript",document.head.appendChild(n)}function F(){let e;for(U=!1;e=M.pop();)e()}function Z(t){let n,o,r,i;return{c(){n=f("input"),h(n,"class",o=t[7].class),h(n,"placeholder",t[0]),n.value=t[1],n.required=t[2],h(n,"pattern",t[3]),v(n,"input",!0)},m(e,o){u(e,n,o),t[11](n),r||(i=[y(n,"change",t[5]),y(n,"keydown",t[6])],r=!0)},p(e,[t]){128&t&&o!==(o=e[7].class)&&h(n,"class",o),1&t&&h(n,"placeholder",e[0]),2&t&&n.value!==e[1]&&(n.value=e[1]),4&t&&(n.required=e[2]),8&t&&h(n,"pattern",e[3]),128&t&&v(n,"input",!0)},i:e,o:e,d(e){e&&p(n),t[11](null),r=!1,s(i)}}}function V(e,n,o){let s,{apiKey:r}=n,{options:i}=n,{placeholder:c}=n,{value:a=""}=n,{required:d=!1}=n,{pattern:u=""}=n,{onSelect:p}=n;const f=w();let m;function g(){o(4,m.value="",m),y()}function y(){""===m.value&&h(null)}function h(e){s=e&&e.text||"",f("place_changed",e)}return S((()=>{R(r,(()=>{o(8,i.types=["street_address","premise","subpremise","point_of_interest"],i);const e=new google.maps.places.Autocomplete(m,Object.assign({},i));e.addListener("place_changed",(()=>{const t=e.getPlace();(function(e){const t=i&&i.fields||["geometry"];return e.hasOwnProperty(t[0])})(t)&&(p(t),h({place:t,text:m.value}))})),f("ready"),setTimeout((()=>{m.setAttribute("autocomplete","one-time-code")}),2e3)}))})),e.$$set=e=>{o(7,n=t(t({},n),l(e))),"apiKey"in e&&o(9,r=e.apiKey),"options"in e&&o(8,i=e.options),"placeholder"in e&&o(0,c=e.placeholder),"value"in e&&o(1,a=e.value),"required"in e&&o(2,d=e.required),"pattern"in e&&o(3,u=e.pattern),"onSelect"in e&&o(10,p=e.onSelect)},e.$$.update=()=>{2&e.$$.dirty&&(s=a||"")},n=l(n),[c,a,d,u,m,y,function(e){const t=document.getElementsByClassName("pac-item").length;if("Enter"===e.key||"Tab"===e.key)if(t){document.getElementsByClassName("pac-item-selected").length||function(){const e=new KeyboardEvent("keydown",{key:"ArrowDown",code:"ArrowDown",keyCode:40});m.dispatchEvent(e)}()}else(function(e){return s!==e})(m.value)&&setTimeout(g,10);else"Escape"===e.key&&setTimeout(g,10);t&&"Enter"===e.key&&e.preventDefault()},n,i,r,p,function(e){E[e?"unshift":"push"]((()=>{m=e,o(4,m)}))}]}class H extends N{constructor(e){super(),D(this,e,V,Z,i,{apiKey:9,options:8,placeholder:0,value:1,required:2,pattern:3,onSelect:10})}}const G=(J="addressState",{update:e=>{try{window[J]=Object.assign(Object.assign({},window[J]),e)}catch(e){}},get:()=>{try{return window[J]}catch(e){return{}}}});var J;function W(e){let t,n;return{c(){t=f("p"),n=m(e[4]),h(t,"class","preorder-address-error-message")},m(e,o){u(e,t,o),d(t,n)},p(e,t){16&t&&b(n,e[4])},d(e){e&&p(t)}}}function X(e){let t,n,o,s,r,i,a,l,v,_,$,S,w,A,E;i=new H({props:{class:"location-search-input",apiKey:e[0],placeholder:"Enter your home address",onSelect:e[8],options:{componentRestrictions:{country:"us"},types:["address"],fields:["address_components","formatted_address","name","place_id","url"]}}});let x=e[4]&&W(e);return{c(){var d,u,p;t=f("div"),n=f("div"),o=f("img"),r=g(),(d=i.$$.fragment)&&d.c(),a=g(),l=f("button"),v=m(e[1]),_=g(),x&&x.c(),$=g(),S=f("div"),u=o.src,p=s="https://cdn.jsdelivr.net/gh/BasePowerCompany/preorder-booking@1.0.1/public/Base_files/map-pin.svg",c||(c=document.createElement("a")),c.href=p,u!==c.href&&h(o,"src","https://cdn.jsdelivr.net/gh/BasePowerCompany/preorder-booking@1.0.1/public/Base_files/map-pin.svg"),h(o,"alt","Map pin icon"),h(n,"class","input-address-container"),h(l,"class","submitAddressButton button secondary w-button"),h(t,"class","input-address-wrap"),h(S,"class","focus_overlay")},m(s,c){u(s,t,c),d(t,n),d(n,o),d(n,r),O(i,n,null),d(t,a),d(t,l),d(l,v),d(t,_),x&&x.m(t,null),u(s,$,c),u(s,S,c),w=!0,A||(E=y(l,"click",e[5]),A=!0)},p(e,[n]){const o={};1&n&&(o.apiKey=e[0]),28&n&&(o.onSelect=e[8]),i.$set(o),(!w||2&n)&&b(v,e[1]),e[4]?x?x.p(e,n):(x=W(e),x.c(),x.m(t,null)):x&&(x.d(1),x=null)},i(e){w||(K(i.$$.fragment,e),w=!0)},o(e){!function(e,t,n,o){if(e&&e.o){if(B.has(e))return;B.add(e),(void 0).c.push((()=>{B.delete(e),o&&(n&&e.d(1),o())})),e.o(t)}else o&&o()}(i.$$.fragment,e),w=!1},d(e){e&&p(t),I(i),x&&x.d(),e&&p($),e&&p(S),A=!1,E()}}}function Y(e,t,n){let o,{targetDisplayAddress:s}=t,{googlePublicApiKey:r}=t,{addressCtaText:i="See if my home qualifies"}=t,{onAddressSelect:c}=t,{onAddressSubmitSuccess:a}=t;w();let l=null;function d(){if(console.log("handleSubmit called with address:",l),!l)return;if(!l.postalCode||!l.houseNumber||!l.street)return void console.log("Validation failed - missing required fields:",l);const e=document.querySelector(s);e&&(e.innerHTML=l.formattedAddress),G.update({selectedAddress:l}),console.log("Calling onAddressSubmitSuccess with:",l),null==a||a(l)}S((()=>{jQuery(".input-address-container").on("click",(function(){jQuery(".focus_overlay").show(),jQuery(".input-address-container").addClass("focused"),jQuery("input.location-search-input").attr("placeholder","Enter your home address"),jQuery("button.submitAddressButton").hide()})),jQuery(".input-address-container").on("keydown",(function(){jQuery("input.location-search-input").attr("placeholder","")})),jQuery(".focus_overlay").on("click",(function(){jQuery(".focus_overlay").hide(),jQuery(".submitAddressButton").show(),jQuery(".input-address-container").removeClass("focused")}))}));return e.$$set=e=>{"targetDisplayAddress"in e&&n(6,s=e.targetDisplayAddress),"googlePublicApiKey"in e&&n(0,r=e.googlePublicApiKey),"addressCtaText"in e&&n(1,i=e.addressCtaText),"onAddressSelect"in e&&n(2,c=e.onAddressSelect),"onAddressSubmitSuccess"in e&&n(7,a=e.onAddressSubmitSuccess)},n(4,o=""),n(3,l=null),[r,i,c,l,o,d,s,a,e=>{console.log("Place selected:",e);const t=(e=>{console.log("Parsing place result:",e);const t=(e.address_components||[]).reduce((function(e,t){return t.types.forEach((function(n){e[n]=t})),e}),{});console.log("Address components by type:",t);const n=(e,n=!1)=>e in t?n?t[e].short_name:t[e].long_name:(console.log(`Missing address component: ${e}`),null),o=n("street_number")||n("subpremise")||n("premise"),s=n("route")||n("street_address")||n("premise"),r=n("postal_code")||n("postal_code_prefix"),i={title:e.name,formattedAddress:e.formatted_address,externalId:e.place_id,externalUrl:e.url,houseNumber:o,street:s,street_2:[n("floor"),n("subpremise")].filter((e=>!!e)).join(",")||null,city:n("locality")||n("sublocality")||n("sublocality_level_1")||n("neighborhood")||n("administrative_area_level_3")||n("administrative_area_level_2"),county:n("administrative_area_level_2"),stateShort:n("administrative_area_level_1",!0),stateLong:n("administrative_area_level_1"),countryCode:n("country",!0),countryLong:n("country"),postalCode:r};return console.log("Parsed result:",i),i})(e);console.log("Parsed place result:",t),c?.(t),window.blur(),n(4,o=""),n(3,l=t),d()}]}class ee extends N{constructor(e){super(),D(this,e,Y,X,i,{targetDisplayAddress:6,googlePublicApiKey:0,addressCtaText:1,onAddressSelect:2,onAddressSubmitSuccess:7})}}function te(t){let n,o,r,i,c,a,l,_,$,S,w,A,E,x,C,k,z,q,j,T,L,P,B,K,O,I,Q,D,N=(t[1][0]||"")+"",U=(t[1][1]||"")+"",M=(t[1][2]||"")+"",R=(t[1][3]||"")+"",F=(t[1][4]||"")+"",Z=(t[2]?t[0]:"Enter your zip code")+"";return{c(){n=f("div"),o=f("div"),r=f("div"),i=f("input"),c=g(),a=f("div"),l=f("div"),_=m(N),$=g(),S=f("div"),w=m(U),A=g(),E=f("div"),x=m(M),C=g(),k=f("div"),z=m(R),q=g(),j=f("div"),T=m(F),L=g(),P=f("button"),B=m(Z),O=g(),I=f("div"),h(i,"type","text"),h(i,"inputmode","numeric"),h(i,"pattern","[0-9]*"),h(i,"class","zip-search-input"),h(i,"maxlength","5"),h(l,"class","zip-box"),v(l,"filled",t[1].length>=1),h(S,"class","zip-box"),v(S,"filled",t[1].length>=2),h(E,"class","zip-box"),v(E,"filled",t[1].length>=3),h(k,"class","zip-box"),v(k,"filled",t[1].length>=4),h(j,"class","zip-box"),v(j,"filled",t[1].length>=5),h(a,"class","zip-boxes"),h(r,"class","zip-input-layout"),h(P,"class","submitZipButton button secondary w-button"),P.disabled=K=!t[2],h(o,"class","input-zip-container"),h(n,"class","input-zip-wrap"),h(I,"class","focus_overlay")},m(e,s){u(e,n,s),d(n,o),d(o,r),d(r,i),d(r,c),d(r,a),d(a,l),d(l,_),d(a,$),d(a,S),d(S,w),d(a,A),d(a,E),d(E,x),d(a,C),d(a,k),d(k,z),d(a,q),d(a,j),d(j,T),d(o,L),d(o,P),d(P,B),u(e,O,s),u(e,I,s),Q||(D=[y(i,"input",t[3]),y(i,"keydown",t[6]),y(P,"click",t[4])],Q=!0)},p(e,[t]){2&t&&N!==(N=(e[1][0]||"")+"")&&b(_,N),2&t&&v(l,"filled",e[1].length>=1),2&t&&U!==(U=(e[1][1]||"")+"")&&b(w,U),2&t&&v(S,"filled",e[1].length>=2),2&t&&M!==(M=(e[1][2]||"")+"")&&b(x,M),2&t&&v(E,"filled",e[1].length>=3),2&t&&R!==(R=(e[1][3]||"")+"")&&b(z,R),2&t&&v(k,"filled",e[1].length>=4),2&t&&F!==(F=(e[1][4]||"")+"")&&b(T,F),2&t&&v(j,"filled",e[1].length>=5),5&t&&Z!==(Z=(e[2]?e[0]:"Enter your zip code")+"")&&b(B,Z),4&t&&K!==(K=!e[2])&&(P.disabled=K)},i:e,o:e,d(e){e&&p(n),e&&p(O),e&&p(I),Q=!1,s(D)}}}function ne(e,t,n){let o,{addressCtaText:s="See if I qualify"}=t,{onAddressSubmitSuccess:r=()=>{}}=t;S((()=>{const e=document.querySelector(".input-zip-container"),t=document.querySelector(".focus_overlay"),n=document.querySelector(".zip-search-input");e&&t&&(e.addEventListener("click",(()=>{5!==i.length&&(t.style.display="block",e.classList.add("focused")),null==n||n.focus()})),t.addEventListener("click",(()=>{t.style.display="none",e.classList.remove("focused")})))}));let i="";const c=()=>{if(!i)return;if(5!==i.length)return;const e={title:"",formattedAddress:i,externalId:"",externalUrl:"",houseNumber:"",street:"",street_2:"",city:"",county:"",stateShort:"",stateLong:"",countryCode:"US",countryLong:"United States",postalCode:i};G.update({selectedAddress:e}),null==r||r(e)};return e.$$set=e=>{"addressCtaText"in e&&n(0,s=e.addressCtaText),"onAddressSubmitSuccess"in e&&n(5,r=e.onAddressSubmitSuccess)},e.$$.update=()=>{2&e.$$.dirty&&n(2,o=5===i.length)},[s,i,o,e=>{const t=e.target,o=t.value.replace(/\D/g,"");o.length>5?t.value=o.slice(0,5):t.value=o,n(1,i=t.value)},c,r,e=>"Enter"===e.key&&o&&c()]}class oe extends N{constructor(e){super(),D(this,e,ne,te,i,{addressCtaText:0,onAddressSubmitSuccess:5})}}const se={initialize:e=>{const{targetElAddressInput:t=document.getElementById("hero-address-entry"),googlePublicApiKey:n,onAddressSelect:o,onAddressSubmitSuccess:s,addressCtaText:r,querySelectorClickToOpenForm:i}=e,c=new ee({target:t,props:{googlePublicApiKey:n,onAddressSelect:o,onAddressSubmitSuccess:s,addressCtaText:"See if my home qualifies",targetDisplayAddress:"#hero-address-entry"}});if(i&&t){document.querySelectorAll(i).forEach((e=>{e.addEventListener("click",(()=>{t.scrollIntoView({behavior:"smooth",block:"center"});const e=t.querySelector(".input-address-container");e&&e.dispatchEvent(new MouseEvent("click",{bubbles:!0}));const n=t.querySelector("input");n&&n.focus()}))}))}return c},initializeZipCode:e=>{const{targetElAddressInput:t=document.getElementById("zip-code-entry"),onAddressSubmitSuccess:n,addressCtaText:o,querySelectorClickToOpenForm:s}=e,r=new oe({target:t,props:{onAddressSubmitSuccess:n,addressCtaText:o}});if(s&&t){document.querySelectorAll(s).forEach((e=>{e.addEventListener("click",(()=>{const e=t.querySelector("input");if(e){e.focus();const n=t.querySelector(".input-zip-container");n&&n.classList.add("focused")}}))}))}return r}};window.BasePreorderApp=se,document.addEventListener("DOMContentLoaded",(()=>{document.getElementById("zip-code-entry")&&se.initializeZipCode({targetElAddressInput:document.getElementById("zip-code-entry"),querySelectorClickToOpenForm:'[data-preorder="open"]',addressCtaText:"Check availability",googleSheetConfig:{zipsCsvUrl:"https://bpc-web-static-files.s3.us-east-2.amazonaws.com/deregulated-zips.csv"},onAddressSubmitSuccess:async(e,t,n)=>{const o=(null==n?void 0:n.servingNow)||"no",s=new URL("yes"===o?"/available-now":"preorder"===o?"/available-soon":"/not-available",window.location.origin),r=new URLSearchParams(window.location.search),i={zip:(null==e?void 0:e.postalCode)||"",gclid:r.get("gclid"),utm_source:r.get("utm_source"),utm_medium:r.get("utm_medium"),utm_campaign:r.get("utm_campaign"),utm_term:r.get("utm_term"),utm_content:r.get("utm_content"),referrer_name:r.get("referrer_name")},c={};Object.entries(i).forEach((([e,t])=>{t&&(c[e]=t)})),s.search=new URLSearchParams(c).toString(),window.location.href=s.toString()}})}))})); + +(function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document); +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +})((function () { 'use strict'; + + function noop() { } + const identity = x => x; + function assign(tar, src) { + // @ts-ignore + for (const k in src) + tar[k] = src[k]; + return tar; + } + function add_location(element, file, line, column, char) { + element.__svelte_meta = { + loc: { file, line, column, char } + }; + } + function run(fn) { + return fn(); + } + function blank_object() { + return Object.create(null); + } + function run_all(fns) { + fns.forEach(run); + } + function is_function(thing) { + return typeof thing === 'function'; + } + function safe_not_equal(a, b) { + return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); + } + let src_url_equal_anchor; + function src_url_equal(element_src, url) { + if (!src_url_equal_anchor) { + src_url_equal_anchor = document.createElement('a'); + } + src_url_equal_anchor.href = url; + return element_src === src_url_equal_anchor.href; + } + function is_empty(obj) { + return Object.keys(obj).length === 0; + } + function exclude_internal_props(props) { + const result = {}; + for (const k in props) + if (k[0] !== '$') + result[k] = props[k]; + return result; + } + + const globals = (typeof window !== 'undefined' + ? window + : typeof globalThis !== 'undefined' + ? globalThis + : global); + function append(target, node) { + target.appendChild(node); + } + function insert(target, node, anchor) { + target.insertBefore(node, anchor || null); + } + function detach(node) { + if (node.parentNode) { + node.parentNode.removeChild(node); + } + } + function element(name) { + return document.createElement(name); + } + function text(data) { + return document.createTextNode(data); + } + function space() { + return text(' '); + } + function listen(node, event, handler, options) { + node.addEventListener(event, handler, options); + return () => node.removeEventListener(event, handler, options); + } + function attr(node, attribute, value) { + if (value == null) + node.removeAttribute(attribute); + else if (node.getAttribute(attribute) !== value) + node.setAttribute(attribute, value); + } + function children(element) { + return Array.from(element.childNodes); + } + function toggle_class(element, name, toggle) { + element.classList[toggle ? 'add' : 'remove'](name); + } + function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) { + const e = document.createEvent('CustomEvent'); + e.initCustomEvent(type, bubbles, cancelable, detail); + return e; + } + + let current_component; + function set_current_component(component) { + current_component = component; + } + function get_current_component() { + if (!current_component) + throw new Error('Function called outside component initialization'); + return current_component; + } + /** + * The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM. + * It must be called during the component's initialisation (but doesn't need to live *inside* the component; + * it can be called from an external module). + * + * `onMount` does not run inside a [server-side component](/docs#run-time-server-side-component-api). + * + * https://svelte.dev/docs#run-time-svelte-onmount + */ + function onMount(fn) { + get_current_component().$$.on_mount.push(fn); + } + /** + * Schedules a callback to run immediately before the component is unmounted. + * + * Out of `onMount`, `beforeUpdate`, `afterUpdate` and `onDestroy`, this is the + * only one that runs inside a server-side component. + * + * https://svelte.dev/docs#run-time-svelte-ondestroy + */ + function onDestroy(fn) { + get_current_component().$$.on_destroy.push(fn); + } + /** + * Creates an event dispatcher that can be used to dispatch [component events](/docs#template-syntax-component-directives-on-eventname). + * Event dispatchers are functions that can take two arguments: `name` and `detail`. + * + * Component events created with `createEventDispatcher` create a + * [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent). + * These events do not [bubble](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture). + * The `detail` argument corresponds to the [CustomEvent.detail](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail) + * property and can contain any type of data. + * + * https://svelte.dev/docs#run-time-svelte-createeventdispatcher + */ + function createEventDispatcher() { + const component = get_current_component(); + return (type, detail, { cancelable = false } = {}) => { + const callbacks = component.$$.callbacks[type]; + if (callbacks) { + // TODO are there situations where events could be dispatched + // in a server (non-DOM) environment? + const event = custom_event(type, detail, { cancelable }); + callbacks.slice().forEach(fn => { + fn.call(component, event); + }); + return !event.defaultPrevented; + } + return true; + }; + } + + const dirty_components = []; + const binding_callbacks = []; + let render_callbacks = []; + const flush_callbacks = []; + const resolved_promise = /* @__PURE__ */ Promise.resolve(); + let update_scheduled = false; + function schedule_update() { + if (!update_scheduled) { + update_scheduled = true; + resolved_promise.then(flush); + } + } + function add_render_callback(fn) { + render_callbacks.push(fn); + } + // flush() calls callbacks in this order: + // 1. All beforeUpdate callbacks, in order: parents before children + // 2. All bind:this callbacks, in reverse order: children before parents. + // 3. All afterUpdate callbacks, in order: parents before children. EXCEPT + // for afterUpdates called during the initial onMount, which are called in + // reverse order: children before parents. + // Since callbacks might update component values, which could trigger another + // call to flush(), the following steps guard against this: + // 1. During beforeUpdate, any updated components will be added to the + // dirty_components array and will cause a reentrant call to flush(). Because + // the flush index is kept outside the function, the reentrant call will pick + // up where the earlier call left off and go through all dirty components. The + // current_component value is saved and restored so that the reentrant call will + // not interfere with the "parent" flush() call. + // 2. bind:this callbacks cannot trigger new flush() calls. + // 3. During afterUpdate, any updated components will NOT have their afterUpdate + // callback called a second time; the seen_callbacks set, outside the flush() + // function, guarantees this behavior. + const seen_callbacks = new Set(); + let flushidx = 0; // Do *not* move this inside the flush() function + function flush() { + // Do not reenter flush while dirty components are updated, as this can + // result in an infinite loop. Instead, let the inner flush handle it. + // Reentrancy is ok afterwards for bindings etc. + if (flushidx !== 0) { + return; + } + const saved_component = current_component; + do { + // first, call beforeUpdate functions + // and update components + try { + while (flushidx < dirty_components.length) { + const component = dirty_components[flushidx]; + flushidx++; + set_current_component(component); + update(component.$$); + } + } + catch (e) { + // reset dirty state to not end up in a deadlocked state and then rethrow + dirty_components.length = 0; + flushidx = 0; + throw e; + } + set_current_component(null); + dirty_components.length = 0; + flushidx = 0; + while (binding_callbacks.length) + binding_callbacks.pop()(); + // then, once components are updated, call + // afterUpdate functions. This may cause + // subsequent updates... + for (let i = 0; i < render_callbacks.length; i += 1) { + const callback = render_callbacks[i]; + if (!seen_callbacks.has(callback)) { + // ...so guard against infinite loops + seen_callbacks.add(callback); + callback(); + } + } + render_callbacks.length = 0; + } while (dirty_components.length); + while (flush_callbacks.length) { + flush_callbacks.pop()(); + } + update_scheduled = false; + seen_callbacks.clear(); + set_current_component(saved_component); + } + function update($$) { + if ($$.fragment !== null) { + $$.update(); + run_all($$.before_update); + const dirty = $$.dirty; + $$.dirty = [-1]; + $$.fragment && $$.fragment.p($$.ctx, dirty); + $$.after_update.forEach(add_render_callback); + } + } + /** + * Useful for example to execute remaining `afterUpdate` callbacks before executing `destroy`. + */ + function flush_render_callbacks(fns) { + const filtered = []; + const targets = []; + render_callbacks.forEach((c) => fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c)); + targets.forEach((c) => c()); + render_callbacks = filtered; + } + const outroing = new Set(); + let outros; + function transition_in(block, local) { + if (block && block.i) { + outroing.delete(block); + block.i(local); + } + } + function transition_out(block, local, detach, callback) { + if (block && block.o) { + if (outroing.has(block)) + return; + outroing.add(block); + outros.c.push(() => { + outroing.delete(block); + if (callback) { + if (detach) + block.d(1); + callback(); + } + }); + block.o(local); + } + else if (callback) { + callback(); + } + } + function create_component(block) { + block && block.c(); + } + function mount_component(component, target, anchor, customElement) { + const { fragment, after_update } = component.$$; + fragment && fragment.m(target, anchor); + if (!customElement) { + // onMount happens before the initial afterUpdate + add_render_callback(() => { + const new_on_destroy = component.$$.on_mount.map(run).filter(is_function); + // if the component was destroyed immediately + // it will update the `$$.on_destroy` reference to `null`. + // the destructured on_destroy may still reference to the old array + if (component.$$.on_destroy) { + component.$$.on_destroy.push(...new_on_destroy); + } + else { + // Edge case - component was destroyed immediately, + // most likely as a result of a binding initialising + run_all(new_on_destroy); + } + component.$$.on_mount = []; + }); + } + after_update.forEach(add_render_callback); + } + function destroy_component(component, detaching) { + const $$ = component.$$; + if ($$.fragment !== null) { + flush_render_callbacks($$.after_update); + run_all($$.on_destroy); + $$.fragment && $$.fragment.d(detaching); + // TODO null out other refs, including component.$$ (but need to + // preserve final state?) + $$.on_destroy = $$.fragment = null; + $$.ctx = []; + } + } + function make_dirty(component, i) { + if (component.$$.dirty[0] === -1) { + dirty_components.push(component); + schedule_update(); + component.$$.dirty.fill(0); + } + component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31)); + } + function init(component, options, instance, create_fragment, not_equal, props, append_styles, dirty = [-1]) { + const parent_component = current_component; + set_current_component(component); + const $$ = component.$$ = { + fragment: null, + ctx: [], + // state + props, + update: noop, + not_equal, + bound: blank_object(), + // lifecycle + on_mount: [], + on_destroy: [], + on_disconnect: [], + before_update: [], + after_update: [], + context: new Map(options.context || (parent_component ? parent_component.$$.context : [])), + // everything else + callbacks: blank_object(), + dirty, + skip_bound: false, + root: options.target || parent_component.$$.root + }; + append_styles && append_styles($$.root); + let ready = false; + $$.ctx = instance + ? instance(component, options.props || {}, (i, ret, ...rest) => { + const value = rest.length ? rest[0] : ret; + if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) { + if (!$$.skip_bound && $$.bound[i]) + $$.bound[i](value); + if (ready) + make_dirty(component, i); + } + return ret; + }) + : []; + $$.update(); + ready = true; + run_all($$.before_update); + // `false` as a special case of no DOM component + $$.fragment = create_fragment ? create_fragment($$.ctx) : false; + if (options.target) { + if (options.hydrate) { + const nodes = children(options.target); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + $$.fragment && $$.fragment.l(nodes); + nodes.forEach(detach); + } + else { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + $$.fragment && $$.fragment.c(); + } + if (options.intro) + transition_in(component.$$.fragment); + mount_component(component, options.target, options.anchor, options.customElement); + flush(); + } + set_current_component(parent_component); + } + /** + * Base class for Svelte components. Used when dev=false. + */ + class SvelteComponent { + $destroy() { + destroy_component(this, 1); + this.$destroy = noop; + } + $on(type, callback) { + if (!is_function(callback)) { + return noop; + } + const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = [])); + callbacks.push(callback); + return () => { + const index = callbacks.indexOf(callback); + if (index !== -1) + callbacks.splice(index, 1); + }; + } + $set($$props) { + if (this.$$set && !is_empty($$props)) { + this.$$.skip_bound = true; + this.$$set($$props); + this.$$.skip_bound = false; + } + } + } + + function dispatch_dev(type, detail) { + document.dispatchEvent(custom_event(type, Object.assign({ version: '3.59.2' }, detail), { bubbles: true })); + } + function append_dev(target, node) { + dispatch_dev('SvelteDOMInsert', { target, node }); + append(target, node); + } + function insert_dev(target, node, anchor) { + dispatch_dev('SvelteDOMInsert', { target, node, anchor }); + insert(target, node, anchor); + } + function detach_dev(node) { + dispatch_dev('SvelteDOMRemove', { node }); + detach(node); + } + function listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation, has_stop_immediate_propagation) { + const modifiers = options === true ? ['capture'] : options ? Array.from(Object.keys(options)) : []; + if (has_prevent_default) + modifiers.push('preventDefault'); + if (has_stop_propagation) + modifiers.push('stopPropagation'); + if (has_stop_immediate_propagation) + modifiers.push('stopImmediatePropagation'); + dispatch_dev('SvelteDOMAddEventListener', { node, event, handler, modifiers }); + const dispose = listen(node, event, handler, options); + return () => { + dispatch_dev('SvelteDOMRemoveEventListener', { node, event, handler, modifiers }); + dispose(); + }; + } + function attr_dev(node, attribute, value) { + attr(node, attribute, value); + if (value == null) + dispatch_dev('SvelteDOMRemoveAttribute', { node, attribute }); + else + dispatch_dev('SvelteDOMSetAttribute', { node, attribute, value }); + } + function prop_dev(node, property, value) { + node[property] = value; + dispatch_dev('SvelteDOMSetProperty', { node, property, value }); + } + function set_data_dev(text, data) { + data = '' + data; + if (text.data === data) + return; + dispatch_dev('SvelteDOMSetData', { node: text, data }); + text.data = data; + } + function validate_slots(name, slot, keys) { + for (const slot_key of Object.keys(slot)) { + if (!~keys.indexOf(slot_key)) { + console.warn(`<${name}> received an unexpected slot "${slot_key}".`); + } + } + } + /** + * Base class for Svelte components with some minor dev-enhancements. Used when dev=true. + */ + class SvelteComponentDev extends SvelteComponent { + constructor(options) { + if (!options || (!options.target && !options.$$inline)) { + throw new Error("'target' is a required option"); + } + super(); + } + $destroy() { + super.$destroy(); + this.$destroy = () => { + console.warn('Component was already destroyed'); // eslint-disable-line no-console + }; + } + $capture_state() { } + $inject_state() { } + } + + let isLoadingLibrary = false; + /** + * The list of callbacks, one from each GooglePlacesAutocomplete instance that requested the library before the library + * had finished loading. + */ + const callbacks = []; + function hasLoadedLibrary() { + return window.google && window.google.maps && window.google.maps.places; + } + /** + * Load the Google Places library and notify the calling code (if given a callback) once the library is ready. + * + * This supports three scenarios: + * 1. The library hasn't been loaded yet and isn't in the process of loading yet. + * 2. The library hasn't been loaded yet but is already in the process of loading. + * 3. The library has already been loaded. + * + * In scenarios 1 and 2, any callbacks that have been provided (which could be multiple, if multiple + * GooglePlacesAutocomplete instances are in use) will be called when the library finishes loading. + * + * In scenario 3, the callback will be called immediately. + * + * @param apiKey Your Google Places API Key + * @param callback A callback (if you want to be notified when the library is available for use) + */ + function loadGooglePlacesLibrary(apiKey, callback) { + if (hasLoadedLibrary()) { + callback(); + return; + } + callback && callbacks.push(callback); + if (isLoadingLibrary) { + return; + } + isLoadingLibrary = true; + const element = document.createElement("script"); + element.async = true; + element.defer = true; + element.onload = onLibraryLoaded; + element.src = `https://maps.googleapis.com/maps/api/js?key=${encodeURIComponent(apiKey)}&libraries=places`; + element.type = "text/javascript"; + document.head.appendChild(element); + } + function onLibraryLoaded() { + isLoadingLibrary = false; + let callback; + while ((callback = callbacks.pop())) { + callback(); + } + } + + /* src/location-input/googlePlace/GooglePlaceAutocomplete.svelte generated by Svelte v3.59.2 */ + const file$2 = "src/location-input/googlePlace/GooglePlaceAutocomplete.svelte"; + + function create_fragment$2(ctx) { + let input; + let input_class_value; + let mounted; + let dispose; + + const block = { + c: function create() { + input = element("input"); + attr_dev(input, "class", input_class_value = /*$$props*/ ctx[7].class); + attr_dev(input, "placeholder", /*placeholder*/ ctx[0]); + input.value = /*value*/ ctx[1]; + input.required = /*required*/ ctx[2]; + attr_dev(input, "pattern", /*pattern*/ ctx[3]); + toggle_class(input, "input", true); + add_location(input, file$2, 93, 0, 3467); + }, + l: function claim(nodes) { + throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); + }, + m: function mount(target, anchor) { + insert_dev(target, input, anchor); + /*input_binding*/ ctx[11](input); + + if (!mounted) { + dispose = [ + listen_dev(input, "change", /*onChange*/ ctx[5], false, false, false, false), + listen_dev(input, "keydown", /*onKeyDown*/ ctx[6], false, false, false, false) + ]; + + mounted = true; + } + }, + p: function update(ctx, [dirty]) { + if (dirty & /*$$props*/ 128 && input_class_value !== (input_class_value = /*$$props*/ ctx[7].class)) { + attr_dev(input, "class", input_class_value); + } + + if (dirty & /*placeholder*/ 1) { + attr_dev(input, "placeholder", /*placeholder*/ ctx[0]); + } + + if (dirty & /*value*/ 2 && input.value !== /*value*/ ctx[1]) { + prop_dev(input, "value", /*value*/ ctx[1]); + } + + if (dirty & /*required*/ 4) { + prop_dev(input, "required", /*required*/ ctx[2]); + } + + if (dirty & /*pattern*/ 8) { + attr_dev(input, "pattern", /*pattern*/ ctx[3]); + } + + if (dirty & /*$$props*/ 128) { + toggle_class(input, "input", true); + } + }, + i: noop, + o: noop, + d: function destroy(detaching) { + if (detaching) detach_dev(input); + /*input_binding*/ ctx[11](null); + mounted = false; + run_all(dispose); + } + }; + + dispatch_dev("SvelteRegisterBlock", { + block, + id: create_fragment$2.name, + type: "component", + source: "", + ctx + }); + + return block; + } + + function instance$2($$self, $$props, $$invalidate) { + let selectedLocationName; + let { $$slots: slots = {}, $$scope } = $$props; + validate_slots('GooglePlaceAutocomplete', slots, []); + let { apiKey } = $$props; + let { options = undefined } = $$props; + let { placeholder = undefined } = $$props; + let { value = "" } = $$props; + let { required = false } = $$props; + let { pattern = "" } = $$props; + let { onSelect } = $$props; + const dispatch = createEventDispatcher(); + let inputField; + + onMount(() => { + loadGooglePlacesLibrary(apiKey, () => { + $$invalidate(8, options["types"] = ["street_address", "premise", "subpremise", "point_of_interest"], options); + const autocomplete = new google.maps.places.Autocomplete(inputField, Object.assign({}, options)); + + autocomplete.addListener("place_changed", () => { + const place = autocomplete.getPlace(); + + // There are circumstances where the place_changed event fires, but we + // were NOT given location data. I only want to propagate the event if we + // truly received location data from Google. + // See the `Type something, no suggestions, hit Enter` test case. + if (hasLocationData(place)) { + onSelect(place); + setSelectedLocation({ place, text: inputField.value }); + } + }); + + dispatch("ready"); + + setTimeout( + () => { + inputField.setAttribute("autocomplete", "one-time-code"); + }, + 2000 + ); + }); + }); + + function emptyLocationField() { + $$invalidate(4, inputField.value = "", inputField); + onChange(); + } + + function hasLocationData(place) { + const fieldsToLookFor = options && options.fields || ["geometry"]; + return place.hasOwnProperty(fieldsToLookFor[0]); + } + + function onChange() { + if (inputField.value === "") { + setSelectedLocation(null); + } + } + + function onKeyDown(event) { + const suggestionsAreVisible = document.getElementsByClassName("pac-item").length; + + if (event.key === "Enter" || event.key === "Tab") { + if (suggestionsAreVisible) { + const isSuggestionSelected = document.getElementsByClassName("pac-item-selected").length; + + if (!isSuggestionSelected) { + selectFirstSuggestion(); + } + } else if (doesNotMatchSelectedLocation(inputField.value)) { + setTimeout(emptyLocationField, 10); + } + } else if (event.key === "Escape") { + setTimeout(emptyLocationField, 10); + } + + if (suggestionsAreVisible) { + if (event.key === "Enter") { + /* When suggestions are visible, don't let an 'Enter' submit a form (since + * the user is interacting with the list of suggestions at the time, not + * expecting their actions to affect the form as a whole). */ + event.preventDefault(); + } + } + } + + function selectFirstSuggestion() { + // Simulate the 'down arrow' key in order to select the first suggestion: + // https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Creating_and_triggering_events + const simulatedEvent = new KeyboardEvent("keydown", + { + key: "ArrowDown", + code: "ArrowDown", + keyCode: 40 + }); + + inputField.dispatchEvent(simulatedEvent); + } + + function setSelectedLocation(data) { + selectedLocationName = data && data.text || ""; + dispatch("place_changed", data); + } + + function doesNotMatchSelectedLocation(value) { + return selectedLocationName !== value; + } + + $$self.$$.on_mount.push(function () { + if (apiKey === undefined && !('apiKey' in $$props || $$self.$$.bound[$$self.$$.props['apiKey']])) { + console.warn(" was created without expected prop 'apiKey'"); + } + + if (onSelect === undefined && !('onSelect' in $$props || $$self.$$.bound[$$self.$$.props['onSelect']])) { + console.warn(" was created without expected prop 'onSelect'"); + } + }); + + function input_binding($$value) { + binding_callbacks[$$value ? 'unshift' : 'push'](() => { + inputField = $$value; + $$invalidate(4, inputField); + }); + } + + $$self.$$set = $$new_props => { + $$invalidate(7, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props))); + if ('apiKey' in $$new_props) $$invalidate(9, apiKey = $$new_props.apiKey); + if ('options' in $$new_props) $$invalidate(8, options = $$new_props.options); + if ('placeholder' in $$new_props) $$invalidate(0, placeholder = $$new_props.placeholder); + if ('value' in $$new_props) $$invalidate(1, value = $$new_props.value); + if ('required' in $$new_props) $$invalidate(2, required = $$new_props.required); + if ('pattern' in $$new_props) $$invalidate(3, pattern = $$new_props.pattern); + if ('onSelect' in $$new_props) $$invalidate(10, onSelect = $$new_props.onSelect); + }; + + $$self.$capture_state = () => ({ + loadGooglePlacesLibrary, + createEventDispatcher, + onMount, + apiKey, + options, + placeholder, + value, + required, + pattern, + onSelect, + dispatch, + inputField, + emptyLocationField, + hasLocationData, + onChange, + onKeyDown, + selectFirstSuggestion, + setSelectedLocation, + doesNotMatchSelectedLocation, + selectedLocationName + }); + + $$self.$inject_state = $$new_props => { + $$invalidate(7, $$props = assign(assign({}, $$props), $$new_props)); + if ('apiKey' in $$props) $$invalidate(9, apiKey = $$new_props.apiKey); + if ('options' in $$props) $$invalidate(8, options = $$new_props.options); + if ('placeholder' in $$props) $$invalidate(0, placeholder = $$new_props.placeholder); + if ('value' in $$props) $$invalidate(1, value = $$new_props.value); + if ('required' in $$props) $$invalidate(2, required = $$new_props.required); + if ('pattern' in $$props) $$invalidate(3, pattern = $$new_props.pattern); + if ('onSelect' in $$props) $$invalidate(10, onSelect = $$new_props.onSelect); + if ('inputField' in $$props) $$invalidate(4, inputField = $$new_props.inputField); + if ('selectedLocationName' in $$props) selectedLocationName = $$new_props.selectedLocationName; + }; + + if ($$props && "$$inject" in $$props) { + $$self.$inject_state($$props.$$inject); + } + + $$self.$$.update = () => { + if ($$self.$$.dirty & /*value*/ 2) { + selectedLocationName = value || ""; + } + }; + + $$props = exclude_internal_props($$props); + + return [ + placeholder, + value, + required, + pattern, + inputField, + onChange, + onKeyDown, + $$props, + options, + apiKey, + onSelect, + input_binding + ]; + } + + class GooglePlaceAutocomplete extends SvelteComponentDev { + constructor(options) { + super(options); + + init(this, options, instance$2, create_fragment$2, safe_not_equal, { + apiKey: 9, + options: 8, + placeholder: 0, + value: 1, + required: 2, + pattern: 3, + onSelect: 10 + }); + + dispatch_dev("SvelteRegisterComponent", { + component: this, + tagName: "GooglePlaceAutocomplete", + options, + id: create_fragment$2.name + }); + } + + get apiKey() { + throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); + } + + set apiKey(value) { + throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); + } + + get options() { + throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); + } + + set options(value) { + throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); + } + + get placeholder() { + throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); + } + + set placeholder(value) { + throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); + } + + get value() { + throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); + } + + set value(value) { + throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); + } + + get required() { + throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); + } + + set required(value) { + throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); + } + + get pattern() { + throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); + } + + set pattern(value) { + throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); + } + + get onSelect() { + throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); + } + + set onSelect(value) { + throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); + } + } + + const parsePlaceResult = (place) => { + console.log("Parsing place result:", place); + const addressComponentsByType = (place.address_components || []).reduce(function (acc, data) { + data.types.forEach(function (type) { + acc[type] = data; + }); + return acc; + }, {}); + console.log("Address components by type:", addressComponentsByType); + const placeGet = (key, short = false) => { + if (!(key in addressComponentsByType)) { + console.log(`Missing address component: ${key}`); + return null; + } + return short + ? addressComponentsByType[key].short_name + : addressComponentsByType[key].long_name; + }; + // Try different component types for street number + const houseNumber = placeGet("street_number") || placeGet("subpremise") || placeGet("premise"); + // Try different component types for street + const street = placeGet("route") || placeGet("street_address") || placeGet("premise"); + // Try different component types for postal code + const postalCode = placeGet("postal_code") || placeGet("postal_code_prefix"); + const result = { + title: place.name, + formattedAddress: place.formatted_address, + externalId: place.place_id, + externalUrl: place.url, + houseNumber, + street, + street_2: [placeGet("floor"), placeGet("subpremise")] + .filter((item) => !!item) + .join(",") || null, + city: placeGet("locality") || + placeGet("sublocality") || + placeGet("sublocality_level_1") || + placeGet("neighborhood") || + placeGet("administrative_area_level_3") || + placeGet("administrative_area_level_2"), + county: placeGet("administrative_area_level_2"), + stateShort: placeGet("administrative_area_level_1", true), + stateLong: placeGet("administrative_area_level_1"), + countryCode: placeGet("country", true), + countryLong: placeGet("country"), + postalCode, + }; + console.log("Parsed result:", result); + return result; + }; + + const displayNone = (el) => { + el.style.display = "none"; + }; + const displayBlock = (el, display = "block") => { + el.style.display = display; + }; + function fadeIn(element, display = "block") { + let op = 0.1; // initial opacity + element.style.opacity = "0"; + element.style.display = display; + const timer = setInterval(function () { + if (op >= 1) { + clearInterval(timer); + } + element.style.opacity = `${op}`; + element.style.filter = "alpha(opacity=" + op * 100 + ")"; + op += op * 0.3; + }, 1); + } + function fadeOut(element) { + let op = 1; // initial opacity + const timer = setInterval(function () { + if (op <= 0.1) { + clearInterval(timer); + element.style.display = "none"; + } + element.style.opacity = `${op}`; + element.style.filter = "alpha(opacity=" + op * 100 + ")"; + op -= op * 0.3; + }, 1); + } + + // exchanging data with initialized HS form is hard, creating some window vars here + const createWindowState = (key) => ({ + update: (data) => { + try { + window[key] = Object.assign(Object.assign({}, window[key]), data); + } + catch (e) { } + }, + get: () => { + try { + return window[key]; + } + catch (_a) { + return {}; + } + }, + }); + const addressState = createWindowState("addressState"); + const windowVars = { + hubspotAddressData: null, + }; + + function fade(node, { delay = 0, duration = 400, easing = identity } = {}) { + const o = +getComputedStyle(node).opacity; + return { + delay, + duration, + easing, + css: t => `opacity: ${t * o}` + }; + } + + /* src/location-input/LocationInput.svelte generated by Svelte v3.59.2 */ + + const { console: console_1 } = globals; + const file$1 = "src/location-input/LocationInput.svelte"; + + // (121:2) {#if inputErrorMessage} + function create_if_block(ctx) { + let p; + let t; + + const block = { + c: function create() { + p = element("p"); + t = text(/*inputErrorMessage*/ ctx[4]); + attr_dev(p, "class", "preorder-address-error-message"); + add_location(p, file$1, 121, 4, 4317); + }, + m: function mount(target, anchor) { + insert_dev(target, p, anchor); + append_dev(p, t); + }, + p: function update(ctx, dirty) { + if (dirty & /*inputErrorMessage*/ 16) set_data_dev(t, /*inputErrorMessage*/ ctx[4]); + }, + d: function destroy(detaching) { + if (detaching) detach_dev(p); + } + }; + + dispatch_dev("SvelteRegisterBlock", { + block, + id: create_if_block.name, + type: "if", + source: "(121:2) {#if inputErrorMessage}", + ctx + }); + + return block; + } + + function create_fragment$1(ctx) { + let div1; + let div0; + let img; + let img_src_value; + let t0; + let googleplaceautocomplete; + let t1; + let button; + let t2; + let t3; + let t4; + let div2; + let current; + let mounted; + let dispose; + + googleplaceautocomplete = new GooglePlaceAutocomplete({ + props: { + class: "location-search-input", + apiKey: /*googlePublicApiKey*/ ctx[0], + placeholder: "Enter home address", + onSelect: /*func*/ ctx[8], + options: { + componentRestrictions: { country: "us" }, + types: ["address"], + fields: ["address_components", "formatted_address", "name", "place_id", "url"] + } + }, + $$inline: true + }); + + let if_block = /*inputErrorMessage*/ ctx[4] && create_if_block(ctx); + + const block = { + c: function create() { + div1 = element("div"); + div0 = element("div"); + img = element("img"); + t0 = space(); + create_component(googleplaceautocomplete.$$.fragment); + t1 = space(); + button = element("button"); + t2 = text(/*addressCtaText*/ ctx[1]); + t3 = space(); + if (if_block) if_block.c(); + t4 = space(); + div2 = element("div"); + if (!src_url_equal(img.src, img_src_value = "https://cdn.jsdelivr.net/gh/BasePowerCompany/preorder-booking@1.0.1/public/Base_files/map-pin.svg")) attr_dev(img, "src", img_src_value); + attr_dev(img, "alt", "Map pin icon"); + add_location(img, file$1, 91, 4, 3338); + attr_dev(div0, "class", "input-address-container"); + add_location(div0, file$1, 90, 2, 3296); + attr_dev(button, "class", "submitAddressButton button secondary w-button"); + add_location(button, file$1, 117, 2, 4167); + attr_dev(div1, "class", "input-address-wrap"); + add_location(div1, file$1, 89, 0, 3261); + attr_dev(div2, "class", "focus_overlay"); + add_location(div2, file$1, 126, 0, 4410); + }, + l: function claim(nodes) { + throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); + }, + m: function mount(target, anchor) { + insert_dev(target, div1, anchor); + append_dev(div1, div0); + append_dev(div0, img); + append_dev(div0, t0); + mount_component(googleplaceautocomplete, div0, null); + append_dev(div1, t1); + append_dev(div1, button); + append_dev(button, t2); + append_dev(div1, t3); + if (if_block) if_block.m(div1, null); + insert_dev(target, t4, anchor); + insert_dev(target, div2, anchor); + current = true; + + if (!mounted) { + dispose = listen_dev(button, "click", /*handleSubmit*/ ctx[5], false, false, false, false); + mounted = true; + } + }, + p: function update(ctx, [dirty]) { + const googleplaceautocomplete_changes = {}; + if (dirty & /*googlePublicApiKey*/ 1) googleplaceautocomplete_changes.apiKey = /*googlePublicApiKey*/ ctx[0]; + if (dirty & /*onAddressSelect, inputErrorMessage, selectedAddress*/ 28) googleplaceautocomplete_changes.onSelect = /*func*/ ctx[8]; + googleplaceautocomplete.$set(googleplaceautocomplete_changes); + if (!current || dirty & /*addressCtaText*/ 2) set_data_dev(t2, /*addressCtaText*/ ctx[1]); + + if (/*inputErrorMessage*/ ctx[4]) { + if (if_block) { + if_block.p(ctx, dirty); + } else { + if_block = create_if_block(ctx); + if_block.c(); + if_block.m(div1, null); + } + } else if (if_block) { + if_block.d(1); + if_block = null; + } + }, + i: function intro(local) { + if (current) return; + transition_in(googleplaceautocomplete.$$.fragment, local); + current = true; + }, + o: function outro(local) { + transition_out(googleplaceautocomplete.$$.fragment, local); + current = false; + }, + d: function destroy(detaching) { + if (detaching) detach_dev(div1); + destroy_component(googleplaceautocomplete); + if (if_block) if_block.d(); + if (detaching) detach_dev(t4); + if (detaching) detach_dev(div2); + mounted = false; + dispose(); + } + }; + + dispatch_dev("SvelteRegisterBlock", { + block, + id: create_fragment$1.name, + type: "component", + source: "", + ctx + }); + + return block; + } + + function instance$1($$self, $$props, $$invalidate) { + let inputErrorMessage; + let { $$slots: slots = {}, $$scope } = $$props; + validate_slots('LocationInput', slots, []); + let { targetDisplayAddress } = $$props; + let { googlePublicApiKey } = $$props; + let { addressCtaText = "See if my home qualifies" } = $$props; + let { onAddressSelect } = $$props; + let { onAddressSubmitSuccess } = $$props; + const dispatch = createEventDispatcher(); + let addressInput; + let autocomplete; + let isFocused = false; + let isOverlayVisible = false; + let isInputFocused = false; + let isInputValid = false; + let isSubmitting = false; + let errorMessage = ""; + let selectedAddress = null; + + function handleInputFocus() { + isInputFocused = true; + isOverlayVisible = true; + } + + function handleInputBlur() { + isInputFocused = false; + + setTimeout( + () => { + isOverlayVisible = false; + }, + 200 + ); + } + + function handleInputChange() { + const value = addressInput.value.trim(); + isInputValid = value.length > 0; + errorMessage = ""; + } + + function handleSubmit() { + console.log("handleSubmit called with address:", selectedAddress); + + if (!selectedAddress) { + errorMessage = "Please enter a full address."; + return; + } + + if (!selectedAddress.postalCode || !selectedAddress.houseNumber || !selectedAddress.street) { + errorMessage = "Please enter a full address."; + console.log("Validation failed - missing required fields:", selectedAddress); + return; + } + + const targetDisplayAddressEl = document.querySelector(targetDisplayAddress); + + if (targetDisplayAddressEl) { + targetDisplayAddressEl.innerHTML = selectedAddress.formattedAddress; + } + + addressState.update({ selectedAddress }); + console.log("Calling onAddressSubmitSuccess with:", selectedAddress); + + onAddressSubmitSuccess === null || onAddressSubmitSuccess === void 0 + ? void 0 + : onAddressSubmitSuccess(selectedAddress); + } + + function handlePlaceSelect() { + const place = autocomplete.getPlace(); + + if (place) { + $$invalidate(3, selectedAddress = parsePlaceResult(place)); + onAddressSelect(selectedAddress); + isInputValid = true; + errorMessage = ""; + } + } + + onMount(() => { + jQuery(".input-address-container").on("click", function () { + jQuery(".focus_overlay").show(); + jQuery(".input-address-container").addClass("focused"); + jQuery("input.location-search-input").attr("placeholder", "Enter home address"); + jQuery("button.submitAddressButton").hide(); + }); + + jQuery(".input-address-container").on("keydown", function () { + jQuery("input.location-search-input").attr("placeholder", ""); + }); + + jQuery(".focus_overlay").on("click", function () { + jQuery(".focus_overlay").hide(); + jQuery(".submitAddressButton").show(); + jQuery(".input-address-container").removeClass("focused"); + }); + }); + + $$self.$$.on_mount.push(function () { + if (targetDisplayAddress === undefined && !('targetDisplayAddress' in $$props || $$self.$$.bound[$$self.$$.props['targetDisplayAddress']])) { + console_1.warn(" was created without expected prop 'targetDisplayAddress'"); + } + + if (googlePublicApiKey === undefined && !('googlePublicApiKey' in $$props || $$self.$$.bound[$$self.$$.props['googlePublicApiKey']])) { + console_1.warn(" was created without expected prop 'googlePublicApiKey'"); + } + + if (onAddressSelect === undefined && !('onAddressSelect' in $$props || $$self.$$.bound[$$self.$$.props['onAddressSelect']])) { + console_1.warn(" was created without expected prop 'onAddressSelect'"); + } + + if (onAddressSubmitSuccess === undefined && !('onAddressSubmitSuccess' in $$props || $$self.$$.bound[$$self.$$.props['onAddressSubmitSuccess']])) { + console_1.warn(" was created without expected prop 'onAddressSubmitSuccess'"); + } + }); + + const writable_props = [ + 'targetDisplayAddress', + 'googlePublicApiKey', + 'addressCtaText', + 'onAddressSelect', + 'onAddressSubmitSuccess' + ]; + + Object.keys($$props).forEach(key => { + if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console_1.warn(` was created with unknown prop '${key}'`); + }); + + const func = value => { + console.log("Place selected:", value); + const parsed = parsePlaceResult(value); + console.log("Parsed place result:", parsed); + onAddressSelect?.(parsed); + window.blur(); + $$invalidate(4, inputErrorMessage = ""); + $$invalidate(3, selectedAddress = parsed); + handleSubmit(); + }; + + $$self.$$set = $$props => { + if ('targetDisplayAddress' in $$props) $$invalidate(6, targetDisplayAddress = $$props.targetDisplayAddress); + if ('googlePublicApiKey' in $$props) $$invalidate(0, googlePublicApiKey = $$props.googlePublicApiKey); + if ('addressCtaText' in $$props) $$invalidate(1, addressCtaText = $$props.addressCtaText); + if ('onAddressSelect' in $$props) $$invalidate(2, onAddressSelect = $$props.onAddressSelect); + if ('onAddressSubmitSuccess' in $$props) $$invalidate(7, onAddressSubmitSuccess = $$props.onAddressSubmitSuccess); + }; + + $$self.$capture_state = () => ({ + GooglePlaceAutocomplete, + parsePlaceResult, + displayBlock, + displayNone, + fadeIn, + onMount, + addressState, + createEventDispatcher, + fade, + fadeOut, + windowVars, + targetDisplayAddress, + googlePublicApiKey, + addressCtaText, + onAddressSelect, + onAddressSubmitSuccess, + dispatch, + addressInput, + autocomplete, + isFocused, + isOverlayVisible, + isInputFocused, + isInputValid, + isSubmitting, + errorMessage, + selectedAddress, + handleInputFocus, + handleInputBlur, + handleInputChange, + handleSubmit, + handlePlaceSelect, + inputErrorMessage + }); + + $$self.$inject_state = $$props => { + if ('targetDisplayAddress' in $$props) $$invalidate(6, targetDisplayAddress = $$props.targetDisplayAddress); + if ('googlePublicApiKey' in $$props) $$invalidate(0, googlePublicApiKey = $$props.googlePublicApiKey); + if ('addressCtaText' in $$props) $$invalidate(1, addressCtaText = $$props.addressCtaText); + if ('onAddressSelect' in $$props) $$invalidate(2, onAddressSelect = $$props.onAddressSelect); + if ('onAddressSubmitSuccess' in $$props) $$invalidate(7, onAddressSubmitSuccess = $$props.onAddressSubmitSuccess); + if ('addressInput' in $$props) addressInput = $$props.addressInput; + if ('autocomplete' in $$props) autocomplete = $$props.autocomplete; + if ('isFocused' in $$props) isFocused = $$props.isFocused; + if ('isOverlayVisible' in $$props) isOverlayVisible = $$props.isOverlayVisible; + if ('isInputFocused' in $$props) isInputFocused = $$props.isInputFocused; + if ('isInputValid' in $$props) isInputValid = $$props.isInputValid; + if ('isSubmitting' in $$props) isSubmitting = $$props.isSubmitting; + if ('errorMessage' in $$props) errorMessage = $$props.errorMessage; + if ('selectedAddress' in $$props) $$invalidate(3, selectedAddress = $$props.selectedAddress); + if ('inputErrorMessage' in $$props) $$invalidate(4, inputErrorMessage = $$props.inputErrorMessage); + }; + + if ($$props && "$$inject" in $$props) { + $$self.$inject_state($$props.$$inject); + } + + $$invalidate(4, inputErrorMessage = ""); + $$invalidate(3, selectedAddress = null); + + return [ + googlePublicApiKey, + addressCtaText, + onAddressSelect, + selectedAddress, + inputErrorMessage, + handleSubmit, + targetDisplayAddress, + onAddressSubmitSuccess, + func + ]; + } + + class LocationInput extends SvelteComponentDev { + constructor(options) { + super(options); + + init(this, options, instance$1, create_fragment$1, safe_not_equal, { + targetDisplayAddress: 6, + googlePublicApiKey: 0, + addressCtaText: 1, + onAddressSelect: 2, + onAddressSubmitSuccess: 7 + }); + + dispatch_dev("SvelteRegisterComponent", { + component: this, + tagName: "LocationInput", + options, + id: create_fragment$1.name + }); + } + + get targetDisplayAddress() { + throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); + } + + set targetDisplayAddress(value) { + throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); + } + + get googlePublicApiKey() { + throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); + } + + set googlePublicApiKey(value) { + throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); + } + + get addressCtaText() { + throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); + } + + set addressCtaText(value) { + throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); + } + + get onAddressSelect() { + throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); + } + + set onAddressSelect(value) { + throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); + } + + get onAddressSubmitSuccess() { + throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); + } + + set onAddressSubmitSuccess(value) { + throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); + } + } + + /* src/location-input/ZipCodeInput.svelte generated by Svelte v3.59.2 */ + const file = "src/location-input/ZipCodeInput.svelte"; + + function create_fragment(ctx) { + let div8; + let div7; + let div6; + let input_1; + let t0; + let div5; + let div0; + let t1_value = (/*zipCode*/ ctx[1][0] || '') + ""; + let t1; + let t2; + let div1; + let t3_value = (/*zipCode*/ ctx[1][1] || '') + ""; + let t3; + let t4; + let div2; + let t5_value = (/*zipCode*/ ctx[1][2] || '') + ""; + let t5; + let t6; + let div3; + let t7_value = (/*zipCode*/ ctx[1][3] || '') + ""; + let t7; + let t8; + let div4; + let t9_value = (/*zipCode*/ ctx[1][4] || '') + ""; + let t9; + let t10; + let button; + + let t11_value = (/*isComplete*/ ctx[5] + ? /*addressCtaText*/ ctx[0] + : "Enter your zip code") + ""; + + let t11; + let button_disabled_value; + let t12; + let div9; + let mounted; + let dispose; + + const block = { + c: function create() { + div8 = element("div"); + div7 = element("div"); + div6 = element("div"); + input_1 = element("input"); + t0 = space(); + div5 = element("div"); + div0 = element("div"); + t1 = text(t1_value); + t2 = space(); + div1 = element("div"); + t3 = text(t3_value); + t4 = space(); + div2 = element("div"); + t5 = text(t5_value); + t6 = space(); + div3 = element("div"); + t7 = text(t7_value); + t8 = space(); + div4 = element("div"); + t9 = text(t9_value); + t10 = space(); + button = element("button"); + t11 = text(t11_value); + t12 = space(); + div9 = element("div"); + attr_dev(input_1, "type", "text"); + attr_dev(input_1, "inputmode", "numeric"); + attr_dev(input_1, "pattern", "[0-9]*"); + attr_dev(input_1, "class", "zip-search-input"); + attr_dev(input_1, "maxlength", "5"); + add_location(input_1, file, 84, 6, 2657); + attr_dev(div0, "class", "zip-box"); + toggle_class(div0, "filled", /*zipCode*/ ctx[1].length >= 1); + add_location(div0, file, 95, 8, 2974); + attr_dev(div1, "class", "zip-box"); + toggle_class(div1, "filled", /*zipCode*/ ctx[1].length >= 2); + add_location(div1, file, 96, 8, 3063); + attr_dev(div2, "class", "zip-box"); + toggle_class(div2, "filled", /*zipCode*/ ctx[1].length >= 3); + add_location(div2, file, 97, 8, 3152); + attr_dev(div3, "class", "zip-box"); + toggle_class(div3, "filled", /*zipCode*/ ctx[1].length >= 4); + add_location(div3, file, 98, 8, 3241); + attr_dev(div4, "class", "zip-box"); + toggle_class(div4, "filled", /*zipCode*/ ctx[1].length >= 5); + add_location(div4, file, 99, 8, 3330); + attr_dev(div5, "class", "zip-boxes"); + add_location(div5, file, 94, 6, 2942); + attr_dev(div6, "class", "zip-input-layout"); + add_location(div6, file, 83, 4, 2620); + attr_dev(button, "class", "submitZipButton button secondary w-button"); + button.disabled = button_disabled_value = !/*isComplete*/ ctx[5]; + add_location(button, file, 102, 4, 3439); + attr_dev(div7, "class", "input-zip-container"); + add_location(div7, file, 82, 2, 2555); + attr_dev(div8, "class", "input-zip-wrap"); + add_location(div8, file, 81, 0, 2524); + attr_dev(div9, "class", "focus_overlay"); + add_location(div9, file, 111, 0, 3660); + }, + l: function claim(nodes) { + throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); + }, + m: function mount(target, anchor) { + insert_dev(target, div8, anchor); + append_dev(div8, div7); + append_dev(div7, div6); + append_dev(div6, input_1); + /*input_1_binding*/ ctx[9](input_1); + append_dev(div6, t0); + append_dev(div6, div5); + append_dev(div5, div0); + append_dev(div0, t1); + append_dev(div5, t2); + append_dev(div5, div1); + append_dev(div1, t3); + append_dev(div5, t4); + append_dev(div5, div2); + append_dev(div2, t5); + append_dev(div5, t6); + append_dev(div5, div3); + append_dev(div3, t7); + append_dev(div5, t8); + append_dev(div5, div4); + append_dev(div4, t9); + append_dev(div7, t10); + append_dev(div7, button); + append_dev(button, t11); + /*div7_binding*/ ctx[11](div7); + insert_dev(target, t12, anchor); + insert_dev(target, div9, anchor); + /*div9_binding*/ ctx[12](div9); + + if (!mounted) { + dispose = [ + listen_dev(input_1, "input", /*handleInput*/ ctx[6], false, false, false, false), + listen_dev(input_1, "keydown", /*keydown_handler*/ ctx[10], false, false, false, false), + listen_dev(button, "click", /*handleSubmit*/ ctx[7], false, false, false, false) + ]; + + mounted = true; + } + }, + p: function update(ctx, [dirty]) { + if (dirty & /*zipCode*/ 2 && t1_value !== (t1_value = (/*zipCode*/ ctx[1][0] || '') + "")) set_data_dev(t1, t1_value); + + if (dirty & /*zipCode*/ 2) { + toggle_class(div0, "filled", /*zipCode*/ ctx[1].length >= 1); + } + + if (dirty & /*zipCode*/ 2 && t3_value !== (t3_value = (/*zipCode*/ ctx[1][1] || '') + "")) set_data_dev(t3, t3_value); + + if (dirty & /*zipCode*/ 2) { + toggle_class(div1, "filled", /*zipCode*/ ctx[1].length >= 2); + } + + if (dirty & /*zipCode*/ 2 && t5_value !== (t5_value = (/*zipCode*/ ctx[1][2] || '') + "")) set_data_dev(t5, t5_value); + + if (dirty & /*zipCode*/ 2) { + toggle_class(div2, "filled", /*zipCode*/ ctx[1].length >= 3); + } + + if (dirty & /*zipCode*/ 2 && t7_value !== (t7_value = (/*zipCode*/ ctx[1][3] || '') + "")) set_data_dev(t7, t7_value); + + if (dirty & /*zipCode*/ 2) { + toggle_class(div3, "filled", /*zipCode*/ ctx[1].length >= 4); + } + + if (dirty & /*zipCode*/ 2 && t9_value !== (t9_value = (/*zipCode*/ ctx[1][4] || '') + "")) set_data_dev(t9, t9_value); + + if (dirty & /*zipCode*/ 2) { + toggle_class(div4, "filled", /*zipCode*/ ctx[1].length >= 5); + } + + if (dirty & /*isComplete, addressCtaText*/ 33 && t11_value !== (t11_value = (/*isComplete*/ ctx[5] + ? /*addressCtaText*/ ctx[0] + : "Enter your zip code") + "")) set_data_dev(t11, t11_value); + + if (dirty & /*isComplete*/ 32 && button_disabled_value !== (button_disabled_value = !/*isComplete*/ ctx[5])) { + prop_dev(button, "disabled", button_disabled_value); + } + }, + i: noop, + o: noop, + d: function destroy(detaching) { + if (detaching) detach_dev(div8); + /*input_1_binding*/ ctx[9](null); + /*div7_binding*/ ctx[11](null); + if (detaching) detach_dev(t12); + if (detaching) detach_dev(div9); + /*div9_binding*/ ctx[12](null); + mounted = false; + run_all(dispose); + } + }; + + dispatch_dev("SvelteRegisterBlock", { + block, + id: create_fragment.name, + type: "component", + source: "", + ctx + }); + + return block; + } + + function instance($$self, $$props, $$invalidate) { + let inputErrorMessage; + let isComplete; + let { $$slots: slots = {}, $$scope } = $$props; + validate_slots('ZipCodeInput', slots, []); + let { addressCtaText = "See if I qualify" } = $$props; + + let { onAddressSubmitSuccess = () => { + + } } = $$props; + + let inputContainer; + let focusOverlay; + let input; + + const handleContainerClick = () => { + if (zipCode.length !== 5) { + // Only show overlay if not complete + $$invalidate(3, focusOverlay.style.display = "block", focusOverlay); + + inputContainer.classList.add("focused"); + } + + input === null || input === void 0 + ? void 0 + : input.focus(); + }; + + const handleOverlayClick = () => { + $$invalidate(3, focusOverlay.style.display = "none", focusOverlay); + inputContainer.classList.remove("focused"); + }; + + onMount(() => { + if (inputContainer && focusOverlay) { + inputContainer.addEventListener("click", handleContainerClick); + focusOverlay.addEventListener("click", handleOverlayClick); + } + }); + + onDestroy(() => { + if (inputContainer && focusOverlay) { + inputContainer.removeEventListener("click", handleContainerClick); + focusOverlay.removeEventListener("click", handleOverlayClick); + } + }); + + let zipCode = ""; + + const handleInput = event => { + const input = event.target; + + // Only allow numbers + const value = input.value.replace(/\D/g, ''); + + // Limit to 5 digits + if (value.length > 5) { + input.value = value.slice(0, 5); + } else { + input.value = value; + } + + $$invalidate(1, zipCode = input.value); + }; + + const handleSubmit = () => { + if (!zipCode) { + inputErrorMessage = "Please enter a zip code."; + return; + } + + if (zipCode.length !== 5) { + inputErrorMessage = "Please enter a valid 5-digit zip code."; + return; + } + + // Create a minimal address object for consistency with LocationInput + const minimalAddress = { + title: "", + formattedAddress: zipCode, + externalId: "", + externalUrl: "", + houseNumber: "", + street: "", + street_2: "", + city: "", + county: "", + stateShort: "", + stateLong: "", + countryCode: "US", + countryLong: "United States", + postalCode: zipCode + }; + + // Always update state and call success handler + addressState.update({ selectedAddress: minimalAddress }); + + onAddressSubmitSuccess === null || onAddressSubmitSuccess === void 0 + ? void 0 + : onAddressSubmitSuccess(minimalAddress); + }; + + const writable_props = ['addressCtaText', 'onAddressSubmitSuccess']; + + Object.keys($$props).forEach(key => { + if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console.warn(` was created with unknown prop '${key}'`); + }); + + function input_1_binding($$value) { + binding_callbacks[$$value ? 'unshift' : 'push'](() => { + input = $$value; + $$invalidate(4, input); + }); + } + + const keydown_handler = e => e.key === 'Enter' && isComplete && handleSubmit(); + + function div7_binding($$value) { + binding_callbacks[$$value ? 'unshift' : 'push'](() => { + inputContainer = $$value; + $$invalidate(2, inputContainer); + }); + } + + function div9_binding($$value) { + binding_callbacks[$$value ? 'unshift' : 'push'](() => { + focusOverlay = $$value; + $$invalidate(3, focusOverlay); + }); + } + + $$self.$$set = $$props => { + if ('addressCtaText' in $$props) $$invalidate(0, addressCtaText = $$props.addressCtaText); + if ('onAddressSubmitSuccess' in $$props) $$invalidate(8, onAddressSubmitSuccess = $$props.onAddressSubmitSuccess); + }; + + $$self.$capture_state = () => ({ + onMount, + onDestroy, + displayBlock, + displayNone, + fadeIn, + addressState, + addressCtaText, + onAddressSubmitSuccess, + inputContainer, + focusOverlay, + input, + handleContainerClick, + handleOverlayClick, + zipCode, + handleInput, + handleSubmit, + inputErrorMessage, + isComplete + }); + + $$self.$inject_state = $$props => { + if ('addressCtaText' in $$props) $$invalidate(0, addressCtaText = $$props.addressCtaText); + if ('onAddressSubmitSuccess' in $$props) $$invalidate(8, onAddressSubmitSuccess = $$props.onAddressSubmitSuccess); + if ('inputContainer' in $$props) $$invalidate(2, inputContainer = $$props.inputContainer); + if ('focusOverlay' in $$props) $$invalidate(3, focusOverlay = $$props.focusOverlay); + if ('input' in $$props) $$invalidate(4, input = $$props.input); + if ('zipCode' in $$props) $$invalidate(1, zipCode = $$props.zipCode); + if ('inputErrorMessage' in $$props) inputErrorMessage = $$props.inputErrorMessage; + if ('isComplete' in $$props) $$invalidate(5, isComplete = $$props.isComplete); + }; + + if ($$props && "$$inject" in $$props) { + $$self.$inject_state($$props.$$inject); + } + + $$self.$$.update = () => { + if ($$self.$$.dirty & /*zipCode*/ 2) { + $$invalidate(5, isComplete = zipCode.length === 5); + } + }; + + inputErrorMessage = ""; + + return [ + addressCtaText, + zipCode, + inputContainer, + focusOverlay, + input, + isComplete, + handleInput, + handleSubmit, + onAddressSubmitSuccess, + input_1_binding, + keydown_handler, + div7_binding, + div9_binding + ]; + } + + class ZipCodeInput extends SvelteComponentDev { + constructor(options) { + super(options); + + init(this, options, instance, create_fragment, safe_not_equal, { + addressCtaText: 0, + onAddressSubmitSuccess: 8 + }); + + dispatch_dev("SvelteRegisterComponent", { + component: this, + tagName: "ZipCodeInput", + options, + id: create_fragment.name + }); + } + + get addressCtaText() { + throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); + } + + set addressCtaText(value) { + throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); + } + + get onAddressSubmitSuccess() { + throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); + } + + set onAddressSubmitSuccess(value) { + throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); + } + } + + // Track initialization state + let isZipCodeInitialized = false; + const PreorderApp = { + initialize: (props) => { + const { targetElAddressInput = document.getElementById("hero-address-entry"), googlePublicApiKey, onAddressSelect, onAddressSubmitSuccess, addressCtaText, querySelectorClickToOpenForm, } = props; + const locationInput = new LocationInput({ + target: targetElAddressInput, + props: { + googlePublicApiKey, + onAddressSelect, + onAddressSubmitSuccess, + addressCtaText: "See if my home qualifies", + targetDisplayAddress: "#hero-address-entry", + }, + }); + // Add click-to-open logic if selector is provided + if (querySelectorClickToOpenForm && targetElAddressInput) { + const triggerEls = document.querySelectorAll(querySelectorClickToOpenForm); + triggerEls.forEach((el) => { + el.addEventListener("click", () => { + // Scroll to the form + targetElAddressInput.scrollIntoView({ + behavior: "smooth", + block: "center", + }); + // Simulate a click on the input-address-container to trigger overlay/focus + const container = targetElAddressInput.querySelector(".input-address-container"); + if (container) { + container.dispatchEvent(new MouseEvent("click", { bubbles: true })); + } + // Optionally, focus the input as well + const input = targetElAddressInput.querySelector("input"); + if (input) { + input.focus(); + } + }); + }); + } + return locationInput; + }, + initializeZipCode: (props) => { + // Prevent multiple initializations + if (isZipCodeInitialized) { + console.warn('ZipCodeInput already initialized, skipping...'); + return; + } + const { targetElAddressInput = document.getElementById("zip-code-entry"), onAddressSubmitSuccess, addressCtaText, querySelectorClickToOpenForm, } = props; + const zipCodeInput = new ZipCodeInput({ + target: targetElAddressInput, + props: { + onAddressSubmitSuccess, + addressCtaText, + }, + }); + // Add click-to-open logic if selector is provided + if (querySelectorClickToOpenForm && targetElAddressInput) { + const triggerEls = document.querySelectorAll(querySelectorClickToOpenForm); + triggerEls.forEach((el) => { + el.addEventListener("click", () => { + // Find the input inside the target element and focus it + const input = targetElAddressInput.querySelector("input"); + if (input) { + input.focus(); + // Optionally, add a 'focused' class to the container + const container = targetElAddressInput.querySelector(".input-zip-container"); + if (container) { + container.classList.add("focused"); + } + } + }); + }); + } + // Mark as initialized + isZipCodeInitialized = true; + return zipCodeInput; + }, + }; + + window.BasePreorderApp = PreorderApp; + // Initialize ZIP code input when DOM is ready + document.addEventListener("DOMContentLoaded", () => { + // Initialize ZIP code input if it exists + if (document.getElementById("zip-code-entry")) { + PreorderApp.initializeZipCode({ + targetElAddressInput: document.getElementById("zip-code-entry"), + querySelectorClickToOpenForm: '[data-preorder="open"]', + addressCtaText: "Check availability", + googleSheetConfig: { + zipsCsvUrl: "https://bpc-web-static-files.s3.us-east-2.amazonaws.com/deregulated-zips.csv", + }, + onAddressSubmitSuccess: async (addressData, leadType, zipConfig) => { + const marketStatus = (zipConfig === null || zipConfig === void 0 ? void 0 : zipConfig.servingNow) || "no"; + const redirectPath = marketStatus === "yes" + ? "/available-now" + : marketStatus === "preorder" + ? "/available-soon" + : "/not-available"; + const url = new URL(redirectPath, window.location.origin); + const currentParams = new URLSearchParams(window.location.search); + const selectedParams = { + zip: (addressData === null || addressData === void 0 ? void 0 : addressData.postalCode) || "", + gclid: currentParams.get("gclid"), + utm_source: currentParams.get("utm_source"), + utm_medium: currentParams.get("utm_medium"), + utm_campaign: currentParams.get("utm_campaign"), + utm_term: currentParams.get("utm_term"), + utm_content: currentParams.get("utm_content"), + referrer_name: currentParams.get("referrer_name"), + }; + const filteredParams = {}; + Object.entries(selectedParams).forEach(([k, v]) => { + if (v) { + filteredParams[k] = v; + } + }); + url.search = new URLSearchParams(filteredParams).toString(); + window.location.href = url.toString(); + }, + }); + } + }); + +})); //# sourceMappingURL=embed.js.map diff --git a/public/preorder-app/embed.js.map b/public/preorder-app/embed.js.map index 216e3f3..3c1efc3 100644 --- a/public/preorder-app/embed.js.map +++ b/public/preorder-app/embed.js.map @@ -1 +1 @@ -{"version":3,"file":"embed.js","sources":["../../node_modules/svelte/internal/index.mjs","../../src/location-input/googlePlace/googlePlaceLibraryLoader.ts","../../src/location-input/googlePlace/GooglePlaceAutocomplete.svelte","../../src/location-input/googlePlace/utils.ts","../../src/windowVars.ts","../../src/location-input/LocationInput.svelte","../../src/location-input/ZipCodeInput.svelte","../../src/PreorderApp.ts","../../src/embed.ts"],"sourcesContent":["function noop() { }\nconst identity = x => x;\nfunction assign(tar, src) {\n // @ts-ignore\n for (const k in src)\n tar[k] = src[k];\n return tar;\n}\n// Adapted from https://github.com/then/is-promise/blob/master/index.js\n// Distributed under MIT License https://github.com/then/is-promise/blob/master/LICENSE\nfunction is_promise(value) {\n return !!value && (typeof value === 'object' || typeof value === 'function') && typeof value.then === 'function';\n}\nfunction add_location(element, file, line, column, char) {\n element.__svelte_meta = {\n loc: { file, line, column, char }\n };\n}\nfunction run(fn) {\n return fn();\n}\nfunction blank_object() {\n return Object.create(null);\n}\nfunction run_all(fns) {\n fns.forEach(run);\n}\nfunction is_function(thing) {\n return typeof thing === 'function';\n}\nfunction safe_not_equal(a, b) {\n return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');\n}\nlet src_url_equal_anchor;\nfunction src_url_equal(element_src, url) {\n if (!src_url_equal_anchor) {\n src_url_equal_anchor = document.createElement('a');\n }\n src_url_equal_anchor.href = url;\n return element_src === src_url_equal_anchor.href;\n}\nfunction not_equal(a, b) {\n return a != a ? b == b : a !== b;\n}\nfunction is_empty(obj) {\n return Object.keys(obj).length === 0;\n}\nfunction validate_store(store, name) {\n if (store != null && typeof store.subscribe !== 'function') {\n throw new Error(`'${name}' is not a store with a 'subscribe' method`);\n }\n}\nfunction subscribe(store, ...callbacks) {\n if (store == null) {\n return noop;\n }\n const unsub = store.subscribe(...callbacks);\n return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\nfunction get_store_value(store) {\n let value;\n subscribe(store, _ => value = _)();\n return value;\n}\nfunction component_subscribe(component, store, callback) {\n component.$$.on_destroy.push(subscribe(store, callback));\n}\nfunction create_slot(definition, ctx, $$scope, fn) {\n if (definition) {\n const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);\n return definition[0](slot_ctx);\n }\n}\nfunction get_slot_context(definition, ctx, $$scope, fn) {\n return definition[1] && fn\n ? assign($$scope.ctx.slice(), definition[1](fn(ctx)))\n : $$scope.ctx;\n}\nfunction get_slot_changes(definition, $$scope, dirty, fn) {\n if (definition[2] && fn) {\n const lets = definition[2](fn(dirty));\n if ($$scope.dirty === undefined) {\n return lets;\n }\n if (typeof lets === 'object') {\n const merged = [];\n const len = Math.max($$scope.dirty.length, lets.length);\n for (let i = 0; i < len; i += 1) {\n merged[i] = $$scope.dirty[i] | lets[i];\n }\n return merged;\n }\n return $$scope.dirty | lets;\n }\n return $$scope.dirty;\n}\nfunction update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {\n if (slot_changes) {\n const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);\n slot.p(slot_context, slot_changes);\n }\n}\nfunction update_slot(slot, slot_definition, ctx, $$scope, dirty, get_slot_changes_fn, get_slot_context_fn) {\n const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);\n update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn);\n}\nfunction get_all_dirty_from_scope($$scope) {\n if ($$scope.ctx.length > 32) {\n const dirty = [];\n const length = $$scope.ctx.length / 32;\n for (let i = 0; i < length; i++) {\n dirty[i] = -1;\n }\n return dirty;\n }\n return -1;\n}\nfunction exclude_internal_props(props) {\n const result = {};\n for (const k in props)\n if (k[0] !== '$')\n result[k] = props[k];\n return result;\n}\nfunction compute_rest_props(props, keys) {\n const rest = {};\n keys = new Set(keys);\n for (const k in props)\n if (!keys.has(k) && k[0] !== '$')\n rest[k] = props[k];\n return rest;\n}\nfunction compute_slots(slots) {\n const result = {};\n for (const key in slots) {\n result[key] = true;\n }\n return result;\n}\nfunction once(fn) {\n let ran = false;\n return function (...args) {\n if (ran)\n return;\n ran = true;\n fn.call(this, ...args);\n };\n}\nfunction null_to_empty(value) {\n return value == null ? '' : value;\n}\nfunction set_store_value(store, ret, value) {\n store.set(value);\n return ret;\n}\nconst has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);\nfunction action_destroyer(action_result) {\n return action_result && is_function(action_result.destroy) ? action_result.destroy : noop;\n}\nfunction split_css_unit(value) {\n const split = typeof value === 'string' && value.match(/^\\s*(-?[\\d.]+)([^\\s]*)\\s*$/);\n return split ? [parseFloat(split[1]), split[2] || 'px'] : [value, 'px'];\n}\nconst contenteditable_truthy_values = ['', true, 1, 'true', 'contenteditable'];\n\nconst is_client = typeof window !== 'undefined';\nlet now = is_client\n ? () => window.performance.now()\n : () => Date.now();\nlet raf = is_client ? cb => requestAnimationFrame(cb) : noop;\n// used internally for testing\nfunction set_now(fn) {\n now = fn;\n}\nfunction set_raf(fn) {\n raf = fn;\n}\n\nconst tasks = new Set();\nfunction run_tasks(now) {\n tasks.forEach(task => {\n if (!task.c(now)) {\n tasks.delete(task);\n task.f();\n }\n });\n if (tasks.size !== 0)\n raf(run_tasks);\n}\n/**\n * For testing purposes only!\n */\nfunction clear_loops() {\n tasks.clear();\n}\n/**\n * Creates a new task that runs on each raf frame\n * until it returns a falsy value or is aborted\n */\nfunction loop(callback) {\n let task;\n if (tasks.size === 0)\n raf(run_tasks);\n return {\n promise: new Promise(fulfill => {\n tasks.add(task = { c: callback, f: fulfill });\n }),\n abort() {\n tasks.delete(task);\n }\n };\n}\n\nconst globals = (typeof window !== 'undefined'\n ? window\n : typeof globalThis !== 'undefined'\n ? globalThis\n : global);\n\n/**\n * Resize observer singleton.\n * One listener per element only!\n * https://groups.google.com/a/chromium.org/g/blink-dev/c/z6ienONUb5A/m/F5-VcUZtBAAJ\n */\nclass ResizeObserverSingleton {\n constructor(options) {\n this.options = options;\n this._listeners = 'WeakMap' in globals ? new WeakMap() : undefined;\n }\n observe(element, listener) {\n this._listeners.set(element, listener);\n this._getObserver().observe(element, this.options);\n return () => {\n this._listeners.delete(element);\n this._observer.unobserve(element); // this line can probably be removed\n };\n }\n _getObserver() {\n var _a;\n return (_a = this._observer) !== null && _a !== void 0 ? _a : (this._observer = new ResizeObserver((entries) => {\n var _a;\n for (const entry of entries) {\n ResizeObserverSingleton.entries.set(entry.target, entry);\n (_a = this._listeners.get(entry.target)) === null || _a === void 0 ? void 0 : _a(entry);\n }\n }));\n }\n}\n// Needs to be written like this to pass the tree-shake-test\nResizeObserverSingleton.entries = 'WeakMap' in globals ? new WeakMap() : undefined;\n\n// Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM\n// at the end of hydration without touching the remaining nodes.\nlet is_hydrating = false;\nfunction start_hydrating() {\n is_hydrating = true;\n}\nfunction end_hydrating() {\n is_hydrating = false;\n}\nfunction upper_bound(low, high, key, value) {\n // Return first index of value larger than input value in the range [low, high)\n while (low < high) {\n const mid = low + ((high - low) >> 1);\n if (key(mid) <= value) {\n low = mid + 1;\n }\n else {\n high = mid;\n }\n }\n return low;\n}\nfunction init_hydrate(target) {\n if (target.hydrate_init)\n return;\n target.hydrate_init = true;\n // We know that all children have claim_order values since the unclaimed have been detached if target is not \n let children = target.childNodes;\n // If target is , there may be children without claim_order\n if (target.nodeName === 'HEAD') {\n const myChildren = [];\n for (let i = 0; i < children.length; i++) {\n const node = children[i];\n if (node.claim_order !== undefined) {\n myChildren.push(node);\n }\n }\n children = myChildren;\n }\n /*\n * Reorder claimed children optimally.\n * We can reorder claimed children optimally by finding the longest subsequence of\n * nodes that are already claimed in order and only moving the rest. The longest\n * subsequence of nodes that are claimed in order can be found by\n * computing the longest increasing subsequence of .claim_order values.\n *\n * This algorithm is optimal in generating the least amount of reorder operations\n * possible.\n *\n * Proof:\n * We know that, given a set of reordering operations, the nodes that do not move\n * always form an increasing subsequence, since they do not move among each other\n * meaning that they must be already ordered among each other. Thus, the maximal\n * set of nodes that do not move form a longest increasing subsequence.\n */\n // Compute longest increasing subsequence\n // m: subsequence length j => index k of smallest value that ends an increasing subsequence of length j\n const m = new Int32Array(children.length + 1);\n // Predecessor indices + 1\n const p = new Int32Array(children.length);\n m[0] = -1;\n let longest = 0;\n for (let i = 0; i < children.length; i++) {\n const current = children[i].claim_order;\n // Find the largest subsequence length such that it ends in a value less than our current value\n // upper_bound returns first greater value, so we subtract one\n // with fast path for when we are on the current longest subsequence\n const seqLen = ((longest > 0 && children[m[longest]].claim_order <= current) ? longest + 1 : upper_bound(1, longest, idx => children[m[idx]].claim_order, current)) - 1;\n p[i] = m[seqLen] + 1;\n const newLen = seqLen + 1;\n // We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence.\n m[newLen] = i;\n longest = Math.max(newLen, longest);\n }\n // The longest increasing subsequence of nodes (initially reversed)\n const lis = [];\n // The rest of the nodes, nodes that will be moved\n const toMove = [];\n let last = children.length - 1;\n for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) {\n lis.push(children[cur - 1]);\n for (; last >= cur; last--) {\n toMove.push(children[last]);\n }\n last--;\n }\n for (; last >= 0; last--) {\n toMove.push(children[last]);\n }\n lis.reverse();\n // We sort the nodes being moved to guarantee that their insertion order matches the claim order\n toMove.sort((a, b) => a.claim_order - b.claim_order);\n // Finally, we move the nodes\n for (let i = 0, j = 0; i < toMove.length; i++) {\n while (j < lis.length && toMove[i].claim_order >= lis[j].claim_order) {\n j++;\n }\n const anchor = j < lis.length ? lis[j] : null;\n target.insertBefore(toMove[i], anchor);\n }\n}\nfunction append(target, node) {\n target.appendChild(node);\n}\nfunction append_styles(target, style_sheet_id, styles) {\n const append_styles_to = get_root_for_style(target);\n if (!append_styles_to.getElementById(style_sheet_id)) {\n const style = element('style');\n style.id = style_sheet_id;\n style.textContent = styles;\n append_stylesheet(append_styles_to, style);\n }\n}\nfunction get_root_for_style(node) {\n if (!node)\n return document;\n const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;\n if (root && root.host) {\n return root;\n }\n return node.ownerDocument;\n}\nfunction append_empty_stylesheet(node) {\n const style_element = element('style');\n append_stylesheet(get_root_for_style(node), style_element);\n return style_element.sheet;\n}\nfunction append_stylesheet(node, style) {\n append(node.head || node, style);\n return style.sheet;\n}\nfunction append_hydration(target, node) {\n if (is_hydrating) {\n init_hydrate(target);\n if ((target.actual_end_child === undefined) || ((target.actual_end_child !== null) && (target.actual_end_child.parentNode !== target))) {\n target.actual_end_child = target.firstChild;\n }\n // Skip nodes of undefined ordering\n while ((target.actual_end_child !== null) && (target.actual_end_child.claim_order === undefined)) {\n target.actual_end_child = target.actual_end_child.nextSibling;\n }\n if (node !== target.actual_end_child) {\n // We only insert if the ordering of this node should be modified or the parent node is not target\n if (node.claim_order !== undefined || node.parentNode !== target) {\n target.insertBefore(node, target.actual_end_child);\n }\n }\n else {\n target.actual_end_child = node.nextSibling;\n }\n }\n else if (node.parentNode !== target || node.nextSibling !== null) {\n target.appendChild(node);\n }\n}\nfunction insert(target, node, anchor) {\n target.insertBefore(node, anchor || null);\n}\nfunction insert_hydration(target, node, anchor) {\n if (is_hydrating && !anchor) {\n append_hydration(target, node);\n }\n else if (node.parentNode !== target || node.nextSibling != anchor) {\n target.insertBefore(node, anchor || null);\n }\n}\nfunction detach(node) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n}\nfunction destroy_each(iterations, detaching) {\n for (let i = 0; i < iterations.length; i += 1) {\n if (iterations[i])\n iterations[i].d(detaching);\n }\n}\nfunction element(name) {\n return document.createElement(name);\n}\nfunction element_is(name, is) {\n return document.createElement(name, { is });\n}\nfunction object_without_properties(obj, exclude) {\n const target = {};\n for (const k in obj) {\n if (has_prop(obj, k)\n // @ts-ignore\n && exclude.indexOf(k) === -1) {\n // @ts-ignore\n target[k] = obj[k];\n }\n }\n return target;\n}\nfunction svg_element(name) {\n return document.createElementNS('http://www.w3.org/2000/svg', name);\n}\nfunction text(data) {\n return document.createTextNode(data);\n}\nfunction space() {\n return text(' ');\n}\nfunction empty() {\n return text('');\n}\nfunction comment(content) {\n return document.createComment(content);\n}\nfunction listen(node, event, handler, options) {\n node.addEventListener(event, handler, options);\n return () => node.removeEventListener(event, handler, options);\n}\nfunction prevent_default(fn) {\n return function (event) {\n event.preventDefault();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction stop_propagation(fn) {\n return function (event) {\n event.stopPropagation();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction stop_immediate_propagation(fn) {\n return function (event) {\n event.stopImmediatePropagation();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction self(fn) {\n return function (event) {\n // @ts-ignore\n if (event.target === this)\n fn.call(this, event);\n };\n}\nfunction trusted(fn) {\n return function (event) {\n // @ts-ignore\n if (event.isTrusted)\n fn.call(this, event);\n };\n}\nfunction attr(node, attribute, value) {\n if (value == null)\n node.removeAttribute(attribute);\n else if (node.getAttribute(attribute) !== value)\n node.setAttribute(attribute, value);\n}\n/**\n * List of attributes that should always be set through the attr method,\n * because updating them through the property setter doesn't work reliably.\n * In the example of `width`/`height`, the problem is that the setter only\n * accepts numeric values, but the attribute can also be set to a string like `50%`.\n * If this list becomes too big, rethink this approach.\n */\nconst always_set_through_set_attribute = ['width', 'height'];\nfunction set_attributes(node, attributes) {\n // @ts-ignore\n const descriptors = Object.getOwnPropertyDescriptors(node.__proto__);\n for (const key in attributes) {\n if (attributes[key] == null) {\n node.removeAttribute(key);\n }\n else if (key === 'style') {\n node.style.cssText = attributes[key];\n }\n else if (key === '__value') {\n node.value = node[key] = attributes[key];\n }\n else if (descriptors[key] && descriptors[key].set && always_set_through_set_attribute.indexOf(key) === -1) {\n node[key] = attributes[key];\n }\n else {\n attr(node, key, attributes[key]);\n }\n }\n}\nfunction set_svg_attributes(node, attributes) {\n for (const key in attributes) {\n attr(node, key, attributes[key]);\n }\n}\nfunction set_custom_element_data_map(node, data_map) {\n Object.keys(data_map).forEach((key) => {\n set_custom_element_data(node, key, data_map[key]);\n });\n}\nfunction set_custom_element_data(node, prop, value) {\n if (prop in node) {\n node[prop] = typeof node[prop] === 'boolean' && value === '' ? true : value;\n }\n else {\n attr(node, prop, value);\n }\n}\nfunction set_dynamic_element_data(tag) {\n return (/-/.test(tag)) ? set_custom_element_data_map : set_attributes;\n}\nfunction xlink_attr(node, attribute, value) {\n node.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);\n}\nfunction get_binding_group_value(group, __value, checked) {\n const value = new Set();\n for (let i = 0; i < group.length; i += 1) {\n if (group[i].checked)\n value.add(group[i].__value);\n }\n if (!checked) {\n value.delete(__value);\n }\n return Array.from(value);\n}\nfunction init_binding_group(group) {\n let _inputs;\n return {\n /* push */ p(...inputs) {\n _inputs = inputs;\n _inputs.forEach(input => group.push(input));\n },\n /* remove */ r() {\n _inputs.forEach(input => group.splice(group.indexOf(input), 1));\n }\n };\n}\nfunction init_binding_group_dynamic(group, indexes) {\n let _group = get_binding_group(group);\n let _inputs;\n function get_binding_group(group) {\n for (let i = 0; i < indexes.length; i++) {\n group = group[indexes[i]] = group[indexes[i]] || [];\n }\n return group;\n }\n function push() {\n _inputs.forEach(input => _group.push(input));\n }\n function remove() {\n _inputs.forEach(input => _group.splice(_group.indexOf(input), 1));\n }\n return {\n /* update */ u(new_indexes) {\n indexes = new_indexes;\n const new_group = get_binding_group(group);\n if (new_group !== _group) {\n remove();\n _group = new_group;\n push();\n }\n },\n /* push */ p(...inputs) {\n _inputs = inputs;\n push();\n },\n /* remove */ r: remove\n };\n}\nfunction to_number(value) {\n return value === '' ? null : +value;\n}\nfunction time_ranges_to_array(ranges) {\n const array = [];\n for (let i = 0; i < ranges.length; i += 1) {\n array.push({ start: ranges.start(i), end: ranges.end(i) });\n }\n return array;\n}\nfunction children(element) {\n return Array.from(element.childNodes);\n}\nfunction init_claim_info(nodes) {\n if (nodes.claim_info === undefined) {\n nodes.claim_info = { last_index: 0, total_claimed: 0 };\n }\n}\nfunction claim_node(nodes, predicate, processNode, createNode, dontUpdateLastIndex = false) {\n // Try to find nodes in an order such that we lengthen the longest increasing subsequence\n init_claim_info(nodes);\n const resultNode = (() => {\n // We first try to find an element after the previous one\n for (let i = nodes.claim_info.last_index; i < nodes.length; i++) {\n const node = nodes[i];\n if (predicate(node)) {\n const replacement = processNode(node);\n if (replacement === undefined) {\n nodes.splice(i, 1);\n }\n else {\n nodes[i] = replacement;\n }\n if (!dontUpdateLastIndex) {\n nodes.claim_info.last_index = i;\n }\n return node;\n }\n }\n // Otherwise, we try to find one before\n // We iterate in reverse so that we don't go too far back\n for (let i = nodes.claim_info.last_index - 1; i >= 0; i--) {\n const node = nodes[i];\n if (predicate(node)) {\n const replacement = processNode(node);\n if (replacement === undefined) {\n nodes.splice(i, 1);\n }\n else {\n nodes[i] = replacement;\n }\n if (!dontUpdateLastIndex) {\n nodes.claim_info.last_index = i;\n }\n else if (replacement === undefined) {\n // Since we spliced before the last_index, we decrease it\n nodes.claim_info.last_index--;\n }\n return node;\n }\n }\n // If we can't find any matching node, we create a new one\n return createNode();\n })();\n resultNode.claim_order = nodes.claim_info.total_claimed;\n nodes.claim_info.total_claimed += 1;\n return resultNode;\n}\nfunction claim_element_base(nodes, name, attributes, create_element) {\n return claim_node(nodes, (node) => node.nodeName === name, (node) => {\n const remove = [];\n for (let j = 0; j < node.attributes.length; j++) {\n const attribute = node.attributes[j];\n if (!attributes[attribute.name]) {\n remove.push(attribute.name);\n }\n }\n remove.forEach(v => node.removeAttribute(v));\n return undefined;\n }, () => create_element(name));\n}\nfunction claim_element(nodes, name, attributes) {\n return claim_element_base(nodes, name, attributes, element);\n}\nfunction claim_svg_element(nodes, name, attributes) {\n return claim_element_base(nodes, name, attributes, svg_element);\n}\nfunction claim_text(nodes, data) {\n return claim_node(nodes, (node) => node.nodeType === 3, (node) => {\n const dataStr = '' + data;\n if (node.data.startsWith(dataStr)) {\n if (node.data.length !== dataStr.length) {\n return node.splitText(dataStr.length);\n }\n }\n else {\n node.data = dataStr;\n }\n }, () => text(data), true // Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements\n );\n}\nfunction claim_space(nodes) {\n return claim_text(nodes, ' ');\n}\nfunction claim_comment(nodes, data) {\n return claim_node(nodes, (node) => node.nodeType === 8, (node) => {\n node.data = '' + data;\n return undefined;\n }, () => comment(data), true);\n}\nfunction find_comment(nodes, text, start) {\n for (let i = start; i < nodes.length; i += 1) {\n const node = nodes[i];\n if (node.nodeType === 8 /* comment node */ && node.textContent.trim() === text) {\n return i;\n }\n }\n return nodes.length;\n}\nfunction claim_html_tag(nodes, is_svg) {\n // find html opening tag\n const start_index = find_comment(nodes, 'HTML_TAG_START', 0);\n const end_index = find_comment(nodes, 'HTML_TAG_END', start_index);\n if (start_index === end_index) {\n return new HtmlTagHydration(undefined, is_svg);\n }\n init_claim_info(nodes);\n const html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1);\n detach(html_tag_nodes[0]);\n detach(html_tag_nodes[html_tag_nodes.length - 1]);\n const claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1);\n for (const n of claimed_nodes) {\n n.claim_order = nodes.claim_info.total_claimed;\n nodes.claim_info.total_claimed += 1;\n }\n return new HtmlTagHydration(claimed_nodes, is_svg);\n}\nfunction set_data(text, data) {\n data = '' + data;\n if (text.data === data)\n return;\n text.data = data;\n}\nfunction set_data_contenteditable(text, data) {\n data = '' + data;\n if (text.wholeText === data)\n return;\n text.data = data;\n}\nfunction set_data_maybe_contenteditable(text, data, attr_value) {\n if (~contenteditable_truthy_values.indexOf(attr_value)) {\n set_data_contenteditable(text, data);\n }\n else {\n set_data(text, data);\n }\n}\nfunction set_input_value(input, value) {\n input.value = value == null ? '' : value;\n}\nfunction set_input_type(input, type) {\n try {\n input.type = type;\n }\n catch (e) {\n // do nothing\n }\n}\nfunction set_style(node, key, value, important) {\n if (value == null) {\n node.style.removeProperty(key);\n }\n else {\n node.style.setProperty(key, value, important ? 'important' : '');\n }\n}\nfunction select_option(select, value, mounting) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n if (option.__value === value) {\n option.selected = true;\n return;\n }\n }\n if (!mounting || value !== undefined) {\n select.selectedIndex = -1; // no option should be selected\n }\n}\nfunction select_options(select, value) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n option.selected = ~value.indexOf(option.__value);\n }\n}\nfunction select_value(select) {\n const selected_option = select.querySelector(':checked');\n return selected_option && selected_option.__value;\n}\nfunction select_multiple_value(select) {\n return [].map.call(select.querySelectorAll(':checked'), option => option.__value);\n}\n// unfortunately this can't be a constant as that wouldn't be tree-shakeable\n// so we cache the result instead\nlet crossorigin;\nfunction is_crossorigin() {\n if (crossorigin === undefined) {\n crossorigin = false;\n try {\n if (typeof window !== 'undefined' && window.parent) {\n void window.parent.document;\n }\n }\n catch (error) {\n crossorigin = true;\n }\n }\n return crossorigin;\n}\nfunction add_iframe_resize_listener(node, fn) {\n const computed_style = getComputedStyle(node);\n if (computed_style.position === 'static') {\n node.style.position = 'relative';\n }\n const iframe = element('iframe');\n iframe.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; ' +\n 'overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;');\n iframe.setAttribute('aria-hidden', 'true');\n iframe.tabIndex = -1;\n const crossorigin = is_crossorigin();\n let unsubscribe;\n if (crossorigin) {\n iframe.src = \"data:text/html,\";\n unsubscribe = listen(window, 'message', (event) => {\n if (event.source === iframe.contentWindow)\n fn();\n });\n }\n else {\n iframe.src = 'about:blank';\n iframe.onload = () => {\n unsubscribe = listen(iframe.contentWindow, 'resize', fn);\n // make sure an initial resize event is fired _after_ the iframe is loaded (which is asynchronous)\n // see https://github.com/sveltejs/svelte/issues/4233\n fn();\n };\n }\n append(node, iframe);\n return () => {\n if (crossorigin) {\n unsubscribe();\n }\n else if (unsubscribe && iframe.contentWindow) {\n unsubscribe();\n }\n detach(iframe);\n };\n}\nconst resize_observer_content_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'content-box' });\nconst resize_observer_border_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'border-box' });\nconst resize_observer_device_pixel_content_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'device-pixel-content-box' });\nfunction toggle_class(element, name, toggle) {\n element.classList[toggle ? 'add' : 'remove'](name);\n}\nfunction custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {\n const e = document.createEvent('CustomEvent');\n e.initCustomEvent(type, bubbles, cancelable, detail);\n return e;\n}\nfunction query_selector_all(selector, parent = document.body) {\n return Array.from(parent.querySelectorAll(selector));\n}\nfunction head_selector(nodeId, head) {\n const result = [];\n let started = 0;\n for (const node of head.childNodes) {\n if (node.nodeType === 8 /* comment node */) {\n const comment = node.textContent.trim();\n if (comment === `HEAD_${nodeId}_END`) {\n started -= 1;\n result.push(node);\n }\n else if (comment === `HEAD_${nodeId}_START`) {\n started += 1;\n result.push(node);\n }\n }\n else if (started > 0) {\n result.push(node);\n }\n }\n return result;\n}\nclass HtmlTag {\n constructor(is_svg = false) {\n this.is_svg = false;\n this.is_svg = is_svg;\n this.e = this.n = null;\n }\n c(html) {\n this.h(html);\n }\n m(html, target, anchor = null) {\n if (!this.e) {\n if (this.is_svg)\n this.e = svg_element(target.nodeName);\n /** #7364 target for