gigaboard 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +27 -0
  3. package/dist/board-model-BvJOtwQ3.d.cts +675 -0
  4. package/dist/board-model-BvJOtwQ3.d.ts +675 -0
  5. package/dist/canvas.cjs +8 -0
  6. package/dist/canvas.cjs.map +1 -0
  7. package/dist/canvas.d.cts +14 -0
  8. package/dist/canvas.d.ts +14 -0
  9. package/dist/canvas.js +6 -0
  10. package/dist/canvas.js.map +1 -0
  11. package/dist/chunk-3HNIF4ZE.js +3 -0
  12. package/dist/chunk-3HNIF4ZE.js.map +1 -0
  13. package/dist/chunk-44YKPXXT.js +63 -0
  14. package/dist/chunk-44YKPXXT.js.map +1 -0
  15. package/dist/chunk-5WAOEWKS.js +16 -0
  16. package/dist/chunk-5WAOEWKS.js.map +1 -0
  17. package/dist/chunk-AYVQCHSG.cjs +10 -0
  18. package/dist/chunk-AYVQCHSG.cjs.map +1 -0
  19. package/dist/chunk-B26QLI2K.cjs +18 -0
  20. package/dist/chunk-B26QLI2K.cjs.map +1 -0
  21. package/dist/chunk-B2TBDDJN.cjs +10 -0
  22. package/dist/chunk-B2TBDDJN.cjs.map +1 -0
  23. package/dist/chunk-BFN5JI3T.js +8 -0
  24. package/dist/chunk-BFN5JI3T.js.map +1 -0
  25. package/dist/chunk-BWNBPN3P.cjs +10 -0
  26. package/dist/chunk-BWNBPN3P.cjs.map +1 -0
  27. package/dist/chunk-CXDGJMYL.js +105 -0
  28. package/dist/chunk-CXDGJMYL.js.map +1 -0
  29. package/dist/chunk-EOSX5UX3.js +8 -0
  30. package/dist/chunk-EOSX5UX3.js.map +1 -0
  31. package/dist/chunk-FNRS6YJI.cjs +67 -0
  32. package/dist/chunk-FNRS6YJI.cjs.map +1 -0
  33. package/dist/chunk-G6ZFOJZR.cjs +18 -0
  34. package/dist/chunk-G6ZFOJZR.cjs.map +1 -0
  35. package/dist/chunk-HSMILJKQ.cjs +18 -0
  36. package/dist/chunk-HSMILJKQ.cjs.map +1 -0
  37. package/dist/chunk-I4BQGFP5.cjs +113 -0
  38. package/dist/chunk-I4BQGFP5.cjs.map +1 -0
  39. package/dist/chunk-J6GGNP5S.js +1104 -0
  40. package/dist/chunk-J6GGNP5S.js.map +1 -0
  41. package/dist/chunk-JQSBAWIZ.cjs +4 -0
  42. package/dist/chunk-JQSBAWIZ.cjs.map +1 -0
  43. package/dist/chunk-KW56FEBY.js +8 -0
  44. package/dist/chunk-KW56FEBY.js.map +1 -0
  45. package/dist/chunk-N7ED2MZS.cjs +10 -0
  46. package/dist/chunk-N7ED2MZS.cjs.map +1 -0
  47. package/dist/chunk-NAA5O4BT.js +16 -0
  48. package/dist/chunk-NAA5O4BT.js.map +1 -0
  49. package/dist/chunk-OQLY5GJF.js +16 -0
  50. package/dist/chunk-OQLY5GJF.js.map +1 -0
  51. package/dist/chunk-P72B3YTG.js +16 -0
  52. package/dist/chunk-P72B3YTG.js.map +1 -0
  53. package/dist/chunk-U6WAD322.js +8 -0
  54. package/dist/chunk-U6WAD322.js.map +1 -0
  55. package/dist/chunk-UUTEFNFO.cjs +1148 -0
  56. package/dist/chunk-UUTEFNFO.cjs.map +1 -0
  57. package/dist/chunk-VYSVIIZA.cjs +18 -0
  58. package/dist/chunk-VYSVIIZA.cjs.map +1 -0
  59. package/dist/core.cjs +180 -0
  60. package/dist/core.cjs.map +1 -0
  61. package/dist/core.d.cts +164 -0
  62. package/dist/core.d.ts +164 -0
  63. package/dist/core.js +3 -0
  64. package/dist/core.js.map +1 -0
  65. package/dist/create-image-piece-set-BcmRKGql.d.cts +100 -0
  66. package/dist/create-image-piece-set-BcmRKGql.d.ts +100 -0
  67. package/dist/gigachess-3BDD--yT.d.cts +22 -0
  68. package/dist/gigachess-DolQlR82.d.ts +22 -0
  69. package/dist/index.cjs +2972 -0
  70. package/dist/index.cjs.map +1 -0
  71. package/dist/index.d.cts +435 -0
  72. package/dist/index.d.ts +435 -0
  73. package/dist/index.js +2898 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/pieces/alpha.cjs +13 -0
  76. package/dist/pieces/alpha.cjs.map +1 -0
  77. package/dist/pieces/alpha.d.cts +17 -0
  78. package/dist/pieces/alpha.d.ts +17 -0
  79. package/dist/pieces/alpha.js +4 -0
  80. package/dist/pieces/alpha.js.map +1 -0
  81. package/dist/pieces/cburnett.cjs +13 -0
  82. package/dist/pieces/cburnett.cjs.map +1 -0
  83. package/dist/pieces/cburnett.d.cts +19 -0
  84. package/dist/pieces/cburnett.d.ts +19 -0
  85. package/dist/pieces/cburnett.js +4 -0
  86. package/dist/pieces/cburnett.js.map +1 -0
  87. package/dist/pieces/chesscom.cjs +14 -0
  88. package/dist/pieces/chesscom.cjs.map +1 -0
  89. package/dist/pieces/chesscom.d.cts +3 -0
  90. package/dist/pieces/chesscom.d.ts +3 -0
  91. package/dist/pieces/chesscom.js +5 -0
  92. package/dist/pieces/chesscom.js.map +1 -0
  93. package/dist/pieces/merida.cjs +13 -0
  94. package/dist/pieces/merida.cjs.map +1 -0
  95. package/dist/pieces/merida.d.cts +17 -0
  96. package/dist/pieces/merida.d.ts +17 -0
  97. package/dist/pieces/merida.js +4 -0
  98. package/dist/pieces/merida.js.map +1 -0
  99. package/dist/pieces/neo.cjs +13 -0
  100. package/dist/pieces/neo.cjs.map +1 -0
  101. package/dist/pieces/neo.d.cts +18 -0
  102. package/dist/pieces/neo.d.ts +18 -0
  103. package/dist/pieces/neo.js +4 -0
  104. package/dist/pieces/neo.js.map +1 -0
  105. package/dist/pieces.cjs +55 -0
  106. package/dist/pieces.cjs.map +1 -0
  107. package/dist/pieces.d.cts +21 -0
  108. package/dist/pieces.d.ts +21 -0
  109. package/dist/pieces.js +24 -0
  110. package/dist/pieces.js.map +1 -0
  111. package/dist/server.cjs +207 -0
  112. package/dist/server.cjs.map +1 -0
  113. package/dist/server.d.cts +60 -0
  114. package/dist/server.d.ts +60 -0
  115. package/dist/server.js +205 -0
  116. package/dist/server.js.map +1 -0
  117. package/dist/sounds/capture.mp3 +0 -0
  118. package/dist/sounds/castle.mp3 +0 -0
  119. package/dist/sounds/game-end.mp3 +0 -0
  120. package/dist/sounds/move-check.mp3 +0 -0
  121. package/dist/sounds/move-opponent.mp3 +0 -0
  122. package/dist/sounds/move-self.mp3 +0 -0
  123. package/dist/sounds/promote.mp3 +0 -0
  124. package/dist/themes/blue.cjs +12 -0
  125. package/dist/themes/blue.cjs.map +1 -0
  126. package/dist/themes/blue.d.cts +102 -0
  127. package/dist/themes/blue.d.ts +102 -0
  128. package/dist/themes/blue.js +3 -0
  129. package/dist/themes/blue.js.map +1 -0
  130. package/dist/themes/brown.cjs +12 -0
  131. package/dist/themes/brown.cjs.map +1 -0
  132. package/dist/themes/brown.d.cts +1 -0
  133. package/dist/themes/brown.d.ts +1 -0
  134. package/dist/themes/brown.js +3 -0
  135. package/dist/themes/brown.js.map +1 -0
  136. package/dist/themes/green.cjs +12 -0
  137. package/dist/themes/green.cjs.map +1 -0
  138. package/dist/themes/green.d.cts +1 -0
  139. package/dist/themes/green.d.ts +1 -0
  140. package/dist/themes/green.js +3 -0
  141. package/dist/themes/green.js.map +1 -0
  142. package/dist/themes/wood.cjs +12 -0
  143. package/dist/themes/wood.cjs.map +1 -0
  144. package/dist/themes/wood.d.cts +1 -0
  145. package/dist/themes/wood.d.ts +1 -0
  146. package/dist/themes/wood.js +3 -0
  147. package/dist/themes/wood.js.map +1 -0
  148. package/dist/themes.cjs +36 -0
  149. package/dist/themes.cjs.map +1 -0
  150. package/dist/themes.d.cts +1 -0
  151. package/dist/themes.d.ts +1 -0
  152. package/dist/themes.js +21 -0
  153. package/dist/themes.js.map +1 -0
  154. package/dist/types-Bg2xiUHE.d.cts +501 -0
  155. package/dist/types-D5eBJGzj.d.ts +501 -0
  156. package/package.json +210 -0
@@ -0,0 +1,1104 @@
1
+ import { ensureMagicTablesLoaded, ensureZobristLoaded, makeSan } from 'gigachess';
2
+ import { Chess } from 'gigachess/chessjs';
3
+
4
+ // src/core/adapters/gigachess.ts
5
+
6
+ // src/core/types.ts
7
+ var MOVE2_PROMO_NONE = 0;
8
+ var MOVE2_PROMO_KNIGHT = 1;
9
+ var MOVE2_PROMO_BISHOP = 2;
10
+ var MOVE2_PROMO_ROOK = 3;
11
+ var MOVE2_PROMO_QUEEN = 4;
12
+ function packMove(from, to, promo = MOVE2_PROMO_NONE) {
13
+ return (from & 63 | (to & 63) << 6 | (promo & 15) << 12) & 65535;
14
+ }
15
+ function unpackMove(move) {
16
+ const w = move & 65535;
17
+ return {
18
+ from: w & 63,
19
+ to: w >>> 6 & 63,
20
+ promo: w >>> 12 & 15
21
+ };
22
+ }
23
+ var Color = {
24
+ White: 0,
25
+ Black: 1
26
+ };
27
+ var PieceType = {
28
+ Pawn: 0,
29
+ Knight: 1,
30
+ Bishop: 2,
31
+ Rook: 3,
32
+ Queen: 4,
33
+ King: 5
34
+ };
35
+ var BOARD_CELL_EMPTY = 0;
36
+ var BOARD_CELL_WP = 1;
37
+ var BOARD_CELL_WN = 2;
38
+ var BOARD_CELL_WB = 3;
39
+ var BOARD_CELL_WR = 4;
40
+ var BOARD_CELL_WQ = 5;
41
+ var BOARD_CELL_WK = 6;
42
+ var BOARD_CELL_BP = 7;
43
+ var BOARD_CELL_BN = 8;
44
+ var BOARD_CELL_BB = 9;
45
+ var BOARD_CELL_BR = 10;
46
+ var BOARD_CELL_BQ = 11;
47
+ var BOARD_CELL_BK = 12;
48
+ function toSquareIndex(n) {
49
+ if (process.env["NODE_ENV"] !== "production") {
50
+ if (!Number.isInteger(n) || n < 0 || n > 63) {
51
+ throw new RangeError(`SquareIndex out of range: ${n}`);
52
+ }
53
+ }
54
+ return n;
55
+ }
56
+ function isSquareIndex(n) {
57
+ return Number.isInteger(n) && n >= 0 && n <= 63;
58
+ }
59
+ function encodeBoardCell(color, type) {
60
+ return 1 + type + color * 6;
61
+ }
62
+ function isEmptyCell(cell) {
63
+ return cell === 0;
64
+ }
65
+ function colorOf(cell) {
66
+ return cell > 6 ? 1 : 0;
67
+ }
68
+ function pieceTypeOf(cell) {
69
+ return (cell - 1) % 6;
70
+ }
71
+
72
+ // src/core/adapters/gigachess.ts
73
+ void ensureMagicTablesLoaded().catch(() => {
74
+ });
75
+ void ensureZobristLoaded().catch(() => {
76
+ });
77
+ function preloadGigachessAdapter() {
78
+ return Promise.all([ensureMagicTablesLoaded(), ensureZobristLoaded()]).then(() => void 0);
79
+ }
80
+ function algebraicOf(sq) {
81
+ const file = sq & 7;
82
+ const rank = sq >> 3;
83
+ return `${String.fromCharCode(97 + file)}${rank + 1}`;
84
+ }
85
+ function squareIndexOf(alg) {
86
+ const file = alg.charCodeAt(0) - 97;
87
+ const rank = alg.charCodeAt(1) - 49;
88
+ return rank * 8 + file;
89
+ }
90
+ function promoRole(code) {
91
+ switch (code) {
92
+ case 1:
93
+ return 1;
94
+ // Knight
95
+ case 2:
96
+ return 2;
97
+ // Bishop
98
+ case 3:
99
+ return 3;
100
+ // Rook
101
+ case 4:
102
+ return 4;
103
+ // Queen
104
+ default:
105
+ return void 0;
106
+ }
107
+ }
108
+ function promoChar(piece) {
109
+ switch (piece) {
110
+ case 1:
111
+ return "n";
112
+ case 2:
113
+ return "b";
114
+ case 3:
115
+ return "r";
116
+ case 4:
117
+ return "q";
118
+ default:
119
+ return void 0;
120
+ }
121
+ }
122
+ function createGigachessAdapter(fen) {
123
+ const chess = fen === void 0 ? new Chess() : new Chess(fen);
124
+ const makeMove = (from, to, promotion) => {
125
+ try {
126
+ const fromAlg = algebraicOf(from);
127
+ const toAlg = algebraicOf(to);
128
+ const promo = promoChar(promotion);
129
+ const res = chess.move({
130
+ from: fromAlg,
131
+ to: toAlg,
132
+ ...promo ? { promotion: promo } : {}
133
+ });
134
+ if (res === null) return null;
135
+ if (res.flags.includes("k")) {
136
+ return res.color === "w" ? packMove(4, 7, 0) : packMove(60, 63, 0);
137
+ }
138
+ if (res.flags.includes("q")) {
139
+ return res.color === "w" ? packMove(4, 0, 0) : packMove(60, 56, 0);
140
+ }
141
+ const pCode = res.promotion ? res.promotion === "n" ? 1 : res.promotion === "b" ? 2 : res.promotion === "r" ? 3 : 4 : 0;
142
+ return packMove(from, to, pCode);
143
+ } catch {
144
+ return null;
145
+ }
146
+ };
147
+ const undo = () => {
148
+ const res = chess.undo();
149
+ if (res === null) return null;
150
+ if (res.flags.includes("k")) {
151
+ return res.color === "w" ? packMove(4, 7, 0) : packMove(60, 63, 0);
152
+ }
153
+ if (res.flags.includes("q")) {
154
+ return res.color === "w" ? packMove(4, 0, 0) : packMove(60, 56, 0);
155
+ }
156
+ const from = squareIndexOf(res.from);
157
+ const to = squareIndexOf(res.to);
158
+ const pCode = res.promotion ? res.promotion === "n" ? 1 : res.promotion === "b" ? 2 : res.promotion === "r" ? 3 : 4 : 0;
159
+ return packMove(from, to, pCode);
160
+ };
161
+ const legalMoves = (from) => {
162
+ const moves = from === void 0 ? chess.moves({ verbose: true }) : chess.moves({ verbose: true, square: algebraicOf(from) });
163
+ const out = [];
164
+ for (let i = 0; i < moves.length; i++) {
165
+ const m = moves[i];
166
+ if (m === void 0) continue;
167
+ if (m.flags.includes("k")) {
168
+ out.push(m.color === "w" ? packMove(4, 7, 0) : packMove(60, 63, 0));
169
+ } else if (m.flags.includes("q")) {
170
+ out.push(m.color === "w" ? packMove(4, 0, 0) : packMove(60, 56, 0));
171
+ } else {
172
+ const f = squareIndexOf(m.from);
173
+ const t = squareIndexOf(m.to);
174
+ const pCode = m.promotion ? m.promotion === "n" ? 1 : m.promotion === "b" ? 2 : m.promotion === "r" ? 3 : 4 : 0;
175
+ out.push(packMove(f, t, pCode));
176
+ }
177
+ }
178
+ return out;
179
+ };
180
+ const readBoard = (out) => {
181
+ if (process.env["NODE_ENV"] !== "production") {
182
+ if (out.length !== 64) {
183
+ throw new RangeError("readBoard: out.length must be 64");
184
+ }
185
+ }
186
+ out.fill(0);
187
+ const b = chess.boardInstance;
188
+ for (let sq = 0; sq < 64; sq++) {
189
+ const p = b.pieceAt(sq);
190
+ if (p !== void 0) {
191
+ out[sq] = encodeBoardCell(p.color, p.role);
192
+ }
193
+ }
194
+ };
195
+ const san = (move) => {
196
+ const { from, to, promo } = unpackMove(move);
197
+ const role = promoRole(promo);
198
+ return makeSan(
199
+ {
200
+ from,
201
+ to,
202
+ ...role !== void 0 ? { promotion: role } : {}
203
+ },
204
+ chess.pos
205
+ );
206
+ };
207
+ return {
208
+ makeMove,
209
+ undo,
210
+ legalMoves,
211
+ readBoard,
212
+ fen: () => chess.fen(),
213
+ turn: () => chess.turn() === "w" ? Color.White : Color.Black,
214
+ hash: () => chess.zobrist(),
215
+ inCheck: () => chess.inCheck(),
216
+ san,
217
+ isGameOver: () => chess.isGameOver(),
218
+ load: (f) => chess.load(f),
219
+ reset: () => chess.reset(),
220
+ dispose: () => {
221
+ }
222
+ };
223
+ }
224
+
225
+ // src/core/animation-planner.ts
226
+ var MOVE_FROM_MASK = 63;
227
+ var MOVE_TO_SHIFT = 6;
228
+ var MOVE_TO_MASK = 63;
229
+ var MOVE_PROMO_SHIFT = 12;
230
+ var MOVE_PROMO_MASK = 15;
231
+ var PROMO_PIECE = [
232
+ null,
233
+ PieceType.Knight,
234
+ PieceType.Bishop,
235
+ PieceType.Rook,
236
+ PieceType.Queen
237
+ ];
238
+ function planAnimations(prev, next, move) {
239
+ if (process.env["NODE_ENV"] !== "production") {
240
+ if (prev.length !== 64 || next.length !== 64) {
241
+ throw new RangeError("planAnimations: board buffers must be length 64");
242
+ }
243
+ }
244
+ if (move !== null) {
245
+ return planFromMove(prev, next, move);
246
+ }
247
+ return planFromDiff(prev, next);
248
+ }
249
+ function planFromMove(prev, next, move) {
250
+ const from = move & MOVE_FROM_MASK;
251
+ const to = move >> MOVE_TO_SHIFT & MOVE_TO_MASK;
252
+ const promoCode = move >> MOVE_PROMO_SHIFT & MOVE_PROMO_MASK;
253
+ const pieceBefore = prev[from];
254
+ const pieceAfter = next[to];
255
+ const targetBefore = prev[to];
256
+ if (!isEmptyCell(pieceBefore) && pieceTypeOf(pieceBefore) === PieceType.King) {
257
+ const isFriendlyRookTarget = !isEmptyCell(targetBefore) && colorOf(targetBefore) === colorOf(pieceBefore) && pieceTypeOf(targetBefore) === PieceType.Rook;
258
+ const isKingCapturesRookCanonical = from === 4 && (to === 7 || to === 0) || from === 60 && (to === 63 || to === 56);
259
+ const isKingTwoSquares = from === 4 && (to === 6 || to === 2) || from === 60 && (to === 62 || to === 58);
260
+ if (isFriendlyRookTarget || isKingCapturesRookCanonical || isKingTwoSquares) {
261
+ const isKingside = (to & 7) > (from & 7);
262
+ const kingRank = from >> 3;
263
+ const base = kingRank << 3;
264
+ const kingFrom = from;
265
+ const kingTo = base + (isKingside ? 6 : 2);
266
+ const rookFrom = base + (isKingside ? 7 : 0);
267
+ const rookTo = base + (isKingside ? 5 : 3);
268
+ return [
269
+ {
270
+ kind: "castle",
271
+ kingFrom,
272
+ kingTo,
273
+ rookFrom,
274
+ rookTo
275
+ }
276
+ ];
277
+ }
278
+ }
279
+ if (!isEmptyCell(pieceBefore) && pieceTypeOf(pieceBefore) === PieceType.Pawn && (from & 7) !== (to & 7) && isEmptyCell(targetBefore)) {
280
+ const capturedSquare = from & -8 | to & 7;
281
+ const captured = prev[capturedSquare];
282
+ return [
283
+ {
284
+ kind: "en-passant",
285
+ from,
286
+ to,
287
+ capturedSquare,
288
+ piece: pieceBefore,
289
+ captured
290
+ }
291
+ ];
292
+ }
293
+ if (promoCode > 0) {
294
+ const captured = isEmptyCell(targetBefore) ? null : targetBefore;
295
+ return [
296
+ {
297
+ kind: "promotion",
298
+ from,
299
+ to,
300
+ pieceBefore,
301
+ pieceAfter,
302
+ captured
303
+ }
304
+ ];
305
+ }
306
+ if (!isEmptyCell(targetBefore)) {
307
+ return [
308
+ {
309
+ kind: "capture",
310
+ from,
311
+ to,
312
+ piece: pieceBefore,
313
+ captured: targetBefore
314
+ }
315
+ ];
316
+ }
317
+ return [{ kind: "move", from, to, piece: pieceBefore }];
318
+ }
319
+ function planFromDiff(prev, next) {
320
+ const descriptors = [];
321
+ for (let i = 0; i < 64; i++) {
322
+ const a = prev[i];
323
+ const b = next[i];
324
+ if (a === b) continue;
325
+ const at = i;
326
+ if (!isEmptyCell(a) && isEmptyCell(b)) {
327
+ descriptors.push({ kind: "disappear", at, piece: a });
328
+ } else if (isEmptyCell(a) && !isEmptyCell(b)) {
329
+ descriptors.push({ kind: "appear", at, piece: b });
330
+ } else {
331
+ descriptors.push({ kind: "disappear", at, piece: a });
332
+ descriptors.push({ kind: "appear", at, piece: b });
333
+ }
334
+ }
335
+ return descriptors;
336
+ }
337
+ function decodePackedMove(m) {
338
+ const from = m & MOVE_FROM_MASK;
339
+ const to = m >> MOVE_TO_SHIFT & MOVE_TO_MASK;
340
+ const promoCode = m >> MOVE_PROMO_SHIFT & MOVE_PROMO_MASK;
341
+ const promotion = PROMO_PIECE[promoCode] ?? null;
342
+ const isCastle = from === 4 && (to === 7 || to === 0 || to === 6 || to === 2) || from === 60 && (to === 63 || to === 56 || to === 62 || to === 58);
343
+ const kind = promotion !== null ? "promotion" : isCastle ? "castle" : "normal";
344
+ return { from, to, kind, promotion };
345
+ }
346
+ var animationInspect = {
347
+ colorOf,
348
+ pieceTypeOf,
349
+ // Re-export the Color / PieceType enums so consumers can compare without
350
+ // extra imports.
351
+ Color,
352
+ PieceType
353
+ };
354
+
355
+ // src/core/arrow-model.ts
356
+ function arrowKey(arrow) {
357
+ let key = `${arrow.from}|${arrow.to}|${arrow.color}`;
358
+ if (arrow.brush !== void 0) key += `|b:${arrow.brush}`;
359
+ if (arrow.label !== void 0) key += `|l:${arrow.label.text}`;
360
+ if (arrow.customSvg !== void 0) key += `|s:${arrow.customSvg.html}`;
361
+ if (arrow.below === true) key += "|below";
362
+ return key;
363
+ }
364
+ function freezeArrow(a) {
365
+ const out = { from: a.from, to: a.to, color: a.color };
366
+ if (a.brush !== void 0) out.brush = a.brush;
367
+ if (a.label !== void 0) out.label = Object.freeze({ ...a.label });
368
+ if (a.customSvg !== void 0) out.customSvg = Object.freeze({ ...a.customSvg });
369
+ if (a.below === true) out.below = true;
370
+ if (a.managed === true) out.managed = true;
371
+ return Object.freeze(out);
372
+ }
373
+ var EMPTY_ARROWS = Object.freeze([]);
374
+ function createArrowModel() {
375
+ const byKey = /* @__PURE__ */ new Map();
376
+ let changed = false;
377
+ let cached = EMPTY_ARROWS;
378
+ const invalidate = () => {
379
+ cached = null;
380
+ };
381
+ const has = (arrow) => byKey.has(arrowKey(arrow));
382
+ const add = (arrow) => {
383
+ const key = arrowKey(arrow);
384
+ if (byKey.has(key)) {
385
+ changed = false;
386
+ return;
387
+ }
388
+ byKey.set(key, freezeArrow(arrow));
389
+ changed = true;
390
+ invalidate();
391
+ };
392
+ const remove = (arrow) => {
393
+ changed = byKey.delete(arrowKey(arrow));
394
+ if (changed) invalidate();
395
+ };
396
+ const toggle = (arrow) => {
397
+ const key = arrowKey(arrow);
398
+ if (byKey.has(key)) {
399
+ byKey.delete(key);
400
+ changed = true;
401
+ invalidate();
402
+ return false;
403
+ }
404
+ byKey.set(key, freezeArrow(arrow));
405
+ changed = true;
406
+ invalidate();
407
+ return true;
408
+ };
409
+ const clear = () => {
410
+ changed = byKey.size > 0;
411
+ byKey.clear();
412
+ if (changed) invalidate();
413
+ };
414
+ const dropWhere = (remove2) => {
415
+ let mutated = false;
416
+ for (const [key, arrow] of byKey) {
417
+ if (remove2(arrow)) {
418
+ byKey.delete(key);
419
+ mutated = true;
420
+ }
421
+ }
422
+ changed = mutated;
423
+ if (mutated) invalidate();
424
+ };
425
+ const clearUser = () => dropWhere((a) => a.managed !== true);
426
+ const clearManaged = () => dropWhere((a) => a.managed === true);
427
+ const setManaged = (arrows) => {
428
+ const nextKeys = /* @__PURE__ */ new Set();
429
+ let mutated = false;
430
+ for (let i = 0; i < arrows.length; i++) {
431
+ const raw = arrows[i];
432
+ if (raw === void 0) continue;
433
+ const marked = raw.managed === true ? raw : { ...raw, managed: true };
434
+ const key = arrowKey(marked);
435
+ if (nextKeys.has(key)) continue;
436
+ nextKeys.add(key);
437
+ if (!byKey.has(key)) {
438
+ byKey.set(key, freezeArrow(marked));
439
+ mutated = true;
440
+ }
441
+ }
442
+ for (const [key, arrow] of byKey) {
443
+ if (arrow.managed === true && !nextKeys.has(key)) {
444
+ byKey.delete(key);
445
+ mutated = true;
446
+ }
447
+ }
448
+ changed = mutated;
449
+ if (mutated) invalidate();
450
+ };
451
+ const setAll = (arrows) => {
452
+ const nextKeys = /* @__PURE__ */ new Set();
453
+ let mutated = false;
454
+ for (let i = 0; i < arrows.length; i++) {
455
+ const a = arrows[i];
456
+ if (a === void 0) continue;
457
+ const key = arrowKey(a);
458
+ if (nextKeys.has(key)) continue;
459
+ nextKeys.add(key);
460
+ if (!byKey.has(key)) {
461
+ byKey.set(key, freezeArrow(a));
462
+ mutated = true;
463
+ }
464
+ }
465
+ if (byKey.size !== nextKeys.size) {
466
+ for (const key of byKey.keys()) {
467
+ if (!nextKeys.has(key)) {
468
+ byKey.delete(key);
469
+ mutated = true;
470
+ }
471
+ }
472
+ }
473
+ changed = mutated;
474
+ if (mutated) invalidate();
475
+ };
476
+ return {
477
+ get arrows() {
478
+ if (cached === null) {
479
+ cached = Object.freeze([...byKey.values()]);
480
+ }
481
+ return cached;
482
+ },
483
+ has,
484
+ add,
485
+ remove,
486
+ toggle,
487
+ clear,
488
+ clearUser,
489
+ clearManaged,
490
+ setAll,
491
+ setManaged,
492
+ get lastChanged() {
493
+ return changed;
494
+ }
495
+ };
496
+ }
497
+ function makeArrow(from, to, color) {
498
+ return Object.freeze({ from, to, color });
499
+ }
500
+
501
+ // src/core/drag-controller.ts
502
+ var DEFAULT_ACTIVATION_DISTANCE = 4;
503
+ function createDragController(options = {}) {
504
+ const activationDistance = options.activationDistance ?? DEFAULT_ACTIVATION_DISTANCE;
505
+ if (!Number.isFinite(activationDistance) || activationDistance < 0) {
506
+ throw new RangeError(
507
+ `DragController: activationDistance must be a non-negative number, got ${activationDistance}`
508
+ );
509
+ }
510
+ const thresholdSq = activationDistance * activationDistance;
511
+ let state = { kind: "idle" };
512
+ const pointerDown = (from, pointerId, x, y) => {
513
+ if (state.kind !== "idle") return false;
514
+ state = { kind: "pending", from, pointerId, originX: x, originY: y };
515
+ return true;
516
+ };
517
+ const pointerMove = (pointerId, x, y) => {
518
+ if (state.kind === "idle") return null;
519
+ if (state.pointerId !== pointerId) return null;
520
+ if (state.kind === "pending") {
521
+ const dx = x - state.originX;
522
+ const dy = y - state.originY;
523
+ if (dx * dx + dy * dy < thresholdSq) {
524
+ return null;
525
+ }
526
+ const from = state.from;
527
+ state = { kind: "dragging", from, pointerId, x, y };
528
+ return { kind: "drag-start", from };
529
+ }
530
+ state = { kind: "dragging", from: state.from, pointerId, x, y };
531
+ return { kind: "drag-move", from: state.from, x, y };
532
+ };
533
+ const pointerUp = (pointerId, x, y) => {
534
+ if (state.kind === "idle") return null;
535
+ if (state.pointerId !== pointerId) return null;
536
+ if (state.kind === "dragging") {
537
+ const event2 = { kind: "drop", from: state.from, x, y, wasDrag: true };
538
+ state = { kind: "idle" };
539
+ return event2;
540
+ }
541
+ const event = { kind: "click", from: state.from };
542
+ state = { kind: "idle" };
543
+ return event;
544
+ };
545
+ const cancel = () => {
546
+ if (state.kind === "idle") return null;
547
+ const event = { kind: "cancel", from: state.from };
548
+ state = { kind: "idle" };
549
+ return event;
550
+ };
551
+ return {
552
+ get state() {
553
+ return state;
554
+ },
555
+ pointerDown,
556
+ pointerMove,
557
+ pointerUp,
558
+ cancel
559
+ };
560
+ }
561
+
562
+ // src/core/legal-move-index.ts
563
+ function makeKey(hash, from) {
564
+ if (typeof hash === "bigint") {
565
+ return `${hash}_${from}`;
566
+ }
567
+ return `${hash.lo}_${hash.hi}_${from}`;
568
+ }
569
+ function createLegalMoveIndex(options = {}) {
570
+ const capacity = options.capacity ?? 1024;
571
+ if (!Number.isInteger(capacity) || capacity < 1) {
572
+ throw new RangeError(`LegalMoveIndex: capacity must be a positive integer, got ${capacity}`);
573
+ }
574
+ const entries = /* @__PURE__ */ new Map();
575
+ let hits = 0;
576
+ let misses = 0;
577
+ const get = (hash, from) => {
578
+ const key = makeKey(hash, from);
579
+ const hit = entries.get(key);
580
+ if (hit === void 0) {
581
+ misses++;
582
+ return void 0;
583
+ }
584
+ entries.delete(key);
585
+ entries.set(key, hit);
586
+ hits++;
587
+ return hit;
588
+ };
589
+ const set = (hash, from, tos) => {
590
+ const key = makeKey(hash, from);
591
+ if (entries.has(key)) {
592
+ entries.delete(key);
593
+ } else if (entries.size >= capacity) {
594
+ const oldest = entries.keys().next().value;
595
+ if (oldest !== void 0) entries.delete(oldest);
596
+ }
597
+ entries.set(key, tos);
598
+ };
599
+ const clear = () => {
600
+ entries.clear();
601
+ };
602
+ const resetStats = () => {
603
+ hits = 0;
604
+ misses = 0;
605
+ };
606
+ return {
607
+ get,
608
+ set,
609
+ clear,
610
+ resetStats,
611
+ get size() {
612
+ return entries.size;
613
+ },
614
+ capacity,
615
+ get hits() {
616
+ return hits;
617
+ },
618
+ get misses() {
619
+ return misses;
620
+ }
621
+ };
622
+ }
623
+
624
+ // src/core/premove-buffer.ts
625
+ function freezePremove(p) {
626
+ if (p.promotion === void 0) {
627
+ return Object.freeze({ from: p.from, to: p.to });
628
+ }
629
+ return Object.freeze({ from: p.from, to: p.to, promotion: p.promotion });
630
+ }
631
+ var EMPTY_PREMOVES = Object.freeze([]);
632
+ function createPremoveBuffer() {
633
+ const queue = [];
634
+ let cached = EMPTY_PREMOVES;
635
+ const peek = () => queue[0];
636
+ const push = (premove) => {
637
+ queue.push(freezePremove(premove));
638
+ cached = null;
639
+ };
640
+ const shift = () => {
641
+ const head = queue.shift();
642
+ if (head !== void 0) cached = null;
643
+ return head;
644
+ };
645
+ const clear = () => {
646
+ if (queue.length > 0) {
647
+ queue.length = 0;
648
+ cached = null;
649
+ }
650
+ };
651
+ return {
652
+ get all() {
653
+ if (cached === null) {
654
+ cached = Object.freeze([...queue]);
655
+ }
656
+ return cached;
657
+ },
658
+ peek,
659
+ push,
660
+ shift,
661
+ clear,
662
+ get length() {
663
+ return queue.length;
664
+ }
665
+ };
666
+ }
667
+ function makePremove(from, to, promotion) {
668
+ return promotion === void 0 ? Object.freeze({ from, to }) : Object.freeze({ from, to, promotion });
669
+ }
670
+
671
+ // src/core/subscribe-store.ts
672
+ function createBoardStore(initial) {
673
+ let snapshot = initial;
674
+ const globalListeners = /* @__PURE__ */ new Set();
675
+ const squareListeners = new Array(64);
676
+ const notify = (set) => {
677
+ for (const l of [...set]) l();
678
+ };
679
+ const getSnapshot = () => snapshot;
680
+ const subscribe = (listener) => {
681
+ globalListeners.add(listener);
682
+ let alive = true;
683
+ return () => {
684
+ if (!alive) return;
685
+ alive = false;
686
+ globalListeners.delete(listener);
687
+ };
688
+ };
689
+ const subscribeSquare = (index, listener) => {
690
+ let set = squareListeners[index];
691
+ if (!set) {
692
+ set = /* @__PURE__ */ new Set();
693
+ squareListeners[index] = set;
694
+ }
695
+ set.add(listener);
696
+ let alive = true;
697
+ return () => {
698
+ if (!alive) return;
699
+ alive = false;
700
+ set.delete(listener);
701
+ };
702
+ };
703
+ const commit = (next) => {
704
+ if (next === snapshot) return;
705
+ const prev = snapshot;
706
+ snapshot = next;
707
+ const prevBoard = prev.board;
708
+ const nextBoard = next.board;
709
+ if (prevBoard !== nextBoard) {
710
+ for (let i = 0; i < 64; i++) {
711
+ if (prevBoard[i] !== nextBoard[i]) {
712
+ const set = squareListeners[i];
713
+ if (set && set.size > 0) notify(set);
714
+ }
715
+ }
716
+ }
717
+ if (globalListeners.size > 0) notify(globalListeners);
718
+ };
719
+ return { getSnapshot, subscribe, subscribeSquare, commit };
720
+ }
721
+
722
+ // src/core/board-model.ts
723
+ var EMPTY_SET = Object.freeze(
724
+ /* @__PURE__ */ new Set()
725
+ );
726
+ function moveTo(m) {
727
+ return m >> 6 & 63;
728
+ }
729
+ function normalizeCastlingTarget(from, to) {
730
+ if (from === 4) {
731
+ if (to === 6) return 7;
732
+ if (to === 2) return 0;
733
+ } else if (from === 60) {
734
+ if (to === 62) return 63;
735
+ if (to === 58) return 56;
736
+ }
737
+ return to;
738
+ }
739
+ function createBoardModel(engine, options = {}) {
740
+ const freezeSnapshots = options.freezeSnapshots ?? process.env["NODE_ENV"] !== "production";
741
+ const legalMoveIndex = createLegalMoveIndex(options.legalMoveIndex ?? {});
742
+ const arrowModel = createArrowModel();
743
+ const premoveBuffer = createPremoveBuffer();
744
+ const drag = createDragController(options.dragController ?? {});
745
+ const history = [];
746
+ const redoStack = [];
747
+ let selected = null;
748
+ let lastMove = null;
749
+ let lastAnimations = [];
750
+ let disposed = false;
751
+ const stageBuffer = new Uint8Array(64);
752
+ const readBoardCopy = () => {
753
+ engine.readBoard(stageBuffer);
754
+ return new Uint8Array(stageBuffer);
755
+ };
756
+ const computeLegalTargets = (fromBoard) => {
757
+ if (selected === null) return EMPTY_SET;
758
+ const pieceOnSquare = fromBoard[selected];
759
+ if (pieceOnSquare === 0 || pieceOnSquare === void 0) return EMPTY_SET;
760
+ const hash = engine.hash();
761
+ let tos = legalMoveIndex.get(hash, selected);
762
+ if (tos === void 0) {
763
+ const moves = engine.legalMoves(selected);
764
+ const buf = new Uint8Array(moves.length);
765
+ for (let i = 0; i < moves.length; i++) {
766
+ const m = moves[i];
767
+ if (m === void 0) continue;
768
+ buf[i] = moveTo(m);
769
+ }
770
+ legalMoveIndex.set(hash, selected, buf);
771
+ tos = buf;
772
+ }
773
+ if (tos.length === 0) return EMPTY_SET;
774
+ const set = /* @__PURE__ */ new Set();
775
+ for (let i = 0; i < tos.length; i++) {
776
+ const t = tos[i];
777
+ if (t !== void 0) set.add(t);
778
+ }
779
+ return set;
780
+ };
781
+ const buildSnapshot = () => {
782
+ const board = readBoardCopy();
783
+ const legalTargets = computeLegalTargets(board);
784
+ const snap = {
785
+ board,
786
+ turn: engine.turn(),
787
+ hash: engine.hash(),
788
+ lastMove,
789
+ selected,
790
+ legalTargets,
791
+ inCheck: engine.inCheck(),
792
+ isGameOver: engine.isGameOver(),
793
+ historyPly: history.length,
794
+ historyLength: history.length + redoStack.length,
795
+ arrows: arrowModel.arrows,
796
+ premoves: premoveBuffer.all
797
+ };
798
+ return freezeSnapshots ? Object.freeze(snap) : snap;
799
+ };
800
+ const store = createBoardStore(buildSnapshot());
801
+ const commitWith = (triggerMove) => {
802
+ const prev = store.getSnapshot();
803
+ const next = buildSnapshot();
804
+ lastAnimations = planAnimations(prev.board, next.board, triggerMove);
805
+ store.commit(next);
806
+ };
807
+ const tryApplyPremoves = () => {
808
+ let last = null;
809
+ while (premoveBuffer.length > 0) {
810
+ const pm = premoveBuffer.peek();
811
+ if (pm === void 0) break;
812
+ const m = engine.makeMove(pm.from, pm.to, pm.promotion);
813
+ if (m === null) {
814
+ premoveBuffer.clear();
815
+ break;
816
+ }
817
+ premoveBuffer.shift();
818
+ history.push(m);
819
+ last = m;
820
+ }
821
+ return last;
822
+ };
823
+ const selectSquare = (index) => {
824
+ if (selected === index) return;
825
+ selected = index;
826
+ commitWith(null);
827
+ };
828
+ const tryMove = (from, to, promotion) => {
829
+ const resolvedTo = normalizeCastlingTarget(from, to);
830
+ let m = engine.makeMove(from, resolvedTo, promotion);
831
+ if (m === null && resolvedTo !== to) {
832
+ m = engine.makeMove(from, to, promotion);
833
+ }
834
+ if (m === null) return null;
835
+ redoStack.length = 0;
836
+ history.push(m);
837
+ lastMove = m;
838
+ selected = null;
839
+ const last = tryApplyPremoves();
840
+ if (last === null) {
841
+ commitWith(m);
842
+ } else {
843
+ lastMove = last;
844
+ commitWith(null);
845
+ }
846
+ return m;
847
+ };
848
+ const undo = () => {
849
+ const m = engine.undo();
850
+ if (m === null) return null;
851
+ redoStack.push(m);
852
+ history.pop();
853
+ lastMove = history[history.length - 1] ?? null;
854
+ selected = null;
855
+ commitWith(null);
856
+ return m;
857
+ };
858
+ const redo = () => {
859
+ const m = redoStack.pop();
860
+ if (m === void 0) return null;
861
+ const from = m & 63;
862
+ const to = moveTo(m);
863
+ const promoBits = m >> 12 & 15;
864
+ const promotion = promoBits > 0 ? promoBits : void 0;
865
+ const applied = engine.makeMove(from, to, promotion);
866
+ if (applied === null) {
867
+ return null;
868
+ }
869
+ history.push(applied);
870
+ lastMove = applied;
871
+ selected = null;
872
+ commitWith(applied);
873
+ return applied;
874
+ };
875
+ const goto = (ply) => {
876
+ if (!Number.isInteger(ply) || ply < 0) return;
877
+ const total = history.length + redoStack.length;
878
+ if (ply > total) return;
879
+ while (history.length > ply) {
880
+ const m = engine.undo();
881
+ if (m === null) break;
882
+ redoStack.push(m);
883
+ history.pop();
884
+ }
885
+ while (history.length < ply) {
886
+ const m = redoStack.pop();
887
+ if (m === void 0) break;
888
+ const from = m & 63;
889
+ const to = moveTo(m);
890
+ const promoBits = m >> 12 & 15;
891
+ const promotion = promoBits > 0 ? promoBits : void 0;
892
+ const applied = engine.makeMove(from, to, promotion);
893
+ if (applied === null) break;
894
+ history.push(applied);
895
+ }
896
+ lastMove = history[history.length - 1] ?? null;
897
+ selected = null;
898
+ commitWith(null);
899
+ };
900
+ const load = (fen) => {
901
+ engine.load(fen);
902
+ history.length = 0;
903
+ redoStack.length = 0;
904
+ premoveBuffer.clear();
905
+ arrowModel.clear();
906
+ selected = null;
907
+ lastMove = null;
908
+ legalMoveIndex.clear();
909
+ commitWith(null);
910
+ };
911
+ const syncPosition = ({
912
+ fen,
913
+ managedArrows,
914
+ preserveUserArrows = false
915
+ }) => {
916
+ const positionChanged = engine.fen() !== fen;
917
+ if (positionChanged) {
918
+ engine.load(fen);
919
+ history.length = 0;
920
+ redoStack.length = 0;
921
+ premoveBuffer.clear();
922
+ if (preserveUserArrows) {
923
+ if (managedArrows !== void 0) {
924
+ arrowModel.setManaged(managedArrows);
925
+ }
926
+ } else {
927
+ arrowModel.clear();
928
+ if (managedArrows !== void 0) {
929
+ arrowModel.setManaged(managedArrows);
930
+ }
931
+ }
932
+ selected = null;
933
+ lastMove = null;
934
+ legalMoveIndex.clear();
935
+ commitWith(null);
936
+ return;
937
+ }
938
+ if (managedArrows === void 0) {
939
+ return;
940
+ }
941
+ arrowModel.setManaged(managedArrows);
942
+ if (arrowModel.lastChanged) commitWith(null);
943
+ };
944
+ const reset = () => {
945
+ engine.reset();
946
+ history.length = 0;
947
+ redoStack.length = 0;
948
+ premoveBuffer.clear();
949
+ arrowModel.clear();
950
+ selected = null;
951
+ lastMove = null;
952
+ legalMoveIndex.clear();
953
+ commitWith(null);
954
+ };
955
+ const isLegal = (from, to, promotion) => {
956
+ const resolvedTo = normalizeCastlingTarget(from, to);
957
+ const hash = engine.hash();
958
+ const cached = legalMoveIndex.get(hash, from);
959
+ if (cached !== void 0 && promotion === void 0) {
960
+ for (let i = 0; i < cached.length; i++) {
961
+ if (cached[i] === resolvedTo || cached[i] === to) return true;
962
+ }
963
+ return false;
964
+ }
965
+ const moves = engine.legalMoves(from);
966
+ for (let i = 0; i < moves.length; i++) {
967
+ const m = moves[i];
968
+ if (m === void 0) continue;
969
+ const target = moveTo(m);
970
+ if (target !== resolvedTo && target !== to) continue;
971
+ if (promotion === void 0) return true;
972
+ const promoBits = m >> 12 & 15;
973
+ if (promoBits === 0) return true;
974
+ if (promoBits === promotion) return true;
975
+ }
976
+ return false;
977
+ };
978
+ const legalFrom = (from) => {
979
+ const hash = engine.hash();
980
+ let tos = legalMoveIndex.get(hash, from);
981
+ if (tos === void 0) {
982
+ const moves = engine.legalMoves(from);
983
+ const buf = new Uint8Array(moves.length);
984
+ for (let i = 0; i < moves.length; i++) {
985
+ const m = moves[i];
986
+ if (m === void 0) continue;
987
+ buf[i] = moveTo(m);
988
+ }
989
+ legalMoveIndex.set(hash, from, buf);
990
+ tos = buf;
991
+ }
992
+ if (tos.length === 0) return EMPTY_SET;
993
+ const set = /* @__PURE__ */ new Set();
994
+ for (let i = 0; i < tos.length; i++) {
995
+ const t = tos[i];
996
+ if (t !== void 0) {
997
+ set.add(t);
998
+ if (from === 4) {
999
+ if (t === 7) set.add(6);
1000
+ else if (t === 0) set.add(2);
1001
+ } else if (from === 60) {
1002
+ if (t === 63) set.add(62);
1003
+ else if (t === 56) set.add(58);
1004
+ }
1005
+ }
1006
+ }
1007
+ return set;
1008
+ };
1009
+ const addArrow = (arrow) => {
1010
+ arrowModel.add(arrow);
1011
+ if (arrowModel.lastChanged) commitWith(null);
1012
+ };
1013
+ const removeArrow = (arrow) => {
1014
+ arrowModel.remove(arrow);
1015
+ if (arrowModel.lastChanged) commitWith(null);
1016
+ };
1017
+ const toggleArrow = (arrow) => {
1018
+ arrowModel.toggle(arrow);
1019
+ if (arrowModel.lastChanged) commitWith(null);
1020
+ };
1021
+ const clearArrows = () => {
1022
+ arrowModel.clear();
1023
+ if (arrowModel.lastChanged) commitWith(null);
1024
+ };
1025
+ const clearUserArrows = () => {
1026
+ arrowModel.clearUser();
1027
+ if (arrowModel.lastChanged) commitWith(null);
1028
+ };
1029
+ const clearManagedArrows = () => {
1030
+ arrowModel.clearManaged();
1031
+ if (arrowModel.lastChanged) commitWith(null);
1032
+ };
1033
+ const setArrows = (arrows) => {
1034
+ arrowModel.setAll(arrows);
1035
+ if (arrowModel.lastChanged) commitWith(null);
1036
+ };
1037
+ const setManagedArrows = (arrows) => {
1038
+ arrowModel.setManaged(arrows);
1039
+ if (arrowModel.lastChanged) commitWith(null);
1040
+ };
1041
+ const queuePremove = (premove) => {
1042
+ premoveBuffer.push(premove);
1043
+ commitWith(null);
1044
+ };
1045
+ const clearPremoves = () => {
1046
+ if (premoveBuffer.length === 0) return;
1047
+ premoveBuffer.clear();
1048
+ commitWith(null);
1049
+ };
1050
+ const dispose = () => {
1051
+ if (disposed) return;
1052
+ disposed = true;
1053
+ engine.dispose();
1054
+ legalMoveIndex.clear();
1055
+ history.length = 0;
1056
+ redoStack.length = 0;
1057
+ premoveBuffer.clear();
1058
+ arrowModel.clear();
1059
+ };
1060
+ return {
1061
+ getSnapshot: () => store.getSnapshot(),
1062
+ subscribe: (l) => store.subscribe(l),
1063
+ subscribeSquare: (i, l) => store.subscribeSquare(i, l),
1064
+ selectSquare,
1065
+ tryMove,
1066
+ undo,
1067
+ redo,
1068
+ goto,
1069
+ load,
1070
+ syncPosition,
1071
+ reset,
1072
+ isLegal,
1073
+ legalFrom,
1074
+ addArrow,
1075
+ removeArrow,
1076
+ toggleArrow,
1077
+ clearArrows,
1078
+ clearUserArrows,
1079
+ clearManagedArrows,
1080
+ setArrows,
1081
+ setManagedArrows,
1082
+ queuePremove,
1083
+ clearPremoves,
1084
+ drag,
1085
+ legalMoveCache: legalMoveIndex,
1086
+ engine,
1087
+ get lastAnimations() {
1088
+ return lastAnimations;
1089
+ },
1090
+ dispose
1091
+ };
1092
+ }
1093
+
1094
+ // src/core/engine-adapter.ts
1095
+ function writeBoardCell(out, index, cell) {
1096
+ out[index] = cell;
1097
+ }
1098
+
1099
+ // src/core/index.ts
1100
+ var PACKAGE_VERSION = "0.1.0-alpha";
1101
+
1102
+ export { BOARD_CELL_BB, BOARD_CELL_BK, BOARD_CELL_BN, BOARD_CELL_BP, BOARD_CELL_BQ, BOARD_CELL_BR, BOARD_CELL_EMPTY, BOARD_CELL_WB, BOARD_CELL_WK, BOARD_CELL_WN, BOARD_CELL_WP, BOARD_CELL_WQ, BOARD_CELL_WR, Color, MOVE2_PROMO_BISHOP, MOVE2_PROMO_KNIGHT, MOVE2_PROMO_NONE, MOVE2_PROMO_QUEEN, MOVE2_PROMO_ROOK, PACKAGE_VERSION, PieceType, animationInspect, colorOf, createArrowModel, createBoardModel, createBoardStore, createDragController, createGigachessAdapter, createLegalMoveIndex, createPremoveBuffer, decodePackedMove, encodeBoardCell, isEmptyCell, isSquareIndex, makeArrow, makePremove, packMove, pieceTypeOf, planAnimations, preloadGigachessAdapter, toSquareIndex, unpackMove, writeBoardCell };
1103
+ //# sourceMappingURL=chunk-J6GGNP5S.js.map
1104
+ //# sourceMappingURL=chunk-J6GGNP5S.js.map