"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SupportSettingsModel = void 0;
const mongoose_1 = __importStar(require("mongoose"));
const BusinessHoursSchema = new mongoose_1.Schema({
    day: { type: Number, required: true, min: 0, max: 6 },
    start: { type: String, required: true },
    end: { type: String, required: true },
    enabled: { type: Boolean, default: true }
}, { _id: false });
const AutoReplySchema = new mongoose_1.Schema({
    id: { type: String, required: true },
    trigger: { type: String, required: true },
    response: { type: String, required: true },
    enabled: { type: Boolean, default: true }
}, { _id: false });
const CannedResponseSchema = new mongoose_1.Schema({
    id: { type: String, required: true },
    title: { type: String, required: true },
    content: { type: String, required: true },
    enabled: { type: Boolean, default: true }
}, { _id: false });
const AutoMessageButtonSchema = new mongoose_1.Schema({
    id: { type: String, required: true },
    label: { type: String, required: true },
    value: { type: String, required: true }
}, { _id: false });
const SupportSettingsSchema = new mongoose_1.Schema({
    welcomeMessage: {
        type: String,
        default: "Hello {{firstName}}\n\nWelcome to Support.\n\nPlease describe your issue.\n\nYou may also send:\n\n• Images\n• Documents\n• Videos\n• Voice Notes\n\nA support ticket will be created automatically."
    },
    aiEnabled: { type: Boolean, default: false },
    aiConfidenceThreshold: { type: Number, default: 0.6, min: 0, max: 1 },
    assignmentMode: {
        type: String,
        required: true,
        enum: ["ROUND_ROBIN", "LEAST_BUSY", "MANUAL", "RANDOM"],
        default: "ROUND_ROBIN"
    },
    maxOpenTickets: { type: Number, default: 100, min: 1 },
    maxTicketsPerUser: { type: Number, default: 3, min: 1 },
    businessHours: { type: [BusinessHoursSchema], default: [] },
    autoReplies: { type: [AutoReplySchema], default: [] },
    cannedResponses: { type: [CannedResponseSchema], default: [] },
    autoMessageOnTicketOpenEnabled: { type: Boolean, default: true },
    autoMessageOnTicketOpenText: {
        type: String,
        default: "Your support request has been received. A support agent will assist you shortly."
    },
    autoMessageOnTicketOpenButtons: { type: [AutoMessageButtonSchema], default: [] },
    autoMessageOnTicketCloseEnabled: { type: Boolean, default: true },
    autoMessageOnTicketCloseText: {
        type: String,
        default: "Your support ticket has been closed. If you need further assistance, feel free to open a new chat."
    },
    autoMessageOnTicketCloseButtons: { type: [AutoMessageButtonSchema], default: [] }
}, { timestamps: true });
exports.SupportSettingsModel = mongoose_1.default.model("SupportSettings", SupportSettingsSchema);
