· 5 years ago · May 20, 2020, 08:16 AM
1function happu() {
2 if (document.documentElement.getAttribute("data-init") === "loading") {
3 !function (window, document, jQuery, undefined) {
4 "use strict";
5
6 function _classCallCheck(e, t) {
7 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
8 }
9
10 function _toConsumableArray(e) {
11 if (Array.isArray(e)) {
12 for (var t = 0, r = Array(e.length); t < e.length; t++) r[t] = e[t];
13 return r
14 }
15 return Array.from(e)
16 }
17
18 var _createClass = function () {
19 function e(e, t) {
20 for (var r = 0; r < t.length; r++) {
21 var n = t[r];
22 n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, n.key, n)
23 }
24 }
25
26 return function (t, r, n) {
27 return r && e(t.prototype, r), n && e(t, n), t
28 }
29 }(), _slicedToArray = function () {
30 function e(e, t) {
31 var r = [], n = !0, a = !1, i = undefined;
32 try {
33 for (var o, s = e[Symbol.iterator](); !(n = (o = s.next()).done) && (r.push(o.value), !t || r.length !== t); n = !0) ;
34 } catch (e) {
35 a = !0, i = e
36 } finally {
37 try {
38 !n && s.return && s.return()
39 } finally {
40 if (a) throw i
41 }
42 }
43 return r
44 }
45
46 return function (t, r) {
47 if (Array.isArray(t)) return t;
48 if (Symbol.iterator in Object(t)) return e(t, r);
49 throw new TypeError("Invalid attempt to destructure non-iterable instance")
50 }
51 }(), _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (e) {
52 return typeof e
53 } : function (e) {
54 return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
55 }, Alert = function () {
56 function e(e, t, r, n) {
57 var a = "fatal" === e, i = "Apologies! " + (a ? "A fatal" : "An") + " error has occurred.";
58 i += a ? " Aborting." : " You may be able to continue, but some parts may not work properly.", null == t && null == r || (i += "\n\nError", null != t && (i += " [" + t + "]"), i += null != r ? ": " + r.replace(/^(?:(?:uncaught\s+(?:exception:\s+)?)?error:\s+)+/i, "") + "." : ": unknown error."), "object" === ("undefined" == typeof n ? "undefined" : _typeof(n)) && n.stack && (i += "\n\nStack Trace:\n" + n.stack), window.alert(i)
59 }
60
61 function t(t, r, n) {
62 e(null, t, r, n)
63 }
64
65 function r(t, r, n) {
66 e("fatal", t, r, n)
67 }
68
69 return function (e) {
70 window.onerror = function (n, a, i, o, s) {
71 "complete" === document.readyState ? t(null, n, s) : (r(null, n, s), window.onerror = e, "function" == typeof window.onerror && window.onerror.apply(this, arguments))
72 }
73 }(window.onerror), Object.freeze(Object.defineProperties({}, {error: {value: t}, fatal: {value: r}}))
74 }();
75 !function () {
76 function e(e, t) {
77 var a = String(e);
78 switch (t) {
79 case"start":
80 return a && r.test(a) ? a.replace(r, "") : a;
81 case"end":
82 return a && n.test(a) ? a.replace(n, "") : a;
83 default:
84 throw new Error('_trimFrom called with incorrect where parameter value: "' + t + '"')
85 }
86 }
87
88 function t(e, t) {
89 var r = Number.parseInt(e, 10) || 0;
90 if (r < 1) return "";
91 var n = "undefined" == typeof t ? "" : String(t);
92 for ("" === n && (n = " "); n.length < r;) {
93 var a = n.length, i = r - a;
94 n += a > i ? n.slice(0, i) : n
95 }
96 return n.length > r && (n = n.slice(0, r)), n
97 }
98
99 var r = /^[\s\u00A0\uFEFF][\s\u00A0\uFEFF]*/, n = /[\s\u00A0\uFEFF][\s\u00A0\uFEFF]*$/;
100 Array.prototype.includes || Object.defineProperty(Array.prototype, "includes", {
101 configurable: !0,
102 writable: !0,
103 value: function () {
104 if (null == this) throw new TypeError("Array.prototype.includes called on null or undefined");
105 if (0 === arguments.length) return !1;
106 var e = this.length >>> 0;
107 if (0 === e) return !1;
108 var t = arguments[0], r = Number(arguments[1]) || 0;
109 for (r < 0 && (r = Math.max(0, e + r)); r < e; ++r) {
110 var n = this[r];
111 if (t === n || t !== t && n !== n) return !0
112 }
113 return !1
114 }
115 }), String.prototype.padStart || Object.defineProperty(String.prototype, "padStart", {
116 configurable: !0,
117 writable: !0,
118 value: function (e, r) {
119 if (null == this) throw new TypeError("String.prototype.padStart called on null or undefined");
120 var n = String(this), a = n.length, i = Number.parseInt(e, 10);
121 return i <= a ? n : t(i - a, r) + n
122 }
123 }), String.prototype.padEnd || Object.defineProperty(String.prototype, "padEnd", {
124 configurable: !0,
125 writable: !0,
126 value: function (e, r) {
127 if (null == this) throw new TypeError("String.prototype.padEnd called on null or undefined");
128 var n = String(this), a = n.length, i = Number.parseInt(e, 10);
129 return i <= a ? n : n + t(i - a, r)
130 }
131 }), String.prototype.trimStart || Object.defineProperty(String.prototype, "trimStart", {
132 configurable: !0,
133 writable: !0,
134 value: function () {
135 if (null == this) throw new TypeError("String.prototype.trimStart called on null or undefined");
136 return e(this, "start")
137 }
138 }), String.prototype.trimLeft || Object.defineProperty(String.prototype, "trimLeft", {
139 configurable: !0,
140 writable: !0,
141 value: function () {
142 if (null == this) throw new TypeError("String.prototype.trimLeft called on null or undefined");
143 return e(this, "start")
144 }
145 }), String.prototype.trimEnd || Object.defineProperty(String.prototype, "trimEnd", {
146 configurable: !0,
147 writable: !0,
148 value: function () {
149 if (null == this) throw new TypeError("String.prototype.trimEnd called on null or undefined");
150 return e(this, "end")
151 }
152 }), String.prototype.trimRight || Object.defineProperty(String.prototype, "trimRight", {
153 configurable: !0,
154 writable: !0,
155 value: function () {
156 if (null == this) throw new TypeError("String.prototype.trimRight called on null or undefined");
157 return e(this, "end")
158 }
159 })
160 }(), function () {
161 function _random() {
162 var e = void 0, t = void 0;
163 switch (arguments.length) {
164 case 0:
165 throw new Error("_random called with insufficient parameters");
166 case 1:
167 e = 0, t = arguments[0];
168 break;
169 default:
170 e = arguments[0], t = arguments[1]
171 }
172 if (e > t) {
173 var r = [t, e];
174 e = r[0], t = r[1]
175 }
176 return Math.floor(_nativeMathRandom() * (t - e + 1)) + e
177 }
178
179 function _randomIndex(e, t) {
180 var r = void 0, n = void 0;
181 switch (t.length) {
182 case 1:
183 r = 0, n = e - 1;
184 break;
185 case 2:
186 r = 0, n = Math.trunc(t[1]);
187 break;
188 default:
189 r = Math.trunc(t[1]), n = Math.trunc(t[2])
190 }
191 return Number.isNaN(r) ? r = 0 : !Number.isFinite(r) || r >= e ? r = e - 1 : r < 0 && (r = e + r, r < 0 && (r = 0)), Number.isNaN(n) ? n = 0 : !Number.isFinite(n) || n >= e ? n = e - 1 : n < 0 && (n = e + n, n < 0 && (n = e - 1)), _random(r, n)
192 }
193
194 function _getCodePointStartAndEnd(e, t) {
195 var r = e.charCodeAt(t);
196 if (Number.isNaN(r)) return {char: "", start: -1, end: -1};
197 if (r < 55296 || r > 57343) return {char: e.charAt(t), start: t, end: t};
198 if (r >= 55296 && r <= 56319) {
199 var n = t + 1;
200 if (n >= e.length) throw new Error("high surrogate without trailing low surrogate");
201 var a = e.charCodeAt(n);
202 if (a < 56320 || a > 57343) throw new Error("high surrogate without trailing low surrogate");
203 return {char: e.charAt(t) + e.charAt(n), start: t, end: n}
204 }
205 if (0 === t) throw new Error("low surrogate without leading high surrogate");
206 var i = t - 1, o = e.charCodeAt(i);
207 if (o < 55296 || o > 56319) throw new Error("low surrogate without leading high surrogate");
208 return {char: e.charAt(i) + e.charAt(t), start: i, end: t}
209 }
210
211 var _nativeMathRandom = Math.random;
212 Object.defineProperty(Array, "random", {
213 configurable: !0, writable: !0, value: function (e) {
214 if (null == e || "object" !== ("undefined" == typeof e ? "undefined" : _typeof(e)) || !Object.prototype.hasOwnProperty.call(e, "length")) throw new TypeError("Array.random array parameter must be an array or array-lke object");
215 var t = e.length >>> 0;
216 if (0 !== t) {
217 var r = 0 === arguments.length ? _random(0, t - 1) : _randomIndex(t, Array.prototype.slice.call(arguments, 1));
218 return e[r]
219 }
220 }
221 }), Object.defineProperty(Array.prototype, "concatUnique", {
222 configurable: !0,
223 writable: !0,
224 value: function e() {
225 if (null == this) throw new TypeError("Array.prototype.concatUnique called on null or undefined");
226 var t = Array.from(this);
227 if (0 === arguments.length) return t;
228 var r = Array.prototype.reduce.call(arguments, function (e, t) {
229 return e.concat(t)
230 }, []), n = r.length;
231 if (0 === n) return t;
232 for (var a = Array.prototype.indexOf, i = Array.prototype.push, o = 0; o < n; ++o) {
233 var e = r[o];
234 a.call(t, e) === -1 && i.call(t, e)
235 }
236 return t
237 }
238 }), Object.defineProperty(Array.prototype, "count", {
239 configurable: !0, writable: !0, value: function () {
240 if (null == this) throw new TypeError("Array.prototype.count called on null or undefined");
241 for (var e = Array.prototype.indexOf, t = arguments[0], r = Number(arguments[1]) || 0, n = 0; (r = e.call(this, t, r)) !== -1;) ++n, ++r;
242 return n
243 }
244 }), Object.defineProperty(Array.prototype, "delete", {
245 configurable: !0, writable: !0, value: function () {
246 if (null == this) throw new TypeError("Array.prototype.delete called on null or undefined");
247 if (0 === arguments.length) return [];
248 var e = this.length >>> 0;
249 if (0 === e) return [];
250 for (var t = Array.prototype.indexOf, r = Array.prototype.push, n = Array.prototype.splice, a = Array.prototype.concat.apply([], arguments), i = [], o = 0, s = a.length; o < s; ++o) for (var u = a[o], l = 0; (l = t.call(this, u, l)) !== -1;) r.apply(i, n.call(this, l, 1));
251 return i
252 }
253 }), Object.defineProperty(Array.prototype, "deleteAt", {
254 configurable: !0, writable: !0, value: function () {
255 if (null == this) throw new TypeError("Array.prototype.deleteAt called on null or undefined");
256 if (0 === arguments.length) return [];
257 var e = this.length >>> 0;
258 if (0 === e) return [];
259 for (var t = Array.prototype.splice, r = [].concat(_toConsumableArray(new Set(Array.prototype.concat.apply([], arguments).map(function (t) {
260 return t < 0 ? Math.max(0, e + t) : t
261 })).values())), n = [].concat(_toConsumableArray(r)).sort(function (e, t) {
262 return t - e
263 }), a = [], i = 0, o = r.length; i < o; ++i) a[i] = this[r[i]];
264 for (var s = 0, u = n.length; s < u; ++s) t.call(this, n[s], 1);
265 return a
266 }
267 }), Object.defineProperty(Array.prototype, "flatten", {
268 configurable: !0, writable: !0, value: function () {
269 if (null == this) throw new TypeError("Array.prototype.flatten called on null or undefined");
270 return Array.prototype.reduce.call(this, function (e, t) {
271 return e.concat(Array.isArray(t) ? t.flatten() : t)
272 }, [])
273 }
274 }), Object.defineProperty(Array.prototype, "includesAll", {
275 configurable: !0,
276 writable: !0,
277 value: function () {
278 if (null == this) throw new TypeError("Array.prototype.includesAll called on null or undefined");
279 if (1 === arguments.length) return Array.isArray(arguments[0]) ? Array.prototype.includesAll.apply(this, arguments[0]) : Array.prototype.includes.apply(this, arguments);
280 for (var e = 0, t = arguments.length; e < t; ++e) if (!Array.prototype.some.call(this, function (e) {
281 return e === this.val || e !== e && this.val !== this.val
282 }, {val: arguments[e]})) return !1;
283 return !0
284 }
285 }), Object.defineProperty(Array.prototype, "includesAny", {
286 configurable: !0,
287 writable: !0,
288 value: function () {
289 if (null == this) throw new TypeError("Array.prototype.includesAny called on null or undefined");
290 if (1 === arguments.length) return Array.isArray(arguments[0]) ? Array.prototype.includesAny.apply(this, arguments[0]) : Array.prototype.includes.apply(this, arguments);
291 for (var e = 0, t = arguments.length; e < t; ++e) if (Array.prototype.some.call(this, function (e) {
292 return e === this.val || e !== e && this.val !== this.val
293 }, {val: arguments[e]})) return !0;
294 return !1
295 }
296 }), Object.defineProperty(Array.prototype, "pluck", {
297 configurable: !0, writable: !0, value: function () {
298 if (null == this) throw new TypeError("Array.prototype.pluck called on null or undefined");
299 var e = this.length >>> 0;
300 if (0 !== e) {
301 var t = 0 === arguments.length ? _random(0, e - 1) : _randomIndex(e, [].concat(Array.prototype.slice.call(arguments)));
302 return Array.prototype.splice.call(this, t, 1)[0]
303 }
304 }
305 }), Object.defineProperty(Array.prototype, "pluckMany", {
306 configurable: !0,
307 writable: !0,
308 value: function (e) {
309 if (null == this) throw new TypeError("Array.prototype.pluckMany called on null or undefined");
310 var t = this.length >>> 0;
311 if (0 === t) return [];
312 var r = Math.trunc(e);
313 if (!Number.isInteger(r)) throw new Error("Array.prototype.pluckMany want parameter must be an integer");
314 if (r < 1) return [];
315 r > t && (r = t);
316 var n = Array.prototype.splice, a = [], i = t - 1;
317 do a.push(n.call(this, _random(0, i--), 1)[0]); while (a.length < r);
318 return a
319 }
320 }), Object.defineProperty(Array.prototype, "pushUnique", {
321 configurable: !0,
322 writable: !0,
323 value: function e() {
324 if (null == this) throw new TypeError("Array.prototype.pushUnique called on null or undefined");
325 var t = arguments.length;
326 if (0 === t) return this.length >>> 0;
327 for (var r = Array.prototype.indexOf, n = Array.prototype.push, a = 0; a < t; ++a) {
328 var e = arguments[a];
329 r.call(this, e) === -1 && n.call(this, e)
330 }
331 return this.length >>> 0
332 }
333 }), Object.defineProperty(Array.prototype, "random", {
334 configurable: !0, writable: !0, value: function () {
335 if (null == this) throw new TypeError("Array.prototype.random called on null or undefined");
336 var e = this.length >>> 0;
337 if (0 !== e) {
338 var t = 0 === arguments.length ? _random(0, e - 1) : _randomIndex(e, [].concat(Array.prototype.slice.call(arguments)));
339 return this[t]
340 }
341 }
342 }), Object.defineProperty(Array.prototype, "randomMany", {
343 configurable: !0,
344 writable: !0,
345 value: function (e) {
346 if (null == this) throw new TypeError("Array.prototype.randomMany called on null or undefined");
347 var t = this.length >>> 0;
348 if (0 === t) return [];
349 var r = Math.trunc(e);
350 if (!Number.isInteger(r)) throw new Error("Array.prototype.randomMany want parameter must be an integer");
351 if (r < 1) return [];
352 r > t && (r = t);
353 var n = new Map, a = [], i = t - 1;
354 do {
355 var o = void 0;
356 do o = _random(0, i); while (n.has(o));
357 n.set(o, !0), a.push(this[o])
358 } while (a.length < r);
359 return a
360 }
361 }), Object.defineProperty(Array.prototype, "shuffle", {
362 configurable: !0, writable: !0, value: function () {
363 if (null == this) throw new TypeError("Array.prototype.shuffle called on null or undefined");
364 var e = this.length >>> 0;
365 if (0 === e) return this;
366 for (var t = e - 1; t > 0; --t) {
367 var r = Math.floor(_nativeMathRandom() * (t + 1));
368 if (t !== r) {
369 var n = this[t];
370 this[t] = this[r], this[r] = n
371 }
372 }
373 return this
374 }
375 }), Object.defineProperty(Array.prototype, "unshiftUnique", {
376 configurable: !0,
377 writable: !0,
378 value: function e() {
379 if (null == this) throw new TypeError("Array.prototype.unshiftUnique called on null or undefined");
380 var t = arguments.length;
381 if (0 === t) return this.length >>> 0;
382 for (var r = Array.prototype.indexOf, n = Array.prototype.unshift, a = 0; a < t; ++a) {
383 var e = arguments[a];
384 r.call(this, e) === -1 && n.call(this, e)
385 }
386 return this.length >>> 0
387 }
388 }), Object.defineProperty(Function.prototype, "partial", {
389 configurable: !0,
390 writable: !0,
391 value: function () {
392 if (null == this) throw new TypeError("Function.prototype.partial called on null or undefined");
393 var e = Array.prototype.slice, t = this, r = e.call(arguments, 0);
394 return function () {
395 for (var n = [], a = 0, i = 0; i < r.length; ++i) n.push(r[i] === undefined ? arguments[a++] : r[i]);
396 return t.apply(this, n.concat(e.call(arguments, a)))
397 }
398 }
399 }), Object.defineProperty(Math, "clamp", {
400 configurable: !0, writable: !0, value: function e(t, r, n) {
401 var e = Number(t);
402 return Number.isNaN(e) ? NaN : e.clamp(r, n)
403 }
404 }), Object.defineProperty(Math, "easeInOut", {
405 configurable: !0, writable: !0, value: function (e) {
406 return 1 - (Math.cos(Number(e) * Math.PI) + 1) / 2
407 }
408 }), Object.defineProperty(Number.prototype, "clamp", {
409 configurable: !0, writable: !0, value: function () {
410 if (null == this) throw new TypeError("Number.prototype.clamp called on null or undefined");
411 if (2 !== arguments.length) throw new Error("Number.prototype.clamp called with an incorrect number of parameters");
412 var e = Number(arguments[0]), t = Number(arguments[1]);
413 if (e > t) {
414 var r = [t, e];
415 e = r[0], t = r[1]
416 }
417 return Math.min(Math.max(this, e), t)
418 }
419 }), RegExp.escape || !function () {
420 var e = /[\\^$*+?.()|[\]{}]/g, t = new RegExp(e.source);
421 Object.defineProperty(RegExp, "escape", {
422 configurable: !0, writable: !0, value: function (r) {
423 var n = String(r);
424 return n && t.test(n) ? n.replace(e, "\\$&") : n
425 }
426 })
427 }(), function () {
428 var e = /{(\d+)(?:,([+-]?\d+))?}/g, t = new RegExp(e.source);
429 Object.defineProperty(String, "format", {
430 configurable: !0, writable: !0, value: function (r) {
431 function n(e, t, r) {
432 if (!t) return e;
433 var n = Math.abs(t) - e.length;
434 if (n < 1) return e;
435 var a = String(r).repeat(n);
436 return t < 0 ? e + a : a + e
437 }
438
439 if (arguments.length < 2) return 0 === arguments.length ? "" : r;
440 var a = 2 === arguments.length && Array.isArray(arguments[1]) ? [].concat(_toConsumableArray(arguments[1])) : Array.prototype.slice.call(arguments, 1);
441 return 0 === a.length ? r : t.test(r) ? (e.lastIndex = 0, r.replace(e, function (e, t, r) {
442 var i = a[t];
443 if (null == i) return "";
444 for (; "function" == typeof i;) i = i();
445 switch ("undefined" == typeof i ? "undefined" : _typeof(i)) {
446 case"string":
447 break;
448 case"object":
449 i = JSON.stringify(i);
450 break;
451 default:
452 i = String(i)
453 }
454 return n(i, r ? Number.parseInt(r, 10) : 0, " ")
455 })) : r
456 }
457 })
458 }(), Object.defineProperty(String.prototype, "contains", {
459 configurable: !0,
460 writable: !0,
461 value: function () {
462 if (null == this) throw new TypeError("String.prototype.contains called on null or undefined");
463 return String.prototype.indexOf.apply(this, arguments) !== -1
464 }
465 }), Object.defineProperty(String.prototype, "count", {
466 configurable: !0, writable: !0, value: function () {
467 if (null == this) throw new TypeError("String.prototype.count called on null or undefined");
468 var e = String(arguments[0] || "");
469 if ("" === e) return 0;
470 for (var t = String.prototype.indexOf, r = e.length, n = Number(arguments[1]) || 0, a = 0; (n = t.call(this, e, n)) !== -1;) ++a, n += r;
471 return a
472 }
473 }), Object.defineProperty(String.prototype, "splice", {
474 configurable: !0,
475 writable: !0,
476 value: function (e, t, r) {
477 if (null == this) throw new TypeError("String.prototype.splice called on null or undefined");
478 var n = this.length >>> 0;
479 if (0 === n) return "";
480 var a = Number(e);
481 Number.isSafeInteger(a) ? a < 0 && (a += n, a < 0 && (a = 0)) : a = 0, a > n && (a = n);
482 var i = Number(t);
483 (!Number.isSafeInteger(i) || i < 0) && (i = 0);
484 var o = this.slice(0, a);
485 return "undefined" != typeof r && (o += r), a + i < n && (o += this.slice(a + i)), o
486 }
487 }), Object.defineProperty(String.prototype, "splitOrEmpty", {
488 configurable: !0,
489 writable: !0,
490 value: function () {
491 if (null == this) throw new TypeError("String.prototype.splitOrEmpty called on null or undefined");
492 return "" === String(this) ? [] : String.prototype.split.apply(this, arguments)
493 }
494 }), Object.defineProperty(String.prototype, "toLocaleUpperFirst", {
495 configurable: !0,
496 writable: !0,
497 value: function () {
498 if (null == this) throw new TypeError("String.prototype.toLocaleUpperFirst called on null or undefined");
499 var e = String(this), t = _getCodePointStartAndEnd(e, 0), r = t.char, n = t.end;
500 return n === -1 ? "" : r.toLocaleUpperCase() + e.slice(n + 1)
501 }
502 }), Object.defineProperty(String.prototype, "toUpperFirst", {
503 configurable: !0,
504 writable: !0,
505 value: function () {
506 if (null == this) throw new TypeError("String.prototype.toUpperFirst called on null or undefined");
507 var e = String(this), t = _getCodePointStartAndEnd(e, 0), r = t.char, n = t.end;
508 return n === -1 ? "" : r.toUpperCase() + e.slice(n + 1)
509 }
510 }), Object.defineProperty(Date.prototype, "toJSON", {
511 configurable: !0, writable: !0, value: function () {
512 return ["(revive:date)", this.toISOString()]
513 }
514 }), Object.defineProperty(Function.prototype, "toJSON", {
515 configurable: !0,
516 writable: !0,
517 value: function () {
518 return ["(revive:eval)", "(" + this.toString() + ")"]
519 }
520 }), Object.defineProperty(Map.prototype, "toJSON", {
521 configurable: !0, writable: !0, value: function () {
522 return ["(revive:map)", [].concat(_toConsumableArray(this))]
523 }
524 }), Object.defineProperty(RegExp.prototype, "toJSON", {
525 configurable: !0, writable: !0, value: function () {
526 return ["(revive:eval)", this.toString()]
527 }
528 }), Object.defineProperty(Set.prototype, "toJSON", {
529 configurable: !0, writable: !0, value: function () {
530 return ["(revive:set)", [].concat(_toConsumableArray(this))]
531 }
532 }), Object.defineProperty(JSON, "reviveWrapper", {
533 configurable: !0, writable: !0, value: function (e, t) {
534 if ("string" != typeof e) throw new TypeError("JSON.reviveWrapper code parameter must be a string");
535 return ["(revive:eval)", [e, t]]
536 }
537 }), Object.defineProperty(JSON, "_real_parse", {value: JSON.parse}), Object.defineProperty(JSON, "parse", {
538 configurable: !0,
539 writable: !0,
540 value: function value(text, reviver) {
541 return JSON._real_parse(text, function (key, val) {
542 var value = val;
543 if (Array.isArray(value) && 2 === value.length) switch (value[0]) {
544 case"(revive:set)":
545 value = new Set(value[1]);
546 break;
547 case"(revive:map)":
548 value = new Map(value[1]);
549 break;
550 case"(revive:date)":
551 value = new Date(value[1]);
552 break;
553 case"(revive:eval)":
554 try {
555 if (Array.isArray(value[1])) {
556 var $ReviveData$ = value[1][1];
557 value = eval(value[1][0])
558 } else value = eval(value[1])
559 } catch (e) {
560 }
561 } else if ("string" == typeof value && "@@revive@@" === value.slice(0, 10)) try {
562 value = eval(value.slice(10))
563 } catch (e) {
564 }
565 if ("function" == typeof reviver) try {
566 value = reviver(key, value)
567 } catch (e) {
568 }
569 return value
570 })
571 }
572 }), Object.defineProperty(Array.prototype, "contains", {
573 configurable: !0, writable: !0, value: function () {
574 if (null == this) throw new TypeError("Array.prototype.contains called on null or undefined");
575 return Array.prototype.includes.apply(this, arguments)
576 }
577 }), Object.defineProperty(Array.prototype, "containsAll", {
578 configurable: !0,
579 writable: !0,
580 value: function () {
581 if (null == this) throw new TypeError("Array.prototype.containsAll called on null or undefined");
582 return Array.prototype.includesAll.apply(this, arguments)
583 }
584 }), Object.defineProperty(Array.prototype, "containsAny", {
585 configurable: !0,
586 writable: !0,
587 value: function () {
588 if (null == this) throw new TypeError("Array.prototype.containsAny called on null or undefined");
589 return Array.prototype.includesAny.apply(this, arguments)
590 }
591 }), Object.defineProperty(String.prototype, "readBracketedList", {
592 configurable: !0,
593 writable: !0,
594 value: function () {
595 if (null == this) throw new TypeError("String.prototype.readBracketedList called on null or undefined");
596 for (var e = new RegExp("(?:\\[\\[((?:\\s|\\S)*?)\\]\\])|([^\"'\\s]\\S*)", "gm"), t = [], r = void 0; null !== (r = e.exec(this));) r[1] ? t.push(r[1]) : r[2] && t.push(r[2]);
597 return t
598 }
599 })
600 }();
601 var Browser = function () {
602 var e = navigator.userAgent.toLowerCase(), t = e.includes("windows phone"), r = Object.freeze({
603 Android: !t && e.includes("android"),
604 BlackBerry: /blackberry|bb10/.test(e),
605 iOS: !t && /ip(?:hone|ad|od)/.test(e),
606 Windows: t || e.includes("iemobile"),
607 any: function () {
608 return r.Android || r.BlackBerry || r.iOS || r.Windows
609 }
610 }), n = !r.Windows && !/khtml|trident|edge/.test(e) && e.includes("gecko"),
611 a = !e.includes("opera") && /msie|trident/.test(e), i = a ? function () {
612 var t = /(?:msie\s+|rv:)(\d+\.\d)/.exec(e);
613 return t ? Number(t[1]) : 0
614 }() : null, o = e.includes("opera") || e.includes(" opr/"), s = o ? function () {
615 var t = new RegExp((/khtml|chrome/.test(e) ? "opr" : "version") + "\\/(\\d+\\.\\d+)"), r = t.exec(e);
616 return r ? Number(r[1]) : 0
617 }() : null;
618 return Object.freeze({
619 userAgent: e,
620 isMobile: r,
621 isGecko: n,
622 isIE: a,
623 ieVersion: i,
624 isOpera: o,
625 operaVersion: s
626 })
627 }(), Has = function () {
628 var e = function () {
629 try {
630 return "function" == typeof document.createElement("audio").canPlayType
631 } catch (e) {
632 }
633 return !1
634 }(), t = function () {
635 try {
636 return "Blob" in window && "File" in window && "FileList" in window && "FileReader" in window && !Browser.isMobile.any() && (!Browser.isOpera || Browser.operaVersion >= 15)
637 } catch (e) {
638 }
639 return !1
640 }(), r = function () {
641 try {
642 return "geolocation" in navigator && "function" == typeof navigator.geolocation.getCurrentPosition && "function" == typeof navigator.geolocation.watchPosition
643 } catch (e) {
644 }
645 return !1
646 }(), n = function () {
647 try {
648 return "MutationObserver" in window && "function" == typeof window.MutationObserver
649 } catch (e) {
650 }
651 return !1
652 }(), a = function () {
653 try {
654 return "performance" in window && "function" == typeof window.performance.now
655 } catch (e) {
656 }
657 return !1
658 }();
659 return Object.freeze({audio: e, fileAPI: t, geolocation: r, mutationObserver: n, performance: a})
660 }(), _ref3 = function () {
661 function e(t) {
662 if ("object" !== ("undefined" == typeof t ? "undefined" : _typeof(t)) || null == t) return t;
663 if ("function" == typeof t.clone) return t.clone(!0);
664 if (t.nodeType && "function" == typeof t.cloneNode) return t.cloneNode(!0);
665 var r = void 0;
666 return Array.isArray(t) ? r = [] : t instanceof Date ? r = new Date(t.getTime()) : t instanceof Map ? (r = new Map, t.forEach(function (t, n) {
667 r.set(n, e(t))
668 })) : t instanceof RegExp ? r = new RegExp(t) : t instanceof Set ? (r = new Set, t.forEach(function (t) {
669 r.add(e(t))
670 })) : r = Object.create(Object.getPrototypeOf(t)), Object.keys(t).forEach(function (n) {
671 return r[n] = e(t[n])
672 }), r
673 }
674
675 function t(e) {
676 for (var t = document.createDocumentFragment(), r = document.createElement("p"), n = void 0; null !== (n = e.firstChild);) {
677 if (n.nodeType === Node.ELEMENT_NODE) {
678 var a = n.nodeName.toUpperCase();
679 switch (a) {
680 case"BR":
681 if (null !== n.nextSibling && n.nextSibling.nodeType === Node.ELEMENT_NODE && "BR" === n.nextSibling.nodeName.toUpperCase()) {
682 e.removeChild(n.nextSibling), e.removeChild(n), t.appendChild(r), r = document.createElement("p");
683 continue
684 }
685 if (!r.hasChildNodes()) {
686 e.removeChild(n);
687 continue
688 }
689 break;
690 case"ADDRESS":
691 case"ARTICLE":
692 case"ASIDE":
693 case"BLOCKQUOTE":
694 case"CENTER":
695 case"DIV":
696 case"DL":
697 case"FIGURE":
698 case"FOOTER":
699 case"FORM":
700 case"H1":
701 case"H2":
702 case"H3":
703 case"H4":
704 case"H5":
705 case"H6":
706 case"HEADER":
707 case"HR":
708 case"MAIN":
709 case"NAV":
710 case"OL":
711 case"P":
712 case"PRE":
713 case"SECTION":
714 case"TABLE":
715 case"UL":
716 r.hasChildNodes() && (t.appendChild(r), r = document.createElement("p")), t.appendChild(n);
717 continue
718 }
719 }
720 r.appendChild(n)
721 }
722 r.hasChildNodes() && t.appendChild(r), e.appendChild(t)
723 }
724
725 function r() {
726 try {
727 return document.activeElement || null
728 } catch (e) {
729 return null
730 }
731 }
732
733 function n(e, t, r) {
734 var n = "object" === ("undefined" == typeof e ? "undefined" : _typeof(e)) ? e : document.getElementById(e);
735 if (null == n) return null;
736 var a = Array.isArray(t) ? t : [t];
737 jQuery(n).empty();
738 for (var i = 0, o = a.length; i < o; ++i) if (Story.has(a[i])) return new Wikifier(n, Story.get(a[i]).processText().trim()), n;
739 if (null != r) {
740 var s = String(r).trim();
741 "" !== s && new Wikifier(n, s)
742 }
743 return n
744 }
745
746 function a(e, t, r) {
747 return jQuery(document.createElement("span")).addClass("error").attr("title", r).text(L10n.get("errorTitle") + ": " + (t || "unknown error")).appendTo(e), !1
748 }
749
750 function i(e, t) {
751 var r = i;
752 switch ("undefined" == typeof e ? "undefined" : _typeof(e)) {
753 case"number":
754 if (Number.isNaN(e)) return t;
755 break;
756 case"object":
757 if (null === e) return t;
758 if (Array.isArray(e)) return e.map(function (e) {
759 return r(e, t)
760 }).join(", ");
761 if (e instanceof Set) return [].concat(_toConsumableArray(e)).map(function (e) {
762 return r(e, t)
763 }).join(", ");
764 if (e instanceof Map) {
765 var n = [].concat(_toConsumableArray(e)).map(function (e) {
766 return r(e[0], t) + " ⇒ " + r(e[1], t)
767 }).join("; ");
768 return "( " + n + " )"
769 }
770 return e instanceof Date ? e.toLocaleString() : "function" == typeof e.toString ? e.toString() : Object.prototype.toString.call(e);
771 case"function":
772 case"undefined":
773 return t
774 }
775 return String(e)
776 }
777
778 return Object.freeze(Object.defineProperties({}, {
779 clone: {value: e},
780 convertBreaks: {value: t},
781 safeActiveElement: {value: r},
782 setPageElement: {value: n},
783 throwError: {value: a},
784 toStringOrDefault: {value: i}
785 }))
786 }(), clone = _ref3.clone, convertBreaks = _ref3.convertBreaks, safeActiveElement = _ref3.safeActiveElement,
787 setPageElement = _ref3.setPageElement, throwError = _ref3.throwError,
788 toStringOrDefault = _ref3.toStringOrDefault;
789 !function () {
790 function e(e) {
791 13 !== e.which && 32 !== e.which || (e.preventDefault(), jQuery(safeActiveElement() || this).trigger("click"))
792 }
793
794 function t(e) {
795 return function () {
796 var t = jQuery(this);
797 t.is("[aria-pressed]") && t.attr("aria-pressed", "true" === t.attr("aria-pressed") ? "false" : "true"), e.apply(this, arguments)
798 }
799 }
800
801 function r(e) {
802 return t(function () {
803 jQuery(this).off(".aria-clickable").removeAttr("tabindex aria-controls aria-pressed").not("a,button").removeAttr("role").end().filter("button").prop("disabled", !0), e.apply(this, arguments)
804 })
805 }
806
807 jQuery.fn.extend({
808 ariaClick: function (n, a) {
809 if (0 === this.length || 0 === arguments.length) return this;
810 var i = n, o = a;
811 return null == o && (o = i, i = undefined), i = jQuery.extend({
812 namespace: undefined,
813 one: !1,
814 selector: undefined,
815 data: undefined,
816 controls: undefined,
817 pressed: undefined,
818 label: undefined
819 }, i), "string" != typeof i.namespace ? i.namespace = "" : "." !== i.namespace[0] && (i.namespace = "." + i.namespace), "boolean" == typeof i.pressed && (i.pressed = i.pressed ? "true" : "false"), this.filter("button").prop("type", "button"), this.not("a,button").attr("role", "button"), this.attr("tabindex", 0), null != i.controls && this.attr("aria-controls", i.controls), null != i.pressed && this.attr("aria-pressed", i.pressed), null != i.label && this.attr({
820 "aria-label": i.label,
821 title: i.label
822 }), this.not("button").on("keypress.aria-clickable" + i.namespace, i.selector, e), this.on("click.aria-clickable" + i.namespace, i.selector, i.data, i.one ? r(o) : t(o)), this
823 }
824 })
825 }(), function () {
826 jQuery.extend({
827 wikiWithOptions: function (e) {
828 for (var t = arguments.length, r = Array(t > 1 ? t - 1 : 0), n = 1; n < t; n++) r[n - 1] = arguments[n];
829 if (0 !== r.length) {
830 var a = document.createDocumentFragment();
831 r.forEach(function (t) {
832 return new Wikifier(a, t, e)
833 });
834 var i = [].concat(_toConsumableArray(a.querySelectorAll(".error"))).map(function (e) {
835 return e.textContent.replace(/^(?:(?:Uncaught\s+)?Error:\s+)+/, "")
836 });
837 if (i.length > 0) throw new Error(i.join("; "))
838 }
839 }, wiki: function () {
840 for (var e = arguments.length, t = Array(e), r = 0; r < e; r++) t[r] = arguments[r];
841 this.wikiWithOptions.apply(this, [undefined].concat(t))
842 }
843 }), jQuery.fn.extend({
844 wikiWithOptions: function (e) {
845 for (var t = arguments.length, r = Array(t > 1 ? t - 1 : 0), n = 1; n < t; n++) r[n - 1] = arguments[n];
846 if (0 === this.length || 0 === r.length) return this;
847 var a = document.createDocumentFragment();
848 return r.forEach(function (t) {
849 return new Wikifier(a, t, e)
850 }), this.append(a), this
851 }, wiki: function () {
852 for (var e = arguments.length, t = Array(e), r = 0; r < e; r++) t[r] = arguments[r];
853 return this.wikiWithOptions.apply(this, [undefined].concat(t))
854 }
855 })
856 }();
857 var Util = function () {
858 function e(e) {
859 return Object.freeze(Object.assign(Object.create(null), e))
860 }
861
862 function t(e) {
863 return Object.prototype.toString.call(e).slice(8, -1)
864 }
865
866 function r(e) {
867 var t = void 0;
868 switch ("undefined" == typeof e ? "undefined" : _typeof(e)) {
869 case"number":
870 t = e;
871 break;
872 case"string":
873 t = Number(e);
874 break;
875 default:
876 return !1
877 }
878 return !Number.isNaN(t) && Number.isFinite(t)
879 }
880
881 function n(e) {
882 return "boolean" == typeof e || "string" == typeof e && ("true" === e || "false" === e)
883 }
884
885 function a(e) {
886 return String(e).trim().replace(/[^\w\s\u2013\u2014-]+/g, "").replace(/[_\s\u2013\u2014-]+/g, "-").toLocaleLowerCase()
887 }
888
889 function i(e) {
890 if (null == e) return "";
891 var t = String(e);
892 return t && h.test(t) ? t.replace(p, function (e) {
893 return g[e]
894 }) : t
895 }
896
897 function o(e) {
898 if (null == e) return "";
899 var t = String(e);
900 return t && y.test(t) ? t.replace(m, function (e) {
901 return v[e.toLowerCase()]
902 }) : t
903 }
904
905 function s(e, t) {
906 var r = String(e), n = Math.trunc(t), a = r.charCodeAt(n);
907 if (Number.isNaN(a)) return {char: "", start: -1, end: -1};
908 var i = {char: r.charAt(n), start: n, end: n};
909 if (a < 55296 || a > 57343) return i;
910 if (a >= 55296 && a <= 56319) {
911 var o = n + 1;
912 if (o >= r.length) return i;
913 var s = r.charCodeAt(o);
914 return s < 56320 || s > 57343 ? i : (i.char = i.char + r.charAt(o), i.end = o, i)
915 }
916 if (0 === n) return i;
917 var u = n - 1, l = r.charCodeAt(u);
918 return l < 55296 || l > 56319 ? i : (i.char = r.charAt(u) + i.char, i.start = u, i)
919 }
920
921 function u() {
922 return (Has.performance ? performance : Date).now()
923 }
924
925 function l(e) {
926 var t = /^([+-]?(?:\d*\.)?\d+)([Mm]?[Ss])$/, r = t.exec(String(e));
927 if (null === r) throw new SyntaxError('invalid time value syntax: "' + e + '"');
928 var n = Number(r[1]);
929 if (/^[Ss]$/.test(r[2]) && (n *= 1e3), Number.isNaN(n) || !Number.isFinite(n)) throw new RangeError('invalid time value: "' + e + '"');
930 return n
931 }
932
933 function c(e) {
934 if ("number" != typeof e || Number.isNaN(e) || !Number.isFinite(e)) {
935 var t = void 0;
936 switch ("undefined" == typeof e ? "undefined" : _typeof(e)) {
937 case"string":
938 t = '"' + e + '"';
939 break;
940 case"number":
941 t = String(e);
942 break;
943 default:
944 t = Object.prototype.toString.call(e)
945 }
946 throw new Error("invalid milliseconds: " + t)
947 }
948 return e + "ms"
949 }
950
951 function d(e) {
952 if (!e.includes("-")) switch (e) {
953 case"bgcolor":
954 return "backgroundColor";
955 case"float":
956 return "cssFloat";
957 default:
958 return e
959 }
960 var t = "-ms-" === e.slice(0, 4) ? e.slice(1) : e;
961 return t.split("-").map(function (e, t) {
962 return 0 === t ? e : e.toUpperFirst()
963 }).join("")
964 }
965
966 function f(e) {
967 var t = document.createElement("a"), r = Object.create(null);
968 t.href = e, t.search && t.search.replace(/^\?/, "").splitOrEmpty(/(?:&(?:amp;)?|;)/).forEach(function (e) {
969 var t = e.split("="), n = _slicedToArray(t, 2), a = n[0], i = n[1];
970 r[a] = i
971 });
972 var n = t.host && "/" !== t.pathname[0] ? "/" + t.pathname : t.pathname;
973 return {
974 href: t.href,
975 protocol: t.protocol,
976 host: t.host,
977 hostname: t.hostname,
978 port: t.port,
979 path: "" + n + t.search,
980 pathname: n,
981 query: t.search,
982 search: t.search,
983 queries: r,
984 searches: r,
985 hash: t.hash
986 }
987 }
988
989 var p = /[&<>"'`]/g, h = new RegExp(p.source),
990 g = Object.freeze({"&": "&", "<": "<", ">": ">", '"': """, "'": "'", "`": "`"}),
991 m = /&(?:amp|#38|#x26|lt|#60|#x3c|gt|#62|#x3e|quot|#34|#x22|apos|#39|#x27|#96|#x60);/gi,
992 y = new RegExp(m.source, "i"), v = Object.freeze({
993 "&": "&",
994 "&": "&",
995 "&": "&",
996 "<": "<",
997 "<": "<",
998 "<": "<",
999 ">": ">",
1000 ">": ">",
1001 ">": ">",
1002 """: '"',
1003 """: '"',
1004 """: '"',
1005 "'": "'",
1006 "'": "'",
1007 "'": "'",
1008 "`": "`",
1009 "`": "`"
1010 });
1011 return Object.freeze(Object.defineProperties({}, {
1012 toEnum: {value: e},
1013 toStringTag: {value: t},
1014 isNumeric: {value: r},
1015 isBoolean: {value: n},
1016 slugify: {value: a},
1017 escape: {value: i},
1018 unescape: {value: o},
1019 charAndPosAt: {value: s},
1020 fromCssTime: {value: l},
1021 toCssTime: {value: c},
1022 fromCssProperty: {value: d},
1023 parseUrl: {value: f},
1024 now: {value: u},
1025 random: {value: Math.random},
1026 entityEncode: {value: i},
1027 entityDecode: {value: o},
1028 evalExpression: {
1029 value: function () {
1030 return Scripting.evalJavaScript.apply(Scripting, arguments)
1031 }
1032 },
1033 evalStatements: {
1034 value: function () {
1035 return Scripting.evalJavaScript.apply(Scripting, arguments)
1036 }
1037 }
1038 }))
1039 }(), SimpleAudio = function () {
1040 function e() {
1041 return g
1042 }
1043
1044 function t(e) {
1045 g = !!e, l("mute", g)
1046 }
1047
1048 function r() {
1049 return p
1050 }
1051
1052 function n(e) {
1053 p = Math.clamp(e, .2, 5), l("rate", p)
1054 }
1055
1056 function a() {
1057 return h
1058 }
1059
1060 function i(e) {
1061 h = Math.clamp(e, 0, 1), l("volume", h)
1062 }
1063
1064 function o() {
1065 l("stop")
1066 }
1067
1068 function s(e, t) {
1069 if ("function" != typeof t) throw new Error("callback parameter must be a function");
1070 f.set(e, t)
1071 }
1072
1073 function u(e) {
1074 f.delete(e)
1075 }
1076
1077 function l(e, t) {
1078 f.forEach(function (r) {
1079 return r(e, t)
1080 })
1081 }
1082
1083 function c() {
1084 for (var e = arguments.length, t = Array(e), r = 0; r < e; r++) t[r] = arguments[r];
1085 return new (Function.prototype.bind.apply(m, [null].concat(t)))
1086 }
1087
1088 function d() {
1089 for (var e = arguments.length, t = Array(e), r = 0; r < e; r++) t[r] = arguments[r];
1090 return new (Function.prototype.bind.apply(y, [null].concat(t)))
1091 }
1092
1093 var f = new Map, p = 1, h = 1, g = !1, m = function () {
1094 function e(t) {
1095 if (_classCallCheck(this, e), Array.isArray(t)) this._create(t); else {
1096 if (!(t instanceof e)) throw new Error("sources parameter must be an array of either URLs or source objects");
1097 this._copy(t)
1098 }
1099 }
1100
1101 return _createClass(e, [{
1102 key: "_create", value: function (t) {
1103 if (!Array.isArray(t) || 0 === t.length) throw new Error("sources parameter must be an array of either URLs or source objects");
1104 var r = /^data:\s*audio\/([^;,]+)\s*[;,]/i, n = /\.([^.\/\\]+)$/, a = e.getType, i = [],
1105 o = document.createElement("audio");
1106 if (t.forEach(function (e) {
1107 var t = null;
1108 switch ("undefined" == typeof e ? "undefined" : _typeof(e)) {
1109 case"string":
1110 var s = void 0;
1111 if ("data:" === e.slice(0, 5)) {
1112 if (s = r.exec(e), null === s) throw new Error("source data URI missing media type")
1113 } else if (s = n.exec(Util.parseUrl(e).pathname), null === s) throw new Error("source URL missing file extension");
1114 var u = a(s[1]);
1115 null !== u && (t = {src: e, type: u});
1116 break;
1117 case"object":
1118 if (null === e) throw new Error("source object cannot be null");
1119 if (!e.hasOwnProperty("src")) throw new Error('source object missing required "src" property');
1120 if (!e.hasOwnProperty("format")) throw new Error('source object missing required "format" property');
1121 var l = a(e.format);
1122 null !== l && (t = {src: e.src, type: l});
1123 break;
1124 default:
1125 throw new Error("invalid source value (type: " + ("undefined" == typeof e ? "undefined" : _typeof(e)) + ")")
1126 }
1127 if (null !== t) {
1128 var c = document.createElement("source");
1129 c.src = t.src, c.type = Browser.isOpera ? t.type.replace(/;.*$/, "") : t.type, o.appendChild(c), i.push(t)
1130 }
1131 }), !o.hasChildNodes()) if (Browser.isIE) o.src = undefined; else {
1132 var s = document.createElement("source");
1133 s.src = undefined, s.type = undefined, o.appendChild(s)
1134 }
1135 this._finalize(o, i, clone(t))
1136 }
1137 }, {
1138 key: "_copy", value: function (t) {
1139 if (!(t instanceof e)) throw new Error("original parameter must be an instance of AudioWrapper");
1140 this._finalize(t.audio.cloneNode(!0), clone(t.sources), clone(t.originalSources))
1141 }
1142 }, {
1143 key: "_finalize", value: function (e, t, r) {
1144 var n = this;
1145 Object.defineProperties(this, {
1146 audio: {configurable: !0, value: e},
1147 sources: {configurable: !0, value: Object.freeze(t)},
1148 originalSources: {configurable: !0, value: Object.freeze(r)},
1149 _error: {writable: !0, value: !1},
1150 _faderId: {writable: !0, value: null},
1151 _mute: {writable: !0, value: !1},
1152 _rate: {writable: !0, value: 1},
1153 _volume: {writable: !0, value: 1}
1154 }), jQuery(this.audio).on("loadstart", function () {
1155 return n._error = !1
1156 }).on("error", function () {
1157 return n._error = !0
1158 }).find("source:last-of-type").on("error", function () {
1159 return n._trigger("error")
1160 }), SimpleAudio.subscribe(this, function (e) {
1161 if (!n.audio) return void SimpleAudio.unsubscribe(n);
1162 switch (e) {
1163 case"mute":
1164 n._updateAudioMute();
1165 break;
1166 case"rate":
1167 n._updateAudioRate();
1168 break;
1169 case"stop":
1170 n.stop();
1171 break;
1172 case"volume":
1173 n._updateAudioVolume()
1174 }
1175 }), this.load()
1176 }
1177 }, {
1178 key: "_trigger", value: function (e) {
1179 jQuery(this.audio).triggerHandler(e)
1180 }
1181 }, {
1182 key: "clone", value: function () {
1183 return new e(this)
1184 }
1185 }, {
1186 key: "destroy", value: function () {
1187 SimpleAudio.unsubscribe(this), this.fadeStop(), this.stop();
1188 var e = this.audio;
1189 for (jQuery(e).off(); e.hasChildNodes();) e.removeChild(e.firstChild);
1190 e.load(), this._error = !0, delete this.audio, delete this.sources, delete this.originalSources
1191 }
1192 }, {
1193 key: "_updateAudioMute", value: function () {
1194 this.audio.muted = this._mute || SimpleAudio.mute
1195 }
1196 }, {
1197 key: "_updateAudioRate", value: function () {
1198 this.audio.playbackRate = this._rate * SimpleAudio.rate
1199 }
1200 }, {
1201 key: "_updateAudioVolume", value: function () {
1202 this.audio.volume = this._volume * SimpleAudio.volume
1203 }
1204 }, {
1205 key: "hasSource", value: function () {
1206 return this.sources.length > 0
1207 }
1208 }, {
1209 key: "hasNoData", value: function () {
1210 return this.audio.readyState === HTMLMediaElement.HAVE_NOTHING
1211 }
1212 }, {
1213 key: "hasMetadata", value: function () {
1214 return this.audio.readyState >= HTMLMediaElement.HAVE_METADATA
1215 }
1216 }, {
1217 key: "hasSomeData", value: function () {
1218 return this.audio.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA
1219 }
1220 }, {
1221 key: "hasData", value: function () {
1222 return this.audio.readyState === HTMLMediaElement.HAVE_ENOUGH_DATA
1223 }
1224 }, {
1225 key: "isFailed", value: function () {
1226 return this._error
1227 }
1228 }, {
1229 key: "isLoading", value: function () {
1230 return this.audio.networkState === HTMLMediaElement.NETWORK_LOADING
1231 }
1232 }, {
1233 key: "isPlaying", value: function () {
1234 return !(this.audio.ended || this.audio.paused || !this.hasSomeData())
1235 }
1236 }, {
1237 key: "isPaused", value: function () {
1238 return this.audio.paused && (this.audio.duration === 1 / 0 || this.audio.currentTime > 0) && !this.audio.ended
1239 }
1240 }, {
1241 key: "isEnded", value: function () {
1242 return this.audio.ended
1243 }
1244 }, {
1245 key: "isFading", value: function () {
1246 return null !== this._faderId
1247 }
1248 }, {
1249 key: "isMuted", value: function () {
1250 return this._mute
1251 }
1252 }, {
1253 key: "isLooped", value: function () {
1254 return this.audio.loop
1255 }
1256 }, {
1257 key: "load", value: function () {
1258 "auto" !== this.audio.preload && (this.audio.preload = "auto"), this.isLoading() || this.audio.load()
1259 }
1260 }, {
1261 key: "play", value: function () {
1262 this.audio.play()
1263 }
1264 }, {
1265 key: "pause", value: function () {
1266 this.audio.pause()
1267 }
1268 }, {
1269 key: "stop", value: function () {
1270 this.pause(), this.time = 0, this._trigger(":stop")
1271 }
1272 }, {
1273 key: "fadeWithDuration", value: function (e, t, r) {
1274 var n = this;
1275 this.fadeStop();
1276 var a = Math.clamp(null == r ? this.volume : r, 0, 1), i = Math.clamp(t, 0, 1);
1277 a !== i && (this.volume = a, jQuery(this.audio).off("timeupdate.AudioWrapper:fadeWithDuration").one("timeupdate.AudioWrapper:fadeWithDuration", function () {
1278 var t = void 0, r = void 0;
1279 a < i ? (t = a, r = i) : (t = i, r = a);
1280 var o = Number(e);
1281 o < 1 && (o = 1);
1282 var s = 25, u = (i - a) / (o / (s / 1e3));
1283 n._faderId = setInterval(function () {
1284 return n.isPlaying() ? (n.volume = Math.clamp(n.volume + u, t, r), 0 === n.volume && n.pause(), void (n.volume === i && (n.fadeStop(), n._trigger(":fade")))) : void n.fadeStop()
1285 }, s)
1286 }), this.play())
1287 }
1288 }, {
1289 key: "fade", value: function (e, t) {
1290 this.fadeWithDuration(5, e, t)
1291 }
1292 }, {
1293 key: "fadeIn", value: function () {
1294 this.fade(1)
1295 }
1296 }, {
1297 key: "fadeOut", value: function () {
1298 this.fade(0)
1299 }
1300 }, {
1301 key: "fadeStop", value: function () {
1302 null !== this._faderId && (clearInterval(this._faderId), this._faderId = null)
1303 }
1304 }, {
1305 key: "on", value: function (t, r) {
1306 if ("function" != typeof r) throw new Error("listener parameter must be a function");
1307 var n = e._events, a = t.trim().splitOrEmpty(/\s+/).map(function (e) {
1308 var t = e.split(".", 1)[0];
1309 if (!n.hasOwnProperty(t)) throw new Error('unknown event "' + t + '"; valid: ' + Object.keys(n).join(", "));
1310 return e.replace(t, n[t]) + ".AudioWrapperEvent"
1311 }).join(" ");
1312 if ("" === a) throw new Error('invalid eventNames parameter "' + t + '"');
1313 return jQuery(this.audio).on(a, r), this
1314 }
1315 }, {
1316 key: "one", value: function (t, r) {
1317 if ("function" != typeof r) throw new Error("listener parameter must be a function");
1318 var n = e._events, a = t.trim().splitOrEmpty(/\s+/).map(function (e) {
1319 var t = e.split(".", 1)[0];
1320 if (!n.hasOwnProperty(t)) throw new Error('unknown event "' + t + '"; valid: ' + Object.keys(n).join(", "));
1321 return e.replace(t, n[t]) + ".AudioWrapperEvent"
1322 }).join(" ");
1323 if ("" === a) throw new Error('invalid eventNames parameter "' + t + '"');
1324 return jQuery(this.audio).one(a, r), this
1325 }
1326 }, {
1327 key: "off", value: function (t, r) {
1328 if (r && "function" != typeof r) throw new Error("listener parameter must be a function");
1329 if (!t) return jQuery(this.audio).off(".AudioWrapperEvent", r);
1330 var n = e._events, a = t.trim().splitOrEmpty(/\s+/).map(function (e) {
1331 var t = e.split(".", 1)[0];
1332 if (t) {
1333 if (!n.hasOwnProperty(t)) throw new Error('unknown event "' + t + '"; valid: ' + Object.keys(n).join(", "));
1334 return e.replace(t, n[t]) + ".AudioWrapperEvent"
1335 }
1336 return e + ".AudioWrapperEvent"
1337 }).join(" ");
1338 if ("" === a) throw new Error('invalid eventNames parameter "' + t + '"');
1339 return jQuery(this.audio).off(a, r), this
1340 }
1341 }, {
1342 key: "duration", get: function () {
1343 return this.audio.duration
1344 }
1345 }, {
1346 key: "ended", get: function () {
1347 return this.audio.ended
1348 }
1349 }, {
1350 key: "loop", get: function () {
1351 return this.audio.loop
1352 }, set: function (e) {
1353 this.audio.loop = !!e
1354 }
1355 }, {
1356 key: "mute", get: function () {
1357 return this._mute
1358 }, set: function (e) {
1359 this._mute = !!e, this._updateAudioMute()
1360 }
1361 }, {
1362 key: "paused", get: function () {
1363 return this.audio.paused
1364 }
1365 }, {
1366 key: "rate", get: function () {
1367 return this._rate
1368 }, set: function (e) {
1369 this._rate = Math.clamp(e, .2, 5), this._updateAudioRate()
1370 }
1371 }, {
1372 key: "remaining", get: function () {
1373 return this.audio.duration - this.audio.currentTime
1374 }
1375 }, {
1376 key: "time", get: function () {
1377 return this.audio.currentTime
1378 }, set: function (e) {
1379 var t = this;
1380 try {
1381 this.audio.currentTime = e
1382 } catch (r) {
1383 jQuery(this.audio).off("loadedmetadata.AudioWrapper:time").one("loadedmetadata.AudioWrapper:time", function () {
1384 return t.audio.currentTime = e
1385 })
1386 }
1387 }
1388 }, {
1389 key: "volume", get: function () {
1390 return this._volume
1391 }, set: function (e) {
1392 this._volume = Math.clamp(e, 0, 1), this._updateAudioVolume()
1393 }
1394 }], [{
1395 key: "_verifyType", value: function (t) {
1396 if (!t || !Has.audio) return null;
1397 var r = e._types;
1398 if (!r.hasOwnProperty(t)) {
1399 var n = document.createElement("audio");
1400 r[t] = "" !== n.canPlayType(t).replace(/^no$/i, "")
1401 }
1402 return r[t] ? t : null
1403 }
1404 }, {
1405 key: "getType", value: function (t) {
1406 if (!t || !Has.audio) return null;
1407 var r = e.formats, n = t.toLowerCase(), a = r.hasOwnProperty(n) ? r[n] : "audio/" + n;
1408 return e._verifyType(a)
1409 }
1410 }, {
1411 key: "canPlayFormat", value: function (t) {
1412 return null !== e.getType(t)
1413 }
1414 }, {
1415 key: "canPlayType", value: function (t) {
1416 return null !== e._verifyType(t)
1417 }
1418 }]), e
1419 }();
1420 Object.defineProperties(m, {
1421 formats: {
1422 value: {
1423 aac: "audio/aac",
1424 caf: "audio/x-caf",
1425 "x-caf": "audio/x-caf",
1426 mp3: 'audio/mpeg; codecs="mp3"',
1427 mpeg: 'audio/mpeg; codecs="mp3"',
1428 m4a: "audio/mp4",
1429 mp4: "audio/mp4",
1430 "x-m4a": "audio/mp4",
1431 "x-mp4": "audio/mp4",
1432 oga: "audio/ogg",
1433 ogg: "audio/ogg",
1434 opus: 'audio/ogg; codecs="opus"',
1435 wav: "audio/wav",
1436 wave: "audio/wav",
1437 weba: "audio/webm",
1438 webm: "audio/webm"
1439 }
1440 },
1441 _types: {value: {}},
1442 _events: {
1443 value: Object.freeze({
1444 canplay: "canplaythrough",
1445 end: "ended",
1446 error: "error",
1447 fade: ":fade",
1448 pause: "pause",
1449 play: "playing",
1450 rate: "ratechange",
1451 seek: "seeked",
1452 stop: ":stop",
1453 volume: "volumechange"
1454 })
1455 }
1456 });
1457 var y = function () {
1458 function e(t) {
1459 var r = this;
1460 _classCallCheck(this, e), Object.defineProperties(this, {
1461 tracks: {configurable: !0, value: []},
1462 queue: {configurable: !0, value: []},
1463 current: {writable: !0, value: null},
1464 _rate: {writable: !0, value: 1},
1465 _volume: {writable: !0, value: 1},
1466 _mute: {writable: !0, value: !1},
1467 _loop: {writable: !0, value: !1},
1468 _shuffle: {writable: !0, value: !1}
1469 }), Array.isArray(t) ? t.forEach(function (e) {
1470 return r.add(e)
1471 }) : t instanceof e && t.tracks.forEach(function (e) {
1472 return r.add(e)
1473 })
1474 }
1475
1476 return _createClass(e, [{
1477 key: "add", value: function (e) {
1478 var t = this;
1479 if (null == e || "object" !== ("undefined" == typeof e ? "undefined" : _typeof(e))) throw new Error("track parameter must be an object");
1480 var r = void 0, n = void 0, a = void 0, i = void 0;
1481 if (e instanceof m) r = !0, n = e.clone(), a = e.volume, i = e.rate; else {
1482 if (!e.hasOwnProperty("track")) throw new Error('track object missing required "track" property');
1483 if (!(e.track instanceof m)) throw new Error('track object\'s "track" property must be an AudioWrapper object');
1484 r = e.hasOwnProperty("copy") && e.copy, n = r ? e.track.clone() : e.track, a = e.hasOwnProperty("volume") ? e.volume : e.track.volume, i = e.hasOwnProperty("rate") ? e.rate : e.track.rate
1485 }
1486 n.stop(), n.loop = !1, n.mute = !1, n.volume = a, n.rate = i, n.on("end.AudioListEvent", function () {
1487 return t._onEnd()
1488 }), this.tracks.push({copy: r, track: n, volume: a, rate: i})
1489 }
1490 }, {
1491 key: "destroy", value: function () {
1492 this.stop(), this.tracks.filter(function (e) {
1493 return e.copy
1494 }).forEach(function (e) {
1495 return e.track.destroy()
1496 }), delete this.tracks, delete this.queue
1497 }
1498 }, {
1499 key: "isPlaying", value: function () {
1500 return null !== this.current && this.current.track.isPlaying()
1501 }
1502 }, {
1503 key: "isEnded", value: function () {
1504 return 0 === this.queue.length && (null === this.current || this.current.track.isEnded())
1505 }
1506 }, {
1507 key: "isPaused", value: function () {
1508 return null === this.current || this.current.track.isPaused()
1509 }
1510 }, {
1511 key: "isMuted", value: function () {
1512 return this._mute
1513 }
1514 }, {
1515 key: "isLooped", value: function () {
1516 return this._loop
1517 }
1518 }, {
1519 key: "isShuffled", value: function () {
1520 return this._shuffle
1521 }
1522 }, {
1523 key: "play", value: function () {
1524 (null !== this.current && !this.current.track.isEnded() || (0 === this.queue.length && this._buildList(), this._next())) && this.current.track.play()
1525 }
1526 }, {
1527 key: "pause", value: function () {
1528 null !== this.current && this.current.track.pause()
1529 }
1530 }, {
1531 key: "stop", value: function () {
1532 null !== this.current && (this.current.track.stop(), this.current = null), this.queue.splice(0)
1533 }
1534 }, {
1535 key: "skip", value: function () {
1536 this._next() ? this.current.track.play() : this._loop && this.play()
1537 }
1538 }, {
1539 key: "fadeWithDuration", value: function (e, t, r) {
1540 if (0 === this.queue.length && this._buildList(), null !== this.current && !this.current.track.isEnded() || this._next()) {
1541 var n = Math.clamp(t, 0, 1) * this.current.volume, a = void 0;
1542 null != r && (a = Math.clamp(r, 0, 1) * this.current.volume), this.current.track.fadeWithDuration(e, n, a), this._volume = t
1543 }
1544 }
1545 }, {
1546 key: "fade", value: function (e, t) {
1547 this.fadeWithDuration(5, e, t)
1548 }
1549 }, {
1550 key: "fadeIn", value: function () {
1551 this.fade(1)
1552 }
1553 }, {
1554 key: "fadeOut", value: function () {
1555 this.fade(0)
1556 }
1557 }, {
1558 key: "_next", value: function () {
1559 return null !== this.current && this.current.track.stop(), 0 === this.queue.length ? (this.current = null, !1) : (this.current = this.queue.shift(), !this.current.track.hasSource() || this.current.track.isFailed() ? this._next() : (this.current.track.mute = this._mute, this.current.track.rate = this.rate * this.current.rate, this.current.track.volume = this.volume * this.current.volume, !0))
1560 }
1561 }, {
1562 key: "_onEnd", value: function () {
1563 if (0 === this.queue.length) {
1564 if (!this._loop) return;
1565 this._buildList()
1566 }
1567 this._next() && this.current.track.play()
1568 }
1569 }, {
1570 key: "_buildList", value: function () {
1571 var e;
1572 this.queue.splice(0), (e = this.queue).push.apply(e, _toConsumableArray(this.tracks)), 0 !== this.queue.length && this._shuffle && (this.queue.shuffle(), this.queue.length > 1 && this.queue[0] === this.current && this.queue.push(this.queue.shift()))
1573 }
1574 }, {
1575 key: "duration", get: function () {
1576 return this.tracks.map(function (e) {
1577 return e.track.duration
1578 }).reduce(function (e, t) {
1579 return e + t
1580 }, 0)
1581 }
1582 }, {
1583 key: "loop", get: function () {
1584 return this._loop
1585 }, set: function (e) {
1586 this._loop = !!e
1587 }
1588 }, {
1589 key: "mute", get: function () {
1590 return this._mute
1591 }, set: function (e) {
1592 this._mute = !!e, null !== this.current && (this.current.track.mute = this._mute)
1593 }
1594 }, {
1595 key: "rate", get: function () {
1596 return this._rate
1597 }, set: function (e) {
1598 this._rate = Math.clamp(e, .2, 5), null !== this.current && (this.current.track.rate = this.rate * this.current.rate)
1599 }
1600 }, {
1601 key: "remaining", get: function () {
1602 var e = this.queue.map(function (e) {
1603 return e.track.duration
1604 }).reduce(function (e, t) {
1605 return e + t
1606 }, 0);
1607 return null !== this.current && (e += this.current.track.remaining), e
1608 }
1609 }, {
1610 key: "shuffle", get: function () {
1611 return this._shuffle
1612 }, set: function (e) {
1613 this._shuffle = !!e
1614 }
1615 }, {
1616 key: "time", get: function () {
1617 return this.duration - this.remaining
1618 }
1619 }, {
1620 key: "volume", get: function () {
1621 return this._volume
1622 }, set: function (e) {
1623 this._volume = Math.clamp(e, 0, 1), null !== this.current && (this.current.track.volume = this.volume * this.current.volume)
1624 }
1625 }]), e
1626 }();
1627 return Object.freeze(Object.defineProperties({}, {
1628 mute: {get: e, set: t},
1629 rate: {get: r, set: n},
1630 volume: {get: a, set: i},
1631 stop: {value: o},
1632 subscribe: {value: s},
1633 unsubscribe: {value: u},
1634 publish: {value: l},
1635 create: {value: c},
1636 createList: {value: d}
1637 }))
1638 }(), SimpleStore = function () {
1639 function e(e, n) {
1640 if (r) return r.create(e, n);
1641 for (var a = 0; a < t.length; ++a) if (t[a].init(e, n)) return r = t[a], r.create(e, n);
1642 throw new Error("no valid storage adapters found")
1643 }
1644
1645 var t = [], r = null;
1646 return Object.freeze(Object.defineProperties({}, {adapters: {value: t}, create: {value: e}}))
1647 }();
1648 SimpleStore.adapters.push(function () {
1649 function e() {
1650 function e(e) {
1651 try {
1652 var t = window[e], r = "_sc_" + String(Date.now());
1653 t.setItem(r, r);
1654 var n = t.getItem(r) === r;
1655 return t.removeItem(r), n
1656 } catch (e) {
1657 }
1658 return !1
1659 }
1660
1661 return r = e("localStorage") && e("sessionStorage")
1662 }
1663
1664 function t(e, t) {
1665 if (!r) throw new Error("adapter not initialized");
1666 return new n(e, t)
1667 }
1668
1669 var r = !1, n = function () {
1670 function e(t, r) {
1671 _classCallCheck(this, e);
1672 var n = t + ".", a = null, i = null;
1673 r ? (a = window.localStorage, i = "localStorage") : (a = window.sessionStorage, i = "sessionStorage"), Object.defineProperties(this, {
1674 _engine: {value: a},
1675 _prefix: {value: n},
1676 _prefixRe: {value: new RegExp("^" + RegExp.escape(n))},
1677 name: {value: i},
1678 id: {value: t},
1679 persistent: {value: !!r}
1680 })
1681 }
1682
1683 return _createClass(e, [{
1684 key: "size", value: function () {
1685 return this.keys().length
1686 }
1687 }, {
1688 key: "keys", value: function e() {
1689 for (var e = [], t = 0; t < this._engine.length; ++t) {
1690 var r = this._engine.key(t);
1691 this._prefixRe.test(r) && e.push(r.replace(this._prefixRe, ""))
1692 }
1693 return e
1694 }
1695 }, {
1696 key: "has", value: function (e) {
1697 return !("string" != typeof e || !e) && this._engine.hasOwnProperty(this._prefix + e)
1698 }
1699 }, {
1700 key: "get", value: function (t) {
1701 if ("string" != typeof t || !t) return null;
1702 var r = this._engine.getItem(this._prefix + t);
1703 return null == r ? null : e._deserialize(r)
1704 }
1705 }, {
1706 key: "set", value: function (t, r) {
1707 if ("string" != typeof t || !t) return !1;
1708 try {
1709 this._engine.setItem(this._prefix + t, e._serialize(r))
1710 } catch (e) {
1711 throw/quota[_\s]?(?:exceeded|reached)/i.test(e.name) && (e.message = this.name + " quota exceeded"), e
1712 }
1713 return !0
1714 }
1715 }, {
1716 key: "delete", value: function (e) {
1717 return !("string" != typeof e || !e) && (this._engine.removeItem(this._prefix + e), !0)
1718 }
1719 }, {
1720 key: "clear", value: function () {
1721 for (var e = this.keys(), t = 0, r = e.length; t < r; ++t) this.delete(e[t]);
1722 return !0
1723 }
1724 }, {
1725 key: "length", get: function () {
1726 return this.keys().length
1727 }
1728 }], [{
1729 key: "_serialize", value: function (e) {
1730 return LZString.compressToUTF16(JSON.stringify(e))
1731 }
1732 }, {
1733 key: "_deserialize", value: function (e) {
1734 return JSON.parse(LZString.decompressFromUTF16(e))
1735 }
1736 }]), e
1737 }();
1738 return Object.freeze(Object.defineProperties({}, {init: {value: e}, create: {value: t}}))
1739 }()), SimpleStore.adapters.push(function () {
1740 function e(e) {
1741 try {
1742 var t = "_sc_" + String(Date.now());
1743 o._setCookie(t, o._serialize(t), undefined), i = o._deserialize(o._getCookie(t)) === t, o._setCookie(t, undefined, a)
1744 } catch (e) {
1745 i = !1
1746 }
1747 return i && r(e), i
1748 }
1749
1750 function t(e, t) {
1751 if (!i) throw new Error("adapter not initialized");
1752 return new o(e, t)
1753 }
1754
1755 function r(e) {
1756 if ("" !== document.cookie) for (var t = e + ".", r = new RegExp("^" + RegExp.escape(t)), i = e + "!.", s = e + "*.", u = /\.(?:state|rcWarn)$/, l = document.cookie.split(/;\s*/), c = 0; c < l.length; ++c) {
1757 var d = l[c].split("="), f = decodeURIComponent(d[0]);
1758 if (r.test(f)) {
1759 var p = decodeURIComponent(d[1]);
1760 "" !== p && !function () {
1761 var e = !u.test(f);
1762 o._setCookie(f, undefined, a), o._setCookie(f.replace(r, function () {
1763 return e ? i : s
1764 }), p, e ? n : undefined)
1765 }()
1766 }
1767 }
1768 }
1769
1770 var n = "Tue, 19 Jan 2038 03:14:07 GMT", a = "Thu, 01 Jan 1970 00:00:00 GMT", i = !1, o = function () {
1771 function e(t, r) {
1772 _classCallCheck(this, e);
1773 var n = "" + t + (r ? "!" : "*") + ".";
1774 Object.defineProperties(this, {
1775 _prefix: {value: n},
1776 _prefixRe: {value: new RegExp("^" + RegExp.escape(n))},
1777 name: {value: "cookie"},
1778 id: {value: t},
1779 persistent: {value: !!r}
1780 })
1781 }
1782
1783 return _createClass(e, [{
1784 key: "size", value: function () {
1785 return this.keys().length
1786 }
1787 }, {
1788 key: "keys", value: function e() {
1789 if ("" === document.cookie) return [];
1790 for (var t = document.cookie.split(/;\s*/), e = [], r = 0; r < t.length; ++r) {
1791 var n = t[r].split("="), a = decodeURIComponent(n[0]);
1792 if (this._prefixRe.test(a)) {
1793 var i = decodeURIComponent(n[1]);
1794 "" !== i && e.push(a.replace(this._prefixRe, ""))
1795 }
1796 }
1797 return e
1798 }
1799 }, {
1800 key: "has", value: function (t) {
1801 return !("string" != typeof t || !t) && null !== e._getCookie(this._prefix + t)
1802 }
1803 }, {
1804 key: "get", value: function (t) {
1805 if ("string" != typeof t || !t) return null;
1806 var r = e._getCookie(this._prefix + t);
1807 return null === r ? null : e._deserialize(r)
1808 }
1809 }, {
1810 key: "set", value: function (t, r) {
1811 if ("string" != typeof t || !t) return !1;
1812 try {
1813 if (e._setCookie(this._prefix + t, e._serialize(r), this.persistent ? n : undefined), !this.has(t)) throw new Error("unknown validation error during set")
1814 } catch (e) {
1815 throw e.message = "cookie error: " + e.message, e
1816 }
1817 return !0
1818 }
1819 }, {
1820 key: "delete", value: function (t) {
1821 if ("string" != typeof t || !t || !this.has(t)) return !1;
1822 try {
1823 if (e._setCookie(this._prefix + t, undefined, a), this.has(t)) throw new Error("unknown validation error during delete")
1824 } catch (e) {
1825 throw e.message = "cookie error: " + e.message, e
1826 }
1827 return !0
1828 }
1829 }, {
1830 key: "clear", value: function () {
1831 for (var e = this.keys(), t = 0, r = e.length; t < r; ++t) this.delete(e[t]);
1832 return !0
1833 }
1834 }, {
1835 key: "length", get: function () {
1836 return this.keys().length
1837 }
1838 }], [{
1839 key: "_getCookie", value: function (e) {
1840 if (!e || "" === document.cookie) return null;
1841 for (var t = document.cookie.split(/;\s*/), r = 0; r < t.length; ++r) {
1842 var n = t[r].split("="), a = decodeURIComponent(n[0]);
1843 if (e === a) {
1844 var i = decodeURIComponent(n[1]);
1845 return i || null
1846 }
1847 }
1848 return null
1849 }
1850 }, {
1851 key: "_setCookie", value: function (e, t, r) {
1852 if (e) {
1853 var n = encodeURIComponent(e) + "=";
1854 null != t && (n += encodeURIComponent(t)), null != r && (n += "; expires=" + r), n += "; path=/", document.cookie = n
1855 }
1856 }
1857 }, {
1858 key: "_serialize", value: function (e) {
1859 return LZString.compressToBase64(JSON.stringify(e))
1860 }
1861 }, {
1862 key: "_deserialize", value: function (e) {
1863 return JSON.parse(LZString.decompressFromBase64(e))
1864 }
1865 }]), e
1866 }();
1867 return Object.freeze(Object.defineProperties({}, {init: {value: e}, create: {value: t}}))
1868 }());
1869 var DebugView = function () {
1870 var e = function () {
1871 function e(t, r, n, a) {
1872 _classCallCheck(this, e), Object.defineProperties(this, {
1873 parent: {value: t},
1874 view: {value: document.createElement("span")},
1875 break: {value: document.createElement("wbr")}
1876 }), jQuery(this.view).attr({
1877 title: a,
1878 "aria-label": a,
1879 "data-type": null != r ? r : "",
1880 "data-name": null != n ? n : ""
1881 }).addClass("debug"), this.parent.appendChild(this.view), this.parent.appendChild(this.break)
1882 }
1883
1884 return _createClass(e, [{
1885 key: "append", value: function (e) {
1886 return jQuery(this.view).append(e), this
1887 }
1888 }, {
1889 key: "modes", value: function (e) {
1890 var t = this;
1891 if (null == e) {
1892 var r = function () {
1893 var e = {};
1894 return t.view.className.splitOrEmpty(/\s+/).forEach(function (t) {
1895 "debug" !== t && (e[t] = !0)
1896 }), {v: e}
1897 }();
1898 if ("object" === ("undefined" == typeof r ? "undefined" : _typeof(r))) return r.v
1899 } else if ("object" === ("undefined" == typeof e ? "undefined" : _typeof(e))) return Object.keys(e).forEach(function (t) {
1900 this[e[t] ? "addClass" : "removeClass"](t)
1901 }, jQuery(this.view)), this;
1902 throw new Error("DebugView.prototype.modes options parameter must be an object or null/undefined")
1903 }
1904 }, {
1905 key: "remove", value: function () {
1906 var e = jQuery(this.view);
1907 this.view.hasChildNodes() && e.contents().appendTo(this.parent), e.remove(), jQuery(this.break).remove()
1908 }
1909 }, {
1910 key: "output", get: function () {
1911 return this.view
1912 }
1913 }, {
1914 key: "type", get: function () {
1915 return this.view.getAttribute("data-type")
1916 }, set: function (e) {
1917 this.view.setAttribute("data-type", null != e ? e : "")
1918 }
1919 }, {
1920 key: "name", get: function () {
1921 return this.view.getAttribute("data-name")
1922 }, set: function (e) {
1923 this.view.setAttribute("data-name", null != e ? e : "")
1924 }
1925 }, {
1926 key: "title", get: function () {
1927 return this.view.title
1928 }, set: function (e) {
1929 this.view.title = e
1930 }
1931 }], [{
1932 key: "init", value: function () {
1933 jQuery('<button id="debug-view-toggle">' + L10n.get("debugViewTitle") + "</button>").ariaClick({label: L10n.get("debugViewToggle")}, function () {
1934 return e.toggle()
1935 }).prependTo("#ui-bar-body"), e.enable()
1936 }
1937 }, {
1938 key: "enable", value: function () {
1939 jQuery(document.documentElement).attr("data-debug-view", "enabled"), jQuery.event.trigger(":debugviewupdate")
1940 }
1941 }, {
1942 key: "disable", value: function () {
1943 jQuery(document.documentElement).removeAttr("data-debug-view"), jQuery.event.trigger(":debugviewupdate")
1944 }
1945 }, {
1946 key: "toggle", value: function () {
1947 "enabled" === jQuery(document.documentElement).attr("data-debug-view") ? e.disable() : e.enable()
1948 }
1949 }]), e
1950 }();
1951 return e
1952 }(), PRNGWrapper = function () {
1953 var e = function () {
1954 function e(t, r) {
1955 _classCallCheck(this, e), Object.defineProperties(this, new Math.seedrandom(t, r, function (e, t) {
1956 return {
1957 _prng: {value: e},
1958 seed: {writable: !0, value: t},
1959 pull: {writable: !0, value: 0},
1960 random: {
1961 value: function () {
1962 return ++this.pull, this._prng()
1963 }
1964 }
1965 }
1966 }))
1967 }
1968
1969 return _createClass(e, null, [{
1970 key: "marshal", value: function (e) {
1971 if (!e || !e.hasOwnProperty("seed") || !e.hasOwnProperty("pull")) throw new Error("PRNG is missing required data");
1972 return {seed: e.seed, pull: e.pull}
1973 }
1974 }, {
1975 key: "unmarshal", value: function (t) {
1976 if (!t || !t.hasOwnProperty("seed") || !t.hasOwnProperty("pull")) throw new Error("PRNG object is missing required data");
1977 for (var r = new e(t.seed, !1), n = t.pull; n > 0; --n) r.random();
1978 return r
1979 }
1980 }]), e
1981 }();
1982 return e
1983 }(), StyleWrapper = function () {
1984 var e = /\[[<>]?[Ii][Mm][Gg]\[(?:\s|\S)*?\]\]+/g, t = new RegExp(e.source), r = function () {
1985 function r(e) {
1986 if (_classCallCheck(this, r), null == e) throw new TypeError("StyleWrapper style parameter must be an HTMLStyleElement object");
1987 Object.defineProperties(this, {style: {value: e}})
1988 }
1989
1990 return _createClass(r, [{
1991 key: "isEmpty", value: function () {
1992 return 0 === this.style.cssRules.length
1993 }
1994 }, {
1995 key: "set", value: function (e) {
1996 this.clear(), this.add(e)
1997 }
1998 }, {
1999 key: "add", value: function (r) {
2000 var n = r;
2001 t.test(n) && (e.lastIndex = 0, n = n.replace(e, function (e) {
2002 var t = Wikifier.helpers.parseSquareBracketedMarkup({source: e, matchStart: 0});
2003 if (t.hasOwnProperty("error") || t.pos < e.length) return e;
2004 var r = t.source;
2005 if ("data:" !== r.slice(0, 5) && Story.has(r)) {
2006 var n = Story.get(r);
2007 n.tags.includes("Twine.image") && (r = n.text)
2008 }
2009 return 'url("' + r.replace(/"/g, "%22") + '")'
2010 })), this.style.styleSheet ? this.style.styleSheet.cssText += n : this.style.appendChild(document.createTextNode(n))
2011 }
2012 }, {
2013 key: "clear", value: function () {
2014 this.style.styleSheet ? this.style.styleSheet.cssText = "" : jQuery(this.style).empty()
2015 }
2016 }]), r
2017 }();
2018 return r
2019 }(), Diff = function () {
2020 function e(t, n) {
2021 for (var a = Object.prototype.toString, i = Array.isArray(t), o = [].concat(Object.keys(t), Object.keys(n)).sort().filter(function (e, t, r) {
2022 return 0 === t || r[t - 1] !== e
2023 }), s = {}, u = void 0, l = function (e) {
2024 return e === u
2025 }, c = 0, d = o.length; c < d; ++c) {
2026 var f = o[c], p = t[f], h = n[f];
2027 if (t.hasOwnProperty(f)) if (n.hasOwnProperty(f)) {
2028 if (p === h) continue;
2029 if (("undefined" == typeof p ? "undefined" : _typeof(p)) === ("undefined" == typeof h ? "undefined" : _typeof(h))) if ("function" == typeof p) p.toString() !== h.toString() && (s[f] = [r.Copy, h]); else if ("object" !== ("undefined" == typeof p ? "undefined" : _typeof(p)) || null === p) s[f] = [r.Copy, h]; else {
2030 var g = a.call(p), m = a.call(h);
2031 if (g === m) if ("[object Date]" === g) {
2032 var y = Number(h);
2033 Number(p) !== y && (s[f] = [r.CopyDate, y])
2034 } else if ("[object RegExp]" === g) p.toString() !== h.toString() && (s[f] = [r.Copy, clone(h)]); else {
2035 var v = e(p, h);
2036 null !== v && (s[f] = v)
2037 } else s[f] = [r.Copy, clone(h)]
2038 } else s[f] = [r.Copy, "object" !== ("undefined" == typeof h ? "undefined" : _typeof(h)) || null === h ? h : clone(h)]
2039 } else if (i && Util.isNumeric(f)) {
2040 var b = Number(f);
2041 if (!u) {
2042 u = "";
2043 do u += "~"; while (o.some(l));
2044 s[u] = [r.SpliceArray, b, b]
2045 }
2046 b < s[u][1] && (s[u][1] = b), b > s[u][2] && (s[u][2] = b)
2047 } else s[f] = r.Delete; else s[f] = [r.Copy, "object" !== ("undefined" == typeof h ? "undefined" : _typeof(h)) || null === h ? h : clone(h)]
2048 }
2049 return Object.keys(s).length > 0 ? s : null
2050 }
2051
2052 function t(e, n) {
2053 for (var a = Object.keys(n || {}), i = clone(e), o = 0, s = a.length; o < s; ++o) {
2054 var u = a[o], l = n[u];
2055 if (l === r.Delete) delete i[u]; else if (Array.isArray(l)) switch (l[0]) {
2056 case r.SpliceArray:
2057 i.splice(l[1], 1 + (l[2] - l[1]));
2058 break;
2059 case r.Copy:
2060 i[u] = clone(l[1]);
2061 break;
2062 case r.CopyDate:
2063 i[u] = new Date(l[1])
2064 } else i[u] = t(i[u], l)
2065 }
2066 return i
2067 }
2068
2069 var r = Util.toEnum({Delete: 0, SpliceArray: 1, Copy: 2, CopyDate: 3});
2070 return Object.freeze(Object.defineProperties({}, {Op: {value: r}, diff: {value: e}, patch: {value: t}}))
2071 }(), L10n = function () {
2072 function e() {
2073 r()
2074 }
2075
2076 function t(e, t) {
2077 if (!e) return "";
2078 var r = function (e) {
2079 var t = void 0;
2080 return e.some(function (e) {
2081 return !!l10nStrings.hasOwnProperty(e) && (t = e, !0)
2082 }), t
2083 }(Array.isArray(e) ? e : [e]);
2084 if (!r) return "";
2085 for (var i = 50, o = l10nStrings[r], s = 0; a.test(o);) {
2086 if (++s > i) throw new Error("L10n.get exceeded maximum replacement iterations, probable infinite loop");
2087 n.lastIndex = 0, o = o.replace(n, function (e) {
2088 var r = e.slice(1, -1);
2089 return t && t.hasOwnProperty(r) ? t[r] : l10nStrings.hasOwnProperty(r) ? l10nStrings[r] : void 0
2090 })
2091 }
2092 return o
2093 }
2094
2095 function r() {
2096 strings && Object.keys(strings).length > 0 && Object.keys(l10nStrings).forEach(function (e) {
2097 try {
2098 var t = void 0;
2099 switch (e) {
2100 case"identity":
2101 t = strings.identity;
2102 break;
2103 case"aborting":
2104 t = strings.aborting;
2105 break;
2106 case"cancel":
2107 t = strings.cancel;
2108 break;
2109 case"close":
2110 t = strings.close;
2111 break;
2112 case"ok":
2113 t = strings.ok;
2114 break;
2115 case"errorTitle":
2116 t = strings.errors.title;
2117 break;
2118 case"errorNonexistentPassage":
2119 t = strings.errors.nonexistentPassage;
2120 break;
2121 case"errorSaveMissingData":
2122 t = strings.errors.saveMissingData;
2123 break;
2124 case"errorSaveIdMismatch":
2125 t = strings.errors.saveIdMismatch;
2126 break;
2127 case"warningDegraded":
2128 t = strings.warnings.degraded;
2129 break;
2130 case"debugViewTitle":
2131 t = strings.debugView.title;
2132 break;
2133 case"debugViewToggle":
2134 t = strings.debugView.toggle;
2135 break;
2136 case"uiBarToggle":
2137 t = strings.uiBar.toggle;
2138 break;
2139 case"uiBarBackward":
2140 t = strings.uiBar.backward;
2141 break;
2142 case"uiBarForward":
2143 t = strings.uiBar.forward;
2144 break;
2145 case"uiBarJumpto":
2146 t = strings.uiBar.jumpto;
2147 break;
2148 case"jumptoTitle":
2149 t = strings.jumpto.title;
2150 break;
2151 case"jumptoTurn":
2152 t = strings.jumpto.turn;
2153 break;
2154 case"jumptoUnavailable":
2155 t = strings.jumpto.unavailable;
2156 break;
2157 case"savesTitle":
2158 t = strings.saves.title;
2159 break;
2160 case"savesDisallowed":
2161 t = strings.saves.disallowed;
2162 break;
2163 case"savesEmptySlot":
2164 t = strings.saves.emptySlot;
2165 break;
2166 case"savesIncapable":
2167 t = strings.saves.incapable;
2168 break;
2169 case"savesLabelAuto":
2170 t = strings.saves.labelAuto;
2171 break;
2172 case"savesLabelDelete":
2173 t = strings.saves.labelDelete;
2174 break;
2175 case"savesLabelExport":
2176 t = strings.saves.labelExport;
2177 break;
2178 case"savesLabelImport":
2179 t = strings.saves.labelImport;
2180 break;
2181 case"savesLabelLoad":
2182 t = strings.saves.labelLoad;
2183 break;
2184 case"savesLabelClear":
2185 t = strings.saves.labelClear;
2186 break;
2187 case"savesLabelSave":
2188 t = strings.saves.labelSave;
2189 break;
2190 case"savesLabelSlot":
2191 t = strings.saves.labelSlot;
2192 break;
2193 case"savesSavedOn":
2194 t = strings.saves.savedOn;
2195 break;
2196 case"savesUnavailable":
2197 t = strings.saves.unavailable;
2198 break;
2199 case"savesUnknownDate":
2200 t = strings.saves.unknownDate;
2201 break;
2202 case"settingsTitle":
2203 t = strings.settings.title;
2204 break;
2205 case"settingsOff":
2206 t = strings.settings.off;
2207 break;
2208 case"settingsOn":
2209 t = strings.settings.on;
2210 break;
2211 case"settingsReset":
2212 t = strings.settings.reset;
2213 break;
2214 case"restartTitle":
2215 t = strings.restart.title;
2216 break;
2217 case"restartPrompt":
2218 t = strings.restart.prompt;
2219 break;
2220 case"shareTitle":
2221 t = strings.share.title;
2222 break;
2223 case"autoloadTitle":
2224 t = strings.autoload.title;
2225 break;
2226 case"autoloadCancel":
2227 t = strings.autoload.cancel;
2228 break;
2229 case"autoloadOk":
2230 t = strings.autoload.ok;
2231 break;
2232 case"autoloadPrompt":
2233 t = strings.autoload.prompt;
2234 break;
2235 case"macroBackText":
2236 t = strings.macros.back.text;
2237 break;
2238 case"macroReturnText":
2239 t = strings.macros.return.text
2240 }
2241 t && (l10nStrings[e] = t.replace(/%\w+%/g, function (e) {
2242 return "{" + e.slice(1, -1) + "}"
2243 }))
2244 } catch (e) {
2245 }
2246 })
2247 }
2248
2249 var n = /\{\w+\}/g, a = new RegExp(n.source);
2250 return Object.freeze(Object.defineProperties({}, {init: {value: e}, get: {value: t}}))
2251 }(), strings = {
2252 errors: {},
2253 warnings: {},
2254 debugView: {},
2255 uiBar: {},
2256 jumpto: {},
2257 saves: {},
2258 settings: {},
2259 restart: {},
2260 share: {},
2261 autoload: {},
2262 macros: {back: {}, return: {}}
2263 }, l10nStrings = {
2264 identity: "game",
2265 aborting: "Aborting",
2266 cancel: "Cancel",
2267 close: "Close",
2268 ok: "OK",
2269 errorTitle: "Error",
2270 errorNonexistentPassage: 'the passage "{passage}" does not exist',
2271 errorSaveMissingData: "save is missing required data. Either the loaded file is not a save or the save has become corrupted",
2272 errorSaveIdMismatch: "save is from the wrong {identity}",
2273 _warningIntroLacking: "Your browser either lacks or has disabled",
2274 _warningOutroDegraded: ", so this {identity} is running in a degraded mode. You may be able to continue, however, some parts may not work properly.",
2275 warningNoWebStorage: "{_warningIntroLacking} the Web Storage API{_warningOutroDegraded}",
2276 warningDegraded: "{_warningIntroLacking} some of the capabilities required by this {identity}{_warningOutroDegraded}",
2277 debugViewTitle: "Debug View",
2278 debugViewToggle: "Toggle the debug view",
2279 uiBarToggle: "Toggle the UI bar",
2280 uiBarBackward: "Go backward within the {identity} history",
2281 uiBarForward: "Go forward within the {identity} history",
2282 uiBarJumpto: "Jump to a specific point within the {identity} history",
2283 jumptoTitle: "Jump To",
2284 jumptoTurn: "Turn",
2285 jumptoUnavailable: "No jump points currently available…",
2286 savesTitle: "Saves",
2287 savesDisallowed: "Saving has been disallowed on this passage.",
2288 savesEmptySlot: "— slot empty —",
2289 savesIncapable: "{_warningIntroLacking} the capabilities required to support saves, so saves have been disabled for this session.",
2290 savesLabelAuto: "Autosave",
2291 savesLabelDelete: "Delete",
2292 savesLabelExport: "Save to Disk…",
2293 savesLabelImport: "Load from Disk…",
2294 savesLabelLoad: "Load",
2295 savesLabelClear: "Delete All",
2296 savesLabelSave: "Save",
2297 savesLabelSlot: "Slot",
2298 savesSavedOn: "Saved on",
2299 savesUnavailable: "No save slots found…",
2300 savesUnknownDate: "unknown",
2301 settingsTitle: "Settings",
2302 settingsOff: "Off",
2303 settingsOn: "On",
2304 settingsReset: "Reset to Defaults",
2305 restartTitle: "Restart",
2306 restartPrompt: "Are you sure that you want to restart? Unsaved progress will be lost.",
2307 shareTitle: "Share",
2308 autoloadTitle: "Autoload",
2309 autoloadCancel: "Go to start",
2310 autoloadOk: "Load autosave",
2311 autoloadPrompt: "An autosave exists. Load it now or go to the start?",
2312 macroBackText: "Back",
2313 macroReturnText: "Return"
2314 }, Config = function () {
2315 function e() {
2316 throw new Error("Config.history.mode has been deprecated and is no longer used by SugarCube, please remove it from your code")
2317 }
2318
2319 function t() {
2320 throw new Error("Config.history.tracking has been deprecated, use Config.history.maxStates instead")
2321 }
2322
2323 var r = Object.seal({
2324 debug: !1,
2325 addVisitedLinkClass: !1,
2326 cleanupWikifierOutput: !1,
2327 loadDelay: 0,
2328 history: Object.seal({
2329 controls: !0, maxStates: 100, get mode() {
2330 e()
2331 }, set mode(t) {
2332 e()
2333 }, get tracking() {
2334 t()
2335 }, set tracking(e) {
2336 t()
2337 }
2338 }),
2339 macros: Object.seal({ifAssignmentError: !0, maxLoopIterations: 1e3}),
2340 navigation: Object.seal({override: undefined}),
2341 passages: Object.seal({
2342 descriptions: undefined,
2343 displayTitles: !1,
2344 nobr: !1,
2345 start: undefined,
2346 transitionOut: undefined
2347 }),
2348 saves: Object.seal({
2349 autoload: undefined,
2350 autosave: undefined,
2351 id: "untitled-story",
2352 isAllowed: undefined,
2353 onLoad: undefined,
2354 onSave: undefined,
2355 slots: 8,
2356 version: undefined
2357 }),
2358 ui: Object.seal({stowBarInitially: 800, updateStoryElements: !0}),
2359 transitionEndEventName: function () {
2360 for (var e = new Map([["transition", "transitionend"], ["MSTransition", "msTransitionEnd"], ["WebkitTransition", "webkitTransitionEnd"], ["MozTransition", "transitionend"]]), t = [].concat(_toConsumableArray(e.keys())), r = document.createElement("div"), n = 0; n < t.length; ++n) if (r.style[t[n]] !== undefined) return e.get(t[n]);
2361 return ""
2362 }()
2363 });
2364 return r
2365 }(), Patterns = function () {
2366 var e = function () {
2367 var e = new Map([[" ", "\\u0020"], ["\f", "\\f"], ["\n", "\\n"], ["\r", "\\r"], ["\t", "\\t"], ["\v", "\\v"], [" ", "\\u00a0"], [" ", "\\u1680"], ["", "\\u180e"], [" ", "\\u2000"], [" ", "\\u2001"], [" ", "\\u2002"], [" ", "\\u2003"], [" ", "\\u2004"], [" ", "\\u2005"], [" ", "\\u2006"], [" ", "\\u2007"], [" ", "\\u2008"], [" ", "\\u2009"], [" ", "\\u200a"], ["\u2028", "\\u2028"], ["\u2029", "\\u2029"], [" ", "\\u202f"], [" ", "\\u205f"], [" ", "\\u3000"], ["\ufeff", "\\ufeff"]]),
2368 t = /\s/, r = "";
2369 return e.forEach(function (e, n) {
2370 t.test(n) || (r += e)
2371 }), r ? "[\\s" + r + "]" : "\\s"
2372 }(), t = "[\\u0020\\f\\t\\v\\u00a0\\u1680\\u180e\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]",
2373 r = "[\\n\\r\\u2028\\u2029]",
2374 n = "[0-9A-Z_a-z\\-\\u00c0-\\u00d6\\u00d8-\\u00f6\\u00f8-\\u00ff\\u0150\\u0170\\u0151\\u0171]",
2375 a = n.replace("\\-", ""), i = "[$A-Z_a-z]", o = i + "[$0-9A-Z_a-z]*", s = "[$_]", u = s + o,
2376 l = "[A-Za-z][\\w-]*|[=-]", c = "(" + n + "+)\\(([^\\)\\|\\n]+)\\):", d = "(" + n + "+):([^;\\|\\n]+);",
2377 f = "((?:\\." + n + "+)+);", p = "((?:#" + n + "+)+);", h = c + "|" + d + "|" + f + "|" + p,
2378 g = "(?:file|https?|mailto|ftp|javascript|irc|news|data):[^\\s'\"]+";
2379 return Object.freeze({
2380 space: e,
2381 spaceNoTerminator: t,
2382 lineTerminator: r,
2383 anyLetter: n,
2384 anyLetterStrict: a,
2385 identifierFirstChar: i,
2386 identifier: o,
2387 variableSigil: s,
2388 variable: u,
2389 macroName: l,
2390 inlineCss: h,
2391 url: g
2392 })
2393 }(), Scripting = function () {
2394 function addAccessibleClickHandler(e, t, r, n, a) {
2395 if (arguments.length < 2) throw new Error("addAccessibleClickHandler insufficient number of parameters");
2396 var i = void 0, o = void 0;
2397 if ("function" == typeof t ? (i = t, o = {namespace: n, one: !!r}) : (i = r, o = {
2398 namespace: a,
2399 one: !!n,
2400 selector: t
2401 }), "function" != typeof i) throw new TypeError("addAccessibleClickHandler handler parameter must be a function");
2402 return jQuery(e).ariaClick(o, i)
2403 }
2404
2405 function insertElement(e, t, r, n, a, i) {
2406 var o = jQuery(document.createElement(t));
2407 return r && o.attr("id", r), n && o.addClass(n), i && o.attr("title", i), a && o.text(a), e && o.appendTo(e), o[0]
2408 }
2409
2410 function insertText(e, t) {
2411 jQuery(e).append(document.createTextNode(t))
2412 }
2413
2414 function removeChildren(e) {
2415 jQuery(e).empty()
2416 }
2417
2418 function removeElement(e) {
2419 jQuery(e).remove()
2420 }
2421
2422 function fade(e, t) {
2423 function r() {
2424 i += .05 * a, n(o, Math.easeInOut(i)), (1 === a && i >= 1 || a === -1 && i <= 0) && (e.style.visibility = "in" === t.fade ? "visible" : "hidden", o.parentNode.replaceChild(e, o), o = null, window.clearInterval(s), t.onComplete && t.onComplete())
2425 }
2426
2427 function n(e, t) {
2428 e.style.zoom = 1, e.style.filter = "alpha(opacity=" + Math.floor(100 * t) + ")", e.style.opacity = t
2429 }
2430
2431 var a = "in" === t.fade ? 1 : -1, i = void 0, o = e.cloneNode(!0), s = void 0;
2432 e.parentNode.replaceChild(o, e), "in" === t.fade ? (i = 0, o.style.visibility = "visible") : i = 1, n(o, i), s = window.setInterval(r, 25)
2433 }
2434
2435 function scrollWindowTo(e, t) {
2436 function r() {
2437 c += i, window.scroll(0, o + l * (u * Math.easeInOut(c))), c >= 1 && window.clearInterval(d)
2438 }
2439
2440 function n(e) {
2441 for (var t = 0; e.offsetParent;) t += e.offsetTop, e = e.offsetParent;
2442 return t
2443 }
2444
2445 function a(e) {
2446 var t = n(e), r = t + e.offsetHeight, a = window.scrollY ? window.scrollY : document.body.scrollTop,
2447 i = window.innerHeight ? window.innerHeight : document.body.clientHeight, o = a + i;
2448 return t >= a && r > o && e.offsetHeight < i ? t - (i - e.offsetHeight) + 20 : t
2449 }
2450
2451 var i = null != t ? Number(t) : .1;
2452 Number.isNaN(i) || !Number.isFinite(i) || i < 0 ? i = .1 : i > 1 && (i = 1);
2453 var o = window.scrollY ? window.scrollY : document.body.scrollTop, s = a(e), u = Math.abs(o - s),
2454 l = o > s ? -1 : 1, c = 0, d = void 0;
2455 d = window.setInterval(r, 25)
2456 }
2457
2458 function either() {
2459 if (0 !== arguments.length) return Array.prototype.concat.apply([], arguments).random()
2460 }
2461
2462 function hasVisited() {
2463 if (0 === arguments.length) throw new Error("hasVisited called with insufficient parameters");
2464 if (State.isEmpty()) return !1;
2465 for (var e = Array.prototype.concat.apply([], arguments), t = State.passages, r = 0, n = e.length; r < n; ++r) if (!t.includes(e[r])) return !1;
2466 return !0
2467 }
2468
2469 function lastVisited() {
2470 if (0 === arguments.length) throw new Error("lastVisited called with insufficient parameters");
2471 if (State.isEmpty()) return -1;
2472 for (var e = Array.prototype.concat.apply([], arguments), t = State.passages, r = t.length - 1, n = State.turns, a = 0, i = e.length; a < i && n > -1; ++a) {
2473 var o = t.lastIndexOf(e[a]);
2474 n = Math.min(n, o === -1 ? -1 : r - o)
2475 }
2476 return n
2477 }
2478
2479 function passage() {
2480 return State.passage
2481 }
2482
2483 function previous() {
2484 var e = State.passages;
2485 if (arguments.length > 0) {
2486 var t = Number(arguments[0]);
2487 if (!Number.isSafeInteger(t) || t < 1) throw new RangeError("previous offset parameter must be a positive integer greater than zero");
2488 return e.length > t ? e[e.length - 1 - t] : ""
2489 }
2490 for (var r = e.length - 2; r >= 0; --r) if (e[r] !== State.passage) return e[r];
2491 return ""
2492 }
2493
2494 function random() {
2495 var e = void 0, t = void 0;
2496 switch (arguments.length) {
2497 case 0:
2498 throw new Error("random called with insufficient parameters");
2499 case 1:
2500 e = 0, t = Math.trunc(arguments[0]);
2501 break;
2502 default:
2503 e = Math.trunc(arguments[0]), t = Math.trunc(arguments[1])
2504 }
2505 if (!Number.isInteger(e)) throw new Error("random min parameter must be an integer");
2506 if (!Number.isInteger(t)) throw new Error("random max parameter must be an integer");
2507 if (e > t) {
2508 var r = [t, e];
2509 e = r[0], t = r[1]
2510 }
2511 return Math.floor(State.random() * (t - e + 1)) + e
2512 }
2513
2514 function randomFloat() {
2515 var e = void 0, t = void 0;
2516 switch (arguments.length) {
2517 case 0:
2518 throw new Error("randomFloat called with insufficient parameters");
2519 case 1:
2520 e = 0, t = Number(arguments[0]);
2521 break;
2522 default:
2523 e = Number(arguments[0]), t = Number(arguments[1])
2524 }
2525 if (Number.isNaN(e) || !Number.isFinite(e)) throw new Error("randomFloat min parameter must be a number");
2526 if (Number.isNaN(t) || !Number.isFinite(t)) throw new Error("randomFloat max parameter must be a number");
2527 if (e > t) {
2528 var r = [t, e];
2529 e = r[0], t = r[1]
2530 }
2531 return State.random() * (t - e) + e
2532 }
2533
2534 function tags() {
2535 if (0 === arguments.length) return Story.get(State.passage).tags.slice(0);
2536 for (var e = Array.prototype.concat.apply([], arguments), t = [], r = 0, n = e.length; r < n; ++r) t = t.concat(Story.get(e[r]).tags);
2537 return t
2538 }
2539
2540 function temporary() {
2541 return State.temporary
2542 }
2543
2544 function time() {
2545 return null === Engine.lastPlay ? 0 : Util.now() - Engine.lastPlay
2546 }
2547
2548 function turns() {
2549 return State.turns
2550 }
2551
2552 function variables() {
2553 return State.variables
2554 }
2555
2556 function visited() {
2557 if (State.isEmpty()) return 0;
2558 for (var e = Array.prototype.concat.apply([], 0 === arguments.length ? [State.passage] : arguments), t = State.passages, r = State.turns, n = 0, a = e.length; n < a && r > 0; ++n) r = Math.min(r, t.count(e[n]));
2559 return r
2560 }
2561
2562 function visitedTags() {
2563 if (0 === arguments.length) throw new Error("visitedTags called with insufficient parameters");
2564 if (State.isEmpty()) return 0;
2565 for (var e = Array.prototype.concat.apply([], arguments), t = e.length, r = State.passages, n = new Map, a = 0, i = 0, o = r.length; i < o; ++i) {
2566 var s = r[i];
2567 if (n.has(s)) n.get(s) && ++a; else {
2568 var u = Story.get(s).tags;
2569 if (u.length > 0) {
2570 for (var l = 0, c = 0; c < t; ++c) u.includes(e[c]) && ++l;
2571 l === t ? (++a, n.set(s, !0)) : n.set(s, !1)
2572 }
2573 }
2574 }
2575 return a
2576 }
2577
2578 function evalJavaScript(code, output) {
2579 return function (code, output) {
2580 return eval(code)
2581 }.call(output ? {output: output} : null, String(code), output)
2582 }
2583
2584 function evalTwineScript(code, output) {
2585 return function (code, output) {
2586 return eval(code)
2587 }.call(output ? {output: output} : null, parse(String(code)), output)
2588 }
2589
2590 var _ref6 = function () {
2591 function e(e) {
2592 return e.reduce(function (e, t) {
2593 return e = e.then(t)
2594 }, Promise.resolve())
2595 }
2596
2597 function t(e) {
2598 return Util.parseUrl(e).path.replace(/^[^\w]+|[^\w]+$/g, "").replace(/[^\w]+/g, "-").toLocaleLowerCase()
2599 }
2600
2601 function r() {
2602 function r(e) {
2603 return new Promise(function (r, n) {
2604 jQuery(document.createElement("script")).one("load abort error", function (e) {
2605 jQuery(e.target).off(), "load" === e.type ? r(e.target) : n(e.target)
2606 }).appendTo(document.head).attr({
2607 id: "script-imported-" + t(e),
2608 type: "text/javascript",
2609 src: e
2610 })
2611 })
2612 }
2613
2614 for (var n = arguments.length, a = Array(n), i = 0; i < n; i++) a[i] = arguments[i];
2615 return Promise.all(a.map(function (t) {
2616 return Array.isArray(t) ? e(t.map(function (e) {
2617 return function () {
2618 return r(e)
2619 }
2620 })) : r(t)
2621 }))
2622 }
2623
2624 function n() {
2625 function r(e) {
2626 return new Promise(function (r, n) {
2627 jQuery(document.createElement("link")).one("load abort error", function (e) {
2628 jQuery(e.target).off(), "load" === e.type ? r(e.target) : n(e.target)
2629 }).appendTo(document.head).attr({id: "style-imported-" + t(e), rel: "stylesheet", href: e})
2630 })
2631 }
2632
2633 for (var n = arguments.length, a = Array(n), i = 0; i < n; i++) a[i] = arguments[i];
2634 return Promise.all(a.map(function (t) {
2635 return Array.isArray(t) ? e(t.map(function (e) {
2636 return function () {
2637 return r(e)
2638 }
2639 })) : r(t)
2640 }))
2641 }
2642
2643 return {importScripts: r, importStyles: n}
2644 }(), importScripts = _ref6.importScripts, importStyles = _ref6.importStyles, parse = function () {
2645 function e(e) {
2646 if (0 !== r.lastIndex) throw new RangeError("Scripting.parse last index is non-zero at start");
2647 for (var a = e, i = void 0; null !== (i = r.exec(a));) if (i[5]) {
2648 var o = i[5];
2649 if ("$" === o || "_" === o) continue;
2650 if (n.test(o)) o = o[0]; else if ("is" === o) {
2651 var s = r.lastIndex, u = a.slice(s);
2652 /^\s+not\b/.test(u) && (a = a.splice(s, u.search(/\S/)), o = "isnot")
2653 }
2654 t.hasOwnProperty(o) && (a = a.splice(i.index, o.length, t[o]), r.lastIndex += t[o].length - o.length)
2655 }
2656 return a
2657 }
2658
2659 var t = Object.freeze({
2660 $: "State.variables.",
2661 _: "State.temporary.",
2662 to: "=",
2663 eq: "==",
2664 neq: "!=",
2665 is: "===",
2666 isnot: "!==",
2667 gt: ">",
2668 gte: ">=",
2669 lt: "<",
2670 lte: "<=",
2671 and: "&&",
2672 or: "||",
2673 not: "!",
2674 def: '"undefined" !== typeof',
2675 ndef: '"undefined" === typeof'
2676 }),
2677 r = new RegExp(["(\"\"|'')", '("(?:\\\\.|[^"\\\\])+")', "('(?:\\\\.|[^'\\\\])+')", "([=+\\-*\\/%<>&\\|\\^~!?:,;\\(\\)\\[\\]{}]+)", "([^\"'=+\\-*\\/%<>&\\|\\^~!?:,;\\(\\)\\[\\]{}\\s]+)"].join("|"), "g"),
2678 n = new RegExp("^" + Patterns.variable);
2679 return e
2680 }();
2681 return Object.freeze(Object.defineProperties({}, {
2682 parse: {value: parse},
2683 evalJavaScript: {value: evalJavaScript},
2684 evalTwineScript: {value: evalTwineScript}
2685 }))
2686 }(), Wikifier = function () {
2687 var e = 0, t = function () {
2688 function t(r, n, a) {
2689 _classCallCheck(this, t), t.Parser.Profile.isEmpty() && t.Parser.Profile.compile(), Object.defineProperties(this, {
2690 source: {value: String(n)},
2691 options: {writable: !0, value: Object.assign({profile: "all"}, a)},
2692 nextMatch: {writable: !0, value: 0},
2693 output: {writable: !0, value: null},
2694 _rawArgs: {writable: !0, value: ""}
2695 }), null == r ? this.output = document.createDocumentFragment() : r.jquery ? this.output = r[0] : this.output = r;
2696 try {
2697 ++e, this.subWikify(this.output), 1 === e && Config.cleanupWikifierOutput && convertBreaks(this.output)
2698 } finally {
2699 --e
2700 }
2701 }
2702
2703 return _createClass(t, [{
2704 key: "subWikify", value: function (e, r, n) {
2705 var a = this.output, i = void 0;
2706 this.output = e, null != n && "object" === ("undefined" == typeof n ? "undefined" : _typeof(n)) && (i = this.options, this.options = Object.assign({}, this.options, n));
2707 var o = t.Parser.Profile.get(this.options.profile),
2708 s = r ? new RegExp("(?:" + r + ")", this.options.ignoreTerminatorCase ? "gim" : "gm") : null,
2709 u = void 0, l = void 0;
2710 do {
2711 if (o.parserRegExp.lastIndex = this.nextMatch, s && (s.lastIndex = this.nextMatch), l = o.parserRegExp.exec(this.source), u = s ? s.exec(this.source) : null, u && (!l || u.index <= l.index)) return u.index > this.nextMatch && this.outputText(this.output, this.nextMatch, u.index), this.matchStart = u.index, this.matchLength = u[0].length, this.matchText = u[0], this.nextMatch = s.lastIndex, this.output = a, void (i && (this.options = i));
2712 if (l) {
2713 l.index > this.nextMatch && this.outputText(this.output, this.nextMatch, l.index), this.matchStart = l.index, this.matchLength = l[0].length, this.matchText = l[0], this.nextMatch = o.parserRegExp.lastIndex;
2714 for (var c = void 0, d = 1, f = l.length; d < f; ++d) if (l[d]) {
2715 c = d - 1;
2716 break
2717 }
2718 if (o.parsers[c].handler(this), null != TempState.break) break
2719 }
2720 } while (u || l);
2721 null == TempState.break ? this.nextMatch < this.source.length && (this.outputText(this.output, this.nextMatch, this.source.length), this.nextMatch = this.source.length) : this.output.lastChild && this.output.lastChild.nodeType === Node.ELEMENT_NODE && "BR" === this.output.lastChild.nodeName.toUpperCase() && jQuery(this.output.lastChild).remove(), this.output = a, i && (this.options = i)
2722 }
2723 }, {
2724 key: "outputText", value: function (e, t, r) {
2725 jQuery(e).append(document.createTextNode(this.source.substring(t, r)))
2726 }
2727 }, {
2728 key: "rawArgs", value: function () {
2729 return this._rawArgs
2730 }
2731 }, {
2732 key: "fullArgs", value: function () {
2733 return Scripting.parse(this._rawArgs)
2734 }
2735 }], [{
2736 key: "getValue", value: function (e) {
2737 var r = t.parseStoryVariable(e), n = void 0;
2738 if (null !== r) {
2739 n = r.store;
2740 for (var a = r.names, i = 0, o = a.length; i < o; ++i) {
2741 if ("undefined" == typeof n[a[i]]) {
2742 n = undefined;
2743 break
2744 }
2745 n = n[a[i]]
2746 }
2747 }
2748 return n
2749 }
2750 }, {
2751 key: "setValue", value: function (e, r) {
2752 var n = t.parseStoryVariable(e);
2753 if (null !== n) {
2754 for (var a = n.names, i = a.pop(), o = n.store, s = 0, u = a.length; s < u; ++s) {
2755 if ("undefined" == typeof o[a[s]]) {
2756 o = undefined;
2757 break
2758 }
2759 o = o[a[s]]
2760 }
2761 if (o !== undefined) return o[i] = r, !0
2762 }
2763 return !1
2764 }
2765 }, {
2766 key: "parseStoryVariable", value: function (e) {
2767 for (var r = {
2768 store: "$" === e[0] ? State.variables : State.temporary,
2769 names: []
2770 }, n = e, a = void 0; null !== (a = t._parseVarRegExp.exec(n));) n = n.slice(a[0].length), a[1] ? r.names.push(a[1]) : a[2] ? r.names.push(a[2]) : a[3] ? r.names.push(a[3]) : a[4] ? r.names.push(a[4]) : a[5] ? r.names.push(t.getValue(a[5])) : a[6] && r.names.push(Number(a[6]));
2771 return "" === n ? r : null
2772 }
2773 }, {
2774 key: "wikifyEval", value: function (e) {
2775 var r = document.createDocumentFragment();
2776 new t(r, e);
2777 var n = r.querySelector(".error");
2778 if (null !== n) throw new Error(n.textContent.replace(/^(?:(?:Uncaught\s+)?Error:\s+)+/, ""));
2779 return r
2780 }
2781 }, {
2782 key: "createInternalLink", value: function (e, t, r, n) {
2783 var a = jQuery(document.createElement("a"));
2784 return null != t && (a.attr("data-passage", t), Story.has(t) ? (a.addClass("link-internal"), Config.addVisitedLinkClass && State.hasPlayed(t) && a.addClass("link-visited")) : a.addClass("link-broken"), a.ariaClick({one: !0}, function () {
2785 "function" == typeof n && n(), Engine.play(t)
2786 })), r && a.append(document.createTextNode(r)), e && a.appendTo(e), a[0]
2787 }
2788 }, {
2789 key: "createExternalLink", value: function (e, t, r) {
2790 var n = jQuery(document.createElement("a")).attr("target", "_blank").addClass("link-external").text(r).appendTo(e);
2791 return null != t && n.attr({href: t, tabindex: 0}), n[0]
2792 }
2793 }, {
2794 key: "isExternalLink", value: function (e) {
2795 if (Story.has(e)) return !1;
2796 var t = new RegExp("^" + Patterns.url, "gim");
2797 return t.test(e) || /[\/.?#]/.test(e)
2798 }
2799 }]), t
2800 }();
2801 return Object.defineProperty(t, "Parser", {
2802 value: function () {
2803 function e() {
2804 return d
2805 }
2806
2807 function t(e) {
2808 if ("object" !== ("undefined" == typeof e ? "undefined" : _typeof(e))) throw new Error("Wikifier.Parser.add parser parameter must be an object");
2809 if (!e.hasOwnProperty("name")) throw new Error('parser object missing required "name" property');
2810 if ("string" != typeof e.name) throw new Error('parser object "name" property must be a string');
2811 if (!e.hasOwnProperty("match")) throw new Error('parser object missing required "match" property');
2812 if ("string" != typeof e.match) throw new Error('parser object "match" property must be a string');
2813 if (!e.hasOwnProperty("handler")) throw new Error('parser object missing required "handler" property');
2814 if ("function" != typeof e.handler) throw new Error('parser object "handler" property must be a function');
2815 if (e.hasOwnProperty("profiles") && !Array.isArray(e.profiles)) throw new Error('parser object "profiles" property must be an array');
2816 if (a(e.name)) throw new Error('cannot clobber existing parser "' + e.name + '"');
2817 d.push(e)
2818 }
2819
2820 function r(e) {
2821 var t = d.find(function (t) {
2822 return t.name === e
2823 });
2824 t && d.delete(t)
2825 }
2826
2827 function n() {
2828 return 0 === d.length
2829 }
2830
2831 function a(e) {
2832 return !!d.find(function (t) {
2833 return t.name === e
2834 })
2835 }
2836
2837 function i(e) {
2838 return d.find(function (t) {
2839 return t.name === e
2840 }) || null
2841 }
2842
2843 function o() {
2844 return f
2845 }
2846
2847 function s() {
2848 var e = d, t = e.filter(function (e) {
2849 return !Array.isArray(e.profiles) || e.profiles.includes("core")
2850 });
2851 return f = Object.freeze({
2852 all: {
2853 parsers: e, parserRegExp: new RegExp(e.map(function (e) {
2854 return "(" + e.match + ")"
2855 }).join("|"), "gm")
2856 }, core: {
2857 parsers: t, parserRegExp: new RegExp(t.map(function (e) {
2858 return "(" + e.match + ")"
2859 }).join("|"), "gm")
2860 }
2861 })
2862 }
2863
2864 function u() {
2865 return "object" !== ("undefined" == typeof f ? "undefined" : _typeof(f)) || 0 === Object.keys(f).length
2866 }
2867
2868 function l(e) {
2869 if ("object" !== ("undefined" == typeof f ? "undefined" : _typeof(f)) || !f.hasOwnProperty(e)) throw new Error('nonexistent parser profile "' + e + '"');
2870 return f[e]
2871 }
2872
2873 function c(e) {
2874 return "object" === ("undefined" == typeof f ? "undefined" : _typeof(f)) && f.hasOwnProperty(e)
2875 }
2876
2877 var d = [], f = void 0;
2878 return Object.freeze(Object.defineProperties({}, {
2879 parsers: {get: e},
2880 add: {value: t},
2881 delete: {value: r},
2882 isEmpty: {value: n},
2883 has: {value: a},
2884 get: {value: i},
2885 Profile: {
2886 value: Object.freeze(Object.defineProperties({}, {
2887 profiles: {get: o},
2888 compile: {value: s},
2889 isEmpty: {value: u},
2890 has: {value: c},
2891 get: {value: l}
2892 }))
2893 }
2894 }))
2895 }()
2896 }), Object.defineProperties(t, {
2897 _parseVarRegExp: {value: new RegExp("^(?:" + Patterns.variableSigil + "(" + Patterns.identifier + ")|\\.(" + Patterns.identifier + ")|\\[(?:(?:\"((?:\\\\.|[^\"\\\\])+)\")|(?:'((?:\\\\.|[^'\\\\])+)')|(" + Patterns.variableSigil + Patterns.identifierFirstChar + ".*)|(\\d+))\\])")},
2898 helpers: {value: {}},
2899 parse: {value: Scripting.parse},
2900 evalExpression: {value: Scripting.evalTwineScript},
2901 evalStatements: {value: Scripting.evalTwineScript},
2902 textPrimitives: {value: Patterns}
2903 }), Object.defineProperties(t.helpers, {
2904 inlineCss: {
2905 value: function () {
2906 function e(e) {
2907 var r = {classes: [], id: "", styles: {}}, n = void 0;
2908 do {
2909 t.lastIndex = e.nextMatch;
2910 var a = t.exec(e.source);
2911 n = a && a.index === e.nextMatch, n && (a[1] ? r.styles[Util.fromCssProperty(a[1])] = a[2].trim() : a[3] ? r.styles[Util.fromCssProperty(a[3])] = a[4].trim() : a[5] ? r.classes = r.classes.concat(a[5].slice(1).split(/\./)) : a[6] && (r.id = a[6].slice(1).split(/#/).pop()), e.nextMatch = t.lastIndex)
2912 } while (n);
2913 return r
2914 }
2915
2916 var t = new RegExp(Patterns.inlineCss, "gm");
2917 return e
2918 }()
2919 }, evalText: {
2920 value: function (e) {
2921 var t = void 0;
2922 try {
2923 t = Scripting.evalTwineScript(e), null == t || "function" == typeof t ? t = e : (t = String(t), /\[(?:object(?:\s+[^\]]+)?|native\s+code)\]/.test(t) && (t = e))
2924 } catch (r) {
2925 t = e
2926 }
2927 return t
2928 }
2929 }, evalPassageId: {
2930 value: function (e) {
2931 return null == e || Story.has(e) ? e : t.helpers.evalText(e)
2932 }
2933 }, hasBlockContext: {
2934 value: function (e) {
2935 for (var t = "function" == typeof window.getComputedStyle, r = e.length - 1; r >= 0; --r) {
2936 var n = e[r];
2937 switch (n.nodeType) {
2938 case Node.ELEMENT_NODE:
2939 var a = n.nodeName.toUpperCase();
2940 if ("BR" === a) return !0;
2941 var i = t ? window.getComputedStyle(n, null) : n.currentStyle;
2942 if (i && i.display) {
2943 if ("none" === i.display) continue;
2944 return "block" === i.display
2945 }
2946 switch (a) {
2947 case"ADDRESS":
2948 case"ARTICLE":
2949 case"ASIDE":
2950 case"BLOCKQUOTE":
2951 case"CENTER":
2952 case"DIV":
2953 case"DL":
2954 case"FIGURE":
2955 case"FOOTER":
2956 case"FORM":
2957 case"H1":
2958 case"H2":
2959 case"H3":
2960 case"H4":
2961 case"H5":
2962 case"H6":
2963 case"HEADER":
2964 case"HR":
2965 case"MAIN":
2966 case"NAV":
2967 case"OL":
2968 case"P":
2969 case"PRE":
2970 case"SECTION":
2971 case"TABLE":
2972 case"UL":
2973 return !0
2974 }
2975 return !1;
2976 case Node.COMMENT_NODE:
2977 continue;
2978 default:
2979 return !1
2980 }
2981 }
2982 return !0
2983 }
2984 }, createShadowSetterCallback: {
2985 value: function () {
2986 function e() {
2987 if (!a && (a = t.Parser.get("macro"), !a)) throw new Error('cannot find "macro" parser');
2988 return a
2989 }
2990
2991 function r() {
2992 for (var t = a || e(), r = new Set, n = t.context; null !== n; n = n.parent) n._shadows && n._shadows.forEach(function (e) {
2993 return r.add(e)
2994 });
2995 return [].concat(_toConsumableArray(r))
2996 }
2997
2998 function n(e) {
2999 var t = {};
3000 return r().forEach(function (e) {
3001 var r = e.slice(1), n = "$" === e[0] ? State.variables : State.temporary;
3002 t[e] = n[r]
3003 }), function () {
3004 var r = Object.keys(t), n = r.length > 0 ? {} : null;
3005 try {
3006 return r.forEach(function (e) {
3007 var r = e.slice(1), a = "$" === e[0] ? State.variables : State.temporary;
3008 a.hasOwnProperty(r) && (n[r] = a[r]), a[r] = t[e]
3009 }), Scripting.evalJavaScript(e)
3010 } finally {
3011 r.forEach(function (e) {
3012 var r = e.slice(1), a = "$" === e[0] ? State.variables : State.temporary;
3013 t[e] = a[r], n.hasOwnProperty(r) ? a[r] = n[r] : delete a[r]
3014 })
3015 }
3016 }
3017 }
3018
3019 var a = null;
3020 return n
3021 }()
3022 }, parseSquareBracketedMarkup: {
3023 value: function (e) {
3024 function t() {
3025 return d >= e.source.length ? u : e.source[d++]
3026 }
3027
3028 function r() {
3029 return d >= e.source.length ? u : e.source[d]
3030 }
3031
3032 function n(t) {
3033 return t < 1 || d + t >= e.source.length ? u : e.source[d + t]
3034 }
3035
3036 function a() {
3037 return {error: String.format.apply(String, arguments), pos: d}
3038 }
3039
3040 function i() {
3041 c = d
3042 }
3043
3044 function o(t) {
3045 var r = e.source.slice(c, d).trim();
3046 if ("" === r) throw new Error("malformed wiki " + (h ? "link" : "image") + ", empty " + t + " component");
3047 "link" === t && "~" === r[0] ? (l.forceInternal = !0, l.link = r.slice(1)) : l[t] = r, c = d
3048 }
3049
3050 function s(e) {
3051 ++d;
3052 e:for (; ;) {
3053 switch (r()) {
3054 case"\\":
3055 ++d;
3056 var t = r();
3057 if (t !== u && "\n" !== t) break;
3058 case u:
3059 case"\n":
3060 return u;
3061 case e:
3062 break e
3063 }
3064 ++d
3065 }
3066 return d
3067 }
3068
3069 var u = -1, l = {}, c = e.matchStart, d = c + 1, f = void 0, p = void 0, h = void 0, g = void 0;
3070 if (g = r(), "[" === g) h = l.isLink = !0; else {
3071 switch (h = !1, g) {
3072 case"<":
3073 l.align = "left", ++d;
3074 break;
3075 case">":
3076 l.align = "right", ++d
3077 }
3078 if (!/^[Ii][Mm][Gg]$/.test(e.source.slice(d, d + 3))) return a("malformed square-bracketed wiki markup");
3079 d += 3, l.isImage = !0
3080 }
3081 if ("[" !== t()) return a("malformed wiki {0}", h ? "link" : "image");
3082 f = 1, p = 0, i();
3083 try {
3084 e:for (; ;) {
3085 switch (g = r()) {
3086 case u:
3087 case"\n":
3088 return a("unterminated wiki {0}", h ? "link" : "image");
3089 case'"':
3090 if (s(g) === u) return a("unterminated double quoted string in wiki {0}", h ? "link" : "image");
3091 break;
3092 case"'":
3093 if ((4 === p || 3 === p && h) && s(g) === u) return a("unterminated single quoted string in wiki {0}", h ? "link" : "image");
3094 break;
3095 case"|":
3096 0 === p && (o(h ? "text" : "title"), ++c, p = 1);
3097 break;
3098 case"-":
3099 0 === p && ">" === n(1) && (o(h ? "text" : "title"), ++d, c += 2, p = 1);
3100 break;
3101 case"<":
3102 0 === p && "-" === n(1) && (o(h ? "link" : "source"), ++d, c += 2, p = 2);
3103 break;
3104 case"[":
3105 if (p === -1) return a("unexpected left square bracket '['");
3106 ++f, 1 === f && (i(), ++c);
3107 break;
3108 case"]":
3109 if (--f, 0 === f) {
3110 switch (p) {
3111 case 0:
3112 case 1:
3113 o(h ? "link" : "source"), p = 3;
3114 break;
3115 case 2:
3116 o(h ? "text" : "title"), p = 3;
3117 break;
3118 case 3:
3119 h ? (o("setter"), p = -1) : (o("link"), p = 4);
3120 break;
3121 case 4:
3122 o("setter"), p = -1
3123 }
3124 if (++d, "]" === r()) {
3125 ++d;
3126 break e
3127 }
3128 --d
3129 }
3130 }
3131 ++d
3132 }
3133 } catch (e) {
3134 return a(e.message)
3135 }
3136 return l.pos = d, l
3137 }
3138 }
3139 }), t
3140 }();
3141 !function () {
3142 Wikifier.Parser.add({
3143 name: "quoteByBlock",
3144 profiles: ["block"],
3145 match: "^<<<\\n",
3146 terminator: "^<<<\\n",
3147 handler: function (e) {
3148 return Wikifier.helpers.hasBlockContext(e.output.childNodes) ? void e.subWikify(jQuery(document.createElement("blockquote")).appendTo(e.output).get(0), this.terminator) : void jQuery(e.output).append(document.createTextNode(e.matchText))
3149 }
3150 }), Wikifier.Parser.add({
3151 name: "quoteByLine",
3152 profiles: ["block"],
3153 match: "^>+",
3154 lookahead: /^>+/gm,
3155 terminator: "\\n",
3156 handler: function (e) {
3157 if (!Wikifier.helpers.hasBlockContext(e.output.childNodes)) return void jQuery(e.output).append(document.createTextNode(e.matchText));
3158 var t = [e.output], r = 0, n = e.matchLength, a = void 0, i = void 0;
3159 do {
3160 if (n > r) for (i = r; i < n; ++i) t.push(jQuery(document.createElement("blockquote")).appendTo(t[t.length - 1]).get(0)); else if (n < r) for (i = r; i > n; --i) t.pop();
3161 r = n, e.subWikify(t[t.length - 1], this.terminator), jQuery(document.createElement("br")).appendTo(t[t.length - 1]), this.lookahead.lastIndex = e.nextMatch;
3162 var o = this.lookahead.exec(e.source);
3163 a = o && o.index === e.nextMatch, a && (n = o[0].length, e.nextMatch += o[0].length)
3164 } while (a)
3165 }
3166 }), Wikifier.Parser.add({
3167 name: "macro",
3168 profiles: ["core"],
3169 match: "<<",
3170 lookahead: new RegExp("<<(/?" + Patterns.macroName + ")(?:\\s*)((?:(?:\"(?:\\\\.|[^\"\\\\])*\")|(?:'(?:\\\\.|[^'\\\\])*')|(?:\\[(?:[<>]?[Ii][Mm][Gg])?\\[[^\\r\\n]*?\\]\\]+)|[^>]|(?:>(?!>)))*)>>", "gm"),
3171 argsPattern: ["(``)", "`((?:\\\\.|[^`\\\\])+)`", "(\"\"|'')", '("(?:\\\\.|[^"\\\\])+")', "('(?:\\\\.|[^'\\\\])+')", "(\\[(?:[<>]?[Ii][Mm][Gg])?\\[[^\\r\\n]*?\\]\\]+)", "([^`\"'\\s]+)", "(`|\"|')"].join("|"),
3172 working: {source: "", name: "", arguments: "", index: 0},
3173 context: null,
3174 handler: function (e) {
3175 var t = this.lookahead.lastIndex = e.matchStart;
3176 if (this.parseTag(e)) {
3177 var r = e.nextMatch, n = this.working.source, a = this.working.name, i = this.working.arguments,
3178 o = void 0;
3179 try {
3180 if (o = Macro.get(a), !o) {
3181 if (Macro.tags.has(a)) {
3182 var s = Macro.tags.get(a);
3183 return throwError(e.output, "child tag <<" + a + ">> was found outside of a call to its parent macro" + (1 === s.length ? "" : "s") + " <<" + s.join(">>, <<") + ">>", e.source.slice(t, e.nextMatch))
3184 }
3185 return throwError(e.output, "macro <<" + a + ">> does not exist", e.source.slice(t, e.nextMatch))
3186 }
3187 var u = null;
3188 if (o.hasOwnProperty("tags") && (u = this.parseBody(e, o), !u)) return e.nextMatch = r, throwError(e.output, "cannot find a closing tag for macro <<" + a + ">>", e.source.slice(t, e.nextMatch) + "…");
3189 if ("function" != typeof o.handler) return throwError(e.output, "macro <<" + a + ">> handler function " + (o.hasOwnProperty("handler") ? "is not a function" : "does not exist"), e.source.slice(t, e.nextMatch));
3190 var l = u ? u[0].args : this.createArgs(i, o.hasOwnProperty("skipArgs") && !!o.skipArgs || o.hasOwnProperty("skipArg0") && !!o.skipArg0);
3191 if (o.hasOwnProperty("_MACRO_API")) {
3192 this.context = new MacroContext({
3193 parent: this.context,
3194 macro: o,
3195 name: a,
3196 args: l,
3197 payload: u,
3198 parser: e,
3199 source: n
3200 });
3201 try {
3202 o.handler.call(this.context)
3203 } finally {
3204 this.context = this.context.parent
3205 }
3206 } else {
3207 var c = e._rawArgs;
3208 e._rawArgs = i;
3209 try {
3210 o.handler(e.output, a, l, e, u)
3211 } finally {
3212 e._rawArgs = c
3213 }
3214 }
3215 } catch (r) {
3216 return throwError(e.output, "cannot execute " + (o && o.isWidget ? "widget" : "macro") + " <<" + a + ">>: " + r.message, e.source.slice(t, e.nextMatch))
3217 } finally {
3218 this.working.source = "", this.working.name = "", this.working.arguments = "", this.working.index = 0
3219 }
3220 } else e.outputText(e.output, e.matchStart, e.nextMatch)
3221 },
3222 parseTag: function (e) {
3223 var t = this.lookahead.exec(e.source);
3224 return !(!t || t.index !== e.matchStart || !t[1]) && (e.nextMatch = this.lookahead.lastIndex, this.working.source = e.source.slice(t.index, this.lookahead.lastIndex), this.working.name = t[1], this.working.arguments = t[2], this.working.index = t.index, !0)
3225 },
3226 parseBody: function (e, t) {
3227 for (var r = this.working.name, n = "/" + r, a = "end" + r, i = !!Array.isArray(t.tags) && t.tags, o = [], s = t.hasOwnProperty("skipArgs") && t.skipArgs, u = t.hasOwnProperty("skipArg0") && t.skipArg0, l = -1, c = 1, d = this.working.source, f = this.working.name, p = this.working.arguments, h = e.nextMatch; (e.matchStart = e.source.indexOf(this.match, e.nextMatch)) !== -1;) if (this.parseTag(e)) {
3228 var g = this.working.source, m = this.working.name, y = this.working.arguments,
3229 v = this.working.index, b = e.nextMatch;
3230 switch (m) {
3231 case r:
3232 ++c;
3233 break;
3234 case a:
3235 case n:
3236 --c;
3237 break;
3238 default:
3239 if (1 === c && i) for (var w = 0, k = i.length; w < k; ++w) m === i[w] && (o.push({
3240 source: d,
3241 name: f,
3242 arguments: p,
3243 args: this.createArgs(p, s || 0 === o.length && u),
3244 contents: e.source.slice(h, v)
3245 }), d = g, f = m, p = y, h = b)
3246 }
3247 if (0 === c) {
3248 o.push({
3249 source: d,
3250 name: f,
3251 arguments: p,
3252 args: this.createArgs(p, s || 0 === o.length && u),
3253 contents: e.source.slice(h, v)
3254 }), l = b;
3255 break
3256 }
3257 } else this.lookahead.lastIndex = e.nextMatch = e.matchStart + this.match.length;
3258 return l !== -1 ? (e.nextMatch = l, o) : null
3259 },
3260 createArgs: function (e, t) {
3261 var r = t ? [] : this.parseArgs(e);
3262 return Object.defineProperties(r, {raw: {value: e}, full: {value: Scripting.parse(e)}}), r
3263 },
3264 parseArgs: function (e) {
3265 for (var t = new RegExp(this.argsPattern, "gm"), r = [], n = new RegExp("^" + Patterns.variable), a = void 0; null !== (a = t.exec(e));) {
3266 var i = void 0;
3267 if (a[1]) i = undefined; else if (a[2]) {
3268 i = a[2];
3269 try {
3270 i = Scripting.evalTwineScript(i)
3271 } catch (e) {
3272 throw new Error('unable to parse macro argument "' + i + '": ' + e.message)
3273 }
3274 } else if (a[3]) i = ""; else if (a[4]) {
3275 i = a[4];
3276 try {
3277 i = Scripting.evalJavaScript(i)
3278 } catch (e) {
3279 throw new Error("unable to parse macro argument '" + i + "': " + e.message)
3280 }
3281 } else if (a[5]) {
3282 i = a[5];
3283 try {
3284 i = Scripting.evalJavaScript(i)
3285 } catch (e) {
3286 throw new Error('unable to parse macro argument "' + i + '": ' + e.message)
3287 }
3288 } else if (a[6]) {
3289 i = a[6];
3290 var o = Wikifier.helpers.parseSquareBracketedMarkup({source: i, matchStart: 0});
3291 if (o.hasOwnProperty("error")) throw new Error('unable to parse macro argument "' + i + '": ' + o.error);
3292 if (o.pos < i.length) throw new Error('unable to parse macro argument "' + i + '": unexpected character(s) "' + i.slice(o.pos) + '" (pos: ' + o.pos + ")");
3293 o.isLink ? (i = {isLink: !0}, i.count = o.hasOwnProperty("text") ? 2 : 1, i.link = Wikifier.helpers.evalPassageId(o.link), i.text = o.hasOwnProperty("text") ? Wikifier.helpers.evalText(o.text) : i.link, i.external = !o.forceInternal && Wikifier.isExternalLink(i.link), i.setFn = o.hasOwnProperty("setter") ? Wikifier.helpers.createShadowSetterCallback(Scripting.parse(o.setter)) : null) : o.isImage && (i = function (e) {
3294 var t = {source: e, isImage: !0};
3295 if ("data:" !== e.slice(0, 5) && Story.has(e)) {
3296 var r = Story.get(e);
3297 r.tags.includes("Twine.image") && (t.source = r.text, t.passage = r.title)
3298 }
3299 return t
3300 }(Wikifier.helpers.evalPassageId(o.source)), o.hasOwnProperty("align") && (i.align = o.align), o.hasOwnProperty("title") && (i.title = Wikifier.helpers.evalText(o.title)), o.hasOwnProperty("link") && (i.link = Wikifier.helpers.evalPassageId(o.link), i.external = !o.forceInternal && Wikifier.isExternalLink(i.link)), i.setFn = o.hasOwnProperty("setter") ? Wikifier.helpers.createShadowSetterCallback(Scripting.parse(o.setter)) : null)
3301 } else if (a[7]) if (i = a[7], n.test(i)) i = Wikifier.getValue(i); else if (/^(?:settings|setup)[.[]/.test(i)) try {
3302 i = Scripting.evalTwineScript(i)
3303 } catch (e) {
3304 throw new Error('unable to parse macro argument "' + i + '": ' + e.message)
3305 } else if ("null" === i) i = null; else if ("undefined" === i) i = undefined; else if ("true" === i) i = !0; else if ("false" === i) i = !1; else {
3306 var s = Number(i);
3307 Number.isNaN(s) || (i = s)
3308 } else if (a[8]) {
3309 var u = void 0;
3310 switch (a[8]) {
3311 case"`":
3312 u = "backquote expression";
3313 break;
3314 case'"':
3315 u = "double quoted string";
3316 break;
3317 case"'":
3318 u = "single quoted string"
3319 }
3320 throw new Error("unterminated " + u + " in macro argument string")
3321 }
3322 r.push(i)
3323 }
3324 return r
3325 }
3326 }), Wikifier.Parser.add({
3327 name: "prettyLink",
3328 profiles: ["core"],
3329 match: "\\[\\[[^[]",
3330 handler: function (e) {
3331 var t = Wikifier.helpers.parseSquareBracketedMarkup(e);
3332 if (t.hasOwnProperty("error")) return void e.outputText(e.output, e.matchStart, e.nextMatch);
3333 e.nextMatch = t.pos;
3334 var r = Wikifier.helpers.evalPassageId(t.link),
3335 n = t.hasOwnProperty("text") ? Wikifier.helpers.evalText(t.text) : r,
3336 a = t.hasOwnProperty("setter") ? Wikifier.helpers.createShadowSetterCallback(Scripting.parse(t.setter)) : null,
3337 i = (Config.debug ? new DebugView(e.output, "wiki-link", "[[link]]", e.source.slice(e.matchStart, e.nextMatch)) : e).output;
3338 t.forceInternal || !Wikifier.isExternalLink(r) ? Wikifier.createInternalLink(i, r, n, a) : Wikifier.createExternalLink(i, r, n)
3339 }
3340 }), Wikifier.Parser.add({
3341 name: "urlLink", profiles: ["core"], match: Patterns.url, handler: function (e) {
3342 e.outputText(Wikifier.createExternalLink(e.output, e.matchText), e.matchStart, e.nextMatch)
3343 }
3344 }), Wikifier.Parser.add({
3345 name: "image", profiles: ["core"], match: "\\[[<>]?[Ii][Mm][Gg]\\[", handler: function (e) {
3346 var t = Wikifier.helpers.parseSquareBracketedMarkup(e);
3347 if (t.hasOwnProperty("error")) return void e.outputText(e.output, e.matchStart, e.nextMatch);
3348 e.nextMatch = t.pos;
3349 var r = void 0;
3350 Config.debug && (r = new DebugView(e.output, "wiki-image", t.hasOwnProperty("link") ? "[img[][link]]" : "[img[]]", e.source.slice(e.matchStart, e.nextMatch)), r.modes({block: !0}));
3351 var n = t.hasOwnProperty("setter") ? Wikifier.helpers.createShadowSetterCallback(Scripting.parse(t.setter)) : null,
3352 a = (Config.debug ? r : e).output, i = void 0;
3353 if (t.hasOwnProperty("link")) {
3354 var o = Wikifier.helpers.evalPassageId(t.link);
3355 a = t.forceInternal || !Wikifier.isExternalLink(o) ? Wikifier.createInternalLink(a, o, null, n) : Wikifier.createExternalLink(a, o), a.classList.add("link-image")
3356 }
3357 if (a = jQuery(document.createElement("img")).appendTo(a).get(0), i = Wikifier.helpers.evalPassageId(t.source), "data:" !== i.slice(0, 5) && Story.has(i)) {
3358 var s = Story.get(i);
3359 s.tags.includes("Twine.image") && (a.setAttribute("data-passage", s.title), i = s.text)
3360 }
3361 a.src = i, t.hasOwnProperty("title") && (a.title = Wikifier.helpers.evalText(t.title)), t.hasOwnProperty("align") && (a.align = t.align)
3362 }
3363 }), Wikifier.Parser.add({
3364 name: "monospacedByBlock",
3365 profiles: ["block"],
3366 match: "^\\{\\{\\{\\n",
3367 lookahead: /^\{\{\{\n((?:^[^\n]*\n)+?)(^\}\}\}$\n?)/gm,
3368 handler: function (e) {
3369 this.lookahead.lastIndex = e.matchStart;
3370 var t = this.lookahead.exec(e.source);
3371 if (t && t.index === e.matchStart) {
3372 var r = jQuery(document.createElement("pre"));
3373 jQuery(document.createElement("code")).text(t[1]).appendTo(r), r.appendTo(e.output), e.nextMatch = this.lookahead.lastIndex
3374 }
3375 }
3376 }), Wikifier.Parser.add({
3377 name: "formatByChar",
3378 profiles: ["core"],
3379 match: "''|//|__|\\^\\^|~~|==|\\{\\{\\{",
3380 handler: function (e) {
3381 switch (e.matchText) {
3382 case"''":
3383 e.subWikify(jQuery(document.createElement("strong")).appendTo(e.output).get(0), "''");
3384 break;
3385 case"//":
3386 e.subWikify(jQuery(document.createElement("em")).appendTo(e.output).get(0), "//");
3387 break;
3388 case"__":
3389 e.subWikify(jQuery(document.createElement("u")).appendTo(e.output).get(0), "__");
3390 break;
3391 case"^^":
3392 e.subWikify(jQuery(document.createElement("sup")).appendTo(e.output).get(0), "\\^\\^");
3393 break;
3394 case"~~":
3395 e.subWikify(jQuery(document.createElement("sub")).appendTo(e.output).get(0), "~~");
3396 break;
3397 case"==":
3398 e.subWikify(jQuery(document.createElement("s")).appendTo(e.output).get(0), "==");
3399 break;
3400 case"{{{":
3401 var t = /\{\{\{((?:.|\n)*?)\}\}\}/gm;
3402 t.lastIndex = e.matchStart;
3403 var r = t.exec(e.source);
3404 r && r.index === e.matchStart && (jQuery(document.createElement("code")).text(r[1]).appendTo(e.output), e.nextMatch = t.lastIndex)
3405 }
3406 }
3407 }), Wikifier.Parser.add({
3408 name: "customStyle",
3409 profiles: ["core"],
3410 match: "@@",
3411 terminator: "@@",
3412 blockRegExp: /\s*\n/gm,
3413 handler: function (e) {
3414 var t = Wikifier.helpers.inlineCss(e);
3415 this.blockRegExp.lastIndex = e.nextMatch;
3416 var r = this.blockRegExp.exec(e.source), n = r && r.index === e.nextMatch,
3417 a = jQuery(document.createElement(n ? "div" : "span")).appendTo(e.output);
3418 0 === t.classes.length && "" === t.id && 0 === Object.keys(t.styles).length ? a.addClass("marked") : (t.classes.forEach(function (e) {
3419 return a.addClass(e)
3420 }), "" !== t.id && a.attr("id", t.id), a.css(t.styles)), n ? (e.nextMatch += r[0].length, e.subWikify(a[0], "\\n?" + this.terminator)) : e.subWikify(a[0], this.terminator)
3421 }
3422 }), Wikifier.Parser.add({
3423 name: "verbatimText",
3424 profiles: ["core"],
3425 match: '"{3}|<[Nn][Oo][Ww][Ii][Kk][Ii]>',
3426 lookahead: /(?:"{3}((?:.|\n)*?)"{3})|(?:<[Nn][Oo][Ww][Ii][Kk][Ii]>((?:.|\n)*?)<\/[Nn][Oo][Ww][Ii][Kk][Ii]>)/gm,
3427 handler: function (e) {
3428 this.lookahead.lastIndex = e.matchStart;
3429 var t = this.lookahead.exec(e.source);
3430 t && t.index === e.matchStart && (e.nextMatch = this.lookahead.lastIndex, jQuery(document.createElement("span")).addClass("verbatim").text(t[1] || t[2]).appendTo(e.output))
3431 }
3432 }), Wikifier.Parser.add({
3433 name: "horizontalRule",
3434 profiles: ["core"],
3435 match: "^----+$\\n?|<[Hh][Rr]\\s*/?>\\n?",
3436 handler: function (e) {
3437 jQuery(document.createElement("hr")).appendTo(e.output)
3438 }
3439 }), Wikifier.Parser.add({
3440 name: "emdash", profiles: ["core"], match: "--", handler: function (e) {
3441 jQuery(document.createTextNode("—")).appendTo(e.output)
3442 }
3443 }), Wikifier.Parser.add({
3444 name: "doubleDollarSign",
3445 profiles: ["core"],
3446 match: "\\${2}",
3447 handler: function (e) {
3448 jQuery(document.createTextNode("$")).appendTo(e.output)
3449 }
3450 }), Wikifier.Parser.add({
3451 name: "nakedVariable",
3452 profiles: ["core"],
3453 match: Patterns.variable + "(?:(?:\\." + Patterns.identifier + ")|(?:\\[\\d+\\])|(?:\\[\"(?:\\\\.|[^\"\\\\])+\"\\])|(?:\\['(?:\\\\.|[^'\\\\])+'\\])|(?:\\[" + Patterns.variable + "\\]))*",
3454 handler: function (e) {
3455 var t = toStringOrDefault(Wikifier.getValue(e.matchText), null);
3456 null === t ? jQuery(document.createTextNode(e.matchText)).appendTo(e.output) : new Wikifier((Config.debug ? new DebugView(e.output, "variable", e.matchText, e.matchText) : e).output, t)
3457 }
3458 }), Wikifier.Parser.add({
3459 name: "heading", profiles: ["block"], match: "^!{1,6}", terminator: "\\n", handler: function (e) {
3460 return Wikifier.helpers.hasBlockContext(e.output.childNodes) ? void e.subWikify(jQuery(document.createElement("h" + e.matchLength)).appendTo(e.output).get(0), this.terminator) : void jQuery(e.output).append(document.createTextNode(e.matchText))
3461 }
3462 }), Wikifier.Parser.add({
3463 name: "table",
3464 profiles: ["block"],
3465 match: "^\\|(?:[^\\n]*)\\|(?:[fhck]?)$",
3466 lookahead: /^\|([^\n]*)\|([fhck]?)$/gm,
3467 rowTerminator: "\\|(?:[cfhk]?)$\\n?",
3468 cellPattern: "(?:\\|([^\\n\\|]*)\\|)|(\\|[cfhk]?$\\n?)",
3469 cellTerminator: "(?:\\u0020*)\\|",
3470 rowTypes: {c: "caption", f: "tfoot", h: "thead", "": "tbody"},
3471 handler: function (e) {
3472 if (!Wikifier.helpers.hasBlockContext(e.output.childNodes)) return void jQuery(e.output).append(document.createTextNode(e.matchText));
3473 var t = jQuery(document.createElement("table")).appendTo(e.output).get(0), r = [], n = null,
3474 a = null, i = 0, o = void 0;
3475 e.nextMatch = e.matchStart;
3476 do {
3477 this.lookahead.lastIndex = e.nextMatch;
3478 var s = this.lookahead.exec(e.source);
3479 if (o = s && s.index === e.nextMatch) {
3480 var u = s[2];
3481 "k" === u ? (t.className = s[1], e.nextMatch += s[0].length + 1) : (u !== n && (n = u, a = jQuery(document.createElement(this.rowTypes[u])).appendTo(t)), "c" === n ? (a.css("caption-side", 0 === i ? "top" : "bottom"), e.nextMatch += 1, e.subWikify(a[0], this.rowTerminator)) : this.rowHandler(e, jQuery(document.createElement("tr")).appendTo(a).get(0), r), ++i)
3482 }
3483 } while (o)
3484 },
3485 rowHandler: function (e, t, r) {
3486 var n = this, a = new RegExp(this.cellPattern, "gm"), i = 0, o = 1, s = void 0;
3487 do {
3488 a.lastIndex = e.nextMatch;
3489 var u = a.exec(e.source);
3490 if (s = u && u.index === e.nextMatch) {
3491 if ("~" === u[1]) {
3492 var l = r[i];
3493 l && (++l.rowCount, l.$element.attr("rowspan", l.rowCount).css("vertical-align", "middle")), e.nextMatch = u.index + u[0].length - 1
3494 } else if (">" === u[1]) ++o, e.nextMatch = u.index + u[0].length - 1; else {
3495 if (u[2]) {
3496 e.nextMatch = u.index + u[0].length;
3497 break
3498 }
3499 !function () {
3500 ++e.nextMatch;
3501 for (var a = Wikifier.helpers.inlineCss(e), s = !1, u = !1, l = void 0; " " === e.source.substr(e.nextMatch, 1);) s = !0, ++e.nextMatch;
3502 "!" === e.source.substr(e.nextMatch, 1) ? (l = jQuery(document.createElement("th")).appendTo(t), ++e.nextMatch) : l = jQuery(document.createElement("td")).appendTo(t), r[i] = {
3503 rowCount: 1,
3504 $element: l
3505 }, o > 1 && (l.attr("colspan", o), o = 1), e.subWikify(l[0], n.cellTerminator), " " === e.matchText.substr(e.matchText.length - 2, 1) && (u = !0), a.classes.forEach(function (e) {
3506 return l.addClass(e)
3507 }), "" !== a.id && l.attr("id", a.id), s && u ? a.styles["text-align"] = "center" : s ? a.styles["text-align"] = "right" : u && (a.styles["text-align"] = "left"), l.css(a.styles), e.nextMatch = e.nextMatch - 1
3508 }()
3509 }
3510 ++i
3511 }
3512 } while (s)
3513 }
3514 }), Wikifier.Parser.add({
3515 name: "list",
3516 profiles: ["block"],
3517 match: "^(?:(?:\\*+)|(?:#+))",
3518 lookahead: /^(?:(\*+)|(#+))/gm,
3519 terminator: "\\n",
3520 handler: function (e) {
3521 if (!Wikifier.helpers.hasBlockContext(e.output.childNodes)) return void jQuery(e.output).append(document.createTextNode(e.matchText));
3522 e.nextMatch = e.matchStart;
3523 var t = [e.output], r = null, n = 0, a = void 0, i = void 0;
3524 do {
3525 this.lookahead.lastIndex = e.nextMatch;
3526 var o = this.lookahead.exec(e.source);
3527 if (a = o && o.index === e.nextMatch) {
3528 var s = o[2] ? "ol" : "ul", u = o[0].length;
3529 if (e.nextMatch += o[0].length, u > n) for (i = n; i < u; ++i) t.push(jQuery(document.createElement(s)).appendTo(t[t.length - 1]).get(0)); else if (u < n) for (i = n; i > u; --i) t.pop(); else u === n && s !== r && (t.pop(), t.push(jQuery(document.createElement(s)).appendTo(t[t.length - 1]).get(0)));
3530 n = u, r = s, e.subWikify(jQuery(document.createElement("li")).appendTo(t[t.length - 1]).get(0), this.terminator)
3531 }
3532 } while (a)
3533 }
3534 }), Wikifier.Parser.add({
3535 name: "verbatimHtml",
3536 profiles: ["core"],
3537 match: "<[Hh][Tt][Mm][Ll]>",
3538 lookahead: /<[Hh][Tt][Mm][Ll]>((?:.|\n)*?)<\/[Hh][Tt][Mm][Ll]>/gm,
3539 handler: function (e) {
3540 this.lookahead.lastIndex = e.matchStart;
3541 var t = this.lookahead.exec(e.source);
3542 t && t.index === e.matchStart && (e.nextMatch = this.lookahead.lastIndex, jQuery(document.createDocumentFragment()).append(t[1]).appendTo(e.output))
3543 }
3544 }), Wikifier.Parser.add({
3545 name: "commentByBlock",
3546 profiles: ["core"],
3547 match: "(?:/(?:%|\\*))|(?:<!--)",
3548 lookahead: /(?:\/(%|\*)(?:(?:.|\n)*?)\1\/)|(?:<!--(?:(?:.|\n)*?)-->)/gm,
3549 handler: function (e) {
3550 this.lookahead.lastIndex = e.matchStart;
3551 var t = this.lookahead.exec(e.source);
3552 t && t.index === e.matchStart && (e.nextMatch = this.lookahead.lastIndex)
3553 }
3554 }), Wikifier.Parser.add({
3555 name: "lineContinuation",
3556 profiles: ["core"],
3557 match: "\\\\" + Patterns.spaceNoTerminator + "*(?:\\n|$)|(?:^|\\n)" + Patterns.spaceNoTerminator + "*\\\\",
3558 handler: function (e) {
3559 e.nextMatch = e.matchStart + e.matchLength
3560 }
3561 }), Wikifier.Parser.add({
3562 name: "lineBreak",
3563 profiles: ["core"],
3564 match: "\\n|<[Bb][Rr]\\s*/?>",
3565 handler: function (e) {
3566 e.options.nobr || jQuery(document.createElement("br")).appendTo(e.output)
3567 }
3568 }), Wikifier.Parser.add({
3569 name: "htmlCharacterReference",
3570 profiles: ["core"],
3571 match: "(?:(?:&#?[0-9A-Za-z]{2,8};|.)(?:&#?(?:x0*(?:3[0-6][0-9A-Fa-f]|1D[C-Fc-f][0-9A-Fa-f]|20[D-Fd-f][0-9A-Fa-f]|FE2[0-9A-Fa-f])|0*(?:76[89]|7[7-9][0-9]|8[0-7][0-9]|761[6-9]|76[2-7][0-9]|84[0-3][0-9]|844[0-7]|6505[6-9]|6506[0-9]|6507[0-1]));)+|&#?[0-9A-Za-z]{2,8};)",
3572 handler: function (e) {
3573 jQuery(document.createDocumentFragment()).append(e.matchText).appendTo(e.output)
3574 }
3575 }), Wikifier.Parser.add({
3576 name: "xmlProlog",
3577 profiles: ["core"],
3578 match: "<\\?[Xx][Mm][Ll][^>]*\\?>",
3579 handler: function (e) {
3580 e.nextMatch = e.matchStart + e.matchLength
3581 }
3582 }), Wikifier.Parser.add({
3583 name: "verbatimSvg",
3584 profiles: ["core"],
3585 match: "<[Ss][Vv][Gg][^>]*>",
3586 lookahead: /(<[Ss][Vv][Gg][^>]*>(?:.|\n)*?<\/[Ss][Vv][Gg]>)/gm,
3587 handler: function (e) {
3588 this.lookahead.lastIndex = e.matchStart;
3589 var t = this.lookahead.exec(e.source);
3590 t && t.index === e.matchStart && (e.nextMatch = this.lookahead.lastIndex, jQuery(document.createDocumentFragment()).append(t[1]).appendTo(e.output))
3591 }
3592 }), Wikifier.Parser.add({
3593 name: "htmlTag",
3594 profiles: ["core"],
3595 match: "<\\w+(?:\\s+[^\\u0000-\\u001F\\u007F-\\u009F\\s\"'>\\/=]+(?:\\s*=\\s*(?:\"[^\"]*?\"|'[^']*?'|[^\\s\"'=<>`]+))?)*\\s*\\/?>",
3596 tagPattern: "<(\\w+)",
3597 voidElements: ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "menuitem", "meta", "param", "source", "track", "wbr"],
3598 nobrElements: ["colgroup", "datalist", "dl", "figure", "ol", "optgroup", "select", "table", "tbody", "tfoot", "thead", "tr", "ul"],
3599 handler: function (e) {
3600 var t = new RegExp(this.tagPattern).exec(e.matchText), r = t && t[1], n = r && r.toLowerCase();
3601 if (n) {
3602 var a = this.voidElements.includes(n) || e.matchText.endsWith("/>"),
3603 i = this.nobrElements.includes(n), o = void 0, s = void 0;
3604 if (!a) {
3605 o = "<\\/" + n + "\\s*>";
3606 var u = new RegExp(o, "gim");
3607 u.lastIndex = e.matchStart, s = u.exec(e.source)
3608 }
3609 if (a || s) {
3610 var l = e.output, c = document.createElement(e.output.tagName), d = void 0;
3611 for (c.innerHTML = e.matchText; c.firstChild;) c = c.firstChild;
3612 try {
3613 this.processAttributeDirectives(c)
3614 } catch (t) {
3615 return throwError(e.output, "<" + n + ">: bad evaluation from attribute directive: " + t.message, e.matchText + "…")
3616 }
3617 c.hasAttribute("data-passage") && (this.processDataAttributes(c), Config.debug && (d = new DebugView(e.output, "html-" + n, n, e.matchText), d.modes({
3618 block: "img" === n,
3619 nonvoid: s
3620 }), l = d.output)), s && (e.subWikify(c, o, {
3621 ignoreTerminatorCase: !0,
3622 nobr: i
3623 }), d && jQuery(c).find(".debug.block").length > 0 && d.modes({block: !0})), l.appendChild(c)
3624 } else throwError(e.output, 'HTML tag "' + r + '" is not closed', e.matchText + "…")
3625 }
3626 },
3627 processAttributeDirectives: function (e) {
3628 for (var t = e.attributes, r = 0; r < t.length; ++r) {
3629 var n = t[r], a = n.name, i = n.value, o = "@" === a[0];
3630 if (o || a.startsWith("sc-eval:")) {
3631 var s = a.slice(o ? 1 : 8);
3632 e.setAttribute(s, Scripting.evalTwineScript(i)), e.removeAttribute(a)
3633 }
3634 }
3635 },
3636 processDataAttributes: function (e) {
3637 var t = e.getAttribute("data-passage");
3638 if (null != t) {
3639 var r = Wikifier.helpers.evalPassageId(t);
3640 r !== t && (t = r, e.setAttribute("data-passage", r)), "" !== t && ("IMG" === e.tagName.toUpperCase() ? "data:" !== t.slice(0, 5) && Story.has(t) && (t = Story.get(t), t.tags.includes("Twine.image") && (e.src = t.text.trim())) : !function () {
3641 var r = e.getAttribute("data-setter"), n = void 0;
3642 null != r && (r = String(r).trim(), "" !== r && (n = Wikifier.helpers.createShadowSetterCallback(Scripting.parse(r)))), Story.has(t) ? (e.classList.add("link-internal"), Config.addVisitedLinkClass && State.hasPlayed(t) && e.classList.add("link-visited")) : e.classList.add("link-broken"), jQuery(e).ariaClick({one: !0}, function () {
3643 "function" == typeof n && n.call(this), Engine.play(t)
3644 })
3645 }())
3646 }
3647 }
3648 })
3649 }();
3650 var Macro = function () {
3651 function e(t, r, a) {
3652 if (Array.isArray(t)) return void t.forEach(function (t) {
3653 return e(t, r, a)
3654 });
3655 if (!f.test(t)) throw new Error('invalid macro name "' + t + '"');
3656 if (n(t)) throw new Error("cannot clobber existing macro <<" + t + ">>");
3657 if (u(t)) throw new Error("cannot clobber child tag <<" + t + ">> of parent macro" + (1 === d[t].length ? "" : "s") + " <<" + d[t].join(">>, <<") + ">>");
3658 try {
3659 if ("object" === ("undefined" == typeof r ? "undefined" : _typeof(r))) c[t] = a ? clone(r) : r; else {
3660 if (!n(r)) throw new Error("cannot create alias of nonexistent macro <<" + r + ">>");
3661 c[t] = a ? clone(c[r]) : c[r]
3662 }
3663 Object.defineProperty(c, t, {writable: !1}), c[t]._MACRO_API = !0
3664 } catch (e) {
3665 throw"TypeError" === e.name ? new Error("cannot clobber protected macro <<" + t + ">>") : new Error("unknown error when attempting to add macro <<" + t + ">>: [" + e.name + "] " + e.message)
3666 }
3667 if (c[t].hasOwnProperty("tags")) if (null == c[t].tags) o(t); else {
3668 if (!Array.isArray(c[t].tags)) throw new Error('bad value for "tags" property of macro <<' + t + ">>");
3669 o(t, c[t].tags)
3670 }
3671 }
3672
3673 function t(e) {
3674 if (Array.isArray(e)) return void e.forEach(function (e) {
3675 return t(e)
3676 });
3677 if (n(e)) {
3678 c[e].hasOwnProperty("tags") && s(e);
3679 try {
3680 Object.defineProperty(c, e, {writable: !0}), delete c[e]
3681 } catch (t) {
3682 throw new Error("unknown error removing macro <<" + e + ">>: " + t.message)
3683 }
3684 } else if (u(e)) throw new Error("cannot remove child tag <<" + e + ">> of parent macro <<" + d[e] + ">>")
3685 }
3686
3687 function r() {
3688 return 0 === Object.keys(c).length
3689 }
3690
3691 function n(e) {
3692 return c.hasOwnProperty(e)
3693 }
3694
3695 function a(e) {
3696 var t = null;
3697 return n(e) && "function" == typeof c[e].handler ? t = c[e] : macros.hasOwnProperty(e) && "function" == typeof macros[e].handler && (t = macros[e]), t
3698 }
3699
3700 function i() {
3701 var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "init";
3702 Object.keys(c).forEach(function (t) {
3703 "function" == typeof c[t][e] && c[t][e](t)
3704 }), Object.keys(macros).forEach(function (t) {
3705 "function" == typeof macros[t][e] && macros[t][e](t)
3706 })
3707 }
3708
3709 function o(e, t) {
3710 if (!e) throw new Error("no parent specified");
3711 for (var r = ["/" + e, "end" + e], a = [].concat(r, Array.isArray(t) ? t : []), i = 0; i < a.length; ++i) {
3712 var o = a[i];
3713 if (n(o)) throw new Error("cannot register tag for an existing macro");
3714 u(o) ? d[o].includes(e) || (d[o].push(e), d[o].sort()) : d[o] = [e]
3715 }
3716 }
3717
3718 function s(e) {
3719 if (!e) throw new Error("no parent specified");
3720 Object.keys(d).forEach(function (t) {
3721 var r = d[t].indexOf(e);
3722 r !== -1 && (1 === d[t].length ? delete d[t] : d[t].splice(r, 1))
3723 })
3724 }
3725
3726 function u(e) {
3727 return d.hasOwnProperty(e)
3728 }
3729
3730 function l(e) {
3731 return u(e) ? d[e] : null
3732 }
3733
3734 var c = {}, d = {}, f = new RegExp("^(?:" + Patterns.macroName + ")$");
3735 return Object.freeze(Object.defineProperties({}, {
3736 add: {value: e},
3737 delete: {value: t},
3738 isEmpty: {value: r},
3739 has: {value: n},
3740 get: {value: a},
3741 init: {value: i},
3742 tags: {
3743 value: Object.freeze(Object.defineProperties({}, {
3744 register: {value: o},
3745 unregister: {value: s},
3746 has: {value: u},
3747 get: {value: l}
3748 }))
3749 },
3750 evalStatements: {
3751 value: function () {
3752 return Scripting.evalJavaScript.apply(Scripting, arguments)
3753 }
3754 }
3755 }))
3756 }(), MacroContext = function () {
3757 var e = function () {
3758 function e(t) {
3759 _classCallCheck(this, e);
3760 var r = Object.assign({
3761 parent: null,
3762 macro: null,
3763 name: "",
3764 args: null,
3765 payload: null,
3766 parser: null,
3767 source: ""
3768 }, t);
3769 if (null === r.macro || "" === r.name || null === r.parser) throw new TypeError("context object missing required properties");
3770 Object.defineProperties(this, {
3771 parent: {value: r.parent},
3772 self: {value: r.macro},
3773 name: {value: r.name},
3774 args: {value: r.args},
3775 payload: {value: r.payload},
3776 source: {value: r.source},
3777 parser: {value: r.parser},
3778 _output: {value: r.parser.output},
3779 _shadows: {writable: !0, value: null},
3780 _debugView: {writable: !0, value: null},
3781 _debugViewEnabled: {writable: !0, value: Config.debug}
3782 })
3783 }
3784
3785 return _createClass(e, [{
3786 key: "contextHas", value: function (e) {
3787 for (var t = this; null !== (t = t.parent);) if (e(t)) return !0;
3788 return !1
3789 }
3790 }, {
3791 key: "contextSelect", value: function (e) {
3792 for (var t = this; null !== (t = t.parent);) if (e(t)) return t;
3793 return null
3794 }
3795 }, {
3796 key: "contextSelectAll", value: function (e) {
3797 for (var t = [], r = this; null !== (r = r.parent);) e(r) && t.push(r);
3798 return t
3799 }
3800 }, {
3801 key: "addShadow", value: function () {
3802 var e = this;
3803 this._shadows || (this._shadows = new Set);
3804 for (var t = new RegExp("^" + Patterns.variable + "$"), r = arguments.length, n = Array(r), a = 0; a < r; a++) n[a] = arguments[a];
3805 n.flatten().forEach(function (r) {
3806 if ("string" != typeof r) throw new TypeError("variable name must be a string; type: " + ("undefined" == typeof r ? "undefined" : _typeof(r)));
3807 if (!t.test(r)) throw new Error('invalid variable name "' + r + '"');
3808 e._shadows.add(r)
3809 })
3810 }
3811 }, {
3812 key: "createShadowWrapper", value: function (e, t, r) {
3813 var n = void 0;
3814 return "function" == typeof e && (n = {}, this.shadowView.forEach(function (e) {
3815 var t = e.slice(1), r = "$" === e[0] ? State.variables : State.temporary;
3816 n[e] = r[t]
3817 })), function () {
3818 for (var a = this, i = arguments.length, o = Array(i), s = 0; s < i; s++) o[s] = arguments[s];
3819 "function" == typeof r && r.apply(this, o), "function" == typeof e && !function () {
3820 var t = Object.keys(n), r = t.length > 0 ? {} : null;
3821 try {
3822 t.forEach(function (e) {
3823 var t = e.slice(1), a = "$" === e[0] ? State.variables : State.temporary;
3824 a.hasOwnProperty(t) && (r[t] = a[t]), a[t] = n[e]
3825 }), e.apply(a, o)
3826 } finally {
3827 t.forEach(function (e) {
3828 var t = e.slice(1), a = "$" === e[0] ? State.variables : State.temporary;
3829 n[e] = a[t], r.hasOwnProperty(t) ? a[t] = r[t] : delete a[t]
3830 })
3831 }
3832 }(), "function" == typeof t && t.apply(this, o)
3833 }
3834 }
3835 }, {
3836 key: "createDebugView", value: function (e, t) {
3837 return this._debugView = new DebugView(this._output, "macro", e ? e : this.name, t ? t : this.source), null !== this.payload && this.payload.length > 0 && this._debugView.modes({nonvoid: !0}), this._debugViewEnabled = !0, this._debugView
3838 }
3839 }, {
3840 key: "removeDebugView", value: function () {
3841 null !== this._debugView && (this._debugView.remove(), this._debugView = null), this._debugViewEnabled = !1
3842 }
3843 }, {
3844 key: "error", value: function (e, t) {
3845 return throwError(this._output, "<<" + this.name + ">>: " + e, t ? t : this.source)
3846 }
3847 }, {
3848 key: "output", get: function () {
3849 return this._debugViewEnabled ? this.debugView.output : this._output
3850 }
3851 }, {
3852 key: "shadows", get: function () {
3853 return [].concat(_toConsumableArray(this._shadows))
3854 }
3855 }, {
3856 key: "shadowView", get: function () {
3857 var e = new Set;
3858 return this.contextSelectAll(function (e) {
3859 return e._shadows
3860 }).forEach(function (t) {
3861 return t._shadows.forEach(function (t) {
3862 return e.add(t)
3863 })
3864 }), [].concat(_toConsumableArray(e))
3865 }
3866 }, {
3867 key: "debugView", get: function () {
3868 return this._debugViewEnabled ? null !== this._debugView ? this._debugView : this.createDebugView() : null
3869 }
3870 }]), e
3871 }();
3872 return e
3873 }();
3874 !function () {
3875 Macro.add("capture", {
3876 skipArgs: !0, tags: null, handler: function () {
3877 if (0 === this.args.raw.length) return this.error("no story/temporary variable list specified");
3878 var e = {};
3879 try {
3880 for (var t = new RegExp("(" + Patterns.variable + ")", "g"), r = void 0; null !== (r = t.exec(this.args.raw));) {
3881 var n = r[1], a = n.slice(1), i = "$" === n[0] ? State.variables : State.temporary;
3882 i.hasOwnProperty(a) && (e[a] = i[a]), this.addShadow(n)
3883 }
3884 new Wikifier(this.output, this.payload[0].contents)
3885 } finally {
3886 this.shadows.forEach(function (t) {
3887 var r = t.slice(1), n = "$" === t[0] ? State.variables : State.temporary;
3888 e.hasOwnProperty(r) ? n[r] = e[r] : delete n[r]
3889 })
3890 }
3891 }
3892 }), Macro.add("set", {
3893 skipArgs: !0, handler: function () {
3894 if (0 === this.args.full.length) return this.error("no expression specified");
3895 try {
3896 Scripting.evalJavaScript(this.args.full)
3897 } catch (e) {
3898 return this.error("bad evaluation: " + ("object" === ("undefined" == typeof e ? "undefined" : _typeof(e)) ? e.message : e))
3899 }
3900 Config.debug && this.debugView.modes({hidden: !0})
3901 }
3902 }), Macro.add("unset", {
3903 skipArgs: !0, handler: function () {
3904 if (0 === this.args.full.length) return this.error("no story/temporary variable list specified");
3905 for (var e = new RegExp("State\\.(variables|temporary)\\.(" + Patterns.identifier + ")", "g"), t = void 0; null !== (t = e.exec(this.args.full));) {
3906 var r = State[t[1]], n = t[2];
3907 r.hasOwnProperty(n) && delete r[n]
3908 }
3909 Config.debug && this.debugView.modes({hidden: !0})
3910 }
3911 }), Macro.add("remember", {
3912 skipArgs: !0, handler: function () {
3913 if (0 === this.args.full.length) return this.error("no expression specified");
3914 try {
3915 Scripting.evalJavaScript(this.args.full)
3916 } catch (e) {
3917 return this.error("bad evaluation: " + ("object" === ("undefined" == typeof e ? "undefined" : _typeof(e)) ? e.message : e))
3918 }
3919 for (var e = storage.get("remember") || {}, t = new RegExp("State\\.variables\\.(" + Patterns.identifier + ")", "g"), r = void 0; null !== (r = t.exec(this.args.full));) {
3920 var n = r[1];
3921 e[n] = State.variables[n]
3922 }
3923 return storage.set("remember", e) ? void (Config.debug && this.debugView.modes({hidden: !0})) : this.error("unknown error, cannot remember: " + this.args.raw)
3924 }, init: function () {
3925 var e = storage.get("remember");
3926 e && Object.keys(e).forEach(function (t) {
3927 return State.variables[t] = e[t]
3928 })
3929 }
3930 }), Macro.add("forget", {
3931 skipArgs: !0, handler: function () {
3932 if (0 === this.args.full.length) return this.error("no story variable list specified");
3933 for (var e = storage.get("remember"), t = new RegExp("State\\.variables\\.(" + Patterns.identifier + ")", "g"), r = void 0, n = !1; null !== (r = t.exec(this.args.full));) {
3934 var a = r[1];
3935 State.variables.hasOwnProperty(a) && delete State.variables[a], e && e.hasOwnProperty(a) && (n = !0, delete e[a])
3936 }
3937 return n && !storage.set("remember", e) ? this.error("unknown error, cannot update remember store") : void (Config.debug && this.debugView.modes({hidden: !0}))
3938 }
3939 }), Macro.add("run", "set"), Macro.add("script", {
3940 skipArgs: !0, tags: null, handler: function () {
3941 var e = document.createDocumentFragment();
3942 try {
3943 Scripting.evalJavaScript(this.payload[0].contents, e), Config.debug && this.createDebugView(this.name, this.source + this.payload[0].contents + "<</" + this.name + ">>")
3944 } catch (e) {
3945 return this.error("bad evaluation: " + ("object" === ("undefined" == typeof e ? "undefined" : _typeof(e)) ? e.message : e), this.source + this.payload[0].contents + "<</" + this.name + ">>")
3946 }
3947 e.hasChildNodes() && this.output.appendChild(e)
3948 }
3949 }), Macro.add("include", {
3950 handler: function () {
3951 if (0 === this.args.length) return this.error("no passage specified");
3952 var e = void 0;
3953 if (e = "object" === _typeof(this.args[0]) ? this.args[0].link : this.args[0], !Story.has(e)) return this.error('passage "' + e + '" does not exist');
3954 Config.debug && this.debugView.modes({block: !0}), e = Story.get(e);
3955 var t = void 0;
3956 t = this.args[1] ? jQuery(document.createElement(this.args[1])).addClass(e.domId + " macro-" + this.name).attr("data-passage", e.title).appendTo(this.output) : jQuery(this.output), t.wiki(e.processText())
3957 }
3958 }), Macro.add("nobr", {
3959 skipArgs: !0, tags: null, handler: function () {
3960 new Wikifier(this.output, this.payload[0].contents.replace(/^\n+|\n+$/g, "").replace(/\n+/g, " "))
3961 }
3962 }), Macro.add(["print", "=", "-"], {
3963 skipArgs: !0, handler: function () {
3964 if (0 === this.args.full.length) return this.error("no expression specified");
3965 try {
3966 var e = toStringOrDefault(Scripting.evalJavaScript(this.args.full), null);
3967 null !== e && new Wikifier(this.output, "-" === this.name ? Util.escape(e) : e)
3968 } catch (e) {
3969 return this.error("bad evaluation: " + ("object" === ("undefined" == typeof e ? "undefined" : _typeof(e)) ? e.message : e))
3970 }
3971 }
3972 }), Macro.add("silently", {
3973 skipArgs: !0, tags: null, handler: function () {
3974 var e = document.createDocumentFragment();
3975 if (new Wikifier(e, this.payload[0].contents.trim()), Config.debug) this.debugView.modes({hidden: !0}), this.output.appendChild(e); else {
3976 var t = [].concat(_toConsumableArray(e.querySelectorAll(".error"))).map(function (e) {
3977 return e.textContent
3978 });
3979 if (t.length > 0) return this.error("error" + (1 === t.length ? "" : "s") + " within contents (" + t.join("; ") + ")", this.source + this.payload[0].contents + "<</" + this.name + ">>")
3980 }
3981 }
3982 }), Macro.add("display", "include"), Macro.add("if", {
3983 skipArgs: !0, tags: ["elseif", "else"], handler: function () {
3984 var e = 0;
3985 try {
3986 for (var t = Scripting.evalJavaScript, r = this.payload.length, n = !1; e < r; ++e) {
3987 switch (this.payload[e].name) {
3988 case"else":
3989 if (e + 1 !== r) return this.error("<<else>> must be the final clause");
3990 if (this.payload[e].args.raw.length > 0) return /^\s*if\b/i.test(this.payload[e].args.raw) ? this.error('whitespace is not allowed between the "else" and "if" in <<elseif>> clause' + (e > 0 ? " (#" + e + ")" : "")) : this.error("<<else>> does not accept a conditional expression (perhaps you meant to use <<elseif>>), invalid: " + this.payload[e].args.raw);
3991 break;
3992 default:
3993 if (0 === this.payload[e].args.full.length) return this.error("no conditional expression specified for <<" + this.payload[e].name + ">> clause" + (e > 0 ? " (#" + e + ")" : ""));
3994 if (Config.macros.ifAssignmentError && /[^!=&^|<>*\/%+-]=[^=]/.test(this.payload[e].args.full)) return this.error("assignment operator found within <<" + this.payload[e].name + ">> clause" + (e > 0 ? " (#" + e + ")" : "") + " (perhaps you meant to use an equality operator: ==, ===, eq, is), invalid: " + this.payload[e].args.raw)
3995 }
3996 if (Config.debug && this.createDebugView(this.payload[e].name, this.payload[e].source).modes({nonvoid: !1}), "else" === this.payload[e].name || t(this.payload[e].args.full)) {
3997 n = !0, new Wikifier(this.output, this.payload[e].contents);
3998 break
3999 }
4000 Config.debug && this.debugView.modes({hidden: !0, invalid: !0})
4001 }
4002 if (Config.debug) {
4003 for (++e; e < r; ++e) this.createDebugView(this.payload[e].name, this.payload[e].source).modes({
4004 nonvoid: !1,
4005 hidden: !0,
4006 invalid: !0
4007 });
4008 this.createDebugView("/" + this.name, "<</" + this.name + ">>").modes({
4009 nonvoid: !1,
4010 hidden: !n,
4011 invalid: !n
4012 })
4013 }
4014 } catch (t) {
4015 return this.error("bad conditional expression in <<" + (0 === e ? "if" : "elseif") + ">> clause" + (e > 0 ? " (#" + e + ")" : "") + ": " + ("object" === ("undefined" == typeof t ? "undefined" : _typeof(t)) ? t.message : t))
4016 }
4017 }
4018 }), Macro.add("switch", {
4019 skipArg0: !0, tags: ["case", "default"], handler: function () {
4020 if (0 === this.args.full.length) return this.error("no expression specified");
4021 var e = this.payload.length, t = void 0;
4022 if (1 === e) return this.error("no cases specified");
4023 try {
4024 t = Scripting.evalJavaScript(this.args.full)
4025 } catch (e) {
4026 return this.error("bad evaluation: " + ("object" === ("undefined" == typeof e ? "undefined" : _typeof(e)) ? e.message : e))
4027 }
4028 var r = this.debugView, n = 1, a = !1;
4029 for (Config.debug && r.modes({nonvoid: !1, hidden: !0}); n < e; ++n) {
4030 switch (this.payload[n].name) {
4031 case"default":
4032 if (n + 1 !== e) return this.error("<<default>> must be the final case");
4033 if (this.payload[n].args.length > 0) return this.error("<<default>> does not accept values, invalid: " + this.payload[n].args.raw);
4034 break;
4035 default:
4036 if (0 === this.payload[n].args.length) return this.error("no value(s) specified for <<" + this.payload[n].name + ">> (#" + n + ")")
4037 }
4038 if (Config.debug && this.createDebugView(this.payload[n].name, this.payload[n].source).modes({nonvoid: !1}), "default" === this.payload[n].name || this.payload[n].args.some(function (e) {
4039 return e === t
4040 })) {
4041 a = !0, new Wikifier(this.output, this.payload[n].contents);
4042 break
4043 }
4044 Config.debug && this.debugView.modes({hidden: !0, invalid: !0})
4045 }
4046 if (Config.debug) {
4047 for (++n; n < e; ++n) this.createDebugView(this.payload[n].name, this.payload[n].source).modes({
4048 nonvoid: !1,
4049 hidden: !0,
4050 invalid: !0
4051 });
4052 r.modes({
4053 nonvoid: !1,
4054 hidden: !0,
4055 invalid: !a
4056 }), this.createDebugView("/" + this.name, "<</" + this.name + ">>").modes({
4057 nonvoid: !1,
4058 hidden: !0,
4059 invalid: !a
4060 })
4061 }
4062 }
4063 }), Macro.add("for", {
4064 skipArgs: !0,
4065 tags: null,
4066 _hasRangeRe: new RegExp("^\\S.*?\\s+range\\s+\\S.*?$"),
4067 _rangeRe: new RegExp("^(?:State\\.(variables|temporary)\\.(" + Patterns.identifier + ")\\s*,\\s*)?State\\.(variables|temporary)\\.(" + Patterns.identifier + ")\\s+range\\s+(\\S.*?)$"),
4068 _3PartRe: /^([^;]*?)\s*;\s*([^;]*?)\s*;\s*([^;]*?)$/,
4069 handler: function () {
4070 var e = this.args.full.trim(), t = this.payload[0].contents.replace(/\n$/, "");
4071 if (0 === e.length) this.self._handleFor.call(this, t, null, !0, null); else if (this.self._hasRangeRe.test(e)) {
4072 var r = e.match(this.self._rangeRe);
4073 if (null === r) return this.error("invalid range form syntax, format: [index ,] value range collection");
4074 this.self._handleForRange.call(this, t, {type: r[1], name: r[2]}, {
4075 type: r[3],
4076 name: r[4]
4077 }, r[5])
4078 } else {
4079 var n = void 0, a = void 0, i = void 0;
4080 if (e.indexOf(";") === -1) {
4081 if (/^\S+\s+in\s+\S+/i.test(e)) return this.error("invalid syntax, for…in is not supported; see: for…range");
4082 if (/^\S+\s+of\s+\S+/i.test(e)) return this.error("invalid syntax, for…of is not supported; see: for…range");
4083 a = e
4084 } else {
4085 var o = e.match(this.self._3PartRe);
4086 if (null === o) return this.error("invalid 3-part conditional form syntax, format: [init] ; [condition] ; [post]");
4087 n = o[1], a = o[2].trim(), i = o[3], 0 === a.length && (a = !0)
4088 }
4089 this.self._handleFor.call(this, t, n, a, i)
4090 }
4091 },
4092 _handleFor: function (e, t, r, n) {
4093 var a = Scripting.evalJavaScript, i = !0, o = Config.macros.maxLoopIterations;
4094 Config.debug && this.debugView.modes({block: !0});
4095 try {
4096 if (TempState.break = null, t) try {
4097 a(t)
4098 } catch (e) {
4099 return this.error("bad init expression: " + ("object" === ("undefined" == typeof e ? "undefined" : _typeof(e)) ? e.message : e))
4100 }
4101 for (; a(r);) {
4102 if (--o < 0) return this.error("exceeded configured maximum loop iterations (" + Config.macros.maxLoopIterations + ")");
4103 if (new Wikifier(this.output, i ? e.replace(/^\n/, "") : e), i && (i = !1), null != TempState.break) if (1 === TempState.break) TempState.break = null; else if (2 === TempState.break) {
4104 TempState.break = null;
4105 break
4106 }
4107 if (n) try {
4108 a(n)
4109 } catch (e) {
4110 return this.error("bad post expression: " + ("object" === ("undefined" == typeof e ? "undefined" : _typeof(e)) ? e.message : e))
4111 }
4112 }
4113 } catch (e) {
4114 return this.error("bad conditional expression: " + ("object" === ("undefined" == typeof e ? "undefined" : _typeof(e)) ? e.message : e))
4115 } finally {
4116 TempState.break = null
4117 }
4118 },
4119 _handleForRange: function (e, t, r, n) {
4120 var a = !0, i = void 0;
4121 try {
4122 i = this.self._toRangeList(n)
4123 } catch (e) {
4124 return this.error(e.message)
4125 }
4126 Config.debug && this.debugView.modes({block: !0});
4127 try {
4128 TempState.break = null;
4129 for (var o = 0; o < i.length; ++o) if (t.name && (State[t.type][t.name] = i[o][0]), State[r.type][r.name] = i[o][1], new Wikifier(this.output, a ? e.replace(/^\n/, "") : e), a && (a = !1), null != TempState.break) if (1 === TempState.break) TempState.break = null; else if (2 === TempState.break) {
4130 TempState.break = null;
4131 break
4132 }
4133 } catch (e) {
4134 return this.error("object" === ("undefined" == typeof e ? "undefined" : _typeof(e)) ? e.message : e)
4135 } finally {
4136 TempState.break = null
4137 }
4138 },
4139 _toRangeList: function (e) {
4140 var t = Scripting.evalJavaScript, r = void 0;
4141 try {
4142 r = t("{" === e[0] ? "(" + e + ")" : e)
4143 } catch (e) {
4144 if ("object" !== ("undefined" == typeof e ? "undefined" : _typeof(e))) throw new Error("bad range expression: " + e);
4145 throw e.message = "bad range expression: " + e.message, e
4146 }
4147 var n = void 0;
4148 switch ("undefined" == typeof r ? "undefined" : _typeof(r)) {
4149 case"string":
4150 n = [];
4151 for (var a = 0; a < r.length;) {
4152 var i = Util.charAndPosAt(r, a);
4153 n.push([a, i.char]), a = 1 + i.end
4154 }
4155 break;
4156 case"object":
4157 if (Array.isArray(r)) n = r.map(function (e, t) {
4158 return [t, e]
4159 }); else if (r instanceof Set) n = [].concat(_toConsumableArray(r)).map(function (e, t) {
4160 return [t, e]
4161 }); else if (r instanceof Map) n = [].concat(_toConsumableArray(r.entries())); else {
4162 if ("Object" !== Util.toStringTag(r)) throw new Error("unsupported range expression type: " + Util.toStringTag(r));
4163 n = Object.keys(r).map(function (e) {
4164 return [e, r[e]]
4165 })
4166 }
4167 break;
4168 default:
4169 throw new Error("unsupported range expression type: " + ("undefined" == typeof r ? "undefined" : _typeof(r)))
4170 }
4171 return n
4172 }
4173 }), Macro.add(["break", "continue"], {
4174 skipArgs: !0, handler: function () {
4175 return this.contextHas(function (e) {
4176 return "for" === e.name
4177 }) ? (TempState.break = "continue" === this.name ? 1 : 2, void (Config.debug && this.debugView.modes({hidden: !0}))) : this.error("must only be used in conjunction with its parent macro <<for>>")
4178 }
4179 }), Macro.add(["button", "link"], {
4180 isAsync: !0, tags: null, handler: function () {
4181 var e = this;
4182 if (0 === this.args.length) return this.error("no " + ("button" === this.name ? "button" : "link") + " text specified");
4183 Config.debug && this.createDebugView(this.name, this.source + this.payload[0].contents + "<</" + this.name + ">>");
4184 var t = jQuery(document.createElement("button" === this.name ? "button" : "a")), r = void 0;
4185 if ("object" === _typeof(this.args[0])) if (this.args[0].isImage) {
4186 var n = jQuery(document.createElement("img")).attr("src", this.args[0].source).appendTo(t);
4187 this.args[0].hasOwnProperty("passage") && n.attr("data-passage", this.args[0].passage), this.args[0].hasOwnProperty("title") && n.attr("title", this.args[0].title), this.args[0].hasOwnProperty("align") && n.attr("align", this.args[0].align), this.args[0].hasOwnProperty("link") && (r = this.args[0].link), r = this.args[0].link
4188 } else t.append(document.createTextNode(this.args[0].text)), r = this.args[0].link; else t.wikiWithOptions({profile: "core"}, this.args[0]), r = this.args.length > 1 ? this.args[1] : undefined;
4189 null != r ? (t.attr("data-passage", r), Story.has(r) ? (t.addClass("link-internal"), Config.addVisitedLinkClass && State.hasPlayed(r) && t.addClass("link-visited")) : t.addClass("link-broken")) : t.addClass("link-internal"), t.addClass("macro-" + this.name).ariaClick({
4190 namespace: ".macros",
4191 one: null != r
4192 }, this.createShadowWrapper("" !== this.payload[0].contents ? function () {
4193 return Wikifier.wikifyEval(e.payload[0].contents.trim())
4194 } : null, null != r ? function () {
4195 return Engine.play(r)
4196 } : null)).appendTo(this.output)
4197 }
4198 }), Macro.add("checkbox", {
4199 handler: function () {
4200 if (this.args.length < 3) {
4201 var e = [];
4202 return this.args.length < 1 && e.push("variable name"), this.args.length < 2 && e.push("unchecked value"), this.args.length < 3 && e.push("checked value"), this.error("no " + e.join(" or ") + " specified")
4203 }
4204 if ("string" != typeof this.args[0]) return this.error("variable name argument is not a string");
4205 var t = this.args[0].trim();
4206 if ("$" !== t[0] && "_" !== t[0]) return this.error('variable name "' + this.args[0] + '" is missing its sigil ($ or _)');
4207 var r = Util.slugify(t), n = this.args[1], a = this.args[2], i = document.createElement("input");
4208 jQuery(i).attr({
4209 id: this.name + "-" + r,
4210 name: this.name + "-" + r,
4211 type: "checkbox",
4212 tabindex: 0
4213 }).addClass("macro-" + this.name).on("change", function () {
4214 Wikifier.setValue(t, this.checked ? a : n)
4215 }).appendTo(this.output), this.args.length > 3 && "checked" === this.args[3] ? (i.checked = !0, Wikifier.setValue(t, a)) : Wikifier.setValue(t, n)
4216 }
4217 }), Macro.add(["linkappend", "linkprepend", "linkreplace"], {
4218 isAsync: !0, tags: null, handler: function () {
4219 var e = this;
4220 if (0 === this.args.length) return this.error("no link text specified");
4221 Config.debug && this.createDebugView(this.name, this.source + this.payload[0].contents + "<</" + this.name + ">>");
4222 var t = jQuery(document.createElement("a")), r = jQuery(document.createElement("span")),
4223 n = this.args.length > 1 && /^(?:transition|t8n)$/.test(this.args[1]);
4224 t.wikiWithOptions({profile: "core"}, this.args[0]).addClass("link-internal macro-" + this.name).ariaClick({
4225 namespace: ".macros",
4226 one: !0
4227 }, this.createShadowWrapper(function () {
4228 if ("linkreplace" === e.name ? t.remove() : t.wrap('<span class="macro-' + e.name + '"></span>').replaceWith(function () {
4229 return t.html()
4230 }), "" !== e.payload[0].contents) {
4231 var a = document.createDocumentFragment();
4232 new Wikifier(a, e.payload[0].contents), r.append(a)
4233 }
4234 n && setTimeout(function () {
4235 return r.removeClass("macro-" + e.name + "-in")
4236 }, Engine.minDomActionDelay)
4237 })).appendTo(this.output), r.addClass("macro-" + this.name + "-insert"), n && r.addClass("macro-" + this.name + "-in"), "linkprepend" === this.name ? r.insertBefore(t) : r.insertAfter(t)
4238 }
4239 }), Macro.add("radiobutton", {
4240 handler: function () {
4241 if (this.args.length < 2) {
4242 var e = [];
4243 return this.args.length < 1 && e.push("variable name"), this.args.length < 2 && e.push("checked value"), this.error("no " + e.join(" or ") + " specified")
4244 }
4245 if ("string" != typeof this.args[0]) return this.error("variable name argument is not a string");
4246 var t = this.args[0].trim();
4247 if ("$" !== t[0] && "_" !== t[0]) return this.error('variable name "' + this.args[0] + '" is missing its sigil ($ or _)');
4248 var r = Util.slugify(t), n = this.args[1], a = document.createElement("input");
4249 TempState.hasOwnProperty(this.name) || (TempState[this.name] = {}), TempState[this.name].hasOwnProperty(r) || (TempState[this.name][r] = 0), jQuery(a).attr({
4250 id: this.name + "-" + r + "-" + TempState[this.name][r]++,
4251 name: this.name + "-" + r,
4252 type: "radio",
4253 tabindex: 0
4254 }).addClass("macro-" + this.name).on("change", function () {
4255 this.checked && Wikifier.setValue(t, n)
4256 }).appendTo(this.output), this.args.length > 2 && "checked" === this.args[2] && (a.checked = !0, Wikifier.setValue(t, n))
4257 }
4258 }), Macro.add("textarea", {
4259 handler: function () {
4260 if (this.args.length < 2) {
4261 var e = [];
4262 return this.args.length < 1 && e.push("variable name"), this.args.length < 2 && e.push("default value"), this.error("no " + e.join(" or ") + " specified")
4263 }
4264 if ("string" != typeof this.args[0]) return this.error("variable name argument is not a string");
4265 var t = this.args[0].trim();
4266 if ("$" !== t[0] && "_" !== t[0]) return this.error('variable name "' + this.args[0] + '" is missing its sigil ($ or _)');
4267 Config.debug && this.debugView.modes({block: !0});
4268 var r = Util.slugify(t), n = this.args[1], a = "autofocus" === this.args[2],
4269 i = document.createElement("textarea");
4270 jQuery(i).attr({
4271 id: this.name + "-" + r,
4272 name: this.name + "-" + r,
4273 rows: 4,
4274 tabindex: 0
4275 }).addClass("macro-" + this.name).on("change", function () {
4276 Wikifier.setValue(t, this.value)
4277 }).appendTo(this.output), Wikifier.setValue(t, n), i.textContent = n, a && (i.setAttribute("autofocus", "autofocus"), postdisplay["#autofocus:" + i.id] = function (e) {
4278 delete postdisplay[e], setTimeout(function () {
4279 return i.focus()
4280 }, Engine.minDomActionDelay)
4281 })
4282 }
4283 }), Macro.add("textbox", {
4284 handler: function () {
4285 if (this.args.length < 2) {
4286 var e = [];
4287 return this.args.length < 1 && e.push("variable name"), this.args.length < 2 && e.push("default value"), this.error("no " + e.join(" or ") + " specified")
4288 }
4289 if ("string" != typeof this.args[0]) return this.error("variable name argument is not a string");
4290 var t = this.args[0].trim();
4291 if ("$" !== t[0] && "_" !== t[0]) return this.error('variable name "' + this.args[0] + '" is missing its sigil ($ or _)');
4292 Config.debug && this.debugView.modes({block: !0});
4293 var r = Util.slugify(t), n = this.args[1], a = document.createElement("input"), i = !1, o = void 0;
4294 this.args.length > 3 ? (o = this.args[2], i = "autofocus" === this.args[3]) : this.args.length > 2 && ("autofocus" === this.args[2] ? i = !0 : o = this.args[2]), jQuery(a).attr({
4295 id: this.name + "-" + r,
4296 name: this.name + "-" + r,
4297 type: "text",
4298 tabindex: 0
4299 }).addClass("macro-" + this.name).on("change", function () {
4300 Wikifier.setValue(t, this.value)
4301 }).on("keypress", function (e) {
4302 13 === e.which && (e.preventDefault(), Wikifier.setValue(t, this.value),
4303 null != o && Engine.play(o))
4304 }).appendTo(this.output), Wikifier.setValue(t, n), a.value = n, i && (a.setAttribute("autofocus", "autofocus"), postdisplay["#autofocus:" + a.id] = function (e) {
4305 delete postdisplay[e], setTimeout(function () {
4306 return a.focus()
4307 }, Engine.minDomActionDelay)
4308 })
4309 }
4310 }), Macro.add("click", "link"), Macro.add("actions", {
4311 handler: function () {
4312 for (var e = jQuery(document.createElement("ul")).addClass(this.name).appendTo(this.output), t = 0; t < this.args.length; ++t) {
4313 var r = void 0, n = void 0, a = void 0, i = void 0;
4314 "object" === _typeof(this.args[t]) ? this.args[t].isImage ? (a = jQuery(document.createElement("img")).attr("src", this.args[t].source), this.args[t].hasOwnProperty("passage") && a.attr("data-passage", this.args[t].passage), this.args[t].hasOwnProperty("title") && a.attr("title", this.args[t].title), this.args[t].hasOwnProperty("align") && a.attr("align", this.args[t].align), r = this.args[t].link, i = this.args[t].setFn) : (n = this.args[t].text, r = this.args[t].link, i = this.args[t].setFn) : n = r = this.args[t], State.variables.hasOwnProperty("#actions") && State.variables["#actions"].hasOwnProperty(r) && State.variables["#actions"][r] || jQuery(Wikifier.createInternalLink(jQuery(document.createElement("li")).appendTo(e), r, null, function (e, t) {
4315 return function () {
4316 State.variables.hasOwnProperty("#actions") || (State.variables["#actions"] = {}), State.variables["#actions"][e] = !0, "function" == typeof t && t()
4317 }
4318 }(r, i))).addClass("macro-" + this.name).append(a || document.createTextNode(n))
4319 }
4320 }
4321 }), Macro.add(["back", "return"], {
4322 handler: function () {
4323 if (this.args.length > 1) return this.error("too many arguments specified, check the documentation for details");
4324 var e = -1, t = void 0, r = void 0, n = void 0;
4325 if (1 === this.args.length && ("object" === _typeof(this.args[0]) ? this.args[0].isImage ? (n = jQuery(document.createElement("img")).attr("src", this.args[0].source), this.args[0].hasOwnProperty("passage") && n.attr("data-passage", this.args[0].passage), this.args[0].hasOwnProperty("title") && n.attr("title", this.args[0].title), this.args[0].hasOwnProperty("align") && n.attr("align", this.args[0].align), this.args[0].hasOwnProperty("link") && (t = this.args[0].link)) : 1 === this.args[0].count ? t = this.args[0].link : (r = this.args[0].text, t = this.args[0].link) : 1 === this.args.length && (r = this.args[0])), null == t) {
4326 for (var a = State.length - 2; a >= 0; --a) if (State.history[a].title !== State.passage) {
4327 e = a, t = State.history[a].title;
4328 break
4329 }
4330 if (null == t && "return" === this.name) for (var i = State.expired.length - 1; i >= 0; --i) if (State.expired[i] !== State.passage) {
4331 t = State.expired[i];
4332 break
4333 }
4334 } else {
4335 if (!Story.has(t)) return this.error('passage "' + t + '" does not exist');
4336 if ("back" === this.name) {
4337 for (var o = State.length - 2; o >= 0; --o) if (State.history[o].title === t) {
4338 e = o;
4339 break
4340 }
4341 if (e === -1) return this.error('cannot find passage "' + t + '" in the current story history')
4342 }
4343 }
4344 if (null == t) return this.error("cannot find passage");
4345 var s = void 0;
4346 s = "back" !== this.name || e !== -1 ? jQuery(document.createElement("a")).addClass("link-internal").ariaClick({one: !0}, "return" === this.name ? function () {
4347 return Engine.play(t)
4348 } : function () {
4349 return Engine.goTo(e)
4350 }) : jQuery(document.createElement("span")).addClass("link-disabled"), s.addClass("macro-" + this.name).append(n || document.createTextNode(r || L10n.get("macro" + this.name.toUpperFirst() + "Text"))).appendTo(this.output)
4351 }
4352 }), Macro.add("choice", {
4353 handler: function () {
4354 if (0 === this.args.length) return this.error("no passage specified");
4355 var e = State.passage, t = void 0, r = void 0, n = void 0, a = void 0;
4356 return 1 === this.args.length ? "object" === _typeof(this.args[0]) ? this.args[0].isImage ? (n = jQuery(document.createElement("img")).attr("src", this.args[0].source), this.args[0].hasOwnProperty("passage") && n.attr("data-passage", this.args[0].passage), this.args[0].hasOwnProperty("title") && n.attr("title", this.args[0].title), this.args[0].hasOwnProperty("align") && n.attr("align", this.args[0].align), t = this.args[0].link, a = this.args[0].setFn) : (r = this.args[0].text, t = this.args[0].link, a = this.args[0].setFn) : r = t = this.args[0] : (t = this.args[0], r = this.args[1]), State.variables.hasOwnProperty("#choice") && State.variables["#choice"].hasOwnProperty(e) && State.variables["#choice"][e] ? void jQuery(document.createElement("span")).addClass("link-disabled macro-" + this.name).attr("tabindex", -1).append(n || document.createTextNode(r)).appendTo(this.output) : void jQuery(Wikifier.createInternalLink(this.output, t, null, function () {
4357 State.variables.hasOwnProperty("#choice") || (State.variables["#choice"] = {}), State.variables["#choice"][e] = !0, "function" == typeof a && a()
4358 })).addClass("macro-" + this.name).append(n || document.createTextNode(r))
4359 }
4360 }), Macro.add(["addclass", "toggleclass"], {
4361 handler: function () {
4362 if (this.args.length < 2) {
4363 var e = [];
4364 return this.args.length < 1 && e.push("selector"), this.args.length < 2 && e.push("class names"), this.error("no " + e.join(" or ") + " specified")
4365 }
4366 var t = jQuery(this.args[0]);
4367 if (0 === t.length) return this.error('no elements matched the selector "' + this.args[0] + '"');
4368 switch (this.name) {
4369 case"addclass":
4370 t.addClass(this.args[1].trim());
4371 break;
4372 case"toggleclass":
4373 t.toggleClass(this.args[1].trim())
4374 }
4375 }
4376 }), Macro.add("removeclass", {
4377 handler: function () {
4378 if (0 === this.args.length) return this.error("no selector specified");
4379 var e = jQuery(this.args[0]);
4380 return 0 === e.length ? this.error('no elements matched the selector "' + this.args[0] + '"') : void (this.args.length > 1 ? e.removeClass(this.args[1].trim()) : e.removeClass())
4381 }
4382 }), Macro.add("copy", {
4383 handler: function () {
4384 if (0 === this.args.length) return this.error("no selector specified");
4385 var e = jQuery(this.args[0]);
4386 return 0 === e.length ? this.error('no elements matched the selector "' + this.args[0] + '"') : void jQuery(this.output).append(e.html())
4387 }
4388 }), Macro.add(["append", "prepend", "replace"], {
4389 tags: null, handler: function () {
4390 if (0 === this.args.length) return this.error("no selector specified");
4391 var e = jQuery(this.args[0]);
4392 if (0 === e.length) return this.error('no elements matched the selector "' + this.args[0] + '"');
4393 if ("" !== this.payload[0].contents) {
4394 var t = document.createDocumentFragment();
4395 switch (new Wikifier(t, this.payload[0].contents), this.name) {
4396 case"replace":
4397 e.empty();
4398 case"append":
4399 e.append(t);
4400 break;
4401 case"prepend":
4402 e.prepend(t)
4403 }
4404 } else "replace" === this.name && e.empty()
4405 }
4406 }), Macro.add("remove", {
4407 handler: function () {
4408 if (0 === this.args.length) return this.error("no selector specified");
4409 var e = jQuery(this.args[0]);
4410 return 0 === e.length ? this.error('no elements matched the selector "' + this.args[0] + '"') : void e.remove()
4411 }
4412 }), Has.audio ? !function () {
4413 var e = Object.freeze([":not", ":all", ":looped", ":muted", ":paused", ":playing"]);
4414 Macro.add("audio", {
4415 handler: function () {
4416 var e = this;
4417 if (this.args.length < 2) {
4418 var t = [];
4419 return this.args.length < 1 && t.push("track or group IDs"), this.args.length < 2 && t.push("actions"), this.error("no " + t.join(" or ") + " specified")
4420 }
4421 var r = Macro.get("cacheaudio").tracks, n = [];
4422 try {
4423 !function () {
4424 var t = function e(t) {
4425 var n = t.id, o = void 0;
4426 switch (n) {
4427 case":all":
4428 o = a;
4429 break;
4430 case":looped":
4431 o = a.filter(function (e) {
4432 return r[e].isLooped()
4433 });
4434 break;
4435 case":muted":
4436 o = a.filter(function (e) {
4437 return r[e].isMuted()
4438 });
4439 break;
4440 case":paused":
4441 o = a.filter(function (e) {
4442 return r[e].isPaused()
4443 });
4444 break;
4445 case":playing":
4446 o = a.filter(function (e) {
4447 return r[e].isPlaying()
4448 });
4449 break;
4450 default:
4451 o = ":" === n[0] ? i[n] : [n]
4452 }
4453 return t.hasOwnProperty("not") && !function () {
4454 var r = t.not.map(function (t) {
4455 return e(t)
4456 }).flatten();
4457 o = o.filter(function (e) {
4458 return !r.includes(e)
4459 })
4460 }(), o
4461 }, a = Object.freeze(Object.keys(r)), i = Macro.get("cacheaudio").groups;
4462 e.self.parseIds(String(e.args[0]).trim()).forEach(function (e) {
4463 n.push.apply(n, _toConsumableArray(t(e)))
4464 }), n.forEach(function (e) {
4465 if (!r.hasOwnProperty(e)) throw new Error('track "' + e + '" does not exist')
4466 })
4467 }()
4468 } catch (e) {
4469 return this.error(e.message)
4470 }
4471 for (var a = this.args.slice(1), i = void 0, o = void 0, s = void 0, u = void 0, l = void 0, c = void 0, d = 5, f = void 0, p = void 0; a.length > 0;) {
4472 var h = a.shift();
4473 switch (h) {
4474 case"play":
4475 case"pause":
4476 case"stop":
4477 i = h;
4478 break;
4479 case"fadein":
4480 i = "fade", c = 1;
4481 break;
4482 case"fadeout":
4483 i = "fade", c = 0;
4484 break;
4485 case"fadeto":
4486 if (0 === a.length) return this.error("fadeto missing required level value");
4487 if (i = "fade", p = a.shift(), c = Number.parseFloat(p), Number.isNaN(c) || !Number.isFinite(c)) return this.error("cannot parse fadeto: " + p);
4488 break;
4489 case"fadeoverto":
4490 if (a.length < 2) {
4491 var g = [];
4492 return a.length < 1 && g.push("seconds"), a.length < 2 && g.push("level"), this.error("fadeoverto missing required " + g.join(" and ") + " value" + (g.length > 1 ? "s" : ""))
4493 }
4494 if (i = "fade", p = a.shift(), d = Number.parseFloat(p), Number.isNaN(d) || !Number.isFinite(d)) return this.error("cannot parse fadeoverto: " + p);
4495 if (p = a.shift(), c = Number.parseFloat(p), Number.isNaN(c) || !Number.isFinite(c)) return this.error("cannot parse fadeoverto: " + p);
4496 break;
4497 case"volume":
4498 if (0 === a.length) return this.error("volume missing required level value");
4499 if (p = a.shift(), o = Number.parseFloat(p), Number.isNaN(o) || !Number.isFinite(o)) return this.error("cannot parse volume: " + p);
4500 break;
4501 case"mute":
4502 case"unmute":
4503 s = "mute" === h;
4504 break;
4505 case"time":
4506 if (0 === a.length) return this.error("time missing required seconds value");
4507 if (p = a.shift(), u = Number.parseFloat(p), Number.isNaN(u) || !Number.isFinite(u)) return this.error("cannot parse time: " + p);
4508 break;
4509 case"loop":
4510 case"unloop":
4511 l = "loop" === h;
4512 break;
4513 case"goto":
4514 if (0 === a.length) return this.error("goto missing required passage title");
4515 if (p = a.shift(), f = "object" === ("undefined" == typeof p ? "undefined" : _typeof(p)) ? p.link : p, !Story.has(f)) return this.error('passage "' + f + '" does not exist');
4516 break;
4517 default:
4518 return this.error("unknown action: " + h)
4519 }
4520 }
4521 try {
4522 n.forEach(function (e) {
4523 var t = r[e];
4524 switch (null != o && (t.volume = o), null != u && (t.time = u), null != s && (t.mute = s), null != l && (t.loop = l), null != f && t.one("end", function () {
4525 return Engine.play(f)
4526 }), i) {
4527 case"play":
4528 t.play();
4529 break;
4530 case"pause":
4531 t.pause();
4532 break;
4533 case"stop":
4534 t.stop();
4535 break;
4536 case"fade":
4537 t.fadeWithDuration(d, c)
4538 }
4539 }), Config.debug && this.createDebugView()
4540 } catch (e) {
4541 return this.error("error executing audio action: " + e.message)
4542 }
4543 }, parseIds: function (e) {
4544 function t(e, t) {
4545 var r = /\S/g, n = /[()]/g, a = void 0;
4546 if (r.lastIndex = t, a = r.exec(e), null === a || "(" !== a[0]) throw new Error('invalid ":not()" syntax: missing parentheticals');
4547 n.lastIndex = r.lastIndex;
4548 for (var i = r.lastIndex, o = {
4549 str: "",
4550 nextMatch: -1
4551 }, s = 1; null !== (a = n.exec(e));) if ("(" === a[0] ? ++s : --s, s < 1) {
4552 o.nextMatch = n.lastIndex, o.str = e.slice(i, o.nextMatch - 1);
4553 break
4554 }
4555 return o
4556 }
4557
4558 for (var r = [], n = /:?[^\s:()]+/g, a = void 0; null !== (a = n.exec(e));) {
4559 var i = a[0];
4560 if (":not" === i) {
4561 if (0 === r.length) throw new Error('invalid negation: no group ID preceded ":not()"');
4562 var o = r[r.length - 1];
4563 if (":" !== o.id[0]) throw new Error('invalid negation of track "' + o.id + '": only groups may be negated with ":not()"');
4564 var s = t(e, n.lastIndex);
4565 if (s.nextMatch === -1) throw new Error('unknown error parsing ":not()"');
4566 n.lastIndex = s.nextMatch, o.not = this.parseIds(s.str)
4567 } else r.push({id: i})
4568 }
4569 return r
4570 }
4571 }), Macro.add("cacheaudio", {
4572 tracks: {}, groups: {}, handler: function () {
4573 if (this.args.length < 2) {
4574 var e = [];
4575 return this.args.length < 1 && e.push("track ID"), this.args.length < 2 && e.push("sources"), this.error("no " + e.join(" or ") + " specified")
4576 }
4577 var t = String(this.args[0]).trim(), r = /^:|\s/;
4578 if (r.test(t)) return this.error('invalid track ID "' + t + '": track IDs may not start with a colon or contain whitespace');
4579 var n = /^format:\s*([\w-]+)\s*;\s*(\S.*)$/i, a = void 0;
4580 try {
4581 a = SimpleAudio.create(this.args.slice(1).map(function (e) {
4582 var t = n.exec(e);
4583 return null === t ? e : {format: t[1], src: t[2]}
4584 }))
4585 } catch (e) {
4586 return this.error('error during track initialization for "' + t + '": ' + e.message)
4587 }
4588 if (Config.debug && !a.hasSource()) return this.error('no supported audio sources found for "' + t + '"');
4589 var i = this.self.tracks;
4590 i.hasOwnProperty(t) && i[t].destroy(), i[t] = a, Config.debug && this.createDebugView()
4591 }
4592 }), Macro.add("createaudiogroup", {
4593 tags: ["track"], handler: function () {
4594 if (0 === this.args.length) return this.error("no group ID specified");
4595 var t = String(this.args[0]).trim(), r = /^[^:]|\s/;
4596 if (r.test(t)) return this.error('invalid group ID "' + t + '": group IDs must start with a colon and may not contain whitespace');
4597 if (e.includes(t)) return this.error('cannot clobber special group ID "' + t + '"');
4598 if (1 === this.payload.length) return this.error("no tracks defined via <<track>>");
4599 Config.debug && this.debugView.modes({nonvoid: !1, hidden: !0});
4600 for (var n = Macro.get("cacheaudio").tracks, a = [], i = 1, o = this.payload.length; i < o; ++i) {
4601 if (this.payload[i].args.length < 1) return this.error("no track ID specified");
4602 var s = String(this.payload[i].args[0]).trim();
4603 if (!n.hasOwnProperty(s)) return this.error('track "' + s + '" does not exist');
4604 a.push(s), Config.debug && this.createDebugView(this.payload[i].name, this.payload[i].source).modes({
4605 nonvoid: !1,
4606 hidden: !0
4607 })
4608 }
4609 var u = Macro.get("cacheaudio").groups;
4610 u.hasOwnProperty(t) && delete u[t], u[t] = a, this.createDebugView("/" + this.name, "<</" + this.name + ">>").modes({
4611 nonvoid: !1,
4612 hidden: !0
4613 })
4614 }
4615 }), Macro.add("createplaylist", {
4616 tags: ["track"], lists: {}, handler: function () {
4617 if (0 === this.args.length) return this.error("no list ID specified");
4618 var e = Macro.get("playlist");
4619 if (null !== e.from && "createplaylist" !== e.from) return this.error("a playlist has already been defined with <<setplaylist>>");
4620 var t = Macro.get("cacheaudio").tracks, r = String(this.args[0]).trim(), n = /^:|\s/;
4621 if (n.test(r)) return this.error('invalid list ID "' + r + '": list IDs may not start with a colon or contain whitespace');
4622 if (1 === this.payload.length) return this.error("no tracks defined via <<track>>");
4623 Config.debug && this.debugView.modes({nonvoid: !1, hidden: !0});
4624 for (var a = SimpleAudio.createList(), i = 1, o = this.payload.length; i < o; ++i) {
4625 if (this.payload[i].args.length < 2) {
4626 var s = [];
4627 return this.payload[i].args.length < 1 && s.push("track ID"), this.payload[i].args.length < 2 && s.push("actions"), this.error("no " + s.join(" or ") + " specified")
4628 }
4629 var u = String(this.payload[i].args[0]).trim();
4630 if (!t.hasOwnProperty(u)) return this.error('track "' + u + '" does not exist');
4631 for (var l = this.payload[i].args.slice(1), c = !1, d = void 0; l.length > 0;) {
4632 var f = l.shift(), p = void 0;
4633 switch (f) {
4634 case"copy":
4635 c = !0;
4636 break;
4637 case"rate":
4638 l.length > 0 && l.shift();
4639 break;
4640 case"volume":
4641 if (0 === l.length) return this.error("volume missing required level value");
4642 if (p = l.shift(), d = Number.parseFloat(p), Number.isNaN(d) || !Number.isFinite(d)) return this.error("cannot parse volume: " + p);
4643 break;
4644 default:
4645 return this.error("unknown action: " + f)
4646 }
4647 }
4648 var h = t[u];
4649 a.add({
4650 copy: c,
4651 track: h,
4652 volume: null != d ? d : h.volume
4653 }), Config.debug && this.createDebugView(this.payload[i].name, this.payload[i].source).modes({
4654 nonvoid: !1,
4655 hidden: !0
4656 })
4657 }
4658 var g = this.self.lists;
4659 g.hasOwnProperty(r) && g[r].destroy(), g[r] = a, null === e.from && (e.from = "createplaylist"), this.createDebugView("/" + this.name, "<</" + this.name + ">>").modes({
4660 nonvoid: !1,
4661 hidden: !0
4662 })
4663 }
4664 }), Macro.add("masteraudio", {
4665 handler: function () {
4666 if (0 === this.args.length) return this.error("no actions specified");
4667 for (var e = this.args.slice(0), t = !1, r = void 0, n = void 0; e.length > 0;) {
4668 var a = e.shift(), i = void 0;
4669 switch (a) {
4670 case"stop":
4671 t = !0;
4672 break;
4673 case"mute":
4674 case"unmute":
4675 r = "mute" === a;
4676 break;
4677 case"volume":
4678 if (0 === e.length) return this.error("volume missing required level value");
4679 if (i = e.shift(), n = Number.parseFloat(i), Number.isNaN(n) || !Number.isFinite(n)) return this.error("cannot parse volume: " + i);
4680 break;
4681 default:
4682 return this.error("unknown action: " + a)
4683 }
4684 }
4685 try {
4686 null != r && (SimpleAudio.mute = r), null != n && (SimpleAudio.volume = n), t && SimpleAudio.stop(), Config.debug && this.createDebugView()
4687 } catch (e) {
4688 return this.error("error executing master audio action: " + e.message)
4689 }
4690 }
4691 }), Macro.add("playlist", {
4692 from: null, handler: function () {
4693 var e = this.self.from;
4694 if (null === e) return this.error("no playlists have been created");
4695 var t = void 0, r = void 0;
4696 if ("createplaylist" === e) {
4697 if (this.args.length < 2) {
4698 var n = [];
4699 return this.args.length < 1 && n.push("list ID"), this.args.length < 2 && n.push("actions"), this.error("no " + n.join(" or ") + " specified")
4700 }
4701 var a = Macro.get("createplaylist").lists, i = String(this.args[0]).trim();
4702 if (!a.hasOwnProperty(i)) return this.error('playlist "' + i + '" does not exist');
4703 t = a[i], r = this.args.slice(1)
4704 } else {
4705 if (0 === this.args.length) return this.error("no actions specified");
4706 t = Macro.get("setplaylist").list, r = this.args.slice(0)
4707 }
4708 for (var o = void 0, s = void 0, u = void 0, l = void 0, c = void 0, d = void 0, f = 5, p = void 0; r.length > 0;) {
4709 var h = r.shift();
4710 switch (h) {
4711 case"play":
4712 case"pause":
4713 case"stop":
4714 case"skip":
4715 o = h;
4716 break;
4717 case"fadein":
4718 o = "fade", d = 1;
4719 break;
4720 case"fadeout":
4721 o = "fade", d = 0;
4722 break;
4723 case"fadeto":
4724 if (0 === r.length) return this.error("fadeto missing required level value");
4725 if (o = "fade", p = r.shift(), d = Number.parseFloat(p), Number.isNaN(d) || !Number.isFinite(d)) return this.error("cannot parse fadeto: " + p);
4726 break;
4727 case"fadeoverto":
4728 if (r.length < 2) {
4729 var g = [];
4730 return r.length < 1 && g.push("seconds"), r.length < 2 && g.push("level"), this.error("fadeoverto missing required " + g.join(" and ") + " value" + (g.length > 1 ? "s" : ""))
4731 }
4732 if (o = "fade", p = r.shift(), f = Number.parseFloat(p), Number.isNaN(f) || !Number.isFinite(f)) return this.error("cannot parse fadeoverto: " + p);
4733 if (p = r.shift(), d = Number.parseFloat(p), Number.isNaN(d) || !Number.isFinite(d)) return this.error("cannot parse fadeoverto: " + p);
4734 break;
4735 case"volume":
4736 if (0 === r.length) return this.error("volume missing required level value");
4737 if (p = r.shift(), s = Number.parseFloat(p), Number.isNaN(s) || !Number.isFinite(s)) return this.error("cannot parse volume: " + p);
4738 break;
4739 case"mute":
4740 case"unmute":
4741 u = "mute" === h;
4742 break;
4743 case"loop":
4744 case"unloop":
4745 l = "loop" === h;
4746 break;
4747 case"shuffle":
4748 case"unshuffle":
4749 c = "shuffle" === h;
4750 break;
4751 default:
4752 return this.error("unknown action: " + h)
4753 }
4754 }
4755 try {
4756 switch (null != s && (t.volume = s), null != u && (t.mute = u), null != l && (t.loop = l), null != c && (t.shuffle = c), o) {
4757 case"play":
4758 t.play();
4759 break;
4760 case"pause":
4761 t.pause();
4762 break;
4763 case"stop":
4764 t.stop();
4765 break;
4766 case"skip":
4767 t.skip();
4768 break;
4769 case"fade":
4770 t.fadeWithDuration(f, d)
4771 }
4772 Config.debug && this.createDebugView()
4773 } catch (e) {
4774 return this.error("error playing audio: " + e.message)
4775 }
4776 }
4777 }), Macro.add("removeplaylist", {
4778 handler: function () {
4779 if (0 === this.args.length) return this.error("no list ID specified");
4780 var e = Macro.get("createplaylist").lists, t = String(this.args[0]).trim();
4781 return e.hasOwnProperty(t) ? (e[t].destroy(), delete e[t], void (Config.debug && this.createDebugView())) : this.error('playlist "' + t + '" does not exist')
4782 }
4783 }), Macro.add("waitforaudio", {
4784 skipArgs: !0, queue: [], handler: function () {
4785 function e() {
4786 if (0 === t.length) return LoadScreen.unlock(r);
4787 var n = t.shift();
4788 return n.hasData() ? e() : void n.one("canplay.waitforaudio error.waitforaudio", function () {
4789 jQuery(this).off(".waitforaudio"), e()
4790 }).load()
4791 }
4792
4793 var t = this.self.queue, r = void 0;
4794 t.length > 0 || (this.self.fillQueue(t), t.length > 0 && (r = LoadScreen.lock(), e()))
4795 }, fillQueue: function (e) {
4796 var t = Macro.get("cacheaudio").tracks;
4797 Object.keys(t).forEach(function (r) {
4798 return e.push(t[r])
4799 });
4800 var r = Macro.get("createplaylist").lists;
4801 if (Object.keys(r).map(function (e) {
4802 return r[e].tracks
4803 }).flatten().filter(function (e) {
4804 return e.copy
4805 }).forEach(function (t) {
4806 return e.push(t.track)
4807 }), Macro.has("setplaylist")) {
4808 var n = Macro.get("setplaylist").list;
4809 null !== n && n.tracks.forEach(function (t) {
4810 return e.push(t.track)
4811 })
4812 }
4813 }
4814 }), Macro.add("setplaylist", {
4815 list: null, handler: function () {
4816 if (0 === this.args.length) return this.error("no track ID(s) specified");
4817 var e = Macro.get("playlist");
4818 if (null !== e.from && "setplaylist" !== e.from) return this.error("playlists have already been defined with <<createplaylist>>");
4819 var t = this.self, r = Macro.get("cacheaudio").tracks;
4820 null !== t.list && t.list.destroy(), t.list = SimpleAudio.createList();
4821 for (var n = 0; n < this.args.length; ++n) {
4822 var a = this.args[n];
4823 if (!r.hasOwnProperty(a)) return this.error('track "' + a + '" does not exist');
4824 t.list.add(r[a])
4825 }
4826 null === e.from && (e.from = "setplaylist"), Config.debug && this.createDebugView()
4827 }
4828 }), Macro.add("stopallaudio", {
4829 skipArgs: !0, handler: function () {
4830 var e = Macro.get("cacheaudio").tracks;
4831 Object.keys(e).forEach(function (t) {
4832 return e[t].stop()
4833 }), Config.debug && this.createDebugView()
4834 }
4835 })
4836 }() : Macro.add(["audio", "cacheaudio", "createaudiogroup", "createplaylist", "masteraudio", "playlist", "removeplaylist", "waitforaudio", "setplaylist", "stopallaudio"], {
4837 skipArgs: !0,
4838 handler: function () {
4839 }
4840 }), Macro.add("goto", {
4841 handler: function () {
4842 if (0 === this.args.length) return this.error("no passage specified");
4843 var e = void 0;
4844 return e = "object" === _typeof(this.args[0]) ? this.args[0].link : this.args[0], Story.has(e) ? void setTimeout(function () {
4845 return Engine.play(e)
4846 }, Engine.minDomActionDelay) : this.error('passage "' + e + '" does not exist')
4847 }
4848 }), Macro.add("repeat", {
4849 isAsync: !0, tags: null, timers: new Set, handler: function () {
4850 var e = this;
4851 if (0 === this.args.length) return this.error("no time value specified");
4852 var t = void 0;
4853 try {
4854 t = Math.max(Engine.minDomActionDelay, Util.fromCssTime(this.args[0]))
4855 } catch (e) {
4856 return this.error(e.message)
4857 }
4858 Config.debug && this.debugView.modes({block: !0});
4859 var r = this.args.length > 1 && /^(?:transition|t8n)$/.test(this.args[1]),
4860 n = jQuery(document.createElement("span")).addClass("macro-" + this.name).appendTo(this.output);
4861 this.self.registerInterval(this.createShadowWrapper(function () {
4862 var t = document.createDocumentFragment();
4863 new Wikifier(t, e.payload[0].contents);
4864 var a = n;
4865 r && (a = jQuery(document.createElement("span")).addClass("macro-repeat-insert macro-repeat-in").appendTo(a)), a.append(t), r && setTimeout(function () {
4866 return a.removeClass("macro-repeat-in")
4867 }, Engine.minDomActionDelay)
4868 }), t)
4869 }, registerInterval: function (e, t) {
4870 var r = this;
4871 if ("function" != typeof e) throw new TypeError("callback parameter must be a function");
4872 var n = State.turns, a = this.timers, i = null;
4873 i = setInterval(function () {
4874 if (n !== State.turns) return clearInterval(i), void a.delete(i);
4875 var t = void 0;
4876 try {
4877 TempState.break = null, TempState.hasOwnProperty("repeatTimerId") && (t = TempState.repeatTimerId), TempState.repeatTimerId = i, e.call(r)
4878 } finally {
4879 "undefined" != typeof t ? TempState.repeatTimerId = t : delete TempState.repeatTimerId, TempState.break = null
4880 }
4881 }, t), a.add(i), prehistory.hasOwnProperty("#repeat-timers-cleanup") || (prehistory["#repeat-timers-cleanup"] = function (e) {
4882 delete prehistory[e], a.forEach(function (e) {
4883 return clearInterval(e)
4884 }), a.clear()
4885 })
4886 }
4887 }), Macro.add("stop", {
4888 skipArgs: !0, handler: function () {
4889 if (!TempState.hasOwnProperty("repeatTimerId")) return this.error("must only be used in conjunction with its parent macro <<repeat>>");
4890 var e = Macro.get("repeat").timers, t = TempState.repeatTimerId;
4891 clearInterval(t), e.delete(t), TempState.break = 2, Config.debug && this.debugView.modes({hidden: !0})
4892 }
4893 }), Macro.add("timed", {
4894 isAsync: !0, tags: ["next"], timers: new Set, handler: function () {
4895 if (0 === this.args.length) return this.error("no time value specified in <<timed>>");
4896 var e = [];
4897 try {
4898 e.push({
4899 name: this.name,
4900 source: this.source,
4901 delay: Math.max(Engine.minDomActionDelay, Util.fromCssTime(this.args[0])),
4902 content: this.payload[0].contents
4903 })
4904 } catch (e) {
4905 return this.error(e.message + " in <<timed>>")
4906 }
4907 if (this.payload.length > 1) {
4908 var t = void 0;
4909 try {
4910 var r = void 0;
4911 for (t = 1, r = this.payload.length; t < r; ++t) e.push({
4912 name: this.payload[t].name,
4913 source: this.payload[t].source,
4914 delay: 0 === this.payload[t].args.length ? e[e.length - 1].delay : Math.max(Engine.minDomActionDelay, Util.fromCssTime(this.payload[t].args[0])),
4915 content: this.payload[t].contents
4916 })
4917 } catch (e) {
4918 return this.error(e.message + " in <<next>> (#" + t + ")")
4919 }
4920 }
4921 Config.debug && this.debugView.modes({block: !0});
4922 var n = this.args.length > 1 && /^(?:transition|t8n)$/.test(this.args[1]),
4923 a = jQuery(document.createElement("span")).addClass("macro-" + this.name).appendTo(this.output);
4924 this.self.registerTimeout(this.createShadowWrapper(function (e) {
4925 var t = document.createDocumentFragment();
4926 new Wikifier(t, e.content);
4927 var r = a;
4928 Config.debug && "next" === e.name && (r = jQuery(new DebugView(r[0], "macro", e.name, e.source).output)), n && (r = jQuery(document.createElement("span")).addClass("macro-timed-insert macro-timed-in").appendTo(r)), r.append(t), n && setTimeout(function () {
4929 return r.removeClass("macro-timed-in")
4930 }, Engine.minDomActionDelay)
4931 }), e)
4932 }, registerTimeout: function (e, t) {
4933 if ("function" != typeof e) throw new TypeError("callback parameter must be a function");
4934 var r = State.turns, n = this.timers, a = null, i = t.shift(), o = function o() {
4935 if (n.delete(a), r === State.turns) {
4936 var s = i;
4937 null != (i = t.shift()) && (a = setTimeout(o, i.delay), n.add(a)), e.call(this, s)
4938 }
4939 };
4940 a = setTimeout(o, i.delay), n.add(a), prehistory.hasOwnProperty("#timed-timers-cleanup") || (prehistory["#timed-timers-cleanup"] = function (e) {
4941 delete prehistory[e], n.forEach(function (e) {
4942 return clearTimeout(e)
4943 }), n.clear()
4944 })
4945 }
4946 }), Macro.add("widget", {
4947 tags: null, handler: function () {
4948 if (0 === this.args.length) return this.error("no widget name specified");
4949 var e = this.args[0];
4950 if (Macro.has(e)) {
4951 if (!Macro.get(e).isWidget) return this.error('cannot clobber existing macro "' + e + '"');
4952 Macro.delete(e)
4953 }
4954 try {
4955 Macro.add(e, {
4956 isWidget: !0, handler: function (e) {
4957 return function () {
4958 var t = this, r = void 0;
4959 try {
4960 var n = function () {
4961 State.variables.hasOwnProperty("args") && (r = State.variables.args), State.variables.args = [].concat(_toConsumableArray(t.args)), State.variables.args.raw = t.args.raw, State.variables.args.full = t.args.full, t.addShadow("$args");
4962 var n = document.createDocumentFragment(), a = [];
4963 return new Wikifier(n, e), Array.from(n.querySelectorAll(".error")).forEach(function (e) {
4964 a.push(e.textContent)
4965 }), 0 !== a.length ? {v: t.error("error" + (a.length > 1 ? "s" : "") + " within widget contents (" + a.join("; ") + ")")} : void t.output.appendChild(n)
4966 }();
4967 if ("object" === ("undefined" == typeof n ? "undefined" : _typeof(n))) return n.v
4968 } catch (e) {
4969 return this.error("cannot execute widget: " + e.message)
4970 } finally {
4971 "undefined" != typeof r ? State.variables.args = r : delete State.variables.args
4972 }
4973 }
4974 }(this.payload[0].contents)
4975 }), Config.debug && this.createDebugView(this.name, this.source + this.payload[0].contents + "<</" + this.name + ">>")
4976 } catch (t) {
4977 return this.error('cannot create widget macro "' + e + '": ' + t.message)
4978 }
4979 }
4980 })
4981 }();
4982 var Dialog = function () {
4983 function e() {
4984 m = function () {
4985 var e = void 0;
4986 try {
4987 var t = document.createElement("p"), r = document.createElement("div");
4988 t.style.width = "100%", t.style.height = "200px", r.style.position = "absolute", r.style.left = "0px", r.style.top = "0px", r.style.width = "100px", r.style.height = "100px", r.style.visibility = "hidden", r.style.overflow = "hidden", r.appendChild(t), document.body.appendChild(r);
4989 var n = t.offsetWidth;
4990 r.style.overflow = "auto";
4991 var a = t.offsetWidth;
4992 n === a && (a = r.clientWidth), document.body.removeChild(r), e = n - a
4993 } catch (e) {
4994 }
4995 return e || 17
4996 }();
4997 var e = jQuery(document.createDocumentFragment()).append('<div id="ui-overlay" class="ui-close"></div><div id="ui-dialog" tabindex="0" role="dialog" aria-labelledby="ui-dialog-title"><div id="ui-dialog-titlebar"><h1 id="ui-dialog-title"></h1>' + ('<button id="ui-dialog-close" class="ui-close" tabindex="0" aria-label="' + L10n.get("close") + '"></button>') + '</div><div id="ui-dialog-body"></div></div>');
4998 d = jQuery(e.find("#ui-overlay").get(0)), f = jQuery(e.find("#ui-dialog").get(0)), p = jQuery(e.find("#ui-dialog-title").get(0)), h = jQuery(e.find("#ui-dialog-body").get(0)), e.insertBefore("#store-area")
4999 }
5000
5001 function t(e) {
5002 return f.hasClass("open") && (!e || e.splitOrEmpty(/\s+/).every(function (e) {
5003 return h.hasClass(e)
5004 }))
5005 }
5006
5007 function r(e, t) {
5008 return h.empty().removeClass(), null != t && h.addClass(t), p.empty().append((null != e ? String(e) : "") || " "), h.get(0)
5009 }
5010
5011 function n() {
5012 return h.get(0)
5013 }
5014
5015 function a() {
5016 var e;
5017 return (e = h).append.apply(e, arguments), Dialog
5018 }
5019
5020 function i() {
5021 var e;
5022 return (e = h).wiki.apply(e, arguments), Dialog
5023 }
5024
5025 function o(e, t, r, n, a) {
5026 return jQuery(e).ariaClick(function (e) {
5027 e.preventDefault(), "function" == typeof r && r(e), s(t, a), "function" == typeof n && n(e)
5028 })
5029 }
5030
5031 function s(e, r) {
5032 var n = jQuery.extend({top: 50}, e), a = n.top;
5033 t() || (g = safeActiveElement()), jQuery(document.documentElement).attr("data-dialog", "open"), d.addClass("open"), null !== h[0].querySelector("img") && h.imagesLoaded().always(function () {
5034 return l({data: {top: a}})
5035 }), jQuery("body>:not(script,#store-area,#ui-bar,#ui-overlay,#ui-dialog)").attr("tabindex", -3).attr("aria-hidden", !0), jQuery("#ui-bar,#story").find("[tabindex]:not([tabindex^=-])").attr("tabindex", -2).attr("aria-hidden", !0);
5036 var i = c(a);
5037 return f.css(i).addClass("open").focus(), jQuery(window).on("resize.dialog-resize", null, {top: a}, jQuery.throttle(40, l)), Has.mutationObserver ? (y = new MutationObserver(function (e) {
5038 for (var t = 0; t < e.length; ++t) if ("childList" === e[t].type) {
5039 l({data: {top: a}});
5040 break
5041 }
5042 }), y.observe(h[0], {
5043 childList: !0,
5044 subtree: !0
5045 })) : h.on("DOMNodeInserted.dialog-resize DOMNodeRemoved.dialog-resize", null, {top: a}, jQuery.throttle(40, l)), jQuery(document).on("click.dialog-close", ".ui-close", {closeFn: r}, u).on("keypress.dialog-close", ".ui-close", function (e) {
5046 13 !== e.which && 32 !== e.which || jQuery(this).trigger("click")
5047 }), setTimeout(function () {
5048 return jQuery.event.trigger(":dialogopen")
5049 }, Engine.minDomActionDelay), Dialog
5050 }
5051
5052 function u(e) {
5053 return jQuery(document).off(".dialog-close"), y ? (y.disconnect(), y = null) : h.off(".dialog-resize"), jQuery(window).off(".dialog-resize"), f.removeClass("open").css({
5054 left: "",
5055 right: "",
5056 top: "",
5057 bottom: ""
5058 }), jQuery("#ui-bar,#story").find("[tabindex=-2]").removeAttr("aria-hidden").attr("tabindex", 0), jQuery("body>[tabindex=-3]").removeAttr("aria-hidden").removeAttr("tabindex"), p.empty(), h.empty().removeClass(), d.removeClass("open"), jQuery(document.documentElement).removeAttr("data-dialog"), null !== g && (jQuery(g).focus(), g = null), e && e.data && "function" == typeof e.data.closeFn && e.data.closeFn(e), setTimeout(function () {
5059 return jQuery.event.trigger(":dialogclose")
5060 }, Engine.minDomActionDelay), Dialog
5061 }
5062
5063 function l(e) {
5064 var t = e && e.data && "undefined" != typeof e.data.top ? e.data.top : 50;
5065 "block" === f.css("display") && (f.css({display: "none"}), f.css(jQuery.extend({display: ""}, c(t))))
5066 }
5067
5068 function c(e) {
5069 var t = null != e ? e : 50, r = jQuery(window), n = {left: "", right: "", top: "", bottom: ""};
5070 f.css(n);
5071 var a = r.width() - f.outerWidth(!0) - 1, i = r.height() - f.outerHeight(!0) - 1;
5072 return a <= 32 + m && (i -= m), i <= 32 + m && (a -= m), a <= 32 ? n.left = n.right = 16 : n.left = n.right = a / 2 >> 0, i <= 32 ? n.top = n.bottom = 16 : i / 2 > t ? n.top = t : n.top = n.bottom = i / 2 >> 0, Object.keys(n).forEach(function (e) {
5073 "" !== n[e] && (n[e] += "px")
5074 }), n
5075 }
5076
5077 var d = null, f = null, p = null, h = null, g = null, m = 0, y = null;
5078 return Object.freeze(Object.defineProperties({}, {
5079 init: {value: e},
5080 isOpen: {value: t},
5081 setup: {value: r},
5082 body: {value: n},
5083 append: {value: a},
5084 wiki: {value: i},
5085 addClickHandler: {value: o},
5086 open: {value: s},
5087 close: {value: u},
5088 resize: {
5089 value: function (e) {
5090 return l("object" === ("undefined" == typeof e ? "undefined" : _typeof(e)) ? {data: e} : undefined)
5091 }
5092 }
5093 }))
5094 }(), Engine = function () {
5095 function e() {
5096 jQuery("#init-no-js,#init-lacking").remove(), function () {
5097 var e = jQuery(document.createDocumentFragment()),
5098 t = Story.has("StoryInterface") && Story.get("StoryInterface").text.trim();
5099 if (t) {
5100 if (UIBar.destroy(), jQuery(document.head).find("#style-core-display").remove(), e.append(t), 0 === e.find("#passages").length) throw new Error('no element with ID "passages" found within "StoryInterface" special passage')
5101 } else e.append('<div id="story" role="main"><div id="passages"></div></div>');
5102 e.insertBefore("#store-area")
5103 }(), S = new StyleWrapper(function () {
5104 return jQuery(document.createElement("style")).attr({
5105 id: "style-aria-outlines",
5106 type: "text/css"
5107 }).appendTo(document.head).get(0)
5108 }()), jQuery(document).on("mousedown.aria-outlines keydown.aria-outlines", function (e) {
5109 return "keydown" === e.type ? m() : g()
5110 })
5111 }
5112
5113 function t() {
5114 if (Story.has("StoryInit")) try {
5115 var e = Wikifier.wikifyEval(Story.get("StoryInit").text);
5116 if (Config.debug) {
5117 var t = new DebugView(document.createDocumentFragment(), "special", "StoryInit", "StoryInit");
5118 t.modes({hidden: !0}), t.append(e), k = t.output
5119 }
5120 } catch (e) {
5121 console.error(e), Alert.error("StoryInit", e.message)
5122 }
5123 if (Config.history.maxStates = Math.max(0, Config.history.maxStates), Number.isSafeInteger(Config.history.maxStates) || (Config.history.maxStates = 100), 1 === Config.history.maxStates && (Config.history.controls = !1), Config.debug && DebugView.init(), null == Config.passages.start) throw new Error("starting passage not selected");
5124 if (!Story.has(Config.passages.start)) throw new Error('starting passage ("' + Config.passages.start + '") not found');
5125 if (jQuery(document.documentElement).focus(), State.restore()) f(); else {
5126 var r = !0;
5127 switch (_typeof(Config.saves.autoload)) {
5128 case"boolean":
5129 Config.saves.autoload && Save.autosave.ok() && Save.autosave.has() && (r = !Save.autosave.load());
5130 break;
5131 case"string":
5132 "prompt" === Config.saves.autoload && Save.autosave.ok() && Save.autosave.has() && (r = !1, UI.buildDialogAutoload(), UI.open());
5133 break;
5134 case"function":
5135 Save.autosave.ok() && Save.autosave.has() && Config.saves.autoload() && (r = !Save.autosave.load())
5136 }
5137 r && p(Config.passages.start)
5138 }
5139 }
5140
5141 function r() {
5142 LoadScreen.show(), window.scroll(0, 0), State.reset(), window.location.reload()
5143 }
5144
5145 function n() {
5146 return b
5147 }
5148
5149 function a() {
5150 return b === y.Idle
5151 }
5152
5153 function i() {
5154 return b !== y.Idle
5155 }
5156
5157 function o() {
5158 return b === y.Rendering
5159 }
5160
5161 function s() {
5162 return w
5163 }
5164
5165 function u(e) {
5166 var t = State.goTo(e);
5167 return t && f(), t
5168 }
5169
5170 function l(e) {
5171 var t = State.go(e);
5172 return t && f(), t
5173 }
5174
5175 function c() {
5176 return l(-1)
5177 }
5178
5179 function d() {
5180 return l(1)
5181 }
5182
5183 function f() {
5184 return p(State.passage, !0)
5185 }
5186
5187 function p(e, t) {
5188 var r = e;
5189 b = y.Playing, TempState = {}, State.clearTemporary();
5190 var n = void 0, a = void 0;
5191 if ("function" == typeof Config.navigation.override) try {
5192 var i = Config.navigation.override(r);
5193 i && (r = i)
5194 } catch (e) {
5195 }
5196 var o = Story.get(r);
5197 if (jQuery.event.trigger({
5198 type: ":passageinit",
5199 passage: o
5200 }), Object.keys(prehistory).forEach(function (e) {
5201 "function" == typeof prehistory[e] && prehistory[e].call(this, e)
5202 }, o), t || State.create(o.title), document.body.className && (document.body.className = ""), Object.keys(predisplay).forEach(function (e) {
5203 "function" == typeof predisplay[e] && predisplay[e].call(this, e)
5204 }, o), Story.has("PassageReady")) try {
5205 n = Wikifier.wikifyEval(Story.get("PassageReady").text)
5206 } catch (e) {
5207 console.error(e), Alert.error("PassageReady", e.message)
5208 }
5209 b = y.Rendering;
5210 var s = jQuery(o.render()), u = document.getElementById("passages");
5211 if (u.hasChildNodes() && ("number" == typeof Config.passages.transitionOut || "string" == typeof Config.passages.transitionOut && "" !== Config.passages.transitionOut && "" !== Config.transitionEndEventName ? [].concat(_toConsumableArray(u.childNodes)).forEach(function (e) {
5212 var t = jQuery(e);
5213 if (e.nodeType === Node.ELEMENT_NODE && t.hasClass("passage")) {
5214 if (t.hasClass("passage-out")) return;
5215 t.attr("id", "out-" + t.attr("id")).addClass("passage-out"), "string" == typeof Config.passages.transitionOut ? t.on(Config.transitionEndEventName, function (e) {
5216 e.originalEvent.propertyName === Config.passages.transitionOut && t.remove()
5217 }) : setTimeout(function () {
5218 return t.remove()
5219 }, Math.max(v, Config.passages.transitionOut))
5220 } else t.remove()
5221 }) : jQuery(u).empty()), s.addClass("passage-in").appendTo(u), setTimeout(function () {
5222 return s.removeClass("passage-in")
5223 }, v), Config.passages.displayTitles && o.title !== Config.passages.start && (document.title = o.title + " | " + Story.title), window.scroll(0, 0), b = y.Playing, Story.has("PassageDone")) try {
5224 a = Wikifier.wikifyEval(Story.get("PassageDone").text)
5225 } catch (e) {
5226 console.error(e), Alert.error("PassageDone", e.message)
5227 }
5228 if (jQuery.event.trigger({
5229 type: ":passagedisplay",
5230 passage: o
5231 }), Object.keys(postdisplay).forEach(function (e) {
5232 "function" == typeof postdisplay[e] && postdisplay[e].call(this, e)
5233 }, o), Config.ui.updateStoryElements && UIBar.setStoryElements(), Config.debug) {
5234 var l = void 0;
5235 null != n && (l = new DebugView(document.createDocumentFragment(), "special", "PassageReady", "PassageReady"), l.modes({hidden: !0}), l.append(n), s.prepend(l.output)), null != a && (l = new DebugView(document.createDocumentFragment(), "special", "PassageDone", "PassageDone"), l.modes({hidden: !0}), l.append(a), s.append(l.output)), 1 === State.turns && null != k && s.prepend(k)
5236 }
5237 switch (w = Util.now(), g(), jQuery("#story").find("a[href]:not(.link-external)").addClass("link-external").end().find("a,link,button,input,select,textarea").not("[tabindex]").attr("tabindex", 0), _typeof(Config.saves.autosave)) {
5238 case"boolean":
5239 Config.saves.autosave && Save.autosave.save();
5240 break;
5241 case"string":
5242 o.tags.includes(Config.saves.autosave) && Save.autosave.save();
5243 break;
5244 case"object":
5245 Array.isArray(Config.saves.autosave) && o.tags.some(function (e) {
5246 return Config.saves.autosave.includes(e)
5247 }) && Save.autosave.save()
5248 }
5249 return jQuery.event.trigger({type: ":passageend", passage: o}), b = y.Idle, s[0]
5250 }
5251
5252 function h(e, t, r) {
5253 var n = !1;
5254 switch (r) {
5255 case undefined:
5256 break;
5257 case"replace":
5258 case"back":
5259 n = !0;
5260 break;
5261 default:
5262 throw new Error('Engine.display option parameter called with obsolete value "' + r + '"; please notify the developer')
5263 }
5264 p(e, n)
5265 }
5266
5267 function g() {
5268 S.set("*:focus{outline:none}")
5269 }
5270
5271 function m() {
5272 S.clear()
5273 }
5274
5275 var y = Util.toEnum({Idle: "idle", Playing: "playing", Rendering: "rendering"}), v = 40, b = y.Idle,
5276 w = null, k = null, S = null;
5277 return Object.freeze(Object.defineProperties({}, {
5278 States: {value: y},
5279 minDomActionDelay: {value: v},
5280 init: {value: e},
5281 start: {value: t},
5282 restart: {value: r},
5283 state: {get: n},
5284 isIdle: {value: a},
5285 isPlaying: {value: i},
5286 isRendering: {value: o},
5287 lastPlay: {get: s},
5288 goTo: {value: u},
5289 go: {value: l},
5290 backward: {value: c},
5291 forward: {value: d},
5292 show: {value: f},
5293 play: {value: p},
5294 display: {value: h}
5295 }))
5296 }(), Passage = function () {
5297 var e = void 0;
5298 e = /^(?:debug|nobr|passage|widget|twine\..*)$/i;
5299 var t = function () {
5300 function t(r, n) {
5301 var a = this;
5302 _classCallCheck(this, t), Object.defineProperties(this, {
5303 title: {value: Util.unescape(r)},
5304 element: {value: n || null},
5305 tags: {
5306 value: Object.freeze(n && n.hasAttribute("tags") ? n.getAttribute("tags").trim().splitOrEmpty(/\s+/).sort().filter(function (e, t, r) {
5307 return 0 === t || r[t - 1] !== e
5308 }) : [])
5309 },
5310 _excerpt: {writable: !0, value: null}
5311 }), Object.defineProperties(this, {
5312 domId: {value: "passage-" + Util.slugify(this.title)},
5313 classes: {
5314 value: Object.freeze(0 === this.tags.length ? [] : function () {
5315 return a.tags.filter(function (t) {
5316 return !e.test(t)
5317 }).map(function (e) {
5318 return Util.slugify(e)
5319 })
5320 }())
5321 }
5322 })
5323 }
5324
5325 return _createClass(t, [{
5326 key: "description", value: function () {
5327 var e = Config.passages.descriptions;
5328 if (null != e) switch ("undefined" == typeof e ? "undefined" : _typeof(e)) {
5329 case"boolean":
5330 if (e) return this.title;
5331 break;
5332 case"object":
5333 if (e instanceof Map && e.has(this.title)) return e.get(this.title);
5334 if (e.hasOwnProperty(this.title)) return e[this.title];
5335 break;
5336 case"function":
5337 var r = e.call(this);
5338 if (r) return r;
5339 break;
5340 default:
5341 throw new TypeError("Config.passages.descriptions must be a boolean, object, or function")
5342 }
5343 return null === this._excerpt && (this._excerpt = t.getExcerptFromText(this.text)), this._excerpt
5344 }
5345 }, {
5346 key: "processText", value: function () {
5347 var e = this.text;
5348 return (Config.passages.nobr || this.tags.includes("nobr")) && (e = e.replace(/^\n+|\n+$/g, "").replace(/\n+/g, " ")), this.tags.includes("Twine.image") && (e = "[img[" + e + "]]"), e
5349 }
5350 }, {
5351 key: "render", value: function () {
5352 var e = this, r = this.tags.length > 0 ? this.tags.join(" ") : null,
5353 n = document.createElement("div");
5354 return jQuery(n).attr({
5355 id: this.domId,
5356 "data-passage": this.title,
5357 "data-tags": r
5358 }).addClass("passage " + this.className), jQuery(document.body).attr("data-tags", r).addClass(this.className), jQuery(document.documentElement).attr("data-tags", r), jQuery.event.trigger({
5359 type: ":passagestart",
5360 content: n,
5361 passage: this
5362 }), Object.keys(prerender).forEach(function (t) {
5363 "function" == typeof prerender[t] && prerender[t].call(e, n, t)
5364 }), Story.has("PassageHeader") && new Wikifier(n, Story.get("PassageHeader").processText()), new Wikifier(n, this.processText()), Story.has("PassageFooter") && new Wikifier(n, Story.get("PassageFooter").processText()), jQuery.event.trigger({
5365 type: ":passagerender",
5366 content: n,
5367 passage: this
5368 }), Object.keys(postrender).forEach(function (t) {
5369 "function" == typeof postrender[t] && postrender[t].call(e, n, t)
5370 }), this._excerpt = t.getExcerptFromNode(n), n
5371 }
5372 }, {
5373 key: "className", get: function () {
5374 return this.classes.join(" ")
5375 }
5376 }, {
5377 key: "text", get: function () {
5378 if (null == this.element) {
5379 var e = Util.escape(this.title);
5380 return '<span class="error" title="' + e + '">' + L10n.get("errorTitle") + ": " + L10n.get("errorNonexistentPassage", {passage: e}) + "</span>"
5381 }
5382 return this.element.textContent.replace(/\r/g, "")
5383 }
5384 }], [{
5385 key: "getExcerptFromNode", value: function (e, t) {
5386 if (!e.hasChildNodes()) return "";
5387 var r = e.textContent.trim();
5388 if ("" !== r) {
5389 var n = new RegExp("(\\S+(?:\\s+\\S+){0," + (t > 0 ? t - 1 : 7) + "})");
5390 r = r.replace(/\s+/g, " ").match(n)
5391 }
5392 return r ? r[1] + "…" : "…"
5393 }
5394 }, {
5395 key: "getExcerptFromText", value: function (e, t) {
5396 if ("" === e) return "";
5397 var r = new RegExp("(\\S+(?:\\s+\\S+){0," + (t > 0 ? t - 1 : 7) + "})"),
5398 n = e.replace(/<<.*?>>/g, " ").replace(/<.*?>/g, " ").trim().replace(/^\s*\|.*\|.*?$/gm, "").replace(/\[[<>]?img\[[^\]]*\]\]/g, "").replace(/\[\[([^|\]]*)(?:|[^\]]*)?\]\]/g, "$1").replace(/^\s*!+(.*?)$/gm, "$1").replace(/'{2}|\/{2}|_{2}|@{2}/g, "").trim().replace(/\s+/g, " ").match(r);
5399 return n ? n[1] + "…" : "…"
5400 }
5401 }]), t
5402 }();
5403 return t
5404 }(), Save = function () {
5405 function e() {
5406 if ("cookie" === storage.name) return n(), Config.saves.autosave = undefined, Config.saves.slots = 0, !1;
5407 Config.saves.slots = Math.max(0, Config.saves.slots), Number.isSafeInteger(Config.saves.slots) || (Config.saves.slots = 8);
5408 var e = r(), t = !1;
5409 Array.isArray(e) && (e = {
5410 autosave: null,
5411 slots: e
5412 }, t = !0), Config.saves.slots !== e.slots.length && (Config.saves.slots < e.slots.length ? (e.slots.reverse(), e.slots = e.slots.filter(function (e) {
5413 return !(null === e && this.count > 0) || (--this.count, !1)
5414 }, {count: e.slots.length - Config.saves.slots}), e.slots.reverse()) : Config.saves.slots > e.slots.length && x(e.slots, Config.saves.slots - e.slots.length), t = !0), O(e.autosave) && (t = !0);
5415 for (var a = 0; a < e.slots.length; ++a) O(e.slots[a]) && (t = !0);
5416 return j(e) && (storage.delete("saves"), t = !1), t && C(e), P = e.slots.length - 1, !0
5417 }
5418
5419 function t() {
5420 return {autosave: null, slots: x([], Config.saves.slots)}
5421 }
5422
5423 function r() {
5424 var e = storage.get("saves");
5425 return null === e ? t() : e
5426 }
5427
5428 function n() {
5429 return storage.delete("saves"), !0
5430 }
5431
5432 function a() {
5433 return i() || d()
5434 }
5435
5436 function i() {
5437 return "cookie" !== storage.name && "undefined" != typeof Config.saves.autosave
5438 }
5439
5440 function o() {
5441 var e = r();
5442 return null !== e.autosave
5443 }
5444
5445 function s() {
5446 var e = r();
5447 return e.autosave
5448 }
5449
5450 function u() {
5451 var e = r();
5452 return null !== e.autosave && T(e.autosave)
5453 }
5454
5455 function l(e, t) {
5456 if ("function" == typeof Config.saves.isAllowed && !Config.saves.isAllowed()) return !1;
5457 var n = r(), a = {title: e || Story.get(State.passage).description(), date: Date.now()};
5458 return null != t && (a.metadata = t), n.autosave = A(a), C(n)
5459 }
5460
5461 function c() {
5462 var e = r();
5463 return e.autosave = null, C(e)
5464 }
5465
5466 function d() {
5467 return "cookie" !== storage.name && P !== -1
5468 }
5469
5470 function f() {
5471 return P + 1
5472 }
5473
5474 function p() {
5475 if (!d()) return 0;
5476 for (var e = r(), t = 0, n = 0, a = e.slots.length; n < a; ++n) null !== e.slots[n] && ++t;
5477 return t
5478 }
5479
5480 function h() {
5481 return 0 === p()
5482 }
5483
5484 function g(e) {
5485 if (e < 0 || e > P) return !1;
5486 var t = r();
5487 return !(e >= t.slots.length || null === t.slots[e])
5488 }
5489
5490 function m(e) {
5491 if (e < 0 || e > P) return null;
5492 var t = r();
5493 return e >= t.slots.length ? null : t.slots[e]
5494 }
5495
5496 function y(e) {
5497 if (e < 0 || e > P) return !1;
5498 var t = r();
5499 return !(e >= t.slots.length || null === t.slots[e]) && T(t.slots[e])
5500 }
5501
5502 function v(e, t, n) {
5503 if ("function" == typeof Config.saves.isAllowed && !Config.saves.isAllowed()) return UI.alert(L10n.get("savesDisallowed")), !1;
5504 if (e < 0 || e > P) return !1;
5505 var a = r();
5506 if (e >= a.slots.length) return !1;
5507 var i = {title: t || Story.get(State.passage).description(), date: Date.now()};
5508 return null != n && (i.metadata = n), a.slots[e] = A(i), C(a)
5509 }
5510
5511 function b(e) {
5512 if (e < 0 || e > P) return !1;
5513 var t = r();
5514 return !(e >= t.slots.length) && (t.slots[e] = null, C(t))
5515 }
5516
5517 function w(e, t) {
5518 function r() {
5519 var e = new Date, t = e.getMonth() + 1, r = e.getDate(), n = e.getHours(), a = e.getMinutes(),
5520 i = e.getSeconds();
5521 return t < 10 && (t = "0" + t), r < 10 && (r = "0" + r), n < 10 && (n = "0" + n), a < 10 && (a = "0" + a), i < 10 && (i = "0" + i), "" + e.getFullYear() + t + r + "-" + n + a + i
5522 }
5523
5524 if ("function" == typeof Config.saves.isAllowed && !Config.saves.isAllowed()) return void UI.alert(L10n.get("savesDisallowed"));
5525 var n = null == e ? Story.domId : Util.slugify(e), a = n + "-" + r() + ".save",
5526 i = null == t ? {} : {metadata: t}, o = LZString.compressToBase64(JSON.stringify(A(i)));
5527 saveAs(new Blob([o], {type: "text/plain;charset=UTF-8"}), a)
5528 }
5529
5530 function k(e) {
5531 var t = e.target.files[0], r = new FileReader;
5532 jQuery(r).on("load", function (e) {
5533 var r = e.currentTarget;
5534 if (r.result) {
5535 var n = void 0;
5536 try {
5537 n = JSON.parse(/\.json$/i.test(t.name) || /^\{/.test(r.result) ? r.result : LZString.decompressFromBase64(r.result))
5538 } catch (e) {
5539 }
5540 T(n)
5541 }
5542 }), r.readAsText(t)
5543 }
5544
5545 function S(e) {
5546 if ("function" == typeof Config.saves.isAllowed && !Config.saves.isAllowed()) return UI.alert(L10n.get("savesDisallowed")), null;
5547 var t = null == e ? {} : {metadata: e};
5548 return LZString.compressToBase64(JSON.stringify(A(t)))
5549 }
5550
5551 function E(e) {
5552 var t = void 0;
5553 try {
5554 t = JSON.parse(LZString.decompressFromBase64(e))
5555 } catch (e) {
5556 }
5557 return T(t) ? t.metadata : null
5558 }
5559
5560 function x(e, t) {
5561 for (var r = 0; r < t; ++r) e.push(null);
5562 return e
5563 }
5564
5565 function j(e) {
5566 for (var t = e.slots, r = !0, n = 0, a = t.length; n < a; ++n) if (null !== t[n]) {
5567 r = !1;
5568 break
5569 }
5570 return null === e.autosave && r
5571 }
5572
5573 function C(e) {
5574 return j(e) ? (storage.delete("saves"), !0) : storage.set("saves", e)
5575 }
5576
5577 function O(e) {
5578 if (null == e || "object" !== ("undefined" == typeof e ? "undefined" : _typeof(e))) return !1;
5579 var t = !1;
5580 return e.hasOwnProperty("state") && e.state.hasOwnProperty("delta") && e.state.hasOwnProperty("index") || (e.hasOwnProperty("data") ? (delete e.mode, e.state = {delta: State.deltaEncode(e.data)}, delete e.data) : e.state.hasOwnProperty("delta") ? e.state.hasOwnProperty("index") || delete e.state.mode : (delete e.state.mode, e.state.delta = State.deltaEncode(e.state.history), delete e.state.history), e.state.index = e.state.delta.length - 1, t = !0), e.state.hasOwnProperty("rseed") && (e.state.seed = e.state.rseed, delete e.state.rseed, e.state.delta.forEach(function (e, t, r) {
5581 r[t].hasOwnProperty("rcount") && (r[t].pull = r[t].rcount, delete r[t].rcount)
5582 }), t = !0), (e.state.hasOwnProperty("expired") && "number" == typeof e.state.expired || e.state.hasOwnProperty("unique") || e.state.hasOwnProperty("last")) && (e.state.hasOwnProperty("expired") && "number" == typeof e.state.expired && delete e.state.expired, (e.state.hasOwnProperty("unique") || e.state.hasOwnProperty("last")) && (e.state.expired = [], e.state.hasOwnProperty("unique") && (e.state.expired.push(e.state.unique), delete e.state.unique), e.state.hasOwnProperty("last") && (e.state.expired.push(e.state.last), delete e.state.last)), t = !0), t
5583 }
5584
5585 function A(e) {
5586 if (null != e && "object" !== ("undefined" == typeof e ? "undefined" : _typeof(e))) throw new Error("supplemental parameter must be an object");
5587 var t = Object.assign({}, e, {id: Config.saves.id, state: State.marshalForSave()});
5588 return Config.saves.version && (t.version = Config.saves.version), "function" == typeof Config.saves.onSave && Config.saves.onSave(t), t.state.delta = State.deltaEncode(t.state.history), delete t.state.history, t
5589 }
5590
5591 function T(e) {
5592 try {
5593 if (O(e), !e || !e.hasOwnProperty("id") || !e.hasOwnProperty("state")) throw new Error(L10n.get("errorSaveMissingData"));
5594 if (e.state.history = State.deltaDecode(e.state.delta), delete e.state.delta, "function" == typeof Config.saves.onLoad && Config.saves.onLoad(e), e.id !== Config.saves.id) throw new Error(L10n.get("errorSaveIdMismatch"));
5595 State.unmarshalForSave(e.state), Engine.show()
5596 } catch (e) {
5597 return UI.alert(e.message.toUpperFirst() + ".</p><p>" + L10n.get("aborting") + "."), !1
5598 }
5599 return !0
5600 }
5601
5602 var P = -1;
5603 return Object.freeze(Object.defineProperties({}, {
5604 init: {value: e},
5605 get: {value: r},
5606 clear: {value: n},
5607 ok: {value: a},
5608 autosave: {
5609 value: Object.freeze(Object.defineProperties({}, {
5610 ok: {value: i},
5611 has: {value: o},
5612 get: {value: s},
5613 load: {value: u},
5614 save: {value: l},
5615 delete: {value: c}
5616 }))
5617 },
5618 slots: {
5619 value: Object.freeze(Object.defineProperties({}, {
5620 ok: {value: d},
5621 length: {get: f},
5622 isEmpty: {value: h},
5623 count: {value: p},
5624 has: {value: g},
5625 get: {value: m},
5626 load: {value: y},
5627 save: {value: v},
5628 delete: {value: b}
5629 }))
5630 },
5631 export: {value: w},
5632 import: {value: k},
5633 serialize: {value: S},
5634 deserialize: {value: E}
5635 }))
5636 }(), Setting = function () {
5637 function e() {
5638 if (storage.has("options")) {
5639 var e = storage.get("options");
5640 null !== e && (window.SugarCube.settings = settings = Object.assign(t(), e)), r(), storage.delete("options")
5641 }
5642 n(), g.forEach(function (e) {
5643 if (e.hasOwnProperty("onInit")) {
5644 var t = {name: e.name, value: settings[e.name], default: e.default};
5645 e.hasOwnProperty("list") && (t.list = e.list), e.onInit.call(t)
5646 }
5647 })
5648 }
5649
5650 function t() {
5651 return Object.create(null)
5652 }
5653
5654 function r() {
5655 var e = t();
5656 return Object.keys(settings).length > 0 && g.filter(function (e) {
5657 return e.type !== m.Header && settings[e.name] !== e.default
5658 }).forEach(function (t) {
5659 return e[t.name] = settings[t.name]
5660 }), 0 === Object.keys(e).length ? (storage.delete("settings"), !0) : storage.set("settings", e)
5661 }
5662
5663 function n() {
5664 var e = t(), r = storage.get("settings") || t();
5665 g.filter(function (e) {
5666 return e.type !== m.Header
5667 }).forEach(function (t) {
5668 return e[t.name] = t.default
5669 }), window.SugarCube.settings = settings = Object.assign(e, r)
5670 }
5671
5672 function a() {
5673 return window.SugarCube.settings = settings = t(), storage.delete("settings"), !0
5674 }
5675
5676 function i(e) {
5677 if (0 === arguments.length) a(), n(); else {
5678 if (null == e || !f(e)) throw new Error('nonexistent setting "' + e + '"');
5679 var t = p(e);
5680 t.type !== m.Header && (settings[e] = t.default)
5681 }
5682 return r()
5683 }
5684
5685 function o(e, t) {
5686 g.forEach(e, t)
5687 }
5688
5689 function s(e, t, r) {
5690 if (arguments.length < 3) {
5691 var n = [];
5692 throw arguments.length < 1 && n.push("type"), arguments.length < 2 && n.push("name"), arguments.length < 3 && n.push("definition"), new Error("missing parameters, no " + n.join(" or ") + " specified")
5693 }
5694 if ("object" !== ("undefined" == typeof r ? "undefined" : _typeof(r))) throw new TypeError("definition parameter must be an object");
5695 if (f(t)) throw new Error('cannot clobber existing setting "' + t + '"');
5696 var a = {type: e, name: t, label: null == r.label ? "" : String(r.label).trim()};
5697 switch (e) {
5698 case m.Header:
5699 break;
5700 case m.Toggle:
5701 a.default = !!r.default;
5702 break;
5703 case m.List:
5704 if (!r.hasOwnProperty("list")) throw new Error("no list specified");
5705 if (!Array.isArray(r.list)) throw new TypeError("list must be an array");
5706 if (0 === r.list.length) throw new Error("list must not be empty");
5707 if (a.list = Object.freeze(r.list), null == r.default) a.default = r.list[0]; else {
5708 var i = r.list.indexOf(r.default);
5709 if (i === -1) throw new Error("list does not contain default");
5710 a.default = r.list[i]
5711 }
5712 break;
5713 default:
5714 throw new Error("unknown Setting type: " + e)
5715 }
5716 "function" == typeof r.onInit && (a.onInit = Object.freeze(r.onInit)), "function" == typeof r.onChange && (a.onChange = Object.freeze(r.onChange)), g.push(Object.freeze(a))
5717 }
5718
5719 function u(e, t) {
5720 s(m.Header, e, {label: t})
5721 }
5722
5723 function l() {
5724 for (var e = arguments.length, t = Array(e), r = 0; r < e; r++) t[r] = arguments[r];
5725 s.apply(undefined, [m.Toggle].concat(t))
5726 }
5727
5728 function c() {
5729 for (var e = arguments.length, t = Array(e), r = 0; r < e; r++) t[r] = arguments[r];
5730 s.apply(undefined, [m.List].concat(t))
5731 }
5732
5733 function d() {
5734 return 0 === g.length
5735 }
5736
5737 function f(e) {
5738 return g.some(function (t) {
5739 return t.name === e
5740 })
5741 }
5742
5743 function p(e) {
5744 return g.find(function (t) {
5745 return t.name === e
5746 })
5747 }
5748
5749 function h(e) {
5750 f(e) && delete settings[e];
5751 for (var t = 0; t < g.length; ++t) if (g[t].name === e) {
5752 g.splice(t, 1), h(e);
5753 break
5754 }
5755 }
5756
5757 var g = [], m = Util.toEnum({Header: 0, Toggle: 1, List: 2});
5758 return Object.freeze(Object.defineProperties({}, {
5759 Types: {value: m},
5760 init: {value: e},
5761 create: {value: t},
5762 save: {value: r},
5763 load: {value: n},
5764 clear: {value: a},
5765 reset: {value: i},
5766 forEach: {value: o},
5767 add: {value: s},
5768 addHeader: {value: u},
5769 addToggle: {value: l},
5770 addList: {value: c},
5771 isEmpty: {value: d},
5772 has: {value: f},
5773 get: {value: p},
5774 delete: {value: h}
5775 }))
5776 }(), State = function () {
5777 function e() {
5778 session.delete("state"), I = [], L = c(), Q = -1, W = [], R = null === R ? null : new PRNGWrapper(R.seed, !1)
5779 }
5780
5781 function t() {
5782 if (session.has("state")) {
5783 var e = session.get("state");
5784 return null != e && (n(e), !0)
5785 }
5786 return !1
5787 }
5788
5789 function r(e) {
5790 var t = {index: Q};
5791 return e ? t.history = clone(I) : t.delta = T(I), W.length > 0 && (t.expired = [].concat(_toConsumableArray(W))), null !== R && (t.seed = R.seed), t
5792 }
5793
5794 function n(e, t) {
5795 if (null == e) throw new Error("state object is null or undefined");
5796 if (!e.hasOwnProperty(t ? "history" : "delta") || 0 === e[t ? "history" : "delta"].length) throw new Error("state object has no history or history is empty");
5797 if (!e.hasOwnProperty("index")) throw new Error("state object has no index");
5798 if (null !== R && !e.hasOwnProperty("seed")) throw new Error("state object has no seed, but PRNG is enabled");
5799 if (null === R && e.hasOwnProperty("seed")) throw new Error("state object has seed, but PRNG is disabled");
5800 I = t ? clone(e.history) : P(e.delta), Q = e.index, W = e.hasOwnProperty("expired") ? [].concat(_toConsumableArray(e.expired)) : [], e.hasOwnProperty("seed") && (R.seed = e.seed), g(Q)
5801 }
5802
5803 function a() {
5804 return r(!0)
5805 }
5806
5807 function i(e) {
5808 return n(e, !0)
5809 }
5810
5811 function o() {
5812 return W
5813 }
5814
5815 function s() {
5816 return W.length + y()
5817 }
5818
5819 function u() {
5820 return W.concat(I.slice(0, y()).map(function (e) {
5821 return e.title
5822 }))
5823 }
5824
5825 function l(e) {
5826 return null != e && "" !== e && (!!W.includes(e) || !!I.slice(0, y()).some(function (t) {
5827 return t.title === e
5828 }))
5829 }
5830
5831 function c(e, t) {
5832 return {title: null == e ? "" : String(e), variables: null == t ? {} : clone(t)}
5833 }
5834
5835 function d() {
5836 return L
5837 }
5838
5839 function f() {
5840 return Q
5841 }
5842
5843 function p() {
5844 return L.title
5845 }
5846
5847 function h() {
5848 return L.variables
5849 }
5850
5851 function g(e) {
5852 if (null == e) throw new Error("moment activation attempted with null or undefined");
5853 switch ("undefined" == typeof e ? "undefined" : _typeof(e)) {
5854 case"object":
5855 L = clone(e);
5856 break;
5857 case"number":
5858 if (b()) throw new Error("moment activation attempted with index on empty history");
5859 if (e < 0 || e >= v()) throw new RangeError("moment activation attempted with out-of-bounds index; need [0, " + (v() - 1) + "], got " + e);
5860 L = clone(I[e]);
5861 break;
5862 default:
5863 throw new TypeError('moment activation attempted with a "' + ("undefined" == typeof e ? "undefined" : _typeof(e)) + '"; must be an object or valid history stack index')
5864 }
5865 return null !== R && (R = PRNGWrapper.unmarshal({
5866 seed: R.seed,
5867 pull: L.pull
5868 })), session.set("state", r()), jQuery.event.trigger(":historyupdate"), L
5869 }
5870
5871 function m() {
5872 return I
5873 }
5874
5875 function y() {
5876 return Q + 1
5877 }
5878
5879 function v() {
5880 return I.length
5881 }
5882
5883 function b() {
5884 return 0 === I.length
5885 }
5886
5887 function w() {
5888 return I.length > 0 ? I[Q] : null
5889 }
5890
5891 function k() {
5892 return I.length > 0 ? I[I.length - 1] : null
5893 }
5894
5895 function S() {
5896 return I.length > 0 ? I[0] : null
5897 }
5898
5899 function E(e) {
5900 return b() || e < 0 || e > Q ? null : I[e]
5901 }
5902
5903 function x(e) {
5904 if (b()) return null;
5905 var t = 1 + (e ? Math.abs(e) : 0);
5906 return t > y() ? null : I[y() - t]
5907 }
5908
5909 function j(e) {
5910 if (b() || null == e || "" === e) return !1;
5911 for (var t = Q; t >= 0; --t) if (I[t].title === e) return !0;
5912 return !1
5913 }
5914
5915 function C(e) {
5916 if (y() < v() && I.splice(y(), v() - y()), I.push(c(e, L.variables)), R && (k().pull = R.pull), Config.history.maxStates > 0) for (; v() > Config.history.maxStates;) W.push(I.shift().title);
5917 return Q = v() - 1, g(Q), y()
5918 }
5919
5920 function O(e) {
5921 return !(null == e || e < 0 || e >= v() || e === Q) && (Q = e, g(Q), !0)
5922 }
5923
5924 function A(e) {
5925 return null != e && 0 !== e && O(Q + e)
5926 }
5927
5928 function T(e) {
5929 if (!Array.isArray(e)) return null;
5930 if (0 === e.length) return [];
5931 for (var t = [clone(e[0])], r = 1, n = e.length; r < n; ++r) t.push(Diff.diff(e[r - 1], e[r]));
5932 return t
5933 }
5934
5935 function P(e) {
5936 if (!Array.isArray(e)) return null;
5937 if (0 === e.length) return [];
5938 for (var t = [clone(e[0])], r = 1, n = e.length; r < n; ++r) t.push(Diff.patch(t[r - 1], e[r]));
5939 return t
5940 }
5941
5942 function _(e, t) {
5943 if (!b()) {
5944 var r = void 0;
5945 throw r = "the Story JavaScript", new Error("State.initPRNG must be called during initialization, within either " + r + " or the StoryInit special passage")
5946 }
5947 R = new PRNGWrapper(e, t), L.pull = R.pull
5948 }
5949
5950 function M() {
5951 return R ? R.random() : Math.random()
5952 }
5953
5954 function N() {
5955 F = {}, TempVariables = F
5956 }
5957
5958 function D() {
5959 return F
5960 }
5961
5962 var I = [], L = c(), Q = -1, W = [], R = null, F = {};
5963 return Object.freeze(Object.defineProperties({}, {
5964 reset: {value: e},
5965 restore: {value: t},
5966 marshalForSave: {value: a},
5967 unmarshalForSave: {value: i},
5968 expired: {get: o},
5969 turns: {get: s},
5970 passages: {get: u},
5971 hasPlayed: {value: l},
5972 active: {get: d},
5973 activeIndex: {get: f},
5974 passage: {get: p},
5975 variables: {get: h},
5976 history: {get: m},
5977 length: {get: y},
5978 size: {get: v},
5979 isEmpty: {value: b},
5980 current: {get: w},
5981 top: {get: k},
5982 bottom: {get: S},
5983 index: {value: E},
5984 peek: {value: x},
5985 has: {value: j},
5986 create: {value: C},
5987 goTo: {value: O},
5988 go: {value: A},
5989 deltaEncode: {value: T},
5990 deltaDecode: {value: P},
5991 initPRNG: {value: _},
5992 random: {value: M},
5993 clearTemporary: {value: N},
5994 temporary: {get: D},
5995 restart: {
5996 value: function () {
5997 return Engine.restart()
5998 }
5999 },
6000 backward: {
6001 value: function () {
6002 return Engine.backward()
6003 }
6004 },
6005 forward: {
6006 value: function () {
6007 return Engine.forward()
6008 }
6009 },
6010 display: {
6011 value: function () {
6012 return Engine.display.apply(Engine, arguments)
6013 }
6014 },
6015 show: {
6016 value: function () {
6017 return Engine.show.apply(Engine, arguments)
6018 }
6019 },
6020 play: {
6021 value: function () {
6022 return Engine.play.apply(Engine, arguments)
6023 }
6024 }
6025 }))
6026 }(), Story = function () {
6027 function e() {
6028 function e(e) {
6029 if (e.tags.includesAny(n)) throw new Error('starting passage "' + e.title + '" contains illegal tags; invalid: "' + e.tags.filter(function (e) {
6030 return n.includes(e)
6031 }).sort().join('", "') + '"')
6032 }
6033
6034 function t(e) {
6035 if (a.includes(e.title) && e.tags.includesAny(n)) throw new Error('special passage "' + e.title + '" contains illegal tags; invalid: "' + e.tags.filter(function (e) {
6036 return n.includes(e)
6037 }).sort().join('", "') + '"')
6038 }
6039
6040 var n = ["widget"],
6041 a = ["PassageDone", "PassageFooter", "PassageHeader", "PassageReady", "StoryAuthor", "StoryBanner", "StoryCaption", "StoryInit", "StoryMenu", "StoryShare", "StorySubtitle"];
6042 !function () {
6043 var n = jQuery("#store-area>tw-storydata"), a = n.attr("startnode") || "";
6044 Config.passages.start = null, Config.debug = /\bdebug\b/.test(n.attr("options")), n.children("style").each(function (e) {
6045 d.push(new Passage("tw-user-style-" + e, this))
6046 }), n.children("script").each(function (e) {
6047 f.push(new Passage("tw-user-script-" + e, this))
6048 }), n.children('tw-passagedata:not([tags~="Twine.private"],[tags~="annotation"])').each(function () {
6049 var r = jQuery(this), n = r.attr("pid") || "", i = new Passage(r.attr("name"), this);
6050 n === a && "" !== a ? (Config.passages.start = i.title, e(i), c[i.title] = i) : i.tags.includes("widget") ? p.push(i) : (t(i), c[i.title] = i)
6051 }), g = n.attr("ifid"), r(Util.unescape("Friends of Mine")), Config.saves.id = Story.domId
6052 }()
6053 }
6054
6055 function t() {
6056 !function () {
6057 var e = document.createElement("style");
6058 new StyleWrapper(e).add(d.map(function (e) {
6059 return e.text.trim()
6060 }).join("\n")), jQuery(e).appendTo(document.head).attr({id: "style-story", type: "text/css"})
6061 }();
6062 for (var e = 0; e < f.length; ++e) try {
6063 Scripting.evalJavaScript(f[e].text)
6064 } catch (t) {
6065 console.error(t), Alert.error(f[e].title, "object" === ("undefined" == typeof t ? "undefined" : _typeof(t)) ? t.message : t)
6066 }
6067 for (var t = 0; t < p.length; ++t) try {
6068 Wikifier.wikifyEval(p[t].processText())
6069 } catch (e) {
6070 console.error(e), Alert.error(p[t].title, "object" === ("undefined" == typeof e ? "undefined" : _typeof(e)) ? e.message : e)
6071 }
6072 }
6073
6074 function r(e) {
6075 if (null == e || "" === e) throw new Error("story title cannot be null or empty");
6076 document.title = h = Util.unescape(e), m = Util.slugify(h)
6077 }
6078
6079 function n() {
6080 return h
6081 }
6082
6083 function a() {
6084 return m
6085 }
6086
6087 function i() {
6088 return g
6089 }
6090
6091 function o(e) {
6092 var t = "undefined" == typeof e ? "undefined" : _typeof(e);
6093 switch (t) {
6094 case"number":
6095 case"string":
6096 var r = String(e);
6097 return c.hasOwnProperty(r);
6098 case"boolean":
6099 case"function":
6100 t = "a " + t;
6101 break;
6102 case"undefined":
6103 break;
6104 default:
6105 t = null === e ? "null" : "an " + t
6106 }
6107 throw new TypeError("Story.has title parameter cannot be " + t)
6108 }
6109
6110 function s(e) {
6111 var t = "undefined" == typeof e ? "undefined" : _typeof(e);
6112 switch (t) {
6113 case"number":
6114 case"string":
6115 var r = String(e);
6116 return c.hasOwnProperty(r) ? c[r] : new Passage(r || "(unknown)");
6117 case"boolean":
6118 case"function":
6119 t = "a " + t;
6120 break;
6121 case"undefined":
6122 break;
6123 default:
6124 t = null === e ? "null" : "an " + t
6125 }
6126 throw new TypeError("Story.get title parameter cannot be " + t)
6127 }
6128
6129 function u(e, t) {
6130 for (var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "title", n = Object.keys(c), a = [], i = 0; i < n.length; ++i) {
6131 var o = c[n[i]];
6132 if (o.hasOwnProperty(e)) switch (_typeof(o[e])) {
6133 case"undefined":
6134 break;
6135 case"object":
6136 for (var s = 0, u = o[e].length; s < u; ++s) if (o[e][s] == t) {
6137 a.push(o);
6138 break
6139 }
6140 break;
6141 default:
6142 o[e] == t && a.push(o)
6143 }
6144 }
6145 return a.sort(function (e, t) {
6146 return e[r] == t[r] ? 0 : e[r] < t[r] ? -1 : 1
6147 }), a
6148 }
6149
6150 function l(e) {
6151 var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "title";
6152 if ("function" != typeof e) throw new Error("Story.lookupWith filter parameter must be a function");
6153 for (var r = Object.keys(c), n = [], a = 0; a < r.length; ++a) {
6154 var i = c[r[a]];
6155 e(i) && n.push(i)
6156 }
6157 return n.sort(function (e, r) {
6158 return e[t] == r[t] ? 0 : e[t] < r[t] ? -1 : 1
6159 }), n
6160 }
6161
6162 var c = {}, d = [], f = [], p = [], h = "", g = "", m = "";
6163 return Object.freeze(Object.defineProperties({}, {
6164 passages: {value: c},
6165 styles: {value: d},
6166 scripts: {value: f},
6167 widgets: {value: p},
6168 load: {value: e},
6169 init: {value: t},
6170 title: {get: n},
6171 domId: {get: a},
6172 ifId: {get: i},
6173 has: {value: o},
6174 get: {value: s},
6175 lookup: {value: u},
6176 lookupWith: {value: l}
6177 }))
6178 }(), UI = function () {
6179 function e(e, t) {
6180 var r = t, n = Config.debug;
6181 Config.debug = !1;
6182 try {
6183 null == r && (r = document.createElement("ul"));
6184 var a = document.createDocumentFragment();
6185 new Wikifier(a, Story.get(e).processText().trim());
6186 var i = [].concat(_toConsumableArray(a.querySelectorAll(".error"))).map(function (e) {
6187 return e.textContent.replace(/^(?:(?:Uncaught\s+)?Error:\s+)+/, "")
6188 });
6189 if (i.length > 0) throw new Error(i.join("; "));
6190 for (; a.hasChildNodes();) {
6191 var o = a.firstChild;
6192 if (o.nodeType === Node.ELEMENT_NODE && "A" === o.nodeName.toUpperCase()) {
6193 var s = document.createElement("li");
6194 r.appendChild(s), s.appendChild(o)
6195 } else a.removeChild(o)
6196 }
6197 } finally {
6198 Config.debug = n
6199 }
6200 return r
6201 }
6202
6203 function t(e) {
6204 jQuery(Dialog.setup("Alert", "alert")).append("<p>" + e + '</p><ul class="buttons">' + ('<li><button id="alert-ok" class="ui-close">' + L10n.get(["alertOk", "ok"]) + "</button></li>") + "</ul>");
6205 for (var t = arguments.length, r = Array(t > 1 ? t - 1 : 0), n = 1; n < t; n++) r[n - 1] = arguments[n];
6206 Dialog.open.apply(Dialog, r)
6207 }
6208
6209 function r() {
6210 u(), Dialog.open.apply(Dialog, arguments)
6211 }
6212
6213 function n() {
6214 l(), Dialog.open.apply(Dialog, arguments)
6215 }
6216
6217 function a() {
6218 c(), Dialog.open.apply(Dialog, arguments)
6219 }
6220
6221 function i() {
6222 d(), Dialog.open.apply(Dialog, arguments)
6223 }
6224
6225 function o() {
6226 f(), Dialog.open.apply(Dialog, arguments)
6227 }
6228
6229 function s() {
6230 return jQuery(Dialog.setup(L10n.get("autoloadTitle"), "autoload")).append("<p>" + L10n.get("autoloadPrompt") + '</p><ul class="buttons">' + ('<li><button id="autoload-ok" class="ui-close">' + L10n.get(["autoloadOk", "ok"]) + "</button></li>") + ('<li><button id="autoload-cancel" class="ui-close">' + L10n.get(["autoloadCancel", "cancel"]) + "</button></li>") + "</ul>"), jQuery(document).one("click.autoload", ".ui-close", function (e) {
6231 var t = "autoload-ok" === e.target.id;
6232 jQuery(document).one(":dialogclose", function () {
6233 t && Save.autosave.load() || Engine.play(Config.passages.start)
6234 })
6235 }), !0
6236 }
6237
6238 function u() {
6239 var e = document.createElement("ul");
6240 jQuery(Dialog.setup(L10n.get("jumptoTitle"), "jumpto list")).append(e);
6241 for (var t = State.expired.length, r = State.size - 1; r >= 0; --r) if (r !== State.activeIndex) {
6242 var n = Story.get(State.history[r].title);
6243 n && n.tags.includes("bookmark") && jQuery(document.createElement("li")).append(jQuery(document.createElement("a")).ariaClick({one: !0}, function (e) {
6244 return function () {
6245 return jQuery(document).one(":dialogclose", function () {
6246 return Engine.goTo(e)
6247 })
6248 }
6249 }(r)).addClass("ui-close").text(L10n.get("jumptoTurn") + " " + (t + r + 1) + ": " + n.description())).appendTo(e)
6250 }
6251 e.hasChildNodes() || jQuery(e).append("<li><a><em>" + L10n.get("jumptoUnavailable") + "</em></a></li>")
6252 }
6253
6254 function l() {
6255 return jQuery(Dialog.setup(L10n.get("restartTitle"), "restart")).append("<p>" + L10n.get("restartPrompt") + '</p><ul class="buttons">' + ('<li><button id="restart-ok">' + L10n.get(["restartOk", "ok"]) + "</button></li>") + ('<li><button id="restart-cancel" class="ui-close">' + L10n.get(["restartCancel", "cancel"]) + "</button></li>") + "</ul>").find("#restart-ok").ariaClick({one: !0}, function () {
6256 jQuery(document).one(":dialogclose", function () {
6257 return Engine.restart()
6258 }), Dialog.close()
6259 }), !0
6260 }
6261
6262 function c() {
6263 function e(e, t, r, n) {
6264 var a = jQuery(document.createElement("button")).attr("id", "saves-" + e).html(r);
6265 return t && a.addClass(t), n ? a.ariaClick(n) : a.prop("disabled", !0), jQuery(document.createElement("li")).append(a)
6266 }
6267
6268 function r() {
6269 function e(e, t, r, n, a) {
6270 var i = jQuery(document.createElement("button")).attr("id", "saves-" + e + "-" + n).addClass(e).html(r);
6271 return t && i.addClass(t), a ? "auto" === n ? i.ariaClick({label: r + " " + L10n.get("savesLabelAuto")}, function () {
6272 return a()
6273 }) : i.ariaClick({label: r + " " + L10n.get("savesLabelSlot") + " " + (n + 1)}, function () {
6274 return a(n)
6275 }) : i.prop("disabled", !0), i
6276 }
6277
6278 var t = Save.get(), r = jQuery(document.createElement("tbody"));
6279 if (Save.autosave.ok()) {
6280 var n = jQuery(document.createElement("td")), a = jQuery(document.createElement("td")),
6281 i = jQuery(document.createElement("td")), o = jQuery(document.createElement("td"));
6282 jQuery(document.createElement("b")).attr({
6283 title: L10n.get("savesLabelAuto"),
6284 "aria-label": L10n.get("savesLabelAuto")
6285 }).text("A").appendTo(n), t.autosave ? (a.append(e("load", "ui-close", L10n.get("savesLabelLoad"), "auto", function () {
6286 jQuery(document).one(":dialogclose", function () {
6287 return Save.autosave.load()
6288 })
6289 })), jQuery(document.createElement("div")).text(t.autosave.title).appendTo(i), jQuery(document.createElement("div")).addClass("datestamp").html(t.autosave.date ? L10n.get("savesSavedOn") + " " + new Date(t.autosave.date).toLocaleString() : L10n.get("savesSavedOn") + " <em>" + L10n.get("savesUnknownDate") + "</em>").appendTo(i), o.append(e("delete", null, L10n.get("savesLabelDelete"), "auto", function () {
6290 Save.autosave.delete(), c()
6291 }))) : (a.append(e("load", null, L10n.get("savesLabelLoad"), "auto")), jQuery(document.createElement("em")).text(L10n.get("savesEmptySlot")).appendTo(i), i.addClass("empty"), o.append(e("delete", null, L10n.get("savesLabelDelete"), "auto"))), jQuery(document.createElement("tr")).append(n).append(a).append(i).append(o).appendTo(r)
6292 }
6293 for (var s = 0, u = t.slots.length; s < u; ++s) {
6294 var l = jQuery(document.createElement("td")), d = jQuery(document.createElement("td")),
6295 f = jQuery(document.createElement("td")), p = jQuery(document.createElement("td"));
6296 l.append(document.createTextNode(s + 1)), t.slots[s] ? (d.append(e("load", "ui-close", L10n.get("savesLabelLoad"), s, function (e) {
6297 jQuery(document).one(":dialogclose", function () {
6298 return Save.slots.load(e)
6299 })
6300 })), jQuery(document.createElement("div")).text(t.slots[s].title).appendTo(f), jQuery(document.createElement("div")).addClass("datestamp").html(t.slots[s].date ? L10n.get("savesSavedOn") + " " + new Date(t.slots[s].date).toLocaleString() : L10n.get("savesSavedOn") + " <em>" + L10n.get("savesUnknownDate") + "</em>").appendTo(f), p.append(e("delete", null, L10n.get("savesLabelDelete"), s, function (e) {
6301 Save.slots.delete(e), c()
6302 }))) : (d.append(e("save", "ui-close", L10n.get("savesLabelSave"), s, Save.slots.save)), jQuery(document.createElement("em")).text(L10n.get("savesEmptySlot")).appendTo(f), f.addClass("empty"), p.append(e("delete", null, L10n.get("savesLabelDelete"), s))), jQuery(document.createElement("tr")).append(l).append(d).append(f).append(p).appendTo(r)
6303 }
6304 return jQuery(document.createElement("table")).attr("id", "saves-list").append(r)
6305 }
6306
6307 var n = jQuery(Dialog.setup(L10n.get("savesTitle"), "saves")), a = Save.ok();
6308 if (a && n.append(r()), a || Has.fileAPI) {
6309 var i = jQuery(document.createElement("ul")).addClass("buttons").appendTo(n);
6310 return Has.fileAPI && (i.append(e("export", "ui-close", L10n.get("savesLabelExport"), function () {
6311 return Save.export()
6312 })), i.append(e("import", null, L10n.get("savesLabelImport"), function () {
6313 return n.find("#saves-import-file").trigger("click")
6314 })), jQuery(document.createElement("input")).css({
6315 display: "block",
6316 visibility: "hidden",
6317 position: "fixed",
6318 left: "-9999px",
6319 top: "-9999px",
6320 width: "1px",
6321 height: "1px"
6322 }).attr({
6323 type: "file",
6324 id: "saves-import-file",
6325 tabindex: -1,
6326 "aria-hidden": !0
6327 }).on("change", function (e) {
6328 jQuery(document).one(":dialogclose", function () {
6329 return Save.import(e)
6330 }), Dialog.close()
6331 }).appendTo(n)), a && i.append(e("clear", null, L10n.get("savesLabelClear"), Save.autosave.has() || !Save.slots.isEmpty() ? function () {
6332 Save.clear(), c()
6333 } : null)), !0
6334 }
6335 return t(L10n.get("savesIncapable")), !1
6336 }
6337
6338 function d() {
6339 var e = jQuery(Dialog.setup(L10n.get("settingsTitle"), "settings"));
6340 return Setting.forEach(function (t) {
6341 if (t.type === Setting.Types.Header) {
6342 var r = t.name, n = Util.slugify(r), a = jQuery(document.createElement("div")),
6343 i = jQuery(document.createElement("h2")), o = jQuery(document.createElement("p"));
6344 return a.attr("id", "header-body-" + n).append(i).append(o).appendTo(e), i.attr("id", "header-heading-" + n).wiki(r), void o.attr("id", "header-label-" + n).wiki(t.label)
6345 }
6346 var s = t.name, u = Util.slugify(s), l = jQuery(document.createElement("div")),
6347 c = jQuery(document.createElement("label")), d = jQuery(document.createElement("div")),
6348 f = void 0;
6349 switch (l.attr("id", "setting-body-" + u).append(c).append(d).appendTo(e), c.attr({
6350 id: "setting-label-" + u,
6351 for: "setting-control-" + u
6352 }).wiki(t.label), null == settings[s] && (settings[s] = t.default), t.type) {
6353 case Setting.Types.Toggle:
6354 f = jQuery(document.createElement("button")), settings[s] ? f.addClass("enabled").text(L10n.get("settingsOn")) : f.text(L10n.get("settingsOff")), f.ariaClick(function () {
6355 settings[s] ? (jQuery(this).removeClass("enabled").text(L10n.get("settingsOff")), settings[s] = !1) : (jQuery(this).addClass("enabled").text(L10n.get("settingsOn")), settings[s] = !0), Setting.save(), t.hasOwnProperty("onChange") && t.onChange.call({
6356 name: s,
6357 value: settings[s],
6358 default: t.default
6359 })
6360 });
6361 break;
6362 case Setting.Types.List:
6363 f = jQuery(document.createElement("select"));
6364 for (var p = 0, h = t.list.length; p < h; ++p) jQuery(document.createElement("option")).val(p).text(t.list[p]).appendTo(f);
6365 f.val(t.list.indexOf(settings[s])).attr("tabindex", 0).on("change", function () {
6366 settings[s] = t.list[Number(this.value)], Setting.save(), t.hasOwnProperty("onChange") && t.onChange.call({
6367 name: s,
6368 value: settings[s],
6369 default: t.default,
6370 list: t.list
6371 })
6372 })
6373 }
6374 f.attr("id", "setting-control-" + u).appendTo(d)
6375 }), e.append('<ul class="buttons">' + ('<li><button id="settings-ok" class="ui-close">' + L10n.get(["settingsOk", "ok"]) + "</button></li>") + ('<li><button id="settings-reset">' + L10n.get("settingsReset") + "</button></li>") + "</ul>").find("#settings-reset").ariaClick({one: !0}, function () {
6376 jQuery(document).one(":dialogclose", function () {
6377 Setting.reset(), window.location.reload()
6378 }), Dialog.close()
6379 }), !0
6380 }
6381
6382 function f() {
6383 try {
6384 jQuery(Dialog.setup(L10n.get("shareTitle"), "share list")).append(e("StoryShare"))
6385 } catch (e) {
6386 return console.error(e), Alert.error("StoryShare", e.message), !1
6387 }
6388 return !0
6389 }
6390
6391 return Object.freeze(Object.defineProperties({}, {
6392 assembleLinkList: {value: e},
6393 alert: {value: t},
6394 jumpto: {value: r},
6395 restart: {value: n},
6396 saves: {value: a},
6397 settings: {value: i},
6398 share: {value: o},
6399 buildAutoload: {value: s},
6400 buildJumpto: {value: u},
6401 buildRestart: {value: l},
6402 buildSaves: {value: c},
6403 buildSettings: {value: d},
6404 buildShare: {value: f},
6405 stow: {
6406 value: function () {
6407 return UIBar.stow()
6408 }
6409 },
6410 unstow: {
6411 value: function () {
6412 return UIBar.unstow()
6413 }
6414 },
6415 setStoryElements: {
6416 value: function () {
6417 return UIBar.setStoryElements()
6418 }
6419 },
6420 isOpen: {
6421 value: function () {
6422 return Dialog.isOpen.apply(Dialog, arguments)
6423 }
6424 },
6425 body: {
6426 value: function () {
6427 return Dialog.body()
6428 }
6429 },
6430 setup: {
6431 value: function () {
6432 return Dialog.setup.apply(Dialog, arguments)
6433 }
6434 },
6435 addClickHandler: {
6436 value: function () {
6437 return Dialog.addClickHandler.apply(Dialog, arguments)
6438 }
6439 },
6440 open: {
6441 value: function () {
6442 return Dialog.open.apply(Dialog, arguments)
6443 }
6444 },
6445 close: {
6446 value: function () {
6447 return Dialog.close.apply(Dialog, arguments)
6448 }
6449 },
6450 resize: {
6451 value: function () {
6452 return Dialog.resize()
6453 }
6454 },
6455 buildDialogAutoload: {value: s},
6456 buildDialogJumpto: {value: u},
6457 buildDialogRestart: {value: l},
6458 buildDialogSaves: {value: c},
6459 buildDialogSettings: {value: d},
6460 buildDialogShare: {value: f},
6461 buildLinkListFromPassage: {value: e}
6462 }))
6463 }(), UIBar = function () {
6464 function e() {
6465 o || document.getElementById("ui-bar") || (!function () {
6466 var e = L10n.get("uiBarToggle"), t = L10n.get("uiBarBackward"), r = L10n.get("uiBarJumpto"),
6467 n = L10n.get("uiBarForward");
6468 jQuery(document.createDocumentFragment()).append('<div id="ui-bar"><div id="ui-bar-tray">' + ('<button id="ui-bar-toggle" tabindex="0" title="' + e + '" aria-label="' + e + '"></button>') + '<div id="ui-bar-history">' + ('<button id="history-backward" tabindex="0" title="' + t + '" aria-label="' + t + '"></button>') + ('<button id="history-jumpto" tabindex="0" title="' + r + '" aria-label="' + r + '"></button>') + ('<button id="history-forward" tabindex="0" title="' + n + '" aria-label="' + n + '"></button>') + '</div></div><div id="ui-bar-body"><header id="title" role="banner"><div id="story-banner"></div><h1 id="story-title"></h1><div id="story-subtitle"></div><div id="story-title-separator"></div><p id="story-author"></p></header><div id="story-caption"></div><nav id="menu" role="navigation"><ul id="menu-story"></ul><ul id="menu-core">' + ('<li id="menu-item-saves"><a tabindex="0">' + L10n.get("savesTitle") + "</a></li>") + ('<li id="menu-item-settings"><a tabindex="0">' + L10n.get("settingsTitle") + "</a></li>") + ('<li id="menu-item-restart"><a tabindex="0">' + L10n.get("restartTitle") + "</a></li>") + ('<li id="menu-item-share"><a tabindex="0">' + L10n.get("shareTitle") + "</a></li>") + "</ul></nav></div></div>").insertBefore("#store-area")
6469 }(), jQuery(document).on(":historyupdate.ui-bar", function (e, t) {
6470 return function () {
6471 e.prop("disabled", State.length < 2), t.prop("disabled", State.length === State.size)
6472 }
6473 }(jQuery("#history-backward"), jQuery("#history-forward"))))
6474 }
6475
6476 function t() {
6477 if (!o) {
6478 var e = jQuery("#ui-bar");
6479 ("boolean" == typeof Config.ui.stowBarInitially ? Config.ui.stowBarInitially : jQuery(window).width() <= Config.ui.stowBarInitially) && !function () {
6480 var t = jQuery(e).add("#story");
6481 t.addClass("no-transition"), e.addClass("stowed"), setTimeout(function () {
6482 return t.removeClass("no-transition")
6483 }, Engine.minDomActionDelay)
6484 }(), jQuery("#ui-bar-toggle").ariaClick({label: L10n.get("uiBarToggle")}, function () {
6485 return e.toggleClass("stowed")
6486 }), Config.history.controls ? (jQuery("#history-backward").prop("enabled", State.length < 2).ariaClick({label: L10n.get("uiBarBackward")}, function () {
6487 return Engine.backward()
6488 }), Story.lookup("tags", "bookmark").length > 0 ? jQuery("#history-jumpto").ariaClick({label: L10n.get("uiBarJumpto")}, function () {
6489 return UI.jumpto()
6490 }) : jQuery("#history-jumpto").remove(), jQuery("#history-forward").prop("disabled", State.length === State.size).ariaClick({label: L10n.get("uiBarForward")}, function () {
6491 return Engine.forward()
6492 })) : jQuery("#ui-bar-history").remove(), jQuery("#story-title").text(Story.title), Story.has("StoryCaption") || jQuery("#story-caption").remove(), Story.has("StoryMenu") || jQuery("#menu-story").remove(), Config.ui.updateStoryElements || i(), Dialog.addClickHandler("#menu-item-saves a", null, UI.buildSaves).text(L10n.get("savesTitle")), Setting.isEmpty() ? jQuery("#menu-item-settings").remove() : Dialog.addClickHandler("#menu-item-settings a", null, UI.buildSettings).text(L10n.get("settingsTitle")), Dialog.addClickHandler("#menu-item-restart a", null, UI.buildRestart).text(L10n.get("restartTitle")), Story.has("StoryShare") ? Dialog.addClickHandler("#menu-item-share a", null, UI.buildShare).text(L10n.get("shareTitle")) : jQuery("#menu-item-share").remove()
6493 }
6494 }
6495
6496 function r() {
6497 o || (jQuery(document).off(".ui-bar"), jQuery("#ui-bar").remove(), jQuery(document.head).find("#style-ui-bar").remove(), Config.ui.updateStoryElements = !1, o = !0)
6498 }
6499
6500 function n() {
6501 o || jQuery("#ui-bar").addClass("stowed")
6502 }
6503
6504 function a() {
6505 o || jQuery("#ui-bar").removeClass("stowed")
6506 }
6507
6508 function i() {
6509 if (!o) {
6510 setPageElement("story-banner", "StoryBanner"), setPageElement("story-subtitle", "StorySubtitle"), setPageElement("story-author", "StoryAuthor"), setPageElement("story-caption", "StoryCaption");
6511 var e = document.getElementById("menu-story");
6512 if (null !== e && (jQuery(e).empty(), Story.has("StoryMenu"))) try {
6513 UI.assembleLinkList("StoryMenu", e)
6514 } catch (e) {
6515 console.error(e), Alert.error("StoryMenu", e.message)
6516 }
6517 }
6518 }
6519
6520 var o = !1;
6521 return Object.freeze(Object.defineProperties({}, {
6522 init: {value: e},
6523 start: {value: t},
6524 destroy: {value: r},
6525 stow: {value: n},
6526 unstow: {value: a},
6527 setStoryElements: {value: i}
6528 }))
6529 }(), LoadScreen = function () {
6530 function e() {
6531 jQuery(document).on("readystatechange.SugarCube", function () {
6532 o.size > 0 || ("complete" === document.readyState ? "loading" === jQuery(document.documentElement).attr("data-init") && (Config.loadDelay > 0 ? setTimeout(function () {
6533 0 === o.size && r()
6534 }, Math.max(Engine.minDomActionDelay, Config.loadDelay)) : r()) : n())
6535 })
6536 }
6537
6538 function t() {
6539 jQuery(document).off("readystatechange.SugarCube"), o.clear(), r()
6540 }
6541
6542 function r() {
6543 jQuery(document.documentElement).removeAttr("data-init")
6544 }
6545
6546 function n() {
6547 jQuery(document.documentElement).attr("data-init", "loading")
6548 }
6549
6550 function a() {
6551 return ++s, o.add(s), n(), s
6552 }
6553
6554 function i(e) {
6555 if (null == e) throw new Error("LoadScreen.unlock called with a null or undefined ID");
6556 o.has(e) && o.delete(e), 0 === o.size && jQuery(document).trigger("readystatechange")
6557 }
6558
6559 var o = new Set, s = 0;
6560 return Object.freeze(Object.defineProperties({}, {
6561 init: {value: e},
6562 clear: {value: t},
6563 hide: {value: r},
6564 show: {value: n},
6565 lock: {value: a},
6566 unlock: {value: i}
6567 }))
6568 }(), version = Object.freeze({
6569 title: "SugarCube",
6570 major: 2,
6571 minor: 21,
6572 patch: 0,
6573 prerelease: null,
6574 build: 8137,
6575 date: new Date("2017-12-05T14:45:09.718Z"),
6576 extensions: {},
6577 toString: function () {
6578 var e = this.prerelease ? "-" + this.prerelease : "";
6579 return this.major + "." + this.minor + "." + this.patch + e + "+" + this.build
6580 },
6581 short: function () {
6582 var e = this.prerelease ? "-" + this.prerelease : "";
6583 return this.title + " (v" + this.major + "." + this.minor + "." + this.patch + e + ")"
6584 },
6585 long: function () {
6586 return this.title + " v" + this.toString() + " (" + this.date.toUTCString() + ")"
6587 }
6588 }), TempState = {}, macros = {}, postdisplay = {}, postrender = {}, predisplay = {}, prehistory = {},
6589 prerender = {}, session = null, settings = {}, setup = {}, storage = null, browser = Browser,
6590 config = Config, has = Has, History = State, state = State, tale = Story, TempVariables = State.temporary;
6591 window.SugarCube = {}, jQuery(function () {
6592 try {
6593 var e = LoadScreen.lock();
6594 LoadScreen.init(), document.normalize && document.normalize(), Story.load(), storage = SimpleStore.create(Story.domId, !0), session = SimpleStore.create(Story.domId, !1), Dialog.init(), UIBar.init(), Engine.init(), Story.init(), L10n.init(), session.has("rcWarn") || "cookie" !== storage.name || (session.set("rcWarn", 1), window.alert(L10n.get("warningNoWebStorage"))), Save.init(), Setting.init(), Macro.init(), Engine.start(), UIBar.start(), window.SugarCube = {
6595 Browser: Browser,
6596 Config: Config,
6597 Dialog: Dialog,
6598 DebugView: DebugView,
6599 Engine: Engine,
6600 Has: Has,
6601 L10n: L10n,
6602 Macro: Macro,
6603 Passage: Passage,
6604 Save: Save,
6605 Scripting: Scripting,
6606 Setting: Setting,
6607 SimpleAudio: SimpleAudio,
6608 State: State,
6609 Story: Story,
6610 UI: UI,
6611 UIBar: UIBar,
6612 Util: Util,
6613 Wikifier: Wikifier,
6614 macros: macros,
6615 session: session,
6616 settings: settings,
6617 setup: setup,
6618 storage: storage,
6619 version: version
6620 }, LoadScreen.unlock(e)
6621 } catch (e) {
6622 return console.error(e), LoadScreen.clear(), Alert.fatal(null, e.message, e)
6623 }
6624 })
6625 }(window, window.document, jQuery);
6626 }
6627}