(()=>{"use strict";const{applyFilters:t}=JetPlugins.hooks,{ReactiveHook:i,InputData:s}=JetFormBuilderAbstract;function e(){s.call(this),this.maskOptions={},this.clearOnSubmit=!1,this.isSupported=function(t){return t.classList.contains("jet-form-builder__masked-field")&&jQuery.fn.inputmask},this.addListeners=function(){const[t]=this.nodes;this.enterKey=new i,t.addEventListener("keydown",this.handleEnterKey.bind(this)),t.addEventListener("input",this.handleAutofill.bind(this,t))},this.handleAutofill=function(t){t&&t.inputmask&&(t.inputmask.setValue(t.value),this.maskValidation())},this.maskValidation=function(){const[t]=this.nodes,{value:i}=t;this.value.current=t.inputmask.unmaskedvalue(),setTimeout((()=>{this.reporting.validateOnBlur()}),0),this.silenceSet(i)},this.changeStateMaskValidation=function(){const[t]=this.nodes;this.value.current=t.inputmask.unmaskedvalue()},this.setNode=function(i){var e;s.prototype.setNode.call(this,i),this.clearOnSubmit=null!==(e=i.dataset.clearMaskOnSubmit)&&void 0!==e&&e;const n=this.clearOnSubmit?{autoUnmask:!0}:{};n.oncomplete=this.maskValidation.bind(this),n.onincomplete=this.maskValidation.bind(this);const a=t("jet.fb.inputmask.options",n,this);jQuery(i).inputmask(a),i.inputmask&&setTimeout((()=>{const t=i.inputmask._valueGet(),s=i.inputmask.getemptymask();t&&t!==s&&(i.value=t,jQuery(i).trigger("input"))}),0),this.beforeSubmit(this.removeMask.bind(this)),this.getSubmit().onEndSubmit(this.revertMask.bind(this))},this.removeMask=function(t){const i=jQuery(this.nodes[0]);this.maskOptions=i[0].inputmask.opts,this.value.current&&!this.clearOnSubmit||(i.inputmask("remove"),this.value.notify()),t()},this.revertMask=function(){const[t]=this.nodes,i=this.maskOptions;this.maskOptions={},t.inputmask||jQuery(t).inputmask(i)},this.onClear=function(){this.silenceSet("")}}e.prototype=Object.create(s.prototype);const n=e,{addFilter:a}=JetPlugins.hooks;a("jet.fb.inputs","jet-form-builder/text-field-masked",(function(t){return[n,...t]}))})();