"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Service = exports.Silent = exports.Talker = exports.ConferenceSession = exports.Participant = exports.Publisher = void 0;
const ts_generic_collections_linq_1 = require("ts-generic-collections-linq");
const RESTService_1 = require("../../connection/RESTService");
/// <summary>
/// Define a participant to a conference
///
/// The Id of the particpant is NOT AT ALL related to the Id of a <see cref="Contact"/>
///
/// The Jid_im of the participant can be compared to the Jid_im of a <see cref="Contact"/>
/// </summary>
/**
 * @class
 * @name Participant
 * @public
 * @description
 *      This class Define a participant to a conference. <br>
 */
class Participant {
    constructor(id) {
        this._id = id;
    }
    /**
     *
     *  @name id
     * @return {string}
     * @description
     *    get the id of the participant. The Id of the particpant is NOT AT ALL related to the Id of a Contact.
     */
    get id() {
        return this._id;
    }
    /**
     *
     *  @name id
     * @param {string} value
     * @description
     *    set the id of the participant. The Id of the particpant is NOT AT ALL related to the Id of a Contact.
     */
    set id(value) {
        this._id = value;
    }
    get jid_im() {
        return this._jid_im;
    }
    set jid_im(value) {
        this._jid_im = value;
    }
    get phoneNumber() {
        return this._phoneNumber;
    }
    set phoneNumber(value) {
        this._phoneNumber = value;
    }
    get moderator() {
        return this._moderator;
    }
    set moderator(value) {
        this._moderator = value;
    }
    get muted() {
        return this._muted;
    }
    set muted(value) {
        this._muted = value;
    }
    get hold() {
        return this._hold;
    }
    set hold(value) {
        this._hold = value;
    }
    get connected() {
        return this._connected;
    }
    set connected(value) {
        this._connected = value;
    }
    get contact() {
        return this._contact;
    }
    set contact(value) {
        this._contact = value;
    }
    get talkingTime() {
        return this._talkingTime;
    }
    set talkingTime(value) {
        this._talkingTime = value;
    }
    get talking() {
        return this._talking;
    }
    set talking(value) {
        this._talking = value;
    }
    get microphone() {
        return this._microphone;
    }
    set microphone(value) {
        this._microphone = value;
    }
    get delegateCapability() {
        return this._delegateCapability;
    }
    set delegateCapability(value) {
        this._delegateCapability = value;
    }
    get associatedUserId() {
        return this._associatedUserId;
    }
    set associatedUserId(value) {
        this._associatedUserId = value;
    }
    get associatedGroupName() {
        return this._associatedGroupName;
    }
    set associatedGroupName(value) {
        this._associatedGroupName = value;
    }
    get isOwner() {
        return this._isOwner;
    }
    set isOwner(value) {
        this._isOwner = value;
    }
    /// <summary>
    /// Serialize this object to String
    /// </summary>
    /// <returns><see cref="String"/> as serialization result</returns>
    ToString() {
        let tab = "- ";
        let result = "";
        // let result = String.Format($"Id:[{Id}] {tab}Jid_im:[{Jid_im}] {tab}PhoneNumber:[{PhoneNumber}] {tab}Moderator:[{Moderator}] {tab}Muted:[{Muted}] {tab}Hold:[{Hold}] {tab}Connected:[{Connected}]");
        return `Id:[{Id}] {tab}Jid_im:[{Jid_im}] {tab}PhoneNumber:[{PhoneNumber}] {tab}Moderator:[{Moderator}] {tab}Muted:[{Muted}] {tab}Hold:[{Hold}] {tab}Connected:[{Connected}]`;
    }
}
exports.Participant = Participant;
/**
 * @class
 * @name Talker
 * @public
 * @description
 *      This class Define a participant talking in a conference. <br>
 */
class Talker {
    constructor(participant) {
        this._participant = participant;
    }
    get participant() {
        return this._participant;
    }
    set participant(value) {
        this._participant = value;
    }
    get talkingTime() {
        return this._talkingTime;
    }
    set talkingTime(value) {
        this._talkingTime = value;
    }
    get publisher() {
        return this._publisher;
    }
    set publisher(value) {
        this._publisher = value;
    }
    get simulcast() {
        return this._simulcast;
    }
    set simulcast(value) {
        this._simulcast = value;
    }
    ToString() {
        let tab = "- ";
        let result = "";
        // let result = String.Format($"Id:[{Id}] {tab}Jid_im:[{Jid_im}] {tab}PhoneNumber:[{PhoneNumber}] {tab}Moderator:[{Moderator}] {tab}Muted:[{Muted}] {tab}Hold:[{Hold}] {tab}Connected:[{Connected}]");
        return `participant Id:[{_participant.id}] {tab}Jid_im:[{Jid_im}] {tab}PhoneNumber:[{PhoneNumber}] {tab}Moderator:[{Moderator}] {tab}Muted:[{Muted}] {tab}Hold:[{Hold}] {tab}Connected:[{Connected}]`;
    }
}
exports.Talker = Talker;
/**
 * @class
 * @name Silent
 * @public
 * @description
 *      This class Define a participant talking in a conference. <br>
 */
class Silent {
    constructor(participant) {
        this._participant = participant;
    }
    get participant() {
        return this._participant;
    }
    set participant(value) {
        this._participant = value;
    }
    get talkingTime() {
        return this._talkingTime;
    }
    set talkingTime(value) {
        this._talkingTime = value;
    }
    get publisher() {
        return this._publisher;
    }
    set publisher(value) {
        this._publisher = value;
    }
    get simulcast() {
        return this._simulcast;
    }
    set simulcast(value) {
        this._simulcast = value;
    }
    ToString() {
        let tab = "- ";
        let result = "";
        // let result = String.Format($"Id:[{Id}] {tab}Jid_im:[{Jid_im}] {tab}PhoneNumber:[{PhoneNumber}] {tab}Moderator:[{Moderator}] {tab}Muted:[{Muted}] {tab}Hold:[{Hold}] {tab}Connected:[{Connected}]");
        return `participant Id:[{_participant.id}] {tab}Jid_im:[{Jid_im}] {tab}PhoneNumber:[{PhoneNumber}] {tab}Moderator:[{Moderator}] {tab}Muted:[{Muted}] {tab}Hold:[{Hold}] {tab}Connected:[{Connected}]`;
    }
}
exports.Silent = Silent;
/// <summary>
/// Define a publisher to a conference
///
/// The Id of the particpant is NOT AT ALL related to the Id of a <see cref="Contact"/>
///
/// The Jid_im of the participant can be compared to the Jid_im of a <see cref="Contact"/>
/// </summary>
class Publisher {
    get simulcast() {
        return this._simulcast;
    }
    set simulcast(value) {
        this._simulcast = value;
    }
    get participant() {
        return this._participant;
    }
    set participant(value) {
        this._participant = value;
    }
    //    private _contact: Contact;
    constructor(id) {
        /// <summary>
        /// <see cref="T:List{String}"/> - List of media used by the publisher - can be "sharing" or "video"
        /// </summary>
        this._media = new ts_generic_collections_linq_1.List(); // { get; set; }
        this.id = id;
    }
    get id() {
        return this._id;
    }
    set id(value) {
        this._id = value;
    }
    get jid_im() {
        return this._jid_im;
    }
    set jid_im(value) {
        this._jid_im = value;
    }
    get media() {
        return this._media;
    }
    set media(value) {
        this._media = value;
    }
    /*
        get contact(): Contact {
            return this._contact;
        }
    
        set contact(value: Contact) {
            this._contact = value;
        }
    */
    /// <summary>
    /// Serialize this object to String
    /// </summary>
    /// <returns><see cref="String"/> as serialization result</returns>
    ToString() {
        let tab = "- ";
        let result = `Id:[{Id}] {tab}Jid_im:[{Jid_im}] {tab}MediaType:[{String.Join(", ", Media.ToArray())}]`;
        // let result = String.Format($"Id:[{Id}] {tab}Jid_im:[{Jid_im}] {tab}MediaType:[{String.Join(", ", Media.ToArray())}]");
        return result;
    }
}
exports.Publisher = Publisher;
class Service {
    get serviceId() {
        return this._serviceId;
    }
    set serviceId(value) {
        this._serviceId = value;
    }
    get serviceType() {
        return this._serviceType;
    }
    set serviceType(value) {
        this._serviceType = value;
    }
    constructor() { }
}
exports.Service = Service;
/// <summary>
/// To describe a Conference in progress in a Bubble
///
/// Id of the Conference is related to a Bubble using Bubble.ConfEndpoints.ConfEndpointId
/// </summary>
class ConferenceSession {
    get bubble() {
        return this._bubble;
    }
    set bubble(value) {
        this._bubble = value;
    }
    get ownerJidIm() {
        return this._ownerJidIm;
    }
    set ownerJidIm(value) {
        this._ownerJidIm = value;
    }
    get services() {
        return this._services;
    }
    set services(value) {
        this._services = value;
    }
    constructor(id, participants = new ts_generic_collections_linq_1.List(), mediaType = RESTService_1.MEDIATYPE.WEBRTC) {
        /// <summary>
        /// <see cref="T:List{Participant}"/> - List of <see cref="Participant"/>
        /// </summary>
        this._participants = new ts_generic_collections_linq_1.List(); // { get; set; }
        /// <summary>
        /// <see cref="T:List{Publisher}"/> - List of <see cref="Publisher"/>
        /// </summary>
        this._publishers = new ts_generic_collections_linq_1.List(); // { get; set; }
        /// <summary>
        /// <see cref="T:List{String}"/> - List of talkers (using the ID of the participant)
        /// </summary>
        this._talkers = new ts_generic_collections_linq_1.List(); //{ get; set; }
        this._silents = new ts_generic_collections_linq_1.List(); //{ get; set; }
        this._services = new ts_generic_collections_linq_1.List();
        let that = this;
        that._id = id;
        that._participants = participants;
        that._mediaType = mediaType;
    }
    get id() {
        return this._id;
    }
    set id(value) {
        this._id = value;
    }
    get active() {
        return this._active;
    }
    set active(value) {
        this._active = value;
    }
    get muted() {
        return this._muted;
    }
    set muted(value) {
        this._muted = value;
    }
    get locked() {
        return this._locked;
    }
    set locked(value) {
        this._locked = value;
    }
    get recordStarted() {
        return this._recordStarted;
    }
    set recordStarted(value) {
        this._recordStarted = value;
    }
    get recordingState() {
        return this._recordingState;
    }
    set recordingState(value) {
        this._recordingState = value;
    }
    get recordingUserId() {
        return this._recordingUserId;
    }
    set recordingUserId(value) {
        this._recordingUserId = value;
    }
    get participantCount() {
        return this._participantCount;
    }
    set participantCount(value) {
        this._participantCount = value;
    }
    get mediaType() {
        return this._mediaType;
    }
    set mediaType(value) {
        this._mediaType = value;
    }
    get participants() {
        return this._participants;
    }
    set participants(value) {
        this._participants = value;
    }
    get publishers() {
        return this._publishers;
    }
    set publishers(value) {
        this._publishers = value;
    }
    get talkers() {
        return this._talkers;
    }
    set talkers(value) {
        this._talkers = value;
    }
    get silents() {
        return this._silents;
    }
    set silents(value) {
        this._silents = value;
    }
    get talkerActive() {
        return this._talkerActive;
    }
    set talkerActive(value) {
        this._talkerActive = value;
    }
    /*
        get participantCount(): number {
            return this._participantCount;
        }
    
        set participantCount(value: number) {
            this._participantCount = value;
        }
    
        get publisherCount(): number {
            return this._publisherCount;
        }
    
        set publisherCount(value: number) {
            this._publisherCount = value;
        }
    // */
    get reason() {
        return this._reason;
    }
    set reason(value) {
        this._reason = value;
    }
    get replacedByConference() {
        return this._replacedByConference;
    }
    set replacedByConference(value) {
        this._replaceConference = null; // can not replace a conf if this conf is replaced.
        this._replacedByConference = value;
    }
    get replaceConference() {
        return this._replaceConference;
    }
    set replaceConference(conference) {
        let that = this;
        that._replaceConference = conference;
        /*that.participants = conference.participants;
        that.publishers = conference.publishers ;
        that.talkers = conference.talkers ;
        that.silents = conference.silents ;
        // */
        conference.reset();
        conference.active = false;
        conference.replacedByConference = that;
    }
    /// <summary>
    /// Serialize this object to String
    /// </summary>
    /// <returns><see cref="String"/> as serialization result</returns>
    ToString() {
        let that = this;
        let tab = "\r\n\t";
        let participantsStr = "";
        if (that._participants != null) {
            /*
                            foreach(Participant participant in Participants)
                            {
                                if (String.IsNullOrEmpty(participantsStr))
                                    participantsStr += String.Format($" [{participant.ToString()}]");
                                else
                                    participantsStr += String.Format($"{tab}\t[{participant.ToString()}] ");
                            }
            */
        }
        let publishersStr = "";
        if (that._publishers != null) {
            /* foreach (Publisher publisher in Publishers)
             {
                 if (String.IsNullOrEmpty(publishersStr))
                     publishersStr += String.Format($" [{publisher.ToString()}]");
                 else
                     publishersStr += String.Format($"{tab}\t[{publisher.ToString()}] ");
             }*/
        }
        let talkersStr = "";
        let result = "" + this.id;
        /*
                    if (Talkers != null)
                        talkersStr = (Talkers.Count > 0) ? " [" + String.Join("], [", Talkers.ToArray()) + "] " : "";

                    let result = String.Format($"{tab}Id:[{Id}] {tab}Active:[{Active}] {tab}Muted:[{Muted}] {tab}Locked:[{Locked}] {tab}RecordStarted:[{RecordStarted}] {tab}MediaType:[{MediaType}]" +
                        $"  {tab}Participants:[{participantsStr}]" +
                        $"  {tab}Publishers:[{publishersStr}]" +
                        $"  {tab}Talkers:[{talkersStr}]" );
        */
        //result = this;
        //result = JSON.stringify(this);
        return result;
    }
    reset() {
        let that = this;
        /*
                that._participants = new List<Participant>(); // { get; set; }
                that._publishers = new List<Publisher>(); // { get; set; }
                that._talkers = new List<Talker>(); //{ get; set; }
                that._silents = new List<Silent>(); //{ get; set; }
        // */
        that._participants.clear();
        that._publishers.clear();
        that._talkers.clear();
        that._silents.clear();
        /*that._active = false;
        that._locked = false;
        that._talkerActive = false;
        // */
    }
}
exports.ConferenceSession = ConferenceSession;
module.exports.Talker = Talker;
module.exports.Silent = Silent;
module.exports.Publisher = Publisher;
module.exports.Participant = Participant;
module.exports.Service = Service;
module.exports.ConferenceSession = ConferenceSession;
//# sourceMappingURL=ConferenceSession.js.map