"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 triggerBehavioralAction_1 = __importDefault(require("./triggerBehavioralAction"));
const destination = {
    name: 'Eagle Eye',
    slug: 'actions-eagleeye',
    mode: 'cloud',
    description: 'Synchronize Segment audiences to trigger behavioral actions in Eagle Eye AIR, enabling customer rewards.',
    authentication: {
        scheme: 'custom',
        fields: {
            connectorUrl: {
                label: 'Connector URL',
                description: 'Eagle Eye URL of the Segment connector provided by your EagleEye CSM',
                type: 'string',
                format: 'uri',
                required: true
            },
            externalKey: {
                label: 'Connector External Key',
                description: 'Key to authenticate with the connector provided by your EagleEye CSM',
                type: 'password',
                required: true
            }
        }
    },
    audienceFields: {
        behavioralActionTriggerReferences: {
            label: 'Behavioral Action trigger reference',
            type: 'string',
            description: 'Required if connecting to an Engage Audience. Accepts a comma delimited list of reference strings for the Behavioral Action to be executed. E.g.: A0001,P0001',
            required: false
        }
    },
    audienceConfig: {
        mode: {
            type: 'synced',
            full_audience_sync: false
        },
        async createAudience(_, createAudienceInput) {
            const triggerRef = createAudienceInput?.audienceSettings?.behavioralActionTriggerReferences?.trim();
            if (!triggerRef) {
                throw new actions_core_1.IntegrationError('Behavioral Action trigger references cannot be empty', 'Invalid Audience Settings', 400);
            }
            return { externalId: triggerRef };
        },
        async getAudience(_, getAudienceInput) {
            return {
                externalId: getAudienceInput.externalId
            };
        }
    },
    actions: {
        triggerBehavioralAction: triggerBehavioralAction_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map