// (C) Copyright 2020 Hewlett-Packard Enterprise Company, L.P.
/**
 * @type {StatusState}
 *
 */
define([], function() { //"use strict";

    var StatusState = (function () {
        /**
         * @constructor
         */
        function StatusState() {

            // mapping from health status to health status string
            var HEALTH_STATUS_MAP = {
                // resources
                OK             : "ok",
                UNKNOWN        : "unknown",
                WARNING        : "warning",
                MAJOR          : "warning",
                CRITICAL       : "error",
                DISABLED       : "disabled",
                // mock resources
                ok             : "ok",
                unknown        : "unknown",
                warning        : "warning",
                critical       : "error",
                major          : "warning",
                error          : "error",
                disabled       : "disabled",
                // alerts
                Warning        : "warning",
                Critical       : "error",
                Disabled       : "disabled",
                // tasks
                Unknown        : "unknown",
                New            : "unknown",
                Running        : "unknown",
                Suspended      : "disabled",
                Terminated     : "disabled",
                Killed         : "disabled",
                Completed      : "ok",
                Error          : "error",
                Interrupted    : "error",
                // mock tasks
                'new'          : "unknown",
                running        : "unknown",
                suspended      : "disabled",
                terminated     : "disabled",
                killed         : "disabled",
                completed      : "ok",
                interrupted    : "error"
            };

            /**
             * Get appropriate hpStatus name for a given resource status.
             * @param healthStatus one of the health status names for a resource.
             *        Typically this are one of the values from hp.ci.mgmt.model.HealthStatus.java
             * @return the matching status name to use for jquery.hpStatus
             */
            this.getHealthStatus = function (healthStatus) {
                var status = "unknown";

                if (healthStatus && HEALTH_STATUS_MAP.hasOwnProperty(healthStatus)) {
                    status = HEALTH_STATUS_MAP[healthStatus];
                }
                return status;
            };
        }

        return new StatusState();
    }());

    return StatusState;

});