"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const functions_1 = require("../functions");
const properties_1 = require("../properties");
const actions_core_1 = require("@segment/actions-core");
const action = {
    title: 'Remove from Audience',
    description: 'Remove contacts from an Engage Audience to a TikTok Audience Segment.',
    defaultSubscription: 'event = "Audience Exited"',
    fields: {
        email: { ...properties_1.email },
        phone: { ...properties_1.phone },
        advertising_id: { ...properties_1.advertising_id },
        send_email: { ...properties_1.send_email },
        send_phone: { ...properties_1.send_phone },
        send_advertising_id: { ...properties_1.send_advertising_id },
        event_name: { ...properties_1.event_name },
        enable_batching: { ...properties_1.enable_batching },
        external_audience_id: { ...properties_1.external_audience_id }
    },
    perform: async (request, { audienceSettings, payload, statsContext }) => {
        const statsClient = statsContext?.statsClient;
        const statsTag = statsContext?.tags;
        if (!audienceSettings) {
            throw new actions_core_1.IntegrationError('Bad Request: no audienceSettings found.', 'INVALID_REQUEST_DATA', 400);
        }
        statsClient?.incr('removeFromAudience', 1, statsTag);
        return (0, functions_1.processPayload)(request, audienceSettings, [payload], 'delete');
    },
    performBatch: async (request, { audienceSettings, payload, statsContext }) => {
        const statsClient = statsContext?.statsClient;
        const statsTag = statsContext?.tags;
        if (!audienceSettings) {
            throw new actions_core_1.IntegrationError('Bad Request: no audienceSettings found.', 'INVALID_REQUEST_DATA', 400);
        }
        statsClient?.incr('removeFromAudience', 1, statsTag);
        return (0, functions_1.processPayload)(request, audienceSettings, payload, 'delete');
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map