"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const cartFields_1 = require("../fields/cartFields");
const commonFields_1 = require("../fields/commonFields");
const customerFields_1 = require("../fields/customerFields");
const searchFields_1 = require("../fields/searchFields");
const routes_1 = require("../routes");
const transform_payload_1 = require("./transform-payload");
const action = {
    title: 'Save Search Event',
    description: 'Save a search event.',
    fields: {
        ...commonFields_1.commonFields,
        ...customerFields_1.customerFields,
        ...cartFields_1.cartFields,
        ...searchFields_1.searchFields,
        eventName: {
            label: 'Search Event Name',
            type: 'string',
            description: 'The name of the Search event to track.',
            required: true,
            readOnly: true,
            choices: [{ label: 'search_submitted', value: 'search_submitted' }],
            default: 'search_submitted'
        }
    },
    perform: (request, data) => {
        const transformedPayload = (0, transform_payload_1.transformPayload)(data.payload);
        const payload = {
            src: 'SEGMENT',
            data: [transformedPayload]
        };
        return request(routes_1.baseURL + (0, routes_1.eventsEndpoint)(data.settings.workspaceId), {
            method: 'post',
            json: payload
        });
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map