"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _ServerMessage_fullMessage, _ServerMessage_message, _ServerMessage_type, _ServerMessage_date, _ServerMessage_category;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServerMessageCategory = exports.ServerMessageType = void 0;
var ServerMessageType;
(function (ServerMessageType) {
    ServerMessageType[ServerMessageType["general"] = 0] = "general";
    ServerMessageType[ServerMessageType["info"] = 1] = "info";
    ServerMessageType[ServerMessageType["error"] = 2] = "error";
})(ServerMessageType = exports.ServerMessageType || (exports.ServerMessageType = {}));
var ServerMessageCategory;
(function (ServerMessageCategory) {
    ServerMessageCategory[ServerMessageCategory["general"] = 0] = "general";
})(ServerMessageCategory = exports.ServerMessageCategory || (exports.ServerMessageCategory = {}));
class ServerMessage {
    get fullMessage() {
        return __classPrivateFieldGet(this, _ServerMessage_fullMessage, "f");
    }
    get message() {
        return __classPrivateFieldGet(this, _ServerMessage_message, "f");
    }
    get type() {
        return __classPrivateFieldGet(this, _ServerMessage_type, "f");
    }
    get category() {
        return __classPrivateFieldGet(this, _ServerMessage_category, "f");
    }
    get date() {
        return __classPrivateFieldGet(this, _ServerMessage_date, "f");
    }
    constructor(message) {
        _ServerMessage_fullMessage.set(this, void 0);
        _ServerMessage_message.set(this, void 0);
        _ServerMessage_type.set(this, ServerMessageType.general);
        _ServerMessage_date.set(this, void 0);
        _ServerMessage_category.set(this, ServerMessageCategory.general);
        __classPrivateFieldSet(this, _ServerMessage_fullMessage, message, "f");
        __classPrivateFieldSet(this, _ServerMessage_date, new Date(0), "f");
        const firstBracket = message.indexOf("[");
        if (firstBracket === 0) {
            const lastBracket = message.indexOf("] ", firstBracket);
            if (lastBracket > firstBracket && lastBracket > 10) {
                __classPrivateFieldSet(this, _ServerMessage_message, message.substring(lastBracket + 2), "f");
                if (message.substring(lastBracket - 4, lastBracket) === "INFO") {
                    __classPrivateFieldSet(this, _ServerMessage_type, ServerMessageType.info, "f");
                }
                else if (message.substring(lastBracket - 5, lastBracket) === "ERROR") {
                    __classPrivateFieldSet(this, _ServerMessage_type, ServerMessageType.error, "f");
                }
                const lastSpace = message.lastIndexOf(" ", lastBracket);
                const dateTime = message.substring(firstBracket + 1, lastSpace);
                __classPrivateFieldSet(this, _ServerMessage_date, new Date(dateTime), "f");
            }
            else {
                __classPrivateFieldSet(this, _ServerMessage_message, __classPrivateFieldGet(this, _ServerMessage_fullMessage, "f"), "f");
            }
        }
        else {
            __classPrivateFieldSet(this, _ServerMessage_message, __classPrivateFieldGet(this, _ServerMessage_fullMessage, "f"), "f");
        }
        __classPrivateFieldSet(this, _ServerMessage_message, __classPrivateFieldGet(this, _ServerMessage_message, "f").trim(), "f");
    }
}
exports.default = ServerMessage;
_ServerMessage_fullMessage = new WeakMap(), _ServerMessage_message = new WeakMap(), _ServerMessage_type = new WeakMap(), _ServerMessage_date = new WeakMap(), _ServerMessage_category = new WeakMap();

//# sourceMappingURL=../maps/local/ServerMessage.js.map
