1"use strict";function _defineProperty(t,e,s){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==typeof e?e:e+""}function _toPrimitive(t,e){if("object"!=typeof t||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var r=s.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}window.addEventListener("DOMContentLoaded",()=>{validate.validators.creditCard=((t,e,r,o)=>{if(!t||!s.validate_credit_card(t))return"^"+s.options.messages.INVALID_CARD_NUMBER}),validate.validators.iso=((t,e,s,r)=>{if(!/^[\x20-\x7E\xA0-\xA3\xA5\xA7\xA9-\xB3\xB5-\xB7\xB9-\xBB\xBF-\xFF\u20AC\u0160\u0161\u017D\u017E\u0152\u0153\u0178]*$/.test(t))return"^"+it("LATIN_CHARACTERS_ONLY")}),validate.validators.username=((t,e,s,r)=>{if(!/^[a-zA-Z0-9_.-]+$/.test(t))return"^"+messages.MANDATORY_FIELD}),validate.validators.phone=((t,e,r,o)=>{if(!t||!s.validate_phone_number(t)[0])return"^"+s.options.messages.ERROR_VALID_NUMBER}),validate.validators.regex=((t,e,s,r)=>{if(e.regexp&&(!t||!new RegExp(e.regexp,"i").test(t)))return"^Invalid pattern"}),validate.validators.over18=((t,e,s,r)=>{const o=new Date(t),i=new Date;i.toLocaleString("en-US",{timeZone:"America/New_York"});const n=i.getFullYear()-o.getFullYear();if(!(n>18)){if(18===n){const t=o.getMonth(),e=i.getMonth();if(t>e)return;if(e===t){const t=i.getDate();if(o.getDate()>=t)return}}return"^You must be 18 years old or older to proceed."}}),validate.validators.uniqueness=((t,e,r,o)=>new Promise(function(r,o){var i,n,a,l,d,c,u,h;if(!t)return r("^"+s.options.messages.MANDATORY_FIELD);if(validate({email:t},{email:{email:!0}}))return r("^"+s.options.messages.ERROR_INVALID_EMAIL);let m=new FormData;m.append("email",t),m.append("action","validate_email");const p=(null==e?void 0:null===(i=e.form)||void 0===i?void 0:null===(n=i.querySelector('[name="_token"]'))||void 0===n?void 0:n.value)||(null===(a=document.querySelector('[name="_token"]'))||void 0===a?void 0:a.value),f=(null==e?void 0:null===(l=e.form)||void 0===l?void 0:null===(d=l.querySelector('[name="_snowman"]'))||void 0===d?void 0:d.value)||(null===(c=document.querySelector('[name="_snowman"]'))||void 0===c?void 0:c.value),v=(null==e?void 0:null===(u=e.form)||void 0===u?void 0:null===(h=u.querySelector('[name^="_nothing_"]'))||void 0===h?void 0:h.getAttribute("name"))||document.querySelector('[name^="_nothing_"]').getAttribute("name");m.append("_token",p),m.append("_snowman",f),m.append(v,"");try{s.common.fetcher(s.url("account/process_register"),{method:"POST",body:m}).ready.then(t=>{"true"==t||1==t?(e.onComplete&&e.onComplete(t),r()):r("^"+s.options.messages.ERROR_INVALID_EMAIL)})}catch(t){r("^"+s.options.messages.ERROR_INVALID_EMAIL)}})),validate.validators.passwordStrongSecurity=function(t,e,r,o){let i=0;const n="^"+s.options.messages.ERROR_ENTER_STRONG_PASSWORD;return t?([/.{8,}/,/([a-z].*[A-Z])|([A-Z].*[a-z])/,/([0-9])/,/([^\w\s])/].forEach((e,s)=>{e.test(t)&&i++}),4===i?void 0:n):n}});class FormValidator{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};_defineProperty(this,"isElementVisible",t=>!!t&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)),this.options={errorClass:"js-has-error",isInvalid:"is-invalid",customCssError:[],blockError:"js-help-block-error",errorMessageContainerElement:"label",errorMessageContainer:"js-error-message",inputContainer:"form-group",formSubmitHandler:!1,beforeSubmitHandler:!1,showAllErrors:!1,autoTrim:[],isStarted:!1,hasErrorContainer:!1,errorHandler:!1,clearDisabledStatusOnButton:!1,onSubmitDisableTriggers:!1,scrollAndFocus:!0,ignoreIsHiddenInputs:!0,isAttachEventOnConstraints:!1,event:null,...t},this.form=null,this.constraints=null,this.seenInputs=[],validate.validators.presence.message="^"+s.options.messages.MANDATORY_FIELD,validate.validators.email.message="^"+s.options.messages.ERROR_INVALID_EMAIL}start(t,e){"string"==typeof t&&(t=document.getElementById(t)),t&&(this.form=t,this.constraints=e,t.addEventListener("submit",e=>{e.preventDefault(),e.stopImmediatePropagation(),this.options.isStarted=!0,this.handleFormSubmit(t)}),this.onEventValidate(t,"input"))}onEventValidate(t,e){"string"==typeof t&&(t=document.getElementById(t));const s=t.querySelectorAll("input, textarea, select");for(let t=0;t<s.length;t++)this.addInputEventListener(s.item(t),e)}addInputEventListener(t,e){t.addEventListener(e,t=>{if(!this.options.isStarted&&-1==this.seenInputs.indexOf(t.target.name))return;-1!=this.options.autoTrim.indexOf(t.target.name)&&(t.target.value=t.target.value.trim());let e=this.constraints;
1this.options.ignoreIsHiddenInputs&&(e=this.getConstraintsNotHidden()),validate.async(validate.collectFormValues(this.form),e).then(()=>{if(this.resetForm(t.target),this.options.clearDisabledStatusOnButton){const t=this.form.querySelector('button[type="submit"]');t&&t.hasAttribute("disabled")&&t.removeAttribute("disabled")}}).catch(e=>{0===Object.keys(e).length&&this.resetForm(t.target),"password"===t.target.name&&(this.options.errorHandler?this.resetPasswordErrorCustomErrorHandler(t.target.name,e,this.form):this.resetPasswordErrorContainerInjection(t.target.name,e,this.form)),this.showErrorsForInput(t.target,e[t.target.name])})}),t.addEventListener("blur",e=>{let s=this.constraints;this.options.ignoreIsHiddenInputs&&(s=this.getConstraintsNotHidden());const r=t.value.trim();if(-1==this.seenInputs.indexOf(t.name)&&""===r||!s[t.name])return;let o={[t.name]:s[t.name]};if(s[t.name].equality){const e=s[t.name].equality.attribute;o[e]=s[e]}validate.async(validate.collectFormValues(this.form),o).then(()=>{this.resetInput(t)}).catch(e=>{this.seenInputs.push(t.name),this.showErrorsForInput(t,e[t.name])})})}addIndividualInputEventListener(t,e){t.addEventListener(e,e=>{if(!this.options.isStarted)return;-1!=this.options.autoTrim.indexOf(e.target.name)&&(e.target.value=e.target.value.trim());let s=this.constraints;if(this.options.ignoreIsHiddenInputs&&(s=this.getConstraintsNotHidden()),!s[t.name]&&(this.resetForm(),this.options.clearDisabledStatusOnButton)){const t=this.form.querySelector('button[type="submit"]');t&&t.hasAttribute("disabled")&&t.removeAttribute("disabled")}validate.async(validate.collectFormValues(this.form),{[t.name]:s[t.name]}).then(()=>{if(this.resetInput(t),this.options.clearDisabledStatusOnButton){const t=this.form.querySelector('button[type="submit"]');t&&t.hasAttribute("disabled")&&t.removeAttribute("disabled")}}).catch(t=>{this.showErrorsForInput(e.target,t[e.target.name])})})}handleFormSubmit(t){let e=this.constraints;this.options.ignoreIsHiddenInputs&&(e=this.getConstraintsNotHidden()),validate.async(validate.collectFormValues(t),e).then(()=>{this.submit(t)}).catch(e=>{this.showErrors(t,e||{}),null!=this&&this.options.clearSubmitButtonId&&(document.getElementById(null==this?void 0:this.options.clearSubmitButtonId).disabled=!1),this.scrollAndFocus()})}showErrors(t,e){t.querySelectorAll("input[name], select[name], textarea[name]").forEach(t=>{let s=t.getAttribute("name");e&&e[s]&&this.showErrorsForInput(t,e&&e[s])})}findErrorContainer(t){var e=t.nextSibling;1===e.nodeType&&"span"===e.tagName.toLowerCase()&&e.classList.contains(this.options.errorMessageContainer)&&e.remove(),e=e.nextSibling}showErrorsForInput(t,e){if(this.options.errorHandler){const s=this.getErrorHandlerContainer(t,e,this.form);this.options.errorHandler(t,e,this.form,s)}else if(this.options.hasErrorContainer){const s=this.closestParent(t.parentNode,this.options.inputContainer);if(!s)return;const r=s.querySelector(".".concat(this.options.errorMessageContainer));this.resetFormGroup(s),e&&(s.classList.add(this.options.errorClass),t.classList.add(this.options.isInvalid),this.options.showAllErrors&&1!==e.length?e.forEach(t=>{this.addError(r,t)}):this.addError(r,e[0]))}else{if(this.findErrorContainer(t),t.classList.remove(this.options.isInvalid),!e)return;let s=document.createElement("span");s.classList.add(this.options.errorMessageContainer),s.classList.add(this.options.blockError),s.id="js-name-".concat(t.name),t.classList.add(this.options.isInvalid),t.insertAdjacentElement("afterend",s),this.options.showAllErrors&&1!==e.length?e.forEach(t=>{this.addError(s,t)}):this.addError(s,e[0])}}getErrorHandlerContainer(t,e,s){const r=s.querySelector("#js-name-".concat(t.getAttribute("name")));if(r&&(t.classList.remove(this.options.isInvalid),r.remove()),!e)return;t.classList.add(this.options.isInvalid);let o,i=document.createElement("label");return i.classList.add(this.options.errorMessageContainer),i.id="js-name-".concat(t.getAttribute("name")),i.classList.add(this.options.isInvalid),i.classList.add(this.options.blockError),o=this.options.showAllErrors&&1!==e.length?document.createTextNode(e):document.createTextNode(e[0]),i.appendChild(o),i}closestParent(t,e){return t&&t!=document?t.classList.contains(e)?t:this.closestParent(t.parentNode,e):null}resetFormGroup(t){t.classList.contains(this.options.errorClass)&&(t.classList.remove(this.options.errorClass),t.querySelectorAll(".".concat(this.options.blockError)).forEac
1h(t=>{t.parentNode.removeChild(t)}),t.querySelectorAll(".".concat(this.options.isInvalid)).forEach(t=>{t.classList.remove(this.options.isInvalid)}))}resetForm(t){let e;(e=t?t.closest("form"):this.form).querySelectorAll(".".concat(this.options.blockError)).forEach(t=>{t.parentNode.removeChild(t)}),e.querySelectorAll(".".concat(this.options.errorMessageContainer)).forEach(t=>{t.parentNode.removeChild(t)}),e.querySelectorAll(".".concat(this.options.isInvalid)).forEach(t=>{t.classList.remove(this.options.isInvalid)}),e.querySelectorAll(".".concat(this.options.errorClass)).forEach(t=>{t.classList.remove(this.options.errorClass)})}resetInput(t){const e=document.getElementById("js-name-".concat(t.name));e&&e.remove(),t.classList.remove(this.options.isInvalid)}resetPasswordErrorContainerInjection(t,e,s){try{if("password"===t&&!e[t]&&!e.confirm_password&&1===s.querySelectorAll(".".concat(this.options.errorClass," input[name='confirm_password'].").concat(this.options.isInvalid)).length){let t=s.querySelectorAll(".".concat(this.options.errorClass," input[name='confirm_password'].").concat(this.options.isInvalid))[0].closest(".".concat(this.options.errorClass));t&&this.resetFormGroup(t)}if("password"===t&&!e[t]&&e.confirm_password&&0===s.querySelectorAll(".".concat(this.options.errorClass," input[name='confirm_password'].").concat(this.options.isInvalid)).length){let t=s.querySelectorAll('input[name="confirm_password"]')[0],r=t.closest(".form-group");if(r){r.classList.add(this.options.errorClass),r.classList.add(this.options.errorClass),t.classList.add(this.options.isInvalid),r.classList.add(this.options.errorClass),t.classList.add(this.options.isInvalid);let s=r.querySelector(".".concat(this.options.errorMessageContainer));this.addError(s,e.confirm_password)}t.classList.add(this.options.isInvalid)}}catch(t){console.log("ERROR",t)}}resetPasswordErrorCustomErrorHandler(t,e,s){try{if("password"!==t||e[t]||e.confirm_password){if("password"===t&&!e[t]&&e.confirm_password){if(s.querySelector("#js-name-confirm_password"))return;const t=s.querySelector('input[name="confirm_password"]');t.classList.add(this.options.isInvalid);let o=document.createElement("label");o.classList.add(this.options.errorMessageContainer),o.id="js-name-confirm_password",o.classList.add(this.options.isInvalid);var r=document.createTextNode(e.confirm_password);o.appendChild(r);const i=t.parentElement;i.classList.contains("input-group")?i.insertAdjacentElement("afterend",o):t.insertAdjacentElement("afterend",o)}}else{const t=s.querySelector("#js-name-confirm_password"),e=s.querySelector('input[name="confirm_password"]');t&&t.remove(),e&&e.classList.remove(this.options.isInvalid)}}catch(t){console.log("ERROR",t)}}addError(t,e){if(!t||!e)return;let s=document.createElement(this.options.errorMessageContainerElement);s.classList.add(this.options.blockError),s.classList.add(this.options.isInvalid),this.options.customCssError.forEach(t=>{s.classList.add(t)}),s.innerText=e,t.appendChild(s)}submit(t){this.options.event&&s.track.event(this.options.event.category,this.options.event.action,this.options.event.label);const{formSubmitHandler:e,beforeSubmitHandler:r,onSubmitDisableTriggers:o}=this.options;o&&this.disableSubmitTriggers(t),"function"==typeof r&&r(t),"function"==typeof e?e():t.submit()}ajaxValidate(t,e){if("string"==typeof t&&(t=document.getElementById(t)),this.form=t,this.constraints=e,!this.form||!this.constraints)return!1;let s=this.constraints;this.options.ignoreIsHiddenInputs&&(s=this.getConstraintsNotHidden());const r=validate(this.form,s);return this.resetForm(t),this.showErrors(t,r||{}),r&&this.scrollAndFocus(),r}hasErrors(){if(!this.form||!this.constraints)return!1;let t=this.constraints;this.options.ignoreIsHiddenInputs&&(t=this.getConstraintsNotHidden());const e=validate(this.form,t);return this.resetForm(this.form),this.showErrors(this.form,e||{}),e&&this.scrollAndFocus(),e}async hasErrorsAsync(){if(!this.form||!this.constraints)return!1;let t=this.constraints;this.options.ignoreIsHiddenInputs&&(t=this.getConstraintsNotHidden());let e=this;
1try{return await validate.async(validate.collectFormValues(this.form),t),this.resetForm(this.form),this.submit(this.form),!0}catch(t){return e.showErrors(e.form,t||{}),!1}}async hasErrorsAsyncAjax(){if(!this.form||!this.constraints)return!1;let t=this.constraints;this.options.ignoreIsHiddenInputs&&(t=this.getConstraintsNotHidden());let e=this;try{return await validate.async(validate.collectFormValues(this.form),t),this.resetForm(this.form),!0}catch(t){return e.showErrors(e.form,t||{}),!1}}setForm(t){this.form=t}setConstraints(t){this.constraints=t}setStarted(t){this.options.isStarted=t}addConstraints(t){this.constraints={...this.constraints,...t}}getConstraints(){return this.constraints}removeConstraints(t){if(this.constraints)for(let e in t)this.constraints.hasOwnProperty(e)&&delete this.constraints[e];else console.warn("removeConstraints cannot be removed because no constraints are present")}onlyErrors(t,e){"string"==typeof t&&(t=document.getElementById(t)),this.form=t,this.constraints=e,this.onEventValidate(t,"input")}removeConstraintsNotHidden(){let t=this.constraints;for(let e in t){const s=this.getInputByName(e);s&&"hidden"!==s.type&&!s.classList.contains("hidden")||delete t[e]}}getConstraintsNotHidden(){let t=Object.assign({},this.constraints);for(let e in t){const s=this.getInputByName(e);s&&"hidden"!==s.type&&!s.classList.contains("hidden")||delete t[e]}return t}getInputByName(t){const e=this.form.querySelectorAll("input, textarea, select");for(let s=0;s<e.length;s++)if(e.item(s).name===t)return e.item(s);return null}attachEventOnConstraints(t,e){if(!this.options.isAttachEventOnConstraints){this.options.isAttachEventOnConstraints=!0,"string"==typeof t&&(t=document.getElementById(t));for(let s in e){const e=t.querySelector('[name="'.concat(s,'"]'));e&&this.addIndividualInputEventListener(e,"input")}}}startIndividual(t,e){if("string"==typeof t&&(t=document.getElementById(t)),!t)return;this.form=t,this.constraints=e,t.addEventListener("submit",e=>{e.preventDefault(),e.stopImmediatePropagation(),this.options.isStarted=!0,this.handleFormSubmit(t)});const s=t.querySelectorAll("input, textarea, select");for(let t=0;t<s.length;t++)this.addIndividualInputEventListener(s.item(t),"input")}isElementInViewport(t){const e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}findPreviousInput(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,s=0;for(;t&&s<e;){let e=t.previousElementSibling;for(;e;){if("INPUT"===e.tagName)return e;e=e.previousElementSibling}t=t.parentElement,s++}return null}scrollAndFocus(){if(!this.options.scrollAndFocus)return;const t=this.form.querySelector(".".concat(this.options.errorMessageContainer));if(!t)return;this.isElementInViewport(t)||t.scrollIntoView({behavior:"smooth",block:"center"});const e=this.findPreviousInput(t);e&&e.focus()}disableSubmitTriggers(t){null==t||t.querySelectorAll("[type=submit]:not([name])").forEach(t=>{t.disabled=!0})}passwordStrongSecurityMeter(t,e){if("string"==typeof t&&(t=document.getElementById(t)),t){const r=t.querySelector('input[name="'.concat(e,'"]')),o=t.querySelector(".password-strength"),i=o.querySelector(".password-strength-message .text"),n=[...o.querySelector(".password-strength-progress").querySelectorAll(".bar")],a=[...o.querySelectorAll(".constrain")];r.addEventListener("input",t=>{!function(t){let e=0;const r=["danger","warning","success"],o=[s.it("PASSWORD_SECURITY_SCORE_EMPTY"),s.it("PASSWORD_SECURITY_SCORE_VERY_WEAK"),s.it("PASSWORD_SECURITY_SCORE_WEAK"),s.it("PASSWORD_SECURITY_SCORE_GOOD"),s.it("PASSWORD_SECURITY_SCORE_STRONG")],l=[/.{8,}/,/([a-z].*[A-Z])|([A-Z].*[a-z])/,/([0-9])/,/([^\w\s])/];t?(l.forEach((s,r)=>{const o=a[r],i=s.test(t);i&&e++,o.classList.toggle("color-danger",!i),o.querySelector(".icon-alert").classList.toggle("d-none",i),o.querySelector(".icon-check").classList.toggle("d-none",!i)}),n.forEach((t,s)=>{t.classList.remove(...r),0===e&&0===s&&t.classList.add(r[0]),s<e&&(e<3?t.classList.add(r[0]):3===e?t.classList.add(r[1]):t.classList.add(r[2]))}
1),i.innerHTML=0===e?o[1]:o[e]):(a.forEach(t=>{t.classList.remove("color-danger"),t.querySelector(".icon-alert").classList.remove("d-none"),t.querySelector(".icon-check").classList.add("d-none")}),n.forEach(t=>{t.classList.remove(...r)}),i.innerHTML=o[0])}(t.currentTarget.value)})}}} 2//# sourceMappingURL=form_validator.min.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.