-
Notifications
You must be signed in to change notification settings - Fork 25
/
jquery-turtle.min.js
5 lines (5 loc) · 145 KB
/
jquery-turtle.min.js
1
2
3
4
5
(function(a){function b(b,c){if(Ne>5)Oe.push({elem:b,qname:c});else{for(Ne+=1,a.dequeue(b,c);Oe.length>0;){var d=Oe.shift();a.dequeue(d.elem,d.qname),Vc()}Ne-=1}}function c(a,b){function c(){this.constructor=a}for(var d in b)Je.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a}function d(b){var c,d,e=b.charAt(0).toUpperCase()+b.slice(1),f=["Moz","Webkit","O","ms"],g=document.createElement("div");if(b in g.style)d=b;else for(var h=0;h<f.length;h++)if(c=f[h]+e,c in g.style){d=c;break}return g=null,a.support[b]=d,d}function e(){var a=document.createElement("div"),b="getBoundingClientRect"in a;return a=null,b}function f(b,c){function d(){for(;m.length&&/^\s/.test(m[m.length-1]);)m.pop();for(;m.length&&/^\s/.test(m[0]);)m.shift();1==m.length&&(/^".*"$/.test(m[0])||/^'.*'$/.test(m[0]))?g=m[0].substr(1,m[0].length-2):2==m.length&&"url"==m[0]&&/^(.*)$/.test(m[1])?g=m[1].substr(1,m[1].length-2):(h=m.join(""),g=""==h?h:isNaN(h)?h:Number(h)),!l&&n&&c&&m.length&&(k=c),k&&(j[k]=g)}if("string"!=typeof b){if(null==b)return{};if(a.isPlainObject(b))return b;b=""+b}var e,f,g,h,i=b.match(/[-a-zA-Z_][-\w]*|"[^"]*"|'[^']'|\([^()]*\)|\s+|./g),j={},k=null,l=!1,m=[],n=!0;for(e=0;e<i.length;++e)f=i[e],l||(!k&&/^[a-zA-Z_-]/.test(f)&&(k=f),":"!=f)?";"!=f?m.push(f):(d(),k=null,m.length=0,l=!1,n=!1):(l=!0,m.length=0);return d(),j}function g(a){function b(a){return/[\s;]/.test(a)?a.indexOf('"')<0?'"'+a+'"':"'"+a+"'":a}var c=[];for(var d in a)a.hasOwnProperty(d)&&c.push(d+":"+b(a[d])+";");return c.join(" ")}function h(a){return a}function i(a,b){var c=[a[0]*b[0]+a[2]*b[1],a[1]*b[0]+a[3]*b[1]];return 6==a.length&&(c[0]+=a[4],c[1]+=a[5]),c}function j(a,b){var c=[a[0]*b[0]+a[2]*b[1],a[1]*b[0]+a[3]*b[1],a[0]*b[2]+a[2]*b[3],a[1]*b[2]+a[3]*b[3]],d=6==a.length;return 6==b.length?(c.push(a[0]*b[4]+a[2]*b[5]+(d?a[4]:0)),c.push(a[1]*b[4]+a[3]*b[5]+(d?a[5]:0))):d&&(c.push(a[4]),c.push(a[5])),c}function k(a){return Math.abs(a)>1e-12}function l(a){return!(k(a[1])||k(a[2])||k(1-a[0])||k(1-a[3]))}function m(a){if(l(a))return[1,0,0,1];var b=u(a);return k(b[2])?j(o(-b[3]),j(p(1/b[1],1/b[2]),o(-b[0]))):null}function n(a){var b=m(a);if(4==a.length)return b;var c=i(b,[-a[4],-a[5]]);return b.push(c[0]),b.push(c[1]),b}function o(a){var b=Math.cos(a),c=Math.sin(a);return[b,c,-c,b]}function p(a,b){return 1==arguments.length&&(a=b),[a,0,0,b]}function q(a,b){return[a[0]+b[0],a[1]+b[1]]}function r(a,b){return[a[0]-b[0],a[1]-b[1]]}function s(a,b){return[a[0]*b,a[1]*b]}function t(a,b,c){return q(i(a,r(b,c)),c)}function u(a){var b,c,d=a[0]*a[0]+a[1]*a[1],e=a[0]*a[2]+a[1]*a[3],f=a[2]*a[2]+a[3]*a[3],g=-.5*Math.atan2(2*e,d-f),h=Math.cos(g),i=Math.sin(g),j=a[0]*h-a[2]*i,k=a[1]*h-a[3]*i,l=Math.atan2(k,j),m=Math.cos(l),n=Math.sin(l),o=(a[1]*i+a[3]*h)*m-(a[0]*i+a[2]*h)*n,p=(a[0]*h-a[2]*i)*m+(a[1]*h-a[3]*i)*n;return g<-Math.PI/4?(g+=Math.PI/2,c=p,b=o,l-=Math.PI/2):(b=p,c=o),l>Math.PI&&(l-=2*Math.PI),[l,b,c,g]}function v(a,b){var c=(b-a)/2,d=Math.cos(c),e=Math.sin(c),f=d,g=-e,h=1+f*d+g*e,i=f*e-g*d,j=i&&4/3*(Math.sqrt(2*h)-h)/i,k=f-j*g,l=g+j*f,m=k,n=-l,o=c+a,p=Math.cos(o),q=Math.sin(o);return[[k*p-l*q,k*q+l*p],[m*p-n*q,m*q+n*p],[Math.cos(b),Math.sin(b)]]}function w(a){var b=ra(a,!1);if(b)return[b.tx,b.ty];var c=x(a);return c?[c[4],c[5]]:[0,0]}function x(b){var c=Ie.getComputedStyle?Ie.getComputedStyle(b)[Pe]:a.css(b,"transform");if(!c||"none"===c)return null;var d=/^matrix\(([\-+.\de]+),\s*([\-+.\de]+),\s*([\-+.\de]+),\s*([\-+.\de]+),\s*([\-+.\de]+)(?:px)?,\s*([\-+.\de]+)(?:px)?\)$/.exec(c);return d?[parseFloat(d[1]),parseFloat(d[2]),parseFloat(d[3]),parseFloat(d[4]),parseFloat(d[5]),parseFloat(d[6])]:A(c)}function y(b,c){var d,e,f,g="none"===a.css(b,"display");if(g){d={position:"absolute",visibility:"hidden",display:"block"},e={};for(f in d)e[f]=b.style[f],b.style[f]=d[f]}var h=Ie.getComputedStyle?Ie.getComputedStyle(b):null;if(g)for(f in d)b.style[f]=e[f];var i=h&&h[Qe]||a.css(b,"transformOrigin");if(i&&i.indexOf("%")<0)return a.map(i.split(" "),parseFloat);if(c)return[c[0]/2,c[1]/2];var j=a(b);return[j.width()/2,j.height()/2]}function z(a){for(var b,c=[1,0,0,1];null!==a;)b=x(a),b&&!l(b)&&(c=j(b,c)),a=a.parentElement;return c.slice(0,4)}function A(b){var c=[1,0,0,1],d=[],e=[],f=/(?:^\s*|)(\w*)\s*\(([^)]*)\)\s*/g,g=b.replace(f,function(b){return d.push(b[1].toLowerCase()),e.push(a.map(b[2].split(","),function(a){var b=a.trim().toLowerCase();return{num:parseFloat(b),unit:b.replace(/^[+-.\de]*/,"")}})),""});if(g)return null;for(var h=d.length-1;h>=0;--h){var i,k,l,m=null,n=d[h],o=e[h];if("matrix"==n)o.length>=6&&(m=[o[0].num,o[1].num,o[2].num,o[3].num,o[4].num,o[5].num]);else if("rotate"==n)1==o.length&&(i=wa(o[0]),k=Math.cos(i),l=Math.sin(i),m=[k,-l,k,l]);else if("translate"==n||"translatex"==n||"translatey"==n){var p=0,q=0;if(o.length>=1){if(o[0].unit&&"px"!=o[0].unit)return null;if("translate"==n||"translatex"==n?p=o[0].num:"translatey"==n&&(q=o[0].num),"translate"==n&&o.length>=2){if(o[1].unit&&"px"!=o[1].unit)return null;q=o[1].num}m=[0,0,0,0,p,q]}}else if("scale"==n||"scalex"==n||"scaley"==n){var r=1,s=1;o.length>=1&&("scale"==n||"scalex"==n?r=o[0].num:"scaley"==n&&(s=o[0].num),"scale"==n&&o.length>=2&&(s=o[1].num),m=[r,0,0,s,0,0])}else{if("skew"!=n&&"skewx"!=n&&"skewy"!=n)return null;var t=0,u=0;o.length>=1&&("skew"==n||"skewx"==n?t=Math.tan(wa(o[0])):"skewy"==n&&(u=Math.tan(wa(o[0]))),"skew"==n&&o.length>=2&&(u=Math.tan(wa(o[0]))),m=[1,u,t,1,0,0])}c=j(c,m)}return c}function B(a,b,c){if(0>=c)return a;var d=b.pageX-a.pageX,e=b.pageY-a.pageY,f=d*d+e*e;if(c*c>=f)return b;var g=c/Math.sqrt(f);return{pageX:a.pageX+g*d,pageY:a.pageY+g*e}}function C(a,b,c){if(0>=c)b=a;else if(180>c){var d=xa(b-a);d>c?b=a+c:-c>d&&(b=a-c)}return xa(b)}function D(a,b,c,d){return{pageX:Math.floor(a+c/2),pageY:Math.floor(b+d/2)}}function E(a,b,c,d){var e=a+c,f=b+d;return[{pageX:a,pageY:b},{pageX:a,pageY:f},{pageX:e,pageY:f},{pageX:e,pageY:b}]}function F(a){if(!/e[\-+]/.exec(a))return a;var b=a.replace(/(?:\d+(?:\.\d*)?|\.\d+)e[\-+]\d+/g,function(a){return sa(parseFloat(a))});return b}function G(b,c,d){var e=a.data(b,"turtleData");if(e&&e.quickhomeorigin&&e.down&&e.style&&!d&&b.classList&&b.classList.contains("turtle"))return e.quickhomeorigin;var f,g,h,i="none"===a.css(b,"display"),j=i?{position:"absolute",visibility:"hidden",display:"block"}:{},k=(j[Pe]=c?"matrix("+a.map(c,sa).join(", ")+", 0, 0)":"none",{});for(f in j)k[f]=b.style[f],b.style[f]=j[f];g=N(b),h=y(b,[g.width,g.height]);for(f in j)b.style[f]=F(k[f]);d&&(d.gbcr=g,d.localorigin=h);var l=q([g.left,g.top],h);return e&&e.down&&e.style&&(e.quickhomeorigin=l),l}function H(){return Ie.innerHeight||a(Ie).height()}function I(){return Ie.innerWidth||a(Ie).width()}function J(){return document.body?a(document).height():document.height}function K(){return document.body?a(document).width():document.width}function L(a){return a.offsetHeight<=0&&a.offsetWidth<=0}function M(a,b,c,d){return{left:a,top:b,right:a+c,bottom:b+d,width:c,height:d}}function N(b){return mb(b)?M(b.pageX,b.pageY,0,0):a.isWindow(b)?M(a(Ie).scrollLeft(),a(Ie).scrollTop(),I(),H()):9===b.nodeType?M(0,0,K(),J()):"getBoundingClientRect"in b?T.apply(b):M(0,0,0,0)}function O(a,b,c){var d=Math.max(0,Math.max(c.top-a.pageY,a.pageY-c.bottom)),e=Math.max(0,Math.max(c.left-a.pageX,a.pageX-c.right));return e*e+d*d>b}function P(a,b,c){var d=Math.max(c.bottom-a.pageY,a.pageY-c.top),e=Math.max(c.right-a.pageX,a.pageX-c.left);return b>e*e+d*d}function Q(a,b){return b.right<a.left||a.right<b.left||b.bottom<a.top||a.bottom<b.top}function R(a,b){return b.top>=a.top&&b.bottom<=a.bottom&&b.left>=a.left&&b.right<=a.right}function S(a,b){return 4===a.length&&a[0].pageX===b.left&&a[0].pageY===b.top&&a[1].pageX===b.left&&a[1].pageY===b.bottom&&a[2].pageX===b.right&&a[2].pageY===b.bottom&&a[3].pageX===b.right&&a[3].pageY===b.top}function T(){var a=this.getBoundingClientRect();return{top:a.top+Ie.pageYOffset,bottom:a.bottom+Ie.pageYOffset,left:a.left+Ie.pageXOffset,right:a.right+Ie.pageXOffset,width:a.width,height:a.height}}function U(b,c,d,e,f){var g,h,j,k,l=z(b.parentElement),n=m(l),o=G(b,n);if(n){if(a.isNumeric(d)&&(j=w(b),g=q(i(l,j),o),h={pageX:g[0],pageY:g[1]},c=B(h,c,d)),k=i(n,r([c.pageX,c.pageY],o)),e||f){var p=Gc(b);k[0]+=e*p,k[1]-=f*p}return sa(k[0])+" "+sa(k[1])}}function V(a){var b=a.offsetParent;return b?b:document}function W(b,c){c||(c=a(V(b)).pagexy());var d=z(b.parentElement),e=m(d),f=G(b,e),g=ra(b,!0),h=e&&i(e,r([c.pageX,c.pageY],f)),j=1/Gc(b);if(e)return[(g.tx-h[0])*j,(h[1]-g.ty)*j]}function X(b,c){var d,e,f=z(b.parentElement),g=(ra(b,!0),a(V(b)).pagexy()),h=Gc(b),j=[];for(e=0;e<c.length;e++)d=i(f,[c[e][0]*h,-c[e][1]*h]),j.push({pageX:g.pageX+d[0],pageY:g.pageY+d[1]});return j}function Y(b){if(a.isWindow(b))return D(a(Ie).scrollLeft(),a(Ie).scrollTop(),I(),H());if(9===b.nodeType||b==document.body)return D(0,0,K(),J());var c=Oa(b);if(c&&c.quickpagexy&&c.down&&c.style)return c.quickpagexy;var d=w(b),e=z(b.parentElement),f=l(e),g=f?null:m(e),h=G(b,g),j=q(i(e,d),h),k={pageX:j[0],pageY:j[1]};return c&&f&&c.down&&c.style&&b.classList&&b.classList.contains("turtle")&&(c.quickpagexy=k),k}function Z(b){"CANVAS"!=b.tagName&&"IMG"!=b.tagName&&a(b).find(".turtle").each(function(b,c){var d=a.data(c,"turtleData");d&&(d.quickpagexy=null,d.quickhomeorigin=null)})}function $(a,b){if(!a)return null;for(var c=[],d=0;d<a.length;++d)c.push([a[d].pageX+b[0],a[d].pageY+b[1]]);return c}function _(b,c){if(a.isWindow(b))return E(a(Ie).scrollLeft(),a(Ie).scrollTop(),I(),H());if(9===b.nodeType)return E(0,0,K(),J());var d=x(b)||[1,0,0,1],e=z(b.parentElement),f=j(e,d),g=m(e),h={},i=G(b,g,h),k=h.gbcr,l=$(Oa(b).hull,i)||[[k.left,k.top],[k.left,k.bottom],[k.right,k.bottom],[k.right,k.top]];return c?a.map(l,function(a){return{pageX:a[0]-i[0],pageY:a[1]-i[1]}}):a.map(l,function(a){var b=t(f,a,i);return{pageX:b[0],pageY:b[1]}})}function aa(a){var b=ra(a,!0),c=wa(xa(b.rot)),d=Math.sin(c),e=Math.cos(c),f=z(a.parentElement),g=i(f,[d,e]),h=Math.atan2(g[0],g[1]);return va(h)}function ba(b,c){var d=b.pageX,e=b.pageY,f=I()/2,g=H()/2,h=a("body"),i=h.width(),j=h.height(),k=a(Ie);d>i-f&&(d=i-f),f>d&&(d=f),e>j-g&&(e=j-g),g>e&&(e=g);var l={pageX:d,pageY:e};a.isNumeric(c)&&(l=B(k.origin(),l,c)),k.scrollLeft(l.pageX-f),k.scrollTop(l.pageY-g)}function ca(a,b,c){var d=b.pageX-a.pageX,e=b.pageY-a.pageY,f=c.pageX-a.pageX,g=c.pageY-a.pageY;return f*e-d*g}function da(a,b,c){var d=c.pageX-a.pageX,e=c.pageY-a.pageY;return d*b.pageY-b.pageX*e}function ea(a,b){if(b.length<=0)return!1;if(1==b.length)return b[0].pageX==a.pageX&&b[0].pageY==a.pageY;var c=ca(a,b[b.length-1],b[0]);if(0===c)return!0;var d=c>0;if(2==b.length)return!1;for(var e=1;e<b.length;++e){var f=ca(a,b[e-1],b[e]);if(0===f)return!0;if(f>0!=d)return!1}return!0}function fa(a,b){return{pageX:a.pageX-b.pageX,pageY:a.pageY-b.pageY}}function ga(a,b,c,d){var e,f,g=fa(c,b);for(e=0;e<d.length;++e)if(f=ha(da(b,g,d[e])),!f||f===a)return!1;return!0}function ha(a){return a>0?1:0>a?-1:0}function ia(a){if(a.length<=2)return 0;var b=ca(a[a.length-1],a[0],a[1]);if(0!==b)return ha(b);for(var c=1;c<a.length;++c)if(b=ca(a[c-1],a[c],a[(c+1)%a.length]),0!==b)return ha(b);return 0}function ja(a,b){var c,d=ia(a);for(c=0;c<a.length;++c)if(ga(d,a[c],a[(c+1)%a.length],b))return!1;for(d=ia(b),c=0;c<b.length;++c)if(ga(d,b[c],b[(c+1)%b.length],a))return!1;return!0}function ka(a,b){for(var c=0;c<b.length;++c)if(!ea(b[c],a))return!1;return!0}function la(a){function b(a,b){if(!b||!mb(b))return a;for(;a.length>1&&1!=ha(ca(a[a.length-2],a[a.length-1],b));)a.pop();return a.length&&d(a[a.length-1],b)||a.push(b),a}function c(a,b,c){for(var d=0;d<a.length;++d)b=c(b,a[d]);return b}function d(a,b){return a.pageX===b.pageX&&a.pageY===b.pageY}function e(a,b){return a.pageX<b.pageX?-1:a.pageX>b.pageX?1:a.pageY<b.pageY?-1:a.pageY>b.pageY?1:0}a.sort(e);var f=c(a,[],b),g=c(a.reverse(),[],b);return f.concat(g.slice(1,-1))}function ma(b){if(!b)return null;if(a.isArray(b))return b;for(var c=a.map(b.trim().split(/\s+/),parseFloat),d=[],e=0;e+1<c.length;)d.push({pageX:c[e],pageY:c[e+1]}),e+=2;return d}function na(b){for(var c=0,d=[];c<b.length;++c)d.push(b[c].pageX,b[c].pageY);return d.length?a.map(d,sa).join(" "):"none"}function oa(){return{get:function(a,b,c){var d=Oa(a).hull;return na(d||_(a,!0))},set:function(a,b){var c=b&&"auto"!=b?"none"==b?[]:la(ma(b)):null;Oa(a).hull=c}}}function pa(a){if("none"===a)return{tx:0,ty:0,rot:0,sx:1,sy:1,twi:0};var b=/^(?:translate\(([\-+.\de]+)(?:px)?,\s*([\-+.\de]+)(?:px)?\)\s*)?(?:rotate\(([\-+.\de]+)(?:deg)?\)\s*)?(?:scale\(([\-+.\de]+)(?:,\s*([\-+.\de]+))?\)\s*)?(?:rotate\(([\-+.\de]+)(?:deg)?\)\s*)?$/.exec(a);if(!b)return null;var c=b[1]?parseFloat(b[1]):0,d=b[2]?parseFloat(b[2]):0,e=b[3]?parseFloat(b[3]):0,f=b[4]?parseFloat(b[4]):1,g=b[5]?parseFloat(b[5]):f,h=b[6]?parseFloat(b[6]):0;return{tx:c,ty:d,rot:e,sx:f,sy:g,twi:h}}function qa(a){var b,c=x(a);return c?(b=u(c),{tx:c[4],ty:c[5],rot:va(b[0]),sx:b[1],sy:b[2],twi:va(b[3])}):{tx:0,ty:0,rot:0,sx:1,sy:1,twi:0}}function ra(a,b){return pa(a.style[Pe])||b&&qa(a)}function sa(a){var b=a.toString();return~b.indexOf("e")&&(b=Number(a).toFixed(17)),b}function ta(a){var b=[];return(k(a.tx)||k(a.ty))&&b.push("translate("+sa(a.tx)+"px, "+sa(a.ty)+"px)"),(k(a.rot)||k(a.twi))&&b.push("rotate("+sa(a.rot)+"deg)"),(k(1-a.sx)||k(1-a.sy))&&(k(a.sx-a.sy)?b.push("scale("+sa(a.sx)+", "+sa(a.sy)+")"):b.push("scale("+sa(a.sx)+")")),k(a.twi)&&b.push("rotate("+sa(a.twi)+"deg)"),b.length?b.join(" "):"none"}function ua(a,b){return(+a%(b=+b)+b)%b}function va(a){var b=180*a/Math.PI;return b>180&&(b-=360),b}function wa(a){return a/180*Math.PI}function xa(a){return Math.abs(a)>180&&(a%=360,a>180?a-=360:-180>=a&&(a+=360)),a}function ya(a){return Math.abs(a)>=720&&(a=a%360+(a>0?360:-360)),a}function za(){return Re.field||Ba(),Re.field}function Aa(){return Re.surface||Ba(),Re.surface}function Ba(){var b=document.createElement("samp"),c=document.createElement("samp"),d=Math.floor(I()/2),e=Math.floor(H()/2);a(b).css({position:"absolute",display:"inline-block",top:0,left:0,width:"100%",height:"100%",font:"inherit",zIndex:-1,transformOrigin:d+"px "+e+"px",pointerEvents:"none",overflow:"hidden"}).addClass("turtlefield"),a(c).attr("id","origin").css({position:"absolute",display:"inline-block",top:e,left:d,width:"100%",height:"0",font:"inherit",transformOrigin:"0px 0px",pointerEvents:"all",turtleSpeed:1/0}).appendTo(b),Re.surface=b,Re.field=c,Ca(),Sb()}function Ca(){document.body?(null==a("html").attr("style")&&a("html").css("min-height","100%"),a(Re.surface).prependTo("body"),Rb()):a(document).ready(Ca)}function Da(a){return a.drawOnCanvas||(a.drawOnCanvas=Fa()),a.drawOnCanvas}function Ea(b){var c=a.data(b,"turtleData");return c?c.drawOnCanvas?c.drawOnCanvas:Re.canvas:null}function Fa(){if(Re.canvas)return Re.canvas;var b=Aa();return Re.canvas=document.createElement("canvas"),a(Re.canvas).css({"z-index":-1}),b.insertBefore(Re.canvas,b.firstChild),Ja(),Ha(Ja),a(Ie).resize(Ja),Re.canvas}function Ga(a,b){return Re.offscreen&&Re.offscreen.width===a&&Re.offscreen.height===b?(Re.offscreen.getContext("2d").clearRect(0,0,a,b),Re.offscreen):(Re.offscreen||(Re.offscreen=document.createElement("canvas")),Re.offscreen.width=a,Re.offscreen.height=b,Re.offscreen)}function Ha(b){var c=a("body"),d=c.width(),e=c.height(),f=function(){(c.width()!=d||c.height()!=e)&&(b(),d=c.width(),e=c.height())};Re.timer&&clearInterval(Re.timer),Re.timer=setInterval(f,250)}function Ia(){var b=a("body");return[Math.max(b.outerWidth(!0),Ie.innerWidth||a(Ie).width()),Math.max(b.outerHeight(!0),Ie.innerHeight||a(Ie).height())]}function Ja(){if(Re.canvas){var b,c=Ia(),d=c[0],e=c[1],f=Re.canvas.width,g=Re.canvas.height,h=Math.max(Math.min(2e3,Math.max(200,f)),100*Math.ceil(d/100))*Re.subpixel,i=Math.max(Math.min(2e3,Math.max(200,f)),100*Math.ceil(e/100))*Re.subpixel;a(Re.surface).css({width:d+"px",height:e+"px"}),(f!=h||g!=i)&&(b=document.createElement("canvas"),b.width=Math.min(f,h),b.height=Math.min(g,i),b.getContext("2d").drawImage(Re.canvas,0,0),Re.canvas.width=h,Re.canvas.height=i,Re.canvas.getContext("2d").drawImage(b,0,0),a(Re.canvas).css({width:h/Re.subpixel,height:i/Re.subpixel}))}}function Ka(a,b){if(!a)return null;if(a&&"function"==typeof a&&(a.helpname||a.name)&&(a=a.helpname||a.name),a=String(a),a.trim&&(a=a.trim()),!a||"none"===a)return null;if("path"===a||"fill"===a)return{savePath:!0};var c=!1;/^erase\b/.test(a)&&(a=a.replace(/^erase\b/,"white; globalCompositeOperation:destination-out"),c=!0);var d=f(a,b);return c&&(d.eraseMode=!0),d}function La(a){return a?g(a):"none"}function Ma(a){return"down"==a||a===!0?!0:"up"==a||a===!1?!1:He}function Na(a){return a?"down":"up"}function Oa(b){var c=a.data(b,"turtleData");return c||(c=a.data(b,"turtleData",{style:null,corners:[[]],path:[[]],down:!1,speed:"turtle",easing:"swing",turningRadius:0,drawOnCanvas:null,quickpagexy:null,quickhomeorigin:null,oldscale:1,instrument:null,stream:null})),c}function Pa(b){var c=a.data(b,"turtleData");return c?c.turningRadius:0}function Qa(){return{get:function(a,b,c){return sa(Pa(a))+"px"},set:function(a,b){var c=parseFloat(b);if(!isNaN(c)&&(Oa(a).turningRadius=c,a.style.turtleTurningRadius=""+sa(c)+"px",0===c)){var d=ra(a,!1);d&&(d.rot>180||d.rot<=-180)&&(d.rot=xa(d.rot),a.style[Pe]=ta(d))}}}}function Ra(){return{get:function(a,b,c){return La(Oa(a).style)},set:function(a,b){var c=Ka(b,"strokeStyle"),d=Oa(a);d.style&&(d.style=null,bb(a,d,!0)),d.style=c,a.style.turtlePenStyle=La(c),bb(a,d,!0)}}}function Sa(){return{get:function(a,b,c){return Na(Oa(a).down)},set:function(a,b){var c=Ma(b);if(c!==He){var d=Oa(a);c!=d.down&&(d.down=c,d.quickpagexy=null,d.quickhomeorigin=null,a.style.turtlePenDown=Na(c),bb(a,d,!0))}}}}function Ta(a,b){return 0===Math.round(a.pageX-b.pageX)&&0===Math.round(a.pageY-b.pageY)}function Ua(a,b){return 0===Math.round(1e3*(a.pageX-b.pageX))&&0===Math.round(1e3*(a.pageY-b.pageY))}function Va(a,b){return Ta(a,b)&&0===Math.round(a.pageX-b.pageX1)&&0===Math.round(a.pageY-b.pageY1)&&0===Math.round(b.pageX2-b.pageX)&&0===Math.round(b.pageY2-b.pageY)}function Wa(a){var b=1e3*a,c=Math.round(b);return Math.abs(c-b)<Math.abs(5e-15*b)?c/1e3:a}function Xa(a,b,c){c=c||1;var d=b.eraseMode?1:0;if(b&&"strokeStyle"in b||(a.strokeStyle="black"),b&&"lineWidth"in b||(a.lineWidth=1.62*c+d),b&&"lineCap"in b||(a.lineCap="round"),b&&"lineJoin"in b||(a.lineJoin="round"),b)for(var e in b)"savePath"!==e&&"eraseMode"!==e&&(c&&"lineWidth"===e?a[e]=c*b[e]+d:"lineDash"===e?a.setLineDash((""+b[e]).split(/[,\s]/g)):a[e]=b[e])}function Ya(a){if(a){if(a===Re.canvas)return[Re.subpixel,0,0,Re.subpixel];var b,c=z(a.parentElement),d=m(c),e={},f=G(a,d,e),g=e.gbcr,h=[1,0,0,1,-f[0],-f[1]],i=g.width&&g.height&&[a.width/g.width,0,0,a.height/g.height],k=x(a)||[1,0,0,1],l=n(k);if(d&&l&&i)return b=j(j(j(i,l),d),h),b[4]+=e.localorigin[0]*i[0],b[5]+=e.localorigin[1]*i[3],b}}function Za(a,b){if(b===Re.canvas)a.setTransform(Re.subpixel,0,0,Re.subpixel,0,0);else{var c=Ya(b);c&&a.setTransform.apply(a,c)}}function $a(a,b,c,d,e){var f,g,h,i=a.getContext("2d"),j=b.length;for(i.save(),Za(i,a),i.beginPath(),Xa(i,c,d);j--;)if(b[j].length>1){h=b[j],f=h.length>2&&Ta(h[0],h[h.length-1])&&!Ta(h[0],h[Math.floor(h.length/2)]),g=f&&!("pageX2"in h[h.length-1]);var k=h[0].pageX,l=h[0].pageY;i.moveTo(k,l);for(var m=1;m<h.length-(g?1:0);++m)"pageX2"in h[m]&&!Va(h[m-1],h[m])?i.bezierCurveTo(h[m].pageX1,h[m].pageY1,h[m].pageX2,h[m].pageY2,h[m].pageX,h[m].pageY):i.lineTo(h[m].pageX,h[m].pageY);f&&i.closePath()}"fillStyle"in c&&i.fill(),"strokeStyle"in c&&i.stroke(),i.restore(),b.length=1,b[0].splice(0,Math.max(0,b[0].length-e))}function _a(a,b,c){a.length&&Ta(b,a[a.length-1])||a.push(b);for(var d=0;d<c.length;++d)a.push({pageX1:c[d][0].pageX,pageY1:c[d][0].pageY,pageX2:c[d][1].pageX,pageY2:c[d][1].pageY,pageX:c[d][2].pageX,pageY:c[d][2].pageY})}function ab(a,b){a.length&&(b.corner?Ua(b,a[a.length-1]):Ta(b,a[a.length-1]))||a.push(b)}function bb(a,b,c){if(Z(a),b){var d=b.path,e=b.style,f=b.corners;if(!e||!b.down)return d.length>1&&(d.length=1),d[0].length&&(d[0].length=0),void(c&&(e?f.length&&f[0].length&&(1==f[0].length?f[0].length=0:f.unshift([])):(f.length>1&&(f.length=1),f[0].length&&(f[0].length=0))));if(c||!e.savePath){var g=Y(a);if(c&&(g.corner=!0,ab(f[0],g)),!e.savePath){ab(d[0],g);var h=Kc(a);$a(Da(b),b.path,e,h,2)}}}}function cb(b,c){var d=Oa(b);d.style&&(c=a.extend({},d.style,c));var e=Kc(b);$a(Da(d),d.corners,c,e,1)}function db(b){if((!b||/\bcanvas\b/.test(b))&&Re.canvas){var c=Re.canvas.getContext("2d");c.save(),c.setTransform(1,0,0,1,0,0),c.clearRect(0,0,Re.canvas.width,Re.canvas.height),c.restore()}if((!b||/\bturtles\b/.test(b))&&Re.surface){var d=a(Re.surface).find(".turtle").not(".turtlefield");pf&&(d=d.not(pf)),d.remove()}if((!b||/\blabels\b/.test(b))&&Re.surface){var d=a(Re.surface).find(".turtlelabel").not(".turtlefield");d.remove()}(!b||/\btext\b/.test(b))&&a("body").contents().not(".turtlefield").remove()}function eb(a,b){if(!a||a.length<1)return null;for(var c=1,d={left:Math.floor(a[0].pageX),top:Math.floor(a[0].pageY),right:Math.ceil(a[0].pageX),bottom:Math.ceil(a[0].pageY)};c<a.length;++c)d.left=Math.min(d.left,Math.floor(a[c].pageX)),d.top=Math.min(d.top,Math.floor(a[c].pageY)),d.right=Math.max(d.right,Math.ceil(a[c].pageX)),d.bottom=Math.max(d.bottom,Math.ceil(a[c].pageY));return b&&(d.left=Math.max(b.left,d.left),d.top=Math.max(b.top,d.top),d.right=Math.min(b.right,d.right),d.bottom=Math.min(b.bottom,d.bottom)),d}function fb(a,b){if(!a||!b)return null;if(4==a.length&&l(a))return b;var c,d,e=[];for(c=0;c<b.length;++c)d=i(a,[b[c].pageX,b[c].pageY]),e.push({pageX:d[0],pageY:d[1]});return e}function gb(a,b){if(!a)return!1;var c=ed(b),d=Ea(a);if(!d)return c&&0==c[3];var e=Ya(d),f=_(a),g=fb(e,f),h=eb(g,{left:0,top:0,right:d.width,bottom:d.height}),i=h.right-h.left,j=h.bottom-h.top,k=Ga(i,j),l=k.getContext("2d"),m=1;if(!g||g.length<3||!i||!j)return!1;for(l.drawImage(d,h.left,h.top,i,j,0,0,i,j),l.save(),l.beginPath(),l.moveTo(0,0),l.lineTo(i,0),l.lineTo(i,j),l.lineTo(0,j),l.closePath(),l.moveTo(g[0].pageX-h.left,g[0].pageY-h.top);m<g.length;m+=1)l.lineTo(g[m].pageX-h.left,g[m].pageY-h.top);l.closePath(),l.clip(),c&&0==c[3]?l.fillRect(0,0,i,j):l.clearRect(0,0,i,j),l.restore();var n=l.getImageData(0,0,i,j).data;if(c&&0!=c[3]){for(m=0;m<n.length;m+=4)if(Math.abs(n[m+0]-c[0])<=3&&Math.abs(n[m+1]-c[1])<=3&&Math.abs(n[m+2]-c[2])<=3&&n[m+3]<=2*c[3]&&n[m+3]>=c[3]/2)return!0}else{var o=!c;for(m=0;m<n.length;m+=4)if(n[m+3]>0==o)return!0}return!1}function hb(a,b,c){if(b.img)("CANVAS"==a[0].tagName||a[0].tagName==b.img.tagName)&&Kb(b.img,a[0],b.css);else if("IMG"==a[0].tagName||"CANVAS"==a[0].tagName)Hb(a[0],b.url,b.css,c),c=null;else{var d={backgroundImage:"url("+b.url+")",backgroundRepeat:"no-repeat",backgroundPosition:"center"};b.css.width&&b.css.height&&(d.backgroundSize=b.css.width+"px "+b.css.height+"px"),a.css(d)}c&&c()}function ib(b,c,d){var e,f=ra(b,!0),g=f&&wa(f.rot),h=Gc(b),i=f&&c*h,j=f&&(d||0)*h,k=-Math.cos(g)*i,l=Math.sin(g)*i,m=a.data(b,"turtleData");f&&(d&&(k+=Math.sin(g)*j,l+=Math.cos(g)*j),m&&(e=m.quickpagexy)&&(m.quickpagexy={pageX:e.pageX+l,pageY:e.pageY+k}),f.tx+=l,f.ty+=k,b.style[Pe]=ta(f),bb(b,m,!0))}function jb(b,c,d){var e,f=ra(b,!0),g=a.data(b,"turtleData");f&&(g&&(e=g.quickpagexy)&&(g.quickpagexy={pageX:e.pageX+c,pageY:e.pageY-d}),f.tx+=c,f.ty-=d,b.style[Pe]=ta(f),bb(b,g,!0))}function kb(a,b){var c=ra(a,!0);c&&(c.rot+=b,a.style[Pe]=ta(c))}function lb(a,b,c){var d=ra(a,!0);if(d){var e=Gc(a),f=wa(d.rot),g=b*e,h=(c||0)*e,i=-Math.cos(f)*g,j=Math.sin(f)*g;return h&&(i+=Math.sin(f)*h,j+=Math.cos(f)*h),sa(d.tx+j)+" "+sa(d.ty+i)}}function mb(b){return b&&a.isNumeric(b.pageX)&&a.isNumeric(b.pageY)}function nb(){return{get:function(a,b,c){return Oa(a).speed},set:function(b,c){(a.isNumeric(c)&&!(0>=c)||c in a.fx.speeds||""+c=="Infinity")&&(Oa(b).speed=""+c)}}}function ob(){return{get:function(a,b,c){return Oa(a).easing},set:function(b,c){c in a.easing&&(Oa(b).easing=c)}}}function pb(b,c){var d=a.data(b,"turtleData");return c=c||Df,d?a.isNumeric(d.speed)||"Infinity"==d.speed?1e3/d.speed:"turtle"==d.speed&&c?0:d.speed:c?0:"turtle"}function qb(b){var c=a.data(b,"turtleData");return c?c.easing:null}function rb(){return{get:function(a,b,c){var d=ra(a,b),e=y(a);if(d){var f=wa(d.rot),g=Math.cos(f),h=Math.sin(f),i=Gc(a);return sa(((d.tx+e[0])*h-(d.ty+e[1])*g)/i)+"px"}},set:function(b,c){var d,e=ra(b,!0)||{tx:0,ty:0,rot:0,sx:1,sy:1,twi:0},f=y(b),g=Gc(b),h=parseFloat(c)*g,i=wa(e.rot),j=Math.cos(i),k=Math.sin(i),l=(e.tx+f[0])*j+(e.ty+f[1])*k,m=l*j+h*k-f[0],n=l*k-h*j-f[1],o=a.data(b,"turtleData");o&&(d=o.quickpagexy)&&(o.quickpagexy={pageX:d.pageX+(m-e.tx),pageY:d.pageY+(n-e.ty)}),e.tx=m,e.ty=n,b.style[Pe]=ta(e),bb(b,o)}}}function sb(b,c,d,e){return{get:function(a,c,e){var f=ra(a,c);return f?f[b]+d:void 0},set:function(d,f){var g,h=ra(d,!0)||{tx:0,ty:0,rot:0,sx:1,sy:1,twi:0},i={displace:e},j=a.data(d,"turtleData"),k=h.tx,l=h.ty;h[b]=c(f,d,h,i),d.style[Pe]=ta(h),i.displace?(j&&(g=j.quickpagexy)&&(j.quickpagexy={pageX:g.pageX+(h.tx-k),pageY:g.pageY+(h.ty-l)}),bb(d,j)):Z(d)}}}function tb(a,b,c){var d=ya(b-a),e=d>0?c:-c,f=wa(a),g=[Math.cos(f)*e,Math.sin(f)*e],h=wa(b);return{delta:d,sradius:e,dc:g,dx:g[0]-Math.cos(h)*e,dy:g[1]-Math.sin(h)*e}}function ub(a,b,c,d,e,f){var g,h,j,k,l,m,n,o,p,r,t,u=tb(c,d,e),w=u.sradius,x=u.dc;for(n=1,o=u.delta,p=Math.abs(u.delta),p>45&&(n=Math.ceil(p/45),o=u.delta/n),r=[];--n>=0;)g=0===n?d:c+o,h=wa(c+180),j=wa(g+180),r.push.apply(r,v(h,j)),c=g;for(t=[],k=0;k<r.length;k++)l=i(f,q(s(r[k],w),x)),t.push({pageX:l[0]+b.pageX,pageY:l[1]+b.pageY});for(m=[],k=0;k<t.length;k+=3)m.push(t.slice(k,k+3));return _a(a,b,m),u}function vb(b,c,d,e){b=parseFloat(b);var f=a.data(c,"turtleData"),g=f?f.turningRadius:0;if(0===g||d.rot==b)return e.displace=!1,0===g?xa(b):b;var h,i=f&&f.style&&f.down,j=f&&f.oldscale?d.sy:1,k=g*j;return h=i?ub(f.path[0],Y(c),d.rot,b,k,z(c.parentElement)):tb(d.rot,b,k),d.tx+=h.dx,d.ty+=h.dy,e.displace=!0,b}function wb(b){return function(c){c.delta||(c.delta=ya(c.end-c.start),c.start=c.end-c.delta),a.cssHooks[b].set(c.elem,c.start+c.delta*c.pos)}}function xb(b,c){b.length&&"_"===b[0]&&(b=b.substring(1));for(var d=a.map((""+b).split(/\s+/),parseFloat);d.length<2;)d.push(c?d.length?d[d.length-1]:1:0);return d}function yb(b,c){return function(d){if(!d.delta){var e=xb(d.end,!c);d.start=xb(d.start,!c),d.delta=[e[0]-d.start[0],e[1]-d.start[1]]}a.cssHooks[b].set(d.elem,[d.start[0]+d.delta[0]*d.pos,d.start[1]+d.delta[1]*d.pos].join(" "))}}function zb(b,c,d,e){return{get:function(a,b,f){var g=ra(a,b);return g?e||g[c]!=g[d]?(""===f?"_":"")+g[c]+" "+g[d]:""+g[c]:void 0},set:function(b,f,g){var h,i=ra(b,!0)||{tx:0,ty:0,rot:0,sx:1,sy:1,twi:0},j="string"==typeof f?f.split(/\s+/):[f],k=a.data(b,"turtleData"),l=i.tx,m=i.ty;j.length<1||j.length>2||(j.length>=1&&(i[c]=parseFloat(j[0])),j.length>=2?i[d]=parseFloat(j[1]):e?i[d]=0:i[d]=i[c],b.style[Pe]=ta(i),e?(k&&(h=k.quickpagexy)&&(k.quickpagexy={pageX:h.pageX+(i.tx-l),pageY:h.pageY+(i.ty-m)}),bb(b,k)):Z(b))}}}function Ab(a){return Se.href=a,Se}function Bb(a){return Ab(a).href}function Cb(a){return/(?:^|\.)pencil(?:code)?\./i.test(a)}function Db(a){var b=Ab(null==a?"":a).hostname,c=/^(\w+)\.pencil(?:code)?\./i.exec(b);return c?c[1]:null}function Eb(a,b){var c=Ab(null==a?"":a),d=c.href;return Cb(c.hostname)?/^\/(?:edit|home|code|load|save)(?:\/|$)/.test(c.pathname)&&(d=c.protocol+"//"+c.host+"/"+b+"/"+c.pathname.replace(/\/[^\/]*(?:\/|$)/,"")+c.search+c.hash):Cb(Ie.location.hostname)&&(d="/proxy/"+d),d}function Fb(a){return/\//.test(a)?a:(a="/img/"+a,Cb(Ie.location.hostname)?a:"//pencilcode.net"+a)}function Gb(){if(!document.cookie)return null;for(var a=document.cookie.split(/;\s*/),b=0;b<a.length;++b)if(/^login=/.test(a[b])){var c=unescape(a[b].substr(6)).split(":");if(c&&2==c.length)return{user:c[0],key:c[1]}}return null}function Hb(a,b,c,d){function e(a,b,c,d){b.getAttribute("data-loading")==a.src&&(b.removeAttribute("data-loading"),Kb(a,b,c)),d&&d()}var f,g=Ab(b);b=g.href,a.setAttribute("data-loading",b),b in Te?(f=Te[b],null===f.queue?e(f.img,a,c,d):(f.queue.push({elem:a,css:c,cb:d}),Jb(b,a,c))):(Te[b]=f={img:new Image,queue:[{elem:a,css:c,cb:d}]},Cb(g.hostname)&&(f.img.crossOrigin="Anonymous"),Jb(b,a,c),Ib(f.img,b,function(){var a,b=f.queue;if(f.queue=null,b)for(a=0;a<b.length;++a)e(f.img,b[a].elem,b[a].css,b[a].cb)}))}function Ib(a,b,c){function d(f){f||a.complete||a.src!=b?(a.removeEventListener("load",d),a.removeEventListener("error",d),clearTimeout(e),c()):e=setTimeout(d,100)}if(null==b&&(b=a.src),b==a.src&&(!b||a.complete))return void c();var e=null;a.addEventListener("load",d),a.addEventListener("error",d),a.src=b,d()}function Jb(a,b,c){/^data:/.test(a)&&c.width&&c.height&&Kb(null,b,c)}function Kb(b,c,d){var e,f=y(c),g=a(c),h="CANVAS"==c.tagName;if(h||(c.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"),g.css({backgroundImage:"none",height:"",width:"",turtleHull:"",transformOrigin:""}),b)if("VIDEO"==b.tagName)c.width=a(b).width(),c.height=a(b).height(),h&&(e=c.getContext("2d"),e.clearRect(0,0,c.width,c.height),e.drawImage(b,0,0,b.videoWidth,b.videoHeight,0,0,c.width,c.height));else if(c.width=b.width,c.height=b.height,h){if(b.width>0&&b.height>0)try{e=c.getContext("2d"),e.clearRect(0,0,b.width,b.height),e.drawImage(b,0,0)}catch(i){}}else c.src=b.src;d&&g.css(d);var j=y(c);if(b&&!d.turtleHull)try{var k=De(b);Ge(k,parseFloat(g.css("width"))/b.width,parseFloat(g.css("height"))/b.height,-j[0],-j[1]),g.css("turtleHull",k)}catch(i){}Lb(c,f,j)}function Lb(b,c,d){var e=a(b);if(e.hasClass("turtle")&&(d[0]!=c[0]||d[1]!=c[1]))if("absolute"==e.css("position")&&/px$/.test(e.css("left"))&&/px$/.test(e.css("top")))e.css("left",parseFloat(e.css("left"))+c[0]-d[0]),e.css("top",parseFloat(e.css("top"))+c[1]-d[1]);else{var f=ra(b,!0);f.tx+=c[0]-d[0],f.ty+=c[1]-d[1],b.style[Pe]=ta(f)}}function Mb(b,c,d,e,f){var g,h,i,j,k;return e===He&&f===He?(g=a(d),g.length?(h=g[0],i=N(h),S(_(h),i)?b.filter(function(){var b=N(this);return c===(R(i,b)||!Q(i,b)&&a(this).inside(h))}):b.filter(function(){return c===a(this).inside(h)})):[]):(j=a.isNumeric(e)&&a.isNumeric(f)?[e,f]:e,a.isArray(j)&&(j=X(b[0]||document.body,[j])[0]),"touch"===d?mb(j)?b.filter(function(){return c===a(this).touches(j)}):(g=a(j),i=N(g[0]),S(_(g[0]),i)?b.filter(function(){var a=N(this);return c===(!Q(i,a)&&(R(i,a)||g.touches(this)))}):b.filter(function(){return c===g.touches(this)})):(k=d*d,b.filter(function(){var a=N(this);if(O(j,k,a))return!c;if(P(j,k,a))return c;var b=Y(this),d=j.pageX-b.pageX,e=j.pageY-b.pageY;return c===k>=d*d+e*e})))}function Nb(){if(!Ze){Ze=!0;try{Ie.parent.document.activeElement.blur()}catch(a){}Ie.focus()}}function Ob(b,c,d,e,f){for(var g=e.split(/\s+/),h=0;h<g.length;++h){e=g[h];var i=b[e];i||(i=b[e]=a.extend({},d)),"function"!=typeof i[c]?i[c]=f:i[c]!=f&&(i[c].hooklist?i[c].hooklist.indexOf(f)<0&&i[c].hooklist.push(f):!function(){var a=[i[c],f];(i[c]=function(b,c){for(var d=b,e=0;e<a.length;++e)d=a[e](d,c)||d;return d}).hooklist=a}())}}function Pb(b,c){if(Re.field&&"pageX"in b&&"pageY"in b){var d=a(Re.field).offset();d&&(b.x=b.pageX-d.left,b.y=d.top-b.pageY)}return b}function Qb(a,b,c){return(Re.field&&!Re.fieldMouse&&this.parentElement===Re.field||/(?:^|\s)turtle(?:\s|$)/.test(this["class"]))&&(Re.fieldMouse=!0,Rb()),!1}function Rb(){Re.fieldHook||Re.surface&&Re.fieldMouse&&(Re.fieldHook=!0,setTimeout(function(){a("body").on("click.turtle dblclick.turtle mouseup.turtle mousedown.turtle mousemove.turtle",function(b){if(b.target===this&&!b.isTrigger){var c=a.turtle.nowarn;a.turtle.nowarn=!0;var d=a(Re.surface).find(".turtle,.turtlelabel").within("touch",b).eq(0);if(a.turtle.nowarn=c,1===d.length)return b.target=null,b.relatedTarget=null,b.fromElement=null,b.toElement=null,d.trigger(b),!1}})},0))}function Sb(){var b="mousedown mouseup mousemove click dblclick";Ob(a.event.fixHooks,"filter",a.event.mouseHooks,b,Pb),Ob(a.event.special,"setup",{},b,Qb)}function Tb(a,b){var c=a.which;c||(c=(b||a.originalEvent).whichSynth);var d=$e[c];return!d&&c&&(d=String.fromCharCode(c)),
a.key=d,a}function Ub(a,b){null!=a.charCode&&(a.key=String.fromCharCode(a.charCode))}function Vb(a){if("string"==typeof a.data){var b=a.data.replace(/\s/g,"").toLowerCase().split(","),c=a.handler,d=function(a){return b.indexOf(a.key)<0?void 0:c.apply(this,arguments)};c.guid&&(d.guid=c.guid),a.handler=d}}function Wb(){Ob(a.event.fixHooks,"filter",a.event.keyHooks,"keydown keyup",Tb),Ob(a.event.fixHooks,"filter",a.event.keyHooks,"keypress",Ub),Ob(a.event.special,"add",{},"keydown keyup keypress",Vb)}function Xb(){return{get:function(a,b,c){return g(Zb(a).getTimbre())},set:function(a,b){Zb(a).setTimbre(f(b,"wave"))}}}function Yb(){return{get:function(a,b,c){return Zb(a).getVolume()},set:function(a,b){Zb(a).setVolume(parseFloat(b))}}}function Zb(b){var c=Oa(b);if(c.instrument)return c.instrument;c.instrument=new ef("piano");var d=a(b);return c.instrument.on("noteon",function(b){var c=a.Event("noteon");c.midi=b.midi,d.trigger(c)}),c.instrument.on("noteoff",function(b){var c=a.Event("noteoff");c.midi=b.midi,d.trigger(c)}),c.instrument}function $b(){return af||(af=new ef),af}function _b(){return!(!Ie.AudioContext&&!Ie.webkitAudioContext)}function ac(){if(ac.audioTop)return ac.audioTop;if(!_b())return null;var a=new(Ie.AudioContext||Ie.webkitAudioContext);return ac.audioTop={ac:a,wavetable:jc(a),out:null,currentStart:null},bc(),ac.audioTop}function bc(){if(ac.audioTop){var a=ac.audioTop;a.out&&(a.out.disconnect(),a.out=null,a.currentStart=null);try{var b=a.ac.createDynamicsCompressor();b.ratio=16,b.attack=5e-4,b.connect(a.ac.destination),a.out=b}catch(c){ac.audioTop=null}}}function cc(){var a=ac();return null!=a.currentStart?a.currentStart:(a.currentStart=Math.max(.25,a.ac.currentTime),setTimeout(function(){a.currentStart=null},0),a.currentStart)}function dc(a){return 440*Math.pow(2,(a-69)/12)}function ec(a){return Math.round(69+12*Math.log(a/440)/Math.LN2)}function fc(a){var b=/^(\^+|_+|=|)([A-Ga-g])([,']*)$/.exec(a);if(!b)return null;var c=b[3].replace(/,/g,"").length-b[3].replace(/'/g,"").length,d=bf[b[2]]+cf[b[1].charAt(0)]*b[1].length+12*c;return d+60}function gc(a){var b=(a-72)%12;(a>60||0!=b)&&(b+=12);for(var c=Math.round((a-b-60)/12),d=df[b];0!=c;)d+=c>0?"'":",",c+=c>0?-1:1;return d}function hc(a){return dc(fc(a))}function ic(a){function b(a,b){switch(a){case"V":A!==z&&c(b.split(" ")[0]);break;case"M":f(b,A);break;case"L":g(b,A);break;case"Q":h(b,A)}A.hasOwnProperty(a)?A[a]+="\n"+b:A[a]=b,"K"==a&&(B=k(b),A===z&&c(d()))}function c(a){a=a||"",(a||A===z)&&(z.voice||(z.voice={}),z.voice.hasOwnProperty(a)?(A=z.voice[a],C=A.accent):(A={id:a,accent:{slurred:0}},z.voice[a]=A,C=A.accent))}function d(){return z.V?z.V.split(/\s+/)[0]:""}function e(a){var e,f=a.match(gf),g=null,h=0,i=0,j=null;if(!f)return null;for(;h<f.length;)if(/^[\s%]/.test(f[h]))h++;else if(/^\[[A-Za-z]:[^\]]*\]$/.test(f[h]))b(f[h].substring(1,2),f[h].substring(3,f[h].length-1).trim()),h++;else if(/</.test(f[h]))i=-f[h++].length;else if(/>/.test(f[h]))i=f[h++].length;else if(/^\(\d+(?::\d+)*/.test(f[h]))j=o(f[h++]);else if(/^[!+].*[!+]$/.test(f[h]))p(f[h++],C);else if(/^.?".*"$/.test(f[h]))h++;else if(/^[()]$/.test(f[h]))"("==f[h++]?C.slurred+=1:(C.slurred-=1,C.slurred<=0&&(C.slurred=0,A.stems&&A.stems.length>=1&&m(A.stems[A.stems.length-1],!1)));else if(/\|/.test(f[h])){for(e in C)1==e.length&&delete C[e];h++}else g=q(f,h,B,C),null!==g?(j&&(n(g.stem,j.time),j.count-=1,j.count||(j=null)),i&&A.stems&&A.stems.length&&(e=i>0?(1-Math.pow(.5,i))*g.stem.time:(Math.pow(.5,-i)-1)*A.stems[A.stems.length-1].time,l(A.stems[A.stems.length-1],e),l(g.stem,-e)),i=0,C.slurred&&m(g.stem,!0),A===z&&c(d()),"stems"in A||(A.stems=[]),A.stems.push(g.stem),h=g.index):h++}function f(a,b){var c=/^C/.test(a)?1:t(a);c&&(b.unitnote||(.75>c?b.unitnote=1/16:b.unitnote=1/8))}function g(a,b){var c=t(a);c&&(b.unitnote=c)}function h(a,b){var c,d=a.split(/\s+|=/),e=null,f=null;for(c=0;c<d.length;++c)d[c].indexOf("/")>=0||/^[1-4]$/.test(d[c])?e=e||t(d[c]):f=f||Number(d[c]);e&&(b.unitbeat=e),f&&(b.tempo=f)}function i(a){var b,c,d,e,f,g={};for(c=0;c<a.length;++c){for(b={},d=0;d<a[c].notes.length;++d)f=e=a[c].notes[d],g.hasOwnProperty(e.pitch)&&(f=g[e.pitch],f.time+=e.time,e.holdover=!0),e.tie&&(b[e.pitch]=f);g=b}}function j(a){var b,c="FCGDAEB",d={};if(!a)return d;if(a>0)for(b=0;a>b&&7>b;++b)d[c.charAt(b)]="^";else for(b=0;b>a&&b>-7;--b)d[c.charAt(6+b)]="_";return d}function k(a){if(!a)return{};var b,c={"c#":7,"f#":6,b:5,e:4,a:3,d:2,g:1,c:0,f:-1,bb:-2,eb:-3,ab:-4,db:-5,gb:-6,cb:-7,"a#m":7,"d#m":6,"g#m":5,"c#m":4,"f#m":3,bm:2,em:1,am:0,dm:-1,gm:-2,cm:-3,fm:-4,bbm:-5,ebm:-6,abm:-7,"g#mix":7,"c#mix":6,"f#mix":5,bmix:4,emix:3,amix:2,dmix:1,gmix:0,cmix:-1,fmix:-2,bbmix:-3,ebmix:-4,abmix:-5,dbmix:-6,gbmix:-7,"d#dor":7,"g#dor":6,"c#dor":5,"f#dor":4,bdor:3,edor:2,ador:1,ddor:0,gdor:-1,cdor:-2,fdor:-3,bbdor:-4,ebdor:-5,abdor:-6,dbdor:-7,"e#phr":7,"a#phr":6,"d#phr":5,"g#phr":4,"c#phr":3,"f#phr":2,bphr:1,ephr:0,aphr:-1,dphr:-2,gphr:-3,cphr:-4,fphr:-5,bbphr:-6,ebphr:-7,"f#lyd":7,blyd:6,elyd:5,alyd:4,dlyd:3,glyd:2,clyd:1,flyd:0,bblyd:-1,eblyd:-2,ablyd:-3,dblyd:-4,gblyd:-5,cblyd:-6,fblyd:-7,"b#loc":7,"e#loc":6,"a#loc":5,"d#loc":4,"g#loc":3,"c#loc":2,"f#loc":1,bloc:0,eloc:-1,aloc:-2,dloc:-3,gloc:-4,cloc:-5,floc:-6,bbloc:-7},d=a.replace(/\s+/g,"").toLowerCase().substr(0,5),e=d.match(/maj|min|mix|dor|phr|lyd|loc|m/);b=e?"maj"==e?d.substr(0,e.index):"min"==e?d.substr(0,e.index+1):d.substr(0,e.index+e[0].length):/^[a-g][#b]?/.exec(d)||"";var f=j(c[b]),g=a.substr(b.length).match(/(_+|=|\^+)[a-g]/gi);if(g)for(var h=0;h<g.length;++h){var i=g[h].charAt(g[h].length-1).toUpperCase();"="==g[h].charAt(0)?delete f[i]:f[i]=g[h].substr(0,g[h].length-1)}return f}function l(a,b){var c,d,e=a.time,f=e+b;for(a.time=f,c=0;c<a.notes.length;++c)d=a.notes[c],d.time==e&&(d.time=f)}function m(a,b){var c,d;for(c=0;c<a.notes.length;++c)d=a.notes[c],b?d.slurred=!0:d.slurred&&delete d.slurred}function n(a,b){var c;for(a.time*=b,c=0;c<a.notes.length;++c)a.notes[c].time*=b}function o(a){var b=/^\((\d+)(?::(\d+)(?::(\d+))?)?$/.exec(a);if(!b)return null;var c=Number(b[1]),d=Number(b[2])||2,e=Number(b[3])||c;return{time:d/c,count:e}}function p(a,b){if(!(a.length<2))switch(a=a.substring(1,a.length-1)){case"pppp":case"ppp":b.dynamics=.2;break;case"pp":b.dynamics=.4;break;case"p":b.dynamics=.6;break;case"mp":b.dynamics=.8;break;case"mf":b.dynamics=1;break;case"f":b.dynamics=1.2;break;case"ff":b.dynamics=1.4;break;case"fff":case"ffff":b.dynamics=1.5}}function q(a,b,c,d){var e,f,g,h,i=[],j="",k=!1,l=null,m=1/0;if(b<a.length&&"."==a[b]&&(k=!0,b++),b<a.length&&"["==a[b]){for(b++;b<a.length;)if(/^[\s%]/.test(a[b]))b++;else{if(/[A-Ga-g]/.test(a[b]))l={pitch:s(a[b++],c,d),tie:!1},l.frequency=hc(l.pitch),i.push(l);else{if(!/[xzXZ]/.test(a[b])){if("."==a[b]){k=!0,b++;continue}break}l=null,b++}b<a.length&&/^(?![\s%!]).*[\d\/]/.test(a[b])?(e=a[b++],f=t(e)):(e="",f=1),l&&(l.duration=e,l.time=f),f&&m>f&&(j=e,m=f),b<a.length&&"-"==a[b]&&(l&&(i[i.length-1].tie=!0),b++)}if("]"!=a[b])return null;b++}else if(b<a.length&&/[A-Ga-g]/.test(a[b]))l={pitch:s(a[b++],c,d),tie:!1,duration:"",time:1},l.frequency=hc(l.pitch),i.push(l);else{if(!(b<a.length&&/^[xzXZ]$/.test(a[b])))return null;b++}if(b<a.length&&/^(?![\s%!]).*[\d\/]/.test(a[b]))for(j=a[b++],f=t(j),h=0;h<i.length;++h)i[h].duration=j,i[h].time=f;if(b<a.length&&"-"==a[b])for(b++,h=0;h<i.length;++h)i[h].tie=!0;if(d.dynamics)for(g=d.dynamics,h=0;h<i.length;++h)i[h].velocity=g;return{index:b,stem:{notes:i,duration:j,staccato:k,time:t(j)}}}function r(a){return a.length>0&&"="==a.charAt(0)?a.substr(1):a}function s(a,b,c){var d,e=/^(\^+|_+|=|)([A-Ga-g])(.*)$/.exec(a);return e?(d=e[2].toUpperCase(),e[1].length>0?(c[d]=e[1],r(a)):r(c.hasOwnProperty(d)?c[d]+e[2]+e[3]:b.hasOwnProperty(d)?b[d]+e[2]+e[3]:a)):a}function t(a){var b,c,d,e=/^(\d*)(?:\/(\d*))?$|^(\/+)$/.exec(a),f=0;if(e){if(e[3])return Math.pow(.5,e[3].length);if(c=e[2]?parseFloat(e[2]):/\//.test(a)?2:1,d=0,b=e[1]?parseFloat(e[1]):1,e[2])for(;d+1<e[1].length&&b>c;)d+=1,f=parseFloat(e[1].substring(0,d)),b=parseFloat(e[1].substring(d));return f+b/c}}var u,v,w,x,y=a.split("\n"),z={},A=z,B={},C={slurred:0};for(u=0;u<y.length;++u)if(w=ff.exec(y[u]))b(w[1],w[2].trim());else{if(/^\s*(?:%.*)?$/.test(y[u]))continue;e(y[u])}var D=["unitnote","unitbeat","tempo"];if(z.voice){x=[];for(u in z.voice)if(z.voice[u].stems&&z.voice[u].stems.length){for(i(z.voice[u].stems),v=0;v<D.length;++v)!(D[v]in z)&&D[v]in z.voice[u]&&(z[D[v]]=z.voice[u][D[v]]);delete z.voice[u].accent}else x.push(u);for(u=0;u<x.length;++u)delete z.voice[x[u]]}return z}function jc(a){return function(b){function c(b){var c,d=b.real.length,e=new Float32Array(d),f=new Float32Array(d);for(c=0;d>c;++c)e[c]=b.real[c],f[c]=b.imag[c];try{return a.createPeriodicWave(e,f)}catch(g){}try{return a.createWaveTable(e,f)}catch(g){}return null}function d(a,b,c){var d,e,f={real:[],imag:[]},g=a.real.length;for(d=0;g>d;++d)e=Math.log(b[Math.min(d,b.length-1)]),f.real.push(a.real[d]*Math.exp(c*e)),f.imag.push(a.imag[d]*Math.exp(c*e));return f}var e,f,g,h,i,j,k={};for(e in b)if(f=b[e],j=c(f)){if(i={wave:j},f.mult)for(h=b[e].freq,i.freq={},g=0;g<h.length;++g)j=c(d(f,f.mult,(g+1)/h.length)),j&&(i.freq[h[g]]=j);f.defs&&(i.defs=f.defs),k[e]=i}return k}({piano:{real:[0,0,-.203569,.5,-.401676,.137128,-.104117,.115965,-.004413,.067884,-.00888,.0793,-.038756,.011882,-.030883,.027608,-.013429,.00393,-.014029,.00972,-.007653,.007866,-.032029,.046127,-.024155,.023095,-.005522,.004511,-.003593,.011248,-.004919,.008505],imag:[0,.147621,0,7e-6,-1e-5,5e-6,-6e-6,9e-6,0,8e-6,-1e-6,14e-6,-8e-6,3e-6,-9e-6,9e-6,-5e-6,2e-6,-7e-6,5e-6,-5e-6,5e-6,-23e-6,37e-6,-21e-6,22e-6,-6e-6,5e-6,-4e-6,14e-6,-7e-6,12e-6],mult:[1,1,.18,.016,.01,.01,.01,.004,.014,.02,.014,.004,.002,1e-5],freq:[65,80,100,135,180,240,620,1360],defs:{wave:"piano",gain:.5,attack:.002,decay:.25,sustain:.03,release:.1,decayfollow:.7,cutoff:800,cutfollow:.1,resonance:1,detune:.9994}}})}function kc(b){var c,d,e=[],f=b.length;for(f&&a.isFunction(b[f-1])&&(d=b[--f]),c=0;f>c;++c)b[c]&&(b[c].constructor===a?e.push.apply(e,b[c].toArray()):a.isArray(b[c])?e.push.apply(e,b[c]):e.push(b[c]));return{elts:a.unique(e),completion:d}}function lc(){function b(){var a,b=g;for(g=null,f&&f(),a=0;a<b.length;++a)b[a]()}var c,d=kc(arguments),e=d.elts,f=d.completion,g=[];if(e.length>1)for(c=0;c<e.length;++c)Uc(e[c]),a(e[c]).queue(function(a){g&&(g.push(a),g.length==e.length&&b())})}function mc(){var b,c=kc(arguments),d=c.elts,e=c.completion,f=d.length;for(b=0;b<d.length;++b)a(d[b]).queue(function(b){a(this).remove(),f-=1,e&&0==f&&e(),b()})}function nc(a){Sf.html('<aside style="line-height:133%;word-break:normal;white-space:normal">'+a+"</aside>")}function oc(b){var c,d,e=a.extend({},sf,hf,tf);if(b&&!a.isArray(b.helptext)&&b in e&&(b=e[b]),b&&a.isArray(b.helptext)&&b.helptext.length){for(d=0;d<b.helptext.length;++d){var f=b.helptext[d];nc(f.replace(/<(u)>/g,'<$1 style="border:1px solid black;text-decoration:none;word-break:keep-all;white-space:nowrap">').replace(/<(mark)>/g,'<$1 style="border:1px solid blue;color:blue;text-decoration:none;word-break:keep-all;white-space:nowrap;cursor:pointer;" onclick="see.enter($(this).text())">'))}return vf}if("number"==typeof b)return nc("Equal to the number "+b+"."),vf;if("boolean"==typeof b)return nc("Equal to the boolean value "+b+"."),vf;if(null===b)return nc("The special null value represents the absence of a value."),vf;if(b===He)return nc("This is an unassigned value."),vf;if(b===Ie)return nc("The global window object represents the browser window."),vf;if(b===document)return nc("The HTML document running the program."),vf;if(b===jQuery)return nc('The jQuery function. Read about it at <a href="http://learn.jquery.com/" target="_blank">jquery.com</a>.'),vf;if(b&&b!=oc)return nc("No help available for "+b),vf;c=[];for(var g in e)!e[g].helptext||!e[g].helptext.length||g in Ie&&"function"!=typeof Ie[g]||c.push(g);return c.sort(function(a,b){return a.length!=b.length?a.length-b.length:b>a?-1:a>b?1:0}),nc("help available for: "+c.map(function(a){return'<mark style="border:1px solid blue;color:blue;text-decoration:none;word-break:keep-all;white-space:nowrap;cursor:pointer;" onclick="see.enter($(this).text())">'+a+"</mark>"}).join(" ")),vf}function pc(a){return 1==a.length&&qc(a[0])&&a[0]}function qc(b){var c;return!(!b||0!=a.queue(b).length||b.parentElement&&b.parentElement.style.transform||0!==(c=pb(b))&&0!==a.fx.speeds[c])}function rc(b,c){var d;if(null==c){if(qc(b))return;d=pb(b)}else d=1e3*c;var e=a(b);d>0&&e.delay(d)}function sc(a,b){if(b=b||0,a.length<=b)return null;var c=a[a.length-1];return"function"!=typeof c||c.helpname?null:c}function tc(b,c,d,e){function f(d,e){if(null!=d){var f=b&&b[d];e&&f&&bb(f,a.data(f,"turtleData"),!0),Hf.reportEvent("resolve",[c,m,j,d,f])}0==--k&&h&&(l?(Me+=1,setTimeout(function(){Me-=1,h()},0)):h())}function g(a){null!=a&&Hf.reportEvent("appear",[c,m,j,a,b&&b[a],i])}var h=sc(d,e),i=h?Array.prototype.slice.call(d,0,d.length-1):d,j=b?b.length||0:0,k=j+1,l=!0,m=Hf.nextId();return Hf.reportEvent("enter",[c,m,j,i]),{name:c,args:i,appear:g,resolve:f,resolver:function(a,b){return function(){f(a,b)}},exit:function(){Hf.reportEvent("exit",[c,m,j,i]),f(null),l=!1}}}function uc(b,c,d,e){var f=function(){if(Vc(b),Le)throw new Error(b+" interrupted");var d,f=tc(this,b,arguments,c),g=[f].concat(a.makeArray(f.args));try{d=e.apply(this,g)}finally{f.exit()}return d};return zc(b,d,f)}function vc(a,b,c){var d=function(){if(Vc(a),Le)throw new Error(a+" interrupted");return Wc(a,this),c.apply(this,arguments)};return zc(a,b,d)}function wc(b,c,d,e){var f=function(){if(Vc(b),Le)throw new Error(b+" interrupted");var c=null,f=0,g=pf;if(e&&(c=e.apply(null,arguments),f=arguments.length,g=Yc()),g){var h=a(pf).eq(0),i=arguments,j=tc(h,b,arguments,f);h.plan(function(a,b){j.appear(a),d.apply(c,i),this.plan(j.resolver(a))}),j.exit()}else j=tc(null,b,arguments,f),d.apply(c,arguments),j.exit();return c?(c.result&&c.result.constructor===jQuery&&pf&&lc(pf,c.result),c.result):void 0};return zc(b,c,f)}function xc(b,c){return zc(b,c,function(c,d){var e=/^key/.test(b),f=/^mouse|click$/.test(b),g=f?"input,button":e?"textarea,input:not([type]),input[type=text],input[type=password]":null;e&&Nb(),null==d&&"function"==typeof c&&(d=c,c=null),a(Ie).on(b+".turtleevent",null,c,g?function(b){return Le||a(b.target).closest(g).length?void 0:d.apply(this,arguments)}:d)})}function yc(){var b=a._data(Ie,"events");if(!b)return!1;for(var c in b)for(var d=b[c],e=0;e<d.length;++e)if("turtleevent"==d[e].namespace)return!0;return!1}function zc(a,b,c){return c.helpname=a,c.helptext=b,c}function Ac(a,b,c){b=null==b?90:ya(b);var d,e="lt"===a.name,f=Df;if((d=pc(this))&&(0===c||null==c&&0===Pa(d)))return a.appear(0),kb(d,e?-b:b),a.resolve(0),this;var g=e?"-=":"+=";return null==c?(this.plan(function(c,d){a.appear(c),this.animate({turtleRotation:g+sa(b||0)+"deg"},pb(d,f),qb(d),a.resolver(c))}),this):(this.plan(function(d,h){a.appear(d);var i=Oa(h),j=i.turningRadius,k=0>b?-c:c,l=null;i.style&&i.down&&(l=function(){var a=Y(h),c=ra(h,!0),d=z(h.parentElement);return function(){ub(i.corners[0],a,c.rot,c.rot+(e?-b:b),k*(i.oldscale?c.sy:1),d)}}()),i.turningRadius=k,this.animate({turtleRotation:g+sa(b)+"deg"},pb(h,f),qb(h)),this.plan(function(){l&&l(),i.turningRadius=j,a.resolve(d,!0)})}),this)}function Bc(a,b){null==b&&(b=100),"bk"===a.name&&(b=-b);var c,d=Df;return(c=pc(this))?(a.appear(0),ib(c,b,0),a.resolve(0,!0),this):(this.plan(function(c,e){a.appear(c),this.animate({turtleForward:"+="+sa(b||0)+"px"},pb(e,d),qb(e),a.resolver(c,!0))}),this)}function Cc(b,c,d){a.isArray(c)&&(d=c[1],c=c[0]),d||(d=0),c||(c=0);var e=Df;return this.plan(function(a,f){b&&b.appear(a),this.animate({turtlePosition:lb(f,d,c)},pb(f,e),qb(f),b&&b.resolver(a,!0))}),this}function Dc(b,c,d){a.isArray(c)&&(d=c[1],c=c[0]),d||(d=0),c||(c=0);var e,f=Df;return(e=pc(this))?(b&&b.appear(0),jb(e,c,d),b&&b.resolve(0),this):(this.plan(function(a,e){b&&b.appear(a);var g=w(e);this.animate({turtlePosition:sa(g[0]+c)+" "+sa(g[1]-d)},pb(e,f),qb(e),b&&b.resolver(a,!0))}),this)}function Ec(b,c,d){var e=c,f=0,g=0,h=null,i=Df;return a.isNumeric(e)&&a.isNumeric(d)?(f=parseFloat(e),g=parseFloat(d),e=null,h=null):a.isArray(e)?(f=e[0],g=e[1],e=null,h=d):a.isNumeric(d)&&(h=d),this.plan(function(c,d){var j=e;if(null===j&&(j=a(V(d)).pagexy()),j&&!mb(j))try{j=a(j).pagexy()}catch(k){return}return j&&mb(j)?a.isWindow(d)?(b&&b.appear(c),ba(j,h),void(b&&b.resolve(c))):void(9!==d.nodeType&&(b&&b.appear(c),this.animate({turtlePosition:U(d,j,h,f,g)},pb(d,i),qb(d),b&&b.resolver(c,!0)))):void 0}),this}function Fc(a){return function(b,c,d){return this.plan(function(e,f){b.appear(e);var g=this.css("turtlePenDown");this.css({turtlePenDown:"up"}),a.call(this,null,c,d),this.plan(function(){this.css({turtlePenDown:g}),b.resolve(e,!0)})}),this}}function Gc(b){var c=a.data(b,"turtleData");return c&&null!=c.oldscale?c.oldscale:1}function Hc(a,b,c){Jc.call(this,!0,a,b,c)}function Ic(a,b,c){Jc.call(this,!1,a,b,c)}function Jc(b,c,d,e){e===He&&(e=d),d&&e||(d=e=1);var f=Df;return this.plan(function(g,h){if(b&&(Oa(h).oldscale*=e),c.appear(g),a.isWindow(h)||9===h.nodeType)return void c.resolve(g);var i=a.map(a.css(h,"turtleScale").split(" "),parseFloat);1===i.length&&i.push(i[0]),i[0]*=d,i[1]*=e,this.animate({turtleScale:a.map(i,sa).join(" ")},pb(h,f),qb(h),c.resolver(g))}),this}function Kc(a,b){var c=z(a.parentElement),d=l(c),e=d?1:u(c)[1];return e*Gc(a)}function Lc(b){var c=Df;return function(d,e,f){if(a.isNumeric(e)){var g=e;e=f,f=g}return null==f&&(f=8.8),this.plan(function(g,h){var i=Oa(h),j=i.style;e||(e=j&&(j.fillStyle||j.strokeStyle)||"black"),d.appear(g);var k=this.pagexy(),l=ra(h,!0),m=Ka(e,"fillStyle"),n=Da(i),o=Kc(h),p=f*o,q=Math.max(0,p-2),r=p+(m.eraseMode?2:0),s=/rgba|hsla/.test(m.fillStyle);null==m.lineWidth&&j&&j.lineWidth&&(m.lineWidth=j.lineWidth),pc(this)?(b(n,k,r,l.rot,m,!0),d.resolve(g)):this.queue(function(e){a({radius:0}).animate({radius:q},{duration:pb(h,c),step:function(){s||b(n,k,this.radius,l.rot,m,!1)},complete:function(){b(n,k,r,l.rot,m,!0),d.resolve(g),e()}})})}),this}}function Mc(a,b,c,d,e){var f=a.getContext("2d");f.save(),Xa(f,e),c===1/0?(f.setTransform(1,0,0,1,0,0),f.fillRect(0,0,a.width,a.height)):(Za(f,a),f.beginPath(),f.arc(b.pageX,b.pageY,c/2,0,2*Math.PI,!1),f.closePath(),f.fill(),e.strokeStyle&&f.stroke()),f.restore()}function Nc(a,b,c,d,e){var f=a.getContext("2d");if(f.save(),Xa(f,e),c===1/0)f.setTransform(1,0,0,1,0,0),f.fillRect(0,0,a.width,a.height);else{var g=Math.sin((d+45)/180*Math.PI),h=Math.cos((d+45)/180*Math.PI),i=c*h/Math.SQRT2,j=c*g/Math.SQRT2;Za(f,a),f.beginPath(),f.moveTo(b.pageX-i,b.pageY-j),f.lineTo(b.pageX-j,b.pageY+i),f.lineTo(b.pageX+i,b.pageY+j),f.lineTo(b.pageX+j,b.pageY-i),f.closePath(),f.fill(),e.strokeStyle&&f.stroke()}f.restore()}function Oc(a,b,c,d,e,f){var g=a.getContext("2d");if(g.save(),Xa(g,e),!e.strokeStyle&&e.fillStyle&&(g.strokeStyle=e.fillStyle),c!==1/0){var h=Math.sin(d/180*Math.PI),i=-Math.cos(d/180*Math.PI),j=e.lineWidth||1.62,k=b.pageX+c*h,l=b.pageY+c*i,m=Pc(j,k,l,h,i),n=c-m.hs,o=n*h,p=n*i;Za(g,a),n>0&&(g.beginPath(),g.moveTo(b.pageX,b.pageY),g.lineTo(b.pageX+o,b.pageY+p),g.stroke()),f&&Qc(g,m)}g.restore()}function Pc(a,b,c,d,e){var f=Math.max(1.25*a,a+2),g=2*f,h=g-f/2;return{hs:h,x1:b,y1:c,xm:b-d*h,ym:c-e*h,x2:b-e*f-d*g,y2:c+d*f-e*g,x3:b+e*f-d*g,y3:c-d*f-e*g}}function Qc(a,b){a.beginPath(),a.moveTo(b.x2,b.y2),a.lineTo(b.x1,b.y1),a.lineTo(b.x3,b.y3),a.quadraticCurveTo(b.xm,b.ym,b.x2,b.y2),a.closePath(),a.fill()}function Rc(a,b,c,d,e,f){var g=e-c,h=f-d,i=Math.sqrt(g*g+h*h),j=g/i,k=h/i,l=Pc(b,e,f,j,k);i>l.hs&&(a.beginPath(),a.moveTo(c,d),a.lineTo(l.xm,l.ym),a.lineWidth=b,a.stroke()),Qc(a,l)}function Sc(a,b){function c(){d&&clearInterval(d),b&&b()}var d=null;if(!Ie.speechSynthesis)return console.log("No speech synthesis: "+a),void c();try{var e=new Ie.SpeechSynthesisUtterance(a);e.addEventListener("end",c),e.addEventListener("error",c),e.lang=navigator.language||"en-GB",Ie.speechSynthesis.speak(e),d=setInterval(function(){Ie.speechSynthesis.pending||Ie.speechSynthesis.speaking||c()},250)}catch(f){Ie.console&&Ie.console.log(f),c()}}function Tc(){a.each(["toggle","show","hide"],function(b,c){var d=a.fn[c];a.fn[c]=function(b,c,e){var f=arguments;!f.length&&this.hasClass("turtle")&&(this.length>1||!a._data(this[0],"fxshow"))&&(f=[0]),d.apply(this,f)}})}function Uc(c,d){if(d||(d="fx"),"IMG"==c.tagName&&c.src&&!c.complete){var e=a.queue(c,d);0==e.length&&(a.queue(c,d,function(a){Ib(c,null,a)}),b(c,d))}}function Vc(b){if(!(a.turtle.hangtime==1/0||kf++<100)){kf=0;var c=(new Date).getTime();return mf?void(c-mf>a.turtle.hangtime&&(Sf.visible()&&Sf.html('<span style="color:red">Oops: program interrupted because it was hanging the browser. Try reducing the number of repetitions. Or try using <b style="background:yellow">await done defer()</b> or <b style="background:yellow">tick</b> to make an animation.</span>'),a.turtle.interrupt("hung"))):(mf=c,clearTimeout(lf),void(lf=setTimeout(function(){clearTimeout(lf),lf=null,mf=null},0)))}}function Wc(b,c){if(!a.turtle.nowarn){var d,e=!0;for(d=0;e&&d<c.length;++d)a.queue(c[d]).length>=100&&(e=!1);e||(jf[b]||(jf[b]=1,Sf.visible()?Sf.html('<span style="color:red">Oops: '+b+' may not return useful results when motion is queued. Try <b style="background:yellow">speed Infinity</b></span> or <b style="background:yellow">await done defer()</b> first.'):console.warn(b+' may not return useful results when motion is queued. Try "speed Infinity" or "await done defer()".')),c.finish())}}function Xc(a,b,d){a[b]=function(){return b in jf||(Sf.html('<span style="color:red;">'+b+" deprecated. Use "+d+".</span>"),jf[b]=1),a[d].apply(this,arguments)},a[d].__super__&&c(a[b],a[d])}function Yc(){return pf&&a.queue(pf).length>0}function Zc(a){if(null===uf.pollTimer){var b=uf.sent[a],c=uf.waiting[a];c&&c.length&&b&&b.length&&(uf.pollTimer=setTimeout(function(){uf.pollTimer=null,c&&c.length&&b&&b.length&&(c.shift().apply(null,b.shift()),Zc(a))},0))}}function $c(a,b){if("function"!=typeof b&&"undefined"!=typeof b||!/^\w+\s*$/.test(a)){if("undefined"==typeof b&&/^help\s+\S+$/.test(a))return oc(/^help\s+(\S+)$/.exec(a)[1]),!0}else{if(b&&b.helptext)return oc(b),!0;if(a in tf)return oc(a),!0}return!1}function _c(a,b,c,d){return a.helptext?d.helptext=a.helptext:b in c&&(d.helptext=c[b].helptext),d.method=a,d.helpname=b,d}function ad(a,b){var c=[];for(var d in b)!b.hasOwnProperty(d)||d in Ie||(c.push(d),Ie[d]=function(b){var c=a[b],d=a;return _c(c,b,tf,function(){return c.apply(d,arguments)})}(d));return c}function bd(){pf=null;for(var a=0;a<qf.length;++a)delete Ie[qf[a]];qf.length=0}function cd(a){return null!==ed(a)}function dd(a){if(!/^[a-z]+$/.test(a))return!1;for(var b=0;b<wf.length;++b)if(wf[b]==a)return!0;return!1}function ed(b){if(b in xf)return xf[b];if(!b||!dd(b)&&!/^(?:rgb|hsl)a?\([^)]*\)$|^\#[a-f0-9]{3}(?:[a-f0-9]{3})?$/i.test(b))return null;var c,d=document.createElement("div"),e=d.style.color,f=null;return d.style.color=b,e!==d.style.color&&(c=/rgba?\s*\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*([.\d]+))?\s*\)/.exec(a(d).css({position:"absolute",top:0,left:0}).appendTo("body").css("color")),c?f=[parseInt(c[1]),parseInt(c[2]),parseInt(c[3]),Math.round(255*(c[4]?parseFloat(c[4]):1))]:"transparent"==b&&(f=[0,0,0,0]),a(d).remove()),xf[b]=f,f}function fd(a){var b=Ga(40,48),c=b.getContext("2d"),d=20,e=26;c.beginPath(),c.arc(d,e,16,0,2*Math.PI,!1),c.closePath(),c.fillStyle=a,c.fill(),c.beginPath();for(var f=[[[5,-14],[3,-11]],[[3,-11],[7,-8],[4,-4]],[[4,-4],[7,0],[4,4]],[[4,4],[7,8],[3,11]],[[7,-8],[12,-9],null],[[7,0],[15,0],null],[[7,8],[12,9],null],[[3,11],[1,15],null]],g=0;g<f.length;g++){var h=f[g];c.moveTo(d+h[0][0],e+h[0][1]);for(var i=1;i<h.length;i++)null!==h[i]&&c.lineTo(d+h[i][0],e+h[i][1]);for(var i=h.length-1;i>=0;i--)null===h[i]?(i--,c.moveTo(d-h[i][0],e+h[i][1])):c.lineTo(d-h[i][0],e+h[i][1])}return c.lineWidth=1.1,c.strokeStyle="rgba(255,255,255,0.75)",c.stroke(),c.beginPath(),c.arc(d,e,15.5,0,2*Math.PI,!1),c.closePath(),c.strokeStyle="rgba(0,0,0,0.4)",c.stroke(),b.toDataURL()}function gd(a){var b=Ga(40,48),c=b.getContext("2d");return c.beginPath(),c.moveTo(0,48),c.lineTo(20,0),c.lineTo(40,48),c.lineTo(20,36),c.closePath(),c.fillStyle=a,c.fill(),b.toDataURL()}function hd(a){var b=Ga(40,40),c=b.getContext("2d");return c.beginPath(),c.arc(20,20,18,-5*Math.PI/2,-Math.PI/2),c.closePath(),c.lineTo(20,20),c.stroke(),c.strokeStyle=a,c.lineWidth=4,c.stroke(),b.toDataURL()}function id(a,b){b=b||12;var c=Ga(b,b),d=c.getContext("2d"),e=b/2;return d.beginPath(),d.arc(e,e,e,0,2*Math.PI),d.closePath(),d.fillStyle=a,d.fill(),c.toDataURL()}function jd(a){function b(){e.moveTo(19.5,43),e.lineTo(20.5,43),e.lineTo(21.5,43.5),e.lineTo(25.5,36.2),e.lineTo(24,35.5),e.lineTo(23,35.5),e.lineTo(20.5,36.5),e.lineTo(19.5,36.5),e.lineTo(17,35.5),e.lineTo(16,35.5),e.lineTo(14.5,36.2),e.lineTo(18.5,43.5),e.closePath()}function c(){e.moveTo(25.5,12),e.lineTo(25.5,8),e.lineTo(14.5,8),e.lineTo(14.5,12),e.closePath()}var d=Ga(40,48),e=d.getContext("2d");return e.beginPath(),b(),e.fillStyle="#ffcb6b",e.fill(),e.beginPath(),c(),e.fillStyle="#d1ebff",e.fill(),e.beginPath(),e.moveTo(19.5,48),e.lineTo(13,36),e.lineTo(13,1),e.lineTo(14,0),e.lineTo(26,0),e.lineTo(27,1),e.lineTo(27,36),e.lineTo(20.5,48),e.closePath(),b(),e.moveTo(25.5,12),e.lineTo(25.5,8),e.lineTo(14.5,8),e.lineTo(14.5,12),e.closePath(),e.fillStyle=a,e.fill(),d.toDataURL()}function kd(a,b,c){return c||(c=1),function(d){var e=document.createElement("canvas");e.width=a,e.height=b;var f=e.getContext("2d");d||(d="rgba(128,128,128,0.125)"),"transparent"!=d&&(f.fillStyle=d,f.fillRect(0,0,a,b));var g=a/c,h=b/c,i={width:g,height:h,transformOrigin:g/2+"px + "+h/2+"px",opacity:1};return 1>c&&(i.imageRendering="pixelated"),{img:e,css:i}}}function ld(a){if(!a)return null;if(a in yf)return yf[a];var b=a.match(/^(\d+)x(\d+)(?:\/(\d+))?$/);return b?kd(parseFloat(b[1]),parseFloat(b[2]),b[3]&&parseFloat(b[3])):null}function md(a,b){var c=a.width||a.height||256,d=a.height||a.width||256,e=a.subpixel||1/(a.scale||1),f=a.color||"transparent",g=kd(c,d,e);return g(f)}function nd(b,c){if(!b)return null;if(a.isPlainObject(b))return md(b,c);if(a.isFunction(b)&&(b.helpname||b.name)&&(b=b.helpname||b.name),b.constructor===jQuery){if(!b.length)return null;b=b.get(0)}if(b.tagName)return"CANVAS"!=b.tagName&&"IMG"!=b.tagName&&"VIDEO"!=b.tagName?null:{img:b,css:{opacity:1}};var d=b.toString().trim().split(/\s+/),e=null,f=null;if(d.length&&(f=ld(d[d.length-1]),f&&d.pop()),d.length&&cd(d.join(" "))&&(e=d.join(" "),d.length=0),!f&&e&&(f=ld(c)),f)return f(e);if(/\//.test(b)||(b=Fb(b)),/\//.test(b)){var g=Ab(b).hostname;return!Cb(g)&&Cb(Ie.location.hostname)&&(b=Ie.location.protocol+"//"+Ie.location.host+"/proxy/"+Bb(b)),{url:b,css:{transformOrigin:"50% 50%",opacity:1}}}return null}function od(a){return null==a?"":String(a).replace(/[&<>"]/g,function(a){return zf[a]})}function pd(b,c,d){var e=b&&/^[a-zA-Z]\w*$/.exec(b),f=b&&/^<.*>$/.exec(b),g=nd(b,d)||null==b&&nd(d);e&&a("#"+b).length&&(e=!1);var h;f?h=a(b):g?(h=a("<canvas>"),hb(h,g)):h=a("<div>"+od(b)+"</div>"),b&&"object"==typeof b&&("id"in b&&h.attr("id",b.id),"class"in b&&h.addClass(b["class"])),h.css({position:"absolute",display:"table",top:0,left:0}),(!c||9==c.nodeType||a.isWindow(c))&&(c=za()),h.appendTo(c);var i=y(h[0]);return h.css({top:-i[1],left:-i[0]}),h.css({turtlePosition:U(h[0],a(c).pagexy(),null,0,0),turtleRotation:0,turtleScale:1}),h.addClass("turtle"),e&&(h.attr("id",b),rf&&!Ie.hasOwnProperty(b)&&(Ie[b]=h)),h}function qd(a,b){if("number"==typeof a)return a=Math.ceil(a),"number"==typeof b?(b=Math.ceil(b),Math.floor(Math.random()*(b-a)+a)):Math.floor(Math.random()*a);if("object"==typeof a&&a&&a.length&&a.slice)return a[Math.floor(Math.random()*a.length)];if("normal"==a){var c,d,e,f,g;do c=Math.random(),d=1.7156*(Math.random()-.5),e=c-.449871,f=Math.abs(d)+.386595,g=e*e+f*(.196*f-.25472*e);while(g>.27597&&(g>.27846||d*d>-4*Math.log(c)*c*c));return d/c}return"position"==a?{pageX:qd(K()+1),pageY:qd(J()+1)}:"color"==a?"hsl("+Math.floor(360*Math.random())+",100%,50%)":"gray"==a?"hsl(0,0,"+Math.floor(100*Math.random())+"%)":a===!0?Math.random()>=.5:Math.random()}function rd(b,c){c||"function"!=typeof b||(c=b,b=30);var d=null,e=Math.max(Math.floor(1e3/Math.max(1/86400,b)),0);if(Yc()){var f=a(pf);f.plan(function(){d=c})}else d=c;var g={fn:c,timer:setInterval(function(){if(d)try{Df++,Bf.push(g),d()}finally{Df--,Bf.pop(g)}},e)};return Af.push(g),g.timer}function sd(a){for(var b=[],c=0;c<Af.length;++c){var d=Af[c];null==a||a==d.timer||a==d.fn?clearInterval(Af[c].timer):b.push(Af[c])}Af=b}function td(a){null==a&&Bf.length&&(a=Bf[Bf.length-1].timer),sd(a)}function ud(b,c){c===He&&a.isFunction(b)&&(c=b,b=1),Cf&&(Ie.clearInterval(Cf),Cf=null),c&&b&&(Cf=Ie.setInterval(function(){try{Df++,c()}finally{Df--}},1e3/b))}function vd(b){return b===He?1e3/a.fx.speeds.turtle:void(a.fx.speeds.turtle=b>0?1e3/b:0)}function wd(b){b===He&&(b=""),a("[id]").each(function(c,d){Ie[b+d.id]=a("#"+d.id)}),rf=!0}function xd(b){if(b===He&&(b="last"),Ef&&a(Ie).off(a.map(of,function(a,b){return b}).join(" "),Ef),b||""===b){Ef=function(a){var c,d=[b+a.type];for((a.originalEvent||a)instanceof MouseEvent&&d.push(b+"mouse"),c=0;c<d.length;++c){var e,f=d[c],g=Ie[f];if(g&&g.__proto__===a.__proto__){for(e in g)g.hasOwnProperty(e)&&delete g[e];for(e in a)a.hasOwnProperty(e)&&(g[e]=a[e])}else Ie[f]=a}},Ie[b+"mouse"]=new a.Event;for(var c in of)Ie[b+c]=new a.Event;a(Ie).on(a.map(of,function(a,b){return b}).join(" "),Ef)}}function yd(b){var c=10,d=zd(),e=a(Ie).height()+a(Ie).scrollTop()+c>=a("html").outerHeight(!0);if(b(),e){var f=a(Ie).scrollTop(),g=Math.min(d,a("html").outerHeight(!0)-a(Ie).height());g>f&&a(Ie).scrollTop(g)}}function zd(){if(!Ff.timer){Ff.timer=setTimeout(function(){Ff.timer=null},0);var b=a("body").offset(),c=b?b.top:8;Ff.bottomSeen=Math.min(a(Ie).height()+a(Ie).scrollTop(),a("body").height()+c)}return Ff.bottomSeen}function Ad(b){var c=a(Ie).scrollTop();b(),a(Ie).scrollTop(c)}function Bd(){var a=document.body.lastChild;return a&&"PRE"==a.tagName||(a=document.createElement("pre"),document.body.appendChild(a)),a}function Cd(){var a=arguments;yd(function(){for(var b=Bd(),c=0;c<a.length;c++)b.appendChild(document.createTextNode(String(a[c])))})}function Dd(b,c){var d=a("<div>").css({display:"inline-block",verticalAlign:"top",textAlign:"center",height:"1.2em",width:"1.2em",maxWidth:"1.2em",overflow:"hidden"}).appendTo(Bd()),e=function(){null!=b&&d.css({background:b}),null!=c&&d.text(c)};if(pf){var f=a(pf);Ec.call(f,null,d),f.eq(0).plan(e)}else e()}function Ed(){var a=this;yd(function(){a.result.appendTo("body"),a.setup&&a.setup()})}function Fd(b,c){var d="<"+c+' style="display:table">',e="</"+c+">";if(b===He||null===b)return{result:a(d+"<br>"+e)};if(b.jquery||b instanceof Element&&(b=a(b)))return{result:b};var f=null;return b=""+b,/^\s*<.*>\s*$/.test(b)&&(f=a(b)),(null==f||1!=f.length||1!=f[0].nodeType)&&(f=a(d+b+e)),{result:f}}function Gd(b,c){function d(b){return function(d){j||m&&"change"==d.type||(j=!0,a(this).prop("checked",!0),i.find("input[type=radio]").prop("disabled",!0),c(b))}}function e(a){return function(){j||(l=a,f())}}function f(a){a||(m+=1,setTimeout(function(){m-=1},0),i.find("input").eq(l).prop("checked",!0)),i.find("input").eq(l).focus()}function g(b,c){a.isFunction(b)&&(b=(k+1).toString());var f=a.isFunction(c)||null==c?b:c,g=a('<input type="radio" name="menu" class="turtleinput">').attr("value",f).on("change click",d(c)),h=a('<label style="display:table">').append(g).append(b).on("click",d(c)).on("mousedown",e(k)),j=b&&b.toString().substr(0,1).toUpperCase();!j||j in n||(n[j]=k),k+=1,i.append(h)}var h,i=a("<form>").css({display:"table",marginLeft:"20px"}).submit(function(){return!1}),j=!1,k=0,l=0,m=0,n={};if(c||(c=function(b){a.isFunction(b)&&b.call(null)}),a.isArray(b))for(var o=0;o<b.length;++o)g(b[o],b[o]);else if(a.isPlainObject(b))for(h in b)g(h,b[h]);else g(b,b);return i.on("keydown",function(a){if(a.which>=37&&a.which<=40||32==a.which){
var b=i.find("input").index(i.find(":checked"));return l=b>=0&&l!=b?b:0>b?0:a.which>=39||32==a.which?(l+1)%k:(l+k-1)%k,f(),!1}13==a.which?i.find(":checked").click():String.fromCharCode(a.which)in n&&(l=n[String.fromCharCode(a.which)],f())}),{result:i,setup:function(){Ad(function(){f(!0)})}}}function Hd(b,c){a.isFunction(b)&&c===He&&(c=b,b=null),(null===b||b===He)&&(b="button");var d=a('<button class="turtleinput">'+od(b)+"</button>");return c&&d.click(c),{result:d}}function Id(b,c,d){function e(){l||(l=setTimeout(function(){l=null},1e3))}function f(){if(!g())return!1;var b=i.val();l&&m==b||(e(),m=b,i.remove(),j.remove(),k.append(b).css({display:"table"}),("number"==d||"auto"==d&&a.isNumeric(b)&&""+parseFloat(b)==b)&&(b=parseFloat(b)),k.prop("value",b),c&&setTimeout(function(){c.call(k,b)},0))}function g(){if("numeric"!=d)return!0;var b=i.val(),c=b.replace(/[^0-9\.]/g,"");return b==c&&a.isNumeric(c)?!0:(i.val(c),!1)}function h(a){if(13==a.which){if(!g())return!1;f()}return"voice"==d&&n&&(n.abort(),n=null),"numeric"==d&&a.which>=32&&a.which<=127&&(a.which<"0".charCodeAt(0)||a.which>"9".charCodeAt(0))&&(a.which!=".".charCodeAt(0)||~i.val().indexOf("."))?!1:void 0}a.isFunction(b)&&!c&&(c=b,b=null),d||(d="auto"),b=a.isNumeric(b)||b?b:"⇒";var i=a('<input class="turtleinput">').css({margin:0,padding:0}),j=a("<button>Submit</button>").css({marginLeft:4}),k=a('<label style="display:table">'+b+" </label>").append(i).append(j),l=null,m=i.val(),n=null;return i.on("keypress keydown",h),j.on("click",f),{result:k,setup:function(){if(e(),"text"==d||"voice"==d){var a=k.parent().width(),b=a+k.offset().left-i.offset().left,c=Math.max(256,a/2),g=c>b?a:b,h=i.outerWidth(!0)-i.width();i.width(g-h)}if("number"==d&&i.attr("type","number"),"voice"==d){j.css({display:"none"});var l=Ie.SpeechRecognition||Ie.webkitSpeechRecognition;if("function"==typeof l)try{n=new l,n.continuous=!1,n.interimResults=!0,i.css({backgroundColor:"lightyellow",color:"gray",backgroundImage:"url("+Gf+")",backgroundRepeat:"no-repeat",backgroundPosition:"center"}),n.onspeechstart=function(){i.css({background:"lightgreen"})},n.onend=function(){i.css({color:"",backgroundColor:"",backgroundImage:"",backgroundRepeat:"",backgroundPosition:""}),i.val(m),f()},n.onresult=function(a){var b=a.results[0][0].transcript,c=a.results[0][0].confidence,d=128-128*c;a.results[0].isFinal&&(d=0,m=b),i.css({color:Ld("rgb",d,d,d)}),i.val(b)},n.start()}catch(o){console.log(o)}}Ad(function(){i.focus()})}}}function Jd(b,c){a.isNumeric(c)&&(c={height:c});var d=a("<img>");return b&&d.attr("src",Fb(b)),c&&d.css(c),{result:d}}function Kd(b,c,d,e){var f,g,h=null;if(a.isArray(b))for(e=d,d=c,h=b,b=h.length,c=0,f=0;b>f;f++)c=a.isArray(h[f])?Math.max(c,h[f].length):Math.max(c,1);var i=["<table>"];for(f=0;b>f;f++){for(i.push("<tr>"),g=0;c>g;g++)h?a.isArray(h[f])&&g<h[f].length?i.push("<td>"+od(h[f][g])+"</td>"):a.isArray(h[f])||0!=g?i.push("<td></td>"):i.push("<td>"+od(h[f])+"</td>"):i.push("<td></td>");i.push("</tr>")}i.push("</table>");var j=a(i.join("")),k={borderCollapse:"collapse",width:"35px",height:"35px",border:"1px solid black",tableLayout:"fixed",textAlign:"center",margin:"0",padding:"0"};return j.css(a.extend({},k,{width:"auto",height:"auto",maxWidth:"auto",border:"none"},e)),j.find("td").css(a.extend({},k,d)),{result:j}}function Ld(a,b){return a+"("+Array.prototype.join.call(b,",")+")"}function Md(a,b,c){var d=0,e=[],f={};for(var g in c){var h=c[g];for(d=b;d<a.length;++d)if(!~e.indexOf(d)){if("*"==h)break;if(h instanceof RegExp&&h.test(a[d]))break;if(h instanceof Function&&h(a[d]))break;if(h==typeof a[d])break}d<a.length&&(e.push(d),f[g]=a[d])}if(e.length+b<a.length){var i=[];for(d=b;d<a.length;++d)~e.indexOf(d)||i.push(a[d]);f.extra=i}return f}function Nd(b){if(0===arguments.length)b={};else if(2==arguments.length){var c={};c[arguments[0]]=arguments[1],b=c}else 1==arguments.length&&"function"==typeof arguments[0]&&(b={eval:arguments[0]});return"jQuery"in b&&(a=b.jQuery),"eval"in b&&(Zf[""].e=b.eval),"this"in b&&(Zf[""].t=b["this"]),"element"in b&&(Pf=b.element),"autoscroll"in b&&(Of=b.autoscroll),"linestyle"in b&&(Mf=b.linestyle),"depth"in b&&(Nf=b.depth),"panel"in b&&(Qf=b.panel),"height"in b&&(Xf=b.height),"title"in b&&(Uf=b.title),"console"in b&&(Vf=b.console),"history"in b&&(Wf=b.history),"coffee"in b&&($f=b.coffee),"abbreviate"in b&&(kg=b.abbreviate),"consolehook"in b&&(lg=b.consolehook),"consolelog"in b&&(Tf=b.consolelog),"noconflict"in b&&Ud(b.noconflict),Qf&&(Pf="#_testlog",Of="#_testscroll",Qf===!0&&Be()),Tf===!0&&Ae(),Od()}function Od(a,b,c){return arguments.length<=1?(arguments.length||(a=""),Jf+".scope("+_d(a)+","+_f+",this)"):void(Zf[a]={e:b,t:c})}function Pd(a,b){1==arguments.length&&(b=a,a="");var c=Zf[""].e,d=Zf[""].t;return Zf.hasOwnProperty(a)&&(Zf[a].e&&(c=Zf[a].e),Zf[a].t&&(d=Zf[a].t)),Hf.reportEvent("seeeval",[a,b]),c.call(d,b)}function Qd(a){var b=$f||Ie.CoffeeScript,c=b.compile(a,{bare:1});return c&&(c=c.replace(bg,"")),c}function Rd(){Sf.repr=le,Sf.html=Wd,Sf.noconflict=Ud,Sf.init=Nd,Sf.scope=Od,Sf.eval=Pd,Sf.barecs=Qd,Sf.here="eval("+Jf+".init())",Sf.clear=te,Sf.hide=pe,Sf.show=qe,Sf.visible=re,Sf.enter=se,Sf.js=_f,Sf.cs="(function(){return eval("+Jf+".barecs(arguments[0]));})",Sf.version=Kf,Ie[Jf]=Sf}function Sd(a){return{name:a,has:Ie.hasOwnProperty(a),value:Ie[a]}}function Td(a){a.has?Ie[a.name]=a.value:delete Ie[a.name]}function Ud(a){return a&&"string"==typeof a||(a="see"+(1+Math.random()+"").substr(2)),Lf&&Td(Lf),Jf=a,Lf=Sd(a),Rd(),Sf}function Vd(b){function c(a,b){function c(a,b){a.onload=a.onreadystatechange=b}var d=document.createElement("script"),e=document.getElementsByTagName("head")[0],f=1;c(d,function(){!f||d.readyState&&!{loaded:1,complete:1}[d.readyState]||(f=0,b(),c(d,null),e.removeChild(d))}),d.src=a,e.appendChild(d)}return!If||a&&a.fn&&a.fn.jquery?void b():void c("//ajax.googleapis.com/ajax/libs/jquery/"+If+"/jquery.min.js",function(){a=jQuery.noConflict(!0),b()})}function Wd(a){gg.push('<samp class="_log">'),gg.push(a),gg.push("</samp>"),oe()}function Xd(a){var b=Object.prototype.toString.call(a),c=b.substring(8,b.length-1);if("Object"==c){if("length"in a&&"slice"in a&&"number"==typeof a.length)return"Array";if("originalEvent"in a&&"target"in a&&"type"in a)return Xd(a.originalEvent)}return c}function Yd(a){switch(a){case"String":case"Number":case"Boolean":case"Undefined":case"Date":case"RegExp":case"Null":return!0}return!1}function Zd(a){return a&&a.nodeType&&a.nodeName&&"function"==typeof a.cloneNode}function $d(a,b){return b&&b>3&&a.length>b?a.substring(0,Math.floor(b/2)-1)+"..."+a.substring(a.length-(Math.ceil(b/2)-2)):a}function _d(a,b){function c(a){if(eg.hasOwnProperty(a))return eg[a];var b="0"+a.charCodeAt(0).toString(16);return"\\x"+b.substring(b.length-2)}return-1==a.indexOf('"')||-1!=a.indexOf("'")?$d('"'+he(a.replace(/[\0-\x1f\x7f-\x9f"\\]/g,c))+'"',b):$d("'"+he(a.replace(/[\0-\x1f\x7f-\x9f'\\]/g,c))+"'",b)}function ae(a,b){var c=Xd(a);if("String"==c)return _d(a,b);if("Undefined"==c||"Null"==c)return c.toLowerCase();if(Yd(c))return""+a;if("Array"==c&&0===a.length)return"[]";if("Object"==c&&de(a))return"{}";if(Zd(a)&&1==a.nodeType){if(a.hasAttribute("id"))return a.tagName.toLowerCase()+"#"+he(a.getAttribute("id"));if(a.hasAttribute("class")){var d=a.getAttribute("class").split(" ")[0];if(d)return a.tagName.toLowerCase()+"."+he(d)}return a.tagName.toLowerCase()}return c}function be(a){return 3!=a.nodeType||/[^\s]/.exec(a.textContent)}function ce(a){return a.replace(/^\s*\n/,"")}function de(a,b,c){var d=Xd(a);if(Yd(d))return!0;if(!b&&"Array"==d)return!c||a.length<=c;if(Zd(a))return 9==a.nodeType||11==a.nodeType?!1:1==a.nodeType?null===a.firstChild||null===a.firstChild.nextSibling&&3==a.firstChild.nodeType&&a.firstChild.textContent.length<=c:!0;if("Function"==d){var e=a.toString();return e.length-e.indexOf("{")<=c}if("Error"==d)return!!a.stack;var f=0;for(var g in a)if(a.hasOwnProperty(g)){if(f+=1,b&&!Yd(Xd(a[g])))return!1;if(c&&f>c)return!1}return!0}function ee(a,b){var c;if("outerHTML"in a){c=de(a,!0,b);var d=a.cloneNode(c).outerHTML,e=null;if(!c){var f=/^(.*)(<\/[^\s]*>$)/.exec(d);f&&(e=f[2],d=f[1])}return[he(d),e&&he(e)]}if(1==a.nodeType){for(var g=["<"+a.tagName],h=0;h<a.attributes.length;++h)g.push(ee(a.attributes[h],b)[0]);return c=de(a,!0,b),c&&a.firstChild?[he(g.join(" ")+">"+a.firstChild.textContent+"</"+a.tagName+">"),null]:[he(g.join(" ")+(a.firstChild?">":"/>")),a.firstChild?he("</"+a.tagName+">"):null]}return 2==a.nodeType?[he(a.name+'="'+he($d(a.value,b),'"')+'"'),null]:3==a.nodeType?[he(ce(a.textContent)),null]:4==a.nodeType?["<![CDATA["+he($d(a.textContent,b))+"]]>",null]:8==a.nodeType?["<!--"+he($d(a.textContent,b))+"-->",null]:10==a.nodeType?["<!DOCTYPE "+he(a.nodeName)+">",null]:[a.nodeName,null]}function fe(a,b){var c=Xd(a);if(Yd(c))return ae(a,b);if(Zd(a)){var d=ee(a,b);return d[0]+(d[1]?"..."+d[1]:"")}if("Function"==c){var e=a.toString();return e.length-e.indexOf("{")>b&&(e=e.replace(/\{(?:.|\n)*$/,"").trim()),e}if(("Error"==c||"ErrorEvent"==c)&&"message"in a)return a.message;var f=[];if("Array"==c&&a.length<b){for(var g=a.length>=5,h=g&&a[0],i=0;i<a.length;++i)g&&a[i]!==h&&(g=!1),f.push(ae(a[i],b));return g?"["+ae(h,b)+"] × "+a.length:"["+f.join(", ")+"]"}if(de(a,!1,b)){for(var j in a)a.hasOwnProperty(j)&&f.push(ge(j)+": "+ae(a[j],b));return("Object"==c?"{":c+"{")+f.join(", ")+"}"}return"Array"==c?"Array("+a.length+")":c}function ge(a){return/^\w+$/.exec(a)?a:_d(a)}function he(a,b){var c=/[<>&]/g;return b&&(c=new RegExp("[<>&"+b+"]","g")),a.replace(c,function(a){return"<"==a?"<":">"==a?">":"&"==a?"&":'"'==a?""":"&#"+a.charCodeAt(0)+";"})}function ie(a){a=a.replace(/^\s*\n/,"");var b=a.match(/^\s*\S/gm),c=b.length&&b[0].length-1,d=1;for(b.length>1&&"{"==b[0].trim()&&(c=b[1].length-1,d=2);d<b.length;++d)if(c=Math.min(b[d].length-1,c),0>=c)return a;var e=new RegExp("^\\s{"+c+"}","mg");return a.replace(e,"")}function je(a,b,c,d){if(d.push('<label class="_log"><input type="checkbox"><span>'),a&&d.push(a),Zd(b)){var e=ee(b,10);d.push(e[0]),d.push("</span><ul>");for(var f=b.firstChild;f;f=f.nextSibling)be(f)&&(3==f.nodeType?(d.push("<li><samp>"),d.push(ie(f.textContent)),d.push("</samp></li>")):de(f,!0,20)||1>=c?d.push("<li>"+fe(f,20)+"</li>"):je("",f,c-1,d));d.push("</ul>"),e[1]&&(d.push("<span>"),d.push(e[1]),d.push("</span>")),d.push("</label>")}else{d.push(fe(b,10)),d.push("</span><ul>");var g=Xd(b);if("Function"==g){var h=b.toString(),i=/\{(?:.|\n)*$/.exec(h);i&&(h=i[0]),d.push("<li><samp>"),d.push(he(ie(h))),d.push("</samp></li>")}else if("Error"==g)d.push("<li><samp>"),d.push(he(b.stack)),d.push("</samp></li>");else if("Array"==g){for(var j=0;j<Math.min(100,b.length);++j){try{n=b[j]}catch(k){n=k}de(n,!0,20)||1>=c||"global"==Xd(n)?d.push("<li>"+j+": "+fe(n,100)+"</li>"):je(j+": ",n,c-1,d)}b.length>100&&d.push("<li>length="+b.length+" ...</li>")}else{var l=0;for(var m in b)if(b.hasOwnProperty(m)){if(l+=1,l>100)continue;var n;try{n=b[m]}catch(k){n=k}de(n,!0,20)||1>=c||"global"==Xd(n)?(d.push("<li>"),d.push(ge(m)),d.push(": "),d.push(fe(n,100)),d.push("</li>")):je(ge(m)+": ",n,c-1,d)}l>100&&d.push("<li>"+l+" properties total...</li>")}d.push("</ul></label>")}}function ke(){if(!dg&&!Ie.document.getElementById("_logcss")){var a=Ie.document.createElement("style");a.id="_logcss",a.innerHTML=(Mf?"samp._log{"+Mf+"}":"")+cg,Ie.document.head.appendChild(a),dg=!0}}function le(a,b,c){b=b||3;var d=c||[],e=Xd(a);return"Error"==e||"ErrorEvent"==e?(d.push('<span style="color:red;">'),je("",a,b,d),d.push("</span>")):Yd(e)?d.push(ae(a)):de(a,!0,100)||0>=b?d.push(fe(a,100)):je("",a,b,d),c?void 0:d.join("")}function me(b,c){switch(typeof b){case"string":return"body"==b?document.body:document.querySelector?document.querySelector(b):a?a(b)[0]:null;case"undefined":return c;case"boolean":return b?c:null;default:return b}}function ne(){var a=!1,b=me(Of,null);return b&&(a=b.scrollHeight-b.scrollTop-10<=b.clientHeight),a?function(){b.scrollTop=b.scrollHeight-b.clientHeight}:function(){}}function oe(){var a,b=me(Pf,null);if(b&&b.appendChild&&gg.length){ke();var c=Ie.document.createElement("samp");c.innerHTML=gg.join(""),gg.length=0;for(var d=ne();a=c.firstChild;)b.appendChild(a);d()}!fg&&gg.length?("auto"==Qf&&Be(),fg=setTimeout(function(){fg=null,oe()},100)):fg&&!gg.length&&(clearTimeout(fg),fg=null)}function pe(){a("#_testpanel").hide()}function qe(){a("#_testpanel").show()}function re(){return a("#_testpanel").is(":visible")}function se(b){a("#_testinput").val(b)}function te(){hg&&a("#_testlog").find("._log").not("#_testpaneltitle").remove()}function ue(a){return'<samp class="_logcaret" style="color:'+a+';"></samp>'}function ve(){return Ie.getSelection?Ie.getSelection().toString():document.getSelection?document.getSelection():document.selection?document.selection.createRange().text:void 0}function we(a){return'<samp class="_log" id="_testpaneltitle" style="font-weight:bold;">'+a+"</samp>"}function xe(){if(Wf){var b,c={height:Xf,history:[]};try{b=Ie.JSON.parse(Ie.localStorage[Wf])}catch(d){b=mg||{}}return b&&b.slice&&b.length?(c.history=b,c):(a.extend(c,b),c)}}function ye(a){if(Wf){var b=xe(),c=!1;if("history"in a&&a.history.length&&(!b.history.length||b.history[b.history.length-1]!==a.history[a.history.length-1])&&(b.history.push(a.history[a.history.length-1]),c=!0),"height"in a&&a.height!==b.height&&(b.height=a.height,c=!0),c)try{Ie.localStorage[Wf]=Ie.JSON.stringify(b)}catch(d){mg=b}}}function ze(){return Ie.innerHeight||a(Ie).height()}function Ae(){try{if(Tf&&Ie.console&&!Ie.console._log&&"function"==typeof Ie.console.log){var a=Ie.console._log=Ie.console.log;Ie.console.log=function(){a.apply(this,arguments),Sf.apply(this,arguments)};var b=Ie.console._debug=Ie.console.debug;Ie.console.debug=function(){b.apply(this,arguments),Sf.apply(this,arguments)}}}catch(c){}}function Be(){ig||(ig=!0,Vd(Ce))}function Ce(){if(hg)Uf&&(a("#_testpaneltitle").length?a("#_testpaneltitle").html(Uf):a("#_testlog").prepend(we(Uf))),a("#_testpanel").show();else if(!Ie.document.getElementById("_testlog")&&Ie.document.body){Ae(),ke();var b=xe(),c=Uf?we(Uf):"";b.height>ze()-50&&(b.height=Math.min(ze(),Math.max(10,ze()-50))),a("body").prepend('<samp id="_testpanel" class="turtlefield" style="overflow:hidden;z-index:99;position:fixed;bottom:0;left:0;width:100%;height:'+b.height+'px;background:rgba(240,240,240,0.8);font:10pt monospace;-webkit-transform:translateZ(0);"><samp id="_testdrag" style="cursor:row-resize;height:6px;width:100%;display:block;background:lightgray"></samp><samp id="_testscroll" style="overflow-y:scroll;overflow-x:hidden;display:block;width:100%;height:'+(b.height-6)+'px;"><samp id="_testlog" style="display:block">'+c+'</samp><samp class="_log" style="position:relative;display:block;">'+ue("blue")+'<input id="_testinput" class="_log" style="width:100%;margin:0;border:0;font:inherit;background:rgba(255,255,255,0.8);"></samp></samp>'),hg=!0,oe();var d=0,e={};a("#_testinput").on("keydown",function(c){if(13==c.which){var f=a(this).val();if(a(this).val(""),!f.trim().length||b.history.length&&b.history[b.history.length-1]===f||(b.history.push(f),ye({history:[f]})),e={},d=0,Wd('<samp class="_log" style="margin-left:-1em;">'+ue("lightgray")+he(f)+"</samp>"),a(this).select(),f.trim().length&&":"==f.trim()[0]){var g=f.trim().substring(1).trim();if(!g||Zf.hasOwnProperty(g)){Yf=g;var h=g?"scope "+g:"default scope";Wd('<span style="color:blue">switched to '+h+"</span>")}else Wd('<span style="color:red">no scope '+g+"</span>");return}a.turtle.interrupt("reset");var i=!1;try{var j;try{j=Pd(Yf,f)}finally{if(lg&&lg(f,j))i=!0;else{for(var k=kg.length-1;k>=0&&j!==kg[k];--k);0>k&&Wd(le(j))}}}catch(c){i||Sf(c)}}else if(38==c.which||40==c.which){e[d]=a(this).val(),d+=38==c.which?1:-1,d=Math.max(0,Math.min(b.history.length,d));var l=e[d]||b.history[b.history.length-d];"undefined"==typeof l&&(l=""),a(this).val(l),this.selectionStart=this.selectionEnd=l.length,c.preventDefault()}}),a("#_testdrag").on("mousedown",function(c){var d,e=this,f=a("#_testpanel").height()+c.pageY,g=a("#_testdrag").height(),h=c.which;return e.setCapture&&e.setCapture(!0),d=function(c){if("blur"!=c.type&&c.which==h){var e=ze(),i=Math.max(g,Math.min(e,f-c.pageY)),j=ne();a("#_testpanel").height(i),a("#_testscroll").height(i-g),j()}("mouseup"==c.type||"blur"==c.type||"mousemove"==c.type&&c.which!=h)&&(a(Ie).off("mousemove mouseup blur",d),document.releaseCapture&&document.releaseCapture(),a("#_testpanel").height()!=b.height&&(b.height=a("#_testpanel").height(),ye({height:b.height})))},a(Ie).on("mousemove mouseup blur",d),!1}),a("#_testpanel").on("mouseup",function(b){if(!ve()){var c=a("#_testscroll").scrollTop();a("#_testinput").focus(),a("#_testscroll").scrollTop(c)}})}jg&&hg?clearTimeout(jg):hg||jg||(jg=setTimeout(Ce,100))}function De(a,b){var c=document.createElement("canvas");b||(b=0),c.width=a.width,c.height=a.height;var d=c.getContext("2d");return d.drawImage(a,0,0),Ee(c,b)}function Ee(a,b){for(var c,d,e=a.getContext("2d"),f=e.getImageData(0,0,a.width,a.height).data,g=[],h=256*b,i=1/0,j=-1,k=0;k<a.height;++k){c=1/0,d=-1;for(var l=0;l<a.width;++l)f[4*k*a.width+4*l+3]>h&&(0>d&&(c=l),d=l);(d>=0||j>=0)&&(g.push({pageX:Math.min(c,i),pageY:k}),g.push({pageX:Math.max(d,j)+1,pageY:k})),i=c,j=d}return j>=0&&(g.push({pageX:i,pageY:a.height}),g.push({pageX:j+1,pageY:a.height})),la(g)}function Fe(a,b){var c=a.getContext("2d"),d=a.width,e=a.height,f=0;if(c.save(),c.beginPath(),c.moveTo(0,0),c.lineTo(d,0),c.lineTo(d,e),c.lineTo(0,e),c.closePath(),b.length)for(c.moveTo(b[0].pageX,b[0].pageY);f<b.length;f+=1)c.lineTo(b[f].pageX,b[f].pageY);c.closePath(),c.clip(),c.clearRect(0,0,d,e),c.restore()}function Ge(a,b,c,d,e){for(var f=0;f<a.length;f++)a[f].pageX=a[f].pageX*b+d,a[f].pageY=a[f].pageY*c+e}var He=void 0,Ie=this,Je={}.hasOwnProperty,Ke=jQuery(function(){}),Le=!1,Me=0,Ne=0,Oe=[];if(!a.cssHooks)throw"jQuery 1.4.3+ is needed for jQuery-turtle to work";var Pe=d("transform"),Qe=d("transformOrigin");if(Pe&&e()){var Re={attached:!1,surface:null,field:null,ctx:null,canvas:null,timer:null,fieldMouse:!1,fieldHook:!1,subpixel:1},Se=document.createElement("a"),Te={},Ue=function(b){function d(b,c){this.constructor=jQuery,this.constructor.prototype=Object.getPrototypeOf(this),(!b||"string"==typeof b||a.isPlainObject(b)||"number"==typeof b)&&(b=pd(b,c,"256x256")),jQuery.fn.init.call(this,b,c,Ke)}return c(d,b),d.prototype.pushStack=function(){var a,b,c;for(b=jQuery.fn.pushStack.apply(this,arguments),a=b.length,c=a===this.length;c&&a--;)c=c&&this[a]===b[a];return c?this:b},d}(jQuery.fn.init),Ve=function(b){function d(b){b&&b.jquery&&a.isFunction(b.canvas)&&(b=b.canvas()),!b||"CANVAS"==b.tagName&&"function"==typeof b.getContext||(b=a(b).filter("canvas").get(0)),b&&"CANVAS"==b.tagName&&"function"==typeof b.getContext||(b=null);var c=b?b.parentElement:null,e={width:0,height:0,color:"transparent"};d.__super__.constructor.call(this,e,c),this.each(function(){var a=Oa(this);a.speed=1/0,a.drawOnCanvas=b,this.style.display="none",b&&(this.style[Pe]=ta(ra(b,!0)))})}return c(d,b),d}(Ue),We=function(a){function b(a,c){b.__super__.constructor.call(this,pd(a,c,"turtle"))}return c(b,a),b}(Ue),Xe=function(b){function d(b,c){var e="",f=!1,g=!1,h=!1;if(a.isPlainObject(b)){for(var i in b)e+=" "+i+'="'+od(b[i])+'"';f="src"in b,g="autoplay"in b,h="width"in b||"height"in b,!h||"height"in b||(e+=" height="+Math.round(3*b.width/4)),!h||"width"in b||(e+=" width="+Math.round(4*b.height/3))}g||(e+=" autoplay"),h||(e+=" width=320 height=240"),d.__super__.constructor.call(this,"<video"+e+">"),f||this.capture()}return c(d,b),d.prototype.capture=function(){return this.queue(function(b){var c=this,d=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return d?void d.call(navigator,{video:!0},function(d){if(d){var e=Oa(c),f=(""+Math.random()).substr(2);e.stream&&e.stream.stop(),e.stream=d,a(c).on("play.capture"+f,function(){a(c).off("play.capture"+f),b()}),c.src=Ie.URL.createObjectURL(d)}},function(){b()}):void b()})},d.prototype.cut=function(){return this.plan(function(){var a=this.data("turtleData");a.stream&&(a.stream.stop(),a.stream=null),this.attr("src","")})},d}(Ue),Ye=function(a){function b(a){var c,i,j,k,l,m,n,o,p,q,r,s=null,t=this;a=f(a,"keys"),q=ef.pitchToMidi(a.lowest),r=ef.pitchToMidi(a.highest);var u=this._geom={};if(u.lineWidth="lineWidth"in a?a.lineWidth:1.5,u.color="color"in a?a.color:"white",u.blackColor="blackColor"in a?a.blackColor:"black",u.lineColor="lineColor"in a?a.lineColor:"black",j=Math.ceil(u.lineWidth),i=422,c=4.2,null!=q&&null!=r?s=e(r)-e(q)+1:"keys"in a&&(s=Math.ceil(a.keys/12*7)),s&&(c=s/5,i=Math.sqrt(42e3*c)+j),m="width"in a?a.width:"height"in a?Math.round((a.height-j)*c+j):i,l="height"in a?a.height:Math.round((m-j)/c+j),s||(s=Math.max(1,Math.round((m-j)/(l-j)*5))),n=Math.min(e(108),Math.ceil(42+(s-1)/2)),u.highest=null!=r?r:null!=q&&"keys"in a?q+a.keys-1:g(null!=q?e(q)+s-1:n),u.lowest=null!=q?q:"keys"in a?u.highest-a.keys+1:Math.min(u.highest,g(e(u.highest)-s+1)),k=e(u.lowest),n=e(u.highest),h(u.highest)&&(n+=1),s=n-k+1,u.kw=(m-j)/s,u.kh=("height"in a?a.height-j:5*u.kw)+(j-u.lineWidth),u.bkw=4*u.kw/7,u.bkh=3*u.kh/5,u.halfex=j/2,u.leftpx=k*u.kw,u.rightpx=(n+1)*u.kw,u.ckw=(3*u.kw-2*u.bkw)/3,u.fkw=(4*u.kw-3*u.bkw)/4,b.__super__.constructor.call(this,{width:Math.ceil(u.rightpx-u.leftpx+j),height:Math.ceil(u.kh+j)}),"timbre"in a)p=a.timbre;else for(o in ef.defaultTimbre)o in a&&(p||(p={}),p[o]=a[o]);return p||(p="piano"),this.css({turtleTimbre:p}),this.on("noteon",function(a){t.drawkey(a.midi,d(a.midi))}),this.on("noteoff",function(a){t.drawkey(a.midi)}),this.draw(),this}function d(a){return k[(a%12+12)%12]}function e(a){return Math.floor((a+7)/12*7)}function g(a){return Math.ceil(a/7*12)-7}function h(a){return i(a)>=8}function i(a){return[1,8,2,9,3,4,10,5,11,6,12,7][(a%12+12)%12]}function j(a,b,c){var d,f,g,j,k,l,m;switch(l=b.halfex+b.kw*e(c)-b.leftpx,m=b.halfex,d=i(c),g=c===b.lowest,k=c===b.highest,f=0,j=0,d){case 1:j=b.kw-b.ckw;break;case 2:j=f=(b.kw-b.ckw)/2;break;case 3:f=b.kw-b.ckw;break;case 4:j=b.kw-b.fkw;break;case 5:f=b.fkw+b.bkw-b.kw,j=2*b.kw-2*b.fkw-b.bkw;break;case 6:f=2*b.kw-2*b.fkw-b.bkw,j=b.fkw+b.bkw-b.kw;break;case 7:f=b.kw-b.fkw;break;case 8:l+=b.ckw;break;case 9:l+=2*b.ckw+b.bkw-b.kw;break;case 10:l+=b.fkw;break;case 11:l+=2*b.fkw+b.bkw-b.kw;break;case 12:l+=3*b.fkw+2*b.bkw-2*b.kw}return g&&(f=0),k&&(j=0),h(c)?(a.moveTo(l,m+b.bkh),a.lineTo(l+b.bkw,m+b.bkh),a.lineTo(l+b.bkw,m),a.lineTo(l,m),a.closePath()):(a.moveTo(l,m+b.kh),a.lineTo(l+b.kw,m+b.kh),a.lineTo(l+b.kw,m+b.bkh),a.lineTo(l+b.kw-j,m+b.bkh),a.lineTo(l+b.kw-j,m),a.lineTo(l+f,m),a.lineTo(l+f,m+b.bkh),a.lineTo(l,m+b.bkh),a.closePath())}c(b,a),b.prototype.drawkey=function(a,b){var c,d=this._geom;if(d.lowest<=a&&a<=d.highest)return null==b&&(b=h(a)?d.blackColor:d.color),c=this.canvas().getContext("2d"),c.save(),c.beginPath(),j(c,d,a),c.fillStyle=b,c.strokeStyle=d.lineColor,c.lineWidth=d.lineWidth,c.fill(),c.stroke(),c.restore()},b.prototype.draw=function(){for(var a=this._geom.lowest;a<=this._geom.highest;++a)this.drawkey(a)};var k=["#db4437","#ff5722","#f4b400","#ffeb3b","#cddc39","#0f9d58","#00bcd4","#03a9f4","#4285f4","#673ab7","#9c27b0","#e91e63"];return b}(Ue),Ze=!1,$e=function(){for(var a="undefined"!=typeof Ie?Ie.navigator.userAgent:"",b=/OS X/.test(a),c=/Opera/.test(a),d=!/like Gecko/.test(a)&&!c,e={0:"null",1:"mouse1",2:"mouse2",3:"break",4:"mouse3",5:"mouse4",6:"mouse5",8:"backspace",9:"tab",12:"clear",13:"enter",16:"shift",17:"control",18:"alt",19:"pause",20:"capslock",21:"hangulmode",23:"junjamode",24:"finalmode",25:"kanjimode",27:"escape",28:"convert",29:"nonconvert",30:"accept",31:"modechange",27:"escape",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",41:"select",42:"print",43:"execute",44:"snapshot",45:"insert",46:"delete",47:"help",91:"meta",92:"meta",93:b?"meta":"menu",95:"sleep",106:"numpad*",107:"numpad+",108:"numpadenter",109:"numpad-",110:"numpad.",111:"numpad/",144:"numlock",145:"scrolllock",160:"shiftleft",161:"shiftright",162:"controlleft",163:"controlright",164:"altleft",165:"altright",166:"browserback",167:"browserforward",168:"browserrefresh",169:"browserstop",170:"browsersearch",171:"browserfavorites",172:"browserhome",173:b&&d?"-":"volumemute",174:"volumedown",175:"volumeup",176:"mediatracknext",177:"mediatrackprev",178:"mediastop",179:"mediaplaypause",180:"launchmail",181:"launchmediaplayer",182:"launchapp1",183:"launchapp2",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",223:"meta",224:"meta",226:"altgraph",229:"process",231:c?"`":"unicode",246:"attention",247:"crsel",248:"exsel",249:"eraseeof",250:"play",251:"zoom",252:"noname",253:"pa1",254:"clear"},f=48;91>f;++f)e[f]=String.fromCharCode(f).toLowerCase();for(f=96;106>f;++f)e[f]="numpad"+(f-96);for(f=112;136>f;++f)e[f]="f"+(f-111);return e}(),_e=function(){function a(a,c){return function(d){var e,f=d.which;a?e="mouse"+f:(!f&&d.whichSynth&&(f=d.whichSynth),e=$e[f],f>=160&&165>=f&&b(e.replace(/(?:left|right)$/,""),c)),b(e,c)}}function b(a,b){null!=a&&(b?h[a]=!0:delete h[a])}function c(){for(var a in h)delete h[a]}function d(a){c();for(var b in g)a?Ie.addEventListener(b,g[b],!0):Ie.removeEventListener(b,g[b])}function e(){var a,b=[];for(a in h)h[a]&&b.push(a);return b}function f(a){return Nb(),a?(a=a.replace(/\s/g,"").toLowerCase(),h[a]?!0:!1):e()}var g={mousedown:a(1,1),mouseup:a(1,0),keydown:a(0,1),keyup:a(0,0),blur:c},h={};return f.enable=d,f.list=e,f}(),af=null,bf={C:0,D:2,E:4,F:5,G:7,A:9,B:11,c:12,d:14,e:16,f:17,g:19,a:21,b:23},cf={"^":1,"":0,"=":0,_:-1},df=["C","^C","D","_E","E","F","^F","G","_A","A","_B","B","c","^c","d","_e","e","f","^f","g","_a","a","_b","b"],ef=function(){function a(a){this._atop=ac(),this._timbre=b(a,this._atop),this._queue=[],this._minQueueTime=1/0,this._maxScheduledTime=0,this._unsortedQueue=!1,this._startSet=[],this._finishSet={},this._cleanupSet=[],this._callbackSet=[],this._handlers={},this._now=null,_b()&&this.silence()}function b(a,b){a||(a={}),"string"==typeof a&&(a={wave:a});var c,d={},f=b&&b.wavetable&&b.wavetable[a.wave];for(c in e)a.hasOwnProperty(c)?d[c]=a[c]:f&&f.defs&&f.defs.hasOwnProperty(c)?d[c]=f.defs[c]:d[c]=e[c];return d}function c(){for(var a=ac().ac,b=2*a.sampleRate,c=a.createBuffer(1,b,a.sampleRate),d=c.getChannelData(0),e=0;b>e;e++)d[e]=2*Math.random()-1;return c}function d(a,b,d){if("noise"==b){var e=a.ac.createBufferSource();return e.buffer=c(),e.loop=!0,e}var f,g,h,i,j=a.wavetable,k=a.ac.createOscillator();try{if(j.hasOwnProperty(b)){if(g=j[b].wave,j[b].freq){h=0;for(f in j[b].freq)i=Number(f),d>i&&i>h&&(h=i,g=j[b].freq[h])}!k.setPeriodicWave&&k.setWaveTable?k.setWaveTable(g):k.setPeriodicWave(g)}else k.type=b}catch(l){window.console&&window.console.log(l),k.type="square"}return k.frequency.value=d,k}a.timeOffset=.0625,a.dequeueTime=.5,a.bufferSecs=2,a.toneLength=1,a.cleanupDelay=.1,a.prototype.setTimbre=function(a){this._timbre=b(a,this._atop)},a.prototype.getTimbre=function(a){return b(this._timbre,this._atop)},a.prototype.setVolume=function(a){this._out&&(isNaN(a)||(this._out.gain.value=a))},a.prototype.getVolume=function(a){return this._out?this._out.gain.value:0},a.prototype.silence=function(){var a,b,c,d=1;this._queue.length=0,this._minQueueTime=1/0,this._maxScheduledTime=0,this._startSet.length=0,b=this._finishSet,this._finishSet={},c=this._callbackSet,this._callbackSet=[],this._out&&(this._out.disconnect(),d=this._out.gain.value),this._atop=ac(),this._out=this._atop.ac.createGain(),this._out.gain.value=d,this._out.connect(this._atop.out);for(a in b)this._trigger("noteoff",b[a]);for(a=0;a<c.length;++a)c[a].callback()},a.prototype.now=function(){return null!=this._now?this._now:(this._startPollTimer(!0),this._now)},a.prototype.on=function(a,b){this._handlers.hasOwnProperty(a)||(this._handlers[a]=[]),this._handlers[a].push(b)},a.prototype.off=function(a,b){if(this._handlers.hasOwnProperty(a))if(b){var c,d=this._handlers[a];for(c=0;c<d.length;++c)d[c]===b&&(d.splice(c,1),c-=1)}else this._handlers[a]=[]},a.prototype._trigger=function(a,b){var c,d=this._handlers[a];if(d){if(1==d.length)return void d[0](b);for(d=d.slice(),c=0;c<d.length;++c)d[c](b)}},a.prototype._makeSound=function(b){var c,e,f,g,h=b.timbre||this._timbre,i=b.time+a.timeOffset,j=i+b.duration,k=Math.min(j,i+h.attack),l=h.decay*Math.pow(440/b.frequency,h.decayfollow),m=k,n=j+h.release,o=h.detune&&1!=h.detune,p=h.gain*b.velocity*(o?.5:1),q=this._atop.ac;if(b.duration>0&&b.velocity>0){for(c=q.createGain(),c.gain.setValueAtTime(0,i),c.gain.linearRampToValueAtTime(p,k);k+1/32>m&&j>m+1/256;)m+=1/256,c.gain.linearRampToValueAtTime(p*(h.sustain+(1-h.sustain)*Math.exp((k-m)/l)),m);c.gain.setTargetAtTime(p*h.sustain,m,l),c.gain.setValueAtTime(p*(h.sustain+(1-h.sustain)*Math.exp((k-j)/l)),j),c.gain.linearRampToValueAtTime(0,n),c.connect(this._out),!h.cutoff&&!h.cutfollow||h.cutoff==1/0?e=c:(e=q.createBiquadFilter(),e.frequency.value=h.cutoff+b.frequency*h.cutfollow,e.Q.value=h.resonance,e.connect(c)),f=d(this._atop,h.wave,b.frequency),f.connect(e),f.start(i),f.stop(n),o&&(g=d(this._atop,h.wave,b.frequency*h.detune),g.connect(e),g.start(i),g.stop(n)),b.gainNode=c,b.oscillators=[f],o&&b.oscillators.push(g),b.cleanuptime=n}else b.duration=0;this._startSet.push(b)},a.prototype._truncateSound=function(b,c){if(c<b.time+b.duration&&(b.duration=Math.max(0,c-b.time),b.gainNode)){var d,e=b.timbre||this._timbre,f=b.time+a.timeOffset,g=c+a.timeOffset,h=Math.min(g,f+e.attack),i=e.decay*Math.pow(440/b.frequency,e.decayfollow),j=g+e.release,k=j+a.cleanupDelay,l=e.detune&&1!=e.detune,m=e.gain*b.velocity*(l?.5:1),n=b.gainNode;if(n.gain.cancelScheduledValues(g),f>=g?n.gain.setValueAtTime(0,g):h>=g?n.gain.linearRampToValueAtTime(m*(g-f)/(h-f),g):n.gain.setValueAtTime(m*(e.sustain+(1-e.sustain)*Math.exp((h-g)/i)),g),n.gain.linearRampToValueAtTime(0,j),b.oscillators)for(d=0;d<b.oscillators.length;++d)b.oscillators[d].stop(j);b.cleanuptime=k}},a.prototype._doPoll=function(){if(this._pollTimer=null,this._now=null,Le)return void this.silence();var b,c,d,e,f,g,h,i,j=this._atop.ac.currentTime+5e-4,k=[];if(this._minQueueTime-j<=a.bufferSecs){for(this._unsortedQueue&&(this._queue.sort(function(a,b){return a.time!=b.time?a.time-b.time:a.duration!=b.duration?a.duration-b.duration:a.frequency-b.frequency}),this._unsortedQueue=!1),b=0;b<this._queue.length&&!(this._queue[b].time-j>a.bufferSecs);++b);if(b>0){for(c=this._queue.splice(0,b),b=0;b<c.length;++b)this._makeSound(c[b]);this._minQueueTime=this._queue.length>0?this._queue[0].time:1/0}}for(b=0;b<this._cleanupSet.length;++b)f=this._cleanupSet[b],f.cleanuptime<j&&(f.gainNode&&(f.gainNode.disconnect(),f.gainNode=null),this._cleanupSet.splice(b,1),b-=1);for(e in this._finishSet)f=this._finishSet[e],d=f.time+f.duration,j>=d&&(k.push({order:[d,0],f:this._trigger,t:this,a:["noteoff",f]}),f.cleanuptime!=1/0&&this._cleanupSet.push(f),delete this._finishSet[e]);for(b=0;b<this._callbackSet.length;++b)i=this._callbackSet[b],d=i.time,j>=d&&(k.push({order:[d,1],f:i.callback,t:null,a:[]}),this._callbackSet.splice(b,1),b-=1);for(b=0;b<this._startSet.length;++b)this._startSet[b].time<=j&&(h=f=this._startSet[b],e=f.frequency,g=null,this._finishSet.hasOwnProperty(e)&&(g=this._finishSet[e],g.time<f.time||g.time==f.time&&g.duration<f.duration?(this._truncateSound(g,f.time),k.push({order:[f.time,0],f:this._trigger,t:this,a:["noteoff",g]}),delete this._finishSet[e]):(this._truncateSound(f,g.time),g=f)),this._startSet.splice(b,1),b-=1,f.duration>0&&f.velocity>0&&g!==f&&(this._finishSet[e]=f,k.push({order:[f.time,2],f:this._trigger,t:this,a:["noteon",f]})));for(this._startPollTimer(),k.sort(function(a,b){return a.order[0]!=b.order[0]?a.order[0]-b.order[0]:a.order[1]-b.order[1]}),b=0;b<k.length;++b)i=k[b],i.f.apply(i.t,i.a)},a.prototype._startPollTimer=function(b){if(!this._pollTimer||null==this._now){var c,d,e=this,f=function(){e._doPoll()},g=1/0;if(this._pollTimer&&(clearTimeout(this._pollTimer),
this._pollTimer=null),b)return this._now=cc(),void(this._pollTimer=setTimeout(f,0));for(c=0;c<this._startSet.length;++c)g=Math.min(g,this._startSet[c].time);for(c in this._finishSet)g=Math.min(g,this._finishSet[c].time+this._finishSet[c].duration);for(c=0;c<this._callbackSet.length;++c)g=Math.min(g,this._callbackSet[c].time);this._cleanupSet.length>0&&(g=Math.min(g,this._cleanupSet[0].cleanuptime+1)),g=Math.min(g,this._minQueueTime-a.dequeueTime),d=Math.max(.001,g-this._atop.ac.currentTime),isNaN(d)||d==1/0||(this._pollTimer=setTimeout(f,Math.round(1e3*d)))}},a.prototype.tone=function(b,c,d,f,g,h){if(this._atop){"object"==typeof b&&(null==d&&(d=b.velocity),null==c&&(c=b.duration),null==f&&(f=b.delay),null==g&&(g=b.timbre),null==h&&(h=b.origin),b=b.pitch);var i,j;if(b||(b="C"),isNaN(b)?(i=fc(b),j=dc(i)):(j=Number(b),0>j?(i=-j,j=dc(i)):i=ec(j)),g||(g=this._timbre),g!==this._timbre){var k,l=g;g={};for(k in e)k in l?g[k]=l[k]:g[k]=e[k]}var m=(this._atop.ac,this.now()),n=m+(f||0),o={time:n,on:!1,frequency:j,midi:i,velocity:null==d?1:d,duration:null==c?a.toneLength:c,timbre:g,instrument:this,gainNode:null,oscillators:null,cleanuptime:1/0,origin:h};n<m+a.bufferSecs?this._makeSound(o):(!this._unsortedQueue&&this._queue.length&&n<this._queue[this._queue.length-1].time&&(this._unsortedQueue=!0),this._queue.push(o),this._minQueueTime=Math.min(this._minQueueTime,o.time))}},a.prototype.schedule=function(a,b){this._callbackSet.push({time:this.now()+a,callback:b})},a.prototype.play=function(a){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s=Array.prototype.slice.call(arguments),t=null,u={},v=0,w=[];if(s.length&&"function"==typeof s[s.length-1]&&(t=s.pop()),!this._atop)return void(t&&t());if(e=0,"object"==typeof s[0]){for(g in s[0])s[0].hasOwnProperty(g)&&(u[g]=s[0][g]);e=1,u.song&&s.push(u.song)}for(;e<s.length;++e)for(c=s[e].split(/\n(?=X:)/),g=0;g<c.length;++g)d=ic(c[g]),d&&(!u.tempo&&d.tempo&&(u.tempo=d.tempo,d.unitbeat&&(u.tempo*=d.unitbeat/(d.unitnote||1))),d.voice&&w.push(d));for(u.tempo||(u.tempo=120),null==u.volume&&(u.volume=1),p=60/u.tempo,g=0;g<w.length;++g){d=w[g];for(l in d.voice)if(f=b(u.timbre||d.voice[l].timbre||d.timbre||this._timbre,this._atop),j=d.voice[l].stems){for(h=0,k=0;k<j.length;++k){for(n=j[k],i=1/Math.sqrt(n.notes.length),m=0;m<n.notes.length;++m)o=n.notes[m],o.holdover||(q=(o.time||n.time)*p,n.staccato?q=Math.min(Math.min(q,p/16),f.attack+f.decay):!o.slurred&&q>=1/8&&(q-=1/32),r=(o.velocity||1)*i*u.volume,this.tone(o.pitch,q,r,h,f,o));h+=n.time*p}v=Math.max(h,v)}}this._maxScheduledTime=Math.max(this._maxScheduledTime,this.now()+v),t&&this.schedule(v,t)};var e=a.defaultTimbre={wave:"square",gain:.1,attack:.002,decay:.4,decayfollow:0,sustain:0,release:.1,cutoff:0,cutfollow:0,resonance:0,detune:0};return a.pitchToMidi=function(a){return"string"==typeof a?fc(a):a},a.midiToPitch=function(a){return"number"==typeof a?gc(a):a},a}(),ff=/^([A-Za-z]):\s*(.*)$/,gf=/(?:\[[A-Za-z]:[^\]]*\])|\s+|%[^\n]*|![^\s!:|\[\]]*!|\+[^+|!]*\+|[_<>@^]?"[^"]*"|\[|\]|>+|<+|(?:(?:\^+|_+|=|)[A-Ga-g](?:,+|'+|))|\(\d+(?::\d+){0,2}|\d*\/\d+|\d+\/?|\/+|[xzXZ]|\[?\|\]?|:?\|:?|::|./g;a.extend(!0,a,{cssHooks:{turtlePenStyle:Ra(),turtlePenDown:Sa(),turtleSpeed:nb(),turtleEasing:ob(),turtleForward:rb(),turtleTurningRadius:Qa(),turtlePosition:zb("turtlePosition","tx","ty",!0),turtlePositionX:sb("tx",parseFloat,"px",!0),turtlePositionY:sb("ty",parseFloat,"px",!0),turtleRotation:sb("rot",vb,"deg",!0),turtleScale:zb("turtleScale","sx","sy",!1),turtleScaleX:sb("sx",h,"",!1),turtleScaleY:sb("sy",h,"",!1),turtleTwist:sb("twi",xa,"deg",!1),turtleHull:oa(),turtleTimbre:Xb(),turtleVolume:Yb()},cssNumber:{turtleRotation:!0,turtleSpeed:!0,turtleScale:!0,turtleScaleX:!0,turtleScaleY:!0,turtleTwist:!0},support:{turtle:!0}}),a.extend(!0,a.fx,{step:{turtlePosition:yb("turtlePosition",!0),turtleRotation:wb("turtleRotation"),turtleScale:yb("turtleScale",!1),turtleTwist:wb("turtleTwist")},speeds:{turtle:0}}),oc.helptext=[];var hf={rt:uc("rt",1,["<u>rt(degrees)</u> Right turn. Pivots clockwise by some degrees: <mark>rt 90</mark>","<u>rt(degrees, radius)</u> Right arc. Pivots with a turning radius: <mark>rt 90, 50</mark>"],Ac),lt:uc("lt",1,["<u>lt(degrees)</u> Left turn. Pivots counterclockwise by some degrees: <mark>lt 90</mark>","<u>lt(degrees, radius)</u> Left arc. Pivots with a turning radius: <mark>lt 90, 50</mark>"],Ac),fd:uc("fd",1,["<u>fd(pixels)</u> Forward. Moves ahead by some pixels: <mark>fd 100</mark>"],Bc),bk:uc("bk",1,["<u>bk(pixels)</u> Back. Moves in reverse by some pixels: <mark>bk 100</mark>"],Bc),slide:uc("slide",1,["<u>move(x, y)</u> Slides right x and forward y pixels without turning: <mark>slide 50, 100</mark>"],Cc),movexy:uc("movexy",1,["<u>movexy(x, y)</u> Changes graphing coordinates by x and y: <mark>movexy 50, 100</mark>"],Dc),moveto:uc("moveto",1,["<u>moveto(x, y)</u> Move to graphing coordinates (see <u>getxy</u>): <mark>moveto 50, 100</mark>","<u>moveto(obj)</u> Move to page coordinates or an object on the page (see <u>pagexy</u>): <mark>moveto lastmousemove</mark>"],Ec),jump:uc("jump",1,["<u>jump(x, y)</u> Move without drawing (compare to <u>slide</u>): <mark>jump 0, 50</mark>"],Fc(Cc)),jumpxy:uc("jumpxy",1,["<u>jumpxy(x, y)</u> Move without drawing (compare to <u>movexy</u>): <mark>jump 0, 50</mark>"],Fc(Dc)),jumpto:uc("jumpto",1,["<u>jumpto(x, y)</u> Move without drawing (compare to <u>moveto</u>): <mark>jumpto 50, 100</mark>"],Fc(Ec)),turnto:uc("turnto",1,["<u>turnto(degrees)</u> Turn to a direction. North is 0, East is 90: <mark>turnto 270</turnto>","<u>turnto(x, y)</u> Turn to graphing coordinates: <mark>turnto 50, 100</mark>","<u>turnto(obj)</u> Turn to page coordinates or an object on the page: <mark>turnto lastmousemove</mark>"],function(b,c,d){a.isNumeric(d)&&a.isNumeric(c)&&(c=[c,d],d=null);var e=Df;return this.plan(function(f,g){if(b.appear(f),a.isWindow(g)||9===g.nodeType)return void b.resolve(f);var h,i,j,k=null,l=null,m=null;if(a.isNumeric(c))i=wa(c),j=Y(g),l={pageX:j.pageX+1024*Math.sin(i),pageY:j.pageY-1024*Math.cos(i)},k=d;else if(a.isArray(c))m=W(g),m[0]-=c[0],m[1]-=c[1];else if(mb(c))l=c;else try{l=a(c).pagexy()}catch(n){return void b.resolve(f)}m||(m=W(g,l));var o=va(Math.atan2(-m[0],-m[1]));h=ra(g,!0),null!==k&&(i=wa(h.rot),o=C(h.rot,o,null===k?360:k)),o=h.rot+xa(o-h.rot);var p=this.css("turtleTurningRadius");this.css({turtleTurningRadius:0}),this.animate({turtleRotation:o},pb(g,e),qb(g)),this.plan(function(){this.css({turtleTurningRadius:p}),b.resolve(f)})}),this}),home:uc("home",0,["<u>home()</u> Goes home. Jumps to the center without drawing: <mark>do home</mark>"],function(b,c){return this.plan(function(d,e){b.appear(d);var f=this.css("turtlePenDown"),g=this.css("turtleTurningRadius"),h=c||V(e);this.css({turtlePenDown:"up",turtleTurningRadius:0}),this.css({turtlePosition:U(e,a(h).pagexy(),null,0,0),turtleRotation:0,turtleScale:1}),this.css({turtlePenDown:f,turtleTurningRadius:g}),b.resolve(d)}),this}),copy:uc("copy",0,["<u>copy()</u> makes a new turtle that is a copy of this turtle."],function(b){var c=this.clone().insertAfter(this);return c.hide(),this.plan(function(d,e){b.appear(d);var f=Oa(this),g=Oa(c);for(var h in f)g[h]=f[h];c.attr("style",this.attr("style"));for(var i in a.cssHooks){var j=this.css(i);c.css(i,j)}var k=this.prop("attributes");for(var l in k)c.attr(k[l].name,k[l].value);var m=c.canvas(),n=this.canvas();if(m&&n){m.width=n.width,m.height=n.height;var o=m.getContext("2d");o.drawImage(n,0,0)}c.show(),b.resolve(d)}),lc(c,this),c}),pen:uc("pen",1,["<u>pen(color, size)</u> Selects a pen. Chooses a color and/or size for the pen: <mark>pen red</mark>; <mark>pen 0</mark>; <mark>pen erase</mark>; <mark>pen blue, 5</mark>.","<u>pen(on-or-off)</u> Turns the pen on or off: <mark>pen off</mark>; <mark>pen on</mark>."],function(b,c,d){var e=Md(arguments,1,{lineCap:/^(?:butt|square|round)$/,lineJoin:/^(?:bevel|round|miter)$/,lineWidth:a.isNumeric,penStyle:"*"});c=e.penStyle,c&&"function"==typeof c&&(c.helpname||c.name)&&(c=c.helpname||c.name),0===e.lineWidth||null===c?c="none":c===He?c="black":a.isPlainObject(c)&&(c=La(c));var f=Df;return this.plan(function(a,d){b.appear(a);var g=!L(d)&&!pc(this),h=g&&Ka(this.css("turtlePenStyle")),i=h&&"down"==this.css("turtlePenDown"),j=!1;if(c===!1||c===!0||"down"==c||"up"==c?(this.css("turtlePenDown",c),j=!0):(e.lineWidth&&(c+=";lineWidth:"+e.lineWidth),e.lineCap&&(c+=";lineCap:"+e.lineCap),e.lineJoin&&(c+=";lineJoin:"+e.lineJoin),this.css("turtlePenStyle",c),this.css("turtlePenDown","none"==c?"up":"down")),g){var k=Ka(this.css("turtlePenStyle")),l=k&&(k.strokeStyle||k.savePath&&"gray")||h&&h.strokeStyle||"gray",m={},n=k&&"down"==this.css("turtlePenDown"),o=new We(l+" pencil",this.parent()),p=this.height();o.css({zIndex:1,turtlePosition:U(o.get(0),this.pagexy(),null,0,0),turtleRotation:this.css("turtleRotation"),turtleSpeed:1/0}),i?n||(m.turtleForward="+="+p,m.opacity=0):(o.css({turtleForward:"+="+p,opacity:0}),n&&(m.turtleForward="-="+p,m.opacity=1)),h&&!k&&"down"==i?(m.turtleForward="+="+p,m.opacity=0):h==k||h&&k&&h.strokeStyle==k.strokeStyle||(o.css({opacity:0}),m.opacity=1),o.animate(m,pb(d,f)),this.queue(function(a){o.done(function(){o.remove(),a()})})}this.plan(function(){b.resolve(a)})}),this}),fill:uc("fill",0,["<u>fill(color)</u> Fills a path traced using <u>pen path</u>: <mark>pen path; rt 100, 90; fill blue</mark>"],function(b,c){c?a.isPlainObject(c)&&(c=La(c)):c="none";var d=Ka(c,"fillStyle");return this.plan(function(a,c){b.appear(a),cb(c,d),b.resolve(a)}),this}),dot:uc("dot",0,["<u>dot(color, diameter)</u> Draws a dot. Color and diameter are optional: <mark>dot blue</mark>"],Lc(Mc)),box:uc("box",0,["<u>box(color, size)</u> Draws a box. Color and size are optional: <mark>dot blue</mark>"],Lc(Nc)),arrow:uc("arrow",0,["<u>arrow(color, size)</u> Draws an arrow. <mark>arrow red, 100</mark>"],Lc(Oc)),mirror:uc("mirror",1,["<u>mirror(flipped)</u> Mirrors the turtle across its main axis, or unmirrors if flipped if false. <mark>mirror(true)</mark>"],function(b,c){return this.plan(function(d,e){b.appear(d);var f=a.map(a.css(e,"turtleScale").split(" "),parseFloat);1===f.length&&f.push(f[0]),f[0]*f[1]<0==!c&&(f[0]=-f[0],this.css("turtleScale",f.join(" "))),b.resolve(d)}),this}),twist:uc("twist",1,["<u>twist(degrees)</u> Set the primary direction of the turtle. Allows use of images that face a different direction than 'up': <mark>twist(-90)</mark>"],function(b,c){return this.plan(function(d,e){b.appear(d),a.isWindow(e)||9===e.nodeType||(this.css("turtleTwist",c),b.resolve(d))}),this}),scale:uc("scale",1,["<u>scale(factor)</u> Scales all motion up or down by a factor. To double all drawing: <mark>scale(2)</mark>"],Hc),grow:uc("grow",1,["<u>grow(factor)</u> Changes the size of the element by a factor. To double the size: <mark>grow(2)</mark>"],Ic),pause:uc("pause",1,["<u>pause(seconds)</u> Pauses some seconds before proceeding. <mark>fd 100; pause 2.5; bk 100</mark>","<u>pause(turtle)</u> Waits for other turtles to be done before proceeding. <mark>t = new Turtle().fd 100; pause t; bk 100</mark>"],function(b,c){var d=null,e=null;return c&&a.isFunction(c.done)?(d=c,e=c.done):a.isFunction(c)&&(e=c),e?this.queue(function(){var b=this;e.call(d,function(){var c=b;b=null,c&&a.dequeue(c)})}):this.plan(function(a,d){b.appear(a),rc(d,c),this.plan(b.resolver(a))}),this}),st:uc("st",0,["<u>st()</u> Show turtle. The reverse of <u>ht()</u>. <mark>do st</mark>"],function(a){return this.plan(function(b){a.appear(b),this.show(),a.resolve(b)}),this}),ht:uc("ht",0,["<u>ht()</u> Hide turtle. The turtle can be shown again with <u>st()</u>. <mark>do ht</mark>"],function(a){return this.plan(function(b){a.appear(b),this.hide(),a.resolve(b)}),this}),pu:function(){return this.pen(!1,sc(arguments,0))},pd:function(){return this.pen(!0,sc(arguments,0))},pe:function(){return this.pen("erase",sc(arguments,0))},pf:function(){return this.pen("path",sc(arguments,0))},clip:uc("clip",1,["<u>Clips tranparent bits out of the image of the sprite, and sets the hit region."],function(b,c){return null==c&&(c=.125),this.plan(function(d,e){if(b.appear(d),"CANVAS"==e.tagName){var f=De(e,c),g=a(e),h=y(e);Fe(e,f),Ge(f,parseFloat(g.css("width"))/e.width,parseFloat(g.css("height"))/e.height,-h[0],-h[1]),g.css("turtleHull",f)}b.resolve(d)})}),say:uc("say",1,['<u>say(words)</u> Say something. Use English words.<mark>say "Let\'s go!"</mark>'],function(a,b){return this.plan(function(c,d){a.appear(c),this.queue(function(d){Sc(b,function(){a.resolve(c),d()})})}),this}),play:uc("play",1,['<u>play(notes)</u> Play notes. Notes are specified in <a href="http://abcnotation.com/" target="_blank">ABC notation</a>. <mark>play "de[dBFA]2[cGEC]4"</mark>'],function(b,c){return this.plan(function(c,d){b.appear(c),this.queue(function(e){var f=Zb(d),g=a.makeArray(b.args),h=!0,i=function(){b.resolve(c),e()};g.length>0&&a.isPlainObject(g[0])&&g[0].hasOwnProperty("wait")&&(h=g[0].wait),h&&g.push(i),f.play.apply(f,g),h||i()})}),this}),tone:zc("tone",["<u>tone(freq)</u> Immediately sound a tone. <u>tone(freq, 0)</u> Stop sounding the tone. <u>tone(freq, v, secs)</u> Play a tone with a volume and duration. Frequency may be a number in Hz or a letter pitch. <mark>tone 440, 5</mark>"],function(a,b){var c=arguments;return this.each(function(a,b){var d=Zb(b);d.tone.apply(d,c)})}),silence:zc("silence",["<u>silence()</u> immediately silences sound from play() or tone()."],function(){return this.each(function(a,b){var c=Zb(b);c.silence()})}),speed:uc("speed",1,["<u>speed(persec)</u> Set one turtle's speed in moves per second: <mark>turtle.speed 60</mark>"],function(a,b){return this.plan(function(c,d){a.appear(c),this.css("turtleSpeed",b),this.plan(function(){a.resolve(c)})}),this}),wear:uc("wear",1,["<u>wear(color)</u> Sets the turtle shell color: <mark>wear turquoise</mark>","<u>wear(url)</u> Sets the turtle image url: <mark>wear 'http://bit.ly/1bgrQ0p'</mark>"],function(b,c,d){if(("object"==typeof c||"number"==typeof c)&&"string"==typeof d){var e=d;d=c,c=e}"number"==typeof d&&(d={height:d});var f=nd(c,"turtle"),g=Df;return f?(d&&a.extend(f.css,d),this.plan(function(a,c){b.appear(a),this.css({backgroundImage:"none"});var d=!1,e=null;hb(this,f,function(){d=!0;var a=e;a&&(e=null,a())}),pc(this)||this.delay(pb(c,g)),d||this.pause({done:function(a){d?a():e=a}}),this.plan(function(){b.resolve(a)})}),this):this}),saveimg:uc("saveimg",1,["<u>saveimg(filename)</u> Saves the turtle's image as a file. <mark>t.saveimg 'mypicture.png'</mark>"],function(a,b){return this.plan(function(c,d){a.appear(c);var e=!1;b||(b="img");var f=this.canvas();if(f){var g=f.toDataURL(),h=/^data:image\/(\w+);base64,(.*)$/i.exec(g);h?(h[1]&&b.toLowerCase().lastIndexOf("."+h[1].toLowerCase())!=Math.max(0,b.length-h[1].length-1)&&(b+="."+h[1]),e=!0,sf.save(b,atob(h[2]),function(){a.resolve(c)})):Sf.html('<span style="color:red">Cannot saveimg: canvas toDataURL did not work as expected.</span>')}else Sf.html('<span style="color:red">Cannot saveimg: not a canvas</span>');e||a.resolve(c)})}),drawon:uc("drawon",1,["<u>drawon(canvas)</u> Switches to drawing on the specified canvas. <mark>A = new Sprite('100x100'); drawon A; pen red; fd 50; done -> A.rt 360</mark>"],function(b,c){return this.each(function(){var a=Oa(this);a.drawOnCanvasSync&&lc(this,a.drawOnCanvasSync),a.drawOnCanvasSync=c}),lc(c,this),this.plan(function(d,e){b.appear(d);var f=Oa(e);c&&c!==Ie?c.jquery&&a.isFunction(c.canvas)?f.drawOnCanvas=c.canvas():c.tagName&&"CANVAS"==c.tagName?f.drawOnCanvas=c:(1==c.nodeType||9==c.nodeType)&&(f.drawOnCanvas=a(c).canvas()):f.drawOnCanvas=null,b.resolve(d)})}),label:uc("label",1,["<u>label(text)</u> Labels the current position with HTML: <mark>label 'remember'</mark>","<u>label(text, styles, labelsite)</u> Optional position specifies 'top', 'bottom', 'left', 'right', and optional styles is a size or CSS object: <mark>label 'big', { color: red, fontSize: 100 }, 'bottom'</mark>"],function(b,c,d,e){if((!e||"string"==typeof e)&&(a.isNumeric(d)||a.isPlainObject(d))){var f=e;e=d,d=f}a.isNumeric(e)&&(e={fontSize:e}),null==d&&(d=e&&"labelSide"in e?e.labelSide:e&&"label-side"in e?e["label-side"]:d="rotated scaled");var g=Df;return this.plan(function(f,h){b.appear(f);for(var i={},j=this.prop("style"),k=0;k<j.length;++k){var l=j[k];/^(?:width|height|opacity|background-image|background-size)$/.test(l)||/transform/.test(l)||(i[a.camelCase(l)]=j[l])}a.extend(i,{position:"absolute",display:"table",top:0,left:0},e);var m=Fd(c,"label").result.css(i).addClass("turtlelabel").appendTo(za());(m.hasClass("turtleinput")||m.find(".turtleinput").length)&&Qb.apply(m.get(0)),e&&"id"in e&&m.attr("id",e.id),e&&"class"in e&&m.addClass(e["class"]);var n=/\brotated\b/.test(d),o=/\bscaled\b/.test(d);m.css({turtlePosition:U(m.get(0),this.pagexy(),null,0,0),turtleRotation:n?this.css("turtleRotation"):0,turtleScale:o?this.css("turtleScale"):1});var p=m.get(0).getBoundingClientRect();/\b(?:top|bottom)\b/.test(d)&&(i.top=(/\btop\b/.test(d)?-1:1)*p.height/2),/\b(?:left|right)\b/.test(d)&&(i.left=(/\bleft\b/.test(d)?-1:1)*p.width/2),m.css(i),pc(this)||this.delay(pb(h,g)),this.plan(function(){b.resolve(f)})})}),reload:uc("reload",0,["<u>reload()</u> Does a reload, recycling content (cycling animated gifs)."],function(b){return this.plan(function(c,d){if(b.appear(c),a.isWindow(d)||9===d.nodeType)return Ie.location.reload(),void b.resolve(c);if(d.src){var e=d.src;d.src="",d.src=e}b.resolve(c)}),this}),hatch:function(b,c){if(this.length){c!==He||a.isNumeric(b)||(c=b,b=1);var d=this[0];if(a.isWindow(d)||9===d.nodeType?d=za():/^(?:br|img|input|hr|canvas)$/i.test(d.tagName)&&(d=d.parentElement),1===b)return pd("function"==typeof c?c(0):c,d,"turtle");for(var e=0,f=[];b>e;++e)f.push(pd("function"==typeof c?c(e):c,d,"turtle")[0]);return a(f)}},pagexy:vc("pagexy",["<u>pagexy()</u> Page coordinates {pageX:, pageY}, top-left based: <mark>c = pagexy(); fd 500; moveto c</mark>"],function(){if(this.length){var a=Y(this[0]);return{pageX:a.pageX,pageY:a.pageY}}}),getxy:vc("getxy",["<u>getxy()</u> Graphing coordinates [x, y], center-based: <mark>v = getxy(); move -v[0], -v[1]</mark>"],function(){return this.length?W(this[0]):void 0}),direction:vc("direction",["<u>direction()</u> Current turtle direction. North is 0; East is 90: <mark>direction()</mark>","<u>direction(obj)</u> <u>direction(x, y)</u> Returns the direction from the turtle towards an object or coordinate. Also see <u>turnto</u>: <mark>direction lastclick</mark>"],function(b,c){if(this.length){var d,e=this[0],f=b;if(f!==He){if(d=a(e).pagexy(),a.isNumeric(c)&&a.isNumeric(b)&&(f=[b,c]),a.isArray(f)&&(f=X(e,[f])[0]),!mb(f))try{f=a(f).pagexy()}catch(g){}return f?va(Math.atan2(f.pageX-d.pageX,d.pageY-f.pageY)):NaN}return a.isWindow(e)||9===e.nodeType?0:aa(e)}}),distance:vc("distance",["<u>distance(obj)</u> Returns the distance from the turtle to another object: <mark>distance lastclick</mark>","<u>distance(x, y)</u> Returns the distance from the turtle to graphing coorindates: <mark>distance(100, 0)</mark>"],function(b,c){if(this.length){var d,e,f=this[0],g=a(f).pagexy();if(a.isNumeric(c)&&a.isNumeric(b)&&(b=[b,c]),a.isArray(b)&&(b=X(f,[b])[0]),!mb(b))try{b=a(b).pagexy()}catch(h){}return b?(d=b.pageX-g.pageX,e=b.pageY-g.pageY,Math.sqrt(d*d+e*e)):NaN}}),canvas:zc("canvas",["<u>turtle.canvas()</u> The canvas for the turtle image. Draw on the turtle: <mark>c = turtle.canvas().getContext('2d'); c.fillStyle = red; c.fillRect(10, 10, 30, 30)</mark>"],function(){return this.filter("canvas").get(0)||this.find("canvas").get(0)}),imagedata:zc("imagedata",["<u>imagedata()</u> Returns the image data for the turtle. <mark>imdat = imagedata(); write imdat.data.length, 'bytes'</mark>","<u>imagedata(imdat)</u> Sets the image data for the turtle. <mark>imagedata({width: 1, height:1, data:[255,0,0,255]});</mark>"],function(b){var c=this.canvas();if(!c){if(b)throw new Error("can only set imagedata on a canvas like a Sprite");var d=this.filter("img").get(0);if(!d)return;c=Ga(d.naturalWidth,d.naturalHeight),c.getContext("2d").drawImage(d,0,0)}var e=c.getContext("2d");if(!b)return e.getImageData(0,0,c.width,c.height);if(!(b instanceof ImageData)){if("object"!=typeof b||!a.isNumeric(b.width)||!a.isNumeric(b.height)||!(a.isArray(b.data)||b.data instanceof Uint8ClampedArray||b.data instanceof Uint8Array))return;for(var f=e.createImageData(Math.round(b.width),Math.round(b.height)),g=Math.min(b.data.length,f.data.length),h=0;g>h;++h)f.data[h]=b.data[h];b=f}if(b.width!=c.width||b.height!=c.height){var i=y(c);c.width=b.width,c.height=b.height;var j=y(c);Lb(c,i,j),a(c).css("turtleHull","auto"),e=c.getContext("2d")}e.putImageData(b,0,0)}),cell:zc("cell",["<u>cell(r, c)</u> Row r and column c in a table. Use together with the table function: <mark>g = table 8, 8; g.cell(0,2).text 'hello'</mark>"],function(b,c){var d=this.find(a.isNumeric(b)?"tr:nth-of-type("+(b+1)+")":"tr");return d.find(a.isNumeric(c)?"td:nth-of-type("+(c+1)+")":"td")}),shown:vc("shown",["<u>shown()</u> True if turtle is shown, false if hidden: <mark>do ht; write shown()</mark>"],function(){var a=this.get(0);return a&&!L(a)}),hidden:vc("hidden",["<u>hidden()</u> True if turtle is hidden: <mark>do ht; write hidden()</mark>"],function(){var a=this.get(0);return!a||L(a)}),inside:vc("inside",["<u>inside(obj)</u> True if the turtle is encircled by obj: <mark>inside(window)</mark>"],function(b){if(!b)return!1;if("string"==typeof b&&(b=a(b)),b.jquery){if(!b.length||L(b[0]))return!1;b=b[0]}for(var c,d=N(b),e=null,f=!1,g=!0,h=0;g&&h<this.length;++h){if(c=this[h],Q(d,N(c)))return!1;e||(e=_(b),f=S(e,d)),f&&R(d,N(c))||(g&=mb(c)?ea(c,e):ka(e,_(c)))}return!!g}),touches:vc("touches",["<u>touches(obj)</u> True if the turtle touches obj: <mark>touches(lastclick)</mark>","<u>touches(color)</u> True if the turtle touches a drawn color: <mark>touches red</mark>"],function(b,c){if(!this.length||L(this[0]))return!1;if("function"==typeof b&&cd(b.helpname)&&(b=b.helpname),"color"==b||cd(b))return gb(this[0],"color"==b?null:b);if(a.isNumeric(b)&&a.isNumeric(c)&&(b=[b,c]),a.isArray(b)&&2==b.length&&a.isNumeric(b[0])&&a.isNumeric(b[1])&&(b=X(this[0]||document.body,[b])[0]),!b)return!1;"string"==typeof b&&(b=a(b)),b.jquery||a.isArray(b)||(b=[b]);for(var d,e,f,g,h,i,j=!1,k=0;!j&&k<this.length;++k)if(f=this[k],g=N(f),0!=g.width)for(h=null,d=0;!j&&d<b.length;++d)e=b[d],i=N(e),Q(g,i)||(0!=i.width||null!=e.pageX&&null!=e.pageY)&&(h||(h=_(f)),j|=mb(e)?ea(e,h):ja(h,_(e)));return!!j}),within:vc("within",["<u>within(distance, obj)</u> Filters elements to those within distance of obj: <mark>$('.turtle').within(100, lastclick)</mark>"],function(a,b,c){return Mb(this,!0,a,b,c)}),notwithin:vc("notwithin",["<u>within(distance, obj)</u> Filters elements to those further than distance of obj: <mark>$('.turtle').notwithin(100, lastclick)</mark>"],function(a,b,c){return Mb(this,!1,a,b,c)}),nearest:vc("nearest",["<u>nearest(obj)</u> Filters elements to those nearest obj<mark>$('.turtle').neareest(lastclick)</mark>"],function(b,c){var d,e,f,g=[],h=1/0;if(d=a.isNumeric(d)&&a.isNumeric(c)?[b,c]:b,a.isArray(d)&&(d=X(this[0]||document.body,[d])[0]),!mb(d))try{d=a(d).pagexy()}catch(i){d=null}for(f=0;f<this.length;f++)if(e=N(this[f]),!g.length||!O(d,h,e)){var j=Y(this[f]),k=d.pageX-j.pageX,l=d.pageY-j.pageY,m=k*k+l*l;h>=m&&(h>m&&(h=m,g.length=0),g.push(this[f]))}return a(g)}),done:zc("done",["<u>done(fn)</u> Calls fn when animation is complete. Use with await: <mark>await done defer()</mark>"],function(a){var b=this;return this.promise().done(function(){if(b){var c=b;Me+=1,setTimeout(function(){Me-=1,c.promise().done(a)},0)}else a.apply(this,arguments)})}),plan:zc("plan",["<u>plan(fn)</u> Runs fn in the animation queue. For planning logic: <mark>write getxy(); fd 50; plan -> write getxy(); bk 50"],function(c,d,e){function f(f,g,h){var i=e?function(){d.apply(a(f),e)}:function(){d.call(a(f),g,f)},j=(h.length&&h[h.length-1],function(){var d=a.queue(this,c),e=[];"inprogress"===d[0]&&e.unshift(d.shift()),a.queue(f,c,e),i(),Array.prototype.push.apply(a.queue(f,c),d),b(f,c)});j.finish=i,a.queue(f,c,j)}a.isFunction(c)&&(e=d,d=c,c="fx");for(var g,h=this.length,i=0;h>i;++i){g=this[i],Uc(g,c);var j=a.queue(g,c);j.length?f(g,i,j):e?d.apply(a(g),e):d.call(a(g),i,g)}return this})},jf={},kf=0,lf=null,mf=null;Xc(hf,"move","slide"),Xc(hf,"direct","plan"),Xc(hf,"enclosedby","inside"),Xc(hf,"bearing","direction"),a.fn.extend(hf);var nf="data:image/gif;base64,R0lGODlhKAAwAPIFAAAAAAFsOACSRTCuSICAgP///wAAAAAAACH5BAlkAAYAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAKAAwAAAD72i6zATEgBCAebHpzUnxhDAMAvhxKOoV3ziuZyo3RO26dTbvgXj/gsCO9ysOhENZz+gKJmcUkmA6PSKfSqrWieVtuU+KGNXbXofLEZgR/VHCgdua4isGz9mbmM6U7/94BmlyfUZ1fhqDhYuGgYqMkCOBgo+RfWsNlZZ3ewIpcZaIYaF6XaCkR6aokqqrk0qrqVinpK+fsbZkuK2ouRy0ob4bwJbCibthh6GYebGcY7/EsWqTbdNG1dd9jnXPyk2d38y0Z9Yub2yA6AvWPYk+zEnkv6xdCoPuw/X2gLqy9vJIGAN4b8pAgpQOIlzI8EkCACH5BAlkAAYALAAAAAAoADAAAAPuaLrMBMSAEIB5senNSfGEMAwC+HEo6hXfOK5nKjdE7bp1Nu+BeP+CwI73Kw6EQ1nP6AomZxSSYDo9Ip9KqtaJ5W25Xej3qqGYsdEfZbMcgZXtYpActzLMeLOP6c7f3nVNfEZ7TXSFg4lyZAYBio+LZYiQfHMbc3iTlG9ilGpdjp4ujESiI6RQpqegqkesqqhKrbEpoaa0KLaiuBy6nrxss6+3w7tomo+cDXmBnsoLza2nsb7SN2tl1nyozVOZTJhxysxnd9XYCrrAtT7KQaPruavBo2HQ8xrvffaN+GV5/JbE45fOG8Ek5Q4qXHgwAQA7",of={click:1,dblclick:1,mouseup:1,mousedown:1,mousemove:1},pf=null,qf=[],rf=!1,sf={interrupt:zc("interrupt",["<u>interrupt()</u> Interrupts and aborts all turtle commands."],function(b){if("reset"==b)return void(Le=!1);if("test"==b)return Le?!1:Cf?!0:a.timers.length?!0:Af.length?!0:Me?!0:Yc()?!0:a(":animated").length?!0:a(".turtle").filter(function(){return a.queue(this).length>0}).length>0?!0:a(".turtleinput").filter(function(){return!a(this).prop("disabled")}).length>0?!0:yc()?!0:!1;a(":animated,.turtle").clearQueue().stop(),bc(),a(".turtleinput").prop("disabled",!0),a(Ie).off(".turtleevent"),a("*").not("#_testpanel *").map(function(b,c){a._data(c,"events",null)}),Le=!0,ud(null,null),sd();for(var c=a.timers.length-1;c>=0;--c)a.timers[c].anim&&a.timers[c].anim.elem&&a(a.timers[c].anim.elem).stop(!0,!0);var d=b?"'"+b+"'":"";throw new Error("interrupt("+d+") called")}),cs:wc("cs",["<u>cs()</u> Clear screen. Erases both graphics canvas and body text: <mark>do cs</mark>"],function(){db()}),cg:wc("cg",["<u>cg()</u> Clear graphics. Does not alter body text: <mark>do cg</mark>"],function(){db("canvas labels")}),ct:wc("ct",["<u>ct()</u> Clear text. Does not alter graphics canvas: <mark>do ct</mark>"],function(){db("text")}),canvas:zc("canvas",["<u>canvas()</u> Returns the raw turtle canvas. <mark>c = canvas().getContext('2d'); c.fillStyle = red; c.fillRect(100,100,200,200)</mark>"],function(){return Fa()}),sizexy:zc("sizexy",["<u>sizexy()</u> Get the document pixel [width, height]. <mark>[w, h] = sizexy(); canvas('2d').fillRect(0, 0, w, h)</mark>"],Ia),forever:zc("forever",["<u>forever(fn)</u> Calls fn repeatedly, forever. <mark>forever -> fd 2; rt 2</mark>","<u>forever(fps, fn)</u> Calls fn repeating fps per second. <mark>forever 2, -> fd 25; dot blue</mark>"],rd),stop:zc("stop",["<u>stop()</u> stops the current forever loop. <mark>forever -> fd 10; if not inside window then stop()</mark>","<u>stop(fn)</u> stops the forever loop corresponding to fn.","Use <u>break</u> to stop a <u>for</u> or <u>while</u> loop."],td),tick:zc("tick",["<u>tick(fps, fn)</u> Calls fn fps times per second until <u>tick</u> is called again: <mark>c = 10; tick 1, -> c and write(c--) or tick()</mark>"],function(b,c){if(Yc()){var d=a(pf);d.plan(function(){ud(b,c)})}else ud(b,c)}),speed:wc("speed",["<u>speed(mps)</u> Sets default turtle speed in moves per second: <mark>speed Infinity</mark>"],function(a){vd(a)}),say:zc("say",['<u>say(words)</u> Say something. Use English words.<mark>say "Let\'s go!"</mark>'],function(b){if(pf){var c=a(pf);c.say.call(c,b)}else{var d=tc(null,"say",arguments,0);d.appear(null),Sc(b,function(){d.resolve(null)}),d.exit()}}),play:zc("play",['<u>play(notes)</u> Play notes. Notes are specified in <a href="http://abcnotation.com/" target="_blank">ABC notation</a>. <mark>play "de[dBFA]2[cGEC]4"</mark>'],function(){if(pf){var b=a(pf);b.play.apply(b,arguments)}else{var c=tc(null,"play",arguments,0);c.appear(null);var d=$b(),e=a.makeArray(c.args);e.push(function(){c.resolve(null)}),d.play.apply(d,e),c.exit()}}),tone:zc("tone",["<u>tone(freq)</u> Immediately sound a tone. <u>tone(freq, 0)</u> Stop sounding the tone. <u>tone(freq, v, secs)</u> Play a tone with a volume and duration. Frequency may be a number in Hz or a letter pitch. <mark>tone 440, 5</mark>"],function(){if(pf){var b=a(pf);b.tone.apply(b,arguments)}else{var c=$b();c.play.apply(c)}}),silence:zc("silence",["<u>silence()</u> Immediately silences sound from play() or tone()."],function(){if(pf){var b=a(pf);b.silence()}else{var c=$b();c.silence()}}),sync:zc("sync",["<u>sync(t1, t2, t3,...)</u> Selected turtles wait for each other to stop."],lc),remove:zc("remove",["<u>remove(t)</u> Remove selected turtles."],mc),done:zc("done",["<u>done(fn)</u> Calls fn when animation is complete. Use with await: <mark>await done defer()</mark>"],function(b){var c=a(".turtle");return c.promise().done(function(){if(c){var a=c;Me+=1,setTimeout(function(){Me-=1,a.promise().done(b)},0)}else b.apply(this,arguments)})}),load:zc("load",["<u>load(url, cb)</u> Loads data from the url and passes it to cb. <mark>load 'intro', (t) -> write 'intro contains', t</mark>"],function(b,c){var d;return a.ajax(Eb(b,"load"),{async:!!c,complete:function(e){try{if(d=e.responseObject=JSON.parse(e.responseText),"string"==typeof d.data&&"string"==typeof d.file){if(d=d.data,/\.json(?:$|\?|\#)/.test(b))try{d=JSON.parse(d)}catch(f){}}else a.isArray(d.list)&&"string"==typeof d.directory?d=d.list:d.error&&(d=null)}catch(f){null==d&&e&&e.responseText&&(d=e.responseText)}c&&c(d,e)}}),d}),save:zc("save",["<u>save(url, data, cb)</u> Posts data to the url and calls when done. <mark>save 'intro', 'pen gold, 20\\nfd 100\\n'</mark>"],function(b,c,d){if(!b)throw new Error("Missing url for save");var e,f={};if(b=Eb(b,"save"),/\.json(?:$|\?|\#)/.test(b)&&(c=JSON.stringify(c,null,2)),"string"==typeof c||"number"==typeof c)f.data=c;else for(e in c)c.hasOwnProperty(e)&&("string"==typeof c[e]?f[e]=c[e]:f[e]=JSON.stringify(c[e]));if(f&&!f.key){var g=Gb();g&&g.key&&g.user==Db(b)&&(f.key=g.key)}a.ajax(Eb(b,"save"),{type:"POST",data:f,complete:function(a){var b;try{b=JSON.parse(a.responseText)}catch(c){null==b&&a&&a.responseText&&(b=a.responseText)}d&&d(b,a)}})}),append:wc("append",["<u>append(html)</u> Appends text to the document without a new line. <mark>append 'try this twice...'</mark>"],function(b){a.fn.append.apply(a("body"),arguments)}),type:wc("type",["<u>type(text)</u> Types preformatted text like a typewriter. <mark>type 'Hello!\n'</mark>"],Cd),typebox:wc("typebox",["<u>typebox(clr)</u> Draws a colored box as typewriter output. <mark>typebox red</mark>"],function(a,b){null!=b||null==a||cd(a)||(b=a,a=null),Dd(a,b)}),typeline:wc("typebox",["<u>typeline()</u> Same as type '\\n'. <mark>typeline()</mark>"],function(a){Cd((a||"")+"\n")}),write:wc("write",["<u>write(html)</u> Writes a line of text. Arbitrary HTML may be written: <mark>write 'Hello, world!'</mark>"],Ed,function(){return Fd(Array.prototype.join.call(arguments," "),"div")}),read:wc("read",["<u>read(fn)</u> Reads text or numeric input. Calls fn once: <mark>read (x) -> write x</mark>","<u>read(html, fn)</u> Prompts for input: <mark>read 'Your name?', (v) -> write 'Hello ' + v</mark>"],Ed,function(a,b){return Id(a,b,0)}),readnum:wc("readnum",["<u>readnum(html, fn)</u> Reads numeric input. Only numbers allowed: <mark>readnum 'Amount?', (v) -> write 'Tip: ' + (0.15 * v)</mark>"],Ed,function(a,b){return Id(a,b,"number")}),readstr:wc("readstr",["<u>readstr(html, fn)</u> Reads text input. Never converts input to a number: <mark>readstr 'Enter code', (v) -> write v.length + ' long'</mark>"],Ed,function(a,b){return Id(a,b,"text")}),listen:wc("listen",["<u>listen(html, fn)</u> Reads voice input, if the browser supports it:<mark>listen 'Say something', (v) -> write v</mark>"],Ed,function(a,b){
return Id(a,b,"voice")}),menu:wc("menu",["<u>menu(map)</u> shows a menu of choices and calls a function based on the user's choice: <mark>menu {A: (-> write 'chose A'), B: (-> write 'chose B')}</mark>"],Ed,Gd),button:wc("button",["<u>button(text, fn)</u> Writes a button. Calls fn whenever the button is clicked: <mark>button 'GO', -> fd 100</mark>"],Ed,Hd),table:wc("table",["<u>table(m, n)</u> Writes m rows and c columns. Access cells using <u>cell</u>: <mark>g = table 8, 8; g.cell(2,3).text 'hello'</mark>","<u>table(array)</u> Writes tabular data. Each nested array is a row: <mark>table [[1,2,3],[4,5,6]]</mark>"],Ed,Kd),img:wc("img",["<u>img(url)</u> Writes an image with the given address. Any URL can be provided. A name without slashes will be treated as '/img/name'.<mark>t = img 'tree'</mark>"],Ed,Jd),random:zc("random",["<u>random(n)</u> Random non-negative integer less than n: <mark>write random 10</mark>","<u>random(list)</u> Random member of the list: <mark>write random ['a', 'b', 'c']</mark>","<u>random('position')</u> Random page position: <mark>moveto random 'position'</mark>","<u>random('color')</u> Random color: <mark>pen random 'color'</mark>"],qd),rgb:zc("rgb",["<u>rgb(r,g,b)</u> Makes a color out of red, green, and blue parts. <mark>pen rgb(150,88,255)</mark>"],function(a,b,c){return Ld("rgb",[Math.max(0,Math.min(255,Math.floor(a))),Math.max(0,Math.min(255,Math.floor(b))),Math.max(0,Math.min(255,Math.floor(c)))])}),hatch:function(b,c){return a(document).hatch(b,c)},rgba:zc("rgba",["<u>rgba(r,g,b,a)</u> Makes a color out of red, green, blue, and alpha. <mark>pen rgba(150,88,255,0.5)</mark>"],function(a,b,c,d){return Ld("rgba",[Math.max(0,Math.min(255,Math.floor(a))),Math.max(0,Math.min(255,Math.floor(b))),Math.max(0,Math.min(255,Math.floor(c))),d])}),hsl:zc("hsl",["<u>hsl(h,s,l)</u> Makes a color out of hue, saturation, and lightness. <mark>pen hsl(120,0.65,0.75)</mark>"],function(a,b,c){return Ld("hsl",[a,(100*b).toFixed(0)+"%",(100*c).toFixed()+"%"])}),hsla:zc("hsla",["<u>hsla(h,s,l,a)</u> Makes a color out of hue, saturation, lightness, alpha. <mark>pen hsla(120,0.65,0.75,0.5)</mark>"],function(a,b,c,d){return Ld("hsla",[a,(100*b).toFixed(0)+"%",(100*c).toFixed(0)+"%",d])}),click:xc("click",["<u>click(fn)</u> Calls fn(event) whenever the mouse is clicked. <mark>click (e) -> moveto e; label 'clicked'</mark>"]),dblclick:xc("dblclick",["<u>dblclick(fn)</u> Calls fn(event) whenever the mouse is double-clicked. <mark>dblclick (e) -> moveto e; label 'double'</mark>"]),mouseup:xc("mouseup",["<u>mouseup(fn)</u> Calls fn(event) whenever the mouse is released. <mark>mouseup (e) -> moveto e; label 'up'</mark>"]),mousedown:xc("mousedown",["<u>mousedown(fn)</u> Calls fn(event) whenever the mouse is pressed. <mark>mousedown (e) -> moveto e; label 'down'</mark>"]),mousemove:xc("mousemove",["<u>mousemove(fn)</u> Calls fn(event) whenever the mouse is moved. <mark>mousemove (e) -> write 'at ', e.x, ',', e.y</mark>"]),keydown:xc("keydown",["<u>keydown(fn)</u> Calls fn(event) whenever a key is pushed down. <mark>keydown (e) -> write 'down ' + e.key</mark>"]),keyup:xc("keyup",["<u>keyup(fn)</u> Calls fn(event) whenever a key is released. <mark>keyup (e) -> write 'up ' + e.key</mark>"]),keypress:xc("keypress",["<u>keypress(fn)</u> Calls fn(event) whenever a character key is pressed. <mark>keypress (e) -> write 'press ' + e.key</mark>"]),send:zc("send",["<u>send(name)</u> Sends a message to be received by recv. <mark>send 'go'; recv 'go', -> fd 100</mark>"],function(a){var b=arguments,c=Array.prototype.slice.call(b,1),d=uf.sent[a];d||(d=uf.sent[a]=[]),d.push(c),Zc(a)}),recv:zc("recv",["<u>recv(name, fn)</u> Calls fn once when a sent message is received. <mark>recv 'go', (-> fd 100); send 'go'</mark>"],function(a,b){var c=uf.waiting[a];c||(c=uf.waiting[a]=[]),c.push(b),Zc(a)}),abs:zc("abs",["<u>abs(x)</u> The absolute value of x. <mark>see abs -5</mark>"],Math.abs),acos:zc("acos",["<u>acos(x)</u> Trigonometric arccosine, in radians. <mark>see acos 0.5</mark>"],Math.acos),asin:zc("asin",["<u>asin(y)</u> Trigonometric arcsine, in radians. <mark>see asin 0.5</mark>"],Math.asin),atan:zc("atan",["<u>atan(y, x = 1)</u> Trigonometric arctangent, in radians. <mark>see atan 0.5</mark>"],function(a,b){return Math.atan2(a,b==He?1:b)}),cos:zc("cos",["<u>cos(radians)</u> Trigonometric cosine, in radians. <mark>see cos 0</mark>"],Math.cos),sin:zc("sin",["<u>sin(radians)</u> Trigonometric sine, in radians. <mark>see sin 0</mark>"],Math.sin),tan:zc("tan",["<u>tan(radians)</u> Trigonometric tangent, in radians. <mark>see tan 0</mark>"],Math.tan),acosd:zc("acosd",["<u>acosd(x)</u> Trigonometric arccosine, in degrees. <mark>see acosd 0.5</mark>"],function(a){switch(a){case 1:return 0;case.5:return 60;case 0:return 90;case-.5:return 120;case-1:return 180}return 180*Math.acos(a)/Math.PI}),asind:zc("asind",["<u>asind(x)</u> Trigonometric arcsine, in degrees. <mark>see asind 0.5</mark>"],function(a){switch(a){case 1:return 90;case.5:return 30;case 0:return 0;case-.5:return-30;case-1:return-90}return 180*Math.asin(a)/Math.PI}),atand:zc("atand",["<u>atand(y, x = 1)</u> Trigonometric arctangent, in degrees. <mark>see atand -1, 0/mark>"],function(a,b){return b==He&&(b=1),0==a?0==b?NaN:b>0?0:180:0==b?a>0?1/0:-(1/0):Math.abs(a)==Math.abs(b)?a>0?b>0?45:135:b>0?-45:-135:180*Math.atan2(a,b)/Math.PI}),cosd:zc("cosd",["<u>cosd(degrees)</u> Trigonometric cosine, in degrees. <mark>see cosd 45</mark>"],function(a){if(a=ua(a,360),a%30===0)switch(0>a?a+360:a){case 0:return 1;case 60:return.5;case 90:return 0;case 120:return-.5;case 180:return-1;case 240:return-.5;case 270:return 0;case 300:return.5}return Math.cos(a/180*Math.PI)}),sind:zc("sind",["<u>sind(degrees)</u> Trigonometric sine, in degrees. <mark>see sind 45</mark>"],function(a){if(a=ua(a,360),a%30===0)switch(0>a?a+360:a){case 0:return 0;case 30:return.5;case 90:return 1;case 150:return.5;case 180:return 0;case 210:return-.5;case 270:return-1;case 330:return-.5}return Math.sin(a/180*Math.PI)}),tand:zc("tand",["<u>tand(degrees)</u> Trigonometric tangent, in degrees. <mark>see tand 45</mark>"],function(a){if(a=ua(a,360),a%45===0)switch(0>a?a+360:a){case 0:return 0;case 45:return 1;case 90:return 1/0;case 135:return-1;case 180:return 0;case 225:return 1;case 270:return-(1/0);case 315:return-1}return Math.tan(a/180*Math.PI)}),ceil:zc("ceil",["<u>ceil(x)</u> Round up. <mark>see ceil 1.9</mark>"],Math.ceil),floor:zc("floor",["<u>floor(x)</u> Round down. <mark>see floor 1.9</mark>"],Math.floor),round:zc("round",["<u>round(x)</u> Round to the nearest integer. <mark>see round 1.9</mark>"],Math.round),exp:zc("exp",["<u>exp(x)</u> Raise e to the power x. <mark>see exp 2</mark>"],Math.exp),ln:zc("ln",["<u>ln(x)</u> The natural logarithm of x. <mark>see ln 2</mark>"],Math.log),log10:zc("log10",["<u>log10(x)</u> The base 10 logarithm of x. <mark>see log10 0.01</mark>"],function(a){return Wa(Math.log(a)*Math.LOG10E)}),pow:zc("pow",["<u>pow(x, y)</u> Raise x to the power y. <mark>see pow 4, 1.5</mark>"],function(a,b){return Wa(Math.pow(a,b))}),sqrt:zc("sqrt",["<u>sqrt(x)</u> The square root of x. <mark>see sqrt 25</mark>"],Math.sqrt),max:zc("max",["<u>max(x, y, ...)</u> The maximum of a set of values. <mark>see max -5, 2, 1</mark>"],Math.max),min:zc("min",["<u>min(x, y, ...)</u> The minimum of a set of values. <mark>see min 2, -5, 1</mark>"],Math.min),Pencil:zc("Pencil",["<u>new Pencil(canvas)</u> Make an invisble pencil for drawing on a canvas. <mark>s = new Sprite; p = new Pencil(s); p.pen red; p.fd 100; remove p</mark>"],Ve),Turtle:zc("Turtle",["<u>new Turtle(color)</u> Make a new turtle. <mark>t = new Turtle; t.fd 100</mark>"],We),Piano:zc("Piano",["<u>new Piano(keys)</u> Make a new piano. <mark>t = new Piano 88; t.play 'edcdeee'</mark>"],Ye),Webcam:zc("Webcam",["<u>new Webcam(options)</u> Make a new webcam. <mark>v = new Webcam; v.plan -> pic = new Sprite v</mark>"],Xe),Sprite:zc("Sprite",["<u>new Sprite({width:w,height:h,color:c})</u> Make a new sprite to <mark>drawon</mark>. <mark>s = new Sprite({width:50,height:50,color:blue}); s.fd 100</mark>"],Ue),loadscript:zc("loadscript",["<u>loadscript(url, callback)</u> Loads Javascript or Coffeescript from the given URL, calling callback when done."],function(b,c){Ie.CoffeeScript&&/\.(?:coffee|cs)$/.test(b)?CoffeeScript.load(b,c):a.getScript(b,c)}),pressed:zc("pressed",["<u>pressed('control')</u> Tests if a specific key is pressed. <mark>if pressed 'a' then write 'a was pressed'</mark>","<u>pressed.list()</u> Returns a list of pressed keys, by name. <mark>write 'Pressed keys: ' + pressed.list().join(',')</mark>"],_e),help:oc},tf={finish:{helptext:["<u>finish()</u> Finishes turtle animation. Does not pause for effect: <mark>do finish</mark>"]}},uf={sent:{},waiting:{},pollTimer:null};Xc(sf,"defaultspeed","speed"),sf.save.loginCookie=Gb;var vf={},wf=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","transparent"];!function(){for(var a=["none","erase","path","up","down","color","position","normal","touch"],b=a.concat(wf),c=0;c<b.length;c++)sf.hasOwnProperty(b[c])||(sf[b[c]]=b[c]);sf.PI=Math.PI,sf.E=Math.E,sf.print=sf.write,tf.colors={helptext:["Defined colors: "+wf.join(" ")]},tf.see={helptext:["<u>see(v)</u> Shows the value of v in the test panel: <mark>see document</mark>"]},tf["if"]=tf["else"]=tf.then={helptext:["<u>if</u> <u>then</u> <u>else</u> Tests a condition: <mark>if 1 <= (new Date).getDay() <= 5 then write 'Working hard!' else write 'Happy weekend!'</mark>"]},tf.await=tf.defer={helptext:['<u>await</u> <u>defer</u> Waits for results from an asynchronous event; from <a href="http://maxtaco.github.io/coffee-script/" target="_blank">Iced CoffeeScript</a>: <mark>await readnum defer n</mark>']}}(),a.turtle=function(b,c){var d=!1;if(1==arguments.length&&"object"==typeof b&&b&&!b.hasOwnProperty("length")&&(c=b,b="turtle"),b=b||"turtle",c=c||{},"turtle"in c&&(b=c.turtle),bd(),"htmlscript"in c&&!c.htmlscript||a('script[type="text/html"]').each(function(){a(this).replaceWith(a(this).html().replace(/^\x3c!\[CDATA\[\n?|\]\]\x3e$/g,""))}),!Re.ctx&&"subpixel"in c&&(Re.subpixel=parseInt(c.subpixel)),a.turtle.hangtime="hangtime"in c?parseFloat(c.hangtime):2e4,c.events!==!1&&xd(c.eventprefix),c.pressed!==!1&&(Wb(),_e.enable(!0)),c.see!==!1&&(Rd(),d=!0,Ie.addEventListener?Ie.addEventListener("error",Sf):Ie.onerror=Sf,Ie.debug=Sf,Xc(Ie,"log","debug")),c.queuehide!==!1&&Tc(),c.functions!==!1&&(Ie.printpage=Ie.print,a.extend(Ie,sf)),vd("defaultspeed"in c?c.defaultspeed:1),_b())try{ac()}catch(e){}var f=null,g=!1;if(b&&(f=a("#"+b),f.length||(a("body").length||(document.write("<body>"),g=!0),f=new We(b))),f&&!f.length&&(f=null),f&&1===f.length&&c.global!==!1){var h={css:1,fadeIn:1,fadeOut:1,fadeTo:1,fadeToggle:1,animate:1,toggle:1,finish:1,promise:1,direct:1,show:1,hide:1},i=a.extend({},hf,h);qf.push.apply(qf,ad(f,i)),pf=f[0],f.css({zIndex:1})}if(c.ids!==!1&&(wd(c.idprefix),f&&b&&(Ie[b]=f)),c.panel!==!1){var j={title:"test panel (type help for help)",abbreviate:[He,vf],consolehook:$c};if(f&&j.abbreviate.push(f),c.title&&(j.title=c.title),c.panelheight&&(j.height=c.panelheight),Sf.init(j),d)return Ie.CoffeeScript?"see.init(eval(see.cs))":Sf.here}return a("#"+b)},a.extend(a.turtle,sf),a.turtle.colors=wf;a.cleanData;a.cleanData=function(b){for(var c,d=0;(c=b[d])!==He;d++){var e=a.data(c,"turtleData");e&&e.stream&&e.stream.stop(),c.id&&Ie[c.id]&&Ie[c.id].jquery&&1===Ie[c.id].length&&Ie[c.id][0]===c&&delete Ie[c.id],c===pf&&bd()}};var xf={},yf={turtle:function(a){return a||(a="mediumseagreen"),{url:fd(a),css:{width:20,height:24,transformOrigin:"10px 13px",turtleHull:"-8 -5 -8 6 -2 -13 2 -13 8 6 8 -5 0 9",opacity:.67,backgroundImage:"url("+nf+")",backgroundSize:"cover"}}},pointer:function(a){return a||(a="gray"),{url:gd(a),css:{width:20,height:24,transformOrigin:"10px 18px",turtleHull:"-10 6 0 -18 10 6",opacity:.67}}},radius:function(a){return a||(a="gray"),{url:hd(a),css:{width:20,height:20,transformOrigin:"10px 10px",turtleHull:"-10 0 -7 7 0 10 7 7 10 0 7 -7 0 -10 -7 -7",opacity:1}}},dot:function(a){return a||(a="black"),{url:id(a,24),css:{width:12,height:12,transformOrigin:"6px 6px",turtleHull:"-6 0 -4 4 0 6 4 4 6 0 4 -4 0 -6 -4 -4",opacity:1}}},point:function(a){return a||(a="black"),{url:id(a,6),css:{width:3,height:3,transformOrigin:"1.5px 1.5px",turtleHull:"-1.5 0 -1 1 0 1.5 1 1 1.5 0 1 -1 0 -1.5 -1 -1",opacity:1}}},pencil:function(a){return a||(a="dodgerblue"),{url:jd(a),css:{width:20,height:24,transformOrigin:"10px 24px",turtleHull:"0 0 -3 -6 -3 -24 3 -6 3 -24",opacity:1}}}},zf={"&":"&","<":"<",">":">",'"':"""},Af=[],Bf=[],Cf=null,Df=0,Ef=null,Ff={autoScrollTimer:null,bottomSeen:0},Gf="data:image/svg+xml,<svg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%20260%20400%22><path%20d=%22M180,210c0,26-22,48-48,48h-12c-26,0-48-22-48-48v-138c0-26,22-48,48-48h12c26,0,48,22,48,48zm51,-31h-9c-5,0-9,4-9,9v8c0,50-37,91-87,91c-50,0-87-41-87-91v-8c0-5-4-9-9-9h-9c-5,0-9,4-9,9v8c0,59,40,107,96,116v37h-34c-5,0-9,4-9,9v18c0,5,4,9,9,9h105c5,0,9-4,9-9v-18c0-5-5-9-9-9h-34v-37c56-9,96-58,96-116v-8c0-5-4-9-9-9%22/></svg>",Hf={init:function(){if(!this.ide){try{parent&&parent.ide&&parent.ide.bindframe&&parent.ide.bindframe(Ie,parent)&&(this.ide=parent.ide,this.attached=!0)}catch(a){}this.attached&&Ie.addEventListener&&Ie.addEventListener("error",function(a){Hf.reportEvent("error",[a])})}},attached:!1,ide:null,reportEvent:function(a,b){this.ide&&this.ide.reportEvent(a,b)},nextId:function(){return this.ide?this.ide.nextId():0}};Hf.init(),function(){function b(a){return a.toFixed(1).replace(/\.0$/,"")}function c(a){return'<code style="font-weight:bold;color:blue">'+a+"</code>"}function d(b,c){return b&&(b=b.get(0))&&c&&c.target&&(b==c.target||a.contains(b,c.target))}if(Hf.ide){var e,f,g,h,i=a("<samp>").css({position:"fixed",zIndex:1e6-1,fontFamily:"sans-serif",display:"none",background:"#ff8",border:"1px solid dimgray",padding:"1px",cursor:"move",fontSize:12}).appendTo("body"),j=null,k=null,l=null,m=0,n=0,o=0,p=0;a(Ie).on("mousedown mouseup mousemove keydown",function(q){if("keydown"==q.type){if(q.which<27)return;k&&k.remove(),k=j=l=null}if("mousedown"==q.type)if(k)if(l)k&&k.remove(),k=j=l=null;else if(j)k.css({cursor:"default"}),l=q;else{a.turtle.interrupt("reset");var r=a(".turtle").within("touch",q);j=r.length?r.eq(0):q}else if(d(i,q)){var s=Ia();l=j=null,k=a('<canvas width="'+s[0]+'" height="'+s[1]+'">').css({position:"absolute",top:0,left:0,cursor:"crosshair",zIndex:1e6}).appendTo("body")}if(k){var t,u,v,w,x,y,z=k.canvas(),A=z.getContext("2d"),B=!1,C=l||q;if(j&&"function"==typeof j.pagexy){var D=j.getxy(),E=j.pagexy();E.x=D[0],E.y=D[1],B=!0,x=j.direction(),t=["getxy is "+b(E.x)+", "+b(E.y),"direction is "+b(x)]}else E=j||C,t=[c("moveto "+b(E.x)+", "+b(E.y))];if(t.unshift(l?'<span style="color:green">click to close</span>':j?'<span style="color:red">click to measure</span>':'<span style="color:red">click on point</span>'),u=C.x-E.x,v=C.y-E.y,w=Math.sqrt(u*u+v*v),y=Math.atan2(u,v)/Math.PI*180,j){if(A.save(),A.clearRect(m-10,n-10,o-m+20,p-n+20),m=o=E.pageX,n=p=E.pageY,A.fillStyle="red",A.beginPath(),A.arc(E.pageX,E.pageY,4,0,2*Math.PI,!1),A.closePath(),A.fill(),w>0){if(B){A.strokeStyle="black",A.fillStyle="black",g=(x-90)/180*Math.PI,h=(y-90)/180*Math.PI,e=E.pageX+100*Math.cos(g),f=E.pageY+100*Math.sin(g),Rc(A,2,E.pageX,E.pageY,e,f),m=Math.min(e,m),n=Math.min(f,n),o=Math.max(e,o),p=Math.max(f,p);var F=(360+y-x)%360;A.beginPath(),180>=F?(t.push(c("rt "+b(F))),w>=20&&A.arc(E.pageX,E.pageY,20,g,h)):(t.push(c("lt "+b(360-F))),w>=20&&A.arc(E.pageX,E.pageY,20,h,g)),A.stroke(),m=Math.min(E.pageX-20,m),n=Math.min(E.pageY-20,n),o=Math.max(E.pageX+20,o),p=Math.max(E.pageY+20,p)}else t.push(c("turnto "+b(y)));t.push(c("fd "+b(w))),t.push("end at "+b(C.x)+", "+b(C.y)),A.strokeStyle="red",A.fillStyle="red",Rc(A,2,E.pageX,E.pageY,C.pageX,C.pageY),m=Math.min(C.pageX,m),n=Math.min(C.pageY,n),o=Math.max(C.pageX,o),p=Math.max(C.pageY,p)}A.restore()}i.css({left:0,top:0}).html(t.join("<br>")).show();var G={left:"",top:"",right:"",bottom:""};C.pageX+5<E.pageX?G.left=Math.max(C.pageX-a(Ie).scrollLeft()-i.outerWidth()-5,2):G.left=Math.min(C.pageX-a(Ie).scrollLeft()+5,a(document).width()-i.outerWidth()-2),C.pageY+5<E.pageY?G.top=Math.max(C.pageY-a(Ie).scrollTop()-i.outerHeight()-5,2):G.top=Math.min(C.pageY-a(Ie).scrollTop()+5,a(document).height()-i.outerHeight()-2),i.css(G)}else t=[],d(i,q)&&t.push('<span style="color:red">click to use</span>'),null!=q.x&&t.push(q.x+", "+q.y),i.html(t.join("<br>")).css({left:"",top:"",right:0,bottom:0}).show()})}}();var If=null,Jf="see",Kf="0.2",Lf=Sd(Jf),Mf="position:relative;display:block;font-family:monospace;font-size:16px;word-break:break-all;margin-bottom:3px;padding-left:1em;",Nf=5,Of=!1,Pf="body",Qf="auto";try{Ie.self!==Ie.top&&screen.width>=800&&screen.height>=600&&parent&&parent.ide&&(Qf=parent.ide.getOptions().panel)}catch(Rf){}var Sf,Tf=Qf,Uf="",Vf=null,Wf="_loghistory",Xf=50,Yf="",Zf={"":{e:Ie.eval,t:Ie},top:{e:Ie.eval,t:Ie}},$f=Ie.CoffeeScript,_f="(function(){return eval(arguments[0]);})",ag="[_$a-zA-Z -][_$a-zA-Z0-9 -]*",bg=new RegExp("^\\s*var\\s+(?:"+ag+"\\s*,\\s*)*"+ag+"\\s*;\\s*"),cg="input._log:focus{outline:none;}samp._logcaret{position:absolute;left:0;font-size:120%;}samp._logcaret:before{content: '>'}label._log > span:first-of-type:hover{text-decoration:underline;}samp._log > label._log,samp_.log > span > label._log{display:inline-block;vertical-align:top;}label._log > span:first-of-type{margin-left:2em;text-indent:-1em;}label._log > ul{display:none;padding-left:14px;margin:0;}label._log > span:before{content:'';font-size:70%;font-style:normal;display:inline-block;width:0;text-align:center;}label._log > span:first-of-type:before{content:'\\0025B6';}label._log > ul > li{display:block;white-space:pre-line;margin-left:2em;text-indent:-1em}label._log > ul > li > samp{margin-left:-1em;text-indent:0;white-space:pre;}label._log > input[type=checkbox]:checked ~ span{margin-left:2em;text-indent:-1em;}label._log > input[type=checkbox]:checked ~ span:first-of-type:before{content:'\\0025BC';}label._log > input[type=checkbox]:checked ~ span:before{content:'';}label._log,label._log > input[type=checkbox]:checked ~ ul{display:block;}label._log > span:first-of-type,label._log > input[type=checkbox]:checked ~ span{display:inline-block;}label._log > input[type=checkbox],label._log > input[type=checkbox]:checked ~ span > span{display:none;}",dg=!1,eg={"\x00":"\\0","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","":"\\v","'":"\\'",'"':'\\"',"\\":"\\\\"},fg=null,gg=[];Sf=function(){Vf&&"function"==typeof Vf.log&&Vf.log.apply(Ie.console,arguments);var a=Array.prototype.slice.call(arguments);for(gg.push('<samp class="_log">');a.length;){var b=a.shift();"String"==Xd(b)?gg.push(he(b)):gg.push(le(b,Nf,gg)),a.length&&gg.push(" ")}gg.push("</samp>"),oe()};var hg=!1,ig=!1,jg=null,kg=[{}.undefined],lg=null,mg=null}}).call(this,this.jQuery);