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