elm/elm-mini.js

50 lines
25 KiB
JavaScript
Raw Normal View History

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