"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const actions_core_1 = require("@segment/actions-core");
const constants_1 = require("./constants");
const send_1 = __importDefault(require("./send"));
const destination = {
    name: 'Attribution (Actions)',
    slug: 'actions-attribution',
    mode: 'cloud',
    authentication: {
        scheme: 'custom',
        fields: {
            projectID: {
                label: 'Project ID',
                description: 'Your Attribution project ID.',
                type: 'string',
                required: true
            }
        },
        testAuthentication: async (request) => {
            return request(`${constants_1.ATTRIBUTION_ENDPOINT}/check_auth`, {
                method: 'POST'
            });
        }
    },
    extendRequest({ settings }) {
        const { projectID } = settings;
        return {
            headers: {
                Authorization: `Basic ${Buffer.from(projectID + ':').toString('base64')}`
            }
        };
    },
    presets: [
        {
            name: 'Send Events',
            subscribe: 'type = "track" or type = "identify" or type = "page" or type = "screen" or type = "group" or type = "alias"',
            partnerAction: 'send',
            mapping: (0, actions_core_1.defaultValues)(send_1.default.fields),
            type: 'automatic'
        }
    ],
    actions: {
        send: send_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map