@konoui/mjimage 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -38,33 +38,33 @@ const On = "MS Gothic, sans-serif", mt = {
38
38
  IMAGE_DORA: "dora",
39
39
  IMAGE_DISCARD: "simple-discard",
40
40
  UNKNOWN: "unknown"
41
- }, A = {
42
- E: "1w",
43
- S: "2w",
44
- W: "3w",
45
- N: "4w"
41
+ }, E = {
42
+ E: "1z",
43
+ S: "2z",
44
+ W: "3z",
45
+ N: "4z"
46
46
  }, x = {
47
- E1: "1w1",
48
- E2: "1w2",
49
- E3: "1w3",
50
- E4: "1w4",
51
- S1: "2w1",
52
- S2: "2w2",
53
- S3: "2w3",
54
- S4: "2w4",
55
- W1: "3w1",
56
- W2: "3w2",
57
- W3: "3w3",
58
- W4: "3w4",
59
- N1: "4w1",
60
- N2: "4w2",
61
- N3: "4w3",
62
- N4: "4w4"
47
+ E1: "1z1",
48
+ E2: "1z2",
49
+ E3: "1z3",
50
+ E4: "1z4",
51
+ S1: "2z1",
52
+ S2: "2z2",
53
+ S3: "2z3",
54
+ S4: "2z4",
55
+ W1: "3z1",
56
+ W2: "3z2",
57
+ W3: "3z3",
58
+ W4: "3z4",
59
+ N1: "4z1",
60
+ N2: "4z2",
61
+ N3: "4z3",
62
+ N4: "4z4"
63
63
  }, Be = {
64
- [A.E]: "東",
65
- [A.S]: "南",
66
- [A.W]: "西",
67
- [A.N]: "北"
64
+ [E.E]: "東",
65
+ [E.S]: "南",
66
+ [E.W]: "西",
67
+ [E.N]: "北"
68
68
  }, Cn = {
69
69
  [x.E1]: "東1局",
70
70
  [x.E2]: "東2局",
@@ -201,7 +201,7 @@ class w {
201
201
  this.t = t, this.n = e, this.ops = s;
202
202
  }
203
203
  static from(t) {
204
- const e = new L(t).tiles();
204
+ const e = new z(t).tiles();
205
205
  if (e.length != 1) throw new Error(`input is not a single tile ${t}`);
206
206
  return e[0];
207
207
  }
@@ -241,7 +241,7 @@ class O {
241
241
  }
242
242
  }
243
243
  static from(t) {
244
- const e = new L(t).parse();
244
+ const e = new z(t).parse();
245
245
  if (e.length != 1) throw new Error(`block must be 1: ${t}`);
246
246
  return e[0];
247
247
  }
@@ -252,7 +252,7 @@ class O {
252
252
  throw new Error(
253
253
  `input type is ${t.type} but got is ${s}: ${t.tiles}`
254
254
  );
255
- return se(e.tiles, t.type);
255
+ return ee(e.tiles, t.type);
256
256
  }
257
257
  serialize() {
258
258
  return {
@@ -284,7 +284,7 @@ class O {
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), se(s, this._type);
287
+ return e && (s[e.idx] = e.tile), ee(s, this._type);
288
288
  }
289
289
  }
290
290
  const bt = (n) => {
@@ -361,7 +361,7 @@ class et extends O {
361
361
  return bt(this.tiles);
362
362
  }
363
363
  }
364
- class z extends O {
364
+ class j extends O {
365
365
  constructor(t) {
366
366
  super(t, b.SHO_KAN);
367
367
  }
@@ -370,7 +370,7 @@ class z extends O {
370
370
  }
371
371
  static fromPon(t, e) {
372
372
  const s = t.tiles.findIndex((r) => r.has(y.HORIZONTAL)), i = [...t.tiles];
373
- return i.splice(s, 0, e.clone({ add: y.HORIZONTAL })), new z(i);
373
+ return i.splice(s, 0, e.clone({ add: y.HORIZONTAL })), new j(i);
374
374
  }
375
375
  toString() {
376
376
  return bt(this.tiles);
@@ -423,7 +423,7 @@ class kn extends O {
423
423
  return this.tiles[0].toString();
424
424
  }
425
425
  }
426
- class jt extends O {
426
+ class zt extends O {
427
427
  constructor(t) {
428
428
  super(t, b.HAND);
429
429
  }
@@ -442,7 +442,7 @@ class xn extends O {
442
442
  return this.is(b.IMAGE_DISCARD) ? this.tiles.join("") : Ke(this.tiles);
443
443
  }
444
444
  }
445
- const se = (n, t) => {
445
+ const ee = (n, t) => {
446
446
  switch (t) {
447
447
  case b.CHI:
448
448
  return new Q([n[0], n[1], n[2]]);
@@ -453,7 +453,7 @@ const se = (n, t) => {
453
453
  case b.DAI_KAN:
454
454
  return new et(n);
455
455
  case b.SHO_KAN:
456
- return new z(n);
456
+ return new j(n);
457
457
  case b.THREE:
458
458
  return new V(n);
459
459
  case b.RUN:
@@ -463,12 +463,12 @@ const se = (n, t) => {
463
463
  case b.ISOLATED:
464
464
  return new kn(n[0]);
465
465
  case b.HAND:
466
- return new jt(n);
466
+ return new zt(n);
467
467
  default:
468
468
  return new xn(n, t);
469
469
  }
470
470
  };
471
- class L {
471
+ class z {
472
472
  constructor(t) {
473
473
  _(this, "maxInputLength", 600);
474
474
  this.input = t, this.input = t.replace(/\s/g, "");
@@ -524,13 +524,13 @@ class L {
524
524
  if (t.length == 0) return s;
525
525
  for (const o of t) {
526
526
  if (o == ft) {
527
- const a = rn(e), c = se(e, a);
527
+ const a = rn(e), c = ee(e, a);
528
528
  s.push(c), e = [];
529
529
  continue;
530
530
  }
531
531
  e.push(o);
532
532
  }
533
- const i = rn(e), r = se(e, i);
533
+ const i = rn(e), r = ee(e, i);
534
534
  return s.push(r), e = [], s;
535
535
  }
536
536
  validate(t) {
@@ -615,25 +615,25 @@ function xs(n) {
615
615
  }
616
616
  function D(n, t = !1) {
617
617
  const e = {
618
- [A.E]: n,
619
- [A.S]: n,
620
- [A.W]: n,
621
- [A.N]: n
618
+ [E.E]: n,
619
+ [E.S]: n,
620
+ [E.W]: n,
621
+ [E.N]: n
622
622
  };
623
623
  if (t)
624
- for (let s of Object.values(A)) e[s] = structuredClone(n);
624
+ for (let s of Object.values(E)) e[s] = structuredClone(n);
625
625
  return e;
626
626
  }
627
- const te = (n) => {
627
+ const qt = (n) => {
628
628
  let t = n.substring(0, 2), e = Number(n.substring(2, 3));
629
629
  return e == 4 ? (e = 1, t = Nt(t)) : e++, `${t}${e}`;
630
- }, Lo = (n) => te(te(te(n))), Nt = (n) => {
630
+ }, zo = (n) => qt(qt(qt(n))), Nt = (n) => {
631
631
  let t = Number(n.toString()[0]);
632
- return t = t % 4 + 1, `${t}w`;
633
- }, Le = (n) => {
632
+ return t = t % 4 + 1, `${t}${g.Z}`;
633
+ }, ze = (n) => {
634
634
  let t = Number(n.toString()[0]);
635
635
  const e = [1, 4, 3, 2], s = e.indexOf(t);
636
- return `${e[(s + 1) % e.length]}w`;
636
+ return `${e[(s + 1) % e.length]}${g.Z}`;
637
637
  }, an = (n, t, e) => {
638
638
  const s = Math.abs(Number(n[0]) - Number(t[0]));
639
639
  return I(s == 1 || s == 2 || s == 3), e == b.PON ? s == 3 ? 0 : s == 2 ? 1 : 2 : s == 3 ? 0 : s == 1 ? 3 : 2;
@@ -651,7 +651,7 @@ function Ie(n, t = 0) {
651
651
  f: t
652
652
  };
653
653
  }
654
- function je(...n) {
654
+ function Le(...n) {
655
655
  n = Array.isArray(n[0]) ? n[0] : n;
656
656
  const t = (e, s) => ({
657
657
  a: e.a * s.a + e.c * s.b,
@@ -670,12 +670,12 @@ function je(...n) {
670
670
  return t(n[0], n[1]);
671
671
  default: {
672
672
  const [e, s, ...i] = n, r = t(e, s);
673
- return je(r, ...i);
673
+ return Le(r, ...i);
674
674
  }
675
675
  }
676
676
  }
677
677
  function Rs(...n) {
678
- return je(...n);
678
+ return Le(...n);
679
679
  }
680
680
  const { cos: $s, sin: Ms, PI: Ps } = Math;
681
681
  function Hs(n, t, e) {
@@ -687,7 +687,7 @@ function Hs(n, t, e) {
687
687
  d: s,
688
688
  f: 0
689
689
  };
690
- return cn(t) || cn(e) ? r : je([
690
+ return cn(t) || cn(e) ? r : Le([
691
691
  Ie(t, e),
692
692
  r,
693
693
  Ie(-t, -e)
@@ -801,7 +801,7 @@ fe.buildMessage = function(n, t) {
801
801
  }
802
802
  return "Expected " + a(n) + " but " + c(t) + " found.";
803
803
  };
804
- const $n = ":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", Ls = $n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040", js = "[" + $n + "][" + Ls + "]*", zs = new RegExp("^" + js + "$");
804
+ const $n = ":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", zs = $n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040", Ls = "[" + $n + "][" + zs + "]*", js = new RegExp("^" + Ls + "$");
805
805
  function Mn(n, t) {
806
806
  const e = [];
807
807
  let s = t.exec(n);
@@ -815,8 +815,8 @@ function Mn(n, t) {
815
815
  }
816
816
  return e;
817
817
  }
818
- const ze = function(n) {
819
- const t = zs.exec(n);
818
+ const je = function(n) {
819
+ const t = js.exec(n);
820
820
  return !(t === null || typeof t > "u");
821
821
  };
822
822
  function Us(n) {
@@ -1036,10 +1036,10 @@ function C(n, t, e) {
1036
1036
  };
1037
1037
  }
1038
1038
  function Qs(n) {
1039
- return ze(n);
1039
+ return je(n);
1040
1040
  }
1041
1041
  function ti(n) {
1042
- return ze(n);
1042
+ return je(n);
1043
1043
  }
1044
1044
  function M(n, t) {
1045
1045
  const e = n.substring(0, t).split(/\r?\n/);
@@ -1099,8 +1099,8 @@ const ei = {
1099
1099
  }, ni = function(n) {
1100
1100
  return Object.assign({}, ei, n);
1101
1101
  };
1102
- let ie;
1103
- typeof Symbol != "function" ? ie = "@@xmlMetadata" : ie = Symbol("XML Node Metadata");
1102
+ let ne;
1103
+ typeof Symbol != "function" ? ne = "@@xmlMetadata" : ne = Symbol("XML Node Metadata");
1104
1104
  class ht {
1105
1105
  constructor(t) {
1106
1106
  this.tagname = t, this.child = [], this[":@"] = {};
@@ -1109,11 +1109,11 @@ class ht {
1109
1109
  t === "__proto__" && (t = "#__proto__"), this.child.push({ [t]: e });
1110
1110
  }
1111
1111
  addChild(t, e) {
1112
- 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][ie] = { startIndex: e });
1112
+ 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][ne] = { startIndex: e });
1113
1113
  }
1114
1114
  /** symbol used for metadata */
1115
1115
  static getMetaDataSymbol() {
1116
- return ie;
1116
+ return ne;
1117
1117
  }
1118
1118
  }
1119
1119
  function si(n, t) {
@@ -1168,7 +1168,7 @@ function ii(n, t) {
1168
1168
  if (n[t] === "%")
1169
1169
  throw new Error("Parameter entities are not supported");
1170
1170
  let s = "";
1171
- return [t, s] = ee(n, t, "entity"), t--, [e, s, t];
1171
+ return [t, s] = Qt(n, t, "entity"), t--, [e, s, t];
1172
1172
  }
1173
1173
  function ri(n, t) {
1174
1174
  t = nt(n, t);
@@ -1182,12 +1182,12 @@ function ri(n, t) {
1182
1182
  t += s.length, t = nt(n, t);
1183
1183
  let i = null, r = null;
1184
1184
  if (s === "PUBLIC")
1185
- [t, i] = ee(n, t, "publicIdentifier"), t = nt(n, t), (n[t] === '"' || n[t] === "'") && ([t, r] = ee(n, t, "systemIdentifier"));
1186
- else if (s === "SYSTEM" && ([t, r] = ee(n, t, "systemIdentifier"), !r))
1185
+ [t, i] = Qt(n, t, "publicIdentifier"), t = nt(n, t), (n[t] === '"' || n[t] === "'") && ([t, r] = Qt(n, t, "systemIdentifier"));
1186
+ else if (s === "SYSTEM" && ([t, r] = Qt(n, t, "systemIdentifier"), !r))
1187
1187
  throw new Error("Missing mandatory system identifier for SYSTEM notation");
1188
1188
  return { notationName: e, publicIdentifier: i, systemIdentifier: r, index: --t };
1189
1189
  }
1190
- function ee(n, t, e) {
1190
+ function Qt(n, t, e) {
1191
1191
  let s = "";
1192
1192
  const i = n[t];
1193
1193
  if (i !== '"' && i !== "'")
@@ -1228,7 +1228,7 @@ function ut(n, t, e) {
1228
1228
  return !0;
1229
1229
  }
1230
1230
  function Ue(n) {
1231
- if (ze(n))
1231
+ if (je(n))
1232
1232
  return n;
1233
1233
  throw new Error(`Invalid entity name ${n}`);
1234
1234
  }
@@ -1447,8 +1447,8 @@ const Ei = function(n) {
1447
1447
  if (!S) throw new Error(`Unexpected end of ${l}`);
1448
1448
  r = S.i, m = S.tagContent;
1449
1449
  }
1450
- const E = new ht(c);
1451
- c !== h && u && (E[":@"] = this.buildAttributesMap(h, i, c)), m && (m = this.parseTextData(m, c, i, !0, u, !0, !0)), i = i.substr(0, i.lastIndexOf(".")), E.add(this.options.textNodeName, m), this.addChild(e, E, i, f);
1450
+ const A = new ht(c);
1451
+ c !== h && u && (A[":@"] = this.buildAttributesMap(h, i, c)), m && (m = this.parseTextData(m, c, i, !0, u, !0, !0)), i = i.substr(0, i.lastIndexOf(".")), A.add(this.options.textNodeName, m), this.addChild(e, A, i, f);
1452
1452
  } else {
1453
1453
  if (h.length > 0 && h.lastIndexOf("/") === h.length - 1) {
1454
1454
  c[c.length - 1] === "/" ? (c = c.substr(0, c.length - 1), i = i.substr(0, i.length - 1), h = c) : h = h.substr(0, h.length - 1), this.options.transformTagName && (c = this.options.transformTagName(c));
@@ -1709,8 +1709,8 @@ function Wn(n, t, e, s) {
1709
1709
  continue;
1710
1710
  } else if (c[0] === "?") {
1711
1711
  const f = fn(a[":@"], t), m = c === "?xml" ? "" : s;
1712
- let E = a[c][0][t.textNodeName];
1713
- E = E.length !== 0 ? " " + E : "", i += m + `<${c}${E}${f}?>`, r = !0;
1712
+ let A = a[c][0][t.textNodeName];
1713
+ A = A.length !== 0 ? " " + A : "", i += m + `<${c}${A}${f}?>`, r = !0;
1714
1714
  continue;
1715
1715
  }
1716
1716
  let h = s;
@@ -1924,7 +1924,7 @@ class _t {
1924
1924
  left(...t) {
1925
1925
  return `<${[
1926
1926
  this.type,
1927
- jn(this.attrs),
1927
+ Ln(this.attrs),
1928
1928
  Gi(this.styles),
1929
1929
  ...t
1930
1930
  ].filter((e) => e != "").join(" ")}>`;
@@ -2004,7 +2004,7 @@ class It extends _t {
2004
2004
  return this._text;
2005
2005
  }
2006
2006
  }
2007
- let Ln = class extends _t {
2007
+ let zn = class extends _t {
2008
2008
  constructor(e) {
2009
2009
  super("symbol");
2010
2010
  _(this, "raw");
@@ -2049,12 +2049,12 @@ class T extends _t {
2049
2049
  }
2050
2050
  }
2051
2051
  }
2052
- const Li = [
2052
+ const zi = [
2053
2053
  'xmlns="http://www.w3.org/2000/svg"',
2054
2054
  'version="1.1"',
2055
2055
  'xmlns:xlink="http://www.w3.org/1999/xlink"'
2056
2056
  ];
2057
- class ji extends _t {
2057
+ class Li extends _t {
2058
2058
  constructor() {
2059
2059
  super("svg");
2060
2060
  _(this, "children", []);
@@ -2069,8 +2069,8 @@ class ji extends _t {
2069
2069
  left(...e) {
2070
2070
  return `<${[
2071
2071
  this.type,
2072
- ...Li,
2073
- jn(this.attrs),
2072
+ ...zi,
2073
+ Ln(this.attrs),
2074
2074
  Fi(this.viewBox)
2075
2075
  ].filter((s) => s != "").join(" ")}>`;
2076
2076
  }
@@ -2101,10 +2101,10 @@ class ji extends _t {
2101
2101
  }
2102
2102
  }
2103
2103
  }
2104
- function zi() {
2105
- return new ji();
2104
+ function ji() {
2105
+ return new Li();
2106
2106
  }
2107
- const zo = zi, Uo = T, Fo = Bn, Zo = Fe, Go = Kn, Vo = It;
2107
+ const jo = ji, Uo = T, Fo = Bn, Zo = Fe, Go = Kn, Vo = It;
2108
2108
  function Ui(n) {
2109
2109
  return n.replace(/[A-Z]/g, (t) => "-" + t.toLowerCase());
2110
2110
  }
@@ -2114,7 +2114,7 @@ function Fi(n) {
2114
2114
  function Zi(n) {
2115
2115
  return n == null ? "" : `transform="${Ds(n)}"`;
2116
2116
  }
2117
- function jn(n) {
2117
+ function Ln(n) {
2118
2118
  return Object.entries(n).filter(([t, e]) => e !== void 0).map(([t, e]) => `${Ui(t)}="${e}"`).join(" ");
2119
2119
  }
2120
2120
  function Gi(n) {
@@ -2126,7 +2126,7 @@ function* Vi(n) {
2126
2126
  ignoreAttributes: !1
2127
2127
  }), s = t.parse(n);
2128
2128
  for (const i of s.svg.symbol) {
2129
- const r = e.build(i), o = new Ln(r);
2129
+ const r = e.build(i), o = new zn(r);
2130
2130
  for (const [a, c] of Object.entries(i))
2131
2131
  a.startsWith("@_") && (o.attrs[a.substring(2)] = c);
2132
2132
  yield o;
@@ -2195,7 +2195,7 @@ class Tt {
2195
2195
  return this.imageHostUrl != "" ? `${this.imageHostUrl}${e}` : e;
2196
2196
  }
2197
2197
  }
2198
- class zn extends Tt {
2198
+ class jn extends Tt {
2199
2199
  constructor() {
2200
2200
  super(...arguments);
2201
2201
  _(this, "blockMargin", mt.WIDTH * mt.BLOCK_MARGIN_SCALE * this.scale);
@@ -2284,12 +2284,12 @@ const Ji = (n, t) => {
2284
2284
  return { ...r, e: o };
2285
2285
  },
2286
2286
  [b.IMAGE_DORA]: function(i) {
2287
- i = (t == null ? void 0 : t.doraText) == !1 ? new jt([i.tiles[0].clone({ remove: y.DORA })]) : i;
2287
+ i = (t == null ? void 0 : t.doraText) == !1 ? new zt([i.tiles[0].clone({ remove: y.DORA })]) : i;
2288
2288
  const r = Z(i, e), o = new T(), a = (t == null ? void 0 : t.doraText) === !1 ? n.createImage(i.tiles[0], 0, 0) : n.createTextImage(i.tiles[0], 0, 0, "(ドラ)");
2289
2289
  return o.add(a), { ...r, e: o };
2290
2290
  },
2291
2291
  [b.TSUMO]: function(i) {
2292
- i = (t == null ? void 0 : t.tsumoText) == !1 ? new jt([i.tiles[0].clone({ remove: y.TSUMO })]) : i;
2292
+ i = (t == null ? void 0 : t.tsumoText) == !1 ? new zt([i.tiles[0].clone({ remove: y.TSUMO })]) : i;
2293
2293
  const r = Z(i, e), o = new T(), a = (t == null ? void 0 : t.tsumoText) === !1 ? n.createImage(i.tiles[0], 0, 0) : n.createTextImage(i.tiles[0], 0, 0, "(ツモ)");
2294
2294
  return o.add(a), { ...r, e: o };
2295
2295
  },
@@ -2340,7 +2340,7 @@ const Ji = (n, t) => {
2340
2340
  doraText: !0,
2341
2341
  tsumoText: !0
2342
2342
  }) => {
2343
- const i = new zn(e), r = Dt(i, t, s);
2343
+ const i = new jn(e), r = Dt(i, t, s);
2344
2344
  s.responsive || n.size(r.width, r.height), n.viewbox(0, 0, r.width, r.height), n.add(r.e);
2345
2345
  }, Un = () => {
2346
2346
  const n = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], t = [];
@@ -2367,7 +2367,7 @@ const Ji = (n, t) => {
2367
2367
  const t = Un(), e = Yi(n);
2368
2368
  n.each((s, i) => {
2369
2369
  const r = i[s];
2370
- r instanceof Ln && (t.includes(r.id()) && e.includes(r.id()) || r.remove());
2370
+ r instanceof zn && (t.includes(r.id()) && e.includes(r.id()) || r.remove());
2371
2371
  }, !0);
2372
2372
  }, Xi = (n) => {
2373
2373
  const e = [];
@@ -2391,7 +2391,7 @@ const Ji = (n, t) => {
2391
2391
  return o.rotate(s, 0, e).translate(a, c), new T().add(o);
2392
2392
  }
2393
2393
  return new T().add(o);
2394
- }, Gt = (n, t) => {
2394
+ }, Ft = (n, t) => {
2395
2395
  const e = new T(), s = Xi(n);
2396
2396
  for (let i = 0; i < s.length; i++) {
2397
2397
  let r = s[i], o = i * t.tileHeight;
@@ -2408,7 +2408,7 @@ const Ji = (n, t) => {
2408
2408
  let h = i * 3, u = r;
2409
2409
  const d = (c + n.tileWidth + i - h) / 2, p = new It().plain(e.round).font(s).x(d).y(0);
2410
2410
  u += 25 * n.scale;
2411
- const f = n.tileHeight, m = new T().size(c, f).translate(0, u), E = { family: s.family, size: s.size * 0.7 }, S = n.createStick(1e3).size(c, l).x(0).y(0), k = new It().plain(a.toString()).font(E).dx(c).dy(l), N = n.createStick(100).size(c, l).x(0).y(l + l), v = new It().plain(o.toString()).font(E).dx(c).dy(l * 3);
2411
+ const f = n.tileHeight, m = new T().size(c, f).translate(0, u), A = { family: s.family, size: s.size * 0.7 }, S = n.createStick(1e3).size(c, l).x(0).y(0), k = new It().plain(a.toString()).font(A).dx(c).dy(l), N = n.createStick(100).size(c, l).x(0).y(l + l), v = new It().plain(o.toString()).font(A).dx(c).dy(l * 3);
2412
2412
  m.add(S), m.add(k), m.add(N), m.add(v);
2413
2413
  const H = n.createImage(e.doras[0], 0, 0).x(c + i).y(0);
2414
2414
  m.add(H);
@@ -2420,7 +2420,7 @@ const Ji = (n, t) => {
2420
2420
  };
2421
2421
  }, Qi = (n, t, e = 0) => {
2422
2422
  const s = Dt(n, t.front), i = Dt(n, t.right), r = Dt(n, t.opposite), o = Dt(n, t.left), a = [s.width, i.width, r.width, o.width].reduce(
2423
- (m, E) => Math.max(m, E)
2423
+ (m, A) => Math.max(m, A)
2424
2424
  ), c = Math.max(
2425
2425
  e + n.tileHeight * 2 + n.blockMargin * 2,
2426
2426
  a + n.tileWidth * 2 + n.blockMargin
@@ -2456,7 +2456,7 @@ const Ji = (n, t) => {
2456
2456
  };
2457
2457
  }, [h, u, d, p] = tr(
2458
2458
  e.frontPlace
2459
- ), f = e.scores, E = l(h, f.front, {
2459
+ ), f = e.scores, A = l(h, f.front, {
2460
2460
  x: s / 2,
2461
2461
  y: s,
2462
2462
  "dominant-baseline": "text-after-edge",
@@ -2486,9 +2486,9 @@ const Ji = (n, t) => {
2486
2486
  -H.height,
2487
2487
  s / 2
2488
2488
  ), J = new T(), ms = new Kn().size(s, s).x(0).y(0).fill("none").stroke("#000000");
2489
- return J.add(ms), J.add(c.e), J.add(E), J.add(k), J.add(v), J.add($), { e: J, width: s, height: s };
2489
+ return J.add(ms), J.add(c.e), J.add(A), J.add(k), J.add(v), J.add($), { e: J, width: s, height: s };
2490
2490
  }, nr = (n, t) => {
2491
- const e = Gt(t.front, n), s = Gt(t.right, n), i = Gt(t.opposite, n), r = Gt(t.left, n), o = [e.height, s.height, i.height, r.height].reduce(
2491
+ const e = Ft(t.front, n), s = Ft(t.right, n), i = Ft(t.opposite, n), r = Ft(t.left, n), o = [e.height, s.height, i.height, r.height].reduce(
2492
2492
  (k, N) => Math.max(k, N)
2493
2493
  ), a = n.tileWidth * 5 + n.tileHeight * 1, c = o, l = a + o * 2 + n.blockMargin, h = l, u = new T().size(l, h), d = l / 2 - a / 2, p = h / 2 - a / 2, f = U(e.e, a, c, 0).translate(
2494
2494
  d,
@@ -2496,7 +2496,7 @@ const Ji = (n, t) => {
2496
2496
  ), m = U(s.e, a, c, 270).translate(
2497
2497
  l - c,
2498
2498
  p
2499
- ), E = U(
2499
+ ), A = U(
2500
2500
  i.e,
2501
2501
  a,
2502
2502
  c,
@@ -2505,7 +2505,7 @@ const Ji = (n, t) => {
2505
2505
  0,
2506
2506
  p
2507
2507
  );
2508
- return u.add(f), u.add(m), u.add(E), u.add(S), { e: new T().add(u), width: l, height: h };
2508
+ return u.add(f), u.add(m), u.add(A), u.add(S), { e: new T().add(u), width: l, height: h };
2509
2509
  }, sr = (n, t, e, s, i) => {
2510
2510
  const r = new T(), o = nr(n, s), a = Qi(n, e, o.height), c = er(n, t, i);
2511
2511
  return o.e.translate(
@@ -2516,7 +2516,7 @@ const Ji = (n, t) => {
2516
2516
  (a.height - c.height) / 2
2517
2517
  ), r.add(a.e), r.add(o.e), r.add(c.e), { e: r, width: a.width, height: a.height };
2518
2518
  }, Xo = (n, t, e = {}, s, i = { responsive: !1 }) => {
2519
- const r = new zn(e), o = s, { discards: a, hands: c, scoreBoard: l } = fr(t), h = sr(r, o, c, a, l);
2519
+ const r = new jn(e), o = s, { discards: a, hands: c, scoreBoard: l } = fr(t), h = sr(r, o, c, a, l);
2520
2520
  i.responsive || n.size(h.width, h.height), n.viewbox(0, 0, h.width, h.height), n.add(h.e);
2521
2521
  };
2522
2522
  var Y;
@@ -2641,11 +2641,11 @@ function Zn(n, t, e) {
2641
2641
  );
2642
2642
  }
2643
2643
  // @__NO_SIDE_EFFECTS__
2644
- function re(n) {
2644
+ function se(n) {
2645
2645
  return {
2646
2646
  kind: "schema",
2647
2647
  type: "number",
2648
- reference: re,
2648
+ reference: se,
2649
2649
  expects: "number",
2650
2650
  async: !1,
2651
2651
  message: n,
@@ -2658,11 +2658,11 @@ function re(n) {
2658
2658
  };
2659
2659
  }
2660
2660
  // @__NO_SIDE_EFFECTS__
2661
- function j(n, t) {
2661
+ function L(n, t) {
2662
2662
  return {
2663
2663
  kind: "schema",
2664
2664
  type: "optional",
2665
- reference: j,
2665
+ reference: L,
2666
2666
  expects: `(${n.expects} | undefined)`,
2667
2667
  async: !1,
2668
2668
  wrapped: n,
@@ -2780,11 +2780,11 @@ function Ct(n, t) {
2780
2780
  };
2781
2781
  }
2782
2782
  // @__NO_SIDE_EFFECTS__
2783
- function oe(n) {
2783
+ function ie(n) {
2784
2784
  return {
2785
2785
  kind: "schema",
2786
2786
  type: "string",
2787
- reference: oe,
2787
+ reference: ie,
2788
2788
  expects: "string",
2789
2789
  async: !1,
2790
2790
  message: n,
@@ -2827,44 +2827,44 @@ function lr(n, t, e) {
2827
2827
  issues: s.issues
2828
2828
  };
2829
2829
  }
2830
- const Vt = /* @__PURE__ */ j(
2830
+ const Zt = /* @__PURE__ */ L(
2831
2831
  /* @__PURE__ */ Ct({
2832
- discard: /* @__PURE__ */ j(/* @__PURE__ */ oe(), ""),
2833
- hand: /* @__PURE__ */ j(/* @__PURE__ */ oe(), ""),
2834
- score: /* @__PURE__ */ j(/* @__PURE__ */ re(), 25e3)
2832
+ discard: /* @__PURE__ */ L(/* @__PURE__ */ ie(), ""),
2833
+ hand: /* @__PURE__ */ L(/* @__PURE__ */ ie(), ""),
2834
+ score: /* @__PURE__ */ L(/* @__PURE__ */ se(), 25e3)
2835
2835
  }),
2836
2836
  { discard: "", hand: "", score: 25e3 }
2837
2837
  ), hr = /* @__PURE__ */ Ct({
2838
- [A.E]: Vt,
2839
- [A.S]: Vt,
2840
- [A.W]: Vt,
2841
- [A.N]: Vt
2838
+ [E.E]: Zt,
2839
+ [E.S]: Zt,
2840
+ [E.W]: Zt,
2841
+ [E.N]: Zt
2842
2842
  }), at = {
2843
2843
  round: x.E1,
2844
2844
  sticks: { reach: 0, dead: 0 },
2845
- doras: A.S,
2846
- front: A.E
2847
- }, ur = /* @__PURE__ */ j(
2845
+ doras: E.S,
2846
+ front: E.E
2847
+ }, ur = /* @__PURE__ */ L(
2848
2848
  /* @__PURE__ */ Ct({
2849
- round: /* @__PURE__ */ j(
2849
+ round: /* @__PURE__ */ L(
2850
2850
  /* @__PURE__ */ ke(Object.keys(Cn)),
2851
2851
  at.round
2852
2852
  ),
2853
- sticks: /* @__PURE__ */ j(
2853
+ sticks: /* @__PURE__ */ L(
2854
2854
  /* @__PURE__ */ Ct({
2855
- reach: /* @__PURE__ */ j(
2856
- /* @__PURE__ */ pn(/* @__PURE__ */ re(), /* @__PURE__ */ Ce(0, ""), /* @__PURE__ */ Oe(9, "")),
2855
+ reach: /* @__PURE__ */ L(
2856
+ /* @__PURE__ */ pn(/* @__PURE__ */ se(), /* @__PURE__ */ Ce(0, ""), /* @__PURE__ */ Oe(9, "")),
2857
2857
  at.sticks.reach
2858
2858
  ),
2859
- dead: /* @__PURE__ */ j(
2860
- /* @__PURE__ */ pn(/* @__PURE__ */ re(), /* @__PURE__ */ Ce(0, ""), /* @__PURE__ */ Oe(9, "")),
2859
+ dead: /* @__PURE__ */ L(
2860
+ /* @__PURE__ */ pn(/* @__PURE__ */ se(), /* @__PURE__ */ Ce(0, ""), /* @__PURE__ */ Oe(9, "")),
2861
2861
  at.sticks.dead
2862
2862
  )
2863
2863
  }),
2864
2864
  at.sticks
2865
2865
  ),
2866
- doras: /* @__PURE__ */ j(/* @__PURE__ */ oe(), at.doras),
2867
- front: /* @__PURE__ */ j(
2866
+ doras: /* @__PURE__ */ L(/* @__PURE__ */ ie(), at.doras),
2867
+ front: /* @__PURE__ */ L(
2868
2868
  /* @__PURE__ */ ke(Object.keys(Be)),
2869
2869
  at.front
2870
2870
  )
@@ -2889,7 +2889,7 @@ const Vt = /* @__PURE__ */ j(
2889
2889
  if (!i.startsWith(t))
2890
2890
  throw new Error(`input does not start with table: ${i}`);
2891
2891
  const r = {};
2892
- let o = [A.E, A.S, A.W, A.N, e];
2892
+ let o = [E.E, E.S, E.W, E.N, e];
2893
2893
  for (; ; ) {
2894
2894
  const a = s.shift();
2895
2895
  if (a == null) break;
@@ -2937,20 +2937,20 @@ const Vt = /* @__PURE__ */ j(
2937
2937
  return [a, c];
2938
2938
  }, wr = (n) => {
2939
2939
  const t = n.board.front, e = br(t), s = (a) => n[a].discard.replace(/\r?\n/g, ""), i = {
2940
- front: new L(s(e.front)).tiles(),
2941
- right: new L(s(e.right)).tiles(),
2942
- opposite: new L(s(e.opposite)).tiles(),
2943
- left: new L(s(e.left)).tiles()
2940
+ front: new z(s(e.front)).tiles(),
2941
+ right: new z(s(e.right)).tiles(),
2942
+ opposite: new z(s(e.opposite)).tiles(),
2943
+ left: new z(s(e.left)).tiles()
2944
2944
  }, r = {
2945
- front: new L(n[e.front].hand).parse(),
2946
- right: new L(n[e.right].hand).parse(),
2947
- opposite: new L(n[e.opposite].hand).parse(),
2948
- left: new L(n[e.left].hand).parse()
2945
+ front: new z(n[e.front].hand).parse(),
2946
+ right: new z(n[e.right].hand).parse(),
2947
+ opposite: new z(n[e.opposite].hand).parse(),
2948
+ left: new z(n[e.left].hand).parse()
2949
2949
  }, o = {
2950
2950
  round: Cn[n.board.round],
2951
2951
  frontPlace: Be[t],
2952
2952
  sticks: n.board.sticks,
2953
- doras: new L(n.board.doras).tiles(),
2953
+ doras: new z(n.board.doras).tiles(),
2954
2954
  scores: {
2955
2955
  front: n[e.front].score,
2956
2956
  right: n[e.right].score,
@@ -2963,7 +2963,7 @@ const Vt = /* @__PURE__ */ j(
2963
2963
  front: n,
2964
2964
  right: Nt(n),
2965
2965
  opposite: Nt(Nt(n)),
2966
- left: Le(n)
2966
+ left: ze(n)
2967
2967
  });
2968
2968
  function* F(n) {
2969
2969
  const t = n != null && n.filterBy && n.filterBy.length > 0 ? n == null ? void 0 : n.filterBy : Object.values(g);
@@ -2989,7 +2989,7 @@ class Ze {
2989
2989
  }, this.init(t, e);
2990
2990
  }
2991
2991
  init(t, e) {
2992
- const s = Array.isArray(t) ? t : new L(t).parse();
2992
+ const s = Array.isArray(t) ? t : new z(t).parse();
2993
2993
  for (const i of s) {
2994
2994
  if (i.isCalled()) {
2995
2995
  this.data.called = [...this.called, i];
@@ -3032,7 +3032,7 @@ class Ze {
3032
3032
  }
3033
3033
  toString() {
3034
3034
  const t = this.called.length > 0 ? `${ft}${this.called.join(ft)}` : "", e = this.drawn ? `${ft}${this.drawn.toString()}` : "", s = this.hands.filter((r) => !r.has(y.TSUMO));
3035
- return `${new jt(s).toString()}${e}${t}`;
3035
+ return `${new zt(s).toString()}${e}${t}`;
3036
3036
  }
3037
3037
  get called() {
3038
3038
  return this.data.called;
@@ -3101,7 +3101,7 @@ class Ze {
3101
3101
  this.dec(t.tiles), this.data.called = [...this.called, t], this.data.tsumo = null;
3102
3102
  return;
3103
3103
  }
3104
- if (t instanceof z) {
3104
+ if (t instanceof j) {
3105
3105
  const e = this.data.called.findIndex(
3106
3106
  (i) => i.is(b.PON) && i.tiles[0].equals(t.tiles[0])
3107
3107
  // FIXME handle which tile is called
@@ -3146,7 +3146,7 @@ class pe {
3146
3146
  let t = 0, e = 0;
3147
3147
  for (const s of Object.values(g)) {
3148
3148
  if (s == g.BACK) continue;
3149
- const i = s == g.Z ? zt : q;
3149
+ const i = s == g.Z ? Lt : q;
3150
3150
  for (const r of i)
3151
3151
  this.hand.get(s, r) >= 1 && t++, this.hand.get(s, r) >= 2 && e++;
3152
3152
  }
@@ -3167,8 +3167,8 @@ class pe {
3167
3167
  const m = [this.hand.called.length, 0, 0];
3168
3168
  for (let S = 0; S < 3; S++)
3169
3169
  m[S] += d[S] + p[S] + f[S] + i[S] + r[S];
3170
- const E = this.calcCommon(m[0], m[1], m[2], s);
3171
- E < c && (c = E);
3170
+ const A = this.calcCommon(m[0], m[1], m[2], s);
3171
+ A < c && (c = A);
3172
3172
  }
3173
3173
  return c;
3174
3174
  };
@@ -3276,7 +3276,7 @@ class _r {
3276
3276
  let e = !1;
3277
3277
  for (const s of Object.values(g)) {
3278
3278
  if (s == g.BACK) continue;
3279
- const i = s == g.Z ? zt : q;
3279
+ const i = s == g.Z ? Lt : q;
3280
3280
  for (let r of i)
3281
3281
  if (this.hand.get(s, r) == 1)
3282
3282
  t.push(new kn(new w(s, r)));
@@ -3292,7 +3292,7 @@ class _r {
3292
3292
  if (e == g.BACK || e == g.Z) continue;
3293
3293
  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]), i = this.hand.sum(e) == 14;
3294
3294
  if (s && i)
3295
- return [[new jt(this.hand.hands)]];
3295
+ return [[new zt(this.hand.hands)]];
3296
3296
  }
3297
3297
  return [];
3298
3298
  }
@@ -3345,8 +3345,8 @@ class _r {
3345
3345
  const l = e[c], h = {};
3346
3346
  for (let u = 0; u < l.length; u++) {
3347
3347
  const d = l[u], p = d.tiles.findIndex(
3348
- (E) => E.equals(s) && !E.has(y.RED)
3349
- ), f = d.tiles.findIndex((E) => E.equals(i) && E.has(y.RED));
3348
+ (A) => A.equals(s) && !A.has(y.RED)
3349
+ ), f = d.tiles.findIndex((A) => A.equals(i) && A.has(y.RED));
3350
3350
  if (f > -1 && o.push([c, u, f]), f > -1 && p > -1 || p < 0) continue;
3351
3351
  const m = Bt(d);
3352
3352
  h[m] || (h[m] = !0, r.push([c, u, p]));
@@ -3359,7 +3359,7 @@ class _r {
3359
3359
  d[l] = p.clone({
3360
3360
  replace: { idx: h, tile: i }
3361
3361
  });
3362
- const f = o.find((E) => E[0] == c);
3362
+ const f = o.find((A) => A[0] == c);
3363
3363
  if (f == null) continue;
3364
3364
  const m = d[f[1]];
3365
3365
  m == null && console.error(f, r), d[f[1]] = m.clone({
@@ -3394,7 +3394,7 @@ class _r {
3394
3394
  return s;
3395
3395
  }
3396
3396
  }
3397
- const zt = [1, 2, 3, 4, 5, 6, 7], q = [1, 9], Jt = (n) => {
3397
+ const Lt = [1, 2, 3, 4, 5, 6, 7], q = [1, 9], Gt = (n) => {
3398
3398
  var e;
3399
3399
  const t = n.boardContext;
3400
3400
  return {
@@ -3470,18 +3470,18 @@ class gn {
3470
3470
  l >= 13 && l < 26 && e[o].yakus.every((N) => N.is32000 == null || N.is32000 == !1) && (h = this.cfg.disableCountable32000 ? 6e3 : 8e3, i = !this.cfg.disableCountable32000), this.cfg.enableRoundUp8000 && (c == 30 && l == 4 || c == 60 && l == 3) && (h = 2e3);
3471
3471
  const u = e[o].hand.some(
3472
3472
  (N) => N.tiles.some((v) => v.has(y.TSUMO))
3473
- ), d = this.cfg.orig.myWind, p = d == A.E;
3473
+ ), d = this.cfg.orig.myWind, p = d == E.E;
3474
3474
  let f = "";
3475
3475
  const m = D(0);
3476
3476
  if (u) {
3477
3477
  const N = this.cfg.sticks.dead * 100;
3478
3478
  if (p) {
3479
3479
  const v = a(h * 2);
3480
- m[A.E] += v * 3 + N * 3, m[A.S] -= v + N, m[A.W] -= v + N, m[A.N] -= v + N, f = `${v}`;
3480
+ m[E.E] += v * 3 + N * 3, m[E.S] -= v + N, m[E.W] -= v + N, m[E.N] -= v + N, f = `${v}`;
3481
3481
  } else {
3482
- for (const v of Object.values(A)) {
3482
+ for (const v of Object.values(E)) {
3483
3483
  if (v == d) continue;
3484
- const H = v == A.E ? 2 : 1, $ = a(h * H);
3484
+ const H = v == E.E ? 2 : 1, $ = a(h * H);
3485
3485
  m[v] -= $ + N, m[d] += $ + N;
3486
3486
  }
3487
3487
  f = `${a(h * 1)}-${a(h * 2)}`;
@@ -3493,7 +3493,7 @@ class gn {
3493
3493
  const $ = a(h * (p ? 6 : 4)) + N;
3494
3494
  m[d] += $, m[this.cfg.orig.ronWind] -= $, f = `${$}`;
3495
3495
  }
3496
- const E = m[d] - this.cfg.sticks.dead * 100;
3496
+ const A = m[d] - this.cfg.sticks.dead * 300;
3497
3497
  m[d] += 1e3 * this.cfg.sticks.reach;
3498
3498
  let S;
3499
3499
  return s ? S = "役満" : i ? S = "数え役満" : h == 2e3 ? S = `${c}符${l}飜 満貫${f}` : h == 3e3 ? S = `${c}符${l}飜 跳満${f}` : h == 4e3 ? S = `${c}符${l}飜 倍満${f}` : h == 6e3 ? S = `${c}符${l}飜 三倍満${f}` : S = `${c}符${l}飜 ${f}`, {
@@ -3502,7 +3502,7 @@ class gn {
3502
3502
  fu: c,
3503
3503
  yakus: e[o].yakus,
3504
3504
  point: m[d],
3505
- basePoint: E,
3505
+ rawPoint: A,
3506
3506
  hand: e[o].hand,
3507
3507
  boardContext: this.cfg.orig,
3508
3508
  description: S
@@ -3647,7 +3647,7 @@ class gn {
3647
3647
  }
3648
3648
  dC2(t) {
3649
3649
  return t.length == 7 ? [] : t.every(
3650
- (s) => s instanceof P || s instanceof z || s instanceof et || s instanceof V || s instanceof tt || s instanceof B
3650
+ (s) => s instanceof P || s instanceof j || s instanceof et || s instanceof V || s instanceof tt || s instanceof B
3651
3651
  ) ? [{ name: "対々和", han: 2 }] : [];
3652
3652
  }
3653
3653
  dD2(t) {
@@ -3655,11 +3655,11 @@ class gn {
3655
3655
  }
3656
3656
  dE2(t) {
3657
3657
  return t.filter(
3658
- (s) => s instanceof P || s instanceof z || s instanceof et
3658
+ (s) => s instanceof P || s instanceof j || s instanceof et
3659
3659
  ).length >= 3 ? [{ name: "三槓子", han: 2 }] : [];
3660
3660
  }
3661
3661
  dF2(t) {
3662
- const e = (s) => s instanceof P || s instanceof z || s instanceof et || s instanceof V || s instanceof tt;
3662
+ const e = (s) => s instanceof P || s instanceof j || s instanceof et || s instanceof V || s instanceof tt;
3663
3663
  for (const s of t) {
3664
3664
  if (!e(s)) continue;
3665
3665
  const i = ct(s);
@@ -3683,13 +3683,13 @@ class gn {
3683
3683
  }
3684
3684
  dH2(t) {
3685
3685
  return t.every((s) => {
3686
- const i = s.tiles[0].t == g.Z ? zt : q;
3686
+ const i = s.tiles[0].t == g.Z ? Lt : q;
3687
3687
  return s.tiles.every((r) => i.includes(r.n));
3688
3688
  }) ? [{ name: "混老頭", han: 2 }] : [];
3689
3689
  }
3690
3690
  dI2(t) {
3691
3691
  return t.length == 7 ? [] : t.some((s) => s instanceof pt || s instanceof Q) ? t.some((s) => s.tiles[0].t == g.Z) ? t.every((s) => {
3692
- const i = s.tiles[0].t == g.Z ? zt : q;
3692
+ const i = s.tiles[0].t == g.Z ? Lt : q;
3693
3693
  return s.tiles.some((r) => i.includes(r.n));
3694
3694
  }) ? [{ name: "混全帯么九", han: 2 - this.minus() }] : [] : [] : [];
3695
3695
  }
@@ -3761,7 +3761,7 @@ class gn {
3761
3761
  }
3762
3762
  dG13(t) {
3763
3763
  return t.filter(
3764
- (s) => s instanceof P || s instanceof z || s instanceof et
3764
+ (s) => s instanceof P || s instanceof j || s instanceof et
3765
3765
  ).length == 4 ? [{ name: "四槓子", han: 13, is32000: !0 }] : [];
3766
3766
  }
3767
3767
  dH13(t) {
@@ -3788,19 +3788,19 @@ class gn {
3788
3788
  const o = t.find(
3789
3789
  (f) => f.tiles.some((m) => m.has(y.TSUMO) || m.has(y.RON))
3790
3790
  ), a = this.minus() == 1, c = o.tiles.some((f) => f.has(y.TSUMO)), l = (f, m) => {
3791
- const E = f.tiles[0];
3792
- return E.t == g.Z || q.includes(E.n) ? m * 2 : m;
3791
+ const A = f.tiles[0];
3792
+ return A.t == g.Z || q.includes(A.n) ? m * 2 : m;
3793
3793
  };
3794
3794
  for (const f of t)
3795
3795
  switch (!0) {
3796
3796
  case f instanceof V:
3797
- const m = f.tiles.some((E) => E.has(y.RON)) ? 2 : 4;
3797
+ const m = f.tiles.some((A) => A.has(y.RON)) ? 2 : 4;
3798
3798
  s += l(f, m);
3799
3799
  break;
3800
3800
  case f instanceof tt:
3801
3801
  s += l(f, 2);
3802
3802
  break;
3803
- case (f instanceof et || f instanceof z):
3803
+ case (f instanceof et || f instanceof j):
3804
3804
  s += l(f, 8);
3805
3805
  break;
3806
3806
  case f instanceof P:
@@ -3810,8 +3810,8 @@ class gn {
3810
3810
  s += ((f) => {
3811
3811
  if (f instanceof V) return 0;
3812
3812
  if (f instanceof B) return 2;
3813
- const m = f.tiles, E = m.findIndex((S) => S.has(y.TSUMO) || S.has(y.RON));
3814
- return E == 1 || E == 0 && m[2].n == 9 || E == 2 && m[0].n == 1 ? 2 : 0;
3813
+ const m = f.tiles, A = m.findIndex((S) => S.has(y.TSUMO) || S.has(y.RON));
3814
+ return A == 1 || A == 0 && m[2].n == 9 || A == 2 && m[0].n == 1 ? 2 : 0;
3815
3815
  })(o);
3816
3816
  const d = t.find((f) => f instanceof B).tiles[0];
3817
3817
  d.t == g.Z && ([5, 6, 7].includes(d.n) && (s += 2), (d.n == r || d.n == i) && (s += 2));
@@ -3838,7 +3838,7 @@ const Bt = (n) => n.tiles.reduce((t, e) => `${t}${e.n}${e.t}`, ""), yn = (n) =>
3838
3838
  }
3839
3839
  return new w(e, t % 9 + 1);
3840
3840
  };
3841
- class Ut {
3841
+ class jt {
3842
3842
  // ツモった後の14枚の手配から、牌効率に従って捨てるべき牌を返す。
3843
3843
  // choices は、通常なら hand.hand を指定する。ただし、リーチしている場合は捨てる牌が限られているので choices で制限する。
3844
3844
  static calcCandidates(t, e, s) {
@@ -3846,7 +3846,7 @@ class Ut {
3846
3846
  const i = /* @__PURE__ */ new Map();
3847
3847
  let r = 1 / 0;
3848
3848
  for (const o of e) {
3849
- const a = t.dec([o]), c = Ut.candidateTiles(t, s);
3849
+ const a = t.dec([o]), c = jt.candidateTiles(t, s);
3850
3850
  t.inc(a);
3851
3851
  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 });
3852
3852
  c.shanten < r ? (i.clear(), i.set(l.toString(), {
@@ -3946,7 +3946,7 @@ function Vn(n, t) {
3946
3946
  if (t[e]) return e;
3947
3947
  return !1;
3948
3948
  }
3949
- const Yt = () => {
3949
+ const Vt = () => {
3950
3950
  const n = Re(), t = Re(), e = {
3951
3951
  emit: n.emit,
3952
3952
  on: (i) => t.on(i)
@@ -3966,7 +3966,7 @@ const Yt = () => {
3966
3966
  }
3967
3967
  };
3968
3968
  };
3969
- class ae {
3969
+ class re {
3970
3970
  constructor(t) {
3971
3971
  _(this, "reachValue", 1e3);
3972
3972
  _(this, "m");
@@ -3985,7 +3985,7 @@ class ae {
3985
3985
  }
3986
3986
  }
3987
3987
  }
3988
- class ce {
3988
+ class oe {
3989
3989
  constructor(t, e) {
3990
3990
  _(this, "pToW", {});
3991
3991
  _(this, "wToP", D(""));
@@ -3996,7 +3996,7 @@ class ce {
3996
3996
  }
3997
3997
  update() {
3998
3998
  for (let t in this.pToW) {
3999
- const e = Le(this.pToW[t]);
3999
+ const e = ze(this.pToW[t]);
4000
4000
  this.pToW[t] = e, this.wToP[e] = t;
4001
4001
  }
4002
4002
  }
@@ -4007,7 +4007,7 @@ class ce {
4007
4007
  this.sticks.reach++;
4008
4008
  }
4009
4009
  nextRound() {
4010
- const t = te(this.round);
4010
+ const t = qt(this.round);
4011
4011
  this.round = t, this.update();
4012
4012
  }
4013
4013
  resetDeadStick() {
@@ -4305,15 +4305,15 @@ function Kr(n, t) {
4305
4305
  clock: a,
4306
4306
  logger: c
4307
4307
  } = t, l = {
4308
- schedule: (d, p, f, m, E = Math.random().toString(36).slice(2)) => {
4308
+ schedule: (d, p, f, m, A = Math.random().toString(36).slice(2)) => {
4309
4309
  const S = {
4310
4310
  source: d,
4311
4311
  target: p,
4312
4312
  event: f,
4313
4313
  delay: m,
4314
- id: E,
4314
+ id: A,
4315
4315
  startedAt: Date.now()
4316
- }, k = An(d, E);
4316
+ }, k = An(d, A);
4317
4317
  u._snapshot._scheduledEvents[k] = S;
4318
4318
  const N = a.setTimeout(() => {
4319
4319
  delete o[k], delete u._snapshot._scheduledEvents[k], u._relay(d, p, f);
@@ -4389,11 +4389,11 @@ function Kr(n, t) {
4389
4389
  const {
4390
4390
  source: f,
4391
4391
  target: m,
4392
- event: E,
4392
+ event: A,
4393
4393
  delay: S,
4394
4394
  id: k
4395
4395
  } = d[p];
4396
- l.schedule(f, m, E, S, k);
4396
+ l.schedule(f, m, A, S, k);
4397
4397
  }
4398
4398
  },
4399
4399
  _clock: a,
@@ -4406,7 +4406,7 @@ const Je = 1;
4406
4406
  let W = /* @__PURE__ */ function(n) {
4407
4407
  return n[n.NotStarted = 0] = "NotStarted", n[n.Running = 1] = "Running", n[n.Stopped = 2] = "Stopped", n;
4408
4408
  }({});
4409
- const Lr = {
4409
+ const zr = {
4410
4410
  clock: {
4411
4411
  setTimeout: (n, t) => setTimeout(n, t),
4412
4412
  clearTimeout: (n) => clearTimeout(n)
@@ -4414,7 +4414,7 @@ const Lr = {
4414
4414
  logger: console.log.bind(console),
4415
4415
  devTools: !1
4416
4416
  };
4417
- class jr {
4417
+ class Lr {
4418
4418
  /**
4419
4419
  * Creates a new actor instance for the given logic with the provided options,
4420
4420
  * if any.
@@ -4425,7 +4425,7 @@ class jr {
4425
4425
  constructor(t, e) {
4426
4426
  this.logic = t, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new wn(this._process.bind(this)), this.observers = /* @__PURE__ */ new Set(), this.eventListeners = /* @__PURE__ */ new Map(), this.logger = void 0, this._processingStatus = W.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 = [];
4427
4427
  const s = {
4428
- ...Lr,
4428
+ ...zr,
4429
4429
  ...e
4430
4430
  }, {
4431
4431
  clock: i,
@@ -4814,9 +4814,9 @@ class jr {
4814
4814
  }
4815
4815
  }
4816
4816
  function kt(n, ...[t]) {
4817
- return new jr(n, t);
4817
+ return new Lr(n, t);
4818
4818
  }
4819
- function zr(n, t, e, s, {
4819
+ function jr(n, t, e, s, {
4820
4820
  sendId: i
4821
4821
  }) {
4822
4822
  const r = typeof i == "function" ? i(e, s) : i;
@@ -4832,7 +4832,7 @@ function Ur(n, t) {
4832
4832
  function Fr(n) {
4833
4833
  function t(e, s) {
4834
4834
  }
4835
- return t.type = "xstate.cancel", t.sendId = n, t.resolve = zr, t.execute = Ur, t;
4835
+ return t.type = "xstate.cancel", t.sendId = n, t.resolve = jr, t.execute = Ur, t;
4836
4836
  }
4837
4837
  function Zr(n, t, e, s, {
4838
4838
  id: i,
@@ -4937,7 +4937,7 @@ const Xe = (n) => n.type === "atomic" || n.type === "final";
4937
4937
  function xt(n) {
4938
4938
  return Object.values(n.states).filter((t) => t.type !== "history");
4939
4939
  }
4940
- function Zt(n, t) {
4940
+ function Ut(n, t) {
4941
4941
  const e = [];
4942
4942
  if (t === n)
4943
4943
  return e;
@@ -4946,7 +4946,7 @@ function Zt(n, t) {
4946
4946
  e.push(s), s = s.parent;
4947
4947
  return e;
4948
4948
  }
4949
- function le(n) {
4949
+ function ae(n) {
4950
4950
  const t = new Set(n), e = as(t);
4951
4951
  for (const s of t)
4952
4952
  if (s.type === "compound" && (!e.get(s) || !e.get(s).length))
@@ -4990,7 +4990,7 @@ function as(n) {
4990
4990
  return t;
4991
4991
  }
4992
4992
  function cs(n, t) {
4993
- const e = le(t);
4993
+ const e = ae(t);
4994
4994
  return os(n, as(e));
4995
4995
  }
4996
4996
  function qe(n, t) {
@@ -5124,11 +5124,11 @@ function eo(n, t) {
5124
5124
  return n.machine.getStateNodeById(e);
5125
5125
  const s = e[0] === Xn;
5126
5126
  if (s && !n.parent)
5127
- return Ft(n, e.slice(1));
5127
+ return ce(n, e.slice(1));
5128
5128
  const i = s ? n.key + e : e;
5129
5129
  if (n.parent)
5130
5130
  try {
5131
- return Ft(n.parent, i);
5131
+ return ce(n.parent, i);
5132
5132
  } catch (r) {
5133
5133
  throw new Error(`Invalid transition definition for state node '${n.id}':
5134
5134
  ${r.message}`);
@@ -5140,7 +5140,7 @@ ${r.message}`);
5140
5140
  function ls(n) {
5141
5141
  const t = is(n.config.target);
5142
5142
  return t ? {
5143
- target: t.map((e) => typeof e == "string" ? Ft(n.parent, e) : e)
5143
+ target: t.map((e) => typeof e == "string" ? ce(n.parent, e) : e)
5144
5144
  } : n.parent.initial;
5145
5145
  }
5146
5146
  function yt(n) {
@@ -5149,7 +5149,7 @@ function yt(n) {
5149
5149
  function Sn(n) {
5150
5150
  const t = hs(n);
5151
5151
  for (const e of t)
5152
- for (const s of Zt(e, n))
5152
+ for (const s of Ut(e, n))
5153
5153
  t.add(s);
5154
5154
  return t;
5155
5155
  }
@@ -5176,7 +5176,7 @@ function Rt(n, t) {
5176
5176
  throw new Error(`Child state '${t}' does not exist on '${n.id}'`);
5177
5177
  return e;
5178
5178
  }
5179
- function Ft(n, t) {
5179
+ function ce(n, t) {
5180
5180
  if (typeof t == "string" && ge(t))
5181
5181
  try {
5182
5182
  return n.machine.getStateNodeById(t);
@@ -5192,7 +5192,7 @@ function Ft(n, t) {
5192
5192
  }
5193
5193
  return s;
5194
5194
  }
5195
- function he(n, t) {
5195
+ function le(n, t) {
5196
5196
  if (typeof t == "string") {
5197
5197
  const i = n.states[t];
5198
5198
  if (!i)
@@ -5204,7 +5204,7 @@ function he(n, t) {
5204
5204
  const o = Rt(n, r);
5205
5205
  if (!o)
5206
5206
  return i;
5207
- const a = he(o, t[r]);
5207
+ const a = le(o, t[r]);
5208
5208
  return i.concat(a);
5209
5209
  }, []));
5210
5210
  }
@@ -5272,7 +5272,7 @@ function us(n, t, e) {
5272
5272
  }
5273
5273
  function ao(n) {
5274
5274
  const [t, ...e] = n;
5275
- for (const s of Zt(t, void 0))
5275
+ for (const s of Ut(t, void 0))
5276
5276
  if (e.every((i) => rt(i, s)))
5277
5277
  return s;
5278
5278
  }
@@ -5369,14 +5369,14 @@ function ho(n, t, e, s, i, r, o, a) {
5369
5369
  }
5370
5370
  if (c = $t(c, t, e, p, r, d.invoke.map((f) => f.id)), d.type === "final") {
5371
5371
  const f = d.parent;
5372
- let m = (f == null ? void 0 : f.type) === "parallel" ? f : f == null ? void 0 : f.parent, E = m || d;
5372
+ let m = (f == null ? void 0 : f.type) === "parallel" ? f : f == null ? void 0 : f.parent, A = m || d;
5373
5373
  for ((f == null ? void 0 : f.type) === "compound" && r.push(Me(f.id, d.output !== void 0 ? Pe(d.output, c.context, t, e.self) : void 0)); (m == null ? void 0 : m.type) === "parallel" && !u.has(m) && qe(i, m); )
5374
- u.add(m), r.push(Me(m.id)), E = m, m = m.parent;
5374
+ u.add(m), r.push(Me(m.id)), A = m, m = m.parent;
5375
5375
  if (m)
5376
5376
  continue;
5377
5377
  c = wt(c, {
5378
5378
  status: "done",
5379
- output: lo(c, t, e, c.machine.root, E)
5379
+ output: lo(c, t, e, c.machine.root, A)
5380
5380
  });
5381
5381
  }
5382
5382
  }
@@ -5393,7 +5393,7 @@ function uo(n, t, e, s) {
5393
5393
  i.reenter) && (s.add(a), e.add(a)), St(a, t, e, s);
5394
5394
  const o = tn(i, t);
5395
5395
  for (const a of o) {
5396
- const c = Zt(a, r);
5396
+ const c = Ut(a, r);
5397
5397
  (r == null ? void 0 : r.type) === "parallel" && c.push(r), fs(s, t, e, c, !i.source.parent && i.reenter ? void 0 : r);
5398
5398
  }
5399
5399
  }
@@ -5428,7 +5428,7 @@ function fs(n, t, e, s, i) {
5428
5428
  [...n].some((a) => rt(a, o)) || (n.add(o), St(o, t, e, n));
5429
5429
  }
5430
5430
  function Se(n, t, e, s, i) {
5431
- fs(e, s, i, Zt(n, t));
5431
+ fs(e, s, i, Ut(n, t));
5432
5432
  }
5433
5433
  function fo(n, t, e, s, i, r, o, a) {
5434
5434
  let c = n;
@@ -5478,7 +5478,7 @@ function ps(n, t, e, s, i, r) {
5478
5478
  });
5479
5479
  continue;
5480
5480
  }
5481
- const p = h, [f, m, E] = p.resolve(
5481
+ const p = h, [f, m, A] = p.resolve(
5482
5482
  e,
5483
5483
  a,
5484
5484
  u,
@@ -5492,7 +5492,7 @@ function ps(n, t, e, s, i, r) {
5492
5492
  info: u,
5493
5493
  params: m,
5494
5494
  exec: p.execute.bind(null, e, m)
5495
- }), E && (a = ps(a, t, e, E, i, r));
5495
+ }), A && (a = ps(a, t, e, A, i, r));
5496
5496
  }
5497
5497
  return a;
5498
5498
  }
@@ -5570,7 +5570,7 @@ function In(n, t) {
5570
5570
  function go(n, t) {
5571
5571
  const e = /* @__PURE__ */ new Set(), s = n._nodes.filter(Xe);
5572
5572
  for (const i of s)
5573
- t: for (const r of [i].concat(Zt(i, void 0)))
5573
+ t: for (const r of [i].concat(Ut(i, void 0)))
5574
5574
  if (r.always) {
5575
5575
  for (const o of r.always)
5576
5576
  if (o.guard === void 0 || Ye(o.guard, n.context, t, n)) {
@@ -5581,7 +5581,7 @@ function go(n, t) {
5581
5581
  return us(Array.from(e), new Set(n._nodes), n.historyValue);
5582
5582
  }
5583
5583
  function yo(n, t) {
5584
- const e = le(he(n, t));
5584
+ const e = ae(le(n, t));
5585
5585
  return cs(n, [...e]);
5586
5586
  }
5587
5587
  function mo(n) {
@@ -5614,7 +5614,7 @@ const wo = function(t) {
5614
5614
  }, Ao = function() {
5615
5615
  return this._nodes.reduce((t, e) => (e.meta !== void 0 && (t[e.id] = e.meta), t), {});
5616
5616
  };
5617
- function ne(n, t) {
5617
+ function te(n, t) {
5618
5618
  return {
5619
5619
  status: n.status,
5620
5620
  output: n.output,
@@ -5634,7 +5634,7 @@ function ne(n, t) {
5634
5634
  };
5635
5635
  }
5636
5636
  function wt(n, t = {}) {
5637
- return ne({
5637
+ return te({
5638
5638
  ...n,
5639
5639
  ...t
5640
5640
  }, n.machine);
@@ -5666,12 +5666,12 @@ function No(n, t) {
5666
5666
  ...d
5667
5667
  } = n, p = {};
5668
5668
  for (const m in r) {
5669
- const E = r[m];
5669
+ const A = r[m];
5670
5670
  p[m] = {
5671
- snapshot: E.getPersistedSnapshot(t),
5672
- src: E.src,
5673
- systemId: E._systemId,
5674
- syncSnapshot: E._syncSnapshot
5671
+ snapshot: A.getPersistedSnapshot(t),
5672
+ src: A.src,
5673
+ systemId: A._systemId,
5674
+ syncSnapshot: A._syncSnapshot
5675
5675
  };
5676
5676
  }
5677
5677
  return {
@@ -5834,9 +5834,9 @@ const xo = {}, Wt = (n) => typeof n == "string" ? {
5834
5834
  } : {
5835
5835
  type: n.name
5836
5836
  } : n;
5837
- class Kt {
5837
+ class he {
5838
5838
  constructor(t, e) {
5839
- 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 ? _n(this.config.states, (s, i) => new Kt(s, {
5839
+ 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 ? _n(this.config.states, (s, i) => new he(s, {
5840
5840
  _parent: this,
5841
5841
  _key: i,
5842
5842
  _machine: this.machine
@@ -5987,17 +5987,16 @@ class en {
5987
5987
  actions: (e == null ? void 0 : e.actions) ?? {},
5988
5988
  delays: (e == null ? void 0 : e.delays) ?? {},
5989
5989
  guards: (e == null ? void 0 : e.guards) ?? {}
5990
- }, 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 Kt(t, {
5990
+ }, 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 he(t, {
5991
5991
  _key: this.id,
5992
5992
  _machine: this
5993
5993
  }), this.root._initialize(), this.states = this.root.states, this.events = this.root.events;
5994
5994
  }
5995
5995
  /**
5996
- * Clones this state machine with the provided implementations and merges the
5997
- * `context` (if provided).
5996
+ * Clones this state machine with the provided implementations.
5998
5997
  *
5999
- * @param implementations Options (`actions`, `guards`, `actors`, `delays`,
6000
- * `context`) to recursively merge with the existing options.
5998
+ * @param implementations Options (`actions`, `guards`, `actors`, `delays`)
5999
+ * to recursively merge with the existing options.
6001
6000
  * @returns A new `StateMachine` instance with the provided implementations.
6002
6001
  */
6003
6002
  provide(t) {
@@ -6027,8 +6026,8 @@ class en {
6027
6026
  });
6028
6027
  }
6029
6028
  resolveState(t) {
6030
- const e = yo(this.root, t.value), s = le(he(this.root, e));
6031
- return ne({
6029
+ const e = yo(this.root, t.value), s = ae(le(this.root, e));
6030
+ return te({
6032
6031
  _nodes: [...s],
6033
6032
  context: t.context || {},
6034
6033
  children: {},
@@ -6068,7 +6067,7 @@ class en {
6068
6067
  getPreInitialState(t, e, s) {
6069
6068
  const {
6070
6069
  context: i
6071
- } = this.config, r = ne({
6070
+ } = this.config, r = te({
6072
6071
  context: typeof i != "function" && i ? i : {},
6073
6072
  _nodes: [this.root],
6074
6073
  children: {},
@@ -6111,7 +6110,7 @@ class en {
6111
6110
  const e = Ge(t), s = e.slice(1), i = ge(e[0]) ? e[0].slice(Ro.length) : e[0], r = this.idMap.get(i);
6112
6111
  if (!r)
6113
6112
  throw new Error(`Child state node '#${i}' does not exist on machine '${this.id}'`);
6114
- return Ft(r, s);
6113
+ return ce(r, s);
6115
6114
  }
6116
6115
  get definition() {
6117
6116
  return this.root.definition;
@@ -6128,7 +6127,7 @@ class en {
6128
6127
  const d = i[u], p = d.snapshot, f = d.src, m = typeof f == "string" ? Ve(this, f) : f;
6129
6128
  if (!m)
6130
6129
  return;
6131
- const E = kt(m, {
6130
+ const A = kt(m, {
6132
6131
  id: u,
6133
6132
  parent: e.self,
6134
6133
  syncSnapshot: d.syncSnapshot,
@@ -6136,38 +6135,33 @@ class en {
6136
6135
  src: f,
6137
6136
  systemId: d.systemId
6138
6137
  });
6139
- s[u] = E;
6138
+ s[u] = A;
6140
6139
  });
6141
6140
  function r(u, d) {
6141
+ if (d instanceof he)
6142
+ return d;
6142
6143
  try {
6143
- return d.machine.getStateNodeById(u);
6144
+ return u.machine.getStateNodeById(d.id);
6144
6145
  } catch {
6145
- try {
6146
- return Ft(d, u.split("."));
6147
- } catch {
6148
- return u;
6149
- }
6150
6146
  }
6151
6147
  }
6152
6148
  function o(u, d) {
6153
- if (!u || typeof u != "object") return {};
6149
+ if (!d || typeof d != "object")
6150
+ return {};
6154
6151
  const p = {};
6155
- for (const f in u) {
6156
- const m = u[f];
6157
- p[f] = m.map((E) => {
6158
- if (E instanceof Kt) return E;
6159
- if (typeof E == "object" && "id" in E && typeof E.id == "string") {
6160
- const S = r(E.id, d);
6161
- if (S instanceof Kt) return S;
6162
- }
6163
- }).filter((E) => E !== void 0), p[f].length === 0 && delete p[f];
6152
+ for (const f in d) {
6153
+ const m = d[f];
6154
+ for (const A of m) {
6155
+ const S = r(u, A);
6156
+ S && (p[f] ?? (p[f] = []), p[f].push(S));
6157
+ }
6164
6158
  }
6165
6159
  return p;
6166
6160
  }
6167
- const a = o(t.historyValue, this.root), c = ne({
6161
+ const a = o(this.root, t.historyValue), c = te({
6168
6162
  ...t,
6169
6163
  children: s,
6170
- _nodes: Array.from(le(he(this.root, t.value))),
6164
+ _nodes: Array.from(ae(le(this.root, t.value))),
6171
6165
  historyValue: a
6172
6166
  }, this), l = /* @__PURE__ */ new Set();
6173
6167
  function h(u, d) {
@@ -6191,16 +6185,16 @@ class en {
6191
6185
  function $o(n, t) {
6192
6186
  return new en(n, t);
6193
6187
  }
6194
- const Xt = (n) => n === !1 ? !1 : n.map((t) => t.serialize()), Mo = (n) => n === !1 ? !1 : n.serialize(), Po = (n) => n === !1 ? !1 : n.map((t) => ({
6188
+ const Jt = (n) => n === !1 ? !1 : n.map((t) => t.serialize()), Mo = (n) => n === !1 ? !1 : n.serialize(), Po = (n) => n === !1 ? !1 : n.map((t) => ({
6195
6189
  tile: t.tile.toString(),
6196
6190
  candidates: t.candidates.map((e) => e.toString()),
6197
6191
  shanten: t.shanten
6198
- })), qt = (n) => n === !1 ? !1 : xe(n), Tn = (n) => $o(
6192
+ })), Yt = (n) => n === !1 ? !1 : xe(n), Tn = (n) => $o(
6199
6193
  {
6200
6194
  id: "Untitled",
6201
6195
  initial: "distribute",
6202
6196
  context: {
6203
- currentWind: A.E,
6197
+ currentWind: E.E,
6204
6198
  oneShotMap: D(!1),
6205
6199
  missingMap: D(!1),
6206
6200
  controller: n,
@@ -6520,7 +6514,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6520
6514
  },
6521
6515
  notify_distribution: ({ context: t, event: e }) => {
6522
6516
  const s = t.genEventID(), i = t.controller.initialHands();
6523
- for (const r of Object.values(A)) {
6517
+ for (const r of Object.values(E)) {
6524
6518
  const o = D("_____________");
6525
6519
  o[r] = i[r].toString();
6526
6520
  const a = {
@@ -6546,15 +6540,15 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6546
6540
  wind: i,
6547
6541
  drawerInfo: { wind: i, tile: r.toString() },
6548
6542
  choices: {
6549
- TSUMO: qt(
6543
+ TSUMO: Yt(
6550
6544
  t.controller.doWin(i, r, {
6551
6545
  oneShot: t.oneShotMap[i],
6552
6546
  replacementWin: s == null ? void 0 : s.replacementWin
6553
6547
  })
6554
6548
  ),
6555
6549
  REACH: Po(t.controller.doReach(i)),
6556
- AN_KAN: Xt(t.controller.doAnKan(i)),
6557
- SHO_KAN: Xt(t.controller.doShoKan(i)),
6550
+ AN_KAN: Jt(t.controller.doAnKan(i)),
6551
+ SHO_KAN: Jt(t.controller.doShoKan(i)),
6558
6552
  DISCARD: t.controller.doDiscard(i).map((c) => c.toString()),
6559
6553
  DRAWN_GAME_BY_NINE_ORPHANS: t.controller.canDrawnGame(i)
6560
6554
  }
@@ -6563,7 +6557,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6563
6557
  },
6564
6558
  notify_choice_after_discarded: ({ context: t, event: e }) => {
6565
6559
  const s = t.genEventID(), i = t.controller.river.lastTile, r = i.t.clone({ add: y.HORIZONTAL });
6566
- for (const o of Object.values(A)) {
6560
+ for (const o of Object.values(E)) {
6567
6561
  const a = {
6568
6562
  id: s,
6569
6563
  type: "CHOICE_AFTER_DISCARDED",
@@ -6573,17 +6567,17 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6573
6567
  tile: i.t.toString()
6574
6568
  },
6575
6569
  choices: {
6576
- RON: qt(
6570
+ RON: Yt(
6577
6571
  t.controller.doWin(o, r, {
6578
6572
  discardedBy: i.w,
6579
6573
  oneShot: t.oneShotMap[o],
6580
6574
  missingRon: t.missingMap[o]
6581
6575
  })
6582
6576
  ),
6583
- PON: Xt(
6577
+ PON: Jt(
6584
6578
  t.controller.doPon(o, i.w, r)
6585
6579
  ),
6586
- CHI: Xt(
6580
+ CHI: Jt(
6587
6581
  t.controller.doChi(o, i.w, r)
6588
6582
  ),
6589
6583
  DAI_KAN: Mo(
@@ -6593,7 +6587,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6593
6587
  };
6594
6588
  a.choices.RON && (t.missingMap[o] = !0), t.controller.emit(a);
6595
6589
  }
6596
- t.controller.pollReplies(s, Object.values(A));
6590
+ t.controller.pollReplies(s, Object.values(E));
6597
6591
  },
6598
6592
  notify_choice_after_called: ({ context: t, event: e }, s) => {
6599
6593
  const i = t.genEventID(), r = t.currentWind;
@@ -6612,14 +6606,14 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6612
6606
  },
6613
6607
  notify_choice_for_reach_acceptance: ({ context: t, event: e }) => {
6614
6608
  const s = t.genEventID(), i = t.controller.river.lastTile, r = i.t.clone({ add: y.HORIZONTAL });
6615
- for (const o of Object.values(A)) {
6609
+ for (const o of Object.values(E)) {
6616
6610
  const a = {
6617
6611
  id: s,
6618
6612
  type: "CHOICE_FOR_REACH_ACCEPTANCE",
6619
6613
  wind: o,
6620
6614
  reacherInfo: { wind: i.w, tile: r.toString() },
6621
6615
  choices: {
6622
- RON: qt(
6616
+ RON: Yt(
6623
6617
  t.controller.doWin(o, r, {
6624
6618
  discardedBy: i.w,
6625
6619
  oneShot: t.oneShotMap[o],
@@ -6630,7 +6624,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6630
6624
  };
6631
6625
  t.controller.emit(a);
6632
6626
  }
6633
- t.controller.pollReplies(s, Object.values(A));
6627
+ t.controller.pollReplies(s, Object.values(E));
6634
6628
  },
6635
6629
  notify_choice_for_chankan: ({ context: t, event: e }) => {
6636
6630
  I(
@@ -6638,7 +6632,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6638
6632
  `unexpected event ${e.type}`
6639
6633
  );
6640
6634
  const s = t.genEventID(), i = e.block.tiles[0].clone({ remove: y.HORIZONTAL });
6641
- for (const r of Object.values(A)) {
6635
+ for (const r of Object.values(E)) {
6642
6636
  const o = t.controller.doWin(
6643
6637
  r,
6644
6638
  e.block.tiles[0].clone({ remove: y.HORIZONTAL }),
@@ -6654,12 +6648,12 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6654
6648
  wind: r,
6655
6649
  callerInfo: { wind: e.iam, tile: i.toString() },
6656
6650
  choices: {
6657
- RON: e.type == "SHO_KAN" ? qt(o) : !1
6651
+ RON: e.type == "SHO_KAN" ? Yt(o) : !1
6658
6652
  }
6659
6653
  };
6660
6654
  a.choices.RON && (t.missingMap[r] = !0), t.controller.emit(a);
6661
6655
  }
6662
- t.controller.pollReplies(s, Object.values(A));
6656
+ t.controller.pollReplies(s, Object.values(E));
6663
6657
  },
6664
6658
  notify_call: ({ context: t, event: e }) => {
6665
6659
  I(
@@ -6668,7 +6662,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6668
6662
  );
6669
6663
  const s = t.genEventID(), i = e.iam;
6670
6664
  t.currentWind = i;
6671
- for (const r of Object.values(A)) {
6665
+ for (const r of Object.values(E)) {
6672
6666
  const o = {
6673
6667
  id: s,
6674
6668
  type: e.type,
@@ -6683,7 +6677,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6683
6677
  notify_discard: ({ context: t, event: e }) => {
6684
6678
  I(e.type == "DISCARD", `unexpected event ${e.type}`);
6685
6679
  const s = t.genEventID(), i = t.currentWind, r = e.tile;
6686
- for (const o of Object.values(A)) {
6680
+ for (const o of Object.values(E)) {
6687
6681
  const a = {
6688
6682
  id: s,
6689
6683
  type: "DISCARD",
@@ -6701,7 +6695,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6701
6695
  r == "kan" ? o = t.controller.wall.kan() : o = t.controller.wall.draw();
6702
6696
  const a = t.currentWind;
6703
6697
  t.controller.hand(a).reached || (t.missingMap[a] = !1);
6704
- for (const c of Object.values(A)) {
6698
+ for (const c of Object.values(E)) {
6705
6699
  let l = new w(g.BACK, 0, [y.TSUMO]);
6706
6700
  c == a && (l = o);
6707
6701
  const h = {
@@ -6719,7 +6713,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6719
6713
  notify_ron: ({ context: t, event: e }) => {
6720
6714
  I(e.type == "RON");
6721
6715
  const s = t.genEventID(), i = e.iam;
6722
- for (const r of Object.values(A)) {
6716
+ for (const r of Object.values(E)) {
6723
6717
  const o = {
6724
6718
  id: s,
6725
6719
  type: e.type,
@@ -6737,7 +6731,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6737
6731
  notify_tsumo: ({ context: t, event: e }) => {
6738
6732
  I(e.type == "TSUMO", `unexpected event ${e.type}`);
6739
6733
  const s = t.genEventID(), i = t.currentWind;
6740
- for (const r of Object.values(A)) {
6734
+ for (const r of Object.values(E)) {
6741
6735
  const o = {
6742
6736
  id: s,
6743
6737
  type: e.type,
@@ -6753,7 +6747,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6753
6747
  I(e.type == "REACH", `unexpected event ${e.type}`);
6754
6748
  const s = t.genEventID(), i = e.iam, r = e.tile.clone({ add: y.HORIZONTAL });
6755
6749
  t.oneShotMap[i] = !0;
6756
- for (const o of Object.values(A)) {
6750
+ for (const o of Object.values(E)) {
6757
6751
  const a = {
6758
6752
  id: s,
6759
6753
  type: e.type,
@@ -6767,7 +6761,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6767
6761
  notify_reach_accepted: ({ context: t, event: e }) => {
6768
6762
  I(e.type == "REACH_ACCEPT");
6769
6763
  const s = t.genEventID();
6770
- for (const i of Object.values(A)) {
6764
+ for (const i of Object.values(E)) {
6771
6765
  const r = {
6772
6766
  id: s,
6773
6767
  type: "REACH_ACCEPTED",
@@ -6785,7 +6779,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6785
6779
  const s = t.genEventID();
6786
6780
  if (e.type == "AN_KAN") {
6787
6781
  const i = t.controller.wall.openDoraIndicator();
6788
- for (const r of Object.values(A)) {
6782
+ for (const r of Object.values(E)) {
6789
6783
  const o = {
6790
6784
  id: s,
6791
6785
  type: "NEW_DORA",
@@ -6798,7 +6792,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6798
6792
  e.type == "SHO_KAN";
6799
6793
  },
6800
6794
  disable_one_shot: ({ context: t, event: e }) => {
6801
- for (const s of Object.values(A)) t.oneShotMap[s] = !1;
6795
+ for (const s of Object.values(E)) t.oneShotMap[s] = !1;
6802
6796
  },
6803
6797
  disable_one_shot_for_me: ({ context: t, event: e }) => {
6804
6798
  t.oneShotMap[t.currentWind] = !1;
@@ -6807,7 +6801,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6807
6801
  const s = t.genEventID(), i = D("");
6808
6802
  if (e.type == "DRAWN_GAME_BY_NINE_ORPHANS") {
6809
6803
  i[e.iam] = t.controller.hand(e.iam).toString();
6810
- for (const r of Object.values(A)) {
6804
+ for (const r of Object.values(E)) {
6811
6805
  const o = {
6812
6806
  id: s,
6813
6807
  type: "END_GAME",
@@ -6822,11 +6816,11 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6822
6816
  t.controller.emit(o);
6823
6817
  }
6824
6818
  } else if (e.type == "RON" || e.type == "TSUMO") {
6825
- const r = e.iam == A.E, o = t.controller.finalResult(
6819
+ const r = e.iam == E.E, o = t.controller.finalResult(
6826
6820
  e.ret,
6827
6821
  e.iam
6828
6822
  );
6829
- for (const a of Object.values(A)) {
6823
+ for (const a of Object.values(E)) {
6830
6824
  i[e.iam] = t.controller.hand(e.iam).toString();
6831
6825
  const c = {
6832
6826
  id: s,
@@ -6843,7 +6837,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6843
6837
  }
6844
6838
  } else if (!t.controller.wall.canKan || t.controller.river.cannotContinue()) {
6845
6839
  const r = t.controller.wall.canKan ? "FOUR_WIND" : "FOUR_KAN";
6846
- for (const o of Object.values(A)) {
6840
+ for (const o of Object.values(E)) {
6847
6841
  const a = {
6848
6842
  id: s,
6849
6843
  type: "END_GAME",
@@ -6862,15 +6856,15 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6862
6856
  throw new Error(`unexpected event ${e.type}`);
6863
6857
  {
6864
6858
  const r = [];
6865
- for (const l of Object.values(A)) {
6859
+ for (const l of Object.values(E)) {
6866
6860
  const h = t.controller.hand(l);
6867
6861
  new pe(h).calc() == 0 && (r.push(l), i[l] = h.toString());
6868
6862
  }
6869
6863
  const o = r.length == 0 || r.length == 4, a = D(0);
6870
- for (const l of Object.values(A))
6864
+ for (const l of Object.values(E))
6871
6865
  r.includes(l) ? a[l] += o ? 0 : 3e3 / r.length : a[l] -= o ? 0 : 3e3 / (4 - r.length);
6872
- const c = r.length == 4 || a[A.E] > 0;
6873
- for (const l of Object.values(A)) {
6866
+ const c = r.length == 4 || a[E.E] > 0;
6867
+ for (const l of Object.values(E)) {
6874
6868
  const h = {
6875
6869
  id: s,
6876
6870
  type: "END_GAME",
@@ -6954,10 +6948,10 @@ class vt {
6954
6948
  initialHands() {
6955
6949
  const t = D("");
6956
6950
  for (let e = 0; e < 3; e++)
6957
- for (const s of Object.values(A))
6951
+ for (const s of Object.values(E))
6958
6952
  for (let i = 0; i < 4; i++)
6959
6953
  t[s] += this.draw().toString();
6960
- for (const e of Object.values(A)) t[e] += this.draw().toString();
6954
+ for (const e of Object.values(E)) t[e] += this.draw().toString();
6961
6955
  return t;
6962
6956
  }
6963
6957
  init(t) {
@@ -7018,13 +7012,13 @@ class ye {
7018
7012
  // bind
7019
7013
  );
7020
7014
  const i = Object.fromEntries(this.playerIDs.map((o) => [o, 25e3]));
7021
- this.observer.scoreManager = new ae(i);
7015
+ this.observer.scoreManager = new re(i);
7022
7016
  const r = (e == null ? void 0 : e.shuffle) == !1 ? this.playerIDs : Jn([...this.playerIDs]);
7023
- this.observer.placeManager = new ce({
7024
- [r[0]]: A.E,
7025
- [r[1]]: A.S,
7026
- [r[2]]: A.W,
7027
- [r[3]]: A.N
7017
+ this.observer.placeManager = new oe({
7018
+ [r[0]]: E.E,
7019
+ [r[1]]: E.S,
7020
+ [r[2]]: E.W,
7021
+ [r[3]]: E.N
7028
7022
  });
7029
7023
  }
7030
7024
  boardParams(t) {
@@ -7095,7 +7089,7 @@ class ye {
7095
7089
  I(o.choices.RON, "ron choice is none"), this.actor.send({
7096
7090
  type: r.type,
7097
7091
  iam: o.wind,
7098
- ret: Jt(o.choices.RON),
7092
+ ret: Gt(o.choices.RON),
7099
7093
  targetInfo: {
7100
7094
  wind: o.discarterInfo.wind,
7101
7095
  tile: w.from(o.discarterInfo.tile)
@@ -7134,7 +7128,7 @@ class ye {
7134
7128
  case "TSUMO":
7135
7129
  I(o.choices.TSUMO, "tsumo choice is none"), this.actor.send({
7136
7130
  type: r.type,
7137
- ret: Jt(o.choices.TSUMO),
7131
+ ret: Gt(o.choices.TSUMO),
7138
7132
  lastTile: w.from(o.drawerInfo.tile),
7139
7133
  iam: a
7140
7134
  });
@@ -7168,7 +7162,7 @@ class ye {
7168
7162
  const h = o.choices[r.type];
7169
7163
  I(h, `${r.type} choice is none`), this.actor.send({
7170
7164
  type: r.type,
7171
- block: z.from(h[0].tiles),
7165
+ block: j.from(h[0].tiles),
7172
7166
  iam: a
7173
7167
  });
7174
7168
  break;
@@ -7204,7 +7198,7 @@ class ye {
7204
7198
  this.actor.send({
7205
7199
  type: "RON",
7206
7200
  iam: o.wind,
7207
- ret: Jt(o.choices.RON),
7201
+ ret: Gt(o.choices.RON),
7208
7202
  targetInfo: {
7209
7203
  wind: o.reacherInfo.wind,
7210
7204
  tile: w.from(o.reacherInfo.tile)
@@ -7221,7 +7215,7 @@ class ye {
7221
7215
  I(o.choices.RON, "ron choice is none"), this.actor.send({
7222
7216
  type: "RON",
7223
7217
  iam: o.wind,
7224
- ret: Jt(o.choices.RON),
7218
+ ret: Gt(o.choices.RON),
7225
7219
  quadWin: !0,
7226
7220
  targetInfo: {
7227
7221
  wind: o.callerInfo.wind,
@@ -7242,10 +7236,10 @@ class ye {
7242
7236
  on: (a) => {
7243
7237
  }
7244
7238
  }, r = s.map((a) => ({ id: a, handler: i })), o = new ye(r);
7245
- return o.playerIDs = s, o.mailBox = e, o.observer.placeManager = new ce(t.players, {
7239
+ return o.playerIDs = s, o.mailBox = e, o.observer.placeManager = new oe(t.players, {
7246
7240
  round: t.round,
7247
7241
  sticks: structuredClone(t.sticks)
7248
- }), o.observer.scoreManager = new ae(t.scores), o.wall = new vt(t.wall), o;
7242
+ }), o.observer.scoreManager = new re(t.scores), o.wall = new vt(t.wall), o;
7249
7243
  }
7250
7244
  start() {
7251
7245
  this.actor.subscribe((s) => {
@@ -7292,7 +7286,7 @@ class ye {
7292
7286
  const o = new _r(i), a = new gn(i, r), c = o.calc(e), l = a.calc(...c);
7293
7287
  if (!l || l.yakus.length == 0) return !1;
7294
7288
  if (i.draw == null) {
7295
- const h = Ut.candidateTiles(this.hand(t)).candidates;
7289
+ const h = jt.candidateTiles(this.hand(t)).candidates;
7296
7290
  if (this.river.discards(t).some((u) => h.some((d) => d.equals(u.t))))
7297
7291
  return !1;
7298
7292
  }
@@ -7358,8 +7352,8 @@ class ye {
7358
7352
  const N = i.get(k.t, k.n);
7359
7353
  for (let v = 0; v < N; v++) m.push(k.clone({ remove: y.RED }));
7360
7354
  }
7361
- const E = i.dec([...m, p.tiles[1], p.tiles[2]]), S = i.hands.length == 0;
7362
- i.inc(E), S && o.splice(d, 1);
7355
+ const A = i.dec([...m, p.tiles[1], p.tiles[2]]), S = i.hands.length == 0;
7356
+ i.inc(A), S && o.splice(d, 1);
7363
7357
  }
7364
7358
  if (o.length == 0) return !1;
7365
7359
  const u = i.get(s.t, 0) > 0 ? this.redPattern(o) : [];
@@ -7380,7 +7374,7 @@ class ye {
7380
7374
  }
7381
7375
  doReach(t) {
7382
7376
  const e = this.hand(t);
7383
- return e.reached || !e.menzen || new pe(e).calc() > 0 ? !1 : Ut.calcCandidates(e, e.hands);
7377
+ return e.reached || !e.menzen || new pe(e).calc() > 0 ? !1 : jt.calcCandidates(e, e.hands);
7384
7378
  }
7385
7379
  doDiscard(t, e) {
7386
7380
  if (this.hand(t).reached) return [this.hand(t).drawn];
@@ -7429,7 +7423,7 @@ class ye {
7429
7423
  });
7430
7424
  if (e.get(o.t, o.n) == 1) {
7431
7425
  const a = R(o) && e.get(o.t, 0) > 0 ? o.clone({ add: y.RED }) : o;
7432
- i.push(new z([...r.tiles, a]));
7426
+ i.push(new j([...r.tiles, a]));
7433
7427
  }
7434
7428
  }
7435
7429
  if (i.length == 0) return !1;
@@ -7477,7 +7471,7 @@ class ye {
7477
7471
  let s = 0;
7478
7472
  for (const i of Object.values(g)) {
7479
7473
  if (i == g.BACK) continue;
7480
- const r = i == g.Z ? zt : q;
7474
+ const r = i == g.Z ? Lt : q;
7481
7475
  for (const o of r)
7482
7476
  e.get(i, o) > 0 && s++;
7483
7477
  }
@@ -7506,9 +7500,9 @@ class ys {
7506
7500
  constructor(t, e) {
7507
7501
  _(this, "id");
7508
7502
  _(this, "river", new Yn());
7509
- _(this, "placeManager", new ce({}));
7503
+ _(this, "placeManager", new oe({}));
7510
7504
  // empty for init
7511
- _(this, "scoreManager", new ae({}));
7505
+ _(this, "scoreManager", new re({}));
7512
7506
  // empty for init
7513
7507
  _(this, "hands", D(new Mt("")));
7514
7508
  // empty for init
@@ -7533,11 +7527,11 @@ class ys {
7533
7527
  case "DISTRIBUTE":
7534
7528
  this.counter.reset();
7535
7529
  const e = w.from(t.doraIndicator);
7536
- this.setHands(t), this.placeManager = new ce(structuredClone(t.places), {
7530
+ this.setHands(t), this.placeManager = new oe(structuredClone(t.places), {
7537
7531
  round: t.round,
7538
7532
  sticks: structuredClone(t.sticks)
7539
- }), this.scoreManager = new ae(structuredClone(t.scores)), this.doraIndicators = [e], this.counter.dec(e);
7540
- for (const i of Object.values(A))
7533
+ }), this.scoreManager = new re(structuredClone(t.scores)), this.doraIndicators = [e], this.counter.dec(e);
7534
+ for (const i of Object.values(E))
7541
7535
  i == t.wind && this.counter.dec(...this.hand(i).hands);
7542
7536
  break;
7543
7537
  case "DRAW": {
@@ -7549,7 +7543,7 @@ class ys {
7549
7543
  const i = w.from(t.tile);
7550
7544
  if (this.river.discard(i, t.iam), this.hands[t.iam].discard(i), t.iam != t.wind) {
7551
7545
  this.counter.dec(i), this.counter.addTileToSafeMap(i, t.iam);
7552
- for (const r of Object.values(A))
7546
+ for (const r of Object.values(E))
7553
7547
  this.hand(r).reached && this.counter.addTileToSafeMap(i, r);
7554
7548
  }
7555
7549
  break;
@@ -7562,7 +7556,7 @@ class ys {
7562
7556
  break;
7563
7557
  }
7564
7558
  case "SHO_KAN": {
7565
- const i = z.from(t.block.tiles);
7559
+ const i = j.from(t.block.tiles);
7566
7560
  this.hands[t.iam].kan(i), t.iam != t.wind && this.counter.dec(i.tiles.filter((r) => r.has(y.HORIZONTAL))[0]);
7567
7561
  break;
7568
7562
  }
@@ -7576,7 +7570,7 @@ class ys {
7576
7570
  const i = w.from(t.tile);
7577
7571
  if (this.river.discard(i, t.iam), this.hands[t.iam].discard(i), t.iam != t.wind) {
7578
7572
  this.counter.dec(i), this.counter.addTileToSafeMap(i, t.iam);
7579
- for (const r of Object.values(A))
7573
+ for (const r of Object.values(E))
7580
7574
  this.hand(r).reached && this.counter.addTileToSafeMap(i, r);
7581
7575
  }
7582
7576
  break;
@@ -7631,7 +7625,7 @@ class Wo extends ys {
7631
7625
  switch (super.handleEvent(e), e.type) {
7632
7626
  case "DISTRIBUTE":
7633
7627
  let s = !0;
7634
- for (const i of Object.values(A))
7628
+ for (const i of Object.values(E))
7635
7629
  s && (s = this.hand(i).get(g.BACK, 0) == 0);
7636
7630
  if (!s) break;
7637
7631
  console.debug(
@@ -7641,7 +7635,7 @@ class Wo extends ys {
7641
7635
  `map: ${JSON.stringify(this.placeManager.playerMap, null, 2)}`,
7642
7636
  `sticks: ${JSON.stringify(this.placeManager.sticks, null, 2)}`
7643
7637
  );
7644
- for (const i of Object.values(A))
7638
+ for (const i of Object.values(E))
7645
7639
  console.debug(
7646
7640
  `${this.placeManager.playerID(i)}(${i})`,
7647
7641
  `init hand: ${this.hand(i).toString()}`
@@ -7688,9 +7682,9 @@ class Wo extends ys {
7688
7682
  );
7689
7683
  break;
7690
7684
  case "END_GAME":
7691
- for (const i of Object.values(A))
7685
+ for (const i of Object.values(E))
7692
7686
  console.debug(
7693
- `${this.placeManager.playerID(i)}(${Le(i)})`,
7687
+ `${this.placeManager.playerID(i)}(${ze(i)})`,
7694
7688
  `end hand: ${this.hand(i).toString()}`
7695
7689
  );
7696
7690
  console.debug(
@@ -7703,7 +7697,7 @@ class Wo extends ys {
7703
7697
  }
7704
7698
  }
7705
7699
  }
7706
- class Qt extends ys {
7700
+ class Xt extends ys {
7707
7701
  constructor(e, s) {
7708
7702
  super(e, s);
7709
7703
  _(this, "river", new Yn());
@@ -7714,14 +7708,14 @@ class Qt extends ys {
7714
7708
  return this.placeManager.wind(this.id);
7715
7709
  }
7716
7710
  setHands(e) {
7717
- for (const s of Object.values(A))
7711
+ for (const s of Object.values(E))
7718
7712
  this.hands[s] = new Mt(e.hands[s]);
7719
7713
  }
7720
7714
  handleDiscard(e) {
7721
- const s = Object.values(A).filter((h) => h == this.myWind ? !1 : this.hand(h).reached), i = new pe(this.hand(this.myWind)).calc();
7715
+ const s = Object.values(E).filter((h) => h == this.myWind ? !1 : this.hand(h).reached), i = new pe(this.hand(this.myWind)).calc();
7722
7716
  if (s.length > 0 && i >= 2)
7723
- return Lt.selectTile(this.counter, s, e);
7724
- const r = Ut.calcCandidates(this.hand(this.myWind), e), a = ue.calcPlayerCandidates(this.counter, r).sort((h, u) => u.sum - h.sum), c = a.filter((h) => h.sum == a[0].sum);
7717
+ return Kt.selectTile(this.counter, s, e);
7718
+ const r = jt.calcCandidates(this.hand(this.myWind), e), a = ue.calcPlayerCandidates(this.counter, r).sort((h, u) => u.sum - h.sum), c = a.filter((h) => h.sum == a[0].sum);
7725
7719
  return ue.selectMinPriority(
7726
7720
  this.counter,
7727
7721
  c,
@@ -7773,7 +7767,7 @@ class qo {
7773
7767
  }
7774
7768
  }
7775
7769
  const Qo = (n) => {
7776
- const [t, e] = Yt(), [s, i] = Yt(), [r, o] = Yt(), [a, c] = Yt(), l = ["player-1", "player-2", "player-3", "player-4"], h = n == null ? void 0 : n.playerInjection, u = (h == null ? void 0 : h.p1) ?? Qt, d = (h == null ? void 0 : h.p2) ?? Qt, p = (h == null ? void 0 : h.p3) ?? Qt, f = (h == null ? void 0 : h.p4) ?? Qt, m = new u(l[0], e), E = new d(l[1], i), S = new p(l[2], o), k = new f(l[3], c), N = [
7770
+ const [t, e] = Vt(), [s, i] = Vt(), [r, o] = Vt(), [a, c] = Vt(), l = ["player-1", "player-2", "player-3", "player-4"], h = n == null ? void 0 : n.playerInjection, u = (h == null ? void 0 : h.p1) ?? Xt, d = (h == null ? void 0 : h.p2) ?? Xt, p = (h == null ? void 0 : h.p3) ?? Xt, f = (h == null ? void 0 : h.p4) ?? Xt, m = new u(l[0], e), A = new d(l[1], i), S = new p(l[2], o), k = new f(l[3], c), N = [
7777
7771
  { handler: t, id: l[0] },
7778
7772
  { handler: s, id: l[1] },
7779
7773
  { handler: r, id: l[2] },
@@ -7785,7 +7779,7 @@ const Qo = (n) => {
7785
7779
  shuffle: n == null ? void 0 : n.shuffle
7786
7780
  }),
7787
7781
  p1: m,
7788
- p2: E,
7782
+ p2: A,
7789
7783
  p3: S,
7790
7784
  p4: k
7791
7785
  };
@@ -7835,19 +7829,19 @@ class ue {
7835
7829
  }
7836
7830
  }
7837
7831
  }
7838
- class Lt {
7832
+ class Kt {
7839
7833
  static selectTile(t, e, s) {
7840
7834
  I(e.length > 0 && s.length > 0);
7841
7835
  let i = s[0], r = Number.POSITIVE_INFINITY;
7842
7836
  for (let o of s) {
7843
- const a = Lt.rank(t, e, o);
7837
+ const a = Kt.rank(t, e, o);
7844
7838
  a < r && (i = o, r = a);
7845
7839
  }
7846
7840
  return i;
7847
7841
  }
7848
7842
  static rank(t, e, s) {
7849
7843
  let i = 0;
7850
- const r = s.isNum() ? Lt.rankN : Lt.rankZ;
7844
+ const r = s.isNum() ? Kt.rankN : Kt.rankZ;
7851
7845
  for (let o of e) {
7852
7846
  const a = r(t, o, s);
7853
7847
  i < a && (i = a);
@@ -7882,83 +7876,83 @@ export {
7882
7876
  _r as BlockCalculator,
7883
7877
  Q as BlockChi,
7884
7878
  et as BlockDaiKan,
7885
- jt as BlockHand,
7879
+ zt as BlockHand,
7886
7880
  kn as BlockIsolated,
7887
7881
  xn as BlockOther,
7888
7882
  B as BlockPair,
7889
7883
  tt as BlockPon,
7890
7884
  pt as BlockRun,
7891
- z as BlockShoKan,
7885
+ j as BlockShoKan,
7892
7886
  V as BlockThree,
7893
7887
  ye as Controller,
7894
7888
  vr as Counter,
7895
- Ut as Efficiency,
7889
+ jt as Efficiency,
7896
7890
  On as FONT_FAMILY,
7897
7891
  T as G,
7898
7892
  Ze as Hand,
7899
7893
  ft as INPUT_SEPARATOR,
7900
7894
  Bn as Image,
7901
- zn as ImageHelper,
7895
+ jn as ImageHelper,
7902
7896
  _t as Mark,
7903
7897
  Ko as MeasureText,
7904
7898
  Uo as MyG,
7905
7899
  Fo as MyImage,
7906
7900
  Go as MyRect,
7907
- zo as MySVG,
7901
+ jo as MySVG,
7908
7902
  Vo as MyText,
7909
7903
  Zo as MyUse,
7910
7904
  q as N19,
7911
- zt as NZ,
7905
+ Lt as NZ,
7912
7906
  y as OP,
7913
7907
  Wo as Observer,
7914
- L as Parser,
7915
- ce as PlaceManager,
7916
- Qt as Player,
7908
+ z as Parser,
7909
+ oe as PlaceManager,
7910
+ Xt as Player,
7917
7911
  ue as PlayerEfficiency,
7918
7912
  gn as PointCalculator,
7919
7913
  x as ROUND,
7920
7914
  Cn as ROUND_MAP,
7921
7915
  Kn as Rect,
7922
7916
  qo as Replayer,
7923
- Lt as RiskRank,
7917
+ Kt as RiskRank,
7924
7918
  Yn as River,
7925
7919
  sn as STICK_CONTEXT,
7926
- zi as SVG,
7927
- ae as ScoreManager,
7920
+ ji as SVG,
7921
+ re as ScoreManager,
7928
7922
  pe as ShantenCalculator,
7929
- ji as Svg,
7930
- Ln as Symbol,
7923
+ Li as Svg,
7924
+ zn as Symbol,
7931
7925
  Ns as TABLE_CONTEXT,
7932
7926
  mt as TILE_CONTEXT,
7933
7927
  g as TYPE,
7934
7928
  It as Text,
7935
7929
  w as Tile,
7936
7930
  Fe as Use,
7937
- A as WIND,
7931
+ E as WIND,
7938
7932
  Be as WIND_MAP,
7939
7933
  vt as Wall,
7940
7934
  an as callBlockIndex,
7941
7935
  wr as convertInput,
7942
7936
  Tn as createControllerMachine,
7943
7937
  Ir as createEventEmitter,
7944
- Yt as createEventPipe,
7938
+ Vt as createEventPipe,
7945
7939
  Dt as createHand,
7946
7940
  Qo as createLocalGame,
7947
7941
  sr as createTable,
7948
7942
  D as createWindMap,
7949
- Jt as deserializeWinResult,
7943
+ Gt as deserializeWinResult,
7950
7944
  Jo as drawBlocks,
7951
7945
  Xo as drawTable,
7952
7946
  F as forHand,
7953
7947
  Ho as incrementalIDGenerator,
7954
7948
  R as isNum5,
7955
- te as nextRound,
7949
+ qt as nextRound,
7956
7950
  Nt as nextWind,
7957
7951
  Yo as optimizeSVG,
7958
7952
  fr as parse,
7959
7953
  pr as parseTableInput,
7960
- Lo as prevRound,
7961
- Le as prevWind,
7954
+ zo as prevRound,
7955
+ ze as prevWind,
7962
7956
  Er as prioritizeDiscardedEvents,
7963
7957
  Ar as prioritizeDrawnEvents,
7964
7958
  xe as serializeWinResult,