// source --> https://budget.haus/wp-content/plugins/cookie-law-info/public/js/cookie-law-info-public.js?ver=2.0.1 
CLI_ACCEPT_COOKIE_NAME =(typeof CLI_ACCEPT_COOKIE_NAME !== 'undefined' ? CLI_ACCEPT_COOKIE_NAME : 'viewed_cookie_policy');
CLI_PREFERNCE_COOKIE =(typeof CLI_PREFERNCE_COOKIE !== 'undefined' ? CLI_PREFERNCE_COOKIE : 'CookieLawInfoConsent');
CLI_ACCEPT_COOKIE_EXPIRE =(typeof CLI_ACCEPT_COOKIE_EXPIRE !== 'undefined' ? CLI_ACCEPT_COOKIE_EXPIRE : 365);
CLI_COOKIEBAR_AS_POPUP=(typeof CLI_COOKIEBAR_AS_POPUP !== 'undefined' ? CLI_COOKIEBAR_AS_POPUP : false);
var CLI_Cookie={
	set: function (name, value, days) {
		var secure = "";
		if ( true === Boolean( Cli_Data.secure_cookies ) ) secure = ";secure";
        if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            var expires = "; expires=" + date.toGMTString();
        } else
            var expires = "";
        document.cookie = name + "=" + value + secure + expires + "; path=/";
        if(days<1)
        {
            host_name=window.location.hostname;
            document.cookie = name + "=" + value + expires + "; path=/; domain=."+host_name+";";
            if(host_name.indexOf("www")!=1)
			{  
			   var host_name_withoutwww=host_name.replace('www','');
			   document.cookie = name + "=" + value + secure + expires + "; path=/; domain="+host_name_withoutwww+";";
			}
            host_name=host_name.substring(host_name.lastIndexOf(".", host_name.lastIndexOf(".")-1));
            document.cookie = name + "=" + value + secure + expires + "; path=/; domain="+host_name+";";
        }
    },
    read: function (name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') {
                c = c.substring(1, c.length);
            }
            if (c.indexOf(nameEQ) === 0) {
                return c.substring(nameEQ.length, c.length);
            }
        }
        return null;
    },
    erase: function (name) {
        this.set(name, "", -10);
    },
    exists: function (name) {
        return (this.read(name) !== null);
    },
    getallcookies:function() 
    {
	    var pairs = document.cookie.split(";");
	    var cookieslist = {};
	    for (var i = 0; i < pairs.length; i++) {
	        var pair = pairs[i].split("=");
	        cookieslist[(pair[0] + '').trim()] = unescape(pair[1]);
	    }
	    return cookieslist;
	}
}
var CLI=
{
	bar_config:{},
	showagain_config:{},
	allowedCategories:[],
	js_blocking_enabled: false,
	set:function(args)
	{
		if(typeof JSON.parse !== "function") 
		{
	        console.log("CookieLawInfo requires JSON.parse but your browser doesn't support it");
	        return;
		}
		if(typeof args.settings!=='object')
	    {
	    	this.settings = JSON.parse(args.settings);
		} 
		else
	    {
	    	this.settings = args.settings;
	    }
		this.js_blocking_enabled = Boolean( Cli_Data.js_blocking );
	    this.settings = args.settings;
	    this.bar_elm = jQuery(this.settings.notify_div_id);
	    this.showagain_elm = jQuery(this.settings.showagain_div_id);
		this.settingsModal = jQuery('#cliSettingsPopup');
		
        /* buttons */
        this.main_button=jQuery('.cli-plugin-main-button');
        this.main_link = jQuery('.cli-plugin-main-link');
        this.reject_link = jQuery('.cookie_action_close_header_reject');
		this.delete_link=jQuery(".cookielawinfo-cookie-delete");
		this.settings_button=jQuery('.cli_settings_button');
		this.accept_all_button = jQuery('.wt-cli-accept-all-btn');
        if(this.settings.cookie_bar_as=='popup')
    	{
    		CLI_COOKIEBAR_AS_POPUP=true;
		}
        this.addStyleAttribute();
		this.configBar();
        this.toggleBar();
        this.attachDelete();
        this.attachEvents();
		this.configButtons();
		this.reviewConsent();
		var cli_hidebar_on_readmore=this.hideBarInReadMoreLink();
        if( Boolean( this.settings.scroll_close ) ===true && cli_hidebar_on_readmore===false) 
        {
        	window.addEventListener("scroll",CLI.closeOnScroll, false);
		}
		
	},
	hideBarInReadMoreLink:function()
	{
		if( Boolean( CLI.settings.button_2_hidebar ) === true && this.main_link.length>0 && this.main_link.hasClass('cli-minimize-bar'))
		{
			this.hideHeader();
			cliBlocker.cookieBar( false );
			this.showagain_elm.slideDown(this.settings.animate_speed_show);
			return true;
		}
		return false;
	},
	attachEvents:function()
	{	
		jQuery(document).on('click','.wt-cli-privacy-btn',function(e){
			e.preventDefault();
			CLI.accept_close();
			CLI.settingsPopUpClose();
		});

		jQuery('.cli_action_button').on("click", function(e) {
			e.preventDefault();
			var elm=jQuery(this);
			var button_action=elm.attr('data-cli_action');
			var open_link=elm[0].hasAttribute("href") && elm.attr("href") != '#' ? true : false;
			var new_window=false;
			if(button_action=='accept')
			{
				CLI.accept_close();
				new_window= Boolean( CLI.settings.button_1_new_win ) ? true : false;

			}
			else if( button_action == 'accept_all') {
				CLI.enableAllCookies();
				CLI.accept_close();
				new_window=CLI.settings.button_7_new_win ? true : false;
			}
			else if(button_action=='reject')
			{
				CLI.reject_close();
				new_window= Boolean( CLI.settings.button_3_new_win ) ? true : false;
			}
			if(open_link)
			{
                if(new_window)
                {
                    window.open(elm.attr("href"),'_blank');
                }else
                {
                    window.location.href =elm.attr("href");
                }  
            }
		});
		this.settingsPopUp();
		this.settingsTabbedAccordion();
		this.toggleUserPreferenceCheckBox();
		this.hideCookieBarOnClose();
		this.cookieLawInfoRunCallBacks();

	},
	toggleUserPreferenceCheckBox:function()
	{	
		
    	jQuery('.cli-user-preference-checkbox').each(function(){

			categoryCookie = 'cookielawinfo-'+jQuery(this).attr('data-id');
			categoryCookieValue = CLI_Cookie.read(categoryCookie);
			if( categoryCookieValue == null )
			{
				if(jQuery(this).is(':checked'))
				{
					CLI_Cookie.set(categoryCookie,'yes',CLI_ACCEPT_COOKIE_EXPIRE);
				}else
				{
					CLI_Cookie.set(categoryCookie,'no',CLI_ACCEPT_COOKIE_EXPIRE);	
				}
			}
			else
			{	
				if(categoryCookieValue == "yes")
				{
					jQuery(this).prop("checked",true);
				}
				else
				{
					jQuery(this).prop("checked",false);
				}

			}
			
        });
    	jQuery('.cli-user-preference-checkbox').on("click", function(e) {
			var dataID = jQuery(this).attr('data-id');
			var currentToggleElm = jQuery('.cli-user-preference-checkbox[data-id='+dataID+']');
        	if(jQuery(this).is(':checked'))
        	{	
        		CLI_Cookie.set('cookielawinfo-'+dataID,'yes',CLI_ACCEPT_COOKIE_EXPIRE);
				currentToggleElm.prop('checked',true);
			}else
        	{
				CLI_Cookie.set('cookielawinfo-'+dataID,'no',CLI_ACCEPT_COOKIE_EXPIRE);	
				currentToggleElm.prop('checked',false);				
			}
			CLI.checkCategories();
			CLI.generateConsent();
		});
		
	},
	settingsPopUp:function()
	{	
		jQuery(document).on('click','.cli_settings_button',function(e){
			e.preventDefault();
			CLI.settingsModal.addClass("cli-show").css({'opacity':0}).animate({'opacity':1});
			CLI.settingsModal.removeClass('cli-blowup cli-out').addClass("cli-blowup");
			jQuery('body').addClass("cli-modal-open");
			jQuery(".cli-settings-overlay").addClass("cli-show");
			jQuery("#cookie-law-info-bar").css({'opacity':.1});
			if(!jQuery('.cli-settings-mobile').is(':visible'))
			{
				CLI.settingsModal.find('.cli-nav-link:eq(0)').trigger("click");
			}
	    });
		jQuery('#cliModalClose').on("click", function(e) {
			CLI.settingsPopUpClose();
		});
		CLI.settingsModal.on("click", function(e) {
			if(!(document.getElementsByClassName('cli-modal-dialog')[0].contains(e.target)))
			{
				CLI.settingsPopUpClose();
			}
		});
		jQuery('.cli_enable_all_btn').on("click", function(e) {
			var cli_toggle_btn = jQuery(this);
			var enable_text = cli_toggle_btn.attr('data-enable-text');
			var disable_text= cli_toggle_btn.attr('data-disable-text');
			if(cli_toggle_btn.hasClass('cli-enabled')){
				CLI.disableAllCookies();
				cli_toggle_btn.html(enable_text);
			}
			else
			{
				CLI.enableAllCookies();
				cli_toggle_btn.html(disable_text);

			}
			jQuery(this).toggleClass('cli-enabled');
		});
		
		this.privacyReadmore();
	},
	settingsTabbedAccordion:function()
	{
		jQuery(".cli-tab-header").on("click", function(e) {
			if(!(jQuery(e.target).hasClass('cli-slider') || jQuery(e.target).hasClass('cli-user-preference-checkbox')))
			{
				if (jQuery(this).hasClass("cli-tab-active")) {
					jQuery(this).removeClass("cli-tab-active");
					jQuery(this)
					  .siblings(".cli-tab-content")
					  .slideUp(200);

				  } else {
					jQuery(".cli-tab-header").removeClass("cli-tab-active");
					jQuery(this).addClass("cli-tab-active");
					jQuery(".cli-tab-content").slideUp(200);
					jQuery(this)
					  .siblings(".cli-tab-content")
					  .slideDown(200);
				  }
			}	
		  });
	},
	settingsPopUpClose:function()
	{
		this.settingsModal.removeClass('cli-show');
		this.settingsModal.addClass('cli-out');
		jQuery('body').removeClass("cli-modal-open");
        jQuery(".cli-settings-overlay").removeClass("cli-show");
        jQuery("#cookie-law-info-bar").css({'opacity':1});
	},
	privacyReadmore:function()
	{	
		var el= jQuery('.cli-privacy-content .cli-privacy-content-text');
		if( el.length > 0 ) {
			var clone= el.clone(),
			originalHtml= clone.html(),
			originalHeight= el.outerHeight(),
			Trunc = {
			addReadmore:function(textBlock)
			{	
				if(textBlock.html().length > 250)
				{
					jQuery('.cli-privacy-readmore').show();
				}
				else
				{
					jQuery('.cli-privacy-readmore').hide();
				}
			},
			truncateText : function( textBlock ) {   
				var strippedText = jQuery('<div />').html(textBlock.html()); 
				strippedText.find('table').remove();        
				textBlock.html(strippedText.html());
				currentText = textBlock.text();
				if(currentText.trim().length > 250){
					var newStr = currentText.substring(0, 250);
					textBlock.empty().html(newStr).append('...');
				}
			},     
			replaceText: function ( textBlock, original ){
				return textBlock.html(original);      
			}  
			
			};
			Trunc.addReadmore(el);
			Trunc.truncateText(el);
			jQuery('a.cli-privacy-readmore').on("click", function(e) {
				e.preventDefault();
				if(jQuery('.cli-privacy-overview').hasClass('cli-collapsed'))
				{	
					Trunc.truncateText(el);
					jQuery('.cli-privacy-overview').removeClass('cli-collapsed');
					el.css('height', '100%');
				}
				else
				{
					jQuery('.cli-privacy-overview').addClass('cli-collapsed');
					Trunc.replaceText(el, originalHtml);
				}
				
				
			});
		}
		
	},
	attachDelete:function()
	{
		this.delete_link.on("click", function(e) {
	        CLI_Cookie.erase(CLI_ACCEPT_COOKIE_NAME);
	        for(var k in Cli_Data.nn_cookie_ids) 
	        {
	            CLI_Cookie.erase(Cli_Data.nn_cookie_ids[k]);
			}
			CLI.generateConsent();
	        return false;
		});
		
	},
	configButtons:function()
	{
	    /*[cookie_button] */
	    this.main_button.css('color',this.settings.button_1_link_colour);
	    if( Boolean( this.settings.button_1_as_button ) ) 
	    {	
	        this.main_button.css('background-color',this.settings.button_1_button_colour);
			
			this.main_button.on('mouseenter', function(){
				jQuery(this).css('background-color',CLI.settings.button_1_button_hover);
			})
			.on('mouseleave', function(){
				jQuery(this).css('background-color',CLI.settings.button_1_button_colour);
			});
	    }

	    /* [cookie_link] */    
	    this.main_link.css('color',this.settings.button_2_link_colour);
	    if( Boolean( this.settings.button_2_as_button ) ) 
	    {
			this.main_link.css('background-color',this.settings.button_2_button_colour);

			this.main_link.on('mouseenter', function(){
				jQuery(this).css('background-color',CLI.settings.button_2_button_hover);
			})
			.on('mouseleave', function(){
				jQuery(this).css('background-color',CLI.settings.button_2_button_colour);
			});
	        
	    }
	    /* [cookie_reject] */	    
		this.reject_link.css('color',this.settings.button_3_link_colour);
	    if( Boolean( this.settings.button_3_as_button ) ) 
	    {	
		
			this.reject_link.css('background-color',this.settings.button_3_button_colour);
			this.reject_link.on('mouseenter', function(){
				jQuery(this).css('background-color',CLI.settings.button_3_button_hover);
			})
			.on('mouseleave', function(){
				jQuery(this).css('background-color',CLI.settings.button_3_button_colour);
			});
		}
		/* [cookie_settings] */	    
	    this.settings_button.css('color',this.settings.button_4_link_colour);
	    if( Boolean( this.settings.button_4_as_button ) ) 
	    {
			this.settings_button.css('background-color',this.settings.button_4_button_colour);
			this.settings_button.on('mouseenter', function(){
				jQuery(this).css('background-color',CLI.settings.button_4_button_hover);
			})
			.on('mouseleave', function(){
				jQuery(this).css('background-color',CLI.settings.button_4_button_colour);
			});
	    }
		/* [cookie_accept_all] */
		this.accept_all_button.css('color',this.settings.button_7_link_colour);
		if(this.settings.button_7_as_button) 
		{
			this.accept_all_button.css('background-color',this.settings.button_7_button_colour);
			this.accept_all_button.on('mouseenter', function(){
				jQuery(this).css('background-color',CLI.settings.button_7_button_hover);
			})
			.on('mouseleave', function(){
				jQuery(this).css('background-color',CLI.settings.button_7_button_colour);
			});
		}
	},
	toggleBar:function()
	{
		if(CLI_COOKIEBAR_AS_POPUP)
		{
			this.barAsPopUp(1);
		}
		if(CLI.settings.cookie_bar_as=='widget')
		{
			this.barAsWidget(1);
		}
		if(!CLI_Cookie.exists(CLI_ACCEPT_COOKIE_NAME)) 
		{
	        this.displayHeader();
	    }else
	    {
	        this.hideHeader();
	    }
	    if( Boolean( this.settings.show_once_yn )) 
	    {
	        setTimeout(function(){
	        	CLI.close_header();
	        },CLI.settings.show_once);
		}
		if( CLI.js_blocking_enabled === false ) {
			if( Boolean( Cli_Data.ccpaEnabled ) === true ) {
				if( Cli_Data.ccpaType === 'ccpa' && Boolean( Cli_Data.ccpaBarEnabled ) === false ) {
					cliBlocker.cookieBar( false );
				}
			} else {
				jQuery('.wt-cli-ccpa-opt-out,.wt-cli-ccpa-checkbox,.wt-cli-ccpa-element').remove();
			}
		} 
		
	    this.showagain_elm.on("click", function(e) {
	        e.preventDefault();
	        CLI.showagain_elm.slideUp(CLI.settings.animate_speed_hide,function() 
	        {
	            CLI.bar_elm.slideDown(CLI.settings.animate_speed_show);
	            if(CLI_COOKIEBAR_AS_POPUP)
				{
					CLI.showPopupOverlay();
				}
	        });
	    });
	},
	configShowAgain:function()
	{
		this.showagain_config = {
	        'background-color': this.settings.background,
	        'color':this.l1hs(this.settings.text),
	        'position': 'fixed',
	        'font-family': this.settings.font_family
	    };
	    if(Boolean( this.settings.border_on ) ) 
	    {
	        var border_to_hide = 'border-' + this.settings.notify_position_vertical;
	        this.showagain_config['border'] = '1px solid ' + this.l1hs(this.settings.border);
	        this.showagain_config[border_to_hide] = 'none';
	    }
	    var cli_win=jQuery(window);
    	var cli_winw=cli_win.width();
    	var showagain_x_pos=this.settings.showagain_x_position;
    	if(cli_winw<300)
    	{
    		showagain_x_pos=10;
    		this.showagain_config.width=cli_winw-20;
    	}else
    	{
    		this.showagain_config.width='auto';
    	}
	    var cli_defw=cli_winw>400 ? 500 : cli_winw-20;
	    if(CLI_COOKIEBAR_AS_POPUP) /* cookie bar as popup */
	    {
	    	var sa_pos=this.settings.popup_showagain_position;
	    	var sa_pos_arr=sa_pos.split('-');
	    	if(sa_pos_arr[1]=='left')
	    	{
	    		this.showagain_config.left=showagain_x_pos;
	    	}else if(sa_pos_arr[1]=='right')
	    	{	
	    		this.showagain_config.right=showagain_x_pos;
	    	}
	    	if(sa_pos_arr[0]=='top')
	    	{
	    		this.showagain_config.top=0;

	    	}else if(sa_pos_arr[0]=='bottom')
	    	{	
	    		this.showagain_config.bottom=0;
	    	}
	    	this.bar_config['position'] = 'fixed';

	    }else if(this.settings.cookie_bar_as=='widget')
	    {
	    	this.showagain_config.bottom=0;
	    	if(this.settings.widget_position=='left')
	    	{
	    		this.showagain_config.left=showagain_x_pos;
	    	}else if(this.settings.widget_position=='right')
	    	{	
	    		this.showagain_config.right=showagain_x_pos;
	    	}
	    }
	    else
	    {
	    	if(this.settings.notify_position_vertical == "top") 
		    {
		        this.showagain_config.top = '0';
		    }
		    else if(this.settings.notify_position_vertical == "bottom") 
		    {
		        this.bar_config['position'] = 'fixed';
		        this.bar_config['bottom'] = '0';
		        this.showagain_config.bottom = '0';
		    }
		    if(this.settings.notify_position_horizontal == "left") 
		    {
		        this.showagain_config.left =showagain_x_pos;
		    }else if(this.settings.notify_position_horizontal == "right") 
		    {
		        this.showagain_config.right =showagain_x_pos;
		    }
	    } 
	    this.showagain_elm.css(this.showagain_config);	    
	},
	configBar:function()
	{
		this.bar_config = {
	        'background-color':this.settings.background,
	        'color':this.settings.text,
	        'font-family':this.settings.font_family
	    };
	    if(this.settings.notify_position_vertical=="top") 
	    {
	        this.bar_config['top'] = '0';
	        if( Boolean( this.settings.header_fix ) === true) 
	        {
	            this.bar_config['position'] = 'fixed';
	        }
	    }else 
	    {
	        this.bar_config['bottom'] = '0';
	    }
	    this.configShowAgain();
	    this.bar_elm.css(this.bar_config).hide();
	},
	l1hs:function(str) 
	{
	    if (str.charAt(0) == "#") {
	        str = str.substring(1, str.length);
	    } else {
	        return "#" + str;
	    }
	    return this.l1hs(str);
	},
	close_header:function() 
	{
        CLI_Cookie.set(CLI_ACCEPT_COOKIE_NAME,'yes',CLI_ACCEPT_COOKIE_EXPIRE);
        this.hideHeader();
    },
	accept_close:function() 
    {        
		this.hidePopupOverlay();
		this.generateConsent();
		this.cookieLawInfoRunCallBacks();

        CLI_Cookie.set(CLI_ACCEPT_COOKIE_NAME,'yes',CLI_ACCEPT_COOKIE_EXPIRE);
        if( Boolean( this.settings.notify_animate_hide ) ) 
        {	
			if( CLI.js_blocking_enabled === true ) {
				this.bar_elm.slideUp( this.settings.animate_speed_hide, cliBlocker.runScripts );
			} else {
				this.bar_elm.slideUp( this.settings.animate_speed_hide );
			}
           
        }else 
        {	
			if( CLI.js_blocking_enabled === true ) {
            	this.bar_elm.hide( cliBlocker.runScripts );

			} else {
				this.bar_elm.hide();
			}
        }
        if( Boolean( this.settings.showagain_tab ) ) 
        {
        	this.showagain_elm.slideDown(this.settings.animate_speed_show);
		}
        if( Boolean( this.settings.accept_close_reload ) === true  ) 
        {
            this.reload_current_page();
        }
        return false;
    },
	reject_close:function() 
    {
		this.hidePopupOverlay();
		this.generateConsent();
		this.cookieLawInfoRunCallBacks();
        for(var k in Cli_Data.nn_cookie_ids) 
        {
            CLI_Cookie.erase(Cli_Data.nn_cookie_ids[k]);
        }
		CLI_Cookie.set(CLI_ACCEPT_COOKIE_NAME,'no',CLI_ACCEPT_COOKIE_EXPIRE);
		
        if( Boolean( this.settings.notify_animate_hide ) ) 
        {	
			if( CLI.js_blocking_enabled === true ) {

				this.bar_elm.slideUp(this.settings.animate_speed_hide, cliBlocker.runScripts);

			} else {
				
				this.bar_elm.slideUp(this.settings.animate_speed_hide);
			}
            
        } else 
        {	
			if( CLI.js_blocking_enabled === true ) {

				this.bar_elm.hide( cliBlocker.runScripts );

			} else {

				this.bar_elm.hide();

			}
            
        }
        if( Boolean( this.settings.showagain_tab ) ) 
        {
        	this.showagain_elm.slideDown(this.settings.animate_speed_show);
        }
        if( Boolean( this.settings.reject_close_reload ) === true ) 
        {
            this.reload_current_page();
        }
        return false;
    },
    reload_current_page:function()
    {	
		
    	if(typeof cli_flush_cache!=='undefined' && cli_flush_cache === true)
    	{
            window.location.href=this.add_clear_cache_url_query();
    	}else
    	{
    		window.location.reload(true);
    	}
    },
    add_clear_cache_url_query:function()
    {
    	var cli_rand=new Date().getTime()/1000;
    	var cli_url=window.location.href;
    	var cli_hash_arr=cli_url.split('#');
    	var cli_urlparts= cli_hash_arr[0].split('?');
    	if(cli_urlparts.length>=2) 
    	{
    		var cli_url_arr=cli_urlparts[1].split('&');
    		cli_url_temp_arr=new Array();
    		for(var cli_i=0; cli_i<cli_url_arr.length; cli_i++)
    		{   			
    			var cli_temp_url_arr=cli_url_arr[cli_i].split('=');
    			if(cli_temp_url_arr[0]=='cli_action')
    			{

    			}else
    			{
    				cli_url_temp_arr.push(cli_url_arr[cli_i]);
    			}
    		}
    		cli_urlparts[1]=cli_url_temp_arr.join('&');
    		cli_url=cli_urlparts.join('?')+(cli_url_temp_arr.length>0 ? '&': '')+'cli_action=';
    	}else
    	{
    		cli_url=cli_hash_arr[0]+'?cli_action=';
    	}
    	cli_url+=cli_rand;
    	if(cli_hash_arr.length>1)
    	{
    		cli_url+='#'+cli_hash_arr[1];
    	}
    	return cli_url;
    },
	closeOnScroll:function() 
	{
        if(window.pageYOffset > 100 && !CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME)) 
        {
            CLI.accept_close();
            if( Boolean( CLI.settings.scroll_close_reload ) === true) 
            {
                window.location.reload();
            }
            window.removeEventListener("scroll",CLI.closeOnScroll,false);
        }
    },
    displayHeader:function() 
    {   
        if( Boolean( this.settings.notify_animate_show ) ) 
        {
            this.bar_elm.slideDown(this.settings.animate_speed_show);
        }else 
        {
            this.bar_elm.show();
        }
        this.showagain_elm.hide();
        if(CLI_COOKIEBAR_AS_POPUP)
		{
			this.showPopupOverlay();
		}    
    },
    hideHeader:function()
    {      
        if( Boolean( this.settings.showagain_tab ) ) 
        {
	        if( Boolean( this.settings.notify_animate_show ) ) 
	        {
	            this.showagain_elm.slideDown(this.settings.animate_speed_show);
	        } else {
	            this.showagain_elm.show();
	        }
    	}else
    	{
    		this.showagain_elm.hide();
    	}
        this.bar_elm.slideUp(this.settings.animate_speed_show);
        this.hidePopupOverlay();
    },
    hidePopupOverlay:function() 
    {
        jQuery('body').removeClass("cli-barmodal-open");
        jQuery(".cli-popupbar-overlay").removeClass("cli-show");
    },
    showPopupOverlay:function()
    {	
		if( this.bar_elm.length ) {
			if( Boolean( this.settings.popup_overlay ) )
			{
				jQuery('body').addClass("cli-barmodal-open");
				jQuery(".cli-popupbar-overlay").addClass("cli-show");
			}
		}
        
    },
    barAsWidget:function(a)
    {
		var cli_elm=this.bar_elm;
		cli_elm.attr('data-cli-type','widget');
	    var cli_win=jQuery(window);
	    var cli_winh=cli_win.height()-40;
	    var cli_winw=cli_win.width();
	    var cli_defw=cli_winw>400 ? 300 : cli_winw-30;
	    cli_elm.css({
	        'width':cli_defw,'height':'auto','max-height':cli_winh,'overflow':'auto','position':'fixed','box-sizing':'border-box'
		});
		if ( this.checkifStyleAttributeExist() === false ) {
			cli_elm.css({'padding':'25px 15px'});
		}
	    if(this.settings.widget_position=='left')
	    {
	    	cli_elm.css({
	        	'left':'15px','right':'auto','bottom':'15px','top':'auto'
	    	});
	    }else
	    {
	    	cli_elm.css({
	        	'left':'auto','right':'15px','bottom':'15px','top':'auto'
	    	});
	    }
	    if(a)
	    {
	    	this.setResize();
		}
    },
    barAsPopUp:function(a)
    {    	
    	if(typeof cookie_law_info_bar_as_popup==='function')
    	{
    		return false;
    	}
		var cli_elm=this.bar_elm;
		cli_elm.attr('data-cli-type','popup');
	    var cli_win=jQuery(window);
	    var cli_winh=cli_win.height()-40;
	    var cli_winw=cli_win.width();
	    var cli_defw=cli_winw>700 ? 500 : cli_winw-20;

	    cli_elm.css({
	        'width':cli_defw,'height':'auto','max-height':cli_winh,'bottom':'','top':'50%','left':'50%','margin-left':(cli_defw/2)*-1,'margin-top':'-100px','overflow':'auto'
		}).addClass('cli-bar-popup cli-modal-content');
		if ( this.checkifStyleAttributeExist() === false ) {
			cli_elm.css({'padding':'25px 15px'});
		}
	    cli_h=cli_elm.height();
	    li_h=cli_h<200 ? 200 : cli_h;
	    cli_elm.css({'top':'50%','margin-top':((cli_h/2)+30)*-1});	    
	    setTimeout(function(){ 
		    cli_elm.css({
		        'bottom':''
		    });
	     },100);
	    if(a)
	    {
	    	this.setResize();
		}
    },
    setResize:function()
	{
		var resizeTmr=null;
		jQuery(window).resize(function() {
			clearTimeout(resizeTmr);
			resizeTmr=setTimeout(function()
			{
				if(CLI_COOKIEBAR_AS_POPUP)
				{
					CLI.barAsPopUp();
				}
				if(CLI.settings.cookie_bar_as=='widget')
				{
					CLI.barAsWidget();
				}
				CLI.configShowAgain();
			},500);
		});
	},
	enableAllCookies:function()
    {	
		
    	jQuery('.cli-user-preference-checkbox').each(function(){
			var cli_chkbox_elm=jQuery(this);
			var cli_chkbox_data_id=cli_chkbox_elm.attr('data-id');
			if(cli_chkbox_data_id!='checkbox-necessary')
			{
				cli_chkbox_elm.prop('checked',true);
				CLI_Cookie.set('cookielawinfo-'+cli_chkbox_data_id,'yes',CLI_ACCEPT_COOKIE_EXPIRE);
			}
		});
	},
	hideCookieBarOnClose: function() {
		jQuery(document).on('click','.cli_cookie_close_button',function(e){
			e.preventDefault();
			var elm=jQuery(this);
			var button_action = elm.attr('data-cli_action');
			if( Cli_Data.ccpaType === 'ccpa' )
			{	
				CLI.enableAllCookies();
			}
			CLI.accept_close();
		});
	},
	checkCategories:function()
	{	
		var cliAllowedCategories =  [];
		var cli_categories = {};
		jQuery('.cli-user-preference-checkbox').each(function()
		{	var status=false;
			cli_chkbox_elm=jQuery(this);
			cli_chkbox_data_id=cli_chkbox_elm.attr('data-id');
			cli_chkbox_data_id=cli_chkbox_data_id.replace('checkbox-','');
			cli_chkbox_data_id_trimmed=cli_chkbox_data_id.replace('-','_')
    		if(jQuery(cli_chkbox_elm).is(':checked'))
        	{
				status=true;
				cliAllowedCategories.push(cli_chkbox_data_id);
			}
			
			cli_categories[cli_chkbox_data_id_trimmed]= status;
		});
		CLI.allowedCategories = cliAllowedCategories;
	},
	cookieLawInfoRunCallBacks:function()
	{		
		this.checkCategories();
		if(CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME)=='yes')		
    	{	
			if("function" == typeof CookieLawInfo_Accept_Callback){
				CookieLawInfo_Accept_Callback(); 
			}
		}
	},
	generateConsent:function()
	{	
		var preferenceCookie = CLI_Cookie.read(CLI_PREFERNCE_COOKIE);
		cliConsent = {};
		if(preferenceCookie !== null) {
			cliConsent = window.atob(preferenceCookie);
			cliConsent = JSON.parse(cliConsent);
		}
		cliConsent.ver = Cli_Data.consentVersion;
		categories = [];
		jQuery('.cli-user-preference-checkbox').each(function(){
			categoryVal = '';
			cli_chkbox_data_id = jQuery(this).attr('data-id');
			cli_chkbox_data_id = cli_chkbox_data_id.replace('checkbox-','');
			if(jQuery(this).is(':checked'))
        	{	
				categoryVal = true;
			}
			else	
        	{		
				categoryVal = false;
			}
			cliConsent[cli_chkbox_data_id] = categoryVal;
		});
		cliConsent = JSON.stringify(cliConsent);
		cliConsent = window.btoa(cliConsent);
		CLI_Cookie.set(CLI_PREFERNCE_COOKIE,cliConsent,CLI_ACCEPT_COOKIE_EXPIRE);
	},
	addStyleAttribute:function()
	{
		var bar=this.bar_elm;
		var styleClass='';
		if(jQuery(bar).find('.cli-bar-container').length > 0)
		{
			styleClass	=	jQuery('.cli-bar-container').attr('class');
			styleClass	=	styleClass.replace('cli-bar-container','');
			styleClass	=	styleClass.trim();
			jQuery(bar).attr('data-cli-style',styleClass);
		}
	},
	getParameterByName: function( name, url ) {
		if (!url) url = window.location.href;
		name = name.replace(/[\[\]]/g, '\\$&');
		var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
			results = regex.exec(url);
		if (!results) return null;
		if (!results[2]) return '';
		return decodeURIComponent(results[2].replace(/\+/g, ' '));
	},
	CookieLawInfo_Callback: function( enableBar, enableBlocking ) {
		enableBar = typeof enableBar !== 'undefined' ? enableBar : true;
		enableBlocking = typeof enableBlocking !== 'undefined' ? enableBlocking : true;
		if( CLI.js_blocking_enabled === true && Boolean( Cli_Data.custom_integration ) === true ) {
			cliBlocker.cookieBar( enableBar );
			cliBlocker.runScripts( enableBlocking );
		}
	},
	checkifStyleAttributeExist: function() 
	{	
		var exist = false;
		var attr = this.bar_elm.attr('data-cli-style');
		if (typeof attr !== typeof undefined && attr !== false) {
			exist = true;
		}
		return exist;
	},
	reviewConsent : function()
	{	
		jQuery(document).on('click','.cli_manage_current_consent,.wt-cli-manage-consent-link',function(){
			CLI.displayHeader();
		});
	}
}
var cliBlocker = 
{   
	blockingStatus: true,
	scriptsLoaded: false,
	ccpaEnabled : false,
	ccpaRegionBased : false,
	ccpaApplicable : false,
	ccpaBarEnabled: false,
	cliShowBar: true ,
	isBypassEnabled: CLI.getParameterByName('cli_bypass'),
	checkPluginStatus: function(callbackA , callbackB )
	{	
		this.ccpaEnabled = Boolean( Cli_Data.ccpaEnabled );
		this.ccpaRegionBased = Boolean( Cli_Data.ccpaRegionBased );
		this.ccpaBarEnabled = Boolean( Cli_Data.ccpaBarEnabled );
		
		if( Boolean( Cli_Data.custom_integration ) === true ) {
			callbackA( false );
		} 
		else {
			if( this.ccpaEnabled === true ) {
				this.ccpaApplicable = true;
				if( Cli_Data.ccpaType === 'ccpa') {
					if( this.ccpaBarEnabled !== true ) {
						this.cliShowBar = false;
						this.blockingStatus = false;
					}
				}
			} else {
				jQuery('.wt-cli-ccpa-opt-out,.wt-cli-ccpa-checkbox,.wt-cli-ccpa-element').remove();
			}
			if ( cliBlocker.isBypassEnabled === "1") {
				cliBlocker.blockingStatus = false;
			}
			callbackA( this.cliShowBar );
			callbackB( this.blockingStatus);
		}
		
		
	},
	cookieBar: function( showbar )
	{	
		showbar = typeof showbar !== 'undefined' ? showbar : true;
		cliBlocker.cliShowBar = showbar;
		if(cliBlocker.cliShowBar === false)
		{
			CLI.bar_elm.hide();
			CLI.showagain_elm.hide();
			CLI.settingsModal.removeClass('cli-blowup cli-out');
			CLI.hidePopupOverlay();
			jQuery(".cli-settings-overlay").removeClass("cli-show");
		}	
		else
		{
			if(!CLI_Cookie.exists(CLI_ACCEPT_COOKIE_NAME)) 
			{	
				CLI.displayHeader();
			}
			else
			{
				CLI.hideHeader();
			}
			CLI.settingsModal.show();
			jQuery('.cli-modal-backdrop').show();
		}
	},
	removeCookieByCategory : function() 
	{	

		if(cliBlocker.blockingStatus === true)
		{	
			if(CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME) !== null)
			{
				var non_necessary_cookies = Cli_Data.non_necessary_cookies;
				for (var key in non_necessary_cookies) {
					currentCategory = key;
					if(CLI.allowedCategories.indexOf(currentCategory) === -1)
					{	
						var nonNecessaryCookies = non_necessary_cookies[currentCategory];
						for(var i=0; i < nonNecessaryCookies.length; i++)
						{	
							if(CLI_Cookie.read(nonNecessaryCookies[i]) !== null)
							{	
								CLI_Cookie.erase(nonNecessaryCookies[i]);
							}

						}
					}
				}
			}
		}
	},
    runScripts:function( blocking )
	{		
		blocking = typeof blocking !== 'undefined' ? blocking : true;
		cliBlocker.blockingStatus = blocking;
		srcReplaceableElms = ['iframe','IFRAME','EMBED','embed','OBJECT','object','IMG','img'];
		var genericFuncs = 
		{	
			
			renderByElement: function( callback )
			{	
				cliScriptFuncs.renderScripts();
				callback();
				cliBlocker.scriptsLoaded = true;
			},

		};
		var cliScriptFuncs = 
		{
			// trigger DOMContentLoaded
			scriptsDone:function() 
			{	
				if (typeof Cli_Data.triggerDomRefresh !== 'undefined') {
					if( Boolean( Cli_Data.triggerDomRefresh ) === true ) 
					{	
						var DOMContentLoadedEvent = document.createEvent('Event')
						DOMContentLoadedEvent.initEvent('DOMContentLoaded', true, true)
						window.document.dispatchEvent(DOMContentLoadedEvent);
					}
				}
			},
			seq :function(arr, callback, index) {
				// first call, without an index
				if (typeof index === 'undefined') {
				  index = 0
				}
			  
				arr[index](function () {
				  index++
				  if (index === arr.length) {
					callback()
				  } else {
					cliScriptFuncs.seq(arr, callback, index)
				  }
				})
			  },
			/* script runner */
			insertScript:function($script,callback) {
				var s ='';
				var scriptType = $script.getAttribute('data-cli-script-type');
				var elementPosition = $script.getAttribute('data-cli-element-position');
				var isBlock = $script.getAttribute('data-cli-block');
				var s = document.createElement('script');
				var ccpaOptedOut = cliBlocker.ccpaOptedOut();
				s.type = 'text/plain';
				if($script.async)
				{
					s.async = $script.async;
				}
				if($script.defer)
				{
					s.defer = $script.defer;
				}
				if ($script.src) {
					s.onload = callback
					s.onerror = callback
					s.src = $script.src
				} else {
					s.textContent = $script.innerText
				}
				var attrs = jQuery($script).prop("attributes");
				for (var ii = 0; ii < attrs.length; ++ii) {
					if (attrs[ii].nodeName !== 'id') {
						s.setAttribute(attrs[ii].nodeName,attrs[ii].value);
					}
				}
				if(cliBlocker.blockingStatus === true)
				{	
					
					if(( CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME)=='yes' && CLI.allowedCategories.indexOf(scriptType) !== -1 ) )
					{
						s.setAttribute('data-cli-consent','accepted');
						s.type = 'text/javascript';
					}
					if( cliBlocker.ccpaApplicable === true ) {
						if( ccpaOptedOut === true || CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME) == null ) {
							s.type = 'text/plain';
						}
					}
				}
				else
				{
					s.type = 'text/javascript';
				}
				
				if($script.type != s.type)
				{
					if(elementPosition === 'head') {	
						document.head.appendChild(s);
					} else {	
						document.body.appendChild(s);
					}
					if (!$script.src) {
						callback()
					}		
					$script.parentNode.removeChild($script);
					
				} 
				else {

					callback();
				}
			},
			renderScripts:function()
			{	
				var $scripts = document.querySelectorAll('script[data-cli-class="cli-blocker-script"]');
				if($scripts.length > 0)
				{
					var runList = []
					var typeAttr
					Array.prototype.forEach.call($scripts, function ($script) {
						// only run script tags without the type attribute
						// or with a javascript mime attribute value
						typeAttr = $script.getAttribute('type')
						runList.push(function (callback) {
							cliScriptFuncs.insertScript($script, callback)
						})
					})
					cliScriptFuncs.seq(runList, cliScriptFuncs.scriptsDone);
				}
			}
		};
		genericFuncs.renderByElement( cliBlocker.removeCookieByCategory );
	},
	ccpaOptedOut : function () {
		var ccpaOptedOut = false;
		var preferenceCookie = CLI_Cookie.read(CLI_PREFERNCE_COOKIE);
		if( preferenceCookie !== null ) {
			cliConsent = window.atob(preferenceCookie);
			cliConsent = JSON.parse(cliConsent);
           if( typeof cliConsent.ccpaOptout !== 'undefined') {
			ccpaOptedOut =  cliConsent.ccpaOptout;
		   }
		}
		return ccpaOptedOut;
	}
}
jQuery(document).ready(function() {
    if(typeof cli_cookiebar_settings!='undefined')
    {	
	    CLI.set({
	      settings:cli_cookiebar_settings
		});
		if( CLI.js_blocking_enabled === true ) {
			cliBlocker.checkPluginStatus(cliBlocker.cookieBar,cliBlocker.runScripts);
		}
	}
});
// source --> https://budget.haus/wp-content/plugins/mega-addons-for-visual-composer/js/script.js?ver=4.9.7 
jQuery(document).ready(function($) {

	if(jQuery('.mason-item').length > 0){
		jQuery('.mason-item').matchHeight({byRow: true}); 
	}
	$('a, i').hover(function() {
		$(this).css({
			'color': $(this).data('onhovercolor'),
			'background-color': $(this).data('onhoverbg')
		});
	}, function() {
		$(this).css({
			'color': $(this).data('onleavecolor'),
			'background-color': $(this).data('onleavebg')
		});		
	});
});

// Photo Book Gallery

function PhotoBookGallery(el){
	jQuery('.wcp-loader').show();
	if (initiated) { jQuery(el).booklet('destroy'); };

	jQuery(el).css('width', '100%');	
	jQuery(el).find('img').css('width', '100%');

	var width = jQuery(el).find('img').width();
	var height = jQuery(el).find('img').height()/2;

	var speedofturn 		= (jQuery(el).data('speed') != '') ? jQuery(el).data('speed') : '1000';
	var readingdirection 	= jQuery(el).data('direction');
	var pagepadding 		= jQuery(el).data('padding');
	var delay 				= jQuery(el).data('autodelay');
	var pagenumbers 		= (jQuery(el).data('pagenumbers') != '') ? true : false;
	var closedbook 			= (jQuery(el).data('closedbook') != '') ? true : false;
	var autoplay 			= (jQuery(el).data('autoplay') != '') ? true : false;
	var keyboardcontrols 	= (jQuery(el).data('keyboard') != '') ? true : false;
	var booktabs 			= (jQuery(el).data('tabs') != '') ? true : false;
	var bookarrows 			= (jQuery(el).data('arrows') != '') ? true : false;
	var manual 				= (jQuery(el).data('turnbyclick') != '') ? true : false;
	var manualcontrol 		= false;

	if (jQuery(el).data('turnbyclick') != '') { manualcontrol = true; manual = false; }

	jQuery(el).booklet({
        width:  width,
        height: height,
		auto: autoplay,
		arrows: bookarrows,
		tabs: booktabs,
        closed: closedbook,
        autoCenter: closedbook,
        delay: delay,
        keyboard: keyboardcontrols,
        overlays: manualcontrol,
        manual: manual,
        pageNumbers: pagenumbers,
		pagePadding: pagepadding,
		direction: readingdirection,
		speed: speedofturn,
	});

	if (jQuery(el).data('zoom') != '') {
	    setTimeout(function() {
			jQuery(el).find('img').each(function(index, el) {
				jQuery(this).closest('div').zoom({magnify: jQuery(el).data('zoomdepth')});
			});
	    }, 50);
    };

	jQuery('.wcp-loader').hide();
	initiated = true;
}
var initiated = false;
jQuery( window ).on("resize", function() {
	jQuery('.flipbook').each(function(index, el) {
		PhotoBookGallery(el);
	});
});

jQuery(window).load(function($) {
	jQuery(window).trigger('resize');
});


// Stat Counter Script

(function ($) {

    $.fn.isOnScreen = function(x, y){

        if(x == null || typeof x == 'undefined') x = 1;
        if(y == null || typeof y == 'undefined') y = 1;

        var win = $(window);

        var viewport = {
            top : win.scrollTop(),
            left : win.scrollLeft()
        };
        viewport.right = viewport.left + win.width();
        viewport.bottom = viewport.top + win.height();

        var height = this.outerHeight();
        var width = this.outerWidth();

        if(!width || !height){
            return false;
        }

        var bounds = this.offset();
        bounds.right = bounds.left + width;
        bounds.bottom = bounds.top + height;

        var visible = (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));

        if(!visible){
            return false;
        }

        var deltas = {
            top : Math.min( 1, ( bounds.bottom - viewport.top ) / height),
            bottom : Math.min(1, ( viewport.bottom - bounds.top ) / height),
            left : Math.min(1, ( bounds.right - viewport.left ) / width),
            right : Math.min(1, ( viewport.right - bounds.left ) / width)
        };

        return (deltas.left * deltas.right) >= x && (deltas.top * deltas.bottom) >= y;

    };

})(jQuery);

jQuery(document).scroll(function(event) {

  	var hasBeenSeen = false;
	jQuery('.timer').each(function(index, el) {
		if (jQuery(el).isOnScreen()) {
			if (jQuery(this).closest('div').data('alreadystarted') != 'yes') {
				jQuery(this).countTo();
				jQuery(this).closest('div').data('alreadystarted', 'yes');
			};
		};
		
	});
});


// Flip Box
jQuery(document).ready(function(){
	jQuery('.hover').hover(function(){
		jQuery(this).addClass('flip');
	},function(){
		jQuery(this).removeClass('flip');
	});
});


// CountDown timer
jQuery(document).ready(function($) {
	$(function () {
		$('.countdownapply').each(function(index, el) {
			var style = $(this).data('style');
			var year = $(this).data('year');
			var month = $(this).data('month');
			var date = $(this).data('date');
			var CountDown = new Date();
			CountDown = new Date(CountDown.getFullYear() + year, month - 1, date);
			$(this).countdown({until: CountDown, format: style});
		});
	});
});
// source --> https://budget.haus/wp-content/plugins/wptables/build/js/wptables.min.js?ver=1.3.9 
!function(t,e,i){function n(t,i){var n=e(t);n.data(r,this),this._container=n,this.data=[],this.fields=[],this._editingRow=null,this._sortField=null,this._sortOrder=o,this._firstDisplayingPage=1,this._init(i),this.render()}var r="JSGrid",a="JSGridItem",s="JSGridEditRow",o="asc",l=function(t,i){return e.isFunction(t)?t.apply(i,e.makeArray(arguments).slice(2)):t},d=function(t){var i=e.Deferred();return t&&t.then?t.then(function(){i.resolve.apply(i,arguments)},function(){i.reject.apply(i,arguments)}):i.resolve(t),i.promise()},u={loadData:e.noop,insertItem:e.noop,updateItem:e.noop,deleteItem:e.noop};n.prototype={width:"auto",height:"auto",updateOnResize:!0,rowClass:e.noop,rowRenderer:null,rowClick:function(t){this.editing&&this.editItem(e(t.event.target).closest("tr"))},rowDoubleClick:e.noop,noDataContent:"Not found",noDataRowClass:"jsgrid-nodata-row",heading:!0,headerRowRenderer:null,headerRowClass:"jsgrid-header-row",headerCellClass:"jsgrid-header-cell",filtering:!1,filterRowRenderer:null,filterRowClass:"jsgrid-filter-row",inserting:!1,insertRowRenderer:null,insertRowClass:"jsgrid-insert-row",editing:!1,editRowRenderer:null,editRowClass:"jsgrid-edit-row",confirmDeleting:!0,deleteConfirm:"Are you sure?",selecting:!0,selectedRowClass:"jsgrid-selected-row",oddRowClass:"jsgrid-row",evenRowClass:"jsgrid-alt-row",cellClass:"jsgrid-cell",sorting:!1,sortableClass:"jsgrid-header-sortable",sortAscClass:"jsgrid-header-sort jsgrid-header-sort-asc",sortDescClass:"jsgrid-header-sort jsgrid-header-sort-desc",paging:!1,pagerContainer:null,pageIndex:1,pageSize:20,pageButtonCount:15,pagerFormat:"Pages: {first} {prev} {pages} {next} {last} &nbsp;&nbsp; {pageIndex} of {pageCount}",pagePrevText:"Prev",pageNextText:"Next",pageFirstText:"First",pageLastText:"Last",pageNavigatorNextText:"...",pageNavigatorPrevText:"...",pagerContainerClass:"jsgrid-pager-container",pagerClass:"jsgrid-pager",pagerNavButtonClass:"jsgrid-pager-nav-button",pagerNavButtonInactiveClass:"jsgrid-pager-nav-inactive-button",pageClass:"jsgrid-pager-page",currentPageClass:"jsgrid-pager-current-page",customLoading:!1,pageLoading:!1,autoload:!1,controller:u,loadIndication:!0,loadIndicationDelay:500,loadMessage:"Please, wait...",loadShading:!0,invalidMessage:"Invalid data entered!",invalidNotify:function(i){var n=e.map(i.errors,function(t){return t.message||null});t.alert([this.invalidMessage].concat(n).join("\n"))},onInit:e.noop,onRefreshing:e.noop,onRefreshed:e.noop,onPageChanged:e.noop,onItemDeleting:e.noop,onItemDeleted:e.noop,onItemInserting:e.noop,onItemInserted:e.noop,onItemEditing:e.noop,onItemUpdating:e.noop,onItemUpdated:e.noop,onItemInvalid:e.noop,onDataLoading:e.noop,onDataLoaded:e.noop,onOptionChanging:e.noop,onOptionChanged:e.noop,onError:e.noop,invalidClass:"jsgrid-invalid",containerClass:"jsgrid",tableClass:"jsgrid-table",gridHeaderClass:"jsgrid-grid-header",gridBodyClass:"jsgrid-grid-body",_init:function(t){e.extend(this,t),this._initLoadStrategy(),this._initController(),this._initFields(),this._attachWindowLoadResize(),this._attachWindowResizeCallback(),this._callEventHandler(this.onInit)},loadStrategy:function(){return this.pageLoading?new jsGrid.loadStrategies.PageLoadingStrategy(this):new jsGrid.loadStrategies.DirectLoadingStrategy(this)},_initLoadStrategy:function(){this._loadStrategy=l(this.loadStrategy,this)},_initController:function(){this._controller=e.extend({},u,l(this.controller,this))},renderTemplate:function(t,e,n){args=[];for(var r in n)args.push(n[r]);return args.unshift(t,e),(t=l.apply(null,args))===i||null===t?"":t},loadIndicator:function(t){return new jsGrid.LoadIndicator(t)},validation:function(t){return jsGrid.Validation&&new jsGrid.Validation(t)},_initFields:function(){var t=this;t.fields=e.map(t.fields,function(i){return e.isPlainObject(i)&&(i=new(i.type&&jsGrid.fields[i.type]||jsGrid.Field)(i)),i._grid=t,i})},_attachWindowLoadResize:function(){e(t).on("load",e.proxy(this._refreshSize,this))},_attachWindowResizeCallback:function(){this.updateOnResize&&e(t).on("resize",e.proxy(this._refreshSize,this))},_detachWindowResizeCallback:function(){e(t).off("resize",this._refreshSize)},option:function(t,e){var i,n;return 1===arguments.length?this[t]:(i={option:t,oldValue:this[t],newValue:e},this._callEventHandler(this.onOptionChanging,i),this._handleOptionChange(i.option,i.newValue),n={option:i.option,value:i.newValue},void this._callEventHandler(this.onOptionChanged,n))},fieldOption:function(t,e,i){return t=this._normalizeField(t),2===arguments.length?t[e]:(t[e]=i,void this._renderGrid())},_handleOptionChange:function(t,e){switch(this[t]=e,t){case"width":case"height":this._refreshSize();break;case"rowClass":case"rowRenderer":case"rowClick":case"rowDoubleClick":case"noDataRowClass":case"noDataContent":case"selecting":case"selectedRowClass":case"oddRowClass":case"evenRowClass":this._refreshContent();break;case"pageButtonCount":case"pagerFormat":case"pagePrevText":case"pageNextText":case"pageFirstText":case"pageLastText":case"pageNavigatorNextText":case"pageNavigatorPrevText":case"pagerClass":case"pagerNavButtonClass":case"pageClass":case"currentPageClass":case"pagerRenderer":this._refreshPager();break;case"fields":this._initFields(),this.render();break;case"data":case"editing":case"heading":case"filtering":case"inserting":case"paging":this.refresh();break;case"loadStrategy":case"pageLoading":this._initLoadStrategy(),this.search();break;case"pageIndex":this.openPage(e);break;case"pageSize":this.refresh(),this.search();break;case"editRowRenderer":case"editRowClass":this.cancelEdit();break;case"updateOnResize":this._detachWindowResizeCallback(),this._attachWindowResizeCallback();break;case"invalidNotify":case"invalidMessage":break;default:this.render()}},destroy:function(){this._detachWindowResizeCallback(),this._clear(),this._container.removeData(r)},render:function(){return this._renderGrid(),this.autoload?this.loadData():e.Deferred().resolve().promise()},_renderGrid:function(){this._clear(),this._container.addClass(this.containerClass).css("position","relative").append(this._createHeader()).append(this._createBody()),this._pagerContainer=this._createPagerContainer(),this._loadIndicator=this._createLoadIndicator(),this._validation=this._createValidation(),this.refresh()},_createLoadIndicator:function(){return l(this.loadIndicator,this,{message:this.loadMessage,shading:this.loadShading,container:this._container})},_createValidation:function(){return l(this.validation,this)},_clear:function(){this.cancelEdit(),clearTimeout(this._loadingTimer),this._pagerContainer&&this._pagerContainer.empty(),this._container.empty().css({position:"",width:"",height:""})},_createHeader:function(){var t=this._headerRow=this._createHeaderRow(),i=this._filterRow=this._createFilterRow(),n=this._insertRow=this._createInsertRow(),r=this._headerGrid=e("<table>").addClass(this.tableClass).append(t).append(i).append(n);return this._header=e("<div>").addClass(this.gridHeaderClass).addClass(this._scrollBarWidth()?"jsgrid-header-scrollbar":"").append(r)},_createBody:function(){var t=this._content=e("<tbody>"),i=this._bodyGrid=e("<table>").addClass(this.tableClass).append(t);return this._body=e("<div>").addClass(this.gridBodyClass).append(i).on("scroll",e.proxy(function(t){this._header.scrollLeft(t.target.scrollLeft)},this))},_createPagerContainer:function(){var t=this.pagerContainer||e("<div>").appendTo(this._container);return e(t).addClass(this.pagerContainerClass)},_eachField:function(t){var i=this;e.each(this.fields,function(e,n){n.visible&&t.call(i,n,e)})},_createHeaderRow:function(){if(e.isFunction(this.headerRowRenderer))return e(this.renderTemplate(this.headerRowRenderer,this));var t=e("<tr>").addClass(this.headerRowClass);return this._eachField(function(i,n){var r=this._prepareCell("<th>",i,"headercss",this.headerCellClass).append(this.renderTemplate(i.headerTemplate,i)).appendTo(t);this.sorting&&i.sorting&&r.addClass(this.sortableClass).on("click",e.proxy(function(){this.sort(n)},this))}),t},_prepareCell:function(t,i,n,r){return e(t).css("width",i.width).addClass(r||this.cellClass).addClass(n&&i[n]||i.css).addClass(i.align?"jsgrid-align-"+i.align:"")},_createFilterRow:function(){if(e.isFunction(this.filterRowRenderer))return e(this.renderTemplate(this.filterRowRenderer,this));var t=e("<tr>").addClass(this.filterRowClass);return this._eachField(function(e){this._prepareCell("<td>",e,"filtercss").append(this.renderTemplate(e.filterTemplate,e)).appendTo(t)}),t},_createInsertRow:function(){if(e.isFunction(this.insertRowRenderer))return e(this.renderTemplate(this.insertRowRenderer,this));var t=e("<tr>").addClass(this.insertRowClass);return this._eachField(function(e){this._prepareCell("<td>",e,"insertcss").append(this.renderTemplate(e.insertTemplate,e)).appendTo(t)}),t},_callEventHandler:function(t,i){return t.call(this,e.extend(i,{grid:this})),i},reset:function(){return this._resetSorting(),this._resetPager(),this._loadStrategy.reset()},_resetPager:function(){this._firstDisplayingPage=1,this._setPage(1)},_resetSorting:function(){this._sortField=null,this._sortOrder=o,this._clearSortingCss()},refresh:function(){this._callEventHandler(this.onRefreshing),this.cancelEdit(),this._refreshHeading(),this._refreshFiltering(),this._refreshInserting(),this._refreshContent(),this._refreshPager(),this._refreshSize(),this._callEventHandler(this.onRefreshed)},_refreshHeading:function(){this._headerRow.toggle(this.heading)},_refreshFiltering:function(){this._filterRow.toggle(this.filtering)},_refreshInserting:function(){this._insertRow.toggle(this.inserting)},_refreshContent:function(){var t=this._content;if(t.empty(),!this.data.length)return t.append(this._createNoDataRow()),this;for(var e=this._loadStrategy.firstDisplayIndex(),i=this._loadStrategy.lastDisplayIndex(),n=e;i>n;n++){var r=this.data[n];t.append(this._createRow(r,n))}},_createNoDataRow:function(){var t=0;return this._eachField(function(){t++}),e("<tr>").addClass(this.noDataRowClass).append(e("<td>").addClass(this.cellClass).attr("colspan",t).append(this.renderTemplate(this.noDataContent,this)))},_createRow:function(t,i){var n;return e.isFunction(this.rowRenderer)?n=this.renderTemplate(this.rowRenderer,this,{item:t,itemIndex:i}):(n=e("<tr>"),this._renderCells(n,t)),n.addClass(this._getRowClasses(t,i)).data(a,t).on("click",e.proxy(function(e){this.rowClick({item:t,itemIndex:i,event:e})},this)).on("dblclick",e.proxy(function(e){this.rowDoubleClick({item:t,itemIndex:i,event:e})},this)),this.selecting&&this._attachRowHover(n),n},_getRowClasses:function(t,e){var i=[];return i.push((e+1)%2?this.oddRowClass:this.evenRowClass),i.push(l(this.rowClass,this,t,e)),i.join(" ")},_attachRowHover:function(t){var i=this.selectedRowClass;t.hover(function(){e(this).addClass(i)},function(){e(this).removeClass(i)})},_renderCells:function(t,e){return this._eachField(function(i){t.append(this._createCell(e,i))}),this},_createCell:function(t,i){var n,r=this._getItemFieldValue(t,i),a={value:r,item:t};return n=e.isFunction(i.cellRenderer)?this.renderTemplate(i.cellRenderer,i,a):e("<td>").append(this.renderTemplate(i.itemTemplate||r,i,a)),this._prepareCell(n,i)},_getItemFieldValue:function(t,e){for(var i=e.name.split("."),n=t[i.shift()];n&&i.length;)n=n[i.shift()];return n},_setItemFieldValue:function(t,e,i){for(var n=e.name.split("."),r=t,a=n[0];r&&n.length;)t=r,a=n.shift(),r=t[a];if(!r)for(;n.length;)t=t[a]={},a=n.shift();t[a]=i},sort:function(t,i){return e.isPlainObject(t)&&(i=t.order,t=t.field),this._clearSortingCss(),this._setSortingParams(t,i),this._setSortingCss(),this._loadStrategy.sort()},_clearSortingCss:function(){this._headerRow.find("th").removeClass(this.sortAscClass).removeClass(this.sortDescClass)},_setSortingParams:function(t,e){t=this._normalizeField(t),e=e||(this._sortField===t?this._reversedSortOrder(this._sortOrder):o),this._sortField=t,this._sortOrder=e},_normalizeField:function(t){return e.isNumeric(t)?this.fields[t]:"string"==typeof t?e.grep(this.fields,function(e){return e.name===t})[0]:t},_reversedSortOrder:function(t){return t===o?"desc":o},_setSortingCss:function(){var t=this._visibleFieldIndex(this._sortField);this._headerRow.find("th").eq(t).addClass(this._sortOrder===o?this.sortAscClass:this.sortDescClass)},_visibleFieldIndex:function(t){return e.inArray(t,e.grep(this.fields,function(t){return t.visible}))},_sortData:function(){var t=this._sortFactor(),e=this._sortField;e&&this.data.sort(function(i,n){return t*e.sortingFunc(i[e.name],n[e.name])})},_sortFactor:function(){return this._sortOrder===o?1:-1},_itemsCount:function(){return this._loadStrategy.itemsCount()},_pagesCount:function(){var t=this._itemsCount(),e=this.pageSize;return Math.floor(t/e)+(t%e?1:0)},_refreshPager:function(){var t=this._pagerContainer;t.empty(),this.paging&&t.append(this._createPager());var e=this.paging&&this._pagesCount()>1;t.toggle(e)},_createPager:function(){var t;return(t=e.isFunction(this.pagerRenderer)?e(this.pagerRenderer({pageIndex:this.pageIndex,pageCount:this._pagesCount()})):e("<div>").append(this._createPagerByFormat())).addClass(this.pagerClass),t},_createPagerByFormat:function(){var t=this.pageIndex,i=this._pagesCount(),n=this._itemsCount(),r=this.pagerFormat.split(" ");return e.map(r,e.proxy(function(r){var a=r;return"{pages}"===r?a=this._createPages():"{first}"===r?a=this._createPagerNavButton(this.pageFirstText,1,t>1):"{prev}"===r?a=this._createPagerNavButton(this.pagePrevText,t-1,t>1):"{next}"===r?a=this._createPagerNavButton(this.pageNextText,t+1,i>t):"{last}"===r?a=this._createPagerNavButton(this.pageLastText,i,i>t):"{pageIndex}"===r?a=t:"{pageCount}"===r?a=i:"{itemCount}"===r&&(a=n),e.isArray(a)?a.concat([" "]):[a," "]},this))},_createPages:function(){var t=this._pagesCount(),e=this.pageButtonCount,i=this._firstDisplayingPage,n=[];i>1&&n.push(this._createPagerPageNavButton(this.pageNavigatorPrevText,this.showPrevPages));for(var r=0,a=i;e>r&&t>=a;r++,a++)n.push(a===this.pageIndex?this._createPagerCurrentPage():this._createPagerPage(a));return t>i+e-1&&n.push(this._createPagerPageNavButton(this.pageNavigatorNextText,this.showNextPages)),n},_createPagerNavButton:function(t,i,n){return this._createPagerButton(t,this.pagerNavButtonClass+(n?"":" "+this.pagerNavButtonInactiveClass),n?function(){this.openPage(i)}:e.noop)},_createPagerPageNavButton:function(t,e){return this._createPagerButton(t,this.pagerNavButtonClass,e)},_createPagerPage:function(t){return this._createPagerButton(t,this.pageClass,function(){this.openPage(t)})},_createPagerButton:function(t,i,n){var r=e("<a>").attr("href","javascript:void(0);").html(t).on("click",e.proxy(n,this));return e("<span>").addClass(i).append(r)},_createPagerCurrentPage:function(){return e("<span>").addClass(this.pageClass).addClass(this.currentPageClass).text(this.pageIndex)},_refreshSize:function(){this._refreshHeight(),this._refreshWidth()},_refreshWidth:function(){var t="auto"===this.width?this._getAutoWidth():this.width;this._container.width(t)},_getAutoWidth:function(){var t=this._headerGrid,e=this._header;t.width("auto");var i=t.outerWidth(),n=e.outerWidth()-e.innerWidth();return t.width(""),i+n},_scrollBarWidth:function(){var t;return function(){if(t===i){var n=e("<div style='width:50px;height:50px;overflow:hidden;position:absolute;top:-10000px;left:-10000px;'></div>"),r=e("<div style='height:100px;'></div>");n.append(r).appendTo("body");var a=r.innerWidth();n.css("overflow-y","auto");var s=r.innerWidth();n.remove(),t=a-s}return t}}(),_refreshHeight:function(){var t,e=this._container,i=this._pagerContainer,n=this.height;e.height(n),"auto"!==n&&(n=e.height(),t=this._header.outerHeight(!0),i.parents(e).length&&(t+=i.outerHeight(!0)),this._body.outerHeight(n-t))},showPrevPages:function(){var t=this._firstDisplayingPage,e=this.pageButtonCount;this._firstDisplayingPage=t>e?t-e:1,this._refreshPager()},showNextPages:function(){var t=this._firstDisplayingPage,e=this.pageButtonCount,i=this._pagesCount();this._firstDisplayingPage=t+2*e>i?i-e+1:t+e,this._refreshPager()},openPage:function(t){1>t||t>this._pagesCount()||(this._setPage(t),this._loadStrategy.openPage(t))},_setPage:function(t){var e=this._firstDisplayingPage,i=this.pageButtonCount;this.pageIndex=t,e>t&&(this._firstDisplayingPage=t),t>e+i-1&&(this._firstDisplayingPage=t-i+1),this._callEventHandler(this.onPageChanged,{pageIndex:t})},_controllerCall:function(t,i,n,r){if(n)return e.Deferred().reject().promise();this._showLoading();var a=this._controller;if(!a||!a[t])throw Error("controller has no method '"+t+"'");return d(a[t](i)).done(e.proxy(r,this)).fail(e.proxy(this._errorHandler,this)).always(e.proxy(this._hideLoading,this))},_errorHandler:function(){this._callEventHandler(this.onError,{args:e.makeArray(arguments)})},_showLoading:function(){this.loadIndication&&(clearTimeout(this._loadingTimer),this._loadingTimer=setTimeout(e.proxy(function(){this._loadIndicator.show()},this),this.loadIndicationDelay))},_hideLoading:function(){this.loadIndication&&(clearTimeout(this._loadingTimer),this._loadIndicator.hide())},search:function(t){return this._resetSorting(),this._resetPager(),this.loadData(t)},loadData:function(t){t=t||(this.filtering?this.getFilter():{}),e.extend(t,this._loadStrategy.loadParams(),this._sortingParams());var i=this._callEventHandler(this.onDataLoading,{filter:t});return this._controllerCall("loadData",t,i.cancel,function(t){t&&(this._loadStrategy.finishLoad(t),this._callEventHandler(this.onDataLoaded,{data:t}))})},getFilter:function(){var t={};return this._eachField(function(e){e.filtering&&this._setItemFieldValue(t,e,e.filterValue())}),t},_sortingParams:function(){return this.sorting&&this._sortField?{sortField:this._sortField.name,sortOrder:this._sortOrder}:{}},getSorting:function(){var t=this._sortingParams();return{field:t.sortField,order:t.sortOrder}},clearFilter:function(){var t=this._createFilterRow();return this._filterRow.replaceWith(t),this._filterRow=t,this.search()},insertItem:function(t){var i=t||this._getValidatedInsertItem();if(!i)return e.Deferred().reject().promise();var n=this._callEventHandler(this.onItemInserting,{item:i});return this._controllerCall("insertItem",i,n.cancel,function(t){t=t||i,this._loadStrategy.finishInsert(t),this._callEventHandler(this.onItemInserted,{item:t})})},_getValidatedInsertItem:function(){var t=this._getInsertItem();return this._validateItem(t,this._insertRow)?t:null},_getInsertItem:function(){var t={};return this._eachField(function(e){e.inserting&&this._setItemFieldValue(t,e,e.insertValue())}),t},_validateItem:function(t,i){var n=[],r={item:t,itemIndex:this._rowIndex(i),row:i};if(this._eachField(function(a){if(a.validate&&(i!==this._insertRow||a.inserting)&&(i!==this._getEditRow()||a.editing)){var s=this._getItemFieldValue(t,a),o=this._validation.validate(e.extend({value:s,rules:a.validate},r));this._setCellValidity(i.children().eq(this._visibleFieldIndex(a)),o),o.length&&n.push.apply(n,e.map(o,function(t){return{field:a,message:t}}))}}),!n.length)return!0;var a=e.extend({errors:n},r);return this._callEventHandler(this.onItemInvalid,a),this.invalidNotify(a),!1},_setCellValidity:function(t,e){t.toggleClass(this.invalidClass,!!e.length).attr("title",e.join("\n"))},clearInsert:function(){var t=this._createInsertRow();this._insertRow.replaceWith(t),this._insertRow=t,this.refresh()},editItem:function(t){var e=this.rowByItem(t);e.length&&this._editRow(e)},rowByItem:function(t){return t.jquery||t.nodeType?e(t):this._content.find("tr").filter(function(){return e.data(this,a)===t})},_editRow:function(t){if(this.editing){var e=t.data(a);if(!this._callEventHandler(this.onItemEditing,{row:t,item:e,itemIndex:this._itemIndex(e)}).cancel){this._editingRow&&this.cancelEdit();var i=this._createEditRow(e);this._editingRow=t,t.hide(),i.insertBefore(t),t.data(s,i)}}},_createEditRow:function(t){if(e.isFunction(this.editRowRenderer))return e(this.renderTemplate(this.editRowRenderer,this,{item:t,itemIndex:this._itemIndex(t)}));var i=e("<tr>").addClass(this.editRowClass);return this._eachField(function(e){var n=this._getItemFieldValue(t,e);this._prepareCell("<td>",e,"editcss").append(this.renderTemplate(e.editTemplate||"",e,{value:n,item:t})).appendTo(i)}),i},updateItem:function(t,e){1===arguments.length&&(e=t);var i=t?this.rowByItem(t):this._editingRow;return(e=e||this._getValidatedEditedItem())?this._updateRow(i,e):void 0},_getValidatedEditedItem:function(){var t=this._getEditedItem();return this._validateItem(t,this._getEditRow())?t:null},_updateRow:function(t,i){var n=t.data(a),r=this._itemIndex(n),s=e.extend(!0,{},n,i),o=this._callEventHandler(this.onItemUpdating,{row:t,item:s,itemIndex:r,previousItem:n});return this._controllerCall("updateItem",s,o.cancel,function(a){var o=e.extend(!0,{},n);s=a||e.extend(!0,n,i);var l=this._finishUpdate(t,s,r);this._callEventHandler(this.onItemUpdated,{row:l,item:s,itemIndex:r,previousItem:o})})},_rowIndex:function(t){return this._content.children().index(e(t))},_itemIndex:function(t){return e.inArray(t,this.data)},_finishUpdate:function(t,e,i){this.cancelEdit(),this.data[i]=e;var n=this._createRow(e,i);return t.replaceWith(n),n},_getEditedItem:function(){var t={};return this._eachField(function(e){e.editing&&this._setItemFieldValue(t,e,e.editValue())}),t},cancelEdit:function(){this._editingRow&&(this._getEditRow().remove(),this._editingRow.show(),this._editingRow=null)},_getEditRow:function(){return this._editingRow&&this._editingRow.data(s)},deleteItem:function(e){var i=this.rowByItem(e);if(i.length&&(!this.confirmDeleting||t.confirm(l(this.deleteConfirm,this,i.data(a)))))return this._deleteRow(i)},_deleteRow:function(t){var e=t.data(a),i=this._itemIndex(e),n=this._callEventHandler(this.onItemDeleting,{row:t,item:e,itemIndex:i});return this._controllerCall("deleteItem",e,n.cancel,function(){this._loadStrategy.finishDelete(e,i),this._callEventHandler(this.onItemDeleted,{row:t,item:e,itemIndex:i})})}},e.fn.jsGrid=function(t){var a=e.makeArray(arguments).slice(1),s=this;return this.each(function(){var o,l=e(this),d=l.data(r);if(d)if("string"==typeof t){if((o=d[t].apply(d,a))!==i&&o!==d)return s=o,!1}else d._detachWindowResizeCallback(),d._init(t),d.render();else new n(l,t)}),s};var h={},c={},f=function(t,i){e.each(i,function(i,n){return e.isPlainObject(n)?void f(t[i]||t[i[0].toUpperCase()+i.slice(1)],n):void(t.hasOwnProperty(i)?t[i]=n:t.prototype[i]=n)})};t.jsGrid={Grid:n,fields:h,setDefaults:function(t){var i;e.isPlainObject(t)?i=n.prototype:(i=h[t].prototype,t=arguments[1]||{}),e.extend(i,t)},locales:c,locale:function(t){var i=e.isPlainObject(t)?t:c[t];if(!i)throw Error("unknown locale "+t);f(jsGrid,i)},version:"1.5.3"}}(window,jQuery),function(t,e){function i(t){this._init(t)}i.prototype={container:"body",message:"Loading...",shading:!0,zIndex:1e3,shaderClass:"jsgrid-load-shader",loadPanelClass:"jsgrid-load-panel",_init:function(t){e.extend(!0,this,t),this._initContainer(),this._initShader(),this._initLoadPanel()},_initContainer:function(){this._container=e(this.container)},_initShader:function(){this.shading&&(this._shader=e("<div>").addClass(this.shaderClass).hide().css({position:"absolute",top:0,right:0,bottom:0,left:0,zIndex:this.zIndex}).appendTo(this._container))},_initLoadPanel:function(){this._loadPanel=e("<div>").addClass(this.loadPanelClass).text(this.message).hide().css({position:"absolute",top:"50%",left:"50%",zIndex:this.zIndex}).appendTo(this._container)},show:function(){var t=this._loadPanel.show(),e=t.outerWidth(),i=t.outerHeight();t.css({marginTop:-i/2,marginLeft:-e/2}),this._shader.show()},hide:function(){this._loadPanel.hide(),this._shader.hide()}},t.LoadIndicator=i}(jsGrid,jQuery),function(t,e){function i(t){this._grid=t}function n(t){this._grid=t,this._itemsCount=0}i.prototype={firstDisplayIndex:function(){var t=this._grid;return t.option("paging")?(t.option("pageIndex")-1)*t.option("pageSize"):0},lastDisplayIndex:function(){var t=this._grid,e=t.option("data").length;return t.option("paging")?Math.min(t.option("pageIndex")*t.option("pageSize"),e):e},itemsCount:function(){return this._grid.option("data").length},openPage:function(){this._grid.refresh()},loadParams:function(){return{}},sort:function(){return this._grid._sortData(),this._grid.refresh(),e.Deferred().resolve().promise()},reset:function(){return this._grid.refresh(),e.Deferred().resolve().promise()},finishLoad:function(t){this._grid.option("data",t)},finishInsert:function(t){var e=this._grid;e.option("data").push(t),e.refresh()},finishDelete:function(t,e){var i=this._grid;i.option("data").splice(e,1),i.reset()}},n.prototype={firstDisplayIndex:function(){return 0},lastDisplayIndex:function(){return this._grid.option("data").length},itemsCount:function(){return this._itemsCount},openPage:function(){this._grid.loadData()},loadParams:function(){var t=this._grid;return{pageIndex:t.option("pageIndex"),pageSize:t.option("pageSize")}},reset:function(){return this._grid.loadData()},sort:function(){return this._grid.loadData()},finishLoad:function(t){this._itemsCount=t.itemsCount,this._grid.option("data",t.data)},finishInsert:function(){this._grid.search()},finishDelete:function(){this._grid.search()}},t.loadStrategies={DirectLoadingStrategy:i,PageLoadingStrategy:n}}(jsGrid,jQuery),function(t){var e=function(t){return void 0!==t&&null!==t},i={string:function(t,i){return e(t)||e(i)?e(t)?e(i)?(""+t).localeCompare(""+i):1:-1:0},number:function(t,e){return t-e},date:function(t,e){return t-e},numberAsString:function(t,e){return parseFloat(t)-parseFloat(e)}};jsGrid.sortStrategies=i}(0,jQuery),function(t,e,i){function n(t){this._init(t)}n.prototype={_init:function(t){e.extend(!0,this,t)},validate:function(t){var i=[];return e.each(this._normalizeRules(t.rules),function(n,r){if(!r.validator(t.value,t.item,r.param)){var a=e.isFunction(r.message)?r.message(t.value,t.item):r.message;i.push(a)}}),i},_normalizeRules:function(t){return e.isArray(t)||(t=[t]),e.map(t,e.proxy(function(t){return this._normalizeRule(t)},this))},_normalizeRule:function(t){if("string"==typeof t&&(t={validator:t}),e.isFunction(t)&&(t={validator:t}),!e.isPlainObject(t))throw Error("wrong validation config specified");return t=e.extend({},t),e.isFunction(t.validator)?t:this._applyNamedValidator(t,t.validator)},_applyNamedValidator:function(t,i){delete t.validator;var n=r[i];if(!n)throw Error('unknown validator "'+i+'"');return e.isFunction(n)&&(n={validator:n}),e.extend({},n,t)}},t.Validation=n;var r={required:{message:"Field is required",validator:function(t){return void 0!==t&&null!==t&&""!==t}},rangeLength:{message:"Field value length is out of the defined range",validator:function(t,e,i){return t.length>=i[0]&&t.length<=i[1]}},minLength:{message:"Field value is too short",validator:function(t,e,i){return t.length>=i}},maxLength:{message:"Field value is too long",validator:function(t,e,i){return t.length<=i}},pattern:{message:"Field value is not matching the defined pattern",validator:function(t,e,i){return"string"==typeof i&&(i=new RegExp("^(?:"+i+")$")),i.test(t)}},range:{message:"Field value is out of the defined range",validator:function(t,e,i){return t>=i[0]&&t<=i[1]}},min:{message:"Field value is too small",validator:function(t,e,i){return t>=i}},max:{message:"Field value is too large",validator:function(t,e,i){return i>=t}}};t.validators=r}(jsGrid,jQuery),function(t,e,i){function n(t){e.extend(!0,this,t),this.sortingFunc=this._getSortingFunc()}n.prototype={name:"",title:null,css:"",align:"",width:100,visible:!0,filtering:!0,inserting:!0,editing:!0,sorting:!0,sorter:"string",headerTemplate:function(){return void 0===this.title||null===this.title?this.name:this.title},itemTemplate:function(t){return t},filterTemplate:function(){return""},insertTemplate:function(){return""},editTemplate:function(t,e){return this._value=t,this.itemTemplate(t,e)},filterValue:function(){return""},insertValue:function(){return""},editValue:function(){return this._value},_getSortingFunc:function(){var i=this.sorter;if(e.isFunction(i))return i;if("string"==typeof i)return t.sortStrategies[i];throw Error('wrong sorter for the field "'+this.name+'"!')}},t.Field=n}(jsGrid,jQuery),function(t,e){function i(t){n.call(this,t)}var n=t.Field;i.prototype=new n({autosearch:!0,readOnly:!1,filterTemplate:function(){if(!this.filtering)return"";var t=this._grid,e=this.filterControl=this._createTextBox();return this.autosearch&&e.on("keypress",function(e){13===e.which&&(t.search(),e.preventDefault())}),e},insertTemplate:function(){return this.inserting?this.insertControl=this._createTextBox():""},editTemplate:function(t){if(!this.editing)return this.itemTemplate.apply(this,arguments);var e=this.editControl=this._createTextBox();return e.val(t),e},filterValue:function(){return this.filterControl.val()},insertValue:function(){return this.insertControl.val()},editValue:function(){return this.editControl.val()},_createTextBox:function(){return e("<input>").attr("type","text").prop("readonly",!!this.readOnly)}}),t.fields.text=t.TextField=i}(jsGrid,jQuery),function(t,e,i){function n(t){r.call(this,t)}var r=t.TextField;n.prototype=new r({sorter:"number",align:"right",readOnly:!1,filterValue:function(){return this.filterControl.val()?parseInt(this.filterControl.val()||0,10):i},insertValue:function(){return this.insertControl.val()?parseInt(this.insertControl.val()||0,10):i},editValue:function(){return this.editControl.val()?parseInt(this.editControl.val()||0,10):i},_createTextBox:function(){return e("<input>").attr("type","number").prop("readonly",!!this.readOnly)}}),t.fields.number=t.NumberField=n}(jsGrid,jQuery),function(t,e){function i(t){n.call(this,t)}var n=t.TextField;i.prototype=new n({insertTemplate:function(){return this.inserting?this.insertControl=this._createTextArea():""},editTemplate:function(t){if(!this.editing)return this.itemTemplate.apply(this,arguments);var e=this.editControl=this._createTextArea();return e.val(t),e},_createTextArea:function(){return e("<textarea>").prop("readonly",!!this.readOnly)}}),t.fields.textarea=t.TextAreaField=i}(jsGrid,jQuery),function(t,e,i){function n(t){if(this.items=[],this.selectedIndex=-1,this.valueField="",this.textField="",t.valueField&&t.items.length){var e=t.items[0][t.valueField];this.valueType=typeof e===a?a:s}this.sorter=this.valueType,r.call(this,t)}var r=t.NumberField,a="number",s="string";n.prototype=new r({align:"center",valueType:a,itemTemplate:function(t){var n,r=this.items,a=this.valueField,s=this.textField;n=a?e.grep(r,function(e){return e[a]===t})[0]||{}:r[t];var o=s?n[s]:n;return o===i||null===o?"":o},filterTemplate:function(){if(!this.filtering)return"";var t=this._grid,e=this.filterControl=this._createSelect();return this.autosearch&&e.on("change",function(){t.search()}),e},insertTemplate:function(){return this.inserting?this.insertControl=this._createSelect():""},editTemplate:function(t){if(!this.editing)return this.itemTemplate.apply(this,arguments);var e=this.editControl=this._createSelect();return t!==i&&e.val(t),e},filterValue:function(){var t=this.filterControl.val();return this.valueType===a?parseInt(t||0,10):t},insertValue:function(){var t=this.insertControl.val();return this.valueType===a?parseInt(t||0,10):t},editValue:function(){var t=this.editControl.val();return this.valueType===a?parseInt(t||0,10):t},_createSelect:function(){var t=e("<select>"),i=this.valueField,n=this.textField,r=this.selectedIndex;return e.each(this.items,function(a,s){var o=i?s[i]:a,l=n?s[n]:s;e("<option>").attr("value",o).text(l).appendTo(t).prop("selected",r===a)}),t.prop("disabled",!!this.readOnly),t}}),t.fields.select=t.SelectField=n}(jsGrid,jQuery),function(t,e,i){function n(t){r.call(this,t)}var r=t.Field;n.prototype=new r({sorter:"number",align:"center",autosearch:!0,itemTemplate:function(t){return this._createCheckbox().prop({checked:t,disabled:!0})},filterTemplate:function(){if(!this.filtering)return"";var t=this._grid,i=this.filterControl=this._createCheckbox();return i.prop({readOnly:!0,indeterminate:!0}),i.on("click",function(){var t=e(this);t.prop("readOnly")?t.prop({checked:!1,readOnly:!1}):t.prop("checked")||t.prop({readOnly:!0,indeterminate:!0})}),this.autosearch&&i.on("click",function(){t.search()}),i},insertTemplate:function(){return this.inserting?this.insertControl=this._createCheckbox():""},editTemplate:function(t){if(!this.editing)return this.itemTemplate.apply(this,arguments);var e=this.editControl=this._createCheckbox();return e.prop("checked",t),e},filterValue:function(){return this.filterControl.get(0).indeterminate?void 0:this.filterControl.is(":checked")},insertValue:function(){return this.insertControl.is(":checked")},editValue:function(){return this.editControl.is(":checked")},_createCheckbox:function(){return e("<input>").attr("type","checkbox")}}),t.fields.checkbox=t.CheckboxField=n}(jsGrid,jQuery),function(t,e){function i(t){n.call(this,t),this._configInitialized=!1}var n=t.Field;i.prototype=new n({css:"jsgrid-control-field",align:"center",width:50,filtering:!1,inserting:!1,editing:!1,sorting:!1,buttonClass:"jsgrid-button",modeButtonClass:"jsgrid-mode-button",modeOnButtonClass:"jsgrid-mode-on-button",searchModeButtonClass:"jsgrid-search-mode-button",insertModeButtonClass:"jsgrid-insert-mode-button",editButtonClass:"jsgrid-edit-button",deleteButtonClass:"jsgrid-delete-button",searchButtonClass:"jsgrid-search-button",clearFilterButtonClass:"jsgrid-clear-filter-button",insertButtonClass:"jsgrid-insert-button",updateButtonClass:"jsgrid-update-button",cancelEditButtonClass:"jsgrid-cancel-edit-button",searchModeButtonTooltip:"Switch to searching",insertModeButtonTooltip:"Switch to inserting",editButtonTooltip:"Edit",deleteButtonTooltip:"Delete",searchButtonTooltip:"Search",clearFilterButtonTooltip:"Clear filter",insertButtonTooltip:"Insert",updateButtonTooltip:"Update",cancelEditButtonTooltip:"Cancel edit",editButton:!0,deleteButton:!0,clearFilterButton:!0,modeSwitchButton:!0,_initConfig:function(){this._hasFiltering=this._grid.filtering,this._hasInserting=this._grid.inserting,this._hasInserting&&this.modeSwitchButton&&(this._grid.inserting=!1),this._configInitialized=!0},headerTemplate:function(){this._configInitialized||this._initConfig();var t=this._hasFiltering,e=this._hasInserting;return this.modeSwitchButton&&(t||e)?t&&!e?this._createFilterSwitchButton():e&&!t?this._createInsertSwitchButton():this._createModeSwitchButton():""},itemTemplate:function(t,i){var n=e([]);return this.editButton&&(n=n.add(this._createEditButton(i))),this.deleteButton&&(n=n.add(this._createDeleteButton(i))),n},filterTemplate:function(){var t=this._createSearchButton();return this.clearFilterButton?t.add(this._createClearFilterButton()):t},insertTemplate:function(){return this._createInsertButton()},editTemplate:function(){return this._createUpdateButton().add(this._createCancelEditButton())},_createFilterSwitchButton:function(){return this._createOnOffSwitchButton("filtering",this.searchModeButtonClass,!0)},_createInsertSwitchButton:function(){return this._createOnOffSwitchButton("inserting",this.insertModeButtonClass,!1)},_createOnOffSwitchButton:function(t,i,n){var r=n,a=e.proxy(function(){s.toggleClass(this.modeOnButtonClass,r)},this),s=this._createGridButton(this.modeButtonClass+" "+i,"",function(e){r=!r,e.option(t,r),a()});return a(),s},_createModeSwitchButton:function(){var t=!1,i=e.proxy(function(){n.attr("title",t?this.searchModeButtonTooltip:this.insertModeButtonTooltip).toggleClass(this.insertModeButtonClass,!t).toggleClass(this.searchModeButtonClass,t)},this),n=this._createGridButton(this.modeButtonClass,"",function(e){t=!t,e.option("inserting",t),e.option("filtering",!t),i()});return i(),n},_createEditButton:function(t){return this._createGridButton(this.editButtonClass,this.editButtonTooltip,function(e,i){e.editItem(t),i.stopPropagation()})},_createDeleteButton:function(t){return this._createGridButton(this.deleteButtonClass,this.deleteButtonTooltip,function(e,i){e.deleteItem(t),i.stopPropagation()})},_createSearchButton:function(){return this._createGridButton(this.searchButtonClass,this.searchButtonTooltip,function(t){t.search()})},_createClearFilterButton:function(){return this._createGridButton(this.clearFilterButtonClass,this.clearFilterButtonTooltip,function(t){t.clearFilter()})},_createInsertButton:function(){return this._createGridButton(this.insertButtonClass,this.insertButtonTooltip,function(t){t.insertItem().done(function(){t.clearInsert()})})},_createUpdateButton:function(){return this._createGridButton(this.updateButtonClass,this.updateButtonTooltip,function(t,e){t.updateItem(),e.stopPropagation()})},_createCancelEditButton:function(){return this._createGridButton(this.cancelEditButtonClass,this.cancelEditButtonTooltip,function(t,e){t.cancelEdit(),e.stopPropagation()})},_createGridButton:function(t,i,n){var r=this._grid;return e("<input>").addClass(this.buttonClass).addClass(t).attr({type:"button",title:i}).on("click",function(t){n(r,t)})},editValue:function(){return""}}),t.fields.control=t.ControlField=i}(jsGrid,jQuery),function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof module&&module.exports?module.exports=e():t.numeral=e()}(this,function(){function t(t,e){this._input=t,this._value=e}var e,i,n={},r={},a={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0",scalePercentBy100:!0},s={currentLocale:a.currentLocale,zeroFormat:a.zeroFormat,nullFormat:a.nullFormat,defaultFormat:a.defaultFormat,scalePercentBy100:a.scalePercentBy100};return e=function(r){var a,o,l,d;if(e.isNumeral(r))a=r.value();else if(0===r||void 0===r)a=0;else if(null===r||i.isNaN(r))a=null;else if("string"==typeof r)if(s.zeroFormat&&r===s.zeroFormat)a=0;else if(s.nullFormat&&r===s.nullFormat||!r.replace(/[^0-9]+/g,"").length)a=null;else{for(o in n)if((d="function"==typeof n[o].regexps.unformat?n[o].regexps.unformat():n[o].regexps.unformat)&&r.match(d)){l=n[o].unformat;break}a=(l=l||e._.stringToNumber)(r)}else a=Number(r)||null;return new t(r,a)},e.version="2.0.6",e.isNumeral=function(e){return e instanceof t},e._=i={numberToFormat:function(t,i,n){var a,s,o,l,d,u,h,c=r[e.options.currentLocale],f=!1,g=!1,p=0,_="",m=1e12,v="",C=!1;if(t=t||0,s=Math.abs(t),e._.includes(i,"(")?(f=!0,i=i.replace(/[\(|\)]/g,"")):(e._.includes(i,"+")||e._.includes(i,"-"))&&(d=e._.includes(i,"+")?i.indexOf("+"):0>t?i.indexOf("-"):-1,i=i.replace(/[\+|\-]/g,"")),e._.includes(i,"a")&&(a=i.match(/a(k|m|b|t)?/),a=!!a&&a[1],e._.includes(i," a")&&(_=" "),i=i.replace(new RegExp(_+"a[kmbt]?"),""),s>=m&&!a||"t"===a?(_+=c.abbreviations.trillion,t/=m):m>s&&s>=1e9&&!a||"b"===a?(_+=c.abbreviations.billion,t/=1e9):1e9>s&&s>=1e6&&!a||"m"===a?(_+=c.abbreviations.million,t/=1e6):(1e6>s&&s>=1e3&&!a||"k"===a)&&(_+=c.abbreviations.thousand,t/=1e3)),e._.includes(i,"[.]")&&(g=!0,i=i.replace("[.]",".")),o=t.toString().split(".")[0],l=i.split(".")[1],u=i.indexOf(","),p=(i.split(".")[0].split(",")[0].match(/0/g)||[]).length,l?(e._.includes(l,"[")?(l=l.replace("]",""),l=l.split("["),v=e._.toFixed(t,l[0].length+l[1].length,n,l[1].length)):v=e._.toFixed(t,l.length,n),o=v.split(".")[0],v=e._.includes(v,".")?c.delimiters.decimal+v.split(".")[1]:"",g&&0===Number(v.slice(1))&&(v="")):o=e._.toFixed(t,0,n),_&&!a&&Number(o)>=1e3&&_!==c.abbreviations.trillion)switch(o=String(Number(o)/1e3),_){case c.abbreviations.thousand:_=c.abbreviations.million;break;case c.abbreviations.million:_=c.abbreviations.billion;break;case c.abbreviations.billion:_=c.abbreviations.trillion}if(e._.includes(o,"-")&&(o=o.slice(1),C=!0),o.length<p)for(var w=p-o.length;w>0;w--)o="0"+o;return u>-1&&(o=o.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+c.delimiters.thousands)),0===i.indexOf(".")&&(o=""),h=o+v+(_||""),f?h=(f&&C?"(":"")+h+(f&&C?")":""):d>=0?h=0===d?(C?"-":"+")+h:h+(C?"-":"+"):C&&(h="-"+h),h},stringToNumber:function(t){var e,i,n,a=r[s.currentLocale],o=t,l={thousand:3,million:6,billion:9,trillion:12};if(s.zeroFormat&&t===s.zeroFormat)i=0;else if(s.nullFormat&&t===s.nullFormat||!t.replace(/[^0-9]+/g,"").length)i=null;else{i=1,"."!==a.delimiters.decimal&&(t=t.replace(/\./g,"").replace(a.delimiters.decimal,"."));for(e in l)if(n=new RegExp("[^a-zA-Z]"+a.abbreviations[e]+"(?:\\)|(\\"+a.currency.symbol+")?(?:\\))?)?$"),o.match(n)){i*=Math.pow(10,l[e]);break}i*=(t.split("-").length+Math.min(t.split("(").length-1,t.split(")").length-1))%2?1:-1,t=t.replace(/[^0-9\.]+/g,""),i*=Number(t)}return i},isNaN:function(t){return"number"==typeof t&&isNaN(t)},includes:function(t,e){return-1!==t.indexOf(e)},insert:function(t,e,i){return t.slice(0,i)+e+t.slice(i)},reduce:function(t,e){if(null===this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof e)throw new TypeError(e+" is not a function");var i,n=Object(t),r=n.length>>>0,a=0;if(3===arguments.length)i=arguments[2];else{for(;r>a&&!(a in n);)a++;if(a>=r)throw new TypeError("Reduce of empty array with no initial value");i=n[a++]}for(;r>a;a++)a in n&&(i=e(i,n[a],a,n));return i},multiplier:function(t){var e=t.toString().split(".");return e.length<2?1:Math.pow(10,e[1].length)},correctionFactor:function(){return Array.prototype.slice.call(arguments).reduce(function(t,e){var n=i.multiplier(e);return t>n?t:n},1)},toFixed:function(t,e,i,n){var r,a,s,o,l=t.toString().split("."),d=e-(n||0);return r=2===l.length?Math.min(Math.max(l[1].length,d),e):d,s=Math.pow(10,r),o=(i(t+"e+"+r)/s).toFixed(r),n>e-r&&(a=new RegExp("\\.?0{1,"+(n-(e-r))+"}$"),o=o.replace(a,"")),o}},e.options=s,e.formats=n,e.locales=r,e.locale=function(t){return t&&(s.currentLocale=t.toLowerCase()),s.currentLocale},e.localeData=function(t){if(!t)return r[s.currentLocale];if(t=t.toLowerCase(),!r[t])throw new Error("Unknown locale : "+t);return r[t]},e.reset=function(){for(var t in a)s[t]=a[t]},e.zeroFormat=function(t){s.zeroFormat="string"==typeof t?t:null},e.nullFormat=function(t){s.nullFormat="string"==typeof t?t:null},e.defaultFormat=function(t){s.defaultFormat="string"==typeof t?t:"0.0"},e.register=function(t,e,i){if(e=e.toLowerCase(),this[t+"s"][e])throw new TypeError(e+" "+t+" already registered.");return this[t+"s"][e]=i,i},e.validate=function(t,i){var n,r,a,s,o,l,d,u;if("string"!=typeof t&&(t+="",console.warn&&console.warn("Numeral.js: Value is not string. It has been co-erced to: ",t)),(t=t.trim()).match(/^\d+$/))return!0;if(""===t)return!1;try{d=e.localeData(i)}catch(t){d=e.localeData(e.locale())}return a=d.currency.symbol,o=d.abbreviations,n=d.delimiters.decimal,r="."===d.delimiters.thousands?"\\.":d.delimiters.thousands,(null===(u=t.match(/^[^\d]+/))||(t=t.substr(1),u[0]===a))&&!(null!==(u=t.match(/[^\d]+$/))&&(t=t.slice(0,-1),u[0]!==o.thousand&&u[0]!==o.million&&u[0]!==o.billion&&u[0]!==o.trillion)||(l=new RegExp(r+"{2}"),t.match(/[^\d.,]/g)||(s=t.split(n)).length>2||(s.length<2?!s[0].match(/^\d+.*\d$/)||s[0].match(l):1===s[0].length?!s[0].match(/^\d+$/)||s[0].match(l)||!s[1].match(/^\d+$/):!s[0].match(/^\d+.*\d$/)||s[0].match(l)||!s[1].match(/^\d+$/))))},e.fn=t.prototype={clone:function(){return e(this)},format:function(t,i){var r,a,o,l=this._value,d=t||s.defaultFormat;if(i=i||Math.round,0===l&&null!==s.zeroFormat)a=s.zeroFormat;else if(null===l&&null!==s.nullFormat)a=s.nullFormat;else{for(r in n)if(d.match(n[r].regexps.format)){o=n[r].format;break}a=(o=o||e._.numberToFormat)(l,d,i)}return a},value:function(){return this._value},input:function(){return this._input},set:function(t){return this._value=Number(t),this},add:function(t){var e=i.correctionFactor.call(null,this._value,t);return this._value=i.reduce([this._value,t],function(t,i,n,r){return t+Math.round(e*i)},0)/e,this},subtract:function(t){var e=i.correctionFactor.call(null,this._value,t);return this._value=i.reduce([t],function(t,i,n,r){return t-Math.round(e*i)},Math.round(this._value*e))/e,this},multiply:function(t){return this._value=i.reduce([this._value,t],function(t,e,n,r){var a=i.correctionFactor(t,e);return Math.round(t*a)*Math.round(e*a)/Math.round(a*a)},1),this},divide:function(t){return this._value=i.reduce([this._value,t],function(t,e,n,r){var a=i.correctionFactor(t,e);return Math.round(t*a)/Math.round(e*a)}),this},difference:function(t){return Math.abs(e(this._value).subtract(t).value())}},e.register("locale","en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(t){var e=t%10;return 1==~~(t%100/10)?"th":1===e?"st":2===e?"nd":3===e?"rd":"th"},currency:{symbol:"$"}}),e.register("format","bps",{regexps:{format:/(BPS)/,unformat:/(BPS)/},format:function(t,i,n){var r,a=e._.includes(i," BPS")?" ":"";return t*=1e4,i=i.replace(/\s?BPS/,""),r=e._.numberToFormat(t,i,n),e._.includes(r,")")?((r=r.split("")).splice(-1,0,a+"BPS"),r=r.join("")):r=r+a+"BPS",r},unformat:function(t){return+(1e-4*e._.stringToNumber(t)).toFixed(15)}}),function(){var t={base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},i={base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},n=t.suffixes.concat(i.suffixes.filter(function(e){return t.suffixes.indexOf(e)<0})).join("|");n="("+n.replace("B","B(?!PS)")+")",e.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp(n)},format:function(n,r,a){var s,o,l,d=e._.includes(r,"ib")?i:t,u=e._.includes(r," b")||e._.includes(r," ib")?" ":"";for(r=r.replace(/\s?i?b/,""),s=0;s<=d.suffixes.length;s++)if(o=Math.pow(d.base,s),l=Math.pow(d.base,s+1),null===n||0===n||n>=o&&l>n){u+=d.suffixes[s],o>0&&(n/=o);break}return e._.numberToFormat(n,r,a)+u},unformat:function(n){var r,a,s=e._.stringToNumber(n);if(s){for(r=t.suffixes.length-1;r>=0;r--){if(e._.includes(n,t.suffixes[r])){a=Math.pow(t.base,r);break}if(e._.includes(n,i.suffixes[r])){a=Math.pow(i.base,r);break}}s*=a||1}return s}})}(),e.register("format","currency",{regexps:{format:/(\$)/},format:function(t,i,n){var r,a,s=e.locales[e.options.currentLocale],o={before:i.match(/^([\+|\-|\(|\s|\$]*)/)[0],after:i.match(/([\+|\-|\)|\s|\$]*)$/)[0]};for(i=i.replace(/\s?\$\s?/,""),r=e._.numberToFormat(t,i,n),t>=0?(o.before=o.before.replace(/[\-\(]/,""),o.after=o.after.replace(/[\-\)]/,"")):0>t&&!e._.includes(o.before,"-")&&!e._.includes(o.before,"(")&&(o.before="-"+o.before),a=0;a<o.before.length;a++)switch(o.before[a]){case"$":r=e._.insert(r,s.currency.symbol,a);break;case" ":r=e._.insert(r," ",a+s.currency.symbol.length-1)}for(a=o.after.length-1;a>=0;a--)switch(o.after[a]){case"$":r=a===o.after.length-1?r+s.currency.symbol:e._.insert(r,s.currency.symbol,-(o.after.length-(1+a)));break;case" ":r=a===o.after.length-1?r+" ":e._.insert(r," ",-(o.after.length-(1+a)+s.currency.symbol.length-1))}return r}}),e.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(t,i,n){var r=("number"!=typeof t||e._.isNaN(t)?"0e+0":t.toExponential()).split("e");return i=i.replace(/e[\+|\-]{1}0/,""),e._.numberToFormat(Number(r[0]),i,n)+"e"+r[1]},unformat:function(t){var i=e._.includes(t,"e+")?t.split("e+"):t.split("e-"),n=Number(i[0]),r=Number(i[1]);return r=e._.includes(t,"e-")?r*=-1:r,e._.reduce([n,Math.pow(10,r)],function(t,i,n,r){var a=e._.correctionFactor(t,i);return t*a*(i*a)/(a*a)},1)}}),e.register("format","ordinal",{regexps:{format:/(o)/},format:function(t,i,n){var r=e.locales[e.options.currentLocale],a=e._.includes(i," o")?" ":"";return i=i.replace(/\s?o/,""),a+=r.ordinal(t),e._.numberToFormat(t,i,n)+a}}),e.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(t,i,n){var r,a=e._.includes(i," %")?" ":"";return e.options.scalePercentBy100&&(t*=100),i=i.replace(/\s?\%/,""),r=e._.numberToFormat(t,i,n),e._.includes(r,")")?((r=r.split("")).splice(-1,0,a+"%"),r=r.join("")):r=r+a+"%",r},unformat:function(t){var i=e._.stringToNumber(t);return e.options.scalePercentBy100?.01*i:i}}),e.register("format","time",{regexps:{format:/(:)/,unformat:/(:)/},format:function(t,e,i){var n=Math.floor(t/60/60),r=Math.floor((t-60*n*60)/60),a=Math.round(t-60*n*60-60*r);return n+":"+(10>r?"0"+r:r)+":"+(10>a?"0"+a:a)},unformat:function(t){var e=t.split(":"),i=0;return 3===e.length?(i+=60*Number(e[0])*60,i+=60*Number(e[1]),i+=Number(e[2])):2===e.length&&(i+=60*Number(e[0]),i+=Number(e[1])),Number(i)}}),e}),function(){"use strict";function t(t){jsGrid.NumberField.call(this,t)}function e(t){jsGrid.TextField.call(this,t)}t.prototype=new jsGrid.NumberField({itemTemplate:function(t){var e=numeral(t).format(this.format||"0,0.00");return this.currency_symbol&&this.currency_symbol.length>0&&(e=e.replace(/\$/g,this.currency_symbol)),e}}),e.prototype=new jsGrid.TextField({itemTemplate:function(t){var e,i,n=new RegExp(/(^\[.*\])(\(.*\)$)/);if(n.test(t)){var r=n.exec(t);e=(e=r[1]).substring(1,e.length-1),i=(i=r[2]).substring(1,i.length-1)}else e=i=t;return"<a href='"+i+"'>"+e+"</a>"}}),jsGrid.fields.number=t,jsGrid.fields.link=e}(),function(t){"use strict";window.wpt=window.wpt||{},window.wpt.createTable=function(e){e.width||delete e.width,e.height||delete e.height,e.controller={loadData:function(i){i=i||{};var n=e._ctrl_url.replace(/&amp;/gi,"&");return t.ajax({type:"GET",url:n,data:i})}},e.onRefreshed=function(){"function"==typeof t.fancybox&&t("#"+e._id_div+" [data-fancybox]").fancybox()},t("#"+e._id_div).jsGrid(e)}}(jQuery);