var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
export function unhideElementById(document, e) {
    return __awaiter(this, void 0, void 0, function* () {
        var element = document.getElementById(e);
        if (element) {
            element.classList.remove('hidden-before-load');
        }
    });
}
export function getEvent(id) {
    return __awaiter(this, void 0, void 0, function* () {
        const res = yield fetch("/api/events/" + id);
        if (!res.ok) {
            throw Error("To wydarzenie nie istnieje");
        }
        const events = yield res.json();
        return events;
    });
}
export function getMyAccount() {
    return __awaiter(this, void 0, void 0, function* () {
        const res = yield fetch("/api/auth/my_account");
        if (!res.ok) {
            throw Error("U�ytkownik niezalogowany!");
        }
        const data = yield res.json();
        return data;
    });
}
export function getMyRegisteredEventIds() {
    return __awaiter(this, void 0, void 0, function* () {
        const res = yield fetch("/api/auth/my_events");
        if (!res.ok) {
            throw Error("Użytkownik niezalogowany!");
        }
        const events = yield res.json();
        return events.map((event) => event.eventId);
    });
}
