@bedard/hexboard 0.0.9 → 0.0.10

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,7 @@
1
+ # 0.0.10
2
+
3
+ - Fix autoselect not updating targets (https://github.com/scottbedard/hexboard/issues/3)
4
+
1
5
  # 0.0.9
2
6
 
3
7
  - Fix click-move capturing (https://github.com/scottbedard/hexboard/issues/1)
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
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";
1
+ import { defineComponent as fo, createElementBlock as C, openBlock as x, createElementVNode as vo, toDisplayString as ho, mergeModels as uo, useModel as Zt, shallowRef as et, useTemplateRef as Co, computed as W, onBeforeMount as Eo, onMounted as Lo, onUnmounted as Bo, watch as jt, createCommentVNode as tt, unref as a, normalizeStyle as ct, Fragment as ot, renderList as nt, mergeProps as Mo, createBlock as io, resolveDynamicComponent as co, withModifiers as $o, renderSlot as To, h as Fo } from "vue";
2
+ import { Hexchess as ao, position as ae, San as at, isPromotionPosition as Ro } from "@bedard/hexchess";
3
3
  function r(i, B, v) {
4
4
  return [i[0] + v * (B[0] - i[0]), i[1] + v * (B[1] - i[1])];
5
5
  }
@@ -8,22 +8,22 @@ function n(i) {
8
8
  }
9
9
  function e(i) {
10
10
  return [
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)
11
+ k(i, -300, ue),
12
+ k(i, 0, ue),
13
+ k(i, -60, ue),
14
+ k(i, -120, ue),
15
+ k(i, -180, ue),
16
+ k(i, -240, ue)
17
17
  ];
18
18
  }
19
- function x(i, B, v) {
20
- const Q = Ro(B);
19
+ function k(i, B, v) {
20
+ const Q = So(B);
21
21
  return [
22
22
  v * Math.cos(Q) + i[0],
23
23
  v * Math.sin(Q) + i[1]
24
24
  ];
25
25
  }
26
- function Ro(i) {
26
+ function So(i) {
27
27
  return i * (Math.PI / 180);
28
28
  }
29
29
  function t(i) {
@@ -32,13 +32,13 @@ function t(i) {
32
32
  function l(i, B) {
33
33
  return [i[0] + B[0], i[1] + B[1]];
34
34
  }
35
- function ve(i) {
35
+ function fe(i) {
36
36
  return de / 2 + i;
37
37
  }
38
- function he(i) {
38
+ function ve(i) {
39
39
  return de / 2 - i;
40
40
  }
41
- const de = 23.6, So = {
41
+ const de = 23.6, qo = {
42
42
  colors: [
43
43
  "oklch(0.9015 0.0729 70.7)",
44
44
  "oklch(0.8366 0.1165 66.29)",
@@ -57,133 +57,133 @@ const de = 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", 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 = [
60
+ }, No = "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, y = p * 2, w = p * 3, P = p * 4, L = p * 5, m = [0, 0], A = k(m, 150, L), S = k(m, 150, P), D = k(m, 150, w), q = k(m, 150, y), $ = k(m, 150, p), T = k(m, 30, p), N = k(m, 30, y), H = k(m, 30, w), z = k(m, 30, P), O = k(m, 30, L), U = l(A, [0, -L]), Z = l(S, [0, -L]), he = l(D, [0, -L]), pe = l(q, [0, -L]), me = l($, [0, -L]), ge = l(m, [0, -L]), ye = l(T, [0, -L]), we = l(N, [0, -L]), be = l(H, [0, -L]), j = l(z, [0, -L]), G = l(O, [0, -L]), I = l(A, [0, -P]), J = l(S, [0, -P]), xe = l(D, [0, -P]), ke = l(q, [0, -P]), Pe = l($, [0, -P]), Ce = l(m, [0, -P]), Ee = l(T, [0, -P]), Le = l(N, [0, -P]), Be = l(H, [0, -P]), _ = l(z, [0, -P]), ee = l(O, [0, -P]), Me = l(A, [0, -w]), $e = l(S, [0, -w]), ft = l(D, [0, -w]), vt = l(q, [0, -w]), dt = l($, [0, -w]), ht = l(m, [0, -w]), pt = l(T, [0, -w]), mt = l(N, [0, -w]), gt = l(H, [0, -w]), Te = l(z, [0, -w]), Fe = l(O, [0, -w]), Re = l(A, [0, -y]), Se = l(S, [0, -y]), yt = l(D, [0, -y]), wt = l(q, [0, -y]), bt = l($, [0, -y]), xt = l(m, [0, -y]), kt = l(T, [0, -y]), Pt = l(N, [0, -y]), Ct = l(H, [0, -y]), qe = l(z, [0, -y]), Ne = l(O, [0, -y]), ze = l(A, [0, -p]), We = l(S, [0, -p]), Et = l(D, [0, -p]), Lt = l(q, [0, -p]), Bt = l($, [0, -p]), Mt = l(m, [0, -p]), $t = l(T, [0, -p]), Tt = l(N, [0, -p]), Ft = l(H, [0, -p]), Ae = l(z, [0, -p]), De = l(O, [0, -p]), He = l(S, [0, p]), Oe = l(D, [0, p]), Rt = l(q, [0, p]), St = l($, [0, p]), qt = l(m, [0, p]), Nt = l(T, [0, p]), zt = l(N, [0, p]), Xe = l(H, [0, p]), Ye = l(z, [0, p]), Ke = l(D, [0, y]), Qe = l(q, [0, y]), Wt = l($, [0, y]), At = l(m, [0, y]), Dt = l(T, [0, y]), Ve = l(N, [0, y]), Ue = l(H, [0, y]), Ze = l(q, [0, w]), je = l($, [0, w]), Ht = l(m, [0, w]), Ge = l(T, [0, w]), Ie = l(N, [0, w]), te = l($, [0, P]), oe = l(m, [0, P]), ne = l(T, [0, P]), 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, je, t(je), e(je), n(e(je))],
65
+ [0, Ze, t(Ze), e(Ze), n(e(Ze))],
66
+ [2, je, t(je), e(je), n(e(je))],
67
+ [1, Ht, t(Ht), e(Ht), n(e(Ht))],
66
68
  [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
- [0, Je, t(Je), e(Je), n(e(Je))],
70
- [2, Qe, t(Qe), e(Qe), n(e(Qe))],
69
+ [0, Ie, t(Ie), e(Ie), n(e(Ie))],
70
+ [2, Ke, t(Ke), e(Ke), n(e(Ke))],
71
+ [1, Qe, t(Qe), e(Qe), n(e(Qe))],
72
+ [0, Wt, t(Wt), e(Wt), n(e(Wt))],
73
+ [2, At, t(At), e(At), n(e(At))],
74
+ [0, Dt, t(Dt), e(Dt), n(e(Dt))],
71
75
  [1, Ve, t(Ve), e(Ve), n(e(Ve))],
72
- [0, At, t(At), e(At), n(e(At))],
73
- [2, Dt, t(Dt), e(Dt), n(e(Dt))],
74
- [0, Ht, t(Ht), e(Ht), n(e(Ht))],
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))],
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))],
79
+ [2, Rt, t(Rt), e(Rt), n(e(Rt))],
80
+ [1, St, t(St), e(St), n(e(St))],
81
+ [0, qt, t(qt), e(qt), n(e(qt))],
82
+ [1, Nt, t(Nt), e(Nt), n(e(Nt))],
83
+ [2, zt, t(zt), e(zt), n(e(zt))],
78
84
  [0, Xe, t(Xe), e(Xe), n(e(Xe))],
79
- [2, St, t(St), e(St), n(e(St))],
80
- [1, qt, t(qt), e(qt), n(e(qt))],
81
- [0, Nt, t(Nt), e(Nt), n(e(Nt))],
82
- [1, zt, t(zt), e(zt), n(e(zt))],
83
- [2, Wt, t(Wt), e(Wt), n(e(Wt))],
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))],
85
+ [1, Ye, t(Ye), e(Ye), n(e(Ye))],
86
+ [0, A, t(A), e(A), n(e(A))],
87
87
  [2, S, t(S), e(S), n(e(S))],
88
- [1, H, t(H), e(H), n(e(H))],
88
+ [1, D, t(D), e(D), n(e(D))],
89
89
  [0, q, t(q), e(q), n(e(q))],
90
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
93
  [0, N, t(N), e(N), n(e(N))],
94
- [1, O, t(O), e(O), n(e(O))],
94
+ [1, H, t(H), e(H), n(e(H))],
95
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))],
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))],
99
+ [2, Et, t(Et), e(Et), n(e(Et))],
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
+ [0, $t, t($t), e($t), n(e($t))],
104
+ [1, Tt, t(Tt), e(Tt), n(e(Tt))],
105
+ [2, Ft, t(Ft), e(Ft), n(e(Ft))],
98
106
  [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))],
102
- [2, $t, t($t), e($t), n(e($t))],
103
- [0, Tt, t(Tt), e(Tt), n(e(Tt))],
104
- [1, Ft, t(Ft), e(Ft), n(e(Ft))],
105
- [2, Rt, t(Rt), e(Rt), n(e(Rt))],
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))],
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))],
110
110
  [0, yt, t(yt), e(yt), n(e(yt))],
111
- [2, bt, t(bt), e(bt), n(e(bt))],
112
- [1, xt, t(xt), e(xt), n(e(xt))],
113
- [0, kt, t(kt), e(kt), n(e(kt))],
114
- [1, Pt, t(Pt), e(Pt), n(e(Pt))],
115
- [2, Ct, t(Ct), e(Ct), n(e(Ct))],
116
- [0, Et, t(Et), e(Et), n(e(Et))],
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))],
111
+ [2, wt, t(wt), e(wt), n(e(wt))],
112
+ [1, bt, t(bt), e(bt), n(e(bt))],
113
+ [0, xt, t(xt), e(xt), n(e(xt))],
114
+ [1, kt, t(kt), e(kt), n(e(kt))],
115
+ [2, Pt, t(Pt), e(Pt), n(e(Pt))],
116
+ [0, Ct, t(Ct), e(Ct), n(e(Ct))],
117
+ [1, qe, t(qe), e(qe), n(e(qe))],
118
+ [2, Ne, t(Ne), e(Ne), n(e(Ne))],
119
+ [0, Me, t(Me), e(Me), n(e(Me))],
120
+ [2, $e, t($e), e($e), n(e($e))],
121
+ [1, ft, t(ft), e(ft), n(e(ft))],
122
+ [0, vt, t(vt), e(vt), n(e(vt))],
123
123
  [2, dt, t(dt), e(dt), n(e(dt))],
124
- [1, pt, t(pt), e(pt), n(e(pt))],
125
- [2, mt, t(mt), e(mt), n(e(mt))],
126
- [0, gt, t(gt), e(gt), n(e(gt))],
127
- [1, wt, t(wt), e(wt), n(e(wt))],
128
- [2, Fe, t(Fe), e(Fe), n(e(Fe))],
129
- [0, Re, t(Re), e(Re), n(e(Re))],
124
+ [1, ht, t(ht), e(ht), n(e(ht))],
125
+ [2, pt, t(pt), e(pt), n(e(pt))],
126
+ [0, mt, t(mt), e(mt), n(e(mt))],
127
+ [1, gt, t(gt), e(gt), n(e(gt))],
128
+ [2, Te, t(Te), e(Te), n(e(Te))],
129
+ [0, Fe, t(Fe), e(Fe), n(e(Fe))],
130
130
  [1, I, t(I), e(I), n(e(I))],
131
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))],
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, Le, t(Le), e(Le), n(e(Le))],
138
+ [2, Be, t(Be), e(Be), n(e(Be))],
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, 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))],
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
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))],
148
+ [2, we, t(we), e(we), n(e(we))],
149
+ [0, be, t(be), e(be), n(e(be))],
150
150
  [1, j, t(j), e(j), n(e(j))],
151
151
  [2, G, t(G), e(G), n(e(G))]
152
- ], No = [
152
+ ], zo = [
153
153
  ["11", r(ne, le, u), t(r(ne, le, u))],
154
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))],
155
+ ["9", r(je, Ze, u), t(r(je, Ze, u))],
156
+ ["8", r(Qe, Ke, u), t(r(Qe, Ke, u))],
157
+ ["7", r(Oe, He, u), t(r(Oe, He, u))],
158
+ ["6", r(S, A, u), t(r(S, A, u))],
159
+ ["5", r(We, ze, u), t(r(We, ze, u))],
160
+ ["4", r(Se, Re, u), t(r(Se, Re, u))],
161
+ ["3", r($e, Me, u), t(r($e, Me, u))],
162
162
  ["2", r(J, I, u), t(r(J, I, u))],
163
163
  ["1", r(Z, U, u), t(r(Z, U, u))],
164
164
  ["a", r(I, U, u), t(r(I, U, u))],
165
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))],
166
+ ["c", r(xe, he, u), t(r(xe, he, u))],
167
+ ["d", r(ke, pe, u), t(r(ke, pe, u))],
168
+ ["e", r(Pe, me, u), t(r(Pe, me, u))],
169
+ ["f", r(Ce, ge, u), t(r(Ce, ge, u))],
170
+ ["g", r(Ee, ye, u), t(r(Ee, ye, u))],
171
+ ["h", r(Le, we, u), t(r(Le, we, u))],
172
+ ["i", r(Be, be, u), t(r(Be, be, u))],
173
173
  ["k", r(_, j, u), t(r(_, j, u))],
174
174
  ["l", r(ee, G, u), t(r(ee, G, u))],
175
175
  ["1", r(j, G, u), t(r(j, G, u))],
176
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))],
177
+ ["3", r(Te, Fe, u), t(r(Te, Fe, u))],
178
+ ["4", r(qe, Ne, u), t(r(qe, Ne, u))],
179
+ ["5", r(Ae, De, u), t(r(Ae, De, u))],
180
+ ["6", r(z, O, u), t(r(z, O, u))],
181
+ ["7", r(Xe, Ye, u), t(r(Xe, Ye, u))],
182
+ ["8", r(Ve, Ue, u), t(r(Ve, Ue, u))],
183
+ ["9", r(Ge, Ie, u), t(r(Ge, Ie, u))],
184
184
  ["10", r(oe, ne, u), t(r(oe, ne, u))],
185
185
  ["11", r(te, le, u), t(r(te, le, u))]
186
- ], zo = [
186
+ ], Wo = [
187
187
  o[
188
188
  0
189
189
  /* f11 */
@@ -557,30 +557,30 @@ const de = 23.6, So = {
557
557
  /* e10 */
558
558
  ][3][0]
559
559
  ];
560
- function Xt(i) {
560
+ function Ot(i) {
561
561
  if (i.length === 0)
562
562
  return "";
563
563
  const [B, ...v] = i;
564
- let Q = `M ${R(ve(B[0]))} ${R(he(B[1]))} L `;
564
+ let Q = `M ${R(fe(B[0]))} ${R(ve(B[1]))} L `;
565
565
  for (const F of v)
566
- Q += `${R(ve(F[0]))} ${R(he(F[1]))} `;
566
+ Q += `${R(fe(F[0]))} ${R(ve(F[1]))} `;
567
567
  return `${Q} Z`;
568
568
  }
569
569
  function R(i) {
570
570
  return i.toFixed(8);
571
571
  }
572
- const Wo = {
572
+ const Ao = {
573
573
  viewBox: "0 0 50 50",
574
574
  xmlns: "http://www.w3.org/2000/svg"
575
- }, Ao = ["textContent", "fill"], Do = /* @__PURE__ */ ao({
575
+ }, Do = ["textContent", "fill"], Ho = /* @__PURE__ */ fo({
576
576
  __name: "Letter",
577
577
  props: {
578
578
  type: {}
579
579
  },
580
580
  setup(i) {
581
- return (B, v) => (b(), P("svg", Wo, [
582
- fo("text", {
583
- textContent: vo(i.type),
581
+ return (B, v) => (x(), C("svg", Ao, [
582
+ vo("text", {
583
+ textContent: ho(i.type),
584
584
  "dominant-baseline": "middle",
585
585
  "font-family": "sans-serif",
586
586
  "font-size": "30",
@@ -591,22 +591,22 @@ const Wo = {
591
591
  stroke: "oklch(37.3% 0.034 259.733)",
592
592
  "stroke-width": "2",
593
593
  fill: i.type === i.type.toLowerCase() ? "oklch(13% 0.028 261.692)" : "oklch(98.5% 0.002 247.839)"
594
- }, null, 8, Ao)
594
+ }, null, 8, Do)
595
595
  ]));
596
596
  }
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({
597
+ }), Oo = ["viewBox"], Xo = ["d", "fill"], Yo = ["d", "data-hexboard-position", "fill"], Ko = ["d", "fill"], Qo = ["d", "fill"], Vo = ["textContent", "x", "y"], Uo = ["cx", "cy", "fill"], Zo = ["viewBox"], Io = /* @__PURE__ */ fo({
598
598
  __name: "Hexboard",
599
- props: /* @__PURE__ */ so({
599
+ props: /* @__PURE__ */ uo({
600
600
  active: { type: Boolean, default: !1 },
601
601
  autoselect: { type: Boolean, default: !1 },
602
602
  flipped: { type: Boolean, default: !1 },
603
- hexchess: { default: () => co.init() },
603
+ hexchess: { default: () => ao.init() },
604
604
  highlight: { default: () => [] },
605
605
  ignoreTurn: { type: Boolean, default: !1 },
606
606
  options: { default: () => ({}) },
607
- pieces: { default: () => Do },
607
+ pieces: { default: () => Ho },
608
608
  playing: { type: [String, Boolean], default: !1 },
609
- position: { default: qo }
609
+ position: { default: No }
610
610
  }, {
611
611
  "mouseover-position": {
612
612
  default: null,
@@ -624,44 +624,44 @@ const Wo = {
624
624
  },
625
625
  targetsModifiers: {}
626
626
  }),
627
- emits: /* @__PURE__ */ so(["clickPosition", "move"], ["update:mouseover-position", "update:selected", "update:targets"]),
627
+ emits: /* @__PURE__ */ uo(["clickPosition", "move"], ["update:mouseover-position", "update:selected", "update:targets"]),
628
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({
629
+ const v = i, Q = B, F = Zt(i, "mouseover-position"), b = Zt(i, "selected"), X = Zt(i, "targets"), Je = et({ x: 0, y: 0 }), M = et(null), ie = et(se()), h = et({
630
630
  hexchess: null,
631
631
  promotionEl: null,
632
632
  promotionFrom: null,
633
633
  promotionTo: null,
634
634
  selected: null
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(
635
+ }), Xt = Co("svgEl"), Y = et(se());
636
+ let Yt = !1;
637
+ const po = W(() => h.value.hexchess ? [] : X.value), ce = W(() => h.value.hexchess ? h.value.hexchess : v.hexchess ? v.hexchess : ao.init()), mo = W(() => ce.value.board.reduce(
638
638
  (s, f, c) => (f && c !== M.value && s.push({ piece: f, index: c }), s),
639
639
  []
640
- )), Qt = A(() => typeof d.value.selected == "number" ? null : C.value), jt = A(() => {
640
+ )), Kt = W(() => typeof h.value.selected == "number" ? null : b.value), Gt = W(() => {
641
641
  var s, f, c;
642
- if (Vt.value)
642
+ if (Qt.value)
643
643
  return "grabbing";
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))
644
+ if (!(!v.active || F.value === null || h.value.hexchess)) {
645
+ if (b.value !== null && X.value.includes(F.value)) {
646
+ const d = (s = ce.value) == null ? void 0 : s.board[b.value];
647
+ if (d) {
648
+ const g = d === d.toLowerCase() ? "b" : "w", E = ((f = ce.value) == null ? void 0 : f.turn) === g;
649
+ if ((v.playing === !0 || E) && rt(b.value))
650
650
  return "pointer";
651
651
  }
652
652
  }
653
- if (st.value)
654
- return v.playing === !0 || v.playing && It.value === ((c = ce.value) == null ? void 0 : c.turn) && v.playing === It.value ? "grab" : "pointer";
653
+ if (lt.value)
654
+ return v.playing === !0 || v.playing && Jt.value === ((c = ce.value) == null ? void 0 : c.turn) && v.playing === Jt.value ? "grab" : "pointer";
655
655
  }
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(() => {
656
+ }), It = W(() => ({
657
+ x: Je.value.x - Y.value.width / 2,
658
+ y: Je.value.y - Y.value.height / 2
659
+ })), Qt = W(() => !v.hexchess || h.value.hexchess || M.value === null ? null : v.hexchess.board[M.value]), K = W(() => ({ ...qo, ...v.options })), Jt = W(() => lt.value ? lt.value === lt.value.toLowerCase() ? "b" : "w" : null), lt = W(() => {
660
660
  var s;
661
661
  return F.value === null ? null : ((s = ce.value) == null ? void 0 : s.board[F.value]) ?? null;
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 });
662
+ }), st = W(() => {
663
+ var d;
664
+ const s = (d = h.value.hexchess) == null ? void 0 : d.board[h.value.selected ?? -1], f = s === (s == null ? void 0 : s.toUpperCase()), c = (g) => (E) => Fo(v.pieces, { ...E, type: g });
665
665
  return {
666
666
  n: c(f ? "N" : "n"),
667
667
  b: c(f ? "B" : "b"),
@@ -670,28 +670,30 @@ const Wo = {
670
670
  };
671
671
  });
672
672
  Eo(() => {
673
- v.active && Jt();
674
- }), Lo(lo), ro(jt, (s) => {
673
+ v.autoselect && so();
674
+ }), Lo(() => {
675
+ v.active && _t();
676
+ }), Bo(ro), jt(Gt, (s) => {
675
677
  document.body.style.setProperty(
676
678
  "cursor",
677
679
  s === "grabbing" ? "grabbing" : null
678
680
  );
679
- }), ro(
681
+ }), jt(
680
682
  () => v.active,
681
- (s) => s ? Jt() : lo()
682
- );
683
- function Ut(s, f) {
683
+ (s) => s ? _t() : ro()
684
+ ), jt(b, so);
685
+ function Vt(s, f) {
684
686
  var E, re;
685
- if (!W.value.includes(s.to))
687
+ if (!X.value.includes(s.to))
686
688
  return;
687
689
  const c = (E = v.hexchess) == null ? void 0 : E.board[s.from];
688
690
  if (!c)
689
691
  return;
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
- hexchess: ae,
692
+ const d = c === c.toLowerCase() ? "b" : "w", g = ((re = v.hexchess) == null ? void 0 : re.turn) === d;
693
+ if (v.hexchess && (c === "p" || c === "P") && Ro(s.to, d)) {
694
+ const Ut = v.hexchess.clone();
695
+ Ut.board[s.from] = null, Ut.board[s.to] = c, h.value = {
696
+ hexchess: Ut,
695
697
  promotionEl: (f == null ? void 0 : f.target) instanceof Element ? f.target : null,
696
698
  promotionFrom: s.from,
697
699
  promotionTo: s.to,
@@ -699,137 +701,137 @@ const Wo = {
699
701
  }, (f == null ? void 0 : f.target) instanceof Element && (ie.value = f.target.getBoundingClientRect());
700
702
  return;
701
703
  }
702
- ut(s.from) && (v.ignoreTurn || g) && eo(s);
704
+ rt(s.from) && (v.ignoreTurn || g) && to(s);
703
705
  }
704
- function ut(s) {
705
- var h;
706
- const f = (h = v.hexchess) == null ? void 0 : h.board[s];
706
+ function _e() {
707
+ const s = h.value.promotionFrom;
708
+ h.value = {
709
+ hexchess: null,
710
+ promotionEl: null,
711
+ promotionFrom: null,
712
+ promotionTo: null,
713
+ selected: null
714
+ }, typeof s == "number" && (b.value = s), M.value = null, Yt = !0;
715
+ }
716
+ function go(s) {
717
+ var f, c;
718
+ return F.value === null ? K.value.labelColor : (f = ae(F.value)) != null && f.startsWith(s) || (c = ae(F.value)) != null && c.endsWith(s) ? K.value.labelActiveColor : K.value.labelInactiveColor;
719
+ }
720
+ function rt(s) {
721
+ var d;
722
+ const f = (d = v.hexchess) == null ? void 0 : d.board[s];
707
723
  if (!f)
708
724
  return !1;
709
725
  const c = f === f.toLowerCase() ? "b" : "w";
710
726
  return v.playing === !0 || v.playing === c;
711
727
  }
712
- function mo(s) {
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
- }
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 });
728
+ function _t() {
729
+ Je.value = { x: 0, y: 0 }, window.addEventListener("keyup", eo), window.addEventListener("pointermove", oo), window.addEventListener("pointerup", no), window.addEventListener("resize", ut), window.addEventListener("scroll", ut), window.addEventListener("touchmove", lo, { passive: !1 });
718
730
  }
719
- function it() {
731
+ function ut() {
720
732
  var s;
721
- ie.value = ((s = d.value.promotionEl) == null ? void 0 : s.getBoundingClientRect()) ?? se();
733
+ ie.value = ((s = h.value.promotionEl) == null ? void 0 : s.getBoundingClientRect()) ?? se();
722
734
  }
723
- function go(s, f) {
735
+ function yo(s, f) {
724
736
  if (v.active) {
725
- if (Kt) {
726
- Kt = !1;
737
+ if (Yt) {
738
+ Yt = !1;
727
739
  return;
728
740
  }
729
- if (d.value.hexchess) {
730
- d.value.selected !== s && et();
741
+ if (h.value.hexchess) {
742
+ h.value.selected !== s && _e();
731
743
  return;
732
744
  }
733
- if (C.value !== null && W.value.includes(s)) {
734
- const c = new ft({ from: C.value, to: s });
735
- Ut(c, f);
745
+ if (b.value !== null && X.value.includes(s)) {
746
+ const c = new at({ from: b.value, to: s });
747
+ Vt(c, f);
736
748
  return;
737
749
  }
738
- v.autoselect && !v.hexchess.board[s] && (C.value = null, W.value = []), Q("clickPosition", s);
750
+ v.autoselect && !v.hexchess.board[s] && (b.value = null), Q("clickPosition", s);
739
751
  }
740
752
  }
741
- function _t(s) {
753
+ function eo(s) {
742
754
  if (s.key === "Escape") {
743
- if (d.value.hexchess) {
744
- et();
755
+ if (h.value.hexchess) {
756
+ _e();
745
757
  return;
746
758
  }
747
- v.autoselect && (C.value = null, W.value = []);
759
+ v.autoselect && (b.value = null);
748
760
  }
749
761
  }
750
- function eo(s) {
751
- Q("move", s), ct();
762
+ function wo(s) {
763
+ F.value = s;
764
+ }
765
+ function bo() {
766
+ F.value = null;
767
+ }
768
+ function to(s) {
769
+ Q("move", s), it();
752
770
  }
753
- function wo(s, f) {
771
+ function xo(s, f) {
772
+ var E, re;
773
+ if (f.preventDefault(), h.value.hexchess || b.value !== null && X.value.includes(s))
774
+ return;
775
+ const c = (E = v.hexchess) == null ? void 0 : E.board[s];
776
+ if (!c || (v.autoselect && (b.value = s), !rt(s)))
777
+ return;
778
+ const d = c === c.toLowerCase() ? "b" : "w", g = ((re = v.hexchess) == null ? void 0 : re.turn) === d;
779
+ !v.ignoreTurn && !g || (M.value = s, Je.value = { x: f.clientX, y: f.clientY }, Xt.value instanceof Element && (Y.value = Xt.value.getBoundingClientRect()));
780
+ }
781
+ function oo(s) {
782
+ v.active && (Je.value = { x: s.clientX, y: s.clientY });
783
+ }
784
+ function ko(s, f) {
754
785
  var c;
755
786
  if (f.stopPropagation(), M.value !== null) {
756
- let h = s;
787
+ let d = s;
757
788
  const g = document.elementFromPoint(
758
789
  f.clientX,
759
790
  f.clientY
760
791
  ), 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)
792
+ E !== null && (d = Number(E));
793
+ const re = new at({ from: M.value, to: d });
794
+ if (Vt(re, f), h.value.hexchess)
764
795
  return;
765
796
  M.value = null, Y.value = se();
766
797
  return;
767
798
  }
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;
799
+ if (b.value !== null && X.value.includes(s)) {
800
+ const d = new at({ from: b.value, to: s });
801
+ return Vt(d, f), h.value.hexchess, void 0;
771
802
  }
772
- if (d.value.hexchess) {
773
- et();
803
+ if (h.value.hexchess) {
804
+ _e();
774
805
  return;
775
806
  }
776
807
  if ((c = v.hexchess) != null && c.board[s]) {
777
808
  M.value = null, Y.value = se();
778
809
  return;
779
810
  }
780
- ct();
781
- }
782
- function et() {
783
- const s = d.value.promotionFrom;
784
- d.value = {
785
- hexchess: null,
786
- promotionEl: null,
787
- promotionFrom: null,
788
- promotionTo: null,
789
- selected: null
790
- }, typeof s == "number" && (C.value = s, W.value = v.hexchess.movesFrom(s).map((f) => f.to) ?? []), M.value = null, Kt = !0;
791
- }
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
- return;
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
- return;
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
- }
802
- function bo(s) {
803
- F.value = s;
804
- }
805
- function xo() {
806
- F.value = null;
807
- }
808
- function to(s) {
809
- v.active && (_e.value = { x: s.clientX, y: s.clientY });
810
- }
811
- function oo(s) {
812
- M.value !== null && s.preventDefault();
811
+ it();
813
812
  }
814
813
  function no() {
815
- if (d.value.hexchess) {
816
- et();
814
+ if (h.value.hexchess) {
815
+ _e();
817
816
  return;
818
817
  }
819
818
  if (M.value !== null) {
820
819
  M.value = null, Y.value = se();
821
820
  return;
822
821
  }
823
- ct();
822
+ it();
823
+ }
824
+ function lo(s) {
825
+ M.value !== null && s.preventDefault();
824
826
  }
825
- function ko(s) {
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,
827
+ function Po(s) {
828
+ if (typeof h.value.promotionFrom == "number" && rt(h.value.promotionFrom)) {
829
+ const f = new at({
830
+ from: h.value.promotionFrom ?? 0,
831
+ to: h.value.promotionTo ?? 0,
830
832
  promotion: s
831
833
  });
832
- eo(f);
834
+ to(f);
833
835
  }
834
836
  }
835
837
  function se() {
@@ -844,144 +846,148 @@ const Wo = {
844
846
  y: 0
845
847
  };
846
848
  }
847
- function ct() {
848
- document.body.style.setProperty("cursor", null), M.value = null, C.value = null, d.value = {
849
+ function it() {
850
+ document.body.style.setProperty("cursor", null), M.value = null, b.value = null, h.value = {
849
851
  hexchess: null,
850
852
  promotionEl: null,
851
853
  promotionFrom: null,
852
854
  promotionTo: null,
853
855
  selected: null
854
- }, Y.value = se(), W.value = [];
856
+ }, Y.value = se(), X.value = [];
857
+ }
858
+ function so() {
859
+ var s;
860
+ typeof b.value == "number" ? X.value = ((s = v.hexchess) == null ? void 0 : s.movesFrom(b.value).map((f) => f.to)) ?? [] : X.value = [];
855
861
  }
856
- function lo() {
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);
862
+ function ro() {
863
+ it(), window.removeEventListener("keyup", eo), window.removeEventListener("pointermove", oo), window.removeEventListener("pointerup", no), window.removeEventListener("resize", ut), window.removeEventListener("scroll", ut), window.removeEventListener("touchmove", lo);
858
864
  }
859
- return (s, f) => (b(), P("div", null, [
860
- (b(), P("svg", {
865
+ return (s, f) => (x(), C("div", null, [
866
+ (x(), C("svg", {
861
867
  xmlns: "http://www.w3.org/2000/svg",
862
868
  ref_key: "svgEl",
863
- ref: Yt,
864
- style: at({ cursor: jt.value }),
869
+ ref: Xt,
870
+ style: ct({ cursor: Gt.value }),
865
871
  viewBox: `0 0 ${a(de)} ${a(de)}`
866
872
  }, [
867
- fo("path", {
868
- d: a(Xt)(a(zo)),
873
+ vo("path", {
874
+ d: a(Ot)(a(Wo)),
869
875
  fill: K.value.colors[1],
870
876
  style: { pointerEvents: "none" }
871
- }, null, 8, Oo),
872
- (b(!0), P(nt, null, lt(a(o), (c, h) => (b(), P("path", Bo(
877
+ }, null, 8, Xo),
878
+ (x(!0), C(ot, null, nt(a(o), (c, d) => (x(), C("path", Mo(
873
879
  { ref_for: !0 },
874
880
  i.active ? {
875
- onClick: (g) => go(h, g),
876
- onMouseenter: () => bo(h),
877
- onMouseleave: () => xo(),
878
- onPointerdown: (g) => yo(h, g),
879
- onPointerup: (g) => wo(h, g)
881
+ onClick: (g) => yo(d, g),
882
+ onMouseenter: () => wo(d),
883
+ onMouseleave: () => bo(),
884
+ onPointerdown: (g) => xo(d, g),
885
+ onPointerup: (g) => ko(d, g)
880
886
  } : {},
881
887
  {
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
888
+ d: a(Ot)(i.flipped ? c[4] : c[3]),
889
+ "data-hexboard-position": d,
890
+ fill: K.value.colors[a(o)[d][0]],
891
+ key: d
886
892
  }
887
- ), null, 16, Xo))), 128)),
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]),
893
+ ), null, 16, Yo))), 128)),
894
+ (x(!0), C(ot, null, nt(i.highlight, (c) => (x(), C("path", {
895
+ d: a(Ot)(i.flipped ? a(o)[c][4] : a(o)[c][3]),
890
896
  fill: K.value.highlightColor,
891
897
  key: `highlight-${c}`,
892
898
  style: { pointerEvents: "none" }
893
- }, null, 8, Yo))), 128)),
894
- typeof Qt.value == "number" ? (b(), P("path", {
899
+ }, null, 8, Ko))), 128)),
900
+ typeof Kt.value == "number" ? (x(), C("path", {
895
901
  key: 0,
896
- d: a(Xt)(i.flipped ? a(o)[Qt.value][4] : a(o)[Qt.value][3]),
902
+ d: a(Ot)(i.flipped ? a(o)[Kt.value][4] : a(o)[Kt.value][3]),
897
903
  fill: K.value.selectedColor,
898
904
  ref: "selectedEl",
899
905
  style: { pointerEvents: "none" }
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", {
902
- textContent: vo(c),
906
+ }, null, 8, Qo)) : tt("", !0),
907
+ K.value.labels ? (x(!0), C(ot, { key: 1 }, nt(a(zo), ([c, d, g], E) => (x(), C("text", {
908
+ textContent: ho(c),
903
909
  "dominant-baseline": "central",
904
910
  "text-anchor": "middle",
905
911
  key: `label-${E}`,
906
- style: at({
907
- fill: mo(c),
912
+ style: ct({
913
+ fill: go(c),
908
914
  fontSize: ".5px",
909
915
  pointerEvents: "none",
910
916
  userSelect: "none"
911
917
  }),
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), {
918
+ x: a(R)(a(fe)(i.flipped ? g[0] : d[0])),
919
+ y: a(R)(a(ve)(i.flipped ? g[1] : d[1]))
920
+ }, null, 12, Vo))), 128)) : tt("", !0),
921
+ ce.value ? (x(!0), C(ot, { key: 2 }, nt(mo.value, ({ piece: c, index: d }) => (x(), io(co(i.pieces), {
916
922
  "data-piece-type": c,
917
923
  height: a(V),
918
- key: `piece-${a(fe)(h)}`,
924
+ key: `piece-${a(ae)(d)}`,
919
925
  style: { pointerEvents: "none" },
920
926
  type: c,
921
927
  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])),
928
+ x: a(R)(a(fe)(a(o)[d][i.flipped ? 2 : 1][0] - a(V) / 2)),
929
+ y: a(R)(a(ve)(a(o)[d][i.flipped ? 2 : 1][1] + a(V) / 2))
930
+ }, null, 8, ["data-piece-type", "height", "type", "width", "x", "y"]))), 128)) : tt("", !0),
931
+ (x(!0), C(ot, null, nt(po.value, (c) => (x(), C("circle", {
932
+ cx: a(R)(a(fe)(a(o)[c][i.flipped ? 2 : 1][0])),
933
+ cy: a(R)(a(ve)(a(o)[c][i.flipped ? 2 : 1][1])),
928
934
  fill: K.value.targetColor,
929
- key: `target-${a(fe)(c)}`,
935
+ key: `target-${a(ae)(c)}`,
930
936
  r: 0.3,
931
937
  style: { pointerEvents: "none" }
932
- }, null, 8, Vo))), 128))
933
- ], 12, Ho)),
934
- Vt.value ? (b(), P("svg", {
938
+ }, null, 8, Uo))), 128))
939
+ ], 12, Oo)),
940
+ Qt.value ? (x(), C("svg", {
935
941
  key: 0,
936
942
  xmlns: "http://www.w3.org/2000/svg",
937
- style: at({
943
+ style: ct({
938
944
  height: Y.value.height + "px",
939
945
  left: "0px",
940
946
  pointerEvents: "none",
941
947
  position: "fixed",
942
948
  top: "0px",
943
- transform: `translate(${Gt.value.x}px, ${Gt.value.y}px) scale(1.1)`,
949
+ transform: `translate(${It.value.x}px, ${It.value.y}px) scale(1.1)`,
944
950
  width: Y.value.width + "px",
945
951
  willChange: "transform"
946
952
  }),
947
953
  viewBox: `0 0 ${a(de)} ${a(de)}`
948
954
  }, [
949
- (b(), uo(io(i.pieces), {
955
+ (x(), io(co(i.pieces), {
950
956
  height: a(V),
951
957
  style: { pointerEvents: "none" },
952
- type: Vt.value,
958
+ type: Qt.value,
953
959
  width: a(V),
954
- x: a(R)(a(ve)(a(V) / -2)),
955
- y: a(R)(a(he)(a(V) / 2))
960
+ x: a(R)(a(fe)(a(V) / -2)),
961
+ y: a(R)(a(ve)(a(V) / 2))
956
962
  }, null, 8, ["height", "type", "width", "x", "y"]))
957
- ], 12, Uo)) : ot("", !0),
958
- typeof d.value.selected == "number" ? (b(), P("div", {
963
+ ], 12, Zo)) : tt("", !0),
964
+ typeof h.value.selected == "number" ? (x(), C("div", {
959
965
  key: 1,
960
- style: at({
966
+ style: ct({
961
967
  height: ie.value.height + "px",
962
968
  left: ie.value.left + "px",
963
969
  position: "fixed",
964
970
  top: ie.value.top + "px",
965
971
  width: ie.value.width + "px"
966
972
  }),
967
- onPointerup: f[0] || (f[0] = Mo(() => {
973
+ onPointerup: f[0] || (f[0] = $o(() => {
968
974
  }, ["stop"]))
969
975
  }, [
970
- $o(s.$slots, "promotion", {
971
- b: rt.value.b,
972
- cancel: et,
973
- file: a(fe)(d.value.selected)[0],
974
- n: rt.value.n,
975
- promote: ko,
976
- q: rt.value.q,
977
- r: rt.value.r,
978
- rank: Number(a(fe)(d.value.selected).slice(1))
976
+ To(s.$slots, "promotion", {
977
+ b: st.value.b,
978
+ cancel: _e,
979
+ file: a(ae)(h.value.selected)[0],
980
+ n: st.value.n,
981
+ promote: Po,
982
+ q: st.value.q,
983
+ r: st.value.r,
984
+ rank: Number(a(ae)(h.value.selected).slice(1))
979
985
  })
980
- ], 36)) : ot("", !0)
986
+ ], 36)) : tt("", !0)
981
987
  ]));
982
988
  }
983
989
  });
984
990
  export {
985
- Go as Hexboard,
986
- So as defaultOptions
991
+ Io as Hexboard,
992
+ qo as defaultOptions
987
993
  };
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.9"
61
+ "version": "0.0.10"
62
62
  }
@@ -172,6 +172,7 @@ import {
172
172
  type Component,
173
173
  computed,
174
174
  h,
175
+ onBeforeMount,
175
176
  onMounted,
176
177
  onUnmounted,
177
178
  shallowRef,
@@ -462,6 +463,12 @@ const promotionPieces = computed(() => {
462
463
  // lifecycle
463
464
  //
464
465
 
466
+ onBeforeMount(() => {
467
+ if (props.autoselect) {
468
+ selectCurrentTargets()
469
+ }
470
+ })
471
+
465
472
  onMounted(() => {
466
473
  if (props.active) {
467
474
  listen()
@@ -486,6 +493,8 @@ watch(
486
493
  val => (val ? listen() : unlisten()),
487
494
  )
488
495
 
496
+ watch(selected, selectCurrentTargets)
497
+
489
498
  //
490
499
  // methods
491
500
  //
@@ -537,17 +546,25 @@ function attemptMove(san: San, evt?: MouseEvent) {
537
546
  }
538
547
  }
539
548
 
540
- /** check if user is playing the color at a position */
541
- function isPlayingPosition(index: number): boolean {
542
- const piece = props.hexchess?.board[index]
549
+ /** cancel promotion and restore original selection */
550
+ function cancelPromotion() {
551
+ const from = staging.value.promotionFrom
543
552
 
544
- if (!piece) {
545
- return false
553
+ staging.value = {
554
+ hexchess: null,
555
+ promotionEl: null,
556
+ promotionFrom: null,
557
+ promotionTo: null,
558
+ selected: null,
546
559
  }
547
560
 
548
- const pieceColor: Color = piece === piece.toLowerCase() ? 'b' : 'w'
561
+ // Keep the original piece selected
562
+ if (typeof from === 'number') {
563
+ selected.value = from
564
+ }
549
565
 
550
- return props.playing === true || props.playing === pieceColor
566
+ pointerdownPosition.value = null
567
+ skipNextClick = true
551
568
  }
552
569
 
553
570
  /** get fill color of label */
@@ -566,6 +583,19 @@ function getLabelFill(text: string) {
566
583
  return normalizedOptions.value.labelInactiveColor
567
584
  }
568
585
 
586
+ /** check if user is playing the color at a position */
587
+ function isPlayingPosition(index: number): boolean {
588
+ const piece = props.hexchess?.board[index]
589
+
590
+ if (!piece) {
591
+ return false
592
+ }
593
+
594
+ const pieceColor: Color = piece === piece.toLowerCase() ? 'b' : 'w'
595
+
596
+ return props.playing === true || props.playing === pieceColor
597
+ }
598
+
569
599
  /** listen for events */
570
600
  function listen() {
571
601
  pointerCoords.value = { x: 0, y: 0 }
@@ -614,7 +644,6 @@ function onClickPosition(index: number, evt: MouseEvent) {
614
644
  // If autoselect is enabled and clicking an unoccupied position, deselect
615
645
  if (props.autoselect && !props.hexchess.board[index]) {
616
646
  selected.value = null
617
- targets.value = []
618
647
  }
619
648
 
620
649
  emit('clickPosition', index)
@@ -632,11 +661,20 @@ function onKeyupWindow(evt: KeyboardEvent) {
632
661
  // Otherwise deselect if autoselect is enabled
633
662
  if (props.autoselect) {
634
663
  selected.value = null
635
- targets.value = []
636
664
  }
637
665
  }
638
666
  }
639
667
 
668
+ /** mouseenter position */
669
+ function onMouseenter(index: number) {
670
+ mouseoverPosition.value = index
671
+ }
672
+
673
+ /** mouseleave position */
674
+ function onMouseleave() {
675
+ mouseoverPosition.value = null
676
+ }
677
+
640
678
  /** handle piece move */
641
679
  function onPieceMove(san: San) {
642
680
  emit('move', san)
@@ -644,6 +682,60 @@ function onPieceMove(san: San) {
644
682
  resetState()
645
683
  }
646
684
 
685
+ /** pointerdown on position */
686
+ function onPointerdownPosition(index: number, evt: PointerEvent) {
687
+ evt.preventDefault()
688
+
689
+ // Don't start new interactions during promotion
690
+ if (staging.value.hexchess) {
691
+ return
692
+ }
693
+
694
+ // If clicking on a valid target for the selected piece, don't re-select
695
+ // (the move will be handled in onPointerupPosition/onClickPosition)
696
+ if (selected.value !== null && targets.value.includes(index)) {
697
+ return
698
+ }
699
+
700
+ const piece = props.hexchess?.board[index]
701
+
702
+ if (!piece) {
703
+ return
704
+ }
705
+
706
+ if (props.autoselect) {
707
+ selected.value = index
708
+ }
709
+
710
+ if (!isPlayingPosition(index)) {
711
+ return
712
+ }
713
+
714
+ // Only allow dragging if it's the piece's turn (or ignoreTurn is true)
715
+ const pieceColor: Color = piece === piece.toLowerCase() ? 'b' : 'w'
716
+ const isCurrentTurn = props.hexchess?.turn === pieceColor
717
+
718
+ if (!props.ignoreTurn && !isCurrentTurn) {
719
+ return
720
+ }
721
+
722
+ pointerdownPosition.value = index
723
+ pointerCoords.value = { x: evt.clientX, y: evt.clientY }
724
+
725
+ if (svgEl.value instanceof Element) {
726
+ svgRect.value = svgEl.value.getBoundingClientRect()
727
+ }
728
+ }
729
+
730
+ /** pointermove window */
731
+ function onPointermoveWindow(evt: MouseEvent) {
732
+ if (!props.active) {
733
+ return
734
+ }
735
+
736
+ pointerCoords.value = { x: evt.clientX, y: evt.clientY }
737
+ }
738
+
647
739
  /** pointerup position */
648
740
  function onPointerupPosition(index: number, evt: PointerEvent) {
649
741
  evt.stopPropagation()
@@ -707,100 +799,6 @@ function onPointerupPosition(index: number, evt: PointerEvent) {
707
799
  resetState()
708
800
  }
709
801
 
710
- /** cancel promotion and restore original selection */
711
- function cancelPromotion() {
712
- const from = staging.value.promotionFrom
713
-
714
- staging.value = {
715
- hexchess: null,
716
- promotionEl: null,
717
- promotionFrom: null,
718
- promotionTo: null,
719
- selected: null,
720
- }
721
-
722
- // Keep the original piece selected
723
- if (typeof from === 'number') {
724
- selected.value = from
725
- targets.value = props.hexchess.movesFrom(from).map(san => san.to) ?? []
726
- }
727
-
728
- pointerdownPosition.value = null
729
- skipNextClick = true
730
- }
731
-
732
- /** pointerdown on position */
733
- function onPointerdownPosition(index: number, evt: PointerEvent) {
734
- evt.preventDefault()
735
-
736
- // Don't start new interactions during promotion
737
- if (staging.value.hexchess) {
738
- return
739
- }
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
-
747
- const piece = props.hexchess?.board[index]
748
-
749
- if (!piece) {
750
- return
751
- }
752
-
753
- if (props.autoselect) {
754
- selected.value = index
755
- targets.value = props.hexchess?.movesFrom(index).map(san => san.to) ?? []
756
- }
757
-
758
- if (!isPlayingPosition(index)) {
759
- return
760
- }
761
-
762
- // Only allow dragging if it's the piece's turn (or ignoreTurn is true)
763
- const pieceColor: Color = piece === piece.toLowerCase() ? 'b' : 'w'
764
- const isCurrentTurn = props.hexchess?.turn === pieceColor
765
-
766
- if (!props.ignoreTurn && !isCurrentTurn) {
767
- return
768
- }
769
-
770
- pointerdownPosition.value = index
771
- pointerCoords.value = { x: evt.clientX, y: evt.clientY }
772
-
773
- if (svgEl.value instanceof Element) {
774
- svgRect.value = svgEl.value.getBoundingClientRect()
775
- }
776
- }
777
-
778
- /** mouseenter position */
779
- function onMouseenter(index: number) {
780
- mouseoverPosition.value = index
781
- }
782
-
783
- /** mouseleave position */
784
- function onMouseleave() {
785
- mouseoverPosition.value = null
786
- }
787
-
788
- /** pointermove window */
789
- function onPointermoveWindow(evt: MouseEvent) {
790
- if (!props.active) {
791
- return
792
- }
793
-
794
- pointerCoords.value = { x: evt.clientX, y: evt.clientY }
795
- }
796
-
797
- /** touchmove window - prevent scrolling while dragging */
798
- function onTouchmoveWindow(evt: TouchEvent) {
799
- if (pointerdownPosition.value !== null) {
800
- evt.preventDefault()
801
- }
802
- }
803
-
804
802
  /** pointerup window */
805
803
  function onPointerupWindow() {
806
804
  // If staging a promotion, cancel it but keep the original piece selected
@@ -819,6 +817,13 @@ function onPointerupWindow() {
819
817
  resetState()
820
818
  }
821
819
 
820
+ /** touchmove window - prevent scrolling while dragging */
821
+ function onTouchmoveWindow(evt: TouchEvent) {
822
+ if (pointerdownPosition.value !== null) {
823
+ evt.preventDefault()
824
+ }
825
+ }
826
+
822
827
  /** promote piece */
823
828
  function promote(promotion: 'n' | 'b' | 'r' | 'q') {
824
829
  if (
@@ -865,6 +870,16 @@ function resetState() {
865
870
  targets.value = []
866
871
  }
867
872
 
873
+ /** select current targets */
874
+ function selectCurrentTargets() {
875
+ if (typeof selected.value === 'number') {
876
+ targets.value = props.hexchess?.movesFrom(selected.value).map(san => san.to) ?? []
877
+ }
878
+ else {
879
+ targets.value = []
880
+ }
881
+ }
882
+
868
883
  /** stop listening for events */
869
884
  function unlisten() {
870
885
  resetState()
@@ -846,3 +846,26 @@ test('drag capture', async () => {
846
846
 
847
847
  await expect(hexchess.value.toString()).toBe('b/qbk/n1b1n/r5r/ppp1ppppp/11/4P6/4P1P4/3P1B1P3/2P2B2P2/1PRNQBKNRP1 b - 0 2')
848
848
  })
849
+
850
+ test('updates targets when autoselect is true', async () => {
851
+ const selected = ref<number | null>(index('f5'))
852
+ const targets = ref<number[]>([])
853
+
854
+ setup(() => {
855
+ return () => (
856
+ <Hexboard
857
+ v-model:selected={selected.value}
858
+ v-model:targets={targets.value}
859
+ autoselect
860
+ />
861
+ )
862
+ })
863
+
864
+ await expect(targets.value).toEqual([index('f6')])
865
+
866
+ selected.value = index('e4')
867
+
868
+ await nextTick()
869
+
870
+ await expect(targets.value).toEqual([index('e5'), index('e6')])
871
+ })