"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var WebinarsService_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebinarsService = void 0;
const ErrorManager_1 = require("../common/ErrorManager");
const Utils_1 = require("../common/Utils");
const PubSub = require("pubsub-js");
const GenericService_1 = require("./GenericService");
const webinar_1 = require("../common/models/webinar");
const webinarEventHandler_1 = require("../connection/XMPPServiceHandler/webinarEventHandler");
const LOG_ID = "WEBINAR/SVCE - ";
const API_ID = "API_CALL - ";
let WebinarsService = WebinarsService_1 = 
/**
 * @module
 * @name WebinarsService
 * @version 2.42.0-lts.4 - Documentation generated on 2026/04/24T11:38:22.926Z
 * @public
 * @description
 *      This service manages .<br>
 */
class WebinarsService extends GenericService_1.GenericService {
    static getClassName() { return 'WebinarsService'; }
    getClassName() { return WebinarsService_1.getClassName(); }
    static getAccessorName() { return 'webinars'; }
    getAccessorName() { return WebinarsService_1.getAccessorName(); }
    constructor(_core, _eventEmitter, _http, _logger, _startConfig) {
        super(_logger, LOG_ID, _eventEmitter);
        this._protocol = null;
        this._host = null;
        this._port = null;
        //region Events
        this.LIST_EVENT_TYPE = {
            ADD: { code: 0, label: "ADD" },
            UPDATE: { code: 1, label: "UPDATE" },
            REMOVE: { code: 2, label: "REMOVE" },
            DELETE: { code: 3, label: "DELETE" },
            SUBSCRIBE: { code: 4, label: "SUBSCRIBE" },
            UNSUBSCRIBE: { code: 5, label: "UNSUBSCRIBE" },
            CREATE: { code: 6, label: "CREATE" }
        };
        this.setLogLevels(this);
        this._xmpp = null;
        this._rest = null;
        this._s2s = null;
        this._options = {};
        this._useXMPP = false;
        this._useS2S = false;
        this._eventEmitter = _eventEmitter;
        this._logger = _logger;
        this._startConfig = _startConfig;
        this._protocol = _http.protocol;
        this._host = _http.host;
        this._port = _http.port;
        this._core = _core;
        this.avatarDomain = this._host.split(".").length === 2 ? this._protocol + "://cdn." + this._host + ":" + this._port : this._protocol + "://" + this._host + ":" + this._port;
        this._eventEmitter.on("evt_internal_createwebinar", this.onCreateWebinar.bind(this));
        this._eventEmitter.on("evt_internal_deletewebinar", this.onDeleteWebinar.bind(this));
    }
    start(_options) {
        let that = this;
        that.initStartDate();
        return new Promise(async function (resolve, reject) {
            try {
                that._xmpp = that._core._xmpp;
                that._rest = that._core._rest;
                that._options = _options;
                that._s2s = that._core._s2s;
                that._useXMPP = that._options.useXMPP;
                that._useS2S = that._options.useS2S;
                that._webinars = [];
                that.attachHandlers();
                that.setStarted();
                resolve(undefined);
            }
            catch (err) {
                return reject();
            }
        });
    }
    stop() {
        let that = this;
        return new Promise(function (resolve, reject) {
            try {
                that._xmpp = null;
                that._rest = null;
                if (that.webinarHandlerToken) {
                    that.webinarHandlerToken.forEach((token) => PubSub.unsubscribe(token));
                }
                that.webinarHandlerToken = [];
                that._webinars = null;
                that.setStopped();
                resolve(undefined);
            }
            catch (err) {
                return reject(err);
            }
        });
    }
    async init(useRestAtStartup) {
        let that = this;
        that.setInitialized();
    }
    attachHandlers() {
        let that = this;
        that.webinarEventHandler = new webinarEventHandler_1.WebinarEventHandler(that._xmpp, that);
        that.webinarHandlerToken = [
            PubSub.subscribe(that._xmpp.hash + "." + that.webinarEventHandler.MESSAGE_MANAGEMENT, that.webinarEventHandler.onManagementMessageReceived.bind(that.webinarEventHandler)),
            PubSub.subscribe(that._xmpp.hash + "." + that.webinarEventHandler.MESSAGE_ERROR, that.webinarEventHandler.onErrorMessageReceived.bind(that.webinarEventHandler))
        ];
    }
    async onCreateWebinar(webinarInfo) {
        let that = this;
        let webinarId = webinarInfo.id;
        that._logger.log(that.DEBUG, LOG_ID + "(onCreateWebinar) webinarId : ", webinarId);
        //that._logger.log(that.INTERNAL, LOG_ID + "(onAddToWebinar) this._webinars : ", this._webinars);
        // Get webinars from cache
        //let webinar = this.getWebinarFromCache(webinarId);
        // Get webinars from server
        await that.getWebinarData(webinarId).then((newWebinar) => {
            // Handle webinars creation
            if (newWebinar) {
                let webinarsObj = that.addOrUpdateWebinarToCache(newWebinar);
                //that._logger.log(that.DEBUG, LOG_ID + "(onCreateWebinar) evt_internal_webinarupdated : ", webinarsObj.id);
                that._eventEmitter.emit("evt_internal_webinarupdated", {
                    'id': webinarsObj.id,
                    "kind": that.LIST_EVENT_TYPE.ADD.code,
                    "label": that.LIST_EVENT_TYPE.ADD.label,
                    "webinar": webinarsObj
                });
            }
        }).catch(err => {
            that._logger.log(that.WARN, LOG_ID + "(onCreateWebinar) getWebinarData error : ", err);
        });
    }
    async onDeleteWebinar(webinarsInfo) {
        let that = this;
        let webinarsId = webinarsInfo.id;
        that._logger.log(that.DEBUG, LOG_ID + "(onDeleteWebinar) webinarsId : ", webinarsId);
        let webinarsDeleted = await that.removeWebinarFromCache(webinarsId);
        let webinarsIdDeleted = webinarsDeleted ? webinarsDeleted.id : webinarsInfo.id;
        that._eventEmitter.emit("evt_internal_webinarupdated", { 'id': webinarsIdDeleted,
            "kind": that.LIST_EVENT_TYPE.DELETE.code,
            "label": that.LIST_EVENT_TYPE.DELETE.label,
            "webinar": webinarsDeleted
        });
    }
    //endregion Events
    //region Webinars Utils
    /**
     * @name getWebinarFromCache
     * @private
     * @category Webinars Utils
     * @param {string} webinarId
     * @description
     *      GET A CHANNEL FROM CACHE <br>
     */
    getWebinarFromCache(webinarId) {
        let webinarsFound = null;
        let that = this;
        that._logger.log(that.INTERNAL, LOG_ID + "(getWebinarFromCache) search id : ", webinarId);
        if (this._webinars) {
            let webinarsFoundindex = this._webinars.findIndex((webinars) => {
                return webinars.id === webinarId;
            });
            if (webinarsFoundindex != -1) {
                that._logger.log(that.INTERNAL, LOG_ID + "(getWebinarFromCache) webinars found : ", this._webinars[webinarsFoundindex], " with id : ", webinarId);
                return this._webinars[webinarsFoundindex];
            }
        }
        that._logger.log(that.INTERNAL, LOG_ID + "(getWebinarFromCache) webinars found : ", webinarsFound, " with id : ", webinarId);
        return webinarsFound;
    }
    addOrUpdateWebinarToCache(webinar) {
        let that = this;
        let webinarsObj = webinar_1.Webinar.createFromData(webinar, that._rest.http.serverURL);
        let webinarsFoundindex = that._webinars.findIndex((webinarsIter) => {
            return webinarsIter.id === webinar.id;
        });
        if (webinarsFoundindex != -1) {
            that._logger.log(that.INTERNAL, LOG_ID + "(addOrUpdateWebinarToCache) update in cache with webinar : ", webinar, ", at webinarsFoundindex : ", webinarsFoundindex);
            that._logger.log(that.INTERNAL, LOG_ID + "(addOrUpdateWebinarToCache) in update this._webinars : ", that._webinars);
            webinar_1.Webinar.updateFromData(that._webinars[webinarsFoundindex], webinar);
            webinarsObj = that._webinars[webinarsFoundindex];
        }
        else {
            that._logger.log(that.INTERNAL, LOG_ID + "(addOrUpdateWebinarToCache) add in cache webinarsObj : ", webinarsObj);
            that._webinars.push(webinarsObj);
        }
        // this.updateWebinarsList();
        return webinarsObj;
    }
    removeWebinarFromCache(webinarsId) {
        let that = this;
        return new Promise((resolve, reject) => {
            // Get the webinars to remove
            let webinarsToRemove = this.getWebinarFromCache(webinarsId);
            if (webinarsToRemove) {
                // Store webinars name
                //let webinarsName = webinarsToRemove.name;
                // Handle invitation webinars
                //if (webinarsToRemove.invited) { this.decrementInvitationCounter(); }
                // Remove from webinarss
                let webinarsId = webinarsToRemove.id;
                that._logger.log(that.INTERNAL, LOG_ID + "(removeWebinarFromCache) remove from cache webinarsId : ", webinarsId);
                this._webinars = this._webinars.filter(function (chnl) {
                    return !(chnl.id === webinarsId);
                });
                resolve(webinarsToRemove);
                // this.updateWebinarsList();
                // Update messagesList
                //this.feedWebinar.messages = [];
                /* this.retrieveLatests()
                        .then(() => { resolve(webinarsToRemove); })
                        .catch((err) => {
                            that._logger.log(that.ERROR, LOG_ID + "(removeWebinarFromCache) error retrieveLatests ");
                            that._logger.log(that.INTERNALERROR, LOG_ID + "(removeWebinarFromCache) error retrieveLatests : ", err);
                            return reject(err);
                        });
                 // */
            }
            else {
                resolve(null);
            }
        });
    }
    //endregion Webinars Utils
    //region Webinar
    /**
     * @public
     * @nodered true
     * @method createWebinar
     * @since 2.3.0
     * @instance
     * @category Webinars
     * @description
     *  Create a webinar (2 rooms are used for it).<br>
     * @param {string} name The name of the bubble to create.
     * @param {string} subject Webinar subject.
     * @param {Date} waitingRoomStartDate Waiting room start date UTC format.
     * @param {Date} webinarStartDate Webinar start date UTC format.
     * @param {Date} webinarEndDate Webinar end date UTC format.
     * @param {Array<Date>} reminderDates Up to 10 webinar reminder dates UTC format.
     * @param {string} timeZone Webinar time zone. If none, user time zone will be used.
     * @param {boolean} register=true Is participant registration required for webinar? Default value : true.
     * @param {string} approvalRegistrationMethod="automatic" Participants approval method. If 'manual` is selected, webinar creator can choose to manually approve or reject participants. default value : automatic. Possible values : manual, automatic.
     * @param {boolean} passwordNeeded=true If true, a password is needed when joining the webinar. This password is included in the registration confirmation email. Default value : true.
     * @param {boolean} isOrganizer=false If true, webinar creator is also an organizer. Default value : false.
     * @param {Array<string>} waitingRoomMultimediaURL Up to 5 URL of media to broadcast in the waiting room.
     * @param {string} stageBackground Free field used for customization (for example a file descriptor unique identifier).
     * @param {string} chatOption="participant" Define how participants can chat with organizers. Default value : participant. Possible values : participant, visitor, private.
     * @async
     * @return {Promise<any, ErrorManager>}
    
     */
    async createWebinar(name, subject, waitingRoomStartDate, webinarStartDate, webinarEndDate, reminderDates, timeZone, register = true, approvalRegistrationMethod = "automatic", passwordNeeded = true, isOrganizer = false, waitingRoomMultimediaURL, stageBackground, chatOption = "participant") {
        let that = this;
        that._logger.log(that.INFOAPI, LOG_ID + API_ID + "(createWebinar) is name defined : ", (0, Utils_1.isDefined)(name));
        return new Promise((resolve, reject) => {
            if (!name) {
                that._logger.log(that.WARN, LOG_ID + "(createWebinar) bad or empty 'name' parameter.");
                that._logger.log(that.INTERNALERROR, LOG_ID + "(createWebinar) bad or empty 'name' parameter : ", name);
                reject(ErrorManager_1.ErrorManager.getErrorManager().BAD_REQUEST);
                return;
            }
            //dateFormat(mDate, "YYYY-MM-DD_HH-mm")
            if (!webinarStartDate) {
                webinarStartDate = new Date();
                webinarStartDate.setMinutes(webinarStartDate.getMinutes() + 3);
            }
            if (!webinarEndDate) {
                webinarEndDate = new Date(webinarStartDate);
                webinarEndDate.setHours(webinarEndDate.getHours() + 1);
            }
            that._rest.createWebinar(name, subject, waitingRoomStartDate, webinarStartDate, webinarEndDate, reminderDates, timeZone, register, approvalRegistrationMethod, passwordNeeded, isOrganizer, waitingRoomMultimediaURL, stageBackground, chatOption).then((webinar) => {
                that._logger.log(that.DEBUG, LOG_ID + "(createWebinar) creation successfull");
                that._logger.log(that.INTERNAL, LOG_ID + "(createWebinar) creation successfull, webinar", webinar);
                resolve(webinar);
            }).catch(err => {
                that._logger.log(that.ERROR, LOG_ID + "(createWebinar) failed to create webinar.");
                that._logger.log(that.INTERNALERROR, LOG_ID + "(createWebinar) failed to create webinar : ", err);
                reject(ErrorManager_1.ErrorManager.getErrorManager().OTHERERROR("webinar_create_failed", err.message));
            });
        });
    }
    /**
     * @public
     * @nodered true
     * @method updateWebinar
     * @since 2.3.0
     * @category Webinars
     * @instance
     * @description
     *  Update a webinar.<br>
     * @param {string} webinarId Webinar identifier.
     * @param {string} name The name of the bubble to create.
     * @param {string} subject Webinar subject.
     * @param {Date} waitingRoomStartDate Waiting room start date UTC format.
     * @param {Date} webinarStartDate Webinar start date UTC format.
     * @param {Date} webinarEndDate Webinar end date UTC format.
     * @param {Array<Date>} reminderDates Up to 10 webinar reminder dates UTC format.
     * @param {string} timeZone Webinar time zone. If none, user time zone will be used.
     * @param {boolean} register Is participant registration required for webinar?
     * @param {string} approvalRegistrationMethod Participants approval method. If 'manual` is selected, webinar creator can choose to manually approve or reject participants. Possible values : manual, automatic.
     * @param {boolean} passwordNeeded If true, a password is needed when joining the webinar. This password is included in the registration confirmation email.
     * @param {boolean} lockRegistration Turn off registration for webinar before it starts.
     * @param {Array<string>} waitingRoomMultimediaURL Up to 5 URL of media to broadcast in the waiting room.
     * @param {string} stageBackground Free field used for customization (for example a file descriptor unique identifier).
     * @param {string} chatOption Define how participants can chat with organizers. Default value : participant. Possible values : participant, visitor, private.
     * @async
     * @return {Promise<any, ErrorManager>}
     */
    async updateWebinar(webinarId, name, subject, waitingRoomStartDate, webinarStartDate, webinarEndDate, reminderDates, timeZone, register, approvalRegistrationMethod, passwordNeeded, lockRegistration, waitingRoomMultimediaURL, stageBackground, chatOption) {
        let that = this;
        that._logger.log(that.INFOAPI, LOG_ID + API_ID + "(updateWebinar) is name defined : ", (0, Utils_1.isDefined)(name));
        return new Promise((resolve, reject) => {
            if (!webinarId) {
                that._logger.log(that.WARN, LOG_ID + "(updateWebinar) bad or empty 'webinarId' parameter.");
                that._logger.log(that.INTERNALERROR, LOG_ID + "(updateWebinar) bad or empty 'webinarId' parameter : ", webinarId);
                reject(ErrorManager_1.ErrorManager.getErrorManager().BAD_REQUEST);
                return;
            }
            that._rest.updateWebinar(webinarId, name, subject, waitingRoomStartDate, webinarStartDate, webinarEndDate, reminderDates, timeZone, register, approvalRegistrationMethod, passwordNeeded, lockRegistration, waitingRoomMultimediaURL, stageBackground, chatOption).then((webinar) => {
                that._logger.log(that.DEBUG, LOG_ID + "(updateWebinar) update successfull");
                that._logger.log(that.INTERNAL, LOG_ID + "(updateWebinar) update successfull, webinar", webinar);
                resolve(webinar);
            }).catch(err => {
                that._logger.log(that.ERROR, LOG_ID + "(updateWebinar) failed to update webinar.");
                that._logger.log(that.INTERNALERROR, LOG_ID + "(updateWebinar) failed to update webinar : ", err);
                reject(ErrorManager_1.ErrorManager.getErrorManager().OTHERERROR("webinar_update_failed", err.message));
            });
        });
    }
    /**
     * @public
     * @nodered true
     * @method getWebinarData
     * @since 2.3.0
     * @instance
     * @category Webinars
     * @description
     *  Get data for a given webinar.<br>
     * @param {string} webinarId Webinar identifier.
     * @async
     * @return {Promise<any, ErrorManager>}
    
     */
    async getWebinarData(webinarId) {
        let that = this;
        that._logger.log(that.INFOAPI, LOG_ID + API_ID + "(getWebinarData) is webinarId defined : ", (0, Utils_1.isDefined)(webinarId));
        return new Promise((resolve, reject) => {
            if (!webinarId) {
                that._logger.log(that.WARN, LOG_ID + "(getWebinarsData) bad or empty 'webinarId' parameter.");
                that._logger.log(that.INTERNALERROR, LOG_ID + "(getWebinarsData) bad or empty 'webinarId' parameter : ", webinarId);
                reject(ErrorManager_1.ErrorManager.getErrorManager().BAD_REQUEST);
                return;
            }
            that._rest.getWebinarData(webinarId).then((webinar) => {
                that._logger.log(that.DEBUG, LOG_ID + "(getWebinarsData) get successfull");
                that._logger.log(that.INTERNAL, LOG_ID + "(getWebinarsData) get successfull, webinar", webinar);
                resolve(webinar);
            }).catch(err => {
                that._logger.log(that.ERROR, LOG_ID + "(getWebinarsData) failed to get webinar.");
                that._logger.log(that.INTERNALERROR, LOG_ID + "(getWebinarsData) failed to get webinar : ", err);
                reject(ErrorManager_1.ErrorManager.getErrorManager().OTHERERROR("webinar_get_failed", err.message));
            });
        });
    }
    /**
     * @public
     * @nodered true
     * @method getWebinarsData
     * @instance
     * @category Webinars
     * @since 2.3.0
     * @description
     *  Get data for webinars where requester is creator, organizer, speaker and/or participant.<br>
     * @param {string} role filter. Possible values : creator, organizer, speaker, participant
     * @async
     * @return {Promise<any, ErrorManager>}
     */
    async getWebinarsData(role) {
        let that = this;
        that._logger.log(that.INFOAPI, LOG_ID + API_ID + "(getWebinarsData) is role defined : ", (0, Utils_1.isDefined)(role));
        return new Promise((resolve, reject) => {
            that._rest.getWebinarsData(role).then((webinarsInfo) => {
                that._logger.log(that.DEBUG, LOG_ID + "(getWebinarsData) get successfull.");
                that._logger.log(that.INTERNAL, LOG_ID + "(getWebinarsData) get successfull, webinars : ", webinarsInfo);
                webinarsInfo.webinars = [];
                for (const listeventtypeKey in webinarsInfo.data) {
                    let webinarObj = webinar_1.Webinar.createFromData(webinarsInfo.data[listeventtypeKey], that._rest.http.serverURL);
                    webinarsInfo.webinars.push(webinarObj);
                }
                resolve(webinarsInfo);
            }).catch(err => {
                that._logger.log(that.ERROR, LOG_ID + "(getWebinarsData) failed to get webinars.");
                that._logger.log(that.INTERNALERROR, LOG_ID + "(getWebinarsData) failed to get webinars : ", err);
                reject(ErrorManager_1.ErrorManager.getErrorManager().OTHERERROR("webinars_get_failed", err.message));
            });
        });
    }
    /**
     * @public
     * @nodered true
     * @method fetchMyWebinars
     * @since 2.3.0
     * @instance
     * @async
     * @category Webinars
     * @param {boolean} forceServerSearch Boolean to force the get of webinars's informations from server.
     * @description
     *    Get the webinars you own.<br>
     *    Return a promise. <br>
     * @return {Promise<Webinar[]>} Return Promise
     */
    async fetchMyWebinars(forceServerSearch) {
        let that = this;
        that._logger.log(that.INFOAPI, LOG_ID + API_ID + "(fetchMyWebinars) is forceServerSearch defined : ", (0, Utils_1.isDefined)(forceServerSearch));
        return new Promise((resolve) => {
            that.getWebinarsData(undefined).then((webinarsResult) => {
                /*
                // Hack waiting server change
                let promises = [];

                if (Array.isArray(webinarsResult.data)) {
                    webinarsResult.data.forEach((webinar) => {
                        promises.push(this.getWebinarData(webinar.id));
                    });
                } else {
                   
                }

                that._logger.log(that.INFO, LOG_ID + "(fetchMyChannels) hack start get channel data individually from server...");
                Promise.all(promises).then((channels : [Channel]) => {
                    that._logger.log(that.INTERNAL, LOG_ID + "(fetchMyChannels) hack done : ", channels);
                    that._webinars = [];
                    if (channels) {
                        channels.forEach((channel) => {
                            that.addOrUpdateChannelToCache(channel);
                        })
                    }
                    //that._logger.log(that.INTERNAL, LOG_ID + "(fetchMyChannels) get successfully and updated the channels cache : ", that._channels);
                    resolve(that._webinars);
                });
                // */
            }).catch((err) => {
                that._logger.log(that.ERROR, LOG_ID + "(fetchMyChannels) error ");
                that._logger.log(that.INTERNALERROR, LOG_ID + "(fetchMyChannels) error : ", err);
                // Do not block the startup on VM without channels API
                that._webinars = [];
                resolve(that._webinars);
            });
        });
    }
    /**
     * @public
     * @nodered true
     * @method warnWebinarModerators
     * @since 2.3.0
     * @instance
     * @category Webinars
     * @description
     *  When main speakers and organizers are selected, it's time to warn each of them to join the practice room. when some webinar information change such as:<br>
     *  As a result, moderatorsSelectedAnNotified boolean is set to true.<br>
     * @param {string} webinarId Webinar unique identifier. <br>
     * Notes:<br>
     * API Call Mandatory before publishing the webinar event:<br>
     *  The webinar can't be published if webinar moderators are not warned prior.<br>
     *  see API publishAWebinarEvent<br>
     * @async
     * @return {Promise<any, ErrorManager>}
    
     */
    async warnWebinarModerators(webinarId) {
        let that = this;
        that._logger.log(that.INFOAPI, LOG_ID + API_ID + "(warnWebinarModerators) is webinarId defined : ", (0, Utils_1.isDefined)(webinarId));
        return new Promise((resolve, reject) => {
            if (!webinarId) {
                that._logger.log(that.WARN, LOG_ID + "(warnWebinarModerators) bad or empty 'webinarId' parameter.");
                that._logger.log(that.INTERNALERROR, LOG_ID + "(warnWebinarModerators) bad or empty 'webinarId' parameter : ", webinarId);
                reject(ErrorManager_1.ErrorManager.getErrorManager().BAD_REQUEST);
                return;
            }
            that._rest.warnWebinarModerators(webinarId).then((webinar) => {
                that._logger.log(that.DEBUG, LOG_ID + "(warnWebinarModerators) get successfull.");
                that._logger.log(that.INTERNAL, LOG_ID + "(warnWebinarModerators) get successfull, webinars : ", webinar);
                resolve(webinar);
            }).catch(err => {
                that._logger.log(that.ERROR, LOG_ID + "(warnWebinarModerators) failed to get webinars.");
                that._logger.log(that.INTERNALERROR, LOG_ID + "(warnWebinarModerators) failed to get webinars : ", err);
                reject(ErrorManager_1.ErrorManager.getErrorManager().OTHERERROR("webinar_warn_failed", err.message));
            });
        });
    }
    /**
     * @public
     * @nodered true
     * @method publishAWebinarEvent
     * @since 2.3.0
     * @instance
     * @category Webinars
     * @description
     *  When main information about the webinar event are decided, it's up to open participant registration and allow automatic email sent when some webinar information change such as:<br>
     *  cancellation<br>
     *  date changes<br>
     *  speakers added or removed<br>
     *  As a result, emailNotification boolean is set to true. This boolean is checked when a participant try to submit a registration earlier. See API POST /api/rainbow/webinar/v1.0/webinars/self-register<br>
     * @param {string} webinarId Webinar unique identifier. <br>
     * @async
     * @return {Promise<any, ErrorManager>}
    
     */
    async publishAWebinarEvent(webinarId) {
        let that = this;
        that._logger.log(that.INFOAPI, LOG_ID + API_ID + "(publishAWebinarEvent) is webinarId defined : ", (0, Utils_1.isDefined)(webinarId));
        return new Promise((resolve, reject) => {
            if (!webinarId) {
                that._logger.log(that.WARN, LOG_ID + "(publishAWebinarEvent) bad or empty 'webinarId' parameter.");
                that._logger.log(that.INTERNALERROR, LOG_ID + "(publishAWebinarEvent) bad or empty 'webinarId' parameter : ", webinarId);
                reject(ErrorManager_1.ErrorManager.getErrorManager().BAD_REQUEST);
                return;
            }
            that._rest.publishAWebinarEvent(webinarId).then((webinar) => {
                that._logger.log(that.DEBUG, LOG_ID + "(publishAWebinarEvent) get successfull.");
                that._logger.log(that.INTERNAL, LOG_ID + "(publishAWebinarEvent) get successfull, webinars : ", webinar);
                resolve(webinar);
            }).catch(err => {
                that._logger.log(that.ERROR, LOG_ID + "(publishAWebinarEvent) failed to get webinars.");
                that._logger.log(that.INTERNALERROR, LOG_ID + "(publishAWebinarEvent) failed to get webinars : ", err);
                reject(ErrorManager_1.ErrorManager.getErrorManager().OTHERERROR("webinar_publish_failed", err.message));
            });
        });
    }
    /**
     * @public
     * @nodered true
     * @method deleteWebinar
     * @since 2.3.0
     * @category Webinars
     * @instance
     * @description
     *  Delete a webinar.<br>
     * @param {string} webinarId Webinar unique identifier. <br>
     * @async
     * @return {Promise<any, ErrorManager>}
     */
    async deleteWebinar(webinarId) {
        let that = this;
        that._logger.log(that.INFOAPI, LOG_ID + API_ID + "(deleteWebinar) is webinarId defined : ", (0, Utils_1.isDefined)(webinarId));
        return new Promise((resolve, reject) => {
            if (!webinarId) {
                that._logger.log(that.WARN, LOG_ID + "(deleteWebinar) bad or empty 'webinarId' parameter.");
                that._logger.log(that.INTERNALERROR, LOG_ID + "(deleteWebinar) bad or empty 'webinarId' parameter : ", webinarId);
                reject(ErrorManager_1.ErrorManager.getErrorManager().BAD_REQUEST);
                return;
            }
            that._rest.deleteWebinar(webinarId).then((webinar) => {
                that._logger.log(that.DEBUG, LOG_ID + "(deleteWebinar) get successfull.");
                that._logger.log(that.INTERNAL, LOG_ID + "(deleteWebinar) get successfull, webinars : ", webinar);
                resolve(webinar);
            }).catch(err => {
                that._logger.log(that.ERROR, LOG_ID + "(deleteWebinar) failed to get webinars.");
                that._logger.log(that.INTERNALERROR, LOG_ID + "(deleteWebinar) failed to get webinars : ", err);
                reject(ErrorManager_1.ErrorManager.getErrorManager().OTHERERROR("webinar_delete_failed", err.message));
            });
        });
    }
};
exports.WebinarsService = WebinarsService;
exports.WebinarsService = WebinarsService = WebinarsService_1 = __decorate([
    (0, Utils_1.logEntryExit)(LOG_ID),
    (0, Utils_1.isStarted)([])
    /**
     * @module
     * @name WebinarsService
     * @version 2.42.0-lts.4 - Documentation generated on 2026/04/24T11:38:22.926Z
     * @public
     * @description
     *      This service manages .<br>
     */
], WebinarsService);
module.exports.WebinarsService = WebinarsService;
//# sourceMappingURL=WebinarsService.js.map