mudlet-map-editor 0.5.0 → 0.6.1

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-lib/index.js CHANGED
@@ -76,7 +76,8 @@ var T = C(), E = {
76
76
  activeSwatchSetId: T.activeSwatchSetId,
77
77
  activeSwatchId: T.activeSwatchId,
78
78
  swatchPaletteOpen: !1,
79
- sessionId: null
79
+ sessionId: null,
80
+ spreadShrink: null
80
81
  }, D = new class {
81
82
  state = E;
82
83
  listeners = /* @__PURE__ */ new Set();
@@ -104,7 +105,7 @@ function O(e) {
104
105
  //#endregion
105
106
  //#region node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.js
106
107
  var k = {}, A = {};
107
- A.byteLength = R, A.toByteArray = B, A.fromByteArray = ee;
108
+ A.byteLength = R, A.toByteArray = z, A.fromByteArray = te;
108
109
  for (var j = [], M = [], N = typeof Uint8Array < "u" ? Uint8Array : Array, P = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", F = 0, I = P.length; F < I; ++F) j[F] = P[F], M[P.charCodeAt(F)] = F;
109
110
  M[45] = 62, M[95] = 63;
110
111
  function L(e) {
@@ -119,27 +120,27 @@ function R(e) {
119
120
  var t = L(e), n = t[0], r = t[1];
120
121
  return (n + r) * 3 / 4 - r;
121
122
  }
122
- function z(e, t, n) {
123
+ function ee(e, t, n) {
123
124
  return (t + n) * 3 / 4 - n;
124
125
  }
125
- function B(e) {
126
- var t, n = L(e), r = n[0], i = n[1], a = new N(z(e, r, i)), o = 0, s = i > 0 ? r - 4 : r, c;
126
+ function z(e) {
127
+ var t, n = L(e), r = n[0], i = n[1], a = new N(ee(e, r, i)), o = 0, s = i > 0 ? r - 4 : r, c;
127
128
  for (c = 0; c < s; c += 4) t = M[e.charCodeAt(c)] << 18 | M[e.charCodeAt(c + 1)] << 12 | M[e.charCodeAt(c + 2)] << 6 | M[e.charCodeAt(c + 3)], a[o++] = t >> 16 & 255, a[o++] = t >> 8 & 255, a[o++] = t & 255;
128
129
  return i === 2 && (t = M[e.charCodeAt(c)] << 2 | M[e.charCodeAt(c + 1)] >> 4, a[o++] = t & 255), i === 1 && (t = M[e.charCodeAt(c)] << 10 | M[e.charCodeAt(c + 1)] << 4 | M[e.charCodeAt(c + 2)] >> 2, a[o++] = t >> 8 & 255, a[o++] = t & 255), a;
129
130
  }
130
- function V(e) {
131
+ function B(e) {
131
132
  return j[e >> 18 & 63] + j[e >> 12 & 63] + j[e >> 6 & 63] + j[e & 63];
132
133
  }
133
- function H(e, t, n) {
134
- for (var r, i = [], a = t; a < n; a += 3) r = (e[a] << 16 & 16711680) + (e[a + 1] << 8 & 65280) + (e[a + 2] & 255), i.push(V(r));
134
+ function V(e, t, n) {
135
+ for (var r, i = [], a = t; a < n; a += 3) r = (e[a] << 16 & 16711680) + (e[a + 1] << 8 & 65280) + (e[a + 2] & 255), i.push(B(r));
135
136
  return i.join("");
136
137
  }
137
- function ee(e) {
138
- for (var t, n = e.length, r = n % 3, i = [], a = 16383, o = 0, s = n - r; o < s; o += a) i.push(H(e, o, o + a > s ? s : o + a));
138
+ function te(e) {
139
+ for (var t, n = e.length, r = n % 3, i = [], a = 16383, o = 0, s = n - r; o < s; o += a) i.push(V(e, o, o + a > s ? s : o + a));
139
140
  return r === 1 ? (t = e[n - 1], i.push(j[t >> 2] + j[t << 4 & 63] + "==")) : r === 2 && (t = (e[n - 2] << 8) + e[n - 1], i.push(j[t >> 10] + j[t >> 4 & 63] + j[t << 2 & 63] + "=")), i.join("");
140
141
  }
141
- var te = {};
142
- te.read = function(e, t, n, r, i) {
142
+ var ne = {};
143
+ ne.read = function(e, t, n, r, i) {
143
144
  var a, o, s = i * 8 - r - 1, c = (1 << s) - 1, l = c >> 1, u = -7, d = n ? i - 1 : 0, f = n ? -1 : 1, p = e[t + d];
144
145
  for (d += f, a = p & (1 << -u) - 1, p >>= -u, u += s; u > 0; a = a * 256 + e[t + d], d += f, u -= 8);
145
146
  for (o = a & (1 << -u) - 1, a >>= -u, u += r; u > 0; o = o * 256 + e[t + d], d += f, u -= 8);
@@ -147,13 +148,13 @@ te.read = function(e, t, n, r, i) {
147
148
  else if (a === c) return o ? NaN : (p ? -1 : 1) * Infinity;
148
149
  else o += 2 ** r, a -= l;
149
150
  return (p ? -1 : 1) * o * 2 ** (a - r);
150
- }, te.write = function(e, t, n, r, i, a) {
151
+ }, ne.write = function(e, t, n, r, i, a) {
151
152
  var o, s, c, l = a * 8 - i - 1, u = (1 << l) - 1, d = u >> 1, f = i === 23 ? 2 ** -24 - 2 ** -77 : 0, p = r ? 0 : a - 1, m = r ? 1 : -1, h = +(t < 0 || t === 0 && 1 / t < 0);
152
153
  for (t = Math.abs(t), isNaN(t) || t === Infinity ? (s = +!!isNaN(t), o = u) : (o = Math.floor(Math.log(t) / Math.LN2), t * (c = 2 ** -o) < 1 && (o--, c *= 2), o + d >= 1 ? t += f / c : t += f * 2 ** (1 - d), t * c >= 2 && (o++, c /= 2), o + d >= u ? (s = 0, o = u) : o + d >= 1 ? (s = (t * c - 1) * 2 ** i, o += d) : (s = t * 2 ** (d - 1) * 2 ** i, o = 0)); i >= 8; e[n + p] = s & 255, p += m, s /= 256, i -= 8);
153
154
  for (o = o << i | s, l += i; l > 0; e[n + p] = o & 255, p += m, o /= 256, l -= 8);
154
155
  e[n + p - m] |= h * 128;
155
156
  }, (function(e) {
156
- let t = A, n = te, r = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null;
157
+ let t = A, n = ne, r = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null;
157
158
  e.Buffer = u, e.SlowBuffer = x, e.INSPECT_MAX_BYTES = 50;
158
159
  let i = 2147483647;
159
160
  e.kMaxLength = i;
@@ -335,7 +336,7 @@ te.read = function(e, t, n, r, i) {
335
336
  let r = !1;
336
337
  if ((t === void 0 || t < 0) && (t = 0), t > this.length || ((n === void 0 || n > this.length) && (n = this.length), n <= 0) || (n >>>= 0, t >>>= 0, n <= t)) return "";
337
338
  for (e ||= "utf8";;) switch (e) {
338
- case "hex": return z(this, t, n);
339
+ case "hex": return ee(this, t, n);
339
340
  case "utf8":
340
341
  case "utf-8": return P(this, t, n);
341
342
  case "ascii": return L(this, t, n);
@@ -345,7 +346,7 @@ te.read = function(e, t, n, r, i) {
345
346
  case "ucs2":
346
347
  case "ucs-2":
347
348
  case "utf16le":
348
- case "utf-16le": return B(this, t, n);
349
+ case "utf-16le": return z(this, t, n);
349
350
  default:
350
351
  if (r) throw TypeError("Unknown encoding: " + e);
351
352
  e = (e + "").toLowerCase(), r = !0;
@@ -541,14 +542,14 @@ te.read = function(e, t, n, r, i) {
541
542
  for (let i = t; i < n; ++i) r += String.fromCharCode(e[i]);
542
543
  return r;
543
544
  }
544
- function z(e, t, n) {
545
+ function ee(e, t, n) {
545
546
  let r = e.length;
546
547
  (!t || t < 0) && (t = 0), (!n || n < 0 || n > r) && (n = r);
547
548
  let i = "";
548
549
  for (let r = t; r < n; ++r) i += _e[e[r]];
549
550
  return i;
550
551
  }
551
- function B(e, t, n) {
552
+ function z(e, t, n) {
552
553
  let r = e.slice(t, n), i = "";
553
554
  for (let e = 0; e < r.length - 1; e += 2) i += String.fromCharCode(r[e] + r[e + 1] * 256);
554
555
  return i;
@@ -559,30 +560,30 @@ te.read = function(e, t, n, r, i) {
559
560
  let r = this.subarray(e, t);
560
561
  return Object.setPrototypeOf(r, u.prototype), r;
561
562
  };
562
- function V(e, t, n) {
563
+ function B(e, t, n) {
563
564
  if (e % 1 != 0 || e < 0) throw RangeError("offset is not uint");
564
565
  if (e + t > n) throw RangeError("Trying to access beyond buffer length");
565
566
  }
566
567
  u.prototype.readUintLE = u.prototype.readUIntLE = function(e, t, n) {
567
- e >>>= 0, t >>>= 0, n || V(e, t, this.length);
568
+ e >>>= 0, t >>>= 0, n || B(e, t, this.length);
568
569
  let r = this[e], i = 1, a = 0;
569
570
  for (; ++a < t && (i *= 256);) r += this[e + a] * i;
570
571
  return r;
571
572
  }, u.prototype.readUintBE = u.prototype.readUIntBE = function(e, t, n) {
572
- e >>>= 0, t >>>= 0, n || V(e, t, this.length);
573
+ e >>>= 0, t >>>= 0, n || B(e, t, this.length);
573
574
  let r = this[e + --t], i = 1;
574
575
  for (; t > 0 && (i *= 256);) r += this[e + --t] * i;
575
576
  return r;
576
577
  }, u.prototype.readUint8 = u.prototype.readUInt8 = function(e, t) {
577
- return e >>>= 0, t || V(e, 1, this.length), this[e];
578
+ return e >>>= 0, t || B(e, 1, this.length), this[e];
578
579
  }, u.prototype.readUint16LE = u.prototype.readUInt16LE = function(e, t) {
579
- return e >>>= 0, t || V(e, 2, this.length), this[e] | this[e + 1] << 8;
580
+ return e >>>= 0, t || B(e, 2, this.length), this[e] | this[e + 1] << 8;
580
581
  }, u.prototype.readUint16BE = u.prototype.readUInt16BE = function(e, t) {
581
- return e >>>= 0, t || V(e, 2, this.length), this[e] << 8 | this[e + 1];
582
+ return e >>>= 0, t || B(e, 2, this.length), this[e] << 8 | this[e + 1];
582
583
  }, u.prototype.readUint32LE = u.prototype.readUInt32LE = function(e, t) {
583
- return e >>>= 0, t || V(e, 4, this.length), (this[e] | this[e + 1] << 8 | this[e + 2] << 16) + this[e + 3] * 16777216;
584
+ return e >>>= 0, t || B(e, 4, this.length), (this[e] | this[e + 1] << 8 | this[e + 2] << 16) + this[e + 3] * 16777216;
584
585
  }, u.prototype.readUint32BE = u.prototype.readUInt32BE = function(e, t) {
585
- return e >>>= 0, t || V(e, 4, this.length), this[e] * 16777216 + (this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3]);
586
+ return e >>>= 0, t || B(e, 4, this.length), this[e] * 16777216 + (this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3]);
586
587
  }, u.prototype.readBigUInt64LE = ve(function(e) {
587
588
  e >>>= 0, ce(e, "offset");
588
589
  let t = this[e], n = this[e + 7];
@@ -596,29 +597,29 @@ te.read = function(e, t, n, r, i) {
596
597
  let r = t * 2 ** 24 + this[++e] * 2 ** 16 + this[++e] * 2 ** 8 + this[++e], i = this[++e] * 2 ** 24 + this[++e] * 2 ** 16 + this[++e] * 2 ** 8 + n;
597
598
  return (BigInt(r) << BigInt(32)) + BigInt(i);
598
599
  }), u.prototype.readIntLE = function(e, t, n) {
599
- e >>>= 0, t >>>= 0, n || V(e, t, this.length);
600
+ e >>>= 0, t >>>= 0, n || B(e, t, this.length);
600
601
  let r = this[e], i = 1, a = 0;
601
602
  for (; ++a < t && (i *= 256);) r += this[e + a] * i;
602
603
  return i *= 128, r >= i && (r -= 2 ** (8 * t)), r;
603
604
  }, u.prototype.readIntBE = function(e, t, n) {
604
- e >>>= 0, t >>>= 0, n || V(e, t, this.length);
605
+ e >>>= 0, t >>>= 0, n || B(e, t, this.length);
605
606
  let r = t, i = 1, a = this[e + --r];
606
607
  for (; r > 0 && (i *= 256);) a += this[e + --r] * i;
607
608
  return i *= 128, a >= i && (a -= 2 ** (8 * t)), a;
608
609
  }, u.prototype.readInt8 = function(e, t) {
609
- return e >>>= 0, t || V(e, 1, this.length), this[e] & 128 ? (255 - this[e] + 1) * -1 : this[e];
610
+ return e >>>= 0, t || B(e, 1, this.length), this[e] & 128 ? (255 - this[e] + 1) * -1 : this[e];
610
611
  }, u.prototype.readInt16LE = function(e, t) {
611
- e >>>= 0, t || V(e, 2, this.length);
612
+ e >>>= 0, t || B(e, 2, this.length);
612
613
  let n = this[e] | this[e + 1] << 8;
613
614
  return n & 32768 ? n | 4294901760 : n;
614
615
  }, u.prototype.readInt16BE = function(e, t) {
615
- e >>>= 0, t || V(e, 2, this.length);
616
+ e >>>= 0, t || B(e, 2, this.length);
616
617
  let n = this[e + 1] | this[e] << 8;
617
618
  return n & 32768 ? n | 4294901760 : n;
618
619
  }, u.prototype.readInt32LE = function(e, t) {
619
- return e >>>= 0, t || V(e, 4, this.length), this[e] | this[e + 1] << 8 | this[e + 2] << 16 | this[e + 3] << 24;
620
+ return e >>>= 0, t || B(e, 4, this.length), this[e] | this[e + 1] << 8 | this[e + 2] << 16 | this[e + 3] << 24;
620
621
  }, u.prototype.readInt32BE = function(e, t) {
621
- return e >>>= 0, t || V(e, 4, this.length), this[e] << 24 | this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3];
622
+ return e >>>= 0, t || B(e, 4, this.length), this[e] << 24 | this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3];
622
623
  }, u.prototype.readBigInt64LE = ve(function(e) {
623
624
  e >>>= 0, ce(e, "offset");
624
625
  let t = this[e], n = this[e + 7];
@@ -632,15 +633,15 @@ te.read = function(e, t, n, r, i) {
632
633
  let r = (t << 24) + this[++e] * 2 ** 16 + this[++e] * 2 ** 8 + this[++e];
633
634
  return (BigInt(r) << BigInt(32)) + BigInt(this[++e] * 2 ** 24 + this[++e] * 2 ** 16 + this[++e] * 2 ** 8 + n);
634
635
  }), u.prototype.readFloatLE = function(e, t) {
635
- return e >>>= 0, t || V(e, 4, this.length), n.read(this, e, !0, 23, 4);
636
+ return e >>>= 0, t || B(e, 4, this.length), n.read(this, e, !0, 23, 4);
636
637
  }, u.prototype.readFloatBE = function(e, t) {
637
- return e >>>= 0, t || V(e, 4, this.length), n.read(this, e, !1, 23, 4);
638
+ return e >>>= 0, t || B(e, 4, this.length), n.read(this, e, !1, 23, 4);
638
639
  }, u.prototype.readDoubleLE = function(e, t) {
639
- return e >>>= 0, t || V(e, 8, this.length), n.read(this, e, !0, 52, 8);
640
+ return e >>>= 0, t || B(e, 8, this.length), n.read(this, e, !0, 52, 8);
640
641
  }, u.prototype.readDoubleBE = function(e, t) {
641
- return e >>>= 0, t || V(e, 8, this.length), n.read(this, e, !1, 52, 8);
642
+ return e >>>= 0, t || B(e, 8, this.length), n.read(this, e, !1, 52, 8);
642
643
  };
643
- function H(e, t, n, r, i, a) {
644
+ function V(e, t, n, r, i, a) {
644
645
  if (!u.isBuffer(e)) throw TypeError("\"buffer\" argument must be a Buffer instance");
645
646
  if (t > i || t < a) throw RangeError("\"value\" argument is out of bounds");
646
647
  if (n + r > e.length) throw RangeError("Index out of range");
@@ -648,7 +649,7 @@ te.read = function(e, t, n, r, i) {
648
649
  u.prototype.writeUintLE = u.prototype.writeUIntLE = function(e, t, n, r) {
649
650
  if (e = +e, t >>>= 0, n >>>= 0, !r) {
650
651
  let r = 2 ** (8 * n) - 1;
651
- H(this, e, t, n, r, 0);
652
+ V(this, e, t, n, r, 0);
652
653
  }
653
654
  let i = 1, a = 0;
654
655
  for (this[t] = e & 255; ++a < n && (i *= 256);) this[t + a] = e / i & 255;
@@ -656,30 +657,30 @@ te.read = function(e, t, n, r, i) {
656
657
  }, u.prototype.writeUintBE = u.prototype.writeUIntBE = function(e, t, n, r) {
657
658
  if (e = +e, t >>>= 0, n >>>= 0, !r) {
658
659
  let r = 2 ** (8 * n) - 1;
659
- H(this, e, t, n, r, 0);
660
+ V(this, e, t, n, r, 0);
660
661
  }
661
662
  let i = n - 1, a = 1;
662
663
  for (this[t + i] = e & 255; --i >= 0 && (a *= 256);) this[t + i] = e / a & 255;
663
664
  return t + n;
664
665
  }, u.prototype.writeUint8 = u.prototype.writeUInt8 = function(e, t, n) {
665
- return e = +e, t >>>= 0, n || H(this, e, t, 1, 255, 0), this[t] = e & 255, t + 1;
666
+ return e = +e, t >>>= 0, n || V(this, e, t, 1, 255, 0), this[t] = e & 255, t + 1;
666
667
  }, u.prototype.writeUint16LE = u.prototype.writeUInt16LE = function(e, t, n) {
667
- return e = +e, t >>>= 0, n || H(this, e, t, 2, 65535, 0), this[t] = e & 255, this[t + 1] = e >>> 8, t + 2;
668
+ return e = +e, t >>>= 0, n || V(this, e, t, 2, 65535, 0), this[t] = e & 255, this[t + 1] = e >>> 8, t + 2;
668
669
  }, u.prototype.writeUint16BE = u.prototype.writeUInt16BE = function(e, t, n) {
669
- return e = +e, t >>>= 0, n || H(this, e, t, 2, 65535, 0), this[t] = e >>> 8, this[t + 1] = e & 255, t + 2;
670
+ return e = +e, t >>>= 0, n || V(this, e, t, 2, 65535, 0), this[t] = e >>> 8, this[t + 1] = e & 255, t + 2;
670
671
  }, u.prototype.writeUint32LE = u.prototype.writeUInt32LE = function(e, t, n) {
671
- return e = +e, t >>>= 0, n || H(this, e, t, 4, 4294967295, 0), this[t + 3] = e >>> 24, this[t + 2] = e >>> 16, this[t + 1] = e >>> 8, this[t] = e & 255, t + 4;
672
+ return e = +e, t >>>= 0, n || V(this, e, t, 4, 4294967295, 0), this[t + 3] = e >>> 24, this[t + 2] = e >>> 16, this[t + 1] = e >>> 8, this[t] = e & 255, t + 4;
672
673
  }, u.prototype.writeUint32BE = u.prototype.writeUInt32BE = function(e, t, n) {
673
- return e = +e, t >>>= 0, n || H(this, e, t, 4, 4294967295, 0), this[t] = e >>> 24, this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, this[t + 3] = e & 255, t + 4;
674
+ return e = +e, t >>>= 0, n || V(this, e, t, 4, 4294967295, 0), this[t] = e >>> 24, this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, this[t + 3] = e & 255, t + 4;
674
675
  };
675
- function ee(e, t, n, r, i) {
676
+ function te(e, t, n, r, i) {
676
677
  se(t, r, i, e, n, 7);
677
678
  let a = Number(t & BigInt(4294967295));
678
679
  e[n++] = a, a >>= 8, e[n++] = a, a >>= 8, e[n++] = a, a >>= 8, e[n++] = a;
679
680
  let o = Number(t >> BigInt(32) & BigInt(4294967295));
680
681
  return e[n++] = o, o >>= 8, e[n++] = o, o >>= 8, e[n++] = o, o >>= 8, e[n++] = o, n;
681
682
  }
682
- function ne(e, t, n, r, i) {
683
+ function re(e, t, n, r, i) {
683
684
  se(t, r, i, e, n, 7);
684
685
  let a = Number(t & BigInt(4294967295));
685
686
  e[n + 7] = a, a >>= 8, e[n + 6] = a, a >>= 8, e[n + 5] = a, a >>= 8, e[n + 4] = a;
@@ -687,13 +688,13 @@ te.read = function(e, t, n, r, i) {
687
688
  return e[n + 3] = o, o >>= 8, e[n + 2] = o, o >>= 8, e[n + 1] = o, o >>= 8, e[n] = o, n + 8;
688
689
  }
689
690
  u.prototype.writeBigUInt64LE = ve(function(e, t = 0) {
690
- return ee(this, e, t, BigInt(0), BigInt("0xffffffffffffffff"));
691
+ return te(this, e, t, BigInt(0), BigInt("0xffffffffffffffff"));
691
692
  }), u.prototype.writeBigUInt64BE = ve(function(e, t = 0) {
692
- return ne(this, e, t, BigInt(0), BigInt("0xffffffffffffffff"));
693
+ return re(this, e, t, BigInt(0), BigInt("0xffffffffffffffff"));
693
694
  }), u.prototype.writeIntLE = function(e, t, n, r) {
694
695
  if (e = +e, t >>>= 0, !r) {
695
696
  let r = 2 ** (8 * n - 1);
696
- H(this, e, t, n, r - 1, -r);
697
+ V(this, e, t, n, r - 1, -r);
697
698
  }
698
699
  let i = 0, a = 1, o = 0;
699
700
  for (this[t] = e & 255; ++i < n && (a *= 256);) e < 0 && o === 0 && this[t + i - 1] !== 0 && (o = 1), this[t + i] = (e / a >> 0) - o & 255;
@@ -701,44 +702,44 @@ te.read = function(e, t, n, r, i) {
701
702
  }, u.prototype.writeIntBE = function(e, t, n, r) {
702
703
  if (e = +e, t >>>= 0, !r) {
703
704
  let r = 2 ** (8 * n - 1);
704
- H(this, e, t, n, r - 1, -r);
705
+ V(this, e, t, n, r - 1, -r);
705
706
  }
706
707
  let i = n - 1, a = 1, o = 0;
707
708
  for (this[t + i] = e & 255; --i >= 0 && (a *= 256);) e < 0 && o === 0 && this[t + i + 1] !== 0 && (o = 1), this[t + i] = (e / a >> 0) - o & 255;
708
709
  return t + n;
709
710
  }, u.prototype.writeInt8 = function(e, t, n) {
710
- return e = +e, t >>>= 0, n || H(this, e, t, 1, 127, -128), e < 0 && (e = 255 + e + 1), this[t] = e & 255, t + 1;
711
+ return e = +e, t >>>= 0, n || V(this, e, t, 1, 127, -128), e < 0 && (e = 255 + e + 1), this[t] = e & 255, t + 1;
711
712
  }, u.prototype.writeInt16LE = function(e, t, n) {
712
- return e = +e, t >>>= 0, n || H(this, e, t, 2, 32767, -32768), this[t] = e & 255, this[t + 1] = e >>> 8, t + 2;
713
+ return e = +e, t >>>= 0, n || V(this, e, t, 2, 32767, -32768), this[t] = e & 255, this[t + 1] = e >>> 8, t + 2;
713
714
  }, u.prototype.writeInt16BE = function(e, t, n) {
714
- return e = +e, t >>>= 0, n || H(this, e, t, 2, 32767, -32768), this[t] = e >>> 8, this[t + 1] = e & 255, t + 2;
715
+ return e = +e, t >>>= 0, n || V(this, e, t, 2, 32767, -32768), this[t] = e >>> 8, this[t + 1] = e & 255, t + 2;
715
716
  }, u.prototype.writeInt32LE = function(e, t, n) {
716
- return e = +e, t >>>= 0, n || H(this, e, t, 4, 2147483647, -2147483648), this[t] = e & 255, this[t + 1] = e >>> 8, this[t + 2] = e >>> 16, this[t + 3] = e >>> 24, t + 4;
717
+ return e = +e, t >>>= 0, n || V(this, e, t, 4, 2147483647, -2147483648), this[t] = e & 255, this[t + 1] = e >>> 8, this[t + 2] = e >>> 16, this[t + 3] = e >>> 24, t + 4;
717
718
  }, u.prototype.writeInt32BE = function(e, t, n) {
718
- return e = +e, t >>>= 0, n || H(this, e, t, 4, 2147483647, -2147483648), e < 0 && (e = 4294967295 + e + 1), this[t] = e >>> 24, this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, this[t + 3] = e & 255, t + 4;
719
+ return e = +e, t >>>= 0, n || V(this, e, t, 4, 2147483647, -2147483648), e < 0 && (e = 4294967295 + e + 1), this[t] = e >>> 24, this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, this[t + 3] = e & 255, t + 4;
719
720
  }, u.prototype.writeBigInt64LE = ve(function(e, t = 0) {
720
- return ee(this, e, t, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
721
+ return te(this, e, t, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
721
722
  }), u.prototype.writeBigInt64BE = ve(function(e, t = 0) {
722
- return ne(this, e, t, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
723
+ return re(this, e, t, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
723
724
  });
724
- function re(e, t, n, r, i, a) {
725
+ function ie(e, t, n, r, i, a) {
725
726
  if (n + r > e.length || n < 0) throw RangeError("Index out of range");
726
727
  }
727
- function U(e, t, r, i, a) {
728
- return t = +t, r >>>= 0, a || re(e, t, r, 4), n.write(e, t, r, i, 23, 4), r + 4;
728
+ function H(e, t, r, i, a) {
729
+ return t = +t, r >>>= 0, a || ie(e, t, r, 4), n.write(e, t, r, i, 23, 4), r + 4;
729
730
  }
730
731
  u.prototype.writeFloatLE = function(e, t, n) {
731
- return U(this, e, t, !0, n);
732
+ return H(this, e, t, !0, n);
732
733
  }, u.prototype.writeFloatBE = function(e, t, n) {
733
- return U(this, e, t, !1, n);
734
+ return H(this, e, t, !1, n);
734
735
  };
735
- function W(e, t, r, i, a) {
736
- return t = +t, r >>>= 0, a || re(e, t, r, 8), n.write(e, t, r, i, 52, 8), r + 8;
736
+ function U(e, t, r, i, a) {
737
+ return t = +t, r >>>= 0, a || ie(e, t, r, 8), n.write(e, t, r, i, 52, 8), r + 8;
737
738
  }
738
739
  u.prototype.writeDoubleLE = function(e, t, n) {
739
- return W(this, e, t, !0, n);
740
+ return U(this, e, t, !0, n);
740
741
  }, u.prototype.writeDoubleBE = function(e, t, n) {
741
- return W(this, e, t, !1, n);
742
+ return U(this, e, t, !1, n);
742
743
  }, u.prototype.copy = function(e, t, n, r) {
743
744
  if (!u.isBuffer(e)) throw TypeError("argument should be a Buffer");
744
745
  if (n ||= 0, !r && r !== 0 && (r = this.length), t >= e.length && (t = e.length), t ||= 0, r > 0 && r < n && (r = n), r === n || e.length === 0 || this.length === 0) return 0;
@@ -769,9 +770,9 @@ te.read = function(e, t, n, r, i) {
769
770
  }
770
771
  return this;
771
772
  };
772
- let G = {};
773
- function ie(e, t, n) {
774
- G[e] = class extends n {
773
+ let W = {};
774
+ function G(e, t, n) {
775
+ W[e] = class extends n {
775
776
  constructor() {
776
777
  super(), Object.defineProperty(this, "message", {
777
778
  value: t.apply(this, arguments),
@@ -795,11 +796,11 @@ te.read = function(e, t, n, r, i) {
795
796
  }
796
797
  };
797
798
  }
798
- ie("ERR_BUFFER_OUT_OF_BOUNDS", function(e) {
799
+ G("ERR_BUFFER_OUT_OF_BOUNDS", function(e) {
799
800
  return e ? `${e} is outside of buffer bounds` : "Attempt to access memory outside buffer bounds";
800
- }, RangeError), ie("ERR_INVALID_ARG_TYPE", function(e, t) {
801
+ }, RangeError), G("ERR_INVALID_ARG_TYPE", function(e, t) {
801
802
  return `The "${e}" argument must be of type number. Received type ${typeof t}`;
802
- }, TypeError), ie("ERR_OUT_OF_RANGE", function(e, t, n) {
803
+ }, TypeError), G("ERR_OUT_OF_RANGE", function(e, t, n) {
803
804
  let r = `The value of "${e}" is out of range.`, i = n;
804
805
  return Number.isInteger(n) && Math.abs(n) > 2 ** 32 ? i = ae(String(n)) : typeof n == "bigint" && (i = String(n), (n > BigInt(2) ** BigInt(32) || n < -(BigInt(2) ** BigInt(32))) && (i = ae(i)), i += "n"), r += ` It must be ${t}. Received ${i}`, r;
805
806
  }, RangeError);
@@ -814,15 +815,15 @@ te.read = function(e, t, n, r, i) {
814
815
  function se(e, t, n, r, i, a) {
815
816
  if (e > n || e < t) {
816
817
  let r = typeof t == "bigint" ? "n" : "", i;
817
- throw i = a > 3 ? t === 0 || t === BigInt(0) ? `>= 0${r} and < 2${r} ** ${(a + 1) * 8}${r}` : `>= -(2${r} ** ${(a + 1) * 8 - 1}${r}) and < 2 ** ${(a + 1) * 8 - 1}${r}` : `>= ${t}${r} and <= ${n}${r}`, new G.ERR_OUT_OF_RANGE("value", i, e);
818
+ throw i = a > 3 ? t === 0 || t === BigInt(0) ? `>= 0${r} and < 2${r} ** ${(a + 1) * 8}${r}` : `>= -(2${r} ** ${(a + 1) * 8 - 1}${r}) and < 2 ** ${(a + 1) * 8 - 1}${r}` : `>= ${t}${r} and <= ${n}${r}`, new W.ERR_OUT_OF_RANGE("value", i, e);
818
819
  }
819
820
  oe(r, i, a);
820
821
  }
821
822
  function ce(e, t) {
822
- if (typeof e != "number") throw new G.ERR_INVALID_ARG_TYPE(t, "number", e);
823
+ if (typeof e != "number") throw new W.ERR_INVALID_ARG_TYPE(t, "number", e);
823
824
  }
824
825
  function le(e, t, n) {
825
- throw Math.floor(e) === e ? t < 0 ? new G.ERR_BUFFER_OUT_OF_BOUNDS() : new G.ERR_OUT_OF_RANGE(n || "offset", `>= ${+!!n} and <= ${t}`, e) : (ce(e, n), new G.ERR_OUT_OF_RANGE(n || "offset", "an integer", e));
826
+ throw Math.floor(e) === e ? t < 0 ? new W.ERR_BUFFER_OUT_OF_BOUNDS() : new W.ERR_OUT_OF_RANGE(n || "offset", `>= ${+!!n} and <= ${t}`, e) : (ce(e, n), new W.ERR_OUT_OF_RANGE(n || "offset", "an integer", e));
826
827
  }
827
828
  let ue = /[^+/0-9A-Za-z-_]/g;
828
829
  function de(e) {
@@ -907,20 +908,20 @@ te.read = function(e, t, n, r, i) {
907
908
  throw Error("BigInt not supported");
908
909
  }
909
910
  })(k), k.Buffer, k.Blob, k.BlobOptions;
910
- var ne = k.Buffer;
911
+ var re = k.Buffer;
911
912
  k.File, k.FileOptions, k.INSPECT_MAX_BYTES, k.SlowBuffer, k.TranscodeEncoding, k.atob, k.btoa, k.constants, k.isAscii, k.isUtf8, k.kMaxLength, k.kStringMaxLength, k.resolveObjectURL, k.transcode;
912
913
  //#endregion
913
914
  //#region src/mapIO.ts
914
- function re(e) {
915
- return o(ne.from(e));
915
+ function ie(e) {
916
+ return o(re.from(e));
916
917
  }
917
- function U(e) {
918
+ function H(e) {
918
919
  return new Uint8Array(c(e));
919
920
  }
920
- function W(e) {
921
+ function U(e) {
921
922
  return s(e);
922
923
  }
923
- function G() {
924
+ function W() {
924
925
  return {
925
926
  version: 20,
926
927
  rooms: {},
@@ -970,7 +971,7 @@ function G() {
970
971
  }
971
972
  //#endregion
972
973
  //#region src/editor/loadFile.ts
973
- async function ie(e, t) {
974
+ async function G(e, t) {
974
975
  try {
975
976
  D.setState({ status: "Fetching…" });
976
977
  let n = await fetch(e);
@@ -988,7 +989,7 @@ async function ie(e, t) {
988
989
  }
989
990
  let s = new Uint8Array(o), c = 0;
990
991
  for (let e of a) s.set(e, c), c += e.length;
991
- let l = e.split("/").pop()?.split("?")[0] || "map.dat", u = re(s.buffer), d = Number(Object.keys(u.areaNames)[0] ?? -1), f = Number.isNaN(d) ? null : d;
992
+ let l = e.split("/").pop()?.split("?")[0] || "map.dat", u = ie(s.buffer), d = Number(Object.keys(u.areaNames)[0] ?? -1), f = Number.isNaN(d) ? null : d;
992
993
  D.setState({
993
994
  map: u,
994
995
  loaded: { fileName: l },
@@ -1010,7 +1011,7 @@ async function ie(e, t) {
1010
1011
  async function ae(e) {
1011
1012
  try {
1012
1013
  D.setState({ status: `Reading ${e.name}…` });
1013
- let t = re(await e.arrayBuffer()), n = Number(Object.keys(t.areaNames)[0] ?? -1), r = Number.isNaN(n) ? null : n;
1014
+ let t = ie(await e.arrayBuffer()), n = Number(Object.keys(t.areaNames)[0] ?? -1), r = Number.isNaN(n) ? null : n;
1014
1015
  D.setState({
1015
1016
  map: t,
1016
1017
  loaded: { fileName: e.name },
@@ -1306,7 +1307,7 @@ function ue({ title: e = "Mudlet Map Editor", onHelpClick: t, onLoadFromUrl: a,
1306
1307
  l,
1307
1308
  h,
1308
1309
  P
1309
- ]), L = r(null), [R, z] = i(""), B = () => {
1310
+ ]), L = r(null), [R, ee] = i(""), z = () => {
1310
1311
  let e = parseInt(R, 10);
1311
1312
  if (Number.isNaN(e)) return;
1312
1313
  let t = D.getState();
@@ -1328,9 +1329,9 @@ function ue({ title: e = "Mudlet Map Editor", onHelpClick: t, onLoadFromUrl: a,
1328
1329
  ids: [e]
1329
1330
  },
1330
1331
  pending: null
1331
- }), D.bumpStructure(), z("");
1332
- }, V = () => {
1333
- let e = G();
1332
+ }), D.bumpStructure(), ee("");
1333
+ }, B = () => {
1334
+ let e = W();
1334
1335
  D.setState({
1335
1336
  map: e,
1336
1337
  loaded: { fileName: "new-map.dat" },
@@ -1345,7 +1346,7 @@ function ue({ title: e = "Mudlet Map Editor", onHelpClick: t, onLoadFromUrl: a,
1345
1346
  status: "New map created · 0 rooms · 1 area",
1346
1347
  sessionId: null
1347
1348
  }), D.bumpStructure();
1348
- }, H = ae;
1349
+ }, V = ae;
1349
1350
  return /* @__PURE__ */ f("div", {
1350
1351
  className: "toolbar",
1351
1352
  children: [/* @__PURE__ */ f("div", {
@@ -1360,7 +1361,7 @@ function ue({ title: e = "Mudlet Map Editor", onHelpClick: t, onLoadFromUrl: a,
1360
1361
  /* @__PURE__ */ d("button", {
1361
1362
  type: "button",
1362
1363
  title: "New Map",
1363
- onClick: V,
1364
+ onClick: B,
1364
1365
  children: /* @__PURE__ */ f("svg", {
1365
1366
  width: "16",
1366
1367
  height: "16",
@@ -1428,7 +1429,7 @@ function ue({ title: e = "Mudlet Map Editor", onHelpClick: t, onLoadFromUrl: a,
1428
1429
  style: { display: "none" },
1429
1430
  onChange: (e) => {
1430
1431
  let t = e.target.files?.[0];
1431
- t && H(t), e.target.value = "";
1432
+ t && V(t), e.target.value = "";
1432
1433
  }
1433
1434
  })]
1434
1435
  }),
@@ -1483,7 +1484,7 @@ function ue({ title: e = "Mudlet Map Editor", onHelpClick: t, onLoadFromUrl: a,
1483
1484
  onClick: () => {
1484
1485
  let e = D.getState();
1485
1486
  if (!(!e.map || !e.loaded)) try {
1486
- let t = U(e.map), n = t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength), r = new Blob([n], { type: "application/octet-stream" }), i = URL.createObjectURL(r), a = document.createElement("a");
1487
+ let t = H(e.map), n = t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength), r = new Blob([n], { type: "application/octet-stream" }), i = URL.createObjectURL(r), a = document.createElement("a");
1487
1488
  a.href = i, a.download = e.loaded.fileName.replace(/\.dat$/i, "") + "-edited.dat", document.body.appendChild(a), a.click(), a.remove(), URL.revokeObjectURL(i), D.setState((e) => ({
1488
1489
  savedUndoLength: e.undo.length,
1489
1490
  status: `Saved ${a.download}`
@@ -1594,15 +1595,15 @@ function ue({ title: e = "Mudlet Map Editor", onHelpClick: t, onLoadFromUrl: a,
1594
1595
  min: 1,
1595
1596
  placeholder: "ID",
1596
1597
  value: R,
1597
- onChange: (e) => z(e.target.value),
1598
+ onChange: (e) => ee(e.target.value),
1598
1599
  onKeyDown: (e) => {
1599
- e.key === "Enter" && B();
1600
+ e.key === "Enter" && z();
1600
1601
  }
1601
1602
  }),
1602
1603
  /* @__PURE__ */ d("button", {
1603
1604
  type: "button",
1604
1605
  className: "toolbar-goto-btn",
1605
- onClick: B,
1606
+ onClick: z,
1606
1607
  disabled: R === "",
1607
1608
  children: "Go"
1608
1609
  })
@@ -1623,25 +1624,9 @@ function ue({ title: e = "Mudlet Map Editor", onHelpClick: t, onLoadFromUrl: a,
1623
1624
  className: "tool-btn",
1624
1625
  title: "Search rooms and labels (Ctrl+F)",
1625
1626
  onClick: s,
1626
- children: [/* @__PURE__ */ f("svg", {
1627
- width: "13",
1628
- height: "13",
1629
- viewBox: "0 0 16 16",
1630
- fill: "none",
1631
- "aria-hidden": "true",
1632
- style: { flexShrink: 0 },
1633
- children: [/* @__PURE__ */ d("circle", {
1634
- cx: "6.5",
1635
- cy: "6.5",
1636
- r: "4.5",
1637
- stroke: "currentColor",
1638
- strokeWidth: "1.4"
1639
- }), /* @__PURE__ */ d("path", {
1640
- d: "M10.5 10.5L14 14",
1641
- stroke: "currentColor",
1642
- strokeWidth: "1.4",
1643
- strokeLinecap: "round"
1644
- })]
1627
+ children: [/* @__PURE__ */ d("span", {
1628
+ className: "tool-key",
1629
+ children: "^F"
1645
1630
  }), /* @__PURE__ */ d("span", { children: "Search" })]
1646
1631
  })
1647
1632
  ] }),
@@ -1778,7 +1763,7 @@ function ue({ title: e = "Mudlet Map Editor", onHelpClick: t, onLoadFromUrl: a,
1778
1763
  //#region src/components/UrlLoadModal.tsx
1779
1764
  function de({ onClose: e, initialUrl: n }) {
1780
1765
  let [r, a] = i(n ?? ""), [o, s] = i(!1), [c, l] = i(null), u = async (t = r.trim()) => {
1781
- t && (a(t), s(!0), l(0), await ie(t, l), s(!1), l(null), D.getState().map && e());
1766
+ t && (a(t), s(!0), l(0), await G(t, l), s(!1), l(null), D.getState().map && e());
1782
1767
  };
1783
1768
  return t(() => {
1784
1769
  n && u(n);
@@ -2714,7 +2699,7 @@ function Y(e, t) {
2714
2699
  redo: []
2715
2700
  })), r;
2716
2701
  }
2717
- function De(e, t) {
2702
+ function X(e, t) {
2718
2703
  if (e.length === 0) return !1;
2719
2704
  if (e.length === 1) return Y(e[0], t);
2720
2705
  let n = D.getState();
@@ -2730,7 +2715,7 @@ function De(e, t) {
2730
2715
  redo: []
2731
2716
  })), r;
2732
2717
  }
2733
- function Oe(e) {
2718
+ function De(e) {
2734
2719
  let t = D.getState();
2735
2720
  if (!t.map || t.undo.length === 0) return {
2736
2721
  changed: !1,
@@ -2745,7 +2730,7 @@ function Oe(e) {
2745
2730
  structural: r
2746
2731
  };
2747
2732
  }
2748
- function ke(e) {
2733
+ function Oe(e) {
2749
2734
  let t = D.getState();
2750
2735
  if (!t.map || t.redo.length === 0) return {
2751
2736
  changed: !1,
@@ -2760,7 +2745,7 @@ function ke(e) {
2760
2745
  structural: r
2761
2746
  };
2762
2747
  }
2763
- function Ae(e, t, n, r) {
2748
+ function ke(e, t, n, r) {
2764
2749
  if (n === 0 && r === 0) return [];
2765
2750
  let i = e.rooms[t];
2766
2751
  if (!i) return [];
@@ -2795,14 +2780,14 @@ function Ae(e, t, n, r) {
2795
2780
  }
2796
2781
  return a;
2797
2782
  }
2798
- function je(e, t) {
2783
+ function Ae(e, t) {
2799
2784
  return Ce(e, t).map((t) => ({
2800
2785
  roomId: t.roomId,
2801
2786
  dir: t.dir,
2802
2787
  was: J(e.rooms[t.roomId], t.dir)
2803
2788
  }));
2804
2789
  }
2805
- function Me(e, t) {
2790
+ function je(e, t) {
2806
2791
  let n = new Set(t), r = new Map(t.map((e) => [e, []]));
2807
2792
  for (let t of Object.keys(e.rooms)) {
2808
2793
  let i = Number(t);
@@ -2821,7 +2806,7 @@ function Me(e, t) {
2821
2806
  }
2822
2807
  //#endregion
2823
2808
  //#region src/components/panelShared.tsx
2824
- function Ne({ id: e, name: t, className: n }) {
2809
+ function Me({ id: e, name: t, className: n }) {
2825
2810
  return /* @__PURE__ */ f("button", {
2826
2811
  type: "button",
2827
2812
  className: n ?? "exit-target",
@@ -2870,7 +2855,7 @@ function Ne({ id: e, name: t, className: n }) {
2870
2855
  ]
2871
2856
  });
2872
2857
  }
2873
- function X({ label: e, children: t, as: n = "label" }) {
2858
+ function Z({ label: e, children: t, as: n = "label" }) {
2874
2859
  return /* @__PURE__ */ f(n, {
2875
2860
  className: "field",
2876
2861
  children: [/* @__PURE__ */ d("span", {
@@ -2879,7 +2864,7 @@ function X({ label: e, children: t, as: n = "label" }) {
2879
2864
  }), t]
2880
2865
  });
2881
2866
  }
2882
- function Pe({ checked: e, onChange: t, description: n }) {
2867
+ function Ne({ checked: e, onChange: t, description: n }) {
2883
2868
  return /* @__PURE__ */ f("label", {
2884
2869
  className: "field checkbox-field",
2885
2870
  children: [/* @__PURE__ */ d("input", {
@@ -2889,7 +2874,7 @@ function Pe({ checked: e, onChange: t, description: n }) {
2889
2874
  }), /* @__PURE__ */ d("span", { children: n })]
2890
2875
  });
2891
2876
  }
2892
- function Fe({ activeTool: e }) {
2877
+ function Pe({ activeTool: e }) {
2893
2878
  return /* @__PURE__ */ d("p", {
2894
2879
  className: "hint-tool",
2895
2880
  children: {
@@ -2904,7 +2889,7 @@ function Fe({ activeTool: e }) {
2904
2889
  }[e] ?? ""
2905
2890
  });
2906
2891
  }
2907
- function Ie({ data: e, onCommit: t }) {
2892
+ function Fe({ data: e, onCommit: t }) {
2908
2893
  let [n, r] = i(""), [a, o] = i(""), s = () => {
2909
2894
  let e = n.trim();
2910
2895
  e && (t(e, null, a), r(""), o(""));
@@ -2971,14 +2956,14 @@ function Ie({ data: e, onCommit: t }) {
2971
2956
  ]
2972
2957
  });
2973
2958
  }
2974
- function Le(e) {
2959
+ function Ie(e) {
2975
2960
  return "#" + [
2976
2961
  e.r,
2977
2962
  e.g,
2978
2963
  e.b
2979
2964
  ].map((e) => e.toString(16).padStart(2, "0")).join("");
2980
2965
  }
2981
- function Re(e) {
2966
+ function Le(e) {
2982
2967
  return {
2983
2968
  spec: 1,
2984
2969
  alpha: 255,
@@ -2990,7 +2975,7 @@ function Re(e) {
2990
2975
  }
2991
2976
  //#endregion
2992
2977
  //#region src/components/AreaManagerModal.tsx
2993
- function ze({ sceneRef: e }) {
2978
+ function Re({ sceneRef: e }) {
2994
2979
  let t = O((e) => e.map), [n, r] = i(""), [a, o] = i(null), [s, c] = i(""), [l, u] = i(null), [p, m] = i(null);
2995
2980
  if (!t) return /* @__PURE__ */ d("div", {
2996
2981
  className: "modal-empty",
@@ -3062,7 +3047,7 @@ function ze({ sceneRef: e }) {
3062
3047
  }, y = () => {
3063
3048
  if (!l || l.moveTarget === "") return;
3064
3049
  let t = Number(l.moveTarget);
3065
- De([{
3050
+ X([{
3066
3051
  kind: "moveRoomsToArea",
3067
3052
  roomIds: [...l.rooms],
3068
3053
  fromAreaId: l.id,
@@ -3161,7 +3146,7 @@ function ze({ sceneRef: e }) {
3161
3146
  }),
3162
3147
  p === n && /* @__PURE__ */ d("div", {
3163
3148
  className: "area-ud-section",
3164
- children: /* @__PURE__ */ d(Ie, {
3149
+ children: /* @__PURE__ */ d(Fe, {
3165
3150
  data: t.areas[n]?.userData ?? {},
3166
3151
  onCommit: (t, r, i) => {
3167
3152
  Y({
@@ -3233,14 +3218,14 @@ function ze({ sceneRef: e }) {
3233
3218
  }
3234
3219
  //#endregion
3235
3220
  //#region src/components/EnvManagerModal.tsx
3236
- function Be(e) {
3221
+ function ze(e) {
3237
3222
  return "#" + [
3238
3223
  e.r,
3239
3224
  e.g,
3240
3225
  e.b
3241
3226
  ].map((e) => e.toString(16).padStart(2, "0")).join("");
3242
3227
  }
3243
- function Ve(e) {
3228
+ function Be(e) {
3244
3229
  return {
3245
3230
  spec: 1,
3246
3231
  alpha: 255,
@@ -3250,7 +3235,7 @@ function Ve(e) {
3250
3235
  pad: 0
3251
3236
  };
3252
3237
  }
3253
- function He({ sceneRef: e }) {
3238
+ function Ve({ sceneRef: e }) {
3254
3239
  let t = O((e) => e.map), n = O((e) => e.dataVersion), [r, a] = i(""), [o, s] = i(null), [c, l] = i(!1), [u, p] = i(""), [m, h] = i("#888888");
3255
3240
  if (!t) return /* @__PURE__ */ d("div", {
3256
3241
  className: "modal-empty",
@@ -3271,7 +3256,7 @@ function He({ sceneRef: e }) {
3271
3256
  }, S = () => {
3272
3257
  s(null), p(String(x())), l(!0);
3273
3258
  }, C = (n, r) => {
3274
- let i = Ve(r);
3259
+ let i = Be(r);
3275
3260
  Y({
3276
3261
  kind: "setCustomEnvColor",
3277
3262
  envId: n,
@@ -3292,7 +3277,7 @@ function He({ sceneRef: e }) {
3292
3277
  D.setState({ status: "Env IDs 1–256 are reserved. Use 257 or higher." });
3293
3278
  return;
3294
3279
  }
3295
- let r = Ve(m);
3280
+ let r = Be(m);
3296
3281
  Y({
3297
3282
  kind: "setCustomEnvColor",
3298
3283
  envId: n,
@@ -3397,7 +3382,7 @@ function He({ sceneRef: e }) {
3397
3382
  }),
3398
3383
  /* @__PURE__ */ d("input", {
3399
3384
  type: "color",
3400
- value: Be(t.mCustomEnvColors[y.envId]),
3385
+ value: ze(t.mCustomEnvColors[y.envId]),
3401
3386
  onChange: (e) => C(y.envId, e.target.value),
3402
3387
  style: {
3403
3388
  width: "100%",
@@ -3422,7 +3407,7 @@ function He({ sceneRef: e }) {
3422
3407
  }
3423
3408
  //#endregion
3424
3409
  //#region src/components/panels/HistoryPanel.tsx
3425
- function Ue(e) {
3410
+ function He(e) {
3426
3411
  switch (e.kind) {
3427
3412
  case "moveRoom": return `Move room #${e.id}`;
3428
3413
  case "addRoom": return `Add room #${e.id}`;
@@ -3464,10 +3449,10 @@ function Ue(e) {
3464
3449
  case "setLabelNoScaling": return `${e.to ? "Disable" : "Enable"} zoom scaling on label #${e.id}`;
3465
3450
  case "setLabelShowOnTop": return `Set label #${e.id} ${e.to ? "foreground" : "background"}`;
3466
3451
  case "resizeLabel": return `Resize label #${e.id}`;
3467
- case "batch": return Ue(e.cmds[0]);
3452
+ case "batch": return He(e.cmds[0]);
3468
3453
  }
3469
3454
  }
3470
- function We({ cmd: e, className: t, onClick: n, title: r }) {
3455
+ function Ue({ cmd: e, className: t, onClick: n, title: r }) {
3471
3456
  return /* @__PURE__ */ f("button", {
3472
3457
  type: "button",
3473
3458
  className: t,
@@ -3475,23 +3460,23 @@ function We({ cmd: e, className: t, onClick: n, title: r }) {
3475
3460
  title: r,
3476
3461
  children: [/* @__PURE__ */ d("span", {
3477
3462
  className: "history-label",
3478
- children: Ue(e)
3463
+ children: He(e)
3479
3464
  }), e.kind === "batch" && e.cmds.slice(1).map((e, t) => /* @__PURE__ */ d("span", {
3480
3465
  className: "history-sub",
3481
- children: Ue(e)
3466
+ children: He(e)
3482
3467
  }, t))]
3483
3468
  });
3484
3469
  }
3485
- function Ge({ sceneRef: e }) {
3470
+ function We({ sceneRef: e }) {
3486
3471
  let t = O((e) => e.undo), n = O((e) => e.redo), r = (t, n) => {
3487
3472
  let r = e.current, i = !1;
3488
3473
  for (let e = 0; e < t; e++) {
3489
- let e = Oe(r);
3474
+ let e = De(r);
3490
3475
  if (!e.changed) break;
3491
3476
  e.structural && (i = !0);
3492
3477
  }
3493
3478
  for (let e = 0; e < n; e++) {
3494
- let e = ke(r);
3479
+ let e = Oe(r);
3495
3480
  if (!e.changed) break;
3496
3481
  e.structural && (i = !0);
3497
3482
  }
@@ -3502,7 +3487,7 @@ function Ge({ sceneRef: e }) {
3502
3487
  children: /* @__PURE__ */ f("div", {
3503
3488
  className: "history-list",
3504
3489
  children: [
3505
- n.map((e, t) => /* @__PURE__ */ d(We, {
3490
+ n.map((e, t) => /* @__PURE__ */ d(Ue, {
3506
3491
  cmd: e,
3507
3492
  className: "history-item history-undone",
3508
3493
  onClick: () => r(0, n.length - t),
@@ -3518,7 +3503,7 @@ function Ge({ sceneRef: e }) {
3518
3503
  children: "Current state"
3519
3504
  })]
3520
3505
  }),
3521
- i.map((e, t) => /* @__PURE__ */ d(We, {
3506
+ i.map((e, t) => /* @__PURE__ */ d(Ue, {
3522
3507
  cmd: e,
3523
3508
  className: "history-item history-done",
3524
3509
  onClick: () => r(t + 1, 0),
@@ -3535,7 +3520,7 @@ function Ge({ sceneRef: e }) {
3535
3520
  }
3536
3521
  //#endregion
3537
3522
  //#region src/components/panels/MapPanel.tsx
3538
- function Ke(e, t) {
3523
+ function Ge(e, t) {
3539
3524
  let n = [], r = e.current?.reader;
3540
3525
  if (r) for (let e of r.getAreas()) {
3541
3526
  let t = e.getAreaId(), r = e.getAreaName();
@@ -3577,7 +3562,7 @@ function Ke(e, t) {
3577
3562
  }
3578
3563
  return n;
3579
3564
  }
3580
- function qe(e) {
3565
+ function Ke(e) {
3581
3566
  let t = D.getState(), n = e.areaId !== t.currentAreaId, r = e.z !== t.currentZ, i = e.x, a = -e.y;
3582
3567
  n || r ? (D.setState({
3583
3568
  selection: {
@@ -3605,7 +3590,7 @@ function qe(e) {
3605
3590
  sidebarTab: "selection"
3606
3591
  });
3607
3592
  }
3608
- function Je(e) {
3593
+ function qe(e) {
3609
3594
  let t = D.getState(), n = t.map?.rooms[e.roomId];
3610
3595
  if (!n) return;
3611
3596
  let r = n.area !== t.currentAreaId, i = n.z !== t.currentZ;
@@ -3633,7 +3618,7 @@ function Je(e) {
3633
3618
  sidebarTab: "selection"
3634
3619
  });
3635
3620
  }
3636
- function Ye({ sceneRef: e }) {
3621
+ function Je({ sceneRef: e }) {
3637
3622
  let t = O((e) => e.map);
3638
3623
  if (O((e) => e.structureVersion), O((e) => e.dataVersion), !t) return /* @__PURE__ */ f("div", {
3639
3624
  className: "panel-content",
@@ -3642,7 +3627,7 @@ function Ye({ sceneRef: e }) {
3642
3627
  children: "Drag a .dat file in or load from toolbar."
3643
3628
  })]
3644
3629
  });
3645
- let n = Object.keys(t.rooms).length, r = Object.keys(t.areas).length, i = Object.keys(t.mCustomEnvColors).length, a = Ke(e, t);
3630
+ let n = Object.keys(t.rooms).length, r = Object.keys(t.areas).length, i = Object.keys(t.mCustomEnvColors).length, a = Ge(e, t);
3646
3631
  return /* @__PURE__ */ f("div", {
3647
3632
  className: "panel-content",
3648
3633
  children: [
@@ -3693,7 +3678,7 @@ function Ye({ sceneRef: e }) {
3693
3678
  ]
3694
3679
  }),
3695
3680
  /* @__PURE__ */ d("h4", { children: "User Data" }),
3696
- /* @__PURE__ */ d(Ie, {
3681
+ /* @__PURE__ */ d(Fe, {
3697
3682
  data: t.mUserData ?? {},
3698
3683
  onCommit: (t, n, r) => {
3699
3684
  Y({
@@ -3732,7 +3717,7 @@ function Ye({ sceneRef: e }) {
3732
3717
  /* @__PURE__ */ d("button", {
3733
3718
  type: "button",
3734
3719
  className: "warning-go-btn",
3735
- onClick: () => qe(e),
3720
+ onClick: () => Ke(e),
3736
3721
  children: "Go"
3737
3722
  })
3738
3723
  ]
@@ -3759,7 +3744,7 @@ function Ye({ sceneRef: e }) {
3759
3744
  /* @__PURE__ */ d("button", {
3760
3745
  type: "button",
3761
3746
  className: "warning-go-btn",
3762
- onClick: () => Je(e),
3747
+ onClick: () => qe(e),
3763
3748
  children: "Go"
3764
3749
  })
3765
3750
  ]
@@ -3771,7 +3756,7 @@ function Ye({ sceneRef: e }) {
3771
3756
  }
3772
3757
  //#endregion
3773
3758
  //#region src/components/panels/ExitPanel.tsx
3774
- function Xe({ selection: e, map: t, sceneRef: n }) {
3759
+ function Ye({ selection: e, map: t, sceneRef: n }) {
3775
3760
  let r = t.rooms[e.fromId], i = t.rooms[e.toId], a = {
3776
3761
  north: "south",
3777
3762
  south: "north",
@@ -3813,7 +3798,7 @@ function Xe({ selection: e, map: t, sceneRef: n }) {
3813
3798
  /* @__PURE__ */ f("div", {
3814
3799
  className: "exit-flow",
3815
3800
  children: [
3816
- /* @__PURE__ */ d(Ne, {
3801
+ /* @__PURE__ */ d(Me, {
3817
3802
  id: e.fromId,
3818
3803
  name: r?.name
3819
3804
  }),
@@ -3848,7 +3833,7 @@ function Xe({ selection: e, map: t, sceneRef: n }) {
3848
3833
  })
3849
3834
  ]
3850
3835
  }),
3851
- /* @__PURE__ */ d(Ne, {
3836
+ /* @__PURE__ */ d(Me, {
3852
3837
  id: e.toId,
3853
3838
  name: i?.name
3854
3839
  })
@@ -3864,10 +3849,10 @@ function Xe({ selection: e, map: t, sceneRef: n }) {
3864
3849
  }
3865
3850
  //#endregion
3866
3851
  //#region src/editor/coords.ts
3867
- function Ze(e, t) {
3852
+ function Xe(e, t) {
3868
3853
  return Math.round(e / t) * t;
3869
3854
  }
3870
- function Qe(e, t, n, r) {
3855
+ function Ze(e, t, n, r) {
3871
3856
  let i = t.getBoundingClientRect(), a = e.backend.viewport.clientToMapPoint(n, r, {
3872
3857
  left: i.left,
3873
3858
  top: i.top
@@ -3881,7 +3866,7 @@ function Qe(e, t, n, r) {
3881
3866
  }
3882
3867
  //#endregion
3883
3868
  //#region src/editor/hitTest.ts
3884
- function $e(e, t, n, r, i) {
3869
+ function Qe(e, t, n, r, i) {
3885
3870
  let a = i.getArea(e);
3886
3871
  if (!a) return null;
3887
3872
  let o = a.getPlane(t);
@@ -3896,7 +3881,7 @@ function $e(e, t, n, r, i) {
3896
3881
  }
3897
3882
  return c;
3898
3883
  }
3899
- function et(e, t, n, r, i) {
3884
+ function $e(e, t, n, r, i) {
3900
3885
  let a = i.getArea(e);
3901
3886
  if (!a) return [];
3902
3887
  let o = a.getPlane(t);
@@ -3911,7 +3896,7 @@ function et(e, t, n, r, i) {
3911
3896
  }
3912
3897
  return c;
3913
3898
  }
3914
- function tt(e, t, n, r, i, a, o, s) {
3899
+ function et(e, t, n, r, i, a, o, s) {
3915
3900
  let c = [], l = e.backend.culling?.findRoomAtMapPoint?.(i, a);
3916
3901
  if (l) {
3917
3902
  let e = t.rooms[l.id];
@@ -3920,19 +3905,19 @@ function tt(e, t, n, r, i, a, o, s) {
3920
3905
  id: Number(i)
3921
3906
  });
3922
3907
  }
3923
- let u = et(n, r, i, a, s);
3908
+ let u = $e(n, r, i, a, s);
3924
3909
  for (let e = u.length - 1; e >= 0; e--) c.push({
3925
3910
  kind: "label",
3926
3911
  id: u[e].id,
3927
3912
  areaId: u[e].areaId
3928
3913
  });
3929
- let d = lt(e, i, a, o);
3914
+ let d = ct(e, i, a, o);
3930
3915
  d && c.push({
3931
3916
  kind: "customLine",
3932
3917
  roomId: d.roomId,
3933
3918
  exitName: d.exitName
3934
3919
  });
3935
- let f = ct(e, i, a, o);
3920
+ let f = st(e, i, a, o);
3936
3921
  return f && c.push({
3937
3922
  kind: "exit",
3938
3923
  fromId: f.fromId,
@@ -3940,7 +3925,7 @@ function tt(e, t, n, r, i, a, o, s) {
3940
3925
  dir: f.dir
3941
3926
  }), c;
3942
3927
  }
3943
- function nt(e, t, n, r) {
3928
+ function tt(e, t, n, r) {
3944
3929
  let i = .05, a = e.x - i, o = e.y - i, s = e.w + i * 2, c = e.h + i * 2, l = Math.max(.15, r), u = [
3945
3930
  [
3946
3931
  a,
@@ -3992,7 +3977,7 @@ function nt(e, t, n, r) {
3992
3977
  }
3993
3978
  return d?.handle ?? null;
3994
3979
  }
3995
- function rt(e, t, n, r, i) {
3980
+ function nt(e, t, n, r, i) {
3996
3981
  let a = e.areas[t];
3997
3982
  if (!a) return null;
3998
3983
  for (let t of a.rooms) {
@@ -4001,22 +3986,22 @@ function rt(e, t, n, r, i) {
4001
3986
  }
4002
3987
  return null;
4003
3988
  }
4004
- function it(e, t, n, r, i, a) {
3989
+ function rt(e, t, n, r, i, a) {
4005
3990
  let o = i - n, s = a - r, c = o * o + s * s;
4006
3991
  if (c < 1e-9) return Math.hypot(e - n, t - r);
4007
3992
  let l = ((e - n) * o + (t - r) * s) / c;
4008
3993
  return l = Math.max(0, Math.min(1, l)), Math.hypot(e - (n + l * o), t - (r + l * s));
4009
3994
  }
4010
- function at(e, t, n) {
3995
+ function it(e, t, n) {
4011
3996
  if (e.length < 4) return Infinity;
4012
3997
  let r = Infinity;
4013
3998
  for (let i = 0; i + 3 < e.length; i += 2) {
4014
- let a = it(t, n, e[i], e[i + 1], e[i + 2], e[i + 3]);
3999
+ let a = rt(t, n, e[i], e[i + 1], e[i + 2], e[i + 3]);
4015
4000
  a < r && (r = a);
4016
4001
  }
4017
4002
  return r;
4018
4003
  }
4019
- var ot = [
4004
+ var at = [
4020
4005
  [
4021
4006
  0,
4022
4007
  -1,
@@ -4058,18 +4043,18 @@ var ot = [
4058
4043
  "northwest"
4059
4044
  ]
4060
4045
  ];
4061
- function st(e, t, n) {
4046
+ function ot(e, t, n) {
4062
4047
  let r = e.x - t.x, i = e.y - t.y;
4063
4048
  if (r === 0 && i === 0) return "east";
4064
4049
  let a = (Math.atan2(i, r) * 180 / Math.PI + 360) % 360;
4065
4050
  return a < 22.5 || a >= 337.5 ? "east" : a < 67.5 ? "southeast" : a < 112.5 ? "south" : a < 157.5 ? "southwest" : a < 202.5 ? "west" : a < 247.5 ? "northwest" : a < 292.5 ? "north" : "northeast";
4066
4051
  }
4067
- function ct(e, t, n, r) {
4052
+ function st(e, t, n, r) {
4068
4053
  let i = r * .35, a = e.getDrawnExits(), o = null;
4069
4054
  for (let e of a) {
4070
4055
  let r = Infinity, a = !0;
4071
4056
  for (let i of e.data.lines) {
4072
- let e = at(i.points, t, n);
4057
+ let e = it(i.points, t, n);
4073
4058
  if (e < r) {
4074
4059
  r = e;
4075
4060
  let o = Math.hypot(t - i.points[0], n - i.points[1]), s = i.points.length - 2;
@@ -4077,7 +4062,7 @@ function ct(e, t, n, r) {
4077
4062
  }
4078
4063
  }
4079
4064
  for (let i of e.data.arrows) {
4080
- let o = at(i.points, t, n);
4065
+ let o = it(i.points, t, n);
4081
4066
  if (o < r) {
4082
4067
  r = o;
4083
4068
  let s = Math.hypot(t - i.points[0], n - i.points[1]), c = i.points.length - 2, l = Math.hypot(t - i.points[c], n - i.points[c + 1]);
@@ -4111,10 +4096,10 @@ function ct(e, t, n, r) {
4111
4096
  dir: o.bDir
4112
4097
  } : null : null;
4113
4098
  }
4114
- function lt(e, t, n, r) {
4099
+ function ct(e, t, n, r) {
4115
4100
  let i = r * .5, a = null;
4116
4101
  for (let r of e.getDrawnSpecialExits()) {
4117
- let e = at(r.points, t, n);
4102
+ let e = it(r.points, t, n);
4118
4103
  e < i && (a === null || e < a.dist) && (a = {
4119
4104
  roomId: r.roomId,
4120
4105
  exitName: r.exitName,
@@ -4126,13 +4111,13 @@ function lt(e, t, n, r) {
4126
4111
  exitName: a.exitName
4127
4112
  } : null;
4128
4113
  }
4129
- function ut(e, t, n, r, i, a) {
4114
+ function lt(e, t, n, r, i, a) {
4130
4115
  let o = a * .5;
4131
4116
  for (let a of e.getDrawnSpecialExits()) {
4132
4117
  if (a.roomId !== t || a.exitName !== n) continue;
4133
4118
  let e = null;
4134
4119
  for (let t = 0; t + 3 < a.points.length; t += 2) {
4135
- let n = it(r, i, a.points[t], a.points[t + 1], a.points[t + 2], a.points[t + 3]);
4120
+ let n = rt(r, i, a.points[t], a.points[t + 1], a.points[t + 2], a.points[t + 3]);
4136
4121
  n < o && (e === null || n < e.dist) && (e = {
4137
4122
  segIdx: t / 2,
4138
4123
  dist: n
@@ -4142,7 +4127,7 @@ function ut(e, t, n, r, i, a) {
4142
4127
  }
4143
4128
  return null;
4144
4129
  }
4145
- function dt(e, t, n, r, i, a) {
4130
+ function ut(e, t, n, r, i, a) {
4146
4131
  let o = a * .45;
4147
4132
  for (let a of e.getDrawnSpecialExits()) {
4148
4133
  if (a.roomId !== t || a.exitName !== n) continue;
@@ -4160,21 +4145,21 @@ function dt(e, t, n, r, i, a) {
4160
4145
  }
4161
4146
  //#endregion
4162
4147
  //#region src/editor/tools.ts
4163
- var ft = null;
4164
- function pt(e) {
4165
- ft = e;
4148
+ var dt = null;
4149
+ function ft(e) {
4150
+ dt = e;
4166
4151
  }
4167
- function Z(e, t) {
4168
- return Qe(e.renderer, e.container, t.clientX, t.clientY);
4152
+ function Q(e, t) {
4153
+ return Ze(e.renderer, e.container, t.clientX, t.clientY);
4169
4154
  }
4170
- function mt(e, t) {
4171
- let n = Z(e, t), r = D.getState();
4155
+ function pt(e, t) {
4156
+ let n = Q(e, t), r = D.getState();
4172
4157
  return r.snapToGrid ? {
4173
- x: Ze(n.x, r.gridStep),
4174
- y: Ze(n.y, r.gridStep)
4158
+ x: Xe(n.x, r.gridStep),
4159
+ y: Xe(n.y, r.gridStep)
4175
4160
  } : n;
4176
4161
  }
4177
- function ht() {
4162
+ function mt() {
4178
4163
  let e = D.getState();
4179
4164
  return !e.map || e.currentAreaId == null ? null : {
4180
4165
  map: e.map,
@@ -4183,8 +4168,8 @@ function ht() {
4183
4168
  state: e
4184
4169
  };
4185
4170
  }
4186
- function Q(e, t) {
4187
- if (!ht()) return null;
4171
+ function $(e, t) {
4172
+ if (!mt()) return null;
4188
4173
  let n = e.container.getBoundingClientRect(), r = e.renderer.backend.viewport.clientToMapPoint(t.clientX, t.clientY, {
4189
4174
  left: n.left,
4190
4175
  top: n.top
@@ -4193,14 +4178,14 @@ function Q(e, t) {
4193
4178
  let i = e.renderer.backend.culling?.findRoomAtMapPoint?.(r.x, r.y);
4194
4179
  return i ? e.scene.getRenderRoom(i.id) ?? null : null;
4195
4180
  }
4196
- var gt = .15, _t = {
4181
+ var ht = .15, gt = {
4197
4182
  id: "select",
4198
4183
  cursor: "default",
4199
4184
  onPointerDown(e, t) {
4200
4185
  if (e.button !== 0) return !1;
4201
4186
  let n = D.getState();
4202
4187
  if (n.contextMenu && D.setState({ contextMenu: null }), n.pending?.kind === "pickExit") {
4203
- let r = Q(t, e);
4188
+ let r = $(t, e);
4204
4189
  if (r && n.map) {
4205
4190
  let { fromId: e, dir: i } = n.pending, a = n.map.rooms[e];
4206
4191
  if (a) {
@@ -4225,8 +4210,8 @@ var gt = .15, _t = {
4225
4210
  return !0;
4226
4211
  }
4227
4212
  if (n.pending?.kind === "pickSpecialExit") {
4228
- let r = Q(t, e), i = n.pending.fromId;
4229
- return r && ft && ft(r.id), D.setState({
4213
+ let r = $(t, e), i = n.pending.fromId;
4214
+ return r && dt && dt(r.id), D.setState({
4230
4215
  pending: null,
4231
4216
  selection: {
4232
4217
  kind: "room",
@@ -4235,7 +4220,7 @@ var gt = .15, _t = {
4235
4220
  }), !0;
4236
4221
  }
4237
4222
  if (n.pending?.kind === "pickSwatch") {
4238
- let r = Q(t, e);
4223
+ let r = $(t, e);
4239
4224
  if (r && n.map) {
4240
4225
  let e = n.map.rooms[r.id];
4241
4226
  e && window.dispatchEvent(new CustomEvent("editor:swatchRoomPicked", { detail: {
@@ -4245,9 +4230,9 @@ var gt = .15, _t = {
4245
4230
  }
4246
4231
  return D.setState({ pending: null }), !0;
4247
4232
  }
4248
- let r = Z(t, e), i = ht();
4233
+ let r = Q(t, e), i = mt();
4249
4234
  if (e.altKey) {
4250
- let e = i ? tt(t.renderer, i.map, i.areaId, i.z, r.x, r.y, t.settings.roomSize, t.scene.reader) : [];
4235
+ let e = i ? et(t.renderer, i.map, i.areaId, i.z, r.x, r.y, t.settings.roomSize, t.scene.reader) : [];
4251
4236
  if (e.length > 0) {
4252
4237
  let t = Math.round(r.x), i = Math.round(r.y), a = n.hitCycle, o = a && a.x === t && a.y === i ? (a.index + 1) % e.length : 0, s = e[o];
4253
4238
  D.setState({
@@ -4256,15 +4241,15 @@ var gt = .15, _t = {
4256
4241
  y: i,
4257
4242
  index: o
4258
4243
  },
4259
- selection: Lt(s),
4244
+ selection: It(s),
4260
4245
  sidebarTab: "selection",
4261
- status: `Selected ${Rt(s)} (${o + 1}/${e.length})`
4246
+ status: `Selected ${Lt(s)} (${o + 1}/${e.length})`
4262
4247
  });
4263
4248
  }
4264
4249
  return !0;
4265
4250
  }
4266
4251
  if (D.setState({ hitCycle: null }), n.selection?.kind === "customLine" && i) {
4267
- let i = dt(t.renderer, n.selection.roomId, n.selection.exitName, r.x, r.y, t.settings.roomSize);
4252
+ let i = ut(t.renderer, n.selection.roomId, n.selection.exitName, r.x, r.y, t.settings.roomSize);
4268
4253
  if (i !== null) {
4269
4254
  let r = n.map?.rooms[n.selection.roomId], a = r?.customLines?.[n.selection.exitName] ? [...r.customLines[n.selection.exitName]] : [];
4270
4255
  return D.setState({
@@ -4299,7 +4284,7 @@ var gt = .15, _t = {
4299
4284
  }), c = t.renderer.backend.viewport.clientToMapPoint(8, 0, {
4300
4285
  left: o.left,
4301
4286
  top: o.top
4302
- }), l = s && c ? Math.abs(c.x - s.x) : .25, u = nt(n, r.x, r.y, l);
4287
+ }), l = s && c ? Math.abs(c.x - s.x) : .25, u = tt(n, r.x, r.y, l);
4303
4288
  if (u) return D.setState({ pending: {
4304
4289
  kind: "labelResize",
4305
4290
  labelId: i.id,
@@ -4310,7 +4295,7 @@ var gt = .15, _t = {
4310
4295
  } }), t.container.setPointerCapture(e.pointerId), !0;
4311
4296
  }
4312
4297
  }
4313
- let a = $e(i.areaId, i.z, r.x, r.y, t.scene.reader);
4298
+ let a = Qe(i.areaId, i.z, r.x, r.y, t.scene.reader);
4314
4299
  if (a) {
4315
4300
  let n = t.scene.reader.getLabelSnapshot(a.areaId, a.id), i = n ? n.pos[0] : 0, o = n ? -n.pos[1] : 0;
4316
4301
  return D.setState({
@@ -4331,7 +4316,7 @@ var gt = .15, _t = {
4331
4316
  }), t.container.setPointerCapture(e.pointerId), !0;
4332
4317
  }
4333
4318
  }
4334
- let a = Q(t, e);
4319
+ let a = $(t, e);
4335
4320
  if (a && n.selection?.kind === "room") {
4336
4321
  let e = a, r = n.selection.ids.find((n) => {
4337
4322
  let r = t.scene.getRenderRoom(n);
@@ -4402,13 +4387,13 @@ var gt = .15, _t = {
4402
4387
  }), t.container.setPointerCapture(e.pointerId), !0;
4403
4388
  }
4404
4389
  if (i) {
4405
- let e = lt(t.renderer, r.x, r.y, t.settings.roomSize);
4390
+ let e = ct(t.renderer, r.x, r.y, t.settings.roomSize);
4406
4391
  if (e) return D.setState({ selection: {
4407
4392
  kind: "customLine",
4408
4393
  roomId: e.roomId,
4409
4394
  exitName: e.exitName
4410
4395
  } }), !0;
4411
- let n = ct(t.renderer, r.x, r.y, t.settings.roomSize);
4396
+ let n = st(t.renderer, r.x, r.y, t.settings.roomSize);
4412
4397
  if (n) return D.setState({ selection: {
4413
4398
  kind: "exit",
4414
4399
  fromId: n.fromId,
@@ -4416,7 +4401,7 @@ var gt = .15, _t = {
4416
4401
  dir: n.dir
4417
4402
  } }), !0;
4418
4403
  }
4419
- let o = Z(t, e);
4404
+ let o = Q(t, e);
4420
4405
  return D.setState({ pending: {
4421
4406
  kind: "marquee",
4422
4407
  startX: o.x,
@@ -4431,15 +4416,15 @@ var gt = .15, _t = {
4431
4416
  onPointerMove(e, t) {
4432
4417
  let n = D.getState();
4433
4418
  if (n.pending?.kind === "customLinePoint") {
4434
- let r = mt(t, e);
4419
+ let r = pt(t, e);
4435
4420
  return t.scene.reader.setCustomLinePoint(n.pending.roomId, n.pending.exitName, n.pending.pointIndex, r.x, r.y), t.refresh(), D.bumpData(), !0;
4436
4421
  }
4437
4422
  if (n.pending?.kind === "marquee") {
4438
- let r = Z(t, e), i = {
4423
+ let r = Q(t, e), i = {
4439
4424
  ...n.pending,
4440
4425
  currentX: r.x,
4441
4426
  currentY: r.y
4442
- }, a = vt(Math.min(i.startX, r.x), Math.max(i.startX, r.x), Math.min(i.startY, r.y), Math.max(i.startY, r.y)), o;
4427
+ }, a = _t(Math.min(i.startX, r.x), Math.max(i.startX, r.x), Math.min(i.startY, r.y), Math.max(i.startY, r.y)), o;
4443
4428
  if (i.ctrlHeld) {
4444
4429
  let e = new Set(i.preExistingIds);
4445
4430
  for (let t of a) e.has(t) ? e.delete(t) : e.add(t);
@@ -4458,28 +4443,28 @@ var gt = .15, _t = {
4458
4443
  }), !0;
4459
4444
  }
4460
4445
  if (n.pending?.kind === "labelDrag") {
4461
- let r = Z(t, e), i = {
4446
+ let r = Q(t, e), i = {
4462
4447
  x: r.x - n.pending.offsetX,
4463
4448
  y: r.y - n.pending.offsetY
4464
4449
  }, a = n.snapToGrid ? {
4465
- x: Ze(i.x, n.gridStep),
4466
- y: Ze(i.y, n.gridStep)
4450
+ x: Xe(i.x, n.gridStep),
4451
+ y: Xe(i.y, n.gridStep)
4467
4452
  } : i, o = t.scene.reader.getLabelSnapshot(n.pending.areaId, n.pending.labelId), s = o ? a.x - o.pos[0] : 1, c = o ? a.y - -o.pos[1] : 1;
4468
4453
  return (s !== 0 || c !== 0) && (t.scene.reader.moveLabel(n.pending.areaId, n.pending.labelId, a.x, a.y), t.refresh(), D.bumpData()), !0;
4469
4454
  }
4470
4455
  if (n.pending?.kind === "labelResize") {
4471
- let r = Z(t, e), i = n.pending, a = n.labelAspectRatioLocked && i.originSize[1] > 0 ? i.originSize[0] / i.originSize[1] : void 0, o = jt(i.handle, i.originPos[0], -i.originPos[1], i.originSize[0], i.originSize[1], r.x, r.y, a), s = t.scene.reader.getLabelSnapshot(i.areaId, i.labelId);
4456
+ let r = Q(t, e), i = n.pending, a = n.labelAspectRatioLocked && i.originSize[1] > 0 ? i.originSize[0] / i.originSize[1] : void 0, o = At(i.handle, i.originPos[0], -i.originPos[1], i.originSize[0], i.originSize[1], r.x, r.y, a), s = t.scene.reader.getLabelSnapshot(i.areaId, i.labelId);
4472
4457
  return (!s || o.x !== s.pos[0] || o.y !== -s.pos[1] || o.w !== s.size[0] || o.h !== s.size[1]) && (t.scene.reader.moveLabel(i.areaId, i.labelId, o.x, o.y), t.scene.reader.setLabelSize(i.areaId, i.labelId, o.w, o.h), t.scene.refresh()), !0;
4473
4458
  }
4474
- if (n.pending?.kind !== "drag") return zt(t, e), !1;
4459
+ if (n.pending?.kind !== "drag") return Rt(t, e), !1;
4475
4460
  let r = t.scene.getRenderRoom(n.pending.roomId);
4476
4461
  if (!r) return !0;
4477
- let i = Z(t, e), a = {
4462
+ let i = Q(t, e), a = {
4478
4463
  x: i.x - n.pending.offsetX,
4479
4464
  y: i.y - n.pending.offsetY
4480
4465
  }, o = n.snapToGrid ? {
4481
- x: Ze(a.x, n.gridStep),
4482
- y: Ze(a.y, n.gridStep)
4466
+ x: Xe(a.x, n.gridStep),
4467
+ y: Xe(a.y, n.gridStep)
4483
4468
  } : a, s = o.x - r.x, c = o.y - r.y;
4484
4469
  if (s !== 0 || c !== 0) {
4485
4470
  if (t.scene.reader.moveRoom(n.pending.roomId, o.x, o.y, r.z), n.pending.multiOrigins) for (let { id: e } of n.pending.multiOrigins) {
@@ -4537,7 +4522,7 @@ var gt = .15, _t = {
4537
4522
  t.container.releasePointerCapture(e.pointerId);
4538
4523
  } catch {}
4539
4524
  let r = n.pending, i = Math.abs(r.currentX - r.startX), a = Math.abs(r.currentY - r.startY);
4540
- return i <= gt && a <= gt && !r.ctrlHeld && !r.shiftHeld && D.setState({ selection: null }), D.setState({ pending: null }), !0;
4525
+ return i <= ht && a <= ht && !r.ctrlHeld && !r.shiftHeld && D.setState({ selection: null }), D.setState({ pending: null }), !0;
4541
4526
  }
4542
4527
  if (n.pending?.kind === "labelDrag" && n.map) {
4543
4528
  let e = n.pending, r = t.scene.reader.getLabelSnapshot(e.areaId, e.labelId);
@@ -4639,9 +4624,17 @@ var gt = .15, _t = {
4639
4624
  onContextMenu(e, t) {
4640
4625
  let n = D.getState();
4641
4626
  if (!n.map) return !1;
4642
- let r = Z(t, e), i = ht();
4627
+ if (n.spreadShrink) {
4628
+ let r = $(t, e);
4629
+ if (r) return D.setState({ spreadShrink: {
4630
+ ...n.spreadShrink,
4631
+ centerMode: "anchor",
4632
+ anchorRoomId: r.id
4633
+ } }), !0;
4634
+ }
4635
+ let r = Q(t, e), i = mt();
4643
4636
  if (i) {
4644
- let n = tt(t.renderer, i.map, i.areaId, i.z, r.x, r.y, t.settings.roomSize, t.scene.reader).filter((e) => e.kind !== "exit" && e.kind !== "customLine");
4637
+ let n = et(t.renderer, i.map, i.areaId, i.z, r.x, r.y, t.settings.roomSize, t.scene.reader).filter((e) => e.kind !== "exit" && e.kind !== "customLine");
4645
4638
  if (n.length > 1) return D.setState({ contextMenu: {
4646
4639
  kind: "disambiguate",
4647
4640
  hits: n,
@@ -4649,7 +4642,7 @@ var gt = .15, _t = {
4649
4642
  screenY: e.clientY
4650
4643
  } }), !0;
4651
4644
  }
4652
- let a = Q(t, e);
4645
+ let a = $(t, e);
4653
4646
  if (a) return D.setState({ contextMenu: {
4654
4647
  kind: "room",
4655
4648
  roomId: a.id,
@@ -4657,7 +4650,7 @@ var gt = .15, _t = {
4657
4650
  screenY: e.clientY
4658
4651
  } }), !0;
4659
4652
  if (i) {
4660
- let n = $e(i.areaId, i.z, r.x, r.y, t.scene.reader);
4653
+ let n = Qe(i.areaId, i.z, r.x, r.y, t.scene.reader);
4661
4654
  if (n) return D.setState({
4662
4655
  selection: {
4663
4656
  kind: "label",
@@ -4677,7 +4670,7 @@ var gt = .15, _t = {
4677
4670
  if (n.selection?.kind !== "customLine") return !1;
4678
4671
  let o = n.selection, s = n.map.rooms[o.roomId], c = s?.customLines?.[o.exitName];
4679
4672
  if (!s || !c) return !1;
4680
- let l = dt(t.renderer, o.roomId, o.exitName, r.x, r.y, t.settings.roomSize);
4673
+ let l = ut(t.renderer, o.roomId, o.exitName, r.x, r.y, t.settings.roomSize);
4681
4674
  if (l !== null) return D.setState({
4682
4675
  selection: {
4683
4676
  kind: "customLine",
@@ -4694,10 +4687,10 @@ var gt = .15, _t = {
4694
4687
  screenY: e.clientY
4695
4688
  }
4696
4689
  }), !0;
4697
- let u = ut(t.renderer, o.roomId, o.exitName, r.x, r.y, t.settings.roomSize);
4690
+ let u = lt(t.renderer, o.roomId, o.exitName, r.x, r.y, t.settings.roomSize);
4698
4691
  if (u !== null) {
4699
- let n = mt(t, e);
4700
- return yt(t, o.roomId, o.exitName, u.insertIndex, n.x, n.y), !0;
4692
+ let n = pt(t, e);
4693
+ return vt(t, o.roomId, o.exitName, u.insertIndex, n.x, n.y), !0;
4701
4694
  }
4702
4695
  return !1;
4703
4696
  },
@@ -4724,7 +4717,7 @@ var gt = .15, _t = {
4724
4717
  D.setState({ pending: null });
4725
4718
  }
4726
4719
  };
4727
- function vt(e, t, n, r) {
4720
+ function _t(e, t, n, r) {
4728
4721
  let i = D.getState();
4729
4722
  if (!i.map || i.currentAreaId == null) return [];
4730
4723
  let a = [];
@@ -4735,7 +4728,7 @@ function vt(e, t, n, r) {
4735
4728
  }
4736
4729
  return a;
4737
4730
  }
4738
- function yt(e, t, n, r, i, a) {
4731
+ function vt(e, t, n, r, i, a) {
4739
4732
  let o = D.getState();
4740
4733
  if (!o.map) return;
4741
4734
  let s = o.map.rooms[t], c = s?.customLines?.[n];
@@ -4775,17 +4768,17 @@ function yt(e, t, n, r, i, a) {
4775
4768
  status: `Added waypoint to '${n}' on room ${t}`
4776
4769
  });
4777
4770
  }
4778
- var bt = {
4771
+ var yt = {
4779
4772
  id: "connect",
4780
4773
  cursor: "crosshair",
4781
4774
  onPointerDown(e, t) {
4782
4775
  if (e.button !== 0) return !1;
4783
- let n = Q(t, e);
4776
+ let n = $(t, e);
4784
4777
  if (!n) return D.getState().pending?.kind === "connect" && D.setState({
4785
4778
  pending: null,
4786
4779
  status: "Connect cancelled."
4787
4780
  }), !0;
4788
- let r = Z(t, e), i = st(r, {
4781
+ let r = Q(t, e), i = ot(r, {
4789
4782
  x: n.x,
4790
4783
  y: n.y
4791
4784
  }, t.settings.roomSize);
@@ -4810,10 +4803,10 @@ var bt = {
4810
4803
  return !0;
4811
4804
  },
4812
4805
  onPointerMove(e, t) {
4813
- let n = D.getState(), r = Z(t, e), i = Q(t, e), a = i ? i.id : null;
4806
+ let n = D.getState(), r = Q(t, e), i = $(t, e), a = i ? i.id : null;
4814
4807
  if (n.pending?.kind === "connect") {
4815
4808
  let e = null;
4816
- return i && i.id !== n.pending.sourceId && (e = st(r, {
4809
+ return i && i.id !== n.pending.sourceId && (e = ot(r, {
4817
4810
  x: i.x,
4818
4811
  y: i.y
4819
4812
  }, t.settings.roomSize)), D.setState({ pending: {
@@ -4823,7 +4816,7 @@ var bt = {
4823
4816
  targetDir: e
4824
4817
  } }), !0;
4825
4818
  }
4826
- return zt(t, e), !1;
4819
+ return Rt(t, e), !1;
4827
4820
  },
4828
4821
  onPointerUp(e, t) {
4829
4822
  let n = D.getState();
@@ -4832,13 +4825,13 @@ var bt = {
4832
4825
  try {
4833
4826
  t.container.releasePointerCapture(e.pointerId);
4834
4827
  } catch {}
4835
- return r.hoverTargetId != null && r.hoverTargetId !== r.sourceId ? xt(t, r.sourceId, r.hoverTargetId, r.sourceDir, r.targetDir, e.shiftKey) : D.setState({ status: "Connect cancelled." }), D.setState({ pending: null }), !0;
4828
+ return r.hoverTargetId != null && r.hoverTargetId !== r.sourceId ? bt(t, r.sourceId, r.hoverTargetId, r.sourceDir, r.targetDir, e.shiftKey) : D.setState({ status: "Connect cancelled." }), D.setState({ pending: null }), !0;
4836
4829
  },
4837
4830
  onCancel() {
4838
4831
  D.setState({ pending: null });
4839
4832
  }
4840
4833
  };
4841
- function xt(e, t, n, r, i, a) {
4834
+ function bt(e, t, n, r, i, a) {
4842
4835
  let o = e.scene.getRenderRoom(t), s = e.scene.getRenderRoom(n);
4843
4836
  if (!o || !s) return;
4844
4837
  let c = r ?? Se(o.x, o.y, s.x, s.y);
@@ -4861,16 +4854,16 @@ function xt(e, t, n, r, i, a) {
4861
4854
  let g = h ? `Connected ${t}.${c} ↔ ${n}.${f}` : `Connected ${t}.${c} → ${n}`;
4862
4855
  D.setState({ status: g });
4863
4856
  }
4864
- var St = {
4857
+ var xt = {
4865
4858
  id: "unlink",
4866
4859
  cursor: "crosshair",
4867
4860
  onPointerDown(e, t) {
4868
4861
  if (e.button !== 0) return !1;
4869
- let n = ht();
4862
+ let n = mt();
4870
4863
  if (!n) return !1;
4871
- let r = Z(t, e), i = Q(t, e), a = t.settings.roomSize / 2;
4864
+ let r = Q(t, e), i = $(t, e), a = t.settings.roomSize / 2;
4872
4865
  if (!(i && Math.abs(r.x - i.x) <= a && Math.abs(r.y - i.y) <= a)) {
4873
- let e = lt(t.renderer, r.x, r.y, t.settings.roomSize);
4866
+ let e = ct(t.renderer, r.x, r.y, t.settings.roomSize);
4874
4867
  if (e) {
4875
4868
  let r = n.map.rooms[e.roomId], i = r?.customLines?.[e.exitName] ?? [], a = r?.customLinesColor?.[e.exitName] ?? {
4876
4869
  spec: 1,
@@ -4893,7 +4886,7 @@ var St = {
4893
4886
  let c = D.getState();
4894
4887
  return c.selection?.kind === "customLine" && c.selection.roomId === e.roomId && c.selection.exitName === e.exitName && D.setState({ selection: null }), D.setState({ status: `Removed custom line '${e.exitName}' from room ${e.roomId}` }), !0;
4895
4888
  }
4896
- let i = ct(t.renderer, r.x, r.y, t.settings.roomSize);
4889
+ let i = st(t.renderer, r.x, r.y, t.settings.roomSize);
4897
4890
  if (i) {
4898
4891
  if (!n.map.rooms[i.fromId]) return !0;
4899
4892
  let e = me[i.dir], r = n.map.rooms[i.toId], a = r && we(e) && J(r, e) === i.fromId ? {
@@ -4942,17 +4935,17 @@ var St = {
4942
4935
  }, t.scene), t.refresh(), D.bumpData(), D.setState({ status: `Removed all exits from room ${i.id}` }), !0);
4943
4936
  },
4944
4937
  onPointerMove(e, t) {
4945
- zt(t, e);
4938
+ Rt(t, e);
4946
4939
  }
4947
- }, Ct = {
4940
+ }, St = {
4948
4941
  id: "addRoom",
4949
4942
  cursor: "crosshair",
4950
4943
  onPointerDown(e, t) {
4951
4944
  if (e.button !== 0) return !1;
4952
- let n = ht();
4945
+ let n = mt();
4953
4946
  if (!n) return !1;
4954
- let { x: r, y: i } = mt(t, e), a = r, o = -i;
4955
- if (rt(n.map, n.areaId, a, o, n.z)) return D.setState({ status: "Cell is already occupied." }), !0;
4947
+ let { x: r, y: i } = pt(t, e), a = r, o = -i;
4948
+ if (nt(n.map, n.areaId, a, o, n.z)) return D.setState({ status: "Cell is already occupied." }), !0;
4956
4949
  let s = be(n.map);
4957
4950
  return Y({
4958
4951
  kind: "addRoom",
@@ -4969,17 +4962,17 @@ var St = {
4969
4962
  }), !0;
4970
4963
  },
4971
4964
  onPointerMove(e, t) {
4972
- let n = mt(t, e);
4973
- D.setState({ snapCursor: n }), zt(t, e);
4965
+ let n = pt(t, e);
4966
+ D.setState({ snapCursor: n }), Rt(t, e);
4974
4967
  }
4975
- }, wt = {
4968
+ }, Ct = {
4976
4969
  id: "delete",
4977
4970
  cursor: "not-allowed",
4978
4971
  onPointerDown(e, t) {
4979
4972
  if (e.button !== 0) return !1;
4980
- let n = ht();
4973
+ let n = mt();
4981
4974
  if (!n) return !1;
4982
- let r = Z(t, e), i = $e(n.areaId, n.z, r.x, r.y, t.scene.reader);
4975
+ let r = Q(t, e), i = Qe(n.areaId, n.z, r.x, r.y, t.scene.reader);
4983
4976
  if (i) {
4984
4977
  let e = t.scene.reader.getLabelSnapshot(i.areaId, i.id);
4985
4978
  if (e) {
@@ -4993,9 +4986,9 @@ var St = {
4993
4986
  }
4994
4987
  return !0;
4995
4988
  }
4996
- let a = Q(t, e), o = t.settings.roomSize / 2;
4989
+ let a = $(t, e), o = t.settings.roomSize / 2;
4997
4990
  if (!(a && Math.abs(r.x - a.x) <= o && Math.abs(r.y - a.y) <= o)) {
4998
- let e = lt(t.renderer, r.x, r.y, t.settings.roomSize);
4991
+ let e = ct(t.renderer, r.x, r.y, t.settings.roomSize);
4999
4992
  if (e) {
5000
4993
  let r = n.map.rooms[e.roomId], i = r?.customLines?.[e.exitName] ?? [], a = r?.customLinesColor?.[e.exitName] ?? {
5001
4994
  spec: 1,
@@ -5018,7 +5011,7 @@ var St = {
5018
5011
  let c = D.getState();
5019
5012
  return c.selection?.kind === "customLine" && c.selection.roomId === e.roomId && c.selection.exitName === e.exitName && D.setState({ selection: null }), D.setState({ status: `Removed custom line '${e.exitName}' from room ${e.roomId}` }), !0;
5020
5013
  }
5021
- let i = ct(t.renderer, r.x, r.y, t.settings.roomSize);
5014
+ let i = st(t.renderer, r.x, r.y, t.settings.roomSize);
5022
5015
  if (i) {
5023
5016
  if (!n.map.rooms[i.fromId]) return !0;
5024
5017
  let e = me[i.dir], r = n.map.rooms[i.toId], a = r && we(e) && J(r, e) === i.fromId ? {
@@ -5040,7 +5033,7 @@ var St = {
5040
5033
  if (!a) return D.setState({ status: "No exit, custom line, or room under cursor." }), !0;
5041
5034
  let s = n.map.rooms[a.id];
5042
5035
  if (!s) return !0;
5043
- let c = { ...s }, l = je(n.map, a.id);
5036
+ let c = { ...s }, l = Ae(n.map, a.id);
5044
5037
  Y({
5045
5038
  kind: "deleteRoom",
5046
5039
  id: a.id,
@@ -5052,37 +5045,37 @@ var St = {
5052
5045
  return u.selection?.kind === "room" && u.selection.ids.includes(a.id) && D.setState({ selection: null }), D.setState({ status: `Deleted room ${a.id}` }), !0;
5053
5046
  },
5054
5047
  onPointerMove(e, t) {
5055
- zt(t, e);
5048
+ Rt(t, e);
5056
5049
  }
5057
- }, Tt = !1, Et = {
5050
+ }, wt = !1, Tt = {
5058
5051
  id: "pan",
5059
5052
  cursor: "grab",
5060
5053
  onPointerDown(e, t) {
5061
- return e.button !== 0 || e.pointerType !== "mouse" ? !1 : (t.renderer.backend.viewport.startDrag(e.clientX, e.clientY), Tt = !0, !0);
5054
+ return e.button !== 0 || e.pointerType !== "mouse" ? !1 : (t.renderer.backend.viewport.startDrag(e.clientX, e.clientY), wt = !0, !0);
5062
5055
  },
5063
5056
  onPointerMove(e, t) {
5064
5057
  if (e.pointerType === "mouse") {
5065
- if (!Tt) {
5058
+ if (!wt) {
5066
5059
  if (e.buttons === 0) return;
5067
- t.renderer.backend.viewport.startDrag(e.clientX, e.clientY), Tt = !0;
5060
+ t.renderer.backend.viewport.startDrag(e.clientX, e.clientY), wt = !0;
5068
5061
  }
5069
5062
  return t.renderer.backend.viewport.updateDrag(e.clientX, e.clientY), t.refresh(), !0;
5070
5063
  }
5071
5064
  },
5072
5065
  onPointerUp(e, t) {
5073
- return Tt ? (t.renderer.backend.viewport.endDrag(), Tt = !1, !0) : !1;
5066
+ return wt ? (t.renderer.backend.viewport.endDrag(), wt = !1, !0) : !1;
5074
5067
  },
5075
5068
  onCancel(e) {
5076
- Tt &&= (e.renderer.backend.viewport.endDrag(), !1);
5069
+ wt &&= (e.renderer.backend.viewport.endDrag(), !1);
5077
5070
  }
5078
- }, Dt = {
5071
+ }, Et = {
5079
5072
  id: "customLine",
5080
5073
  cursor: "crosshair",
5081
5074
  onPointerDown(e, t) {
5082
5075
  let n = D.getState();
5083
5076
  if (!n.pending || n.pending.kind !== "customLine" || e.button !== 0) return !1;
5084
- let r = mt(t, e), i = [...n.pending.points, [r.x, r.y]];
5085
- return Ot(n.pending, i, t), D.setState({ pending: {
5077
+ let r = pt(t, e), i = [...n.pending.points, [r.x, r.y]];
5078
+ return Dt(n.pending, i, t), D.setState({ pending: {
5086
5079
  ...n.pending,
5087
5080
  points: i,
5088
5081
  cursor: r
@@ -5090,31 +5083,31 @@ var St = {
5090
5083
  },
5091
5084
  onContextMenu(e, t) {
5092
5085
  let n = D.getState();
5093
- return n.pending?.kind === "customLine" ? (At(n.pending, t), !0) : !1;
5086
+ return n.pending?.kind === "customLine" ? (kt(n.pending, t), !0) : !1;
5094
5087
  },
5095
5088
  onPointerMove(e, t) {
5096
- let n = D.getState(), r = mt(t, e);
5089
+ let n = D.getState(), r = pt(t, e);
5097
5090
  return n.pending?.kind === "customLine" ? (D.setState({ pending: {
5098
5091
  ...n.pending,
5099
5092
  cursor: r
5100
- } }), !0) : (zt(t, e), !1);
5093
+ } }), !0) : (Rt(t, e), !1);
5101
5094
  },
5102
5095
  onPointerUp() {
5103
5096
  return !1;
5104
5097
  },
5105
5098
  onCancel(e) {
5106
5099
  let t = D.getState();
5107
- t.pending?.kind === "customLine" && e && kt(t.pending, e.scene), D.setState({
5100
+ t.pending?.kind === "customLine" && e && Ot(t.pending, e.scene), D.setState({
5108
5101
  pending: null,
5109
5102
  status: "Custom line cancelled."
5110
5103
  }), D.bumpData();
5111
5104
  }
5112
5105
  };
5113
- function Ot(e, t, n) {
5106
+ function Dt(e, t, n) {
5114
5107
  let r = t.slice(1).map(([e, t]) => [e, -t]);
5115
5108
  n.scene.reader.setCustomLine(e.roomId, e.exitName, r, e.color, e.style, e.arrow), n.refresh();
5116
5109
  }
5117
- function kt(e, t) {
5110
+ function Ot(e, t) {
5118
5111
  if (e.previousSnapshot) {
5119
5112
  let n = e.previousSnapshot;
5120
5113
  t.reader.setCustomLine(e.roomId, e.exitName, n.points, n.color, n.style, n.arrow);
@@ -5128,10 +5121,10 @@ function kt(e, t) {
5128
5121
  }
5129
5122
  t.refresh();
5130
5123
  }
5131
- function At(e, t) {
5124
+ function kt(e, t) {
5132
5125
  if (!D.getState().map) return;
5133
5126
  if (e.points.length < 2) {
5134
- t && kt(e, t.scene), D.setState({
5127
+ t && Ot(e, t.scene), D.setState({
5135
5128
  pending: null,
5136
5129
  activeTool: "select",
5137
5130
  status: "Need at least 1 waypoint — cancelled."
@@ -5170,7 +5163,7 @@ function At(e, t) {
5170
5163
  status: `Custom line '${e.exitName}' saved on room ${e.roomId}`
5171
5164
  });
5172
5165
  }
5173
- function jt(e, t, n, r, i, a, o, s) {
5166
+ function At(e, t, n, r, i, a, o, s) {
5174
5167
  let c = t, l = t + r, u = n, d = n + i;
5175
5168
  switch (e) {
5176
5169
  case "nw":
@@ -5231,19 +5224,19 @@ function jt(e, t, n, r, i, a, o, s) {
5231
5224
  h
5232
5225
  };
5233
5226
  }
5234
- function Mt(e) {
5227
+ function jt(e) {
5235
5228
  let t = 0;
5236
5229
  for (let n of Object.values(e.labels ?? {})) for (let e of n) e.id > t && (t = e.id);
5237
5230
  return t + 1;
5238
5231
  }
5239
- var Nt = {
5232
+ var Mt = {
5240
5233
  id: "addLabel",
5241
5234
  cursor: "crosshair",
5242
5235
  onPointerDown(e, t) {
5243
5236
  if (e.button !== 0) return !1;
5244
- let n = ht();
5237
+ let n = mt();
5245
5238
  if (!n) return !1;
5246
- let r = mt(t, e);
5239
+ let r = pt(t, e);
5247
5240
  return D.setState({ pending: {
5248
5241
  kind: "labelRect",
5249
5242
  areaId: n.areaId,
@@ -5257,15 +5250,15 @@ var Nt = {
5257
5250
  onPointerMove(e, t) {
5258
5251
  let n = D.getState();
5259
5252
  if (n.pending?.kind === "labelRect") {
5260
- let r = Z(t, e);
5253
+ let r = Q(t, e);
5261
5254
  return D.setState({ pending: {
5262
5255
  ...n.pending,
5263
5256
  currentX: r.x,
5264
5257
  currentY: r.y
5265
5258
  } }), !0;
5266
5259
  }
5267
- let r = mt(t, e);
5268
- D.setState({ snapCursor: r }), zt(t, e);
5260
+ let r = pt(t, e);
5261
+ D.setState({ snapCursor: r }), Rt(t, e);
5269
5262
  },
5270
5263
  onPointerUp(e, t) {
5271
5264
  let n = D.getState();
@@ -5273,9 +5266,9 @@ var Nt = {
5273
5266
  try {
5274
5267
  t.container.releasePointerCapture(e.pointerId);
5275
5268
  } catch {}
5276
- let r = n.pending, i = ht();
5269
+ let r = n.pending, i = mt();
5277
5270
  if (!i) return D.setState({ pending: null }), !0;
5278
- let a = Math.abs(r.currentX - r.startX), o = Math.abs(r.currentY - r.startY), s = a < .5 ? 4 : a, c = o < .5 ? 1 : o, l = a < .5 ? r.startX : Math.min(r.startX, r.currentX), u = o < .5 ? r.startY : Math.min(r.startY, r.currentY), d = Mt(i.map), f = {
5271
+ let a = Math.abs(r.currentX - r.startX), o = Math.abs(r.currentY - r.startY), s = a < .5 ? 4 : a, c = o < .5 ? 1 : o, l = a < .5 ? r.startX : Math.min(r.startX, r.currentX), u = o < .5 ? r.startY : Math.min(r.startY, r.currentY), d = jt(i.map), f = {
5279
5272
  id: d,
5280
5273
  pos: [
5281
5274
  l,
@@ -5323,13 +5316,13 @@ var Nt = {
5323
5316
  D.setState({ pending: null });
5324
5317
  }
5325
5318
  };
5326
- function Pt(e) {
5319
+ function Nt(e) {
5327
5320
  return !e.activeSwatchSetId || !e.activeSwatchId ? null : [...e.swatchSets, ...e.pluginSwatchSets].find((t) => t.id === e.activeSwatchSetId)?.swatches.find((t) => t.id === e.activeSwatchId) ?? null;
5328
5321
  }
5329
- function Ft(e, t, n) {
5322
+ function Pt(e, t, n) {
5330
5323
  let r = D.getState();
5331
5324
  if (r.pending?.kind !== "paint") return;
5332
- let i = Q(e, t);
5325
+ let i = $(e, t);
5333
5326
  if (!i || r.pending.painted.some((e) => e.id === i.id)) return;
5334
5327
  let a = r.map?.rooms[i.id];
5335
5328
  if (!a) return;
@@ -5345,31 +5338,31 @@ function Ft(e, t, n) {
5345
5338
  painted: c
5346
5339
  } });
5347
5340
  }
5348
- var It = {
5349
- select: _t,
5350
- connect: bt,
5351
- unlink: St,
5352
- addRoom: Ct,
5353
- delete: wt,
5354
- pan: Et,
5355
- customLine: Dt,
5356
- addLabel: Nt,
5341
+ var Ft = {
5342
+ select: gt,
5343
+ connect: yt,
5344
+ unlink: xt,
5345
+ addRoom: St,
5346
+ delete: Ct,
5347
+ pan: Tt,
5348
+ customLine: Et,
5349
+ addLabel: Mt,
5357
5350
  paint: {
5358
5351
  id: "paint",
5359
5352
  cursor: "cell",
5360
5353
  onPointerDown(e, t) {
5361
5354
  if (e.button !== 0) return !1;
5362
- let n = Pt(D.getState());
5355
+ let n = Nt(D.getState());
5363
5356
  return n ? (D.setState({ pending: {
5364
5357
  kind: "paint",
5365
5358
  painted: []
5366
- } }), t.container.setPointerCapture(e.pointerId), Ft(t, e, n), !0) : (D.setState({ status: "No swatch selected — open the Swatches palette first." }), !0);
5359
+ } }), t.container.setPointerCapture(e.pointerId), Pt(t, e, n), !0) : (D.setState({ status: "No swatch selected — open the Swatches palette first." }), !0);
5367
5360
  },
5368
5361
  onPointerMove(e, t) {
5369
5362
  let n = D.getState();
5370
- if (n.pending?.kind !== "paint") return zt(t, e), !1;
5371
- let r = Pt(n);
5372
- return r && Ft(t, e, r), !0;
5363
+ if (n.pending?.kind !== "paint") return Rt(t, e), !1;
5364
+ let r = Nt(n);
5365
+ return r && Pt(t, e, r), !0;
5373
5366
  },
5374
5367
  onPointerUp(e, t) {
5375
5368
  let n = D.getState();
@@ -5377,7 +5370,7 @@ var It = {
5377
5370
  try {
5378
5371
  t.container.releasePointerCapture(e.pointerId);
5379
5372
  } catch {}
5380
- let r = n.pending.painted, i = Pt(n);
5373
+ let r = n.pending.painted, i = Nt(n);
5381
5374
  if (r.length > 0 && i) {
5382
5375
  let e = [];
5383
5376
  for (let { id: t, prevSymbol: n, prevEnv: a } of r) n !== i.symbol && e.push({
@@ -5416,7 +5409,7 @@ var It = {
5416
5409
  }
5417
5410
  }
5418
5411
  };
5419
- function Lt(e) {
5412
+ function It(e) {
5420
5413
  switch (e.kind) {
5421
5414
  case "room": return {
5422
5415
  kind: "room",
@@ -5440,7 +5433,7 @@ function Lt(e) {
5440
5433
  };
5441
5434
  }
5442
5435
  }
5443
- function Rt(e) {
5436
+ function Lt(e) {
5444
5437
  switch (e.kind) {
5445
5438
  case "room": return `room ${e.id}`;
5446
5439
  case "label": return `label ${e.id}`;
@@ -5448,12 +5441,12 @@ function Rt(e) {
5448
5441
  case "exit": return `exit ${e.dir} (${e.fromId}→${e.toId})`;
5449
5442
  }
5450
5443
  }
5451
- function zt(e, t) {
5452
- let n = ht();
5444
+ function Rt(e, t) {
5445
+ let n = mt();
5453
5446
  if (!n) return;
5454
- let r = Z(e, t), i = Q(e, t), a = null;
5447
+ let r = Q(e, t), i = $(e, t), a = null;
5455
5448
  if (i) {
5456
- let t = st(r, {
5449
+ let t = ot(r, {
5457
5450
  x: i.x,
5458
5451
  y: i.y
5459
5452
  }, e.settings.roomSize);
@@ -5463,21 +5456,21 @@ function zt(e, t) {
5463
5456
  handleDir: t
5464
5457
  };
5465
5458
  } else {
5466
- let t = $e(n.areaId, n.z, r.x, r.y, e.scene.reader);
5459
+ let t = Qe(n.areaId, n.z, r.x, r.y, e.scene.reader);
5467
5460
  if (t) a = {
5468
5461
  kind: "label",
5469
5462
  id: t.id,
5470
5463
  areaId: t.areaId
5471
5464
  };
5472
5465
  else {
5473
- let t = lt(e.renderer, r.x, r.y, e.settings.roomSize);
5466
+ let t = ct(e.renderer, r.x, r.y, e.settings.roomSize);
5474
5467
  if (t) a = {
5475
5468
  kind: "customLine",
5476
5469
  roomId: t.roomId,
5477
5470
  exitName: t.exitName
5478
5471
  };
5479
5472
  else {
5480
- let t = ct(e.renderer, r.x, r.y, e.settings.roomSize);
5473
+ let t = st(e.renderer, r.x, r.y, e.settings.roomSize);
5481
5474
  t && (a = {
5482
5475
  kind: "exit",
5483
5476
  ...t
@@ -5486,18 +5479,18 @@ function zt(e, t) {
5486
5479
  }
5487
5480
  }
5488
5481
  let o = D.getState().hover;
5489
- Bt(o, a) || D.setState({ hover: a });
5482
+ zt(o, a) || D.setState({ hover: a });
5490
5483
  }
5491
- function Bt(e, t) {
5484
+ function zt(e, t) {
5492
5485
  return e === t ? !0 : !e || !t || e.kind !== t.kind ? !1 : e.kind === "room" && t.kind === "room" ? e.id === t.id && e.handleDir === t.handleDir : e.kind === "exit" && t.kind === "exit" ? e.fromId === t.fromId && e.toId === t.toId && e.dir === t.dir : e.kind === "customLine" && t.kind === "customLine" ? e.roomId === t.roomId && e.exitName === t.exitName : e.kind === "label" && t.kind === "label" ? e.id === t.id && e.areaId === t.areaId : !1;
5493
5486
  }
5494
5487
  //#endregion
5495
5488
  //#region src/components/panels/CustomLinePanel.tsx
5496
- function Vt({ pending: e, sceneRef: t }) {
5489
+ function Bt({ pending: e, sceneRef: t }) {
5497
5490
  let n = (t) => D.setState({ pending: {
5498
5491
  ...e,
5499
5492
  ...t
5500
- } }), r = Le(e.color), i = (r) => {
5493
+ } }), r = Ie(e.color), i = (r) => {
5501
5494
  n(r);
5502
5495
  let i = t.current;
5503
5496
  if (!i) return;
@@ -5521,7 +5514,7 @@ function Vt({ pending: e, sceneRef: t }) {
5521
5514
  "Click to add waypoints · right-click or Enter to finish · Esc cancels."
5522
5515
  ]
5523
5516
  }),
5524
- /* @__PURE__ */ d(X, {
5517
+ /* @__PURE__ */ d(Z, {
5525
5518
  label: "Exit Name",
5526
5519
  children: /* @__PURE__ */ d("span", {
5527
5520
  className: "readonly",
@@ -5552,7 +5545,7 @@ function Vt({ pending: e, sceneRef: t }) {
5552
5545
  }), /* @__PURE__ */ d("input", {
5553
5546
  type: "color",
5554
5547
  value: r,
5555
- onChange: (e) => i({ color: Re(e.target.value) })
5548
+ onChange: (e) => i({ color: Le(e.target.value) })
5556
5549
  })]
5557
5550
  }),
5558
5551
  /* @__PURE__ */ f("div", {
@@ -5613,14 +5606,14 @@ function Vt({ pending: e, sceneRef: t }) {
5613
5606
  },
5614
5607
  children: [/* @__PURE__ */ d("button", {
5615
5608
  type: "button",
5616
- onClick: () => At(e),
5609
+ onClick: () => kt(e),
5617
5610
  disabled: e.points.length < 2,
5618
5611
  style: { flex: 1 },
5619
5612
  children: "Finish"
5620
5613
  }), /* @__PURE__ */ d("button", {
5621
5614
  type: "button",
5622
5615
  onClick: () => {
5623
- t.current && kt(e, t.current), D.setState({
5616
+ t.current && Ot(e, t.current), D.setState({
5624
5617
  pending: null,
5625
5618
  activeTool: "select",
5626
5619
  status: "Custom line cancelled."
@@ -5634,8 +5627,8 @@ function Vt({ pending: e, sceneRef: t }) {
5634
5627
  })
5635
5628
  });
5636
5629
  }
5637
- function Ht({ selection: e, map: t, sceneRef: n }) {
5638
- let r = t.rooms[e.roomId], a = r?.customLines?.[e.exitName], o = r?.customLinesColor?.[e.exitName], s = r?.customLinesStyle?.[e.exitName] ?? 1, c = r?.customLinesArrow?.[e.exitName] ?? !1, l = r?.mSpecialExits?.[e.exitName], p = J(r, he[e.exitName] ?? e.exitName), m = l ?? (p != null && p > 0 ? p : void 0), h = m == null ? null : t.rooms[m], [g, _] = i(o ? Le(o) : "#ffffff"), [v, y] = i(s), [b, x] = i(c), [S, C] = i(null);
5630
+ function Vt({ selection: e, map: t, sceneRef: n }) {
5631
+ let r = t.rooms[e.roomId], a = r?.customLines?.[e.exitName], o = r?.customLinesColor?.[e.exitName], s = r?.customLinesStyle?.[e.exitName] ?? 1, c = r?.customLinesArrow?.[e.exitName] ?? !1, l = r?.mSpecialExits?.[e.exitName], p = J(r, he[e.exitName] ?? e.exitName), m = l ?? (p != null && p > 0 ? p : void 0), h = m == null ? null : t.rooms[m], [g, _] = i(o ? Ie(o) : "#ffffff"), [v, y] = i(s), [b, x] = i(c), [S, C] = i(null);
5639
5632
  if (!r || !a) return /* @__PURE__ */ d("h3", { children: "Custom line not found" });
5640
5633
  let w = (e) => ({
5641
5634
  points: a,
@@ -5745,7 +5738,7 @@ function Ht({ selection: e, map: t, sceneRef: n }) {
5745
5738
  children: [/* @__PURE__ */ d("span", {
5746
5739
  className: "label",
5747
5740
  children: h == null ? "Room" : "From"
5748
- }), /* @__PURE__ */ d(Ne, {
5741
+ }), /* @__PURE__ */ d(Me, {
5749
5742
  id: e.roomId,
5750
5743
  name: r.name
5751
5744
  })]
@@ -5755,7 +5748,7 @@ function Ht({ selection: e, map: t, sceneRef: n }) {
5755
5748
  children: [/* @__PURE__ */ d("span", {
5756
5749
  className: "label",
5757
5750
  children: "To"
5758
- }), /* @__PURE__ */ d(Ne, {
5751
+ }), /* @__PURE__ */ d(Me, {
5759
5752
  id: m,
5760
5753
  name: h.name
5761
5754
  })]
@@ -5793,7 +5786,7 @@ function Ht({ selection: e, map: t, sceneRef: n }) {
5793
5786
  type: "color",
5794
5787
  value: g,
5795
5788
  onChange: (e) => _(e.target.value),
5796
- onBlur: (e) => E({ color: Re(e.target.value) })
5789
+ onBlur: (e) => E({ color: Le(e.target.value) })
5797
5790
  })]
5798
5791
  }),
5799
5792
  /* @__PURE__ */ f("div", {
@@ -5898,7 +5891,7 @@ function Ht({ selection: e, map: t, sceneRef: n }) {
5898
5891
  width: "100%"
5899
5892
  },
5900
5893
  onClick: () => {
5901
- let t = D.getState().gridStep, r = a.map(([e, n]) => [Ze(e, t), -Ze(-n, t)]);
5894
+ let t = D.getState().gridStep, r = a.map(([e, n]) => [Xe(e, t), -Xe(-n, t)]);
5902
5895
  if (!r.some((e, t) => e[0] !== a[t][0] || e[1] !== a[t][1])) {
5903
5896
  D.setState({ status: `Custom line '${e.exitName}' already on grid.` });
5904
5897
  return;
@@ -5936,28 +5929,28 @@ function Ht({ selection: e, map: t, sceneRef: n }) {
5936
5929
  }
5937
5930
  //#endregion
5938
5931
  //#region src/editor/labelPixmap.ts
5939
- var Ut = 64;
5940
- function Wt(e) {
5932
+ var Ht = 64;
5933
+ function Ut(e) {
5941
5934
  return `rgba(${e.r},${e.g},${e.b},${(e.alpha / 255).toFixed(3)})`;
5942
5935
  }
5943
- function Gt(e) {
5936
+ function Wt(e) {
5944
5937
  let t = document.createElement("canvas"), n = t.getContext("2d");
5945
5938
  if (!n) return "";
5946
- let r = Math.max(1, Math.round(e.size[0] * Ut)), i = Math.max(1, Math.round(e.size[1] * Ut)), a = window.devicePixelRatio || 1;
5947
- if (t.width = r * a, t.height = i * a, n.scale(a, a), n.fillStyle = Wt(e.bgColor), n.fillRect(0, 0, r, i), !e.text) return t.toDataURL("image/png");
5939
+ let r = Math.max(1, Math.round(e.size[0] * Ht)), i = Math.max(1, Math.round(e.size[1] * Ht)), a = window.devicePixelRatio || 1;
5940
+ if (t.width = r * a, t.height = i * a, n.scale(a, a), n.fillStyle = Ut(e.bgColor), n.fillRect(0, 0, r, i), !e.text) return t.toDataURL("image/png");
5948
5941
  let { font: o } = e;
5949
5942
  n.font = [
5950
5943
  o.italic ? "italic" : "",
5951
5944
  o.bold ? "bold" : "",
5952
5945
  `${o.size}px`,
5953
5946
  `"${o.family}", sans-serif`
5954
- ].filter(Boolean).join(" "), n.fillStyle = Wt(e.fgColor), n.textBaseline = "middle", n.textAlign = "center";
5947
+ ].filter(Boolean).join(" "), n.fillStyle = Ut(e.fgColor), n.textBaseline = "middle", n.textAlign = "center";
5955
5948
  let s = e.text.split("\n"), c = o.size * 1.25, l = (i - s.length * c) / 2 + c / 2, u = r / 2;
5956
5949
  for (let t = 0; t < s.length; t++) {
5957
5950
  let i = l + t * c;
5958
- if (e.outlineColor && e.outlineColor.alpha > 0 && (n.strokeStyle = Wt(e.outlineColor), n.lineWidth = Math.max(1, o.size / 12), n.lineJoin = "round", n.strokeText(s[t], u, i, r)), n.fillText(s[t], u, i, r), o.underline || o.strikeout) {
5951
+ if (e.outlineColor && e.outlineColor.alpha > 0 && (n.strokeStyle = Ut(e.outlineColor), n.lineWidth = Math.max(1, o.size / 12), n.lineJoin = "round", n.strokeText(s[t], u, i, r)), n.fillText(s[t], u, i, r), o.underline || o.strikeout) {
5959
5952
  let r = n.measureText(s[t]).width, a = u - r / 2, c = u + r / 2;
5960
- if (n.strokeStyle = Wt(e.fgColor), n.lineWidth = Math.max(1, o.size / 14), o.underline) {
5953
+ if (n.strokeStyle = Ut(e.fgColor), n.lineWidth = Math.max(1, o.size / 14), o.underline) {
5961
5954
  let e = i + o.size * .6;
5962
5955
  n.beginPath(), n.moveTo(a, e), n.lineTo(c, e), n.stroke();
5963
5956
  }
@@ -5966,13 +5959,13 @@ function Gt(e) {
5966
5959
  }
5967
5960
  return t.toDataURL("image/png");
5968
5961
  }
5969
- function Kt(e) {
5962
+ function Gt(e) {
5970
5963
  let t = e.includes(",") ? e.split(",")[1] : e;
5971
- return t ? ne.from(t, "base64") : ne.alloc(0);
5964
+ return t ? re.from(t, "base64") : re.alloc(0);
5972
5965
  }
5973
5966
  //#endregion
5974
5967
  //#region src/components/FontPicker.tsx
5975
- function qt({ value: e, options: n, onChange: a }) {
5968
+ function Kt({ value: e, options: n, onChange: a }) {
5976
5969
  let [o, s] = i(!1), [c, p] = i(""), [m, h] = i(-1), [g, _] = i({}), v = r(null), y = r(null), b = r(null), x = c.trim() ? n.filter((e) => e.toLowerCase().includes(c.toLowerCase())) : n;
5977
5970
  t(() => {
5978
5971
  let t = x.findIndex((t) => t === e);
@@ -6075,7 +6068,7 @@ function qt({ value: e, options: n, onChange: a }) {
6075
6068
  }
6076
6069
  //#endregion
6077
6070
  //#region src/components/panels/LabelPanel.tsx
6078
- var Jt = [
6071
+ var qt = [
6079
6072
  "Arial",
6080
6073
  "Arial Black",
6081
6074
  "Comic Sans MS",
@@ -6088,9 +6081,9 @@ var Jt = [
6088
6081
  "Times New Roman",
6089
6082
  "Trebuchet MS",
6090
6083
  "Verdana"
6091
- ], Yt = (e, t) => e.r === t.r && e.g === t.g && e.b === t.b && e.alpha === t.alpha, Xt = (e, t) => e === void 0 && t === void 0 ? !0 : e === void 0 || t === void 0 ? !1 : Yt(e, t), Zt = 64;
6092
- function Qt({ selection: e, sceneRef: n }) {
6093
- let a = O((e) => e.dataVersion), o = O((e) => e.labelAspectRatioLocked), s = n.current?.reader.getLabelSnapshot(e.areaId, e.id), [c, l] = i(s?.text ?? ""), [p, m] = i(String(s?.size[0] ?? 4)), [h, g] = i(String(s?.size[1] ?? 1)), [_, v] = i(s?.bgColor.alpha ?? 255), [y, b] = i(s?.outlineColor?.alpha ?? 0), [x, S] = i(Jt);
6084
+ ], Jt = (e, t) => e.r === t.r && e.g === t.g && e.b === t.b && e.alpha === t.alpha, Yt = (e, t) => e === void 0 && t === void 0 ? !0 : e === void 0 || t === void 0 ? !1 : Jt(e, t), Xt = 64;
6085
+ function Zt({ selection: e, sceneRef: n }) {
6086
+ let a = O((e) => e.dataVersion), o = O((e) => e.labelAspectRatioLocked), s = n.current?.reader.getLabelSnapshot(e.areaId, e.id), [c, l] = i(s?.text ?? ""), [p, m] = i(String(s?.size[0] ?? 4)), [h, g] = i(String(s?.size[1] ?? 1)), [_, v] = i(s?.bgColor.alpha ?? 255), [y, b] = i(s?.outlineColor?.alpha ?? 0), [x, S] = i(qt);
6094
6087
  t(() => {
6095
6088
  "queryLocalFonts" in window && window.queryLocalFonts?.().then((e) => {
6096
6089
  let t = [...new Set(e.map((e) => e.family))].sort();
@@ -6119,7 +6112,7 @@ function Qt({ selection: e, sceneRef: n }) {
6119
6112
  })
6120
6113
  });
6121
6114
  let N = (t) => {
6122
- let n = Gt(t);
6115
+ let n = Wt(t);
6123
6116
  return n === t.pixMap ? [] : [{
6124
6117
  kind: "setLabelPixmap",
6125
6118
  areaId: e.areaId,
@@ -6136,7 +6129,7 @@ function Qt({ selection: e, sceneRef: n }) {
6136
6129
  ...r,
6137
6130
  text: E.current
6138
6131
  };
6139
- De([{
6132
+ X([{
6140
6133
  kind: "setLabelText",
6141
6134
  areaId: e.areaId,
6142
6135
  id: e.id,
@@ -6154,7 +6147,7 @@ function Qt({ selection: e, sceneRef: n }) {
6154
6147
  ...r,
6155
6148
  size: [i, a]
6156
6149
  };
6157
- De([{
6150
+ X([{
6158
6151
  kind: "setLabelSize",
6159
6152
  areaId: e.areaId,
6160
6153
  id: e.id,
@@ -6171,7 +6164,7 @@ function Qt({ selection: e, sceneRef: n }) {
6171
6164
  fg: s.fgColor,
6172
6165
  bg: s.bgColor
6173
6166
  };
6174
- if (j.current = null, !i || Yt(a.fg, t) && Yt(a.bg, r)) return;
6167
+ if (j.current = null, !i || Jt(a.fg, t) && Jt(a.bg, r)) return;
6175
6168
  let o = i.reader.getLabelSnapshot(e.areaId, e.id);
6176
6169
  if (!o) return;
6177
6170
  let c = {
@@ -6179,7 +6172,7 @@ function Qt({ selection: e, sceneRef: n }) {
6179
6172
  fgColor: t,
6180
6173
  bgColor: r
6181
6174
  };
6182
- De([{
6175
+ X([{
6183
6176
  kind: "setLabelColors",
6184
6177
  areaId: e.areaId,
6185
6178
  id: e.id,
@@ -6199,7 +6192,7 @@ function Qt({ selection: e, sceneRef: n }) {
6199
6192
  from: i.noScaling,
6200
6193
  to: t
6201
6194
  }, r), r.refresh(), D.bumpData());
6202
- }, z = (t) => {
6195
+ }, ee = (t) => {
6203
6196
  let r = n.current;
6204
6197
  if (!r) return;
6205
6198
  let i = r.reader.getLabelSnapshot(e.areaId, e.id);
@@ -6210,7 +6203,7 @@ function Qt({ selection: e, sceneRef: n }) {
6210
6203
  from: i.showOnTop,
6211
6204
  to: t
6212
6205
  }, r), r.refresh(), D.bumpData());
6213
- }, B = (t) => {
6206
+ }, z = (t) => {
6214
6207
  let r = n.current;
6215
6208
  if (!r) return;
6216
6209
  let i = r.reader.getLabelSnapshot(e.areaId, e.id);
@@ -6219,7 +6212,7 @@ function Qt({ selection: e, sceneRef: n }) {
6219
6212
  ...i.font,
6220
6213
  ...t
6221
6214
  };
6222
- De([{
6215
+ X([{
6223
6216
  kind: "setLabelFont",
6224
6217
  areaId: e.areaId,
6225
6218
  id: e.id,
@@ -6229,32 +6222,32 @@ function Qt({ selection: e, sceneRef: n }) {
6229
6222
  ...i,
6230
6223
  font: a
6231
6224
  })], r), r.refresh(), D.bumpData();
6232
- }, V = () => {
6225
+ }, B = () => {
6233
6226
  M.current ||= { color: s.outlineColor };
6234
- }, H = (t) => {
6227
+ }, V = (t) => {
6235
6228
  let r = n.current, i = M.current ?? { color: s.outlineColor };
6236
- if (M.current = null, !r || Xt(i.color, t)) return;
6229
+ if (M.current = null, !r || Yt(i.color, t)) return;
6237
6230
  let a = r.reader.getLabelSnapshot(e.areaId, e.id);
6238
6231
  if (!a) return;
6239
6232
  let o = {
6240
6233
  ...a,
6241
6234
  outlineColor: t
6242
6235
  };
6243
- De([{
6236
+ X([{
6244
6237
  kind: "setLabelOutlineColor",
6245
6238
  areaId: e.areaId,
6246
6239
  id: e.id,
6247
6240
  from: i.color,
6248
6241
  to: t
6249
6242
  }, ...N(o)], r), r.refresh(), D.bumpData();
6250
- }, ee = () => {
6243
+ }, te = () => {
6251
6244
  let t = n.current;
6252
6245
  if (!t) return;
6253
6246
  let r = t.reader.getLabelSnapshot(e.areaId, e.id);
6254
6247
  if (!r || !r.text) return;
6255
6248
  let i = document.createElement("canvas").getContext("2d");
6256
6249
  if (!i) return;
6257
- let a = Math.max(1, Math.round(r.size[0] * Zt)), o = Math.max(1, Math.round(r.size[1] * Zt)), s = a - 16, c = o - 16;
6250
+ let a = Math.max(1, Math.round(r.size[0] * Xt)), o = Math.max(1, Math.round(r.size[1] * Xt)), s = a - 16, c = o - 16;
6258
6251
  if (s <= 0 || c <= 0) return;
6259
6252
  let l = r.text.split("\n"), { font: u } = r, d = Math.floor(c / (l.length * 1.25)), f = 1, p = d, m = 1;
6260
6253
  for (; f <= p;) {
@@ -6266,13 +6259,13 @@ function Qt({ selection: e, sceneRef: n }) {
6266
6259
  `"${u.family}", sans-serif`
6267
6260
  ].filter(Boolean).join(" "), Math.max(...l.map((e) => i.measureText(e).width)) <= s ? (m = e, f = e + 1) : p = e - 1;
6268
6261
  }
6269
- m !== r.font.size && B({ size: m });
6270
- }, te = () => {
6262
+ m !== r.font.size && z({ size: m });
6263
+ }, ne = () => {
6271
6264
  let t = n.current;
6272
6265
  if (!t) return;
6273
6266
  let r = t.reader.getLabelSnapshot(e.areaId, e.id);
6274
6267
  if (!r) return;
6275
- let i = Gt(r);
6268
+ let i = Wt(r);
6276
6269
  i !== r.pixMap && (Y({
6277
6270
  kind: "setLabelPixmap",
6278
6271
  areaId: e.areaId,
@@ -6280,7 +6273,7 @@ function Qt({ selection: e, sceneRef: n }) {
6280
6273
  from: r.pixMap,
6281
6274
  to: i
6282
6275
  }, t), t.refresh(), D.bumpData());
6283
- }, ne = () => {
6276
+ }, re = () => {
6284
6277
  let t = document.createElement("input");
6285
6278
  t.type = "file", t.accept = "image/*", t.onchange = () => {
6286
6279
  let r = t.files?.[0];
@@ -6293,8 +6286,8 @@ function Qt({ selection: e, sceneRef: n }) {
6293
6286
  if (!i) return;
6294
6287
  let a = i.reader.getLabelSnapshot(e.areaId, e.id);
6295
6288
  if (!a) return;
6296
- let o = Math.max(.1, Math.round(r.naturalWidth / Zt * 100) / 100), s = Math.max(.1, Math.round(r.naturalHeight / Zt * 100) / 100);
6297
- De([
6289
+ let o = Math.max(.1, Math.round(r.naturalWidth / Xt * 100) / 100), s = Math.max(.1, Math.round(r.naturalHeight / Xt * 100) / 100);
6290
+ X([
6298
6291
  {
6299
6292
  kind: "setLabelImageSrc",
6300
6293
  areaId: e.areaId,
@@ -6320,13 +6313,13 @@ function Qt({ selection: e, sceneRef: n }) {
6320
6313
  }, r.src = t;
6321
6314
  }, i.readAsDataURL(r);
6322
6315
  }, t.click();
6323
- }, re = () => {
6316
+ }, ie = () => {
6324
6317
  let t = n.current;
6325
6318
  if (!t) return;
6326
6319
  let r = t.reader.getLabelSnapshot(e.areaId, e.id);
6327
6320
  if (!r || !r.imageSrc) return;
6328
- let i = Gt(r);
6329
- De([{
6321
+ let i = Wt(r);
6322
+ X([{
6330
6323
  kind: "setLabelImageSrc",
6331
6324
  areaId: e.areaId,
6332
6325
  id: e.id,
@@ -6339,14 +6332,14 @@ function Qt({ selection: e, sceneRef: n }) {
6339
6332
  from: r.pixMap,
6340
6333
  to: i
6341
6334
  }], t), t.refresh(), D.setState({ labelAspectRatioLocked: !1 }), D.bumpData();
6342
- }, U = !!s.imageSrc, W = Le(s.fgColor), G = Le(s.bgColor), ie = s.outlineColor ?? {
6335
+ }, H = !!s.imageSrc, U = Ie(s.fgColor), W = Ie(s.bgColor), G = s.outlineColor ?? {
6343
6336
  spec: 1,
6344
6337
  r: 0,
6345
6338
  g: 0,
6346
6339
  b: 0,
6347
6340
  alpha: 0,
6348
6341
  pad: 0
6349
- }, ae = Le(ie), oe = (e) => ({
6342
+ }, ae = Ie(G), oe = (e) => ({
6350
6343
  flex: 1,
6351
6344
  padding: "4px 0",
6352
6345
  fontSize: 12,
@@ -6381,18 +6374,18 @@ function Qt({ selection: e, sceneRef: n }) {
6381
6374
  overflow: "hidden"
6382
6375
  },
6383
6376
  children: [/* @__PURE__ */ d("button", {
6384
- style: oe(!U),
6377
+ style: oe(!H),
6385
6378
  onClick: () => {
6386
- U && re();
6379
+ H && ie();
6387
6380
  },
6388
6381
  children: "Text"
6389
6382
  }), /* @__PURE__ */ d("button", {
6390
6383
  style: {
6391
- ...oe(U),
6384
+ ...oe(H),
6392
6385
  borderLeft: "1px solid var(--border, #444)"
6393
6386
  },
6394
6387
  onClick: () => {
6395
- U || ne();
6388
+ H || re();
6396
6389
  },
6397
6390
  children: "Image"
6398
6391
  })]
@@ -6400,7 +6393,7 @@ function Qt({ selection: e, sceneRef: n }) {
6400
6393
  /* @__PURE__ */ f("div", {
6401
6394
  className: "field-row",
6402
6395
  children: [
6403
- /* @__PURE__ */ d(X, {
6396
+ /* @__PURE__ */ d(Z, {
6404
6397
  label: "Width",
6405
6398
  children: /* @__PURE__ */ d("input", {
6406
6399
  type: "number",
@@ -6418,7 +6411,7 @@ function Qt({ selection: e, sceneRef: n }) {
6418
6411
  style: { width: 70 }
6419
6412
  })
6420
6413
  }),
6421
- /* @__PURE__ */ d(X, {
6414
+ /* @__PURE__ */ d(Z, {
6422
6415
  label: "Height",
6423
6416
  children: /* @__PURE__ */ d("input", {
6424
6417
  type: "number",
@@ -6447,17 +6440,17 @@ function Qt({ selection: e, sceneRef: n }) {
6447
6440
  })
6448
6441
  ]
6449
6442
  }),
6450
- /* @__PURE__ */ d(Pe, {
6443
+ /* @__PURE__ */ d(Ne, {
6451
6444
  checked: s.showOnTop,
6452
- onChange: z,
6445
+ onChange: ee,
6453
6446
  description: "Show on top (foreground)"
6454
6447
  }),
6455
- /* @__PURE__ */ d(Pe, {
6448
+ /* @__PURE__ */ d(Ne, {
6456
6449
  checked: !s.noScaling,
6457
6450
  onChange: (e) => R(!e),
6458
6451
  description: "Scale with zoom"
6459
6452
  }),
6460
- U && /* @__PURE__ */ d(X, {
6453
+ H && /* @__PURE__ */ d(Z, {
6461
6454
  label: "Image",
6462
6455
  children: /* @__PURE__ */ f("div", {
6463
6456
  style: {
@@ -6475,14 +6468,14 @@ function Qt({ selection: e, sceneRef: n }) {
6475
6468
  borderRadius: 3
6476
6469
  }
6477
6470
  }), /* @__PURE__ */ d("button", {
6478
- onClick: ne,
6471
+ onClick: re,
6479
6472
  style: { alignSelf: "flex-start" },
6480
6473
  children: "Replace image..."
6481
6474
  })]
6482
6475
  })
6483
6476
  }),
6484
- !U && /* @__PURE__ */ f(u, { children: [
6485
- /* @__PURE__ */ d(X, {
6477
+ !H && /* @__PURE__ */ f(u, { children: [
6478
+ /* @__PURE__ */ d(Z, {
6486
6479
  label: "Text",
6487
6480
  children: /* @__PURE__ */ d("textarea", {
6488
6481
  value: c,
@@ -6502,30 +6495,30 @@ function Qt({ selection: e, sceneRef: n }) {
6502
6495
  display: "flex",
6503
6496
  gap: 8
6504
6497
  },
6505
- children: [/* @__PURE__ */ d(X, {
6498
+ children: [/* @__PURE__ */ d(Z, {
6506
6499
  label: "Text color",
6507
6500
  as: "div",
6508
6501
  children: /* @__PURE__ */ d("input", {
6509
6502
  type: "color",
6510
- defaultValue: W,
6503
+ defaultValue: U,
6511
6504
  onMouseDown: I,
6512
- onBlur: (e) => L(Re(e.target.value), s.bgColor)
6513
- }, `fg-${e.id}-${W}`)
6514
- }), /* @__PURE__ */ d(X, {
6505
+ onBlur: (e) => L(Le(e.target.value), s.bgColor)
6506
+ }, `fg-${e.id}-${U}`)
6507
+ }), /* @__PURE__ */ d(Z, {
6515
6508
  label: "BG color",
6516
6509
  as: "div",
6517
6510
  children: /* @__PURE__ */ d("input", {
6518
6511
  type: "color",
6519
- defaultValue: G,
6512
+ defaultValue: W,
6520
6513
  onMouseDown: I,
6521
6514
  onBlur: (e) => L(s.fgColor, {
6522
- ...Re(e.target.value),
6515
+ ...Le(e.target.value),
6523
6516
  alpha: s.bgColor.alpha
6524
6517
  })
6525
- }, `bg-${e.id}-${G}`)
6518
+ }, `bg-${e.id}-${W}`)
6526
6519
  })]
6527
6520
  }),
6528
- /* @__PURE__ */ d(X, {
6521
+ /* @__PURE__ */ d(Z, {
6529
6522
  label: "BG alpha",
6530
6523
  children: /* @__PURE__ */ f("div", {
6531
6524
  style: {
@@ -6562,16 +6555,16 @@ function Qt({ selection: e, sceneRef: n }) {
6562
6555
  })]
6563
6556
  })
6564
6557
  }),
6565
- /* @__PURE__ */ d(X, {
6558
+ /* @__PURE__ */ d(Z, {
6566
6559
  label: "Font",
6567
6560
  as: "div",
6568
- children: /* @__PURE__ */ d(qt, {
6561
+ children: /* @__PURE__ */ d(Kt, {
6569
6562
  value: s.font.family,
6570
6563
  options: x,
6571
- onChange: (e) => B({ family: e })
6564
+ onChange: (e) => z({ family: e })
6572
6565
  })
6573
6566
  }),
6574
- /* @__PURE__ */ d(X, {
6567
+ /* @__PURE__ */ d(Z, {
6575
6568
  label: "Size",
6576
6569
  children: /* @__PURE__ */ f("div", {
6577
6570
  style: {
@@ -6587,14 +6580,14 @@ function Qt({ selection: e, sceneRef: n }) {
6587
6580
  defaultValue: s.font.size,
6588
6581
  onBlur: (e) => {
6589
6582
  let t = parseInt(e.target.value, 10);
6590
- t > 0 && B({ size: t });
6583
+ t > 0 && z({ size: t });
6591
6584
  },
6592
6585
  onKeyDown: (e) => e.key === "Enter" && e.target.blur(),
6593
6586
  style: { width: 60 }
6594
6587
  }, `font-size-${e.id}-${s.font.size}`),
6595
6588
  /* @__PURE__ */ d("button", {
6596
6589
  title: "Auto-fit font size to fill label area",
6597
- onClick: ee,
6590
+ onClick: te,
6598
6591
  style: {
6599
6592
  height: 24,
6600
6593
  padding: "0 6px",
@@ -6635,7 +6628,7 @@ function Qt({ selection: e, sceneRef: n }) {
6635
6628
  ]
6636
6629
  ].map(([e, t, n]) => /* @__PURE__ */ d("button", {
6637
6630
  title: t,
6638
- onClick: () => B({ [t]: !s.font[t] }),
6631
+ onClick: () => z({ [t]: !s.font[t] }),
6639
6632
  style: {
6640
6633
  width: 24,
6641
6634
  height: 24,
@@ -6654,20 +6647,20 @@ function Qt({ selection: e, sceneRef: n }) {
6654
6647
  ]
6655
6648
  })
6656
6649
  }),
6657
- /* @__PURE__ */ d(X, {
6650
+ /* @__PURE__ */ d(Z, {
6658
6651
  label: "Outline color",
6659
6652
  as: "div",
6660
6653
  children: /* @__PURE__ */ d("input", {
6661
6654
  type: "color",
6662
6655
  defaultValue: ae,
6663
- onMouseDown: V,
6664
- onBlur: (e) => H({
6665
- ...ie,
6666
- ...Re(e.target.value)
6656
+ onMouseDown: B,
6657
+ onBlur: (e) => V({
6658
+ ...G,
6659
+ ...Le(e.target.value)
6667
6660
  })
6668
6661
  }, `outline-${e.id}-${ae}`)
6669
6662
  }),
6670
- /* @__PURE__ */ d(X, {
6663
+ /* @__PURE__ */ d(Z, {
6671
6664
  label: "Outline alpha",
6672
6665
  children: /* @__PURE__ */ f("div", {
6673
6666
  style: {
@@ -6683,19 +6676,19 @@ function Qt({ selection: e, sceneRef: n }) {
6683
6676
  step: 1,
6684
6677
  value: y,
6685
6678
  style: { flex: 1 },
6686
- onPointerDown: V,
6679
+ onPointerDown: B,
6687
6680
  onChange: (e) => b(parseInt(e.target.value, 10)),
6688
6681
  onPointerUp: (e) => {
6689
6682
  let t = parseInt(e.target.value, 10);
6690
- H(t === 0 ? void 0 : {
6691
- ...ie,
6683
+ V(t === 0 ? void 0 : {
6684
+ ...G,
6692
6685
  alpha: t
6693
6686
  });
6694
6687
  },
6695
6688
  onBlur: (e) => {
6696
6689
  let t = parseInt(e.target.value, 10);
6697
- H(t === 0 ? void 0 : {
6698
- ...ie,
6690
+ V(t === 0 ? void 0 : {
6691
+ ...G,
6699
6692
  alpha: t
6700
6693
  });
6701
6694
  }
@@ -6710,7 +6703,7 @@ function Qt({ selection: e, sceneRef: n }) {
6710
6703
  })]
6711
6704
  })
6712
6705
  }),
6713
- /* @__PURE__ */ d(X, {
6706
+ /* @__PURE__ */ d(Z, {
6714
6707
  label: "Pixmap",
6715
6708
  children: /* @__PURE__ */ f("div", {
6716
6709
  style: {
@@ -6731,7 +6724,7 @@ function Qt({ selection: e, sceneRef: n }) {
6731
6724
  className: "hint",
6732
6725
  children: "No pixmap stored"
6733
6726
  }), /* @__PURE__ */ d("button", {
6734
- onClick: te,
6727
+ onClick: ne,
6735
6728
  style: { alignSelf: "flex-start" },
6736
6729
  children: "Regenerate pixmap"
6737
6730
  })]
@@ -6743,7 +6736,7 @@ function Qt({ selection: e, sceneRef: n }) {
6743
6736
  }
6744
6737
  //#endregion
6745
6738
  //#region src/components/EnvPicker.tsx
6746
- function $t({ map: e, sceneRef: n, currentEnvId: a, onSelect: o, onClose: s }) {
6739
+ function Qt({ map: e, sceneRef: n, currentEnvId: a, onSelect: o, onClose: s }) {
6747
6740
  let c = r(null), [l, u] = i("");
6748
6741
  t(() => {
6749
6742
  let e = (e) => {
@@ -6818,7 +6811,7 @@ function $t({ map: e, sceneRef: n, currentEnvId: a, onSelect: o, onClose: s }) {
6818
6811
  }
6819
6812
  //#endregion
6820
6813
  //#region src/components/icons.tsx
6821
- function en() {
6814
+ function $t() {
6822
6815
  return /* @__PURE__ */ f("svg", {
6823
6816
  width: "10",
6824
6817
  height: "12",
@@ -6841,7 +6834,7 @@ function en() {
6841
6834
  })]
6842
6835
  });
6843
6836
  }
6844
- function tn({ locked: e }) {
6837
+ function en({ locked: e }) {
6845
6838
  return /* @__PURE__ */ f("svg", {
6846
6839
  width: "10",
6847
6840
  height: "12",
@@ -6878,7 +6871,7 @@ function tn({ locked: e }) {
6878
6871
  ]
6879
6872
  });
6880
6873
  }
6881
- function nn() {
6874
+ function tn() {
6882
6875
  return /* @__PURE__ */ f("svg", {
6883
6876
  width: "12",
6884
6877
  height: "8",
@@ -6911,7 +6904,7 @@ function nn() {
6911
6904
  ]
6912
6905
  });
6913
6906
  }
6914
- function rn() {
6907
+ function nn() {
6915
6908
  return /* @__PURE__ */ f("svg", {
6916
6909
  width: "11",
6917
6910
  height: "11",
@@ -6932,7 +6925,7 @@ function rn() {
6932
6925
  })]
6933
6926
  });
6934
6927
  }
6935
- function an() {
6928
+ function rn() {
6936
6929
  return /* @__PURE__ */ f("svg", {
6937
6930
  width: "10",
6938
6931
  height: "10",
@@ -6988,7 +6981,7 @@ function an() {
6988
6981
  }
6989
6982
  //#endregion
6990
6983
  //#region src/components/RoomPanel.tsx
6991
- var on = [
6984
+ var an = [
6992
6985
  "north",
6993
6986
  "northeast",
6994
6987
  "east",
@@ -7001,7 +6994,7 @@ var on = [
7001
6994
  "down",
7002
6995
  "in",
7003
6996
  "out"
7004
- ], sn = [
6997
+ ], on = [
7005
6998
  [
7006
6999
  "northwest",
7007
7000
  "north",
@@ -7017,7 +7010,7 @@ var on = [
7017
7010
  "south",
7018
7011
  "southeast"
7019
7012
  ]
7020
- ], cn = [[
7013
+ ], sn = [[
7021
7014
  "up",
7022
7015
  null,
7023
7016
  "down"
@@ -7025,7 +7018,7 @@ var on = [
7025
7018
  "in",
7026
7019
  null,
7027
7020
  "out"
7028
- ]], ln = {
7021
+ ]], cn = {
7029
7022
  north: "N",
7030
7023
  northeast: "NE",
7031
7024
  east: "E",
@@ -7038,29 +7031,29 @@ var on = [
7038
7031
  down: "Dn",
7039
7032
  in: "In",
7040
7033
  out: "Out"
7041
- }, un = [
7034
+ }, ln = [
7042
7035
  "No door (click to set)",
7043
7036
  "Open door",
7044
7037
  "Closed door",
7045
7038
  "Locked door"
7046
- ], dn = [
7039
+ ], un = [
7047
7040
  "",
7048
7041
  "door-open",
7049
7042
  "door-closed",
7050
7043
  "door-locked"
7051
7044
  ];
7052
- function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = [] }) {
7053
- let l = n.ids[0], p = O((e) => e.pending), [m, h] = i(a.name ?? ""), [g, _] = i(String(a.weight ?? 1)), [v, y] = i(a.symbol ?? ""), [b, x] = i(a.userData?.["system.fallback_symbol_color"] ?? null), [S, C] = i(!1), [w, T] = i(""), [E, k] = i(""), [A, j] = i({}), [M, N] = i(null), [P, F] = i("#ffffff"), [I, L] = i(1), [R, z] = i(!1), [B, V] = i(!1), H = r(k);
7054
- H.current = k, t(() => (pt((e) => H.current(String(e))), () => pt(null)), []);
7055
- let ee = r(m);
7056
- ee.current = m;
7057
- let te = r(g);
7058
- te.current = g;
7059
- let ne = r(v);
7060
- ne.current = v, t(() => {
7045
+ function dn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = [] }) {
7046
+ let l = n.ids[0], p = O((e) => e.pending), [m, h] = i(a.name ?? ""), [g, _] = i(String(a.weight ?? 1)), [v, y] = i(a.symbol ?? ""), [b, x] = i(a.userData?.["system.fallback_symbol_color"] ?? null), [S, C] = i(!1), [w, T] = i(""), [E, k] = i(""), [A, j] = i({}), [M, N] = i(null), [P, F] = i("#ffffff"), [I, L] = i(1), [R, ee] = i(!1), [z, B] = i(!1), V = r(k);
7047
+ V.current = k, t(() => (ft((e) => V.current(String(e))), () => ft(null)), []);
7048
+ let te = r(m);
7049
+ te.current = m;
7050
+ let ne = r(g);
7051
+ ne.current = g;
7052
+ let re = r(v);
7053
+ re.current = v, t(() => {
7061
7054
  let e = a, t = l;
7062
7055
  return () => {
7063
- let n = !1, r = ne.current;
7056
+ let n = !1, r = re.current;
7064
7057
  r !== e.symbol && (Y({
7065
7058
  kind: "setRoomField",
7066
7059
  id: t,
@@ -7068,7 +7061,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7068
7061
  from: e.symbol,
7069
7062
  to: r
7070
7063
  }, s.current), n = !0);
7071
- let i = ee.current;
7064
+ let i = te.current;
7072
7065
  i !== e.name && (Y({
7073
7066
  kind: "setRoomField",
7074
7067
  id: t,
@@ -7076,7 +7069,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7076
7069
  from: e.name,
7077
7070
  to: i
7078
7071
  }, s.current), n = !0);
7079
- let a = Number(te.current);
7072
+ let a = Number(ne.current);
7080
7073
  !Number.isNaN(a) && a !== e.weight && (Y({
7081
7074
  kind: "setRoomField",
7082
7075
  id: t,
@@ -7086,11 +7079,11 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7086
7079
  }, s.current), n = !0), n && (s.current?.refresh(), D.bumpData());
7087
7080
  };
7088
7081
  }, [a]), t(() => {
7089
- h(a.name ?? ""), _(String(a.weight ?? 1)), y(a.symbol ?? ""), x(a.userData?.["system.fallback_symbol_color"] ?? null), C(!1), T(""), k(""), j({}), N(null), V(!1);
7082
+ h(a.name ?? ""), _(String(a.weight ?? 1)), y(a.symbol ?? ""), x(a.userData?.["system.fallback_symbol_color"] ?? null), C(!1), T(""), k(""), j({}), N(null), B(!1);
7090
7083
  let e = D.getState().pending;
7091
7084
  (e?.kind === "pickExit" || e?.kind === "pickSpecialExit") && D.setState({ pending: null });
7092
7085
  }, [a]);
7093
- let re = (e, t) => {
7086
+ let ie = (e, t) => {
7094
7087
  let n = a[e], r = t;
7095
7088
  if (e === "weight" || e === "environment") {
7096
7089
  let e = Number(t);
@@ -7104,7 +7097,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7104
7097
  from: n,
7105
7098
  to: r
7106
7099
  }, s.current), s.current?.refresh(), D.bumpData(), D.setState({ status: `Updated ${e} on room ${l}` }));
7107
- }, U = (e) => {
7100
+ }, H = (e) => {
7108
7101
  e !== a.environment && (Y({
7109
7102
  kind: "setRoomField",
7110
7103
  id: l,
@@ -7112,7 +7105,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7112
7105
  from: a.environment,
7113
7106
  to: e
7114
7107
  }, s.current), s.current?.refresh(), D.bumpData(), D.setState({ status: `Room ${l} environment → ${e}` }));
7115
- }, W = (e) => {
7108
+ }, U = (e) => {
7116
7109
  let t = "system.fallback_symbol_color", n = a.userData?.[t] ?? null, r = e;
7117
7110
  n !== r && (Y({
7118
7111
  kind: "setUserDataEntry",
@@ -7121,7 +7114,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7121
7114
  from: n,
7122
7115
  to: r
7123
7116
  }, s.current), s.current?.refresh(), D.bumpData());
7124
- }, G = (e, t) => {
7117
+ }, W = (e, t) => {
7125
7118
  if (!o.rooms[t]) return;
7126
7119
  let n = a[e];
7127
7120
  Y({
@@ -7132,7 +7125,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7132
7125
  previous: n,
7133
7126
  reverse: null
7134
7127
  }, s.current), s.current?.refresh(), D.bumpData(), D.setState({ status: `Exit ${e} → room ${t} added.` });
7135
- }, ie = (e, t, n) => {
7128
+ }, G = (e, t, n) => {
7136
7129
  Y({
7137
7130
  kind: "setDoor",
7138
7131
  roomId: l,
@@ -7179,7 +7172,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7179
7172
  roomId: l,
7180
7173
  dir: e,
7181
7174
  stub: !0
7182
- }, s.current) : De([{
7175
+ }, s.current) : X([{
7183
7176
  kind: "removeExit",
7184
7177
  fromId: l,
7185
7178
  dir: e,
@@ -7260,8 +7253,8 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7260
7253
  },
7261
7254
  style: a.customLinesStyle?.[i] ?? 1,
7262
7255
  arrow: a.customLinesArrow?.[i] ?? !1
7263
- } : null, u = Re(P), d = null, f = _e[i];
7264
- if (B && f) {
7256
+ } : null, u = Le(P), d = null, f = _e[i];
7257
+ if (z && f) {
7265
7258
  let e = a?.[f];
7266
7259
  if (e !== void 0 && e !== -1) {
7267
7260
  let t = o.rooms[e], r = me[f];
@@ -7318,7 +7311,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7318
7311
  } });
7319
7312
  return;
7320
7313
  }
7321
- F("#ffffff"), L(1), z(!1), V(!1), N(e);
7314
+ F("#ffffff"), L(1), ee(!1), B(!1), N(e);
7322
7315
  }, be = (e) => /* @__PURE__ */ f("div", {
7323
7316
  className: "cl-form cl-form-inline",
7324
7317
  children: [
@@ -7373,7 +7366,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7373
7366
  }), /* @__PURE__ */ d("input", {
7374
7367
  type: "checkbox",
7375
7368
  checked: R,
7376
- onChange: (e) => z(e.target.checked)
7369
+ onChange: (e) => ee(e.target.checked)
7377
7370
  })]
7378
7371
  }),
7379
7372
  /* @__PURE__ */ f("div", {
@@ -7384,8 +7377,8 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7384
7377
  children: "Both ways"
7385
7378
  }), /* @__PURE__ */ d("input", {
7386
7379
  type: "checkbox",
7387
- checked: B,
7388
- onChange: (e) => V(e.target.checked)
7380
+ checked: z,
7381
+ onChange: (e) => B(e.target.checked)
7389
7382
  })]
7390
7383
  }),
7391
7384
  /* @__PURE__ */ f("div", {
@@ -7415,7 +7408,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7415
7408
  className: "cc-header",
7416
7409
  children: [/* @__PURE__ */ d("span", {
7417
7410
  className: "cc-label",
7418
- children: ln[e]
7411
+ children: cn[e]
7419
7412
  }), /* @__PURE__ */ f("span", {
7420
7413
  className: "cc-header-btn-slot",
7421
7414
  children: [
@@ -7455,7 +7448,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7455
7448
  /* @__PURE__ */ f("div", {
7456
7449
  className: "cc-middle",
7457
7450
  children: [
7458
- r && /* @__PURE__ */ d(Ne, {
7451
+ r && /* @__PURE__ */ d(Me, {
7459
7452
  id: n,
7460
7453
  className: "cc-target"
7461
7454
  }),
@@ -7476,7 +7469,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7476
7469
  })),
7477
7470
  onBlur: (n) => {
7478
7471
  let r = parseInt(n.target.value, 10);
7479
- isNaN(r) || (G(t, r), j((t) => ({
7472
+ isNaN(r) || (W(t, r), j((t) => ({
7480
7473
  ...t,
7481
7474
  [e]: ""
7482
7475
  })));
@@ -7493,7 +7486,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7493
7486
  fromId: l,
7494
7487
  dir: t
7495
7488
  } }),
7496
- children: /* @__PURE__ */ d(an, {})
7489
+ children: /* @__PURE__ */ d(rn, {})
7497
7490
  })]
7498
7491
  })
7499
7492
  ]
@@ -7503,11 +7496,11 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7503
7496
  children: [
7504
7497
  /* @__PURE__ */ d("button", {
7505
7498
  type: "button",
7506
- className: `cc-door-btn ${dn[u]}${c ? "" : " cc-dim"}`,
7507
- title: c ? un[u] : void 0,
7499
+ className: `cc-door-btn ${un[u]}${c ? "" : " cc-dim"}`,
7500
+ title: c ? ln[u] : void 0,
7508
7501
  disabled: !c,
7509
- onClick: c ? () => ie(t, u, (u + 1) % 4) : void 0,
7510
- children: /* @__PURE__ */ d(en, {})
7502
+ onClick: c ? () => G(t, u, (u + 1) % 4) : void 0,
7503
+ children: /* @__PURE__ */ d($t, {})
7511
7504
  }),
7512
7505
  /* @__PURE__ */ d("button", {
7513
7506
  type: "button",
@@ -7515,11 +7508,11 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7515
7508
  title: c ? h ? "Locked — click to unlock" : "Unlocked — click to lock" : void 0,
7516
7509
  disabled: !c,
7517
7510
  onClick: c ? () => oe(t, h) : void 0,
7518
- children: /* @__PURE__ */ d(tn, { locked: h })
7511
+ children: /* @__PURE__ */ d(en, { locked: h })
7519
7512
  }),
7520
7513
  /* @__PURE__ */ f("span", {
7521
7514
  className: `cc-weight-wrap${c ? "" : " cc-dim"}`,
7522
- children: [/* @__PURE__ */ d(nn, {}), /* @__PURE__ */ d("input", {
7515
+ children: [/* @__PURE__ */ d(tn, {}), /* @__PURE__ */ d("input", {
7523
7516
  type: "number",
7524
7517
  className: "cc-weight",
7525
7518
  min: 1,
@@ -7561,16 +7554,16 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7561
7554
  let e = s.current;
7562
7555
  e && (e.renderer.backend.viewport.panToMapPoint(a.x, -a.y), e.refresh());
7563
7556
  },
7564
- children: /* @__PURE__ */ d(rn, {})
7557
+ children: /* @__PURE__ */ d(nn, {})
7565
7558
  })]
7566
7559
  })]
7567
7560
  }),
7568
- /* @__PURE__ */ d(X, {
7561
+ /* @__PURE__ */ d(Z, {
7569
7562
  label: "Name",
7570
7563
  children: /* @__PURE__ */ d("input", {
7571
7564
  value: m,
7572
7565
  onChange: (e) => h(e.target.value),
7573
- onBlur: () => re("name", m),
7566
+ onBlur: () => ie("name", m),
7574
7567
  onKeyDown: (e) => {
7575
7568
  e.key === "Enter" && e.target.blur();
7576
7569
  }
@@ -7597,16 +7590,16 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7597
7590
  className: "env-id-label",
7598
7591
  children: ["#", a.environment]
7599
7592
  }),
7600
- S && /* @__PURE__ */ d($t, {
7593
+ S && /* @__PURE__ */ d(Qt, {
7601
7594
  map: o,
7602
7595
  sceneRef: s,
7603
7596
  currentEnvId: a.environment,
7604
- onSelect: U,
7597
+ onSelect: H,
7605
7598
  onClose: () => C(!1)
7606
7599
  })
7607
7600
  ]
7608
7601
  })]
7609
- }), /* @__PURE__ */ d(X, {
7602
+ }), /* @__PURE__ */ d(Z, {
7610
7603
  label: "Symbol",
7611
7604
  children: /* @__PURE__ */ f("div", {
7612
7605
  className: "symbol-row",
@@ -7615,7 +7608,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7615
7608
  value: v,
7616
7609
  maxLength: 4,
7617
7610
  onChange: (e) => y(e.target.value),
7618
- onBlur: () => re("symbol", v)
7611
+ onBlur: () => ie("symbol", v)
7619
7612
  }),
7620
7613
  /* @__PURE__ */ d("input", {
7621
7614
  type: "color",
@@ -7624,7 +7617,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7624
7617
  title: "Symbol color (stored in userData as system.fallback_symbol_color)",
7625
7618
  onChange: (e) => x(e.target.value),
7626
7619
  onBlur: () => {
7627
- b !== null && W(b);
7620
+ b !== null && U(b);
7628
7621
  }
7629
7622
  }),
7630
7623
  /* @__PURE__ */ d("button", {
@@ -7633,7 +7626,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7633
7626
  style: { visibility: b === null ? "hidden" : "visible" },
7634
7627
  title: "Clear symbol color",
7635
7628
  onClick: () => {
7636
- x(null), W(null);
7629
+ x(null), U(null);
7637
7630
  },
7638
7631
  children: "×"
7639
7632
  })
@@ -7644,7 +7637,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7644
7637
  /* @__PURE__ */ d("h4", { children: "Exits" }),
7645
7638
  /* @__PURE__ */ d("div", {
7646
7639
  className: "compass-rose",
7647
- children: sn.flat().map((e, t) => e === null ? /* @__PURE__ */ f("div", {
7640
+ children: on.flat().map((e, t) => e === null ? /* @__PURE__ */ f("div", {
7648
7641
  className: "compass-cell compass-center",
7649
7642
  children: [/* @__PURE__ */ d("button", {
7650
7643
  type: "button",
@@ -7657,7 +7650,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7657
7650
  lock: !a.isLocked
7658
7651
  }, s.current), s.current?.refresh(), D.bumpData();
7659
7652
  },
7660
- children: /* @__PURE__ */ d(tn, { locked: a.isLocked })
7653
+ children: /* @__PURE__ */ d(en, { locked: a.isLocked })
7661
7654
  }), /* @__PURE__ */ d("input", {
7662
7655
  type: "number",
7663
7656
  className: "cc-room-weight",
@@ -7665,16 +7658,16 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7665
7658
  value: g,
7666
7659
  title: "Room weight",
7667
7660
  onChange: (e) => _(e.target.value),
7668
- onBlur: () => re("weight", g),
7661
+ onBlur: () => ie("weight", g),
7669
7662
  onKeyDown: (e) => e.key === "Enter" && e.target.blur()
7670
7663
  }, `${l}-w`)]
7671
7664
  }, t) : xe(e))
7672
7665
  }),
7673
7666
  /* @__PURE__ */ d("div", {
7674
7667
  className: "compass-extra",
7675
- children: cn.flat().map((e, t) => e === null ? /* @__PURE__ */ d("div", { className: "compass-vert-spacer" }, t) : xe(e))
7668
+ children: sn.flat().map((e, t) => e === null ? /* @__PURE__ */ d("div", { className: "compass-vert-spacer" }, t) : xe(e))
7676
7669
  }),
7677
- M !== null && on.includes(M) && be(M),
7670
+ M !== null && an.includes(M) && be(M),
7678
7671
  /* @__PURE__ */ d("h4", { children: "Special Exits" }),
7679
7672
  /* @__PURE__ */ f("div", {
7680
7673
  className: "special-exits-list",
@@ -7711,7 +7704,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7711
7704
  }),
7712
7705
  /* @__PURE__ */ d("div", {
7713
7706
  className: "cc-middle",
7714
- children: /* @__PURE__ */ d(Ne, {
7707
+ children: /* @__PURE__ */ d(Me, {
7715
7708
  id: n,
7716
7709
  className: "cc-target"
7717
7710
  })
@@ -7721,14 +7714,14 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7721
7714
  children: [
7722
7715
  /* @__PURE__ */ d("button", {
7723
7716
  type: "button",
7724
- className: `cc-door-btn ${dn[r]}`,
7725
- title: un[r],
7717
+ className: `cc-door-btn ${un[r]}`,
7718
+ title: ln[r],
7726
7719
  onClick: () => de(t, r, (r + 1) % 4),
7727
- children: /* @__PURE__ */ d(en, {})
7720
+ children: /* @__PURE__ */ d($t, {})
7728
7721
  }),
7729
7722
  /* @__PURE__ */ f("span", {
7730
7723
  className: "cc-weight-wrap",
7731
- children: [/* @__PURE__ */ d(nn, {}), /* @__PURE__ */ d("input", {
7724
+ children: [/* @__PURE__ */ d(tn, {}), /* @__PURE__ */ d("input", {
7732
7725
  type: "number",
7733
7726
  className: "cc-weight",
7734
7727
  min: 1,
@@ -7778,7 +7771,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7778
7771
  fromId: l
7779
7772
  } });
7780
7773
  },
7781
- children: /* @__PURE__ */ d(an, {})
7774
+ children: /* @__PURE__ */ d(rn, {})
7782
7775
  })]
7783
7776
  }),
7784
7777
  /* @__PURE__ */ d("button", {
@@ -7835,7 +7828,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7835
7828
  sceneRef: s
7836
7829
  }) }, t.id)),
7837
7830
  /* @__PURE__ */ d("h4", { children: "User Data" }),
7838
- /* @__PURE__ */ d(Ie, {
7831
+ /* @__PURE__ */ d(Fe, {
7839
7832
  data: a.userData,
7840
7833
  onCommit: (e, t, n) => {
7841
7834
  Y({
@@ -7852,7 +7845,7 @@ function fn({ selection: n, room: a, map: o, sceneRef: s, pluginSections: c = []
7852
7845
  }
7853
7846
  //#endregion
7854
7847
  //#region src/components/SidePanel.tsx
7855
- var pn = [
7848
+ var fn = [
7856
7849
  {
7857
7850
  id: "selection",
7858
7851
  label: "Sel"
@@ -7874,11 +7867,11 @@ var pn = [
7874
7867
  label: "Map"
7875
7868
  }
7876
7869
  ];
7877
- function mn({ sceneRef: e, extraTabs: t = [], pluginRoomSections: n = [] }) {
7870
+ function pn({ sceneRef: e, extraTabs: t = [], pluginRoomSections: n = [] }) {
7878
7871
  let r = O((e) => e.selection), i = O((e) => e.map), a = O((e) => e.activeTool), o = O((e) => e.pending), s = O((e) => e.sidebarTab), c = O((e) => e.panelCollapsed), l = O((e) => e.undo.length);
7879
7872
  O((e) => e.dataVersion);
7880
7873
  let u = i ? Object.keys(i.mCustomEnvColors).length : 0, p = i ? Object.keys(i.areaNames).length : 0;
7881
- if (a === "customLine" && o?.kind === "customLine") return /* @__PURE__ */ d(Vt, {
7874
+ if (a === "customLine" && o?.kind === "customLine") return /* @__PURE__ */ d(Bt, {
7882
7875
  pending: o,
7883
7876
  sceneRef: e
7884
7877
  });
@@ -7892,7 +7885,7 @@ function mn({ sceneRef: e, extraTabs: t = [], pluginRoomSections: n = [] }) {
7892
7885
  children: "◀"
7893
7886
  }), /* @__PURE__ */ d("div", {
7894
7887
  className: "side-panel-tabs side-panel-tabs--vert",
7895
- children: [...pn, ...t].map((e) => /* @__PURE__ */ d("button", {
7888
+ children: [...fn, ...t].map((e) => /* @__PURE__ */ d("button", {
7896
7889
  type: "button",
7897
7890
  className: `side-panel-tab${s === e.id ? " active" : ""}`,
7898
7891
  onClick: () => D.setState({
@@ -7962,19 +7955,19 @@ function mn({ sceneRef: e, extraTabs: t = [], pluginRoomSections: n = [] }) {
7962
7955
  });
7963
7956
  if (s === "areas") return /* @__PURE__ */ f("div", {
7964
7957
  className: "side-panel",
7965
- children: [m, /* @__PURE__ */ d(ze, { sceneRef: e })]
7958
+ children: [m, /* @__PURE__ */ d(Re, { sceneRef: e })]
7966
7959
  });
7967
7960
  if (s === "envs") return /* @__PURE__ */ f("div", {
7968
7961
  className: "side-panel",
7969
- children: [m, /* @__PURE__ */ d(He, { sceneRef: e })]
7962
+ children: [m, /* @__PURE__ */ d(Ve, { sceneRef: e })]
7970
7963
  });
7971
7964
  if (s === "history") return /* @__PURE__ */ f("div", {
7972
7965
  className: "side-panel",
7973
- children: [m, /* @__PURE__ */ d(Ge, { sceneRef: e })]
7966
+ children: [m, /* @__PURE__ */ d(We, { sceneRef: e })]
7974
7967
  });
7975
7968
  if (s === "map") return /* @__PURE__ */ f("div", {
7976
7969
  className: "side-panel",
7977
- children: [m, /* @__PURE__ */ d(Ye, { sceneRef: e })]
7970
+ children: [m, /* @__PURE__ */ d(Je, { sceneRef: e })]
7978
7971
  });
7979
7972
  let h = t.find((e) => e.id === s);
7980
7973
  if (h) return /* @__PURE__ */ f("div", {
@@ -7986,7 +7979,7 @@ function mn({ sceneRef: e, extraTabs: t = [], pluginRoomSections: n = [] }) {
7986
7979
  });
7987
7980
  if (r?.kind === "label") return /* @__PURE__ */ f("div", {
7988
7981
  className: "side-panel",
7989
- children: [m, /* @__PURE__ */ d(Qt, {
7982
+ children: [m, /* @__PURE__ */ d(Zt, {
7990
7983
  selection: r,
7991
7984
  sceneRef: e
7992
7985
  })]
@@ -7995,7 +7988,7 @@ function mn({ sceneRef: e, extraTabs: t = [], pluginRoomSections: n = [] }) {
7995
7988
  className: "side-panel",
7996
7989
  children: [m, /* @__PURE__ */ d("div", {
7997
7990
  className: "panel-content",
7998
- children: /* @__PURE__ */ d(Xe, {
7991
+ children: /* @__PURE__ */ d(Ye, {
7999
7992
  selection: r,
8000
7993
  map: i,
8001
7994
  sceneRef: e
@@ -8006,7 +7999,7 @@ function mn({ sceneRef: e, extraTabs: t = [], pluginRoomSections: n = [] }) {
8006
7999
  className: "side-panel",
8007
8000
  children: [m, /* @__PURE__ */ d("div", {
8008
8001
  className: "panel-content",
8009
- children: /* @__PURE__ */ d(Ht, {
8002
+ children: /* @__PURE__ */ d(Vt, {
8010
8003
  selection: r,
8011
8004
  map: i,
8012
8005
  sceneRef: e
@@ -8034,12 +8027,12 @@ function mn({ sceneRef: e, extraTabs: t = [], pluginRoomSections: n = [] }) {
8034
8027
  className: "hint",
8035
8028
  children: "Select a room with the Select tool to edit its properties."
8036
8029
  }),
8037
- /* @__PURE__ */ d(Fe, { activeTool: a })
8030
+ /* @__PURE__ */ d(Pe, { activeTool: a })
8038
8031
  ]
8039
8032
  })]
8040
8033
  }) : /* @__PURE__ */ f("div", {
8041
8034
  className: "side-panel",
8042
- children: [m, /* @__PURE__ */ d(fn, {
8035
+ children: [m, /* @__PURE__ */ d(dn, {
8043
8036
  selection: r,
8044
8037
  room: g,
8045
8038
  map: i,
@@ -8050,7 +8043,7 @@ function mn({ sceneRef: e, extraTabs: t = [], pluginRoomSections: n = [] }) {
8050
8043
  }
8051
8044
  //#endregion
8052
8045
  //#region src/components/ContextMenu.tsx
8053
- function hn({ sceneRef: e }) {
8046
+ function mn({ sceneRef: e }) {
8054
8047
  let n = O((e) => e.contextMenu), a = r(null), [o, s] = i(null), [c, l] = i(null);
8055
8048
  if (t(() => {
8056
8049
  if (!n) {
@@ -8066,12 +8059,12 @@ function hn({ sceneRef: e }) {
8066
8059
  window.removeEventListener("keydown", t), window.removeEventListener("mousedown", r, !0);
8067
8060
  };
8068
8061
  }, [n]), !n) return null;
8069
- let u = () => D.setState({ contextMenu: null }), p = () => {
8062
+ let p = () => D.setState({ contextMenu: null }), m = () => {
8070
8063
  if (n.kind !== "customLinePoint") return;
8071
8064
  let t = D.getState();
8072
- if (!t.map) return u();
8065
+ if (!t.map) return p();
8073
8066
  let r = t.map.rooms[n.roomId], i = r?.customLines?.[n.exitName];
8074
- if (!r || !i || n.pointIndex < 0 || n.pointIndex >= i.length) return u();
8067
+ if (!r || !i || n.pointIndex < 0 || n.pointIndex >= i.length) return p();
8075
8068
  let a = r.customLinesColor?.[n.exitName] ?? {
8076
8069
  spec: 1,
8077
8070
  alpha: 255,
@@ -8108,7 +8101,7 @@ function hn({ sceneRef: e }) {
8108
8101
  if (n.kind === "disambiguate") {
8109
8102
  let t = D.getState(), r = (e) => {
8110
8103
  e.kind === "room" ? D.setState({
8111
- selection: Lt(e),
8104
+ selection: It(e),
8112
8105
  contextMenu: {
8113
8106
  kind: "room",
8114
8107
  roomId: e.id,
@@ -8117,7 +8110,7 @@ function hn({ sceneRef: e }) {
8117
8110
  },
8118
8111
  sidebarTab: "selection"
8119
8112
  }) : e.kind === "label" ? D.setState({
8120
- selection: Lt(e),
8113
+ selection: It(e),
8121
8114
  contextMenu: {
8122
8115
  kind: "label",
8123
8116
  areaId: e.areaId,
@@ -8127,10 +8120,10 @@ function hn({ sceneRef: e }) {
8127
8120
  },
8128
8121
  sidebarTab: "selection"
8129
8122
  }) : D.setState({
8130
- selection: Lt(e),
8123
+ selection: It(e),
8131
8124
  contextMenu: null,
8132
8125
  sidebarTab: "selection",
8133
- status: `Selected ${Rt(e)}`
8126
+ status: `Selected ${Lt(e)}`
8134
8127
  });
8135
8128
  }, i = (n) => {
8136
8129
  if (n.kind === "room") {
@@ -8141,7 +8134,7 @@ function hn({ sceneRef: e }) {
8141
8134
  let t = (e.current?.reader.getLabelSnapshot(n.areaId, n.id))?.text?.trim();
8142
8135
  return t ? `Label: "${t.length > 24 ? t.slice(0, 24) + "…" : t}"` : `Label ${n.id}`;
8143
8136
  }
8144
- return Rt(n);
8137
+ return Lt(n);
8145
8138
  };
8146
8139
  return /* @__PURE__ */ f("div", {
8147
8140
  ref: a,
@@ -8173,7 +8166,7 @@ function hn({ sceneRef: e }) {
8173
8166
  children: /* @__PURE__ */ d("button", {
8174
8167
  type: "button",
8175
8168
  className: "context-menu-item danger",
8176
- onClick: p,
8169
+ onClick: m,
8177
8170
  children: "Delete waypoint"
8178
8171
  })
8179
8172
  });
@@ -8296,7 +8289,7 @@ function hn({ sceneRef: e }) {
8296
8289
  type: "button",
8297
8290
  className: "context-menu-item danger",
8298
8291
  onClick: () => {
8299
- if (!t) return u();
8292
+ if (!t) return p();
8300
8293
  Y({
8301
8294
  kind: "deleteLabel",
8302
8295
  areaId: n.areaId,
@@ -8314,19 +8307,40 @@ function hn({ sceneRef: e }) {
8314
8307
  });
8315
8308
  }
8316
8309
  if (n.kind !== "room") return null;
8317
- let m = D.getState(), h = m.map?.rooms[n.roomId], g = m.map?.areaNames ?? {}, _ = m.selection, v = _?.kind === "room" && _.ids.length > 1 && _.ids.includes(n.roomId) ? _.ids : null, y = () => {
8318
- h && s({
8319
- areaId: h.area,
8320
- x: String(h.x),
8321
- y: String(h.y),
8322
- z: String(h.z)
8310
+ let h = D.getState(), g = h.map?.rooms[n.roomId], _ = h.map?.areaNames ?? {}, v = h.selection, y = v?.kind === "room" && v.ids.length > 1 && v.ids.includes(n.roomId) ? v.ids : null, b = () => {
8311
+ g && s({
8312
+ areaId: g.area,
8313
+ x: String(g.x),
8314
+ y: String(g.y),
8315
+ z: String(g.z)
8323
8316
  });
8324
- }, b = () => {
8317
+ }, x = () => {
8325
8318
  let t = D.getState();
8326
- if (!t.map) return u();
8319
+ if (!t.map) return p();
8320
+ if (y) {
8321
+ let n = je(t.map, y);
8322
+ Y({
8323
+ kind: "batch",
8324
+ cmds: y.map((e) => {
8325
+ let r = t.map.rooms[e];
8326
+ return {
8327
+ kind: "deleteRoom",
8328
+ id: e,
8329
+ room: { ...r },
8330
+ areaId: r.area,
8331
+ neighborEdits: n.get(e) ?? []
8332
+ };
8333
+ })
8334
+ }, e.current), e.current?.refresh(), D.bumpStructure(), D.setState({
8335
+ selection: null,
8336
+ status: `Deleted ${y.length} rooms`,
8337
+ contextMenu: null
8338
+ });
8339
+ return;
8340
+ }
8327
8341
  let r = t.map.rooms[n.roomId];
8328
- if (!r) return u();
8329
- let i = { ...r }, a = je(t.map, n.roomId);
8342
+ if (!r) return p();
8343
+ let i = { ...r }, a = Ae(t.map, n.roomId);
8330
8344
  Y({
8331
8345
  kind: "deleteRoom",
8332
8346
  id: n.roomId,
@@ -8339,21 +8353,21 @@ function hn({ sceneRef: e }) {
8339
8353
  status: `Deleted room ${n.roomId}`,
8340
8354
  contextMenu: null
8341
8355
  });
8342
- }, x = () => {
8343
- if (!o || !h || !m.map) return;
8356
+ }, S = () => {
8357
+ if (!o || !g || !h.map) return;
8344
8358
  let t = parseInt(o.x, 10), r = parseInt(o.y, 10), i = parseInt(o.z, 10);
8345
8359
  if (isNaN(t) || isNaN(r) || isNaN(i)) return;
8346
8360
  let a = [];
8347
- if (v) {
8348
- let e = t - h.x, n = r - h.y, s = i - h.z;
8349
- o.areaId !== h.area && a.push({
8361
+ if (y) {
8362
+ let e = t - g.x, n = r - g.y, s = i - g.z;
8363
+ o.areaId !== g.area && a.push({
8350
8364
  kind: "moveRoomsToArea",
8351
- roomIds: v,
8352
- fromAreaId: h.area,
8365
+ roomIds: y,
8366
+ fromAreaId: g.area,
8353
8367
  toAreaId: o.areaId
8354
8368
  });
8355
- for (let t of v) {
8356
- let r = m.map.rooms[t];
8369
+ for (let t of y) {
8370
+ let r = h.map.rooms[t];
8357
8371
  if (!r) continue;
8358
8372
  let i = r.x + e, o = r.y + n, c = r.z + s;
8359
8373
  (i !== r.x || o !== r.y || c !== r.z) && a.push({
@@ -8369,33 +8383,33 @@ function hn({ sceneRef: e }) {
8369
8383
  y: o,
8370
8384
  z: c
8371
8385
  }
8372
- }), a.push(...Ae(m.map, t, e, n));
8386
+ }), a.push(...ke(h.map, t, e, n));
8373
8387
  }
8374
8388
  } else {
8375
- o.areaId !== h.area && a.push({
8389
+ o.areaId !== g.area && a.push({
8376
8390
  kind: "moveRoomsToArea",
8377
8391
  roomIds: [n.roomId],
8378
- fromAreaId: h.area,
8392
+ fromAreaId: g.area,
8379
8393
  toAreaId: o.areaId
8380
8394
  });
8381
- let e = t - h.x, s = r - h.y;
8382
- (t !== h.x || r !== h.y || i !== h.z) && a.push({
8395
+ let e = t - g.x, s = r - g.y;
8396
+ (t !== g.x || r !== g.y || i !== g.z) && a.push({
8383
8397
  kind: "moveRoom",
8384
8398
  id: n.roomId,
8385
8399
  from: {
8386
- x: h.x,
8387
- y: h.y,
8388
- z: h.z
8400
+ x: g.x,
8401
+ y: g.y,
8402
+ z: g.z
8389
8403
  },
8390
8404
  to: {
8391
8405
  x: t,
8392
8406
  y: r,
8393
8407
  z: i
8394
8408
  }
8395
- }), a.push(...Ae(m.map, n.roomId, e, s));
8409
+ }), a.push(...ke(h.map, n.roomId, e, s));
8396
8410
  }
8397
- a.length > 0 && (De(a, e.current), e.current?.refresh(), D.bumpStructure(), D.setState({ status: v ? `Moved ${v.length} rooms to area ${o.areaId} (${t}, ${r}, ${i})` : `Moved room ${n.roomId} to area ${o.areaId} (${t}, ${r}, ${i})` }));
8398
- let s = o.areaId !== (m.currentAreaId ?? h.area), c = i !== m.currentZ;
8411
+ a.length > 0 && (X(a, e.current), e.current?.refresh(), D.bumpStructure(), D.setState({ status: y ? `Moved ${y.length} rooms to area ${o.areaId} (${t}, ${r}, ${i})` : `Moved room ${n.roomId} to area ${o.areaId} (${t}, ${r}, ${i})` }));
8412
+ let s = o.areaId !== (h.currentAreaId ?? g.area), c = i !== h.currentZ;
8399
8413
  D.setState({
8400
8414
  contextMenu: null,
8401
8415
  currentAreaId: o.areaId,
@@ -8405,7 +8419,7 @@ function hn({ sceneRef: e }) {
8405
8419
  mapY: -r
8406
8420
  } : null
8407
8421
  });
8408
- }, S = Object.entries(g).map(([e, t]) => ({
8422
+ }, C = Object.entries(_).map(([e, t]) => ({
8409
8423
  id: Number(e),
8410
8424
  name: t
8411
8425
  })).sort((e, t) => e.name.localeCompare(t.name));
@@ -8420,7 +8434,7 @@ function hn({ sceneRef: e }) {
8420
8434
  children: [
8421
8435
  /* @__PURE__ */ d("div", {
8422
8436
  className: "context-menu-title",
8423
- children: v ? `Move ${v.length} rooms to` : `Move room ${n.roomId} to`
8437
+ children: y ? `Move ${y.length} rooms to` : `Move room ${n.roomId} to`
8424
8438
  }),
8425
8439
  /* @__PURE__ */ f("div", {
8426
8440
  className: "context-menu-field",
@@ -8430,7 +8444,7 @@ function hn({ sceneRef: e }) {
8430
8444
  ...t,
8431
8445
  areaId: Number(e.target.value)
8432
8446
  }),
8433
- children: S.map(({ id: e, name: t }) => /* @__PURE__ */ d("option", {
8447
+ children: C.map(({ id: e, name: t }) => /* @__PURE__ */ d("option", {
8434
8448
  value: e,
8435
8449
  children: t
8436
8450
  }, e))
@@ -8484,7 +8498,7 @@ function hn({ sceneRef: e }) {
8484
8498
  }), /* @__PURE__ */ d("button", {
8485
8499
  type: "button",
8486
8500
  className: "context-menu-btn primary",
8487
- onClick: x,
8501
+ onClick: S,
8488
8502
  children: "Move"
8489
8503
  })]
8490
8504
  })
@@ -8498,34 +8512,61 @@ function hn({ sceneRef: e }) {
8498
8512
  },
8499
8513
  onContextMenu: (e) => e.preventDefault(),
8500
8514
  children: [
8501
- /* @__PURE__ */ f("div", {
8515
+ /* @__PURE__ */ d("div", {
8502
8516
  className: "context-menu-title",
8503
- children: ["Room ", n.roomId]
8517
+ children: y ? `${y.length} rooms` : `Room ${n.roomId}`
8504
8518
  }),
8505
8519
  /* @__PURE__ */ d("button", {
8506
8520
  type: "button",
8507
8521
  className: "context-menu-item",
8508
- onClick: y,
8522
+ onClick: b,
8509
8523
  children: "Move to…"
8510
8524
  }),
8525
+ y && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("button", {
8526
+ type: "button",
8527
+ className: "context-menu-item",
8528
+ onClick: () => D.setState({
8529
+ spreadShrink: {
8530
+ mode: "spread",
8531
+ factor: 2,
8532
+ centerMode: "centroid",
8533
+ anchorRoomId: null
8534
+ },
8535
+ contextMenu: null
8536
+ }),
8537
+ children: "Spread…"
8538
+ }), /* @__PURE__ */ d("button", {
8539
+ type: "button",
8540
+ className: "context-menu-item",
8541
+ onClick: () => D.setState({
8542
+ spreadShrink: {
8543
+ mode: "shrink",
8544
+ factor: .5,
8545
+ centerMode: "centroid",
8546
+ anchorRoomId: null
8547
+ },
8548
+ contextMenu: null
8549
+ }),
8550
+ children: "Shrink…"
8551
+ })] }),
8511
8552
  /* @__PURE__ */ d("button", {
8512
8553
  type: "button",
8513
8554
  className: "context-menu-item danger",
8514
- onClick: b,
8515
- children: "Delete room"
8555
+ onClick: x,
8556
+ children: y ? `Delete ${y.length} rooms` : "Delete room"
8516
8557
  })
8517
8558
  ]
8518
8559
  });
8519
8560
  }
8520
8561
  //#endregion
8521
8562
  //#region src/editor/session.ts
8522
- var gn = "mudlet-map-editor", $ = "sessions", _n = 2;
8563
+ var hn = "mudlet-map-editor", gn = "sessions", _n = 2;
8523
8564
  function vn() {
8524
8565
  return new Promise((e, t) => {
8525
- let n = indexedDB.open(gn, _n);
8566
+ let n = indexedDB.open(hn, _n);
8526
8567
  n.onupgradeneeded = (e) => {
8527
8568
  let t = n.result;
8528
- e.oldVersion < 2 && t.objectStoreNames.contains($) && t.deleteObjectStore($), t.createObjectStore($, { keyPath: "id" });
8569
+ e.oldVersion < 2 && t.objectStoreNames.contains(gn) && t.deleteObjectStore(gn), t.createObjectStore(gn, { keyPath: "id" });
8529
8570
  }, n.onsuccess = () => e(n.result), n.onerror = () => t(n.error);
8530
8571
  });
8531
8572
  }
@@ -8535,7 +8576,7 @@ function yn(e) {
8535
8576
  return t;
8536
8577
  }
8537
8578
  async function bn(e, t, n, r, i, a) {
8538
- let o = U(t), s = o.buffer.slice(o.byteOffset, o.byteOffset + o.byteLength), c = a ?? crypto.randomUUID(), l = {
8579
+ let o = H(t), s = o.buffer.slice(o.byteOffset, o.byteOffset + o.byteLength), c = a ?? crypto.randomUUID(), l = {
8539
8580
  id: c,
8540
8581
  fileName: e,
8541
8582
  mapBytes: s,
@@ -8547,8 +8588,8 @@ async function bn(e, t, n, r, i, a) {
8547
8588
  roomCount: Object.keys(t.rooms).length
8548
8589
  }, u = await vn();
8549
8590
  return new Promise((e, t) => {
8550
- let n = u.transaction($, "readwrite");
8551
- n.objectStore($).put(l), n.oncomplete = () => {
8591
+ let n = u.transaction(gn, "readwrite");
8592
+ n.objectStore(gn).put(l), n.oncomplete = () => {
8552
8593
  u.close(), e(c);
8553
8594
  }, n.onerror = () => {
8554
8595
  u.close(), t(n.error);
@@ -8558,7 +8599,7 @@ async function bn(e, t, n, r, i, a) {
8558
8599
  async function xn() {
8559
8600
  let e = await vn();
8560
8601
  return new Promise((t, n) => {
8561
- let r = e.transaction($, "readonly").objectStore($).getAll();
8602
+ let r = e.transaction(gn, "readonly").objectStore(gn).getAll();
8562
8603
  r.onsuccess = () => {
8563
8604
  e.close(), t(r.result.sort((e, t) => t.savedAt - e.savedAt));
8564
8605
  }, r.onerror = () => {
@@ -8569,8 +8610,8 @@ async function xn() {
8569
8610
  async function Sn() {
8570
8611
  let e = await vn();
8571
8612
  return new Promise((t, n) => {
8572
- let r = e.transaction($, "readwrite");
8573
- r.objectStore($).clear(), r.oncomplete = () => {
8613
+ let r = e.transaction(gn, "readwrite");
8614
+ r.objectStore(gn).clear(), r.oncomplete = () => {
8574
8615
  e.close(), t();
8575
8616
  }, r.onerror = () => {
8576
8617
  e.close(), n(r.error);
@@ -8580,8 +8621,8 @@ async function Sn() {
8580
8621
  async function Cn(e) {
8581
8622
  let t = await vn();
8582
8623
  return new Promise((n, r) => {
8583
- let i = t.transaction($, "readwrite");
8584
- i.objectStore($).delete(e), i.oncomplete = () => {
8624
+ let i = t.transaction(gn, "readwrite");
8625
+ i.objectStore(gn).delete(e), i.oncomplete = () => {
8585
8626
  t.close(), n();
8586
8627
  }, i.onerror = () => {
8587
8628
  t.close(), r(i.error);
@@ -8589,7 +8630,7 @@ async function Cn(e) {
8589
8630
  });
8590
8631
  }
8591
8632
  function wn(e) {
8592
- let t = re(e.mapBytes);
8633
+ let t = ie(e.mapBytes);
8593
8634
  if (Object.keys(e.imageSrcs).length > 0) for (let n of Object.values(t.labels)) for (let t of n) {
8594
8635
  let n = e.imageSrcs[String(t.id)];
8595
8636
  n && (t.imageSrc = n);
@@ -8782,46 +8823,46 @@ function An({ sceneRef: e }) {
8782
8823
  };
8783
8824
  return window.addEventListener("editor:swatchRoomPicked", e), () => window.removeEventListener("editor:swatchRoomPicked", e);
8784
8825
  }, []);
8785
- let z = (t) => {
8826
+ let ee = (t) => {
8786
8827
  let n = e.current?.reader;
8787
8828
  return n ? n.getColorValue(t) : "rgb(114,1,0)";
8788
- }, B = (e, t, n) => {
8829
+ }, z = (e, t, n) => {
8789
8830
  let r = t === void 0 ? o : t, i = n === void 0 ? s : n;
8790
8831
  D.setState({
8791
8832
  swatchSets: e,
8792
8833
  activeSwatchSetId: r,
8793
8834
  activeSwatchId: i
8794
8835
  }), w(e, r, i);
8795
- }, V = () => {
8836
+ }, B = () => {
8796
8837
  let e = v.trim() || "New Set", t = crypto.randomUUID();
8797
- B([...n, {
8838
+ z([...n, {
8798
8839
  id: t,
8799
8840
  name: e,
8800
8841
  swatches: []
8801
8842
  }], t, null), y(""), _(!1);
8802
- }, H = (e) => {
8803
- R && B(n.map((t) => t.id === R.id ? {
8843
+ }, V = (e) => {
8844
+ R && z(n.map((t) => t.id === R.id ? {
8804
8845
  ...t,
8805
8846
  name: e
8806
8847
  } : t));
8807
- }, ee = () => {
8848
+ }, te = () => {
8808
8849
  if (!R || n.length <= 1 || !window.confirm(`Delete set "${R.name}"?`)) return;
8809
8850
  let e = n.filter((e) => e.id !== R.id);
8810
- B(e, e[0]?.id ?? null, null);
8811
- }, te = (e) => {
8851
+ z(e, e[0]?.id ?? null, null);
8852
+ }, ne = (e) => {
8812
8853
  D.setState({
8813
8854
  activeSwatchSetId: e,
8814
8855
  activeSwatchId: null
8815
8856
  }), w(n, e, null);
8816
- }, ne = (e) => {
8817
- D.setState({ activeSwatchId: e }), w(n, o, e);
8818
8857
  }, re = (e) => {
8858
+ D.setState({ activeSwatchId: e }), w(n, o, e);
8859
+ }, ie = (e) => {
8819
8860
  E(e.id), A(e.name), M(e.symbol), P(e.environment), I(!1);
8820
- }, U = () => {
8861
+ }, H = () => {
8821
8862
  E("new"), A(""), M(""), P(-1), I(!1);
8822
- }, W = () => {
8863
+ }, U = () => {
8823
8864
  E(null), I(!1);
8824
- }, G = () => {
8865
+ }, W = () => {
8825
8866
  if (!R || !T) return;
8826
8867
  let e = k.trim() || "Swatch", t = j.slice(0, 4);
8827
8868
  if (T === "new") {
@@ -8831,11 +8872,11 @@ function An({ sceneRef: e }) {
8831
8872
  symbol: t,
8832
8873
  environment: N
8833
8874
  };
8834
- B(n.map((e) => e.id === R.id ? {
8875
+ z(n.map((e) => e.id === R.id ? {
8835
8876
  ...e,
8836
8877
  swatches: [...e.swatches, i]
8837
8878
  } : e), o, r);
8838
- } else B(n.map((n) => n.id === R.id ? {
8879
+ } else z(n.map((n) => n.id === R.id ? {
8839
8880
  ...n,
8840
8881
  swatches: n.swatches.map((n) => n.id === T ? {
8841
8882
  ...n,
@@ -8845,8 +8886,8 @@ function An({ sceneRef: e }) {
8845
8886
  } : n)
8846
8887
  } : n));
8847
8888
  E(null), I(!1);
8848
- }, ie = (e) => {
8849
- R && B(n.map((t) => t.id === R.id ? {
8889
+ }, G = (e) => {
8890
+ R && z(n.map((t) => t.id === R.id ? {
8850
8891
  ...t,
8851
8892
  swatches: t.swatches.filter((t) => t.id !== e)
8852
8893
  } : t), void 0, s === e ? null : void 0);
@@ -8889,7 +8930,7 @@ function An({ sceneRef: e }) {
8889
8930
  value: S,
8890
8931
  onChange: (e) => C(e.target.value),
8891
8932
  onKeyDown: (e) => {
8892
- e.key === "Enter" && (H(S), x(!1)), e.key === "Escape" && x(!1);
8933
+ e.key === "Enter" && (V(S), x(!1)), e.key === "Escape" && x(!1);
8893
8934
  },
8894
8935
  autoFocus: !0
8895
8936
  }),
@@ -8897,7 +8938,7 @@ function An({ sceneRef: e }) {
8897
8938
  type: "button",
8898
8939
  className: "swatch-icon-btn",
8899
8940
  onClick: () => {
8900
- H(S), x(!1);
8941
+ V(S), x(!1);
8901
8942
  },
8902
8943
  children: "✓"
8903
8944
  }),
@@ -8910,7 +8951,7 @@ function An({ sceneRef: e }) {
8910
8951
  ] }) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("select", {
8911
8952
  className: "swatch-set-select",
8912
8953
  value: R?.id ?? "",
8913
- onChange: (e) => te(e.target.value),
8954
+ onChange: (e) => ne(e.target.value),
8914
8955
  children: L.map((e) => /* @__PURE__ */ d("option", {
8915
8956
  value: e.id,
8916
8957
  children: e.name
@@ -8928,7 +8969,7 @@ function An({ sceneRef: e }) {
8928
8969
  className: "swatch-icon-btn swatch-icon-btn-danger",
8929
8970
  title: "Delete set",
8930
8971
  disabled: n.length <= 1,
8931
- onClick: ee,
8972
+ onClick: te,
8932
8973
  children: "🗑"
8933
8974
  })] })] }), g ? /* @__PURE__ */ f(u, { children: [
8934
8975
  /* @__PURE__ */ d("input", {
@@ -8937,14 +8978,14 @@ function An({ sceneRef: e }) {
8937
8978
  value: v,
8938
8979
  onChange: (e) => y(e.target.value),
8939
8980
  onKeyDown: (e) => {
8940
- e.key === "Enter" && V(), e.key === "Escape" && (_(!1), y(""));
8981
+ e.key === "Enter" && B(), e.key === "Escape" && (_(!1), y(""));
8941
8982
  },
8942
8983
  autoFocus: !0
8943
8984
  }),
8944
8985
  /* @__PURE__ */ d("button", {
8945
8986
  type: "button",
8946
8987
  className: "swatch-icon-btn",
8947
- onClick: V,
8988
+ onClick: B,
8948
8989
  children: "✓"
8949
8990
  }),
8950
8991
  /* @__PURE__ */ d("button", {
@@ -8967,12 +9008,12 @@ function An({ sceneRef: e }) {
8967
9008
  className: "swatch-grid",
8968
9009
  children: [R.swatches.map((e) => /* @__PURE__ */ f("div", {
8969
9010
  className: `swatch-chip${s === e.id ? " active" : ""}${T === e.id ? " editing" : ""}`,
8970
- onClick: () => ne(e.id),
9011
+ onClick: () => re(e.id),
8971
9012
  title: `${e.name} · env ${e.environment}${e.symbol ? ` · "${e.symbol}"` : ""}`,
8972
9013
  children: [
8973
9014
  /* @__PURE__ */ d("span", {
8974
9015
  className: "swatch-chip-env",
8975
- style: { background: z(e.environment) }
9016
+ style: { background: ee(e.environment) }
8976
9017
  }),
8977
9018
  e.symbol && /* @__PURE__ */ d("span", {
8978
9019
  className: "swatch-chip-symbol",
@@ -8987,7 +9028,7 @@ function An({ sceneRef: e }) {
8987
9028
  className: "swatch-chip-edit",
8988
9029
  title: "Edit",
8989
9030
  onClick: (t) => {
8990
- t.stopPropagation(), re(e);
9031
+ t.stopPropagation(), ie(e);
8991
9032
  },
8992
9033
  children: "✏"
8993
9034
  }), /* @__PURE__ */ d("button", {
@@ -8995,7 +9036,7 @@ function An({ sceneRef: e }) {
8995
9036
  className: "swatch-chip-del",
8996
9037
  title: "Delete",
8997
9038
  onClick: (t) => {
8998
- t.stopPropagation(), ie(e.id);
9039
+ t.stopPropagation(), G(e.id);
8999
9040
  },
9000
9041
  children: "×"
9001
9042
  })] })
@@ -9004,7 +9045,7 @@ function An({ sceneRef: e }) {
9004
9045
  type: "button",
9005
9046
  className: "swatch-add-btn",
9006
9047
  title: "Add swatch",
9007
- onClick: U,
9048
+ onClick: H,
9008
9049
  children: "+"
9009
9050
  })]
9010
9051
  }),
@@ -9025,7 +9066,7 @@ function An({ sceneRef: e }) {
9025
9066
  value: k,
9026
9067
  onChange: (e) => A(e.target.value),
9027
9068
  onKeyDown: (e) => {
9028
- e.key === "Enter" && G(), e.key === "Escape" && W();
9069
+ e.key === "Enter" && W(), e.key === "Escape" && U();
9029
9070
  },
9030
9071
  autoFocus: !0
9031
9072
  }),
@@ -9036,7 +9077,7 @@ function An({ sceneRef: e }) {
9036
9077
  value: j,
9037
9078
  onChange: (e) => M(e.target.value),
9038
9079
  onKeyDown: (e) => {
9039
- e.key === "Enter" && G(), e.key === "Escape" && W();
9080
+ e.key === "Enter" && W(), e.key === "Escape" && U();
9040
9081
  }
9041
9082
  }),
9042
9083
  /* @__PURE__ */ f("div", {
@@ -9044,14 +9085,14 @@ function An({ sceneRef: e }) {
9044
9085
  children: [/* @__PURE__ */ d("button", {
9045
9086
  type: "button",
9046
9087
  className: "swatch-env-btn",
9047
- style: { background: z(N) },
9088
+ style: { background: ee(N) },
9048
9089
  title: `Env ${N === -1 ? "none" : N} — click to change`,
9049
9090
  onClick: () => I((e) => !e),
9050
9091
  children: /* @__PURE__ */ d("span", {
9051
9092
  className: "swatch-env-id",
9052
9093
  children: N === -1 ? "−" : N
9053
9094
  })
9054
- }), F && c && /* @__PURE__ */ d($t, {
9095
+ }), F && c && /* @__PURE__ */ d(Qt, {
9055
9096
  map: c,
9056
9097
  sceneRef: e,
9057
9098
  currentEnvId: N,
@@ -9072,14 +9113,14 @@ function An({ sceneRef: e }) {
9072
9113
  type: "button",
9073
9114
  className: "swatch-edit-ok",
9074
9115
  title: "Save",
9075
- onClick: G,
9116
+ onClick: W,
9076
9117
  children: "✓"
9077
9118
  }),
9078
9119
  /* @__PURE__ */ d("button", {
9079
9120
  type: "button",
9080
9121
  className: "swatch-edit-cancel",
9081
9122
  title: "Cancel",
9082
- onClick: W,
9123
+ onClick: U,
9083
9124
  children: "✕"
9084
9125
  })
9085
9126
  ]
@@ -9334,15 +9375,173 @@ function Mn({ onClose: e }) {
9334
9375
  });
9335
9376
  }
9336
9377
  //#endregion
9378
+ //#region src/components/SpreadShrinkPopup.tsx
9379
+ function Nn({ sceneRef: e }) {
9380
+ let n = O((e) => e.spreadShrink), i = O((e) => e.selection), a = r(null);
9381
+ if (t(() => {
9382
+ if (!n) return;
9383
+ let e = () => D.setState({ spreadShrink: null }), t = (t) => {
9384
+ t.key === "Escape" && e();
9385
+ }, r = (t) => {
9386
+ t.button === 0 && a.current && !a.current.contains(t.target) && e();
9387
+ };
9388
+ return window.addEventListener("keydown", t), window.addEventListener("mousedown", r, !0), () => {
9389
+ window.removeEventListener("keydown", t), window.removeEventListener("mousedown", r, !0);
9390
+ };
9391
+ }, [n]), !n || !i || i.kind !== "room") return null;
9392
+ let { mode: o, factor: s, centerMode: c, anchorRoomId: l } = n, p = (e) => {
9393
+ D.setState({ spreadShrink: {
9394
+ ...n,
9395
+ mode: e,
9396
+ factor: e === "spread" ? 2 : .5
9397
+ } });
9398
+ }, m = (e) => {
9399
+ D.setState({ spreadShrink: {
9400
+ ...n,
9401
+ centerMode: e,
9402
+ anchorRoomId: null
9403
+ } });
9404
+ }, h = (e) => {
9405
+ let t = parseFloat(e);
9406
+ !isNaN(t) && t > 0 && D.setState({ spreadShrink: {
9407
+ ...n,
9408
+ factor: t
9409
+ } });
9410
+ };
9411
+ return /* @__PURE__ */ f("div", {
9412
+ ref: a,
9413
+ className: "spread-shrink-popup",
9414
+ onContextMenu: (e) => e.preventDefault(),
9415
+ children: [
9416
+ /* @__PURE__ */ f("div", {
9417
+ className: "spread-shrink-title",
9418
+ children: [
9419
+ o === "spread" ? "Spread" : "Shrink",
9420
+ " ",
9421
+ i.ids.length,
9422
+ " rooms"
9423
+ ]
9424
+ }),
9425
+ /* @__PURE__ */ f("div", {
9426
+ className: "spread-shrink-mode",
9427
+ children: [/* @__PURE__ */ d("button", {
9428
+ type: "button",
9429
+ className: `spread-shrink-tab${o === "spread" ? " active" : ""}`,
9430
+ onClick: () => p("spread"),
9431
+ children: "Spread"
9432
+ }), /* @__PURE__ */ d("button", {
9433
+ type: "button",
9434
+ className: `spread-shrink-tab${o === "shrink" ? " active" : ""}`,
9435
+ onClick: () => p("shrink"),
9436
+ children: "Shrink"
9437
+ })]
9438
+ }),
9439
+ /* @__PURE__ */ f("div", {
9440
+ className: "spread-shrink-mode",
9441
+ children: [/* @__PURE__ */ d("button", {
9442
+ type: "button",
9443
+ className: `spread-shrink-tab${c === "centroid" ? " active" : ""}`,
9444
+ onClick: () => m("centroid"),
9445
+ children: "Centroid"
9446
+ }), /* @__PURE__ */ d("button", {
9447
+ type: "button",
9448
+ className: `spread-shrink-tab${c === "anchor" ? " active" : ""}`,
9449
+ onClick: () => m("anchor"),
9450
+ children: "Anchor"
9451
+ })]
9452
+ }),
9453
+ c === "anchor" && /* @__PURE__ */ d("div", {
9454
+ className: "spread-shrink-anchor",
9455
+ children: l === null ? /* @__PURE__ */ d("span", {
9456
+ className: "spread-shrink-anchor-hint",
9457
+ children: "Right-click a room to set anchor"
9458
+ }) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ f("span", { children: ["Anchor: room ", l] }), /* @__PURE__ */ d("button", {
9459
+ type: "button",
9460
+ className: "spread-shrink-anchor-clear",
9461
+ onClick: () => m("anchor"),
9462
+ children: "×"
9463
+ })] })
9464
+ }),
9465
+ /* @__PURE__ */ f("div", {
9466
+ className: "spread-shrink-field",
9467
+ children: [/* @__PURE__ */ d("label", { children: "Scale factor" }), /* @__PURE__ */ d("input", {
9468
+ type: "number",
9469
+ min: "0.01",
9470
+ max: "10",
9471
+ step: "0.1",
9472
+ value: s,
9473
+ onChange: (e) => h(e.target.value)
9474
+ })]
9475
+ }),
9476
+ /* @__PURE__ */ f("div", {
9477
+ className: "spread-shrink-actions",
9478
+ children: [/* @__PURE__ */ d("button", {
9479
+ type: "button",
9480
+ className: "context-menu-btn",
9481
+ onClick: () => D.setState({ spreadShrink: null }),
9482
+ children: "Cancel"
9483
+ }), /* @__PURE__ */ d("button", {
9484
+ type: "button",
9485
+ className: "context-menu-btn primary",
9486
+ onClick: () => {
9487
+ let t = D.getState(), n = t.selection, r = e.current;
9488
+ if (!n || n.kind !== "room" || !r || !t.map) return;
9489
+ let i = [];
9490
+ for (let e of n.ids) {
9491
+ let n = r.getRenderRoom(e);
9492
+ !n || n.z !== t.currentZ || n.area !== t.currentAreaId || i.push({
9493
+ id: e,
9494
+ rx: n.x,
9495
+ ry: n.y
9496
+ });
9497
+ }
9498
+ if (i.length < 2) {
9499
+ D.setState({ spreadShrink: null });
9500
+ return;
9501
+ }
9502
+ let a = t.spreadShrink, c, l;
9503
+ if (a.centerMode === "anchor" && a.anchorRoomId !== null) {
9504
+ let e = r.getRenderRoom(a.anchorRoomId);
9505
+ c = e ? e.x : i.reduce((e, t) => e + t.rx, 0) / i.length, l = e ? e.y : i.reduce((e, t) => e + t.ry, 0) / i.length;
9506
+ } else c = i.reduce((e, t) => e + t.rx, 0) / i.length, l = i.reduce((e, t) => e + t.ry, 0) / i.length;
9507
+ let u = t.snapToGrid ? (e) => Math.round(e / t.gridStep) * t.gridStep : (e) => e, d = [];
9508
+ for (let { id: e, rx: n, ry: r } of i) {
9509
+ let i = u(c + (n - c) * s), a = u(l + (r - l) * s), o = t.map.rooms[e];
9510
+ if (!o) continue;
9511
+ let f = i, p = -a;
9512
+ f === o.x && p === o.y || (d.push({
9513
+ kind: "moveRoom",
9514
+ id: e,
9515
+ from: {
9516
+ x: o.x,
9517
+ y: o.y,
9518
+ z: o.z
9519
+ },
9520
+ to: {
9521
+ x: f,
9522
+ y: p,
9523
+ z: o.z
9524
+ }
9525
+ }), d.push(...ke(t.map, e, f - o.x, p - o.y)));
9526
+ }
9527
+ d.length > 0 && (X(d, r), r.refresh(), D.bumpStructure(), D.setState({ status: `${o === "spread" ? "Spread" : "Shrunk"} ${i.length} rooms (×${s.toFixed(2)})` })), D.setState({ spreadShrink: null });
9528
+ },
9529
+ children: "Apply"
9530
+ })]
9531
+ })
9532
+ ]
9533
+ });
9534
+ }
9535
+ //#endregion
9337
9536
  //#region src/editor/reader/EditorMapReader.ts
9338
- var Nn = {
9537
+ var Pn = {
9339
9538
  1: "solid line",
9340
9539
  2: "dash line",
9341
9540
  3: "dot line",
9342
9541
  4: "dash dot line",
9343
9542
  5: "dash dot dot line"
9344
9543
  };
9345
- function Pn(e, t) {
9544
+ function Fn(e, t) {
9346
9545
  let n = {
9347
9546
  id: e,
9348
9547
  __raw: t
@@ -9431,7 +9630,7 @@ function Pn(e, t) {
9431
9630
  g: 255,
9432
9631
  b: 255
9433
9632
  },
9434
- style: Nn[t.customLinesStyle?.[r]] ?? "solid line",
9633
+ style: Pn[t.customLinesStyle?.[r]] ?? "solid line",
9435
9634
  arrow: t.customLinesArrow?.[r] ?? !1
9436
9635
  }
9437
9636
  };
@@ -9442,7 +9641,7 @@ function Pn(e, t) {
9442
9641
  configurable: !0
9443
9642
  }), n;
9444
9643
  }
9445
- function Fn(e) {
9644
+ function In(e) {
9446
9645
  let t = {
9447
9646
  north: "south",
9448
9647
  south: "north",
@@ -9508,7 +9707,7 @@ function Fn(e) {
9508
9707
  }
9509
9708
  return r;
9510
9709
  }
9511
- function In(e) {
9710
+ function Ln(e) {
9512
9711
  if (!e || e.length === 0) return "";
9513
9712
  if (typeof e == "string") return e.includes(",") ? e.split(",")[1] : e;
9514
9713
  try {
@@ -9517,10 +9716,10 @@ function In(e) {
9517
9716
  return "";
9518
9717
  }
9519
9718
  }
9520
- function Ln(e) {
9521
- e.pixMapBase64 === void 0 && (e.pixMapBase64 = In(e.pixMap));
9719
+ function Rn(e) {
9720
+ e.pixMapBase64 === void 0 && (e.pixMapBase64 = Ln(e.pixMap));
9522
9721
  }
9523
- function Rn(e, t) {
9722
+ function zn(e, t) {
9524
9723
  let n = e.id;
9525
9724
  if (!e.font) {
9526
9725
  let r = t[`system.labelFont_${n}`];
@@ -9550,7 +9749,7 @@ function Rn(e, t) {
9550
9749
  });
9551
9750
  }
9552
9751
  }
9553
- function zn(e, t) {
9752
+ function Bn(e, t) {
9554
9753
  let n = e.id, r = e.font;
9555
9754
  if (r?.family) {
9556
9755
  let e = r.bold ? 75 : 50;
@@ -9561,7 +9760,7 @@ function zn(e, t) {
9561
9760
  t[`system.labelOutlineColor_${n}`] = `${r}|${i}|${a}|${o}`;
9562
9761
  } else t[`system.labelOutlineColor_${n}`] = "0|0|0|0";
9563
9762
  }
9564
- function Bn(e) {
9763
+ function Vn(e) {
9565
9764
  return {
9566
9765
  id: e.id,
9567
9766
  pos: [...e.pos],
@@ -9577,7 +9776,7 @@ function Bn(e) {
9577
9776
  imageSrc: e.imageSrc
9578
9777
  };
9579
9778
  }
9580
- var Vn = class {
9779
+ var Hn = class {
9581
9780
  constructor(e, t) {
9582
9781
  this.rooms = e, this.labels = t;
9583
9782
  }
@@ -9607,7 +9806,7 @@ var Vn = class {
9607
9806
  setLabels(e) {
9608
9807
  this.labels = e;
9609
9808
  }
9610
- }, Hn = class {
9809
+ }, Un = class {
9611
9810
  planes = {};
9612
9811
  exits = /* @__PURE__ */ new Map();
9613
9812
  version = 0;
@@ -9675,19 +9874,19 @@ var Vn = class {
9675
9874
  let t = {};
9676
9875
  for (let [n, r] of Object.entries(e)) {
9677
9876
  let e = Number(n);
9678
- t[e] = new Vn(r, this.labels.filter((t) => t.Z === e));
9877
+ t[e] = new Hn(r, this.labels.filter((t) => t.Z === e));
9679
9878
  }
9680
9879
  this.planes = t;
9681
9880
  }
9682
9881
  rebuildExits() {
9683
- this.exits = Fn(this.rooms);
9882
+ this.exits = In(this.rooms);
9684
9883
  }
9685
9884
  };
9686
- function Un(e) {
9885
+ function Wn(e) {
9687
9886
  let t = e[0] / 255, n = e[1] / 255, r = e[2] / 255;
9688
9887
  return (Math.max(t, n, r) + Math.min(t, n, r)) / 2;
9689
9888
  }
9690
- var Wn = {
9889
+ var Gn = {
9691
9890
  rgb: [
9692
9891
  114,
9693
9892
  1,
@@ -9700,17 +9899,17 @@ var Wn = {
9700
9899
  225
9701
9900
  ],
9702
9901
  symbolColorValue: "rgb(225,225,225)"
9703
- }, Gn = class {
9902
+ }, Kn = class {
9704
9903
  rooms = {};
9705
9904
  areas = {};
9706
9905
  colors = {};
9707
9906
  constructor(e) {
9708
9907
  this.raw = e;
9709
- let { colors: t } = W(e);
9908
+ let { colors: t } = U(e);
9710
9909
  for (let e of t) this.colors[e.envId] = {
9711
9910
  rgb: e.colors,
9712
9911
  rgbValue: `rgb(${e.colors.join(",")})`,
9713
- symbolColor: Un(e.colors) > .41 ? [
9912
+ symbolColor: Wn(e.colors) > .41 ? [
9714
9913
  25,
9715
9914
  25,
9716
9915
  25
@@ -9719,19 +9918,19 @@ var Wn = {
9719
9918
  255,
9720
9919
  255
9721
9920
  ],
9722
- symbolColorValue: Un(e.colors) > .41 ? "rgb(25,25,25)" : "rgb(225,255,255)"
9921
+ symbolColorValue: Wn(e.colors) > .41 ? "rgb(25,25,25)" : "rgb(225,255,255)"
9723
9922
  };
9724
9923
  for (let [t, n] of Object.entries(e.areas)) {
9725
9924
  let r = Number(t), i = [];
9726
9925
  for (let t of n.rooms) {
9727
9926
  let n = e.rooms[t];
9728
9927
  if (!n) continue;
9729
- let r = Pn(t, n);
9928
+ let r = Fn(t, n);
9730
9929
  this.rooms[t] = r, i.push(r);
9731
9930
  }
9732
9931
  let a = e.labels?.[r] ?? [], o = e.areas[r]?.userData ?? {};
9733
- for (let e of a) Ln(e), Rn(e, o);
9734
- this.areas[r] = new Hn(r, e.areaNames[r] ?? `Area ${r}`, i, a.map((e) => this.toRendererLabel(e, r)));
9932
+ for (let e of a) Rn(e), zn(e, o);
9933
+ this.areas[r] = new Un(r, e.areaNames[r] ?? `Area ${r}`, i, a.map((e) => this.toRendererLabel(e, r)));
9735
9934
  }
9736
9935
  }
9737
9936
  toRendererLabel(e, t) {
@@ -9788,10 +9987,10 @@ var Wn = {
9788
9987
  return !1;
9789
9988
  }
9790
9989
  getColorValue(e) {
9791
- return this.colors[e]?.rgbValue ?? Wn.rgbValue;
9990
+ return this.colors[e]?.rgbValue ?? Gn.rgbValue;
9792
9991
  }
9793
9992
  getSymbolColor(e, t) {
9794
- let n = this.colors[e] ?? Wn, r = Math.min(Math.max(t ?? 1, 0), 1), i = n.symbolColor.join(",");
9993
+ let n = this.colors[e] ?? Gn, r = Math.min(Math.max(t ?? 1, 0), 1), i = n.symbolColor.join(",");
9795
9994
  return r === 1 ? `rgba(${i})` : `rgba(${i}, ${r})`;
9796
9995
  }
9797
9996
  moveRoom(e, t, n, r) {
@@ -9825,7 +10024,7 @@ var Wn = {
9825
10024
  this.raw.rooms[e] = t;
9826
10025
  let n = this.raw.areas[t.area];
9827
10026
  n && !n.rooms.includes(e) && n.rooms.push(e);
9828
- let r = Pn(e, t);
10027
+ let r = Fn(e, t);
9829
10028
  this.rooms[e] = r, this.areas[t.area]?.addRoomLive(r);
9830
10029
  }
9831
10030
  setSpecialExit(e, t, n) {
@@ -9921,7 +10120,7 @@ var Wn = {
9921
10120
  isZone: !1,
9922
10121
  zoneAreaRef: -1,
9923
10122
  userData: {}
9924
- }, this.raw.areaNames[e] = t, this.areas[e] = new Hn(e, t, [], []);
10123
+ }, this.raw.areaNames[e] = t, this.areas[e] = new Un(e, t, [], []);
9925
10124
  }
9926
10125
  removeArea(e) {
9927
10126
  delete this.raw.areas[e], delete this.raw.areaNames[e], delete this.areas[e];
@@ -9949,11 +10148,11 @@ var Wn = {
9949
10148
  }
9950
10149
  setCustomEnvColor(e, t) {
9951
10150
  t === null ? delete this.raw.mCustomEnvColors[e] : this.raw.mCustomEnvColors[e] = t;
9952
- let { colors: n } = W(this.raw);
10151
+ let { colors: n } = U(this.raw);
9953
10152
  for (let e of n) this.colors[e.envId] = {
9954
10153
  rgb: e.colors,
9955
10154
  rgbValue: `rgb(${e.colors.join(",")})`,
9956
- symbolColor: Un(e.colors) > .41 ? [
10155
+ symbolColor: Wn(e.colors) > .41 ? [
9957
10156
  25,
9958
10157
  25,
9959
10158
  25
@@ -9962,17 +10161,17 @@ var Wn = {
9962
10161
  255,
9963
10162
  255
9964
10163
  ],
9965
- symbolColorValue: Un(e.colors) > .41 ? "rgb(25,25,25)" : "rgb(225,255,255)"
10164
+ symbolColorValue: Wn(e.colors) > .41 ? "rgb(25,25,25)" : "rgb(225,255,255)"
9966
10165
  };
9967
10166
  t === null && delete this.colors[e];
9968
10167
  }
9969
10168
  getLabelSnapshot(e, t) {
9970
10169
  let n = this.raw.labels[e]?.find((e) => e.id === t);
9971
- return n ? Bn(n) : null;
10170
+ return n ? Vn(n) : null;
9972
10171
  }
9973
10172
  addLabel(e, t) {
9974
10173
  this.raw.labels[e] || (this.raw.labels[e] = []);
9975
- let n = t.pixMap || Gt(t), r = {
10174
+ let n = t.pixMap || Wt(t), r = {
9976
10175
  id: t.id,
9977
10176
  labelId: t.id,
9978
10177
  areaId: e,
@@ -9981,7 +10180,7 @@ var Wn = {
9981
10180
  text: t.text,
9982
10181
  fgColor: { ...t.fgColor },
9983
10182
  bgColor: { ...t.bgColor },
9984
- pixMap: Kt(n),
10183
+ pixMap: Gt(n),
9985
10184
  pixMapBase64: n.includes(",") ? n.split(",")[1] : n,
9986
10185
  noScaling: t.noScaling,
9987
10186
  showOnTop: t.showOnTop,
@@ -9990,7 +10189,7 @@ var Wn = {
9990
10189
  };
9991
10190
  this.raw.labels[e].push(r);
9992
10191
  let i = this.raw.areas[e]?.userData;
9993
- i && zn(r, i), this.syncRendererLabels(e);
10192
+ i && Bn(r, i), this.syncRendererLabels(e);
9994
10193
  }
9995
10194
  removeLabel(e, t) {
9996
10195
  if (!this.raw.labels[e]) return;
@@ -10012,7 +10211,7 @@ var Wn = {
10012
10211
  }
10013
10212
  setLabelPixmap(e, t, n) {
10014
10213
  let r = this.raw.labels[e]?.find((e) => e.id === t);
10015
- r && (r.pixMap = Kt(n), r.pixMapBase64 = n.includes(",") ? n.split(",")[1] : n, this.syncRendererLabels(e));
10214
+ r && (r.pixMap = Gt(n), r.pixMapBase64 = n.includes(",") ? n.split(",")[1] : n, this.syncRendererLabels(e));
10016
10215
  }
10017
10216
  setLabelImageSrc(e, t, n) {
10018
10217
  let r = this.raw.labels[e]?.find((e) => e.id === t);
@@ -10023,14 +10222,14 @@ var Wn = {
10023
10222
  if (!r) return;
10024
10223
  r.font = { ...n };
10025
10224
  let i = this.raw.areas[e]?.userData;
10026
- i && zn(r, i), this.syncRendererLabels(e);
10225
+ i && Bn(r, i), this.syncRendererLabels(e);
10027
10226
  }
10028
10227
  setLabelOutlineColor(e, t, n) {
10029
10228
  let r = this.raw.labels[e]?.find((e) => e.id === t);
10030
10229
  if (!r) return;
10031
10230
  r.outlineColor = n ? { ...n } : void 0;
10032
10231
  let i = this.raw.areas[e]?.userData;
10033
- i && zn(r, i), this.syncRendererLabels(e);
10232
+ i && Bn(r, i), this.syncRendererLabels(e);
10034
10233
  }
10035
10234
  setLabelNoScaling(e, t, n) {
10036
10235
  let r = this.raw.labels[e]?.find((e) => e.id === t);
@@ -10061,10 +10260,10 @@ var Wn = {
10061
10260
  restoreAreaWithRooms(e, t, n, r) {
10062
10261
  let i = [];
10063
10262
  for (let { id: e, room: t } of n) {
10064
- let n = Pn(e, t);
10263
+ let n = Fn(e, t);
10065
10264
  this.rooms[e] = n, i.push(n);
10066
10265
  }
10067
- this.areas[e] = new Hn(e, t, i, []);
10266
+ this.areas[e] = new Un(e, t, i, []);
10068
10267
  for (let e of r) {
10069
10268
  let t = this.areas[e];
10070
10269
  t && (t.rebuildExits(), t.markDirty());
@@ -10103,7 +10302,7 @@ var Wn = {
10103
10302
  }
10104
10303
  for (let e of this.getAreas()) n.has(e.getAreaId()) || e.rebuildExits();
10105
10304
  }
10106
- }, Kn = class {
10305
+ }, qn = class {
10107
10306
  rects = /* @__PURE__ */ new Map();
10108
10307
  layer;
10109
10308
  unsubscribe;
@@ -10147,7 +10346,7 @@ var Wn = {
10147
10346
  }
10148
10347
  this.layer.batchDraw();
10149
10348
  }
10150
- }, qn = "#ffcc00", Jn = .9, Yn = .3, Xn = .2, Zn = class {
10349
+ }, Jn = "#ffcc00", Yn = .9, Xn = .3, Zn = .2, Qn = class {
10151
10350
  roomRect;
10152
10351
  linkGroup;
10153
10352
  layer;
@@ -10158,7 +10357,7 @@ var Wn = {
10158
10357
  }
10159
10358
  attach(e) {
10160
10359
  this.layer = e, this.roomRect = new h.Rect({
10161
- stroke: qn,
10360
+ stroke: Jn,
10162
10361
  strokeWidth: .06,
10163
10362
  listening: !1,
10164
10363
  visible: !1,
@@ -10206,23 +10405,23 @@ var Wn = {
10206
10405
  }
10207
10406
  for (let t of e.data.lines) this.linkGroup.add(new h.Line({
10208
10407
  points: [...t.points],
10209
- stroke: qn,
10408
+ stroke: Jn,
10210
10409
  strokeWidth: r,
10211
10410
  dash: t.dash ? [...t.dash] : void 0,
10212
10411
  listening: !1,
10213
10412
  lineCap: "round",
10214
- opacity: Jn
10413
+ opacity: Yn
10215
10414
  }));
10216
10415
  for (let t of e.data.arrows) this.linkGroup.add(new h.Arrow({
10217
10416
  points: [...t.points],
10218
- stroke: qn,
10219
- fill: qn,
10417
+ stroke: Jn,
10418
+ fill: Jn,
10220
10419
  strokeWidth: r,
10221
10420
  dash: t.dash ? [...t.dash] : void 0,
10222
10421
  pointerLength: t.pointerLength,
10223
10422
  pointerWidth: t.pointerWidth,
10224
10423
  listening: !1,
10225
- opacity: Jn
10424
+ opacity: Yn
10226
10425
  }));
10227
10426
  this.linkGroup.visible(!0);
10228
10427
  } else if (t.kind === "customLine") {
@@ -10233,33 +10432,33 @@ var Wn = {
10233
10432
  }
10234
10433
  let i = e.hasArrow && e.points.length >= 4 ? new h.Arrow({
10235
10434
  points: [...e.points],
10236
- stroke: qn,
10237
- fill: qn,
10435
+ stroke: Jn,
10436
+ fill: Jn,
10238
10437
  strokeWidth: r,
10239
10438
  dash: e.dash ? [...e.dash] : void 0,
10240
- pointerLength: Yn,
10241
- pointerWidth: Xn,
10439
+ pointerLength: Xn,
10440
+ pointerWidth: Zn,
10242
10441
  listening: !1,
10243
10442
  lineCap: "round",
10244
10443
  lineJoin: "round",
10245
- opacity: Jn
10444
+ opacity: Yn
10246
10445
  }) : new h.Line({
10247
10446
  points: [...e.points],
10248
- stroke: qn,
10447
+ stroke: Jn,
10249
10448
  strokeWidth: r,
10250
10449
  dash: e.dash ? [...e.dash] : void 0,
10251
10450
  listening: !1,
10252
10451
  lineCap: "round",
10253
10452
  lineJoin: "round",
10254
- opacity: Jn
10453
+ opacity: Yn
10255
10454
  });
10256
10455
  this.linkGroup.add(i), this.linkGroup.visible(!0);
10257
10456
  }
10258
10457
  this.layer.batchDraw();
10259
10458
  }
10260
- }, Qn = .6;
10261
- function $n(e) {
10262
- for (let [t, n, r] of ot) if (r === e) return {
10459
+ }, $n = .6;
10460
+ function er(e) {
10461
+ for (let [t, n, r] of at) if (r === e) return {
10263
10462
  ox: t,
10264
10463
  oy: n
10265
10464
  };
@@ -10268,7 +10467,7 @@ function $n(e) {
10268
10467
  oy: 0
10269
10468
  };
10270
10469
  }
10271
- var er = class {
10470
+ var tr = class {
10272
10471
  line;
10273
10472
  dirLabel;
10274
10473
  layer;
@@ -10315,14 +10514,14 @@ var er = class {
10315
10514
  }
10316
10515
  let r = n.getRenderRoom(t.sourceId);
10317
10516
  if (!r) return;
10318
- let i = t.hoverTargetId == null ? null : n.getRenderRoom(t.hoverTargetId), a = (n.settings.roomSize ?? Qn) / 2, o = r.x, s = r.y;
10517
+ let i = t.hoverTargetId == null ? null : n.getRenderRoom(t.hoverTargetId), a = (n.settings.roomSize ?? $n) / 2, o = r.x, s = r.y;
10319
10518
  if (t.sourceDir) {
10320
- let { ox: e, oy: n } = $n(t.sourceDir);
10519
+ let { ox: e, oy: n } = er(t.sourceDir);
10321
10520
  o = r.x + e * a, s = r.y + n * a;
10322
10521
  }
10323
10522
  let c, l;
10324
10523
  if (i && t.targetDir) {
10325
- let { ox: e, oy: n } = $n(t.targetDir);
10524
+ let { ox: e, oy: n } = er(t.targetDir);
10326
10525
  c = i.x + e * a, l = i.y + n * a;
10327
10526
  } else i ? (c = i.x, l = i.y) : (c = t.cursorMap?.x ?? r.x, l = t.cursorMap?.y ?? r.y);
10328
10527
  let u = !0, d = "";
@@ -10343,7 +10542,7 @@ var er = class {
10343
10542
  l
10344
10543
  ]), this.line.stroke(f), this.line.fill(f), this.line.visible(!0), d ? (this.dirLabel.text(d), this.dirLabel.fill(f), this.dirLabel.x((o + c) / 2 + .2), this.dirLabel.y((s + l) / 2 + .2), this.dirLabel.visible(!0)) : this.dirLabel.visible(!1), this.layer.batchDraw();
10345
10544
  }
10346
- }, tr = class {
10545
+ }, nr = class {
10347
10546
  rect;
10348
10547
  layer;
10349
10548
  unsubscribe;
@@ -10379,7 +10578,7 @@ var er = class {
10379
10578
  }
10380
10579
  this.rect.x(t.x), this.rect.y(t.y), this.rect.visible(!0), this.layer.batchDraw();
10381
10580
  }
10382
- }, nr = class {
10581
+ }, rr = class {
10383
10582
  source;
10384
10583
  target;
10385
10584
  layer;
@@ -10403,7 +10602,7 @@ var er = class {
10403
10602
  listening: !1,
10404
10603
  visible: !1
10405
10604
  }), t = /* @__PURE__ */ new Map();
10406
- for (let [, , n] of ot) {
10605
+ for (let [, , n] of at) {
10407
10606
  let r = new h.Circle({
10408
10607
  radius: this.roomSize * .12,
10409
10608
  fill: "rgba(143, 184, 255, 0.85)",
@@ -10420,7 +10619,7 @@ var er = class {
10420
10619
  }
10421
10620
  placeHandles(e, t, n, r) {
10422
10621
  let i = this.roomSize / 2, a = r === "drag-source" || r === "drag-target" ? "#7fff9f" : "#ffd27f", o = r === "drag-source" || r === "drag-target" ? "#ffffff" : "#cfe1ff";
10423
- for (let [r, s, c] of ot) {
10622
+ for (let [r, s, c] of at) {
10424
10623
  let l = e.handles.get(c);
10425
10624
  l.x(t.x + r * i), l.y(t.y + s * i), l.fill(c === n ? a : "rgba(143, 184, 255, 0.85)"), l.stroke(c === n ? o : "#cfe1ff");
10426
10625
  }
@@ -10457,7 +10656,7 @@ var er = class {
10457
10656
  }
10458
10657
  this.layer.batchDraw();
10459
10658
  }
10460
- }, rr = "rgba(255, 220, 60, 0.9)", ir = .55, ar = class {
10659
+ }, ir = "rgba(255, 220, 60, 0.9)", ar = .55, or = class {
10461
10660
  group;
10462
10661
  layer;
10463
10662
  unsubscribe;
@@ -10530,14 +10729,14 @@ var er = class {
10530
10729
  if (o) {
10531
10730
  let t = this.resolveTargetRoom(e, o.roomId, o.exitName);
10532
10731
  if (t) {
10533
- let { x: e, y: n } = t, r = ir, i = new h.Line({
10732
+ let { x: e, y: n } = t, r = ar, i = new h.Line({
10534
10733
  points: [
10535
10734
  e - r,
10536
10735
  n,
10537
10736
  e + r,
10538
10737
  n
10539
10738
  ],
10540
- stroke: rr,
10739
+ stroke: ir,
10541
10740
  strokeWidth: a,
10542
10741
  listening: !1,
10543
10742
  lineCap: "round"
@@ -10548,7 +10747,7 @@ var er = class {
10548
10747
  e,
10549
10748
  n + r
10550
10749
  ],
10551
- stroke: rr,
10750
+ stroke: ir,
10552
10751
  strokeWidth: a,
10553
10752
  listening: !1,
10554
10753
  lineCap: "round"
@@ -10578,11 +10777,11 @@ var er = class {
10578
10777
  y: c.y
10579
10778
  };
10580
10779
  }
10581
- }, or = "#00e5ff", sr = {
10582
- shadowColor: or,
10780
+ }, sr = "#00e5ff", cr = {
10781
+ shadowColor: sr,
10583
10782
  shadowBlur: 4,
10584
10783
  shadowOpacity: .8
10585
- }, cr = .3, lr = .2, ur = class {
10784
+ }, lr = .3, ur = .2, dr = class {
10586
10785
  group;
10587
10786
  layer;
10588
10787
  unsubscribe;
@@ -10620,22 +10819,22 @@ var er = class {
10620
10819
  }
10621
10820
  for (let t of e.data.lines) this.group.add(new h.Line({
10622
10821
  points: [...t.points],
10623
- stroke: or,
10822
+ stroke: sr,
10624
10823
  strokeWidth: .08,
10625
10824
  dash: t.dash ? [...t.dash] : void 0,
10626
10825
  listening: !1,
10627
- ...sr
10826
+ ...cr
10628
10827
  }));
10629
10828
  for (let t of e.data.arrows) this.group.add(new h.Arrow({
10630
10829
  points: [...t.points],
10631
- stroke: or,
10632
- fill: or,
10830
+ stroke: sr,
10831
+ fill: sr,
10633
10832
  strokeWidth: .08,
10634
10833
  dash: t.dash ? [...t.dash] : void 0,
10635
10834
  pointerLength: t.pointerLength,
10636
10835
  pointerWidth: t.pointerWidth,
10637
10836
  listening: !1,
10638
- ...sr
10837
+ ...cr
10639
10838
  }));
10640
10839
  this.group.visible(!0), this.layer.batchDraw();
10641
10840
  return;
@@ -10648,28 +10847,28 @@ var er = class {
10648
10847
  }
10649
10848
  let r = e.hasArrow && e.points.length >= 4 ? new h.Arrow({
10650
10849
  points: [...e.points],
10651
- stroke: or,
10652
- fill: or,
10850
+ stroke: sr,
10851
+ fill: sr,
10653
10852
  strokeWidth: .08,
10654
10853
  dash: e.dash ? [...e.dash] : void 0,
10655
- pointerLength: cr,
10656
- pointerWidth: lr,
10854
+ pointerLength: lr,
10855
+ pointerWidth: ur,
10657
10856
  listening: !1,
10658
- ...sr
10857
+ ...cr
10659
10858
  }) : new h.Line({
10660
10859
  points: [...e.points],
10661
- stroke: or,
10860
+ stroke: sr,
10662
10861
  strokeWidth: .08,
10663
10862
  dash: e.dash ? [...e.dash] : void 0,
10664
10863
  listening: !1,
10665
- ...sr
10864
+ ...cr
10666
10865
  });
10667
10866
  this.group.add(r), this.group.add(new h.Circle({
10668
10867
  x: e.points[0],
10669
10868
  y: e.points[1],
10670
10869
  radius: .1,
10671
10870
  fill: "#1a2030",
10672
- stroke: or,
10871
+ stroke: sr,
10673
10872
  strokeWidth: .04,
10674
10873
  listening: !1
10675
10874
  }));
@@ -10680,8 +10879,8 @@ var er = class {
10680
10879
  x: e.points[t],
10681
10880
  y: e.points[t + 1],
10682
10881
  radius: r ? .14 : .1,
10683
- fill: r ? "#ffffff" : or,
10684
- stroke: r ? or : "#ffffff",
10882
+ fill: r ? "#ffffff" : sr,
10883
+ stroke: r ? sr : "#ffffff",
10685
10884
  strokeWidth: r ? .06 : .04,
10686
10885
  listening: !1
10687
10886
  }));
@@ -10694,13 +10893,13 @@ var er = class {
10694
10893
  };
10695
10894
  //#endregion
10696
10895
  //#region src/editor/effects/GridOverlayEffect.ts
10697
- function dr(e, t) {
10896
+ function fr(e, t) {
10698
10897
  let n = e.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\s*\)/);
10699
10898
  if (!n) return e;
10700
10899
  let r = n[4] === void 0 ? 1 : parseFloat(n[4]);
10701
10900
  return `rgba(${n[1]}, ${n[2]}, ${n[3]}, ${Math.min(1, r * t)})`;
10702
10901
  }
10703
- var fr = class {
10902
+ var pr = class {
10704
10903
  gridShape;
10705
10904
  axisShape;
10706
10905
  labelShape;
@@ -10732,7 +10931,7 @@ var fr = class {
10732
10931
  }), this.axisShape = new h.Shape({
10733
10932
  listening: !1,
10734
10933
  visible: !1,
10735
- stroke: dr(this.gridColor, 2),
10934
+ stroke: fr(this.gridColor, 2),
10736
10935
  strokeWidth: this.gridLineWidth * 2,
10737
10936
  sceneFunc: (e, t) => {
10738
10937
  let { minX: n, maxX: r, minY: i, maxY: a } = this.bounds;
@@ -10746,7 +10945,7 @@ var fr = class {
10746
10945
  text: "(0,0)",
10747
10946
  fontSize: this.gridSize,
10748
10947
  fontFamily: "monospace",
10749
- fill: dr(this.gridColor, 2)
10948
+ fill: fr(this.gridColor, 2)
10750
10949
  }), e.add(this.gridShape), e.add(this.axisShape), e.add(this.labelShape), this.unsubscribe = D.subscribe(() => this.syncVisibility());
10751
10950
  }
10752
10951
  updateViewport(e, t, n) {
@@ -10760,7 +10959,7 @@ var fr = class {
10760
10959
  let e = this.getIsEmpty();
10761
10960
  e && (this.bounds = this.getViewportBounds()), this.gridShape.visible() !== e && (this.gridShape.visible(e), this.axisShape.visible(e), this.labelShape.visible(e), this.layer.batchDraw());
10762
10961
  }
10763
- }, pr = class {
10962
+ }, mr = class {
10764
10963
  rect;
10765
10964
  layer;
10766
10965
  unsubscribe;
@@ -10794,7 +10993,7 @@ var fr = class {
10794
10993
  };
10795
10994
  //#endregion
10796
10995
  //#region src/editor/effects/LabelHaloEffect.ts
10797
- function mr(e, t, n, r) {
10996
+ function hr(e, t, n, r) {
10798
10997
  return [
10799
10998
  {
10800
10999
  id: "nw",
@@ -10838,7 +11037,7 @@ function mr(e, t, n, r) {
10838
11037
  }
10839
11038
  ];
10840
11039
  }
10841
- var hr = class {
11040
+ var gr = class {
10842
11041
  selRect;
10843
11042
  hoverRect;
10844
11043
  previewRect;
@@ -10928,7 +11127,7 @@ var hr = class {
10928
11127
  for (let e of this.handles) e.visible(!1);
10929
11128
  return;
10930
11129
  }
10931
- let t = .05, n = e.x - t, r = e.y - t, i = e.w + t * 2, a = e.h + t * 2, o = this.handleSize, s = mr(n, r, i, a);
11130
+ let t = .05, n = e.x - t, r = e.y - t, i = e.w + t * 2, a = e.h + t * 2, o = this.handleSize, s = hr(n, r, i, a);
10932
11131
  for (let e = 0; e < this.handles.length; e++) {
10933
11132
  let t = this.handles[e], n = s[e];
10934
11133
  t.x(n.x - o / 2), t.y(n.y - o / 2), t.width(o), t.height(o), t.visible(!0);
@@ -10947,13 +11146,170 @@ var hr = class {
10947
11146
  } else this.previewRect.visible(!1);
10948
11147
  this.layer.batchDraw();
10949
11148
  }
11149
+ }, _r = class {
11150
+ hLine;
11151
+ vLine;
11152
+ dot;
11153
+ layer;
11154
+ unsubscribe;
11155
+ constructor(e) {
11156
+ this.sceneRef = e;
11157
+ }
11158
+ attach(e) {
11159
+ this.layer = e;
11160
+ let t = {
11161
+ stroke: "rgba(0, 229, 255, 0.7)",
11162
+ strokeWidth: .05,
11163
+ listening: !1,
11164
+ visible: !1
11165
+ };
11166
+ this.hLine = new h.Line({
11167
+ ...t,
11168
+ points: [
11169
+ 0,
11170
+ 0,
11171
+ 0,
11172
+ 0
11173
+ ]
11174
+ }), this.vLine = new h.Line({
11175
+ ...t,
11176
+ points: [
11177
+ 0,
11178
+ 0,
11179
+ 0,
11180
+ 0
11181
+ ]
11182
+ }), this.dot = new h.Circle({
11183
+ radius: .07,
11184
+ fill: "rgba(0, 229, 255, 0.6)",
11185
+ listening: !1,
11186
+ visible: !1
11187
+ }), e.add(this.hLine), e.add(this.vLine), e.add(this.dot), this.unsubscribe = D.subscribe((e) => this.sync(e)), this.sync(D.getState());
11188
+ }
11189
+ updateViewport(e, t, n) {
11190
+ let r = Math.max(.02, 1.5 / t);
11191
+ this.hLine?.strokeWidth(r), this.vLine?.strokeWidth(r), this.layer?.batchDraw();
11192
+ }
11193
+ syncPositions() {
11194
+ this.sync(D.getState());
11195
+ }
11196
+ destroy() {
11197
+ this.unsubscribe?.(), this.hLine?.destroy(), this.vLine?.destroy(), this.dot?.destroy();
11198
+ }
11199
+ sync(e) {
11200
+ if (!this.layer) return;
11201
+ let t = e.selection, n = this.sceneRef.current, r = () => {
11202
+ this.hLine?.visible(!1), this.vLine?.visible(!1), this.dot?.visible(!1), this.layer.batchDraw();
11203
+ };
11204
+ if (!t || t.kind !== "room" || t.ids.length < 2 || !n) return r();
11205
+ let { spreadShrink: i } = e, a, o;
11206
+ if (i?.centerMode === "anchor" && i.anchorRoomId !== null) {
11207
+ let e = n.getRenderRoom(i.anchorRoomId);
11208
+ if (!e) return r();
11209
+ a = e.x, o = e.y;
11210
+ } else {
11211
+ let i = [];
11212
+ for (let r of t.ids) {
11213
+ let t = n.getRenderRoom(r);
11214
+ !t || t.z !== e.currentZ || t.area !== e.currentAreaId || i.push({
11215
+ x: t.x,
11216
+ y: t.y
11217
+ });
11218
+ }
11219
+ if (i.length < 2) return r();
11220
+ a = i.reduce((e, t) => e + t.x, 0) / i.length, o = i.reduce((e, t) => e + t.y, 0) / i.length;
11221
+ }
11222
+ let s = .3;
11223
+ this.hLine.points([
11224
+ a - s,
11225
+ o,
11226
+ a + s,
11227
+ o
11228
+ ]), this.hLine.visible(!0), this.vLine.points([
11229
+ a,
11230
+ o - s,
11231
+ a,
11232
+ o + s
11233
+ ]), this.vLine.visible(!0), this.dot.x(a), this.dot.y(o), this.dot.visible(!0), this.layer.batchDraw();
11234
+ }
11235
+ };
11236
+ //#endregion
11237
+ //#region src/editor/effects/GhostRoomsEffect.ts
11238
+ function vr(e, t) {
11239
+ let n = e.match(/\d+/g);
11240
+ return !n || n.length < 3 ? `rgba(128, 128, 128, ${t})` : `rgba(${n[0]}, ${n[1]}, ${n[2]}, ${t})`;
11241
+ }
11242
+ var yr = class {
11243
+ rects = /* @__PURE__ */ new Map();
11244
+ layer;
11245
+ unsubscribe;
11246
+ strokeWidth = .06;
11247
+ dash = [.2, .15];
11248
+ constructor(e, t) {
11249
+ this.roomSize = e, this.sceneRef = t;
11250
+ }
11251
+ attach(e) {
11252
+ this.layer = e, this.unsubscribe = D.subscribe((e) => this.sync(e)), this.sync(D.getState());
11253
+ }
11254
+ updateViewport(e, t, n) {
11255
+ this.strokeWidth = Math.max(.03, 2 / t), this.dash = [Math.max(.1, 6 / t), Math.max(.08, 5 / t)], this.rects.forEach((e) => {
11256
+ e.strokeWidth(this.strokeWidth), e.dash([...this.dash]);
11257
+ }), this.layer?.batchDraw();
11258
+ }
11259
+ syncPositions() {
11260
+ this.sync(D.getState());
11261
+ }
11262
+ destroy() {
11263
+ this.unsubscribe?.(), this.rects.forEach((e) => e.destroy()), this.rects.clear();
11264
+ }
11265
+ computePositions(e) {
11266
+ let t = /* @__PURE__ */ new Map(), { selection: n, spreadShrink: r, currentAreaId: i, currentZ: a } = e, o = this.sceneRef.current;
11267
+ if (!r || !n || n.kind !== "room" || !o) return t;
11268
+ let s = [];
11269
+ for (let e of n.ids) {
11270
+ let t = o.getRenderRoom(e);
11271
+ !t || t.z !== a || t.area !== i || s.push({
11272
+ id: e,
11273
+ x: t.x,
11274
+ y: t.y
11275
+ });
11276
+ }
11277
+ if (s.length < 2) return t;
11278
+ let c, l;
11279
+ if (r.centerMode === "anchor" && r.anchorRoomId !== null) {
11280
+ let e = o.getRenderRoom(r.anchorRoomId);
11281
+ c = e ? e.x : s.reduce((e, t) => e + t.x, 0) / s.length, l = e ? e.y : s.reduce((e, t) => e + t.y, 0) / s.length;
11282
+ } else c = s.reduce((e, t) => e + t.x, 0) / s.length, l = s.reduce((e, t) => e + t.y, 0) / s.length;
11283
+ let { factor: u } = r, d = e.snapToGrid ? (t) => Math.round(t / e.gridStep) * e.gridStep : (e) => e;
11284
+ for (let { id: e, x: n, y: r } of s) t.set(e, {
11285
+ x: d(c + (n - c) * u),
11286
+ y: d(l + (r - l) * u)
11287
+ });
11288
+ return t;
11289
+ }
11290
+ sync(e) {
11291
+ if (!this.layer) return;
11292
+ let t = this.sceneRef.current, n = this.computePositions(e);
11293
+ for (let [e, t] of this.rects) n.has(e) || (t.destroy(), this.rects.delete(e));
11294
+ let r = .05, i = this.roomSize + r * 2;
11295
+ for (let [e, a] of n) {
11296
+ let n = t?.getRenderRoom(e), o = t?.reader.getColorValue(n?.env ?? 1) ?? "rgb(128,128,128)", s = vr(o, .2), c = vr(o, .65), l = this.rects.get(e);
11297
+ l || (l = new h.Rect({
11298
+ strokeWidth: this.strokeWidth,
11299
+ dash: [...this.dash],
11300
+ cornerRadius: .04,
11301
+ listening: !1
11302
+ }), this.layer.add(l), this.rects.set(e, l)), l.fill(s), l.stroke(c), l.x(a.x - this.roomSize / 2 - r), l.y(a.y - this.roomSize / 2 - r), l.width(i), l.height(i);
11303
+ }
11304
+ this.layer.batchDraw();
11305
+ }
10950
11306
  };
10951
11307
  //#endregion
10952
11308
  //#region src/editor/pointerController.ts
10953
- function gr(e) {
11309
+ function br(e) {
10954
11310
  let { container: t } = e, n = null, r = null, i = D.getState().spaceHeld, a = D.subscribe((r) => {
10955
11311
  if (!i && r.spaceHeld && n !== null) {
10956
- It[r.activeTool].onCancel?.(e);
11312
+ Ft[r.activeTool].onCancel?.(e);
10957
11313
  try {
10958
11314
  t.releasePointerCapture(n);
10959
11315
  } catch {}
@@ -10971,7 +11327,7 @@ function gr(e) {
10971
11327
  e.renderer.backend.viewport.startDrag(i.clientX - n.left, i.clientY - n.top), r = i.pointerId, t.setPointerCapture(i.pointerId), o(i);
10972
11328
  return;
10973
11329
  }
10974
- let a = D.getState().pending?.kind, l = It[a === "pickSwatch" || a === "pickExit" || a === "pickSpecialExit" ? "select" : s()];
11330
+ let a = D.getState().pending?.kind, l = Ft[a === "pickSwatch" || a === "pickExit" || a === "pickSpecialExit" ? "select" : s()];
10975
11331
  !l.onPointerDown || !c(i) || l.onPointerDown(i, e) && (n = i.pointerId, o(i));
10976
11332
  }, u = (i) => {
10977
11333
  if (r === i.pointerId) {
@@ -10979,7 +11335,7 @@ function gr(e) {
10979
11335
  e.renderer.backend.viewport.updateDrag(i.clientX - n.left, i.clientY - n.top), e.refresh(), o(i);
10980
11336
  return;
10981
11337
  }
10982
- (It[s()].onPointerMove?.(i, e) || n === i.pointerId) && o(i);
11338
+ (Ft[s()].onPointerMove?.(i, e) || n === i.pointerId) && o(i);
10983
11339
  }, d = (i) => {
10984
11340
  if (r === i.pointerId) {
10985
11341
  e.renderer.backend.viewport.endDrag();
@@ -10989,14 +11345,14 @@ function gr(e) {
10989
11345
  r = null, o(i);
10990
11346
  return;
10991
11347
  }
10992
- let a = It[s()].onPointerUp?.(i, e), c = n === i.pointerId;
11348
+ let a = Ft[s()].onPointerUp?.(i, e), c = n === i.pointerId;
10993
11349
  c && (n = null), (a || c) && o(i);
10994
11350
  }, f = (t) => {
10995
11351
  if (r === t.pointerId) {
10996
11352
  e.renderer.backend.viewport.endDrag(), r = null;
10997
11353
  return;
10998
11354
  }
10999
- It[s()].onCancel?.(e), n === t.pointerId && (n = null, o(t));
11355
+ Ft[s()].onCancel?.(e), n === t.pointerId && (n = null, o(t));
11000
11356
  }, p = () => {
11001
11357
  D.getState().hover && D.setState({ hover: null });
11002
11358
  }, m = (e) => {
@@ -11008,7 +11364,7 @@ function gr(e) {
11008
11364
  }, h = (e) => {
11009
11365
  e.button !== 1 && (e.button === 0 || e.button === 2) && s() !== "pan" && o(e);
11010
11366
  }, g = (t) => {
11011
- t.preventDefault(), It[s()].onContextMenu?.(t, e);
11367
+ t.preventDefault(), Ft[s()].onContextMenu?.(t, e);
11012
11368
  }, _ = { capture: !0 };
11013
11369
  return t.addEventListener("pointerdown", l, _), t.addEventListener("pointermove", u, _), t.addEventListener("pointerup", d, _), t.addEventListener("pointercancel", f, _), t.addEventListener("pointerleave", p), t.addEventListener("mousedown", m, _), t.addEventListener("mouseup", h, _), t.addEventListener("contextmenu", g), () => {
11014
11370
  a(), t.removeEventListener("pointerdown", l, _), t.removeEventListener("pointermove", u, _), t.removeEventListener("pointerup", d, _), t.removeEventListener("pointercancel", f, _), t.removeEventListener("pointerleave", p), t.removeEventListener("mousedown", m, _), t.removeEventListener("mouseup", h, _), t.removeEventListener("contextmenu", g);
@@ -11016,17 +11372,17 @@ function gr(e) {
11016
11372
  }
11017
11373
  //#endregion
11018
11374
  //#region src/editor/scene.ts
11019
- function _r(e, t) {
11375
+ function xr(e, t) {
11020
11376
  let n = m();
11021
11377
  n.gridEnabled = !0, n.highlightCurrentRoom = !1, n.areaName = !1, n.labelRenderMode = "image", t.dataset.editorCursor = "true";
11022
- let r = new Gn(e), i = new p(r, n, t), a = { current: null }, o = new pr(), s = new Kn(n.roomSize, a), c = new Zn(n.roomSize, a), l = new er(a), u = new tr(n.roomSize), d = new nr(n.roomSize, a), f = new ar(a), h = new ur(a, n.roomSize), g = new hr(a), _ = new fr(n.gridColor, n.gridLineWidth, n.gridSize, () => {
11378
+ let r = new Kn(e), i = new p(r, n, t), a = { current: null }, o = new mr(), s = new qn(n.roomSize, a), c = new Qn(n.roomSize, a), l = new tr(a), u = new nr(n.roomSize), d = new rr(n.roomSize, a), f = new or(a), h = new dr(a, n.roomSize), g = new gr(a), _ = new _r(a), v = new yr(n.roomSize, a), y = new pr(n.gridColor, n.gridLineWidth, n.gridSize, () => {
11023
11379
  let e = D.getState();
11024
11380
  if (e.currentAreaId == null) return !1;
11025
11381
  let t = r.getArea(e.currentAreaId);
11026
11382
  return t ? t.getRooms().every((t) => t.z !== e.currentZ) : !1;
11027
11383
  }, () => i.backend.viewport.getViewportBounds());
11028
- i.addLiveEffect("editor.marquee", o), i.addLiveEffect("editor.selection", s), i.addLiveEffect("editor.hover", c), i.addLiveEffect("editor.rubberband", l), i.addLiveEffect("editor.snap", u), i.addLiveEffect("editor.connectHandles", d), i.addLiveEffect("editor.customLinePreview", f), i.addLiveEffect("editor.selectedLink", h), i.addLiveEffect("editor.labelHalo", g), i.addLiveEffect("editor.gridOverlay", _);
11029
- let v = {
11384
+ i.addLiveEffect("editor.marquee", o), i.addLiveEffect("editor.selection", s), i.addLiveEffect("editor.hover", c), i.addLiveEffect("editor.rubberband", l), i.addLiveEffect("editor.snap", u), i.addLiveEffect("editor.connectHandles", d), i.addLiveEffect("editor.customLinePreview", f), i.addLiveEffect("editor.selectedLink", h), i.addLiveEffect("editor.labelHalo", g), i.addLiveEffect("editor.selectionCenter", _), i.addLiveEffect("editor.ghostRooms", v), i.addLiveEffect("editor.gridOverlay", y);
11385
+ let b = {
11030
11386
  renderer: i,
11031
11387
  reader: r,
11032
11388
  settings: n,
@@ -11036,36 +11392,36 @@ function _r(e, t) {
11036
11392
  setArea(e, t, n) {
11037
11393
  i.drawArea(e, t);
11038
11394
  let a = r.getArea(e);
11039
- !a || a.getRooms().every((e) => e.z !== t) ? i.backend.viewport.panToMapPoint(0, 0) : i.fitArea(n), _.syncVisibility();
11395
+ !a || a.getRooms().every((e) => e.z !== t) ? i.backend.viewport.panToMapPoint(0, 0) : i.fitArea(n), y.syncVisibility();
11040
11396
  },
11041
11397
  setAreaAt(e, t, n, r) {
11042
- i.drawArea(e, t), i.backend.viewport.panToMapPoint(n, r), _.syncVisibility();
11398
+ i.drawArea(e, t), i.backend.viewport.panToMapPoint(n, r), y.syncVisibility();
11043
11399
  },
11044
11400
  refresh() {
11045
- i.refresh(), s.syncPositions(), g.syncPositions();
11401
+ i.refresh(), s.syncPositions(), g.syncPositions(), _.syncPositions(), v.syncPositions();
11046
11402
  },
11047
11403
  destroy() {
11048
- delete t.dataset.editorCursor, y(), i.removeLiveEffect("editor.selection"), i.removeLiveEffect("editor.hover"), i.removeLiveEffect("editor.rubberband"), i.removeLiveEffect("editor.snap"), i.removeLiveEffect("editor.connectHandles"), o.destroy(), i.removeLiveEffect("editor.marquee"), s.destroy(), c.destroy(), l.destroy(), u.destroy(), d.destroy(), f.destroy(), i.removeLiveEffect("editor.customLinePreview"), h.destroy(), i.removeLiveEffect("editor.selectedLink"), g.destroy(), i.removeLiveEffect("editor.labelHalo"), _.destroy(), i.removeLiveEffect("editor.gridOverlay"), i.destroy();
11404
+ delete t.dataset.editorCursor, x(), i.removeLiveEffect("editor.selection"), i.removeLiveEffect("editor.hover"), i.removeLiveEffect("editor.rubberband"), i.removeLiveEffect("editor.snap"), i.removeLiveEffect("editor.connectHandles"), o.destroy(), i.removeLiveEffect("editor.marquee"), s.destroy(), c.destroy(), l.destroy(), u.destroy(), d.destroy(), f.destroy(), i.removeLiveEffect("editor.customLinePreview"), h.destroy(), i.removeLiveEffect("editor.selectedLink"), g.destroy(), i.removeLiveEffect("editor.labelHalo"), _.destroy(), i.removeLiveEffect("editor.selectionCenter"), v.destroy(), i.removeLiveEffect("editor.ghostRooms"), y.destroy(), i.removeLiveEffect("editor.gridOverlay"), i.destroy();
11049
11405
  }
11050
11406
  };
11051
- a.current = v;
11052
- let y = gr({
11407
+ a.current = b;
11408
+ let x = br({
11053
11409
  renderer: i,
11054
11410
  container: t,
11055
11411
  settings: n,
11056
11412
  refresh: () => i.refresh(),
11057
- scene: v
11413
+ scene: b
11058
11414
  });
11059
- return v;
11415
+ return b;
11060
11416
  }
11061
11417
  //#endregion
11062
11418
  //#region src/App.tsx
11063
- var vr = {
11419
+ var Sr = {
11064
11420
  top: 104,
11065
11421
  right: 464,
11066
11422
  bottom: 24,
11067
11423
  left: 24
11068
- }, yr = {
11424
+ }, Cr = {
11069
11425
  1: "select",
11070
11426
  2: "connect",
11071
11427
  3: "unlink",
@@ -11074,7 +11430,7 @@ var vr = {
11074
11430
  6: "delete",
11075
11431
  7: "pan",
11076
11432
  8: "paint"
11077
- }, br = {
11433
+ }, wr = {
11078
11434
  ArrowLeft: {
11079
11435
  dx: -1,
11080
11436
  dy: 0
@@ -11092,43 +11448,43 @@ var vr = {
11092
11448
  dy: -1
11093
11449
  }
11094
11450
  };
11095
- function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11096
- let s = r(null), c = r(null), l = O((e) => e.map), u = O((e) => e.swatchPaletteOpen), p = l != null, m = O((e) => e.currentAreaId), h = O((e) => e.currentZ), g = O((e) => e.activeTool), _ = O((e) => e.pending), v = O((e) => e.hover), y = O((e) => e.spaceHeld), b = O((e) => e.panelCollapsed), x = O((e) => e.dataVersion), C = O((e) => e.panRequest), [w, T] = i(!1), [E, k] = i(!1), [A, j] = i(!1), [M, N] = i(() => new URLSearchParams(window.location.search).get("map")), P = n(() => a.flatMap((e) => e.swatchSets?.() ?? []), [a]), F = n(() => a.flatMap((e) => e.sidebarTabs?.() ?? []), [a]), I = n(() => a.flatMap((e) => e.roomPanelSections?.() ?? []), [a]);
11451
+ function Tr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11452
+ let s = r(null), c = r(null), l = O((e) => e.map), p = O((e) => e.swatchPaletteOpen), m = l != null, h = O((e) => e.currentAreaId), g = O((e) => e.currentZ), _ = O((e) => e.activeTool), v = O((e) => e.pending), y = O((e) => e.hover), b = O((e) => e.spaceHeld), x = O((e) => e.panelCollapsed), C = O((e) => e.dataVersion), w = O((e) => e.panRequest), [T, E] = i(!1), [k, A] = i(!1), [j, M] = i(!1), [N, P] = i(() => new URLSearchParams(window.location.search).get("map")), F = n(() => a.flatMap((e) => e.swatchSets?.() ?? []), [a]), I = n(() => a.flatMap((e) => e.sidebarTabs?.() ?? []), [a]), L = n(() => a.flatMap((e) => e.roomPanelSections?.() ?? []), [a]);
11097
11453
  t(() => {
11098
- D.setState({ pluginSwatchSets: P });
11099
- }, [P]), t(() => {
11454
+ D.setState({ pluginSwatchSets: F });
11455
+ }, [F]), t(() => {
11100
11456
  a.length !== 0 && (async () => {
11101
11457
  for (let e of a) await e.onAppReady?.();
11102
11458
  })();
11103
11459
  }, []);
11104
- let L = r(l);
11460
+ let R = r(l);
11105
11461
  t(() => {
11106
- let e = L.current;
11107
- if (L.current = l, l && l !== e) for (let e of a) e.onMapOpened?.(l);
11462
+ let e = R.current;
11463
+ if (R.current = l, l && l !== e) for (let e of a) e.onMapOpened?.(l);
11108
11464
  else if (e && !l) for (let e of a) e.onMapClosed?.();
11109
11465
  }, [l]), t(() => {
11110
11466
  if (!l || !s.current) return;
11111
- let e = _r(l, s.current);
11467
+ let e = xr(l, s.current);
11112
11468
  c.current = e;
11113
11469
  let { currentAreaId: t, currentZ: n } = D.getState();
11114
- return t != null && e.setArea(t, n, vr), () => {
11470
+ return t != null && e.setArea(t, n, Sr), () => {
11115
11471
  e.destroy(), c.current = null;
11116
11472
  };
11117
11473
  }, [l]), t(() => {
11118
11474
  let e = c.current;
11119
- if (!e || !p || m == null) return;
11475
+ if (!e || !m || h == null) return;
11120
11476
  let t = D.getState().navigateTo;
11121
- t ? (D.setState({ navigateTo: null }), e.setAreaAt(m, h, t.mapX, t.mapY)) : e.setArea(m, h, vr);
11477
+ t ? (D.setState({ navigateTo: null }), e.setAreaAt(h, g, t.mapX, t.mapY)) : e.setArea(h, g, Sr);
11122
11478
  }, [
11123
- m,
11124
11479
  h,
11125
- p
11480
+ g,
11481
+ m
11126
11482
  ]), t(() => {
11127
- !C || !c.current || (D.setState({ panRequest: null }), c.current.renderer.backend.viewport.panToMapPoint(C.mapX, C.mapY), c.current.refresh());
11128
- }, [C]), t(() => {
11483
+ !w || !c.current || (D.setState({ panRequest: null }), c.current.renderer.backend.viewport.panToMapPoint(w.mapX, w.mapY), c.current.refresh());
11484
+ }, [w]), t(() => {
11129
11485
  let e = s.current;
11130
11486
  if (!e) return;
11131
- if (y) {
11487
+ if (b) {
11132
11488
  let t = () => {
11133
11489
  e.style.cursor = "grabbing";
11134
11490
  }, n = () => {
@@ -11138,12 +11494,12 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11138
11494
  e.removeEventListener("pointerdown", t), e.removeEventListener("pointerup", n), e.removeEventListener("pointercancel", n);
11139
11495
  };
11140
11496
  }
11141
- if (_?.kind === "pickExit" || _?.kind === "pickSpecialExit" || _?.kind === "pickSwatch") {
11497
+ if (v?.kind === "pickExit" || v?.kind === "pickSpecialExit" || v?.kind === "pickSwatch") {
11142
11498
  e.style.cursor = "crosshair";
11143
11499
  return;
11144
11500
  }
11145
11501
  let t = {
11146
- select: v ? "pointer" : "default",
11502
+ select: y ? "pointer" : "default",
11147
11503
  connect: "crosshair",
11148
11504
  unlink: "crosshair",
11149
11505
  addRoom: "crosshair",
@@ -11153,12 +11509,12 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11153
11509
  addLabel: "crosshair",
11154
11510
  paint: "cell"
11155
11511
  };
11156
- e.style.cursor = t[g];
11512
+ e.style.cursor = t[_];
11157
11513
  }, [
11158
- g,
11159
- v,
11514
+ _,
11160
11515
  y,
11161
- _
11516
+ b,
11517
+ v
11162
11518
  ]), t(() => {
11163
11519
  let { map: e, loaded: t, undo: n, currentAreaId: r, currentZ: i, sessionId: a } = D.getState();
11164
11520
  if (!e || !t) return;
@@ -11168,7 +11524,7 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11168
11524
  }).catch(console.error);
11169
11525
  }, 1500);
11170
11526
  return () => clearTimeout(o);
11171
- }, [x]), t(() => {
11527
+ }, [C]), t(() => {
11172
11528
  let e = (e) => {
11173
11529
  let t = e?.tagName;
11174
11530
  return t === "INPUT" || t === "TEXTAREA" || t === "SELECT";
@@ -11183,7 +11539,7 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11183
11539
  return;
11184
11540
  }
11185
11541
  if ((t.ctrlKey || t.metaKey) && t.key.toLowerCase() === "f") {
11186
- t.preventDefault(), j((e) => !e);
11542
+ t.preventDefault(), M((e) => !e);
11187
11543
  return;
11188
11544
  }
11189
11545
  if ((t.ctrlKey || t.metaKey) && !t.shiftKey && t.key.toLowerCase() === "z") {
@@ -11196,12 +11552,12 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11196
11552
  }
11197
11553
  if (t.key === "Enter") {
11198
11554
  let e = D.getState();
11199
- e.pending?.kind === "customLine" && At(e.pending);
11555
+ e.pending?.kind === "customLine" && kt(e.pending);
11200
11556
  return;
11201
11557
  }
11202
11558
  if (t.key === "Escape") {
11203
11559
  let e = D.getState();
11204
- e.pending ? (e.pending.kind === "customLine" && c.current && kt(e.pending, c.current), D.setState({
11560
+ e.pending ? (e.pending.kind === "customLine" && c.current && Ot(e.pending, c.current), D.setState({
11205
11561
  pending: null,
11206
11562
  activeTool: e.pending.kind === "customLine" ? "select" : e.activeTool,
11207
11563
  status: "Cancelled."
@@ -11209,7 +11565,7 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11209
11565
  return;
11210
11566
  }
11211
11567
  if (t.key === "Delete" || t.key === "Backspace") {
11212
- R();
11568
+ ee();
11213
11569
  return;
11214
11570
  }
11215
11571
  if (t.key === "g" || t.key === "G") {
@@ -11217,13 +11573,13 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11217
11573
  return;
11218
11574
  }
11219
11575
  if (t.key === "f" || t.key === "F") {
11220
- c.current?.renderer.fitArea(vr);
11576
+ c.current?.renderer.fitArea(Sr);
11221
11577
  return;
11222
11578
  }
11223
- if (yr[t.key]) {
11579
+ if (Cr[t.key]) {
11224
11580
  let e = D.getState();
11225
- e.pending?.kind === "customLine" && c.current && (kt(e.pending, c.current), D.bumpData()), D.setState({
11226
- activeTool: yr[t.key],
11581
+ e.pending?.kind === "customLine" && c.current && (Ot(e.pending, c.current), D.bumpData()), D.setState({
11582
+ activeTool: Cr[t.key],
11227
11583
  pending: null
11228
11584
  });
11229
11585
  return;
@@ -11239,14 +11595,14 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11239
11595
  } });
11240
11596
  return;
11241
11597
  }
11242
- if (br[t.key]) {
11598
+ if (wr[t.key]) {
11243
11599
  let e = D.getState();
11244
11600
  if (e.activeTool !== "select" || !e.selection || !e.map) return;
11245
11601
  if (e.selection.kind === "label") {
11246
11602
  let { id: n, areaId: r } = e.selection, i = c.current?.reader.getLabelSnapshot(r, n);
11247
11603
  if (!i) return;
11248
11604
  t.preventDefault();
11249
- let a = (t.shiftKey ? 5 : 1) * e.gridStep, o = br[t.key], s = o.dx * a, l = o.dy * a, u = [...i.pos], d = [
11605
+ let a = (t.shiftKey ? 5 : 1) * e.gridStep, o = wr[t.key], s = o.dx * a, l = o.dy * a, u = [...i.pos], d = [
11250
11606
  i.pos[0] + s,
11251
11607
  i.pos[1] + l,
11252
11608
  i.pos[2]
@@ -11265,7 +11621,7 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11265
11621
  }
11266
11622
  if (e.selection.kind !== "room") return;
11267
11623
  t.preventDefault();
11268
- let n = (t.shiftKey ? 5 : 1) * e.gridStep, r = br[t.key], i = r.dx * n, a = r.dy * n, o = [];
11624
+ let n = (t.shiftKey ? 5 : 1) * e.gridStep, r = wr[t.key], i = r.dx * n, a = r.dy * n, o = [];
11269
11625
  for (let t of e.selection.ids) {
11270
11626
  let n = e.map.rooms[t];
11271
11627
  if (!n) continue;
@@ -11273,7 +11629,7 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11273
11629
  x: n.x,
11274
11630
  y: n.y,
11275
11631
  z: n.z
11276
- }, s = Ae(e.map, t, i, a);
11632
+ }, s = ke(e.map, t, i, a);
11277
11633
  c.current?.reader.moveRoom(t, n.x + i, -(n.y + a), n.z);
11278
11634
  let l = {
11279
11635
  x: n.x,
@@ -11303,7 +11659,7 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11303
11659
  }
11304
11660
  };
11305
11661
  window.addEventListener("keydown", r), window.addEventListener("keyup", t), window.addEventListener("blur", n);
11306
- let i = () => c.current?.renderer.fitArea(vr);
11662
+ let i = () => c.current?.renderer.fitArea(Sr);
11307
11663
  return window.addEventListener("editor:undo", z), window.addEventListener("editor:redo", B), window.addEventListener("editor:fit", i), () => {
11308
11664
  window.removeEventListener("keydown", r), window.removeEventListener("keyup", t), window.removeEventListener("blur", n), window.removeEventListener("editor:undo", z), window.removeEventListener("editor:redo", B), window.removeEventListener("editor:fit", i);
11309
11665
  };
@@ -11319,7 +11675,7 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11319
11675
  window.removeEventListener("dragover", e), window.removeEventListener("drop", t);
11320
11676
  };
11321
11677
  }, []);
11322
- let R = () => {
11678
+ let ee = () => {
11323
11679
  let e = D.getState();
11324
11680
  if (!e.map) return;
11325
11681
  let t = e.selection;
@@ -11327,7 +11683,7 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11327
11683
  if (t.kind === "room") {
11328
11684
  if (e.currentAreaId == null) return;
11329
11685
  if (t.ids.length > 1) {
11330
- let n = Me(e.map, t.ids), r = [];
11686
+ let n = je(e.map, t.ids), r = [];
11331
11687
  for (let i of t.ids) {
11332
11688
  let t = e.map.rooms[i];
11333
11689
  t && r.push({
@@ -11350,7 +11706,7 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11350
11706
  }
11351
11707
  let n = t.ids[0], r = e.map.rooms[n];
11352
11708
  if (!r) return;
11353
- let i = { ...r }, a = je(e.map, n);
11709
+ let i = { ...r }, a = Ae(e.map, n);
11354
11710
  Y({
11355
11711
  kind: "deleteRoom",
11356
11712
  id: n,
@@ -11465,14 +11821,14 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11465
11821
  }
11466
11822
  }
11467
11823
  }, z = () => {
11468
- let { changed: e, structural: t } = Oe(c.current);
11824
+ let { changed: e, structural: t } = De(c.current);
11469
11825
  e && (c.current?.refresh(), t ? D.bumpStructure() : D.bumpData(), D.setState({ status: "Undone" }));
11470
11826
  }, B = () => {
11471
- let { changed: e, structural: t } = ke(c.current);
11827
+ let { changed: e, structural: t } = Oe(c.current);
11472
11828
  e && (c.current?.refresh(), t ? D.bumpStructure() : D.bumpData(), D.setState({ status: "Redone" }));
11473
11829
  };
11474
11830
  return /* @__PURE__ */ f("div", {
11475
- className: `app${b ? " panel-collapsed" : ""}`,
11831
+ className: `app${x ? " panel-collapsed" : ""}`,
11476
11832
  children: [
11477
11833
  /* @__PURE__ */ f("div", {
11478
11834
  className: "map-viewport",
@@ -11481,32 +11837,40 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11481
11837
  ref: s,
11482
11838
  className: "map-container"
11483
11839
  }),
11484
- !p && /* @__PURE__ */ d(kn, {}),
11840
+ !m && /* @__PURE__ */ d(kn, {}),
11485
11841
  /* @__PURE__ */ d(ue, {
11486
11842
  title: o,
11487
- onHelpClick: () => T(!0),
11488
- onLoadFromUrl: () => k(!0),
11843
+ onHelpClick: () => E(!0),
11844
+ onLoadFromUrl: () => A(!0),
11489
11845
  onSave: (e) => {
11490
11846
  for (let t of a) t.onMapSave?.(e);
11491
11847
  },
11492
- onSearchClick: () => j((e) => !e)
11848
+ onSearchClick: () => M((e) => !e)
11493
11849
  }),
11494
- /* @__PURE__ */ d(mn, {
11850
+ /* @__PURE__ */ d(pn, {
11495
11851
  sceneRef: c,
11496
- extraTabs: F,
11497
- pluginRoomSections: I
11852
+ extraTabs: I,
11853
+ pluginRoomSections: L
11498
11854
  })
11499
11855
  ]
11500
11856
  }),
11501
- /* @__PURE__ */ d(hn, { sceneRef: c }),
11502
- u && /* @__PURE__ */ d(An, { sceneRef: c }),
11857
+ /* @__PURE__ */ d(mn, { sceneRef: c }),
11858
+ p && /* @__PURE__ */ d(An, { sceneRef: c }),
11503
11859
  a.map((t, n) => /* @__PURE__ */ d(e, { children: t.renderOverlay?.() }, n)),
11504
- A && p && /* @__PURE__ */ d(Mn, { onClose: () => j(!1) }),
11505
- w && /* @__PURE__ */ d(le, { onClose: () => T(!1) }),
11506
- (E || M) && /* @__PURE__ */ d(de, {
11507
- initialUrl: M ?? void 0,
11860
+ j && m && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("div", {
11861
+ style: {
11862
+ position: "fixed",
11863
+ inset: 0,
11864
+ zIndex: 399
11865
+ },
11866
+ onMouseDown: () => M(!1)
11867
+ }), /* @__PURE__ */ d(Mn, { onClose: () => M(!1) })] }),
11868
+ /* @__PURE__ */ d(Nn, { sceneRef: c }),
11869
+ T && /* @__PURE__ */ d(le, { onClose: () => E(!1) }),
11870
+ (k || N) && /* @__PURE__ */ d(de, {
11871
+ initialUrl: N ?? void 0,
11508
11872
  onClose: () => {
11509
- k(!1), N(null);
11873
+ A(!1), P(null);
11510
11874
  }
11511
11875
  })
11512
11876
  ]
@@ -11514,9 +11878,9 @@ function xr({ plugins: a = [], title: o = "Mudlet Map Editor" }) {
11514
11878
  }
11515
11879
  //#endregion
11516
11880
  //#region src/editor/mapBytes.ts
11517
- function Sr() {
11881
+ function Er() {
11518
11882
  let { map: e } = D.getState();
11519
- return e ? U(e) : null;
11883
+ return e ? H(e) : null;
11520
11884
  }
11521
11885
  //#endregion
11522
- export { xr as App, Sr as getMapBytes, ie as loadUrlIntoStore, Y as pushCommand, D as store, O as useEditorState };
11886
+ export { Tr as App, Er as getMapBytes, G as loadUrlIntoStore, Y as pushCommand, D as store, O as useEditorState };