­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ (()=>{"use strict";var t={n:e=>{var i=e&&e.__esModule?()=>e.default:()=>e;return t.d(i,{a:i}),i},d:(e,i)=>{for(var r in i)t.o(i,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:i[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const{Restriction:e,CalculatedFormula:i}=window.JetFormBuilderAbstract;function r(){e.call(this),this.message="",this.formula=null,this.watchedAttrs=[]}r.prototype=Object.create(e.prototype),r.prototype.message="",r.prototype.formula=null,r.prototype.watchedAttrs=[],r.prototype.isServerSide=function(){return!1},r.prototype.getMessage=function(){return this.message},r.prototype.getRawMessage=function(){return"Error"},r.prototype.getMessageBySlug=function(t){return function(t,e){var i,r,s,n;const{reporting:o}=t,a=null!==(i=o.messages[e])&&void 0!==i?i:"";if(a)return a;const u=null!==(r=window?.JetFormsValidation)&&void 0!==r&&r;if(!1===u)return"";const c=o.input.getSubmit(),{messages:l}=null!==(s=u[c.getFormId()])&&void 0!==s?s:{};return null!==(n=l[e])&&void 0!==n?n:""}(this,t)},r.prototype.onReady=function(){this.formula=new i(this.reporting.input),this.formula.observe(this.getRawMessage()),this.formula.setResult=()=>{this.message=this.formula.calculateString()},this.formula.setResult(),this.watchedAttrs.length&&(this.reporting.watchAttrs=[...new Set([...this.reporting.watchAttrs,...this.watchedAttrs])])};const s=r;function n(){s.call(this),this.watchedAttrs.push("max"),this.isSupported=function(t,e){const{max:i=!1}=e.input.attrs;return!1!==i&&["number","range"].includes(t.type)},this.validate=function(){const t=this.getValue(),{max:e}=this.reporting.input.attrs;return!t||+t<=+e.value.current},this.getRawMessage=function(){return this.getMessageBySlug("number_max")}}n.prototype=Object.create(s.prototype);const o=n;function a(){s.call(this),this.watchedAttrs.push("min"),this.isSupported=function(t,e){const{min:i=!1}=e.input.attrs;return!1!==i&&["number","range"].includes(t.type)},this.validate=function(){const t=this.getValue(),{min:e}=this.reporting.input.attrs;return!t||+t>=+e.value.current},this.getRawMessage=function(){return this.getMessageBySlug("number_min")}}a.prototype=Object.create(s.prototype);const u=a;function c(){s.call(this),this.isSupported=function(t){return"url"===t.type},this.validate=function(){const t=this.getValue();return!t||/((mailto\:|(news|(ht|f)tp(s?))\:\/\/)\S+)/.test(t)},this.getRawMessage=function(){return this.getMessageBySlug("url")}}c.prototype=Object.create(s.prototype);const l=c;function h(){s.call(this),this.isSupported=function(t){return"email"===t.type},this.validate=function(){const t=this.getValue();return!t||/^[\w-\.\+]+@([\w-]+\.)+[\w-]{1,6}$/.test(t)},this.getRawMessage=function(){return this.getMessageBySlug("email")}}h.prototype=Object.create(s.prototype);const p=h;function d(){s.call(this),this.watchedAttrs.push("minLength"),this.isSupported=function(t,e){const{minLength:i=!1}=e.input.attrs;return!1!==i},this.validate=function(){const t=this.getValue()?.length,{minLength:e}=this.reporting.input.attrs;return!t||t>=+e.value.current},this.getRawMessage=function(){return this.getMessageBySlug("char_min")}}d.prototype=Object.create(s.prototype);const g=d;function f(){s.call(this),this.watchedAttrs.push("maxLength"),this.isSupported=function(t,e){const{maxLength:i=!1}=e.input.attrs;return!1!==i},this.validate=function(){const t=this.getValue()?.length,{maxLength:e}=this.reporting.input.attrs;return!t||t<=+e.value.current},this.getRawMessage=function(){return this.getMessageBySlug("char_max")}}f.prototype=Object.create(s.prototype);const m=f,{isEmpty:y}=JetFormBuilderFunctions;function v(){s.call(this),this.type="required"}v.prototype=Object.create(s.prototype),v.prototype.isSupported=function(t,e){return e.input.isRequired},v.prototype.validate=function(){const t=this.getValue();return!y(t)},v.prototype.getRawMessage=function(){return this.getMessageBySlug("empty")};const S=v;function b(){s.call(this),this.isSupported=function(t){return t.classList.contains("jet-form-builder__masked-field")&&jQuery.fn.inputmask},this.validate=function(){const t=this.getValue(),e=this.reporting.getNode();return!t||e.inputmask.isComplete()},this.getRawMessage=function(){return this.getMessageBySlug("inputmask")}}b.prototype=Object.create(s.prototype);const w=b;function j(){s.call(this),this.isSupported=function(t,e){var i;const r=t.closest(".jet-form-builder-row"),s=JSON.parse(null!==(i=r.dataset?.validationRules)&&void 0!==i?i:"[]");return!!Boolean(s.length)&&(e.restrictions=[...e.restrictions,...X(s,e)],!1)}}j.prototype=Object.create(s.prototype);const _=j;function R(){s.call(this),this.attrs={}}R.prototype=Object.create(s.prototype),R.prototype.attrs={},R.prototype.setAttrs=function(t){this.attrs=t},R.prototype.getSlug=function(){throw new Error("you need to return slug of rule")},R.prototype.getRawMessage=function(){var t;return null!==(t=this.attrs?.message)&&void 0!==t?t:""};const P=R;function A(){P.call(this),this.getSlug=function(){return"contain"}}A.prototype=Object.create(P.prototype),A.prototype.setAttrs=function(t){P.prototype.setAttrs.call(this,t),Z.call(this)},A.prototype.validate=function(){const t=this.getValue();return!t||t.includes(this.attrs.value)};const O=A;function B(){O.call(this),this.getSlug=function(){return"contain_not"},this.validate=function(){return!this.getValue()||!O.prototype.validate.call(this)}}B.prototype=Object.create(O.prototype);const V=B;function x(){P.call(this),this.getSlug=function(){return"regexp"}}x.prototype=Object.create(P.prototype),x.prototype.setAttrs=function(t){P.prototype.setAttrs.call(this,t),Z.call(this)},x.prototype.validate=function(){const t=this.getValue();return!t||new RegExp(this.attrs.value,"g").test(t)};const M=x;function F(){M.call(this),this.getSlug=function(){return"regexp_not"},this.validate=function(){return!this.getValue()||!M.prototype.validate.call(this)}}F.prototype=Object.create(M.prototype);const E=F,k=window.wp.apiFetch;var L=t.n(k);function N(){P.call(this),this.getSlug=function(){return"ssr"},this.isServerSide=function(){return!0},this.validatePromise=async function(t=null){if(!this.getValue())return Promise.resolve();const e=this.getFormData(),{rootNode:i}=this.reporting.input.getRoot();switch(i.getAttribute("ssr_validation_method")||"rest"){case"admin_ajax":return this.validateViaAdminAjax(e,t);case"self":return this.validateViaSelfRequest(e,t);default:return this.validateViaRest(e,t)}},this.validateViaRest=async function(t,e){try{const i=await L()({path:"/jet-form-builder/v1/validate-field",method:"POST",body:t,signal:e});return i?.result?Promise.resolve():Promise.reject()}catch(t){throw t}},this.validateViaAdminAjax=async function(t,e){try{const i=await fetch(window.JetFormBuilderSettings.adminajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"jet_fb_ssr_validation_ajax",data:JSON.stringify(Object.fromEntries(t))}),signal:e}).then((t=>t.json()));return i?.result?Promise.resolve():Promise.reject()}catch(t){throw t}},this.validateViaSelfRequest=async function(t,e){try{const i=new URL(window.location.href);i.searchParams.set("jet_fb_ssr_self_validation","1");for(const[e,r]of t.entries())i.searchParams.append(e,r);const r=await fetch(i.toString(),{method:"GET",signal:e}).then((t=>t.json()));return r?.result?Promise.resolve():Promise.reject()}catch(t){throw t}},this.getFormData=function(){const{input:t}=this.reporting,{rootNode:e}=t.getRoot(),i=new FormData(e);i.delete("_wpnonce"),i.set("_jfb_validation_rule_index",this.attrs.index);for(const e of t.path)i.append("_jfb_validation_path[]",e);return this.attrs._sig&&i.set("_jfb_validation_sig",this.attrs._sig),i}}N.prototype=Object.create(P.prototype);const J=N;function T(){P.call(this),this.getSlug=function(){return"equal"},this.validate=function(){const t=this.getValue();return!t||t===this.attrs.value}}T.prototype=Object.create(P.prototype),T.prototype.setAttrs=function(t){P.prototype.setAttrs.call(this,t),Z.call(this)};const C=T,{getTimestamp:q}=JetFormBuilderFunctions;function I(){s.call(this),this.watchedAttrs.push("min"),this.isSupported=function(t,e){const{min:i=!1}=e.input.attrs;return!1!==i&&["time","date","datetime-local"].includes(t.type)},this.validate=function(){const t=this.getValue();if(!t)return!0;const{min:e}=this.reporting.input.attrs,{time:i}=q(t),{time:r}=q(e.value.current);return i>=r},this.getRawMessage=function(){return this.getMessageBySlug("date_min")}}I.prototype=Object.create(s.prototype);const D=I,{getTimestamp:H}=JetFormBuilderFunctions;function U(){s.call(this),this.watchedAttrs.push("max"),this.isSupported=function(t,e){const{max:i=!1}=e.input.attrs;return!1!==i&&["time","date","datetime-local"].includes(t.type)},this.validate=function(){const t=this.getValue();if(!t)return!0;const{max:e}=this.reporting.input.attrs,{time:i}=H(t),{time:r}=H(e.value.current);return i<=r},this.getRawMessage=function(){return this.getMessageBySlug("date_max")}}U.prototype=Object.create(s.prototype);const G=U,{applyFilters:Q}=JetPlugins.hooks,{isEmpty:$}=JetFormBuilderFunctions,z=()=>Q("jet.fb.advanced.rules",[O,V,M,E,J,C]);let K=[],W=[];function X(t,e){const i=[];K.length||(K=z());for(const[r,s]of Object.entries(t))for(const t of K){const n=new t;if(s.type===n.getSlug()){delete s.type,n.setReporting(e),n.setAttrs({...s,index:r}),n.onReady(),i.push(n);break}}return i}function Y(t){return t.closest(".jet-form-builder-row")}function Z(){if(!this.attrs?.field)return;const{root:t}=this.reporting.input,e=t.getInput(this.attrs.field);e.watch((()=>{this.attrs.value=e.value.current,this.reporting.valuePrev=null,this.reporting.validateOnChange()})),$(e.value.current)||(this.attrs.value=e.value.current)}function tt(t){for(const e of t.children)if(e.classList.contains("error-message"))return e;const e=t.querySelector(".jet-form-builder-col__end");return!!e&&tt(e)}const{ReportingInterface:et}=JetFormBuilderAbstract,{allRejected:it}=JetFormBuilderFunctions;function rt(){et.call(this),this.type="inherit",this.messages={},this.skipServerSide=!0,this.watchAttrs=[],this.queue=[]}rt.prototype=Object.create(et.prototype),rt.prototype.skipServerSide=!0,rt.prototype.hasServerSide=!1,rt.prototype.isProcess=null,rt.prototype.queue=[],rt.prototype.setRestrictions=function(){!function(t){W.length||(W=Q("jet.fb.restrictions",[D,G,o,u,l,p,w,g,m,S,_]));for(const e of W){const i=new e;i.isSupported(t.getNode(),t)&&(i.setReporting(t),i.onReady(),t.restrictions.push(i))}}(this)},rt.prototype.isSupported=function(t,e){this.type=function(t){var e;const i=Y(t),{validationType:r=""}=null!==(e=i?.dataset)&&void 0!==e?e:{};return r}(t);const i="inherit"===this.type?function(t){var e,i;const r=null!==(e=window?.JetFormsValidation)&&void 0!==e&&e;if(!1===r)return"";const s=t.getSubmit().getFormId(),{type:n=""}=null!==(i=r[s])&&void 0!==i?i:{};return n}(e):this.type;return!!i?.length},rt.prototype.getErrorsRaw=async function(t,e=null){this.hasServerSide&&this.input.loading.start();let i=await it(t);return this.valuePrev=this.input.getValue(),this.hasServerSide&&this.input.loading.end(),e?.aborted&&(i=[]),i},rt.prototype.reportRaw=function(t){let e="";for(const i of t)if(e=i.getMessage(),e?.length)break;e?this.insertError(e):this.clearReport()},rt.prototype.setInput=function(t){this.messages=function(t){var e;const i=Y(t),{validationMessages:r="{}"}=null!==(e=i?.dataset)&&void 0!==e?e:{};return JSON.parse(r)}(t.nodes[0]),et.prototype.setInput.call(this,t)},rt.prototype.observeAttrs=function(){for(const t of this.watchAttrs)this.input.attrs.hasOwnProperty(t)&&this.input.attrs[t].value.watch((()=>{this.valuePrev=null,this.validateOnBlur()}))},rt.prototype.clearReport=function(){(()=>{const t=Y(this.getNode());if(!t)return;t.classList.remove("field-has-error");const e=tt(t);e&&e.remove()})(),this.makeValid()},rt.prototype.insertError=function(t){(()=>{const e=Y(this.getNode()),i=this.createError(e,t);if(e.classList.add("field-has-error"),i.isConnected)return;const r=e.querySelector(".jet-form-builder-col__end");r?r.appendChild(i):e.appendChild(i)})(),this.makeInvalid()},rt.prototype.createError=function(t,e){const i=tt(t);if(i)return i.innerHTML=e,i;const r=this.getNode(),s=document.createElement("div");return s.classList.add("error-message"),s.innerHTML=e,s.id=r.id+"__error",s},rt.prototype.makeInvalid=function(){var t;const e=tt(Y(this.getNode()));this.getNode().setAttribute("aria-invalid","true"),this.getNode().setAttribute("aria-describedby",null!==(t=e?.id)&&void 0!==t&&t)},rt.prototype.makeValid=function(){this.getNode().removeAttribute("aria-invalid"),this.getNode().removeAttribute("aria-describedby")},rt.prototype.validateOnChange=function(t=!1){const e=this.input.getValue();if((!e||""===e)&&null===this.valuePrev&&this.input.getContext().silence)return;this.switchButtonsState(!0);const i=()=>{this.input.getContext().setSilence(!1),this.validate().then((()=>{})).catch((()=>{})).finally((()=>{this.isProcess=null;const t=[...this.queue];this.queue=[],t.length?(this.valuePrev=null,t.forEach((t=>t())),this.switchButtonsState()):this.switchButtonsState()}))};t&&this.isProcess&&(this.queue=[i]),this.isProcess||(this.isProcess=!0,i())},rt.prototype.validateOnBlur=function(t=null){if(this.isProcess)return;const e=this.input.getValue();(e&&""!==e||null!==this.valuePrev||!this.input.getContext().silence)&&(this.isProcess=!0,this.skipServerSide=!1,this.switchButtonsState(!0),this.canSubmitForm(!1),this.canTriggerEnterSubmit(!1),this.input.getContext().setSilence(!1),this.validate(t).then((()=>{})).catch((()=>{})).finally((()=>{this.skipServerSide=!0,this.hasServerSide=!1,this.isProcess=null,this.input.nodes[0].readOnly=!1,t?.aborted||(this.switchButtonsState(),this.canSubmitForm(),this.validityState.current&&this.canTriggerEnterSubmit())})))},rt.prototype.switchButtonsState=function(t=!1){const e=this.input.nodes[0].closest(".jet-form-builder-page");if(e&&!this.input.getContext().silence){const i=e.querySelectorAll(".jet-form-builder__next-page, .jet-form-builder__prev-page, .jet-form-builder__action-button");for(const e of i)(e.classList.contains("jet-form-builder__submit")||this.isNodeBelongThis(e))&&(e.classList.contains("jet-form-builder__prev-page")?e.disabled=t:e.disabled=!0===t||!this.validityState.current)}},rt.prototype.canTriggerEnterSubmit=function(t=!0){const e=this.input.root.form;e&&(e.canTriggerEnterSubmit=t)},rt.prototype.canSubmitForm=function(t=!0){const e=this.input.root.form;e&&(e.canSubmitForm=t)},rt.prototype.isNodeBelongThis=function(t){const e=t.closest(".jet-form-builder-page");return!!e&&!e.classList.contains("jet-form-builder-page--hidden")},rt.prototype.validateOnChangeState=function(){if(this.isProcess)return Promise.resolve();const t=this.input.getValue();return t&&""!==t||null!==this.valuePrev||!this.input.getContext().silence?(this.switchButtonsState(!0),this.canTriggerEnterSubmit(!1),this.input.maskValidation&&this.input.changeStateMaskValidation(),this.isProcess=!0,this.skipServerSide=!1,new Promise(((t,e)=>{this.validate().then(t).catch(e).finally((()=>{this.skipServerSide=!0,this.hasServerSide=!1,this.isProcess=null,this.input.nodes[0].readOnly=!1,this.switchButtonsState(),this.canTriggerEnterSubmit()}))}))):Promise.resolve()},rt.prototype.canProcessRestriction=function(t){return!this.skipServerSide||!t.isServerSide()},rt.prototype.beforeProcessRestriction=function(t){this.hasServerSide=!!t.isServerSide()||this.hasServerSide};const st=rt;var nt;const{addFilter:ot,addAction:at}=JetPlugins.hooks;at("jet.fb.observe.after","jet-form-builder/observe-dynamic-attrs",(function(t){t.getInputs().forEach((t=>{t.reporting instanceof st&&t.reporting.observeAttrs()}))}),11),ot("jet.fb.reporting","jet-form-builder/advanced-reporting",(function(t){return[st,...t]})),window.JetFormBuilderAbstract={...null!==(nt=window.JetFormBuilderAbstract)&&void 0!==nt?nt:{},AdvancedRestriction:s,NotEmptyRestriction:S}})();