"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppraiserContact = exports.AppraiserContactSchema = exports.AppraiserContactValidationSchema = void 0;
const mongoose_1 = __importDefault(require("mongoose"));
const joi_1 = __importDefault(require("joi"));
const _models_1 = require("./_models");
exports.AppraiserContactValidationSchema = joi_1.default.object({
    _id: joi_1.default.string(),
    appraiserId: joi_1.default.string(),
    name: joi_1.default.string().allow(''),
    title: joi_1.default.string().allow(''),
    emails: joi_1.default.array().items(joi_1.default.string().email()).allow(null),
    phone: joi_1.default.string().allow(''),
    comment: joi_1.default.string().allow(''),
    isDeleted: joi_1.default.boolean(),
    order: joi_1.default.number().required().allow(null),
});
exports.AppraiserContactSchema = new mongoose_1.default.Schema({
    appraiserId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.appraiser,
        required: true,
    },
    isDeleted: {
        type: Boolean,
        default: false,
    },
    name: {
        type: String,
    },
    title: {
        type: String,
    },
    emails: {
        type: [String],
    },
    normalizedEmails: {
        type: [String],
        lowercase: true,
        select: false,
        // unique: true, // TODO potential issue with unique email normalization
    },
    phone: {
        type: String,
    },
    comment: {
        type: String,
    },
    order: {
        type: Number,
        required: true,
    },
}, {
    timestamps: { createdAt: true, updatedAt: true },
    versionKey: false,
});
exports.AppraiserContact = mongoose_1.default.model(_models_1.MODEL_NAMES.appraiserContact, exports.AppraiserContactSchema);
