elm/elm-mini.js

47 lines
No EOL
23 KiB
JavaScript

var Guid=function(){var b=0;return{guid:function(){return b+=1}}}(),Value=function(){var b=function(a){if("boolean"===typeof a)return a?"True":"False";if("number"!==typeof a&&a[0]){if("Tuple"===a[0].substring(0,5)){for(var d="",e=a.length;--e;)d=","+b(a[e])+d;","===d[0]&&(d=d.substring(1));return"("+d+")"}if("Cons"===a[0])for(var e="string"===typeof a[1]?'"':"]",c="string"===typeof a[1]?"":",",d=("string"===typeof a[1]?'"':"[")+b(a[1]),a=a[2];;)if("Cons"===a[0])d+=c+b(a[1]),a=a[2];else return d+e;
else{if("Nil"===a[0])return"[]";d="";for(e=a.length;--e;)d=" "+b(a[e])+d;d=a[0]+d;return 1<a.length?"("+d+")":d}}return a+""};return{show:function(a){return Text.monospace(String.properEscape(b(a)))},Tuple:function(){var a=arguments.length,b=Array(a+1);for(b[0]="Tuple"+arguments.length;a--;)b[a+1]=arguments[a];return b},append:function(a,b){if("string"===typeof a&&"string"===typeof b)return a.concat(b);if("Nil"===a[0])return b;for(var e=["Cons",a[1],["Nil"]],c=e,a=a[2];"Cons"===a[0];)c[2]=["Cons",
a[1],["Nil"]],a=a[2],c=c[2];c[2]=b;return e}}}(),String=function(){return{toText:function(b){if("string"===typeof b)return b;for(var a=[];"Cons"===b[0];)a.push(b[1]),b=b[2];return String.properEscape(a.join(""))},properEscape:function(b){b.replace('"',"&#34;");b.replace("&","&#38;");b.replace("'","&#39;");b.replace("<","&#60;");b.replace(">","&#62;");return b}}}(),Color=function(){var b=function(a,b,e,c){return{r:Math.round(255*a),g:Math.round(255*b),b:Math.round(255*e),a:c}};return{black:b(0,0,0,
1),white:b(1,1,1,1),red:b(1,0,0,1),green:b(0,1,0,1),blue:b(0,0,1,1),rgba:function(a){return function(d){return function(e){return function(c){return b(a,d,e,c)}}}},rgb:function(a){return function(d){return function(e){return b(a,d,e,1)}}},Internal:{extract:function(a){return 1===a.a?"rgb("+a.r+","+a.g+","+a.b+")":"rgba("+a.r+","+a.g+","+a.b+","+a.a+")"}}}}(),Element=function(){var b=function(a){a=document.createElement(a);a.id=Guid.guid();return a},a=function(a){var i=b("div");i.appendChild(a);return i},
d=function(a){return function(i){return function(d){var c=b("div");c.isElmText=!0;c.innerHTML=d;c.style.textAlign=i;0<a&&(c.style.width=a+"px");c.isElmLeaf=!0;c.style.visibility="hidden";c.style.styleFloat="left";c.style.cssFloat="left";document.body.appendChild(c);d=window.getComputedStyle(c);0>=a&&(c.style.width=d.getPropertyValue("width"));c.style.height=d.getPropertyValue("height");document.body.removeChild(c);c.style.visibility="visible";c.style.styleFloat="none";c.style.cssFloat="none";return c}}},
e=d(0)("left"),c=d(0)("justify"),f=d(0)("center"),h=function(n){return"DIV"===n.tagName?n:a(n)},k=function(a){a.style.styleFloat="left";a.style.cssFloat="left";return a},g=function(a){a.style.position="absolute";return a},j=function(a,i,c){for(var d=b("div"),e=c.length;e--;){var g=i(c[e]);d.appendChild(g)}d.elmFlowDirection=a;return d},m=function(a){return function(i){for(var b=[];"Cons"===i[0];)b.push(i[1]),i=i[2];3<=a&&b.reverse();i=a%3;if(0==i)return j("Y",h,b);if(1==i)return j("X",k,b);if(2==
i)return j("Z",g,b)}},l=function(a){return function(b){if("A"===b.tagName)return l(a)(b.firstChild),b;if(b.hasOwnProperty("isElmText")){var c=d(a)(b.style.textAlign)(b.innerHTML);b.style.height=c.style.height}b.style.width=a+"px";return b}};return{text:e,image:function(a){var c=b("img");c.isElmLeaf=!0;c.onload=function(){""===c.style.width&&0<this.width&&(c.style.width=c.width=this.width+"px");""===c.style.height&&0<this.height&&(c.style.height=c.height=this.height+"px");Dispatcher.adjust()};c.src=
String.toText(a);c.name=c.src;return c},fittedImage:function(a){return function(c){return function(d){var e=b("canvas");e.style.width=a+"px";e.style.height=c+"px";e.width=a;e.height=c;e.innerHTML="Your browser does not support the canvas element.";e.isElmLeaf=!0;var g=b("img");g.onload=function(){if(e.getContext){var b=e.getContext("2d"),d=0,q=0,f=this.width,j=this.height;a/c>this.width/this.height?(j=this.width*c/a,q=(this.height-j)/2):(f=this.height*a/c,d=(this.width-f)/2);b.drawImage(g,d,q,f,j,
0,0,e.width,e.height)}};g.src=String.toText(d);return e}}},video:function(a){var a=String.toText(a),c=b("video");c.controls="controls";var d=b("source");d.src=a;d.type="video/"+a.substring(a.length-3,a.length);c.appendChild(d);c.isElmLeaf=!0;return c},audio:function(a){var a=String.toString(a),c=b("video");c.controls="controls";var d=b("source");d.src=a;d.type="audio/"+a.substring(a.length-3,a.length);c.appendChild(d);c.isElmLeaf=!0;return c},collage:function(a){return function(c){return function(d){var e=
b("canvas");e.style.width=a+"px";e.style.height=c+"px";e.width=a;e.height=c;if(e.getContext){var g=e.getContext("2d");for(g.clearRect(0,0,e.width,e.height);"Cons"===d[0];)g=d[1](g),d=d[2];return e}e.innerHTML="Your browser does not support the canvas element.";e.isElmLeaf=!0;return e}}},flow:m,layers:m(2),beside:function(a){return function(c){return m(4)(["Cons",a,["Cons",c,["Nil"]]])}},above:function(a){return function(c){return m(3)(["Cons",a,["Cons",c,["Nil"]]])}},below:function(a){return function(c){return m(0)(["Cons",
a,["Cons",c,["Nil"]]])}},box:function(a){return function(c){c.style.position="absolute";c.style.margin="auto";var d=(a-1)%3,e=(a-1)/3;2>d&&(c.style.left=0);0<d&&(c.style.right=0);2>e&&(c.style.top=0);0<e&&(c.style.bottom=0);d=b("div");d.style.position="relative";d.appendChild(c);return d}},width:l,height:function(a){return function(c){("A"===c.tagName?c.firstChild:c).style.height=a+"px";return c}},size:function(a){return function(c){return function(b){var d="A"===b.tagName?b.firstChild:b;d.style.width=
a+"px";d.style.height=c+"px";return b}}},color:function(a){return function(c){c.style.backgroundColor=Color.Internal.extract(a);return c}},opacity:function(a){return function(c){c.style.opacity=a;return c}},link:function(c){return function(d){var e=b("a");e.href=Text.fromString(c);e.appendChild(d);return a(e)}},asText:function(a){return d(0)("left")(Value.show(a))},plainText:function(a){return d(0)("left")(String.toText(a))},justifiedText:c,centeredText:f,up:0,left:1,inward:2,down:3,right:4,outward:5}}(),
Text=function(){var b=function(a){if("string"===typeof a)return a;for(var c=[];"Cons"===a[0];)c.push(a[1]),a=a[2];return String.properEscape(c.join(""))},a=function(a){return function(c){return"<"+a+">"+c+"</"+a+">"}},d=function(a,c){return function(b){return"<span style='"+a+":"+c+"'>"+b+"</span>"}},e=a("h1"),c=d("font-style","italic"),a=a("b"),f=d("text-decoration","underline"),h=d("text-decoration","overline"),k=d("text-decoration","line-through");return{fromString:b,toText:b,header:e,height:function(a){return d("font-size",
a+"em")},italic:c,bold:a,underline:f,overline:h,strikeThrough:k,monospace:d("font-family","monospace"),color:function(a){return d("color",Color.Internal.extract(a))},link:function(a){return function(c){return"<a href='"+b(a)+"'>"+c+"</a>"}}}}(),Shape=function(){var b=function(a,b,c,f){return{center:a,points:b,theta:c,scale:f}},a=function(a){return function(b){return function(c){return function(f){f.save();f.translate(c.center[0],c.center[1]);f.rotate(c.theta);f.scale(c.scale,c.scale);f.beginPath();
var h=c.points;f.moveTo(h[0][0],h[0][1]);for(var k=h.length;k--;)f.lineTo(h[k][0],h[k][1]);f.closePath();a?(f.fillStyle=Color.Internal.extract(b),f.fill()):(f.strokeStyle=Color.Internal.extract(b),f.stroke());f.restore();return f}}}};return{polygon:function(a){return function(e){for(var c=[];"Cons"===a[0];)c.push([a[1][1],a[1][2]]),a=a[2];e=[e[1],e[2]];return b(e,c,0,1)}},ngon:function(a){return function(e){return function(c){for(var f=[],h=a;h--;)f.push([e*Math.cos(2*Math.PI*h/a),e*Math.sin(2*Math.PI*
h/a)]);c=[c[1],c[2]];return b(c,f,0,1)}}},rect:function(a){return function(e){return function(c){var f=[[-a/2,-e/2],[a/2,-e/2],[a/2,e/2],[-a/2,e/2]],c=[c[1],c[2]];return b(c,f,0,1)}}},oval:function(a){return function(e){return function(c){for(var f=[],h=2*Math.PI;0<h;h-=Math.PI/50)f.push([a/2*Math.cos(h),e/2*Math.sin(h)]);c=[c[1],c[2]];return b(c,f,0,1)}}},move:function(a){return function(e){return function(c){return b([a+c.center[0],e+c.center[1]],c.points,c.theta,c.scale)}}},rotate:function(a){return function(e){return b(e.center,
e.points,e.theta+2*Math.PI*a,e.scale)}},scale:function(a){return function(e){return b(e.center,e.points,e.theta,e.scale*a)}},filled:a(!0),outlined:a(!1),customOutline:function(a){return function(b){return function(c){c.points.push(c.points[0]);return Line.customLine(a)(b)(c)}}}}}(),Line=function(){var b=function(a){return function(b){return function(e){if("string"===typeof a[0]){for(var c=[];"Cons"===a[0];)c.push(a[1]),a=a[2];a=c}0===a.length&&(a=[8,4]);return function(c){c.save();c.beginPath();c.translate(e.center[0],
e.center[1]);c.rotate(e.theta);c.scale(e.scale,e.scale);var h=a,k=e.points,g=k.length-1,j=k[g][0],m=k[g][1],l=0,n=0,i=0,o=0,p=0,r=0,t=h.length,s=!0,q=h[0];for(c.moveTo(j,m);g--;){l=k[g][0];n=k[g][1];i=l-j;o=n-m;for(p=Math.sqrt(i*i+o*o);q<=p;)j+=i*q/p,m+=o*q/p,c[s?"lineTo":"moveTo"](j,m),i=l-j,o=n-m,p=Math.sqrt(i*i+o*o),s=!s,r=(r+1)%t,q=h[r];0<p&&(c[s?"lineTo":"moveTo"](l,n),q-=p);j=l;m=n}c.strokeStyle=Color.Internal.extract(b);c.stroke();c.restore();return c}}}};return{line:function(a){for(var b=
[];"Cons"===a[0];)b.push([a[1][1],a[1][2]]),a=a[2];return{center:[0,0],points:b,theta:0,scale:1}},customLine:b,solid:function(a){return function(b){return function(e){e.save();e.beginPath();e.translate(b.center[0],b.center[1]);e.rotate(b.theta);e.scale(b.scale,b.scale);var c=b.points,f=c.length;for(e.moveTo(c[f-1][0],c[f-1][1]);f--;)e.lineTo(c[f][0],c[f][1]);e.strokeStyle=Color.Internal.extract(a);e.stroke();e.restore();return e}}},dashed:b([8,4]),dotted:b([3,3])}}(),Elm=function(){var b=function(a,
b,e){for(var d=a.length;d--;)a[d].recv(b,e)},a=function(a){this.id=Guid.guid();this.value=a;this.kids=[];this.recv=function(a,c,e){if(c=c===this.id)this.value=e;b(this.kids,a,c)};Dispatcher.inputs.push(this)},d=function(a,e){this.id=Guid.guid();this.value=null;this.kids=[];this.inbox={};e.reverse();this.recalc=function(){for(var b=a,d=e.length;d--;)b=b(e[d].value);this.value=b};this.recalc();this.recv=function(a,c){this.inbox.hasOwnProperty(a)||(this.inbox[a]={changed:!1,count:0});var d=this.inbox[a];
d.count+=1;c&&(d.changed=!0);d.count==e.length&&(d.changed&&this.recalc(),b(this.kids,a,d.changed),delete this.inbox[a])};for(var d=e.length;d--;)e[d].kids.push(this)},e=function(a,e,d){this.id=Guid.guid();this.value=e;this.kids=[];this.recv=function(e,g){g&&(this.value=a(d.value)(this.value));b(this.kids,e,g)};d.kids.push(this)};return{Input:function(c){return new a(c)},Lift:function(a,b){return new d(a,b)},Fold:function(a,b,d){return new e(a,b,d)}}}(),Dispatcher=function(){var b=null,a=0,d=[],e=
function(a){var b=a.childNodes,d=b.length;if(a.hasOwnProperty("isElmLeaf")){var b=""===a.style.width?0:a.style.width.slice(0,-2)-0,k=""===a.style.height?0:a.style.height.slice(0,-2)-0;return[b,k]}if(1===d){var g=e(b[0]);""!==a.style.width&&(g[0]=a.style.width.slice(0,-2)-0);""!==a.style.height&&(g[1]=a.style.height.slice(0,-2)-0);0!==g[0]&&(a.style.width=g[0]+"px");0!==g[1]&&(a.style.height=g[1]+"px");return g}for(var j=0,m=k=0,l=0,n=!0,i=!0;d--;)g=e(b[d]),j=Math.max(j,g[0]),k=Math.max(k,g[1]),m+=
g[0],l+=g[1],n=n&&0<g[0],i=i&&0<g[1];b=j;d=a.elmFlowDirection;"X"===d&&(b=n?m:0);"Y"===d&&(k=i?l:0);0<b&&(a.style.width=b+"px");0<k&&(a.style.height=k+"px");return[b,k]};return{initialize:function(){try{b=main()}catch(a){throw document.body.innerHTML=monospace("Runtime Error:<br>JavaScript "+a),a;}b.hasOwnProperty("recv")||(b=Elm.Input(b));var d=document.getElementById("content");d.appendChild(b.value);e(d);d=document.getElementById("widthChecker").offsetWidth;d!==window.innerWidth&&Dispatcher.notify(Window.dimensions.id,
Value.Tuple(d,window.innerHeight));b=Elm.Lift(function(a){var b=document.getElementById("content");b.replaceChild(a,b.children[0]);e(b);return a},[b])},notify:function(b,e){a+=1;for(var h=d.length;h--;)d[h].recv(a,b,e)},adjust:function(){var a=document.getElementById("content");e(a)},inputs:d}}(),Signal=function(){function b(a){for(var b=["Nil"],c=a.length;c--;)b=["Cons",a[c],b];return b}var a=function(){return document.addEventListener?function(a,b,c){a.addEventListener(b,c,!1)}:function(a,b,c){a.attachEvent("on"+
b,c)}}(),d=function(){function b(a){var c=0,d=0;a||(a=window.event);if(a.pageX||a.pageY)c=a.pageX,d=a.pageY;else if(a.clientX||a.clientY)c=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,d=a.clientY+document.body.scrollTop+document.documentElement.scrollTop;return Value.Tuple(c,d)}var c=Elm.Input(Value.Tuple(0,0)),d=Elm.Input(!1),e=Elm.Input(!1);a(document,"click",function(){Dispatcher.notify(e.id,!0);Dispatcher.notify(e.id,!1)});a(document,"mousedown",function(){Dispatcher.notify(d.id,
!0)});a(document,"mouseup",function(){Dispatcher.notify(d.id,!1)});a(document,"mousemove",function(a){Dispatcher.notify(c.id,b(a))});return{position:c,x:Elm.Lift(function(a){return a[1]},[c]),y:Elm.Lift(function(a){return a[2]},[c]),isClicked:e,isDown:d,clickedOn:function(b){var c=Elm.Input(!1);a(b,"click",function(){Dispatcher.notify(c.id,!0);Dispatcher.notify(c.id,!1)});return Value.Tuple(b,c)}}}(),e=function(){return{every:function(a){var a=1E3*a,b=Elm.Input(0),c=0;setInterval(function(){c+=a;
Dispatcher.notify(b.id,c/1E3)},a);return b},after:function(a){var a=1E3*a,b=Elm.Input(!1);setTimeout(function(){Dispatcher.notify(b.id,!0)},a);return b},before:function(a){var a=1E3*a,b=Elm.Input(!0);setTimeout(function(){Dispatcher.notify(b.id,!1)},a);return b}}}(),c=function(){var b=Elm.Input(Value.Tuple(window.innerWidth,window.innerHeight));a(window,"resize",function(){var a=document.getElementById("widthChecker").offsetWidth;Dispatcher.notify(b.id,Value.Tuple(a,window.innerHeight))});return{dimensions:b,
width:Elm.Lift(function(a){return a[1]},[b]),height:Elm.Lift(function(a){return a[2]},[b])}}(),f=function(){var a=function(a){return function(c){var d=Elm.Input(["Waiting"]),e={};window.XMLHttpRequest?e=new XMLHttpRequest:window.ActiveXObject&&(e=new ActiveXObject("Microsoft.XMLHTTP"));e.onreadystatechange=function(){4===e.readyState&&Dispatcher.notify(d.id,200===e.status?["Success",b(e.responseText)]:["Failure",e.status,b(e.statusText)])};e.open(a,String.toText(c),!0);e.send(null);return d}},c=function(a){return function(c){var e=
Elm.Input(["Nothing"]),c=Elm.Lift(function(c){if("Just"!==c[0]){try{Dispatcher.notify(e.id,["Nothing"])}catch(d){}return[]}try{Dispatcher.notify(e.id,["Just",["Waiting"]])}catch(g){e.value=["Just",["Waiting"]]}var l={};window.XMLHttpRequest?l=new XMLHttpRequest:window.ActiveXObject&&(l=new ActiveXObject("Microsoft.XMLHTTP"));l.onreadystatechange=function(){4===l.readyState&&Dispatcher.notify(e.id,["Just",200===l.status?["Success",b(l.responseText)]:["Failure",l.status,b(l.statusText)]])};l.open(a,
String.toText(c[1]),!0);l.send(null);return[]},[c]);return Elm.Lift(function(a){return function(){return a}},[e,c])}};return{get:a("GET"),post:a("POST"),gets:c("GET"),posts:c("POST")}}(),h=function(){return{inRange:function(a){return function(b){return Elm.Input(Math.floor(Math.random()*(b-a+1))+a)}},randomize:function(a){return function(b){return function(c){return Elm.Lift(function(){return Math.floor(Math.random()*(b-a+1))+a},[c])}}}}}(),k=function(){var c=function(c){c.isElmLeaf=!0;var e=Elm.Input(["Nil"]);
a(c,"keyup",function(){Dispatcher.notify(e.id,b(c.value));c.focus()});return Value.Tuple(c,e)},e=function(a){a=document.createElement(a);a.id=Guid.guid();return a},d=function(b){for(var c=e("select"),d=[];"Cons"===b[0];){var f=e("option"),g=Text.toText(b[1][1]);f.value=g;f.innerHTML=g;c.appendChild(f);d.push(b[1][2]);b=b[2]}var h=Elm.Input(d[0]);a(c,"change",function(){Dispatcher.notify(h.id,d[c.selectedIndex])});return Value.Tuple(c,h)};return{textArea:function(a){return function(b){var d=e("textarea");
d.rows=b;d.cols=a;return c(d,"")}},textField:function(a){var b=e("input");b.type="text";return c(b,a)},password:function(a){var b=e("input");b.type="password";return c(b,a)},checkbox:function(b){var c=e("input");c.type="checkbox";c.checked=b;var d=Elm.Input(b);a(c,"change",function(){Dispatcher.notify(d.id,c.checked)});return Value.Tuple(c,d)},dropDown:d,stringDropDown:function(a){return d(List.map(function(a){return Value.Tuple(a,a)})(a))},button:function(b){var c=e("input");c.type="button";c.value=
Text.toText(b);var d=Elm.Input(!1);a(c,"click",function(){Dispatcher.notify(d.id,!0);Dispatcher.notify(d.id,!1)});return Value.Tuple(c,d)}}}();return{Mouse:d,Time:e,Window:c,HTTP:f,Random:h,Input:k}}(),List=function(){function b(a){return function(b){if("Nil"===b[0])return b;"Cons"!==b[0]&&j();for(var c=["Cons",a(b[1]),["Nil"]],d=c,b=b[2];"Cons"===b[0];)d[2]=["Cons",a(b[1]),["Nil"]],b=b[2],d=d[2];return c}}function a(a){return function(b){return function(c){var d=b;if("Nil"===c[0])return d;for("Cons"!==
c[0]&&j();"Cons"===c[0];)d=a(c[1])(d),c=c[2];return d}}}function d(a){return function(b){return function(c){var d=b;if("Nil"===c[0])return d;"Cons"!==c[0]&&j();for(var e=[];"Cons"===c[0];)e.push(c[1]),c=c[2];for(c=e.length;c--;)d=a(e[c])(d);return d}}}function e(b){return function(c){var d;"Cons"!==c[0]?d=void 0:(d=c[1],c=c[2],d=a(b)(d)(c));return d}}function c(a){return function(c){return function(b){if("Nil"===b[0])return["Cons",c,["Nil"]];"Cons"!==b[0]&&j();for(var d=[c];"Cons"===b[0];)c=a(b[1])(c),
d.push(c),b=b[2];for(var b=["Nil"],e=d.length;e--;)b=["Cons",d[e],b];return b}}}function f(a){return function(b){return function(){for(var c=[function(a){return"Nil"!==a[0]?void 0:["Tuple2",["Nil"],["Nil"]]},function(b){if("Cons"===b[0]){var c=b[1],b=b[2];var d=f(a)(b);"Tuple2"!==d[0]?c=void 0:(b=d[1],d=d[2],c=a(c)?["Tuple2",["Cons",c,b],d]:["Tuple2",b,["Cons",c,d]]);return c}}],d=c.length;d--;){var e=c[d](b);if(void 0!==e)return e}}()}}function h(a){return function(){for(var b=[function(a){return"Nil"!==
a[0]?void 0:["Tuple2",["Nil"],["Nil"]]},function(a){if("Cons"!==a[0])a=void 0;else if(a=["Tuple2",a[1],h(a[2])],"Tuple2"!==a[0]||"Tuple2"!==a[1][0])a=void 0;else var b=a[1][1],c=a[1][2],a="Tuple2"!==a[2][0]?void 0:["Tuple2",["Cons",b,a[2][1]],["Cons",c,a[2][2]]];return a}],c=b.length;c--;){var d=b[c](a);if(void 0!==d)return d}}()}function k(a){return function(b){return function(){for(var c=[function(a){return"Nil"!==a[0]?void 0:["Nil"]},function(a){if("Cons"===a[0]){var b=a[1];return"Nil"!==a[2][0]?
void 0:["Cons",b,["Nil"]]}},function(b){if("Cons"===b[0]){var c=b[1];if("Cons"===b[2][0]){var d=b[2][1],b=b[2][2];return["Cons",c,["Cons",a,k(a)(["Cons",d,b])]]}}}],d=c.length;d--;){var e=c[d](b);if(void 0!==e)return e}}()}}function g(a){return function(b){return function(){for(var c=[function(a){return"Nil"!==a[0]?void 0:["Nil"]},function(a){if("Cons"===a[0]){var b=a[1];return"Nil"!==a[2][0]?void 0:b}},function(b){if("Cons"===b[0]){var c=b[1];if("Cons"===b[2][0]){var d=b[2][1],b=b[2][2];return Value.append(c,
Value.append(a,g(a)(["Cons",d,b])))}}}],d=c.length;d--;){var e=c[d](b);if(void 0!==e)return e}}()}}var j=function(){throw"Function expecting a list!";},m=a(function(a){return function(b){return["Cons",a,b]}})(["Nil"]),l=d(function(a){return function(b){return Value.append(a,b)}})(["Nil"]),n=a(function(a){return function(b){return a&&b}})(!0),i=a(function(a){return function(b){return a||b}})(!1),o=a(function(a){return function(b){return a+b}})(0),p=a(function(a){return function(b){return a*b}})(1),
r=e(function(a){return function(b){return Math.max(a,b)}}),t=e(function(a){return function(b){return Math.min(a,b)}});return{head:function(a){if("Cons"!==a[0])throw"Error: 'head' only accepts lists of length greater than one.";return a[1]},tail:function(a){if("Cons"!==a[0])throw"Error: 'tail' only accepts lists of length greater than one.";return a[2]},map:b,foldl:a,foldr:d,foldl1:e,foldr1:function(a){return function(b){var c;"Cons"!==b[0]?c=void 0:(c=b[1],b=b[2],c=d(a)(c)(b));return c}},scanl:c,
scanl1:function(a){return function(b){if("Cons"!==b[0])throw"Error: 'scanl1' requires a list of at least length 1.";return c(a)(b[1])(b[2])}},filter:function(a){return function(b){if("Nil"===b[0])return b;"Cons"!==b[0]&&j();for(var c=[];"Cons"===b[0];)a(b[1])&&c.push(b[1]),b=b[2];for(var b=["Nil"],d=c.length;d--;)b=["Cons",c[d],b];return b}},length:function(a){for(var b=0;"Cons"===a[0];)b+=1,a=a[2];return b},reverse:m,concat:l,concatMap:function(a){return function(c){return l(b(a)(c))}},and:n,or:i,
forall:function(b){return a(function(a){return function(c){return c&&b(a)}})(!0)},exists:function(b){return a(function(a){return function(c){return c||b(a)}})(!1)},sum:o,product:p,maximum:r,minimum:t,partition:f,zipWith:function(a){return function(b){return function(c){if("Nil"===b[0]||"Nil"===c[0])return b;("Cons"!==b[0]||"Cons"!==c[0])&&j();for(var d=[];"Cons"===b[0]&&"Cons"===c[0];)d.push(a(b[1])(c[1])),b=b[2],c=c[2];for(var c=["Nil"],e=d.length;e--;)c=["Cons",d[e],c];return c}}},zip:function(a){return function(b){if("Nil"===
a[0]||"Nil"===b[0])return a;("Cons"!==a[0]||"Cons"!==b[0])&&j();for(var c=[];"Cons"===a[0]&&"Cons"===b[0];)c.push(["Tuple2",a[1],b[1]]),a=a[2],b=b[2];for(var b=["Nil"],d=c.length;d--;)b=["Cons",c[d],b];return b}},unzip:h,intersperse:k,intercalate:g,sort:function(a){if("Nil"===a[0])return a;"Cons"!==a[0]&&j();for(var b=[];"Cons"===a[0];)b.push(a[1]),a=a[2];b.sort(function(a,b){return a-b});for(var a=["Nil"],c=b.length;c--;)a=["Cons",b[c],a];return a}}}(),id=function(b){return b},not=function(b){return!b},
sqrt=function(b){return Math.sqrt(b)},rem=function(b){return function(a){return b%a}},mod=function(b){return function(a){var d=b%a,d=0==b?0:0<a?0<=b?d:d+a:-mod(-b)(-a);return d==a?0:d}},abs=function(b){return Math.abs(b)},logBase=function(b){return function(a){return Math.log(a)/Math.log(b)}},min=function(b){return function(a){return Math.min(b,a)}},max=function(b){return function(a){return Math.max(b,a)}},clamp=function(b){return function(a){return function(d){return Math.min(a,Math.max(b,d))}}},
sin=Math.sin,cos=Math.cos,tan=Math.tan,asin=Math.asin,acos=Math.acos,atan=Math.atan,flip=function(b){return function(a){return function(d){return b(d)(a)}}},Just=function(b){return["Just",b]},Nothing=["Nothing"];function constant(b){return Elm.Input(b)}function lift(b){return function(a){return Elm.Lift(b,[a])}}function lift2(b){return function(a){return function(d){return Elm.Lift(b,[a,d])}}}
function lift3(b){return function(a){return function(d){return function(e){return Elm.Lift(b,[a,d,e])}}}}function lift4(b){return function(a){return function(d){return function(e){return function(c){return Elm.Lift(b,[a,d,e,c])}}}}}function foldp(b){return function(a){return function(d){return Elm.Fold(b,a,d)}}}var includeGlobal=this;
(function(){var b=function(a){for(var b in a)if("Internal"!==b)try{includeGlobal[b]=a[b]}catch(c){"length"===b&&(includeGlobal.execScript("var length;"),length=a[b])}},a=function(a){return function(b){includeGlobal[a]=includeGlobal[a]||{};for(var c in b)"Internal"!==c&&(includeGlobal[a][c]=b[c])}};b(Element);b(Text);color=Element.color;height=Element.height;show=Value.show;a("Time")(Signal.Time);a("Mouse")(Signal.Mouse);a("Window")(Signal.Window);a("HTTP")(Signal.HTTP);a("Input")(Signal.Input);a("Random")(Signal.Random);
b(Color);b(Shape);b(Line)})();