(function($) {
    var SifencyTypewriterHandler = function($scope, $) {
        var $wrapper = $scope.find('.sifency-typewriter-wrapper');
        var $target = $scope.find('.sifency-typed-string');
        var config = $wrapper.data('settings');
        if (!config || !$target.length) {
            return;
        }
        if (typeof Typed === 'undefined') {
            console.warn('Sifency Addons: Typed.js is missing.');
            return;
        }
        if ($target.data('typed-instance')) {
            $target.data('typed-instance').destroy();
        }

        var typed = new Typed($target[0], config);
        $target.data('typed-instance', typed);
    };

    $(window).on('elementor/frontend/init', function() {
        elementorFrontend.hooks.addAction('frontend/element_ready/sifency_typewriter.default', SifencyTypewriterHandler);
    });

})(jQuery);