websiteComponents.loader.define("website.components.form.visitor",[],()=>(()=>{"use strict";var t={d:(e,o)=>{for(var n in o)t.o(o,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function n(t,e,n){return(e=function(t){var e=function(t){if("object"!=o(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==o(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}t.r(e),t.d(e,{Visitor:()=>C,default:()=>E});let r=!1,i=!1,s=!1,a=!1;"undefined"!=typeof window&&"CSS"in window&&"function"==typeof CSS.supports&&(r="Animation"in window,"ViewTimeline"in window&&CSS.supports("animation-range","entry 0% exit 100%"),s="registerProperty"in CSS,CSS.supports("animation-timing-function","linear(0, 0.25 75%, 1)"));const l=r&&s,c=()=>window.__sqsAnimationRuntime;class d{constructor(t){var e,o,r;let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n(this,"componentId",""),n(this,"handlePrefersReducedMotionChange",t=>{t?this.destroyAnimations():(this.parseBlockData(),this.createAnimations())}),this.root=t,this.root=t,l?(this.componentId=(null===(e=this.root.closest("[data-block-id]"))||void 0===e?void 0:e.dataset.blockId)??"",i||(this.prefersReducedMotionUnsub=null===(o=c())||void 0===o||null===(r=o.registerReducedMotionChangeHandler)||void 0===r?void 0:r.call(o,this.handlePrefersReducedMotionChange))):this.removePrerender()}removePrerender(){var t;null===(t=this.root.querySelector("style[data-block-animations-prerender]"))||void 0===t||t.remove()}parseBlockData(){const t=this.root.querySelector("script[data-block-animations]");if(!t)return void(this.blockData={animations:[],transforms:{},componentId:this.componentId});const e=JSON.parse(String(t.textContent));this.blockData=e}createAnimations(){var t;l&&this.blockData&&(null===(t=c())||void 0===t||t.createAnimationTriggers(this.blockData))}destroyAnimations(){var t,e;null===(t=this.prefersReducedMotionUnsub)||void 0===t||t.call(this),this.blockData&&(null===(e=c())||void 0===e||e.destroyAnimationTriggers(this.blockData))}updateBlockData(t){t&&(this.blockData||this.parseBlockData(),this.blockData={...this.blockData||{},...t})}getBlockData(){return this.blockData||this.parseBlockData(),this.blockData}}function h(t,e,o){u(t,e),e.set(t,o)}function u(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function m(t,e,o){return t.set(b(t,e),o),o}function p(t,e){return t.get(b(t,e))}function b(t,e,o){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:o;throw new TypeError("Private element is not present on this object")}var f=new WeakMap,v=new WeakMap,g=new WeakMap,y=new WeakMap,w=new WeakSet;function x(){p(f,this)&&(m(g,this,t=>{t.target===p(f,this)&&this.close()}),p(f,this).addEventListener("click",p(g,this)),m(y,this,t=>{"Escape"===t.key&&p(v,this)&&this.close()}),document.addEventListener("keydown",p(y,this)))}function S(){var t;p(f,this)&&p(g,this)&&p(f,this).removeEventListener("click",p(g,this)),p(y,this)&&document.removeEventListener("keydown",p(y,this));const e=null===(t=p(f,this))||void 0===t?void 0:t.parentElement;e&&e.parentNode&&e.parentNode.removeChild(e),m(f,this,null),m(g,this,null),m(y,this,null),m(v,this,!1),document.body.style.overflow=""}const k=new class{constructor(){var t;u(this,t=w),t.add(this),h(this,f,null),h(this,v,!1),h(this,g,null),h(this,y,null)}open(t){const{wrapper:e,overlay:o}=((t,e)=>{const{wrapper:o,overlay:n}=(()=>{const t=document.createElement("div");t.className="sqs-modal-lightbox";const e=document.createElement("div");return e.className="sqs-modal-lightbox-content",e.style.cssText="\n    display: flex;\n    align-items: center;\n    justify-content: center;\n  ",t.appendChild(e),{wrapper:t,overlay:e}})(),r=(()=>{const t=document.createElement("div");return t.className="lightbox-inner",t})(),i=(()=>{const t=document.createElement("div");return t.className="lightbox-background",t})(),s=(t=>{const e=document.createElement("div");return e.setAttribute("role","button"),e.setAttribute("tabindex","0"),e.setAttribute("aria-label","Close"),e.className="lightbox-close",e.innerHTML="×",e.addEventListener("click",t),e.addEventListener("keydown",e=>{"Enter"!==e.key&&" "!==e.key||t()}),e})(e),a=(t=>{var e;const o=document.createElement("div");return o.className="lightbox-content",o.style.cssText="\n    margin: 50px auto;\n  ",null!==(e=t.contentClasses)&&void 0!==e&&e.length&&o.classList.add(...t.contentClasses),t.contentDataAttributes&&Object.entries(t.contentDataAttributes).forEach(t=>{let[e,n]=t;o.setAttribute(`data-${e}`,n)}),o})(t);return a.appendChild(s),a.appendChild(t.content),r.appendChild(a),n.appendChild(i),n.appendChild(r),{wrapper:o,overlay:n}})(t,()=>this.close());m(f,this,o),document.body.appendChild(e),b(w,this,x).call(this),p(f,this).style.display="flex",m(v,this,!0),document.body.style.overflow="hidden"}close(){b(w,this,S).call(this)}isLightboxOpen(){return p(v,this)}};class C{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n(this,"localizedStrings",{}),n(this,"localizedFieldFormats",{}),n(this,"previewSubmissionState",!1),n(this,"useLightbox",!1),this.root=t,this.animationVisitor=new d(this.root,e);const o=this.root.querySelector("script.sqs-form-block-localized-strings");null!=o&&o.textContent&&(this.localizedStrings=JSON.parse(o.textContent));const r=this.getFormContextFromMarkup(),i=this.getDesignFieldsFromMarkup();this.formContext={...r,...i},r.formFieldFormats&&(this.localizedFieldFormats=r.formFieldFormats),this.useLightbox=!!this.root.querySelector(".lightbox-handle"),this.useLightbox?this.setupLightboxHandler():this.renderReactForm(!0).catch(console.error)}createLightboxContent(){const t=document.createElement("div");t.className="sqs-block-form sqs-block-form-lightbox sqs-background-enabled";const e=document.createElement("div");if(e.className="form-wrapper sqs-site-style-form",t.appendChild(e),!this.formContext)throw new Error("Form context not initialized");const o=document.createElement("div");o.innerHTML=this.formContext.formName||"",o.classList.add("form-title"),e.appendChild(o);const n=document.createElement("div");return n.className="form-inner-wrapper",e.appendChild(n),{wrapper:t,inner:n}}setupLightboxHandler(){const t=this.root.querySelector(".lightbox-handle");if(!t)throw new Error("Lightbox handle element not found");t.addEventListener("click",()=>{const{wrapper:t,inner:e}=this.createLightboxContent(),o=["lightbox-form-content-background"],n={},r=this.root.closest("[data-section-theme]"),i=(null==r?void 0:r.getAttribute("data-section-theme"))||"";i&&(o.push(i),n["section-theme"]=i),k.open({content:t,contentClasses:o,contentDataAttributes:n}),this.renderReactForm(!0,e).catch(console.error)})}updateFormContext(t){this.formContext=t}setPreviewSubmissionState(t){this.previewSubmissionState=t}async renderReactForm(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const e=(arguments.length>1?arguments[1]:void 0)||this.root.querySelector(".form-wrapper");if(!e)throw new Error("Form wrapper element not found");if(!this.formContext)throw new Error("Form context not initialized");const o=this.generateReactProps();window.Squarespace.renderReactFormForWebsiteComponent(o,e,t)}generateReactProps(){var t;if(!this.formContext)throw new Error("Form context not initialized");return{...this.formContext,lightboxHandleText:this.formContext.lightboxHandleText||(null===(t=this.localizedStrings)||void 0===t?void 0:t.lightbox.openForm),previewSubmissionState:this.previewSubmissionState,formFieldFormats:this.localizedFieldFormats,localizedStrings:this.localizedStrings}}getFormContextFromMarkup(){const t=this.root.querySelector("script.sqs-form-block-context");if(null==t||!t.textContent)throw new Error("Form context script not found or empty");const e=this.root.querySelector(".sqs-form-block-submission-html"),o=(null==e?void 0:e.getAttribute("data-submission-html"))||void 0;try{return{formSubmissionHTML:o,...JSON.parse(t.textContent)}}catch(t){throw new Error(`Error parsing the JSON form context: ${t}`)}}getDesignFieldsFromMarkup(){const t=this.root.querySelector("script.sqs-form-block-design-fields");if(null==t||!t.textContent)throw new Error("Design fields script not found or empty");try{return JSON.parse(t.textContent)}catch(t){throw new Error(`Error parsing design fields: ${t}`)}}}const E=function(t){return new C(t,arguments.length>1&&void 0!==arguments[1]&&arguments[1])};return e})());