// logical_blocks.js

/**
 * Logical Blocks Category Definitions
 *
 * This file defines a set of logical blocks for Blockly. These blocks enable
 * comparison operations, logical AND/OR operations, boolean condition checks,
 * and flag evaluations within a strategy or workflow. The use of "dynamic_value"
 * types allows for flexible chaining with other blocks, enhancing the modularity
 * and interconnectivity of the Blockly environment.
 *
 * Ensure that this file is loaded **after** the `json_base_generator.js` and any other
 * necessary Blockly setup files to maintain proper loading order and functionality.
 */
export function defineLogicalBlocks() {

    /**
     * comparison Block
     *
     * Description:
     * Compares two numerical or dynamic values using operators like > (greater than),
     * < (less than), or == (equal to). Outputs a Boolean value based on the comparison result.
     */
    Blockly.defineBlocksWithJsonArray([{
        "type": "comparison",
        "message0": "%1 %2 %3",
        "args0": [
          {
            "type": "input_value",
            "name": "LEFT",
            "check": ["number", "dynamic_value"],
            "align": "RIGHT"
          },
          {
            "type": "field_dropdown",
            "name": "OPERATOR",
            "options": [
              [">", ">"],
              ["<", "<"],
              ["==", "=="]
            ]
          },
          {
            "type": "input_value",
            "name": "RIGHT",
            "check": ["number", "dynamic_value"],
            "align": "LEFT"
          }
        ],
        "inputsInline": true,
        "output": "Boolean",
        "colour": 160,
        "tooltip": "Compare two numerical or dynamic values using operators like > (greater than), < (less than), or == (equal to). Outputs a Boolean value based on the comparison result.",
        "helpUrl": "https://example.com/docs/comparison"
    }]);

    /**
     * logical_and Block
     *
     * Description:
     * Performs a logical AND operation between two Boolean conditions. Outputs true only
     * if both conditions are true.
     */
    Blockly.defineBlocksWithJsonArray([{
        "type": "logical_and",
        "message0": "%1 AND %2",
        "args0": [
            {
                "type": "input_value",
                "name": "LEFT",
                "check": "Boolean",
                "align": "RIGHT"
            },
            {
                "type": "input_value",
                "name": "RIGHT",
                "check": "Boolean",
                "align": "LEFT"
            }
        ],
        "inputsInline": true,
        "output": "Boolean",
        "colour": 210,
        "tooltip": "Perform a logical AND operation between two Boolean conditions. Outputs true only if both conditions are true.",
        "helpUrl": "https://example.com/docs/logical_and"
    }]);

    /**
     * logical_or Block
     *
     * Description:
     * Performs a logical OR operation between two Boolean conditions. Outputs true if
     * at least one of the conditions is true.
     */
    Blockly.defineBlocksWithJsonArray([{
        "type": "logical_or",
        "message0": "%1 OR %2",
        "args0": [
            {
                "type": "input_value",
                "name": "LEFT",
                "check": "Boolean",
                "align": "RIGHT"
            },
            {
                "type": "input_value",
                "name": "RIGHT",
                "check": "Boolean",
                "align": "LEFT"
            }
        ],
        "inputsInline": true,
        "output": "Boolean",
        "colour": 210,
        "tooltip": "Perform a logical OR operation between two Boolean conditions. Outputs true if at least one of the conditions is true.",
        "helpUrl": "https://example.com/docs/logical_or"
    }]);

    /**
     * is_false Block
     *
     * Description:
     * Checks if a given Boolean condition is false. Outputs a Boolean value indicating
     * the result of the check.
     */
    Blockly.defineBlocksWithJsonArray([{
        "type": "is_false",
        "message0": "%1 is false",
        "args0": [
            {
                "type": "input_value",
                "name": "condition",
                "check": "Boolean",
                "align": "RIGHT"
            }
        ],
        "output": "Boolean",
        "colour": 160,
        "tooltip": "Check if the provided Boolean condition is false. Outputs true if the condition is false, otherwise false.",
        "helpUrl": "https://example.com/docs/is_false"
    }]);

}