diff options
Diffstat (limited to 'frontend/index.html')
-rw-r--r-- | frontend/index.html | 12764 |
1 files changed, 0 insertions, 12764 deletions
diff --git a/frontend/index.html b/frontend/index.html deleted file mode 100644 index ffc3920..0000000 --- a/frontend/index.html +++ /dev/null | |||
@@ -1,12764 +0,0 @@ | |||
1 | <!DOCTYPE HTML> | ||
2 | <html> | ||
3 | <head> | ||
4 | <meta charset="UTF-8"> | ||
5 | <title>Main</title> | ||
6 | <style>body { padding: 0; margin: 0; }</style> | ||
7 | </head> | ||
8 | |||
9 | <body> | ||
10 | |||
11 | <pre id="elm"></pre> | ||
12 | |||
13 | <script> | ||
14 | try { | ||
15 | (function(scope){ | ||
16 | 'use strict'; | ||
17 | |||
18 | function F(arity, fun, wrapper) { | ||
19 | wrapper.a = arity; | ||
20 | wrapper.f = fun; | ||
21 | return wrapper; | ||
22 | } | ||
23 | |||
24 | function F2(fun) { | ||
25 | return F(2, fun, function(a) { return function(b) { return fun(a,b); }; }) | ||
26 | } | ||
27 | function F3(fun) { | ||
28 | return F(3, fun, function(a) { | ||
29 | return function(b) { return function(c) { return fun(a, b, c); }; }; | ||
30 | }); | ||
31 | } | ||
32 | function F4(fun) { | ||
33 | return F(4, fun, function(a) { return function(b) { return function(c) { | ||
34 | return function(d) { return fun(a, b, c, d); }; }; }; | ||
35 | }); | ||
36 | } | ||
37 | function F5(fun) { | ||
38 | return F(5, fun, function(a) { return function(b) { return function(c) { | ||
39 | return function(d) { return function(e) { return fun(a, b, c, d, e); }; }; }; }; | ||
40 | }); | ||
41 | } | ||
42 | function F6(fun) { | ||
43 | return F(6, fun, function(a) { return function(b) { return function(c) { | ||
44 | return function(d) { return function(e) { return function(f) { | ||
45 | return fun(a, b, c, d, e, f); }; }; }; }; }; | ||
46 | }); | ||
47 | } | ||
48 | function F7(fun) { | ||
49 | return F(7, fun, function(a) { return function(b) { return function(c) { | ||
50 | return function(d) { return function(e) { return function(f) { | ||
51 | return function(g) { return fun(a, b, c, d, e, f, g); }; }; }; }; }; }; | ||
52 | }); | ||
53 | } | ||
54 | function F8(fun) { | ||
55 | return F(8, fun, function(a) { return function(b) { return function(c) { | ||
56 | return function(d) { return function(e) { return function(f) { | ||
57 | return function(g) { return function(h) { | ||
58 | return fun(a, b, c, d, e, f, g, h); }; }; }; }; }; }; }; | ||
59 | }); | ||
60 | } | ||
61 | function F9(fun) { | ||
62 | return F(9, fun, function(a) { return function(b) { return function(c) { | ||
63 | return function(d) { return function(e) { return function(f) { | ||
64 | return function(g) { return function(h) { return function(i) { | ||
65 | return fun(a, b, c, d, e, f, g, h, i); }; }; }; }; }; }; }; }; | ||
66 | }); | ||
67 | } | ||
68 | |||
69 | function A2(fun, a, b) { | ||
70 | return fun.a === 2 ? fun.f(a, b) : fun(a)(b); | ||
71 | } | ||
72 | function A3(fun, a, b, c) { | ||
73 | return fun.a === 3 ? fun.f(a, b, c) : fun(a)(b)(c); | ||
74 | } | ||
75 | function A4(fun, a, b, c, d) { | ||
76 | return fun.a === 4 ? fun.f(a, b, c, d) : fun(a)(b)(c)(d); | ||
77 | } | ||
78 | function A5(fun, a, b, c, d, e) { | ||
79 | return fun.a === 5 ? fun.f(a, b, c, d, e) : fun(a)(b)(c)(d)(e); | ||
80 | } | ||
81 | function A6(fun, a, b, c, d, e, f) { | ||
82 | return fun.a === 6 ? fun.f(a, b, c, d, e, f) : fun(a)(b)(c)(d)(e)(f); | ||
83 | } | ||
84 | function A7(fun, a, b, c, d, e, f, g) { | ||
85 | return fun.a === 7 ? fun.f(a, b, c, d, e, f, g) : fun(a)(b)(c)(d)(e)(f)(g); | ||
86 | } | ||
87 | function A8(fun, a, b, c, d, e, f, g, h) { | ||
88 | return fun.a === 8 ? fun.f(a, b, c, d, e, f, g, h) : fun(a)(b)(c)(d)(e)(f)(g)(h); | ||
89 | } | ||
90 | function A9(fun, a, b, c, d, e, f, g, h, i) { | ||
91 | return fun.a === 9 ? fun.f(a, b, c, d, e, f, g, h, i) : fun(a)(b)(c)(d)(e)(f)(g)(h)(i); | ||
92 | } | ||
93 | |||
94 | console.warn('Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.'); | ||
95 | |||
96 | |||
97 | // EQUALITY | ||
98 | |||
99 | function _Utils_eq(x, y) | ||
100 | { | ||
101 | for ( | ||
102 | var pair, stack = [], isEqual = _Utils_eqHelp(x, y, 0, stack); | ||
103 | isEqual && (pair = stack.pop()); | ||
104 | isEqual = _Utils_eqHelp(pair.a, pair.b, 0, stack) | ||
105 | ) | ||
106 | {} | ||
107 | |||
108 | return isEqual; | ||
109 | } | ||
110 | |||
111 | function _Utils_eqHelp(x, y, depth, stack) | ||
112 | { | ||
113 | if (x === y) | ||
114 | { | ||
115 | return true; | ||
116 | } | ||
117 | |||
118 | if (typeof x !== 'object' || x === null || y === null) | ||
119 | { | ||
120 | typeof x === 'function' && _Debug_crash(5); | ||
121 | return false; | ||
122 | } | ||
123 | |||
124 | if (depth > 100) | ||
125 | { | ||
126 | stack.push(_Utils_Tuple2(x,y)); | ||
127 | return true; | ||
128 | } | ||
129 | |||
130 | /**/ | ||
131 | if (x.$ === 'Set_elm_builtin') | ||
132 | { | ||
133 | x = $elm$core$Set$toList(x); | ||
134 | y = $elm$core$Set$toList(y); | ||
135 | } | ||
136 | if (x.$ === 'RBNode_elm_builtin' || x.$ === 'RBEmpty_elm_builtin') | ||
137 | { | ||
138 | x = $elm$core$Dict$toList(x); | ||
139 | y = $elm$core$Dict$toList(y); | ||
140 | } | ||
141 | //*/ | ||
142 | |||
143 | /**_UNUSED/ | ||
144 | if (x.$ < 0) | ||
145 | { | ||
146 | x = $elm$core$Dict$toList(x); | ||
147 | y = $elm$core$Dict$toList(y); | ||
148 | } | ||
149 | //*/ | ||
150 | |||
151 | for (var key in x) | ||
152 | { | ||
153 | if (!_Utils_eqHelp(x[key], y[key], depth + 1, stack)) | ||
154 | { | ||
155 | return false; | ||
156 | } | ||
157 | } | ||
158 | return true; | ||
159 | } | ||
160 | |||
161 | var _Utils_equal = F2(_Utils_eq); | ||
162 | var _Utils_notEqual = F2(function(a, b) { return !_Utils_eq(a,b); }); | ||
163 | |||
164 | |||
165 | |||
166 | // COMPARISONS | ||
167 | |||
168 | // Code in Generate/JavaScript.hs, Basics.js, and List.js depends on | ||
169 | // the particular integer values assigned to LT, EQ, and GT. | ||
170 | |||
171 | function _Utils_cmp(x, y, ord) | ||
172 | { | ||
173 | if (typeof x !== 'object') | ||
174 | { | ||
175 | return x === y ? /*EQ*/ 0 : x < y ? /*LT*/ -1 : /*GT*/ 1; | ||
176 | } | ||
177 | |||
178 | /**/ | ||
179 | if (x instanceof String) | ||
180 | { | ||
181 | var a = x.valueOf(); | ||
182 | var b = y.valueOf(); | ||
183 | return a === b ? 0 : a < b ? -1 : 1; | ||
184 | } | ||
185 | //*/ | ||
186 | |||
187 | /**_UNUSED/ | ||
188 | if (typeof x.$ === 'undefined') | ||
189 | //*/ | ||
190 | /**/ | ||
191 | if (x.$[0] === '#') | ||
192 | //*/ | ||
193 | { | ||
194 | return (ord = _Utils_cmp(x.a, y.a)) | ||
195 | ? ord | ||
196 | : (ord = _Utils_cmp(x.b, y.b)) | ||
197 | ? ord | ||
198 | : _Utils_cmp(x.c, y.c); | ||
199 | } | ||
200 | |||
201 | // traverse conses until end of a list or a mismatch | ||
202 | for (; x.b && y.b && !(ord = _Utils_cmp(x.a, y.a)); x = x.b, y = y.b) {} // WHILE_CONSES | ||
203 | return ord || (x.b ? /*GT*/ 1 : y.b ? /*LT*/ -1 : /*EQ*/ 0); | ||
204 | } | ||
205 | |||
206 | var _Utils_lt = F2(function(a, b) { return _Utils_cmp(a, b) < 0; }); | ||
207 | var _Utils_le = F2(function(a, b) { return _Utils_cmp(a, b) < 1; }); | ||
208 | var _Utils_gt = F2(function(a, b) { return _Utils_cmp(a, b) > 0; }); | ||
209 | var _Utils_ge = F2(function(a, b) { return _Utils_cmp(a, b) >= 0; }); | ||
210 | |||
211 | var _Utils_compare = F2(function(x, y) | ||
212 | { | ||
213 | var n = _Utils_cmp(x, y); | ||
214 | return n < 0 ? $elm$core$Basics$LT : n ? $elm$core$Basics$GT : $elm$core$Basics$EQ; | ||
215 | }); | ||
216 | |||
217 | |||
218 | // COMMON VALUES | ||
219 | |||
220 | var _Utils_Tuple0_UNUSED = 0; | ||
221 | var _Utils_Tuple0 = { $: '#0' }; | ||
222 | |||
223 | function _Utils_Tuple2_UNUSED(a, b) { return { a: a, b: b }; } | ||
224 | function _Utils_Tuple2(a, b) { return { $: '#2', a: a, b: b }; } | ||
225 | |||
226 | function _Utils_Tuple3_UNUSED(a, b, c) { return { a: a, b: b, c: c }; } | ||
227 | function _Utils_Tuple3(a, b, c) { return { $: '#3', a: a, b: b, c: c }; } | ||
228 | |||
229 | function _Utils_chr_UNUSED(c) { return c; } | ||
230 | function _Utils_chr(c) { return new String(c); } | ||
231 | |||
232 | |||
233 | // RECORDS | ||
234 | |||
235 | function _Utils_update(oldRecord, updatedFields) | ||
236 | { | ||
237 | var newRecord = {}; | ||
238 | |||
239 | for (var key in oldRecord) | ||
240 | { | ||
241 | newRecord[key] = oldRecord[key]; | ||
242 | } | ||
243 | |||
244 | for (var key in updatedFields) | ||
245 | { | ||
246 | newRecord[key] = updatedFields[key]; | ||
247 | } | ||
248 | |||
249 | return newRecord; | ||
250 | } | ||
251 | |||
252 | |||
253 | // APPEND | ||
254 | |||
255 | var _Utils_append = F2(_Utils_ap); | ||
256 | |||
257 | function _Utils_ap(xs, ys) | ||
258 | { | ||
259 | // append Strings | ||
260 | if (typeof xs === 'string') | ||
261 | { | ||
262 | return xs + ys; | ||
263 | } | ||
264 | |||
265 | // append Lists | ||
266 | if (!xs.b) | ||
267 | { | ||
268 | return ys; | ||
269 | } | ||
270 | var root = _List_Cons(xs.a, ys); | ||
271 | xs = xs.b | ||
272 | for (var curr = root; xs.b; xs = xs.b) // WHILE_CONS | ||
273 | { | ||
274 | curr = curr.b = _List_Cons(xs.a, ys); | ||
275 | } | ||
276 | return root; | ||
277 | } | ||
278 | |||
279 | |||
280 | |||
281 | var _List_Nil_UNUSED = { $: 0 }; | ||
282 | var _List_Nil = { $: '[]' }; | ||
283 | |||
284 | function _List_Cons_UNUSED(hd, tl) { return { $: 1, a: hd, b: tl }; } | ||
285 | function _List_Cons(hd, tl) { return { $: '::', a: hd, b: tl }; } | ||
286 | |||
287 | |||
288 | var _List_cons = F2(_List_Cons); | ||
289 | |||
290 | function _List_fromArray(arr) | ||
291 | { | ||
292 | var out = _List_Nil; | ||
293 | for (var i = arr.length; i--; ) | ||
294 | { | ||
295 | out = _List_Cons(arr[i], out); | ||
296 | } | ||
297 | return out; | ||
298 | } | ||
299 | |||
300 | function _List_toArray(xs) | ||
301 | { | ||
302 | for (var out = []; xs.b; xs = xs.b) // WHILE_CONS | ||
303 | { | ||
304 | out.push(xs.a); | ||
305 | } | ||
306 | return out; | ||
307 | } | ||
308 | |||
309 | var _List_map2 = F3(function(f, xs, ys) | ||
310 | { | ||
311 | for (var arr = []; xs.b && ys.b; xs = xs.b, ys = ys.b) // WHILE_CONSES | ||
312 | { | ||
313 | arr.push(A2(f, xs.a, ys.a)); | ||
314 | } | ||
315 | return _List_fromArray(arr); | ||
316 | }); | ||
317 | |||
318 | var _List_map3 = F4(function(f, xs, ys, zs) | ||
319 | { | ||
320 | for (var arr = []; xs.b && ys.b && zs.b; xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES | ||
321 | { | ||
322 | arr.push(A3(f, xs.a, ys.a, zs.a)); | ||
323 | } | ||
324 | return _List_fromArray(arr); | ||
325 | }); | ||
326 | |||
327 | var _List_map4 = F5(function(f, ws, xs, ys, zs) | ||
328 | { | ||
329 | for (var arr = []; ws.b && xs.b && ys.b && zs.b; ws = ws.b, xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES | ||
330 | { | ||
331 | arr.push(A4(f, ws.a, xs.a, ys.a, zs.a)); | ||
332 | } | ||
333 | return _List_fromArray(arr); | ||
334 | }); | ||
335 | |||
336 | var _List_map5 = F6(function(f, vs, ws, xs, ys, zs) | ||
337 | { | ||
338 | for (var arr = []; vs.b && ws.b && xs.b && ys.b && zs.b; vs = vs.b, ws = ws.b, xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES | ||
339 | { | ||
340 | arr.push(A5(f, vs.a, ws.a, xs.a, ys.a, zs.a)); | ||
341 | } | ||
342 | return _List_fromArray(arr); | ||
343 | }); | ||
344 | |||
345 | var _List_sortBy = F2(function(f, xs) | ||
346 | { | ||
347 | return _List_fromArray(_List_toArray(xs).sort(function(a, b) { | ||
348 | return _Utils_cmp(f(a), f(b)); | ||
349 | })); | ||
350 | }); | ||
351 | |||
352 | var _List_sortWith = F2(function(f, xs) | ||
353 | { | ||
354 | return _List_fromArray(_List_toArray(xs).sort(function(a, b) { | ||
355 | var ord = A2(f, a, b); | ||
356 | return ord === $elm$core$Basics$EQ ? 0 : ord === $elm$core$Basics$LT ? -1 : 1; | ||
357 | })); | ||
358 | }); | ||
359 | |||
360 | |||
361 | |||
362 | var _JsArray_empty = []; | ||
363 | |||
364 | function _JsArray_singleton(value) | ||
365 | { | ||
366 | return [value]; | ||
367 | } | ||
368 | |||
369 | function _JsArray_length(array) | ||
370 | { | ||
371 | return array.length; | ||
372 | } | ||
373 | |||
374 | var _JsArray_initialize = F3(function(size, offset, func) | ||
375 | { | ||
376 | var result = new Array(size); | ||
377 | |||
378 | for (var i = 0; i < size; i++) | ||
379 | { | ||
380 | result[i] = func(offset + i); | ||
381 | } | ||
382 | |||
383 | return result; | ||
384 | }); | ||
385 | |||
386 | var _JsArray_initializeFromList = F2(function (max, ls) | ||
387 | { | ||
388 | var result = new Array(max); | ||
389 | |||
390 | for (var i = 0; i < max && ls.b; i++) | ||
391 | { | ||
392 | result[i] = ls.a; | ||
393 | ls = ls.b; | ||
394 | } | ||
395 | |||
396 | result.length = i; | ||
397 | return _Utils_Tuple2(result, ls); | ||
398 | }); | ||
399 | |||
400 | var _JsArray_unsafeGet = F2(function(index, array) | ||
401 | { | ||
402 | return array[index]; | ||
403 | }); | ||
404 | |||
405 | var _JsArray_unsafeSet = F3(function(index, value, array) | ||
406 | { | ||
407 | var length = array.length; | ||
408 | var result = new Array(length); | ||
409 | |||
410 | for (var i = 0; i < length; i++) | ||
411 | { | ||
412 | result[i] = array[i]; | ||
413 | } | ||
414 | |||
415 | result[index] = value; | ||
416 | return result; | ||
417 | }); | ||
418 | |||
419 | var _JsArray_push = F2(function(value, array) | ||
420 | { | ||
421 | var length = array.length; | ||
422 | var result = new Array(length + 1); | ||
423 | |||
424 | for (var i = 0; i < length; i++) | ||
425 | { | ||
426 | result[i] = array[i]; | ||
427 | } | ||
428 | |||
429 | result[length] = value; | ||
430 | return result; | ||
431 | }); | ||
432 | |||
433 | var _JsArray_foldl = F3(function(func, acc, array) | ||
434 | { | ||
435 | var length = array.length; | ||
436 | |||
437 | for (var i = 0; i < length; i++) | ||
438 | { | ||
439 | acc = A2(func, array[i], acc); | ||
440 | } | ||
441 | |||
442 | return acc; | ||
443 | }); | ||
444 | |||
445 | var _JsArray_foldr = F3(function(func, acc, array) | ||
446 | { | ||
447 | for (var i = array.length - 1; i >= 0; i--) | ||
448 | { | ||
449 | acc = A2(func, array[i], acc); | ||
450 | } | ||
451 | |||
452 | return acc; | ||
453 | }); | ||
454 | |||
455 | var _JsArray_map = F2(function(func, array) | ||
456 | { | ||
457 | var length = array.length; | ||
458 | var result = new Array(length); | ||
459 | |||
460 | for (var i = 0; i < length; i++) | ||
461 | { | ||
462 | result[i] = func(array[i]); | ||
463 | } | ||
464 | |||
465 | return result; | ||
466 | }); | ||
467 | |||
468 | var _JsArray_indexedMap = F3(function(func, offset, array) | ||
469 | { | ||
470 | var length = array.length; | ||
471 | var result = new Array(length); | ||
472 | |||
473 | for (var i = 0; i < length; i++) | ||
474 | { | ||
475 | result[i] = A2(func, offset + i, array[i]); | ||
476 | } | ||
477 | |||
478 | return result; | ||
479 | }); | ||
480 | |||
481 | var _JsArray_slice = F3(function(from, to, array) | ||
482 | { | ||
483 | return array.slice(from, to); | ||
484 | }); | ||
485 | |||
486 | var _JsArray_appendN = F3(function(n, dest, source) | ||
487 | { | ||
488 | var destLen = dest.length; | ||
489 | var itemsToCopy = n - destLen; | ||
490 | |||
491 | if (itemsToCopy > source.length) | ||
492 | { | ||
493 | itemsToCopy = source.length; | ||
494 | } | ||
495 | |||
496 | var size = destLen + itemsToCopy; | ||
497 | var result = new Array(size); | ||
498 | |||
499 | for (var i = 0; i < destLen; i++) | ||
500 | { | ||
501 | result[i] = dest[i]; | ||
502 | } | ||
503 | |||
504 | for (var i = 0; i < itemsToCopy; i++) | ||
505 | { | ||
506 | result[i + destLen] = source[i]; | ||
507 | } | ||
508 | |||
509 | return result; | ||
510 | }); | ||
511 | |||
512 | |||
513 | |||
514 | // LOG | ||
515 | |||
516 | var _Debug_log_UNUSED = F2(function(tag, value) | ||
517 | { | ||
518 | return value; | ||
519 | }); | ||
520 | |||
521 | var _Debug_log = F2(function(tag, value) | ||
522 | { | ||
523 | console.log(tag + ': ' + _Debug_toString(value)); | ||
524 | return value; | ||
525 | }); | ||
526 | |||
527 | |||
528 | // TODOS | ||
529 | |||
530 | function _Debug_todo(moduleName, region) | ||
531 | { | ||
532 | return function(message) { | ||
533 | _Debug_crash(8, moduleName, region, message); | ||
534 | }; | ||
535 | } | ||
536 | |||
537 | function _Debug_todoCase(moduleName, region, value) | ||
538 | { | ||
539 | return function(message) { | ||
540 | _Debug_crash(9, moduleName, region, value, message); | ||
541 | }; | ||
542 | } | ||
543 | |||
544 | |||
545 | // TO STRING | ||
546 | |||
547 | function _Debug_toString_UNUSED(value) | ||
548 | { | ||
549 | return '<internals>'; | ||
550 | } | ||
551 | |||
552 | function _Debug_toString(value) | ||
553 | { | ||
554 | return _Debug_toAnsiString(false, value); | ||
555 | } | ||
556 | |||
557 | function _Debug_toAnsiString(ansi, value) | ||
558 | { | ||
559 | if (typeof value === 'function') | ||
560 | { | ||
561 | return _Debug_internalColor(ansi, '<function>'); | ||
562 | } | ||
563 | |||
564 | if (typeof value === 'boolean') | ||
565 | { | ||
566 | return _Debug_ctorColor(ansi, value ? 'True' : 'False'); | ||
567 | } | ||
568 | |||
569 | if (typeof value === 'number') | ||
570 | { | ||
571 | return _Debug_numberColor(ansi, value + ''); | ||
572 | } | ||
573 | |||
574 | if (value instanceof String) | ||
575 | { | ||
576 | return _Debug_charColor(ansi, "'" + _Debug_addSlashes(value, true) + "'"); | ||
577 | } | ||
578 | |||
579 | if (typeof value === 'string') | ||
580 | { | ||
581 | return _Debug_stringColor(ansi, '"' + _Debug_addSlashes(value, false) + '"'); | ||
582 | } | ||
583 | |||
584 | if (typeof value === 'object' && '$' in value) | ||
585 | { | ||
586 | var tag = value.$; | ||
587 | |||
588 | if (typeof tag === 'number') | ||
589 | { | ||
590 | return _Debug_internalColor(ansi, '<internals>'); | ||
591 | } | ||
592 | |||
593 | if (tag[0] === '#') | ||
594 | { | ||
595 | var output = []; | ||
596 | for (var k in value) | ||
597 | { | ||
598 | if (k === '$') continue; | ||
599 | output.push(_Debug_toAnsiString(ansi, value[k])); | ||
600 | } | ||
601 | return '(' + output.join(',') + ')'; | ||
602 | } | ||
603 | |||
604 | if (tag === 'Set_elm_builtin') | ||
605 | { | ||
606 | return _Debug_ctorColor(ansi, 'Set') | ||
607 | + _Debug_fadeColor(ansi, '.fromList') + ' ' | ||
608 | + _Debug_toAnsiString(ansi, $elm$core$Set$toList(value)); | ||
609 | } | ||
610 | |||
611 | if (tag === 'RBNode_elm_builtin' || tag === 'RBEmpty_elm_builtin') | ||
612 | { | ||
613 | return _Debug_ctorColor(ansi, 'Dict') | ||
614 | + _Debug_fadeColor(ansi, '.fromList') + ' ' | ||
615 | + _Debug_toAnsiString(ansi, $elm$core$Dict$toList(value)); | ||
616 | } | ||
617 | |||
618 | if (tag === 'Array_elm_builtin') | ||
619 | { | ||
620 | return _Debug_ctorColor(ansi, 'Array') | ||
621 | + _Debug_fadeColor(ansi, '.fromList') + ' ' | ||
622 | + _Debug_toAnsiString(ansi, $elm$core$Array$toList(value)); | ||
623 | } | ||
624 | |||
625 | if (tag === '::' || tag === '[]') | ||
626 | { | ||
627 | var output = '['; | ||
628 | |||
629 | value.b && (output += _Debug_toAnsiString(ansi, value.a), value = value.b) | ||
630 | |||
631 | for (; value.b; value = value.b) // WHILE_CONS | ||
632 | { | ||
633 | output += ',' + _Debug_toAnsiString(ansi, value.a); | ||
634 | } | ||
635 | return output + ']'; | ||
636 | } | ||
637 | |||
638 | var output = ''; | ||
639 | for (var i in value) | ||
640 | { | ||
641 | if (i === '$') continue; | ||
642 | var str = _Debug_toAnsiString(ansi, value[i]); | ||
643 | var c0 = str[0]; | ||
644 | var parenless = c0 === '{' || c0 === '(' || c0 === '[' || c0 === '<' || c0 === '"' || str.indexOf(' ') < 0; | ||
645 | output += ' ' + (parenless ? str : '(' + str + ')'); | ||
646 | } | ||
647 | return _Debug_ctorColor(ansi, tag) + output; | ||
648 | } | ||
649 | |||
650 | if (typeof DataView === 'function' && value instanceof DataView) | ||
651 | { | ||
652 | return _Debug_stringColor(ansi, '<' + value.byteLength + ' bytes>'); | ||
653 | } | ||
654 | |||
655 | if (typeof File !== 'undefined' && value instanceof File) | ||
656 | { | ||
657 | return _Debug_internalColor(ansi, '<' + value.name + '>'); | ||
658 | } | ||
659 | |||
660 | if (typeof value === 'object') | ||
661 | { | ||
662 | var output = []; | ||
663 | for (var key in value) | ||
664 | { | ||
665 | var field = key[0] === '_' ? key.slice(1) : key; | ||
666 | output.push(_Debug_fadeColor(ansi, field) + ' = ' + _Debug_toAnsiString(ansi, value[key])); | ||
667 | } | ||
668 | if (output.length === 0) | ||
669 | { | ||
670 | return '{}'; | ||
671 | } | ||
672 | return '{ ' + output.join(', ') + ' }'; | ||
673 | } | ||
674 | |||
675 | return _Debug_internalColor(ansi, '<internals>'); | ||
676 | } | ||
677 | |||
678 | function _Debug_addSlashes(str, isChar) | ||
679 | { | ||
680 | var s = str | ||
681 | .replace(/\\/g, '\\\\') | ||
682 | .replace(/\n/g, '\\n') | ||
683 | .replace(/\t/g, '\\t') | ||
684 | .replace(/\r/g, '\\r') | ||
685 | .replace(/\v/g, '\\v') | ||
686 | .replace(/\0/g, '\\0'); | ||
687 | |||
688 | if (isChar) | ||
689 | { | ||
690 | return s.replace(/\'/g, '\\\''); | ||
691 | } | ||
692 | else | ||
693 | { | ||
694 | return s.replace(/\"/g, '\\"'); | ||
695 | } | ||
696 | } | ||
697 | |||
698 | function _Debug_ctorColor(ansi, string) | ||
699 | { | ||
700 | return ansi ? '\x1b[96m' + string + '\x1b[0m' : string; | ||
701 | } | ||
702 | |||
703 | function _Debug_numberColor(ansi, string) | ||
704 | { | ||
705 | return ansi ? '\x1b[95m' + string + '\x1b[0m' : string; | ||
706 | } | ||
707 | |||
708 | function _Debug_stringColor(ansi, string) | ||
709 | { | ||
710 | return ansi ? '\x1b[93m' + string + '\x1b[0m' : string; | ||
711 | } | ||
712 | |||
713 | function _Debug_charColor(ansi, string) | ||
714 | { | ||
715 | return ansi ? '\x1b[92m' + string + '\x1b[0m' : string; | ||
716 | } | ||
717 | |||
718 | function _Debug_fadeColor(ansi, string) | ||
719 | { | ||
720 | return ansi ? '\x1b[37m' + string + '\x1b[0m' : string; | ||
721 | } | ||
722 | |||
723 | function _Debug_internalColor(ansi, string) | ||
724 | { | ||
725 | return ansi ? '\x1b[36m' + string + '\x1b[0m' : string; | ||
726 | } | ||
727 | |||
728 | function _Debug_toHexDigit(n) | ||
729 | { | ||
730 | return String.fromCharCode(n < 10 ? 48 + n : 55 + n); | ||
731 | } | ||
732 | |||
733 | |||
734 | // CRASH | ||
735 | |||
736 | |||
737 | function _Debug_crash_UNUSED(identifier) | ||
738 | { | ||
739 | throw new Error('https://github.com/elm/core/blob/1.0.0/hints/' + identifier + '.md'); | ||
740 | } | ||
741 | |||
742 | |||
743 | function _Debug_crash(identifier, fact1, fact2, fact3, fact4) | ||
744 | { | ||
745 | switch(identifier) | ||
746 | { | ||
747 | case 0: | ||
748 | throw new Error('What node should I take over? In JavaScript I need something like:\n\n Elm.Main.init({\n node: document.getElementById("elm-node")\n })\n\nYou need to do this with any Browser.sandbox or Browser.element program.'); | ||
749 | |||
750 | case 1: | ||
751 | throw new Error('Browser.application programs cannot handle URLs like this:\n\n ' + document.location.href + '\n\nWhat is the root? The root of your file system? Try looking at this program with `elm reactor` or some other server.'); | ||
752 | |||
753 | case 2: | ||
754 | var jsonErrorString = fact1; | ||
755 | throw new Error('Problem with the flags given to your Elm program on initialization.\n\n' + jsonErrorString); | ||
756 | |||
757 | case 3: | ||
758 | var portName = fact1; | ||
759 | throw new Error('There can only be one port named `' + portName + '`, but your program has multiple.'); | ||
760 | |||
761 | case 4: | ||
762 | var portName = fact1; | ||
763 | var problem = fact2; | ||
764 | throw new Error('Trying to send an unexpected type of value through port `' + portName + '`:\n' + problem); | ||
765 | |||
766 | case 5: | ||
767 | throw new Error('Trying to use `(==)` on functions.\nThere is no way to know if functions are "the same" in the Elm sense.\nRead more about this at https://package.elm-lang.org/packages/elm/core/latest/Basics#== which describes why it is this way and what the better version will look like.'); | ||
768 | |||
769 | case 6: | ||
770 | var moduleName = fact1; | ||
771 | throw new Error('Your page is loading multiple Elm scripts with a module named ' + moduleName + '. Maybe a duplicate script is getting loaded accidentally? If not, rename one of them so I know which is which!'); | ||
772 | |||
773 | case 8: | ||
774 | var moduleName = fact1; | ||
775 | var region = fact2; | ||
776 | var message = fact3; | ||
777 | throw new Error('TODO in module `' + moduleName + '` ' + _Debug_regionToString(region) + '\n\n' + message); | ||
778 | |||
779 | case 9: | ||
780 | var moduleName = fact1; | ||
781 | var region = fact2; | ||
782 | var value = fact3; | ||
783 | var message = fact4; | ||
784 | throw new Error( | ||
785 | 'TODO in module `' + moduleName + '` from the `case` expression ' | ||
786 | + _Debug_regionToString(region) + '\n\nIt received the following value:\n\n ' | ||
787 | + _Debug_toString(value).replace('\n', '\n ') | ||
788 | + '\n\nBut the branch that handles it says:\n\n ' + message.replace('\n', '\n ') | ||
789 | ); | ||
790 | |||
791 | case 10: | ||
792 | throw new Error('Bug in https://github.com/elm/virtual-dom/issues'); | ||
793 | |||
794 | case 11: | ||
795 | throw new Error('Cannot perform mod 0. Division by zero error.'); | ||
796 | } | ||
797 | } | ||
798 | |||
799 | function _Debug_regionToString(region) | ||
800 | { | ||
801 | if (region.start.line === region.end.line) | ||
802 | { | ||
803 | return 'on line ' + region.start.line; | ||
804 | } | ||
805 | return 'on lines ' + region.start.line + ' through ' + region.end.line; | ||
806 | } | ||
807 | |||
808 | |||
809 | |||
810 | // MATH | ||
811 | |||
812 | var _Basics_add = F2(function(a, b) { return a + b; }); | ||
813 | var _Basics_sub = F2(function(a, b) { return a - b; }); | ||
814 | var _Basics_mul = F2(function(a, b) { return a * b; }); | ||
815 | var _Basics_fdiv = F2(function(a, b) { return a / b; }); | ||
816 | var _Basics_idiv = F2(function(a, b) { return (a / b) | 0; }); | ||
817 | var _Basics_pow = F2(Math.pow); | ||
818 | |||
819 | var _Basics_remainderBy = F2(function(b, a) { return a % b; }); | ||
820 | |||
821 | // https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/divmodnote-letter.pdf | ||
822 | var _Basics_modBy = F2(function(modulus, x) | ||
823 | { | ||
824 | var answer = x % modulus; | ||
825 | return modulus === 0 | ||
826 | ? _Debug_crash(11) | ||
827 | : | ||
828 | ((answer > 0 && modulus < 0) || (answer < 0 && modulus > 0)) | ||
829 | ? answer + modulus | ||
830 | : answer; | ||
831 | }); | ||
832 | |||
833 | |||
834 | // TRIGONOMETRY | ||
835 | |||
836 | var _Basics_pi = Math.PI; | ||
837 | var _Basics_e = Math.E; | ||
838 | var _Basics_cos = Math.cos; | ||
839 | var _Basics_sin = Math.sin; | ||
840 | var _Basics_tan = Math.tan; | ||
841 | var _Basics_acos = Math.acos; | ||
842 | var _Basics_asin = Math.asin; | ||
843 | var _Basics_atan = Math.atan; | ||
844 | var _Basics_atan2 = F2(Math.atan2); | ||
845 | |||
846 | |||
847 | // MORE MATH | ||
848 | |||
849 | function _Basics_toFloat(x) { return x; } | ||
850 | function _Basics_truncate(n) { return n | 0; } | ||
851 | function _Basics_isInfinite(n) { return n === Infinity || n === -Infinity; } | ||
852 | |||
853 | var _Basics_ceiling = Math.ceil; | ||
854 | var _Basics_floor = Math.floor; | ||
855 | var _Basics_round = Math.round; | ||
856 | var _Basics_sqrt = Math.sqrt; | ||
857 | var _Basics_log = Math.log; | ||
858 | var _Basics_isNaN = isNaN; | ||
859 | |||
860 | |||
861 | // BOOLEANS | ||
862 | |||
863 | function _Basics_not(bool) { return !bool; } | ||
864 | var _Basics_and = F2(function(a, b) { return a && b; }); | ||
865 | var _Basics_or = F2(function(a, b) { return a || b; }); | ||
866 | var _Basics_xor = F2(function(a, b) { return a !== b; }); | ||
867 | |||
868 | |||
869 | |||
870 | var _String_cons = F2(function(chr, str) | ||
871 | { | ||
872 | return chr + str; | ||
873 | }); | ||
874 | |||
875 | function _String_uncons(string) | ||
876 | { | ||
877 | var word = string.charCodeAt(0); | ||
878 | return !isNaN(word) | ||
879 | ? $elm$core$Maybe$Just( | ||
880 | 0xD800 <= word && word <= 0xDBFF | ||
881 | ? _Utils_Tuple2(_Utils_chr(string[0] + string[1]), string.slice(2)) | ||
882 | : _Utils_Tuple2(_Utils_chr(string[0]), string.slice(1)) | ||
883 | ) | ||
884 | : $elm$core$Maybe$Nothing; | ||
885 | } | ||
886 | |||
887 | var _String_append = F2(function(a, b) | ||
888 | { | ||
889 | return a + b; | ||
890 | }); | ||
891 | |||
892 | function _String_length(str) | ||
893 | { | ||
894 | return str.length; | ||
895 | } | ||
896 | |||
897 | var _String_map = F2(function(func, string) | ||
898 | { | ||
899 | var len = string.length; | ||
900 | var array = new Array(len); | ||
901 | var i = 0; | ||
902 | while (i < len) | ||
903 | { | ||
904 | var word = string.charCodeAt(i); | ||
905 | if (0xD800 <= word && word <= 0xDBFF) | ||
906 | { | ||
907 | array[i] = func(_Utils_chr(string[i] + string[i+1])); | ||
908 | i += 2; | ||
909 | continue; | ||
910 | } | ||
911 | array[i] = func(_Utils_chr(string[i])); | ||
912 | i++; | ||
913 | } | ||
914 | return array.join(''); | ||
915 | }); | ||
916 | |||
917 | var _String_filter = F2(function(isGood, str) | ||
918 | { | ||
919 | var arr = []; | ||
920 | var len = str.length; | ||
921 | var i = 0; | ||
922 | while (i < len) | ||
923 | { | ||
924 | var char = str[i]; | ||
925 | var word = str.charCodeAt(i); | ||
926 | i++; | ||
927 | if (0xD800 <= word && word <= 0xDBFF) | ||
928 | { | ||
929 | char += str[i]; | ||
930 | i++; | ||
931 | } | ||
932 | |||
933 | if (isGood(_Utils_chr(char))) | ||
934 | { | ||
935 | arr.push(char); | ||
936 | } | ||
937 | } | ||
938 | return arr.join(''); | ||
939 | }); | ||
940 | |||
941 | function _String_reverse(str) | ||
942 | { | ||
943 | var len = str.length; | ||
944 | var arr = new Array(len); | ||
945 | var i = 0; | ||
946 | while (i < len) | ||
947 | { | ||
948 | var word = str.charCodeAt(i); | ||
949 | if (0xD800 <= word && word <= 0xDBFF) | ||
950 | { | ||
951 | arr[len - i] = str[i + 1]; | ||
952 | i++; | ||
953 | arr[len - i] = str[i - 1]; | ||
954 | i++; | ||
955 | } | ||
956 | else | ||
957 | { | ||
958 | arr[len - i] = str[i]; | ||
959 | i++; | ||
960 | } | ||
961 | } | ||
962 | return arr.join(''); | ||
963 | } | ||
964 | |||
965 | var _String_foldl = F3(function(func, state, string) | ||
966 | { | ||
967 | var len = string.length; | ||
968 | var i = 0; | ||
969 | while (i < len) | ||
970 | { | ||
971 | var char = string[i]; | ||
972 | var word = string.charCodeAt(i); | ||
973 | i++; | ||
974 | if (0xD800 <= word && word <= 0xDBFF) | ||
975 | { | ||
976 | char += string[i]; | ||
977 | i++; | ||
978 | } | ||
979 | state = A2(func, _Utils_chr(char), state); | ||
980 | } | ||
981 | return state; | ||
982 | }); | ||
983 | |||
984 | var _String_foldr = F3(function(func, state, string) | ||
985 | { | ||
986 | var i = string.length; | ||
987 | while (i--) | ||
988 | { | ||
989 | var char = string[i]; | ||
990 | var word = string.charCodeAt(i); | ||
991 | if (0xDC00 <= word && word <= 0xDFFF) | ||
992 | { | ||
993 | i--; | ||
994 | char = string[i] + char; | ||
995 | } | ||
996 | state = A2(func, _Utils_chr(char), state); | ||
997 | } | ||
998 | return state; | ||
999 | }); | ||
1000 | |||
1001 | var _String_split = F2(function(sep, str) | ||
1002 | { | ||
1003 | return str.split(sep); | ||
1004 | }); | ||
1005 | |||
1006 | var _String_join = F2(function(sep, strs) | ||
1007 | { | ||
1008 | return strs.join(sep); | ||
1009 | }); | ||
1010 | |||
1011 | var _String_slice = F3(function(start, end, str) { | ||
1012 | return str.slice(start, end); | ||
1013 | }); | ||
1014 | |||
1015 | function _String_trim(str) | ||
1016 | { | ||
1017 | return str.trim(); | ||
1018 | } | ||
1019 | |||
1020 | function _String_trimLeft(str) | ||
1021 | { | ||
1022 | return str.replace(/^\s+/, ''); | ||
1023 | } | ||
1024 | |||
1025 | function _String_trimRight(str) | ||
1026 | { | ||
1027 | return str.replace(/\s+$/, ''); | ||
1028 | } | ||
1029 | |||
1030 | function _String_words(str) | ||
1031 | { | ||
1032 | return _List_fromArray(str.trim().split(/\s+/g)); | ||
1033 | } | ||
1034 | |||
1035 | function _String_lines(str) | ||
1036 | { | ||
1037 | return _List_fromArray(str.split(/\r\n|\r|\n/g)); | ||
1038 | } | ||
1039 | |||
1040 | function _String_toUpper(str) | ||
1041 | { | ||
1042 | return str.toUpperCase(); | ||
1043 | } | ||
1044 | |||
1045 | function _String_toLower(str) | ||
1046 | { | ||
1047 | return str.toLowerCase(); | ||
1048 | } | ||
1049 | |||
1050 | var _String_any = F2(function(isGood, string) | ||
1051 | { | ||
1052 | var i = string.length; | ||
1053 | while (i--) | ||
1054 | { | ||
1055 | var char = string[i]; | ||
1056 | var word = string.charCodeAt(i); | ||
1057 | if (0xDC00 <= word && word <= 0xDFFF) | ||
1058 | { | ||
1059 | i--; | ||
1060 | char = string[i] + char; | ||
1061 | } | ||
1062 | if (isGood(_Utils_chr(char))) | ||
1063 | { | ||
1064 | return true; | ||
1065 | } | ||
1066 | } | ||
1067 | return false; | ||
1068 | }); | ||
1069 | |||
1070 | var _String_all = F2(function(isGood, string) | ||
1071 | { | ||
1072 | var i = string.length; | ||
1073 | while (i--) | ||
1074 | { | ||
1075 | var char = string[i]; | ||
1076 | var word = string.charCodeAt(i); | ||
1077 | if (0xDC00 <= word && word <= 0xDFFF) | ||
1078 | { | ||
1079 | i--; | ||
1080 | char = string[i] + char; | ||
1081 | } | ||
1082 | if (!isGood(_Utils_chr(char))) | ||
1083 | { | ||
1084 | return false; | ||
1085 | } | ||
1086 | } | ||
1087 | return true; | ||
1088 | }); | ||
1089 | |||
1090 | var _String_contains = F2(function(sub, str) | ||
1091 | { | ||
1092 | return str.indexOf(sub) > -1; | ||
1093 | }); | ||
1094 | |||
1095 | var _String_startsWith = F2(function(sub, str) | ||
1096 | { | ||
1097 | return str.indexOf(sub) === 0; | ||
1098 | }); | ||
1099 | |||
1100 | var _String_endsWith = F2(function(sub, str) | ||
1101 | { | ||
1102 | return str.length >= sub.length && | ||
1103 | str.lastIndexOf(sub) === str.length - sub.length; | ||
1104 | }); | ||
1105 | |||
1106 | var _String_indexes = F2(function(sub, str) | ||
1107 | { | ||
1108 | var subLen = sub.length; | ||
1109 | |||
1110 | if (subLen < 1) | ||
1111 | { | ||
1112 | return _List_Nil; | ||
1113 | } | ||
1114 | |||
1115 | var i = 0; | ||
1116 | var is = []; | ||
1117 | |||
1118 | while ((i = str.indexOf(sub, i)) > -1) | ||
1119 | { | ||
1120 | is.push(i); | ||
1121 | i = i + subLen; | ||
1122 | } | ||
1123 | |||
1124 | return _List_fromArray(is); | ||
1125 | }); | ||
1126 | |||
1127 | |||
1128 | // TO STRING | ||
1129 | |||
1130 | function _String_fromNumber(number) | ||
1131 | { | ||
1132 | return number + ''; | ||
1133 | } | ||
1134 | |||
1135 | |||
1136 | // INT CONVERSIONS | ||
1137 | |||
1138 | function _String_toInt(str) | ||
1139 | { | ||
1140 | var total = 0; | ||
1141 | var code0 = str.charCodeAt(0); | ||
1142 | var start = code0 == 0x2B /* + */ || code0 == 0x2D /* - */ ? 1 : 0; | ||
1143 | |||
1144 | for (var i = start; i < str.length; ++i) | ||
1145 | { | ||
1146 | var code = str.charCodeAt(i); | ||
1147 | if (code < 0x30 || 0x39 < code) | ||
1148 | { | ||
1149 | return $elm$core$Maybe$Nothing; | ||
1150 | } | ||
1151 | total = 10 * total + code - 0x30; | ||
1152 | } | ||
1153 | |||
1154 | return i == start | ||
1155 | ? $elm$core$Maybe$Nothing | ||
1156 | : $elm$core$Maybe$Just(code0 == 0x2D ? -total : total); | ||
1157 | } | ||
1158 | |||
1159 | |||
1160 | // FLOAT CONVERSIONS | ||
1161 | |||
1162 | function _String_toFloat(s) | ||
1163 | { | ||
1164 | // check if it is a hex, octal, or binary number | ||
1165 | if (s.length === 0 || /[\sxbo]/.test(s)) | ||
1166 | { | ||
1167 | return $elm$core$Maybe$Nothing; | ||
1168 | } | ||
1169 | var n = +s; | ||
1170 | // faster isNaN check | ||
1171 | return n === n ? $elm$core$Maybe$Just(n) : $elm$core$Maybe$Nothing; | ||
1172 | } | ||
1173 | |||
1174 | function _String_fromList(chars) | ||
1175 | { | ||
1176 | return _List_toArray(chars).join(''); | ||
1177 | } | ||
1178 | |||
1179 | |||
1180 | |||
1181 | |||
1182 | function _Char_toCode(char) | ||
1183 | { | ||
1184 | var code = char.charCodeAt(0); | ||
1185 | if (0xD800 <= code && code <= 0xDBFF) | ||
1186 | { | ||
1187 | return (code - 0xD800) * 0x400 + char.charCodeAt(1) - 0xDC00 + 0x10000 | ||
1188 | } | ||
1189 | return code; | ||
1190 | } | ||
1191 | |||
1192 | function _Char_fromCode(code) | ||
1193 | { | ||
1194 | return _Utils_chr( | ||
1195 | (code < 0 || 0x10FFFF < code) | ||
1196 | ? '\uFFFD' | ||
1197 | : | ||
1198 | (code <= 0xFFFF) | ||
1199 | ? String.fromCharCode(code) | ||
1200 | : | ||
1201 | (code -= 0x10000, | ||
1202 | String.fromCharCode(Math.floor(code / 0x400) + 0xD800, code % 0x400 + 0xDC00) | ||
1203 | ) | ||
1204 | ); | ||
1205 | } | ||
1206 | |||
1207 | function _Char_toUpper(char) | ||
1208 | { | ||
1209 | return _Utils_chr(char.toUpperCase()); | ||
1210 | } | ||
1211 | |||
1212 | function _Char_toLower(char) | ||
1213 | { | ||
1214 | return _Utils_chr(char.toLowerCase()); | ||
1215 | } | ||
1216 | |||
1217 | function _Char_toLocaleUpper(char) | ||
1218 | { | ||
1219 | return _Utils_chr(char.toLocaleUpperCase()); | ||
1220 | } | ||
1221 | |||
1222 | function _Char_toLocaleLower(char) | ||
1223 | { | ||
1224 | return _Utils_chr(char.toLocaleLowerCase()); | ||
1225 | } | ||
1226 | |||
1227 | |||
1228 | |||
1229 | /**/ | ||
1230 | function _Json_errorToString(error) | ||
1231 | { | ||
1232 | return $elm$json$Json$Decode$errorToString(error); | ||
1233 | } | ||
1234 | //*/ | ||
1235 | |||
1236 | |||
1237 | // CORE DECODERS | ||
1238 | |||
1239 | function _Json_succeed(msg) | ||
1240 | { | ||
1241 | return { | ||
1242 | $: 0, | ||
1243 | a: msg | ||
1244 | }; | ||
1245 | } | ||
1246 | |||
1247 | function _Json_fail(msg) | ||
1248 | { | ||
1249 | return { | ||
1250 | $: 1, | ||
1251 | a: msg | ||
1252 | }; | ||
1253 | } | ||
1254 | |||
1255 | function _Json_decodePrim(decoder) | ||
1256 | { | ||
1257 | return { $: 2, b: decoder }; | ||
1258 | } | ||
1259 | |||
1260 | var _Json_decodeInt = _Json_decodePrim(function(value) { | ||
1261 | return (typeof value !== 'number') | ||
1262 | ? _Json_expecting('an INT', value) | ||
1263 | : | ||
1264 | (-2147483647 < value && value < 2147483647 && (value | 0) === value) | ||
1265 | ? $elm$core$Result$Ok(value) | ||
1266 | : | ||
1267 | (isFinite(value) && !(value % 1)) | ||
1268 | ? $elm$core$Result$Ok(value) | ||
1269 | : _Json_expecting('an INT', value); | ||
1270 | }); | ||
1271 | |||
1272 | var _Json_decodeBool = _Json_decodePrim(function(value) { | ||
1273 | return (typeof value === 'boolean') | ||
1274 | ? $elm$core$Result$Ok(value) | ||
1275 | : _Json_expecting('a BOOL', value); | ||
1276 | }); | ||
1277 | |||
1278 | var _Json_decodeFloat = _Json_decodePrim(function(value) { | ||
1279 | return (typeof value === 'number') | ||
1280 | ? $elm$core$Result$Ok(value) | ||
1281 | : _Json_expecting('a FLOAT', value); | ||
1282 | }); | ||
1283 | |||
1284 | var _Json_decodeValue = _Json_decodePrim(function(value) { | ||
1285 | return $elm$core$Result$Ok(_Json_wrap(value)); | ||
1286 | }); | ||
1287 | |||
1288 | var _Json_decodeString = _Json_decodePrim(function(value) { | ||
1289 | return (typeof value === 'string') | ||
1290 | ? $elm$core$Result$Ok(value) | ||
1291 | : (value instanceof String) | ||
1292 | ? $elm$core$Result$Ok(value + '') | ||
1293 | : _Json_expecting('a STRING', value); | ||
1294 | }); | ||
1295 | |||
1296 | function _Json_decodeList(decoder) { return { $: 3, b: decoder }; } | ||
1297 | function _Json_decodeArray(decoder) { return { $: 4, b: decoder }; } | ||
1298 | |||
1299 | function _Json_decodeNull(value) { return { $: 5, c: value }; } | ||
1300 | |||
1301 | var _Json_decodeField = F2(function(field, decoder) | ||
1302 | { | ||
1303 | return { | ||
1304 | $: 6, | ||
1305 | d: field, | ||
1306 | b: decoder | ||
1307 | }; | ||
1308 | }); | ||
1309 | |||
1310 | var _Json_decodeIndex = F2(function(index, decoder) | ||
1311 | { | ||
1312 | return { | ||
1313 | $: 7, | ||
1314 | e: index, | ||
1315 | b: decoder | ||
1316 | }; | ||
1317 | }); | ||
1318 | |||
1319 | function _Json_decodeKeyValuePairs(decoder) | ||
1320 | { | ||
1321 | return { | ||
1322 | $: 8, | ||
1323 | b: decoder | ||
1324 | }; | ||
1325 | } | ||
1326 | |||
1327 | function _Json_mapMany(f, decoders) | ||
1328 | { | ||
1329 | return { | ||
1330 | $: 9, | ||
1331 | f: f, | ||
1332 | g: decoders | ||
1333 | }; | ||
1334 | } | ||
1335 | |||
1336 | var _Json_andThen = F2(function(callback, decoder) | ||
1337 | { | ||
1338 | return { | ||
1339 | $: 10, | ||
1340 | b: decoder, | ||
1341 | h: callback | ||
1342 | }; | ||
1343 | }); | ||
1344 | |||
1345 | function _Json_oneOf(decoders) | ||
1346 | { | ||
1347 | return { | ||
1348 | $: 11, | ||
1349 | g: decoders | ||
1350 | }; | ||
1351 | } | ||
1352 | |||
1353 | |||
1354 | // DECODING OBJECTS | ||
1355 | |||
1356 | var _Json_map1 = F2(function(f, d1) | ||
1357 | { | ||
1358 | return _Json_mapMany(f, [d1]); | ||
1359 | }); | ||
1360 | |||
1361 | var _Json_map2 = F3(function(f, d1, d2) | ||
1362 | { | ||
1363 | return _Json_mapMany(f, [d1, d2]); | ||
1364 | }); | ||
1365 | |||
1366 | var _Json_map3 = F4(function(f, d1, d2, d3) | ||
1367 | { | ||
1368 | return _Json_mapMany(f, [d1, d2, d3]); | ||
1369 | }); | ||
1370 | |||
1371 | var _Json_map4 = F5(function(f, d1, d2, d3, d4) | ||
1372 | { | ||
1373 | return _Json_mapMany(f, [d1, d2, d3, d4]); | ||
1374 | }); | ||
1375 | |||
1376 | var _Json_map5 = F6(function(f, d1, d2, d3, d4, d5) | ||
1377 | { | ||
1378 | return _Json_mapMany(f, [d1, d2, d3, d4, d5]); | ||
1379 | }); | ||
1380 | |||
1381 | var _Json_map6 = F7(function(f, d1, d2, d3, d4, d5, d6) | ||
1382 | { | ||
1383 | return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6]); | ||
1384 | }); | ||
1385 | |||
1386 | var _Json_map7 = F8(function(f, d1, d2, d3, d4, d5, d6, d7) | ||
1387 | { | ||
1388 | return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7]); | ||
1389 | }); | ||
1390 | |||
1391 | var _Json_map8 = F9(function(f, d1, d2, d3, d4, d5, d6, d7, d8) | ||
1392 | { | ||
1393 | return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7, d8]); | ||
1394 | }); | ||
1395 | |||
1396 | |||
1397 | // DECODE | ||
1398 | |||
1399 | var _Json_runOnString = F2(function(decoder, string) | ||
1400 | { | ||
1401 | try | ||
1402 | { | ||
1403 | var value = JSON.parse(string); | ||
1404 | return _Json_runHelp(decoder, value); | ||
1405 | } | ||
1406 | catch (e) | ||
1407 | { | ||
1408 | return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, 'This is not valid JSON! ' + e.message, _Json_wrap(string))); | ||
1409 | } | ||
1410 | }); | ||
1411 | |||
1412 | var _Json_run = F2(function(decoder, value) | ||
1413 | { | ||
1414 | return _Json_runHelp(decoder, _Json_unwrap(value)); | ||
1415 | }); | ||
1416 | |||
1417 | function _Json_runHelp(decoder, value) | ||
1418 | { | ||
1419 | switch (decoder.$) | ||
1420 | { | ||
1421 | case 2: | ||
1422 | return decoder.b(value); | ||
1423 | |||
1424 | case 5: | ||
1425 | return (value === null) | ||
1426 | ? $elm$core$Result$Ok(decoder.c) | ||
1427 | : _Json_expecting('null', value); | ||
1428 | |||
1429 | case 3: | ||
1430 | if (!_Json_isArray(value)) | ||
1431 | { | ||
1432 | return _Json_expecting('a LIST', value); | ||
1433 | } | ||
1434 | return _Json_runArrayDecoder(decoder.b, value, _List_fromArray); | ||
1435 | |||
1436 | case 4: | ||
1437 | if (!_Json_isArray(value)) | ||
1438 | { | ||
1439 | return _Json_expecting('an ARRAY', value); | ||
1440 | } | ||
1441 | return _Json_runArrayDecoder(decoder.b, value, _Json_toElmArray); | ||
1442 | |||
1443 | case 6: | ||
1444 | var field = decoder.d; | ||
1445 | if (typeof value !== 'object' || value === null || !(field in value)) | ||
1446 | { | ||
1447 | return _Json_expecting('an OBJECT with a field named `' + field + '`', value); | ||
1448 | } | ||
1449 | var result = _Json_runHelp(decoder.b, value[field]); | ||
1450 | return ($elm$core$Result$isOk(result)) ? result : $elm$core$Result$Err(A2($elm$json$Json$Decode$Field, field, result.a)); | ||
1451 | |||
1452 | case 7: | ||
1453 | var index = decoder.e; | ||
1454 | if (!_Json_isArray(value)) | ||
1455 | { | ||
1456 | return _Json_expecting('an ARRAY', value); | ||
1457 | } | ||
1458 | if (index >= value.length) | ||
1459 | { | ||
1460 | return _Json_expecting('a LONGER array. Need index ' + index + ' but only see ' + value.length + ' entries', value); | ||
1461 | } | ||
1462 | var result = _Json_runHelp(decoder.b, value[index]); | ||
1463 | return ($elm$core$Result$isOk(result)) ? result : $elm$core$Result$Err(A2($elm$json$Json$Decode$Index, index, result.a)); | ||
1464 | |||
1465 | case 8: | ||
1466 | if (typeof value !== 'object' || value === null || _Json_isArray(value)) | ||
1467 | { | ||
1468 | return _Json_expecting('an OBJECT', value); | ||
1469 | } | ||
1470 | |||
1471 | var keyValuePairs = _List_Nil; | ||
1472 | // TODO test perf of Object.keys and switch when support is good enough | ||
1473 | for (var key in value) | ||
1474 | { | ||
1475 | if (value.hasOwnProperty(key)) | ||
1476 | { | ||
1477 | var result = _Json_runHelp(decoder.b, value[key]); | ||
1478 | if (!$elm$core$Result$isOk(result)) | ||
1479 | { | ||
1480 | return $elm$core$Result$Err(A2($elm$json$Json$Decode$Field, key, result.a)); | ||
1481 | } | ||
1482 | keyValuePairs = _List_Cons(_Utils_Tuple2(key, result.a), keyValuePairs); | ||
1483 | } | ||
1484 | } | ||
1485 | return $elm$core$Result$Ok($elm$core$List$reverse(keyValuePairs)); | ||
1486 | |||
1487 | case 9: | ||
1488 | var answer = decoder.f; | ||
1489 | var decoders = decoder.g; | ||
1490 | for (var i = 0; i < decoders.length; i++) | ||
1491 | { | ||
1492 | var result = _Json_runHelp(decoders[i], value); | ||
1493 | if (!$elm$core$Result$isOk(result)) | ||
1494 | { | ||
1495 | return result; | ||
1496 | } | ||
1497 | answer = answer(result.a); | ||
1498 | } | ||
1499 | return $elm$core$Result$Ok(answer); | ||
1500 | |||
1501 | case 10: | ||
1502 | var result = _Json_runHelp(decoder.b, value); | ||
1503 | return (!$elm$core$Result$isOk(result)) | ||
1504 | ? result | ||
1505 | : _Json_runHelp(decoder.h(result.a), value); | ||
1506 | |||
1507 | case 11: | ||
1508 | var errors = _List_Nil; | ||
1509 | for (var temp = decoder.g; temp.b; temp = temp.b) // WHILE_CONS | ||
1510 | { | ||
1511 | var result = _Json_runHelp(temp.a, value); | ||
1512 | if ($elm$core$Result$isOk(result)) | ||
1513 | { | ||
1514 | return result; | ||
1515 | } | ||
1516 | errors = _List_Cons(result.a, errors); | ||
1517 | } | ||
1518 | return $elm$core$Result$Err($elm$json$Json$Decode$OneOf($elm$core$List$reverse(errors))); | ||
1519 | |||
1520 | case 1: | ||
1521 | return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, decoder.a, _Json_wrap(value))); | ||
1522 | |||
1523 | case 0: | ||
1524 | return $elm$core$Result$Ok(decoder.a); | ||
1525 | } | ||
1526 | } | ||
1527 | |||
1528 | function _Json_runArrayDecoder(decoder, value, toElmValue) | ||
1529 | { | ||
1530 | var len = value.length; | ||
1531 | var array = new Array(len); | ||
1532 | for (var i = 0; i < len; i++) | ||
1533 | { | ||
1534 | var result = _Json_runHelp(decoder, value[i]); | ||
1535 | if (!$elm$core$Result$isOk(result)) | ||
1536 | { | ||
1537 | return $elm$core$Result$Err(A2($elm$json$Json$Decode$Index, i, result.a)); | ||
1538 | } | ||
1539 | array[i] = result.a; | ||
1540 | } | ||
1541 | return $elm$core$Result$Ok(toElmValue(array)); | ||
1542 | } | ||
1543 | |||
1544 | function _Json_isArray(value) | ||
1545 | { | ||
1546 | return Array.isArray(value) || (typeof FileList !== 'undefined' && value instanceof FileList); | ||
1547 | } | ||
1548 | |||
1549 | function _Json_toElmArray(array) | ||
1550 | { | ||
1551 | return A2($elm$core$Array$initialize, array.length, function(i) { return array[i]; }); | ||
1552 | } | ||
1553 | |||
1554 | function _Json_expecting(type, value) | ||
1555 | { | ||
1556 | return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, 'Expecting ' + type, _Json_wrap(value))); | ||
1557 | } | ||
1558 | |||
1559 | |||
1560 | // EQUALITY | ||
1561 | |||
1562 | function _Json_equality(x, y) | ||
1563 | { | ||
1564 | if (x === y) | ||
1565 | { | ||
1566 | return true; | ||
1567 | } | ||
1568 | |||
1569 | if (x.$ !== y.$) | ||
1570 | { | ||
1571 | return false; | ||
1572 | } | ||
1573 | |||
1574 | switch (x.$) | ||
1575 | { | ||
1576 | case 0: | ||
1577 | case 1: | ||
1578 | return x.a === y.a; | ||
1579 | |||
1580 | case 2: | ||
1581 | return x.b === y.b; | ||
1582 | |||
1583 | case 5: | ||
1584 | return x.c === y.c; | ||
1585 | |||
1586 | case 3: | ||
1587 | case 4: | ||
1588 | case 8: | ||
1589 | return _Json_equality(x.b, y.b); | ||
1590 | |||
1591 | case 6: | ||
1592 | return x.d === y.d && _Json_equality(x.b, y.b); | ||
1593 | |||
1594 | case 7: | ||
1595 | return x.e === y.e && _Json_equality(x.b, y.b); | ||
1596 | |||
1597 | case 9: | ||
1598 | return x.f === y.f && _Json_listEquality(x.g, y.g); | ||
1599 | |||
1600 | case 10: | ||
1601 | return x.h === y.h && _Json_equality(x.b, y.b); | ||
1602 | |||
1603 | case 11: | ||
1604 | return _Json_listEquality(x.g, y.g); | ||
1605 | } | ||
1606 | } | ||
1607 | |||
1608 | function _Json_listEquality(aDecoders, bDecoders) | ||
1609 | { | ||
1610 | var len = aDecoders.length; | ||
1611 | if (len !== bDecoders.length) | ||
1612 | { | ||
1613 | return false; | ||
1614 | } | ||
1615 | for (var i = 0; i < len; i++) | ||
1616 | { | ||
1617 | if (!_Json_equality(aDecoders[i], bDecoders[i])) | ||
1618 | { | ||
1619 | return false; | ||
1620 | } | ||
1621 | } | ||
1622 | return true; | ||
1623 | } | ||
1624 | |||
1625 | |||
1626 | // ENCODE | ||
1627 | |||
1628 | var _Json_encode = F2(function(indentLevel, value) | ||
1629 | { | ||
1630 | return JSON.stringify(_Json_unwrap(value), null, indentLevel) + ''; | ||
1631 | }); | ||
1632 | |||
1633 | function _Json_wrap(value) { return { $: 0, a: value }; } | ||
1634 | function _Json_unwrap(value) { return value.a; } | ||
1635 | |||
1636 | function _Json_wrap_UNUSED(value) { return value; } | ||
1637 | function _Json_unwrap_UNUSED(value) { return value; } | ||
1638 | |||
1639 | function _Json_emptyArray() { return []; } | ||
1640 | function _Json_emptyObject() { return {}; } | ||
1641 | |||
1642 | var _Json_addField = F3(function(key, value, object) | ||
1643 | { | ||
1644 | object[key] = _Json_unwrap(value); | ||
1645 | return object; | ||
1646 | }); | ||
1647 | |||
1648 | function _Json_addEntry(func) | ||
1649 | { | ||
1650 | return F2(function(entry, array) | ||
1651 | { | ||
1652 | array.push(_Json_unwrap(func(entry))); | ||
1653 | return array; | ||
1654 | }); | ||
1655 | } | ||
1656 | |||
1657 | var _Json_encodeNull = _Json_wrap(null); | ||
1658 | |||
1659 | |||
1660 | |||
1661 | // TASKS | ||
1662 | |||
1663 | function _Scheduler_succeed(value) | ||
1664 | { | ||
1665 | return { | ||
1666 | $: 0, | ||
1667 | a: value | ||
1668 | }; | ||
1669 | } | ||
1670 | |||
1671 | function _Scheduler_fail(error) | ||
1672 | { | ||
1673 | return { | ||
1674 | $: 1, | ||
1675 | a: error | ||
1676 | }; | ||
1677 | } | ||
1678 | |||
1679 | function _Scheduler_binding(callback) | ||
1680 | { | ||
1681 | return { | ||
1682 | $: 2, | ||
1683 | b: callback, | ||
1684 | c: null | ||
1685 | }; | ||
1686 | } | ||
1687 | |||
1688 | var _Scheduler_andThen = F2(function(callback, task) | ||
1689 | { | ||
1690 | return { | ||
1691 | $: 3, | ||
1692 | b: callback, | ||
1693 | d: task | ||
1694 | }; | ||
1695 | }); | ||
1696 | |||
1697 | var _Scheduler_onError = F2(function(callback, task) | ||
1698 | { | ||
1699 | return { | ||
1700 | $: 4, | ||
1701 | b: callback, | ||
1702 | d: task | ||
1703 | }; | ||
1704 | }); | ||
1705 | |||
1706 | function _Scheduler_receive(callback) | ||
1707 | { | ||
1708 | return { | ||
1709 | $: 5, | ||
1710 | b: callback | ||
1711 | }; | ||
1712 | } | ||
1713 | |||
1714 | |||
1715 | // PROCESSES | ||
1716 | |||
1717 | var _Scheduler_guid = 0; | ||
1718 | |||
1719 | function _Scheduler_rawSpawn(task) | ||
1720 | { | ||
1721 | var proc = { | ||
1722 | $: 0, | ||
1723 | e: _Scheduler_guid++, | ||
1724 | f: task, | ||
1725 | g: null, | ||
1726 | h: [] | ||
1727 | }; | ||
1728 | |||
1729 | _Scheduler_enqueue(proc); | ||
1730 | |||
1731 | return proc; | ||
1732 | } | ||
1733 | |||
1734 | function _Scheduler_spawn(task) | ||
1735 | { | ||
1736 | return _Scheduler_binding(function(callback) { | ||
1737 | callback(_Scheduler_succeed(_Scheduler_rawSpawn(task))); | ||
1738 | }); | ||
1739 | } | ||
1740 | |||
1741 | function _Scheduler_rawSend(proc, msg) | ||
1742 | { | ||
1743 | proc.h.push(msg); | ||
1744 | _Scheduler_enqueue(proc); | ||
1745 | } | ||
1746 | |||
1747 | var _Scheduler_send = F2(function(proc, msg) | ||
1748 | { | ||
1749 | return _Scheduler_binding(function(callback) { | ||
1750 | _Scheduler_rawSend(proc, msg); | ||
1751 | callback(_Scheduler_succeed(_Utils_Tuple0)); | ||
1752 | }); | ||
1753 | }); | ||
1754 | |||
1755 | function _Scheduler_kill(proc) | ||
1756 | { | ||
1757 | return _Scheduler_binding(function(callback) { | ||
1758 | var task = proc.f; | ||
1759 | if (task.$ === 2 && task.c) | ||
1760 | { | ||
1761 | task.c(); | ||
1762 | } | ||
1763 | |||
1764 | proc.f = null; | ||
1765 | |||
1766 | callback(_Scheduler_succeed(_Utils_Tuple0)); | ||
1767 | }); | ||
1768 | } | ||
1769 | |||
1770 | |||
1771 | /* STEP PROCESSES | ||
1772 | |||
1773 | type alias Process = | ||
1774 | { $ : tag | ||
1775 | , id : unique_id | ||
1776 | , root : Task | ||
1777 | , stack : null | { $: SUCCEED | FAIL, a: callback, b: stack } | ||
1778 | , mailbox : [msg] | ||
1779 | } | ||
1780 | |||
1781 | */ | ||
1782 | |||
1783 | |||
1784 | var _Scheduler_working = false; | ||
1785 | var _Scheduler_queue = []; | ||
1786 | |||
1787 | |||
1788 | function _Scheduler_enqueue(proc) | ||
1789 | { | ||
1790 | _Scheduler_queue.push(proc); | ||
1791 | if (_Scheduler_working) | ||
1792 | { | ||
1793 | return; | ||
1794 | } | ||
1795 | _Scheduler_working = true; | ||
1796 | while (proc = _Scheduler_queue.shift()) | ||
1797 | { | ||
1798 | _Scheduler_step(proc); | ||
1799 | } | ||
1800 | _Scheduler_working = false; | ||
1801 | } | ||
1802 | |||
1803 | |||
1804 | function _Scheduler_step(proc) | ||
1805 | { | ||
1806 | while (proc.f) | ||
1807 | { | ||
1808 | var rootTag = proc.f.$; | ||
1809 | if (rootTag === 0 || rootTag === 1) | ||
1810 | { | ||
1811 | while (proc.g && proc.g.$ !== rootTag) | ||
1812 | { | ||
1813 | proc.g = proc.g.i; | ||
1814 | } | ||
1815 | if (!proc.g) | ||
1816 | { | ||
1817 | return; | ||
1818 | } | ||
1819 | proc.f = proc.g.b(proc.f.a); | ||
1820 | proc.g = proc.g.i; | ||
1821 | } | ||
1822 | else if (rootTag === 2) | ||
1823 | { | ||
1824 | proc.f.c = proc.f.b(function(newRoot) { | ||
1825 | proc.f = newRoot; | ||
1826 | _Scheduler_enqueue(proc); | ||
1827 | }); | ||
1828 | return; | ||
1829 | } | ||
1830 | else if (rootTag === 5) | ||
1831 | { | ||
1832 | if (proc.h.length === 0) | ||
1833 | { | ||
1834 | return; | ||
1835 | } | ||
1836 | proc.f = proc.f.b(proc.h.shift()); | ||
1837 | } | ||
1838 | else // if (rootTag === 3 || rootTag === 4) | ||
1839 | { | ||
1840 | proc.g = { | ||
1841 | $: rootTag === 3 ? 0 : 1, | ||
1842 | b: proc.f.b, | ||
1843 | i: proc.g | ||
1844 | }; | ||
1845 | proc.f = proc.f.d; | ||
1846 | } | ||
1847 | } | ||
1848 | } | ||
1849 | |||
1850 | |||
1851 | |||
1852 | function _Process_sleep(time) | ||
1853 | { | ||
1854 | return _Scheduler_binding(function(callback) { | ||
1855 | var id = setTimeout(function() { | ||
1856 | callback(_Scheduler_succeed(_Utils_Tuple0)); | ||
1857 | }, time); | ||
1858 | |||
1859 | return function() { clearTimeout(id); }; | ||
1860 | }); | ||
1861 | } | ||
1862 | |||
1863 | |||
1864 | |||
1865 | |||
1866 | // PROGRAMS | ||
1867 | |||
1868 | |||
1869 | var _Platform_worker = F4(function(impl, flagDecoder, debugMetadata, args) | ||
1870 | { | ||
1871 | return _Platform_initialize( | ||
1872 | flagDecoder, | ||
1873 | args, | ||
1874 | impl.init, | ||
1875 | impl.update, | ||
1876 | impl.subscriptions, | ||
1877 | function() { return function() {} } | ||
1878 | ); | ||
1879 | }); | ||
1880 | |||
1881 | |||
1882 | |||
1883 | // INITIALIZE A PROGRAM | ||
1884 | |||
1885 | |||
1886 | function _Platform_initialize(flagDecoder, args, init, update, subscriptions, stepperBuilder) | ||
1887 | { | ||
1888 | var result = A2(_Json_run, flagDecoder, _Json_wrap(args ? args['flags'] : undefined)); | ||
1889 | $elm$core$Result$isOk(result) || _Debug_crash(2 /**/, _Json_errorToString(result.a) /**/); | ||
1890 | var managers = {}; | ||
1891 | var initPair = init(result.a); | ||
1892 | var model = initPair.a; | ||
1893 | var stepper = stepperBuilder(sendToApp, model); | ||
1894 | var ports = _Platform_setupEffects(managers, sendToApp); | ||
1895 | |||
1896 | function sendToApp(msg, viewMetadata) | ||
1897 | { | ||
1898 | var pair = A2(update, msg, model); | ||
1899 | stepper(model = pair.a, viewMetadata); | ||
1900 | _Platform_enqueueEffects(managers, pair.b, subscriptions(model)); | ||
1901 | } | ||
1902 | |||
1903 | _Platform_enqueueEffects(managers, initPair.b, subscriptions(model)); | ||
1904 | |||
1905 | return ports ? { ports: ports } : {}; | ||
1906 | } | ||
1907 | |||
1908 | |||
1909 | |||
1910 | // TRACK PRELOADS | ||
1911 | // | ||
1912 | // This is used by code in elm/browser and elm/http | ||
1913 | // to register any HTTP requests that are triggered by init. | ||
1914 | // | ||
1915 | |||
1916 | |||
1917 | var _Platform_preload; | ||
1918 | |||
1919 | |||
1920 | function _Platform_registerPreload(url) | ||
1921 | { | ||
1922 | _Platform_preload.add(url); | ||
1923 | } | ||
1924 | |||
1925 | |||
1926 | |||
1927 | // EFFECT MANAGERS | ||
1928 | |||
1929 | |||
1930 | var _Platform_effectManagers = {}; | ||
1931 | |||
1932 | |||
1933 | function _Platform_setupEffects(managers, sendToApp) | ||
1934 | { | ||
1935 | var ports; | ||
1936 | |||
1937 | // setup all necessary effect managers | ||
1938 | for (var key in _Platform_effectManagers) | ||
1939 | { | ||
1940 | var manager = _Platform_effectManagers[key]; | ||
1941 | |||
1942 | if (manager.a) | ||
1943 | { | ||
1944 | ports = ports || {}; | ||
1945 | ports[key] = manager.a(key, sendToApp); | ||
1946 | } | ||
1947 | |||
1948 | managers[key] = _Platform_instantiateManager(manager, sendToApp); | ||
1949 | } | ||
1950 | |||
1951 | return ports; | ||
1952 | } | ||
1953 | |||
1954 | |||
1955 | function _Platform_createManager(init, onEffects, onSelfMsg, cmdMap, subMap) | ||
1956 | { | ||
1957 | return { | ||
1958 | b: init, | ||
1959 | c: onEffects, | ||
1960 | d: onSelfMsg, | ||
1961 | e: cmdMap, | ||
1962 | f: subMap | ||
1963 | }; | ||
1964 | } | ||
1965 | |||
1966 | |||
1967 | function _Platform_instantiateManager(info, sendToApp) | ||
1968 | { | ||
1969 | var router = { | ||
1970 | g: sendToApp, | ||
1971 | h: undefined | ||
1972 | }; | ||
1973 | |||
1974 | var onEffects = info.c; | ||
1975 | var onSelfMsg = info.d; | ||
1976 | var cmdMap = info.e; | ||
1977 | var subMap = info.f; | ||
1978 | |||
1979 | function loop(state) | ||
1980 | { | ||
1981 | return A2(_Scheduler_andThen, loop, _Scheduler_receive(function(msg) | ||
1982 | { | ||
1983 | var value = msg.a; | ||
1984 | |||
1985 | if (msg.$ === 0) | ||
1986 | { | ||
1987 | return A3(onSelfMsg, router, value, state); | ||
1988 | } | ||
1989 | |||
1990 | return cmdMap && subMap | ||
1991 | ? A4(onEffects, router, value.i, value.j, state) | ||
1992 | : A3(onEffects, router, cmdMap ? value.i : value.j, state); | ||
1993 | })); | ||
1994 | } | ||
1995 | |||
1996 | return router.h = _Scheduler_rawSpawn(A2(_Scheduler_andThen, loop, info.b)); | ||
1997 | } | ||
1998 | |||
1999 | |||
2000 | |||
2001 | // ROUTING | ||
2002 | |||
2003 | |||
2004 | var _Platform_sendToApp = F2(function(router, msg) | ||
2005 | { | ||
2006 | return _Scheduler_binding(function(callback) | ||
2007 | { | ||
2008 | router.g(msg); | ||
2009 | callback(_Scheduler_succeed(_Utils_Tuple0)); | ||
2010 | }); | ||
2011 | }); | ||
2012 | |||
2013 | |||
2014 | var _Platform_sendToSelf = F2(function(router, msg) | ||
2015 | { | ||
2016 | return A2(_Scheduler_send, router.h, { | ||
2017 | $: 0, | ||
2018 | a: msg | ||
2019 | }); | ||
2020 | }); | ||
2021 | |||
2022 | |||
2023 | |||
2024 | // BAGS | ||
2025 | |||
2026 | |||
2027 | function _Platform_leaf(home) | ||
2028 | { | ||
2029 | return function(value) | ||
2030 | { | ||
2031 | return { | ||
2032 | $: 1, | ||
2033 | k: home, | ||
2034 | l: value | ||
2035 | }; | ||
2036 | }; | ||
2037 | } | ||
2038 | |||
2039 | |||
2040 | function _Platform_batch(list) | ||
2041 | { | ||
2042 | return { | ||
2043 | $: 2, | ||
2044 | m: list | ||
2045 | }; | ||
2046 | } | ||
2047 | |||
2048 | |||
2049 | var _Platform_map = F2(function(tagger, bag) | ||
2050 | { | ||
2051 | return { | ||
2052 | $: 3, | ||
2053 | n: tagger, | ||
2054 | o: bag | ||
2055 | } | ||
2056 | }); | ||
2057 | |||
2058 | |||
2059 | |||
2060 | // PIPE BAGS INTO EFFECT MANAGERS | ||
2061 | // | ||
2062 | // Effects must be queued! | ||
2063 | // | ||
2064 | // Say your init contains a synchronous command, like Time.now or Time.here | ||
2065 | // | ||
2066 | // - This will produce a batch of effects (FX_1) | ||
2067 | // - The synchronous task triggers the subsequent `update` call | ||
2068 | // - This will produce a batch of effects (FX_2) | ||
2069 | // | ||
2070 | // If we just start dispatching FX_2, subscriptions from FX_2 can be processed | ||
2071 | // before subscriptions from FX_1. No good! Earlier versions of this code had | ||
2072 | // this problem, leading to these reports: | ||
2073 | // | ||
2074 | // https://github.com/elm/core/issues/980 | ||
2075 | // https://github.com/elm/core/pull/981 | ||
2076 | // https://github.com/elm/compiler/issues/1776 | ||
2077 | // | ||
2078 | // The queue is necessary to avoid ordering issues for synchronous commands. | ||
2079 | |||
2080 | |||
2081 | // Why use true/false here? Why not just check the length of the queue? | ||
2082 | // The goal is to detect "are we currently dispatching effects?" If we | ||
2083 | // are, we need to bail and let the ongoing while loop handle things. | ||
2084 | // | ||
2085 | // Now say the queue has 1 element. When we dequeue the final element, | ||
2086 | // the queue will be empty, but we are still actively dispatching effects. | ||
2087 | // So you could get queue jumping in a really tricky category of cases. | ||
2088 | // | ||
2089 | var _Platform_effectsQueue = []; | ||
2090 | var _Platform_effectsActive = false; | ||
2091 | |||
2092 | |||
2093 | function _Platform_enqueueEffects(managers, cmdBag, subBag) | ||
2094 | { | ||
2095 | _Platform_effectsQueue.push({ p: managers, q: cmdBag, r: subBag }); | ||
2096 | |||
2097 | if (_Platform_effectsActive) return; | ||
2098 | |||
2099 | _Platform_effectsActive = true; | ||
2100 | for (var fx; fx = _Platform_effectsQueue.shift(); ) | ||
2101 | { | ||
2102 | _Platform_dispatchEffects(fx.p, fx.q, fx.r); | ||
2103 | } | ||
2104 | _Platform_effectsActive = false; | ||
2105 | } | ||
2106 | |||
2107 | |||
2108 | function _Platform_dispatchEffects(managers, cmdBag, subBag) | ||
2109 | { | ||
2110 | var effectsDict = {}; | ||
2111 | _Platform_gatherEffects(true, cmdBag, effectsDict, null); | ||
2112 | _Platform_gatherEffects(false, subBag, effectsDict, null); | ||
2113 | |||
2114 | for (var home in managers) | ||
2115 | { | ||
2116 | _Scheduler_rawSend(managers[home], { | ||
2117 | $: 'fx', | ||
2118 | a: effectsDict[home] || { i: _List_Nil, j: _List_Nil } | ||
2119 | }); | ||
2120 | } | ||
2121 | } | ||
2122 | |||
2123 | |||
2124 | function _Platform_gatherEffects(isCmd, bag, effectsDict, taggers) | ||
2125 | { | ||
2126 | switch (bag.$) | ||
2127 | { | ||
2128 | case 1: | ||
2129 | var home = bag.k; | ||
2130 | var effect = _Platform_toEffect(isCmd, home, taggers, bag.l); | ||
2131 | effectsDict[home] = _Platform_insert(isCmd, effect, effectsDict[home]); | ||
2132 | return; | ||
2133 | |||
2134 | case 2: | ||
2135 | for (var list = bag.m; list.b; list = list.b) // WHILE_CONS | ||
2136 | { | ||
2137 | _Platform_gatherEffects(isCmd, list.a, effectsDict, taggers); | ||
2138 | } | ||
2139 | return; | ||
2140 | |||
2141 | case 3: | ||
2142 | _Platform_gatherEffects(isCmd, bag.o, effectsDict, { | ||
2143 | s: bag.n, | ||
2144 | t: taggers | ||
2145 | }); | ||
2146 | return; | ||
2147 | } | ||
2148 | } | ||
2149 | |||
2150 | |||
2151 | function _Platform_toEffect(isCmd, home, taggers, value) | ||
2152 | { | ||
2153 | function applyTaggers(x) | ||
2154 | { | ||
2155 | for (var temp = taggers; temp; temp = temp.t) | ||
2156 | { | ||
2157 | x = temp.s(x); | ||
2158 | } | ||
2159 | return x; | ||
2160 | } | ||
2161 | |||
2162 | var map = isCmd | ||
2163 | ? _Platform_effectManagers[home].e | ||
2164 | : _Platform_effectManagers[home].f; | ||
2165 | |||
2166 | return A2(map, applyTaggers, value) | ||
2167 | } | ||
2168 | |||
2169 | |||
2170 | function _Platform_insert(isCmd, newEffect, effects) | ||
2171 | { | ||
2172 | effects = effects || { i: _List_Nil, j: _List_Nil }; | ||
2173 | |||
2174 | isCmd | ||
2175 | ? (effects.i = _List_Cons(newEffect, effects.i)) | ||
2176 | : (effects.j = _List_Cons(newEffect, effects.j)); | ||
2177 | |||
2178 | return effects; | ||
2179 | } | ||
2180 | |||
2181 | |||
2182 | |||
2183 | // PORTS | ||
2184 | |||
2185 | |||
2186 | function _Platform_checkPortName(name) | ||
2187 | { | ||
2188 | if (_Platform_effectManagers[name]) | ||
2189 | { | ||
2190 | _Debug_crash(3, name) | ||
2191 | } | ||
2192 | } | ||
2193 | |||
2194 | |||
2195 | |||
2196 | // OUTGOING PORTS | ||
2197 | |||
2198 | |||
2199 | function _Platform_outgoingPort(name, converter) | ||
2200 | { | ||
2201 | _Platform_checkPortName(name); | ||
2202 | _Platform_effectManagers[name] = { | ||
2203 | e: _Platform_outgoingPortMap, | ||
2204 | u: converter, | ||
2205 | a: _Platform_setupOutgoingPort | ||
2206 | }; | ||
2207 | return _Platform_leaf(name); | ||
2208 | } | ||
2209 | |||
2210 | |||
2211 | var _Platform_outgoingPortMap = F2(function(tagger, value) { return value; }); | ||
2212 | |||
2213 | |||
2214 | function _Platform_setupOutgoingPort(name) | ||
2215 | { | ||
2216 | var subs = []; | ||
2217 | var converter = _Platform_effectManagers[name].u; | ||
2218 | |||
2219 | // CREATE MANAGER | ||
2220 | |||
2221 | var init = _Process_sleep(0); | ||
2222 | |||
2223 | _Platform_effectManagers[name].b = init; | ||
2224 | _Platform_effectManagers[name].c = F3(function(router, cmdList, state) | ||
2225 | { | ||
2226 | for ( ; cmdList.b; cmdList = cmdList.b) // WHILE_CONS | ||
2227 | { | ||
2228 | // grab a separate reference to subs in case unsubscribe is called | ||
2229 | var currentSubs = subs; | ||
2230 | var value = _Json_unwrap(converter(cmdList.a)); | ||
2231 | for (var i = 0; i < currentSubs.length; i++) | ||
2232 | { | ||
2233 | currentSubs[i](value); | ||
2234 | } | ||
2235 | } | ||
2236 | return init; | ||
2237 | }); | ||
2238 | |||
2239 | // PUBLIC API | ||
2240 | |||
2241 | function subscribe(callback) | ||
2242 | { | ||
2243 | subs.push(callback); | ||
2244 | } | ||
2245 | |||
2246 | function unsubscribe(callback) | ||
2247 | { | ||
2248 | // copy subs into a new array in case unsubscribe is called within a | ||
2249 | // subscribed callback | ||
2250 | subs = subs.slice(); | ||
2251 | var index = subs.indexOf(callback); | ||
2252 | if (index >= 0) | ||
2253 | { | ||
2254 | subs.splice(index, 1); | ||
2255 | } | ||
2256 | } | ||
2257 | |||
2258 | return { | ||
2259 | subscribe: subscribe, | ||
2260 | unsubscribe: unsubscribe | ||
2261 | }; | ||
2262 | } | ||
2263 | |||
2264 | |||
2265 | |||
2266 | // INCOMING PORTS | ||
2267 | |||
2268 | |||
2269 | function _Platform_incomingPort(name, converter) | ||
2270 | { | ||
2271 | _Platform_checkPortName(name); | ||
2272 | _Platform_effectManagers[name] = { | ||
2273 | f: _Platform_incomingPortMap, | ||
2274 | u: converter, | ||
2275 | a: _Platform_setupIncomingPort | ||
2276 | }; | ||
2277 | return _Platform_leaf(name); | ||
2278 | } | ||
2279 | |||
2280 | |||
2281 | var _Platform_incomingPortMap = F2(function(tagger, finalTagger) | ||
2282 | { | ||
2283 | return function(value) | ||
2284 | { | ||
2285 | return tagger(finalTagger(value)); | ||
2286 | }; | ||
2287 | }); | ||
2288 | |||
2289 | |||
2290 | function _Platform_setupIncomingPort(name, sendToApp) | ||
2291 | { | ||
2292 | var subs = _List_Nil; | ||
2293 | var converter = _Platform_effectManagers[name].u; | ||
2294 | |||
2295 | // CREATE MANAGER | ||
2296 | |||
2297 | var init = _Scheduler_succeed(null); | ||
2298 | |||
2299 | _Platform_effectManagers[name].b = init; | ||
2300 | _Platform_effectManagers[name].c = F3(function(router, subList, state) | ||
2301 | { | ||
2302 | subs = subList; | ||
2303 | return init; | ||
2304 | }); | ||
2305 | |||
2306 | // PUBLIC API | ||
2307 | |||
2308 | function send(incomingValue) | ||
2309 | { | ||
2310 | var result = A2(_Json_run, converter, _Json_wrap(incomingValue)); | ||
2311 | |||
2312 | $elm$core$Result$isOk(result) || _Debug_crash(4, name, result.a); | ||
2313 | |||
2314 | var value = result.a; | ||
2315 | for (var temp = subs; temp.b; temp = temp.b) // WHILE_CONS | ||
2316 | { | ||
2317 | sendToApp(temp.a(value)); | ||
2318 | } | ||
2319 | } | ||
2320 | |||
2321 | return { send: send }; | ||
2322 | } | ||
2323 | |||
2324 | |||
2325 | |||
2326 | // EXPORT ELM MODULES | ||
2327 | // | ||
2328 | // Have DEBUG and PROD versions so that we can (1) give nicer errors in | ||
2329 | // debug mode and (2) not pay for the bits needed for that in prod mode. | ||
2330 | // | ||
2331 | |||
2332 | |||
2333 | function _Platform_export_UNUSED(exports) | ||
2334 | { | ||
2335 | scope['Elm'] | ||
2336 | ? _Platform_mergeExportsProd(scope['Elm'], exports) | ||
2337 | : scope['Elm'] = exports; | ||
2338 | } | ||
2339 | |||
2340 | |||
2341 | function _Platform_mergeExportsProd(obj, exports) | ||
2342 | { | ||
2343 | for (var name in exports) | ||
2344 | { | ||
2345 | (name in obj) | ||
2346 | ? (name == 'init') | ||
2347 | ? _Debug_crash(6) | ||
2348 | : _Platform_mergeExportsProd(obj[name], exports[name]) | ||
2349 | : (obj[name] = exports[name]); | ||
2350 | } | ||
2351 | } | ||
2352 | |||
2353 | |||
2354 | function _Platform_export(exports) | ||
2355 | { | ||
2356 | scope['Elm'] | ||
2357 | ? _Platform_mergeExportsDebug('Elm', scope['Elm'], exports) | ||
2358 | : scope['Elm'] = exports; | ||
2359 | } | ||
2360 | |||
2361 | |||
2362 | function _Platform_mergeExportsDebug(moduleName, obj, exports) | ||
2363 | { | ||
2364 | for (var name in exports) | ||
2365 | { | ||
2366 | (name in obj) | ||
2367 | ? (name == 'init') | ||
2368 | ? _Debug_crash(6, moduleName) | ||
2369 | : _Platform_mergeExportsDebug(moduleName + '.' + name, obj[name], exports[name]) | ||
2370 | : (obj[name] = exports[name]); | ||
2371 | } | ||
2372 | } | ||
2373 | |||
2374 | |||
2375 | |||
2376 | |||
2377 | // HELPERS | ||
2378 | |||
2379 | |||
2380 | var _VirtualDom_divertHrefToApp; | ||
2381 | |||
2382 | var _VirtualDom_doc = typeof document !== 'undefined' ? document : {}; | ||
2383 | |||
2384 | |||
2385 | function _VirtualDom_appendChild(parent, child) | ||
2386 | { | ||
2387 | parent.appendChild(child); | ||
2388 | } | ||
2389 | |||
2390 | var _VirtualDom_init = F4(function(virtualNode, flagDecoder, debugMetadata, args) | ||
2391 | { | ||
2392 | // NOTE: this function needs _Platform_export available to work | ||
2393 | |||
2394 | /**_UNUSED/ | ||
2395 | var node = args['node']; | ||
2396 | //*/ | ||
2397 | /**/ | ||
2398 | var node = args && args['node'] ? args['node'] : _Debug_crash(0); | ||
2399 | //*/ | ||
2400 | |||
2401 | node.parentNode.replaceChild( | ||
2402 | _VirtualDom_render(virtualNode, function() {}), | ||
2403 | node | ||
2404 | ); | ||
2405 | |||
2406 | return {}; | ||
2407 | }); | ||
2408 | |||
2409 | |||
2410 | |||
2411 | // TEXT | ||
2412 | |||
2413 | |||
2414 | function _VirtualDom_text(string) | ||
2415 | { | ||
2416 | return { | ||
2417 | $: 0, | ||
2418 | a: string | ||
2419 | }; | ||
2420 | } | ||
2421 | |||
2422 | |||
2423 | |||
2424 | // NODE | ||
2425 | |||
2426 | |||
2427 | var _VirtualDom_nodeNS = F2(function(namespace, tag) | ||
2428 | { | ||
2429 | return F2(function(factList, kidList) | ||
2430 | { | ||
2431 | for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS | ||
2432 | { | ||
2433 | var kid = kidList.a; | ||
2434 | descendantsCount += (kid.b || 0); | ||
2435 | kids.push(kid); | ||
2436 | } | ||
2437 | descendantsCount += kids.length; | ||
2438 | |||
2439 | return { | ||
2440 | $: 1, | ||
2441 | c: tag, | ||
2442 | d: _VirtualDom_organizeFacts(factList), | ||
2443 | e: kids, | ||
2444 | f: namespace, | ||
2445 | b: descendantsCount | ||
2446 | }; | ||
2447 | }); | ||
2448 | }); | ||
2449 | |||
2450 | |||
2451 | var _VirtualDom_node = _VirtualDom_nodeNS(undefined); | ||
2452 | |||
2453 | |||
2454 | |||
2455 | // KEYED NODE | ||
2456 | |||
2457 | |||
2458 | var _VirtualDom_keyedNodeNS = F2(function(namespace, tag) | ||
2459 | { | ||
2460 | return F2(function(factList, kidList) | ||
2461 | { | ||
2462 | for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS | ||
2463 | { | ||
2464 | var kid = kidList.a; | ||
2465 | descendantsCount += (kid.b.b || 0); | ||
2466 | kids.push(kid); | ||
2467 | } | ||
2468 | descendantsCount += kids.length; | ||
2469 | |||
2470 | return { | ||
2471 | $: 2, | ||
2472 | c: tag, | ||
2473 | d: _VirtualDom_organizeFacts(factList), | ||
2474 | e: kids, | ||
2475 | f: namespace, | ||
2476 | b: descendantsCount | ||
2477 | }; | ||
2478 | }); | ||
2479 | }); | ||
2480 | |||
2481 | |||
2482 | var _VirtualDom_keyedNode = _VirtualDom_keyedNodeNS(undefined); | ||
2483 | |||
2484 | |||
2485 | |||
2486 | // CUSTOM | ||
2487 | |||
2488 | |||
2489 | function _VirtualDom_custom(factList, model, render, diff) | ||
2490 | { | ||
2491 | return { | ||
2492 | $: 3, | ||
2493 | d: _VirtualDom_organizeFacts(factList), | ||
2494 | g: model, | ||
2495 | h: render, | ||
2496 | i: diff | ||
2497 | }; | ||
2498 | } | ||
2499 | |||
2500 | |||
2501 | |||
2502 | // MAP | ||
2503 | |||
2504 | |||
2505 | var _VirtualDom_map = F2(function(tagger, node) | ||
2506 | { | ||
2507 | return { | ||
2508 | $: 4, | ||
2509 | j: tagger, | ||
2510 | k: node, | ||
2511 | b: 1 + (node.b || 0) | ||
2512 | }; | ||
2513 | }); | ||
2514 | |||
2515 | |||
2516 | |||
2517 | // LAZY | ||
2518 | |||
2519 | |||
2520 | function _VirtualDom_thunk(refs, thunk) | ||
2521 | { | ||
2522 | return { | ||
2523 | $: 5, | ||
2524 | l: refs, | ||
2525 | m: thunk, | ||
2526 | k: undefined | ||
2527 | }; | ||
2528 | } | ||
2529 | |||
2530 | var _VirtualDom_lazy = F2(function(func, a) | ||
2531 | { | ||
2532 | return _VirtualDom_thunk([func, a], function() { | ||
2533 | return func(a); | ||
2534 | }); | ||
2535 | }); | ||
2536 | |||
2537 | var _VirtualDom_lazy2 = F3(function(func, a, b) | ||
2538 | { | ||
2539 | return _VirtualDom_thunk([func, a, b], function() { | ||
2540 | return A2(func, a, b); | ||
2541 | }); | ||
2542 | }); | ||
2543 | |||
2544 | var _VirtualDom_lazy3 = F4(function(func, a, b, c) | ||
2545 | { | ||
2546 | return _VirtualDom_thunk([func, a, b, c], function() { | ||
2547 | return A3(func, a, b, c); | ||
2548 | }); | ||
2549 | }); | ||
2550 | |||
2551 | var _VirtualDom_lazy4 = F5(function(func, a, b, c, d) | ||
2552 | { | ||
2553 | return _VirtualDom_thunk([func, a, b, c, d], function() { | ||
2554 | return A4(func, a, b, c, d); | ||
2555 | }); | ||
2556 | }); | ||
2557 | |||
2558 | var _VirtualDom_lazy5 = F6(function(func, a, b, c, d, e) | ||
2559 | { | ||
2560 | return _VirtualDom_thunk([func, a, b, c, d, e], function() { | ||
2561 | return A5(func, a, b, c, d, e); | ||
2562 | }); | ||
2563 | }); | ||
2564 | |||
2565 | var _VirtualDom_lazy6 = F7(function(func, a, b, c, d, e, f) | ||
2566 | { | ||
2567 | return _VirtualDom_thunk([func, a, b, c, d, e, f], function() { | ||
2568 | return A6(func, a, b, c, d, e, f); | ||
2569 | }); | ||
2570 | }); | ||
2571 | |||
2572 | var _VirtualDom_lazy7 = F8(function(func, a, b, c, d, e, f, g) | ||
2573 | { | ||
2574 | return _VirtualDom_thunk([func, a, b, c, d, e, f, g], function() { | ||
2575 | return A7(func, a, b, c, d, e, f, g); | ||
2576 | }); | ||
2577 | }); | ||
2578 | |||
2579 | var _VirtualDom_lazy8 = F9(function(func, a, b, c, d, e, f, g, h) | ||
2580 | { | ||
2581 | return _VirtualDom_thunk([func, a, b, c, d, e, f, g, h], function() { | ||
2582 | return A8(func, a, b, c, d, e, f, g, h); | ||
2583 | }); | ||
2584 | }); | ||
2585 | |||
2586 | |||
2587 | |||
2588 | // FACTS | ||
2589 | |||
2590 | |||
2591 | var _VirtualDom_on = F2(function(key, handler) | ||
2592 | { | ||
2593 | return { | ||
2594 | $: 'a0', | ||
2595 | n: key, | ||
2596 | o: handler | ||
2597 | }; | ||
2598 | }); | ||
2599 | var _VirtualDom_style = F2(function(key, value) | ||
2600 | { | ||
2601 | return { | ||
2602 | $: 'a1', | ||
2603 | n: key, | ||
2604 | o: value | ||
2605 | }; | ||
2606 | }); | ||
2607 | var _VirtualDom_property = F2(function(key, value) | ||
2608 | { | ||
2609 | return { | ||
2610 | $: 'a2', | ||
2611 | n: key, | ||
2612 | o: value | ||
2613 | }; | ||
2614 | }); | ||
2615 | var _VirtualDom_attribute = F2(function(key, value) | ||
2616 | { | ||
2617 | return { | ||
2618 | $: 'a3', | ||
2619 | n: key, | ||
2620 | o: value | ||
2621 | }; | ||
2622 | }); | ||
2623 | var _VirtualDom_attributeNS = F3(function(namespace, key, value) | ||
2624 | { | ||
2625 | return { | ||
2626 | $: 'a4', | ||
2627 | n: key, | ||
2628 | o: { f: namespace, o: value } | ||
2629 | }; | ||
2630 | }); | ||
2631 | |||
2632 | |||
2633 | |||
2634 | // XSS ATTACK VECTOR CHECKS | ||
2635 | |||
2636 | |||
2637 | function _VirtualDom_noScript(tag) | ||
2638 | { | ||
2639 | return tag == 'script' ? 'p' : tag; | ||
2640 | } | ||
2641 | |||
2642 | function _VirtualDom_noOnOrFormAction(key) | ||
2643 | { | ||
2644 | return /^(on|formAction$)/i.test(key) ? 'data-' + key : key; | ||
2645 | } | ||
2646 | |||
2647 | function _VirtualDom_noInnerHtmlOrFormAction(key) | ||
2648 | { | ||
2649 | return key == 'innerHTML' || key == 'formAction' ? 'data-' + key : key; | ||
2650 | } | ||
2651 | |||
2652 | function _VirtualDom_noJavaScriptUri_UNUSED(value) | ||
2653 | { | ||
2654 | return /^javascript:/i.test(value.replace(/\s/g,'')) ? '' : value; | ||
2655 | } | ||
2656 | |||
2657 | function _VirtualDom_noJavaScriptUri(value) | ||
2658 | { | ||
2659 | return /^javascript:/i.test(value.replace(/\s/g,'')) | ||
2660 | ? 'javascript:alert("This is an XSS vector. Please use ports or web components instead.")' | ||
2661 | : value; | ||
2662 | } | ||
2663 | |||
2664 | function _VirtualDom_noJavaScriptOrHtmlUri_UNUSED(value) | ||
2665 | { | ||
2666 | return /^\s*(javascript:|data:text\/html)/i.test(value) ? '' : value; | ||
2667 | } | ||
2668 | |||
2669 | function _VirtualDom_noJavaScriptOrHtmlUri(value) | ||
2670 | { | ||
2671 | return /^\s*(javascript:|data:text\/html)/i.test(value) | ||
2672 | ? 'javascript:alert("This is an XSS vector. Please use ports or web components instead.")' | ||
2673 | : value; | ||
2674 | } | ||
2675 | |||
2676 | |||
2677 | |||
2678 | // MAP FACTS | ||
2679 | |||
2680 | |||
2681 | var _VirtualDom_mapAttribute = F2(function(func, attr) | ||
2682 | { | ||
2683 | return (attr.$ === 'a0') | ||
2684 | ? A2(_VirtualDom_on, attr.n, _VirtualDom_mapHandler(func, attr.o)) | ||
2685 | : attr; | ||
2686 | }); | ||
2687 | |||
2688 | function _VirtualDom_mapHandler(func, handler) | ||
2689 | { | ||
2690 | var tag = $elm$virtual_dom$VirtualDom$toHandlerInt(handler); | ||
2691 | |||
2692 | // 0 = Normal | ||
2693 | // 1 = MayStopPropagation | ||
2694 | // 2 = MayPreventDefault | ||
2695 | // 3 = Custom | ||
2696 | |||
2697 | return { | ||
2698 | $: handler.$, | ||
2699 | a: | ||
2700 | !tag | ||
2701 | ? A2($elm$json$Json$Decode$map, func, handler.a) | ||
2702 | : | ||
2703 | A3($elm$json$Json$Decode$map2, | ||
2704 | tag < 3 | ||
2705 | ? _VirtualDom_mapEventTuple | ||
2706 | : _VirtualDom_mapEventRecord, | ||
2707 | $elm$json$Json$Decode$succeed(func), | ||
2708 | handler.a | ||
2709 | ) | ||
2710 | }; | ||
2711 | } | ||
2712 | |||
2713 | var _VirtualDom_mapEventTuple = F2(function(func, tuple) | ||
2714 | { | ||
2715 | return _Utils_Tuple2(func(tuple.a), tuple.b); | ||
2716 | }); | ||
2717 | |||
2718 | var _VirtualDom_mapEventRecord = F2(function(func, record) | ||
2719 | { | ||
2720 | return { | ||
2721 | message: func(record.message), | ||
2722 | stopPropagation: record.stopPropagation, | ||
2723 | preventDefault: record.preventDefault | ||
2724 | } | ||
2725 | }); | ||
2726 | |||
2727 | |||
2728 | |||
2729 | // ORGANIZE FACTS | ||
2730 | |||
2731 | |||
2732 | function _VirtualDom_organizeFacts(factList) | ||
2733 | { | ||
2734 | for (var facts = {}; factList.b; factList = factList.b) // WHILE_CONS | ||
2735 | { | ||
2736 | var entry = factList.a; | ||
2737 | |||
2738 | var tag = entry.$; | ||
2739 | var key = entry.n; | ||
2740 | var value = entry.o; | ||
2741 | |||
2742 | if (tag === 'a2') | ||
2743 | { | ||
2744 | (key === 'className') | ||
2745 | ? _VirtualDom_addClass(facts, key, _Json_unwrap(value)) | ||
2746 | : facts[key] = _Json_unwrap(value); | ||
2747 | |||
2748 | continue; | ||
2749 | } | ||
2750 | |||
2751 | var subFacts = facts[tag] || (facts[tag] = {}); | ||
2752 | (tag === 'a3' && key === 'class') | ||
2753 | ? _VirtualDom_addClass(subFacts, key, value) | ||
2754 | : subFacts[key] = value; | ||
2755 | } | ||
2756 | |||
2757 | return facts; | ||
2758 | } | ||
2759 | |||
2760 | function _VirtualDom_addClass(object, key, newClass) | ||
2761 | { | ||
2762 | var classes = object[key]; | ||
2763 | object[key] = classes ? classes + ' ' + newClass : newClass; | ||
2764 | } | ||
2765 | |||
2766 | |||
2767 | |||
2768 | // RENDER | ||
2769 | |||
2770 | |||
2771 | function _VirtualDom_render(vNode, eventNode) | ||
2772 | { | ||
2773 | var tag = vNode.$; | ||
2774 | |||
2775 | if (tag === 5) | ||
2776 | { | ||
2777 | return _VirtualDom_render(vNode.k || (vNode.k = vNode.m()), eventNode); | ||
2778 | } | ||
2779 | |||
2780 | if (tag === 0) | ||
2781 | { | ||
2782 | return _VirtualDom_doc.createTextNode(vNode.a); | ||
2783 | } | ||
2784 | |||
2785 | if (tag === 4) | ||
2786 | { | ||
2787 | var subNode = vNode.k; | ||
2788 | var tagger = vNode.j; | ||
2789 | |||
2790 | while (subNode.$ === 4) | ||
2791 | { | ||
2792 | typeof tagger !== 'object' | ||
2793 | ? tagger = [tagger, subNode.j] | ||
2794 | : tagger.push(subNode.j); | ||
2795 | |||
2796 | subNode = subNode.k; | ||
2797 | } | ||
2798 | |||
2799 | var subEventRoot = { j: tagger, p: eventNode }; | ||
2800 | var domNode = _VirtualDom_render(subNode, subEventRoot); | ||
2801 | domNode.elm_event_node_ref = subEventRoot; | ||
2802 | return domNode; | ||
2803 | } | ||
2804 | |||
2805 | if (tag === 3) | ||
2806 | { | ||
2807 | var domNode = vNode.h(vNode.g); | ||
2808 | _VirtualDom_applyFacts(domNode, eventNode, vNode.d); | ||
2809 | return domNode; | ||
2810 | } | ||
2811 | |||
2812 | // at this point `tag` must be 1 or 2 | ||
2813 | |||
2814 | var domNode = vNode.f | ||
2815 | ? _VirtualDom_doc.createElementNS(vNode.f, vNode.c) | ||
2816 | : _VirtualDom_doc.createElement(vNode.c); | ||
2817 | |||
2818 | if (_VirtualDom_divertHrefToApp && vNode.c == 'a') | ||
2819 | { | ||
2820 | domNode.addEventListener('click', _VirtualDom_divertHrefToApp(domNode)); | ||
2821 | } | ||
2822 | |||
2823 | _VirtualDom_applyFacts(domNode, eventNode, vNode.d); | ||
2824 | |||
2825 | for (var kids = vNode.e, i = 0; i < kids.length; i++) | ||
2826 | { | ||
2827 | _VirtualDom_appendChild(domNode, _VirtualDom_render(tag === 1 ? kids[i] : kids[i].b, eventNode)); | ||
2828 | } | ||
2829 | |||
2830 | return domNode; | ||
2831 | } | ||
2832 | |||
2833 | |||
2834 | |||
2835 | // APPLY FACTS | ||
2836 | |||
2837 | |||
2838 | function _VirtualDom_applyFacts(domNode, eventNode, facts) | ||
2839 | { | ||
2840 | for (var key in facts) | ||
2841 | { | ||
2842 | var value = facts[key]; | ||
2843 | |||
2844 | key === 'a1' | ||
2845 | ? _VirtualDom_applyStyles(domNode, value) | ||
2846 | : | ||
2847 | key === 'a0' | ||
2848 | ? _VirtualDom_applyEvents(domNode, eventNode, value) | ||
2849 | : | ||
2850 | key === 'a3' | ||
2851 | ? _VirtualDom_applyAttrs(domNode, value) | ||
2852 | : | ||
2853 | key === 'a4' | ||
2854 | ? _VirtualDom_applyAttrsNS(domNode, value) | ||
2855 | : | ||
2856 | ((key !== 'value' && key !== 'checked') || domNode[key] !== value) && (domNode[key] = value); | ||
2857 | } | ||
2858 | } | ||
2859 | |||
2860 | |||
2861 | |||
2862 | // APPLY STYLES | ||
2863 | |||
2864 | |||
2865 | function _VirtualDom_applyStyles(domNode, styles) | ||
2866 | { | ||
2867 | var domNodeStyle = domNode.style; | ||
2868 | |||
2869 | for (var key in styles) | ||
2870 | { | ||
2871 | domNodeStyle[key] = styles[key]; | ||
2872 | } | ||
2873 | } | ||
2874 | |||
2875 | |||
2876 | |||
2877 | // APPLY ATTRS | ||
2878 | |||
2879 | |||
2880 | function _VirtualDom_applyAttrs(domNode, attrs) | ||
2881 | { | ||
2882 | for (var key in attrs) | ||
2883 | { | ||
2884 | var value = attrs[key]; | ||
2885 | typeof value !== 'undefined' | ||
2886 | ? domNode.setAttribute(key, value) | ||
2887 | : domNode.removeAttribute(key); | ||
2888 | } | ||
2889 | } | ||
2890 | |||
2891 | |||
2892 | |||
2893 | // APPLY NAMESPACED ATTRS | ||
2894 | |||
2895 | |||
2896 | function _VirtualDom_applyAttrsNS(domNode, nsAttrs) | ||
2897 | { | ||
2898 | for (var key in nsAttrs) | ||
2899 | { | ||
2900 | var pair = nsAttrs[key]; | ||
2901 | var namespace = pair.f; | ||
2902 | var value = pair.o; | ||
2903 | |||
2904 | typeof value !== 'undefined' | ||
2905 | ? domNode.setAttributeNS(namespace, key, value) | ||
2906 | : domNode.removeAttributeNS(namespace, key); | ||
2907 | } | ||
2908 | } | ||
2909 | |||
2910 | |||
2911 | |||
2912 | // APPLY EVENTS | ||
2913 | |||
2914 | |||
2915 | function _VirtualDom_applyEvents(domNode, eventNode, events) | ||
2916 | { | ||
2917 | var allCallbacks = domNode.elmFs || (domNode.elmFs = {}); | ||
2918 | |||
2919 | for (var key in events) | ||
2920 | { | ||
2921 | var newHandler = events[key]; | ||
2922 | var oldCallback = allCallbacks[key]; | ||
2923 | |||
2924 | if (!newHandler) | ||
2925 | { | ||
2926 | domNode.removeEventListener(key, oldCallback); | ||
2927 | allCallbacks[key] = undefined; | ||
2928 | continue; | ||
2929 | } | ||
2930 | |||
2931 | if (oldCallback) | ||
2932 | { | ||
2933 | var oldHandler = oldCallback.q; | ||
2934 | if (oldHandler.$ === newHandler.$) | ||
2935 | { | ||
2936 | oldCallback.q = newHandler; | ||
2937 | continue; | ||
2938 | } | ||
2939 | domNode.removeEventListener(key, oldCallback); | ||
2940 | } | ||
2941 | |||
2942 | oldCallback = _VirtualDom_makeCallback(eventNode, newHandler); | ||
2943 | domNode.addEventListener(key, oldCallback, | ||
2944 | _VirtualDom_passiveSupported | ||
2945 | && { passive: $elm$virtual_dom$VirtualDom$toHandlerInt(newHandler) < 2 } | ||
2946 | ); | ||
2947 | allCallbacks[key] = oldCallback; | ||
2948 | } | ||
2949 | } | ||
2950 | |||
2951 | |||
2952 | |||
2953 | // PASSIVE EVENTS | ||
2954 | |||
2955 | |||
2956 | var _VirtualDom_passiveSupported; | ||
2957 | |||
2958 | try | ||
2959 | { | ||
2960 | window.addEventListener('t', null, Object.defineProperty({}, 'passive', { | ||
2961 | get: function() { _VirtualDom_passiveSupported = true; } | ||
2962 | })); | ||
2963 | } | ||
2964 | catch(e) {} | ||
2965 | |||
2966 | |||
2967 | |||
2968 | // EVENT HANDLERS | ||
2969 | |||
2970 | |||
2971 | function _VirtualDom_makeCallback(eventNode, initialHandler) | ||
2972 | { | ||
2973 | function callback(event) | ||
2974 | { | ||
2975 | var handler = callback.q; | ||
2976 | var result = _Json_runHelp(handler.a, event); | ||
2977 | |||
2978 | if (!$elm$core$Result$isOk(result)) | ||
2979 | { | ||
2980 | return; | ||
2981 | } | ||
2982 | |||
2983 | var tag = $elm$virtual_dom$VirtualDom$toHandlerInt(handler); | ||
2984 | |||
2985 | // 0 = Normal | ||
2986 | // 1 = MayStopPropagation | ||
2987 | // 2 = MayPreventDefault | ||
2988 | // 3 = Custom | ||
2989 | |||
2990 | var value = result.a; | ||
2991 | var message = !tag ? value : tag < 3 ? value.a : value.message; | ||
2992 | var stopPropagation = tag == 1 ? value.b : tag == 3 && value.stopPropagation; | ||
2993 | var currentEventNode = ( | ||
2994 | stopPropagation && event.stopPropagation(), | ||
2995 | (tag == 2 ? value.b : tag == 3 && value.preventDefault) && event.preventDefault(), | ||
2996 | eventNode | ||
2997 | ); | ||
2998 | var tagger; | ||
2999 | var i; | ||
3000 | while (tagger = currentEventNode.j) | ||
3001 | { | ||
3002 | if (typeof tagger == 'function') | ||
3003 | { | ||
3004 | message = tagger(message); | ||
3005 | } | ||
3006 | else | ||
3007 | { | ||
3008 | for (var i = tagger.length; i--; ) | ||
3009 | { | ||
3010 | message = tagger[i](message); | ||
3011 | } | ||
3012 | } | ||
3013 | currentEventNode = currentEventNode.p; | ||
3014 | } | ||
3015 | currentEventNode(message, stopPropagation); // stopPropagation implies isSync | ||
3016 | } | ||
3017 | |||
3018 | callback.q = initialHandler; | ||
3019 | |||
3020 | return callback; | ||
3021 | } | ||
3022 | |||
3023 | function _VirtualDom_equalEvents(x, y) | ||
3024 | { | ||
3025 | return x.$ == y.$ && _Json_equality(x.a, y.a); | ||
3026 | } | ||
3027 | |||
3028 | |||
3029 | |||
3030 | // DIFF | ||
3031 | |||
3032 | |||
3033 | // TODO: Should we do patches like in iOS? | ||
3034 | // | ||
3035 | // type Patch | ||
3036 | // = At Int Patch | ||
3037 | // | Batch (List Patch) | ||
3038 | // | Change ... | ||
3039 | // | ||
3040 | // How could it not be better? | ||
3041 | // | ||
3042 | function _VirtualDom_diff(x, y) | ||
3043 | { | ||
3044 | var patches = []; | ||
3045 | _VirtualDom_diffHelp(x, y, patches, 0); | ||
3046 | return patches; | ||
3047 | } | ||
3048 | |||
3049 | |||
3050 | function _VirtualDom_pushPatch(patches, type, index, data) | ||
3051 | { | ||
3052 | var patch = { | ||
3053 | $: type, | ||
3054 | r: index, | ||
3055 | s: data, | ||
3056 | t: undefined, | ||
3057 | u: undefined | ||
3058 | }; | ||
3059 | patches.push(patch); | ||
3060 | return patch; | ||
3061 | } | ||
3062 | |||
3063 | |||
3064 | function _VirtualDom_diffHelp(x, y, patches, index) | ||
3065 | { | ||
3066 | if (x === y) | ||
3067 | { | ||
3068 | return; | ||
3069 | } | ||
3070 | |||
3071 | var xType = x.$; | ||
3072 | var yType = y.$; | ||
3073 | |||
3074 | // Bail if you run into different types of nodes. Implies that the | ||
3075 | // structure has changed significantly and it's not worth a diff. | ||
3076 | if (xType !== yType) | ||
3077 | { | ||
3078 | if (xType === 1 && yType === 2) | ||
3079 | { | ||
3080 | y = _VirtualDom_dekey(y); | ||
3081 | yType = 1; | ||
3082 | } | ||
3083 | else | ||
3084 | { | ||
3085 | _VirtualDom_pushPatch(patches, 0, index, y); | ||
3086 | return; | ||
3087 | } | ||
3088 | } | ||
3089 | |||
3090 | // Now we know that both nodes are the same $. | ||
3091 | switch (yType) | ||
3092 | { | ||
3093 | case 5: | ||
3094 | var xRefs = x.l; | ||
3095 | var yRefs = y.l; | ||
3096 | var i = xRefs.length; | ||
3097 | var same = i === yRefs.length; | ||
3098 | while (same && i--) | ||
3099 | { | ||
3100 | same = xRefs[i] === yRefs[i]; | ||
3101 | } | ||
3102 | if (same) | ||
3103 | { | ||
3104 | y.k = x.k; | ||
3105 | return; | ||
3106 | } | ||
3107 | y.k = y.m(); | ||
3108 | var subPatches = []; | ||
3109 | _VirtualDom_diffHelp(x.k, y.k, subPatches, 0); | ||
3110 | subPatches.length > 0 && _VirtualDom_pushPatch(patches, 1, index, subPatches); | ||
3111 | return; | ||
3112 | |||
3113 | case 4: | ||
3114 | // gather nested taggers | ||
3115 | var xTaggers = x.j; | ||
3116 | var yTaggers = y.j; | ||
3117 | var nesting = false; | ||
3118 | |||
3119 | var xSubNode = x.k; | ||
3120 | while (xSubNode.$ === 4) | ||
3121 | { | ||
3122 | nesting = true; | ||
3123 | |||
3124 | typeof xTaggers !== 'object' | ||
3125 | ? xTaggers = [xTaggers, xSubNode.j] | ||
3126 | : xTaggers.push(xSubNode.j); | ||
3127 | |||
3128 | xSubNode = xSubNode.k; | ||
3129 | } | ||
3130 | |||
3131 | var ySubNode = y.k; | ||
3132 | while (ySubNode.$ === 4) | ||
3133 | { | ||
3134 | nesting = true; | ||
3135 | |||
3136 | typeof yTaggers !== 'object' | ||
3137 | ? yTaggers = [yTaggers, ySubNode.j] | ||
3138 | : yTaggers.push(ySubNode.j); | ||
3139 | |||
3140 | ySubNode = ySubNode.k; | ||
3141 | } | ||
3142 | |||
3143 | // Just bail if different numbers of taggers. This implies the | ||
3144 | // structure of the virtual DOM has changed. | ||
3145 | if (nesting && xTaggers.length !== yTaggers.length) | ||
3146 | { | ||
3147 | _VirtualDom_pushPatch(patches, 0, index, y); | ||
3148 | return; | ||
3149 | } | ||
3150 | |||
3151 | // check if taggers are "the same" | ||
3152 | if (nesting ? !_VirtualDom_pairwiseRefEqual(xTaggers, yTaggers) : xTaggers !== yTaggers) | ||
3153 | { | ||
3154 | _VirtualDom_pushPatch(patches, 2, index, yTaggers); | ||
3155 | } | ||
3156 | |||
3157 | // diff everything below the taggers | ||
3158 | _VirtualDom_diffHelp(xSubNode, ySubNode, patches, index + 1); | ||
3159 | return; | ||
3160 | |||
3161 | case 0: | ||
3162 | if (x.a !== y.a) | ||
3163 | { | ||
3164 | _VirtualDom_pushPatch(patches, 3, index, y.a); | ||
3165 | } | ||
3166 | return; | ||
3167 | |||
3168 | case 1: | ||
3169 | _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKids); | ||
3170 | return; | ||
3171 | |||
3172 | case 2: | ||
3173 | _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKeyedKids); | ||
3174 | return; | ||
3175 | |||
3176 | case 3: | ||
3177 | if (x.h !== y.h) | ||
3178 | { | ||
3179 | _VirtualDom_pushPatch(patches, 0, index, y); | ||
3180 | return; | ||
3181 | } | ||
3182 | |||
3183 | var factsDiff = _VirtualDom_diffFacts(x.d, y.d); | ||
3184 | factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff); | ||
3185 | |||
3186 | var patch = y.i(x.g, y.g); | ||
3187 | patch && _VirtualDom_pushPatch(patches, 5, index, patch); | ||
3188 | |||
3189 | return; | ||
3190 | } | ||
3191 | } | ||
3192 | |||
3193 | // assumes the incoming arrays are the same length | ||
3194 | function _VirtualDom_pairwiseRefEqual(as, bs) | ||
3195 | { | ||
3196 | for (var i = 0; i < as.length; i++) | ||
3197 | { | ||
3198 | if (as[i] !== bs[i]) | ||
3199 | { | ||
3200 | return false; | ||
3201 | } | ||
3202 | } | ||
3203 | |||
3204 | return true; | ||
3205 | } | ||
3206 | |||
3207 | function _VirtualDom_diffNodes(x, y, patches, index, diffKids) | ||
3208 | { | ||
3209 | // Bail if obvious indicators have changed. Implies more serious | ||
3210 | // structural changes such that it's not worth it to diff. | ||
3211 | if (x.c !== y.c || x.f !== y.f) | ||
3212 | { | ||
3213 | _VirtualDom_pushPatch(patches, 0, index, y); | ||
3214 | return; | ||
3215 | } | ||
3216 | |||
3217 | var factsDiff = _VirtualDom_diffFacts(x.d, y.d); | ||
3218 | factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff); | ||
3219 | |||
3220 | diffKids(x, y, patches, index); | ||
3221 | } | ||
3222 | |||
3223 | |||
3224 | |||
3225 | // DIFF FACTS | ||
3226 | |||
3227 | |||
3228 | // TODO Instead of creating a new diff object, it's possible to just test if | ||
3229 | // there *is* a diff. During the actual patch, do the diff again and make the | ||
3230 | // modifications directly. This way, there's no new allocations. Worth it? | ||
3231 | function _VirtualDom_diffFacts(x, y, category) | ||
3232 | { | ||
3233 | var diff; | ||
3234 | |||
3235 | // look for changes and removals | ||
3236 | for (var xKey in x) | ||
3237 | { | ||
3238 | if (xKey === 'a1' || xKey === 'a0' || xKey === 'a3' || xKey === 'a4') | ||
3239 | { | ||
3240 | var subDiff = _VirtualDom_diffFacts(x[xKey], y[xKey] || {}, xKey); | ||
3241 | if (subDiff) | ||
3242 | { | ||
3243 | diff = diff || {}; | ||
3244 | diff[xKey] = subDiff; | ||
3245 | } | ||
3246 | continue; | ||
3247 | } | ||
3248 | |||
3249 | // remove if not in the new facts | ||
3250 | if (!(xKey in y)) | ||
3251 | { | ||
3252 | diff = diff || {}; | ||
3253 | diff[xKey] = | ||
3254 | !category | ||
3255 | ? (typeof x[xKey] === 'string' ? '' : null) | ||
3256 | : | ||
3257 | (category === 'a1') | ||
3258 | ? '' | ||
3259 | : | ||
3260 | (category === 'a0' || category === 'a3') | ||
3261 | ? undefined | ||
3262 | : | ||
3263 | { f: x[xKey].f, o: undefined }; | ||
3264 | |||
3265 | continue; | ||
3266 | } | ||
3267 | |||
3268 | var xValue = x[xKey]; | ||
3269 | var yValue = y[xKey]; | ||
3270 | |||
3271 | // reference equal, so don't worry about it | ||
3272 | if (xValue === yValue && xKey !== 'value' && xKey !== 'checked' | ||
3273 | || category === 'a0' && _VirtualDom_equalEvents(xValue, yValue)) | ||
3274 | { | ||
3275 | continue; | ||
3276 | } | ||
3277 | |||
3278 | diff = diff || {}; | ||
3279 | diff[xKey] = yValue; | ||
3280 | } | ||
3281 | |||
3282 | // add new stuff | ||
3283 | for (var yKey in y) | ||
3284 | { | ||
3285 | if (!(yKey in x)) | ||
3286 | { | ||
3287 | diff = diff || {}; | ||
3288 | diff[yKey] = y[yKey]; | ||
3289 | } | ||
3290 | } | ||
3291 | |||
3292 | return diff; | ||
3293 | } | ||
3294 | |||
3295 | |||
3296 | |||
3297 | // DIFF KIDS | ||
3298 | |||
3299 | |||
3300 | function _VirtualDom_diffKids(xParent, yParent, patches, index) | ||
3301 | { | ||
3302 | var xKids = xParent.e; | ||
3303 | var yKids = yParent.e; | ||
3304 | |||
3305 | var xLen = xKids.length; | ||
3306 | var yLen = yKids.length; | ||
3307 | |||
3308 | // FIGURE OUT IF THERE ARE INSERTS OR REMOVALS | ||
3309 | |||
3310 | if (xLen > yLen) | ||
3311 | { | ||
3312 | _VirtualDom_pushPatch(patches, 6, index, { | ||
3313 | v: yLen, | ||
3314 | i: xLen - yLen | ||
3315 | }); | ||
3316 | } | ||
3317 | else if (xLen < yLen) | ||
3318 | { | ||
3319 | _VirtualDom_pushPatch(patches, 7, index, { | ||
3320 | v: xLen, | ||
3321 | e: yKids | ||
3322 | }); | ||
3323 | } | ||
3324 | |||
3325 | // PAIRWISE DIFF EVERYTHING ELSE | ||
3326 | |||
3327 | for (var minLen = xLen < yLen ? xLen : yLen, i = 0; i < minLen; i++) | ||
3328 | { | ||
3329 | var xKid = xKids[i]; | ||
3330 | _VirtualDom_diffHelp(xKid, yKids[i], patches, ++index); | ||
3331 | index += xKid.b || 0; | ||
3332 | } | ||
3333 | } | ||
3334 | |||
3335 | |||
3336 | |||
3337 | // KEYED DIFF | ||
3338 | |||
3339 | |||
3340 | function _VirtualDom_diffKeyedKids(xParent, yParent, patches, rootIndex) | ||
3341 | { | ||
3342 | var localPatches = []; | ||
3343 | |||
3344 | var changes = {}; // Dict String Entry | ||
3345 | var inserts = []; // Array { index : Int, entry : Entry } | ||
3346 | // type Entry = { tag : String, vnode : VNode, index : Int, data : _ } | ||
3347 | |||
3348 | var xKids = xParent.e; | ||
3349 | var yKids = yParent.e; | ||
3350 | var xLen = xKids.length; | ||
3351 | var yLen = yKids.length; | ||
3352 | var xIndex = 0; | ||
3353 | var yIndex = 0; | ||
3354 | |||
3355 | var index = rootIndex; | ||
3356 | |||
3357 | while (xIndex < xLen && yIndex < yLen) | ||
3358 | { | ||
3359 | var x = xKids[xIndex]; | ||
3360 | var y = yKids[yIndex]; | ||
3361 | |||
3362 | var xKey = x.a; | ||
3363 | var yKey = y.a; | ||
3364 | var xNode = x.b; | ||
3365 | var yNode = y.b; | ||
3366 | |||
3367 | var newMatch = undefined; | ||
3368 | var oldMatch = undefined; | ||
3369 | |||
3370 | // check if keys match | ||
3371 | |||
3372 | if (xKey === yKey) | ||
3373 | { | ||
3374 | index++; | ||
3375 | _VirtualDom_diffHelp(xNode, yNode, localPatches, index); | ||
3376 | index += xNode.b || 0; | ||
3377 | |||
3378 | xIndex++; | ||
3379 | yIndex++; | ||
3380 | continue; | ||
3381 | } | ||
3382 | |||
3383 | // look ahead 1 to detect insertions and removals. | ||
3384 | |||
3385 | var xNext = xKids[xIndex + 1]; | ||
3386 | var yNext = yKids[yIndex + 1]; | ||
3387 | |||
3388 | if (xNext) | ||
3389 | { | ||
3390 | var xNextKey = xNext.a; | ||
3391 | var xNextNode = xNext.b; | ||
3392 | oldMatch = yKey === xNextKey; | ||
3393 | } | ||
3394 | |||
3395 | if (yNext) | ||
3396 | { | ||
3397 | var yNextKey = yNext.a; | ||
3398 | var yNextNode = yNext.b; | ||
3399 | newMatch = xKey === yNextKey; | ||
3400 | } | ||
3401 | |||
3402 | |||
3403 | // swap x and y | ||
3404 | if (newMatch && oldMatch) | ||
3405 | { | ||
3406 | index++; | ||
3407 | _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index); | ||
3408 | _VirtualDom_insertNode(changes, localPatches, xKey, yNode, yIndex, inserts); | ||
3409 | index += xNode.b || 0; | ||
3410 | |||
3411 | index++; | ||
3412 | _VirtualDom_removeNode(changes, localPatches, xKey, xNextNode, index); | ||
3413 | index += xNextNode.b || 0; | ||
3414 | |||
3415 | xIndex += 2; | ||
3416 | yIndex += 2; | ||
3417 | continue; | ||
3418 | } | ||
3419 | |||
3420 | // insert y | ||
3421 | if (newMatch) | ||
3422 | { | ||
3423 | index++; | ||
3424 | _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts); | ||
3425 | _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index); | ||
3426 | index += xNode.b || 0; | ||
3427 | |||
3428 | xIndex += 1; | ||
3429 | yIndex += 2; | ||
3430 | continue; | ||
3431 | } | ||
3432 | |||
3433 | // remove x | ||
3434 | if (oldMatch) | ||
3435 | { | ||
3436 | index++; | ||
3437 | _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index); | ||
3438 | index += xNode.b || 0; | ||
3439 | |||
3440 | index++; | ||
3441 | _VirtualDom_diffHelp(xNextNode, yNode, localPatches, index); | ||
3442 | index += xNextNode.b || 0; | ||
3443 | |||
3444 | xIndex += 2; | ||
3445 | yIndex += 1; | ||
3446 | continue; | ||
3447 | } | ||
3448 | |||
3449 | // remove x, insert y | ||
3450 | if (xNext && xNextKey === yNextKey) | ||
3451 | { | ||
3452 | index++; | ||
3453 | _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index); | ||
3454 | _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts); | ||
3455 | index += xNode.b || 0; | ||
3456 | |||
3457 | index++; | ||
3458 | _VirtualDom_diffHelp(xNextNode, yNextNode, localPatches, index); | ||
3459 | index += xNextNode.b || 0; | ||
3460 | |||
3461 | xIndex += 2; | ||
3462 | yIndex += 2; | ||
3463 | continue; | ||
3464 | } | ||
3465 | |||
3466 | break; | ||
3467 | } | ||
3468 | |||
3469 | // eat up any remaining nodes with removeNode and insertNode | ||
3470 | |||
3471 | while (xIndex < xLen) | ||
3472 | { | ||
3473 | index++; | ||
3474 | var x = xKids[xIndex]; | ||
3475 | var xNode = x.b; | ||
3476 | _VirtualDom_removeNode(changes, localPatches, x.a, xNode, index); | ||
3477 | index += xNode.b || 0; | ||
3478 | xIndex++; | ||
3479 | } | ||
3480 | |||
3481 | while (yIndex < yLen) | ||
3482 | { | ||
3483 | var endInserts = endInserts || []; | ||
3484 | var y = yKids[yIndex]; | ||
3485 | _VirtualDom_insertNode(changes, localPatches, y.a, y.b, undefined, endInserts); | ||
3486 | yIndex++; | ||
3487 | } | ||
3488 | |||
3489 | if (localPatches.length > 0 || inserts.length > 0 || endInserts) | ||
3490 | { | ||
3491 | _VirtualDom_pushPatch(patches, 8, rootIndex, { | ||
3492 | w: localPatches, | ||
3493 | x: inserts, | ||
3494 | y: endInserts | ||
3495 | }); | ||
3496 | } | ||
3497 | } | ||
3498 | |||
3499 | |||
3500 | |||
3501 | // CHANGES FROM KEYED DIFF | ||
3502 | |||
3503 | |||
3504 | var _VirtualDom_POSTFIX = '_elmW6BL'; | ||
3505 | |||
3506 | |||
3507 | function _VirtualDom_insertNode(changes, localPatches, key, vnode, yIndex, inserts) | ||
3508 | { | ||
3509 | var entry = changes[key]; | ||
3510 | |||
3511 | // never seen this key before | ||
3512 | if (!entry) | ||
3513 | { | ||
3514 | entry = { | ||
3515 | c: 0, | ||
3516 | z: vnode, | ||
3517 | r: yIndex, | ||
3518 | s: undefined | ||
3519 | }; | ||
3520 | |||
3521 | inserts.push({ r: yIndex, A: entry }); | ||
3522 | changes[key] = entry; | ||
3523 | |||
3524 | return; | ||
3525 | } | ||
3526 | |||
3527 | // this key was removed earlier, a match! | ||
3528 | if (entry.c === 1) | ||
3529 | { | ||
3530 | inserts.push({ r: yIndex, A: entry }); | ||
3531 | |||
3532 | entry.c = 2; | ||
3533 | var subPatches = []; | ||
3534 | _VirtualDom_diffHelp(entry.z, vnode, subPatches, entry.r); | ||
3535 | entry.r = yIndex; | ||
3536 | entry.s.s = { | ||
3537 | w: subPatches, | ||
3538 | A: entry | ||
3539 | }; | ||
3540 | |||
3541 | return; | ||
3542 | } | ||
3543 | |||
3544 | // this key has already been inserted or moved, a duplicate! | ||
3545 | _VirtualDom_insertNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, yIndex, inserts); | ||
3546 | } | ||
3547 | |||
3548 | |||
3549 | function _VirtualDom_removeNode(changes, localPatches, key, vnode, index) | ||
3550 | { | ||
3551 | var entry = changes[key]; | ||
3552 | |||
3553 | // never seen this key before | ||
3554 | if (!entry) | ||
3555 | { | ||
3556 | var patch = _VirtualDom_pushPatch(localPatches, 9, index, undefined); | ||
3557 | |||
3558 | changes[key] = { | ||
3559 | c: 1, | ||
3560 | z: vnode, | ||
3561 | r: index, | ||
3562 | s: patch | ||
3563 | }; | ||
3564 | |||
3565 | return; | ||
3566 | } | ||
3567 | |||
3568 | // this key was inserted earlier, a match! | ||
3569 | if (entry.c === 0) | ||
3570 | { | ||
3571 | entry.c = 2; | ||
3572 | var subPatches = []; | ||
3573 | _VirtualDom_diffHelp(vnode, entry.z, subPatches, index); | ||
3574 | |||
3575 | _VirtualDom_pushPatch(localPatches, 9, index, { | ||
3576 | w: subPatches, | ||
3577 | A: entry | ||
3578 | }); | ||
3579 | |||
3580 | return; | ||
3581 | } | ||
3582 | |||
3583 | // this key has already been removed or moved, a duplicate! | ||
3584 | _VirtualDom_removeNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, index); | ||
3585 | } | ||
3586 | |||
3587 | |||
3588 | |||
3589 | // ADD DOM NODES | ||
3590 | // | ||
3591 | // Each DOM node has an "index" assigned in order of traversal. It is important | ||
3592 | // to minimize our crawl over the actual DOM, so these indexes (along with the | ||
3593 | // descendantsCount of virtual nodes) let us skip touching entire subtrees of | ||
3594 | // the DOM if we know there are no patches there. | ||
3595 | |||
3596 | |||
3597 | function _VirtualDom_addDomNodes(domNode, vNode, patches, eventNode) | ||
3598 | { | ||
3599 | _VirtualDom_addDomNodesHelp(domNode, vNode, patches, 0, 0, vNode.b, eventNode); | ||
3600 | } | ||
3601 | |||
3602 | |||
3603 | // assumes `patches` is non-empty and indexes increase monotonically. | ||
3604 | function _VirtualDom_addDomNodesHelp(domNode, vNode, patches, i, low, high, eventNode) | ||
3605 | { | ||
3606 | var patch = patches[i]; | ||
3607 | var index = patch.r; | ||
3608 | |||
3609 | while (index === low) | ||
3610 | { | ||
3611 | var patchType = patch.$; | ||
3612 | |||
3613 | if (patchType === 1) | ||
3614 | { | ||
3615 | _VirtualDom_addDomNodes(domNode, vNode.k, patch.s, eventNode); | ||
3616 | } | ||
3617 | else if (patchType === 8) | ||
3618 | { | ||
3619 | patch.t = domNode; | ||
3620 | patch.u = eventNode; | ||
3621 | |||
3622 | var subPatches = patch.s.w; | ||
3623 | if (subPatches.length > 0) | ||
3624 | { | ||
3625 | _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode); | ||
3626 | } | ||
3627 | } | ||
3628 | else if (patchType === 9) | ||
3629 | { | ||
3630 | patch.t = domNode; | ||
3631 | patch.u = eventNode; | ||
3632 | |||
3633 | var data = patch.s; | ||
3634 | if (data) | ||
3635 | { | ||
3636 | data.A.s = domNode; | ||
3637 | var subPatches = data.w; | ||
3638 | if (subPatches.length > 0) | ||
3639 | { | ||
3640 | _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode); | ||
3641 | } | ||
3642 | } | ||
3643 | } | ||
3644 | else | ||
3645 | { | ||
3646 | patch.t = domNode; | ||
3647 | patch.u = eventNode; | ||
3648 | } | ||
3649 | |||
3650 | i++; | ||
3651 | |||
3652 | if (!(patch = patches[i]) || (index = patch.r) > high) | ||
3653 | { | ||
3654 | return i; | ||
3655 | } | ||
3656 | } | ||
3657 | |||
3658 | var tag = vNode.$; | ||
3659 | |||
3660 | if (tag === 4) | ||
3661 | { | ||
3662 | var subNode = vNode.k; | ||
3663 | |||
3664 | while (subNode.$ === 4) | ||
3665 | { | ||
3666 | subNode = subNode.k; | ||
3667 | } | ||
3668 | |||
3669 | return _VirtualDom_addDomNodesHelp(domNode, subNode, patches, i, low + 1, high, domNode.elm_event_node_ref); | ||
3670 | } | ||
3671 | |||
3672 | // tag must be 1 or 2 at this point | ||
3673 | |||
3674 | var vKids = vNode.e; | ||
3675 | var childNodes = domNode.childNodes; | ||
3676 | for (var j = 0; j < vKids.length; j++) | ||
3677 | { | ||
3678 | low++; | ||
3679 | var vKid = tag === 1 ? vKids[j] : vKids[j].b; | ||
3680 | var nextLow = low + (vKid.b || 0); | ||
3681 | if (low <= index && index <= nextLow) | ||
3682 | { | ||
3683 | i = _VirtualDom_addDomNodesHelp(childNodes[j], vKid, patches, i, low, nextLow, eventNode); | ||
3684 | if (!(patch = patches[i]) || (index = patch.r) > high) | ||
3685 | { | ||
3686 | return i; | ||
3687 | } | ||
3688 | } | ||
3689 | low = nextLow; | ||
3690 | } | ||
3691 | return i; | ||
3692 | } | ||
3693 | |||
3694 | |||
3695 | |||
3696 | // APPLY PATCHES | ||
3697 | |||
3698 | |||
3699 | function _VirtualDom_applyPatches(rootDomNode, oldVirtualNode, patches, eventNode) | ||
3700 | { | ||
3701 | if (patches.length === 0) | ||
3702 | { | ||
3703 | return rootDomNode; | ||
3704 | } | ||
3705 | |||
3706 | _VirtualDom_addDomNodes(rootDomNode, oldVirtualNode, patches, eventNode); | ||
3707 | return _VirtualDom_applyPatchesHelp(rootDomNode, patches); | ||
3708 | } | ||
3709 | |||
3710 | function _VirtualDom_applyPatchesHelp(rootDomNode, patches) | ||
3711 | { | ||
3712 | for (var i = 0; i < patches.length; i++) | ||
3713 | { | ||
3714 | var patch = patches[i]; | ||
3715 | var localDomNode = patch.t | ||
3716 | var newNode = _VirtualDom_applyPatch(localDomNode, patch); | ||
3717 | if (localDomNode === rootDomNode) | ||
3718 | { | ||
3719 | rootDomNode = newNode; | ||
3720 | } | ||
3721 | } | ||
3722 | return rootDomNode; | ||
3723 | } | ||
3724 | |||
3725 | function _VirtualDom_applyPatch(domNode, patch) | ||
3726 | { | ||
3727 | switch (patch.$) | ||
3728 | { | ||
3729 | case 0: | ||
3730 | return _VirtualDom_applyPatchRedraw(domNode, patch.s, patch.u); | ||
3731 | |||
3732 | case 4: | ||
3733 | _VirtualDom_applyFacts(domNode, patch.u, patch.s); | ||
3734 | return domNode; | ||
3735 | |||
3736 | case 3: | ||
3737 | domNode.replaceData(0, domNode.length, patch.s); | ||
3738 | return domNode; | ||
3739 | |||
3740 | case 1: | ||
3741 | return _VirtualDom_applyPatchesHelp(domNode, patch.s); | ||
3742 | |||
3743 | case 2: | ||
3744 | if (domNode.elm_event_node_ref) | ||
3745 | { | ||
3746 | domNode.elm_event_node_ref.j = patch.s; | ||
3747 | } | ||
3748 | else | ||
3749 | { | ||
3750 | domNode.elm_event_node_ref = { j: patch.s, p: patch.u }; | ||
3751 | } | ||
3752 | return domNode; | ||
3753 | |||
3754 | case 6: | ||
3755 | var data = patch.s; | ||
3756 | for (var i = 0; i < data.i; i++) | ||
3757 | { | ||
3758 | domNode.removeChild(domNode.childNodes[data.v]); | ||
3759 | } | ||
3760 | return domNode; | ||
3761 | |||
3762 | case 7: | ||
3763 | var data = patch.s; | ||
3764 | var kids = data.e; | ||
3765 | var i = data.v; | ||
3766 | var theEnd = domNode.childNodes[i]; | ||
3767 | for (; i < kids.length; i++) | ||
3768 | { | ||
3769 | domNode.insertBefore(_VirtualDom_render(kids[i], patch.u), theEnd); | ||
3770 | } | ||
3771 | return domNode; | ||
3772 | |||
3773 | case 9: | ||
3774 | var data = patch.s; | ||
3775 | if (!data) | ||
3776 | { | ||
3777 | domNode.parentNode.removeChild(domNode); | ||
3778 | return domNode; | ||
3779 | } | ||
3780 | var entry = data.A; | ||
3781 | if (typeof entry.r !== 'undefined') | ||
3782 | { | ||
3783 | domNode.parentNode.removeChild(domNode); | ||
3784 | } | ||
3785 | entry.s = _VirtualDom_applyPatchesHelp(domNode, data.w); | ||
3786 | return domNode; | ||
3787 | |||
3788 | case 8: | ||
3789 | return _VirtualDom_applyPatchReorder(domNode, patch); | ||
3790 | |||
3791 | case 5: | ||
3792 | return patch.s(domNode); | ||
3793 | |||
3794 | default: | ||
3795 | _Debug_crash(10); // 'Ran into an unknown patch!' | ||
3796 | } | ||
3797 | } | ||
3798 | |||
3799 | |||
3800 | function _VirtualDom_applyPatchRedraw(domNode, vNode, eventNode) | ||
3801 | { | ||
3802 | var parentNode = domNode.parentNode; | ||
3803 | var newNode = _VirtualDom_render(vNode, eventNode); | ||
3804 | |||
3805 | if (!newNode.elm_event_node_ref) | ||
3806 | { | ||
3807 | newNode.elm_event_node_ref = domNode.elm_event_node_ref; | ||
3808 | } | ||
3809 | |||
3810 | if (parentNode && newNode !== domNode) | ||
3811 | { | ||
3812 | parentNode.replaceChild(newNode, domNode); | ||
3813 | } | ||
3814 | return newNode; | ||
3815 | } | ||
3816 | |||
3817 | |||
3818 | function _VirtualDom_applyPatchReorder(domNode, patch) | ||
3819 | { | ||
3820 | var data = patch.s; | ||
3821 | |||
3822 | // remove end inserts | ||
3823 | var frag = _VirtualDom_applyPatchReorderEndInsertsHelp(data.y, patch); | ||
3824 | |||
3825 | // removals | ||
3826 | domNode = _VirtualDom_applyPatchesHelp(domNode, data.w); | ||
3827 | |||
3828 | // inserts | ||
3829 | var inserts = data.x; | ||
3830 | for (var i = 0; i < inserts.length; i++) | ||
3831 | { | ||
3832 | var insert = inserts[i]; | ||
3833 | var entry = insert.A; | ||
3834 | var node = entry.c === 2 | ||
3835 | ? entry.s | ||
3836 | : _VirtualDom_render(entry.z, patch.u); | ||
3837 | domNode.insertBefore(node, domNode.childNodes[insert.r]); | ||
3838 | } | ||
3839 | |||
3840 | // add end inserts | ||
3841 | if (frag) | ||
3842 | { | ||
3843 | _VirtualDom_appendChild(domNode, frag); | ||
3844 | } | ||
3845 | |||
3846 | return domNode; | ||
3847 | } | ||
3848 | |||
3849 | |||
3850 | function _VirtualDom_applyPatchReorderEndInsertsHelp(endInserts, patch) | ||
3851 | { | ||
3852 | if (!endInserts) | ||
3853 | { | ||
3854 | return; | ||
3855 | } | ||
3856 | |||
3857 | var frag = _VirtualDom_doc.createDocumentFragment(); | ||
3858 | for (var i = 0; i < endInserts.length; i++) | ||
3859 | { | ||
3860 | var insert = endInserts[i]; | ||
3861 | var entry = insert.A; | ||
3862 | _VirtualDom_appendChild(frag, entry.c === 2 | ||
3863 | ? entry.s | ||
3864 | : _VirtualDom_render(entry.z, patch.u) | ||
3865 | ); | ||
3866 | } | ||
3867 | return frag; | ||
3868 | } | ||
3869 | |||
3870 | |||
3871 | function _VirtualDom_virtualize(node) | ||
3872 | { | ||
3873 | // TEXT NODES | ||
3874 | |||
3875 | if (node.nodeType === 3) | ||
3876 | { | ||
3877 | return _VirtualDom_text(node.textContent); | ||
3878 | } | ||
3879 | |||
3880 | |||
3881 | // WEIRD NODES | ||
3882 | |||
3883 | if (node.nodeType !== 1) | ||
3884 | { | ||
3885 | return _VirtualDom_text(''); | ||
3886 | } | ||
3887 | |||
3888 | |||
3889 | // ELEMENT NODES | ||
3890 | |||
3891 | var attrList = _List_Nil; | ||
3892 | var attrs = node.attributes; | ||
3893 | for (var i = attrs.length; i--; ) | ||
3894 | { | ||
3895 | var attr = attrs[i]; | ||
3896 | var name = attr.name; | ||
3897 | var value = attr.value; | ||
3898 | attrList = _List_Cons( A2(_VirtualDom_attribute, name, value), attrList ); | ||
3899 | } | ||
3900 | |||
3901 | var tag = node.tagName.toLowerCase(); | ||
3902 | var kidList = _List_Nil; | ||
3903 | var kids = node.childNodes; | ||
3904 | |||
3905 | for (var i = kids.length; i--; ) | ||
3906 | { | ||
3907 | kidList = _List_Cons(_VirtualDom_virtualize(kids[i]), kidList); | ||
3908 | } | ||
3909 | return A3(_VirtualDom_node, tag, attrList, kidList); | ||
3910 | } | ||
3911 | |||
3912 | function _VirtualDom_dekey(keyedNode) | ||
3913 | { | ||
3914 | var keyedKids = keyedNode.e; | ||
3915 | var len = keyedKids.length; | ||
3916 | var kids = new Array(len); | ||
3917 | for (var i = 0; i < len; i++) | ||
3918 | { | ||
3919 | kids[i] = keyedKids[i].b; | ||
3920 | } | ||
3921 | |||
3922 | return { | ||
3923 | $: 1, | ||
3924 | c: keyedNode.c, | ||
3925 | d: keyedNode.d, | ||
3926 | e: kids, | ||
3927 | f: keyedNode.f, | ||
3928 | b: keyedNode.b | ||
3929 | }; | ||
3930 | } | ||
3931 | |||
3932 | |||
3933 | |||
3934 | |||
3935 | // ELEMENT | ||
3936 | |||
3937 | |||
3938 | var _Debugger_element; | ||
3939 | |||
3940 | var _Browser_element = _Debugger_element || F4(function(impl, flagDecoder, debugMetadata, args) | ||
3941 | { | ||
3942 | return _Platform_initialize( | ||
3943 | flagDecoder, | ||
3944 | args, | ||
3945 | impl.init, | ||
3946 | impl.update, | ||
3947 | impl.subscriptions, | ||
3948 | function(sendToApp, initialModel) { | ||
3949 | var view = impl.view; | ||
3950 | /**_UNUSED/ | ||
3951 | var domNode = args['node']; | ||
3952 | //*/ | ||
3953 | /**/ | ||
3954 | var domNode = args && args['node'] ? args['node'] : _Debug_crash(0); | ||
3955 | //*/ | ||
3956 | var currNode = _VirtualDom_virtualize(domNode); | ||
3957 | |||
3958 | return _Browser_makeAnimator(initialModel, function(model) | ||
3959 | { | ||
3960 | var nextNode = view(model); | ||
3961 | var patches = _VirtualDom_diff(currNode, nextNode); | ||
3962 | domNode = _VirtualDom_applyPatches(domNode, currNode, patches, sendToApp); | ||
3963 | currNode = nextNode; | ||
3964 | }); | ||
3965 | } | ||
3966 | ); | ||
3967 | }); | ||
3968 | |||
3969 | |||
3970 | |||
3971 | // DOCUMENT | ||
3972 | |||
3973 | |||
3974 | var _Debugger_document; | ||
3975 | |||
3976 | var _Browser_document = _Debugger_document || F4(function(impl, flagDecoder, debugMetadata, args) | ||
3977 | { | ||
3978 | return _Platform_initialize( | ||
3979 | flagDecoder, | ||
3980 | args, | ||
3981 | impl.init, | ||
3982 | impl.update, | ||
3983 | impl.subscriptions, | ||
3984 | function(sendToApp, initialModel) { | ||
3985 | var divertHrefToApp = impl.setup && impl.setup(sendToApp) | ||
3986 | var view = impl.view; | ||
3987 | var title = _VirtualDom_doc.title; | ||
3988 | var bodyNode = _VirtualDom_doc.body; | ||
3989 | var currNode = _VirtualDom_virtualize(bodyNode); | ||
3990 | return _Browser_makeAnimator(initialModel, function(model) | ||
3991 | { | ||
3992 | _VirtualDom_divertHrefToApp = divertHrefToApp; | ||
3993 | var doc = view(model); | ||
3994 | var nextNode = _VirtualDom_node('body')(_List_Nil)(doc.body); | ||
3995 | var patches = _VirtualDom_diff(currNode, nextNode); | ||
3996 | bodyNode = _VirtualDom_applyPatches(bodyNode, currNode, patches, sendToApp); | ||
3997 | currNode = nextNode; | ||
3998 | _VirtualDom_divertHrefToApp = 0; | ||
3999 | (title !== doc.title) && (_VirtualDom_doc.title = title = doc.title); | ||
4000 | }); | ||
4001 | } | ||
4002 | ); | ||
4003 | }); | ||
4004 | |||
4005 | |||
4006 | |||
4007 | // ANIMATION | ||
4008 | |||
4009 | |||
4010 | var _Browser_cancelAnimationFrame = | ||
4011 | typeof cancelAnimationFrame !== 'undefined' | ||
4012 | ? cancelAnimationFrame | ||
4013 | : function(id) { clearTimeout(id); }; | ||
4014 | |||
4015 | var _Browser_requestAnimationFrame = | ||
4016 | typeof requestAnimationFrame !== 'undefined' | ||
4017 | ? requestAnimationFrame | ||
4018 | : function(callback) { return setTimeout(callback, 1000 / 60); }; | ||
4019 | |||
4020 | |||
4021 | function _Browser_makeAnimator(model, draw) | ||
4022 | { | ||
4023 | draw(model); | ||
4024 | |||
4025 | var state = 0; | ||
4026 | |||
4027 | function updateIfNeeded() | ||
4028 | { | ||
4029 | state = state === 1 | ||
4030 | ? 0 | ||
4031 | : ( _Browser_requestAnimationFrame(updateIfNeeded), draw(model), 1 ); | ||
4032 | } | ||
4033 | |||
4034 | return function(nextModel, isSync) | ||
4035 | { | ||
4036 | model = nextModel; | ||
4037 | |||
4038 | isSync | ||
4039 | ? ( draw(model), | ||
4040 | state === 2 && (state = 1) | ||
4041 | ) | ||
4042 | : ( state === 0 && _Browser_requestAnimationFrame(updateIfNeeded), | ||
4043 | state = 2 | ||
4044 | ); | ||
4045 | }; | ||
4046 | } | ||
4047 | |||
4048 | |||
4049 | |||
4050 | // APPLICATION | ||
4051 | |||
4052 | |||
4053 | function _Browser_application(impl) | ||
4054 | { | ||
4055 | var onUrlChange = impl.onUrlChange; | ||
4056 | var onUrlRequest = impl.onUrlRequest; | ||
4057 | var key = function() { key.a(onUrlChange(_Browser_getUrl())); }; | ||
4058 | |||
4059 | return _Browser_document({ | ||
4060 | setup: function(sendToApp) | ||
4061 | { | ||
4062 | key.a = sendToApp; | ||
4063 | _Browser_window.addEventListener('popstate', key); | ||
4064 | _Browser_window.navigator.userAgent.indexOf('Trident') < 0 || _Browser_window.addEventListener('hashchange', key); | ||
4065 | |||
4066 | return F2(function(domNode, event) | ||
4067 | { | ||
4068 | if (!event.ctrlKey && !event.metaKey && !event.shiftKey && event.button < 1 && !domNode.target && !domNode.hasAttribute('download')) | ||
4069 | { | ||
4070 | event.preventDefault(); | ||
4071 | var href = domNode.href; | ||
4072 | var curr = _Browser_getUrl(); | ||
4073 | var next = $elm$url$Url$fromString(href).a; | ||
4074 | sendToApp(onUrlRequest( | ||
4075 | (next | ||
4076 | && curr.protocol === next.protocol | ||
4077 | && curr.host === next.host | ||
4078 | && curr.port_.a === next.port_.a | ||
4079 | ) | ||
4080 | ? $elm$browser$Browser$Internal(next) | ||
4081 | : $elm$browser$Browser$External(href) | ||
4082 | )); | ||
4083 | } | ||
4084 | }); | ||
4085 | }, | ||
4086 | init: function(flags) | ||
4087 | { | ||
4088 | return A3(impl.init, flags, _Browser_getUrl(), key); | ||
4089 | }, | ||
4090 | view: impl.view, | ||
4091 | update: impl.update, | ||
4092 | subscriptions: impl.subscriptions | ||
4093 | }); | ||
4094 | } | ||
4095 | |||
4096 | function _Browser_getUrl() | ||
4097 | { | ||
4098 | return $elm$url$Url$fromString(_VirtualDom_doc.location.href).a || _Debug_crash(1); | ||
4099 | } | ||
4100 | |||
4101 | var _Browser_go = F2(function(key, n) | ||
4102 | { | ||
4103 | return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() { | ||
4104 | n && history.go(n); | ||
4105 | key(); | ||
4106 | })); | ||
4107 | }); | ||
4108 | |||
4109 | var _Browser_pushUrl = F2(function(key, url) | ||
4110 | { | ||
4111 | return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() { | ||
4112 | history.pushState({}, '', url); | ||
4113 | key(); | ||
4114 | })); | ||
4115 | }); | ||
4116 | |||
4117 | var _Browser_replaceUrl = F2(function(key, url) | ||
4118 | { | ||
4119 | return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() { | ||
4120 | history.replaceState({}, '', url); | ||
4121 | key(); | ||
4122 | })); | ||
4123 | }); | ||
4124 | |||
4125 | |||
4126 | |||
4127 | // GLOBAL EVENTS | ||
4128 | |||
4129 | |||
4130 | var _Browser_fakeNode = { addEventListener: function() {}, removeEventListener: function() {} }; | ||
4131 | var _Browser_doc = typeof document !== 'undefined' ? document : _Browser_fakeNode; | ||
4132 | var _Browser_window = typeof window !== 'undefined' ? window : _Browser_fakeNode; | ||
4133 | |||
4134 | var _Browser_on = F3(function(node, eventName, sendToSelf) | ||
4135 | { | ||
4136 | return _Scheduler_spawn(_Scheduler_binding(function(callback) | ||
4137 | { | ||
4138 | function handler(event) { _Scheduler_rawSpawn(sendToSelf(event)); } | ||
4139 | node.addEventListener(eventName, handler, _VirtualDom_passiveSupported && { passive: true }); | ||
4140 | return function() { node.removeEventListener(eventName, handler); }; | ||
4141 | })); | ||
4142 | }); | ||
4143 | |||
4144 | var _Browser_decodeEvent = F2(function(decoder, event) | ||
4145 | { | ||
4146 | var result = _Json_runHelp(decoder, event); | ||
4147 | return $elm$core$Result$isOk(result) ? $elm$core$Maybe$Just(result.a) : $elm$core$Maybe$Nothing; | ||
4148 | }); | ||
4149 | |||
4150 | |||
4151 | |||
4152 | // PAGE VISIBILITY | ||
4153 | |||
4154 | |||
4155 | function _Browser_visibilityInfo() | ||
4156 | { | ||
4157 | return (typeof _VirtualDom_doc.hidden !== 'undefined') | ||
4158 | ? { hidden: 'hidden', change: 'visibilitychange' } | ||
4159 | : | ||
4160 | (typeof _VirtualDom_doc.mozHidden !== 'undefined') | ||
4161 | ? { hidden: 'mozHidden', change: 'mozvisibilitychange' } | ||
4162 | : | ||
4163 | (typeof _VirtualDom_doc.msHidden !== 'undefined') | ||
4164 | ? { hidden: 'msHidden', change: 'msvisibilitychange' } | ||
4165 | : | ||
4166 | (typeof _VirtualDom_doc.webkitHidden !== 'undefined') | ||
4167 | ? { hidden: 'webkitHidden', change: 'webkitvisibilitychange' } | ||
4168 | : { hidden: 'hidden', change: 'visibilitychange' }; | ||
4169 | } | ||
4170 | |||
4171 | |||
4172 | |||
4173 | // ANIMATION FRAMES | ||
4174 | |||
4175 | |||
4176 | function _Browser_rAF() | ||
4177 | { | ||
4178 | return _Scheduler_binding(function(callback) | ||
4179 | { | ||
4180 | var id = _Browser_requestAnimationFrame(function() { | ||
4181 | callback(_Scheduler_succeed(Date.now())); | ||
4182 | }); | ||
4183 | |||
4184 | return function() { | ||
4185 | _Browser_cancelAnimationFrame(id); | ||
4186 | }; | ||
4187 | }); | ||
4188 | } | ||
4189 | |||
4190 | |||
4191 | function _Browser_now() | ||
4192 | { | ||
4193 | return _Scheduler_binding(function(callback) | ||
4194 | { | ||
4195 | callback(_Scheduler_succeed(Date.now())); | ||
4196 | }); | ||
4197 | } | ||
4198 | |||
4199 | |||
4200 | |||
4201 | // DOM STUFF | ||
4202 | |||
4203 | |||
4204 | function _Browser_withNode(id, doStuff) | ||
4205 | { | ||
4206 | return _Scheduler_binding(function(callback) | ||
4207 | { | ||
4208 | _Browser_requestAnimationFrame(function() { | ||
4209 | var node = document.getElementById(id); | ||
4210 | callback(node | ||
4211 | ? _Scheduler_succeed(doStuff(node)) | ||
4212 | : _Scheduler_fail($elm$browser$Browser$Dom$NotFound(id)) | ||
4213 | ); | ||
4214 | }); | ||
4215 | }); | ||
4216 | } | ||
4217 | |||
4218 | |||
4219 | function _Browser_withWindow(doStuff) | ||
4220 | { | ||
4221 | return _Scheduler_binding(function(callback) | ||
4222 | { | ||
4223 | _Browser_requestAnimationFrame(function() { | ||
4224 | callback(_Scheduler_succeed(doStuff())); | ||
4225 | }); | ||
4226 | }); | ||
4227 | } | ||
4228 | |||
4229 | |||
4230 | // FOCUS and BLUR | ||
4231 | |||
4232 | |||
4233 | var _Browser_call = F2(function(functionName, id) | ||
4234 | { | ||
4235 | return _Browser_withNode(id, function(node) { | ||
4236 | node[functionName](); | ||
4237 | return _Utils_Tuple0; | ||
4238 | }); | ||
4239 | }); | ||
4240 | |||
4241 | |||
4242 | |||
4243 | // WINDOW VIEWPORT | ||
4244 | |||
4245 | |||
4246 | function _Browser_getViewport() | ||
4247 | { | ||
4248 | return { | ||
4249 | scene: _Browser_getScene(), | ||
4250 | viewport: { | ||
4251 | x: _Browser_window.pageXOffset, | ||
4252 | y: _Browser_window.pageYOffset, | ||
4253 | width: _Browser_doc.documentElement.clientWidth, | ||
4254 | height: _Browser_doc.documentElement.clientHeight | ||
4255 | } | ||
4256 | }; | ||
4257 | } | ||
4258 | |||
4259 | function _Browser_getScene() | ||
4260 | { | ||
4261 | var body = _Browser_doc.body; | ||
4262 | var elem = _Browser_doc.documentElement; | ||
4263 | return { | ||
4264 | width: Math.max(body.scrollWidth, body.offsetWidth, elem.scrollWidth, elem.offsetWidth, elem.clientWidth), | ||
4265 | height: Math.max(body.scrollHeight, body.offsetHeight, elem.scrollHeight, elem.offsetHeight, elem.clientHeight) | ||
4266 | }; | ||
4267 | } | ||
4268 | |||
4269 | var _Browser_setViewport = F2(function(x, y) | ||
4270 | { | ||
4271 | return _Browser_withWindow(function() | ||
4272 | { | ||
4273 | _Browser_window.scroll(x, y); | ||
4274 | return _Utils_Tuple0; | ||
4275 | }); | ||
4276 | }); | ||
4277 | |||
4278 | |||
4279 | |||
4280 | // ELEMENT VIEWPORT | ||
4281 | |||
4282 | |||
4283 | function _Browser_getViewportOf(id) | ||
4284 | { | ||
4285 | return _Browser_withNode(id, function(node) | ||
4286 | { | ||
4287 | return { | ||
4288 | scene: { | ||
4289 | width: node.scrollWidth, | ||
4290 | height: node.scrollHeight | ||
4291 | }, | ||
4292 | viewport: { | ||
4293 | x: node.scrollLeft, | ||
4294 | y: node.scrollTop, | ||
4295 | width: node.clientWidth, | ||
4296 | height: node.clientHeight | ||
4297 | } | ||
4298 | }; | ||
4299 | }); | ||
4300 | } | ||
4301 | |||
4302 | |||
4303 | var _Browser_setViewportOf = F3(function(id, x, y) | ||
4304 | { | ||
4305 | return _Browser_withNode(id, function(node) | ||
4306 | { | ||
4307 | node.scrollLeft = x; | ||
4308 | node.scrollTop = y; | ||
4309 | return _Utils_Tuple0; | ||
4310 | }); | ||
4311 | }); | ||
4312 | |||
4313 | |||
4314 | |||
4315 | // ELEMENT | ||
4316 | |||
4317 | |||
4318 | function _Browser_getElement(id) | ||
4319 | { | ||
4320 | return _Browser_withNode(id, function(node) | ||
4321 | { | ||
4322 | var rect = node.getBoundingClientRect(); | ||
4323 | var x = _Browser_window.pageXOffset; | ||
4324 | var y = _Browser_window.pageYOffset; | ||
4325 | return { | ||
4326 | scene: _Browser_getScene(), | ||
4327 | viewport: { | ||
4328 | x: x, | ||
4329 | y: y, | ||
4330 | width: _Browser_doc.documentElement.clientWidth, | ||
4331 | height: _Browser_doc.documentElement.clientHeight | ||
4332 | }, | ||
4333 | element: { | ||
4334 | x: x + rect.left, | ||
4335 | y: y + rect.top, | ||
4336 | width: rect.width, | ||
4337 | height: rect.height | ||
4338 | } | ||
4339 | }; | ||
4340 | }); | ||
4341 | } | ||
4342 | |||
4343 | |||
4344 | |||
4345 | // LOAD and RELOAD | ||
4346 | |||
4347 | |||
4348 | function _Browser_reload(skipCache) | ||
4349 | { | ||
4350 | return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function(callback) | ||
4351 | { | ||
4352 | _VirtualDom_doc.location.reload(skipCache); | ||
4353 | })); | ||
4354 | } | ||
4355 | |||
4356 | function _Browser_load(url) | ||
4357 | { | ||
4358 | return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function(callback) | ||
4359 | { | ||
4360 | try | ||
4361 | { | ||
4362 | _Browser_window.location = url; | ||
4363 | } | ||
4364 | catch(err) | ||
4365 | { | ||
4366 | // Only Firefox can throw a NS_ERROR_MALFORMED_URI exception here. | ||
4367 | // Other browsers reload the page, so let's be consistent about that. | ||
4368 | _VirtualDom_doc.location.reload(false); | ||
4369 | } | ||
4370 | })); | ||
4371 | } | ||
4372 | |||
4373 | |||
4374 | |||
4375 | // SEND REQUEST | ||
4376 | |||
4377 | var _Http_toTask = F3(function(router, toTask, request) | ||
4378 | { | ||
4379 | return _Scheduler_binding(function(callback) | ||
4380 | { | ||
4381 | function done(response) { | ||
4382 | callback(toTask(request.expect.a(response))); | ||
4383 | } | ||
4384 | |||
4385 | var xhr = new XMLHttpRequest(); | ||
4386 | xhr.addEventListener('error', function() { done($elm$http$Http$NetworkError_); }); | ||
4387 | xhr.addEventListener('timeout', function() { done($elm$http$Http$Timeout_); }); | ||
4388 | xhr.addEventListener('load', function() { done(_Http_toResponse(request.expect.b, xhr)); }); | ||
4389 | $elm$core$Maybe$isJust(request.tracker) && _Http_track(router, xhr, request.tracker.a); | ||
4390 | |||
4391 | try { | ||
4392 | xhr.open(request.method, request.url, true); | ||
4393 | } catch (e) { | ||
4394 | return done($elm$http$Http$BadUrl_(request.url)); | ||
4395 | } | ||
4396 | |||
4397 | _Http_configureRequest(xhr, request); | ||
4398 | |||
4399 | request.body.a && xhr.setRequestHeader('Content-Type', request.body.a); | ||
4400 | xhr.send(request.body.b); | ||
4401 | |||
4402 | return function() { xhr.c = true; xhr.abort(); }; | ||
4403 | }); | ||
4404 | }); | ||
4405 | |||
4406 | |||
4407 | // CONFIGURE | ||
4408 | |||
4409 | function _Http_configureRequest(xhr, request) | ||
4410 | { | ||
4411 | for (var headers = request.headers; headers.b; headers = headers.b) // WHILE_CONS | ||
4412 | { | ||
4413 | xhr.setRequestHeader(headers.a.a, headers.a.b); | ||
4414 | } | ||
4415 | xhr.timeout = request.timeout.a || 0; | ||
4416 | xhr.responseType = request.expect.d; | ||
4417 | xhr.withCredentials = request.allowCookiesFromOtherDomains; | ||
4418 | } | ||
4419 | |||
4420 | |||
4421 | // RESPONSES | ||
4422 | |||
4423 | function _Http_toResponse(toBody, xhr) | ||
4424 | { | ||
4425 | return A2( | ||
4426 | 200 <= xhr.status && xhr.status < 300 ? $elm$http$Http$GoodStatus_ : $elm$http$Http$BadStatus_, | ||
4427 | _Http_toMetadata(xhr), | ||
4428 | toBody(xhr.response) | ||
4429 | ); | ||
4430 | } | ||
4431 | |||
4432 | |||
4433 | // METADATA | ||
4434 | |||
4435 | function _Http_toMetadata(xhr) | ||
4436 | { | ||
4437 | return { | ||
4438 | url: xhr.responseURL, | ||
4439 | statusCode: xhr.status, | ||
4440 | statusText: xhr.statusText, | ||
4441 | headers: _Http_parseHeaders(xhr.getAllResponseHeaders()) | ||
4442 | }; | ||
4443 | } | ||
4444 | |||
4445 | |||
4446 | // HEADERS | ||
4447 | |||
4448 | function _Http_parseHeaders(rawHeaders) | ||
4449 | { | ||
4450 | if (!rawHeaders) | ||
4451 | { | ||
4452 | return $elm$core$Dict$empty; | ||
4453 | } | ||
4454 | |||
4455 | var headers = $elm$core$Dict$empty; | ||
4456 | var headerPairs = rawHeaders.split('\r\n'); | ||
4457 | for (var i = headerPairs.length; i--; ) | ||
4458 | { | ||
4459 | var headerPair = headerPairs[i]; | ||
4460 | var index = headerPair.indexOf(': '); | ||
4461 | if (index > 0) | ||
4462 | { | ||
4463 | var key = headerPair.substring(0, index); | ||
4464 | var value = headerPair.substring(index + 2); | ||
4465 | |||
4466 | headers = A3($elm$core$Dict$update, key, function(oldValue) { | ||
4467 | return $elm$core$Maybe$Just($elm$core$Maybe$isJust(oldValue) | ||
4468 | ? value + ', ' + oldValue.a | ||
4469 | : value | ||
4470 | ); | ||
4471 | }, headers); | ||
4472 | } | ||
4473 | } | ||
4474 | return headers; | ||
4475 | } | ||
4476 | |||
4477 | |||
4478 | // EXPECT | ||
4479 | |||
4480 | var _Http_expect = F3(function(type, toBody, toValue) | ||
4481 | { | ||
4482 | return { | ||
4483 | $: 0, | ||
4484 | d: type, | ||
4485 | b: toBody, | ||
4486 | a: toValue | ||
4487 | }; | ||
4488 | }); | ||
4489 | |||
4490 | var _Http_mapExpect = F2(function(func, expect) | ||
4491 | { | ||
4492 | return { | ||
4493 | $: 0, | ||
4494 | d: expect.d, | ||
4495 | b: expect.b, | ||
4496 | a: function(x) { return func(expect.a(x)); } | ||
4497 | }; | ||
4498 | }); | ||
4499 | |||
4500 | function _Http_toDataView(arrayBuffer) | ||
4501 | { | ||
4502 | return new DataView(arrayBuffer); | ||
4503 | } | ||
4504 | |||
4505 | |||
4506 | // BODY and PARTS | ||
4507 | |||
4508 | var _Http_emptyBody = { $: 0 }; | ||
4509 | var _Http_pair = F2(function(a, b) { return { $: 0, a: a, b: b }; }); | ||
4510 | |||
4511 | function _Http_toFormData(parts) | ||
4512 | { | ||
4513 | for (var formData = new FormData(); parts.b; parts = parts.b) // WHILE_CONS | ||
4514 | { | ||
4515 | var part = parts.a; | ||
4516 | formData.append(part.a, part.b); | ||
4517 | } | ||
4518 | return formData; | ||
4519 | } | ||
4520 | |||
4521 | var _Http_bytesToBlob = F2(function(mime, bytes) | ||
4522 | { | ||
4523 | return new Blob([bytes], { type: mime }); | ||
4524 | }); | ||
4525 | |||
4526 | |||
4527 | // PROGRESS | ||
4528 | |||
4529 | function _Http_track(router, xhr, tracker) | ||
4530 | { | ||
4531 | // TODO check out lengthComputable on loadstart event | ||
4532 | |||
4533 | xhr.upload.addEventListener('progress', function(event) { | ||
4534 | if (xhr.c) { return; } | ||
4535 | _Scheduler_rawSpawn(A2($elm$core$Platform$sendToSelf, router, _Utils_Tuple2(tracker, $elm$http$Http$Sending({ | ||
4536 | sent: event.loaded, | ||
4537 | size: event.total | ||
4538 | })))); | ||
4539 | }); | ||
4540 | xhr.addEventListener('progress', function(event) { | ||
4541 | if (xhr.c) { return; } | ||
4542 | _Scheduler_rawSpawn(A2($elm$core$Platform$sendToSelf, router, _Utils_Tuple2(tracker, $elm$http$Http$Receiving({ | ||
4543 | received: event.loaded, | ||
4544 | size: event.lengthComputable ? $elm$core$Maybe$Just(event.total) : $elm$core$Maybe$Nothing | ||
4545 | })))); | ||
4546 | }); | ||
4547 | } | ||
4548 | |||
4549 | function _Url_percentEncode(string) | ||
4550 | { | ||
4551 | return encodeURIComponent(string); | ||
4552 | } | ||
4553 | |||
4554 | function _Url_percentDecode(string) | ||
4555 | { | ||
4556 | try | ||
4557 | { | ||
4558 | return $elm$core$Maybe$Just(decodeURIComponent(string)); | ||
4559 | } | ||
4560 | catch (e) | ||
4561 | { | ||
4562 | return $elm$core$Maybe$Nothing; | ||
4563 | } | ||
4564 | } | ||
4565 | |||
4566 | |||
4567 | var _Bitwise_and = F2(function(a, b) | ||
4568 | { | ||
4569 | return a & b; | ||
4570 | }); | ||
4571 | |||
4572 | var _Bitwise_or = F2(function(a, b) | ||
4573 | { | ||
4574 | return a | b; | ||
4575 | }); | ||
4576 | |||
4577 | var _Bitwise_xor = F2(function(a, b) | ||
4578 | { | ||
4579 | return a ^ b; | ||
4580 | }); | ||
4581 | |||
4582 | function _Bitwise_complement(a) | ||
4583 | { | ||
4584 | return ~a; | ||
4585 | }; | ||
4586 | |||
4587 | var _Bitwise_shiftLeftBy = F2(function(offset, a) | ||
4588 | { | ||
4589 | return a << offset; | ||
4590 | }); | ||
4591 | |||
4592 | var _Bitwise_shiftRightBy = F2(function(offset, a) | ||
4593 | { | ||
4594 | return a >> offset; | ||
4595 | }); | ||
4596 | |||
4597 | var _Bitwise_shiftRightZfBy = F2(function(offset, a) | ||
4598 | { | ||
4599 | return a >>> offset; | ||
4600 | }); | ||
4601 | var $author$project$Main$LinkClicked = function (a) { | ||
4602 | return {$: 'LinkClicked', a: a}; | ||
4603 | }; | ||
4604 | var $author$project$Main$UrlChanged = function (a) { | ||
4605 | return {$: 'UrlChanged', a: a}; | ||
4606 | }; | ||
4607 | var $elm$core$Basics$EQ = {$: 'EQ'}; | ||
4608 | var $elm$core$Basics$GT = {$: 'GT'}; | ||
4609 | var $elm$core$Basics$LT = {$: 'LT'}; | ||
4610 | var $elm$core$List$cons = _List_cons; | ||
4611 | var $elm$core$Dict$foldr = F3( | ||
4612 | function (func, acc, t) { | ||
4613 | foldr: | ||
4614 | while (true) { | ||
4615 | if (t.$ === 'RBEmpty_elm_builtin') { | ||
4616 | return acc; | ||
4617 | } else { | ||
4618 | var key = t.b; | ||
4619 | var value = t.c; | ||
4620 | var left = t.d; | ||
4621 | var right = t.e; | ||
4622 | var $temp$func = func, | ||
4623 | $temp$acc = A3( | ||
4624 | func, | ||
4625 | key, | ||
4626 | value, | ||
4627 | A3($elm$core$Dict$foldr, func, acc, right)), | ||
4628 | $temp$t = left; | ||
4629 | func = $temp$func; | ||
4630 | acc = $temp$acc; | ||
4631 | t = $temp$t; | ||
4632 | continue foldr; | ||
4633 | } | ||
4634 | } | ||
4635 | }); | ||
4636 | var $elm$core$Dict$toList = function (dict) { | ||
4637 | return A3( | ||
4638 | $elm$core$Dict$foldr, | ||
4639 | F3( | ||
4640 | function (key, value, list) { | ||
4641 | return A2( | ||
4642 | $elm$core$List$cons, | ||
4643 | _Utils_Tuple2(key, value), | ||
4644 | list); | ||
4645 | }), | ||
4646 | _List_Nil, | ||
4647 | dict); | ||
4648 | }; | ||
4649 | var $elm$core$Dict$keys = function (dict) { | ||
4650 | return A3( | ||
4651 | $elm$core$Dict$foldr, | ||
4652 | F3( | ||
4653 | function (key, value, keyList) { | ||
4654 | return A2($elm$core$List$cons, key, keyList); | ||
4655 | }), | ||
4656 | _List_Nil, | ||
4657 | dict); | ||
4658 | }; | ||
4659 | var $elm$core$Set$toList = function (_v0) { | ||
4660 | var dict = _v0.a; | ||
4661 | return $elm$core$Dict$keys(dict); | ||
4662 | }; | ||
4663 | var $elm$core$Elm$JsArray$foldr = _JsArray_foldr; | ||
4664 | var $elm$core$Array$foldr = F3( | ||
4665 | function (func, baseCase, _v0) { | ||
4666 | var tree = _v0.c; | ||
4667 | var tail = _v0.d; | ||
4668 | var helper = F2( | ||
4669 | function (node, acc) { | ||
4670 | if (node.$ === 'SubTree') { | ||
4671 | var subTree = node.a; | ||
4672 | return A3($elm$core$Elm$JsArray$foldr, helper, acc, subTree); | ||
4673 | } else { | ||
4674 | var values = node.a; | ||
4675 | return A3($elm$core$Elm$JsArray$foldr, func, acc, values); | ||
4676 | } | ||
4677 | }); | ||
4678 | return A3( | ||
4679 | $elm$core$Elm$JsArray$foldr, | ||
4680 | helper, | ||
4681 | A3($elm$core$Elm$JsArray$foldr, func, baseCase, tail), | ||
4682 | tree); | ||
4683 | }); | ||
4684 | var $elm$core$Array$toList = function (array) { | ||
4685 | return A3($elm$core$Array$foldr, $elm$core$List$cons, _List_Nil, array); | ||
4686 | }; | ||
4687 | var $elm$core$Result$Err = function (a) { | ||
4688 | return {$: 'Err', a: a}; | ||
4689 | }; | ||
4690 | var $elm$json$Json$Decode$Failure = F2( | ||
4691 | function (a, b) { | ||
4692 | return {$: 'Failure', a: a, b: b}; | ||
4693 | }); | ||
4694 | var $elm$json$Json$Decode$Field = F2( | ||
4695 | function (a, b) { | ||
4696 | return {$: 'Field', a: a, b: b}; | ||
4697 | }); | ||
4698 | var $elm$json$Json$Decode$Index = F2( | ||
4699 | function (a, b) { | ||
4700 | return {$: 'Index', a: a, b: b}; | ||
4701 | }); | ||
4702 | var $elm$core$Result$Ok = function (a) { | ||
4703 | return {$: 'Ok', a: a}; | ||
4704 | }; | ||
4705 | var $elm$json$Json$Decode$OneOf = function (a) { | ||
4706 | return {$: 'OneOf', a: a}; | ||
4707 | }; | ||
4708 | var $elm$core$Basics$False = {$: 'False'}; | ||
4709 | var $elm$core$Basics$add = _Basics_add; | ||
4710 | var $elm$core$Maybe$Just = function (a) { | ||
4711 | return {$: 'Just', a: a}; | ||
4712 | }; | ||
4713 | var $elm$core$Maybe$Nothing = {$: 'Nothing'}; | ||
4714 | var $elm$core$String$all = _String_all; | ||
4715 | var $elm$core$Basics$and = _Basics_and; | ||
4716 | var $elm$core$Basics$append = _Utils_append; | ||
4717 | var $elm$json$Json$Encode$encode = _Json_encode; | ||
4718 | var $elm$core$String$fromInt = _String_fromNumber; | ||
4719 | var $elm$core$String$join = F2( | ||
4720 | function (sep, chunks) { | ||
4721 | return A2( | ||
4722 | _String_join, | ||
4723 | sep, | ||
4724 | _List_toArray(chunks)); | ||
4725 | }); | ||
4726 | var $elm$core$String$split = F2( | ||
4727 | function (sep, string) { | ||
4728 | return _List_fromArray( | ||
4729 | A2(_String_split, sep, string)); | ||
4730 | }); | ||
4731 | var $elm$json$Json$Decode$indent = function (str) { | ||
4732 | return A2( | ||
4733 | $elm$core$String$join, | ||
4734 | '\n ', | ||
4735 | A2($elm$core$String$split, '\n', str)); | ||
4736 | }; | ||
4737 | var $elm$core$List$foldl = F3( | ||
4738 | function (func, acc, list) { | ||
4739 | foldl: | ||
4740 | while (true) { | ||
4741 | if (!list.b) { | ||
4742 | return acc; | ||
4743 | } else { | ||
4744 | var x = list.a; | ||
4745 | var xs = list.b; | ||
4746 | var $temp$func = func, | ||
4747 | $temp$acc = A2(func, x, acc), | ||
4748 | $temp$list = xs; | ||
4749 | func = $temp$func; | ||
4750 | acc = $temp$acc; | ||
4751 | list = $temp$list; | ||
4752 | continue foldl; | ||
4753 | } | ||
4754 | } | ||
4755 | }); | ||
4756 | var $elm$core$List$length = function (xs) { | ||
4757 | return A3( | ||
4758 | $elm$core$List$foldl, | ||
4759 | F2( | ||
4760 | function (_v0, i) { | ||
4761 | return i + 1; | ||
4762 | }), | ||
4763 | 0, | ||
4764 | xs); | ||
4765 | }; | ||
4766 | var $elm$core$List$map2 = _List_map2; | ||
4767 | var $elm$core$Basics$le = _Utils_le; | ||
4768 | var $elm$core$Basics$sub = _Basics_sub; | ||
4769 | var $elm$core$List$rangeHelp = F3( | ||
4770 | function (lo, hi, list) { | ||
4771 | rangeHelp: | ||
4772 | while (true) { | ||
4773 | if (_Utils_cmp(lo, hi) < 1) { | ||
4774 | var $temp$lo = lo, | ||
4775 | $temp$hi = hi - 1, | ||
4776 | $temp$list = A2($elm$core$List$cons, hi, list); | ||
4777 | lo = $temp$lo; | ||
4778 | hi = $temp$hi; | ||
4779 | list = $temp$list; | ||
4780 | continue rangeHelp; | ||
4781 | } else { | ||
4782 | return list; | ||
4783 | } | ||
4784 | } | ||
4785 | }); | ||
4786 | var $elm$core$List$range = F2( | ||
4787 | function (lo, hi) { | ||
4788 | return A3($elm$core$List$rangeHelp, lo, hi, _List_Nil); | ||
4789 | }); | ||
4790 | var $elm$core$List$indexedMap = F2( | ||
4791 | function (f, xs) { | ||
4792 | return A3( | ||
4793 | $elm$core$List$map2, | ||
4794 | f, | ||
4795 | A2( | ||
4796 | $elm$core$List$range, | ||
4797 | 0, | ||
4798 | $elm$core$List$length(xs) - 1), | ||
4799 | xs); | ||
4800 | }); | ||
4801 | var $elm$core$Char$toCode = _Char_toCode; | ||
4802 | var $elm$core$Char$isLower = function (_char) { | ||
4803 | var code = $elm$core$Char$toCode(_char); | ||
4804 | return (97 <= code) && (code <= 122); | ||
4805 | }; | ||
4806 | var $elm$core$Char$isUpper = function (_char) { | ||
4807 | var code = $elm$core$Char$toCode(_char); | ||
4808 | return (code <= 90) && (65 <= code); | ||
4809 | }; | ||
4810 | var $elm$core$Basics$or = _Basics_or; | ||
4811 | var $elm$core$Char$isAlpha = function (_char) { | ||
4812 | return $elm$core$Char$isLower(_char) || $elm$core$Char$isUpper(_char); | ||
4813 | }; | ||
4814 | var $elm$core$Char$isDigit = function (_char) { | ||
4815 | var code = $elm$core$Char$toCode(_char); | ||
4816 | return (code <= 57) && (48 <= code); | ||
4817 | }; | ||
4818 | var $elm$core$Char$isAlphaNum = function (_char) { | ||
4819 | return $elm$core$Char$isLower(_char) || ($elm$core$Char$isUpper(_char) || $elm$core$Char$isDigit(_char)); | ||
4820 | }; | ||
4821 | var $elm$core$List$reverse = function (list) { | ||
4822 | return A3($elm$core$List$foldl, $elm$core$List$cons, _List_Nil, list); | ||
4823 | }; | ||
4824 | var $elm$core$String$uncons = _String_uncons; | ||
4825 | var $elm$json$Json$Decode$errorOneOf = F2( | ||
4826 | function (i, error) { | ||
4827 | return '\n\n(' + ($elm$core$String$fromInt(i + 1) + (') ' + $elm$json$Json$Decode$indent( | ||
4828 | $elm$json$Json$Decode$errorToString(error)))); | ||
4829 | }); | ||
4830 | var $elm$json$Json$Decode$errorToString = function (error) { | ||
4831 | return A2($elm$json$Json$Decode$errorToStringHelp, error, _List_Nil); | ||
4832 | }; | ||
4833 | var $elm$json$Json$Decode$errorToStringHelp = F2( | ||
4834 | function (error, context) { | ||
4835 | errorToStringHelp: | ||
4836 | while (true) { | ||
4837 | switch (error.$) { | ||
4838 | case 'Field': | ||
4839 | var f = error.a; | ||
4840 | var err = error.b; | ||
4841 | var isSimple = |