form-functionality-library
Version:
A modular, flexible form functionality library for Webflow forms supporting single-step, multi-step, and branching forms
1 lines • 44.8 kB
JavaScript
;var FormLib=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,a={};((t,i)=>{for(var n in i)e(t,n,{get:i[n],enumerable:!0})})(a,{FormState:()=>d,clearAllErrors:()=>z,clearError:()=>V,clearSummary:()=>Oe,default:()=>Be,getCleanState:()=>pe,getFieldsWithErrors:()=>q,goToStep:()=>X,goToStepById:()=>K,goToStepByIdClean:()=>me,hasError:()=>D,initBrowserValidationFix:()=>Le,initErrors:()=>R,initMultiStep:()=>Y,initMultiStepClean:()=>de,initSummary:()=>Fe,initValidation:()=>Se,showError:()=>x,showErrors:()=>O,updateSummary:()=>Re,validateAllVisibleFields:()=>Ie,validateField:()=>be,validateStep:()=>Me});var r={MULTISTEP:'[data-form="multistep"]',LOGIC:"[data-logic]",STEP:'[data-form="step"]',ANSWER:"[data-answer]",GO_TO:"[data-go-to]",SKIP:"[data-skip]",NEXT_BTN:'[data-form="next-btn"]',BACK_BTN:'[data-form="back-btn"]',SUBMIT:'[data-form="submit"]',SUBMIT_BTN:'[data-form="submit-btn"]',ERROR_DISPLAY:'[data-form="error"]',SHOW_IF:"[data-show-if]",STEP_TYPE:"[data-step-type]",STEP_SUBTYPE:"[data-step-subtype]",STEP_NUMBER:"[data-step-number]",STEP_FIELD_NAME:"[data-step-field-name]",SUMMARY_FIELD:"[data-summary-field]",SUMMARY_TYPE:"[data-summary-type]",SUMMARY_SUBTYPE:"[data-summary-subtype]",SUMMARY_NUMBER:"[data-summary-number]",JOIN:"[data-join]",REQUIRED:"[required]",ERROR_MESSAGE:"[data-error-message]",VALIDATE:"[data-validate]",ALL_INPUTS:"input, select, textarea",FORM_FIELD_WRAPPER:".form-field_wrapper",FORM_FIELD_LABEL:".form_field-label",FORM_INPUT:".form_input",FORM_ERROR_MESSAGE:".form_error-message"},o={START_STEP:1,DEBUG:!0,LOG_PREFIX:"[FormLib]",VALIDATION_DELAY:300,ANIMATION_DURATION:300,JOIN_SEPARATOR:{space:" ",comma:", ",dash:" - ",pipe:" | ",newline:"\n"}},s={ACTIVE_STEP:"active-step",HIDDEN_STEP:"hidden-step",HIDDEN_STEP_ITEM:"hidden-step-item",ERROR_FIELD:"error-field",ACTIVE_ERROR:"active-error",DISABLED:"disabled",FORM_FIELD_WRAPPER:"form-field_wrapper",FORM_FIELD_LABEL:"form_field-label",FORM_INPUT:"form_input",FORM_ERROR_MESSAGE:"form_error-message"},l=class{constructor(){this.data={},m("FormState initialized (simplified)")}static getInstance(){return l.instance||(l.instance=new l),l.instance}setField(e,t){const i=this.data[e];this.data[e]=t,m(`Field updated: ${e}`,{oldValue:i,newValue:t})}getField(e){return this.data[e]}getAll(){return{...this.data}}clear(){const e={...this.data};this.data={},m("FormState cleared",{oldData:e})}clearFields(e){const t={};e.forEach(e=>{void 0!==this.data[e]&&(t[e]=this.data[e],delete this.data[e])}),Object.keys(t).length>0&&m("Fields cleared due to branch change",t)}getDebugInfo(){return{data:this.data,fieldCount:Object.keys(this.data).length}}},d=l.getInstance(),c=new class{constructor(){this.events={},this.moduleStates=new Map}registerModule(e){this.moduleStates.set(e,{initialized:!0,name:e})}unregisterModule(e){this.moduleStates.delete(e)}isModuleInitialized(e){return this.moduleStates.get(e)?.initialized??!1}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.off(e,t)}}off(e,t){this.events[e]&&(this.events[e]=this.events[e].filter(e=>e!==t))}emit(e,t){const i=String(e);if(console.log(`🔄 [FormEvents] Emitting event: ${i}`,{eventData:t,timestamp:(new Date).toISOString(),hasListeners:!!this.events[e],listenerCount:this.events[e]?.length||0}),!this.events[e])return void console.warn(`⚠️ [FormEvents] No listeners registered for event: ${i}`);if("skip:request"===e&&!this.isModuleInitialized("multiStep"))return void console.error(`❌ [FormEvents] CRITICAL: Skipping '${i}' event - multiStep module not initialized`,{eventData:t,registeredModules:Array.from(this.moduleStates.keys()),multiStepState:this.moduleStates.get("multiStep")});if("branch:change"===e&&!this.isModuleInitialized("multiStep"))return void console.error(`❌ [FormEvents] CRITICAL: Skipping '${i}' event - multiStep module not initialized`,{eventData:t,registeredModules:Array.from(this.moduleStates.keys()),multiStepState:this.moduleStates.get("multiStep")});let n=0,a=0;this.events[e].forEach((r,o)=>{try{console.log(`📡 [FormEvents] Calling listener ${o+1}/${this.events[e].length} for ${i}`),r(t),n++,console.log(`✅ [FormEvents] Listener ${o+1} completed successfully for ${i}`)}catch(n){a++,console.error(`💥 [FormEvents] LISTENER ERROR ${o+1}/${this.events[e].length} for '${i}':`,{error:n,errorMessage:n instanceof Error?n.message:String(n),errorStack:n instanceof Error?n.stack:void 0,eventData:t,listenerIndex:o})}}),console.log(`📊 [FormEvents] Event ${i} completed:`,{totalListeners:this.events[e].length,successful:n,failed:a,eventData:t})}},u=new Map;function m(e,t){if(!o.DEBUG)return;const i=(new Date).toISOString().split("T")[1].split(".")[0],n=`${o.LOG_PREFIX} [${i}]`;void 0!==t?console.log(`${n} ${e}`,t):console.log(`${n} ${e}`)}function p(e,t=document){if(t===document){const i=`all:${e}`;if(u.has(i))return u.get(i);const n=t.querySelectorAll(e);return u.set(i,n),n}return t.querySelectorAll(e)}function f(e,t){return e.getAttribute(t)}function g(e,t){e.classList.add(t)}function y(e,t){e.classList.remove(t)}function h(e){y(e,"hidden-step");const t=e.getAttribute("data-original-display")||"",i=e.classList.contains("flex")||e.classList.contains("d-flex")||e.classList.contains("step_wrapper")||e.classList.contains("step-wrapper")||"flex"===getComputedStyle(e).display;let n="block";t&&"none"!==t?n=t:i&&(n="flex"),e.style.setProperty("display",n,"important"),e.style.setProperty("visibility","visible","important"),e.style.setProperty("opacity","1","important"),e.style.setProperty("transform","none","important"),e.style.removeProperty("height"),e.style.removeProperty("max-height"),e.style.removeProperty("width"),e.style.removeProperty("max-width"),console.log("🔄 [Utils] Showing element:",{element:e,tagName:e.tagName,id:e.id,className:e.className,dataAnswer:e.getAttribute("data-answer"),displayValue:n,originalDisplay:t||"none stored",currentDisplay:e.style.display,computedDisplay:getComputedStyle(e).display,computedVisibility:getComputedStyle(e).visibility,computedOpacity:getComputedStyle(e).opacity,hasHiddenClass:e.classList.contains("hidden-step"),isVisible:v(e)})}function S(e){const t=getComputedStyle(e).display;t&&"none"!==t&&e.setAttribute("data-original-display",t),g(e,"hidden-step"),e.style.setProperty("display","none","important"),e.style.setProperty("visibility","hidden","important"),e.style.setProperty("opacity","0","important"),console.log("🔄 [Utils] Hiding element:",{element:e,tagName:e.tagName,id:e.id,className:e.className,originalDisplay:t,currentDisplay:e.style.display,computedDisplay:getComputedStyle(e).display,computedVisibility:getComputedStyle(e).visibility,hasHiddenClass:e.classList.contains("hidden-step"),isVisible:v(e)})}function v(e){const t=getComputedStyle(e);return"none"!==t.display&&"hidden"!==t.visibility&&"0"!==t.opacity&&!function(e,t){return e.classList.contains(t)}(e,"hidden-step")}function b(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function E(e){return e instanceof HTMLInputElement?"checkbox"===e.type||"radio"===e.type?e.checked?e.value:"":e.value:e instanceof HTMLSelectElement&&e.multiple?Array.from(e.selectedOptions).map(e=>e.value):e.value}function A(e,t,i,n){const a=e=>{const t=e.target?.closest(i);t&&n(e,t)};return e.addEventListener(t,a),()=>{e.removeEventListener(t,a)}}var N=!1,M=[];function I(e,t){if(!b(t))return;const i=T(t),n=E(t);i&&(d.setField(i,n),m("Field input detected",{fieldName:i,value:n,eventType:"input"}),c.emit("field:input",{fieldName:i,value:n,element:t,eventType:"input"}))}function L(e,t){if(!b(t))return;const i=T(t),n=E(t);i&&(d.setField(i,n),m("Field change detected",{fieldName:i,value:n,eventType:"change"}),c.emit("field:change",{fieldName:i,value:n,element:t,eventType:"change"}))}function w(e,t){if(!b(t))return;const i=T(t),n=E(t);i&&(m("Field blur detected",{fieldName:i,value:n,eventType:"blur"}),c.emit("field:blur",{fieldName:i,value:n,element:t,eventType:"blur"}))}function T(e){return e.name||f(e,"data-step-field-name")||null}function C(){N?(m("Resetting field coordinator"),M.forEach(e=>e()),M=[],N=!1,m("Field coordinator reset complete")):m("Field coordinator not initialized, nothing to reset")}var F=new Map,$=new Map,_=!1;function R(e=document){m("Initializing error handling"),function(){if(_)return;const e=document.createElement("style");e.setAttribute("data-form-lib","error-styles"),e.textContent="\n /* Form Library Error Message Styles - Auto-injected v1.5.10 - Nuclear CSS Override */\n .form_error-message {\n display: none !important;\n opacity: 0 !important;\n visibility: hidden !important;\n transition: all 0.2s ease-in-out !important;\n }\n\n /* Ultra-aggressive CSS overrides for Webflow */\n .form_error-message.active-error,\n div.form_error-message.active-error,\n .form-field_wrapper .form_error-message.active-error,\n .w-form .form_error-message.active-error {\n display: block !important;\n opacity: 1 !important;\n visibility: visible !important;\n color: #e74c3c !important;\n font-size: 0.875rem !important;\n margin-top: 0.25rem !important;\n line-height: 1.4 !important;\n animation: errorAppear 0.2s ease-out !important;\n height: auto !important;\n max-height: none !important;\n overflow: visible !important;\n position: relative !important;\n z-index: 1000 !important;\n /* Nuclear-level Webflow overrides */\n width: auto !important;\n min-height: 1rem !important;\n padding: 0.25rem 0 !important;\n margin-bottom: 0.25rem !important;\n background: transparent !important;\n border: none !important;\n box-shadow: none !important;\n transform: none !important;\n clip: auto !important;\n clip-path: none !important;\n white-space: normal !important;\n font-weight: 400 !important;\n text-transform: none !important;\n letter-spacing: normal !important;\n text-align: left !important;\n left: auto !important;\n right: auto !important;\n top: auto !important;\n bottom: auto !important;\n float: none !important;\n clear: none !important;\n content: normal !important;\n }\n\n /* Error field styling - Enhanced red borders */\n input.error-field,\n select.error-field,\n textarea.error-field,\n .form_input.error-field {\n border: 2px solid #e74c3c !important;\n box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1) !important;\n background-color: rgba(231, 76, 60, 0.02) !important;\n transition: all 0.2s ease-in-out !important;\n }\n\n input.error-field:focus,\n select.error-field:focus,\n textarea.error-field:focus,\n .form_input.error-field:focus {\n border-color: #c0392b !important;\n box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.2) !important;\n outline: none !important;\n }\n\n .form-field_wrapper.error-field {\n position: relative;\n }\n\n @keyframes errorAppear {\n from {\n opacity: 0 !important;\n transform: translateY(-5px) !important;\n }\n to {\n opacity: 1 !important;\n transform: translateY(0) !important;\n }\n }\n ",document.head.appendChild(e),_=!0,m("📦 [Errors] CSS auto-injected for error visibility")}();e.querySelectorAll("input, select, textarea").forEach(e=>{const t=e.name||f(e,"data-step-field-name");t&&F.set(t,{fieldName:t,element:e,customMessage:f(e,"data-error-message")||void 0})}),c.registerModule("errors"),m(`Error handling initialized for ${F.size} fields`)}function x(e,t){const i=F.get(e);if(!i)return void m(`Cannot show error for unknown field: ${e}`);const n=i.customMessage||t||"This field has an error";m(`Showing error for field: ${e}`,{message:n,hasCustomMessage:!!i.customMessage,messageSource:i.customMessage?"html":t?"parameter":"fallback"}),g(i.element,s.ERROR_FIELD);const a=function(e){if(!e||!e.element)return m("Cannot create error element - no config or element provided"),null;if(!e.element.parentElement)return m(`Cannot create error element for field: ${e.fieldName} - no parent element`,{element:e.element,parentElement:e.element.parentElement,nodeName:e.element.nodeName,id:e.element.id}),null;let t=null;const i=e.element.closest(".form-field_wrapper");if(i){if(t=i.querySelector('[data-form="required"]'),t&&t.textContent&&""!==t.textContent.trim()){const i=t.textContent.trim();e.customMessage=i,m(`Found custom required error message for field: ${e.fieldName}`,{customText:i})}if(!t&&(t=i.querySelector(".form_error-message"),t&&t.textContent&&""!==t.textContent.trim())){const i=t.textContent.trim();e.customMessage=i,m(`Found custom error message for field: ${e.fieldName}`,{customText:i})}t||(t=i.querySelector('[data-form="error"]'))}if(!t){const i=e.element.parentElement;if(t=i.querySelector('[data-form="required"]'),t&&t.textContent&&""!==t.textContent.trim()){const i=t.textContent.trim();e.customMessage=i,m(`Found custom required error message for field: ${e.fieldName}`,{customText:i})}if(!t&&(t=i.querySelector(".form_error-message"),t&&t.textContent&&""!==t.textContent.trim())){const i=t.textContent.trim();e.customMessage=i,m(`Found custom error message for field: ${e.fieldName}`,{customText:i})}}if(!t)try{t=e.element.parentElement.querySelector(`${r.ERROR_DISPLAY}[data-field="${e.fieldName}"]`)}catch(t){m(`Error finding existing error element for field: ${e.fieldName}`,t)}if(t)m(`Found existing error element for field: ${e.fieldName}`,{className:t.className,hasCustomMessage:!!e.customMessage});else try{t=document.createElement("div"),t.setAttribute("data-form","error"),t.setAttribute("data-field",e.fieldName),t.className="form_error-message",i?i.appendChild(t):e.element.parentElement.insertBefore(t,e.element.nextSibling),m(`Created new error element for field: ${e.fieldName}`)}catch(t){return m(`Failed to create error element for field: ${e.fieldName}`,t),null}return t}(i);a&&(i.customMessage&&!t||(a.textContent=n),a.style.display="block",a.style.visibility="visible",a.style.opacity="1",a.style.color="#e74c3c",a.style.fontSize="0.875rem",a.style.marginTop="0.25rem",a.style.lineHeight="1.4",g(a,s.ACTIVE_ERROR),i.errorElement=a,m(`Error element activated for field: ${e}`,{elementVisible:null!==a.offsetParent,hasActiveClass:a.classList.contains(s.ACTIVE_ERROR),hasInlineStyles:!0})),function(e){const t=e.getBoundingClientRect();t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)||(e.scrollIntoView({behavior:"smooth",block:"center"}),m(`Scrolled to field with error: ${e.name||"unnamed"}`))}(i.element)}function V(e){const t=F.get(e);t?(m(`Clearing error for field: ${e}`),y(t.element,s.ERROR_FIELD),t.errorElement&&(t.errorElement.textContent="",t.errorElement.style.display="none",t.errorElement.style.visibility="hidden",t.errorElement.style.opacity="0",y(t.errorElement,s.ACTIVE_ERROR))):m(`Cannot clear error for unknown field: ${e}`)}function z(){m("Clearing all field errors"),F.forEach((e,t)=>{V(t)})}function O(e){m("Showing multiple errors",e),Object.entries(e).forEach(([e,t])=>{x(e,t)})}function D(e){const t=F.get(e);return!!t&&t.element.classList.contains(s.ERROR_FIELD)}function q(){const e=[];return F.forEach((t,i)=>{D(i)&&e.push(i)}),e}function P(){const e={};return $.forEach((t,i)=>{e[i]={message:t.message}}),e}var k=!1,B=[],U=[],H=[],j=-1,W="",Z=[],G=new Set;function Y(e=document){k&&(m("MultiStep already initialized, cleaning up first"),function(){if(!k)return void m("Multi-step module not initialized, nothing to reset");m("Resetting multi-step module"),c.unregisterModule("multiStep"),B.forEach(e=>e()),B=[],H=[],j=-1,W="",Z=[],G.clear(),k=!1,U.forEach(e=>e()),U=[],m("Multi-step module reset")}()),console.log("🚀 [MultiStep] === UPDATED STRUCTURE INITIALIZATION ===");const t=e.querySelectorAll(".step_wrapper[data-answer]");if(console.log("📋 [MultiStep] Found step wrappers with data-answer:",{count:t.length,selector:".step_wrapper[data-answer]"}),0!==t.length){if(H=Array.from(t).map((e,t)=>{const i=f(e,"data-answer"),n="true"===f(e,"data-branch"),a=e.closest('[data-form="step"]');return console.log(`✅ [MultiStep] Registered step wrapper ${t}:`,{id:i,isBranch:n,hasParentStep:!!a,element:{tagName:e.tagName,className:e.className}}),{element:e,id:i||`step-${t}`,index:t,isBranch:n,parentStepElement:a}}),console.log("📊 [MultiStep] Step registration complete:",{totalSteps:H.length,stepIds:H.map(e=>e.id),branchSteps:H.filter(e=>e.isBranch).map(e=>e.id),regularSteps:H.filter(e=>!e.isBranch).map(e=>e.id)}),H.forEach((e,t)=>{"step-0"===e.id?(console.log("👁️ [MultiStep] Keeping step-0 visible for progressive disclosure"),h(e.element),e.element.classList.add("active-step")):(console.log(`🫥 [MultiStep] Hiding step ${t} (${e.id})`),S(e.element))}),function(e){const t=A(e,"click",r.NEXT_BTN,te),i=A(e,"click",r.BACK_BTN,ie),n=A(e,"click",r.SUBMIT_BTN,ne),a=A(e,"change",'input[type="radio"][data-go-to]',ee),o=A(e,"click",'input[type="radio"][data-go-to]',ee),s=A(e,"click","label",J),l=A(e,"click","[data-go-to]",Q);B.push(t,i,n,a,o,s,l),m("Enhanced navigation listeners with Webflow compatibility setup complete")}(e),function(){const e=c.on("step:navigate",e=>{const t=e;console.log("🎯 [MultiStep] Navigation event received:",{targetStepId:t.targetStepId,reason:t.reason}),t.targetStepId&&K(t.targetStepId)});U.push(e)}(),function(e){const t=A(e,"click",r.SKIP,ae);B.push(t),m("Skip listeners setup complete")}(e),H.length>0){const e=H.findIndex(e=>"step-0"===e.id);if(-1!==e){console.log("🎬 [MultiStep] Progressive disclosure: Setting step-0 as current"),j=e,W="step-0",Z=["step-0"],G.add("step-0");const t=H[e];h(t.element),t.element.classList.add("active-step"),re(),c.emit("step:change",{currentStepIndex:e,currentStepId:"step-0",navigatedSteps:Array.from(G),isBranchStep:t.isBranch})}else console.log("🎬 [MultiStep] No step-0 found, showing first step"),X(0)}k=!0,c.registerModule("multiStep"),console.log("✅ [MultiStep] Updated structure initialization complete")}else console.error("❌ [MultiStep] No step wrappers with data-answer found!")}function K(e){if(console.log("🎯 [MultiStep] NAVIGATION to step ID:",e),!k)return void console.error("❌ [MultiStep] Not initialized");const t=H.findIndex(t=>t.id===e);if(-1===t){console.error("❌ [MultiStep] Step not found:",{searchedFor:e,availableSteps:H.map(e=>({id:e.id,isBranch:e.isBranch})),totalSteps:H.length});const t=document.querySelector(`[data-answer="${e}"]`);if(t&&(console.error("🔍 [MultiStep] Step exists in DOM but not registered:",{stepId:e,element:{tagName:t.tagName,id:t.id,className:t.className,hasStepAttribute:t.hasAttribute("data-form"),dataForm:f(t,"data-form"),parentElement:t.parentElement?.tagName,isStepWrapper:t.classList.contains("step_wrapper")}}),t.classList.contains("step_wrapper")&&f(t,"data-answer"))){console.warn("🔧 [MultiStep] Attempting to register missing step:",e);const i="true"===f(t,"data-branch"),n=t.closest('[data-form="step"]'),a={element:t,id:e,index:H.length,isBranch:i,parentStepElement:n};return H.push(a),console.log("✅ [MultiStep] Successfully registered missing step:",a),void X(H.length-1)}return}console.log("✅ [MultiStep] Found step, navigating:",{stepId:e,stepIndex:t,currentIndex:j,isBranch:H[t].isBranch}),X(t)}function X(e){if(console.log("🎯 [MultiStep] GO TO STEP:",{targetIndex:e,currentIndex:j,totalSteps:H.length}),!k||e<0||e>=H.length)return void console.error("❌ [MultiStep] Invalid navigation:",{initialized:k,stepIndex:e,totalSteps:H.length});const t=H[e];if(-1!==j&&j!==e){const e=H[j];console.log("👋 [MultiStep] Hiding current step:",e.id),S(e.element),e.element.classList.remove("active-step")}console.log("👁️ [MultiStep] Showing target step:",t.id),h(t.element),t.element.classList.add("active-step"),G.add(t.id),j=e,W=t.id,Z[Z.length-1]!==t.id&&Z.push(t.id),re(),c.emit("step:change",{currentStepIndex:e,currentStepId:t.id,navigatedSteps:Array.from(G),isBranchStep:t.isBranch}),console.log("✅ [MultiStep] Navigation complete:",{stepId:t.id,isBranch:t.isBranch,isVisible:v(t.element),hasActiveClass:t.element.classList.contains("active-step"),totalNavigatedSteps:G.size}),v(t.element)||(console.error("❌ [MultiStep] Step still not visible after show!"),function(e,t){const i=getComputedStyle(e),n=[];let a=e;for(;a&&a!==document.body;)n.push(a),a=a.parentElement;console.log(`🔍 [MultiStep] Diagnosing visibility issues for step ${t}:`,{targetElement:{tagName:e.tagName,id:e.id,className:e.className,computedDisplay:i.display,computedVisibility:i.visibility,computedOpacity:i.opacity,inlineDisplay:e.style.display,inlineVisibility:e.style.visibility,inlineOpacity:e.style.opacity,hasHiddenClass:e.classList.contains("hidden-step"),isVisible:v(e)},parentChain:n.map(e=>({tagName:e.tagName,id:e.id,className:e.className,computedDisplay:getComputedStyle(e).display,computedVisibility:getComputedStyle(e).visibility,computedOpacity:getComputedStyle(e).opacity,hasHiddenClass:e.classList.contains("hidden-step")})),possibleConflicts:{hasDisplayNone:"none"===i.display,hasVisibilityHidden:"hidden"===i.visibility,hasZeroOpacity:"0"===i.opacity,hasHiddenClass:e.classList.contains("hidden-step"),parentWithDisplayNone:n.some(e=>"none"===getComputedStyle(e).display),parentWithVisibilityHidden:n.some(e=>"hidden"===getComputedStyle(e).visibility)}})}(t.element,t.id))}function J(e,t){const i=t;let n=null;if(n=i.querySelector('input[type="radio"][data-go-to]'),!n&&i.htmlFor){const e=document.getElementById(i.htmlFor);e&&"radio"===e.type&&f(e,"data-go-to")&&(n=e)}n&&(console.log("🏷️ [MultiStep] Label click detected for radio navigation:",{labelClicked:!0,radioId:n.id,dataGoTo:f(n,"data-go-to"),radioHidden:"0"===n.style.opacity||"absolute"===n.style.position}),n.checked=!0,n.dispatchEvent(new Event("change",{bubbles:!0})),ee(e,n))}function Q(e,t){if(t instanceof HTMLInputElement&&"radio"===t.type)return;if(t.classList.contains("step_wrapper")||t.classList.contains("step-wrapper")||f(t,"data-answer"))return void console.log("🛑 [MultiStep] Ignoring navigation from step wrapper:",{stepId:f(t,"data-answer"),reason:"Step wrappers should not trigger direct navigation"});if(!("A"===t.tagName||"BUTTON"===t.tagName||f(t,"data-form")?.includes("btn")||f(t,"data-skip")||t.classList.contains("button")||t.closest('[data-form*="btn"]')||t.closest("button, a")))return void console.log("🛑 [MultiStep] Ignoring navigation from non-navigation element:",{element:t.tagName,className:t.className,reason:"Only buttons, links, and navigation elements can trigger navigation"});const i=f(t,"data-go-to");i&&(e.preventDefault(),console.log("🎯 [MultiStep] Direct navigation triggered:",{element:t.tagName,className:t.className,goToValue:i,isNavigationElement:!0}),K(i))}function ee(e,t){const i=t;if(console.log("🎯 [MultiStep] Radio button navigation:",{radioName:i.name,radioValue:i.value,isChecked:i.checked,dataGoTo:f(i,"data-go-to"),eventType:e.type}),!i.checked)return;const n=f(i,"data-go-to");n?(!function(e){const t=e.name;if(!t)return;const i=f(e,"fs-inputactive-class")||"is-active-inputactive";document.querySelectorAll(`input[type="radio"][name="${t}"]`).forEach(t=>{const n=t,a=n.closest("label");n!==e&&(n.classList.remove(i),a?.classList.remove(i))}),e.classList.add(i);const n=e.closest("label");n?.classList.add(i)}(i),setTimeout(()=>{console.log("🚀 [MultiStep] Navigating to step via radio button:",n);const e=H[j];e&&e.isBranch&&console.log("📝 [MultiStep] Storing branch selection:",{branchStepId:e.id,selectedOption:n,radioValue:i.value}),K(n)},100)):console.warn("⚠️ [MultiStep] Radio button missing data-go-to attribute")}function te(e){e.preventDefault();const t=H[j];if(!t)return void console.error("❌ [MultiStep] No current step found for next navigation");m("🔍 [MultiStep] Validating current step before navigation:",{stepId:t.id,stepIndex:j});const i=function(e){m("🔍 [MultiStep] Starting validation for step:",e.id);const t=e.element.querySelectorAll("input[data-required], select[data-required], textarea[data-required]");if(0===t.length)return m("✅ [MultiStep] No required fields in step, validation passed"),!0;m(`🔍 [MultiStep] Found ${t.length} required fields to validate`);let i=!1;if(t.forEach((e,t)=>{const n=e,a=n.name||n.getAttribute("data-step-field-name")||`field-${t}`,r=n.value?.trim()||"",o=!r;if(m(`🔍 [MultiStep] Validating field #${t}:`,{fieldName:a,inputName:n.name,dataStepFieldName:n.getAttribute("data-step-field-name"),fallbackName:`field-${t}`,value:r,valueLength:r.length,isEmpty:o,inputType:n.type||n.tagName,inputId:n.id}),o){i=!0;const e=function(e){const t=e.closest(".form-field_wrapper");if(t){const e=t.querySelector(".form_error-message");if(e&&e.textContent){const t=e.textContent.trim();if(!t.includes("This is some text inside of a div block"))return t}}const i=e.parentElement;if(i){const e=i.querySelector(".form_error-message");if(e&&e.textContent){const t=e.textContent.trim();if(!t.includes("This is some text inside of a div block"))return t}}return null}(n)||"This field is required";x(a,e),n.classList.add("error-field"),m(`❌ [MultiStep] Required field is empty: ${a}`,{fieldType:n.type||n.tagName,value:r,errorStylingApplied:!0})}else V(a),n.classList.remove("error-field"),m(`✅ [MultiStep] Required field is filled: ${a}`)}),i){m(`🚫 [MultiStep] Validation failed - ${t.length} required fields with errors`);const i=e.element.querySelector('input[data-required]:invalid, input[data-required][value=""], select[data-required][value=""], textarea[data-required][value=""]');if(i)m("🎯 [MultiStep] Auto-focusing first empty required field (via selector)"),i.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>i.focus(),300);else{const e=Array.from(t).find(e=>{const t=e;return!t.value?.trim()});e&&(m("🎯 [MultiStep] Auto-focusing first empty required field"),e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>e.focus(),300))}return!1}return m("✅ [MultiStep] All required fields validated successfully"),!0}(t);if(!i)return void m("🚫 [MultiStep] Navigation blocked - validation failed for step:",t.id);m("✅ [MultiStep] Validation passed, proceeding with navigation");const n=f(t.element,"data-go-to");if(n)console.log("🔀 [MultiStep] Using data-go-to for next navigation:",n),K(n);else{const e=j+1;e<H.length?(console.log("➡️ [MultiStep] Using linear navigation to index:",e),X(e)):console.log("🏁 [MultiStep] Reached end of form")}}function ie(e){if(e.preventDefault(),Z.length>1){Z.pop();const e=Z[Z.length-1];console.log("🔙 [MultiStep] Back navigation using history:",{previousStepId:e,historyLength:Z.length,fullHistory:[...Z]}),K(e)}else{const e=j-1;e>=0?(console.log("🔙 [MultiStep] Back navigation using linear index:",e),X(e)):console.log("🚫 [MultiStep] Already at first step")}}function ne(e){m("Form submission - allowing default behavior")}function ae(e,t){e.preventDefault();const i=f(t,"data-skip");i&&"true"!==i&&""!==i&&K(i)}function re(){const e=document.querySelector(r.NEXT_BTN),t=document.querySelector(r.BACK_BTN),i=document.querySelector(r.SUBMIT_BTN);if(!e||!t||!i)return;const n=0===j,a=j===H.length-1;t.style.display=n?"none":"",a?(e.style.display="none",i.style.display=""):(e.style.display="",i.style.display="none")}var oe=!1,se=[],le=0;function de(e=document){console.log("🚀 [CLEAN] Ultra-minimal initialization starting...");const t=p(r.STEP,e);0!==t.length?(se=Array.from(t).map((e,t)=>{const i=e.querySelector(".step_wrapper[data-answer]");return{element:e,id:f(i||e,"data-answer")||`step-${t}`,index:t}}),console.log("✅ [CLEAN] Steps registered:",se.map(e=>e.id)),ce(),ue(0),function(e){A(e,"change",'input[type="radio"][data-go-to]',(e,t)=>{const i=t;if(!i.checked)return;const n=f(i,"data-go-to");n?(console.log(`🔘 [CLEAN] Radio clicked: ${i.name} → ${n}`),function(e){const t=e.name;if(!t)return;const i="is-active-inputactive";document.querySelectorAll(`input[type="radio"][name="${t}"]`).forEach(e=>{const t=e,n=t.closest("label");t.classList.remove(i),n?.classList.remove(i)}),e.classList.add(i);const n=e.closest("label");n?.classList.add(i),console.log(`🎨 [CLEAN] Styled radio: ${e.name}`)}(i),me(n)):console.warn("⚠️ [CLEAN] Radio missing data-go-to")});console.log("✅ [CLEAN] Radio listeners setup")}(e),oe=!0,console.log("✅ [CLEAN] Initialization complete")):console.error("❌ [CLEAN] No steps found")}function ce(){se.forEach(e=>{e.element.style.display="none",e.element.style.visibility="hidden",console.log(`🙈 [CLEAN] Hiding: ${e.id}`)})}function ue(e){if(e<0||e>=se.length)return void console.error("❌ [CLEAN] Invalid step index:",e);const t=se[e];ce(),t.element.style.setProperty("display","block","important"),t.element.style.setProperty("visibility","visible","important"),t.element.style.setProperty("opacity","1","important"),le=e,console.log(`✅ [CLEAN] Showing: ${t.id} at index ${e}`)}function me(e){console.log(`🎯 [CLEAN] Navigate to: ${e}`);const t=se.findIndex(t=>t.id===e);if(-1===t)return console.error("❌ [CLEAN] Step not found:",e),void console.log("Available steps:",se.map(e=>e.id));ue(t)}function pe(){return{initialized:oe,currentStepIndex:le,currentStepId:se[le]?.id||"none",totalSteps:se.length,stepIds:se.map(e=>e.id)}}var fe=!1,ge=[],ye=new Map,he=new Set;function Se(e=document){fe&&(m("Validation already initialized, cleaning up first"),m("Resetting validation"),ge.forEach(e=>e()),ge=[],m("Clearing all field validation"),ye.forEach((e,t)=>{!function(e){const t=ye.get(e);t&&(t.isValid=!0,t.errorMessage=void 0,Ne(t.element,!0),m(`Cleared validation for field: ${e}`))}(t)}),ye.clear(),he.clear(),fe=!1,m("Validation reset complete")),m("Initializing form validation");const t=p("input, select, textarea",e);m(`Found ${t.length} form inputs`),t.forEach(e=>{if(!b(e))return;const t=e,i=t.name||f(e,"data-step-field-name");if(!i)return void m("Skipping field validation setup - no field name",{element:e,name:t.name,dataStepFieldName:f(e,"data-step-field-name"),id:t.id,type:t.type});const n=function(e){const t=[];(e.hasAttribute("required")||e.hasAttribute("data-required"))&&t.push({type:"required",message:f(e,"data-error-message")||"This field is required"}),e instanceof HTMLInputElement&&"email"===e.type&&t.push({type:"email",message:"Please enter a valid email address"}),e instanceof HTMLInputElement&&"tel"===e.type&&t.push({type:"phone",message:"Please enter a valid phone number"});const i=f(e,"minlength");i&&t.push({type:"min",value:parseInt(i),message:`Minimum ${i} characters required`});const n=f(e,"maxlength");n&&t.push({type:"max",value:parseInt(n),message:`Maximum ${n} characters allowed`});const a=f(e,"pattern");return a&&t.push({type:"pattern",value:new RegExp(a),message:"Please enter a valid format"}),t}(e);0!==n.length?(ye.set(i,{element:e,rules:n,isValid:!0}),m(`Validation rules set for field: ${i}`,{rules:n.map(e=>e.type),rulesCount:n.length,elementId:e.id,elementName:e.name,elementValue:e.value,elementTag:e.tagName})):m(`No validation rules found for field: ${i}`)}),function(){const e=c.on("field:input",e=>{!function(e,t){let i;return(...n)=>{clearTimeout(i),i=setTimeout(()=>e(...n),t)}}(()=>ve(e),o.VALIDATION_DELAY)()}),t=c.on("field:blur",ve),i=c.on("field:change",ve),n=c.on("step:change",e=>{e.currentStepId&&(he.add(e.currentStepId),m(`Validation: Step ${e.currentStepId} marked as navigated`,{totalNavigatedSteps:he.size,navigatedStepsList:Array.from(he)}))});ge.push(e,t,i,n),m("Validation module subscribed to centralized field and step events")}(),fe=!0,c.registerModule("validation"),m("Validation initialization complete")}function ve(e){const{fieldName:t,element:i,eventType:n}=e;if(!t)return void m("Skipping validation - no field name found",{element:i,eventType:n});const a=i.closest(".step_wrapper[data-answer]");if(a){const e=f(a,"data-answer");if(e&&!he.has(e))return void m(`Skipping validation for field in non-navigated step: ${t}`,{stepId:e,navigatedSteps:Array.from(he),fieldInNavigatedStep:!1,eventType:n})}if("input"===n){const e=ye.get(t),a=i.classList.contains("error-field");if(e&&!e.isValid||a){m(`Input event on error field, checking if valid: ${t}`,{currentlyValid:e?.isValid||"no-validation-rules",hasVisualErrors:a,eventType:n});be(t)&&m(`Field error cleared on input: ${t}`)}else m(`Input event on field without errors, skipping validation: ${t}`,{hasValidationRules:!!e,currentlyValid:e?.isValid||"no-rules",hasVisualErrors:a,eventType:n})}else"blur"===n||"change"===n?(m(`Validating field on ${n}: ${t}`),be(t)):m(`Skipping validation for event type: ${n}`,{fieldName:t,eventType:n,reason:"Event type not handled"})}function be(e){const t=ye.get(e);if(!t)return m(`No validation rules found for field: ${e}`),!0;const i=document.querySelector(`input[name="${e}"], select[name="${e}"], textarea[name="${e}"]`)||t.element;if(!i)return m(`No element found for field: ${e}`),!0;const n=E(i);m(`Validating field: ${e}`,{value:n,elementExists:!!i});for(const a of t.rules){const{isValid:r,message:o}=Ae(n,a);if(!r)return t.isValid=!1,t.errorMessage=o||"Invalid field",x(e,t.errorMessage),Ne(i,!1,t.errorMessage),!1}return t.isValid=!0,V(e),Ne(i,!0),!0}var Ee={email:/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,phone:/^[\+]?[1-9][\d]{0,15}$/,phoneUS:/^(\+1\s?)?(\([0-9]{3}\)|[0-9]{3})[\s\-]?[0-9]{3}[\s\-]?[0-9]{4}$/,url:/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/,zipCode:/^\d{5}(-\d{4})?$/,zipCodeCA:/^[A-Za-z]\d[A-Za-z][ -]?\d[A-Za-z]\d$/,creditCard:/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3[0-9]{13}|6(?:011|5[0-9]{2})[0-9]{12})$/,ssn:/^\d{3}-?\d{2}-?\d{4}$/,strongPassword:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/};function Ae(e,t){switch(t.type){case"required":return{isValid:Array.isArray(e)?e.length>0:!!e&&""!==String(e).trim(),message:t.message};case"email":return{isValid:Ee.email.test(String(e)),message:t.message||"Please enter a valid email address"};case"phone":const i=String(e).replace(/[\s\-\(\)]/g,"");return{isValid:Ee.phone.test(i)||Ee.phoneUS.test(String(e)),message:t.message||"Please enter a valid phone number"};case"min":return"number"!=typeof t.value?{isValid:!0}:{isValid:String(e).length>=t.value,message:t.message||`Minimum ${t.value} characters required`};case"max":return"number"!=typeof t.value?{isValid:!0}:{isValid:String(e).length<=t.value,message:t.message||`Maximum ${t.value} characters allowed`};case"pattern":return t.value instanceof RegExp?{isValid:t.value.test(String(e)),message:t.message||"Please enter a valid format"}:{isValid:!0};case"custom":if(!t.validator)return{isValid:!0};try{return{isValid:t.validator(e),message:t.message||"Invalid value"}}catch(e){return m("Error in custom validator",{error:e,rule:t}),{isValid:!1,message:"Validation error occurred"}}default:return{isValid:!0}}}function Ne(e,t,i){const n=e.name||f(e,"data-step-field-name");if(!n)return;t?(e.classList.remove("error-field"),V(n)):(e.classList.add("error-field"),x(n,i));const a=e.closest(".form-field_wrapper");a&&(t?a.classList.remove("error-field"):a.classList.add("error-field"))}function Me(e){const t=function(e,t=document){if(t===document){const i=`single:${e}`;if(u.has(i))return u.get(i);const n=t.querySelector(e);return u.set(i,n),n}return t.querySelector(e)}(`[data-answer="${e}"]`);if(!t)return m(`Step not found with data-answer="${e}"`),!0;if(!v(t))return m(`Skipping validation for hidden step: ${e}`),!0;m(`Validating step: ${e}`);const i=t.querySelectorAll("input, select, textarea");let n=!0;return i.forEach(e=>{if(!b(e))return;const t=e.name||f(e,"data-step-field-name");if(t){be(t)||(n=!1)}}),m(`Step validation result: ${e}`,{isValid:n}),n}function Ie(){m("Validating all visible fields");let e=!0;const t={};for(const[i,n]of ye){const a=n.element.closest(r.STEP);let o=!0;if(a){f(a,"data-answer")&&!v(a)&&(o=!1)}if(o){const n=be(i);t[i]=n,n||(e=!1)}}return m("All visible fields validation complete",{allValid:e,results:t}),e}function Le(e=document){m("Initializing browser validation fix");const t=e.querySelectorAll("form");let i=0;t.forEach(e=>{e.hasAttribute("novalidate")||(e.setAttribute("novalidate","true"),i++,m(`Added novalidate to form: ${e.id||"unnamed"}`))});const n=e.querySelectorAll("input[required], select[required], textarea[required]");let a=0;n.forEach(e=>{const t=e.name||e.getAttribute("data-step-field-name")||"unnamed";e.setAttribute("data-required","true"),e.removeAttribute("required"),a++,m(`Fixed validation conflict: ${t} (required → data-required)`)});return e.querySelectorAll("input, select, textarea").forEach(e=>{"setCustomValidity"in e&&"function"==typeof e.setCustomValidity&&e.setCustomValidity("")}),m(`Browser validation fix complete: ${i} forms, ${a} inputs fixed`),{formsFixed:i,inputsFixed:a,conflictsEliminated:a>0}}var we=!1,Te=[],Ce=[];function Fe(e=document){we&&(m("Summary already initialized, cleaning up first"),m("Resetting summary functionality"),Te.forEach(e=>e()),Te=[],Ce.forEach(e=>{ze(e.element,"")}),Ce=[],we=!1,m("Summary reset complete")),m("Initializing summary functionality");const t=p(r.SUMMARY_FIELD,e);m(`Found ${t.length} summary fields`),function(e){e.forEach(e=>{const t=f(e,"data-summary-field");if(!t)return;const i=t.split("|").map(e=>e.trim()),n=f(e,"data-join"),a=n&&n in o.JOIN_SEPARATOR?n:"space",r=f(e,"data-summary-type")||void 0,s=f(e,"data-summary-subtype")||void 0,l=f(e,"data-summary-number")||void 0,d={element:e,fieldNames:i,joinType:a,type:r,subtype:s,number:l};Ce.push(d),m("Summary field configured",{fieldNames:i,joinType:a,type:r,subtype:s,number:l})})}(t),function(){const e=c.on("field:change",$e),t=c.on("field:input",$e);Te.push(e,t),m("Summary module subscribed to centralized field events")}(),xe(),we=!0,c.registerModule("summary"),m("Summary initialization complete")}function $e(e){const{fieldName:t,value:i,eventType:n}=e;m(`Summary received field ${n}: ${t}`,{value:i}),_e(t)}function _e(e){Ce.forEach(t=>{t.fieldNames.includes(e)&&Ve(t)})}function Re(){m("Updating all summaries"),xe()}function xe(){Ce.forEach(e=>{Ve(e)})}function Ve(e){const t=[];e.fieldNames.forEach(e=>{const i=d.getField(e);null!=i&&""!==i&&(Array.isArray(i)?t.push(...i.filter(e=>""!==e)):t.push(String(i)))});const i=function(e,t){if(0===e.length)return"";const i=o.JOIN_SEPARATOR[t];return e.join(i)}(t,e.joinType);ze(e.element,i),m("Summary field updated",{fieldNames:e.fieldNames,values:t,joinType:e.joinType,result:i})}function ze(e,t){e.textContent=t,""===t?(e.classList.add("summary-empty"),e.classList.remove("summary-filled")):(e.classList.remove("summary-empty"),e.classList.add("summary-filled"))}function Oe(e){e?(m("Clearing specific summary fields",e),d.clearFields(e),e.forEach(e=>{_e(e)})):(m("Clearing all summaries"),d.clear(),xe())}function De(){const e={};return Ce.forEach((t,i)=>{const n=t.type&&t.subtype&&t.number?`${t.type}-${t.subtype}-${t.number}`:`summary-${i}`;e[n]={hasContent:(t.element.textContent||"").trim().length>0}}),e}console.log("🚀 [FormLib] === SCRIPT VERSION CHECK ==="),console.log("📦 [FormLib] Script Version: CACHE_BUST_2025_01_28_23_35_NUCLEAR_CSS_OVERRIDE"),console.log("🔗 [FormLib] Expected URL: @9705259 or newer"),console.log("⏰ [FormLib] Load Time:",(new Date).toISOString());var qe,Pe=class{constructor(){this.initialized=!1,this.rootElement=document,m("FormLibrary instance created")}static getInstance(){return Pe.instance||(Pe.instance=new Pe),Pe.instance}init(e=document){this.initialized&&(m("FormLibrary already initialized, reinitializing..."),this.destroy()),this.rootElement=e,m("Initializing FormLibrary",{root:e===document?"document":"custom element"});const t=e.querySelectorAll(r.MULTISTEP),i=e.querySelectorAll(r.LOGIC),n=e.querySelectorAll(r.STEP);if(m("Form detection results",{multistepForms:t.length,logicForms:i.length,stepElements:n.length}),0!==t.length||0!==n.length)try{!function(e=document){N&&(m("Field coordinator already initialized, cleaning up first"),C()),m("Initializing centralized field coordinator");const t=A(e,"input","input, select, textarea",I),i=A(e,"change","input, select, textarea",L),n=A(e,"blur","input, select, textarea",w);M.push(t,i,n),N=!0,m("Field coordinator initialization complete")}(e),Le(e),R(e),Se(e),(t.length>0||n.length>0)&&Y(e),Fe(e),this.initialized=!0,m("FormLibrary initialization complete"),this.logCurrentState()}catch(e){throw m("FormLibrary initialization failed",e),e}else m("No compatible forms found, library will not initialize")}destroy(){if(this.initialized){m("Destroying FormLibrary");try{C()}catch(e){m("Error during FormLibrary destruction",e)}d.clear(),u.clear(),this.initialized=!1,m("FormLibrary destruction complete")}else m("FormLibrary not initialized, nothing to destroy")}isInitialized(){return this.initialized}getState(){return{initialized:this.initialized,formState:d.getDebugInfo(),multiStep:{note:"Simplified linear navigation - debug info removed"},validation:{initialized:fe,fieldValidations:Array.from(ye.entries()).reduce((e,[t,i])=>(e[t]={isValid:i.isValid,errorMessage:i.errorMessage,rules:i.rules.map(e=>e.type)},e),{})},errors:P(),summary:De()}}logCurrentState(){m("Current FormLibrary State",this.getState())}validateForm(){if(!this.initialized)return m("Cannot validate form - library not initialized"),!1;m("Validating entire form");const e=Ie();return m("Form validation result",{isValid:e}),e}resetForm(){if(this.initialized){m("Resetting form to initial state"),z(),d.clear(),Oe();try{X(0)}catch(e){m("Could not go to first step during reset",e)}m("Form reset complete")}else m("Cannot reset form - library not initialized")}getFormData(){return d.getAll()}setFormData(e){Object.entries(e).forEach(([e,t])=>{d.setField(e,t)}),Re(),m("Form data set",e)}debugStepSystem(){!function(){console.log("🔍 [MultiStep] === STEP SYSTEM DEBUG ==="),console.log("📊 Registered Steps:",{totalSteps:H.length,currentStepIndex:j,currentStepId:W,navigatedStepsCount:G.size}),H.forEach((e,t)=>{const i=t===j,n=G.has(e.id),a=v(e.element);console.log(`${i?"👁️":"💤"} Step ${t} (${e.id}):`,{isBranch:e.isBranch,isNavigated:n,isCurrentStep:i,elementVisible:a,elementDisplay:getComputedStyle(e.element).display,elementVisibility:getComputedStyle(e.element).visibility,hasActiveClass:e.element.classList.contains("active-step"),hasHiddenClass:e.element.classList.contains("hidden-step"),elementClasses:e.element.className})}),console.log("📜 Navigation History:",Z),console.log("🗂️ Navigated Steps:",Array.from(G));const e=document.querySelectorAll(".step_wrapper[data-answer]");e.length!==H.length&&console.warn("⚠️ DOM vs Registered Steps Mismatch:",{domCount:e.length,registeredCount:H.length,missing:Array.from(e).map(e=>f(e,"data-answer")).filter(e=>!H.some(t=>t.id===e))}),console.log("🔍 [MultiStep] === DEBUG COMPLETE ===")}()}getNavigatedSteps(){return Array.from(G)}showError(e,t){x(e,t)}clearError(e){V(e)}clearAllErrors(){z()}hasError(e){return D(e)}getFieldsWithErrors(){return q()}},ke=Pe.getInstance(),Be=ke;if("undefined"!=typeof window){const e=()=>{const e=document.querySelectorAll(r.MULTISTEP),t=document.querySelectorAll(r.STEP);if(console.log("🔍 [FormLib] Auto-init check:",{multistepForms:e.length,stepElements:t.length,readyState:document.readyState}),e.length>0||t.length>0){console.log("🚀 [FormLib] Auto-initializing FormLibrary");try{ke.init(),console.log("✅ [FormLib] Auto-initialization complete")}catch(e){console.error("❌ [FormLib] Auto-initialization failed:",e)}}else console.log("⏭️ [FormLib] No compatible forms found, skipping auto-init")},t=window;t.Webflow?.push?(console.log("🌐 [FormLib] Using Webflow.push for initialization"),t.Webflow.push(e)):console.log("🔄 [FormLib] Webflow not available, using DOM events"),"loading"===document.readyState?(console.log("⏳ [FormLib] DOM loading, waiting for ready"),document.addEventListener("DOMContentLoaded",e)):(console.log("✅ [FormLib] DOM already ready, initializing now"),setTimeout(e,100)),setTimeout(()=>{ke.isInitialized()||(console.log("🔁 [FormLib] Fallback initialization attempt"),e())},1e3)}return"undefined"!=typeof window&&(window.FormLib=ke,m("FormLib attached to window for debugging")),qe=a,((a,r,o,s)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let l of i(r))n.call(a,l)||l===o||e(a,l,{get:()=>r[l],enumerable:!(s=t(r,l))||s.enumerable});return a})(e({},"__esModule",{value:!0}),qe)})();