websiteComponents.loader.define("website.components.form.visitor",[],()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t,n){return(t=function(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}e.r(t),e.d(t,{Visitor:()=>J,default:()=>Q});const i=(new Proxy({},{get:function(e){return()=>e}}),function(){const e=globalThis;return(e=>void 0!==e.SQUARESPACE_VISITOR_SENTRY)(e)?e.SQUARESPACE_VISITOR_SENTRY.captureException(...arguments):""});let o=!1,s=!1,a=!1,c=!1;"undefined"!=typeof window&&"CSS"in window&&"function"==typeof CSS.supports&&(o="Animation"in window,"ViewTimeline"in window&&CSS.supports("animation-range","entry 0% exit 100%"),a="registerProperty"in CSS,CSS.supports("animation-timing-function","linear(0, 0.25 75%, 1)"));const l=o&&a,u=()=>window.__sqsAnimationRuntime;function d(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function h(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const f="[object String]",p="[object Number]",b="[object Boolean]",m="[object Arguments]",v="[object Object]";function g(e){return null==e||"object"!=typeof e&&"function"!=typeof e}function y(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function w(e,t,r,n=new Map,i=void 0){const o=i?.(e,t,r,n);if(void 0!==o)return o;if(g(e))return e;if(n.has(e))return n.get(e);if(Array.isArray(e)){const t=new Array(e.length);n.set(e,t);for(let o=0;o{const s=t?.(r,n,i,o);if(void 0!==s)return s;if("object"==typeof e){if(h(e)===v&&"function"!=typeof e.constructor){const t={};return o.set(e,t),k(t,e,i,o),t}switch(Object.prototype.toString.call(e)){case p:case f:case b:{const t=new e.constructor(e?.valueOf());return k(t,e),t}case m:{const t={};return k(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}}})}(e)}function S(e){return"__proto__"===e}function O(e){return null!==e&&"object"==typeof e&&"[object Arguments]"===h(e)}function j(e){return"object"==typeof e&&null!==e}function C(e){return j(e)&&function(e){return null!=e&&"function"!=typeof e&&function(e){return Number.isSafeInteger(e)&&e>=0}(e.length)}(e)}function E(e){if("object"!=typeof e)return!1;if(null==e)return!1;if(null===Object.getPrototypeOf(e))return!0;if("[object Object]"!==Object.prototype.toString.call(e)){const t=e[Symbol.toStringTag];return null!=t&&(!!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable&&e.toString()===`[object ${t}]`)}let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function B(e){return y(e)}function L(e,t,r,n){if(g(e)&&(e=Object(e)),null==t||"object"!=typeof t)return e;if(n.has(t))return function(e){if(g(e))return e;if(Array.isArray(e)||y(e)||e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer)return e.slice(0);const t=Object.getPrototypeOf(e);if(null==t)return Object.assign(Object.create(t),e);const r=t.constructor;if(e instanceof Date||e instanceof Map||e instanceof Set)return new r(e);if(e instanceof RegExp){const t=new r(e);return t.lastIndex=e.lastIndex,t}if(e instanceof DataView)return new r(e.buffer.slice(0));if(e instanceof Error){let t;return t=e instanceof AggregateError?new r(e.errors,e.message,{cause:e.cause}):new r(e.message,{cause:e.cause}),t.stack=e.stack,Object.assign(t,e),t}if("undefined"!=typeof File&&e instanceof File)return new r([e],e.name,{type:e.type,lastModified:e.lastModified});if("object"==typeof e){const r=Object.create(t);return Object.assign(r,e)}return e}(n.get(t));if(n.set(t,e),Array.isArray(t)){t=t.slice();for(let e=0;e(e.maxWidth?parseInt(e.maxWidth):1/0)-(t.maxWidth?parseInt(t.maxWidth):1/0)),r=document.documentElement.clientWidth;return t.find(e=>{if((null!=e&&e.maxWidth?parseInt(e.maxWidth):Number.MAX_SAFE_INTEGER)>r)return e})??e[0]??null}function F(e,t){if(!t||null==e||!e.breakpointOverrides)return e;const r=e.breakpointOverrides[t.id];return r?function(e,...t){return function(e,...t){const r=t.slice(0,-1),n=t[t.length-1];let i=e;for(let e=0;e1&&void 0!==arguments[1]&&arguments[1];if(n(this,"componentId",""),n(this,"processedValue",null),n(this,"previousBreakpoint",null),n(this,"resizeListener",null),n(this,"handlePrefersReducedMotionChange",e=>{e?(this.destroyAnimations(),this.detachResizeListener()):(this.parseBlockData(),this.attachResizeListener(),this.createAnimations())}),this.root=e,this.root=e,!l)return void this.removePrerender();this.componentId=(null===(t=this.root.closest("[data-website-component-id]"))||void 0===t?void 0:t.dataset.websiteComponentId)??"";const a=null===(r=this.root.parentElement)||void 0===r?void 0:r.classList.contains("pseudo-engine__block");s||a||(this.prefersReducedMotionUnsub=null===(i=u())||void 0===i||null===(o=i.registerReducedMotionChangeHandler)||void 0===o?void 0:o.call(i,this.handlePrefersReducedMotionChange),window.matchMedia("(prefers-reduced-motion: reduce)").matches||this.attachResizeListener())}processBreakpointOverrideValue(){var e,t;this.overridesData||this.parseBlockData();const r=null===(e=this.overridesData)||void 0===e?void 0:e.websitesBreakpoints;if(null===(t=this.overridesData)||void 0===t||!t.isOverridesEnabled||!r)return;const n=D(r);this.processedValue=F(this.blockData,n)}removePrerender(){var e;null===(e=this.root.querySelector("style[data-block-animations-prerender]"))||void 0===e||e.remove()}parseBlockData(){const e=this.root.querySelector(`script[data-block-animations="${this.componentId||""}"]`);if(!e)return this.blockData={animations:[],transforms:{},componentId:this.componentId},void(this.overridesData={isOverridesEnabled:!1,websitesBreakpoints:void 0});const t=JSON.parse(String(e.textContent)),{isOverridesEnabled:r,websitesBreakpoints:n,...i}=t;this.overridesData={isOverridesEnabled:r,websitesBreakpoints:n},this.blockData=i,this.processBreakpointOverrideValue()}attachResizeListener(){var e,t;if(this.resizeListener)return;this.blockData||this.parseBlockData();const r=null===(e=this.overridesData)||void 0===e?void 0:e.websitesBreakpoints;var n;null!==(t=this.overridesData)&&void 0!==t&&t.isOverridesEnabled&&r&&(null!==(n=this.previousBreakpoint)&&void 0!==n&&n.id||(this.previousBreakpoint=D(r)),this.resizeListener=()=>{var e;const t=D(r);if((null===(e=this.previousBreakpoint)||void 0===e?void 0:e.id)!==(null==t?void 0:t.id)){if(this.previousBreakpoint=t,this.processBreakpointOverrideValue(),!this.root.isConnected)return;this.destroyAnimationTriggers(),this.createAnimations()}},window.addEventListener("resize",this.resizeListener))}detachResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null,this.previousBreakpoint=null)}createAnimations(){var e,t;l&&this.blockData&&(this.processBreakpointOverrideValue(),this.processedValue?null===(e=u())||void 0===e||e.createAnimationTriggers(this.processedValue):null===(t=u())||void 0===t||t.createAnimationTriggers(this.blockData))}destroyAnimationTriggers(){const e=u();this.processedValue?null==e||e.destroyAnimationTriggers(this.processedValue):null==e||e.destroyAnimationTriggers(this.blockData)}destroyAnimations(){var e;null===(e=this.prefersReducedMotionUnsub)||void 0===e||e.call(this),this.blockData&&this.destroyAnimationTriggers()}updateBlockData(e,t){e&&(this.blockData||this.parseBlockData(),this.blockData={...this.blockData||{},...e},this.overridesData.websitesBreakpoints=t,this.overridesData.isOverridesEnabled=!!t,this.processBreakpointOverrideValue())}getBlockData(){var e;return this.blockData||this.parseBlockData(),null!==(e=this.overridesData)&&void 0!==e&&e.isOverridesEnabled&&(this.processBreakpointOverrideValue(),this.processedValue)?this.processedValue:this.blockData}}function R(e,t,r){M(e,t),t.set(e,r)}function M(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function P(e,t,r){return e.set(N(e,t),r),r}function T(e,t){return e.get(N(e,t))}function N(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var V=new WeakMap,I=new WeakMap,q=new WeakMap,_=new WeakMap,W=new WeakSet;function H(){T(V,this)&&(P(q,this,e=>{e.target===T(V,this)&&this.close()}),T(V,this).addEventListener("click",T(q,this)),P(_,this,e=>{"Escape"===e.key&&T(I,this)&&this.close()}),document.addEventListener("keydown",T(_,this)))}function U(){var e;T(V,this)&&T(q,this)&&T(V,this).removeEventListener("click",T(q,this)),T(_,this)&&document.removeEventListener("keydown",T(_,this));const t=null===(e=T(V,this))||void 0===e?void 0:e.parentElement;t&&t.parentNode&&t.parentNode.removeChild(t),P(V,this,null),P(q,this,null),P(_,this,null),P(I,this,!1),document.body.style.overflow=""}const $=new class{constructor(){var e;M(this,e=W),e.add(this),R(this,V,null),R(this,I,!1),R(this,q,null),R(this,_,null)}open(e){const{wrapper:t,overlay:r}=((e,t)=>{const{wrapper:r,overlay:n}=(()=>{const e=document.createElement("div");e.className="sqs-modal-lightbox";const t=document.createElement("div");return t.className="sqs-modal-lightbox-content",t.style.cssText="\n display: flex;\n align-items: center;\n justify-content: center;\n ",e.appendChild(t),{wrapper:e,overlay:t}})(),i=(()=>{const e=document.createElement("div");return e.className="lightbox-inner",e})(),o=(()=>{const e=document.createElement("div");return e.className="lightbox-background",e})(),s=(e=>{const t=document.createElement("div");return t.setAttribute("role","button"),t.setAttribute("tabindex","0"),t.setAttribute("aria-label","Close"),t.className="lightbox-close",t.innerHTML="×",t.addEventListener("click",e),t.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||e()}),t})(t),a=(e=>{var t;const r=document.createElement("div");return r.className="lightbox-content",r.style.cssText="\n margin: 50px auto;\n ",null!==(t=e.contentClasses)&&void 0!==t&&t.length&&r.classList.add(...e.contentClasses),e.contentDataAttributes&&Object.entries(e.contentDataAttributes).forEach(e=>{let[t,n]=e;r.setAttribute(`data-${t}`,n)}),r})(e);return a.appendChild(s),a.appendChild(e.content),i.appendChild(a),n.appendChild(o),n.appendChild(i),{wrapper:r,overlay:n}})(e,()=>this.close());P(V,this,r),document.body.appendChild(t),N(W,this,H).call(this),T(V,this).style.display="flex",P(I,this,!0),document.body.style.overflow="hidden"}close(){N(W,this,U).call(this)}isLightboxOpen(){return T(I,this)}};class J{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n(this,"localizedStrings",{}),n(this,"localizedFieldFormats",{}),n(this,"previewSubmissionState",!1),n(this,"resizeListener",null),n(this,"lastBreakpoint",null),n(this,"lightboxButtonListeners",null),this.root=e,this.animationVisitor=new z(this.root,t);const r=this.root.querySelector("script.sqs-form-block-localized-strings");null!=r&&r.textContent&&(this.localizedStrings=JSON.parse(r.textContent));const i=this.getFormContextFromMarkup(),o=this.getDesignFieldsFromMarkup();this.formContext={...i,...o},i.formFieldFormats&&(this.localizedFieldFormats=i.formFieldFormats);const s=this.isBreakpointOverrideable();if(!this.resizeListener&&s){var a;const e=D(null===(a=this.formContext)||void 0===a?void 0:a.breakpoints);this.lastBreakpoint=e,this.attachResizeListener()}else this.resizeListener&&!s&&this.detachResizeListener();this.renderFormOrLightBox()}isBreakpointOverrideable(){var e,t;const r=null===(e=this.formContext)||void 0===e?void 0:e.breakpoints,n=null===(t=this.formContext)||void 0===t?void 0:t.breakpointOverridesFlag;return r&&n}renderFormOrLightBox(){if(this.isBreakpointOverrideable()){var e;const t=D(null===(e=this.formContext)||void 0===e?void 0:e.breakpoints);F(this.formContext,t).useLightbox?this.setupLightBoxHandlerWithBreakpointOverrides():this.renderReactForm(!0).catch(console.error)}else{var t;(null===(t=this.formContext)||void 0===t?void 0:t.useLightbox)?this.setupLightboxHandler():this.renderReactForm(!0).catch(console.error)}}attachResizeListener(){this.resizeListener||(this.resizeListener=()=>{var e;if(!this.formContext||!this.formContext.breakpoints||!this.root.isConnected)return;const t=D(this.formContext.breakpoints);(null===(e=this.lastBreakpoint)||void 0===e?void 0:e.id)!==(null==t?void 0:t.id)&&(this.lastBreakpoint=t,$.isLightboxOpen()&&$.close(),this.renderFormOrLightBox())},window.addEventListener("resize",this.resizeListener))}detachResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null,this.lastBreakpoint=null)}createLightboxContent(){const e=document.createElement("div");e.className="sqs-block-form sqs-block-form-lightbox sqs-background-enabled";const t=document.createElement("div");if(t.className="form-wrapper sqs-site-style-form",e.appendChild(t),!this.formContext)throw new Error("Form context not initialized");const r=document.createElement("div");r.innerHTML=this.formContext.formName||"",r.classList.add("form-title"),t.appendChild(r);const n=document.createElement("div");return n.className="form-inner-wrapper",t.appendChild(n),{wrapper:e,inner:n}}onLightboxClick(){const{wrapper:e,inner:t}=this.createLightboxContent(),r=["lightbox-form-content-background"],n={},i=this.root.closest("[data-section-theme]"),o=(null==i?void 0:i.getAttribute("data-section-theme"))||"";o&&(r.push(o),n["section-theme"]=o),$.open({content:e,contentClasses:r,contentDataAttributes:n}),this.renderReactForm(!0,t).catch(console.error)}setupLightboxHandler(){const e=this.root.querySelector(".lightbox-handle");if(!e)throw new Error("Lightbox handle element not found");e.addEventListener("click",()=>this.onLightboxClick())}setupLightBoxHandlerWithBreakpointOverrides(){var e;const t=D(null===(e=this.formContext)||void 0===e?void 0:e.breakpoints);if(!t){const e=new Error("Form component cannot get current breakpoint to bind lightbox handler");return void i(e)}null===this.lightboxButtonListeners&&(this.lightboxButtonListeners=new Map);const r=e=>this.root.querySelector(`.lightbox-handle-wrapper-${e} .lightbox-handle`),n=r(t.id)??r("system_desktop");if(!n){const e=new Error("Form component cannot find a Lightbox element for the current breakpoint to attach a click handler");return void i(e)}this.lightboxButtonListeners.has(n)||(this.lightboxButtonListeners.set(n,!0),n.addEventListener("click",()=>this.onLightboxClick()))}updateFormContext(e){var t;if(null!==(t=this.formContext)&&void 0!==t&&t.breakpoints&&this.formContext.breakpointOverridesFlag){const t={...this.formContext,...e};this.formContext=t}else this.formContext=e}setPreviewSubmissionState(e){this.previewSubmissionState=e}async renderReactForm(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=(arguments.length>1?arguments[1]:void 0)||this.root.querySelector(".form-wrapper");if(!t)throw new Error("Form wrapper element not found");if(!this.formContext)throw new Error("Form context not initialized");const r=this.generateReactProps();window.Squarespace.renderReactFormForWebsiteComponent(r,t,e)}generateReactProps(){var e;if(!this.formContext)throw new Error("Form context not initialized");let t=this.formContext;if(this.isBreakpointOverrideable()){var r;const e=D(null===(r=this.formContext)||void 0===r?void 0:r.breakpoints);t=F(this.formContext,e)}return{...t,lightboxHandleText:t.lightboxHandleText||(null===(e=this.localizedStrings)||void 0===e?void 0:e.lightbox.openForm),previewSubmissionState:this.previewSubmissionState,formFieldFormats:this.localizedFieldFormats,localizedStrings:this.localizedStrings}}getFormContextFromMarkup(){const e=this.root.querySelector("script.sqs-form-block-context");if(null==e||!e.textContent)throw new Error("Form context script not found or empty");const t=this.root.querySelector(".sqs-form-block-submission-html"),r=(null==t?void 0:t.getAttribute("data-submission-html"))||void 0;try{return{formSubmissionHTML:r,...JSON.parse(e.textContent)}}catch(e){throw new Error(`Error parsing the JSON form context: ${e}`)}}getDesignFieldsFromMarkup(){const e=this.root.querySelector("script.sqs-form-block-design-fields");if(null==e||!e.textContent)throw new Error("Design fields script not found or empty");try{return JSON.parse(e.textContent)}catch(e){throw new Error(`Error parsing design fields: ${e}`)}}}const Q=function(e){return new J(e,arguments.length>1&&void 0!==arguments[1]&&arguments[1])};return t})());