on master help sign in
Increase version number.
commit7b7b136002eb7b0597b6327c3b7833bb4f2052ff authorevancz <info@elm-lang.org> dateSun 10 Feb 2013, 14:01 (14 years ago) parent6b12850
3 files changed+4525−3
core-js/cat.bat+1−1 elm/Elm.cabal+2−2 elm/elm-runtime-0.7.2.js+4522
core-js/cat.bat+1−1
@@ -2,4 +2,4 @@ copy /B Guid.js+foreign\JavaScript.js+foreign\JSON.js+Value.js+List.js+Maybe.js+
22
33cd ..\elm
44
5−copy /B ..\elm-mini.js elm-runtime-0.7.1.js
5+copy /B ..\elm-mini.js elm-runtime-0.7.2.js
elm/Elm.cabal+2−2
@@ -1,6 +1,6 @@
11
22Name: Elm
3−Version: 0.7.1.1
3+Version: 0.7.2
44Synopsis: The Elm language module.
55Description: Elm aims to make client-side web-development more pleasant.
66 It is a statically/strongly typed, functional reactive
@@ -22,7 +22,7 @@ Category: Compiler, Language
2222Build-type: Simple
2323
2424Extra-source-files: changelog.txt
25−Data-files: elm-runtime-0.7.1.1.js
25+Data-files: elm-runtime-0.7.2.js
2626Cabal-version: >=1.8
2727
2828source-repository head
elm/elm-runtime-0.7.2.jsnew file+4522
@@ -0,0 +1,4522 @@
1+
2+Elm = {};
3+
4+var Guid = function() {
5+ var counter = 0;
6+ var guid = function() { counter += 1; return counter; };
7+ return {guid : guid};
8+}();
9+Elm.JavaScript = function() {
10+ function castJSBoolToBool(b) { return b; }
11+ function castBoolToJSBool(b) { return b; }
12+
13+ function castJSNumberToFloat(n) { return n; }
14+ function castFloatToJSNumber(n) { return n; }
15+
16+ function castJSNumberToInt(n) { return ~~n; }
17+ function castIntToJSNumber(n) { return n; }
18+
19+ function castJSElementToElement(w) {
20+ return function(h) {
21+ return function(node) {
22+ return ["Element",Guid.guid(),
23+ ["EExternalHtml",node],
24+ w,h,1,["Nothing"],["Nothing"]];
25+ }
26+ }
27+ }
28+ function castElementToJSElement(elem) { return Render.render(elem); }
29+
30+ function castJSArrayToList(arr) {
31+ var list = ["Nil"];
32+ for (var i = arr.length; i--; ) {
33+ list = [ "Cons", arr[i], list ];
34+ }
35+ return list;
36+ }
37+ function castListToJSArray(list) {
38+ var a = [];
39+ while (list[0] === "Cons") {
40+ a.push(list[1]);
41+ list = list[2];
42+ }
43+ return a;
44+ }
45+
46+ var castJSStringToString = castJSArrayToList;
47+ function castStringToJSString(str) {
48+ if (typeof str === "string") return str;
49+ return castListToJSArray(str).join('');
50+ }
51+
52+ function fromTuple(t) { return t.slice(1); }
53+ function toTuple(a) { return ["Tuple" + a.length].concat(a); }
54+
55+ return {castJSBoolToBool:castJSBoolToBool,
56+ castBoolToJSBool:castBoolToJSBool,
57+ castJSNumberToFloat:castJSNumberToFloat,
58+ castFloatToJSNumber:castFloatToJSNumber,
59+ castJSNumberToInt:castJSNumberToInt,
60+ castIntToJSNumber:castIntToJSNumber,
61+ Experimental : {castJSElementToElement:castJSElementToElement,
62+ castElementToJSElement:castElementToJSElement},
63+ castJSArrayToList:castJSArrayToList,
64+ castListToJSArray:castListToJSArray,
65+ castJSStringToString:castJSStringToString,
66+ castStringToJSString:castStringToJSString,
67+ castTupleToJSTuple2:fromTuple,
68+ castTupleToJSTuple3:fromTuple,
69+ castTupleToJSTuple4:fromTuple,
70+ castTupleToJSTuple5:fromTuple,
71+ castJSTupleToTuple2:toTuple,
72+ castJSTupleToTuple3:toTuple,
73+ castJSTupleToTuple4:toTuple,
74+ castJSTupleToTuple5:toTuple
75+ };
76+}();
77+
78+var JSjson = window.JSON;
79+Elm.JSON = function() {
80+ var JS = Elm.JavaScript;
81+ var empty = ['JSON',{}];
82+ function singleton(k) { return function(v) {
83+ var obj = {};
84+ obj[JS.castStringToJSString(k)] = v;
85+ return ['JSON', obj ];
86+ };
87+ }
88+ function insert(k) { return function(v) { return function(inObj) {
89+ var obj = inObj[1];
90+ var outObj = {};
91+ for (var i in obj) {
92+ outObj[i] = obj[i];
93+ }
94+ outObj[JS.castStringToJSString(k)] = v;
95+ return ['JSON', outObj ];
96+ };
97+ };
98+ }
99+
100+ function lookup(key) { return function(obj) {
101+ var k = JS.castStringToJSString(key);
102+ return (k in obj[1]) ? ["Just", obj[1][k]] : ["Nothing"] ;
103+ };
104+ }
105+ function find(tipe,base) { return function (key) { return function(obj) {
106+ var k = JS.castStringToJSString(key);
107+ if (k in obj[1]) {
108+ var v = obj[1][k];
109+ if (v[0] === tipe) { return v[1]; }
110+ }
111+ return base;
112+ };
113+ }
114+ }
115+ function lookupWithDefault(base) { return function(key) { return function(obj) {
116+ var k = JS.castStringToJSString(key);
117+ return (k in obj[1]) ? obj[1][k] : base ;
118+ };
119+ };
120+ }
121+
122+ function remove(k) { return function(inObj) {
123+ var obj = inObj[1];
124+ var outObj = {};
125+ for (var i in obj) {
126+ outObj[i] = obj[i];
127+ }
128+ delete outObj[JS.castStringToJSString(k)];
129+ return ['JSON', outObj];
130+ };
131+ }
132+
133+ function JsonString(v) { return [ "JsonString", v ]; }
134+ function JsonNumber(v) { return [ "JsonNumber", v ]; }
135+ function JsonBool(v) { return [ "JsonBool", v ]; }
136+ var JsonNull = [ "JsonNull" ];
137+ function JsonArray(v) { return [ "JsonArray", v ]; }
138+ function JsonObject(v) { return [ "JsonObject", v ]; }
139+
140+ function toList(json) {
141+ var obj = json[1];
142+ var arr = [];
143+ for (var i in obj) {
144+ arr.push(Value.Tuple(JS.castJSStringToString(i), obj[i]));
145+ }
146+ return JS.castJSArrayToList(arr);
147+ }
148+ function fromList(list) {
149+ var arr = JS.castListToJSArray(list);
150+ var obj = {};
151+ for (var i = arr.length; i--; ) {
152+ obj[JS.castStringToJSString(arr[i][1])] = arr[i][2];
153+ }
154+ return [ "JSON", obj ];
155+ }
156+
157+ function toPrettyJSString(sep) { return function (obj) {
158+ function fromValue(v) {
159+ switch (v[0]) {
160+ case 'JsonNull' : return null;
161+ case 'JsonString' : return JS.castStringToJSString(v[1]);
162+ case 'JsonObject' :
163+ var o = {};
164+ var from = v[1][1];
165+ for (var i in from) {
166+ o[i] = fromValue(from[i]);
167+ }
168+ return o;
169+ case 'JsonArray' :
170+ var a = JS.castListToJSArray(v[1]);
171+ for (var i = a.length; i--; ) {
172+ a[i] = fromValue(a[i]);
173+ }
174+ return a;
175+ default :
176+ return v[1];
177+ }
178+ }
179+ return JSjson.stringify(fromValue([ 'JsonObject', obj ]), null, JS.castStringToJSString(sep));
180+ };
181+ }
182+ function fromJSString(str) {
183+ var obj;
184+ try {
185+ obj = JSjson.parse(str);
186+ } catch (e) {
187+ return Elm.Maybe.Nothing;
188+ }
189+ function toValue(v) {
190+ switch (typeof v) {
191+ case 'string' : return [ "JsonString", JS.castJSStringToString(v) ];
192+ case 'number' : return [ "JsonNumber", JS.castJSNumberToFloat(v) ];
193+ case 'boolean' : return [ "JsonBool", JS.castJSBoolToBool(v) ];
194+ case 'object' :
195+ if (v === null) return [ "JsonNull" ];
196+ for (var i in v) {
197+ v[i] = toValue(v[i]);
198+ }
199+ if (v instanceof Array) return [ "JsonArray", JS.castJSArrayToList(v) ];
200+ return [ "JsonObject", [ "JSON", v ] ];
201+ }
202+ }
203+ for (var i in obj) {
204+ obj[i] = toValue(obj[i]);
205+ }
206+ return Elm.Maybe.Just( ['JSON',obj] );
207+ }
208+ return {empty : empty,
209+ singleton : singleton,
210+ insert : insert,
211+ lookup : lookup,
212+ findNumber : find("JsonNumber",0),
213+ findString : find("JsonString",["Nil"]),
214+ findObject : find("JsonObject", empty ),
215+ findArray : find("JsonArray" ,["Nil"]),
216+ findWithDefault : lookupWithDefault,
217+ remove : remove,
218+ toPrettyJSString : toPrettyJSString,
219+ toJSString : toPrettyJSString(''),
220+ fromJSString : fromJSString,
221+ toPrettyString : function(sep) { return function(v) {
222+ return JS.castJSStringToString(toPrettyJSString(sep)(v)); }; },
223+ toString : function(v) { return JS.castJSStringToString(toPrettyJSString('')(v)); },
224+ fromString : function(v) { return fromJSString(JS.castStringToJSString(v)); },
225+ toList : toList,
226+ fromList : fromList,
227+ JsonString : JsonString,
228+ JsonNumber : JsonNumber,
229+ JsonBool : JsonBool,
230+ JsonNull : JsonNull,
231+ JsonArray : JsonArray,
232+ JsonObject : JsonObject
233+ };
234+}();
235+
236+var Value = function(){
237+
238+ var eq = function(x,y) {
239+ if (typeof x === "object") {
240+ if (x !== null && '_' in x) {
241+ for (var i in x) { if (x[i] != y[i]) return false; }
242+ for (var i in y) { if (!(i in x)) return false; }
243+ return true;
244+ }
245+ if (x === y) return true;
246+ if (x.length !== y.length) return false;
247+ for (var i = x.length; i--; ) {
248+ if (!eq(x[i],y[i])) return false;
249+ }
250+ return true;
251+ }
252+ return x === y;
253+ };
254+
255+ var Tuple = function() {
256+ var len = arguments.length;
257+ var arr = new Array(len+1);
258+ arr[0] = "Tuple" + arguments.length;
259+ for (var i = len; i--; ) {
260+ arr[i+1] = arguments[i];
261+ }
262+ return arr;
263+ };
264+
265+ var listToArray = function(list) {
266+ var arr = [];
267+ while (list[0] === "Cons") {
268+ arr.push(list[1]);
269+ list = list[2];
270+ }
271+ return arr;
272+ };
273+
274+ function makeSpaces(s) {
275+ if (s.length == 0) { return s; }
276+ var arr = s.split('');
277+ if (arr[0] == ' ') { arr[0] = "&nbsp;" }
278+ for (var i = arr.length; --i; ) {
279+ if (arr[i][0] == ' ' && arr[i-1] == ' ') {
280+ arr[i-1] = arr[i-1] + arr[i];
281+ arr[i] = '';
282+ }
283+ }
284+ for (var i = arr.length; i--; ) {
285+ if (arr[i].length > 1 && arr[i][0] == ' ') {
286+ var spaces = arr[i].split('');
287+ for (var j = spaces.length - 2; j >= 0; j -= 2) {
288+ spaces[j] = '&nbsp;';
289+ }
290+ arr[i] = spaces.join('');
291+ }
292+ }
293+ arr = arr.join('');
294+ if (arr[arr.length-1] === " ") {
295+ return arr.slice(0,-1) + '&nbsp;';
296+ }
297+ return arr;
298+ }
299+
300+ function properEscape(str) {
301+ if (str.length == 0) return str;
302+ str = str //.replace(/&/g, "&#38;")
303+ .replace(/"/g, /*"*/ "&#34;")
304+ .replace(/'/g, /*'*/ "&#39;")
305+ .replace(/</g, "&#60;")
306+ .replace(/>/g, "&#62;")
307+ .replace(/\n/g, "<br/>");
308+ var arr = str.split('<br/>');
309+ for (var i = arr.length; i--; ) {
310+ arr[i] = makeSpaces(arr[i]);
311+ }
312+ return arr.join('<br/>');
313+ }
314+
315+ var toText = function(elmList) {
316+ if (typeof elmList === "string") return properEscape(elmList);
317+ var a = [];
318+ while (elmList[0] === "Cons") {
319+ a.push(elmList[1]);
320+ elmList = elmList[2];
321+ }
322+ return properEscape(a.join(''));
323+ };
324+
325+ function getTextSize(w,h,txt) {
326+ var t = document.createElement('div');
327+ t.innerHTML = txt;
328+ t.style.textAlign = 'left';
329+ if (w > 0) { t.style.width = w + "px"; }
330+
331+ t.style.visibility = "hidden";
332+ t.style.styleFloat = "left";
333+ t.style.cssFloat = "left";
334+
335+ document.body.appendChild(t);
336+ var cStyle = window.getComputedStyle(t,null);
337+ var realW = cStyle.getPropertyValue("width").slice(0,-2) - 0;
338+ var realH = cStyle.getPropertyValue("height").slice(0,-2) - 0;
339+ document.body.removeChild(t);
340+ //delete t;
341+ return [Math.ceil(realW),Math.ceil(Math.max(h,realH))];
342+ }
343+
344+ function getSize(e) {
345+ var t = e.cloneNode(true);
346+
347+ t.style.visibility = "hidden";
348+ t.style.styleFloat = "left";
349+ t.style.cssFloat = "left";
350+
351+ document.body.appendChild(t);
352+ var w = t.offsetWidth;
353+ var h = t.offsetHeight;
354+ document.body.removeChild(t);
355+ //delete t;
356+ return [w,h];
357+ }
358+
359+ function getExcess(e) {
360+ var t = e.cloneNode(true);
361+
362+ t.style.visibility = "hidden";
363+ t.style.styleFloat = "left";
364+ t.style.cssFloat = "left";
365+
366+ document.body.appendChild(t);
367+ var ow = t.offsetWidth;
368+ var oh = t.offsetHeight;
369+ var cStyle = window.getComputedStyle(t,null);
370+ var w = cStyle.getPropertyValue("width").slice(0,-2) - 0;
371+ var h = cStyle.getPropertyValue("height").slice(0,-2) - 0;
372+ document.body.removeChild(t);
373+ //delete t;
374+ return [ow-w,oh-h];
375+ }
376+
377+
378+ function groupForms(forms) {
379+ forms = Elm.JavaScript.castListToJSArray(forms);
380+ var groups = [];
381+ var arr = [];
382+ for (var i = forms.length; i--; ) {
383+ var f = forms[i];
384+ switch(f[4][0]) {
385+ case "FElement":
386+ if (arr.length > 0) {
387+ groups.push(arr);
388+ arr = [];
389+ }
390+ groups.push(f);
391+ break;
392+ default:
393+ arr.push(f);
394+ }
395+ }
396+ if (arr.length > 0) groups.push(arr);
397+ return groups;
398+ }
399+
400+ var toString = function(v) {
401+ if (typeof v === "function") {
402+ return "<function>";
403+ } else if (typeof v === "boolean") {
404+ return v ? "True" : "False";
405+ } else if (typeof v === "number") {
406+ return v+"";
407+ } else if (typeof v === "string" && v.length < 2) {
408+ return "'"+v+"'";
409+ } else if (typeof v === "object" && ('_' in v)) {
410+ var output = [];
411+ for (var k in v._) {
412+ console.log(k,v._[k]);
413+ for (var i = v._[k].length; i--; ) {
414+ output.push(k + " = " + toString(v._[k][i]));
415+ }
416+ }
417+ for (var k in v) {
418+ if (k === '_') continue;
419+ output.push(k + " = " + toString(v[k]));
420+ }
421+ if (output.length === 0) return "{}";
422+ return "{ " + output.join(", ") + " }";
423+ } else if (v[0]) {
424+ if (v[0].substring(0,5) === "Tuple") {
425+ var output = new Array(v.length-1);
426+ for (var i = v.length; --i; ) { output[i-1] = toString(v[i]); }
427+ return "(" + output.join(",") + ")";
428+ } else if (v[0] === "Cons") {
429+ var start = (typeof v[1] === "string") ? '"' : "[";
430+ var end = (typeof v[1] === "string") ? '"' : "]";
431+ var div = (typeof v[1] === "string") ? "" : ",";
432+ var f = (typeof v[1] === "string") ? function(x){return x} : toString;
433+ var output = start + f(v[1]);
434+ v = v[2];
435+ while (true) {
436+ if (v[0] === "Cons") {
437+ output += div + f(v[1]);
438+ v = v[2];
439+ } else {
440+ return output + end;
441+ }
442+ }
443+ } else if (v[0] === "Nil") {
444+ return "[]";
445+ } else if (v[0] === "JSON") {
446+ return "(JSON.fromList " + toString(Elm.JSON.toList(v)) + ")";
447+ } else if (v[0] === "RBNode" || v[0] === "RBEmpty") {
448+ function cons(k){ return function(v) { return function(acc) { return ["Cons",["Tuple2",k,v],acc]; }; }; }
449+ var list = Elm.Dict.foldr(cons)(["Nil"])(v);
450+ var name = "Dict";
451+ if (list[0] === "Cons" && list[1][2][0] === "Tuple0") {
452+ name = "Set";
453+ list = Elm.List.map(function(x) { return x[1]; })(list);
454+ }
455+ return "(" + name + ".fromList " + toString(list) + ")";
456+ } else {
457+ var output = "";
458+ for (var i = v.length; --i; ) { output = ' ' + toString(v[i]) + output; }
459+ output = v[0] + output;
460+ return (v.length > 1) ? "(" + output + ")" : output;
461+ }
462+ }
463+ return v+"";
464+ };
465+ var show = function(v) { return str(toString(v)); };
466+ var append = function(xs,ys) {
467+ if (typeof xs === "string" && typeof ys === "string") {
468+ return xs.concat(ys);
469+ }
470+ if (xs[0] === "Nil") {
471+ return ys;
472+ }
473+ var root = ["Cons", xs[1], ["Nil"]];
474+ var curr = root;
475+ xs = xs[2];
476+ while (xs[0]==="Cons") {
477+ curr[2] = ["Cons", xs[1], ["Nil"]];
478+ xs = xs[2];
479+ curr = curr[2];
480+ }
481+ curr[2] = ys;
482+ return root;
483+ };
484+
485+ var str = function(s) {
486+ var out = ["Nil"];
487+ for (var i = s.length; i--; ) {
488+ out = ["Cons", s[i], out];
489+ }
490+ return out;
491+ };
492+
493+ function wrap(elem) {
494+ var p = Value.getSize(elem);
495+ return ["Element", Guid.guid(), ["EHtml",elem],
496+ p[0], p[1], 1, ["Nothing"], ["Nothing"]];
497+ }
498+ var addListener = function() {
499+ if(document.addEventListener) {
500+ return function(element, event, handler) {
501+ element.addEventListener(event, handler, false);
502+ };
503+ } else {
504+ return function(element, event, handler) {
505+ element.attachEvent('on' + event, handler);
506+ };
507+ }
508+ }();
509+
510+ return {eq:eq,
511+ str:str,
512+ show:show,
513+ Tuple:Tuple,
514+ append:append,
515+ listToArray:listToArray,
516+ toText : toText,
517+ properEscape : properEscape,
518+ getTextSize : getTextSize,
519+ getSize : getSize,
520+ getExcess : getExcess,
521+ groupForms : groupForms,
522+ wrap : wrap,
523+ addListener : addListener
524+ };
525+}();Elm.List = function() {
526+
527+ var throwError = function(f) {
528+ throw new Error("Function '" + f + "' expecting a list!");
529+ }
530+
531+ function length(xs) {
532+ var out = 0;
533+ while (xs[0] === "Cons") {
534+ out += 1;
535+ xs = xs[2];
536+ }
537+ return out;
538+ };
539+ var reverse = foldl(function(x_72) {
540+ return function(y_73) {
541+ return["Cons", x_72, y_73]
542+ }
543+ })(["Nil"]);
544+ var concat = foldr(function(x_74) {
545+ return function(y_75) {
546+ return Value.append(x_74, y_75)
547+ }
548+ })(["Nil"]);
549+ var and = foldl(function(x_77) {
550+ return function(y_78) {
551+ return x_77 && y_78
552+ }
553+ })(true);
554+ var or = foldl(function(x_79) {
555+ return function(y_80) {
556+ return x_79 || y_80
557+ }
558+ })(false);
559+ var sum = foldl(function(x_89) {
560+ return function(y_90) {
561+ return x_89 + y_90
562+ }
563+ })(0);
564+ var product = foldl(function(x_91) {
565+ return function(y_92) {
566+ return x_91 * y_92
567+ }
568+ })(1);
569+ var maximum = foldl1(function(x) { return function(y) { return Math.max(x,y) } });
570+ var minimum = foldl1(function(x) { return function(y) { return Math.min(x,y) } });
571+ function head(v) {
572+ if (v[0] !== "Cons") {
573+ throw new Error("Error: 'head' only accepts lists of length greater than one.");
574+ }
575+ return v[1];
576+ }
577+ function tail(v) {
578+ if (v[0] !== "Cons") {
579+ throw new Error("Error: 'tail' only accepts lists of length greater than one.");
580+ }
581+ return v[2];
582+ }
583+ function last(v) {
584+ if (v[0] !== "Cons") {
585+ throw new Error("Error: 'last' only accepts lists of length greater than one.");
586+ }
587+ var out = v[1];
588+ while (v[0] === "Cons") {
589+ out = v[1];
590+ v = v[2];
591+ }
592+ return out;
593+ }
594+ function map(f) {
595+ return function(xs) {
596+ if (xs[0] === "Nil") { return xs; }
597+ if (xs[0] !== "Cons") { throwError('map'); }
598+ var root = ["Cons", f(xs[1]), ["Nil"]];
599+ var curr = root;
600+ xs = xs[2];
601+ while (xs[0]==="Cons") {
602+ curr[2] = ["Cons", f(xs[1]), ["Nil"]];
603+ xs = xs[2];
604+ curr = curr[2];
605+ }
606+ return root;
607+ }
608+ }
609+ function foldl(f) {
610+ return function(b) {
611+ return function(xs) {
612+ var acc = b;
613+ if (xs[0] === "Nil") { return acc; }
614+ if (xs[0] !== "Cons") { throwError('foldl'); }
615+ while (xs[0] === "Cons") {
616+ acc = f(xs[1])(acc);
617+ xs = xs[2];
618+ }
619+ return acc;
620+ }
621+ }
622+ }
623+ function foldr(f) {
624+ return function(b) {
625+ return function(xs) {
626+ var acc = b;
627+ if (xs[0] === "Nil") { return acc; }
628+ if (xs[0] !== "Cons") { throwError('foldr'); }
629+ var arr = [];
630+ while (xs[0] === "Cons") {
631+ arr.push(xs[1]);
632+ xs = xs[2];
633+ }
634+ for (var i = arr.length; i--; ) {
635+ acc = f(arr[i])(acc);
636+ }
637+ return acc;
638+ }
639+ }
640+ }
641+ function foldl1(f_49) {
642+ return function(_temp_50) {
643+ return function(v) {
644+ if("Cons" !== v[0]) {
645+ return undefined
646+ }else {
647+ var x_51 = v[1];
648+ var xs_52 = v[2];
649+ return foldl(f_49)(x_51)(xs_52)
650+ }
651+ }(_temp_50)
652+ }
653+ }
654+ function foldr1(f) {
655+ return function(xs) {
656+ if (xs[0] === "Nil") { throw new Error("'foldr1' requires an non-empty list.") }
657+ if (xs[0] !== "Cons") { throwError('foldr1'); }
658+ var arr = [];
659+ while (xs[0] === "Cons") {
660+ arr.push(xs[1]);
661+ xs = xs[2];
662+ }
663+ var acc = arr.pop();
664+ for (var i = arr.length; i--; ) {
665+ acc = f(arr[i])(acc);
666+ }
667+ return acc;
668+ }
669+ }
670+ function scanl(f) {
671+ return function(b) {
672+ return function(xs) {
673+ if (xs[0] === "Nil") { return ["Cons",b,["Nil"]]; }
674+ if (xs[0] !== "Cons") { throwError('scanl'); }
675+ var arr = [b];
676+ while (xs[0] === "Cons") {
677+ b = f(xs[1])(b);
678+ arr.push(b);
679+ xs = xs[2];
680+ }
681+ var out = ["Nil"];
682+ for (var i = arr.length; i--; ) {
683+ out = ["Cons", arr[i], out];
684+ }
685+ return out;
686+ }
687+ }
688+ }
689+ function scanl1(f) {
690+ return function(xs) {
691+ if (xs[0] !== "Cons") {
692+ throw new Error("Error: 'scanl1' requires a list of at least length 1.");
693+ }
694+ return scanl(f)(xs[1])(xs[2]);
695+ }
696+ }
697+ function filter(pred) {
698+ return function(xs) {
699+ if (xs[0] === "Nil") { return xs; }
700+ if (xs[0] !== "Cons") { throwError('filter'); }
701+ var arr = [];
702+ while (xs[0] === "Cons") {
703+ if (pred(xs[1])) { arr.push(xs[1]); }
704+ xs = xs[2];
705+ }
706+ var out = ["Nil"];
707+ for (var i = arr.length; i--; ) {
708+ out = ["Cons", arr[i], out];
709+ }
710+ return out;
711+ }
712+ }
713+ function concatMap(f_76) {
714+ return function(x) {
715+ return concat(map(f_76)(x))
716+ }
717+ }
718+ function all(pred) {
719+ return foldl(function(x) { return function(acc) {
720+ return acc && pred(x);
721+ };})(true);
722+ }
723+ function any(pred) {
724+ return foldl(function(x) { return function(acc) {
725+ return acc || pred(x);
726+ };})(false);
727+ }
728+ function partition(pred_93) {
729+ return function(lst_94) {
730+ return function() {
731+ var v = lst_94;
732+ var c = [function(v) {
733+ if("Nil" !== v[0]) {
734+ return undefined
735+ }else {
736+ return["Tuple2", ["Nil"], ["Nil"]]
737+ }
738+ }, function(v) {
739+ if("Cons" !== v[0]) {
740+ return undefined
741+ }else {
742+ var x_95 = v[1];
743+ var xs_96 = v[2];
744+ return function(v) {
745+ if("Tuple2" !== v[0]) {
746+ return undefined
747+ }else {
748+ var as_97 = v[1];
749+ var bs_98 = v[2];
750+ return pred_93(x_95) ? ["Tuple2", ["Cons", x_95, as_97], bs_98] : ["Tuple2", as_97, ["Cons", x_95, bs_98]]
751+ }
752+ }(partition(pred_93)(xs_96))
753+ }
754+ }];
755+ for(var i = c.length;i--;) {
756+ var r = c[i](v);
757+ if(r !== undefined) {
758+ return r
759+ }
760+ }
761+ }()
762+ }
763+ }
764+ function zipWith(f) {
765+ return function(listA) {
766+ return function(listB) {
767+ if (listA[0] === "Nil" || listB[0] === "Nil") { return ["Nil"]; }
768+ if (listA[0] !== "Cons" || listB[0] !== "Cons") { throwError('zipWith'); }
769+ var arr = [];
770+ while (listA[0] === "Cons" && listB[0] === "Cons") {
771+ arr.push(f(listA[1])(listB[1]));
772+ listA = listA[2];
773+ listB = listB[2];
774+ }
775+ var out = ["Nil"];
776+ for (var i = arr.length; i--; ) {
777+ out = ["Cons", arr[i], out];
778+ }
779+ return out;
780+ }
781+ }
782+ }
783+ function zip(listA) {
784+ return function(listB) {
785+ if (listA[0] === "Nil" || listB[0] === "Nil") { return ["Nil"]; }
786+ if (listA[0] !== "Cons" || listB[0] !== "Cons") { throwError('zip'); }
787+ var arr = [];
788+ while (listA[0] === "Cons" && listB[0] === "Cons") {
789+ arr.push(["Tuple2", listA[1], listB[1]]);
790+ listA = listA[2];
791+ listB = listB[2];
792+ }
793+ var out = ["Nil"];
794+ for (var i = arr.length; i--; ) {
795+ out = ["Cons", arr[i], out];
796+ }
797+ return out;
798+ }
799+ }
800+ function unzip(pairs_112) {
801+ return function() {
802+ var v = pairs_112;
803+ var c = [function(v) {
804+ if("Nil" !== v[0]) {
805+ return undefined
806+ }else {
807+ return["Tuple2", ["Nil"], ["Nil"]]
808+ }
809+ }, function(v) {
810+ if("Cons" !== v[0]) {
811+ return undefined
812+ }else {
813+ var p_113 = v[1];
814+ var ps_114 = v[2];
815+ return function(v) {
816+ if("Tuple2" !== v[0]) {
817+ return undefined
818+ }else {
819+ if("Tuple2" !== v[1][0]) {
820+ return undefined
821+ }else {
822+ var x_115 = v[1][1];
823+ var y_116 = v[1][2];
824+ if("Tuple2" !== v[2][0]) {
825+ return undefined
826+ }else {
827+ var xs_117 = v[2][1];
828+ var ys_118 = v[2][2];
829+ return["Tuple2", ["Cons", x_115, xs_117], ["Cons", y_116, ys_118]]
830+ }
831+ }
832+ }
833+ }(["Tuple2", p_113, unzip(ps_114)])
834+ }
835+ }];
836+ for(var i = c.length;i--;) {
837+ var r = c[i](v);
838+ if(r !== undefined) {
839+ return r
840+ }
841+ }
842+ }()
843+ }
844+ function intersperse(sep_119) {
845+ return function(xs_120) {
846+ return function() {
847+ var v = xs_120;
848+ var c = [function(v) {
849+ if("Nil" !== v[0]) {
850+ return undefined
851+ }else {
852+ return["Nil"]
853+ }
854+ }, function(v) {
855+ if("Cons" !== v[0]) {
856+ return undefined
857+ }else {
858+ var a_124 = v[1];
859+ if("Nil" !== v[2][0]) {
860+ return undefined
861+ }else {
862+ return["Cons", a_124, ["Nil"]]
863+ }
864+ }
865+ }, function(v) {
866+ if("Cons" !== v[0]) {
867+ return undefined
868+ }else {
869+ var a_121 = v[1];
870+ if("Cons" !== v[2][0]) {
871+ return undefined
872+ }else {
873+ var b_122 = v[2][1];
874+ var cs_123 = v[2][2];
875+ return["Cons", a_121, ["Cons", sep_119, intersperse(sep_119)(["Cons", b_122, cs_123])]]
876+ }
877+ }
878+ }];
879+ for(var i = c.length;i--;) {
880+ var r = c[i](v);
881+ if(r !== undefined) {
882+ return r
883+ }
884+ }
885+ }()
886+ }
887+ }
888+ function intercalate(sep_125) {
889+ return function(xs_126) {
890+ return function() {
891+ var v = xs_126;
892+ var c = [function(v) {
893+ if("Nil" !== v[0]) {
894+ return undefined
895+ }else {
896+ return["Nil"]
897+ }
898+ }, function(v) {
899+ if("Cons" !== v[0]) {
900+ return undefined
901+ }else {
902+ var a_130 = v[1];
903+ if("Nil" !== v[2][0]) {
904+ return undefined
905+ }else {
906+ return a_130
907+ }
908+ }
909+ }, function(v) {
910+ if("Cons" !== v[0]) {
911+ return undefined
912+ }else {
913+ var a_127 = v[1];
914+ if("Cons" !== v[2][0]) {
915+ return undefined
916+ }else {
917+ var b_128 = v[2][1];
918+ var cs_129 = v[2][2];
919+ return Value.append(a_127, Value.append(sep_125, intercalate(sep_125)(["Cons", b_128, cs_129])))
920+ }
921+ }
922+ }];
923+ for(var i = c.length;i--;) {
924+ var r = c[i](v);
925+ if(r !== undefined) {
926+ return r
927+ }
928+ }
929+ }()
930+ }
931+ }
932+ function sort(xs) {
933+ if (xs[0] === "Nil") { return xs; }
934+ if (xs[0] !== "Cons") { throwError('sort'); }
935+ var arr = [];
936+ while (xs[0] === "Cons") {
937+ arr.push(xs[1]);
938+ xs = xs[2];
939+ }
940+ arr.sort(function(a,b) { return a - b});
941+ var out = ["Nil"];
942+ for (var i = arr.length; i--; ) {
943+ out = [ "Cons", arr[i], out ];
944+ }
945+ return out;
946+ }
947+ function take(n) { return function(xs) {
948+ if (n <= 0) { return ["Nil"]; }
949+ if (xs[0] === "Nil") { return xs; }
950+ if (xs[0] !== "Cons") { throwError('take'); }
951+ var out = [ "Cons", xs[1], ["Nil"] ];
952+ var temp = out;
953+ xs = xs[2];
954+ --n;
955+ while (xs[0] === "Cons" && n > 0) {
956+ temp[2] = [ "Cons", xs[1], ["Nil"] ];
957+ temp = temp[2];
958+ xs = xs[2];
959+ --n;
960+ }
961+ return out;
962+ };
963+ }
964+ function drop(n) { return function(xs) {
965+ if (xs[0] === "Nil") { return xs; }
966+ if (xs[0] !== "Cons") { throwError('drop'); }
967+ while (xs[0] === "Cons" && n > 0) {
968+ xs = xs[2];
969+ --n;
970+ }
971+ return xs;
972+ };
973+ }
974+ return {head:head,
975+ tail:tail,
976+ last:last,
977+ map:map,
978+ foldl:foldl,
979+ foldr:foldr,
980+ foldl1:foldl1,
981+ foldr1:foldr1,
982+ scanl:scanl,
983+ scanl1:scanl1,
984+ filter:filter,
985+ length:length,
986+ reverse:reverse,
987+ concat:concat,
988+ concatMap:concatMap,
989+ and:and,
990+ or:or,
991+ all:all,
992+ any:any,
993+ sum:sum,
994+ product:product,
995+ maximum:maximum,
996+ minimum:minimum,
997+ partition:partition,
998+ zipWith:zipWith,
999+ zip:zip,
1000+ unzip:unzip,
1001+ intersperse:intersperse,
1002+ intercalate:intercalate,
1003+ sort:sort,
1004+ take:take,
1005+ drop:drop};
1006+}();/*! Maybe
1007+!*/
1008+
1009+/*[Definition]*/
1010+
1011+/** data Maybe a = Just a | Nothing
1012+ The Maybe datatype. Useful when a computation may or may not
1013+ result in a value (e.g. logarithm is defined only for positive numbers).
1014+**/
1015+
1016+/*[Basic Utilities]*/
1017+
1018+/** maybe : b -> (a -> b) -> Maybe a -> b
1019+ Apply a function to the contents of a `Maybe`.
1020+ Return default when given `Nothing`.
1021+**/
1022+/** isJust : Maybe a -> Bool
1023+ Check if constructed with `Just`.
1024+**/
1025+/** isNothing : Maybe a -> Bool
1026+ Check if constructed with `Nothing`.
1027+**/
1028+
1029+/*[Maybe with Lists]*/
1030+
1031+/** cons : Maybe a -> [a] -> [a]
1032+ If `Just`, adds the value to the front of the list.
1033+ If `Nothing`, list is unchanged.
1034+**/
1035+/** justs : [Maybe a] -> [a]
1036+ Filters out Nothings and extracts the remaining values.
1037+**/
1038+
1039+Elm.Maybe = function() {
1040+ function consMaybe(x) { return function(xs) {
1041+ if (x[0] === "Just") return ["Cons", x[1], xs];
1042+ return xs;
1043+ };
1044+ }
1045+ function mapCons(f) { return function(y) { return function(xs) {
1046+ var x = f(y);
1047+ if (x[0] === "Just") return ["Cons", x[1], xs];
1048+ return xs;
1049+ };
1050+ };
1051+ }
1052+ function maybe(b) { return function(f) { return function(m) {
1053+ if (m[0] === "Just") return f(m[1]);
1054+ return b;
1055+ };
1056+ };
1057+ }
1058+
1059+ return {Just : function(x) { return ["Just",x]; },
1060+ Nothing : ["Nothing"],
1061+ justs : Elm.List.foldr(consMaybe)(["Nil"]),
1062+ isJust : function(m) { return m[0] === "Just"; },
1063+ isNothing : function(m) { return m[0] === "Nothing"; },
1064+ cons : consMaybe,
1065+ maybe : maybe
1066+ };
1067+}();
1068+/*! Either
1069+!*/
1070+
1071+
1072+Elm.Either = function() {
1073+ /*[Definition]*/
1074+
1075+ /** data Either a b = Left a | Right b
1076+ Represents any data that can take two different types.
1077+
1078+ This can also be used for error handling (`Either String a`) where
1079+ error messages are stored on the left, and the correct values
1080+ ("right" values) are stored on the right.
1081+ **/
1082+ function Left(a1) { return ['Left',a1]; }
1083+ function Right(a1){ return ['Right',a1]; }
1084+
1085+ /*[Basics]*/
1086+
1087+ /** either : (a -> c) -> (b -> c) -> Either a b -> c
1088+ Apply the first function to a `Left` and the second function to a `Right`.
1089+ This allows the extraction of a value from an `Either`.
1090+ **/
1091+ function either(f){ return function(g){ return function(e){
1092+ switch(e[0]){
1093+ case 'Left': return f(e[1]);
1094+ case 'Right': return g(e[1]);
1095+ }
1096+ };};}
1097+
1098+ /** isLeft : Either a b -> Bool
1099+ True if the value is a `Left`.
1100+ **/
1101+ function isLeft(e) { return e[0] == 'Left'; }
1102+
1103+ /** isRight : Either a b -> Bool
1104+ True if the value is a `Right`.
1105+ **/
1106+ function isRight(e) { return e[0] == 'Right'; }
1107+
1108+ /*[With Lists]*/
1109+
1110+ function get(es) { return Elm.List.map(function(x){return x[1];})(es); }
1111+
1112+ /** lefts : [Either a b] -> [a]
1113+ Keep only the values held in `Left` values.
1114+ **/
1115+ function lefts(es) { return get(Elm.List.filter(isLeft)(es)); }
1116+
1117+ /** rights : [Either a b] -> [a]
1118+ Keep only the values held in `Right` values.
1119+ **/
1120+ function rights(es) { return get(Elm.List.filter(isRight)(es)); }
1121+
1122+ /** partition : [Either a b] -> ([a],[b])
1123+ Split into two lists, lefts on the left and rights on the right.
1124+ So we have the equivalence:
1125+
1126+ partition es == (lefts es, rights es)
1127+ **/
1128+ function partition(es) {
1129+ var lrs = Elm.List.partition(isLeft)(es);
1130+ lrs[1] = get(lrs[1]);
1131+ lrs[2] = get(lrs[2]);
1132+ return lrs;
1133+ }
1134+ return {Left:Left,
1135+ Right:Right,
1136+ either:either,
1137+ isLeft:isLeft,
1138+ isRight:isRight,
1139+ lefts:lefts,
1140+ rights:rights,
1141+ partition:partition};
1142+}();
1143+/*! Char !*/
1144+
1145+/*[Classification]*/
1146+
1147+/** isUpper : Char -> Bool
1148+ Selects upper case letters.
1149+**/
1150+/** isLower : Char -> Bool
1151+ Selects lower case letters.
1152+**/
1153+/** isDigit : Char -> Bool
1154+ Selects ASCII digits (0..9).
1155+**/
1156+/** isOctDigit : Char -> Bool
1157+ Selects ASCII octal digits (0..7).
1158+**/
1159+/** isHexDigit : Char -> Bool
1160+ Selects ASCII hexadecimal digits (0..9a..fA..F).
1161+**/
1162+
1163+/*[Conversion]*/
1164+
1165+/** toUpper : Char -> Char
1166+ Convert to upper case.
1167+**/
1168+/** toLower : Char -> Char
1169+ Convert to lower case.
1170+**/
1171+/** toLocaleUpper : Char -> Char
1172+ Convert to upper case, according to any locale-specific case mappings.
1173+**/
1174+/** toLocaleLower : Char -> Char
1175+ Convert to lower case, according to any locale-specific case mappings.
1176+**/
1177+/** toCode : Char -> Int
1178+ Convert to unicode.
1179+**/
1180+/** fromCode : Int -> Char
1181+ Convert from unicode.
1182+**/
1183+
1184+Elm.Char = function() {
1185+ function isBetween(lo,hi) { return function(chr) {
1186+ var c = chr.charCodeAt(0);
1187+ return lo <= c && c <= hi;
1188+ };
1189+ }
1190+ var isDigit = isBetween('0'.charCodeAt(0),'9'.charCodeAt(0));
1191+ var chk1 = isBetween('a'.charCodeAt(0),'f'.charCodeAt(0));
1192+ var chk2 = isBetween('A'.charCodeAt(0),'F'.charCodeAt(0));
1193+
1194+ return {fromCode : function(c) { return String.fromCharCode(c); },
1195+ toCode : function(c) { return c.charCodeAt(0); },
1196+ toUpper : function(c) { return c.toUpperCase(); },
1197+ toLower : function(c) { return c.toLowerCase(); },
1198+ toLocaleUpper : function(c) { return c.toLocaleUpperCase(); },
1199+ toLocaleLower : function(c) { return c.toLocaleLowerCase(); },
1200+ isLower : isBetween('a'.charCodeAt(0),'z'.charCodeAt(0)),
1201+ isUpper : isBetween('A'.charCodeAt(0),'Z'.charCodeAt(0)),
1202+ isDigit : isDigit,
1203+ isOctDigit : isBetween('0'.charCodeAt(0),'7'.charCodeAt(0)),
1204+ isHexDigit : function(c) { return isDigit(c) || chk1(c) || chk2(c); }
1205+ };
1206+}();
1207+Elm.Color = function() {
1208+
1209+function Color_0(a1) {
1210+ return function(a2) {
1211+ return function(a3) {
1212+ return function(a4) {
1213+ return["Color", a1, a2, a3, a4]
1214+ }
1215+ }
1216+ }
1217+}
1218+var rgba_1 = Color_0;
1219+var red_3 = ["Color",255,0,0,1];
1220+var green_4 = ["Color",0,255,0,1];
1221+var blue_5 = ["Color",0,0,255,1];
1222+var yellow_6 = ["Color",255,255,0,1];
1223+var cyan_7 = ["Color",0,255,255,1];
1224+var magenta_8 = ["Color",255,0,255,1];
1225+var black_9 = ["Color",0,0,0,1];
1226+var white_10 = ["Color",255,255,255,1];
1227+var gray_11 = ["Color",128,128,128,1];
1228+var grey_12 = ["Color",128,128,128,1];
1229+function rgb_2(r_13) {
1230+ return function(g_14) {
1231+ return function(b_15) {
1232+ return ["Color",r_13,g_14,b_15,1]
1233+ }
1234+ }
1235+}
1236+function extract(c) {
1237+ if (c[4] === 1) { return 'rgb(' + c[1] + ',' + c[2] + ',' + c[3] + ')'; }
1238+ return 'rgba(' + c[1] + ',' + c[2] + ',' + c[3] + ',' + c[4] + ')';
1239+}
1240+function complement(rgb) {
1241+ var hsv = toHSV(rgb);
1242+ hsv.hue = (hsv.hue + 180) % 360;
1243+ return toRGB(hsv);
1244+}
1245+
1246+function hsva(h) { return function(s) { return function(v) { return function(a) {
1247+ var clr = toRGB({hue:h, saturation:s, value:v});
1248+ clr[4] = a;
1249+ return clr;
1250+ }; }; };
1251+}
1252+
1253+function hsv(h) { return function(s) { return function(v) {
1254+ return toRGB({hue:h, saturation:s, value:v}); }; }; }
1255+
1256+function toHSV(rgb) {
1257+ var hsv = {};
1258+ var r = rgb[1] / 255.0, g = rgb[2] / 255.0, b = rgb[3] / 255.0;
1259+ var M = Math.max(r,g,b);
1260+ var m = Math.min(r,g,b);
1261+ var c = M - m;
1262+
1263+ var h = 0;
1264+ if (c === 0) { h = 0; }
1265+ else if (M === r) { h = ((g - b) / c) % 6; }
1266+ else if (M === g) { h = ((b - r) / c) + 2; }
1267+ else if (M === b) { h = ((r - g) / c) + 4; }
1268+ h *= 60;
1269+
1270+ return { value : M, hue : h, saturation : (M === 0 ? 0 : c / M) };
1271+}
1272+
1273+function between(lo,hi,x) { return lo <= x && x < hi; }
1274+function norm(n) { return Math.round(n*255); }
1275+
1276+function toRGB(hsv) {
1277+ var c = hsv.value * hsv.saturation;
1278+ var hue = hsv.hue / 60;
1279+ var x = c * (1 - Math.abs((hue % 2) - 1));
1280+ var r = 0, g = 0, b = 0;
1281+ if (between(0,1,hue)) { r = c; g = x; b = 0; }
1282+ else if (between(1,2,hue)) { r = x; g = c; b = 0; }
1283+ else if (between(2,3,hue)) { r = 0; g = c; b = x; }
1284+ else if (between(3,4,hue)) { r = 0; g = x; b = c; }
1285+ else if (between(4,5,hue)) { r = x; g = 0; b = c; }
1286+ else if (between(5,6,hue)) { r = c; g = 0; b = x; }
1287+
1288+ var m = hsv.value - c;
1289+ return ["Color", norm(r+m), norm(g+m), norm(b+m), 1 ];
1290+}
1291+ return{rgba:rgba_1, rgb:rgb_2, hsva:hsva, hsv:hsv, red:red_3, green:green_4, blue:blue_5, yellow:yellow_6, cyan:cyan_7, magenta:magenta_8, black:black_9, white:white_10, gray:gray_11, grey:grey_12,complement:complement,extract:extract}
1292+}();
1293+var Collage = function() {
1294+
1295+var JS = Elm.JavaScript;
1296+
1297+function tracePoints(ctx,points) {
1298+ var i = points.length - 1;
1299+ if (i <= 0) return;
1300+ ctx.moveTo(points[i][1], points[i][2]);
1301+ while (i--) { ctx.lineTo(points[i][1], points[i][2]); }
1302+}
1303+
1304+function solid(ctx,color,points) {
1305+ tracePoints(ctx,points);
1306+ ctx.strokeStyle = Elm.Color.extract(color);
1307+ ctx.stroke();
1308+};
1309+
1310+function filled(ctx,color,points) {
1311+ tracePoints(ctx,points);
1312+ ctx.fillStyle = Elm.Color.extract(color);
1313+ ctx.fill();
1314+}
1315+
1316+function textured(redo,ctx,src,points) {
1317+ var img = new Image();
1318+ img.src = JS.castStringToJSString(src);
1319+ img.onload = redo;
1320+
1321+ tracePoints(ctx,points);
1322+ ctx.fillStyle = ctx.createPattern(img,'repeat');
1323+ ctx.fill();
1324+}
1325+
1326+function customLine(pattern,ctx,color,points) {
1327+ if (pattern.length === 0) { pattern = [8,4]; }
1328+ customLineHelp(ctx, pattern, points);
1329+ ctx.strokeStyle = Elm.Color.extract(color);
1330+ ctx.stroke();
1331+};
1332+
1333+var customLineHelp = function(ctx, pattern, points) {
1334+ var i = points.length - 1;
1335+ if (i <= 0) return;
1336+ var x0 = points[i][1], y0 = points[i][2];
1337+ var x1=0, y1=0, dx=0, dy=0, remaining=0, nx=0, ny=0;
1338+ var pindex = 0, plen = pattern.length;
1339+ var draw = true, segmentLength = pattern[0];
1340+ ctx.moveTo(x0,y0);
1341+ while (i--) {
1342+ x1 = points[i][1]; y1 = points[i][2];
1343+ dx = x1 - x0; dy = y1 - y0;
1344+ remaining = Math.sqrt(dx * dx + dy * dy);
1345+ while (segmentLength <= remaining) {
1346+ x0 += dx * segmentLength / remaining;
1347+ y0 += dy * segmentLength / remaining;
1348+ ctx[draw ? 'lineTo' : 'moveTo'](x0, y0);
1349+ // update starting position
1350+ dx = x1 - x0; dy = y1 - y0;
1351+ remaining = Math.sqrt(dx * dx + dy * dy);
1352+ // update pattern
1353+ draw = !draw;
1354+ pindex = (pindex + 1) % plen;
1355+ segmentLength = pattern[pindex];
1356+ }
1357+ if (remaining > 0) {
1358+ ctx[draw ? 'lineTo' : 'moveTo'](x1, y1);
1359+ segmentLength -= remaining;
1360+ }
1361+ x0 = x1; y0 = y1;
1362+ }
1363+};
1364+
1365+function drawLine(ctx,form) {
1366+ var points = form[3][1];
1367+ switch(form[1][0]) {
1368+ case "Solid" : return solid(ctx,form[2],points);
1369+ case "Dotted": return customLine([3,3],ctx,form[2],points);
1370+ case "Dashed": return customLine([8,4],ctx,form[2],points);
1371+ case "Custom": return customLine(form[1][1],ctx,form[2],points);
1372+ }
1373+};
1374+
1375+function drawShape(redo,ctx,shapeStyle,color,points) {
1376+ switch(shapeStyle[0]) {
1377+ case "Filled": return filled(ctx,color,points);
1378+ case "Outlined": return solid(ctx,color,points);
1379+ case "Textured": return textured(redo,ctx,shapeStyle[1],points);
1380+ case "CustomOutline":
1381+ return customLine(shapeStyle[1],ctx,color,points);
1382+ }
1383+};
1384+
1385+function drawImage(redo,ctx,w,h,src) {
1386+ var img = new Image();
1387+ img.onload = redo;
1388+ img.src = JS.castStringToJSString(src);
1389+ ctx.drawImage(img,-w/2,-h/2,w,h);
1390+}
1391+
1392+function renderForm(redo,ctx,theta,scale,x,y,form) {
1393+ ctx.save();
1394+ if (x !== 0 || y !== 0) ctx.translate(x,y);
1395+ if (theta !== ~~theta) ctx.rotate(2*Math.PI*theta);
1396+ if (scale !== 1) ctx.scale(scale,scale);
1397+ ctx.beginPath();
1398+ switch(form[0]) {
1399+ case "FLine": drawLine(ctx,form); break;
1400+ case "FShape": drawShape(redo,ctx,form[1],form[2],form[3][1]); break;
1401+ case "FImage": drawImage(redo,ctx,form[1],form[2],form[3]); break;
1402+ }
1403+ ctx.restore();
1404+};
1405+
1406+function renderForms(redo,ctx,w,h,forms) {
1407+ ctx.clearRect(0,0,w,h);
1408+ for (var i = forms.length; i--; ) {
1409+ var f = forms[i];
1410+ renderForm(redo,ctx,f[1],f[2],f[3][1],f[3][2],f[4]);
1411+ }
1412+}
1413+
1414+function collageForms(w,h,forms) {
1415+ var canvas = Render.newElement('canvas');
1416+ w = ~~w;
1417+ h = ~~h;
1418+ canvas.style.width = w + 'px';
1419+ canvas.style.height = h + 'px';
1420+ canvas.style.display = "block";
1421+ canvas.width = w;
1422+ canvas.height = h;
1423+ if (canvas.getContext) {
1424+ var ctx = canvas.getContext('2d');
1425+ function redo() { renderForms(this,ctx,w,h,forms); }
1426+ renderForms(redo,ctx,w,h,forms);
1427+ return canvas;
1428+ }
1429+ canvas.innerHTML = "Your browser does not support the canvas element.";
1430+ return canvas;
1431+};
1432+
1433+function applyTransforms(theta,scale,x,y,w,h,e) {
1434+ var t = "translate(" + (x - w / 2) + "px,"+ (y - h / 2) + "px)";
1435+ var r = theta === (~~theta) ? "" : "rotate(" + theta*360 + "deg)";
1436+ var s = scale === 1 ? "" : "scale(" + scale + "," + scale + ")";
1437+ var transforms = t + " " + s + " " + r;
1438+ e.style.transform = transforms;
1439+ e.style.msTransform = transforms;
1440+ e.style.MozTransform = transforms;
1441+ e.style.webkitTransform = transforms;
1442+ e.style.OTransform = transforms;
1443+}
1444+
1445+function collageElement(w,h,theta,scale,x,y,elem) {
1446+ var e = Render.render(elem);
1447+ applyTransforms(theta,scale,x,y,elem[3],elem[4],e);
1448+ var div = Render.newElement('div');
1449+ Render.addTo(div,e);
1450+ div.style.width = (~~w) + "px";
1451+ div.style.height = (~~h) + "px";
1452+ div.style.overflow = "hidden";
1453+ return div;
1454+}
1455+
1456+function collage(w,h,formss) {
1457+ if (formss.length === 0) { return collageForms(w,h,[]); }
1458+ var elems = new Array(formss.length);
1459+ for (var i = formss.length; i--; ) {
1460+ var f = formss[i];
1461+ if (typeof f[0] === "string") {
1462+ elems[i] = collageElement(w,h,f[1],f[2],f[3][1],f[3][2],f[4][1]);
1463+ } else {
1464+ elems[i] = collageForms(w,h,f);
1465+ }
1466+ }
1467+ if (formss.length === 1) { return elems[0]; }
1468+ return Render.flowWith(Render.goIn,function(x){return x},elems);
1469+}
1470+
1471+function updateFormSet(node,currSet,nextSet) {
1472+ if (Value.eq(nextSet,currSet)) return;
1473+ var w = node.style.width.slice(0,-2) - 0;
1474+ var h = node.style.height.slice(0,-2) - 0;
1475+ if (typeof nextSet[0] === "object") {
1476+ if (typeof currSet[0] === "object") {
1477+ if (node.getContext) {
1478+ var ctx = node.getContext('2d');
1479+ function redo() { renderForms(this,ctx,w,h,nextSet); }
1480+ return renderForms(redo,ctx,w,h,nextSet);
1481+ }
1482+ }
1483+ var newNode = collageForms(w,h,nextSet);
1484+ newNode.style.position = 'absolute';
1485+ return node.parentNode.replaceChild(newNode,node);
1486+ }
1487+ node.style.width = (~~w) + "px";
1488+ node.style.height = (~~h) + "px";
1489+ var f = nextSet;
1490+ var next = nextSet[4][1];
1491+ Render.update(node.firstChild, currSet[4][1], next);
1492+ applyTransforms(f[1],f[2],f[3][1],f[3][2],next[3],next[4],node.firstChild);
1493+}
1494+
1495+// assumes that the form sets are the same length.
1496+function updateCollage(node,currs,nexts) {
1497+ if (nexts.length === 1) {
1498+ return updateFormSet(node,currs[0],nexts[0]);
1499+ }
1500+ var kids = node.childNodes;
1501+ var len = kids.length;
1502+ for (var i = len; i--; ) {
1503+ updateFormSet(kids[len-i-1], currs[i], nexts[i]);
1504+ }
1505+}
1506+
1507+function style(clr,n,list) {
1508+ return ["Tuple2",
1509+ '<span style="font-size:100%;color:' + clr + ';">' + n + '</span>',
1510+ list];
1511+}
1512+
1513+function insideForm(point) { return function(form) {
1514+ if (!inBoundsOf(point[1],point[2],form)) return false;
1515+ var hw, hh;
1516+ switch (form[4][0]) {
1517+ case "FShape": return insideShape(point,form[1],form[2],form[3],form[4][3][1]);
1518+ case "FLine": return false;
1519+ case "FImage":
1520+ hw = form[4][1] / 2;
1521+ hh = form[4][2] / 2;
1522+ break;
1523+ case "FElement":
1524+ hw = form[4][1][3] / 2;
1525+ hh = form[4][1][4] / 2;
1526+ break;
1527+ }
1528+ return insideShape(point,form[1],form[2],form[3],
1529+ [ [null, hw, hh],
1530+ [null,-hw, hh],
1531+ [null,-hw,-hh],
1532+ [null, hw,-hh],
1533+ [null, hw, hh] ]);
1534+ };
1535+}
1536+
1537+function inBoundsOf(px,py,form) {
1538+ if (form.length < 6) {
1539+ var fx = form[3][1], fy = form[3][2];
1540+ var radiusSquared = 0;
1541+ var scale = form[2];
1542+ switch (form[4][0]) {
1543+ case "FShape":
1544+ var points = form[4][3][1];
1545+ for (var i = points.length; --i; ) {
1546+ var p = points[i];
1547+ radiusSquared = Math.max(radiusSquared, p[1]*p[1] + p[2]*p[2]);
1548+ }
1549+ radiusSquared *= scale * scale;
1550+ break;
1551+ case "FLine":
1552+ break;
1553+ case "FImage":
1554+ var x = scale * form[4][1] / 2;
1555+ var y = scale * form[4][2] / 2;
1556+ radiusSquared = x*x + y*y;
1557+ break;
1558+ case "FElement":
1559+ var x = scale * form[4][1][3] / 2;
1560+ var y = scale * form[4][1][4] / 2;
1561+ radiusSquared = x*x + y*y;
1562+ break;
1563+ }
1564+ form.push(function(px,py) {
1565+ var dx = px - fx;
1566+ var dy = py - fy;
1567+ return dx*dx + dy*dy < radiusSquared + 1;
1568+ });
1569+ }
1570+ return form[5](px,py);
1571+}
1572+
1573+function insideShape(point,theta,scale,pos,points) {
1574+ var counter = 0;
1575+ var list = ["Nil"];
1576+ var p1,p2;
1577+
1578+ var x = (point[1] - pos[1]) / scale;
1579+ var y = (point[2] - pos[2]) / scale;
1580+ if (theta !== 0) {
1581+ var t = -2 * Math.PI * theta;
1582+ var nx = x * Math.cos(t) - y * Math.sin(t);
1583+ y = x * Math.sin(t) + y * Math.cos(t);
1584+ x = nx;
1585+ }
1586+
1587+ if (points.length === 0) { return false; }
1588+ p1 = points[0];
1589+ for (var i = points.length - 1; i--; ) {
1590+ p2 = points[i];
1591+ var p1x = p1[1], p1y = p1[2], p2x = p2[1], p2y = p2[2];
1592+
1593+ if (p1y < p2y) {var ymin=p1y, ymax=p2y;} else {var ymin=p2y, ymax=p1y;}
1594+ if (p1x < p2x) {var xmin=p1x, xmax=p2x;} else {var xmin=p2x, xmax=p1x;}
1595+
1596+ if (ymin < y && y <= ymax && x <= xmax) {
1597+ if (x <= xmin || x <= ((y-p1y)*(p2x-p1x)/(p2y-p1y)+p1x)) {
1598+ ++counter;
1599+ }
1600+ }
1601+ p1 = p2;
1602+ }
1603+ return (counter % 2) === 1;
1604+}
1605+
1606+return {collage:collage, updateCollage:updateCollage, insideForm:insideForm};
1607+
1608+}();Elm.Graphics = function() {
1609+ for (this['i'] in Elm.List) {
1610+ eval('var ' + this['i'] + ' = Elm.List[this.i];');
1611+ }
1612+ var JS = Elm.JavaScript;
1613+ var DLeft_0 = ["DLeft"];
1614+ var DRight_1 = ["DRight"];
1615+ var DUp_2 = ["DUp"];
1616+ var DDown_3 = ["DDown"];
1617+ var DIn_4 = ["DIn"];
1618+ var DOut_5 = ["DOut"];
1619+ function Absolute_12(a1) {
1620+ return["Absolute", a1]
1621+ }
1622+ function Relative_13(a1) {
1623+ return["Relative", a1]
1624+ }
1625+ var Near_14 = ["Near"];
1626+ var Mid_15 = ["Mid"];
1627+ var Far_16 = ["Far"];
1628+ function Position_17(a1) {
1629+ return function(a2) {
1630+ return["Position", a1, a2]
1631+ }
1632+ }
1633+ function PositionTL_18(a1) {
1634+ return function(a2) {
1635+ return["PositionTL", a1, a2]
1636+ }
1637+ }
1638+ function PositionTR_19(a1) {
1639+ return function(a2) {
1640+ return["PositionTR", a1, a2]
1641+ }
1642+ }
1643+ function PositionBL_20(a1) {
1644+ return function(a2) {
1645+ return["PositionBL", a1, a2]
1646+ }
1647+ }
1648+ function PositionBR_21(a1) {
1649+ return function(a2) {
1650+ return["PositionBR", a1, a2]
1651+ }
1652+ }
1653+ function Element_37(id,e,w,h,o,c,l) {
1654+ return["Element", id, e, w, h, o, c, l ]
1655+ }
1656+ function EText_39(a1) {
1657+ return function(a2) {
1658+ return["EText", a1, a2]
1659+ }
1660+ }
1661+ function EImage_40(a1) {
1662+ return["EImage", JS.castStringToJSString(a1)]
1663+ }
1664+ function EVideo_41(a1) {
1665+ return["EVideo", JS.castStringToJSString(a1)]
1666+ }
1667+ function EFittedImage_42(a1) {
1668+ return["EFittedImage", JS.castStringToJSString(a1)]
1669+ }
1670+ function EFlow_43(a1) {
1671+ return function(a2) {
1672+ return["EFlow", a1, JS.castListToJSArray(a2)]
1673+ }
1674+ }
1675+ function ECollage_44(a1) {
1676+ return function(a2) {
1677+ return function(a3) {
1678+ return["ECollage", a1, a2, Value.groupForms(a3)]
1679+ }
1680+ }
1681+ }
1682+ var EEmpty_45 = ["EEmpty"];
1683+ function EContainer_46(a1) {
1684+ return function(a2) {
1685+ return["EContainer", a1, a2]
1686+ }
1687+ }
1688+ var Solid_68 = ["Solid"];
1689+ var Dotted_69 = ["Dotted"];
1690+ var Dashed_70 = ["Dashed"];
1691+ function Custom_71(a1) {
1692+ return["Custom", JS.castListToJSArray(a1)]
1693+ }
1694+ var Filled_72 = ["Filled"];
1695+ var Outlined_73 = ["Outlined"];
1696+ function CustomOutline_74(a1) {
1697+ return["CustomOutline", JS.castListToJSArray(a1)]
1698+ }
1699+ function Line_75(a1) {
1700+ return["Line", JS.castListToJSArray(a1)]
1701+ }
1702+ function Shape_78(a1) {
1703+ return function(a2) {
1704+ var points = JS.castListToJSArray(a1);
1705+ if (points.length > 0) { points.push(points[0]); }
1706+ return["Shape", points, a2];
1707+ }
1708+ }
1709+ function Form_84(a1) {
1710+ return function(a2) {
1711+ return function(a3) {
1712+ return function(a4) {
1713+ return["Form", a1, a2, a3, a4]
1714+ }
1715+ }
1716+ }
1717+ }
1718+ function FLine_85(a1) {
1719+ return function(a2) {
1720+ return function(a3) {
1721+ return["FLine", a1, a2, a3]
1722+ }
1723+ }
1724+ }
1725+ function FShape_86(a1) {
1726+ return function(a2) {
1727+ return function(a3) {
1728+ return["FShape", a1, a2, a3]
1729+ }
1730+ }
1731+ }
1732+ function FImage_87(a1) {
1733+ return function(a2) {
1734+ return function(a3) {
1735+ return["FImage", a1, a2, JS.castStringToJSString(a3)]
1736+ }
1737+ }
1738+ }
1739+ function FElement_88(a1) {
1740+ return["FElement", a1]
1741+ }
1742+ var left_6 = DLeft_0;
1743+ var right_7 = DRight_1;
1744+ var down_8 = DDown_3;
1745+ var up_9 = DUp_2;
1746+ var inward_10 = DIn_4;
1747+ var outward_11 = DOut_5;
1748+ var topLeft_22 = Position_17(Near_14)(Near_14);
1749+ var topRight_23 = Position_17(Far_16)(Near_14);
1750+ var bottomLeft_24 = Position_17(Near_14)(Far_16);
1751+ var bottomRight_25 = Position_17(Far_16)(Far_16);
1752+ var midLeft_26 = Position_17(Near_14)(Mid_15);
1753+ var midRight_27 = Position_17(Far_16)(Mid_15);
1754+ var midTop_28 = Position_17(Mid_15)(Near_14);
1755+ var midBottom_29 = Position_17(Mid_15)(Far_16);
1756+ var middle_30 = Position_17(Mid_15)(Mid_15);
1757+ function middleAt(a1) {
1758+ return function(a2) {
1759+ return["PositionAt", a1, a2]
1760+ }
1761+ }
1762+ var topLeftAt_31 = PositionTL_18;
1763+ var topRightAt_32 = PositionTR_19;
1764+ var bottomLeftAt_33 = PositionBL_20;
1765+ var bottomRightAt_34 = PositionBR_21;
1766+ var absolute_35 = Absolute_12;
1767+ var relative_36 = Relative_13;
1768+ function newElement_38(e,w,h,o,c,l) { return Element_37(Guid.guid(),e,w,h,o,c,l); }
1769+ function basicNewElement(e,w,h) { return Element_37(Guid.guid(),e,w,h,1,["Nothing"],["Nothing"]); }
1770+ var line_76 = Line_75;
1771+ var polygon_79 = Shape_78;
1772+ function sprite_96(src) {
1773+ return function(w) {
1774+ return function(h) {
1775+ return function(pos) {
1776+ return Form_84(0)(1)(pos)(FImage_87(w)(h)(src))
1777+ }
1778+ }
1779+ }
1780+ }
1781+ function toForm_97(pos) {
1782+ return function(e) {
1783+ return Form_84(0)(1)(pos)(FElement_88(e))
1784+ }
1785+ }
1786+ function width_47(w__101) {
1787+ return function(e) {
1788+ var be = e[2];
1789+ switch(be[0]) {
1790+ case "EImage":
1791+ case "EVideo":
1792+ return newElement_38(e[2],w__101,e[4] * w__101 / e[3], e[5], e[6], e[7]);
1793+ case "EText":
1794+ var p = Value.getTextSize(w__101,e[4],be[2]);
1795+ return newElement_38(e[2], w__101, p[1], e[5], e[6], e[7]);
1796+ }
1797+ return newElement_38(e[2], w__101, e[4], e[5], e[6], e[7]);
1798+ }
1799+ }
1800+ function height_48(h__108) {
1801+ return function(e) {
1802+ var be = e[2];
1803+ switch(be[0]) {
1804+ case "EImage":
1805+ case "EVideo":
1806+ return newElement_38(e[2], e[3] * h__108 / e[4], h__108, e[5], e[6], e[7]);
1807+ }
1808+ return newElement_38(e[2], e[3], h__108, e[5], e[6], e[7]);
1809+ }
1810+ }
1811+ function size_49(w) {
1812+ return function(h) {
1813+ return function(e) {
1814+ return newElement_38(e[2], w, h, e[5], e[6], e[7]);
1815+ }
1816+ }
1817+ }
1818+ function opacity_50(o) {
1819+ return function(e) {
1820+ return newElement_38(e[2], e[3], e[4], o, e[6], e[7]);
1821+ }
1822+ }
1823+ function color_51(c) {
1824+ return function(e) {
1825+ return newElement_38(e[2], e[3], e[4], e[5], ["Just",c], e[7]);
1826+ }
1827+ }
1828+ function link(lnk) {
1829+ return function(e) {
1830+ return newElement_38(e[2], e[3], e[4], e[5], e[6], ["Just", JS.castStringToJSString(lnk)]);
1831+ }
1832+ }
1833+ function widthOf_52(e) { return ~~e[3]; }
1834+ function heightOf_53(e) { return ~~e[4]; }
1835+ function sizeOf_54(e) { return["Tuple2", ~~e[3], ~~e[4]] }
1836+ function text_56(txt) {
1837+ var p = Value.getTextSize(0,0,txt);
1838+ return basicNewElement(EText_39("left")(txt), p[0], p[1])
1839+ }
1840+ function plainText(str) {
1841+ var txt = Value.toText(str);
1842+ var p = Value.getTextSize(0,0,txt);
1843+ return basicNewElement(EText_39("left")(txt),p[0],p[1])
1844+ }
1845+ function asText(v) {
1846+ var txt = Elm.Text.monospace(Value.toText(Value.show(v)));
1847+ var p = Value.getTextSize(0,0,txt);
1848+ return basicNewElement(EText_39("left")(txt),p[0],p[1])
1849+ }
1850+ function centeredText(txt) {
1851+ var p = Value.getTextSize(0,0,txt);
1852+ return basicNewElement(EText_39("center")(txt),p[0],p[1])
1853+ }
1854+ function justifiedText(txt) {
1855+ var p = Value.getTextSize(0,0,txt);
1856+ return basicNewElement(EText_39("justify")(txt),p[0],p[1])
1857+ }
1858+ function rightedText(txt) {
1859+ var p = Value.getTextSize(0,0,txt);
1860+ return basicNewElement(EText_39("right")(txt),p[0],p[1])
1861+ }
1862+ function image_57(w) {
1863+ return function(h) {
1864+ return function(src) {
1865+ return basicNewElement(EImage_40(src),w,h)
1866+ }
1867+ }
1868+ }
1869+ function images(srcs) {
1870+ var pics = Elm.Signal.constant(spacer_66(0)(0));
1871+ var update = Elm.Signal.lift(function(src) {
1872+ src = JS.castStringToJSString(src);
1873+ var img = new Image();
1874+ img.onload = function() {
1875+ Dispatcher.notify(pics.id,
1876+ image_57(this.width)(this.height)(src));
1877+ };
1878+ img.src = src;
1879+ })(srcs);
1880+ function f(x) { return function(y) { return x; } }
1881+ var combine = Elm.Signal.lift2(f)(pics)(update);
1882+ return combine;
1883+ }
1884+ function video_58(w) {
1885+ return function(h) {
1886+ return function(src) {
1887+ return basicNewElement(EVideo_41(src),w,h)
1888+ }
1889+ }
1890+ }
1891+ function fittedImage_59(w_147) {
1892+ return function(h_148) {
1893+ return function(s_149) {
1894+ return basicNewElement(EFittedImage_42(s_149),w_147,h_148)
1895+ }
1896+ }
1897+ }
1898+ function flow_60(dir_150) {
1899+ return function(es_151) {
1900+ return function() {
1901+ var w_152 = function() {
1902+ var ws_154 = map(widthOf_52)(es_151);
1903+ return function(case1) {
1904+ var case0 = case1;
1905+ switch(case0[0]) {
1906+ case "DLeft":
1907+ return sum(ws_154);
1908+ case "DRight":
1909+ return sum(ws_154)
1910+ }
1911+ return maximum(ws_154)
1912+ }(dir_150)
1913+ }();
1914+ var h_153 = function() {
1915+ var hs_155 = map(heightOf_53)(es_151);
1916+ return function(case3) {
1917+ var case2 = case3;
1918+ switch(case2[0]) {
1919+ case "DDown":
1920+ return sum(hs_155);
1921+ case "DUp":
1922+ return sum(hs_155)
1923+ }
1924+ return maximum(hs_155)
1925+ }(dir_150)
1926+ }();
1927+ return basicNewElement(EFlow_43(dir_150)(es_151), w_152, h_153)
1928+ }()
1929+ }
1930+ }
1931+ function above_61(e1_156) {
1932+ return function(e2_157) {
1933+ return basicNewElement(EFlow_43(DDown_3)(["Cons", e1_156, ["Cons", e2_157, ["Nil"]]]), Math.max(widthOf_52(e1_156),widthOf_52(e2_157)), heightOf_53(e1_156) + heightOf_53(e2_157));
1934+ }
1935+ }
1936+ function below_62(e1_158) {
1937+ return function(e2_159) {
1938+ return basicNewElement(EFlow_43(DDown_3)(["Cons", e2_159, ["Cons", e1_158, ["Nil"]]]), Math.max(widthOf_52(e1_158),widthOf_52(e2_159)), heightOf_53(e1_158) + heightOf_53(e2_159));
1939+ }
1940+ }
1941+ function beside_63(e1_160) {
1942+ return function(e2_161) {
1943+ return basicNewElement(EFlow_43(DRight_1)(["Cons", e1_160, ["Cons", e2_161, ["Nil"]]]), widthOf_52(e1_160) + widthOf_52(e2_161), Math.max(heightOf_53(e1_160),heightOf_53(e2_161)));
1944+ }
1945+ }
1946+ function layers_64(es_162) {
1947+ return basicNewElement(EFlow_43(DOut_5)(es_162), maximum(map(widthOf_52)(es_162)), maximum(map(heightOf_53)(es_162)))
1948+ }
1949+ function collage_65(w_163) {
1950+ return function(h_164) {
1951+ return function(forms_165) {
1952+ return basicNewElement(ECollage_44(w_163)(h_164)(forms_165),w_163,h_164)
1953+ }
1954+ }
1955+ }
1956+ function spacer_66(w_166) {
1957+ return function(h_167) {
1958+ return basicNewElement(EEmpty_45,w_166,h_167)
1959+ }
1960+ }
1961+ function container_67(w_169) {
1962+ return function(h_170) {
1963+ return function(pos_168) {
1964+ return function(e_171) {
1965+ return basicNewElement(EContainer_46(pos_168)(e_171),w_169,h_170)
1966+ }
1967+ }
1968+ }
1969+ }
1970+ function segment_77(p1_172) {
1971+ return function(p2_173) {
1972+ return Line_75(["Cons", p1_172, ["Cons", p2_173, ["Nil"]]])
1973+ }
1974+ }
1975+ function rect_80(w_174) {
1976+ return function(h_175) {
1977+ return function(pos_176) {
1978+ return Shape_78(["Cons", ["Tuple2", 0 - w_174 / 2, 0 - h_175 / 2],
1979+ ["Cons", ["Tuple2", 0 - w_174 / 2, h_175 / 2],
1980+ ["Cons", ["Tuple2", w_174 / 2, h_175 / 2],
1981+ ["Cons", ["Tuple2", w_174 / 2, 0 - h_175 / 2], ["Nil"]]]]])(pos_176)
1982+ }
1983+ }
1984+ }
1985+ function oval_81(w_177) {
1986+ return function(h_178) {
1987+ return function(pos_179) {
1988+ return function() {
1989+ var n_180 = 50;
1990+ return function() {
1991+ function f_181(i_182) {
1992+ return["Tuple2", w_177 / 2 * Math.cos(2 * (Math.PI / n_180) * i_182), h_178 / 2 * Math.sin(2 * (Math.PI / n_180) * i_182)];
1993+ }
1994+ return Shape_78(map(f_181)(function() {
1995+ var lo = 0;
1996+ var hi = n_180 - 1;
1997+ var lst = ["Nil"];
1998+ if(lo <= hi) {
1999+ do {
2000+ lst = ["Cons", hi, lst]
2001+ }while(hi-- > lo)
2002+ }
2003+ return lst
2004+ }()))(pos_179)
2005+ }()
2006+ }()
2007+ }
2008+ }
2009+ }
2010+ function circle_82(r_183) {
2011+ return oval_81(2 * r_183)(2 * r_183)
2012+ }
2013+ function ngon_83(n_184) {
2014+ return function(r_185) {
2015+ return function(pos_186) {
2016+ return function() {
2017+ var m_187 = n_184;
2018+ return function() {
2019+ function f_188(i_189) {
2020+ return["Tuple2", r_185 * Math.cos(2 * (Math.PI / m_187) * i_189), r_185 * Math.sin(2 * (Math.PI / m_187) * i_189)];
2021+ }
2022+ return Shape_78(map(f_188)(function() {
2023+ var lo = 0;
2024+ var hi = n_184 - 1;
2025+ var lst = ["Nil"];
2026+ if(lo <= hi) {
2027+ do {
2028+ lst = ["Cons", hi, lst]
2029+ }while(hi-- > lo)
2030+ }
2031+ return lst
2032+ }()))(pos_186)
2033+ }()
2034+ }()
2035+ }
2036+ }
2037+ }
2038+ function solid_89(clr_190) {
2039+ return function(ln_191) {
2040+ return Form_84(0)(1)(["Tuple2", 0, 0])(FLine_85(Solid_68)(clr_190)(ln_191))
2041+ }
2042+ }
2043+ function dotted_90(clr_192) {
2044+ return function(ln_193) {
2045+ return Form_84(0)(1)(["Tuple2", 0, 0])(FLine_85(Dotted_69)(clr_192)(ln_193))
2046+ }
2047+ }
2048+ function dashed_91(clr_194) {
2049+ return function(ln_195) {
2050+ return Form_84(0)(1)(["Tuple2", 0, 0])(FLine_85(Dashed_70)(clr_194)(ln_195))
2051+ }
2052+ }
2053+ function customLine_92(pattern_196) {
2054+ return function(clr_197) {
2055+ return function(ln_198) {
2056+ return Form_84(0)(1)(["Tuple2", 0, 0])(FLine_85(Custom_71(pattern_196))(clr_197)(ln_198))
2057+ }
2058+ }
2059+ }
2060+ function filled_93(clr) {
2061+ return function(shape) {
2062+ return Form_84(0)(1)(shape[2])(FShape_86(Filled_72)(clr)(shape));
2063+ }
2064+ }
2065+ function outlined_94(clr) {
2066+ return function(shape) {
2067+ return Form_84(0)(1)(shape[2])(FShape_86(Outlined_73)(clr)(shape));
2068+ }
2069+ }
2070+ function customOutline_95(pattern) {
2071+ return function(clr) {
2072+ return function(shape) {
2073+ return Form_84(0)(1)(shape[2])(FShape_86(CustomOutline_74(pattern))(clr)(shape));
2074+ }
2075+ }
2076+ }
2077+ function textured(src) {
2078+ return function(shape) {
2079+ return Form_84(0)(1)(shape[2])(FShape_86(["Textured",src])(null)(shape));
2080+ }
2081+ }
2082+ function rotate_98(t_212) {
2083+ return function(Form$thetascaleposform_213) {
2084+ return function(case5) {
2085+ var case0 = case5;
2086+ switch(case0[0]) {
2087+ case "Form":
2088+ var case1 = case0[1], case2 = case0[2], case3 = case0[3], case4 = case0[4];
2089+ return Form_84(t_212 + case1)(case2)(case3)(case4)
2090+ }
2091+ throw new Error("Non-exhaustive pattern match in case");
2092+ }(Form$thetascaleposform_213)
2093+ }
2094+ }
2095+ function scale_99(s) {
2096+ return function(form) {
2097+ return Form_84(form[1])(s * form[2])(form[3])(form[4])
2098+ }
2099+ }
2100+ function move_100(x_224) {
2101+ return function(y_225) {
2102+ return function(Form$thetascaleTuple2$pxpyform_226) {
2103+ return function(case7) {
2104+ var case0 = case7;
2105+ switch(case0[0]) {
2106+ case "Form":
2107+ var case1 = case0[1], case2 = case0[2], case3 = case0[3], case4 = case0[4];
2108+ switch(case3[0]) {
2109+ case "Tuple2":
2110+ var case5 = case3[1], case6 = case3[2];
2111+ return Form_84(case1)(case2)(["Tuple2", x_224 + case5, y_225 + case6])(case4)
2112+ }
2113+ break
2114+ }
2115+ throw new Error("Non-exhaustive pattern match in case");
2116+ }(Form$thetascaleTuple2$pxpyform_226)
2117+ }
2118+ }
2119+ }
2120+ return{left:left_6, right:right_7, down:down_8, up:up_9, inward:inward_10, outward:outward_11, topLeft:topLeft_22, topRight:topRight_23, bottomLeft:bottomLeft_24, bottomRight:bottomRight_25, midLeft:midLeft_26, midRight:midRight_27, midTop:midTop_28, midBottom:midBottom_29, middle:middle_30, middleAt:middleAt, topLeftAt:topLeftAt_31, topRightAt:topRightAt_32, bottomLeftAt:bottomLeftAt_33, bottomRightAt:bottomRightAt_34, absolute:absolute_35, relative:relative_36, width:width_47, height:height_48, size:size_49, opacity:opacity_50,
2121+ color:color_51, link:link, widthOf:widthOf_52, heightOf:heightOf_53, sizeOf:sizeOf_54, text:text_56, asText:asText, plainText:plainText, centeredText:centeredText, justifiedText:justifiedText, rightedText:rightedText, image:image_57, images:images, video:video_58, fittedImage:fittedImage_59, flow:flow_60, above:above_61, below:below_62, beside:beside_63, layers:layers_64, collage:collage_65, spacer:spacer_66, container:container_67, line:line_76, segment:segment_77, polygon:polygon_79, rect:rect_80, oval:oval_81, circle:circle_82, ngon:ngon_83, solid:solid_89, dotted:dotted_90, dashed:dashed_91, customLine:customLine_92, filled:filled_93,
2122+ outlined:outlined_94, customOutline:customOutline_95, textured:textured, sprite:sprite_96, toForm:toForm_97, rotate:rotate_98, scale:scale_99, move:move_100,
2123+ isWithin: Collage.insideForm}
2124+}();
2125+Elm.Text = function() {
2126+ function fromString(s) { return Value.toText(s); }
2127+
2128+ var addTag = function(tag) { return function(text) {
2129+ return '<' + tag + ' style="padding:0;margin:0">' + text + '</' + tag + '>';
2130+ };
2131+ };
2132+ var addStyle = function(style, value) { return function(text) {
2133+ return "<span style='" + style + ":" + value + "'>" + text + "</span>";
2134+ };
2135+ };
2136+
2137+ var typeface = function(name) {
2138+ name = Elm.JavaScript.castStringToJSString(name);
2139+ return addStyle('font-family', name);
2140+ };
2141+ var size = function(px) {
2142+ return addStyle('font-size', px + 'px');
2143+ };
2144+ var header = addTag('h1');
2145+ var height = function(h) { return addStyle('font-size', h+'em'); }
2146+ var italic = addStyle('font-style', 'italic');
2147+ var bold = addTag('b');
2148+ var color = function(c) {
2149+ return addStyle('color', Elm.Color.extract(c));
2150+ };
2151+ var underline = addStyle('text-decoration', 'underline');
2152+ var overline = addStyle('text-decoration', 'overline');
2153+ var strikeThrough = addStyle('text-decoration', 'line-through');
2154+ var link = function(href) { return function(text) {
2155+ return "<a href='" + fromString(href) + "'>" + text + "</a>";
2156+ };
2157+ };
2158+
2159+ return {fromString : fromString,
2160+ toText: fromString,
2161+ header : header,
2162+ height : height,
2163+ italic : italic,
2164+ bold : bold,
2165+ underline : underline,
2166+ overline : overline,
2167+ strikeThrough : strikeThrough,
2168+ monospace : typeface('monospace'),
2169+ typeface : typeface,
2170+ color : color,
2171+ link : link };
2172+}();
2173+
2174+var Render = function(){
2175+
2176+function newElement(elementType) {
2177+ var e = document.createElement(elementType);
2178+ e.style.padding = "0";
2179+ e.style.margin = "0";
2180+ return e;
2181+};
2182+
2183+function addTo(container, elem) {
2184+ container.appendChild(elem);
2185+};
2186+
2187+function makeText(pos,txt) {
2188+ var e = newElement('div');
2189+ e.innerHTML = txt;
2190+ e.style.textAlign = pos;
2191+ return e;
2192+};
2193+
2194+function image(src) {
2195+ var img = newElement('img');
2196+ img.src = src;
2197+ img.name = src;
2198+ img.style.display = "block";
2199+ return img;
2200+}
2201+
2202+function fittedImage(w,h,src) {
2203+ var e = newElement('div');
2204+ e.style.width = w + 'px';
2205+ e.style.height = h + 'px';
2206+ e.style.position = "relative";
2207+ e.style.overflow = "hidden";
2208+
2209+ var img = newElement('img');
2210+ img.onload = function() {
2211+ img.style.position = 'absolute';
2212+ img.style.margin = 'auto';
2213+
2214+ var sw = w, sh = h;
2215+ if (w / h > this.width / this.height) {
2216+ sh = Math.round(this.height * w / this.width);
2217+ } else {
2218+ sw = Math.round(this.width * h / this.height);
2219+ }
2220+ img.style.width = sw + 'px';
2221+ img.style.height = sh + 'px';
2222+ img.style.left = ((w - sw) / 2) + 'px';
2223+ img.style.top = ((h - sh) / 2) + 'px';
2224+ };
2225+ img.src = src;
2226+ img.name = src;
2227+ addTo(e,img);
2228+ return e;
2229+};
2230+
2231+var video = function(src) {
2232+ var e = newElement('video');
2233+ e.controls = "controls";
2234+ var source = newElement('source');
2235+ source.src = src;
2236+ var segs = src.split('.');
2237+ source.type = "video/" + segs[segs.length-1];
2238+ addTo(e, source);
2239+ e.style.display = "block";
2240+ return e;
2241+};
2242+
2243+function divify(e) {
2244+ var div = newElement('div');
2245+ addTo(div, e);
2246+ return div;
2247+};
2248+function goDown(e) {
2249+ return e //.tagName === "DIV" ? e : divify(e);
2250+};
2251+function goRight(e) {
2252+ e.style.styleFloat = "left";
2253+ e.style.cssFloat = "left";
2254+ return e;
2255+};
2256+function goIn(e) {
2257+ e.style.position = 'absolute';
2258+ return e;
2259+};
2260+function flowWith(f, prep, elist) {
2261+ var container = newElement('div');
2262+ for (var i = elist.length; i--; ) {
2263+ addTo(container, f(prep(elist[i])));
2264+ }
2265+ return container;
2266+};
2267+
2268+function flow(dir,elist) {
2269+ switch(dir) {
2270+ case "DDown": elist = elist.slice(0).reverse();
2271+ case "DUp": return flowWith(goDown,render,elist);
2272+ case "DRight": elist = elist.slice(0).reverse();
2273+ case "DLeft": return flowWith(goRight,render,elist);
2274+ case "DOut": elist = elist.slice(0).reverse();
2275+ case "DIn": return flowWith(goIn,render,elist);
2276+ };
2277+};
2278+
2279+function toPos(pos) {
2280+ switch(pos[0]) {
2281+ case "Absolute": return pos[1] + "px";
2282+ case "Relative": return (pos[1] * 100) + "%";
2283+ }
2284+}
2285+
2286+function setPos(pos,e) {
2287+ e.style.position = 'absolute';
2288+ e.style.margin = 'auto';
2289+ switch(pos[0]) {
2290+ case "Position":
2291+ if (pos[1][0] !== "Far") e.style.left = 0;
2292+ if (pos[1][0] !== "Near") e.style.right = 0;
2293+ if (pos[2][0] !== "Far") e.style.top = 0;
2294+ if (pos[2][0] !== "Near") e.style.bottom = 0;
2295+ break;
2296+ case "PositionAt":
2297+ e.style.top = toPos(pos[2]);
2298+ e.style.left = toPos(pos[1]);
2299+ var shift = "translate(" + ~~(-e.style.width.slice(0,-2) / 2) + "px," + ~~(-e.style.height.slice(0,-2) / 2) + "px)";
2300+ e.style.transform = shift;
2301+ e.style.msTransform = shift;
2302+ e.style.MozTransform = shift;
2303+ e.style.webkitTransform = shift;
2304+ e.style.OTransform = shift;
2305+ break;
2306+ default:
2307+ var p = pos[0].slice(-2);
2308+ e.style[p[0] === "T" ? 'top' : 'bottom'] = toPos(pos[2]);
2309+ e.style[p[1] === "L" ? 'left' : 'right'] = toPos(pos[1]);
2310+ }
2311+}
2312+
2313+function container(pos,elem) {
2314+ var e = render(elem);
2315+ setPos(pos,e);
2316+ var div = newElement('div');
2317+ div.style.position = "relative";
2318+ div.style.overflow = "hidden";
2319+ addTo(div,e);
2320+ return div;
2321+};
2322+
2323+function render(elem) {
2324+ var e = {};
2325+ switch(elem[2][0]) {
2326+ case "EText": e = makeText(elem[2][1],elem[2][2]); break;
2327+ case "EImage": e = image(elem[2][1]); break;
2328+ case "EVideo": e = video(elem[2][1]); break;
2329+ case "EFittedImage": e = fittedImage(elem[3],elem[4],elem[2][1]); break;
2330+ case "EFlow": e = flow(elem[2][1][0],elem[2][2]); break;
2331+ case "ECollage": e = Collage.collage(elem[2][1],elem[2][2],elem[2][3]); break;
2332+ case "EEmpty": e = newElement('div'); break;
2333+ case "EContainer": e = container(elem[2][1],elem[2][2]); break;
2334+ case "EHtml":
2335+ e = elem[2][1];
2336+ if (e.type !== 'button') {
2337+ var p = Value.getExcess(e);
2338+ elem[3] -= p[0];
2339+ elem[4] -= p[1];
2340+ }
2341+ break;
2342+ case "EExternalHtml":
2343+ e = newElement('div');
2344+ addTo(e, elem[2][1]);
2345+ break;
2346+ }
2347+ e.id = elem[1];
2348+ e.style.width = (~~elem[3]) + 'px';
2349+ e.style.height = (~~elem[4]) + 'px';
2350+ if (elem[5] !== 1) { e.style.opacity = elem[5]; }
2351+ if (elem[6][0] === "Just") {
2352+ e.style.backgroundColor = Elm.Color.extract(elem[6][1]);
2353+ }
2354+ if (elem[7][0] === "Just") {
2355+ var a = newElement('a');
2356+ a.href = elem[7][1];
2357+ addTo(a,e);
2358+ return a;
2359+ }
2360+ return e;
2361+};
2362+
2363+function update(node,curr,next) {
2364+ if (node.tagName === 'A') { node = node.firstChild; }
2365+ if (curr[1] === next[1]) return;
2366+ if (curr[2][0] !== next[2][0]) {
2367+ return node.parentNode.replaceChild(render(next),node);
2368+ }
2369+ var nextE = next[2], currE = curr[2];
2370+ switch(nextE[0]) {
2371+ case "EText":
2372+ if (nextE[1] !== currE[1]) node.style.textAlign = nextE[1];
2373+ if (nextE[2] !== currE[2]) node.innerHTML = nextE[2];
2374+ break;
2375+ case "EImage":
2376+ if (nextE[1] !== currE[1]) node.src = nextE[1];
2377+ break;
2378+ case "EVideo":
2379+ case "EFittedImage":
2380+ if (!Value.eq(nextE,currE) || next[3]!==curr[3] || next[4]!==curr[4]) {
2381+ return node.parentNode.replaceChild(render(next),node);
2382+ }
2383+ break;
2384+ case "ECollage":
2385+ if (nextE[1] !== currE[1] || nextE[2] !== currE[2] || nextE[3].length !== currE[3].length) {
2386+ return node.parentNode.replaceChild(render(next),node);
2387+ }
2388+ Collage.updateCollage(node,currE[3],nextE[3]);
2389+ break;
2390+ case "EFlow":
2391+ if (nextE[1] !== currE[1]) {
2392+ return node.parentNode.replaceChild(render(next),node);
2393+ }
2394+ var nexts = nextE[2];
2395+ var kids = node.childNodes;
2396+ if (nexts.length !== kids.length) {
2397+ return node.parentNode.replaceChild(render(next),node);
2398+ }
2399+ var currs = currE[2];
2400+ var goDir = function(x) { return x; };
2401+ switch(nextE[1][0]) {
2402+ case "DDown": case "DUp": goDir = goDown; break;
2403+ case "DRight": case "DLeft": goDir = goRight; break;
2404+ case "DOut": case "DIn": goDir = goIn; break;
2405+ }
2406+ for (var i = kids.length; i-- ;) {
2407+ update(kids[i],currs[i],nexts[i]);
2408+ goDir(kids[i]);
2409+ }
2410+ break;
2411+ case "EContainer":
2412+ update(node.childNodes[0],currE[2],nextE[2]);
2413+ setPos(nextE[1],node.childNodes[0]);
2414+ break;
2415+ case "EEmpty":
2416+ break;
2417+ case "EHtml":
2418+ if (next[1] !== curr[1]) {
2419+ var e = render(next);
2420+ node.parentNode.replaceChild(e,node);
2421+ node = e;
2422+ }
2423+ if (e.type !== 'button') {
2424+ var p = Value.getExcess(node);
2425+ next[3] -= p[0];
2426+ next[4] -= p[1];
2427+ }
2428+ break;
2429+ case "EExternalHtml":
2430+ if (next[1] !== curr[1])
2431+ node.parentNode.replaceChild(render(next),node);
2432+ break;
2433+ }
2434+ if (next[3] !== curr[3]) node.style.width = (~~next[3]) + 'px';
2435+ if (next[4] !== curr[4]) node.style.height = (~~next[4]) + 'px';
2436+ if (next[5] !== curr[5]) node.style.opacity = next[5];
2437+ if (next[6].length === 2) {
2438+ var clr = Elm.Color.extract(next[6][1]);
2439+ if (clr !== node.style.backgroundColor) node.style.backgroundColor = clr;
2440+ }
2441+ if (next[7].length === 2) {
2442+ if (curr[7].length === 1 || next[7][1] !== curr[7][1]) node.parentNode.href = next[7][1];
2443+ }
2444+ next[1] = curr[1];
2445+}
2446+
2447+return {render:render,update:update,addTo:addTo,newElement:newElement,flowWith:flowWith,goIn:goIn};
2448+
2449+}();
2450+Elm.Signal = function() {
2451+ var send = function(node, timestep, changed) {
2452+ var kids = node.kids;
2453+ for (var i = kids.length; i--; ) {
2454+ kids[i].recv(timestep, changed, node.id);
2455+ }
2456+ };
2457+ function input(base) {
2458+ this.id = Guid.guid();
2459+ this.value = base;
2460+ this.kids = [];
2461+ this.defaultNumberOfKids = 0;
2462+ this.recv = function(timestep, eid, v) {
2463+ var changed = eid === this.id;
2464+ if (changed) { this.value = v; }
2465+ send(this, timestep, changed);
2466+ return changed;
2467+ };
2468+ Dispatcher.inputs.push(this);
2469+ };
2470+ function lift(func,args) {
2471+ this.id = Guid.guid();
2472+ this.value = null;
2473+ this.kids = [];
2474+ this.count = 0;
2475+ this.changed = false;
2476+
2477+ args.reverse();
2478+ this.recalc = function() {
2479+ var f = func;
2480+ for (var i = args.length; i--; ) {
2481+ f = f(args[i].value);
2482+ }
2483+ this.value = f;
2484+ };
2485+ this.recalc();
2486+
2487+ this.recv = function(timestep, changed, parentID) {
2488+ this.count += 1;
2489+ if (changed) { this.changed = true; }
2490+ if (this.count == args.length) {
2491+ if (this.changed) { this.recalc() }
2492+ send(this, timestep, this.changed);
2493+ this.changed = false;
2494+ this.count = 0;
2495+ }
2496+ };
2497+ for (var i = args.length; i--; ) {
2498+ args[i].kids.push(this);
2499+ }
2500+ };
2501+ function fold(func,base,baseIsFunc,input) {
2502+ this.id = Guid.guid();
2503+ this.value = baseIsFunc ? base(input.value) : base;
2504+ this.kids = [];
2505+ this.recv = function(timestep, changed, parentID) {
2506+ if (changed) { this.value = func(input.value)(this.value); }
2507+ send(this, timestep, changed);
2508+ };
2509+ input.kids.push(this);
2510+ };
2511+
2512+ function dropIf(pred,base,input) {
2513+ this.id = Guid.guid();
2514+ this.value = pred(input.value) ? base : input.value;
2515+ this.kids = [];
2516+ this.recv = function(timestep, changed, parentID) {
2517+ var chng = changed && !pred(input.value);
2518+ if (chng) { this.value = input.value; }
2519+ send(this, timestep, chng);
2520+ };
2521+ input.kids.push(this);
2522+ };
2523+
2524+ function dropRepeats(input) {
2525+ this.id = Guid.guid();
2526+ this.value = input.value;
2527+ this.kids = [];
2528+ this.recv = function(timestep, changed, parentID) {
2529+ var chng = changed && !Value.eq(this.value,input.value);
2530+ if (chng) { this.value = input.value; }
2531+ send(this, timestep, chng);
2532+ };
2533+ input.kids.push(this);
2534+ };
2535+
2536+ var dropWhen = function(s1) { return function(b) { return function(s2) {
2537+ var pairs = new lift(function(x){return function(y){return [x,y];};},[s1,s2]);
2538+ var dropped = new dropIf(function(p){return p[0];},[true,b],pairs);
2539+ return new lift(function(p){return p[1];},[dropped]); }; };
2540+ };
2541+
2542+ function timeIndex(pair,s) {
2543+ this.id = Guid.guid();
2544+ var t = (new window.Date).getTime();
2545+ this.value = pair ? Value.Tuple(t,s.value) : t;
2546+ this.kids = [];
2547+ this.recv = function(timestep, changed, parentID) {
2548+ if (changed) this.value = pair ? Value.Tuple(timestep, s.value) : timestep;
2549+ send(this, timestep, changed);
2550+ };
2551+ s.kids.push(this);
2552+ }
2553+
2554+ function sampleOn(s1,s2) {
2555+ this.id = Guid.guid();
2556+ this.value = s2.value;
2557+ this.kids = [];
2558+ this.count = 0;
2559+ this.changed = false;
2560+
2561+ this.recv = function(timestep, changed, parentID) {
2562+ if (parentID === s1.id) this.changed = changed;
2563+ this.count += 1;
2564+ if (this.count == 2) {
2565+ if (this.changed) { this.value = s2.value; }
2566+ send(this, timestep, this.changed);
2567+ this.count = 0;
2568+ this.changed = false;
2569+ }
2570+ };
2571+ s1.kids.push(this);
2572+ s2.kids.push(this);
2573+ };
2574+
2575+ function delay(t) { return function(s) {
2576+ var delayed = new input(s.value);
2577+ var firstEvent = true;
2578+ function update(v) {
2579+ if (firstEvent) return;
2580+ setTimeout(function() { Dispatcher.notify(delayed.id,v); },t);
2581+ }
2582+ function first(a) { return function(b) { return a; }; }
2583+ var out = new sampleOn(delayed,new lift(first, [delayed, new lift(update,[s])]));
2584+ firstEvent = false;
2585+ return out;
2586+ };
2587+ }
2588+
2589+ function merge(s1,s2) {
2590+ this.id = Guid.guid();
2591+ this.value = s1.value;
2592+ this.kids = [];
2593+ this.next = null;
2594+ this.count = 0;
2595+ this.changed = false;
2596+
2597+ this.recv = function(timestep, changed, parentID) {
2598+ this.count += 1;
2599+ if (changed) {
2600+ this.changed = true;
2601+ if (parentID == s2.id && this.next === null) { this.next = s2.value; }
2602+ if (parentID == s1.id) { this.next = s1.value; }
2603+ }
2604+
2605+ if (this.count == 2) {
2606+ if (this.changed) {
2607+ this.value = this.next;
2608+ this.next = null;
2609+ }
2610+ send(this, timestep, this.changed);
2611+ this.changed = false;
2612+ this.count = 0;
2613+ }
2614+ };
2615+ s1.kids.push(this);
2616+ s2.kids.push(this);
2617+ };
2618+
2619+ function merges(ss) {
2620+ function mrg(x) { return function(y) { return new merge(x,y); }; }
2621+ return Elm.List.foldl1(mrg)(ss);
2622+ }
2623+
2624+ function mergeEither(s1) { return function(s2) {
2625+ function f(s) { return function(x) { return [s,x]; }; }
2626+ return new merge(new lift(f('Left'),[s1]), new lift(f('Right'),[s2]));
2627+ };
2628+ }
2629+
2630+ function average(sampleSize) { return function(s) {
2631+ var sample = new Array(sampleSize);
2632+ var i = sampleSize;
2633+ while (i--) sample[i] = 0;
2634+ i = 0;
2635+ var full = false;
2636+ var total = 0;
2637+ function f(n) {
2638+ total += n - sample[i];
2639+ sample[i] = n;
2640+ var avg = total / Math.max(1, full ? sampleSize : i);
2641+ if (++i == sampleSize) { full = true; i = 0; }
2642+ return avg;
2643+ }
2644+ return new lift(f, [s]);
2645+ };
2646+ }
2647+
2648+ return {
2649+ constant : function(v) { return new input(v); },
2650+ lift : function(f){return function(e){return new lift(f,[e]);};},
2651+ lift2 : function(f) {
2652+ return function(e1) { return function(e2) {
2653+ return new lift(f, [e1,e2]); };};},
2654+ lift3 : function(f) {
2655+ return function(e1) { return function(e2) {
2656+ return function(e3){return new lift(f,[e1,e2,e3]);};};};},
2657+ lift4 : function(f) {
2658+ return function(e1) { return function(e2) {
2659+ return function(e3) { return function(e4) {
2660+ return new lift(f, [e1,e2,e3,e4]);};};};};},
2661+ lift5 : function(f) {
2662+ return function(e1) { return function(e2) {
2663+ return function(e3) { return function(e4) {
2664+ return function(e5) {
2665+ return new lift(f, [e1,e2,e3,e4,e5]);};};};};};},
2666+ lift6 : function(f) { return function(e1) { return function(e2) {
2667+ return function(e3) { return function(e4) {
2668+ return function(e5) { return function(e6) {
2669+ return new lift(f, [e1,e2,e3,e4,e5,e6]); };};};};};};},
2670+ lift7 : function(f) { return function(e1) { return function(e2) {
2671+ return function(e3) { return function(e4) {
2672+ return function(e5) { return function(e6) {
2673+ return function(e7) {
2674+ return new lift(f, [e1,e2,e3,e4,e5,e6,e7]);};};};};};};};},
2675+ lift8 : function(f) { return function(e1) { return function(e2) {
2676+ return function(e3) { return function(e4) {
2677+ return function(e5) { return function(e6) {
2678+ return function(e7) { return function(e8) {
2679+ return new lift(f, [e1,e2,e3,e4,e5,e6,e7,e8]);};};};};};};};};},
2680+ foldp : function(f) { return function(b) { return function(e) {
2681+ return new fold(f,b,false,e); }; }; },
2682+ foldp$ : function(f) { return function(b) { return function(e) {
2683+ return new fold(f,b,true,e); }; }; },
2684+ foldp1 : function(f) { return function(e) {
2685+ return new fold(f,function(x){return x;},true,e); }; },
2686+ delay : delay,
2687+ merge : function(s1) { return function(s2) { return new merge(s1,s2)}; },
2688+ merges : merges,
2689+ mergeEither : mergeEither,
2690+ average : average,
2691+ count : function(sig) {
2692+ var incr = function(_){return function(c){return c+1;};};
2693+ return new fold(incr,0,false,sig) },
2694+ countIf : function(pred) { return function(sig) {
2695+ var incr = function(x){return function(c){return pred(x) ? c+1 : c;};};
2696+ return new fold(incr,0,false,sig) }; },
2697+ keepIf : function(pred) { return function(base) { return function(sig) {
2698+ return new dropIf(function(x) { return !pred(x)},base,sig); }; }; },
2699+ dropIf : function(pred) { return function(base) { return function(sig) {
2700+ return new dropIf(pred,base,sig); }; }; },
2701+ keepWhen : function(s) { return dropWhen(new lift(function(b){return !b;},[s])); },
2702+ dropWhen : dropWhen,
2703+ dropRepeats : function(s) { return new dropRepeats(s);},
2704+ sampleOn : function(s1){return function(s2){return new sampleOn(s1,s2);};},
2705+ timestamp : function(s) { return new timeIndex(true, s); },
2706+ timeOf : function(s) { return new timeIndex(false, s); }
2707+ };
2708+}();
2709+var Dispatcher = function() {
2710+ var program = null;
2711+ var inputs = [];
2712+ var currentElement = null;
2713+
2714+ var initialize = function() {
2715+ program = Elm.main();
2716+ if (!('recv' in program)) {
2717+ program = Elm.Signal.constant(program);
2718+ }
2719+
2720+ currentElement = program.value;
2721+ filterDeadInputs();
2722+
2723+ var content = document.getElementById('content');
2724+ content.appendChild(Render.render(currentElement));
2725+ var w = document.getElementById('widthChecker').offsetWidth;
2726+ if (w !== window.innerWidth) {
2727+ Dispatcher.notify(Elm.Window.dimensions.id, Value.Tuple(w, window.innerHeight));
2728+ }
2729+ program = Elm.Signal.lift(function(value) {
2730+ var content = document.getElementById('content');
2731+ Render.update(content.firstChild,currentElement,value);
2732+ currentElement = value;
2733+ return value;
2734+ })(program);
2735+ };
2736+ var notify = function(id, v) {
2737+ var timestep = (new window.Date).getTime();
2738+ var hasListener = false;
2739+ for (var i = inputs.length; i--; ) {
2740+ hasListener = inputs[i].recv(timestep, id, v) || hasListener;
2741+ }
2742+ return hasListener;
2743+ };
2744+
2745+ function isAlive(input) {
2746+ if (!('defaultNumberOfKids' in input)) return true;
2747+ var len = input.kids.length;
2748+ if (len == 0) return false;
2749+ if (len > input.defaultNumberOfKids) return true;
2750+ var alive = false;
2751+ for (var i = len; i--; ) {
2752+ alive = alive || isAlive(input.kids[i]);
2753+ }
2754+ return alive;
2755+ }
2756+ function filterDeadInputs() {
2757+ var temp = [];
2758+ for (var i = inputs.length; i--; ) {
2759+ if (isAlive(inputs[i])) temp.push(inputs[i]);
2760+ }
2761+ inputs = temp;
2762+ }
2763+
2764+ return {initialize:initialize, notify:notify, inputs:inputs};
2765+}();
2766+/*! HTTP
2767+A library for asynchronous HTTP requests (AJAX). See the
2768+[WebSocket](http://elm-lang.org/docs/WebSocket.elm) library if
2769+you have very strict latency requirements.
2770+!*/
2771+
2772+Elm.HTTP = function() {
2773+ var JS = Elm.JavaScript;
2774+ var toElmString = Elm.JavaScript.castJSStringToString;
2775+
2776+ /*[Creating Requests]*/
2777+
2778+ /** get : String -> Request String
2779+ Create a GET request to the given url.
2780+ **/
2781+ function get(url) { return request("GET")(url)(null)(["Nil"]); }
2782+
2783+ /** post : String -> String -> Request String
2784+ Create a POST request to the given url, carrying the given data.
2785+ **/
2786+ function post(url) { return function(data) {
2787+ return request("POST")(url)(data)(["Nil"]); }; }
2788+
2789+ /** request : String -> String -> String -> [(String,String)] -> Request String
2790+ Create a customized request. Arguments are request type (get, post, put,
2791+ delete, etc.), target url, data, and a list of additional headers.
2792+ **/
2793+ function request(verb) { return function(url) { return function(data) {
2794+ return function(headers) {
2795+ return {0 : "Request",
2796+ length : 1,
2797+ verb : JS.castStringToJSString(verb),
2798+ url : JS.castStringToJSString(url),
2799+ data : data === null ? null : JS.castStringToJSString(data),
2800+ headers : headers }; }; }; };
2801+ }
2802+
2803+ function registerReq(queue,responses) { return function(req) {
2804+ if (req.url !== "") { sendReq(queue,responses,req); }
2805+ };
2806+ }
2807+
2808+ function updateQueue(queue,responses) {
2809+ if (queue.length > 0) {
2810+ Dispatcher.notify(responses.id, queue[0].value);
2811+ if (queue[0].value[0] !== "Waiting") {
2812+ queue.shift();
2813+ setTimeout(function() { updateQueue(queue,responses); }, 0);
2814+ }
2815+ }
2816+ }
2817+
2818+ function sendReq(queue,responses,req) {
2819+ var response = { value: ["Waiting"] };
2820+ queue.push(response);
2821+
2822+ var request = null;
2823+ if (window.ActiveXObject) { request = new ActiveXObject("Microsoft.XMLHTTP"); }
2824+ if (window.XMLHttpRequest) { request = new XMLHttpRequest(); }
2825+ request.onreadystatechange = function(e) {
2826+ if (request.readyState === 4) {
2827+ response.value = (request.status === 200
2828+ ? ["Success", toElmString(request.responseText)]
2829+ : ["Failure", request.status,
2830+ toElmString(request.statusText)]);
2831+ setTimeout(function() { updateQueue(queue,responses); }, 0);
2832+ }
2833+ };
2834+ request.open(req.verb, req.url, true);
2835+ Elm.List.map(function(pair) {
2836+ request.setRequestHeader(
2837+ JS.castStringToJSString(pair[1]),
2838+ JS.castStringToJSString(pair[2]));
2839+ })(req.headers);
2840+ request.send(req.data);
2841+ return null;
2842+ }
2843+
2844+ /*[Responses]*/
2845+
2846+ /** data Response a = Waiting | Success a | Failure Int String
2847+ The datatype for responses. Success contains only the returned message.
2848+ Failures contain both an error code and an error message.
2849+ **/
2850+
2851+ /*[Sending Requests]*/
2852+
2853+ /** send : Signal (Request a) -> Signal (Response String)
2854+ Performs an HTTP request with the given requests. Produces a signal
2855+ that carries the responses.
2856+ **/
2857+ function send(requests) {
2858+ var responses = Elm.Signal.constant(["Waiting"]);
2859+ var sender = Elm.Signal.lift(registerReq([],responses))(requests);
2860+ function f(x) { return function(y) { return x; } }
2861+ return Elm.Signal.lift2(f)(responses)(sender);
2862+ }
2863+
2864+ /** sendGet : Signal String -> Signal (Response String)
2865+ Performs an HTTP GET request with the given urls. Produces a signal
2866+ that carries the responses.
2867+ **/
2868+
2869+ return {get : get,
2870+ post : post,
2871+ request : request,
2872+ send : send,
2873+ sendGet : function(urls){return send(Elm.Signal.lift(get)(urls));}
2874+ };
2875+}();
2876+/*! WebSocket
2877+A library for low latency HTTP communication. See the HTTP library for standard
2878+requests like GET, POST, etc.
2879+!*/
2880+
2881+Elm.WebSocket = function() {
2882+ var JS = Elm.JavaScript;
2883+
2884+ /** open : String -> Signal String -> Signal String
2885+ Create a web-socket. The first argument is the URL of the desired
2886+ web-socket server. The input signal holds the outgoing messages,
2887+ and the resulting signal contains the incoming ones.
2888+ **/
2889+ function open(url) { return function(outgoing) {
2890+ var incoming = Elm.Signal.constant(["Nil"]);
2891+ var ws = new window.WebSocket(JS.castStringToJSString(url));
2892+
2893+ var pending = [];
2894+ var ready = false;
2895+
2896+ ws.onopen = function(e) {
2897+ var len = pending.length;
2898+ for (var i = 0; i < len; ++i) { ws.send(pending[i]); }
2899+ ready = true;
2900+ };
2901+ ws.onmessage = function(event) {
2902+ Dispatcher.notify(incoming.id, JS.castJSStringToString(event.data));
2903+ };
2904+
2905+ function send(msg) {
2906+ var s = JS.castStringToJSString(msg);
2907+ ready ? ws.send(s) : pending.push(s);
2908+ }
2909+
2910+ function take1(x) { return function(y) { return x; } }
2911+ return Elm.Signal.lift2(take1)(incoming)(Elm.Signal.lift(send)(outgoing));
2912+ };
2913+ }
2914+
2915+ return {open:open};
2916+}();
2917+
2918+Elm.Input = function() {
2919+ var JS = Elm.JavaScript;
2920+ var toElmString = Elm.JavaScript.castJSStringToString;
2921+ var newTextInput = function(elem, ghostText) {
2922+ elem.placeholder = JS.castStringToJSString(ghostText);
2923+ var str = Elm.Signal.constant(["Nil"]);
2924+ Value.addListener(elem, 'keyup', function(e) {
2925+ Dispatcher.notify(str.id, toElmString(elem.value));
2926+ elem.focus();
2927+ });
2928+ elem.style.padding = "1px";
2929+ return Value.Tuple(Value.wrap(elem), str);
2930+ };
2931+ var newElement = function(name) {
2932+ var e = document.createElement(name);
2933+ e.style.padding = "0";
2934+ e.style.margin = "0";
2935+ return e;
2936+ };
2937+ var textArea = function(cols) { return function(rows) {
2938+ var textarea = newElement('textarea');
2939+ textarea.rows = rows;
2940+ textarea.cols = cols;
2941+ return newTextInput(textarea, "");
2942+ };
2943+ };
2944+ var textField = function(ghostText) {
2945+ var field = newElement('input');
2946+ field.type = 'text';
2947+ return newTextInput(field, ghostText);
2948+ };
2949+ var password = function(ghostText) {
2950+ var field = newElement('input');
2951+ field.type = 'password';
2952+ return newTextInput(field, ghostText);
2953+ };
2954+ var checkbox = function(checked) {
2955+ var box = newElement('input');
2956+ box.type = 'checkbox';
2957+ box.checked = checked;
2958+ var status = Elm.Signal.constant(checked);
2959+ Value.addListener(box, 'change', function(e) {
2960+ Dispatcher.notify(status.id, box.checked);
2961+ });
2962+ return Value.Tuple(Value.wrap(box), status);
2963+ };
2964+ var dropDown = function(options) {
2965+ var slct = newElement('select');
2966+ var opts = [];
2967+ while (options[0] === "Cons") {
2968+ var opt = newElement('option');
2969+ var str = Value.toText(options[1][1]);
2970+ opt.value = str;
2971+ opt.innerHTML = str;
2972+ slct.appendChild(opt);
2973+ opts.push(options[1][2]);
2974+ options = options[2];
2975+ }
2976+ var status = Elm.Signal.constant(opts[0]);
2977+ Value.addListener(slct, 'change', function(e) {
2978+ Dispatcher.notify(status.id, opts[slct.selectedIndex]);
2979+ });
2980+ return Value.Tuple(Value.wrap(slct), status);
2981+ };
2982+ var stringDropDown = function(opts) {
2983+ return dropDown(Elm.List.map (function(x) {return Value.Tuple(x,x);}) (opts));
2984+ };
2985+ var button = function(name) {
2986+ var b = newElement('input');
2987+ b.type = "button";
2988+ b.value = JS.castStringToJSString(name);
2989+ var press = Elm.Signal.constant(false);
2990+ Value.addListener(b, 'click', function(e) {
2991+ Dispatcher.notify(press.id, true);
2992+ Dispatcher.notify(press.id, false);
2993+ });
2994+ return Value.Tuple(Value.wrap(b),press);
2995+ };
2996+ return {textArea:textArea, textField:textField,
2997+ password:password, checkbox:checkbox,
2998+ dropDown:dropDown, stringDropDown:stringDropDown,
2999+ button:button};
3000+}();
3001+
3002+Elm.Keyboard = { Raw : function() {
3003+ var keysDown = Elm.Signal.constant(["Nil"]);
3004+ var charPressed = Elm.Signal.constant(["Nothing"]);
3005+
3006+ function remove(x,xs) {
3007+ if (xs[0] === "Nil") return xs;
3008+ if (xs[1] === x) return xs[2];
3009+ return ["Cons", xs[1], remove(x,xs[2])];
3010+ }
3011+ function has(x,xs) {
3012+ while (xs[0] !== "Nil") {
3013+ if (xs[1] === x) return true;
3014+ xs = xs[2];
3015+ }
3016+ return false;
3017+ }
3018+ Value.addListener(document, 'keydown', function(e) {
3019+ if (has(e.keyCode, keysDown.value)) return;
3020+ var hasListener = Dispatcher.notify(keysDown.id, ["Cons", e.keyCode, keysDown.value]);
3021+ if (!hasListener)
3022+ this.removeEventListener('keydown',arguments.callee,false);
3023+ });
3024+ Value.addListener(document, 'keyup', function(e) {
3025+ var codes = remove(e.keyCode, keysDown.value);
3026+ var hasListener = Dispatcher.notify(keysDown.id, codes);
3027+ if (!hasListener)
3028+ this.removeEventListener('keyup',arguments.callee,false);
3029+ });
3030+ Value.addListener(window, 'blur', function(e) {
3031+ var hasListener = Dispatcher.notify(keysDown.id, ["Nil"]);
3032+ if (!hasListener)
3033+ this.removeEventListener('blur',arguments.callee,false);
3034+ });
3035+ Value.addListener(document, 'keypress', function(e) {
3036+ var hasListener = Dispatcher.notify(charPressed.id, ["Just",e.charCode || e.keyCode]);
3037+ Dispatcher.notify(charPressed.id, ["Nothing"]);
3038+ if (!hasListener)
3039+ this.removeEventListener('keypress',arguments.callee,false);
3040+ });
3041+ return {keysDown:keysDown,
3042+ charPressed:charPressed};
3043+ }()
3044+};
3045+
3046+/*! Keyboard
3047+These are nicely curated inputs from the keyboard. See the
3048+[Keyboard.Raw library](/docs/Signal/KeyboardRaw.elm) for a
3049+lower-level interface that will let you define more complicated behavior.
3050+!*/
3051+
3052+(function() {
3053+ function keySignal(f) {
3054+ var signal = Elm.Signal.lift(f)(Elm.Keyboard.Raw.keysDown);
3055+ Elm.Keyboard.Raw.keysDown.defaultNumberOfKids += 1;
3056+ signal.defaultNumberOfKids = 0;
3057+ return signal;
3058+ }
3059+
3060+ function dir(left,right,up,down) {
3061+ function f(ks) {
3062+ var x = 0, y = 0;
3063+ while (ks[0] == "Cons") {
3064+ switch (ks[1]) {
3065+ case left : --x; break;
3066+ case right: ++x; break;
3067+ case up : ++y; break;
3068+ case down : --y; break;
3069+ }
3070+ ks = ks[2];
3071+ }
3072+ return { _:[true], x:[x], y:[y] };
3073+ }
3074+ return keySignal(f);
3075+ }
3076+
3077+ function is(key) {
3078+ function f(ks) {
3079+ while (ks[0] == "Cons") {
3080+ if (key == ks[1]) return true;
3081+ ks = ks[2];
3082+ }
3083+ return false;
3084+ }
3085+ return keySignal(f);
3086+ }
3087+
3088+ /*[Directions]*/
3089+
3090+ /** arrows : Signal { x:Int, y:Int }
3091+ A signal of records indicating which arrow keys are pressed.
3092+
3093+ `{ x = 0, y = 0 }` when pressing no arrows.
3094+ `{ x =-1, y = 0 }` when pressing the left arrow.
3095+ `{ x = 1, y = 1 }` when pressing the up and right arrows.
3096+ `{ x = 0, y =-1 }` when pressing the down, left, and right arrows.
3097+ **/
3098+ Elm.Keyboard.arrows = dir(37,39,38,40);
3099+
3100+ /** wasd : Signal { x:Int, y:Int }
3101+ Just like the arrows signal, but this uses keys w, a, s, and d,
3102+ which are common controls for many computer games.
3103+ **/
3104+ Elm.Keyboard.wasd = dir(65,68,87,83);
3105+
3106+ /*[Modifiers]*/
3107+
3108+ /** shift : Signal Bool
3109+ Whether the shift key is pressed.
3110+ **/
3111+ Elm.Keyboard.shift = is(16);
3112+
3113+ /** ctrl : Signal Bool
3114+ Whether the control key is pressed.
3115+ **/
3116+ Elm.Keyboard.ctrl = is(17);
3117+
3118+ /** space : Signal Bool
3119+ Whether the space key is pressed.
3120+ **/
3121+ Elm.Keyboard.space = is(32);
3122+
3123+}());
3124+/*! Mouse
3125+ !*/
3126+
3127+Elm.Mouse = function() {
3128+ /*[Position]*/
3129+
3130+ /** position : Signal (Int,Int)
3131+ The current mouse position.
3132+ **/
3133+ var position = Elm.Signal.constant(Value.Tuple(0,0));
3134+ position.defaultNumberOfKids = 2;
3135+
3136+ /** x : Signal Int
3137+ The current x-coordinate of the mouse.
3138+ **/
3139+ var x = Elm.Signal.lift(function(p){return p[1];})(position);
3140+ x.defaultNumberOfKids = 0;
3141+
3142+ /** y : Signal Int
3143+ The current y-coordinate of the mouse.
3144+ **/
3145+ var y = Elm.Signal.lift(function(p){return p[2];})(position);
3146+ y.defaultNumberOfKids = 0;
3147+
3148+ /*[Button Status]*/
3149+
3150+ /** isDown : Signal Bool
3151+ The current state of the left mouse-button.
3152+ True when the button is down, and false otherwise.
3153+ **/
3154+ var isDown = Elm.Signal.constant(false);
3155+
3156+ /** isClicked : Signal Bool
3157+ True immediately after the left mouse-button has been clicked,
3158+ and false otherwise.
3159+ **/
3160+ var isClicked = Elm.Signal.constant(false);
3161+
3162+ /** clicks : Signal ()
3163+ Always equal to unit. Event triggers on every mouse click.
3164+ **/
3165+ var clicks = Elm.Signal.constant(Value.Tuple());
3166+
3167+ function getXY(e) {
3168+ var posx = 0;
3169+ var posy = 0;
3170+ if (!e) e = window.event;
3171+ if (e.pageX || e.pageY) {
3172+ posx = e.pageX;
3173+ posy = e.pageY;
3174+ } else if (e.clientX || e.clientY) {
3175+ posx = e.clientX + document.body.scrollLeft +
3176+ document.documentElement.scrollLeft;
3177+ posy = e.clientY + document.body.scrollTop +
3178+ document.documentElement.scrollTop;
3179+ }
3180+ return Value.Tuple(posx, posy);
3181+ }
3182+
3183+ Value.addListener(document, 'click', function(e) {
3184+ var hasListener1 = Dispatcher.notify(isClicked.id, true);
3185+ var hasListener2 = Dispatcher.notify(clicks.id, Value.Tuple());
3186+ Dispatcher.notify(isClicked.id, false);
3187+ if (!hasListener1 && !hasListener2)
3188+ this.removeEventListener('click',arguments.callee,false);
3189+ });
3190+ Value.addListener(document, 'mousedown', function(e) {
3191+ var hasListener = Dispatcher.notify(isDown.id, true);
3192+ if (!hasListener)
3193+ this.removeEventListener('mousedown',arguments.callee,false);
3194+ });
3195+ Value.addListener(document, 'mouseup', function(e) {
3196+ var hasListener = Dispatcher.notify(isDown.id, false);
3197+ if (!hasListener)
3198+ this.removeEventListener('mouseup',arguments.callee,false);
3199+ });
3200+ Value.addListener(document, 'mousemove', function(e) {
3201+ var hasListener = Dispatcher.notify(position.id, getXY(e));
3202+ if (!hasListener)
3203+ this.removeEventListener('mousemove',arguments.callee,false);
3204+ });
3205+
3206+ /** isClickedOn : Element -> (Element, Signal Bool)
3207+ Determine whether an element has been clicked. The resulting pair
3208+ is a signal of booleans that is true when its paired element has
3209+ been clicked. The signal is True immediately after the left
3210+ mouse-button has been clicked, and false otherwise.
3211+ **/
3212+ var clickedOn = function(elem) {
3213+ var node = Render.render(elem);
3214+ var click = Elm.Signal.constant(false);
3215+ Value.addListener(node, 'click', function(e) {
3216+ Dispatcher.notify(click.id, true);
3217+ Dispatcher.notify(click.id, false);
3218+ });
3219+ return Value.Tuple(Value.wrap(node), click);
3220+ };
3221+ return {position: position,
3222+ x:x,
3223+ y:y,
3224+ isClicked: isClicked,
3225+ isDown: isDown,
3226+ clicks: clicks,
3227+ isClickedOn: clickedOn
3228+ };
3229+ }();/*! Random
3230+ !*/
3231+
3232+Elm.Random = function() {
3233+ /*[In a Range]*/
3234+
3235+ /** inRange : Int -> Int -> Signal Int
3236+ Given a range from low to high, this produces a random number
3237+ between 'low' and 'high' inclusive. The value in the signal does
3238+ not change after the page has loaded.
3239+ **/
3240+ var inRange = function(min) { return function(max) {
3241+ return Elm.Signal.constant(Math.floor(Math.random() * (max-min+1)) + min);
3242+ };
3243+ };
3244+
3245+ /** randomize : Int -> Int -> Signal a -> Signal Int
3246+ Given a range from low to high and a signal of values, this produces
3247+ a new signal that changes whenever the input signal changes. The new
3248+ values are random number between 'low' and 'high' inclusive.
3249+ **/
3250+ var randomize = function(min) { return function(max) { return function(signal) {
3251+ function f(x) { return Math.floor(Math.random() * (max-min+1)) + min; }
3252+ return Elm.Signal.lift(f)(signal);
3253+ };
3254+ };
3255+ };
3256+ return { inRange:inRange, randomize:randomize };
3257+}();/*! Time
3258+Library for working with time. Type `Time` represents some number of
3259+milliseconds.
3260+!*/
3261+
3262+Elm.Time = function() {
3263+
3264+ /*[Times]*/
3265+
3266+ /** hour, minute, second, ms : Time
3267+ Units of time, making it easier to specify things like a
3268+ half-second `(second / 2)`.
3269+ **/
3270+
3271+ function timeNow() { return (new window.Date).getTime(); }
3272+
3273+ /*[Tickers]*/
3274+
3275+ /** fps : Number -> Signal Time
3276+ Takes desired number of frames per second (fps). The resulting signal
3277+ gives a sequence of time deltas as quickly as possible until it reaches
3278+ the desired FPS. A time delta is the time between the last frame and the
3279+ current frame.
3280+ **/
3281+
3282+ /** fpsWhen : Number -> Signal Bool -> Signal Time
3283+ Same as the fps function, but you can turn it on and off. Allows you
3284+ to do brief animations based on user input without major ineffeciencies.
3285+ The first time delta after a pause is always zero, no matter how long
3286+ the pause was. This way summing the deltas will actually give the amount
3287+ of time that the output signal has been running.
3288+ **/
3289+ function fpsWhen(desiredFPS) { return function (isOn) {
3290+ var msPerFrame = 1000 / desiredFPS;
3291+ var prev = timeNow(), curr = prev, diff = 0, wasOn = true;
3292+ var ticker = Elm.Signal.constant(diff);
3293+ function tick(zero) { return function() {
3294+ curr = timeNow();
3295+ diff = zero ? 0 : curr - prev;
3296+ prev = curr;
3297+ Dispatcher.notify(ticker.id, diff);
3298+ };
3299+ }
3300+ var timeoutID = 0;
3301+ function f(isOn) { return function(t) {
3302+ if (isOn) {
3303+ timeoutID = setTimeout(tick(!wasOn && isOn), msPerFrame);
3304+ } else if (wasOn) {
3305+ clearTimeout(timeoutID);
3306+ }
3307+ wasOn = isOn;
3308+ return t;
3309+ };
3310+ }
3311+ return Elm.Signal.lift2(f)(isOn)(ticker);
3312+ };
3313+ }
3314+
3315+ /** every : Time -> Signal Time
3316+ Takes a time interval t. The resulting signal is the current time,
3317+ updated every t.
3318+ **/
3319+ function everyWhen(isOn) { return function(t) {
3320+ var clock = Elm.Signal.constant(timeNow());
3321+ function tellTime() { Dispatcher.notify(clock.id, timeNow()); }
3322+ setInterval(tellTime, t);
3323+ return clock;
3324+ };
3325+ }
3326+
3327+ function since(t) { return function(s) {
3328+ function cmp(a) { return function(b) { return !Value.eq(a,b); }; }
3329+ var dcount = Elm.Signal.count(Elm.Signal.delay(t)(s));
3330+ return Elm.Signal.lift2(cmp)(Elm.Signal.count(s))(dcount);
3331+ };
3332+ }
3333+ function after(t) {
3334+ t *= 1000;
3335+ var thread = Elm.Signal.constant(false);
3336+ setTimeout(function() { Dispatcher.notify(thread.id, true); }, t);
3337+ return thread;
3338+ }
3339+ function before(t) {
3340+ t *= 1000;
3341+ var thread = Elm.Signal.constant(true);
3342+ setTimeout(function() { Dispatcher.notify(thread.id, false); }, t);
3343+ return thread;
3344+ }
3345+ function read(s) {
3346+ var t = window.Date.parse(s);
3347+ return isNaN(t) ? ["Nothing"] : ["Just",t];
3348+ }
3349+ return {fpsWhen : fpsWhen,
3350+ fps : function(t) { return fpsWhen(t)(Elm.Signal.constant(true)); },
3351+ every : everyWhen(Elm.Signal.constant(true)),
3352+ delay : Elm.Signal.delay,
3353+ since : since,
3354+ after : after,
3355+ before : before,
3356+ hour : 3600000,
3357+ minute : 60000,
3358+ second : 1000,
3359+ ms : 1,
3360+ inHours : function(t) { return t / 3600000; },
3361+ inMinutes : function(t) { return t / 60000; },
3362+ inSeconds : function(t) { return t / 1000; },
3363+ inMss : function(t) { return t; },
3364+ toDate : function(t) { return new window.Date(t); },
3365+ read : read
3366+ };
3367+
3368+}();/*! Window !*/
3369+
3370+Elm.Window = function() {
3371+
3372+ /*[Dimensions]*/
3373+
3374+ /** dimensions : Signal (Int,Int)
3375+ The current dimensions of the window (i.e. the area viewable to the
3376+ user, not including scroll bars).
3377+ **/
3378+ var dimensions = Elm.Signal.constant(Value.Tuple(window.innerWidth,
3379+ window.innerHeight));
3380+ dimensions.defaultNumberOfKids = 2;
3381+
3382+ /** width : Signal Int
3383+ The current width of the window.
3384+ **/
3385+ var width = Elm.Signal.lift(function(p){return p[1];})(dimensions);
3386+ width.defaultNumberOfKids = 0;
3387+
3388+ /** height : Signal Int
3389+ The current height of the window.
3390+ **/
3391+ var height = Elm.Signal.lift(function(p){return p[2];})(dimensions);
3392+ height.defaultNumberOfKids = 0;
3393+
3394+ Value.addListener(window, 'resize', function(e) {
3395+ var w = document.getElementById('widthChecker').offsetWidth;
3396+ var hasListener = Dispatcher.notify(dimensions.id,
3397+ Value.Tuple(w, window.innerHeight));
3398+ if (!hasListener)
3399+ this.removeEventListener('resize',arguments.callee,false);
3400+ });
3401+ return {dimensions:dimensions,width:width,height:height};
3402+}();
3403+
3404+Elm.Date = function() {
3405+
3406+ function dateNow() { return new window.Date; }
3407+ function readDate(str) {
3408+ var d = new window.Date(Elm.JavaScript.castStringToJSString(str));
3409+ if (isNaN(d.getTime())) return ["Nothing"];
3410+ return ["Just",d];
3411+ }
3412+
3413+ var dayTable = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
3414+ var monthTable = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
3415+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
3416+
3417+ return {
3418+ read : readDate,
3419+ year : function(d) { return d.getFullYear(); },
3420+ month : function(d) { return [monthTable[d.getMonth()]]; },
3421+ day : function(d) { return d.getDate(); },
3422+ hour : function(d) { return d.getHours(); },
3423+ minute : function(d) { return d.getMinutes(); },
3424+ second : function(d) { return d.getSeconds(); },
3425+ dayOfWeek : function(d) { return [dayTable[d.getDay()]]; },
3426+ toTime : function(d) { return d.getTime(); },
3427+ Mon : ["Mon"], Tue : ["Tue"], Wed : ["Wed"],
3428+ Thu : ["Thu"], Fri : ["Fri"], Sat : ["Sat"], Sun : ["Sun"],
3429+ Jan : ["Jan"], Feb : ["Feb"], Mar : ["Mar"], Apr : ["Apr"],
3430+ May : ["May"], Jun : ["Jun"], Jul : ["Jul"], Aug : ["Aug"],
3431+ Sep : ["Sep"], Oct : ["Oct"], Nov : ["Nov"], Dec : ["Dec"]
3432+ };
3433+
3434+}();
3435+function elmRecordCopy(r) {
3436+ var o = {};
3437+ for (var i in r) { o[i] = r[i]; }
3438+ return o;
3439+}
3440+
3441+function elmRecordRemove(x,r) {
3442+ var o = elmRecordCopy(r);
3443+ if (x in o._) {
3444+ o[x] = o._[x][0];
3445+ o._[x] = o._[x].slice(1);
3446+ if (o._[x].length === 0) { delete o._[x]; }
3447+ } else {
3448+ delete o[x];
3449+ }
3450+ return o;
3451+}
3452+
3453+function elmRecordReplace(kvs,r) {
3454+ var o = elmRecordCopy(r);
3455+ for (var i = kvs.length; i--; ) {
3456+ kvsi = kvs[i];
3457+ o[kvsi[0]] = kvsi[1];
3458+ }
3459+ return o;
3460+}
3461+
3462+function elmRecordInsert(x,v,r) {
3463+ var o = elmRecordCopy(r);
3464+ if (x in o) o._[x] = [o[x]].concat(x in o._ ? o._[x].slice(0) : []);
3465+ o[x] = v;
3466+ return o;
3467+}
3468+
3469+Value.addListener(document, 'elm_log', function(e) { console.log(e.value); });
3470+Value.addListener(document, 'elm_title', function(e) {document.title = e.value;});
3471+Value.addListener(document, 'elm_redirect', function(e) {
3472+ if (e.value.length > 0) { window.location = e.value; }
3473+ });
3474+Value.addListener(document, 'elm_viewport', function(e) {
3475+ var node = document.getElementById('elm_viewport');
3476+ if (!node) {
3477+ node = document.createElement('meta');
3478+ node.id = 'elm_viewport';
3479+ node.name = 'viewport';
3480+ document.head.appendChild(node);
3481+ }
3482+ node.content = e.value;
3483+ Dispatcher.notify(Elm.Window.dimensions.id,
3484+ Value.Tuple(window.innerWidth, window.innerHeight));
3485+ });
3486+
3487+Elm.Prelude = function() {
3488+ var mod = function(x) { return function(y) {
3489+ var r = x % y;
3490+ var m = x==0 ? 0 : (y>0 ? (x>=0 ? r : r+y) : -mod(-x)(-y));
3491+ return m == y ? 0 : m;
3492+ }; };
3493+
3494+ var min = function(x) { return function(y) { return Math.min(x,y); }; };
3495+ var max = function(x) { return function(y) { return Math.max(x,y); }; };
3496+
3497+ var flip=function(f){return function(x){return function(y){return f(y)(x);};};};
3498+ var clamp = function(lo) { return function(hi) {
3499+ return function(x) { return Math.min(hi, Math.max(lo, x)); };
3500+ };
3501+ };
3502+ var curry = function(f) { return function(x) { return function(y) {
3503+ return f(["Tuple2",x,y]); }; };
3504+ };
3505+ var uncurry = function(f) { return function(p) {
3506+ if (p[0] !== "Tuple2") {
3507+ throw new Error("Function was uncurry'd but was not given a pair.");
3508+ }
3509+ return f(p[1])(p[2]); };
3510+ };
3511+
3512+ var logBase=function(b){return function(x){return Math.log(x)/Math.log(b);};};
3513+
3514+ function readInt(str) {
3515+ var s = Elm.JavaScript.castStringToJSString(str);
3516+ var len = s.length;
3517+ if (len === 0) { return ["Nothing"]; }
3518+ var start = 0;
3519+ if (s[0] == '-') {
3520+ if (len === 1) { return ["Nothing"]; }
3521+ start = 1;
3522+ }
3523+ for (var i = start; i < len; ++i) {
3524+ if (!Elm.Char.isDigit(s[i])) { return ["Nothing"]; }
3525+ }
3526+ return ["Just", parseInt(s)];
3527+ }
3528+
3529+ function readFloat(str) {
3530+ var s = Elm.JavaScript.castStringToJSString(str);
3531+ var len = s.length;
3532+ if (len === 0) { return ["Nothing"]; }
3533+ var start = 0;
3534+ if (s[0] == '-') {
3535+ if (len === 1) { return ["Nothing"]; }
3536+ start = 1;
3537+ }
3538+ var dotCount = 0;
3539+ for (var i = start; i < len; ++i) {
3540+ if (Elm.Char.isDigit(s[i])) { continue; }
3541+ if (s[i] === '.') {
3542+ dotCount += 1;
3543+ if (dotCount <= 1) { continue; }
3544+ }
3545+ return ["Nothing"];
3546+ }
3547+ return ["Just", parseFloat(s)];
3548+ }
3549+
3550+ function compare(x) { return function (y) {
3551+ if (x instanceof Array && y instanceof Array) {
3552+ var len = x.length;
3553+ if (len == y.length) {
3554+ for (var i = 1; i < len; ++i) {
3555+ var cmp = compare(x[i])(y[i]);
3556+ if (cmp[0] === 'EQ') continue;
3557+ return cmp;
3558+ }
3559+ return ['EQ'];
3560+ }
3561+ return [ y.length == 1 ? 'GT' : 'LT' ];
3562+ }
3563+ return [ x === y ? 'EQ' : (x < y ? 'LT' : 'GT') ];
3564+ };
3565+ }
3566+ return {eq : Value.eq,
3567+ id : function(x) { return x; },
3568+ not : function(b) { return !b; },
3569+ xor : function(x) { return function(y) { return x != y; }; },
3570+ fst : function(p) { return p[1]; },
3571+ snd : function(p) { return p[2]; },
3572+ rem : function(x) { return function(y) { return x % y; }; },
3573+ div : function(x) { return function(y) { return ~~(x / y); }; },
3574+ otherwise : true,
3575+ compare : compare,
3576+ toFloat : function(x) { return x; },
3577+ round : function(n) { return Math.round(n); },
3578+ floor : function(n) { return Math.floor(n); },
3579+ ceiling : function(n) { return Math.ceil(n); },
3580+ truncate : function(n) { return ~~n; },
3581+ readInt : readInt,
3582+ readFloat : readFloat,
3583+ sqrt : Math.sqrt,
3584+ abs : Math.abs,
3585+ pi : Math.PI,
3586+ e : Math.E,
3587+ sin : Math.sin,
3588+ cos : Math.cos,
3589+ tan : Math.tan,
3590+ asin : Math.asin,
3591+ acos : Math.acos,
3592+ atan : Math.atan,
3593+ atan2 : function(y) { return function(x) { return Math.atan2(y,x); }; },
3594+ mod : mod,
3595+ min : min,
3596+ max : max,
3597+ flip : flip,
3598+ clamp : clamp,
3599+ curry : curry,
3600+ uncurry : uncurry,
3601+ logBase : logBase,
3602+ Just : Elm.Maybe.Just,
3603+ Nothing : Elm.Maybe.Nothing,
3604+ maybe : Elm.Maybe.maybe,
3605+ map : Elm.List.map,
3606+ zip : Elm.List.zip,
3607+ zipWith : Elm.List.zipWith,
3608+ filter : Elm.List.filter,
3609+ head : Elm.List.head,
3610+ tail : Elm.List.tail,
3611+ last : Elm.List.last,
3612+ length : Elm.List.length,
3613+ reverse : Elm.List.reverse,
3614+ foldr : Elm.List.foldr,
3615+ foldr1 : Elm.List.foldr1,
3616+ foldl : Elm.List.foldl,
3617+ foldl1 : Elm.List.foldl1,
3618+ and : Elm.List.and,
3619+ or : Elm.List.or,
3620+ all : Elm.List.all,
3621+ any : Elm.List.any,
3622+ sum : Elm.List.sum,
3623+ product : Elm.List.product,
3624+ concat : Elm.List.concat,
3625+ concatMap : Elm.List.concatMap,
3626+ maximum : Elm.List.maximum,
3627+ minimum : Elm.List.minimum,
3628+ scanl : Elm.List.scanl,
3629+ scanl1 : Elm.List.scanl1,
3630+ take : Elm.List.take,
3631+ drop : Elm.List.drop,
3632+ zip : Elm.List.zip,
3633+ unzip : Elm.List.unzip,
3634+ lift : Elm.Signal.lift,
3635+ lift2 : Elm.Signal.lift2,
3636+ lift3 : Elm.Signal.lift3,
3637+ lift4 : Elm.Signal.lift4,
3638+ lift5 : Elm.Signal.lift5,
3639+ lift6 : Elm.Signal.lift6,
3640+ lift7 : Elm.Signal.lift7,
3641+ lift8 : Elm.Signal.lift8,
3642+ foldp : Elm.Signal.foldp,
3643+ foldp1 : Elm.Signal.foldp1,
3644+ foldp$ : Elm.Signal.foldp$,
3645+ constant : Elm.Signal.constant,
3646+ merge : Elm.Signal.merge,
3647+ merges : Elm.Signal.merges,
3648+ mergeEither : Elm.Signal.mergeEither,
3649+ count : Elm.Signal.count,
3650+ countIf : Elm.Signal.countIf,
3651+ average : Elm.Signal.average,
3652+ keepIf : Elm.Signal.keepIf,
3653+ dropIf : Elm.Signal.dropIf,
3654+ keepWhen : Elm.Signal.keepWhen,
3655+ dropWhen : Elm.Signal.dropWhen,
3656+ dropRepeats : Elm.Signal.dropRepeats,
3657+ sampleOn : Elm.Signal.sampleOn,
3658+ timestamp : Elm.Signal.timestamp,
3659+ timeOf : Elm.Signal.timeOf
3660+ };
3661+
3662+}();
3663+
3664+(function() {
3665+ var include = function(library) {
3666+ for (var i in library) {
3667+ Elm.Prelude[i] = library[i];
3668+ }
3669+ };
3670+ include (Elm.Color);
3671+ include (Elm.Text);
3672+ include (Elm.Graphics);
3673+ include (Elm.Time);
3674+
3675+ show = Value.show;
3676+
3677+}());
3678+/*! Touch
3679+This is an early version of the touch library. It will likely grow to
3680+include gestures that would be useful for both games and web-pages.
3681+!*/
3682+
3683+Elm.Touch = function() {
3684+
3685+ function Dict() {
3686+ this.keys = [];
3687+ this.values = [];
3688+
3689+ this.insert = function(key,value) {
3690+ this.keys.push(key);
3691+ this.values.push(value);
3692+ };
3693+ this.lookup = function(key) {
3694+ var i = this.keys.indexOf(key)
3695+ return i >= 0 ? this.values[i] : {x:0,y:0,t:0};
3696+ };
3697+ this.remove = function(key) {
3698+ var i = this.keys.indexOf(key);
3699+ if (i < 0) return;
3700+ var t = this.values[i];
3701+ this.keys.splice(i,1);
3702+ this.values.splice(i,1);
3703+ return t;
3704+ };
3705+ }
3706+
3707+ var root = Elm.Signal.constant([]),
3708+ tapTime = 500,
3709+ hasTap = false,
3710+ tap = {_:[true],x:[0],y:[0]},
3711+ dict = new Dict();
3712+
3713+ function touch(t) {
3714+ var r = dict.lookup(t.identifier);
3715+ return {_ : [true], id: [t.identifier],
3716+ x: [t.pageX], y: [t.pageY],
3717+ x0: [r.x], y0: [r.y],
3718+ t0: [r.t] };
3719+ }
3720+
3721+ function start(e) {
3722+ dict.insert(e.identifier,{x:e.pageX,y:e.pageY,t:Date.now()});
3723+ }
3724+ function end(e) {
3725+ var t = dict.remove(e.identifier);
3726+ if (Date.now() - t.t < tapTime) {
3727+ hasTap = true;
3728+ tap = {_:[true], x:[t.x], y:[t.y]};
3729+ }
3730+ }
3731+
3732+ function listen(name, f) {
3733+ function update(e) {
3734+ for (var i = e.changedTouches.length; i--; ) { f(e.changedTouches[i]); }
3735+ var ts = new Array(e.touches.length);
3736+ for (var i = e.touches.length; i--; ) { ts[i] = touch(e.touches[i]); }
3737+ var hasListener = Dispatcher.notify(root.id, ts);
3738+ if (!hasListener) return document.removeEventListener(name, update);
3739+ e.preventDefault();
3740+ }
3741+ Value.addListener(document, name, update);
3742+ }
3743+
3744+ listen("touchstart", start);
3745+ listen("touchmove", function(_){});
3746+ listen("touchend", end);
3747+ listen("touchcancel", end);
3748+ listen("touchleave", end);
3749+
3750+ function dependency(f) {
3751+ var sig = Elm.Signal.lift(f)(root);
3752+ root.defaultNumberOfKids += 1;
3753+ sig.defaultNumberOfKids = 0;
3754+ return sig;
3755+ }
3756+
3757+ /*[Touches]*/
3758+
3759+ /** touches : Signal [{ x:Int, y:Int, id:Int, x0:Int, y0:Int, t0:Time }]
3760+ A list of touches. Each ongoing touch is represented by a set of
3761+ coordinates and an identifier id that allows you to distinguish
3762+ between different touches. Each touch also contains the coordinates and
3763+ time of the initial contact (x0, y0, and t0) which helps compute more
3764+ complicated gestures.
3765+ **/
3766+ var touches = dependency(function(ts) {
3767+ return Elm.JavaScript.castJSArrayToList(ts);
3768+ });
3769+
3770+ /*[Gestures]*/
3771+
3772+ /** taps : Signal { x:Int, y:Int }
3773+ The last position that was tapped. Default value is `{x=0,y=0}`.
3774+ Updates whenever the user taps the screen.
3775+ **/
3776+ var taps = function() {
3777+ var sig = dependency(function(_) { return tap; });
3778+ sig.defaultNumberOfKids = 1;
3779+ function pred(_) { var b = hasTap; hasTap = false; return b; }
3780+ var sig2 = Elm.Signal.keepIf(pred)({_:[true],x:[0],y:[0]})(sig);
3781+ sig2.defaultNumberOfKids = 0;
3782+ return sig2;
3783+ }();
3784+
3785+ return { touches: touches, taps: taps };
3786+}();
3787+Elm.Dict=function(){
3788+ var compare = Elm.Prelude.compare;
3789+ var uncurry = Elm.Prelude.uncurry;
3790+ var Nothing = Elm.Prelude.Nothing;
3791+ var Just = Elm.Prelude.Just;
3792+ var not = Elm.Prelude.not;
3793+ var eq = Elm.Prelude.eq;
3794+ var isJust=Elm.Maybe.isJust;
3795+ var Red_0=['Red'];
3796+ var Black_1=['Black'];
3797+ function RBNode_2(a1){
3798+ return function(a2){
3799+ return function(a3){
3800+ return function(a4){
3801+ return function(a5){
3802+ return ['RBNode',a1,a2,a3,a4,a5];};};};};}
3803+ var RBEmpty_3=['RBEmpty'];
3804+ function min_6(t_42){
3805+ return function(){
3806+ switch(t_42[0]){
3807+ case 'RBEmpty':
3808+ throw '(min RBEmpty) is not defined';
3809+ case 'RBNode':
3810+ switch(t_42[4][0]){
3811+ case 'RBEmpty':
3812+ return ['Tuple2',t_42[2],t_42[3]];
3813+ }
3814+ return min_6(t_42[4]);
3815+ }
3816+ throw new Error("Non-exhaustive pattern match in case");}();}
3817+ function lookup_7(k_46){
3818+ return function(t_47){
3819+ return function(){
3820+ switch(t_47[0]){
3821+ case 'RBEmpty':
3822+ return Nothing;
3823+ case 'RBNode':
3824+ return function(){
3825+ var case12=compare(k_46)(t_47[2]);
3826+ switch(case12[0]){
3827+ case 'EQ':
3828+ return Just(t_47[3]);
3829+ case 'GT':
3830+ return lookup_7(k_46)(t_47[5]);
3831+ case 'LT':
3832+ return lookup_7(k_46)(t_47[4]);
3833+ }
3834+ throw new Error("Non-exhaustive pattern match in case");}();
3835+ }
3836+ throw new Error("Non-exhaustive pattern match in case");}();};}
3837+ function findWithDefault_8(base_52){
3838+ return function(k_53){
3839+ return function(t_54){
3840+ return function(){
3841+ switch(t_54[0]){
3842+ case 'RBEmpty':
3843+ return base_52;
3844+ case 'RBNode':
3845+ return function(){
3846+ var case19=compare(k_53)(t_54[2]);
3847+ switch(case19[0]){
3848+ case 'EQ':
3849+ return t_54[3];
3850+ case 'GT':
3851+ return findWithDefault_8(base_52)(k_53)(t_54[5]);
3852+ case 'LT':
3853+ return findWithDefault_8(base_52)(k_53)(t_54[4]);
3854+ }
3855+ throw new Error("Non-exhaustive pattern match in case");}();
3856+ }
3857+ throw new Error("Non-exhaustive pattern match in case");}();};};}
3858+ function member_9(k_59){
3859+ return function(t_60){
3860+ return isJust(lookup_7(k_59)(t_60));};}
3861+ function rotateLeft_10(t_61){
3862+ return function(){
3863+ switch(t_61[0]){
3864+ case 'RBNode':
3865+ switch(t_61[5][0]){
3866+ case 'RBNode':
3867+ return RBNode_2(t_61[1])(t_61[5][2])(t_61[5][3])(RBNode_2(Red_0)(t_61[2])(t_61[3])(t_61[4])(t_61[5][4]))(t_61[5][5]);
3868+ }break;
3869+ }
3870+ throw 'rotateLeft of a node without enough children';}();}
3871+ function rotateRight_11(t_71){
3872+ return function(){
3873+ switch(t_71[0]){
3874+ case 'RBNode':
3875+ switch(t_71[4][0]){
3876+ case 'RBNode':
3877+ return RBNode_2(t_71[1])(t_71[4][2])(t_71[4][3])(t_71[4][4])(RBNode_2(Red_0)(t_71[2])(t_71[3])(t_71[4][5])(t_71[5]));
3878+ }break;
3879+ }
3880+ throw 'rotateRight of a node without enough children';}();}
3881+ function rotateLeftIfNeeded_12(t_81){
3882+ return function(){
3883+ switch(t_81[0]){
3884+ case 'RBNode':
3885+ switch(t_81[5][0]){
3886+ case 'RBNode':
3887+ switch(t_81[5][1][0]){
3888+ case 'Red':
3889+ return rotateLeft_10(t_81);
3890+ }break;
3891+ }break;
3892+ }
3893+ return t_81;}();}
3894+ function rotateRightIfNeeded_13(t_82){
3895+ return function(){
3896+ switch(t_82[0]){
3897+ case 'RBNode':
3898+ switch(t_82[4][0]){
3899+ case 'RBNode':
3900+ switch(t_82[4][1][0]){
3901+ case 'Red':
3902+ switch(t_82[4][4][0]){
3903+ case 'RBNode':
3904+ switch(t_82[4][4][1][0]){
3905+ case 'Red':
3906+ return rotateRight_11(t_82);
3907+ }break;
3908+ }break;
3909+ }break;
3910+ }break;
3911+ }
3912+ return t_82;}();}
3913+ function otherColor_14(c_83){
3914+ return function(){
3915+ switch(c_83[0]){
3916+ case 'Black':
3917+ return Red_0;
3918+ case 'Red':
3919+ return Black_1;
3920+ }
3921+ throw new Error("Non-exhaustive pattern match in case");}();}
3922+ function color_flip_15(t_84){
3923+ return function(){
3924+ switch(t_84[0]){
3925+ case 'RBNode':
3926+ switch(t_84[4][0]){
3927+ case 'RBNode':
3928+ switch(t_84[5][0]){
3929+ case 'RBNode':
3930+ return RBNode_2(otherColor_14(t_84[1]))(t_84[2])(t_84[3])(RBNode_2(otherColor_14(t_84[4][1]))(t_84[4][2])(t_84[4][3])(t_84[4][4])(t_84[4][5]))(RBNode_2(otherColor_14(t_84[5][1]))(t_84[5][2])(t_84[5][3])(t_84[5][4])(t_84[5][5]));
3931+ }break;
3932+ }break;
3933+ }
3934+ throw 'color_flip called on a RBEmpty or RBNode with a RBEmpty child';}();}
3935+ function color_flipIfNeeded_16(t_98){
3936+ return function(){
3937+ switch(t_98[0]){
3938+ case 'RBNode':
3939+ switch(t_98[4][0]){
3940+ case 'RBNode':
3941+ switch(t_98[4][1][0]){
3942+ case 'Red':
3943+ switch(t_98[5][0]){
3944+ case 'RBNode':
3945+ switch(t_98[5][1][0]){
3946+ case 'Red':
3947+ return color_flip_15(t_98);
3948+ }break;
3949+ }break;
3950+ }break;
3951+ }break;
3952+ }
3953+ return t_98;}();}
3954+ function fixUp_17(t_99){
3955+ return color_flipIfNeeded_16(rotateRightIfNeeded_13(rotateLeftIfNeeded_12(t_99)));}
3956+ function ensureBlackRoot_18(t_100){
3957+ return function(){
3958+ switch(t_100[0]){
3959+ case 'RBNode':
3960+ switch(t_100[1][0]){
3961+ case 'Red':
3962+ return RBNode_2(Black_1)(t_100[2])(t_100[3])(t_100[4])(t_100[5]);
3963+ }break;
3964+ }
3965+ return t_100;}();}
3966+ function insert_19(k_105){
3967+ return function(v_106){
3968+ return function(t_107){
3969+ return function(){
3970+ function ins_108(t_109){
3971+ return function(){
3972+ switch(t_109[0]){
3973+ case 'RBEmpty':
3974+ return RBNode_2(Red_0)(k_105)(v_106)(RBEmpty_3)(RBEmpty_3);
3975+ case 'RBNode':
3976+ return function(){
3977+ var h_115=function(){
3978+ var case114=compare(k_105)(t_109[2]);
3979+ switch(case114[0]){
3980+ case 'EQ':
3981+ return RBNode_2(t_109[1])(t_109[2])(v_106)(t_109[4])(t_109[5]);
3982+ case 'GT':
3983+ return RBNode_2(t_109[1])(t_109[2])(t_109[3])(t_109[4])(ins_108(t_109[5]));
3984+ case 'LT':
3985+ return RBNode_2(t_109[1])(t_109[2])(t_109[3])(ins_108(t_109[4]))(t_109[5]);
3986+ }
3987+ throw new Error("Non-exhaustive pattern match in case");}();
3988+ return fixUp_17(h_115);}();
3989+ }
3990+ throw new Error("Non-exhaustive pattern match in case");}();}
3991+ return ensureBlackRoot_18(ins_108(t_107));}();};};}
3992+ function singleton_20(k_116){
3993+ return function(v_117){
3994+ return insert_19(k_116)(v_117)(RBEmpty_3);};}
3995+ function isRed_21(t_118){
3996+ return function(){
3997+ switch(t_118[0]){
3998+ case 'RBNode':
3999+ switch(t_118[1][0]){
4000+ case 'Red':
4001+ return true;
4002+ }break;
4003+ }
4004+ return false;}();}
4005+ function isRedLeft_22(t_119){
4006+ return function(){
4007+ switch(t_119[0]){
4008+ case 'RBNode':
4009+ switch(t_119[4][0]){
4010+ case 'RBNode':
4011+ switch(t_119[4][1][0]){
4012+ case 'Red':
4013+ return true;
4014+ }break;
4015+ }break;
4016+ }
4017+ return false;}();}
4018+ function isRedLeftLeft_23(t_120){
4019+ return function(){
4020+ switch(t_120[0]){
4021+ case 'RBNode':
4022+ switch(t_120[4][0]){
4023+ case 'RBNode':
4024+ switch(t_120[4][4][0]){
4025+ case 'RBNode':
4026+ switch(t_120[4][4][1][0]){
4027+ case 'Red':
4028+ return true;
4029+ }break;
4030+ }break;
4031+ }break;
4032+ }
4033+ return false;}();}
4034+ function isRedRight_24(t_121){
4035+ return function(){
4036+ switch(t_121[0]){
4037+ case 'RBNode':
4038+ switch(t_121[5][0]){
4039+ case 'RBNode':
4040+ switch(t_121[5][1][0]){
4041+ case 'Red':
4042+ return true;
4043+ }break;
4044+ }break;
4045+ }
4046+ return false;}();}
4047+ function isRedRightLeft_25(t_122){
4048+ return function(){
4049+ switch(t_122[0]){
4050+ case 'RBNode':
4051+ switch(t_122[5][0]){
4052+ case 'RBNode':
4053+ switch(t_122[5][4][0]){
4054+ case 'RBNode':
4055+ switch(t_122[5][4][1][0]){
4056+ case 'Red':
4057+ return true;
4058+ }break;
4059+ }break;
4060+ }break;
4061+ }
4062+ return false;}();}
4063+ function moveRedLeft_26(t_123){
4064+ return function(){
4065+ var t__124=color_flip_15(t_123);
4066+ return function(){
4067+ switch(t__124[0]){
4068+ case 'RBNode':
4069+ return function(){
4070+ switch(t__124[5][0]){
4071+ case 'RBNode':
4072+ switch(t__124[5][4][0]){
4073+ case 'RBNode':
4074+ switch(t__124[5][4][1][0]){
4075+ case 'Red':
4076+ return color_flip_15(rotateLeft_10(RBNode_2(t__124[1])(t__124[2])(t__124[3])(t__124[4])(rotateRight_11(t__124[5]))));
4077+ }break;
4078+ }break;
4079+ }
4080+ return t__124;}();
4081+ }
4082+ return t__124;}();}();}
4083+ function moveRedRight_27(t_130){
4084+ return function(){
4085+ var t__131=color_flip_15(t_130);
4086+ return (isRedLeftLeft_23(t__131)?color_flip_15(rotateRight_11(t__131)):t__131);}();}
4087+ function moveRedLeftIfNeeded_28(t_132){
4088+ return ((not(isRedLeft_22(t_132))&&not(isRedLeftLeft_23(t_132)))?moveRedLeft_26(t_132):t_132);}
4089+ function moveRedRightIfNeeded_29(t_133){
4090+ return ((not(isRedRight_24(t_133))&&not(isRedRightLeft_25(t_133)))?moveRedRight_27(t_133):t_133);}
4091+ function deleteMin_30(t_134){
4092+ return function(){
4093+ function del_135(t_136){
4094+ return function(){
4095+ switch(t_136[0]){
4096+ case 'RBNode':
4097+ switch(t_136[4][0]){
4098+ case 'RBEmpty':
4099+ return RBEmpty_3;
4100+ }break;
4101+ }
4102+ return function(){
4103+ var case198=moveRedLeftIfNeeded_28(t_136);
4104+ switch(case198[0]){
4105+ case 'RBEmpty':
4106+ return RBEmpty_3;
4107+ case 'RBNode':
4108+ return fixUp_17(RBNode_2(case198[1])(case198[2])(case198[3])(del_135(case198[4]))(case198[5]));
4109+ }
4110+ throw new Error("Non-exhaustive pattern match in case");}();}();}
4111+ return ensureBlackRoot_18(del_135(t_134));}();}
4112+ function remove_31(k_142){
4113+ return function(t_143){
4114+ return function(){
4115+ function eq_and_noRightNode_144(t_150){
4116+ return function(){
4117+ switch(t_150[0]){
4118+ case 'RBNode':
4119+ switch(t_150[5][0]){
4120+ case 'RBEmpty':
4121+ return eq(k_142,t_150[2]);
4122+ }break;
4123+ }
4124+ return false;}();}
4125+ function eq_145(t_152){
4126+ return function(){
4127+ switch(t_152[0]){
4128+ case 'RBNode':
4129+ return eq(k_142,t_152[2]);
4130+ }
4131+ return false;}();}
4132+ function delLT_146(t_154){
4133+ return function(){
4134+ var case216=moveRedLeftIfNeeded_28(t_154);
4135+ switch(case216[0]){
4136+ case 'RBEmpty':
4137+ throw 'delLT on RBEmpty';
4138+ case 'RBNode':
4139+ return fixUp_17(RBNode_2(case216[1])(case216[2])(case216[3])(del_149(case216[4]))(case216[5]));
4140+ }
4141+ throw new Error("Non-exhaustive pattern match in case");}();}
4142+ function delEQ_147(t_160){
4143+ return function(){
4144+ switch(t_160[0]){
4145+ case 'RBEmpty':
4146+ throw 'delEQ called on a RBEmpty';
4147+ case 'RBNode':
4148+ return function(){
4149+ var Tuple2$k_v__164=min_6(t_160[5]);
4150+ var k__165=function(){
4151+ switch(Tuple2$k_v__164[0]){
4152+ case 'Tuple2':
4153+ return Tuple2$k_v__164[1];
4154+ }
4155+ throw new Error("Non-exhaustive pattern match in case");}();
4156+ var v__166=function(){
4157+ switch(Tuple2$k_v__164[0]){
4158+ case 'Tuple2':
4159+ return Tuple2$k_v__164[2];
4160+ }
4161+ throw new Error("Non-exhaustive pattern match in case");}();
4162+ return fixUp_17(RBNode_2(t_160[1])(k__165)(v__166)(t_160[4])(deleteMin_30(t_160[5])));}();
4163+ }
4164+ throw new Error("Non-exhaustive pattern match in case");}();}
4165+ function delGT_148(t_171){
4166+ return function(){
4167+ switch(t_171[0]){
4168+ case 'RBEmpty':
4169+ throw 'delGT called on a RBEmpty';
4170+ case 'RBNode':
4171+ return fixUp_17(RBNode_2(t_171[1])(t_171[2])(t_171[3])(t_171[4])(del_149(t_171[5])));
4172+ }
4173+ throw new Error("Non-exhaustive pattern match in case");}();}
4174+ function del_149(t_177){
4175+ return function(){
4176+ switch(t_177[0]){
4177+ case 'RBEmpty':
4178+ return RBEmpty_3;
4179+ case 'RBNode':
4180+ return ((compare(k_142)(t_177[2])[0] === 'LT')?delLT_146(t_177):function(){
4181+ var u_179=(isRedLeft_22(t_177)?rotateRight_11(t_177):t_177);
4182+ return (eq_and_noRightNode_144(u_179)?u_179[4]:function(){
4183+ var t__180=moveRedRightIfNeeded_29(t_177);
4184+ return (eq_145(t__180)?delEQ_147(t__180):delGT_148(t__180));}());}());
4185+ }
4186+ throw new Error("Non-exhaustive pattern match in case");}();}
4187+ return (member_9(k_142)(t_143)?ensureBlackRoot_18(del_149(t_143)):t_143);}();};}
4188+ function map_32(f_181){
4189+ return function(t_182){
4190+ return function(){
4191+ switch(t_182[0]){
4192+ case 'RBEmpty':
4193+ return RBEmpty_3;
4194+ case 'RBNode':
4195+ return RBNode_2(t_182[1])(t_182[2])(f_181(t_182[3]))(map_32(f_181)(t_182[4]))(map_32(f_181)(t_182[5]));
4196+ }
4197+ throw new Error("Non-exhaustive pattern match in case");}();};}
4198+ function foldl_33(f_188){
4199+ return function(acc_189){
4200+ return function(t_190){
4201+ return function(){
4202+ switch(t_190[0]){
4203+ case 'RBEmpty':
4204+ return acc_189;
4205+ case 'RBNode':
4206+ return foldl_33(f_188)(f_188(t_190[2])(t_190[3])(foldl_33(f_188)(acc_189)(t_190[4])))(t_190[5]);
4207+ }
4208+ throw new Error("Non-exhaustive pattern match in case");}();};};}
4209+ function foldr_34(f_195){
4210+ return function(acc_196){
4211+ return function(t_197){
4212+ return function(){
4213+ switch(t_197[0]){
4214+ case 'RBEmpty':
4215+ return acc_196;
4216+ case 'RBNode':
4217+ return foldr_34(f_195)(f_195(t_197[2])(t_197[3])(foldr_34(f_195)(acc_196)(t_197[5])))(t_197[4]);
4218+ }
4219+ throw new Error("Non-exhaustive pattern match in case");}();};};}
4220+ function union_35(t1_202){
4221+ return function(t2_203){
4222+ return foldl_33(insert_19)(t2_203)(t1_202);};}
4223+ function intersect_36(t1_204){
4224+ return function(t2_205){
4225+ return foldl_33(function(k_206){
4226+ return function(v_207){
4227+ return function(t_208){
4228+ return (member_9(k_206)(t2_205)?insert_19(k_206)(v_207)(t_208):t_208);};};})(empty_4)(t1_204);};}
4229+ function diff_37(t1_209){
4230+ return function(t2_210){
4231+ return foldl_33(function(k_211){
4232+ return function(v_212){
4233+ return function(t_213){
4234+ return remove_31(k_211)(t_213);};};})(t1_209)(t2_210);};}
4235+ function keys_38(t_214){
4236+ return foldr_34(function(k_215){
4237+ return function(v_216){
4238+ return function(acc_217){
4239+ return ['Cons',k_215,acc_217];};};})(['Nil'])(t_214);}
4240+ function values_39(t_218){
4241+ return foldr_34(function(k_219){
4242+ return function(v_220){
4243+ return function(acc_221){
4244+ return ['Cons',v_220,acc_221];};};})(['Nil'])(t_218);}
4245+ function toList_40(t_222){
4246+ return foldr_34(function(k_223){
4247+ return function(v_224){
4248+ return function(acc_225){
4249+ return ['Cons',['Tuple2',k_223,v_224],acc_225];};};})(['Nil'])(t_222);}
4250+ function fromList_41(assocs_226){
4251+ return Elm.List.foldl(uncurry(insert_19))(empty_4)(assocs_226);}
4252+ var empty_4=RBEmpty_3;
4253+ return {$op : {},
4254+ empty:empty_4,
4255+ lookup:lookup_7,
4256+ findWithDefault:findWithDefault_8,
4257+ member:member_9,
4258+ insert:insert_19,
4259+ singleton:singleton_20,
4260+ remove:remove_31,
4261+ map:map_32,
4262+ foldl:foldl_33,
4263+ foldr:foldr_34,
4264+ union:union_35,
4265+ intersect:intersect_36,
4266+ diff:diff_37,
4267+ keys:keys_38,
4268+ values:values_39,
4269+ toList:toList_40,
4270+ fromList:fromList_41};}();
4271+
4272+Elm.Set=function(){
4273+ var empty_0=Elm.Dict.empty;
4274+ var remove_3=Elm.Dict.remove;
4275+ var member_4=Elm.Dict.member;
4276+ var union_5=Elm.Dict.union;
4277+ var intersect_6=Elm.Dict.intersect;
4278+ var diff_7=Elm.Dict.diff;
4279+ var toList_8=Elm.Dict.keys;
4280+ var fromList_9=Elm.List.foldl(function(k_15){
4281+ return function(t_16){
4282+ return Elm.Dict.insert(k_15)(["Tuple0"])(t_16);};})(empty_0);
4283+ function singleton_1(k_13){
4284+ return Elm.Dict.singleton(k_13)(["Tuple0"]);};
4285+ function insert_2(k_14){
4286+ return Elm.Dict.insert(k_14)(["Tuple0"]);};
4287+ function foldl_10(f_17){
4288+ return Elm.Dict.foldl(function(k_18){
4289+ return function(v_19){
4290+ return function(b_20){
4291+ return f_17(k_18)(b_20);};};});};
4292+ function foldr_11(f_21){
4293+ return Elm.Dict.foldr(function(k_22){
4294+ return function(v_23){
4295+ return function(b_24){
4296+ return f_21(k_22)(b_24);};};});};
4297+ function map_12(f_25){
4298+ return function(t_26){
4299+ return function(x){
4300+ return fromList_9(Elm.List.map(f_25)(x));}(toList_8(t_26));};};
4301+ return {empty:empty_0,singleton:singleton_1,insert:insert_2,remove:remove_3,member:member_4,union:union_5,intersect:intersect_6,diff:diff_7,toList:toList_8,fromList:fromList_9,foldl:foldl_10,foldr:foldr_11,map:map_12};}();
4302+
4303+(function() {
4304+try{
4305+
4306+var $op={};
4307+for(this['i'] in Elm){eval('var '+this['i']+'=Elm[this.i];');}
4308+if (Elm.Automaton) throw new Error("Module name collision, 'Automaton' is already defined.");
4309+Elm.Automaton=function(){
4310+ try{
4311+ if (!(Elm.Prelude instanceof Object)) throw 'module not found';
4312+ } catch(e) {
4313+ throw ("Module 'Prelude' is missing. Compile with --make flag or load missing module in a separate JavaScript file.");
4314+ }
4315+ var hiddenVars={};
4316+ for (this['i'] in Elm.Prelude) {
4317+ if (hiddenVars[this['i']]) continue;
4318+ eval('var ' + this['i'] + ' = Elm.Prelude[this.i];');}
4319+ function Automaton_0(a1){
4320+ return ["Automaton",a1];}
4321+ var Listen_8=["Listen"];
4322+ var Ignore_9=["Ignore"];
4323+ function DragFrom_10(a1){
4324+ return ["DragFrom",a1];}
4325+ $op['>>>'] = function(a1_24){
4326+ return function(a2_25){
4327+ return function(){
4328+ var Automaton$m1_26=a1_24;
4329+ var m1_27=function(){
4330+ switch(Automaton$m1_26[0]){
4331+ case "Automaton":
4332+ return Automaton$m1_26[1];
4333+ }
4334+ throw new Error("Non-exhaustive pattern match in case");}();
4335+ var Automaton$m2_28=a2_25;
4336+ var m2_29=function(){
4337+ switch(Automaton$m2_28[0]){
4338+ case "Automaton":
4339+ return Automaton$m2_28[1];
4340+ }
4341+ throw new Error("Non-exhaustive pattern match in case");}();
4342+ return Automaton_0(function(a_32){
4343+ return function(){
4344+ var Tuple2$bm1__33=m1_27(a_32);
4345+ var b_34=function(){
4346+ switch(Tuple2$bm1__33[0]){
4347+ case "Tuple2":
4348+ return Tuple2$bm1__33[1];
4349+ }
4350+ throw new Error("Non-exhaustive pattern match in case");}();
4351+ var m1__35=function(){
4352+ switch(Tuple2$bm1__33[0]){
4353+ case "Tuple2":
4354+ return Tuple2$bm1__33[2];
4355+ }
4356+ throw new Error("Non-exhaustive pattern match in case");}();
4357+ return function(){
4358+ var Tuple2$cm2__40=m2_29(b_34);
4359+ var c_41=function(){
4360+ switch(Tuple2$cm2__40[0]){
4361+ case "Tuple2":
4362+ return Tuple2$cm2__40[1];
4363+ }
4364+ throw new Error("Non-exhaustive pattern match in case");}();
4365+ var m2__42=function(){
4366+ switch(Tuple2$cm2__40[0]){
4367+ case "Tuple2":
4368+ return Tuple2$cm2__40[2];
4369+ }
4370+ throw new Error("Non-exhaustive pattern match in case");}();
4371+ return ["Tuple2",c_41,$op['>>>'](m1__35)(m2__42)];}();}();});}();};};
4372+ $op['<<<'] = function(a2_47){
4373+ return function(a1_48){
4374+ return $op['>>>'](a1_48)(a2_47);};};
4375+ $op['^>>'] = function(f_49){
4376+ return function(a_50){
4377+ return $op['>>>'](pure_4(f_49))(a_50);};};
4378+ $op['>>^'] = function(a_51){
4379+ return function(f_52){
4380+ return $op['>>>'](a_51)(pure_4(f_52));};};
4381+ $op['^<<'] = function(f_53){
4382+ return function(a_54){
4383+ return $op['>>>'](a_54)(pure_4(f_53));};};
4384+ $op['<<^'] = function(a_55){
4385+ return function(f_56){
4386+ return $op['>>>'](pure_4(f_56))(a_55);};};
4387+ var count_7=init_5(0)(function(__84){
4388+ return function(c_85){
4389+ return (1+c_85);};});
4390+ function run_1(Automaton$m0_14){
4391+ return function(input_15){
4392+ return function(){
4393+ switch(Automaton$m0_14[0]){
4394+ case "Automaton":
4395+ return lift(fst)(foldp$(function(a_17){
4396+ return function(Tuple2$bAutomaton$m_18){
4397+ return function(){
4398+ switch(Tuple2$bAutomaton$m_18[0]){
4399+ case "Tuple2":
4400+ switch(Tuple2$bAutomaton$m_18[2][0]){
4401+ case "Automaton":
4402+ return Tuple2$bAutomaton$m_18[2][1](a_17);
4403+ }break;
4404+ }
4405+ throw new Error("Non-exhaustive pattern match in case");}();};})(Automaton$m0_14[1])(input_15));
4406+ }
4407+ throw new Error("Non-exhaustive pattern match in case");}();};}
4408+ function step_2(Automaton$m_21){
4409+ return function(a_22){
4410+ return function(){
4411+ switch(Automaton$m_21[0]){
4412+ case "Automaton":
4413+ return Automaton$m_21[1](a_22);
4414+ }
4415+ throw new Error("Non-exhaustive pattern match in case");}();};}
4416+ function combine_3(autos_57){
4417+ return Automaton_0(function(a_58){
4418+ return function(){
4419+ var Tuple2$bsautos__59=unzip(map(function(Automaton$m_62){
4420+ return function(){
4421+ switch(Automaton$m_62[0]){
4422+ case "Automaton":
4423+ return Automaton$m_62[1](a_58);
4424+ }
4425+ throw new Error("Non-exhaustive pattern match in case");}();})(autos_57));
4426+ var bs_60=function(){
4427+ switch(Tuple2$bsautos__59[0]){
4428+ case "Tuple2":
4429+ return Tuple2$bsautos__59[1];
4430+ }
4431+ throw new Error("Non-exhaustive pattern match in case");}();
4432+ var autos__61=function(){
4433+ switch(Tuple2$bsautos__59[0]){
4434+ case "Tuple2":
4435+ return Tuple2$bsautos__59[2];
4436+ }
4437+ throw new Error("Non-exhaustive pattern match in case");}();
4438+ return ["Tuple2",bs_60,combine_3(autos__61)];}();});}
4439+ function pure_4(f_68){
4440+ return Automaton_0(function(x_69){
4441+ return ["Tuple2",f_68(x_69),pure_4(f_68)];});}
4442+ function init_5(s_70){
4443+ return function(step_71){
4444+ return Automaton_0(function(a_72){
4445+ return function(){
4446+ var s__73=step_71(a_72)(s_70);
4447+ return ["Tuple2",s__73,init_5(s__73)(step_71)];}();});};}
4448+ function init__6(s_74){
4449+ return function(step_75){
4450+ return Automaton_0(function(a_76){
4451+ return function(){
4452+ var Tuple2$bs__77=step_75(a_76)(s_74);
4453+ var b_78=function(){
4454+ switch(Tuple2$bs__77[0]){
4455+ case "Tuple2":
4456+ return Tuple2$bs__77[1];
4457+ }
4458+ throw new Error("Non-exhaustive pattern match in case");}();
4459+ var s__79=function(){
4460+ switch(Tuple2$bs__77[0]){
4461+ case "Tuple2":
4462+ return Tuple2$bs__77[2];
4463+ }
4464+ throw new Error("Non-exhaustive pattern match in case");}();
4465+ return ["Tuple2",b_78,init__6(s__79)(step_75)];}();});};}
4466+ function vecSub_11(Tuple2$x1y1_86){
4467+ return function(Tuple2$x2y2_87){
4468+ return function(){
4469+ switch(Tuple2$x1y1_86[0]){
4470+ case "Tuple2":
4471+ return function(){
4472+ switch(Tuple2$x2y2_87[0]){
4473+ case "Tuple2":
4474+ return ["Tuple2",(Tuple2$x1y1_86[1]-Tuple2$x2y2_87[1]),(Tuple2$x1y1_86[2]-Tuple2$x2y2_87[2])];
4475+ }
4476+ throw new Error("Non-exhaustive pattern match in case");}();
4477+ }
4478+ throw new Error("Non-exhaustive pattern match in case");}();};}
4479+ function stepDrag_12(Tuple2$presspos_92){
4480+ return function(Tuple2$dsform_93){
4481+ return function(){
4482+ switch(Tuple2$presspos_92[0]){
4483+ case "Tuple2":
4484+ return function(){
4485+ switch(Tuple2$dsform_93[0]){
4486+ case "Tuple2":
4487+ return function(){
4488+ function wrap_98(ds__99){
4489+ return ["Tuple2",Tuple2$dsform_93[2],["Tuple2",ds__99,Tuple2$dsform_93[2]]];}
4490+ return function(){
4491+ switch(Tuple2$dsform_93[1][0]){
4492+ case "DragFrom":
4493+ return (Tuple2$presspos_92[1]?["Tuple2",uncurry(move)(vecSub_11(Tuple2$presspos_92[2])(Tuple2$dsform_93[1][1]))(Tuple2$dsform_93[2]),["Tuple2",DragFrom_10(Tuple2$dsform_93[1][1]),Tuple2$dsform_93[2]]]:function(){
4494+ var form__101=uncurry(move)(vecSub_11(Tuple2$presspos_92[2])(Tuple2$dsform_93[1][1]))(Tuple2$dsform_93[2]);
4495+ return ["Tuple2",form__101,["Tuple2",Listen_8,form__101]];}());
4496+ case "Ignore":
4497+ return wrap_98((Tuple2$presspos_92[1]?Ignore_9:Listen_8));
4498+ case "Listen":
4499+ return wrap_98((not(Tuple2$presspos_92[1])?Listen_8:(isWithin(Tuple2$presspos_92[2])(Tuple2$dsform_93[2])?DragFrom_10(Tuple2$presspos_92[2]):Ignore_9)));
4500+ }
4501+ throw new Error("Non-exhaustive pattern match in case");}();}();
4502+ }
4503+ throw new Error("Non-exhaustive pattern match in case");}();
4504+ }
4505+ throw new Error("Non-exhaustive pattern match in case");}();};}
4506+ function draggable_13(form_102){
4507+ return init__6(["Tuple2",Listen_8,form_102])(stepDrag_12);}
4508+ return {$op : {'>>>' : $op['>>>'], '<<<' : $op['<<<'], '^>>' : $op['^>>'], '>>^' : $op['>>^'], '^<<' : $op['^<<'], '<<^' : $op['<<^']},
4509+ run:run_1,
4510+ step:step_2,
4511+ combine:combine_3,
4512+ pure:pure_4,
4513+ init:init_5,
4514+ init$:init__6,
4515+ count:count_7,
4516+ draggable:draggable_13};}();
4517+Elm.main=function(){
4518+ return Elm.Automaton.main;};
4519+} catch (e) {
4520+Elm.main=function() {
4521+var msg = ('<br/><h2>Your browser may not be supported. Are you using a modern browser?</h2>' + '<br/><span style="color:grey">Runtime Error in Automaton module:<br/>' + e + '</span>');
4522+document.body.innerHTML = Elm.Text.monospace(msg);throw e;};}}());