// source --> https://westkreuz.org/wp-content/plugins/divi-form-builder/js/multistep.min.js?ver=4.1.11 
let current_step, next_step, previous_step, current_index, steps_count,df_form; //steps
let opacity;
let progress_bar_style;
const current = 1;
let resizeInt = null;

jQuery(document).ready(function ($) {

    jQuery('.de_fb_form .multistep').each(function() {
        df_form = jQuery(this);
        handleFormStep(this);
    });

    jQuery(window).resize(function(){
        setFormHeight();
    }).trigger('resize');

    jQuery('.de_fb_form .multistep textarea').on("mousedown", function(e) {
        resizeInt = setInterval( function() {
            setFormHeight();
        }, 1000/15);
    });
    
    $(window).on("mouseup", function(e) {
        if (resizeInt !== null) {
            clearInterval(resizeInt);
        }
        setFormHeight();
    });
});

function setFormHeight() {
  jQuery('.de_fb_form').each(function() {
    const $container = jQuery(this);
    const $form = $container.find('form.multistep').first();
    if ($form.length) {
      const $activeStep = $form.find('.df_form_step.active').first();
      const $wrapper = $form.find('.divi-form-wrapper').first();
      if ($activeStep.length && $wrapper.length) {
        $wrapper.height($activeStep.outerHeight());
      }
    }
  });
}


// Helper: find the submit button even if it's outside the .multistep node
function findSubmitButton($form) {
  const formId = $form.attr('id');

  // 1) Inside the current multistep node
  let $btn = $form.find('.divi-form-submit').first();
  if ($btn.length) return $btn;

  // 2) Nearest likely containers that usually wrap the multistep + submit
  const $containers = $form.closest('.de_fb_form, form, .divi-form-wrapper');
  if ($containers.length) {
    $btn = $containers.first().find('.divi-form-submit').first();
    if ($btn.length) return $btn;
  }

  // 3) Attribute-based: HTML5 'form' attribute or plugin-specific data attribute
  if (formId) {
    $btn = jQuery(`.divi-form-submit[form="${formId}"], .divi-form-submit[data-form-id="${formId}"]`).first();
    if ($btn.length) return $btn;
  }

  // 4) Fallback: same higher-level form container (avoid stealing from another form)
  const $topDeForm = $form.closest('.de_fb_form');
  if ($topDeForm.length) {
    $btn = $topDeForm.find('.divi-form-submit').first();
    if ($btn.length) return $btn;
  }

  // 5) Absolute last resort: nearest sibling relation
  $btn = $form.parent().find('> .divi-form-submit').first();
  if ($btn.length) return $btn;

  return jQuery(); // empty set
}

function handleFormStep(form) {
  const $form = jQuery(form);
  const formId = $form.attr('id');

  if ($form.data('ms-initialised')) return;

  jQuery('.empty_module', form).remove();

  // Ensure steps live inside the wrapper
  const $wrapperDiv = $form.find('.divi-form-wrapper').first();
  if ($wrapperDiv.length) {
    const $looseSteps = $form.children('.df_form_step');
    if ($looseSteps.length) $wrapperDiv.append($looseSteps.detach());
    const $looseBits = $form.children('.step_button_wrapper, .et_contact_bottom_container.in_step');
    if ($looseBits.length) $wrapperDiv.append($looseBits.detach());
  }

  // Re-select steps
  let $steps = jQuery('.df_form_step', $form);
  const stepCount = $steps.length;
  if (!stepCount) {
    console.warn('No .df_form_step elements found for form:', formId);
    return;
  }

  // --- CLEANUP: remove stray wrappers not inside a step
  $form.find('.divi-form-wrapper > .step_button_wrapper').each(function () {
    if (!jQuery(this).closest('.df_form_step').length) jQuery(this).remove();
  });

  // --- DEDUP: keep only one wrapper per step (keep the last one)
  $steps.each(function () {
    const $w = jQuery(this).children('.step_button_wrapper');
    if ($w.length > 1) $w.not(':last').remove();
  });

  // Ensure exactly one active step and hide the rest
  if (!$steps.filter('.active').length) {
    $steps.removeClass('active').hide().first().addClass('active').show();
  } else {
    $steps.hide().filter('.active').show();
  }

  const isMulti = stepCount > 1;
  if (isMulti) jQuery('.et_contact_bottom_container', form).hide();

  const $lastStep = $steps.last();
  const $beforeLast = stepCount >= 2 ? $steps.eq(-2) : jQuery();
  const previousStepNumber = $beforeLast.length ? $beforeLast.index() : 0;

  // in_step container inside last step
  let $inStep = $lastStep.children('.et_contact_bottom_container.in_step');
  if (!$inStep.length) {
    $inStep = jQuery('<div class="et_contact_bottom_container in_step" style="display:none;"></div>');
    $lastStep.append($inStep);
  }

  // Move captcha/bloom into in_step
  jQuery('.et_contact_bottom_container:not(.in_step) .captcha-field', form).appendTo($inStep);
  jQuery('.et_contact_bottom_container:not(.in_step) .bloom_subscribe', form).appendTo($inStep);

  // Wrapper in last step (dedup if multiple)
  let $wrapper = $lastStep.children('.step_button_wrapper');
  if ($wrapper.length > 1) {
    $wrapper.not(':last').remove();
    $wrapper = $lastStep.children('.step_button_wrapper');
  }
  if (!$wrapper.length) {
    $wrapper = jQuery('<div class="step_button_wrapper"></div>');
    $lastStep.append($wrapper);
  }

  // Prev button (only for multi-step and if missing)
  if (isMulti && !$wrapper.find('.df_step_prev').length) {
    $wrapper.prepend(
      `<button class="et_pb_button df_step_button df_step_prev" data-step="${previousStepNumber}">Prev</button>`
    );
  }

  // Find & move the actual submit button into the last step wrapper
  const $submitBtn = findSubmitButton($form);
  if ($submitBtn.length && !$wrapper.find('.divi-form-submit').length) {
    $wrapper.append($submitBtn.detach());
  } else if (!$submitBtn.length) {
    console.warn('No .divi-form-submit found for form (even outside scope):', formId);
  }

  // Update per-step button texts
  jQuery('.df_form_step', form).each(function () {
    const $step = jQuery(this);
    $step.find('.step_button_wrapper button').each(function () {
      const $btn = jQuery(this);
      if ($btn.hasClass('df_step_prev')) {
        $btn.html($step.attr('data-prev_text'));
      } else if ($btn.hasClass('df_step_next')) {
        $btn.html($step.attr('data-next_text'));
      }
    });
  });

  // Scoped events
  $form.off('click.dfPrev', '.df_step_prev').on('click.dfPrev', '.df_step_prev', function (e) {
    prev_button_handler(e);
  });

  jQuery('.special_contact_form .divi-form-wrapper .df_form_step', form)
    .not(':last')
    .each(function () {
      const $step = jQuery(this);
      $step.off('click.autoNext', 'input[type=radio]')
           .on('click.autoNext', 'input[type=radio]', function () {
             $step.find('.df_step_next').trigger('click');
           });
    });

  $form.off('change.autoNext', '.next_on_change input[type=radio], .next_on_change select')
       .on('change.autoNext', '.next_on_change input[type=radio], .next_on_change select', function () {
         jQuery(this).closest('.df_form_step').find('.df_step_next').trigger('click');
       });

  $form.data('ms-initialised', true);
  setTimeout(setFormHeight, 0);
}


if ( typeof ms_obj !== 'undefined' && ms_obj.next_on_enter === 'on' ) {
    jQuery(document).on('keydown', '.fb_form', function(event){
        var keycode = (event.keyCode ? event.keyCode : event.which);
        if(keycode === 13){
            if ( jQuery(this).find('.df_form_step.active').find('.df_step_next').length > 0 ) {
                jQuery(this).find('.df_form_step.active').find('.df_step_next').trigger('click');
            } else {
                jQuery(this).find('.df_form_step.active').find('.divi-form-submit').trigger('click');
            }
        }
        event.stopPropagation();
    });

    jQuery('.fb_form.multistep textarea').keydown( function(event){
        event.stopPropagation();
    });

    jQuery('.fb_form.multistep input:not([type="hidden"])').keyup( function(event){
        var keycode = (event.keyCode ? event.keyCode : event.which);
        if(keycode === 13){
            if ( jQuery(this).closest('.df_form_step.active').find('.df_step_next').length > 0 ) {
                jQuery(this).closest('.df_form_step.active').find('.df_step_next').trigger('click');    
            } else {
                jQuery(this).closest('.df_form_step.active').find('.divi-form-submit').trigger('click');
            }
        }
        event.stopPropagation();
    });
}

function next_button_handler(e, type) {
    e.preventDefault();
    var _this = jQuery(e.target);
    df_form = _this.closest('.fb_form');
    current_step = _this.closest('.df_form_step');
    next_step = current_step.nextAll('.df_form_step').first();
    current_index = jQuery(".df_form_step",df_form).index(next_step);
    steps_count = jQuery(".df_form_step",df_form).length;
    progress_bar_style = jQuery(".df_progressbar",df_form).data("style");

    df_form.attr('data-type', type);

    if ( _this.closest('.fb_form').find('.required, *[required]').length > 0 ) {
        var required_check = true;

        current_step.find('.required, *[required]').each(function(){

            // if field has child .existing_image_preview, remove required class
            if ( jQuery(this).find('.existing_image_preview').length > 0 ) {
                jQuery(this).removeClass('required');
            }

            jQuery(this).closest('.et_pb_contact_field').parent().find('p.error').remove();
            if ( !jQuery(this).closest('.de_fb_form_field').hasClass('condition-hide') ) {
                var field_type = jQuery(this).closest('.et_pb_contact_field').data('type');
                if ( ( field_type === 'checkbox' || field_type === 'radio' ) &&  jQuery(this).find('input:checked').length === 0 ) {
                    required_check = false;
                } else if ( ( field_type === 'file' || field_type === 'image' ) ) {
                    var value_field_id = jQuery(this).find('input.upload_field').attr('id') + '_value';

                    if (jQuery(this).find('.files .template-upload').length === 0 && jQuery(this).find('#' + value_field_id).val() === "") {
                        required_check = false;
                    }

                } else if (!( field_type === 'checkbox' || field_type === 'radio') && jQuery(this).val() === '' ) {
                    /*if ( jQuery(this).val() == '' ) {
                        required_check = false;
                    }*/
                }

                if ( !required_check ) {
                    var required_message = jQuery(this).attr('data-required_message')?jQuery(this).attr('data-required_message'):'This field is required.';
                    var required_message_pos = jQuery(this).attr('data-required_position');

                    if ( required_message_pos === 'top' ) {
                        jQuery(this).closest('.et_pb_contact_field').before('<p class="error">' + required_message + '</p>');
                    } else {
                        jQuery(this).closest('.et_pb_contact_field').after('<p class="error">' + required_message + '</p>');
                    }

                    jQuery('html, body').animate({
                        scrollTop: jQuery(this).closest('.field_wrapper').offset().top - 100
                    }, 300);

                    return false;
                }
            }
        });

        if ( required_check === false ) {
            return false;
        }
    }

    var is_valid = true;
    if ( current_step.find('input, textarea, select').length > 0 ) {
        is_valid = current_step.find('input, textarea, select').valid();
    }

    if ( !is_valid ) {
        return false;
    }

    switch (progress_bar_style) {
        case 'step':
            //Remove class Active
            df_form.find(".df_progressbar_step li").removeClass('active').removeClass('prev-active');
            //Add Class Active
            df_form.find(".df_progressbar_step li").eq(current_index).addClass("active");
            df_form.find(".df_progressbar_step li:lt(" + current_index + ")").addClass("prev-active");
            break;
        case 'basic':
        case 'lollipop':
            let width = parseInt(current_index/(steps_count-1)*100);
            let previous_width = parseInt((current_index-1)/(steps_count-1)*100);

            let interval = 300 / (width - previous_width);
            let i = 1;

            var si = setInterval(function(){
                let cur_width = previous_width + i;
                if ( cur_width <= width ) {
                    df_form.find('.df_progressbar_active').width(`${cur_width}%`);
                    df_form.find('.df_progressbar_percentage').html(`${cur_width}%`);
                    i++;
                } else {
                    clearInterval( si );
                }
            }, interval);
            //df_form.find('.df_progressbar_active').width(`${width}%`)
            break;
    }

    jQuery(".df_form_step", df_form).hide();
    current_step.removeClass('active');
    next_step.addClass('active');
    next_step.show();

    if ( steps_count === current_index +  1) { 
        jQuery(".et_contact_bottom_container", df_form).show(); 
    } 

    df_form.removeAttr('data-type');
    
    // scroll up to the div that has the class .de_fb_form 
    if ( !_this.closest('.fb_form').hasClass('scroll_disabled') ) {
        jQuery('html, body').animate({
            scrollTop: _this.closest(".de_fb_form").offset().top - 150
        }, 300); 
    }

    // focus on the first input element of the next step
    setTimeout(function(){
        next_step.find('.de_fb_form_field:not(:hidden)').find('input:not([type="hidden"]), textarea, select').eq(0).focus();
    }, 100);

    jQuery(document).trigger('dfbStepChanged', [next_step]);
    setFormHeight();
}

jQuery(document).on("click", ".df_step_next", function(e) {
    var df_form = jQuery(e.target).closest('.fb_form');
    var attr = df_form.attr('data-type');
    if ( typeof attr === 'undefined' || attr !== 'type_b' ) {
        next_button_handler(e, 'type_a');    
    }
    // wait half a second and the setFormHeight();
    setTimeout(function(){
        setFormHeight();
    }
    , 10);
});
jQuery(".df_step_next").click(function(e){
    var df_form = jQuery(e.target).closest('.fb_form');
    var attr = df_form.attr('data-type');
    if ( typeof attr === 'undefined' || attr !== 'type_a' ) {
        next_button_handler(e, 'type_b');
    }
    // wait half a second and the setFormHeight();
    setTimeout(function(){
        setFormHeight();
    }
    , 10);
});

function init_step( df_form ) {
    steps_count = jQuery(".df_form_step",df_form).length;
    progress_bar_style = jQuery(".df_progressbar",df_form).data("style");

    switch (progress_bar_style) {
        case 'step':
            //Remove class Active
            df_form.find(".df_progressbar_step li").removeClass('active').removeClass('prev-active');
            //Add Class Active
            df_form.find(".df_progressbar_step li").eq(0).addClass("active");
            break;
        case 'basic':
        case 'lollipop':
            df_form.find('.df_progressbar_active').width(`0%`);
            df_form.find('.df_progressbar_percentage').html(`0%`);
            //df_form.find('.df_progressbar_active').width(`${width}%`)
            break;
    }


    jQuery(".df_form_step", df_form).removeClass('active');
    jQuery(".df_form_step", df_form).eq(0).addClass('active');
    
    // scroll up to the div that has the class .de_fb_form 
    jQuery('html, body').animate({
        scrollTop: df_form.offset().top - 150
    }, 300);
    // focus on the first input element of the next step
    setTimeout(function(){
        jQuery(".df_form_step", df_form).eq(0).find('.de_fb_form_field:not(:hidden)').find('input:not([type="hidden"]), textarea, select').eq(0).focus();
    }, 100);

    setFormHeight();    
}

function prev_button_handler(e) {
    e.preventDefault();
    var _this = jQuery(e.target);
    df_form = _this.closest('.fb_form');
    current_step = _this.closest('.df_form_step');
    previous_step = current_step.prevAll('.df_form_step').first();
    current_index = parseInt(jQuery(".df_form_step",df_form).index(previous_step));
    steps_count = jQuery(".df_form_step",df_form).length;
    progress_bar_style = jQuery(".df_progressbar",df_form).data("style");

    switch (progress_bar_style) {
        case 'step':
            //Remove class Active
            df_form.find(".df_progressbar_step li").removeClass('active').removeClass('prev-active');
            //de-activate current step on progressbar
            df_form.find(".df_progressbar_step li").eq(current_index).addClass("active");
            df_form.find(".df_progressbar_step li:lt(" + current_index + ")").addClass("prev-active");
            break;
        case 'basic':
        case 'lollipop':
            let width = parseInt(current_index/(steps_count-1)*100);
            let previous_width = parseInt((current_index+1)/(steps_count-1)*100);

            let interval = 300 / (previous_width - width);
            let i = 1;

            var si = setInterval(function(){
                let cur_width = previous_width - i;
                if ( cur_width >= width ) {
                    df_form.find('.df_progressbar_active').width(`${cur_width}%`);
                    df_form.find('.df_progressbar_percentage').html(`${cur_width}%`);
                    i++;
                } else {
                    clearInterval( si );
                }
            }, interval);

            break;
    }

    if ( steps_count !== current_index +  1) { 
        jQuery(".et_contact_bottom_container", df_form).hide(); 
    } 

    jQuery(".df_form_step", df_form).hide();
    current_step.removeClass('active');
    //show the previous step
    previous_step.addClass('active').show();
    

    jQuery(document).trigger('dfbStepChanged', [previous_step]);
    setFormHeight();
}

jQuery(document).on("click", ".df_step_prev", function(e) {
    prev_button_handler(e);
    // wait half a second and the setFormHeight();
    setTimeout(function(){
        setFormHeight();
    }
    , 10);
});
jQuery(".df_step_prev").click(function(e){
    prev_button_handler(e);
    // wait half a second and the setFormHeight();
    setTimeout(function(){
        setFormHeight();
    }
    , 10);
});
jQuery(document).on("click", ".divi-form-submit", function(e) {
    // wait half a second and the setFormHeight();
    setTimeout(function(){
        setFormHeight();
    }
    , 10);
});
// source --> https://westkreuz.org/wp-content/plugins/divi-form-builder/js/divi-form-calc.min.js?ver=4.1.11 
function formatPrice(e,a){void 0===a&&(a=2);var t="undefined"!=typeof de_fb_obj&&de_fb_obj.amount_separator?de_fb_obj.amount_separator:",",l="undefined"!=typeof de_fb_obj&&de_fb_obj.amount_decimalpoint?de_fb_obj.amount_decimalpoint:".";console.log("[DEBUG formatPrice] Input price:",e,"Separator:",t,"Decimal point:",l);var c=parseFloat(e).toFixed(a).split(".");c[0]=c[0].replace(/\B(?=(\d{3})+(?!\d))/g,t);var i=c.join(l);return console.log("[DEBUG formatPrice] Output:",i),i}function calculateFieldsOnForm(e){jQuery(e).find('.calculate_field input:not([type="hidden"]), .calculate_field select').trigger("change")}jQuery(document).ready(function($){function check_calculation_validation(e){var a=$("#"+e+"_wrapper").find(".calculation_field"),t=a.data("calculate-logic"),l=a.data("calculate-relation"),c=!1,r=[];return jQuery.each(t,function(e,a){var t=!1,l=jQuery("#"+a[0]+"_wrapper"),c=l.find(".et_pb_contact_field").data("type"),_="",d=a[2],n=""!==d&&!isNaN(d);switch(n&&(d=parseFloat(d)),"checkbox"===c||"radio"===c?(_=[],l.find("input:checked").each(function(){n?_.push(parseFloat(jQuery(this).val())):_.push(jQuery(this).val())})):_=n?parseFloat(jQuery("#"+a[0]).val()):jQuery("#"+a[0]).val(),null===_&&(_=""),a[1]){case"is":t=Array.isArray(_)?_.includes(d):_===d;break;case"is not":t=Array.isArray(_)?!_.includes(d):_!==d;break;case"is greater":if(jQuery.isNumeric(d))if(Array.isArray(_))for(i=0;i<_.size;i++)jQuery.isNumeric(_[i])&&_[i]>d&&(t=!0);else t=jQuery.isNumeric(_)&&_>d;else t=!1;break;case"is less":if(jQuery.isNumeric(d))if(Array.isArray(_))for(i=0;i<_.size;i++)jQuery.isNumeric(_[i])&&_[i]<d&&(t=!0);else t=jQuery.isNumeric(_)&&_<d;else t=!1;break;case"contains":if(Array.isArray(_))for(i=0;i<_.size;i++)-1!==_[i].indexOf(d)&&(t=!0);else t=-1!==_.indexOf(d);break;case"does not contain":if(Array.isArray(_))for(i=0;i<_.length;i++)-1===_[i].indexOf(d)&&(t=!0);else t=-1===_.indexOf(d);break;case"is empty":t=Array.isArray(_)?0===_.length:""===_;break;case"is not empty":t=Array.isArray(_)?0!==_.length:""!==_}r.push(t)}),"any"===l?r.includes(!0)&&(c=!0):r.includes(!1)||(c=!0),c}"undefined"!=typeof de_fb_calc_obj&&(void 0!==de_fb_calc_obj.calc_setting&&$.each(de_fb_calc_obj.calc_setting,function(e,a){var t=a.calc_fields;$.each(t,function(a,l){$("#de_fb_"+l+"_wrapper").length>0&&(t[a]="de_fb_"+l),$("#"+t[a]+"_wrapper").addClass("calculate_field"),$("#"+t[a]+"_wrapper").attr("data-calc_field")?$("#"+t[a]+"_wrapper").attr("data-calc_field",$("#"+t[a]+"_wrapper").attr("data-calc_field")+" "+e):$("#"+t[a]+"_wrapper").attr("data-calc_field",e)})}),$(document).on("change",'.calculate_field input:not([type="hidden"]), .calculate_field select',function(){var calc_field_wrapper=$(this).closest(".calculate_field"),calc_result_field=calc_field_wrapper.attr("data-calc_field").split(" "),form_id=$(this).closest(".de_fb_form").find('input[name="unique_id"]').val(),enable_payment=$(this).closest(".de_fb_form").find('input[name="enable_payment"]').val(),form_display_type=$(this).closest(".de_fb_form").find('input[name="form_display_type"]').val(),payButtonText=$(this).closest(".de_fb_form").find('input[name="popup_button_text"]').val();let submitButton=$(this).closest(".de_fb_form").find('button[type="submit"].divi-form-submit'),labelCurrency=$(this).closest(".de_fb_form").find('input[name="popup_button_text"]').data("currency"),paymentGateway=$(this).closest(".de_fb_form").find('input[name="de_fb_payment_action"]').val();$.each(calc_result_field,function(key,calc_result_field_id){var calc_validation=check_calculation_validation(calc_result_field_id),calc_item=de_fb_calc_obj.calc_setting[calc_result_field_id];if($("#"+calc_result_field_id+"_wrapper").hide(),$("#"+calc_result_field_id+"_wrapper").closest(".de_fb_form_field").hide(),calc_validation)if("off"===calc_item.calc_server){var calc_formula=calc_item.formula,calc_variables=[],calc_result=0;calc_formula.replace(/%%(.*?)%%/g,function(e,a){calc_variables.push(a)}),$.each(calc_variables,function(e,a){var t=a;$("#de_fb_"+a+"_wrapper").length>0&&(t="de_fb_"+a);var l=$("#"+t+"_wrapper").find(".et_pb_contact_field").attr("data-type"),c=0;"input"===l||"number"===l?void 0!==(c=$("#"+t+"_wrapper").find('input:not([type="hidden"])').val())&&""!==c||(c=$("#"+t+"_wrapper").find('input:not([type="hidden"])').attr("data-calc_default")):"checkbox"===l||"radio"===l?$.each($("#"+t+"_wrapper").find("input:checked"),function(e,a){c+=parseFloat($(a).attr("data-calc_value"))}):"select"===l&&(c=$("#"+t+"_wrapper").find("select option:selected").attr("data-calc_value")),void 0!==c&&""!==c||(c=0),$("."+a+"_value").html(c),calc_formula=calc_formula.replace("%%"+a+"%%",c)}),calc_result=eval(calc_formula),$("#"+calc_result_field_id+"_wrapper").find("input.result").val(calc_result),$("#"+calc_result_field_id+"_wrapper").find("span.result").html(formatPrice(calc_result)),"on"===enable_payment&&$(".cost-wrap").length>0&&($("input#de_fb_payment_amount").val(parseFloat(calc_result).toFixed(2)),$(".plan-price").find("span.price").html(formatPrice(calc_result))),"in_overlay"===form_display_type&&"stripe"===paymentGateway&&$(".cost-wrap").length>0&&(payButtonText=payButtonText.replace("%s",labelCurrency+formatPrice(calc_result)),submitButton.text(payButtonText).attr("id","open-popup")),$("#"+calc_result_field_id+"_wrapper").show(),$("#"+calc_result_field_id+"_wrapper").closest(".de_fb_form_field").show(),$("#"+calc_result_field_id+"_wrapper").closest(".fb_form").hasClass("multistep")&&"function"==typeof setFormHeight&&setFormHeight(),jQuery.event.trigger({type:"divi_fb_calculated",elem:$("#"+calc_result_field_id+"_wrapper")})}else{var ajax_field_all=$("#"+calc_result_field_id+"_wrapper").find(".calculation_field").attr("data-ajax_fields"),ajax_submit=!0,calc_variables=calc_item.calc_fields,ajax_calc_values={};$.each(calc_variables,function(e,a){var t=a;$("#de_fb_"+a+"_wrapper").length>0&&(t="de_fb_"+a);var l=$("#"+t+"_wrapper").find(".et_pb_contact_field").attr("data-type"),c="";if("input"===l||"number"===l?void 0!==(c=$("#"+t+"_wrapper").find('input:not([type="hidden"])').val())&&""!==c||(c=$("#"+t+"_wrapper").find('input:not([type="hidden"])').attr("data-calc_default")):"checkbox"===l||"radio"===l?$.each($("#"+t+"_wrapper").find("input:checked"),function(e,a){""===c&&(c=0),c=parseFloat(c)+parseFloat($(a).attr("data-calc_value"))}):"select"===l&&(c=$("#"+t+"_wrapper").find("select option:selected").attr("data-calc_value")),void 0===c||""===c){if("on"===ajax_field_all)return void(ajax_submit=!1);c=0}ajax_calc_values[a]=parseFloat(c)}),ajax_submit&&$.ajax({url:de_fb_calc_obj.ajax_url,type:"post",data:{action:"de_fb_calculate_handler",form_id:form_id,calc_id:calc_result_field_id,calc_values:ajax_calc_values,_ajax_nonce:de_fb_calc_obj.nonce},dataType:"JSON",success:function(e){var a=$("#"+calc_result_field_id+"_wrapper").find(".calculation_field").data("decimal");""!==a&&(e.calc_result=parseFloat(e.calc_result).toFixed(a)),$("#"+calc_result_field_id+"_wrapper").find("input.result").val(e.calc_result),e.calc_content?$("#"+calc_result_field_id+"_wrapper").find(".calculation_content").html(e.calc_content):$("#"+calc_result_field_id+"_wrapper").find("span.result").html(formatPrice(e.calc_result)),$("#"+calc_result_field_id+"_wrapper").show(),$("#"+calc_result_field_id+"_wrapper").closest(".de_fb_form_field").show(),$("#"+calc_result_field_id+"_wrapper").closest(".fb_form").hasClass("multistep")&&"function"==typeof setFormHeight&&setFormHeight(),"on"===enable_payment&&$(".cost-wrap").length>0&&($("input#de_fb_payment_amount").val(parseFloat(e.calc_result).toFixed(2)),$(".plan-price").find("span.price").html(formatPrice(e.calc_result))),"in_overlay"===form_display_type&&"stripe"===paymentGateway&&(payButtonText=payButtonText.replace("%s",labelCurrency+formatPrice(e.calc_result)),submitButton.text(payButtonText).attr("id","open-popup")),jQuery.event.trigger({type:"divi_fb_calculated",elem:$("#"+calc_result_field_id+"_wrapper")})}})}else $("#"+calc_result_field_id+"_wrapper").find("input.result").val(""),$("#"+calc_result_field_id+"_wrapper").find("span.result").html(""),$("#"+calc_result_field_id+"_wrapper").find(".calc_content_field").html(""),$("#"+calc_result_field_id+"_wrapper").hide(),$("#"+calc_result_field_id+"_wrapper").closest(".de_fb_form_field").hide()})}),$(".de_fb_form").each(function(){calculateFieldsOnForm(this)}))});
// source --> https://westkreuz.org/wp-content/plugins/woocommerce/assets/js/jquery-blockui/jquery.blockUI.min.js?ver=2.7.0-wc.10.5.2 
/*!
 * jQuery blockUI plugin
 * Version 2.70.0-2014.11.23
 * Requires jQuery v1.7 or later
 *
 * Examples at: http://malsup.com/jquery/block/
 * Copyright (c) 2007-2013 M. Alsup
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Thanks to Amir-Hossein Sobhi for some excellent contributions!
 */
!function(){"use strict";function e(e){e.fn._fadeIn=e.fn.fadeIn;var t=e.noop||function(){},o=/MSIE/.test(navigator.userAgent),n=/MSIE 6.0/.test(navigator.userAgent)&&!/MSIE 8.0/.test(navigator.userAgent),i=(document.documentMode,"function"==typeof document.createElement("div").style.setExpression&&document.createElement("div").style.setExpression);e.blockUI=function(e){d(window,e)},e.unblockUI=function(e){a(window,e)},e.growlUI=function(t,o,n,i){var s=e('<div class="growlUI"></div>');t&&s.append("<h1>"+t+"</h1>"),o&&s.append("<h2>"+o+"</h2>"),n===undefined&&(n=3e3);var l=function(t){t=t||{},e.blockUI({message:s,fadeIn:"undefined"!=typeof t.fadeIn?t.fadeIn:700,fadeOut:"undefined"!=typeof t.fadeOut?t.fadeOut:1e3,timeout:"undefined"!=typeof t.timeout?t.timeout:n,centerY:!1,showOverlay:!1,onUnblock:i,css:e.blockUI.defaults.growlCSS})};l();s.css("opacity");s.on("mouseover",function(){l({fadeIn:0,timeout:3e4});var t=e(".blockMsg");t.stop(),t.fadeTo(300,1)}).on("mouseout",function(){e(".blockMsg").fadeOut(1e3)})},e.fn.block=function(t){if(this[0]===window)return e.blockUI(t),this;var o=e.extend({},e.blockUI.defaults,t||{});return this.each(function(){var t=e(this);o.ignoreIfBlocked&&t.data("blockUI.isBlocked")||t.unblock({fadeOut:0})}),this.each(function(){"static"==e.css(this,"position")&&(this.style.position="relative",e(this).data("blockUI.static",!0)),this.style.zoom=1,d(this,t)})},e.fn.unblock=function(t){return this[0]===window?(e.unblockUI(t),this):this.each(function(){a(this,t)})},e.blockUI.version=2.7,e.blockUI.defaults={message:"<h1>Please wait...</h1>",title:null,draggable:!0,theme:!1,css:{padding:0,margin:0,width:"30%",top:"40%",left:"35%",textAlign:"center",color:"#000",border:"3px solid #aaa",backgroundColor:"#fff",cursor:"wait"},themedCSS:{width:"30%",top:"40%",left:"35%"},overlayCSS:{backgroundColor:"#000",opacity:.6,cursor:"wait"},cursorReset:"default",growlCSS:{width:"350px",top:"10px",left:"",right:"10px",border:"none",padding:"5px",opacity:.6,cursor:"default",color:"#fff",backgroundColor:"#000","-webkit-border-radius":"10px","-moz-border-radius":"10px","border-radius":"10px"},iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank",forceIframe:!1,baseZ:1e3,centerX:!0,centerY:!0,allowBodyStretch:!0,bindEvents:!0,constrainTabKey:!0,fadeIn:200,fadeOut:400,timeout:0,showOverlay:!0,focusInput:!0,focusableElements:":input:enabled:visible",onBlock:null,onUnblock:null,onOverlayClick:null,quirksmodeOffsetHack:4,blockMsgClass:"blockMsg",ignoreIfBlocked:!1};var s=null,l=[];function d(d,c){var u,b,h=d==window,k=c&&c.message!==undefined?c.message:undefined;if(!(c=e.extend({},e.blockUI.defaults,c||{})).ignoreIfBlocked||!e(d).data("blockUI.isBlocked")){if(c.overlayCSS=e.extend({},e.blockUI.defaults.overlayCSS,c.overlayCSS||{}),u=e.extend({},e.blockUI.defaults.css,c.css||{}),c.onOverlayClick&&(c.overlayCSS.cursor="pointer"),b=e.extend({},e.blockUI.defaults.themedCSS,c.themedCSS||{}),k=k===undefined?c.message:k,h&&s&&a(window,{fadeOut:0}),k&&"string"!=typeof k&&(k.parentNode||k.jquery)){var y=k.jquery?k[0]:k,m={};e(d).data("blockUI.history",m),m.el=y,m.parent=y.parentNode,m.display=y.style.display,m.position=y.style.position,m.parent&&m.parent.removeChild(y)}e(d).data("blockUI.onUnblock",c.onUnblock);var g,v,I,w,U=c.baseZ;g=o||c.forceIframe?e('<iframe class="blockUI" style="z-index:'+U+++';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+c.iframeSrc+'"></iframe>'):e('<div class="blockUI" style="display:none"></div>'),v=c.theme?e('<div class="blockUI blockOverlay ui-widget-overlay" style="z-index:'+U+++';display:none"></div>'):e('<div class="blockUI blockOverlay" style="z-index:'+U+++';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>'),c.theme&&h?(w='<div class="blockUI '+c.blockMsgClass+' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+(U+10)+';display:none;position:fixed">',c.title&&(w+='<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(c.title||"&nbsp;")+"</div>"),w+='<div class="ui-widget-content ui-dialog-content"></div>',w+="</div>"):c.theme?(w='<div class="blockUI '+c.blockMsgClass+' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(U+10)+';display:none;position:absolute">',c.title&&(w+='<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(c.title||"&nbsp;")+"</div>"),w+='<div class="ui-widget-content ui-dialog-content"></div>',w+="</div>"):w=h?'<div class="blockUI '+c.blockMsgClass+' blockPage" style="z-index:'+(U+10)+';display:none;position:fixed"></div>':'<div class="blockUI '+c.blockMsgClass+' blockElement" style="z-index:'+(U+10)+';display:none;position:absolute"></div>',I=e(w),k&&(c.theme?(I.css(b),I.addClass("ui-widget-content")):I.css(u)),c.theme||v.css(c.overlayCSS),v.css("position",h?"fixed":"absolute"),(o||c.forceIframe)&&g.css("opacity",0);var x=[g,v,I],C=e(h?"body":d);e.each(x,function(){this.appendTo(C)}),c.theme&&c.draggable&&e.fn.draggable&&I.draggable({handle:".ui-dialog-titlebar",cancel:"li"});var S=i&&(!e.support.boxModel||e("object,embed",h?null:d).length>0);if(n||S){if(h&&c.allowBodyStretch&&e.support.boxModel&&e("html,body").css("height","100%"),(n||!e.support.boxModel)&&!h)var E=p(d,"borderTopWidth"),O=p(d,"borderLeftWidth"),T=E?"(0 - "+E+")":0,M=O?"(0 - "+O+")":0;e.each(x,function(e,t){var o=t[0].style;if(o.position="absolute",e<2)h?o.setExpression("height","Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:"+c.quirksmodeOffsetHack+') + "px"'):o.setExpression("height",'this.parentNode.offsetHeight + "px"'),h?o.setExpression("width",'jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'):o.setExpression("width",'this.parentNode.offsetWidth + "px"'),M&&o.setExpression("left",M),T&&o.setExpression("top",T);else if(c.centerY)h&&o.setExpression("top",'(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"'),o.marginTop=0;else if(!c.centerY&&h){var n="((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "+(c.css&&c.css.top?parseInt(c.css.top,10):0)+') + "px"';o.setExpression("top",n)}})}if(k&&(c.theme?I.find(".ui-widget-content").append(k):I.append(k),(k.jquery||k.nodeType)&&e(k).show()),(o||c.forceIframe)&&c.showOverlay&&g.show(),c.fadeIn){var B=c.onBlock?c.onBlock:t,j=c.showOverlay&&!k?B:t,H=k?B:t;c.showOverlay&&v._fadeIn(c.fadeIn,j),k&&I._fadeIn(c.fadeIn,H)}else c.showOverlay&&v.show(),k&&I.show(),c.onBlock&&c.onBlock.bind(I)();if(r(1,d,c),h?(s=I[0],l=e(c.focusableElements,s),c.focusInput&&setTimeout(f,20)):function(e,t,o){var n=e.parentNode,i=e.style,s=(n.offsetWidth-e.offsetWidth)/2-p(n,"borderLeftWidth"),l=(n.offsetHeight-e.offsetHeight)/2-p(n,"borderTopWidth");t&&(i.left=s>0?s+"px":"0");o&&(i.top=l>0?l+"px":"0")}(I[0],c.centerX,c.centerY),c.timeout){var z=setTimeout(function(){h?e.unblockUI(c):e(d).unblock(c)},c.timeout);e(d).data("blockUI.timeout",z)}}}function a(t,o){var n,i,d=t==window,a=e(t),u=a.data("blockUI.history"),f=a.data("blockUI.timeout");f&&(clearTimeout(f),a.removeData("blockUI.timeout")),o=e.extend({},e.blockUI.defaults,o||{}),r(0,t,o),null===o.onUnblock&&(o.onUnblock=a.data("blockUI.onUnblock"),a.removeData("blockUI.onUnblock")),i=d?e(document.body).children().filter(".blockUI").add("body > .blockUI"):a.find(">.blockUI"),o.cursorReset&&(i.length>1&&(i[1].style.cursor=o.cursorReset),i.length>2&&(i[2].style.cursor=o.cursorReset)),d&&(s=l=null),o.fadeOut?(n=i.length,i.stop().fadeOut(o.fadeOut,function(){0==--n&&c(i,u,o,t)})):c(i,u,o,t)}function c(t,o,n,i){var s=e(i);if(!s.data("blockUI.isBlocked")){t.each(function(e,t){this.parentNode&&this.parentNode.removeChild(this)}),o&&o.el&&(o.el.style.display=o.display,o.el.style.position=o.position,o.el.style.cursor="default",o.parent&&o.parent.appendChild(o.el),s.removeData("blockUI.history")),s.data("blockUI.static")&&s.css("position","static"),"function"==typeof n.onUnblock&&n.onUnblock(i,n);var l=e(document.body),d=l.width(),a=l[0].style.width;l.width(d-1).width(d),l[0].style.width=a}}function r(t,o,n){var i=o==window,l=e(o);if((t||(!i||s)&&(i||l.data("blockUI.isBlocked")))&&(l.data("blockUI.isBlocked",t),i&&n.bindEvents&&(!t||n.showOverlay))){var d="mousedown mouseup keydown keypress keyup touchstart touchend touchmove";t?e(document).on(d,n,u):e(document).off(d,u)}}function u(t){if("keydown"===t.type&&t.keyCode&&9==t.keyCode&&s&&t.data.constrainTabKey){var o=l,n=!t.shiftKey&&t.target===o[o.length-1],i=t.shiftKey&&t.target===o[0];if(n||i)return setTimeout(function(){f(i)},10),!1}var d=t.data,a=e(t.target);return a.hasClass("blockOverlay")&&d.onOverlayClick&&d.onOverlayClick(t),a.parents("div."+d.blockMsgClass).length>0||0===a.parents().children().filter("div.blockUI").length}function f(e){if(l){var t=l[!0===e?l.length-1:0];t&&t.trigger("focus")}}function p(t,o){return parseInt(e.css(t,o),10)||0}}"function"==typeof define&&define.amd&&define.amd.jQuery?define(["jquery"],e):e(jQuery)}();