// source --> http://labaronessa.be/wp-content/plugins/profile-builder-pro/add-ons-advanced/woocommerce/assets/js/country-select.js?ver=6.9.4 
jQuery( function( $ ) {

    /* State/Country select boxes */
    var states_json = wc_country_select_params.countries.replace( /&quot;/g, '"' ),
        states = JSON.parse( states_json),
        locale_json = wc_country_select_params.locale;
        
        if( typeof locale_json != 'undefined' && locale_json != '' ){
            var locale = JSON.parse( locale_json );
        }

    $( 'body' ).on( 'change', 'select.country_to_state', function() {

        var country = $( this ).val(),
            $statebox = $( this ).closest( 'ul' ).find( '#billing_state, #shipping_state' ),
            input_name = $statebox.attr( 'name' ),
            input_id = $statebox.attr( 'id');
            $statebox.val("");

        if( typeof input_name != "undefined") {//this was added for compatibility with conditional logic. Our hide show function trigger a change event and since we might not have a name attribute but a condifional-name attribute input_name could be undefined

            if ($('.wppb-required', $statebox.parent()).length > 0) {
                $('.wppb-required', $statebox.parent()).show();
            } else {
                $('label', $statebox.parent()).append('<span class="wppb-required" title="This field is required">*</span>');
                $('.wppb-required', $statebox.parent()).show();
            }

            if (states[country]) {    //we have states in the selected country

                if (!($.isEmptyObject(states[country]))) {

                    var options = '',
                        state = states[country];

                    for (var index in state) {
                        if (state.hasOwnProperty(index)) {
                            options = options + '<option value="' + index + '">' + state[index] + '</option>';
                        }
                    }

                    if ($statebox.is('input')) {
                        // Change for select
                        $statebox.replaceWith('<select name="' + input_name + '" id="' + input_id + '" class="custom_field_state_select" value=""></select>');
                        $statebox = $(this).closest('ul').find('#billing_state, #shipping_state');
                    }

                    $statebox.html('<option value="">' + wc_country_select_params.i18n_select_state_text + '</option>' + options);

                    $statebox.parent().show();

                } else {  // states array empty for this country; this means we need to hide the states field to mimic WooCommerce behaviour
                    $statebox.parent().hide();
                }

            } else {  //states[country] is not defined

                $statebox.parent().show();
                // Remove asterisk if State field is not required
                if (locale && (typeof (locale[country]) != 'undefined')) {

                    if (typeof (locale[country].state) != 'undefined') {

                        if ((typeof (locale[country].state.required) != 'undefined') && (locale[country].state.required == false)) {

                            $('.wppb-required', $statebox.parent()).hide();
                        }

                    }

                }

                $statebox.replaceWith('<input type="text" class="extra_field_input" name="' + input_name + '" id="' + input_id + '" value="" />');

            }
        }
    });
});
// source --> http://labaronessa.be/wp-content/plugins/shopengine/assets/js/shopengine-modal.js?ver=4.8.9 
jQuery((function(o){"use strict";var e=o(".se-modal-wrapper");e.on(o.modal.OPEN,(function(o,e){if(!0!==e.options.ifIframe)return;let t=e.$elm.find("iframe");t.on("load",(function(){t.contents().find("head").append('<base target="_parent" />'),e.$elm.addClass("se-loaded iframeLoaded")}))})),e.on(o.modal.AFTER_CLOSE,(function(o,e){e.$elm.removeClass("se-loaded iframeLoaded ajaxLoaded")}))})),function(o){"object"==typeof module&&"object"==typeof module.exports?o(require("jquery"),window,document):o(jQuery,window,document)}((function(o,e,t,i){var s=[],l=function(){return s.length?s[s.length-1]:null},n=function(){var o,e=!1;for(o=s.length-1;o>=0;o--)s[o].$blocker&&(s[o].$blocker.toggleClass("current",!e).toggleClass("behind",e),e=!0)};o.modal=function(e,t){var i,n;if(this.$body=o("body"),this.options=o.extend({},o.modal.defaults,t),this.options.doFade=!isNaN(parseInt(this.options.fadeDuration,10)),this.$blocker=null,this.options.closeExisting)for(;o.modal.isActive();)o.modal.close();if(s.push(this),e.is("a"))if(n=e.attr("href"),this.anchor=e,/^#/.test(n)){if(this.$elm=o(n),1!==this.$elm.length)return null;this.$body.append(this.$elm),this.open()}else this.$elm=o("<div>"),this.$body.append(this.$elm),i=function(o,e){e.elm.remove()},this.showSpinner(),e.trigger(o.modal.AJAX_SEND),o.get(n).done((function(t){if(o.modal.isActive()){e.trigger(o.modal.AJAX_SUCCESS);var s=l();s.$elm.empty().append(t).on(o.modal.CLOSE,i),s.hideSpinner(),s.open(),e.trigger(o.modal.AJAX_COMPLETE)}})).fail((function(){e.trigger(o.modal.AJAX_FAIL),l().hideSpinner(),s.pop(),e.trigger(o.modal.AJAX_COMPLETE)}));else this.$elm=e,this.anchor=e,this.$body.append(this.$elm),this.open()},o.modal.prototype={constructor:o.modal,open:function(){var e=this;this.block(),this.anchor.blur(),this.options.doFade?setTimeout((function(){e.show()}),this.options.fadeDuration*this.options.fadeDelay):this.show(),o(t).off("keydown.modal").on("keydown.modal",(function(o){var e=l();27===o.which&&e.options.escapeClose&&e.close()})),this.options.clickClose&&this.$blocker.click((function(e){e.target===this&&o.modal.close()}))},close:function(){s.pop(),this.unblock(),this.hide(),o.modal.isActive()||o(t).off("keydown.modal")},block:function(){this.$elm.trigger(o.modal.BEFORE_BLOCK,[this._ctx()]),this.$doc=o(t),this.$prevWidth=this.$doc.width(),this.$body.css("overflow","hidden").css("padding-right",this.$doc.width()-this.$prevWidth),this.$blocker=o('<div class="'+this.options.blockerClass+' se-blocker current"></div>').appendTo(this.$body),n(),this.options.doFade&&this.$blocker.css("opacity",0).animate({opacity:1},this.options.fadeDuration),this.$elm.trigger(o.modal.BLOCK,[this._ctx()])},unblock:function(e){!e&&this.options.doFade?this.$blocker.fadeOut(this.options.fadeDuration,this.unblock.bind(this,!0)):(this.$blocker.children().appendTo(this.$body),this.$blocker.remove(),this.$blocker=null,n(),o.modal.isActive()||this.$body.css({overflow:"","padding-right":""}))},show:function(){this.$elm.trigger(o.modal.BEFORE_OPEN,[this._ctx()]),this.options.showClose&&(this.closeButton=o('<a title="Close Modal" href="#close-modal" rel="modal:close" class="se-close-modal '+this.options.closeClass+'">'+this.options.closeText+"</a>"),this.$elm.append(this.closeButton)),this.$elm.addClass(this.options.modalClass).appendTo(this.$blocker),this.options.doFade?this.$elm.css({opacity:0,display:"inline-block"}).animate({opacity:1},this.options.fadeDuration):this.$elm.css("display","inline-block"),this.$elm.trigger(o.modal.OPEN,[this._ctx()])},hide:function(){this.$elm.trigger(o.modal.BEFORE_CLOSE,[this._ctx()]),this.closeButton&&this.closeButton.remove();var e=this;this.options.doFade?this.$elm.fadeOut(this.options.fadeDuration,(function(){e.$elm.trigger(o.modal.AFTER_CLOSE,[e._ctx()])})):this.$elm.hide(0,(function(){e.$elm.trigger(o.modal.AFTER_CLOSE,[e._ctx()])})),this.$elm.trigger(o.modal.CLOSE,[this._ctx()])},showSpinner:function(){this.options.showSpinner&&(this.spinner=this.spinner||o('<div class="se-'+this.options.modalClass+'-spinner"></div>').append(this.options.spinnerHtml),this.$body.append(this.spinner),this.spinner.show())},hideSpinner:function(){this.spinner&&this.spinner.remove()},_ctx:function(){return{elm:this.$elm,$elm:this.$elm,$blocker:this.$blocker,options:this.options,$anchor:this.anchor}}},o.modal.close=function(e){if(o.modal.isActive()){e&&e.preventDefault();var t=l();return t.close(),t.$elm}},o.modal.isActive=function(){return s.length>0},o.modal.getCurrent=l,o.modal.defaults={closeExisting:!0,escapeClose:!0,clickClose:!0,closeText:"Close",closeClass:"",modalClass:"se-modal",blockerClass:"jquery-modal",spinnerHtml:'<div class="rect1"></div><div class="rect2"></div><div class="rect3"></div><div class="rect4"></div>',showSpinner:!0,showClose:!0,fadeDuration:null,fadeDelay:1},o.modal.BEFORE_BLOCK="modal:before-block",o.modal.BLOCK="modal:block",o.modal.BEFORE_OPEN="modal:before-open",o.modal.OPEN="modal:open",o.modal.BEFORE_CLOSE="modal:before-close",o.modal.CLOSE="modal:close",o.modal.AFTER_CLOSE="modal:after-close",o.modal.AJAX_SEND="modal:ajax:send",o.modal.AJAX_SUCCESS="modal:ajax:success",o.modal.AJAX_FAIL="modal:ajax:fail",o.modal.AJAX_COMPLETE="modal:ajax:complete",o.fn.seModal=function(e){return 1===this.length&&new o.modal(this,e),this},o.fn.modal&&o.fn.modal.Constructor||(o.fn.modal=o.fn.seModal),o(t).on("click.semodal",'a[rel~="modal:close"]',o.modal.close),o(t).on("click.semodal",'a[rel~="modal:open"]',(function(e){e.preventDefault(),o(this).seModal()}))}));