"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const sendIdentify_1 = __importDefault(require("./sendIdentify"));
const sendGroup_1 = __importDefault(require("./sendGroup"));
const sendScreen_1 = __importDefault(require("./sendScreen"));
const sendPage_1 = __importDefault(require("./sendPage"));
const sendTrack_1 = __importDefault(require("./sendTrack"));
const properties_1 = require("./properties");
const destination = {
    name: 'Segment',
    slug: 'actions-segment',
    mode: 'cloud',
    authentication: {
        scheme: 'custom',
        fields: {
            source_write_key: {
                label: 'Source Write Key',
                description: 'The **Write Key** of a Segment source.',
                type: 'password',
                required: true
            }
        },
        testAuthentication: async (request, { settings }) => {
            const { source_write_key } = settings;
            const AWS_REGION = process.env['AWS_REGION'] || properties_1.DEFAULT_SEGMENT_ENDPOINT;
            return request(`${properties_1.SEGMENT_ENDPOINTS[AWS_REGION].cdn}/projects/${source_write_key}/settings`);
        }
    },
    extendRequest({ settings }) {
        return {
            headers: {
                authorization: `Basic ${Buffer.from(settings.source_write_key + ':').toString('base64')}`
            }
        };
    },
    actions: {
        sendIdentify: sendIdentify_1.default,
        sendGroup: sendGroup_1.default,
        sendScreen: sendScreen_1.default,
        sendPage: sendPage_1.default,
        sendTrack: sendTrack_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map