@konoui/mjimage 0.0.49 → 0.0.51
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 +11 -11
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +344 -329
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var ws = Object.defineProperty;
|
|
2
2
|
var bs = (n, t, e) => t in n ? ws(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
3
|
var _ = (n, t, e) => bs(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
const
|
|
4
|
+
const Nn = "MS Gothic, sans-serif", dt = {
|
|
5
5
|
WIDTH: 66,
|
|
6
6
|
HEIGHT: 90,
|
|
7
7
|
TEXT_SCALE: 0.8,
|
|
8
8
|
BLOCK_MARGIN_SCALE: 0.3
|
|
9
|
-
},
|
|
9
|
+
}, Ye = {
|
|
10
10
|
WIDTH: 125,
|
|
11
11
|
HEIGHT: 27.5
|
|
12
12
|
}, _s = { BASE: 40 }, ct = ",", p = {
|
|
@@ -65,7 +65,7 @@ const En = "MS Gothic, sans-serif", dt = {
|
|
|
65
65
|
[A.S]: "南",
|
|
66
66
|
[A.W]: "西",
|
|
67
67
|
[A.N]: "北"
|
|
68
|
-
},
|
|
68
|
+
}, Sn = {
|
|
69
69
|
[k.E1]: "東1局",
|
|
70
70
|
[k.E2]: "東2局",
|
|
71
71
|
[k.E3]: "東3局",
|
|
@@ -112,7 +112,7 @@ class Wo {
|
|
|
112
112
|
});
|
|
113
113
|
_(this, "measureTableFontContext", (t) => {
|
|
114
114
|
const e = this.measureFontContext(
|
|
115
|
-
|
|
115
|
+
Nn,
|
|
116
116
|
_s.BASE * t
|
|
117
117
|
);
|
|
118
118
|
return e.textHeight = e.textWidth, e.numHeight = e.numWidth, e;
|
|
@@ -227,7 +227,7 @@ class w {
|
|
|
227
227
|
return t.t == p.BACK && this.t == p.BACK ? !0 : this.t == t.t && this.n == t.n;
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
-
class
|
|
230
|
+
class T {
|
|
231
231
|
constructor(t, e) {
|
|
232
232
|
_(this, "_tiles");
|
|
233
233
|
_(this, "_type");
|
|
@@ -240,16 +240,19 @@ class I {
|
|
|
240
240
|
return;
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
+
static from(t) {
|
|
244
|
+
const e = new D(t).parse();
|
|
245
|
+
if (e.length != 1) throw new Error(`block must be 1: ${t}`);
|
|
246
|
+
return e[0];
|
|
247
|
+
}
|
|
243
248
|
// deserialize json object. it validates the input type by comparing to parsed block type.
|
|
244
249
|
static deserialize(t) {
|
|
245
|
-
const e =
|
|
246
|
-
if (e.length != 1) throw new Error(`block must be 1: ${t.tiles}`);
|
|
247
|
-
const s = e[0].type;
|
|
250
|
+
const e = T.from(t.tiles), s = e.type;
|
|
248
251
|
if (!(t.type == b.PAIR || t.type == b.ISOLATED || t.type == b.THREE || t.type == b.RUN) && s != t.type)
|
|
249
252
|
throw new Error(
|
|
250
253
|
`input type is ${t.type} but got is ${s}: ${t.tiles}`
|
|
251
254
|
);
|
|
252
|
-
return qt(e
|
|
255
|
+
return qt(e.tiles, t.type);
|
|
253
256
|
}
|
|
254
257
|
serialize() {
|
|
255
258
|
return {
|
|
@@ -284,7 +287,7 @@ class I {
|
|
|
284
287
|
return e && (s[e.idx] = e.tile), qt(s, this._type);
|
|
285
288
|
}
|
|
286
289
|
}
|
|
287
|
-
const
|
|
290
|
+
const pt = (n) => {
|
|
288
291
|
let t = "";
|
|
289
292
|
for (const e of n) {
|
|
290
293
|
if (e.t == p.BACK) return n.join("");
|
|
@@ -300,29 +303,29 @@ const gt = (n) => {
|
|
|
300
303
|
const s = n.at(-1);
|
|
301
304
|
return s.t != p.BACK && (e += s.t), e;
|
|
302
305
|
};
|
|
303
|
-
class J extends
|
|
306
|
+
class J extends T {
|
|
304
307
|
constructor(t) {
|
|
305
308
|
super(t, b.CHI);
|
|
306
309
|
}
|
|
307
310
|
static from(t) {
|
|
308
|
-
return
|
|
311
|
+
return T.deserialize({ tiles: t, type: b.CHI });
|
|
309
312
|
}
|
|
310
313
|
toString() {
|
|
311
|
-
return
|
|
314
|
+
return pt(this.tiles);
|
|
312
315
|
}
|
|
313
316
|
}
|
|
314
|
-
class
|
|
317
|
+
class X extends T {
|
|
315
318
|
constructor(t) {
|
|
316
319
|
super(t, b.PON);
|
|
317
320
|
}
|
|
318
321
|
static from(t) {
|
|
319
|
-
return
|
|
322
|
+
return T.deserialize({ tiles: t, type: b.PON });
|
|
320
323
|
}
|
|
321
324
|
toString() {
|
|
322
|
-
return
|
|
325
|
+
return pt(this.tiles);
|
|
323
326
|
}
|
|
324
327
|
}
|
|
325
|
-
class M extends
|
|
328
|
+
class M extends T {
|
|
326
329
|
constructor(t) {
|
|
327
330
|
const e = t.filter((r) => r.t != p.BACK), s = e[0];
|
|
328
331
|
if (e.length < t.length) {
|
|
@@ -341,85 +344,97 @@ class M extends I {
|
|
|
341
344
|
return [new w(p.BACK, 0), e, t, new w(p.BACK, 0)];
|
|
342
345
|
}
|
|
343
346
|
static from(t) {
|
|
344
|
-
return
|
|
347
|
+
return T.deserialize({ tiles: t, type: b.AN_KAN });
|
|
345
348
|
}
|
|
346
349
|
toString() {
|
|
347
350
|
return He(this.tilesWithBack);
|
|
348
351
|
}
|
|
349
352
|
}
|
|
350
|
-
class
|
|
353
|
+
class q extends T {
|
|
351
354
|
constructor(t) {
|
|
352
355
|
super(t, b.DAI_KAN);
|
|
353
356
|
}
|
|
354
357
|
static from(t) {
|
|
355
|
-
return
|
|
358
|
+
return T.deserialize({ tiles: t, type: b.DAI_KAN });
|
|
356
359
|
}
|
|
357
360
|
toString() {
|
|
358
|
-
return
|
|
361
|
+
return pt(this.tiles);
|
|
359
362
|
}
|
|
360
363
|
}
|
|
361
|
-
class K extends
|
|
364
|
+
class K extends T {
|
|
362
365
|
constructor(t) {
|
|
363
366
|
super(t, b.SHO_KAN);
|
|
364
367
|
}
|
|
365
368
|
static from(t) {
|
|
366
|
-
return
|
|
369
|
+
return T.deserialize({ tiles: t, type: b.SHO_KAN });
|
|
367
370
|
}
|
|
368
371
|
static fromPon(t, e) {
|
|
369
372
|
const s = t.tiles.findIndex((i) => i.has(y.HORIZONTAL)), r = [...t.tiles];
|
|
370
373
|
return r.splice(s, 0, e.clone({ add: y.HORIZONTAL })), new K(r);
|
|
371
374
|
}
|
|
372
375
|
toString() {
|
|
373
|
-
return
|
|
376
|
+
return pt(this.tiles);
|
|
374
377
|
}
|
|
375
378
|
}
|
|
376
|
-
class P extends
|
|
379
|
+
class P extends T {
|
|
377
380
|
constructor(t, e) {
|
|
378
381
|
super([t, e], b.PAIR);
|
|
379
382
|
}
|
|
380
383
|
toString() {
|
|
381
|
-
return
|
|
384
|
+
return pt(this.tiles);
|
|
385
|
+
}
|
|
386
|
+
static from(t) {
|
|
387
|
+
return T.deserialize({ tiles: t, type: b.PAIR });
|
|
382
388
|
}
|
|
383
389
|
}
|
|
384
|
-
class Z extends
|
|
390
|
+
class Z extends T {
|
|
385
391
|
constructor(t) {
|
|
386
392
|
super(t, b.THREE);
|
|
387
393
|
}
|
|
388
394
|
static from(t) {
|
|
389
|
-
return
|
|
395
|
+
return T.deserialize({ tiles: t, type: b.THREE });
|
|
390
396
|
}
|
|
391
397
|
toString() {
|
|
392
|
-
return
|
|
398
|
+
return pt(this.tiles);
|
|
393
399
|
}
|
|
394
400
|
}
|
|
395
|
-
class lt extends
|
|
401
|
+
class lt extends T {
|
|
396
402
|
constructor(t) {
|
|
397
403
|
super(t, b.RUN);
|
|
398
404
|
}
|
|
399
405
|
static from(t) {
|
|
400
|
-
return
|
|
406
|
+
return T.deserialize({ tiles: t, type: b.RUN });
|
|
401
407
|
}
|
|
402
408
|
toString() {
|
|
403
|
-
return
|
|
409
|
+
return pt(this.tiles);
|
|
404
410
|
}
|
|
405
411
|
}
|
|
406
|
-
class
|
|
412
|
+
class vn extends T {
|
|
407
413
|
constructor(t) {
|
|
408
414
|
super([t], b.ISOLATED);
|
|
409
415
|
}
|
|
416
|
+
static from(t) {
|
|
417
|
+
return T.deserialize({
|
|
418
|
+
tiles: t,
|
|
419
|
+
type: b.ISOLATED
|
|
420
|
+
});
|
|
421
|
+
}
|
|
410
422
|
toString() {
|
|
411
423
|
return this.tiles[0].toString();
|
|
412
424
|
}
|
|
413
425
|
}
|
|
414
|
-
class Dt extends
|
|
426
|
+
class Dt extends T {
|
|
415
427
|
constructor(t) {
|
|
416
428
|
super(t, b.HAND);
|
|
417
429
|
}
|
|
430
|
+
static from(t) {
|
|
431
|
+
return T.deserialize({ tiles: t, type: b.HAND });
|
|
432
|
+
}
|
|
418
433
|
toString() {
|
|
419
434
|
return He(this.tiles);
|
|
420
435
|
}
|
|
421
436
|
}
|
|
422
|
-
class
|
|
437
|
+
class Tn extends T {
|
|
423
438
|
constructor(t, e) {
|
|
424
439
|
super(t, e);
|
|
425
440
|
}
|
|
@@ -432,11 +447,11 @@ const qt = (n, t) => {
|
|
|
432
447
|
case b.CHI:
|
|
433
448
|
return new J([n[0], n[1], n[2]]);
|
|
434
449
|
case b.PON:
|
|
435
|
-
return new
|
|
450
|
+
return new X([n[0], n[1], n[2]]);
|
|
436
451
|
case b.AN_KAN:
|
|
437
452
|
return new M(n);
|
|
438
453
|
case b.DAI_KAN:
|
|
439
|
-
return new
|
|
454
|
+
return new q(n);
|
|
440
455
|
case b.SHO_KAN:
|
|
441
456
|
return new K(n);
|
|
442
457
|
case b.THREE:
|
|
@@ -446,11 +461,11 @@ const qt = (n, t) => {
|
|
|
446
461
|
case b.PAIR:
|
|
447
462
|
return new P(n[0], n[1]);
|
|
448
463
|
case b.ISOLATED:
|
|
449
|
-
return new
|
|
464
|
+
return new vn(n[0]);
|
|
450
465
|
case b.HAND:
|
|
451
466
|
return new Dt(n);
|
|
452
467
|
default:
|
|
453
|
-
return new
|
|
468
|
+
return new Tn(n, t);
|
|
454
469
|
}
|
|
455
470
|
};
|
|
456
471
|
class D {
|
|
@@ -476,7 +491,7 @@ class D {
|
|
|
476
491
|
e.push(ct), t.readChar();
|
|
477
492
|
continue;
|
|
478
493
|
}
|
|
479
|
-
const [i, o] =
|
|
494
|
+
const [i, o] = tn(r, s);
|
|
480
495
|
if (o) {
|
|
481
496
|
if (i == p.BACK) {
|
|
482
497
|
e.push(new w(i, 0)), t.readChar();
|
|
@@ -490,7 +505,7 @@ class D {
|
|
|
490
505
|
s.push(a), t.readChar();
|
|
491
506
|
continue;
|
|
492
507
|
}
|
|
493
|
-
const [l, u] =
|
|
508
|
+
const [l, u] = In(r);
|
|
494
509
|
if (!u)
|
|
495
510
|
throw new Error(
|
|
496
511
|
`encounter unexpected number. n: ${l}, current: ${r}, input: ${t.input}`
|
|
@@ -509,25 +524,25 @@ class D {
|
|
|
509
524
|
if (t.length == 0) return s;
|
|
510
525
|
for (const o of t) {
|
|
511
526
|
if (o == ct) {
|
|
512
|
-
const a =
|
|
527
|
+
const a = Qe(e), c = qt(e, a);
|
|
513
528
|
s.push(c), e = [];
|
|
514
529
|
continue;
|
|
515
530
|
}
|
|
516
531
|
e.push(o);
|
|
517
532
|
}
|
|
518
|
-
const r =
|
|
533
|
+
const r = Qe(e), i = qt(e, r);
|
|
519
534
|
return s.push(i), e = [], s;
|
|
520
535
|
}
|
|
521
536
|
validate(t) {
|
|
522
537
|
if (t.length == 0) return;
|
|
523
538
|
if (t.length > this.maxInputLength)
|
|
524
539
|
throw new Error(`exceeded maximum input length(${t.length})`);
|
|
525
|
-
const e = t.charAt(t.length - 1), [s, r] =
|
|
540
|
+
const e = t.charAt(t.length - 1), [s, r] = tn(e, [new w(p.BACK, 1)]);
|
|
526
541
|
if (!r)
|
|
527
542
|
throw new Error(`last character(${e}) is not type value`);
|
|
528
543
|
}
|
|
529
544
|
}
|
|
530
|
-
function
|
|
545
|
+
function Qe(n) {
|
|
531
546
|
if (n.length === 0) return b.UNKNOWN;
|
|
532
547
|
if (n.length === 1)
|
|
533
548
|
return n[0].has(y.DORA) ? b.IMAGE_DORA : n[0].has(y.TSUMO) ? b.TSUMO : b.HAND;
|
|
@@ -559,7 +574,7 @@ function Ts(n, t) {
|
|
|
559
574
|
return s.isNum() && s.n == 0 ? s.clone({ n: 5, add: y.RED }) : s;
|
|
560
575
|
});
|
|
561
576
|
}
|
|
562
|
-
function
|
|
577
|
+
function tn(n, t) {
|
|
563
578
|
const [e, s] = Ss(n);
|
|
564
579
|
if (s) return [e, !0];
|
|
565
580
|
if ((n === "w" || n === "d") && t.length > 0) {
|
|
@@ -571,7 +586,7 @@ function Qe(n, t) {
|
|
|
571
586
|
}
|
|
572
587
|
return [p.BACK, !1];
|
|
573
588
|
}
|
|
574
|
-
function
|
|
589
|
+
function In(n) {
|
|
575
590
|
const t = Number(n), e = 0 <= t && t <= 9;
|
|
576
591
|
return [t, e];
|
|
577
592
|
}
|
|
@@ -583,7 +598,7 @@ function Is(n) {
|
|
|
583
598
|
const r = n.peekCharN(s);
|
|
584
599
|
if (t.includes(r)) e.push(r);
|
|
585
600
|
else {
|
|
586
|
-
const [i, o] =
|
|
601
|
+
const [i, o] = In(r);
|
|
587
602
|
if (!o) break;
|
|
588
603
|
for (const c of e) n.readChar();
|
|
589
604
|
const a = new w(p.BACK, i, e);
|
|
@@ -609,18 +624,18 @@ function H(n, t = !1) {
|
|
|
609
624
|
}
|
|
610
625
|
const Jt = (n) => {
|
|
611
626
|
let t = n.substring(0, 2), e = Number(n.substring(2, 3));
|
|
612
|
-
return e == 4 ? (e = 1, t =
|
|
613
|
-
}, Do = (n) => Jt(Jt(Jt(n))),
|
|
627
|
+
return e == 4 ? (e = 1, t = Et(t)) : e++, `${t}${e}`;
|
|
628
|
+
}, Do = (n) => Jt(Jt(Jt(n))), Et = (n) => {
|
|
614
629
|
let t = Number(n.toString()[0]);
|
|
615
630
|
return t = t % 4 + 1, `${t}w`;
|
|
616
|
-
},
|
|
631
|
+
}, Pe = (n) => {
|
|
617
632
|
let t = Number(n.toString()[0]);
|
|
618
633
|
return t = t % 2 + 1, `${t}w`;
|
|
619
|
-
},
|
|
634
|
+
}, en = (n, t, e) => {
|
|
620
635
|
const s = Math.abs(Number(n[0]) - Number(t[0]));
|
|
621
636
|
return S(s == 1 || s == 2 || s == 3), e == b.PON ? s == 3 ? 0 : s == 2 ? 1 : 2 : s == 3 ? 0 : s == 1 ? 3 : 2;
|
|
622
637
|
};
|
|
623
|
-
function
|
|
638
|
+
function nn(n) {
|
|
624
639
|
return typeof n > "u";
|
|
625
640
|
}
|
|
626
641
|
function _e(n, t = 0) {
|
|
@@ -633,7 +648,7 @@ function _e(n, t = 0) {
|
|
|
633
648
|
f: t
|
|
634
649
|
};
|
|
635
650
|
}
|
|
636
|
-
function
|
|
651
|
+
function We(...n) {
|
|
637
652
|
n = Array.isArray(n[0]) ? n[0] : n;
|
|
638
653
|
const t = (e, s) => ({
|
|
639
654
|
a: e.a * s.a + e.c * s.b,
|
|
@@ -652,12 +667,12 @@ function Pe(...n) {
|
|
|
652
667
|
return t(n[0], n[1]);
|
|
653
668
|
default: {
|
|
654
669
|
const [e, s, ...r] = n, i = t(e, s);
|
|
655
|
-
return
|
|
670
|
+
return We(i, ...r);
|
|
656
671
|
}
|
|
657
672
|
}
|
|
658
673
|
}
|
|
659
674
|
function Os(...n) {
|
|
660
|
-
return
|
|
675
|
+
return We(...n);
|
|
661
676
|
}
|
|
662
677
|
const { cos: ks, sin: Cs, PI: xs } = Math;
|
|
663
678
|
function Rs(n, t, e) {
|
|
@@ -669,7 +684,7 @@ function Rs(n, t, e) {
|
|
|
669
684
|
d: s,
|
|
670
685
|
f: 0
|
|
671
686
|
};
|
|
672
|
-
return
|
|
687
|
+
return nn(t) || nn(e) ? i : We([
|
|
673
688
|
_e(t, e),
|
|
674
689
|
i,
|
|
675
690
|
_e(-t, -e)
|
|
@@ -797,30 +812,30 @@ function kn(n, t) {
|
|
|
797
812
|
}
|
|
798
813
|
return e;
|
|
799
814
|
}
|
|
800
|
-
const
|
|
815
|
+
const De = function(n) {
|
|
801
816
|
const t = Bs.exec(n);
|
|
802
817
|
return !(t === null || typeof t > "u");
|
|
803
818
|
};
|
|
804
819
|
function Ks(n) {
|
|
805
820
|
return typeof n < "u";
|
|
806
821
|
}
|
|
807
|
-
const
|
|
822
|
+
const zs = {
|
|
808
823
|
allowBooleanAttributes: !1,
|
|
809
824
|
//A tag can have attributes without any value
|
|
810
825
|
unpairedTags: []
|
|
811
826
|
};
|
|
812
|
-
function
|
|
813
|
-
t = Object.assign({},
|
|
827
|
+
function Ls(n, t) {
|
|
828
|
+
t = Object.assign({}, zs, t);
|
|
814
829
|
const e = [];
|
|
815
830
|
let s = !1, r = !1;
|
|
816
831
|
n[0] === "\uFEFF" && (n = n.substr(1));
|
|
817
832
|
for (let i = 0; i < n.length; i++)
|
|
818
833
|
if (n[i] === "<" && n[i + 1] === "?") {
|
|
819
|
-
if (i += 2, i =
|
|
834
|
+
if (i += 2, i = rn(n, i), i.err) return i;
|
|
820
835
|
} else if (n[i] === "<") {
|
|
821
836
|
let o = i;
|
|
822
837
|
if (i++, n[i] === "!") {
|
|
823
|
-
i =
|
|
838
|
+
i = on(n, i);
|
|
824
839
|
continue;
|
|
825
840
|
} else {
|
|
826
841
|
let a = !1;
|
|
@@ -831,31 +846,31 @@ function zs(n, t) {
|
|
|
831
846
|
c += n[i];
|
|
832
847
|
if (c = c.trim(), c[c.length - 1] === "/" && (c = c.substring(0, c.length - 1), i--), !Xs(c)) {
|
|
833
848
|
let h;
|
|
834
|
-
return c.trim().length === 0 ? h = "Invalid space after '<'." : h = "Tag '" + c + "' is an invalid name.",
|
|
849
|
+
return c.trim().length === 0 ? h = "Invalid space after '<'." : h = "Tag '" + c + "' is an invalid name.", I("InvalidTag", h, R(n, i));
|
|
835
850
|
}
|
|
836
851
|
const l = Zs(n, i);
|
|
837
852
|
if (l === !1)
|
|
838
|
-
return
|
|
853
|
+
return I("InvalidAttr", "Attributes for '" + c + "' have open quote.", R(n, i));
|
|
839
854
|
let u = l.value;
|
|
840
855
|
if (i = l.index, u[u.length - 1] === "/") {
|
|
841
856
|
const h = i - u.length;
|
|
842
857
|
u = u.substring(0, u.length - 1);
|
|
843
|
-
const d =
|
|
858
|
+
const d = an(u, t);
|
|
844
859
|
if (d === !0)
|
|
845
860
|
s = !0;
|
|
846
861
|
else
|
|
847
|
-
return
|
|
862
|
+
return I(d.err.code, d.err.msg, R(n, h + d.err.line));
|
|
848
863
|
} else if (a)
|
|
849
864
|
if (l.tagClosed) {
|
|
850
865
|
if (u.trim().length > 0)
|
|
851
|
-
return
|
|
866
|
+
return I("InvalidTag", "Closing tag '" + c + "' can't have attributes or invalid starting.", R(n, o));
|
|
852
867
|
if (e.length === 0)
|
|
853
|
-
return
|
|
868
|
+
return I("InvalidTag", "Closing tag '" + c + "' has not been opened.", R(n, o));
|
|
854
869
|
{
|
|
855
870
|
const h = e.pop();
|
|
856
871
|
if (c !== h.tagName) {
|
|
857
872
|
let d = R(n, h.tagStartPos);
|
|
858
|
-
return
|
|
873
|
+
return I(
|
|
859
874
|
"InvalidTag",
|
|
860
875
|
"Expected closing tag '" + h.tagName + "' (opened in line " + d.line + ", col " + d.col + ") instead of closing tag '" + c + "'.",
|
|
861
876
|
R(n, o)
|
|
@@ -863,57 +878,57 @@ function zs(n, t) {
|
|
|
863
878
|
}
|
|
864
879
|
e.length == 0 && (r = !0);
|
|
865
880
|
}
|
|
866
|
-
} else return
|
|
881
|
+
} else return I("InvalidTag", "Closing tag '" + c + "' doesn't have proper closing.", R(n, i));
|
|
867
882
|
else {
|
|
868
|
-
const h =
|
|
883
|
+
const h = an(u, t);
|
|
869
884
|
if (h !== !0)
|
|
870
|
-
return
|
|
885
|
+
return I(h.err.code, h.err.msg, R(n, i - u.length + h.err.line));
|
|
871
886
|
if (r === !0)
|
|
872
|
-
return
|
|
887
|
+
return I("InvalidXml", "Multiple possible root nodes found.", R(n, i));
|
|
873
888
|
t.unpairedTags.indexOf(c) !== -1 || e.push({ tagName: c, tagStartPos: o }), s = !0;
|
|
874
889
|
}
|
|
875
890
|
for (i++; i < n.length; i++)
|
|
876
891
|
if (n[i] === "<")
|
|
877
892
|
if (n[i + 1] === "!") {
|
|
878
|
-
i++, i =
|
|
893
|
+
i++, i = on(n, i);
|
|
879
894
|
continue;
|
|
880
895
|
} else if (n[i + 1] === "?") {
|
|
881
|
-
if (i =
|
|
896
|
+
if (i = rn(n, ++i), i.err) return i;
|
|
882
897
|
} else
|
|
883
898
|
break;
|
|
884
899
|
else if (n[i] === "&") {
|
|
885
900
|
const h = Vs(n, i);
|
|
886
901
|
if (h == -1)
|
|
887
|
-
return
|
|
902
|
+
return I("InvalidChar", "char '&' is not expected.", R(n, i));
|
|
888
903
|
i = h;
|
|
889
|
-
} else if (r === !0 && !
|
|
890
|
-
return
|
|
904
|
+
} else if (r === !0 && !sn(n[i]))
|
|
905
|
+
return I("InvalidXml", "Extra text at the end", R(n, i));
|
|
891
906
|
n[i] === "<" && i--;
|
|
892
907
|
}
|
|
893
908
|
} else {
|
|
894
|
-
if (
|
|
909
|
+
if (sn(n[i]))
|
|
895
910
|
continue;
|
|
896
|
-
return
|
|
911
|
+
return I("InvalidChar", "char '" + n[i] + "' is not expected.", R(n, i));
|
|
897
912
|
}
|
|
898
913
|
if (s) {
|
|
899
914
|
if (e.length == 1)
|
|
900
|
-
return
|
|
915
|
+
return I("InvalidTag", "Unclosed tag '" + e[0].tagName + "'.", R(n, e[0].tagStartPos));
|
|
901
916
|
if (e.length > 0)
|
|
902
|
-
return
|
|
903
|
-
} else return
|
|
917
|
+
return I("InvalidXml", "Invalid '" + JSON.stringify(e.map((i) => i.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
|
|
918
|
+
} else return I("InvalidXml", "Start tag expected.", 1);
|
|
904
919
|
return !0;
|
|
905
920
|
}
|
|
906
|
-
function
|
|
921
|
+
function sn(n) {
|
|
907
922
|
return n === " " || n === " " || n === `
|
|
908
923
|
` || n === "\r";
|
|
909
924
|
}
|
|
910
|
-
function
|
|
925
|
+
function rn(n, t) {
|
|
911
926
|
const e = t;
|
|
912
927
|
for (; t < n.length; t++)
|
|
913
928
|
if (n[t] == "?" || n[t] == " ") {
|
|
914
929
|
const s = n.substr(e, t - e);
|
|
915
930
|
if (t > 5 && s === "xml")
|
|
916
|
-
return
|
|
931
|
+
return I("InvalidXml", "XML declaration allowed only at the start of the document.", R(n, t));
|
|
917
932
|
if (n[t] == "?" && n[t + 1] == ">") {
|
|
918
933
|
t++;
|
|
919
934
|
break;
|
|
@@ -922,7 +937,7 @@ function sn(n, t) {
|
|
|
922
937
|
}
|
|
923
938
|
return t;
|
|
924
939
|
}
|
|
925
|
-
function
|
|
940
|
+
function on(n, t) {
|
|
926
941
|
if (n.length > t + 5 && n[t + 1] === "-" && n[t + 2] === "-") {
|
|
927
942
|
for (t += 3; t < n.length; t++)
|
|
928
943
|
if (n[t] === "-" && n[t + 1] === "-" && n[t + 2] === ">") {
|
|
@@ -964,22 +979,22 @@ function Zs(n, t) {
|
|
|
964
979
|
};
|
|
965
980
|
}
|
|
966
981
|
const Us = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
|
|
967
|
-
function
|
|
982
|
+
function an(n, t) {
|
|
968
983
|
const e = kn(n, Us), s = {};
|
|
969
984
|
for (let r = 0; r < e.length; r++) {
|
|
970
985
|
if (e[r][1].length === 0)
|
|
971
|
-
return
|
|
986
|
+
return I("InvalidAttr", "Attribute '" + e[r][2] + "' has no space in starting.", $t(e[r]));
|
|
972
987
|
if (e[r][3] !== void 0 && e[r][4] === void 0)
|
|
973
|
-
return
|
|
988
|
+
return I("InvalidAttr", "Attribute '" + e[r][2] + "' is without value.", $t(e[r]));
|
|
974
989
|
if (e[r][3] === void 0 && !t.allowBooleanAttributes)
|
|
975
|
-
return
|
|
990
|
+
return I("InvalidAttr", "boolean attribute '" + e[r][2] + "' is not allowed.", $t(e[r]));
|
|
976
991
|
const i = e[r][2];
|
|
977
992
|
if (!Js(i))
|
|
978
|
-
return
|
|
993
|
+
return I("InvalidAttr", "Attribute '" + i + "' is an invalid name.", $t(e[r]));
|
|
979
994
|
if (!s.hasOwnProperty(i))
|
|
980
995
|
s[i] = 1;
|
|
981
996
|
else
|
|
982
|
-
return
|
|
997
|
+
return I("InvalidAttr", "Attribute '" + i + "' is repeated.", $t(e[r]));
|
|
983
998
|
}
|
|
984
999
|
return !0;
|
|
985
1000
|
}
|
|
@@ -1007,7 +1022,7 @@ function Vs(n, t) {
|
|
|
1007
1022
|
}
|
|
1008
1023
|
return t;
|
|
1009
1024
|
}
|
|
1010
|
-
function
|
|
1025
|
+
function I(n, t, e) {
|
|
1011
1026
|
return {
|
|
1012
1027
|
err: {
|
|
1013
1028
|
code: n,
|
|
@@ -1018,10 +1033,10 @@ function T(n, t, e) {
|
|
|
1018
1033
|
};
|
|
1019
1034
|
}
|
|
1020
1035
|
function Js(n) {
|
|
1021
|
-
return
|
|
1036
|
+
return De(n);
|
|
1022
1037
|
}
|
|
1023
1038
|
function Xs(n) {
|
|
1024
|
-
return
|
|
1039
|
+
return De(n);
|
|
1025
1040
|
}
|
|
1026
1041
|
function R(n, t) {
|
|
1027
1042
|
const e = n.substring(0, t).split(/\r?\n/);
|
|
@@ -1155,7 +1170,7 @@ function ir(n, t) {
|
|
|
1155
1170
|
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";
|
|
1156
1171
|
}
|
|
1157
1172
|
function or(n) {
|
|
1158
|
-
if (
|
|
1173
|
+
if (De(n))
|
|
1159
1174
|
return n;
|
|
1160
1175
|
throw new Error(`Invalid entity name ${n}`);
|
|
1161
1176
|
}
|
|
@@ -1559,7 +1574,7 @@ class Cr {
|
|
|
1559
1574
|
throw new Error("XML data is accepted in String or Bytes[] form.");
|
|
1560
1575
|
if (e) {
|
|
1561
1576
|
e === !0 && (e = {});
|
|
1562
|
-
const i =
|
|
1577
|
+
const i = Ls(t, e);
|
|
1563
1578
|
if (i !== !0)
|
|
1564
1579
|
throw Error(`${i.err.msg}:${i.err.line}:${i.err.col}`);
|
|
1565
1580
|
}
|
|
@@ -1619,14 +1634,14 @@ function Rn(n, t, e, s) {
|
|
|
1619
1634
|
r += s + `<!--${a[c][0][t.textNodeName]}-->`, i = !0;
|
|
1620
1635
|
continue;
|
|
1621
1636
|
} else if (c[0] === "?") {
|
|
1622
|
-
const f =
|
|
1637
|
+
const f = cn(a[":@"], t), m = c === "?xml" ? "" : s;
|
|
1623
1638
|
let E = a[c][0][t.textNodeName];
|
|
1624
1639
|
E = E.length !== 0 ? " " + E : "", r += m + `<${c}${E}${f}?>`, i = !0;
|
|
1625
1640
|
continue;
|
|
1626
1641
|
}
|
|
1627
1642
|
let u = s;
|
|
1628
1643
|
u !== "" && (u += t.indentBy);
|
|
1629
|
-
const h =
|
|
1644
|
+
const h = cn(a[":@"], t), d = s + `<${c}${h}`, g = Rn(a[c], t, l, u);
|
|
1630
1645
|
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;
|
|
1631
1646
|
}
|
|
1632
1647
|
return r;
|
|
@@ -1639,7 +1654,7 @@ function Mr(n) {
|
|
|
1639
1654
|
return s;
|
|
1640
1655
|
}
|
|
1641
1656
|
}
|
|
1642
|
-
function
|
|
1657
|
+
function cn(n, t) {
|
|
1643
1658
|
let e = "";
|
|
1644
1659
|
if (n && !t.ignoreAttributes)
|
|
1645
1660
|
for (let s in n) {
|
|
@@ -1806,7 +1821,7 @@ function Wr(n) {
|
|
|
1806
1821
|
function Dr(n) {
|
|
1807
1822
|
return n.startsWith(this.options.attributeNamePrefix) && n !== this.options.textNodeName ? n.substr(this.attrPrefixLen) : !1;
|
|
1808
1823
|
}
|
|
1809
|
-
class
|
|
1824
|
+
class gt {
|
|
1810
1825
|
constructor(t) {
|
|
1811
1826
|
_(this, "type");
|
|
1812
1827
|
_(this, "attrs", {});
|
|
@@ -1863,7 +1878,7 @@ class yt {
|
|
|
1863
1878
|
return this.toString();
|
|
1864
1879
|
}
|
|
1865
1880
|
}
|
|
1866
|
-
class $n extends
|
|
1881
|
+
class $n extends gt {
|
|
1867
1882
|
constructor(e) {
|
|
1868
1883
|
super("image");
|
|
1869
1884
|
_(this, "attrs", {});
|
|
@@ -1873,7 +1888,7 @@ class $n extends yt {
|
|
|
1873
1888
|
return this.attrs.href = e, this;
|
|
1874
1889
|
}
|
|
1875
1890
|
}
|
|
1876
|
-
class
|
|
1891
|
+
class Be extends gt {
|
|
1877
1892
|
constructor(e) {
|
|
1878
1893
|
super("use");
|
|
1879
1894
|
_(this, "attrs", {});
|
|
@@ -1886,7 +1901,7 @@ class De extends yt {
|
|
|
1886
1901
|
return e == null ? e : `#${e}`;
|
|
1887
1902
|
}
|
|
1888
1903
|
}
|
|
1889
|
-
class Hn extends
|
|
1904
|
+
class Hn extends gt {
|
|
1890
1905
|
constructor() {
|
|
1891
1906
|
super("rect");
|
|
1892
1907
|
_(this, "attrs", {});
|
|
@@ -1898,7 +1913,7 @@ class Hn extends yt {
|
|
|
1898
1913
|
return this.attrs.stroke = e, this;
|
|
1899
1914
|
}
|
|
1900
1915
|
}
|
|
1901
|
-
class Nt extends
|
|
1916
|
+
class Nt extends gt {
|
|
1902
1917
|
constructor(e = "") {
|
|
1903
1918
|
super("text");
|
|
1904
1919
|
_(this, "attrs");
|
|
@@ -1915,7 +1930,7 @@ class Nt extends yt {
|
|
|
1915
1930
|
return this._text;
|
|
1916
1931
|
}
|
|
1917
1932
|
}
|
|
1918
|
-
let Pn = class extends
|
|
1933
|
+
let Pn = class extends gt {
|
|
1919
1934
|
constructor(e) {
|
|
1920
1935
|
super("symbol");
|
|
1921
1936
|
_(this, "raw");
|
|
@@ -1928,7 +1943,7 @@ let Pn = class extends yt {
|
|
|
1928
1943
|
return this.raw;
|
|
1929
1944
|
}
|
|
1930
1945
|
};
|
|
1931
|
-
class v extends
|
|
1946
|
+
class v extends gt {
|
|
1932
1947
|
constructor() {
|
|
1933
1948
|
super("g");
|
|
1934
1949
|
_(this, "children", []);
|
|
@@ -1965,7 +1980,7 @@ const Br = [
|
|
|
1965
1980
|
'version="1.1"',
|
|
1966
1981
|
'xmlns:xlink="http://www.w3.org/1999/xlink"'
|
|
1967
1982
|
];
|
|
1968
|
-
class Kr extends
|
|
1983
|
+
class Kr extends gt {
|
|
1969
1984
|
constructor() {
|
|
1970
1985
|
super("svg");
|
|
1971
1986
|
_(this, "children", []);
|
|
@@ -2012,11 +2027,11 @@ class Kr extends yt {
|
|
|
2012
2027
|
}
|
|
2013
2028
|
}
|
|
2014
2029
|
}
|
|
2015
|
-
function
|
|
2030
|
+
function zr() {
|
|
2016
2031
|
return new Kr();
|
|
2017
2032
|
}
|
|
2018
|
-
const Ko =
|
|
2019
|
-
function
|
|
2033
|
+
const Ko = zr, zo = v, Lo = $n, jo = Be, Fo = Hn, Zo = Nt;
|
|
2034
|
+
function Lr(n) {
|
|
2020
2035
|
return n.replace(/[A-Z]/g, (t) => "-" + t.toLowerCase());
|
|
2021
2036
|
}
|
|
2022
2037
|
function jr(n) {
|
|
@@ -2026,7 +2041,7 @@ function Fr(n) {
|
|
|
2026
2041
|
return n == null ? "" : `transform="${$s(n)}"`;
|
|
2027
2042
|
}
|
|
2028
2043
|
function Wn(n) {
|
|
2029
|
-
return Object.entries(n).filter(([t, e]) => e !== void 0).map(([t, e]) => `${
|
|
2044
|
+
return Object.entries(n).filter(([t, e]) => e !== void 0).map(([t, e]) => `${Lr(t)}="${e}"`).join(" ");
|
|
2030
2045
|
}
|
|
2031
2046
|
function Zr(n) {
|
|
2032
2047
|
const t = Object.entries(n).map(([e, s]) => `${e}: ${s};`).join(" ");
|
|
@@ -2073,7 +2088,7 @@ class vt {
|
|
|
2073
2088
|
// image wrapper
|
|
2074
2089
|
image(t) {
|
|
2075
2090
|
let e = new $n().load(this.buildURL(t));
|
|
2076
|
-
return this.svgSprite && (e = new
|
|
2091
|
+
return this.svgSprite && (e = new Be().use(vt.buildID(t))), t instanceof w && t.has(y.COLOR_GRAYSCALE) && e.css({ filter: "contrast(65%)" }), e;
|
|
2077
2092
|
}
|
|
2078
2093
|
createImage(t, e, s) {
|
|
2079
2094
|
const r = W(t, this.scale);
|
|
@@ -2082,7 +2097,7 @@ class vt {
|
|
|
2082
2097
|
createTextImage(t, e, s, r) {
|
|
2083
2098
|
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);
|
|
2084
2099
|
u.size(o.baseWidth, o.baseHeight).font({
|
|
2085
|
-
family:
|
|
2100
|
+
family: Nn,
|
|
2086
2101
|
size: a
|
|
2087
2102
|
}).dx(c).dy(l);
|
|
2088
2103
|
const h = new v();
|
|
@@ -2269,7 +2284,7 @@ const Gr = (n, t) => {
|
|
|
2269
2284
|
const t = Bn(), e = [];
|
|
2270
2285
|
return n.each((s, r) => {
|
|
2271
2286
|
const i = r[s];
|
|
2272
|
-
if (i instanceof
|
|
2287
|
+
if (i instanceof Be) {
|
|
2273
2288
|
const a = i.attr("href").substring(1);
|
|
2274
2289
|
t.includes(a) && e.push(a);
|
|
2275
2290
|
}
|
|
@@ -2287,7 +2302,7 @@ const Gr = (n, t) => {
|
|
|
2287
2302
|
e.push(r);
|
|
2288
2303
|
}
|
|
2289
2304
|
return e;
|
|
2290
|
-
},
|
|
2305
|
+
}, z = (n, t, e, s, r = 0, i = 0) => {
|
|
2291
2306
|
const o = new v().add(n);
|
|
2292
2307
|
if (s == 90) {
|
|
2293
2308
|
const a = r, c = i - e;
|
|
@@ -2302,11 +2317,11 @@ const Gr = (n, t) => {
|
|
|
2302
2317
|
return o.rotate(s, 0, e).translate(a, c), new v().add(o);
|
|
2303
2318
|
}
|
|
2304
2319
|
return new v().add(o);
|
|
2305
|
-
},
|
|
2320
|
+
}, Lt = (n, t) => {
|
|
2306
2321
|
const e = new v(), s = Jr(n);
|
|
2307
2322
|
for (let r = 0; r < s.length; r++) {
|
|
2308
2323
|
let i = s[r], o = r * t.tileHeight;
|
|
2309
|
-
const a = t.createBlockHandDiscard(new
|
|
2324
|
+
const a = t.createBlockHandDiscard(new Tn(i, b.IMAGE_DISCARD)).translate(0, o);
|
|
2310
2325
|
e.add(a);
|
|
2311
2326
|
}
|
|
2312
2327
|
return {
|
|
@@ -2315,17 +2330,17 @@ const Gr = (n, t) => {
|
|
|
2315
2330
|
height: t.tileHeight * s.length
|
|
2316
2331
|
};
|
|
2317
2332
|
}, Xr = (n, t, e) => {
|
|
2318
|
-
const s = t.font, r = t.textWidth, i = t.textHeight, o = e.sticks.dead, a = e.sticks.reach, c =
|
|
2333
|
+
const s = t.font, r = t.textWidth, i = t.textHeight, o = e.sticks.dead, a = e.sticks.reach, c = Ye.WIDTH * n.scale, l = Ye.HEIGHT * n.scale;
|
|
2319
2334
|
let u = r * 3, h = i;
|
|
2320
2335
|
const d = (c + n.tileWidth + r - u) / 2, g = new Nt().plain(e.round).font(s).x(d).y(0);
|
|
2321
2336
|
h += 25 * n.scale;
|
|
2322
|
-
const f = n.tileHeight, m = new v().size(c, f).translate(0, h), E = { family: s.family, size: s.size * 0.7 }, N = n.createStick(1e3).size(c, l).x(0).y(0), O = new Nt().plain(a.toString()).font(E).dx(c).dy(l), x = n.createStick(100).size(c, l).x(0).y(l + l),
|
|
2323
|
-
m.add(N), m.add(O), m.add(x), m.add(
|
|
2324
|
-
const
|
|
2325
|
-
m.add(
|
|
2326
|
-
const
|
|
2327
|
-
return
|
|
2328
|
-
e:
|
|
2337
|
+
const f = n.tileHeight, m = new v().size(c, f).translate(0, h), E = { family: s.family, size: s.size * 0.7 }, N = n.createStick(1e3).size(c, l).x(0).y(0), O = new Nt().plain(a.toString()).font(E).dx(c).dy(l), x = n.createStick(100).size(c, l).x(0).y(l + l), yt = new Nt().plain(o.toString()).font(E).dx(c).dy(l * 3);
|
|
2338
|
+
m.add(N), m.add(O), m.add(x), m.add(yt);
|
|
2339
|
+
const mt = n.createImage(e.doras[0], 0, 0).x(c + r).y(0);
|
|
2340
|
+
m.add(mt);
|
|
2341
|
+
const wt = new v();
|
|
2342
|
+
return wt.add(g), wt.add(g), wt.add(m), {
|
|
2343
|
+
e: wt,
|
|
2329
2344
|
width: c + n.tileWidth + r,
|
|
2330
2345
|
height: h + n.tileHeight
|
|
2331
2346
|
};
|
|
@@ -2335,16 +2350,16 @@ const Gr = (n, t) => {
|
|
|
2335
2350
|
), c = Math.max(
|
|
2336
2351
|
e + n.tileHeight * 2 + n.blockMargin * 2,
|
|
2337
2352
|
a + n.tileWidth * 2 + n.blockMargin
|
|
2338
|
-
), l = c, u =
|
|
2353
|
+
), l = c, u = z(s.e, s.width, s.height, 0).translate(
|
|
2339
2354
|
(c - s.width) / 2,
|
|
2340
2355
|
l - s.height
|
|
2341
|
-
), h =
|
|
2356
|
+
), h = z(r.e, r.width, r.height, 270).translate(
|
|
2342
2357
|
c - r.height,
|
|
2343
2358
|
(c - r.width) / 2
|
|
2344
|
-
), d =
|
|
2359
|
+
), d = z(i.e, i.width, i.height, 180).translate(
|
|
2345
2360
|
(c - i.width) / 2,
|
|
2346
2361
|
0
|
|
2347
|
-
), g =
|
|
2362
|
+
), g = z(o.e, o.width, o.height, 90).translate(
|
|
2348
2363
|
0,
|
|
2349
2364
|
(c - o.width) / 2
|
|
2350
2365
|
), f = new v().size(c, l);
|
|
@@ -2358,11 +2373,11 @@ const Gr = (n, t) => {
|
|
|
2358
2373
|
s / 2 - c.width / 2,
|
|
2359
2374
|
s / 2 - c.height / 2
|
|
2360
2375
|
);
|
|
2361
|
-
const l = (ps,
|
|
2362
|
-
const ys = `${ps} ${
|
|
2376
|
+
const l = (ps, qe, gs) => {
|
|
2377
|
+
const ys = `${ps} ${qe}`, ms = new Nt().plain(ys).font(r).attr(gs);
|
|
2363
2378
|
return {
|
|
2364
2379
|
e: new v().add(ms),
|
|
2365
|
-
width: i + a *
|
|
2380
|
+
width: i + a * qe.toString().length,
|
|
2366
2381
|
height: o
|
|
2367
2382
|
};
|
|
2368
2383
|
}, [u, h, d, g] = Yr(
|
|
@@ -2377,7 +2392,7 @@ const Gr = (n, t) => {
|
|
|
2377
2392
|
"dominant-baseline": "text-after-edge",
|
|
2378
2393
|
"text-anchor": "middle"
|
|
2379
2394
|
});
|
|
2380
|
-
const O =
|
|
2395
|
+
const O = z(N.e, N.width, N.height, 270).translate(
|
|
2381
2396
|
s,
|
|
2382
2397
|
s / 2 - N.width
|
|
2383
2398
|
);
|
|
@@ -2385,34 +2400,34 @@ const Gr = (n, t) => {
|
|
|
2385
2400
|
"text-anchor": "middle",
|
|
2386
2401
|
"dominant-baseline": "text-after-edge"
|
|
2387
2402
|
});
|
|
2388
|
-
const
|
|
2403
|
+
const yt = z(x.e, x.width, x.height, 180).translate(
|
|
2389
2404
|
s / 2 - x.width,
|
|
2390
2405
|
-x.height
|
|
2391
2406
|
);
|
|
2392
|
-
let
|
|
2407
|
+
let mt = l(g, f.left, {
|
|
2393
2408
|
"dominant-baseline": "ideographic",
|
|
2394
2409
|
"text-anchor": "middle"
|
|
2395
2410
|
});
|
|
2396
|
-
const
|
|
2397
|
-
-
|
|
2411
|
+
const wt = z(mt.e, mt.width, mt.height, 90).translate(
|
|
2412
|
+
-mt.height,
|
|
2398
2413
|
s / 2
|
|
2399
2414
|
), nt = new v(), fs = new Hn().size(s, s).x(0).y(0).fill("none").stroke("#000000");
|
|
2400
|
-
return nt.add(fs), nt.add(c.e), nt.add(E), nt.add(O), nt.add(
|
|
2415
|
+
return nt.add(fs), nt.add(c.e), nt.add(E), nt.add(O), nt.add(yt), nt.add(wt), { e: nt, width: s, height: s };
|
|
2401
2416
|
}, ti = (n, t) => {
|
|
2402
|
-
const e =
|
|
2417
|
+
const e = Lt(t.front, n), s = Lt(t.right, n), r = Lt(t.opposite, n), i = Lt(t.left, n), o = [e.height, s.height, r.height, i.height].reduce(
|
|
2403
2418
|
(O, x) => Math.max(O, x)
|
|
2404
|
-
), 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 =
|
|
2419
|
+
), 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 = z(e.e, a, c, 0).translate(
|
|
2405
2420
|
d,
|
|
2406
2421
|
u - c
|
|
2407
|
-
), m =
|
|
2422
|
+
), m = z(s.e, a, c, 270).translate(
|
|
2408
2423
|
l - c,
|
|
2409
2424
|
g
|
|
2410
|
-
), E =
|
|
2425
|
+
), E = z(
|
|
2411
2426
|
r.e,
|
|
2412
2427
|
a,
|
|
2413
2428
|
c,
|
|
2414
2429
|
180
|
|
2415
|
-
).translate(d, 0), N =
|
|
2430
|
+
).translate(d, 0), N = z(i.e, a, c, 90).translate(
|
|
2416
2431
|
0,
|
|
2417
2432
|
g
|
|
2418
2433
|
);
|
|
@@ -2542,7 +2557,7 @@ function oi(n, t, e) {
|
|
|
2542
2557
|
);
|
|
2543
2558
|
}
|
|
2544
2559
|
// @__NO_SIDE_EFFECTS__
|
|
2545
|
-
function
|
|
2560
|
+
function zn(n, t, e) {
|
|
2546
2561
|
return typeof n.default == "function" ? (
|
|
2547
2562
|
// @ts-expect-error
|
|
2548
2563
|
n.default(t, e)
|
|
@@ -2582,7 +2597,7 @@ function B(n, t) {
|
|
|
2582
2597
|
return /* @__PURE__ */ Mt(this);
|
|
2583
2598
|
},
|
|
2584
2599
|
"~run"(e, s) {
|
|
2585
|
-
return e.value === void 0 && (this.default !== void 0 && (e.value = /* @__PURE__ */
|
|
2600
|
+
return e.value === void 0 && (this.default !== void 0 && (e.value = /* @__PURE__ */ zn(this, e, s)), e.value === void 0) ? (e.typed = !0, e) : this.wrapped["~run"](e, s);
|
|
2586
2601
|
}
|
|
2587
2602
|
};
|
|
2588
2603
|
}
|
|
@@ -2629,7 +2644,7 @@ function It(n, t) {
|
|
|
2629
2644
|
const c = o in r ? (
|
|
2630
2645
|
// @ts-expect-error
|
|
2631
2646
|
r[o]
|
|
2632
|
-
) : /* @__PURE__ */
|
|
2647
|
+
) : /* @__PURE__ */ zn(a), l = a["~run"]({ value: c }, s);
|
|
2633
2648
|
if (l.issues) {
|
|
2634
2649
|
const u = {
|
|
2635
2650
|
type: "object",
|
|
@@ -2708,7 +2723,7 @@ function te(n) {
|
|
|
2708
2723
|
};
|
|
2709
2724
|
}
|
|
2710
2725
|
// @__NO_SIDE_EFFECTS__
|
|
2711
|
-
function
|
|
2726
|
+
function ln(...n) {
|
|
2712
2727
|
return {
|
|
2713
2728
|
...n[0],
|
|
2714
2729
|
pipe: n,
|
|
@@ -2758,17 +2773,17 @@ const jt = /* @__PURE__ */ B(
|
|
|
2758
2773
|
}, li = /* @__PURE__ */ B(
|
|
2759
2774
|
/* @__PURE__ */ It({
|
|
2760
2775
|
round: /* @__PURE__ */ B(
|
|
2761
|
-
/* @__PURE__ */ ve(Object.keys(
|
|
2776
|
+
/* @__PURE__ */ ve(Object.keys(Sn)),
|
|
2762
2777
|
st.round
|
|
2763
2778
|
),
|
|
2764
2779
|
sticks: /* @__PURE__ */ B(
|
|
2765
2780
|
/* @__PURE__ */ It({
|
|
2766
2781
|
reach: /* @__PURE__ */ B(
|
|
2767
|
-
/* @__PURE__ */
|
|
2782
|
+
/* @__PURE__ */ ln(/* @__PURE__ */ Qt(), /* @__PURE__ */ Se(0, ""), /* @__PURE__ */ Ne(9, "")),
|
|
2768
2783
|
st.sticks.reach
|
|
2769
2784
|
),
|
|
2770
2785
|
dead: /* @__PURE__ */ B(
|
|
2771
|
-
/* @__PURE__ */
|
|
2786
|
+
/* @__PURE__ */ ln(/* @__PURE__ */ Qt(), /* @__PURE__ */ Se(0, ""), /* @__PURE__ */ Ne(9, "")),
|
|
2772
2787
|
st.sticks.dead
|
|
2773
2788
|
)
|
|
2774
2789
|
}),
|
|
@@ -2858,7 +2873,7 @@ const jt = /* @__PURE__ */ B(
|
|
|
2858
2873
|
opposite: new D(n[e.opposite].hand).parse(),
|
|
2859
2874
|
left: new D(n[e.left].hand).parse()
|
|
2860
2875
|
}, o = {
|
|
2861
|
-
round:
|
|
2876
|
+
round: Sn[n.board.round],
|
|
2862
2877
|
frontPlace: $e[t],
|
|
2863
2878
|
sticks: n.board.sticks,
|
|
2864
2879
|
doras: new D(n.board.doras).tiles(),
|
|
@@ -2872,11 +2887,11 @@ const jt = /* @__PURE__ */ B(
|
|
|
2872
2887
|
return { discards: r, hands: i, scoreBoard: o };
|
|
2873
2888
|
}, mi = (n) => ({
|
|
2874
2889
|
front: n,
|
|
2875
|
-
right:
|
|
2876
|
-
opposite:
|
|
2877
|
-
left:
|
|
2890
|
+
right: Et(n),
|
|
2891
|
+
opposite: Et(Et(n)),
|
|
2892
|
+
left: Pe(n)
|
|
2878
2893
|
});
|
|
2879
|
-
function*
|
|
2894
|
+
function* L(n) {
|
|
2880
2895
|
const t = n != null && n.filterBy && n.filterBy.length > 0 ? n == null ? void 0 : n.filterBy : Object.values(p);
|
|
2881
2896
|
for (const e of t) {
|
|
2882
2897
|
if (n != null && n.skipBack && e == p.BACK) continue;
|
|
@@ -2885,7 +2900,7 @@ function* z(n) {
|
|
|
2885
2900
|
yield [e, r];
|
|
2886
2901
|
}
|
|
2887
2902
|
}
|
|
2888
|
-
class
|
|
2903
|
+
class Ke {
|
|
2889
2904
|
constructor(t, e = !1) {
|
|
2890
2905
|
_(this, "data");
|
|
2891
2906
|
this.data = {
|
|
@@ -2924,7 +2939,7 @@ class Be {
|
|
|
2924
2939
|
}
|
|
2925
2940
|
get hands() {
|
|
2926
2941
|
const t = [];
|
|
2927
|
-
for (const [e, s] of
|
|
2942
|
+
for (const [e, s] of L()) {
|
|
2928
2943
|
let r = this.get(e, s);
|
|
2929
2944
|
e != p.Z && s == 5 && this.get(e, 0) > 0 && (r -= this.get(e, 0), t.push(new w(e, s, [y.RED])));
|
|
2930
2945
|
for (let i = 0; i < r; i++)
|
|
@@ -2957,7 +2972,7 @@ class Be {
|
|
|
2957
2972
|
}
|
|
2958
2973
|
sum(t) {
|
|
2959
2974
|
let e = 0;
|
|
2960
|
-
for (const [s, r] of
|
|
2975
|
+
for (const [s, r] of L({ filterBy: [t] })) e += this.get(s, r);
|
|
2961
2976
|
return e;
|
|
2962
2977
|
}
|
|
2963
2978
|
get(t, e) {
|
|
@@ -3027,7 +3042,7 @@ class Be {
|
|
|
3027
3042
|
throw new Error(`unexpected input ${t}`);
|
|
3028
3043
|
}
|
|
3029
3044
|
clone() {
|
|
3030
|
-
const t = new
|
|
3045
|
+
const t = new Ke(this.toString());
|
|
3031
3046
|
return t.data.reached = this.data.reached, t;
|
|
3032
3047
|
}
|
|
3033
3048
|
}
|
|
@@ -3046,7 +3061,7 @@ class le {
|
|
|
3046
3061
|
sevenPairs() {
|
|
3047
3062
|
if (this.hand.called.length > 0) return 1 / 0;
|
|
3048
3063
|
let t = 0, e = 0;
|
|
3049
|
-
for (const [s, r] of
|
|
3064
|
+
for (const [s, r] of L({ skipBack: !0 }))
|
|
3050
3065
|
this.hand.get(s, r) == 2 && t++, this.hand.get(s, r) == 1 && e++;
|
|
3051
3066
|
return t > 7 && (t = 7), t + e >= 7 && (e = 7 - t), 13 - 2 * t - e;
|
|
3052
3067
|
}
|
|
@@ -3064,7 +3079,7 @@ class le {
|
|
|
3064
3079
|
fourSetsOnePair() {
|
|
3065
3080
|
const t = (s) => {
|
|
3066
3081
|
const r = [0, 0, 0];
|
|
3067
|
-
for (const [d, g] of
|
|
3082
|
+
for (const [d, g] of L({ filterBy: [p.Z] }))
|
|
3068
3083
|
this.hand.get(d, g) >= 3 ? r[0]++ : this.hand.get(d, g) == 2 ? r[1]++ : this.hand.get(d, g) == 1 && r[2]++;
|
|
3069
3084
|
const i = [0, 0, 0], o = this.hand.get(p.BACK, 0), a = o % 3;
|
|
3070
3085
|
i[0] = Math.floor(o / 3), a == 2 ? i[1] = 1 : a == 1 && (i[2] = 1);
|
|
@@ -3082,7 +3097,7 @@ class le {
|
|
|
3082
3097
|
return c;
|
|
3083
3098
|
};
|
|
3084
3099
|
let e = t(!1);
|
|
3085
|
-
for (const [s, r] of
|
|
3100
|
+
for (const [s, r] of L())
|
|
3086
3101
|
if (this.hand.get(s, r) >= 2) {
|
|
3087
3102
|
const i = this.hand.dec(new Array(2).fill(new w(s, r))), o = t(!0);
|
|
3088
3103
|
this.hand.inc(i), o < e && (e = o);
|
|
@@ -3108,7 +3123,7 @@ class le {
|
|
|
3108
3123
|
}
|
|
3109
3124
|
groupRemainingTiles(t) {
|
|
3110
3125
|
let e = 0, s = 0, r = 0;
|
|
3111
|
-
for (const [i, o] of
|
|
3126
|
+
for (const [i, o] of L({ filterBy: [t] }))
|
|
3112
3127
|
r += this.hand.get(i, o), o <= 7 && this.hand.get(i, o + 1) == 0 && this.hand.get(i, o + 2) == 0 && (e += r >> 1, s += r % 2, r = 0);
|
|
3113
3128
|
return e += r >> 1, s += r % 2, {
|
|
3114
3129
|
patternA: [0, e, s],
|
|
@@ -3148,7 +3163,7 @@ class wi {
|
|
|
3148
3163
|
(g) => g.equals(e) && e.has(y.RED) == g.has(y.RED)
|
|
3149
3164
|
);
|
|
3150
3165
|
if (h < 0) continue;
|
|
3151
|
-
const d =
|
|
3166
|
+
const d = Ln(u);
|
|
3152
3167
|
c[d] || (c[d] = !0, r.push([o, l, h]));
|
|
3153
3168
|
}
|
|
3154
3169
|
}
|
|
@@ -3168,7 +3183,7 @@ class wi {
|
|
|
3168
3183
|
sevenPairs() {
|
|
3169
3184
|
if (this.hand.called.length > 0) return [];
|
|
3170
3185
|
const t = [];
|
|
3171
|
-
for (const [e, s] of
|
|
3186
|
+
for (const [e, s] of L({ skipBack: !0 })) {
|
|
3172
3187
|
const r = this.hand.get(e, s);
|
|
3173
3188
|
if (r == 2) {
|
|
3174
3189
|
const i = this.hand.dec(new Array(2).fill(new w(e, s)));
|
|
@@ -3188,7 +3203,7 @@ class wi {
|
|
|
3188
3203
|
const r = s == p.Z ? Bt : V;
|
|
3189
3204
|
for (let i of r)
|
|
3190
3205
|
if (this.hand.get(s, i) == 1)
|
|
3191
|
-
t.push(new
|
|
3206
|
+
t.push(new vn(new w(s, i)));
|
|
3192
3207
|
else if (this.hand.get(s, i) == 2 && e == !1)
|
|
3193
3208
|
t.unshift(new P(new w(s, i), new w(s, i))), e = !0;
|
|
3194
3209
|
else return [];
|
|
@@ -3207,7 +3222,7 @@ class wi {
|
|
|
3207
3222
|
}
|
|
3208
3223
|
fourSetsOnePair() {
|
|
3209
3224
|
let t = [];
|
|
3210
|
-
for (const [e, s] of
|
|
3225
|
+
for (const [e, s] of L())
|
|
3211
3226
|
if (this.hand.get(e, s) >= 2) {
|
|
3212
3227
|
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 P(r[0], r[1])), o));
|
|
3213
3228
|
t = [...t, ...i], this.hand.inc(r);
|
|
@@ -3238,7 +3253,7 @@ class wi {
|
|
|
3238
3253
|
}
|
|
3239
3254
|
handleZ() {
|
|
3240
3255
|
const t = [];
|
|
3241
|
-
for (const [e, s] of
|
|
3256
|
+
for (const [e, s] of L({ filterBy: [p.Z] })) {
|
|
3242
3257
|
if (this.hand.get(e, s) == 0) continue;
|
|
3243
3258
|
if (this.hand.get(e, s) != 3) return [];
|
|
3244
3259
|
const r = new w(e, s);
|
|
@@ -3276,7 +3291,7 @@ const Bt = [1, 2, 3, 4, 5, 6, 7], V = [1, 9], Ft = (n) => {
|
|
|
3276
3291
|
const t = n.boardContext;
|
|
3277
3292
|
return {
|
|
3278
3293
|
...n,
|
|
3279
|
-
hand: n.hand.map(
|
|
3294
|
+
hand: n.hand.map(T.deserialize),
|
|
3280
3295
|
boardContext: {
|
|
3281
3296
|
...t,
|
|
3282
3297
|
doraMarkers: t.doraMarkers.map(w.from),
|
|
@@ -3284,14 +3299,14 @@ const Bt = [1, 2, 3, 4, 5, 6, 7], V = [1, 9], Ft = (n) => {
|
|
|
3284
3299
|
}
|
|
3285
3300
|
};
|
|
3286
3301
|
};
|
|
3287
|
-
class
|
|
3302
|
+
class un {
|
|
3288
3303
|
constructor(t, e) {
|
|
3289
3304
|
_(this, "hand");
|
|
3290
3305
|
_(this, "cfg");
|
|
3291
3306
|
this.hand = t, this.cfg = {
|
|
3292
|
-
doras: e.doraMarkers.map((s) =>
|
|
3307
|
+
doras: e.doraMarkers.map((s) => dn(s)),
|
|
3293
3308
|
// convert to dora
|
|
3294
|
-
blindDoras: e.blindDoraMarkers == null ? [] : e.blindDoraMarkers.map((s) =>
|
|
3309
|
+
blindDoras: e.blindDoraMarkers == null ? [] : e.blindDoraMarkers.map((s) => dn(s)),
|
|
3295
3310
|
roundWind: w.from(e.round.substring(0, 2)),
|
|
3296
3311
|
myWind: w.from(e.myWind),
|
|
3297
3312
|
reached: e.reached ?? 0,
|
|
@@ -3453,7 +3468,7 @@ class ln {
|
|
|
3453
3468
|
) ? [] : [{ name: "断么九", double: 1 }];
|
|
3454
3469
|
}
|
|
3455
3470
|
dE1(t) {
|
|
3456
|
-
return this.minus() != 0 ? [] :
|
|
3471
|
+
return this.minus() != 0 ? [] : hn(t) == 1 ? [{ name: "一盃口", double: 1 }] : [];
|
|
3457
3472
|
}
|
|
3458
3473
|
dF1(t) {
|
|
3459
3474
|
const e = [];
|
|
@@ -3512,7 +3527,7 @@ class ln {
|
|
|
3512
3527
|
}
|
|
3513
3528
|
dC2(t) {
|
|
3514
3529
|
return t.length == 7 ? [] : t.every(
|
|
3515
|
-
(s) => s instanceof M || s instanceof K || s instanceof
|
|
3530
|
+
(s) => s instanceof M || s instanceof K || s instanceof q || s instanceof Z || s instanceof X || s instanceof P
|
|
3516
3531
|
) ? [{ name: "対々和", double: 2 }] : [];
|
|
3517
3532
|
}
|
|
3518
3533
|
dD2(t) {
|
|
@@ -3520,11 +3535,11 @@ class ln {
|
|
|
3520
3535
|
}
|
|
3521
3536
|
dE2(t) {
|
|
3522
3537
|
return t.filter(
|
|
3523
|
-
(s) => s instanceof M || s instanceof K || s instanceof
|
|
3538
|
+
(s) => s instanceof M || s instanceof K || s instanceof q
|
|
3524
3539
|
).length >= 3 ? [{ name: "三槓子", double: 2 }] : [];
|
|
3525
3540
|
}
|
|
3526
3541
|
dF2(t) {
|
|
3527
|
-
const e = (s) => s instanceof M || s instanceof K || s instanceof
|
|
3542
|
+
const e = (s) => s instanceof M || s instanceof K || s instanceof q || s instanceof Z || s instanceof X;
|
|
3528
3543
|
for (const s of t) {
|
|
3529
3544
|
if (!e(s)) continue;
|
|
3530
3545
|
const r = rt(s);
|
|
@@ -3585,7 +3600,7 @@ class ln {
|
|
|
3585
3600
|
return t.length == 7 ? [] : t.some((s) => s instanceof lt || 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() }] : [] : [];
|
|
3586
3601
|
}
|
|
3587
3602
|
dC3(t) {
|
|
3588
|
-
return this.minus() != 0 ? [] :
|
|
3603
|
+
return this.minus() != 0 ? [] : hn(t) == 2 ? [{ name: "ニ盃口", double: 3 }] : [];
|
|
3589
3604
|
}
|
|
3590
3605
|
dA6(t) {
|
|
3591
3606
|
if (t.some((e) => e.tiles[0].t == p.Z)) return [];
|
|
@@ -3627,7 +3642,7 @@ class ln {
|
|
|
3627
3642
|
}
|
|
3628
3643
|
dG13(t) {
|
|
3629
3644
|
return t.filter(
|
|
3630
|
-
(s) => s instanceof M || s instanceof K || s instanceof
|
|
3645
|
+
(s) => s instanceof M || s instanceof K || s instanceof q
|
|
3631
3646
|
).length == 4 ? [{ name: "四槓子", double: 13 }] : [];
|
|
3632
3647
|
}
|
|
3633
3648
|
dH13(t) {
|
|
@@ -3663,10 +3678,10 @@ class ln {
|
|
|
3663
3678
|
const m = f.tiles.some((E) => E.has(y.RON)) ? 2 : 4;
|
|
3664
3679
|
s += l(f, m);
|
|
3665
3680
|
break;
|
|
3666
|
-
case f instanceof
|
|
3681
|
+
case f instanceof X:
|
|
3667
3682
|
s += l(f, 2);
|
|
3668
3683
|
break;
|
|
3669
|
-
case (f instanceof
|
|
3684
|
+
case (f instanceof q || f instanceof K):
|
|
3670
3685
|
s += l(f, 8);
|
|
3671
3686
|
break;
|
|
3672
3687
|
case f instanceof M:
|
|
@@ -3685,18 +3700,18 @@ class ln {
|
|
|
3685
3700
|
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;
|
|
3686
3701
|
}
|
|
3687
3702
|
}
|
|
3688
|
-
const
|
|
3703
|
+
const Ln = (n) => n.tiles.reduce((t, e) => `${t}${e.n}${e.t}`, ""), hn = (n) => {
|
|
3689
3704
|
const t = {};
|
|
3690
3705
|
for (const s of n) {
|
|
3691
3706
|
if (!(s instanceof lt)) continue;
|
|
3692
|
-
const r =
|
|
3707
|
+
const r = Ln(s);
|
|
3693
3708
|
t[r] == null ? t[r] = 1 : t[r]++;
|
|
3694
3709
|
}
|
|
3695
3710
|
let e = 0;
|
|
3696
3711
|
for (const s in t)
|
|
3697
3712
|
t[s] >= 2 && e++;
|
|
3698
3713
|
return e;
|
|
3699
|
-
}, rt = (n) => [...n.tiles].sort(ae)[0],
|
|
3714
|
+
}, rt = (n) => [...n.tiles].sort(ae)[0], dn = (n) => {
|
|
3700
3715
|
const t = n.n, e = n.t;
|
|
3701
3716
|
return new w(e, t % 9 + 1);
|
|
3702
3717
|
};
|
|
@@ -3727,7 +3742,7 @@ class Kt {
|
|
|
3727
3742
|
static candidateTiles(t, e) {
|
|
3728
3743
|
let s = 1 / 0, r = [];
|
|
3729
3744
|
const i = new le(t);
|
|
3730
|
-
for (const [o, a] of
|
|
3745
|
+
for (const [o, a] of L({
|
|
3731
3746
|
skipBack: !0,
|
|
3732
3747
|
filterBy: e == null ? void 0 : e.typeFilter
|
|
3733
3748
|
})) {
|
|
@@ -3858,7 +3873,7 @@ class ne {
|
|
|
3858
3873
|
}
|
|
3859
3874
|
update() {
|
|
3860
3875
|
for (let t in this.pToW) {
|
|
3861
|
-
const e =
|
|
3876
|
+
const e = Pe(this.pToW[t]);
|
|
3862
3877
|
this.pToW[t] = e, this.wToP[e] = t;
|
|
3863
3878
|
}
|
|
3864
3879
|
}
|
|
@@ -3990,7 +4005,7 @@ const Ii = (n) => {
|
|
|
3990
4005
|
const t = Ti();
|
|
3991
4006
|
t && t.register(n);
|
|
3992
4007
|
};
|
|
3993
|
-
class
|
|
4008
|
+
class fn {
|
|
3994
4009
|
constructor(t) {
|
|
3995
4010
|
this._process = t, this._active = !1, this._current = null, this._last = null;
|
|
3996
4011
|
}
|
|
@@ -4058,10 +4073,10 @@ function G(n) {
|
|
|
4058
4073
|
}
|
|
4059
4074
|
const $i = typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
4060
4075
|
function qn(n, t) {
|
|
4061
|
-
const e =
|
|
4076
|
+
const e = pn(n), s = pn(t);
|
|
4062
4077
|
return typeof s == "string" ? typeof e == "string" ? s === e : !1 : typeof e == "string" ? e in s : Object.keys(e).every((r) => r in s ? qn(e[r], s[r]) : !1);
|
|
4063
4078
|
}
|
|
4064
|
-
function
|
|
4079
|
+
function ze(n) {
|
|
4065
4080
|
if (Qn(n))
|
|
4066
4081
|
return n;
|
|
4067
4082
|
const t = [];
|
|
@@ -4081,12 +4096,12 @@ function Ke(n) {
|
|
|
4081
4096
|
}
|
|
4082
4097
|
return t.push(e), t;
|
|
4083
4098
|
}
|
|
4084
|
-
function
|
|
4099
|
+
function pn(n) {
|
|
4085
4100
|
if (go(n))
|
|
4086
4101
|
return n.value;
|
|
4087
4102
|
if (typeof n != "string")
|
|
4088
4103
|
return n;
|
|
4089
|
-
const t =
|
|
4104
|
+
const t = ze(n);
|
|
4090
4105
|
return Hi(t);
|
|
4091
4106
|
}
|
|
4092
4107
|
function Hi(n) {
|
|
@@ -4103,7 +4118,7 @@ function Hi(n) {
|
|
|
4103
4118
|
}
|
|
4104
4119
|
return t;
|
|
4105
4120
|
}
|
|
4106
|
-
function
|
|
4121
|
+
function gn(n, t) {
|
|
4107
4122
|
const e = {}, s = Object.keys(n);
|
|
4108
4123
|
for (let r = 0; r < s.length; r++) {
|
|
4109
4124
|
const i = s[r];
|
|
@@ -4114,7 +4129,7 @@ function pn(n, t) {
|
|
|
4114
4129
|
function Yn(n) {
|
|
4115
4130
|
return Qn(n) ? n : [n];
|
|
4116
4131
|
}
|
|
4117
|
-
function
|
|
4132
|
+
function Y(n) {
|
|
4118
4133
|
return n === void 0 ? [] : Yn(n);
|
|
4119
4134
|
}
|
|
4120
4135
|
function ke(n, t, e, s) {
|
|
@@ -4130,14 +4145,14 @@ function Qn(n) {
|
|
|
4130
4145
|
function Pi(n) {
|
|
4131
4146
|
return n.type.startsWith("xstate.error.actor");
|
|
4132
4147
|
}
|
|
4133
|
-
function
|
|
4148
|
+
function _t(n) {
|
|
4134
4149
|
return Yn(n).map((t) => typeof t > "u" || typeof t == "string" ? {
|
|
4135
4150
|
target: t
|
|
4136
4151
|
} : t);
|
|
4137
4152
|
}
|
|
4138
4153
|
function ts(n) {
|
|
4139
4154
|
if (!(n === void 0 || n === Oi))
|
|
4140
|
-
return
|
|
4155
|
+
return Y(n);
|
|
4141
4156
|
}
|
|
4142
4157
|
function Ce(n, t, e) {
|
|
4143
4158
|
var i, o, a;
|
|
@@ -4148,7 +4163,7 @@ function Ce(n, t, e) {
|
|
|
4148
4163
|
complete: (a = s ? n.complete : e) == null ? void 0 : a.bind(r)
|
|
4149
4164
|
};
|
|
4150
4165
|
}
|
|
4151
|
-
function
|
|
4166
|
+
function yn(n, t) {
|
|
4152
4167
|
return `${t}.${n}`;
|
|
4153
4168
|
}
|
|
4154
4169
|
function Le(n, t) {
|
|
@@ -4158,7 +4173,7 @@ function Le(n, t) {
|
|
|
4158
4173
|
const [, s, r] = e, o = n.getStateNodeById(r).config.invoke;
|
|
4159
4174
|
return (Array.isArray(o) ? o[s] : o).src;
|
|
4160
4175
|
}
|
|
4161
|
-
function
|
|
4176
|
+
function mn(n, t) {
|
|
4162
4177
|
return `${n.sessionId}.${t}`;
|
|
4163
4178
|
}
|
|
4164
4179
|
let Wi = 0;
|
|
@@ -4175,7 +4190,7 @@ function Di(n, t) {
|
|
|
4175
4190
|
delay: m,
|
|
4176
4191
|
id: E,
|
|
4177
4192
|
startedAt: Date.now()
|
|
4178
|
-
}, O =
|
|
4193
|
+
}, O = mn(d, E);
|
|
4179
4194
|
h._snapshot._scheduledEvents[O] = N;
|
|
4180
4195
|
const x = a.setTimeout(() => {
|
|
4181
4196
|
delete o[O], delete h._snapshot._scheduledEvents[O], h._relay(d, g, f);
|
|
@@ -4183,7 +4198,7 @@ function Di(n, t) {
|
|
|
4183
4198
|
o[O] = x;
|
|
4184
4199
|
},
|
|
4185
4200
|
cancel: (d, g) => {
|
|
4186
|
-
const f =
|
|
4201
|
+
const f = mn(d, g), m = o[f];
|
|
4187
4202
|
delete o[f], delete h._snapshot._scheduledEvents[f], m !== void 0 && a.clearTimeout(m);
|
|
4188
4203
|
},
|
|
4189
4204
|
cancelAll: (d) => {
|
|
@@ -4264,7 +4279,7 @@ function Di(n, t) {
|
|
|
4264
4279
|
return h;
|
|
4265
4280
|
}
|
|
4266
4281
|
let me = !1;
|
|
4267
|
-
const
|
|
4282
|
+
const je = 1;
|
|
4268
4283
|
let $ = /* @__PURE__ */ function(n) {
|
|
4269
4284
|
return n[n.NotStarted = 0] = "NotStarted", n[n.Running = 1] = "Running", n[n.Stopped = 2] = "Stopped", n;
|
|
4270
4285
|
}({});
|
|
@@ -4285,7 +4300,7 @@ class Ki {
|
|
|
4285
4300
|
* @param options Actor options
|
|
4286
4301
|
*/
|
|
4287
4302
|
constructor(t, e) {
|
|
4288
|
-
this.logic = t, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new
|
|
4303
|
+
this.logic = t, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new fn(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 = [];
|
|
4289
4304
|
const s = {
|
|
4290
4305
|
...Bi,
|
|
4291
4306
|
...e
|
|
@@ -4612,7 +4627,7 @@ class Ki {
|
|
|
4612
4627
|
// right now, they are being stopped within the machine's transition
|
|
4613
4628
|
// but that could throw and leave us with "orphaned" active actors
|
|
4614
4629
|
_stopProcedure() {
|
|
4615
|
-
return this._processingStatus !== $.Running ? this : (this.system.scheduler.cancelAll(this), this.mailbox.clear(), this.mailbox = new
|
|
4630
|
+
return this._processingStatus !== $.Running ? this : (this.system.scheduler.cancelAll(this), this.mailbox.clear(), this.mailbox = new fn(this._process.bind(this)), this._processingStatus = $.Stopped, this.system._unregister(this), this);
|
|
4616
4631
|
}
|
|
4617
4632
|
/** @internal */
|
|
4618
4633
|
_send(t) {
|
|
@@ -4634,7 +4649,7 @@ class Ki {
|
|
|
4634
4649
|
}
|
|
4635
4650
|
toJSON() {
|
|
4636
4651
|
return {
|
|
4637
|
-
xstate$$type:
|
|
4652
|
+
xstate$$type: je,
|
|
4638
4653
|
id: this.id
|
|
4639
4654
|
};
|
|
4640
4655
|
}
|
|
@@ -4678,7 +4693,7 @@ class Ki {
|
|
|
4678
4693
|
function Ot(n, ...[t]) {
|
|
4679
4694
|
return new Ki(n, t);
|
|
4680
4695
|
}
|
|
4681
|
-
function
|
|
4696
|
+
function zi(n, t, e, s, {
|
|
4682
4697
|
sendId: r
|
|
4683
4698
|
}) {
|
|
4684
4699
|
const i = typeof r == "function" ? r(e, s) : r;
|
|
@@ -4686,7 +4701,7 @@ function Li(n, t, e, s, {
|
|
|
4686
4701
|
sendId: i
|
|
4687
4702
|
}, void 0];
|
|
4688
4703
|
}
|
|
4689
|
-
function
|
|
4704
|
+
function Li(n, t) {
|
|
4690
4705
|
n.defer(() => {
|
|
4691
4706
|
n.system.scheduler.cancel(n.self, t.sendId);
|
|
4692
4707
|
});
|
|
@@ -4694,7 +4709,7 @@ function zi(n, t) {
|
|
|
4694
4709
|
function ji(n) {
|
|
4695
4710
|
function t(e, s) {
|
|
4696
4711
|
}
|
|
4697
|
-
return t.type = "xstate.cancel", t.sendId = n, t.resolve =
|
|
4712
|
+
return t.type = "xstate.cancel", t.sendId = n, t.resolve = zi, t.execute = Li, t;
|
|
4698
4713
|
}
|
|
4699
4714
|
function Fi(n, t, e, s, {
|
|
4700
4715
|
id: r,
|
|
@@ -4716,7 +4731,7 @@ function Fi(n, t, e, s, {
|
|
|
4716
4731
|
syncSnapshot: c,
|
|
4717
4732
|
systemId: i,
|
|
4718
4733
|
input: d
|
|
4719
|
-
})), [
|
|
4734
|
+
})), [ft(t, {
|
|
4720
4735
|
children: {
|
|
4721
4736
|
...t.children,
|
|
4722
4737
|
[u]: h
|
|
@@ -4753,7 +4768,7 @@ function Gi(n, t, e, s, {
|
|
|
4753
4768
|
let a = t.children;
|
|
4754
4769
|
return o && (a = {
|
|
4755
4770
|
...a
|
|
4756
|
-
}, delete a[o.id]), [
|
|
4771
|
+
}, delete a[o.id]), [ft(t, {
|
|
4757
4772
|
children: a
|
|
4758
4773
|
}), o, void 0];
|
|
4759
4774
|
}
|
|
@@ -4773,14 +4788,14 @@ function es(n) {
|
|
|
4773
4788
|
}
|
|
4774
4789
|
return t.type = "xstate.stopChild", t.actorRef = n, t.resolve = Gi, t.execute = Vi, t;
|
|
4775
4790
|
}
|
|
4776
|
-
function
|
|
4791
|
+
function Fe(n, t, e, s) {
|
|
4777
4792
|
const {
|
|
4778
4793
|
machine: r
|
|
4779
4794
|
} = s, i = typeof n == "function", o = i ? n : r.implementations.guards[typeof n == "string" ? n : n.type];
|
|
4780
4795
|
if (!i && !o)
|
|
4781
4796
|
throw new Error(`Guard '${typeof n == "string" ? n : n.type}' is not implemented.'.`);
|
|
4782
4797
|
if (typeof o != "function")
|
|
4783
|
-
return
|
|
4798
|
+
return Fe(o, t, e, s);
|
|
4784
4799
|
const a = {
|
|
4785
4800
|
context: t,
|
|
4786
4801
|
event: e
|
|
@@ -4795,11 +4810,11 @@ function je(n, t, e, s) {
|
|
|
4795
4810
|
// this holds all params
|
|
4796
4811
|
) : o(a, c);
|
|
4797
4812
|
}
|
|
4798
|
-
const
|
|
4813
|
+
const Ze = (n) => n.type === "atomic" || n.type === "final";
|
|
4799
4814
|
function kt(n) {
|
|
4800
4815
|
return Object.values(n.states).filter((t) => t.type !== "history");
|
|
4801
4816
|
}
|
|
4802
|
-
function
|
|
4817
|
+
function zt(n, t) {
|
|
4803
4818
|
const e = [];
|
|
4804
4819
|
if (t === n)
|
|
4805
4820
|
return e;
|
|
@@ -4812,11 +4827,11 @@ function se(n) {
|
|
|
4812
4827
|
const t = new Set(n), e = ss(t);
|
|
4813
4828
|
for (const s of t)
|
|
4814
4829
|
if (s.type === "compound" && (!e.get(s) || !e.get(s).length))
|
|
4815
|
-
|
|
4830
|
+
wn(s).forEach((r) => t.add(r));
|
|
4816
4831
|
else if (s.type === "parallel") {
|
|
4817
4832
|
for (const r of kt(s))
|
|
4818
4833
|
if (r.type !== "history" && !t.has(r)) {
|
|
4819
|
-
const i =
|
|
4834
|
+
const i = wn(r);
|
|
4820
4835
|
for (const o of i)
|
|
4821
4836
|
t.add(o);
|
|
4822
4837
|
}
|
|
@@ -4835,7 +4850,7 @@ function ns(n, t) {
|
|
|
4835
4850
|
if (n.type === "compound") {
|
|
4836
4851
|
const r = e[0];
|
|
4837
4852
|
if (r) {
|
|
4838
|
-
if (
|
|
4853
|
+
if (Ze(r))
|
|
4839
4854
|
return r.key;
|
|
4840
4855
|
} else
|
|
4841
4856
|
return {};
|
|
@@ -4855,8 +4870,8 @@ function rs(n, t) {
|
|
|
4855
4870
|
const e = se(t);
|
|
4856
4871
|
return ns(n, ss(e));
|
|
4857
4872
|
}
|
|
4858
|
-
function
|
|
4859
|
-
return t.type === "compound" ? kt(t).some((e) => e.type === "final" && n.has(e)) : t.type === "parallel" ? kt(t).every((e) =>
|
|
4873
|
+
function Ue(n, t) {
|
|
4874
|
+
return t.type === "compound" ? kt(t).some((e) => e.type === "final" && n.has(e)) : t.type === "parallel" ? kt(t).every((e) => Ue(n, e)) : t.type === "final";
|
|
4860
4875
|
}
|
|
4861
4876
|
const ue = (n) => n[0] === ki;
|
|
4862
4877
|
function Ji(n, t) {
|
|
@@ -4891,7 +4906,7 @@ function Xi(n) {
|
|
|
4891
4906
|
const i = t[r], o = typeof i == "string" ? {
|
|
4892
4907
|
target: i
|
|
4893
4908
|
} : i, a = Number.isNaN(+r) ? r : +r, c = e(a);
|
|
4894
|
-
return
|
|
4909
|
+
return Y(o).map((l) => ({
|
|
4895
4910
|
...l,
|
|
4896
4911
|
event: c,
|
|
4897
4912
|
delay: a
|
|
@@ -4909,7 +4924,7 @@ function Xi(n) {
|
|
|
4909
4924
|
function at(n, t, e) {
|
|
4910
4925
|
const s = ts(e.target), r = e.reenter ?? !1, i = Qi(n, s), o = {
|
|
4911
4926
|
...e,
|
|
4912
|
-
actions:
|
|
4927
|
+
actions: Y(e.actions),
|
|
4913
4928
|
guard: e.guard,
|
|
4914
4929
|
target: i,
|
|
4915
4930
|
source: n,
|
|
@@ -4930,24 +4945,24 @@ function qi(n) {
|
|
|
4930
4945
|
if (e === Vn)
|
|
4931
4946
|
throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');
|
|
4932
4947
|
const s = n.config.on[e];
|
|
4933
|
-
t.set(e,
|
|
4948
|
+
t.set(e, _t(s).map((r) => at(n, e, r)));
|
|
4934
4949
|
}
|
|
4935
4950
|
if (n.config.onDone) {
|
|
4936
4951
|
const e = `xstate.done.state.${n.id}`;
|
|
4937
|
-
t.set(e,
|
|
4952
|
+
t.set(e, _t(n.config.onDone).map((s) => at(n, e, s)));
|
|
4938
4953
|
}
|
|
4939
4954
|
for (const e of n.invoke) {
|
|
4940
4955
|
if (e.onDone) {
|
|
4941
4956
|
const s = `xstate.done.actor.${e.id}`;
|
|
4942
|
-
t.set(s,
|
|
4957
|
+
t.set(s, _t(e.onDone).map((r) => at(n, s, r)));
|
|
4943
4958
|
}
|
|
4944
4959
|
if (e.onError) {
|
|
4945
4960
|
const s = `xstate.error.actor.${e.id}`;
|
|
4946
|
-
t.set(s,
|
|
4961
|
+
t.set(s, _t(e.onError).map((r) => at(n, s, r)));
|
|
4947
4962
|
}
|
|
4948
4963
|
if (e.onSnapshot) {
|
|
4949
4964
|
const s = `xstate.snapshot.${e.id}`;
|
|
4950
|
-
t.set(s,
|
|
4965
|
+
t.set(s, _t(e.onSnapshot).map((r) => at(n, s, r)));
|
|
4951
4966
|
}
|
|
4952
4967
|
}
|
|
4953
4968
|
for (const e of n.after) {
|
|
@@ -4965,7 +4980,7 @@ function Yi(n, t) {
|
|
|
4965
4980
|
);
|
|
4966
4981
|
const s = {
|
|
4967
4982
|
source: n,
|
|
4968
|
-
actions: !t || typeof t == "string" ? [] :
|
|
4983
|
+
actions: !t || typeof t == "string" ? [] : Y(t.actions),
|
|
4969
4984
|
eventType: null,
|
|
4970
4985
|
reenter: !1,
|
|
4971
4986
|
target: e ? [e] : [],
|
|
@@ -5008,10 +5023,10 @@ function is(n) {
|
|
|
5008
5023
|
function ht(n) {
|
|
5009
5024
|
return n.type === "history";
|
|
5010
5025
|
}
|
|
5011
|
-
function
|
|
5026
|
+
function wn(n) {
|
|
5012
5027
|
const t = os(n);
|
|
5013
5028
|
for (const e of t)
|
|
5014
|
-
for (const s of
|
|
5029
|
+
for (const s of zt(e, n))
|
|
5015
5030
|
t.add(s);
|
|
5016
5031
|
return t;
|
|
5017
5032
|
}
|
|
@@ -5044,7 +5059,7 @@ function re(n, t) {
|
|
|
5044
5059
|
return n.machine.getStateNodeById(t);
|
|
5045
5060
|
} catch {
|
|
5046
5061
|
}
|
|
5047
|
-
const e =
|
|
5062
|
+
const e = ze(t).slice();
|
|
5048
5063
|
let s = n;
|
|
5049
5064
|
for (; e.length; ) {
|
|
5050
5065
|
const r = e.shift();
|
|
@@ -5075,7 +5090,7 @@ function to(n, t, e, s) {
|
|
|
5075
5090
|
return !i || !i.length ? n.next(e, s) : i;
|
|
5076
5091
|
}
|
|
5077
5092
|
function eo(n, t, e, s) {
|
|
5078
|
-
const r = Object.keys(t), i = Ct(n, r[0]), o =
|
|
5093
|
+
const r = Object.keys(t), i = Ct(n, r[0]), o = Ge(i, t[r[0]], e, s);
|
|
5079
5094
|
return !o || !o.length ? n.next(e, s) : o;
|
|
5080
5095
|
}
|
|
5081
5096
|
function no(n, t, e, s) {
|
|
@@ -5084,12 +5099,12 @@ function no(n, t, e, s) {
|
|
|
5084
5099
|
const o = t[i];
|
|
5085
5100
|
if (!o)
|
|
5086
5101
|
continue;
|
|
5087
|
-
const a = Ct(n, i), c =
|
|
5102
|
+
const a = Ct(n, i), c = Ge(a, o, e, s);
|
|
5088
5103
|
c && r.push(...c);
|
|
5089
5104
|
}
|
|
5090
5105
|
return r.length ? r : n.next(e, s);
|
|
5091
5106
|
}
|
|
5092
|
-
function
|
|
5107
|
+
function Ge(n, t, e, s) {
|
|
5093
5108
|
return typeof t == "string" ? to(n, t, e, s) : Object.keys(t).length === 1 ? eo(n, t, e, s) : no(n, t, e, s);
|
|
5094
5109
|
}
|
|
5095
5110
|
function so(n) {
|
|
@@ -5134,11 +5149,11 @@ function as(n, t, e) {
|
|
|
5134
5149
|
}
|
|
5135
5150
|
function io(n) {
|
|
5136
5151
|
const [t, ...e] = n;
|
|
5137
|
-
for (const s of
|
|
5152
|
+
for (const s of zt(t, void 0))
|
|
5138
5153
|
if (e.every((r) => tt(r, s)))
|
|
5139
5154
|
return s;
|
|
5140
5155
|
}
|
|
5141
|
-
function
|
|
5156
|
+
function Ve(n, t) {
|
|
5142
5157
|
if (!n.target)
|
|
5143
5158
|
return [];
|
|
5144
5159
|
const e = /* @__PURE__ */ new Set();
|
|
@@ -5148,14 +5163,14 @@ function Ge(n, t) {
|
|
|
5148
5163
|
for (const r of t[s.id])
|
|
5149
5164
|
e.add(r);
|
|
5150
5165
|
else
|
|
5151
|
-
for (const r of
|
|
5166
|
+
for (const r of Ve(is(s), t))
|
|
5152
5167
|
e.add(r);
|
|
5153
5168
|
else
|
|
5154
5169
|
e.add(s);
|
|
5155
5170
|
return [...e];
|
|
5156
5171
|
}
|
|
5157
5172
|
function cs(n, t) {
|
|
5158
|
-
const e =
|
|
5173
|
+
const e = Ve(n, t);
|
|
5159
5174
|
if (!e)
|
|
5160
5175
|
return;
|
|
5161
5176
|
if (!n.reenter && e.every((r) => r === n.source || tt(r, n.source)))
|
|
@@ -5197,7 +5212,7 @@ function Re(n, t, e, s, r, i) {
|
|
|
5197
5212
|
const u = [...o];
|
|
5198
5213
|
l.status === "done" && (l = xt(l, s, e, u.sort((h, d) => d.order - h.order).flatMap((h) => h.exit), i, void 0));
|
|
5199
5214
|
try {
|
|
5200
|
-
return a === t.historyValue && oo(t._nodes, o) ? l :
|
|
5215
|
+
return a === t.historyValue && oo(t._nodes, o) ? l : ft(l, {
|
|
5201
5216
|
_nodes: u,
|
|
5202
5217
|
historyValue: a
|
|
5203
5218
|
});
|
|
@@ -5232,11 +5247,11 @@ function co(n, t, e, s, r, i, o, a) {
|
|
|
5232
5247
|
if (c = xt(c, t, e, g, i, d.invoke.map((f) => f.id)), d.type === "final") {
|
|
5233
5248
|
const f = d.parent;
|
|
5234
5249
|
let m = (f == null ? void 0 : f.type) === "parallel" ? f : f == null ? void 0 : f.parent, E = m || d;
|
|
5235
|
-
for ((f == null ? void 0 : f.type) === "compound" && i.push(Oe(f.id, d.output !== void 0 ? ke(d.output, c.context, t, e.self) : void 0)); (m == null ? void 0 : m.type) === "parallel" && !h.has(m) &&
|
|
5250
|
+
for ((f == null ? void 0 : f.type) === "compound" && i.push(Oe(f.id, d.output !== void 0 ? ke(d.output, c.context, t, e.self) : void 0)); (m == null ? void 0 : m.type) === "parallel" && !h.has(m) && Ue(r, m); )
|
|
5236
5251
|
h.add(m), i.push(Oe(m.id)), E = m, m = m.parent;
|
|
5237
5252
|
if (m)
|
|
5238
5253
|
continue;
|
|
5239
|
-
c =
|
|
5254
|
+
c = ft(c, {
|
|
5240
5255
|
status: "done",
|
|
5241
5256
|
output: ao(c, t, e, c.machine.root, E)
|
|
5242
5257
|
});
|
|
@@ -5252,45 +5267,45 @@ function lo(n, t, e, s) {
|
|
|
5252
5267
|
(r.source !== a || // we know that the domain can't lie within the source
|
|
5253
5268
|
// 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
|
|
5254
5269
|
r.source !== i || // reentering transitions always enter the target, even if it's the source itself
|
|
5255
|
-
r.reenter) && (s.add(a), e.add(a)),
|
|
5256
|
-
const o =
|
|
5270
|
+
r.reenter) && (s.add(a), e.add(a)), At(a, t, e, s);
|
|
5271
|
+
const o = Ve(r, t);
|
|
5257
5272
|
for (const a of o) {
|
|
5258
|
-
const c =
|
|
5273
|
+
const c = zt(a, i);
|
|
5259
5274
|
(i == null ? void 0 : i.type) === "parallel" && c.push(i), ls(s, t, e, c, !r.source.parent && r.reenter ? void 0 : i);
|
|
5260
5275
|
}
|
|
5261
5276
|
}
|
|
5262
5277
|
}
|
|
5263
|
-
function
|
|
5278
|
+
function At(n, t, e, s) {
|
|
5264
5279
|
var r;
|
|
5265
5280
|
if (ht(n))
|
|
5266
5281
|
if (t[n.id]) {
|
|
5267
5282
|
const i = t[n.id];
|
|
5268
5283
|
for (const o of i)
|
|
5269
|
-
s.add(o),
|
|
5284
|
+
s.add(o), At(o, t, e, s);
|
|
5270
5285
|
for (const o of i)
|
|
5271
5286
|
we(o, n.parent, s, t, e);
|
|
5272
5287
|
} else {
|
|
5273
5288
|
const i = is(n);
|
|
5274
5289
|
for (const o of i.target)
|
|
5275
|
-
s.add(o), i === ((r = n.parent) == null ? void 0 : r.initial) && e.add(n.parent),
|
|
5290
|
+
s.add(o), i === ((r = n.parent) == null ? void 0 : r.initial) && e.add(n.parent), At(o, t, e, s);
|
|
5276
5291
|
for (const o of i.target)
|
|
5277
5292
|
we(o, n.parent, s, t, e);
|
|
5278
5293
|
}
|
|
5279
5294
|
else if (n.type === "compound") {
|
|
5280
5295
|
const [i] = n.initial.target;
|
|
5281
|
-
ht(i) || (s.add(i), e.add(i)),
|
|
5296
|
+
ht(i) || (s.add(i), e.add(i)), At(i, t, e, s), we(i, n, s, t, e);
|
|
5282
5297
|
} else if (n.type === "parallel")
|
|
5283
5298
|
for (const i of kt(n).filter((o) => !ht(o)))
|
|
5284
|
-
[...s].some((o) => tt(o, i)) || (ht(i) || (s.add(i), e.add(i)),
|
|
5299
|
+
[...s].some((o) => tt(o, i)) || (ht(i) || (s.add(i), e.add(i)), At(i, t, e, s));
|
|
5285
5300
|
}
|
|
5286
5301
|
function ls(n, t, e, s, r) {
|
|
5287
5302
|
for (const i of s)
|
|
5288
5303
|
if ((!r || tt(i, r)) && n.add(i), i.type === "parallel")
|
|
5289
5304
|
for (const o of kt(i).filter((a) => !ht(a)))
|
|
5290
|
-
[...n].some((a) => tt(a, o)) || (n.add(o),
|
|
5305
|
+
[...n].some((a) => tt(a, o)) || (n.add(o), At(o, t, e, n));
|
|
5291
5306
|
}
|
|
5292
5307
|
function we(n, t, e, s, r) {
|
|
5293
|
-
ls(e, s, r,
|
|
5308
|
+
ls(e, s, r, zt(n, t));
|
|
5294
5309
|
}
|
|
5295
5310
|
function uo(n, t, e, s, r, i, o, a) {
|
|
5296
5311
|
let c = n;
|
|
@@ -5300,7 +5315,7 @@ function uo(n, t, e, s, r, i, o, a) {
|
|
|
5300
5315
|
for (const h of l)
|
|
5301
5316
|
for (const d of so(h)) {
|
|
5302
5317
|
let g;
|
|
5303
|
-
d.history === "deep" ? g = (f) =>
|
|
5318
|
+
d.history === "deep" ? g = (f) => Ze(f) && tt(f, h) : g = (f) => f.parent === h, u ?? (u = {
|
|
5304
5319
|
...i
|
|
5305
5320
|
}), u[d.id] = Array.from(r).filter(g);
|
|
5306
5321
|
}
|
|
@@ -5380,7 +5395,7 @@ function be(n, t, e, s) {
|
|
|
5380
5395
|
}), i.push(l);
|
|
5381
5396
|
}
|
|
5382
5397
|
if (t.type === Ie)
|
|
5383
|
-
return r =
|
|
5398
|
+
return r = ft(bn(r, t, e), {
|
|
5384
5399
|
status: "stopped"
|
|
5385
5400
|
}), o(r, t, []), {
|
|
5386
5401
|
snapshot: r,
|
|
@@ -5388,9 +5403,9 @@ function be(n, t, e, s) {
|
|
|
5388
5403
|
};
|
|
5389
5404
|
let a = t;
|
|
5390
5405
|
if (a.type !== Jn) {
|
|
5391
|
-
const l = a, u = Pi(l), h =
|
|
5406
|
+
const l = a, u = Pi(l), h = _n(l, r);
|
|
5392
5407
|
if (u && !h.length)
|
|
5393
|
-
return r =
|
|
5408
|
+
return r = ft(n, {
|
|
5394
5409
|
status: "error",
|
|
5395
5410
|
error: l.error
|
|
5396
5411
|
}), o(r, l, []), {
|
|
@@ -5414,28 +5429,28 @@ function be(n, t, e, s) {
|
|
|
5414
5429
|
if (!l.length) {
|
|
5415
5430
|
if (!s.length)
|
|
5416
5431
|
break;
|
|
5417
|
-
a = s.shift(), l =
|
|
5432
|
+
a = s.shift(), l = _n(a, r);
|
|
5418
5433
|
}
|
|
5419
5434
|
r = Re(l, r, e, a, !1, s), c = r !== u, o(r, a, l);
|
|
5420
5435
|
}
|
|
5421
|
-
return r.status !== "active" &&
|
|
5436
|
+
return r.status !== "active" && bn(r, a, e), {
|
|
5422
5437
|
snapshot: r,
|
|
5423
5438
|
microstates: i
|
|
5424
5439
|
};
|
|
5425
5440
|
}
|
|
5426
|
-
function
|
|
5441
|
+
function bn(n, t, e) {
|
|
5427
5442
|
return xt(n, t, e, Object.values(n.children).map((s) => es(s)), [], void 0);
|
|
5428
5443
|
}
|
|
5429
|
-
function
|
|
5444
|
+
function _n(n, t) {
|
|
5430
5445
|
return t.machine.getTransitionData(t, n);
|
|
5431
5446
|
}
|
|
5432
5447
|
function fo(n, t) {
|
|
5433
|
-
const e = /* @__PURE__ */ new Set(), s = n._nodes.filter(
|
|
5448
|
+
const e = /* @__PURE__ */ new Set(), s = n._nodes.filter(Ze);
|
|
5434
5449
|
for (const r of s)
|
|
5435
|
-
t: for (const i of [r].concat(
|
|
5450
|
+
t: for (const i of [r].concat(zt(r, void 0)))
|
|
5436
5451
|
if (i.always) {
|
|
5437
5452
|
for (const o of i.always)
|
|
5438
|
-
if (o.guard === void 0 ||
|
|
5453
|
+
if (o.guard === void 0 || Fe(o.guard, n.context, t, n)) {
|
|
5439
5454
|
e.add(o);
|
|
5440
5455
|
break t;
|
|
5441
5456
|
}
|
|
@@ -5495,7 +5510,7 @@ function Xt(n, t) {
|
|
|
5495
5510
|
toJSON: bo
|
|
5496
5511
|
};
|
|
5497
5512
|
}
|
|
5498
|
-
function
|
|
5513
|
+
function ft(n, t = {}) {
|
|
5499
5514
|
return Xt({
|
|
5500
5515
|
...n,
|
|
5501
5516
|
...t
|
|
@@ -5539,7 +5554,7 @@ function hs(n) {
|
|
|
5539
5554
|
t ?? (t = Array.isArray(n) ? n.slice() : {
|
|
5540
5555
|
...n
|
|
5541
5556
|
}), t[e] = {
|
|
5542
|
-
xstate$$type:
|
|
5557
|
+
xstate$$type: je,
|
|
5543
5558
|
id: s.id
|
|
5544
5559
|
};
|
|
5545
5560
|
else {
|
|
@@ -5656,7 +5671,7 @@ function To(n, t, e, s, {
|
|
|
5656
5671
|
a[l] = typeof u == "function" ? u(o, s) : u;
|
|
5657
5672
|
}
|
|
5658
5673
|
const c = Object.assign({}, t.context, a);
|
|
5659
|
-
return [
|
|
5674
|
+
return [ft(t, {
|
|
5660
5675
|
context: c,
|
|
5661
5676
|
children: Object.keys(i).length ? {
|
|
5662
5677
|
...t.children,
|
|
@@ -5669,12 +5684,12 @@ function Io(n) {
|
|
|
5669
5684
|
}
|
|
5670
5685
|
return t.type = "xstate.assign", t.assignment = n, t.resolve = To, t;
|
|
5671
5686
|
}
|
|
5672
|
-
const
|
|
5673
|
-
function
|
|
5674
|
-
let s =
|
|
5687
|
+
const An = /* @__PURE__ */ new WeakMap();
|
|
5688
|
+
function bt(n, t, e) {
|
|
5689
|
+
let s = An.get(n);
|
|
5675
5690
|
return s ? t in s || (s[t] = e()) : (s = {
|
|
5676
5691
|
[t]: e()
|
|
5677
|
-
},
|
|
5692
|
+
}, An.set(n, s)), s[t];
|
|
5678
5693
|
}
|
|
5679
5694
|
const Oo = {}, Ht = (n) => typeof n == "string" ? {
|
|
5680
5695
|
type: n
|
|
@@ -5683,19 +5698,19 @@ const Oo = {}, Ht = (n) => typeof n == "string" ? {
|
|
|
5683
5698
|
} : {
|
|
5684
5699
|
type: n.name
|
|
5685
5700
|
} : n;
|
|
5686
|
-
class
|
|
5701
|
+
class Je {
|
|
5687
5702
|
constructor(t, e) {
|
|
5688
|
-
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(Gn), 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 ?
|
|
5703
|
+
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(Gn), 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 ? gn(this.config.states, (s, r) => new Je(s, {
|
|
5689
5704
|
_parent: this,
|
|
5690
5705
|
_key: r,
|
|
5691
5706
|
_machine: this.machine
|
|
5692
5707
|
})) : Oo, this.type === "compound" && !this.config.initial)
|
|
5693
5708
|
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.`);
|
|
5694
|
-
this.history = this.config.history === !0 ? "shallow" : this.config.history || !1, this.entry =
|
|
5709
|
+
this.history = this.config.history === !0 ? "shallow" : this.config.history || !1, this.entry = Y(this.config.entry).slice(), this.exit = Y(this.config.exit).slice(), this.meta = this.config.meta, this.output = this.type === "final" || !this.parent ? this.config.output : void 0, this.tags = Y(t.tags).slice();
|
|
5695
5710
|
}
|
|
5696
5711
|
/** @internal */
|
|
5697
5712
|
_initialize() {
|
|
5698
|
-
this.transitions = qi(this), this.config.always && (this.always =
|
|
5713
|
+
this.transitions = qi(this), this.config.always && (this.always = _t(this.config.always).map((t) => at(this, Vn, t))), Object.keys(this.states).forEach((t) => {
|
|
5699
5714
|
this.states[t]._initialize();
|
|
5700
5715
|
});
|
|
5701
5716
|
}
|
|
@@ -5720,7 +5735,7 @@ class Ve {
|
|
|
5720
5735
|
})
|
|
5721
5736
|
} : void 0,
|
|
5722
5737
|
history: this.history,
|
|
5723
|
-
states:
|
|
5738
|
+
states: gn(this.states, (t) => t.definition),
|
|
5724
5739
|
on: this.on,
|
|
5725
5740
|
transitions: [...this.transitions.values()].flat().map((t) => ({
|
|
5726
5741
|
...t,
|
|
@@ -5742,11 +5757,11 @@ class Ve {
|
|
|
5742
5757
|
}
|
|
5743
5758
|
/** The logic invoked as actors by this state node. */
|
|
5744
5759
|
get invoke() {
|
|
5745
|
-
return
|
|
5760
|
+
return bt(this, "invoke", () => Y(this.config.invoke).map((t, e) => {
|
|
5746
5761
|
const {
|
|
5747
5762
|
src: s,
|
|
5748
5763
|
systemId: r
|
|
5749
|
-
} = t, i = t.id ??
|
|
5764
|
+
} = t, i = t.id ?? yn(this.id, e), o = typeof s == "string" ? s : `xstate.invoke.${yn(this.id, e)}`;
|
|
5750
5765
|
return {
|
|
5751
5766
|
...t,
|
|
5752
5767
|
src: o,
|
|
@@ -5770,26 +5785,26 @@ class Ve {
|
|
|
5770
5785
|
}
|
|
5771
5786
|
/** The mapping of events to transitions. */
|
|
5772
5787
|
get on() {
|
|
5773
|
-
return
|
|
5788
|
+
return bt(this, "on", () => [...this.transitions].flatMap(([e, s]) => s.map((r) => [e, r])).reduce((e, [s, r]) => (e[s] = e[s] || [], e[s].push(r), e), {}));
|
|
5774
5789
|
}
|
|
5775
5790
|
get after() {
|
|
5776
|
-
return
|
|
5791
|
+
return bt(this, "delayedTransitions", () => Xi(this));
|
|
5777
5792
|
}
|
|
5778
5793
|
get initial() {
|
|
5779
|
-
return
|
|
5794
|
+
return bt(this, "initial", () => Yi(this, this.config.initial));
|
|
5780
5795
|
}
|
|
5781
5796
|
/** @internal */
|
|
5782
5797
|
next(t, e) {
|
|
5783
5798
|
const s = e.type, r = [];
|
|
5784
5799
|
let i;
|
|
5785
|
-
const o =
|
|
5800
|
+
const o = bt(this, `candidates-${s}`, () => Ji(this, s));
|
|
5786
5801
|
for (const a of o) {
|
|
5787
5802
|
const {
|
|
5788
5803
|
guard: c
|
|
5789
5804
|
} = a, l = t.context;
|
|
5790
5805
|
let u = !1;
|
|
5791
5806
|
try {
|
|
5792
|
-
u = !c ||
|
|
5807
|
+
u = !c || Fe(c, l, e, t);
|
|
5793
5808
|
} catch (h) {
|
|
5794
5809
|
const d = typeof c == "string" ? c : typeof c == "object" ? c.type : void 0;
|
|
5795
5810
|
throw new Error(`Unable to evaluate guard ${d ? `'${d}' ` : ""}in transition for event '${s}' in state node '${this.id}':
|
|
@@ -5804,7 +5819,7 @@ ${h.message}`);
|
|
|
5804
5819
|
}
|
|
5805
5820
|
/** All the event types accepted by this state node and its descendants. */
|
|
5806
5821
|
get events() {
|
|
5807
|
-
return
|
|
5822
|
+
return bt(this, "events", () => {
|
|
5808
5823
|
const {
|
|
5809
5824
|
states: t
|
|
5810
5825
|
} = this, e = new Set(this.ownEvents);
|
|
@@ -5829,14 +5844,14 @@ ${h.message}`);
|
|
|
5829
5844
|
}
|
|
5830
5845
|
}
|
|
5831
5846
|
const ko = "#";
|
|
5832
|
-
class
|
|
5847
|
+
class Xe {
|
|
5833
5848
|
constructor(t, e) {
|
|
5834
5849
|
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 = {
|
|
5835
5850
|
actors: (e == null ? void 0 : e.actors) ?? {},
|
|
5836
5851
|
actions: (e == null ? void 0 : e.actions) ?? {},
|
|
5837
5852
|
delays: (e == null ? void 0 : e.delays) ?? {},
|
|
5838
5853
|
guards: (e == null ? void 0 : e.guards) ?? {}
|
|
5839
|
-
}, 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
|
|
5854
|
+
}, 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 Je(t, {
|
|
5840
5855
|
_key: this.id,
|
|
5841
5856
|
_machine: this
|
|
5842
5857
|
}), this.root._initialize(), this.states = this.root.states, this.events = this.root.events;
|
|
@@ -5856,7 +5871,7 @@ class Je {
|
|
|
5856
5871
|
actors: r,
|
|
5857
5872
|
delays: i
|
|
5858
5873
|
} = this.implementations;
|
|
5859
|
-
return new
|
|
5874
|
+
return new Xe(this.config, {
|
|
5860
5875
|
actions: {
|
|
5861
5876
|
...e,
|
|
5862
5877
|
...t.actions
|
|
@@ -5881,7 +5896,7 @@ class Je {
|
|
|
5881
5896
|
_nodes: [...s],
|
|
5882
5897
|
context: t.context || {},
|
|
5883
5898
|
children: {},
|
|
5884
|
-
status:
|
|
5899
|
+
status: Ue(s, this.root) ? "done" : t.status || "active",
|
|
5885
5900
|
output: t.output,
|
|
5886
5901
|
error: t.error,
|
|
5887
5902
|
historyValue: t.historyValue
|
|
@@ -5908,7 +5923,7 @@ class Je {
|
|
|
5908
5923
|
return be(t, e, s, []).microstates;
|
|
5909
5924
|
}
|
|
5910
5925
|
getTransitionData(t, e) {
|
|
5911
|
-
return
|
|
5926
|
+
return Ge(this.root, t.value, t, e) || [];
|
|
5912
5927
|
}
|
|
5913
5928
|
/**
|
|
5914
5929
|
* The initial state _before_ evaluating any microsteps. This "pre-initial"
|
|
@@ -5957,7 +5972,7 @@ class Je {
|
|
|
5957
5972
|
});
|
|
5958
5973
|
}
|
|
5959
5974
|
getStateNodeById(t) {
|
|
5960
|
-
const e =
|
|
5975
|
+
const e = ze(t), s = e.slice(1), r = ue(e[0]) ? e[0].slice(ko.length) : e[0], i = this.idMap.get(r);
|
|
5961
5976
|
if (!i)
|
|
5962
5977
|
throw new Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);
|
|
5963
5978
|
return re(i, s);
|
|
@@ -5998,7 +6013,7 @@ class Je {
|
|
|
5998
6013
|
for (const u in c) {
|
|
5999
6014
|
const h = c[u];
|
|
6000
6015
|
if (h && typeof h == "object") {
|
|
6001
|
-
if ("xstate$$type" in h && h.xstate$$type ===
|
|
6016
|
+
if ("xstate$$type" in h && h.xstate$$type === je) {
|
|
6002
6017
|
c[u] = l[h.id];
|
|
6003
6018
|
continue;
|
|
6004
6019
|
}
|
|
@@ -6011,13 +6026,13 @@ class Je {
|
|
|
6011
6026
|
}
|
|
6012
6027
|
}
|
|
6013
6028
|
function Co(n, t) {
|
|
6014
|
-
return new
|
|
6029
|
+
return new Xe(n, t);
|
|
6015
6030
|
}
|
|
6016
6031
|
const Ut = (n) => n === !1 ? !1 : n.map((t) => t.serialize()), xo = (n) => n === !1 ? !1 : n.serialize(), Ro = (n) => n === !1 ? !1 : n.map((t) => ({
|
|
6017
6032
|
tile: t.tile.toString(),
|
|
6018
6033
|
candidates: t.candidates.map((e) => e.toString()),
|
|
6019
6034
|
shanten: t.shanten
|
|
6020
|
-
})), Me = (n) => JSON.parse(JSON.stringify(n)), Gt = (n) => n === !1 ? !1 : Me(n),
|
|
6035
|
+
})), Me = (n) => JSON.parse(JSON.stringify(n)), Gt = (n) => n === !1 ? !1 : Me(n), En = (n) => Co(
|
|
6021
6036
|
{
|
|
6022
6037
|
id: "Untitled",
|
|
6023
6038
|
initial: "distribute",
|
|
@@ -6338,7 +6353,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6338
6353
|
actions: {
|
|
6339
6354
|
updateNextWind: ({ context: t, event: e }) => {
|
|
6340
6355
|
const s = t.currentWind;
|
|
6341
|
-
t.currentWind =
|
|
6356
|
+
t.currentWind = Et(s);
|
|
6342
6357
|
},
|
|
6343
6358
|
notify_distribution: ({ context: t, event: e }) => {
|
|
6344
6359
|
const s = t.genEventID(), r = t.controller.initialHands();
|
|
@@ -6421,7 +6436,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6421
6436
|
const r = t.genEventID(), i = t.currentWind;
|
|
6422
6437
|
let o = t.controller.doDiscard(i);
|
|
6423
6438
|
const a = t.controller.hand(t.currentWind).called.at(-1);
|
|
6424
|
-
(a instanceof J || a instanceof
|
|
6439
|
+
(a instanceof J || a instanceof X) && (o = t.controller.doDiscard(i, a));
|
|
6425
6440
|
const c = {
|
|
6426
6441
|
id: r,
|
|
6427
6442
|
type: "CHOICE_AFTER_CALLED",
|
|
@@ -6824,7 +6839,7 @@ class he {
|
|
|
6824
6839
|
constructor(t, e) {
|
|
6825
6840
|
_(this, "wall", new St());
|
|
6826
6841
|
_(this, "playerIDs");
|
|
6827
|
-
_(this, "actor", Ot(
|
|
6842
|
+
_(this, "actor", Ot(En(this), {}));
|
|
6828
6843
|
_(this, "observer");
|
|
6829
6844
|
_(this, "handlers", {});
|
|
6830
6845
|
_(this, "mailBox", {});
|
|
@@ -6928,7 +6943,7 @@ class he {
|
|
|
6928
6943
|
S(o.choices.DAI_KAN, "daikan choice is none"), this.actor.send({
|
|
6929
6944
|
type: i.type,
|
|
6930
6945
|
iam: o.wind,
|
|
6931
|
-
block:
|
|
6946
|
+
block: q.from(o.choices.DAI_KAN.tiles)
|
|
6932
6947
|
});
|
|
6933
6948
|
break;
|
|
6934
6949
|
case "CHI":
|
|
@@ -6938,7 +6953,7 @@ class he {
|
|
|
6938
6953
|
i.events.length == 1,
|
|
6939
6954
|
`found more than one selected: ${JSON.stringify(i, null, 2)}`
|
|
6940
6955
|
);
|
|
6941
|
-
const c =
|
|
6956
|
+
const c = X.deserialize(a[0]);
|
|
6942
6957
|
this.actor.send({
|
|
6943
6958
|
type: i.type,
|
|
6944
6959
|
iam: o.wind,
|
|
@@ -7089,11 +7104,11 @@ class he {
|
|
|
7089
7104
|
);
|
|
7090
7105
|
}
|
|
7091
7106
|
startGame() {
|
|
7092
|
-
for (; console.debug(`start========${this.placeManager.round}=============`), this.start(), this.wall = new St(), this.observer.applied = {}, this.mailBox = {}, this.actor = Ot(
|
|
7107
|
+
for (; console.debug(`start========${this.placeManager.round}=============`), this.start(), this.wall = new St(), this.observer.applied = {}, this.mailBox = {}, this.actor = Ot(En(this)), !this.placeManager.is(k.W1); )
|
|
7093
7108
|
;
|
|
7094
7109
|
}
|
|
7095
7110
|
finalResult(t, e) {
|
|
7096
|
-
const s = this.hand(e), r = s.reached ? this.wall.blindDoraMarkers : void 0, i = new
|
|
7111
|
+
const s = this.hand(e), r = s.reached ? this.wall.blindDoraMarkers : void 0, i = new un(s, {
|
|
7097
7112
|
...t.boardContext,
|
|
7098
7113
|
sticks: this.placeManager.sticks,
|
|
7099
7114
|
blindDoraMarkers: r
|
|
@@ -7111,7 +7126,7 @@ class he {
|
|
|
7111
7126
|
} else
|
|
7112
7127
|
i.finalWallWin = !this.wall.canDraw, i.replacementWin = s == null ? void 0 : s.replacementWin;
|
|
7113
7128
|
i.oneShotWin = s == null ? void 0 : s.oneShot;
|
|
7114
|
-
const o = new wi(r), a = new
|
|
7129
|
+
const o = new wi(r), a = new un(r, i), c = o.calc(e), l = a.calc(...c);
|
|
7115
7130
|
if (!l || l.points.length == 0) return !1;
|
|
7116
7131
|
if (r.draw == null) {
|
|
7117
7132
|
const u = Kt.candidateTiles(this.hand(t)).candidates;
|
|
@@ -7124,7 +7139,7 @@ class he {
|
|
|
7124
7139
|
if (s == null || t == e) return !1;
|
|
7125
7140
|
const r = this.hand(t);
|
|
7126
7141
|
if (r.reached || r.hands.length < 3 || r.get(s.t, s.n) < 2) return !1;
|
|
7127
|
-
const i = s.clone({ removeAll: !0 }), o =
|
|
7142
|
+
const i = s.clone({ removeAll: !0 }), o = en(t, e, b.PON), a = [], c = new X([i, i, i]).clone({
|
|
7128
7143
|
replace: { idx: o, tile: s.clone({ add: y.HORIZONTAL }) }
|
|
7129
7144
|
});
|
|
7130
7145
|
let l = c;
|
|
@@ -7148,7 +7163,7 @@ class he {
|
|
|
7148
7163
|
return a;
|
|
7149
7164
|
}
|
|
7150
7165
|
doChi(t, e, s) {
|
|
7151
|
-
if (s == null || !s.isNum() ||
|
|
7166
|
+
if (s == null || !s.isNum() || Et(e) != t) return !1;
|
|
7152
7167
|
const r = this.hand(t);
|
|
7153
7168
|
if (r.reached || r.hands.length < 3) return !1;
|
|
7154
7169
|
const i = s.clone({
|
|
@@ -7178,7 +7193,7 @@ class he {
|
|
|
7178
7193
|
const g = o[d], f = this.cannotDiscardTile(g), m = [];
|
|
7179
7194
|
for (const O of f) {
|
|
7180
7195
|
const x = r.get(O.t, O.n);
|
|
7181
|
-
for (let
|
|
7196
|
+
for (let yt = 0; yt < x; yt++) m.push(O.clone({ remove: y.RED }));
|
|
7182
7197
|
}
|
|
7183
7198
|
const E = r.dec([...m, g.tiles[1], g.tiles[2]]), N = r.hands.length == 0;
|
|
7184
7199
|
r.inc(E), N && o.splice(d, 1);
|
|
@@ -7208,7 +7223,7 @@ class he {
|
|
|
7208
7223
|
if (this.hand(t).reached) return [this.hand(t).drawn];
|
|
7209
7224
|
const s = this.hand(t).hands;
|
|
7210
7225
|
if (e == null) return s;
|
|
7211
|
-
if (e instanceof
|
|
7226
|
+
if (e instanceof X)
|
|
7212
7227
|
return s.filter((o) => !o.equals(e.tiles[0]));
|
|
7213
7228
|
const r = this.cannotDiscardTile(e), i = s.filter((o) => !r.some((a) => o.equals(a)));
|
|
7214
7229
|
return S(
|
|
@@ -7225,7 +7240,7 @@ class he {
|
|
|
7225
7240
|
doAnKan(t) {
|
|
7226
7241
|
const e = this.hand(t), s = [];
|
|
7227
7242
|
if (e.reached) return !1;
|
|
7228
|
-
for (const [r, i] of
|
|
7243
|
+
for (const [r, i] of L())
|
|
7229
7244
|
if (e.get(r, i) == 4) {
|
|
7230
7245
|
const o = new w(r, i), a = [o, o, o, o];
|
|
7231
7246
|
C(o) && (a[1] = o.clone({ add: y.RED })), s.push(new M(a));
|
|
@@ -7241,7 +7256,7 @@ class he {
|
|
|
7241
7256
|
doShoKan(t) {
|
|
7242
7257
|
const e = this.hand(t);
|
|
7243
7258
|
if (e.reached) return !1;
|
|
7244
|
-
const s = e.called.filter((i) => i instanceof
|
|
7259
|
+
const s = e.called.filter((i) => i instanceof X);
|
|
7245
7260
|
if (s.length == 0) return !1;
|
|
7246
7261
|
const r = [];
|
|
7247
7262
|
for (const i of s) {
|
|
@@ -7267,8 +7282,8 @@ class he {
|
|
|
7267
7282
|
if (r.reached || t == e) return !1;
|
|
7268
7283
|
const i = s.clone({ removeAll: !0 });
|
|
7269
7284
|
if (r.get(i.t, i.n) != 3) return !1;
|
|
7270
|
-
const o =
|
|
7271
|
-
let a = new
|
|
7285
|
+
const o = en(t, e, b.DAI_KAN);
|
|
7286
|
+
let a = new q([i, i, i, i]).clone({
|
|
7272
7287
|
replace: { idx: o, tile: i.clone({ add: y.HORIZONTAL }) }
|
|
7273
7288
|
});
|
|
7274
7289
|
if (C(s) && s.has(y.RED))
|
|
@@ -7309,7 +7324,7 @@ class he {
|
|
|
7309
7324
|
return this.wall.initialHands();
|
|
7310
7325
|
}
|
|
7311
7326
|
}
|
|
7312
|
-
class Rt extends
|
|
7327
|
+
class Rt extends Ke {
|
|
7313
7328
|
isBackHand() {
|
|
7314
7329
|
for (const t of Object.values(p))
|
|
7315
7330
|
if (t != p.BACK && this.sum(t) > 0)
|
|
@@ -7379,7 +7394,7 @@ class ds {
|
|
|
7379
7394
|
case "PON":
|
|
7380
7395
|
case "CHI":
|
|
7381
7396
|
case "DAI_KAN": {
|
|
7382
|
-
const r =
|
|
7397
|
+
const r = T.deserialize(t.block);
|
|
7383
7398
|
this.hands[t.iam].call(r), this.river.markCalled(), t.iam != t.wind && this.counter.dec(...r.tiles.filter((i) => !i.has(y.HORIZONTAL)));
|
|
7384
7399
|
break;
|
|
7385
7400
|
}
|
|
@@ -7512,7 +7527,7 @@ class $o extends ds {
|
|
|
7512
7527
|
case "END_GAME":
|
|
7513
7528
|
for (const r of Object.values(A))
|
|
7514
7529
|
console.debug(
|
|
7515
|
-
`${this.placeManager.playerID(r)}(${
|
|
7530
|
+
`${this.placeManager.playerID(r)}(${Pe(r)})`,
|
|
7516
7531
|
`end hand: ${this.hand(r).toString()}`
|
|
7517
7532
|
);
|
|
7518
7533
|
console.debug(
|
|
@@ -7699,33 +7714,33 @@ export {
|
|
|
7699
7714
|
Rt as ActorHand,
|
|
7700
7715
|
b as BLOCK,
|
|
7701
7716
|
ds as BaseActor,
|
|
7702
|
-
|
|
7717
|
+
T as Block,
|
|
7703
7718
|
M as BlockAnKan,
|
|
7704
7719
|
wi as BlockCalculator,
|
|
7705
7720
|
J as BlockChi,
|
|
7706
|
-
|
|
7721
|
+
q as BlockDaiKan,
|
|
7707
7722
|
Dt as BlockHand,
|
|
7708
|
-
|
|
7709
|
-
|
|
7723
|
+
vn as BlockIsolated,
|
|
7724
|
+
Tn as BlockOther,
|
|
7710
7725
|
P as BlockPair,
|
|
7711
|
-
|
|
7726
|
+
X as BlockPon,
|
|
7712
7727
|
lt as BlockRun,
|
|
7713
7728
|
K as BlockShoKan,
|
|
7714
7729
|
Z as BlockThree,
|
|
7715
7730
|
he as Controller,
|
|
7716
7731
|
Si as Counter,
|
|
7717
|
-
|
|
7732
|
+
un as DoubleCalculator,
|
|
7718
7733
|
Kt as Efficiency,
|
|
7719
|
-
|
|
7734
|
+
Nn as FONT_FAMILY,
|
|
7720
7735
|
v as G,
|
|
7721
|
-
|
|
7736
|
+
Ke as Hand,
|
|
7722
7737
|
ct as INPUT_SEPARATOR,
|
|
7723
7738
|
$n as Image,
|
|
7724
7739
|
Dn as ImageHelper,
|
|
7725
|
-
|
|
7740
|
+
gt as Mark,
|
|
7726
7741
|
Wo as MeasureText,
|
|
7727
|
-
|
|
7728
|
-
|
|
7742
|
+
zo as MyG,
|
|
7743
|
+
Lo as MyImage,
|
|
7729
7744
|
Fo as MyRect,
|
|
7730
7745
|
Ko as MySVG,
|
|
7731
7746
|
Zo as MyText,
|
|
@@ -7739,13 +7754,13 @@ export {
|
|
|
7739
7754
|
Vt as Player,
|
|
7740
7755
|
oe as PlayerEfficiency,
|
|
7741
7756
|
k as ROUND,
|
|
7742
|
-
|
|
7757
|
+
Sn as ROUND_MAP,
|
|
7743
7758
|
Hn as Rect,
|
|
7744
7759
|
Jo as Replayer,
|
|
7745
7760
|
Wt as RiskRank,
|
|
7746
7761
|
Un as River,
|
|
7747
|
-
|
|
7748
|
-
|
|
7762
|
+
Ye as STICK_CONTEXT,
|
|
7763
|
+
zr as SVG,
|
|
7749
7764
|
ee as ScoreManager,
|
|
7750
7765
|
le as ShantenCalculator,
|
|
7751
7766
|
Kr as Svg,
|
|
@@ -7755,13 +7770,13 @@ export {
|
|
|
7755
7770
|
p as TYPE,
|
|
7756
7771
|
Nt as Text,
|
|
7757
7772
|
w as Tile,
|
|
7758
|
-
|
|
7773
|
+
Be as Use,
|
|
7759
7774
|
A as WIND,
|
|
7760
7775
|
$e as WIND_MAP,
|
|
7761
7776
|
St as Wall,
|
|
7762
|
-
|
|
7777
|
+
en as callBlockIndex,
|
|
7763
7778
|
yi as convertInput,
|
|
7764
|
-
|
|
7779
|
+
En as createControllerMachine,
|
|
7765
7780
|
Ni as createEventEmitter,
|
|
7766
7781
|
Zt as createEventPipe,
|
|
7767
7782
|
Pt as createHand,
|
|
@@ -7771,16 +7786,16 @@ export {
|
|
|
7771
7786
|
Ft as deserializeWinResult,
|
|
7772
7787
|
Uo as drawBlocks,
|
|
7773
7788
|
Vo as drawTable,
|
|
7774
|
-
|
|
7789
|
+
L as forHand,
|
|
7775
7790
|
Mo as incrementalIDGenerator,
|
|
7776
7791
|
C as isNum5,
|
|
7777
7792
|
Jt as nextRound,
|
|
7778
|
-
|
|
7793
|
+
Et as nextWind,
|
|
7779
7794
|
Go as optimizeSVG,
|
|
7780
7795
|
hi as parse,
|
|
7781
7796
|
di as parseTableInput,
|
|
7782
7797
|
Do as prevRound,
|
|
7783
|
-
|
|
7798
|
+
Pe as prevWind,
|
|
7784
7799
|
bi as prioritizeDiscardedEvents,
|
|
7785
7800
|
_i as prioritizeDrawnEvents,
|
|
7786
7801
|
Zn as shuffle,
|