(function ($) {
	"use strict";
	var WidgetInfounFold = function ($scope, $) {
		if ( $scope.find( '.ec-info-unfold-wrapper' ).length ) {
			var button = $scope.find( ".ec-iu-f-button" ),
			left       = $scope.find( ".ec-info-unfold-left" ),
			right      = $scope.find( ".ec-info-unfold-right" ),
			back       = $scope.find( ".ec-info-unfold-back" ),
			close      = $scope.find( ".ec-info-unfold-close" );
			$( button ).on(
				'click',
				function () {
					$( left ).addClass( "ec-iu-visible" );
					setTimeout(
						function () {
							$( right ).addClass( "ec-iu-visible" );
						},
						200
					);
					setTimeout(
						function () {
							$( back ).addClass( "ec-iu-visible" );
						},
						300
					);
					$( close ).delay( 1000 ).fadeIn(
						function () {
							$( this ).css( "display", "inline-flex" );
						}
					);
				}
			);

			$( close ).on(
				'click',
				function () {
					$( close ).fadeOut();
					setTimeout(
						function () {
							$( left ).removeClass( "ec-iu-visible" );
						},
						200
					);
					$( right ).removeClass( "ec-iu-visible" );
					setTimeout(
						function () {
							$( back ).removeClass( "ec-iu-visible" );
						},
						600
					);
				}
			);
		}
	};
	$( window ).on(
		'elementor/frontend/init',
		function () {
			elementorFrontend.hooks.addAction( 'frontend/element_ready/ecafe-infounfold.default', WidgetInfounFold );
		}
	);
})( jQuery );