/**
 * @constructor
**/
function Chatter(id) {
    /** @const @type {string} */
    this.id = id;
    /** @type {string} */
    this.name;
    /** @type {boolean} */
    this.deleted;
    /** @type {string} */
    this.status;
    /** @type {string} */
    this.realName;
    /** @type {string} */
    this.goal;
    /** @type {string} */
    this.phone;
    /** @type {boolean} */
    this.presence;
    /** @type {string} */
    this.email;
    /** @type {string} */
    this.firstName;
    /** @type {string} */
    this.lastName;
    /** @type {!Object.<string, Room>} */
    this.channels = {};
    /** @type {SelfPreferences|null} */
    this.prefs = null;
    /** @type {boolean} */
    this.isBot;
    /** @type {PrivateMessageRoom|null} */
    this.privateRoom = null;
    /** @type {number} */
    this.version = 0;
};

Chatter.prototype.toStatic = function(t) {
    return t >= this.version ? null : {
        "id": this.id
        ,"name": this.name
        ,"deleted": this.deleted
        ,"status": this.status
        ,"real_name": this.realName
        ,"isPresent": this.presence
        ,"isBot": this.isBot
        ,"email": this.email
        ,"phone": this.phone
        ,"goal": this.goal
        ,"first_name": this.firstName
        ,"last_name": this.lastName
    };
};

/**
 * @param {*} userData
 * @param {number} t
**/
Chatter.prototype.update = function(userData, t) {
    if (userData["name"] !== undefined) this.name = userData["name"];
    if (userData["deleted"] !== undefined) this.deleted = userData["deleted"];
    if (userData["status"] !== undefined) this.status = userData["status"];
    if (userData["goal"] !== undefined) this.goal = userData["goal"];
    if (userData["phone"] !== undefined) this.phone = userData["phone"];
    if (userData["email"] !== undefined) this.email = userData["email"];
    if (userData["first_name"] !== undefined) this.firstName = userData["first_name"];
    if (userData["last_name"] !== undefined) this.lastName = userData["last_name"];
    if (userData["real_name"] !== undefined) this.realName = userData["real_name"];
    if (userData["isPresent"] !== undefined) this.presence = userData["isPresent"];
    if (userData["isBot"]) this.isBot = userData["isBot"];
    this.version = Math.max(this.version, t);
};

Chatter.prototype.getSmallIcon = function() {
    return "api/avatar?user=" +encodeURIComponent(this.id);
};

Chatter.prototype.getLargeIcon = function() {
    return "api/avatar?size=l&user=" +encodeURIComponent(this.id);
};

Chatter.prototype.getName = function() {
    return this.name || this.realName || this.firstName || this.lastName;
};

/** @suppress {undefinedVars,checkTypes} */
(function() {
    if (typeof module !== "undefined") {
        module.exports.Chatter = Chatter;
    }
})();

