!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";function e(e,{include:t,exclude:o}={}){const n=e=>{const n=t=>"string"==typeof t?e===t:t.test(e);return t?t.some(n):!o||!o.some(n)};for(const[r,s]of(e=>{const t=new Set;do{for(const o of Reflect.ownKeys(e))t.add([e,o])}while((e=Reflect.getPrototypeOf(e))&&e!==Object.prototype);return t})(e.constructor.prototype)){if("constructor"===s||!n(s))continue;const t=Reflect.getOwnPropertyDescriptor(r,s);t&&"function"==typeof t.value&&(e[s]=e[s].bind(e))}return e}const t=/^[a-zà-öø-ÿа-я]+|[A-ZÀ-ÖØ-ßА-Я][a-zà-öø-ÿа-я]+|[a-zà-öø-ÿа-я]+|[0-9]+|[A-ZÀ-ÖØ-ßА-Я]+(?![a-zà-öø-ÿа-я])/g,o=/\S+/g;function n(e,n){return function(e,n){const{keepSpecialCharacters:r=!1,keep:s,prefix:i=""}=n||{},a=e.trim().normalize("NFC"),c=a.includes(" "),d=function(e,t){const o={parts:[],prefixes:[]},n=e.matchAll(t);let r=0;for(const i of n){if("number"!=typeof i.index)continue;const t=i[0];o.parts.push(t);const n=e.slice(r,i.index).trim();o.prefixes.push(n),r=i.index+t.length}const s=e.slice(r).trim();return s&&(o.parts.push(""),o.prefixes.push(s)),o}(a,c?o:t);return d.parts.map((e,t)=>{let o=d.prefixes[t]||"",n=e;return!1===r&&(s&&(n=n.normalize("NFD").replace(new RegExp(`[^a-zA-ZØßø0-9${s.join("")}]`,"g"),"")),s||(n=n.normalize("NFD").replace(/[^a-zA-ZØßø0-9]/g,""),o="")),s&&o&&(o=o.replace(new RegExp(`[^${s.join("")}]`,"g"),"")),0===t?o+n:o||n?c&&!o&&i.match(/\s/)?" "+n:(o||i)+n:""}).filter(Boolean)}(e,{...n,prefix:"_"}).join("").toLowerCase()}function r(e,t,o){let n=e.length-t.length;if(0===n)return e(...t);if(1===n)return function(e,t,o){let n=o=>e(o,...t);return void 0===o?n:Object.assign(n,{lazy:o,lazyArgs:t})}(e,t,o);throw Error("Wrong number of arguments")}function s(...e){return r(i,e)}const i=(e,t)=>e.length>=t;function a(e){if("object"!=typeof e||!e)return!1;let t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(...e){return r(d,e)}function d(e,t){let o={...e,...t};for(let n in t){if(!(n in e))continue;let{[n]:r}=e;if(!a(r))continue;let{[n]:s}=t;a(s)&&(o[n]=d(r,s))}return o}function m(...e){return r(f,e)}function f(e,t){if(!s(t,1))return{...e};if(!s(t,2)){let{[t[0]]:o,...n}=e;return n}let o={...e};for(let n of t)delete o[n];return o}const u={name:"",steps:[{name:"",form:{id:"",hooks:{},fieldsContextOptions:{saveInContext:[],pickFromContext:[]},submitOptions:{watchRequiredFields:!0,disabledClass:"disabled"},showNativeFeedback:{success:!1,error:!1},recaptcha:{enabled:!1,mode:"v3"}}}],options:{debug:!1,storage:localStorage,features:{passthroughUtm:!0,useDataLayer:!0},credentials:{}}};function l(e,t){return new Proxy({},{get:(o,n)=>e.getItem(`${t}.${n}`),set:(o,n,r)=>(e.setItem(`${t}.${n}`,r),!0)})}window.WebflowManagedForm=class{config;pendingForms=new WeakSet;managedFormState;managedFormContext;constructor(t){this.config=function(e){const t=e.steps.map(e=>e.form?c(u.steps[0],e):e),o=m(e,["steps"]);return{...c(m(u,["steps"]),o),steps:t}}(t);const{name:o,options:n}=this.config;this.managedFormState=l(n.storage,`${o}-wf-managed-form-state`),this.managedFormContext=l(n.storage,`${o}-wf-managed-form-context`),e(this),$(this.setupManagedForm)}get currentStep(){const e=this.managedFormState.currentStep;return e?parseInt(e):0}setupManagedForm(){const{name:e,options:t}=this.config,o=t?.debug??!1,n=this.currentStep;n>0&&this.goToFormStep(n);const r=e=>{console.log("✅ "+this.getCurrentStepDebugLog(e))};o&&console.log(`⏳ [${e}] Setup started`);for(let s=n;s{const o=e[0],n=!(!!o&&(!t.submitOptions.watchRequiredFields||o.checkValidity()))||!!o&&this.pendingForms.has(o);e.find("[type=submit]").toggleClass(t.submitOptions.disabledClass,n).prop("disabled",n)};e.on("input.webflowManagedForm change.webflowManagedForm",o),o()}setupFormSubmitHandler(e,t,o){const n=this;e.on("submit.webflowManagedForm",async function(e){e.preventDefault(),e.stopPropagation();const r=t.form;if(!r||n.pendingForms.has(this)||!this.checkValidity())return;n.pendingForms.add(this);const s=$(this),i=s.find("[type=submit]"),a=i.val()?.toString()??"",c=i.attr("data-wait")??"Loading...";i.prop("disabled",!0).val(c),s.siblings(".w-form-fail").hide();try{const e=s.attr("method"),i=s.attr("action");if(!e||!i)throw new Error("Form destination is missing");const a=r.recaptcha.enabled&&!o?await n.getRecaptchaToken(t):null;if(r.recaptcha.enabled&&!o&&!a)throw new Error("CAPTCHA validation failed");const c=s.serializeArray().reduce((e,t)=>(e[t.name]=t.value,e),{});let d={data:{}};r.hooks.beforeSubmit&&(d=r.hooks.beforeSubmit(d));for(const t of r.fieldsContextOptions.pickFromContext){if(d.data[t])continue;const e=n.managedFormContext[t];if(!e)throw new Error("Required form context is missing");if(d.data[t]=JSON.parse(e),!d.data[t])throw new Error("Required form context is empty")}const m={managed_form:n.config.name,step:t.name,data:{...c,...d.data,...n.config.options.features.passthroughUtm?n.getUtmParameters():{}}};r.recaptcha.enabled&&(m.recaptchaToken=a??"");const f=()=>{n.savePayloadDataInContext(m.data,r.fieldsContextOptions.saveInContext),n.config.options.features.useDataLayer&&n.pushDataLayerEvent({event:"form_submission",form_name:n.config.name,form_step:t.name,form_data:m.data});const e=s.attr("data-redirect");e?window.location=e:(s.hide(),r.showNativeFeedback.success&&(s.siblings(".w-form-done").show(),s.siblings(".w-form-fail").hide()),n.goToNextFormStep())};if(o)console.log(n.getCurrentStepDebugLog(n.currentStep)),await async function(e){return new Promise(t=>{setTimeout(t,e)})}(300);else{const t=await new Promise((t,o)=>{$.ajax(i,{contentType:"application/json",data:JSON.stringify(m),method:e}).done(e=>t(e)).fail(()=>o(new Error("Form request failed")))});if(r.hooks.validateResponse&&!r.hooks.validateResponse(t))throw new Error("Form response did not confirm completion")}f()}catch{r.showNativeFeedback.error&&(s.siblings(".w-form-done").hide(),s.siblings(".w-form-fail").show())}finally{n.pendingForms.delete(this),i.val(a);const e=r.submitOptions.watchRequiredFields&&!this.checkValidity();i.prop("disabled",e).toggleClass(r.submitOptions.disabledClass,e)}})}savePayloadDataInContext(e,t){for(const o of t)o in e&&Boolean(e[o])&&(this.managedFormContext[o]=JSON.stringify(e[o]))}goToFormStep(e){e>=this.config.steps.length||(this.managedFormState.currentStep=e.toString(),this.moveFormSliderTo(e))}goToNextFormStep(){const e=this.currentStep+1;this.goToFormStep(e)}moveFormSliderTo(e){if(e>=this.config.steps.length||!this.config.slider)return;const t=this.config.slider.id;$(`#${t}`).find(`div:nth-child(${e+1})`).trigger("tap")}getCurrentStepDebugLog(e){const t=this.config.steps[e];if(!t)return"";const{name:o,form:n}=t;let r=`[${this.config.name}][${e+1}/${this.config.steps.length}] step: ${o}`;return n&&(r+=` @ ${n.id}`),r}async getRecaptchaToken(e){const{name:t,form:o}=e;if(!o)return null;const{mode:r}=o.recaptcha,s=this.config.options.credentials.recaptcha?.siteKey;if(!["v3","v3-enterprise"].includes(r)||!s)return null;try{await this.waitForRecaptchaLoad(r);const e=n(t),o=r.includes("enterprise")?grecaptcha.enterprise:grecaptcha;let i;try{return await Promise.race([o.execute(s,{action:e}),new Promise((e,t)=>{i=setTimeout(()=>t(new Error("CAPTCHA execution timed out")),15e3)})])}finally{clearTimeout(i)}}catch(i){return null}}waitForRecaptchaLoad(e){return new Promise((t,o)=>{const n=setTimeout(()=>o(new Error("CAPTCHA readiness timed out")),15e3);try{(e.includes("enterprise")?grecaptcha.enterprise:grecaptcha).ready(()=>{clearTimeout(n),t()})}catch{clearTimeout(n),o(new Error("CAPTCHA is unavailable"))}})}getUtmParameters(){const e=new URLSearchParams(window.location.search),t={},o=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];for(const n of o){const o=e.get(n);o&&(t[n]=o)}return t}pushDataLayerEvent(e){const t=window.dataLayer;t&&"function"==typeof t.push&&t.push(e)}},window.managedForms=window.managedForms||{}});