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

Blockly.Python = pythonGenerator
Blockly.Blocks['custom_text_block'] = {
    init: function () {
        this.appendDummyInput()
            .appendField(Blockly.Msg.numpy_mnist_clear)
            .appendField(new Blockly.FieldTextInput("张三丰"), "TEXT_INPUT");
        // this.setOutput(true, null);
        this.setPreviousStatement(true, null)
        this.setNextStatement(true, null)
        this.setTooltip("");
        this.setHelpUrl("");
        this.setStyle('custom_text_blocks')
    }
};
Blockly.Blocks["CocoRobo_return"] = {
    init:function(){
        this.appendDummyInput().appendField("返回一个值")
        this.setPreviousStatement(true, null)
        this.setNextStatement(true, null)
        this.setStyle('custom_text_blocks')
    }
}
Blockly.Blocks.CocoRobo_try_except = {
    init:function(){
        this.appendStatementInput("TRY").appendField("try");
        this.appendStatementInput("EXCEPT").appendField("except");
        this.setStyle('custom_text_blocks')
    }
}

Blockly.Blocks.CocoRobo_try_except_finally = {
    init: function () {
        this.appendStatementInput("TRY").appendField("try");
        this.appendStatementInput("EXCEPT").appendField("except");
        this.appendStatementInput("FINALLY").appendField("finally")
    }
};

Blockly.Blocks.CocoRobo_type = {
    init: function () {
        this.jsonInit({
            message0: "值 %1 的类型",
            args0: [{
                type: "input_value",
                name: "VAR"
            }],
            output: null,
            colour: CategoryColors.Logic,
            tooltip: "返回当前值的类型",
            helpUrl: ""
        })
    }
};
Blockly.Blocks.CocoRobo_type_is = {
    init: function () {
        this.jsonInit({
            message0: '值 %1 的类型为 %2',
            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: '计算表达式 %1 的结果',
            args0: [{
                check: "String",
                type: "input_value",
                name: "VAR"
            }],
            output: null,
            colour: CategoryColors.Logic,
            tooltip: '计算字符串表达式，并返回结果',
            helpUrl: ""
        })
    }
};

Blockly.controls = {
    HUE:"#9d64fd"
}
Blockly.Blocks.controls_repeat_forever = {
    init: function () {
        this.jsonInit({
            message0: Blockly.Msg.CONTROLS_REPEAT_FOREVER,
            previousStatement: null,
            nextStatement: null,
            colour: Blockly.controls.HUE,
            tooltip: Blockly.Msg.CONTROLS_REPEAT_FOREVER_TOOLTIP,
            helpUrl: Blockly.Msg.CONTROLS_REPEAT_HELPURL
        });
        this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO)
    }
};
Blockly.Blocks.controls_repeat_ext = {
    init: function () {
        this.jsonInit({
            message0: Blockly.Msg.CONTROLS_REPEAT_TITLE,
            args0: [{
                type: "input_value",
                name: "TIMES",
                check: "Number"
            }],
            previousStatement: null,
            nextStatement: null,
            colour: Blockly.controls.HUE,
            tooltip: Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,
            helpUrl: Blockly.Msg.CONTROLS_REPEAT_HELPURL
        });
        this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO)
    }
};
Blockly.Blocks.controls_repeat = {
    init: function () {
        this.jsonInit({
            message0: Blockly.Msg.CONTROLS_REPEAT_TITLE,
            args0: [{
                type: "field_number",
                name: "TIMES",
                value: 10,
                min: 0,
                precision: 1
            }],
            previousStatement: null,
            nextStatement: null,
            colour: Blockly.controls.HUE,
            tooltip: Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,
            helpUrl: Blockly.Msg.CONTROLS_REPEAT_HELPURL
        });
        this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO)
    }
};
Blockly.Blocks.controls_whileUntil = {
    init: function () {
        var a = [[Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE, "WHILE"], [Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL, "UNTIL"]];
        this.setHelpUrl(Blockly.Msg.CONTROLS_WHILEUNTIL_HELPURL);
        this.setColour(Blockly.controls.HUE);
        this.appendValueInput("BOOL").setCheck("Boolean").appendField(new Blockly.FieldDropdown(a), "MODE");
        this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_WHILEUNTIL_INPUT_DO);
        this.setPreviousStatement(!0);
        this.setNextStatement(!0);
        var b = this;
        this.setTooltip(function () {
            var a = b.getFieldValue("MODE");
            return {
                WHILE: Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE,
                UNTIL: Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL
            }[a]
        })
    }
};
Blockly.Blocks.controls_for = {
    init: function () {
        this.jsonInit({
            message0: Blockly.Msg.CONTROLS_FOR_TITLE,
            args0: [{
                type: "field_variable",
                name: "VAR",
                variable: null
            }, {
                type: "input_value",
                name: "FROM",
                check: "Number",
                align: "RIGHT"
            }, {
                type: "input_value",
                name: "TO",
                check: "Number",
                align: "RIGHT"
            }, {
                type: "input_value",
                name: "BY",
                check: "Number",
                align: "RIGHT"
            }],
            inputsInline: !0,
            previousStatement: null,
            nextStatement: null,
            colour: Blockly.controls.HUE,
            helpUrl: Blockly.Msg.CONTROLS_FOR_HELPURL
        });
        this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_FOR_INPUT_DO);
        var a = this;
        this.setTooltip(function () {
            return Blockly.Msg.CONTROLS_FOR_TOOLTIP.replace("%1", a.getFieldValue("VAR"))
        })
    },
    customContextMenu: function (a) {
        if (!this.isCollapsed()) {
            var b = {
                enabled: !0
            }
                , c = this.getFieldValue("VAR");
            b.text = Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1", c);
            c = goog.dom.createDom("field", null, c);
            c.setAttribute("name", "VAR");
            c = goog.dom.createDom("block", null, c);
            c.setAttribute("type", "variables_get");
            b.callback = Blockly.ContextMenu.callbackFactory(this, c);
            a.push(b)
        }
    }
};
Blockly.Blocks.controls_forEach = {
    init: function () {
        this.jsonInit({
            message0: Blockly.Msg.CONTROLS_FOREACH_TITLE,
            args0: [{
                type: "field_variable",
                name: "VAR",
                variable: null
            }, {
                type: "input_value",
                name: "LIST",
                check: "Array"
            }],
            previousStatement: null,
            nextStatement: null,
            colour: Blockly.controls.HUE,
            helpUrl: Blockly.Msg.CONTROLS_FOREACH_HELPURL
        });
        this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_FOREACH_INPUT_DO);
        var a = this;
        this.setTooltip(function () {
            return Blockly.Msg.CONTROLS_FOREACH_TOOLTIP.replace("%1", a.getFieldValue("VAR"))
        })
    },
    customContextMenu: Blockly.Blocks.controls_for.customContextMenu
};
Blockly.Blocks.controls_flow_statements = {
    init: function () {
        var a = [[Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK, "BREAK"], [Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE, "CONTINUE"]];
        this.setHelpUrl(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_HELPURL);
        this.setColour(Blockly.controls.HUE);
        this.appendDummyInput().appendField(new Blockly.FieldDropdown(a), "FLOW");
        this.setPreviousStatement(!0);
        var b = this;
        this.setTooltip(function () {
            var a = b.getFieldValue("FLOW");
            return {
                BREAK: Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK,
                CONTINUE: Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE
            }[a]
        })
    },
    onchange: function (a) {
        if (!this.workspace.isDragging()) {
            a = !1;
            var b = this;
            do {
                if (-1 != this.LOOP_TYPES.indexOf(b.type)) {
                    a = !0;
                    break
                }
                b = b.getSurroundParent()
            } while (b); a ? (this.setWarningText(null),
                this.isInFlyout || this.setDisabled(!1)) : (this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING),
                    this.isInFlyout || this.getInheritedDisabled() || this.setDisabled(!0))
        }
    },
    LOOP_TYPES: "controls_repeat_forever controls_repeat controls_repeat_ext controls_forEach controls_for controls_whileUntil tello_repeat_forever".split(" ")
};

// math
Blockly.math={
    HUE:"#5472ea"
}
/* additional math */
Blockly.Blocks['math_degrad'] = {
    init: function () {
        this.appendValueInput("convert")
            .setCheck(null)
            .appendField(new Blockly.FieldDropdown([
                [Blockly.Msg.math_degrad_rad, "radians"],
                [Blockly.Msg.math_degrad_deg, "degrees"]
            ]), "rad_deg");
        this.setOutput(true, null);
        this.setColour("#5472ea");
        // this.setTooltip("");
        this.setHelpUrl("");

        var thisBlock = this;
        this.setTooltip(function () {
            var mode = thisBlock.getFieldValue('rad_deg');
            var TOOLTIPS = {
                'radians': Blockly.Msg.Math_Degrad_RAD_TOOLTIP,
                'degrees': Blockly.Msg.Math_Degrad_DEG_TOOLTIP
            };
            return TOOLTIPS[mode];
        });
    }
};

Blockly.Blocks.math_angle = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "Number",
            colour: CategoryColors.Math,
            helpUrl: "",
            tooltip: "",
            message0: "%1",
            args0: [{
                name: "angle",
                type: "field_angle"
            }]
        })
    }
};


Blockly.Blocks.math_keep_decimal = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "Number",
            colour: CategoryColors.Math,
            helpUrl: Blockly.Msg.MATH_KEEP_DECIMAL_HELPURL,
            tooltip: Blockly.Msg.MATH_KEEP_DECIMAL_TOOLTIP,
            message0: Blockly.Msg.MATH_KEEP_DECIMAL_MESSAGE0,
            args0: [{
                check: "Number",
                type: "input_value",
                name: "NUM"
            }, {
                check: "Number",
                type: "input_value",
                name: "PLACE"
            }]
        })
    }
};
Blockly.Blocks.math_division_consult = {
    init: function () {
        this.jsonInit({
            message0: Blockly.Msg.MATH_DIVISION_CONSULT_TITLE,
            args0: [{
                type: "input_value",
                name: "DIVIDEND",
                check: "Number"
            }, {
                type: "input_value",
                name: "DIVISOR",
                check: "Number"
            }],
            inputsInline: !0,
            output: "Number",
            colour: Blockly.math.HUE,
            tooltip: Blockly.Msg.MATH_DIVISION_CONSULT_TOOLTIP,
            helpUrl: Blockly.Msg.MATH_DIVISION_CONSULT_HELPURL
        })
    }
};
Blockly.Blocks.labplus_mapping = {
    init: function () {
        this.jsonInit({
            colour: 230,
            args0: [{
                name: "inputNum",
                type: "input_value",
                check: "Number"
            }, {
                name: "bMin",
                type: "input_value",
                check: "Number"
            }, {
                name: "bMax",
                type: "input_value",
                check: "Number"
            }, {
                name: "cMin",
                type: "input_value",
                check: "Number"
            }, {
                name: "cMax",
                type: "input_value",
                check: "Number"
            }],
            output: "Number",
            message0: Blockly.Msg.labplus_mapping_MESSAGE0,
            tooltip: Blockly.Msg.labplus_mapping_TOOLTIP,
            helpUrl: Blockly.Msg.labplus_mapping_HELPURL
        })
    }
};

Blockly.Blocks.math_random_randrange = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "Number",
            colour: CategoryColors.Math,
            helpUrl: Blockly.Msg.MATH_RANDOM_RANDRANGE_HELPURL,
            tooltip: Blockly.Msg.MATH_RANDOM_RANDRANGE_TOOLTIP,
            message0: Blockly.Msg.MATH_RANDOM_RANDRANGE_MESSAGE0,
            args0: [{
                check: "Number",
                type: "input_value",
                name: "start"
            }, {
                check: "Number",
                type: "input_value",
                name: "stop"
            }, {
                check: "Number",
                type: "input_value",
                name: "step"
            }]
        })
    }
};
Blockly.Blocks.math_convert = {
    init: function () {
        this.jsonInit({
            message0: Blockly.Msg.MATH_CONVERT_MESSAGE0,
            args0: [{
                type: "field_dropdown",
                options: [["int", "int"], ["float", "float"]],
                name: "TYPE0"
            }, {
                type: "input_value",
                name: "INPUT0",
                check: ["Number", "String"]
            }],
            output: "Number",
            colour: CategoryColors.Math,
            tooltip: Blockly.Msg.MATH_CONVERT_TOOLTIP,
            helpUrl: Blockly.Msg.MATH_CONVERT_HELPURL
        })
    }
};
Blockly.Blocks.math_number_bits_ops = {
    init: function () {
        this.jsonInit({
            message0: Blockly.Msg.MATH_NUMBER_BITS_OPS_MESSAGE0,
            args0: [{
                type: "input_value",
                name: "A",
                check: "Number"
            }, {
                type: "field_dropdown",
                options: [["|", " | "], ["&", " & "], ["^", " ^ "], ["<<", " << "], [">>", " >> "]],
                name: "OP"
            }, {
                type: "input_value",
                name: "B",
                check: "Number"
            }],
            inputsInline: !0,
            output: "Number",
            colour: CategoryColors.Math,
            tooltip: Blockly.Msg.MATH_NUMBER_BITS_OPS_TOOLTIP,
            helpUrl: Blockly.Msg.MATH_NUMBER_BITS_OPS_HELPURL
        })
    }
};
Blockly.Blocks.bit_inversion = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "Number",
            colour: CategoryColors.Math,
            helpUrl: Blockly.Msg.BIT_INVERSION_HELPURL,
            tooltip: Blockly.Msg.BIT_INVERSION_TOOLTIP,
            message0: Blockly.Msg.BIT_INVERSION_MESSAGE0,
            args0: [{
                type: "input_value",
                name: "data"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_ten_convert_to = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "String",
            colour: CategoryColors.Math,
            helpUrl: Blockly.Msg.CocoRobo_TEN_CONVERT_TO_HELPURL,
            // tooltip: Blockly.Msg.CocoRobo_TEN_CONVERT_TO_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_TEN_CONVERT_TO_MESSAGE0,
            args0: [{
                check: "Number",
                type: "input_value",
                name: "int_num"
            }, {
                options: [
                    [Blockly.Msg.CocoRobo_BIN, "bin"],
                    [Blockly.Msg.CocoRobo_OCT, "oct"],
                    [Blockly.Msg.CocoRobo_HEX, "hex"]
                ],
                type: "field_dropdown",
                name: "ten_convert_to"
            }]
        });
        var thisBlock = this;
        this.setTooltip(function () {
            return Blockly.Msg.CocoRobo_TEN_CONVERT_TO_TOOLTIP.replace('%2',
                thisBlock.getFieldValue('ten_convert_to'));
        });
    }
};
Blockly.Blocks.CocoRobo_convert_to_ten = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "Number",
            colour: CategoryColors.Math,
            helpUrl: Blockly.Msg.CocoRobo_CONVERT_TO_TEN_HELPURL,
            // tooltip: Blockly.Msg.CocoRobo_CONVERT_TO_TEN_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_CONVERT_TO_TEN_MESSAGE0,
            args0: [{
                options: [
                    [Blockly.Msg.CocoRobo_BIN, "2"],
                    [Blockly.Msg.CocoRobo_OCT, "8"],
                    [Blockly.Msg.CocoRobo_HEX, "16"]
                ],
                type: "field_dropdown",
                name: "convert_choice"
            }, {
                check: "String",
                type: "input_value",
                name: "convert_str"
            }]
        });
        var thisBlock = this;
        this.setTooltip(function () {
            var mode = thisBlock.getFieldValue('convert_choice');
            var TOOLTIPS = {
                '2': Blockly.Msg.CocoRobo_CONVERT_TO_TEN_TOOLTIP.replace('%2', "bin"),
                '8': Blockly.Msg.CocoRobo_CONVERT_TO_TEN_TOOLTIP.replace('%2', "oct"),
                '16': Blockly.Msg.CocoRobo_CONVERT_TO_TEN_TOOLTIP.replace('%2', "hex")
            };
            return TOOLTIPS[mode];
        });
    }
};
Blockly.Blocks.CocoRobo_ten_convert_to = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "String",
            colour: CategoryColors.Math,
            helpUrl: Blockly.Msg.CocoRobo_TEN_CONVERT_TO_HELPURL,
            // tooltip: Blockly.Msg.CocoRobo_TEN_CONVERT_TO_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_TEN_CONVERT_TO_MESSAGE0,
            args0: [{
                check: "Number",
                type: "input_value",
                name: "int_num"
            }, {
                options: [
                    [Blockly.Msg.CocoRobo_BIN, "bin"],
                    [Blockly.Msg.CocoRobo_OCT, "oct"],
                    [Blockly.Msg.CocoRobo_HEX, "hex"]
                ],
                type: "field_dropdown",
                name: "ten_convert_to"
            }]
        });
        var thisBlock = this;
        this.setTooltip(function () {
            return Blockly.Msg.CocoRobo_TEN_CONVERT_TO_TOOLTIP.replace('%2',
                thisBlock.getFieldValue('ten_convert_to'));
        });
    }
};
Blockly.Blocks.CocoRobo_high_low = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "Number",
            colour: CategoryColors.Pin,
            helpUrl: Blockly.Msg.CocoRobo_HIGH_LOW_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_HIGH_LOW_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_HIGH_LOW_MESSAGE0,
            args0: [{
                options: [
                    ["HIGH", "1"],
                    ["LOW", "0"]
                ],
                type: "field_dropdown",
                name: "high_low"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_start_new_thread = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            nextStatement: null,
            previousStatement: null,
            colour: CategoryColors.Event,
            helpUrl: Blockly.Msg.CocoRobo_START_NEW_THREAD_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_START_NEW_THREAD_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_START_NEW_THREAD_MESSAGE0,
            args0: [{
                options: [
                    ["1", "1"],
                    ["2", "2"],
                    ["3", "3"],
                    ["4", "4"]
                ],
                type: "field_dropdown",
                name: "thread_name"
            }]
        });
        this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO)
    }
};
Blockly.Blocks.CocoRobo_lock_object_acquire_lock = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            nextStatement: null,
            previousStatement: null,
            colour: CategoryColors.Event,
            helpUrl: Blockly.Msg.CocoRobo_LOCK_OBJECT_ACQUIRE_LOCK_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_LOCK_OBJECT_ACQUIRE_LOCK_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_LOCK_OBJECT_ACQUIRE_LOCK_MESSAGE0,
            args0: [{
                type: "field_input",
                name: "thread_lock_object",
                text: "lock"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_ten_converted_to_bytes = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: null,
            colour: CategoryColors.Math,
            helpUrl: Blockly.Msg.CocoRobo_TEN_CONVERTED_TO_BYTES_HELPURL,
            // tooltip: Blockly.Msg.CocoRobo_TEN_CONVERTED_TO_BYTES_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_TEN_CONVERTED_TO_BYTES_MESSAGE0,
            args0: [{
                options: [
                    ["2", "'\x3cH'"],
                    ["4", "'\x3cL'"]
                ],
                type: "field_dropdown",
                name: "convert_choice"
            }, {
                check: "Number",
                type: "input_value",
                name: "convert_num"
            }]
        });
        var thisBlock = this;
        this.setTooltip(function () {
            var mode = thisBlock.getFieldValue('convert_choice');
            var TOOLTIPS = {
                "'\x3cHH'": Blockly.Msg.CocoRobo_TEN_CONVERTED_TO_BYTES_TOOLTIP.replace('%1', "2"),
                "'\x3cLL'": Blockly.Msg.CocoRobo_TEN_CONVERTED_TO_BYTES_TOOLTIP.replace('%1', "4")
            };
            return TOOLTIPS[mode];
        });
    }
};
Blockly.Blocks.CocoRobo_int_to_chr = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "String",
            colour: CategoryColors.Math,
            helpUrl: Blockly.Msg.CocoRobo_INT_TO_CHR_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_INT_TO_CHR_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_INT_TO_CHR_MESSAGE0,
            args0: [{
                check: "Number",
                type: "input_value",
                name: "convert_num"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_hcsr04_obj = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            nextStatement: null,
            previousStatement: null,
            colour: CategoryColors.General,
            helpUrl: Blockly.Msg.CocoRobo_HCSR04_OBJ_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_HCSR04_OBJ_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_HCSR04_OBJ_MESSAGE0,
            args0: [{
                text: "hcsr04",
                type: "field_input",
                name: "hcsr04_name"
            }, {
                check: "Number",
                type: "input_value",
                name: "trigger"
            }, {
                check: "Number",
                type: "input_value",
                name: "echo"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_hcsr04_distance = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "Number",
            colour: CategoryColors.General,
            helpUrl: Blockly.Msg.CocoRobo_HCSR04_DISTANCE_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_HCSR04_DISTANCE_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_HCSR04_DISTANCE_MESSAGE0,
            args0: [{
                text: "hcsr04",
                type: "field_input",
                name: "hcsr04_name"
            }, {
                options: [
                    ["mm", "mm"],
                    ["cm", "cm"]
                ],
                type: "field_dropdown",
                name: "unit"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_hcsr04_distance_mm = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "Number",
            colour: CategoryColors.Pin,
            helpUrl: Blockly.Msg.CocoRobo_HCSR04_DISTANCE_MM_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_HCSR04_DISTANCE_MM_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_HCSR04_DISTANCE_MM_MESSAGE0,
            args0: [{
                text: "hcsr04",
                type: "field_input",
                name: "hcsr04_name"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_pm2_5_MIC = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "Number",
            colour: CategoryColors.General,
            helpUrl: Blockly.Msg.CocoRobo_PM2_5_MIC_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_PM2_5_MIC_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_PM2_5_MIC_MESSAGE0,
            args0: [{
                check: "Number",
                type: "input_value",
                name: "rx"
            }, {
                options: [
                    ["PM1.0ug/m3", "_pm_data[0]"],
                    ["PM2.5ug/m3", "_pm_data[1]"],
                    ["PM10ug/m3", "_pm_data[2]"]
                ],
                type: "field_dropdown",
                name: "unit"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_pm2_5_LitresAir = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "Number",
            colour: CategoryColors.General,
            helpUrl: Blockly.Msg.CocoRobo_PM2_5_LitresAir_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_PM2_5_LitresAir_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_PM2_5_LitresAir_MESSAGE0,
            args0: [{
                check: "Number",
                type: "input_value",
                name: "rx"
            }, {
                options: [
                    ["0.3um", "_pm_data[3]"],
                    ["0.5um", "_pm_data[4]"],
                    ["1um", "_pm_data[5]"],
                    ["2.5um", "_pm_data[6]"],
                    ["5um", "_pm_data[7]"],
                    ["10um", "_pm_data[8]"]
                ],
                type: "field_dropdown",
                name: "unit"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_mac_address = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "String",
            colour: "X" == SOFTWARE_KEY ? CategoryColors.System : CategoryColors.Wifi,
            helpUrl: Blockly.Msg.CocoRobo_MAC_ADDRESS_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_MAC_ADDRESS_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_MAC_ADDRESS_MESSAGE0
        })
    }
};
Blockly.Blocks.CocoRobo_ujson_loads = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: null,
            colour: CategoryColors.Text,
            helpUrl: Blockly.Msg.CocoRobo_UJSON_LOADS_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_UJSON_LOADS_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_UJSON_LOADS_MESSAGE0,
            args0: [{
                check: "String",
                type: "input_value",
                name: "data"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_code_annotation = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            nextStatement: null,
            previousStatement: null,
            // output: null,
            colour: CategoryColors.Text,
            helpUrl: Blockly.Msg.CocoRobo_code_annotation_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_code_annotation_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_code_annotation_MESSAGE0,
            args0: [{
                check: "String",
                type: "input_value",
                name: "data"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_ujson_dumps = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "String",
            colour: CategoryColors.Text,
            helpUrl: Blockly.Msg.CocoRobo_UJSON_DUMPS_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_UJSON_DUMPS_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_UJSON_DUMPS_MESSAGE0,
            args0: [{
                type: "input_value",
                name: "data"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_base64_to_data = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: null,
            colour: CategoryColors.Math,
            helpUrl: Blockly.Msg.CocoRobo_BASE64_TO_DATA_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_BASE64_TO_DATA_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_BASE64_TO_DATA_MESSAGE0,
            args0: [{
                type: "input_value",
                name: "data"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_data_to_base64 = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: null,
            colour: CategoryColors.Math,
            helpUrl: Blockly.Msg.CocoRobo_DATA_TO_BASE64_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_DATA_TO_BASE64_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_DATA_TO_BASE64_MESSAGE0,
            args0: [{
                type: "input_value",
                name: "data"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_hex_to_bin_str = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: null,
            colour: CategoryColors.Math,
            helpUrl: Blockly.Msg.CocoRobo_HEX_TO_BIN_STR_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_HEX_TO_BIN_STR_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_HEX_TO_BIN_STR_MESSAGE0,
            args0: [{
                check: "String",
                type: "input_value",
                name: "convert_chr"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_str_to_hex = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: null,
            colour: CategoryColors.Math,
            helpUrl: Blockly.Msg.CocoRobo_STR_TO_HEX_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_STR_TO_HEX_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_STR_TO_HEX_MESSAGE0,
            args0: [{
                check: "String",
                type: "input_value",
                name: "convert_chr"
            }]
        })
    }
};
Blockly.Blocks.CocoRobo_chr_to_int = {
    init: function () {
        this.jsonInit({
            inputsInline: !0,
            output: "String",
            colour: CategoryColors.Math,
            helpUrl: Blockly.Msg.CocoRobo_CHR_TO_INT_HELPURL,
            tooltip: Blockly.Msg.CocoRobo_CHR_TO_INT_TOOLTIP,
            message0: Blockly.Msg.CocoRobo_CHR_TO_INT_MESSAGE0,
            args0: [{
                check: "String",
                type: "input_value",
                name: "convert_chr"
            }]
        })
    }
};


export default Blockly