/** One shared client for generated and preserved contact forms. Lazy challenge keeps resting layouts intact. */ export declare const leadsJs = "(() => {\n let challengeScript;\n const loadChallenge = () => {\n if (window.turnstile) return Promise.resolve(window.turnstile);\n if (!challengeScript) challengeScript = new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = 'https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit';\n script.onload = () => window.turnstile ? resolve(window.turnstile) : reject(new Error('challenge_unavailable'));\n script.onerror = () => { script.remove(); challengeScript = null; reject(new Error('challenge_unavailable')); };\n document.head.append(script);\n });\n return challengeScript;\n };\n document.querySelectorAll('form[data-lead-form][data-vitris-enhanced]').forEach(form => {\n // Named controls can shadow native form properties and methods.\n const data = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'dataset').get.call(form);\n const setAttribute = Element.prototype.setAttribute.bind(form);\n const removeAttribute = Element.prototype.removeAttribute.bind(form);\n const querySelectorAll = Element.prototype.querySelectorAll.bind(form);\n if (data.vitrisInitialized) return;\n data.vitrisInitialized = '1';\n let submitting = false, key, signature, widget, token = '', challengeResolve, challengeReject, completedSignature;\n const note = document.createElement('p'); note.className = 'c-lead-status';\n note.setAttribute('role', 'status'); note.setAttribute('aria-live', 'polite'); note.tabIndex = -1;\n note.style.display = 'none'; Element.prototype.after.call(form, note);\n const say = (message, error = false) => {\n note.style.display = ''; note.setAttribute('role', error ? 'alert' : 'status'); note.textContent = message;\n if (error) note.focus();\n };\n let challengeBox;\n const challenge = async () => {\n const api = await loadChallenge();\n if (challengeBox) challengeBox.style.display = '';\n if (token) return token;\n if (!challengeBox) { challengeBox = document.createElement('div'); challengeBox.className = 'vitris-challenge'; challengeBox.setAttribute('aria-label', 'Security verification'); Element.prototype.append.call(form, challengeBox); }\n return new Promise((resolve, reject) => {\n challengeResolve = resolve; challengeReject = reject;\n if (widget !== undefined) api.reset(widget);\n else widget = api.render(challengeBox, {\n sitekey: data.vitrisSitekey, action: data.vitrisAction,\n callback: value => { token = value; challengeResolve?.(value); },\n 'expired-callback': () => { token = ''; if (submitting) say('Security check expired. Please submit again.', true); challengeReject?.(new Error('challenge_expired')); },\n 'timeout-callback': () => { token = ''; challengeReject?.(new Error('challenge_expired')); },\n 'error-callback': () => { token = ''; challengeReject?.(new Error('challenge_unavailable')); }\n });\n });\n };\n EventTarget.prototype.addEventListener.call(form, 'submit', async event => {\n if (event.defaultPrevented) return;\n event.preventDefault(); if (submitting) return;\n if (!HTMLFormElement.prototype.reportValidity.call(form)) return;\n const values = new URLSearchParams(new FormData(form));\n values.delete('cf-turnstile-response'); values.delete('idempotency_key');\n const current = values.toString();\n if (current === completedSignature) { say('Your message was already accepted.'); return; }\n if (!data.vitrisForm || !data.vitrisSitekey) { say('This preview does not send messages. Please use the listed contact details.', true); return; }\n if (current !== signature) { key = crypto.randomUUID(); signature = current; }\n submitting = true;\n const controls = [...querySelectorAll('button[type=\"submit\"], button:not([type]), input[type=\"submit\"], [data-vitrisid=\"emailSendButton\"]')];\n const prior = controls.map(c => c.disabled);\n controls.forEach(c => { c.disabled = true; c.setAttribute('aria-disabled', 'true'); }); setAttribute('aria-busy', 'true');\n let timeout;\n try {\n say('Please complete the security check.');\n const challengeTimeout = new Promise((_, reject) => { timeout = setTimeout(() => reject(new Error('challenge_unavailable')), 120000); });\n const verified = await Promise.race([challenge(), challengeTimeout]);\n clearTimeout(timeout);\n values.set('cf-turnstile-response', verified); values.set('idempotency_key', key);\n say('Sending your inquiry\u2026');\n const controller = new AbortController();\n timeout = setTimeout(() => controller.abort(), Math.max(100, Math.min(30000, Number(data.leadTimeoutMs) || 10000)));\n const response = await fetch(Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, 'action').get.call(form), { method:'POST', body:values, headers:{accept:'application/json'}, signal:controller.signal, credentials:'omit' });\n const result = response.headers.get('content-type')?.includes('application/json') ? await response.json() : null;\n if (!response.ok || result?.ok !== true) throw new Error(result?.error || 'backend_unavailable');\n say(result.mode === 'test' ? 'Test message accepted. No customer email will be sent.' : 'Message accepted. Your inquiry has been saved.');\n completedSignature = current;\n if (challengeBox) challengeBox.style.display = 'none';\n } catch (error) {\n const messages = {\n challenge_required:'Please complete the security check and try again.',\n challenge_invalid:'Security check expired or was invalid. Please try again.',\n challenge_replayed:'Security check was already used. Please try again.',\n challenge_expired:'Security check expired. Please try again.',\n challenge_unavailable:'Security check is unavailable. Please try again or use the listed contact details.',\n rate_limited:'Too many attempts. Please wait ten minutes and try again.',\n validation_error:'Please check your form fields and try again.',\n form_disabled:'This form is currently unavailable. Please use the listed contact details.',\n configuration_unavailable:'This form is currently unavailable. Please use the listed contact details.',\n idempotency_conflict:'This request changed during a retry. Please edit your message and try again.'\n };\n say(error?.name === 'AbortError' ? 'The request timed out. Your message is still here; please try again.' : (messages[error?.message] || 'Acceptance could not be confirmed. Your details are still here; please try again or use the listed contact options.'), true);\n if (challengeBox) challengeBox.style.display = '';\n } finally {\n clearTimeout(timeout); token = ''; challengeResolve = null; challengeReject = null;\n if (window.turnstile && widget !== undefined) window.turnstile.reset(widget);\n controls.forEach((c, i) => { c.disabled = prior[i]; c.removeAttribute('aria-disabled'); });\n removeAttribute('aria-busy'); submitting = false;\n }\n });\n });\n})();";