(function ($) {
	'use strict';

	function initRestaurantFoodMenu() {
		$(document).off('click.unlockafeRestaurantFoodMenu', '.unlockaddons_restaurant_food_menu_tab');
		$(document).on('click.unlockafeRestaurantFoodMenu', '.unlockaddons_restaurant_food_menu_tab', function () {
			var $tab = $(this);
			var category = $tab.data('category') || '';
			var $container = $tab.closest('.unlockaddons_restaurant_food_menu_container');
			var $items = $container.find('.unlockaddons_restaurant_food_menu_item');

			$tab.siblings('.unlockaddons_restaurant_food_menu_tab').removeClass('active');
			$tab.addClass('active');

			$items.each(function () {
				var itemCat = $(this).data('category') || '';
				if (category === '' || itemCat === category) {
					$(this).show();
				} else {
					$(this).hide();
				}
			});
		});
	}

	$(function () {
		initRestaurantFoodMenu();
	});

	if (typeof elementorFrontend !== 'undefined') {
		elementorFrontend.hooks.addAction('frontend/element_ready/unlockafe-restaurant-food-menu.default', function () {
			initRestaurantFoodMenu();
		});
	}
})(jQuery);
