doubletwelve 0.2.0 → 0.3.1

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.
package/dist/index.js CHANGED
@@ -1,48 +1,73 @@
1
- import { jsx as M, Fragment as xe, jsxs as D } from "react/jsx-runtime";
2
- import { useEffect as ne, useMemo as Ye, useState as B, useRef as ce, useCallback as Re } from "react";
3
- const Ae = {
4
- "3x3": { rows: [20, 50, 80], cols: [20, 50, 80], size: "18%" },
5
- "3x4": { rows: [24, 50, 76], cols: [22, 40, 60, 78], size: "12%" },
6
- "4x3": { rows: [15, 38, 62, 85], cols: [20, 50, 80], size: "14%" }
7
- };
8
- function Fe(e) {
9
- const t = Ae[e.gridSize];
10
- return {
11
- top: e.top ?? `${t.rows[e.row]}%`,
12
- left: e.left ?? `${t.cols[e.col]}%`,
13
- width: t.size,
14
- height: t.size
15
- };
1
+ import { jsx as z, Fragment as we, jsxs as $ } from "react/jsx-runtime";
2
+ import { useContext as Se, createContext as Ke, useEffect as ae, useMemo as He, useState as G, useRef as ve, useCallback as Ze } from "react";
3
+ const Je = {};
4
+ function ze(e, t) {
5
+ return t ? {
6
+ ...e,
7
+ ...t,
8
+ tileDataAttributes: {
9
+ ...e.tileDataAttributes,
10
+ ...t.tileDataAttributes
11
+ }
12
+ } : e;
13
+ }
14
+ function Qe(e) {
15
+ if (!e)
16
+ return {};
17
+ const t = {};
18
+ for (const [o, n] of Object.entries(e))
19
+ n === void 0 || n === !1 || (t[`data-${o}`] = n === !0 ? "true" : String(n));
20
+ return t;
16
21
  }
17
- const Le = ({
18
- row: e,
19
- col: t,
20
- gridSize: n,
21
- color: o,
22
- hollow: r,
23
- top: i,
24
- left: l
22
+ const le = Ke(Je), sn = ({
23
+ theme: e,
24
+ children: t
25
25
  }) => {
26
- const s = Fe({ row: e, col: t, gridSize: n, top: i, left: l });
27
- return /* @__PURE__ */ M(
26
+ const o = Se(le), n = ze(o, e);
27
+ return /* @__PURE__ */ z(le.Provider, { value: n, children: t });
28
+ };
29
+ function Ie(e) {
30
+ const t = Se(le);
31
+ return ze(t, e);
32
+ }
33
+ const We = ({ ctx: e, theme: t }) => {
34
+ const { row: o, col: n, gridSize: r, color: i, hollow: l, positionStyle: s } = e, a = t?.pipStyle?.(e) ?? {};
35
+ return /* @__PURE__ */ z(
28
36
  "div",
29
37
  {
30
38
  "data-testid": "pip",
31
- "data-row": e,
32
- "data-col": t,
33
- "data-grid": n,
39
+ "data-row": o,
40
+ "data-col": n,
41
+ "data-grid": r,
42
+ "data-pip-value": e.value,
43
+ "data-hollow": l ? "true" : void 0,
34
44
  style: {
35
45
  position: "absolute",
36
- backgroundColor: r ? "transparent" : o,
37
- border: r ? "2px solid #888" : void 0,
38
46
  borderRadius: "50%",
39
47
  transform: "translate(-50%, -50%)",
40
- boxShadow: r ? void 0 : "1px 2px 3px rgba(0,0,0,0.3)",
41
- ...s
48
+ backgroundColor: l ? "transparent" : i,
49
+ border: l ? `2px solid ${i}` : void 0,
50
+ boxShadow: l ? void 0 : "1px 2px 3px rgba(0,0,0,0.3)",
51
+ ...s,
52
+ ...a
42
53
  }
43
54
  }
44
55
  );
45
- }, _e = {
56
+ }, et = {
57
+ "3x3": { rows: [20, 50, 80], cols: [20, 50, 80], size: "18%" },
58
+ "3x4": { rows: [24, 50, 76], cols: [22, 40, 60, 78], size: "12%" },
59
+ "4x3": { rows: [15, 38, 62, 85], cols: [20, 50, 80], size: "14%" }
60
+ };
61
+ function tt(e) {
62
+ const t = et[e.gridSize];
63
+ return {
64
+ top: e.top ?? `${t.rows[e.row]}%`,
65
+ left: e.left ?? `${t.cols[e.col]}%`,
66
+ width: t.size,
67
+ height: t.size
68
+ };
69
+ }
70
+ const nt = {
46
71
  0: [],
47
72
  1: [{ row: 1, col: 1, gridSize: "3x3" }],
48
73
  2: [
@@ -145,10 +170,10 @@ const Le = ({
145
170
  { row: 3, col: 2, gridSize: "4x3" }
146
171
  ]
147
172
  };
148
- function Ne(e) {
149
- return _e[e] ?? [];
173
+ function ot(e) {
174
+ return nt[e] ?? [];
150
175
  }
151
- const j = {
176
+ const q = {
152
177
  0: { color: "transparent" },
153
178
  1: { color: "#1a1a1a" },
154
179
  2: { color: "#8B1A1A" },
@@ -162,44 +187,45 @@ const j = {
162
187
  10: { color: "#EA580C" },
163
188
  11: { color: "#166534" },
164
189
  12: { color: "#DC2626" }
165
- }, Mt = j;
166
- function $t(e) {
167
- return { ...j, ...e };
190
+ }, an = q;
191
+ function un(e) {
192
+ return { ...q, ...e };
168
193
  }
169
- function ge(e, t) {
194
+ function Pe(e, t) {
170
195
  if (t !== void 0)
171
- return t[e] ?? j[e] ?? { color: "#1a1a1a" };
196
+ return t[e] ?? q[e] ?? { color: "#1a1a1a" };
172
197
  }
173
- function kt(e) {
174
- return ge(e, j);
198
+ function cn(e) {
199
+ return Pe(e, q);
175
200
  }
176
- const Be = (e, t, n) => {
177
- const o = ge(e, n);
178
- return o ? { color: o.color, hollow: o.hollow } : { color: t };
179
- }, je = ({
201
+ const rt = (e, t, o) => {
202
+ const n = Pe(e, o);
203
+ return n ? { color: n.color, hollow: n.hollow } : { color: t };
204
+ }, it = ({
180
205
  value: e,
181
206
  pipColor: t,
182
- pipColors: n
207
+ pipColors: o
183
208
  }) => {
184
- const { color: o, hollow: r } = Be(e, t, n), i = Ne(e);
185
- return /* @__PURE__ */ M(xe, { children: i.map((l, s) => /* @__PURE__ */ M(
186
- Le,
187
- {
188
- row: l.row,
189
- col: l.col,
190
- gridSize: l.gridSize,
191
- color: o,
192
- hollow: r,
193
- top: l.top,
194
- left: l.left
195
- },
196
- s
197
- )) });
198
- }, de = ({
209
+ const n = Ie(), { color: r, hollow: i } = rt(e, t, o), l = ot(e);
210
+ return /* @__PURE__ */ z(we, { children: l.map((s, a) => {
211
+ const c = {
212
+ value: e,
213
+ row: s.row,
214
+ col: s.col,
215
+ gridSize: s.gridSize,
216
+ color: r,
217
+ hollow: i,
218
+ top: s.top,
219
+ left: s.left,
220
+ positionStyle: tt(s)
221
+ };
222
+ return n.renderPip ? /* @__PURE__ */ z("span", { children: n.renderPip(c) }, a) : /* @__PURE__ */ z(We, { ctx: c, theme: n }, a);
223
+ }) });
224
+ }, xe = ({
199
225
  value: e,
200
226
  pipColor: t,
201
- pipColors: n
202
- }) => /* @__PURE__ */ M(
227
+ pipColors: o
228
+ }) => /* @__PURE__ */ z(
203
229
  "div",
204
230
  {
205
231
  style: {
@@ -209,26 +235,37 @@ const Be = (e, t, n) => {
209
235
  padding: "0",
210
236
  overflow: "hidden"
211
237
  },
212
- children: /* @__PURE__ */ M(je, { value: e, pipColor: t, pipColors: n })
238
+ children: /* @__PURE__ */ z(it, { value: e, pipColor: t, pipColors: o })
213
239
  }
214
- ), ve = ({
240
+ ), Te = ({
215
241
  value1: e = 0,
216
242
  value2: t = 0,
217
- width: n = 100,
218
- height: o = 200,
243
+ width: o = 100,
244
+ height: n = 200,
219
245
  backgroundColor: r = "white",
220
246
  pipColor: i = "black",
221
247
  pipColors: l,
222
248
  borderColor: s = "black",
223
- rotation: a = 0
249
+ rotation: a = 0,
250
+ theme: c
224
251
  }) => {
225
- const c = Math.min(Math.max(e, 0), 12), d = Math.min(Math.max(t, 0), 12);
226
- return /* @__PURE__ */ D(
252
+ const d = Ie(c), u = Math.min(Math.max(e, 0), 12), f = Math.min(Math.max(t, 0), 12), p = {
253
+ value1: u,
254
+ value2: f,
255
+ width: o,
256
+ height: n,
257
+ backgroundColor: r,
258
+ borderColor: s,
259
+ rotation: a
260
+ }, v = d.tileStyle?.(p) ?? {}, S = d.halfDividerStyle?.(p) ?? {};
261
+ return /* @__PURE__ */ $(
227
262
  "div",
228
263
  {
264
+ className: d.tileClassName,
265
+ ...Qe(d.tileDataAttributes),
229
266
  style: {
230
- width: `${n}px`,
231
- height: `${o}px`,
267
+ width: `${o}px`,
268
+ height: `${n}px`,
232
269
  backgroundColor: r,
233
270
  borderColor: s,
234
271
  borderWidth: "1px",
@@ -239,10 +276,11 @@ const Be = (e, t, n) => {
239
276
  boxShadow: "0 1px 2px rgba(0,0,0,0.2)",
240
277
  display: "flex",
241
278
  flexDirection: "column",
242
- overflow: "hidden"
279
+ overflow: "hidden",
280
+ ...v
243
281
  },
244
282
  children: [
245
- /* @__PURE__ */ M(
283
+ /* @__PURE__ */ z(
246
284
  "div",
247
285
  {
248
286
  style: {
@@ -250,62 +288,63 @@ const Be = (e, t, n) => {
250
288
  position: "relative",
251
289
  borderBottomWidth: "1px",
252
290
  borderBottomStyle: "solid",
253
- borderBottomColor: s
291
+ borderBottomColor: s,
292
+ ...S
254
293
  },
255
- children: /* @__PURE__ */ M(de, { value: c, pipColor: i, pipColors: l })
294
+ children: /* @__PURE__ */ z(xe, { value: u, pipColor: i, pipColors: l })
256
295
  }
257
296
  ),
258
- /* @__PURE__ */ M(
297
+ /* @__PURE__ */ z(
259
298
  "div",
260
299
  {
261
300
  style: {
262
301
  flex: 1,
263
302
  position: "relative"
264
303
  },
265
- children: /* @__PURE__ */ M(de, { value: d, pipColor: i, pipColors: l })
304
+ children: /* @__PURE__ */ z(xe, { value: f, pipColor: i, pipColors: l })
266
305
  }
267
306
  )
268
307
  ]
269
308
  }
270
309
  );
271
- }, T = 60, I = 120, Ue = [-45, 45];
272
- function Z(e, t = T, n = I) {
273
- return e ? t / 2 : n / 2;
310
+ }, C = 60, D = 120, lt = [-45, 45];
311
+ function W(e, t = C, o = D) {
312
+ return e ? t / 2 : o / 2;
274
313
  }
275
- function O(e, t, n = T, o = I) {
276
- return Z(e, n, o) + Z(t, n, o);
314
+ function A(e, t, o = C, n = D) {
315
+ return W(e, o, n) + W(t, o, n);
277
316
  }
278
- function R(e) {
317
+ function Y(e) {
279
318
  const t = e * Math.PI / 180;
280
319
  return {
281
320
  dirX: Math.cos(t),
282
321
  dirY: Math.sin(t)
283
322
  };
284
323
  }
285
- function F(e) {
286
- const { dirX: t, dirY: n } = R(e);
287
- return { perpX: -n, perpY: t };
324
+ function L(e) {
325
+ const { dirX: t, dirY: o } = Y(e);
326
+ return { perpX: -o, perpY: t };
288
327
  }
289
- function Ve(e) {
290
- const t = e.map((n) => ({ ...n }));
291
- for (let n = 1; n < t.length; n++) {
292
- const o = t[n], r = t[n - 1].value2;
293
- !(o.value1 === o.value2) && o.value1 !== r && o.value2 === r && (t[n] = { value1: o.value2, value2: o.value1 });
328
+ function st(e) {
329
+ const t = e.map((o) => ({ ...o }));
330
+ for (let o = 1; o < t.length; o++) {
331
+ const n = t[o], r = t[o - 1].value2;
332
+ !(n.value1 === n.value2) && n.value1 !== r && n.value2 === r && (t[o] = { value1: n.value2, value2: n.value1 });
294
333
  }
295
334
  return t;
296
335
  }
297
- function U(e) {
298
- const { dirX: t, dirY: n } = R(e);
299
- return Math.abs(t) >= Math.abs(n) ? t >= 0 ? 1 : -1 : n >= 0 ? 1 : -1;
336
+ function K(e) {
337
+ const { dirX: t, dirY: o } = Y(e);
338
+ return Math.abs(t) >= Math.abs(o) ? t >= 0 ? 1 : -1 : o >= 0 ? 1 : -1;
300
339
  }
301
- function be(e, t) {
340
+ function Me(e, t) {
302
341
  return e === 0 ? t : e === t ? -t : t;
303
342
  }
304
- function ye({
343
+ function ke({
305
344
  orientedDominoes: e,
306
345
  startX: t,
307
- startY: n,
308
- angle: o,
346
+ startY: o,
347
+ angle: n,
309
348
  layoutStyle: r,
310
349
  dominoWidth: i,
311
350
  dominoHeight: l,
@@ -313,96 +352,96 @@ function ye({
313
352
  outwardSign: a,
314
353
  hubIndex: c
315
354
  }) {
316
- const d = [], { dirX: u, dirY: f } = R(o), { perpX: p, perpY: b } = F(o), m = r === "offset" && c != null, w = [];
317
- let z = t + u * s, v = n + f * s, k = 0, x = 0;
318
- const S = i / 2, C = (g) => {
319
- const h = (g - k) * S;
320
- z += p * h, v += b * h, k = g;
355
+ const d = [], { dirX: u, dirY: f } = Y(n), { perpX: p, perpY: v } = L(n), S = r === "offset" && c != null, m = [];
356
+ let P = t + u * s, b = o + f * s, M = 0, g = 0;
357
+ const I = i / 2, k = (x) => {
358
+ const h = (x - M) * I;
359
+ P += p * h, b += v * h, M = x;
321
360
  };
322
- for (let g = 0; g < e.length; g++) {
323
- const h = e[g], y = h.value1 === h.value2, $ = g > 0 && e[g - 1].value1 === e[g - 1].value2;
324
- r === "linear" ? g > 0 && (y ? (z += u * O($, !0, i, l), v += f * O($, !0, i, l)) : $ ? (z += u * O(!0, !1, i, l), v += f * O(!0, !1, i, l)) : (z += u * l, v += f * l)) : y ? g > 0 && (z += u * O($, !0, i, l), v += f * O($, !0, i, l)) : (g === 0 ? x = a : $ ? (z += u * O(!0, !1, i, l), v += f * O(!0, !1, i, l)) : (z += u * (l / 2), v += f * (l / 2), x = be(x, a)), C(x)), w.push(k), d.push({
325
- x: z,
326
- y: v,
327
- rotation: y ? o + 180 : o - 90,
361
+ for (let x = 0; x < e.length; x++) {
362
+ const h = e[x], y = h.value1 === h.value2, T = x > 0 && e[x - 1].value1 === e[x - 1].value2;
363
+ r === "linear" ? x > 0 && (y ? (P += u * A(T, !0, i, l), b += f * A(T, !0, i, l)) : T ? (P += u * A(!0, !1, i, l), b += f * A(!0, !1, i, l)) : (P += u * l, b += f * l)) : y ? x > 0 && (P += u * A(T, !0, i, l), b += f * A(T, !0, i, l)) : (x === 0 ? g = a : T ? (P += u * A(!0, !1, i, l), b += f * A(!0, !1, i, l)) : (P += u * (l / 2), b += f * (l / 2), g = Me(g, a)), k(g)), m.push(M), d.push({
364
+ x: P,
365
+ y: b,
366
+ rotation: y ? n + 180 : n - 90,
328
367
  isDouble: y,
329
368
  value1: h.value1,
330
369
  value2: h.value2
331
370
  });
332
371
  }
333
- if (m && c != null) {
334
- const g = -w[c] * S;
335
- if (g !== 0)
372
+ if (S && c != null) {
373
+ const x = -m[c] * I;
374
+ if (x !== 0)
336
375
  for (let h = 0; h < d.length; h++)
337
376
  d[h] = {
338
377
  ...d[h],
339
- x: d[h].x + p * g,
340
- y: d[h].y + b * g
378
+ x: d[h].x + p * x,
379
+ y: d[h].y + v * x
341
380
  };
342
381
  }
343
382
  return d;
344
383
  }
345
- function we(e, t) {
384
+ function Ce(e, t) {
346
385
  if (!e || e.length === 0) return [];
347
- const n = /* @__PURE__ */ new Map();
348
- for (const o of e)
349
- Number.isInteger(o.index) && (o.index <= 0 || o.index >= t || n.set(o.index, o.turn));
350
- return [...n.entries()].map(([o, r]) => ({ index: o, turn: r })).sort((o, r) => o.index - r.index);
386
+ const o = /* @__PURE__ */ new Map();
387
+ for (const n of e)
388
+ Number.isInteger(n.index) && (n.index <= 0 || n.index >= t || o.set(n.index, n.turn));
389
+ return [...o.entries()].map(([n, r]) => ({ index: n, turn: r })).sort((n, r) => n.index - r.index);
351
390
  }
352
- function Ge(e, t, n, o = 1 / 0) {
353
- const r = we(t, Number.isFinite(o) ? o : n + 1);
391
+ function at(e, t, o, n = 1 / 0) {
392
+ const r = Ce(t, Number.isFinite(n) ? n : o + 1);
354
393
  let i = e;
355
394
  for (const l of r)
356
- if (l.index <= n) i += l.turn;
395
+ if (l.index <= o) i += l.turn;
357
396
  else break;
358
397
  return i;
359
398
  }
360
- function qe(e, t, n, o) {
361
- const { startX: r, startY: i, angle: l, layoutStyle: s, dominoWidth: a, dominoHeight: c, leadGap: d, outwardSign: u } = t, f = [0, ...n.map((v) => v.index), e.length], p = [];
362
- let b = l, m = r, w = i, z = d;
363
- for (let v = 0; v < f.length - 1; v++) {
364
- const k = e.slice(f[v], f[v + 1]);
365
- if (k.length === 0) continue;
366
- const x = v === 0 && o != null && o < f[1] ? o : void 0, S = ye({
367
- orientedDominoes: k,
368
- startX: m,
369
- startY: w,
370
- angle: b,
399
+ function ut(e, t, o, n) {
400
+ const { startX: r, startY: i, angle: l, layoutStyle: s, dominoWidth: a, dominoHeight: c, leadGap: d, outwardSign: u } = t, f = [0, ...o.map((b) => b.index), e.length], p = [];
401
+ let v = l, S = r, m = i, P = d;
402
+ for (let b = 0; b < f.length - 1; b++) {
403
+ const M = e.slice(f[b], f[b + 1]);
404
+ if (M.length === 0) continue;
405
+ const g = b === 0 && n != null && n < f[1] ? n : void 0, I = ke({
406
+ orientedDominoes: M,
407
+ startX: S,
408
+ startY: m,
409
+ angle: v,
371
410
  layoutStyle: s,
372
411
  dominoWidth: a,
373
412
  dominoHeight: c,
374
- leadGap: z,
413
+ leadGap: P,
375
414
  outwardSign: u,
376
- hubIndex: x
415
+ hubIndex: g
377
416
  });
378
- if (p.push(...S), v >= f.length - 2) break;
379
- const g = S[S.length - 1], h = R(b), y = Z(g.isDouble, a, c);
380
- b += n[v].turn;
381
- const $ = e[f[v + 1]], E = $.value1 === $.value2, A = Z(E, a, c), _ = R(b), N = F(b), P = a / 2, W = g.x + h.dirX * (y - P) + _.dirX * (A + P), V = g.y + h.dirY * (y - P) + _.dirY * (A + P), X = s === "offset" && !E, G = X ? N.perpX * P * u : 0, q = X ? N.perpY * P * u : 0;
382
- m = W - G, w = V - q, z = 0;
417
+ if (p.push(...I), b >= f.length - 2) break;
418
+ const x = I[I.length - 1], h = Y(v), y = W(x.isDouble, a, c);
419
+ v += o[b].turn;
420
+ const T = e[f[b + 1]], O = T.value1 === T.value2, _ = W(O, a, c), U = Y(v), j = L(v), E = a / 2, oe = x.x + h.dirX * (y - E) + U.dirX * (_ + E), H = x.y + h.dirY * (y - E) + U.dirY * (_ + E), R = s === "offset" && !O, Z = R ? j.perpX * E * u : 0, J = R ? j.perpY * E * u : 0;
421
+ S = oe - Z, m = H - J, P = 0;
383
422
  }
384
423
  return p;
385
424
  }
386
- function Ke({
425
+ function ct({
387
426
  startX: e,
388
427
  startY: t,
389
- angle: n,
390
- dominoes: o,
428
+ angle: o,
429
+ dominoes: n,
391
430
  layoutStyle: r,
392
- dominoWidth: i = T,
393
- dominoHeight: l = I,
431
+ dominoWidth: i = C,
432
+ dominoHeight: l = D,
394
433
  leadGap: s = l * 0.3,
395
434
  outwardSign: a,
396
435
  hubIndex: c,
397
436
  bends: d
398
437
  }) {
399
- const u = Ve([...o]), f = a ?? U(n), p = we(d, u.length);
400
- return p.length > 0 ? qe(
438
+ const u = st([...n]), f = a ?? K(o), p = Ce(d, u.length);
439
+ return p.length > 0 ? ut(
401
440
  u,
402
441
  {
403
442
  startX: e,
404
443
  startY: t,
405
- angle: n,
444
+ angle: o,
406
445
  layoutStyle: r,
407
446
  dominoWidth: i,
408
447
  dominoHeight: l,
@@ -411,11 +450,11 @@ function Ke({
411
450
  },
412
451
  p,
413
452
  c
414
- ) : ye({
453
+ ) : ke({
415
454
  orientedDominoes: u,
416
455
  startX: e,
417
456
  startY: t,
418
- angle: n,
457
+ angle: o,
419
458
  layoutStyle: r,
420
459
  dominoWidth: i,
421
460
  dominoHeight: l,
@@ -424,8 +463,8 @@ function Ke({
424
463
  hubIndex: c
425
464
  });
426
465
  }
427
- function fe(e, t = T, n = I) {
428
- const o = e.rotation * Math.PI / 180, r = Math.cos(o), i = Math.sin(o), l = t / 2, s = n / 2;
466
+ function be(e, t = C, o = D) {
467
+ const n = e.rotation * Math.PI / 180, r = Math.cos(n), i = Math.sin(n), l = t / 2, s = o / 2;
429
468
  return [
430
469
  [-l, -s],
431
470
  [l, -s],
@@ -436,56 +475,56 @@ function fe(e, t = T, n = I) {
436
475
  y: e.y + a * i + c * r
437
476
  }));
438
477
  }
439
- function Ze(e, t, n) {
440
- let o = 1 / 0, r = -1 / 0, i = 1 / 0, l = -1 / 0;
478
+ function dt(e, t, o) {
479
+ let n = 1 / 0, r = -1 / 0, i = 1 / 0, l = -1 / 0;
441
480
  for (const s of e) {
442
- const a = s.x * n.x + s.y * n.y;
443
- o = Math.min(o, a), r = Math.max(r, a);
481
+ const a = s.x * o.x + s.y * o.y;
482
+ n = Math.min(n, a), r = Math.max(r, a);
444
483
  }
445
484
  for (const s of t) {
446
- const a = s.x * n.x + s.y * n.y;
485
+ const a = s.x * o.x + s.y * o.y;
447
486
  i = Math.min(i, a), l = Math.max(l, a);
448
487
  }
449
- return Math.min(r, l) - Math.max(o, i);
488
+ return Math.min(r, l) - Math.max(n, i);
450
489
  }
451
- function J(e, t, n = 1, o = T, r = I) {
452
- const i = fe(e, o, r), l = fe(t, o, r);
490
+ function ee(e, t, o = 1, n = C, r = D) {
491
+ const i = be(e, n, r), l = be(t, n, r);
453
492
  for (const s of [i, l])
454
493
  for (let a = 0; a < 4; a++) {
455
- const c = s[a], d = s[(a + 1) % 4], u = d.x - c.x, f = d.y - c.y, p = Math.hypot(u, f) || 1, b = { x: -f / p, y: u / p };
456
- if (Ze(i, l, b) <= n)
494
+ const c = s[a], d = s[(a + 1) % 4], u = d.x - c.x, f = d.y - c.y, p = Math.hypot(u, f) || 1, v = { x: -f / p, y: u / p };
495
+ if (dt(i, l, v) <= o)
457
496
  return !1;
458
497
  }
459
498
  return !0;
460
499
  }
461
- function Je(e, t, n, o) {
500
+ function ft(e, t, o, n) {
462
501
  return t.some(
463
- (r) => J(e, r, 1, n, o)
502
+ (r) => ee(e, r, 1, o, n)
464
503
  );
465
504
  }
466
- function Se(e, t, n = 1, o = T, r = I) {
505
+ function De(e, t, o = 1, n = C, r = D) {
467
506
  return e.some(
468
507
  (i) => t.some(
469
- (l) => J(i, l, n, o, r)
508
+ (l) => ee(i, l, o, n, r)
470
509
  )
471
510
  );
472
511
  }
473
- function me(e, t = 1, n = T, o = I) {
512
+ function $e(e, t = 1, o = C, n = D) {
474
513
  for (let r = 0; r < e.length; r++)
475
514
  for (let i = r + 1; i < e.length; i++)
476
- if (J(e[r], e[i], t, n, o))
515
+ if (ee(e[r], e[i], t, o, n))
477
516
  return !0;
478
517
  return !1;
479
518
  }
480
- const Y = T / 4, pe = 24;
481
- function re({
519
+ const F = C / 4, ye = 24;
520
+ function ue({
482
521
  startX: e,
483
522
  startY: t,
484
- angle: n,
485
- branch: o,
523
+ angle: o,
524
+ branch: n,
486
525
  layoutStyle: r,
487
- dominoWidth: i = T,
488
- dominoHeight: l = I,
526
+ dominoWidth: i = C,
527
+ dominoHeight: l = D,
489
528
  leadGap: s,
490
529
  depth: a = 0,
491
530
  anchor: c,
@@ -494,105 +533,105 @@ function re({
494
533
  pushAxis: f,
495
534
  minPushSteps: p = 0
496
535
  }) {
497
- const b = d ?? U(n), m = o.feet ? Object.keys(o.feet).map(Number).filter((x) => {
498
- const S = o.dominoes[x];
499
- return S && S.value1 === S.value2;
500
- }).sort((x, S) => x - S)[0] : void 0, w = (x, S) => Ke({
501
- startX: x,
502
- startY: S,
503
- angle: n,
504
- dominoes: o.dominoes,
536
+ const v = d ?? K(o), S = n.feet ? Object.keys(n.feet).map(Number).filter((g) => {
537
+ const I = n.dominoes[g];
538
+ return I && I.value1 === I.value2;
539
+ }).sort((g, I) => g - I)[0] : void 0, m = (g, I) => ct({
540
+ startX: g,
541
+ startY: I,
542
+ angle: o,
543
+ dominoes: n.dominoes,
505
544
  layoutStyle: r,
506
545
  dominoWidth: i,
507
546
  dominoHeight: l,
508
547
  leadGap: s,
509
- outwardSign: b,
510
- hubIndex: m,
511
- bends: o.bends
548
+ outwardSign: v,
549
+ hubIndex: S,
550
+ bends: n.bends
512
551
  });
513
- let z = w(
514
- e + (f?.x ?? 0) * Y * p,
515
- t + (f?.y ?? 0) * Y * p
516
- ), v = c && f ? {
517
- x: c.x + f.x * Y * p,
518
- y: c.y + f.y * Y * p
552
+ let P = m(
553
+ e + (f?.x ?? 0) * F * p,
554
+ t + (f?.y ?? 0) * F * p
555
+ ), b = c && f ? {
556
+ x: c.x + f.x * F * p,
557
+ y: c.y + f.y * F * p
519
558
  } : c;
520
559
  if (f && u.length > 0)
521
- for (let x = p; x <= pe; x++) {
522
- const S = e + f.x * Y * x, C = t + f.y * Y * x, g = w(S, C);
523
- if (!g.some(
524
- (y) => Je(y, u, i, l)
525
- ) || x === pe) {
526
- z = g, v = c && {
527
- x: c.x + f.x * Y * x,
528
- y: c.y + f.y * Y * x
560
+ for (let g = p; g <= ye; g++) {
561
+ const I = e + f.x * F * g, k = t + f.y * F * g, x = m(I, k);
562
+ if (!x.some(
563
+ (y) => ft(y, u, i, l)
564
+ ) || g === ye) {
565
+ P = x, b = c && {
566
+ x: c.x + f.x * F * g,
567
+ y: c.y + f.y * F * g
529
568
  };
530
569
  break;
531
570
  }
532
571
  }
533
- u.push(...z);
534
- const k = [
572
+ u.push(...P);
573
+ const M = [
535
574
  {
536
- angle: n,
575
+ angle: o,
537
576
  depth: a,
538
577
  layoutStyle: r,
539
- outwardSign: b,
540
- dominoes: o.dominoes,
541
- layout: z,
542
- anchor: v
578
+ outwardSign: v,
579
+ dominoes: n.dominoes,
580
+ layout: P,
581
+ anchor: b
543
582
  }
544
583
  ];
545
- if (o.feet) {
546
- const x = i / 2, S = l / 2;
547
- for (const C of Object.keys(o.feet)) {
548
- const g = Number(C), h = z[g], y = o.feet[g];
584
+ if (n.feet) {
585
+ const g = i / 2, I = l / 2;
586
+ for (const k of Object.keys(n.feet)) {
587
+ const x = Number(k), h = P[x], y = n.feet[x];
549
588
  if (!h || !h.isDouble || !y)
550
589
  continue;
551
- const $ = Ge(
552
- n,
553
- o.bends,
554
- g,
555
- o.dominoes.length
556
- ), { dirX: E, dirY: A } = R($), { perpX: _, perpY: N } = F($);
557
- for (let P = 0; P < y.length; P++) {
558
- const W = y[P], V = Ue[P] ?? 0, X = Math.sign(V), G = $ + V, q = F(G), ee = -X, Ee = h.x + E * (i / 2) + _ * (l / 2) * X, Xe = h.y + A * (i / 2) + N * (l / 2) * X, ae = Ee - q.perpX * ee * x, ue = Xe - q.perpY * ee * x;
559
- k.push(
560
- ...re({
561
- startX: ae,
562
- startY: ue,
563
- angle: G,
564
- branch: W,
590
+ const T = at(
591
+ o,
592
+ n.bends,
593
+ x,
594
+ n.dominoes.length
595
+ ), { dirX: O, dirY: _ } = Y(T), { perpX: U, perpY: j } = L(T);
596
+ for (let E = 0; E < y.length; E++) {
597
+ const oe = y[E], H = lt[E] ?? 0, R = Math.sign(H), Z = T + H, J = L(Z), re = -R, Ge = h.x + O * (i / 2) + U * (l / 2) * R, qe = h.y + _ * (i / 2) + j * (l / 2) * R, he = Ge - J.perpX * re * g, ge = qe - J.perpY * re * g;
598
+ M.push(
599
+ ...ue({
600
+ startX: he,
601
+ startY: ge,
602
+ angle: Z,
603
+ branch: oe,
565
604
  // Toes inherit the main style so they zigzag in offset mode.
566
605
  layoutStyle: r,
567
606
  dominoWidth: i,
568
607
  dominoHeight: l,
569
- leadGap: S,
570
- outwardSign: ee,
608
+ leadGap: I,
609
+ outwardSign: re,
571
610
  depth: a + 1,
572
- anchor: { x: ae, y: ue },
611
+ anchor: { x: he, y: ge },
573
612
  placed: u,
574
613
  // If the snug spot is still blocked (the offset center toe leans into
575
614
  // one side), slide this toe along the double's open edge, away from
576
615
  // center, until it clears. This keeps it butted against the double
577
616
  // while stepping past the obstacle — independent per toe, so a foot
578
617
  // ends up snug and only as asymmetric as the obstruction requires.
579
- pushAxis: { x: _ * X, y: N * X }
618
+ pushAxis: { x: U * R, y: j * R }
580
619
  })
581
620
  );
582
621
  }
583
622
  }
584
623
  }
585
- return k;
624
+ return M;
586
625
  }
587
- function ze(e) {
626
+ function Ee(e) {
588
627
  return e.flatMap((t) => t.layout);
589
628
  }
590
- function Ct(e, t = 24, n = T, o = I) {
591
- const r = Math.hypot(n, o) / 2;
629
+ function dn(e, t = 24, o = C, n = D) {
630
+ const r = Math.hypot(o, n) / 2;
592
631
  if (e.length === 0)
593
632
  return {
594
- width: t * 2 + n,
595
- height: t * 2 + o,
633
+ width: t * 2 + o,
634
+ height: t * 2 + n,
596
635
  offsetX: t,
597
636
  offsetY: t
598
637
  };
@@ -606,84 +645,84 @@ function Ct(e, t = 24, n = T, o = I) {
606
645
  offsetY: t - l
607
646
  };
608
647
  }
609
- const Q = 1;
610
- function Me(e, t, n) {
611
- const { dirX: o, dirY: r } = R(n);
612
- return e * o + t * r;
648
+ const te = 1;
649
+ function Ae(e, t, o) {
650
+ const { dirX: n, dirY: r } = Y(o);
651
+ return e * n + t * r;
613
652
  }
614
- function Qe(e, t, n) {
615
- const { perpX: o, perpY: r } = F(n);
616
- return e * o + t * r;
653
+ function pt(e, t, o) {
654
+ const { perpX: n, perpY: r } = L(o);
655
+ return e * n + t * r;
617
656
  }
618
- function ie(e) {
657
+ function ce(e) {
619
658
  const t = [];
620
- for (let n = 1; n < e.length; n++)
621
- e[n].value1 !== e[n - 1].value2 && t.push({
659
+ for (let o = 1; o < e.length; o++)
660
+ e[o].value1 !== e[o - 1].value2 && t.push({
622
661
  code: "chain-break",
623
- message: `Domino ${n} does not connect to domino ${n - 1}`,
624
- index: n
662
+ message: `Domino ${o} does not connect to domino ${o - 1}`,
663
+ index: o
625
664
  });
626
- for (let n = 1; n < e.length; n++) {
627
- const o = e[n - 1].value1 === e[n - 1].value2, r = e[n].value1 === e[n].value2;
628
- o && r && t.push({
665
+ for (let o = 1; o < e.length; o++) {
666
+ const n = e[o - 1].value1 === e[o - 1].value2, r = e[o].value1 === e[o].value2;
667
+ n && r && t.push({
629
668
  code: "consecutive-doubles",
630
- message: `Consecutive doubles at index ${n - 1} and ${n}`,
631
- index: n
669
+ message: `Consecutive doubles at index ${o - 1} and ${o}`,
670
+ index: o
632
671
  });
633
672
  }
634
673
  return { valid: t.length === 0, issues: t };
635
674
  }
636
- function $e(e, t, n, o = T, r = I) {
637
- const i = o / 2, l = e.map((u) => u.isDouble), s = [];
675
+ function Oe(e, t, o, n = C, r = D) {
676
+ const i = n / 2, l = e.map((u) => u.isDouble), s = [];
638
677
  let a = 0, c = 0, d = 0;
639
678
  for (let u = 0; u < e.length; u++) {
640
679
  const f = l[u], p = u > 0 && l[u - 1];
641
- t === "linear" ? (u > 0 && (a += O(p, f, o, r)), c = 0) : f ? u > 0 && (a += O(p, !0, o, r)) : u === 0 ? (d = n, c = d * i) : p ? a += O(!0, !1, o, r) : (a += r / 2, d = be(d, n), c = d * i), s.push({ along: a, perp: c });
680
+ t === "linear" ? (u > 0 && (a += A(p, f, n, r)), c = 0) : f ? u > 0 && (a += A(p, !0, n, r)) : u === 0 ? (d = o, c = d * i) : p ? a += A(!0, !1, n, r) : (a += r / 2, d = Me(d, o), c = d * i), s.push({ along: a, perp: c });
642
681
  }
643
682
  return s;
644
683
  }
645
- function He(e, t, n, o = Q, r) {
646
- const i = [], l = r ?? U(t), s = $e(e, n, l);
684
+ function ht(e, t, o, n = te, r) {
685
+ const i = [], l = r ?? K(t), s = Oe(e, o, l);
647
686
  for (let a = 1; a < e.length; a++) {
648
- const c = e[a - 1], d = e[a], u = d.x - c.x, f = d.y - c.y, p = Me(u, f, t), b = Qe(u, f, t), m = s[a].along - s[a - 1].along, w = s[a].perp - s[a - 1].perp;
649
- Math.abs(p - m) > o && i.push({
687
+ const c = e[a - 1], d = e[a], u = d.x - c.x, f = d.y - c.y, p = Ae(u, f, t), v = pt(u, f, t), S = s[a].along - s[a - 1].along, m = s[a].perp - s[a - 1].perp;
688
+ Math.abs(p - S) > n && i.push({
650
689
  code: "spacing-along-train",
651
- message: `Along-train spacing between domino ${a - 1} and ${a} is ${p.toFixed(2)}px (expected ${m}px)`,
690
+ message: `Along-train spacing between domino ${a - 1} and ${a} is ${p.toFixed(2)}px (expected ${S}px)`,
652
691
  index: a
653
- }), Math.abs(b - w) > o && i.push({
692
+ }), Math.abs(v - m) > n && i.push({
654
693
  code: "spacing-perpendicular",
655
- message: `Perpendicular spacing between domino ${a - 1} and ${a} is ${b.toFixed(2)}px (expected ${w}px)`,
694
+ message: `Perpendicular spacing between domino ${a - 1} and ${a} is ${v.toFixed(2)}px (expected ${m}px)`,
656
695
  index: a
657
696
  });
658
697
  }
659
698
  return { valid: i.length === 0, issues: i };
660
699
  }
661
- function We(e, t, n, o = Q, r) {
662
- const i = [], l = r ?? U(t), s = $e(e, n, l);
700
+ function gt(e, t, o, n = te, r) {
701
+ const i = [], l = r ?? K(t), s = Oe(e, o, l);
663
702
  for (let a = 1; a < e.length; a++) {
664
- const c = e[a - 1], d = e[a], u = d.x - c.x, f = d.y - c.y, p = Math.hypot(u, f), b = s[a].along - s[a - 1].along, m = s[a].perp - s[a - 1].perp, w = Math.hypot(b, m) * 0.9;
665
- p + o < w && i.push({
703
+ const c = e[a - 1], d = e[a], u = d.x - c.x, f = d.y - c.y, p = Math.hypot(u, f), v = s[a].along - s[a - 1].along, S = s[a].perp - s[a - 1].perp, m = Math.hypot(v, S) * 0.9;
704
+ p + n < m && i.push({
666
705
  code: "overlap",
667
- message: `Domino ${a - 1} and ${a} centers are ${p.toFixed(2)}px apart (minimum ${w.toFixed(2)}px)`,
706
+ message: `Domino ${a - 1} and ${a} centers are ${p.toFixed(2)}px apart (minimum ${m.toFixed(2)}px)`,
668
707
  index: a
669
708
  });
670
709
  }
671
710
  return { valid: i.length === 0, issues: i };
672
711
  }
673
- function Tt(e, t, n, o, r = Q, i) {
712
+ function fn(e, t, o, n, r = te, i) {
674
713
  const l = [
675
- ...ie(t).issues,
676
- ...He(
714
+ ...ce(t).issues,
715
+ ...ht(
677
716
  e,
678
- n,
679
717
  o,
718
+ n,
680
719
  r,
681
720
  i
682
721
  ).issues,
683
- ...We(
722
+ ...gt(
684
723
  e,
685
- n,
686
724
  o,
725
+ n,
687
726
  r,
688
727
  i
689
728
  ).issues
@@ -693,16 +732,16 @@ function Tt(e, t, n, o, r = Q, i) {
693
732
  message: `Layout length ${e.length} does not match domino count ${t.length}`
694
733
  }), { valid: l.length === 0, issues: l };
695
734
  }
696
- function et(e) {
697
- const t = [], n = (o, r) => {
735
+ function vt(e) {
736
+ const t = [], o = (n, r) => {
698
737
  if (t.push(
699
- ...ie(o.dominoes).issues.map((i) => ({
738
+ ...ce(n.dominoes).issues.map((i) => ({
700
739
  ...i,
701
740
  message: `[${r}] ${i.message}`
702
741
  }))
703
- ), !!o.feet)
704
- for (const i of Object.keys(o.feet)) {
705
- const l = Number(i), s = o.dominoes[l], a = o.feet[l] ?? [];
742
+ ), !!n.feet)
743
+ for (const i of Object.keys(n.feet)) {
744
+ const l = Number(i), s = n.dominoes[l], a = n.feet[l] ?? [];
706
745
  if (!s) {
707
746
  t.push({
708
747
  code: "foot-host-missing",
@@ -721,57 +760,57 @@ function et(e) {
721
760
  u && u.value1 !== s.value1 && t.push({
722
761
  code: "foot-connection",
723
762
  message: `[${r}] Toe ${d} on double ${l} starts with ${u.value1} but the double is ${s.value1}`
724
- }), n(c, `${r}.${l}.${d}`);
763
+ }), o(c, `${r}.${l}.${d}`);
725
764
  });
726
765
  }
727
766
  };
728
- return n(e, "main"), { valid: t.length === 0, issues: t };
767
+ return o(e, "main"), { valid: t.length === 0, issues: t };
729
768
  }
730
- function It(e, t = Q) {
731
- const n = [];
769
+ function pn(e, t = te) {
770
+ const o = [];
732
771
  e.forEach((r, i) => {
733
- if (n.push(
734
- ...ie(r.dominoes).issues.map((l) => ({
772
+ if (o.push(
773
+ ...ce(r.dominoes).issues.map((l) => ({
735
774
  ...l,
736
775
  message: `[segment ${i} @${r.angle}°] ${l.message}`
737
776
  }))
738
- ), r.layout.length !== r.dominoes.length && n.push({
777
+ ), r.layout.length !== r.dominoes.length && o.push({
739
778
  code: "layout-length",
740
779
  message: `[segment ${i}] Layout length ${r.layout.length} does not match domino count ${r.dominoes.length}`
741
780
  }), r.anchor && r.layout.length > 0) {
742
- const l = r.layout[0], s = Me(
781
+ const l = r.layout[0], s = Ae(
743
782
  l.x - r.anchor.x,
744
783
  l.y - r.anchor.y,
745
784
  r.angle
746
- ), a = I / 2;
747
- Math.abs(s - a) > t && n.push({
785
+ ), a = D / 2;
786
+ Math.abs(s - a) > t && o.push({
748
787
  code: "foot-anchor",
749
788
  message: `[segment ${i}] First toe tile sits ${s.toFixed(2)}px from the double along the toe (expected ${a}px)`,
750
789
  index: 0
751
790
  });
752
791
  }
753
792
  });
754
- const o = e.flatMap((r) => r.layout);
755
- for (let r = 0; r < o.length; r++)
756
- for (let i = r + 1; i < o.length; i++)
757
- J(o[r], o[i]) && n.push({
793
+ const n = e.flatMap((r) => r.layout);
794
+ for (let r = 0; r < n.length; r++)
795
+ for (let i = r + 1; i < n.length; i++)
796
+ ee(n[r], n[i]) && o.push({
758
797
  code: "tile-overlap",
759
798
  message: `Tiles ${r} and ${i} overlap`,
760
799
  index: i
761
800
  });
762
- return { valid: n.length === 0, issues: n };
801
+ return { valid: o.length === 0, issues: o };
763
802
  }
764
- const tt = (() => {
803
+ const xt = (() => {
765
804
  try {
766
805
  return !1;
767
806
  } catch {
768
807
  return !1;
769
808
  }
770
- })(), ot = ({
809
+ })(), bt = ({
771
810
  startX: e,
772
811
  startY: t,
773
- angle: n,
774
- trainData: o,
812
+ angle: o,
813
+ trainData: n,
775
814
  layoutStyle: r,
776
815
  tableWidth: i,
777
816
  tableHeight: l,
@@ -779,56 +818,56 @@ const tt = (() => {
779
818
  centerY: a,
780
819
  pipColors: c
781
820
  }) => {
782
- ne(() => {
783
- if (!tt) return;
784
- const u = et({
785
- dominoes: o.dominoes,
786
- feet: o.feet
821
+ ae(() => {
822
+ if (!xt) return;
823
+ const u = vt({
824
+ dominoes: n.dominoes,
825
+ feet: n.feet
787
826
  });
788
827
  u.valid || console.warn(
789
- `DominoTrain: player ${o.playerId} train does not follow the rules:`,
828
+ `DominoTrain: player ${n.playerId} train does not follow the rules:`,
790
829
  u.issues.map((f) => f.message)
791
830
  );
792
- }, [o.dominoes, o.feet, o.playerId]);
793
- const d = Ye(
794
- () => ze(
795
- re({
831
+ }, [n.dominoes, n.feet, n.playerId]);
832
+ const d = He(
833
+ () => Ee(
834
+ ue({
796
835
  startX: e,
797
836
  startY: t,
798
- angle: n,
799
- branch: { dominoes: o.dominoes, feet: o.feet },
837
+ angle: o,
838
+ branch: { dominoes: n.dominoes, feet: n.feet },
800
839
  layoutStyle: r
801
840
  })
802
841
  ),
803
842
  [
804
843
  e,
805
844
  t,
806
- n,
807
- o.dominoes,
808
- o.feet,
845
+ o,
846
+ n.dominoes,
847
+ n.feet,
809
848
  r,
810
849
  i,
811
850
  l
812
851
  ]
813
852
  );
814
- return /* @__PURE__ */ M(xe, { children: d.map((u, f) => {
815
- const p = o.isPublic;
816
- return /* @__PURE__ */ M(
853
+ return /* @__PURE__ */ z(we, { children: d.map((u, f) => {
854
+ const p = n.isPublic;
855
+ return /* @__PURE__ */ z(
817
856
  "div",
818
857
  {
819
858
  style: {
820
859
  position: "absolute",
821
- left: `${u.x - T / 2}px`,
822
- top: `${u.y - I / 2}px`,
860
+ left: `${u.x - C / 2}px`,
861
+ top: `${u.y - D / 2}px`,
823
862
  zIndex: 5
824
863
  },
825
- children: /* @__PURE__ */ M(
826
- ve,
864
+ children: /* @__PURE__ */ z(
865
+ Te,
827
866
  {
828
867
  value1: u.value1,
829
868
  value2: u.value2,
830
- width: T,
831
- height: I,
869
+ width: C,
870
+ height: D,
832
871
  backgroundColor: "white",
833
872
  pipColor: "black",
834
873
  pipColors: c,
@@ -837,19 +876,19 @@ const tt = (() => {
837
876
  }
838
877
  )
839
878
  },
840
- `main-train-${o.playerId}-${f}`
879
+ `main-train-${n.playerId}-${f}`
841
880
  );
842
881
  }) });
843
882
  };
844
- function nt(e, t, n, o) {
845
- const r = n * (o === "offset" ? 2.5 : 1.3);
883
+ function yt(e, t, o, n) {
884
+ const r = o * (n === "offset" ? 2.5 : 1.3);
846
885
  return Math.max(t + 20, Math.ceil(r * e / (2 * Math.PI)));
847
886
  }
848
- const rt = ({
887
+ const mt = ({
849
888
  playerCount: e,
850
889
  centerX: t,
851
- centerY: n,
852
- radius: o,
890
+ centerY: o,
891
+ radius: n,
853
892
  engineValue: r,
854
893
  trains: i,
855
894
  layoutStyle: l,
@@ -857,9 +896,9 @@ const rt = ({
857
896
  tableHeight: a,
858
897
  pipColors: c
859
898
  }) => {
860
- const d = Math.max(8, e), u = 120, f = 60, p = 120, b = nt(d, o, f, l);
861
- return /* @__PURE__ */ D("div", { style: { position: "relative", width: "100%", height: "100%" }, children: [
862
- /* @__PURE__ */ M(
899
+ const d = Math.max(8, e), u = 120, f = 60, p = 120, v = yt(d, n, f, l);
900
+ return /* @__PURE__ */ $("div", { style: { position: "relative", width: "100%", height: "100%" }, children: [
901
+ /* @__PURE__ */ z(
863
902
  "div",
864
903
  {
865
904
  style: {
@@ -867,7 +906,7 @@ const rt = ({
867
906
  width: `${u}px`,
868
907
  height: `${u}px`,
869
908
  left: `${t - u / 2}px`,
870
- top: `${n - u / 2}px`,
909
+ top: `${o - u / 2}px`,
871
910
  backgroundColor: "#d1d5db",
872
911
  borderWidth: "3px",
873
912
  borderStyle: "solid",
@@ -879,8 +918,8 @@ const rt = ({
879
918
  justifyContent: "center",
880
919
  alignItems: "center"
881
920
  },
882
- children: /* @__PURE__ */ M("div", { style: { transform: "rotate(0deg)" }, children: /* @__PURE__ */ M(
883
- ve,
921
+ children: /* @__PURE__ */ z("div", { style: { transform: "rotate(0deg)" }, children: /* @__PURE__ */ z(
922
+ Te,
884
923
  {
885
924
  value1: r,
886
925
  value2: r,
@@ -894,79 +933,79 @@ const rt = ({
894
933
  ) })
895
934
  }
896
935
  ),
897
- Array.from({ length: d }).map((m, w) => {
898
- const z = w * 360 / d, v = z * Math.PI / 180, k = t + b * Math.cos(v), x = n + b * Math.sin(v), S = i.find((C) => C.playerId === w) || {
936
+ Array.from({ length: d }).map((S, m) => {
937
+ const P = m * 360 / d, b = P * Math.PI / 180, M = t + v * Math.cos(b), g = o + v * Math.sin(b), I = i.find((k) => k.playerId === m) || {
899
938
  dominoes: [],
900
- playerId: w,
939
+ playerId: m,
901
940
  isPublic: !1
902
941
  };
903
- return /* @__PURE__ */ M(
904
- ot,
942
+ return /* @__PURE__ */ z(
943
+ bt,
905
944
  {
906
- startX: k,
907
- startY: x,
908
- angle: z,
909
- trainData: S,
945
+ startX: M,
946
+ startY: g,
947
+ angle: P,
948
+ trainData: I,
910
949
  layoutStyle: l,
911
950
  tableWidth: s,
912
951
  tableHeight: a,
913
952
  centerX: t,
914
- centerY: n,
953
+ centerY: o,
915
954
  pipColors: c
916
955
  },
917
- w
956
+ m
918
957
  );
919
958
  })
920
959
  ] });
921
960
  };
922
- function L(e, t) {
961
+ function V(e, t) {
923
962
  return e <= t ? `${e}:${t}` : `${t}:${e}`;
924
963
  }
925
- function ke(e) {
926
- return L(e.value1, e.value2);
964
+ function B(e) {
965
+ return V(e.value1, e.value2);
927
966
  }
928
- function Ce(e) {
967
+ function Re(e) {
929
968
  return e.value1 === e.value2;
930
969
  }
931
- function Dt(e, t) {
970
+ function Fe(e, t) {
932
971
  return e.value1 === t || e.value2 === t;
933
972
  }
934
- function Pt(e, t) {
973
+ function hn(e, t) {
935
974
  return e.value1 === t ? e.value2 : e.value2 === t ? e.value1 : null;
936
975
  }
937
- function Te(e, t) {
976
+ function de(e, t) {
938
977
  return e.value1 === t ? { value1: e.value1, value2: e.value2 } : e.value2 === t ? { value1: e.value2, value2: e.value1 } : null;
939
978
  }
940
- function Ot(e) {
979
+ function wt(e) {
941
980
  const t = [];
942
- for (let n = 0; n <= e; n++)
943
- for (let o = n; o <= e; o++)
944
- t.push({ value1: n, value2: o });
981
+ for (let o = 0; o <= e; o++)
982
+ for (let n = o; n <= e; n++)
983
+ t.push({ value1: o, value2: n });
945
984
  return t;
946
985
  }
947
- function Et(e) {
986
+ function gn(e) {
948
987
  const t = e + 1;
949
988
  return t * (t + 1) / 2;
950
989
  }
951
- function it(e, t = 12, n = {}) {
952
- const o = /* @__PURE__ */ new Set([L(t, t)]), r = [];
990
+ function St(e, t = 12, o = {}) {
991
+ const n = /* @__PURE__ */ new Set([V(t, t)]), r = [];
953
992
  for (let i = 0; i < e; i++) {
954
993
  const l = 4 + Math.floor(Math.random() * 7), s = [];
955
994
  let a = t, c = !1;
956
995
  for (let u = 0; u < l; u++) {
957
- const f = ut(
996
+ const f = Tt(
958
997
  a,
959
998
  c,
960
999
  u === 0,
961
1000
  t,
962
- o
1001
+ n
963
1002
  );
964
1003
  if (f === null)
965
1004
  break;
966
1005
  const p = f === a;
967
- o.add(L(a, f)), s.push({ value1: a, value2: f }), c = p, a = f;
1006
+ n.add(V(a, f)), s.push({ value1: a, value2: f }), c = p, a = f;
968
1007
  }
969
- const d = n.chickenFeet ? lt(s, o) : void 0;
1008
+ const d = o.chickenFeet ? zt(s, n) : void 0;
970
1009
  r.push({
971
1010
  playerId: i,
972
1011
  dominoes: s,
@@ -976,89 +1015,89 @@ function it(e, t = 12, n = {}) {
976
1015
  }
977
1016
  return r;
978
1017
  }
979
- function lt(e, t) {
980
- const n = {};
981
- for (let o = 0; o < e.length; o++) {
982
- if (e[o].value1 !== e[o].value2)
1018
+ function zt(e, t) {
1019
+ const o = {};
1020
+ for (let n = 0; n < e.length; n++) {
1021
+ if (e[n].value1 !== e[n].value2)
983
1022
  continue;
984
- const r = e[o].value1, i = [];
1023
+ const r = e[n].value1, i = [];
985
1024
  for (let l = 0; l < 2; l++) {
986
- const s = st(r, t);
1025
+ const s = It(r, t);
987
1026
  s && i.push(s);
988
1027
  }
989
- i.length && (n[o] = i);
1028
+ i.length && (o[n] = i);
990
1029
  }
991
- return Object.keys(n).length ? n : void 0;
1030
+ return Object.keys(o).length ? o : void 0;
992
1031
  }
993
- function st(e, t) {
994
- const n = 1 + Math.floor(Math.random() * 2), o = [];
1032
+ function It(e, t) {
1033
+ const o = 1 + Math.floor(Math.random() * 2), n = [];
995
1034
  let r = e;
996
- for (let i = 0; i < n; i++) {
997
- const l = at(r, t);
1035
+ for (let i = 0; i < o; i++) {
1036
+ const l = Pt(r, t);
998
1037
  if (l === null)
999
1038
  break;
1000
- t.add(L(r, l)), o.push({ value1: r, value2: l }), r = l;
1039
+ t.add(V(r, l)), n.push({ value1: r, value2: l }), r = l;
1001
1040
  }
1002
- return o.length ? { dominoes: o } : null;
1041
+ return n.length ? { dominoes: n } : null;
1003
1042
  }
1004
- function at(e, t) {
1005
- const n = [];
1006
- for (let o = 0; o < 13; o++)
1007
- o !== e && (t.has(L(e, o)) || n.push(o));
1008
- return n.length === 0 ? null : n[Math.floor(Math.random() * n.length)];
1043
+ function Pt(e, t) {
1044
+ const o = [];
1045
+ for (let n = 0; n < 13; n++)
1046
+ n !== e && (t.has(V(e, n)) || o.push(n));
1047
+ return o.length === 0 ? null : o[Math.floor(Math.random() * o.length)];
1009
1048
  }
1010
- function ut(e, t, n, o, r) {
1049
+ function Tt(e, t, o, n, r) {
1011
1050
  const i = Array.from({ length: 13 }, (l, s) => s).filter(
1012
- (l) => ct(
1051
+ (l) => Mt(
1013
1052
  e,
1014
1053
  l,
1015
1054
  t,
1016
- n,
1017
1055
  o,
1056
+ n,
1018
1057
  r
1019
1058
  )
1020
1059
  );
1021
1060
  return i.length === 0 ? null : i[Math.floor(Math.random() * i.length)];
1022
1061
  }
1023
- function ct(e, t, n, o, r, i) {
1062
+ function Mt(e, t, o, n, r, i) {
1024
1063
  const l = t === e;
1025
- return !(o && l && e === r || l && n || i.has(L(e, t)));
1064
+ return !(n && l && e === r || l && o || i.has(V(e, t)));
1026
1065
  }
1027
- const dt = {
1066
+ const kt = {
1028
1067
  playerCount: 8,
1029
1068
  trains: [],
1030
1069
  engineValue: 12
1031
- }, Xt = ({
1032
- initialState: e = dt,
1070
+ }, vn = ({
1071
+ initialState: e = kt,
1033
1072
  width: t = 1200,
1034
- height: n = 800,
1035
- pipColors: o,
1073
+ height: o = 800,
1074
+ pipColors: n,
1036
1075
  onPipColorsChange: r
1037
1076
  }) => {
1038
- const [i, l] = B(e), [s, a] = B("offset"), [c, d] = B(!1), [u, f] = B(void 0), p = o ?? u, b = r ?? f, m = p !== void 0, w = t / 2, z = n / 2, v = (x = c) => {
1039
- const S = it(
1077
+ const [i, l] = G(e), [s, a] = G("offset"), [c, d] = G(!1), [u, f] = G(void 0), p = n ?? u, v = r ?? f, S = p !== void 0, m = t / 2, P = o / 2, b = (g = c) => {
1078
+ const I = St(
1040
1079
  i.playerCount,
1041
1080
  i.engineValue,
1042
- { chickenFeet: x }
1081
+ { chickenFeet: g }
1043
1082
  );
1044
- l((C) => ({
1045
- ...C,
1046
- trains: S
1083
+ l((k) => ({
1084
+ ...k,
1085
+ trains: I
1047
1086
  }));
1048
1087
  };
1049
- ne(() => {
1050
- v();
1088
+ ae(() => {
1089
+ b();
1051
1090
  }, []);
1052
- const k = () => {
1053
- const x = !c;
1054
- d(x), v(x);
1091
+ const M = () => {
1092
+ const g = !c;
1093
+ d(g), b(g);
1055
1094
  };
1056
- return /* @__PURE__ */ D(
1095
+ return /* @__PURE__ */ $(
1057
1096
  "div",
1058
1097
  {
1059
1098
  style: {
1060
1099
  width: `${t}px`,
1061
- height: `${n}px`,
1100
+ height: `${o}px`,
1062
1101
  position: "relative",
1063
1102
  backgroundColor: "#1f8a55",
1064
1103
  // Classic green felt background
@@ -1067,15 +1106,15 @@ const dt = {
1067
1106
  overflow: "hidden"
1068
1107
  },
1069
1108
  children: [
1070
- /* @__PURE__ */ D(
1109
+ /* @__PURE__ */ $(
1071
1110
  "div",
1072
1111
  {
1073
1112
  style: { position: "absolute", top: "10px", left: "10px", zIndex: 100 },
1074
1113
  children: [
1075
- /* @__PURE__ */ M(
1114
+ /* @__PURE__ */ z(
1076
1115
  "button",
1077
1116
  {
1078
- onClick: () => v(),
1117
+ onClick: () => b(),
1079
1118
  style: {
1080
1119
  padding: "8px 12px",
1081
1120
  backgroundColor: "#fff",
@@ -1087,7 +1126,7 @@ const dt = {
1087
1126
  children: "New trains"
1088
1127
  }
1089
1128
  ),
1090
- /* @__PURE__ */ D(
1129
+ /* @__PURE__ */ $(
1091
1130
  "button",
1092
1131
  {
1093
1132
  onClick: () => a(s === "offset" ? "linear" : "offset"),
@@ -1105,10 +1144,10 @@ const dt = {
1105
1144
  ]
1106
1145
  }
1107
1146
  ),
1108
- /* @__PURE__ */ D(
1147
+ /* @__PURE__ */ $(
1109
1148
  "button",
1110
1149
  {
1111
- onClick: k,
1150
+ onClick: M,
1112
1151
  style: {
1113
1152
  padding: "8px 12px",
1114
1153
  backgroundColor: c ? "#fef3c7" : "#fff",
@@ -1123,27 +1162,27 @@ const dt = {
1123
1162
  ]
1124
1163
  }
1125
1164
  ),
1126
- /* @__PURE__ */ D(
1165
+ /* @__PURE__ */ $(
1127
1166
  "button",
1128
1167
  {
1129
- onClick: () => b(m ? void 0 : j),
1168
+ onClick: () => v(S ? void 0 : q),
1130
1169
  style: {
1131
1170
  padding: "8px 12px",
1132
- backgroundColor: m ? "#fef3c7" : "#fff",
1133
- border: `1px solid ${m ? "#f59e0b" : "#ccc"}`,
1171
+ backgroundColor: S ? "#fef3c7" : "#fff",
1172
+ border: `1px solid ${S ? "#f59e0b" : "#ccc"}`,
1134
1173
  borderRadius: "4px",
1135
1174
  cursor: "pointer"
1136
1175
  },
1137
1176
  children: [
1138
1177
  "Pip Colors: ",
1139
- m ? "On" : "Off"
1178
+ S ? "On" : "Off"
1140
1179
  ]
1141
1180
  }
1142
1181
  )
1143
1182
  ]
1144
1183
  }
1145
1184
  ),
1146
- /* @__PURE__ */ D(
1185
+ /* @__PURE__ */ $(
1147
1186
  "div",
1148
1187
  {
1149
1188
  style: {
@@ -1157,55 +1196,55 @@ const dt = {
1157
1196
  fontSize: "14px"
1158
1197
  },
1159
1198
  children: [
1160
- /* @__PURE__ */ D("div", { children: [
1199
+ /* @__PURE__ */ $("div", { children: [
1161
1200
  "Engine: Double-",
1162
1201
  i.engineValue
1163
1202
  ] }),
1164
- /* @__PURE__ */ D("div", { children: [
1203
+ /* @__PURE__ */ $("div", { children: [
1165
1204
  "Players: ",
1166
1205
  i.playerCount
1167
1206
  ] })
1168
1207
  ]
1169
1208
  }
1170
1209
  ),
1171
- /* @__PURE__ */ M(
1172
- rt,
1210
+ /* @__PURE__ */ z(
1211
+ mt,
1173
1212
  {
1174
1213
  playerCount: i.playerCount,
1175
- centerX: w,
1176
- centerY: z,
1214
+ centerX: m,
1215
+ centerY: P,
1177
1216
  radius: 80,
1178
1217
  engineValue: i.engineValue,
1179
1218
  trains: i.trains,
1180
1219
  layoutStyle: s,
1181
1220
  tableWidth: t,
1182
- tableHeight: n,
1221
+ tableHeight: o,
1183
1222
  pipColors: p
1184
1223
  }
1185
1224
  )
1186
1225
  ]
1187
1226
  }
1188
1227
  );
1189
- }, le = 90;
1190
- function oe(e, t = le) {
1228
+ }, fe = 90;
1229
+ function se(e, t = fe) {
1191
1230
  return e === "right" ? t : -t;
1192
1231
  }
1193
- function Ie(e) {
1232
+ function Ne(e) {
1194
1233
  return e === "right" ? "left" : "right";
1195
1234
  }
1196
- function Yt(e, t) {
1197
- return (t ?? U(e)) >= 0 ? "left" : "right";
1235
+ function xn(e, t) {
1236
+ return (t ?? K(e)) >= 0 ? "left" : "right";
1198
1237
  }
1199
- function Rt(e, t, n) {
1200
- const { perpX: o, perpY: r } = F(t), i = (a, c) => {
1238
+ function bn(e, t, o) {
1239
+ const { perpX: n, perpY: r } = L(t), i = (a, c) => {
1201
1240
  let d = 1 / 0;
1202
- return a > 0 ? d = Math.min(d, (n.width - e.x) / a) : a < 0 && (d = Math.min(d, (0 - e.x) / a)), c > 0 ? d = Math.min(d, (n.height - e.y) / c) : c < 0 && (d = Math.min(d, (0 - e.y) / c)), Number.isFinite(d) ? Math.max(0, d) : 1 / 0;
1203
- }, l = i(o, r), s = i(-o, -r);
1241
+ return a > 0 ? d = Math.min(d, (o.width - e.x) / a) : a < 0 && (d = Math.min(d, (0 - e.x) / a)), c > 0 ? d = Math.min(d, (o.height - e.y) / c) : c < 0 && (d = Math.min(d, (0 - e.y) / c)), Number.isFinite(d) ? Math.max(0, d) : 1 / 0;
1242
+ }, l = i(n, r), s = i(-n, -r);
1204
1243
  return l >= s ? "right" : "left";
1205
1244
  }
1206
- function De(e, t) {
1207
- return ze(
1208
- re({
1245
+ function Ye(e, t) {
1246
+ return Ee(
1247
+ ue({
1209
1248
  startX: t.startX,
1210
1249
  startY: t.startY,
1211
1250
  angle: t.angle,
@@ -1214,80 +1253,80 @@ function De(e, t) {
1214
1253
  })
1215
1254
  );
1216
1255
  }
1217
- function K(e, t, n) {
1218
- const o = (e ?? []).filter((r) => r.index !== t);
1219
- return n === null ? o : [...o, { index: t, turn: n }].sort((r, i) => r.index - i.index);
1256
+ function Q(e, t, o) {
1257
+ const n = (e ?? []).filter((r) => r.index !== t);
1258
+ return o === null ? n : [...n, { index: t, turn: o }].sort((r, i) => r.index - i.index);
1220
1259
  }
1221
- function At({
1260
+ function yn({
1222
1261
  branch: e,
1223
1262
  index: t,
1224
- build: n,
1225
- obstacles: o,
1263
+ build: o,
1264
+ obstacles: n,
1226
1265
  preferredSide: r,
1227
- degrees: i = le
1266
+ degrees: i = fe
1228
1267
  }) {
1229
- const l = [r, Ie(r)];
1268
+ const l = [r, Ne(r)];
1230
1269
  for (const s of l) {
1231
- const a = oe(s, i), c = {
1270
+ const a = se(s, i), c = {
1232
1271
  ...e,
1233
- bends: K(e.bends, t, a)
1234
- }, d = De(c, n);
1235
- if (!me(d) && !Se(d, o))
1272
+ bends: Q(e.bends, t, a)
1273
+ }, d = Ye(c, o);
1274
+ if (!$e(d) && !De(d, n))
1236
1275
  return { turn: a };
1237
1276
  }
1238
1277
  return { turn: null, reason: "blocked" };
1239
1278
  }
1240
- function Ft(e, t, n, o, r, i = le) {
1241
- const l = (e.bends ?? []).find((u) => u.index === t), s = oe(r, i), a = oe(Ie(r), i), c = (u) => {
1279
+ function mn(e, t, o, n, r, i = fe) {
1280
+ const l = (e.bends ?? []).find((u) => u.index === t), s = se(r, i), a = se(Ne(r), i), c = (u) => {
1242
1281
  const f = {
1243
1282
  ...e,
1244
- bends: K(e.bends, t, u)
1245
- }, p = De(f, n);
1246
- return !me(p) && !Se(p, o);
1283
+ bends: Q(e.bends, t, u)
1284
+ }, p = Ye(f, o);
1285
+ return !$e(p) && !De(p, n);
1247
1286
  };
1248
1287
  let d;
1249
1288
  l ? l.turn === s ? d = [a, null] : l.turn === a ? d = [null] : d = [s, a, null] : d = [s, a];
1250
1289
  for (const u of d) {
1251
1290
  if (u === null)
1252
- return { bends: K(e.bends, t, null), changed: !0, blocked: !1 };
1291
+ return { bends: Q(e.bends, t, null), changed: !0, blocked: !1 };
1253
1292
  if (c(u))
1254
- return { bends: K(e.bends, t, u), changed: !0, blocked: !1 };
1293
+ return { bends: Q(e.bends, t, u), changed: !0, blocked: !1 };
1255
1294
  }
1256
1295
  return { bends: e.bends ?? [], changed: !1, blocked: !0 };
1257
1296
  }
1258
- function se(e, t, n) {
1259
- return Math.min(n, Math.max(t, e));
1297
+ function pe(e, t, o) {
1298
+ return Math.min(o, Math.max(t, e));
1260
1299
  }
1261
- function he(e, t, n, o, r) {
1262
- const i = se(e.scale * t, o, r), l = i / e.scale;
1300
+ function me(e, t, o, n, r) {
1301
+ const i = pe(e.scale * t, n, r), l = i / e.scale;
1263
1302
  return {
1264
1303
  scale: i,
1265
- x: n.x - (n.x - e.x) * l,
1266
- y: n.y - (n.y - e.y) * l
1304
+ x: o.x - (o.x - e.x) * l,
1305
+ y: o.y - (o.y - e.y) * l
1267
1306
  };
1268
1307
  }
1269
- function ft(e, t, n, o, r) {
1308
+ function Ct(e, t, o, n, r) {
1270
1309
  const i = Math.max(1, e.width), l = Math.max(1, e.height), s = Math.min(
1271
- (t.width - n * 2) / i,
1272
- (t.height - n * 2) / l
1273
- ), a = se(s, o, r);
1310
+ (t.width - o * 2) / i,
1311
+ (t.height - o * 2) / l
1312
+ ), a = pe(s, n, r);
1274
1313
  return {
1275
1314
  scale: a,
1276
1315
  x: (t.width - i * a) / 2,
1277
1316
  y: (t.height - l * a) / 2
1278
1317
  };
1279
1318
  }
1280
- function Lt(e, t) {
1319
+ function wn(e, t) {
1281
1320
  return {
1282
1321
  x: (t.x - e.x) / e.scale,
1283
1322
  y: (t.y - e.y) / e.scale
1284
1323
  };
1285
1324
  }
1286
- const pt = 3, _t = ({
1325
+ const Dt = 3, Sn = ({
1287
1326
  width: e,
1288
1327
  height: t,
1289
- contentWidth: n,
1290
- contentHeight: o,
1328
+ contentWidth: o,
1329
+ contentHeight: n,
1291
1330
  children: r,
1292
1331
  minScale: i = 0.2,
1293
1332
  maxScale: l = 4,
@@ -1297,44 +1336,44 @@ const pt = 3, _t = ({
1297
1336
  showControls: d = !0,
1298
1337
  testId: u = "viewport"
1299
1338
  }) => {
1300
- const f = ce(null), p = Re(
1301
- () => ft(
1302
- { width: n, height: o },
1339
+ const f = ve(null), p = Ze(
1340
+ () => Ct(
1341
+ { width: o, height: n },
1303
1342
  { width: e, height: t },
1304
1343
  a,
1305
1344
  i,
1306
1345
  l
1307
1346
  ),
1308
- [n, o, e, t, a, i, l]
1309
- ), [b, m] = B(p);
1310
- ne(() => {
1311
- m(p());
1347
+ [o, n, e, t, a, i, l]
1348
+ ), [v, S] = G(p);
1349
+ ae(() => {
1350
+ S(p());
1312
1351
  }, [p]);
1313
- const w = ce(null), z = (h, y) => {
1314
- const $ = f.current?.getBoundingClientRect();
1315
- return { x: h - ($?.left ?? 0), y: y - ($?.top ?? 0) };
1316
- }, v = (h) => {
1317
- w.current = {
1352
+ const m = ve(null), P = (h, y) => {
1353
+ const T = f.current?.getBoundingClientRect();
1354
+ return { x: h - (T?.left ?? 0), y: y - (T?.top ?? 0) };
1355
+ }, b = (h) => {
1356
+ m.current = {
1318
1357
  pointerX: h.clientX,
1319
1358
  pointerY: h.clientY,
1320
- startX: b.x,
1321
- startY: b.y,
1359
+ startX: v.x,
1360
+ startY: v.y,
1322
1361
  moved: !1
1323
1362
  };
1324
- }, k = (h) => {
1325
- const y = w.current;
1363
+ }, M = (h) => {
1364
+ const y = m.current;
1326
1365
  if (!y) return;
1327
- const $ = h.clientX - y.pointerX, E = h.clientY - y.pointerY;
1328
- !y.moved && Math.hypot($, E) < pt || (y.moved = !0, f.current?.setPointerCapture?.(h.pointerId), m((A) => ({ ...A, x: y.startX + $, y: y.startY + E })));
1329
- }, x = (h) => {
1330
- w.current?.moved && h.preventDefault(), w.current = null;
1331
- }, S = (h) => {
1366
+ const T = h.clientX - y.pointerX, O = h.clientY - y.pointerY;
1367
+ !y.moved && Math.hypot(T, O) < Dt || (y.moved = !0, f.current?.setPointerCapture?.(h.pointerId), S((_) => ({ ..._, x: y.startX + T, y: y.startY + O })));
1368
+ }, g = (h) => {
1369
+ m.current?.moved && h.preventDefault(), m.current = null;
1370
+ }, I = (h) => {
1332
1371
  h.preventDefault();
1333
- const y = z(h.clientX, h.clientY), $ = h.deltaY < 0 ? s : 1 / s;
1334
- m((E) => he(E, $, y, i, l));
1335
- }, C = (h) => m(
1336
- (y) => he(y, h, { x: e / 2, y: t / 2 }, i, l)
1337
- ), g = {
1372
+ const y = P(h.clientX, h.clientY), T = h.deltaY < 0 ? s : 1 / s;
1373
+ S((O) => me(O, T, y, i, l));
1374
+ }, k = (h) => S(
1375
+ (y) => me(y, h, { x: e / 2, y: t / 2 }, i, l)
1376
+ ), x = {
1338
1377
  width: 32,
1339
1378
  height: 32,
1340
1379
  fontSize: 18,
@@ -1346,16 +1385,16 @@ const pt = 3, _t = ({
1346
1385
  borderRadius: 6,
1347
1386
  userSelect: "none"
1348
1387
  };
1349
- return /* @__PURE__ */ D(
1388
+ return /* @__PURE__ */ $(
1350
1389
  "div",
1351
1390
  {
1352
1391
  ref: f,
1353
1392
  "data-testid": u,
1354
- onPointerDown: v,
1355
- onPointerMove: k,
1356
- onPointerUp: x,
1357
- onPointerLeave: x,
1358
- onWheel: S,
1393
+ onPointerDown: b,
1394
+ onPointerMove: M,
1395
+ onPointerUp: g,
1396
+ onPointerLeave: g,
1397
+ onWheel: I,
1359
1398
  style: {
1360
1399
  position: "relative",
1361
1400
  width: e,
@@ -1367,7 +1406,7 @@ const pt = 3, _t = ({
1367
1406
  touchAction: "none"
1368
1407
  },
1369
1408
  children: [
1370
- /* @__PURE__ */ M(
1409
+ /* @__PURE__ */ z(
1371
1410
  "div",
1372
1411
  {
1373
1412
  "data-testid": `${u}-content`,
@@ -1376,12 +1415,12 @@ const pt = 3, _t = ({
1376
1415
  left: 0,
1377
1416
  top: 0,
1378
1417
  transformOrigin: "0 0",
1379
- transform: `translate(${b.x}px, ${b.y}px) scale(${b.scale})`
1418
+ transform: `translate(${v.x}px, ${v.y}px) scale(${v.scale})`
1380
1419
  },
1381
1420
  children: r
1382
1421
  }
1383
1422
  ),
1384
- d && /* @__PURE__ */ D(
1423
+ d && /* @__PURE__ */ $(
1385
1424
  "div",
1386
1425
  {
1387
1426
  "data-testid": `${u}-controls`,
@@ -1394,24 +1433,24 @@ const pt = 3, _t = ({
1394
1433
  gap: 6
1395
1434
  },
1396
1435
  children: [
1397
- /* @__PURE__ */ M("div", { style: g, role: "button", "aria-label": "Zoom in", onClick: () => C(s), children: "+" }),
1398
- /* @__PURE__ */ M("div", { style: g, role: "button", "aria-label": "Zoom out", onClick: () => C(1 / s), children: "−" }),
1399
- /* @__PURE__ */ M(
1436
+ /* @__PURE__ */ z("div", { style: x, role: "button", "aria-label": "Zoom in", onClick: () => k(s), children: "+" }),
1437
+ /* @__PURE__ */ z("div", { style: x, role: "button", "aria-label": "Zoom out", onClick: () => k(1 / s), children: "−" }),
1438
+ /* @__PURE__ */ z(
1400
1439
  "div",
1401
1440
  {
1402
- style: { ...g, fontSize: 12, lineHeight: "30px" },
1441
+ style: { ...x, fontSize: 12, lineHeight: "30px" },
1403
1442
  role: "button",
1404
1443
  "aria-label": "Reset view",
1405
- onClick: () => m(p()),
1444
+ onClick: () => S(p()),
1406
1445
  children: "⤢"
1407
1446
  }
1408
1447
  ),
1409
- /* @__PURE__ */ M(
1448
+ /* @__PURE__ */ z(
1410
1449
  "div",
1411
1450
  {
1412
1451
  "data-testid": `${u}-zoom-readout`,
1413
- style: { ...g, fontSize: 11, cursor: "default" },
1414
- children: Math.round(se(b.scale, i, l) * 100)
1452
+ style: { ...x, fontSize: 11, cursor: "default" },
1453
+ children: Math.round(pe(v.scale, i, l) * 100)
1415
1454
  }
1416
1455
  )
1417
1456
  ]
@@ -1420,7 +1459,7 @@ const pt = 3, _t = ({
1420
1459
  ]
1421
1460
  }
1422
1461
  );
1423
- }, Nt = [
1462
+ }, zn = [
1424
1463
  {
1425
1464
  id: "regular-after-double",
1426
1465
  name: "Regular after double",
@@ -1507,7 +1546,7 @@ const pt = 3, _t = ({
1507
1546
  ],
1508
1547
  layoutStyles: ["linear", "offset"]
1509
1548
  }
1510
- ], Bt = [
1549
+ ], In = [
1511
1550
  {
1512
1551
  id: "single-foot",
1513
1552
  name: "Single foot",
@@ -1615,7 +1654,7 @@ const pt = 3, _t = ({
1615
1654
  },
1616
1655
  layoutStyles: ["linear", "offset"]
1617
1656
  }
1618
- ], te = {
1657
+ ], ie = {
1619
1658
  maxPips: 12,
1620
1659
  engineValue: 12,
1621
1660
  allowConsecutiveDoubles: !1,
@@ -1627,7 +1666,7 @@ const pt = 3, _t = ({
1627
1666
  sideToeAngles: [-45, 45]
1628
1667
  }
1629
1668
  };
1630
- function ht(e) {
1669
+ function $t(e) {
1631
1670
  switch (e.doubleObligation) {
1632
1671
  case "chicken-foot":
1633
1672
  return Math.max(1, e.chickenFoot.toeCount);
@@ -1637,45 +1676,45 @@ function ht(e) {
1637
1676
  return 0;
1638
1677
  }
1639
1678
  }
1640
- function xt(e) {
1679
+ function Et(e) {
1641
1680
  return e.doubleObligation === "chicken-foot" ? Math.max(0, e.chickenFoot.toeCount - 1) : 0;
1642
1681
  }
1643
- function jt(e = {}) {
1644
- const t = e.maxPips ?? te.maxPips;
1682
+ function Pn(e = {}) {
1683
+ const t = e.maxPips ?? ie.maxPips;
1645
1684
  return {
1646
- ...te,
1685
+ ...ie,
1647
1686
  ...e,
1648
1687
  maxPips: t,
1649
1688
  engineValue: e.engineValue ?? t,
1650
1689
  chickenFoot: {
1651
- ...te.chickenFoot,
1690
+ ...ie.chickenFoot,
1652
1691
  ...e.chickenFoot ?? {}
1653
1692
  }
1654
1693
  };
1655
1694
  }
1656
- function gt(e, t) {
1657
- let n = e;
1658
- for (const o of t)
1659
- if (n = n?.feet?.[o.doubleIndex]?.[o.toeIndex], !n) return;
1660
- return n;
1695
+ function At(e, t) {
1696
+ let o = e;
1697
+ for (const n of t)
1698
+ if (o = o?.feet?.[n.doubleIndex]?.[n.toeIndex], !o) return;
1699
+ return o;
1661
1700
  }
1662
- function H(e, t, n) {
1663
- if (n(e, t), !!e.feet)
1664
- for (const o of Object.keys(e.feet)) {
1665
- const r = Number(o);
1701
+ function ne(e, t, o) {
1702
+ if (o(e, t), !!e.feet)
1703
+ for (const n of Object.keys(e.feet)) {
1704
+ const r = Number(n);
1666
1705
  e.feet[r].forEach((i, l) => {
1667
- H(i, [...t, { doubleIndex: r, toeIndex: l }], n);
1706
+ ne(i, [...t, { doubleIndex: r, toeIndex: l }], o);
1668
1707
  });
1669
1708
  }
1670
1709
  }
1671
- function vt(e) {
1710
+ function Ot(e) {
1672
1711
  const t = [];
1673
- return H(e, [], (n, o) => {
1674
- n.dominoes.forEach((r, i) => {
1712
+ return ne(e, [], (o, n) => {
1713
+ o.dominoes.forEach((r, i) => {
1675
1714
  if (r.value1 !== r.value2) return;
1676
- const l = i < n.dominoes.length - 1, s = n.feet?.[i]?.length ?? 0;
1715
+ const l = i < o.dominoes.length - 1, s = o.feet?.[i]?.length ?? 0;
1677
1716
  t.push({
1678
- path: o,
1717
+ path: n,
1679
1718
  doubleIndex: i,
1680
1719
  value: r.value1,
1681
1720
  hasCenter: l,
@@ -1685,18 +1724,18 @@ function vt(e) {
1685
1724
  });
1686
1725
  }), t;
1687
1726
  }
1688
- function bt(e, t) {
1689
- const n = ht(t);
1690
- return n <= 0 ? [] : vt(e).filter((o) => o.answers < n);
1727
+ function Rt(e, t) {
1728
+ const o = $t(t);
1729
+ return o <= 0 ? [] : Ot(e).filter((n) => n.answers < o);
1691
1730
  }
1692
- function yt(e) {
1731
+ function Xe(e) {
1693
1732
  const t = /* @__PURE__ */ new Set();
1694
- return H(e, [], (n) => {
1695
- for (const o of n.dominoes)
1696
- t.add(ke(o));
1733
+ return ne(e, [], (o) => {
1734
+ for (const n of o.dominoes)
1735
+ t.add(B(n));
1697
1736
  }), t;
1698
1737
  }
1699
- function wt(e, t, n) {
1738
+ function Ft(e, t, o) {
1700
1739
  if (e.dominoes.length === 0)
1701
1740
  return [
1702
1741
  {
@@ -1708,11 +1747,11 @@ function wt(e, t, n) {
1708
1747
  obligation: !1
1709
1748
  }
1710
1749
  ];
1711
- const o = bt(e, n);
1712
- if (n.doubleObligation !== "none" && o.length > 0) {
1713
- const i = xt(n), l = [];
1714
- for (const s of o) {
1715
- const a = gt(e, s.path);
1750
+ const n = Rt(e, o);
1751
+ if (o.doubleObligation !== "none" && n.length > 0) {
1752
+ const i = Et(o), l = [];
1753
+ for (const s of n) {
1754
+ const a = At(e, s.path);
1716
1755
  a && (!s.hasCenter && s.doubleIndex === a.dominoes.length - 1 && l.push({
1717
1756
  path: s.path,
1718
1757
  attach: "run-tail",
@@ -1732,126 +1771,428 @@ function wt(e, t, n) {
1732
1771
  return l;
1733
1772
  }
1734
1773
  const r = [];
1735
- return H(e, [], (i, l) => {
1774
+ return ne(e, [], (i, l) => {
1736
1775
  const s = i.dominoes[i.dominoes.length - 1];
1737
1776
  s && r.push({
1738
1777
  path: l,
1739
1778
  attach: "run-tail",
1740
1779
  value: s.value2,
1741
- attachToDouble: Ce(s),
1780
+ attachToDouble: Re(s),
1742
1781
  obligation: !1
1743
1782
  });
1744
1783
  }), r;
1745
1784
  }
1746
- function Pe(e, t, n, o) {
1747
- const r = [], i = Te(e, t.value);
1748
- return o.requireSequential && !i && r.push("value-mismatch"), o.requireUniqueTiles && n.has(ke(e)) && r.push("duplicate-tile"), !o.allowConsecutiveDoubles && t.attachToDouble && Ce(e) && r.push("consecutive-doubles"), { legal: r.length === 0, violations: r };
1785
+ function _e(e, t, o, n) {
1786
+ const r = [], i = de(e, t.value);
1787
+ return n.requireSequential && !i && r.push("value-mismatch"), n.requireUniqueTiles && o.has(B(e)) && r.push("duplicate-tile"), !n.allowConsecutiveDoubles && t.attachToDouble && Re(e) && r.push("consecutive-doubles"), { legal: r.length === 0, violations: r };
1749
1788
  }
1750
- function Ut(e, t, n, o, r) {
1751
- const i = wt(e, t, r), l = [];
1789
+ function Nt(e, t, o, n, r) {
1790
+ const i = Ft(e, t, r), l = [];
1752
1791
  for (const s of i)
1753
- for (const a of n)
1754
- Pe(a, s, o, r).legal && l.push({ end: s, tile: a });
1792
+ for (const a of o)
1793
+ _e(a, s, n, r).legal && l.push({ end: s, tile: a });
1755
1794
  return l;
1756
1795
  }
1757
- function Oe(e, t, n) {
1796
+ function Le(e, t, o) {
1758
1797
  if (t.length === 0)
1759
- return n(e);
1760
- const [o, ...r] = t, l = (e.feet?.[o.doubleIndex] ?? []).map(
1761
- (s, a) => a === o.toeIndex ? Oe(s, r, n) : s
1798
+ return o(e);
1799
+ const [n, ...r] = t, l = (e.feet?.[n.doubleIndex] ?? []).map(
1800
+ (s, a) => a === n.toeIndex ? Le(s, r, o) : s
1762
1801
  );
1763
1802
  return {
1764
1803
  ...e,
1765
- feet: { ...e.feet, [o.doubleIndex]: l }
1804
+ feet: { ...e.feet, [n.doubleIndex]: l }
1766
1805
  };
1767
1806
  }
1768
- function St(e, t, n) {
1769
- const o = Te(t.tile, t.end.value) ?? { ...t.tile };
1770
- return Oe(e, t.end.path, (r) => {
1807
+ function Yt(e, t, o) {
1808
+ const n = de(t.tile, t.end.value) ?? { ...t.tile };
1809
+ return Le(e, t.end.path, (r) => {
1771
1810
  if (t.end.attach === "run-tail")
1772
- return { ...r, dominoes: [...r.dominoes, o] };
1811
+ return { ...r, dominoes: [...r.dominoes, n] };
1773
1812
  const i = t.end.doubleIndex ?? 0, l = t.end.toeSlot ?? r.feet?.[i]?.length ?? 0, s = r.feet?.[i] ? [...r.feet[i]] : [];
1774
- return s[l] = { dominoes: [o] }, {
1813
+ return s[l] = { dominoes: [n] }, {
1775
1814
  ...r,
1776
1815
  feet: { ...r.feet, [i]: s }
1777
1816
  };
1778
1817
  });
1779
1818
  }
1780
- function Vt(e, t, n) {
1781
- const o = Pe(
1819
+ function Tn(e, t, o) {
1820
+ const n = _e(
1782
1821
  t.tile,
1783
1822
  t.end,
1784
- yt(e),
1785
- n
1823
+ Xe(e),
1824
+ o
1786
1825
  );
1787
- return o.legal ? { ok: !0, board: St(e, t), violations: [] } : { ok: !1, board: e, violations: o.violations };
1826
+ return n.legal ? { ok: !0, board: Yt(e, t), violations: [] } : { ok: !1, board: e, violations: n.violations };
1827
+ }
1828
+ function X(e) {
1829
+ return e.kind === "play";
1830
+ }
1831
+ function Xt(e) {
1832
+ const t = [];
1833
+ return e.trains.forEach((o, n) => {
1834
+ (o.playerId === e.selfPlayerId || o.isPublic) && t.push(n);
1835
+ }), t;
1836
+ }
1837
+ function Ve(e) {
1838
+ const t = /* @__PURE__ */ new Set();
1839
+ for (const o of e)
1840
+ for (const n of Xe(o))
1841
+ t.add(n);
1842
+ return t;
1843
+ }
1844
+ function _t(e) {
1845
+ const t = Ve(e.trains), o = [];
1846
+ for (const n of Xt(e)) {
1847
+ const r = e.trains[n], i = Nt(
1848
+ r,
1849
+ e.engineValue,
1850
+ e.hand,
1851
+ t,
1852
+ e.rules
1853
+ );
1854
+ for (const l of i)
1855
+ o.push({ kind: "play", trainIndex: n, move: l });
1856
+ }
1857
+ return o;
1858
+ }
1859
+ function Lt(e = {}) {
1860
+ return (t) => {
1861
+ const o = _t(t), n = [...o];
1862
+ return (t.drawPileSize ?? Number.POSITIVE_INFINITY) > 0 && !t.turnDrawUsed && (o.length === 0 || e.allowOptionalDraw) && n.push({ kind: "draw" }), n.length === 0 && n.push({ kind: "pass" }), n;
1863
+ };
1864
+ }
1865
+ const Vt = Lt(), N = {
1866
+ preferPlay: "prefer-play",
1867
+ dumpPips: "dump-pips",
1868
+ doublesEarly: "play-doubles-early",
1869
+ ownTrain: "own-train",
1870
+ obligationRelief: "obligation-relief",
1871
+ handFlexibility: "hand-flexibility",
1872
+ defensivePublic: "defensive-public"
1873
+ };
1874
+ function Be(e) {
1875
+ const t = de(e.move.tile, e.move.end.value);
1876
+ return t ? t.value2 : e.move.tile.value2;
1877
+ }
1878
+ const Bt = {
1879
+ id: N.preferPlay,
1880
+ score(e) {
1881
+ return e.kind === "play" ? 100 : e.kind === "draw" ? 0 : -50;
1882
+ }
1883
+ }, Ut = {
1884
+ id: N.dumpPips,
1885
+ score(e) {
1886
+ if (!X(e)) return 0;
1887
+ const t = e.move.tile;
1888
+ return t.value1 + t.value2;
1889
+ }
1890
+ }, jt = {
1891
+ id: N.doublesEarly,
1892
+ score(e, t) {
1893
+ if (!X(e)) return 0;
1894
+ const o = e.move.tile;
1895
+ return o.value1 !== o.value2 ? 0 : Math.min(t.obs.hand.length, 12);
1896
+ }
1897
+ }, Gt = {
1898
+ id: N.ownTrain,
1899
+ score(e, t) {
1900
+ if (!X(e)) return 0;
1901
+ const o = t.obs.trains[e.trainIndex];
1902
+ return o && o.playerId === t.obs.selfPlayerId ? 8 : 0;
1903
+ }
1904
+ }, qt = {
1905
+ id: N.obligationRelief,
1906
+ score(e) {
1907
+ return X(e) && e.move.end.obligation ? 10 : 0;
1908
+ }
1909
+ }, Kt = {
1910
+ id: N.handFlexibility,
1911
+ score(e, t) {
1912
+ if (!X(e)) return 0;
1913
+ const o = Be(e), n = B(e.move.tile);
1914
+ let r = !1, i = 0;
1915
+ for (const l of t.obs.hand) {
1916
+ if (!r && B(l) === n) {
1917
+ r = !0;
1918
+ continue;
1919
+ }
1920
+ Fe(l, o) && i++;
1921
+ }
1922
+ return i * 3;
1923
+ }
1924
+ }, Ht = {
1925
+ id: N.defensivePublic,
1926
+ score(e, t) {
1927
+ if (!X(e)) return 0;
1928
+ const o = t.obs.trains[e.trainIndex];
1929
+ if (!o || o.playerId === t.obs.selfPlayerId) return 0;
1930
+ const n = Be(e);
1931
+ let r = 0;
1932
+ for (const i of t.unseen)
1933
+ Fe(i, n) && r++;
1934
+ return -r;
1935
+ }
1936
+ }, Zt = [
1937
+ Bt,
1938
+ Ut,
1939
+ jt,
1940
+ Gt,
1941
+ qt,
1942
+ Kt,
1943
+ Ht
1944
+ ], w = N, Jt = {
1945
+ beginner: {
1946
+ id: "beginner",
1947
+ temperature: 2.5,
1948
+ blunderRate: 0.25,
1949
+ lookaheadDepth: 0,
1950
+ enabled: /* @__PURE__ */ new Set([w.preferPlay, w.dumpPips]),
1951
+ weights: {
1952
+ [w.preferPlay]: 1,
1953
+ [w.dumpPips]: 0.2
1954
+ }
1955
+ },
1956
+ intermediate: {
1957
+ id: "intermediate",
1958
+ temperature: 0.6,
1959
+ blunderRate: 0.05,
1960
+ lookaheadDepth: 0,
1961
+ enabled: /* @__PURE__ */ new Set([w.preferPlay, w.dumpPips, w.doublesEarly, w.ownTrain]),
1962
+ weights: {
1963
+ [w.preferPlay]: 1,
1964
+ [w.dumpPips]: 1,
1965
+ [w.doublesEarly]: 1,
1966
+ [w.ownTrain]: 1
1967
+ }
1968
+ },
1969
+ advanced: {
1970
+ id: "advanced",
1971
+ temperature: 0.15,
1972
+ blunderRate: 0,
1973
+ lookaheadDepth: 0,
1974
+ enabled: /* @__PURE__ */ new Set([
1975
+ w.preferPlay,
1976
+ w.dumpPips,
1977
+ w.doublesEarly,
1978
+ w.ownTrain,
1979
+ w.obligationRelief,
1980
+ w.handFlexibility,
1981
+ w.defensivePublic
1982
+ ]),
1983
+ weights: {
1984
+ [w.preferPlay]: 1,
1985
+ [w.dumpPips]: 1.2,
1986
+ [w.doublesEarly]: 1.5,
1987
+ [w.ownTrain]: 1,
1988
+ [w.obligationRelief]: 1.5,
1989
+ [w.handFlexibility]: 1,
1990
+ [w.defensivePublic]: 1.5
1991
+ }
1992
+ }
1993
+ };
1994
+ function Mn(e) {
1995
+ return Jt[e];
1996
+ }
1997
+ function Qt(e, t, o, n) {
1998
+ let r = 0;
1999
+ for (const i of n.enabled) {
2000
+ const l = o.get(i);
2001
+ if (!l) continue;
2002
+ const s = n.weights[i] ?? 1;
2003
+ r += s * l.score(e, t);
2004
+ }
2005
+ return r;
2006
+ }
2007
+ function Wt(e, t) {
2008
+ let o = Number.NEGATIVE_INFINITY, n = [];
2009
+ return e.forEach((r, i) => {
2010
+ r > o ? (o = r, n = [i]) : r === o && n.push(i);
2011
+ }), n[Math.floor(t() * n.length)];
2012
+ }
2013
+ function en(e, t, o) {
2014
+ const n = Math.max(...e), r = e.map((s) => Math.exp((s - n) / t)), i = r.reduce((s, a) => s + a, 0);
2015
+ let l = o() * i;
2016
+ for (let s = 0; s < r.length; s++)
2017
+ if (l -= r[s], l <= 0) return s;
2018
+ return r.length - 1;
2019
+ }
2020
+ function tn(e, t, o) {
2021
+ return e.length <= 1 ? 0 : t.temperature <= 0 ? Wt(e, o) : en(e, t.temperature, o);
2022
+ }
2023
+ function nn(e) {
2024
+ const { skill: t, generateCandidates: o, buildContext: n, fallback: r } = e, i = e.rng ?? Math.random, l = new Map(e.heuristics.map((s) => [s.id, s]));
2025
+ return {
2026
+ decide(s) {
2027
+ const a = o(s);
2028
+ if (a.length === 0) return r(s);
2029
+ if (a.length === 1) return a[0];
2030
+ if (t.blunderRate > 0 && i() < t.blunderRate)
2031
+ return a[Math.floor(i() * a.length)];
2032
+ const c = n(s, a), d = a.map(
2033
+ (u) => Qt(u, c, l, t)
2034
+ );
2035
+ return a[tn(d, t, i)];
2036
+ }
2037
+ };
2038
+ }
2039
+ function on(e, t, o) {
2040
+ const n = Ve(e.trains), r = new Set(n);
2041
+ for (const l of e.hand)
2042
+ r.add(B(l));
2043
+ const i = wt(e.rules.maxPips).filter(
2044
+ (l) => !r.has(B(l))
2045
+ );
2046
+ return {
2047
+ obs: e,
2048
+ playedKeys: n,
2049
+ candidates: t,
2050
+ playCandidates: t.filter(X),
2051
+ unseen: i,
2052
+ rng: o
2053
+ };
2054
+ }
2055
+ function kn(e) {
2056
+ const t = e.heuristics ?? Zt, o = e.generateCandidates ?? Vt, n = e.rng ?? Math.random;
2057
+ return nn({
2058
+ skill: e.skill,
2059
+ heuristics: t,
2060
+ generateCandidates: o,
2061
+ buildContext: (r, i) => on(r, i, n),
2062
+ fallback: () => ({ kind: "pass" }),
2063
+ rng: n
2064
+ });
2065
+ }
2066
+ function Ue(e, t, o) {
2067
+ let n = t.legalActions(e);
2068
+ return t.orderActions && (n = t.orderActions(e, n)), Number.isFinite(o) && n.length > o && (n = n.slice(0, o)), n;
2069
+ }
2070
+ function je(e, t, o, n, r) {
2071
+ if (o <= 0 || t.isTerminal(e))
2072
+ return t.evaluate(e, n);
2073
+ const i = Ue(e, t, r);
2074
+ if (i.length === 0)
2075
+ return t.evaluate(e, n);
2076
+ const l = t.currentPlayer(e) === n;
2077
+ let s = l ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
2078
+ for (const a of i) {
2079
+ const c = je(
2080
+ t.applyAction(e, a),
2081
+ t,
2082
+ o - 1,
2083
+ n,
2084
+ r
2085
+ );
2086
+ s = l ? Math.max(s, c) : Math.min(s, c);
2087
+ }
2088
+ return s;
2089
+ }
2090
+ function Cn(e, t, o) {
2091
+ const n = o.rng ?? Math.random, r = Math.max(1, o.determinizations ?? 1), i = o.maxBranch ?? Number.POSITIVE_INFINITY, l = Math.max(1, o.depth);
2092
+ return Ue(e, t, i).map((a) => {
2093
+ let c = 0;
2094
+ for (let d = 0; d < r; d++) {
2095
+ const u = t.determinize ? t.determinize(e, o.perspective, n) : e;
2096
+ c += je(
2097
+ t.applyAction(u, a),
2098
+ t,
2099
+ l - 1,
2100
+ o.perspective,
2101
+ i
2102
+ );
2103
+ }
2104
+ return { action: a, value: c / r };
2105
+ });
1788
2106
  }
1789
2107
  export {
1790
- Bt as CHICKEN_FOOT_FIXTURES,
1791
- Ue as CHICKEN_FOOT_TOE_ANGLES,
1792
- j as DEFAULT_PIP_COLORS,
1793
- te as DEFAULT_RULES,
1794
- rt as DominoHub,
1795
- ot as DominoTrain,
1796
- ve as DoubleTwelve,
1797
- Xt as MexicanTrainGame,
1798
- Mt as PIP_COLORS,
1799
- _e as PIP_LAYOUTS,
1800
- Nt as TRAIN_FIXTURES,
1801
- le as TURN_DEGREES,
1802
- _t as Viewport,
1803
- St as applyMove,
1804
- De as buildBranchTiles,
1805
- se as clampScale,
1806
- yt as collectPlayedKeys,
1807
- Ke as computeTrainLayout,
1808
- re as computeTrainTree,
1809
- Ft as cycleBendAt,
1810
- ke as dominoKey,
1811
- Et as dominoSetSize,
1812
- Pe as evaluatePlacement,
1813
- ft as fitToBounds,
1814
- ze as flattenSegments,
1815
- Ot as generateDominoSet,
1816
- it as generateSampleTrains,
1817
- gt as getBranchAt,
1818
- Ut as getLegalMoves,
1819
- wt as getOpenEnds,
1820
- Ne as getPipLayout,
1821
- kt as getPipStyle,
1822
- Ct as getTrainLayoutBounds,
1823
- bt as getUnsatisfiedDoubles,
1824
- Ge as headingAtIndex,
1825
- nt as hubTrainStartDistance,
1826
- Ce as isDouble,
1827
- me as layoutSelfIntersects,
1828
- Se as layoutsCollide,
1829
- Rt as linearDefaultSide,
1830
- $t as mergePipColors,
1831
- we as normalizeBends,
1832
- Yt as offsetDefaultSide,
1833
- Ie as oppositeSide,
1834
- Te as orientForConnection,
1835
- Pt as otherEnd,
1836
- U as outwardPerpSign,
1837
- Vt as playMove,
1838
- ht as requiredDoubleAnswers,
1839
- At as resolveBend,
1840
- Fe as resolvePipPosition,
1841
- ge as resolvePipStyle,
1842
- jt as resolveRules,
1843
- Lt as screenToContent,
1844
- oe as sideToTurn,
1845
- xt as sideToeSlots,
1846
- O as stepAlongTrain,
1847
- fe as tileCorners,
1848
- Dt as tileHasValue,
1849
- L as tileKey,
1850
- J as tilesOverlap,
1851
- et as validateChickenFootChain,
1852
- Tt as validateTrainLayout,
1853
- It as validateTrainTree,
1854
- K as withBendAt,
1855
- he as zoomAt
2108
+ In as CHICKEN_FOOT_FIXTURES,
2109
+ lt as CHICKEN_FOOT_TOE_ANGLES,
2110
+ Je as DEFAULT_DOMINO_THEME,
2111
+ Zt as DEFAULT_HEURISTICS,
2112
+ q as DEFAULT_PIP_COLORS,
2113
+ ie as DEFAULT_RULES,
2114
+ We as DefaultPip,
2115
+ mt as DominoHub,
2116
+ sn as DominoThemeProvider,
2117
+ bt as DominoTrain,
2118
+ Te as DoubleTwelve,
2119
+ N as HEURISTIC_IDS,
2120
+ vn as MexicanTrainGame,
2121
+ an as PIP_COLORS,
2122
+ nt as PIP_LAYOUTS,
2123
+ Jt as SKILL_PRESETS,
2124
+ zn as TRAIN_FIXTURES,
2125
+ fe as TURN_DEGREES,
2126
+ Sn as Viewport,
2127
+ Yt as applyMove,
2128
+ Wt as argmaxIndex,
2129
+ Ye as buildBranchTiles,
2130
+ tn as chooseActionIndex,
2131
+ pe as clampScale,
2132
+ Ve as collectAllPlayedKeys,
2133
+ Xe as collectPlayedKeys,
2134
+ ct as computeTrainLayout,
2135
+ ue as computeTrainTree,
2136
+ kn as createAiPlayer,
2137
+ Lt as createCandidateGenerator,
2138
+ nn as createPolicyPlayer,
2139
+ mn as cycleBendAt,
2140
+ Vt as defaultCandidateGenerator,
2141
+ B as dominoKey,
2142
+ gn as dominoSetSize,
2143
+ _e as evaluatePlacement,
2144
+ Ct as fitToBounds,
2145
+ Ee as flattenSegments,
2146
+ wt as generateDominoSet,
2147
+ _t as generatePlayActions,
2148
+ St as generateSampleTrains,
2149
+ Xt as getAccessibleTrainIndices,
2150
+ At as getBranchAt,
2151
+ Nt as getLegalMoves,
2152
+ Ft as getOpenEnds,
2153
+ ot as getPipLayout,
2154
+ cn as getPipStyle,
2155
+ Mn as getSkillProfile,
2156
+ dn as getTrainLayoutBounds,
2157
+ Rt as getUnsatisfiedDoubles,
2158
+ at as headingAtIndex,
2159
+ yt as hubTrainStartDistance,
2160
+ Re as isDouble,
2161
+ X as isPlayAction,
2162
+ $e as layoutSelfIntersects,
2163
+ De as layoutsCollide,
2164
+ bn as linearDefaultSide,
2165
+ ze as mergeDominoTheme,
2166
+ un as mergePipColors,
2167
+ Ce as normalizeBends,
2168
+ xn as offsetDefaultSide,
2169
+ Ne as oppositeSide,
2170
+ de as orientForConnection,
2171
+ hn as otherEnd,
2172
+ K as outwardPerpSign,
2173
+ Tn as playMove,
2174
+ $t as requiredDoubleAnswers,
2175
+ yn as resolveBend,
2176
+ tt as resolvePipPosition,
2177
+ Pe as resolvePipStyle,
2178
+ Pn as resolveRules,
2179
+ Qt as scoreWithHeuristics,
2180
+ wn as screenToContent,
2181
+ Cn as searchActionValues,
2182
+ se as sideToTurn,
2183
+ Et as sideToeSlots,
2184
+ en as softmaxIndex,
2185
+ A as stepAlongTrain,
2186
+ Qe as themeDataAttributes,
2187
+ be as tileCorners,
2188
+ Fe as tileHasValue,
2189
+ V as tileKey,
2190
+ ee as tilesOverlap,
2191
+ Ie as useDominoTheme,
2192
+ vt as validateChickenFootChain,
2193
+ fn as validateTrainLayout,
2194
+ pn as validateTrainTree,
2195
+ Q as withBendAt,
2196
+ me as zoomAt
1856
2197
  };
1857
2198
  //# sourceMappingURL=index.js.map