/**
 * Copyright (C) 2020 to the present, Crestron Electronics, Inc.
 * All rights reserved.
 * No part of this software may be reproduced in any form, machine
 * or natural, without the express written consent of Crestron Electronics.
 * Use of this source code is subject to the terms of the Crestron Software License Agreement 
 * under which you licensed this source code.  
 *
 * This code was automatically generated by Crestron's code generation tool.
 */

/* jslint es6 */

const infoModule = (function () {
    'use strict';

    let nextMeetingInfo = document.getElementById("nextMeetingInfo");
    let subInfoHasNextMeeting = null;

    /**
     * Initialize Method
     */
    function onInit() {
        invokeUnsubscriptions();
        initializeVariables();
        invokeSubscriptions();
    }

    /**
     * Invoke unsubscriptions related to module
     */
    function invokeSubscriptions() {
        subInfoHasNextMeeting = CrComLib.subscribeState('b', 'Room[0].RoomScheduler.HasNextMeeting', (response) => {
            const hasNextMeeting = avfUtility.toBool(response);
            avfUtility.log(`Room[0].RoomScheduler.HasNextMeeting: ${hasNextMeeting}`);
            if (hasNextMeeting) {
                nextMeetingInfo.style.display = "block";
            }
        });
    }

    /**
     * Invoke unsubscriptions related to module
     */
    function invokeUnsubscriptions() {
        if (subInfoHasNextMeeting) {
            CrComLib.unsubscribeState('b', 'Room[0].RoomScheduler.HasNextMeeting', subInfoHasNextMeeting);
        }
    }

    /**
     * Initialize all the variables used in this module
     */
    function initializeVariables() {
        nextMeetingInfo.style.display = "none";
        subInfoHasNextMeeting = null;
    }

    /**
     * All public method and properties are exported here
     */
    return {
        onInit
    };

}());