# Control Flow Nodes

Gateway nodes for conditional branching and routing. These nodes appear as diamond shapes in the editor and split execution into multiple paths based on conditions.

---

## IfElse

Conditional branching with text comparison operators. Evaluates a condition and activates either the **True** or **False** branch.

**Category:** Control Flow | **Shape:** Diamond (Gateway)

### Input Ports

| Port | Type | Required | Description |
|------|------|----------|-------------|
| **data** | Mixed | Yes | The value to evaluate |

### Configuration

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| **matchText** | String | (none) | The text to compare against |
| **operator** | String | `equals` | Comparison: `equals`, `not_equals`, `contains`, `starts_with`, `ends_with`, `regex` |
| **caseSensitive** | Boolean | false | Whether comparison is case-sensitive |
| **strictMode** | Boolean | false | Use strict type comparison |

### Output Ports (Branches)

| Branch | Activates When |
|--------|---------------|
| **True** | The condition is met |
| **False** | The condition is not met |

### Example

To check if a text contains the word "urgent":

1. Connect the text to the `data` input
2. Set `operator` to `contains`
3. Set `matchText` to `urgent`

Nodes connected to the **True** branch execute when the text contains "urgent"; nodes on the **False** branch execute otherwise.

---

## Boolean Gateway

Routes execution based on a boolean (true/false) value.

**Category:** Control Flow | **Shape:** Diamond (Gateway)

### Input Ports

| Port | Type | Required | Description |
|------|------|----------|-------------|
| **value** | Boolean | Yes | The boolean value to evaluate |

### Output Ports (Branches)

| Branch | Activates When |
|--------|---------------|
| **True** | The input value is true |
| **False** | The input value is false |

### Usage

Use Boolean Gateway when you already have a boolean value (e.g., from a previous comparison or a toggle) and want to route execution based on it.

---

## Switch Gateway

Multi-path routing based on expression matching. Evaluates an expression and activates the matching branch, or the default branch if no match is found.

**Category:** Control Flow | **Shape:** Diamond (Gateway)

### Input Ports

| Port | Type | Required | Description |
|------|------|----------|-------------|
| **expression** | String | Yes | The value to match against branches |

### Configuration

| Parameter | Type | Description |
|-----------|------|-------------|
| **branches** | Array | List of named branches with match values |
| **default_branch** | String | Branch to activate if no match is found |

### Output Ports (Branches)

Dynamic — one output branch for each configured branch name, plus the default.

### Usage

Use Switch Gateway when you have more than two possible paths. For example, routing based on a content type: "article" → one path, "page" → another path, everything else → default path.

---

## A/B

Randomly routes execution to branch A or branch B based on configurable weights. Useful for A/B testing.

**Category:** Control Flow | **Shape:** Diamond (Gateway)

### Configuration

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| **weight_a** | Number | 50 | Percentage weight for branch A (0-100) |
| **weight_b** | Number | 50 | Percentage weight for branch B (0-100) |

### Output Ports (Branches)

| Branch | Description |
|--------|-------------|
| **A** | Activated based on weight_a probability |
| **B** | Activated based on weight_b probability |
