@kubohiroya/turbowarp-bubble 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4317 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
3
+ if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
4
+ get: ((e) => i[e]).bind(null, d),
5
+ enumerable: !(s = n(i, d)) || s.enumerable
6
+ });
7
+ return e;
8
+ }, c = (n, r, o) => (o = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule || !a.call(n, "default") ? t(o, "default", {
9
+ value: n,
10
+ enumerable: !0
11
+ }) : o, n)), l = [
12
+ "up",
13
+ "up-up-right",
14
+ "up-right",
15
+ "right-up-right",
16
+ "right",
17
+ "right-down-right",
18
+ "down-right",
19
+ "down-down-right",
20
+ "down",
21
+ "down-down-left",
22
+ "down-left",
23
+ "left-down-left",
24
+ "left",
25
+ "left-up-left",
26
+ "up-left",
27
+ "up-up-left"
28
+ ], u = [
29
+ "north",
30
+ "north-northeast",
31
+ "northeast",
32
+ "east-northeast",
33
+ "east",
34
+ "east-southeast",
35
+ "southeast",
36
+ "south-southeast",
37
+ "south",
38
+ "south-southwest",
39
+ "southwest",
40
+ "west-southwest",
41
+ "west",
42
+ "west-northwest",
43
+ "northwest",
44
+ "north-northwest"
45
+ ], d = [
46
+ "HEADER_LIKE",
47
+ "CENTER",
48
+ "FOOTER_LIKE"
49
+ ], f = "up-right", p = /* @__PURE__ */ new Map([
50
+ ["east", "right"],
51
+ ["east-northeast", "right-up-right"],
52
+ ["east-southeast", "right-down-right"],
53
+ ["north", "up"],
54
+ ["northeast", "up-right"],
55
+ ["north-northeast", "up-up-right"],
56
+ ["northwest", "up-left"],
57
+ ["north-northwest", "up-up-left"],
58
+ ["south", "down"],
59
+ ["southeast", "down-right"],
60
+ ["south-southeast", "down-down-right"],
61
+ ["southwest", "down-left"],
62
+ ["south-southwest", "down-down-left"],
63
+ ["west", "left"],
64
+ ["west-northwest", "left-up-left"],
65
+ ["west-southwest", "left-down-left"]
66
+ ]), m = new Set(l), h = new Set(d), g = Math.SQRT2 - 1, _ = Object.freeze({
67
+ down: {
68
+ x: 0,
69
+ y: -1
70
+ },
71
+ "down-down-left": {
72
+ x: -g,
73
+ y: -1
74
+ },
75
+ "down-down-right": {
76
+ x: g,
77
+ y: -1
78
+ },
79
+ "down-left": {
80
+ x: -1,
81
+ y: -1
82
+ },
83
+ "down-right": {
84
+ x: 1,
85
+ y: -1
86
+ },
87
+ left: {
88
+ x: -1,
89
+ y: 0
90
+ },
91
+ "left-down-left": {
92
+ x: -1,
93
+ y: -g
94
+ },
95
+ "left-up-left": {
96
+ x: -1,
97
+ y: g
98
+ },
99
+ right: {
100
+ x: 1,
101
+ y: 0
102
+ },
103
+ "right-down-right": {
104
+ x: 1,
105
+ y: -g
106
+ },
107
+ "right-up-right": {
108
+ x: 1,
109
+ y: g
110
+ },
111
+ up: {
112
+ x: 0,
113
+ y: 1
114
+ },
115
+ "up-left": {
116
+ x: -1,
117
+ y: 1
118
+ },
119
+ "up-right": {
120
+ x: 1,
121
+ y: 1
122
+ },
123
+ "up-up-left": {
124
+ x: -g,
125
+ y: 1
126
+ },
127
+ "up-up-right": {
128
+ x: g,
129
+ y: 1
130
+ }
131
+ });
132
+ function v(e) {
133
+ return Math.abs(e) < 1e-12 ? 0 : Math.abs(1 - Math.abs(e)) < 1e-12 ? Math.sign(e) : e;
134
+ }
135
+ function y(e) {
136
+ if (typeof e == "number") {
137
+ if (!Number.isFinite(e) || e < 0 || e > 360) throw TypeError("Bubble placement angle must be from 0 through 360.");
138
+ return Object.freeze({
139
+ basis: "actor",
140
+ direction: e === 360 ? 0 : e
141
+ });
142
+ }
143
+ if (typeof e != "string" || e.trim().length === 0) throw TypeError("Bubble placement must be a direction, angle, or region.");
144
+ let t = e.trim(), n = t.toUpperCase();
145
+ if (h.has(n)) return Object.freeze({
146
+ basis: "background",
147
+ region: n
148
+ });
149
+ let r = t.toLowerCase();
150
+ if (m.has(r)) return Object.freeze({
151
+ basis: "actor",
152
+ direction: r
153
+ });
154
+ let i = p.get(r);
155
+ if (i) return Object.freeze({
156
+ basis: "actor",
157
+ direction: i
158
+ });
159
+ let a = Number(t);
160
+ if (Number.isFinite(a) && a >= 0 && a <= 360) return Object.freeze({
161
+ basis: "actor",
162
+ direction: a === 360 ? 0 : a
163
+ });
164
+ throw TypeError("Bubble placement is invalid.");
165
+ }
166
+ function b(e) {
167
+ if (typeof e == "string") return _[e];
168
+ let t = e * Math.PI / 180;
169
+ return Object.freeze({
170
+ x: v(Math.sin(t)),
171
+ y: v(Math.cos(t))
172
+ });
173
+ }
174
+ //#endregion
175
+ //#region src/actor-transform.ts
176
+ var ee = 12, x = 18, te = Object.freeze({
177
+ x: 0,
178
+ y: 0,
179
+ scalePercent: 100
180
+ });
181
+ function S(e, t) {
182
+ if (typeof e != "number" || !Number.isFinite(e)) throw TypeError(`${t} must be a finite number.`);
183
+ return e;
184
+ }
185
+ function C(e) {
186
+ let t = S(e, "Bubble distance");
187
+ if (t < 0) throw TypeError("Bubble distance must be zero or greater.");
188
+ return t;
189
+ }
190
+ function ne(e) {
191
+ let t = S(e, "Bubble tail length");
192
+ if (t <= 0) throw TypeError("Bubble tail length must be greater than zero.");
193
+ return t;
194
+ }
195
+ function w(e) {
196
+ if (!Array.isArray(e) || e.length !== 2 && e.length !== 3) throw TypeError("Bubble offset must be [x, y] or [x, y, scale].");
197
+ let t = S(e[0], "Bubble offset x"), n = S(e[1], "Bubble offset y"), r = S(e.length === 3 ? e[2] : 100, "Bubble offset scale");
198
+ if (r <= 0) throw TypeError("Bubble offset scale must be greater than zero.");
199
+ return Object.freeze({
200
+ x: t,
201
+ y: n,
202
+ scalePercent: r
203
+ });
204
+ }
205
+ function re(e) {
206
+ let t = (e.bounds.left + e.bounds.right) / 2, n = (e.bounds.top + e.bounds.bottom) / 2, r = b(e.direction), i = e.distance + e.tailLength, a = r.x < 0 ? t - e.bounds.left + i + e.bubbleWidth / 2 : e.bounds.right - t + i + e.bubbleWidth / 2, o = r.y < 0 ? n - e.bounds.bottom + i + e.bubbleHeight / 2 : e.bounds.top - n + i + e.bubbleHeight / 2, s = Math.min(r.x === 0 ? Infinity : a / Math.abs(r.x), r.y === 0 ? Infinity : o / Math.abs(r.y));
207
+ return Object.freeze({
208
+ x: t + r.x * s + e.offset.x,
209
+ y: n + r.y * s + e.offset.y
210
+ });
211
+ }
212
+ //#endregion
213
+ //#region node_modules/.pnpm/jsclipper@https+++codeload.github.com+platener+jsclipper+tar.gz+56aed19845113e1939d8971c47233054659436b1/node_modules/jsclipper/jsclipper.js
214
+ var ie = /* @__PURE__ */ o(((e, t) => {
215
+ (function() {
216
+ var e = {}, n = !1;
217
+ t !== void 0 && t.exports ? (t.exports = e, n = !0) : typeof document < "u" ? window.ClipperLib = e : self.ClipperLib = e;
218
+ var r;
219
+ if (n) {
220
+ var i = "chrome";
221
+ r = "Netscape";
222
+ } else {
223
+ var i = navigator.userAgent.toString().toLowerCase();
224
+ r = navigator.appName;
225
+ }
226
+ var a = {};
227
+ a.chrome = +(i.indexOf("chrome") != -1 && i.indexOf("chromium") == -1), a.chromium = i.indexOf("chromium") == -1 ? 0 : 1, a.safari = +(i.indexOf("safari") != -1 && i.indexOf("chrome") == -1 && i.indexOf("chromium") == -1), a.firefox = i.indexOf("firefox") == -1 ? 0 : 1, a.firefox17 = i.indexOf("firefox/17") == -1 ? 0 : 1, a.firefox15 = i.indexOf("firefox/15") == -1 ? 0 : 1, a.firefox3 = i.indexOf("firefox/3") == -1 ? 0 : 1, a.opera = i.indexOf("opera") == -1 ? 0 : 1, a.msie10 = i.indexOf("msie 10") == -1 ? 0 : 1, a.msie9 = i.indexOf("msie 9") == -1 ? 0 : 1, a.msie8 = i.indexOf("msie 8") == -1 ? 0 : 1, a.msie7 = i.indexOf("msie 7") == -1 ? 0 : 1, a.msie = i.indexOf("msie ") == -1 ? 0 : 1, e.biginteger_used = null;
228
+ var o, s = !0;
229
+ function c(t, n, r) {
230
+ e.biginteger_used = 1, t != null && (typeof t == "number" && n === void 0 ? this.fromInt(t) : typeof t == "number" ? this.fromNumber(t, n, r) : n == null && typeof t != "string" ? this.fromString(t, 256) : this.fromString(t, n));
231
+ }
232
+ function l() {
233
+ return new c(null);
234
+ }
235
+ function u(e, t, n, r, i, a) {
236
+ for (; --a >= 0;) {
237
+ var o = t * this[e++] + n[r] + i;
238
+ i = Math.floor(o / 67108864), n[r++] = o & 67108863;
239
+ }
240
+ return i;
241
+ }
242
+ function d(e, t, n, r, i, a) {
243
+ for (var o = t & 32767, s = t >> 15; --a >= 0;) {
244
+ var c = this[e] & 32767, l = this[e++] >> 15, u = s * c + l * o;
245
+ c = o * c + ((u & 32767) << 15) + n[r] + (i & 1073741823), i = (c >>> 30) + (u >>> 15) + s * l + (i >>> 30), n[r++] = c & 1073741823;
246
+ }
247
+ return i;
248
+ }
249
+ function f(e, t, n, r, i, a) {
250
+ for (var o = t & 16383, s = t >> 14; --a >= 0;) {
251
+ var c = this[e] & 16383, l = this[e++] >> 14, u = s * c + l * o;
252
+ c = o * c + ((u & 16383) << 14) + n[r] + i, i = (c >> 28) + (u >> 14) + s * l, n[r++] = c & 268435455;
253
+ }
254
+ return i;
255
+ }
256
+ s && r == "Microsoft Internet Explorer" ? (c.prototype.am = d, o = 30) : s && r != "Netscape" ? (c.prototype.am = u, o = 26) : (c.prototype.am = f, o = 28), c.prototype.DB = o, c.prototype.DM = (1 << o) - 1, c.prototype.DV = 1 << o;
257
+ var p = 52;
258
+ c.prototype.FV = 2 ** p, c.prototype.F1 = p - o, c.prototype.F2 = 2 * o - p;
259
+ var m = "0123456789abcdefghijklmnopqrstuvwxyz", h = [], g = 48, _;
260
+ for (_ = 0; _ <= 9; ++_) h[g++] = _;
261
+ for (g = 97, _ = 10; _ < 36; ++_) h[g++] = _;
262
+ for (g = 65, _ = 10; _ < 36; ++_) h[g++] = _;
263
+ function v(e) {
264
+ return m.charAt(e);
265
+ }
266
+ function y(e, t) {
267
+ return h[e.charCodeAt(t)] ?? -1;
268
+ }
269
+ function b(e) {
270
+ for (var t = this.t - 1; t >= 0; --t) e[t] = this[t];
271
+ e.t = this.t, e.s = this.s;
272
+ }
273
+ function ee(e) {
274
+ this.t = 1, this.s = e < 0 ? -1 : 0, e > 0 ? this[0] = e : e < -1 ? this[0] = e + this.DV : this.t = 0;
275
+ }
276
+ function x(e) {
277
+ var t = l();
278
+ return t.fromInt(e), t;
279
+ }
280
+ function te(e, t) {
281
+ var n;
282
+ if (t == 16) n = 4;
283
+ else if (t == 8) n = 3;
284
+ else if (t == 256) n = 8;
285
+ else if (t == 2) n = 1;
286
+ else if (t == 32) n = 5;
287
+ else if (t == 4) n = 2;
288
+ else {
289
+ this.fromRadix(e, t);
290
+ return;
291
+ }
292
+ this.t = 0, this.s = 0;
293
+ for (var r = e.length, i = !1, a = 0; --r >= 0;) {
294
+ var o = n == 8 ? e[r] & 255 : y(e, r);
295
+ if (o < 0) {
296
+ e.charAt(r) == "-" && (i = !0);
297
+ continue;
298
+ }
299
+ i = !1, a == 0 ? this[this.t++] = o : a + n > this.DB ? (this[this.t - 1] |= (o & (1 << this.DB - a) - 1) << a, this[this.t++] = o >> this.DB - a) : this[this.t - 1] |= o << a, a += n, a >= this.DB && (a -= this.DB);
300
+ }
301
+ n == 8 && e[0] & 128 && (this.s = -1, a > 0 && (this[this.t - 1] |= (1 << this.DB - a) - 1 << a)), this.clamp(), i && c.ZERO.subTo(this, this);
302
+ }
303
+ function S() {
304
+ for (var e = this.s & this.DM; this.t > 0 && this[this.t - 1] == e;) --this.t;
305
+ }
306
+ function C(e) {
307
+ if (this.s < 0) return "-" + this.negate().toString(e);
308
+ var t;
309
+ if (e == 16) t = 4;
310
+ else if (e == 8) t = 3;
311
+ else if (e == 2) t = 1;
312
+ else if (e == 32) t = 5;
313
+ else if (e == 4) t = 2;
314
+ else return this.toRadix(e);
315
+ var n = (1 << t) - 1, r, i = !1, a = "", o = this.t, s = this.DB - o * this.DB % t;
316
+ if (o-- > 0) for (s < this.DB && (r = this[o] >> s) > 0 && (i = !0, a = v(r)); o >= 0;) s < t ? (r = (this[o] & (1 << s) - 1) << t - s, r |= this[--o] >> (s += this.DB - t)) : (r = this[o] >> (s -= t) & n, s <= 0 && (s += this.DB, --o)), r > 0 && (i = !0), i && (a += v(r));
317
+ return i ? a : "0";
318
+ }
319
+ function ne() {
320
+ var e = l();
321
+ return c.ZERO.subTo(this, e), e;
322
+ }
323
+ function w() {
324
+ return this.s < 0 ? this.negate() : this;
325
+ }
326
+ function re(e) {
327
+ var t = this.s - e.s;
328
+ if (t != 0) return t;
329
+ var n = this.t;
330
+ if (t = n - e.t, t != 0) return this.s < 0 ? -t : t;
331
+ for (; --n >= 0;) if ((t = this[n] - e[n]) != 0) return t;
332
+ return 0;
333
+ }
334
+ function ie(e) {
335
+ var t = 1, n;
336
+ return (n = e >>> 16) != 0 && (e = n, t += 16), (n = e >> 8) != 0 && (e = n, t += 8), (n = e >> 4) != 0 && (e = n, t += 4), (n = e >> 2) != 0 && (e = n, t += 2), (n = e >> 1) != 0 && (e = n, t += 1), t;
337
+ }
338
+ function ae() {
339
+ return this.t <= 0 ? 0 : this.DB * (this.t - 1) + ie(this[this.t - 1] ^ this.s & this.DM);
340
+ }
341
+ function oe(e, t) {
342
+ var n;
343
+ for (n = this.t - 1; n >= 0; --n) t[n + e] = this[n];
344
+ for (n = e - 1; n >= 0; --n) t[n] = 0;
345
+ t.t = this.t + e, t.s = this.s;
346
+ }
347
+ function T(e, t) {
348
+ for (var n = e; n < this.t; ++n) t[n - e] = this[n];
349
+ t.t = Math.max(this.t - e, 0), t.s = this.s;
350
+ }
351
+ function E(e, t) {
352
+ var n = e % this.DB, r = this.DB - n, i = (1 << r) - 1, a = Math.floor(e / this.DB), o = this.s << n & this.DM, s;
353
+ for (s = this.t - 1; s >= 0; --s) t[s + a + 1] = this[s] >> r | o, o = (this[s] & i) << n;
354
+ for (s = a - 1; s >= 0; --s) t[s] = 0;
355
+ t[a] = o, t.t = this.t + a + 1, t.s = this.s, t.clamp();
356
+ }
357
+ function se(e, t) {
358
+ t.s = this.s;
359
+ var n = Math.floor(e / this.DB);
360
+ if (n >= this.t) {
361
+ t.t = 0;
362
+ return;
363
+ }
364
+ var r = e % this.DB, i = this.DB - r, a = (1 << r) - 1;
365
+ t[0] = this[n] >> r;
366
+ for (var o = n + 1; o < this.t; ++o) t[o - n - 1] |= (this[o] & a) << i, t[o - n] = this[o] >> r;
367
+ r > 0 && (t[this.t - n - 1] |= (this.s & a) << i), t.t = this.t - n, t.clamp();
368
+ }
369
+ function D(e, t) {
370
+ for (var n = 0, r = 0, i = Math.min(e.t, this.t); n < i;) r += this[n] - e[n], t[n++] = r & this.DM, r >>= this.DB;
371
+ if (e.t < this.t) {
372
+ for (r -= e.s; n < this.t;) r += this[n], t[n++] = r & this.DM, r >>= this.DB;
373
+ r += this.s;
374
+ } else {
375
+ for (r += this.s; n < e.t;) r -= e[n], t[n++] = r & this.DM, r >>= this.DB;
376
+ r -= e.s;
377
+ }
378
+ t.s = r < 0 ? -1 : 0, r < -1 ? t[n++] = this.DV + r : r > 0 && (t[n++] = r), t.t = n, t.clamp();
379
+ }
380
+ function ce(e, t) {
381
+ var n = this.abs(), r = e.abs(), i = n.t;
382
+ for (t.t = i + r.t; --i >= 0;) t[i] = 0;
383
+ for (i = 0; i < r.t; ++i) t[i + n.t] = n.am(0, r[i], t, i, 0, n.t);
384
+ t.s = 0, t.clamp(), this.s != e.s && c.ZERO.subTo(t, t);
385
+ }
386
+ function le(e) {
387
+ for (var t = this.abs(), n = e.t = 2 * t.t; --n >= 0;) e[n] = 0;
388
+ for (n = 0; n < t.t - 1; ++n) {
389
+ var r = t.am(n, t[n], e, 2 * n, 0, 1);
390
+ (e[n + t.t] += t.am(n + 1, 2 * t[n], e, 2 * n + 1, r, t.t - n - 1)) >= t.DV && (e[n + t.t] -= t.DV, e[n + t.t + 1] = 1);
391
+ }
392
+ e.t > 0 && (e[e.t - 1] += t.am(n, t[n], e, 2 * n, 0, 1)), e.s = 0, e.clamp();
393
+ }
394
+ function ue(e, t, n) {
395
+ var r = e.abs();
396
+ if (!(r.t <= 0)) {
397
+ var i = this.abs();
398
+ if (i.t < r.t) {
399
+ t?.fromInt(0), n != null && this.copyTo(n);
400
+ return;
401
+ }
402
+ n ??= l();
403
+ var a = l(), o = this.s, s = e.s, u = this.DB - ie(r[r.t - 1]);
404
+ u > 0 ? (r.lShiftTo(u, a), i.lShiftTo(u, n)) : (r.copyTo(a), i.copyTo(n));
405
+ var d = a.t, f = a[d - 1];
406
+ if (f != 0) {
407
+ var p = f * (1 << this.F1) + (d > 1 ? a[d - 2] >> this.F2 : 0), m = this.FV / p, h = (1 << this.F1) / p, g = 1 << this.F2, _ = n.t, v = _ - d, y = t ?? l();
408
+ for (a.dlShiftTo(v, y), n.compareTo(y) >= 0 && (n[n.t++] = 1, n.subTo(y, n)), c.ONE.dlShiftTo(d, y), y.subTo(a, a); a.t < d;) a[a.t++] = 0;
409
+ for (; --v >= 0;) {
410
+ var b = n[--_] == f ? this.DM : Math.floor(n[_] * m + (n[_ - 1] + g) * h);
411
+ if ((n[_] += a.am(0, b, n, v, 0, d)) < b) for (a.dlShiftTo(v, y), n.subTo(y, n); n[_] < --b;) n.subTo(y, n);
412
+ }
413
+ t != null && (n.drShiftTo(d, t), o != s && c.ZERO.subTo(t, t)), n.t = d, n.clamp(), u > 0 && n.rShiftTo(u, n), o < 0 && c.ZERO.subTo(n, n);
414
+ }
415
+ }
416
+ }
417
+ function O(e) {
418
+ var t = l();
419
+ return this.abs().divRemTo(e, null, t), this.s < 0 && t.compareTo(c.ZERO) > 0 && e.subTo(t, t), t;
420
+ }
421
+ function k(e) {
422
+ this.m = e;
423
+ }
424
+ function A(e) {
425
+ return e.s < 0 || e.compareTo(this.m) >= 0 ? e.mod(this.m) : e;
426
+ }
427
+ function de(e) {
428
+ return e;
429
+ }
430
+ function fe(e) {
431
+ e.divRemTo(this.m, null, e);
432
+ }
433
+ function pe(e, t, n) {
434
+ e.multiplyTo(t, n), this.reduce(n);
435
+ }
436
+ function me(e, t) {
437
+ e.squareTo(t), this.reduce(t);
438
+ }
439
+ k.prototype.convert = A, k.prototype.revert = de, k.prototype.reduce = fe, k.prototype.mulTo = pe, k.prototype.sqrTo = me;
440
+ function he() {
441
+ if (this.t < 1) return 0;
442
+ var e = this[0];
443
+ if (!(e & 1)) return 0;
444
+ var t = e & 3;
445
+ return t = t * (2 - (e & 15) * t) & 15, t = t * (2 - (e & 255) * t) & 255, t = t * (2 - ((e & 65535) * t & 65535)) & 65535, t = t * (2 - e * t % this.DV) % this.DV, t > 0 ? this.DV - t : -t;
446
+ }
447
+ function j(e) {
448
+ this.m = e, this.mp = e.invDigit(), this.mpl = this.mp & 32767, this.mph = this.mp >> 15, this.um = (1 << e.DB - 15) - 1, this.mt2 = 2 * e.t;
449
+ }
450
+ function ge(e) {
451
+ var t = l();
452
+ return e.abs().dlShiftTo(this.m.t, t), t.divRemTo(this.m, null, t), e.s < 0 && t.compareTo(c.ZERO) > 0 && this.m.subTo(t, t), t;
453
+ }
454
+ function _e(e) {
455
+ var t = l();
456
+ return e.copyTo(t), this.reduce(t), t;
457
+ }
458
+ function ve(e) {
459
+ for (; e.t <= this.mt2;) e[e.t++] = 0;
460
+ for (var t = 0; t < this.m.t; ++t) {
461
+ var n = e[t] & 32767, r = n * this.mpl + ((n * this.mph + (e[t] >> 15) * this.mpl & this.um) << 15) & e.DM;
462
+ for (n = t + this.m.t, e[n] += this.m.am(0, r, e, t, 0, this.m.t); e[n] >= e.DV;) e[n] -= e.DV, e[++n]++;
463
+ }
464
+ e.clamp(), e.drShiftTo(this.m.t, e), e.compareTo(this.m) >= 0 && e.subTo(this.m, e);
465
+ }
466
+ function ye(e, t) {
467
+ e.squareTo(t), this.reduce(t);
468
+ }
469
+ function be(e, t, n) {
470
+ e.multiplyTo(t, n), this.reduce(n);
471
+ }
472
+ j.prototype.convert = ge, j.prototype.revert = _e, j.prototype.reduce = ve, j.prototype.mulTo = be, j.prototype.sqrTo = ye;
473
+ function xe() {
474
+ return (this.t > 0 ? this[0] & 1 : this.s) == 0;
475
+ }
476
+ function Se(e, t) {
477
+ if (e > 4294967295 || e < 1) return c.ONE;
478
+ var n = l(), r = l(), i = t.convert(this), a = ie(e) - 1;
479
+ for (i.copyTo(n); --a >= 0;) if (t.sqrTo(n, r), (e & 1 << a) > 0) t.mulTo(r, i, n);
480
+ else {
481
+ var o = n;
482
+ n = r, r = o;
483
+ }
484
+ return t.revert(n);
485
+ }
486
+ function Ce(e, t) {
487
+ var n = e < 256 || t.isEven() ? new k(t) : new j(t);
488
+ return this.exp(e, n);
489
+ }
490
+ c.prototype.copyTo = b, c.prototype.fromInt = ee, c.prototype.fromString = te, c.prototype.clamp = S, c.prototype.dlShiftTo = oe, c.prototype.drShiftTo = T, c.prototype.lShiftTo = E, c.prototype.rShiftTo = se, c.prototype.subTo = D, c.prototype.multiplyTo = ce, c.prototype.squareTo = le, c.prototype.divRemTo = ue, c.prototype.invDigit = he, c.prototype.isEven = xe, c.prototype.exp = Se, c.prototype.toString = C, c.prototype.negate = ne, c.prototype.abs = w, c.prototype.compareTo = re, c.prototype.bitLength = ae, c.prototype.mod = O, c.prototype.modPowInt = Ce, c.ZERO = x(0), c.ONE = x(1);
491
+ function we() {
492
+ var e = l();
493
+ return this.copyTo(e), e;
494
+ }
495
+ function Te() {
496
+ if (this.s < 0) {
497
+ if (this.t == 1) return this[0] - this.DV;
498
+ if (this.t == 0) return -1;
499
+ } else if (this.t == 1) return this[0];
500
+ else if (this.t == 0) return 0;
501
+ return (this[1] & (1 << 32 - this.DB) - 1) << this.DB | this[0];
502
+ }
503
+ function Ee() {
504
+ return this.t == 0 ? this.s : this[0] << 24 >> 24;
505
+ }
506
+ function De() {
507
+ return this.t == 0 ? this.s : this[0] << 16 >> 16;
508
+ }
509
+ function Oe(e) {
510
+ return Math.floor(Math.LN2 * this.DB / Math.log(e));
511
+ }
512
+ function ke() {
513
+ return this.s < 0 ? -1 : this.t <= 0 || this.t == 1 && this[0] <= 0 ? 0 : 1;
514
+ }
515
+ function M(e) {
516
+ if (e ??= 10, this.signum() == 0 || e < 2 || e > 36) return "0";
517
+ var t = this.chunkSize(e), n = e ** +t, r = x(n), i = l(), a = l(), o = "";
518
+ for (this.divRemTo(r, i, a); i.signum() > 0;) o = (n + a.intValue()).toString(e).substr(1) + o, i.divRemTo(r, i, a);
519
+ return a.intValue().toString(e) + o;
520
+ }
521
+ function N(e, t) {
522
+ this.fromInt(0), t ??= 10;
523
+ for (var n = this.chunkSize(t), r = t ** +n, i = !1, a = 0, o = 0, s = 0; s < e.length; ++s) {
524
+ var l = y(e, s);
525
+ if (l < 0) {
526
+ e.charAt(s) == "-" && this.signum() == 0 && (i = !0);
527
+ continue;
528
+ }
529
+ o = t * o + l, ++a >= n && (this.dMultiply(r), this.dAddOffset(o, 0), a = 0, o = 0);
530
+ }
531
+ a > 0 && (this.dMultiply(t ** +a), this.dAddOffset(o, 0)), i && c.ZERO.subTo(this, this);
532
+ }
533
+ function Ae(e, t, n) {
534
+ if (typeof t == "number") {
535
+ if (e < 2) this.fromInt(1);
536
+ else for (this.fromNumber(e, n), this.testBit(e - 1) || this.bitwiseTo(c.ONE.shiftLeft(e - 1), Re, this), this.isEven() && this.dAddOffset(1, 0); !this.isProbablePrime(t);) this.dAddOffset(2, 0), this.bitLength() > e && this.subTo(c.ONE.shiftLeft(e - 1), this);
537
+ } else {
538
+ var r = [], i = e & 7;
539
+ r.length = (e >> 3) + 1, t.nextBytes(r), i > 0 ? r[0] &= (1 << i) - 1 : r[0] = 0, this.fromString(r, 256);
540
+ }
541
+ }
542
+ function je() {
543
+ var e = this.t, t = [];
544
+ t[0] = this.s;
545
+ var n = this.DB - e * this.DB % 8, r, i = 0;
546
+ if (e-- > 0) for (n < this.DB && (r = this[e] >> n) != (this.s & this.DM) >> n && (t[i++] = r | this.s << this.DB - n); e >= 0;) n < 8 ? (r = (this[e] & (1 << n) - 1) << 8 - n, r |= this[--e] >> (n += this.DB - 8)) : (r = this[e] >> (n -= 8) & 255, n <= 0 && (n += this.DB, --e)), r & 128 && (r |= -256), i == 0 && (this.s & 128) != (r & 128) && ++i, (i > 0 || r != this.s) && (t[i++] = r);
547
+ return t;
548
+ }
549
+ function Me(e) {
550
+ return this.compareTo(e) == 0;
551
+ }
552
+ function Ne(e) {
553
+ return this.compareTo(e) < 0 ? this : e;
554
+ }
555
+ function Pe(e) {
556
+ return this.compareTo(e) > 0 ? this : e;
557
+ }
558
+ function Fe(e, t, n) {
559
+ var r, i, a = Math.min(e.t, this.t);
560
+ for (r = 0; r < a; ++r) n[r] = t(this[r], e[r]);
561
+ if (e.t < this.t) {
562
+ for (i = e.s & this.DM, r = a; r < this.t; ++r) n[r] = t(this[r], i);
563
+ n.t = this.t;
564
+ } else {
565
+ for (i = this.s & this.DM, r = a; r < e.t; ++r) n[r] = t(i, e[r]);
566
+ n.t = e.t;
567
+ }
568
+ n.s = t(this.s, e.s), n.clamp();
569
+ }
570
+ function Ie(e, t) {
571
+ return e & t;
572
+ }
573
+ function Le(e) {
574
+ var t = l();
575
+ return this.bitwiseTo(e, Ie, t), t;
576
+ }
577
+ function Re(e, t) {
578
+ return e | t;
579
+ }
580
+ function ze(e) {
581
+ var t = l();
582
+ return this.bitwiseTo(e, Re, t), t;
583
+ }
584
+ function Be(e, t) {
585
+ return e ^ t;
586
+ }
587
+ function P(e) {
588
+ var t = l();
589
+ return this.bitwiseTo(e, Be, t), t;
590
+ }
591
+ function F(e, t) {
592
+ return e & ~t;
593
+ }
594
+ function Ve(e) {
595
+ var t = l();
596
+ return this.bitwiseTo(e, F, t), t;
597
+ }
598
+ function He() {
599
+ for (var e = l(), t = 0; t < this.t; ++t) e[t] = this.DM & ~this[t];
600
+ return e.t = this.t, e.s = ~this.s, e;
601
+ }
602
+ function Ue(e) {
603
+ var t = l();
604
+ return e < 0 ? this.rShiftTo(-e, t) : this.lShiftTo(e, t), t;
605
+ }
606
+ function We(e) {
607
+ var t = l();
608
+ return e < 0 ? this.lShiftTo(-e, t) : this.rShiftTo(e, t), t;
609
+ }
610
+ function Ge(e) {
611
+ if (e == 0) return -1;
612
+ var t = 0;
613
+ return e & 65535 || (e >>= 16, t += 16), e & 255 || (e >>= 8, t += 8), e & 15 || (e >>= 4, t += 4), e & 3 || (e >>= 2, t += 2), e & 1 || ++t, t;
614
+ }
615
+ function Ke() {
616
+ for (var e = 0; e < this.t; ++e) if (this[e] != 0) return e * this.DB + Ge(this[e]);
617
+ return this.s < 0 ? this.t * this.DB : -1;
618
+ }
619
+ function I(e) {
620
+ for (var t = 0; e != 0;) e &= e - 1, ++t;
621
+ return t;
622
+ }
623
+ function qe() {
624
+ for (var e = 0, t = this.s & this.DM, n = 0; n < this.t; ++n) e += I(this[n] ^ t);
625
+ return e;
626
+ }
627
+ function Je(e) {
628
+ var t = Math.floor(e / this.DB);
629
+ return t >= this.t ? this.s != 0 : !!(this[t] & 1 << e % this.DB);
630
+ }
631
+ function Ye(e, t) {
632
+ var n = c.ONE.shiftLeft(e);
633
+ return this.bitwiseTo(n, t, n), n;
634
+ }
635
+ function Xe(e) {
636
+ return this.changeBit(e, Re);
637
+ }
638
+ function L(e) {
639
+ return this.changeBit(e, F);
640
+ }
641
+ function Ze(e) {
642
+ return this.changeBit(e, Be);
643
+ }
644
+ function Qe(e, t) {
645
+ for (var n = 0, r = 0, i = Math.min(e.t, this.t); n < i;) r += this[n] + e[n], t[n++] = r & this.DM, r >>= this.DB;
646
+ if (e.t < this.t) {
647
+ for (r += e.s; n < this.t;) r += this[n], t[n++] = r & this.DM, r >>= this.DB;
648
+ r += this.s;
649
+ } else {
650
+ for (r += this.s; n < e.t;) r += e[n], t[n++] = r & this.DM, r >>= this.DB;
651
+ r += e.s;
652
+ }
653
+ t.s = r < 0 ? -1 : 0, r > 0 ? t[n++] = r : r < -1 && (t[n++] = this.DV + r), t.t = n, t.clamp();
654
+ }
655
+ function $e(e) {
656
+ var t = l();
657
+ return this.addTo(e, t), t;
658
+ }
659
+ function et(e) {
660
+ var t = l();
661
+ return this.subTo(e, t), t;
662
+ }
663
+ function tt(e) {
664
+ var t = l();
665
+ return this.multiplyTo(e, t), t;
666
+ }
667
+ function nt() {
668
+ var e = l();
669
+ return this.squareTo(e), e;
670
+ }
671
+ function rt(e) {
672
+ var t = l();
673
+ return this.divRemTo(e, t, null), t;
674
+ }
675
+ function it(e) {
676
+ var t = l();
677
+ return this.divRemTo(e, null, t), t;
678
+ }
679
+ function at(e) {
680
+ var t = l(), n = l();
681
+ return this.divRemTo(e, t, n), [t, n];
682
+ }
683
+ function ot(e) {
684
+ this[this.t] = this.am(0, e - 1, this, 0, 0, this.t), ++this.t, this.clamp();
685
+ }
686
+ function st(e, t) {
687
+ if (e != 0) {
688
+ for (; this.t <= t;) this[this.t++] = 0;
689
+ for (this[t] += e; this[t] >= this.DV;) this[t] -= this.DV, ++t >= this.t && (this[this.t++] = 0), ++this[t];
690
+ }
691
+ }
692
+ function R() {}
693
+ function ct(e) {
694
+ return e;
695
+ }
696
+ function lt(e, t, n) {
697
+ e.multiplyTo(t, n);
698
+ }
699
+ function ut(e, t) {
700
+ e.squareTo(t);
701
+ }
702
+ R.prototype.convert = ct, R.prototype.revert = ct, R.prototype.mulTo = lt, R.prototype.sqrTo = ut;
703
+ function dt(e) {
704
+ return this.exp(e, new R());
705
+ }
706
+ function ft(e, t, n) {
707
+ var r = Math.min(this.t + e.t, t);
708
+ for (n.s = 0, n.t = r; r > 0;) n[--r] = 0;
709
+ var i;
710
+ for (i = n.t - this.t; r < i; ++r) n[r + this.t] = this.am(0, e[r], n, r, 0, this.t);
711
+ for (i = Math.min(e.t, t); r < i; ++r) this.am(0, e[r], n, r, 0, t - r);
712
+ n.clamp();
713
+ }
714
+ function pt(e, t, n) {
715
+ --t;
716
+ var r = n.t = this.t + e.t - t;
717
+ for (n.s = 0; --r >= 0;) n[r] = 0;
718
+ for (r = Math.max(t - this.t, 0); r < e.t; ++r) n[this.t + r - t] = this.am(t - r, e[r], n, 0, 0, this.t + r - t);
719
+ n.clamp(), n.drShiftTo(1, n);
720
+ }
721
+ function z(e) {
722
+ this.r2 = l(), this.q3 = l(), c.ONE.dlShiftTo(2 * e.t, this.r2), this.mu = this.r2.divide(e), this.m = e;
723
+ }
724
+ function mt(e) {
725
+ if (e.s < 0 || e.t > 2 * this.m.t) return e.mod(this.m);
726
+ if (e.compareTo(this.m) < 0) return e;
727
+ var t = l();
728
+ return e.copyTo(t), this.reduce(t), t;
729
+ }
730
+ function ht(e) {
731
+ return e;
732
+ }
733
+ function gt(e) {
734
+ for (e.drShiftTo(this.m.t - 1, this.r2), e.t > this.m.t + 1 && (e.t = this.m.t + 1, e.clamp()), this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3), this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2); e.compareTo(this.r2) < 0;) e.dAddOffset(1, this.m.t + 1);
735
+ for (e.subTo(this.r2, e); e.compareTo(this.m) >= 0;) e.subTo(this.m, e);
736
+ }
737
+ function _t(e, t) {
738
+ e.squareTo(t), this.reduce(t);
739
+ }
740
+ function vt(e, t, n) {
741
+ e.multiplyTo(t, n), this.reduce(n);
742
+ }
743
+ z.prototype.convert = mt, z.prototype.revert = ht, z.prototype.reduce = gt, z.prototype.mulTo = vt, z.prototype.sqrTo = _t;
744
+ function yt(e, t) {
745
+ var n = e.bitLength(), r, i = x(1), a;
746
+ if (n <= 0) return i;
747
+ r = n < 18 ? 1 : n < 48 ? 3 : n < 144 ? 4 : n < 768 ? 5 : 6, a = n < 8 ? new k(t) : t.isEven() ? new z(t) : new j(t);
748
+ var o = [], s = 3, c = r - 1, u = (1 << r) - 1;
749
+ if (o[1] = a.convert(this), r > 1) {
750
+ var d = l();
751
+ for (a.sqrTo(o[1], d); s <= u;) o[s] = l(), a.mulTo(d, o[s - 2], o[s]), s += 2;
752
+ }
753
+ var f = e.t - 1, p, m = !0, h = l(), g;
754
+ for (n = ie(e[f]) - 1; f >= 0;) {
755
+ for (n >= c ? p = e[f] >> n - c & u : (p = (e[f] & (1 << n + 1) - 1) << c - n, f > 0 && (p |= e[f - 1] >> this.DB + n - c)), s = r; !(p & 1);) p >>= 1, --s;
756
+ if ((n -= s) < 0 && (n += this.DB, --f), m) o[p].copyTo(i), m = !1;
757
+ else {
758
+ for (; s > 1;) a.sqrTo(i, h), a.sqrTo(h, i), s -= 2;
759
+ s > 0 ? a.sqrTo(i, h) : (g = i, i = h, h = g), a.mulTo(h, o[p], i);
760
+ }
761
+ for (; f >= 0 && !(e[f] & 1 << n);) a.sqrTo(i, h), g = i, i = h, h = g, --n < 0 && (n = this.DB - 1, --f);
762
+ }
763
+ return a.revert(i);
764
+ }
765
+ function bt(e) {
766
+ var t = this.s < 0 ? this.negate() : this.clone(), n = e.s < 0 ? e.negate() : e.clone();
767
+ if (t.compareTo(n) < 0) {
768
+ var r = t;
769
+ t = n, n = r;
770
+ }
771
+ var i = t.getLowestSetBit(), a = n.getLowestSetBit();
772
+ if (a < 0) return t;
773
+ for (i < a && (a = i), a > 0 && (t.rShiftTo(a, t), n.rShiftTo(a, n)); t.signum() > 0;) (i = t.getLowestSetBit()) > 0 && t.rShiftTo(i, t), (i = n.getLowestSetBit()) > 0 && n.rShiftTo(i, n), t.compareTo(n) >= 0 ? (t.subTo(n, t), t.rShiftTo(1, t)) : (n.subTo(t, n), n.rShiftTo(1, n));
774
+ return a > 0 && n.lShiftTo(a, n), n;
775
+ }
776
+ function B(e) {
777
+ if (e <= 0) return 0;
778
+ var t = this.DV % e, n = this.s < 0 ? e - 1 : 0;
779
+ if (this.t > 0) {
780
+ if (t == 0) n = this[0] % e;
781
+ else for (var r = this.t - 1; r >= 0; --r) n = (t * n + this[r]) % e;
782
+ }
783
+ return n;
784
+ }
785
+ function xt(e) {
786
+ var t = e.isEven();
787
+ if (this.isEven() && t || e.signum() == 0) return c.ZERO;
788
+ for (var n = e.clone(), r = this.clone(), i = x(1), a = x(0), o = x(0), s = x(1); n.signum() != 0;) {
789
+ for (; n.isEven();) n.rShiftTo(1, n), t ? ((!i.isEven() || !a.isEven()) && (i.addTo(this, i), a.subTo(e, a)), i.rShiftTo(1, i)) : a.isEven() || a.subTo(e, a), a.rShiftTo(1, a);
790
+ for (; r.isEven();) r.rShiftTo(1, r), t ? ((!o.isEven() || !s.isEven()) && (o.addTo(this, o), s.subTo(e, s)), o.rShiftTo(1, o)) : s.isEven() || s.subTo(e, s), s.rShiftTo(1, s);
791
+ n.compareTo(r) >= 0 ? (n.subTo(r, n), t && i.subTo(o, i), a.subTo(s, a)) : (r.subTo(n, r), t && o.subTo(i, o), s.subTo(a, s));
792
+ }
793
+ if (r.compareTo(c.ONE) != 0) return c.ZERO;
794
+ if (s.compareTo(e) >= 0) return s.subtract(e);
795
+ if (s.signum() < 0) s.addTo(e, s);
796
+ else return s;
797
+ return s.signum() < 0 ? s.add(e) : s;
798
+ }
799
+ var V = [
800
+ 2,
801
+ 3,
802
+ 5,
803
+ 7,
804
+ 11,
805
+ 13,
806
+ 17,
807
+ 19,
808
+ 23,
809
+ 29,
810
+ 31,
811
+ 37,
812
+ 41,
813
+ 43,
814
+ 47,
815
+ 53,
816
+ 59,
817
+ 61,
818
+ 67,
819
+ 71,
820
+ 73,
821
+ 79,
822
+ 83,
823
+ 89,
824
+ 97,
825
+ 101,
826
+ 103,
827
+ 107,
828
+ 109,
829
+ 113,
830
+ 127,
831
+ 131,
832
+ 137,
833
+ 139,
834
+ 149,
835
+ 151,
836
+ 157,
837
+ 163,
838
+ 167,
839
+ 173,
840
+ 179,
841
+ 181,
842
+ 191,
843
+ 193,
844
+ 197,
845
+ 199,
846
+ 211,
847
+ 223,
848
+ 227,
849
+ 229,
850
+ 233,
851
+ 239,
852
+ 241,
853
+ 251,
854
+ 257,
855
+ 263,
856
+ 269,
857
+ 271,
858
+ 277,
859
+ 281,
860
+ 283,
861
+ 293,
862
+ 307,
863
+ 311,
864
+ 313,
865
+ 317,
866
+ 331,
867
+ 337,
868
+ 347,
869
+ 349,
870
+ 353,
871
+ 359,
872
+ 367,
873
+ 373,
874
+ 379,
875
+ 383,
876
+ 389,
877
+ 397,
878
+ 401,
879
+ 409,
880
+ 419,
881
+ 421,
882
+ 431,
883
+ 433,
884
+ 439,
885
+ 443,
886
+ 449,
887
+ 457,
888
+ 461,
889
+ 463,
890
+ 467,
891
+ 479,
892
+ 487,
893
+ 491,
894
+ 499,
895
+ 503,
896
+ 509,
897
+ 521,
898
+ 523,
899
+ 541,
900
+ 547,
901
+ 557,
902
+ 563,
903
+ 569,
904
+ 571,
905
+ 577,
906
+ 587,
907
+ 593,
908
+ 599,
909
+ 601,
910
+ 607,
911
+ 613,
912
+ 617,
913
+ 619,
914
+ 631,
915
+ 641,
916
+ 643,
917
+ 647,
918
+ 653,
919
+ 659,
920
+ 661,
921
+ 673,
922
+ 677,
923
+ 683,
924
+ 691,
925
+ 701,
926
+ 709,
927
+ 719,
928
+ 727,
929
+ 733,
930
+ 739,
931
+ 743,
932
+ 751,
933
+ 757,
934
+ 761,
935
+ 769,
936
+ 773,
937
+ 787,
938
+ 797,
939
+ 809,
940
+ 811,
941
+ 821,
942
+ 823,
943
+ 827,
944
+ 829,
945
+ 839,
946
+ 853,
947
+ 857,
948
+ 859,
949
+ 863,
950
+ 877,
951
+ 881,
952
+ 883,
953
+ 887,
954
+ 907,
955
+ 911,
956
+ 919,
957
+ 929,
958
+ 937,
959
+ 941,
960
+ 947,
961
+ 953,
962
+ 967,
963
+ 971,
964
+ 977,
965
+ 983,
966
+ 991,
967
+ 997
968
+ ], H = (1 << 26) / V[V.length - 1];
969
+ function St(e) {
970
+ var t, n = this.abs();
971
+ if (n.t == 1 && n[0] <= V[V.length - 1]) {
972
+ for (t = 0; t < V.length; ++t) if (n[0] == V[t]) return !0;
973
+ return !1;
974
+ }
975
+ if (n.isEven()) return !1;
976
+ for (t = 1; t < V.length;) {
977
+ for (var r = V[t], i = t + 1; i < V.length && r < H;) r *= V[i++];
978
+ for (r = n.modInt(r); t < i;) if (r % V[t++] == 0) return !1;
979
+ }
980
+ return n.millerRabin(e);
981
+ }
982
+ function Ct(e) {
983
+ var t = this.subtract(c.ONE), n = t.getLowestSetBit();
984
+ if (n <= 0) return !1;
985
+ var r = t.shiftRight(n);
986
+ e = e + 1 >> 1, e > V.length && (e = V.length);
987
+ for (var i = l(), a = 0; a < e; ++a) {
988
+ i.fromInt(V[Math.floor(Math.random() * V.length)]);
989
+ var o = i.modPow(r, this);
990
+ if (o.compareTo(c.ONE) != 0 && o.compareTo(t) != 0) {
991
+ for (var s = 1; s++ < n && o.compareTo(t) != 0;) if (o = o.modPowInt(2, this), o.compareTo(c.ONE) == 0) return !1;
992
+ if (o.compareTo(t) != 0) return !1;
993
+ }
994
+ }
995
+ return !0;
996
+ }
997
+ c.prototype.chunkSize = Oe, c.prototype.toRadix = M, c.prototype.fromRadix = N, c.prototype.fromNumber = Ae, c.prototype.bitwiseTo = Fe, c.prototype.changeBit = Ye, c.prototype.addTo = Qe, c.prototype.dMultiply = ot, c.prototype.dAddOffset = st, c.prototype.multiplyLowerTo = ft, c.prototype.multiplyUpperTo = pt, c.prototype.modInt = B, c.prototype.millerRabin = Ct, c.prototype.clone = we, c.prototype.intValue = Te, c.prototype.byteValue = Ee, c.prototype.shortValue = De, c.prototype.signum = ke, c.prototype.toByteArray = je, c.prototype.equals = Me, c.prototype.min = Ne, c.prototype.max = Pe, c.prototype.and = Le, c.prototype.or = ze, c.prototype.xor = P, c.prototype.andNot = Ve, c.prototype.not = He, c.prototype.shiftLeft = Ue, c.prototype.shiftRight = We, c.prototype.getLowestSetBit = Ke, c.prototype.bitCount = qe, c.prototype.testBit = Je, c.prototype.setBit = Xe, c.prototype.clearBit = L, c.prototype.flipBit = Ze, c.prototype.add = $e, c.prototype.subtract = et, c.prototype.multiply = tt, c.prototype.divide = rt, c.prototype.remainder = it, c.prototype.divideAndRemainder = at, c.prototype.modPow = yt, c.prototype.modInverse = xt, c.prototype.pow = dt, c.prototype.gcd = bt, c.prototype.isProbablePrime = St, c.prototype.square = nt;
998
+ var U = c;
999
+ if (U.prototype.IsNegative = function() {
1000
+ return this.compareTo(U.ZERO) == -1;
1001
+ }, U.op_Equality = function(e, t) {
1002
+ return e.compareTo(t) == 0;
1003
+ }, U.op_Inequality = function(e, t) {
1004
+ return e.compareTo(t) != 0;
1005
+ }, U.op_GreaterThan = function(e, t) {
1006
+ return e.compareTo(t) > 0;
1007
+ }, U.op_LessThan = function(e, t) {
1008
+ return e.compareTo(t) < 0;
1009
+ }, U.op_Addition = function(e, t) {
1010
+ return new U(e).add(new U(t));
1011
+ }, U.op_Subtraction = function(e, t) {
1012
+ return new U(e).subtract(new U(t));
1013
+ }, U.Int128Mul = function(e, t) {
1014
+ return new U(e).multiply(new U(t));
1015
+ }, U.op_Division = function(e, t) {
1016
+ return e.divide(t);
1017
+ }, U.prototype.ToDouble = function() {
1018
+ return parseFloat(this.toString());
1019
+ }, wt === void 0) var wt = function(e, t) {
1020
+ var n;
1021
+ if (Object.getOwnPropertyNames === void 0) {
1022
+ for (n in t.prototype) (e.prototype[n] === void 0 || e.prototype[n] == Object.prototype[n]) && (e.prototype[n] = t.prototype[n]);
1023
+ for (n in t) e[n] === void 0 && (e[n] = t[n]);
1024
+ e.$baseCtor = t;
1025
+ } else {
1026
+ for (var r = Object.getOwnPropertyNames(t.prototype), i = 0; i < r.length; i++) Object.getOwnPropertyDescriptor(e.prototype, r[i]) === void 0 && Object.defineProperty(e.prototype, r[i], Object.getOwnPropertyDescriptor(t.prototype, r[i]));
1027
+ for (n in t) e[n] === void 0 && (e[n] = t[n]);
1028
+ e.$baseCtor = t;
1029
+ }
1030
+ };
1031
+ e.Path = function() {
1032
+ return [];
1033
+ }, e.Paths = function() {
1034
+ return [];
1035
+ }, e.DoublePoint = function() {
1036
+ var e = arguments;
1037
+ this.X = 0, this.Y = 0, e.length == 1 ? (this.X = e[0].X, this.Y = e[0].Y) : e.length == 2 && (this.X = e[0], this.Y = e[1]);
1038
+ }, e.DoublePoint0 = function() {
1039
+ this.X = 0, this.Y = 0;
1040
+ }, e.DoublePoint1 = function(e) {
1041
+ this.X = e.X, this.Y = e.Y;
1042
+ }, e.DoublePoint2 = function(e, t) {
1043
+ this.X = e, this.Y = t;
1044
+ }, e.PolyNode = function() {
1045
+ this.m_Parent = null, this.m_polygon = new e.Path(), this.m_Index = 0, this.m_jointype = 0, this.m_endtype = 0, this.m_Childs = [], this.IsOpen = !1;
1046
+ }, e.PolyNode.prototype.IsHoleNode = function() {
1047
+ for (var e = !0, t = this.m_Parent; t !== null;) e = !e, t = t.m_Parent;
1048
+ return e;
1049
+ }, e.PolyNode.prototype.ChildCount = function() {
1050
+ return this.m_Childs.length;
1051
+ }, e.PolyNode.prototype.Contour = function() {
1052
+ return this.m_polygon;
1053
+ }, e.PolyNode.prototype.AddChild = function(e) {
1054
+ var t = this.m_Childs.length;
1055
+ this.m_Childs.push(e), e.m_Parent = this, e.m_Index = t;
1056
+ }, e.PolyNode.prototype.GetNext = function() {
1057
+ return this.m_Childs.length > 0 ? this.m_Childs[0] : this.GetNextSiblingUp();
1058
+ }, e.PolyNode.prototype.GetNextSiblingUp = function() {
1059
+ return this.m_Parent === null ? null : this.m_Index == this.m_Parent.m_Childs.length - 1 ? this.m_Parent.GetNextSiblingUp() : this.m_Parent.m_Childs[this.m_Index + 1];
1060
+ }, e.PolyNode.prototype.Childs = function() {
1061
+ return this.m_Childs;
1062
+ }, e.PolyNode.prototype.Parent = function() {
1063
+ return this.m_Parent;
1064
+ }, e.PolyNode.prototype.IsHole = function() {
1065
+ return this.IsHoleNode();
1066
+ }, e.PolyTree = function() {
1067
+ this.m_AllPolys = [], e.PolyNode.call(this);
1068
+ }, e.PolyTree.prototype.Clear = function() {
1069
+ for (var e = 0, t = this.m_AllPolys.length; e < t; e++) this.m_AllPolys[e] = null;
1070
+ this.m_AllPolys.length = 0, this.m_Childs.length = 0;
1071
+ }, e.PolyTree.prototype.GetFirst = function() {
1072
+ return this.m_Childs.length > 0 ? this.m_Childs[0] : null;
1073
+ }, e.PolyTree.prototype.Total = function() {
1074
+ return this.m_AllPolys.length;
1075
+ }, wt(e.PolyTree, e.PolyNode), e.Math_Abs_Int64 = e.Math_Abs_Int32 = e.Math_Abs_Double = function(e) {
1076
+ return Math.abs(e);
1077
+ }, e.Math_Max_Int32_Int32 = function(e, t) {
1078
+ return Math.max(e, t);
1079
+ }, e.Cast_Int32 = a.msie || a.opera || a.safari ? function(e) {
1080
+ return e | 0;
1081
+ } : function(e) {
1082
+ return ~~e;
1083
+ }, e.Cast_Int64 = a.chrome ? function(e) {
1084
+ return e < -2147483648 || e > 2147483647 ? e < 0 ? Math.ceil(e) : Math.floor(e) : ~~e;
1085
+ } : a.firefox && typeof Number.toInteger == "function" ? function(e) {
1086
+ return Number.toInteger(e);
1087
+ } : a.msie7 || a.msie8 ? function(e) {
1088
+ return parseInt(e, 10);
1089
+ } : a.msie ? function(e) {
1090
+ return e < -2147483648 || e > 2147483647 ? e < 0 ? Math.ceil(e) : Math.floor(e) : e | 0;
1091
+ } : function(e) {
1092
+ return e < 0 ? Math.ceil(e) : Math.floor(e);
1093
+ }, e.Clear = function(e) {
1094
+ e.length = 0;
1095
+ }, e.PI = 3.141592653589793, e.PI2 = 6.283185307179586, e.IntPoint = function() {
1096
+ var t = arguments, n = t.length;
1097
+ if (this.X = 0, this.Y = 0, 0) var r, i;
1098
+ else if (n == 2) this.X = t[0], this.Y = t[1];
1099
+ else if (n == 1) {
1100
+ if (t[0] instanceof e.DoublePoint) {
1101
+ var r = t[0];
1102
+ this.X = e.Clipper.Round(r.X), this.Y = e.Clipper.Round(r.Y);
1103
+ } else {
1104
+ var i = t[0];
1105
+ this.X = i.X, this.Y = i.Y;
1106
+ }
1107
+ } else this.X = 0, this.Y = 0;
1108
+ }, e.IntPoint.op_Equality = function(e, t) {
1109
+ return e.X == t.X && e.Y == t.Y;
1110
+ }, e.IntPoint.op_Inequality = function(e, t) {
1111
+ return e.X != t.X || e.Y != t.Y;
1112
+ }, e.IntPoint0 = function() {
1113
+ this.X = 0, this.Y = 0;
1114
+ }, e.IntPoint1 = function(e) {
1115
+ this.X = e.X, this.Y = e.Y;
1116
+ }, e.IntPoint1dp = function(t) {
1117
+ this.X = e.Clipper.Round(t.X), this.Y = e.Clipper.Round(t.Y);
1118
+ }, e.IntPoint2 = function(e, t) {
1119
+ this.X = e, this.Y = t;
1120
+ }, e.IntRect = function() {
1121
+ var e = arguments, t = e.length;
1122
+ t == 4 ? (this.left = e[0], this.top = e[1], this.right = e[2], this.bottom = e[3]) : t == 1 ? (this.left = ir.left, this.top = ir.top, this.right = ir.right, this.bottom = ir.bottom) : (this.left = 0, this.top = 0, this.right = 0, this.bottom = 0);
1123
+ }, e.IntRect0 = function() {
1124
+ this.left = 0, this.top = 0, this.right = 0, this.bottom = 0;
1125
+ }, e.IntRect1 = function(e) {
1126
+ this.left = e.left, this.top = e.top, this.right = e.right, this.bottom = e.bottom;
1127
+ }, e.IntRect4 = function(e, t, n, r) {
1128
+ this.left = e, this.top = t, this.right = n, this.bottom = r;
1129
+ }, e.ClipType = {
1130
+ ctIntersection: 0,
1131
+ ctUnion: 1,
1132
+ ctDifference: 2,
1133
+ ctXor: 3
1134
+ }, e.PolyType = {
1135
+ ptSubject: 0,
1136
+ ptClip: 1
1137
+ }, e.PolyFillType = {
1138
+ pftEvenOdd: 0,
1139
+ pftNonZero: 1,
1140
+ pftPositive: 2,
1141
+ pftNegative: 3
1142
+ }, e.JoinType = {
1143
+ jtSquare: 0,
1144
+ jtRound: 1,
1145
+ jtMiter: 2
1146
+ }, e.EndType = {
1147
+ etOpenSquare: 0,
1148
+ etOpenRound: 1,
1149
+ etOpenButt: 2,
1150
+ etClosedLine: 3,
1151
+ etClosedPolygon: 4
1152
+ }, e.EdgeSide = {
1153
+ esLeft: 0,
1154
+ esRight: 1
1155
+ }, e.Direction = {
1156
+ dRightToLeft: 0,
1157
+ dLeftToRight: 1
1158
+ }, e.TEdge = function() {
1159
+ this.Bot = new e.IntPoint(), this.Curr = new e.IntPoint(), this.Top = new e.IntPoint(), this.Delta = new e.IntPoint(), this.Dx = 0, this.PolyTyp = e.PolyType.ptSubject, this.Side = e.EdgeSide.esLeft, this.WindDelta = 0, this.WindCnt = 0, this.WindCnt2 = 0, this.OutIdx = 0, this.Next = null, this.Prev = null, this.NextInLML = null, this.NextInAEL = null, this.PrevInAEL = null, this.NextInSEL = null, this.PrevInSEL = null;
1160
+ }, e.IntersectNode = function() {
1161
+ this.Edge1 = null, this.Edge2 = null, this.Pt = new e.IntPoint();
1162
+ }, e.MyIntersectNodeSort = function() {}, e.MyIntersectNodeSort.Compare = function(e, t) {
1163
+ return t.Pt.Y - e.Pt.Y;
1164
+ }, e.LocalMinima = function() {
1165
+ this.Y = 0, this.LeftBound = null, this.RightBound = null, this.Next = null;
1166
+ }, e.Scanbeam = function() {
1167
+ this.Y = 0, this.Next = null;
1168
+ }, e.OutRec = function() {
1169
+ this.Idx = 0, this.IsHole = !1, this.IsOpen = !1, this.FirstLeft = null, this.Pts = null, this.BottomPt = null, this.PolyNode = null;
1170
+ }, e.OutPt = function() {
1171
+ this.Idx = 0, this.Pt = new e.IntPoint(), this.Next = null, this.Prev = null;
1172
+ }, e.Join = function() {
1173
+ this.OutPt1 = null, this.OutPt2 = null, this.OffPt = new e.IntPoint();
1174
+ }, e.ClipperBase = function() {
1175
+ this.m_MinimaList = null, this.m_CurrentLM = null, this.m_edges = [], this.m_UseFullRange = !1, this.m_HasOpenPaths = !1, this.PreserveCollinear = !1, this.m_MinimaList = null, this.m_CurrentLM = null, this.m_UseFullRange = !1, this.m_HasOpenPaths = !1;
1176
+ }, e.ClipperBase.horizontal = -9007199254740992, e.ClipperBase.Skip = -2, e.ClipperBase.Unassigned = -1, e.ClipperBase.tolerance = 1e-20, e.ClipperBase.loRange = 47453132, e.ClipperBase.hiRange = 0xfffffffffffff, e.ClipperBase.near_zero = function(t) {
1177
+ return t > -e.ClipperBase.tolerance && t < e.ClipperBase.tolerance;
1178
+ }, e.ClipperBase.IsHorizontal = function(e) {
1179
+ return e.Delta.Y === 0;
1180
+ }, e.ClipperBase.prototype.PointIsVertex = function(t, n) {
1181
+ var r = n;
1182
+ do {
1183
+ if (e.IntPoint.op_Equality(r.Pt, t)) return !0;
1184
+ r = r.Next;
1185
+ } while (r != n);
1186
+ return !1;
1187
+ }, e.ClipperBase.prototype.PointOnLineSegment = function(e, t, n, r) {
1188
+ return r ? e.X == t.X && e.Y == t.Y || e.X == n.X && e.Y == n.Y || e.X > t.X == e.X < n.X && e.Y > t.Y == e.Y < n.Y && U.op_Equality(U.Int128Mul(e.X - t.X, n.Y - t.Y), U.Int128Mul(n.X - t.X, e.Y - t.Y)) : e.X == t.X && e.Y == t.Y || e.X == n.X && e.Y == n.Y || e.X > t.X == e.X < n.X && e.Y > t.Y == e.Y < n.Y && (e.X - t.X) * (n.Y - t.Y) == (n.X - t.X) * (e.Y - t.Y);
1189
+ }, e.ClipperBase.prototype.PointOnPolygon = function(e, t, n) {
1190
+ for (var r = t;;) {
1191
+ if (this.PointOnLineSegment(e, r.Pt, r.Next.Pt, n)) return !0;
1192
+ if (r = r.Next, r == t) break;
1193
+ }
1194
+ return !1;
1195
+ }, e.ClipperBase.prototype.SlopesEqual = e.ClipperBase.SlopesEqual = function() {
1196
+ var t = arguments, n = t.length, r, i, a, o, s, c, l;
1197
+ return n == 3 ? (r = t[0], i = t[1], l = t[2], l ? U.op_Equality(U.Int128Mul(r.Delta.Y, i.Delta.X), U.Int128Mul(r.Delta.X, i.Delta.Y)) : e.Cast_Int64(r.Delta.Y * i.Delta.X) == e.Cast_Int64(r.Delta.X * i.Delta.Y)) : n == 4 ? (a = t[0], o = t[1], s = t[2], l = t[3], l ? U.op_Equality(U.Int128Mul(a.Y - o.Y, o.X - s.X), U.Int128Mul(a.X - o.X, o.Y - s.Y)) : e.Cast_Int64((a.Y - o.Y) * (o.X - s.X)) - e.Cast_Int64((a.X - o.X) * (o.Y - s.Y)) === 0) : (a = t[0], o = t[1], s = t[2], c = t[3], l = t[4], l ? U.op_Equality(U.Int128Mul(a.Y - o.Y, s.X - c.X), U.Int128Mul(a.X - o.X, s.Y - c.Y)) : e.Cast_Int64((a.Y - o.Y) * (s.X - c.X)) - e.Cast_Int64((a.X - o.X) * (s.Y - c.Y)) === 0);
1198
+ }, e.ClipperBase.SlopesEqual3 = function(t, n, r) {
1199
+ return r ? U.op_Equality(U.Int128Mul(t.Delta.Y, n.Delta.X), U.Int128Mul(t.Delta.X, n.Delta.Y)) : e.Cast_Int64(t.Delta.Y * n.Delta.X) == e.Cast_Int64(t.Delta.X * n.Delta.Y);
1200
+ }, e.ClipperBase.SlopesEqual4 = function(t, n, r, i) {
1201
+ return i ? U.op_Equality(U.Int128Mul(t.Y - n.Y, n.X - r.X), U.Int128Mul(t.X - n.X, n.Y - r.Y)) : e.Cast_Int64((t.Y - n.Y) * (n.X - r.X)) - e.Cast_Int64((t.X - n.X) * (n.Y - r.Y)) === 0;
1202
+ }, e.ClipperBase.SlopesEqual5 = function(t, n, r, i, a) {
1203
+ return a ? U.op_Equality(U.Int128Mul(t.Y - n.Y, r.X - i.X), U.Int128Mul(t.X - n.X, r.Y - i.Y)) : e.Cast_Int64((t.Y - n.Y) * (r.X - i.X)) - e.Cast_Int64((t.X - n.X) * (r.Y - i.Y)) === 0;
1204
+ }, e.ClipperBase.prototype.Clear = function() {
1205
+ this.DisposeLocalMinimaList();
1206
+ for (var t = 0, n = this.m_edges.length; t < n; ++t) {
1207
+ for (var r = 0, i = this.m_edges[t].length; r < i; ++r) this.m_edges[t][r] = null;
1208
+ e.Clear(this.m_edges[t]);
1209
+ }
1210
+ e.Clear(this.m_edges), this.m_UseFullRange = !1, this.m_HasOpenPaths = !1;
1211
+ }, e.ClipperBase.prototype.DisposeLocalMinimaList = function() {
1212
+ for (; this.m_MinimaList !== null;) {
1213
+ var e = this.m_MinimaList.Next;
1214
+ this.m_MinimaList = null, this.m_MinimaList = e;
1215
+ }
1216
+ this.m_CurrentLM = null;
1217
+ }, e.ClipperBase.prototype.RangeTest = function(t, n) {
1218
+ n.Value ? (t.X > e.ClipperBase.hiRange || t.Y > e.ClipperBase.hiRange || -t.X > e.ClipperBase.hiRange || -t.Y > e.ClipperBase.hiRange) && e.Error("Coordinate outside allowed range in RangeTest().") : (t.X > e.ClipperBase.loRange || t.Y > e.ClipperBase.loRange || -t.X > e.ClipperBase.loRange || -t.Y > e.ClipperBase.loRange) && (n.Value = !0, this.RangeTest(t, n));
1219
+ }, e.ClipperBase.prototype.InitEdge = function(e, t, n, r) {
1220
+ e.Next = t, e.Prev = n, e.Curr.X = r.X, e.Curr.Y = r.Y, e.OutIdx = -1;
1221
+ }, e.ClipperBase.prototype.InitEdge2 = function(e, t) {
1222
+ e.Curr.Y >= e.Next.Curr.Y ? (e.Bot.X = e.Curr.X, e.Bot.Y = e.Curr.Y, e.Top.X = e.Next.Curr.X, e.Top.Y = e.Next.Curr.Y) : (e.Top.X = e.Curr.X, e.Top.Y = e.Curr.Y, e.Bot.X = e.Next.Curr.X, e.Bot.Y = e.Next.Curr.Y), this.SetDx(e), e.PolyTyp = t;
1223
+ }, e.ClipperBase.prototype.FindNextLocMin = function(t) {
1224
+ for (var n;;) {
1225
+ for (; e.IntPoint.op_Inequality(t.Bot, t.Prev.Bot) || e.IntPoint.op_Equality(t.Curr, t.Top);) t = t.Next;
1226
+ if (t.Dx != e.ClipperBase.horizontal && t.Prev.Dx != e.ClipperBase.horizontal) break;
1227
+ for (; t.Prev.Dx == e.ClipperBase.horizontal;) t = t.Prev;
1228
+ for (n = t; t.Dx == e.ClipperBase.horizontal;) t = t.Next;
1229
+ if (t.Top.Y != t.Prev.Bot.Y) {
1230
+ n.Prev.Bot.X < t.Bot.X && (t = n);
1231
+ break;
1232
+ }
1233
+ }
1234
+ return t;
1235
+ }, e.ClipperBase.prototype.ProcessBound = function(t, n) {
1236
+ var r = t, i = t, a, o;
1237
+ if (t.Dx == e.ClipperBase.horizontal && (o = n ? t.Prev.Bot.X : t.Next.Bot.X, t.Bot.X != o && this.ReverseHorizontal(t)), i.OutIdx != e.ClipperBase.Skip) {
1238
+ if (n) {
1239
+ for (; i.Top.Y == i.Next.Bot.Y && i.Next.OutIdx != e.ClipperBase.Skip;) i = i.Next;
1240
+ if (i.Dx == e.ClipperBase.horizontal && i.Next.OutIdx != e.ClipperBase.Skip) {
1241
+ for (a = i; a.Prev.Dx == e.ClipperBase.horizontal;) a = a.Prev;
1242
+ a.Prev.Top.X == i.Next.Top.X ? n || (i = a.Prev) : a.Prev.Top.X > i.Next.Top.X && (i = a.Prev);
1243
+ }
1244
+ for (; t != i;) t.NextInLML = t.Next, t.Dx == e.ClipperBase.horizontal && t != r && t.Bot.X != t.Prev.Top.X && this.ReverseHorizontal(t), t = t.Next;
1245
+ t.Dx == e.ClipperBase.horizontal && t != r && t.Bot.X != t.Prev.Top.X && this.ReverseHorizontal(t), i = i.Next;
1246
+ } else {
1247
+ for (; i.Top.Y == i.Prev.Bot.Y && i.Prev.OutIdx != e.ClipperBase.Skip;) i = i.Prev;
1248
+ if (i.Dx == e.ClipperBase.horizontal && i.Prev.OutIdx != e.ClipperBase.Skip) {
1249
+ for (a = i; a.Next.Dx == e.ClipperBase.horizontal;) a = a.Next;
1250
+ a.Next.Top.X == i.Prev.Top.X ? n || (i = a.Next) : a.Next.Top.X > i.Prev.Top.X && (i = a.Next);
1251
+ }
1252
+ for (; t != i;) t.NextInLML = t.Prev, t.Dx == e.ClipperBase.horizontal && t != r && t.Bot.X != t.Next.Top.X && this.ReverseHorizontal(t), t = t.Prev;
1253
+ t.Dx == e.ClipperBase.horizontal && t != r && t.Bot.X != t.Next.Top.X && this.ReverseHorizontal(t), i = i.Prev;
1254
+ }
1255
+ }
1256
+ if (i.OutIdx == e.ClipperBase.Skip) {
1257
+ if (t = i, n) {
1258
+ for (; t.Top.Y == t.Next.Bot.Y;) t = t.Next;
1259
+ for (; t != i && t.Dx == e.ClipperBase.horizontal;) t = t.Prev;
1260
+ } else {
1261
+ for (; t.Top.Y == t.Prev.Bot.Y;) t = t.Prev;
1262
+ for (; t != i && t.Dx == e.ClipperBase.horizontal;) t = t.Next;
1263
+ }
1264
+ if (t == i) i = n ? t.Next : t.Prev;
1265
+ else {
1266
+ t = n ? i.Next : i.Prev;
1267
+ var s = new e.LocalMinima();
1268
+ s.Next = null, s.Y = t.Bot.Y, s.LeftBound = null, s.RightBound = t, s.RightBound.WindDelta = 0, i = this.ProcessBound(s.RightBound, n), this.InsertLocalMinima(s);
1269
+ }
1270
+ }
1271
+ return i;
1272
+ }, e.ClipperBase.prototype.AddPath = function(t, n, r) {
1273
+ !r && n == e.PolyType.ptClip && e.Error("AddPath: Open paths must be subject.");
1274
+ var i = t.length - 1;
1275
+ if (r) for (; i > 0 && e.IntPoint.op_Equality(t[i], t[0]);) --i;
1276
+ for (; i > 0 && e.IntPoint.op_Equality(t[i], t[i - 1]);) --i;
1277
+ if (r && i < 2 || !r && i < 1) return !1;
1278
+ for (var a = [], o = 0; o <= i; o++) a.push(new e.TEdge());
1279
+ var s = !0;
1280
+ a[1].Curr.X = t[1].X, a[1].Curr.Y = t[1].Y;
1281
+ var c = { Value: this.m_UseFullRange };
1282
+ this.RangeTest(t[0], c), this.m_UseFullRange = c.Value, c.Value = this.m_UseFullRange, this.RangeTest(t[i], c), this.m_UseFullRange = c.Value, this.InitEdge(a[0], a[1], a[i], t[0]), this.InitEdge(a[i], a[0], a[i - 1], t[i]);
1283
+ for (var o = i - 1; o >= 1; --o) c.Value = this.m_UseFullRange, this.RangeTest(t[o], c), this.m_UseFullRange = c.Value, this.InitEdge(a[o], a[o + 1], a[o - 1], t[o]);
1284
+ for (var l = a[0], u = l, d = l;;) {
1285
+ if (e.IntPoint.op_Equality(u.Curr, u.Next.Curr)) {
1286
+ if (u == u.Next) break;
1287
+ u == l && (l = u.Next), u = this.RemoveEdge(u), d = u;
1288
+ continue;
1289
+ }
1290
+ if (u.Prev == u.Next) break;
1291
+ if (r && e.ClipperBase.SlopesEqual(u.Prev.Curr, u.Curr, u.Next.Curr, this.m_UseFullRange) && (!this.PreserveCollinear || !this.Pt2IsBetweenPt1AndPt3(u.Prev.Curr, u.Curr, u.Next.Curr))) {
1292
+ u == l && (l = u.Next), u = this.RemoveEdge(u), u = u.Prev, d = u;
1293
+ continue;
1294
+ }
1295
+ if (u = u.Next, u == d) break;
1296
+ }
1297
+ if (!r && u == u.Next || r && u.Prev == u.Next) return !1;
1298
+ r || (this.m_HasOpenPaths = !0, l.Prev.OutIdx = e.ClipperBase.Skip), u = l;
1299
+ do
1300
+ this.InitEdge2(u, n), u = u.Next, s && u.Curr.Y != l.Curr.Y && (s = !1);
1301
+ while (u != l);
1302
+ if (s) {
1303
+ if (r) return !1;
1304
+ u.Prev.OutIdx = e.ClipperBase.Skip, u.Prev.Bot.X < u.Prev.Top.X && this.ReverseHorizontal(u.Prev);
1305
+ var f = new e.LocalMinima();
1306
+ for (f.Next = null, f.Y = u.Bot.Y, f.LeftBound = null, f.RightBound = u, f.RightBound.Side = e.EdgeSide.esRight, f.RightBound.WindDelta = 0; u.Next.OutIdx != e.ClipperBase.Skip;) u.NextInLML = u.Next, u.Bot.X != u.Prev.Top.X && this.ReverseHorizontal(u), u = u.Next;
1307
+ return this.InsertLocalMinima(f), this.m_edges.push(a), !0;
1308
+ }
1309
+ this.m_edges.push(a);
1310
+ for (var p, m = null; u = this.FindNextLocMin(u), u != m;) {
1311
+ m ??= u;
1312
+ var f = new e.LocalMinima();
1313
+ f.Next = null, f.Y = u.Bot.Y, u.Dx < u.Prev.Dx ? (f.LeftBound = u.Prev, f.RightBound = u, p = !1) : (f.LeftBound = u, f.RightBound = u.Prev, p = !0), f.LeftBound.Side = e.EdgeSide.esLeft, f.RightBound.Side = e.EdgeSide.esRight, r ? f.LeftBound.Next == f.RightBound ? f.LeftBound.WindDelta = -1 : f.LeftBound.WindDelta = 1 : f.LeftBound.WindDelta = 0, f.RightBound.WindDelta = -f.LeftBound.WindDelta, u = this.ProcessBound(f.LeftBound, p);
1314
+ var h = this.ProcessBound(f.RightBound, !p);
1315
+ f.LeftBound.OutIdx == e.ClipperBase.Skip ? f.LeftBound = null : f.RightBound.OutIdx == e.ClipperBase.Skip && (f.RightBound = null), this.InsertLocalMinima(f), p || (u = h);
1316
+ }
1317
+ return !0;
1318
+ }, e.ClipperBase.prototype.AddPaths = function(e, t, n) {
1319
+ for (var r = !1, i = 0, a = e.length; i < a; ++i) this.AddPath(e[i], t, n) && (r = !0);
1320
+ return r;
1321
+ }, e.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3 = function(t, n, r) {
1322
+ return e.IntPoint.op_Equality(t, r) || e.IntPoint.op_Equality(t, n) || e.IntPoint.op_Equality(r, n) ? !1 : t.X == r.X ? n.Y > t.Y == n.Y < r.Y : n.X > t.X == n.X < r.X;
1323
+ }, e.ClipperBase.prototype.RemoveEdge = function(e) {
1324
+ e.Prev.Next = e.Next, e.Next.Prev = e.Prev;
1325
+ var t = e.Next;
1326
+ return e.Prev = null, t;
1327
+ }, e.ClipperBase.prototype.SetDx = function(t) {
1328
+ t.Delta.X = t.Top.X - t.Bot.X, t.Delta.Y = t.Top.Y - t.Bot.Y, t.Dx = t.Delta.Y === 0 ? e.ClipperBase.horizontal : t.Delta.X / t.Delta.Y;
1329
+ }, e.ClipperBase.prototype.InsertLocalMinima = function(e) {
1330
+ if (this.m_MinimaList === null) this.m_MinimaList = e;
1331
+ else if (e.Y >= this.m_MinimaList.Y) e.Next = this.m_MinimaList, this.m_MinimaList = e;
1332
+ else {
1333
+ for (var t = this.m_MinimaList; t.Next !== null && e.Y < t.Next.Y;) t = t.Next;
1334
+ e.Next = t.Next, t.Next = e;
1335
+ }
1336
+ }, e.ClipperBase.prototype.PopLocalMinima = function() {
1337
+ this.m_CurrentLM !== null && (this.m_CurrentLM = this.m_CurrentLM.Next);
1338
+ }, e.ClipperBase.prototype.ReverseHorizontal = function(e) {
1339
+ var t = e.Top.X;
1340
+ e.Top.X = e.Bot.X, e.Bot.X = t;
1341
+ }, e.ClipperBase.prototype.Reset = function() {
1342
+ if (this.m_CurrentLM = this.m_MinimaList, this.m_CurrentLM != null) for (var t = this.m_MinimaList; t != null;) {
1343
+ var n = t.LeftBound;
1344
+ n != null && (n.Curr.X = n.Bot.X, n.Curr.Y = n.Bot.Y, n.Side = e.EdgeSide.esLeft, n.OutIdx = e.ClipperBase.Unassigned), n = t.RightBound, n != null && (n.Curr.X = n.Bot.X, n.Curr.Y = n.Bot.Y, n.Side = e.EdgeSide.esRight, n.OutIdx = e.ClipperBase.Unassigned), t = t.Next;
1345
+ }
1346
+ }, e.Clipper = function(t) {
1347
+ t === void 0 && (t = 0), this.m_PolyOuts = null, this.m_ClipType = e.ClipType.ctIntersection, this.m_Scanbeam = null, this.m_ActiveEdges = null, this.m_SortedEdges = null, this.m_IntersectList = null, this.m_IntersectNodeComparer = null, this.m_ExecuteLocked = !1, this.m_ClipFillType = e.PolyFillType.pftEvenOdd, this.m_SubjFillType = e.PolyFillType.pftEvenOdd, this.m_Joins = null, this.m_GhostJoins = null, this.m_UsingPolyTree = !1, this.ReverseSolution = !1, this.StrictlySimple = !1, e.ClipperBase.call(this), this.m_Scanbeam = null, this.m_ActiveEdges = null, this.m_SortedEdges = null, this.m_IntersectList = [], this.m_IntersectNodeComparer = e.MyIntersectNodeSort.Compare, this.m_ExecuteLocked = !1, this.m_UsingPolyTree = !1, this.m_PolyOuts = [], this.m_Joins = [], this.m_GhostJoins = [], this.ReverseSolution = !!(1 & t), this.StrictlySimple = !!(2 & t), this.PreserveCollinear = !!(4 & t);
1348
+ }, e.Clipper.ioReverseSolution = 1, e.Clipper.ioStrictlySimple = 2, e.Clipper.ioPreserveCollinear = 4, e.Clipper.prototype.Clear = function() {
1349
+ this.m_edges.length !== 0 && (this.DisposeAllPolyPts(), e.ClipperBase.prototype.Clear.call(this));
1350
+ }, e.Clipper.prototype.DisposeScanbeamList = function() {
1351
+ for (; this.m_Scanbeam !== null;) {
1352
+ var e = this.m_Scanbeam.Next;
1353
+ this.m_Scanbeam = null, this.m_Scanbeam = e;
1354
+ }
1355
+ }, e.Clipper.prototype.Reset = function() {
1356
+ e.ClipperBase.prototype.Reset.call(this), this.m_Scanbeam = null, this.m_ActiveEdges = null, this.m_SortedEdges = null;
1357
+ for (var t = this.m_MinimaList; t !== null;) this.InsertScanbeam(t.Y), t = t.Next;
1358
+ }, e.Clipper.prototype.InsertScanbeam = function(t) {
1359
+ if (this.m_Scanbeam === null) this.m_Scanbeam = new e.Scanbeam(), this.m_Scanbeam.Next = null, this.m_Scanbeam.Y = t;
1360
+ else if (t > this.m_Scanbeam.Y) {
1361
+ var n = new e.Scanbeam();
1362
+ n.Y = t, n.Next = this.m_Scanbeam, this.m_Scanbeam = n;
1363
+ } else {
1364
+ for (var r = this.m_Scanbeam; r.Next !== null && t <= r.Next.Y;) r = r.Next;
1365
+ if (t == r.Y) return;
1366
+ var n = new e.Scanbeam();
1367
+ n.Y = t, n.Next = r.Next, r.Next = n;
1368
+ }
1369
+ }, e.Clipper.prototype.Execute = function() {
1370
+ var t = arguments, n = t.length, r = t[1] instanceof e.PolyTree;
1371
+ if (n == 4 && !r) {
1372
+ var i = t[0], a = t[1], o = t[2], s = t[3];
1373
+ if (this.m_ExecuteLocked) return !1;
1374
+ this.m_HasOpenPaths && e.Error("Error: PolyTree struct is need for open path clipping."), this.m_ExecuteLocked = !0, e.Clear(a), this.m_SubjFillType = o, this.m_ClipFillType = s, this.m_ClipType = i, this.m_UsingPolyTree = !1;
1375
+ try {
1376
+ var c = this.ExecuteInternal();
1377
+ c && this.BuildResult(a);
1378
+ } finally {
1379
+ this.DisposeAllPolyPts(), this.m_ExecuteLocked = !1;
1380
+ }
1381
+ return c;
1382
+ }
1383
+ if (n == 4 && r) {
1384
+ var i = t[0], l = t[1], o = t[2], s = t[3];
1385
+ if (this.m_ExecuteLocked) return !1;
1386
+ this.m_ExecuteLocked = !0, this.m_SubjFillType = o, this.m_ClipFillType = s, this.m_ClipType = i, this.m_UsingPolyTree = !0;
1387
+ try {
1388
+ var c = this.ExecuteInternal();
1389
+ c && this.BuildResult2(l);
1390
+ } finally {
1391
+ this.DisposeAllPolyPts(), this.m_ExecuteLocked = !1;
1392
+ }
1393
+ return c;
1394
+ }
1395
+ if (n == 2 && !r) {
1396
+ var i = t[0], a = t[1];
1397
+ return this.Execute(i, a, e.PolyFillType.pftEvenOdd, e.PolyFillType.pftEvenOdd);
1398
+ }
1399
+ if (n == 2 && r) {
1400
+ var i = t[0], l = t[1];
1401
+ return this.Execute(i, l, e.PolyFillType.pftEvenOdd, e.PolyFillType.pftEvenOdd);
1402
+ }
1403
+ }, e.Clipper.prototype.FixHoleLinkage = function(e) {
1404
+ if (!(e.FirstLeft === null || e.IsHole != e.FirstLeft.IsHole && e.FirstLeft.Pts !== null)) {
1405
+ for (var t = e.FirstLeft; t !== null && (t.IsHole == e.IsHole || t.Pts === null);) t = t.FirstLeft;
1406
+ e.FirstLeft = t;
1407
+ }
1408
+ }, e.Clipper.prototype.ExecuteInternal = function() {
1409
+ try {
1410
+ if (this.Reset(), this.m_CurrentLM === null) return !1;
1411
+ var t = this.PopScanbeam();
1412
+ do {
1413
+ if (this.InsertLocalMinimaIntoAEL(t), e.Clear(this.m_GhostJoins), this.ProcessHorizontals(!1), this.m_Scanbeam === null) break;
1414
+ var n = this.PopScanbeam();
1415
+ if (!this.ProcessIntersections(t, n)) return !1;
1416
+ this.ProcessEdgesAtTopOfScanbeam(n), t = n;
1417
+ } while (this.m_Scanbeam !== null || this.m_CurrentLM !== null);
1418
+ for (var r = 0, i = this.m_PolyOuts.length; r < i; r++) {
1419
+ var a = this.m_PolyOuts[r];
1420
+ a.Pts === null || a.IsOpen || (a.IsHole ^ this.ReverseSolution) == this.Area(a) > 0 && this.ReversePolyPtLinks(a.Pts);
1421
+ }
1422
+ this.JoinCommonEdges();
1423
+ for (var r = 0, i = this.m_PolyOuts.length; r < i; r++) {
1424
+ var a = this.m_PolyOuts[r];
1425
+ a.Pts !== null && !a.IsOpen && this.FixupOutPolygon(a);
1426
+ }
1427
+ return this.StrictlySimple && this.DoSimplePolygons(), !0;
1428
+ } finally {
1429
+ e.Clear(this.m_Joins), e.Clear(this.m_GhostJoins);
1430
+ }
1431
+ }, e.Clipper.prototype.PopScanbeam = function() {
1432
+ var e = this.m_Scanbeam.Y;
1433
+ return this.m_Scanbeam, this.m_Scanbeam = this.m_Scanbeam.Next, e;
1434
+ }, e.Clipper.prototype.DisposeAllPolyPts = function() {
1435
+ for (var t = 0, n = this.m_PolyOuts.length; t < n; ++t) this.DisposeOutRec(t);
1436
+ e.Clear(this.m_PolyOuts);
1437
+ }, e.Clipper.prototype.DisposeOutRec = function(e) {
1438
+ var t = this.m_PolyOuts[e];
1439
+ t.Pts !== null && this.DisposeOutPts(t.Pts), t = null, this.m_PolyOuts[e] = null;
1440
+ }, e.Clipper.prototype.DisposeOutPts = function(e) {
1441
+ if (e !== null) for (e.Prev.Next = null; e !== null;) e = e.Next;
1442
+ }, e.Clipper.prototype.AddJoin = function(t, n, r) {
1443
+ var i = new e.Join();
1444
+ i.OutPt1 = t, i.OutPt2 = n, i.OffPt.X = r.X, i.OffPt.Y = r.Y, this.m_Joins.push(i);
1445
+ }, e.Clipper.prototype.AddGhostJoin = function(t, n) {
1446
+ var r = new e.Join();
1447
+ r.OutPt1 = t, r.OffPt.X = n.X, r.OffPt.Y = n.Y, this.m_GhostJoins.push(r);
1448
+ }, e.Clipper.prototype.InsertLocalMinimaIntoAEL = function(t) {
1449
+ for (; this.m_CurrentLM !== null && this.m_CurrentLM.Y == t;) {
1450
+ var n = this.m_CurrentLM.LeftBound, r = this.m_CurrentLM.RightBound;
1451
+ this.PopLocalMinima();
1452
+ var i = null;
1453
+ if (n === null ? (this.InsertEdgeIntoAEL(r, null), this.SetWindingCount(r), this.IsContributing(r) && (i = this.AddOutPt(r, r.Bot))) : r == null ? (this.InsertEdgeIntoAEL(n, null), this.SetWindingCount(n), this.IsContributing(n) && (i = this.AddOutPt(n, n.Bot)), this.InsertScanbeam(n.Top.Y)) : (this.InsertEdgeIntoAEL(n, null), this.InsertEdgeIntoAEL(r, n), this.SetWindingCount(n), r.WindCnt = n.WindCnt, r.WindCnt2 = n.WindCnt2, this.IsContributing(n) && (i = this.AddLocalMinPoly(n, r, n.Bot)), this.InsertScanbeam(n.Top.Y)), r != null && (e.ClipperBase.IsHorizontal(r) ? this.AddEdgeToSEL(r) : this.InsertScanbeam(r.Top.Y)), n != null && r != null) {
1454
+ if (i !== null && e.ClipperBase.IsHorizontal(r) && this.m_GhostJoins.length > 0 && r.WindDelta !== 0) for (var a = 0, o = this.m_GhostJoins.length; a < o; a++) {
1455
+ var s = this.m_GhostJoins[a];
1456
+ this.HorzSegmentsOverlap(s.OutPt1.Pt, s.OffPt, r.Bot, r.Top) && this.AddJoin(s.OutPt1, i, s.OffPt);
1457
+ }
1458
+ if (n.OutIdx >= 0 && n.PrevInAEL !== null && n.PrevInAEL.Curr.X == n.Bot.X && n.PrevInAEL.OutIdx >= 0 && e.ClipperBase.SlopesEqual(n.PrevInAEL, n, this.m_UseFullRange) && n.WindDelta !== 0 && n.PrevInAEL.WindDelta !== 0) {
1459
+ var c = this.AddOutPt(n.PrevInAEL, n.Bot);
1460
+ this.AddJoin(i, c, n.Top);
1461
+ }
1462
+ if (n.NextInAEL != r) {
1463
+ if (r.OutIdx >= 0 && r.PrevInAEL.OutIdx >= 0 && e.ClipperBase.SlopesEqual(r.PrevInAEL, r, this.m_UseFullRange) && r.WindDelta !== 0 && r.PrevInAEL.WindDelta !== 0) {
1464
+ var c = this.AddOutPt(r.PrevInAEL, r.Bot);
1465
+ this.AddJoin(i, c, r.Top);
1466
+ }
1467
+ var l = n.NextInAEL;
1468
+ if (l !== null) for (; l != r;) this.IntersectEdges(r, l, n.Curr, !1), l = l.NextInAEL;
1469
+ }
1470
+ }
1471
+ }
1472
+ }, e.Clipper.prototype.InsertEdgeIntoAEL = function(e, t) {
1473
+ if (this.m_ActiveEdges === null) e.PrevInAEL = null, e.NextInAEL = null, this.m_ActiveEdges = e;
1474
+ else if (t === null && this.E2InsertsBeforeE1(this.m_ActiveEdges, e)) e.PrevInAEL = null, e.NextInAEL = this.m_ActiveEdges, this.m_ActiveEdges.PrevInAEL = e, this.m_ActiveEdges = e;
1475
+ else {
1476
+ for (t === null && (t = this.m_ActiveEdges); t.NextInAEL !== null && !this.E2InsertsBeforeE1(t.NextInAEL, e);) t = t.NextInAEL;
1477
+ e.NextInAEL = t.NextInAEL, t.NextInAEL !== null && (t.NextInAEL.PrevInAEL = e), e.PrevInAEL = t, t.NextInAEL = e;
1478
+ }
1479
+ }, e.Clipper.prototype.E2InsertsBeforeE1 = function(t, n) {
1480
+ return n.Curr.X == t.Curr.X ? n.Top.Y > t.Top.Y ? n.Top.X < e.Clipper.TopX(t, n.Top.Y) : t.Top.X > e.Clipper.TopX(n, t.Top.Y) : n.Curr.X < t.Curr.X;
1481
+ }, e.Clipper.prototype.IsEvenOddFillType = function(t) {
1482
+ return t.PolyTyp == e.PolyType.ptSubject ? this.m_SubjFillType == e.PolyFillType.pftEvenOdd : this.m_ClipFillType == e.PolyFillType.pftEvenOdd;
1483
+ }, e.Clipper.prototype.IsEvenOddAltFillType = function(t) {
1484
+ return t.PolyTyp == e.PolyType.ptSubject ? this.m_ClipFillType == e.PolyFillType.pftEvenOdd : this.m_SubjFillType == e.PolyFillType.pftEvenOdd;
1485
+ }, e.Clipper.prototype.IsContributing = function(t) {
1486
+ var n, r;
1487
+ switch (t.PolyTyp == e.PolyType.ptSubject ? (n = this.m_SubjFillType, r = this.m_ClipFillType) : (n = this.m_ClipFillType, r = this.m_SubjFillType), n) {
1488
+ case e.PolyFillType.pftEvenOdd:
1489
+ if (t.WindDelta === 0 && t.WindCnt != 1) return !1;
1490
+ break;
1491
+ case e.PolyFillType.pftNonZero:
1492
+ if (Math.abs(t.WindCnt) != 1) return !1;
1493
+ break;
1494
+ case e.PolyFillType.pftPositive:
1495
+ if (t.WindCnt != 1) return !1;
1496
+ break;
1497
+ default: if (t.WindCnt != -1) return !1;
1498
+ }
1499
+ switch (this.m_ClipType) {
1500
+ case e.ClipType.ctIntersection: switch (r) {
1501
+ case e.PolyFillType.pftEvenOdd:
1502
+ case e.PolyFillType.pftNonZero: return t.WindCnt2 !== 0;
1503
+ case e.PolyFillType.pftPositive: return t.WindCnt2 > 0;
1504
+ default: return t.WindCnt2 < 0;
1505
+ }
1506
+ case e.ClipType.ctUnion: switch (r) {
1507
+ case e.PolyFillType.pftEvenOdd:
1508
+ case e.PolyFillType.pftNonZero: return t.WindCnt2 === 0;
1509
+ case e.PolyFillType.pftPositive: return t.WindCnt2 <= 0;
1510
+ default: return t.WindCnt2 >= 0;
1511
+ }
1512
+ case e.ClipType.ctDifference: if (t.PolyTyp == e.PolyType.ptSubject) switch (r) {
1513
+ case e.PolyFillType.pftEvenOdd:
1514
+ case e.PolyFillType.pftNonZero: return t.WindCnt2 === 0;
1515
+ case e.PolyFillType.pftPositive: return t.WindCnt2 <= 0;
1516
+ default: return t.WindCnt2 >= 0;
1517
+ }
1518
+ else switch (r) {
1519
+ case e.PolyFillType.pftEvenOdd:
1520
+ case e.PolyFillType.pftNonZero: return t.WindCnt2 !== 0;
1521
+ case e.PolyFillType.pftPositive: return t.WindCnt2 > 0;
1522
+ default: return t.WindCnt2 < 0;
1523
+ }
1524
+ case e.ClipType.ctXor: if (t.WindDelta === 0) switch (r) {
1525
+ case e.PolyFillType.pftEvenOdd:
1526
+ case e.PolyFillType.pftNonZero: return t.WindCnt2 === 0;
1527
+ case e.PolyFillType.pftPositive: return t.WindCnt2 <= 0;
1528
+ default: return t.WindCnt2 >= 0;
1529
+ }
1530
+ else return !0;
1531
+ }
1532
+ return !0;
1533
+ }, e.Clipper.prototype.SetWindingCount = function(t) {
1534
+ for (var n = t.PrevInAEL; n !== null && (n.PolyTyp != t.PolyTyp || n.WindDelta === 0);) n = n.PrevInAEL;
1535
+ if (n === null) t.WindCnt = t.WindDelta === 0 ? 1 : t.WindDelta, t.WindCnt2 = 0, n = this.m_ActiveEdges;
1536
+ else if (t.WindDelta === 0 && this.m_ClipType != e.ClipType.ctUnion) t.WindCnt = 1, t.WindCnt2 = n.WindCnt2, n = n.NextInAEL;
1537
+ else if (this.IsEvenOddFillType(t)) {
1538
+ if (t.WindDelta === 0) {
1539
+ for (var r = !0, i = n.PrevInAEL; i !== null;) i.PolyTyp == n.PolyTyp && i.WindDelta !== 0 && (r = !r), i = i.PrevInAEL;
1540
+ t.WindCnt = +!r;
1541
+ } else t.WindCnt = t.WindDelta;
1542
+ t.WindCnt2 = n.WindCnt2, n = n.NextInAEL;
1543
+ } else t.WindCnt = n.WindCnt * n.WindDelta < 0 ? Math.abs(n.WindCnt) > 1 ? n.WindDelta * t.WindDelta < 0 ? n.WindCnt : n.WindCnt + t.WindDelta : t.WindDelta === 0 ? 1 : t.WindDelta : t.WindDelta === 0 ? n.WindCnt < 0 ? n.WindCnt - 1 : n.WindCnt + 1 : n.WindDelta * t.WindDelta < 0 ? n.WindCnt : n.WindCnt + t.WindDelta, t.WindCnt2 = n.WindCnt2, n = n.NextInAEL;
1544
+ if (this.IsEvenOddAltFillType(t)) for (; n != t;) n.WindDelta !== 0 && (t.WindCnt2 = +(t.WindCnt2 === 0)), n = n.NextInAEL;
1545
+ else for (; n != t;) t.WindCnt2 += n.WindDelta, n = n.NextInAEL;
1546
+ }, e.Clipper.prototype.AddEdgeToSEL = function(e) {
1547
+ this.m_SortedEdges === null ? (this.m_SortedEdges = e, e.PrevInSEL = null, e.NextInSEL = null) : (e.NextInSEL = this.m_SortedEdges, e.PrevInSEL = null, this.m_SortedEdges.PrevInSEL = e, this.m_SortedEdges = e);
1548
+ }, e.Clipper.prototype.CopyAELToSEL = function() {
1549
+ var e = this.m_ActiveEdges;
1550
+ for (this.m_SortedEdges = e; e !== null;) e.PrevInSEL = e.PrevInAEL, e.NextInSEL = e.NextInAEL, e = e.NextInAEL;
1551
+ }, e.Clipper.prototype.SwapPositionsInAEL = function(e, t) {
1552
+ if (e.NextInAEL != e.PrevInAEL && t.NextInAEL != t.PrevInAEL) {
1553
+ if (e.NextInAEL == t) {
1554
+ var n = t.NextInAEL;
1555
+ n !== null && (n.PrevInAEL = e);
1556
+ var r = e.PrevInAEL;
1557
+ r !== null && (r.NextInAEL = t), t.PrevInAEL = r, t.NextInAEL = e, e.PrevInAEL = t, e.NextInAEL = n;
1558
+ } else if (t.NextInAEL == e) {
1559
+ var n = e.NextInAEL;
1560
+ n !== null && (n.PrevInAEL = t);
1561
+ var r = t.PrevInAEL;
1562
+ r !== null && (r.NextInAEL = e), e.PrevInAEL = r, e.NextInAEL = t, t.PrevInAEL = e, t.NextInAEL = n;
1563
+ } else {
1564
+ var n = e.NextInAEL, r = e.PrevInAEL;
1565
+ e.NextInAEL = t.NextInAEL, e.NextInAEL !== null && (e.NextInAEL.PrevInAEL = e), e.PrevInAEL = t.PrevInAEL, e.PrevInAEL !== null && (e.PrevInAEL.NextInAEL = e), t.NextInAEL = n, t.NextInAEL !== null && (t.NextInAEL.PrevInAEL = t), t.PrevInAEL = r, t.PrevInAEL !== null && (t.PrevInAEL.NextInAEL = t);
1566
+ }
1567
+ e.PrevInAEL === null ? this.m_ActiveEdges = e : t.PrevInAEL === null && (this.m_ActiveEdges = t);
1568
+ }
1569
+ }, e.Clipper.prototype.SwapPositionsInSEL = function(e, t) {
1570
+ if ((e.NextInSEL !== null || e.PrevInSEL !== null) && (t.NextInSEL !== null || t.PrevInSEL !== null)) {
1571
+ if (e.NextInSEL == t) {
1572
+ var n = t.NextInSEL;
1573
+ n !== null && (n.PrevInSEL = e);
1574
+ var r = e.PrevInSEL;
1575
+ r !== null && (r.NextInSEL = t), t.PrevInSEL = r, t.NextInSEL = e, e.PrevInSEL = t, e.NextInSEL = n;
1576
+ } else if (t.NextInSEL == e) {
1577
+ var n = e.NextInSEL;
1578
+ n !== null && (n.PrevInSEL = t);
1579
+ var r = t.PrevInSEL;
1580
+ r !== null && (r.NextInSEL = e), e.PrevInSEL = r, e.NextInSEL = t, t.PrevInSEL = e, t.NextInSEL = n;
1581
+ } else {
1582
+ var n = e.NextInSEL, r = e.PrevInSEL;
1583
+ e.NextInSEL = t.NextInSEL, e.NextInSEL !== null && (e.NextInSEL.PrevInSEL = e), e.PrevInSEL = t.PrevInSEL, e.PrevInSEL !== null && (e.PrevInSEL.NextInSEL = e), t.NextInSEL = n, t.NextInSEL !== null && (t.NextInSEL.PrevInSEL = t), t.PrevInSEL = r, t.PrevInSEL !== null && (t.PrevInSEL.NextInSEL = t);
1584
+ }
1585
+ e.PrevInSEL === null ? this.m_SortedEdges = e : t.PrevInSEL === null && (this.m_SortedEdges = t);
1586
+ }
1587
+ }, e.Clipper.prototype.AddLocalMaxPoly = function(e, t, n) {
1588
+ this.AddOutPt(e, n), t.WindDelta == 0 && this.AddOutPt(t, n), e.OutIdx == t.OutIdx ? (e.OutIdx = -1, t.OutIdx = -1) : e.OutIdx < t.OutIdx ? this.AppendPolygon(e, t) : this.AppendPolygon(t, e);
1589
+ }, e.Clipper.prototype.AddLocalMinPoly = function(t, n, r) {
1590
+ var i, a, o;
1591
+ if (e.ClipperBase.IsHorizontal(n) || t.Dx > n.Dx ? (i = this.AddOutPt(t, r), n.OutIdx = t.OutIdx, t.Side = e.EdgeSide.esLeft, n.Side = e.EdgeSide.esRight, a = t, o = a.PrevInAEL == n ? n.PrevInAEL : a.PrevInAEL) : (i = this.AddOutPt(n, r), t.OutIdx = n.OutIdx, t.Side = e.EdgeSide.esRight, n.Side = e.EdgeSide.esLeft, a = n, o = a.PrevInAEL == t ? t.PrevInAEL : a.PrevInAEL), o !== null && o.OutIdx >= 0 && e.Clipper.TopX(o, r.Y) == e.Clipper.TopX(a, r.Y) && e.ClipperBase.SlopesEqual(a, o, this.m_UseFullRange) && a.WindDelta !== 0 && o.WindDelta !== 0) {
1592
+ var s = this.AddOutPt(o, r);
1593
+ this.AddJoin(i, s, a.Top);
1594
+ }
1595
+ return i;
1596
+ }, e.Clipper.prototype.CreateOutRec = function() {
1597
+ var t = new e.OutRec();
1598
+ return t.Idx = -1, t.IsHole = !1, t.IsOpen = !1, t.FirstLeft = null, t.Pts = null, t.BottomPt = null, t.PolyNode = null, this.m_PolyOuts.push(t), t.Idx = this.m_PolyOuts.length - 1, t;
1599
+ }, e.Clipper.prototype.AddOutPt = function(t, n) {
1600
+ var r = t.Side == e.EdgeSide.esLeft;
1601
+ if (t.OutIdx < 0) {
1602
+ var i = this.CreateOutRec();
1603
+ i.IsOpen = t.WindDelta === 0;
1604
+ var a = new e.OutPt();
1605
+ return i.Pts = a, a.Idx = i.Idx, a.Pt.X = n.X, a.Pt.Y = n.Y, a.Next = a, a.Prev = a, i.IsOpen || this.SetHoleState(t, i), t.OutIdx = i.Idx, a;
1606
+ }
1607
+ var i = this.m_PolyOuts[t.OutIdx], o = i.Pts;
1608
+ if (r && e.IntPoint.op_Equality(n, o.Pt)) return o;
1609
+ if (!r && e.IntPoint.op_Equality(n, o.Prev.Pt)) return o.Prev;
1610
+ var a = new e.OutPt();
1611
+ return a.Idx = i.Idx, a.Pt.X = n.X, a.Pt.Y = n.Y, a.Next = o, a.Prev = o.Prev, a.Prev.Next = a, o.Prev = a, r && (i.Pts = a), a;
1612
+ }, e.Clipper.prototype.SwapPoints = function(t, n) {
1613
+ var r = new e.IntPoint(t.Value);
1614
+ t.Value.X = n.Value.X, t.Value.Y = n.Value.Y, n.Value.X = r.X, n.Value.Y = r.Y;
1615
+ }, e.Clipper.prototype.HorzSegmentsOverlap = function(e, t, n, r) {
1616
+ return e.X > n.X == e.X < r.X || t.X > n.X == t.X < r.X || n.X > e.X == n.X < t.X || r.X > e.X == r.X < t.X || e.X == n.X && t.X == r.X || e.X == r.X && t.X == n.X;
1617
+ }, e.Clipper.prototype.InsertPolyPtBetween = function(t, n, r) {
1618
+ var i = new e.OutPt();
1619
+ return i.Pt.X = r.X, i.Pt.Y = r.Y, n == t.Next ? (t.Next = i, n.Prev = i, i.Next = n, i.Prev = t) : (n.Next = i, t.Prev = i, i.Next = t, i.Prev = n), i;
1620
+ }, e.Clipper.prototype.SetHoleState = function(e, t) {
1621
+ for (var n = !1, r = e.PrevInAEL; r !== null;) r.OutIdx >= 0 && r.WindDelta != 0 && (n = !n, t.FirstLeft === null && (t.FirstLeft = this.m_PolyOuts[r.OutIdx])), r = r.PrevInAEL;
1622
+ n && (t.IsHole = !0);
1623
+ }, e.Clipper.prototype.GetDx = function(t, n) {
1624
+ return t.Y == n.Y ? e.ClipperBase.horizontal : (n.X - t.X) / (n.Y - t.Y);
1625
+ }, e.Clipper.prototype.FirstIsBottomPt = function(t, n) {
1626
+ for (var r = t.Prev; e.IntPoint.op_Equality(r.Pt, t.Pt) && r != t;) r = r.Prev;
1627
+ var i = Math.abs(this.GetDx(t.Pt, r.Pt));
1628
+ for (r = t.Next; e.IntPoint.op_Equality(r.Pt, t.Pt) && r != t;) r = r.Next;
1629
+ var a = Math.abs(this.GetDx(t.Pt, r.Pt));
1630
+ for (r = n.Prev; e.IntPoint.op_Equality(r.Pt, n.Pt) && r != n;) r = r.Prev;
1631
+ var o = Math.abs(this.GetDx(n.Pt, r.Pt));
1632
+ for (r = n.Next; e.IntPoint.op_Equality(r.Pt, n.Pt) && r != n;) r = r.Next;
1633
+ var s = Math.abs(this.GetDx(n.Pt, r.Pt));
1634
+ return i >= o && i >= s || a >= o && a >= s;
1635
+ }, e.Clipper.prototype.GetBottomPt = function(t) {
1636
+ for (var n = null, r = t.Next; r != t;) r.Pt.Y > t.Pt.Y ? (t = r, n = null) : r.Pt.Y == t.Pt.Y && r.Pt.X <= t.Pt.X && (r.Pt.X < t.Pt.X ? (n = null, t = r) : r.Next != t && r.Prev != t && (n = r)), r = r.Next;
1637
+ if (n !== null) for (; n != r;) for (this.FirstIsBottomPt(r, n) || (t = n), n = n.Next; e.IntPoint.op_Inequality(n.Pt, t.Pt);) n = n.Next;
1638
+ return t;
1639
+ }, e.Clipper.prototype.GetLowermostRec = function(e, t) {
1640
+ e.BottomPt === null && (e.BottomPt = this.GetBottomPt(e.Pts)), t.BottomPt === null && (t.BottomPt = this.GetBottomPt(t.Pts));
1641
+ var n = e.BottomPt, r = t.BottomPt;
1642
+ return n.Pt.Y > r.Pt.Y ? e : n.Pt.Y < r.Pt.Y ? t : n.Pt.X < r.Pt.X ? e : n.Pt.X > r.Pt.X || n.Next == n ? t : r.Next == r || this.FirstIsBottomPt(n, r) ? e : t;
1643
+ }, e.Clipper.prototype.Param1RightOfParam2 = function(e, t) {
1644
+ do
1645
+ if (e = e.FirstLeft, e == t) return !0;
1646
+ while (e !== null);
1647
+ return !1;
1648
+ }, e.Clipper.prototype.GetOutRec = function(e) {
1649
+ for (var t = this.m_PolyOuts[e]; t != this.m_PolyOuts[t.Idx];) t = this.m_PolyOuts[t.Idx];
1650
+ return t;
1651
+ }, e.Clipper.prototype.AppendPolygon = function(t, n) {
1652
+ var r = this.m_PolyOuts[t.OutIdx], i = this.m_PolyOuts[n.OutIdx], a = this.Param1RightOfParam2(r, i) ? i : this.Param1RightOfParam2(i, r) ? r : this.GetLowermostRec(r, i), o = r.Pts, s = o.Prev, c = i.Pts, l = c.Prev, u;
1653
+ t.Side == e.EdgeSide.esLeft ? (n.Side == e.EdgeSide.esLeft ? (this.ReversePolyPtLinks(c), c.Next = o, o.Prev = c, s.Next = l, l.Prev = s, r.Pts = l) : (l.Next = o, o.Prev = l, c.Prev = s, s.Next = c, r.Pts = c), u = e.EdgeSide.esLeft) : (n.Side == e.EdgeSide.esRight ? (this.ReversePolyPtLinks(c), s.Next = l, l.Prev = s, c.Next = o, o.Prev = c) : (s.Next = c, c.Prev = s, o.Prev = l, l.Next = o), u = e.EdgeSide.esRight), r.BottomPt = null, a == i && (i.FirstLeft != r && (r.FirstLeft = i.FirstLeft), r.IsHole = i.IsHole), i.Pts = null, i.BottomPt = null, i.FirstLeft = r;
1654
+ var d = t.OutIdx, f = n.OutIdx;
1655
+ t.OutIdx = -1, n.OutIdx = -1;
1656
+ for (var p = this.m_ActiveEdges; p !== null;) {
1657
+ if (p.OutIdx == f) {
1658
+ p.OutIdx = d, p.Side = u;
1659
+ break;
1660
+ }
1661
+ p = p.NextInAEL;
1662
+ }
1663
+ i.Idx = r.Idx;
1664
+ }, e.Clipper.prototype.ReversePolyPtLinks = function(e) {
1665
+ if (e !== null) {
1666
+ var t = e, n;
1667
+ do
1668
+ n = t.Next, t.Next = t.Prev, t.Prev = n, t = n;
1669
+ while (t != e);
1670
+ }
1671
+ }, e.Clipper.SwapSides = function(e, t) {
1672
+ var n = e.Side;
1673
+ e.Side = t.Side, t.Side = n;
1674
+ }, e.Clipper.SwapPolyIndexes = function(e, t) {
1675
+ var n = e.OutIdx;
1676
+ e.OutIdx = t.OutIdx, t.OutIdx = n;
1677
+ }, e.Clipper.prototype.IntersectEdges = function(t, n, r, i) {
1678
+ var a = !i && t.NextInLML === null && t.Top.X == r.X && t.Top.Y == r.Y, o = !i && n.NextInLML === null && n.Top.X == r.X && n.Top.Y == r.Y, s = t.OutIdx >= 0, c = n.OutIdx >= 0;
1679
+ if (t.WindDelta === 0 || n.WindDelta === 0) {
1680
+ t.WindDelta === 0 && n.WindDelta === 0 ? (a || o) && s && c && this.AddLocalMaxPoly(t, n, r) : t.PolyTyp == n.PolyTyp && t.WindDelta != n.WindDelta && this.m_ClipType == e.ClipType.ctUnion ? t.WindDelta === 0 ? c && (this.AddOutPt(t, r), s && (t.OutIdx = -1)) : s && (this.AddOutPt(n, r), c && (n.OutIdx = -1)) : t.PolyTyp != n.PolyTyp && (t.WindDelta === 0 && Math.abs(n.WindCnt) == 1 && (this.m_ClipType != e.ClipType.ctUnion || n.WindCnt2 === 0) ? (this.AddOutPt(t, r), s && (t.OutIdx = -1)) : n.WindDelta === 0 && Math.abs(t.WindCnt) == 1 && (this.m_ClipType != e.ClipType.ctUnion || t.WindCnt2 === 0) && (this.AddOutPt(n, r), c && (n.OutIdx = -1))), a && (t.OutIdx < 0 ? this.DeleteFromAEL(t) : e.Error("Error intersecting polylines")), o && (n.OutIdx < 0 ? this.DeleteFromAEL(n) : e.Error("Error intersecting polylines"));
1681
+ return;
1682
+ }
1683
+ if (t.PolyTyp == n.PolyTyp) {
1684
+ if (this.IsEvenOddFillType(t)) {
1685
+ var l = t.WindCnt;
1686
+ t.WindCnt = n.WindCnt, n.WindCnt = l;
1687
+ } else t.WindCnt + n.WindDelta === 0 ? t.WindCnt = -t.WindCnt : t.WindCnt += n.WindDelta, n.WindCnt - t.WindDelta === 0 ? n.WindCnt = -n.WindCnt : n.WindCnt -= t.WindDelta;
1688
+ } else this.IsEvenOddFillType(n) ? t.WindCnt2 = +(t.WindCnt2 === 0) : t.WindCnt2 += n.WindDelta, this.IsEvenOddFillType(t) ? n.WindCnt2 = +(n.WindCnt2 === 0) : n.WindCnt2 -= t.WindDelta;
1689
+ var u, d, f, p;
1690
+ t.PolyTyp == e.PolyType.ptSubject ? (u = this.m_SubjFillType, f = this.m_ClipFillType) : (u = this.m_ClipFillType, f = this.m_SubjFillType), n.PolyTyp == e.PolyType.ptSubject ? (d = this.m_SubjFillType, p = this.m_ClipFillType) : (d = this.m_ClipFillType, p = this.m_SubjFillType);
1691
+ var m, h;
1692
+ switch (u) {
1693
+ case e.PolyFillType.pftPositive:
1694
+ m = t.WindCnt;
1695
+ break;
1696
+ case e.PolyFillType.pftNegative:
1697
+ m = -t.WindCnt;
1698
+ break;
1699
+ default: m = Math.abs(t.WindCnt);
1700
+ }
1701
+ switch (d) {
1702
+ case e.PolyFillType.pftPositive:
1703
+ h = n.WindCnt;
1704
+ break;
1705
+ case e.PolyFillType.pftNegative:
1706
+ h = -n.WindCnt;
1707
+ break;
1708
+ default: h = Math.abs(n.WindCnt);
1709
+ }
1710
+ if (s && c) a || o || m !== 0 && m != 1 || h !== 0 && h != 1 || t.PolyTyp != n.PolyTyp && this.m_ClipType != e.ClipType.ctXor ? this.AddLocalMaxPoly(t, n, r) : (this.AddOutPt(t, r), this.AddOutPt(n, r), e.Clipper.SwapSides(t, n), e.Clipper.SwapPolyIndexes(t, n));
1711
+ else if (s) (h === 0 || h == 1) && (this.AddOutPt(t, r), e.Clipper.SwapSides(t, n), e.Clipper.SwapPolyIndexes(t, n));
1712
+ else if (c) (m === 0 || m == 1) && (this.AddOutPt(n, r), e.Clipper.SwapSides(t, n), e.Clipper.SwapPolyIndexes(t, n));
1713
+ else if ((m === 0 || m == 1) && (h === 0 || h == 1) && !a && !o) {
1714
+ var g, _;
1715
+ switch (f) {
1716
+ case e.PolyFillType.pftPositive:
1717
+ g = t.WindCnt2;
1718
+ break;
1719
+ case e.PolyFillType.pftNegative:
1720
+ g = -t.WindCnt2;
1721
+ break;
1722
+ default: g = Math.abs(t.WindCnt2);
1723
+ }
1724
+ switch (p) {
1725
+ case e.PolyFillType.pftPositive:
1726
+ _ = n.WindCnt2;
1727
+ break;
1728
+ case e.PolyFillType.pftNegative:
1729
+ _ = -n.WindCnt2;
1730
+ break;
1731
+ default: _ = Math.abs(n.WindCnt2);
1732
+ }
1733
+ if (t.PolyTyp != n.PolyTyp) this.AddLocalMinPoly(t, n, r);
1734
+ else if (m == 1 && h == 1) switch (this.m_ClipType) {
1735
+ case e.ClipType.ctIntersection:
1736
+ g > 0 && _ > 0 && this.AddLocalMinPoly(t, n, r);
1737
+ break;
1738
+ case e.ClipType.ctUnion:
1739
+ g <= 0 && _ <= 0 && this.AddLocalMinPoly(t, n, r);
1740
+ break;
1741
+ case e.ClipType.ctDifference:
1742
+ (t.PolyTyp == e.PolyType.ptClip && g > 0 && _ > 0 || t.PolyTyp == e.PolyType.ptSubject && g <= 0 && _ <= 0) && this.AddLocalMinPoly(t, n, r);
1743
+ break;
1744
+ case e.ClipType.ctXor:
1745
+ this.AddLocalMinPoly(t, n, r);
1746
+ break;
1747
+ }
1748
+ else e.Clipper.SwapSides(t, n);
1749
+ }
1750
+ a != o && (a && t.OutIdx >= 0 || o && n.OutIdx >= 0) && (e.Clipper.SwapSides(t, n), e.Clipper.SwapPolyIndexes(t, n)), a && this.DeleteFromAEL(t), o && this.DeleteFromAEL(n);
1751
+ }, e.Clipper.prototype.DeleteFromAEL = function(e) {
1752
+ var t = e.PrevInAEL, n = e.NextInAEL;
1753
+ (t !== null || n !== null || e == this.m_ActiveEdges) && (t === null ? this.m_ActiveEdges = n : t.NextInAEL = n, n !== null && (n.PrevInAEL = t), e.NextInAEL = null, e.PrevInAEL = null);
1754
+ }, e.Clipper.prototype.DeleteFromSEL = function(e) {
1755
+ var t = e.PrevInSEL, n = e.NextInSEL;
1756
+ (t !== null || n !== null || e == this.m_SortedEdges) && (t === null ? this.m_SortedEdges = n : t.NextInSEL = n, n !== null && (n.PrevInSEL = t), e.NextInSEL = null, e.PrevInSEL = null);
1757
+ }, e.Clipper.prototype.UpdateEdgeIntoAEL = function(t) {
1758
+ t.NextInLML === null && e.Error("UpdateEdgeIntoAEL: invalid call");
1759
+ var n = t.PrevInAEL, r = t.NextInAEL;
1760
+ return t.NextInLML.OutIdx = t.OutIdx, n === null ? this.m_ActiveEdges = t.NextInLML : n.NextInAEL = t.NextInLML, r !== null && (r.PrevInAEL = t.NextInLML), t.NextInLML.Side = t.Side, t.NextInLML.WindDelta = t.WindDelta, t.NextInLML.WindCnt = t.WindCnt, t.NextInLML.WindCnt2 = t.WindCnt2, t = t.NextInLML, t.Curr.X = t.Bot.X, t.Curr.Y = t.Bot.Y, t.PrevInAEL = n, t.NextInAEL = r, e.ClipperBase.IsHorizontal(t) || this.InsertScanbeam(t.Top.Y), t;
1761
+ }, e.Clipper.prototype.ProcessHorizontals = function(e) {
1762
+ for (var t = this.m_SortedEdges; t !== null;) this.DeleteFromSEL(t), this.ProcessHorizontal(t, e), t = this.m_SortedEdges;
1763
+ }, e.Clipper.prototype.GetHorzDirection = function(t, n) {
1764
+ t.Bot.X < t.Top.X ? (n.Left = t.Bot.X, n.Right = t.Top.X, n.Dir = e.Direction.dLeftToRight) : (n.Left = t.Top.X, n.Right = t.Bot.X, n.Dir = e.Direction.dRightToLeft);
1765
+ }, e.Clipper.prototype.PrepareHorzJoins = function(t, n) {
1766
+ var r = this.m_PolyOuts[t.OutIdx].Pts;
1767
+ t.Side != e.EdgeSide.esLeft && (r = r.Prev), n && (e.IntPoint.op_Equality(r.Pt, t.Top) ? this.AddGhostJoin(r, t.Bot) : this.AddGhostJoin(r, t.Top));
1768
+ }, e.Clipper.prototype.ProcessHorizontal = function(t, n) {
1769
+ var r = {
1770
+ Dir: null,
1771
+ Left: null,
1772
+ Right: null
1773
+ };
1774
+ this.GetHorzDirection(t, r);
1775
+ for (var i = r.Dir, a = r.Left, o = r.Right, s = t, c = null; s.NextInLML !== null && e.ClipperBase.IsHorizontal(s.NextInLML);) s = s.NextInLML;
1776
+ for (s.NextInLML === null && (c = this.GetMaximaPair(s));;) {
1777
+ for (var l = t == s, u = this.GetNextInAEL(t, i); u !== null && !(u.Curr.X == t.Top.X && t.NextInLML !== null && u.Dx < t.NextInLML.Dx);) {
1778
+ var d = this.GetNextInAEL(u, i);
1779
+ if (i == e.Direction.dLeftToRight && u.Curr.X <= o || i == e.Direction.dRightToLeft && u.Curr.X >= a) {
1780
+ if (t.OutIdx >= 0 && t.WindDelta != 0 && this.PrepareHorzJoins(t, n), u == c && l) {
1781
+ i == e.Direction.dLeftToRight ? this.IntersectEdges(t, u, u.Top, !1) : this.IntersectEdges(u, t, u.Top, !1), c.OutIdx >= 0 && e.Error("ProcessHorizontal error");
1782
+ return;
1783
+ }
1784
+ if (i == e.Direction.dLeftToRight) {
1785
+ var f = new e.IntPoint(u.Curr.X, t.Curr.Y);
1786
+ this.IntersectEdges(t, u, f, !0);
1787
+ } else {
1788
+ var f = new e.IntPoint(u.Curr.X, t.Curr.Y);
1789
+ this.IntersectEdges(u, t, f, !0);
1790
+ }
1791
+ this.SwapPositionsInAEL(t, u);
1792
+ } else if (i == e.Direction.dLeftToRight && u.Curr.X >= o || i == e.Direction.dRightToLeft && u.Curr.X <= a) break;
1793
+ u = d;
1794
+ }
1795
+ if (t.OutIdx >= 0 && t.WindDelta !== 0 && this.PrepareHorzJoins(t, n), t.NextInLML !== null && e.ClipperBase.IsHorizontal(t.NextInLML)) {
1796
+ t = this.UpdateEdgeIntoAEL(t), t.OutIdx >= 0 && this.AddOutPt(t, t.Bot);
1797
+ var r = {
1798
+ Dir: i,
1799
+ Left: a,
1800
+ Right: o
1801
+ };
1802
+ this.GetHorzDirection(t, r), i = r.Dir, a = r.Left, o = r.Right;
1803
+ } else break;
1804
+ }
1805
+ if (t.NextInLML !== null) {
1806
+ if (t.OutIdx >= 0) {
1807
+ var p = this.AddOutPt(t, t.Top);
1808
+ if (t = this.UpdateEdgeIntoAEL(t), t.WindDelta === 0) return;
1809
+ var m = t.PrevInAEL, d = t.NextInAEL;
1810
+ if (m !== null && m.Curr.X == t.Bot.X && m.Curr.Y == t.Bot.Y && m.WindDelta !== 0 && m.OutIdx >= 0 && m.Curr.Y > m.Top.Y && e.ClipperBase.SlopesEqual(t, m, this.m_UseFullRange)) {
1811
+ var h = this.AddOutPt(m, t.Bot);
1812
+ this.AddJoin(p, h, t.Top);
1813
+ } else if (d !== null && d.Curr.X == t.Bot.X && d.Curr.Y == t.Bot.Y && d.WindDelta !== 0 && d.OutIdx >= 0 && d.Curr.Y > d.Top.Y && e.ClipperBase.SlopesEqual(t, d, this.m_UseFullRange)) {
1814
+ var h = this.AddOutPt(d, t.Bot);
1815
+ this.AddJoin(p, h, t.Top);
1816
+ }
1817
+ } else t = this.UpdateEdgeIntoAEL(t);
1818
+ } else c === null ? (t.OutIdx >= 0 && this.AddOutPt(t, t.Top), this.DeleteFromAEL(t)) : c.OutIdx >= 0 ? (i == e.Direction.dLeftToRight ? this.IntersectEdges(t, c, t.Top, !1) : this.IntersectEdges(c, t, t.Top, !1), c.OutIdx >= 0 && e.Error("ProcessHorizontal error")) : (this.DeleteFromAEL(t), this.DeleteFromAEL(c));
1819
+ }, e.Clipper.prototype.GetNextInAEL = function(t, n) {
1820
+ return n == e.Direction.dLeftToRight ? t.NextInAEL : t.PrevInAEL;
1821
+ }, e.Clipper.prototype.IsMinima = function(e) {
1822
+ return e !== null && e.Prev.NextInLML != e && e.Next.NextInLML != e;
1823
+ }, e.Clipper.prototype.IsMaxima = function(e, t) {
1824
+ return e !== null && e.Top.Y == t && e.NextInLML === null;
1825
+ }, e.Clipper.prototype.IsIntermediate = function(e, t) {
1826
+ return e.Top.Y == t && e.NextInLML !== null;
1827
+ }, e.Clipper.prototype.GetMaximaPair = function(t) {
1828
+ var n = null;
1829
+ return e.IntPoint.op_Equality(t.Next.Top, t.Top) && t.Next.NextInLML === null ? n = t.Next : e.IntPoint.op_Equality(t.Prev.Top, t.Top) && t.Prev.NextInLML === null && (n = t.Prev), n !== null && (n.OutIdx == -2 || n.NextInAEL == n.PrevInAEL && !e.ClipperBase.IsHorizontal(n)) ? null : n;
1830
+ }, e.Clipper.prototype.ProcessIntersections = function(t, n) {
1831
+ if (this.m_ActiveEdges == null) return !0;
1832
+ try {
1833
+ if (this.BuildIntersectList(t, n), this.m_IntersectList.length == 0) return !0;
1834
+ if (this.m_IntersectList.length == 1 || this.FixupIntersectionOrder()) this.ProcessIntersectList();
1835
+ else return !1;
1836
+ } catch {
1837
+ this.m_SortedEdges = null, this.m_IntersectList.length = 0, e.Error("ProcessIntersections error");
1838
+ }
1839
+ return this.m_SortedEdges = null, !0;
1840
+ }, e.Clipper.prototype.BuildIntersectList = function(t, n) {
1841
+ if (this.m_ActiveEdges !== null) {
1842
+ var r = this.m_ActiveEdges;
1843
+ for (this.m_SortedEdges = r; r !== null;) r.PrevInSEL = r.PrevInAEL, r.NextInSEL = r.NextInAEL, r.Curr.X = e.Clipper.TopX(r, n), r = r.NextInAEL;
1844
+ for (var i = !0; i && this.m_SortedEdges !== null;) {
1845
+ for (i = !1, r = this.m_SortedEdges; r.NextInSEL !== null;) {
1846
+ var a = r.NextInSEL, o = new e.IntPoint();
1847
+ if (r.Curr.X > a.Curr.X) {
1848
+ !this.IntersectPoint(r, a, o) && r.Curr.X > a.Curr.X + 1 && e.Error("Intersection error"), o.Y > t && (o.Y = t, o.X = Math.abs(r.Dx) > Math.abs(a.Dx) ? e.Clipper.TopX(a, t) : e.Clipper.TopX(r, t));
1849
+ var s = new e.IntersectNode();
1850
+ s.Edge1 = r, s.Edge2 = a, s.Pt.X = o.X, s.Pt.Y = o.Y, this.m_IntersectList.push(s), this.SwapPositionsInSEL(r, a), i = !0;
1851
+ } else r = a;
1852
+ }
1853
+ if (r.PrevInSEL !== null) r.PrevInSEL.NextInSEL = null;
1854
+ else break;
1855
+ }
1856
+ this.m_SortedEdges = null;
1857
+ }
1858
+ }, e.Clipper.prototype.EdgesAdjacent = function(e) {
1859
+ return e.Edge1.NextInSEL == e.Edge2 || e.Edge1.PrevInSEL == e.Edge2;
1860
+ }, e.Clipper.IntersectNodeSort = function(e, t) {
1861
+ return t.Pt.Y - e.Pt.Y;
1862
+ }, e.Clipper.prototype.FixupIntersectionOrder = function() {
1863
+ this.m_IntersectList.sort(this.m_IntersectNodeComparer), this.CopyAELToSEL();
1864
+ for (var e = this.m_IntersectList.length, t = 0; t < e; t++) {
1865
+ if (!this.EdgesAdjacent(this.m_IntersectList[t])) {
1866
+ for (var n = t + 1; n < e && !this.EdgesAdjacent(this.m_IntersectList[n]);) n++;
1867
+ if (n == e) return !1;
1868
+ var r = this.m_IntersectList[t];
1869
+ this.m_IntersectList[t] = this.m_IntersectList[n], this.m_IntersectList[n] = r;
1870
+ }
1871
+ this.SwapPositionsInSEL(this.m_IntersectList[t].Edge1, this.m_IntersectList[t].Edge2);
1872
+ }
1873
+ return !0;
1874
+ }, e.Clipper.prototype.ProcessIntersectList = function() {
1875
+ for (var e = 0, t = this.m_IntersectList.length; e < t; e++) {
1876
+ var n = this.m_IntersectList[e];
1877
+ this.IntersectEdges(n.Edge1, n.Edge2, n.Pt, !0), this.SwapPositionsInAEL(n.Edge1, n.Edge2);
1878
+ }
1879
+ this.m_IntersectList.length = 0;
1880
+ };
1881
+ var Tt = function(e) {
1882
+ return e < 0 ? Math.ceil(e - .5) : Math.round(e);
1883
+ }, Et = function(e) {
1884
+ return e < 0 ? Math.ceil(e - .5) : Math.floor(e + .5);
1885
+ }, Dt = function(e) {
1886
+ return e < 0 ? -Math.round(Math.abs(e)) : Math.round(e);
1887
+ }, Ot = function(e) {
1888
+ return e < 0 ? (e -= .5, e < -2147483648 ? Math.ceil(e) : e | 0) : (e += .5, e > 2147483647 ? Math.floor(e) : e | 0);
1889
+ };
1890
+ a.msie ? e.Clipper.Round = Tt : a.chromium ? e.Clipper.Round = Dt : a.safari ? e.Clipper.Round = Ot : e.Clipper.Round = Et, e.Clipper.TopX = function(t, n) {
1891
+ return n == t.Top.Y ? t.Top.X : t.Bot.X + e.Clipper.Round(t.Dx * (n - t.Bot.Y));
1892
+ }, e.Clipper.prototype.IntersectPoint = function(t, n, r) {
1893
+ r.X = 0, r.Y = 0;
1894
+ var i, a;
1895
+ if (e.ClipperBase.SlopesEqual(t, n, this.m_UseFullRange) || t.Dx == n.Dx) return n.Bot.Y > t.Bot.Y ? (r.X = n.Bot.X, r.Y = n.Bot.Y) : (r.X = t.Bot.X, r.Y = t.Bot.Y), !1;
1896
+ if (t.Delta.X === 0) r.X = t.Bot.X, e.ClipperBase.IsHorizontal(n) ? r.Y = n.Bot.Y : (a = n.Bot.Y - n.Bot.X / n.Dx, r.Y = e.Clipper.Round(r.X / n.Dx + a));
1897
+ else if (n.Delta.X === 0) r.X = n.Bot.X, e.ClipperBase.IsHorizontal(t) ? r.Y = t.Bot.Y : (i = t.Bot.Y - t.Bot.X / t.Dx, r.Y = e.Clipper.Round(r.X / t.Dx + i));
1898
+ else {
1899
+ i = t.Bot.X - t.Bot.Y * t.Dx, a = n.Bot.X - n.Bot.Y * n.Dx;
1900
+ var o = (a - i) / (t.Dx - n.Dx);
1901
+ r.Y = e.Clipper.Round(o), r.X = Math.abs(t.Dx) < Math.abs(n.Dx) ? e.Clipper.Round(t.Dx * o + i) : e.Clipper.Round(n.Dx * o + a);
1902
+ }
1903
+ if (r.Y < t.Top.Y || r.Y < n.Top.Y) {
1904
+ if (t.Top.Y > n.Top.Y) return r.Y = t.Top.Y, r.X = e.Clipper.TopX(n, t.Top.Y), r.X < t.Top.X;
1905
+ r.Y = n.Top.Y, r.X = Math.abs(t.Dx) < Math.abs(n.Dx) ? e.Clipper.TopX(t, r.Y) : e.Clipper.TopX(n, r.Y);
1906
+ }
1907
+ return !0;
1908
+ }, e.Clipper.prototype.ProcessEdgesAtTopOfScanbeam = function(t) {
1909
+ for (var n = this.m_ActiveEdges; n !== null;) {
1910
+ var r = this.IsMaxima(n, t);
1911
+ if (r) {
1912
+ var i = this.GetMaximaPair(n);
1913
+ r = i === null || !e.ClipperBase.IsHorizontal(i);
1914
+ }
1915
+ if (r) {
1916
+ var a = n.PrevInAEL;
1917
+ this.DoMaxima(n), n = a === null ? this.m_ActiveEdges : a.NextInAEL;
1918
+ } else {
1919
+ if (this.IsIntermediate(n, t) && e.ClipperBase.IsHorizontal(n.NextInLML) ? (n = this.UpdateEdgeIntoAEL(n), n.OutIdx >= 0 && this.AddOutPt(n, n.Bot), this.AddEdgeToSEL(n)) : (n.Curr.X = e.Clipper.TopX(n, t), n.Curr.Y = t), this.StrictlySimple) {
1920
+ var a = n.PrevInAEL;
1921
+ if (n.OutIdx >= 0 && n.WindDelta !== 0 && a !== null && a.OutIdx >= 0 && a.Curr.X == n.Curr.X && a.WindDelta !== 0) {
1922
+ var o = this.AddOutPt(a, n.Curr), s = this.AddOutPt(n, n.Curr);
1923
+ this.AddJoin(o, s, n.Curr);
1924
+ }
1925
+ }
1926
+ n = n.NextInAEL;
1927
+ }
1928
+ }
1929
+ for (this.ProcessHorizontals(!0), n = this.m_ActiveEdges; n !== null;) {
1930
+ if (this.IsIntermediate(n, t)) {
1931
+ var o = null;
1932
+ n.OutIdx >= 0 && (o = this.AddOutPt(n, n.Top)), n = this.UpdateEdgeIntoAEL(n);
1933
+ var a = n.PrevInAEL, c = n.NextInAEL;
1934
+ if (a !== null && a.Curr.X == n.Bot.X && a.Curr.Y == n.Bot.Y && o !== null && a.OutIdx >= 0 && a.Curr.Y > a.Top.Y && e.ClipperBase.SlopesEqual(n, a, this.m_UseFullRange) && n.WindDelta !== 0 && a.WindDelta !== 0) {
1935
+ var s = this.AddOutPt(a, n.Bot);
1936
+ this.AddJoin(o, s, n.Top);
1937
+ } else if (c !== null && c.Curr.X == n.Bot.X && c.Curr.Y == n.Bot.Y && o !== null && c.OutIdx >= 0 && c.Curr.Y > c.Top.Y && e.ClipperBase.SlopesEqual(n, c, this.m_UseFullRange) && n.WindDelta !== 0 && c.WindDelta !== 0) {
1938
+ var s = this.AddOutPt(c, n.Bot);
1939
+ this.AddJoin(o, s, n.Top);
1940
+ }
1941
+ }
1942
+ n = n.NextInAEL;
1943
+ }
1944
+ }, e.Clipper.prototype.DoMaxima = function(t) {
1945
+ var n = this.GetMaximaPair(t);
1946
+ if (n === null) {
1947
+ t.OutIdx >= 0 && this.AddOutPt(t, t.Top), this.DeleteFromAEL(t);
1948
+ return;
1949
+ }
1950
+ for (var r = t.NextInAEL, i = !0; r !== null && r != n;) this.IntersectEdges(t, r, t.Top, !0), this.SwapPositionsInAEL(t, r), r = t.NextInAEL;
1951
+ t.OutIdx == -1 && n.OutIdx == -1 ? (this.DeleteFromAEL(t), this.DeleteFromAEL(n)) : t.OutIdx >= 0 && n.OutIdx >= 0 ? this.IntersectEdges(t, n, t.Top, !1) : i && t.WindDelta === 0 ? (t.OutIdx >= 0 && (this.AddOutPt(t, t.Top), t.OutIdx = -1), this.DeleteFromAEL(t), n.OutIdx >= 0 && (this.AddOutPt(n, t.Top), n.OutIdx = -1), this.DeleteFromAEL(n)) : e.Error("DoMaxima error");
1952
+ }, e.Clipper.ReversePaths = function(e) {
1953
+ for (var t = 0, n = e.length; t < n; t++) e[t].reverse();
1954
+ }, e.Clipper.Orientation = function(t) {
1955
+ return e.Clipper.Area(t) >= 0;
1956
+ }, e.Clipper.prototype.PointCount = function(e) {
1957
+ if (e === null) return 0;
1958
+ var t = 0, n = e;
1959
+ do
1960
+ t++, n = n.Next;
1961
+ while (n != e);
1962
+ return t;
1963
+ }, e.Clipper.prototype.BuildResult = function(t) {
1964
+ e.Clear(t);
1965
+ for (var n = 0, r = this.m_PolyOuts.length; n < r; n++) {
1966
+ var i = this.m_PolyOuts[n];
1967
+ if (i.Pts !== null) {
1968
+ var a = i.Pts.Prev, o = this.PointCount(a);
1969
+ if (!(o < 2)) {
1970
+ for (var s = Array(o), c = 0; c < o; c++) s[c] = a.Pt, a = a.Prev;
1971
+ t.push(s);
1972
+ }
1973
+ }
1974
+ }
1975
+ }, e.Clipper.prototype.BuildResult2 = function(t) {
1976
+ t.Clear();
1977
+ for (var n = 0, r = this.m_PolyOuts.length; n < r; n++) {
1978
+ var i = this.m_PolyOuts[n], a = this.PointCount(i.Pts);
1979
+ if (!(i.IsOpen && a < 2 || !i.IsOpen && a < 3)) {
1980
+ this.FixHoleLinkage(i);
1981
+ var o = new e.PolyNode();
1982
+ t.m_AllPolys.push(o), i.PolyNode = o, o.m_polygon.length = a;
1983
+ for (var s = i.Pts.Prev, c = 0; c < a; c++) o.m_polygon[c] = s.Pt, s = s.Prev;
1984
+ }
1985
+ }
1986
+ for (var n = 0, r = this.m_PolyOuts.length; n < r; n++) {
1987
+ var i = this.m_PolyOuts[n];
1988
+ i.PolyNode !== null && (i.IsOpen ? (i.PolyNode.IsOpen = !0, t.AddChild(i.PolyNode)) : i.FirstLeft !== null && i.FirstLeft.PolyNode != null ? i.FirstLeft.PolyNode.AddChild(i.PolyNode) : t.AddChild(i.PolyNode));
1989
+ }
1990
+ }, e.Clipper.prototype.FixupOutPolygon = function(t) {
1991
+ var n = null;
1992
+ t.BottomPt = null;
1993
+ for (var r = t.Pts;;) {
1994
+ if (r.Prev == r || r.Prev == r.Next) {
1995
+ this.DisposeOutPts(r), t.Pts = null;
1996
+ return;
1997
+ }
1998
+ if (e.IntPoint.op_Equality(r.Pt, r.Next.Pt) || e.IntPoint.op_Equality(r.Pt, r.Prev.Pt) || e.ClipperBase.SlopesEqual(r.Prev.Pt, r.Pt, r.Next.Pt, this.m_UseFullRange) && (!this.PreserveCollinear || !this.Pt2IsBetweenPt1AndPt3(r.Prev.Pt, r.Pt, r.Next.Pt))) n = null, r.Prev.Next = r.Next, r.Next.Prev = r.Prev, r = r.Prev;
1999
+ else if (r == n) break;
2000
+ else n === null && (n = r), r = r.Next;
2001
+ }
2002
+ t.Pts = r;
2003
+ }, e.Clipper.prototype.DupOutPt = function(t, n) {
2004
+ var r = new e.OutPt();
2005
+ return r.Pt.X = t.Pt.X, r.Pt.Y = t.Pt.Y, r.Idx = t.Idx, n ? (r.Next = t.Next, r.Prev = t, t.Next.Prev = r, t.Next = r) : (r.Prev = t.Prev, r.Next = t, t.Prev.Next = r, t.Prev = r), r;
2006
+ }, e.Clipper.prototype.GetOverlap = function(e, t, n, r, i) {
2007
+ return e < t ? n < r ? (i.Left = Math.max(e, n), i.Right = Math.min(t, r)) : (i.Left = Math.max(e, r), i.Right = Math.min(t, n)) : n < r ? (i.Left = Math.max(t, n), i.Right = Math.min(e, r)) : (i.Left = Math.max(t, r), i.Right = Math.min(e, n)), i.Left < i.Right;
2008
+ }, e.Clipper.prototype.JoinHorz = function(t, n, r, i, a, o) {
2009
+ var s = t.Pt.X > n.Pt.X ? e.Direction.dRightToLeft : e.Direction.dLeftToRight, c = r.Pt.X > i.Pt.X ? e.Direction.dRightToLeft : e.Direction.dLeftToRight;
2010
+ if (s == c) return !1;
2011
+ if (s == e.Direction.dLeftToRight) {
2012
+ for (; t.Next.Pt.X <= a.X && t.Next.Pt.X >= t.Pt.X && t.Next.Pt.Y == a.Y;) t = t.Next;
2013
+ o && t.Pt.X != a.X && (t = t.Next), n = this.DupOutPt(t, !o), e.IntPoint.op_Inequality(n.Pt, a) && (t = n, t.Pt.X = a.X, t.Pt.Y = a.Y, n = this.DupOutPt(t, !o));
2014
+ } else {
2015
+ for (; t.Next.Pt.X >= a.X && t.Next.Pt.X <= t.Pt.X && t.Next.Pt.Y == a.Y;) t = t.Next;
2016
+ !o && t.Pt.X != a.X && (t = t.Next), n = this.DupOutPt(t, o), e.IntPoint.op_Inequality(n.Pt, a) && (t = n, t.Pt.X = a.X, t.Pt.Y = a.Y, n = this.DupOutPt(t, o));
2017
+ }
2018
+ if (c == e.Direction.dLeftToRight) {
2019
+ for (; r.Next.Pt.X <= a.X && r.Next.Pt.X >= r.Pt.X && r.Next.Pt.Y == a.Y;) r = r.Next;
2020
+ o && r.Pt.X != a.X && (r = r.Next), i = this.DupOutPt(r, !o), e.IntPoint.op_Inequality(i.Pt, a) && (r = i, r.Pt.X = a.X, r.Pt.Y = a.Y, i = this.DupOutPt(r, !o));
2021
+ } else {
2022
+ for (; r.Next.Pt.X >= a.X && r.Next.Pt.X <= r.Pt.X && r.Next.Pt.Y == a.Y;) r = r.Next;
2023
+ !o && r.Pt.X != a.X && (r = r.Next), i = this.DupOutPt(r, o), e.IntPoint.op_Inequality(i.Pt, a) && (r = i, r.Pt.X = a.X, r.Pt.Y = a.Y, i = this.DupOutPt(r, o));
2024
+ }
2025
+ return s == e.Direction.dLeftToRight == o ? (t.Prev = r, r.Next = t, n.Next = i, i.Prev = n) : (t.Next = r, r.Prev = t, n.Prev = i, i.Next = n), !0;
2026
+ }, e.Clipper.prototype.JoinPoints = function(t, n, r) {
2027
+ var i = t.OutPt1, a = new e.OutPt(), o = t.OutPt2, s = new e.OutPt(), c = t.OutPt1.Pt.Y == t.OffPt.Y;
2028
+ if (c && e.IntPoint.op_Equality(t.OffPt, t.OutPt1.Pt) && e.IntPoint.op_Equality(t.OffPt, t.OutPt2.Pt)) {
2029
+ for (a = t.OutPt1.Next; a != i && e.IntPoint.op_Equality(a.Pt, t.OffPt);) a = a.Next;
2030
+ var l = a.Pt.Y > t.OffPt.Y;
2031
+ for (s = t.OutPt2.Next; s != o && e.IntPoint.op_Equality(s.Pt, t.OffPt);) s = s.Next;
2032
+ return l == s.Pt.Y > t.OffPt.Y ? !1 : l ? (a = this.DupOutPt(i, !1), s = this.DupOutPt(o, !0), i.Prev = o, o.Next = i, a.Next = s, s.Prev = a, t.OutPt1 = i, t.OutPt2 = a, !0) : (a = this.DupOutPt(i, !0), s = this.DupOutPt(o, !1), i.Next = o, o.Prev = i, a.Prev = s, s.Next = a, t.OutPt1 = i, t.OutPt2 = a, !0);
2033
+ }
2034
+ if (c) {
2035
+ for (a = i; i.Prev.Pt.Y == i.Pt.Y && i.Prev != a && i.Prev != o;) i = i.Prev;
2036
+ for (; a.Next.Pt.Y == a.Pt.Y && a.Next != i && a.Next != o;) a = a.Next;
2037
+ if (a.Next == i || a.Next == o) return !1;
2038
+ for (s = o; o.Prev.Pt.Y == o.Pt.Y && o.Prev != s && o.Prev != a;) o = o.Prev;
2039
+ for (; s.Next.Pt.Y == s.Pt.Y && s.Next != o && s.Next != i;) s = s.Next;
2040
+ if (s.Next == o || s.Next == i) return !1;
2041
+ var u = {
2042
+ Left: null,
2043
+ Right: null
2044
+ };
2045
+ if (!this.GetOverlap(i.Pt.X, a.Pt.X, o.Pt.X, s.Pt.X, u)) return !1;
2046
+ var d = u.Left, f = u.Right, p = new e.IntPoint(), m;
2047
+ return i.Pt.X >= d && i.Pt.X <= f ? (p.X = i.Pt.X, p.Y = i.Pt.Y, m = i.Pt.X > a.Pt.X) : o.Pt.X >= d && o.Pt.X <= f ? (p.X = o.Pt.X, p.Y = o.Pt.Y, m = o.Pt.X > s.Pt.X) : a.Pt.X >= d && a.Pt.X <= f ? (p.X = a.Pt.X, p.Y = a.Pt.Y, m = a.Pt.X > i.Pt.X) : (p.X = s.Pt.X, p.Y = s.Pt.Y, m = s.Pt.X > o.Pt.X), t.OutPt1 = i, t.OutPt2 = o, this.JoinHorz(i, a, o, s, p, m);
2048
+ }
2049
+ for (a = i.Next; e.IntPoint.op_Equality(a.Pt, i.Pt) && a != i;) a = a.Next;
2050
+ var h = a.Pt.Y > i.Pt.Y || !e.ClipperBase.SlopesEqual(i.Pt, a.Pt, t.OffPt, this.m_UseFullRange);
2051
+ if (h) {
2052
+ for (a = i.Prev; e.IntPoint.op_Equality(a.Pt, i.Pt) && a != i;) a = a.Prev;
2053
+ if (a.Pt.Y > i.Pt.Y || !e.ClipperBase.SlopesEqual(i.Pt, a.Pt, t.OffPt, this.m_UseFullRange)) return !1;
2054
+ }
2055
+ for (s = o.Next; e.IntPoint.op_Equality(s.Pt, o.Pt) && s != o;) s = s.Next;
2056
+ var g = s.Pt.Y > o.Pt.Y || !e.ClipperBase.SlopesEqual(o.Pt, s.Pt, t.OffPt, this.m_UseFullRange);
2057
+ if (g) {
2058
+ for (s = o.Prev; e.IntPoint.op_Equality(s.Pt, o.Pt) && s != o;) s = s.Prev;
2059
+ if (s.Pt.Y > o.Pt.Y || !e.ClipperBase.SlopesEqual(o.Pt, s.Pt, t.OffPt, this.m_UseFullRange)) return !1;
2060
+ }
2061
+ return a == i || s == o || a == s || n == r && h == g ? !1 : h ? (a = this.DupOutPt(i, !1), s = this.DupOutPt(o, !0), i.Prev = o, o.Next = i, a.Next = s, s.Prev = a, t.OutPt1 = i, t.OutPt2 = a, !0) : (a = this.DupOutPt(i, !0), s = this.DupOutPt(o, !1), i.Next = o, o.Prev = i, a.Prev = s, s.Next = a, t.OutPt1 = i, t.OutPt2 = a, !0);
2062
+ }, e.Clipper.GetBounds = function(t) {
2063
+ for (var n = 0, r = t.length; n < r && t[n].length == 0;) n++;
2064
+ if (n == r) return new e.IntRect(0, 0, 0, 0);
2065
+ var i = new e.IntRect();
2066
+ for (i.left = t[n][0].X, i.right = i.left, i.top = t[n][0].Y, i.bottom = i.top; n < r; n++) for (var a = 0, o = t[n].length; a < o; a++) t[n][a].X < i.left ? i.left = t[n][a].X : t[n][a].X > i.right && (i.right = t[n][a].X), t[n][a].Y < i.top ? i.top = t[n][a].Y : t[n][a].Y > i.bottom && (i.bottom = t[n][a].Y);
2067
+ return i;
2068
+ }, e.Clipper.prototype.GetBounds2 = function(t) {
2069
+ var n = t, r = new e.IntRect();
2070
+ for (r.left = t.Pt.X, r.right = t.Pt.X, r.top = t.Pt.Y, r.bottom = t.Pt.Y, t = t.Next; t != n;) t.Pt.X < r.left && (r.left = t.Pt.X), t.Pt.X > r.right && (r.right = t.Pt.X), t.Pt.Y < r.top && (r.top = t.Pt.Y), t.Pt.Y > r.bottom && (r.bottom = t.Pt.Y), t = t.Next;
2071
+ return r;
2072
+ }, e.Clipper.PointInPolygon = function(e, t) {
2073
+ var n = 0, r = t.length;
2074
+ if (r < 3) return 0;
2075
+ for (var i = t[0], a = 1; a <= r; ++a) {
2076
+ var o = a == r ? t[0] : t[a];
2077
+ if (o.Y == e.Y && (o.X == e.X || i.Y == e.Y && o.X > e.X == i.X < e.X)) return -1;
2078
+ if (i.Y < e.Y != o.Y < e.Y) {
2079
+ if (i.X >= e.X) {
2080
+ if (o.X > e.X) n = 1 - n;
2081
+ else {
2082
+ var s = (i.X - e.X) * (o.Y - e.Y) - (o.X - e.X) * (i.Y - e.Y);
2083
+ if (s == 0) return -1;
2084
+ s > 0 == o.Y > i.Y && (n = 1 - n);
2085
+ }
2086
+ } else if (o.X > e.X) {
2087
+ var s = (i.X - e.X) * (o.Y - e.Y) - (o.X - e.X) * (i.Y - e.Y);
2088
+ if (s == 0) return -1;
2089
+ s > 0 == o.Y > i.Y && (n = 1 - n);
2090
+ }
2091
+ }
2092
+ i = o;
2093
+ }
2094
+ return n;
2095
+ }, e.Clipper.prototype.PointInPolygon = function(e, t) {
2096
+ for (var n = 0, r = t;;) {
2097
+ var i = t.Pt.X, a = t.Pt.Y, o = t.Next.Pt.X, s = t.Next.Pt.Y;
2098
+ if (s == e.Y && (o == e.X || a == e.Y && o > e.X == i < e.X)) return -1;
2099
+ if (a < e.Y != s < e.Y) {
2100
+ if (i >= e.X) {
2101
+ if (o > e.X) n = 1 - n;
2102
+ else {
2103
+ var c = (i - e.X) * (s - e.Y) - (o - e.X) * (a - e.Y);
2104
+ if (c == 0) return -1;
2105
+ c > 0 == s > a && (n = 1 - n);
2106
+ }
2107
+ } else if (o > e.X) {
2108
+ var c = (i - e.X) * (s - e.Y) - (o - e.X) * (a - e.Y);
2109
+ if (c == 0) return -1;
2110
+ c > 0 == s > a && (n = 1 - n);
2111
+ }
2112
+ }
2113
+ if (t = t.Next, r == t) break;
2114
+ }
2115
+ return n;
2116
+ }, e.Clipper.prototype.Poly2ContainsPoly1 = function(e, t) {
2117
+ var n = e;
2118
+ do {
2119
+ var r = this.PointInPolygon(n.Pt, t);
2120
+ if (r >= 0) return r != 0;
2121
+ n = n.Next;
2122
+ } while (n != e);
2123
+ return !0;
2124
+ }, e.Clipper.prototype.FixupFirstLefts1 = function(e, t) {
2125
+ for (var n = 0, r = this.m_PolyOuts.length; n < r; n++) {
2126
+ var i = this.m_PolyOuts[n];
2127
+ i.Pts !== null && i.FirstLeft == e && this.Poly2ContainsPoly1(i.Pts, t.Pts) && (i.FirstLeft = t);
2128
+ }
2129
+ }, e.Clipper.prototype.FixupFirstLefts2 = function(e, t) {
2130
+ for (var n = 0, r = this.m_PolyOuts, i = r.length, a = r[n]; n < i; n++, a = r[n]) a.FirstLeft == e && (a.FirstLeft = t);
2131
+ }, e.Clipper.ParseFirstLeft = function(e) {
2132
+ for (; e != null && e.Pts == null;) e = e.FirstLeft;
2133
+ return e;
2134
+ }, e.Clipper.prototype.JoinCommonEdges = function() {
2135
+ for (var t = 0, n = this.m_Joins.length; t < n; t++) {
2136
+ var r = this.m_Joins[t], i = this.GetOutRec(r.OutPt1.Idx), a = this.GetOutRec(r.OutPt2.Idx);
2137
+ if (i.Pts != null && a.Pts != null) {
2138
+ var o = i == a ? i : this.Param1RightOfParam2(i, a) ? a : this.Param1RightOfParam2(a, i) ? i : this.GetLowermostRec(i, a);
2139
+ if (this.JoinPoints(r, i, a)) {
2140
+ if (i == a) {
2141
+ if (i.Pts = r.OutPt1, i.BottomPt = null, a = this.CreateOutRec(), a.Pts = r.OutPt2, this.UpdateOutPtIdxs(a), this.m_UsingPolyTree) for (var s = 0, c = this.m_PolyOuts.length; s < c - 1; s++) {
2142
+ var l = this.m_PolyOuts[s];
2143
+ l.Pts != null && e.Clipper.ParseFirstLeft(l.FirstLeft) == i && l.IsHole != i.IsHole && this.Poly2ContainsPoly1(l.Pts, r.OutPt2) && (l.FirstLeft = a);
2144
+ }
2145
+ this.Poly2ContainsPoly1(a.Pts, i.Pts) ? (a.IsHole = !i.IsHole, a.FirstLeft = i, this.m_UsingPolyTree && this.FixupFirstLefts2(a, i), (a.IsHole ^ this.ReverseSolution) == this.Area(a) > 0 && this.ReversePolyPtLinks(a.Pts)) : this.Poly2ContainsPoly1(i.Pts, a.Pts) ? (a.IsHole = i.IsHole, i.IsHole = !a.IsHole, a.FirstLeft = i.FirstLeft, i.FirstLeft = a, this.m_UsingPolyTree && this.FixupFirstLefts2(i, a), (i.IsHole ^ this.ReverseSolution) == this.Area(i) > 0 && this.ReversePolyPtLinks(i.Pts)) : (a.IsHole = i.IsHole, a.FirstLeft = i.FirstLeft, this.m_UsingPolyTree && this.FixupFirstLefts1(i, a));
2146
+ } else a.Pts = null, a.BottomPt = null, a.Idx = i.Idx, i.IsHole = o.IsHole, o == a && (i.FirstLeft = a.FirstLeft), a.FirstLeft = i, this.m_UsingPolyTree && this.FixupFirstLefts2(a, i);
2147
+ }
2148
+ }
2149
+ }
2150
+ }, e.Clipper.prototype.UpdateOutPtIdxs = function(e) {
2151
+ var t = e.Pts;
2152
+ do
2153
+ t.Idx = e.Idx, t = t.Prev;
2154
+ while (t != e.Pts);
2155
+ }, e.Clipper.prototype.DoSimplePolygons = function() {
2156
+ for (var t = 0; t < this.m_PolyOuts.length;) {
2157
+ var n = this.m_PolyOuts[t++], r = n.Pts;
2158
+ if (r !== null) do {
2159
+ for (var i = r.Next; i != n.Pts;) {
2160
+ if (e.IntPoint.op_Equality(r.Pt, i.Pt) && i.Next != r && i.Prev != r) {
2161
+ var a = r.Prev, o = i.Prev;
2162
+ r.Prev = o, o.Next = r, i.Prev = a, a.Next = i, n.Pts = r;
2163
+ var s = this.CreateOutRec();
2164
+ s.Pts = i, this.UpdateOutPtIdxs(s), this.Poly2ContainsPoly1(s.Pts, n.Pts) ? (s.IsHole = !n.IsHole, s.FirstLeft = n) : this.Poly2ContainsPoly1(n.Pts, s.Pts) ? (s.IsHole = n.IsHole, n.IsHole = !s.IsHole, s.FirstLeft = n.FirstLeft, n.FirstLeft = s) : (s.IsHole = n.IsHole, s.FirstLeft = n.FirstLeft), i = r;
2165
+ }
2166
+ i = i.Next;
2167
+ }
2168
+ r = r.Next;
2169
+ } while (r != n.Pts);
2170
+ }
2171
+ }, e.Clipper.Area = function(e) {
2172
+ var t = e.length;
2173
+ if (t < 3) return 0;
2174
+ for (var n = 0, r = 0, i = t - 1; r < t; ++r) n += (e[i].X + e[r].X) * (e[i].Y - e[r].Y), i = r;
2175
+ return -n * .5;
2176
+ }, e.Clipper.prototype.Area = function(e) {
2177
+ var t = e.Pts;
2178
+ if (t == null) return 0;
2179
+ var n = 0;
2180
+ do
2181
+ n += (t.Prev.Pt.X + t.Pt.X) * (t.Prev.Pt.Y - t.Pt.Y), t = t.Next;
2182
+ while (t != e.Pts);
2183
+ return n * .5;
2184
+ }, e.Clipper.SimplifyPolygon = function(t, n) {
2185
+ var r = [], i = new e.Clipper(0);
2186
+ return i.StrictlySimple = !0, i.AddPath(t, e.PolyType.ptSubject, !0), i.Execute(e.ClipType.ctUnion, r, n, n), r;
2187
+ }, e.Clipper.SimplifyPolygons = function(t, n) {
2188
+ n === void 0 && (n = e.PolyFillType.pftEvenOdd);
2189
+ var r = [], i = new e.Clipper(0);
2190
+ return i.StrictlySimple = !0, i.AddPaths(t, e.PolyType.ptSubject, !0), i.Execute(e.ClipType.ctUnion, r, n, n), r;
2191
+ }, e.Clipper.DistanceSqrd = function(e, t) {
2192
+ var n = e.X - t.X, r = e.Y - t.Y;
2193
+ return n * n + r * r;
2194
+ }, e.Clipper.DistanceFromLineSqrd = function(e, t, n) {
2195
+ var r = t.Y - n.Y, i = n.X - t.X, a = r * t.X + i * t.Y;
2196
+ return a = r * e.X + i * e.Y - a, a * a / (r * r + i * i);
2197
+ }, e.Clipper.SlopesNearCollinear = function(t, n, r, i) {
2198
+ return e.Clipper.DistanceFromLineSqrd(n, t, r) < i;
2199
+ }, e.Clipper.PointsAreClose = function(e, t, n) {
2200
+ var r = e.X - t.X, i = e.Y - t.Y;
2201
+ return r * r + i * i <= n;
2202
+ }, e.Clipper.ExcludeOp = function(e) {
2203
+ var t = e.Prev;
2204
+ return t.Next = e.Next, e.Next.Prev = t, t.Idx = 0, t;
2205
+ }, e.Clipper.CleanPolygon = function(t, n) {
2206
+ n === void 0 && (n = 1.415);
2207
+ var r = t.length;
2208
+ if (r == 0) return [];
2209
+ for (var i = Array(r), a = 0; a < r; ++a) i[a] = new e.OutPt();
2210
+ for (var a = 0; a < r; ++a) i[a].Pt = t[a], i[a].Next = i[(a + 1) % r], i[a].Next.Prev = i[a], i[a].Idx = 0;
2211
+ for (var o = n * n, s = i[0]; s.Idx == 0 && s.Next != s.Prev;) e.Clipper.PointsAreClose(s.Pt, s.Prev.Pt, o) ? (s = e.Clipper.ExcludeOp(s), r--) : e.Clipper.PointsAreClose(s.Prev.Pt, s.Next.Pt, o) ? (e.Clipper.ExcludeOp(s.Next), s = e.Clipper.ExcludeOp(s), r -= 2) : e.Clipper.SlopesNearCollinear(s.Prev.Pt, s.Pt, s.Next.Pt, o) ? (s = e.Clipper.ExcludeOp(s), r--) : (s.Idx = 1, s = s.Next);
2212
+ r < 3 && (r = 0);
2213
+ for (var c = Array(r), a = 0; a < r; ++a) c[a] = new e.IntPoint(s.Pt), s = s.Next;
2214
+ return i = null, c;
2215
+ }, e.Clipper.CleanPolygons = function(t, n) {
2216
+ for (var r = Array(t.length), i = 0, a = t.length; i < a; i++) r[i] = e.Clipper.CleanPolygon(t[i], n);
2217
+ return r;
2218
+ }, e.Clipper.Minkowski = function(t, n, r, i) {
2219
+ var a = +!!i, o = t.length, s = n.length, c = [];
2220
+ if (r) for (var l = 0; l < s; l++) {
2221
+ for (var u = Array(o), d = 0, f = t.length, p = t[d]; d < f; d++, p = t[d]) u[d] = new e.IntPoint(n[l].X + p.X, n[l].Y + p.Y);
2222
+ c.push(u);
2223
+ }
2224
+ else for (var l = 0; l < s; l++) {
2225
+ for (var u = Array(o), d = 0, f = t.length, p = t[d]; d < f; d++, p = t[d]) u[d] = new e.IntPoint(n[l].X - p.X, n[l].Y - p.Y);
2226
+ c.push(u);
2227
+ }
2228
+ for (var m = [], l = 0; l < s - 1 + a; l++) for (var d = 0; d < o; d++) {
2229
+ var h = [];
2230
+ h.push(c[l % s][d % o]), h.push(c[(l + 1) % s][d % o]), h.push(c[(l + 1) % s][(d + 1) % o]), h.push(c[l % s][(d + 1) % o]), e.Clipper.Orientation(h) || h.reverse(), m.push(h);
2231
+ }
2232
+ var g = new e.Clipper(0);
2233
+ return g.AddPaths(m, e.PolyType.ptSubject, !0), g.Execute(e.ClipType.ctUnion, c, e.PolyFillType.pftNonZero, e.PolyFillType.pftNonZero), c;
2234
+ }, e.Clipper.MinkowskiSum = function() {
2235
+ var t = arguments, n = t.length;
2236
+ if (n == 3) {
2237
+ var r = t[0], i = t[1], a = t[2];
2238
+ return e.Clipper.Minkowski(r, i, !0, a);
2239
+ }
2240
+ if (n == 4) {
2241
+ for (var r = t[0], o = t[1], s = t[2], a = t[3], c = new e.Clipper(), l, u = 0, d = o.length; u < d; ++u) {
2242
+ var l = e.Clipper.Minkowski(r, o[u], !0, a);
2243
+ c.AddPaths(l, e.PolyType.ptSubject, !0);
2244
+ }
2245
+ a && c.AddPaths(o, e.PolyType.ptClip, !0);
2246
+ var f = new e.Paths();
2247
+ return c.Execute(e.ClipType.ctUnion, f, s, s), f;
2248
+ }
2249
+ }, e.Clipper.MinkowskiDiff = function(t, n, r) {
2250
+ return e.Clipper.Minkowski(t, n, !1, r);
2251
+ }, e.Clipper.PolyTreeToPaths = function(t) {
2252
+ var n = [];
2253
+ return e.Clipper.AddPolyNodeToPaths(t, e.Clipper.NodeType.ntAny, n), n;
2254
+ }, e.Clipper.AddPolyNodeToPaths = function(t, n, r) {
2255
+ var i = !0;
2256
+ switch (n) {
2257
+ case e.Clipper.NodeType.ntOpen: return;
2258
+ case e.Clipper.NodeType.ntClosed: i = !t.IsOpen;
2259
+ }
2260
+ t.m_polygon.length > 0 && i && r.push(t.m_polygon);
2261
+ for (var a = 0, o = t.Childs(), s = o.length, c = o[a]; a < s; a++, c = o[a]) e.Clipper.AddPolyNodeToPaths(c, n, r);
2262
+ }, e.Clipper.OpenPathsFromPolyTree = function(t) {
2263
+ for (var n = new e.Paths(), r = 0, i = t.ChildCount(); r < i; r++) t.Childs()[r].IsOpen && n.push(t.Childs()[r].m_polygon);
2264
+ return n;
2265
+ }, e.Clipper.ClosedPathsFromPolyTree = function(t) {
2266
+ var n = new e.Paths();
2267
+ return e.Clipper.AddPolyNodeToPaths(t, e.Clipper.NodeType.ntClosed, n), n;
2268
+ }, wt(e.Clipper, e.ClipperBase), e.Clipper.NodeType = {
2269
+ ntAny: 0,
2270
+ ntOpen: 1,
2271
+ ntClosed: 2
2272
+ }, e.ClipperOffset = function(t, n) {
2273
+ t === void 0 && (t = 2), n === void 0 && (n = e.ClipperOffset.def_arc_tolerance), this.m_destPolys = new e.Paths(), this.m_srcPoly = new e.Path(), this.m_destPoly = new e.Path(), this.m_normals = [], this.m_delta = 0, this.m_sinA = 0, this.m_sin = 0, this.m_cos = 0, this.m_miterLim = 0, this.m_StepsPerRad = 0, this.m_lowest = new e.IntPoint(), this.m_polyNodes = new e.PolyNode(), this.MiterLimit = t, this.ArcTolerance = n, this.m_lowest.X = -1;
2274
+ }, e.ClipperOffset.two_pi = 6.28318530717959, e.ClipperOffset.def_arc_tolerance = .25, e.ClipperOffset.prototype.Clear = function() {
2275
+ e.Clear(this.m_polyNodes.Childs()), this.m_lowest.X = -1;
2276
+ }, e.ClipperOffset.Round = e.Clipper.Round, e.ClipperOffset.prototype.AddPath = function(t, n, r) {
2277
+ var i = t.length - 1;
2278
+ if (!(i < 0)) {
2279
+ var a = new e.PolyNode();
2280
+ if (a.m_jointype = n, a.m_endtype = r, r == e.EndType.etClosedLine || r == e.EndType.etClosedPolygon) for (; i > 0 && e.IntPoint.op_Equality(t[0], t[i]);) i--;
2281
+ a.m_polygon.push(t[0]);
2282
+ for (var o = 0, s = 0, c = 1; c <= i; c++) e.IntPoint.op_Inequality(a.m_polygon[o], t[c]) && (o++, a.m_polygon.push(t[c]), (t[c].Y > a.m_polygon[s].Y || t[c].Y == a.m_polygon[s].Y && t[c].X < a.m_polygon[s].X) && (s = o));
2283
+ if (!(r == e.EndType.etClosedPolygon && o < 2 || r != e.EndType.etClosedPolygon && o < 0) && (this.m_polyNodes.AddChild(a), r == e.EndType.etClosedPolygon)) {
2284
+ if (this.m_lowest.X < 0) this.m_lowest = new e.IntPoint(0, s);
2285
+ else {
2286
+ var l = this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];
2287
+ (a.m_polygon[s].Y > l.Y || a.m_polygon[s].Y == l.Y && a.m_polygon[s].X < l.X) && (this.m_lowest = new e.IntPoint(this.m_polyNodes.ChildCount() - 1, s));
2288
+ }
2289
+ }
2290
+ }
2291
+ }, e.ClipperOffset.prototype.AddPaths = function(e, t, n) {
2292
+ for (var r = 0, i = e.length; r < i; r++) this.AddPath(e[r], t, n);
2293
+ }, e.ClipperOffset.prototype.FixOrientations = function() {
2294
+ if (this.m_lowest.X >= 0 && !e.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon)) for (var t = 0; t < this.m_polyNodes.ChildCount(); t++) {
2295
+ var n = this.m_polyNodes.Childs()[t];
2296
+ (n.m_endtype == e.EndType.etClosedPolygon || n.m_endtype == e.EndType.etClosedLine && e.Clipper.Orientation(n.m_polygon)) && n.m_polygon.reverse();
2297
+ }
2298
+ else for (var t = 0; t < this.m_polyNodes.ChildCount(); t++) {
2299
+ var n = this.m_polyNodes.Childs()[t];
2300
+ n.m_endtype == e.EndType.etClosedLine && !e.Clipper.Orientation(n.m_polygon) && n.m_polygon.reverse();
2301
+ }
2302
+ }, e.ClipperOffset.GetUnitNormal = function(t, n) {
2303
+ var r = n.X - t.X, i = n.Y - t.Y;
2304
+ if (r == 0 && i == 0) return new e.DoublePoint(0, 0);
2305
+ var a = 1 / Math.sqrt(r * r + i * i);
2306
+ return r *= a, i *= a, new e.DoublePoint(i, -r);
2307
+ }, e.ClipperOffset.prototype.DoOffset = function(t) {
2308
+ if (this.m_destPolys = [], this.m_delta = t, e.ClipperBase.near_zero(t)) {
2309
+ for (var n = 0; n < this.m_polyNodes.ChildCount(); n++) {
2310
+ var r = this.m_polyNodes.Childs()[n];
2311
+ r.m_endtype == e.EndType.etClosedPolygon && this.m_destPolys.push(r.m_polygon);
2312
+ }
2313
+ return;
2314
+ }
2315
+ this.m_miterLim = this.MiterLimit > 2 ? 2 / (this.MiterLimit * this.MiterLimit) : .5;
2316
+ var i = this.ArcTolerance <= 0 ? e.ClipperOffset.def_arc_tolerance : this.ArcTolerance > Math.abs(t) * e.ClipperOffset.def_arc_tolerance ? Math.abs(t) * e.ClipperOffset.def_arc_tolerance : this.ArcTolerance, a = 3.14159265358979 / Math.acos(1 - i / Math.abs(t));
2317
+ this.m_sin = Math.sin(e.ClipperOffset.two_pi / a), this.m_cos = Math.cos(e.ClipperOffset.two_pi / a), this.m_StepsPerRad = a / e.ClipperOffset.two_pi, t < 0 && (this.m_sin = -this.m_sin);
2318
+ for (var n = 0; n < this.m_polyNodes.ChildCount(); n++) {
2319
+ var r = this.m_polyNodes.Childs()[n];
2320
+ this.m_srcPoly = r.m_polygon;
2321
+ var o = this.m_srcPoly.length;
2322
+ if (!(o == 0 || t <= 0 && (o < 3 || r.m_endtype != e.EndType.etClosedPolygon))) {
2323
+ if (this.m_destPoly = [], o == 1) {
2324
+ if (r.m_jointype == e.JoinType.jtRound) for (var s = 1, c = 0, l = 1; l <= a; l++) {
2325
+ this.m_destPoly.push(new e.IntPoint(e.ClipperOffset.Round(this.m_srcPoly[0].X + s * t), e.ClipperOffset.Round(this.m_srcPoly[0].Y + c * t)));
2326
+ var u = s;
2327
+ s = s * this.m_cos - this.m_sin * c, c = u * this.m_sin + c * this.m_cos;
2328
+ }
2329
+ else for (var s = -1, c = -1, l = 0; l < 4; ++l) this.m_destPoly.push(new e.IntPoint(e.ClipperOffset.Round(this.m_srcPoly[0].X + s * t), e.ClipperOffset.Round(this.m_srcPoly[0].Y + c * t))), s < 0 ? s = 1 : c < 0 ? c = 1 : s = -1;
2330
+ this.m_destPolys.push(this.m_destPoly);
2331
+ continue;
2332
+ }
2333
+ this.m_normals.length = 0;
2334
+ for (var l = 0; l < o - 1; l++) this.m_normals.push(e.ClipperOffset.GetUnitNormal(this.m_srcPoly[l], this.m_srcPoly[l + 1]));
2335
+ if (r.m_endtype == e.EndType.etClosedLine || r.m_endtype == e.EndType.etClosedPolygon ? this.m_normals.push(e.ClipperOffset.GetUnitNormal(this.m_srcPoly[o - 1], this.m_srcPoly[0])) : this.m_normals.push(new e.DoublePoint(this.m_normals[o - 2])), r.m_endtype == e.EndType.etClosedPolygon) {
2336
+ for (var d = o - 1, l = 0; l < o; l++) d = this.OffsetPoint(l, d, r.m_jointype);
2337
+ this.m_destPolys.push(this.m_destPoly);
2338
+ } else if (r.m_endtype == e.EndType.etClosedLine) {
2339
+ for (var d = o - 1, l = 0; l < o; l++) d = this.OffsetPoint(l, d, r.m_jointype);
2340
+ this.m_destPolys.push(this.m_destPoly), this.m_destPoly = [];
2341
+ for (var f = this.m_normals[o - 1], l = o - 1; l > 0; l--) this.m_normals[l] = new e.DoublePoint(-this.m_normals[l - 1].X, -this.m_normals[l - 1].Y);
2342
+ this.m_normals[0] = new e.DoublePoint(-f.X, -f.Y), d = 0;
2343
+ for (var l = o - 1; l >= 0; l--) d = this.OffsetPoint(l, d, r.m_jointype);
2344
+ this.m_destPolys.push(this.m_destPoly);
2345
+ } else {
2346
+ for (var d = 0, l = 1; l < o - 1; ++l) d = this.OffsetPoint(l, d, r.m_jointype);
2347
+ var p;
2348
+ if (r.m_endtype == e.EndType.etOpenButt) {
2349
+ var l = o - 1;
2350
+ p = new e.IntPoint(e.ClipperOffset.Round(this.m_srcPoly[l].X + this.m_normals[l].X * t), e.ClipperOffset.Round(this.m_srcPoly[l].Y + this.m_normals[l].Y * t)), this.m_destPoly.push(p), p = new e.IntPoint(e.ClipperOffset.Round(this.m_srcPoly[l].X - this.m_normals[l].X * t), e.ClipperOffset.Round(this.m_srcPoly[l].Y - this.m_normals[l].Y * t)), this.m_destPoly.push(p);
2351
+ } else {
2352
+ var l = o - 1;
2353
+ d = o - 2, this.m_sinA = 0, this.m_normals[l] = new e.DoublePoint(-this.m_normals[l].X, -this.m_normals[l].Y), r.m_endtype == e.EndType.etOpenSquare ? this.DoSquare(l, d) : this.DoRound(l, d);
2354
+ }
2355
+ for (var l = o - 1; l > 0; l--) this.m_normals[l] = new e.DoublePoint(-this.m_normals[l - 1].X, -this.m_normals[l - 1].Y);
2356
+ this.m_normals[0] = new e.DoublePoint(-this.m_normals[1].X, -this.m_normals[1].Y), d = o - 1;
2357
+ for (var l = d - 1; l > 0; --l) d = this.OffsetPoint(l, d, r.m_jointype);
2358
+ r.m_endtype == e.EndType.etOpenButt ? (p = new e.IntPoint(e.ClipperOffset.Round(this.m_srcPoly[0].X - this.m_normals[0].X * t), e.ClipperOffset.Round(this.m_srcPoly[0].Y - this.m_normals[0].Y * t)), this.m_destPoly.push(p), p = new e.IntPoint(e.ClipperOffset.Round(this.m_srcPoly[0].X + this.m_normals[0].X * t), e.ClipperOffset.Round(this.m_srcPoly[0].Y + this.m_normals[0].Y * t)), this.m_destPoly.push(p)) : (d = 1, this.m_sinA = 0, r.m_endtype == e.EndType.etOpenSquare ? this.DoSquare(0, 1) : this.DoRound(0, 1)), this.m_destPolys.push(this.m_destPoly);
2359
+ }
2360
+ }
2361
+ }
2362
+ }, e.ClipperOffset.prototype.Execute = function() {
2363
+ var t = arguments;
2364
+ if (t[0] instanceof e.PolyTree) {
2365
+ var n = t[0], r = t[1];
2366
+ n.Clear(), this.FixOrientations(), this.DoOffset(r);
2367
+ var i = new e.Clipper(0);
2368
+ if (i.AddPaths(this.m_destPolys, e.PolyType.ptSubject, !0), r > 0) i.Execute(e.ClipType.ctUnion, n, e.PolyFillType.pftPositive, e.PolyFillType.pftPositive);
2369
+ else {
2370
+ var a = e.Clipper.GetBounds(this.m_destPolys), o = new e.Path();
2371
+ if (o.push(new e.IntPoint(a.left - 10, a.bottom + 10)), o.push(new e.IntPoint(a.right + 10, a.bottom + 10)), o.push(new e.IntPoint(a.right + 10, a.top - 10)), o.push(new e.IntPoint(a.left - 10, a.top - 10)), i.AddPath(o, e.PolyType.ptSubject, !0), i.ReverseSolution = !0, i.Execute(e.ClipType.ctUnion, n, e.PolyFillType.pftNegative, e.PolyFillType.pftNegative), n.ChildCount() == 1 && n.Childs()[0].ChildCount() > 0) {
2372
+ var s = n.Childs()[0];
2373
+ n.Childs()[0] = s.Childs()[0];
2374
+ for (var c = 1; c < s.ChildCount(); c++) n.AddChild(s.Childs()[c]);
2375
+ } else n.Clear();
2376
+ }
2377
+ } else {
2378
+ var n = t[0], r = t[1];
2379
+ e.Clear(n), this.FixOrientations(), this.DoOffset(r);
2380
+ var i = new e.Clipper(0);
2381
+ if (i.AddPaths(this.m_destPolys, e.PolyType.ptSubject, !0), r > 0) i.Execute(e.ClipType.ctUnion, n, e.PolyFillType.pftPositive, e.PolyFillType.pftPositive);
2382
+ else {
2383
+ var a = e.Clipper.GetBounds(this.m_destPolys), o = new e.Path();
2384
+ o.push(new e.IntPoint(a.left - 10, a.bottom + 10)), o.push(new e.IntPoint(a.right + 10, a.bottom + 10)), o.push(new e.IntPoint(a.right + 10, a.top - 10)), o.push(new e.IntPoint(a.left - 10, a.top - 10)), i.AddPath(o, e.PolyType.ptSubject, !0), i.ReverseSolution = !0, i.Execute(e.ClipType.ctUnion, n, e.PolyFillType.pftNegative, e.PolyFillType.pftNegative), n.length > 0 && n.splice(0, 1);
2385
+ }
2386
+ }
2387
+ }, e.ClipperOffset.prototype.OffsetPoint = function(t, n, r) {
2388
+ if (this.m_sinA = this.m_normals[n].X * this.m_normals[t].Y - this.m_normals[t].X * this.m_normals[n].Y, this.m_sinA < 5e-5 && this.m_sinA > -5e-5) return n;
2389
+ if (this.m_sinA > 1 ? this.m_sinA = 1 : this.m_sinA < -1 && (this.m_sinA = -1), this.m_sinA * this.m_delta < 0) this.m_destPoly.push(new e.IntPoint(e.ClipperOffset.Round(this.m_srcPoly[t].X + this.m_normals[n].X * this.m_delta), e.ClipperOffset.Round(this.m_srcPoly[t].Y + this.m_normals[n].Y * this.m_delta))), this.m_destPoly.push(new e.IntPoint(this.m_srcPoly[t])), this.m_destPoly.push(new e.IntPoint(e.ClipperOffset.Round(this.m_srcPoly[t].X + this.m_normals[t].X * this.m_delta), e.ClipperOffset.Round(this.m_srcPoly[t].Y + this.m_normals[t].Y * this.m_delta)));
2390
+ else switch (r) {
2391
+ case e.JoinType.jtMiter:
2392
+ var i = 1 + (this.m_normals[t].X * this.m_normals[n].X + this.m_normals[t].Y * this.m_normals[n].Y);
2393
+ i >= this.m_miterLim ? this.DoMiter(t, n, i) : this.DoSquare(t, n);
2394
+ break;
2395
+ case e.JoinType.jtSquare:
2396
+ this.DoSquare(t, n);
2397
+ break;
2398
+ case e.JoinType.jtRound:
2399
+ this.DoRound(t, n);
2400
+ break;
2401
+ }
2402
+ return n = t, n;
2403
+ }, e.ClipperOffset.prototype.DoSquare = function(t, n) {
2404
+ var r = Math.tan(Math.atan2(this.m_sinA, this.m_normals[n].X * this.m_normals[t].X + this.m_normals[n].Y * this.m_normals[t].Y) / 4);
2405
+ this.m_destPoly.push(new e.IntPoint(e.ClipperOffset.Round(this.m_srcPoly[t].X + this.m_delta * (this.m_normals[n].X - this.m_normals[n].Y * r)), e.ClipperOffset.Round(this.m_srcPoly[t].Y + this.m_delta * (this.m_normals[n].Y + this.m_normals[n].X * r)))), this.m_destPoly.push(new e.IntPoint(e.ClipperOffset.Round(this.m_srcPoly[t].X + this.m_delta * (this.m_normals[t].X + this.m_normals[t].Y * r)), e.ClipperOffset.Round(this.m_srcPoly[t].Y + this.m_delta * (this.m_normals[t].Y - this.m_normals[t].X * r))));
2406
+ }, e.ClipperOffset.prototype.DoMiter = function(t, n, r) {
2407
+ var i = this.m_delta / r;
2408
+ this.m_destPoly.push(new e.IntPoint(e.ClipperOffset.Round(this.m_srcPoly[t].X + (this.m_normals[n].X + this.m_normals[t].X) * i), e.ClipperOffset.Round(this.m_srcPoly[t].Y + (this.m_normals[n].Y + this.m_normals[t].Y) * i)));
2409
+ }, e.ClipperOffset.prototype.DoRound = function(t, n) {
2410
+ for (var r = Math.atan2(this.m_sinA, this.m_normals[n].X * this.m_normals[t].X + this.m_normals[n].Y * this.m_normals[t].Y), i = e.Cast_Int32(e.ClipperOffset.Round(this.m_StepsPerRad * Math.abs(r))), a = this.m_normals[n].X, o = this.m_normals[n].Y, s, c = 0; c < i; ++c) this.m_destPoly.push(new e.IntPoint(e.ClipperOffset.Round(this.m_srcPoly[t].X + a * this.m_delta), e.ClipperOffset.Round(this.m_srcPoly[t].Y + o * this.m_delta))), s = a, a = a * this.m_cos - this.m_sin * o, o = s * this.m_sin + o * this.m_cos;
2411
+ this.m_destPoly.push(new e.IntPoint(e.ClipperOffset.Round(this.m_srcPoly[t].X + this.m_normals[t].X * this.m_delta), e.ClipperOffset.Round(this.m_srcPoly[t].Y + this.m_normals[t].Y * this.m_delta)));
2412
+ }, e.Error = function(e) {
2413
+ try {
2414
+ throw Error(e);
2415
+ } catch (e) {
2416
+ alert(e.message);
2417
+ }
2418
+ }, e.JS = {}, e.JS.AreaOfPolygon = function(t, n) {
2419
+ return n ||= 1, e.Clipper.Area(t) / (n * n);
2420
+ }, e.JS.AreaOfPolygons = function(t, n) {
2421
+ n ||= 1;
2422
+ for (var r = 0, i = 0; i < t.length; i++) r += e.Clipper.Area(t[i]);
2423
+ return r / (n * n);
2424
+ }, e.JS.BoundsOfPath = function(t, n) {
2425
+ return e.JS.BoundsOfPaths([t], n);
2426
+ }, e.JS.BoundsOfPaths = function(t, n) {
2427
+ n ||= 1;
2428
+ var r = e.Clipper.GetBounds(t);
2429
+ return r.left /= n, r.bottom /= n, r.right /= n, r.top /= n, r;
2430
+ }, e.JS.Clean = function(t, n) {
2431
+ if (!(t instanceof Array)) return [];
2432
+ var r = t[0] instanceof Array, t = e.JS.Clone(t);
2433
+ if (typeof n != "number" || n === null) return e.Error("Delta is not a number in Clean()."), t;
2434
+ if (t.length === 0 || t.length == 1 && t[0].length === 0 || n < 0) return t;
2435
+ r || (t = [t]);
2436
+ for (var i = t.length, a, o, s, c, l, u, d, f = [], p = 0; p < i; p++) if (o = t[p], a = o.length, a !== 0) {
2437
+ if (a < 3) {
2438
+ s = o, f.push(s);
2439
+ continue;
2440
+ }
2441
+ for (s = o, c = n * n, l = o[0], u = 1, d = 1; d < a; d++) (o[d].X - l.X) * (o[d].X - l.X) + (o[d].Y - l.Y) * (o[d].Y - l.Y) <= c || (s[u] = o[d], l = o[d], u++);
2442
+ l = o[u - 1], (o[0].X - l.X) * (o[0].X - l.X) + (o[0].Y - l.Y) * (o[0].Y - l.Y) <= c && u--, u < a && s.splice(u, a - u), s.length && f.push(s);
2443
+ }
2444
+ return !r && f.length ? f = f[0] : !r && f.length === 0 ? f = [] : r && f.length === 0 && (f = [[]]), f;
2445
+ }, e.JS.Clone = function(e) {
2446
+ if (!(e instanceof Array) || e.length === 0) return [];
2447
+ if (e.length == 1 && e[0].length === 0) return [[]];
2448
+ var t = e[0] instanceof Array;
2449
+ t || (e = [e]);
2450
+ var n = e.length, r, i, a, o, s = Array(n);
2451
+ for (i = 0; i < n; i++) {
2452
+ for (r = e[i].length, o = Array(r), a = 0; a < r; a++) o[a] = {
2453
+ X: e[i][a].X,
2454
+ Y: e[i][a].Y
2455
+ };
2456
+ s[i] = o;
2457
+ }
2458
+ return t || (s = s[0]), s;
2459
+ }, e.JS.Lighten = function(t, n) {
2460
+ if (!(t instanceof Array)) return [];
2461
+ if (typeof n != "number" || n === null) return e.Error("Tolerance is not a number in Lighten()."), e.JS.Clone(t);
2462
+ if (t.length === 0 || t.length == 1 && t[0].length === 0 || n < 0) return e.JS.Clone(t);
2463
+ t[0] instanceof Array || (t = [t]);
2464
+ var r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v, y, b = t.length, ee = n * n, x = [];
2465
+ for (r = 0; r < b; r++) if (a = t[r], c = a.length, c != 0) {
2466
+ for (o = 0; o < 1e6; o++) {
2467
+ for (s = [], c = a.length, a[c - 1].X != a[0].X || a[c - 1].Y != a[0].Y ? (m = 1, a.push({
2468
+ X: a[0].X,
2469
+ Y: a[0].Y
2470
+ }), c = a.length) : m = 0, p = [], i = 0; i < c - 2; i++) l = a[i], d = a[i + 1], u = a[i + 2], v = l.X, y = l.Y, h = u.X - v, g = u.Y - y, (h !== 0 || g !== 0) && (_ = ((d.X - v) * h + (d.Y - y) * g) / (h * h + g * g), _ > 1 ? (v = u.X, y = u.Y) : _ > 0 && (v += h * _, y += g * _)), h = d.X - v, g = d.Y - y, f = h * h + g * g, f <= ee && (p[i + 1] = 1, i++);
2471
+ for (s.push({
2472
+ X: a[0].X,
2473
+ Y: a[0].Y
2474
+ }), i = 1; i < c - 1; i++) p[i] || s.push({
2475
+ X: a[i].X,
2476
+ Y: a[i].Y
2477
+ });
2478
+ if (s.push({
2479
+ X: a[c - 1].X,
2480
+ Y: a[c - 1].Y
2481
+ }), m && a.pop(), p.length) a = s;
2482
+ else break;
2483
+ }
2484
+ c = s.length, s[c - 1].X == s[0].X && s[c - 1].Y == s[0].Y && s.pop(), s.length > 2 && x.push(s);
2485
+ }
2486
+ return !t[0] instanceof Array && (x = x[0]), x === void 0 && (x = [[]]), x;
2487
+ }, e.JS.PerimeterOfPath = function(e, t, n) {
2488
+ if (e === void 0) return 0;
2489
+ var r = Math.sqrt, i = 0, a, o, s = 0, c = 0, l = 0, u = 0, d = e.length;
2490
+ if (d < 2) return 0;
2491
+ for (t && (e[d] = e[0], d++); --d;) a = e[d], s = a.X, c = a.Y, o = e[d - 1], l = o.X, u = o.Y, i += r((s - l) * (s - l) + (c - u) * (c - u));
2492
+ return t && e.pop(), i / n;
2493
+ }, e.JS.PerimeterOfPaths = function(t, n, r) {
2494
+ r ||= 1;
2495
+ for (var i = 0, a = 0; a < t.length; a++) i += e.JS.PerimeterOfPath(t[a], n, r);
2496
+ return i;
2497
+ }, e.JS.ScaleDownPath = function(e, t) {
2498
+ var n, r;
2499
+ for (t ||= 1, n = e.length; n--;) r = e[n], r.X /= t, r.Y /= t;
2500
+ }, e.JS.ScaleDownPaths = function(e, t) {
2501
+ var n, r, i;
2502
+ for (t ||= 1, n = e.length; n--;) for (r = e[n].length; r--;) i = e[n][r], i.X /= t, i.Y /= t;
2503
+ }, e.JS.ScaleUpPath = function(e, t) {
2504
+ var n, r, i = Math.round;
2505
+ for (t ||= 1, n = e.length; n--;) r = e[n], r.X = i(r.X * t), r.Y = i(r.Y * t);
2506
+ }, e.JS.ScaleUpPaths = function(e, t) {
2507
+ var n, r, i, a = Math.round;
2508
+ for (t ||= 1, n = e.length; n--;) for (r = e[n].length; r--;) i = e[n][r], i.X = a(i.X * t), i.Y = a(i.Y * t);
2509
+ }, e.ExPolygons = function() {
2510
+ return [];
2511
+ }, e.ExPolygon = function() {
2512
+ this.outer = null, this.holes = null;
2513
+ }, e.JS.AddOuterPolyNodeToExPolygons = function(t, n) {
2514
+ var r = new e.ExPolygon();
2515
+ r.outer = t.Contour();
2516
+ var i = t.Childs(), a = i.length;
2517
+ r.holes = Array(a);
2518
+ var o, s, c, l, u, d;
2519
+ for (c = 0; c < a; c++) for (o = i[c], r.holes[c] = o.Contour(), l = 0, u = o.Childs(), d = u.length; l < d; l++) s = u[l], e.JS.AddOuterPolyNodeToExPolygons(s, n);
2520
+ n.push(r);
2521
+ }, e.JS.ExPolygonsToPaths = function(t) {
2522
+ var n, r, i, a, o = new e.Paths();
2523
+ for (n = 0, i = t.length; n < i; n++) for (o.push(t[n].outer), r = 0, a = t[n].holes.length; r < a; r++) o.push(t[n].holes[r]);
2524
+ return o;
2525
+ }, e.JS.PolyTreeToExPolygons = function(t) {
2526
+ var n = new e.ExPolygons(), r, i, a, o;
2527
+ for (i = 0, a = t.Childs(), o = a.length; i < o; i++) r = a[i], e.JS.AddOuterPolyNodeToExPolygons(r, n);
2528
+ return n;
2529
+ };
2530
+ })();
2531
+ })), ae = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
2532
+ var n = ie(), r = 10 ** 5;
2533
+ function i(e) {
2534
+ return e.map(function(e) {
2535
+ return {
2536
+ X: e[0],
2537
+ Y: e[1]
2538
+ };
2539
+ });
2540
+ }
2541
+ function a(e) {
2542
+ return e.map(function(e) {
2543
+ return [e.X, e.Y];
2544
+ });
2545
+ }
2546
+ function o(e) {
2547
+ return e.map(i);
2548
+ }
2549
+ function s(e) {
2550
+ return e.map(a);
2551
+ }
2552
+ var c = {
2553
+ EVEN_ODD: n.PolyFillType.pftEvenOdd,
2554
+ NON_ZERO: n.PolyFillType.pftNonZero,
2555
+ NEGATIVE: n.PolyFillType.pftNegative,
2556
+ POSITIVE: n.PolyFillType.pftPositive
2557
+ }, l = {
2558
+ INTERSECTION: n.ClipType.ctIntersection,
2559
+ UNION: n.ClipType.ctUnion,
2560
+ DIFFERENCE: n.ClipType.ctDifference,
2561
+ XOR: n.ClipType.ctXor
2562
+ }, u = {
2563
+ ROUND: n.JoinType.jtRound,
2564
+ MITER: n.JoinType.jtMiter,
2565
+ SQUARE: n.JoinType.jtSquare
2566
+ };
2567
+ function d(e, t, i, a, l) {
2568
+ var a = a || r, l = l || c.NON_ZERO;
2569
+ if (!Array.isArray(e)) throw Error("Provide subject polygon as an array of paths.");
2570
+ if (!Array.isArray(t)) throw Error("Provide clip polygons as arrays of paths.");
2571
+ if (t.length == 0) throw Error("Provide at least one clip.");
2572
+ if (typeof i != "number" || !(0 <= i && i < 4)) throw Error("Provide a valid clip type!");
2573
+ var u = o(e), d = t.map(o), f = new n.Clipper();
2574
+ n.JS.ScaleUpPaths(u, a), f.AddPaths(u, n.PolyType.ptSubject, !0), d.forEach(function(e) {
2575
+ n.JS.ScaleUpPaths(e, a), f.AddPaths(e, n.PolyType.ptClip, !0);
2576
+ });
2577
+ var p = [];
2578
+ return f.Execute(i, p, l, l) ? (n.JS.ScaleDownPaths(p, a), s(p)) : !1;
2579
+ }
2580
+ function f(e, t) {
2581
+ return d(e, t, l.INTERSECTION);
2582
+ }
2583
+ function p(e, t) {
2584
+ return d(e, t, l.UNION);
2585
+ }
2586
+ function m(e, t) {
2587
+ return d(e, t, l.DIFFERENCE);
2588
+ }
2589
+ function h(e, t) {
2590
+ return d(e, t, l.XOR);
2591
+ }
2592
+ _.fromVector = function(e, t) {
2593
+ var n = e.map(function(e) {
2594
+ return [e.x, e.y];
2595
+ }), r = void 0;
2596
+ return t && (r = t.map(function(e) {
2597
+ return e.map(function(e) {
2598
+ return [e.x, e.y];
2599
+ });
2600
+ })), new _(n, r);
2601
+ };
2602
+ function g(e, t, i, a, l, d, f, p) {
2603
+ var i = i || r, a = a || c.NON_ZERO, l = l || 1 / i, d = d || 2, f = f || .25, p = p || u.MITER;
2604
+ if (!Array.isArray(e)) throw Error("Provide subject polygon as an array of paths.");
2605
+ var m = o(e);
2606
+ n.JS.ScaleUpPaths(m, i);
2607
+ var h = n.Clipper.SimplifyPolygons(m, a), g = n.JS.Clean(h, l), _ = new n.ClipperOffset();
2608
+ _.AddPaths(g, p, n.EndType.etClosedPolygon);
2609
+ var v = [];
2610
+ return _.Execute(v, t * i), n.JS.ScaleDownPaths(v, i), s(v);
2611
+ }
2612
+ function _(e, t) {
2613
+ if (!Array.isArray(e)) throw Error("Given shape should be an array of points [x,y].");
2614
+ if (t ||= [], !Array.isArray(t)) throw Error("Given holes should be an array of paths.");
2615
+ var n = e.concat(), r = t.concat();
2616
+ _.isCounterClockwise(n) || n.reverse(), r = r.map(function(e) {
2617
+ return _.isCounterClockwise(e) ? e.concat().reverse() : e;
2618
+ }), this._paths = [n].concat(r);
2619
+ }
2620
+ _.prototype.clone = function() {
2621
+ return clonedShape = this.getShape().map(function(e) {
2622
+ return e.concat();
2623
+ }), clonedHoles = this.getHoles().map((function(e) {
2624
+ return e.map(function(e) {
2625
+ return e.concat();
2626
+ });
2627
+ })), new _(clonedShape, clonedHoles);
2628
+ }, _.prototype.getPaths = function() {
2629
+ return this._paths.slice();
2630
+ }, _.prototype.getShape = function() {
2631
+ return this._paths.slice(0, 1)[0];
2632
+ }, _.prototype.getHoles = function() {
2633
+ return this._paths.slice(1);
2634
+ }, _.prototype.clipMultiple = function(e, t) {
2635
+ var n = e.map(function(e) {
2636
+ return e.getPaths();
2637
+ }), r = d(this.getPaths(), n, t);
2638
+ return r ? _.assignShapesAndHoles(r) : !1;
2639
+ }, _.prototype.diffMultiple = function(e) {
2640
+ return this.clipMultiple(e, l.DIFFERENCE);
2641
+ }, _.prototype.intersectMultiple = function(e) {
2642
+ return this.clipMultiple(e, l.INTERSECTION);
2643
+ }, _.prototype.unionMultiple = function(e) {
2644
+ return this.clipMultiple(e, l.UNION);
2645
+ }, _.prototype.xorMultiple = function(e) {
2646
+ return this.clipMultiple(e, l.XOR);
2647
+ }, _.prototype.diff = function(e) {
2648
+ return this.clipMultiple([e], l.DIFFERENCE);
2649
+ }, _.prototype.intersect = function(e) {
2650
+ return this.clipMultiple([e], l.INTERSECTION);
2651
+ }, _.prototype.union = function(e) {
2652
+ return this.clipMultiple([e], l.UNION);
2653
+ }, _.prototype.xor = function(e) {
2654
+ return this.clipMultiple([e], l.XOR);
2655
+ }, _.prototype.offset = function(e, t) {
2656
+ var n = g(this.getPaths(), e, t);
2657
+ return _.assignShapesAndHoles(n)[0];
2658
+ }, _.prototype.area = function(e) {
2659
+ e ||= r;
2660
+ var t = i(this.getShape());
2661
+ return n.JS.ScaleUpPath(t, e), n.Clipper.Area(t) / (e * e);
2662
+ }, _.prototype.containsPoint = function(e, t) {
2663
+ t ||= r;
2664
+ var n = this.getShape(), i = this.getHoles().some(function(n) {
2665
+ return _.containsPoint(n, e, t);
2666
+ });
2667
+ return _.containsPoint(n, e, t) && !i;
2668
+ }, _.assignShapesAndHoles = function(e) {
2669
+ function t(e) {
2670
+ var t = [], n = [];
2671
+ return e.forEach(function(e) {
2672
+ _.isCounterClockwise(e) ? n.push(e) : t.push(e);
2673
+ }), {
2674
+ shapes: n,
2675
+ holes: t
2676
+ };
2677
+ }
2678
+ function n(e) {
2679
+ return function(t) {
2680
+ return new _(t, e.filter(function(e) {
2681
+ return _.contains(t, e);
2682
+ }));
2683
+ };
2684
+ }
2685
+ var r = t(e);
2686
+ return r.shapes.map(n(r.holes));
2687
+ }, _.isCounterClockwise = function(e) {
2688
+ return n.Clipper.Orientation(i(e));
2689
+ }, _.contains = function(e, t) {
2690
+ var r = i(e);
2691
+ return i(t).reduce(function(e, t) {
2692
+ return e && n.Clipper.PointInPolygon(t, r) !== 0;
2693
+ }, !0);
2694
+ }, _.containsPoint = function(e, t, r) {
2695
+ return e = i(e), n.JS.ScaleUpPath(e, r), n.Clipper.PointInPolygon({
2696
+ X: t[0] * r,
2697
+ Y: t[1] * r
2698
+ }, e) !== 0;
2699
+ }, t.exports = {
2700
+ DEFAULT_SCALE: r,
2701
+ arrayToObjectNotation: i,
2702
+ objectToArrayNotation: a,
2703
+ arrayToClipperPaths: o,
2704
+ clipperPathsToArray: s,
2705
+ FillType: c,
2706
+ ClipType: l,
2707
+ JoinType: u,
2708
+ clip: d,
2709
+ intersect: f,
2710
+ union: p,
2711
+ diff: m,
2712
+ xor: h,
2713
+ offset: g,
2714
+ Polygon: _,
2715
+ ClipperLib: n
2716
+ };
2717
+ })))(), 1), oe = 18, T = Object.freeze({
2718
+ x: 0,
2719
+ y: 0,
2720
+ scalePercent: 100
2721
+ });
2722
+ function E(e) {
2723
+ if (typeof e != "number" || !Number.isFinite(e) || e <= 0) throw TypeError("Bubble tail length must be greater than zero.");
2724
+ return e;
2725
+ }
2726
+ function se(e) {
2727
+ if (e.length !== 2 && e.length !== 3) throw TypeError("Bubble offset must be [x, y] or [x, y, scale].");
2728
+ let [t, n, r = 100] = e;
2729
+ if (![
2730
+ t,
2731
+ n,
2732
+ r
2733
+ ].every(Number.isFinite) || r <= 0) throw TypeError("Bubble offset values must be finite and scale positive.");
2734
+ return Object.freeze({
2735
+ x: t,
2736
+ y: n,
2737
+ scalePercent: r
2738
+ });
2739
+ }
2740
+ var D = Object.freeze([
2741
+ "NORMAL",
2742
+ "THINKING",
2743
+ "DREAMING",
2744
+ "YELLING",
2745
+ "OFF_PANEL",
2746
+ "WAVY",
2747
+ "WHISPERING",
2748
+ "ANNOUNCEMENT",
2749
+ "NARRATION",
2750
+ "NO_BUBBLE"
2751
+ ]);
2752
+ function ce(e) {
2753
+ return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&apos;");
2754
+ }
2755
+ function le(e, t) {
2756
+ let n = e ?? t;
2757
+ if (!Number.isFinite(n) || n <= 0) throw TypeError("Bubble SVG dimensions must be positive and finite.");
2758
+ return n;
2759
+ }
2760
+ function ue(e) {
2761
+ if (e === null) return null;
2762
+ let t = e ?? 180;
2763
+ if (!Number.isFinite(t)) throw TypeError("tailDirection must be finite.");
2764
+ return (t % 360 + 360) % 360;
2765
+ }
2766
+ function O(e, t, n = 18) {
2767
+ let r = e - 24, i = t - 24;
2768
+ return [
2769
+ {
2770
+ centerX: r - n,
2771
+ centerY: 24 + n,
2772
+ start: -90
2773
+ },
2774
+ {
2775
+ centerX: r - n,
2776
+ centerY: i - n,
2777
+ start: 0
2778
+ },
2779
+ {
2780
+ centerX: 24 + n,
2781
+ centerY: i - n,
2782
+ start: 90
2783
+ },
2784
+ {
2785
+ centerX: 24 + n,
2786
+ centerY: 24 + n,
2787
+ start: 180
2788
+ }
2789
+ ].flatMap(({ centerX: e, centerY: t, start: r }) => Array.from({ length: 11 }, (i, a) => {
2790
+ let o = (r + a * 90 / 10) * Math.PI / 180;
2791
+ return {
2792
+ x: e + Math.cos(o) * n,
2793
+ y: t + Math.sin(o) * n
2794
+ };
2795
+ }));
2796
+ }
2797
+ function k(e, t) {
2798
+ return e.x * t.y - e.y * t.x;
2799
+ }
2800
+ function A(e, t) {
2801
+ return {
2802
+ x: e.x - t.x,
2803
+ y: e.y - t.y
2804
+ };
2805
+ }
2806
+ function de(e, t) {
2807
+ return Math.hypot(e.x - t.x, e.y - t.y);
2808
+ }
2809
+ function fe(e, t, n, r) {
2810
+ let i = t, a = r;
2811
+ for (; a > 0;) {
2812
+ let t = (i + n + e.length) % e.length, r = e[i], o = e[t];
2813
+ if (!r || !o) throw Error("Bubble border path is invalid.");
2814
+ let s = de(r, o);
2815
+ if (a <= s) {
2816
+ let e = a / s;
2817
+ return {
2818
+ x: r.x + (o.x - r.x) * e,
2819
+ y: r.y + (o.y - r.y) * e
2820
+ };
2821
+ }
2822
+ a -= s, i = t;
2823
+ }
2824
+ let o = e[i];
2825
+ if (!o) throw Error("Bubble border path is empty.");
2826
+ return o;
2827
+ }
2828
+ function pe(e, t, n, r, i) {
2829
+ let a;
2830
+ for (let r = 0; r < e.length; r += 1) {
2831
+ let i = e[r], o = e[(r + 1) % e.length];
2832
+ if (!i || !o) continue;
2833
+ let s = A(o, i), c = k(n, s);
2834
+ if (Math.abs(c) < 1e-9) continue;
2835
+ let l = A(i, t), u = k(l, s) / c, d = k(l, n) / c;
2836
+ u < 0 || d < -1e-9 || d > 1 + 1e-9 || a && u >= a.rayScale || (a = {
2837
+ edgeIndex: r,
2838
+ point: {
2839
+ x: t.x + n.x * u,
2840
+ y: t.y + n.y * u
2841
+ },
2842
+ rayScale: u
2843
+ });
2844
+ }
2845
+ if (!a) throw Error("Tail ray does not intersect Bubble border.");
2846
+ let o = [
2847
+ ...e.slice(0, a.edgeIndex + 1),
2848
+ a.point,
2849
+ ...e.slice(a.edgeIndex + 1)
2850
+ ], s = a.edgeIndex + 1;
2851
+ return {
2852
+ borderPoint: a.point,
2853
+ base: [fe(o, s, -1, 9), fe(o, s, 1, 9)],
2854
+ tip: {
2855
+ x: i?.x ?? t.x + n.x * (a.rayScale + r),
2856
+ y: i?.y ?? t.y + n.y * (a.rayScale + r)
2857
+ }
2858
+ };
2859
+ }
2860
+ function me(e) {
2861
+ let t = e * Math.PI / 180;
2862
+ return {
2863
+ x: Math.sin(t),
2864
+ y: -Math.cos(t)
2865
+ };
2866
+ }
2867
+ function he(e, t, n, r) {
2868
+ return {
2869
+ x: n.x + (e.x - t.x) * r,
2870
+ y: n.y + (e.y - t.y) * r
2871
+ };
2872
+ }
2873
+ function j(e, t, n, r, i, a) {
2874
+ let o = {
2875
+ x: t / 2,
2876
+ y: n / 2
2877
+ }, s = me(r), c = pe(e, o, s, i), l = de(o, c.borderPoint), u = a.scalePercent / 100, d = {
2878
+ x: o.x - s.x * l * (u - 1) + a.x,
2879
+ y: o.y - s.y * l * (u - 1) - a.y
2880
+ };
2881
+ return {
2882
+ body: e.map((e) => he(e, o, d, u)),
2883
+ bodyCenter: d,
2884
+ tip: c.tip
2885
+ };
2886
+ }
2887
+ function ge(e) {
2888
+ let t = e[0];
2889
+ if (!t) throw Error("Bubble polygon is empty.");
2890
+ return `M ${t.x.toFixed(4)} ${t.y.toFixed(4)} ${e.slice(1).map(({ x: e, y: t }) => `L ${e.toFixed(4)} ${t.toFixed(4)}`).join(" ")} Z`;
2891
+ }
2892
+ function _e(e) {
2893
+ return Math.abs(e.reduce((t, n, r) => {
2894
+ let i = e[(r + 1) % e.length];
2895
+ return i ? t + n.x * i.y - i.x * n.y : t;
2896
+ }, 0) / 2);
2897
+ }
2898
+ function ve(e, t, n, r = "") {
2899
+ return `<path d="${ge(e)}" fill="${t}" stroke="${n}" stroke-width="3" stroke-linejoin="round" ${r}/>`;
2900
+ }
2901
+ function ye(e, t, n, r, i, a = "") {
2902
+ let o = A(n, t), s = Math.hypot(o.x, o.y);
2903
+ if (!(s > 0)) throw TypeError("Bubble body center and tail tip must differ.");
2904
+ let c = pe(e, t, {
2905
+ x: o.x / s,
2906
+ y: o.y / s
2907
+ }, 0, n), l = (e) => e.map(({ x: e, y: t }) => [e, t]), u = ae.default.union([l(e)], [[l([
2908
+ c.base[0],
2909
+ c.tip,
2910
+ c.base[1]
2911
+ ])]]);
2912
+ if (!u || u.length === 0) throw Error("JSClipper failed to union Bubble body and tail.");
2913
+ let d = u.map((e) => e.map(([e, t]) => ({
2914
+ x: e,
2915
+ y: t
2916
+ }))).sort((e, t) => _e(t) - _e(e))[0];
2917
+ if (!d) throw Error("JSClipper returned an empty Bubble outline.");
2918
+ return `<path d="${ge(d)}" fill="${r}" stroke="${i}" stroke-width="3" stroke-linejoin="round" data-boolean-operation="union" data-tail-base-on-border="true" ${a}/>`;
2919
+ }
2920
+ function be(e, t, n, r) {
2921
+ let i = e - 24, a = t - 24, o = e / 2, s = t / 2;
2922
+ return `<path d="M 42 ${s}
2923
+ C 22 ${s - 20}, 32 42, 60 44
2924
+ C 68 22, ${o - 18} 19, ${o} 37
2925
+ C ${o + 24} 16, ${i - 28} 24, ${i - 30} 48
2926
+ C ${i + 2} 42, ${i + 7} ${s - 3}, ${i - 3} ${s + 15}
2927
+ C ${i + 8} ${a - 10}, ${i - 20} ${a + 7}, ${i - 42} ${a - 7}
2928
+ C ${i - 55} ${a + 12}, ${o + 12} ${a + 7}, ${o} ${a - 7}
2929
+ C ${o - 24} ${a + 12}, 66 ${a + 7}, 62 ${a - 12}
2930
+ C 31 ${a + 2}, 17 ${s + 20}, 42 ${s} Z"
2931
+ fill="${n}" stroke="${r}" stroke-width="3" stroke-linejoin="round"/>`;
2932
+ }
2933
+ function xe(e, t, n, r, i, a) {
2934
+ let o = A(n, t), s = Math.hypot(o.x, o.y), c = pe(e, t, {
2935
+ x: o.x / s,
2936
+ y: o.y / s
2937
+ }, 0, n), l = {
2938
+ x: (c.base[0].x + c.base[1].x) / 2,
2939
+ y: (c.base[0].y + c.base[1].y) / 2
2940
+ };
2941
+ return (a ? [
2942
+ {
2943
+ ratio: .45,
2944
+ radius: 7
2945
+ },
2946
+ {
2947
+ ratio: .78,
2948
+ radius: 4.5
2949
+ },
2950
+ {
2951
+ ratio: 1,
2952
+ radius: 3
2953
+ }
2954
+ ] : [{
2955
+ ratio: .5,
2956
+ radius: 5
2957
+ }, {
2958
+ ratio: .82,
2959
+ radius: 3.5
2960
+ }]).map(({ ratio: e, radius: t }) => `<circle cx="${l.x + (c.tip.x - l.x) * e}" cy="${l.y + (c.tip.y - l.y) * e}" r="${t}" fill="${r}" stroke="${i}" stroke-width="2"/>`).join("");
2961
+ }
2962
+ function Se(e, t) {
2963
+ let n = e / 2, r = t / 2;
2964
+ return Array.from({ length: 28 }, (i, a) => {
2965
+ let o = a * Math.PI * 2 / 28 - Math.PI / 2, s = a % 2 == 0, c = s ? e / 2 - 6 : e / 2 - 22, l = s ? t / 2 - 6 : t / 2 - 22;
2966
+ return {
2967
+ x: n + Math.cos(o) * c,
2968
+ y: r + Math.sin(o) * l
2969
+ };
2970
+ });
2971
+ }
2972
+ function Ce(e, t) {
2973
+ let n = e - 24, r = t - 24, i = Array.from({ length: 21 }, (e, t) => {
2974
+ let n = t / 20;
2975
+ return {
2976
+ ratio: n,
2977
+ wave: Math.sin(n * Math.PI * 8) * 4
2978
+ };
2979
+ }), a = Array.from({ length: 9 }, (e, t) => {
2980
+ let n = (t + 1) / 10;
2981
+ return {
2982
+ ratio: n,
2983
+ wave: Math.sin(n * Math.PI * 4) * 4
2984
+ };
2985
+ });
2986
+ return [
2987
+ ...i.map(({ ratio: e, wave: t }) => ({
2988
+ x: 24 + e * (n - 24),
2989
+ y: 24 + t
2990
+ })),
2991
+ ...a.map(({ ratio: e, wave: t }) => ({
2992
+ x: n + t,
2993
+ y: 24 + e * (r - 24)
2994
+ })),
2995
+ ...[...i].reverse().map(({ ratio: e, wave: t }) => ({
2996
+ x: 24 + e * (n - 24),
2997
+ y: r + t
2998
+ })),
2999
+ ...[...a].reverse().map(({ ratio: e, wave: t }) => ({
3000
+ x: 24 + t,
3001
+ y: 24 + e * (r - 24)
3002
+ }))
3003
+ ];
3004
+ }
3005
+ function we(e, t, n) {
3006
+ return e === "YELLING" ? Se(t, n) : e === "WAVY" ? Ce(t, n) : O(t, n);
3007
+ }
3008
+ function Te(e) {
3009
+ let t = le(e.width, 220), n = le(e.height, 112), r = ue(e.tailDirection);
3010
+ if (r === null) throw TypeError("Bubble body center offset requires a tail direction.");
3011
+ let i = E(e.tailLength ?? oe), a = se(e.offset), o = {
3012
+ x: t / 2,
3013
+ y: n / 2
3014
+ }, s = j(we(e.style, t, n), t, n, r, i, a);
3015
+ return Object.freeze({
3016
+ x: s.bodyCenter.x - o.x,
3017
+ y: s.bodyCenter.y - o.y
3018
+ });
3019
+ }
3020
+ function Ee(e, t, n, r, i, a, o, s) {
3021
+ let c = O(t, n), l = (e) => r === null ? e : j(e, t, n, r, o, s).body, u = (e, c = "") => {
3022
+ if (r === null) return ve(e, i, a, c);
3023
+ let l = j(e, t, n, r, o, s);
3024
+ return ye(l.body, l.bodyCenter, l.tip, i, a, c);
3025
+ };
3026
+ switch (e) {
3027
+ case "NO_BUBBLE": return "";
3028
+ case "THINKING":
3029
+ case "DREAMING": {
3030
+ if (r === null) return be(t, n, i, a);
3031
+ let l = j(c, t, n, r, o, s), u = s.scalePercent / 100, d = {
3032
+ x: t / 2,
3033
+ y: n / 2
3034
+ }, f = l.bodyCenter.x - d.x * u, p = l.bodyCenter.y - d.y * u;
3035
+ return `${xe(l.body, l.bodyCenter, l.tip, i, a, e === "DREAMING")}<g transform="translate(${f} ${p}) scale(${u})">${be(t, n, i, a)}</g>`;
3036
+ }
3037
+ case "YELLING": return u(Se(t, n));
3038
+ case "WAVY": return u(Ce(t, n));
3039
+ case "WHISPERING": return u(c, "stroke-dasharray=\"5 5\"");
3040
+ case "ANNOUNCEMENT": return `${u(c)}<rect x="30" y="30" width="${t - 60}" height="${n - 60}" rx="13" fill="none" stroke="${a}" stroke-width="1.5"/>`;
3041
+ case "NARRATION": return ve(l(c), i, a);
3042
+ case "OFF_PANEL": return u(c);
3043
+ case "NORMAL": return u(c);
3044
+ }
3045
+ }
3046
+ function De(e) {
3047
+ if (!D.includes(e.style)) throw TypeError(`Unsupported Bubble visual style: ${String(e.style)}`);
3048
+ if (!Array.isArray(e.lines) || e.lines.some((e) => typeof e != "string")) throw TypeError("lines must be an array of strings.");
3049
+ let t = le(e.width, 220), n = le(e.height, 112), r = le(e.fontSize, 15), i = ue(e.tailDirection), a = E(e.tailLength ?? oe), o = e.offset === void 0 ? T : se(e.offset), s = e.fillColor ?? "#fff4cc", c = e.borderColor ?? "#6f5b45", l = e.textColor ?? "#25283a", u = e.fontFamily ?? "Noto Sans JP, sans-serif", d = r * 1.35, f = n / 2 - (e.lines.length - 1) * d / 2 + r * .35, p = i === null ? 1 : o.scalePercent / 100, m = i === null ? {
3050
+ x: t / 2,
3051
+ y: n / 2
3052
+ } : j(O(t, n), t, n, i, a, o).bodyCenter, h = e.lines.map((e, t) => `<text x="${m.x}" y="${m.y + (f + t * d - n / 2) * p}" text-anchor="middle" fill="${ce(l)}" font-family="${ce(u)}" font-size="${r * p}">${ce(e)}</text>`).join(""), g = ce(e.title ?? `${e.style} bubble`);
3053
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${n}" viewBox="0 0 ${t} ${n}" role="img" data-bubble-renderer="canonical" data-bubble-style="${e.style}"><title>${g}</title>${Ee(e.style, t, n, i, s, c, a, o)}${h}</svg>`;
3054
+ }
3055
+ //#endregion
3056
+ //#region node_modules/.pnpm/@cto.af+unicode-trie-runtime@3.2.9/node_modules/@cto.af/unicode-trie-runtime/constants.js
3057
+ var Oe = 2048, ke = 2112, M = Uint8Array, N = Uint16Array, Ae = Int32Array, je = new M([
3058
+ 0,
3059
+ 0,
3060
+ 0,
3061
+ 0,
3062
+ 0,
3063
+ 0,
3064
+ 0,
3065
+ 0,
3066
+ 1,
3067
+ 1,
3068
+ 1,
3069
+ 1,
3070
+ 2,
3071
+ 2,
3072
+ 2,
3073
+ 2,
3074
+ 3,
3075
+ 3,
3076
+ 3,
3077
+ 3,
3078
+ 4,
3079
+ 4,
3080
+ 4,
3081
+ 4,
3082
+ 5,
3083
+ 5,
3084
+ 5,
3085
+ 5,
3086
+ 0,
3087
+ 0,
3088
+ 0,
3089
+ 0
3090
+ ]), Me = new M([
3091
+ 0,
3092
+ 0,
3093
+ 0,
3094
+ 0,
3095
+ 1,
3096
+ 1,
3097
+ 2,
3098
+ 2,
3099
+ 3,
3100
+ 3,
3101
+ 4,
3102
+ 4,
3103
+ 5,
3104
+ 5,
3105
+ 6,
3106
+ 6,
3107
+ 7,
3108
+ 7,
3109
+ 8,
3110
+ 8,
3111
+ 9,
3112
+ 9,
3113
+ 10,
3114
+ 10,
3115
+ 11,
3116
+ 11,
3117
+ 12,
3118
+ 12,
3119
+ 13,
3120
+ 13,
3121
+ 0,
3122
+ 0
3123
+ ]), Ne = new M([
3124
+ 16,
3125
+ 17,
3126
+ 18,
3127
+ 0,
3128
+ 8,
3129
+ 7,
3130
+ 9,
3131
+ 6,
3132
+ 10,
3133
+ 5,
3134
+ 11,
3135
+ 4,
3136
+ 12,
3137
+ 3,
3138
+ 13,
3139
+ 2,
3140
+ 14,
3141
+ 1,
3142
+ 15
3143
+ ]), Pe = function(e, t) {
3144
+ for (var n = new N(31), r = 0; r < 31; ++r) n[r] = t += 1 << e[r - 1];
3145
+ for (var i = new Ae(n[30]), r = 1; r < 30; ++r) for (var a = n[r]; a < n[r + 1]; ++a) i[a] = a - n[r] << 5 | r;
3146
+ return {
3147
+ b: n,
3148
+ r: i
3149
+ };
3150
+ }, Fe = Pe(je, 2), Ie = Fe.b, Le = Fe.r;
3151
+ Ie[28] = 258, Le[258] = 28;
3152
+ var Re = Pe(Me, 0), ze = Re.b;
3153
+ Re.r;
3154
+ for (var Be = new N(32768), P = 0; P < 32768; ++P) {
3155
+ var F = (P & 43690) >> 1 | (P & 21845) << 1;
3156
+ F = (F & 52428) >> 2 | (F & 13107) << 2, F = (F & 61680) >> 4 | (F & 3855) << 4, Be[P] = ((F & 65280) >> 8 | (F & 255) << 8) >> 1;
3157
+ }
3158
+ for (var Ve = (function(e, t, n) {
3159
+ for (var r = e.length, i = 0, a = new N(t); i < r; ++i) e[i] && ++a[e[i] - 1];
3160
+ var o = new N(t);
3161
+ for (i = 1; i < t; ++i) o[i] = o[i - 1] + a[i - 1] << 1;
3162
+ var s;
3163
+ if (n) {
3164
+ s = new N(1 << t);
3165
+ var c = 15 - t;
3166
+ for (i = 0; i < r; ++i) if (e[i]) for (var l = i << 4 | e[i], u = t - e[i], d = o[e[i] - 1]++ << u, f = d | (1 << u) - 1; d <= f; ++d) s[Be[d] >> c] = l;
3167
+ } else for (s = new N(r), i = 0; i < r; ++i) e[i] && (s[i] = Be[o[e[i] - 1]++] >> 15 - e[i]);
3168
+ return s;
3169
+ }), He = new M(288), P = 0; P < 144; ++P) He[P] = 8;
3170
+ for (var P = 144; P < 256; ++P) He[P] = 9;
3171
+ for (var P = 256; P < 280; ++P) He[P] = 7;
3172
+ for (var P = 280; P < 288; ++P) He[P] = 8;
3173
+ for (var Ue = new M(32), P = 0; P < 32; ++P) Ue[P] = 5;
3174
+ var We = /*#__PURE__*/ Ve(He, 9, 1), Ge = /*#__PURE__*/ Ve(Ue, 5, 1), Ke = function(e) {
3175
+ for (var t = e[0], n = 1; n < e.length; ++n) e[n] > t && (t = e[n]);
3176
+ return t;
3177
+ }, I = function(e, t, n) {
3178
+ var r = t / 8 | 0;
3179
+ return (e[r] | e[r + 1] << 8) >> (t & 7) & n;
3180
+ }, qe = function(e, t) {
3181
+ var n = t / 8 | 0;
3182
+ return (e[n] | e[n + 1] << 8 | e[n + 2] << 16) >> (t & 7);
3183
+ }, Je = function(e) {
3184
+ return (e + 7) / 8 | 0;
3185
+ }, Ye = function(e, t, n) {
3186
+ return (t == null || t < 0) && (t = 0), (n == null || n > e.length) && (n = e.length), new M(e.subarray(t, n));
3187
+ }, Xe = [
3188
+ "unexpected EOF",
3189
+ "invalid block type",
3190
+ "invalid length/literal",
3191
+ "invalid distance",
3192
+ "stream finished",
3193
+ "no stream handler",
3194
+ ,
3195
+ "no callback",
3196
+ "invalid UTF-8 data",
3197
+ "extra field too long",
3198
+ "date not in range 1980-2099",
3199
+ "filename too long",
3200
+ "stream finishing",
3201
+ "invalid zip data"
3202
+ ], L = function(e, t, n) {
3203
+ var r = Error(t || Xe[e]);
3204
+ if (r.code = e, Error.captureStackTrace && Error.captureStackTrace(r, L), !n) throw r;
3205
+ return r;
3206
+ }, Ze = function(e, t, n, r) {
3207
+ var i = e.length, a = r ? r.length : 0;
3208
+ if (!i || t.f && !t.l) return n || new M(0);
3209
+ var o = !n, s = o || t.i != 2, c = t.i;
3210
+ o && (n = new M(i * 3));
3211
+ var l = function(e) {
3212
+ var t = n.length;
3213
+ if (e > t) {
3214
+ var r = new M(Math.max(t * 2, e));
3215
+ r.set(n), n = r;
3216
+ }
3217
+ }, u = t.f || 0, d = t.p || 0, f = t.b || 0, p = t.l, m = t.d, h = t.m, g = t.n, _ = i * 8;
3218
+ do {
3219
+ if (!p) {
3220
+ u = I(e, d, 1);
3221
+ var v = I(e, d + 1, 3);
3222
+ if (d += 3, !v) {
3223
+ var y = Je(d) + 4, b = e[y - 4] | e[y - 3] << 8, ee = y + b;
3224
+ if (ee > i) {
3225
+ c && L(0);
3226
+ break;
3227
+ }
3228
+ s && l(f + b), n.set(e.subarray(y, ee), f), t.b = f += b, t.p = d = ee * 8, t.f = u;
3229
+ continue;
3230
+ }
3231
+ if (v == 1) p = We, m = Ge, h = 9, g = 5;
3232
+ else if (v == 2) {
3233
+ var x = I(e, d, 31) + 257, te = I(e, d + 10, 15) + 4, S = x + I(e, d + 5, 31) + 1;
3234
+ d += 14;
3235
+ for (var C = new M(S), ne = new M(19), w = 0; w < te; ++w) ne[Ne[w]] = I(e, d + w * 3, 7);
3236
+ d += te * 3;
3237
+ for (var re = Ke(ne), ie = (1 << re) - 1, ae = Ve(ne, re, 1), w = 0; w < S;) {
3238
+ var oe = ae[I(e, d, ie)];
3239
+ d += oe & 15;
3240
+ var y = oe >> 4;
3241
+ if (y < 16) C[w++] = y;
3242
+ else {
3243
+ var T = 0, E = 0;
3244
+ for (y == 16 ? (E = 3 + I(e, d, 3), d += 2, T = C[w - 1]) : y == 17 ? (E = 3 + I(e, d, 7), d += 3) : y == 18 && (E = 11 + I(e, d, 127), d += 7); E--;) C[w++] = T;
3245
+ }
3246
+ }
3247
+ var se = C.subarray(0, x), D = C.subarray(x);
3248
+ h = Ke(se), g = Ke(D), p = Ve(se, h, 1), m = Ve(D, g, 1);
3249
+ } else L(1);
3250
+ if (d > _) {
3251
+ c && L(0);
3252
+ break;
3253
+ }
3254
+ }
3255
+ s && l(f + 131072);
3256
+ for (var ce = (1 << h) - 1, le = (1 << g) - 1, ue = d;; ue = d) {
3257
+ var T = p[qe(e, d) & ce], O = T >> 4;
3258
+ if (d += T & 15, d > _) {
3259
+ c && L(0);
3260
+ break;
3261
+ }
3262
+ if (T || L(2), O < 256) n[f++] = O;
3263
+ else if (O == 256) {
3264
+ ue = d, p = null;
3265
+ break;
3266
+ } else {
3267
+ var k = O - 254;
3268
+ if (O > 264) {
3269
+ var w = O - 257, A = je[w];
3270
+ k = I(e, d, (1 << A) - 1) + Ie[w], d += A;
3271
+ }
3272
+ var de = m[qe(e, d) & le], fe = de >> 4;
3273
+ de || L(3), d += de & 15;
3274
+ var D = ze[fe];
3275
+ if (fe > 3) {
3276
+ var A = Me[fe];
3277
+ D += qe(e, d) & (1 << A) - 1, d += A;
3278
+ }
3279
+ if (d > _) {
3280
+ c && L(0);
3281
+ break;
3282
+ }
3283
+ s && l(f + 131072);
3284
+ var pe = f + k;
3285
+ if (f < D) {
3286
+ var me = a - D, he = Math.min(D, pe);
3287
+ for (me + f < 0 && L(3); f < he; ++f) n[f] = r[me + f];
3288
+ }
3289
+ for (; f < pe; ++f) n[f] = n[f - D];
3290
+ }
3291
+ }
3292
+ t.l = p, t.p = ue, t.b = f, t.f = u, p && (u = 1, t.m = h, t.d = m, t.n = g);
3293
+ } while (!u);
3294
+ return f != n.length && o ? Ye(n, 0, f) : n.subarray(0, f);
3295
+ }, Qe = /*#__PURE__*/ new M(0), $e = function(e) {
3296
+ (e[0] != 31 || e[1] != 139 || e[2] != 8) && L(6, "invalid gzip data");
3297
+ var t = e[3], n = 10;
3298
+ t & 4 && (n += (e[10] | e[11] << 8) + 2);
3299
+ for (var r = (t >> 3 & 1) + (t >> 4 & 1); r > 0; r -= !e[n++]);
3300
+ return n + (t & 2);
3301
+ }, et = function(e) {
3302
+ var t = e.length;
3303
+ return (e[t - 4] | e[t - 3] << 8 | e[t - 2] << 16 | e[t - 1] << 24) >>> 0;
3304
+ };
3305
+ function tt(e, t) {
3306
+ var n = $e(e);
3307
+ return n + 8 > e.length && L(6, "invalid gzip data"), Ze(e.subarray(n, -8), { i: 2 }, t && t.out || new M(et(e)), t && t.dictionary);
3308
+ }
3309
+ var nt = typeof TextDecoder < "u" && /*#__PURE__*/ new TextDecoder();
3310
+ try {
3311
+ nt.decode(Qe, { stream: !0 });
3312
+ } catch {}
3313
+ //#endregion
3314
+ //#region node_modules/.pnpm/@cto.af+unicode-trie-runtime@3.2.9/node_modules/@cto.af/unicode-trie-runtime/swap.js
3315
+ var rt = new Uint8Array(new Uint32Array([305419896]).buffer)[0] === 18;
3316
+ function it(e) {
3317
+ let t = e.length;
3318
+ for (let n = 0; n < t; n += 4) [e[n], e[n + 1], e[n + 2], e[n + 3]] = [
3319
+ e[n + 3],
3320
+ e[n + 2],
3321
+ e[n + 1],
3322
+ e[n]
3323
+ ];
3324
+ }
3325
+ function at(e) {}
3326
+ var ot = rt ? it : at, st = new TextDecoder(), R = class e {
3327
+ constructor(e) {
3328
+ if (e instanceof Uint8Array) {
3329
+ let t = 0, n = new DataView(e.buffer);
3330
+ if (this.highStart = n.getUint32(0, !0), this.errorValue = n.getUint32(4, !0), t = n.getUint32(8, !0), t !== 4294967295) throw Error("Trie created with old version of @cto.af/unicode-trie.");
3331
+ if (t = n.getUint32(12, !0), 16 + t > e.byteLength) throw RangeError("Invalid input length");
3332
+ let r = e.subarray(16 + t);
3333
+ this.values = r.length ? JSON.parse(st.decode(tt(r))) : [], e = tt(e.subarray(16, 16 + t)), ot(e), this.data = new Int32Array(e.buffer);
3334
+ } else ({data: this.data, highStart: this.highStart, errorValue: this.errorValue, values: this.values = []} = e);
3335
+ }
3336
+ static fromBase64(t) {
3337
+ return new e(new Uint8Array(atob(t).split("").map((e) => e.charCodeAt(0))));
3338
+ }
3339
+ get(e) {
3340
+ let t = this.errorValue;
3341
+ if (e < 0 || e > 1114111) t = this.errorValue;
3342
+ else if (e < 55296 || e > 56319 && e <= 65535) {
3343
+ let n = (this.data[e >> 5] << 2) + (e & 31);
3344
+ t = this.data[n];
3345
+ } else if (e <= 65535) {
3346
+ let n = (this.data[Oe + (e - 55296 >> 5)] << 2) + (e & 31);
3347
+ t = this.data[n];
3348
+ } else if (e < this.highStart) {
3349
+ let n = this.data[ke - 32 + (e >> 11)];
3350
+ n = this.data[n + (e >> 5 & 63)], n = (n << 2) + (e & 31), t = this.data[n];
3351
+ } else t = this.data[this.data.length - 4];
3352
+ return t;
3353
+ }
3354
+ getString(e) {
3355
+ let t = this.get(e);
3356
+ return this.values[t] ?? t;
3357
+ }
3358
+ }, ct = R.fromBase64("AAgOAAEAAAD/////nRQAAB+LCAC4xcFoAgPtnQnwlkUdx1+URLxABcUUghTEEK8Cmwp0LJAa\n MRrFbBSPSXHSAUYNdFQoBWMKyQrUCo/EyMIjD3TIAxXJM5NBHBm0RDSPzDOVdAz7/nB/07bt\n s8/e+/zhfef9zD7HPs/e129/u8/yzVutVWANeBl079xq9QJ9wUCwDxjqYQ4DI8BoMBYcBY4D\n 48FEw3NTwDTp/BxwAZgJLgaXgCvAAnADuA3cDe4Hj0rPLQerwLPgJfAaeBe8Az4EnT/Ram0D\n eoBdwe5gENgX0DsOhHkQGAlGgTHgaHACGA8mgilgGpgBLgJzweVgPlgIbgF3iPOl4BGwAqwG\n a8Er4C2wDnwEumzRanUDPUFv0B8MBgeAL4BDwNfAN8C3wIngO+A0cCZowd/nwrwA/Eic/wzm\n L8EMHM+HuRDcDP4g7t8Hk3hYmI8BCv+TwvwLTOZvglfBawKyQ7wrjv8Ns1OXVqsroPNuwuwJ\n szfoL86JwTgeIp3HYJj0vhE4Hg3GgnHgZMDhnYDjyWCqZP9CHM8Gc8S1y2BeBa4FvweLxPN3\n wVwq7Dwirp0KVuB4NVgLXgSvg/fA+6C1Jf6gO+gF+oI9wQa3YQ4FwwDlwREwR4Mj+L6GY3Dv\n eMN9OY7JPAV2Jwn7Z8E8F0wHs8AcMA9cA64Dt4I7wT3gQfA4eAI8DdaKd7wizLdgvg86dUWa\n g+1BL0D3+sIcAAaLc5X9xfUDYR4EDlUYJR2PAUeCY8FJ4DRwJjgXTAezwBwwD1wDrgO3gjuF\n G/fAfBA8Js5XwnwaPF/htypeFfbfhvm+w7OdtkL6Axe3thP2uSzuhPM+YICA6tZ9YA4FwwGV\n 55F0XTBGOlY5GhwHxoOJYAqYBn4AfiyOLwVXgvnSc9dKxzeC28XxEoNbbdq0iQvXEe24aNOm\n TZs2bdq0aePC0ob55yFhPg5IHlI3Rl4Je8+I/vALMN+T7v3DMN5+B/c+BJ23hhwQ0LUeMM+G\n OQrshuM9AMkJ94b5WfBF8GVwKPg6+CYgOc7xME8BLFsiJuH8LPA9MFO8/yJhMnNxfjm4AlwJ\n rgK/AleD+e177Xvte+177XvR7/0O3ARuBSQzLcmd8ENJSoe/TZsmE9qfvR9l7FHwhNL3c+Ep\n zbPP4trz4FXwT/AB2Gyb/7WzJc67g16gLxgIBgOasxkCcxgoXf/c2+1jDu7ean0fLDbwDvjc\n 9pi7Aj8H8r1V4vxlmLvtgLlCMBesBNvs+PG9g2GeBxaB5aB7j1brOczh9UN8nAiuBs8BGg8c\n BqgP/xOqI2n+VvAQzile53T6L6NwLts5G+eLwSpxfT3M4dtiTg0sAevB8O1wDuT35GZJA9yX\n 461NmzZtNiXWow6cTrpKaCNGU3uhtPNjcW0cOEFq28fjeAI4HUwWz8iQbIvsrYM5VTw3HSbp\n Fs2EebG4dpnGPYL0hM4n3SfcXyDsLhTmzTBvA3eI86VKn6MK0lshfao/kt9x/pjk7ydFW7lG\n vIt0rl4W99+EuQ58BEh3jP3bBW1oVxHObjjeCfQB7B7bG8DXYJ5OelYwvwS+Ath9fuY0KT4O\n E88dKcxjYJIs8NswT5WeVSG/k/0zYOcccL54nuLvh+QHmD8V5jJA8fILnP8Lz10N87eAdMRu\n grlY9Bfo/AGYfwYrxPl9eOdqHK8l/+D47zDfFv76AOZmyFeTcLwVzB1AL9AXDAT7gSFgGBgB\n yH87ks4ZjseK86+CcdQ+a8JI90/GvQniPtufjPOp4vkLYc4Gc8Hl4NfgesP7Fin3OE3uwvVl\n 4BGwQrKzGsd/BS+C18Hb4APhdif0J7sC1unbHsf83C7SMd3vh/O9yC4YCoaBQ8Aoyd4YHB8J\n jgUngVMBlQ8qG2dI9nScg/sXgJngYsnupTi+EvxG+DMnXI7UuCZuNPjn9pqwboxQOeXwc50Q\n gyUinh8wxPfDFfeW4/qqAvmmaVDb6PvsGiX+XvLM2/1Qb76xEZeLGOlEdTC1i+tEnNMx1Z8f\n ivPOGJtvDXYEJNfw9eeueL4uHLvDziBA/Rb5+gG4Rvq0n5feQTKJXHp8rlBfaiT8R7KcKnnV\n 4Yb42BQ4wjL9joG9E8Apjul9uBL3TS+/kxC+74LzGpAvTHl7BvznUyYuwnM05iGoLM/F+Tzl\n XdyHqStbZM4S5/PxjoXgJvEuWqvAdkmuKIeL6hV5TET9e6r/qsJPazHIvBfveQgsF248BXMF\n 1YcOcXGERXv4AslIPeNXhuL3TVFnroO5HmwB2WtT8j21Mdsa/NMT93qDDevFkJ79Fbsb1s7g\n 2hDLMFE/cZh434iAeKD3jDY8T/fHGu5TuMfVuH+y8KeOCeJZPp+cIU1JD4fcmiq5NVvIIaqe\n oXJyIezPBpeAK8AC8Xxvi/5YXd1+A951C6C1R4uFeTdMurdMmC78Cc+sBM+ANdLzNF/xBlgH\n PpKud8G8xXagB9gZ9AF0fQ+Yg8QxcQCOh4rz4TBHimM5TQ/HNT5egHDQfdZFOkrcI/nEcTge\n Dyh+JsKcIt41TZgzYM5S3j9H8gsxD+dXSe4x10rXrleeyc2iwu6XhsJ/F8WBqMeJ/ysfBpaJ\n PNKReXzzThvYDKd1YFn0hscg/tsALZ21ec4GsTS0hWLZou4kDX9oaELHdI1EeiT24ntUtVGX\n g0yq7igpbCD7BL2HIXfl89RQWCgMHJ7ckPuUlpj63XBO8Y9pyE2aTf2nK5NQC4hWvuvoKfIl\n lXkqGwzlz50EfMx1BOVhztP8HNvdWXlWhp6Xz8ndlOWN/V6K0u43Dc4fch7gc9s4U/OU/Azn\n vZLkKrdNheqTKnzeVxff/FOvc19D/dW9SzZjkuKdMfPmxlrn5Ix3mzzWBKhs9NL4l9rxqj5J\n 06HwcD6W8zQf01iDzLrfLhmpc1vNVza/qvGXnP7UZ2PUcZlLnHOcksk0KZ+nyGe2412KW13c\n p65rOQ3qwmCyo8afzi7bsY2PmPV4yfYqZl7qKO1F6nhyreNs6rvY+S9XnOjaai7TssxAHqfn\n 8GuV/9XrVfZi5PVcZaXK367u636hfuP8bCtL8u3np+6vURhK9BObUPZjxm+scZ0810DkrFfV\n 8uY6zgotWy5ygSq35DJYlyZqedWVX5s2UTeeqQqT6pZr+vJ4QRc/fF1uj6rCZYprU1hypG/d\n sRznpnS1Sd+6dKzLa3X5wzZ9dfWEa5/Mtfzq0qRE+vqWX10eqErfkL6tOubxLb8s1zG54RLO\n nPWzb/3pkl9z1J8ufcQqP9fl9ao6w9Re6cKsS7u6a3Xto2s81NWvpjxqW/5s5IEpxpncTtr2\n 4XPWpbHGWa79Idv0NMWZKR5i1aemn+38oxwum2dKpm+M9jJm+pr6RrHSV9eH9dXnyN0XijEO\n i5GedX16VzluqvZXHr9UpY1P/9a1zSs176m2kbb+NY13qvKLjYwqtP1V/eLT//5kQ1B/1G8I\n eZ/LfA3LgUzxw8dVcZYiLuvcjB33IX7wybe6NKM+gox8jfRq+JjSi87l+ViGrut0buvaqdhy\n QPKj3MawSbqApBfLZoi81kcuXqV3XXc9VHbeBH0L+nF5N7W/Nm2NnBer+rasD9bEute1flTD\n lst9Ux1vK8PWjZFD+x27Fma3wvQujG/fMFQ/0iX/hD7f9PClnr9OHX8+Mh65PTS1Iyn9UULX\n M/b8vq9uKf9ID7KkjkvOtOe+om/8cxvu6meXubpY+jcuc0Wx3TeNBVOH33e+LKQ+rZM55pQd\n cNz3kc4578rygFhy7Fj1H4872f88FpD1hNV1Iy76tbnr35Dyn1v3yCT3KhEnJdpnG1mui46u\n ryzBNNaiH5eH0HFfbPlWqvouVX0ZKjdW65S68XQqfWC1nJSUO8eoj0OfjxGGUjI1V/erZGIh\n P507n8qIa7z1tXinLK/sZwnb/7TS7+drNtj43+Y9sttN00121aMOnR+wTb/UuIZ/d4FrfydV\n PSOXCRmf+jfl/E9KuUMpuVPMfnKMdQIucze69X6m8YPvngAl9yOwqWNt5Wsu+hSp9xRoytr0\n UN3tunhPHQ91brDsoqqOZSivyed7iDzXX8p/JJ8le2QSA4C8lwntkcP7bvGxfC7bJfaUIDd5\n j7CqsiCv/dYh+4HcIbkTYdpLgOWwbNdk31R/k/tqnKpy2oGB43o1H9js0cPhk/ebUfegsZVT\n h8pW5D2aVNQ9nFzQPStf4+MQN4jYfZ4Q+TDndzUNTfqAVfs7uazFtc03KfaP0u3LZYvP877u\n ++6zpf5SuOfiJ9+w6PylXtPdZ1Pdx80UZ1VxoYahLl/Y7tflUxbqwhyr7OjioCpuTOexymmM\n 99vGWe5960LdoT5PrDlkNn39yrIdFzdTxKkqa0o9n5NyfjbFL6T9i03O9jTEjVT9CZt61qWe\n DAmTbX1rkw4ubWysflyu/Uh19Utdv8QUb/wevs/vlN3YK0J95hvGWP26FP0CXV0ix6XOfmi8\n lNw7tlSc284PqXnZlKf5umpfVx7Ue3K5q4onnT9079H5h8ubyX5VGZHfIVOiPynLz2RkPSTV\n /2p/0NZM2Ufw7dPm3tveJp46kn5prDC7miXDUCoOc7QdKeU9KeZZbNZTsw6ZKjPna6G6jLZ6\n v6Y9S0rqHMbaN8j3flUbVIdpnonTleaP+JsiapunntfVOer7WUdXNw+jCyvNYxE6P9Ix+7Mu\n TCa3uM3mb9JUmfLe1q59N19yulXnD5dfU/yRyn/8vR2Cr9H8JB/btsm29undfCw/56tbVmVX\n d53nXtV0+Iw4rjNTk8udOvdtwl13j1B1YuT5b04HMpsW/7HCr8t/dF0Of846J3W9HPtdNnUf\n x7UvpdsiV1mJjawiFLWODEm73G1mLF1J2/GB7X7UtvqhJeeTfPc4T7mPtLpuWqWJ66malIZV\n Oq6uerCp9Oh1dlzCzrpIudKf92/hsZbP+hIbHa0Q/fQYe/v4lmd5T5s6veq6vYViyzJT69KV\n 2t/FlN451zKFrm3i9U0264J0fQOX9U5Vfe6S+xPRL8VaHJe8rK69qpNJqe92jX81XX3X2fr8\n XPaHsq1PdPWWa12Sag1GaXmwT98pZ/2vy8+h7e8gsHdGcrvn+ou5l5j6K7GfmPobXJiY4xLb\n d9C3GKnM2H7Xkd7j+z1I03X5ftWxjd9KwDLy0mNPV/fUtSCh4wyeF5DXS8nzWnSd9Jqrfrye\n UWfa3NP1O131E9TnTDItvs/rn9Qwm9y3lS/yuiSdDK2J32LmH61l4/l7DpMcFl0cy/HpKvNU\n 5Z6yuzmgsPj4PZX78jydfMzx1BFk7Gr61smlU9yXf7w+UL7Pa5Fc9pe3lTntI+YJYvTvQ9Y9\n x9gbNOU66lxyYJPsuqPtBRpjvW7uX6n9Y3LpfMUe8+fYy6sJ+99x2QyVR1TJrEvlz9Lxmzq8\n Kct+jO8mpnIrV35pYv3rso+6j2w1RzkxpWeOslpV38Xey7lJ7XVVnDdFVyDn2o2m7A1s871r\n U3+hbp661LfjbL6l6vL9O5v5uiqdcd/9mG3sVrlrktHl3m+5Ln46Qply/f51rDq2afV3U92P\n 9Z2CVPu71+kExf4uhm265Mpfcrjl9S+p/WGjb9FEeYmrHlhsXTLb772b2v3U8bKvoAk6VaQ3\n ZdqvWf2FytNd9g1W/c57VNf9+JuMuXT+ZJ1tnZ6T7U+un1PXpSm/BxKiZ+b6nUC5P+bybdoU\n 3wWR9zP1WcOrrtc06dG7rA9gf6lzCCVlQKl1cKvW16r7MjdxPqHue3m55l5M6yRy1q8p6i+d\n GzbfR5Dtqeeu1D2rulVlp+67ulXfzlDPqS/AP52us+kb5aoetdp226wrqOtHuvxc9InlsMrX\n 5HCkgvtULt80VtPB5tvHlLbU51R1leQ+nW0ftknjClM7Ktf7Pt9n161FKfULHbeU/P5brO/5\n 8PeveZ2l+s31OpmmizxP5z/VrssvNP7Vb9XbUGr+LWSdWKr4c/lemct7U/1KfJcs5nfiXNcz\n Va3lCf2OXi75c+gaSd/4SyH/pmds+8G2fWCbvmwMeZapf6v2g9hU16vF7l/65K8cc6uh7bIs\n W8jdLyyxp4BPPOru6+Qx8rd8beIyhew8xjoMtU8l90dcyldseUOJPpPLevpc7ZnvL8f4oaRO\n ad34WVeefPYVSdG+27T7vPdESj0VV5leyvXoufQvffKZTpZmGy+27UNKfYCc5dWmj2fbp44Z\n P6G/WN9X1cl8beoieS7ad7+PGP14nz1ATO1q3Xx2jHnpWO1xR1uPovumYQndrFD9uyrdvpD4\n b9L8Yaz9wxl5bbVu/XlT9j2X/Rr6Hl7brYPd0V1jM5bOk+84oUn7xpeeH7IhVJ7j25+IrU9s\n ig+XOi7lGMtGj9pGB903/kuMQVPuORpjv7+c35AvvYYkNO1CviFvU4/HkF+qe2ZTG+VTn1bt\n fV7y5/PtqNR76oeuy4zlH3n/9ND3qPuxu7xb3cuj7heahiXq4ljrC1R5vm5M39HGFz7yzRLr\n k1PoMMfcPzeGvDPWPssxw6Rzo8QcXmp3XGSSHX2/Et08k67f5dtmuupKN2FvMpOsKObeDnVx\n k3ofp1h6VrFIVVdV7T2fYm9013l7k/5rbNlKaBuXso7LLV+K1d67uuWiJ19ShhcjvUP97FsO\n Q+V7pdfDpy5rtv2qEPkU7XFY0v3Q+Oc8FpqHdHV9Xf415XFbPTPfPk7qNWsufow9vkqlz6v+\n eA4udH9l3XxtiA5ZyN5XpvxSNzdetRdQlWnKjzbP695Xt9+WTz/bJk5y6tDVlYHUe0Crv9Bv\n vMf+bnzq79DHenfs/ZD3y4TO7b0S7vPM8Z5yL2mTG1XXKcyMLh5093OzvwbVfzr/1hHDby7u\n ufhH5z/Vrm1YZPsheUtn2pQh+RnfMmCqy3PN7aSeN0oRtrp8m6oONOXflHVfrnj0ccdU1lVS\n yYu7Ssjz96ZwxEgz13rX1c3Y+Sp2vJve7eN+zP3nYsojYunAhMq1cs2vM1X9J99+Q2g+d+1z\n 5OznpXJD1zcKcc/U33KN39TzgCnr4lz95Fz1cW79kxT6SDF00UruT5ZDZ8Xl9x83MV0I0CwB\n AB+LCAC4xcFoAgMdjksWhCAMBO/CelYzJ4gMCqiI4t/n/a9hyk29JN3p5DL7bj7GTQrbKypR\n dDVVywyhZCz4xkUhnSIj5EExoFoQisIfbICE2WJOoAESSK7wecCscDJSxRXMbBAlfLCyIbTh\n T8tr5/YikvVFSYq3dURbKo/gf+Q3zBCELycCXW/uB2mPjCb8AAAA"), lt = Object.fromEntries(ct.values.map((e, t) => [e, t])), { values: ut } = ct, { AI: dt, AL: ft, CJ: pt, CM: z, NS: mt, SA: ht, SG: gt, SP: _t, XX: vt } = lt;
3359
+ function yt(e) {
3360
+ switch (e) {
3361
+ case null: return null;
3362
+ case -1: return "sot";
3363
+ case -2: return "eot";
3364
+ default: return ut[e];
3365
+ }
3366
+ }
3367
+ function bt(e, t) {
3368
+ switch (e) {
3369
+ case dt:
3370
+ case gt:
3371
+ case vt: return ft;
3372
+ case ht: return /^[\p{gc=Mn}\p{gc=Mc}]$/u.test(t) ? z : ft;
3373
+ case pt: return mt;
3374
+ }
3375
+ return e;
3376
+ }
3377
+ var B = class {
3378
+ cp = -Infinity;
3379
+ cls = -1;
3380
+ char = "";
3381
+ len = 0;
3382
+ ignored = !1;
3383
+ constructor(e, t, n, r) {
3384
+ this.cls = e, this.cp = t, this.char = n, this.len = r;
3385
+ }
3386
+ [Symbol.for("nodejs.util.inspect.custom")](e, t, n) {
3387
+ return `${yt(this.cls)}(${this.cp.toString(16).padStart(4, "0")}:${JSON.stringify(this.char)})${this.ignored ? "Ig" : ""}`;
3388
+ }
3389
+ }, xt = class {
3390
+ str = "";
3391
+ len = 0;
3392
+ prevChunk = 0;
3393
+ prev = new B(-1, -Infinity, "", 0);
3394
+ cur = new B(-1, -Infinity, "", 0);
3395
+ next = new B(-1, -Infinity, "", 0);
3396
+ LB8 = !1;
3397
+ spaces = !1;
3398
+ RI = 0;
3399
+ props = void 0;
3400
+ extra = {};
3401
+ constructor(e) {
3402
+ this.str = e, this.len = e.length;
3403
+ }
3404
+ push(e) {
3405
+ this.next.ignored ? this.cur.len = this.next.len : (this.prev = this.cur, this.cur = this.next), this.next = e;
3406
+ }
3407
+ pushEnd() {
3408
+ this.push(new B(-2, Infinity, "", this.next.len));
3409
+ }
3410
+ *codePoints(e, t = !0) {
3411
+ if (t) for (; e < this.len;) if (e === this.cur.len && this.next.cls >= 0) yield this.next, e += this.next.char.length;
3412
+ else {
3413
+ let t = this.str.codePointAt(e), n = String.fromCodePoint(t), r = ct.get(t);
3414
+ e += n.length, yield new B(bt(r, n), t, n, e);
3415
+ }
3416
+ else for (; e > 0;) if (e === this.cur.len) yield this.cur, e -= this.cur.char.length;
3417
+ else if (e === this.prev.len) yield this.prev, e -= this.prev.char.length;
3418
+ else {
3419
+ let t = e - 1, n = this.str.charCodeAt(t);
3420
+ n >= 56320 && n <= 57343 && t--;
3421
+ let r = this.str.codePointAt(t), i = String.fromCodePoint(r);
3422
+ yield new B(bt(ct.get(r), i), r, i, e), e = t;
3423
+ }
3424
+ }
3425
+ classAfterSpaces(e) {
3426
+ for (let { cls: t } of this.codePoints(e)) if (t !== _t) return t;
3427
+ return -2;
3428
+ }
3429
+ afterNext(e = 1) {
3430
+ for (let t of this.codePoints(this.next.len)) if (--e <= 0) return t;
3431
+ return null;
3432
+ }
3433
+ setProp(e, t) {
3434
+ this.props ||= {}, this.props[e] = t;
3435
+ }
3436
+ [Symbol.for("nodejs.util.inspect.custom")](e, t, n) {
3437
+ let r = `${n(this.prev)} => ${n(this.cur)} => ${n(this.next)}`;
3438
+ return this.LB8 && (r += " LB8"), this.spaces && (r += " spaces"), this.RI > 0 && (r += ` RI: ${this.RI}`), this.props && (r += ` ${JSON.stringify(this.props)}`), r;
3439
+ }
3440
+ }, V = class {
3441
+ string = void 0;
3442
+ props = void 0;
3443
+ constructor(e, t = !1) {
3444
+ this.position = e, this.required = t;
3445
+ }
3446
+ }, H = R.fromBase64("AAAEAAAAAAD/////wQIAAB+LCAC1xcFoAgPtmj1IHUEQxzd5FiaEkMLSKqQIViEQCEmTjyqk\n SUgR7OySTrHxdVoIYqUg2AgqFhYWFhYidpYqKDaClVZaqJWF2qj/xT1cjjtv772Z3T1uHvzY\n 753d2b252ds3+1SpRbAMVkGSrlMo5LNjIfqoB/uEfR2Ao5yy4zb7PgUX4Brcgo6GUi9AF+gG\n r0EPeAc+AN3mM8KvJu6DH0bWb08yeyEneV77rHia/yjbMvEBxJum7mCqzQjSo1beuBWfRFy3\n 1fHpR2QJgiAIgiAIgiAIQpoZc45c8HhGd2WJYUyy5oIgCP5oRPhuEQQh7vvPVuAe34q5x1lH\n uJFh15J7HRt9Z7MJ9iKwg1fP72kG4osqz3ynUlNPHjhC2i5/9UypX8DOa6bSa0hfAbsf33zE\n /EPLr7NtOYj4zlTfD+v7dG0r8uzhXM39qEPH9TtBvTNwUXK9dyv0frzE3DSxje8mZ0yNjuz8\n zlT+S6T1OnQh7M5oo+f+Bvk67EGY/OfiPeKfTL5+hr6ZuM13k/cT4R/QC86tMfdZbf4a2Un6\n H9L9OXNIGCoo12yDYdR7mzG+tP8yhjoTpt607tuh/6r7b1VG7yv5ya/OP7iZQXEdYyi9UNel\n WKM83YTQE/f8qftudz9y7G/OdWlXLxTPYRm9cu+ZMutMaYuK2tnjyqpb5jnPa8+xH7n3eJFO\n ivRGbTNC6su3PeHYM0V7OxZ/hUtWLP5ZFfzDmMYQSieU8qj78rF3fMsI+axX5fwWYvw+5t9u\n f0VnNR964yh31bdLOce8qfYb11ndVWeUvibHfCj8tZD2LNZvTRyyW/GfQr1/OM8gob/LcPn8\n If3iVmVT23Iu/69KaxHzOYn6XenTNw1551DW/3V5X7v6c9Tfh7jPX9TrFtqOhjgPttqeW28u\n 33192kvqs2vW7w7BeyuJcEoAAB+LCAC1xcFoAgOLVvJT0lGKVIoFANHfAiwJAAAA");
3447
+ Object.fromEntries(H.values.map((e, t) => [e, t]));
3448
+ var { values: St } = H, { AK: Ct, AL: U, AP: wt, AS: Tt, B2: Et, BA: Dt, BB: Ot, BK: kt, CB: At, CL: jt, CM: Mt, CP: Nt, CR: Pt, EB: Ft, EM: It, EX: Lt, GL: Rt, H2: zt, H3: Bt, HH: Vt, HL: W, HY: Ht, ID: Ut, IN: Wt, IS: G, JL: Gt, JT: Kt, JV: qt, LF: Jt, NU: K, OP: Yt, NL: Xt, NS: Zt, PO: Qt, PR: $t, RI: en, SP: q, SY: tn, QU: J, VF: nn, VI: rn, WJ: an, ZW: on, ZWJ: sn } = lt, cn = /* @__PURE__ */ new Set([
3449
+ U,
3450
+ W,
3451
+ K
3452
+ ]), ln = /* @__PURE__ */ new Set([
3453
+ kt,
3454
+ Pt,
3455
+ Jt,
3456
+ Xt,
3457
+ q,
3458
+ on
3459
+ ]), un = /* @__PURE__ */ new Set([
3460
+ Ut,
3461
+ Ft,
3462
+ It
3463
+ ]), dn = /* @__PURE__ */ new Set([
3464
+ Gt,
3465
+ qt,
3466
+ zt,
3467
+ Bt
3468
+ ]), fn = /* @__PURE__ */ new Set([
3469
+ Gt,
3470
+ qt,
3471
+ Kt,
3472
+ zt,
3473
+ Bt
3474
+ ]), pn = /* @__PURE__ */ new Set([qt, Kt]), mn = /* @__PURE__ */ new Set([
3475
+ q,
3476
+ Rt,
3477
+ an,
3478
+ jt,
3479
+ J,
3480
+ Nt,
3481
+ Lt,
3482
+ G,
3483
+ tn,
3484
+ kt,
3485
+ Pt,
3486
+ Jt,
3487
+ Xt,
3488
+ on
3489
+ ]), hn = /* @__PURE__ */ new Set([
3490
+ -1,
3491
+ kt,
3492
+ Pt,
3493
+ Jt,
3494
+ Xt,
3495
+ Yt,
3496
+ J,
3497
+ Rt,
3498
+ q,
3499
+ on
3500
+ ]), Y = Symbol("PASS"), X = Symbol("NO_BREAK"), gn = Symbol("MAY_BREAK"), _n = Symbol("MUST_BREAK");
3501
+ function vn(e) {
3502
+ return e.cur.cls === -1 && e.next.cls !== -2 ? X : Y;
3503
+ }
3504
+ function yn(e) {
3505
+ return e.next.cls === -2 && (e.cur.len === 0 || e.cur.len !== e.prevChunk) ? _n : Y;
3506
+ }
3507
+ function bn(e) {
3508
+ return e.cur.cls === kt ? _n : Y;
3509
+ }
3510
+ function xn(e) {
3511
+ switch (e.cur.cls) {
3512
+ case Pt: return e.next.cls === Jt ? X : _n;
3513
+ case Jt:
3514
+ case Xt: return _n;
3515
+ }
3516
+ return Y;
3517
+ }
3518
+ function Sn(e) {
3519
+ switch (e.next.cls) {
3520
+ case kt:
3521
+ case Pt:
3522
+ case Jt:
3523
+ case Xt: return X;
3524
+ }
3525
+ return Y;
3526
+ }
3527
+ function Cn(e) {
3528
+ return e.cur.cls !== en && (e.RI = 0), e.spaces ? (e.next.cls !== q && (e.spaces = !1), X) : Y;
3529
+ }
3530
+ function wn(e) {
3531
+ if (e.next.cls === on) return X;
3532
+ if (e.next.cls === q) switch (e.cur.cls) {
3533
+ case on:
3534
+ case Yt:
3535
+ case J:
3536
+ case jt:
3537
+ case Nt:
3538
+ case Et: break;
3539
+ default: return X;
3540
+ }
3541
+ return Y;
3542
+ }
3543
+ function Tn(e) {
3544
+ return e.LB8 ? (e.LB8 = !1, gn) : e.cur.cls === on ? e.next.cls === q ? (e.LB8 = !0, X) : gn : Y;
3545
+ }
3546
+ function En(e) {
3547
+ return e.cur.cls === sn ? X : Y;
3548
+ }
3549
+ function Dn(e) {
3550
+ return !ln.has(e.cur.cls) && (e.next.cls === Mt || e.next.cls === sn) ? (e.next.ignored = !0, X) : Y;
3551
+ }
3552
+ function On(e) {
3553
+ return e.cur.cls === Mt && (e.cur.cls = U), e.next.cls === Mt && (e.next.cls = U), Y;
3554
+ }
3555
+ function kn(e) {
3556
+ return e.next.cls === an || e.cur.cls === an ? X : Y;
3557
+ }
3558
+ function An(e) {
3559
+ return e.cur.cls === Rt ? X : Y;
3560
+ }
3561
+ function jn(e) {
3562
+ if (e.next.cls === Rt) switch (e.cur.cls) {
3563
+ case q:
3564
+ case Dt:
3565
+ case Ht:
3566
+ case Vt: return Y;
3567
+ default: return X;
3568
+ }
3569
+ return Y;
3570
+ }
3571
+ function Mn(e) {
3572
+ switch (e.next.cls) {
3573
+ case jt:
3574
+ case Nt:
3575
+ case Lt:
3576
+ case tn: return X;
3577
+ }
3578
+ return Y;
3579
+ }
3580
+ function Nn(e) {
3581
+ return e.cur.cls === Yt ? (e.next.cls === q && (e.spaces = !0), X) : Y;
3582
+ }
3583
+ function Pn(e) {
3584
+ return hn.has(e.prev.cls) && /^\p{Pi}$/u.test(e.cur.char) && e.cur.cls === J ? (e.spaces = !0, X) : Y;
3585
+ }
3586
+ function Fn(e) {
3587
+ if (/^\p{gc=Pf}$/u.test(e.next.char) && e.next.cls === J) {
3588
+ let t = e.afterNext();
3589
+ if (!t || mn.has(t.cls)) return X;
3590
+ }
3591
+ return Y;
3592
+ }
3593
+ function In(e) {
3594
+ return e.cur.cls === q && e.next.cls === G && e.afterNext()?.cls === K ? gn : Y;
3595
+ }
3596
+ function Ln(e) {
3597
+ return e.next.cls === G ? X : Y;
3598
+ }
3599
+ function Rn(e) {
3600
+ if (e.cur.cls === jt || e.cur.cls === Nt) {
3601
+ if (e.classAfterSpaces(e.cur.len) === Zt) return e.next.cls === q && (e.spaces = !0), X;
3602
+ if (e.next.cls === q) return X;
3603
+ }
3604
+ return Y;
3605
+ }
3606
+ function zn(e) {
3607
+ if (e.cur.cls === Et) {
3608
+ if (e.classAfterSpaces(e.cur.len) === Et) return e.next.cls === q && (e.spaces = !0), X;
3609
+ if (e.next.cls === q) return X;
3610
+ }
3611
+ return Y;
3612
+ }
3613
+ function Bn(e) {
3614
+ return e.cur.cls === q ? gn : Y;
3615
+ }
3616
+ function Vn(e) {
3617
+ return e.next.cls === J && !/^\p{Pi}$/u.test(e.next.char) || e.cur.cls === J && !/^\p{Pf}$/u.test(e.cur.char) ? X : Y;
3618
+ }
3619
+ function Hn(e) {
3620
+ if (!H.get(e.cur.cp) && e.next.cls === J) return X;
3621
+ if (e.next.cls === J) {
3622
+ let t = e.afterNext();
3623
+ if (!t || !H.get(t.cp)) return X;
3624
+ }
3625
+ return e.cur.cls === J && !H.get(e.next.cp) || (e.prev.cls === -1 || !H.get(e.prev.cp)) && e.cur.cls === J ? X : Y;
3626
+ }
3627
+ function Un(e) {
3628
+ return e.cur.cls === At || e.next.cls === At ? gn : Y;
3629
+ }
3630
+ var Wn = /* @__PURE__ */ new Set([
3631
+ -1,
3632
+ kt,
3633
+ Pt,
3634
+ Jt,
3635
+ Xt,
3636
+ q,
3637
+ on,
3638
+ At,
3639
+ Rt
3640
+ ]);
3641
+ function Gn(e) {
3642
+ return Wn.has(e.prev.cls) && (e.cur.cls === Ht || e.cur.cls === Vt) && (e.next.cls === U || e.next.cls === W) ? X : Y;
3643
+ }
3644
+ function Kn(e) {
3645
+ if (e.cur.cls === Ot) return X;
3646
+ switch (e.next.cls) {
3647
+ case Dt:
3648
+ case Vt:
3649
+ case Ht:
3650
+ case Zt: return X;
3651
+ }
3652
+ return Y;
3653
+ }
3654
+ function qn(e) {
3655
+ return e.prev.cls === W && (e.cur.cls === Ht || e.cur.cls === Vt) && e.next.cls !== W ? X : Y;
3656
+ }
3657
+ function Jn(e) {
3658
+ return e.cur.cls === tn && e.next.cls === W ? X : Y;
3659
+ }
3660
+ function Yn(e) {
3661
+ return e.next.cls === Wt ? X : Y;
3662
+ }
3663
+ function Xn(e) {
3664
+ switch (e.cur.cls) {
3665
+ case U:
3666
+ case W:
3667
+ if (e.next.cls === K) return X;
3668
+ break;
3669
+ case K: if (e.next.cls === U || e.next.cls === W) return X;
3670
+ }
3671
+ return Y;
3672
+ }
3673
+ function Zn(e) {
3674
+ return e.cur.cls === $t && un.has(e.next.cls) || e.next.cls === Qt && un.has(e.cur.cls) ? X : Y;
3675
+ }
3676
+ function Qn(e) {
3677
+ return (e.cur.cls === $t || e.cur.cls === Qt) && (e.next.cls === U || e.next.cls === W) || (e.cur.cls === U || e.cur.cls === W) && (e.next.cls === $t || e.next.cls === Qt) ? X : Y;
3678
+ }
3679
+ var $n = /* @__PURE__ */ new Set([Qt, $t]), er = /* @__PURE__ */ new Set([jt, Nt]);
3680
+ function tr(e) {
3681
+ let t = null;
3682
+ if ($n.has(e.next.cls) ? t = er.has(e.cur.cls) ? e.prev.len : e.cur.len : e.next.cls === K && (t = e.cur.len), t !== null) SyIsLoop: for (let { cls: n } of e.codePoints(t, !1)) switch (n) {
3683
+ case tn:
3684
+ case G: continue;
3685
+ case K: return X;
3686
+ default: break SyIsLoop;
3687
+ }
3688
+ if (e.cur.cls === Qt || e.cur.cls === $t) {
3689
+ if (e.next.cls === Yt) {
3690
+ let t = e.afterNext();
3691
+ if (t && (t.cls === K || t.cls === G && e.afterNext(2)?.cls === K)) return X;
3692
+ } else if (e.next.cls === K) return X;
3693
+ }
3694
+ return e.cur.cls === Ht && e.next.cls === K || e.cur.cls === G && e.next.cls === K ? X : Y;
3695
+ }
3696
+ function nr(e) {
3697
+ switch (e.cur.cls) {
3698
+ case Gt:
3699
+ if (dn.has(e.next.cls)) return X;
3700
+ break;
3701
+ case qt:
3702
+ case zt:
3703
+ if (pn.has(e.next.cls)) return X;
3704
+ break;
3705
+ case Kt:
3706
+ case Bt: if (e.next.cls === Kt) return X;
3707
+ }
3708
+ return Y;
3709
+ }
3710
+ function rr(e) {
3711
+ switch (e.cur.cls) {
3712
+ case Gt:
3713
+ case qt:
3714
+ case Kt:
3715
+ case zt:
3716
+ case Bt:
3717
+ if (e.next.cls === Qt) return X;
3718
+ break;
3719
+ case $t: if (fn.has(e.next.cls)) return X;
3720
+ }
3721
+ return Y;
3722
+ }
3723
+ function ar(e) {
3724
+ return (e.cur.cls === U || e.cur.cls === W) && (e.next.cls === U || e.next.cls === W) ? X : Y;
3725
+ }
3726
+ function or(e) {
3727
+ let { prev: t, cur: n, next: r } = e;
3728
+ function i(e) {
3729
+ return e.cls === Ct || e.char === "◌" || e.cls === Tt;
3730
+ }
3731
+ return n.cls === wt && i(r) || i(n) && (r.cls === nn || r.cls === rn) || i(t) && n.cls === rn && (r.cls === Ct || r.char === "◌") || i(n) && i(r) && e.afterNext()?.cls === nn ? X : Y;
3732
+ }
3733
+ function sr(e) {
3734
+ return e.cur.cls === G && (e.next.cls === U || e.next.cls === W) ? X : Y;
3735
+ }
3736
+ function cr(e) {
3737
+ switch (e.cur.cls) {
3738
+ case U:
3739
+ case W:
3740
+ case K:
3741
+ if (e.next.cls === Yt && !H.get(e.next.cp)) return X;
3742
+ break;
3743
+ case Nt: if (!H.get(e.cur.cp) && cn.has(e.next.cls)) return X;
3744
+ }
3745
+ return Y;
3746
+ }
3747
+ function lr(e) {
3748
+ if (e.cur.cls === en) {
3749
+ if (e.next.cls === en && ++e.RI % 2 != 0) return X;
3750
+ } else e.RI = 0;
3751
+ return Y;
3752
+ }
3753
+ function ur(e) {
3754
+ return e.cur.cls === Ft && e.next.cls === It || e.next.cls === It && /^\p{ExtPict}$/u.test(e.cur.char) && /^\p{gc=Cn}$/u.test(e.cur.char) ? X : Y;
3755
+ }
3756
+ function dr() {
3757
+ return gn;
3758
+ }
3759
+ var fr = [
3760
+ vn,
3761
+ yn,
3762
+ bn,
3763
+ xn,
3764
+ Sn,
3765
+ Cn,
3766
+ wn,
3767
+ Tn,
3768
+ En,
3769
+ Dn,
3770
+ On,
3771
+ kn,
3772
+ An,
3773
+ jn,
3774
+ Mn,
3775
+ Nn,
3776
+ Pn,
3777
+ Fn,
3778
+ In,
3779
+ Ln,
3780
+ Rn,
3781
+ zn,
3782
+ Bn,
3783
+ Vn,
3784
+ Hn,
3785
+ Un,
3786
+ Gn,
3787
+ qn,
3788
+ Kn,
3789
+ Jn,
3790
+ Yn,
3791
+ Xn,
3792
+ Zn,
3793
+ Qn,
3794
+ tr,
3795
+ nr,
3796
+ rr,
3797
+ ar,
3798
+ or,
3799
+ sr,
3800
+ cr,
3801
+ lr,
3802
+ ur,
3803
+ dr
3804
+ ], pr = class {
3805
+ #e;
3806
+ constructor(e = {}) {
3807
+ if (this.#e = {
3808
+ string: !1,
3809
+ example7: !1,
3810
+ verbose: !1,
3811
+ ...e
3812
+ }, this.rules = [...fr], this.#e.example7) throw Error("'example7' flag deprecated");
3813
+ this.#e.verbose && this.rules.unshift((e) => (console.log(e.cur.len, e), Y));
3814
+ }
3815
+ removeRule(...e) {
3816
+ let t = [];
3817
+ return this.rules = this.rules.filter((n) => !e.includes(n.name) || (t.push(n), !1)), t;
3818
+ }
3819
+ addRuleAfter(e, ...t) {
3820
+ let n = this.rules.findIndex((t) => t.name === e);
3821
+ if (n === -1) throw Error(`Rule not found: "${e}"`);
3822
+ return this.rules.splice(n + 1, 0, ...t), n + 1;
3823
+ }
3824
+ addRuleBefore(e, ...t) {
3825
+ let n = this.rules.findIndex((t) => t.name === e);
3826
+ if (n === -1) throw Error(`Rule not found: "${e}"`);
3827
+ return this.rules.splice(n, 0, ...t), n;
3828
+ }
3829
+ replaceRule(e, ...t) {
3830
+ let n = this.rules.findIndex((t) => t.name === e);
3831
+ if (n === -1) throw Error(`Rule not found: "${e}"`);
3832
+ return this.rules.splice(n, 1, ...t);
3833
+ }
3834
+ #t(e) {
3835
+ for (let t of this.rules) {
3836
+ let n = t.call(this, e);
3837
+ switch (n) {
3838
+ case Y: break;
3839
+ case X: return this.#e.verbose && console.log(` ${t.name}: NO_BREAK`), null;
3840
+ case gn: return this.#e.verbose && console.log(` ${t.name}: MAY_BREAK`), new V(e.cur.len);
3841
+ case _n: return this.#e.verbose && console.log(` ${t.name}: MUST_BREAK`), new V(e.cur.len, !0);
3842
+ default: throw Error(`Invalid state: "${n}"`);
3843
+ }
3844
+ }
3845
+ return null;
3846
+ }
3847
+ *#n(e) {
3848
+ let t = this.#t(e);
3849
+ t && (this.#e.string && (t.string = e.str.slice(e.prevChunk, e.cur.len)), e.props &&= (t.props = e.props, void 0), yield t, e.prevChunk = e.cur.len);
3850
+ }
3851
+ *breaks(e) {
3852
+ let t = new xt(e);
3853
+ for (let e of t.codePoints(0)) t.push(e), yield* this.#n(t);
3854
+ t.pushEnd(), yield* this.#n(t);
3855
+ }
3856
+ };
3857
+ //#endregion
3858
+ //#region src/text-layout.ts
3859
+ function mr(e, t) {
3860
+ let n = new Intl.Segmenter(t, { granularity: "grapheme" }), r = /* @__PURE__ */ new Set([0]);
3861
+ for (let t of n.segment(e)) r.add(t.index + t.segment.length);
3862
+ return r;
3863
+ }
3864
+ var hr = class {
3865
+ #e = new pr();
3866
+ #t;
3867
+ constructor(e = "ja") {
3868
+ this.#t = e;
3869
+ }
3870
+ getBreakOpportunities(e) {
3871
+ let t = mr(e, this.#t), n = /* @__PURE__ */ new Map();
3872
+ for (let r of this.#e.breaks(e)) t.has(r.position) && n.set(r.position, (n.get(r.position) ?? !1) || r.required);
3873
+ return Object.freeze([...n].sort(([e], [t]) => e - t).map(([e, t]) => Object.freeze({
3874
+ position: e,
3875
+ required: t
3876
+ })));
3877
+ }
3878
+ }, gr = /* @__PURE__ */ new Map(), _r = /\r\n|[\n\r\v\f\u0085\u2028\u2029]/gu;
3879
+ function vr(e) {
3880
+ let t = gr.get(e);
3881
+ if (t) return t;
3882
+ let n = new hr(e);
3883
+ return gr.set(e, n), n;
3884
+ }
3885
+ function yr(e, t) {
3886
+ if (!Number.isFinite(e) || e < 0) throw TypeError(`${t} must return a non-negative finite number.`);
3887
+ return e;
3888
+ }
3889
+ function br(e, t, n) {
3890
+ let r = /* @__PURE__ */ new Map();
3891
+ for (let i of t.getBreakOpportunities(e)) {
3892
+ let { position: t, required: a } = i;
3893
+ !Number.isInteger(t) || t <= 0 || t > e.length || !n.has(t) || r.set(t, (r.get(t) ?? !1) || a);
3894
+ }
3895
+ return r.set(e.length, !0), [...r].sort(([e], [t]) => e - t).map(([e, t]) => ({
3896
+ position: e,
3897
+ required: t
3898
+ }));
3899
+ }
3900
+ function xr(e, t, n, r, i) {
3901
+ if (e.length === 0) return [{
3902
+ text: "",
3903
+ start: t,
3904
+ end: t,
3905
+ width: 0
3906
+ }];
3907
+ let a = mr(e, i), o = [...a].sort((e, t) => e - t), s = br(e, r, a), c = [], l = 0;
3908
+ for (; l < e.length;) {
3909
+ let r = s.find((e) => e.position > l && e.required)?.position ?? e.length, i, a = 0;
3910
+ for (let t of s) {
3911
+ if (t.position <= l || t.position > r) continue;
3912
+ let o = e.slice(l, t.position), s = yr(n.measureText(o), "measureText");
3913
+ s <= n.maxWidth && (i = t.position, a = s);
3914
+ }
3915
+ if (i === void 0) {
3916
+ let t = o.filter((e) => e > l && e <= r);
3917
+ for (let r of t) {
3918
+ let t = e.slice(l, r), o = yr(n.measureText(t), "measureText");
3919
+ o <= n.maxWidth && (i = r, a = o);
3920
+ }
3921
+ i === void 0 && (i = t[0] ?? r, a = yr(n.measureText(e.slice(l, i)), "measureText"));
3922
+ }
3923
+ c.push({
3924
+ text: e.slice(l, i),
3925
+ start: t + l,
3926
+ end: t + i,
3927
+ width: a
3928
+ }), l = i;
3929
+ }
3930
+ return c;
3931
+ }
3932
+ function Sr(e) {
3933
+ if (typeof e.text != "string") throw TypeError("text must be a string.");
3934
+ if (!Number.isFinite(e.maxWidth) || e.maxWidth <= 0) throw TypeError("maxWidth must be a positive finite number.");
3935
+ if (typeof e.measureText != "function") throw TypeError("measureText must be a function.");
3936
+ let t = e.locale ?? "ja", n = e.lineBreakProvider ?? vr(t), r = [], i = 0;
3937
+ for (let a of e.text.matchAll(_r)) {
3938
+ let o = a.index;
3939
+ r.push(...xr(e.text.slice(i, o), i, e, n, t)), i = o + a[0].length;
3940
+ }
3941
+ return r.push(...xr(e.text.slice(i), i, e, n, t)), Object.freeze({
3942
+ lines: Object.freeze(r.map((e) => Object.freeze(e))),
3943
+ maxLineWidth: Math.max(0, ...r.map((e) => e.width))
3944
+ });
3945
+ }
3946
+ //#endregion
3947
+ //#region src/composition.ts
3948
+ var Z = class extends Error {
3949
+ code;
3950
+ constructor(e, t) {
3951
+ super(t), this.name = "BubbleCompositionError", this.code = e;
3952
+ }
3953
+ }, Cr = /* @__PURE__ */ new Set(["say", "think"]), wr = /* @__PURE__ */ new Set([
3954
+ "idle",
3955
+ "talking",
3956
+ "awaiting-advance"
3957
+ ]);
3958
+ function Q(e) {
3959
+ return typeof e == "object" && !!e && !Array.isArray(e);
3960
+ }
3961
+ function Tr(e, t, n, r) {
3962
+ let i = /* @__PURE__ */ new Set([...t, ...n]), a = t.filter((t) => !Object.prototype.hasOwnProperty.call(e, t)), o = Object.keys(e).filter((e) => !i.has(e));
3963
+ if (a.length > 0 || o.length > 0) throw new Z("BUBBLE-COMPOSITION-001", `${r} has missing or unknown properties.`);
3964
+ }
3965
+ function $(e, t) {
3966
+ if (typeof e != "string" || e.trim().length === 0) throw new Z("BUBBLE-COMPOSITION-001", `${t} must be a non-empty string.`);
3967
+ return e.trim();
3968
+ }
3969
+ function Er(e, t, n) {
3970
+ if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", `${t} must be an object.`);
3971
+ if (Tr(e, ["frames", "frameIntervalSeconds"], [], t), !Array.isArray(e.frames) || e.frames.length < n) throw new Z("BUBBLE-COMPOSITION-001", `${t}.frames must contain at least ${n} image asset name${n === 1 ? "" : "s"}.`);
3972
+ let r = Object.freeze(e.frames.map((e, n) => $(e, `${t}.frames[${n}]`))), i = e.frameIntervalSeconds;
3973
+ if (typeof i != "number" || !Number.isFinite(i) || i <= 0) throw new Z("BUBBLE-COMPOSITION-001", `${t}.frameIntervalSeconds must be a positive finite number.`);
3974
+ return Object.freeze({
3975
+ frames: r,
3976
+ frameIntervalSeconds: i
3977
+ });
3978
+ }
3979
+ function Dr(e) {
3980
+ if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", "Bubble portrait must be an object.");
3981
+ Tr(e, ["base"], ["blink", "talk"], "Bubble portrait");
3982
+ let t = e.blink === void 0 ? void 0 : Er(e.blink, "Bubble portrait blink", 1), n = e.talk === void 0 ? void 0 : Er(e.talk, "Bubble portrait talk", 1);
3983
+ return Object.freeze({
3984
+ base: $(e.base, "Bubble portrait base"),
3985
+ ...t === void 0 ? {} : { blink: t },
3986
+ ...n === void 0 ? {} : { talk: n }
3987
+ });
3988
+ }
3989
+ function Or(e) {
3990
+ if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", "Bubble style must be an object.");
3991
+ Tr(e, ["name", "textStyle"], [
3992
+ "placement",
3993
+ "distance",
3994
+ "tailLength",
3995
+ "offset",
3996
+ "visualStyle",
3997
+ "portrait",
3998
+ "advanceIndicator"
3999
+ ], "Bubble style");
4000
+ let t = e.portrait === void 0 ? void 0 : Dr(e.portrait), n = e.advanceIndicator === void 0 ? void 0 : Er(e.advanceIndicator, "Bubble advance indicator", 2), r;
4001
+ try {
4002
+ r = y(e.placement ?? "up-right");
4003
+ } catch (e) {
4004
+ throw new Z("BUBBLE-COMPOSITION-001", e instanceof Error ? e.message : "Bubble placement is invalid.");
4005
+ }
4006
+ let i, a, o;
4007
+ try {
4008
+ i = C(e.distance ?? 12), a = ne(e.tailLength ?? 18), o = e.offset === void 0 ? te : w(e.offset);
4009
+ } catch (e) {
4010
+ throw new Z("BUBBLE-COMPOSITION-001", e instanceof Error ? e.message : "Bubble actor-relative transform is invalid.");
4011
+ }
4012
+ let s = e.visualStyle ?? "NORMAL";
4013
+ if (typeof s != "string" || !D.includes(s)) throw new Z("BUBBLE-COMPOSITION-001", `Unsupported Bubble visual style: ${String(s)}`);
4014
+ return Object.freeze({
4015
+ name: $(e.name, "Bubble style name"),
4016
+ textStyle: $(e.textStyle, "Bubble text style name"),
4017
+ placement: r,
4018
+ distance: i,
4019
+ tailLength: a,
4020
+ offset: o,
4021
+ visualStyle: s,
4022
+ ...t === void 0 ? {} : { portrait: t },
4023
+ ...n === void 0 ? {} : { advanceIndicator: n }
4024
+ });
4025
+ }
4026
+ function kr(e) {
4027
+ if (!Q(e) || typeof e.applyToTarget != "function" || typeof e.getMimeType != "function" || typeof e.isRegistered != "function") throw TypeError("Bubble asset manager must provide applyToTarget, getMimeType, and isRegistered.");
4028
+ return e;
4029
+ }
4030
+ function Ar(e) {
4031
+ if (!Q(e) || typeof e.setText != "function" || typeof e.releaseTarget != "function") throw TypeError("Bubble SVG Text composition must provide setText and releaseTarget.");
4032
+ return e;
4033
+ }
4034
+ function jr() {
4035
+ return Object.freeze({
4036
+ setTimeout: (e, t) => globalThis.setTimeout(e, t),
4037
+ clearTimeout: (e) => globalThis.clearTimeout(e)
4038
+ });
4039
+ }
4040
+ function Mr(e) {
4041
+ if (!Q(e) || typeof e.setTimeout != "function" || typeof e.clearTimeout != "function") throw TypeError("Bubble scheduler must provide setTimeout and clearTimeout.");
4042
+ return e;
4043
+ }
4044
+ function Nr(e, t) {
4045
+ if (!Q(e) || typeof e.id != "string" || e.id.length === 0 || typeof e.isStage != "boolean") throw new Z("BUBBLE-COMPOSITION-004", `${t} must provide id and isStage.`);
4046
+ return e;
4047
+ }
4048
+ function Pr(e) {
4049
+ if (!Q(e) || typeof e.drawableID != "number" || !Number.isInteger(e.drawableID) || e.drawableID < 0) throw new Z("BUBBLE-COMPOSITION-004", "Bubble text target must provide a non-negative integer drawableID.");
4050
+ return e;
4051
+ }
4052
+ function Fr(e, t) {
4053
+ if (!Q(e) || !Q(e.targets) || typeof e.setLayerVisible != "function" || typeof e.show != "function" || typeof e.hide != "function" || typeof e.dispose != "function") throw new Z("BUBBLE-COMPOSITION-004", "Bubble surface is invalid.");
4054
+ let n = e.targets;
4055
+ Pr(n.text);
4056
+ let r = /* @__PURE__ */ new Set(), i = (e, t) => {
4057
+ let i = n[e];
4058
+ if (!t && i === void 0) return;
4059
+ let a = Nr(i, `Bubble surface ${e}`);
4060
+ if (r.has(a.id)) throw new Z("BUBBLE-COMPOSITION-004", "Bubble image layers must use distinct target IDs.");
4061
+ r.add(a.id);
4062
+ };
4063
+ return i("portraitBase", t.portrait !== void 0), i("portraitBlink", t.portrait?.blink !== void 0), i("portraitTalk", t.portrait?.talk !== void 0), i("advanceIndicator", t.advanceIndicator !== void 0), e;
4064
+ }
4065
+ function Ir(e, t) {
4066
+ if (!e.isRegistered(t)) throw new Z("BUBBLE-COMPOSITION-003", `Bubble image asset is not registered: ${t}`);
4067
+ if (!e.getMimeType(t).startsWith("image/")) throw new Z("BUBBLE-COMPOSITION-003", `Bubble asset is not an image: ${t}`);
4068
+ }
4069
+ function Lr(e) {
4070
+ return [...e.portrait === void 0 ? [] : [
4071
+ e.portrait.base,
4072
+ ...e.portrait.blink?.frames ?? [],
4073
+ ...e.portrait.talk?.frames ?? []
4074
+ ], ...e.advanceIndicator?.frames ?? []];
4075
+ }
4076
+ function Rr(e, t) {
4077
+ if (e.length === 1) throw e[0];
4078
+ if (e.length > 1) throw AggregateError(e, t);
4079
+ }
4080
+ function zr(e) {
4081
+ let t = !1, n = 0, r = 0, i, a = Promise.resolve(), o = async (t) => {
4082
+ let n = e.animation.frames[t];
4083
+ n !== void 0 && await e.assetManager.applyToTarget(n, e.target);
4084
+ }, s = (t, n) => {
4085
+ e.onError?.(t, Object.freeze({
4086
+ actorKey: e.actorKey,
4087
+ layer: e.layer,
4088
+ assetName: n
4089
+ }));
4090
+ }, c = (l) => {
4091
+ i = e.scheduler.setTimeout(() => {
4092
+ if (i = void 0, !t || n !== l) return;
4093
+ r = (r + 1) % e.animation.frames.length;
4094
+ let u = e.animation.frames[r];
4095
+ a = a.then(() => o(r)).catch((e) => {
4096
+ t = !1, n += 1, s(e, u ?? "");
4097
+ }).then(() => {
4098
+ t && n === l && c(l);
4099
+ });
4100
+ }, e.animation.frameIntervalSeconds * 1e3);
4101
+ };
4102
+ return Object.freeze({
4103
+ async start(e = {}) {
4104
+ if (t) return;
4105
+ t = !0, n += 1;
4106
+ let i = n;
4107
+ r = 0, (e.primed ?? !1) || await o(r), !(!t || n !== i) && c(i);
4108
+ },
4109
+ async stop(s = {}) {
4110
+ let c = t;
4111
+ t = !1, n += 1, i !== void 0 && e.scheduler.clearTimeout(i), i = void 0, await a, (s.reset ?? !1) && (c || r !== 0) && (r = 0, await o(r));
4112
+ }
4113
+ });
4114
+ }
4115
+ function Br(e) {
4116
+ if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", "Show bubble input must be an object.");
4117
+ if (Tr(e, [
4118
+ "actor",
4119
+ "actorKey",
4120
+ "kind",
4121
+ "text",
4122
+ "styleName"
4123
+ ], ["animationMode"], "Show bubble input"), !Cr.has(e.kind)) throw new Z("BUBBLE-COMPOSITION-001", "Bubble kind must be say or think.");
4124
+ if (typeof e.text != "string") throw new Z("BUBBLE-COMPOSITION-001", "Bubble text must be a string.");
4125
+ let t = e.animationMode ?? "talking";
4126
+ if (!wr.has(t)) throw new Z("BUBBLE-COMPOSITION-001", "Bubble animation mode is invalid.");
4127
+ return {
4128
+ actor: e.actor,
4129
+ actorKey: $(e.actorKey, "Bubble actor key"),
4130
+ kind: e.kind,
4131
+ text: e.text,
4132
+ styleName: $(e.styleName, "Bubble style name"),
4133
+ animationMode: t
4134
+ };
4135
+ }
4136
+ function Vr(e) {
4137
+ if (!Q(e)) throw TypeError("Bubble composition options must be an object.");
4138
+ let t = kr(e.assetManager), n = Ar(e.svgText);
4139
+ if (typeof e.createSurface != "function") throw TypeError("Bubble composition createSurface must be a function.");
4140
+ if (e.onAnimationError !== void 0 && typeof e.onAnimationError != "function") throw TypeError("Bubble composition onAnimationError must be a function.");
4141
+ let r = Mr(e.scheduler ?? jr()), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = !1, c = () => {
4142
+ if (s) throw new Z("BUBBLE-COMPOSITION-005", "Bubble composition has been disposed.");
4143
+ }, l = async (e, t) => {
4144
+ let n = (o.get(e) ?? Promise.resolve()).catch(() => void 0).then(t);
4145
+ o.set(e, n);
4146
+ try {
4147
+ return await n;
4148
+ } finally {
4149
+ o.get(e) === n && o.delete(e);
4150
+ }
4151
+ }, u = async (o) => {
4152
+ c();
4153
+ let s = i.get(o.styleName);
4154
+ if (!s) throw new Z("BUBBLE-COMPOSITION-002", `Bubble style is not defined: ${o.styleName}`);
4155
+ for (let e of new Set(Lr(s))) Ir(t, e);
4156
+ let l = a.get(o.actorKey);
4157
+ l && await l.close();
4158
+ let u, d = !1, f = !1, p, m, h;
4159
+ try {
4160
+ u = Fr(await e.createSurface(Object.freeze({
4161
+ actor: o.actor,
4162
+ actorKey: o.actorKey,
4163
+ kind: o.kind,
4164
+ style: s
4165
+ })), s), n.setText({
4166
+ styleName: s.textStyle,
4167
+ target: u.targets.text,
4168
+ text: o.text
4169
+ }), d = !0;
4170
+ let i = [];
4171
+ if (s.portrait) {
4172
+ i.push(t.applyToTarget(s.portrait.base, u.targets.portraitBase));
4173
+ let e = s.portrait.blink?.frames[0];
4174
+ e !== void 0 && i.push(t.applyToTarget(e, u.targets.portraitBlink));
4175
+ let n = s.portrait.talk?.frames[0];
4176
+ n !== void 0 && i.push(t.applyToTarget(n, u.targets.portraitTalk));
4177
+ }
4178
+ let c = s.advanceIndicator?.frames[0];
4179
+ c !== void 0 && i.push(t.applyToTarget(c, u.targets.advanceIndicator)), await Promise.all(i), p = s.portrait?.blink === void 0 ? void 0 : zr({
4180
+ actorKey: o.actorKey,
4181
+ layer: "portraitBlink",
4182
+ animation: s.portrait.blink,
4183
+ target: u.targets.portraitBlink,
4184
+ assetManager: t,
4185
+ scheduler: r,
4186
+ ...e.onAnimationError === void 0 ? {} : { onError: e.onAnimationError }
4187
+ }), m = s.portrait?.talk === void 0 ? void 0 : zr({
4188
+ actorKey: o.actorKey,
4189
+ layer: "portraitTalk",
4190
+ animation: s.portrait.talk,
4191
+ target: u.targets.portraitTalk,
4192
+ assetManager: t,
4193
+ scheduler: r,
4194
+ ...e.onAnimationError === void 0 ? {} : { onError: e.onAnimationError }
4195
+ }), h = s.advanceIndicator === void 0 ? void 0 : zr({
4196
+ actorKey: o.actorKey,
4197
+ layer: "advanceIndicator",
4198
+ animation: s.advanceIndicator,
4199
+ target: u.targets.advanceIndicator,
4200
+ assetManager: t,
4201
+ scheduler: r,
4202
+ ...e.onAnimationError === void 0 ? {} : { onError: e.onAnimationError }
4203
+ });
4204
+ let l = "idle", g = !1, _ = Promise.resolve(), v = async (e) => {
4205
+ e !== l && (e === "talking" ? (await h?.stop(), await u?.setLayerVisible("advanceIndicator", !1), await u?.setLayerVisible("portraitTalk", m !== void 0), await m?.start({ primed: !0 })) : e === "awaiting-advance" ? (await m?.stop({ reset: !0 }), await u?.setLayerVisible("portraitTalk", !1), await u?.setLayerVisible("advanceIndicator", h !== void 0), await h?.start({ primed: !0 })) : (await Promise.all([m?.stop({ reset: !0 }), h?.stop()]), await Promise.all([u?.setLayerVisible("portraitTalk", !1), u?.setLayerVisible("advanceIndicator", !1)])), l = e);
4206
+ };
4207
+ await Promise.all([
4208
+ u.setLayerVisible("portraitBase", s.portrait !== void 0),
4209
+ u.setLayerVisible("portraitBlink", s.portrait?.blink !== void 0),
4210
+ u.setLayerVisible("portraitTalk", !1),
4211
+ u.setLayerVisible("advanceIndicator", !1)
4212
+ ]), await u.show(), f = !0, await p?.start({ primed: !0 }), await v(o.animationMode);
4213
+ let y = Object.freeze({
4214
+ actorKey: o.actorKey,
4215
+ kind: o.kind,
4216
+ get animationMode() {
4217
+ return l;
4218
+ },
4219
+ setText(e) {
4220
+ return g ? Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${o.actorKey}`)) : typeof e == "string" ? (_ = _.then(async () => {
4221
+ u && (n.setText({
4222
+ styleName: s.textStyle,
4223
+ target: u.targets.text,
4224
+ text: e
4225
+ }), await u.show());
4226
+ }), _) : Promise.reject(new Z("BUBBLE-COMPOSITION-001", "Bubble text must be a string."));
4227
+ },
4228
+ setAnimationMode(e) {
4229
+ return g ? Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${o.actorKey}`)) : wr.has(e) ? (_ = _.then(() => v(e)), _) : Promise.reject(new Z("BUBBLE-COMPOSITION-001", "Bubble animation mode is invalid."));
4230
+ },
4231
+ async close() {
4232
+ if (g) return;
4233
+ g = !0;
4234
+ let e = [];
4235
+ try {
4236
+ await _;
4237
+ } catch (t) {
4238
+ e.push(t);
4239
+ }
4240
+ for (let t of [
4241
+ () => p?.stop(),
4242
+ () => m?.stop(),
4243
+ () => h?.stop(),
4244
+ async () => {
4245
+ f && await u?.hide();
4246
+ },
4247
+ async () => {
4248
+ d && u && n.releaseTarget(u.targets.text);
4249
+ },
4250
+ async () => u?.dispose()
4251
+ ]) try {
4252
+ await t();
4253
+ } catch (t) {
4254
+ e.push(t);
4255
+ }
4256
+ a.get(o.actorKey) === y && a.delete(o.actorKey), Rr(e, `Failed to close bubble: ${o.actorKey}`);
4257
+ }
4258
+ });
4259
+ return a.set(o.actorKey, y), y;
4260
+ } catch (e) {
4261
+ let t = [], r = await Promise.allSettled([
4262
+ p?.stop(),
4263
+ m?.stop(),
4264
+ h?.stop()
4265
+ ]);
4266
+ if (t.push(...r.flatMap((e) => e.status === "rejected" ? [e.reason] : [])), f && u) try {
4267
+ await u.hide();
4268
+ } catch (e) {
4269
+ t.push(e);
4270
+ }
4271
+ if (d && u) try {
4272
+ n.releaseTarget(u.targets.text);
4273
+ } catch (e) {
4274
+ t.push(e);
4275
+ }
4276
+ if (u) try {
4277
+ await u.dispose();
4278
+ } catch (e) {
4279
+ t.push(e);
4280
+ }
4281
+ throw t.length > 0 ? AggregateError([e, ...t], `Failed to show and clean up bubble: ${o.actorKey}`, { cause: e }) : e;
4282
+ }
4283
+ };
4284
+ return Object.freeze({
4285
+ defineStyle(e) {
4286
+ c();
4287
+ let t = Or(e);
4288
+ i.set(t.name, t);
4289
+ },
4290
+ hasActiveBubble(e) {
4291
+ return a.has($(e, "Bubble actor key"));
4292
+ },
4293
+ async show(e) {
4294
+ c();
4295
+ let t = Br(e);
4296
+ return l(t.actorKey, () => u(t));
4297
+ },
4298
+ releaseTarget(e) {
4299
+ c();
4300
+ let t = $(e, "Bubble actor key");
4301
+ return l(t, async () => {
4302
+ await a.get(t)?.close();
4303
+ });
4304
+ },
4305
+ async releaseAll() {
4306
+ c(), await Promise.allSettled([...o.values()]), Rr((await Promise.allSettled([...a.values()].map((e) => e.close()))).flatMap((e) => e.status === "rejected" ? [e.reason] : []), "Failed to release all bubbles");
4307
+ },
4308
+ async dispose() {
4309
+ if (s) return;
4310
+ s = !0, await Promise.allSettled([...o.values()]);
4311
+ let e = await Promise.allSettled([...a.values()].map((e) => e.close()));
4312
+ i.clear(), Rr(e.flatMap((e) => e.status === "rejected" ? [e.reason] : []), "Failed to dispose bubble composition");
4313
+ }
4314
+ });
4315
+ }
4316
+ //#endregion
4317
+ export { Z as BubbleCompositionError, hr as UnicodeLineBreakProvider, re as actorRelativeBubbleCenter, d as bubbleBackgroundRegions, Te as bubbleBodyCenterOffset, u as bubbleDirectionAliases, l as bubbleDirectionNames, D as bubbleVisualStyles, Vr as createBubbleComposition, ee as defaultBubbleDistance, te as defaultBubbleOffset, f as defaultBubblePlacementInput, x as defaultBubbleTailLength, C as normalizeBubbleDistance, w as normalizeBubbleOffset, y as normalizeBubblePlacement, ne as normalizeBubbleTailLength, De as renderBubbleSvg, Sr as wrapText };