(function () { var e = new URL(window.location.href), t = e.searchParams.get("results") === "submitted", s = e.searchParams.get("skip_intro") === "true" || e.searchParams.get("start") === "quiz", a = document.createElement("style"); a.id = "sits-fouc-prevention"; var n = t ? "Loading your personalized quiz results..." : "Loading your quiz..."; a.textContent = "#quiz-section{opacity:0!important;visibility:hidden!important;pointer-events:none!important}#results-section{opacity:0!important;visibility:hidden!important;pointer-events:none!important}.sits-loader-overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:#f7f7f7;display:flex;flex-direction:column;align-items:center;justify-content:center;z-index:9999}.sits-loader-spinner{width:48px;height:48px;animation:sits-spin 1s linear infinite}.sits-loader-text{margin-top:16px;font-family:system-ui,-apple-system,sans-serif;font-size:16px;color:#3f4d49;text-align:center}.sits-loader-text.pulse{animation:sits-pulse 1.5s ease-in-out infinite}@keyframes sits-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}@keyframes sits-pulse{0%,100%{opacity:0.4}50%{opacity:0.8}}"; (document.head || document.documentElement).appendChild(a); document.addEventListener("DOMContentLoaded", function () { var e = document.createElement("div"); e.id = "sits-loader-overlay"; e.className = "sits-loader-overlay"; e.innerHTML = '
' + n + "
"; document.body.appendChild(e); }); window.__SITS_FLAGS = { isResultsPage: t, shouldSkipIntro: s }; })(); (function () { function e() { var e = document.createElement("script"); e.src = "https://cdn.jsdelivr.net/gh/videsigns/webflow-tools@latest/multi-step.js"; document.head.appendChild(e); } function t() { typeof window.jQuery !== "undefined" ? e() : setTimeout(t, 50); } document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : t(); })(); (function () { var e = { config: { successCheckTimeout: 30000, successTriggerDelay: 6000, animationDuration: 500, skipIntroParams: ["skip_intro", "start"], libraryCheckAttempts: 100, libraryCheckDelay: 100, resultsListSelector: "#all-matching-seats", buyingKitModalTarget: "bk-announcement", buyingKitDefaultDelay: 0, buyingKitStageLabels: { infant: "Infant", convertible: "Convertible", "high-back-booster": "Forward-Facing/Booster", "no-back-booster": "Forward-Facing/Booster", "forward-facing-only-harnessed-to-booster": "Forward-Facing/Booster", }, }, elements: {}, flags: window.__SITS_FLAGS || { isResultsPage: false, shouldSkipIntro: false, }, startTime: null, buyingKitTimer: null, buyingKitEmail: "", buyingKitTimeToComplete: "", init: function () { var t = this; // Record the start time when quiz initializes t.startTime = Date.now(); t.cacheElements(); t.flags.isResultsPage ? t.waitForResultsReady() : t.waitForLibraryReady(); t.initRadioControls(); t.initCheckboxHandler(); t.initFormSubmission(); t.initBuyingKitWaitlist(); t.updatePageURL(); t.updateBuyingKitContent(); }, cacheElements: function () { this.elements = { quizSection: document.getElementById("quiz-section"), resultsSection: document.getElementById("results-section"), childFitOptions: document.getElementById( "child-fit-convertible-options", ), radioYes: document.getElementById("radio-yes-hide-animation"), radioNo: document.getElementById("radio-no-do-nothing"), tosCheckbox: document.getElementById( "Read-Terms-of-Service-and-Agree-to-Emails", ), pageUrlInput: document.getElementById("pageURL"), shortenedUrlInput: document.getElementById("shortenedURL"), seatResultsInput: document.getElementById("seat-results"), quantityResultsInput: document.getElementById("quantity-results"), resultsTriggerBlock: document.querySelector(".results-trigger-block"), timeToCompleteInput: document.getElementById("time-to-complete"), quizEmailInput: document.getElementById("quiz-email-submission-trigger") || document.querySelector('input[data-ms-member="email"]'), matchingSeatsList: document.getElementById("all-matching-seats"), buyingKitModal: document.querySelector( '[data-modal-target="bk-announcement"]', ), }; }, hideLoader: function () { var e = document.getElementById("sits-loader-overlay"), t = document.getElementById("sits-fouc-prevention"), s = this.elements.quizSection, a = this.elements.resultsSection; t && t.remove(); if (this.flags.isResultsPage) { s && ((s.style.display = "none"), (s.style.height = "0"), (s.style.overflow = "hidden"), (s.style.opacity = "0"), (s.style.visibility = "hidden")); a && ((a.style.display = "block"), (a.style.opacity = "1"), (a.style.visibility = "visible"), (a.style.pointerEvents = "")); } else { s && ((s.style.opacity = "1"), (s.style.visibility = "visible"), (s.style.pointerEvents = "")); } e && e.remove(); }, waitForResultsReady: function () { var e = this, t = 0; function s() { t++; var a = document.getElementById("results-section"); var n = a && a.querySelector( ".product-list-scroll, .jetboost-list-item, [class*='result']", ); if (a && (a.children.length > 0 || n)) { e.hideLoader(); } else if (t < 50) { setTimeout(s, 100); } else { e.hideLoader(); } } setTimeout(s, 200); }, waitForLibraryReady: function () { var e = this, t = 0; function s() { t++; var a = document.querySelectorAll('[data-form="step"]'); if (a.length < 2) { t < e.config.libraryCheckAttempts ? setTimeout(s, e.config.libraryCheckDelay) : e.hideLoader(); return; } var n = window.getComputedStyle(a[1]).display === "none"; n ? e.flags.shouldSkipIntro ? e.skipToNextStep() : e.hideLoader() : t < e.config.libraryCheckAttempts ? setTimeout(s, e.config.libraryCheckDelay) : e.hideLoader(); } setTimeout(s, 200); }, skipToNextStep: function () { var e = this, t = document.querySelector('[data-card="true"][data-form="step"]') || document.querySelector(".form1_step.cover-screen"); if (!t) { e.hideLoader(); return; } var s = t.querySelector('[data-form="next-btn"]'); if (!s) { e.hideLoader(); return; } s.classList.remove("disabled"); s.style.pointerEvents = "auto"; s.style.opacity = "1"; typeof jQuery !== "undefined" ? jQuery(s).trigger("click") : s.click(); e.cleanSkipIntroFromURL(); setTimeout(function () { e.hideLoader(); }, 100); }, cleanSkipIntroFromURL: function () { var e = new URL(window.location.href), t = false; for (var s = 0; s < this.config.skipIntroParams.length; s++) { var a = this.config.skipIntroParams[s]; if (e.searchParams.has(a)) { e.searchParams.delete(a); t = true; } } t && window.history && window.history.replaceState && window.history.replaceState({}, "", e.toString()); }, initRadioControls: function () { var e = this, t = this.elements.childFitOptions, s = this.elements.radioYes, a = this.elements.radioNo; if (!t) return; this.syncRadioState(); s && s.addEventListener("change", function () { s.checked && e.toggleChildFitOptions(false); }); a && a.addEventListener("change", function () { a.checked && e.toggleChildFitOptions(true); }); }, syncRadioState: function () { var e = this.elements.radioYes, t = this.elements.radioNo; e && e.checked ? this.toggleChildFitOptions(false, false) : t && t.checked && this.toggleChildFitOptions(true, false); }, toggleChildFitOptions: function (e, t) { var s = this.elements.childFitOptions; if (!s) return; t === undefined && (t = true); if (typeof gsap !== "undefined" && t) { gsap.to(s, { autoAlpha: e ? 1 : 0, height: e ? "auto" : 0, duration: 0.5, ease: "power2.inOut", }); } else { s.style.display = e ? "block" : "none"; s.style.opacity = e ? "1" : "0"; s.style.height = e ? "auto" : "0"; s.style.visibility = e ? "visible" : "hidden"; } }, getURLParameters: function () { var e = {}, t = new URL(window.location.href), s = this; t.searchParams.forEach(function (t, a) { s.config.skipIntroParams.indexOf(a) === -1 && (e[a] = t); }); return e; }, updatePageURL: function () { var e = this.getURLParameters(), t = window.location.pathname.split("/").filter(function (e) { return e; }), s = t[t.length - 1] || "convertible", a = "https://www.safeintheseat.com/stage/" + s + "?results=submitted&", n = a + new URLSearchParams(e).toString(); this.elements.pageUrlInput && (this.elements.pageUrlInput.value = n); return n; }, initCheckboxHandler: function () { var e = this, t = this.elements.tosCheckbox; t && t.addEventListener("change", function () { t.checked && e.handleCheckboxChange(); }); }, handleCheckboxChange: function () { var e = this.updatePageURL(); this.elements.shortenedUrlInput && (this.elements.shortenedUrlInput.value = e); var t = document.querySelectorAll( 'input[data-ms-member="last-quiz-result"]', ); for (var s = 0; s < t.length; s++) { t[s].value = e; } this.updateProductResults(); this.updateBuyingKitContent(); }, getResultsList: function () { return ( this.elements.matchingSeatsList || document.querySelector(this.config.resultsListSelector) ); }, getSeatListItem: function (e, t) { var s = e; while (s && s !== t) { if ( s.getAttribute && (s.getAttribute("role") === "listitem" || (s.classList && s.classList.contains("w-dyn-item"))) ) { return s; } s = s.parentElement; } return e; }, isSeatItemHidden: function (e, t) { var s = this.getSeatListItem(e, t); while (s && s !== t) { if ( s.classList && (s.classList.contains("w-dyn-empty") || s.classList.contains("w-condition-invisible") || s.classList.contains("jetboost-hidden") || s.classList.contains("jetboost-list-item-hide")) ) { return true; } if ( s.hasAttribute && (s.hasAttribute("hidden") || s.getAttribute("aria-hidden") === "true") ) { return true; } var a = s.getAttribute ? s.getAttribute("style") || "" : ""; if (/display\s*:\s*none/i.test(a) || /visibility\s*:\s*hidden/i.test(a)) { return true; } if (window.getComputedStyle) { var n = window.getComputedStyle(s); if (n && (n.display === "none" || n.visibility === "hidden")) { return true; } } s = s.parentElement; } return false; }, getSeatName: function (e, t) { var s = this.getSeatListItem(e, t), a = [ ".naming_carseat-name", ".product-card_naming h3", '[class*="carseat-name"]', "h3", ], n, i, o, r; if (!s || !s.querySelector) return e.value || ""; for (n = 0; n < a.length; n++) { i = s.querySelector(a[n]); if (i && i.textContent && i.textContent.trim()) { o = i.textContent.replace(/\s+/g, " ").trim(); r = s.querySelector(".naming_variant-enabled"); if ( r && r.textContent && r.textContent.trim() && !(r.classList && r.classList.contains("w-dyn-bind-empty")) ) { o += " - " + r.textContent.replace(/\s+/g, " ").trim(); } return o; } } return e.value || ""; }, getProductResultsData: function () { var e = this.getResultsList(), t = [], s = [], a, n; if (!e) { return { values: [], names: [], quantity: 0 }; } a = e.querySelectorAll(".jetboost-list-item"); for (n = 0; n < a.length; n++) { if (!this.isSeatItemHidden(a[n], e) && a[n].value) { t.push(a[n].value); s.push(this.getSeatName(a[n], e)); } } return { values: t, names: s, quantity: t.length }; }, updateProductResults: function () { var e = this.getProductResultsData(), t = e.values.join(","); this.elements.seatResultsInput && (this.elements.seatResultsInput.value = t); this.elements.quantityResultsInput && (this.elements.quantityResultsInput.value = e.quantity); return e; }, numberToWords: function (e) { e = parseInt(e, 10); if (isNaN(e) || e < 0) e = 0; var t = [ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", ], s = [ "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", ], a = [ "", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety", ]; if (e < 10) return t[e]; if (e < 20) return s[e - 10]; if (e < 100) { return a[Math.floor(e / 10)] + (e % 10 ? "-" + t[e % 10] : ""); } if (e < 1000) { return ( t[Math.floor(e / 100)] + " hundred" + (e % 100 ? " " + this.numberToWords(e % 100) : "") ); } if (e < 1000000) { return ( this.numberToWords(Math.floor(e / 1000)) + " thousand" + (e % 1000 ? " " + this.numberToWords(e % 1000) : "") ); } return String(e); }, getBuyingKitStageLabel: function () { var e = window.location.pathname.split("/").filter(function (e) { return e; }), t = (e[e.length - 1] || "").toLowerCase(), s = this.config.buyingKitStageLabels[t], a; if (s) return s; a = document.getElementById("Stages"); if (a && a.value) { t = a.value.toLowerCase(); if (t.indexOf("booster") > -1 || t.indexOf("forward-facing") > -1) { return "Forward-Facing/Booster"; } return a.value; } return t ? t.replace(/-/g, " ").replace(/\b\w/g, function (e) { return e.toUpperCase(); }) : ""; }, getQuizEmail: function () { var e = [ "#quiz-email-submission-trigger", 'form[data-form="multistep"] input[type="email"]', 'form.form1_form input[type="email"]', 'input[data-ms-member="email"]', ], t, s, a; for (t = 0; t < e.length; t++) { s = document.querySelector(e[t]); if (s && s.value && s.value.trim()) { a = s.value.trim(); this.buyingKitEmail = a; return a; } } return this.buyingKitEmail || ""; }, setTextForSelector: function (e, t) { var s = document.querySelectorAll(e), a; for (a = 0; a < s.length; a++) { s[a].textContent = t; } }, getInputByName: function (e, t) { var s = e.querySelectorAll("input"), a; for (a = 0; a < s.length; a++) { if (s[a].name === t) return s[a]; } return null; }, ensureBuyingKitHiddenField: function (e, t, s, a) { var n = e.querySelector('input[data-bk-hidden-field="' + t + '"]') || e.querySelector("input." + a) || this.getInputByName(e, s); if (!n) { n = document.createElement("input"); n.type = "hidden"; n.name = s; n.className = a; e.appendChild(n); } n.type = "hidden"; n.name = n.name || s; n.setAttribute("data-name", n.getAttribute("data-name") || s); n.setAttribute("data-bk-hidden-field", t); return n; }, ensureBuyingKitHiddenInputs: function () { var e = document.querySelectorAll(".bk_form"), t; for (t = 0; t < e.length; t++) { this.ensureBuyingKitHiddenField( e[t], "email", "Email Address", "bk_email-input", ); this.ensureBuyingKitHiddenField( e[t], "stage", "Buying Kit Stage", "bk_stage-input", ); this.ensureBuyingKitHiddenField( e[t], "quantity", "Quantity Results", "bk_quantity-input", ); this.ensureBuyingKitHiddenField( e[t], "time-to-complete", "Time To Complete", "bk_time-to-complete-input", ); this.ensureBuyingKitHiddenField( e[t], "seat-names", "Seat Names", "bk_seat-names-input", ); } }, updateBuyingKitHiddenFields: function (e, t, s, a, n) { var i = document.querySelectorAll(".bk_form"), o, r, l, u, c, d; for (o = 0; o < i.length; o++) { r = this.ensureBuyingKitHiddenField( i[o], "email", "Email Address", "bk_email-input", ); l = this.ensureBuyingKitHiddenField( i[o], "stage", "Buying Kit Stage", "bk_stage-input", ); u = this.ensureBuyingKitHiddenField( i[o], "quantity", "Quantity Results", "bk_quantity-input", ); c = this.ensureBuyingKitHiddenField( i[o], "time-to-complete", "Time To Complete", "bk_time-to-complete-input", ); d = this.ensureBuyingKitHiddenField( i[o], "seat-names", "Seat Names", "bk_seat-names-input", ); r.value = e || ""; l.value = t || ""; u.value = s || "0"; c.value = a || ""; d.value = n || ""; } }, getBuyingKitTimeToComplete: function () { var e = this.elements.timeToCompleteInput || document.getElementById("time-to-complete"); if (e && e.value) { this.buyingKitTimeToComplete = e.value; } return this.buyingKitTimeToComplete || ""; }, updateBuyingKitContent: function () { var e = this.getProductResultsData(), t = this.getBuyingKitStageLabel(), s = this.getQuizEmail(), a = e.quantity, n = Math.max(a - 1, 0), i = this.getBuyingKitTimeToComplete(), o = e.names.join(", "); this.setTextForSelector(".bk_stage", t); this.setTextForSelector(".bk_quantity", this.numberToWords(a)); this.setTextForSelector(".bk_number-minus-1", this.numberToWords(n)); this.setTextForSelector(".bk_email, .bk-email, #bk-email", s || "[EMAIL]"); this.updateBuyingKitHiddenFields(s, t, a, i, o); return { stage: t, email: s, quantity: a, quantityMinusOne: n, timeToComplete: i, seatNames: e.names, }; }, initBuyingKitWaitlist: function () { var e = this, t = document.querySelectorAll( '#quiz-email-submission-trigger, form[data-form="multistep"] input[type="email"], form.form1_form input[type="email"], input[data-ms-member="email"]', ), s = document.querySelectorAll(".bk_form"), a; this.ensureBuyingKitHiddenInputs(); for (a = 0; a < t.length; a++) { if (t[a].dataset && t[a].dataset.bkEmailListener) continue; t[a].dataset && (t[a].dataset.bkEmailListener = "true"); t[a].addEventListener("input", function () { e.updateBuyingKitContent(); }); t[a].addEventListener("change", function () { e.updateBuyingKitContent(); }); } for (a = 0; a < s.length; a++) { if (s[a].dataset && s[a].dataset.bkSubmitListener) continue; s[a].dataset && (s[a].dataset.bkSubmitListener = "true"); s[a].addEventListener("submit", function () { e.updateBuyingKitContent(); }); } }, getBuyingKitModal: function () { return ( this.elements.buyingKitModal || document.querySelector( '[data-modal-target="' + this.config.buyingKitModalTarget + '"]', ) ); }, getBuyingKitModalDelay: function () { var e = this.getBuyingKitModal(), t = e ? parseFloat(e.getAttribute("data-modal-delay")) : NaN; if (isNaN(t)) t = this.config.buyingKitDefaultDelay; if (t < 0) t = 0; return t < 1000 ? t * 1000 : t; }, openBuyingKitModal: function () { var e = this.getBuyingKitModal(), t = this.config.buyingKitModalTarget; if (!e || e.open) return; if ( window.lumos && window.lumos.modal && typeof window.lumos.modal.open === "function" ) { window.lumos.modal.open(t); } if (e.open) return; if (typeof e.showModal === "function") { try { e.showModal(); } catch (s) { e.setAttribute("open", ""); } } else { e.setAttribute("open", ""); } }, startBuyingKitModalTimer: function () { var e = this, t = this.getBuyingKitModalDelay(); this.updateBuyingKitContent(); if (!this.getBuyingKitModal()) return; this.buyingKitTimer && clearTimeout(this.buyingKitTimer); this.buyingKitTimer = setTimeout(function () { e.updateBuyingKitContent(); e.openBuyingKitModal(); }, t); }, calculateTimeToComplete: function () { if (this.startTime === null) return 0; var e = Date.now(); var t = Math.round((e - this.startTime) / 1000); return t; }, getQuizForms: function () { var e = document.querySelectorAll( 'form[data-form="multistep"], form.form1_form, #wf-form-CSFT-2026', ), t = [], s, a, n; for (s = 0; s < e.length; s++) { if (t.indexOf(e[s]) === -1) t.push(e[s]); } if (!t.length) { a = this.elements.quizEmailInput || document.querySelector("#quiz-email-submission-trigger"); n = a && a.closest ? a.closest("form") : null; n && t.push(n); } return t; }, initFormSubmission: function () { var e = this, t = this.getQuizForms(); for (var s = 0; s < t.length; s++) { if (t[s].dataset && t[s].dataset.sitsQuizSubmitListener) continue; t[s].dataset && (t[s].dataset.sitsQuizSubmitListener = "true"); t[s].addEventListener("submit", function () { // Calculate and store time to complete var t = e.calculateTimeToComplete(); var s = e.elements.timeToCompleteInput || document.getElementById("time-to-complete"); e.buyingKitTimeToComplete = t; if (s) { s.value = t; } e.updateProductResults(); e.updateBuyingKitContent(); e.startBuyingKitModalTimer(); e.watchForSuccess(); }); } }, watchForSuccess: function () { var e = this, t = new MutationObserver(function (s, a) { document.querySelector(".results-submitted") && (a.disconnect(), setTimeout(function () { e.triggerResultsBlock(); }, e.config.successTriggerDelay)); }); t.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ["class", "style"], }); setTimeout(function () { t.disconnect(); }, this.config.successCheckTimeout); }, triggerResultsBlock: function () { var e = this.elements.resultsTriggerBlock || document.querySelector(".results-trigger-block"); e && e.click(); }, }; document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", function () { e.init(); }) : e.init(); window.SITSQuiz = e; })();