(function($) {
    "use strict";

    var SifencyFaqAccordion = function($scope, $) {
        var $accordion = $scope.find('.sifency-faq-accordion');
        if (!$accordion.length) {
            return;
        }

        var $items = $accordion.find('.sifency-faq-item');
        var allowMultiple = $accordion.data('allow-multiple') === 'yes';

        $items.each(function() {
            var $item = $(this);
            var $title = $item.find('.sifency-faq-question');
            var $content = $item.find('.sifency-faq-answer');

            $title.on('click', function() {
                var $currentItem = $(this).closest('.sifency-faq-item');

                if (!allowMultiple) {
                    $currentItem.siblings('.sifency-faq-item--active').removeClass('sifency-faq-item--active').find('.sifency-faq-answer').slideUp(300);
                }

                $currentItem.toggleClass('sifency-faq-item--active');
                $content.slideToggle(300);
            });
        });
    };

    $(window).on('elementor/frontend/init', function() {
        elementorFrontend.hooks.addAction('frontend/element_ready/sifency-digital-product-faq.default', SifencyFaqAccordion);
    });

})(jQuery);

(function($) {
    "use strict";

    var SifencyVideoPlayer = function($scope, $) {
        var $videoWrapper = $scope.find('.sifency-video-wrapper');
        if (!$videoWrapper.length) {
            return;
        }

        $videoWrapper.on('click', '.sifency-video-play-button', function(e) {
            e.preventDefault();
            var $button = $(this);
            var $wrapper = $button.closest('.sifency-video-wrapper');
            var iframeHtml = $wrapper.find('script[type="text/html"]').html();

            $wrapper.html(iframeHtml);
        });
    };

    $(window).on('elementor/frontend/init', function() {
        elementorFrontend.hooks.addAction('frontend/element_ready/sifency-digital-product-video.default', SifencyVideoPlayer);
    });

})(jQuery);