STRATO-apps/wordpress_03/app/wp-content/plugins/fluentform/assets/js/fluentform-advanced.js
SHA-256: 86034a4025060083ea2c741c441dd7de862dec745801d1f969f93e8dbc5cdda1
(()=>{"use strict";const e=function(e,t){var n=t.find(".jss-ff-el-net-promoter");n.length&&e.each(n,function(t,n){e(n).on("click","label",function(t){var n=e(this);n.addClass("active"),n.prevAll().removeClass("active"),n.nextAll().removeClass("active")})})};var t=function(e){!function(e){e.on("click",".js-repeat .repeat-plus",function(e){var t=jQuery(this),n=t.closest(".ff-el-repeat"),i=parseInt(n.data("max_repeat")),a=n.find(".ff-t-cell:first-child .ff-el-input--content > input").length;if(!(i&&i<=a)){i&&i-a==1&&n.find(".repeat-plus").hide();var r=t.closest("div"),o=r.index(),l=t.closest(".ff-el-input--content").find(".ff-t-cell").length;t.closest(".ff-el-input--content").find(".ff-t-cell").each(function(e,t){var n=jQuery(this).find(".ff-el-form-control:last-child"),i=n.attr("tabindex"),a=n.clone(),r={value:"",id:"ffrpt-"+(new Date).getTime()+e};i&&(r.tabIndex=parseInt(i)+l),a.prop(r),a.insertAfter(n)}),r.clone().insertAfter(r),t.closest(".ff-el-input--content").find(".ff-t-cell").eq(0).find("input:eq(".concat(o+1,")")).focus()}}),e.on("click",".js-repeat .repeat-minus",function(e){var t=!1,n=jQuery(this),i=n.closest("div");n.closest(".ff-el-repeat").find(".repeat-plus").show(),n.closest(".ff-el-input--content").find(".ff-t-cell").each(function(){var e=i.index(),n=jQuery(this).find(".ff-el-form-control:eq("+e+")");i.siblings().length&&(t=n.remove().length)}),t&&i.remove()})}(e),function(e){var t=window.localStorage.getItem("ff_window_type");jQuery(".ff_form_preview").length&&jQuery(".ff_flexible_table").addClass(t),e.on("screen-change",function(e,t){jQuery(".ff_form_preview").length&&("375px"===t?jQuery(".ff_flexible_table").addClass("mobile"):jQuery(".ff_flexible_table").removeClass("mobile"))}),e.on("repeater-container-names-update",function(e,t){var n=t.attr("data-root_name"),i=0;t.find(".ff_repeater_cont_row").each(function(e,t){jQuery(this).find(".ff-el-form-control").each(function(t,a){var r=jQuery(a);0==e&&(i=r.attr("tabindex")),r.prop({name:n+"["+e+"][]"}),r.attr("data-name",n+"_"+t+"_"+e),i&&r.attr("tabindex",i)})})}),e.on("click",".js-repeater .repeat-plus",function(e){var t=jQuery(this),n=t.closest("table"),i=t.closest("tr"),a=parseInt(n.attr("data-max_repeat")),r=n.find("tbody tr").length;if(a&&r==a)n.addClass("repeat-maxed");else{var o=i.clone();o.find("td").each(function(e,t){var n=jQuery(this).find(".ff-el-form-control:last-child"),i="ffrpt-"+(new Date).getTime()+e,a={value:n.attr("data-default")||"",id:i};n.prop(a);var r=n.attr("data-mask");r&&n.mask(r)}),o.insertAfter(i);var l=n.attr("data-root_name"),s=0;n.find("tbody tr").each(function(e,t){jQuery(this).find(".ff-el-form-control").each(function(t,n){var i=jQuery(n);0==e&&(s=i.attr("tabindex")),i.prop({name:l+"["+e+"][]"}),i.attr("data-name",l+"_"+t+"_"+e),s&&i.attr("tabindex",s)})}),o.find(".ff-el-form-control")[0].focus(),n.trigger("repeat_change"),a&&r+1==a&&n.addClass("repeat-maxed")}}),e.on("click",".js-repeater .repeat-minus",function(e){var t=jQuery(this),n=t.closest("table");if(1!=n.find("tbody tr").length){t.closest("tr").remove(),n.removeClass("repeat-maxed");var i=n.attr("data-root_name");n.find("tbody tr").each(function(e,t){jQuery(this).find(".ff-el-form-control").each(function(t,n){jQuery(n).prop({name:i+"["+e+"][]"})})}),n.trigger("repeat_change")}}),e.on("click",".js-container-repeat-buttons .repeat-plus",function(t){var n=jQuery(this),i=n.closest(".ff-repeater-container"),a=n.closest(".ff_repeater_cont_row"),r=parseInt(i.attr("data-max_repeat")),o=i.find(".ff_repeater_cont_row").length;if(r&&o==r)i.addClass("repeat-maxed");else{var l=a.clone();l.find(".ff_repeater_cell").each(function(e,t){var n=jQuery(this).find(".ff-el-form-control:last-child"),i="ffrpt-"+(new Date).getTime()+e,a={value:n.attr("data-default")||"",id:i};n.prop(a);var r=n.attr("data-mask");r&&n.mask(r),jQuery(this).find("label").attr("for",i)}),l.insertAfter(a),e.trigger("repeater-container-names-update",[i]),l.find(".ff-el-form-control")[0].focus(),i.trigger("repeat_change"),r&&o+1==r&&i.addClass("repeat-maxed")}}),e.on("click",".js-container-repeat-buttons .repeat-minus",function(t){var n=jQuery(this),i=n.closest(".ff-repeater-container"),a=n.closest(".ff_repeater_cont_row");i.find(".ff_repeater_cont_row").length>1&&(a.remove(),i.removeClass("repeat-maxed"),e.trigger("repeater-container-names-update",[i]),i.trigger("repeat_change"))})}(e),function(e){e.on("keydown",".repeat-plus",function(e){"Enter"===e.key&&(e.preventDefault(),jQuery(this).click())}),e.on("keydown",".repeat-minus",function(e){"Enter"===e.key&&(e.preventDefault(),jQuery(this).click())})}(e)};function n(){n=function(e,t){return new r(e,void 0,t)};var e=RegExp.prototype,t=new WeakMap;function r(e,n,a){var o=RegExp(e,n);return t.set(o,a||t.get(e)),i(o,r.prototype)}function o(e,n){var i=t.get(n);return Object.keys(i).reduce(function(t,n){var a=i[n];if("number"==typeof a)t[n]=e[a];else{for(var r=0;void 0===e[a[r]]&&r+1<a.length;)r++;t[n]=e[a[r]]}return t},Object.create(null))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&i(e,t)}(r,RegExp),r.prototype.exec=function(t){var n=e.exec.call(this,t);if(n){n.groups=o(n,this);var i=n.indices;i&&(i.groups=o(i,this))}return n},r.prototype[Symbol.replace]=function(n,i){if("string"==typeof i){var r=t.get(this);return e[Symbol.replace].call(this,n,i.replace(/\$<([^>]+)(>|$)/g,function(e,t,n){if(""===n)return e;var i=r[t];return Array.isArray(i)?"$"+i.join("$"):"number"==typeof i?"$"+i:""}))}if("function"==typeof i){var l=this;return e[Symbol.replace].call(this,n,function(){var e=arguments;return"object"!=a(e[e.length-1])&&(e=[].slice.call(e)).push(o(e,l)),i.apply(this,e)})}return e[Symbol.replace].call(this,n,i)},n.apply(this,arguments)}function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function r(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return o(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,l=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){s=!0,r=e},f:function(){try{l||null==n.return||n.return()}finally{if(s)throw r}}}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function l(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,s(i.key),i)}}function s(e){var t=function(e,t){if("object"!=a(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=a(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==a(t)?t:t+""}const f=function(){return e=function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.fields=t,this.formData=n,this.counter=0,this.field_statues={},this.elementCache={}},(t=[{key:"setFields",value:function(e){this.fields=e}},{key:"setFormData",value:function(e){this.elementCache={},this.formData=e}},{key:"getCalculatedStatuses",value:function(){this.elementCache={};for(var e=0,t=Object.keys(this.fields);e<t.length;e++){var n=t[e],i=this.fields[n];this.field_statues[n]=this.evaluate(i,n)}return this.field_statues}},{key:"evaluate",value:function(e,t){var n=this;if(e._visited)return console.warn("Circular dependency detected for field: ".concat(t)),!1;var i=!1;if(e.status){var a,r;this.counter++;var o=e.type,l=1;if(e._visited=!0,"group"===o&&null!=e&&e.condition_groups?i=this.evaluateGroups(e.condition_groups):("any"==o&&(l=0),e.conditions.forEach(function(e){var i=n.getItemEvaluateValue(e,n.formData[e.field]);i&&n.fields[e.field]&&e.field!=t&&(i=n.evaluate(n.fields[e.field],e.field)),"any"==o?i&&(l=1):!i&&l&&(l=!1)}),i=1==l),e._visited=!1,(null!==(a=e.conditions)&&void 0!==a&&a.length||null!==(r=e.condition_groups)&&void 0!==r&&r.length)&&!i)return i}return e.container_condition&&(i=this.evaluate(e.container_condition,t)),i}},{key:"evaluateGroups",value:function(e){var t,n=r(e);try{for(n.s();!(t=n.n()).done;){var i=t.value;if(i&&Array.isArray(i.rules)&&0!==i.rules.length)try{if(!0===this.evaluateRuleGroup(i.rules))return!0}catch(e){console.warn("Error evaluating group:",e);continue}}}catch(e){n.e(e)}finally{n.f()}return!1}},{key:"evaluateRuleGroup",value:function(e){var t=this;return e.map(function(e){try{var n=t.getItemEvaluateValue(e,t.formData[e.field]);return n&&t.fields[e.field]&&t.fields[e.field].status?t.evaluate(t.fields[e.field],e.field):n}catch(t){return console.warn("Error evaluating rule:",e,t),!1}}).every(function(e){return!0===e})}},{key:"getItemEvaluateValue",value:function(e,t){t=t||null;var n=this.elementCache[e.field];return n&&n.length||(n=jQuery("[name='".concat(e.field,"']")),this.elementCache[e.field]=n),"="==e.operator?""===e.value?null===t:"object"==a(t)?null!==t&&-1!=t.indexOf(e.value):n.hasClass("ff_numeric")?this.parseFormattedNumericValue(n,t)==this.parseFormattedNumericValue(n,e.value):t==e.value:"!="==e.operator?"object"==a(t)?null!==t&&-1==t.indexOf(e.value):n.hasClass("ff_numeric")?this.parseFormattedNumericValue(n,t)!=this.parseFormattedNumericValue(n,e.value):t!=e.value:">"==e.operator?t&&this.parseFormattedNumericValue(n,t)>this.parseFormattedNumericValue(n,e.value):"<"==e.operator?t&&this.parseFormattedNumericValue(n,t)<this.parseFormattedNumericValue(n,e.value):">="==e.operator?t&&this.parseFormattedNumericValue(n,t)>=this.parseFormattedNumericValue(n,e.value):"<="==e.operator?t&&this.parseFormattedNumericValue(n,t)<=this.parseFormattedNumericValue(n,e.value):"startsWith"==e.operator?t&&t.startsWith(e.value):"endsWith"==e.operator?t&&t.endsWith(e.value):"contains"==e.operator?null!==t&&-1!=t.indexOf(e.value):"doNotContains"==e.operator?null!==t&&-1==t.indexOf(e.value):"test_regex"==e.operator&&(t=t||"",this.stringToRegex(e.value).test(t))}},{key:"stringToRegex",value:function(e){var t,i=(null===(t=String(e).match(n(/^\/(.*)\/([gimsuy]*)$/,{body:1,flags:2})))||void 0===t?void 0:t.groups)||{},a=i.body,r=i.flags;return a?(r=r||"g",RegExp(a,r)):new RegExp(e,"g")}},{key:"parseFormattedNumericValue",value:function(e,t){if(e.hasClass("ff_numeric")){var n=JSON.parse(e.attr("data-formatter"));return currency(t,n).value}return Number(t)||0}}])&&l(e.prototype,t),i&&l(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,i}();const c=function(e,t,n){var i="."+n.form_instance;(function(){var a=this,r={},o={},l=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:300;return function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];clearTimeout(t),t=setTimeout(function(){return e.apply(a,r)},n)}}(function(e){s(e)},n.debounce_time||300),s=function(n){var i;e.each(n,function(e,n){var a=u(e).closest(".has-conditions");n?("0px"==a.css("height")&&a.attr("style",""),a.removeClass("ff_excluded").addClass("ff_cond_v").slideDown(200,function(){a.find('input[type="range"]').length>0&&(i&&clearTimeout(i),i=setTimeout(function(){t.trigger("reInitRangeSliders")},50))})):a.removeClass("ff_cond_v").addClass("ff_excluded").slideUp(200)}),t.trigger("do_calculation"),t.trigger("ff_render_dynamic_smartcodes",t)},c=function(){var n={};return e.each(r,function(i,a){var r=a.prop("type")||a.attr("data-type");if("radio"==r)n[i]="",a.each(function(t,a){e(a).is(":checked")&&(n[i]=e(a).val())});else if("checkbox"==r)i=i.replace("[]",""),n[i]=[],a.each(function(t,a){e(a).is(":checked")&&n[i].push(e(a).val())});else if("select-multiple"==r){i=i.replace("[]","");var o=a.val();n[i]=o||[]}else if("file"==r){var l="";t.find("input[name="+i+"]").closest(".ff-el-input--content").find(".ff-uploaded-list").find(".ff-upload-preview[data-src]").each(function(t,n){l+=e(this).data("src")}),n[i]=l}else n[i]=a.val()}),n},u=function(t){var n=e(i),a=e("[data-name='"+t+"']",n);return(a=(a=a.length?a:e("[name='"+t+"']",n)).length?a:e("[data-condition_field_name='"+t+"']",n)).length?a:e("[name='"+t+"[]']",n)};return{init:function(){if(n.conditionals){e.each(n.conditionals,function(t,n){t&&("group"==n.type&&n.condition_groups?e.each(n.condition_groups,function(t,n){e.each(n.rules,function(e,t){var n=u(t.field);r[n.prop("name")]=n})}):e.each(n.conditions,function(e,t){var n=u(t.field);r[n.prop("name")]=n}))}),o=c();var i=new f(n.conditionals,o);e.each(r,function(e,n){n.on("keyup change",function(){t.hasClass("ff_force_hide")||t.hasClass("ff_submitting")||(o=c(),i.setFormData(o),setTimeout(function(){l(i.getCalculatedStatuses())},0))})}),jQuery(document.body).on("fluentform_reset",function(e,n){n&&n.length&&n[0]===t[0]&&!t.hasClass("ff_force_hide")&&setTimeout(function(){o=c(),i.setFormData(o),s(i.getCalculatedStatuses())},0)}),setTimeout(function(){s(i.getCalculatedStatuses())},0)}}}})().init()};function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}function p(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return m(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m(e,t):void 0}}(e)||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 m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function h(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,v(i.key),i)}}function v(e){var t=function(e,t){if("object"!=d(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=d(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==d(t)?t:t+""}var g=function(){return e=function e(t,n,i,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.$=t,this.$theForm=n,this.fluentFormVars=i,this.formSelector=a,this.activeStep=0,this.isRtl=!!window.fluentFormVars.is_rtl,this.isPopulatingStepData=!1,this.isInitialLoad=!0,this.fluentFormVars.stepAnimationDuration=parseInt(this.fluentFormVars.stepAnimationDuration),this.stepPersistency="yes"===this.$theForm.find(".ff-step-container").attr("data-enable_step_data_persistency"),this.stepResume=!1,this.stepPersistency&&(this.stepResume="yes"===this.$theForm.find(".ff-step-container").attr("data-enable_step_page_resume"))},t=[{key:"getPublicAPI",value:function(){return{init:this.init.bind(this),updateSlider:this.updateSlider.bind(this),populateFormDataAndSetActiveStep:this.populateFormDataAndSetActiveStep.bind(this)}}},{key:"init",value:function(){this.initFormWithSavedState(),this.removePrevFromFirstStep(),this.initStepSlider(),this.maybeAutoSlider()}},{key:"removePrevFromFirstStep",value:function(){this.$theForm.find(".fluentform-step:first").find('.step-nav [data-action="prev"]').remove()}},{key:"getFormInstance",value:function(){return window.fluentFormApp(this.$theForm)}},{key:"initFormWithSavedState",value:function(){var e=this;if(this.stepPersistency){var t=this.$,n=this;t(document).ready(function(i){var a,r;t.getJSON(e.fluentFormVars.ajaxUrl,{form_id:e.$theForm.data("form_id"),action:"fluentform_step_form_get_data",nonce:null===(a=e.fluentFormVars)||void 0===a?void 0:a.nonce,hash:null===(r=e.fluentFormVars)||void 0===r?void 0:r.hash}).then(function(e){e&&n.populateFormDataAndSetActiveStep(e)})})}}},{key:"populateFormDataAndSetActiveStep",value:function(e){var t=this,n=e.response,i=e.step_completed,a=this.$,r=[];if(a.each(n,function(e,n){if(n){var i=Object.prototype.toString.call(n);if("[object Object]"===i){var o=t.$theForm.find("[data-name=".concat(e,"]"));if(o.length&&"tabular-element"===o.attr("data-type"))jQuery.each(n,function(n,i){var r=t.$theForm.find('[name="'.concat(e,"[").concat(n,']\\[\\]"]'));r.length||(r=t.$theForm.find('[name="'.concat(e,"[").concat(n,']"]'))),a.each(r,function(e,t){var n=a(t).val();-1===a.inArray(n,i)&&n!==i||a(t).prop("checked",!0).change()})});else if("chained-select"===o.attr("data-type")){var l={meta_key:o.find("select:first").attr("data-meta_key"),form_id:o.closest("form").attr("data-form_id"),action:"fluentform_get_chained_select_options",filter_options:"all",keys:n};a.getJSON(t.fluentFormVars.ajaxUrl,l).then(function(e){a.each(e,function(e,t){var i=o.find("select[data-key='".concat(e,"']"));0!=i.attr("data-index")&&a.each(t,function(e,t){i.append(a("<option />",{value:t,text:t}))}),i.attr("disabled",!1).val(n[e])})})}else a.each(n,function(n,i){t.$theForm.find('[name="'.concat(e,"[").concat(n,']"]')).val(i).change()})}else if("[object Array]"===i){var s=t.$theForm.find("[name=".concat(e,"]"));if("file"===(s=(s=s.length?s:t.$theForm.find("[data-name=".concat(e,"]"))).length?s:t.$theForm.find("[name=".concat(e,"\\[\\]]"))).attr("type"))t.addFilesToElement(s,n);else if(s.prop("multiple"))if(a.isFunction(window.Choices)){var f=s.data("choicesjs");f&&r.push({handler:f,values:n})}else s.val(n).change();else if("repeater_field"===s.attr("data-type")){var c=s.find("tbody"),u=s.attr("data-name");a.each(n,function(e,t){0!=e?c.find("tr:last").clone().appendTo(c).find(".ff-el-form-control").each(function(n,i){var r="ffrpt-"+(new Date).getTime()+n;a(i).val(t[n]),a(i).attr({id:r,name:"".concat(u,"[").concat(e,"][]"),value:t[n]}).change()}):c.find("tr:first .ff-el-form-control").each(function(e,n){a(n).val(t[e]).change()})})}else"repeater_container"===s.attr("data-type")?(a.each(n,function(e,t){if(0!==e){var n=s.find(".ff_repeater_cont_row:first").clone();n.find(".ff_repeater_cell").each(function(n,i){var r=a(this).find(".ff-el-form-control:last-child"),o="ffrpt-"+(new Date).getTime()+"_"+e+"_"+n,l={value:t[n]||"",id:o};r.prop(l),a(this).find("label").attr("for",o)}),n.insertAfter(s.find(".ff_repeater_cont_row:last"))}else s.find(".ff_repeater_cont_row:first .ff-el-form-control").each(function(e,n){a(n).val(t[e]).change()})}),t.$theForm.trigger("repeater-container-names-update",[s]),s.trigger("repeat_change")):s.each(function(e,t){-1!==a.inArray(a(t).val(),n)&&a(t).prop("checked",!0).change()})}else{var d=t.$theForm.find("[name=".concat(e,"]"));if(d.hasClass("fluentform-post-content")&&window.wp&&window.wp.editor){var p=d.attr("id");window.tinymce.get(p).setContent(n)}if("undefined"!=typeof flatpickr&&d.prop("_flatpickr")){var m=d.prop("_flatpickr");m&&(m.config.altInput?m.setDate(n,!0):d.val(n).trigger("change"))}if("radio"===d.prop("type")||"checkbox"===d.prop("type"))a("[name=".concat(e,'][value="').concat(n,'"]')).prop("checked",!0).change(),t.$theForm.find("[name=".concat(e,'][value="').concat(n,'"]')).prop("checked",!0).change(),d.closest(".ff-el-group").find(".ff-el-ratings").length&&t.$theForm.find("[name=".concat(e,'][value="').concat(n,'"]')).closest("label").trigger("mouseenter");else{d.hasClass("ff_has_multi_select")&&d.data("choicesjs")&&(d.data("choicesjs").removeActiveItems(n),d.data("choicesjs").setChoiceByValue(n));var h=d.closest(".ff-el-group").find(".fluentform-signature-pad");if(h.length){var v=h[0].getContext("2d"),g=new Image;g.src=n,g.onload=function(){v.drawImage(g,0,0)}}d.val(n).change()}}}}),r.length>0)for(var o=0;o<r.length;o++){var l,s=r[o].handler,f=r[o].values;s.setValue(f);var c=null===(l=s.passedElement)||void 0===l?void 0:l.element;c&&a(c).trigger("change")}this.isPopulatingStepData=!0;var u=this.fluentFormVars.stepAnimationDuration;this.stepResume&&this.updateSlider(i,u,!0).then(function(){t.handleFocus(u)}).catch(function(e){console.error("An error occurred during the slider update:",e)}),this.isPopulatingStepData=!1}},{key:"initStepSlider",value:function(){var e=this.$,t=this.$theForm.find(".fluentform-step"),n=t.length,i=this.$theForm.find(".ff-step-titles li");if(!window.ff_disable_auto_step){for(var a=this.activeStep,r=0;a<n&&this.isStepAllFieldsHidden(e(t[a]))&&r<n;)a++,r++;a!==this.activeStep&&a<n&&(this.activeStep=a)}t.css("display","none"),e(t[this.activeStep]).css("display","block"),t.attr("role","group"),t.attr("aria-hidden","true"),e(t[this.activeStep]).attr("aria-hidden","false"),e(t[this.activeStep]).addClass("active"),e(i[this.activeStep]).addClass("active");var o=t.first();o.hasClass("active")&&o.find('button[data-action="next"]').css("visibility","visible"),t.length&&!t.last().hasClass("active")&&this.$theForm.find('button[type="submit"]').css("visibility","hidden"),this.stepProgressBarHandle({activeStep:this.activeStep,totalSteps:n}),this.registerStepNavigators(this.fluentFormVars.stepAnimationDuration),this.registerClickableStepNav(i,t)}},{key:"registerClickableStepNav",value:function(e,t){var n=this.$,i=this;0!==e.length&&(n.each(e,function(e,t){n(t).attr("data-step-number",e),n(t).attr({role:"button",tabindex:"0","aria-label":"Go to step "+(e+1),style:"cursor: pointer;"})}),e.on("click keydown",function(e){if("keydown"!==e.type||"Enter"===e.key||" "===e.key||13===e.keyCode||32===e.keyCode){"keydown"===e.type&&e.preventDefault();var a=i.getFormInstance(),r=n(this),o=0,l=i.fluentFormVars.stepAnimationDuration;try{var s=r.data("step-number");if(isNaN(s))return;n.each(t,function(e,t){if(o=e,e<s){var i=n(t).find(":input").not(":button").filter(function(e,t){return!n(t).closest(".has-conditions").hasClass("ff_excluded")});i.length&&a.validate(i)}}),i.updateSlider(s,l,!0).then(function(){i.handleFocus(l)}).catch(function(e){console.error("An error occurred during the slider update:",e)})}catch(e){if(!(e instanceof window.ffValidationError))throw e;i.updateSlider(o,l,!0).then(function(){i.handleFocus(l)}).catch(function(e){console.error("An error occurred during the slider update:",e)}),a.showErrorMessages(e.messages),a.scrollToFirstError(350)}}}))}},{key:"stepProgressBarHandle",value:function(e){var t=this.$;if(this.$theForm.find(".ff-el-progress").length){var n=e.totalSteps,i=e.activeStep,a=100/n*(i+1),r=this.$theForm.find(".ff-el-progress-title li"),o=this.$theForm.find(".ff-step-header .ff-el-progress-bar"),l=o.find("span");o.css({transition:"width 0.3s ease-in-out",width:a+"%"}),a?o.append(l.text(parseInt(a)+"%")):l.empty();var s=this.fluentFormVars.step_text,f=t(r[i]).text();s=s.replace("%activeStep%",i+1).replace("%totalStep%",n).replace("%stepTitle%",f),this.$theForm.find(".ff-el-progress-status").html(s).attr("aria-live","polite"),r.css("display","none"),t(r[i]).css("display","inline")}}},{key:"isStepAllFieldsHidden",value:function(e){return this.$,e.find(".ff-el-group").not(".ff-custom_html").length,!1}},{key:"animateProgressToStep",value:function(e,t,n){this.$;var i=this.$theForm.find(".ff-step-header .ff-el-progress-bar");if(!i.length||!t)return Promise.resolve();var a=100/t*(e+1);return n&&n>0?i.css({transition:"width ".concat(n,"ms ease-in-out")}):i.css({transition:"none"}),i[0]&&i[0].offsetHeight,i.css("width",a+"%"),new Promise(function(e){var t=!1,a=setTimeout(function(){t||(t=!0,e())},(n||0)+120);i.one("transitionend webkitTransitionEnd oTransitionEnd",function(){t||(t=!0,clearTimeout(a),e())})})}},{key:"registerStepNavigators",value:function(e){var t=this.$,n=this;this.handleFocus(e),t(this.formSelector).on("click",".fluentform-step .step-nav button, .fluentform-step .step-nav img",function(i){var a=t(this).data("action"),r="next",o=t(this).closest(".fluentform-step"),l=n.getFormInstance();if("next"===a){try{var s=o.find(":input").not(":button").filter(function(e,n){return!t(n).closest(".has-conditions").hasClass("ff_excluded")});s.length&&l.validate(s),n.activeStep++}catch(i){if(!(i instanceof window.ffValidationError))throw i;return l.showErrorMessages(i.messages),void l.scrollToFirstError(350)}n.$theForm.trigger("ff_to_next_page",n.activeStep),t(document).trigger("ff_to_next_page",{step:n.activeStep,form:n.$theForm});var f=n.$theForm.find(".fluentform-step");n.$theForm.trigger("ff_render_dynamic_smartcodes",t(f[n.activeStep]))}else n.activeStep--,r="prev",n.$theForm.trigger("ff_to_prev_page",n.activeStep),t(document).trigger("ff_to_prev_page",{step:n.activeStep,form:n.$theForm});var c="yes"!=n.$theForm.find(".ff-step-container").attr("data-disable_auto_focus");n.updateSlider(n.activeStep,e,c,r).then(function(){n.handleFocus(e)}).catch(function(e){console.error("An error occurred during the slider update:",e)})})}},{key:"updateSlider",value:function(e,t){var n=this,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"next",r=this.$,o=this;return new Promise(function(l){r("div"+n.formSelector+"_errors").empty(),n.activeStep=e;var s=n.$theForm.find(".ff-step-titles li"),f=n.$theForm.find(".fluentform-step"),c=f.length;if(!window.ff_disable_auto_step&&c){var u=o.$theForm.find(".fluentform-step").index(o.$theForm.find(".fluentform-step.active"));if("prev"===a||u>-1&&n.activeStep<u)for(;n.activeStep>0&&n.isStepAllFieldsHidden(r(f[n.activeStep]));)n.activeStep--;else for(;n.activeStep<c-1&&n.isStepAllFieldsHidden(r(f[n.activeStep]));)n.activeStep++}f.css("display","none").removeClass("active").attr("aria-hidden","true"),r(f[n.activeStep]).css("display","block").addClass("active").attr("aria-hidden","false"),s.removeClass("ff_active ff_completed"),r.each(p(Array(n.activeStep).keys()),function(e){r(r(s[e])).addClass("ff_completed")}),r(s[n.activeStep]).addClass("ff_active");var d=r(f[n.activeStep]).closest(".ff-step-container").data("animation_type"),m=r(f[n.activeStep]);m.find(".step-nav button, .step-nav img").css("visibility","hidden");var h,v=c;h="none"===d?0===t?0:t<50?50:t<200?t:window.ffTransitionTimeOut||500:t;var g,y=n.animateProgressToStep(n.activeStep,v,h);switch(d){case"slide":m.css({display:"block",position:"relative",left:n.isRtl?"-100%":"100%",opacity:0,transition:"all ".concat(t,"ms cubic-bezier(0.25, 0.1, 0.25, 1.0)")}),m[0].offsetHeight,m.css({left:"0%",opacity:1}),g=new Promise(function(e){return setTimeout(function(){m.css({position:"",left:"",transition:""}),e()},t+50)});break;case"fade":m.css({display:"block",opacity:0,transition:"opacity ".concat(t,"ms ease-in-out")}),m[0].offsetHeight,m.css("opacity",1),g=new Promise(function(e){return setTimeout(function(){m.css("transition",""),e()},t+50)});break;case"slide_down":m.css({display:"block",opacity:0,maxHeight:"0",overflow:"hidden",transition:"all ".concat(t,"ms cubic-bezier(0.25, 0.1, 0.25, 1.0)")}),m[0].offsetHeight;var _=m[0].scrollHeight;m.css({maxHeight:_+"px",opacity:1}),g=new Promise(function(e){return setTimeout(function(){m.css({maxHeight:"",overflow:"",transition:""}),e()},t+50)});break;default:var b,w=window.ffTransitionTimeOut||500;b=t<50&&t>0?50:t<w?t:w,g=new Promise(function(e){return setTimeout(e,b)})}Promise.all([g,y]).then(function(){i&&function(){if(!window.ff_disable_step_scroll){var e,t,n,i,a,l,s=o.$theForm.find(".ff_step_start");e=window.ff_scroll_top_offset?window.ff_scroll_top_offset:s.offset().top-100,i=(n=(t=s).offset().top)+t.outerHeight(),l=(a=r(window).scrollTop())+r(window).height(),i>a&&n<l&&!window.ff_force_scroll||r("html, body").animate({scrollTop:e},500,"swing")}}(),function(){var t=0===e&&!i,n=o.$theForm.hasClass("ff_submitting");if(!o.stepPersistency||o.isPopulatingStepData||t||n||o.saveStepData(o.$theForm,o.activeStep).then(function(e){}),o.stepProgressBarHandle({activeStep:o.activeStep,totalSteps:c}),f.last().hasClass("active")?o.$theForm.find('button[type="submit"]').css("visibility","visible"):o.$theForm.find('button[type="submit"]').css("visibility","hidden"),!window.ff_disable_auto_step){o.$theForm.find(".fluentform-step.active");var s=o.$theForm.find(".fluentform-step.active > div").length-1,u=o.$theForm.find(".fluentform-step.active > .ff_excluded").length;if(o.$theForm.find(".fluentform-step.active > .ff-t-container").length&&(s-=o.$theForm.find(".fluentform-step.active > .ff-t-container").length,s+=o.$theForm.find(".fluentform-step.active > .ff-t-container > .ff-t-cell > div").length,u+=o.$theForm.find(".fluentform-step.active > .ff-t-container > .ff-t-cell > .ff_excluded").length,o.$theForm.find(".fluentform-step.active > .ff-t-container.ff_excluded").length&&(u-=o.$theForm.find(".fluentform-step.active > .ff-t-container.ff_excluded").length,u-=o.$theForm.find(".fluentform-step.active > .ff-t-container.ff_excluded > .ff-t-cell > .ff_excluded").length,u+=o.$theForm.find(".fluentform-step.active > .ff-t-container.ff_excluded > .ff-t-cell > div").length)),s===u){var d="prev"===a?o.activeStep-1:o.activeStep+1;if(d>=0&&d<c){var p="none"===r(f[d]).closest(".ff-step-container").data("animation_type")?50:100;return void o.updateSlider(d,p,i,a).then(function(){l()}).catch(function(e){console.error("An error occurred during step skip:",e),l()})}}}o.$theForm.find(".fluentform-step.active").find('.step-nav button[data-action="next"]').css("visibility","visible"),o.$theForm.find(".fluentform-step.active").find('.step-nav button[data-action="prev"]').css("visibility","visible"),o.$theForm.find(".fluentform-step.active").find('.step-nav img[data-action="next"]').css("visibility","visible"),o.$theForm.find(".fluentform-step.active").find('.step-nav img[data-action="prev"]').css("visibility","visible"),l()}()})})}},{key:"handleFocus",value:function(e){var t=this.$,n=this,i=!1,a=function(i){var a=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r="yes"!=n.$theForm.find(".ff-step-container").attr("data-disable_auto_focus");if(!n.isInitialLoad)if(r){var o=i.find("input, .ff-custom_html, select, textarea, button, a").filter(":visible");o.length&&a&&setTimeout(function(){o.first().focus()},e+50),n.isInitialLoad=!1}else{var l;!(null===(l=window.fluentFormVars)||void 0===l||!l.step_change_focus)&&setTimeout(function(){t("".concat(n.formSelector," .fluentform-step.active")).attr("tabindex","-1").focus().removeAttr("tabindex")},e),n.isInitialLoad=!1}};n.$theForm.off("keydown.stepNavigation").on("keydown.stepNavigation",function(e){if(!i&&(" "===e.key||32===e.keyCode)){var a=t("".concat(n.formSelector," .fluentform-step.active .ff-btn-next")),r=t("".concat(n.formSelector," .fluentform-step.active .ff-btn-prev"));return document.activeElement===a[0]?(e.preventDefault(),void a.click()):document.activeElement===r[0]?(e.preventDefault(),void r.click()):void 0}}),this.$theForm.on("ff_to_next_page ff_to_prev_page",function(){i=!0,setTimeout(function(){i=!1,a(n.$theForm.find(".fluentform-step.active"),!0)},e+50)}),"yes"!==this.$theForm.find(".ff-step-container").attr("data-disable_auto_focus")&&0!==n.$theForm.find(".fluentform-step").index(n.$theForm.find(".fluentform-step.active"))&&!this.isInitialLoad&&a(t("".concat(this.formSelector," .fluentform-step.active")),!0),this.isInitialLoad=!1}},{key:"saveStepData",value:function(e,t){var n=this.$,i=e.find(":input").filter(function(e,t){return!n(t).closest(".has-conditions").hasClass("ff_excluded")});i.filter(function(e,t){var i=n(t);return i.parents().hasClass("ff_repeater_table")&&"select"==i.attr("type")&&!i.val()}).prepend("<option selected disabled />");var a=i.serialize();n.each(e.find("[type=file]"),function(e,t){var i={},r=t.name+"[]";i[r]=[],n(t).closest("div").find(".ff-uploaded-list").find(".ff-upload-preview[data-src]").each(function(e,t){i[r][e]=n(this).data("src")}),n.each(i,function(e,t){if(t.length){var i={};i[e]=t,a+="&"+n.param(i)}})});var r={active_step:t,data:a,form_id:e.data("form_id"),action:"fluentform_step_form_save_data"};return n.post(this.fluentFormVars.ajaxUrl,r)}},{key:"maybeAutoSlider",value:function(){var e=this.$;if("yes"==this.$theForm.find(".ff-step-container").attr("data-enable_auto_slider")){var t=function(e){if(1==e.closest(".fluentform-step.active").find(".ff-el-group:not(.ff_excluded):not(.ff-custom_html)").length)if(e.closest(".fluentform-step.active").find(".ff_excluded").length){var t=window.ffTransitionTimeOut||500;setTimeout(function(){e.closest(".fluentform-step.active").find(".ff-btn-next").trigger("click")},t)}else e.closest(".fluentform-step.active").find(".ff-btn-next").trigger("click")};this.$theForm.find(".ff-el-form-check-radio,.ff-el-net-label, .ff-el-ratings label").on("click",function(){t(e(this))}),this.$theForm.find("select").on("change",function(){t(e(this))})}}},{key:"addFilesToElement",value:function(e,t){var n=this.$,i=this,a=e.closest(".ff-el-input--content").find(".ff-uploaded-list");n.each(t,function(e,t){t="object"===d(t)?t:{url:t,data_src:t};var r=n("<div/>",{class:"ff-upload-preview","data-src":t.data_src,style:"border: 1px solid rgb(111, 117, 125)"}),o=n("<div/>",{class:"ff-upload-thumb"});o.append(n("<div/>",{class:"ff-upload-preview-img",style:"background-image: url('".concat(i.getThumbnail(t.url),"');")}));var l=n("<div/>",{class:"ff-upload-details"}),s=n("<span/>",{html:i.fluentFormVars.upload_completed_txt,class:"ff-upload-progress-inline-text ff-inline-block"}),f=t.url.substring(t.url.lastIndexOf("/")+1);f.includes("-ff-")&&(f=f.substring(f.lastIndexOf("-ff-")+4));var c=n("<div/>",{class:"ff-upload-filename",html:f}),u=n('\n <div class="ff-upload-progress-inline ff-el-progress">\n <div style="width: 100%;" class="ff-el-progress-bar"></div>\n </div>\n '),p=n("<span/>",{"data-href":"#",html:"×",class:"ff-upload-remove"}),m=n("<div>",{class:"ff-upload-filesize ff-inline-block",html:""}),h=n("<div>",{class:"ff-upload-error",style:"color:red;"});l.append(c,u,s,m,h,p),r.append(o,l),a.append(r)}),e.trigger("change_remaining",-t.length),e.trigger("change")}},{key:"getThumbnail",value:function(e){if(!e)return"";var t=e.split(/[#?]/)[0].split(".").pop().trim().toLowerCase();if(-1!=["jpg","jpeg","gif","png"].indexOf(t))return e;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 i=n.getContext("2d");return i.fillStyle="rgba(0, 0, 0, 0.2)",i.fillRect(0,0,60,60),i.font="13px Arial",i.fillStyle="white",i.textAlign="center",i.fillText(t,30,30,60),n.toDataURL()}}],t&&h(e.prototype,t),n&&h(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n}();function y(e){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(e)}function _(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function b(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=y(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=y(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==y(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w,x,S=[{type:8,token:"round",show:"round",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t||0===t||(t=2),e=parseFloat(e).toFixed(t),parseFloat(e)}},{type:0,token:"ceil",show:"ceil",value:function(e){return Math.ceil(e)}},{type:0,token:"floor",show:"floor",value:function(e){return Math.floor(e)}},{type:0,token:"abs",show:"abs",value:function(e){return Math.abs(e)}},{type:8,token:"max",show:"max",value:function(e,t){return e>t?e:t}},{type:8,token:"min",show:"min",value:function(e,t){return e<t?e:t}}];function F(e,t){var n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_(Object(n),!0).forEach(function(t){b(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({calculation_error:"Calculation error occurred",invalid_formula:"Invalid formula provided",division_by_zero:"Division by zero error"},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}),i=t.find(".ff_has_formula");if(i.length){var a={},r={};mexp.addToken(S);var o=function(){jQuery.each(i,function(i,a){var r=jQuery(a),o=r.data("calculation_formula"),s=function(e,t){for(var n,i=[],a=RegExp(e,"g");n=a.exec(t);)delete n.input,i.push(n);return i}(/{(.*?)}/g,o),p={};jQuery.each(s,function(e,n){var i=n[0];jQuery.each(["{input.","{select.","{checkbox.","{radio.","{repeat.","{payment."],function(e,n){if(function(e,t){return-1!==e.indexOf(t)}(i,n)){var a=(s=i,m=new RegExp(n+"|}","g"),s.replace(m,"")),r=0;if("{select."===n)r=u(a);else if("{checkbox."===n)r=d(a);else if("{radio."===n)r=c(a);else if("{repeat."===n)r=f(a);else if("{payment."===n)r=function(e){var n=0,i=t.find(":input[data-name="+e+"]");if(i.length&&l(i)){var a=i[0].type;"radio"===a?n=c(e,!0):"hidden"===a?n=i.attr("data-payment_value"):"number"===a||"text"===a?n=window.ff_helper.numericVal(i):"checkbox"===a?n=d(e,!0):"select-one"===a&&(n=u(e,!0))}return n}(a);else{var o=t.find("input[name="+a+"]");l(o)&&(r=window.ff_helper.numericVal(o))}return p[i]=r,!1}var s,m})}),jQuery.each(p,function(e,t){t||(t=0),o=o.split(e).join(t)});var m="";try{o=o.replace(/\n/g,""),(m=mexp.eval(o))===1/0||m===-1/0?(console.log(n.division_by_zero,a),m=""):isNaN(m)&&(console.log(n.invalid_formula,a),m="")}catch(e){console.log(n.calculation_error+":",e,a),m=""}if("text"==r[0].type){var h=e(r),v=h.val(),g=window.ff_helper.formatCurrency(h,m);if(h.val(g).prop("defaultValue",g),""==v)return;v!=g&&h.trigger("change")}else r.text(m)})};t.find("input[type=number],input[data-calc_value],select[data-calc_value],.ff_numeric,.ff_payment_item").on("change keyup",o),o(),t.on("do_calculation",function(){o()}),jQuery(document).on("fluentform_reset",function(){i.val("").prop("defaultValue",""),setTimeout(function(){o()},100)})}function l(e){return!e.closest(".ff_excluded.has-conditions").length}function s(n){var i=0,a=t.find(n);return a.closest(".ff_excluded.has-conditions").length||e.each(a,function(t,n){var a=e(n).attr("data-calc_value");a&&!isNaN(a)&&(i+=Number(a))}),i}function f(n){var i=0,s=n.split("."),f=!1;s.length>1&&(n=s[0],f=s[1]);var c=t.find("table[data-root_name="+n+"]");if(a[n]||(a[n]=!0,c.on("repeat_change",function(){o()})),l(c))if(f){var u=c.find("tbody tr td:nth-child("+f+")");e.each(u,function(t,a){var l=e(a).find(":input"),s=n+"_"+f+"_"+l.attr("id");r[s]||(r[s]=!0,l.on("change",function(){o()}));var c=0;c="select"===l.attr("type")?parseFloat(l.find("option:selected").attr("data-calc_value")):parseFloat(l.val()),isNaN(c)||(i+=c)}),i&&(i=i.toFixed(2))}else i=c.find("tbody tr").length;return i}function c(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=0,a=t.find("input[name="+e+"]:checked");return n?a.attr("data-payment_value"):(l(a)&&(i=a.attr("data-calc_value")||0),i)}function u(e){var n;return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?t.find("select[name="+e+"] option:selected").data("payment_value"):(n=s("select[data-name="+e+"] option:selected"),t.find("select[data-name="+e+"]").attr("data-calc_value",n),n)}function d(e){if(!(arguments.length>1&&void 0!==arguments[1]&&arguments[1]))return s("input[data-name="+e+"]:checked");var n=t.find(":input[data-name="+e+"]").data("group_id"),i=t.find('input[data-group_id="'+n+'"]:checked'),a=0;return i.each(function(e,t){var n=jQuery(t).data("payment_value");n&&(a+=parseFloat(n))}),a}}(w=jQuery)(document.body).on("fluentform_init",function(n,i,a){if(i.attr("data-form_instance"),a){a.form_id_selector;var r="."+a.form_instance;!function(e,t,n,i,a){var r=function(e,t){var i="fluentform_upload_messages_"+n.id;return window[i]&&window[i][e]?window[i][e]:t},o=function(){jQuery.fn.fileupload&&(t.find('input[type="file"]').each(function(o,c){var d,p,m=e(this),h=m.closest(".ff-el-group");h.closest(".ff-column-container").is(".ff_columns_total_6, .ff_columns_total_5, .ff_columns_total_4")&&h.width()<162&&(p=h.width()),d=e("<div/>",{class:"ff-uploaded-list",style:"font-size:12px; margin-top: 15px;"+(p?"max-width:".concat(p,"px;"):"")}),m.closest("div").append(d);var v=d.width(),g=n.rules[m.prop("name")],y=g.max_file_count.value;"max_file_count"in g&&(g.max_file_count.remaining=Number(y));var _="";function b(e){var n=m.prop("name");t.trigger("show_element_error",{element:n,message:e})}function w(i,r){if(r&&r.files&&r.files.length){if(t.find(".ff-upload-preview-elem").remove(),"max_file_count"in g){e(a+"_errors").empty(),e(this).closest("div").find(".error").html("");var o=g.max_file_count.remaining;if(!o||r.files.length>o){var l="Maximum 1 file is allowed!";return l=y>1?"Maximum "+y+" files are allowed!":l,g.max_file_count&&g.max_file_count.message&&(l=g.max_file_count.message),b(l),!1}}var s=f(r.files[0],n.rules[m.prop("name")]);if(s.length)return b(s.join(", ")),!1;var c=m.prop("name");return e('[name="'.concat(c,'"]')).closest("div").find(".error").html(""),m.closest("div").find(".error").html(""),!0}}"allowed_file_types"in g?(_=g.allowed_file_types.value.join("|"),m.prop("accept","."+_.replace(/\|/g,",."))):(_=g.allowed_image_types.value.join("|"))?m.prop("accept","."+_.replace(/\|/g,",.")):m.prop("accept","image/*");var x=e(c);m.fileupload({dataType:"json",dropZone:m.closest(".ff-el-group"),url:i.ajaxUrl,formData:function(e){var t=e.serializeArray();return t.push({name:"action",value:"fluentform_file_upload"}),t.push({name:"formId",value:n.id}),t},change:w,add:function(t,n){if(w(0,n)){var a=e("<div/>",{class:"ff-upload-preview"+(p?" ff-upload-container-small-column-image":"")});n.context=a;var r=e("<div/>",{class:"ff-upload-thumb"}),o=e("<div/>",{class:"ff-upload-details"}),f=e("<div/>",{class:"ff-upload-preview-img",style:"background-image: url('".concat(l(n.files[0]),"');")}),c=e("<div>",{class:"ff-upload-error",style:"color:red;"}),u=e("<span/>",{html:i.upload_start_txt,class:"ff-upload-progress-inline-text ff-inline-block"}),m=e('\n\t\t\t\t\t\t\t\t\t<div class="ff-upload-progress-inline ff-el-progress">\n\t\t\t\t\t\t\t\t\t\t<div class="ff-el-progress-bar"></div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t'),h=e("<div/>",{class:"ff-upload-filename",text:n.files[0].name}),g=e("<span/>",{"data-href":"#","data-attachment-id":"",html:"×",class:"ff-upload-remove"}),y=e("<div>",{class:"ff-upload-filesize ff-inline-block",html:s(n.files[0].size)});r.append(f),o.append(h,m,u,y,c,g),a.append(r,o),d.append(a),p||(v-=91),h.css({maxWidth:v+"px"}),n.submit(),n.context.addClass("ff_uploading")}},progress:function(e,t){var n=parseInt(t.loaded/t.total*100,10);t.context.find(".ff-el-progress-bar").css("width",n+"%"),t.context.find(".ff-upload-progress-inline-text").text(i.uploading_txt)},done:function(e,n){if(n.context.removeClass("ff_uploading"),n.result&&"data"in n.result&&"files"in n.result.data)"error"in n.result.data.files[0]?(b("Upload Error: "+n.result.data.files[0].error),n.context.remove()):(n.context.find(".ff-upload-progress-inline-text").text(i.upload_completed_txt),g.max_file_count.remaining-=1,n.context.attr("data-src",n.result.data.files[0].url),n.context.find(".ff-upload-remove").attr({"data-href":n.result.data.files[0].file,"data-attachment-id":n.result.data.files[0].attachment_id}),n.context.addClass("ff_uploading_complete"),t.find("input[name="+x.data("name")+"]").trigger("change"));else{var a=r("upload_failed_text","Sorry! The upload failed for some unknown reason.");if(n.messages){var o=Object.keys(n.messages);o.length&&(a=n.messages[o[0]])}b(a),n.context.remove()}},fail:function(t,n){var i,a,o,l,s=[];null===(i=n.context)||void 0===i||i.remove(),null!==(a=n.jqXHR)&&void 0!==a&&a.responseJSON&&null!==(o=n.jqXHR)&&void 0!==o&&o.responseJSON.errors?e.each(n.jqXHR.responseJSON.errors,function(t,n){"object"==u(n)?e.each(n,function(e,t){s.push(t)}):s.push(n)}):null!==(l=n.jqXHR)&&void 0!==l&&l.responseText?s.push(n.jqXHR.responseText):s.push(r("upload_error_text","Something is wrong when uploading the file! Please try again")),b(s.join(", "))}}),x.on("change_remaining",function(e,t){g.max_file_count.remaining+=t})}),t.find(".ff_upload_btn").on("keyup click",function(t){t.preventDefault(),t.stopPropagation(),("click"===t.type||"keyup"===t.type&&32===t.keyCode)&&e(this).siblings("input[type=file]").trigger("click")}))},l=function(e){if(e.type.match("image"))return URL.createObjectURL(e);var t=document.createElement("canvas");t.width=60,t.height=60,t.style.zIndex=8,t.style.position="absolute",t.style.border="1px solid";var n=t.getContext("2d");return n.fillStyle="rgba(0, 0, 0, 0.2)",n.fillRect(0,0,60,60),n.font="13px Arial",n.fillStyle="white",n.textAlign="center",n.fillText(e.name.substr(e.name.lastIndexOf(".")+1),30,30,60),t.toDataURL()},s=function(e){return e<1024?e+"bytes":e>=1024&&e<=1048576?(e/1024).toFixed(1)+"KB":e>1048576?(e/1048576).toFixed(1)+"MB":void 0},f=function(e,t){var n=[],i="",a="";if("allowed_file_types"in t?(i=t.allowed_file_types.value,a=t.allowed_file_types.message):"allowed_image_types"in t&&(i=t.allowed_image_types.value,a=t.allowed_image_types.message),i){var r=new RegExp("("+i.join("|")+")","i"),o=e.name.split(".").pop();o=o.toLowerCase(),r.test(o)||n.push(a)}return"max_file_size"in t&&t.max_file_size.value>0&&e.size>t.max_file_size.value&&n.push(t.max_file_size.message),n};o(),t.find(".ff-uploaded-list").on("click",".ff-upload-remove",function(t){t.preventDefault();var n=e(this),a=n.closest(".ff-uploaded-list"),r=a.closest(".ff-el-input--content").find("input[type=file]"),o=n.attr("data-href"),l=n.attr("data-attachment-id");"#"==o?(n.closest(".ff-el-input--content").find(".error").remove(),n.closest(".ff-upload-preview").remove(),a.find(".ff-upload-preview").length||a.siblings(".ff-upload-progress").addClass("ff-hidden"),r.trigger("change_remaining",1)):e.post(i.ajaxUrl,{path:o,attachment_id:l,action:"fluentform_delete_uploaded_file"}).then(function(e){n.closest(".ff-el-input--content").find("input"),r.trigger("change_remaining",1),n.closest(".ff-el-input--content").find(".error").remove(),n.closest(".ff-upload-preview").remove(),a.find(".ff-upload-preview").length||a.siblings(".ff-upload-progress").addClass("ff-hidden"),r.trigger("change")})}),e(document.body).on("fluentform_reset",function(){o()})}(w,i,a,window.fluentFormVars,r),t(i),function(e,t){var n=t.find(".fluentform .js-repeat");e.each(n,function(t,n){var i=e(n);if(i.find(".ff-t-cell").length>1){var a=i.find(".ff-el-group").height()-i.find(".ff-el-group").find(".ff-el-input--content").height();i.find(".js-repeat-buttons").css("margin-top",a+"px")}var r=i.find(".ff-el-group").find(".ff-el-input--content .ff-el-form-control").outerHeight();i.find(".ff-el-repeat-buttons").height(r)})}(w,i),c(w,i,a,window.fluentFormVars);var o=function(e){var t="fluentform_calculation_messages_"+e;return window[t]?window[t]:{calculation_error:"Calculation error occurred",invalid_formula:"Invalid formula provided",division_by_zero:"Division by zero error"}}(a.id);if(F(w,i,o),function(e,t){var n=t.find(".jss-ff-el-ratings");n.length&&e.each(n,function(t,n){var i=e(n);i.find("label.active").prevAll().addClass("active"),i.on("mouseenter","label",function(t){var n=e(this),i="[data-id="+n.find("input").attr("id")+"]";n.addClass("active"),n.prevAll().addClass("active"),n.nextAll().removeClass("active"),n.closest(".ff-el-input--content").find(".ff-el-rating-text").css("display","none"),n.closest(".ff-el-input--content").find(i).css("display","inline-block")}).on("click","label",function(t){var n=e(this).find(".jss-ff-svg");n.addClass("scale"),n.addClass("scalling"),setTimeout(function(e){n.removeClass("scalling"),n.removeClass("scale")},150)}).on("mouseleave",function(t){var n=e(this),i="[data-id="+n.find("input:checked").attr("id")+"]",a=n.find("input:checked").parent("label");a.length?(a.addClass("active"),a.prevAll().addClass("active"),a.nextAll().removeClass("active")):n.find("label").removeClass("active"),n.closest(".ff-el-input--content").find(".ff-el-rating-text").css("display","none"),n.closest(".ff-el-input--content").find(i).css("display","inline-block")})})}(w,i),e(w,i),i.hasClass("ff-form-has-steps")){var l=function(e,t,n,i){return new g(e,t,n,i).getPublicAPI()}(w,i,window.fluentFormVars,r);l.init(),i.on("update_slider",function(e,t){l.updateSlider(t.goBackToStep,t.animDuration,t.isScrollTop,t.actionType)})}i.hasClass("ff_has_dynamic_smartcode")&&(i.on("ff_render_dynamic_smartcodes",function(e,t){s(w(t))}),i.on("keyup change",":input",function(){s(i)}),s(i))}else console.log("No Fluent form JS vars found!");function s(e){jQuery.each(e.find(".ff_dynamic_value"),function(e,t){var n=w(t).data("ref");if("payment_summary"!=n){var a=i.find('.ff-el-form-control[name="'+n+'"]'),r=" ";a.length||(a=i.find('.ff-field_container[data-name="'+n+'"]').find("input")),a.length||((a=i.find('*[name="'+n+'"]:checked')).length||(a=i.find('*[name="'+n+'[]"]:checked'),r=", "),a.length||(a=i.find('*[name="'+n+'[]"]').find("option:selected"),r=", "));var o=[];if(!a.length){var l=i.find('.ff-el-repeater[data-name="'+n+'"] tbody tr');l.each(function(e){var t=w(this).find("input, select"),n=[];t.each(function(e){var t=w(this).val();if(t){var i=w(this).closest("td").data("label")||"Column-"+(e+1);n.push(i+": "+t)}}),n.length&&o.push("#"+(e+1)+"- "+n.join(" | "))}),l.length&&(r="<br/>")}w.each(a,function(){var e=w(this).val(),t=w(this).closest(".ff-el-group.has-conditions").hasClass("ff_excluded");e&&!t&&o.push(e)});var s,f="";f=o.length?o.join(r):w(t).data("fallback"),w(this).html(null==(s=f)?"":("string"!=typeof s&&(s=String(s)),(s=(s=s.replace(/<script[^]*?>[^]*?<\/script>/gi,"").replace(/<iframe[^]*?>[^]*?<\/iframe>/gi,"").replace(/<.*?\bon\w+=["'][^"']*["']/gi,"").replace(/javascript:/gi,"")).replace(/</g,"<").replace(/>/g,">")).replace(/<br\s*\/?>/gi,"<br/>").replace(/\n/g,"<br/>")))}else i.trigger("calculate_payment_summary",{element:w(t)})})}}),(x=String.prototype).startsWith||(x.startsWith=function(e,t){return t=!t||t<0?0:+t,this.substring(t,t+e.length)===e}),x.endsWith||(x.endsWith=function(e,t){return(void 0===t||t>this.length)&&(t=this.length),this.substring(t-e.length,t)===e}),x.includes||(x.includes=function(e,t){if(e instanceof RegExp)throw TypeError("first argument must not be a RegExp");return void 0===t&&(t=0),-1!==this.indexOf(e,t)})})();