import Blockly from 'blockly';
import { pythonGenerator } from "blockly/python";
import CategoryColors from './define_color'

Blockly.Python = pythonGenerator
Blockly.Blocks.CocoRobo_return = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            nextStatement: null,
            previousStatement: null,
            colour: CategoryColors.Logic,
            helpUrl: Blockly.Msg.CocoRobo_RETURN_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_RETURN_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_RETURN_MESSAGE0,
            args0: [{
                type: "input_value",
                name: "VAR"
            }]
        })
    }
};

Blockly.Blocks.CocoRobo_try_except = {
    init: function () {
        this.jsonInit({
            message0: "",
            previousStatement: null,
            nextStatement: null,
            colour: CategoryColors.Logic,
            tooltip: Blockly.Msg.CocoRobo_try_except_TOOLTIP,
            helpUrl: ""
        });
        this.appendStatementInput("TRY").appendField("try");
        this.appendStatementInput("EXCEPT").appendField("except");
    }
};


Blockly.Blocks.CocoRobo_try_except_finally = {
    init: function () {
        this.jsonInit({
            message0: "",
            previousStatement: null,
            nextStatement: null,
            colour: CategoryColors.Logic,
            tooltip: Blockly.Msg.CocoRobo_try_except_finally_TOOLTIP,
            helpUrl: ""
        });
        this.appendStatementInput("TRY").appendField("try");
        this.appendStatementInput("EXCEPT").appendField("except");
        this.appendStatementInput("FINALLY").appendField("finally")
    }
};


Blockly.Blocks.CocoRobo_type = {
    init: function () {
        this.jsonInit({
            message0: Blockly.Msg.CocoRobo_TYPE_MESSAGE0,
            args0: [{
                type: "input_value",
                name: "VAR"
            }],
            output: null,
            colour: CategoryColors.Logic,
            tooltip: Blockly.Msg.CocoRobo_TYPE_TOOLTIP,
            helpUrl: Blockly.Msg.CocoRobo_TYPE_HELPURL
        })
    }
};


Blockly.Blocks.CocoRobo_type_is = {
    init: function () {
        this.jsonInit({
            message0: Blockly.Msg.CocoRobo_TYPE_IS_MESSAGE0,
            args0: [{
                type: "input_value",
                name: "VAR"
            }, {
                name: "TYPE",
                options: [
                    ["int", "int"],
                    ["float", "float"],
                    ["bool", "bool"],
                    ["str", "str"],
                    ["list", "list"],
                    ["tuple", "tuple"],
                    ["set", "set"],
                    ["dict", "dict"],
                    ["bytes", "bytes"],
                    ["bytearray", "bytearray"],
                    ["complex", "complex"]
                ],
                type: "field_dropdown"
            }],
            output: "Boolean",
            colour: CategoryColors.Logic,
            // tooltip: Blockly.Msg.CocoRobo_TYPE_IS_TOOLTIP,
            helpUrl: Blockly.Msg.CocoRobo_TYPE_IS_HELPURL
        });
        var thisBlock = this;
        this.setTooltip(function () {
            return Blockly.Msg.CocoRobo_TYPE_IS_TOOLTIP.replace('%2',
                thisBlock.getFieldValue('TYPE'));
        });
    }
};
Blockly.Blocks.CocoRobo_eval = {
    init: function () {
        this.jsonInit({
            message0: Blockly.Msg.CocoRobo_EVAL_MESSAGE0,
            args0: [{
                check: "String",
                type: "input_value",
                name: "VAR"
            }],
            output: null,
            colour: CategoryColors.Logic,
            tooltip: Blockly.Msg.CocoRobo_EVAL_TOOLTIP,
            helpUrl: Blockly.Msg.CocoRobo_EVAL_HELPURL
        })
    }
};
export default Blockly;