Object.defineProperty(exports, "__esModule", { value: true });
module.exports = function (ActionAPI) {
    ActionAPI.handle(function (properties, status, deck) {
        var connectionID = properties.connectionID != undefined && properties.connectionID.length > 0
            ? properties.connectionID
            : 'none';
        var speed = properties.speed != undefined && properties.speed.length > 0 ? properties.speed : 'offline';
        if (connectionID != 'none') {
            var connection = ActionAPI.getConnection('wirecast-bridge', connectionID);
            if (connection && connection.instance) {
                connection.instance
                    .setTransitionSpeed(speed)
                    .then(function () { return status("Transition speed has been set to ".concat(speed)); })
                    .catch(function (error) { return status(error, 'error'); });
            }
        }
        else
            status('No connection specfied', 'error');
    });
    ActionAPI.onOpenEditor(function (EditorAPI, properties) {
        var connectionID = properties.connectionID != undefined && properties.connectionID.length > 0
            ? properties.connectionID
            : 'none';
        var speed = properties.speed != undefined && properties.speed.length > 0 ? properties.speed : 'offline';
        var connectionField = {
            id: 'connectionID',
            name: 'Connection',
            value: connectionID,
            type: 'connection',
            connectionType: 'wirecast-bridge'
        };
        var speedField = {
            id: 'speed',
            name: 'Speed',
            type: 'select',
            value: speed,
            values: []
        };
        if (connectionID != 'none')
            speedField.values = [
                { id: 'slowest', text: 'Slowest' },
                { id: 'slow', text: 'Slow' },
                { id: 'normal', text: 'Normal' },
                { id: 'faster', text: 'Faster' },
                { id: 'fastest', text: 'Fastest' }
            ];
        EditorAPI.setFields([
            connectionField,
            speedField
        ]);
        EditorAPI.onFieldChanges(function (fields) {
            var fieldObject = EditorAPI.tools.objectifyFieldsValues(fields);
            connectionField.value = fieldObject.connectionID;
            speedField.value = fieldObject.speed;
            if (connectionID != fieldObject.connectionID) {
                connectionID = fieldObject.connectionID;
                speedField.values =
                    connectionID != 'none'
                        ? [
                            { id: 'slowest', text: 'Slowest' },
                            { id: 'slow', text: 'Slow' },
                            { id: 'normal', text: 'Normal' },
                            { id: 'faster', text: 'Faster' },
                            { id: 'fastest', text: 'Fastest' }
                        ]
                        : [];
                EditorAPI.setFields([
                    connectionField,
                    speedField
                ]);
            }
            EditorAPI.saveProperties({ connectionID: fieldObject.connectionID, speed: fieldObject.speed });
        });
    });
};
//# sourceMappingURL=transitionSpeed.js.map