"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.destination = exports.segmentEventSource = void 0;
const tslib_1 = require("tslib");
const types_1 = require("./types");
const shim_1 = require("../../runtime/shim");
const trackEvent_1 = tslib_1.__importDefault(require("./trackEvent"));
const identifyUser_1 = tslib_1.__importDefault(require("./identifyUser"));
const viewedPage_1 = tslib_1.__importDefault(require("./viewedPage"));
const actions_core_1 = require("@segment/actions-core");
exports.segmentEventSource = 'segment-browser-actions';
exports.destination = {
    name: 'Fullstory (Actions)',
    slug: 'actions-fullstory',
    mode: 'device',
    presets: [
        {
            name: 'Track Event',
            subscribe: 'type = "track"',
            partnerAction: 'trackEvent',
            mapping: actions_core_1.defaultValues(trackEvent_1.default.fields)
        },
        {
            name: 'Identify User',
            subscribe: 'type = "identify"',
            partnerAction: 'identifyUser',
            mapping: actions_core_1.defaultValues(identifyUser_1.default.fields)
        }
    ],
    settings: {
        orgId: {
            description: 'The organization ID for FullStory.',
            label: 'FS Org',
            type: 'string',
            required: true
        },
        debug: {
            description: 'Enables FullStory debug mode.',
            label: 'Debug mode',
            type: 'boolean',
            required: false,
            default: false
        },
        recordOnlyThisIFrame: {
            description: 'Enables FullStory inside an iframe.',
            label: 'Capture only this iFrame',
            type: 'boolean',
            required: false,
            default: false
        }
    },
    actions: {
        trackEvent: trackEvent_1.default,
        identifyUser: identifyUser_1.default,
        viewedPage: viewedPage_1.default
    },
    initialize: async ({ settings }, dependencies) => {
        types_1.FSPackage.init(settings);
        await dependencies.resolveWhen(() => Object.prototype.hasOwnProperty.call(window, 'FS'), 100);
        return window.FS;
    }
};
exports.default = shim_1.browserDestination(exports.destination);
//# sourceMappingURL=index.js.map