"use strict";
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
    function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
    var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
    var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
    var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
    var _, done = false;
    for (var i = decorators.length - 1; i >= 0; i--) {
        var context = {};
        for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
        for (var p in contextIn.access) context.access[p] = contextIn.access[p];
        context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
        var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
        if (kind === "accessor") {
            if (result === void 0) continue;
            if (result === null || typeof result !== "object") throw new TypeError("Object expected");
            if (_ = accept(result.get)) descriptor.get = _;
            if (_ = accept(result.set)) descriptor.set = _;
            if (_ = accept(result.init)) initializers.unshift(_);
        }
        else if (_ = accept(result)) {
            if (kind === "field") initializers.unshift(_);
            else descriptor[key] = _;
        }
    }
    if (target) Object.defineProperty(target, contextIn.name, descriptor);
    done = true;
};
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
    var useValue = arguments.length > 2;
    for (var i = 0; i < initializers.length; i++) {
        value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
    }
    return useValue ? value : void 0;
};
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
    if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
    return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Season = void 0;
var typeorm_1 = require("typeorm");
var series_entity_1 = require("./series.entity");
var episode_entity_1 = require("./episode.entity");
var Season = function () {
    var _classDecorators = [(0, typeorm_1.Entity)('seasons')];
    var _classDescriptor;
    var _classExtraInitializers = [];
    var _classThis;
    var _id_decorators;
    var _id_initializers = [];
    var _id_extraInitializers = [];
    var _seriesId_decorators;
    var _seriesId_initializers = [];
    var _seriesId_extraInitializers = [];
    var _series_decorators;
    var _series_initializers = [];
    var _series_extraInitializers = [];
    var _number_decorators;
    var _number_initializers = [];
    var _number_extraInitializers = [];
    var _title_decorators;
    var _title_initializers = [];
    var _title_extraInitializers = [];
    var _episodes_decorators;
    var _episodes_initializers = [];
    var _episodes_extraInitializers = [];
    var Season = _classThis = /** @class */ (function () {
        function Season_1() {
            this.id = __runInitializers(this, _id_initializers, void 0);
            this.seriesId = (__runInitializers(this, _id_extraInitializers), __runInitializers(this, _seriesId_initializers, void 0));
            this.series = (__runInitializers(this, _seriesId_extraInitializers), __runInitializers(this, _series_initializers, void 0));
            this.number = (__runInitializers(this, _series_extraInitializers), __runInitializers(this, _number_initializers, void 0));
            this.title = (__runInitializers(this, _number_extraInitializers), __runInitializers(this, _title_initializers, void 0));
            this.episodes = (__runInitializers(this, _title_extraInitializers), __runInitializers(this, _episodes_initializers, void 0));
            __runInitializers(this, _episodes_extraInitializers);
        }
        return Season_1;
    }());
    __setFunctionName(_classThis, "Season");
    (function () {
        var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
        _id_decorators = [(0, typeorm_1.PrimaryGeneratedColumn)('uuid')];
        _seriesId_decorators = [(0, typeorm_1.Column)()];
        _series_decorators = [(0, typeorm_1.ManyToOne)(function () { return series_entity_1.Series; }, function (series) { return series.seasons; }, { onDelete: 'CASCADE' }), (0, typeorm_1.JoinColumn)({ name: 'seriesId' })];
        _number_decorators = [(0, typeorm_1.Column)()];
        _title_decorators = [(0, typeorm_1.Column)({ nullable: true })];
        _episodes_decorators = [(0, typeorm_1.OneToMany)(function () { return episode_entity_1.Episode; }, function (episode) { return episode.season; }, { cascade: true })];
        __esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: function (obj) { return "id" in obj; }, get: function (obj) { return obj.id; }, set: function (obj, value) { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
        __esDecorate(null, null, _seriesId_decorators, { kind: "field", name: "seriesId", static: false, private: false, access: { has: function (obj) { return "seriesId" in obj; }, get: function (obj) { return obj.seriesId; }, set: function (obj, value) { obj.seriesId = value; } }, metadata: _metadata }, _seriesId_initializers, _seriesId_extraInitializers);
        __esDecorate(null, null, _series_decorators, { kind: "field", name: "series", static: false, private: false, access: { has: function (obj) { return "series" in obj; }, get: function (obj) { return obj.series; }, set: function (obj, value) { obj.series = value; } }, metadata: _metadata }, _series_initializers, _series_extraInitializers);
        __esDecorate(null, null, _number_decorators, { kind: "field", name: "number", static: false, private: false, access: { has: function (obj) { return "number" in obj; }, get: function (obj) { return obj.number; }, set: function (obj, value) { obj.number = value; } }, metadata: _metadata }, _number_initializers, _number_extraInitializers);
        __esDecorate(null, null, _title_decorators, { kind: "field", name: "title", static: false, private: false, access: { has: function (obj) { return "title" in obj; }, get: function (obj) { return obj.title; }, set: function (obj, value) { obj.title = value; } }, metadata: _metadata }, _title_initializers, _title_extraInitializers);
        __esDecorate(null, null, _episodes_decorators, { kind: "field", name: "episodes", static: false, private: false, access: { has: function (obj) { return "episodes" in obj; }, get: function (obj) { return obj.episodes; }, set: function (obj, value) { obj.episodes = value; } }, metadata: _metadata }, _episodes_initializers, _episodes_extraInitializers);
        __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
        Season = _classThis = _classDescriptor.value;
        if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        __runInitializers(_classThis, _classExtraInitializers);
    })();
    return Season = _classThis;
}();
exports.Season = Season;
