@bedard/hexboard 0.0.7 → 0.0.9

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/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # 0.0.9
2
+
3
+ - Fix click-move capturing (https://github.com/scottbedard/hexboard/issues/1)
4
+ - Remove `data-testid` from built files
5
+
6
+ # 0.0.8
7
+
8
+ - Round SVG coordinates for better SSR hydration
9
+
1
10
  # 0.0.7
2
11
 
3
12
  - Export `defaultOptions` constant and `HexboardOptions` type
package/dist/index.js CHANGED
@@ -1,44 +1,44 @@
1
- import { defineComponent as ao, createElementBlock as P, openBlock as b, createElementVNode as fo, toDisplayString as vo, mergeModels as so, useModel as Zt, shallowRef as et, useTemplateRef as Co, computed as z, onMounted as Eo, onUnmounted as $o, watch as ro, createCommentVNode as tt, unref as f, normalizeStyle as at, Fragment as ot, renderList as nt, mergeProps as Lo, createBlock as io, resolveDynamicComponent as uo, withModifiers as Bo, renderSlot as Mo, h as To } from "vue";
2
- import { Hexchess as co, position as W, San as ft, isPromotionPosition as Fo } from "@bedard/hexchess";
3
- function r(u, $, d) {
4
- return [u[0] + d * ($[0] - u[0]), u[1] + d * ($[1] - u[1])];
1
+ import { defineComponent as ao, createElementBlock as P, openBlock as b, createElementVNode as fo, toDisplayString as vo, mergeModels as so, useModel as Zt, shallowRef as tt, useTemplateRef as Co, computed as A, onMounted as Eo, onUnmounted as Lo, watch as ro, createCommentVNode as ot, unref as a, normalizeStyle as at, Fragment as nt, renderList as lt, mergeProps as Bo, createBlock as uo, resolveDynamicComponent as io, withModifiers as Mo, renderSlot as $o, h as To } from "vue";
2
+ import { Hexchess as co, position as fe, San as ft, isPromotionPosition as Fo } from "@bedard/hexchess";
3
+ function r(i, B, v) {
4
+ return [i[0] + v * (B[0] - i[0]), i[1] + v * (B[1] - i[1])];
5
5
  }
6
- function n(u) {
7
- return u.map(t);
6
+ function n(i) {
7
+ return i.map(t);
8
8
  }
9
- function e(u) {
9
+ function e(i) {
10
10
  return [
11
- x(u, -300, ie),
12
- x(u, 0, ie),
13
- x(u, -60, ie),
14
- x(u, -120, ie),
15
- x(u, -180, ie),
16
- x(u, -240, ie)
11
+ x(i, -300, ue),
12
+ x(i, 0, ue),
13
+ x(i, -60, ue),
14
+ x(i, -120, ue),
15
+ x(i, -180, ue),
16
+ x(i, -240, ue)
17
17
  ];
18
18
  }
19
- function x(u, $, d) {
20
- const Q = Ro($);
19
+ function x(i, B, v) {
20
+ const Q = Ro(B);
21
21
  return [
22
- d * Math.cos(Q) + u[0],
23
- d * Math.sin(Q) + u[1]
22
+ v * Math.cos(Q) + i[0],
23
+ v * Math.sin(Q) + i[1]
24
24
  ];
25
25
  }
26
- function Ro(u) {
27
- return u * (Math.PI / 180);
26
+ function Ro(i) {
27
+ return i * (Math.PI / 180);
28
28
  }
29
- function t(u) {
30
- return [-u[0], -u[1]];
29
+ function t(i) {
30
+ return [-i[0], -i[1]];
31
31
  }
32
- function l(u, $) {
33
- return [u[0] + $[0], u[1] + $[1]];
32
+ function l(i, B) {
33
+ return [i[0] + B[0], i[1] + B[1]];
34
34
  }
35
- function fe(u) {
36
- return ve / 2 + u;
35
+ function ve(i) {
36
+ return de / 2 + i;
37
37
  }
38
- function de(u) {
39
- return ve / 2 - u;
38
+ function he(i) {
39
+ return de / 2 - i;
40
40
  }
41
- const ve = 23.6, So = {
41
+ const de = 23.6, So = {
42
42
  colors: [
43
43
  "oklch(0.9015 0.0729 70.7)",
44
44
  "oklch(0.8366 0.1165 66.29)",
@@ -57,56 +57,56 @@ const ve = 23.6, So = {
57
57
  // red-500
58
58
  targetColor: "oklch(63.7% 0.237 25.331)"
59
59
  // red-500
60
- }, qo = "b/qbk/n1b1n/r5r/ppppppppp/11/5P5/4P1P4/3P1B1P3/2P2B2P2/1PRNQBKNRP1 w - 0 1", i = 1.7, V = 1.7, ie = 2 / Math.sqrt(3), p = ie * (Math.sqrt(3) / 2) * 2, w = p * 2, y = p * 3, k = p * 4, E = p * 5, m = [0, 0], A = x(m, 150, E), R = x(m, 150, k), D = x(m, 150, y), S = x(m, 150, w), M = x(m, 150, p), T = x(m, 30, p), q = x(m, 30, w), H = x(m, 30, y), N = x(m, 30, k), O = x(m, 30, E), U = l(A, [0, -E]), Z = l(R, [0, -E]), he = l(D, [0, -E]), pe = l(S, [0, -E]), me = l(M, [0, -E]), ge = l(m, [0, -E]), we = l(T, [0, -E]), ye = l(q, [0, -E]), be = l(H, [0, -E]), j = l(N, [0, -E]), G = l(O, [0, -E]), J = l(A, [0, -k]), I = l(R, [0, -k]), xe = l(D, [0, -k]), ke = l(S, [0, -k]), Pe = l(M, [0, -k]), Ce = l(m, [0, -k]), Ee = l(T, [0, -k]), $e = l(q, [0, -k]), Le = l(H, [0, -k]), _ = l(N, [0, -k]), ee = l(O, [0, -k]), Be = l(A, [0, -y]), Me = l(R, [0, -y]), dt = l(D, [0, -y]), vt = l(S, [0, -y]), ht = l(M, [0, -y]), pt = l(m, [0, -y]), mt = l(T, [0, -y]), gt = l(q, [0, -y]), wt = l(H, [0, -y]), Te = l(N, [0, -y]), Fe = l(O, [0, -y]), Re = l(A, [0, -w]), Se = l(R, [0, -w]), yt = l(D, [0, -w]), bt = l(S, [0, -w]), xt = l(M, [0, -w]), kt = l(m, [0, -w]), Pt = l(T, [0, -w]), Ct = l(q, [0, -w]), Et = l(H, [0, -w]), qe = l(N, [0, -w]), Ne = l(O, [0, -w]), ze = l(A, [0, -p]), We = l(R, [0, -p]), $t = l(D, [0, -p]), Lt = l(S, [0, -p]), Bt = l(M, [0, -p]), Mt = l(m, [0, -p]), Tt = l(T, [0, -p]), Ft = l(q, [0, -p]), Rt = l(H, [0, -p]), Ae = l(N, [0, -p]), De = l(O, [0, -p]), He = l(R, [0, p]), Oe = l(D, [0, p]), St = l(S, [0, p]), qt = l(M, [0, p]), Nt = l(m, [0, p]), zt = l(T, [0, p]), Wt = l(q, [0, p]), Xe = l(H, [0, p]), Ye = l(N, [0, p]), Ke = l(D, [0, w]), Qe = l(S, [0, w]), At = l(M, [0, w]), Dt = l(m, [0, w]), Ht = l(T, [0, w]), Ve = l(q, [0, w]), Ue = l(H, [0, w]), Ze = l(S, [0, y]), je = l(M, [0, y]), Ot = l(m, [0, y]), Ge = l(T, [0, y]), Je = l(q, [0, y]), te = l(M, [0, k]), oe = l(m, [0, k]), ne = l(T, [0, k]), le = l(m, [0, E]), o = [
60
+ }, qo = "b/qbk/n1b1n/r5r/ppppppppp/11/5P5/4P1P4/3P1B1P3/2P2B2P2/1PRNQBKNRP1 w - 0 1", u = 1.7, V = 1.7, ue = 2 / Math.sqrt(3), p = ue * (Math.sqrt(3) / 2) * 2, w = p * 2, y = p * 3, k = p * 4, L = p * 5, m = [0, 0], D = x(m, 150, L), S = x(m, 150, k), H = x(m, 150, y), q = x(m, 150, w), $ = x(m, 150, p), T = x(m, 30, p), N = x(m, 30, w), O = x(m, 30, y), z = x(m, 30, k), X = x(m, 30, L), U = l(D, [0, -L]), Z = l(S, [0, -L]), pe = l(H, [0, -L]), me = l(q, [0, -L]), ge = l($, [0, -L]), we = l(m, [0, -L]), ye = l(T, [0, -L]), be = l(N, [0, -L]), xe = l(O, [0, -L]), j = l(z, [0, -L]), G = l(X, [0, -L]), I = l(D, [0, -k]), J = l(S, [0, -k]), ke = l(H, [0, -k]), Pe = l(q, [0, -k]), Ce = l($, [0, -k]), Ee = l(m, [0, -k]), Le = l(T, [0, -k]), Be = l(N, [0, -k]), Me = l(O, [0, -k]), _ = l(z, [0, -k]), ee = l(X, [0, -k]), $e = l(D, [0, -y]), Te = l(S, [0, -y]), vt = l(H, [0, -y]), ht = l(q, [0, -y]), dt = l($, [0, -y]), pt = l(m, [0, -y]), mt = l(T, [0, -y]), gt = l(N, [0, -y]), wt = l(O, [0, -y]), Fe = l(z, [0, -y]), Re = l(X, [0, -y]), Se = l(D, [0, -w]), qe = l(S, [0, -w]), yt = l(H, [0, -w]), bt = l(q, [0, -w]), xt = l($, [0, -w]), kt = l(m, [0, -w]), Pt = l(T, [0, -w]), Ct = l(N, [0, -w]), Et = l(O, [0, -w]), Ne = l(z, [0, -w]), ze = l(X, [0, -w]), We = l(D, [0, -p]), Ae = l(S, [0, -p]), Lt = l(H, [0, -p]), Bt = l(q, [0, -p]), Mt = l($, [0, -p]), $t = l(m, [0, -p]), Tt = l(T, [0, -p]), Ft = l(N, [0, -p]), Rt = l(O, [0, -p]), De = l(z, [0, -p]), He = l(X, [0, -p]), Oe = l(S, [0, p]), Xe = l(H, [0, p]), St = l(q, [0, p]), qt = l($, [0, p]), Nt = l(m, [0, p]), zt = l(T, [0, p]), Wt = l(N, [0, p]), Ye = l(O, [0, p]), Ke = l(z, [0, p]), Qe = l(H, [0, w]), Ve = l(q, [0, w]), At = l($, [0, w]), Dt = l(m, [0, w]), Ht = l(T, [0, w]), Ue = l(N, [0, w]), Ze = l(O, [0, w]), je = l(q, [0, y]), Ge = l($, [0, y]), Ot = l(m, [0, y]), Ie = l(T, [0, y]), Je = l(N, [0, y]), te = l($, [0, k]), oe = l(m, [0, k]), ne = l(T, [0, k]), le = l(m, [0, L]), o = [
61
61
  [2, le, t(le), e(le), n(e(le))],
62
62
  [1, te, t(te), e(te), n(e(te))],
63
63
  [0, oe, t(oe), e(oe), n(e(oe))],
64
64
  [1, ne, t(ne), e(ne), n(e(ne))],
65
- [0, Ze, t(Ze), e(Ze), n(e(Ze))],
66
- [2, je, t(je), e(je), n(e(je))],
67
- [1, Ot, t(Ot), e(Ot), n(e(Ot))],
65
+ [0, je, t(je), e(je), n(e(je))],
68
66
  [2, Ge, t(Ge), e(Ge), n(e(Ge))],
67
+ [1, Ot, t(Ot), e(Ot), n(e(Ot))],
68
+ [2, Ie, t(Ie), e(Ie), n(e(Ie))],
69
69
  [0, Je, t(Je), e(Je), n(e(Je))],
70
- [2, Ke, t(Ke), e(Ke), n(e(Ke))],
71
- [1, Qe, t(Qe), e(Qe), n(e(Qe))],
70
+ [2, Qe, t(Qe), e(Qe), n(e(Qe))],
71
+ [1, Ve, t(Ve), e(Ve), n(e(Ve))],
72
72
  [0, At, t(At), e(At), n(e(At))],
73
73
  [2, Dt, t(Dt), e(Dt), n(e(Dt))],
74
74
  [0, Ht, t(Ht), e(Ht), n(e(Ht))],
75
- [1, Ve, t(Ve), e(Ve), n(e(Ve))],
76
- [2, Ue, t(Ue), e(Ue), n(e(Ue))],
77
- [1, He, t(He), e(He), n(e(He))],
78
- [0, Oe, t(Oe), e(Oe), n(e(Oe))],
75
+ [1, Ue, t(Ue), e(Ue), n(e(Ue))],
76
+ [2, Ze, t(Ze), e(Ze), n(e(Ze))],
77
+ [1, Oe, t(Oe), e(Oe), n(e(Oe))],
78
+ [0, Xe, t(Xe), e(Xe), n(e(Xe))],
79
79
  [2, St, t(St), e(St), n(e(St))],
80
80
  [1, qt, t(qt), e(qt), n(e(qt))],
81
81
  [0, Nt, t(Nt), e(Nt), n(e(Nt))],
82
82
  [1, zt, t(zt), e(zt), n(e(zt))],
83
83
  [2, Wt, t(Wt), e(Wt), n(e(Wt))],
84
- [0, Xe, t(Xe), e(Xe), n(e(Xe))],
85
- [1, Ye, t(Ye), e(Ye), n(e(Ye))],
86
- [0, A, t(A), e(A), n(e(A))],
87
- [2, R, t(R), e(R), n(e(R))],
88
- [1, D, t(D), e(D), n(e(D))],
89
- [0, S, t(S), e(S), n(e(S))],
90
- [2, M, t(M), e(M), n(e(M))],
84
+ [0, Ye, t(Ye), e(Ye), n(e(Ye))],
85
+ [1, Ke, t(Ke), e(Ke), n(e(Ke))],
86
+ [0, D, t(D), e(D), n(e(D))],
87
+ [2, S, t(S), e(S), n(e(S))],
88
+ [1, H, t(H), e(H), n(e(H))],
89
+ [0, q, t(q), e(q), n(e(q))],
90
+ [2, $, t($), e($), n(e($))],
91
91
  [1, m, t(m), e(m), n(e(m))],
92
92
  [2, T, t(T), e(T), n(e(T))],
93
- [0, q, t(q), e(q), n(e(q))],
94
- [1, H, t(H), e(H), n(e(H))],
95
- [2, N, t(N), e(N), n(e(N))],
96
- [0, O, t(O), e(O), n(e(O))],
97
- [1, ze, t(ze), e(ze), n(e(ze))],
98
- [0, We, t(We), e(We), n(e(We))],
93
+ [0, N, t(N), e(N), n(e(N))],
94
+ [1, O, t(O), e(O), n(e(O))],
95
+ [2, z, t(z), e(z), n(e(z))],
96
+ [0, X, t(X), e(X), n(e(X))],
97
+ [1, We, t(We), e(We), n(e(We))],
98
+ [0, Ae, t(Ae), e(Ae), n(e(Ae))],
99
+ [2, Lt, t(Lt), e(Lt), n(e(Lt))],
100
+ [1, Bt, t(Bt), e(Bt), n(e(Bt))],
101
+ [0, Mt, t(Mt), e(Mt), n(e(Mt))],
99
102
  [2, $t, t($t), e($t), n(e($t))],
100
- [1, Lt, t(Lt), e(Lt), n(e(Lt))],
101
- [0, Bt, t(Bt), e(Bt), n(e(Bt))],
102
- [2, Mt, t(Mt), e(Mt), n(e(Mt))],
103
103
  [0, Tt, t(Tt), e(Tt), n(e(Tt))],
104
104
  [1, Ft, t(Ft), e(Ft), n(e(Ft))],
105
105
  [2, Rt, t(Rt), e(Rt), n(e(Rt))],
106
- [0, Ae, t(Ae), e(Ae), n(e(Ae))],
107
- [1, De, t(De), e(De), n(e(De))],
108
- [2, Re, t(Re), e(Re), n(e(Re))],
109
- [1, Se, t(Se), e(Se), n(e(Se))],
106
+ [0, De, t(De), e(De), n(e(De))],
107
+ [1, He, t(He), e(He), n(e(He))],
108
+ [2, Se, t(Se), e(Se), n(e(Se))],
109
+ [1, qe, t(qe), e(qe), n(e(qe))],
110
110
  [0, yt, t(yt), e(yt), n(e(yt))],
111
111
  [2, bt, t(bt), e(bt), n(e(bt))],
112
112
  [1, xt, t(xt), e(xt), n(e(xt))],
@@ -114,75 +114,75 @@ const ve = 23.6, So = {
114
114
  [1, Pt, t(Pt), e(Pt), n(e(Pt))],
115
115
  [2, Ct, t(Ct), e(Ct), n(e(Ct))],
116
116
  [0, Et, t(Et), e(Et), n(e(Et))],
117
- [1, qe, t(qe), e(qe), n(e(qe))],
118
- [2, Ne, t(Ne), e(Ne), n(e(Ne))],
119
- [0, Be, t(Be), e(Be), n(e(Be))],
120
- [2, Me, t(Me), e(Me), n(e(Me))],
121
- [1, dt, t(dt), e(dt), n(e(dt))],
122
- [0, vt, t(vt), e(vt), n(e(vt))],
123
- [2, ht, t(ht), e(ht), n(e(ht))],
117
+ [1, Ne, t(Ne), e(Ne), n(e(Ne))],
118
+ [2, ze, t(ze), e(ze), n(e(ze))],
119
+ [0, $e, t($e), e($e), n(e($e))],
120
+ [2, Te, t(Te), e(Te), n(e(Te))],
121
+ [1, vt, t(vt), e(vt), n(e(vt))],
122
+ [0, ht, t(ht), e(ht), n(e(ht))],
123
+ [2, dt, t(dt), e(dt), n(e(dt))],
124
124
  [1, pt, t(pt), e(pt), n(e(pt))],
125
125
  [2, mt, t(mt), e(mt), n(e(mt))],
126
126
  [0, gt, t(gt), e(gt), n(e(gt))],
127
127
  [1, wt, t(wt), e(wt), n(e(wt))],
128
- [2, Te, t(Te), e(Te), n(e(Te))],
129
- [0, Fe, t(Fe), e(Fe), n(e(Fe))],
130
- [1, J, t(J), e(J), n(e(J))],
131
- [0, I, t(I), e(I), n(e(I))],
132
- [2, xe, t(xe), e(xe), n(e(xe))],
133
- [1, ke, t(ke), e(ke), n(e(ke))],
134
- [0, Pe, t(Pe), e(Pe), n(e(Pe))],
135
- [2, Ce, t(Ce), e(Ce), n(e(Ce))],
136
- [0, Ee, t(Ee), e(Ee), n(e(Ee))],
137
- [1, $e, t($e), e($e), n(e($e))],
138
- [2, Le, t(Le), e(Le), n(e(Le))],
128
+ [2, Fe, t(Fe), e(Fe), n(e(Fe))],
129
+ [0, Re, t(Re), e(Re), n(e(Re))],
130
+ [1, I, t(I), e(I), n(e(I))],
131
+ [0, J, t(J), e(J), n(e(J))],
132
+ [2, ke, t(ke), e(ke), n(e(ke))],
133
+ [1, Pe, t(Pe), e(Pe), n(e(Pe))],
134
+ [0, Ce, t(Ce), e(Ce), n(e(Ce))],
135
+ [2, Ee, t(Ee), e(Ee), n(e(Ee))],
136
+ [0, Le, t(Le), e(Le), n(e(Le))],
137
+ [1, Be, t(Be), e(Be), n(e(Be))],
138
+ [2, Me, t(Me), e(Me), n(e(Me))],
139
139
  [0, _, t(_), e(_), n(e(_))],
140
140
  [1, ee, t(ee), e(ee), n(e(ee))],
141
141
  [2, U, t(U), e(U), n(e(U))],
142
142
  [1, Z, t(Z), e(Z), n(e(Z))],
143
- [0, he, t(he), e(he), n(e(he))],
144
- [2, pe, t(pe), e(pe), n(e(pe))],
145
- [1, me, t(me), e(me), n(e(me))],
146
- [0, ge, t(ge), e(ge), n(e(ge))],
147
- [1, we, t(we), e(we), n(e(we))],
148
- [2, ye, t(ye), e(ye), n(e(ye))],
149
- [0, be, t(be), e(be), n(e(be))],
143
+ [0, pe, t(pe), e(pe), n(e(pe))],
144
+ [2, me, t(me), e(me), n(e(me))],
145
+ [1, ge, t(ge), e(ge), n(e(ge))],
146
+ [0, we, t(we), e(we), n(e(we))],
147
+ [1, ye, t(ye), e(ye), n(e(ye))],
148
+ [2, be, t(be), e(be), n(e(be))],
149
+ [0, xe, t(xe), e(xe), n(e(xe))],
150
150
  [1, j, t(j), e(j), n(e(j))],
151
151
  [2, G, t(G), e(G), n(e(G))]
152
152
  ], No = [
153
- ["11", r(ne, le, i), t(r(ne, le, i))],
154
- ["10", r(oe, te, i), t(r(oe, te, i))],
155
- ["9", r(je, Ze, i), t(r(je, Ze, i))],
156
- ["8", r(Qe, Ke, i), t(r(Qe, Ke, i))],
157
- ["7", r(Oe, He, i), t(r(Oe, He, i))],
158
- ["6", r(R, A, i), t(r(R, A, i))],
159
- ["5", r(We, ze, i), t(r(We, ze, i))],
160
- ["4", r(Se, Re, i), t(r(Se, Re, i))],
161
- ["3", r(Me, Be, i), t(r(Me, Be, i))],
162
- ["2", r(I, J, i), t(r(I, J, i))],
163
- ["1", r(Z, U, i), t(r(Z, U, i))],
164
- ["a", r(J, U, i), t(r(J, U, i))],
165
- ["b", r(I, Z, i), t(r(I, Z, i))],
166
- ["c", r(xe, he, i), t(r(xe, he, i))],
167
- ["d", r(ke, pe, i), t(r(ke, pe, i))],
168
- ["e", r(Pe, me, i), t(r(Pe, me, i))],
169
- ["f", r(Ce, ge, i), t(r(Ce, ge, i))],
170
- ["g", r(Ee, we, i), t(r(Ee, we, i))],
171
- ["h", r($e, ye, i), t(r($e, ye, i))],
172
- ["i", r(Le, be, i), t(r(Le, be, i))],
173
- ["k", r(_, j, i), t(r(_, j, i))],
174
- ["l", r(ee, G, i), t(r(ee, G, i))],
175
- ["1", r(j, G, i), t(r(j, G, i))],
176
- ["2", r(_, ee, i), t(r(_, ee, i))],
177
- ["3", r(Te, Fe, i), t(r(Te, Fe, i))],
178
- ["4", r(qe, Ne, i), t(r(qe, Ne, i))],
179
- ["5", r(Ae, De, i), t(r(Ae, De, i))],
180
- ["6", r(N, O, i), t(r(N, O, i))],
181
- ["7", r(Xe, Ye, i), t(r(Xe, Ye, i))],
182
- ["8", r(Ve, Ue, i), t(r(Ve, Ue, i))],
183
- ["9", r(Ge, Je, i), t(r(Ge, Je, i))],
184
- ["10", r(oe, ne, i), t(r(oe, ne, i))],
185
- ["11", r(te, le, i), t(r(te, le, i))]
153
+ ["11", r(ne, le, u), t(r(ne, le, u))],
154
+ ["10", r(oe, te, u), t(r(oe, te, u))],
155
+ ["9", r(Ge, je, u), t(r(Ge, je, u))],
156
+ ["8", r(Ve, Qe, u), t(r(Ve, Qe, u))],
157
+ ["7", r(Xe, Oe, u), t(r(Xe, Oe, u))],
158
+ ["6", r(S, D, u), t(r(S, D, u))],
159
+ ["5", r(Ae, We, u), t(r(Ae, We, u))],
160
+ ["4", r(qe, Se, u), t(r(qe, Se, u))],
161
+ ["3", r(Te, $e, u), t(r(Te, $e, u))],
162
+ ["2", r(J, I, u), t(r(J, I, u))],
163
+ ["1", r(Z, U, u), t(r(Z, U, u))],
164
+ ["a", r(I, U, u), t(r(I, U, u))],
165
+ ["b", r(J, Z, u), t(r(J, Z, u))],
166
+ ["c", r(ke, pe, u), t(r(ke, pe, u))],
167
+ ["d", r(Pe, me, u), t(r(Pe, me, u))],
168
+ ["e", r(Ce, ge, u), t(r(Ce, ge, u))],
169
+ ["f", r(Ee, we, u), t(r(Ee, we, u))],
170
+ ["g", r(Le, ye, u), t(r(Le, ye, u))],
171
+ ["h", r(Be, be, u), t(r(Be, be, u))],
172
+ ["i", r(Me, xe, u), t(r(Me, xe, u))],
173
+ ["k", r(_, j, u), t(r(_, j, u))],
174
+ ["l", r(ee, G, u), t(r(ee, G, u))],
175
+ ["1", r(j, G, u), t(r(j, G, u))],
176
+ ["2", r(_, ee, u), t(r(_, ee, u))],
177
+ ["3", r(Fe, Re, u), t(r(Fe, Re, u))],
178
+ ["4", r(Ne, ze, u), t(r(Ne, ze, u))],
179
+ ["5", r(De, He, u), t(r(De, He, u))],
180
+ ["6", r(z, X, u), t(r(z, X, u))],
181
+ ["7", r(Ye, Ke, u), t(r(Ye, Ke, u))],
182
+ ["8", r(Ue, Ze, u), t(r(Ue, Ze, u))],
183
+ ["9", r(Ie, Je, u), t(r(Ie, Je, u))],
184
+ ["10", r(oe, ne, u), t(r(oe, ne, u))],
185
+ ["11", r(te, le, u), t(r(te, le, u))]
186
186
  ], zo = [
187
187
  o[
188
188
  0
@@ -557,17 +557,17 @@ const ve = 23.6, So = {
557
557
  /* e10 */
558
558
  ][3][0]
559
559
  ];
560
- function Xt(u) {
561
- if (u.length === 0)
560
+ function Xt(i) {
561
+ if (i.length === 0)
562
562
  return "";
563
- const [$, ...d] = u;
564
- let Q = `M ${Yt(fe($[0]))} ${Yt(de($[1]))} L `;
565
- for (const F of d)
566
- Q += `${Yt(fe(F[0]))} ${Yt(de(F[1]))} `;
563
+ const [B, ...v] = i;
564
+ let Q = `M ${R(ve(B[0]))} ${R(he(B[1]))} L `;
565
+ for (const F of v)
566
+ Q += `${R(ve(F[0]))} ${R(he(F[1]))} `;
567
567
  return `${Q} Z`;
568
568
  }
569
- function Yt(u) {
570
- return u.toFixed(8);
569
+ function R(i) {
570
+ return i.toFixed(8);
571
571
  }
572
572
  const Wo = {
573
573
  viewBox: "0 0 50 50",
@@ -577,10 +577,10 @@ const Wo = {
577
577
  props: {
578
578
  type: {}
579
579
  },
580
- setup(u) {
581
- return ($, d) => (b(), P("svg", Wo, [
580
+ setup(i) {
581
+ return (B, v) => (b(), P("svg", Wo, [
582
582
  fo("text", {
583
- textContent: vo(u.type),
583
+ textContent: vo(i.type),
584
584
  "dominant-baseline": "middle",
585
585
  "font-family": "sans-serif",
586
586
  "font-size": "30",
@@ -590,11 +590,11 @@ const Wo = {
590
590
  y: "27",
591
591
  stroke: "oklch(37.3% 0.034 259.733)",
592
592
  "stroke-width": "2",
593
- fill: u.type === u.type.toLowerCase() ? "oklch(13% 0.028 261.692)" : "oklch(98.5% 0.002 247.839)"
593
+ fill: i.type === i.type.toLowerCase() ? "oklch(13% 0.028 261.692)" : "oklch(98.5% 0.002 247.839)"
594
594
  }, null, 8, Ao)
595
595
  ]));
596
596
  }
597
- }), Ho = ["viewBox"], Oo = ["d", "fill"], Xo = ["d", "data-hexboard-position", "data-testid", "fill"], Yo = ["d", "data-testid", "fill"], Ko = ["d", "data-testid", "fill"], Qo = ["textContent", "data-testid", "x", "y"], Vo = ["cx", "cy", "data-testid", "fill"], Uo = ["viewBox"], Go = /* @__PURE__ */ ao({
597
+ }), Ho = ["viewBox"], Oo = ["d", "fill"], Xo = ["d", "data-hexboard-position", "fill"], Yo = ["d", "fill"], Ko = ["d", "fill"], Qo = ["textContent", "x", "y"], Vo = ["cx", "cy", "fill"], Uo = ["viewBox"], Go = /* @__PURE__ */ ao({
598
598
  __name: "Hexboard",
599
599
  props: /* @__PURE__ */ so({
600
600
  active: { type: Boolean, default: !1 },
@@ -625,179 +625,179 @@ const Wo = {
625
625
  targetsModifiers: {}
626
626
  }),
627
627
  emits: /* @__PURE__ */ so(["clickPosition", "move"], ["update:mouseover-position", "update:selected", "update:targets"]),
628
- setup(u, { emit: $ }) {
629
- const d = u, Q = $, F = Zt(u, "mouseover-position"), L = Zt(u, "selected"), X = Zt(u, "targets"), Ie = et({ x: 0, y: 0 }), B = et(null), ue = et(se()), h = et({
628
+ setup(i, { emit: B }) {
629
+ const v = i, Q = B, F = Zt(i, "mouseover-position"), C = Zt(i, "selected"), W = Zt(i, "targets"), _e = tt({ x: 0, y: 0 }), M = tt(null), ie = tt(se()), d = tt({
630
630
  hexchess: null,
631
631
  promotionEl: null,
632
632
  promotionFrom: null,
633
633
  promotionTo: null,
634
634
  selected: null
635
- }), Kt = Co("svgEl"), Y = et(se());
636
- let Qt = !1;
637
- const ho = z(() => h.value.hexchess ? [] : X.value), ce = z(() => h.value.hexchess ? h.value.hexchess : d.hexchess ? d.hexchess : co.init()), po = z(() => ce.value.board.reduce(
638
- (s, a, c) => (a && c !== B.value && s.push({ piece: a, index: c }), s),
635
+ }), Yt = Co("svgEl"), Y = tt(se());
636
+ let Kt = !1;
637
+ const ho = A(() => d.value.hexchess ? [] : W.value), ce = A(() => d.value.hexchess ? d.value.hexchess : v.hexchess ? v.hexchess : co.init()), po = A(() => ce.value.board.reduce(
638
+ (s, f, c) => (f && c !== M.value && s.push({ piece: f, index: c }), s),
639
639
  []
640
- )), lt = z(() => typeof h.value.selected == "number" ? null : L.value), jt = z(() => {
641
- var s, a, c;
640
+ )), Qt = A(() => typeof d.value.selected == "number" ? null : C.value), jt = A(() => {
641
+ var s, f, c;
642
642
  if (Vt.value)
643
643
  return "grabbing";
644
- if (!(!d.active || F.value === null || h.value.hexchess)) {
645
- if (L.value !== null && X.value.includes(F.value)) {
646
- const v = (s = ce.value) == null ? void 0 : s.board[L.value];
647
- if (v) {
648
- const g = v === v.toLowerCase() ? "b" : "w", C = ((a = ce.value) == null ? void 0 : a.turn) === g;
649
- if ((d.playing === !0 || C) && it(L.value))
644
+ if (!(!v.active || F.value === null || d.value.hexchess)) {
645
+ if (C.value !== null && W.value.includes(F.value)) {
646
+ const h = (s = ce.value) == null ? void 0 : s.board[C.value];
647
+ if (h) {
648
+ const g = h === h.toLowerCase() ? "b" : "w", E = ((f = ce.value) == null ? void 0 : f.turn) === g;
649
+ if ((v.playing === !0 || E) && ut(C.value))
650
650
  return "pointer";
651
651
  }
652
652
  }
653
653
  if (st.value)
654
- return d.playing === !0 || d.playing && Jt.value === ((c = ce.value) == null ? void 0 : c.turn) && d.playing === Jt.value ? "grab" : "pointer";
654
+ return v.playing === !0 || v.playing && It.value === ((c = ce.value) == null ? void 0 : c.turn) && v.playing === It.value ? "grab" : "pointer";
655
655
  }
656
- }), Gt = z(() => ({
657
- x: Ie.value.x - Y.value.width / 2,
658
- y: Ie.value.y - Y.value.height / 2
659
- })), Vt = z(() => !d.hexchess || h.value.hexchess || B.value === null ? null : d.hexchess.board[B.value]), K = z(() => ({ ...So, ...d.options })), Jt = z(() => st.value ? st.value === st.value.toLowerCase() ? "b" : "w" : null), st = z(() => {
656
+ }), Gt = A(() => ({
657
+ x: _e.value.x - Y.value.width / 2,
658
+ y: _e.value.y - Y.value.height / 2
659
+ })), Vt = A(() => !v.hexchess || d.value.hexchess || M.value === null ? null : v.hexchess.board[M.value]), K = A(() => ({ ...So, ...v.options })), It = A(() => st.value ? st.value === st.value.toLowerCase() ? "b" : "w" : null), st = A(() => {
660
660
  var s;
661
661
  return F.value === null ? null : ((s = ce.value) == null ? void 0 : s.board[F.value]) ?? null;
662
- }), rt = z(() => {
663
- var v;
664
- const s = (v = h.value.hexchess) == null ? void 0 : v.board[h.value.selected ?? -1], a = s === (s == null ? void 0 : s.toUpperCase()), c = (g) => (C) => To(d.pieces, { ...C, type: g });
662
+ }), rt = A(() => {
663
+ var h;
664
+ const s = (h = d.value.hexchess) == null ? void 0 : h.board[d.value.selected ?? -1], f = s === (s == null ? void 0 : s.toUpperCase()), c = (g) => (E) => To(v.pieces, { ...E, type: g });
665
665
  return {
666
- n: c(a ? "N" : "n"),
667
- b: c(a ? "B" : "b"),
668
- r: c(a ? "R" : "r"),
669
- q: c(a ? "Q" : "q")
666
+ n: c(f ? "N" : "n"),
667
+ b: c(f ? "B" : "b"),
668
+ r: c(f ? "R" : "r"),
669
+ q: c(f ? "Q" : "q")
670
670
  };
671
671
  });
672
672
  Eo(() => {
673
- d.active && It();
674
- }), $o(lo), ro(jt, (s) => {
673
+ v.active && Jt();
674
+ }), Lo(lo), ro(jt, (s) => {
675
675
  document.body.style.setProperty(
676
676
  "cursor",
677
677
  s === "grabbing" ? "grabbing" : null
678
678
  );
679
679
  }), ro(
680
- () => d.active,
681
- (s) => s ? It() : lo()
680
+ () => v.active,
681
+ (s) => s ? Jt() : lo()
682
682
  );
683
- function Ut(s, a) {
684
- var C, re;
685
- if (!X.value.includes(s.to))
683
+ function Ut(s, f) {
684
+ var E, re;
685
+ if (!W.value.includes(s.to))
686
686
  return;
687
- const c = (C = d.hexchess) == null ? void 0 : C.board[s.from];
687
+ const c = (E = v.hexchess) == null ? void 0 : E.board[s.from];
688
688
  if (!c)
689
689
  return;
690
- const v = c === c.toLowerCase() ? "b" : "w", g = ((re = d.hexchess) == null ? void 0 : re.turn) === v;
691
- if (d.hexchess && (c === "p" || c === "P") && Fo(s.to, v)) {
692
- const ae = d.hexchess.clone();
693
- ae.board[s.from] = null, ae.board[s.to] = c, h.value = {
690
+ const h = c === c.toLowerCase() ? "b" : "w", g = ((re = v.hexchess) == null ? void 0 : re.turn) === h;
691
+ if (v.hexchess && (c === "p" || c === "P") && Fo(s.to, h)) {
692
+ const ae = v.hexchess.clone();
693
+ ae.board[s.from] = null, ae.board[s.to] = c, d.value = {
694
694
  hexchess: ae,
695
- promotionEl: (a == null ? void 0 : a.target) instanceof Element ? a.target : null,
695
+ promotionEl: (f == null ? void 0 : f.target) instanceof Element ? f.target : null,
696
696
  promotionFrom: s.from,
697
697
  promotionTo: s.to,
698
698
  selected: s.to
699
- }, (a == null ? void 0 : a.target) instanceof Element && (ue.value = a.target.getBoundingClientRect());
699
+ }, (f == null ? void 0 : f.target) instanceof Element && (ie.value = f.target.getBoundingClientRect());
700
700
  return;
701
701
  }
702
- it(s.from) && (d.ignoreTurn || g) && eo(s);
702
+ ut(s.from) && (v.ignoreTurn || g) && eo(s);
703
703
  }
704
- function it(s) {
705
- var v;
706
- const a = (v = d.hexchess) == null ? void 0 : v.board[s];
707
- if (!a)
704
+ function ut(s) {
705
+ var h;
706
+ const f = (h = v.hexchess) == null ? void 0 : h.board[s];
707
+ if (!f)
708
708
  return !1;
709
- const c = a === a.toLowerCase() ? "b" : "w";
710
- return d.playing === !0 || d.playing === c;
709
+ const c = f === f.toLowerCase() ? "b" : "w";
710
+ return v.playing === !0 || v.playing === c;
711
711
  }
712
712
  function mo(s) {
713
- var a, c;
714
- return F.value === null ? K.value.labelColor : (a = W(F.value)) != null && a.startsWith(s) || (c = W(F.value)) != null && c.endsWith(s) ? K.value.labelActiveColor : K.value.labelInactiveColor;
713
+ var f, c;
714
+ return F.value === null ? K.value.labelColor : (f = fe(F.value)) != null && f.startsWith(s) || (c = fe(F.value)) != null && c.endsWith(s) ? K.value.labelActiveColor : K.value.labelInactiveColor;
715
715
  }
716
- function It() {
717
- Ie.value = { x: 0, y: 0 }, window.addEventListener("keyup", _t), window.addEventListener("pointermove", to), window.addEventListener("pointerup", no), window.addEventListener("resize", ut), window.addEventListener("scroll", ut), window.addEventListener("touchmove", oo, { passive: !1 });
716
+ function Jt() {
717
+ _e.value = { x: 0, y: 0 }, window.addEventListener("keyup", _t), window.addEventListener("pointermove", to), window.addEventListener("pointerup", no), window.addEventListener("resize", it), window.addEventListener("scroll", it), window.addEventListener("touchmove", oo, { passive: !1 });
718
718
  }
719
- function ut() {
719
+ function it() {
720
720
  var s;
721
- ue.value = ((s = h.value.promotionEl) == null ? void 0 : s.getBoundingClientRect()) ?? se();
721
+ ie.value = ((s = d.value.promotionEl) == null ? void 0 : s.getBoundingClientRect()) ?? se();
722
722
  }
723
- function go(s, a) {
724
- if (d.active) {
725
- if (Qt) {
726
- Qt = !1;
723
+ function go(s, f) {
724
+ if (v.active) {
725
+ if (Kt) {
726
+ Kt = !1;
727
727
  return;
728
728
  }
729
- if (h.value.hexchess) {
730
- h.value.selected !== s && _e();
729
+ if (d.value.hexchess) {
730
+ d.value.selected !== s && et();
731
731
  return;
732
732
  }
733
- if (L.value !== null && X.value.includes(s)) {
734
- const c = new ft({ from: L.value, to: s });
735
- Ut(c, a);
733
+ if (C.value !== null && W.value.includes(s)) {
734
+ const c = new ft({ from: C.value, to: s });
735
+ Ut(c, f);
736
736
  return;
737
737
  }
738
- d.autoselect && !d.hexchess.board[s] && (L.value = null, X.value = []), Q("clickPosition", s);
738
+ v.autoselect && !v.hexchess.board[s] && (C.value = null, W.value = []), Q("clickPosition", s);
739
739
  }
740
740
  }
741
741
  function _t(s) {
742
742
  if (s.key === "Escape") {
743
- if (h.value.hexchess) {
744
- _e();
743
+ if (d.value.hexchess) {
744
+ et();
745
745
  return;
746
746
  }
747
- d.autoselect && (L.value = null, X.value = []);
747
+ v.autoselect && (C.value = null, W.value = []);
748
748
  }
749
749
  }
750
750
  function eo(s) {
751
751
  Q("move", s), ct();
752
752
  }
753
- function wo(s, a) {
753
+ function wo(s, f) {
754
754
  var c;
755
- if (a.stopPropagation(), B.value !== null) {
756
- let v = s;
755
+ if (f.stopPropagation(), M.value !== null) {
756
+ let h = s;
757
757
  const g = document.elementFromPoint(
758
- a.clientX,
759
- a.clientY
760
- ), C = g == null ? void 0 : g.getAttribute("data-hexboard-position");
761
- C !== null && (v = Number(C));
762
- const re = new ft({ from: B.value, to: v });
763
- if (Ut(re, a), h.value.hexchess)
758
+ f.clientX,
759
+ f.clientY
760
+ ), E = g == null ? void 0 : g.getAttribute("data-hexboard-position");
761
+ E !== null && (h = Number(E));
762
+ const re = new ft({ from: M.value, to: h });
763
+ if (Ut(re, f), d.value.hexchess)
764
764
  return;
765
- B.value = null, Y.value = se();
765
+ M.value = null, Y.value = se();
766
766
  return;
767
767
  }
768
- if (L.value !== null && X.value.includes(s)) {
769
- const v = new ft({ from: L.value, to: s });
770
- return Ut(v, a), h.value.hexchess, void 0;
768
+ if (C.value !== null && W.value.includes(s)) {
769
+ const h = new ft({ from: C.value, to: s });
770
+ return Ut(h, f), d.value.hexchess, void 0;
771
771
  }
772
- if (h.value.hexchess) {
773
- _e();
772
+ if (d.value.hexchess) {
773
+ et();
774
774
  return;
775
775
  }
776
- if ((c = d.hexchess) != null && c.board[s]) {
777
- B.value = null, Y.value = se();
776
+ if ((c = v.hexchess) != null && c.board[s]) {
777
+ M.value = null, Y.value = se();
778
778
  return;
779
779
  }
780
780
  ct();
781
781
  }
782
- function _e() {
783
- const s = h.value.promotionFrom;
784
- h.value = {
782
+ function et() {
783
+ const s = d.value.promotionFrom;
784
+ d.value = {
785
785
  hexchess: null,
786
786
  promotionEl: null,
787
787
  promotionFrom: null,
788
788
  promotionTo: null,
789
789
  selected: null
790
- }, typeof s == "number" && (L.value = s, X.value = d.hexchess.movesFrom(s).map((a) => a.to) ?? []), B.value = null, Qt = !0;
790
+ }, typeof s == "number" && (C.value = s, W.value = v.hexchess.movesFrom(s).map((f) => f.to) ?? []), M.value = null, Kt = !0;
791
791
  }
792
- function yo(s, a) {
793
- var C, re, ae;
794
- if (a.preventDefault(), h.value.hexchess)
792
+ function yo(s, f) {
793
+ var E, re, ae;
794
+ if (f.preventDefault(), d.value.hexchess || C.value !== null && W.value.includes(s))
795
795
  return;
796
- const c = (C = d.hexchess) == null ? void 0 : C.board[s];
797
- if (!c || (d.autoselect && (L.value = s, X.value = ((re = d.hexchess) == null ? void 0 : re.movesFrom(s).map((Po) => Po.to)) ?? []), !it(s)))
796
+ const c = (E = v.hexchess) == null ? void 0 : E.board[s];
797
+ if (!c || (v.autoselect && (C.value = s, W.value = ((re = v.hexchess) == null ? void 0 : re.movesFrom(s).map((Po) => Po.to)) ?? []), !ut(s)))
798
798
  return;
799
- const v = c === c.toLowerCase() ? "b" : "w", g = ((ae = d.hexchess) == null ? void 0 : ae.turn) === v;
800
- !d.ignoreTurn && !g || (B.value = s, Ie.value = { x: a.clientX, y: a.clientY }, Kt.value instanceof Element && (Y.value = Kt.value.getBoundingClientRect()));
799
+ const h = c === c.toLowerCase() ? "b" : "w", g = ((ae = v.hexchess) == null ? void 0 : ae.turn) === h;
800
+ !v.ignoreTurn && !g || (M.value = s, _e.value = { x: f.clientX, y: f.clientY }, Yt.value instanceof Element && (Y.value = Yt.value.getBoundingClientRect()));
801
801
  }
802
802
  function bo(s) {
803
803
  F.value = s;
@@ -806,30 +806,30 @@ const Wo = {
806
806
  F.value = null;
807
807
  }
808
808
  function to(s) {
809
- d.active && (Ie.value = { x: s.clientX, y: s.clientY });
809
+ v.active && (_e.value = { x: s.clientX, y: s.clientY });
810
810
  }
811
811
  function oo(s) {
812
- B.value !== null && s.preventDefault();
812
+ M.value !== null && s.preventDefault();
813
813
  }
814
814
  function no() {
815
- if (h.value.hexchess) {
816
- _e();
815
+ if (d.value.hexchess) {
816
+ et();
817
817
  return;
818
818
  }
819
- if (B.value !== null) {
820
- B.value = null, Y.value = se();
819
+ if (M.value !== null) {
820
+ M.value = null, Y.value = se();
821
821
  return;
822
822
  }
823
823
  ct();
824
824
  }
825
825
  function ko(s) {
826
- if (typeof h.value.promotionFrom == "number" && it(h.value.promotionFrom)) {
827
- const a = new ft({
828
- from: h.value.promotionFrom ?? 0,
829
- to: h.value.promotionTo ?? 0,
826
+ if (typeof d.value.promotionFrom == "number" && ut(d.value.promotionFrom)) {
827
+ const f = new ft({
828
+ from: d.value.promotionFrom ?? 0,
829
+ to: d.value.promotionTo ?? 0,
830
830
  promotion: s
831
831
  });
832
- eo(a);
832
+ eo(f);
833
833
  }
834
834
  }
835
835
  function se() {
@@ -845,101 +845,94 @@ const Wo = {
845
845
  };
846
846
  }
847
847
  function ct() {
848
- document.body.style.setProperty("cursor", null), B.value = null, L.value = null, h.value = {
848
+ document.body.style.setProperty("cursor", null), M.value = null, C.value = null, d.value = {
849
849
  hexchess: null,
850
850
  promotionEl: null,
851
851
  promotionFrom: null,
852
852
  promotionTo: null,
853
853
  selected: null
854
- }, Y.value = se(), X.value = [];
854
+ }, Y.value = se(), W.value = [];
855
855
  }
856
856
  function lo() {
857
- ct(), window.removeEventListener("keyup", _t), window.removeEventListener("pointermove", to), window.removeEventListener("pointerup", no), window.removeEventListener("resize", ut), window.removeEventListener("scroll", ut), window.removeEventListener("touchmove", oo);
857
+ ct(), window.removeEventListener("keyup", _t), window.removeEventListener("pointermove", to), window.removeEventListener("pointerup", no), window.removeEventListener("resize", it), window.removeEventListener("scroll", it), window.removeEventListener("touchmove", oo);
858
858
  }
859
- return (s, a) => (b(), P("div", null, [
859
+ return (s, f) => (b(), P("div", null, [
860
860
  (b(), P("svg", {
861
861
  xmlns: "http://www.w3.org/2000/svg",
862
862
  ref_key: "svgEl",
863
- ref: Kt,
863
+ ref: Yt,
864
864
  style: at({ cursor: jt.value }),
865
- viewBox: `0 0 ${f(ve)} ${f(ve)}`
865
+ viewBox: `0 0 ${a(de)} ${a(de)}`
866
866
  }, [
867
867
  fo("path", {
868
- d: f(Xt)(f(zo)),
868
+ d: a(Xt)(a(zo)),
869
869
  fill: K.value.colors[1],
870
870
  style: { pointerEvents: "none" }
871
871
  }, null, 8, Oo),
872
- (b(!0), P(ot, null, nt(f(o), (c, v) => (b(), P("path", Lo(
872
+ (b(!0), P(nt, null, lt(a(o), (c, h) => (b(), P("path", Bo(
873
873
  { ref_for: !0 },
874
- u.active ? {
875
- onClick: (g) => go(v, g),
876
- onMouseenter: () => bo(v),
874
+ i.active ? {
875
+ onClick: (g) => go(h, g),
876
+ onMouseenter: () => bo(h),
877
877
  onMouseleave: () => xo(),
878
- onPointerdown: (g) => yo(v, g),
879
- onPointerup: (g) => wo(v, g)
878
+ onPointerdown: (g) => yo(h, g),
879
+ onPointerup: (g) => wo(h, g)
880
880
  } : {},
881
881
  {
882
- d: f(Xt)(u.flipped ? c[4] : c[3]),
883
- "data-hexboard-position": v,
884
- "data-testid": `position-${f(W)(v)}`,
885
- fill: K.value.colors[f(o)[v][0]],
886
- key: v
882
+ d: a(Xt)(i.flipped ? c[4] : c[3]),
883
+ "data-hexboard-position": h,
884
+ fill: K.value.colors[a(o)[h][0]],
885
+ key: h
887
886
  }
888
887
  ), null, 16, Xo))), 128)),
889
- (b(!0), P(ot, null, nt(u.highlight, (c) => (b(), P("path", {
890
- d: f(Xt)(u.flipped ? f(o)[c][4] : f(o)[c][3]),
891
- "data-testid": `highlight-${f(W)(c)}`,
888
+ (b(!0), P(nt, null, lt(i.highlight, (c) => (b(), P("path", {
889
+ d: a(Xt)(i.flipped ? a(o)[c][4] : a(o)[c][3]),
892
890
  fill: K.value.highlightColor,
893
891
  key: `highlight-${c}`,
894
892
  style: { pointerEvents: "none" }
895
893
  }, null, 8, Yo))), 128)),
896
- typeof lt.value == "number" ? (b(), P("path", {
894
+ typeof Qt.value == "number" ? (b(), P("path", {
897
895
  key: 0,
898
- d: f(Xt)(u.flipped ? f(o)[lt.value][4] : f(o)[lt.value][3]),
899
- "data-testid": `selected-${f(W)(lt.value)}`,
896
+ d: a(Xt)(i.flipped ? a(o)[Qt.value][4] : a(o)[Qt.value][3]),
900
897
  fill: K.value.selectedColor,
901
898
  ref: "selectedEl",
902
899
  style: { pointerEvents: "none" }
903
- }, null, 8, Ko)) : tt("", !0),
904
- K.value.labels ? (b(!0), P(ot, { key: 1 }, nt(f(No), ([c, v, g], C) => (b(), P("text", {
900
+ }, null, 8, Ko)) : ot("", !0),
901
+ K.value.labels ? (b(!0), P(nt, { key: 1 }, lt(a(No), ([c, h, g], E) => (b(), P("text", {
905
902
  textContent: vo(c),
906
903
  "dominant-baseline": "central",
907
904
  "text-anchor": "middle",
908
- "data-testid": `label-${c}`,
909
- key: `label-${C}`,
905
+ key: `label-${E}`,
910
906
  style: at({
911
907
  fill: mo(c),
912
908
  fontSize: ".5px",
913
909
  pointerEvents: "none",
914
910
  userSelect: "none"
915
911
  }),
916
- x: f(fe)(u.flipped ? g[0] : v[0]),
917
- y: f(de)(u.flipped ? g[1] : v[1])
918
- }, null, 12, Qo))), 128)) : tt("", !0),
919
- ce.value ? (b(!0), P(ot, { key: 2 }, nt(po.value, ({ piece: c, index: v }) => (b(), io(uo(u.pieces), {
912
+ x: a(R)(a(ve)(i.flipped ? g[0] : h[0])),
913
+ y: a(R)(a(he)(i.flipped ? g[1] : h[1]))
914
+ }, null, 12, Qo))), 128)) : ot("", !0),
915
+ ce.value ? (b(!0), P(nt, { key: 2 }, lt(po.value, ({ piece: c, index: h }) => (b(), uo(io(i.pieces), {
920
916
  "data-piece-type": c,
921
- "data-testid": `piece-${f(W)(v)}`,
922
- height: f(V),
923
- key: `piece-${f(W)(v)}`,
917
+ height: a(V),
918
+ key: `piece-${a(fe)(h)}`,
924
919
  style: { pointerEvents: "none" },
925
920
  type: c,
926
- width: f(V),
927
- x: f(fe)(f(o)[v][u.flipped ? 2 : 1][0] - f(V) / 2),
928
- y: f(de)(f(o)[v][u.flipped ? 2 : 1][1] + f(V) / 2)
929
- }, null, 8, ["data-piece-type", "data-testid", "height", "type", "width", "x", "y"]))), 128)) : tt("", !0),
930
- (b(!0), P(ot, null, nt(ho.value, (c) => (b(), P("circle", {
931
- cx: f(fe)(f(o)[c][u.flipped ? 2 : 1][0]),
932
- cy: f(de)(f(o)[c][u.flipped ? 2 : 1][1]),
933
- "data-testid": `target-${f(W)(c)}`,
921
+ width: a(V),
922
+ x: a(R)(a(ve)(a(o)[h][i.flipped ? 2 : 1][0] - a(V) / 2)),
923
+ y: a(R)(a(he)(a(o)[h][i.flipped ? 2 : 1][1] + a(V) / 2))
924
+ }, null, 8, ["data-piece-type", "height", "type", "width", "x", "y"]))), 128)) : ot("", !0),
925
+ (b(!0), P(nt, null, lt(ho.value, (c) => (b(), P("circle", {
926
+ cx: a(R)(a(ve)(a(o)[c][i.flipped ? 2 : 1][0])),
927
+ cy: a(R)(a(he)(a(o)[c][i.flipped ? 2 : 1][1])),
934
928
  fill: K.value.targetColor,
935
- key: `target-${f(W)(c)}`,
929
+ key: `target-${a(fe)(c)}`,
936
930
  r: 0.3,
937
931
  style: { pointerEvents: "none" }
938
932
  }, null, 8, Vo))), 128))
939
933
  ], 12, Ho)),
940
934
  Vt.value ? (b(), P("svg", {
941
935
  key: 0,
942
- "data-testid": "drag-piece",
943
936
  xmlns: "http://www.w3.org/2000/svg",
944
937
  style: at({
945
938
  height: Y.value.height + "px",
@@ -951,40 +944,40 @@ const Wo = {
951
944
  width: Y.value.width + "px",
952
945
  willChange: "transform"
953
946
  }),
954
- viewBox: `0 0 ${f(ve)} ${f(ve)}`
947
+ viewBox: `0 0 ${a(de)} ${a(de)}`
955
948
  }, [
956
- (b(), io(uo(u.pieces), {
957
- height: f(V),
949
+ (b(), uo(io(i.pieces), {
950
+ height: a(V),
958
951
  style: { pointerEvents: "none" },
959
952
  type: Vt.value,
960
- width: f(V),
961
- x: f(fe)(f(V) / -2),
962
- y: f(de)(f(V) / 2)
953
+ width: a(V),
954
+ x: a(R)(a(ve)(a(V) / -2)),
955
+ y: a(R)(a(he)(a(V) / 2))
963
956
  }, null, 8, ["height", "type", "width", "x", "y"]))
964
- ], 12, Uo)) : tt("", !0),
965
- typeof h.value.selected == "number" ? (b(), P("div", {
957
+ ], 12, Uo)) : ot("", !0),
958
+ typeof d.value.selected == "number" ? (b(), P("div", {
966
959
  key: 1,
967
960
  style: at({
968
- height: ue.value.height + "px",
969
- left: ue.value.left + "px",
961
+ height: ie.value.height + "px",
962
+ left: ie.value.left + "px",
970
963
  position: "fixed",
971
- top: ue.value.top + "px",
972
- width: ue.value.width + "px"
964
+ top: ie.value.top + "px",
965
+ width: ie.value.width + "px"
973
966
  }),
974
- onPointerup: a[0] || (a[0] = Bo(() => {
967
+ onPointerup: f[0] || (f[0] = Mo(() => {
975
968
  }, ["stop"]))
976
969
  }, [
977
- Mo(s.$slots, "promotion", {
970
+ $o(s.$slots, "promotion", {
978
971
  b: rt.value.b,
979
- cancel: _e,
980
- file: f(W)(h.value.selected)[0],
972
+ cancel: et,
973
+ file: a(fe)(d.value.selected)[0],
981
974
  n: rt.value.n,
982
975
  promote: ko,
983
976
  q: rt.value.q,
984
977
  r: rt.value.r,
985
- rank: Number(f(W)(h.value.selected).slice(1))
978
+ rank: Number(a(fe)(d.value.selected).slice(1))
986
979
  })
987
- ], 36)) : tt("", !0)
980
+ ], 36)) : ot("", !0)
988
981
  ]));
989
982
  }
990
983
  });
package/package.json CHANGED
@@ -58,5 +58,5 @@
58
58
  "license": "MIT",
59
59
  "type": "module",
60
60
  "types": "dist/index.d.ts",
61
- "version": "0.0.7"
61
+ "version": "0.0.9"
62
62
  }
@@ -69,8 +69,8 @@
69
69
  pointerEvents: 'none',
70
70
  userSelect: 'none',
71
71
  }"
72
- :x="x(flipped ? positionFlipped[0] : p[0])"
73
- :y="y(flipped ? positionFlipped[1] : p[1])"
72
+ :x="rounded(x(flipped ? positionFlipped[0] : p[0]))"
73
+ :y="rounded(y(flipped ? positionFlipped[1] : p[1]))"
74
74
  />
75
75
  </template>
76
76
 
@@ -86,16 +86,16 @@
86
86
  :style="{ pointerEvents: 'none' }"
87
87
  :type="piece"
88
88
  :width="pieceSize"
89
- :x="x(board[index][flipped ? 2 : 1][0] - pieceSize / 2)"
90
- :y="y(board[index][flipped ? 2 : 1][1] + pieceSize / 2)"
89
+ :x="rounded(x(board[index][flipped ? 2 : 1][0] - pieceSize / 2))"
90
+ :y="rounded(y(board[index][flipped ? 2 : 1][1] + pieceSize / 2))"
91
91
  />
92
92
  </template>
93
93
 
94
94
  <!-- targets -->
95
95
  <circle
96
96
  v-for="targetIndex in currentTargets"
97
- :cx="x(board[targetIndex][flipped ? 2 : 1][0])"
98
- :cy="y(board[targetIndex][flipped ? 2 : 1][1])"
97
+ :cx="rounded(x(board[targetIndex][flipped ? 2 : 1][0]))"
98
+ :cy="rounded(y(board[targetIndex][flipped ? 2 : 1][1]))"
99
99
  :data-testid="`target-${indexToPosition(targetIndex)}`"
100
100
  :fill="normalizedOptions.targetColor"
101
101
  :key="`target-${indexToPosition(targetIndex)}`"
@@ -127,8 +127,8 @@
127
127
  :style="{ pointerEvents: 'none' }"
128
128
  :type="dragPiece"
129
129
  :width="pieceSize"
130
- :x="x(pieceSize / -2)"
131
- :y="y(pieceSize / 2)"
130
+ :x="rounded(x(pieceSize / -2))"
131
+ :y="rounded(y(pieceSize / 2))"
132
132
  />
133
133
  </svg>
134
134
 
@@ -188,7 +188,7 @@ import {
188
188
  perimeter,
189
189
  pieceSize,
190
190
  } from './constants'
191
- import { d } from './dom'
191
+ import { d, rounded } from './dom'
192
192
  import { x, y } from './geometry'
193
193
  import LetterPiece from './pieces/Letter.vue'
194
194
  import type { HexboardOptions, Rect } from './types'
@@ -738,6 +738,12 @@ function onPointerdownPosition(index: number, evt: PointerEvent) {
738
738
  return
739
739
  }
740
740
 
741
+ // If clicking on a valid target for the selected piece, don't re-select
742
+ // (the move will be handled in onPointerupPosition/onClickPosition)
743
+ if (selected.value !== null && targets.value.includes(index)) {
744
+ return
745
+ }
746
+
741
747
  const piece = props.hexchess?.board[index]
742
748
 
743
749
  if (!piece) {
@@ -3,7 +3,7 @@ import { expect, test, vi } from 'vitest'
3
3
  import { Hexboard } from '../lib'
4
4
  import { Hexchess } from '@bedard/hexchess'
5
5
  import { index, San } from '@bedard/hexchess'
6
- import { makeMove, setup } from './utils'
6
+ import { dragMove, clickMove, setup } from './utils'
7
7
  import { page } from 'vitest/browser'
8
8
  import { ref, nextTick } from 'vue'
9
9
  import { userEvent } from 'vitest/browser'
@@ -520,23 +520,7 @@ test('drag and drop piece emits move event', async () => {
520
520
  )
521
521
  })
522
522
 
523
- const fromPosition = page.getByTestId('position-f5')
524
- const toPosition = page.getByTestId('position-f6')
525
-
526
- // Start dragging the piece (pointerdown)
527
- await fromPosition
528
- .element()
529
- .dispatchEvent(new PointerEvent('pointerdown', { bubbles: true }))
530
- await nextTick()
531
-
532
- // Verify dragging started
533
- await expect.element(page.getByTestId('drag-piece')).toBeVisible()
534
-
535
- // Move pointer to target position and release (pointerup)
536
- await toPosition
537
- .element()
538
- .dispatchEvent(new PointerEvent('pointerup', { bubbles: true }))
539
- await nextTick()
523
+ await dragMove(page, 'f5f6')
540
524
 
541
525
  // Verify move event was emitted with correct San object
542
526
  await expect(onMove).toHaveBeenCalledOnce()
@@ -644,7 +628,7 @@ test('promotion', async () => {
644
628
  )
645
629
  })
646
630
 
647
- await makeMove(page, 'f10f11')
631
+ await clickMove(page, 'f10f11')
648
632
  await page.getByTestId('promote').click()
649
633
  await expect(page.getByTestId('piece-f11')).toHaveAttribute(
650
634
  'data-piece-type',
@@ -682,7 +666,7 @@ test('canceled promotion', async () => {
682
666
  })
683
667
 
684
668
  // Move pawn to promotion square
685
- await makeMove(page, 'f10f11')
669
+ await clickMove(page, 'f10f11')
686
670
 
687
671
  // Promotion UI should be visible
688
672
  await expect.element(page.getByTestId('cancel')).toBeVisible()
@@ -730,7 +714,7 @@ test('clicking position during promotion cancels it', async () => {
730
714
  })
731
715
 
732
716
  // Move pawn to promotion square
733
- await makeMove(page, 'f10f11')
717
+ await clickMove(page, 'f10f11')
734
718
 
735
719
  // Promotion UI should be visible
736
720
  await expect.element(page.getByTestId('promote')).toBeVisible()
@@ -771,14 +755,14 @@ test('ignoreTurn allows moving pieces out of turn', async () => {
771
755
  })
772
756
 
773
757
  // Initial position is white's turn, try to move black's pawn without ignoreTurn
774
- await makeMove(page, 'f7f6')
758
+ await clickMove(page, 'f7f6')
775
759
  await expect(onMove).not.toHaveBeenCalled()
776
760
 
777
761
  // Enable ignoreTurn and try again
778
762
  ignoreTurn.value = true
779
763
  await nextTick()
780
764
 
781
- await makeMove(page, 'f7f6')
765
+ await clickMove(page, 'f7f6')
782
766
  await expect(onMove).toHaveBeenCalledOnce()
783
767
  await expect(onMove).toHaveBeenCalledWith(
784
768
  expect.objectContaining({
@@ -791,6 +775,7 @@ test('ignoreTurn allows moving pieces out of turn', async () => {
791
775
  test('dragging piece to non-target position keeps selection', async () => {
792
776
  const selected = ref<number | null>(null)
793
777
  const targets = ref<number[]>([])
778
+ const onMove = vi.fn()
794
779
 
795
780
  setup(() => {
796
781
  return () => (
@@ -801,32 +786,63 @@ test('dragging piece to non-target position keeps selection', async () => {
801
786
  playing="w"
802
787
  v-model:selected={selected.value}
803
788
  v-model:targets={targets.value}
789
+ onMove={onMove}
804
790
  />
805
791
  <div data-testid="selected-value" v-text={selected.value} />
806
792
  </>
807
793
  )
808
794
  })
809
795
 
810
- const piecePosition = page.getByTestId('position-f5')
811
- const nonTargetPosition = page.getByTestId('position-a1')
812
-
813
- // Start dragging the piece
814
- await piecePosition
815
- .element()
816
- .dispatchEvent(new PointerEvent('pointerdown', { bubbles: true }))
817
- await nextTick()
796
+ await dragMove(page, 'f5a1')
818
797
 
819
- // Verify piece is selected
798
+ // Piece should still be selected
820
799
  await expect.element(page.getByTestId('selected-f5')).toBeVisible()
821
800
  await expect(selected.value).toBe(index('f5'))
822
801
 
823
- // Release on a non-target position
824
- await nonTargetPosition
825
- .element()
826
- .dispatchEvent(new PointerEvent('pointerup', { bubbles: true }))
827
- await nextTick()
802
+ // No move should have been emitted
803
+ await expect(onMove).not.toHaveBeenCalled()
804
+ })
828
805
 
829
- // Piece should still be selected
830
- await expect.element(page.getByTestId('selected-f5')).toBeVisible()
831
- await expect(selected.value).toBe(index('f5'))
806
+ test('click capture', async () => {
807
+ const hexchess = ref(
808
+ Hexchess.parse('b/qbk/n1b1n/r5r/ppp1ppppp/11/4pP5/4P1P4/3P1B1P3/2P2B2P2/1PRNQBKNRP1 w e6 0 2'),
809
+ )
810
+
811
+ setup(() => {
812
+ return () => (
813
+ <Hexboard
814
+ active
815
+ autoselect
816
+ playing={true}
817
+ hexchess={hexchess.value}
818
+ onMove={san => hexchess.value.applyMoveUnsafe(san)}
819
+ />
820
+ )
821
+ })
822
+
823
+ await clickMove(page, 'f5e5')
824
+
825
+ await expect(hexchess.value.toString()).toBe('b/qbk/n1b1n/r5r/ppp1ppppp/11/4P6/4P1P4/3P1B1P3/2P2B2P2/1PRNQBKNRP1 b - 0 2')
826
+ })
827
+
828
+ test('drag capture', async () => {
829
+ const hexchess = ref(
830
+ Hexchess.parse('b/qbk/n1b1n/r5r/ppp1ppppp/11/4pP5/4P1P4/3P1B1P3/2P2B2P2/1PRNQBKNRP1 w e6 0 2'),
831
+ )
832
+
833
+ setup(() => {
834
+ return () => (
835
+ <Hexboard
836
+ active
837
+ autoselect
838
+ playing={true}
839
+ hexchess={hexchess.value}
840
+ onMove={san => hexchess.value.applyMoveUnsafe(san)}
841
+ />
842
+ )
843
+ })
844
+
845
+ await dragMove(page, 'f5e5')
846
+
847
+ await expect(hexchess.value.toString()).toBe('b/qbk/n1b1n/r5r/ppp1ppppp/11/4P6/4P1P4/3P1B1P3/2P2B2P2/1PRNQBKNRP1 b - 0 2')
832
848
  })
@@ -1,11 +1,12 @@
1
1
  import { position } from '@bedard/hexchess'
2
2
  import { San } from '@bedard/hexchess'
3
+ import { expect } from 'vitest'
3
4
  import type { BrowserPage } from 'vitest/browser'
4
5
  import { render } from 'vitest-browser-vue'
5
6
  import { nextTick } from 'vue'
6
7
 
7
- /** make a move on the hexboard */
8
- export async function makeMove(
8
+ /** make a move on the hexboard by clicking */
9
+ export async function clickMove(
9
10
  page: BrowserPage,
10
11
  ...sans: string[]
11
12
  ): Promise<void> {
@@ -20,6 +21,31 @@ export async function makeMove(
20
21
  }
21
22
  }
22
23
 
24
+ /** drag and drop a piece on the hexboard */
25
+ export async function dragMove(
26
+ page: BrowserPage,
27
+ ...sans: string[]
28
+ ): Promise<void> {
29
+ for (const str of sans) {
30
+ const san = San.from(str)
31
+
32
+ const fromPosition = page.getByTestId(`position-${position(san.from)}`)
33
+ const toPosition = page.getByTestId(`position-${position(san.to)}`)
34
+
35
+ await fromPosition
36
+ .element()
37
+ .dispatchEvent(new PointerEvent('pointerdown', { bubbles: true }))
38
+ await nextTick()
39
+
40
+ await expect.element(page.getByTestId('drag-piece')).toBeVisible()
41
+
42
+ await toPosition
43
+ .element()
44
+ .dispatchEvent(new PointerEvent('pointerup', { bubbles: true }))
45
+ await nextTick()
46
+ }
47
+ }
48
+
23
49
  /** setup a component */
24
50
  export function setup(setup: () => any): ReturnType<typeof render> {
25
51
  return render({ setup })
package/vite.config.ts CHANGED
@@ -27,7 +27,24 @@ export default defineConfig({
27
27
  rollupTypes: true,
28
28
  }),
29
29
  tailwindcss(),
30
- vue(),
30
+ vue({
31
+ template: {
32
+ compilerOptions: {
33
+ nodeTransforms: [
34
+ (node) => {
35
+ // remove data-testid attributes from production build
36
+ if (node.type === 1 && node.props) {
37
+ node.props = node.props
38
+ .filter(prop =>
39
+ !(prop.type === 6 && prop.name === 'data-testid')
40
+ && !(prop.type === 7 && prop.name === 'bind' && prop.arg?.type === 4 && prop.arg.content === 'data-testid'),
41
+ )
42
+ }
43
+ },
44
+ ],
45
+ },
46
+ },
47
+ }),
31
48
  ],
32
49
  resolve: {
33
50
  alias: {