@konoui/mjimage 0.0.58 → 0.0.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +12 -12
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +804 -774
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var Es = Object.defineProperty;
|
|
2
2
|
var As = (n, t, e) => t in n ? Es(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
3
|
var _ = (n, t, e) => As(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
const
|
|
4
|
+
const In = "MS Gothic, sans-serif", ft = {
|
|
5
5
|
WIDTH: 66,
|
|
6
6
|
HEIGHT: 90,
|
|
7
7
|
TEXT_SCALE: 0.8,
|
|
8
8
|
BLOCK_MARGIN_SCALE: 0.3
|
|
9
|
-
},
|
|
9
|
+
}, nn = {
|
|
10
10
|
WIDTH: 125,
|
|
11
11
|
HEIGHT: 27.5
|
|
12
12
|
}, Ss = { BASE: 40 }, lt = ",", p = {
|
|
@@ -15,7 +15,7 @@ const Tn = "MS Gothic, sans-serif", ft = {
|
|
|
15
15
|
S: "s",
|
|
16
16
|
Z: "z",
|
|
17
17
|
BACK: "_"
|
|
18
|
-
},
|
|
18
|
+
}, y = {
|
|
19
19
|
TSUMO: "t",
|
|
20
20
|
RON: "v",
|
|
21
21
|
DORA: "d",
|
|
@@ -38,7 +38,7 @@ const Tn = "MS Gothic, sans-serif", ft = {
|
|
|
38
38
|
IMAGE_DORA: "dora",
|
|
39
39
|
IMAGE_DISCARD: "simple-discard",
|
|
40
40
|
UNKNOWN: "unknown"
|
|
41
|
-
},
|
|
41
|
+
}, A = {
|
|
42
42
|
E: "1w",
|
|
43
43
|
S: "2w",
|
|
44
44
|
W: "3w",
|
|
@@ -60,12 +60,12 @@ const Tn = "MS Gothic, sans-serif", ft = {
|
|
|
60
60
|
N2: "4w2",
|
|
61
61
|
N3: "4w3",
|
|
62
62
|
N4: "4w4"
|
|
63
|
-
},
|
|
64
|
-
[
|
|
65
|
-
[
|
|
66
|
-
[
|
|
67
|
-
[
|
|
68
|
-
},
|
|
63
|
+
}, We = {
|
|
64
|
+
[A.E]: "東",
|
|
65
|
+
[A.S]: "南",
|
|
66
|
+
[A.W]: "西",
|
|
67
|
+
[A.N]: "北"
|
|
68
|
+
}, On = {
|
|
69
69
|
[k.E1]: "東1局",
|
|
70
70
|
[k.E2]: "東2局",
|
|
71
71
|
[k.E3]: "東3局",
|
|
@@ -112,7 +112,7 @@ class Lo {
|
|
|
112
112
|
});
|
|
113
113
|
_(this, "measureTableFontContext", (t) => {
|
|
114
114
|
const e = this.measureFontContext(
|
|
115
|
-
|
|
115
|
+
In,
|
|
116
116
|
Ss.BASE * t
|
|
117
117
|
);
|
|
118
118
|
return e.textHeight = e.textWidth, e.numHeight = e.numWidth, e;
|
|
@@ -151,11 +151,11 @@ class Ns {
|
|
|
151
151
|
return /\s/.test(t);
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
const
|
|
154
|
+
const ue = (n, t) => {
|
|
155
155
|
if (n.t == t.t) {
|
|
156
156
|
if (C(n) && C(t)) {
|
|
157
|
-
if (n.has(
|
|
158
|
-
if (t.has(
|
|
157
|
+
if (n.has(y.RED)) return -1;
|
|
158
|
+
if (t.has(y.RED)) return 1;
|
|
159
159
|
}
|
|
160
160
|
return n.n - t.n;
|
|
161
161
|
}
|
|
@@ -169,20 +169,20 @@ const le = (n, t) => {
|
|
|
169
169
|
return e[n.t] - e[t.t];
|
|
170
170
|
}, vs = (n, t) => {
|
|
171
171
|
const e = {
|
|
172
|
-
[
|
|
173
|
-
[
|
|
174
|
-
[
|
|
175
|
-
[
|
|
176
|
-
[
|
|
177
|
-
[
|
|
172
|
+
[y.HORIZONTAL]: 1,
|
|
173
|
+
[y.TSUMO]: 2,
|
|
174
|
+
[y.RON]: 3,
|
|
175
|
+
[y.DORA]: 4,
|
|
176
|
+
[y.COLOR_GRAYSCALE]: 5,
|
|
177
|
+
[y.RED]: 6
|
|
178
178
|
};
|
|
179
179
|
return e[n] - e[t];
|
|
180
180
|
}, Ts = (n) => {
|
|
181
181
|
const t = [];
|
|
182
182
|
n.forEach((s, r) => {
|
|
183
|
-
s.has(
|
|
183
|
+
s.has(y.HORIZONTAL) && t.push(r);
|
|
184
184
|
});
|
|
185
|
-
const e = n.filter((s) => !s.has(
|
|
185
|
+
const e = n.filter((s) => !s.has(y.HORIZONTAL)).sort(ue);
|
|
186
186
|
return t.forEach((s) => {
|
|
187
187
|
e.splice(s, 0, n[s]);
|
|
188
188
|
}), e;
|
|
@@ -236,7 +236,7 @@ class T {
|
|
|
236
236
|
return;
|
|
237
237
|
}
|
|
238
238
|
if (this._type != b.IMAGE_DISCARD) {
|
|
239
|
-
this._tiles = [...this._tiles].sort(
|
|
239
|
+
this._tiles = [...this._tiles].sort(ue);
|
|
240
240
|
return;
|
|
241
241
|
}
|
|
242
242
|
}
|
|
@@ -252,7 +252,7 @@ class T {
|
|
|
252
252
|
throw new Error(
|
|
253
253
|
`input type is ${t.type} but got is ${s}: ${t.tiles}`
|
|
254
254
|
);
|
|
255
|
-
return
|
|
255
|
+
return te(e.tiles, t.type);
|
|
256
256
|
}
|
|
257
257
|
serialize() {
|
|
258
258
|
return {
|
|
@@ -284,7 +284,7 @@ class T {
|
|
|
284
284
|
// clone the block with the operators
|
|
285
285
|
clone(t) {
|
|
286
286
|
const e = t == null ? void 0 : t.replace, s = [...this.tiles];
|
|
287
|
-
return e && (s[e.idx] = e.tile),
|
|
287
|
+
return e && (s[e.idx] = e.tile), te(s, this._type);
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
const gt = (n) => {
|
|
@@ -294,7 +294,7 @@ const gt = (n) => {
|
|
|
294
294
|
t += e.toString().slice(0, -1);
|
|
295
295
|
}
|
|
296
296
|
return `${t}${n[0].t}`;
|
|
297
|
-
},
|
|
297
|
+
}, Be = (n) => {
|
|
298
298
|
let t = n[0].t, e = "";
|
|
299
299
|
for (const r of n) {
|
|
300
300
|
const i = r.t, o = i == p.BACK ? r.toString() : r.toString().slice(0, -1);
|
|
@@ -325,13 +325,13 @@ class X extends T {
|
|
|
325
325
|
return gt(this.tiles);
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
|
-
class
|
|
328
|
+
class M extends T {
|
|
329
329
|
constructor(t) {
|
|
330
330
|
const e = t.filter((r) => r.t != p.BACK), s = e[0];
|
|
331
331
|
if (e.length < t.length) {
|
|
332
332
|
if (C(s)) {
|
|
333
333
|
const r = new w(s.t, 5);
|
|
334
|
-
super([r.clone({ add:
|
|
334
|
+
super([r.clone({ add: y.RED }), r, r, r], b.AN_KAN);
|
|
335
335
|
return;
|
|
336
336
|
}
|
|
337
337
|
super([s, s, s, s], b.AN_KAN);
|
|
@@ -340,14 +340,14 @@ class x extends T {
|
|
|
340
340
|
super(t, b.AN_KAN);
|
|
341
341
|
}
|
|
342
342
|
get tilesWithBack() {
|
|
343
|
-
const t = this.tiles[0].clone({ remove:
|
|
343
|
+
const t = this.tiles[0].clone({ remove: y.RED }), e = C(t) ? t.clone({ add: y.RED }) : t;
|
|
344
344
|
return [new w(p.BACK, 0), e, t, new w(p.BACK, 0)];
|
|
345
345
|
}
|
|
346
346
|
static from(t) {
|
|
347
347
|
return T.deserialize({ tiles: t, type: b.AN_KAN });
|
|
348
348
|
}
|
|
349
349
|
toString() {
|
|
350
|
-
return
|
|
350
|
+
return Be(this.tilesWithBack);
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
353
|
class Y extends T {
|
|
@@ -369,14 +369,14 @@ class K extends T {
|
|
|
369
369
|
return T.deserialize({ tiles: t, type: b.SHO_KAN });
|
|
370
370
|
}
|
|
371
371
|
static fromPon(t, e) {
|
|
372
|
-
const s = t.tiles.findIndex((i) => i.has(
|
|
373
|
-
return r.splice(s, 0, e.clone({ add:
|
|
372
|
+
const s = t.tiles.findIndex((i) => i.has(y.HORIZONTAL)), r = [...t.tiles];
|
|
373
|
+
return r.splice(s, 0, e.clone({ add: y.HORIZONTAL })), new K(r);
|
|
374
374
|
}
|
|
375
375
|
toString() {
|
|
376
376
|
return gt(this.tiles);
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
|
-
class
|
|
379
|
+
class H extends T {
|
|
380
380
|
constructor(t, e) {
|
|
381
381
|
super([t, e], b.PAIR);
|
|
382
382
|
}
|
|
@@ -409,7 +409,7 @@ class ut extends T {
|
|
|
409
409
|
return gt(this.tiles);
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
-
class
|
|
412
|
+
class kn extends T {
|
|
413
413
|
constructor(t) {
|
|
414
414
|
super([t], b.ISOLATED);
|
|
415
415
|
}
|
|
@@ -423,7 +423,7 @@ class On extends T {
|
|
|
423
423
|
return this.tiles[0].toString();
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
|
-
class
|
|
426
|
+
class Kt extends T {
|
|
427
427
|
constructor(t) {
|
|
428
428
|
super(t, b.HAND);
|
|
429
429
|
}
|
|
@@ -431,25 +431,25 @@ class Dt extends T {
|
|
|
431
431
|
return T.deserialize({ tiles: t, type: b.HAND });
|
|
432
432
|
}
|
|
433
433
|
toString() {
|
|
434
|
-
return
|
|
434
|
+
return Be(this.tiles);
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
|
-
class
|
|
437
|
+
class Cn extends T {
|
|
438
438
|
constructor(t, e) {
|
|
439
439
|
super(t, e);
|
|
440
440
|
}
|
|
441
441
|
toString() {
|
|
442
|
-
return this.is(b.IMAGE_DISCARD) ? this.tiles.join("") :
|
|
442
|
+
return this.is(b.IMAGE_DISCARD) ? this.tiles.join("") : Be(this.tiles);
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
|
-
const
|
|
445
|
+
const te = (n, t) => {
|
|
446
446
|
switch (t) {
|
|
447
447
|
case b.CHI:
|
|
448
448
|
return new J([n[0], n[1], n[2]]);
|
|
449
449
|
case b.PON:
|
|
450
450
|
return new X([n[0], n[1], n[2]]);
|
|
451
451
|
case b.AN_KAN:
|
|
452
|
-
return new
|
|
452
|
+
return new M(n);
|
|
453
453
|
case b.DAI_KAN:
|
|
454
454
|
return new Y(n);
|
|
455
455
|
case b.SHO_KAN:
|
|
@@ -459,13 +459,13 @@ const Qt = (n, t) => {
|
|
|
459
459
|
case b.RUN:
|
|
460
460
|
return new ut(n);
|
|
461
461
|
case b.PAIR:
|
|
462
|
-
return new
|
|
462
|
+
return new H(n[0], n[1]);
|
|
463
463
|
case b.ISOLATED:
|
|
464
|
-
return new
|
|
464
|
+
return new kn(n[0]);
|
|
465
465
|
case b.HAND:
|
|
466
|
-
return new
|
|
466
|
+
return new Kt(n);
|
|
467
467
|
default:
|
|
468
|
-
return new
|
|
468
|
+
return new Cn(n, t);
|
|
469
469
|
}
|
|
470
470
|
};
|
|
471
471
|
class B {
|
|
@@ -491,7 +491,7 @@ class B {
|
|
|
491
491
|
e.push(lt), t.readChar();
|
|
492
492
|
continue;
|
|
493
493
|
}
|
|
494
|
-
const [i, o] =
|
|
494
|
+
const [i, o] = rn(r, s);
|
|
495
495
|
if (o) {
|
|
496
496
|
if (i == p.BACK) {
|
|
497
497
|
e.push(new w(i, 0)), t.readChar();
|
|
@@ -505,7 +505,7 @@ class B {
|
|
|
505
505
|
s.push(a), t.readChar();
|
|
506
506
|
continue;
|
|
507
507
|
}
|
|
508
|
-
const [l, u] =
|
|
508
|
+
const [l, u] = Rn(r);
|
|
509
509
|
if (!u)
|
|
510
510
|
throw new Error(
|
|
511
511
|
`encounter unexpected number. n: ${l}, current: ${r}, input: ${t.input}`
|
|
@@ -524,30 +524,30 @@ class B {
|
|
|
524
524
|
if (t.length == 0) return s;
|
|
525
525
|
for (const o of t) {
|
|
526
526
|
if (o == lt) {
|
|
527
|
-
const a =
|
|
527
|
+
const a = sn(e), c = te(e, a);
|
|
528
528
|
s.push(c), e = [];
|
|
529
529
|
continue;
|
|
530
530
|
}
|
|
531
531
|
e.push(o);
|
|
532
532
|
}
|
|
533
|
-
const r =
|
|
533
|
+
const r = sn(e), i = te(e, r);
|
|
534
534
|
return s.push(i), e = [], s;
|
|
535
535
|
}
|
|
536
536
|
validate(t) {
|
|
537
537
|
if (t.length == 0) return;
|
|
538
538
|
if (t.length > this.maxInputLength)
|
|
539
539
|
throw new Error(`exceeded maximum input length(${t.length})`);
|
|
540
|
-
const e = t.charAt(t.length - 1), [s, r] =
|
|
540
|
+
const e = t.charAt(t.length - 1), [s, r] = rn(e, [new w(p.BACK, 1)]);
|
|
541
541
|
if (!r)
|
|
542
542
|
throw new Error(`last character(${e}) is not type value`);
|
|
543
543
|
}
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function sn(n) {
|
|
546
546
|
if (n.length === 0) return b.UNKNOWN;
|
|
547
547
|
if (n.length === 1)
|
|
548
|
-
return n[0].has(
|
|
549
|
-
const t = n.every((i) => i.equals(n[0])), e = n.filter((i) => i.has(
|
|
550
|
-
(i) => i.has(
|
|
548
|
+
return n[0].has(y.DORA) ? b.IMAGE_DORA : n[0].has(y.TSUMO) ? b.TSUMO : b.HAND;
|
|
549
|
+
const t = n.every((i) => i.equals(n[0])), e = n.filter((i) => i.has(y.HORIZONTAL)).length, s = n.filter(
|
|
550
|
+
(i) => i.has(y.TSUMO) || i.has(y.DORA)
|
|
551
551
|
).length, r = n.filter((i) => i.t == p.BACK).length;
|
|
552
552
|
if (s > 0) return b.UNKNOWN;
|
|
553
553
|
if (e == 0 && r == 0) return b.HAND;
|
|
@@ -561,7 +561,7 @@ function nn(n) {
|
|
|
561
561
|
return e == 1 || s == 0 ? b.IMAGE_DISCARD : b.UNKNOWN;
|
|
562
562
|
}
|
|
563
563
|
function Os(n) {
|
|
564
|
-
const t = [...n].sort(
|
|
564
|
+
const t = [...n].sort(ue);
|
|
565
565
|
if (t.some((s) => t[0].t != s.t)) return !1;
|
|
566
566
|
const e = t.map((s) => s.n);
|
|
567
567
|
for (let s = 0; s < e.length - 1; s++)
|
|
@@ -571,10 +571,10 @@ function Os(n) {
|
|
|
571
571
|
function ks(n, t) {
|
|
572
572
|
return n.map((e) => {
|
|
573
573
|
const s = new w(t, e.n, e.ops);
|
|
574
|
-
return s.isNum() && s.n == 0 ? s.clone({ n: 5, add:
|
|
574
|
+
return s.isNum() && s.n == 0 ? s.clone({ n: 5, add: y.RED }) : s;
|
|
575
575
|
});
|
|
576
576
|
}
|
|
577
|
-
function
|
|
577
|
+
function rn(n, t) {
|
|
578
578
|
const [e, s] = Is(n);
|
|
579
579
|
if (s) return [e, !0];
|
|
580
580
|
if ((n === "w" || n === "d") && t.length > 0) {
|
|
@@ -586,60 +586,60 @@ function sn(n, t) {
|
|
|
586
586
|
}
|
|
587
587
|
return [p.BACK, !1];
|
|
588
588
|
}
|
|
589
|
-
function
|
|
589
|
+
function Rn(n) {
|
|
590
590
|
const t = Number(n), e = 0 <= t && t <= 9;
|
|
591
591
|
return [t, e];
|
|
592
592
|
}
|
|
593
593
|
function Cs(n) {
|
|
594
|
-
const t = Object.values(
|
|
594
|
+
const t = Object.values(y);
|
|
595
595
|
if (!t.includes(n.char)) return [new w(p.BACK, 0), !1];
|
|
596
596
|
const e = [];
|
|
597
597
|
for (let s = 0; s < 4; s++) {
|
|
598
598
|
const r = n.peekCharN(s);
|
|
599
599
|
if (t.includes(r)) e.push(r);
|
|
600
600
|
else {
|
|
601
|
-
const [i, o] =
|
|
601
|
+
const [i, o] = Rn(r);
|
|
602
602
|
if (!o) break;
|
|
603
603
|
for (const c of e) n.readChar();
|
|
604
604
|
const a = new w(p.BACK, i, e);
|
|
605
|
-
if (a.has(
|
|
606
|
-
throw new Error(`found ${
|
|
607
|
-
if (a.has(
|
|
608
|
-
throw new Error(`unable to specify both ${
|
|
605
|
+
if (a.has(y.RED) && a.n != 5)
|
|
606
|
+
throw new Error(`found ${y.RED} but number is not 5: ${i}`);
|
|
607
|
+
if (a.has(y.DORA) && a.has(y.TSUMO))
|
|
608
|
+
throw new Error(`unable to specify both ${y.DORA} and ${y.TSUMO}`);
|
|
609
609
|
return [a, !0];
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
612
|
return [new w(p.BACK, 0), !1];
|
|
613
613
|
}
|
|
614
|
-
function
|
|
614
|
+
function P(n, t = !1) {
|
|
615
615
|
const e = {
|
|
616
|
-
[
|
|
617
|
-
[
|
|
618
|
-
[
|
|
619
|
-
[
|
|
616
|
+
[A.E]: n,
|
|
617
|
+
[A.S]: n,
|
|
618
|
+
[A.W]: n,
|
|
619
|
+
[A.N]: n
|
|
620
620
|
};
|
|
621
621
|
if (t)
|
|
622
|
-
for (let s of Object.values(
|
|
622
|
+
for (let s of Object.values(A)) e[s] = structuredClone(n);
|
|
623
623
|
return e;
|
|
624
624
|
}
|
|
625
|
-
const
|
|
625
|
+
const Yt = (n) => {
|
|
626
626
|
let t = n.substring(0, 2), e = Number(n.substring(2, 3));
|
|
627
627
|
return e == 4 ? (e = 1, t = St(t)) : e++, `${t}${e}`;
|
|
628
|
-
}, zo = (n) =>
|
|
628
|
+
}, zo = (n) => Yt(Yt(Yt(n))), St = (n) => {
|
|
629
629
|
let t = Number(n.toString()[0]);
|
|
630
630
|
return t = t % 4 + 1, `${t}w`;
|
|
631
|
-
},
|
|
631
|
+
}, De = (n) => {
|
|
632
632
|
let t = Number(n.toString()[0]);
|
|
633
633
|
const e = [1, 4, 3, 2], s = e.indexOf(t);
|
|
634
634
|
return `${e[(s + 1) % e.length]}w`;
|
|
635
|
-
},
|
|
635
|
+
}, on = (n, t, e) => {
|
|
636
636
|
const s = Math.abs(Number(n[0]) - Number(t[0]));
|
|
637
637
|
return N(s == 1 || s == 2 || s == 3), e == b.PON ? s == 3 ? 0 : s == 2 ? 1 : 2 : s == 3 ? 0 : s == 1 ? 3 : 2;
|
|
638
638
|
};
|
|
639
|
-
function
|
|
639
|
+
function an(n) {
|
|
640
640
|
return typeof n > "u";
|
|
641
641
|
}
|
|
642
|
-
function
|
|
642
|
+
function Se(n, t = 0) {
|
|
643
643
|
return {
|
|
644
644
|
a: 1,
|
|
645
645
|
c: 0,
|
|
@@ -649,7 +649,7 @@ function Ae(n, t = 0) {
|
|
|
649
649
|
f: t
|
|
650
650
|
};
|
|
651
651
|
}
|
|
652
|
-
function
|
|
652
|
+
function Ke(...n) {
|
|
653
653
|
n = Array.isArray(n[0]) ? n[0] : n;
|
|
654
654
|
const t = (e, s) => ({
|
|
655
655
|
a: e.a * s.a + e.c * s.b,
|
|
@@ -668,16 +668,16 @@ function De(...n) {
|
|
|
668
668
|
return t(n[0], n[1]);
|
|
669
669
|
default: {
|
|
670
670
|
const [e, s, ...r] = n, i = t(e, s);
|
|
671
|
-
return
|
|
671
|
+
return Ke(i, ...r);
|
|
672
672
|
}
|
|
673
673
|
}
|
|
674
674
|
}
|
|
675
675
|
function Rs(...n) {
|
|
676
|
-
return
|
|
676
|
+
return Ke(...n);
|
|
677
677
|
}
|
|
678
|
-
const { cos:
|
|
679
|
-
function
|
|
680
|
-
const s =
|
|
678
|
+
const { cos: xs, sin: Ms, PI: $s } = Math;
|
|
679
|
+
function Ps(n, t, e) {
|
|
680
|
+
const s = xs(n), r = Ms(n), i = {
|
|
681
681
|
a: s,
|
|
682
682
|
c: -r,
|
|
683
683
|
e: 0,
|
|
@@ -685,14 +685,14 @@ function Hs(n, t, e) {
|
|
|
685
685
|
d: s,
|
|
686
686
|
f: 0
|
|
687
687
|
};
|
|
688
|
-
return
|
|
689
|
-
|
|
688
|
+
return an(t) || an(e) ? i : Ke([
|
|
689
|
+
Se(t, e),
|
|
690
690
|
i,
|
|
691
|
-
|
|
691
|
+
Se(-t, -e)
|
|
692
692
|
]);
|
|
693
693
|
}
|
|
694
|
-
function
|
|
695
|
-
return
|
|
694
|
+
function Hs(n, t = void 0, e = void 0) {
|
|
695
|
+
return Ps(n * $s / 180, t, e);
|
|
696
696
|
}
|
|
697
697
|
function Ws(n) {
|
|
698
698
|
return Bs(n);
|
|
@@ -706,15 +706,15 @@ function Ds(n, t) {
|
|
|
706
706
|
}
|
|
707
707
|
e.prototype = t.prototype, n.prototype = new e();
|
|
708
708
|
}
|
|
709
|
-
function
|
|
709
|
+
function he(n, t, e, s) {
|
|
710
710
|
var r = Error.call(this, n);
|
|
711
|
-
return Object.setPrototypeOf && Object.setPrototypeOf(r,
|
|
711
|
+
return Object.setPrototypeOf && Object.setPrototypeOf(r, he.prototype), r.expected = t, r.found = e, r.location = s, r.name = "SyntaxError", r;
|
|
712
712
|
}
|
|
713
|
-
Ds(
|
|
714
|
-
function
|
|
713
|
+
Ds(he, Error);
|
|
714
|
+
function ge(n, t, e) {
|
|
715
715
|
return e = e || " ", n.length > t ? n : (t -= n.length, e += e.repeat(t), n + e.slice(0, t));
|
|
716
716
|
}
|
|
717
|
-
|
|
717
|
+
he.prototype.format = function(n) {
|
|
718
718
|
var t = "Error: " + this.message;
|
|
719
719
|
if (this.location) {
|
|
720
720
|
var e = null, s;
|
|
@@ -725,19 +725,19 @@ ue.prototype.format = function(n) {
|
|
|
725
725
|
}
|
|
726
726
|
var r = this.location.start, i = this.location.source && typeof this.location.source.offset == "function" ? this.location.source.offset(r) : r, o = this.location.source + ":" + i.line + ":" + i.column;
|
|
727
727
|
if (e) {
|
|
728
|
-
var a = this.location.end, c =
|
|
728
|
+
var a = this.location.end, c = ge("", i.line.toString().length, " "), l = e[r.line - 1], u = r.line === a.line ? a.column : l.length + 1, h = u - r.column || 1;
|
|
729
729
|
t += `
|
|
730
730
|
--> ` + o + `
|
|
731
731
|
` + c + ` |
|
|
732
732
|
` + i.line + " | " + l + `
|
|
733
|
-
` + c + " | " +
|
|
733
|
+
` + c + " | " + ge("", r.column - 1, " ") + ge("", h, "^");
|
|
734
734
|
} else
|
|
735
735
|
t += `
|
|
736
736
|
at ` + o;
|
|
737
737
|
}
|
|
738
738
|
return t;
|
|
739
739
|
};
|
|
740
|
-
|
|
740
|
+
he.buildMessage = function(n, t) {
|
|
741
741
|
var e = {
|
|
742
742
|
literal: function(l) {
|
|
743
743
|
return '"' + r(l.text) + '"';
|
|
@@ -799,7 +799,7 @@ ue.buildMessage = function(n, t) {
|
|
|
799
799
|
}
|
|
800
800
|
return "Expected " + a(n) + " but " + c(t) + " found.";
|
|
801
801
|
};
|
|
802
|
-
const
|
|
802
|
+
const xn = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", Ks = xn + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040", Ls = "[" + xn + "][" + Ks + "]*", zs = new RegExp("^" + Ls + "$");
|
|
803
803
|
function Mn(n, t) {
|
|
804
804
|
const e = [];
|
|
805
805
|
let s = t.exec(n);
|
|
@@ -813,7 +813,7 @@ function Mn(n, t) {
|
|
|
813
813
|
}
|
|
814
814
|
return e;
|
|
815
815
|
}
|
|
816
|
-
const
|
|
816
|
+
const Le = function(n) {
|
|
817
817
|
const t = zs.exec(n);
|
|
818
818
|
return !(t === null || typeof t > "u");
|
|
819
819
|
};
|
|
@@ -832,11 +832,11 @@ function Fs(n, t) {
|
|
|
832
832
|
n[0] === "\uFEFF" && (n = n.substr(1));
|
|
833
833
|
for (let i = 0; i < n.length; i++)
|
|
834
834
|
if (n[i] === "<" && n[i + 1] === "?") {
|
|
835
|
-
if (i += 2, i =
|
|
835
|
+
if (i += 2, i = ln(n, i), i.err) return i;
|
|
836
836
|
} else if (n[i] === "<") {
|
|
837
837
|
let o = i;
|
|
838
838
|
if (i++, n[i] === "!") {
|
|
839
|
-
i =
|
|
839
|
+
i = un(n, i);
|
|
840
840
|
continue;
|
|
841
841
|
} else {
|
|
842
842
|
let a = !1;
|
|
@@ -847,89 +847,89 @@ function Fs(n, t) {
|
|
|
847
847
|
c += n[i];
|
|
848
848
|
if (c = c.trim(), c[c.length - 1] === "/" && (c = c.substring(0, c.length - 1), i--), !Qs(c)) {
|
|
849
849
|
let h;
|
|
850
|
-
return c.trim().length === 0 ? h = "Invalid space after '<'." : h = "Tag '" + c + "' is an invalid name.", I("InvalidTag", h,
|
|
850
|
+
return c.trim().length === 0 ? h = "Invalid space after '<'." : h = "Tag '" + c + "' is an invalid name.", I("InvalidTag", h, x(n, i));
|
|
851
851
|
}
|
|
852
852
|
const l = Vs(n, i);
|
|
853
853
|
if (l === !1)
|
|
854
|
-
return I("InvalidAttr", "Attributes for '" + c + "' have open quote.",
|
|
854
|
+
return I("InvalidAttr", "Attributes for '" + c + "' have open quote.", x(n, i));
|
|
855
855
|
let u = l.value;
|
|
856
856
|
if (i = l.index, u[u.length - 1] === "/") {
|
|
857
857
|
const h = i - u.length;
|
|
858
858
|
u = u.substring(0, u.length - 1);
|
|
859
|
-
const d =
|
|
859
|
+
const d = hn(u, t);
|
|
860
860
|
if (d === !0)
|
|
861
861
|
s = !0;
|
|
862
862
|
else
|
|
863
|
-
return I(d.err.code, d.err.msg,
|
|
863
|
+
return I(d.err.code, d.err.msg, x(n, h + d.err.line));
|
|
864
864
|
} else if (a)
|
|
865
865
|
if (l.tagClosed) {
|
|
866
866
|
if (u.trim().length > 0)
|
|
867
|
-
return I("InvalidTag", "Closing tag '" + c + "' can't have attributes or invalid starting.",
|
|
867
|
+
return I("InvalidTag", "Closing tag '" + c + "' can't have attributes or invalid starting.", x(n, o));
|
|
868
868
|
if (e.length === 0)
|
|
869
|
-
return I("InvalidTag", "Closing tag '" + c + "' has not been opened.",
|
|
869
|
+
return I("InvalidTag", "Closing tag '" + c + "' has not been opened.", x(n, o));
|
|
870
870
|
{
|
|
871
871
|
const h = e.pop();
|
|
872
872
|
if (c !== h.tagName) {
|
|
873
|
-
let d =
|
|
873
|
+
let d = x(n, h.tagStartPos);
|
|
874
874
|
return I(
|
|
875
875
|
"InvalidTag",
|
|
876
876
|
"Expected closing tag '" + h.tagName + "' (opened in line " + d.line + ", col " + d.col + ") instead of closing tag '" + c + "'.",
|
|
877
|
-
|
|
877
|
+
x(n, o)
|
|
878
878
|
);
|
|
879
879
|
}
|
|
880
880
|
e.length == 0 && (r = !0);
|
|
881
881
|
}
|
|
882
|
-
} else return I("InvalidTag", "Closing tag '" + c + "' doesn't have proper closing.",
|
|
882
|
+
} else return I("InvalidTag", "Closing tag '" + c + "' doesn't have proper closing.", x(n, i));
|
|
883
883
|
else {
|
|
884
|
-
const h =
|
|
884
|
+
const h = hn(u, t);
|
|
885
885
|
if (h !== !0)
|
|
886
|
-
return I(h.err.code, h.err.msg,
|
|
886
|
+
return I(h.err.code, h.err.msg, x(n, i - u.length + h.err.line));
|
|
887
887
|
if (r === !0)
|
|
888
|
-
return I("InvalidXml", "Multiple possible root nodes found.",
|
|
888
|
+
return I("InvalidXml", "Multiple possible root nodes found.", x(n, i));
|
|
889
889
|
t.unpairedTags.indexOf(c) !== -1 || e.push({ tagName: c, tagStartPos: o }), s = !0;
|
|
890
890
|
}
|
|
891
891
|
for (i++; i < n.length; i++)
|
|
892
892
|
if (n[i] === "<")
|
|
893
893
|
if (n[i + 1] === "!") {
|
|
894
|
-
i++, i =
|
|
894
|
+
i++, i = un(n, i);
|
|
895
895
|
continue;
|
|
896
896
|
} else if (n[i + 1] === "?") {
|
|
897
|
-
if (i =
|
|
897
|
+
if (i = ln(n, ++i), i.err) return i;
|
|
898
898
|
} else
|
|
899
899
|
break;
|
|
900
900
|
else if (n[i] === "&") {
|
|
901
901
|
const h = Ys(n, i);
|
|
902
902
|
if (h == -1)
|
|
903
|
-
return I("InvalidChar", "char '&' is not expected.",
|
|
903
|
+
return I("InvalidChar", "char '&' is not expected.", x(n, i));
|
|
904
904
|
i = h;
|
|
905
|
-
} else if (r === !0 && !
|
|
906
|
-
return I("InvalidXml", "Extra text at the end",
|
|
905
|
+
} else if (r === !0 && !cn(n[i]))
|
|
906
|
+
return I("InvalidXml", "Extra text at the end", x(n, i));
|
|
907
907
|
n[i] === "<" && i--;
|
|
908
908
|
}
|
|
909
909
|
} else {
|
|
910
|
-
if (
|
|
910
|
+
if (cn(n[i]))
|
|
911
911
|
continue;
|
|
912
|
-
return I("InvalidChar", "char '" + n[i] + "' is not expected.",
|
|
912
|
+
return I("InvalidChar", "char '" + n[i] + "' is not expected.", x(n, i));
|
|
913
913
|
}
|
|
914
914
|
if (s) {
|
|
915
915
|
if (e.length == 1)
|
|
916
|
-
return I("InvalidTag", "Unclosed tag '" + e[0].tagName + "'.",
|
|
916
|
+
return I("InvalidTag", "Unclosed tag '" + e[0].tagName + "'.", x(n, e[0].tagStartPos));
|
|
917
917
|
if (e.length > 0)
|
|
918
918
|
return I("InvalidXml", "Invalid '" + JSON.stringify(e.map((i) => i.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
|
|
919
919
|
} else return I("InvalidXml", "Start tag expected.", 1);
|
|
920
920
|
return !0;
|
|
921
921
|
}
|
|
922
|
-
function
|
|
922
|
+
function cn(n) {
|
|
923
923
|
return n === " " || n === " " || n === `
|
|
924
924
|
` || n === "\r";
|
|
925
925
|
}
|
|
926
|
-
function
|
|
926
|
+
function ln(n, t) {
|
|
927
927
|
const e = t;
|
|
928
928
|
for (; t < n.length; t++)
|
|
929
929
|
if (n[t] == "?" || n[t] == " ") {
|
|
930
930
|
const s = n.substr(e, t - e);
|
|
931
931
|
if (t > 5 && s === "xml")
|
|
932
|
-
return I("InvalidXml", "XML declaration allowed only at the start of the document.",
|
|
932
|
+
return I("InvalidXml", "XML declaration allowed only at the start of the document.", x(n, t));
|
|
933
933
|
if (n[t] == "?" && n[t + 1] == ">") {
|
|
934
934
|
t++;
|
|
935
935
|
break;
|
|
@@ -938,7 +938,7 @@ function cn(n, t) {
|
|
|
938
938
|
}
|
|
939
939
|
return t;
|
|
940
940
|
}
|
|
941
|
-
function
|
|
941
|
+
function un(n, t) {
|
|
942
942
|
if (n.length > t + 5 && n[t + 1] === "-" && n[t + 2] === "-") {
|
|
943
943
|
for (t += 3; t < n.length; t++)
|
|
944
944
|
if (n[t] === "-" && n[t + 1] === "-" && n[t + 2] === ">") {
|
|
@@ -980,22 +980,22 @@ function Vs(n, t) {
|
|
|
980
980
|
};
|
|
981
981
|
}
|
|
982
982
|
const Js = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
|
|
983
|
-
function
|
|
983
|
+
function hn(n, t) {
|
|
984
984
|
const e = Mn(n, Js), s = {};
|
|
985
985
|
for (let r = 0; r < e.length; r++) {
|
|
986
986
|
if (e[r][1].length === 0)
|
|
987
|
-
return I("InvalidAttr", "Attribute '" + e[r][2] + "' has no space in starting.",
|
|
987
|
+
return I("InvalidAttr", "Attribute '" + e[r][2] + "' has no space in starting.", Pt(e[r]));
|
|
988
988
|
if (e[r][3] !== void 0 && e[r][4] === void 0)
|
|
989
|
-
return I("InvalidAttr", "Attribute '" + e[r][2] + "' is without value.",
|
|
989
|
+
return I("InvalidAttr", "Attribute '" + e[r][2] + "' is without value.", Pt(e[r]));
|
|
990
990
|
if (e[r][3] === void 0 && !t.allowBooleanAttributes)
|
|
991
|
-
return I("InvalidAttr", "boolean attribute '" + e[r][2] + "' is not allowed.",
|
|
991
|
+
return I("InvalidAttr", "boolean attribute '" + e[r][2] + "' is not allowed.", Pt(e[r]));
|
|
992
992
|
const i = e[r][2];
|
|
993
993
|
if (!qs(i))
|
|
994
|
-
return I("InvalidAttr", "Attribute '" + i + "' is an invalid name.",
|
|
994
|
+
return I("InvalidAttr", "Attribute '" + i + "' is an invalid name.", Pt(e[r]));
|
|
995
995
|
if (!s.hasOwnProperty(i))
|
|
996
996
|
s[i] = 1;
|
|
997
997
|
else
|
|
998
|
-
return I("InvalidAttr", "Attribute '" + i + "' is repeated.",
|
|
998
|
+
return I("InvalidAttr", "Attribute '" + i + "' is repeated.", Pt(e[r]));
|
|
999
999
|
}
|
|
1000
1000
|
return !0;
|
|
1001
1001
|
}
|
|
@@ -1034,12 +1034,12 @@ function I(n, t, e) {
|
|
|
1034
1034
|
};
|
|
1035
1035
|
}
|
|
1036
1036
|
function qs(n) {
|
|
1037
|
-
return
|
|
1037
|
+
return Le(n);
|
|
1038
1038
|
}
|
|
1039
1039
|
function Qs(n) {
|
|
1040
|
-
return
|
|
1040
|
+
return Le(n);
|
|
1041
1041
|
}
|
|
1042
|
-
function
|
|
1042
|
+
function x(n, t) {
|
|
1043
1043
|
const e = n.substring(0, t).split(/\r?\n/);
|
|
1044
1044
|
return {
|
|
1045
1045
|
line: e.length,
|
|
@@ -1047,7 +1047,7 @@ function M(n, t) {
|
|
|
1047
1047
|
col: e[e.length - 1].length + 1
|
|
1048
1048
|
};
|
|
1049
1049
|
}
|
|
1050
|
-
function
|
|
1050
|
+
function Pt(n) {
|
|
1051
1051
|
return n.startIndex + n[1].length;
|
|
1052
1052
|
}
|
|
1053
1053
|
const tr = {
|
|
@@ -1097,8 +1097,8 @@ const tr = {
|
|
|
1097
1097
|
}, er = function(n) {
|
|
1098
1098
|
return Object.assign({}, tr, n);
|
|
1099
1099
|
};
|
|
1100
|
-
let
|
|
1101
|
-
typeof Symbol != "function" ?
|
|
1100
|
+
let ee;
|
|
1101
|
+
typeof Symbol != "function" ? ee = "@@xmlMetadata" : ee = Symbol("XML Node Metadata");
|
|
1102
1102
|
class at {
|
|
1103
1103
|
constructor(t) {
|
|
1104
1104
|
this.tagname = t, this.child = [], this[":@"] = {};
|
|
@@ -1107,11 +1107,11 @@ class at {
|
|
|
1107
1107
|
t === "__proto__" && (t = "#__proto__"), this.child.push({ [t]: e });
|
|
1108
1108
|
}
|
|
1109
1109
|
addChild(t, e) {
|
|
1110
|
-
t.tagname === "__proto__" && (t.tagname = "#__proto__"), t[":@"] && Object.keys(t[":@"]).length > 0 ? this.child.push({ [t.tagname]: t.child, ":@": t[":@"] }) : this.child.push({ [t.tagname]: t.child }), e !== void 0 && (this.child[this.child.length - 1][
|
|
1110
|
+
t.tagname === "__proto__" && (t.tagname = "#__proto__"), t[":@"] && Object.keys(t[":@"]).length > 0 ? this.child.push({ [t.tagname]: t.child, ":@": t[":@"] }) : this.child.push({ [t.tagname]: t.child }), e !== void 0 && (this.child[this.child.length - 1][ee] = { startIndex: e });
|
|
1111
1111
|
}
|
|
1112
1112
|
/** symbol used for metadata */
|
|
1113
1113
|
static getMetaDataSymbol() {
|
|
1114
|
-
return
|
|
1114
|
+
return ee;
|
|
1115
1115
|
}
|
|
1116
1116
|
}
|
|
1117
1117
|
function nr(n, t) {
|
|
@@ -1161,31 +1161,31 @@ function sr(n, t) {
|
|
|
1161
1161
|
let e = "";
|
|
1162
1162
|
for (; t < n.length && !/\s/.test(n[t]) && n[t] !== '"' && n[t] !== "'"; )
|
|
1163
1163
|
e += n[t], t++;
|
|
1164
|
-
if (
|
|
1164
|
+
if (ze(e), t = q(n, t), n.substring(t, t + 6).toUpperCase() === "SYSTEM")
|
|
1165
1165
|
throw new Error("External entities are not supported");
|
|
1166
1166
|
if (n[t] === "%")
|
|
1167
1167
|
throw new Error("Parameter entities are not supported");
|
|
1168
1168
|
let s = "";
|
|
1169
|
-
return [t, s] =
|
|
1169
|
+
return [t, s] = qt(n, t, "entity"), t--, [e, s, t];
|
|
1170
1170
|
}
|
|
1171
1171
|
function rr(n, t) {
|
|
1172
1172
|
t = q(n, t);
|
|
1173
1173
|
let e = "";
|
|
1174
1174
|
for (; t < n.length && !/\s/.test(n[t]); )
|
|
1175
1175
|
e += n[t], t++;
|
|
1176
|
-
|
|
1176
|
+
ze(e), t = q(n, t);
|
|
1177
1177
|
const s = n.substring(t, t + 6).toUpperCase();
|
|
1178
1178
|
if (s !== "SYSTEM" && s !== "PUBLIC")
|
|
1179
1179
|
throw new Error(`Expected SYSTEM or PUBLIC, found "${s}"`);
|
|
1180
1180
|
t += s.length, t = q(n, t);
|
|
1181
1181
|
let r = null, i = null;
|
|
1182
1182
|
if (s === "PUBLIC")
|
|
1183
|
-
[t, r] =
|
|
1184
|
-
else if (s === "SYSTEM" && ([t, i] =
|
|
1183
|
+
[t, r] = qt(n, t, "publicIdentifier"), t = q(n, t), (n[t] === '"' || n[t] === "'") && ([t, i] = qt(n, t, "systemIdentifier"));
|
|
1184
|
+
else if (s === "SYSTEM" && ([t, i] = qt(n, t, "systemIdentifier"), !i))
|
|
1185
1185
|
throw new Error("Missing mandatory system identifier for SYSTEM notation");
|
|
1186
1186
|
return { notationName: e, publicIdentifier: r, systemIdentifier: i, index: --t };
|
|
1187
1187
|
}
|
|
1188
|
-
function
|
|
1188
|
+
function qt(n, t, e) {
|
|
1189
1189
|
let s = "";
|
|
1190
1190
|
const r = n[t];
|
|
1191
1191
|
if (r !== '"' && r !== "'")
|
|
@@ -1201,7 +1201,7 @@ function ir(n, t) {
|
|
|
1201
1201
|
let e = "";
|
|
1202
1202
|
for (; t < n.length && !/\s/.test(n[t]); )
|
|
1203
1203
|
e += n[t], t++;
|
|
1204
|
-
if (!
|
|
1204
|
+
if (!ze(e))
|
|
1205
1205
|
throw new Error(`Invalid element name: "${e}"`);
|
|
1206
1206
|
if (t = q(n, t), n[t] !== "(")
|
|
1207
1207
|
throw new Error(`Expected '(', found "${n[t]}"`);
|
|
@@ -1232,8 +1232,8 @@ function lr(n, t) {
|
|
|
1232
1232
|
function ur(n, t) {
|
|
1233
1233
|
return n[t + 1] === "!" && n[t + 2] === "N" && n[t + 3] === "O" && n[t + 4] === "T" && n[t + 5] === "A" && n[t + 6] === "T" && n[t + 7] === "I" && n[t + 8] === "O" && n[t + 9] === "N";
|
|
1234
1234
|
}
|
|
1235
|
-
function
|
|
1236
|
-
if (
|
|
1235
|
+
function ze(n) {
|
|
1236
|
+
if (Le(n))
|
|
1237
1237
|
return n;
|
|
1238
1238
|
throw new Error(`Invalid entity name ${n}`);
|
|
1239
1239
|
}
|
|
@@ -1286,7 +1286,7 @@ function yr(n, t) {
|
|
|
1286
1286
|
if (window && window.parseInt) return window.parseInt(n, t);
|
|
1287
1287
|
throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
|
|
1288
1288
|
}
|
|
1289
|
-
function
|
|
1289
|
+
function $n(n) {
|
|
1290
1290
|
return typeof n == "function" ? n : Array.isArray(n) ? (t) => {
|
|
1291
1291
|
for (const e of n)
|
|
1292
1292
|
if (typeof e == "string" && t === e || e instanceof RegExp && e.test(t))
|
|
@@ -1316,7 +1316,7 @@ class mr {
|
|
|
1316
1316
|
inr: { regex: /&(inr|#8377);/g, val: "₹" },
|
|
1317
1317
|
num_dec: { regex: /&#([0-9]{1,7});/g, val: (e, s) => String.fromCodePoint(Number.parseInt(s, 10)) },
|
|
1318
1318
|
num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (e, s) => String.fromCodePoint(Number.parseInt(s, 16)) }
|
|
1319
|
-
}, this.addExternalEntities = wr, this.parseXml = Sr, this.parseTextData = br, this.resolveNameSpace = _r, this.buildAttributesMap = Ar, this.isItStopNode = Ir, this.replaceEntitiesValue = vr, this.readStopNodeData = kr, this.saveTextToParentTag = Tr, this.addChild = Nr, this.ignoreAttributesFn =
|
|
1319
|
+
}, this.addExternalEntities = wr, this.parseXml = Sr, this.parseTextData = br, this.resolveNameSpace = _r, this.buildAttributesMap = Ar, this.isItStopNode = Ir, this.replaceEntitiesValue = vr, this.readStopNodeData = kr, this.saveTextToParentTag = Tr, this.addChild = Nr, this.ignoreAttributesFn = $n(this.options.ignoreAttributes);
|
|
1320
1320
|
}
|
|
1321
1321
|
}
|
|
1322
1322
|
function wr(n) {
|
|
@@ -1333,7 +1333,7 @@ function br(n, t, e, s, r, i, o) {
|
|
|
1333
1333
|
if (n !== void 0 && (this.options.trimValues && !s && (n = n.trim()), n.length > 0)) {
|
|
1334
1334
|
o || (n = this.replaceEntitiesValue(n));
|
|
1335
1335
|
const a = this.options.tagValueProcessor(t, n, e, r, i);
|
|
1336
|
-
return a == null ? n : typeof a != typeof n || a !== n ? a : this.options.trimValues ?
|
|
1336
|
+
return a == null ? n : typeof a != typeof n || a !== n ? a : this.options.trimValues ? ve(n, this.options.parseTagValue, this.options.numberParseOptions) : n.trim() === n ? ve(n, this.options.parseTagValue, this.options.numberParseOptions) : n;
|
|
1337
1337
|
}
|
|
1338
1338
|
}
|
|
1339
1339
|
function _r(n) {
|
|
@@ -1358,7 +1358,7 @@ function Ar(n, t, e) {
|
|
|
1358
1358
|
if (this.options.transformAttributeName && (l = this.options.transformAttributeName(l)), l === "__proto__" && (l = "#__proto__"), c !== void 0) {
|
|
1359
1359
|
this.options.trimValues && (c = c.trim()), c = this.replaceEntitiesValue(c);
|
|
1360
1360
|
const u = this.options.attributeValueProcessor(a, c, t);
|
|
1361
|
-
u == null ? i[l] = c : typeof u != typeof c || u !== c ? i[l] = u : i[l] =
|
|
1361
|
+
u == null ? i[l] = c : typeof u != typeof c || u !== c ? i[l] = u : i[l] = ve(
|
|
1362
1362
|
c,
|
|
1363
1363
|
this.options.parseAttributeValue,
|
|
1364
1364
|
this.options.numberParseOptions
|
|
@@ -1395,7 +1395,7 @@ const Sr = function(n) {
|
|
|
1395
1395
|
let u = 0;
|
|
1396
1396
|
l && this.options.unpairedTags.indexOf(l) !== -1 ? (u = r.lastIndexOf(".", r.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : u = r.lastIndexOf("."), r = r.substring(0, u), e = this.tagsNodeStack.pop(), s = "", i = a;
|
|
1397
1397
|
} else if (n[i + 1] === "?") {
|
|
1398
|
-
let a =
|
|
1398
|
+
let a = Ne(n, i, !1, "?>");
|
|
1399
1399
|
if (!a) throw new Error("Pi Tag is not closed.");
|
|
1400
1400
|
if (s = this.saveTextToParentTag(s, e, r), !(this.options.ignoreDeclaration && a.tagName === "?xml" || this.options.ignorePiTags)) {
|
|
1401
1401
|
const c = new at(a.tagName);
|
|
@@ -1418,12 +1418,12 @@ const Sr = function(n) {
|
|
|
1418
1418
|
let l = this.parseTextData(c, e.tagname, r, !0, !1, !0, !0);
|
|
1419
1419
|
l == null && (l = ""), this.options.cdataPropName ? e.add(this.options.cdataPropName, [{ [this.options.textNodeName]: c }]) : e.add(this.options.textNodeName, l), i = a + 2;
|
|
1420
1420
|
} else {
|
|
1421
|
-
let a =
|
|
1421
|
+
let a = Ne(n, i, this.options.removeNSPrefix), c = a.tagName;
|
|
1422
1422
|
const l = a.rawTagName;
|
|
1423
1423
|
let u = a.tagExp, h = a.attrExpPresent, d = a.closeIndex;
|
|
1424
1424
|
this.options.transformTagName && (c = this.options.transformTagName(c)), e && s && e.tagname !== "!xml" && (s = this.saveTextToParentTag(s, e, r, !1));
|
|
1425
|
-
const
|
|
1426
|
-
|
|
1425
|
+
const g = e;
|
|
1426
|
+
g && this.options.unpairedTags.indexOf(g.tagname) !== -1 && (e = this.tagsNodeStack.pop(), r = r.substring(0, r.lastIndexOf("."))), c !== t.tagname && (r += r ? "." + c : c);
|
|
1427
1427
|
const f = i;
|
|
1428
1428
|
if (this.isItStopNode(this.options.stopNodes, r, c)) {
|
|
1429
1429
|
let m = "";
|
|
@@ -1436,8 +1436,8 @@ const Sr = function(n) {
|
|
|
1436
1436
|
if (!S) throw new Error(`Unexpected end of ${l}`);
|
|
1437
1437
|
i = S.i, m = S.tagContent;
|
|
1438
1438
|
}
|
|
1439
|
-
const
|
|
1440
|
-
c !== u && h && (
|
|
1439
|
+
const E = new at(c);
|
|
1440
|
+
c !== u && h && (E[":@"] = this.buildAttributesMap(u, r, c)), m && (m = this.parseTextData(m, c, r, !0, h, !0, !0)), r = r.substr(0, r.lastIndexOf(".")), E.add(this.options.textNodeName, m), this.addChild(e, E, r, f);
|
|
1441
1441
|
} else {
|
|
1442
1442
|
if (u.length > 0 && u.lastIndexOf("/") === u.length - 1) {
|
|
1443
1443
|
c[c.length - 1] === "/" ? (c = c.substr(0, c.length - 1), r = r.substr(0, r.length - 1), u = c) : u = u.substr(0, u.length - 1), this.options.transformTagName && (c = this.options.transformTagName(c));
|
|
@@ -1526,7 +1526,7 @@ function ht(n, t, e, s) {
|
|
|
1526
1526
|
throw new Error(s);
|
|
1527
1527
|
return r + t.length - 1;
|
|
1528
1528
|
}
|
|
1529
|
-
function
|
|
1529
|
+
function Ne(n, t, e, s = ">") {
|
|
1530
1530
|
const r = Or(n, t + 1, s);
|
|
1531
1531
|
if (!r) return;
|
|
1532
1532
|
let i = r.data;
|
|
@@ -1566,22 +1566,22 @@ function kr(n, t, e) {
|
|
|
1566
1566
|
else if (n.substr(e + 1, 2) === "![")
|
|
1567
1567
|
e = ht(n, "]]>", e, "StopNode is not closed.") - 2;
|
|
1568
1568
|
else {
|
|
1569
|
-
const i =
|
|
1569
|
+
const i = Ne(n, e, ">");
|
|
1570
1570
|
i && ((i && i.tagName) === t && i.tagExp[i.tagExp.length - 1] !== "/" && r++, e = i.closeIndex);
|
|
1571
1571
|
}
|
|
1572
1572
|
}
|
|
1573
|
-
function
|
|
1573
|
+
function ve(n, t, e) {
|
|
1574
1574
|
if (t && typeof n == "string") {
|
|
1575
1575
|
const s = n.trim();
|
|
1576
1576
|
return s === "true" ? !0 : s === "false" ? !1 : pr(n, e);
|
|
1577
1577
|
} else
|
|
1578
1578
|
return js(n) ? n : "";
|
|
1579
1579
|
}
|
|
1580
|
-
const
|
|
1580
|
+
const ye = at.getMetaDataSymbol();
|
|
1581
1581
|
function Cr(n, t) {
|
|
1582
|
-
return
|
|
1582
|
+
return Pn(n, t);
|
|
1583
1583
|
}
|
|
1584
|
-
function
|
|
1584
|
+
function Pn(n, t, e) {
|
|
1585
1585
|
let s;
|
|
1586
1586
|
const r = {};
|
|
1587
1587
|
for (let i = 0; i < n.length; i++) {
|
|
@@ -1593,9 +1593,9 @@ function $n(n, t, e) {
|
|
|
1593
1593
|
if (a === void 0)
|
|
1594
1594
|
continue;
|
|
1595
1595
|
if (o[a]) {
|
|
1596
|
-
let l =
|
|
1597
|
-
const u =
|
|
1598
|
-
o[
|
|
1596
|
+
let l = Pn(o[a], t, c);
|
|
1597
|
+
const u = Mr(l, t);
|
|
1598
|
+
o[ye] !== void 0 && (l[ye] = o[ye]), o[":@"] ? xr(l, o[":@"], c, t) : Object.keys(l).length === 1 && l[t.textNodeName] !== void 0 && !t.alwaysCreateTextNode ? l = l[t.textNodeName] : Object.keys(l).length === 0 && (t.alwaysCreateTextNode ? l[t.textNodeName] = "" : l = ""), r[a] !== void 0 && r.hasOwnProperty(a) ? (Array.isArray(r[a]) || (r[a] = [r[a]]), r[a].push(l)) : t.isArray(a, c, u) ? r[a] = [l] : r[a] = l;
|
|
1599
1599
|
}
|
|
1600
1600
|
}
|
|
1601
1601
|
}
|
|
@@ -1608,7 +1608,7 @@ function Rr(n) {
|
|
|
1608
1608
|
if (s !== ":@") return s;
|
|
1609
1609
|
}
|
|
1610
1610
|
}
|
|
1611
|
-
function
|
|
1611
|
+
function xr(n, t, e, s) {
|
|
1612
1612
|
if (t) {
|
|
1613
1613
|
const r = Object.keys(t), i = r.length;
|
|
1614
1614
|
for (let o = 0; o < i; o++) {
|
|
@@ -1617,7 +1617,7 @@ function Mr(n, t, e, s) {
|
|
|
1617
1617
|
}
|
|
1618
1618
|
}
|
|
1619
1619
|
}
|
|
1620
|
-
function
|
|
1620
|
+
function Mr(n, t) {
|
|
1621
1621
|
const { textNodeName: e } = t, s = Object.keys(n).length;
|
|
1622
1622
|
return !!(s === 0 || s === 1 && (n[e] || typeof n[e] == "boolean" || n[e] === 0));
|
|
1623
1623
|
}
|
|
@@ -1674,11 +1674,11 @@ class $r {
|
|
|
1674
1674
|
return at.getMetaDataSymbol();
|
|
1675
1675
|
}
|
|
1676
1676
|
}
|
|
1677
|
-
const
|
|
1677
|
+
const Pr = `
|
|
1678
1678
|
`;
|
|
1679
|
-
function
|
|
1679
|
+
function Hr(n, t) {
|
|
1680
1680
|
let e = "";
|
|
1681
|
-
return t.format && t.indentBy.length > 0 && (e =
|
|
1681
|
+
return t.format && t.indentBy.length > 0 && (e = Pr), Hn(n, t, "", e);
|
|
1682
1682
|
}
|
|
1683
1683
|
function Hn(n, t, e, s) {
|
|
1684
1684
|
let r = "", i = !1;
|
|
@@ -1688,7 +1688,7 @@ function Hn(n, t, e, s) {
|
|
|
1688
1688
|
let l = "";
|
|
1689
1689
|
if (e.length === 0 ? l = c : l = `${e}.${c}`, c === t.textNodeName) {
|
|
1690
1690
|
let f = a[c];
|
|
1691
|
-
Br(l, t) || (f = t.tagValueProcessor(c, f), f =
|
|
1691
|
+
Br(l, t) || (f = t.tagValueProcessor(c, f), f = Wn(f, t)), i && (r += s), r += f, i = !1;
|
|
1692
1692
|
continue;
|
|
1693
1693
|
} else if (c === t.cdataPropName) {
|
|
1694
1694
|
i && (r += s), r += `<![CDATA[${a[c][0][t.textNodeName]}]]>`, i = !1;
|
|
@@ -1697,15 +1697,15 @@ function Hn(n, t, e, s) {
|
|
|
1697
1697
|
r += s + `<!--${a[c][0][t.textNodeName]}-->`, i = !0;
|
|
1698
1698
|
continue;
|
|
1699
1699
|
} else if (c[0] === "?") {
|
|
1700
|
-
const f =
|
|
1701
|
-
let
|
|
1702
|
-
|
|
1700
|
+
const f = dn(a[":@"], t), m = c === "?xml" ? "" : s;
|
|
1701
|
+
let E = a[c][0][t.textNodeName];
|
|
1702
|
+
E = E.length !== 0 ? " " + E : "", r += m + `<${c}${E}${f}?>`, i = !0;
|
|
1703
1703
|
continue;
|
|
1704
1704
|
}
|
|
1705
1705
|
let u = s;
|
|
1706
1706
|
u !== "" && (u += t.indentBy);
|
|
1707
|
-
const h =
|
|
1708
|
-
t.unpairedTags.indexOf(c) !== -1 ? t.suppressUnpairedNode ? r += d + ">" : r += d + "/>" : (!
|
|
1707
|
+
const h = dn(a[":@"], t), d = s + `<${c}${h}`, g = Hn(a[c], t, l, u);
|
|
1708
|
+
t.unpairedTags.indexOf(c) !== -1 ? t.suppressUnpairedNode ? r += d + ">" : r += d + "/>" : (!g || g.length === 0) && t.suppressEmptyNode ? r += d + "/>" : g && g.endsWith(">") ? r += d + `>${g}${s}</${c}>` : (r += d + ">", g && s !== "" && (g.includes("/>") || g.includes("</")) ? r += s + t.indentBy + g + s : r += g, r += `</${c}>`), i = !0;
|
|
1709
1709
|
}
|
|
1710
1710
|
return r;
|
|
1711
1711
|
}
|
|
@@ -1717,13 +1717,13 @@ function Wr(n) {
|
|
|
1717
1717
|
return s;
|
|
1718
1718
|
}
|
|
1719
1719
|
}
|
|
1720
|
-
function
|
|
1720
|
+
function dn(n, t) {
|
|
1721
1721
|
let e = "";
|
|
1722
1722
|
if (n && !t.ignoreAttributes)
|
|
1723
1723
|
for (let s in n) {
|
|
1724
1724
|
if (!n.hasOwnProperty(s)) continue;
|
|
1725
1725
|
let r = t.attributeValueProcessor(s, n[s]);
|
|
1726
|
-
r =
|
|
1726
|
+
r = Wn(r, t), r === !0 && t.suppressBooleanAttributes ? e += ` ${s.substr(t.attributeNamePrefix.length)}` : e += ` ${s.substr(t.attributeNamePrefix.length)}="${r}"`;
|
|
1727
1727
|
}
|
|
1728
1728
|
return e;
|
|
1729
1729
|
}
|
|
@@ -1734,7 +1734,7 @@ function Br(n, t) {
|
|
|
1734
1734
|
if (t.stopNodes[s] === n || t.stopNodes[s] === "*." + e) return !0;
|
|
1735
1735
|
return !1;
|
|
1736
1736
|
}
|
|
1737
|
-
function
|
|
1737
|
+
function Wn(n, t) {
|
|
1738
1738
|
if (n && n.length > 0 && t.processEntities)
|
|
1739
1739
|
for (let e = 0; e < t.entities.length; e++) {
|
|
1740
1740
|
const s = t.entities[e];
|
|
@@ -1779,14 +1779,14 @@ const Dr = {
|
|
|
1779
1779
|
function nt(n) {
|
|
1780
1780
|
this.options = Object.assign({}, Dr, n), this.options.ignoreAttributes === !0 || this.options.attributesGroupName ? this.isAttribute = function() {
|
|
1781
1781
|
return !1;
|
|
1782
|
-
} : (this.ignoreAttributesFn =
|
|
1782
|
+
} : (this.ignoreAttributesFn = $n(this.options.ignoreAttributes), this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = zr), this.processTextOrObjNode = Kr, this.options.format ? (this.indentate = Lr, this.tagEndChar = `>
|
|
1783
1783
|
`, this.newLine = `
|
|
1784
1784
|
`) : (this.indentate = function() {
|
|
1785
1785
|
return "";
|
|
1786
1786
|
}, this.tagEndChar = ">", this.newLine = "");
|
|
1787
1787
|
}
|
|
1788
1788
|
nt.prototype.build = function(n) {
|
|
1789
|
-
return this.options.preserveOrder ?
|
|
1789
|
+
return this.options.preserveOrder ? Hr(n, this.options) : (Array.isArray(n) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (n = {
|
|
1790
1790
|
[this.options.arrayNodeName]: n
|
|
1791
1791
|
}), this.j2x(n, 0, []).val);
|
|
1792
1792
|
};
|
|
@@ -1913,7 +1913,7 @@ class yt {
|
|
|
1913
1913
|
left(...t) {
|
|
1914
1914
|
return `<${[
|
|
1915
1915
|
this.type,
|
|
1916
|
-
|
|
1916
|
+
Ln(this.attrs),
|
|
1917
1917
|
Jr(this.styles),
|
|
1918
1918
|
...t
|
|
1919
1919
|
].filter((e) => e != "").join(" ")}>`;
|
|
@@ -1941,7 +1941,7 @@ class yt {
|
|
|
1941
1941
|
return this.toString();
|
|
1942
1942
|
}
|
|
1943
1943
|
}
|
|
1944
|
-
class
|
|
1944
|
+
class Bn extends yt {
|
|
1945
1945
|
constructor(e) {
|
|
1946
1946
|
super("image");
|
|
1947
1947
|
_(this, "attrs", {});
|
|
@@ -1951,7 +1951,7 @@ class Wn extends yt {
|
|
|
1951
1951
|
return this.attrs.href = e, this;
|
|
1952
1952
|
}
|
|
1953
1953
|
}
|
|
1954
|
-
class
|
|
1954
|
+
class je extends yt {
|
|
1955
1955
|
constructor(e) {
|
|
1956
1956
|
super("use");
|
|
1957
1957
|
_(this, "attrs", {});
|
|
@@ -1964,7 +1964,7 @@ class ze extends yt {
|
|
|
1964
1964
|
return e == null ? e : `#${e}`;
|
|
1965
1965
|
}
|
|
1966
1966
|
}
|
|
1967
|
-
class
|
|
1967
|
+
class Dn extends yt {
|
|
1968
1968
|
constructor() {
|
|
1969
1969
|
super("rect");
|
|
1970
1970
|
_(this, "attrs", {});
|
|
@@ -1993,7 +1993,7 @@ class Nt extends yt {
|
|
|
1993
1993
|
return this._text;
|
|
1994
1994
|
}
|
|
1995
1995
|
}
|
|
1996
|
-
let
|
|
1996
|
+
let Kn = class extends yt {
|
|
1997
1997
|
constructor(e) {
|
|
1998
1998
|
super("symbol");
|
|
1999
1999
|
_(this, "raw");
|
|
@@ -2017,10 +2017,10 @@ class v extends yt {
|
|
|
2017
2017
|
return this.children.push(e), this;
|
|
2018
2018
|
}
|
|
2019
2019
|
rotate(e, s, r) {
|
|
2020
|
-
return this.rotateMatrix =
|
|
2020
|
+
return this.rotateMatrix = Hs(e, s, r), this;
|
|
2021
2021
|
}
|
|
2022
2022
|
translate(e, s) {
|
|
2023
|
-
return this.translateMatrix =
|
|
2023
|
+
return this.translateMatrix = Se(e, s), this;
|
|
2024
2024
|
}
|
|
2025
2025
|
center() {
|
|
2026
2026
|
return this.children.map((e) => e.toString()).join("");
|
|
@@ -2059,7 +2059,7 @@ class Ur extends yt {
|
|
|
2059
2059
|
return `<${[
|
|
2060
2060
|
this.type,
|
|
2061
2061
|
...jr,
|
|
2062
|
-
|
|
2062
|
+
Ln(this.attrs),
|
|
2063
2063
|
Gr(this.viewBox)
|
|
2064
2064
|
].filter((s) => s != "").join(" ")}>`;
|
|
2065
2065
|
}
|
|
@@ -2093,7 +2093,7 @@ class Ur extends yt {
|
|
|
2093
2093
|
function Fr() {
|
|
2094
2094
|
return new Ur();
|
|
2095
2095
|
}
|
|
2096
|
-
const Uo = Fr, Fo = v, Zo =
|
|
2096
|
+
const Uo = Fr, Fo = v, Zo = Bn, Go = je, Vo = Dn, Jo = Nt;
|
|
2097
2097
|
function Zr(n) {
|
|
2098
2098
|
return n.replace(/[A-Z]/g, (t) => "-" + t.toLowerCase());
|
|
2099
2099
|
}
|
|
@@ -2103,7 +2103,7 @@ function Gr(n) {
|
|
|
2103
2103
|
function Vr(n) {
|
|
2104
2104
|
return n == null ? "" : `transform="${Ws(n)}"`;
|
|
2105
2105
|
}
|
|
2106
|
-
function
|
|
2106
|
+
function Ln(n) {
|
|
2107
2107
|
return Object.entries(n).filter(([t, e]) => e !== void 0).map(([t, e]) => `${Zr(t)}="${e}"`).join(" ");
|
|
2108
2108
|
}
|
|
2109
2109
|
function Jr(n) {
|
|
@@ -2115,7 +2115,7 @@ function* Xr(n) {
|
|
|
2115
2115
|
ignoreAttributes: !1
|
|
2116
2116
|
}), s = t.parse(n);
|
|
2117
2117
|
for (const r of s.svg.symbol) {
|
|
2118
|
-
const i = e.build(r), o = new
|
|
2118
|
+
const i = e.build(r), o = new Kn(i);
|
|
2119
2119
|
for (const [a, c] of Object.entries(r))
|
|
2120
2120
|
a.startsWith("@_") && (o.attrs[a.substring(2)] = c);
|
|
2121
2121
|
yield o;
|
|
@@ -2131,8 +2131,8 @@ const j = (n, t) => {
|
|
|
2131
2131
|
}, 0);
|
|
2132
2132
|
return { width: n.tiles.reduce((a, c) => a + W(c, t).width, 0), height: i };
|
|
2133
2133
|
}, W = (n, t) => {
|
|
2134
|
-
const e = parseFloat((ft.HEIGHT * t).toPrecision(5)), s = parseFloat((ft.WIDTH * t).toPrecision(5)), r = n.has(
|
|
2135
|
-
return (n.has(
|
|
2134
|
+
const e = parseFloat((ft.HEIGHT * t).toPrecision(5)), s = parseFloat((ft.WIDTH * t).toPrecision(5)), r = n.has(y.HORIZONTAL) ? { width: e, height: s, baseWidth: s, baseHeight: e } : { width: s, height: e, w: s, baseWidth: s, baseHeight: e };
|
|
2135
|
+
return (n.has(y.TSUMO) || n.has(y.DORA)) && (r.width += s * ft.TEXT_SCALE), r;
|
|
2136
2136
|
};
|
|
2137
2137
|
class Tt {
|
|
2138
2138
|
constructor(t = {}) {
|
|
@@ -2150,8 +2150,8 @@ class Tt {
|
|
|
2150
2150
|
}
|
|
2151
2151
|
// image wrapper
|
|
2152
2152
|
image(t) {
|
|
2153
|
-
let e = new
|
|
2154
|
-
return this.svgSprite && (e = new
|
|
2153
|
+
let e = new Bn().load(this.buildURL(t));
|
|
2154
|
+
return this.svgSprite && (e = new je().use(Tt.buildID(t))), t instanceof w && t.has(y.COLOR_GRAYSCALE) && e.css({ filter: "contrast(65%)" }), e;
|
|
2155
2155
|
}
|
|
2156
2156
|
createImage(t, e, s) {
|
|
2157
2157
|
const r = W(t, this.scale);
|
|
@@ -2160,7 +2160,7 @@ class Tt {
|
|
|
2160
2160
|
createTextImage(t, e, s, r) {
|
|
2161
2161
|
const i = this.createImage(t, e, s), o = W(t, this.scale), a = o.baseHeight * 0.2, c = o.baseWidth, l = o.baseHeight, u = new Nt().plain(r);
|
|
2162
2162
|
u.size(o.baseWidth, o.baseHeight).font({
|
|
2163
|
-
family:
|
|
2163
|
+
family: In,
|
|
2164
2164
|
size: a
|
|
2165
2165
|
}).dx(c).dy(l);
|
|
2166
2166
|
const h = new v();
|
|
@@ -2176,7 +2176,7 @@ class Tt {
|
|
|
2176
2176
|
static buildID(t) {
|
|
2177
2177
|
if (t == 100 || t == 1e3)
|
|
2178
2178
|
return t == 100 ? "stick100" : "stick1000";
|
|
2179
|
-
const e = t.t == p.BACK || t.has(
|
|
2179
|
+
const e = t.t == p.BACK || t.has(y.RED) ? 0 : t.n;
|
|
2180
2180
|
return `${t.t}${e}`;
|
|
2181
2181
|
}
|
|
2182
2182
|
buildURL(t) {
|
|
@@ -2184,39 +2184,39 @@ class Tt {
|
|
|
2184
2184
|
return this.imageHostUrl != "" ? `${this.imageHostUrl}${e}` : e;
|
|
2185
2185
|
}
|
|
2186
2186
|
}
|
|
2187
|
-
class
|
|
2187
|
+
class zn extends Tt {
|
|
2188
2188
|
constructor() {
|
|
2189
2189
|
super(...arguments);
|
|
2190
2190
|
_(this, "blockMargin", ft.WIDTH * ft.BLOCK_MARGIN_SCALE * this.scale);
|
|
2191
2191
|
}
|
|
2192
2192
|
createBlockHandDiscard(e) {
|
|
2193
|
-
const s = e instanceof
|
|
2193
|
+
const s = e instanceof M ? e.tilesWithBack : e.tiles, r = new v();
|
|
2194
2194
|
let i = 0;
|
|
2195
2195
|
for (const o of s) {
|
|
2196
|
-
const a = W(o, this.scale), c = o.has(
|
|
2196
|
+
const a = W(o, this.scale), c = o.has(y.HORIZONTAL) ? this.createRotate90Image.bind(this) : this.createImage.bind(this), l = o.has(y.HORIZONTAL) ? this.getDiffTileHeightWidth(o) : 0, u = c(o, i, l);
|
|
2197
2197
|
r.add(u), i += a.width;
|
|
2198
2198
|
}
|
|
2199
2199
|
return r;
|
|
2200
2200
|
}
|
|
2201
2201
|
createBlockPonChiKan(e) {
|
|
2202
|
-
const s = e.tiles.findIndex((o) => o.has(
|
|
2202
|
+
const s = e.tiles.findIndex((o) => o.has(y.HORIZONTAL));
|
|
2203
2203
|
let r = 0;
|
|
2204
2204
|
const i = new v();
|
|
2205
2205
|
if (e.type == b.SHO_KAN) {
|
|
2206
2206
|
let o = s;
|
|
2207
2207
|
for (let a = 0; a < e.tiles.length; a++)
|
|
2208
|
-
e.tiles[a].has(
|
|
2208
|
+
e.tiles[a].has(y.HORIZONTAL) && (o = a);
|
|
2209
2209
|
for (let a = 0; a < e.tiles.length; a++) {
|
|
2210
2210
|
const c = W(e.tiles[a], this.scale);
|
|
2211
2211
|
if (a == o) continue;
|
|
2212
2212
|
if (a == s) {
|
|
2213
|
-
const h = e.tiles[s], d = e.tiles[o],
|
|
2213
|
+
const h = e.tiles[s], d = e.tiles[o], g = W(h, this.scale), f = this.createRotate90Image(h, 0, 0, !0), m = this.createRotate90Image(
|
|
2214
2214
|
d,
|
|
2215
2215
|
0,
|
|
2216
|
-
|
|
2216
|
+
g.height,
|
|
2217
2217
|
!0
|
|
2218
2218
|
);
|
|
2219
|
-
i.add(new v().translate(r, 0).add(f).add(m)), r +=
|
|
2219
|
+
i.add(new v().translate(r, 0).add(f).add(m)), r += g.width;
|
|
2220
2220
|
continue;
|
|
2221
2221
|
}
|
|
2222
2222
|
const l = c.width * 2 - c.height, u = this.createImage(e.tiles[a], r, l);
|
|
@@ -2266,19 +2266,19 @@ const Yr = (n, t) => {
|
|
|
2266
2266
|
},
|
|
2267
2267
|
[b.AN_KAN]: function(r) {
|
|
2268
2268
|
N(
|
|
2269
|
-
r instanceof
|
|
2269
|
+
r instanceof M,
|
|
2270
2270
|
`block type is not ankan: ${r.type}`
|
|
2271
2271
|
);
|
|
2272
2272
|
const i = j(r, e), o = n.createBlockHandDiscard(r);
|
|
2273
2273
|
return { ...i, e: o };
|
|
2274
2274
|
},
|
|
2275
2275
|
[b.IMAGE_DORA]: function(r) {
|
|
2276
|
-
r = (t == null ? void 0 : t.doraText) == !1 ? new
|
|
2276
|
+
r = (t == null ? void 0 : t.doraText) == !1 ? new Kt([r.tiles[0].clone({ remove: y.DORA })]) : r;
|
|
2277
2277
|
const i = j(r, e), o = new v(), a = (t == null ? void 0 : t.doraText) === !1 ? n.createImage(r.tiles[0], 0, 0) : n.createTextImage(r.tiles[0], 0, 0, "(ドラ)");
|
|
2278
2278
|
return o.add(a), { ...i, e: o };
|
|
2279
2279
|
},
|
|
2280
2280
|
[b.TSUMO]: function(r) {
|
|
2281
|
-
r = (t == null ? void 0 : t.tsumoText) == !1 ? new
|
|
2281
|
+
r = (t == null ? void 0 : t.tsumoText) == !1 ? new Kt([r.tiles[0].clone({ remove: y.TSUMO })]) : r;
|
|
2282
2282
|
const i = j(r, e), o = new v(), a = (t == null ? void 0 : t.tsumoText) === !1 ? n.createImage(r.tiles[0], 0, 0) : n.createTextImage(r.tiles[0], 0, 0, "(ツモ)");
|
|
2283
2283
|
return o.add(a), { ...i, e: o };
|
|
2284
2284
|
},
|
|
@@ -2303,7 +2303,7 @@ const Yr = (n, t) => {
|
|
|
2303
2303
|
throw new Error("isolated is unsupported");
|
|
2304
2304
|
},
|
|
2305
2305
|
[b.UNKNOWN]: function(r) {
|
|
2306
|
-
if (r.tiles.some((a) => a.has(
|
|
2306
|
+
if (r.tiles.some((a) => a.has(y.TSUMO) || a.has(y.DORA)))
|
|
2307
2307
|
throw new Error("found an unknown block with operator tiles");
|
|
2308
2308
|
const i = j(r, e), o = n.createBlockHandDiscard(r);
|
|
2309
2309
|
return { ...i, e: o };
|
|
@@ -2314,14 +2314,14 @@ const Yr = (n, t) => {
|
|
|
2314
2314
|
let r = 0, i = 0;
|
|
2315
2315
|
const o = [];
|
|
2316
2316
|
for (const h of t) {
|
|
2317
|
-
const d = s[h.type],
|
|
2318
|
-
i +=
|
|
2317
|
+
const d = s[h.type], g = d(h);
|
|
2318
|
+
i += g.width, r = g.height > r ? g.height : r, o.push(g);
|
|
2319
2319
|
}
|
|
2320
2320
|
const a = r, c = i + (t.length - 1) * n.blockMargin, l = new v();
|
|
2321
2321
|
let u = 0;
|
|
2322
2322
|
for (const h of o) {
|
|
2323
|
-
const d = a - h.height,
|
|
2324
|
-
|
|
2323
|
+
const d = a - h.height, g = new v().translate(u, d);
|
|
2324
|
+
g.add(h.e), l.add(g), u += h.width + n.blockMargin;
|
|
2325
2325
|
}
|
|
2326
2326
|
return { e: l, width: c, height: a };
|
|
2327
2327
|
}, Xo = (n, t, e = {}, s = {
|
|
@@ -2329,9 +2329,9 @@ const Yr = (n, t) => {
|
|
|
2329
2329
|
doraText: !0,
|
|
2330
2330
|
tsumoText: !0
|
|
2331
2331
|
}) => {
|
|
2332
|
-
const r = new
|
|
2332
|
+
const r = new zn(e), i = Wt(r, t, s);
|
|
2333
2333
|
s.responsive || n.size(i.width, i.height), n.viewbox(0, 0, i.width, i.height), n.add(i.e);
|
|
2334
|
-
},
|
|
2334
|
+
}, jn = () => {
|
|
2335
2335
|
const n = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], t = [];
|
|
2336
2336
|
for (const e of Object.values(p)) {
|
|
2337
2337
|
if (e == p.BACK) {
|
|
@@ -2344,19 +2344,19 @@ const Yr = (n, t) => {
|
|
|
2344
2344
|
}
|
|
2345
2345
|
return t;
|
|
2346
2346
|
}, qr = (n) => {
|
|
2347
|
-
const t =
|
|
2347
|
+
const t = jn(), e = [];
|
|
2348
2348
|
return n.each((s, r) => {
|
|
2349
2349
|
const i = r[s];
|
|
2350
|
-
if (i instanceof
|
|
2350
|
+
if (i instanceof je) {
|
|
2351
2351
|
const a = i.attr("href").substring(1);
|
|
2352
2352
|
t.includes(a) && e.push(a);
|
|
2353
2353
|
}
|
|
2354
2354
|
}, !0), e;
|
|
2355
2355
|
}, Yo = (n) => {
|
|
2356
|
-
const t =
|
|
2356
|
+
const t = jn(), e = qr(n);
|
|
2357
2357
|
n.each((s, r) => {
|
|
2358
2358
|
const i = r[s];
|
|
2359
|
-
i instanceof
|
|
2359
|
+
i instanceof Kn && (t.includes(i.id()) && e.includes(i.id()) || i.remove());
|
|
2360
2360
|
}, !0);
|
|
2361
2361
|
}, Qr = (n) => {
|
|
2362
2362
|
const e = [];
|
|
@@ -2380,11 +2380,11 @@ const Yr = (n, t) => {
|
|
|
2380
2380
|
return o.rotate(s, 0, e).translate(a, c), new v().add(o);
|
|
2381
2381
|
}
|
|
2382
2382
|
return new v().add(o);
|
|
2383
|
-
},
|
|
2383
|
+
}, Ut = (n, t) => {
|
|
2384
2384
|
const e = new v(), s = Qr(n);
|
|
2385
2385
|
for (let r = 0; r < s.length; r++) {
|
|
2386
2386
|
let i = s[r], o = r * t.tileHeight;
|
|
2387
|
-
const a = t.createBlockHandDiscard(new
|
|
2387
|
+
const a = t.createBlockHandDiscard(new Cn(i, b.IMAGE_DISCARD)).translate(0, o);
|
|
2388
2388
|
e.add(a);
|
|
2389
2389
|
}
|
|
2390
2390
|
return {
|
|
@@ -2393,23 +2393,23 @@ const Yr = (n, t) => {
|
|
|
2393
2393
|
height: t.tileHeight * s.length
|
|
2394
2394
|
};
|
|
2395
2395
|
}, ti = (n, t, e) => {
|
|
2396
|
-
const s = t.font, r = t.textWidth, i = t.textHeight, o = e.sticks.dead, a = e.sticks.reach, c =
|
|
2396
|
+
const s = t.font, r = t.textWidth, i = t.textHeight, o = e.sticks.dead, a = e.sticks.reach, c = nn.WIDTH * n.scale, l = nn.HEIGHT * n.scale;
|
|
2397
2397
|
let u = r * 3, h = i;
|
|
2398
|
-
const d = (c + n.tileWidth + r - u) / 2,
|
|
2398
|
+
const d = (c + n.tileWidth + r - u) / 2, g = new Nt().plain(e.round).font(s).x(d).y(0);
|
|
2399
2399
|
h += 25 * n.scale;
|
|
2400
|
-
const f = n.tileHeight, m = new v().size(c, f).translate(0, h),
|
|
2400
|
+
const f = n.tileHeight, m = new v().size(c, f).translate(0, h), E = { family: s.family, size: s.size * 0.7 }, S = n.createStick(1e3).size(c, l).x(0).y(0), O = new Nt().plain(a.toString()).font(E).dx(c).dy(l), R = n.createStick(100).size(c, l).x(0).y(l + l), mt = new Nt().plain(o.toString()).font(E).dx(c).dy(l * 3);
|
|
2401
2401
|
m.add(S), m.add(O), m.add(R), m.add(mt);
|
|
2402
2402
|
const wt = n.createImage(e.doras[0], 0, 0).x(c + r).y(0);
|
|
2403
2403
|
m.add(wt);
|
|
2404
2404
|
const bt = new v();
|
|
2405
|
-
return bt.add(
|
|
2405
|
+
return bt.add(g), bt.add(g), bt.add(m), {
|
|
2406
2406
|
e: bt,
|
|
2407
2407
|
width: c + n.tileWidth + r,
|
|
2408
2408
|
height: h + n.tileHeight
|
|
2409
2409
|
};
|
|
2410
2410
|
}, ei = (n, t, e = 0) => {
|
|
2411
2411
|
const s = Wt(n, t.front), r = Wt(n, t.right), i = Wt(n, t.opposite), o = Wt(n, t.left), a = [s.width, r.width, i.width, o.width].reduce(
|
|
2412
|
-
(m,
|
|
2412
|
+
(m, E) => Math.max(m, E)
|
|
2413
2413
|
), c = Math.max(
|
|
2414
2414
|
e + n.tileHeight * 2 + n.blockMargin * 2,
|
|
2415
2415
|
a + n.tileWidth * 2 + n.blockMargin
|
|
@@ -2422,13 +2422,13 @@ const Yr = (n, t) => {
|
|
|
2422
2422
|
), d = L(i.e, i.width, i.height, 180).translate(
|
|
2423
2423
|
(c - i.width) / 2,
|
|
2424
2424
|
0
|
|
2425
|
-
),
|
|
2425
|
+
), g = L(o.e, o.width, o.height, 90).translate(
|
|
2426
2426
|
0,
|
|
2427
2427
|
(c - o.width) / 2
|
|
2428
2428
|
), f = new v().size(c, l);
|
|
2429
|
-
return f.add(u), f.add(h), f.add(d), f.add(
|
|
2429
|
+
return f.add(u), f.add(h), f.add(d), f.add(g), { e: new v().add(f), width: c, height: l };
|
|
2430
2430
|
}, ni = (n) => {
|
|
2431
|
-
const t = Object.values(
|
|
2431
|
+
const t = Object.values(We), e = t.indexOf(n);
|
|
2432
2432
|
return [...t.slice(e), ...t.slice(0, e)];
|
|
2433
2433
|
}, si = (n, t, e) => {
|
|
2434
2434
|
const s = n.tileWidth * 5 + n.tileHeight * 1, r = t.font, i = t.textWidth, o = t.textHeight, a = t.numWidth, c = ti(n, t, e);
|
|
@@ -2436,16 +2436,16 @@ const Yr = (n, t) => {
|
|
|
2436
2436
|
s / 2 - c.width / 2,
|
|
2437
2437
|
s / 2 - c.height / 2
|
|
2438
2438
|
);
|
|
2439
|
-
const l = (ms,
|
|
2440
|
-
const bs = `${ms} ${
|
|
2439
|
+
const l = (ms, en, ws) => {
|
|
2440
|
+
const bs = `${ms} ${en}`, _s = new Nt().plain(bs).font(r).attr(ws);
|
|
2441
2441
|
return {
|
|
2442
2442
|
e: new v().add(_s),
|
|
2443
|
-
width: i + a *
|
|
2443
|
+
width: i + a * en.toString().length,
|
|
2444
2444
|
height: o
|
|
2445
2445
|
};
|
|
2446
|
-
}, [u, h, d,
|
|
2446
|
+
}, [u, h, d, g] = ni(
|
|
2447
2447
|
e.frontPlace
|
|
2448
|
-
), f = e.scores,
|
|
2448
|
+
), f = e.scores, E = l(u, f.front, {
|
|
2449
2449
|
x: s / 2,
|
|
2450
2450
|
y: s,
|
|
2451
2451
|
"dominant-baseline": "text-after-edge",
|
|
@@ -2467,34 +2467,34 @@ const Yr = (n, t) => {
|
|
|
2467
2467
|
s / 2 - R.width,
|
|
2468
2468
|
-R.height
|
|
2469
2469
|
);
|
|
2470
|
-
let wt = l(
|
|
2470
|
+
let wt = l(g, f.left, {
|
|
2471
2471
|
"dominant-baseline": "ideographic",
|
|
2472
2472
|
"text-anchor": "middle"
|
|
2473
2473
|
});
|
|
2474
2474
|
const bt = L(wt.e, wt.width, wt.height, 90).translate(
|
|
2475
2475
|
-wt.height,
|
|
2476
2476
|
s / 2
|
|
2477
|
-
), st = new v(), ys = new
|
|
2478
|
-
return st.add(ys), st.add(c.e), st.add(
|
|
2477
|
+
), st = new v(), ys = new Dn().size(s, s).x(0).y(0).fill("none").stroke("#000000");
|
|
2478
|
+
return st.add(ys), st.add(c.e), st.add(E), st.add(O), st.add(mt), st.add(bt), { e: st, width: s, height: s };
|
|
2479
2479
|
}, ri = (n, t) => {
|
|
2480
|
-
const e =
|
|
2480
|
+
const e = Ut(t.front, n), s = Ut(t.right, n), r = Ut(t.opposite, n), i = Ut(t.left, n), o = [e.height, s.height, r.height, i.height].reduce(
|
|
2481
2481
|
(O, R) => Math.max(O, R)
|
|
2482
|
-
), a = n.tileWidth * 5 + n.tileHeight * 1, c = o, l = a + o * 2 + n.blockMargin, u = l, h = new v().size(l, u), d = l / 2 - a / 2,
|
|
2482
|
+
), a = n.tileWidth * 5 + n.tileHeight * 1, c = o, l = a + o * 2 + n.blockMargin, u = l, h = new v().size(l, u), d = l / 2 - a / 2, g = u / 2 - a / 2, f = L(e.e, a, c, 0).translate(
|
|
2483
2483
|
d,
|
|
2484
2484
|
u - c
|
|
2485
2485
|
), m = L(s.e, a, c, 270).translate(
|
|
2486
2486
|
l - c,
|
|
2487
|
-
|
|
2488
|
-
),
|
|
2487
|
+
g
|
|
2488
|
+
), E = L(
|
|
2489
2489
|
r.e,
|
|
2490
2490
|
a,
|
|
2491
2491
|
c,
|
|
2492
2492
|
180
|
|
2493
2493
|
).translate(d, 0), S = L(i.e, a, c, 90).translate(
|
|
2494
2494
|
0,
|
|
2495
|
-
|
|
2495
|
+
g
|
|
2496
2496
|
);
|
|
2497
|
-
return h.add(f), h.add(m), h.add(
|
|
2497
|
+
return h.add(f), h.add(m), h.add(E), h.add(S), { e: new v().add(h), width: l, height: u };
|
|
2498
2498
|
}, ii = (n, t, e, s, r) => {
|
|
2499
2499
|
const i = new v(), o = ri(n, s), a = ei(n, e, o.height), c = si(n, t, r);
|
|
2500
2500
|
return o.e.translate(
|
|
@@ -2505,12 +2505,12 @@ const Yr = (n, t) => {
|
|
|
2505
2505
|
(a.height - c.height) / 2
|
|
2506
2506
|
), i.add(a.e), i.add(o.e), i.add(c.e), { e: i, width: a.width, height: a.height };
|
|
2507
2507
|
}, qo = (n, t, e = {}, s, r = { responsive: !1 }) => {
|
|
2508
|
-
const i = new
|
|
2508
|
+
const i = new zn(e), o = s, { discards: a, hands: c, scoreBoard: l } = gi(t), u = ii(i, o, c, a, l);
|
|
2509
2509
|
r.responsive || n.size(u.width, u.height), n.viewbox(0, 0, u.width, u.height), n.add(u.e);
|
|
2510
2510
|
};
|
|
2511
2511
|
var Z;
|
|
2512
2512
|
// @__NO_SIDE_EFFECTS__
|
|
2513
|
-
function
|
|
2513
|
+
function Un(n) {
|
|
2514
2514
|
return {
|
|
2515
2515
|
lang: (n == null ? void 0 : n.lang) ?? (Z == null ? void 0 : Z.lang),
|
|
2516
2516
|
message: n == null ? void 0 : n.message,
|
|
@@ -2518,21 +2518,21 @@ function jn(n) {
|
|
|
2518
2518
|
abortPipeEarly: (n == null ? void 0 : n.abortPipeEarly) ?? (Z == null ? void 0 : Z.abortPipeEarly)
|
|
2519
2519
|
};
|
|
2520
2520
|
}
|
|
2521
|
-
var
|
|
2521
|
+
var me;
|
|
2522
2522
|
// @__NO_SIDE_EFFECTS__
|
|
2523
2523
|
function oi(n) {
|
|
2524
|
-
return
|
|
2524
|
+
return me == null ? void 0 : me.get(n);
|
|
2525
2525
|
}
|
|
2526
|
-
var
|
|
2526
|
+
var we;
|
|
2527
2527
|
// @__NO_SIDE_EFFECTS__
|
|
2528
2528
|
function ai(n) {
|
|
2529
|
-
return
|
|
2529
|
+
return we == null ? void 0 : we.get(n);
|
|
2530
2530
|
}
|
|
2531
|
-
var
|
|
2531
|
+
var be;
|
|
2532
2532
|
// @__NO_SIDE_EFFECTS__
|
|
2533
2533
|
function ci(n, t) {
|
|
2534
2534
|
var e;
|
|
2535
|
-
return (e =
|
|
2535
|
+
return (e = be == null ? void 0 : be.get(n)) == null ? void 0 : e.get(t);
|
|
2536
2536
|
}
|
|
2537
2537
|
// @__NO_SIDE_EFFECTS__
|
|
2538
2538
|
function It(n) {
|
|
@@ -2566,7 +2566,7 @@ function $t(n) {
|
|
|
2566
2566
|
version: 1,
|
|
2567
2567
|
vendor: "valibot",
|
|
2568
2568
|
validate(t) {
|
|
2569
|
-
return n["~run"]({ value: t }, /* @__PURE__ */
|
|
2569
|
+
return n["~run"]({ value: t }, /* @__PURE__ */ Un());
|
|
2570
2570
|
}
|
|
2571
2571
|
};
|
|
2572
2572
|
}
|
|
@@ -2576,11 +2576,11 @@ function li(n, t) {
|
|
|
2576
2576
|
return e.length > 1 ? `(${e.join(` ${t} `)})` : e[0] ?? "never";
|
|
2577
2577
|
}
|
|
2578
2578
|
// @__NO_SIDE_EFFECTS__
|
|
2579
|
-
function
|
|
2579
|
+
function Te(n, t) {
|
|
2580
2580
|
return {
|
|
2581
2581
|
kind: "validation",
|
|
2582
2582
|
type: "max_value",
|
|
2583
|
-
reference:
|
|
2583
|
+
reference: Te,
|
|
2584
2584
|
async: !1,
|
|
2585
2585
|
expects: `<=${n instanceof Date ? n.toJSON() : /* @__PURE__ */ It(n)}`,
|
|
2586
2586
|
requirement: n,
|
|
@@ -2593,11 +2593,11 @@ function ve(n, t) {
|
|
|
2593
2593
|
};
|
|
2594
2594
|
}
|
|
2595
2595
|
// @__NO_SIDE_EFFECTS__
|
|
2596
|
-
function
|
|
2596
|
+
function Ie(n, t) {
|
|
2597
2597
|
return {
|
|
2598
2598
|
kind: "validation",
|
|
2599
2599
|
type: "min_value",
|
|
2600
|
-
reference:
|
|
2600
|
+
reference: Ie,
|
|
2601
2601
|
async: !1,
|
|
2602
2602
|
expects: `>=${n instanceof Date ? n.toJSON() : /* @__PURE__ */ It(n)}`,
|
|
2603
2603
|
requirement: n,
|
|
@@ -2620,7 +2620,7 @@ function ui(n, t, e) {
|
|
|
2620
2620
|
);
|
|
2621
2621
|
}
|
|
2622
2622
|
// @__NO_SIDE_EFFECTS__
|
|
2623
|
-
function
|
|
2623
|
+
function Fn(n, t, e) {
|
|
2624
2624
|
return typeof n.default == "function" ? (
|
|
2625
2625
|
// @ts-expect-error
|
|
2626
2626
|
n.default(t, e)
|
|
@@ -2630,11 +2630,11 @@ function Un(n, t, e) {
|
|
|
2630
2630
|
);
|
|
2631
2631
|
}
|
|
2632
2632
|
// @__NO_SIDE_EFFECTS__
|
|
2633
|
-
function
|
|
2633
|
+
function ne(n) {
|
|
2634
2634
|
return {
|
|
2635
2635
|
kind: "schema",
|
|
2636
2636
|
type: "number",
|
|
2637
|
-
reference:
|
|
2637
|
+
reference: ne,
|
|
2638
2638
|
expects: "number",
|
|
2639
2639
|
async: !1,
|
|
2640
2640
|
message: n,
|
|
@@ -2660,16 +2660,16 @@ function D(n, t) {
|
|
|
2660
2660
|
return /* @__PURE__ */ $t(this);
|
|
2661
2661
|
},
|
|
2662
2662
|
"~run"(e, s) {
|
|
2663
|
-
return e.value === void 0 && (this.default !== void 0 && (e.value = /* @__PURE__ */
|
|
2663
|
+
return e.value === void 0 && (this.default !== void 0 && (e.value = /* @__PURE__ */ Fn(this, e, s)), e.value === void 0) ? (e.typed = !0, e) : this.wrapped["~run"](e, s);
|
|
2664
2664
|
}
|
|
2665
2665
|
};
|
|
2666
2666
|
}
|
|
2667
2667
|
// @__NO_SIDE_EFFECTS__
|
|
2668
|
-
function
|
|
2668
|
+
function Oe(n, t) {
|
|
2669
2669
|
return {
|
|
2670
2670
|
kind: "schema",
|
|
2671
2671
|
type: "picklist",
|
|
2672
|
-
reference:
|
|
2672
|
+
reference: Oe,
|
|
2673
2673
|
expects: /* @__PURE__ */ li(n.map(It), "|"),
|
|
2674
2674
|
async: !1,
|
|
2675
2675
|
options: n,
|
|
@@ -2707,7 +2707,7 @@ function Ot(n, t) {
|
|
|
2707
2707
|
const c = o in r ? (
|
|
2708
2708
|
// @ts-expect-error
|
|
2709
2709
|
r[o]
|
|
2710
|
-
) : /* @__PURE__ */
|
|
2710
|
+
) : /* @__PURE__ */ Fn(a), l = a["~run"]({ value: c }, s);
|
|
2711
2711
|
if (l.issues) {
|
|
2712
2712
|
const u = {
|
|
2713
2713
|
type: "object",
|
|
@@ -2769,11 +2769,11 @@ function Ot(n, t) {
|
|
|
2769
2769
|
};
|
|
2770
2770
|
}
|
|
2771
2771
|
// @__NO_SIDE_EFFECTS__
|
|
2772
|
-
function
|
|
2772
|
+
function se(n) {
|
|
2773
2773
|
return {
|
|
2774
2774
|
kind: "schema",
|
|
2775
2775
|
type: "string",
|
|
2776
|
-
reference:
|
|
2776
|
+
reference: se,
|
|
2777
2777
|
expects: "string",
|
|
2778
2778
|
async: !1,
|
|
2779
2779
|
message: n,
|
|
@@ -2786,7 +2786,7 @@ function ne(n) {
|
|
|
2786
2786
|
};
|
|
2787
2787
|
}
|
|
2788
2788
|
// @__NO_SIDE_EFFECTS__
|
|
2789
|
-
function
|
|
2789
|
+
function fn(...n) {
|
|
2790
2790
|
return {
|
|
2791
2791
|
...n[0],
|
|
2792
2792
|
pipe: n,
|
|
@@ -2808,7 +2808,7 @@ function dn(...n) {
|
|
|
2808
2808
|
}
|
|
2809
2809
|
// @__NO_SIDE_EFFECTS__
|
|
2810
2810
|
function hi(n, t, e) {
|
|
2811
|
-
const s = n["~run"]({ value: t }, /* @__PURE__ */
|
|
2811
|
+
const s = n["~run"]({ value: t }, /* @__PURE__ */ Un(e));
|
|
2812
2812
|
return {
|
|
2813
2813
|
typed: s.typed,
|
|
2814
2814
|
success: !s.issues,
|
|
@@ -2816,45 +2816,45 @@ function hi(n, t, e) {
|
|
|
2816
2816
|
issues: s.issues
|
|
2817
2817
|
};
|
|
2818
2818
|
}
|
|
2819
|
-
const
|
|
2819
|
+
const Ft = /* @__PURE__ */ D(
|
|
2820
2820
|
/* @__PURE__ */ Ot({
|
|
2821
|
-
discard: /* @__PURE__ */ D(/* @__PURE__ */
|
|
2822
|
-
hand: /* @__PURE__ */ D(/* @__PURE__ */
|
|
2823
|
-
score: /* @__PURE__ */ D(/* @__PURE__ */
|
|
2821
|
+
discard: /* @__PURE__ */ D(/* @__PURE__ */ se(), ""),
|
|
2822
|
+
hand: /* @__PURE__ */ D(/* @__PURE__ */ se(), ""),
|
|
2823
|
+
score: /* @__PURE__ */ D(/* @__PURE__ */ ne(), 25e3)
|
|
2824
2824
|
}),
|
|
2825
2825
|
{ discard: "", hand: "", score: 25e3 }
|
|
2826
2826
|
), di = /* @__PURE__ */ Ot({
|
|
2827
|
-
[
|
|
2828
|
-
[
|
|
2829
|
-
[
|
|
2830
|
-
[
|
|
2827
|
+
[A.E]: Ft,
|
|
2828
|
+
[A.S]: Ft,
|
|
2829
|
+
[A.W]: Ft,
|
|
2830
|
+
[A.N]: Ft
|
|
2831
2831
|
}), rt = {
|
|
2832
2832
|
round: k.E1,
|
|
2833
2833
|
sticks: { reach: 0, dead: 0 },
|
|
2834
|
-
doras:
|
|
2835
|
-
front:
|
|
2834
|
+
doras: A.S,
|
|
2835
|
+
front: A.E
|
|
2836
2836
|
}, fi = /* @__PURE__ */ D(
|
|
2837
2837
|
/* @__PURE__ */ Ot({
|
|
2838
2838
|
round: /* @__PURE__ */ D(
|
|
2839
|
-
/* @__PURE__ */
|
|
2839
|
+
/* @__PURE__ */ Oe(Object.keys(On)),
|
|
2840
2840
|
rt.round
|
|
2841
2841
|
),
|
|
2842
2842
|
sticks: /* @__PURE__ */ D(
|
|
2843
2843
|
/* @__PURE__ */ Ot({
|
|
2844
2844
|
reach: /* @__PURE__ */ D(
|
|
2845
|
-
/* @__PURE__ */
|
|
2845
|
+
/* @__PURE__ */ fn(/* @__PURE__ */ ne(), /* @__PURE__ */ Ie(0, ""), /* @__PURE__ */ Te(9, "")),
|
|
2846
2846
|
rt.sticks.reach
|
|
2847
2847
|
),
|
|
2848
2848
|
dead: /* @__PURE__ */ D(
|
|
2849
|
-
/* @__PURE__ */
|
|
2849
|
+
/* @__PURE__ */ fn(/* @__PURE__ */ ne(), /* @__PURE__ */ Ie(0, ""), /* @__PURE__ */ Te(9, "")),
|
|
2850
2850
|
rt.sticks.dead
|
|
2851
2851
|
)
|
|
2852
2852
|
}),
|
|
2853
2853
|
rt.sticks
|
|
2854
2854
|
),
|
|
2855
|
-
doras: /* @__PURE__ */ D(/* @__PURE__ */
|
|
2855
|
+
doras: /* @__PURE__ */ D(/* @__PURE__ */ se(), rt.doras),
|
|
2856
2856
|
front: /* @__PURE__ */ D(
|
|
2857
|
-
/* @__PURE__ */
|
|
2857
|
+
/* @__PURE__ */ Oe(Object.keys(We)),
|
|
2858
2858
|
rt.front
|
|
2859
2859
|
)
|
|
2860
2860
|
}),
|
|
@@ -2878,7 +2878,7 @@ const Ut = /* @__PURE__ */ D(
|
|
|
2878
2878
|
if (!r.startsWith(t))
|
|
2879
2879
|
throw new Error(`input does not start with table: ${r}`);
|
|
2880
2880
|
const i = {};
|
|
2881
|
-
let o = [
|
|
2881
|
+
let o = [A.E, A.S, A.W, A.N, e];
|
|
2882
2882
|
for (; ; ) {
|
|
2883
2883
|
const a = s.shift();
|
|
2884
2884
|
if (a == null) break;
|
|
@@ -2936,8 +2936,8 @@ const Ut = /* @__PURE__ */ D(
|
|
|
2936
2936
|
opposite: new B(n[e.opposite].hand).parse(),
|
|
2937
2937
|
left: new B(n[e.left].hand).parse()
|
|
2938
2938
|
}, o = {
|
|
2939
|
-
round:
|
|
2940
|
-
frontPlace:
|
|
2939
|
+
round: On[n.board.round],
|
|
2940
|
+
frontPlace: We[t],
|
|
2941
2941
|
sticks: n.board.sticks,
|
|
2942
2942
|
doras: new B(n.board.doras).tiles(),
|
|
2943
2943
|
scores: {
|
|
@@ -2952,7 +2952,7 @@ const Ut = /* @__PURE__ */ D(
|
|
|
2952
2952
|
front: n,
|
|
2953
2953
|
right: St(n),
|
|
2954
2954
|
opposite: St(St(n)),
|
|
2955
|
-
left:
|
|
2955
|
+
left: De(n)
|
|
2956
2956
|
});
|
|
2957
2957
|
function* z(n) {
|
|
2958
2958
|
const t = n != null && n.filterBy && n.filterBy.length > 0 ? n == null ? void 0 : n.filterBy : Object.values(p);
|
|
@@ -2963,7 +2963,7 @@ function* z(n) {
|
|
|
2963
2963
|
yield [e, r];
|
|
2964
2964
|
}
|
|
2965
2965
|
}
|
|
2966
|
-
class
|
|
2966
|
+
class Ue {
|
|
2967
2967
|
constructor(t, e = !1) {
|
|
2968
2968
|
_(this, "data");
|
|
2969
2969
|
this.data = {
|
|
@@ -3004,24 +3004,24 @@ class je {
|
|
|
3004
3004
|
const t = [];
|
|
3005
3005
|
for (const [e, s] of z()) {
|
|
3006
3006
|
let r = this.get(e, s);
|
|
3007
|
-
e != p.Z && s == 5 && this.get(e, 0) > 0 && (r -= this.get(e, 0), t.push(new w(e, s, [
|
|
3007
|
+
e != p.Z && s == 5 && this.get(e, 0) > 0 && (r -= this.get(e, 0), t.push(new w(e, s, [y.RED])));
|
|
3008
3008
|
for (let i = 0; i < r; i++)
|
|
3009
3009
|
t.push(new w(e, s));
|
|
3010
3010
|
}
|
|
3011
3011
|
if (this.drawn != null) {
|
|
3012
3012
|
const e = this.drawn, s = t.findIndex(
|
|
3013
|
-
(r) => r.equals(e) && e.has(
|
|
3013
|
+
(r) => r.equals(e) && e.has(y.RED) == r.has(y.RED)
|
|
3014
3014
|
);
|
|
3015
3015
|
N(
|
|
3016
3016
|
s >= 0,
|
|
3017
3017
|
`hand has drawn: ${this.drawn} but no tile in hands: ${t.join("")}`
|
|
3018
|
-
), t[s] = t[s].clone({ add:
|
|
3018
|
+
), t[s] = t[s].clone({ add: y.TSUMO });
|
|
3019
3019
|
}
|
|
3020
3020
|
return t;
|
|
3021
3021
|
}
|
|
3022
3022
|
toString() {
|
|
3023
|
-
const t = this.called.length > 0 ? `${lt}${this.called.join(lt)}` : "", e = this.drawn ? `${lt}${this.drawn.toString()}` : "", s = this.hands.filter((i) => !i.has(
|
|
3024
|
-
return `${new
|
|
3023
|
+
const t = this.called.length > 0 ? `${lt}${this.called.join(lt)}` : "", e = this.drawn ? `${lt}${this.drawn.toString()}` : "", s = this.hands.filter((i) => !i.has(y.TSUMO));
|
|
3024
|
+
return `${new Kt(s).toString()}${e}${t}`;
|
|
3025
3025
|
}
|
|
3026
3026
|
get called() {
|
|
3027
3027
|
return this.data.called;
|
|
@@ -3033,7 +3033,7 @@ class je {
|
|
|
3033
3033
|
return this.data.tsumo;
|
|
3034
3034
|
}
|
|
3035
3035
|
get menzen() {
|
|
3036
|
-
return !this.called.some((t) => !(t instanceof
|
|
3036
|
+
return !this.called.some((t) => !(t instanceof M));
|
|
3037
3037
|
}
|
|
3038
3038
|
sum(t) {
|
|
3039
3039
|
let e = 0;
|
|
@@ -3046,29 +3046,29 @@ class je {
|
|
|
3046
3046
|
inc(t) {
|
|
3047
3047
|
const e = [];
|
|
3048
3048
|
for (const s of t) {
|
|
3049
|
-
if (s.t != p.BACK && this.get(s.t, s.n) >= 4 || s.has(
|
|
3049
|
+
if (s.t != p.BACK && this.get(s.t, s.n) >= 4 || s.has(y.RED) && this.get(s.t, 0) > 0)
|
|
3050
3050
|
throw this.dec(e), new Error(`unable to increase ${s} in ${this.toString()}`);
|
|
3051
|
-
e.push(s), s.t == p.BACK ? this.data[s.t][1] += 1 : (this.data[s.t][s.n] += 1, s.has(
|
|
3051
|
+
e.push(s), s.t == p.BACK ? this.data[s.t][1] += 1 : (this.data[s.t][s.n] += 1, s.has(y.RED) && (this.data[s.t][0] += 1));
|
|
3052
3052
|
}
|
|
3053
3053
|
return e;
|
|
3054
3054
|
}
|
|
3055
3055
|
dec(t) {
|
|
3056
3056
|
const e = [];
|
|
3057
3057
|
for (const s of t) {
|
|
3058
|
-
if (this.get(s.t, s.n) < 1 || s.has(
|
|
3058
|
+
if (this.get(s.t, s.n) < 1 || s.has(y.RED) && this.get(s.t, 0) <= 0)
|
|
3059
3059
|
throw this.inc(e), new Error(
|
|
3060
3060
|
`unable to decrease ${s.toString()} in ${this.toString()}`
|
|
3061
3061
|
);
|
|
3062
|
-
if (e.push(s), s.t == p.BACK ? this.data[s.t][1] -= 1 : (this.data[s.t][s.n] -= 1, s.has(
|
|
3062
|
+
if (e.push(s), s.t == p.BACK ? this.data[s.t][1] -= 1 : (this.data[s.t][s.n] -= 1, s.has(y.RED) && (this.data[s.t][0] -= 1)), C(s) && this.get(s.t, 5) == 0 && this.get(s.t, 0) > 0) {
|
|
3063
3063
|
this.data[s.t][0] = 0;
|
|
3064
|
-
const r = e.pop().clone({ add:
|
|
3064
|
+
const r = e.pop().clone({ add: y.RED });
|
|
3065
3065
|
e.push(r);
|
|
3066
3066
|
}
|
|
3067
3067
|
}
|
|
3068
3068
|
return e;
|
|
3069
3069
|
}
|
|
3070
3070
|
draw(t) {
|
|
3071
|
-
const e = t.clone({ add:
|
|
3071
|
+
const e = t.clone({ add: y.TSUMO });
|
|
3072
3072
|
this.inc([e]), this.data.tsumo = e;
|
|
3073
3073
|
}
|
|
3074
3074
|
discard(t) {
|
|
@@ -3080,13 +3080,13 @@ class je {
|
|
|
3080
3080
|
this.data.reached = !0;
|
|
3081
3081
|
}
|
|
3082
3082
|
call(t) {
|
|
3083
|
-
const e = t.tiles.filter((s) => !s.has(
|
|
3083
|
+
const e = t.tiles.filter((s) => !s.has(y.HORIZONTAL));
|
|
3084
3084
|
if (e.length != t.tiles.length - 1)
|
|
3085
3085
|
throw new Error(`removal: ${e} block: ${t}`);
|
|
3086
3086
|
this.dec(e), this.data.called = [...this.called, t], this.data.tsumo = null;
|
|
3087
3087
|
}
|
|
3088
3088
|
kan(t) {
|
|
3089
|
-
if (t instanceof
|
|
3089
|
+
if (t instanceof M) {
|
|
3090
3090
|
this.dec(t.tiles), this.data.called = [...this.called, t], this.data.tsumo = null;
|
|
3091
3091
|
return;
|
|
3092
3092
|
}
|
|
@@ -3097,7 +3097,7 @@ class je {
|
|
|
3097
3097
|
);
|
|
3098
3098
|
if (e == -1) throw new Error(`unable to find ${t.tiles[0]}`);
|
|
3099
3099
|
let s = t.tiles[0];
|
|
3100
|
-
s = C(s) ? s.clone({ remove:
|
|
3100
|
+
s = C(s) ? s.clone({ remove: y.RED }) : s, this.dec([s]), this.data.called = [
|
|
3101
3101
|
...this.called.slice(0, e),
|
|
3102
3102
|
...this.called.slice(e + 1),
|
|
3103
3103
|
t
|
|
@@ -3107,11 +3107,11 @@ class je {
|
|
|
3107
3107
|
throw new Error(`unexpected input ${t}`);
|
|
3108
3108
|
}
|
|
3109
3109
|
clone() {
|
|
3110
|
-
const t = new
|
|
3110
|
+
const t = new Ue(this.toString());
|
|
3111
3111
|
return t.data.reached = this.data.reached, t;
|
|
3112
3112
|
}
|
|
3113
3113
|
}
|
|
3114
|
-
class
|
|
3114
|
+
class de {
|
|
3115
3115
|
constructor(t) {
|
|
3116
3116
|
_(this, "hand");
|
|
3117
3117
|
this.hand = t;
|
|
@@ -3135,7 +3135,7 @@ class he {
|
|
|
3135
3135
|
let t = 0, e = 0;
|
|
3136
3136
|
for (const s of Object.values(p)) {
|
|
3137
3137
|
if (s == p.BACK) continue;
|
|
3138
|
-
const r = s == p.Z ?
|
|
3138
|
+
const r = s == p.Z ? Lt : V;
|
|
3139
3139
|
for (const i of r)
|
|
3140
3140
|
this.hand.get(s, i) >= 1 && t++, this.hand.get(s, i) >= 2 && e++;
|
|
3141
3141
|
}
|
|
@@ -3144,20 +3144,20 @@ class he {
|
|
|
3144
3144
|
fourSetsOnePair() {
|
|
3145
3145
|
const t = (s) => {
|
|
3146
3146
|
const r = [0, 0, 0];
|
|
3147
|
-
for (const [d,
|
|
3148
|
-
this.hand.get(d,
|
|
3147
|
+
for (const [d, g] of z({ filterBy: [p.Z] }))
|
|
3148
|
+
this.hand.get(d, g) >= 3 ? r[0]++ : this.hand.get(d, g) == 2 ? r[1]++ : this.hand.get(d, g) == 1 && r[2]++;
|
|
3149
3149
|
const i = [0, 0, 0], o = this.hand.get(p.BACK, 0), a = o % 3;
|
|
3150
3150
|
i[0] = Math.floor(o / 3), a == 2 ? i[1] = 1 : a == 1 && (i[2] = 1);
|
|
3151
3151
|
let c = 13;
|
|
3152
3152
|
const l = this.patternNumType(p.M), u = this.patternNumType(p.P), h = this.patternNumType(p.S);
|
|
3153
3153
|
for (const d of [l.patternA, l.patternB])
|
|
3154
|
-
for (const
|
|
3154
|
+
for (const g of [u.patternA, u.patternB])
|
|
3155
3155
|
for (const f of [h.patternA, h.patternB]) {
|
|
3156
3156
|
const m = [this.hand.called.length, 0, 0];
|
|
3157
3157
|
for (let S = 0; S < 3; S++)
|
|
3158
|
-
m[S] += d[S] +
|
|
3159
|
-
const
|
|
3160
|
-
|
|
3158
|
+
m[S] += d[S] + g[S] + f[S] + r[S] + i[S];
|
|
3159
|
+
const E = this.calcCommon(m[0], m[1], m[2], s);
|
|
3160
|
+
E < c && (c = E);
|
|
3161
3161
|
}
|
|
3162
3162
|
return c;
|
|
3163
3163
|
};
|
|
@@ -3218,17 +3218,17 @@ class Ai {
|
|
|
3218
3218
|
}
|
|
3219
3219
|
markDrawn(t, e) {
|
|
3220
3220
|
if (t.length == 0) return [];
|
|
3221
|
-
const s = this.hand.drawn != null || e.has(
|
|
3221
|
+
const s = this.hand.drawn != null || e.has(y.TSUMO) ? y.TSUMO : y.RON, r = [];
|
|
3222
3222
|
for (let o = 0; o < t.length; o++) {
|
|
3223
3223
|
const a = t[o], c = {};
|
|
3224
3224
|
for (let l = 0; l < a.length; l++) {
|
|
3225
3225
|
const u = a[l];
|
|
3226
3226
|
if (u.isCalled()) continue;
|
|
3227
3227
|
const h = u.tiles.findIndex(
|
|
3228
|
-
(
|
|
3228
|
+
(g) => g.equals(e) && e.has(y.RED) == g.has(y.RED)
|
|
3229
3229
|
);
|
|
3230
3230
|
if (h < 0) continue;
|
|
3231
|
-
const d =
|
|
3231
|
+
const d = Bt(u);
|
|
3232
3232
|
c[d] || (c[d] = !0, r.push([o, l, h]));
|
|
3233
3233
|
}
|
|
3234
3234
|
}
|
|
@@ -3252,7 +3252,7 @@ class Ai {
|
|
|
3252
3252
|
const r = this.hand.get(e, s);
|
|
3253
3253
|
if (r == 2) {
|
|
3254
3254
|
const i = this.hand.dec(new Array(2).fill(new w(e, s)));
|
|
3255
|
-
t.push(new
|
|
3255
|
+
t.push(new H(i[0], i[1])), this.hand.inc(i);
|
|
3256
3256
|
} else {
|
|
3257
3257
|
if (r == 0) continue;
|
|
3258
3258
|
return [];
|
|
@@ -3265,12 +3265,12 @@ class Ai {
|
|
|
3265
3265
|
let e = !1;
|
|
3266
3266
|
for (const s of Object.values(p)) {
|
|
3267
3267
|
if (s == p.BACK) continue;
|
|
3268
|
-
const r = s == p.Z ?
|
|
3268
|
+
const r = s == p.Z ? Lt : V;
|
|
3269
3269
|
for (let i of r)
|
|
3270
3270
|
if (this.hand.get(s, i) == 1)
|
|
3271
|
-
t.push(new
|
|
3271
|
+
t.push(new kn(new w(s, i)));
|
|
3272
3272
|
else if (this.hand.get(s, i) == 2 && e == !1)
|
|
3273
|
-
t.unshift(new
|
|
3273
|
+
t.unshift(new H(new w(s, i), new w(s, i))), e = !0;
|
|
3274
3274
|
else return [];
|
|
3275
3275
|
}
|
|
3276
3276
|
return [t];
|
|
@@ -3281,7 +3281,7 @@ class Ai {
|
|
|
3281
3281
|
if (e == p.BACK || e == p.Z) continue;
|
|
3282
3282
|
const s = t(e, 1, [3, 4]) && t(e, 9, [3, 4]) && t(e, 2, [1, 2]) && t(e, 3, [1, 2]) && t(e, 4, [1, 2]) && t(e, 5, [1, 2]) && t(e, 6, [1, 2]) && t(e, 7, [1, 2]) && t(e, 8, [1, 2]), r = this.hand.sum(e) == 14;
|
|
3283
3283
|
if (s && r)
|
|
3284
|
-
return [[new
|
|
3284
|
+
return [[new Kt(this.hand.hands)]];
|
|
3285
3285
|
}
|
|
3286
3286
|
return [];
|
|
3287
3287
|
}
|
|
@@ -3289,16 +3289,16 @@ class Ai {
|
|
|
3289
3289
|
let t = [];
|
|
3290
3290
|
for (const [e, s] of z())
|
|
3291
3291
|
if (this.hand.get(e, s) >= 2) {
|
|
3292
|
-
const r = this.hand.dec(new Array(2).fill(new w(e, s))), i = this.patternAll().filter((o) => o.length == 4).map((o) => (o.unshift(new
|
|
3292
|
+
const r = this.hand.dec(new Array(2).fill(new w(e, s))), i = this.patternAll().filter((o) => o.length == 4).map((o) => (o.unshift(new H(r[0], r[1])), o));
|
|
3293
3293
|
t = [...t, ...i], this.hand.inc(r);
|
|
3294
3294
|
}
|
|
3295
3295
|
return t;
|
|
3296
3296
|
}
|
|
3297
3297
|
patternAll() {
|
|
3298
3298
|
const t = [
|
|
3299
|
-
this.handleNumType(p.M),
|
|
3300
|
-
this.handleNumType(p.P),
|
|
3301
|
-
this.handleNumType(p.S),
|
|
3299
|
+
this.addRedPattern(p.M, this.handleNumType(new w(p.M, 1))),
|
|
3300
|
+
this.addRedPattern(p.P, this.handleNumType(new w(p.P, 1))),
|
|
3301
|
+
this.addRedPattern(p.S, this.handleNumType(new w(p.S, 1))),
|
|
3302
3302
|
this.handleZ(),
|
|
3303
3303
|
this.handleBack(),
|
|
3304
3304
|
[this.hand.called.concat()]
|
|
@@ -3326,32 +3326,65 @@ class Ai {
|
|
|
3326
3326
|
}
|
|
3327
3327
|
return t.length == 0 ? [] : [t];
|
|
3328
3328
|
}
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
if (this.hand.get(t,
|
|
3332
|
-
const s = [];
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3329
|
+
// TODO similar to markDrawn
|
|
3330
|
+
addRedPattern(t, e) {
|
|
3331
|
+
if (!(this.hand.get(t, 0) > 0 && this.hand.get(t, 5) >= 2)) return e;
|
|
3332
|
+
const s = new w(t, 5), r = new w(t, 5, [y.RED]), i = [];
|
|
3333
|
+
let o = [-1, -1, -1];
|
|
3334
|
+
for (let c = 0; c < e.length; c++) {
|
|
3335
|
+
const l = e[c], u = {};
|
|
3336
|
+
for (let h = 0; h < l.length; h++) {
|
|
3337
|
+
const d = l[h], g = d.tiles.findIndex(
|
|
3338
|
+
(E) => E.equals(s) && !E.has(y.RED)
|
|
3339
|
+
), f = d.tiles.findIndex((E) => E.equals(r) && E.has(y.RED));
|
|
3340
|
+
if (f > -1 && (o = [c, h, f]), f > -1 && g > -1 || g < 0) continue;
|
|
3341
|
+
const m = Bt(d);
|
|
3342
|
+
u[m] || (u[m] = !0, i.push([c, h, g]));
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
const a = [];
|
|
3346
|
+
for (const [c, l, u] of i) {
|
|
3347
|
+
const d = [...e[c]], g = d[l];
|
|
3348
|
+
d[l] = g.clone({
|
|
3349
|
+
replace: { idx: u, tile: r }
|
|
3350
|
+
});
|
|
3351
|
+
const f = d[o[1]];
|
|
3352
|
+
d[o[1]] = f.clone({
|
|
3353
|
+
replace: { idx: o[2], tile: s }
|
|
3354
|
+
}), Bt(g) != Bt(f) && a.push(d);
|
|
3355
|
+
}
|
|
3356
|
+
return [...e, ...a];
|
|
3357
|
+
}
|
|
3358
|
+
handleNumType(t) {
|
|
3359
|
+
const { t: e, n: s } = t;
|
|
3360
|
+
if (![p.M, p.S, p.P].some((i) => i != e))
|
|
3361
|
+
throw new Error(`unexpected type ${t}`);
|
|
3362
|
+
if (s > 9) return [];
|
|
3363
|
+
if (this.hand.get(e, s) == 0)
|
|
3364
|
+
return this.handleNumType(new w(e, s + 1));
|
|
3365
|
+
const r = [];
|
|
3366
|
+
if (s <= 7 && this.hand.get(e, s) > 0 && this.hand.get(e, s + 1) > 0 && this.hand.get(e, s + 2) > 0) {
|
|
3367
|
+
const i = this.hand.dec([
|
|
3368
|
+
new w(e, s),
|
|
3369
|
+
new w(e, s + 1),
|
|
3370
|
+
new w(e, s + 2)
|
|
3338
3371
|
]);
|
|
3339
|
-
let
|
|
3340
|
-
this.hand.inc(
|
|
3341
|
-
for (const
|
|
3342
|
-
|
|
3372
|
+
let o = this.handleNumType(t);
|
|
3373
|
+
this.hand.inc(i), o.length == 0 && (o = [[]]);
|
|
3374
|
+
for (const a of o)
|
|
3375
|
+
a.unshift(new ut([i[0], i[1], i[2]])), r.push(a);
|
|
3343
3376
|
}
|
|
3344
|
-
if (this.hand.get(
|
|
3345
|
-
const
|
|
3346
|
-
let
|
|
3347
|
-
this.hand.inc(
|
|
3348
|
-
for (const
|
|
3349
|
-
|
|
3377
|
+
if (this.hand.get(e, s) == 3) {
|
|
3378
|
+
const i = this.hand.dec(new Array(3).fill(new w(e, s)));
|
|
3379
|
+
let o = this.handleNumType(t);
|
|
3380
|
+
this.hand.inc(i), o.length == 0 && (o = [[]]);
|
|
3381
|
+
for (const a of o)
|
|
3382
|
+
a.unshift(new F([i[0], i[1], i[2]])), r.push(a);
|
|
3350
3383
|
}
|
|
3351
|
-
return
|
|
3384
|
+
return r;
|
|
3352
3385
|
}
|
|
3353
3386
|
}
|
|
3354
|
-
const
|
|
3387
|
+
const Lt = [1, 2, 3, 4, 5, 6, 7], V = [1, 9], Zt = (n) => {
|
|
3355
3388
|
var e;
|
|
3356
3389
|
const t = n.boardContext;
|
|
3357
3390
|
return {
|
|
@@ -3364,14 +3397,14 @@ const Kt = [1, 2, 3, 4, 5, 6, 7], V = [1, 9], Ft = (n) => {
|
|
|
3364
3397
|
}
|
|
3365
3398
|
};
|
|
3366
3399
|
};
|
|
3367
|
-
class
|
|
3400
|
+
class pn {
|
|
3368
3401
|
constructor(t, e) {
|
|
3369
3402
|
_(this, "hand");
|
|
3370
3403
|
_(this, "cfg");
|
|
3371
3404
|
this.hand = t, this.cfg = {
|
|
3372
|
-
doras: e.doraMarkers.map((s) =>
|
|
3405
|
+
doras: e.doraMarkers.map((s) => yn(s)),
|
|
3373
3406
|
// convert to dora
|
|
3374
|
-
blindDoras: e.blindDoraMarkers == null ? [] : e.blindDoraMarkers.map((s) =>
|
|
3407
|
+
blindDoras: e.blindDoraMarkers == null ? [] : e.blindDoraMarkers.map((s) => yn(s)),
|
|
3375
3408
|
roundWind: w.from(e.round.substring(0, 2)),
|
|
3376
3409
|
myWind: w.from(e.myWind),
|
|
3377
3410
|
reached: e.reached ?? 0,
|
|
@@ -3390,11 +3423,8 @@ class fn {
|
|
|
3390
3423
|
if (e.length == 0) return !1;
|
|
3391
3424
|
let s = [0, 0], r = 0;
|
|
3392
3425
|
for (let f = 0; f < e.length; f++) {
|
|
3393
|
-
const m = e[f],
|
|
3394
|
-
|
|
3395
|
-
0
|
|
3396
|
-
);
|
|
3397
|
-
A > s[0] ? (r = f, s = [A, m.fu]) : A == s[0] && m.fu > s[1] && (r = f, s = [A, m.fu]);
|
|
3426
|
+
const m = e[f], E = m.points.reduce((S, O) => S + O.double, 0);
|
|
3427
|
+
E > s[0] ? (r = f, s = [E, m.fu]) : E == s[0] && m.fu > s[1] && (r = f, s = [E, m.fu]);
|
|
3398
3428
|
}
|
|
3399
3429
|
const i = (f, m = 100) => Math.ceil(f / m) * m, o = s[1] != 25 ? i(s[1], 10) : 25, a = s[0];
|
|
3400
3430
|
let c = Math.min(o * 2 ** (a + 2), 2e3);
|
|
@@ -3424,25 +3454,25 @@ class fn {
|
|
|
3424
3454
|
}
|
|
3425
3455
|
a > 13 && a < 26 && (c = 8e3), this.cfg.roundUp8000 && (o == 30 && a == 4 || o == 60 && a == 3) && (c = 2e3);
|
|
3426
3456
|
const l = e[r].hand.some(
|
|
3427
|
-
(f) => f.tiles.some((m) => m.has(
|
|
3428
|
-
), u = this.cfg.orig.myWind, h = u ==
|
|
3457
|
+
(f) => f.tiles.some((m) => m.has(y.TSUMO))
|
|
3458
|
+
), u = this.cfg.orig.myWind, h = u == A.E, d = P(0);
|
|
3429
3459
|
if (l) {
|
|
3430
3460
|
const f = this.cfg.sticks.dead * 100;
|
|
3431
3461
|
if (h) {
|
|
3432
3462
|
const m = i(c * 2);
|
|
3433
|
-
d[
|
|
3463
|
+
d[A.E] += m * 3 + f * 3, d[A.S] -= m + f, d[A.W] -= m + f, d[A.N] -= m + f;
|
|
3434
3464
|
} else
|
|
3435
|
-
for (const m of Object.values(
|
|
3465
|
+
for (const m of Object.values(A)) {
|
|
3436
3466
|
if (m == u) continue;
|
|
3437
|
-
const
|
|
3467
|
+
const E = m == A.E ? 2 : 1, S = i(c * E) + f;
|
|
3438
3468
|
d[m] -= S, d[u] += S;
|
|
3439
3469
|
}
|
|
3440
3470
|
} else {
|
|
3441
3471
|
const f = this.cfg.sticks.dead * 300;
|
|
3442
3472
|
if (this.cfg.orig.ronWind == null)
|
|
3443
3473
|
throw new Error("ron wind is not specified in the parameters");
|
|
3444
|
-
const
|
|
3445
|
-
d[u] +=
|
|
3474
|
+
const E = i(c * (h ? 6 : 4)) + f;
|
|
3475
|
+
d[u] += E, d[this.cfg.orig.ronWind] -= E;
|
|
3446
3476
|
}
|
|
3447
3477
|
return d[u] += 1e3 * this.cfg.sticks.reach, {
|
|
3448
3478
|
deltas: d,
|
|
@@ -3521,12 +3551,12 @@ class fn {
|
|
|
3521
3551
|
return this.cfg.reached == 1 ? [{ name: "立直", double: 1 }] : this.cfg.reached == 2 ? [{ name: "ダブル立直", double: 2 }] : [];
|
|
3522
3552
|
}
|
|
3523
3553
|
dB1(t) {
|
|
3524
|
-
return this.minus() != 0 ? [] : (this.hand.drawn == null, t.some((s) => s.tiles.some((r) => r.has(
|
|
3554
|
+
return this.minus() != 0 ? [] : (this.hand.drawn == null, t.some((s) => s.tiles.some((r) => r.has(y.TSUMO))) ? [{ name: "門前清自摸和", double: 1 }] : []);
|
|
3525
3555
|
}
|
|
3526
3556
|
dC1(t) {
|
|
3527
3557
|
if (this.minus() != 0) return [];
|
|
3528
3558
|
const e = "平和", s = this.calcFu(t);
|
|
3529
|
-
return s == 20 ? [{ name: e, double: 1 }] : !t.some((r) => r.tiles.some((i) => i.has(
|
|
3559
|
+
return s == 20 ? [{ name: e, double: 1 }] : !t.some((r) => r.tiles.some((i) => i.has(y.TSUMO))) && s == 30 ? [{ name: e, double: 1 }] : [];
|
|
3530
3560
|
}
|
|
3531
3561
|
dD1(t) {
|
|
3532
3562
|
return t.some(
|
|
@@ -3534,12 +3564,12 @@ class fn {
|
|
|
3534
3564
|
) ? [] : [{ name: "断么九", double: 1 }];
|
|
3535
3565
|
}
|
|
3536
3566
|
dE1(t) {
|
|
3537
|
-
return this.minus() != 0 ? [] :
|
|
3567
|
+
return this.minus() != 0 ? [] : gn(t) == 1 ? [{ name: "一盃口", double: 1 }] : [];
|
|
3538
3568
|
}
|
|
3539
3569
|
dF1(t) {
|
|
3540
3570
|
const e = [];
|
|
3541
3571
|
return t.forEach((s) => {
|
|
3542
|
-
if (s instanceof
|
|
3572
|
+
if (s instanceof H) return;
|
|
3543
3573
|
const r = s.tiles[0];
|
|
3544
3574
|
r.t == p.Z && (r.equals(this.cfg.myWind) && e.push({ name: "自風", double: 1 }), r.equals(this.cfg.roundWind) ? e.push({ name: "場風", double: 1 }) : r.n == 5 ? e.push({ name: "白", double: 1 }) : r.n == 6 ? e.push({ name: "發", double: 1 }) : r.n == 7 && e.push({ name: "中", double: 1 }));
|
|
3545
3575
|
}), e;
|
|
@@ -3565,7 +3595,7 @@ class fn {
|
|
|
3565
3595
|
for (const a of o.tiles) {
|
|
3566
3596
|
for (const c of this.cfg.doras) a.equals(c) && e++;
|
|
3567
3597
|
for (const c of this.cfg.blindDoras) a.equals(c) && s++;
|
|
3568
|
-
a.has(
|
|
3598
|
+
a.has(y.RED) && r++;
|
|
3569
3599
|
}
|
|
3570
3600
|
const i = [];
|
|
3571
3601
|
return e > 0 && i.push({ name: "ドラ", double: e }), r > 0 && i.push({ name: "赤ドラ", double: r }), this.hand.reached && s > 0 && i.push({ name: "裏ドラ", double: s }), i;
|
|
@@ -3593,19 +3623,19 @@ class fn {
|
|
|
3593
3623
|
}
|
|
3594
3624
|
dC2(t) {
|
|
3595
3625
|
return t.length == 7 ? [] : t.every(
|
|
3596
|
-
(s) => s instanceof
|
|
3626
|
+
(s) => s instanceof M || s instanceof K || s instanceof Y || s instanceof F || s instanceof X || s instanceof H
|
|
3597
3627
|
) ? [{ name: "対々和", double: 2 }] : [];
|
|
3598
3628
|
}
|
|
3599
3629
|
dD2(t) {
|
|
3600
|
-
return t.filter((s) => (s instanceof
|
|
3630
|
+
return t.filter((s) => (s instanceof M || s instanceof F) && !s.tiles.some((r) => r.has(y.RON))).length >= 3 ? [{ name: "三暗刻", double: 2 }] : [];
|
|
3601
3631
|
}
|
|
3602
3632
|
dE2(t) {
|
|
3603
3633
|
return t.filter(
|
|
3604
|
-
(s) => s instanceof
|
|
3634
|
+
(s) => s instanceof M || s instanceof K || s instanceof Y
|
|
3605
3635
|
).length >= 3 ? [{ name: "三槓子", double: 2 }] : [];
|
|
3606
3636
|
}
|
|
3607
3637
|
dF2(t) {
|
|
3608
|
-
const e = (s) => s instanceof
|
|
3638
|
+
const e = (s) => s instanceof M || s instanceof K || s instanceof Y || s instanceof F || s instanceof X;
|
|
3609
3639
|
for (const s of t) {
|
|
3610
3640
|
if (!e(s)) continue;
|
|
3611
3641
|
const r = it(s);
|
|
@@ -3629,13 +3659,13 @@ class fn {
|
|
|
3629
3659
|
}
|
|
3630
3660
|
dH2(t) {
|
|
3631
3661
|
return t.every((s) => {
|
|
3632
|
-
const r = s.tiles[0].t == p.Z ?
|
|
3662
|
+
const r = s.tiles[0].t == p.Z ? Lt : V;
|
|
3633
3663
|
return s.tiles.every((i) => r.includes(i.n));
|
|
3634
3664
|
}) ? [{ name: "混老頭", double: 2 }] : [];
|
|
3635
3665
|
}
|
|
3636
3666
|
dI2(t) {
|
|
3637
3667
|
return t.length == 7 ? [] : t.some((s) => s instanceof ut || s instanceof J) ? t.some((s) => s.tiles[0].t == p.Z) ? t.every((s) => {
|
|
3638
|
-
const r = s.tiles[0].t == p.Z ?
|
|
3668
|
+
const r = s.tiles[0].t == p.Z ? Lt : V;
|
|
3639
3669
|
return s.tiles.some((i) => r.includes(i.n));
|
|
3640
3670
|
}) ? [{ name: "混全帯么九", double: 2 - this.minus() }] : [] : [] : [];
|
|
3641
3671
|
}
|
|
@@ -3665,7 +3695,7 @@ class fn {
|
|
|
3665
3695
|
return t.length == 7 ? [] : t.some((s) => s instanceof ut || s instanceof J) ? t.some((s) => s.tiles[0].t == p.Z) ? [] : t.every((s) => s.tiles.some((r) => V.includes(r.n))) ? [{ name: "純全帯么九色", double: 3 - this.minus() }] : [] : [];
|
|
3666
3696
|
}
|
|
3667
3697
|
dC3(t) {
|
|
3668
|
-
return this.minus() != 0 ? [] :
|
|
3698
|
+
return this.minus() != 0 ? [] : gn(t) == 2 ? [{ name: "ニ盃口", double: 3 }] : [];
|
|
3669
3699
|
}
|
|
3670
3700
|
dA6(t) {
|
|
3671
3701
|
if (t.some((e) => e.tiles[0].t == p.Z)) return [];
|
|
@@ -3677,7 +3707,7 @@ class fn {
|
|
|
3677
3707
|
}
|
|
3678
3708
|
dA13(t) {
|
|
3679
3709
|
return t.length != 13 ? [] : t.some(
|
|
3680
|
-
(s) => s instanceof
|
|
3710
|
+
(s) => s instanceof H && s.tiles.some((r) => r.has(y.TSUMO) || r.has(y.RON))
|
|
3681
3711
|
) ? [{ name: "国士無双13面待ち", double: 26 }] : [{ name: "国士無双", double: 13 }];
|
|
3682
3712
|
}
|
|
3683
3713
|
dB13(t) {
|
|
@@ -3685,16 +3715,16 @@ class fn {
|
|
|
3685
3715
|
}
|
|
3686
3716
|
dC13(t) {
|
|
3687
3717
|
return t.length == 7 ? [] : t.every(
|
|
3688
|
-
(r) => r instanceof
|
|
3718
|
+
(r) => r instanceof M || r instanceof F && !r.tiles.some((i) => i.has(y.RON)) || r instanceof H
|
|
3689
3719
|
) ? t.some(
|
|
3690
|
-
(r) => r instanceof
|
|
3720
|
+
(r) => r instanceof H && r.tiles.every((i) => i.has(y.TSUMO) || i.has(y.RON))
|
|
3691
3721
|
) ? [{ name: "四暗刻単騎待ち", double: 26 }] : [{ name: "四暗刻", double: 13 }] : [];
|
|
3692
3722
|
}
|
|
3693
3723
|
dD13(t) {
|
|
3694
3724
|
if (t.length == 13) return [];
|
|
3695
3725
|
const e = [5, 6, 7];
|
|
3696
3726
|
return t.filter(
|
|
3697
|
-
(r) => !(r instanceof
|
|
3727
|
+
(r) => !(r instanceof H) && r.tiles.some((i) => i.t == p.Z && e.includes(i.n))
|
|
3698
3728
|
).length == 3 ? [{ name: "大三元", double: 13 }] : [];
|
|
3699
3729
|
}
|
|
3700
3730
|
dE13(t) {
|
|
@@ -3707,14 +3737,14 @@ class fn {
|
|
|
3707
3737
|
}
|
|
3708
3738
|
dG13(t) {
|
|
3709
3739
|
return t.filter(
|
|
3710
|
-
(s) => s instanceof
|
|
3740
|
+
(s) => s instanceof M || s instanceof K || s instanceof Y
|
|
3711
3741
|
).length == 4 ? [{ name: "四槓子", double: 13 }] : [];
|
|
3712
3742
|
}
|
|
3713
3743
|
dH13(t) {
|
|
3714
3744
|
if (t.length == 13) return [];
|
|
3715
3745
|
if (t.length == 7) return [];
|
|
3716
3746
|
const e = [1, 2, 3, 4];
|
|
3717
|
-
return t.filter((i) => i.tiles.some((o) => o.t == p.Z && e.includes(o.n))).length == 4 ? t.find((i) => i instanceof
|
|
3747
|
+
return t.filter((i) => i.tiles.some((o) => o.t == p.Z && e.includes(o.n))).length == 4 ? t.find((i) => i instanceof H).tiles.some((i) => i.t == p.Z && e.includes(i.n)) ? [{ name: "小四喜", double: 13 }] : [{ name: "大四喜", double: 13 }] : [];
|
|
3718
3748
|
}
|
|
3719
3749
|
dI13(t) {
|
|
3720
3750
|
const e = (s) => !!(s.equals(new w(p.Z, 6)) || s.t == p.S && [2, 3, 4, 6, 8].includes(s.n));
|
|
@@ -3732,15 +3762,15 @@ class fn {
|
|
|
3732
3762
|
const r = this.cfg.myWind.n, i = this.cfg.roundWind.n;
|
|
3733
3763
|
if (t.length == 7) return 25;
|
|
3734
3764
|
const o = t.find(
|
|
3735
|
-
(f) => f.tiles.some((m) => m.has(
|
|
3736
|
-
), a = this.minus() == 1, c = o.tiles.some((f) => f.has(
|
|
3737
|
-
const
|
|
3738
|
-
return
|
|
3765
|
+
(f) => f.tiles.some((m) => m.has(y.TSUMO) || m.has(y.RON))
|
|
3766
|
+
), a = this.minus() == 1, c = o.tiles.some((f) => f.has(y.TSUMO)), l = (f, m) => {
|
|
3767
|
+
const E = f.tiles[0];
|
|
3768
|
+
return E.t == p.Z || V.includes(E.n) ? m * 2 : m;
|
|
3739
3769
|
};
|
|
3740
3770
|
for (const f of t)
|
|
3741
3771
|
switch (!0) {
|
|
3742
3772
|
case f instanceof F:
|
|
3743
|
-
const m = f.tiles.some((
|
|
3773
|
+
const m = f.tiles.some((E) => E.has(y.RON)) ? 2 : 4;
|
|
3744
3774
|
s += l(f, m);
|
|
3745
3775
|
break;
|
|
3746
3776
|
case f instanceof X:
|
|
@@ -3749,34 +3779,34 @@ class fn {
|
|
|
3749
3779
|
case (f instanceof Y || f instanceof K):
|
|
3750
3780
|
s += l(f, 8);
|
|
3751
3781
|
break;
|
|
3752
|
-
case f instanceof
|
|
3782
|
+
case f instanceof M:
|
|
3753
3783
|
s += l(f, 16);
|
|
3754
3784
|
break;
|
|
3755
3785
|
}
|
|
3756
3786
|
s += ((f) => {
|
|
3757
3787
|
if (f instanceof F) return 0;
|
|
3758
|
-
if (f instanceof
|
|
3759
|
-
const m = f.tiles,
|
|
3760
|
-
return
|
|
3788
|
+
if (f instanceof H) return 2;
|
|
3789
|
+
const m = f.tiles, E = m.findIndex((S) => S.has(y.TSUMO) || S.has(y.RON));
|
|
3790
|
+
return E == 1 || E == 0 && m[2].n == 9 || E == 2 && m[0].n == 1 ? 2 : 0;
|
|
3761
3791
|
})(o);
|
|
3762
|
-
const d = t.find((f) => f instanceof
|
|
3792
|
+
const d = t.find((f) => f instanceof H).tiles[0];
|
|
3763
3793
|
d.t == p.Z && ([5, 6, 7].includes(d.n) && (s += 2), d.n == i && (s += 2), d.n == r && (s += 2));
|
|
3764
|
-
let
|
|
3765
|
-
return !a && s == 20 && (
|
|
3794
|
+
let g = !1;
|
|
3795
|
+
return !a && s == 20 && (g = !0), c && !g && (s += 2), !c && !a && (s += 10), !c && !a && s == 30 && (g = !0), a && s == 20 && (s = 30), s;
|
|
3766
3796
|
}
|
|
3767
3797
|
}
|
|
3768
|
-
const
|
|
3798
|
+
const Bt = (n) => n.tiles.reduce((t, e) => `${t}${e.n}${e.t}`, ""), gn = (n) => {
|
|
3769
3799
|
const t = {};
|
|
3770
3800
|
for (const s of n) {
|
|
3771
3801
|
if (!(s instanceof ut)) continue;
|
|
3772
|
-
const r =
|
|
3802
|
+
const r = Bt(s);
|
|
3773
3803
|
t[r] == null ? t[r] = 1 : t[r]++;
|
|
3774
3804
|
}
|
|
3775
3805
|
let e = 0;
|
|
3776
3806
|
for (const s in t)
|
|
3777
3807
|
t[s] >= 2 && e++;
|
|
3778
3808
|
return e;
|
|
3779
|
-
}, it = (n) => [...n.tiles].sort(
|
|
3809
|
+
}, it = (n) => [...n.tiles].sort(ue)[0], yn = (n) => {
|
|
3780
3810
|
const t = n.n, e = n.t;
|
|
3781
3811
|
if (e == p.Z) {
|
|
3782
3812
|
if (t == 4) return new w(e, 1);
|
|
@@ -3784,7 +3814,7 @@ const Fn = (n) => n.tiles.reduce((t, e) => `${t}${e.n}${e.t}`, ""), pn = (n) =>
|
|
|
3784
3814
|
}
|
|
3785
3815
|
return new w(e, t % 9 + 1);
|
|
3786
3816
|
};
|
|
3787
|
-
class
|
|
3817
|
+
class zt {
|
|
3788
3818
|
// ツモった後の14枚の手配から、牌効率に従って捨てるべき牌を返す。
|
|
3789
3819
|
// choices は、通常なら hand.hand を指定する。ただし、リーチしている場合は捨てる牌が限られているので choices で制限する。
|
|
3790
3820
|
static calcCandidates(t, e, s) {
|
|
@@ -3792,9 +3822,9 @@ class Lt {
|
|
|
3792
3822
|
const r = /* @__PURE__ */ new Map();
|
|
3793
3823
|
let i = 1 / 0;
|
|
3794
3824
|
for (const o of e) {
|
|
3795
|
-
const a = t.dec([o]), c =
|
|
3825
|
+
const a = t.dec([o]), c = zt.candidateTiles(t, s);
|
|
3796
3826
|
t.inc(a);
|
|
3797
|
-
const l = s != null && s.arrangeRed && o.has(
|
|
3827
|
+
const l = s != null && s.arrangeRed && o.has(y.RED) ? o.clone({ removeAll: !0 }) : o.has(y.RED) ? o.clone({ removeAll: !0, add: y.RED }) : o.clone({ removeAll: !0 });
|
|
3798
3828
|
c.shanten < i ? (r.clear(), r.set(l.toString(), {
|
|
3799
3829
|
shanten: c.shanten,
|
|
3800
3830
|
candidates: c.candidates,
|
|
@@ -3810,7 +3840,7 @@ class Lt {
|
|
|
3810
3840
|
// 積もる前の13枚の手配から、有効牌の一覧を返す
|
|
3811
3841
|
static candidateTiles(t, e) {
|
|
3812
3842
|
let s = 1 / 0, r = [];
|
|
3813
|
-
const i = new
|
|
3843
|
+
const i = new de(t);
|
|
3814
3844
|
for (const [o, a] of z({
|
|
3815
3845
|
skipBack: !0,
|
|
3816
3846
|
filterBy: e == null ? void 0 : e.typeFilter
|
|
@@ -3825,7 +3855,7 @@ class Lt {
|
|
|
3825
3855
|
};
|
|
3826
3856
|
}
|
|
3827
3857
|
}
|
|
3828
|
-
const
|
|
3858
|
+
const ke = () => {
|
|
3829
3859
|
const n = /* @__PURE__ */ new Set();
|
|
3830
3860
|
return {
|
|
3831
3861
|
on(t) {
|
|
@@ -3892,8 +3922,8 @@ function Gn(n, t) {
|
|
|
3892
3922
|
if (t[e]) return e;
|
|
3893
3923
|
return !1;
|
|
3894
3924
|
}
|
|
3895
|
-
const
|
|
3896
|
-
const n =
|
|
3925
|
+
const Gt = () => {
|
|
3926
|
+
const n = ke(), t = ke(), e = {
|
|
3897
3927
|
emit: n.emit,
|
|
3898
3928
|
on: (r) => t.on(r)
|
|
3899
3929
|
}, s = {
|
|
@@ -3902,7 +3932,7 @@ const Zt = () => {
|
|
|
3902
3932
|
};
|
|
3903
3933
|
return [e, s];
|
|
3904
3934
|
}, Ii = () => {
|
|
3905
|
-
const n =
|
|
3935
|
+
const n = ke();
|
|
3906
3936
|
return {
|
|
3907
3937
|
emit: (s) => {
|
|
3908
3938
|
n.emit(s);
|
|
@@ -3912,7 +3942,7 @@ const Zt = () => {
|
|
|
3912
3942
|
}
|
|
3913
3943
|
};
|
|
3914
3944
|
};
|
|
3915
|
-
class
|
|
3945
|
+
class re {
|
|
3916
3946
|
constructor(t) {
|
|
3917
3947
|
_(this, "reachValue", 1e3);
|
|
3918
3948
|
_(this, "m");
|
|
@@ -3931,10 +3961,10 @@ class se {
|
|
|
3931
3961
|
}
|
|
3932
3962
|
}
|
|
3933
3963
|
}
|
|
3934
|
-
class
|
|
3964
|
+
class ie {
|
|
3935
3965
|
constructor(t, e) {
|
|
3936
3966
|
_(this, "pToW", {});
|
|
3937
|
-
_(this, "wToP",
|
|
3967
|
+
_(this, "wToP", P(""));
|
|
3938
3968
|
_(this, "round");
|
|
3939
3969
|
_(this, "sticks");
|
|
3940
3970
|
this.round = (e == null ? void 0 : e.round) ?? k.E1, this.sticks = structuredClone(e == null ? void 0 : e.sticks) ?? { reach: 0, dead: 0 }, this.pToW = structuredClone(t);
|
|
@@ -3942,7 +3972,7 @@ class re {
|
|
|
3942
3972
|
}
|
|
3943
3973
|
update() {
|
|
3944
3974
|
for (let t in this.pToW) {
|
|
3945
|
-
const e =
|
|
3975
|
+
const e = De(this.pToW[t]);
|
|
3946
3976
|
this.pToW[t] = e, this.wToP[e] = t;
|
|
3947
3977
|
}
|
|
3948
3978
|
}
|
|
@@ -3953,7 +3983,7 @@ class re {
|
|
|
3953
3983
|
this.sticks.reach++;
|
|
3954
3984
|
}
|
|
3955
3985
|
nextRound() {
|
|
3956
|
-
const t =
|
|
3986
|
+
const t = Yt(this.round);
|
|
3957
3987
|
this.round = t, this.update();
|
|
3958
3988
|
}
|
|
3959
3989
|
resetDeadStick() {
|
|
@@ -3985,7 +4015,7 @@ function Vn(n) {
|
|
|
3985
4015
|
class Oi {
|
|
3986
4016
|
constructor(t = !1) {
|
|
3987
4017
|
_(this, "c");
|
|
3988
|
-
_(this, "safeMap",
|
|
4018
|
+
_(this, "safeMap", P({}, !0));
|
|
3989
4019
|
this.disable = t, this.c = this.initial();
|
|
3990
4020
|
}
|
|
3991
4021
|
get(t) {
|
|
@@ -3999,7 +4029,7 @@ class Oi {
|
|
|
3999
4029
|
throw new Error(
|
|
4000
4030
|
`[counter] cannot decrease ${e.toString()} due to zero`
|
|
4001
4031
|
);
|
|
4002
|
-
this.c[e.t][e.n] -= 1, e.has(
|
|
4032
|
+
this.c[e.t][e.n] -= 1, e.has(y.RED) && (this.c[e.t][0] -= 1);
|
|
4003
4033
|
}
|
|
4004
4034
|
}
|
|
4005
4035
|
}
|
|
@@ -4074,7 +4104,7 @@ const Ri = (n) => {
|
|
|
4074
4104
|
const t = Ci();
|
|
4075
4105
|
t && t.register(n);
|
|
4076
4106
|
};
|
|
4077
|
-
class
|
|
4107
|
+
class mn {
|
|
4078
4108
|
constructor(t) {
|
|
4079
4109
|
this._process = t, this._active = !1, this._current = null, this._last = null;
|
|
4080
4110
|
}
|
|
@@ -4103,19 +4133,19 @@ class yn {
|
|
|
4103
4133
|
this._last = null;
|
|
4104
4134
|
}
|
|
4105
4135
|
}
|
|
4106
|
-
const Xn = ".",
|
|
4107
|
-
function
|
|
4136
|
+
const Xn = ".", xi = "", Yn = "", Mi = "#", $i = "*", qn = "xstate.init", Ce = "xstate.stop";
|
|
4137
|
+
function Pi(n, t) {
|
|
4108
4138
|
return {
|
|
4109
4139
|
type: `xstate.after.${n}.${t}`
|
|
4110
4140
|
};
|
|
4111
4141
|
}
|
|
4112
|
-
function
|
|
4142
|
+
function Re(n, t) {
|
|
4113
4143
|
return {
|
|
4114
4144
|
type: `xstate.done.state.${n}`,
|
|
4115
4145
|
output: t
|
|
4116
4146
|
};
|
|
4117
4147
|
}
|
|
4118
|
-
function
|
|
4148
|
+
function Hi(n, t) {
|
|
4119
4149
|
return {
|
|
4120
4150
|
type: `xstate.done.actor.${n}`,
|
|
4121
4151
|
output: t,
|
|
@@ -4142,10 +4172,10 @@ function G(n) {
|
|
|
4142
4172
|
}
|
|
4143
4173
|
const Bi = typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
4144
4174
|
function ts(n, t) {
|
|
4145
|
-
const e =
|
|
4175
|
+
const e = wn(n), s = wn(t);
|
|
4146
4176
|
return typeof s == "string" ? typeof e == "string" ? s === e : !1 : typeof e == "string" ? e in s : Object.keys(e).every((r) => r in s ? ts(e[r], s[r]) : !1);
|
|
4147
4177
|
}
|
|
4148
|
-
function
|
|
4178
|
+
function Fe(n) {
|
|
4149
4179
|
if (ns(n))
|
|
4150
4180
|
return n;
|
|
4151
4181
|
const t = [];
|
|
@@ -4165,12 +4195,12 @@ function Ue(n) {
|
|
|
4165
4195
|
}
|
|
4166
4196
|
return t.push(e), t;
|
|
4167
4197
|
}
|
|
4168
|
-
function
|
|
4198
|
+
function wn(n) {
|
|
4169
4199
|
if (bo(n))
|
|
4170
4200
|
return n.value;
|
|
4171
4201
|
if (typeof n != "string")
|
|
4172
4202
|
return n;
|
|
4173
|
-
const t =
|
|
4203
|
+
const t = Fe(n);
|
|
4174
4204
|
return Di(t);
|
|
4175
4205
|
}
|
|
4176
4206
|
function Di(n) {
|
|
@@ -4187,7 +4217,7 @@ function Di(n) {
|
|
|
4187
4217
|
}
|
|
4188
4218
|
return t;
|
|
4189
4219
|
}
|
|
4190
|
-
function
|
|
4220
|
+
function bn(n, t) {
|
|
4191
4221
|
const e = {}, s = Object.keys(n);
|
|
4192
4222
|
for (let r = 0; r < s.length; r++) {
|
|
4193
4223
|
const i = s[r];
|
|
@@ -4201,7 +4231,7 @@ function es(n) {
|
|
|
4201
4231
|
function Q(n) {
|
|
4202
4232
|
return n === void 0 ? [] : es(n);
|
|
4203
4233
|
}
|
|
4204
|
-
function
|
|
4234
|
+
function xe(n, t, e, s) {
|
|
4205
4235
|
return typeof n == "function" ? n({
|
|
4206
4236
|
context: t,
|
|
4207
4237
|
event: e,
|
|
@@ -4220,7 +4250,7 @@ function Et(n) {
|
|
|
4220
4250
|
} : t);
|
|
4221
4251
|
}
|
|
4222
4252
|
function ss(n) {
|
|
4223
|
-
if (!(n === void 0 || n ===
|
|
4253
|
+
if (!(n === void 0 || n === xi))
|
|
4224
4254
|
return Q(n);
|
|
4225
4255
|
}
|
|
4226
4256
|
function Me(n, t, e) {
|
|
@@ -4232,17 +4262,17 @@ function Me(n, t, e) {
|
|
|
4232
4262
|
complete: (a = s ? n.complete : e) == null ? void 0 : a.bind(r)
|
|
4233
4263
|
};
|
|
4234
4264
|
}
|
|
4235
|
-
function
|
|
4265
|
+
function _n(n, t) {
|
|
4236
4266
|
return `${t}.${n}`;
|
|
4237
4267
|
}
|
|
4238
|
-
function
|
|
4268
|
+
function Ze(n, t) {
|
|
4239
4269
|
const e = t.match(/^xstate\.invoke\.(\d+)\.(.*)/);
|
|
4240
4270
|
if (!e)
|
|
4241
4271
|
return n.implementations.actors[t];
|
|
4242
4272
|
const [, s, r] = e, o = n.getStateNodeById(r).config.invoke;
|
|
4243
4273
|
return (Array.isArray(o) ? o[s] : o).src;
|
|
4244
4274
|
}
|
|
4245
|
-
function
|
|
4275
|
+
function En(n, t) {
|
|
4246
4276
|
return `${n.sessionId}.${t}`;
|
|
4247
4277
|
}
|
|
4248
4278
|
let Li = 0;
|
|
@@ -4251,76 +4281,76 @@ function zi(n, t) {
|
|
|
4251
4281
|
clock: a,
|
|
4252
4282
|
logger: c
|
|
4253
4283
|
} = t, l = {
|
|
4254
|
-
schedule: (d,
|
|
4284
|
+
schedule: (d, g, f, m, E = Math.random().toString(36).slice(2)) => {
|
|
4255
4285
|
const S = {
|
|
4256
4286
|
source: d,
|
|
4257
|
-
target:
|
|
4287
|
+
target: g,
|
|
4258
4288
|
event: f,
|
|
4259
4289
|
delay: m,
|
|
4260
|
-
id:
|
|
4290
|
+
id: E,
|
|
4261
4291
|
startedAt: Date.now()
|
|
4262
|
-
}, O =
|
|
4292
|
+
}, O = En(d, E);
|
|
4263
4293
|
h._snapshot._scheduledEvents[O] = S;
|
|
4264
4294
|
const R = a.setTimeout(() => {
|
|
4265
|
-
delete o[O], delete h._snapshot._scheduledEvents[O], h._relay(d,
|
|
4295
|
+
delete o[O], delete h._snapshot._scheduledEvents[O], h._relay(d, g, f);
|
|
4266
4296
|
}, m);
|
|
4267
4297
|
o[O] = R;
|
|
4268
4298
|
},
|
|
4269
|
-
cancel: (d,
|
|
4270
|
-
const f =
|
|
4299
|
+
cancel: (d, g) => {
|
|
4300
|
+
const f = En(d, g), m = o[f];
|
|
4271
4301
|
delete o[f], delete h._snapshot._scheduledEvents[f], m !== void 0 && a.clearTimeout(m);
|
|
4272
4302
|
},
|
|
4273
4303
|
cancelAll: (d) => {
|
|
4274
|
-
for (const
|
|
4275
|
-
const f = h._snapshot._scheduledEvents[
|
|
4304
|
+
for (const g in h._snapshot._scheduledEvents) {
|
|
4305
|
+
const f = h._snapshot._scheduledEvents[g];
|
|
4276
4306
|
f.source === d && l.cancel(d, f.id);
|
|
4277
4307
|
}
|
|
4278
4308
|
}
|
|
4279
4309
|
}, u = (d) => {
|
|
4280
4310
|
if (!i.size)
|
|
4281
4311
|
return;
|
|
4282
|
-
const
|
|
4312
|
+
const g = {
|
|
4283
4313
|
...d,
|
|
4284
4314
|
rootId: n.sessionId
|
|
4285
4315
|
};
|
|
4286
4316
|
i.forEach((f) => {
|
|
4287
4317
|
var m;
|
|
4288
|
-
return (m = f.next) == null ? void 0 : m.call(f,
|
|
4318
|
+
return (m = f.next) == null ? void 0 : m.call(f, g);
|
|
4289
4319
|
});
|
|
4290
4320
|
}, h = {
|
|
4291
4321
|
_snapshot: {
|
|
4292
4322
|
_scheduledEvents: ((t == null ? void 0 : t.snapshot) && t.snapshot.scheduler) ?? {}
|
|
4293
4323
|
},
|
|
4294
4324
|
_bookId: () => `x:${Li++}`,
|
|
4295
|
-
_register: (d,
|
|
4325
|
+
_register: (d, g) => (e.set(d, g), d),
|
|
4296
4326
|
_unregister: (d) => {
|
|
4297
4327
|
e.delete(d.sessionId);
|
|
4298
|
-
const
|
|
4299
|
-
|
|
4328
|
+
const g = r.get(d);
|
|
4329
|
+
g !== void 0 && (s.delete(g), r.delete(d));
|
|
4300
4330
|
},
|
|
4301
4331
|
get: (d) => s.get(d),
|
|
4302
|
-
_set: (d,
|
|
4332
|
+
_set: (d, g) => {
|
|
4303
4333
|
const f = s.get(d);
|
|
4304
|
-
if (f && f !==
|
|
4334
|
+
if (f && f !== g)
|
|
4305
4335
|
throw new Error(`Actor with system ID '${d}' already exists.`);
|
|
4306
|
-
s.set(d,
|
|
4336
|
+
s.set(d, g), r.set(g, d);
|
|
4307
4337
|
},
|
|
4308
4338
|
inspect: (d) => {
|
|
4309
|
-
const
|
|
4310
|
-
return i.add(
|
|
4339
|
+
const g = Me(d);
|
|
4340
|
+
return i.add(g), {
|
|
4311
4341
|
unsubscribe() {
|
|
4312
|
-
i.delete(
|
|
4342
|
+
i.delete(g);
|
|
4313
4343
|
}
|
|
4314
4344
|
};
|
|
4315
4345
|
},
|
|
4316
4346
|
_sendInspectionEvent: u,
|
|
4317
|
-
_relay: (d,
|
|
4347
|
+
_relay: (d, g, f) => {
|
|
4318
4348
|
h._sendInspectionEvent({
|
|
4319
4349
|
type: "@xstate.event",
|
|
4320
4350
|
sourceRef: d,
|
|
4321
|
-
actorRef:
|
|
4351
|
+
actorRef: g,
|
|
4322
4352
|
event: f
|
|
4323
|
-
}),
|
|
4353
|
+
}), g._send(f);
|
|
4324
4354
|
},
|
|
4325
4355
|
scheduler: l,
|
|
4326
4356
|
getSnapshot: () => ({
|
|
@@ -4331,15 +4361,15 @@ function zi(n, t) {
|
|
|
4331
4361
|
start: () => {
|
|
4332
4362
|
const d = h._snapshot._scheduledEvents;
|
|
4333
4363
|
h._snapshot._scheduledEvents = {};
|
|
4334
|
-
for (const
|
|
4364
|
+
for (const g in d) {
|
|
4335
4365
|
const {
|
|
4336
4366
|
source: f,
|
|
4337
4367
|
target: m,
|
|
4338
|
-
event:
|
|
4368
|
+
event: E,
|
|
4339
4369
|
delay: S,
|
|
4340
4370
|
id: O
|
|
4341
|
-
} = d[
|
|
4342
|
-
l.schedule(f, m,
|
|
4371
|
+
} = d[g];
|
|
4372
|
+
l.schedule(f, m, E, S, O);
|
|
4343
4373
|
}
|
|
4344
4374
|
},
|
|
4345
4375
|
_clock: a,
|
|
@@ -4347,8 +4377,8 @@ function zi(n, t) {
|
|
|
4347
4377
|
};
|
|
4348
4378
|
return h;
|
|
4349
4379
|
}
|
|
4350
|
-
let
|
|
4351
|
-
const
|
|
4380
|
+
let _e = !1;
|
|
4381
|
+
const Ge = 1;
|
|
4352
4382
|
let $ = /* @__PURE__ */ function(n) {
|
|
4353
4383
|
return n[n.NotStarted = 0] = "NotStarted", n[n.Running = 1] = "Running", n[n.Stopped = 2] = "Stopped", n;
|
|
4354
4384
|
}({});
|
|
@@ -4369,7 +4399,7 @@ class Ui {
|
|
|
4369
4399
|
* @param options Actor options
|
|
4370
4400
|
*/
|
|
4371
4401
|
constructor(t, e) {
|
|
4372
|
-
this.logic = t, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new
|
|
4402
|
+
this.logic = t, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new mn(this._process.bind(this)), this.observers = /* @__PURE__ */ new Set(), this.eventListeners = /* @__PURE__ */ new Map(), this.logger = void 0, this._processingStatus = $.NotStarted, this._parent = void 0, this._syncSnapshot = void 0, this.ref = void 0, this._actorScope = void 0, this._systemId = void 0, this.sessionId = void 0, this.system = void 0, this._doneEvent = void 0, this.src = void 0, this._deferred = [];
|
|
4373
4403
|
const s = {
|
|
4374
4404
|
...ji,
|
|
4375
4405
|
...e
|
|
@@ -4400,10 +4430,10 @@ class Ui {
|
|
|
4400
4430
|
h._stop();
|
|
4401
4431
|
},
|
|
4402
4432
|
emit: (h) => {
|
|
4403
|
-
const d = this.eventListeners.get(h.type),
|
|
4404
|
-
if (!d && !
|
|
4433
|
+
const d = this.eventListeners.get(h.type), g = this.eventListeners.get("*");
|
|
4434
|
+
if (!d && !g)
|
|
4405
4435
|
return;
|
|
4406
|
-
const f = [...d ? d.values() : [], ...
|
|
4436
|
+
const f = [...d ? d.values() : [], ...g ? g.values() : []];
|
|
4407
4437
|
for (const m of f)
|
|
4408
4438
|
m(h);
|
|
4409
4439
|
},
|
|
@@ -4418,11 +4448,11 @@ class Ui {
|
|
|
4418
4448
|
}
|
|
4419
4449
|
}), !h.exec)
|
|
4420
4450
|
return;
|
|
4421
|
-
const
|
|
4451
|
+
const g = _e;
|
|
4422
4452
|
try {
|
|
4423
|
-
|
|
4453
|
+
_e = !0, h.exec(h.info, h.params);
|
|
4424
4454
|
} finally {
|
|
4425
|
-
|
|
4455
|
+
_e = g;
|
|
4426
4456
|
}
|
|
4427
4457
|
};
|
|
4428
4458
|
this._processingStatus === $.Running ? d() : this._deferred.push(d);
|
|
@@ -4474,7 +4504,7 @@ class Ui {
|
|
|
4474
4504
|
} catch (a) {
|
|
4475
4505
|
G(a);
|
|
4476
4506
|
}
|
|
4477
|
-
this._stopProcedure(), this._complete(), this._doneEvent =
|
|
4507
|
+
this._stopProcedure(), this._complete(), this._doneEvent = Hi(this.id, this._snapshot.output), this._parent && this.system._relay(this, this._parent, this._doneEvent);
|
|
4478
4508
|
break;
|
|
4479
4509
|
case "error":
|
|
4480
4510
|
this._error(this._snapshot.error);
|
|
@@ -4647,11 +4677,11 @@ class Ui {
|
|
|
4647
4677
|
}, this._error(r);
|
|
4648
4678
|
return;
|
|
4649
4679
|
}
|
|
4650
|
-
this.update(e, t), t.type ===
|
|
4680
|
+
this.update(e, t), t.type === Ce && (this._stopProcedure(), this._complete());
|
|
4651
4681
|
}
|
|
4652
4682
|
_stop() {
|
|
4653
4683
|
return this._processingStatus === $.Stopped ? this : (this.mailbox.clear(), this._processingStatus === $.NotStarted ? (this._processingStatus = $.Stopped, this) : (this.mailbox.enqueue({
|
|
4654
|
-
type:
|
|
4684
|
+
type: Ce
|
|
4655
4685
|
}), this));
|
|
4656
4686
|
}
|
|
4657
4687
|
/** Stops the Actor and unsubscribe all listeners. */
|
|
@@ -4696,7 +4726,7 @@ class Ui {
|
|
|
4696
4726
|
// right now, they are being stopped within the machine's transition
|
|
4697
4727
|
// but that could throw and leave us with "orphaned" active actors
|
|
4698
4728
|
_stopProcedure() {
|
|
4699
|
-
return this._processingStatus !== $.Running ? this : (this.system.scheduler.cancelAll(this), this.mailbox.clear(), this.mailbox = new
|
|
4729
|
+
return this._processingStatus !== $.Running ? this : (this.system.scheduler.cancelAll(this), this.mailbox.clear(), this.mailbox = new mn(this._process.bind(this)), this._processingStatus = $.Stopped, this.system._unregister(this), this);
|
|
4700
4730
|
}
|
|
4701
4731
|
/** @internal */
|
|
4702
4732
|
_send(t) {
|
|
@@ -4718,7 +4748,7 @@ class Ui {
|
|
|
4718
4748
|
}
|
|
4719
4749
|
toJSON() {
|
|
4720
4750
|
return {
|
|
4721
|
-
xstate$$type:
|
|
4751
|
+
xstate$$type: Ge,
|
|
4722
4752
|
id: this.id
|
|
4723
4753
|
};
|
|
4724
4754
|
}
|
|
@@ -4787,7 +4817,7 @@ function Vi(n, t, e, s, {
|
|
|
4787
4817
|
input: a,
|
|
4788
4818
|
syncSnapshot: c
|
|
4789
4819
|
}) {
|
|
4790
|
-
const l = typeof o == "string" ?
|
|
4820
|
+
const l = typeof o == "string" ? Ze(t.machine, o) : o, u = typeof r == "function" ? r(e) : r;
|
|
4791
4821
|
let h, d;
|
|
4792
4822
|
return l && (d = typeof a == "function" ? a({
|
|
4793
4823
|
context: t.context,
|
|
@@ -4857,14 +4887,14 @@ function rs(n) {
|
|
|
4857
4887
|
}
|
|
4858
4888
|
return t.type = "xstate.stopChild", t.actorRef = n, t.resolve = Yi, t.execute = qi, t;
|
|
4859
4889
|
}
|
|
4860
|
-
function
|
|
4890
|
+
function Ve(n, t, e, s) {
|
|
4861
4891
|
const {
|
|
4862
4892
|
machine: r
|
|
4863
4893
|
} = s, i = typeof n == "function", o = i ? n : r.implementations.guards[typeof n == "string" ? n : n.type];
|
|
4864
4894
|
if (!i && !o)
|
|
4865
4895
|
throw new Error(`Guard '${typeof n == "string" ? n : n.type}' is not implemented.'.`);
|
|
4866
4896
|
if (typeof o != "function")
|
|
4867
|
-
return
|
|
4897
|
+
return Ve(o, t, e, s);
|
|
4868
4898
|
const a = {
|
|
4869
4899
|
context: t,
|
|
4870
4900
|
event: e
|
|
@@ -4879,11 +4909,11 @@ function Ge(n, t, e, s) {
|
|
|
4879
4909
|
// this holds all params
|
|
4880
4910
|
) : o(a, c);
|
|
4881
4911
|
}
|
|
4882
|
-
const
|
|
4912
|
+
const Je = (n) => n.type === "atomic" || n.type === "final";
|
|
4883
4913
|
function Ct(n) {
|
|
4884
4914
|
return Object.values(n.states).filter((t) => t.type !== "history");
|
|
4885
4915
|
}
|
|
4886
|
-
function
|
|
4916
|
+
function jt(n, t) {
|
|
4887
4917
|
const e = [];
|
|
4888
4918
|
if (t === n)
|
|
4889
4919
|
return e;
|
|
@@ -4892,15 +4922,15 @@ function zt(n, t) {
|
|
|
4892
4922
|
e.push(s), s = s.parent;
|
|
4893
4923
|
return e;
|
|
4894
4924
|
}
|
|
4895
|
-
function
|
|
4925
|
+
function oe(n) {
|
|
4896
4926
|
const t = new Set(n), e = os(t);
|
|
4897
4927
|
for (const s of t)
|
|
4898
4928
|
if (s.type === "compound" && (!e.get(s) || !e.get(s).length))
|
|
4899
|
-
|
|
4929
|
+
An(s).forEach((r) => t.add(r));
|
|
4900
4930
|
else if (s.type === "parallel") {
|
|
4901
4931
|
for (const r of Ct(s))
|
|
4902
4932
|
if (r.type !== "history" && !t.has(r)) {
|
|
4903
|
-
const i =
|
|
4933
|
+
const i = An(r);
|
|
4904
4934
|
for (const o of i)
|
|
4905
4935
|
t.add(o);
|
|
4906
4936
|
}
|
|
@@ -4919,7 +4949,7 @@ function is(n, t) {
|
|
|
4919
4949
|
if (n.type === "compound") {
|
|
4920
4950
|
const r = e[0];
|
|
4921
4951
|
if (r) {
|
|
4922
|
-
if (
|
|
4952
|
+
if (Je(r))
|
|
4923
4953
|
return r.key;
|
|
4924
4954
|
} else
|
|
4925
4955
|
return {};
|
|
@@ -4936,13 +4966,13 @@ function os(n) {
|
|
|
4936
4966
|
return t;
|
|
4937
4967
|
}
|
|
4938
4968
|
function as(n, t) {
|
|
4939
|
-
const e =
|
|
4969
|
+
const e = oe(t);
|
|
4940
4970
|
return is(n, os(e));
|
|
4941
4971
|
}
|
|
4942
|
-
function
|
|
4943
|
-
return t.type === "compound" ? Ct(t).some((e) => e.type === "final" && n.has(e)) : t.type === "parallel" ? Ct(t).every((e) =>
|
|
4972
|
+
function Xe(n, t) {
|
|
4973
|
+
return t.type === "compound" ? Ct(t).some((e) => e.type === "final" && n.has(e)) : t.type === "parallel" ? Ct(t).every((e) => Xe(n, e)) : t.type === "final";
|
|
4944
4974
|
}
|
|
4945
|
-
const
|
|
4975
|
+
const fe = (n) => n[0] === Mi;
|
|
4946
4976
|
function Qi(n, t) {
|
|
4947
4977
|
return n.transitions.get(t) || [...n.transitions.keys()].filter((s) => {
|
|
4948
4978
|
if (s === $i)
|
|
@@ -4965,7 +4995,7 @@ function to(n) {
|
|
|
4965
4995
|
if (!t)
|
|
4966
4996
|
return [];
|
|
4967
4997
|
const e = (r) => {
|
|
4968
|
-
const i =
|
|
4998
|
+
const i = Pi(r, n.id), o = i.type;
|
|
4969
4999
|
return n.entry.push(Oo(i, {
|
|
4970
5000
|
id: o,
|
|
4971
5001
|
delay: r
|
|
@@ -5066,15 +5096,15 @@ function so(n, t) {
|
|
|
5066
5096
|
return t.map((e) => {
|
|
5067
5097
|
if (typeof e != "string")
|
|
5068
5098
|
return e;
|
|
5069
|
-
if (
|
|
5099
|
+
if (fe(e))
|
|
5070
5100
|
return n.machine.getStateNodeById(e);
|
|
5071
5101
|
const s = e[0] === Xn;
|
|
5072
5102
|
if (s && !n.parent)
|
|
5073
|
-
return
|
|
5103
|
+
return ae(n, e.slice(1));
|
|
5074
5104
|
const r = s ? n.key + e : e;
|
|
5075
5105
|
if (n.parent)
|
|
5076
5106
|
try {
|
|
5077
|
-
return
|
|
5107
|
+
return ae(n.parent, r);
|
|
5078
5108
|
} catch (i) {
|
|
5079
5109
|
throw new Error(`Invalid transition definition for state node '${n.id}':
|
|
5080
5110
|
${i.message}`);
|
|
@@ -5086,16 +5116,16 @@ ${i.message}`);
|
|
|
5086
5116
|
function cs(n) {
|
|
5087
5117
|
const t = ss(n.config.target);
|
|
5088
5118
|
return t ? {
|
|
5089
|
-
target: t.map((e) => typeof e == "string" ?
|
|
5119
|
+
target: t.map((e) => typeof e == "string" ? ae(n.parent, e) : e)
|
|
5090
5120
|
} : n.parent.initial;
|
|
5091
5121
|
}
|
|
5092
5122
|
function dt(n) {
|
|
5093
5123
|
return n.type === "history";
|
|
5094
5124
|
}
|
|
5095
|
-
function
|
|
5125
|
+
function An(n) {
|
|
5096
5126
|
const t = ls(n);
|
|
5097
5127
|
for (const e of t)
|
|
5098
|
-
for (const s of
|
|
5128
|
+
for (const s of jt(e, n))
|
|
5099
5129
|
t.add(s);
|
|
5100
5130
|
return t;
|
|
5101
5131
|
}
|
|
@@ -5113,7 +5143,7 @@ function ls(n) {
|
|
|
5113
5143
|
return e(n), t;
|
|
5114
5144
|
}
|
|
5115
5145
|
function Rt(n, t) {
|
|
5116
|
-
if (
|
|
5146
|
+
if (fe(t))
|
|
5117
5147
|
return n.machine.getStateNodeById(t);
|
|
5118
5148
|
if (!n.states)
|
|
5119
5149
|
throw new Error(`Unable to retrieve child state '${t}' from '${n.id}'; no child states exist.`);
|
|
@@ -5122,13 +5152,13 @@ function Rt(n, t) {
|
|
|
5122
5152
|
throw new Error(`Child state '${t}' does not exist on '${n.id}'`);
|
|
5123
5153
|
return e;
|
|
5124
5154
|
}
|
|
5125
|
-
function
|
|
5126
|
-
if (typeof t == "string" &&
|
|
5155
|
+
function ae(n, t) {
|
|
5156
|
+
if (typeof t == "string" && fe(t))
|
|
5127
5157
|
try {
|
|
5128
5158
|
return n.machine.getStateNodeById(t);
|
|
5129
5159
|
} catch {
|
|
5130
5160
|
}
|
|
5131
|
-
const e =
|
|
5161
|
+
const e = Fe(t).slice();
|
|
5132
5162
|
let s = n;
|
|
5133
5163
|
for (; e.length; ) {
|
|
5134
5164
|
const r = e.shift();
|
|
@@ -5138,7 +5168,7 @@ function oe(n, t) {
|
|
|
5138
5168
|
}
|
|
5139
5169
|
return s;
|
|
5140
5170
|
}
|
|
5141
|
-
function
|
|
5171
|
+
function ce(n, t) {
|
|
5142
5172
|
if (typeof t == "string") {
|
|
5143
5173
|
const r = n.states[t];
|
|
5144
5174
|
if (!r)
|
|
@@ -5150,7 +5180,7 @@ function ae(n, t) {
|
|
|
5150
5180
|
const o = Rt(n, i);
|
|
5151
5181
|
if (!o)
|
|
5152
5182
|
return r;
|
|
5153
|
-
const a =
|
|
5183
|
+
const a = ce(o, t[i]);
|
|
5154
5184
|
return r.concat(a);
|
|
5155
5185
|
}, []));
|
|
5156
5186
|
}
|
|
@@ -5159,7 +5189,7 @@ function ro(n, t, e, s) {
|
|
|
5159
5189
|
return !i || !i.length ? n.next(e, s) : i;
|
|
5160
5190
|
}
|
|
5161
5191
|
function io(n, t, e, s) {
|
|
5162
|
-
const r = Object.keys(t), i = Rt(n, r[0]), o =
|
|
5192
|
+
const r = Object.keys(t), i = Rt(n, r[0]), o = Ye(i, t[r[0]], e, s);
|
|
5163
5193
|
return !o || !o.length ? n.next(e, s) : o;
|
|
5164
5194
|
}
|
|
5165
5195
|
function oo(n, t, e, s) {
|
|
@@ -5168,12 +5198,12 @@ function oo(n, t, e, s) {
|
|
|
5168
5198
|
const o = t[i];
|
|
5169
5199
|
if (!o)
|
|
5170
5200
|
continue;
|
|
5171
|
-
const a = Rt(n, i), c =
|
|
5201
|
+
const a = Rt(n, i), c = Ye(a, o, e, s);
|
|
5172
5202
|
c && r.push(...c);
|
|
5173
5203
|
}
|
|
5174
5204
|
return r.length ? r : n.next(e, s);
|
|
5175
5205
|
}
|
|
5176
|
-
function
|
|
5206
|
+
function Ye(n, t, e, s) {
|
|
5177
5207
|
return typeof t == "string" ? ro(n, t, e, s) : Object.keys(t).length === 1 ? io(n, t, e, s) : oo(n, t, e, s);
|
|
5178
5208
|
}
|
|
5179
5209
|
function ao(n) {
|
|
@@ -5201,7 +5231,7 @@ function us(n, t, e) {
|
|
|
5201
5231
|
let i = !1;
|
|
5202
5232
|
const o = /* @__PURE__ */ new Set();
|
|
5203
5233
|
for (const a of s)
|
|
5204
|
-
if (co(
|
|
5234
|
+
if (co($e([r], t, e), $e([a], t, e)))
|
|
5205
5235
|
if (et(r.source, a.source))
|
|
5206
5236
|
o.add(a);
|
|
5207
5237
|
else {
|
|
@@ -5218,11 +5248,11 @@ function us(n, t, e) {
|
|
|
5218
5248
|
}
|
|
5219
5249
|
function lo(n) {
|
|
5220
5250
|
const [t, ...e] = n;
|
|
5221
|
-
for (const s of
|
|
5251
|
+
for (const s of jt(t, void 0))
|
|
5222
5252
|
if (e.every((r) => et(r, s)))
|
|
5223
5253
|
return s;
|
|
5224
5254
|
}
|
|
5225
|
-
function
|
|
5255
|
+
function qe(n, t) {
|
|
5226
5256
|
if (!n.target)
|
|
5227
5257
|
return [];
|
|
5228
5258
|
const e = /* @__PURE__ */ new Set();
|
|
@@ -5232,14 +5262,14 @@ function Ye(n, t) {
|
|
|
5232
5262
|
for (const r of t[s.id])
|
|
5233
5263
|
e.add(r);
|
|
5234
5264
|
else
|
|
5235
|
-
for (const r of
|
|
5265
|
+
for (const r of qe(cs(s), t))
|
|
5236
5266
|
e.add(r);
|
|
5237
5267
|
else
|
|
5238
5268
|
e.add(s);
|
|
5239
5269
|
return [...e];
|
|
5240
5270
|
}
|
|
5241
5271
|
function hs(n, t) {
|
|
5242
|
-
const e =
|
|
5272
|
+
const e = qe(n, t);
|
|
5243
5273
|
if (!e)
|
|
5244
5274
|
return;
|
|
5245
5275
|
if (!n.reenter && e.every((r) => r === n.source || et(r, n.source)))
|
|
@@ -5250,7 +5280,7 @@ function hs(n, t) {
|
|
|
5250
5280
|
if (!n.reenter)
|
|
5251
5281
|
return n.source.machine.root;
|
|
5252
5282
|
}
|
|
5253
|
-
function
|
|
5283
|
+
function $e(n, t, e) {
|
|
5254
5284
|
var r;
|
|
5255
5285
|
const s = /* @__PURE__ */ new Set();
|
|
5256
5286
|
for (const i of n)
|
|
@@ -5270,16 +5300,16 @@ function uo(n, t) {
|
|
|
5270
5300
|
return !1;
|
|
5271
5301
|
return !0;
|
|
5272
5302
|
}
|
|
5273
|
-
function
|
|
5303
|
+
function Pe(n, t, e, s, r, i) {
|
|
5274
5304
|
if (!n.length)
|
|
5275
5305
|
return t;
|
|
5276
5306
|
const o = new Set(t._nodes);
|
|
5277
5307
|
let a = t.historyValue;
|
|
5278
5308
|
const c = us(n, o, a);
|
|
5279
5309
|
let l = t;
|
|
5280
|
-
r || ([l, a] = go(l, s, e, c, o, a, i, e.actionExecutor)), l =
|
|
5310
|
+
r || ([l, a] = go(l, s, e, c, o, a, i, e.actionExecutor)), l = xt(l, s, e, c.flatMap((h) => h.actions), i, void 0), l = fo(l, s, e, c, o, i, a, r);
|
|
5281
5311
|
const u = [...o];
|
|
5282
|
-
l.status === "done" && (l =
|
|
5312
|
+
l.status === "done" && (l = xt(l, s, e, u.sort((h, d) => d.order - h.order).flatMap((h) => h.exit), i, void 0));
|
|
5283
5313
|
try {
|
|
5284
5314
|
return a === t.historyValue && uo(t._nodes, o) ? l : pt(l, {
|
|
5285
5315
|
_nodes: u,
|
|
@@ -5292,37 +5322,37 @@ function $e(n, t, e, s, r, i) {
|
|
|
5292
5322
|
function ho(n, t, e, s, r) {
|
|
5293
5323
|
if (s.output === void 0)
|
|
5294
5324
|
return;
|
|
5295
|
-
const i =
|
|
5296
|
-
return
|
|
5325
|
+
const i = Re(r.id, r.output !== void 0 && r.parent ? xe(r.output, n.context, t, e.self) : void 0);
|
|
5326
|
+
return xe(s.output, n.context, i, e.self);
|
|
5297
5327
|
}
|
|
5298
5328
|
function fo(n, t, e, s, r, i, o, a) {
|
|
5299
5329
|
let c = n;
|
|
5300
5330
|
const l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
|
|
5301
5331
|
po(s, o, u, l), a && u.add(n.machine.root);
|
|
5302
5332
|
const h = /* @__PURE__ */ new Set();
|
|
5303
|
-
for (const d of [...l].sort((
|
|
5333
|
+
for (const d of [...l].sort((g, f) => g.order - f.order)) {
|
|
5304
5334
|
r.add(d);
|
|
5305
|
-
const
|
|
5306
|
-
|
|
5335
|
+
const g = [];
|
|
5336
|
+
g.push(...d.entry);
|
|
5307
5337
|
for (const f of d.invoke)
|
|
5308
|
-
|
|
5338
|
+
g.push(Xi(f.src, {
|
|
5309
5339
|
...f,
|
|
5310
5340
|
syncSnapshot: !!f.onSnapshot
|
|
5311
5341
|
}));
|
|
5312
5342
|
if (u.has(d)) {
|
|
5313
5343
|
const f = d.initial.actions;
|
|
5314
|
-
|
|
5344
|
+
g.push(...f);
|
|
5315
5345
|
}
|
|
5316
|
-
if (c =
|
|
5346
|
+
if (c = xt(c, t, e, g, i, d.invoke.map((f) => f.id)), d.type === "final") {
|
|
5317
5347
|
const f = d.parent;
|
|
5318
|
-
let m = (f == null ? void 0 : f.type) === "parallel" ? f : f == null ? void 0 : f.parent,
|
|
5319
|
-
for ((f == null ? void 0 : f.type) === "compound" && i.push(
|
|
5320
|
-
h.add(m), i.push(
|
|
5348
|
+
let m = (f == null ? void 0 : f.type) === "parallel" ? f : f == null ? void 0 : f.parent, E = m || d;
|
|
5349
|
+
for ((f == null ? void 0 : f.type) === "compound" && i.push(Re(f.id, d.output !== void 0 ? xe(d.output, c.context, t, e.self) : void 0)); (m == null ? void 0 : m.type) === "parallel" && !h.has(m) && Xe(r, m); )
|
|
5350
|
+
h.add(m), i.push(Re(m.id)), E = m, m = m.parent;
|
|
5321
5351
|
if (m)
|
|
5322
5352
|
continue;
|
|
5323
5353
|
c = pt(c, {
|
|
5324
5354
|
status: "done",
|
|
5325
|
-
output: ho(c, t, e, c.machine.root,
|
|
5355
|
+
output: ho(c, t, e, c.machine.root, E)
|
|
5326
5356
|
});
|
|
5327
5357
|
}
|
|
5328
5358
|
}
|
|
@@ -5337,9 +5367,9 @@ function po(n, t, e, s) {
|
|
|
5337
5367
|
// if it's different than the source then it's outside of it and it means that the target has to be entered as well
|
|
5338
5368
|
r.source !== i || // reentering transitions always enter the target, even if it's the source itself
|
|
5339
5369
|
r.reenter) && (s.add(a), e.add(a)), At(a, t, e, s);
|
|
5340
|
-
const o =
|
|
5370
|
+
const o = qe(r, t);
|
|
5341
5371
|
for (const a of o) {
|
|
5342
|
-
const c =
|
|
5372
|
+
const c = jt(a, i);
|
|
5343
5373
|
(i == null ? void 0 : i.type) === "parallel" && c.push(i), ds(s, t, e, c, !r.source.parent && r.reenter ? void 0 : i);
|
|
5344
5374
|
}
|
|
5345
5375
|
}
|
|
@@ -5352,17 +5382,17 @@ function At(n, t, e, s) {
|
|
|
5352
5382
|
for (const o of i)
|
|
5353
5383
|
s.add(o), At(o, t, e, s);
|
|
5354
5384
|
for (const o of i)
|
|
5355
|
-
|
|
5385
|
+
Ee(o, n.parent, s, t, e);
|
|
5356
5386
|
} else {
|
|
5357
5387
|
const i = cs(n);
|
|
5358
5388
|
for (const o of i.target)
|
|
5359
5389
|
s.add(o), i === ((r = n.parent) == null ? void 0 : r.initial) && e.add(n.parent), At(o, t, e, s);
|
|
5360
5390
|
for (const o of i.target)
|
|
5361
|
-
|
|
5391
|
+
Ee(o, n.parent, s, t, e);
|
|
5362
5392
|
}
|
|
5363
5393
|
else if (n.type === "compound") {
|
|
5364
5394
|
const [i] = n.initial.target;
|
|
5365
|
-
dt(i) || (s.add(i), e.add(i)), At(i, t, e, s),
|
|
5395
|
+
dt(i) || (s.add(i), e.add(i)), At(i, t, e, s), Ee(i, n, s, t, e);
|
|
5366
5396
|
} else if (n.type === "parallel")
|
|
5367
5397
|
for (const i of Ct(n).filter((o) => !dt(o)))
|
|
5368
5398
|
[...s].some((o) => et(o, i)) || (dt(i) || (s.add(i), e.add(i)), At(i, t, e, s));
|
|
@@ -5373,23 +5403,23 @@ function ds(n, t, e, s, r) {
|
|
|
5373
5403
|
for (const o of Ct(i).filter((a) => !dt(a)))
|
|
5374
5404
|
[...n].some((a) => et(a, o)) || (n.add(o), At(o, t, e, n));
|
|
5375
5405
|
}
|
|
5376
|
-
function
|
|
5377
|
-
ds(e, s, r,
|
|
5406
|
+
function Ee(n, t, e, s, r) {
|
|
5407
|
+
ds(e, s, r, jt(n, t));
|
|
5378
5408
|
}
|
|
5379
5409
|
function go(n, t, e, s, r, i, o, a) {
|
|
5380
5410
|
let c = n;
|
|
5381
|
-
const l =
|
|
5411
|
+
const l = $e(s, r, i);
|
|
5382
5412
|
l.sort((h, d) => d.order - h.order);
|
|
5383
5413
|
let u;
|
|
5384
5414
|
for (const h of l)
|
|
5385
5415
|
for (const d of ao(h)) {
|
|
5386
|
-
let
|
|
5387
|
-
d.history === "deep" ?
|
|
5416
|
+
let g;
|
|
5417
|
+
d.history === "deep" ? g = (f) => Je(f) && et(f, h) : g = (f) => f.parent === h, u ?? (u = {
|
|
5388
5418
|
...i
|
|
5389
|
-
}), u[d.id] = Array.from(r).filter(
|
|
5419
|
+
}), u[d.id] = Array.from(r).filter(g);
|
|
5390
5420
|
}
|
|
5391
5421
|
for (const h of l)
|
|
5392
|
-
c =
|
|
5422
|
+
c = xt(c, t, e, [...h.exit, ...h.invoke.map((d) => rs(d.id))], o, void 0), r.delete(h);
|
|
5393
5423
|
return [c, u || i];
|
|
5394
5424
|
}
|
|
5395
5425
|
function yo(n, t) {
|
|
@@ -5424,7 +5454,7 @@ function fs(n, t, e, s, r, i) {
|
|
|
5424
5454
|
});
|
|
5425
5455
|
continue;
|
|
5426
5456
|
}
|
|
5427
|
-
const
|
|
5457
|
+
const g = u, [f, m, E] = g.resolve(
|
|
5428
5458
|
e,
|
|
5429
5459
|
a,
|
|
5430
5460
|
h,
|
|
@@ -5433,16 +5463,16 @@ function fs(n, t, e, s, r, i) {
|
|
|
5433
5463
|
// this holds all params
|
|
5434
5464
|
r
|
|
5435
5465
|
);
|
|
5436
|
-
a = f, "retryResolve" in
|
|
5437
|
-
type:
|
|
5466
|
+
a = f, "retryResolve" in g && (i == null || i.push([g, m])), "execute" in g && e.actionExecutor({
|
|
5467
|
+
type: g.type,
|
|
5438
5468
|
info: h,
|
|
5439
5469
|
params: m,
|
|
5440
|
-
exec:
|
|
5441
|
-
}),
|
|
5470
|
+
exec: g.execute.bind(null, e, m)
|
|
5471
|
+
}), E && (a = fs(a, t, e, E, r, i));
|
|
5442
5472
|
}
|
|
5443
5473
|
return a;
|
|
5444
5474
|
}
|
|
5445
|
-
function
|
|
5475
|
+
function xt(n, t, e, s, r, i) {
|
|
5446
5476
|
const o = i ? [] : void 0, a = fs(n, t, e, s, {
|
|
5447
5477
|
internalQueue: r,
|
|
5448
5478
|
deferredActorIds: i
|
|
@@ -5451,7 +5481,7 @@ function Mt(n, t, e, s, r, i) {
|
|
|
5451
5481
|
c.retryResolve(e, a, l);
|
|
5452
5482
|
}), a;
|
|
5453
5483
|
}
|
|
5454
|
-
function
|
|
5484
|
+
function Ae(n, t, e, s) {
|
|
5455
5485
|
let r = n;
|
|
5456
5486
|
const i = [];
|
|
5457
5487
|
function o(l, u, h) {
|
|
@@ -5463,8 +5493,8 @@ function Ee(n, t, e, s) {
|
|
|
5463
5493
|
_transitions: h
|
|
5464
5494
|
}), i.push(l);
|
|
5465
5495
|
}
|
|
5466
|
-
if (t.type ===
|
|
5467
|
-
return r = pt(
|
|
5496
|
+
if (t.type === Ce)
|
|
5497
|
+
return r = pt(Sn(r, t, e), {
|
|
5468
5498
|
status: "stopped"
|
|
5469
5499
|
}), o(r, t, []), {
|
|
5470
5500
|
snapshot: r,
|
|
@@ -5472,7 +5502,7 @@ function Ee(n, t, e, s) {
|
|
|
5472
5502
|
};
|
|
5473
5503
|
let a = t;
|
|
5474
5504
|
if (a.type !== qn) {
|
|
5475
|
-
const l = a, u = Ki(l), h =
|
|
5505
|
+
const l = a, u = Ki(l), h = Nn(l, r);
|
|
5476
5506
|
if (u && !h.length)
|
|
5477
5507
|
return r = pt(n, {
|
|
5478
5508
|
status: "error",
|
|
@@ -5481,7 +5511,7 @@ function Ee(n, t, e, s) {
|
|
|
5481
5511
|
snapshot: r,
|
|
5482
5512
|
microstates: i
|
|
5483
5513
|
};
|
|
5484
|
-
r =
|
|
5514
|
+
r = Pe(
|
|
5485
5515
|
h,
|
|
5486
5516
|
n,
|
|
5487
5517
|
e,
|
|
@@ -5498,28 +5528,28 @@ function Ee(n, t, e, s) {
|
|
|
5498
5528
|
if (!l.length) {
|
|
5499
5529
|
if (!s.length)
|
|
5500
5530
|
break;
|
|
5501
|
-
a = s.shift(), l =
|
|
5531
|
+
a = s.shift(), l = Nn(a, r);
|
|
5502
5532
|
}
|
|
5503
|
-
r =
|
|
5533
|
+
r = Pe(l, r, e, a, !1, s), c = r !== u, o(r, a, l);
|
|
5504
5534
|
}
|
|
5505
|
-
return r.status !== "active" &&
|
|
5535
|
+
return r.status !== "active" && Sn(r, a, e), {
|
|
5506
5536
|
snapshot: r,
|
|
5507
5537
|
microstates: i
|
|
5508
5538
|
};
|
|
5509
5539
|
}
|
|
5510
|
-
function
|
|
5511
|
-
return
|
|
5540
|
+
function Sn(n, t, e) {
|
|
5541
|
+
return xt(n, t, e, Object.values(n.children).map((s) => rs(s)), [], void 0);
|
|
5512
5542
|
}
|
|
5513
|
-
function
|
|
5543
|
+
function Nn(n, t) {
|
|
5514
5544
|
return t.machine.getTransitionData(t, n);
|
|
5515
5545
|
}
|
|
5516
5546
|
function mo(n, t) {
|
|
5517
|
-
const e = /* @__PURE__ */ new Set(), s = n._nodes.filter(
|
|
5547
|
+
const e = /* @__PURE__ */ new Set(), s = n._nodes.filter(Je);
|
|
5518
5548
|
for (const r of s)
|
|
5519
|
-
t: for (const i of [r].concat(
|
|
5549
|
+
t: for (const i of [r].concat(jt(r, void 0)))
|
|
5520
5550
|
if (i.always) {
|
|
5521
5551
|
for (const o of i.always)
|
|
5522
|
-
if (o.guard === void 0 ||
|
|
5552
|
+
if (o.guard === void 0 || Ve(o.guard, n.context, t, n)) {
|
|
5523
5553
|
e.add(o);
|
|
5524
5554
|
break t;
|
|
5525
5555
|
}
|
|
@@ -5527,7 +5557,7 @@ function mo(n, t) {
|
|
|
5527
5557
|
return us(Array.from(e), new Set(n._nodes), n.historyValue);
|
|
5528
5558
|
}
|
|
5529
5559
|
function wo(n, t) {
|
|
5530
|
-
const e =
|
|
5560
|
+
const e = oe(ce(n, t));
|
|
5531
5561
|
return as(n, [...e]);
|
|
5532
5562
|
}
|
|
5533
5563
|
function bo(n) {
|
|
@@ -5560,7 +5590,7 @@ const _o = function(t) {
|
|
|
5560
5590
|
}, No = function() {
|
|
5561
5591
|
return this._nodes.reduce((t, e) => (e.meta !== void 0 && (t[e.id] = e.meta), t), {});
|
|
5562
5592
|
};
|
|
5563
|
-
function
|
|
5593
|
+
function Qt(n, t) {
|
|
5564
5594
|
return {
|
|
5565
5595
|
status: n.status,
|
|
5566
5596
|
output: n.output,
|
|
@@ -5580,7 +5610,7 @@ function qt(n, t) {
|
|
|
5580
5610
|
};
|
|
5581
5611
|
}
|
|
5582
5612
|
function pt(n, t = {}) {
|
|
5583
|
-
return
|
|
5613
|
+
return Qt({
|
|
5584
5614
|
...n,
|
|
5585
5615
|
...t
|
|
5586
5616
|
}, n.machine);
|
|
@@ -5598,20 +5628,20 @@ function vo(n, t) {
|
|
|
5598
5628
|
getMeta: u,
|
|
5599
5629
|
toJSON: h,
|
|
5600
5630
|
...d
|
|
5601
|
-
} = n,
|
|
5631
|
+
} = n, g = {};
|
|
5602
5632
|
for (const m in i) {
|
|
5603
|
-
const
|
|
5604
|
-
|
|
5605
|
-
snapshot:
|
|
5606
|
-
src:
|
|
5607
|
-
systemId:
|
|
5608
|
-
syncSnapshot:
|
|
5633
|
+
const E = i[m];
|
|
5634
|
+
g[m] = {
|
|
5635
|
+
snapshot: E.getPersistedSnapshot(t),
|
|
5636
|
+
src: E.src,
|
|
5637
|
+
systemId: E._systemId,
|
|
5638
|
+
syncSnapshot: E._syncSnapshot
|
|
5609
5639
|
};
|
|
5610
5640
|
}
|
|
5611
5641
|
return {
|
|
5612
5642
|
...d,
|
|
5613
5643
|
context: ps(o),
|
|
5614
|
-
children:
|
|
5644
|
+
children: g
|
|
5615
5645
|
};
|
|
5616
5646
|
}
|
|
5617
5647
|
function ps(n) {
|
|
@@ -5623,7 +5653,7 @@ function ps(n) {
|
|
|
5623
5653
|
t ?? (t = Array.isArray(n) ? n.slice() : {
|
|
5624
5654
|
...n
|
|
5625
5655
|
}), t[e] = {
|
|
5626
|
-
xstate$$type:
|
|
5656
|
+
xstate$$type: Ge,
|
|
5627
5657
|
id: s.id
|
|
5628
5658
|
};
|
|
5629
5659
|
else {
|
|
@@ -5686,7 +5716,7 @@ function ko(n, {
|
|
|
5686
5716
|
}, s, r) {
|
|
5687
5717
|
const i = (o, a) => {
|
|
5688
5718
|
if (typeof o == "string") {
|
|
5689
|
-
const c =
|
|
5719
|
+
const c = Ze(t, o);
|
|
5690
5720
|
if (!c)
|
|
5691
5721
|
throw new Error(`Actor logic '${o}' not implemented in machine '${t.id}'`);
|
|
5692
5722
|
const l = kt(c, {
|
|
@@ -5753,27 +5783,27 @@ function Ro(n) {
|
|
|
5753
5783
|
}
|
|
5754
5784
|
return t.type = "xstate.assign", t.assignment = n, t.resolve = Co, t;
|
|
5755
5785
|
}
|
|
5756
|
-
const
|
|
5786
|
+
const vn = /* @__PURE__ */ new WeakMap();
|
|
5757
5787
|
function _t(n, t, e) {
|
|
5758
|
-
let s =
|
|
5788
|
+
let s = vn.get(n);
|
|
5759
5789
|
return s ? t in s || (s[t] = e()) : (s = {
|
|
5760
5790
|
[t]: e()
|
|
5761
|
-
},
|
|
5791
|
+
}, vn.set(n, s)), s[t];
|
|
5762
5792
|
}
|
|
5763
|
-
const
|
|
5793
|
+
const xo = {}, Ht = (n) => typeof n == "string" ? {
|
|
5764
5794
|
type: n
|
|
5765
5795
|
} : typeof n == "function" ? "resolve" in n ? {
|
|
5766
5796
|
type: n.type
|
|
5767
5797
|
} : {
|
|
5768
5798
|
type: n.name
|
|
5769
5799
|
} : n;
|
|
5770
|
-
class
|
|
5800
|
+
class Qe {
|
|
5771
5801
|
constructor(t, e) {
|
|
5772
|
-
if (this.config = t, this.key = void 0, this.id = void 0, this.type = void 0, this.path = void 0, this.states = void 0, this.history = void 0, this.entry = void 0, this.exit = void 0, this.parent = void 0, this.machine = void 0, this.meta = void 0, this.output = void 0, this.order = -1, this.description = void 0, this.tags = [], this.transitions = void 0, this.always = void 0, this.parent = e._parent, this.key = e._key, this.machine = e._machine, this.path = this.parent ? this.parent.path.concat(this.key) : [], this.id = this.config.id || [this.machine.id, ...this.path].join(Xn), this.type = this.config.type || (this.config.states && Object.keys(this.config.states).length ? "compound" : this.config.history ? "history" : "atomic"), this.description = this.config.description, this.order = this.machine.idMap.size, this.machine.idMap.set(this.id, this), this.states = this.config.states ?
|
|
5802
|
+
if (this.config = t, this.key = void 0, this.id = void 0, this.type = void 0, this.path = void 0, this.states = void 0, this.history = void 0, this.entry = void 0, this.exit = void 0, this.parent = void 0, this.machine = void 0, this.meta = void 0, this.output = void 0, this.order = -1, this.description = void 0, this.tags = [], this.transitions = void 0, this.always = void 0, this.parent = e._parent, this.key = e._key, this.machine = e._machine, this.path = this.parent ? this.parent.path.concat(this.key) : [], this.id = this.config.id || [this.machine.id, ...this.path].join(Xn), this.type = this.config.type || (this.config.states && Object.keys(this.config.states).length ? "compound" : this.config.history ? "history" : "atomic"), this.description = this.config.description, this.order = this.machine.idMap.size, this.machine.idMap.set(this.id, this), this.states = this.config.states ? bn(this.config.states, (s, r) => new Qe(s, {
|
|
5773
5803
|
_parent: this,
|
|
5774
5804
|
_key: r,
|
|
5775
5805
|
_machine: this.machine
|
|
5776
|
-
})) :
|
|
5806
|
+
})) : xo, this.type === "compound" && !this.config.initial)
|
|
5777
5807
|
throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);
|
|
5778
5808
|
this.history = this.config.history === !0 ? "shallow" : this.config.history || !1, this.entry = Q(this.config.entry).slice(), this.exit = Q(this.config.exit).slice(), this.meta = this.config.meta, this.output = this.type === "final" || !this.parent ? this.config.output : void 0, this.tags = Q(t.tags).slice();
|
|
5779
5809
|
}
|
|
@@ -5793,25 +5823,25 @@ class qe {
|
|
|
5793
5823
|
initial: this.initial ? {
|
|
5794
5824
|
target: this.initial.target,
|
|
5795
5825
|
source: this,
|
|
5796
|
-
actions: this.initial.actions.map(
|
|
5826
|
+
actions: this.initial.actions.map(Ht),
|
|
5797
5827
|
eventType: null,
|
|
5798
5828
|
reenter: !1,
|
|
5799
5829
|
toJSON: () => ({
|
|
5800
5830
|
target: this.initial.target.map((t) => `#${t.id}`),
|
|
5801
5831
|
source: `#${this.id}`,
|
|
5802
|
-
actions: this.initial.actions.map(
|
|
5832
|
+
actions: this.initial.actions.map(Ht),
|
|
5803
5833
|
eventType: null
|
|
5804
5834
|
})
|
|
5805
5835
|
} : void 0,
|
|
5806
5836
|
history: this.history,
|
|
5807
|
-
states:
|
|
5837
|
+
states: bn(this.states, (t) => t.definition),
|
|
5808
5838
|
on: this.on,
|
|
5809
5839
|
transitions: [...this.transitions.values()].flat().map((t) => ({
|
|
5810
5840
|
...t,
|
|
5811
|
-
actions: t.actions.map(
|
|
5841
|
+
actions: t.actions.map(Ht)
|
|
5812
5842
|
})),
|
|
5813
|
-
entry: this.entry.map(
|
|
5814
|
-
exit: this.exit.map(
|
|
5843
|
+
entry: this.entry.map(Ht),
|
|
5844
|
+
exit: this.exit.map(Ht),
|
|
5815
5845
|
meta: this.meta,
|
|
5816
5846
|
order: this.order || -1,
|
|
5817
5847
|
output: this.output,
|
|
@@ -5830,7 +5860,7 @@ class qe {
|
|
|
5830
5860
|
const {
|
|
5831
5861
|
src: s,
|
|
5832
5862
|
systemId: r
|
|
5833
|
-
} = t, i = t.id ??
|
|
5863
|
+
} = t, i = t.id ?? _n(this.id, e), o = typeof s == "string" ? s : `xstate.invoke.${_n(this.id, e)}`;
|
|
5834
5864
|
return {
|
|
5835
5865
|
...t,
|
|
5836
5866
|
src: o,
|
|
@@ -5873,7 +5903,7 @@ class qe {
|
|
|
5873
5903
|
} = a, l = t.context;
|
|
5874
5904
|
let u = !1;
|
|
5875
5905
|
try {
|
|
5876
|
-
u = !c ||
|
|
5906
|
+
u = !c || Ve(c, l, e, t);
|
|
5877
5907
|
} catch (h) {
|
|
5878
5908
|
const d = typeof c == "string" ? c : typeof c == "object" ? c.type : void 0;
|
|
5879
5909
|
throw new Error(`Unable to evaluate guard ${d ? `'${d}' ` : ""}in transition for event '${s}' in state node '${this.id}':
|
|
@@ -5912,15 +5942,15 @@ ${h.message}`);
|
|
|
5912
5942
|
return Array.from(t);
|
|
5913
5943
|
}
|
|
5914
5944
|
}
|
|
5915
|
-
const
|
|
5916
|
-
class
|
|
5945
|
+
const Mo = "#";
|
|
5946
|
+
class tn {
|
|
5917
5947
|
constructor(t, e) {
|
|
5918
5948
|
this.config = t, this.version = void 0, this.schemas = void 0, this.implementations = void 0, this.__xstatenode = !0, this.idMap = /* @__PURE__ */ new Map(), this.root = void 0, this.id = void 0, this.states = void 0, this.events = void 0, this.id = t.id || "(machine)", this.implementations = {
|
|
5919
5949
|
actors: (e == null ? void 0 : e.actors) ?? {},
|
|
5920
5950
|
actions: (e == null ? void 0 : e.actions) ?? {},
|
|
5921
5951
|
delays: (e == null ? void 0 : e.delays) ?? {},
|
|
5922
5952
|
guards: (e == null ? void 0 : e.guards) ?? {}
|
|
5923
|
-
}, this.version = this.config.version, this.schemas = this.config.schemas, this.transition = this.transition.bind(this), this.getInitialSnapshot = this.getInitialSnapshot.bind(this), this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this), this.restoreSnapshot = this.restoreSnapshot.bind(this), this.start = this.start.bind(this), this.root = new
|
|
5953
|
+
}, this.version = this.config.version, this.schemas = this.config.schemas, this.transition = this.transition.bind(this), this.getInitialSnapshot = this.getInitialSnapshot.bind(this), this.getPersistedSnapshot = this.getPersistedSnapshot.bind(this), this.restoreSnapshot = this.restoreSnapshot.bind(this), this.start = this.start.bind(this), this.root = new Qe(t, {
|
|
5924
5954
|
_key: this.id,
|
|
5925
5955
|
_machine: this
|
|
5926
5956
|
}), this.root._initialize(), this.states = this.root.states, this.events = this.root.events;
|
|
@@ -5940,7 +5970,7 @@ class Qe {
|
|
|
5940
5970
|
actors: r,
|
|
5941
5971
|
delays: i
|
|
5942
5972
|
} = this.implementations;
|
|
5943
|
-
return new
|
|
5973
|
+
return new tn(this.config, {
|
|
5944
5974
|
actions: {
|
|
5945
5975
|
...e,
|
|
5946
5976
|
...t.actions
|
|
@@ -5960,12 +5990,12 @@ class Qe {
|
|
|
5960
5990
|
});
|
|
5961
5991
|
}
|
|
5962
5992
|
resolveState(t) {
|
|
5963
|
-
const e = wo(this.root, t.value), s =
|
|
5964
|
-
return
|
|
5993
|
+
const e = wo(this.root, t.value), s = oe(ce(this.root, e));
|
|
5994
|
+
return Qt({
|
|
5965
5995
|
_nodes: [...s],
|
|
5966
5996
|
context: t.context || {},
|
|
5967
5997
|
children: {},
|
|
5968
|
-
status:
|
|
5998
|
+
status: Xe(s, this.root) ? "done" : t.status || "active",
|
|
5969
5999
|
output: t.output,
|
|
5970
6000
|
error: t.error,
|
|
5971
6001
|
historyValue: t.historyValue
|
|
@@ -5979,7 +6009,7 @@ class Qe {
|
|
|
5979
6009
|
* @param event The received event
|
|
5980
6010
|
*/
|
|
5981
6011
|
transition(t, e, s) {
|
|
5982
|
-
return
|
|
6012
|
+
return Ae(t, e, s, []).snapshot;
|
|
5983
6013
|
}
|
|
5984
6014
|
/**
|
|
5985
6015
|
* Determines the next state given the current `state` and `event`. Calculates
|
|
@@ -5989,10 +6019,10 @@ class Qe {
|
|
|
5989
6019
|
* @param event The received event
|
|
5990
6020
|
*/
|
|
5991
6021
|
microstep(t, e, s) {
|
|
5992
|
-
return
|
|
6022
|
+
return Ae(t, e, s, []).microstates;
|
|
5993
6023
|
}
|
|
5994
6024
|
getTransitionData(t, e) {
|
|
5995
|
-
return
|
|
6025
|
+
return Ye(this.root, t.value, t, e) || [];
|
|
5996
6026
|
}
|
|
5997
6027
|
/**
|
|
5998
6028
|
* The initial state _before_ evaluating any microsteps. This "pre-initial"
|
|
@@ -6001,13 +6031,13 @@ class Qe {
|
|
|
6001
6031
|
getPreInitialState(t, e, s) {
|
|
6002
6032
|
const {
|
|
6003
6033
|
context: r
|
|
6004
|
-
} = this.config, i =
|
|
6034
|
+
} = this.config, i = Qt({
|
|
6005
6035
|
context: typeof r != "function" && r ? r : {},
|
|
6006
6036
|
_nodes: [this.root],
|
|
6007
6037
|
children: {},
|
|
6008
6038
|
status: "active"
|
|
6009
6039
|
}, this);
|
|
6010
|
-
return typeof r == "function" ?
|
|
6040
|
+
return typeof r == "function" ? xt(i, e, t, [Ro(({
|
|
6011
6041
|
spawn: a,
|
|
6012
6042
|
event: c,
|
|
6013
6043
|
self: l
|
|
@@ -6022,7 +6052,7 @@ class Qe {
|
|
|
6022
6052
|
* `ActorRef`.
|
|
6023
6053
|
*/
|
|
6024
6054
|
getInitialSnapshot(t, e) {
|
|
6025
|
-
const s = Qn(e), r = [], i = this.getPreInitialState(t, s, r), o =
|
|
6055
|
+
const s = Qn(e), r = [], i = this.getPreInitialState(t, s, r), o = Pe([{
|
|
6026
6056
|
target: [...ls(this.root)],
|
|
6027
6057
|
source: this.root,
|
|
6028
6058
|
reenter: !0,
|
|
@@ -6032,7 +6062,7 @@ class Qe {
|
|
|
6032
6062
|
// TODO: fix
|
|
6033
6063
|
}], i, t, s, !0, r), {
|
|
6034
6064
|
snapshot: a
|
|
6035
|
-
} =
|
|
6065
|
+
} = Ae(o, s, t, r);
|
|
6036
6066
|
return a;
|
|
6037
6067
|
}
|
|
6038
6068
|
start(t) {
|
|
@@ -6041,10 +6071,10 @@ class Qe {
|
|
|
6041
6071
|
});
|
|
6042
6072
|
}
|
|
6043
6073
|
getStateNodeById(t) {
|
|
6044
|
-
const e =
|
|
6074
|
+
const e = Fe(t), s = e.slice(1), r = fe(e[0]) ? e[0].slice(Mo.length) : e[0], i = this.idMap.get(r);
|
|
6045
6075
|
if (!i)
|
|
6046
6076
|
throw new Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);
|
|
6047
|
-
return
|
|
6077
|
+
return ae(i, s);
|
|
6048
6078
|
}
|
|
6049
6079
|
get definition() {
|
|
6050
6080
|
return this.root.definition;
|
|
@@ -6058,10 +6088,10 @@ class Qe {
|
|
|
6058
6088
|
restoreSnapshot(t, e) {
|
|
6059
6089
|
const s = {}, r = t.children;
|
|
6060
6090
|
Object.keys(r).forEach((c) => {
|
|
6061
|
-
const l = r[c], u = l.snapshot, h = l.src, d = typeof h == "string" ?
|
|
6091
|
+
const l = r[c], u = l.snapshot, h = l.src, d = typeof h == "string" ? Ze(this, h) : h;
|
|
6062
6092
|
if (!d)
|
|
6063
6093
|
return;
|
|
6064
|
-
const
|
|
6094
|
+
const g = kt(d, {
|
|
6065
6095
|
id: c,
|
|
6066
6096
|
parent: e.self,
|
|
6067
6097
|
syncSnapshot: l.syncSnapshot,
|
|
@@ -6069,12 +6099,12 @@ class Qe {
|
|
|
6069
6099
|
src: h,
|
|
6070
6100
|
systemId: l.systemId
|
|
6071
6101
|
});
|
|
6072
|
-
s[c] =
|
|
6102
|
+
s[c] = g;
|
|
6073
6103
|
});
|
|
6074
|
-
const i =
|
|
6104
|
+
const i = Qt({
|
|
6075
6105
|
...t,
|
|
6076
6106
|
children: s,
|
|
6077
|
-
_nodes: Array.from(
|
|
6107
|
+
_nodes: Array.from(oe(ce(this.root, t.value)))
|
|
6078
6108
|
}, this), o = /* @__PURE__ */ new Set();
|
|
6079
6109
|
function a(c, l) {
|
|
6080
6110
|
if (!o.has(c)) {
|
|
@@ -6082,7 +6112,7 @@ class Qe {
|
|
|
6082
6112
|
for (const u in c) {
|
|
6083
6113
|
const h = c[u];
|
|
6084
6114
|
if (h && typeof h == "object") {
|
|
6085
|
-
if ("xstate$$type" in h && h.xstate$$type ===
|
|
6115
|
+
if ("xstate$$type" in h && h.xstate$$type === Ge) {
|
|
6086
6116
|
c[u] = l[h.id];
|
|
6087
6117
|
continue;
|
|
6088
6118
|
}
|
|
@@ -6095,20 +6125,20 @@ class Qe {
|
|
|
6095
6125
|
}
|
|
6096
6126
|
}
|
|
6097
6127
|
function $o(n, t) {
|
|
6098
|
-
return new
|
|
6128
|
+
return new tn(n, t);
|
|
6099
6129
|
}
|
|
6100
|
-
const
|
|
6130
|
+
const Vt = (n) => n === !1 ? !1 : n.map((t) => t.serialize()), Po = (n) => n === !1 ? !1 : n.serialize(), Ho = (n) => n === !1 ? !1 : n.map((t) => ({
|
|
6101
6131
|
tile: t.tile.toString(),
|
|
6102
6132
|
candidates: t.candidates.map((e) => e.toString()),
|
|
6103
6133
|
shanten: t.shanten
|
|
6104
|
-
})), He = (n) => JSON.parse(JSON.stringify(n)),
|
|
6134
|
+
})), He = (n) => JSON.parse(JSON.stringify(n)), Jt = (n) => n === !1 ? !1 : He(n), Tn = (n) => $o(
|
|
6105
6135
|
{
|
|
6106
6136
|
id: "Untitled",
|
|
6107
6137
|
initial: "distribute",
|
|
6108
6138
|
context: {
|
|
6109
|
-
currentWind:
|
|
6110
|
-
oneShotMap:
|
|
6111
|
-
missingMap:
|
|
6139
|
+
currentWind: A.E,
|
|
6140
|
+
oneShotMap: P(!1),
|
|
6141
|
+
missingMap: P(!1),
|
|
6112
6142
|
controller: n,
|
|
6113
6143
|
genEventID: Wo()
|
|
6114
6144
|
},
|
|
@@ -6426,8 +6456,8 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6426
6456
|
},
|
|
6427
6457
|
notify_distribution: ({ context: t, event: e }) => {
|
|
6428
6458
|
const s = t.genEventID(), r = t.controller.initialHands();
|
|
6429
|
-
for (const i of Object.values(
|
|
6430
|
-
const o =
|
|
6459
|
+
for (const i of Object.values(A)) {
|
|
6460
|
+
const o = P("_____________");
|
|
6431
6461
|
o[i] = r[i].toString();
|
|
6432
6462
|
const a = {
|
|
6433
6463
|
id: s,
|
|
@@ -6452,15 +6482,15 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6452
6482
|
wind: r,
|
|
6453
6483
|
drawerInfo: { wind: r, tile: i.toString() },
|
|
6454
6484
|
choices: {
|
|
6455
|
-
TSUMO:
|
|
6485
|
+
TSUMO: Jt(
|
|
6456
6486
|
t.controller.doWin(r, i, {
|
|
6457
6487
|
oneShot: t.oneShotMap[r],
|
|
6458
6488
|
replacementWin: s == null ? void 0 : s.replacementWin
|
|
6459
6489
|
})
|
|
6460
6490
|
),
|
|
6461
|
-
REACH:
|
|
6462
|
-
AN_KAN:
|
|
6463
|
-
SHO_KAN:
|
|
6491
|
+
REACH: Ho(t.controller.doReach(r)),
|
|
6492
|
+
AN_KAN: Vt(t.controller.doAnKan(r)),
|
|
6493
|
+
SHO_KAN: Vt(t.controller.doShoKan(r)),
|
|
6464
6494
|
DISCARD: t.controller.doDiscard(r).map((c) => c.toString()),
|
|
6465
6495
|
DRAWN_GAME_BY_NINE_ORPHANS: t.controller.canDrawnGame(r)
|
|
6466
6496
|
}
|
|
@@ -6468,8 +6498,8 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6468
6498
|
t.controller.emit(a), t.controller.pollReplies(o, [r]);
|
|
6469
6499
|
},
|
|
6470
6500
|
notify_choice_after_discarded: ({ context: t, event: e }) => {
|
|
6471
|
-
const s = t.genEventID(), r = t.controller.river.lastTile, i = r.t.clone({ add:
|
|
6472
|
-
for (const o of Object.values(
|
|
6501
|
+
const s = t.genEventID(), r = t.controller.river.lastTile, i = r.t.clone({ add: y.HORIZONTAL });
|
|
6502
|
+
for (const o of Object.values(A)) {
|
|
6473
6503
|
const a = {
|
|
6474
6504
|
id: s,
|
|
6475
6505
|
type: "CHOICE_AFTER_DISCARDED",
|
|
@@ -6479,27 +6509,27 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6479
6509
|
tile: r.t.toString()
|
|
6480
6510
|
},
|
|
6481
6511
|
choices: {
|
|
6482
|
-
RON:
|
|
6512
|
+
RON: Jt(
|
|
6483
6513
|
t.controller.doWin(o, i, {
|
|
6484
6514
|
discardedBy: r.w,
|
|
6485
6515
|
oneShot: t.oneShotMap[o],
|
|
6486
6516
|
missingRon: t.missingMap[o]
|
|
6487
6517
|
})
|
|
6488
6518
|
),
|
|
6489
|
-
PON:
|
|
6519
|
+
PON: Vt(
|
|
6490
6520
|
t.controller.doPon(o, r.w, i)
|
|
6491
6521
|
),
|
|
6492
|
-
CHI:
|
|
6522
|
+
CHI: Vt(
|
|
6493
6523
|
t.controller.doChi(o, r.w, i)
|
|
6494
6524
|
),
|
|
6495
|
-
DAI_KAN:
|
|
6525
|
+
DAI_KAN: Po(
|
|
6496
6526
|
t.controller.doDaiKan(o, r.w, i)
|
|
6497
6527
|
)
|
|
6498
6528
|
}
|
|
6499
6529
|
};
|
|
6500
6530
|
a.choices.RON && (t.missingMap[o] = !0), t.controller.emit(a);
|
|
6501
6531
|
}
|
|
6502
|
-
t.controller.pollReplies(s, Object.values(
|
|
6532
|
+
t.controller.pollReplies(s, Object.values(A));
|
|
6503
6533
|
},
|
|
6504
6534
|
notify_choice_after_called: ({ context: t, event: e }, s) => {
|
|
6505
6535
|
const r = t.genEventID(), i = t.currentWind;
|
|
@@ -6517,15 +6547,15 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6517
6547
|
t.controller.emit(c), t.controller.pollReplies(r, [i]);
|
|
6518
6548
|
},
|
|
6519
6549
|
notify_choice_for_reach_acceptance: ({ context: t, event: e }) => {
|
|
6520
|
-
const s = t.genEventID(), r = t.controller.river.lastTile, i = r.t.clone({ add:
|
|
6521
|
-
for (const o of Object.values(
|
|
6550
|
+
const s = t.genEventID(), r = t.controller.river.lastTile, i = r.t.clone({ add: y.HORIZONTAL });
|
|
6551
|
+
for (const o of Object.values(A)) {
|
|
6522
6552
|
const a = {
|
|
6523
6553
|
id: s,
|
|
6524
6554
|
type: "CHOICE_FOR_REACH_ACCEPTANCE",
|
|
6525
6555
|
wind: o,
|
|
6526
6556
|
reacherInfo: { wind: r.w, tile: i.toString() },
|
|
6527
6557
|
choices: {
|
|
6528
|
-
RON:
|
|
6558
|
+
RON: Jt(
|
|
6529
6559
|
t.controller.doWin(o, i, {
|
|
6530
6560
|
discardedBy: r.w,
|
|
6531
6561
|
oneShot: t.oneShotMap[o],
|
|
@@ -6536,18 +6566,18 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6536
6566
|
};
|
|
6537
6567
|
t.controller.emit(a);
|
|
6538
6568
|
}
|
|
6539
|
-
t.controller.pollReplies(s, Object.values(
|
|
6569
|
+
t.controller.pollReplies(s, Object.values(A));
|
|
6540
6570
|
},
|
|
6541
6571
|
notify_choice_for_chankan: ({ context: t, event: e }) => {
|
|
6542
6572
|
N(
|
|
6543
6573
|
e.type == "SHO_KAN" || e.type == "AN_KAN",
|
|
6544
6574
|
`unexpected event ${e.type}`
|
|
6545
6575
|
);
|
|
6546
|
-
const s = t.genEventID(), r = e.block.tiles[0].clone({ remove:
|
|
6547
|
-
for (const i of Object.values(
|
|
6576
|
+
const s = t.genEventID(), r = e.block.tiles[0].clone({ remove: y.HORIZONTAL });
|
|
6577
|
+
for (const i of Object.values(A)) {
|
|
6548
6578
|
const o = t.controller.doWin(
|
|
6549
6579
|
i,
|
|
6550
|
-
e.block.tiles[0].clone({ remove:
|
|
6580
|
+
e.block.tiles[0].clone({ remove: y.HORIZONTAL }),
|
|
6551
6581
|
{
|
|
6552
6582
|
discardedBy: e.iam,
|
|
6553
6583
|
quadWin: !0,
|
|
@@ -6560,12 +6590,12 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6560
6590
|
wind: i,
|
|
6561
6591
|
callerInfo: { wind: e.iam, tile: r.toString() },
|
|
6562
6592
|
choices: {
|
|
6563
|
-
RON: e.type == "SHO_KAN" ?
|
|
6593
|
+
RON: e.type == "SHO_KAN" ? Jt(o) : !1
|
|
6564
6594
|
}
|
|
6565
6595
|
};
|
|
6566
6596
|
a.choices.RON && (t.missingMap[i] = !0), t.controller.emit(a);
|
|
6567
6597
|
}
|
|
6568
|
-
t.controller.pollReplies(s, Object.values(
|
|
6598
|
+
t.controller.pollReplies(s, Object.values(A));
|
|
6569
6599
|
},
|
|
6570
6600
|
notify_call: ({ context: t, event: e }) => {
|
|
6571
6601
|
N(
|
|
@@ -6574,7 +6604,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6574
6604
|
);
|
|
6575
6605
|
const s = t.genEventID(), r = e.iam;
|
|
6576
6606
|
t.currentWind = r;
|
|
6577
|
-
for (const i of Object.values(
|
|
6607
|
+
for (const i of Object.values(A)) {
|
|
6578
6608
|
const o = {
|
|
6579
6609
|
id: s,
|
|
6580
6610
|
type: e.type,
|
|
@@ -6589,7 +6619,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6589
6619
|
notify_discard: ({ context: t, event: e }) => {
|
|
6590
6620
|
N(e.type == "DISCARD", `unexpected event ${e.type}`);
|
|
6591
6621
|
const s = t.genEventID(), r = t.currentWind, i = e.tile;
|
|
6592
|
-
for (const o of Object.values(
|
|
6622
|
+
for (const o of Object.values(A)) {
|
|
6593
6623
|
const a = {
|
|
6594
6624
|
id: s,
|
|
6595
6625
|
type: "DISCARD",
|
|
@@ -6607,8 +6637,8 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6607
6637
|
i == "kan" ? o = t.controller.wall.kan() : o = t.controller.wall.draw();
|
|
6608
6638
|
const a = t.currentWind;
|
|
6609
6639
|
t.controller.hand(a).reached || (t.missingMap[a] = !1);
|
|
6610
|
-
for (const c of Object.values(
|
|
6611
|
-
let l = new w(p.BACK, 0, [
|
|
6640
|
+
for (const c of Object.values(A)) {
|
|
6641
|
+
let l = new w(p.BACK, 0, [y.TSUMO]);
|
|
6612
6642
|
c == a && (l = o);
|
|
6613
6643
|
const u = {
|
|
6614
6644
|
id: r,
|
|
@@ -6625,7 +6655,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6625
6655
|
notify_ron: ({ context: t, event: e }) => {
|
|
6626
6656
|
N(e.type == "RON");
|
|
6627
6657
|
const s = t.genEventID(), r = e.iam;
|
|
6628
|
-
for (const i of Object.values(
|
|
6658
|
+
for (const i of Object.values(A)) {
|
|
6629
6659
|
const o = {
|
|
6630
6660
|
id: s,
|
|
6631
6661
|
type: e.type,
|
|
@@ -6643,7 +6673,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6643
6673
|
notify_tsumo: ({ context: t, event: e }) => {
|
|
6644
6674
|
N(e.type == "TSUMO", `unexpected event ${e.type}`);
|
|
6645
6675
|
const s = t.genEventID(), r = t.currentWind;
|
|
6646
|
-
for (const i of Object.values(
|
|
6676
|
+
for (const i of Object.values(A)) {
|
|
6647
6677
|
const o = {
|
|
6648
6678
|
id: s,
|
|
6649
6679
|
type: e.type,
|
|
@@ -6657,9 +6687,9 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6657
6687
|
},
|
|
6658
6688
|
notify_reach: ({ context: t, event: e }) => {
|
|
6659
6689
|
N(e.type == "REACH", `unexpected event ${e.type}`);
|
|
6660
|
-
const s = t.genEventID(), r = e.iam, i = e.tile.clone({ add:
|
|
6690
|
+
const s = t.genEventID(), r = e.iam, i = e.tile.clone({ add: y.HORIZONTAL });
|
|
6661
6691
|
t.oneShotMap[r] = !0;
|
|
6662
|
-
for (const o of Object.values(
|
|
6692
|
+
for (const o of Object.values(A)) {
|
|
6663
6693
|
const a = {
|
|
6664
6694
|
id: s,
|
|
6665
6695
|
type: e.type,
|
|
@@ -6673,7 +6703,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6673
6703
|
notify_reach_accepted: ({ context: t, event: e }) => {
|
|
6674
6704
|
N(e.type == "REACH_ACCEPT");
|
|
6675
6705
|
const s = t.genEventID();
|
|
6676
|
-
for (const r of Object.values(
|
|
6706
|
+
for (const r of Object.values(A)) {
|
|
6677
6707
|
const i = {
|
|
6678
6708
|
id: s,
|
|
6679
6709
|
type: "REACH_ACCEPTED",
|
|
@@ -6691,7 +6721,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6691
6721
|
const s = t.genEventID();
|
|
6692
6722
|
if (e.type == "AN_KAN") {
|
|
6693
6723
|
const r = t.controller.wall.openDoraMarker();
|
|
6694
|
-
for (const i of Object.values(
|
|
6724
|
+
for (const i of Object.values(A)) {
|
|
6695
6725
|
const o = {
|
|
6696
6726
|
id: s,
|
|
6697
6727
|
type: "NEW_DORA",
|
|
@@ -6704,16 +6734,16 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6704
6734
|
e.type == "SHO_KAN";
|
|
6705
6735
|
},
|
|
6706
6736
|
disable_one_shot: ({ context: t, event: e }) => {
|
|
6707
|
-
for (const s of Object.values(
|
|
6737
|
+
for (const s of Object.values(A)) t.oneShotMap[s] = !1;
|
|
6708
6738
|
},
|
|
6709
6739
|
disable_one_shot_for_me: ({ context: t, event: e }) => {
|
|
6710
6740
|
t.oneShotMap[t.currentWind] = !1;
|
|
6711
6741
|
},
|
|
6712
6742
|
notify_end: ({ context: t, event: e }) => {
|
|
6713
|
-
const s = t.genEventID(), r =
|
|
6743
|
+
const s = t.genEventID(), r = P("");
|
|
6714
6744
|
if (e.type == "DRAWN_GAME_BY_NINE_ORPHANS") {
|
|
6715
6745
|
r[e.iam] = t.controller.hand(e.iam).toString();
|
|
6716
|
-
for (const i of Object.values(
|
|
6746
|
+
for (const i of Object.values(A)) {
|
|
6717
6747
|
const o = {
|
|
6718
6748
|
id: s,
|
|
6719
6749
|
type: "END_GAME",
|
|
@@ -6722,17 +6752,17 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6722
6752
|
shouldContinue: !0,
|
|
6723
6753
|
sticks: t.controller.placeManager.sticks,
|
|
6724
6754
|
scores: t.controller.scoreManager.summary,
|
|
6725
|
-
deltas:
|
|
6755
|
+
deltas: P(0),
|
|
6726
6756
|
hands: r
|
|
6727
6757
|
};
|
|
6728
6758
|
t.controller.emit(o);
|
|
6729
6759
|
}
|
|
6730
6760
|
} else if (e.type == "RON" || e.type == "TSUMO") {
|
|
6731
|
-
const i = e.iam ==
|
|
6761
|
+
const i = e.iam == A.E, o = t.controller.finalResult(
|
|
6732
6762
|
e.ret,
|
|
6733
6763
|
e.iam
|
|
6734
6764
|
);
|
|
6735
|
-
for (const a of Object.values(
|
|
6765
|
+
for (const a of Object.values(A)) {
|
|
6736
6766
|
r[e.iam] = t.controller.hand(e.iam).toString();
|
|
6737
6767
|
const c = {
|
|
6738
6768
|
id: s,
|
|
@@ -6749,7 +6779,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6749
6779
|
}
|
|
6750
6780
|
} else if (!t.controller.wall.canKan || t.controller.river.cannotContinue()) {
|
|
6751
6781
|
const i = t.controller.wall.canKan ? "FOUR_WIND" : "FOUR_KAN";
|
|
6752
|
-
for (const o of Object.values(
|
|
6782
|
+
for (const o of Object.values(A)) {
|
|
6753
6783
|
const a = {
|
|
6754
6784
|
id: s,
|
|
6755
6785
|
type: "END_GAME",
|
|
@@ -6758,8 +6788,8 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6758
6788
|
shouldContinue: !0,
|
|
6759
6789
|
sticks: t.controller.placeManager.sticks,
|
|
6760
6790
|
scores: t.controller.scoreManager.summary,
|
|
6761
|
-
deltas:
|
|
6762
|
-
hands:
|
|
6791
|
+
deltas: P(0),
|
|
6792
|
+
hands: P("")
|
|
6763
6793
|
};
|
|
6764
6794
|
t.controller.emit(a);
|
|
6765
6795
|
}
|
|
@@ -6768,15 +6798,15 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6768
6798
|
throw new Error(`unexpected event ${e.type}`);
|
|
6769
6799
|
{
|
|
6770
6800
|
const i = [];
|
|
6771
|
-
for (const l of Object.values(
|
|
6801
|
+
for (const l of Object.values(A)) {
|
|
6772
6802
|
const u = t.controller.hand(l);
|
|
6773
|
-
new
|
|
6803
|
+
new de(u).calc() == 0 && (i.push(l), r[l] = u.toString());
|
|
6774
6804
|
}
|
|
6775
|
-
const o = i.length == 0 || i.length == 4, a =
|
|
6776
|
-
for (const l of Object.values(
|
|
6805
|
+
const o = i.length == 0 || i.length == 4, a = P(0);
|
|
6806
|
+
for (const l of Object.values(A))
|
|
6777
6807
|
i.includes(l) ? a[l] += o ? 0 : 3e3 / i.length : a[l] -= o ? 0 : 3e3 / (4 - i.length);
|
|
6778
|
-
const c = i.length == 4 || a[
|
|
6779
|
-
for (const l of Object.values(
|
|
6808
|
+
const c = i.length == 4 || a[A.E] > 0;
|
|
6809
|
+
for (const l of Object.values(A)) {
|
|
6780
6810
|
const u = {
|
|
6781
6811
|
id: s,
|
|
6782
6812
|
type: "END_GAME",
|
|
@@ -6858,12 +6888,12 @@ class vt {
|
|
|
6858
6888
|
return this.walls.drawable.length > 0;
|
|
6859
6889
|
}
|
|
6860
6890
|
initialHands() {
|
|
6861
|
-
const t =
|
|
6891
|
+
const t = P("");
|
|
6862
6892
|
for (let e = 0; e < 3; e++)
|
|
6863
|
-
for (const s of Object.values(
|
|
6893
|
+
for (const s of Object.values(A))
|
|
6864
6894
|
for (let r = 0; r < 4; r++)
|
|
6865
6895
|
t[s] += this.draw().toString();
|
|
6866
|
-
for (const e of Object.values(
|
|
6896
|
+
for (const e of Object.values(A)) t[e] += this.draw().toString();
|
|
6867
6897
|
return t;
|
|
6868
6898
|
}
|
|
6869
6899
|
init(t) {
|
|
@@ -6877,7 +6907,7 @@ class vt {
|
|
|
6877
6907
|
for (let r = 0; r < 4; r++)
|
|
6878
6908
|
for (let i of s) {
|
|
6879
6909
|
let o = new w(e, i);
|
|
6880
|
-
e != p.Z && r == 3 && i == 5 && (o = o.clone({ add:
|
|
6910
|
+
e != p.Z && r == 3 && i == 5 && (o = o.clone({ add: y.RED })), this.walls.drawable.push(o.toString());
|
|
6881
6911
|
}
|
|
6882
6912
|
}
|
|
6883
6913
|
Vn(this.walls.drawable);
|
|
@@ -6904,11 +6934,11 @@ class vt {
|
|
|
6904
6934
|
};
|
|
6905
6935
|
}
|
|
6906
6936
|
}
|
|
6907
|
-
class
|
|
6937
|
+
class pe {
|
|
6908
6938
|
constructor(t, e) {
|
|
6909
6939
|
_(this, "wall", new vt());
|
|
6910
6940
|
_(this, "playerIDs");
|
|
6911
|
-
_(this, "actor", kt(
|
|
6941
|
+
_(this, "actor", kt(Tn(this), {}));
|
|
6912
6942
|
_(this, "observer");
|
|
6913
6943
|
_(this, "handlers", {});
|
|
6914
6944
|
_(this, "mailBox", {});
|
|
@@ -6924,20 +6954,20 @@ class fe {
|
|
|
6924
6954
|
// bind
|
|
6925
6955
|
);
|
|
6926
6956
|
const r = Object.fromEntries(this.playerIDs.map((o) => [o, 25e3]));
|
|
6927
|
-
this.observer.scoreManager = new
|
|
6957
|
+
this.observer.scoreManager = new re(r);
|
|
6928
6958
|
const i = (e == null ? void 0 : e.shuffle) == !1 ? this.playerIDs : Vn([...this.playerIDs]);
|
|
6929
|
-
this.observer.placeManager = new
|
|
6930
|
-
[i[0]]:
|
|
6931
|
-
[i[1]]:
|
|
6932
|
-
[i[2]]:
|
|
6933
|
-
[i[3]]:
|
|
6959
|
+
this.observer.placeManager = new ie({
|
|
6960
|
+
[i[0]]: A.E,
|
|
6961
|
+
[i[1]]: A.S,
|
|
6962
|
+
[i[2]]: A.W,
|
|
6963
|
+
[i[3]]: A.N
|
|
6934
6964
|
});
|
|
6935
6965
|
}
|
|
6936
6966
|
boardParams(t) {
|
|
6937
6967
|
let s = this.hand(t).reached ? 1 : void 0;
|
|
6938
6968
|
if (s) {
|
|
6939
6969
|
const r = this.river.discards(t);
|
|
6940
|
-
s = r.length == 0 || r.length == 1 && r[0].t.has(
|
|
6970
|
+
s = r.length == 0 || r.length == 1 && r[0].t.has(y.HORIZONTAL) ? 2 : 1;
|
|
6941
6971
|
}
|
|
6942
6972
|
return {
|
|
6943
6973
|
doraMarkers: this.observer.doraMarkers,
|
|
@@ -7001,7 +7031,7 @@ class fe {
|
|
|
7001
7031
|
N(o.choices.RON, "ron choice is none"), this.actor.send({
|
|
7002
7032
|
type: i.type,
|
|
7003
7033
|
iam: o.wind,
|
|
7004
|
-
ret:
|
|
7034
|
+
ret: Zt(o.choices.RON),
|
|
7005
7035
|
targetInfo: {
|
|
7006
7036
|
wind: o.discarterInfo.wind,
|
|
7007
7037
|
tile: w.from(o.discarterInfo.tile)
|
|
@@ -7040,7 +7070,7 @@ class fe {
|
|
|
7040
7070
|
case "TSUMO":
|
|
7041
7071
|
N(o.choices.TSUMO, "tsumo choice is none"), this.actor.send({
|
|
7042
7072
|
type: i.type,
|
|
7043
|
-
ret:
|
|
7073
|
+
ret: Zt(o.choices.TSUMO),
|
|
7044
7074
|
lastTile: w.from(o.drawerInfo.tile),
|
|
7045
7075
|
iam: a
|
|
7046
7076
|
});
|
|
@@ -7057,7 +7087,7 @@ class fe {
|
|
|
7057
7087
|
const l = o.choices[i.type];
|
|
7058
7088
|
N(l, `${i.type} choice is none`), this.actor.send({
|
|
7059
7089
|
type: i.type,
|
|
7060
|
-
tile: w.from(l[0]).clone({ remove:
|
|
7090
|
+
tile: w.from(l[0]).clone({ remove: y.TSUMO }),
|
|
7061
7091
|
iam: a
|
|
7062
7092
|
});
|
|
7063
7093
|
break;
|
|
@@ -7065,7 +7095,7 @@ class fe {
|
|
|
7065
7095
|
const u = o.choices[i.type];
|
|
7066
7096
|
N(u, `${i.type} choice is none`), this.actor.send({
|
|
7067
7097
|
type: i.type,
|
|
7068
|
-
block:
|
|
7098
|
+
block: M.from(u[0].tiles),
|
|
7069
7099
|
iam: a
|
|
7070
7100
|
});
|
|
7071
7101
|
break;
|
|
@@ -7110,7 +7140,7 @@ class fe {
|
|
|
7110
7140
|
this.actor.send({
|
|
7111
7141
|
type: "RON",
|
|
7112
7142
|
iam: o.wind,
|
|
7113
|
-
ret:
|
|
7143
|
+
ret: Zt(o.choices.RON),
|
|
7114
7144
|
targetInfo: {
|
|
7115
7145
|
wind: o.reacherInfo.wind,
|
|
7116
7146
|
tile: w.from(o.reacherInfo.tile)
|
|
@@ -7127,7 +7157,7 @@ class fe {
|
|
|
7127
7157
|
N(o.choices.RON, "ron choice is none"), this.actor.send({
|
|
7128
7158
|
type: "RON",
|
|
7129
7159
|
iam: o.wind,
|
|
7130
|
-
ret:
|
|
7160
|
+
ret: Zt(o.choices.RON),
|
|
7131
7161
|
quadWin: !0,
|
|
7132
7162
|
targetInfo: {
|
|
7133
7163
|
wind: o.callerInfo.wind,
|
|
@@ -7147,11 +7177,11 @@ class fe {
|
|
|
7147
7177
|
},
|
|
7148
7178
|
on: (a) => {
|
|
7149
7179
|
}
|
|
7150
|
-
}, i = s.map((a) => ({ id: a, handler: r })), o = new
|
|
7151
|
-
return o.playerIDs = s, o.mailBox = e, o.observer.placeManager = new
|
|
7180
|
+
}, i = s.map((a) => ({ id: a, handler: r })), o = new pe(i);
|
|
7181
|
+
return o.playerIDs = s, o.mailBox = e, o.observer.placeManager = new ie(t.players, {
|
|
7152
7182
|
round: t.round,
|
|
7153
7183
|
sticks: structuredClone(t.sticks)
|
|
7154
|
-
}), o.observer.scoreManager = new
|
|
7184
|
+
}), o.observer.scoreManager = new re(t.scores), o.wall = new vt(t.wall), o;
|
|
7155
7185
|
}
|
|
7156
7186
|
start() {
|
|
7157
7187
|
this.actor.subscribe((s) => {
|
|
@@ -7173,11 +7203,11 @@ class fe {
|
|
|
7173
7203
|
);
|
|
7174
7204
|
}
|
|
7175
7205
|
startGame() {
|
|
7176
|
-
for (; console.debug(`start========${this.placeManager.round}=============`), this.start(), this.wall = new vt(), this.observer.applied = {}, this.mailBox = {}, this.actor = kt(
|
|
7206
|
+
for (; console.debug(`start========${this.placeManager.round}=============`), this.start(), this.wall = new vt(), this.observer.applied = {}, this.mailBox = {}, this.actor = kt(Tn(this)), !this.placeManager.is(k.W1); )
|
|
7177
7207
|
;
|
|
7178
7208
|
}
|
|
7179
7209
|
finalResult(t, e) {
|
|
7180
|
-
const s = this.hand(e), r = s.reached ? this.wall.blindDoraMarkers : void 0, i = new
|
|
7210
|
+
const s = this.hand(e), r = s.reached ? this.wall.blindDoraMarkers : void 0, i = new pn(s, {
|
|
7181
7211
|
...t.boardContext,
|
|
7182
7212
|
sticks: this.placeManager.sticks,
|
|
7183
7213
|
blindDoraMarkers: r
|
|
@@ -7195,10 +7225,10 @@ class fe {
|
|
|
7195
7225
|
} else
|
|
7196
7226
|
i.finalWallWin = !this.wall.canDraw, i.replacementWin = s == null ? void 0 : s.replacementWin;
|
|
7197
7227
|
i.oneShotWin = s == null ? void 0 : s.oneShot;
|
|
7198
|
-
const o = new Ai(r), a = new
|
|
7228
|
+
const o = new Ai(r), a = new pn(r, i), c = o.calc(e), l = a.calc(...c);
|
|
7199
7229
|
if (!l || l.points.length == 0) return !1;
|
|
7200
7230
|
if (r.draw == null) {
|
|
7201
|
-
const u =
|
|
7231
|
+
const u = zt.candidateTiles(this.hand(t)).candidates;
|
|
7202
7232
|
if (this.river.discards(t).some((h) => u.some((d) => d.equals(h.t))))
|
|
7203
7233
|
return !1;
|
|
7204
7234
|
}
|
|
@@ -7208,21 +7238,21 @@ class fe {
|
|
|
7208
7238
|
if (s == null || t == e) return !1;
|
|
7209
7239
|
const r = this.hand(t);
|
|
7210
7240
|
if (r.reached || r.hands.length < 3 || r.get(s.t, s.n) < 2) return !1;
|
|
7211
|
-
const i = s.clone({ removeAll: !0 }), o =
|
|
7212
|
-
replace: { idx: o, tile: s.clone({ add:
|
|
7241
|
+
const i = s.clone({ removeAll: !0 }), o = on(t, e, b.PON), a = [], c = new X([i, i, i]).clone({
|
|
7242
|
+
replace: { idx: o, tile: s.clone({ add: y.HORIZONTAL }) }
|
|
7213
7243
|
});
|
|
7214
7244
|
let l = c;
|
|
7215
|
-
C(s) && s.has(
|
|
7245
|
+
C(s) && s.has(y.RED) && (l = c.clone({
|
|
7216
7246
|
replace: {
|
|
7217
7247
|
idx: o,
|
|
7218
7248
|
tile: i.clone({
|
|
7219
|
-
add: [
|
|
7249
|
+
add: [y.RED, y.HORIZONTAL]
|
|
7220
7250
|
})
|
|
7221
7251
|
}
|
|
7222
7252
|
}));
|
|
7223
7253
|
const u = o % 2 + 1;
|
|
7224
7254
|
if (C(s) && r.get(s.t, 0) > 0 && (l = c.clone({
|
|
7225
|
-
replace: { idx: u, tile: i.clone({ add:
|
|
7255
|
+
replace: { idx: u, tile: i.clone({ add: y.RED }) }
|
|
7226
7256
|
})), a.push(l), C(i) && r.get(i.t, 5) == 3) {
|
|
7227
7257
|
const h = c.clone({
|
|
7228
7258
|
replace: { idx: u, tile: i }
|
|
@@ -7236,8 +7266,8 @@ class fe {
|
|
|
7236
7266
|
const r = this.hand(t);
|
|
7237
7267
|
if (r.reached || r.hands.length < 3) return !1;
|
|
7238
7268
|
const i = s.clone({
|
|
7239
|
-
remove:
|
|
7240
|
-
add: [
|
|
7269
|
+
remove: y.TSUMO,
|
|
7270
|
+
add: [y.HORIZONTAL]
|
|
7241
7271
|
}), o = [];
|
|
7242
7272
|
i.n - 2 >= 1 && r.get(s.t, i.n - 2) > 0 && r.get(s.t, i.n - 1) > 0 && o.push(
|
|
7243
7273
|
new J([
|
|
@@ -7259,13 +7289,13 @@ class fe {
|
|
|
7259
7289
|
])
|
|
7260
7290
|
);
|
|
7261
7291
|
for (let d = 0; d < o.length; d++) {
|
|
7262
|
-
const
|
|
7292
|
+
const g = o[d], f = this.cannotDiscardTile(g), m = [];
|
|
7263
7293
|
for (const O of f) {
|
|
7264
7294
|
const R = r.get(O.t, O.n);
|
|
7265
|
-
for (let mt = 0; mt < R; mt++) m.push(O.clone({ remove:
|
|
7295
|
+
for (let mt = 0; mt < R; mt++) m.push(O.clone({ remove: y.RED }));
|
|
7266
7296
|
}
|
|
7267
|
-
const
|
|
7268
|
-
r.inc(
|
|
7297
|
+
const E = r.dec([...m, g.tiles[1], g.tiles[2]]), S = r.hands.length == 0;
|
|
7298
|
+
r.inc(E), S && o.splice(d, 1);
|
|
7269
7299
|
}
|
|
7270
7300
|
if (o.length == 0) return !1;
|
|
7271
7301
|
const h = r.get(s.t, 0) > 0 ? this.redPattern(o) : [];
|
|
@@ -7276,17 +7306,17 @@ class fe {
|
|
|
7276
7306
|
(s) => C(s.tiles[1]) || C(s.tiles[2])
|
|
7277
7307
|
).map((s) => {
|
|
7278
7308
|
if (C(s.tiles[1])) {
|
|
7279
|
-
const r = s.tiles[1].clone({ add:
|
|
7309
|
+
const r = s.tiles[1].clone({ add: y.RED });
|
|
7280
7310
|
return s.clone({ replace: { idx: 1, tile: r } });
|
|
7281
7311
|
} else if (C(s.tiles[2])) {
|
|
7282
|
-
const r = s.tiles[2].clone({ add:
|
|
7312
|
+
const r = s.tiles[2].clone({ add: y.RED });
|
|
7283
7313
|
return s.clone({ replace: { idx: 2, tile: r } });
|
|
7284
7314
|
}
|
|
7285
7315
|
}).filter((s) => s != null);
|
|
7286
7316
|
}
|
|
7287
7317
|
doReach(t) {
|
|
7288
7318
|
const e = this.hand(t);
|
|
7289
|
-
return e.reached || !e.menzen || new
|
|
7319
|
+
return e.reached || !e.menzen || new de(e).calc() > 0 ? !1 : zt.calcCandidates(e, e.hands);
|
|
7290
7320
|
}
|
|
7291
7321
|
doDiscard(t, e) {
|
|
7292
7322
|
if (this.hand(t).reached) return [this.hand(t).drawn];
|
|
@@ -7312,12 +7342,12 @@ class fe {
|
|
|
7312
7342
|
for (const [r, i] of z())
|
|
7313
7343
|
if (e.get(r, i) == 4) {
|
|
7314
7344
|
const o = new w(r, i), a = [o, o, o, o];
|
|
7315
|
-
C(o) && (a[1] = o.clone({ add:
|
|
7345
|
+
C(o) && (a[1] = o.clone({ add: y.RED })), s.push(new M(a));
|
|
7316
7346
|
}
|
|
7317
7347
|
if (s.length == 0) return !1;
|
|
7318
7348
|
for (const r of s)
|
|
7319
7349
|
N(
|
|
7320
|
-
r.tiles.filter((i) => i.has(
|
|
7350
|
+
r.tiles.filter((i) => i.has(y.HORIZONTAL)).length == 0,
|
|
7321
7351
|
`h op ${r.toString()}`
|
|
7322
7352
|
);
|
|
7323
7353
|
return s;
|
|
@@ -7331,17 +7361,17 @@ class fe {
|
|
|
7331
7361
|
for (const i of s) {
|
|
7332
7362
|
const o = i.tiles[0].clone({
|
|
7333
7363
|
removeAll: !0,
|
|
7334
|
-
add:
|
|
7364
|
+
add: y.HORIZONTAL
|
|
7335
7365
|
});
|
|
7336
7366
|
if (e.get(o.t, o.n) == 1) {
|
|
7337
|
-
const a = C(o) && e.get(o.t, 0) > 0 ? o.clone({ add:
|
|
7367
|
+
const a = C(o) && e.get(o.t, 0) > 0 ? o.clone({ add: y.RED }) : o;
|
|
7338
7368
|
r.push(new K([...i.tiles, a]));
|
|
7339
7369
|
}
|
|
7340
7370
|
}
|
|
7341
7371
|
if (r.length == 0) return !1;
|
|
7342
7372
|
for (const i of r)
|
|
7343
7373
|
N(
|
|
7344
|
-
i.tiles.filter((o) => o.has(
|
|
7374
|
+
i.tiles.filter((o) => o.has(y.HORIZONTAL)).length == 2,
|
|
7345
7375
|
`h op ${i.toString()}`
|
|
7346
7376
|
);
|
|
7347
7377
|
return r;
|
|
@@ -7351,29 +7381,29 @@ class fe {
|
|
|
7351
7381
|
if (r.reached || t == e) return !1;
|
|
7352
7382
|
const i = s.clone({ removeAll: !0 });
|
|
7353
7383
|
if (r.get(i.t, i.n) != 3) return !1;
|
|
7354
|
-
const o =
|
|
7384
|
+
const o = on(t, e, b.DAI_KAN);
|
|
7355
7385
|
let a = new Y([i, i, i, i]).clone({
|
|
7356
|
-
replace: { idx: o, tile: i.clone({ add:
|
|
7386
|
+
replace: { idx: o, tile: i.clone({ add: y.HORIZONTAL }) }
|
|
7357
7387
|
});
|
|
7358
|
-
if (C(s) && s.has(
|
|
7388
|
+
if (C(s) && s.has(y.RED))
|
|
7359
7389
|
a = a.clone({
|
|
7360
7390
|
replace: {
|
|
7361
7391
|
idx: o,
|
|
7362
|
-
tile: i.clone({ add: [
|
|
7392
|
+
tile: i.clone({ add: [y.HORIZONTAL, y.RED] })
|
|
7363
7393
|
}
|
|
7364
7394
|
});
|
|
7365
|
-
else if (C(s) && !s.has(
|
|
7395
|
+
else if (C(s) && !s.has(y.RED)) {
|
|
7366
7396
|
N(
|
|
7367
7397
|
r.get(s.t, 0) > 0,
|
|
7368
7398
|
`hand does not have red tile: ${r.toString()}`
|
|
7369
7399
|
);
|
|
7370
7400
|
const c = o % 3 + 1;
|
|
7371
7401
|
a = a.clone({
|
|
7372
|
-
replace: { idx: c, tile: i.clone({ add:
|
|
7402
|
+
replace: { idx: c, tile: i.clone({ add: y.RED }) }
|
|
7373
7403
|
});
|
|
7374
7404
|
}
|
|
7375
7405
|
return N(
|
|
7376
|
-
a.tiles.filter((c) => c.has(
|
|
7406
|
+
a.tiles.filter((c) => c.has(y.HORIZONTAL)).length == 1,
|
|
7377
7407
|
`h op ${a.toString()}`
|
|
7378
7408
|
), a;
|
|
7379
7409
|
}
|
|
@@ -7383,7 +7413,7 @@ class fe {
|
|
|
7383
7413
|
let s = 0;
|
|
7384
7414
|
for (const r of Object.values(p)) {
|
|
7385
7415
|
if (r == p.BACK) continue;
|
|
7386
|
-
const i = r == p.Z ?
|
|
7416
|
+
const i = r == p.Z ? Lt : V;
|
|
7387
7417
|
for (const o of i)
|
|
7388
7418
|
e.get(r, o) > 0 && s++;
|
|
7389
7419
|
}
|
|
@@ -7393,7 +7423,7 @@ class fe {
|
|
|
7393
7423
|
return this.wall.initialHands();
|
|
7394
7424
|
}
|
|
7395
7425
|
}
|
|
7396
|
-
class
|
|
7426
|
+
class Mt extends Ue {
|
|
7397
7427
|
isBackHand() {
|
|
7398
7428
|
for (const t of Object.values(p))
|
|
7399
7429
|
if (t != p.BACK && this.sum(t) > 0)
|
|
@@ -7401,7 +7431,7 @@ class xt extends je {
|
|
|
7401
7431
|
return this.sum(p.BACK) > 0;
|
|
7402
7432
|
}
|
|
7403
7433
|
clone() {
|
|
7404
|
-
const t = new
|
|
7434
|
+
const t = new Mt(this.toString());
|
|
7405
7435
|
return t.data.reached = this.data.reached, t;
|
|
7406
7436
|
}
|
|
7407
7437
|
dec(t) {
|
|
@@ -7412,11 +7442,11 @@ class gs {
|
|
|
7412
7442
|
constructor(t, e) {
|
|
7413
7443
|
_(this, "id");
|
|
7414
7444
|
_(this, "river", new Jn());
|
|
7415
|
-
_(this, "placeManager", new
|
|
7445
|
+
_(this, "placeManager", new ie({}));
|
|
7416
7446
|
// empty for init
|
|
7417
|
-
_(this, "scoreManager", new
|
|
7447
|
+
_(this, "scoreManager", new re({}));
|
|
7418
7448
|
// empty for init
|
|
7419
|
-
_(this, "hands",
|
|
7449
|
+
_(this, "hands", P(new Mt("")));
|
|
7420
7450
|
// empty for init
|
|
7421
7451
|
_(this, "counter", new Oi());
|
|
7422
7452
|
_(this, "doraMarkers", []);
|
|
@@ -7439,11 +7469,11 @@ class gs {
|
|
|
7439
7469
|
case "DISTRIBUTE":
|
|
7440
7470
|
this.counter.reset();
|
|
7441
7471
|
const e = w.from(t.doraMarker);
|
|
7442
|
-
this.setHands(t), this.placeManager = new
|
|
7472
|
+
this.setHands(t), this.placeManager = new ie(structuredClone(t.places), {
|
|
7443
7473
|
round: t.round,
|
|
7444
7474
|
sticks: structuredClone(t.sticks)
|
|
7445
|
-
}), this.scoreManager = new
|
|
7446
|
-
for (const r of Object.values(
|
|
7475
|
+
}), this.scoreManager = new re(structuredClone(t.scores)), this.doraMarkers = [e], this.counter.dec(e);
|
|
7476
|
+
for (const r of Object.values(A))
|
|
7447
7477
|
r == t.wind && this.counter.dec(...this.hand(r).hands);
|
|
7448
7478
|
break;
|
|
7449
7479
|
case "DRAW": {
|
|
@@ -7455,7 +7485,7 @@ class gs {
|
|
|
7455
7485
|
const r = w.from(t.tile);
|
|
7456
7486
|
if (this.river.discard(r, t.iam), this.hands[t.iam].discard(r), t.iam != t.wind) {
|
|
7457
7487
|
this.counter.dec(r), this.counter.addTileToSafeMap(r, t.iam);
|
|
7458
|
-
for (const i of Object.values(
|
|
7488
|
+
for (const i of Object.values(A))
|
|
7459
7489
|
this.hand(i).reached && this.counter.addTileToSafeMap(r, i);
|
|
7460
7490
|
}
|
|
7461
7491
|
break;
|
|
@@ -7464,17 +7494,17 @@ class gs {
|
|
|
7464
7494
|
case "CHI":
|
|
7465
7495
|
case "DAI_KAN": {
|
|
7466
7496
|
const r = T.deserialize(t.block);
|
|
7467
|
-
this.hands[t.iam].call(r), this.river.markCalled(), t.iam != t.wind && this.counter.dec(...r.tiles.filter((i) => !i.has(
|
|
7497
|
+
this.hands[t.iam].call(r), this.river.markCalled(), t.iam != t.wind && this.counter.dec(...r.tiles.filter((i) => !i.has(y.HORIZONTAL)));
|
|
7468
7498
|
break;
|
|
7469
7499
|
}
|
|
7470
7500
|
case "SHO_KAN": {
|
|
7471
7501
|
const r = K.from(t.block.tiles);
|
|
7472
|
-
this.hands[t.iam].kan(r), t.iam != t.wind && this.counter.dec(r.tiles.filter((i) => i.has(
|
|
7502
|
+
this.hands[t.iam].kan(r), t.iam != t.wind && this.counter.dec(r.tiles.filter((i) => i.has(y.HORIZONTAL))[0]);
|
|
7473
7503
|
break;
|
|
7474
7504
|
}
|
|
7475
7505
|
case "AN_KAN": {
|
|
7476
|
-
const r =
|
|
7477
|
-
this.hands[t.iam].kan(r), t.iam != t.wind && this.counter.dec(...r.tiles.filter((i) => !i.has(
|
|
7506
|
+
const r = M.from(t.block.tiles);
|
|
7507
|
+
this.hands[t.iam].kan(r), t.iam != t.wind && this.counter.dec(...r.tiles.filter((i) => !i.has(y.HORIZONTAL)));
|
|
7478
7508
|
break;
|
|
7479
7509
|
}
|
|
7480
7510
|
case "REACH": {
|
|
@@ -7482,7 +7512,7 @@ class gs {
|
|
|
7482
7512
|
const r = w.from(t.tile);
|
|
7483
7513
|
if (this.river.discard(r, t.iam), this.hands[t.iam].discard(r), t.iam != t.wind) {
|
|
7484
7514
|
this.counter.dec(r), this.counter.addTileToSafeMap(r, t.iam);
|
|
7485
|
-
for (const i of Object.values(
|
|
7515
|
+
for (const i of Object.values(A))
|
|
7486
7516
|
this.hand(i).reached && this.counter.addTileToSafeMap(r, i);
|
|
7487
7517
|
}
|
|
7488
7518
|
break;
|
|
@@ -7528,16 +7558,16 @@ class Bo extends gs {
|
|
|
7528
7558
|
constructor(e) {
|
|
7529
7559
|
super("observer", e);
|
|
7530
7560
|
_(this, "applied", {});
|
|
7531
|
-
this.counter.disable = !0, this.hands =
|
|
7561
|
+
this.counter.disable = !0, this.hands = P(new Mt("_____________"));
|
|
7532
7562
|
}
|
|
7533
7563
|
setHands(e) {
|
|
7534
|
-
this.hands[e.wind] = new
|
|
7564
|
+
this.hands[e.wind] = new Mt(e.hands[e.wind]);
|
|
7535
7565
|
}
|
|
7536
7566
|
handleEvent(e) {
|
|
7537
7567
|
switch (super.handleEvent(e), e.type) {
|
|
7538
7568
|
case "DISTRIBUTE":
|
|
7539
7569
|
let s = !0;
|
|
7540
|
-
for (const r of Object.values(
|
|
7570
|
+
for (const r of Object.values(A))
|
|
7541
7571
|
s && (s = this.hand(r).get(p.BACK, 0) == 0);
|
|
7542
7572
|
if (!s) break;
|
|
7543
7573
|
console.debug(
|
|
@@ -7547,7 +7577,7 @@ class Bo extends gs {
|
|
|
7547
7577
|
`map: ${JSON.stringify(this.placeManager.playerMap, null, 2)}`,
|
|
7548
7578
|
`sticks: ${JSON.stringify(this.placeManager.sticks, null, 2)}`
|
|
7549
7579
|
);
|
|
7550
|
-
for (const r of Object.values(
|
|
7580
|
+
for (const r of Object.values(A))
|
|
7551
7581
|
console.debug(
|
|
7552
7582
|
`${this.placeManager.playerID(r)}(${r})`,
|
|
7553
7583
|
`init hand: ${this.hand(r).toString()}`
|
|
@@ -7594,9 +7624,9 @@ class Bo extends gs {
|
|
|
7594
7624
|
);
|
|
7595
7625
|
break;
|
|
7596
7626
|
case "END_GAME":
|
|
7597
|
-
for (const r of Object.values(
|
|
7627
|
+
for (const r of Object.values(A))
|
|
7598
7628
|
console.debug(
|
|
7599
|
-
`${this.placeManager.playerID(r)}(${
|
|
7629
|
+
`${this.placeManager.playerID(r)}(${De(r)})`,
|
|
7600
7630
|
`end hand: ${this.hand(r).toString()}`
|
|
7601
7631
|
);
|
|
7602
7632
|
console.debug(
|
|
@@ -7609,7 +7639,7 @@ class Bo extends gs {
|
|
|
7609
7639
|
}
|
|
7610
7640
|
}
|
|
7611
7641
|
}
|
|
7612
|
-
class
|
|
7642
|
+
class Xt extends gs {
|
|
7613
7643
|
constructor(e, s) {
|
|
7614
7644
|
super(e, s);
|
|
7615
7645
|
_(this, "river", new Jn());
|
|
@@ -7620,15 +7650,15 @@ class Jt extends gs {
|
|
|
7620
7650
|
return this.placeManager.wind(this.id);
|
|
7621
7651
|
}
|
|
7622
7652
|
setHands(e) {
|
|
7623
|
-
for (const s of Object.values(
|
|
7624
|
-
this.hands[s] = new
|
|
7653
|
+
for (const s of Object.values(A))
|
|
7654
|
+
this.hands[s] = new Mt(e.hands[s]);
|
|
7625
7655
|
}
|
|
7626
7656
|
handleDiscard(e) {
|
|
7627
|
-
const s = Object.values(
|
|
7657
|
+
const s = Object.values(A).filter((u) => u == this.myWind ? !1 : this.hand(u).reached), r = new de(this.hand(this.myWind)).calc();
|
|
7628
7658
|
if (s.length > 0 && r >= 2)
|
|
7629
|
-
return
|
|
7630
|
-
const i =
|
|
7631
|
-
return
|
|
7659
|
+
return Dt.selectTile(this.counter, s, e);
|
|
7660
|
+
const i = zt.calcCandidates(this.hand(this.myWind), e), a = le.calcPlayerCandidates(this.counter, i).sort((u, h) => h.sum - u.sum), c = a.filter((u) => u.sum == a[0].sum);
|
|
7661
|
+
return le.selectMinPriority(
|
|
7632
7662
|
this.counter,
|
|
7633
7663
|
c,
|
|
7634
7664
|
this.doras
|
|
@@ -7671,7 +7701,7 @@ class Qo {
|
|
|
7671
7701
|
this.index--, N(this.index < 0);
|
|
7672
7702
|
}
|
|
7673
7703
|
start() {
|
|
7674
|
-
|
|
7704
|
+
pe.load(this.histories[this.index]).start();
|
|
7675
7705
|
}
|
|
7676
7706
|
auto() {
|
|
7677
7707
|
for (; this.index < this.histories.length; this.next())
|
|
@@ -7679,19 +7709,19 @@ class Qo {
|
|
|
7679
7709
|
}
|
|
7680
7710
|
}
|
|
7681
7711
|
const ta = (n) => {
|
|
7682
|
-
const [t, e] =
|
|
7712
|
+
const [t, e] = Gt(), [s, r] = Gt(), [i, o] = Gt(), [a, c] = Gt(), l = ["player-1", "player-2", "player-3", "player-4"], u = n == null ? void 0 : n.playerInjection, h = (u == null ? void 0 : u.p1) ?? Xt, d = (u == null ? void 0 : u.p2) ?? Xt, g = (u == null ? void 0 : u.p3) ?? Xt, f = (u == null ? void 0 : u.p4) ?? Xt, m = new h(l[0], e), E = new d(l[1], r), S = new g(l[2], o), O = new f(l[3], c), R = [
|
|
7683
7713
|
{ handler: t, id: l[0] },
|
|
7684
7714
|
{ handler: s, id: l[1] },
|
|
7685
7715
|
{ handler: i, id: l[2] },
|
|
7686
7716
|
{ handler: a, id: l[3] }
|
|
7687
7717
|
];
|
|
7688
7718
|
return {
|
|
7689
|
-
c: new
|
|
7719
|
+
c: new pe(R, {
|
|
7690
7720
|
debug: n == null ? void 0 : n.debug,
|
|
7691
7721
|
shuffle: n == null ? void 0 : n.shuffle
|
|
7692
7722
|
}),
|
|
7693
7723
|
p1: m,
|
|
7694
|
-
p2:
|
|
7724
|
+
p2: E,
|
|
7695
7725
|
p3: S,
|
|
7696
7726
|
p4: O
|
|
7697
7727
|
};
|
|
@@ -7700,7 +7730,7 @@ const ta = (n) => {
|
|
|
7700
7730
|
for (let r of t) r.equals(n) && (s *= 2);
|
|
7701
7731
|
return s;
|
|
7702
7732
|
};
|
|
7703
|
-
class
|
|
7733
|
+
class le {
|
|
7704
7734
|
static calcPlayerCandidates(t, e) {
|
|
7705
7735
|
let s = [];
|
|
7706
7736
|
for (let r of e) {
|
|
@@ -7723,7 +7753,7 @@ class ce {
|
|
|
7723
7753
|
N(e.length > 0);
|
|
7724
7754
|
let r = 0, i = 0;
|
|
7725
7755
|
for (let o = 0; o < e.length; o++) {
|
|
7726
|
-
const a =
|
|
7756
|
+
const a = le.calcPriority(t, e[o], s);
|
|
7727
7757
|
a < r && (r = a, i = o);
|
|
7728
7758
|
}
|
|
7729
7759
|
return e[i];
|
|
@@ -7736,24 +7766,24 @@ class ce {
|
|
|
7736
7766
|
{
|
|
7737
7767
|
const o = t.get(r);
|
|
7738
7768
|
i += o * ot(r, s);
|
|
7739
|
-
const a = t.get(new w(r.t, r.n + 1)), c = t.get(new w(r.t, r.n + 2)), l = t.get(new w(r.t, r.n - 1)), u = t.get(new w(r.t, r.n - 2)), h = r.n - 2 > 0 ? Math.min(l, u) : 0, d = r.n + 2 <= 9 ? Math.min(a, c) : 0,
|
|
7769
|
+
const a = t.get(new w(r.t, r.n + 1)), c = t.get(new w(r.t, r.n + 2)), l = t.get(new w(r.t, r.n - 1)), u = t.get(new w(r.t, r.n - 2)), h = r.n - 2 > 0 ? Math.min(l, u) : 0, d = r.n + 2 <= 9 ? Math.min(a, c) : 0, g = r.n - 1 >= 1 && r.n + 1 <= 9 ? Math.min(a, l) : 0, f = Math.max(h, g), m = Math.max(g, d);
|
|
7740
7770
|
return i += o * ot(r, s), i += h * ot(new w(r.t, r.n - 2), s), i += d * ot(new w(r.t, r.n + 2), s), i += f * ot(new w(r.t, r.n - 1), s), i += m * ot(new w(r.t, r.n + 1), s), r.n == 0, i;
|
|
7741
7771
|
}
|
|
7742
7772
|
}
|
|
7743
7773
|
}
|
|
7744
|
-
class
|
|
7774
|
+
class Dt {
|
|
7745
7775
|
static selectTile(t, e, s) {
|
|
7746
7776
|
N(e.length > 0 && s.length > 0);
|
|
7747
7777
|
let r = s[0], i = Number.POSITIVE_INFINITY;
|
|
7748
7778
|
for (let o of s) {
|
|
7749
|
-
const a =
|
|
7779
|
+
const a = Dt.rank(t, e, o);
|
|
7750
7780
|
a < i && (r = o, i = a);
|
|
7751
7781
|
}
|
|
7752
7782
|
return r;
|
|
7753
7783
|
}
|
|
7754
7784
|
static rank(t, e, s) {
|
|
7755
7785
|
let r = 0;
|
|
7756
|
-
const i = s.isNum() ?
|
|
7786
|
+
const i = s.isNum() ? Dt.rankN : Dt.rankZ;
|
|
7757
7787
|
for (let o of e) {
|
|
7758
7788
|
const a = i(t, o, s);
|
|
7759
7789
|
r < a && (r = a);
|
|
@@ -7780,32 +7810,32 @@ class Bt {
|
|
|
7780
7810
|
}
|
|
7781
7811
|
}
|
|
7782
7812
|
export {
|
|
7783
|
-
|
|
7813
|
+
Mt as ActorHand,
|
|
7784
7814
|
b as BLOCK,
|
|
7785
7815
|
gs as BaseActor,
|
|
7786
7816
|
T as Block,
|
|
7787
|
-
|
|
7817
|
+
M as BlockAnKan,
|
|
7788
7818
|
Ai as BlockCalculator,
|
|
7789
7819
|
J as BlockChi,
|
|
7790
7820
|
Y as BlockDaiKan,
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7821
|
+
Kt as BlockHand,
|
|
7822
|
+
kn as BlockIsolated,
|
|
7823
|
+
Cn as BlockOther,
|
|
7824
|
+
H as BlockPair,
|
|
7795
7825
|
X as BlockPon,
|
|
7796
7826
|
ut as BlockRun,
|
|
7797
7827
|
K as BlockShoKan,
|
|
7798
7828
|
F as BlockThree,
|
|
7799
|
-
|
|
7829
|
+
pe as Controller,
|
|
7800
7830
|
Oi as Counter,
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7831
|
+
pn as DoubleCalculator,
|
|
7832
|
+
zt as Efficiency,
|
|
7833
|
+
In as FONT_FAMILY,
|
|
7804
7834
|
v as G,
|
|
7805
|
-
|
|
7835
|
+
Ue as Hand,
|
|
7806
7836
|
lt as INPUT_SEPARATOR,
|
|
7807
|
-
|
|
7808
|
-
|
|
7837
|
+
Bn as Image,
|
|
7838
|
+
zn as ImageHelper,
|
|
7809
7839
|
yt as Mark,
|
|
7810
7840
|
Lo as MeasureText,
|
|
7811
7841
|
Fo as MyG,
|
|
@@ -7815,59 +7845,59 @@ export {
|
|
|
7815
7845
|
Jo as MyText,
|
|
7816
7846
|
Go as MyUse,
|
|
7817
7847
|
V as N19,
|
|
7818
|
-
|
|
7819
|
-
|
|
7848
|
+
Lt as NZ,
|
|
7849
|
+
y as OP,
|
|
7820
7850
|
Bo as Observer,
|
|
7821
7851
|
B as Parser,
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7852
|
+
ie as PlaceManager,
|
|
7853
|
+
Xt as Player,
|
|
7854
|
+
le as PlayerEfficiency,
|
|
7825
7855
|
k as ROUND,
|
|
7826
|
-
|
|
7827
|
-
|
|
7856
|
+
On as ROUND_MAP,
|
|
7857
|
+
Dn as Rect,
|
|
7828
7858
|
Qo as Replayer,
|
|
7829
|
-
|
|
7859
|
+
Dt as RiskRank,
|
|
7830
7860
|
Jn as River,
|
|
7831
|
-
|
|
7861
|
+
nn as STICK_CONTEXT,
|
|
7832
7862
|
Fr as SVG,
|
|
7833
|
-
|
|
7834
|
-
|
|
7863
|
+
re as ScoreManager,
|
|
7864
|
+
de as ShantenCalculator,
|
|
7835
7865
|
Ur as Svg,
|
|
7836
|
-
|
|
7866
|
+
Kn as Symbol,
|
|
7837
7867
|
Ss as TABLE_CONTEXT,
|
|
7838
7868
|
ft as TILE_CONTEXT,
|
|
7839
7869
|
p as TYPE,
|
|
7840
7870
|
Nt as Text,
|
|
7841
7871
|
w as Tile,
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7872
|
+
je as Use,
|
|
7873
|
+
A as WIND,
|
|
7874
|
+
We as WIND_MAP,
|
|
7845
7875
|
vt as Wall,
|
|
7846
|
-
|
|
7876
|
+
on as callBlockIndex,
|
|
7847
7877
|
_i as convertInput,
|
|
7848
|
-
|
|
7878
|
+
Tn as createControllerMachine,
|
|
7849
7879
|
Ii as createEventEmitter,
|
|
7850
|
-
|
|
7880
|
+
Gt as createEventPipe,
|
|
7851
7881
|
Wt as createHand,
|
|
7852
7882
|
ta as createLocalGame,
|
|
7853
7883
|
ii as createTable,
|
|
7854
|
-
|
|
7855
|
-
|
|
7884
|
+
P as createWindMap,
|
|
7885
|
+
Zt as deserializeWinResult,
|
|
7856
7886
|
Xo as drawBlocks,
|
|
7857
7887
|
qo as drawTable,
|
|
7858
7888
|
z as forHand,
|
|
7859
7889
|
Wo as incrementalIDGenerator,
|
|
7860
7890
|
C as isNum5,
|
|
7861
|
-
|
|
7891
|
+
Yt as nextRound,
|
|
7862
7892
|
St as nextWind,
|
|
7863
7893
|
Yo as optimizeSVG,
|
|
7864
7894
|
gi as parse,
|
|
7865
7895
|
yi as parseTableInput,
|
|
7866
7896
|
zo as prevRound,
|
|
7867
|
-
|
|
7897
|
+
De as prevWind,
|
|
7868
7898
|
Si as prioritizeDiscardedEvents,
|
|
7869
7899
|
Ni as prioritizeDrawnEvents,
|
|
7870
7900
|
Vn as shuffle,
|
|
7871
7901
|
Ts as sortCalledTiles,
|
|
7872
|
-
|
|
7902
|
+
ue as tileSortFunc
|
|
7873
7903
|
};
|