"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SKIP_IDENTITY = exports.OPENAI_API_KEY = exports.INTEGRATIONS_FILE = exports.APISERVER_ENDPOINT = exports.CONVERSATION_PROVIDER_FILE = exports.CONVERSATION_PROVIDER = exports.SILERO_VAD_VERSION = exports.UNSTRUCTURED_API_URL = exports.UNSTRUCTURED_API_KEY = exports.NODE_ENV = exports.KNOWLEDGE_BASE_ENABLED = exports.AWS_S3_SECRET_ACCESS_KEY = exports.AWS_S3_REGION = exports.AWS_S3_ENDPOINT = exports.AWS_S3_ACCESS_KEY_ID = void 0;
/**
 * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
 * http://github.com/fonoster/fonoster
 *
 * This file is part of Fonoster
 *
 * Licensed under the MIT License (the "License");
 * you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *    https://opensource.org/licenses/MIT
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const path_1 = require("path");
const common_1 = require("@fonoster/common");
const dotenv_1 = __importDefault(require("dotenv"));
const types_1 = require("./types");
if (process.env.NODE_ENV === "dev") {
    dotenv_1.default.config({ path: (0, path_1.join)(__dirname, "..", "..", "..", ".env") });
}
const e = process.env;
exports.AWS_S3_ACCESS_KEY_ID = e.AUTOPILOT_AWS_S3_ACCESS_KEY_ID ?? "";
exports.AWS_S3_ENDPOINT = e.AUTOPILOT_AWS_S3_ENDPOINT ?? "";
exports.AWS_S3_REGION = e.AUTOPILOT_AWS_S3_REGION ?? "us-east-1";
exports.AWS_S3_SECRET_ACCESS_KEY = e.AUTOPILOT_AWS_S3_SECRET_ACCESS_KEY ?? "";
exports.KNOWLEDGE_BASE_ENABLED = e.AUTOPILOT_KNOWLEDGE_BASE_ENABLED === "true";
exports.NODE_ENV = e.NODE_ENV || "production";
exports.UNSTRUCTURED_API_KEY = e.AUTOPILOT_UNSTRUCTURED_API_KEY ?? "";
exports.UNSTRUCTURED_API_URL = e.AUTOPILOT_UNSTRUCTURED_API_URL ??
    "https://api.unstructuredapp.io/general/v0/general";
exports.SILERO_VAD_VERSION = e.AUTOPILOT_SILERO_VAD_VERSION ?? "v5";
exports.CONVERSATION_PROVIDER = e.AUTOPILOT_CONVERSATION_PROVIDER
    ? e.AUTOPILOT_CONVERSATION_PROVIDER
    : types_1.ConversationProvider.FILE;
exports.CONVERSATION_PROVIDER_FILE = e.AUTOPILOT_CONVERSATION_PROVIDER_FILE
    ? e.AUTOPILOT_CONVERSATION_PROVIDER_FILE
    : `${process.cwd()}/config/assistant.json`;
exports.APISERVER_ENDPOINT = e.AUTOPILOT_APISERVER_ENDPOINT
    ? e.AUTOPILOT_APISERVER_ENDPOINT
    : "apiserver:50051";
exports.INTEGRATIONS_FILE = e.AUTOPILOT_INTEGRATIONS_FILE
    ? e.AUTOPILOT_INTEGRATIONS_FILE
    : "/opt/fonoster/integrations.json";
exports.OPENAI_API_KEY = e.AUTOPILOT_OPENAI_API_KEY;
exports.SKIP_IDENTITY = e.AUTOPILOT_SKIP_IDENTITY === "true";
if (exports.SILERO_VAD_VERSION !== "v4" && exports.SILERO_VAD_VERSION !== "v5") {
    console.error("SILERO_VAD_VERSION must be set to 'v4' or 'v5'");
    process.exit(1);
}
if (exports.CONVERSATION_PROVIDER.toLocaleLowerCase() !== types_1.ConversationProvider.API &&
    exports.CONVERSATION_PROVIDER.toLocaleLowerCase() !== types_1.ConversationProvider.FILE) {
    console.error("CONVERSATION_PROVIDER must be set to 'api' or 'file'");
    process.exit(1);
}
if (exports.CONVERSATION_PROVIDER.toLocaleLowerCase() === types_1.ConversationProvider.API) {
    (0, common_1.assertFileExists)(exports.INTEGRATIONS_FILE);
}
if (exports.KNOWLEDGE_BASE_ENABLED) {
    (0, common_1.assertEnvsAreSet)([
        "AUTOPILOT_AWS_S3_ACCESS_KEY_ID",
        "AUTOPILOT_AWS_S3_SECRET_ACCESS_KEY",
        "AUTOPILOT_UNSTRUCTURED_API_KEY"
    ]);
}
