define('modules/smart-assistant/views/site/navbar', ['views/site/navbar'], function (NavbarView) {

    return NavbarView.extend({

        afterRender: function () {
            NavbarView.prototype.afterRender.call(this);
            this._initFloatingChat();
        },

        _initFloatingChat: function () {
            if (this._floatingChatInitialized) return;
            this._floatingChatInitialized = true;

            var $container = $('body > .smart-assistant-fab-container');
            if ($container.length === 0) {
                $container = $('<div class="smart-assistant-fab-container"></div>');
                $('body').append($container);
            }

            this.createView('floatingChat', 'modules/smart-assistant/views/floating-chat', {
                el: '.smart-assistant-fab-container',
            }, function (view) {
                view.render();
            });
        },

        onRemove: function () {
            $('body > .smart-assistant-fab-container').remove();
            NavbarView.prototype.onRemove.call(this);
        },
    });
});
