// source --> https://www.visualpromo.com.br/wp-content/plugins/meteor-slides/js/slideshow.js?ver=7.1.2 
/*  Script for the Meteor Slides 1.5.7 slideshow
	
	Copy "slideshow.js" from "/meteor-slides/js/" to your theme's directory to replace
	the plugin's default slideshow script.
	
	Learn more about customizing the slideshow script for Meteor Slides: 
	http://www.jleuze.com/plugins/meteor-slides/customizing-the-slideshow-script/
*/

// Set custom shortcut to avoid conflicts
var $j = jQuery.noConflict();

$j(document).ready(function() {

	// Get the slideshow options
	var $slidespeed      = parseInt( meteorslidessettings.meteorslideshowspeed );
	var $slidetimeout    = parseInt( meteorslidessettings.meteorslideshowduration );
	var $slideheight     = parseInt( meteorslidessettings.meteorslideshowheight );
	var $slidewidth      = parseInt( meteorslidessettings.meteorslideshowwidth );
	var $slidetransition = meteorslidessettings.meteorslideshowtransition;

	// Setup jQuery Cycle
    $j('.meteor-slides').cycle({
		cleartypeNoBg: true,
		fit:           1,
		fx:            $slidetransition,
		height:        $slideheight,
		next:          '#meteor-next',
		pager:         '#meteor-buttons',
		pagerEvent:    'click',
		pause:         1,
		prev:          '#meteor-prev',
		slideExpr:     '.mslide',
		speed:         $slidespeed,
		timeout:       $slidetimeout,
		width:         $slidewidth
	});
	
	// Setup jQuery TouchWipe
    $j('.meteor-slides').touchwipe({
        wipeLeft: function() {
            $j('.meteor-slides').cycle('next');
        },
        wipeRight: function() {
            $j('.meteor-slides').cycle('prev');
        },
		preventDefaultEvents: false
    });
	
	// Add class to hide and show prev/next nav on hover
    $j('.meteor-slides').hover(function () {
		$j(this).addClass('navhover');
    }, function () {
		$j(this).removeClass('navhover');
    });
	
	// Set a fixed height for prev/next nav in IE6
	if(typeof document.body.style.maxWidth === 'undefined') {
		$j('.meteor-nav a').height($slideheight);
	}
	
	// Add align class if set in metadata
	$j('.meteor-slides').each(function () {
		meteormetadata = $j(this).metadata();
		if (meteormetadata.align == 'left') {
			$j(this).addClass('meteor-left');
		} else if (meteormetadata.align == 'right') {
			$j(this).addClass('meteor-right');
		} else if (meteormetadata.align == 'center') {
			$j(this).addClass('meteor-center');
		}
	});
	
});
// source --> https://www.visualpromo.com.br/wp-content/plugins/addon-elements-for-elementor-page-builder/assets/js/iconHelper.js?ver=1.0 
window.eae = {};
window.renderIconHtml = function(view,elementor,sett,control_name, wClass = '', index=''){
    // console.log("View => ", view);
    // data.addRenderAttribute('key', 'context', 'value');
    // console.log(data.getRenderAttributeString('key'));

    var icon_class = '';
    let imageHtml = '';
    let lottie_data = [];
    let iconHtml = '';
    if(sett[control_name+'_graphic_type'] != 'none' && sett[control_name+'_graphic_type'] != ''){
        icon_class += ' eae-gbl-icon eae-graphic-type-'+ sett[control_name+'_graphic_type'] + ' elementor-animation-' + sett[control_name+'_hover_animation'];
        if(wClass != ''){
            icon_class += ' '+wClass;     
        }

        icon_class += ' eae-graphic-view-'+sett[control_name+'_view']; 
        if(sett[control_name+'_view'] != 'default'){
            icon_class += ' eae-graphic-shape-'+sett[control_name+'_shape'];
        }

        if(sett[control_name+'_graphic_type'] == 'lottie'){
            if( (sett[control_name+'_lottie_animation_url'] != '' ) ||  (sett[control_name+'_source_json']['url'] != '') ) {
                icon_class += ' eae-lottie-animation eae-lottie';
                lottie_data = {
                    'loop' : ( sett[control_name+'_lottie_animation_loop'] === 'yes' ) ? true : false,
                    'reverse' : ( sett[control_name+'_lottie_animation_reverse'] === 'yes' ) ? true : false,
                } 
                if(sett[control_name+'_source'] == 'media_file' && (sett[control_name+'_source_json']['url'] != '')){
                    lottie_data.url = sett[control_name+'_source_json']['url'];
                }else{
                    lottie_data.url = sett[control_name+'_lottie_animation_url'];
                }
                view.addRenderAttribute('panel-icon-'+ index, 'data-lottie-settings', JSON.stringify(lottie_data));
            }         
        }
        view.addRenderAttribute('panel-icon-'+ index, 'class', icon_class);
        if(sett[control_name+'_graphic_type'] == 'lottie' ){
            if(lottie_data.url != undefined){
                iconHtml = `<span ${view.getRenderAttributeString( 'panel-icon-'+ index )}></span>`;    
            }
        }else{
            if(sett[control_name+'_graphic_type'] === 'icon'){
                if(sett[control_name+'_graphic_icon']['value'] != ''){
                    var icon = elementor.helpers.renderIcon( view, sett[control_name+'_graphic_icon'], { 'aria-hidden': true }, 'i' , 'object' );
                    imageHtml = icon.value;
                    iconHtml = `<span ${ view.getRenderAttributeString( 'panel-icon-'+ index ) }>
                                ${imageHtml}
                                </span>`;
                }            
            }else{
                if(sett[control_name+'_graphic_image']['url'] != ''){
                    var image = {
                        id: sett[control_name+'_graphic_image']['id'],
                        url: sett[control_name+'_graphic_image']['url'],
                        size: sett[control_name+'_graphic_image_size'],
                        dimension: sett[control_name+'_graphic_image_custom_dimension'],
                        model: view.getEditModel()
                    };
                    var image_url = elementor.imagesManager.getImageUrl( image );
                    imageHtml = '<img src="' + image_url + '" />';
                    
                    iconHtml = `<span ${ view.getRenderAttributeString( 'panel-icon-'+ index ) }>
                                    ${imageHtml}
                                </span>`;
                }
            }
        }       
    }
    return iconHtml;
}

window.eae.validateHTMLTag = function( $tag, $collection = null, $fallback = null){
   if($collection == null){
        $collection = ['h1','h2','h3','h4','h5','h6','p','span','div'];
   }
   if($fallback == null){
    $fallback = 'h3';
   }    
   if($collection.includes($tag)){
        return $tag;
   }else{
        return $fallback;
   }
};