define('modules/smart-assistant/views/stream/notes/smart-response', ['views/stream/note'], function (NoteView) {

    return NoteView.extend({

        templateContent: '' +
            '<div style="background: #f5f0ff; padding: 8px 12px; border-radius: 8px; direction: rtl; text-align: right; font-size: 13px;">' +
            '<span class="fas fa-robot" style="color: #5c6bc0; margin-left: 6px;"></span>' +
            '{{{formattedPost}}}' +
            '{{#if actionCount}}' +
            '<span class="badge" style="background: #ff9800; margin-right: 8px;">{{actionCount}} פעולות</span>' +
            '{{/if}}' +
            '</div>',

        data: function () {
            var data = NoteView.prototype.data.call(this);
            var noteData = this.model.get('data') || {};

            data.formattedPost = this.formatPost(this.model.get('post'));
            data.actionCount = (noteData.actions || []).length;

            return data;
        },

        formatPost: function (text) {
            if (!text) return '';
            text = this.getHelper().escapeString(text);
            text = text.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
            text = text.replace(/\n/g, '<br>');
            return text;
        },
    });
});
