"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BorrowerReminders = exports.BorrowerRemindersSchema = void 0;
const mongoose_1 = __importDefault(require("mongoose"));
const _models_1 = require("./_models");
const ReminderSectionSchema = new mongoose_1.default.Schema({
    reportDate: { type: Date },
    asOfDate: { type: Date },
    firm: { type: String },
    nextDue: { type: Date },
    nextScheduled: { type: Boolean },
}, { _id: false });
const InsuranceReminderSchema = new mongoose_1.default.Schema({
    expirationDate: { type: Date },
    company: { type: String },
    comments: { type: String },
}, { _id: false });
exports.BorrowerRemindersSchema = new mongoose_1.default.Schema({
    borrowerId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.borrowers,
        required: true,
    },
    appraisal: {
        type: ReminderSectionSchema,
        default: {},
    },
    fieldExam: {
        type: ReminderSectionSchema,
        default: {},
    },
    insurance: {
        type: InsuranceReminderSchema,
        default: {},
    },
}, {
    timestamps: { createdAt: true, updatedAt: true },
    versionKey: false,
    minimize: false,
});
exports.BorrowerReminders = mongoose_1.default.model(_models_1.MODEL_NAMES.borrowerReminders, exports.BorrowerRemindersSchema);
exports.BorrowerRemindersSchema.set('toJSON', {
    versionKey: false,
    transform: (_doc, ret) => {
        delete ret._id;
        delete ret.__v;
        delete ret.createdAt;
        delete ret.updatedAt;
        return ret;
    },
});
exports.BorrowerRemindersSchema.set('toObject', {
    versionKey: false,
    transform: (_doc, ret) => {
        delete ret._id;
        delete ret.__v;
        delete ret.createdAt;
        delete ret.updatedAt;
        return ret;
    },
});
exports.BorrowerRemindersSchema.index({ borrowerId: 1 }, { unique: true });
