(()=>{"use strict";function e(e){if("undefined"!=typeof document){if("complete"!==document.readyState&&"interactive"!==document.readyState)return document.addEventListener("DOMContentLoaded",e);e()}}const t={generic:[(e,t)=>t.hasAttribute("required")?((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&0===t.value.length&&(e=[...e,r("generic","required")]),e):e]};function n(e,n){var r;t[e]=null!==(r=t[e])&&void 0!==r?r:[],t[e]=n?[...t[e],n]:t[e]}function r(e,t){var n,r,o,i;return window.NelioFormsErrorMessages&&((null===(r=null===(n=window.NelioFormsErrorMessages)||void 0===n?void 0:n[e])||void 0===r?void 0:r[t])||(null===(i=null===(o=window.NelioFormsErrorMessages)||void 0===o?void 0:o.generic)||void 0===i?void 0:i.unknown))||"Unknown error"}const o=function(){let e=0;return(...n)=>{const r=()=>{(e=>{var n,r;const o=(e=>{var t;return e.dataset.fieldType||(null!==(t=Array.from(e.classList).filter(e=>e.includes("__value--")&&!e.includes("required"))[0])&&void 0!==t?t:"").split("--")[1]||""})(e);if(void 0===t[o])return;const i=[...null!==(n=t.generic)&&void 0!==n?n:[],...null!==(r=t[o])&&void 0!==r?r:[]],l=(e=>{var t;const n=document.getElementById(null!==(t=e.id.split("__")[0])&&void 0!==t?t:"");return n instanceof HTMLFormElement?n:null})(e);if(!l)return;const d=(e=>e.id.split("__")[1]||"")(e);!function(e,t,n){const r=function(e,t){return document.getElementById(`${e.id}__${t}`)||void 0}(e,t);if(!r)return;const o=function(e,t){return document.getElementById(`${e.id}__${t}-error`)||function(e,t){var n,r,o;const i=document.createElement("label");i.setAttribute("id",`${e.id}__${t}-error`),i.setAttribute("for",`${e.id}__${t}`),i.classList.add("nelio-forms-field__error-label");const l=null===(n=document.getElementById(`${e.id}__${t}`))||void 0===n?void 0:n.parentElement;return(null===(r=null==l?void 0:l.classList)||void 0===r?void 0:r.contains("nelio-forms-field__value-container"))?null===(o=null==l?void 0:l.parentNode)||void 0===o||o.appendChild(i):null==l||l.appendChild(i),i}(e,t)}(e,t);r.classList.remove("nelio-forms-field__value--error"),o.innerHTML="",n.length&&(r.classList.add("nelio-forms-field__value--error"),n.forEach(e=>{const t=document.createElement("div");t.textContent=e,o.appendChild(t)}))}(l,d,i.reduce((t,n)=>n(t,e),[]))})(...n),e=0};if(e)return clearTimeout(e),void(e=setTimeout(r,0));e=setTimeout(r,0)}}();e(()=>Array.from(document.querySelectorAll(".nelio-forms-field__value")).forEach(e=>(e=>{e.addEventListener("keyup",()=>o(e)),e.addEventListener("change",()=>o(e)),e.addEventListener("blur",()=>o(e))})(e)));const i=/^[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i,l=/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i;n("tel"),n("text"),n("email",function(e,t){const n=t;return 0===n.value.length||i.test(n.value)||(e=[...e,r("email","invalid")]),e}),n("url",function(e,t){const n=t;return 0===n.value.length||l.test(n.value)||(e=[...e,r("url","invalid")]),e}),n("password",function(e,t){const n=t;if(n.dataset.matchField){const t=document.getElementById(n.dataset.matchField);0!==n.value.length&&0!==(null==t?void 0:t.value.length)&&n.value!==(null==t?void 0:t.value)&&(e=[...e,r("password","do-not-match")])}return e}),e(()=>Array.from(document.querySelectorAll(".nelio-forms-form input[type=url]")).forEach(e=>e.addEventListener("change",()=>{const t=e,n=t.value;n&&"http://"!==n.substring(0,7)&&"https://"!==n.substring(0,8)&&(t.value="https://"+n)})))})();