# Build exports

Export a Blizzard in-game loadout string, a compact code, or structured trees and spells.

Source: https://warcraftforever.com/developers/talents/exports/

After `ready`, `exportBuild()` returns the Blizzard in-game format. All exports describe the mount's current allocation; partial builds can be exported too. Use `state.complete` or the `submit` event when every point must be spent.

```js
const calculator = WarcraftForever.Talents.mount('#talents', {
  class: 'paladin', maxLevel: 30
});
await calculator.ready;

const inGame = calculator.exportBuild(); // same as exportBuild('blizzard')
const compact = calculator.exportBuild('compact');
const structured = calculator.exportBuild('structured');

calculator.on('submit', (state) => {
  const saved = {
    class: state.class,
    revision: state.revision,
    code: calculator.exportBuild('blizzard')
  };
  // Send saved to your own backend.
});
```

## In-game strings

The encoder uses the Blizzard V2 trait-loadout bit stream: class specialization, tree hash, complete client node order, selected ranks and entry selection. The Forever client accepts a zero tree hash. Supported definitions have one entry per visible node. Imports reject unsupported versions, another class, unsupported selected/granted nodes, invalid ranks and allocations over the level cap.

The codec follows the [Forever build 1.60.1.70124 client Lua](https://github.com/Gethe/wow-ui-source/blob/966519cf0ad2c10301ea011a88c14b25697c9687/Interface/AddOns/Blizzard_PlayerSpells/ClassTalents/Blizzard_ClassTalentImportExport.lua). The numeric version is V2; a live client import/re-export has not yet been verified. An archived revision without client serialization metadata throws when requesting this export; its compact and structured exports remain available.

Pass the string back as `build: { code, revision }`. For a site link use `/talents/paladin/?v=2&build=` followed by `encodeURIComponent(code)`. The query parameter preserves `+` and `/` characters in the in-game alphabet. The site still generates compact share URLs for compatibility.

## Structured data

`exportBuild('structured')` returns `{ class, revision, pointsSpent, trees }`. Trees retain their published ID, localized name, point total and `talents` array. Every selected talent includes:

- `id`, `name`, `rank`, `maxRanks` and zero-based `row` / `column`.
- An absolute Warcraft Forever `icon` URL.
- The selected rank's `spellId`, `description` and `details`, when available.

Empty trees remain in the result with an empty `talents` array. Unselected talents are omitted. Talent IDs remain distinct even when spells are shared. Returned data is detached from the mount; changing it does not edit the calculator.

## Deprecated compact format

Compact digit strings (including old hyphen-separated links) continue to load. Existing `state.code`, `state.shareUrl`, saved builds and archived revision URLs retain their meaning. There is no automatic rewrite of persisted values and no removal date.

For new integrations, request the in-game export explicitly. Store `class` and `revision` beside either string: the layout revision is independent of the JavaScript library release. Structured data is an output for custom rendering or analysis, not a replacement persisted build format.
