"use strict";

function _defineProperty(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true,
        });
    } else {
        obj[key] = value;
    }
    return obj;
}

(function ($) {
    /* 1.0 Dropdown Menu  */
    $(".menu-item-has-children > a").on("click", function () {
        var element = $(this).parent("li");

        if (element.hasClass("open")) {
            element.removeClass("open");
            element.find("li").removeClass("open");
            element.find("ul").slideUp(500);
            element.find(".rt-mega-menu").slideUp(500);
        } else {
            element.addClass("open");
            element.children("ul").slideDown(500);
            element.children(".rt-mega-menu").slideDown(500);
            element.siblings("li").children("ul").slideUp();
            element.siblings("li").removeClass("open");
            element.siblings("li").find("li").removeClass("open");
            element.siblings("li").find("ul").slideUp();
        }
    });
    $(".has-children > .jobwidget_tiitle").on("click", function () {
        var element = $(this).parent("li");

        if (element.hasClass("open")) {
            element.removeClass("open");
            element.find("li").removeClass("open");
            element.find("ul").slideUp(200);
        } else {
            element.addClass("open");
            element.children("ul").slideDown(200);
            element.siblings("li").children("ul").slideUp();
            element.siblings("li").removeClass("open");
            element.siblings("li").find("li").removeClass("open");
            element.siblings("li").find("ul").slideUp();
        }
    });
    /* 1.01 Sticky Menu  */

    function stickyHeader() {
        var mainheader = $(".rt-sticky"),
            height = mainheader.outerHeight(),
            scroll = $(document).scrollTop();
        $(window).on("load", function () {
            if ($(document).scrollTop() > height) {
                if (mainheader.hasClass("rt-sticky-active")) {
                    mainheader.removeClass("rt-sticky-active");
                } else {
                    mainheader.addClass("rt-sticky-active");
                }
            }
        });
        $(window).on("scroll", function () {
            var scrolled = $(document).scrollTop(),
                header = $(".rt-sticky-active");

            if (scrolled > scroll) {
                header.addClass("sticky");
            } else {
                header.removeClass("sticky");
            }

            if (scrolled === 0) {
                mainheader.removeClass("rt-sticky-active");
            } else {
                mainheader.addClass("rt-sticky-active");
            }

            scroll = $(document).scrollTop();
        });
    }

    if ($(window).width() > 991.98) {
        stickyHeader();
    } // menu menu active link

    /* 1.02 Main Menu  */

    $(".main-menu ul li").on("click", function () {
        $(".main-menu ul li").removeClass("active");
        $(this).addClass("active");
    }); // mobile menu click

    /* 1.03 Mobile Menu */

    $(".menu-click").on("click", function () {
        $(".main-menu").toggleClass("active-mobile-menu");
        $(".rt-mobile-menu-overlay").toggleClass("active");
        return false;
    });
    $(".rt-mobile-menu-close, .rt-mobile-menu-overlay").on(
        "click",
        function () {
            $(".main-menu").removeClass("active-mobile-menu");
            $(".rt-mobile-menu-overlay").removeClass("active");
            return false;
        }
    ); // counter active

    /* 1.04 Counter */

    $(".counter").counterUp({
        delay: 10,
        time: 1000,
    });

    /* 1.07 Scrollup */
    $.scrollUp({
        scrollText: '<i class="fa fa-angle-up pb-1"></i>',
    }); // select 2 active

    $(".toggle-filter-sidebar").on("click", function () {
        $(".sidebar-widget-overlay, .jobsidebar").toggleClass("active");
    });
    $(".sidebar-widget-overlay, .close-me").on("click", function () {
        $(".sidebar-widget-overlay, .jobsidebar").removeClass("active");
    });
    /* 1.1.1 Hide Tag */

    $(".close-tag").on("click", function () {
        $(this).parent(".single-tag").hide();
    }); // advanced fillter

    /* 1.1.2 Advanced Filter */

    $(".job-filter-overlay").on("click", function () {
        $(".jobsearchBox").removeClass("active-adf");
        $(".job-filter-overlay").removeClass("active");
        $(".advance-hidden-filter-menu").slideUp(300);
        $("body").removeClass("body-no-scrolling");
    }); // custom scroll

    /* 1.1.3 Custom Scroll */

    var getToggleClass = document.getElementById("togglclass1");
    var toggleSidebar = document.getElementById("toggoleSidebar");
    var productCloumnClass = document.getElementsByClassName("condition_class");
    $(".toggole-colum-classes").on("click", function () {
        $(toggleSidebar).toggleClass("d-none");

        if (!toggleSidebar.classList.contains("d-none")) {
            getToggleClass.classList.add("col-lg-8");
            getToggleClass.classList.remove("col-xl-12");
        } else {
            getToggleClass.classList.add("col-xl-12");
            getToggleClass.classList.remove("col-lg-8");
        }

        if (getToggleClass.classList.contains("col-lg-8")) {
            $(productCloumnClass).removeClass("col-xl-4");
        } else {
            $(productCloumnClass).addClass("col-xl-4");
        }
    }); // menu active classes

    $(".togglepass").on("click", function () {
        var x = document.getElementById("myInput");

        if (x.type === "password") {
            x.type = "text";
        } else {
            x.type = "password";
        }
    }); // toggle password

    $(".togglepass2").on("click", function () {
        var y = document.getElementById("myInput2");

        if (y.type === "password") {
            y.type = "text";
        } else {
            y.type = "password";
        }
    }); //sidbear toggle

    $(".sidebar-open-nav").on("click", function () {
        $(".d-sidebar, .d-page-content ").toggleClass("acitve");
        $(".sidebar-overlay").toggleClass("active");
    });

    $(".close-sidebar").on("click", function () {
        $(".d-sidebar, .d-page-content ").toggleClass("acitve");
        $(".sidebar-overlay").toggleClass("active");
    });

    $(".sidebar-overlay").on("click", function () {
        $(".d-sidebar, .d-page-content ").toggleClass("acitve");
        $(".sidebar-overlay").toggleClass("active");
    });

    // pricing toggle

    $("#flexSwitchCheckDefault").on("change", function () {
        $("body").toggleClass("price-toggole");
    }); // notifications

    var $notification = $(".notification-icon");
    $(document).mouseup(function (e) {
        if (
            !$notification.is(e.target) && // if the target of the click isn't the container...
            $notification.has(e.target).length === 0
        ) {
            // ... nor a descendant of the container
            $notification.removeClass("notification-visiable");
        }
    });
    $(".notification-icon").on("click", function (event) {
        event.preventDefault();
        $notification.toggleClass("notification-visiable");
    }); //end notification
    // switch profile

    var $profileSwitch = $(".switch-profile");

    $(document).mouseup(function (e) {
        if (
            !$profileSwitch.is(e.target) && // if the target of the click isn't the container...
            $profileSwitch.has(e.target).length === 0
        ) {
            // ... nor a descendant of the container
            $profileSwitch.removeClass("profile-visiable");
        }
    });

    $(".switch-profile").on("click", function (event) {
        event.preventDefault();
        $profileSwitch.toggleClass("profile-visiable");
    }); // 6. input type changer

    // aos initialize
    AOS.init({
        disable: "mobile",
        easing: 'ease-in-out-sine',
        once: true
    });    
    // testimonial slider
    if ($(".testimonail_active").length > 0) {
        var _$$slick;

        $(".testimonail_active").slick(
            ((_$$slick = {
                slidesToShow: 3,
                infinite: true,
                slidesToScroll: 2,
                dots: true,
                prevArrow: $(".slickprev2"),
                nextArrow: $(".slicknext2"),
            }),
            _defineProperty(
                _$$slick,
                "prevArrow",
                '<button aria-label="Arrow Left" title="Arrow Left" class="slide-arrow prev-arrow"></button>'
            ),
            _defineProperty(
                _$$slick,
                "nextArrow",
                '<button aria-label="Arrow Right" title="Arrow Right" class="slide-arrow next-arrow"></button>'
            ),
            _defineProperty(_$$slick, "responsive", [
                {
                    breakpoint: 1199,
                    settings: {
                        slidesToShow: 2,
                        slidesToScroll: 1,
                    },
                },
                {
                    breakpoint: 768,
                    settings: {
                        slidesToShow: 1,
                        slidesToScroll: 1,
                    },
                },
                {
                    breakpoint: 479,
                    settings: {
                        slidesToShow: 1,
                        slidesToScroll: 1,
                    },
                },
                {
                    breakpoint: 320,
                    settings: {
                        slidesToShow: 1,
                        slidesToScroll: 1,
                    },
                },
                {
                    breakpoint: 210,
                    settings: {
                        slidesToShow: 1,
                        slidesToScroll: 1,
                    },
                },
            ]),
            _$$slick)
        );
    }
})(jQuery);

var hideMenuBtn = document.querySelector(".hide-menu-btn");
var hideMenu = document.getElementById("progressbar");

if (hideMenuBtn) {
    hideMenuBtn.addEventListener("click", function () {
        hideMenu.classList.add("hide-menu");
    });
}
