Object.defineProperty(exports, "__esModule", { value: true });
var Atem = require('atem-connection').Atem;
module.exports = function (ActionAPI) {
    ActionAPI.onExecute(function (properties, status) {
        var connectionID = properties.connectionID != undefined ? properties.connectionID : "none";
        if (connectionID != 'none') {
            var connection = ActionAPI.getConnection('bm_atem', connectionID);
            if (connection && connection.instance) {
                var atem = connection.instance;
                atem.fadeToBlack().then(function () {
                    status("Atem fade to black", 'info');
                }).catch(function (error) {
                    status("Error whilst setting atem fadetoblack: ".concat(error), 'error');
                });
            }
            else
                status('Atem is not online', 'error');
        }
        else
            status('No connection specified', 'error');
    });
    ActionAPI.onOpenEditor(function (EditorAPI, properties) {
        var connectionID = properties.connectionID != undefined ? properties.connectionID : "none";
        EditorAPI.onFieldChanges(function (fields) {
            var fieldObject = EditorAPI.tools.objectifyFieldsValues(fields);
            connectionID = fieldObject.connectionID;
            EditorAPI.saveProperties({ connectionID: connectionID });
        });
        EditorAPI.setFields([{
                id: 'connectionID',
                name: "Connection",
                type: "connection",
                connectionType: "bm_atem",
                value: connectionID
            }]);
    });
};
//# sourceMappingURL=fadeToBlack.js.map