# ResizeSession

> Headless pointer-resize engine backing the `resizeHandle(axis)` mixin.

```ts
import { ResizeSession } from "@sdxc/ui/behaviors";
```

Owns one resizable panel group's active pointer session. `move()` re-solves
every panel's size from the constraints captured at `start()`, cascading
into further panels so a drag only takes what the group can give up.

## Signature

```ts
new ResizeSession()
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| `isActive` | `boolean` | Whether a pointer session is in progress between `start()` and `end()`. |
| `activeHandleIndex` | `number \| null` | Index of the handle being dragged in the active session, or `null` when no session is active. |
| `panels` | `readonly ResizeSession.Panel[]` | Every panel's current resolved size and constraints, in group order. Returns a defensive copy on every read, so mutating the result never affects the session's own state. |

## Methods

| Method | Description |
| --- | --- |
| `start(options: ResizeSession.StartOptions): void` | Begins a pointer session on one handle of a panel group, capturing the panels' sizes and constraints as the baseline every subsequent `move()` in this session solves from. |
| `move(pointerPosition: number): void` | Re-solves every panel's size for the current pointer position and dispatches `change`. A no-op when no session is active, so a mixin can forward every `pointermove` without guarding on `isActive` itself. |
| `end(): void` | Concludes the active session, keeping the panels at their last solved sizes, and dispatches `end`. A no-op when no session is active. |
| `cancel(): void` | Aborts the active session, reverting every panel to the size it had when `start()` was called, then dispatches `change` (for the reverted sizes) followed by `end`. A no-op when no session is active. |

## Used with it

The events, constants and types its module publishes, each imported from `@sdxc/ui/behaviors` too.

### ResizeSession.PanelInput

A panel as supplied to `start()`: its current size and, optionally, the
size constraints the solver must respect. `size`, `min`, and `max` are
all expressed as percentages of the panel group's main-axis size (0-100).

#### Members

| Member | Type | Description |
| --- | --- | --- |
| `id` | `string` | Stable identifier the consumer uses to map a resolved size back to its panel element. |
| `size` | `number` | Current size, as a percentage of the group's main-axis size. |
| `min?` | `number` | Smallest percentage this panel may shrink to. Defaults to 0 when omitted. |
| `max?` | `number` | Largest percentage this panel may grow to. Defaults to 100 when omitted. |

### ResizeSession.Panel

A panel's resolved state as read from an in-progress or finished session:
`min` and `max` are always concrete, defaulted values.

#### Members

| Member | Type | Description |
| --- | --- | --- |
| `id` | `string` | Stable identifier, carried over unchanged from the matching `PanelInput`. |
| `size` | `number` | Current size, as a percentage of the group's main-axis size. |
| `min` | `number` | Smallest percentage this panel may shrink to. |
| `max` | `number` | Largest percentage this panel may grow to. |

### ResizeSession.StartOptions

Snapshot passed to `start()`: the panel group's layout and constraints at
the moment a pointer session begins on one of its handles.

#### Members

| Member | Type | Description |
| --- | --- | --- |
| `handleIndex` | `number` | Index of the handle being dragged; it sits between `panels[handleIndex]` and `panels[handleIndex + 1]`. |
| `panels` | `readonly PanelInput[]` | Every panel in the group, in visual order along the resize axis. |
| `pointerPosition` | `number` | Pointer coordinate along the resize axis (`clientX` for a horizontal group, `clientY` for a vertical one) at pointer-down. |
| `groupSize` | `number` | Size, in pixels, of the panel group measured along the resize axis — used to convert pixel pointer deltas into percentage units. |

### ResizeSession.Events

Events a `ResizeSession` dispatches; read the `panels` getter for the state behind each one.

#### Members

| Member | Type | Description |
| --- | --- | --- |
| `change` | `Event` | Dispatched whenever constraint solving produces new panel sizes, from a pointer move or a cancelled session reverting. |
| `end` | `Event` | Dispatched once a session concludes, whether by `end()` or `cancel()`. |
