(()=>{"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,a)}return n}function n(e,n,a){var i;return i=function(e,n){if("object"!=t(e)||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var i=a.call(e,n||"default");if("object"!=t(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(n,"string"),(n="symbol"==t(i)?i:String(i))in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}function a(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=new Array(e);n",{value:e,text:e}))})),a.attr("disabled",!1).val(e[t])}))}))}else jQuery.each(e,(function(e,n){jQuery('[name="'.concat(t,"[").concat(e,']"]')).val(n).change()}))}else if("[object Array]"===n){var s=jQuery("[name=".concat(t,"]"));if("file"==(s=(s=s.length?s:jQuery("[data-name=".concat(t,"]"))).length?s:jQuery("[name=".concat(t,"\\[\\]]"))).attr("type"))j(s,e);else if(s.prop("multiple"))if(i.isFunction(window.Choices)){var l=s.data("choicesjs");a.push({handler:l,values:e})}else s.val(e).change();else if("repeater_field"===s.attr("data-type")){var c=s.find("tbody"),d=s.attr("data-name");jQuery.each(e,(function(t,e){0!=t?c.find("tr:last").clone().appendTo(c).find(".ff-el-form-control").each((function(n,a){var r="ffrpt-"+(new Date).getTime()+n;i(a).val(e[n]),i(a).attr({id:r,name:"".concat(d,"[").concat(t,"][]"),value:e[n]}).change()})):c.find("tr:first .ff-el-form-control").each((function(t,n){i(n).val(e[t]).change()}))}))}else s.each((function(t,n){-1!=jQuery.inArray(i(n).val(),e)&&i(n).prop("checked",!0).change()}))}else{var u=jQuery("[name=".concat(t,"]"));if(u.hasClass("fluentform-post-content")&&window.wp&&window.wp.editor){var p=u.attr("id");window.tinymce.get(p).setContent(e)}if("undefined"!=typeof flatpickr&&u.prop("_flatpickr")){var v=u.prop("_flatpickr");v&&(v.config.altInput?v.setDate(e,!0):u.val(e).trigger("change"))}if("radio"===u.prop("type")||"checkbox"===u.prop("type"))jQuery("[name=".concat(t,'][value="').concat(e,'"]')).prop("checked",!0).change();else{var m=u.closest(".ff-el-group").find(".fluentform-signature-pad");if(m.length){var _=m[0].getContext("2d"),h=new Image;h.src=e,h.onload=function(){_.drawImage(h,0,0)}}u.val(e).change()}}}})),a.length>0)for(var r=0;r2&&void 0!==arguments[2])||arguments[2],d=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"next";return new Promise((function(v){i("div"+o+"_errors").empty(),s=t;var m=r.find(".ff-step-body"),_=r.find(".ff-step-titles li"),g=r.find(".fluentform-step"),y=g.length;g.removeClass("active"),i(g[s]).addClass("active"),_.removeClass("ff_active ff_completed"),i.each(a(Array(s).keys()),(function(t){i(i(_[t])).addClass("ff_completed")})),i(_[s]).addClass("ff_active");var b,w=u?{right:-100*s+"%"}:{left:-100*s+"%"};switch(i(g[s]).closest(".ff-step-container").data("animation_type")){case"slide":m.css("transition","all ".concat(f,"ms")),m.css(w),b=new Promise((function(t){return setTimeout(t,f)}));break;case"fade":m.css("transition","all ".concat(f,"ms")),m.css(function(t){for(var a=1;ao&&n div").length-1,n=r.find(".fluentform-step.active > .ff_excluded").length;if(r.find(".fluentform-step.active > .ff-t-container").length&&(e-=r.find(".fluentform-step.active > .ff-t-container").length,e+=r.find(".fluentform-step.active > .ff-t-container > .ff-t-cell > div").length,n+=r.find(".fluentform-step.active > .ff-t-container > .ff-t-cell > .ff_excluded").length,r.find(".fluentform-step.active > .ff-t-container.ff_excluded").length&&(n-=r.find(".fluentform-step.active > .ff-t-container.ff_excluded").length,n-=r.find(".fluentform-step.active > .ff-t-container.ff_excluded > .ff-t-cell > .ff_excluded").length,n+=r.find(".fluentform-step.active > .ff-t-container.ff_excluded > .ff-t-cell > div").length)),e===n)return t.find(".step-nav button[data-action="+d+"], .step-nav img[data-action="+d+"]").click(),void v()}r.find(".fluentform-step.active").find('.step-nav button[data-action="next"]').css("visibility","visible"),r.find(".fluentform-step.active").find('.step-nav button[data-action="prev"]').css("visibility","visible"),r.find(".fluentform-step.active").find('.step-nav img[data-action="next"]').css("visibility","visible"),r.find(".fluentform-step.active").find('.step-nav img[data-action="prev"]').css("visibility","visible"),v()}))}))},b=!0;function w(t){var e=!1;function n(){return r.find(".fluentform-step").index(r.find(".fluentform-step.active"))}function a(){return r.find(".fluentform-step").length}function f(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a="yes"!=r.find(".ff-step-container").attr("data-disable_auto_focus");if(!b)if(a){var f=e.find("input, select, textarea, button, a").filter(":visible");f.length&&n&&setTimeout((function(){f.first().focus()}),t+50),b=!1}else setTimeout((function(){i("".concat(o," .fluentform-step.active")).attr("tabindex","-1").focus().removeAttr("tabindex")}),t),b=!1}function s(){e=!0,setTimeout((function(){e=!1,f(r.find(".fluentform-step.active"),!0)}),t+50)}function l(t,r){if(!e){var f=n(),l=0===f,c=f===a()-1;if(!("prev"===r&&l||"next"===r&&c)){t.preventDefault(),t.stopPropagation();var d="prev"===r?".ff-btn-prev":".ff-btn-next",u=i("".concat(o," .fluentform-step.active")).find(".step-nav ".concat(d));u.length&&(u.click(),s())}}}r.off("keydown.stepNavigation").on("keydown.stepNavigation",(function(t){if(!e&&("Tab"===t.key||9===t.keyCode)){var r=i("".concat(o," .fluentform-step.active")).find("input, select, textarea, button, a").filter(":visible"),f=r.first(),s=r.last(),c=n(),d=0===c,u=c===a()-1;t.shiftKey?document.activeElement===f[0]&&(d||l(t,"prev")):document.activeElement===s[0]&&(u||l(t,"next"))}})),r.on("ff_to_next_page ff_to_prev_page",(function(){s()})),"yes"!=r.find(".ff-step-container").attr("data-disable_auto_focus")&&0!==n()&&!b&&f(i("".concat(o," .fluentform-step.active")),!0),b=!1}var x=function(t,e){var n=t.find(":input").filter((function(t,e){return!i(e).closest(".has-conditions").hasClass("ff_excluded")}));n.filter((function(t,e){var n=i(e);return n.parents().hasClass("ff_repeater_table")&&"select"==n.attr("type")&&!n.val()})).prepend("");var a=n.serialize();i.each(t.find("[type=file]"),(function(t,e){var n={},r=e.name+"[]";n[r]=[],i(e).closest("div").find(".ff-uploaded-list").find(".ff-upload-preview[data-src]").each((function(t,e){n[r][t]=i(this).data("src")})),i.each(n,(function(t,e){if(e.length){var n={};n[t]=e,a+="&"+i.param(n),!0}}))}));var r={active_step:e,data:a,form_id:t.data("form_id"),action:"fluentform_step_form_save_data"};return jQuery.post(f.ajaxUrl,r)},j=function(e,n){var a=e.closest(".ff-el-input--content").find(".ff-uploaded-list");i.each(n,(function(e,n){n="object"===t(n)?n:{url:n,data_src:n};var r=i("",{class:"ff-upload-preview","data-src":n.data_src,style:"border: 1px solid rgb(111, 117, 125)"}),o=i("",{class:"ff-upload-thumb"});o.append(i("",{class:"ff-upload-preview-img",style:"background-image: url('".concat(k(n.url),"');")}));var s=i("",{class:"ff-upload-details"}),l=i("",{html:f.upload_completed_txt,class:"ff-upload-progress-inline-text ff-inline-block"}),c=n.url.substring(n.url.lastIndexOf("/")+1);c.includes("-ff-")&&(c=c.substring(c.lastIndexOf("-ff-")+4));var d=i("",{class:"ff-upload-filename",html:c}),u=i('\n \n '),p=i("",{"data-href":"#",html:"×",class:"ff-upload-remove"}),v=i("",{class:"ff-upload-filesize ff-inline-block",html:""}),m=i("
",{class:"ff-upload-error",style:"color:red;"});s.append(d,u,l,v,m,p),r.append(o,s),a.append(r)})),e.trigger("change_remaining",-n.length),e.trigger("change")},k=function(t){var e=t.split(/[#?]/)[0].split(".").pop().trim().toLowerCase();if(-1!=["jpg","jpeg","gif","png"].indexOf(e))return t;var n=document.createElement("canvas");n.width=60,n.height=60,n.style.zIndex=8,n.style.position="absolute",n.style.border="1px solid";var a=n.getContext("2d");return a.fillStyle="rgba(0, 0, 0, 0.2)",a.fillRect(0,0,60,60),a.font="13px Arial",a.fillStyle="white",a.textAlign="center",a.fillText(e,30,30,60),n.toDataURL()};return{init:function(){c&&jQuery(document).ready((function(t){jQuery.getJSON(f.ajaxUrl,{form_id:r.data("form_id"),action:"fluentform_step_form_get_data",nonce:null==f?void 0:f.nonce,hash:null==f?void 0:f.hash}).then((function(t){t&&m(t)}))})),r.find(".fluentform-step:first").find('.step-nav [data-action="prev"]').remove(),function(){var t=r.find(".ff-step-body"),e=r.find(".fluentform-step"),n=e.length,a=r.find(".ff-step-titles li");l=100*n+"%",t.css({width:l}),e.css({width:100/n+"%"}),i(e[s]).addClass("active"),i(a[s]).addClass("active");var o=e.first();o.hasClass("active")&&o.find('button[data-action="next"]').css("visibility","visible"),e.length&&!e.last().hasClass("active")&&r.find('button[type="submit"]').css("visibility","hidden"),h({activeStep:s,totalSteps:n}),g(f.stepAnimationDuration),_(a,e)}(),function(){function t(t){if(1==t.closest(".fluentform-step.active").find(".ff-el-group:not(.ff_excluded):not(.ff-custom_html)").length)if(t.closest(".fluentform-step.active").find(".ff_excluded").length){var e=window.ffTransitionTimeOut||400;setTimeout((function(){t.closest(".fluentform-step.active").find(".ff-btn-next").trigger("click")}),e)}else t.closest(".fluentform-step.active").find(".ff-btn-next").trigger("click")}"yes"==r.find(".ff-step-container").attr("data-enable_auto_slider")&&(r.find(".ff-el-form-check-radio,.ff-el-net-label, .ff-el-ratings label").on("click",(function(){t(i(this))})),r.find("select").on("change",(function(){t(i(this))})))}()},updateSlider:y,populateFormDataAndSetActiveStep:m}}var f;(f=jQuery)(document.body).on("fluentform_init",(function(t,e,n){var a="."+n.form_instance,i=-1,o="no";if(f(a).hasClass("ff-form-has-save-progress")){f(a).hasClass("ff-form-has-steps")&&(e.on("ff_to_next_page",(function(t,e){o=e})),e.on("ff_to_prev_page",(function(t,e){o=e}))),f(a).find(".ff-btn-save-progress").each((function(t,n){var a=f(n);a.on("click",(function(t){var n,r=this;t.preventDefault(),a.addClass("ff-working");var s=e.find(":input").filter((function(t,e){return!f(e).closest(".has-conditions").hasClass("ff_excluded")}));s.filter((function(t,e){var n=f(e);return n.parents().hasClass("ff_repeater_table")&&"select"==n.attr("type")&&!n.val()})).prepend("
");var l=s.serialize();f.each(e.find("[type=file]"),(function(t,e){var n={},a=e.name+"[]";n[a]=[],f(e).closest("div").find(".ff-uploaded-list").find(".ff-upload-preview[data-src]").each((function(t,e){n[a][t]=f(this).data("src")})),f.each(n,(function(t,e){if(e.length){var n={};n[t]=e,l+="&"+f.param(n)}}))})),i=null===(n=window.form_state_save_vars)||void 0===n?void 0:n.key;var c={source_url:window.form_state_save_vars.source_url,action:"fluentform_save_form_progress_with_link",data:l,form_id:e.data("form_id"),hash:i,active_step:o,nonce:window.form_state_save_vars.nonce,save_progress_btn_name:f(a).attr("name")},d=c.form_id+"_save_progress_msg",u="#"+d;jQuery.post(fluentFormVars.ajaxUrl,c).then((function(t){if(t){var n;i=t.data.hash,e.find(".ff-saved-state-link"),""!=(null===(n=t.data)||void 0===n?void 0:n.message)&&(f(u).length&&f(u).slideUp("fast"),f("
",{id:d,class:"ff-message-success ff-el-group"}).html(t.data.message).insertBefore(a.closest(".ff-el-group")));var o=window.form_state_save_vars.copy_button||"Copy",s='
"),l=f("
",{class:"ff-el-group ff-saved-state-input ff-saved-state-link ff-hide-group",html:s});f(r).closest(".ff-el-group").after(l),l.fadeIn();var c=window.form_state_save_vars.email_placeholder_str||"Your Email Here",p=window.form_state_save_vars.email_button||"Email";if(f(r).hasClass("ff_resume_email_enabled")){var v='
"),m=f("
",{class:"ff-el-group ff-saved-state-input ff-email-address ff-hide-group",html:v});f(l).after(m),m.fadeIn()}}})).fail((function(t){f(u).length&&f(u).slideUp("fast"),f("
",{id:d,class:"ff-message-success ff-el-group text-danger"}).html(t.responseJSON.data.message).insertBefore(a.closest(".ff-el-group"))})).always((function(){a.parent().hide()}))}))})),f(a).on("click",".ff_btn_copy_link",(function(t){t.preventDefault();var e=f(this).closest(".ff-el-input--content").find(".ff-el-form-control").val();navigator.clipboard.writeText(e);var n=window.form_state_save_vars.copy_success_button||"Copied";f(this).html("".concat(n))})),f(a).on("click",".ff_btn_is_email",(function(t){t.preventDefault();var n=f(this).closest(".ff-el-group"),a=f(this).closest(".ff-email-address").find("input").val();f(".ff-email-address").find("input").val("");var r=f(".ff-saved-state-link").find("input").val(),o={source_url:window.form_state_save_vars.source_url,action:"fluentform_email_progress_link",form_id:e.data("form_id"),to_email:a,link:r,hash:i,nonce:window.form_state_save_vars.nonce},s=o.form_id+"_save_progress_email_response",l="#"+s;jQuery.post(fluentFormVars.ajaxUrl,o).then((function(t){t&&(n.removeClass("ff-el-is-error"),f(l).length&&f(l).slideUp("fast"),f("
",{id:s,class:"ff-message-success ff-el-group"}).html(t.data.response).insertAfter(n))})).fail((function(t){t&&(n.addClass("ff-el-is-error"),f(l).length&&f(l).slideUp("fast"),f("
",{id:s,class:"ff-message-success ff-el-group text-danger"}).html(t.responseJSON.data.Error).insertAfter(n))}))}));var s=!1;void 0!==window.form_state_save_vars&&(s=window.form_state_save_vars.key),s&&(e.append('
')),"yes"==e.find(".ff-step-container").attr("data-enable_step_data_persistency")||jQuery.getJSON(fluentFormVars.ajaxUrl,{form_id:e.data("form_id"),action:"fluentform_get_form_state",hash:s,nonce:window.form_state_save_vars.nonce}).then((function(t){t&&r(f,e,window.fluentFormVars,a).populateFormDataAndSetActiveStep(t)})))}}))})();