// time_metrics_blocks.js

/**
 * Time Metrics Subcategory Blocks Definitions
 *
 * This file defines a set of time metrics-related blocks for Blockly. These blocks
 * enable users to retrieve various time-based data such as the time elapsed since
 * the strategy started. 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 defineTimeMetricsBlocks() {

    /**
     * time_since_start Block
     *
     * Description:
     * Retrieves the time elapsed since the trading strategy started. Users can specify
     * the unit of time (seconds, minutes, hours) through a dropdown menu.
     */
    Blockly.defineBlocksWithJsonArray([{
        "type": "time_since_start",
        "message0": "Time Since Start %1 %2",
        "args0": [
            {
                "type": "field_dropdown",
                "name": "TIME_UNIT",
                "options": [
                    ["Seconds", "seconds"],
                    ["Minutes", "minutes"],
                    ["Hours", "hours"]
                ],
                "align": "RIGHT"
            },
            {
                "type": "input_value",
                "name": "VALUES",
                "check": "dynamic_value",
                "align": "LEFT"
            }
        ],
        "output": "dynamic_value",
        "colour": 230,
        "tooltip": "Retrieve the time elapsed since the trading strategy started in the specified unit.",
        "helpUrl": "https://example.com/docs/time_since_start"
    }]);
}