"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.destination = void 0;
const tslib_1 = require("tslib");
const actions_core_1 = require("@segment/actions-core");
const shim_1 = require("../../runtime/shim");
const identifyUser_1 = tslib_1.__importDefault(require("./identifyUser"));
const trackEvent_1 = tslib_1.__importDefault(require("./trackEvent"));
exports.destination = {
    name: 'PlayerZero Web',
    slug: 'actions-playerzero-web',
    mode: 'device',
    settings: {
        projectId: {
            label: 'PlayerZero Project ID',
            description: 'The Project ID where you want to send data. You can find this ID on the [Project Data Collection](https://go.playerzero.app/setting/data) page.',
            type: 'string',
            required: true
        }
    },
    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)
        }
    ],
    initialize: async ({ settings }, deps) => {
        await deps.loadScript(`https://go.playerzero.app/record/${settings.projectId}`);
        await deps.resolveWhen(() => Object.prototype.hasOwnProperty.call(window, 'playerzero'), 250);
        return window.playerzero;
    },
    actions: {
        trackEvent: trackEvent_1.default,
        identifyUser: identifyUser_1.default
    }
};
exports.default = shim_1.browserDestination(exports.destination);
//# sourceMappingURL=index.js.map