"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TeacherSchema = exports.Teacher = void 0;
const mongoose_1 = require("@nestjs/mongoose");
const base_entity_1 = require("../../common/entities/base.entity");
const class_transformer_1 = require("class-transformer");
const notification_prefs_schema_1 = require("../../common/schemas/notification-prefs.schema");
let CustomDocument = class CustomDocument {
    title;
    publishedBy;
    documentUrl;
    uploadDate;
};
__decorate([
    (0, mongoose_1.Prop)({ required: true }),
    __metadata("design:type", String)
], CustomDocument.prototype, "title", void 0);
__decorate([
    (0, mongoose_1.Prop)(),
    __metadata("design:type", String)
], CustomDocument.prototype, "publishedBy", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true }),
    __metadata("design:type", String)
], CustomDocument.prototype, "documentUrl", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: Date, default: Date.now }),
    __metadata("design:type", Date)
], CustomDocument.prototype, "uploadDate", void 0);
CustomDocument = __decorate([
    (0, mongoose_1.Schema)({ _id: false })
], CustomDocument);
const CustomDocumentSchema = mongoose_1.SchemaFactory.createForClass(CustomDocument);
let CustomImage = class CustomImage {
    title;
    imageUrl;
    uploadDate;
};
__decorate([
    (0, mongoose_1.Prop)(),
    __metadata("design:type", String)
], CustomImage.prototype, "title", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true }),
    __metadata("design:type", String)
], CustomImage.prototype, "imageUrl", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: Date, default: Date.now }),
    __metadata("design:type", Date)
], CustomImage.prototype, "uploadDate", void 0);
CustomImage = __decorate([
    (0, mongoose_1.Schema)({ _id: false })
], CustomImage);
const CustomImageSchema = mongoose_1.SchemaFactory.createForClass(CustomImage);
let EducationEntry = class EducationEntry {
    university;
    degree;
    institution;
    startDate;
    endDate;
    city;
    grade;
};
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], EducationEntry.prototype, "university", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], EducationEntry.prototype, "degree", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], EducationEntry.prototype, "institution", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: Date }),
    __metadata("design:type", Date)
], EducationEntry.prototype, "startDate", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: Date }),
    __metadata("design:type", Date)
], EducationEntry.prototype, "endDate", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], EducationEntry.prototype, "city", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], EducationEntry.prototype, "grade", void 0);
EducationEntry = __decorate([
    (0, mongoose_1.Schema)({ _id: false })
], EducationEntry);
const EducationEntrySchema = mongoose_1.SchemaFactory.createForClass(EducationEntry);
let Teacher = class Teacher extends base_entity_1.BaseEntity {
    name;
    uniqueId;
    email;
    password;
    role;
    isActive;
    designation;
    subject;
    phone;
    joinDate;
    dateOfBirth;
    fatherName;
    motherName;
    mobileNumber;
    adhaarNumber;
    panNumber;
    address;
    highestQualification;
    photoUrl;
    signature;
    customDocuments;
    customImages;
    education;
    bankName;
    accountNumber;
    accountType;
    ifscNumber;
    pfMemberId;
    pfAccountNumber;
    employeeName;
    kycStatus;
    schoolLeavingDate;
    leavingReason;
    notificationPrefs;
};
exports.Teacher = Teacher;
__decorate([
    (0, mongoose_1.Prop)({ required: true, trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "name", void 0);
__decorate([
    (0, mongoose_1.Prop)({ unique: true, sparse: true, trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "uniqueId", void 0);
__decorate([
    (0, mongoose_1.Prop)({ unique: true, sparse: true, trim: true, lowercase: true }),
    __metadata("design:type", String)
], Teacher.prototype, "email", void 0);
__decorate([
    (0, class_transformer_1.Exclude)(),
    (0, mongoose_1.Prop)(),
    __metadata("design:type", String)
], Teacher.prototype, "password", void 0);
__decorate([
    (0, mongoose_1.Prop)({ default: 'teacher' }),
    __metadata("design:type", String)
], Teacher.prototype, "role", void 0);
__decorate([
    (0, mongoose_1.Prop)({ default: true, index: true }),
    __metadata("design:type", Boolean)
], Teacher.prototype, "isActive", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true, index: true }),
    __metadata("design:type", String)
], Teacher.prototype, "designation", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "subject", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true, index: true }),
    __metadata("design:type", String)
], Teacher.prototype, "phone", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: Date }),
    __metadata("design:type", Date)
], Teacher.prototype, "joinDate", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: Date }),
    __metadata("design:type", Date)
], Teacher.prototype, "dateOfBirth", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "fatherName", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "motherName", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "mobileNumber", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "adhaarNumber", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "panNumber", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true, trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "address", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true, trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "highestQualification", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "photoUrl", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "signature", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: [CustomDocumentSchema], default: [] }),
    __metadata("design:type", Array)
], Teacher.prototype, "customDocuments", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: [CustomImageSchema], default: [] }),
    __metadata("design:type", Array)
], Teacher.prototype, "customImages", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: [EducationEntrySchema], default: [] }),
    __metadata("design:type", Array)
], Teacher.prototype, "education", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "bankName", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "accountNumber", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "accountType", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "ifscNumber", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "pfMemberId", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "pfAccountNumber", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "employeeName", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "kycStatus", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: Date }),
    __metadata("design:type", Date)
], Teacher.prototype, "schoolLeavingDate", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], Teacher.prototype, "leavingReason", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: notification_prefs_schema_1.NotificationPrefsSchema, default: () => ({ email: true, whatsapp: true }) }),
    __metadata("design:type", notification_prefs_schema_1.NotificationPrefs)
], Teacher.prototype, "notificationPrefs", void 0);
exports.Teacher = Teacher = __decorate([
    (0, mongoose_1.Schema)({ timestamps: true })
], Teacher);
exports.TeacherSchema = mongoose_1.SchemaFactory.createForClass(Teacher);
exports.TeacherSchema.pre('save', function (next) {
    if (this.email !== undefined && this.email.trim() === '') {
        this.email = undefined;
    }
    next();
});
exports.TeacherSchema.virtual('id').get(function () {
    return this._id?.toString?.() ?? String(this._id);
});
const jsonOpts = {
    versionKey: false,
    virtuals: true,
    transform: (_, ret) => {
        delete ret.password;
        return ret;
    },
};
exports.TeacherSchema.set('toJSON', jsonOpts);
exports.TeacherSchema.set('toObject', jsonOpts);
//# sourceMappingURL=teacher.schema.js.map