"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var ClassicRenderer_1 = require("./ClassicRenderer");
/**
 * The rating renderer adds two rating buttons (like, dislike)
 * after each system conversation output,
 * to allow users to give feedback.
 * Based on the content centric renderer.
 */
var RatingRenderer = /** @class */ (function (_super) {
    __extends(RatingRenderer, _super);
    function RatingRenderer(content, suggest) {
        var _this = _super.call(this, content, suggest) || this;
        _this.qualifier = null;
        _this.behaviour = function (r, t) { return _this.defaultBehaviour(r, t); };
        return _this;
    }
    RatingRenderer.prototype.init = function (channelId) {
        _super.prototype.init.call(this, channelId);
    };
    /**
     * @inheritDoc
     */
    RatingRenderer.prototype.renderElement = function (renderable, containerType) {
        return this.behaviour(renderable, containerType);
    };
    RatingRenderer.getQualifier = function (renderable) {
        return (renderable["spec"] !== undefined) ? renderable["spec"].qualifier : null;
    };
    RatingRenderer.getType = function (renderable) {
        return (renderable["spec"] !== undefined) ? renderable["spec"].type : null;
    };
    RatingRenderer.getPosition = function (renderable) {
        return (renderable["spec"] !== undefined) ? renderable["spec"].position : null;
    };
    RatingRenderer.prototype.defaultBehaviour = function (renderable, containerType) {
        if (!containerType) {
            this.qualifier = RatingRenderer.getQualifier(renderable) || this.qualifier;
        }
        var type = RatingRenderer.getType(renderable);
        var position = RatingRenderer.getPosition(renderable);
        var appendRating = false;
        if (type === "container" && position === "left" && this.qualifier !== null) {
            appendRating = true;
        }
        return _super.prototype.renderElement.call(this, renderable, containerType, appendRating);
    };
    return RatingRenderer;
}(ClassicRenderer_1.ClassicRenderer));
exports.RatingRenderer = RatingRenderer;
//# sourceMappingURL=RatingRenderer.js.map