/* CindyJS - (C) 2014-2016  The CindyJS Project
 * Mostly licensed under the Apache License 2.0, but subprojects may use different licensing.
 * See https://github.com/CindyJS/CindyJS/tree/8c01b8d1d336e92934ad80c44aafc5510a1aea36
 * for corresponding sources and their respective licensing conditions.
 */
var enableInlineVideo=function(){function p(f,k,p,E){function F(p){ia=k(F,E);f(p-(N||p));N=p}var ia,N;return{start:function(){ia||F(0)},stop:function(){p(ia);ia=null;N=0}}}function F(f,k,p,E){function F(k){!!f[p]===!!E&&k.stopImmediatePropagation();delete f[p]}return f.addEventListener(k,F,!1),F}function ha(f,k,p,E){function F(f){p[k]=f}E&&F(f[k]);Object.defineProperty(f,k,{get:function(){return p[k]},set:F})}function Ga(f,k,p){p.addEventListener(k,function(){return f.dispatchEvent(new Event(k))})}
function pa(f,k){Promise.resolve().then(function(){f.dispatchEvent(new Event(k))})}function Ha(f){var k=new Audio;return Ga(f,"play",k),Ga(f,"playing",k),Ga(f,"pause",k),k.crossOrigin=f.crossOrigin,k.src=f.src||f.currentSrc||"data:",k}function ea(k,p,E){(N||0)+200<Date.now()&&(k[fa]=!0,N=Date.now());E||(k.currentTime=p);f[++tb%3]=100*p|0}function k(f){this.video.readyState>=this.video.HAVE_FUTURE_DATA?(this.hasAudio||(this.driver.currentTime=this.video.currentTime+f*this.video.playbackRate/1E3,this.video.loop&&
this.driver.currentTime>=this.video.duration&&(this.driver.currentTime=0)),ea(this.video,this.driver.currentTime)):this.video.networkState===this.video.NETWORK_IDLE&&0===this.video.buffered.length&&this.video.load();this.video.ended&&(delete this.video[fa],this.video.pause(!0))}function Qa(){var f=this[S];return this.webkitDisplayingFullscreen?void this[ub]():("data:"!==f.driver.src&&f.driver.src!==this.src&&(ea(this,0,!0),f.driver.src=this.src),void(this.paused&&(f.paused=!1,0===this.buffered.length&&
this.load(),f.driver.play(),f.updater.start(),f.hasAudio||(pa(this,"play"),f.video.readyState>=f.video.HAVE_ENOUGH_DATA&&pa(this,"playing")))))}function E(f){var k=this[S];k.driver.pause();k.updater.stop();this.webkitDisplayingFullscreen&&this[$a]();k.paused&&!f||(k.paused=!0,k.hasAudio||pa(this,"pause"),this.ended&&(this[fa]=!0,pa(this,"ended")))}function ia(E,F){var M=E[S]={};M.paused=!0;M.hasAudio=F;M.video=E;M.updater=p(k.bind(M),requestAnimationFrame,cancelAnimationFrame);F?M.driver=Ha(E):(E.addEventListener("canplay",
function(){E.paused||pa(E,"playing")}),M.driver={src:E.src||E.currentSrc||"data:",muted:!0,paused:!0,pause:function(){M.driver.paused=!0},play:function(){M.driver.paused=!1;M.driver.currentTime>=M.video.duration&&ea(E,0)},get ended(){return M.driver.currentTime>=M.video.duration}});E.addEventListener("emptied",function(){var f=!M.driver.src||"data:"===M.driver.src;M.driver.src&&M.driver.src!==E.src&&(ea(E,0,!0),M.driver.src=E.src,f?M.driver.play():M.updater.stop())},!1);E.addEventListener("webkitbeginfullscreen",
function(){E.paused?F&&0===M.driver.buffered.length&&M.driver.load():(E.pause(),E[ub]())});F&&(E.addEventListener("webkitendfullscreen",function(){M.driver.currentTime=E.currentTime}),E.addEventListener("seeking",function(){0>f.indexOf(100*E.currentTime|0)&&(M.driver.currentTime=E.currentTime)}))}var N,V="object"==typeof document&&"object-fit"in document.head.style&&!matchMedia("(-webkit-video-playable-inline)").matches,S="bfred-it:iphone-inline-video",fa="bfred-it:iphone-inline-video:event",ub="bfred-it:iphone-inline-video:nativeplay",
$a="bfred-it:iphone-inline-video:nativepause",f=[],tb=0;return function(f,k){if(void 0===k&&(k={}),!f[S])if(k.everywhere||V&&(k.iPad||k.ipad?/iPhone|iPod|iPad/:/iPhone|iPod/).test(navigator.userAgent)){!f.paused&&f.webkitDisplayingFullscreen&&f.pause();ia(f,!f.muted);var p=f[S];f[ub]=f.play;f[$a]=f.pause;f.play=Qa;f.pause=E;ha(f,"paused",p.driver);ha(f,"muted",p.driver,!0);ha(f,"playbackRate",p.driver,!0);ha(f,"ended",p.driver);ha(f,"loop",p.driver,!0);F(f,"seeking");F(f,"seeked");F(f,"timeupdate",
fa,!1);F(f,"ended",fa,!1);f.classList.add("IIV");f.muted&&f.autoplay&&f.play();/iPhone|iPod|iPad/.test(navigator.platform)||console.warn("iphone-inline-video is not guaranteed to work in emulated environments")}}}();
(function(){function p(b,d,e){f.biginteger_used=1;null!=b&&("number"==typeof b&&"undefined"==typeof d?this.fromInt(b):"number"==typeof b?this.fromNumber(b,d,e):null==d&&"string"!=typeof b?this.fromString(b,256):this.fromString(b,d))}function F(){return new p(null,void 0,void 0)}function ha(b,d,e,r,f,k){for(;0<=--k;){var u=d*this[b++]+e[r]+f;f=Math.floor(u/67108864);e[r++]=u&67108863}return f}function Ga(b,d,e,r,f,k){var u=d&32767;for(d>>=15;0<=--k;){var C=this[b]&32767,p=this[b++]>>15,E=d*C+p*u,C=
u*C+((E&32767)<<15)+e[r]+(f&1073741823);f=(C>>>30)+(E>>>15)+d*p+(f>>>30);e[r++]=C&1073741823}return f}function pa(b,d,e,r,f,k){var u=d&16383;for(d>>=14;0<=--k;){var C=this[b]&16383,p=this[b++]>>14,E=d*C+p*u,C=u*C+((E&16383)<<14)+e[r]+f;f=(C>>28)+(E>>14)+d*p;e[r++]=C&268435455}return f}function Ha(b,d){var e=gb[b.charCodeAt(d)];return null==e?-1:e}function ea(b){var d=F();d.fromInt(b);return d}function k(b){var d=1,e;0!=(e=b>>>16)&&(b=e,d+=16);0!=(e=b>>8)&&(b=e,d+=8);0!=(e=b>>4)&&(b=e,d+=4);0!=(e=
b>>2)&&(b=e,d+=2);0!=b>>1&&(d+=1);return d}function Qa(b){this.m=b}function E(b){this.m=b;this.mp=b.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<b.DB-15)-1;this.mt2=2*b.t}function ia(b,d){return b&d}function N(b,d){return b|d}function V(b,d){return b^d}function S(b,d){return b&~d}function fa(){}function ub(b){return b}function $a(b){this.r2=F();this.q3=F();p.ONE.dlShiftTo(2*b.t,this.r2);this.mu=this.r2.divide(b);this.m=b}var f={use_lines:!0,use_xyz:!1},tb=!1;"undefined"!==typeof module&&
module.exports?(module.exports=f,tb=!0):"undefined"!==typeof document?window.ClipperLib=f:self.ClipperLib=f;var Y;if(tb)ba="chrome",Y="Netscape";else{var ba=navigator.userAgent.toString().toLowerCase();Y=navigator.appName}var M,gc,Sb,Ta,fb,Cb;M=-1!=ba.indexOf("chrome")&&-1==ba.indexOf("chromium")?1:0;tb=-1!=ba.indexOf("chromium")?1:0;gc=-1!=ba.indexOf("safari")&&-1==ba.indexOf("chrome")&&-1==ba.indexOf("chromium")?1:0;Sb=-1!=ba.indexOf("firefox")?1:0;ba.indexOf("firefox/17");ba.indexOf("firefox/15");
ba.indexOf("firefox/3");Ta=-1!=ba.indexOf("opera")?1:0;ba.indexOf("msie 10");ba.indexOf("msie 9");fb=-1!=ba.indexOf("msie 8")?1:0;Cb=-1!=ba.indexOf("msie 7")?1:0;ba=-1!=ba.indexOf("msie ")?1:0;f.biginteger_used=null;"Microsoft Internet Explorer"==Y?(p.prototype.am=Ga,Y=30):"Netscape"!=Y?(p.prototype.am=ha,Y=26):(p.prototype.am=pa,Y=28);p.prototype.DB=Y;p.prototype.DM=(1<<Y)-1;p.prototype.DV=1<<Y;p.prototype.FV=Math.pow(2,52);p.prototype.F1=52-Y;p.prototype.F2=2*Y-52;var gb=[],ua;Y=48;for(ua=0;9>=
ua;++ua)gb[Y++]=ua;Y=97;for(ua=10;36>ua;++ua)gb[Y++]=ua;Y=65;for(ua=10;36>ua;++ua)gb[Y++]=ua;Qa.prototype.convert=function(b){return 0>b.s||0<=b.compareTo(this.m)?b.mod(this.m):b};Qa.prototype.revert=function(b){return b};Qa.prototype.reduce=function(b){b.divRemTo(this.m,null,b)};Qa.prototype.mulTo=function(b,d,e){b.multiplyTo(d,e);this.reduce(e)};Qa.prototype.sqrTo=function(b,d){b.squareTo(d);this.reduce(d)};E.prototype.convert=function(b){var d=F();b.abs().dlShiftTo(this.m.t,d);d.divRemTo(this.m,
null,d);0>b.s&&0<d.compareTo(p.ZERO)&&this.m.subTo(d,d);return d};E.prototype.revert=function(b){var d=F();b.copyTo(d);this.reduce(d);return d};E.prototype.reduce=function(b){for(;b.t<=this.mt2;)b[b.t++]=0;for(var d=0;d<this.m.t;++d){var e=b[d]&32767,r=e*this.mpl+((e*this.mph+(b[d]>>15)*this.mpl&this.um)<<15)&b.DM,e=d+this.m.t;for(b[e]+=this.m.am(0,r,b,d,0,this.m.t);b[e]>=b.DV;)b[e]-=b.DV,b[++e]++}b.clamp();b.drShiftTo(this.m.t,b);0<=b.compareTo(this.m)&&b.subTo(this.m,b)};E.prototype.mulTo=function(b,
d,e){b.multiplyTo(d,e);this.reduce(e)};E.prototype.sqrTo=function(b,d){b.squareTo(d);this.reduce(d)};p.prototype.copyTo=function(b){for(var d=this.t-1;0<=d;--d)b[d]=this[d];b.t=this.t;b.s=this.s};p.prototype.fromInt=function(b){this.t=1;this.s=0>b?-1:0;0<b?this[0]=b:-1>b?this[0]=b+this.DV:this.t=0};p.prototype.fromString=function(b,d){var e;if(16==d)e=4;else if(8==d)e=3;else if(256==d)e=8;else if(2==d)e=1;else if(32==d)e=5;else if(4==d)e=2;else{this.fromRadix(b,d);return}this.s=this.t=0;for(var r=
b.length,f=!1,k=0;0<=--r;){var u=8==e?b[r]&255:Ha(b,r);0>u?"-"==b.charAt(r)&&(f=!0):(f=!1,0==k?this[this.t++]=u:k+e>this.DB?(this[this.t-1]|=(u&(1<<this.DB-k)-1)<<k,this[this.t++]=u>>this.DB-k):this[this.t-1]|=u<<k,k+=e,k>=this.DB&&(k-=this.DB))}8==e&&0!=(b[0]&128)&&(this.s=-1,0<k&&(this[this.t-1]|=(1<<this.DB-k)-1<<k));this.clamp();f&&p.ZERO.subTo(this,this)};p.prototype.clamp=function(){for(var b=this.s&this.DM;0<this.t&&this[this.t-1]==b;)--this.t};p.prototype.dlShiftTo=function(b,d){var e;for(e=
this.t-1;0<=e;--e)d[e+b]=this[e];for(e=b-1;0<=e;--e)d[e]=0;d.t=this.t+b;d.s=this.s};p.prototype.drShiftTo=function(b,d){for(var e=b;e<this.t;++e)d[e-b]=this[e];d.t=Math.max(this.t-b,0);d.s=this.s};p.prototype.lShiftTo=function(b,d){var e=b%this.DB,r=this.DB-e,f=(1<<r)-1,k=Math.floor(b/this.DB),u=this.s<<e&this.DM,C;for(C=this.t-1;0<=C;--C)d[C+k+1]=this[C]>>r|u,u=(this[C]&f)<<e;for(C=k-1;0<=C;--C)d[C]=0;d[k]=u;d.t=this.t+k+1;d.s=this.s;d.clamp()};p.prototype.rShiftTo=function(b,d){d.s=this.s;var e=
Math.floor(b/this.DB);if(e>=this.t)d.t=0;else{var r=b%this.DB,f=this.DB-r,k=(1<<r)-1;d[0]=this[e]>>r;for(var u=e+1;u<this.t;++u)d[u-e-1]|=(this[u]&k)<<f,d[u-e]=this[u]>>r;0<r&&(d[this.t-e-1]|=(this.s&k)<<f);d.t=this.t-e;d.clamp()}};p.prototype.subTo=function(b,d){for(var e=0,f=0,n=Math.min(b.t,this.t);e<n;)f+=this[e]-b[e],d[e++]=f&this.DM,f>>=this.DB;if(b.t<this.t){for(f-=b.s;e<this.t;)f+=this[e],d[e++]=f&this.DM,f>>=this.DB;f+=this.s}else{for(f+=this.s;e<b.t;)f-=b[e],d[e++]=f&this.DM,f>>=this.DB;
f-=b.s}d.s=0>f?-1:0;-1>f?d[e++]=this.DV+f:0<f&&(d[e++]=f);d.t=e;d.clamp()};p.prototype.multiplyTo=function(b,d){var e=this.abs(),f=b.abs(),n=e.t;for(d.t=n+f.t;0<=--n;)d[n]=0;for(n=0;n<f.t;++n)d[n+e.t]=e.am(0,f[n],d,n,0,e.t);d.s=0;d.clamp();this.s!=b.s&&p.ZERO.subTo(d,d)};p.prototype.squareTo=function(b){for(var d=this.abs(),e=b.t=2*d.t;0<=--e;)b[e]=0;for(e=0;e<d.t-1;++e){var f=d.am(e,d[e],b,2*e,0,1);(b[e+d.t]+=d.am(e+1,2*d[e],b,2*e+1,f,d.t-e-1))>=d.DV&&(b[e+d.t]-=d.DV,b[e+d.t+1]=1)}0<b.t&&(b[b.t-
1]+=d.am(e,d[e],b,2*e,0,1));b.s=0;b.clamp()};p.prototype.divRemTo=function(b,d,e){var f=b.abs();if(!(0>=f.t)){var n=this.abs();if(n.t<f.t)null!=d&&d.fromInt(0),null!=e&&this.copyTo(e);else{null==e&&(e=F());var I=F(),u=this.s;b=b.s;var C=this.DB-k(f[f.t-1]);0<C?(f.lShiftTo(C,I),n.lShiftTo(C,e)):(f.copyTo(I),n.copyTo(e));f=I.t;n=I[f-1];if(0!=n){var E=n*(1<<this.F1)+(1<f?I[f-2]>>this.F2:0),ab=this.FV/E,E=(1<<this.F1)/E,vb=1<<this.F2,H=e.t,ia=H-f,N=null==d?F():d;I.dlShiftTo(ia,N);0<=e.compareTo(N)&&(e[e.t++]=
1,e.subTo(N,e));p.ONE.dlShiftTo(f,N);for(N.subTo(I,I);I.t<f;)I[I.t++]=0;for(;0<=--ia;){var M=e[--H]==n?this.DM:Math.floor(e[H]*ab+(e[H-1]+vb)*E);if((e[H]+=I.am(0,M,e,ia,0,f))<M)for(I.dlShiftTo(ia,N),e.subTo(N,e);e[H]<--M;)e.subTo(N,e)}null!=d&&(e.drShiftTo(f,d),u!=b&&p.ZERO.subTo(d,d));e.t=f;e.clamp();0<C&&e.rShiftTo(C,e);0>u&&p.ZERO.subTo(e,e)}}}};p.prototype.invDigit=function(){if(1>this.t)return 0;var b=this[0];if(0==(b&1))return 0;var d=b&3,d=d*(2-(b&15)*d)&15,d=d*(2-(b&255)*d)&255,d=d*(2-((b&
65535)*d&65535))&65535,d=d*(2-b*d%this.DV)%this.DV;return 0<d?this.DV-d:-d};p.prototype.isEven=function(){return 0==(0<this.t?this[0]&1:this.s)};p.prototype.exp=function(b,d){if(4294967295<b||1>b)return p.ONE;var e=F(),f=F(),n=d.convert(this),I=k(b)-1;for(n.copyTo(e);0<=--I;)if(d.sqrTo(e,f),0<(b&1<<I))d.mulTo(f,n,e);else var u=e,e=f,f=u;return d.revert(e)};p.prototype.toString=function(b){if(0>this.s)return"-"+this.negate().toString(b);if(16==b)b=4;else if(8==b)b=3;else if(2==b)b=1;else if(32==b)b=
5;else if(4==b)b=2;else return this.toRadix(b);var d=(1<<b)-1,e,f=!1,n="",k=this.t,u=this.DB-k*this.DB%b;if(0<k--)for(u<this.DB&&0<(e=this[k]>>u)&&(f=!0,n="0123456789abcdefghijklmnopqrstuvwxyz".charAt(e));0<=k;)u<b?(e=(this[k]&(1<<u)-1)<<b-u,e|=this[--k]>>(u+=this.DB-b)):(e=this[k]>>(u-=b)&d,0>=u&&(u+=this.DB,--k)),0<e&&(f=!0),f&&(n+="0123456789abcdefghijklmnopqrstuvwxyz".charAt(e));return f?n:"0"};p.prototype.negate=function(){var b=F();p.ZERO.subTo(this,b);return b};p.prototype.abs=function(){return 0>
this.s?this.negate():this};p.prototype.compareTo=function(b){var d=this.s-b.s;if(0!=d)return d;var e=this.t,d=e-b.t;if(0!=d)return 0>this.s?-d:d;for(;0<=--e;)if(0!=(d=this[e]-b[e]))return d;return 0};p.prototype.bitLength=function(){return 0>=this.t?0:this.DB*(this.t-1)+k(this[this.t-1]^this.s&this.DM)};p.prototype.mod=function(b){var d=F();this.abs().divRemTo(b,null,d);0>this.s&&0<d.compareTo(p.ZERO)&&b.subTo(d,d);return d};p.prototype.modPowInt=function(b,d){var e;e=256>b||d.isEven()?new Qa(d):
new E(d);return this.exp(b,e)};p.ZERO=ea(0);p.ONE=ea(1);fa.prototype.convert=ub;fa.prototype.revert=ub;fa.prototype.mulTo=function(b,d,e){b.multiplyTo(d,e)};fa.prototype.sqrTo=function(b,d){b.squareTo(d)};$a.prototype.convert=function(b){if(0>b.s||b.t>2*this.m.t)return b.mod(this.m);if(0>b.compareTo(this.m))return b;var d=F();b.copyTo(d);this.reduce(d);return d};$a.prototype.revert=function(b){return b};$a.prototype.reduce=function(b){b.drShiftTo(this.m.t-1,this.r2);b.t>this.m.t+1&&(b.t=this.m.t+
1,b.clamp());this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);for(this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);0>b.compareTo(this.r2);)b.dAddOffset(1,this.m.t+1);for(b.subTo(this.r2,b);0<=b.compareTo(this.m);)b.subTo(this.m,b)};$a.prototype.mulTo=function(b,d,e){b.multiplyTo(d,e);this.reduce(e)};$a.prototype.sqrTo=function(b,d){b.squareTo(d);this.reduce(d)};var H=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,
173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,
983,991,997],ic=67108864/H[H.length-1];p.prototype.chunkSize=function(b){return Math.floor(Math.LN2*this.DB/Math.log(b))};p.prototype.toRadix=function(b){null==b&&(b=10);if(0==this.signum()||2>b||36<b)return"0";var d=this.chunkSize(b),d=Math.pow(b,d),e=ea(d),f=F(),n=F(),k="";for(this.divRemTo(e,f,n);0<f.signum();)k=(d+n.intValue()).toString(b).substr(1)+k,f.divRemTo(e,f,n);return n.intValue().toString(b)+k};p.prototype.fromRadix=function(b,d){this.fromInt(0);null==d&&(d=10);for(var e=this.chunkSize(d),
f=Math.pow(d,e),n=!1,k=0,u=0,C=0;C<b.length;++C){var E=Ha(b,C);0>E?"-"==b.charAt(C)&&0==this.signum()&&(n=!0):(u=d*u+E,++k>=e&&(this.dMultiply(f),this.dAddOffset(u,0),u=k=0))}0<k&&(this.dMultiply(Math.pow(d,k)),this.dAddOffset(u,0));n&&p.ZERO.subTo(this,this)};p.prototype.fromNumber=function(b,d,e){if("number"==typeof d)if(2>b)this.fromInt(1);else for(this.fromNumber(b,e),this.testBit(b-1)||this.bitwiseTo(p.ONE.shiftLeft(b-1),N,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(d);)this.dAddOffset(2,
0),this.bitLength()>b&&this.subTo(p.ONE.shiftLeft(b-1),this);else{e=[];var f=b&7;e.length=(b>>3)+1;d.nextBytes(e);e[0]=0<f?e[0]&(1<<f)-1:0;this.fromString(e,256)}};p.prototype.bitwiseTo=function(b,d,e){var f,n,k=Math.min(b.t,this.t);for(f=0;f<k;++f)e[f]=d(this[f],b[f]);if(b.t<this.t){n=b.s&this.DM;for(f=k;f<this.t;++f)e[f]=d(this[f],n);e.t=this.t}else{n=this.s&this.DM;for(f=k;f<b.t;++f)e[f]=d(n,b[f]);e.t=b.t}e.s=d(this.s,b.s);e.clamp()};p.prototype.changeBit=function(b,d){var e=p.ONE.shiftLeft(b);
this.bitwiseTo(e,d,e);return e};p.prototype.addTo=function(b,d){for(var e=0,f=0,n=Math.min(b.t,this.t);e<n;)f+=this[e]+b[e],d[e++]=f&this.DM,f>>=this.DB;if(b.t<this.t){for(f+=b.s;e<this.t;)f+=this[e],d[e++]=f&this.DM,f>>=this.DB;f+=this.s}else{for(f+=this.s;e<b.t;)f+=b[e],d[e++]=f&this.DM,f>>=this.DB;f+=b.s}d.s=0>f?-1:0;0<f?d[e++]=f:-1>f&&(d[e++]=this.DV+f);d.t=e;d.clamp()};p.prototype.dMultiply=function(b){this[this.t]=this.am(0,b-1,this,0,0,this.t);++this.t;this.clamp()};p.prototype.dAddOffset=
function(b,d){if(0!=b){for(;this.t<=d;)this[this.t++]=0;for(this[d]+=b;this[d]>=this.DV;)this[d]-=this.DV,++d>=this.t&&(this[this.t++]=0),++this[d]}};p.prototype.multiplyLowerTo=function(b,d,e){var f=Math.min(this.t+b.t,d);e.s=0;for(e.t=f;0<f;)e[--f]=0;var n;for(n=e.t-this.t;f<n;++f)e[f+this.t]=this.am(0,b[f],e,f,0,this.t);for(n=Math.min(b.t,d);f<n;++f)this.am(0,b[f],e,f,0,d-f);e.clamp()};p.prototype.multiplyUpperTo=function(b,d,e){--d;var f=e.t=this.t+b.t-d;for(e.s=0;0<=--f;)e[f]=0;for(f=Math.max(d-
this.t,0);f<b.t;++f)e[this.t+f-d]=this.am(d-f,b[f],e,0,0,this.t+f-d);e.clamp();e.drShiftTo(1,e)};p.prototype.modInt=function(b){if(0>=b)return 0;var d=this.DV%b,e=0>this.s?b-1:0;if(0<this.t)if(0==d)e=this[0]%b;else for(var f=this.t-1;0<=f;--f)e=(d*e+this[f])%b;return e};p.prototype.millerRabin=function(b){var d=this.subtract(p.ONE),e=d.getLowestSetBit();if(0>=e)return!1;var f=d.shiftRight(e);b=b+1>>1;b>H.length&&(b=H.length);for(var n=F(),k=0;k<b;++k){n.fromInt(H[Math.floor(Math.random()*H.length)]);
var u=n.modPow(f,this);if(0!=u.compareTo(p.ONE)&&0!=u.compareTo(d)){for(var C=1;C++<e&&0!=u.compareTo(d);)if(u=u.modPowInt(2,this),0==u.compareTo(p.ONE))return!1;if(0!=u.compareTo(d))return!1}}return!0};p.prototype.clone=function(){var b=F();this.copyTo(b);return b};p.prototype.intValue=function(){if(0>this.s){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]};p.prototype.byteValue=function(){return 0==
this.t?this.s:this[0]<<24>>24};p.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16};p.prototype.signum=function(){return 0>this.s?-1:0>=this.t||1==this.t&&0>=this[0]?0:1};p.prototype.toByteArray=function(){var b=this.t,d=[];d[0]=this.s;var e=this.DB-b*this.DB%8,f,n=0;if(0<b--)for(e<this.DB&&(f=this[b]>>e)!=(this.s&this.DM)>>e&&(d[n++]=f|this.s<<this.DB-e);0<=b;)if(8>e?(f=(this[b]&(1<<e)-1)<<8-e,f|=this[--b]>>(e+=this.DB-8)):(f=this[b]>>(e-=8)&255,0>=e&&(e+=this.DB,--b)),0!=(f&
128)&&(f|=-256),0==n&&(this.s&128)!=(f&128)&&++n,0<n||f!=this.s)d[n++]=f;return d};p.prototype.equals=function(b){return 0==this.compareTo(b)};p.prototype.min=function(b){return 0>this.compareTo(b)?this:b};p.prototype.max=function(b){return 0<this.compareTo(b)?this:b};p.prototype.and=function(b){var d=F();this.bitwiseTo(b,ia,d);return d};p.prototype.or=function(b){var d=F();this.bitwiseTo(b,N,d);return d};p.prototype.xor=function(b){var d=F();this.bitwiseTo(b,V,d);return d};p.prototype.andNot=function(b){var d=
F();this.bitwiseTo(b,S,d);return d};p.prototype.not=function(){for(var b=F(),d=0;d<this.t;++d)b[d]=this.DM&~this[d];b.t=this.t;b.s=~this.s;return b};p.prototype.shiftLeft=function(b){var d=F();0>b?this.rShiftTo(-b,d):this.lShiftTo(b,d);return d};p.prototype.shiftRight=function(b){var d=F();0>b?this.lShiftTo(-b,d):this.rShiftTo(b,d);return d};p.prototype.getLowestSetBit=function(){for(var b=0;b<this.t;++b)if(0!=this[b]){var d=b*this.DB,b=this[b];if(0==b)b=-1;else{var e=0;0==(b&65535)&&(b>>=16,e+=16);
0==(b&255)&&(b>>=8,e+=8);0==(b&15)&&(b>>=4,e+=4);0==(b&3)&&(b>>=2,e+=2);0==(b&1)&&++e;b=e}return d+b}return 0>this.s?this.t*this.DB:-1};p.prototype.bitCount=function(){for(var b=0,d=this.s&this.DM,e=0;e<this.t;++e){for(var f=this[e]^d,n=0;0!=f;)f&=f-1,++n;b+=n}return b};p.prototype.testBit=function(b){var d=Math.floor(b/this.DB);return d>=this.t?0!=this.s:0!=(this[d]&1<<b%this.DB)};p.prototype.setBit=function(b){return this.changeBit(b,N)};p.prototype.clearBit=function(b){return this.changeBit(b,
S)};p.prototype.flipBit=function(b){return this.changeBit(b,V)};p.prototype.add=function(b){var d=F();this.addTo(b,d);return d};p.prototype.subtract=function(b){var d=F();this.subTo(b,d);return d};p.prototype.multiply=function(b){var d=F();this.multiplyTo(b,d);return d};p.prototype.divide=function(b){var d=F();this.divRemTo(b,d,null);return d};p.prototype.remainder=function(b){var d=F();this.divRemTo(b,null,d);return d};p.prototype.divideAndRemainder=function(b){var d=F(),e=F();this.divRemTo(b,d,
e);return[d,e]};p.prototype.modPow=function(b,d){var e=b.bitLength(),f,n=ea(1),I;if(0>=e)return n;f=18>e?1:48>e?3:144>e?4:768>e?5:6;I=8>e?new Qa(d):d.isEven()?new $a(d):new E(d);var u=[],C=3,p=f-1,ab=(1<<f)-1;u[1]=I.convert(this);if(1<f)for(e=F(),I.sqrTo(u[1],e);C<=ab;)u[C]=F(),I.mulTo(e,u[C-2],u[C]),C+=2;for(var H=b.t-1,N,ia=!0,M=F(),e=k(b[H])-1;0<=H;){e>=p?N=b[H]>>e-p&ab:(N=(b[H]&(1<<e+1)-1)<<p-e,0<H&&(N|=b[H-1]>>this.DB+e-p));for(C=f;0==(N&1);)N>>=1,--C;0>(e-=C)&&(e+=this.DB,--H);if(ia)u[N].copyTo(n),
ia=!1;else{for(;1<C;)I.sqrTo(n,M),I.sqrTo(M,n),C-=2;0<C?I.sqrTo(n,M):(C=n,n=M,M=C);I.mulTo(M,u[N],n)}for(;0<=H&&0==(b[H]&1<<e);)I.sqrTo(n,M),C=n,n=M,M=C,0>--e&&(e=this.DB-1,--H)}return I.revert(n)};p.prototype.modInverse=function(b){var d=b.isEven();if(this.isEven()&&d||0==b.signum())return p.ZERO;for(var e=b.clone(),f=this.clone(),n=ea(1),k=ea(0),u=ea(0),C=ea(1);0!=e.signum();){for(;e.isEven();)e.rShiftTo(1,e),d?(n.isEven()&&k.isEven()||(n.addTo(this,n),k.subTo(b,k)),n.rShiftTo(1,n)):k.isEven()||
k.subTo(b,k),k.rShiftTo(1,k);for(;f.isEven();)f.rShiftTo(1,f),d?(u.isEven()&&C.isEven()||(u.addTo(this,u),C.subTo(b,C)),u.rShiftTo(1,u)):C.isEven()||C.subTo(b,C),C.rShiftTo(1,C);0<=e.compareTo(f)?(e.subTo(f,e),d&&n.subTo(u,n),k.subTo(C,k)):(f.subTo(e,f),d&&u.subTo(n,u),C.subTo(k,C))}if(0!=f.compareTo(p.ONE))return p.ZERO;if(0<=C.compareTo(b))return C.subtract(b);if(0>C.signum())C.addTo(b,C);else return C;return 0>C.signum()?C.add(b):C};p.prototype.pow=function(b){return this.exp(b,new fa)};p.prototype.gcd=
function(b){var d=0>this.s?this.negate():this.clone();b=0>b.s?b.negate():b.clone();if(0>d.compareTo(b)){var e=d,d=b;b=e}var e=d.getLowestSetBit(),f=b.getLowestSetBit();if(0>f)return d;e<f&&(f=e);for(0<f&&(d.rShiftTo(f,d),b.rShiftTo(f,b));0<d.signum();)0<(e=d.getLowestSetBit())&&d.rShiftTo(e,d),0<(e=b.getLowestSetBit())&&b.rShiftTo(e,b),0<=d.compareTo(b)?(d.subTo(b,d),d.rShiftTo(1,d)):(b.subTo(d,b),b.rShiftTo(1,b));0<f&&b.lShiftTo(f,b);return b};p.prototype.isProbablePrime=function(b){var d,e=this.abs();
if(1==e.t&&e[0]<=H[H.length-1]){for(d=0;d<H.length;++d)if(e[0]==H[d])return!0;return!1}if(e.isEven())return!1;for(d=1;d<H.length;){for(var f=H[d],n=d+1;n<H.length&&f<ic;)f*=H[n++];for(f=e.modInt(f);d<n;)if(0==f%H[d++])return!1}return e.millerRabin(b)};p.prototype.square=function(){var b=F();this.squareTo(b);return b};p.prototype.IsNegative=function(){return-1==this.compareTo(p.ZERO)?!0:!1};p.op_Equality=function(b,d){return 0==b.compareTo(d)?!0:!1};p.op_Inequality=function(b,d){return 0!=b.compareTo(d)?
!0:!1};p.op_GreaterThan=function(b,d){return 0<b.compareTo(d)?!0:!1};p.op_LessThan=function(b,d){return 0>b.compareTo(d)?!0:!1};p.op_Addition=function(b,d){return(new p(b)).add(new p(d))};p.op_Subtraction=function(b,d){return(new p(b)).subtract(new p(d))};p.Int128Mul=function(b,d){return(new p(b)).multiply(new p(d))};p.op_Division=function(b,d){return b.divide(d)};p.prototype.ToDouble=function(){return parseFloat(this.toString())};Y=function(b,d){var e;if("undefined"==typeof Object.getOwnPropertyNames)for(e in d.prototype){if("undefined"==
typeof b.prototype[e]||b.prototype[e]==Object.prototype[e])b.prototype[e]=d.prototype[e]}else for(var f=Object.getOwnPropertyNames(d.prototype),n=0;n<f.length;n++)"undefined"==typeof Object.getOwnPropertyDescriptor(b.prototype,f[n])&&Object.defineProperty(b.prototype,f[n],Object.getOwnPropertyDescriptor(d.prototype,f[n]));for(e in d)"undefined"==typeof b[e]&&(b[e]=d[e]);b.$baseCtor=d};f.Path=function(){return[]};f.Paths=function(){return[]};f.DoublePoint=function(){var b=arguments;this.Y=this.X=0;
1==b.length?(this.X=b[0].X,this.Y=b[0].Y):2==b.length&&(this.X=b[0],this.Y=b[1])};f.DoublePoint0=function(){this.Y=this.X=0};f.DoublePoint1=function(b){this.X=b.X;this.Y=b.Y};f.DoublePoint2=function(b,d){this.X=b;this.Y=d};f.PolyNode=function(){this.m_Parent=null;this.m_polygon=new f.Path;this.m_endtype=this.m_jointype=this.m_Index=0;this.m_Childs=[];this.IsOpen=!1};f.PolyNode.prototype.IsHoleNode=function(){for(var b=!0,d=this.m_Parent;null!==d;)b=!b,d=d.m_Parent;return b};f.PolyNode.prototype.ChildCount=
function(){return this.m_Childs.length};f.PolyNode.prototype.Contour=function(){return this.m_polygon};f.PolyNode.prototype.AddChild=function(b){var d=this.m_Childs.length;this.m_Childs.push(b);b.m_Parent=this;b.m_Index=d};f.PolyNode.prototype.GetNext=function(){return 0<this.m_Childs.length?this.m_Childs[0]:this.GetNextSiblingUp()};f.PolyNode.prototype.GetNextSiblingUp=function(){return null===this.m_Parent?null:this.m_Index==this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+
1]};f.PolyNode.prototype.Childs=function(){return this.m_Childs};f.PolyNode.prototype.Parent=function(){return this.m_Parent};f.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()};f.PolyTree=function(){this.m_AllPolys=[];f.PolyNode.call(this)};f.PolyTree.prototype.Clear=function(){for(var b=0,d=this.m_AllPolys.length;b<d;b++)this.m_AllPolys[b]=null;this.m_AllPolys.length=0;this.m_Childs.length=0};f.PolyTree.prototype.GetFirst=function(){return 0<this.m_Childs.length?this.m_Childs[0]:null};
f.PolyTree.prototype.Total=function(){var b=this.m_AllPolys.length;0<b&&this.m_Childs[0]!=this.m_AllPolys[0]&&b--;return b};Y(f.PolyTree,f.PolyNode);f.Math_Abs_Int64=f.Math_Abs_Int32=f.Math_Abs_Double=function(b){return Math.abs(b)};f.Math_Max_Int32_Int32=function(b,d){return Math.max(b,d)};f.Cast_Int32=ba||Ta||gc?function(b){return b|0}:function(b){return~~b};f.Cast_Int64=M?function(b){return-2147483648>b||2147483647<b?0>b?Math.ceil(b):Math.floor(b):~~b}:Sb&&"function"==typeof Number.toInteger?function(b){return Number.toInteger(b)}:
Cb||fb?function(b){return parseInt(b,10)}:ba?function(b){return-2147483648>b||2147483647<b?0>b?Math.ceil(b):Math.floor(b):b|0}:function(b){return 0>b?Math.ceil(b):Math.floor(b)};f.Clear=function(b){b.length=0};f.PI=3.141592653589793;f.PI2=6.283185307179586;f.IntPoint=function(){var b=arguments,d=b.length;this.Y=this.X=0;f.use_xyz?(this.Z=0,3==d?(this.X=b[0],this.Y=b[1],this.Z=b[2]):2==d?(this.X=b[0],this.Y=b[1],this.Z=0):1==d?b[0]instanceof f.DoublePoint?(b=b[0],this.X=f.Clipper.Round(b.X),this.Y=
f.Clipper.Round(b.Y),this.Z=0):(b=b[0],"undefined"==typeof b.Z&&(b.Z=0),this.X=b.X,this.Y=b.Y,this.Z=b.Z):this.Z=this.Y=this.X=0):2==d?(this.X=b[0],this.Y=b[1]):1==d?b[0]instanceof f.DoublePoint?(b=b[0],this.X=f.Clipper.Round(b.X),this.Y=f.Clipper.Round(b.Y)):(b=b[0],this.X=b.X,this.Y=b.Y):this.Y=this.X=0};f.IntPoint.op_Equality=function(b,d){return b.X==d.X&&b.Y==d.Y};f.IntPoint.op_Inequality=function(b,d){return b.X!=d.X||b.Y!=d.Y};f.use_xyz?(f.IntPoint0=function(){this.Z=this.Y=this.X=0},f.IntPoint1=
function(b){this.X=b.X;this.Y=b.Y;this.Z=b.Z},f.IntPoint1dp=function(b){this.X=f.Clipper.Round(b.X);this.Y=f.Clipper.Round(b.Y);this.Z=0},f.IntPoint2=function(b,d){this.X=b;this.Y=d;this.Z=0},f.IntPoint3=function(b,d,e){this.X=b;this.Y=d;this.Z=e}):(f.IntPoint0=function(){this.Y=this.X=0},f.IntPoint1=function(b){this.X=b.X;this.Y=b.Y},f.IntPoint1dp=function(b){this.X=f.Clipper.Round(b.X);this.Y=f.Clipper.Round(b.Y)},f.IntPoint2=function(b,d){this.X=b;this.Y=d});f.IntRect=function(){var b=arguments,
d=b.length;4==d?(this.left=b[0],this.top=b[1],this.right=b[2],this.bottom=b[3]):1==d?(this.left=b[0].left,this.top=b[0].top,this.right=b[0].right,this.bottom=b[0].bottom):this.bottom=this.right=this.top=this.left=0};f.IntRect0=function(){this.bottom=this.right=this.top=this.left=0};f.IntRect1=function(b){this.left=b.left;this.top=b.top;this.right=b.right;this.bottom=b.bottom};f.IntRect4=function(b,d,e,f){this.left=b;this.top=d;this.right=e;this.bottom=f};f.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,
ctXor:3};f.PolyType={ptSubject:0,ptClip:1};f.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3};f.JoinType={jtSquare:0,jtRound:1,jtMiter:2};f.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4};f.EdgeSide={esLeft:0,esRight:1};f.Direction={dRightToLeft:0,dLeftToRight:1};f.TEdge=function(){this.Bot=new f.IntPoint;this.Curr=new f.IntPoint;this.Top=new f.IntPoint;this.Delta=new f.IntPoint;this.Dx=0;this.PolyTyp=f.PolyType.ptSubject;this.Side=f.EdgeSide.esLeft;
this.OutIdx=this.WindCnt2=this.WindCnt=this.WindDelta=0;this.PrevInSEL=this.NextInSEL=this.PrevInAEL=this.NextInAEL=this.NextInLML=this.Prev=this.Next=null};f.IntersectNode=function(){this.Edge2=this.Edge1=null;this.Pt=new f.IntPoint};f.MyIntersectNodeSort=function(){};f.MyIntersectNodeSort.Compare=function(b,d){var e=d.Pt.Y-b.Pt.Y;return 0<e?1:0>e?-1:0};f.LocalMinima=function(){this.Y=0;this.Next=this.RightBound=this.LeftBound=null};f.Scanbeam=function(){this.Y=0;this.Next=null};f.OutRec=function(){this.Idx=
0;this.IsOpen=this.IsHole=!1;this.PolyNode=this.BottomPt=this.Pts=this.FirstLeft=null};f.OutPt=function(){this.Idx=0;this.Pt=new f.IntPoint;this.Prev=this.Next=null};f.Join=function(){this.OutPt2=this.OutPt1=null;this.OffPt=new f.IntPoint};f.ClipperBase=function(){this.m_CurrentLM=this.m_MinimaList=null;this.m_edges=[];this.PreserveCollinear=this.m_HasOpenPaths=this.m_UseFullRange=!1;this.m_CurrentLM=this.m_MinimaList=null;this.m_HasOpenPaths=this.m_UseFullRange=!1};f.ClipperBase.horizontal=-9007199254740992;
f.ClipperBase.Skip=-2;f.ClipperBase.Unassigned=-1;f.ClipperBase.tolerance=1E-20;f.ClipperBase.loRange=47453132;f.ClipperBase.hiRange=0xfffffffffffff;f.ClipperBase.near_zero=function(b){return b>-f.ClipperBase.tolerance&&b<f.ClipperBase.tolerance};f.ClipperBase.IsHorizontal=function(b){return 0===b.Delta.Y};f.ClipperBase.prototype.PointIsVertex=function(b,d){var e=d;do{if(f.IntPoint.op_Equality(e.Pt,b))return!0;e=e.Next}while(e!=d);return!1};f.ClipperBase.prototype.PointOnLineSegment=function(b,d,
e,f){return f?b.X==d.X&&b.Y==d.Y||b.X==e.X&&b.Y==e.Y||b.X>d.X==b.X<e.X&&b.Y>d.Y==b.Y<e.Y&&p.op_Equality(p.Int128Mul(b.X-d.X,e.Y-d.Y),p.Int128Mul(e.X-d.X,b.Y-d.Y)):b.X==d.X&&b.Y==d.Y||b.X==e.X&&b.Y==e.Y||b.X>d.X==b.X<e.X&&b.Y>d.Y==b.Y<e.Y&&(b.X-d.X)*(e.Y-d.Y)==(e.X-d.X)*(b.Y-d.Y)};f.ClipperBase.prototype.PointOnPolygon=function(b,d,e){for(var f=d;;){if(this.PointOnLineSegment(b,f.Pt,f.Next.Pt,e))return!0;f=f.Next;if(f==d)break}return!1};f.ClipperBase.prototype.SlopesEqual=f.ClipperBase.SlopesEqual=
function(){var b=arguments,d=b.length,e,r,n;if(3==d)return d=b[0],e=b[1],b[2]?p.op_Equality(p.Int128Mul(d.Delta.Y,e.Delta.X),p.Int128Mul(d.Delta.X,e.Delta.Y)):f.Cast_Int64(d.Delta.Y*e.Delta.X)==f.Cast_Int64(d.Delta.X*e.Delta.Y);if(4==d)return d=b[0],e=b[1],r=b[2],b[3]?p.op_Equality(p.Int128Mul(d.Y-e.Y,e.X-r.X),p.Int128Mul(d.X-e.X,e.Y-r.Y)):0===f.Cast_Int64((d.Y-e.Y)*(e.X-r.X))-f.Cast_Int64((d.X-e.X)*(e.Y-r.Y));d=b[0];e=b[1];r=b[2];n=b[3];return b[4]?p.op_Equality(p.Int128Mul(d.Y-e.Y,r.X-n.X),p.Int128Mul(d.X-
e.X,r.Y-n.Y)):0===f.Cast_Int64((d.Y-e.Y)*(r.X-n.X))-f.Cast_Int64((d.X-e.X)*(r.Y-n.Y))};f.ClipperBase.SlopesEqual3=function(b,d,e){return e?p.op_Equality(p.Int128Mul(b.Delta.Y,d.Delta.X),p.Int128Mul(b.Delta.X,d.Delta.Y)):f.Cast_Int64(b.Delta.Y*d.Delta.X)==f.Cast_Int64(b.Delta.X*d.Delta.Y)};f.ClipperBase.SlopesEqual4=function(b,d,e,r){return r?p.op_Equality(p.Int128Mul(b.Y-d.Y,d.X-e.X),p.Int128Mul(b.X-d.X,d.Y-e.Y)):0===f.Cast_Int64((b.Y-d.Y)*(d.X-e.X))-f.Cast_Int64((b.X-d.X)*(d.Y-e.Y))};f.ClipperBase.SlopesEqual5=
function(b,d,e,r,n){return n?p.op_Equality(p.Int128Mul(b.Y-d.Y,e.X-r.X),p.Int128Mul(b.X-d.X,e.Y-r.Y)):0===f.Cast_Int64((b.Y-d.Y)*(e.X-r.X))-f.Cast_Int64((b.X-d.X)*(e.Y-r.Y))};f.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var b=0,d=this.m_edges.length;b<d;++b){for(var e=0,r=this.m_edges[b].length;e<r;++e)this.m_edges[b][e]=null;f.Clear(this.m_edges[b])}f.Clear(this.m_edges);this.m_HasOpenPaths=this.m_UseFullRange=!1};f.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(;null!==
this.m_MinimaList;){var b=this.m_MinimaList.Next;this.m_MinimaList=null;this.m_MinimaList=b}this.m_CurrentLM=null};f.ClipperBase.prototype.RangeTest=function(b,d){if(d.Value)(b.X>f.ClipperBase.hiRange||b.Y>f.ClipperBase.hiRange||-b.X>f.ClipperBase.hiRange||-b.Y>f.ClipperBase.hiRange)&&f.Error("Coordinate outside allowed range in RangeTest().");else if(b.X>f.ClipperBase.loRange||b.Y>f.ClipperBase.loRange||-b.X>f.ClipperBase.loRange||-b.Y>f.ClipperBase.loRange)d.Value=!0,this.RangeTest(b,d)};f.ClipperBase.prototype.InitEdge=
function(b,d,e,r){b.Next=d;b.Prev=e;b.Curr.X=r.X;b.Curr.Y=r.Y;f.use_xyz&&(b.Curr.Z=r.Z);b.OutIdx=-1};f.ClipperBase.prototype.InitEdge2=function(b,d){b.Curr.Y>=b.Next.Curr.Y?(b.Bot.X=b.Curr.X,b.Bot.Y=b.Curr.Y,f.use_xyz&&(b.Bot.Z=b.Curr.Z),b.Top.X=b.Next.Curr.X,b.Top.Y=b.Next.Curr.Y,f.use_xyz&&(b.Top.Z=b.Next.Curr.Z)):(b.Top.X=b.Curr.X,b.Top.Y=b.Curr.Y,f.use_xyz&&(b.Top.Z=b.Curr.Z),b.Bot.X=b.Next.Curr.X,b.Bot.Y=b.Next.Curr.Y,f.use_xyz&&(b.Bot.Z=b.Next.Curr.Z));this.SetDx(b);b.PolyTyp=d};f.ClipperBase.prototype.FindNextLocMin=
function(b){for(var d;;){for(;f.IntPoint.op_Inequality(b.Bot,b.Prev.Bot)||f.IntPoint.op_Equality(b.Curr,b.Top);)b=b.Next;if(b.Dx!=f.ClipperBase.horizontal&&b.Prev.Dx!=f.ClipperBase.horizontal)break;for(;b.Prev.Dx==f.ClipperBase.horizontal;)b=b.Prev;for(d=b;b.Dx==f.ClipperBase.horizontal;)b=b.Next;if(b.Top.Y!=b.Prev.Bot.Y){d.Prev.Bot.X<b.Bot.X&&(b=d);break}}return b};f.ClipperBase.prototype.ProcessBound=function(b,d){var e,r=b,n;if(r.OutIdx==f.ClipperBase.Skip){b=r;if(d){for(;b.Top.Y==b.Next.Bot.Y;)b=
b.Next;for(;b!=r&&b.Dx==f.ClipperBase.horizontal;)b=b.Prev}else{for(;b.Top.Y==b.Prev.Bot.Y;)b=b.Prev;for(;b!=r&&b.Dx==f.ClipperBase.horizontal;)b=b.Next}b==r?r=d?b.Next:b.Prev:(b=d?r.Next:r.Prev,e=new f.LocalMinima,e.Next=null,e.Y=b.Bot.Y,e.LeftBound=null,e.RightBound=b,b.WindDelta=0,r=this.ProcessBound(b,d),this.InsertLocalMinima(e));return r}b.Dx==f.ClipperBase.horizontal&&(e=d?b.Prev:b.Next,e.OutIdx!=f.ClipperBase.Skip&&(e.Dx==f.ClipperBase.horizontal?e.Bot.X!=b.Bot.X&&e.Top.X!=b.Bot.X&&this.ReverseHorizontal(b):
e.Bot.X!=b.Bot.X&&this.ReverseHorizontal(b)));e=b;if(d){for(;r.Top.Y==r.Next.Bot.Y&&r.Next.OutIdx!=f.ClipperBase.Skip;)r=r.Next;if(r.Dx==f.ClipperBase.horizontal&&r.Next.OutIdx!=f.ClipperBase.Skip){for(n=r;n.Prev.Dx==f.ClipperBase.horizontal;)n=n.Prev;n.Prev.Top.X==r.Next.Top.X?d||(r=n.Prev):n.Prev.Top.X>r.Next.Top.X&&(r=n.Prev)}for(;b!=r;)b.NextInLML=b.Next,b.Dx==f.ClipperBase.horizontal&&b!=e&&b.Bot.X!=b.Prev.Top.X&&this.ReverseHorizontal(b),b=b.Next;b.Dx==f.ClipperBase.horizontal&&b!=e&&b.Bot.X!=
b.Prev.Top.X&&this.ReverseHorizontal(b);r=r.Next}else{for(;r.Top.Y==r.Prev.Bot.Y&&r.Prev.OutIdx!=f.ClipperBase.Skip;)r=r.Prev;if(r.Dx==f.ClipperBase.horizontal&&r.Prev.OutIdx!=f.ClipperBase.Skip){for(n=r;n.Next.Dx==f.ClipperBase.horizontal;)n=n.Next;n.Next.Top.X==r.Prev.Top.X?d||(r=n.Next):n.Next.Top.X>r.Prev.Top.X&&(r=n.Next)}for(;b!=r;)b.NextInLML=b.Prev,b.Dx==f.ClipperBase.horizontal&&b!=e&&b.Bot.X!=b.Next.Top.X&&this.ReverseHorizontal(b),b=b.Prev;b.Dx==f.ClipperBase.horizontal&&b!=e&&b.Bot.X!=
b.Next.Top.X&&this.ReverseHorizontal(b);r=r.Prev}return r};f.ClipperBase.prototype.AddPath=function(b,d,e){f.use_lines?e||d!=f.PolyType.ptClip||f.Error("AddPath: Open paths must be subject."):e||f.Error("AddPath: Open paths have been disabled.");var r=b.length-1;if(e)for(;0<r&&f.IntPoint.op_Equality(b[r],b[0]);)--r;for(;0<r&&f.IntPoint.op_Equality(b[r],b[r-1]);)--r;if(e&&2>r||!e&&1>r)return!1;for(var n=[],k=0;k<=r;k++)n.push(new f.TEdge);var u=!0;n[1].Curr.X=b[1].X;n[1].Curr.Y=b[1].Y;f.use_xyz&&(n[1].Curr.Z=
b[1].Z);var C={Value:this.m_UseFullRange};this.RangeTest(b[0],C);this.m_UseFullRange=C.Value;C.Value=this.m_UseFullRange;this.RangeTest(b[r],C);this.m_UseFullRange=C.Value;this.InitEdge(n[0],n[1],n[r],b[0]);this.InitEdge(n[r],n[0],n[r-1],b[r]);for(k=r-1;1<=k;--k)C.Value=this.m_UseFullRange,this.RangeTest(b[k],C),this.m_UseFullRange=C.Value,this.InitEdge(n[k],n[k+1],n[k-1],b[k]);for(k=b=r=n[0];;)if(b.Curr!=b.Next.Curr||!e&&b.Next==r){if(b.Prev==b.Next)break;else if(e&&f.ClipperBase.SlopesEqual(b.Prev.Curr,
b.Curr,b.Next.Curr,this.m_UseFullRange)&&(!this.PreserveCollinear||!this.Pt2IsBetweenPt1AndPt3(b.Prev.Curr,b.Curr,b.Next.Curr))){b==r&&(r=b.Next);b=this.RemoveEdge(b);k=b=b.Prev;continue}b=b.Next;if(b==k||!e&&b.Next==r)break}else{if(b==b.Next)break;b==r&&(r=b.Next);k=b=this.RemoveEdge(b)}if(!e&&b==b.Next||e&&b.Prev==b.Next)return!1;e||(this.m_HasOpenPaths=!0,r.Prev.OutIdx=f.ClipperBase.Skip);b=r;do this.InitEdge2(b,d),b=b.Next,u&&b.Curr.Y!=r.Curr.Y&&(u=!1);while(b!=r);if(u){if(e)return!1;b.Prev.OutIdx=
f.ClipperBase.Skip;b.Prev.Bot.X<b.Prev.Top.X&&this.ReverseHorizontal(b.Prev);d=new f.LocalMinima;d.Next=null;d.Y=b.Bot.Y;d.LeftBound=null;d.RightBound=b;d.RightBound.Side=f.EdgeSide.esRight;for(d.RightBound.WindDelta=0;b.Next.OutIdx!=f.ClipperBase.Skip;)b.NextInLML=b.Next,b.Bot.X!=b.Prev.Top.X&&this.ReverseHorizontal(b),b=b.Next;this.InsertLocalMinima(d);this.m_edges.push(n);return!0}this.m_edges.push(n);u=null;for(f.IntPoint.op_Equality(b.Prev.Bot,b.Prev.Top)&&(b=b.Next);;){b=this.FindNextLocMin(b);
if(b==u)break;else null==u&&(u=b);d=new f.LocalMinima;d.Next=null;d.Y=b.Bot.Y;b.Dx<b.Prev.Dx?(d.LeftBound=b.Prev,d.RightBound=b,n=!1):(d.LeftBound=b,d.RightBound=b.Prev,n=!0);d.LeftBound.Side=f.EdgeSide.esLeft;d.RightBound.Side=f.EdgeSide.esRight;d.LeftBound.WindDelta=e?d.LeftBound.Next==d.RightBound?-1:1:0;d.RightBound.WindDelta=-d.LeftBound.WindDelta;b=this.ProcessBound(d.LeftBound,n);b.OutIdx==f.ClipperBase.Skip&&(b=this.ProcessBound(b,n));r=this.ProcessBound(d.RightBound,!n);r.OutIdx==f.ClipperBase.Skip&&
(r=this.ProcessBound(r,!n));d.LeftBound.OutIdx==f.ClipperBase.Skip?d.LeftBound=null:d.RightBound.OutIdx==f.ClipperBase.Skip&&(d.RightBound=null);this.InsertLocalMinima(d);n||(b=r)}return!0};f.ClipperBase.prototype.AddPaths=function(b,d,e){for(var f=!1,n=0,k=b.length;n<k;++n)this.AddPath(b[n],d,e)&&(f=!0);return f};f.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(b,d,e){return f.IntPoint.op_Equality(b,e)||f.IntPoint.op_Equality(b,d)||f.IntPoint.op_Equality(e,d)?!1:b.X!=e.X?d.X>b.X==d.X<e.X:d.Y>
b.Y==d.Y<e.Y};f.ClipperBase.prototype.RemoveEdge=function(b){b.Prev.Next=b.Next;b.Next.Prev=b.Prev;var d=b.Next;b.Prev=null;return d};f.ClipperBase.prototype.SetDx=function(b){b.Delta.X=b.Top.X-b.Bot.X;b.Delta.Y=b.Top.Y-b.Bot.Y;b.Dx=0===b.Delta.Y?f.ClipperBase.horizontal:b.Delta.X/b.Delta.Y};f.ClipperBase.prototype.InsertLocalMinima=function(b){if(null===this.m_MinimaList)this.m_MinimaList=b;else if(b.Y>=this.m_MinimaList.Y)b.Next=this.m_MinimaList,this.m_MinimaList=b;else{for(var d=this.m_MinimaList;null!==
d.Next&&b.Y<d.Next.Y;)d=d.Next;b.Next=d.Next;d.Next=b}};f.ClipperBase.prototype.PopLocalMinima=function(){null!==this.m_CurrentLM&&(this.m_CurrentLM=this.m_CurrentLM.Next)};f.ClipperBase.prototype.ReverseHorizontal=function(b){var d=b.Top.X;b.Top.X=b.Bot.X;b.Bot.X=d;f.use_xyz&&(d=b.Top.Z,b.Top.Z=b.Bot.Z,b.Bot.Z=d)};f.ClipperBase.prototype.Reset=function(){this.m_CurrentLM=this.m_MinimaList;if(null!=this.m_CurrentLM)for(var b=this.m_MinimaList;null!=b;){var d=b.LeftBound;null!=d&&(d.Curr.X=d.Bot.X,
d.Curr.Y=d.Bot.Y,f.use_xyz&&(d.Curr.Z=d.Bot.Z),d.Side=f.EdgeSide.esLeft,d.OutIdx=f.ClipperBase.Unassigned);d=b.RightBound;null!=d&&(d.Curr.X=d.Bot.X,d.Curr.Y=d.Bot.Y,f.use_xyz&&(d.Curr.Z=d.Bot.Z),d.Side=f.EdgeSide.esRight,d.OutIdx=f.ClipperBase.Unassigned);b=b.Next}};f.Clipper=function(b){"undefined"==typeof b&&(b=0);this.m_PolyOuts=null;this.m_ClipType=f.ClipType.ctIntersection;this.m_IntersectNodeComparer=this.m_IntersectList=this.m_SortedEdges=this.m_ActiveEdges=this.m_Scanbeam=null;this.m_ExecuteLocked=
!1;this.m_SubjFillType=this.m_ClipFillType=f.PolyFillType.pftEvenOdd;this.m_GhostJoins=this.m_Joins=null;this.StrictlySimple=this.ReverseSolution=this.m_UsingPolyTree=!1;f.ClipperBase.call(this);this.m_SortedEdges=this.m_ActiveEdges=this.m_Scanbeam=null;this.m_IntersectList=[];this.m_IntersectNodeComparer=f.MyIntersectNodeSort.Compare;this.m_UsingPolyTree=this.m_ExecuteLocked=!1;this.m_PolyOuts=[];this.m_Joins=[];this.m_GhostJoins=[];this.ReverseSolution=0!==(1&b);this.StrictlySimple=0!==(2&b);this.PreserveCollinear=
0!==(4&b);f.use_xyz&&(this.ZFillFunction=null)};f.Clipper.ioReverseSolution=1;f.Clipper.ioStrictlySimple=2;f.Clipper.ioPreserveCollinear=4;f.Clipper.prototype.Clear=function(){0!==this.m_edges.length&&(this.DisposeAllPolyPts(),f.ClipperBase.prototype.Clear.call(this))};f.Clipper.prototype.DisposeScanbeamList=function(){for(;null!==this.m_Scanbeam;){var b=this.m_Scanbeam.Next;this.m_Scanbeam=null;this.m_Scanbeam=b}};f.Clipper.prototype.Reset=function(){f.ClipperBase.prototype.Reset.call(this);this.m_SortedEdges=
this.m_ActiveEdges=this.m_Scanbeam=null;for(var b=this.m_MinimaList;null!==b;)this.InsertScanbeam(b.Y),b=b.Next};f.Clipper.prototype.InsertScanbeam=function(b){if(null===this.m_Scanbeam)this.m_Scanbeam=new f.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=b;else if(b>this.m_Scanbeam.Y){var d=new f.Scanbeam;d.Y=b;d.Next=this.m_Scanbeam;this.m_Scanbeam=d}else{for(var e=this.m_Scanbeam;null!==e.Next&&b<=e.Next.Y;)e=e.Next;b!=e.Y&&(d=new f.Scanbeam,d.Y=b,d.Next=e.Next,e.Next=d)}};f.Clipper.prototype.Execute=
function(){var b=arguments,d=b.length,e=b[1]instanceof f.PolyTree;if(4!=d||e){if(4==d&&e){var d=b[0],r=b[1],e=b[2],b=b[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0;this.m_SubjFillType=e;this.m_ClipFillType=b;this.m_ClipType=d;this.m_UsingPolyTree=!0;try{(n=this.ExecuteInternal())&&this.BuildResult2(r)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return n}if(2==d&&!e||2==d&&e)return d=b[0],r=b[1],this.Execute(d,r,f.PolyFillType.pftEvenOdd,f.PolyFillType.pftEvenOdd)}else{d=
b[0];r=b[1];e=b[2];b=b[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&f.Error("Error: PolyTree struct is need for open path clipping.");this.m_ExecuteLocked=!0;f.Clear(r);this.m_SubjFillType=e;this.m_ClipFillType=b;this.m_ClipType=d;this.m_UsingPolyTree=!1;try{var n=this.ExecuteInternal();n&&this.BuildResult(r)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return n}};f.Clipper.prototype.FixHoleLinkage=function(b){if(null!==b.FirstLeft&&(b.IsHole==b.FirstLeft.IsHole||null===b.FirstLeft.Pts)){for(var d=
b.FirstLeft;null!==d&&(d.IsHole==b.IsHole||null===d.Pts);)d=d.FirstLeft;b.FirstLeft=d}};f.Clipper.prototype.ExecuteInternal=function(){try{this.Reset();if(null===this.m_CurrentLM)return!1;var b=this.PopScanbeam();do{this.InsertLocalMinimaIntoAEL(b);f.Clear(this.m_GhostJoins);this.ProcessHorizontals(!1);if(null===this.m_Scanbeam)break;var d=this.PopScanbeam();if(!this.ProcessIntersections(d))return!1;this.ProcessEdgesAtTopOfScanbeam(d);b=d}while(null!==this.m_Scanbeam||null!==this.m_CurrentLM);for(var b=
0,e=this.m_PolyOuts.length;b<e;b++){var r=this.m_PolyOuts[b];null===r.Pts||r.IsOpen||(r.IsHole^this.ReverseSolution)==0<this.Area(r)&&this.ReversePolyPtLinks(r.Pts)}this.JoinCommonEdges();b=0;for(e=this.m_PolyOuts.length;b<e;b++)r=this.m_PolyOuts[b],null===r.Pts||r.IsOpen||this.FixupOutPolygon(r);this.StrictlySimple&&this.DoSimplePolygons();return!0}finally{f.Clear(this.m_Joins),f.Clear(this.m_GhostJoins)}};f.Clipper.prototype.PopScanbeam=function(){var b=this.m_Scanbeam.Y;this.m_Scanbeam=this.m_Scanbeam.Next;
return b};f.Clipper.prototype.DisposeAllPolyPts=function(){for(var b=0,d=this.m_PolyOuts.length;b<d;++b)this.DisposeOutRec(b);f.Clear(this.m_PolyOuts)};f.Clipper.prototype.DisposeOutRec=function(b){this.m_PolyOuts[b].Pts=null;this.m_PolyOuts[b]=null};f.Clipper.prototype.AddJoin=function(b,d,e){var r=new f.Join;r.OutPt1=b;r.OutPt2=d;r.OffPt.X=e.X;r.OffPt.Y=e.Y;f.use_xyz&&(r.OffPt.Z=e.Z);this.m_Joins.push(r)};f.Clipper.prototype.AddGhostJoin=function(b,d){var e=new f.Join;e.OutPt1=b;e.OffPt.X=d.X;e.OffPt.Y=
d.Y;f.use_xyz&&(e.OffPt.Z=d.Z);this.m_GhostJoins.push(e)};f.Clipper.prototype.SetZ=function(b,d,e){null!==this.ZFillFunction&&0==b.Z&&null!==this.ZFillFunction&&(f.IntPoint.op_Equality(b,d.Bot)?b.Z=d.Bot.Z:f.IntPoint.op_Equality(b,d.Top)?b.Z=d.Top.Z:f.IntPoint.op_Equality(b,e.Bot)?b.Z=e.Bot.Z:f.IntPoint.op_Equality(b,e.Top)?b.Z=e.Top.Z:this.ZFillFunction(d.Bot,d.Top,e.Bot,e.Top,b))};f.Clipper.prototype.InsertLocalMinimaIntoAEL=function(b){for(;null!==this.m_CurrentLM&&this.m_CurrentLM.Y==b;){var d=
this.m_CurrentLM.LeftBound,e=this.m_CurrentLM.RightBound;this.PopLocalMinima();var r=null;null===d?(this.InsertEdgeIntoAEL(e,null),this.SetWindingCount(e),this.IsContributing(e)&&(r=this.AddOutPt(e,e.Bot))):(null==e?(this.InsertEdgeIntoAEL(d,null),this.SetWindingCount(d),this.IsContributing(d)&&(r=this.AddOutPt(d,d.Bot))):(this.InsertEdgeIntoAEL(d,null),this.InsertEdgeIntoAEL(e,d),this.SetWindingCount(d),e.WindCnt=d.WindCnt,e.WindCnt2=d.WindCnt2,this.IsContributing(d)&&(r=this.AddLocalMinPoly(d,e,
d.Bot))),this.InsertScanbeam(d.Top.Y));null!=e&&(f.ClipperBase.IsHorizontal(e)?this.AddEdgeToSEL(e):this.InsertScanbeam(e.Top.Y));if(null!=d&&null!=e){if(null!==r&&f.ClipperBase.IsHorizontal(e)&&0<this.m_GhostJoins.length&&0!==e.WindDelta)for(var n=0,k=this.m_GhostJoins.length;n<k;n++){var u=this.m_GhostJoins[n];this.HorzSegmentsOverlap(u.OutPt1.Pt.X,u.OffPt.X,e.Bot.X,e.Top.X)&&this.AddJoin(u.OutPt1,r,u.OffPt)}0<=d.OutIdx&&null!==d.PrevInAEL&&d.PrevInAEL.Curr.X==d.Bot.X&&0<=d.PrevInAEL.OutIdx&&f.ClipperBase.SlopesEqual(d.PrevInAEL,
d,this.m_UseFullRange)&&0!==d.WindDelta&&0!==d.PrevInAEL.WindDelta&&(n=this.AddOutPt(d.PrevInAEL,d.Bot),this.AddJoin(r,n,d.Top));if(d.NextInAEL!=e&&(0<=e.OutIdx&&0<=e.PrevInAEL.OutIdx&&f.ClipperBase.SlopesEqual(e.PrevInAEL,e,this.m_UseFullRange)&&0!==e.WindDelta&&0!==e.PrevInAEL.WindDelta&&(n=this.AddOutPt(e.PrevInAEL,e.Bot),this.AddJoin(r,n,e.Top)),r=d.NextInAEL,null!==r))for(;r!=e;)this.IntersectEdges(e,r,d.Curr,!1),r=r.NextInAEL}}};f.Clipper.prototype.InsertEdgeIntoAEL=function(b,d){if(null===
this.m_ActiveEdges)b.PrevInAEL=null,b.NextInAEL=null,this.m_ActiveEdges=b;else if(null===d&&this.E2InsertsBeforeE1(this.m_ActiveEdges,b))b.PrevInAEL=null,b.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges=this.m_ActiveEdges.PrevInAEL=b;else{for(null===d&&(d=this.m_ActiveEdges);null!==d.NextInAEL&&!this.E2InsertsBeforeE1(d.NextInAEL,b);)d=d.NextInAEL;b.NextInAEL=d.NextInAEL;null!==d.NextInAEL&&(d.NextInAEL.PrevInAEL=b);b.PrevInAEL=d;d.NextInAEL=b}};f.Clipper.prototype.E2InsertsBeforeE1=function(b,d){return d.Curr.X==
b.Curr.X?d.Top.Y>b.Top.Y?d.Top.X<f.Clipper.TopX(b,d.Top.Y):b.Top.X>f.Clipper.TopX(d,b.Top.Y):d.Curr.X<b.Curr.X};f.Clipper.prototype.IsEvenOddFillType=function(b){return b.PolyTyp==f.PolyType.ptSubject?this.m_SubjFillType==f.PolyFillType.pftEvenOdd:this.m_ClipFillType==f.PolyFillType.pftEvenOdd};f.Clipper.prototype.IsEvenOddAltFillType=function(b){return b.PolyTyp==f.PolyType.ptSubject?this.m_ClipFillType==f.PolyFillType.pftEvenOdd:this.m_SubjFillType==f.PolyFillType.pftEvenOdd};f.Clipper.prototype.IsContributing=
function(b){var d,e;b.PolyTyp==f.PolyType.ptSubject?(d=this.m_SubjFillType,e=this.m_ClipFillType):(d=this.m_ClipFillType,e=this.m_SubjFillType);switch(d){case f.PolyFillType.pftEvenOdd:if(0===b.WindDelta&&1!=b.WindCnt)return!1;break;case f.PolyFillType.pftNonZero:if(1!=Math.abs(b.WindCnt))return!1;break;case f.PolyFillType.pftPositive:if(1!=b.WindCnt)return!1;break;default:if(-1!=b.WindCnt)return!1}switch(this.m_ClipType){case f.ClipType.ctIntersection:switch(e){case f.PolyFillType.pftEvenOdd:case f.PolyFillType.pftNonZero:return 0!==
b.WindCnt2;case f.PolyFillType.pftPositive:return 0<b.WindCnt2;default:return 0>b.WindCnt2}case f.ClipType.ctUnion:switch(e){case f.PolyFillType.pftEvenOdd:case f.PolyFillType.pftNonZero:return 0===b.WindCnt2;case f.PolyFillType.pftPositive:return 0>=b.WindCnt2;default:return 0<=b.WindCnt2}case f.ClipType.ctDifference:if(b.PolyTyp==f.PolyType.ptSubject)switch(e){case f.PolyFillType.pftEvenOdd:case f.PolyFillType.pftNonZero:return 0===b.WindCnt2;case f.PolyFillType.pftPositive:return 0>=b.WindCnt2;
default:return 0<=b.WindCnt2}else switch(e){case f.PolyFillType.pftEvenOdd:case f.PolyFillType.pftNonZero:return 0!==b.WindCnt2;case f.PolyFillType.pftPositive:return 0<b.WindCnt2;default:return 0>b.WindCnt2}case f.ClipType.ctXor:if(0===b.WindDelta)switch(e){case f.PolyFillType.pftEvenOdd:case f.PolyFillType.pftNonZero:return 0===b.WindCnt2;case f.PolyFillType.pftPositive:return 0>=b.WindCnt2;default:return 0<=b.WindCnt2}}return!0};f.Clipper.prototype.SetWindingCount=function(b){for(var d=b.PrevInAEL;null!==
d&&(d.PolyTyp!=b.PolyTyp||0===d.WindDelta);)d=d.PrevInAEL;if(null===d)b.WindCnt=0===b.WindDelta?1:b.WindDelta,b.WindCnt2=0,d=this.m_ActiveEdges;else{if(0===b.WindDelta&&this.m_ClipType!=f.ClipType.ctUnion)b.WindCnt=1;else if(this.IsEvenOddFillType(b))if(0===b.WindDelta){for(var e=!0,r=d.PrevInAEL;null!==r;)r.PolyTyp==d.PolyTyp&&0!==r.WindDelta&&(e=!e),r=r.PrevInAEL;b.WindCnt=e?0:1}else b.WindCnt=b.WindDelta;else b.WindCnt=0>d.WindCnt*d.WindDelta?1<Math.abs(d.WindCnt)?0>d.WindDelta*b.WindDelta?d.WindCnt:
d.WindCnt+b.WindDelta:0===b.WindDelta?1:b.WindDelta:0===b.WindDelta?0>d.WindCnt?d.WindCnt-1:d.WindCnt+1:0>d.WindDelta*b.WindDelta?d.WindCnt:d.WindCnt+b.WindDelta;b.WindCnt2=d.WindCnt2;d=d.NextInAEL}if(this.IsEvenOddAltFillType(b))for(;d!=b;)0!==d.WindDelta&&(b.WindCnt2=0===b.WindCnt2?1:0),d=d.NextInAEL;else for(;d!=b;)b.WindCnt2+=d.WindDelta,d=d.NextInAEL};f.Clipper.prototype.AddEdgeToSEL=function(b){null===this.m_SortedEdges?(this.m_SortedEdges=b,b.PrevInSEL=null,b.NextInSEL=null):(b.NextInSEL=this.m_SortedEdges,
b.PrevInSEL=null,this.m_SortedEdges=this.m_SortedEdges.PrevInSEL=b)};f.Clipper.prototype.CopyAELToSEL=function(){var b=this.m_ActiveEdges;for(this.m_SortedEdges=b;null!==b;)b.PrevInSEL=b.PrevInAEL,b=b.NextInSEL=b.NextInAEL};f.Clipper.prototype.SwapPositionsInAEL=function(b,d){if(b.NextInAEL!=b.PrevInAEL&&d.NextInAEL!=d.PrevInAEL){if(b.NextInAEL==d){var e=d.NextInAEL;null!==e&&(e.PrevInAEL=b);var f=b.PrevInAEL;null!==f&&(f.NextInAEL=d);d.PrevInAEL=f;d.NextInAEL=b;b.PrevInAEL=d;b.NextInAEL=e}else d.NextInAEL==
b?(e=b.NextInAEL,null!==e&&(e.PrevInAEL=d),f=d.PrevInAEL,null!==f&&(f.NextInAEL=b),b.PrevInAEL=f,b.NextInAEL=d,d.PrevInAEL=b,d.NextInAEL=e):(e=b.NextInAEL,f=b.PrevInAEL,b.NextInAEL=d.NextInAEL,null!==b.NextInAEL&&(b.NextInAEL.PrevInAEL=b),b.PrevInAEL=d.PrevInAEL,null!==b.PrevInAEL&&(b.PrevInAEL.NextInAEL=b),d.NextInAEL=e,null!==d.NextInAEL&&(d.NextInAEL.PrevInAEL=d),d.PrevInAEL=f,null!==d.PrevInAEL&&(d.PrevInAEL.NextInAEL=d));null===b.PrevInAEL?this.m_ActiveEdges=b:null===d.PrevInAEL&&(this.m_ActiveEdges=
d)}};f.Clipper.prototype.SwapPositionsInSEL=function(b,d){if(null!==b.NextInSEL||null!==b.PrevInSEL)if(null!==d.NextInSEL||null!==d.PrevInSEL){if(b.NextInSEL==d){var e=d.NextInSEL;null!==e&&(e.PrevInSEL=b);var f=b.PrevInSEL;null!==f&&(f.NextInSEL=d);d.PrevInSEL=f;d.NextInSEL=b;b.PrevInSEL=d;b.NextInSEL=e}else d.NextInSEL==b?(e=b.NextInSEL,null!==e&&(e.PrevInSEL=d),f=d.PrevInSEL,null!==f&&(f.NextInSEL=b),b.PrevInSEL=f,b.NextInSEL=d,d.PrevInSEL=b,d.NextInSEL=e):(e=b.NextInSEL,f=b.PrevInSEL,b.NextInSEL=
d.NextInSEL,null!==b.NextInSEL&&(b.NextInSEL.PrevInSEL=b),b.PrevInSEL=d.PrevInSEL,null!==b.PrevInSEL&&(b.PrevInSEL.NextInSEL=b),d.NextInSEL=e,null!==d.NextInSEL&&(d.NextInSEL.PrevInSEL=d),d.PrevInSEL=f,null!==d.PrevInSEL&&(d.PrevInSEL.NextInSEL=d));null===b.PrevInSEL?this.m_SortedEdges=b:null===d.PrevInSEL&&(this.m_SortedEdges=d)}};f.Clipper.prototype.AddLocalMaxPoly=function(b,d,e){this.AddOutPt(b,e);0==d.WindDelta&&this.AddOutPt(d,e);b.OutIdx==d.OutIdx?(b.OutIdx=-1,d.OutIdx=-1):b.OutIdx<d.OutIdx?
this.AppendPolygon(b,d):this.AppendPolygon(d,b)};f.Clipper.prototype.AddLocalMinPoly=function(b,d,e){var r,n;f.ClipperBase.IsHorizontal(d)||b.Dx>d.Dx?(r=this.AddOutPt(b,e),d.OutIdx=b.OutIdx,b.Side=f.EdgeSide.esLeft,d.Side=f.EdgeSide.esRight,n=b,b=n.PrevInAEL==d?d.PrevInAEL:n.PrevInAEL):(r=this.AddOutPt(d,e),b.OutIdx=d.OutIdx,b.Side=f.EdgeSide.esRight,d.Side=f.EdgeSide.esLeft,n=d,b=n.PrevInAEL==b?b.PrevInAEL:n.PrevInAEL);null!==b&&0<=b.OutIdx&&f.Clipper.TopX(b,e.Y)==f.Clipper.TopX(n,e.Y)&&f.ClipperBase.SlopesEqual(n,
b,this.m_UseFullRange)&&0!==n.WindDelta&&0!==b.WindDelta&&(e=this.AddOutPt(b,e),this.AddJoin(r,e,n.Top));return r};f.Clipper.prototype.CreateOutRec=function(){var b=new f.OutRec;b.Idx=-1;b.IsHole=!1;b.IsOpen=!1;b.FirstLeft=null;b.Pts=null;b.BottomPt=null;b.PolyNode=null;this.m_PolyOuts.push(b);b.Idx=this.m_PolyOuts.length-1;return b};f.Clipper.prototype.AddOutPt=function(b,d){var e=b.Side==f.EdgeSide.esLeft;if(0>b.OutIdx){var r=this.CreateOutRec();r.IsOpen=0===b.WindDelta;var n=new f.OutPt;r.Pts=
n;n.Idx=r.Idx;n.Pt.X=d.X;n.Pt.Y=d.Y;f.use_xyz&&(n.Pt.Z=d.Z);n.Next=n;n.Prev=n;r.IsOpen||this.SetHoleState(b,r);b.OutIdx=r.Idx}else{var r=this.m_PolyOuts[b.OutIdx],k=r.Pts;if(e&&f.IntPoint.op_Equality(d,k.Pt))return k;if(!e&&f.IntPoint.op_Equality(d,k.Prev.Pt))return k.Prev;n=new f.OutPt;n.Idx=r.Idx;n.Pt.X=d.X;n.Pt.Y=d.Y;f.use_xyz&&(n.Pt.Z=d.Z);n.Next=k;n.Prev=k.Prev;n.Prev.Next=n;k.Prev=n;e&&(r.Pts=n)}return n};f.Clipper.prototype.SwapPoints=function(b,d){var e=new f.IntPoint(b.Value);b.Value.X=d.Value.X;
b.Value.Y=d.Value.Y;f.use_xyz&&(b.Value.Z=d.Value.Z);d.Value.X=e.X;d.Value.Y=e.Y;f.use_xyz&&(d.Value.Z=e.Z)};f.Clipper.prototype.HorzSegmentsOverlap=function(b,d,e,f){var n;b>d&&(n=b,b=d,d=n);e>f&&(n=e,e=f,f=n);return b<f&&e<d};f.Clipper.prototype.SetHoleState=function(b,d){for(var e=!1,f=b.PrevInAEL;null!==f;)0<=f.OutIdx&&0!=f.WindDelta&&(e=!e,null===d.FirstLeft&&(d.FirstLeft=this.m_PolyOuts[f.OutIdx])),f=f.PrevInAEL;e&&(d.IsHole=!0)};f.Clipper.prototype.GetDx=function(b,d){return b.Y==d.Y?f.ClipperBase.horizontal:
(d.X-b.X)/(d.Y-b.Y)};f.Clipper.prototype.FirstIsBottomPt=function(b,d){for(var e=b.Prev;f.IntPoint.op_Equality(e.Pt,b.Pt)&&e!=b;)e=e.Prev;for(var r=Math.abs(this.GetDx(b.Pt,e.Pt)),e=b.Next;f.IntPoint.op_Equality(e.Pt,b.Pt)&&e!=b;)e=e.Next;for(var n=Math.abs(this.GetDx(b.Pt,e.Pt)),e=d.Prev;f.IntPoint.op_Equality(e.Pt,d.Pt)&&e!=d;)e=e.Prev;for(var k=Math.abs(this.GetDx(d.Pt,e.Pt)),e=d.Next;f.IntPoint.op_Equality(e.Pt,d.Pt)&&e!=d;)e=e.Next;e=Math.abs(this.GetDx(d.Pt,e.Pt));return r>=k&&r>=e||n>=k&&n>=
e};f.Clipper.prototype.GetBottomPt=function(b){for(var d=null,e=b.Next;e!=b;)e.Pt.Y>b.Pt.Y?(b=e,d=null):e.Pt.Y==b.Pt.Y&&e.Pt.X<=b.Pt.X&&(e.Pt.X<b.Pt.X?(d=null,b=e):e.Next!=b&&e.Prev!=b&&(d=e)),e=e.Next;if(null!==d)for(;d!=e;)for(this.FirstIsBottomPt(e,d)||(b=d),d=d.Next;f.IntPoint.op_Inequality(d.Pt,b.Pt);)d=d.Next;return b};f.Clipper.prototype.GetLowermostRec=function(b,d){null===b.BottomPt&&(b.BottomPt=this.GetBottomPt(b.Pts));null===d.BottomPt&&(d.BottomPt=this.GetBottomPt(d.Pts));var e=b.BottomPt,
f=d.BottomPt;return e.Pt.Y>f.Pt.Y?b:e.Pt.Y<f.Pt.Y?d:e.Pt.X<f.Pt.X?b:e.Pt.X>f.Pt.X?d:e.Next==e?d:f.Next==f?b:this.FirstIsBottomPt(e,f)?b:d};f.Clipper.prototype.Param1RightOfParam2=function(b,d){do if(b=b.FirstLeft,b==d)return!0;while(null!==b);return!1};f.Clipper.prototype.GetOutRec=function(b){for(b=this.m_PolyOuts[b];b!=this.m_PolyOuts[b.Idx];)b=this.m_PolyOuts[b.Idx];return b};f.Clipper.prototype.AppendPolygon=function(b,d){var e=this.m_PolyOuts[b.OutIdx],r=this.m_PolyOuts[d.OutIdx],n;n=this.Param1RightOfParam2(e,
r)?r:this.Param1RightOfParam2(r,e)?e:this.GetLowermostRec(e,r);var k=e.Pts,u=k.Prev,C=r.Pts,p=C.Prev;b.Side==f.EdgeSide.esLeft?(d.Side==f.EdgeSide.esLeft?(this.ReversePolyPtLinks(C),C.Next=k,k.Prev=C,u.Next=p,p.Prev=u,e.Pts=p):(p.Next=k,k.Prev=p,C.Prev=u,u.Next=C,e.Pts=C),k=f.EdgeSide.esLeft):(d.Side==f.EdgeSide.esRight?(this.ReversePolyPtLinks(C),u.Next=p,p.Prev=u,C.Next=k,k.Prev=C):(u.Next=C,C.Prev=u,k.Prev=p,p.Next=k),k=f.EdgeSide.esRight);e.BottomPt=null;n==r&&(r.FirstLeft!=e&&(e.FirstLeft=r.FirstLeft),
e.IsHole=r.IsHole);r.Pts=null;r.BottomPt=null;r.FirstLeft=e;n=b.OutIdx;u=d.OutIdx;b.OutIdx=-1;d.OutIdx=-1;for(C=this.m_ActiveEdges;null!==C;){if(C.OutIdx==u){C.OutIdx=n;C.Side=k;break}C=C.NextInAEL}r.Idx=e.Idx};f.Clipper.prototype.ReversePolyPtLinks=function(b){if(null!==b){var d,e;d=b;do e=d.Next,d.Next=d.Prev,d=d.Prev=e;while(d!=b)}};f.Clipper.SwapSides=function(b,d){var e=b.Side;b.Side=d.Side;d.Side=e};f.Clipper.SwapPolyIndexes=function(b,d){var e=b.OutIdx;b.OutIdx=d.OutIdx;d.OutIdx=e};f.Clipper.prototype.IntersectEdges=
function(b,d,e){var r=0<=b.OutIdx,n=0<=d.OutIdx;f.use_xyz&&this.SetZ(e,b,d);if(!f.use_lines||0!==b.WindDelta&&0!==d.WindDelta){if(b.PolyTyp==d.PolyTyp)if(this.IsEvenOddFillType(b)){var k=b.WindCnt;b.WindCnt=d.WindCnt;d.WindCnt=k}else b.WindCnt=0===b.WindCnt+d.WindDelta?-b.WindCnt:b.WindCnt+d.WindDelta,d.WindCnt=0===d.WindCnt-b.WindDelta?-d.WindCnt:d.WindCnt-b.WindDelta;else this.IsEvenOddFillType(d)?b.WindCnt2=0===b.WindCnt2?1:0:b.WindCnt2+=d.WindDelta,this.IsEvenOddFillType(b)?d.WindCnt2=0===d.WindCnt2?
1:0:d.WindCnt2-=b.WindDelta;var u,C,p;b.PolyTyp==f.PolyType.ptSubject?(u=this.m_SubjFillType,p=this.m_ClipFillType):(u=this.m_ClipFillType,p=this.m_SubjFillType);d.PolyTyp==f.PolyType.ptSubject?(C=this.m_SubjFillType,k=this.m_ClipFillType):(C=this.m_ClipFillType,k=this.m_SubjFillType);switch(u){case f.PolyFillType.pftPositive:u=b.WindCnt;break;case f.PolyFillType.pftNegative:u=-b.WindCnt;break;default:u=Math.abs(b.WindCnt)}switch(C){case f.PolyFillType.pftPositive:C=d.WindCnt;break;case f.PolyFillType.pftNegative:C=
-d.WindCnt;break;default:C=Math.abs(d.WindCnt)}if(r&&n)0!=u&&1!=u||0!=C&&1!=C||b.PolyTyp!=d.PolyTyp&&this.m_ClipType!=f.ClipType.ctXor?this.AddLocalMaxPoly(b,d,e):(this.AddOutPt(b,e),this.AddOutPt(d,e),f.Clipper.SwapSides(b,d),f.Clipper.SwapPolyIndexes(b,d));else if(r){if(0===C||1==C)this.AddOutPt(b,e),f.Clipper.SwapSides(b,d),f.Clipper.SwapPolyIndexes(b,d)}else if(n){if(0===u||1==u)this.AddOutPt(d,e),f.Clipper.SwapSides(b,d),f.Clipper.SwapPolyIndexes(b,d)}else if(!(0!=u&&1!=u||0!=C&&1!=C)){switch(p){case f.PolyFillType.pftPositive:r=
b.WindCnt2;break;case f.PolyFillType.pftNegative:r=-b.WindCnt2;break;default:r=Math.abs(b.WindCnt2)}switch(k){case f.PolyFillType.pftPositive:n=d.WindCnt2;break;case f.PolyFillType.pftNegative:n=-d.WindCnt2;break;default:n=Math.abs(d.WindCnt2)}if(b.PolyTyp!=d.PolyTyp)this.AddLocalMinPoly(b,d,e);else if(1==u&&1==C)switch(this.m_ClipType){case f.ClipType.ctIntersection:0<r&&0<n&&this.AddLocalMinPoly(b,d,e);break;case f.ClipType.ctUnion:0>=r&&0>=n&&this.AddLocalMinPoly(b,d,e);break;case f.ClipType.ctDifference:(b.PolyTyp==
f.PolyType.ptClip&&0<r&&0<n||b.PolyTyp==f.PolyType.ptSubject&&0>=r&&0>=n)&&this.AddLocalMinPoly(b,d,e);break;case f.ClipType.ctXor:this.AddLocalMinPoly(b,d,e)}else f.Clipper.SwapSides(b,d)}}else if(0!=b.WindDelta||0!=d.WindDelta)b.PolyTyp==d.PolyTyp&&b.WindDelta!=d.WindDelta&&this.m_ClipType==f.ClipType.ctUnion?0===b.WindDelta?n&&(this.AddOutPt(b,e),r&&(b.OutIdx=-1)):r&&(this.AddOutPt(d,e),n&&(d.OutIdx=-1)):b.PolyTyp!=d.PolyTyp&&(0!==b.WindDelta||1!=Math.abs(d.WindCnt)||this.m_ClipType==f.ClipType.ctUnion&&
0!==d.WindCnt2?0!==d.WindDelta||1!=Math.abs(b.WindCnt)||this.m_ClipType==f.ClipType.ctUnion&&0!==b.WindCnt2||(this.AddOutPt(d,e),n&&(d.OutIdx=-1)):(this.AddOutPt(b,e),r&&(b.OutIdx=-1)))};f.Clipper.prototype.DeleteFromAEL=function(b){var d=b.PrevInAEL,e=b.NextInAEL;if(null!==d||null!==e||b==this.m_ActiveEdges)null!==d?d.NextInAEL=e:this.m_ActiveEdges=e,null!==e&&(e.PrevInAEL=d),b.NextInAEL=null,b.PrevInAEL=null};f.Clipper.prototype.DeleteFromSEL=function(b){var d=b.PrevInSEL,e=b.NextInSEL;if(null!==
d||null!==e||b==this.m_SortedEdges)null!==d?d.NextInSEL=e:this.m_SortedEdges=e,null!==e&&(e.PrevInSEL=d),b.NextInSEL=null,b.PrevInSEL=null};f.Clipper.prototype.UpdateEdgeIntoAEL=function(b){null===b.NextInLML&&f.Error("UpdateEdgeIntoAEL: invalid call");var d=b.PrevInAEL,e=b.NextInAEL;b.NextInLML.OutIdx=b.OutIdx;null!==d?d.NextInAEL=b.NextInLML:this.m_ActiveEdges=b.NextInLML;null!==e&&(e.PrevInAEL=b.NextInLML);b.NextInLML.Side=b.Side;b.NextInLML.WindDelta=b.WindDelta;b.NextInLML.WindCnt=b.WindCnt;
b.NextInLML.WindCnt2=b.WindCnt2;b=b.NextInLML;b.Curr.X=b.Bot.X;b.Curr.Y=b.Bot.Y;f.use_xyz&&(b.Curr.Z=b.Bot.Z);b.PrevInAEL=d;b.NextInAEL=e;f.ClipperBase.IsHorizontal(b)||this.InsertScanbeam(b.Top.Y);return b};f.Clipper.prototype.ProcessHorizontals=function(b){for(var d=this.m_SortedEdges;null!==d;)this.DeleteFromSEL(d),this.ProcessHorizontal(d,b),d=this.m_SortedEdges};f.Clipper.prototype.GetHorzDirection=function(b,d){b.Bot.X<b.Top.X?(d.Left=b.Bot.X,d.Right=b.Top.X,d.Dir=f.Direction.dLeftToRight):
(d.Left=b.Top.X,d.Right=b.Bot.X,d.Dir=f.Direction.dRightToLeft)};f.Clipper.prototype.ProcessHorizontal=function(b,d){var e={Dir:null,Left:null,Right:null};this.GetHorzDirection(b,e);for(var r=e.Dir,n=e.Left,k=e.Right,u=b,C=null;null!==u.NextInLML&&f.ClipperBase.IsHorizontal(u.NextInLML);)u=u.NextInLML;for(null===u.NextInLML&&(C=this.GetMaximaPair(u));;){for(var p=b==u,E=this.GetNextInAEL(b,r);null!==E&&!(E.Curr.X==b.Top.X&&null!==b.NextInLML&&E.Dx<b.NextInLML.Dx);){e=this.GetNextInAEL(E,r);if(r==
f.Direction.dLeftToRight&&E.Curr.X<=k||r==f.Direction.dRightToLeft&&E.Curr.X>=n){if(E==C&&p){if(0<=b.OutIdx){r=this.AddOutPt(b,b.Top);for(e=this.m_SortedEdges;null!==e;)0<=e.OutIdx&&this.HorzSegmentsOverlap(b.Bot.X,b.Top.X,e.Bot.X,e.Top.X)&&(n=this.AddOutPt(e,e.Bot),this.AddJoin(n,r,e.Top)),e=e.NextInSEL;this.AddGhostJoin(r,b.Bot);this.AddLocalMaxPoly(b,C,b.Top)}this.DeleteFromAEL(b);this.DeleteFromAEL(C);return}if(r==f.Direction.dLeftToRight){var F=new f.IntPoint(E.Curr.X,b.Curr.Y);this.IntersectEdges(b,
E,F)}else F=new f.IntPoint(E.Curr.X,b.Curr.Y),this.IntersectEdges(E,b,F);this.SwapPositionsInAEL(b,E)}else if(r==f.Direction.dLeftToRight&&E.Curr.X>=k||r==f.Direction.dRightToLeft&&E.Curr.X<=n)break;E=e}if(null!==b.NextInLML&&f.ClipperBase.IsHorizontal(b.NextInLML))b=this.UpdateEdgeIntoAEL(b),0<=b.OutIdx&&this.AddOutPt(b,b.Bot),e={Dir:r,Left:n,Right:k},this.GetHorzDirection(b,e),r=e.Dir,n=e.Left,k=e.Right;else break}null!==b.NextInLML?0<=b.OutIdx?(r=this.AddOutPt(b,b.Top),d&&this.AddGhostJoin(r,b.Bot),
b=this.UpdateEdgeIntoAEL(b),0!==b.WindDelta&&(C=b.PrevInAEL,e=b.NextInAEL,null!==C&&C.Curr.X==b.Bot.X&&C.Curr.Y==b.Bot.Y&&0!==C.WindDelta&&0<=C.OutIdx&&C.Curr.Y>C.Top.Y&&f.ClipperBase.SlopesEqual(b,C,this.m_UseFullRange)?(n=this.AddOutPt(C,b.Bot),this.AddJoin(r,n,b.Top)):null!==e&&e.Curr.X==b.Bot.X&&e.Curr.Y==b.Bot.Y&&0!==e.WindDelta&&0<=e.OutIdx&&e.Curr.Y>e.Top.Y&&f.ClipperBase.SlopesEqual(b,e,this.m_UseFullRange)&&(n=this.AddOutPt(e,b.Bot),this.AddJoin(r,n,b.Top)))):this.UpdateEdgeIntoAEL(b):(0<=
b.OutIdx&&this.AddOutPt(b,b.Top),this.DeleteFromAEL(b))};f.Clipper.prototype.GetNextInAEL=function(b,d){return d==f.Direction.dLeftToRight?b.NextInAEL:b.PrevInAEL};f.Clipper.prototype.IsMinima=function(b){return null!==b&&b.Prev.NextInLML!=b&&b.Next.NextInLML!=b};f.Clipper.prototype.IsMaxima=function(b,d){return null!==b&&b.Top.Y==d&&null===b.NextInLML};f.Clipper.prototype.IsIntermediate=function(b,d){return b.Top.Y==d&&null!==b.NextInLML};f.Clipper.prototype.GetMaximaPair=function(b){var d=null;
f.IntPoint.op_Equality(b.Next.Top,b.Top)&&null===b.Next.NextInLML?d=b.Next:f.IntPoint.op_Equality(b.Prev.Top,b.Top)&&null===b.Prev.NextInLML&&(d=b.Prev);return null===d||-2!=d.OutIdx&&(d.NextInAEL!=d.PrevInAEL||f.ClipperBase.IsHorizontal(d))?d:null};f.Clipper.prototype.ProcessIntersections=function(b){if(null==this.m_ActiveEdges)return!0;try{this.BuildIntersectList(b);if(0==this.m_IntersectList.length)return!0;if(1==this.m_IntersectList.length||this.FixupIntersectionOrder())this.ProcessIntersectList();
else return!1}catch(d){this.m_SortedEdges=null,this.m_IntersectList.length=0,f.Error("ProcessIntersections error")}this.m_SortedEdges=null;return!0};f.Clipper.prototype.BuildIntersectList=function(b){if(null!==this.m_ActiveEdges){var d=this.m_ActiveEdges;for(this.m_SortedEdges=d;null!==d;)d.PrevInSEL=d.PrevInAEL,d.NextInSEL=d.NextInAEL,d.Curr.X=f.Clipper.TopX(d,b),d=d.NextInAEL;for(var e=!0;e&&null!==this.m_SortedEdges;){e=!1;for(d=this.m_SortedEdges;null!==d.NextInSEL;){b=d.NextInSEL;var r=new f.IntPoint;
d.Curr.X>b.Curr.X?(this.IntersectPoint(d,b,r),e=new f.IntersectNode,e.Edge1=d,e.Edge2=b,e.Pt.X=r.X,e.Pt.Y=r.Y,f.use_xyz&&(e.Pt.Z=r.Z),this.m_IntersectList.push(e),this.SwapPositionsInSEL(d,b),e=!0):d=b}if(null!==d.PrevInSEL)d.PrevInSEL.NextInSEL=null;else break}this.m_SortedEdges=null}};f.Clipper.prototype.EdgesAdjacent=function(b){return b.Edge1.NextInSEL==b.Edge2||b.Edge1.PrevInSEL==b.Edge2};f.Clipper.IntersectNodeSort=function(b,d){return d.Pt.Y-b.Pt.Y};f.Clipper.prototype.FixupIntersectionOrder=
function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer);this.CopyAELToSEL();for(var b=this.m_IntersectList.length,d=0;d<b;d++){if(!this.EdgesAdjacent(this.m_IntersectList[d])){for(var e=d+1;e<b&&!this.EdgesAdjacent(this.m_IntersectList[e]);)e++;if(e==b)return!1;var f=this.m_IntersectList[d];this.m_IntersectList[d]=this.m_IntersectList[e];this.m_IntersectList[e]=f}this.SwapPositionsInSEL(this.m_IntersectList[d].Edge1,this.m_IntersectList[d].Edge2)}return!0};f.Clipper.prototype.ProcessIntersectList=
function(){for(var b=0,d=this.m_IntersectList.length;b<d;b++){var e=this.m_IntersectList[b];this.IntersectEdges(e.Edge1,e.Edge2,e.Pt);this.SwapPositionsInAEL(e.Edge1,e.Edge2)}this.m_IntersectList.length=0};M=function(b){return 0>b?Math.ceil(b-.5):Math.round(b)};Sb=function(b){return 0>b?Math.ceil(b-.5):Math.floor(b+.5)};Ta=function(b){return 0>b?-Math.round(Math.abs(b)):Math.round(b)};fb=function(b){if(0>b)return b-=.5,-2147483648>b?Math.ceil(b):b|0;b+=.5;return 2147483647<b?Math.floor(b):b|0};f.Clipper.Round=
ba?M:tb?Ta:gc?fb:Sb;f.Clipper.TopX=function(b,d){return d==b.Top.Y?b.Top.X:b.Bot.X+f.Clipper.Round(b.Dx*(d-b.Bot.Y))};f.Clipper.prototype.IntersectPoint=function(b,d,e){e.X=0;e.Y=0;var r,n;if(b.Dx==d.Dx)e.Y=b.Curr.Y,e.X=f.Clipper.TopX(b,e.Y);else{if(0===b.Delta.X)e.X=b.Bot.X,f.ClipperBase.IsHorizontal(d)?e.Y=d.Bot.Y:(n=d.Bot.Y-d.Bot.X/d.Dx,e.Y=f.Clipper.Round(e.X/d.Dx+n));else if(0===d.Delta.X)e.X=d.Bot.X,f.ClipperBase.IsHorizontal(b)?e.Y=b.Bot.Y:(r=b.Bot.Y-b.Bot.X/b.Dx,e.Y=f.Clipper.Round(e.X/b.Dx+
r));else{r=b.Bot.X-b.Bot.Y*b.Dx;n=d.Bot.X-d.Bot.Y*d.Dx;var k=(n-r)/(b.Dx-d.Dx);e.Y=f.Clipper.Round(k);e.X=Math.abs(b.Dx)<Math.abs(d.Dx)?f.Clipper.Round(b.Dx*k+r):f.Clipper.Round(d.Dx*k+n)}if(e.Y<b.Top.Y||e.Y<d.Top.Y){if(b.Top.Y>d.Top.Y)return e.Y=b.Top.Y,e.X=f.Clipper.TopX(d,b.Top.Y),e.X<b.Top.X;e.Y=d.Top.Y;e.X=Math.abs(b.Dx)<Math.abs(d.Dx)?f.Clipper.TopX(b,e.Y):f.Clipper.TopX(d,e.Y)}e.Y>b.Curr.Y&&(e.Y=b.Curr.Y,e.X=Math.abs(b.Dx)>Math.abs(d.Dx)?f.Clipper.TopX(d,e.Y):f.Clipper.TopX(b,e.Y))}};f.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=
function(b){for(var d=this.m_ActiveEdges;null!==d;){var e=this.IsMaxima(d,b);e&&(e=this.GetMaximaPair(d),e=null===e||!f.ClipperBase.IsHorizontal(e));if(e){var r=d.PrevInAEL;this.DoMaxima(d);d=null===r?this.m_ActiveEdges:r.NextInAEL}else{this.IsIntermediate(d,b)&&f.ClipperBase.IsHorizontal(d.NextInLML)?(d=this.UpdateEdgeIntoAEL(d),0<=d.OutIdx&&this.AddOutPt(d,d.Bot),this.AddEdgeToSEL(d)):(d.Curr.X=f.Clipper.TopX(d,b),d.Curr.Y=b);if(this.StrictlySimple&&(r=d.PrevInAEL,0<=d.OutIdx&&0!==d.WindDelta&&
null!==r&&0<=r.OutIdx&&r.Curr.X==d.Curr.X&&0!==r.WindDelta)){var n=new f.IntPoint(d.Curr);f.use_xyz&&this.SetZ(n,r,d);e=this.AddOutPt(r,n);r=this.AddOutPt(d,n);this.AddJoin(e,r,n)}d=d.NextInAEL}}this.ProcessHorizontals(!0);for(d=this.m_ActiveEdges;null!==d;)this.IsIntermediate(d,b)&&(e=null,0<=d.OutIdx&&(e=this.AddOutPt(d,d.Top)),d=this.UpdateEdgeIntoAEL(d),r=d.PrevInAEL,n=d.NextInAEL,null!==r&&r.Curr.X==d.Bot.X&&r.Curr.Y==d.Bot.Y&&null!==e&&0<=r.OutIdx&&r.Curr.Y>r.Top.Y&&f.ClipperBase.SlopesEqual(d,
r,this.m_UseFullRange)&&0!==d.WindDelta&&0!==r.WindDelta?(r=this.AddOutPt(r,d.Bot),this.AddJoin(e,r,d.Top)):null!==n&&n.Curr.X==d.Bot.X&&n.Curr.Y==d.Bot.Y&&null!==e&&0<=n.OutIdx&&n.Curr.Y>n.Top.Y&&f.ClipperBase.SlopesEqual(d,n,this.m_UseFullRange)&&0!==d.WindDelta&&0!==n.WindDelta&&(r=this.AddOutPt(n,d.Bot),this.AddJoin(e,r,d.Top))),d=d.NextInAEL};f.Clipper.prototype.DoMaxima=function(b){var d=this.GetMaximaPair(b);if(null===d)0<=b.OutIdx&&this.AddOutPt(b,b.Top),this.DeleteFromAEL(b);else{for(var e=
b.NextInAEL;null!==e&&e!=d;)this.IntersectEdges(b,e,b.Top),this.SwapPositionsInAEL(b,e),e=b.NextInAEL;-1==b.OutIdx&&-1==d.OutIdx?(this.DeleteFromAEL(b),this.DeleteFromAEL(d)):0<=b.OutIdx&&0<=d.OutIdx?(0<=b.OutIdx&&this.AddLocalMaxPoly(b,d,b.Top),this.DeleteFromAEL(b),this.DeleteFromAEL(d)):f.use_lines&&0===b.WindDelta?(0<=b.OutIdx&&(this.AddOutPt(b,b.Top),b.OutIdx=-1),this.DeleteFromAEL(b),0<=d.OutIdx&&(this.AddOutPt(d,b.Top),d.OutIdx=-1),this.DeleteFromAEL(d)):f.Error("DoMaxima error")}};f.Clipper.ReversePaths=
function(b){for(var d=0,e=b.length;d<e;d++)b[d].reverse()};f.Clipper.Orientation=function(b){return 0<=f.Clipper.Area(b)};f.Clipper.prototype.PointCount=function(b){if(null===b)return 0;var d=0,e=b;do d++,e=e.Next;while(e!=b);return d};f.Clipper.prototype.BuildResult=function(b){f.Clear(b);for(var d=0,e=this.m_PolyOuts.length;d<e;d++){var r=this.m_PolyOuts[d];if(null!==r.Pts){var r=r.Pts.Prev,n=this.PointCount(r);if(!(2>n)){for(var k=Array(n),u=0;u<n;u++)k[u]=r.Pt,r=r.Prev;b.push(k)}}}};f.Clipper.prototype.BuildResult2=
function(b){b.Clear();for(var d=0,e=this.m_PolyOuts.length;d<e;d++){var r=this.m_PolyOuts[d],n=this.PointCount(r.Pts);if(!(r.IsOpen&&2>n||!r.IsOpen&&3>n)){this.FixHoleLinkage(r);var k=new f.PolyNode;b.m_AllPolys.push(k);r.PolyNode=k;k.m_polygon.length=n;for(var r=r.Pts.Prev,u=0;u<n;u++)k.m_polygon[u]=r.Pt,r=r.Prev}}d=0;for(e=this.m_PolyOuts.length;d<e;d++)r=this.m_PolyOuts[d],null!==r.PolyNode&&(r.IsOpen?(r.PolyNode.IsOpen=!0,b.AddChild(r.PolyNode)):null!==r.FirstLeft&&null!=r.FirstLeft.PolyNode?
r.FirstLeft.PolyNode.AddChild(r.PolyNode):b.AddChild(r.PolyNode))};f.Clipper.prototype.FixupOutPolygon=function(b){var d=null;b.BottomPt=null;for(var e=b.Pts;;){if(e.Prev==e||e.Prev==e.Next){b.Pts=null;return}if(f.IntPoint.op_Equality(e.Pt,e.Next.Pt)||f.IntPoint.op_Equality(e.Pt,e.Prev.Pt)||f.ClipperBase.SlopesEqual(e.Prev.Pt,e.Pt,e.Next.Pt,this.m_UseFullRange)&&(!this.PreserveCollinear||!this.Pt2IsBetweenPt1AndPt3(e.Prev.Pt,e.Pt,e.Next.Pt)))d=null,e.Prev.Next=e.Next,e=e.Next.Prev=e.Prev;else if(e==
d)break;else null===d&&(d=e),e=e.Next}b.Pts=e};f.Clipper.prototype.DupOutPt=function(b,d){var e=new f.OutPt;e.Pt.X=b.Pt.X;e.Pt.Y=b.Pt.Y;f.use_xyz&&(e.Pt.Z=b.Pt.Z);e.Idx=b.Idx;d?(e.Next=b.Next,e.Prev=b,b.Next.Prev=e,b.Next=e):(e.Prev=b.Prev,e.Next=b,b.Prev.Next=e,b.Prev=e);return e};f.Clipper.prototype.GetOverlap=function(b,d,e,f,n){b<d?e<f?(n.Left=Math.max(b,e),n.Right=Math.min(d,f)):(n.Left=Math.max(b,f),n.Right=Math.min(d,e)):e<f?(n.Left=Math.max(d,e),n.Right=Math.min(b,f)):(n.Left=Math.max(d,f),
n.Right=Math.min(b,e));return n.Left<n.Right};f.Clipper.prototype.JoinHorz=function(b,d,e,r,n,k){var u=b.Pt.X>d.Pt.X?f.Direction.dRightToLeft:f.Direction.dLeftToRight;r=e.Pt.X>r.Pt.X?f.Direction.dRightToLeft:f.Direction.dLeftToRight;if(u==r)return!1;if(u==f.Direction.dLeftToRight){for(;b.Next.Pt.X<=n.X&&b.Next.Pt.X>=b.Pt.X&&b.Next.Pt.Y==n.Y;)b=b.Next;k&&b.Pt.X!=n.X&&(b=b.Next);d=this.DupOutPt(b,!k);f.IntPoint.op_Inequality(d.Pt,n)&&(b=d,b.Pt.X=n.X,b.Pt.Y=n.Y,f.use_xyz&&(b.Pt.Z=n.Z),d=this.DupOutPt(b,
!k))}else{for(;b.Next.Pt.X>=n.X&&b.Next.Pt.X<=b.Pt.X&&b.Next.Pt.Y==n.Y;)b=b.Next;k||b.Pt.X==n.X||(b=b.Next);d=this.DupOutPt(b,k);f.IntPoint.op_Inequality(d.Pt,n)&&(b=d,b.Pt.X=n.X,b.Pt.Y=n.Y,f.use_xyz&&(b.Pt.Z=n.Z),d=this.DupOutPt(b,k))}if(r==f.Direction.dLeftToRight){for(;e.Next.Pt.X<=n.X&&e.Next.Pt.X>=e.Pt.X&&e.Next.Pt.Y==n.Y;)e=e.Next;k&&e.Pt.X!=n.X&&(e=e.Next);r=this.DupOutPt(e,!k);f.IntPoint.op_Inequality(r.Pt,n)&&(e=r,e.Pt.X=n.X,e.Pt.Y=n.Y,f.use_xyz&&(e.Pt.Z=n.Z),r=this.DupOutPt(e,!k))}else{for(;e.Next.Pt.X>=
n.X&&e.Next.Pt.X<=e.Pt.X&&e.Next.Pt.Y==n.Y;)e=e.Next;k||e.Pt.X==n.X||(e=e.Next);r=this.DupOutPt(e,k);f.IntPoint.op_Inequality(r.Pt,n)&&(e=r,e.Pt.X=n.X,e.Pt.Y=n.Y,f.use_xyz&&(e.Pt.Z=n.Z),r=this.DupOutPt(e,k))}u==f.Direction.dLeftToRight==k?(b.Prev=e,e.Next=b,d.Next=r,r.Prev=d):(b.Next=e,e.Prev=b,d.Prev=r,r.Next=d);return!0};f.Clipper.prototype.JoinPoints=function(b,d,e){var r=b.OutPt1,n;new f.OutPt;var k=b.OutPt2,u;new f.OutPt;if((u=b.OutPt1.Pt.Y==b.OffPt.Y)&&f.IntPoint.op_Equality(b.OffPt,b.OutPt1.Pt)&&
f.IntPoint.op_Equality(b.OffPt,b.OutPt2.Pt)){if(d!=e)return!1;for(n=b.OutPt1.Next;n!=r&&f.IntPoint.op_Equality(n.Pt,b.OffPt);)n=n.Next;n=n.Pt.Y>b.OffPt.Y;for(u=b.OutPt2.Next;u!=k&&f.IntPoint.op_Equality(u.Pt,b.OffPt);)u=u.Next;if(n==u.Pt.Y>b.OffPt.Y)return!1;n?(n=this.DupOutPt(r,!1),u=this.DupOutPt(k,!0),r.Prev=k,k.Next=r,n.Next=u,u.Prev=n):(n=this.DupOutPt(r,!0),u=this.DupOutPt(k,!1),r.Next=k,k.Prev=r,n.Prev=u,u.Next=n);b.OutPt1=r;b.OutPt2=n;return!0}if(u){for(n=r;r.Prev.Pt.Y==r.Pt.Y&&r.Prev!=n&&
r.Prev!=k;)r=r.Prev;for(;n.Next.Pt.Y==n.Pt.Y&&n.Next!=r&&n.Next!=k;)n=n.Next;if(n.Next==r||n.Next==k)return!1;for(u=k;k.Prev.Pt.Y==k.Pt.Y&&k.Prev!=u&&k.Prev!=n;)k=k.Prev;for(;u.Next.Pt.Y==u.Pt.Y&&u.Next!=k&&u.Next!=r;)u=u.Next;if(u.Next==k||u.Next==r)return!1;e={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,n.Pt.X,k.Pt.X,u.Pt.X,e))return!1;d=e.Left;var C=e.Right;e=new f.IntPoint;r.Pt.X>=d&&r.Pt.X<=C?(e.X=r.Pt.X,e.Y=r.Pt.Y,f.use_xyz&&(e.Z=r.Pt.Z),d=r.Pt.X>n.Pt.X):k.Pt.X>=d&&k.Pt.X<=C?(e.X=k.Pt.X,
e.Y=k.Pt.Y,f.use_xyz&&(e.Z=k.Pt.Z),d=k.Pt.X>u.Pt.X):n.Pt.X>=d&&n.Pt.X<=C?(e.X=n.Pt.X,e.Y=n.Pt.Y,f.use_xyz&&(e.Z=n.Pt.Z),d=n.Pt.X>r.Pt.X):(e.X=u.Pt.X,e.Y=u.Pt.Y,f.use_xyz&&(e.Z=u.Pt.Z),d=u.Pt.X>k.Pt.X);b.OutPt1=r;b.OutPt2=k;return this.JoinHorz(r,n,k,u,e,d)}for(n=r.Next;f.IntPoint.op_Equality(n.Pt,r.Pt)&&n!=r;)n=n.Next;if(C=n.Pt.Y>r.Pt.Y||!f.ClipperBase.SlopesEqual(r.Pt,n.Pt,b.OffPt,this.m_UseFullRange)){for(n=r.Prev;f.IntPoint.op_Equality(n.Pt,r.Pt)&&n!=r;)n=n.Prev;if(n.Pt.Y>r.Pt.Y||!f.ClipperBase.SlopesEqual(r.Pt,
n.Pt,b.OffPt,this.m_UseFullRange))return!1}for(u=k.Next;f.IntPoint.op_Equality(u.Pt,k.Pt)&&u!=k;)u=u.Next;var p=u.Pt.Y>k.Pt.Y||!f.ClipperBase.SlopesEqual(k.Pt,u.Pt,b.OffPt,this.m_UseFullRange);if(p){for(u=k.Prev;f.IntPoint.op_Equality(u.Pt,k.Pt)&&u!=k;)u=u.Prev;if(u.Pt.Y>k.Pt.Y||!f.ClipperBase.SlopesEqual(k.Pt,u.Pt,b.OffPt,this.m_UseFullRange))return!1}if(n==r||u==k||n==u||d==e&&C==p)return!1;C?(n=this.DupOutPt(r,!1),u=this.DupOutPt(k,!0),r.Prev=k,k.Next=r,n.Next=u,u.Prev=n):(n=this.DupOutPt(r,!0),
u=this.DupOutPt(k,!1),r.Next=k,k.Prev=r,n.Prev=u,u.Next=n);b.OutPt1=r;b.OutPt2=n;return!0};f.Clipper.GetBounds=function(b){for(var d=0,e=b.length;d<e&&0==b[d].length;)d++;if(d==e)return new f.IntRect(0,0,0,0);var r=new f.IntRect;r.left=b[d][0].X;r.right=r.left;r.top=b[d][0].Y;for(r.bottom=r.top;d<e;d++)for(var k=0,I=b[d].length;k<I;k++)b[d][k].X<r.left?r.left=b[d][k].X:b[d][k].X>r.right&&(r.right=b[d][k].X),b[d][k].Y<r.top?r.top=b[d][k].Y:b[d][k].Y>r.bottom&&(r.bottom=b[d][k].Y);return r};f.Clipper.prototype.GetBounds2=
function(b){var d=b,e=new f.IntRect;e.left=b.Pt.X;e.right=b.Pt.X;e.top=b.Pt.Y;e.bottom=b.Pt.Y;for(b=b.Next;b!=d;)b.Pt.X<e.left&&(e.left=b.Pt.X),b.Pt.X>e.right&&(e.right=b.Pt.X),b.Pt.Y<e.top&&(e.top=b.Pt.Y),b.Pt.Y>e.bottom&&(e.bottom=b.Pt.Y),b=b.Next;return e};f.Clipper.PointInPolygon=function(b,d){var e=0,f=d.length;if(3>f)return 0;for(var k=d[0],I=1;I<=f;++I){var u=I==f?d[0]:d[I];if(u.Y==b.Y&&(u.X==b.X||k.Y==b.Y&&u.X>b.X==k.X<b.X))return-1;if(k.Y<b.Y!=u.Y<b.Y)if(k.X>=b.X)if(u.X>b.X)e=1-e;else{var C=
(k.X-b.X)*(u.Y-b.Y)-(u.X-b.X)*(k.Y-b.Y);if(0==C)return-1;0<C==u.Y>k.Y&&(e=1-e)}else if(u.X>b.X){C=(k.X-b.X)*(u.Y-b.Y)-(u.X-b.X)*(k.Y-b.Y);if(0==C)return-1;0<C==u.Y>k.Y&&(e=1-e)}k=u}return e};f.Clipper.prototype.PointInPolygon=function(b,d){var e=0,f=d,k=b.X,I=b.Y,u=d.Pt.X,C=d.Pt.Y;do{d=d.Next;var p=d.Pt.X,E=d.Pt.Y;if(E==I&&(p==k||C==I&&p>k==u<k))return-1;if(C<I!=E<I)if(u>=k)if(p>k)e=1-e;else{u=(u-k)*(E-I)-(p-k)*(C-I);if(0==u)return-1;0<u==E>C&&(e=1-e)}else if(p>k){u=(u-k)*(E-I)-(p-k)*(C-I);if(0==
u)return-1;0<u==E>C&&(e=1-e)}u=p;C=E}while(f!=d);return e};f.Clipper.prototype.Poly2ContainsPoly1=function(b,d){var e=b;do{var f=this.PointInPolygon(e.Pt,d);if(0<=f)return 0<f;e=e.Next}while(e!=b);return!0};f.Clipper.prototype.FixupFirstLefts1=function(b,d){for(var e=0,f=this.m_PolyOuts.length;e<f;e++){var k=this.m_PolyOuts[e];null!=k.Pts&&null!=k.FirstLeft&&this.ParseFirstLeft(k.FirstLeft)==b&&this.Poly2ContainsPoly1(k.Pts,d.Pts)&&(k.FirstLeft=d)}};f.Clipper.prototype.FixupFirstLefts2=function(b,
d){for(var e=0,f=this.m_PolyOuts,k=f.length,p=f[e];e<k;e++,p=f[e])p.FirstLeft==b&&(p.FirstLeft=d)};f.Clipper.ParseFirstLeft=function(b){for(;null!=b&&null==b.Pts;)b=b.FirstLeft;return b};f.Clipper.prototype.JoinCommonEdges=function(){for(var b=0,d=this.m_Joins.length;b<d;b++){var e=this.m_Joins[b],k=this.GetOutRec(e.OutPt1.Idx),n=this.GetOutRec(e.OutPt2.Idx);if(null!=k.Pts&&null!=n.Pts){var p;p=k==n?k:this.Param1RightOfParam2(k,n)?n:this.Param1RightOfParam2(n,k)?k:this.GetLowermostRec(k,n);if(this.JoinPoints(e,
k,n))if(k==n){k.Pts=e.OutPt1;k.BottomPt=null;n=this.CreateOutRec();n.Pts=e.OutPt2;this.UpdateOutPtIdxs(n);if(this.m_UsingPolyTree){p=0;for(var u=this.m_PolyOuts.length;p<u-1;p++){var C=this.m_PolyOuts[p];null!=C.Pts&&f.Clipper.ParseFirstLeft(C.FirstLeft)==k&&C.IsHole!=k.IsHole&&this.Poly2ContainsPoly1(C.Pts,e.OutPt2)&&(C.FirstLeft=n)}}this.Poly2ContainsPoly1(n.Pts,k.Pts)?(n.IsHole=!k.IsHole,n.FirstLeft=k,this.m_UsingPolyTree&&this.FixupFirstLefts2(n,k),(n.IsHole^this.ReverseSolution)==0<this.Area(n)&&
this.ReversePolyPtLinks(n.Pts)):this.Poly2ContainsPoly1(k.Pts,n.Pts)?(n.IsHole=k.IsHole,k.IsHole=!n.IsHole,n.FirstLeft=k.FirstLeft,k.FirstLeft=n,this.m_UsingPolyTree&&this.FixupFirstLefts2(k,n),(k.IsHole^this.ReverseSolution)==0<this.Area(k)&&this.ReversePolyPtLinks(k.Pts)):(n.IsHole=k.IsHole,n.FirstLeft=k.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(k,n))}else n.Pts=null,n.BottomPt=null,n.Idx=k.Idx,k.IsHole=p.IsHole,p==n&&(k.FirstLeft=n.FirstLeft),n.FirstLeft=k,this.m_UsingPolyTree&&this.FixupFirstLefts2(n,
k)}}};f.Clipper.prototype.UpdateOutPtIdxs=function(b){var d=b.Pts;do d.Idx=b.Idx,d=d.Prev;while(d!=b.Pts)};f.Clipper.prototype.DoSimplePolygons=function(){for(var b=0;b<this.m_PolyOuts.length;){var d=this.m_PolyOuts[b++],e=d.Pts;if(null!=e&&!d.IsOpen){do{for(var k=e.Next;k!=d.Pts;){if(f.IntPoint.op_Equality(e.Pt,k.Pt)&&k.Next!=e&&k.Prev!=e){var n=e.Prev,p=k.Prev;e.Prev=p;p.Next=e;k.Prev=n;n.Next=k;d.Pts=e;n=this.CreateOutRec();n.Pts=k;this.UpdateOutPtIdxs(n);this.Poly2ContainsPoly1(n.Pts,d.Pts)?(n.IsHole=
!d.IsHole,n.FirstLeft=d,this.m_UsingPolyTree&&this.FixupFirstLefts2(n,d)):this.Poly2ContainsPoly1(d.Pts,n.Pts)?(n.IsHole=d.IsHole,d.IsHole=!n.IsHole,n.FirstLeft=d.FirstLeft,d.FirstLeft=n,this.m_UsingPolyTree&&this.FixupFirstLefts2(d,n)):(n.IsHole=d.IsHole,n.FirstLeft=d.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(d,n));k=e}k=k.Next}e=e.Next}while(e!=d.Pts)}}};f.Clipper.Area=function(b){var d=b.length;if(3>d)return 0;for(var e=0,f=0,k=d-1;f<d;++f)e+=(b[k].X+b[f].X)*(b[k].Y-b[f].Y),k=f;return.5*
-e};f.Clipper.prototype.Area=function(b){var d=b.Pts;if(null==d)return 0;var e=0;do e+=(d.Prev.Pt.X+d.Pt.X)*(d.Prev.Pt.Y-d.Pt.Y),d=d.Next;while(d!=b.Pts);return.5*e};f.Clipper.SimplifyPolygon=function(b,d){var e=[],k=new f.Clipper(0);k.StrictlySimple=!0;k.AddPath(b,f.PolyType.ptSubject,!0);k.Execute(f.ClipType.ctUnion,e,d,d);return e};f.Clipper.SimplifyPolygons=function(b,d){"undefined"==typeof d&&(d=f.PolyFillType.pftEvenOdd);var e=[],k=new f.Clipper(0);k.StrictlySimple=!0;k.AddPaths(b,f.PolyType.ptSubject,
!0);k.Execute(f.ClipType.ctUnion,e,d,d);return e};f.Clipper.DistanceSqrd=function(b,d){var e=b.X-d.X,f=b.Y-d.Y;return e*e+f*f};f.Clipper.DistanceFromLineSqrd=function(b,d,e){var f=d.Y-e.Y;e=e.X-d.X;d=f*d.X+e*d.Y;d=f*b.X+e*b.Y-d;return d*d/(f*f+e*e)};f.Clipper.SlopesNearCollinear=function(b,d,e,k){return Math.abs(b.X-d.X)>Math.abs(b.Y-d.Y)?b.X>d.X==b.X<e.X?f.Clipper.DistanceFromLineSqrd(b,d,e)<k:d.X>b.X==d.X<e.X?f.Clipper.DistanceFromLineSqrd(d,b,e)<k:f.Clipper.DistanceFromLineSqrd(e,b,d)<k:b.Y>d.Y==
b.Y<e.Y?f.Clipper.DistanceFromLineSqrd(b,d,e)<k:d.Y>b.Y==d.Y<e.Y?f.Clipper.DistanceFromLineSqrd(d,b,e)<k:f.Clipper.DistanceFromLineSqrd(e,b,d)<k};f.Clipper.PointsAreClose=function(b,d,e){var f=b.X-d.X;b=b.Y-d.Y;return f*f+b*b<=e};f.Clipper.ExcludeOp=function(b){var d=b.Prev;d.Next=b.Next;b.Next.Prev=d;d.Idx=0;return d};f.Clipper.CleanPolygon=function(b,d){"undefined"==typeof d&&(d=1.415);var e=b.length;if(0==e)return[];for(var k=Array(e),n=0;n<e;++n)k[n]=new f.OutPt;for(n=0;n<e;++n)k[n].Pt=b[n],k[n].Next=
k[(n+1)%e],k[n].Next.Prev=k[n],k[n].Idx=0;n=d*d;for(k=k[0];0==k.Idx&&k.Next!=k.Prev;)f.Clipper.PointsAreClose(k.Pt,k.Prev.Pt,n)?(k=f.Clipper.ExcludeOp(k),e--):f.Clipper.PointsAreClose(k.Prev.Pt,k.Next.Pt,n)?(f.Clipper.ExcludeOp(k.Next),k=f.Clipper.ExcludeOp(k),e-=2):f.Clipper.SlopesNearCollinear(k.Prev.Pt,k.Pt,k.Next.Pt,n)?(k=f.Clipper.ExcludeOp(k),e--):(k.Idx=1,k=k.Next);3>e&&(e=0);for(var p=Array(e),n=0;n<e;++n)p[n]=new f.IntPoint(k.Pt),k=k.Next;return p};f.Clipper.CleanPolygons=function(b,d){for(var e=
Array(b.length),k=0,n=b.length;k<n;k++)e[k]=f.Clipper.CleanPolygon(b[k],d);return e};f.Clipper.Minkowski=function(b,d,e,k){k=k?1:0;var n=b.length,p=d.length,u=[];if(e)for(e=0;e<p;e++){for(var C=Array(n),E=0,F=b.length,H=b[E];E<F;E++,H=b[E])C[E]=new f.IntPoint(d[e].X+H.X,d[e].Y+H.Y);u.push(C)}else for(e=0;e<p;e++){C=Array(n);E=0;F=b.length;for(H=b[E];E<F;E++,H=b[E])C[E]=new f.IntPoint(d[e].X-H.X,d[e].Y-H.Y);u.push(C)}b=[];for(e=0;e<p-1+k;e++)for(E=0;E<n;E++)d=[],d.push(u[e%p][E%n]),d.push(u[(e+1)%
p][E%n]),d.push(u[(e+1)%p][(E+1)%n]),d.push(u[e%p][(E+1)%n]),f.Clipper.Orientation(d)||d.reverse(),b.push(d);return b};f.Clipper.MinkowskiSum=function(b,d,e){if(d[0]instanceof Array){u=d;d=new f.Paths;for(var k=new f.Clipper,n=0;n<u.length;++n){var p=f.Clipper.Minkowski(b,u[n],!0,e);k.AddPaths(p,f.PolyType.ptSubject,!0);e&&(p=f.Clipper.TranslatePath(u[n],b[0]),k.AddPath(p,f.PolyType.ptClip,!0))}k.Execute(f.ClipType.ctUnion,d,f.PolyFillType.pftNonZero,f.PolyFillType.pftNonZero);return d}var u=f.Clipper.Minkowski(b,
d,!0,e),k=new f.Clipper;k.AddPaths(u,f.PolyType.ptSubject,!0);k.Execute(f.ClipType.ctUnion,u,f.PolyFillType.pftNonZero,f.PolyFillType.pftNonZero);return u};f.Clipper.TranslatePath=function(b,d){for(var e=new f.Path,k=0;k<b.length;k++)e.push(new f.IntPoint(b[k].X+d.X,b[k].Y+d.Y));return e};f.Clipper.MinkowskiDiff=function(b,d){var e=f.Clipper.Minkowski(b,d,!1,!0),k=new f.Clipper;k.AddPaths(e,f.PolyType.ptSubject,!0);k.Execute(f.ClipType.ctUnion,e,f.PolyFillType.pftNonZero,f.PolyFillType.pftNonZero);
return e};f.Clipper.PolyTreeToPaths=function(b){var d=[];f.Clipper.AddPolyNodeToPaths(b,f.Clipper.NodeType.ntAny,d);return d};f.Clipper.AddPolyNodeToPaths=function(b,d,e){var k=!0;switch(d){case f.Clipper.NodeType.ntOpen:return;case f.Clipper.NodeType.ntClosed:k=!b.IsOpen}0<b.m_polygon.length&&k&&e.push(b.m_polygon);k=0;b=b.Childs();for(var n=b.length,p=b[k];k<n;k++,p=b[k])f.Clipper.AddPolyNodeToPaths(p,d,e)};f.Clipper.OpenPathsFromPolyTree=function(b){for(var d=new f.Paths,e=0,k=b.ChildCount();e<
k;e++)b.Childs()[e].IsOpen&&d.push(b.Childs()[e].m_polygon);return d};f.Clipper.ClosedPathsFromPolyTree=function(b){var d=new f.Paths;f.Clipper.AddPolyNodeToPaths(b,f.Clipper.NodeType.ntClosed,d);return d};Y(f.Clipper,f.ClipperBase);f.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2};f.ClipperOffset=function(b,d){"undefined"==typeof b&&(b=2);"undefined"==typeof d&&(d=f.ClipperOffset.def_arc_tolerance);this.m_destPolys=new f.Paths;this.m_srcPoly=new f.Path;this.m_destPoly=new f.Path;this.m_normals=[];
this.m_StepsPerRad=this.m_miterLim=this.m_cos=this.m_sin=this.m_sinA=this.m_delta=0;this.m_lowest=new f.IntPoint;this.m_polyNodes=new f.PolyNode;this.MiterLimit=b;this.ArcTolerance=d;this.m_lowest.X=-1};f.ClipperOffset.two_pi=6.28318530717959;f.ClipperOffset.def_arc_tolerance=.25;f.ClipperOffset.prototype.Clear=function(){f.Clear(this.m_polyNodes.Childs());this.m_lowest.X=-1};f.ClipperOffset.Round=f.Clipper.Round;f.ClipperOffset.prototype.AddPath=function(b,d,e){var k=b.length-1;if(!(0>k)){var n=
new f.PolyNode;n.m_jointype=d;n.m_endtype=e;if(e==f.EndType.etClosedLine||e==f.EndType.etClosedPolygon)for(;0<k&&f.IntPoint.op_Equality(b[0],b[k]);)k--;n.m_polygon.push(b[0]);var p=0;d=0;for(var u=1;u<=k;u++)f.IntPoint.op_Inequality(n.m_polygon[p],b[u])&&(p++,n.m_polygon.push(b[u]),b[u].Y>n.m_polygon[d].Y||b[u].Y==n.m_polygon[d].Y&&b[u].X<n.m_polygon[d].X)&&(d=p);if(!(e==f.EndType.etClosedPolygon&&2>p)&&(this.m_polyNodes.AddChild(n),e==f.EndType.etClosedPolygon))if(0>this.m_lowest.X)this.m_lowest=
new f.IntPoint(this.m_polyNodes.ChildCount()-1,d);else if(b=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y],n.m_polygon[d].Y>b.Y||n.m_polygon[d].Y==b.Y&&n.m_polygon[d].X<b.X)this.m_lowest=new f.IntPoint(this.m_polyNodes.ChildCount()-1,d)}};f.ClipperOffset.prototype.AddPaths=function(b,d,e){for(var f=0,k=b.length;f<k;f++)this.AddPath(b[f],d,e)};f.ClipperOffset.prototype.FixOrientations=function(){if(0<=this.m_lowest.X&&!f.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var b=
0;b<this.m_polyNodes.ChildCount();b++){var d=this.m_polyNodes.Childs()[b];(d.m_endtype==f.EndType.etClosedPolygon||d.m_endtype==f.EndType.etClosedLine&&f.Clipper.Orientation(d.m_polygon))&&d.m_polygon.reverse()}else for(b=0;b<this.m_polyNodes.ChildCount();b++)d=this.m_polyNodes.Childs()[b],d.m_endtype!=f.EndType.etClosedLine||f.Clipper.Orientation(d.m_polygon)||d.m_polygon.reverse()};f.ClipperOffset.GetUnitNormal=function(b,d){var e=d.X-b.X,k=d.Y-b.Y;if(0==e&&0==k)return new f.DoublePoint(0,0);var n=
1/Math.sqrt(e*e+k*k);return new f.DoublePoint(k*n,-(e*n))};f.ClipperOffset.prototype.DoOffset=function(b){this.m_destPolys=[];this.m_delta=b;if(f.ClipperBase.near_zero(b))for(var d=0;d<this.m_polyNodes.ChildCount();d++){var e=this.m_polyNodes.Childs()[d];e.m_endtype==f.EndType.etClosedPolygon&&this.m_destPolys.push(e.m_polygon)}else{this.m_miterLim=2<this.MiterLimit?2/(this.MiterLimit*this.MiterLimit):.5;var k=3.14159265358979/Math.acos(1-(0>=this.ArcTolerance?f.ClipperOffset.def_arc_tolerance:this.ArcTolerance>
Math.abs(b)*f.ClipperOffset.def_arc_tolerance?Math.abs(b)*f.ClipperOffset.def_arc_tolerance:this.ArcTolerance)/Math.abs(b));this.m_sin=Math.sin(f.ClipperOffset.two_pi/k);this.m_cos=Math.cos(f.ClipperOffset.two_pi/k);this.m_StepsPerRad=k/f.ClipperOffset.two_pi;0>b&&(this.m_sin=-this.m_sin);for(d=0;d<this.m_polyNodes.ChildCount();d++){e=this.m_polyNodes.Childs()[d];this.m_srcPoly=e.m_polygon;var n=this.m_srcPoly.length;if(!(0==n||0>=b&&(3>n||e.m_endtype!=f.EndType.etClosedPolygon))){this.m_destPoly=
[];if(1==n)if(e.m_jointype==f.JoinType.jtRound)for(var e=1,n=0,p=1;p<=k;p++){this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[0].X+e*b),f.ClipperOffset.Round(this.m_srcPoly[0].Y+n*b)));var u=e,e=e*this.m_cos-this.m_sin*n,n=u*this.m_sin+n*this.m_cos}else for(n=e=-1,p=0;4>p;++p)this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[0].X+e*b),f.ClipperOffset.Round(this.m_srcPoly[0].Y+n*b))),0>e?e=1:0>n?n=1:e=-1;else{for(p=this.m_normals.length=0;p<n-1;p++)this.m_normals.push(f.ClipperOffset.GetUnitNormal(this.m_srcPoly[p],
this.m_srcPoly[p+1]));e.m_endtype==f.EndType.etClosedLine||e.m_endtype==f.EndType.etClosedPolygon?this.m_normals.push(f.ClipperOffset.GetUnitNormal(this.m_srcPoly[n-1],this.m_srcPoly[0])):this.m_normals.push(new f.DoublePoint(this.m_normals[n-2]));if(e.m_endtype==f.EndType.etClosedPolygon)for(u=n-1,p=0;p<n;p++)u=this.OffsetPoint(p,u,e.m_jointype);else if(e.m_endtype==f.EndType.etClosedLine){u=n-1;for(p=0;p<n;p++)u=this.OffsetPoint(p,u,e.m_jointype);this.m_destPolys.push(this.m_destPoly);this.m_destPoly=
[];u=this.m_normals[n-1];for(p=n-1;0<p;p--)this.m_normals[p]=new f.DoublePoint(-this.m_normals[p-1].X,-this.m_normals[p-1].Y);this.m_normals[0]=new f.DoublePoint(-u.X,-u.Y);u=0;for(p=n-1;0<=p;p--)u=this.OffsetPoint(p,u,e.m_jointype)}else{u=0;for(p=1;p<n-1;++p)u=this.OffsetPoint(p,u,e.m_jointype);e.m_endtype==f.EndType.etOpenButt?(p=n-1,u=new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[p].X+this.m_normals[p].X*b),f.ClipperOffset.Round(this.m_srcPoly[p].Y+this.m_normals[p].Y*b)),this.m_destPoly.push(u),
u=new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[p].X-this.m_normals[p].X*b),f.ClipperOffset.Round(this.m_srcPoly[p].Y-this.m_normals[p].Y*b)),this.m_destPoly.push(u)):(p=n-1,u=n-2,this.m_sinA=0,this.m_normals[p]=new f.DoublePoint(-this.m_normals[p].X,-this.m_normals[p].Y),e.m_endtype==f.EndType.etOpenSquare?this.DoSquare(p,u):this.DoRound(p,u));for(p=n-1;0<p;p--)this.m_normals[p]=new f.DoublePoint(-this.m_normals[p-1].X,-this.m_normals[p-1].Y);this.m_normals[0]=new f.DoublePoint(-this.m_normals[1].X,
-this.m_normals[1].Y);u=n-1;for(p=u-1;0<p;--p)u=this.OffsetPoint(p,u,e.m_jointype);e.m_endtype==f.EndType.etOpenButt?(u=new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*b),f.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*b)),this.m_destPoly.push(u),u=new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*b),f.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*b)),this.m_destPoly.push(u)):(this.m_sinA=0,e.m_endtype==f.EndType.etOpenSquare?
this.DoSquare(0,1):this.DoRound(0,1))}}this.m_destPolys.push(this.m_destPoly)}}}};f.ClipperOffset.prototype.Execute=function(){var b=arguments;if(b[0]instanceof f.PolyTree)if(d=b[0],e=b[1],d.Clear(),this.FixOrientations(),this.DoOffset(e),b=new f.Clipper(0),b.AddPaths(this.m_destPolys,f.PolyType.ptSubject,!0),0<e)b.Execute(f.ClipType.ctUnion,d,f.PolyFillType.pftPositive,f.PolyFillType.pftPositive);else if(e=f.Clipper.GetBounds(this.m_destPolys),k=new f.Path,k.push(new f.IntPoint(e.left-10,e.bottom+
10)),k.push(new f.IntPoint(e.right+10,e.bottom+10)),k.push(new f.IntPoint(e.right+10,e.top-10)),k.push(new f.IntPoint(e.left-10,e.top-10)),b.AddPath(k,f.PolyType.ptSubject,!0),b.ReverseSolution=!0,b.Execute(f.ClipType.ctUnion,d,f.PolyFillType.pftNegative,f.PolyFillType.pftNegative),1==d.ChildCount()&&0<d.Childs()[0].ChildCount())for(b=d.Childs()[0],d.Childs()[0]=b.Childs()[0],d.Childs()[0].m_Parent=d,e=1;e<b.ChildCount();e++)d.AddChild(b.Childs()[e]);else d.Clear();else{var d=b[0],e=b[1];f.Clear(d);
this.FixOrientations();this.DoOffset(e);b=new f.Clipper(0);b.AddPaths(this.m_destPolys,f.PolyType.ptSubject,!0);if(0<e)b.Execute(f.ClipType.ctUnion,d,f.PolyFillType.pftPositive,f.PolyFillType.pftPositive);else{var e=f.Clipper.GetBounds(this.m_destPolys),k=new f.Path;k.push(new f.IntPoint(e.left-10,e.bottom+10));k.push(new f.IntPoint(e.right+10,e.bottom+10));k.push(new f.IntPoint(e.right+10,e.top-10));k.push(new f.IntPoint(e.left-10,e.top-10));b.AddPath(k,f.PolyType.ptSubject,!0);b.ReverseSolution=
!0;b.Execute(f.ClipType.ctUnion,d,f.PolyFillType.pftNegative,f.PolyFillType.pftNegative);0<d.length&&d.splice(0,1)}}};f.ClipperOffset.prototype.OffsetPoint=function(b,d,e){this.m_sinA=this.m_normals[d].X*this.m_normals[b].Y-this.m_normals[b].X*this.m_normals[d].Y;if(1>Math.abs(this.m_sinA*this.m_delta)){if(0<this.m_normals[d].X*this.m_normals[b].X+this.m_normals[b].Y*this.m_normals[d].Y)return this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_normals[d].X*this.m_delta),
f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_normals[d].Y*this.m_delta))),d}else 1<this.m_sinA?this.m_sinA=1:-1>this.m_sinA&&(this.m_sinA=-1);if(0>this.m_sinA*this.m_delta)this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_normals[d].X*this.m_delta),f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_normals[d].Y*this.m_delta))),this.m_destPoly.push(new f.IntPoint(this.m_srcPoly[b])),this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_normals[b].X*
this.m_delta),f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_normals[b].Y*this.m_delta)));else switch(e){case f.JoinType.jtMiter:e=1+(this.m_normals[b].X*this.m_normals[d].X+this.m_normals[b].Y*this.m_normals[d].Y);e>=this.m_miterLim?this.DoMiter(b,d,e):this.DoSquare(b,d);break;case f.JoinType.jtSquare:this.DoSquare(b,d);break;case f.JoinType.jtRound:this.DoRound(b,d)}return b};f.ClipperOffset.prototype.DoSquare=function(b,d){var e=Math.tan(Math.atan2(this.m_sinA,this.m_normals[d].X*this.m_normals[b].X+
this.m_normals[d].Y*this.m_normals[b].Y)/4);this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_delta*(this.m_normals[d].X-this.m_normals[d].Y*e)),f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_delta*(this.m_normals[d].Y+this.m_normals[d].X*e))));this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_delta*(this.m_normals[b].X+this.m_normals[b].Y*e)),f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_delta*(this.m_normals[b].Y-this.m_normals[b].X*
e))))};f.ClipperOffset.prototype.DoMiter=function(b,d,e){e=this.m_delta/e;this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+(this.m_normals[d].X+this.m_normals[b].X)*e),f.ClipperOffset.Round(this.m_srcPoly[b].Y+(this.m_normals[d].Y+this.m_normals[b].Y)*e)))};f.ClipperOffset.prototype.DoRound=function(b,d){for(var e=Math.max(f.Cast_Int32(f.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(Math.atan2(this.m_sinA,this.m_normals[d].X*this.m_normals[b].X+this.m_normals[d].Y*this.m_normals[b].Y)))),
1),k=this.m_normals[d].X,n=this.m_normals[d].Y,p,u=0;u<e;++u)this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+k*this.m_delta),f.ClipperOffset.Round(this.m_srcPoly[b].Y+n*this.m_delta))),p=k,k=k*this.m_cos-this.m_sin*n,n=p*this.m_sin+n*this.m_cos;this.m_destPoly.push(new f.IntPoint(f.ClipperOffset.Round(this.m_srcPoly[b].X+this.m_normals[b].X*this.m_delta),f.ClipperOffset.Round(this.m_srcPoly[b].Y+this.m_normals[b].Y*this.m_delta)))};f.Error=function(b){try{throw Error(b);
}catch(d){alert(d.message)}};f.JS={};f.JS.AreaOfPolygon=function(b,d){d||(d=1);return f.Clipper.Area(b)/(d*d)};f.JS.AreaOfPolygons=function(b,d){d||(d=1);for(var e=0,k=0;k<b.length;k++)e+=f.Clipper.Area(b[k]);return e/(d*d)};f.JS.BoundsOfPath=function(b,d){return f.JS.BoundsOfPaths([b],d)};f.JS.BoundsOfPaths=function(b,d){d||(d=1);var e=f.Clipper.GetBounds(b);e.left/=d;e.bottom/=d;e.right/=d;e.top/=d;return e};f.JS.Clean=function(b,d){if(!(b instanceof Array))return[];var e=b[0]instanceof Array;b=
f.JS.Clone(b);if("number"!=typeof d||null===d)return f.Error("Delta is not a number in Clean()."),b;if(0===b.length||1==b.length&&0===b[0].length||0>d)return b;e||(b=[b]);for(var k=b.length,n,p,u,E,F,H,N,M=[],ia=0;ia<k;ia++)if(p=b[ia],n=p.length,0!==n)if(3>n)u=p,M.push(u);else{u=p;E=d*d;F=p[0];for(N=H=1;N<n;N++)(p[N].X-F.X)*(p[N].X-F.X)+(p[N].Y-F.Y)*(p[N].Y-F.Y)<=E||(u[H]=p[N],F=p[N],H++);F=p[H-1];(p[0].X-F.X)*(p[0].X-F.X)+(p[0].Y-F.Y)*(p[0].Y-F.Y)<=E&&H--;H<n&&u.splice(H,n-H);u.length&&M.push(u)}!e&&
M.length?M=M[0]:e||0!==M.length?e&&0===M.length&&(M=[[]]):M=[];return M};f.JS.Clone=function(b){if(!(b instanceof Array)||0===b.length)return[];if(1==b.length&&0===b[0].length)return[[]];var d=b[0]instanceof Array;d||(b=[b]);var e=b.length,f,k,p,u,E=Array(e);for(k=0;k<e;k++){f=b[k].length;u=Array(f);for(p=0;p<f;p++)u[p]={X:b[k][p].X,Y:b[k][p].Y};E[k]=u}d||(E=E[0]);return E};f.JS.Lighten=function(b,d){if(!(b instanceof Array))return[];if("number"!=typeof d||null===d)return f.Error("Tolerance is not a number in Lighten()."),
f.JS.Clone(b);if(0===b.length||1==b.length&&0===b[0].length||0>d)return f.JS.Clone(b);b[0]instanceof Array||(b=[b]);var e,k,n,p,u,E,F,H,N,M,ia,S,V,Y,ba,fa=b.length,ha=d*d,ea=[];for(e=0;e<fa;e++)if(n=b[e],E=n.length,0!=E){for(p=0;1E6>p;p++){u=[];E=n.length;n[E-1].X!=n[0].X||n[E-1].Y!=n[0].Y?(ia=1,n.push({X:n[0].X,Y:n[0].Y}),E=n.length):ia=0;M=[];for(k=0;k<E-2;k++){F=n[k];N=n[k+1];H=n[k+2];Y=F.X;ba=F.Y;F=H.X-Y;S=H.Y-ba;if(0!==F||0!==S)V=((N.X-Y)*F+(N.Y-ba)*S)/(F*F+S*S),1<V?(Y=H.X,ba=H.Y):0<V&&(Y+=F*
V,ba+=S*V);F=N.X-Y;S=N.Y-ba;H=F*F+S*S;H<=ha&&(M[k+1]=1,k++)}u.push({X:n[0].X,Y:n[0].Y});for(k=1;k<E-1;k++)M[k]||u.push({X:n[k].X,Y:n[k].Y});u.push({X:n[E-1].X,Y:n[E-1].Y});ia&&n.pop();if(M.length)n=u;else break}E=u.length;u[E-1].X==u[0].X&&u[E-1].Y==u[0].Y&&u.pop();2<u.length&&ea.push(u)}b[0]instanceof Array||(ea=ea[0]);"undefined"==typeof ea&&(ea=[[]]);return ea};f.JS.PerimeterOfPath=function(b,d,e){if("undefined"==typeof b)return 0;var f=Math.sqrt,k=0,p,u,E,F,H=b.length;if(2>H)return 0;for(d&&(b[H]=
b[0],H++);--H;)p=b[H],E=p.X,p=p.Y,u=b[H-1],F=u.X,u=u.Y,k+=f((E-F)*(E-F)+(p-u)*(p-u));d&&b.pop();return k/e};f.JS.PerimeterOfPaths=function(b,d,e){e||(e=1);for(var k=0,n=0;n<b.length;n++)k+=f.JS.PerimeterOfPath(b[n],d,e);return k};f.JS.ScaleDownPath=function(b,d){var e,f;d||(d=1);for(e=b.length;e--;)f=b[e],f.X/=d,f.Y/=d};f.JS.ScaleDownPaths=function(b,d){var e,f,k;d||(d=1);for(e=b.length;e--;)for(f=b[e].length;f--;)k=b[e][f],k.X/=d,k.Y/=d};f.JS.ScaleUpPath=function(b,d){var e,f,k=Math.round;d||(d=
1);for(e=b.length;e--;)f=b[e],f.X=k(f.X*d),f.Y=k(f.Y*d)};f.JS.ScaleUpPaths=function(b,d){var e,f,k,p=Math.round;d||(d=1);for(e=b.length;e--;)for(f=b[e].length;f--;)k=b[e][f],k.X=p(k.X*d),k.Y=p(k.Y*d)};f.ExPolygons=function(){return[]};f.ExPolygon=function(){this.holes=this.outer=null};f.JS.AddOuterPolyNodeToExPolygons=function(b,d){var e=new f.ExPolygon;e.outer=b.Contour();var k=b.Childs(),n=k.length;e.holes=Array(n);var p,u,E,F,H;for(u=0;u<n;u++)for(p=k[u],e.holes[u]=p.Contour(),E=0,F=p.Childs(),
H=F.length;E<H;E++)p=F[E],f.JS.AddOuterPolyNodeToExPolygons(p,d);d.push(e)};f.JS.ExPolygonsToPaths=function(b){var d,e,k,n,p=new f.Paths;d=0;for(k=b.length;d<k;d++)for(p.push(b[d].outer),e=0,n=b[d].holes.length;e<n;e++)p.push(b[d].holes[e]);return p};f.JS.PolyTreeToExPolygons=function(b){var d=new f.ExPolygons,e,k,n;e=0;k=b.Childs();for(n=k.length;e<n;e++)b=k[e],f.JS.AddOuterPolyNodeToExPolygons(b,d);return d}})();
var CindyJS=function(){function p(k){if(0===ha)return console.error("Waiting for "+k+" after we finished waiting."),function(){};0>ha&&(ha=0);++ha;return function(){--ha;0>ha&&console.error("Wait count mismatch: "+k);if(0===ha)for(var p=0,F=Ga.length;p<F;)Ga[p++].startup()}}function F(k){var p=F.newInstance(k);0>=ha?p.startup():!1!==k.autostart&&Ga.push(p);return p}var ha=-1,Ga=[];"undefined"===typeof document||"undefined"===typeof window||"undefined"===typeof document.addEventListener||"undefined"!==
typeof window.cindyDontWait&&!0===window.cindyDontWait||document.addEventListener("DOMContentLoaded",p("DOMContentLoaded"));var pa=null,Ha=null,ea={};F.getBaseDir=function(){if(null!==pa)return pa;for(var k=document.getElementsByTagName("script"),p=0;p<k.length;++p){var F=k[p],V=F.src;if(V){var S=/Cindy\.js$/.exec(V);if(S)return pa=V.substr(0,S.index),console.log("Will load extensions from "+pa),Ha=F,pa}}console.error("Could not find <script> tag for Cindy.js");return pa=Ha=!1};F.addNewScript=function(k,
p){p||console.error.bind(console);var N=F.getBaseDir();if(!1===N)return!1;var V=document.createElement("script");V.src=N+k;var N=Ha.nextSibling,S=Ha.parentElement;N?S.insertBefore(V,N):S.appendChild(V);return V};F.loadScript=function(k,p,N,V){for(var S=String(k).split("."),fa=window;S.length&&"object"===typeof fa&&null!==fa;)fa=fa[S.shift()];if(fa&&!S.length)return N(),!0;V||(V=console.error.bind(console));S=ea[k];if(!S){S=F.addNewScript(p,V);if(!1===S)return V("Can't load additional components."),
!1;ea[k]=S}S.addEventListener("load",N);S.addEventListener("error",V);return null};F._autoLoadingPlugin={};F.autoLoadPlugin=function(k,p,N){if(F._pluginRegistry[k])return N(),!0;var V=F._autoLoadingPlugin[k];if(!V){p||(p=k+"-plugin.js");V=F._autoLoadingPlugin[k]=[];k=F.addNewScript(p);if(!1===k)return!1;k.addEventListener("error",console.error.bind(console))}V.push(N);return null};var k={ctype:"undefined"};F.waitFor=p;F._pluginRegistry={};F.instances=[];F.registerPlugin=function(k,p,N){if(1!==k)return console.error("Plugin API version "+
k+" not supported"),!1;F._pluginRegistry[p]=N;(F._autoLoadingPlugin[p]||[]).forEach(function(k){k()})};var Qa=0;F.dumpState=function(k){k=F.instances[k||0].saveState();console.log(JSON.stringify(k))};F.debugState=function(k){F.instances.map(function(k){var p=k.config,p=JSON.parse(JSON.stringify(p)),E=k.saveState();console.log(JSON.stringify(E));for(var F in E)p[F]=E[F];k.shutdown();return p}).forEach(function(k){F(k)})};F.newInstance=function(p){function F(){na.width=ca=na.clientWidth;na.height=da=
na.clientHeight;A.setTransform(1,0,0,1,0,0);y.setMat(25,0,0,25,250.5,250.5);if(Db)for(var a=0;a<Db.length;a++){var g=Db[a],c=Object.keys(g)[0];"scale"===c&&(Tb=g.scale,y[c](g.scale));if("translate"===c)y[c](g.translate[0],g.translate[1]);"scaleAndOrigin"===c&&(Tb=g[c][0]/25,y[c].apply(null,g[c]));"visibleRect"===c&&(y[c].apply(null,g[c]),Tb=y.drawingstate.initialmatrix.a/25)}y.createnewbackup();y.greset();a=1;"undefined"!==typeof window&&window.devicePixelRatio&&(a=window.devicePixelRatio);g=A.webkitBackingStorePixelRatio||
A.mozBackingStorePixelRatio||A.msBackingStorePixelRatio||A.oBackingStorePixelRatio||A.backingStorePixelRatio||1;a!==g&&(a/=g,na.width=ca*a,na.height=da*a,A.scale(a,a))}function N(a){var g;if("canvas"!==a.tagName.toLowerCase())for(g=a,na=document.createElement("canvas");g.firstChild;)g.removeChild(g.firstChild);else{na=a;g=document.createElement("div");var c=null,q=null;Array.prototype.slice.call(na.attributes).forEach(function(a){"width"===a.name?c=a.value:"height"===a.name?q=a.value:g.setAttributeNodeNS(na.removeAttributeNode(a))});
null===c||g.style.width||(g.style.width=c+"px");null===q||g.style.height||(g.style.height=q+"px");na.parentNode.replaceChild(g,na)}g.classList.add("CindyJS-widget");a=na.style;a.position="absolute";a.border="none";a.margin=a.padding=a.left=a.top="0px";a.width=a.height="100%";a="static";window.getComputedStyle&&(a=window.getComputedStyle(g).getPropertyValue("position"),a=String(a||"static"));"static"===a&&(g.style.position="relative");g.appendChild(na);return na}function V(){var a=p.cinderella;if(!a||
!a.version)return!1;for(var g=0;g<arguments.length;++g){var c=a.version[g],q=arguments[g];if(c!==q)return typeof c===typeof q&&c<q}return!1}function S(){kc=!0;if(0===Ub){if(p.exclusive)for(b=va.instances.length;0<b;)va.instances[--b].shutdown();void 0!==p.csconsole&&(wa=p.csconsole);wa=null===wa?new ua:!0===wa?new Cb:"string"===typeof wa?new gb(wa):"object"===typeof wa&&"function"===typeof wa.appendChild?new gb(wa):new ua;ra=[100,100];var a=null;Db=p.transform;if(p.ports&&0<p.ports.length){b=p.ports[0];
(a=b.element)||(a=document.getElementById(b.id));var a=N(a),g=a.parentNode.style;"window"===b.fill?(g.width="100vw",g.height="100vh"):"parent"===b.fill?(g.width="100%",g.height="100%"):b.width&&b.height&&(g.width=b.width+"px",g.height=b.height+"px");b.background&&(a.style.backgroundColor=b.background);void 0!==b.transform&&(Db=b.transform);Ia(b.grid)&&0<b.grid&&(za=b.grid);Ia(b.tgrid)&&0<b.tgrid&&(lc=b.tgrid);b.snap&&(Eb=!0);b.axes&&(Fb=!0)}a||(a=p.canvas,a||"undefined"===typeof document||(a=document.getElementById(p.canvasname))&&
(a=N(a)));a&&(na=a,A=a.getContext("2d"),F(),A.setLineDash||(A.setLineDash=function(){}),(p.animation?p.animation.controls:p.animcontrols)&&ea(p),p.animation&&Ia(p.animation.speed)&&(void 0===p.animation.accuracy&&V(2,9,1875)?ha(.5*p.animation.speed):ha(p.animation.speed)),p.animation&&Ia(p.animation.accuracy)&&(Vb=p.animation.accuracy));p.statusbar&&(mc="string"===typeof p.statusbar?document.getElementById(p.statusbar):p.statusbar);var c=p.scripts,q=null;"string"===typeof c&&c.search(/\*/)&&(q=c);
"object"!==typeof c&&(c=null);"move keydown keyup keytyped keytype mousedown mouseup mousedrag mousemove mouseclick init tick draw simulationstep simulationstart simulationstop ondrop".split(" ").forEach(function(a){var g;if(null!==c&&c[a])g=c[a];else{g=a+"script";if(p[g])g=document.getElementById(p[g]);else if(q){if(g=document.getElementById(q.replace(/\*/,a)),!g)return}else return;g=g.text}g=Ua(g,!1);"error"===g.ctype?console.error("Error compiling "+a+" script: "+g.message):R[a]=Td(g,a)});V(2,
9,1888)&&!R.keydown&&(R.keydown=R.keytyped,R.keytyped=R.keytype,R.keytype=void 0);Ia(p.grid)&&0<p.grid&&(za=p.grid);p.snap&&(Eb=!0);v={};var b=0;bb={};p.geometry||(p.geometry=[]);Ud(p.geometry);p.behavior||(p.behavior=[]);"function"===typeof nc&&nc(p.behavior);for(var d in p.images)b=fa(p.images[d],!1),b!==k&&(bb[d]=b);for(var h in p.videos)d=fa(p.videos[h],!0),d!==k&&(bb[h]=d);sa.canvas=a;if(p.oninit)p.oninit(sa);va.instances.push(sa);p.use&&p.use.forEach(function(a){t.use$1([w.wrap(a)],{})});hb.convexhull3d$1&&
pa("QuickHull3D","QuickHull3D.js");(hb.colorplot$1||hb.colorplot$2||hb.colorplot$3||hb.colorplot$4)&&pa("CindyGL","CindyGL.js");(hb.playtone$1||hb.playmelody$1)&&pa("midi","midi-plugin.js");Y()}}function fa(a,g){var c;"string"===typeof a?(g?(c=document.createElement("video"),c.preload="auto",c.loop=!0,c.setAttribute("playsinline",""),enableInlineVideo(c)):c=new Image,c.src=a):c=a;if(!c.tagName)return console.error("Not a valid image element",c),k;var q={img:c,width:NaN,height:NaN,ready:!0,live:!1,
generation:0,whenReady:f},b=c.tagName.toLowerCase(),d=[];if("img"===b)c.complete?(q.width=c.width,q.height=c.height):(q.ready=!1,c.addEventListener("load",function(){q.width=c.width;q.height=c.height;q.ready=!0;q.whenReady=f;d.forEach(f);e()}),q.whenReady=d.push.bind(d));else if("video"===b)q.live=!0,c.readyState>=c.HAVE_METADATA?(q.width=c.videoWidth,q.height=c.videoHeight):(q.ready=!1,c.addEventListener("loadedmetadata",function(){q.width=c.videoWidth;q.height=c.videoHeight;q.ready=!0;q.whenReady=
f;d.forEach(f);e()}),q.whenReady=d.push.bind(d));else if("canvas"===b)q.width=c.width,q.height=c.height;else return console.error("Not a valid image element",b,c),k;return{ctype:"image",value:q}}function ea(a){function g(a,c){var g=document.createElement("button"),q=document.createElement("img");g.appendChild(q);m.appendChild(g);Gb(q,a);g.addEventListener("click",c);Va[a]=function(a){a?g.classList.add("CindyJS-active"):g.classList.remove("CindyJS-active")}}function c(a){if(k){var c=e.getBoundingClientRect();
ha(h*(a.clientX-c.left-e.clientLeft+.5)/c.width+b)}}var q=document.createElement("div");q.className="CindyJS-animcontrols";na.parentNode.appendChild(q);var b=0,d=1,h=1;a.animation&&a.animation.speedRange&&Ia(a.animation.speedRange[0])&&Ia(a.animation.speedRange[1])&&(b=a.animation.speedRange[0],d=a.animation.speedRange[1],h=d-b);var e=document.createElement("div");e.className="CindyJS-animspeed";q.appendChild(e);var f=document.createElement("div");e.appendChild(f);H(e,"mousedown",function(a){k=!0;
c(a)});H(e,"mousemove",c);H(na.parentNode,"mouseup",function(a){k=!1},!0);var m=document.createElement("div");m.className="CindyJS-animbuttons";q.appendChild(m);g("play",M);g("pause",Ga);g("stop",Ha);Va.stop(!0);oc=function(a){a=(a-b)/h;a=Math.max(0,Math.min(1,a));a=.1*Math.round(1E3*a);f.style.width=a+"%"};var k=!1}function ha(a){Vc=a;oc&&oc(a)}function f(a){return a()}function pa(a,g,c){var q=null;p.plugins&&(q=p.plugins[a]);q||(q=va._pluginRegistry[a]);q?t.use$1([w.wrap(a)],{}):(++Wc,va.autoLoadPlugin(a,
g,function(){t.use$1([w.wrap(a)],{});Y(c)}))}function Y(a){0===--Wc&&(a?e():(z(R.init),(p.animation||p).autoplay&&M(),sa.canvas&&ic(sa.canvas,p)))}function ba(){null!==Hb&&(qa.set(Hb.state),Object.keys(Hb.speeds).forEach(function(a){var g=v.csnames[a];"undefined"!==typeof g.behavior&&(a=Hb.speeds[a],g.behavior.vx=a[0],g.behavior.vy=a[1],g.behavior.vz=a[2],g.behavior.fx=0,g.behavior.fy=0,g.behavior.fz=0)}),Vd())}function M(){if(!cb){if(Xb){var a=ib.backup;a.set(qa);for(var g={},c=0;c<v.points.length;c++){var q=
v.points[c];"undefined"!==typeof q.behavior&&(g[q.name]=[q.behavior.vx,q.behavior.vy,q.behavior.vz])}Hb={state:a,speeds:g};Ib=0;Xb=!1;Va.stop(!1)}else Va.pause(!1);pc=Date.now();Va.play(!0);"function"===typeof nc&&qc&&Wd();cb=!0;z(R.simulationstart);e()}}function Ga(){cb&&(Va.play(!1),Va.pause(!0),cb=!1)}function Ha(){Xb||(cb?(z(R.simulationstop),cb=!1,Va.play(!1)):Va.pause(!1),Va.stop(!0),Xb=!0,ba())}function Ta(){if(!Yb){Yb=!0;for(var a=va.instances.length;0<a;)if(va.instances[--a]===sa){va.instances.splice(a,
1);break}for(a=jb.length;0<a;)try{jb[--a]()}catch(g){console.error(g)}}}function fb(a){this["in"]=function(a,c){console.log(a);c?this.append(this.createTextNode("span","blue",a)):this.append(this.createTextNode("p","blue",a))};this.out=function(a,c){console.log(a);c?this.append(this.createTextNode("span","red",a)):this.append(this.createTextNode("p","red",a))};this.err=function(a,c){console.log(a);c?this.append(this.createTextNode("span","red",a)):this.append(this.createTextNode("p","red",a))};this.createTextNode=
function(a,c,q){return"undefined"!==typeof document?(a=document.createElement(a),a.appendChild(document.createTextNode(q)),a.style.color=c,a):q+"\n"}}function Cb(){var a=this,g,c=document.createElement("div"),q;c.innerHTML='<div id="console" style="border-top: 1px solid #333333; bottom: 0px; position: absolute; width: 100%;"><div id="log" style="height: 150px; overflow-y: auto;"></div><input id="cmd" type="text" style="box-sizing: border-box; height: 30px; width: 100%;"></div>';document.body.appendChild(c);
g=document.getElementById("cmd");q=document.getElementById("log");g.onkeydown=function(c){13===c.keyCode&&""!==g.value&&(a["in"](g.value),c=t.parse$1([w.wrap(g.value)],[]),c=z(c),console.log(Z(c)),"undefined"!==c.ctype&&wa.out(Z(c)),g.value="",q.scrollTop=q.scrollHeight)};this.append=function(a){q.appendChild(a)};this.clear=function(){q.innerHTML=""}}function gb(a){var g=a;"string"===typeof a&&(g=document.getElementById(a));this.append=function(a){g.appendChild(a)};this.clear=function(){g.innerHTML=
""}}function ua(){this.append=function(a){};this.clear=function(){}}function H(a,g,c,q){void 0===q&&(q=!1);jb.push(function(){a.removeEventListener(g,c,q)});a.addEventListener(g,c,q)}function ic(a,g){function c(c){var g=a.getBoundingClientRect();c=y.to(c.clientX-g.left-a.clientLeft+.5,c.clientY-g.top-a.clientTop+.5);aa.prevx=aa.x;aa.prevy=aa.y;aa.x=c[0];aa.y=c[1];ra[0]=aa.x;ra[1]=aa.y;e()}function q(a){for(var c=a.changedTouches,g=!1,q=0;q<c.length;q++)c[q].identifier===W&&(g=!0);g&&(W=-1,aa.down=
!1,ja=void 0,z(R.mouseup),wb("mouseup"),e(),a.preventDefault())}var b=null;"undefined"!==typeof MutationObserver&&(b=MutationObserver);b||"undefined"===typeof WebKitMutationObserver||(b=WebKitMutationObserver);b?(b=new b(function(c){document.body.contains(a)||Ta()}),b.observe(document.documentElement,{childList:!0,subtree:!0}),jb.push(function(){b.disconnect()})):(H(a,"DOMNodeRemovedFromDocument",Ta),H(a,"DOMNodeRemoved",Ta));if(!0===g.keylistener)H(document,"keydown",function(a){I(a,R.keydown);return!1}),
H(document,"keyup",function(a){I(a,R.keyup);return!1}),H(document,"keypress",function(a){I(a,R.keytyped);return!1});else if(R.keydown||R.keyup||R.keytyped)a.setAttribute("tabindex","0"),H(a,"mousedown",function(){a.focus()}),H(a,"keydown",function(a){9!==a.keyCode&&(I(a,R.keydown),R.keytyped||a.preventDefault())}),H(a,"keyup",function(a){I(a,R.keyup);a.preventDefault()}),H(a,"keypress",function(a){9!==a.keyCode&&(I(a,R.keytyped),a.preventDefault())});H(a,"mousedown",function(a){aa.button=a.which;
c(a);z(R.mousedown);wb("mousedown");aa.down=!0;a.preventDefault()});H(a,"mouseup",function(a){aa.down=!1;ja=void 0;z(R.mouseup);wb("mouseup");e();a.preventDefault()});H(a,"mousemove",function(a){c(a);aa.down?z(R.mousedrag):z(R.mousemove);wb("mousemove");a.preventDefault()});H(a,"click",function(a){c(a);z(R.mouseclick);a.preventDefault()});H(a,"dragenter",function(a){a.preventDefault()});H(a,"dragover",function(a){a.preventDefault()});H(a,"drop",function(c){function g(a,c){function h(){e.readyState===
XMLHttpRequest.DONE&&(200!==e.status?(console.error("GET request for "+a+" failed: "+(e.responseText||"(no error message)")),d(c,k)):b(c,e.responseText))}var W=a.replace(/[?#][^]*/,""),W=W.replace(/[^]*\/([^\/])/,"$1");f[c]={type:"",name:W};var e=new XMLHttpRequest;e.onreadystatechange=function(){if(e.readyState===XMLHttpRequest.DONE)if(200!==e.status)console.error("HEAD request for "+a+" failed: "+(e.responseText||"(no error message)")),d(c,k);else{var g=e.getResponseHeader("Content-Type");f[c].type=
g;/^image\//.test(g)?oa(c,a):q(g)?(e=new XMLHttpRequest,e.onreadystatechange=h,e.open("GET",a),e.send()):d(c,k)}};e.open("HEAD",a);e.send()}function q(a){a=a.replace(/;[^]*/,"");return/^text\//.test(a)?1:"application/json"===a?2:0}function b(a,c){switch(q(f[a].type)){case 1:d(a,w.string(c));break;case 2:var g,oa;try{g=JSON.parse(c),oa=w.wrapJSON(g)}catch(h){console.error(h),oa=k}d(a,oa);break;default:d(a,k)}}function oa(a,c){var g=new Image,q=!1;g.onload=function(){q||(q=!0,d(a,fa(g,!1)))};g.onerror=
function(c){q||(q=!0,console.error(c),d(a,k))};g.src=c}function d(a,c,g){m[a]=h.turnIntoCSList([c,w.string(g||c.ctype),w.string(f[a].type),w.string(f[a].name)]);0===--l&&(a=p,rc=h.turnIntoCSList(m),sc=a,z(R.ondrop),sc=rc=k,e())}c.preventDefault();var W=c.dataTransfer,f=W.files,m=Array(f.length),l=f.length,n=c.currentTarget.getBoundingClientRect(),p=h.realVector(y.to(c.clientX-n.left-a.clientLeft+.5,c.clientY-n.top-a.clientTop+.5));if(0<f.length)Array.prototype.forEach.call(f,function(a,c){var g=new FileReader;
q(a.type)?(g.onload=function(){b(c,g.result)},g.readAsText(a)):/^image\//.test(a.type)?(g.onload=function(){oa(c,g.result)},g.readAsDataURL(a)):(console.log("Unknown MIME type: "+a.type),d(c,k))});else if(c=W.getData("text/uri-list"))c=c.split("\n").filter(function(a){return!/^\s*(#|$)/.test(a)}),l=c.length,m=Array(l),f=Array(l),c.forEach(g)});var W=-1;H(a,"touchstart",function(a){if(-1===W){var g=a.changedTouches;0!==g.length&&(W=g[0].identifier,c(a.targetTouches[0]),z(R.mousedown),aa.down=!0,wb("mousedown"),
a.preventDefault())}},!1);H(a,"touchmove",function(a){for(var g=a.changedTouches,q=!1,b=0;b<g.length;b++)g[b].identifier===W&&(q=!0);q&&(c(a.targetTouches[0]),aa.down?z(R.mousedrag):z(R.mousemove),wb("mousemove"),a.preventDefault())},!0);H(a,"touchend",q,!1);"undefined"!==typeof document&&document.body&&H(document.body,"touchcancel",q,!1);"undefined"!==typeof window&&H(window,"resize",function(){Zb(function(){F();e()})},!1);d(a.parentNode);e()}function b(a,g){var c=document.createElement("div");c.setAttribute("style",
g);a.appendChild(c);return c}function d(a){function g(){q.scrollLeft=q.scrollTop=oa.scrollLeft=oa.scrollTop=1E5}function c(){if(d!==a.clientWidth||h!==a.clientHeight)d=a.clientWidth,h=a.clientHeight,f||(f=!0,Zb(function(){f=!1;F();e()}));g()}if("undefined"!==typeof document){var q=b(a,"position: absolute; transition: 0s; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;");b(q,"position: absolute; transition: 0s; left: 0; top: 0; width: 100000px; height: 100000px");
var oa=b(a,"position: absolute; transition: 0s; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;");b(oa,"position: absolute; transition: 0s; left: 0; top: 0; width: 200%; height: 200%");g();var d=a.clientWidth,h=a.clientHeight,f=!1;q.addEventListener("scroll",c);oa.addEventListener("scroll",c)}}function e(){tc||(tc=Zb(r))}function r(){tc=null;if(!Yb){if(cb){var a=Date.now(),g=Math.min(50,a-pc)*Vc*Xd;pc=a;a=Ib+g;qc&&"undefined"!==typeof ya&&ya.tick(g);Ib=a;cb&&
z(R.tick)}n();cb&&e()}}function n(){y.reset();A.save();A.clearRect(0,0,ca,da);var a=y.drawingstate.matrix,g,c,q,b,d;if(0!==za){A.beginPath();A.strokeStyle="rgba(0,0,0,0.1)";A.lineWidth=1;A.lineCap="butt";g=za*a.a;for(b=Math.ceil(-a.tx/g);(d=b*g+a.tx)<ca;){if(b||!Fb)A.moveTo(d,0),A.lineTo(d,da);b++}for(b=Math.floor(a.ty/g);(d=b*g-a.ty)<da;){if(b||!Fb)A.moveTo(0,d),A.lineTo(ca,d);b++}A.stroke()}if(0!==lc){A.beginPath();A.strokeStyle="rgba(0,0,0,0.1)";A.lineWidth=1;A.lineCap="butt";g=lc*a.a;var e=Math.sqrt(3);
c=a.ty/e;q=(da+a.ty)/e;for(b=Math.ceil(-(a.tx+q)/g);(d=b*g+a.tx)+c<ca;)A.moveTo(d+c,0),A.lineTo(d+q,da),b++;for(b=Math.ceil(-(a.tx-c)/g);(d=b*g+a.tx)-q<ca;)A.moveTo(d-c,0),A.lineTo(d-q,da),b++;g*=.5*e;for(b=Math.floor(a.ty/g);(d=b*g-a.ty)<da;){if(b||!Fb)A.moveTo(0,d),A.lineTo(ca,d);b++}A.stroke()}Fb&&(A.beginPath(),A.strokeStyle="rgba(0,0,0,0.2)",A.lineWidth=3,A.lineCap="butt",A.lineJoin="miter",A.miterLimit=10,A.beginPath(),A.moveTo(0,-a.ty),A.lineTo(ca-6,-a.ty),A.moveTo(ca-13,-5-a.ty),A.lineTo(ca-
3,-a.ty),A.lineTo(ca-13,5-a.ty),A.moveTo(a.tx,da),A.lineTo(a.tx,6),A.moveTo(a.tx-5,13),A.lineTo(a.tx,3),A.lineTo(a.tx+5,13),A.stroke());Yd();y.greset();Zd();for(a=0;a<v.polygons.length;a++)g=v.polygons[a],g.isshowing&&!1!==g.visible&&(c={color:g.color,alpha:g.alpha,fillcolor:g.fillcolor,fillalpha:g.fillalpha,size:g.size,lineJoin:w.string("miter"),fillrule:w.string(g.fillrule)},D.drawpolygon([g.vertices],c,"D",!0));for(a=0;a<v.conics.length;a++)v.conics[a].isArc?(g=v.conics[a],g.isshowing&&!1!==g.visible&&
(c={},c.color=g.color,c.alpha=g.alpha,c.size=g.size,D.drawarc(g,c,g.filled?"F":"D"))):(g=v.conics[a],g.isshowing&&!1!==g.visible&&(c={},c.color=g.color,c.alpha=g.alpha,c.size=g.size,D.drawconic(g.matrix,c)));for(a=0;a<v.lines.length;a++)a:if(g=v.lines[a],g.isshowing&&!1!==g.visible&&h._helper.isAlmostReal(g.homog))if("S"===g.kind)c={overhang:g.overhang,dashtype:g.dashtype,size:g.size,color:g.color,alpha:g.alpha,arrow:g.arrow,arrowsize:g.arrowsize,arrowposition:g.arrowposition,arrowshape:g.arrowshape,
arrowsides:g.arrowsides},0<=m.mult(g.startpos.value[2],m.conjugate(g.endpos.value[2])).value.real?(t.draw$2([g.startpos,g.endpos],c),g.labeled&&!g.tmp&&(c=g.printname||g.name||"S",q=h.scalmult(m.real(Math.sign(g.startpos.value[2].value.real)*Math.sign(g.endpos.value[2].value.real)),h.cross(g.startpos,g.endpos)),q={x:q.value[0].value.real,y:q.value[1].value.real},b=Math.sqrt(q.x*q.x+q.y*q.y),q={x:8*q.x/b-3,y:8*q.y/b-3},q=g.labelpos||q,b=x.makeColor(ga.textColor),d=l._helper.midpoint(l._helper.midpoint(g.startpos,
g.endpos),g.endpos),Xc(g,c,d,q,b))):(x.handleModifs(c,x.lineModifs),x.drawRaySegment(g.startpos,g.endpos));else if("end"===g.clip.value&&"Join"===g.type)b=v.csnames[g.args[0]],c=v.csnames[g.args[1]],t.draw$2([b.homog,c.homog],{overhang:g.overhang,dashtype:g.dashtype,size:g.size,color:g.color,alpha:g.alpha});else{if("inci"===g.clip.value){b=[1E6,0];c=[-1E6,0];d=[1E6,0];q=[-1E6,0];for(e=0;e<g.incidences.length;e++){var f=v.csnames[g.incidences[e]].homog,k=f.value[0],Ra=f.value[1],n=f.value[2];m._helper.isAlmostZero(n)||
(k=m.div(k,n),Ra=m.div(Ra,n),m._helper.isAlmostReal(k)&&m._helper.isAlmostReal(Ra)&&(k.value.real<b[0]&&(b=[k.value.real,f]),k.value.real>c[0]&&(c=[k.value.real,f]),Ra.value.real<d[0]&&(d=[Ra.value.real,f]),Ra.value.real>q[0]&&(q=[Ra.value.real,f])))}c[0]-b[0]>q[0]-d[0]?(b=b[1],c=c[1]):(b=d[1],c=q[1]);if(b!==c){t.draw$2([b,c],{dashtype:g.dashtype,size:g.size,color:g.color,alpha:g.alpha,overhang:g.overhang});break a}}t.draw$1([g.homog],{dashtype:g.dashtype,size:g.size,color:g.color,alpha:g.alpha})}for(a=
0;a<v.points.length;a++)if(g=v.points[a],g.isshowing&&!1!==g.visible&&h._helper.isAlmostReal(g.homog)&&(c=g.color,g.behavior&&(c=g.color),t.draw$1([g.homog],{size:g.size,color:c,alpha:g.alpha,noborder:g.noborder,border:g.border}),g.labeled&&!g.tmp)){q=g.printname||g.name||"P";b=g.labelpos||{x:3,y:3};d=x.makeColor(ga.textColor);if(!0===g.noborder.value||!1===g.border.value)d=c;Xc(g,q,g.homog,b,d)}for(a=0;a<v.texts.length;a++)$d(v.texts[a]);if(v.ifs.length){if(U.dirty||!w.deeplyEqual(U.mat,y.drawingstate.matrix))l.IFS.updateParameters(),
U.dirty=!1;U.img&&A.drawImage(U.img,0,0,ca,da)}A.restore()}function I(a,g){var c=window.event?event:a,c=c.charCode?c.charCode:c.keyCode;Yc=String.fromCharCode(c);Zc=c;z(g);e()}function u(a){var g=a.value;a=g[0].value;var c=g[1].value,g=g[2].value;return h.turnIntoCSList([a[0],m.add(a[1],c[0]),m.add(a[2],g[0]),c[1],m.add(c[2],g[1]),g[2]])}function C(a){var g=!0;return function(c,q){g&&(console.error("Operator "+a+" is not supported yet."),g=!1);return k}}function Z(a){if("undefined"===typeof a)return"_??_";
if(null===a)return"_???_";if("undefined"===a.ctype)return"___";if("number"===a.ctype)return m.niceprint(a);if("string"===a.ctype||"boolean"===a.ctype)return a.value;if("list"===a.ctype){for(var g="[",c=0;c<a.value.length;c++)g+=Z(z(a.value[c])),c!==a.value.length-1&&(g+=", ");return g+"]"}return"dict"===a.ctype?Na.niceprint(a):"function"===a.ctype?"FUNCTION":"infix"===a.ctype?"INFIX":"modifier"===a.ctype?a.key+"->"+Z(a.value):"shape"===a.ctype?a.type:"error"===a.ctype?"Error: "+a.message:"variable"===
a.ctype?Z(J.getvar(a.name)):"geo"===a.ctype?a.value.name:"image"===a.ctype?"IMAGE":"_?_"}function ab(a,g){var c="undefined"===a[0].ctype,q="undefined"===a[1].ctype,b=z(a[1]);if(c||q)return k;"variable"===a[0].ctype?J.setvar(a[0].name,b):"infix"===a[0].ctype?"_"===a[0].oper?D.assigntake(a[0],b):ka("Can't use infix expression as lvalue"):"field"===a[0].ctype?D.assigndot(a[0],b):"userdata"===a[0].ctype?D.assigncolon(a[0],b):"function"===a[0].ctype&&"genList"===a[0].oper?"list"===b.ctype?D.assignlist(a[0].args,
b.value):ka("Expected list in rhs of assignment"):ka("Left hand side of assignment is not a recognized lvalue");return b}function vb(a,g){var c=z(a[0]),q=z(a[1]);if(c.ctype===q.ctype){if("number"===c.ctype)return w.bool(c.value.real===q.value.real&&c.value.imag===q.value.imag);if("string"===c.ctype||"boolean"===c.ctype)return w.bool(c.value===q.value);if("list"===c.ctype)return h.equals(c,q);if("geo"===c.ctype)return w.bool(c.value===q.value)}return{ctype:"boolean",value:!1}}function Oc(a,g){return w.not(vb(a,
g))}function hc(a,g){var c=B(a[0]),q=B(a[1]);return"number"===c.ctype&&"number"===q.ctype?{ctype:"boolean",value:m._helper.isAlmostEqual(c,q)}:"string"===c.ctype&&"string"===q.ctype||"boolean"===c.ctype&&"boolean"===q.ctype?{ctype:"boolean",value:c.value===q.value}:"list"===c.ctype&&"list"===q.ctype?h.almostequals(c,q):{ctype:"boolean",value:!1}}function Pc(a,g){var c=B(a[0]),q=B(a[1]);return"boolean"===c.ctype&&"boolean"===q.ctype?{ctype:"boolean",value:c.value&&q.value}:k}function Qc(a,g){var c=
B(a[0]),q=B(a[1]);return"boolean"===c.ctype&&"boolean"===q.ctype?{ctype:"boolean",value:c.value||q.value}:k}function Rc(a,g){var c=a[0];"void"!==c.ctype&&(c=B(c));var q=B(a[1]),b=w.add(c,q);"Angle"===c.usage&&"Angle"===q.usage&&(b=w.withUsage(b,"Angle"));return b}function jc(a,g){var c=a[0];"void"!==c.ctype&&(c=B(c));var q=B(a[1]),b=w.sub(c,q);"Angle"===c.usage&&"Angle"===q.usage&&(b=w.withUsage(b,"Angle"));return b}function Sc(a,g){var c=B(a[0]),q=B(a[1]),b=w.mult(c,q);"Angle"!==c.usage||q.usage?
"Angle"!==q.usage||c.usage||(b=w.withUsage(b,"Angle")):b=w.withUsage(b,"Angle");return b}function Tc(a,g){var c=B(a[0]),q=B(a[1]);"number"===q.ctype&&m._helper.isZero(q)&&ka("WARNING: Division by zero!");var b=w.div(c,q);"Angle"!==c.usage||q.usage?"Angle"!==q.usage||c.usage||(b=w.withUsage(b,"Angle")):b=w.withUsage(b,"Angle");return b}function Uc(a,g){var c=B(a[0]),q=B(a[1]);return"number"===c.ctype&&"number"===q.ctype?m.pow(c,q):k}function $c(a,g){var c=K(a[0]),q=K(a[1]);if(c!==k&&q!==k){var b=h.cross(c,
q);"Point"===c.usage&&"Point"===q.usage&&(b=w.withUsage(b,"Line"));"Line"===c.usage&&"Line"===q.usage&&(b=w.withUsage(b,"Point"));return b}return k}function uc(a){var g=a.length;if(0===g)return[];if(1===g)return[0];if(2===g)return a[0][0]+a[1][1]<=a[0][1]+a[1][0]?[0,1]:[1,0];if(4<g)return ae(a);for(var c=be[g],q=Number.POSITIVE_INFINITY,b=c[0],d=0;d<c.length;++d){for(var h=c[d],e=0,f=0;f<g;++f)e+=a[f][h[f]];e<q&&(q=e,b=h)}return b}function ae(a){function g(){return{matched:-1,prev:-1,start:-1,cost:0,
used:!1,leaf:!1}}function c(a){for(var g=0;g<d;++g)0<k[a][g]||m[g].used||(m[g].used=!0,c(m[g].matched))}function q(a){for(var c=0;c<d;++c)0<k[c][a]||f[c].used||(f[c].used=!0,q(f[c].matched))}var b=Math.abs,d=a.length,h,e,f=Array(d),m=Array(d),k=Array(d);for(h=0;h<d;++h)k[h]=Array(d);for(h=0;h<d;++h)for(f[h]=g(),m[h]=g(),f[h].cost=a[h][0],e=1;e<d;++e)f[h].cost>a[h][e]&&(f[h].cost=a[h][e]);for(;;){for(h=0;h<d;++h)for(e=0;e<d;++e)k[h][e]=a[h][e]-f[h].cost-m[e].cost,k[h][e]<1E-14*(b(a[h][e])+b(f[h].cost)+
b(m[e].cost))&&(k[h][e]=0);for(h=0;h<d;++h)f[h].matched=m[h].matched=-1;for(var l=0;;){for(h=0;h<d;++h)f[h].used=f[h].leaf=m[h].used=m[h].leaf=!1,-1===f[h].matched&&(f[h].start=h,f[h].used=f[h].leaf=!0,f[h].prev=-1);for(var n=!1,p=!1;!p;){for(h=0;h<d;++h)if(f[h].leaf)for(f[h].leaf=!1,e=0;e<d;++e)if(!(m[e].used||0<k[h][e])&&f[h].matched!==e&&(m[e].prev=h,m[e].start=f[h].start,m[e].used=m[e].leaf=!0,-1===m[e].matched)){f[m[e].start].prev=e;n=!0;break}if(n)break;p=!0;for(e=0;e<d;++e)m[e].leaf&&(m[e].leaf=
!1,h=m[e].matched,f[h].used||(f[h].prev=e,f[h].start=m[e].start,f[h].used=f[h].leaf=!0,p=!1))}if(!n)break;for(n=0;n<d;++n)if(-1===f[n].matched&&-1!==f[n].prev){e=f[n].prev;do h=m[e].prev,m[e].matched=h,f[h].matched=e,e=f[h].prev;while(h!==n);++l}}if(l===d)break;for(h=0;h<d;++h)f[h].used=f[h].leaf=m[h].used=m[h].leaf=!1;for(h=0;h<d;++h)-1===f[h].matched&&c(h);for(e=0;e<d;++e)-1===m[e].matched&&q(e);for(h=0;h<d;++h)-1===f[h].matched||f[h].used||m[f[h].matched].used||(f[h].used=!0);l=Number.POSITIVE_INFINITY;
for(h=0;h<d;++h)if(!f[h].used)for(e=0;e<d;++e)m[e].used||l>k[h][e]&&(l=k[h][e]);for(h=0;h<d;++h)f[h].used||(f[h].cost+=l),m[h].used&&(m[h].cost-=l)}a=Array(d);for(h=0;h<d;++h)e=f[h].matched,a[h]=e;return a}function vc(a,g){var c=z(a[0]),q=B(a[1]);"string"!==c.ctype&&(c=h.asList(c));if("number"===q.ctype){q=Math.floor(q.value.real);0>q&&(q=c.value.length+q+1);if(0<q&&q<c.value.length+1)return"list"===c.ctype?c.value[q-1]:{ctype:"string",value:c.value.charAt(q-1)};ka("WARNING: Index out of range!");
return k}if("list"===q.ctype){for(var b=[],d=0;d<q.value.length;d++){var e=B(q.value[d]);b[d]=vc([c,e],[])}return h.turnIntoCSList(b)}return k}function ad(a,g){var c=z(a[0]),q=z(a[1]);if("shape"===c.ctype&&"shape"===q.ctype)return D.shapeconcat(c,q);c=h.asList(c);q=h.asList(q);return"list"===c.ctype&&"list"===q.ctype?h.concat(c,q):k}function bd(a,g){var c=z(a[0]),q=z(a[1]);return"list"===c.ctype&&"list"===q.ctype?h.set(h.common(c,q)):"shape"===c.ctype&&"shape"===q.ctype?D.shapecommon(c,q):k}function cd(a,
g){var c=z(a[0]),q=z(a[1]);return"list"===c.ctype&&"list"===q.ctype?h.remove(c,q):"shape"===c.ctype&&"shape"===q.ctype?D.shaperemove(c,q):k}function dd(a,g){var c=z(a[0]),q=z(a[1]);return"list"===c.ctype?h.append(c,q):k}function ed(a,g){var c=z(a[0]),q=z(a[1]);return"list"===q.ctype?h.prepend(c,q):k}function wc(a,g){a|=0;g|=0;if(0===a&&0===g)return 0;for(;0!==g;){var c=a;a=g;g=c%g|0}return a}function ce(a){return 1===a?0:1}function Jb(a,g,c){var q=g*g-4*a*c;0<=q?(q=Math.sqrt(q),0<g&&(q=-q),g=[[q-
g,2*a],[2*c,q-g]]):g=null;if(null===g)return null;a=g[0][0]/g[0][1];g=g[1][0]/g[1][1];return g<a?[g,a]:[a,g]}function fd(a,g,c,q,b,d,h){if(-1!==g.indexOf("\n")){var e=Infinity,f=-Infinity,m=Infinity,k=-Infinity;g.split("\n").forEach(function(g){g=fd(a,g,c,q,b,d);e>g.left&&(e=g.left);f<g.right&&(f=g.right);m>g.top&&(m=g.top);k<g.bottom&&(k=g.bottom);q+=h});return{left:e,right:f,top:m,bottom:k}}var l=a.measureText(g);a.fillText(g,c-l.width*b,q);return{left:c-l.width*b,right:c+l.width*(1-b),top:q-.84*
d,bottom:q+.36*d}}function Ja(a){return"image"===a.ctype?a.value:"string"===a.ctype&&bb.hasOwnProperty(a.value)?bb[a.value].value:null}function pb(a,g,c,q,b){var d=[];if(a.readPixels)d=a.readPixels(g,c,q,b);else{var h,e;if(a.img.getContext)e=a.img.getContext("2d"),h=e.getImageData(g,c,q,b).data;else try{Kb||(Kb=document.createElement("canvas")),Kb.width=q,Kb.height=b,e=Kb.getContext("2d"),e.drawImage(a.img,g,c,q,b,0,0,q,b),h=e.getImageData(0,0,q,b).data}catch(f){console.log(f)}for(var m in h)d.push(h[m]/
255)}return d}function gd(a){return a.replace(/[^A-Za-z0-9 \u0080-\uffff]/ig,"\\$&")}function la(a,g,c){var q=a;g&&(q=q+" at "+g.row+":"+g.col);c&&(q=q+": \u2018"+c+"\u2019");q=Error(q);q.name="CindyScriptParseError";q.description=a;q.location=g;q.text=c;return q}function qb(a){this.input=a;this.re=new RegExp(hd,"g");for(var g=[],c=a.indexOf("\n")+1;c;)g.push(c),c=a.indexOf("\n",c)+1;g.push(a.length);this.bols=g;this.bol=this.pos=0;this.line=1}function $b(a){var g=a[a.length-2],c=a[a.length-3],q=
a[a.length-1];if(c){if(c.isSuperscript&&g.precedence<=c.precedence)throw la("Operator not allowed after superscript",g.start,g.text);if(q){if(!g.op.infix)throw la("Operator may not be used infix",g.start,g.text);}else if(!g.op.postfix)throw la("Operator may not be used postfix",g.start,g.text);}else if(q){if(!g.op.prefix)throw la("Operator may not be used prefix",g.start,g.text);}else if(!g.op.bare)throw la("Operator without operands",g.start,g.text);g.ctype="infix";g.oper=g.op.sym;g.args=[c,q];a.splice(a.length-
3,3,g)}function id(a,g,c,q){a.length&1||a.push(null);for(c=Ca[c];3<=a.length&&a[a.length-2].precedence<=c.precedence;)$b(a);a.push({op:c,precedence:c.precedence+(c.rassoc?1:0),start:g.start,end:g.end,text:g.text,rawtext:g.rawtext});c="";for(var b=g.text,d=0;d<b.length;++d)c+="0123456789+-".charAt(q.indexOf(b.charAt(d)));g.ctype="number";g.value={real:+c,imag:0};a.push(g);$b(a)}function jd(a,g){var c=[],q;a:for(;;)switch(q=a.next(),q.toktype){case "OP":var b=Ca[q.text];"_"!==b.sym||!c.length||c.length&
1||"OP"!==c[c.length-1].toktype||":="!==c[c.length-1].op.sym||(c.pop(),b=Ca[":=_"],q.text=b.sym);q.op=b;q.precedence=b.precedence;for(c.length&1||c.push(null);3<=c.length&&c[c.length-2].precedence<=q.precedence;)$b(c);b.rassoc&&q.precedence++;c.push(q);break;case "ID":q.ctype="variable";q.name=q.text;if(c.length&1)throw la("Missing operator",q.start,q.text);c.push(q);break;case "NUM":q.ctype="number";q.value={real:+q.text,imag:0};if(c.length&1)throw la("Missing operator",q.start,q.text);c.push(q);
break;case "STR":q.ctype="string";q.value=q.raw.substring(1,q.raw.length-1);if(c.length&1)throw la("Missing operator",q.start,q.text);c.push(q);break;case "SUB":id(c,q,"_","\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089\u208a\u208b");break;case "SUP":id(c,q,"^","\u2070\u00b9\u00b2\u00b3\u2074\u2075\u2076\u2077\u2078\u2079\u207a\u207b");c[c.length-1].isSuperscript=!0;break;case "BRA":b="[](){}||".indexOf(q.text);if(q.text===g||b&1)break a;var b="[](){}||".charAt(b+1),d=jd(a,b),h=d.closedBy;
if(h.text!==b)throw la("Opening "+q.text+" at "+q.start.row+":"+q.start.col+" closed by "+(h.text||"EOF")+" at "+h.start.row+":"+h.start.col);h=q.text+h.text;b=[];if(d=d.expr){for(;d&&"infix"===d.ctype&&","===d.oper;)b.push(d.args[0]),d=d.args[1];b.push(d)}if(c.length&1){if("{}"===h)throw la("{\u2026} reserved for future use",q.start);d=c[c.length-1];if("variable"!==d.ctype)throw la("Function name must be an identifier",d.start);if(2<c.length&&c[c.length-2].precedence<kd)throw la("Function call in indexing construct must be enclosed in parentheses",
q.start);d.ctype="function";q=d.args=[];for(var h=d.modifs={},e=0;e<b.length;++e){var f=b[e];if(f&&"infix"===f.ctype&&"->"===f.oper){var m=f.args[0];if("variable"!==m.ctype)throw la("Modifier name must be an identifier",f.start);h[m.name]=f.args[1]}else q.push(f)}d.oper=d.name.toLowerCase()+"$"+d.args.length}else if("||"===h)if(1===b.length)c.push({ctype:"function",oper:"abs_infix",args:b,modifs:{}});else if(2===b.length)c.push({ctype:"function",oper:"dist_infix",args:b,modifs:{}});else throw la("Don't support |\u2026| with "+
b.length+" arguments",q.start);else{if("{}"===h)throw la("{\u2026} reserved for future use",q.start);"[]"!==h&&1===b.length?c.push({ctype:"paren",args:b}):0===b.length?c.push({ctype:"list",value:[]}):c.push({ctype:"function",oper:"genList",args:b,modifs:{}})}break;case "EOF":break a}for(c.length&1||c.push(null);3<=c.length;)$b(c);return{expr:c[0],closedBy:q}}function Lb(a){this.usedFunctions={};this.usedVariables={}}function z(a){if(void 0===a)return k;if("infix"===a.ctype)return a.impl(a.args,{},
a);if("variable"===a.ctype)return z(J.getvar(a.name));if("function"===a.ctype)return Mb.push(a),a=D.evaluate(a.oper,a.args,a.modifs),Mb.pop(),a;if("void"===a.ctype)return k;if("field"===a.ctype){var g=z(a.obj);return"geo"===g.ctype?ta.getField(g.value,a.key):"list"===g.ctype?h.getField(g,a.key):k}return"userdata"===a.ctype?(g=z(a.obj),a=Z(z(a.key)),"_?_"===a&&(a=void 0),"geo"===g.ctype?ta.getuserData(g.value,a):"list"===g.ctype||"string"===g.ctype?ta.getuserData(g,a):k):a}function B(a){a=z(a);if("geo"===
a.ctype){var g=a.value;if("P"===g.kind)return ta.getField(g,"xy");if("V"===g.kind)return g.value}return a}function K(a){a=z(a);if("geo"===a.ctype){var g=a.value;if("P"===g.kind||"L"===g.kind)return ta.getField(g,"homog")}return h._helper.isNumberVecN(a,3)?a:h._helper.isNumberVecN(a,2)?(g=h.turnIntoCSList([a.value[0],a.value[1],m.real(1)]),a.usage&&(g=w.withUsage(g,a.usage)),g):k}function Ua(a){var g=new Lb;g.usedFunctions=hb;g.infixmap=Q;a=g.parse(a);for(var c in g.usedVariables)J.create(c);return a}
function Td(a,g){return{ctype:"infix",args:[],impl:function(){Mb=[{oper:g}];var c=z(a);Mb=[];return c}}}function ka(a){wa.err(a+Mb.map(function(a){return"\n  at "+a.oper}).join("\n"))}function ld(){this._path=[];this._defs=["<defs>"];this._imgcache=[];this._body=[];this._saveStack=[""];this._clipIndex=0;this._stroke=this._fill="#000";this._strokeOpacity=this._fillOpacity=null;this.height=this.width=0;this.lineWidth=1;this.lineCap="butt";this.lineJoin="miter";this.miterLimit=10;this.globalAlpha=1}
function md(){this._body=[];this._yPos=this._xPos=NaN;this._extGState={Af255:"<< /ca 1 >>",As255:"<< /CA 1 >>"};this._objects=[["%PDF-1.4\n"]];this._offset=this._objects[0][0].length;this._nextIndex=5;this._imgcache=[];this._xobjects={};this._pathUsed=-1;this._fillAlpha=this._strokeAlpha=this._globalAlpha=1;this.height=this.width=0;this.lineWidth=1;this.lineCap="butt";this.lineJoin="miter";this.miterLimit=10}function nd(a,g){var c=a.width,q=a.height,b=document.createElement("canvas");b.setAttribute("width",
c);b.setAttribute("height",q);b.setAttribute("style","display:none;");var d=sa.canvas;d.parentNode.insertBefore(b,d.nextSibling);try{return b.getContext("2d").drawImage(a,0,0,c,q),b.toDataURL(g||"image/png")}finally{b.parentNode.removeChild(b)}}function de(a){a=a.replace(RegExp("[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/]+","g"),"");var g=new Uint8Array(3*a.length>>2),c,q,b,d,h,e;for(q=c=0;c+3<a.length;c+=4)b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c)),
d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c+1)),h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c+2)),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c+3)),g[q++]=b<<2|d>>4,g[q++]=d<<4|h>>2,g[q++]=h<<6|e;switch(a.length-c){case 0:break;case 2:b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c));d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c+
1));g[q++]=b<<2|d>>4;break;case 3:b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c));d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c+1));h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c+2));g[q++]=b<<2|d>>4;g[q++]=d<<4|h>>2;break;default:throw Error("Malformed Base64 input: "+(a.length-c)+" chars left: "+a.substr(c));}if(q!==g.length)throw Error("Failed assertion: "+q+" should be "+
g.length);return g}function ee(a){function g(c){return(a[c]<<24|a[c+1]<<16|a[c+2]<<8|a[c+3])>>>0}if(57>a.length)throw Error("Too short to be a PNG file");if(2303741511!==g(0)||218765834!==g(4))throw Error("PNG signature missing");for(var c=[],q=8;q<a.length;){if(q+12>a.length)throw Error("Incomplete chunk at offset 0x"+q.toString(16));var b=g(q);if(2147483648<=b)throw Error("Chunk too long");var d=q+12+b;if(d>a.length)throw Error("Incomplete chunk at offset 0x"+q.toString(16));var h=a.subarray(q+
4,q+8),h=String.fromCharCode.apply(String,h);c.push({len:b,type:h,data:a.subarray(q+8,q+8+b),crc:g(q+8+b)});q=d}return c}function ac(a,g){var c;if(c=/^rgba\(([0-9.]+), *([0-9.]+), *([0-9.]+), *([0-9.]+)\)$/.exec(a))g(+c[1],+c[2],+c[3],+c[4]);else if(c=/^rgb\(([0-9.]+), *([0-9.]+), *([0-9.]+)\)$/.exec(a))g(+c[1],+c[2],+c[3],1);else throw Error("Can't handle color style "+a);}function fe(a){var g=1;Object.keys(bb).forEach(function(c){var q=bb[c].value.img;if(void 0===q.cachedDataURL&&q.src)if("data:"===
q.src.substr(0,5))q.cachedDataURL=q.src;else{++g;q.cachedDataURL=null;var b=new XMLHttpRequest;b.responseType="blob";b.onreadystatechange=function(){if(b.readyState===XMLHttpRequest.DONE)if(200===b.status){var c=new FileReader;c.onloadend=function(){q.cachedDataURL=c.result;console.log("Cached data for image "+q.src);0===--g&&a()};c.readAsDataURL(b.response)}else console.error("Failed to load "+q.src+": "+b.statusText),0===--g&&a()};b.open("GET",q.src,!0);b.send()}});0===--g&&a()}function rb(a,g,
c){for(c||(c="0");a.length<g;)a=c+a;return a}function od(){null!==Nb&&(window.URL.revokeObjectURL(Nb),Nb=null)}function pd(a){fe(function(){var g=A;try{A=new a;A.width=ca;A.height=da;n();var c=A.toBlob();Nb=window.URL.createObjectURL(c);qd(Nb)}finally{A=g}})}function Ob(a){var g=null,c=1E6,q;console.log("getElementAtMouse");for(var b=0;b<v.gslp.length;b++){var d=v.gslp[b];if(!d.pinned&&!1!==d.visible&&!0!==d.tmp){var e,f,k,l=y.drawingstate.matrix.sdet;if("P"===d.kind){var n=h.normalizeZ(d.homog);
if(!h._helper.isAlmostReal(n))continue;e=n.value[0].value.real-a.x;f=n.value[1].value.real-a.y;k=Math.sqrt(e*e+f*f);d.narrow&k>20/l&&(k=1E4)}else if("C"===d.kind)f=v.csnames[d.args[0]],k=0,"undefined"!==typeof d.radius&&(k=d.radius.value.real),e=m.div(f.homog.value[0],f.homog.value[2]).value.real,f=m.div(f.homog.value[1],f.homog.value[2]).value.real,e-=a.x,f-=a.y,k=Math.sqrt(e*e+f*f)-k,f=e=0,0>k&&(k=-k),k+=30/l;else if("L"===d.kind||"S"===d.kind)e=d.homog,k=m,f=k.add(k.mult(e.value[0],k.conjugate(e.value[0])),
k.mult(e.value[1],k.conjugate(e.value[1]))),f=h.scaldiv(k.sqrt(f),e),k=f.value[0].value.real*a.x+f.value[1].value.real*a.y+f.value[2].value.real,e=f.value[0].value.real*k,f=f.value[1].value.real*k,0>k&&(k=-k),k+=1;k<c+.2/l&&(c=k,g=d,q={x:e,y:f})}}return null===g?null:{mover:g,offset:q,prev:{x:a.x,y:a.y}}}function Xa(){return"P"+ge++}function wb(a){var g=G[xc].actions;g[xb].event===a&&g[xb]["do"]()&&(e(),xb===g.length-1?(Aa=[],xb=Ya=0):xb++)}function yc(a){return a&&.5>Math.abs(a.offset.x)&&.5>Math.abs(a.offset.y)&&
!a.mover.tmp}function rd(a){return yc(a)&&"P"===a.mover.kind}function sd(a){return yc(a)&&("L"===a.mover.kind||"S"===a.mover.kind)}function zc(a){ja={mover:a,offset:{x:0,y:0},prev:{x:aa.x,y:aa.y}}}function sb(){var a=Ob(aa);rd(a)?Aa[Ya]=a.mover:(Aa[Ya]={type:"Free",name:Xa(),labeled:!0,pos:[ra[0],ra[1],1]},Ka(Aa[Ya]));Ya++}function td(){var a=Ob(aa);return sd(a)?(Aa[Ya]=a.mover,Ya++,!0):!1}function ud(){var a=Ob(aa),g;(g=sd(a))||(g=yc(a)&&"C"===a.mover.kind);return g?(Aa[Ya]=a.mover,Ya++,!0):!1}function yb(){var a=
Ob(aa);if(rd(a))for(Pb.args[1]=a.mover.name,a=0;a<v.gslp.length;a++){var g=v.gslp[a];!0===g.tmp&&vd(g.name)}else for(a=0;a<v.gslp.length;a++)g=v.gslp[a],!0===g.tmp&&(g.tmp=!1)}function bc(a){var g={type:"Free",name:Xa(),labeled:!0,pos:[ra[0],ra[1],1],tmp:!0},g=Ka(g);Pb=Ka({type:a,name:Xa(),labeled:!0,args:[Aa[0].name,g.name]});zc(g)}function he(a){for(var g in a)null!==a[g]&&(ga[g]=a[g])}function Ud(a){Object.keys(l).forEach(function(a){var c=l[a];kb(c.signature||"_helper"===a,a+" has no signature");
void 0!==c.updatePosition&&void 0===c.stateSize&&(c.stateSize=0)});v.gslp=[];v.csnames={};v.points=[];v.lines=[];v.conics=[];v.texts=[];v.free=[];v.polygons=[];v.ifs=[];a.forEach(wd);xd()}function yd(a){"undefined"===typeof a.tracedim&&(a.tracedim=1);"undefined"===typeof a.tracelength&&(a.tracelength=100);"undefined"===typeof a.traceskip&&(a.traceskip=1);a._traces=Array(a.tracelength);a._traces_index=0;a._traces_tick=0}function ie(a){void 0===a.size&&(a.size=ga.pointSize);a.size=m.real(a.size);!a.movable||
a.pinned?(a.color=h.realVector(a.color||ga.pointColor),a.color=h.scalmult(m.real(ga.dimDependent),a.color)):a.color=h.realVector(a.color||ga.pointColor);void 0===a.alpha&&(a.alpha=ga.alpha);a.alpha=m.real(a.alpha);"boolean"!==typeof a.noborder&&(a.noborder=ga.noborder);a.noborder=w.bool(a.noborder);"boolean"!==typeof a.border&&(a.border=!ga.noborder);a.border=w.bool(a.border);a.drawtrace&&yd(a)}function cc(a){void 0===a.size&&(a.size=ga.lineSize);a.size=m.real(a.size);a.color=h.realVector(a.color||
ga.lineColor);void 0===a.alpha&&(a.alpha=ga.alpha);a.alpha=m.real(a.alpha);a.clip=w.string(a.clip||ga.clip);void 0===a.overhang&&(a.overhang=ga.overhangLine);a.overhang=m.real(a.overhang);a.dashtype&&(a.dashtype=w.wrap(a.dashtype))}function je(a){void 0===a.overhang&&(a.overhang=ga.overhangSeg);a.arrow&&(a.arrow=w.bool(a.arrow));a.arrowsize&&(a.arrowsize=m.real(a.arrowsize));a.arrowposition&&(a.arrowposition=m.real(a.arrowposition));a.arrowshape&&(a.arrowshape=w.string(a.arrowshape));a.arrowsides&&
(a.arrowsides=w.string(a.arrowsides));cc(a);a.clip=w.string("end")}function ke(a){a.size=void 0!==a.textsize?a.textsize:void 0!==a.size?a.size:ga.textsize;a.size=m.real(+a.size)}function le(a){a.filled=void 0!==a.filled?w.bool(a.filled):w.bool(!0);a.fillcolor=void 0===a.fillcolor?k:h.realVector(a.fillcolor);void 0===a.fillalpha&&(a.fillalpha=0);a.fillalpha=m.real(a.fillalpha);cc(a)}function Ka(a){a=wd(a);xd();return a}function wd(a){var g;if(void 0!==v.csnames[a.name])return console.log("Element name '"+
a.name+"' already exists"),g=v.csnames[a.name],l[g.type].isMovable&&"P"===l[g.type].kind&&La(g,a.pos,"homog"),{ctype:"geo",value:g};for(;Ac.hasOwnProperty(a.type);)a.type=Ac[a.type];if(g=zd[a.type]){var c=g(a),q=null;for(g=0;g<c.length;++g)q=Ka(c[g]);return q}var b=l[a.type],c=!1;if(!b)return console.error(a),console.error("Operation "+a.type+" not implemented yet"),null;if("**"!==b.signature)if(!Array.isArray(b.signature)&&"*"===b.signature.charAt(1))c=!0,a.args.forEach(function(c){if(v.csnames[c].kind!==
b.signature.charAt(0))return console.error("Not all elements in set are of same type: "+a.name+" expects "+b.signature+" but "+c+" is of kind "+v.csnames[c].kind),"undefined"!==typeof window&&window.alert("Not all elements in set are of same type: "+a.name),null});else if(b.signature.length!==(a.args?a.args.length:0))return console.error("Wrong number of arguments for "+a.name+" of type "+a.type),"undefined"!==typeof window&&window.alert("Wrong number of arguments for "+a.name),null;if(a.args)for(g=
0;g<a.args.length;++g){if(!v.csnames.hasOwnProperty(a.args[g]))return console.log("Dropping "+a.name+" due to missing argument "+a.args[g]),null;if("**"!==b.signature&&!c&&(q=v.csnames[a.args[g]].kind,b.signature[g]!==q&&("S"!==q||"L"!==b.signature[g])))return window.alert("Wrong argument kind "+q+" as argument "+g+" to element "+a.name+" of type "+a.type),null}b.signatureConstraints&&!b.signatureConstraints(a)&&window.alert("signature constraints violated for element "+a.name);v.gslp.push(a);v.csnames[a.name]=
a;g=Da.length;a.kind=b.kind;a.stateIdx=g;g+=b.stateSize;a.incidences=[];a.isshowing=!0;a.movable=!1;b.isMovable&&(a.movable=!0,v.free.push(a));"P"===a.kind&&(v.points.push(a),ie(a));"L"===a.kind&&(v.lines.push(a),cc(a));"C"===a.kind&&(v.conics.push(a),cc(a));"S"===a.kind&&(v.lines.push(a),je(a));"Text"===a.kind&&(v.texts.push(a),ke(a));"Poly"===a.kind&&(v.polygons.push(a),le(a));"IFS"===a.kind&&v.ifs.push(a);me(g);qa=Oa=Da;lb=!0;b.initialize&&(Ba=Ea=a.stateIdx,a.param=b.initialize(a),kb(Ea===a.stateIdx+
b.stateSize,"State fully initialized"));Ba=Ea=a.stateIdx;b.updatePosition(a,!1);kb(Ba===a.stateIdx+b.stateSize,"State fully consumed");kb(Ea===a.stateIdx+b.stateSize,"State fully updated");lb=!1;qa=ib["in"];qa.set(Da);Oa=ib.out;Bc(a,b);dc={};mb(a);return v.csnames[a.name]}function vd(a){var g,c;console.log("Remove element "+a);delete v.csnames[a];for(g=0;g<v.gslp.length;g++)c=v.gslp[g],c.name===a&&(console.log("Removed element from gslp "+a),v.gslp.splice(g,1));for(g=0;g<v.free.length;g++)c=v.free[g],
c.name===a&&(console.log("Removed element from free "+a),v.free.splice(g,1));for(g=0;g<v.points.length;g++)c=v.points[g],c.name===a&&(console.log("Removed element from points "+a),v.points.splice(g,1));for(g=0;g<v.lines.length;g++)c=v.lines[g],c.name===a&&(console.log("Removed element from lines "+a),v.lines.splice(g,1));for(g=0;g<v.conics.length;g++)c=v.conics[g],c.name===a&&(console.log("Removed element from conics "+a),v.conics.splice(g,1));dc={}}function Ad(a,g){var c=v.csnames[g.args[0]].homog,
q=v.csnames[g.args[1]].homog,b=a.homog,d=m.div(c.value[0],c.value[2]),c=m.div(c.value[1],c.value[2]),h=m.div(q.value[0],q.value[2]),q=m.div(q.value[1],q.value[2]),e=m.div(b.value[0],b.value[2]),b=m.div(b.value[1],b.value[2]);return m._helper.isAlmostReal(d)&&m._helper.isAlmostReal(c)&&m._helper.isAlmostReal(h)&&m._helper.isAlmostReal(q)&&m._helper.isAlmostReal(e)&&m._helper.isAlmostReal(b)?(d=d.value.real,c=c.value.real,h=h.value.real,q=q.value.real,e=e.value.real,b=b.value.real,d=Math.sqrt((d-h)*
(d-h)+(c-q)*(c-q))-Math.sqrt((d-e)*(d-e)+(c-b)*(c-b))-Math.sqrt((h-e)*(h-e)+(q-b)*(q-b)),1E-15>d*d):!1}function Bc(a,g){a.isshowing=!0;if(a.args)for(var c=0;c<a.args.length;c++)if(!v.csnames[a.args[c]].isshowing){a.isshowing=!1;return}g.visiblecheck&&g.visiblecheck(a)}function Xc(a,g,c,q,b){var d=a.textsize||ga.textsize,h=!0===a.textbold,e=!0===a.textitalics,f=a.text_fontfamily||ga.fontFamily,k=q.x*q.x+q.y*q.y,l=1;0<k&&(l=1+a.size.value.real/Math.sqrt(k));a=a.alpha||m.real(ga.alpha);D.drawtext([c,
w.wrap(g)],{x_offset:w.wrap(l*q.x),y_offset:w.wrap(l*q.y),size:w.wrap(d),bold:w.wrap(h),italics:w.wrap(e),family:w.wrap(f),color:b,alpha:a})}function $d(a){a._bbox=null;if(a.isshowing&&!1!==a.visible){var g={size:a.size},c=a.homog,q=a.text,b=l[a.type].getText,q=b?b(a):q.replace(/@[$#]"([^"\\]|\\.)*"/g,function(a){var c,g;try{if(c=JSON.parse(a.substring(2)),g=v.csnames[c],!g)return"?"}catch(q){return"?"}switch(a.charAt(1)){case "$":return g.printname||c;case "#":return"V"!==g.kind?"?":Z(g.value)}}),
b=null;if(a.html)var d=a._textCache||{text:!1},h=a.html,e=h.parentNode,f=e.parentNode,b=function(c,g,q,b,oa){d.invisible&&f.style.removeProperty("display");if(c!==d.text||g!==d.font||q!==d.x||b!==d.y||oa!==d.align){g!==d.font&&(h.style.font=g,h.style.lineHeight=ga.lineHeight);c!==d.text&&!1!==c&&!1===Bd(h,c,g)&&(c=!1);f.style.left=q+"px";f.style.top=b+"px";if(oa||e.style.transform)e.style.transform="translateX("+-100*oa+"%)";a._textCache={text:c,font:g,x:q,y:b,align:oa}}};q=w.string(q);a.dock&&(a.dock.to?
c=v.csnames[a.dock.to].homog:Cd.hasOwnProperty(a.dock.corner)&&(c=t.screenbounds$0([],{}),c=c.value[Cd[a.dock.corner]]),g.offset=a.dock.offset);a.align&&(g.align=w.string(a.align));c&&(a._bbox=D.drawtext([c,q],g,b))}else a.html&&(a.html.parentNode.parentNode.style.display="none",a._textCache={invisible:!0})}function Zd(){function a(){var a=e++/c._traces.length,g=c._traces[h];g&&(a*=q*a*a,t.draw$1([g],{size:m.real(b),color:c.color,alpha:m.real(a)}));b*=d}for(var g=0;g<v.points.length;g++){var c=v.points[g];
if(c.drawtrace){c._traces_tick===c.traceskip?(c._traces[c._traces_index]=c.homog,c._traces_index=(c._traces_index+1)%c._traces.length,c._traces_tick=0):c._traces_tick++;var q=c.alpha.value.real,b=c.size.value.real,d=1;1!==c.tracedim&&(b*=c.tracedim,d=Math.pow(c.tracedim,-1/c._traces.length));var h,e=0;for(h=c._traces_index;h<c._traces.length;++h)a();for(h=0;h<c._traces_index;++h)a()}}}function kb(a,g){var c="Assertion failed: "+g;if(!a)throw console.log(c),Ta(),"undefined"!==typeof alert&&alert(c),
Error(c);}function me(a){if(a!==Da.length){var g,c,q=Cc.length;nb.length<a*q?(g=2*a,nb=new Float64Array(q*g)):g=nb.length/q|0;for(c=0;c<q;++c)ib[Cc[c]]=nb.subarray(c*g,c*g+a);a=Da;qa=ib["in"];Oa=ib.out;Da=ib.good;Da.set(a)}}function zb(){Da.set(qa);Ma=!1;Dd(!1);for(var a=Da.length,g=Math.abs,c=0;c<a;c+=2)g(Da[c])>1E12*g(Da[c+1])&&(Da[c+1]=0)}function ec(){if(Ab)Ma=!0;else throw Ed;}function Fd(a,g,c,q,b){return w.add(q,w.mult(c,w.sub(b,q)))}function Yd(){L&&(L.currentMouseAndScripts=[]);Dc=!0;if(ja){var a=
ja.mover,g=h.realVector([aa.x+ja.offset.x,aa.y+ja.offset.y,1]);Gd(a,g,"mouse");ja.prev.x=aa.x;ja.prev.y=aa.y}z(R.move);z(R.draw);Ma||zb();Dc=!1;L&&(L.fullLog.push(h.turnIntoCSList([h.turnIntoCSList(L.currentMouseAndScripts)])),L.length>L.logLength&&L.splice(0,L.length-L.logLength),L.currentMouseAndScripts=null,L.postMouseHooks.forEach(function(a){a()}))}function La(a,g,c){Gd(a,g,c);Dc||Ma||zb()}function Gd(a,g,c){L&&L.currentMouseAndScripts&&(L.currentMover=[]);a===Hd?(qa.set(Da),Ma=!1):(Hd=a,zb());
Oa.set(qa);var q=1E4,b;b=dc[a.name];if(!b){var d={},e=0;b=[];d[a.name]=a;for(var f=v.gslp,k=0;k<f.length;++k){var n=f[k],Wa=n.args;if(Wa)for(var p=0;p<Wa.length;++p)d.hasOwnProperty(Wa[p])&&(d[n.name]=n,b[e++]=n)}dc[a.name]=b}var d=-1,e=.9,r,t,u,f=l[a.type],k=f.parameterPath||Fd;Ba=a.stateIdx;n=f.getParamFromState(a);Ba=Ea=a.stateIdx;Wa=f.getParamForInput(a,g,c);for(p=d+e;d!==p;){var x=p*p,y=.5/(1+x),y=m.complex(2*p*y+.5,(1-x)*y);Ab=d+.5*e<=d||0===q;0===q&&console.log("tracing limit Reached");x=!1;
L&&L.currentMouseAndScripts&&(L.currentStep=[]);try{Ba=Ea=a.stateIdx;var A=k(a,p,y,n,Wa);L&&(L.currentParam=A);y=Oa;Oa=qa;f.putParamToState(a,A);Oa=y;Ea=a.stateIdx;L&&(L.currentElement=a);f.updatePosition(a,!0);kb(Ba===a.stateIdx+f.stateSize,"State fully consumed");kb(Ea===a.stateIdx+f.stateSize,"State fully updated");for(r=0;r<b.length;++r)t=b[r],u=l[t.type],Ba=Ea=t.stateIdx,L&&(L.currentElement=t),u.updatePosition(t,!1),kb(Ba===t.stateIdx+u.stateSize,"State fully consumed"),kb(Ea===t.stateIdx+u.stateSize,
"State fully updated");L&&(L.currentElement=null);d=p;e*=1.25;p+=e;1<=p&&(p=1);Oa=qa;qa=y}catch(z){if(z!==Ed)throw z;e*=.5;p=d+e;--q;x=!0}L&&L.currentMouseAndScripts&&(L.currentMover.push(h.turnIntoCSList([h.turnIntoCSList(L.currentStep),w.wrap(x),w.wrap(d),w.wrap(p),w.wrap(L.currentParam)])),L.currentStep=null,L.currentParam=null)}Dd(Ma);for(r=0;r<b.length;++r)t=b[r],u=l[t.type],Bc(t,u);L&&L.currentMouseAndScripts&&(L.currentMouseAndScripts.push(h.turnIntoCSList([h.turnIntoCSList(L.currentMover),
w.wrap(Ma),w.wrap(a.name),g,w.wrap(c),n,Wa])),L.currentMover=null)}function Vd(){zb();Ab=!0;for(var a=v.gslp,g=0;g<a.length;g++){var c=a[g],q=l[c.type];Ba=Ea=c.stateIdx;q.updatePosition(c,!1);Bc(c,q)}a=Oa;Oa=qa;qa=a;zb()}function Dd(a){var g=p.tracingStateReport;"string"===typeof g&&(document.getElementById(g).textContent=a?"BAD":"GOOD")}function ne(){return h.turnIntoCSList(L.fullLog.slice())}function oe(a){var g=JSON.stringify(L.fullLog);a=new Blob([g],{type:a?"application/octet-stream":"application/json"});
return window.URL.createObjectURL(a)}function Bb(){var a=Ba;Ba+=2;return m.complex(qa[a],qa[a+1])}function X(a){for(var g=Array(a),c=0;c<a;++c)g[c]=Bb();return h.turnIntoCSList(g)}function Za(a){Oa[Ea]=a.value.real;Oa[Ea+1]=a.value.imag;Ea+=2}function T(a){for(var g=0,c=a.value.length;g<c;++g)Za(a.value[g])}function Pa(a,g){var c=X(3),q=X(3),c=Ec(a,g,c,q);T(c[0]);T(c[1]);return h.turnIntoCSList(c)}function Ec(a,g,c,q){if(lb)return[a,g];var b=h.projectiveDistMinScal(c,a),d=h.projectiveDistMinScal(c,
g),e=h.projectiveDistMinScal(q,a),f=h.projectiveDistMinScal(q,g),m=h.projectiveDistMinScal(c,q),l=h.projectiveDistMinScal(a,g),n=b+f,p=d+e,r;n>p?(r=[g,a],n=p):r=[a,g];p=function(){};if(L&&L.currentStep){var t=[L.labelTracing2,w.wrap(L.currentElement.name),h.turnIntoCSList(r),h.turnIntoCSList([c,q]),h.realMatrix([[b,d],[e,f]]),w.wrap(n),w.wrap(m),w.wrap(l),k];L.currentStep.push(h.turnIntoCSList(t));p=function(a){L.hasOwnProperty(a)||(L[a]=w.wrap(a));t[t.length-1]=L[a]}}h._helper.isNaN(a)||h._helper.isNaN(g)?
(p("Tracing failed due to NaNs."),Ma=!0):m>3*n&&l>3*n?p("Normal case, everything all right."):1E-5>l?1E-5>m?p("Staying inside singularity."):(p("Moved into singularity."),Ma=!0):1E-5>m?p("Moved out of singularity."):(Ab?p("Reached refinement limit, giving up."):p("Need to refine."),ec());return r}function Fc(a,g,c,q){var b=X(3),d=X(3),e=X(3),f=X(3);a=pe(a,g,c,q,b,d,e,f);T(a[0]);T(a[1]);T(a[2]);T(a[3]);return h.turnIntoCSList(a)}function pe(a,g,c,q,b,d,e,f){var m=function(){};b=[b,d,e,f];a=[a,g,c,
q];if(lb)return a;d=0;q=Array(4);for(c=0;4>c;c++)for(q[c]=Array(4),f=0;4>f;f++)e=h.projectiveDistMinScal(b[c],a[f]),q[c][f]=e;e=uc(q);g=Array(4);for(c=0;4>c;++c)g[c]=a[e[c]],d+=q[c][e[c]];var l=1*d,n=Infinity,p=Infinity;for(c=0;4>c;c++){if(h._helper.isNaN(a[c]))return m("Tracing failed due to NaNs."),Ma=!0,g;for(f=c+1;4>f;f++)e=h.projectiveDistMinScal(b[c],b[f]),n>e&&(n=e),e=h.projectiveDistMinScal(g[c],g[f]),p>e&&(p=e)}if(L&&L.currentStep){var r=[L.labelTracing4,w.wrap(L.currentElement.name),h.turnIntoCSList(g),
h.turnIntoCSList(b),h.realMatrix(q),w.wrap(d),w.wrap(n),w.wrap(p),k];L.currentStep.push(h.turnIntoCSList(r));m=function(a){L.hasOwnProperty(a)||(L[a]=w.wrap(a));r[r.length-1]=L[a]}}n>l&&p>l||(1E-5>p?1E-5>n?m("Staying inside singularity."):(m("Moved into singularity."),Ma=!0):1E-5>n?m("Moved out of singularity."):(Ab?m("Reached refinement limit, giving up."):m("Need to refine."),ec()));return g}function Id(a){var g=a.length,c,q;if(lb){for(c=0;c<g;++c)Ba+=2*a[c].value.length,T(a[c]);return a}var b=
Array(g),d=Array(g),e=Array(g),f=99,m=99,l=Array(g);for(c=0;c<g;++c)b[c]=X(a[c].value.length),d[c]=h.normSquared(b[c]).value.real,e[c]=h.normSquared(a[c]).value.real,l[c]=Array(g);var n;for(c=0;c<g;++c){for(q=0;q<g;++q)n=h.sesquilinearproduct(b[c],a[q]).value,n=(n.real*n.real+n.imag*n.imag)/(d[c]*e[q]),l[c][q]=1-n;for(q=c+1;q<g;++q)n=h.sesquilinearproduct(b[c],b[q]).value,n=(n.real*n.real+n.imag*n.imag)/(d[c]*d[q]),f>1-n&&(f=1-n),n=h.sesquilinearproduct(a[c],a[q]).value,n=(n.real*n.real+n.imag*n.imag)/
(e[c]*e[q]),m>1-n&&(m=1-n)}n=uc(l);q=Array(g);d=0;e=!1;for(c=0;c<g;++c){var d=d+l[c][n[c]],p=q[c]=a[n[c]];T(p);e|=h._helper.isNaN(p)}e|=isNaN(d);a=function(){};if(L&&L.currentStep){var r=[L.labelTracingSesq,w.wrap(L.currentElement.name),h.turnIntoCSList(q),h.turnIntoCSList(b),h.realMatrix(l),w.wrap(d),w.wrap(f),w.wrap(m),k];L.currentStep.push(h.turnIntoCSList(r));a=function(a){L.hasOwnProperty(a)||(L[a]=w.wrap(a));r[r.length-1]=L[a]}}e?(a("Tracing failed due to NaNs."),Ma=!0):f>3*d&&m>3*d?a("Normal case, everything all right."):
1E-5>m?1E-5>f?a("Staying inside singularity."):(a("Moved into singularity."),Ma=!0):1E-5>f?a("Moved out of singularity."):(Ab?a("Reached refinement limit, giving up."):a("Need to refine."),ec());return q}function Qb(a,g){var c=l._helper.flattenConicMatrix(a),q=l._helper.flattenConicMatrix(g),b=X(6),d=X(6),q=Ec(c,q,b,d);T(q[0]);T(q[1]);c=l._helper.buildConicMatrix(q[0].value);q=l._helper.buildConicMatrix(q[1].value);return h.turnIntoCSList([c,q])}function mb(a){if(mb.hasOwnProperty(a.kind))mb[a.kind](a)}
function Jd(a,g){return function(){a.incidences.push(g.name);g.incidences.push(a.name)}}function Kd(a,g){return{toString:function(){return"point "+a.name+" incident line "+g.name},apply:Jd(a,g),holds:function(){var c=h.scaldiv(h.abs(a.homog),a.homog),q=h.scaldiv(h.abs(g.homog),g.homog);return 1E-13>m.abs(h.scalproduct(c,q)).value.real}}}function Ld(a,g){return{toString:function(){return"point "+a.name+" incident conic "+g.name},apply:Jd(a,g),holds:function(){var c=w.mult(g.matrix,a.homog),c=w.mult(a.homog,
c),c=m.abs(c);1E-13>c.value.real&&(a.incidences.push(g.name),g.incidences.push(a.name))}}}function xd(){if(0!==ob.length){for(var a=0;a<ob.length;++a)ob[a].apply();ob=[]}}function Gc(a,g,c){var q=document.createElement("div"),b=document.createElement("img");b.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAPoCAQAAAC1v1zVAAAAGklEQVR42u3BMQEAAADCoPVPbQ0PoAAAgHcDC7gAAVI8ZnwAAAAASUVORK5CYII=";q.className="CindyJS-baseline";q.appendChild(b);b=document.createElement("div");b.className="CindyJS-button";
q.appendChild(b);for(var d=2;d<arguments.length;++d)b.appendChild(arguments[d]);na.parentNode.appendChild(q);a.html=arguments[arguments.length-1];Ia(a.fillalpha)||(a.fillalpha=1);a.fillcolor&&(a.html.style.backgroundColor=x.makeColor(a.fillcolor,a.fillalpha));q=e;if(a.script)var h=Ua(a.script),q=function(){z(h);e()};c.addEventListener(g,q);!p.keylistener&&(R.keydown||R.keyup||R.keytyped)&&(c.addEventListener("keydown",function(a){9!==a.keyCode&&I(a,R.keydown)}),c.addEventListener("keyup",function(a){I(a,
R.keyup)}),c.addEventListener("keypress",function(a){9!==a.keyCode&&I(a,R.keytyped)}));l.Text.initialize(a)}function Sa(){}function qe(a){if(!/^Select/.test(a.type)&&!l[a.type].isMovable)return null;var g=w.unwrap,c=m.add;switch(a.kind){case "P":case "L":case "Text":return g(a.homog);case "C":return a=a.matrix.value,{xx:g(a[0].value[0]),yy:g(a[1].value[1]),zz:g(a[2].value[2]),xy:g(c(a[0].value[1],a[1].value[0])),xz:g(c(a[0].value[2],a[2].value[0])),yz:g(c(a[1].value[2],a[2].value[1]))};default:return null}}
function re(a){var g={};g.offset=w.unwrap(a.offset);a.to&&(g.to=a.to);a.corner&&(g.corner=a.corner);return g}function se(a){var g={};te.forEach(function(c){if(a.hasOwnProperty(c)){var b=w.unwrap(a[c]);null!==b&&void 0!==b&&(g[c]=b)}});if("P"===a.kind&&(!a.movable||a.pinned)&&g.color){var c=m.real(1/ga.dimDependent);g.color=w.unwrap(h.scalmult(c,a.color))}if(c=qe(a))g.pos=c;a.dock&&(g.dock=re(a.dock));return g}function ue(){var a=[];v.gslp.forEach(function(g){g.tmp||a.push(se(g))});return a}function Wd(){Fa.forEach(function(a){var g=
(a.geo||[]).map(function(a){return v.csnames[a]});O[a.type].reset(a,g[0],g)})}function nc(a){qc=0!==a.length;Fa=[];ma=[];Hc=[];O.Environment.init({});a.forEach(function(a){a.behavior?(a.name&&(a.behavior.geo=[a.name]),a=a.behavior,a.gravity&&(a.gravity=-a.gravity)):c=a.geo;var c=(a.geo||[]).map(function(a){return v.csnames[a]}),q=c[0],b=O[a.type];b?(b.init&&b.init(a,q,c),q&&(q.behavior=a,"Mass"===a.type?ma.push(q):"Spring"===a.type&&Hc.push(q)),Fa.push(a)):(console.error(a),console.error("Behavior "+
a.type+" not implemented yet"))})}var va=this,wa,R={},cb=!1,Xb=!0,Ib=0,Vc=.5,pc=0,Vb=10,Md=5/360,Xd=.32/Md/1E3*2,Tb=1,za=0,lc=0,Eb=!1,Fb=!1,na,Db,Ia=Number.isFinite||function(a){return"number"===typeof a&&isFinite(a)},ra,A,ca,da,v,bb,rc=k,sc=k,Va={play:Sa,pause:Sa,stop:Sa},oc=null,Gb=function(a,g){var c=[];Gb=function(a,g){c.push({img:a,id:g})};Gb(a,g);var q=va.getBaseDir()+"images/Icons.svg",b=new XMLHttpRequest;b.onreadystatechange=function(){if(b.readyState===XMLHttpRequest.DONE)if(200!==b.status)console.error("Failed to load CindyJS Icons.svg from "+
q+": "+b.statusText);else{var a=b.responseXML,g=a.documentElement,d={},h,e;for(h=g.firstChild;h;h=e)e=h.nextSibling,h.nodeType===Node.ELEMENT_NODE&&"http://www.w3.org/2000/svg"===h.namespaceURI&&"g"===h.localName.toLowerCase()&&(g.removeChild(h),h.setAttribute("style","display:inline"),d[h.getAttribute("id")]=h);var f=new XMLSerializer;Gb=function(c,q){if(d.hasOwnProperty(q)){var b=d[q];g.appendChild(b);var h;try{h=f.serializeToString(a)}finally{g.removeChild(b)}c.src="data:image/svg+xml;charset=utf-8,"+
encodeURIComponent(h)}};c.forEach(function(a){Gb(a.img,a.id)});c=null}};b.responseType="document";b.open("GET",q);b.send()},Wc=1,Hb=null,jb=[],Yb=!1,sa={config:p,startup:S,shutdown:Ta,evokeCS:function(a){a=Ua(a,!1);z(a);e()},play:M,pause:Ga,stop:Ha,evalcs:function(a){return z(Ua(a,!1))},parse:function(a){return Ua(a)},niceprint:Z,canvas:null},kc=!1,Ub=0;p.use&&p.use.forEach(function(a){var g=null;p.plugins&&(g=p.plugins[a]);g||(g=va._pluginRegistry[a]);g||(++Ub,console.log("Loading script for plugin "+
a),va.loadScript(a+"-plugin",a+"-plugin.js",function(){console.log("Successfully loaded plugin "+a);0===--Ub&&kc&&S()},function(){console.error("Failed to auto-load plugin "+a);0===--Ub&&kc&&S()}))});Cb.prototype=new fb;gb.prototype=new fb;ua.prototype=new fb;var aa={},ja,Yc="",Zc=0,Zb;Zb=p.isNode?process.nextTick:window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,
0)};var tc=null,ve=[0,8,7,0,"g8c01b8d"],m={_helper:{}};m._helper.roundingfactor=1E4;m._helper.angleroundingfactor=10;m._helper.niceround=function(a,g){return Math.round(a*g)/g};m.niceprint=function(a,g){g=g||m._helper.roundingfactor;if("Angle"===a.usage)return m._helper.niceangle(a);var c=m._helper.niceround(a.value.real,g),q=m._helper.niceround(a.value.imag,g);return 0===q?""+c:0<q?""+c+" + i*"+q:""+c+" - i*"+-q};var Ic=p.angleUnit||"\u00b0",we=Ic.replace(/\s+/g,""),Nd=2*Math.PI,xe=1/Nd,ye={rad:Nd,
"\u00b0":360,deg:360,degree:360,gra:400,grad:400,turn:1,cyc:1,rev:1,rot:1,"\u03c0":2,pi:2,quad:4};m._helper.niceangle=function(a){var g=ye[we];if(!g)return m.niceprint(w.withUsage(a,null));if("function"===typeof g)return g(a);a=m.niceprint(m.realmult(g*xe,a),200<g?m._helper.angleroundingfactor:null);return-1===a.indexOf("i*")?a+Ic:"("+a+")"+Ic};m.complex=function(a,g){return{ctype:"number",value:{real:a,imag:g}}};m.real=function(a){return{ctype:"number",value:{real:a,imag:0}}};m.zero=m.real(0);m.one=
m.real(1);m.infinity=m.complex(Infinity,Infinity);m.nan=m.complex(NaN,NaN);m._helper.input=function(a){return"object"===typeof a?m.complex(+a.r,+a.i):m.real(+a)};m.argmax=function(a,g){return a.value.real*a.value.real+a.value.imag*a.value.imag<g.value.real*g.value.real+g.value.imag*g.value.imag?g:a};m.max=function(a,g){return{ctype:"number",value:{real:Math.max(a.value.real,g.value.real),imag:Math.max(a.value.imag,g.value.imag)}}};m.min=function(a,g){return{ctype:"number",value:{real:Math.min(a.value.real,
g.value.real),imag:Math.min(a.value.imag,g.value.imag)}}};m.add=function(a,g){return{ctype:"number",value:{real:a.value.real+g.value.real,imag:a.value.imag+g.value.imag}}};m.sub=function(a,g){return{ctype:"number",value:{real:a.value.real-g.value.real,imag:a.value.imag-g.value.imag}}};m.neg=function(a){return{ctype:"number",value:{real:-a.value.real,imag:-a.value.imag}}};m.re=function(a){return{ctype:"number",value:{real:a.value.real,imag:0}}};m.im=function(a){return{ctype:"number",value:{real:a.value.imag,
imag:0}}};m.conjugate=function(a){return{ctype:"number",value:{real:a.value.real,imag:-a.value.imag}}};m.round=function(a){return{ctype:"number",value:{real:Math.round(a.value.real),imag:Math.round(a.value.imag)}}};m.ceil=function(a){return{ctype:"number",value:{real:Math.ceil(a.value.real),imag:Math.ceil(a.value.imag)}}};m.floor=function(a){return{ctype:"number",value:{real:Math.floor(a.value.real),imag:Math.floor(a.value.imag)}}};m.mult=function(a,g){return{ctype:"number",value:{real:a.value.real*
g.value.real-a.value.imag*g.value.imag,imag:a.value.real*g.value.imag+a.value.imag*g.value.real}}};m.realmult=function(a,g){return{ctype:"number",value:{real:a*g.value.real,imag:a*g.value.imag}}};m.multiMult=function(a){var g=a[0];if("number"!==g.ctype)return k;for(var c=1;c<a.length;c++){if("number"!==a[c].ctype)return k;g=m.mult(g,a[c])}return g};m.abs2=function(a){return{ctype:"number",value:{real:a.value.real*a.value.real+a.value.imag*a.value.imag,imag:0}}};m.abs=function(a){return m.sqrt(m.abs2(a))};
m.inv=function(a){var g=a.value.real*a.value.real+a.value.imag*a.value.imag;return{ctype:"number",value:{real:a.value.real/g,imag:-a.value.imag/g}}};m.div=function(a,g){var c=a.value.real,q=a.value.imag,b=g.value.real,d=g.value.imag,h=b*b+d*d;return{ctype:"number",value:{real:(c*b+q*d)/h,imag:(q*b-c*d)/h}}};m.eps=1E-10;m.epsbig=1E-6;m.snap=function(a){var g=a.value.real;a=a.value.imag;Math.floor(g+m.eps)!==Math.floor(g-m.eps)&&(g=Math.round(g));Math.floor(a+m.eps)!==Math.floor(a-m.eps)&&(a=Math.round(a));
return{ctype:"number",value:{real:g,imag:a}}};m.exp=function(a){var g=Math.exp(a.value.real);return{ctype:"number",value:{real:g*Math.cos(a.value.imag),imag:g*Math.sin(a.value.imag)}}};m.cos=function(a){var g=a.value.real;a=a.value.imag;var c=Math.exp(a),q=c*Math.sin(-g),b=c*Math.cos(-g),c=Math.exp(-a);return{ctype:"number",value:{real:(b+c*Math.cos(g))/2,imag:(q+c*Math.sin(g))/2}}};m.sin=function(a){var g=a.value.real;a=a.value.imag;var c=Math.exp(a),q=c*Math.sin(-g),b=c*Math.cos(-g),c=Math.exp(-a);
return{ctype:"number",value:{real:-(q-c*Math.sin(g))/2,imag:(b-c*Math.cos(g))/2}}};m.tan=function(a){var g=m.sin(a);a=m.cos(a);return m.div(g,a)};m.arccos=function(a){var g=m.mult(a,m.neg(a)),g=m.sqrt(m.add(m.real(1),g));a=m.add(m.mult(a,m.complex(0,1)),g);a=m.add(m.mult(m.log(a),m.complex(0,1)),m.real(.5*Math.PI));return w.withUsage(a,"Angle")};m.arcsin=function(a){var g=m.mult(a,m.neg(a)),g=m.sqrt(m.add(m.real(1),g));a=m.add(m.mult(a,m.complex(0,1)),g);a=m.mult(m.log(a),m.complex(0,-1));return w.withUsage(a,
"Angle")};m.arctan=function(a){var g=m.log(m.add(m.mult(a,m.complex(0,-1)),m.real(1)));a=m.log(m.add(m.mult(a,m.complex(0,1)),m.real(1)));g=m.mult(m.sub(g,a),m.complex(0,.5));return w.withUsage(g,"Angle")};m.arctan2=function(a,g){var c;if(void 0===g)c=m.real(Math.atan2(a.value.imag,a.value.real));else if(m._helper.isReal(a)&&m._helper.isReal(g))c=m.real(Math.atan2(g.value.real,a.value.real));else{c=m.add(a,m.mult(m.complex(0,1),g));var q=m.sqrt(m.add(m.mult(a,a),m.mult(g,g)));c=m.mult(m.complex(0,
-1),m.log(m.div(c,q)))}return w.withUsage(c,"Angle")};m.sqrt=function(a){var g=a.value.real,c=a.value.imag;a=Math.sqrt(Math.sqrt(g*g+c*c));g=Math.atan2(c,g);return{ctype:"number",value:{real:a*Math.cos(g/2),imag:a*Math.sin(g/2)}}};m.powRealExponent=function(a,g){var c=a.value.real,q=a.value.imag,b=Math.pow(Math.sqrt(c*c+q*q),g),c=Math.atan2(q,c);return{ctype:"number",value:{real:b*Math.cos(c*g),imag:b*Math.sin(c*g)}}};m.log=function(a){var g=a.value.real;a=a.value.imag;var c=Math.sqrt(g*g+a*a),q=
Math.atan2(a,g);0>a&&(q+=2*Math.PI);0===a&&0>g&&(q=Math.PI);q>Math.PI&&(q-=2*Math.PI);return m.snap({ctype:"number",value:{real:Math.log(c),imag:q}})};m.pow=function(a,g){return m._helper.isZero(g)?m.one:m._helper.isZero(a)?m.zero:m._helper.isReal(g)?m.powRealExponent(a,g.value.real):m.exp(m.mult(m.log(a),g))};m.mod=function(a,g){var c=a.value.real,q=g.value.real,b=a.value.imag,d=g.value.imag,c=c-Math.floor(c/q)*q,b=b-Math.floor(b/d)*d;0===q&&(c=0);0===d&&(b=0);return m.snap({ctype:"number",value:{real:c,
imag:b}})};m._helper.seed="NO";m._helper.seedrandom=function(a){a-=Math.floor(a);m._helper.seed=.8*a+.1};m._helper.rand=function(){if("NO"===m._helper.seed)return Math.random();var a=m._helper.seed,a=1E3*Math.sin(1E3*a),a=a-Math.floor(a);return m._helper.seed=a};m._helper.randnormal=function(){var a=m._helper.rand(),g=m._helper.rand();return Math.sqrt(-2*Math.log(a))*Math.cos(2*Math.PI*g)};m._helper.isEqual=function(a,g){return a.value.real===g.value.real&&a.value.imag===g.value.imag};m._helper.isLessThan=
function(a,g){return a.value.real<g.value.real||a.value.real===g.value.real&&a.value.imag<g.value.imag};m._helper.compare=function(a,g){return m._helper.isLessThan(a,g)?-1:m._helper.isEqual(a,g)?0:1};m._helper.isAlmostEqual=function(a,g,c){var q=m.eps;"undefined"!==typeof c&&(q=c);c=a.value.real-g.value.real;a=a.value.imag-g.value.imag;return c<q&&c>-q&&a<q&&a>-q};m._helper.isZero=function(a){return 0===a.value.real&&0===a.value.imag};m._helper.isAlmostZero=function(a){var g=a.value.real;a=a.value.imag;
return g<m.eps&&g>-m.eps&&a<m.eps&&a>-m.eps};m._helper.isReal=function(a){return 0===a.value.imag};m._helper.isAlmostReal=function(a){a=a.value.imag;return a<m.epsbig&&a>-m.epsbig};m._helper.isNaN=function(a){return isNaN(a.value.real)||isNaN(a.value.imag)};m._helper.isFinite=function(a){return isFinite(a.value.real)&&isFinite(a.value.imag)};m._helper.isAlmostImag=function(a){a=a.value.real;return a<m.epsbig&&a>-m.epsbig};m._helper.z3a=m.complex(-.5,.5*Math.sqrt(3));m._helper.z3b=m.complex(-.5,-.5*
Math.sqrt(3));m._helper.cub1={ctype:"list",value:[m.one,m.one,m.one]};m._helper.cub2={ctype:"list",value:[m._helper.z3a,m.one,m._helper.z3b]};m._helper.cub3={ctype:"list",value:[m._helper.z3b,m.one,m._helper.z3a]};m.solveCubic=function(a,g,c,q){a=m._helper.solveCubicHelper(a,g,c,q);return[h.scalproduct(m._helper.cub1,a),h.scalproduct(m._helper.cub2,a),h.scalproduct(m._helper.cub3,a)]};m._helper.solveCubicHelper=function(a,g,c,q){var b=a.value.real;a=a.value.imag;var d=g.value.real;g=g.value.imag;
var e=c.value.real,f=c.value.imag,k=q.value.real,l=q.value.imag,n=b*e-a*f;c=b*f+a*e;q=4*n-(d*d-g*g);var p=4*c-2*d*g,r=b*d-a*g,t=b*g+a*d,v=q*e-p*f-18*(r*k-t*l),p=q*f+p*e-18*(r*l+t*k);q=27*(b*b-a*a);var u=54*a*b,w=q*k-u*l,x=q*l+u*k,y=d*d-g*g,A=2*d*g,z=y*d-A*g,B=y*g+A*d,C=w+4*z,u=x+4*B;q=27*(v*e-p*f+C*k-u*l);p=27*(v*f+p*e+C*l+u*k);C=Math.sqrt(Math.sqrt(q*q+p*p));u=Math.atan2(p,q);p=C*Math.sin(u/2);q=C*Math.cos(u/2);z=-2*z+9*(r*e-t*f)-w+(q*b-p*a);B=-2*B+9*(r*f+t*e)-x+(q*a+p*b);q=Math.exp(Math.log(Math.sqrt(z*
z+B*B))/3);e=Math.atan2(B,z);u=q*Math.sin(e/3);p=q*Math.cos(e/3);q*=q;e*=2;n=2*y-6*n;c=2*A-6*c;A=-1.5874010519681996*(d*p-g*u);d=-1.5874010519681996*(d*u+g*p);g=1.2599210498948732*q*Math.cos(e/3);e=1.2599210498948732*q*Math.sin(e/3);q=4.762203155904599*(p*b-u*a);p=4.762203155904599*(p*a+u*b);b=q*q+p*p;u=(-n*p+c*q)/b;n=(n*q+c*p)/b;c=u;u=(-A*p+d*q)/b;A=(A*q+d*p)/b;d=u;u=(-g*p+e*q)/b;g=(g*q+e*p)/b;e=u;return h.turnIntoCSList([m.complex(n,c),m.complex(A,d),m.complex(g,e)])};var h={_helper:{},turnIntoCSList:function(a){return{ctype:"list",
value:a}}};h.EMPTY=h.turnIntoCSList([]);h.asList=function(a){return"list"===a.ctype?a:"number"===a.ctype||"boolean"===a.ctype||"geo"===a.ctype?h.turnIntoCSList([a]):h.EMPTY};h.realVector=function(a){for(var g=[],c=0;c<a.length;c++)g[c]={ctype:"number",value:{real:a[c],imag:0}};return{ctype:"list",value:g}};h._helper.unitvector=function(a,g){var c=h.zerovector(a);c.value[Math.floor(g.value.real-1)]=m.real(1);return c};h.idMatrix=function(a){for(var g=h.zeromatrix(a,a),c=m.real(1),q=0;q<a.value.real;q++)g.value[q].value[q]=
c;return g};h._helper.flippedidMatrix=function(a){for(var g=h.zeromatrix(a,a),c=m.real(1),q=0;q<a.value.real;q++)g.value[q].value[a.value.real-q-1]=c;return g};h.println=function(a){for(var g=[],c=0;c<a.value.length;c++)if("number"===a.value[c].ctype)g[c]=m.niceprint(a.value[c]);else if("list"===a.value[c].ctype)h.println(a.value[c]);else return k;"number"===a.value[0].ctype&&console.log(g)};h.matrix=function(a){return h.turnIntoCSList(a.map(h.turnIntoCSList))};h.realMatrix=function(a){for(var g=
a.length,c=Array(g),q=0;q<g;q++)c[q]=h.realVector(a[q]);return h.turnIntoCSList(c)};h.ex=h.realVector([1,0,0]);h.ey=h.realVector([0,1,0]);h.ez=h.realVector([0,0,1]);h.linfty=h.realVector([0,0,1]);h.ii=h.turnIntoCSList([m.complex(1,0),m.complex(0,1),m.complex(0,0)]);h.jj=h.turnIntoCSList([m.complex(1,0),m.complex(0,-1),m.complex(0,0)]);h.fundDual=h.realMatrix([[1,0,0],[0,1,0],[0,0,0]]);h.fund=h.realMatrix([[0,0,0],[0,0,0],[0,0,1]]);h.sequence=function(a,g){for(var c=[],q=0,b=Math.round(a.value.real);b<
Math.round(g.value.real)+1;b++)c[q]={ctype:"number",value:{real:b,imag:0}},q++;return{ctype:"list",value:c}};h.pairs=function(a){for(var g=[],c=0;c<a.value.length-1;c++)for(var q=c+1;q<a.value.length;q++)g.push({ctype:"list",value:[a.value[c],a.value[q]]});return{ctype:"list",value:g}};h.triples=function(a){for(var g=[],c=0;c<a.value.length-2;c++)for(var q=c+1;q<a.value.length-1;q++)for(var b=q+1;b<a.value.length;b++)g.push({ctype:"list",value:[a.value[c],a.value[q],a.value[b]]});return{ctype:"list",
value:g}};h.cycle=function(a){for(var g=[],c=0;c<a.value.length-1;c++)g[c]={ctype:"list",value:[a.value[c],a.value[c+1]]};g.push({ctype:"list",value:[a.value[a.value.length-1],a.value[0]]});return{ctype:"list",value:g}};h.consecutive=function(a){for(var g=[],c=0;c<a.value.length-1;c++)g[c]={ctype:"list",value:[a.value[c],a.value[c+1]]};return{ctype:"list",value:g}};h.reverse=function(a){for(var g=Array(a.value.length),c=a.value.length-1,q=0;0<=c;c--,q++)g[q]=a.value[c];return{ctype:"list",value:g}};
h.directproduct=function(a,g){for(var c=[],q=0;q<a.value.length;q++)for(var b=0;b<g.value.length;b++)c.push({ctype:"list",value:[a.value[q],g.value[b]]});return{ctype:"list",value:c}};h.concat=function(a,g){for(var c=[],q=0;q<a.value.length;q++)c.push(a.value[q]);for(q=0;q<g.value.length;q++)c.push(g.value[q]);return{ctype:"list",value:c}};h.prepend=function(a,g){var c=[];c[0]=a;for(var q=0;q<g.value.length;q++)c[q+1]=g.value[q];return{ctype:"list",value:c}};h.append=function(a,g){for(var c=[],q=
0;q<a.value.length;q++)c[q]=a.value[q];c.push(g);return{ctype:"list",value:c}};h.contains=function(a,g){for(var c=0;c<a.value.length;c++)if(D.equals(a.value[c],g).value)return{ctype:"boolean",value:!0};return{ctype:"boolean",value:!1}};h.common=function(a,g){for(var c=[],q=0,b=0;b<a.value.length;b++){for(var d=!1,h=a.value[b],e=0;e<g.value.length;e++)d=d||D.equals(h,g.value[e]).value;d&&(c[q]=a.value[b],q++)}return{ctype:"list",value:c}};h.remove=function(a,g){for(var c=[],q=0,b=0;b<a.value.length;b++){for(var d=
!1,h=a.value[b],e=0;e<g.value.length;e++)d=d||D.equals(h,g.value[e]).value;d||(c[q]=a.value[b],q++)}return{ctype:"list",value:c}};h.sort1=function(a){a=a.value.slice();a.sort(w.compare);return h.turnIntoCSList(a)};h._helper.isEqual=function(a,g){return h.equals(a,g).value};h._helper.isLessThan=function(a,g){for(var c=a.value.length,q=g.value.length,b=0;!(b>=c||b>=q)&&w.isEqual(a.value[b],g.value[b]);)b++;return b===c&&b<q?!0:b===q&&b<c||b===c&&b===q?!1:w.isLessThan(a.value[b],g.value[b])};h._helper.compare=
function(a,g){return h._helper.isLessThan(a,g)?-1:h._helper.isEqual(a,g)?0:1};h.equals=function(a,g){if(a.value.length!==g.value.length)return{ctype:"boolean",value:!1};for(var c=!0,q=0;q<a.value.length;q++)var b=a.value[q],d=g.value[q],c="list"===b.ctype&&"list"===d.ctype?c&&h.equals(b,d).value:c&&vb([b,d],[]).value;return{ctype:"boolean",value:c}};h.almostequals=function(a,g){if(a.value.length!==g.value.length)return{ctype:"boolean",value:!1};for(var c=!0,q=0;q<a.value.length;q++)var b=a.value[q],
d=g.value[q],c="list"===b.ctype&&"list"===d.ctype?c&&h.almostequals(b,d).value:c&&hc([b,d],[]).value;return{ctype:"boolean",value:c}};h._helper.isAlmostReal=function(a){for(var g=!0,c=0;c<a.value.length;c++)var q=a.value[c],g="list"===q.ctype?g&&h._helper.isAlmostReal(q):g&&m._helper.isAlmostReal(q);return g};h._helper.isAlmostZero=function(a){for(var g=0;g<a.value.length;g++){var c=a.value[g];if("list"===c.ctype){if(!h._helper.isAlmostZero(c))return!1}else if(!m._helper.isAlmostZero(c))return!1}return!0};
h._helper.isNaN=function(a){for(var g=!1,c=0;c<a.value.length;c++)var q=a.value[c],g="list"===q.ctype?g||h._helper.isNaN(q):g||m._helper.isNaN(q);return g};h.set=function(a){var g=[],c=0;a=a.value.slice();a.sort(w.compare);for(var q=0;q<a.length;q++)0!==q&&vb([g[g.length-1],a[q]],[]).value||(g[c]=a[q],c++);return{ctype:"list",value:g}};h.maxval=function(a){for(var g=m.zero,c=0;c<a.value.length;c++){var q=a.value[c];"number"===q.ctype&&(g=m.argmax(g,q));"list"===q.ctype&&(g=m.argmax(g,h.maxval(q)))}return g};
h.maxIndex=function(a,g,c){var q=0;void 0!==c&&(q=c);c=q;for(var b=g(a.value[q]).value.real;q<a.value.length;++q){var d=g(a.value[q]).value.real;d>b&&(c=q,b=d)}return c};h.normalizeMax=function(a){var g=m.inv(h.maxval(a));return m._helper.isFinite(g)?h.scalmult(g,a):a};h.normalizeZ=function(a){var g=m.inv(a.value[2]);return h.scalmult(g,a)};h.dehom=function(a){a=a.value.slice();var g=a.length-1,c=m.inv(a[g]);a.length=g;for(var q=0;q<g;++q)a[q]=m.mult(c,a[q]);return h.turnIntoCSList(a)};h.normalizeAbs=
function(a){var g=m.inv(h.abs(a));return h.scalmult(g,a)};h.max=function(a,g){if(a.value.length!==g.value.length)return k;for(var c=[],q=0;q<a.value.length;q++)c[q]=w.max(a.value[q],g.value[q]);return{ctype:"list",value:c}};h.min=function(a,g){if(a.value.length!==g.value.length)return k;for(var c=[],q=0;q<a.value.length;q++)c[q]=w.min(a.value[q],g.value[q]);return{ctype:"list",value:c}};h.scaldiv=function(a,g){if("number"!==a.ctype)return k;for(var c=[],q=0;q<g.value.length;q++){var b=g.value[q];
c[q]="number"===b.ctype?w.div(b,a):"list"===b.ctype?h.scaldiv(a,b):k}return{ctype:"list",value:c}};h.scalmult=function(a,g){if("number"!==a.ctype)return k;for(var c=[],q=0;q<g.value.length;q++){var b=g.value[q];c[q]="number"===b.ctype?w.mult(b,a):"list"===b.ctype?h.scalmult(a,b):k}return{ctype:"list",value:c}};h.add=function(a,g){if(a.value.length!==g.value.length)return k;for(var c=[],q=0;q<a.value.length;q++){var b=a.value[q],d=g.value[q];c[q]="number"===b.ctype&&"number"===d.ctype?w.add(b,d):"list"===
b.ctype&&"list"===d.ctype?h.add(b,d):k}return{ctype:"list",value:c}};h.sub=function(a,g){if(a.value.length!==g.value.length)return k;for(var c=[],q=0;q<a.value.length;q++){var b=a.value[q],d=g.value[q];c[q]="number"===b.ctype&&"number"===d.ctype?m.sub(b,d):"list"===b.ctype&&"list"===d.ctype?h.sub(b,d):k}return{ctype:"list",value:c}};h.abs2=function(a){for(var g=0,c=0;c<a.value.length;c++){var q=a.value[c];if("number"===q.ctype)g+=m.abs2(q).value.real;else if("list"===q.ctype)g+=h.abs2(q).value.real;
else return k}return{ctype:"number",value:{real:g,imag:0}}};h.abs=function(a){return m.sqrt(h.abs2(a))};h.normalizeMaxXX=function(a){for(var g=-1E4,c=m.real(1),q=0;q<a.value.length;q++){var b=m.abs(a.value[q]);b.value.real>g&&(c=a.value[q],g=b.value.real)}return h.scaldiv(c,a)};h.recursive=function(a,g){for(var c=[],q=0;q<a.value.length;q++){var b=B(a.value[q]);c[q]="number"===b.ctype?m[g](b):"list"===b.ctype?h[g](b):k}return{ctype:"list",value:c}};h.re=function(a){return h.recursive(a,"re")};h.neg=
function(a){return h.recursive(a,"neg")};h.im=function(a){return h.recursive(a,"im")};h.conjugate=function(a){return h.recursive(a,"conjugate")};h.transjugate=function(a){return h.transpose(h.conjugate(a))};h.round=function(a){return h.recursive(a,"round")};h.ceil=function(a){return h.recursive(a,"ceil")};h.floor=function(a){return h.recursive(a,"floor")};h._helper.colNumb=function(a){if("list"!==a.ctype)return-1;for(var g=-1,c=0;c<a.value.length;c++){if("list"!==a.value[c].ctype)return-1;if(0===
c)g=a.value[c].value.length;else if(g!==a.value[c].value.length)return-1}return g};h._helper.isNumberVecN=function(a,g){if("list"!==a.ctype||a.value.length!==g)return!1;for(var c=0;c<a.value.length;c++)if("number"!==a.value[c].ctype)return!1;return!0};h.isNumberVector=function(a){if("list"!==a.ctype)return{ctype:"boolean",value:!1};for(var g=0;g<a.value.length;g++)if("number"!==a.value[g].ctype)return{ctype:"boolean",value:!1};return{ctype:"boolean",value:!0}};h.isNumberVectorN=function(a,g){if("list"!==
a.ctype)return{ctype:"boolean",value:!1};if(a.value)for(var c=0;c<a.value.length;c++)if("number"!==a.value[c].ctype)return{ctype:"boolean",value:!1};return{ctype:"boolean",value:!0}};h.isNumberMatrix=function(a){if(-1===h._helper.colNumb(a))return{ctype:"boolean",value:!1};for(var g=0;g<a.value.length;g++)if(!h.isNumberVector(a.value[g]).value)return{ctype:"boolean",value:!1};return{ctype:"boolean",value:!0}};h._helper.isNumberMatrixMN=function(a,g,c){return h.isNumberMatrix(a).value&&a.value.length===
g&&a.value[0].value.length===c};h.scalproduct=function(a,g){if(a.value.length!==g.value.length)return k;for(var c={ctype:"number",value:{real:0,imag:0}},q=0;q<g.value.length;q++){var b=a.value[q],d=g.value[q];if("number"===b.ctype&&"number"===d.ctype)c=m.add(m.mult(b,d),c);else return k}return c};h.sesquilinearproduct=function(a,g){if(a.value.length!==g.value.length)return k;for(var c=0,q=0,b=0;b<g.value.length;b++)var d=a.value[b].value,h=g.value[b].value,c=c+(d.real*h.real+d.imag*h.imag),q=q+(d.real*
h.imag-d.imag*h.real);return m.complex(c,q)};h.normSquared=function(a){for(var g=0,c=0;c<a.value.length;c++)var q=a.value[c].value,g=g+(q.real*q.real+q.imag*q.imag);return m.real(g)};h.productMV=function(a,g){if(a.value[0].value.length!==g.value.length)return k;for(var c=[],q=0;q<a.value.length;q++){for(var b={ctype:"number",value:{real:0,imag:0}},d=a.value[q],e=0;e<g.value.length;e++){var f=d.value[e],l=g.value[e];if("number"===f.ctype&&"number"===l.ctype)b=m.add(m.mult(f,l),b);else return k}c[q]=
b}return h.turnIntoCSList(c)};h.productVM=function(a,g){if(a.value.length!==g.value.length)return k;for(var c=[],q=0;q<g.value[0].value.length;q++){for(var b={ctype:"number",value:{real:0,imag:0}},d=0;d<a.value.length;d++){var e=a.value[d],f=g.value[d].value[q];if("number"===e.ctype&&"number"===f.ctype)b=m.add(m.mult(e,f),b);else return k}c[q]=b}return h.turnIntoCSList(c)};h.productMM=function(a,g){if(a.value[0].value.length!==g.value.length)return k;for(var c=[],q=0;q<a.value.length;q++){var b=h.productVM(a.value[q],
g);c[q]=b}return h.turnIntoCSList(c)};h.mult=function(a,g){return a.value.length===g.value.length&&h.isNumberVector(a).value&&h.isNumberVector(g).value?h.scalproduct(a,g):h.isNumberMatrix(a).value&&g.value.length===a.value[0].value.length&&h.isNumberVector(g).value?h.productMV(a,g):h.isNumberMatrix(g).value&&a.value.length===g.value.length&&h.isNumberVector(a).value?h.productVM(a,g):h.isNumberMatrix(a).value&&h.isNumberMatrix(g).value&&g.value.length===a.value[0].value.length?h.productMM(a,g):k};
h.projectiveDistMinScal=function(a,g){var c=h.abs(a),q=h.abs(g);if(0===c.value.real||0===q.value.real)return 0;var b=h.conjugate(g),b=h.scalproduct(a,b),b=m._helper.isAlmostZero(b)?m.real(1):m.div(b,m.abs(b)),c=h.scaldiv(c,a),q=h.scaldiv(q,g),q=h.scalmult(b,q),b=h.abs(h.add(c,q)),q=h.abs(h.sub(c,q));return Math.min(b.value.real,q.value.real)};h.conicDist=function(a,g){var c=u(a),q=u(g);console.log(Z(c),Z(q));return h.projectiveDistMinScal(c,q)};h.crossOperator=function(a){var g=a.value[0],c=a.value[1];
a=a.value[2];return h.turnIntoCSList([h.turnIntoCSList([m.zero,m.neg(a),c]),h.turnIntoCSList([a,m.zero,m.neg(g)]),h.turnIntoCSList([m.neg(c),g,m.zero])])};h.cross=function(a,g){var c=m.sub(m.mult(a.value[1],g.value[2]),m.mult(a.value[2],g.value[1])),q=m.sub(m.mult(a.value[2],g.value[0]),m.mult(a.value[0],g.value[2])),b=m.sub(m.mult(a.value[0],g.value[1]),m.mult(a.value[1],g.value[0]));return h.turnIntoCSList([c,q,b])};h.crossratio3harm=function(a,g,c,q,b){var d=h.det3(a,c,b),e=h.det3(g,q,b);a=h.det3(a,
q,b);g=h.det3(g,c,b);d=m.mult(d,e);e=m.mult(a,g);return h.turnIntoCSList([d,e])};h.crossratio3=function(a,g,c,q,b){a=h.crossratio3harm(a,g,c,q,b);return m.div(a.value[0],a.value[1])};h.veronese=function(a){var g=m.mult(a.value[0],a.value[0]),c=m.mult(a.value[1],a.value[1]),q=m.mult(a.value[2],a.value[2]),b=m.mult(a.value[0],a.value[1]),d=m.mult(a.value[0],a.value[2]);a=m.mult(a.value[1],a.value[2]);return h.turnIntoSCList([g,c,q,b,d,a])};h.matrixFromVeronese=function(a){var g=a.value[0],c=a.value[1],
q=a.value[2],b=m.realmult(.5,a.value[3]),d=m.realmult(.5,a.value[4]);a=m.realmult(.5,a.value[5]);return h.turnIntoCSList([h.turnIntoCSList([g,b,d]),h.turnIntoCSList([b,c,a]),h.turnIntoCSList([d,a,q])])};h.det2=function(a,g){var c=m.mult(a.value[0],g.value[1]);return c=m.sub(c,m.mult(a.value[1],g.value[0]))};h.det3=function(a,g,c){return m.complex(a.value[0].value.real*g.value[1].value.real*c.value[2].value.real-a.value[0].value.imag*g.value[1].value.imag*c.value[2].value.real-a.value[0].value.imag*
g.value[1].value.real*c.value[2].value.imag-a.value[0].value.real*g.value[1].value.imag*c.value[2].value.imag+a.value[2].value.real*g.value[0].value.real*c.value[1].value.real-a.value[2].value.imag*g.value[0].value.imag*c.value[1].value.real-a.value[2].value.imag*g.value[0].value.real*c.value[1].value.imag-a.value[2].value.real*g.value[0].value.imag*c.value[1].value.imag+a.value[1].value.real*g.value[2].value.real*c.value[0].value.real-a.value[1].value.imag*g.value[2].value.imag*c.value[0].value.real-
a.value[1].value.imag*g.value[2].value.real*c.value[0].value.imag-a.value[1].value.real*g.value[2].value.imag*c.value[0].value.imag-a.value[0].value.real*g.value[2].value.real*c.value[1].value.real+a.value[0].value.imag*g.value[2].value.imag*c.value[1].value.real+a.value[0].value.imag*g.value[2].value.real*c.value[1].value.imag+a.value[0].value.real*g.value[2].value.imag*c.value[1].value.imag-a.value[2].value.real*g.value[1].value.real*c.value[0].value.real+a.value[2].value.imag*g.value[1].value.imag*
c.value[0].value.real+a.value[2].value.imag*g.value[1].value.real*c.value[0].value.imag+a.value[2].value.real*g.value[1].value.imag*c.value[0].value.imag-a.value[1].value.real*g.value[0].value.real*c.value[2].value.real+a.value[1].value.imag*g.value[0].value.imag*c.value[2].value.real+a.value[1].value.imag*g.value[0].value.real*c.value[2].value.imag+a.value[1].value.real*g.value[0].value.imag*c.value[2].value.imag,-a.value[0].value.imag*g.value[1].value.imag*c.value[2].value.imag+a.value[0].value.imag*
g.value[1].value.real*c.value[2].value.real+a.value[0].value.real*g.value[1].value.real*c.value[2].value.imag+a.value[0].value.real*g.value[1].value.imag*c.value[2].value.real-a.value[2].value.imag*g.value[0].value.imag*c.value[1].value.imag+a.value[2].value.imag*g.value[0].value.real*c.value[1].value.real+a.value[2].value.real*g.value[0].value.real*c.value[1].value.imag+a.value[2].value.real*g.value[0].value.imag*c.value[1].value.real-a.value[1].value.imag*g.value[2].value.imag*c.value[0].value.imag+
a.value[1].value.imag*g.value[2].value.real*c.value[0].value.real+a.value[1].value.real*g.value[2].value.real*c.value[0].value.imag+a.value[1].value.real*g.value[2].value.imag*c.value[0].value.real+a.value[0].value.imag*g.value[2].value.imag*c.value[1].value.imag-a.value[0].value.imag*g.value[2].value.real*c.value[1].value.real-a.value[0].value.real*g.value[2].value.real*c.value[1].value.imag-a.value[0].value.real*g.value[2].value.imag*c.value[1].value.real+a.value[2].value.imag*g.value[1].value.imag*
c.value[0].value.imag-a.value[2].value.imag*g.value[1].value.real*c.value[0].value.real-a.value[2].value.real*g.value[1].value.real*c.value[0].value.imag-a.value[2].value.real*g.value[1].value.imag*c.value[0].value.real+a.value[1].value.imag*g.value[0].value.imag*c.value[2].value.imag-a.value[1].value.imag*g.value[0].value.real*c.value[2].value.real-a.value[1].value.real*g.value[0].value.real*c.value[2].value.imag-a.value[1].value.real*g.value[0].value.imag*c.value[2].value.real)};h.det4m=function(a){var g=
a.value,c=g[0].value,q=c[0].value,b=+q.real,d=+q.imag,q=c[1].value,h=+q.real,e=+q.imag,q=c[2].value,f=+q.real,k=+q.imag,q=c[3].value,l=+q.real,n=+q.imag,c=g[1].value,q=c[0].value,p=+q.real,r=+q.imag,q=c[1].value,t=+q.real,v=+q.imag,q=c[2].value,u=+q.real,w=+q.imag,q=c[3].value,c=+q.real,q=+q.imag;a=b*t-d*v-h*p+e*r;var x=b*v+d*t-h*r-e*p,y=b*u-d*w-f*p+k*r,A=b*w+d*u-f*r-k*p,z=b*c-d*q-l*p+n*r,B=b*q+d*c-l*r-n*p,C=h*u-e*w-f*t+k*v,D=h*w+e*u-f*v-k*t,F=h*c-e*q-l*t+n*v,E=h*q+e*c-l*v-n*t,G=f*c-k*q-l*u+n*w,H=
f*q+k*c-l*w-n*u,c=g[2].value,q=c[0].value,b=+q.real,d=+q.imag,q=c[1].value,h=+q.real,e=+q.imag,q=c[2].value,f=+q.real,k=+q.imag,q=c[3].value,l=+q.real,n=+q.imag,c=g[3].value,q=c[0].value,p=+q.real,r=+q.imag,q=c[1].value,t=+q.real,v=+q.imag,q=c[2].value,u=+q.real,w=+q.imag,q=c[3].value,c=+q.real,q=+q.imag,g=b*t-d*v-h*p+e*r,L=b*v+d*t-h*r-e*p,J=b*u-d*w-f*p+k*r,M=b*w+d*u-f*r-k*p,N=b*c-d*q-l*p+n*r,b=b*q+d*c-l*r-n*p,d=h*u-e*w-f*t+k*v,p=h*w+e*u-f*v-k*t,r=h*c-e*q-l*t+n*v,h=h*q+e*c-l*v-n*t,e=f*c-k*q-l*u+n*
w,f=f*q+k*c-l*w-n*u;return m.complex(a*e-x*f-y*r+A*h+z*d-B*p+C*N-D*b-F*J+E*M+G*g-H*L,a*f+x*e-y*h-A*r+z*p+B*d+C*b+D*N-F*M-E*J+G*L+H*g)};h.eucangle=function(a,g){var c=h.cross(a,h.linfty),q=h.cross(g,h.linfty),b=h.det3(h.ez,c,h.ii),c=h.det3(h.ez,c,h.jj),d=h.det3(h.ez,q,h.ii),q=h.det3(h.ez,q,h.jj),b=m.div(m.mult(b,q),m.mult(d,c)),b=m.log(b);return b=m.mult(b,m.complex(0,.5))};h.zerovector=function(a){a=Math.floor(a.value.real);for(var g=Array(a),c=0;c<a;c++)g[c]=0;return h.realVector(g)};h.zeromatrix=
function(a,g){for(var c=Math.floor(a.value.real),q=Array(c),b=0;b<c;b++)q[b]=h.zerovector(g);return h.turnIntoCSList(q)};h.vandermonde=function(a){for(var g=a.value.length,c=h.zeromatrix(g,g),q=0;q<g;q++)for(var b=0;b<g;b++)c.value[q].value[b]=m.pow(a.value[q],m.real(b-1));return c};h.transpose=function(a){for(var g=[],c=a.value[0].value.length,q=a.value.length,b=0;b<c;b++){for(var d=[],e=0;e<q;e++)d[e]=a.value[e].value[b];g[b]=h.turnIntoCSList(d)}return h.turnIntoCSList(g)};h.column=function(a,g){for(var c=
[],q=a.value.length,b=Math.floor(g.value.real-1),d=0;d<q;d++)c[d]=a.value[d].value[b];return h.turnIntoCSList(c)};h.row=function(a,g){for(var c=[],q=a.value[0].value.length,b=Math.floor(g.value.real-1),d=0;d<q;d++)c[d]=a.value[b].value[d];return h.turnIntoCSList(c)};h.adjoint2=function(a){var g=a.value[0].value[0],c=a.value[1].value[0],q=Array(2);q[0]=h.turnIntoCSList([a.value[1].value[1],m.neg(a.value[0].value[1])]);q[1]=h.turnIntoCSList([m.neg(c),g]);return q=h.turnIntoCSList(q)};h.adjoint3=function(a){var g,
c,q,b,d,h,e,f,m,k,l,n,p,r,t,v,u;g=a.value[0].value;c=g[0].value;q=c.real;b=c.imag;c=g[1].value;d=c.real;h=c.imag;c=g[2].value;e=c.real;f=c.imag;g=a.value[1].value;c=g[0].value;m=c.real;k=c.imag;c=g[1].value;l=c.real;n=c.imag;c=g[2].value;p=c.real;r=c.imag;g=a.value[2].value;c=g[0].value;a=c.real;t=c.imag;c=g[1].value;v=c.real;u=c.imag;c=g[2].value;g=c.real;c=c.imag;return{ctype:"list",value:[{ctype:"list",value:[{ctype:"number",value:{real:l*g-p*v-n*c+r*u,imag:l*c-p*u-v*r+g*n}},{ctype:"number",value:{real:-d*
g+e*v+h*c-f*u,imag:-d*c+e*u+v*f-g*h}},{ctype:"number",value:{real:d*p-e*l-h*r+f*n,imag:d*r-e*n-l*f+p*h}}]},{ctype:"list",value:[{ctype:"number",value:{real:-m*g+p*a+k*c-r*t,imag:-m*c+p*t+a*r-g*k}},{ctype:"number",value:{real:q*g-e*a-b*c+f*t,imag:q*c-e*t-a*f+g*b}},{ctype:"number",value:{real:-q*p+e*m+b*r-f*k,imag:-q*r+e*k+m*f-p*b}}]},{ctype:"list",value:[{ctype:"number",value:{real:m*v-l*a-k*u+n*t,imag:m*u-l*t-a*n+v*k}},{ctype:"number",value:{real:-q*v+d*a+b*u-h*t,imag:-q*u+d*t+a*h-v*b}},{ctype:"number",
value:{real:q*l-d*m-b*n+h*k,imag:q*n-d*k-m*h+l*b}}]}]}};h.inverse=function(a){var g=a.value.length;if(g!==a.value[0].value.length)return console.log("Inverse works only for square matrices"),k;if(2===g)return h.scaldiv(h.det(a),h.adjoint2(a));if(3===g)return h.scaldiv(h.det(a),h.adjoint3(a));g=h.LUdecomp(a);a=a.value.length;var c=m.real(0),q=m.real(1),b=h.zerovector(m.real(a));b.value[0]=q;for(var d=Array(a),e=0;e<a;e++)d[e]=h._helper.LUsolve(g,b),b.value[e]=c,b.value[e+1]=q;d=h.turnIntoCSList(d);
return d=h.transpose(d)};h.linearsolve=function(a,g){return 2===a.value.length?h.linearsolveCramer2(a,g):3===a.value.length?h.linearsolveCramer3(a,g):h.LUsolve(a,g)};h.getDiag=function(a){if(a.value.length!==a.value[0].value.length)return k;for(var g=Array(a.value.length),c=0;c<a.value.length;c++)g[c]=a.value[c].value[c];return h.turnIntoCSList(g)};h.getSubDiag=function(a){if(a.value.length!==a.value[0].value.length)return k;for(var g=Array(a.value.length-1),c=0;c<a.value.length-1;c++)g[c]=a.value[c+
1].value[c];return h.turnIntoCSList(g)};h.eig2=function(a){var g=m.add(a.value[0].value[0],a.value[1].value[1]);a=h.det2(a.value[0],a.value[1]);var c=m.mult(g,g),b=g=m.mult(g,m.real(.5));a=m.sqrt(m.sub(m.div(c,m.real(4)),a));g=m.add(g,a);b=m.sub(b,a);return h.turnIntoCSList([g,b])};h.eig=function(a,g){var c=g||!0,b=a,d=m.real(b.value.length),e=d.value.real;m.real(0);var b=h._helper.QRIteration(b)[0],b=h.getDiag(b),b=h.sort1(b),d=h.idMatrix(d,d),f=Array(e),f=h.turnIntoCSList(f);if(c){for(var k,l,n,
p=0,r=!1,c=0;c<e;c++)r?l=k.value[p]:(k=b.value[c],k=h.sub(a,h.scalmult(k,d)),k=h.nullSpace(k),l=k.value[0],void 0!==l&&(n=l)),void 0===l&&(l=n),1E-8>h.abs(l).value.real&&0===p&&(l=h._helper.inverseIteration(a,b.value[c])),f.value[c]=h._helper.isAlmostZeroVec(l)?l:h.scaldiv(h.abs(l),l),c<e-1&&((r=1E-6>m.abs(m.sub(b.value[c],b.value[c+1])).value.real)?p++:p=0);f=h.transpose(f)}return h.turnIntoCSList([b,f])};h._helper.isNormalMatrix=function(a){return 1E-10>h.abs(h.sub(a,h.transjugate(a))).value.real};
h._helper.QRIteration=function(a,g){var c,b=a;c=m.real(b.value.length);var d=c.value.real,e=c.value.real;m.real(0);var f;h.idMatrix(c,c);var k=h.zeromatrix(c,c),l=h.idMatrix(c,c),n=g?g:2500,p,r,t,v=0,u=Array(e);for(c=0;c<n;c++){f=h._helper.getBlock(b,[e-2,e-1],[e-2,e-1]);p=h.eig2(f);f=p.value[0];p=p.value[1];h.abs(f);h.abs(p);r=b.value[e-1].value[e-1];t=m.abs(m.sub(r,f)).value.real;r=m.abs(m.sub(r,p)).value.real;p=t<r?f:p;f=h.idMatrix(m.real(e),m.real(e));p=h.scalmult(p,f);f=h.QRdecomp(h.sub(b,p));
b=w.mult(f.R,f.Q);b=h.add(b,p);f.Q=h._helper.buildBlockMatrix(f.Q,h.idMatrix(m.real(v),m.real(v)));l=w.mult(l,f.Q);if(1E-48>m.abs2(b.value[b.value.length-1].value[b.value[0].value.length-2]).value.real&&1<e){u[d-v-1]=b.value[e-1].value[e-1];for(c=0;c<e;c++)k.value[e-1].value[c]=b.value[e-1].value[c],k.value[c].value[e-1]=b.value[c].value[e-1];b=h._helper.getBlock(b,[0,e-2],[0,e-2]);v++;e--}if(1===e){k.value[0].value[0]=b.value[0].value[0];break}if(h._helper.isUpperTriangular(b)){for(c=0;c<e;c++)k.value[c].value[c]=
b.value[c].value[c];break}}return[k,l]};h.rank=function(a,g){return h.RRQRdecomp(a,g).rank};h._helper.isAlmostZeroVec=function(a){for(var g=a.value.length,c=0;c<g;c++)if(!m._helper.isAlmostZero(a.value[c]))return!1;return!0};h._helper.isLowerTriangular=function(a){for(var g=a.value.length,c=a.value[0].value.length,b=0;b<g;b++)for(var d=b+1;d<c;d++)if(!m._helper.isAlmostZero(a.value[b].value[d]))return!1;return!0};h._helper.isUpperTriangular=function(a){return h._helper.isLowerTriangular(h.transpose(a))};
h._helper.isAlmostId=function(a){var g=a.value.length,c=m.real(g);if(g!==a.value[0].value.length)return!1;a=h.sub(a,h.idMatrix(c),c);for(c=0;c<g;c++)for(var b=0;b<g;b++)if(1E-16<m.abs(a.value[c].value[b]).value.real)return!1;return!0};h.nullSpace=function(a,g){var c=a.value.length,b=h.RRQRdecomp(h.transjugate(a),g),d=h.transpose(b.Q),b=c-b.rank.value.real,e=Array(b);d.value.reverse();for(var f,k=0;k<b;k++)f=d.value[k],e[k]=h.scaldiv(h.abs(f),f);e=h.turnIntoCSList(e);return 0<e.value.length?e:h.turnIntoCSList([h.zerovector(m.real(c))])};
h._helper.isAlmostDiagonal=function(a){var g=a.value.length;m.real(g);m.real(0);if(g!==a.value[0].value.length)return!1;for(var c=0;c<g;c++)for(var b=0;b<g;b++)if(c!==b&&1E-16<m.abs(a.value[c].value[b]).value.real)return!1;return!0};h._helper.inverseIteration=function(a,g){console.log("warning: code untested");for(var c=a.value.length,b=Array(c),d=0;d<c;d++)b[d]=2*Math.random()-.5;for(var b=h.realVector(b),c=h.idMatrix(m.real(c),m.real(c)),d=m.add(g,m.real(.1*Math.random()-.5)),e=0;100>e;e++)b=h.scaldiv(h.abs(b),
b),b=h.LUsolve(h.sub(a,h.scalmult(d,c)),JSON.parse(JSON.stringify(b)));return h.scaldiv(h.abs(b),b)};h._helper.toHessenberg=function(a){var g=JSON.parse(JSON.stringify(a)),c=g.value.length,b=m.real(c-1),d=m.real(c);m.real(1);if(h._helper.isUpperTriangular(g))return[h.idMatrix(b,b),a];var e;a=h.idMatrix(d,d);for(var f,d=1;d<c-1;d++)e=h.column(g,m.real(d)),e.value=e.value.splice(d),f=h.abs2(e).value.real,1E-16<f&&(e=h._helper.getHouseHolder(e),a=w.mult(a,e),g=w.mult(w.mult(e,g),e)),b.value.real--;return[a,
g]};h._helper.swapEl=function(a,g,c){var b;"[object Array]"===Object.prototype.toString.call(a)?(b=a[g],a[g]=a[c],a[c]=b):"list"===a.ctype&&(b=a.value[g],a.value[g]=a.value[c],a.value[c]=b)};h.RRQRdecomp=function(a,g){var c=Math.sqrt(m.eps);void 0!==g&&(c=.1*g.value.real);var c=c*c,b,d=a.value.length,e=m.real(d),f=m.real(1),k=h._helper.unitvector(m.real(a.value.length),f),l=h.idMatrix(e,e),n=JSON.parse(JSON.stringify(a)),p=h.transpose(a),r=Array(d);for(b=0;b<d;b++)r[b]=h.abs2(p.value[b]);r=h.turnIntoCSList(r);
p=Array(d);for(b=0;b<d;b++)p[b]=b;b=h.maxIndex(r,m.abs);for(var t=r.value[b],v=0,u=0;1E-16<m.abs2(t).value.real;u++){v++;h._helper.swapColumn(n,u,b);h._helper.swapEl(r,u,b);h._helper.swapEl(p,u,b);b=h._helper.getBlock(n,[u],[u]);b=h.column(b,f);t=h.abs2(b).value.real;1E-8<t&&(b=h._helper.getHouseHolder(b),b=h._helper.buildBlockMatrix(h.idMatrix(m.real(u),m.real(u)),b),l=w.mult(l,h.transjugate(b)),n=w.mult(b,n));for(b=u+1;b<d;b++)r.value[b]=m.sub(r.value[b],m.mult(n.value[u].value[b],m.conjugate(n.value[u].value[b])));
b=h.maxIndex(r,m.abs2,u+1);t=r.value[b];if(u+2===d){m.abs(t).value.real>c&&v++;break}e=m.sub(e,f);k.value=k.value.splice(0,k.value.length-1)}return{Q:l,R:n,P:h.turnIntoCSList(p),rank:m.real(v)}};h._helper.getHouseHolder=function(a){var g=m.real(a.value.length);if(1E-16>h.abs2(a))return h.idMatrix(g,g);var c,b=m.real(1),d=h._helper.unitvector(m.real(a.value.length),b);c=h._helper.QRgetAlpha(a,0);c=h.sub(a,h.scalmult(c,d));c=h.scaldiv(h.abs(c),c);a=m.div(h.sesquilinearproduct(a,c),h.sesquilinearproduct(c,
a));g=h.idMatrix(g,g);return g=h.sub(g,h.scalmult(m.add(b,a),h._helper.transposeMult(c,h.conjugate(c))))};h._helper.reOrderbyPivots=function(a,g){for(var c=a.value.length.length,b=h.transpose(a),c=Array(c),d=0;d<g.length;d++)c[g[d]]=b.value[d];c=h.turnIntoCSList(c);return h.transpose(c)};h.QRdecomp=function(a){var g,c=a.value.length,b=m.real(c);if(h._helper.isUpperTriangular(a))return{Q:h.idMatrix(b,b),R:a};var d=m.real(1),e=h._helper.unitvector(m.real(a.value.length),d),f,k=h.idMatrix(b,b);a=JSON.parse(JSON.stringify(a));
for(var l=0;;l++){g=h._helper.getBlock(a,[l],[l]);g=h.column(g,d);f=h.abs2(g).value.real;1E-8<f&&(g=h._helper.getHouseHolder(g),g=h._helper.buildBlockMatrix(h.idMatrix(m.real(l),m.real(l)),g),k=w.mult(k,h.transjugate(g)),a=w.mult(g,a));if(l+2===c)break;b=m.sub(b,d);e.value=e.value.splice(0,e.value.length-1)}return{Q:k,R:a}};h._helper.swapColumn=function(a,g,c){for(var b,d=0;d<a.value.length;d++)b=a.value[d].value[g],a.value[d].value[g]=a.value[d].value[c],a.value[d].value[c]=b};h._helper.buildBlockMatrix=
function(a,g){if(0===a.value.length)return g;if(0===g.value.length)return a;for(var c=a.value.length,b=a.value[0].value.length,d=b+g.value[0].value.length,d=h.zeromatrix(m.real(c+g.value.length),m.real(d)),e=0;e<a.value.length;e++)for(var f=0;f<a.value[0].value.length;f++)d.value[e].value[f]=a.value[e].value[f];for(e=0;e<g.value.length;e++)for(f=0;f<g.value[0].value.length;f++)d.value[c+e].value[b+f]=g.value[e].value[f];return d};h._helper.getBlock=function(a,g,c){a=JSON.parse(JSON.stringify(a));
var b=g[0],d=c[0];g=void 0===g[1]?a.value.length:g[1];c=void 0===c[1]?a.value[0].value.length:c[1];g++;c++;a.value=a.value.slice(b,g);for(b=0;b<a.value.length;b++)a.value[b].value=a.value[b].value.slice(d,c);return a};h._helper.setBlock=function(a,g,c){a=JSON.parse(JSON.stringify(a));var b=c[0];c=c[1];for(var d=g.value.length,h=g.value[0].value.length,e=0;e<d;e++)for(var f=0;f<h;f++)a.value[b+e].value[c+f]=g.value[e].value[f];return a};h._helper.transposeMult=function(a,g){if(a.value.length!==g.value.length)return k;
for(var c=a.value.length,b=Array(c),d=0;d<c;d++)b[d]=h.scalmult(a.value[d],g);return h.turnIntoCSList(b)};h._helper.QRgetAlpha=function(a,g){return 0>a.value[g].value.real?h.abs(a):m.neg(h.abs(a))};h.LUdecomp=function(a){a=JSON.parse(JSON.stringify(a));var g,c,b,d,h,e=0,f,k=a.value.length,l=k-1,n=Array(k);for(b=0;b<k;++b){h=b;d=a.value[b];f=m.abs(d.value[b]).value.real;for(c=b+1;c<k;++c)g=m.abs(a.value[c].value[b]),f<g.value.real&&(f=g.value.real,h=c);f<m.eps&&console.log("Warning: singular matrix!");
n[b]=h;h!==b&&(a.value[b]=a.value[h],a.value[h]=d,d=a.value[b],e++);c=d.value[b];for(g=b+1;g<k;++g)a.value[g].value[b]=m.div(a.value[g].value[b],c);for(g=b+1;g<k;++g){h=a.value[g];for(c=b+1;c<l;++c)h.value[c]=m.sub(h.value[c],m.mult(h.value[b],d.value[c])),++c,h.value[c]=m.sub(h.value[c],m.mult(h.value[b],d.value[c]));c===l&&(h.value[c]=m.sub(h.value[c],m.mult(h.value[b],d.value[c])))}}return{LU:a,P:n,TransPos:e}};h.LUsolve=function(a,g){var c=h.LUdecomp(a);return h._helper.LUsolve(c,g)};h._helper.LUsolve=
function(a,g){var c=JSON.parse(JSON.stringify(g)),b,d=a.LU,h=d.value.length,e=JSON.parse(JSON.stringify(c)),f=a.P,k;for(b=h-1;-1!==b;--b)e.value[b]=c.value[b];for(b=0;b<h;++b)for(c=f[b],f[b]!==b&&(k=e.value[b],e.value[b]=e.value[c],e.value[c]=k),k=d.value[b],c=0;c<b;++c)e.value[b]=m.sub(e.value[b],m.mult(e.value[c],k.value[c]));for(b=h-1;0<=b;--b){k=d.value[b];for(c=b+1;c<h;++c)e.value[b]=m.sub(e.value[b],m.mult(e.value[c],k.value[c]));e.value[b]=m.div(e.value[b],k.value[b])}return e};h.linearsolveCramer2=
function(a,g){var c=h.column(a,m.real(1)),b=h.column(a,m.real(2)),d=h.det2(c,b);m._helper.isZero(d)&&console.log("A is not regular!");b=h.det2(g,b);b=m.div(b,d);c=h.det2(c,g);c=m.div(c,d);return h.turnIntoCSList([b,c])};h.linearsolveCramer3=function(a,g){var c=h.column(a,m.real(1)),b=h.column(a,m.real(2)),d=h.column(a,m.real(3)),e=h.det3(c,b,d);m._helper.isZero(e)&&console.log("A is not regular!");var f=h.det3(g,b,d),d=h.det3(c,g,d),c=h.det3(c,b,g),f=h.turnIntoCSList([f,d,c]);return f=h.scaldiv(e,
f)};h.linearsolveCGNR=function(a,g){var c=h.transpose(a),b=w.mult(c,a),c=w.mult(c,g);return h.linearsolveCG(b,c)};h.linearsolveCG=function(a,g){var c,b,d,e,f,k;e=g;b=c=h.sub(g,w.mult(a,g));for(var l=Math.ceil(1.2*a.value.length),n=0;n<l;){n++;f=w.mult(a,b);k=d=h.scalproduct(c,c);d=m.div(d,h.scalproduct(b,f));e=h.add(e,w.mult(d,b));c=h.sub(c,w.mult(d,f));if(h.abs(c).value.real<m.eps)break;d=h.scalproduct(c,c);d=m.div(d,k);b=h.add(c,w.mult(d,b))}n>=l&&console.log("CG did not converge");return e};h.det=
function(a){if(1===a.value.length)return a.value[0].value[0];if(2===a.value.length)return h.det2(a.value[0],a.value[1]);if(3===a.value.length)return h.det3(a.value[0],a.value[1],a.value[2]);if(4===a.value.length)return h.det4m(a);var g=a.value.length,c=m.real(1),b,d,e=JSON.parse(JSON.stringify(a)),f,k,l,n;for(a=0;a<g-1;a++){d=a;for(b=a+1;b<g;b++)m.abs(e.value[b].value[a]).value.real>m.abs(e.value[d].value[a]).value.real&&(d=b);d!==a&&(b=e.value[d],e.value[d]=e.value[a],e.value[a]=b,c=m.neg(c));f=
e.value[a];for(b=a+1;b<g;b++){k=e.value[b];l=m.div(k.value[a],f.value[a]);for(d=a+1;d<g-1;d+=2)n=d+1,k.value[d]=m.sub(k.value[d],m.mult(f.value[d],l)),k.value[n]=m.sub(k.value[n],m.mult(f.value[n],l));d!==g&&(k.value[d]=m.sub(k.value[d],m.mult(f.value[d],l)))}if(m._helper.isZero(f.value[a]))return m.real(0);c=m.mult(c,f.value[a])}return m.mult(c,e.value[a].value[a])};h.LUdet=function(a){a=h.LUdecomp(a);for(var g=a.LU,c=g.value.length,b=g.value[0].value[0],d=1;d<c;d++)b=m.mult(b,g.value[d].value[d]);
1===a.TransPos%2&&(b=m.neg(b));return b};h.getField=function(a,g){var c;if("homog"===g){if(h._helper.isNumberVecN(a,3))return a;if(h._helper.isNumberVecN(a,2))return h.turnIntoCSList([a.value[0],a.value[1],m.real(1)])}if("xy"===g){if(h._helper.isNumberVecN(a,2))return a;if(h._helper.isNumberVecN(a,3))return h.turnIntoCSList([m.div(a.value[0],a.value[2]),m.div(a.value[1],a.value[2])])}if("x"===g&&h.isNumberVector(a)){c=a.value.length;if(0<c&&3!==c)return a.value[0];if(3===c)return"Point"===a.usage?
m.div(a.value[0],a.value[2]):a.value[0]}if("y"===g&&h.isNumberVector(a)){c=a.value.length;if(1<c&&3!==c)return a.value[1];if(3===c)return"Point"===a.usage?m.div(a.value[1],a.value[2]):a.value[1]}return"z"===g&&h.isNumberVector(a)&&(c=a.value.length,2<c)?a.value[2]:k};h.nil=h.turnIntoCSList([]);h.ofGeos=function(a){return h.turnIntoCSList(a.map(function(a){return{ctype:"geo",value:a}}))};var Na={key:function(a){if("string"===a.ctype)return"s"+a.value.length+":"+a.value+";";if("number"===a.ctype)return"n"+
a.value.real+","+a.value.imag+";";if("list"===a.ctype)return"l"+a.value.length+":"+a.value.map(Na.key).join(",")+";";if("boolean"===a.ctype)return"b"+a.value+";";if("dict"===a.ctype)return a=Object.keys(a.value).sort(),"d"+a.length+":"+a.join(",")+";";"undefined"!==a.ctype&&wa.err("Bad dictionary key: "+Z(a));return"undef"},create:function(){return{ctype:"dict",value:{}}},clone:function(a){var g=Na.create(),c;for(c in a.value)a.value.hasOwnProperty(c)&&(g.value[c]=a.value[c]);return g},put:function(a,
g,c){a.value[Na.key(g)]={key:g,value:c}},get:function(a,g,c){return(a=a.value[Na.key(g)])?a.value:c},niceprint:function(a){return"{"+Object.keys(a.value).sort().map(function(g){g=a.value[g];return Z(g.key)+":"+Z(g.value)}).join(", ")+"}"}},w={_helper:{},order:{undefined:0,"boolean":1,number:2,term:3,atomic:4,variable:5,geo:6,string:7,list:8},string:function(a){return{ctype:"string",value:a}},bool:function(a){return{ctype:"boolean",value:a}},not:function(a){return w.bool(!a.value)},isLessThan:function(a,
g){return-1===w.compare(a,g)},isEqual:function(a,g){return 0===w.compare(a,g)},compareResults:function(a,g){return w.compare(a.result,g.result)},compare:function(a,g){if(a.ctype!==g.ctype)return w.order[a.ctype]-w.order[g.ctype];if("number"===a.ctype)return m._helper.compare(a,g);if("list"===a.ctype)return h._helper.compare(a,g);if("geo"===a.ctype)return a.value.name===g.value.name?0:a.value.name<g.value.name?-1:1;if("string"===a.ctype)return a.value===g.value?0:a.value<g.value?-1:1;if("boolean"===
a.ctype)return a.value===g.value?0:!1===a.value?-1:1},add:function(a,g){return"void"===a.ctype&&"number"===g.ctype||"void"===a.ctype&&"list"===g.ctype?g:"number"===a.ctype&&"number"===g.ctype?m.add(a,g):"string"===a.ctype||"string"===g.ctype?{ctype:"string",value:Z(a)+Z(g)}:"list"===a.ctype&&"list"===g.ctype?h.add(a,g):k},sub:function(a,g){return"void"===a.ctype&&"number"===g.ctype?m.neg(g):"void"===a.ctype&&"list"===g.ctype?h.neg(g):"number"===a.ctype&&"number"===g.ctype?m.sub(a,g):"list"===a.ctype&&
"list"===g.ctype?h.sub(a,g):k},mult:function(a,g){return"number"===a.ctype&&"number"===g.ctype?m.mult(a,g):"number"===a.ctype&&"list"===g.ctype?h.scalmult(a,g):"list"===a.ctype&&"number"===g.ctype?h.scalmult(g,a):"list"===a.ctype&&"list"===g.ctype?h.mult(a,g):k},div:function(a,g){return"number"===a.ctype&&"number"===g.ctype?m.div(a,g):"list"===a.ctype&&"number"===g.ctype?h.scaldiv(g,a):k},max:function(a,g){return"number"===a.ctype&&"number"===g.ctype?m.max(a,g):"list"===a.ctype&&"list"===g.ctype?
h.max(a,g):k},min:function(a,g){return"number"===a.ctype&&"number"===g.ctype?m.min(a,g):"list"===a.ctype&&"list"===g.ctype?h.min(a,g):k},wrap:function(a){if("number"===typeof a)return m.real(a);if("object"===typeof a&&void 0!==a.length){for(var g=[],c=0;c<a.length;c++)g[c]=w.wrap(a[c]);return h.turnIntoCSList(g)}return"string"===typeof a?{ctype:"string",value:a}:"boolean"===typeof a?{ctype:"boolean",value:a}:k},unwrap:function(a){if("object"!==typeof a||null===a)return a;if(Array.isArray(a))return a.map(w.unwrap);
switch(a.ctype){case "string":case "boolean":return a.value;case "number":return 0===a.value.imag?a.value.real:{r:a.value.real,i:a.value.imag};case "list":return a.value.map(w.unwrap);default:return null}},withUsage:function(a,g){return{ctype:a.ctype,value:a.value,usage:g}},wrapJSON:function(a){switch(typeof a){case "number":return m.real(a);case "string":return w.string(a);case "boolean":return w.bool(a);case "object":if(null===a)return k;if(Array.isArray(a))return h.turnIntoCSList(a.map(w.wrapJSON));
var g=Na.create(),c;for(c in a)Na.put(g,w.string(c),w.wrapJSON(a[c]));return g;default:return console.log("Failed to convert "+typeof a+" to CindyJS data type"),k}},identity:function(a){return a},deeplyEqual:function(a,g){if("object"!==typeof a||"object"!==typeof g||null===a||null===g)return a===g;var c=0,b;for(b in a)if(++c,!(b in g&&w.deeplyEqual(a[b],g[b])))return!1;for(b in g)--c;return 0===c},DeepCloneJSON:function(a){var g,c,b;g=Array.isArray(a)?[]:{};for(b in a)c=a[b],g[b]="object"===typeof c&&
null!==c?w.DeepCloneJSON(c):c;return g}},db={},Q={};Q[":"]=C(":");Q["\u00b0"]=function(a,g){var c=B(a[0]);return"number"===c.ctype&&"void"===a[1].ctype?w.withUsage(m.realmult(Math.PI/180,c),"Angle"):k};Q._=vc;Q["^"]=Uc;Q["\u221a"]=function(a,g){return"void"===a[0].ctype?t.sqrt$1([a[1]],g):k};Q["*"]=Sc;Q["\u00d7"]=$c;Q["/"]=Tc;Q["+"]=Rc;Q["-"]=jc;Q["!"]=function(a,g){var c=B(a[1]);return"void"===a[0].ctype&&"boolean"===c.ctype?{ctype:"boolean",value:!c.value}:k};Q["=="]=vb;Q["~="]=hc;Q["~<"]=function(a,
g){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&m._helper.isAlmostReal(c)&&m._helper.isAlmostReal(b)?{ctype:"boolean",value:c.value.real-b.value.real<=-m.eps}:k};Q["~>"]=function(a,g){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&m._helper.isAlmostReal(c)&&m._helper.isAlmostReal(b)?{ctype:"boolean",value:c.value.real-b.value.real>=m.eps}:k};Q["=:="]=C("=:=");Q[">="]=function(a,g){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&
m._helper.isAlmostReal(c)&&m._helper.isAlmostReal(b)?{ctype:"boolean",value:c.value.real>=b.value.real}:"string"===c.ctype&&"string"===b.ctype?{ctype:"boolean",value:c.value>=b.value}:k};Q["<="]=function(a,g){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&m._helper.isAlmostReal(c)&&m._helper.isAlmostReal(b)?{ctype:"boolean",value:c.value.real<=b.value.real}:"string"===c.ctype&&"string"===b.ctype?{ctype:"boolean",value:c.value<=b.value}:k};Q["~>="]=function(a,g){var c=B(a[0]),
b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&m._helper.isAlmostReal(c)&&m._helper.isAlmostReal(b)?{ctype:"boolean",value:c.value.real-b.value.real>-m.eps}:k};Q["~<="]=function(a,g){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&m._helper.isAlmostReal(c)&&m._helper.isAlmostReal(b)?{ctype:"boolean",value:c.value.real-b.value.real<m.eps}:k};Q[">"]=function(a,g){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&m._helper.isAlmostReal(c)&&m._helper.isAlmostReal(b)?
{ctype:"boolean",value:c.value.real>b.value.real}:"string"===c.ctype&&"string"===b.ctype?{ctype:"boolean",value:c.value>b.value}:k};Q["<"]=function(a,g){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype&&m._helper.isAlmostReal(c)&&m._helper.isAlmostReal(b)?{ctype:"boolean",value:c.value.real<b.value.real}:"string"===c.ctype&&"string"===b.ctype?{ctype:"boolean",value:c.value<b.value}:k};Q["<>"]=Oc;Q["\u2208"]=function(a,g){var c=z(a[0]),b=z(a[1]);return"list"===b.ctype?h.contains(b,
c):k};Q["\u2209"]=function(a,g){var c=z(a[0]),b=z(a[1]);return"list"===b.ctype?w.not(h.contains(b,c)):k};Q["&"]=Pc;Q["%"]=Qc;Q["!="]=Oc;Q["~!="]=function(a,g){return w.not(hc(a,g))};Q[".."]=function(a,g){var c=z(a[0]),b=z(a[1]);return"number"===c.ctype&&"number"===b.ctype?h.sequence(c,b):k};Q["++"]=ad;Q["--"]=cd;Q["~~"]=bd;Q[":>"]=dd;Q["<:"]=ed;Q["="]=ab;Q[":="]=function(a,g,c){g="undefined"===a[1].ctype;if("undefined"===a[0].ctype||g)return k;if("function"===a[0].ctype){g=a[0].oper;var b=a[0].args,
d=a[1],h=1;if(db.hasOwnProperty(g)){h=db[g];if(h.definer===c)return k;h=h.generation+1}db[g]={oper:g,body:d,arglist:b,definer:c,generation:h}}"variable"===a[0].ctype&&J.setvar(a[0].name,a[1]);return k};Q[":=_"]=function(a,g){if("void"!==a[1].ctype)return k;"function"===a[0].ctype&&delete db[a[0].oper];return k};Q["::="]=C("::=");Q[";"]=function(a,g){var c="void"===a[0].ctype,b="void"===a[1].ctype;if(c&&b)return k;if(!c&&b)return z(a[0]);c||b||z(a[0]);return b?k:z(a[1])};var t={},D={evaluate:function(a,
g,c){if(db.hasOwnProperty(a)){a=db[a];if(void 0===a)g=k;else{var b=[];for(c=0;c<a.arglist.length;c++)b[c]=z(g[c]);for(c=0;c<a.arglist.length;c++)J.newvar(a.arglist[c].name),J.setvar(a.arglist[c].name,b[c]);J.pushVstack("*");g=z(a.body);J.cleanVstack();for(c=0;c<a.arglist.length;c++)J.removevar(a.arglist[c].name)}return g}if(b=t[a])return b(g,c);var d=a.lastIndexOf("$");if(-1!==d&&(d=a.substr(0,d),b=t[d]))return b(g,c);wa.err("Called undefined function "+d+" (as "+a+")");return k},equals:function(a,
g){return"number"===a.ctype&&"number"===g.ctype?{ctype:"boolean",value:a.value.real===g.value.real&&a.value.imag===g.value.imag}:"string"===a.ctype&&"string"===g.ctype||"boolean"===a.ctype&&"boolean"===g.ctype?{ctype:"boolean",value:a.value===g.value}:"list"===a.ctype&&"list"===g.ctype?h.equals(a,g):"geo"===a.ctype&&"geo"===g.ctype?{ctype:"boolean",value:a.value===g.value}:{ctype:"boolean",value:!1}}},J={};J.vars=function(){var a={pi:m.real(Math.PI),"\u03c0":m.real(Math.PI),i:m.complex(0,1),"true":w.bool(!0),
"false":w.bool(!1),"#":k,nil:h.turnIntoCSList([]),newline:w.string("\n"),tab:w.string("\t")},g=[],c;for(c in a)g[c]=[a[c]];return g}();J.isVariable=function(a){return this.vars.hasOwnProperty(a)};J.create=function(a){if(this.vars.hasOwnProperty(a))return this.vars[a];var g=[null];return this.vars[a]=g};J.newvar=function(a){a=this.vars[a];a.push(k);return a};J.removevar=function(a){var g=this.vars[a];0===g.length&&console.error("Removing non-existing "+a);g.pop();0===g.length&&console.warn("Removing last "+
a)};J.setvar=function(a,g){var c=this.vars[a];0===c.length&&console.error("Setting non-existing variable "+a);void 0===g&&(console.error("Setting variable "+a+" to undefined value"),g=k);if("undefined"===g.ctype)c[c.length-1]=g;else{var b=g;null===b&&(b=k);c[c.length-1]=b}};J.undefinedWarning={};J.getvar=function(a){var g=this.vars[a]||[];0===g.length&&console.error("Getting non-existing variable "+a);g=g[g.length-1];if(null===g){if(v.csnames.hasOwnProperty(a))return{ctype:"geo",value:v.csnames[a]};
console&&console.log&&void 0===this.undefinedWarning[a]&&(this.undefinedWarning[a]=!0,console.log("Warning: Accessing undefined variable: "+a));return k}return g};J.dump=function(a){var g=this.vars[a];console.log("*** Dump "+a);for(a=0;a<g.length;a++)console.log(a+":> "+Z(g[a]))};J.vstack=[];J.pushVstack=function(a){this.vstack.push(a)};J.popVstack=function(){this.vstack.pop()};J.cleanVstack=function(){for(var a=this.vstack;0<a.length&&"*"!==a[a.length-1];)this.removevar(a[a.length-1]),a.pop();0<
a.length&&a.pop()};var ta={generalFields:{color:"color",colorhsb:"",size:"size",alpha:"alpha",fillcolor:"fillcolor",fillalpha:"fillalpha",isshowing:"isshowing",visible:"visible",name:"name",caption:"caption",trace:"",tracelength:"",selected:"",labeled:"labeled",labelled:"labeled"},getGeoField:function(a,g){return"undefined"!==typeof v.csnames[a]?ta.getField(v.csnames[a],g):k},setGeoField:function(a,g,c){return"undefined"!==typeof v.csnames[a]?ta.setField(v.csnames[a],g,c):k},getField:function(a,g){var c;
if("P"===a.kind){if("xy"===g)return c=h.dehom(a.homog),w.withUsage(c,"Point");if("homog"===g)return w.withUsage(a.homog,"Point");if("x"===g)return m.div(a.homog.value[0],a.homog.value[2]);if("y"===g)return m.div(a.homog.value[1],a.homog.value[2])}if("L"===a.kind||"S"===a.kind){if("homog"===g)return w.withUsage(a.homog,"Line");if("angle"===g)return c=h.eucangle(h.ey,a.homog),w.withUsage(c,"Angle");if("slope"===g)return m.neg(m.div(a.homog.value[0],a.homog.value[1]))}if("Tr"===a.kind&&"matrix"===g)return a.matrix;
if("C"===a.kind){if("radius"===g){var b=a.matrix;c=b.value[0].value[0];var d=b.value[0].value[2],e=b.value[1].value[2],b=b.value[2].value[2];m.mult(c,c);d=m.div(d,c);e=m.div(e,c);c=m.div(b,c);return c=m.sqrt(m.sub(m.add(m.mult(d,d),m.mult(e,e)),c))}if("size"===g)return a.size;if("matrix"===g)return a.matrix;if("center"===g)return c=l._helper.CenterOfConic(a.matrix),c=h.dehom(c),w.withUsage(c,"Point");if("dualMatrix"===g)return h.normalizeMax(h.adjoint3(a.matrix))}if("Text"===a.kind){if("pressed"===
g)return a.checkbox?w.bool(a.checkbox.checked):w.bool(!1);if("xy"===g)return c=h.dehom(a.homog),w.withUsage(c,"Point");if("homog"===g)return w.withUsage(a.homog,"Point");if("x"===g)return m.div(a.homog.value[0],a.homog.value[2]);if("y"===g)return m.div(a.homog.value[1],a.homog.value[2])}if("trace"===g)return w.bool(!!a.drawtrace);if(ta.generalFields[g])return(c=a[ta.generalFields[g]])&&c.ctype?c:"object"!==typeof c?w.wrap(c):k;if(a.behavior){if("mass"===g&&"Mass"===a.behavior.type)return m.real(a.behavior.mass);
if("radius"===g&&"Mass"===a.behavior.type)return m.real(a.behavior.radius);if("charge"===g&&"Mass"===a.behavior.type)return m.real(a.behavior.charge);if("friction"===g&&"Mass"===a.behavior.type)return m.real(a.behavior.friction);if("vx"===g&&"Mass"===a.behavior.type)return m.real(a.behavior.vx);if("vy"===g&&"Mass"===a.behavior.type)return m.real(a.behavior.vy);if("v"===g&&"Mass"===a.behavior.type)return h.realVector([a.behavior.vx,a.behavior.vy]);if("fx"===g&&"Mass"===a.behavior.type)return m.real(a.behavior.fx);
if("fy"===g&&"Mass"===a.behavior.type)return m.real(a.behavior.fy);if("f"===g&&"Mass"===a.behavior.type)return h.realVector([a.behavior.fx,a.behavior.fy]);if("ldiff"===g&&"Spring"===a.behavior.type)return m.real(a.behavior.ldiff)}c=l[a.type]["get_"+g];return"function"===typeof c?c(a):k},setField:function(a,g,c){"color"===g&&h._helper.isNumberVecN(c,3)&&(a.color=c);"size"===g&&"number"===c.ctype&&(a.size=c);"alpha"===g&&"number"===c.ctype&&(a.alpha=c);"fillcolor"===g&&h._helper.isNumberVecN(c,3)&&
(a.fillcolor=c);"fillalpha"===g&&"number"===c.ctype&&(a.fillalpha=c);"visible"===g&&"boolean"===c.ctype&&(a.visible=c.value);"pinned"===g&&"boolean"===c.ctype&&(a.pinned=c.value);"labeled"!==g&&"labelled"!==g||"boolean"!==c.ctype||(a.labeled=c.value);"printlabel"===g&&(a.printname=Z(c));"trace"===g&&"boolean"===c.ctype&&(c.value&&!a.drawtrace?(a.drawtrace=!0,yd(a)):a.drawtrace=c.value);"P"===a.kind&&a.movable&&("xy"===g&&h._helper.isNumberVecN(c,2)&&La(a,h.turnIntoCSList([c.value[0],c.value[1],m.real(1)]),
"homog"),"xy"===g&&h._helper.isNumberVecN(c,3)&&La(a,c,"homog"),"x"===g&&"number"===c.ctype&&La(a,h.turnIntoCSList([m.mult(c,a.homog.value[2]),a.homog.value[1],a.homog.value[2]]),"homog"),"y"===g&&"number"===c.ctype&&La(a,h.turnIntoCSList([a.homog.value[0],m.mult(c,a.homog.value[2]),a.homog.value[2]]),"homog"),"homog"===g&&h._helper.isNumberVecN(c,3)&&La(a,c,"homog"));"homog"===g&&"L"===a.kind&&a.movable&&h._helper.isNumberVecN(c,3)&&La(a,c,"homog");"Text"===a.kind&&("pressed"===g&&"boolean"===c.ctype&&
a.checkbox&&(a.checkbox.checked=c.value),a.movable&&("xy"===g?h._helper.isNumberVecN(c,2)?a.homog=h.turnIntoCSList([c.value[0],c.value[1],m.real(1)]):h._helper.isNumberVecN(c,3)&&(a.homog=c):"homog"===g&&h._helper.isNumberVecN(c,3)?a.homog=c:"x"===g&&"number"===c.ctype?a.homog=h.turnIntoCSList([m.mult(c,a.homog.value[2]),a.homog.value[1],a.homog.value[2]]):"y"===g&&"number"===c.ctype&&(a.homog=h.turnIntoCSList([a.homog.value[0],m.mult(c,a.homog.value[2]),a.homog.value[2]]))));a.behavior&&("mass"===
g&&"Mass"===a.behavior.type&&"number"===c.ctype&&(a.behavior.mass=c.value.real),"mass"===g&&"Sun"===a.behavior.type&&"number"===c.ctype&&(a.behavior.mass=c.value.real),"friction"===g&&"Mass"===a.behavior.type&&"number"===c.ctype&&(a.behavior.friction=c.value.real),"charge"===g&&"Mass"===a.behavior.type&&"number"===c.ctype&&(a.behavior.charge=c.value.real),"radius"===g&&"Mass"===a.behavior.type&&"number"===c.ctype&&(a.behavior.radius=c.value.real),"vx"===g&&"Mass"===a.behavior.type&&"number"===c.ctype&&
(a.behavior.vx=c.value.real),"vy"===g&&"Mass"===a.behavior.type&&"number"===c.ctype&&(a.behavior.vy=c.value.real),"v"===g&&"Mass"===a.behavior.type&&h._helper.isNumberVecN(c,2)&&(a.behavior.vx=c.value[0].value.real,a.behavior.vy=c.value[1].value.real));g=l[a.type]["set_"+g];if("function"===typeof g)return g(a,c)},getuserData:function(a,g){var c;a.userData&&a.userData[g]&&(c=a.userData[g]);return c&&c.ctype?c:"object"!==typeof c?w.wrap(c):k},setuserData:function(a,g,c){a.userData||(a.userData={});
a.userData[g]=c}};t.version$0=function(a,g){var c=["CindyJS"].concat(ve);return h.turnIntoCSList(c.map(w.wrap))};t.clearconsole$0=function(a,g){wa.clear()};t.err$1=function(a,g){var c="",b;"variable"===a[0].ctype?(c=a[0].name,b=J.getvar(a[0].name)):b=a[0];b=c+" ===> "+Z(z(b));ka(b);return k};t.errc$1=function(a,g){var c;"variable"===a[0].ctype?(c=z(J.getvar(a[0].name)),console.log(a[0].name+" ===> "+Z(c))):(c=z(a[0]),console.log(" ===> "+Z(c)));return k};t.print$1=function(a,g){wa.out(Z(z(a[0])),
!0);return k};t.println$1=function(a,g){wa.out(Z(z(a[0])));return k};t.assert$2=function(a,g){var c=z(a[0]);if("boolean"===c.ctype){if(!1===c.value)return t.println$1([a[1]],g)}else ka("Condition for assert is not boolean");return k};t.dump$1=function(a,g){console.log(JSON.stringify(a[0]));return k};t.repeat$2=function(a,g){return t.repeat$3([a[0],null,a[1]],g)};t.repeat$3=function(a,g){var c=B(a[0]),b="#";null!==a[1]&&"variable"===a[1].ctype&&(b=a[1].name);if("number"!==c.ctype)return k;var c=Math.round(c.value.real),
d=1,h=1,e=c+1,f=!1,m=!1,l=!1,n;void 0!==g.start&&(n=z(g.start),"number"===n.ctype&&(f=!0,h=n.value.real));void 0!==g.step&&(n=z(g.step),"number"===n.ctype&&(l=!0,d=n.value.real));void 0!==g.stop&&(n=z(g.stop),"number"===n.ctype&&(m=!0,e=n.value.real));!f||m||l||(e=d*c+h);f||!m||l||(h=-d*(c-1)+e,e+=d);f||m||!l||(e=d*c+h);f&&m&&!l&&(d=(e-h)/(c-1),e+=d);f&&!m&&l&&(e=d*c+h);!f&&m&&l&&(h=-d*(c-1)+e,e+=d);f&&m&&l&&(e+=d);(h<=e&&0<d||h>=e&&0>d)&&f&&m&&l&&(c=Math.floor((e-h)/d));J.newvar(b);e=k;for(f=0;f<
c;f++)J.setvar(b,{ctype:"number",value:{real:f*d+h,imag:0}}),e=z(a[2]);J.removevar(b);return e};t.while$2=function(a,g){for(var c=a[1],b=a[0],d=z(b),h=k;"list"!==d.ctype&&d.value;)h=z(c),d=z(b);return h};t.apply$2=function(a,g){return t.apply$3([a[0],null,a[1]],g)};t.apply$3=function(a,g){var c=B(a[0]);if("list"!==c.ctype)return k;var b="#";null!==a[1]&&"variable"===a[1].ctype&&(b=a[1].name);var c=c.value,d=[];J.newvar(b);for(var h=0;h<c.length;h++)J.setvar(b,c[h]),d[h]=z(a[2]);J.removevar(b);return{ctype:"list",
value:d}};t.forall$2=function(a,g){return t.forall$3([a[0],null,a[1]],g)};t.forall$3=function(a,g){var c=B(a[0]);if("list"!==c.ctype)return k;var b="#";null!==a[1]&&"variable"===a[1].ctype&&(b=a[1].name);c=c.value;J.newvar(b);for(var d,h=0;h<c.length;h++)J.setvar(b,c[h]),d=z(a[2]);J.removevar(b);return d};t.select$2=function(a,g){return t.select$3([a[0],null,a[1]],g)};t.select$3=function(a,g){var c=B(a[0]);if("list"!==c.ctype)return k;var b="#";null!==a[1]&&"variable"===a[1].ctype&&(b=a[1].name);
var c=c.value,d=[];J.newvar(b);for(var h=0,e=0;e<c.length;e++){J.setvar(b,c[e]);var f=z(a[2]);"boolean"===f.ctype&&!0===f.value&&(d[h]=c[e],h++)}J.removevar(b);return{ctype:"list",value:d}};t.flatten$1=function(a,g){function c(a,g){return-1===g||"list"!==a.ctype?a:[].concat.apply([],a.value.map(function(a){return c(a,g-1)}))}var b=B(a[0]);if("list"!==b.ctype)return b;var d=g.levels;void 0===d?d=1:(d=z(d),d="number"===d.ctype?d.value.real:"string"===d.ctype&&"all"===d.value?-2:1);return{ctype:"list",
value:c(b,d)}};t.createvar$1=function(a,g){"variable"===a[0].ctype&&J.newvar(a[0].name);return k};t.local=function(a,g){for(var c=0;c<a.length;c++)"variable"===a[c].ctype&&J.newvar(a[c].name);return k};t.removevar$1=function(a,g){var c=z(a[0]);"variable"===a[0].ctype&&J.removevar(a[0].name);return c};t.release=function(a,g){if(0===a.length)return k;for(var c=z(a[a.length-1]),b=0;b<a.length;b++)"variable"===a[b].ctype&&J.removevar(a[b].name);return c};t.regional=function(a,g){for(var c=0;c<a.length;c++)if("variable"===
a[c].ctype){var b=a[c].name;J.newvar(b);J.pushVstack(b)}return k};t.genList=function(a,g){return h.turnIntoCSList(a.map(z))};D.assigntake=function(a,g){var c=a.args[0],b=z(c),d=B(a.args[1]),e=k;if("list"===b.ctype||"string"===b.ctype)d=Math.floor(d.value.real),0>d&&(d=b.value.length+d+1),0<d&&d<=b.value.length&&("list"===b.ctype?(e=b.value.slice(),e[d-1]=z(g),e=h.turnIntoCSList(e),b.userData&&(e.userData=b.userData)):(b=b.value,b=b.substring(0,d-1)+Z(z(g))+b.substring(d,b.length),e=w.string(b)));
ab([c,e])};D.assigndot=function(a,g){var c=z(a.obj),b=a.key;"geo"===c.ctype&&b&&ta.setField(c.value,b,B(g));return k};D.assigncolon=function(a,g){var c=a.obj,b=z(c),d=Z(z(a.key));"_?_"===d&&(d=void 0);if("geo"===b.ctype&&d)ta.setuserData(b.value,d,B(g));else if("list"===b.ctype||"string"===b.ctype&&d){var h={},e;for(e in b)h[e]=b[e];if(h.userData){var b={},f;for(f in h.userData)b[f]=h.userData[f];h.userData=b}else h.userData={};h.userData[d]=B(g);ab([c,h])}else d?console.log("User data can only be assigned to geo objects and lists."):
console.log("Key is undefined");return k};D.assignlist=function(a,g){var c=a.length,b=g.length;b<c&&(c=b);for(b=0;b<c;b++)ab([a[b],g[b]],[])};t.if$2=function(a,g){return t.if$3(a,g)};t.if$3=function(a,g){var c=B(a[0]);if("boolean"===c.ctype){if(!0===c.value)return z(a[1]);if(3===a.length)return z(a[2])}else ka("Condition for if is not boolean");return k};t.and$2=Pc;t.or$2=Qc;t.xor$2=function(a,g){var c=B(a[0]),b=B(a[1]);return"boolean"===c.ctype&&"boolean"===b.ctype?{ctype:"boolean",value:c.value!==
b.value}:k};t.not$1=function(a,g){var c=B(a[0]);return"boolean"===c.ctype?{ctype:"boolean",value:!c.value}:k};D.genericListMathGen=function(a,g,c){t[a+"$1"]=function(a,b){var q=z(a[0]);if("list"!==q.ctype)return k;q=q.value;if(0===q.length)return c;for(var d=q[0],h=1;h<q.length;h++)d=g(d,q[h]);return d};var b=a+"$3";t[a+"$2"]=function(a,c){return t[b]([a[0],null,a[1]])};t[b]=function(a,b){var q=B(a[0]);if("list"!==q.ctype)return k;q=q.value;if(0===q.length)return c;var d="#";null!==a[1]&&"variable"===
a[1].ctype&&(d=a[1].name);J.newvar(d);J.setvar(d,q[0]);for(var h=z(a[2]),e=1;e<q.length;e++){J.setvar(d,q[e]);var f=z(a[2]),h=g(h,f)}J.removevar(d);return h}};D.genericListMathGen("product",w.mult,m.real(1));D.genericListMathGen("sum",w.add,m.real(0));D.genericListMathGen("max",w.max,k);D.genericListMathGen("min",w.min,k);t.max$2=function(a,g){var c=B(a[0]);if("list"===c.ctype)return t.max$3([c,null,a[1]]);var b=B(a[1]);return t.max$1([h.turnIntoCSList([c,b])])};t.min$2=function(a,g){var c=B(a[0]);
if("list"===c.ctype)return t.min$3([c,null,a[1]]);var b=B(a[1]);return t.min$1([h.turnIntoCSList([c,b])])};t.add$2=Rc;t.sub$2=jc;t.mult$2=Sc;t.div$2=Tc;t.mod$2=function(a,g){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype?m.mod(c,b):k};t.pow$2=Uc;t.exp$1=function(a,g){var c=B(a[0]);return"number"===c.ctype?m.exp(c):k};t.sin$1=function(a,g){var c=B(a[0]);return"number"===c.ctype?m.sin(c):k};t.sqrt$1=function(a,g){var c=B(a[0]);return"number"===c.ctype?m.sqrt(c):k};D.laguerre=function(a,
g,c){if("list"!==a.ctype)return k;var b=a.value.length-1,d;for(d=0;d<=b;d++)if("number"!==a.value[d].ctype)return k;if("number"!==g.ctype)return k;for(var h=[1,.3141,.5926,.5358,.9793,.2385,.6264,.3383,.2795,.0288],e,f,l,n=1;n<=c;n++){f=l=m.zero;e=a.value[b];for(d=b-1;0<=d;d--)l=m.add(f,m.mult(l,g)),f=m.add(e,m.mult(f,g)),e=m.add(a.value[d],m.mult(e,g));if(m._helper.isLessThan(m.abs(e),m.real(1E-14)))break;d=m.div(f,e);f=m.mult(d,d);e=m.sub(f,m.div(m.mult(m.real(2),l),e));l=m.sqrt(m.mult(m.real(b-
1),m.sub(m.mult(m.real(b),e),f)));e=m.add(d,l);d=m.sub(d,l);m._helper.isLessThan(m.abs(e),m.abs(d))&&(e=d);d=m._helper.isLessThan(m.real(1E-14),m.abs(e))?m.div(m.real(b),e):m.mult(m.add(m.abs(g),m.one),m.complex(Math.cos(n),Math.sin(n)));if(m._helper.isLessThan(m.abs(d),m.real(1E-14)))break;0===n%20&&n<c-19&&(d=m.mult(d,m.real(h[Math.floor(n/20)])));g=m.sub(g,d)}return g};D.quadratic_roots=function(a){if("list"!==a.ctype)return k;var g=a.value[2],c=a.value[1];a=a.value[0];if(m._helper.isZero(a))return[m.zero,
m.neg(m.div(c,g))];var b=m.sqrt(m.sub(m.mult(c,c),m.mult(m.real(4),m.mult(g,a))));0<=m.re(c)&&(b=m.neg(b));return[m.div(m.sub(b,c),m.mult(m.real(2),g)),m.div(m.mult(m.real(2),a),m.sub(b,c))]};D.roots=function(a){var g=[],c=a,b=a.value.length-1;if(0>=b)return h.turnIntoCSList([]);if(m._helper.isZero(a.value[b]))return g=D.roots(h.turnIntoCSList(a.value.slice(0,b))),h.append(g,m.infinity);if(1===b)g[0]=m.neg(m.div(a.value[0],a.value[1]));else if(2===b)g=D.quadratic_roots(a);else{for(var d=0;d<b-2;d++){g[d]=
D.laguerre(a,m.zero,200);g[d]=D.laguerre(c,g[d],1);var e=[];e[b-d]=a.value[b-d];for(var f=b-d;0<f;f--)e[f-1]=m.add(a.value[f-1],m.mult(e[f],g[d]));e.shift();a=h.turnIntoCSList(e)}a=D.quadratic_roots(a);g[b-2]=a[0];g[b-1]=a[1]}return h.turnIntoCSList(g)};t.roots$1=function(a,g){var c=B(a[0]);if("list"===c.ctype){for(var b=0;b<c.value.length;b++)if("number"!==c.value[b].ctype)return k;c=D.roots(c);return h.sort1(c)}return k};t.autodiff$3=function(a,g){var c="x",b;if("function"===a[0].ctype)b=db[a[0].oper].body,
c=a[0].args[0].name;else if("function"===typeof a[0].impl)b=a[0];else return ka("could not parse function"),k;var d=B(a[1]),h=B(a[2]);if(1>h.value.real)return ka("grade cant be < 1"),k;h=m.add(h,m.real(1));return P.autodiff(b,c,d,h)};t.cos$1=function(a,g){var c=B(a[0]);return"number"===c.ctype?m.cos(c):k};t.tan$1=function(a,g){var c=B(a[0]);return"number"===c.ctype?m.tan(c):k};t.arccos$1=function(a,g){var c=B(a[0]);return"number"===c.ctype?m.arccos(c):k};t.arcsin$1=function(a,g){var c=B(a[0]);return"number"===
c.ctype?m.arcsin(c):k};t.arctan$1=function(a,g){var c=B(a[0]);return"number"===c.ctype?m.arctan(c):k};t.arctan2$2=function(a,g){var c=B(a[0]),b=B(a[1]);return"number"===c.ctype&&"number"===b.ctype?m.arctan2(c,b):k};t.arctan2$1=function(a,g){var c=B(a[0]);if("list"===c.ctype&&2===c.value.length){if(c=c.value,"number"===c[0].ctype&&"number"===c[1].ctype)return t.arctan2$2(c,g)}else if("number"===c.ctype)return m.arctan2(c);return k};t.log$1=function(a,g){var c=B(a[0]);return"number"===c.ctype?m.log(c):
k};D.recursiveGen=function(a){var g=m[a],c=h[a];t[a+"$1"]=function(a,b){var d=B(a[0]);return"number"===d.ctype?g(d):"list"===d.ctype?c(d):k}};D.recursiveGen("im");D.recursiveGen("re");D.recursiveGen("conjugate");D.recursiveGen("round");D.recursiveGen("ceil");D.recursiveGen("floor");D.recursiveGen("abs");t.abs_infix=t.abs$1;t.random$0=function(a,g){return m.real(m._helper.rand())};t.random$1=function(a,g){var c=B(a[0]);return"number"===c.ctype?m.complex(c.value.real*m._helper.rand(),c.value.imag*m._helper.rand()):
k};t.seedrandom$1=function(a,g){var c=B(a[0]);"number"===c.ctype&&m._helper.seedrandom(c.value.real);return k};t.randomnormal$0=function(a,g){return m.real(m._helper.randnormal())};t.randominteger$1=function(a,g){var c=B(a[0]);if("number"===c.ctype){var b=c.value.real|0,c=c.value.imag|0,b=b*m._helper.rand()|0,c=c*m._helper.rand()|0;return m.complex(b,c)}return k};t.randomint$1=t.randominteger$1;t.randombool$0=function(a,g){return.5<m._helper.rand()?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};
t.isreal$1=function(a,g){var c=z(a[0]);return"number"===c.ctype&&m._helper.isAlmostReal(c)?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.isinteger$1=function(a,g){var c=z(a[0]);return"number"===c.ctype&&m._helper.isAlmostReal(c)&&c.value.real===Math.floor(c.value.real)?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.iseven$1=function(a,g){var c=z(a[0]);return"number"===c.ctype&&m._helper.isAlmostReal(c)&&c.value.real/2===Math.floor(c.value.real/2)?{ctype:"boolean",value:!0}:{ctype:"boolean",
value:!1}};t.isodd$1=function(a,g){var c=z(a[0]);return"number"===c.ctype&&m._helper.isAlmostReal(c)&&(c.value.real-1)/2===Math.floor((c.value.real-1)/2)?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.iscomplex$1=function(a,g){return"number"===z(a[0]).ctype?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.isstring$1=function(a,g){return"string"===z(a[0]).ctype?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.islist$1=function(a,g){return"list"===z(a[0]).ctype?{ctype:"boolean",
value:!0}:{ctype:"boolean",value:!1}};t.ismatrix$1=function(a,g){var c=z(a[0]);return-1!==h._helper.colNumb(c)?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.iscircle$1=function(a,g){var c=z(a[0]);return"geo"===c.ctype&&"C"===c.value.kind&&"Circle"===c.value.matrix.usage?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.isconic$1=function(a,g){var c=z(a[0]);return"geo"===c.ctype&&"C"===c.value.kind?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.isline$1=function(a,g){var c=
z(a[0]);return"geo"===c.ctype&&"L"===c.value.kind?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.ispoint$1=function(a,g){var c=z(a[0]);return"geo"===c.ctype&&"P"===c.value.kind?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.isgeometric$1=function(a,g){return"geo"===z(a[0]).ctype?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.isnumbermatrix$1=function(a,g){var c=z(a[0]);return h.isNumberMatrix(c)};t.isnumbervector$1=function(a,g){var c=z(a[0]);return h.isNumberVector(c)};
t.issun$1=function(a,g){var c=z(a[0]);return"geo"===c.ctype&&void 0!==c.value.behavior&&"Sun"===c.value.behavior.type?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.ismass$1=function(a,g){var c=z(a[0]);return"geo"===c.ctype&&void 0!==c.value.behavior&&"Mass"===c.value.behavior.type?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.isspring$1=function(a,g){var c=z(a[0]);return"geo"===c.ctype&&void 0!==c.value.behavior&&"Spring"===c.value.behavior.type?{ctype:"boolean",value:!0}:{ctype:"boolean",
value:!1}};t.isbouncer$1=function(a,g){var c=z(a[0]);return"geo"===c.ctype&&void 0!==c.value.behavior&&"Bouncer"===c.value.behavior.type?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};t.isundefined$1=function(a,g){return"undefined"===z(a[0]).ctype?{ctype:"boolean",value:!0}:{ctype:"boolean",value:!1}};var Od={ArcBy3:"Arc",CenterOfConic:"Center",ConicBy1p4l:"Conic1P4L",ConicBy4p1l:"Conic4P1L",ConicBy5lines:"Conic5L",ConicBy2Foci1P:"ConicFoci",ConicFromPrincipalDirections:"ConicPrincipleDirs",
Free:"FreePoint",PolarOfLine:"PolarLine",PolarOfPoint:"PolarPoint",PointOnSegment:"PointOnLine",Button:"Text",ToggleButton:"Text",TrReflectionL:"TrReflection",TrReflectionP:"TrReflection",TrReflectionC:"TrReflection",TrTranslation:"TrProjection",TrSimilarity:"TrProjection",TrAffine:"TrProjection",TransformP:"Transform",TransformL:"Transform",TransformSegment:"Transform",TransformS:"Transform",TransformPolygon:"Transform",TransformArc:"Transform",TransformConic:"Transform",TransformC:"Transform",TrMoebiusP:"Transform",
TrMoebiusL:"Transform",TrMoebiusSegment:"Transform",TrMoebiusS:"Transform",TrMoebiusPolygon:"Transform",TrMoebiusArc:"Transform",TrMoebiusCircle:"Transform",TrMoebiusC:"Transform",TrInverseMoebius:"TrInverse",Perp:"Orthogonal",Para:"Parallel",AngleBisector:"AngularBisector",IntersectLC:"IntersectionConicLine",IntersectCirCir:"IntersectionCircleCircle",OtherPointOnCircle:"PointOnCircle"};t.algorithm$1=function(a,g){var c=z(a[0]);if("geo"===c.ctype){var c=c.value,b=c.type,d=B(g.compatibility);"string"===
d.ctype&&/^cinderella$/i.test(d.value)&&(/^Select/.test(b)&&(c=v.csnames[c.args[0]],b=c.type),Od.hasOwnProperty(b)?b=Od[b]:"CircleMr"===b&&(b=c.pinned?"CircleByFixedRadius":"CircleByRadius"));return w.string(b)}return k};t.inputs$1=function(a,g){var c=z(a[0]);if("geo"===c.ctype){var c=c.value,b=c.type,d=[];c.args&&(d=c.args.map(function(a){return{ctype:"geo",value:v.csnames[a]}}));if(/^Select/.test(b)||l[b].isMovable)switch(c.kind){case "P":case "L":d.push(c.homog);break;case "C":d.push(c.matrix)}return h.turnIntoCSList(d)}return k};
t.moveto$2=function(a,g){var c=z(a[0]),b=B(a[1]);"geo"===c.ctype&&(c=c.value,h._helper.isNumberVecN(b,2)?ta.setField(c,"xy",b):h._helper.isNumberVecN(b,3)&&ta.setField(c,"homog",b));return k};t.continuefromhere$0=function(a,g){zb();return k};t.matrixrowcolumn$1=function(a,g){var c=z(a[0]);return-1!==h._helper.colNumb(c)?h.realVector([c.value.length,c.value[0].value.length]):k};t.rowmatrix$1=function(a,g){var c=z(a[0]);return"list"===c.ctype?h.turnIntoCSList([c]):k};t.columnmatrix$1=function(a,g){var c=
z(a[0]);return"list"===c.ctype?h.turnIntoCSList(c.value.map(function(a){return h.turnIntoCSList([a])})):k};t.submatrix$3=function(a,g){var c=z(a[0]),b=z(a[1]),d=z(a[2]);if("list"===c.ctype&&"number"===b.ctype&&"number"===d.ctype){var e=Math.round(b.value.real),b=Math.round(d.value.real),c=c.value.slice();0<b&&b<=c.length&&c.splice(b-1,1);var f=!0,c=c.map(function(a){if("list"!==a.ctype)f=!1;else return a=a.value.slice(),0<e&&e<=a.length&&a.splice(e-1,1),h.turnIntoCSList(a)});return f?h.turnIntoCSList(c):
k}return k};t.complex$1=function(a,g){var c,b,d;d=B(a[0]);if("list"===d.ctype&&h.isNumberVector(d)){if(2===d.value.length)return c=d.value[0],b=d.value[1],m.complex(c.value.real-b.value.imag,b.value.real+c.value.imag);if(3===d.value.length)return c=d.value[0],b=d.value[1],d=d.value[2],c=m.div(c,d),b=m.div(b,d),m.complex(c.value.real-b.value.imag,b.value.real+c.value.imag)}return k};t.gauss$1=function(a,g){var c=B(a[0]);return"number"===c.ctype?h.realVector([c.value.real,c.value.imag]):k};t.cross$2=
$c;t.crossratio$4=function(a,g){var c=z(a[0]),b=z(a[1]),d=z(a[2]),e=z(a[3]),f=K(c),l=K(b),n=K(d),p=K(e);return f!==k&&l!==k&&n!==k&&p!==k?h.crossratio3(f,l,n,p,h.ii):"number"===c.ctype&&"number"===b.ctype&&"number"===d.ctype&&"number"===e.ctype?m.div(m.mult(m.sub(c,d),m.sub(b,e)),m.mult(m.sub(c,e),m.sub(b,d))):k};t.para$2=function(a,g){var c=B(a[0]),b=B(a[1]),d=K(c),e=K(b);if(c!==k&&b!==k){var b=b.usage,f=d,m=e;if("Line"===c.usage||"Point"===b)f=e,m=d;c=h.cross(h.cross(h.linfty,m),f);return w.withUsage(c,
"Line")}return k};t.perp$2=function(a,g){var c=B(a[0]),b=B(a[1]),d=K(c),e=K(b);if(c!==k&&b!==k){var f=b.usage||e.usage,b=d,l=e;if("Line"===(c.usage||d.usage)||"Point"===f)b=e,l=d;c=h.turnIntoCSList([l.value[0],l.value[1],m.zero]);c=h.cross(c,b);return w.withUsage(c,"Line")}return k};t.perp$1=function(a,g){var c=B(a[0]);return h._helper.isNumberVecN(c,2)?h.turnIntoCSList([m.neg(c.value[1]),c.value[0]]):k};t.parallel$2=t.para$2;t.perpendicular$2=t.perp$2;t.perpendicular$1=t.perp$1;t.meet$2=function(a,
g){var c=K(a[0]),b=K(a[1]);return c!==k&&b!==k?(c=h.cross(c,b),w.withUsage(c,"Point")):k};t.join$2=function(a,g){var c=K(a[0]),b=K(a[1]);return c!==k&&b!==k?(c=h.cross(c,b),w.withUsage(c,"Line")):k};t.dist$2=function(a,g){var c=B(a[0]),b=B(a[1]),c=jc([c,b],[]);return t.abs$1([c],[])};t.dist_infix=t.dist$2;t.point$1=function(a,g){var c=z(a[0]);return h._helper.isNumberVecN(c,3)||h._helper.isNumberVecN(c,2)?w.withUsage(c,"Point"):c};t.line$1=function(a,g){var c=z(a[0]);return h._helper.isNumberVecN(c,
3)?w.withUsage(c,"Line"):c};t.det$3=function(a,g){var c=K(a[0]),b=K(a[1]),d=K(a[2]);if(c!==k&&b!==k&&d!==k)return h.det3(c,b,d)};t.det$1=function(a,g){var c=B(a[0]);if("list"===c.ctype){var b=h._helper.colNumb(c);if(-1!==b&&b===c.value.length)return h.det(c)}return k};t.eig$1=function(a,g){var c=B(a[0]);if("list"===c.ctype){var b=h._helper.colNumb(c);if(-1!==b&&b===c.value.length)return h.eig(c)}return k};t.eigenvalues$1=function(a,g){var c=B(a[0]);if("list"===c.ctype){var b=h._helper.colNumb(c);
if(-1!==b&&b===c.value.length)return h.eig(c,!1).value[0]}return k};t.rank$1=function(a,g){var c=B(a[0]);if("list"===c.ctype){var b=h._helper.colNumb(c);if(-1!==b&&b===c.value.length)return h.rank(c,g.precision)}return k};t.kernel$1=function(a,g){var c=B(a[0]);if("list"===c.ctype){var b=h._helper.colNumb(c);if(-1!==b&&b===c.value.length)return c=h.nullSpace(c,g.precision),h.transpose(c)}return k};t.eigenvectors$1=function(a,g){var c=B(a[0]);if("list"===c.ctype){var b=h._helper.colNumb(c);if(-1!==
b&&b===c.value.length)return h.eig(c).value[1]}return k};t.area$3=function(a,g){var c=K(a[0]),b=K(a[1]),d=K(a[2]);if(c!==k&&b!==k&&d!==k){var e=c.value[2],f=b.value[2],l=d.value[2];if(!m._helper.isAlmostZero(e)&&!m._helper.isAlmostZero(f)&&!m._helper.isAlmostZero(l))return c=h.scaldiv(e,c),b=h.scaldiv(f,b),d=h.scaldiv(l,d),c=h.det3(c,b,d),m.realmult(.5,c)}return k};t.inverse$1=function(a,g){var c=B(a[0]);if("list"===c.ctype){var b=h._helper.colNumb(c);if(-1!==b&&b===c.value.length)return h.inverse(c)}return k};
t.linearsolve$2=function(a,g){var c=B(a[0]),b=B(a[1]);if("list"===c.ctype){var d=h._helper.colNumb(c);if(-1!==d&&d===c.value.length&&h._helper.isNumberVecN(b,d))return h.linearsolve(c,b)}return k};var be=[[[]],[[0]],[[0,1],[1,0]],[[0,1,2],[0,2,1],[1,0,2],[1,2,0],[2,0,1],[2,1,0]],[[0,1,2,3],[0,1,3,2],[0,2,1,3],[0,2,3,1],[0,3,1,2],[0,3,2,1],[1,0,2,3],[1,0,3,2],[1,2,0,3],[1,2,3,0],[1,3,0,2],[1,3,2,0],[2,0,1,3],[2,0,3,1],[2,1,0,3],[2,1,3,0],[2,3,0,1],[2,3,1,0],[3,0,1,2],[3,0,2,1],[3,1,0,2],[3,1,2,0],
[3,2,0,1],[3,2,1,0]]];t.mincostmatching$1=function(a,g){var c=z(a[0]);if(h.isNumberMatrix(c).value){var b=c.value.length,d=h._helper.colNumb(c),e=b<d?d:b,f,l,n=Array(e);for(f=0;f<e;++f)for(n[f]=Array(e),l=0;l<e;++l)n[f][l]=f<b&&l<d?c.value[f].value[l].value.real:0;c=uc(n);e=Array(b);for(f=0;f<b;++f)l=c[f],e[f]=l<d?m.real(l+1):m.real(0);return h.turnIntoCSList(e)}return k};t.take$2=vc;t.length$1=function(a,g){var c=z(a[0]);return"list"===c.ctype||"string"===c.ctype?m.real(c.value.length):k};t.pairs$1=
function(a,g){var c=z(a[0]);return"list"===c.ctype?h.pairs(c):k};t.triples$1=function(a,g){var c=z(a[0]);return"list"===c.ctype?h.triples(c):k};t.cycle$1=function(a,g){var c=z(a[0]);return"list"===c.ctype?h.cycle(c):k};t.consecutive$1=function(a,g){var c=z(a[0]);return"list"===c.ctype?h.consecutive(c):k};t.reverse$1=function(a,g){var c=z(a[0]);return"list"===c.ctype?h.reverse(c):k};t.directproduct$2=function(a,g){var c=z(a[0]),b=z(a[1]);return"list"===c.ctype&&"list"===b.ctype?h.directproduct(c,b):
k};t.concat$2=ad;t.common$2=bd;t.remove$2=cd;t.append$2=dd;t.prepend$2=ed;t.contains$2=function(a,g){var c=z(a[0]),b=z(a[1]);return"list"===c.ctype?h.contains(c,b):k};t.sort$2=function(a,g){return t.sort$3([a[0],null,a[1]],g)};t.sort$3=function(a,g){var c=B(a[0]);if("list"!==c.ctype)return k;var b="#";null!==a[1]&&"variable"===a[1].ctype&&(b=a[1].name);var c=c.value,d=[];J.newvar(b);var h;for(h=0;h<c.length;h++)J.setvar(b,c[h]),d[h]={val:c[h],result:z(a[2])};J.removevar(b);d.sort(w.compareResults);
b=[];for(h=0;h<c.length;h++)b[h]=d[h].val;return{ctype:"list",value:b}};t.sort$1=function(a,g){var c=z(a[0]);return"list"===c.ctype?h.sort1(c):k};t.set$1=function(a,g){var c=z(a[0]);return"list"===c.ctype?h.set(c):k};t.combinations$2=function(a,g){function c(a,g){a===f?n.push(h.turnIntoCSList(l.slice())):g<e&&(l[a]=b.value[g],c(a+1,g+1),c(a,g+1))}var b=z(a[0]),d=z(a[1]),e,f,l,n;if("number"===d.ctype){f=d.value.real|0;if("number"===b.ctype){e=b.value.real|0;e-f<f&&(f=e-f);if(0>f)return m.real(0);if(0===
f)return m.real(1);if(1===f)return b;for(var p=d=1,r=1;r<=f;++r)var t=e-f+r|0,u=r|0,v=wc(t,u)|0,t=t/v|0,u=u/v|0,v=wc(d,u)|0,d=d/v|0,u=u/v|0,v=wc(t,p)|0,t=t/v|0,p=p/v|0,d=d*t|0,p=p*u|0;return m.real(d/p)}if("list"===b.ctype){e=b.value.length;if(0>f||f>e)return h.turnIntoCSList([]);if(0===f)return h.turnIntoCSList([h.turnIntoCSList([])]);if(f===e)return h.turnIntoCSList([b]);n=[];l=Array(f);c(0,0);return h.turnIntoCSList(n)}}return k};t.zeromatrix$2=function(a,g){var c=B(a[0]),b=B(a[1]);return"number"===
c.ctype&&"number"===b.ctype?h.zeromatrix(c,b):k};t.zerovector$1=function(a,g){var c=B(a[0]);return"number"===c.ctype?h.zerovector(c):k};t.transpose$1=function(a,g){var c=B(a[0]);return"list"===c.ctype&&-1!==h._helper.colNumb(c)?h.transpose(c):k};t.row$2=function(a,g){var c=B(a[0]),b=B(a[1]);return"number"===b.ctype&&"list"===c.ctype&&-1!==h._helper.colNumb(c)?h.row(c,b):k};t.column$2=function(a,g){var c=B(a[0]),b=B(a[1]);return"number"===b.ctype&&"list"===c.ctype&&-1!==h._helper.colNumb(c)?h.column(c,
b):k};t.dict$0=function(a,g){var c=Na.create(),b;for(b in g)g.hasOwnProperty(b)&&Na.put(c,w.string(b),z(g[b]));return c};t.put$3=function(a,g){var c=z(a[0]),b=z(a[1]),d=z(a[2]);return"dict"===c.ctype?(c=Na.clone(c),Na.put(c,b,d),c):k};t.get$2=function(a,g){var c=z(a[0]),b=z(a[1]);return"dict"===c.ctype?Na.get(c,b,k):k};t.red$1=function(a,g){var c=z(a[0]);return"number"===c.ctype?h.realVector([Math.min(1,Math.max(0,c.value.real)),0,0]):k};t.green$1=function(a,g){var c=z(a[0]);return"number"===c.ctype?
h.realVector([0,Math.min(1,Math.max(0,c.value.real)),0]):k};t.blue$1=function(a,g){var c=z(a[0]);return"number"===c.ctype?h.realVector([0,0,Math.min(1,Math.max(0,c.value.real))]):k};t.gray$1=function(a,g){var c=z(a[0]);return"number"===c.ctype?(c=Math.min(1,Math.max(0,c.value.real)),h.realVector([c,c,c])):k};t.grey$1=t.gray$1;D.HSVtoRGB=function(a,g,c){var b,d,e,f,k,m;a&&void 0===g&&void 0===c&&(g=a.s,c=a.v,a=a.h);f=Math.floor(6*a);k=6*a-f;a=c*(1-g);m=c*(1-k*g);g=c*(1-(1-k)*g);switch(f%6){case 0:b=
c;d=g;e=a;break;case 1:b=m;d=c;e=a;break;case 2:b=a;d=c;e=g;break;case 3:b=a;d=m;e=c;break;case 4:b=g;d=a;e=c;break;case 5:b=c,d=a,e=m}return h.realVector([b,d,e])};t.hue$1=function(a,g){var c=z(a[0]);return"number"===c.ctype?(c=c.value.real,c-=Math.floor(c),D.HSVtoRGB(c,1,1)):k};D.shapeconvert=function(a){var g,c;if("circle"===a.type){g=a.value.value[0];g=w.div(g,g.value[2]);var b=g.value[0].value.real,d=g.value[1].value.real;a=a.value.value[1].value.real;c=Array(125);var h=2*Math.PI/125;for(g=0;125>
g;g++)c[g]={X:b+Math.cos(g*h)*a,Y:d+Math.sin(g*h)*a};return[c]}if("polygon"===a.type){b=[];for(g=0;g<a.value.length;g++){d=a.value[g];c=[];for(h=0;h<d.length;h++)c[h]={X:d[h].X,Y:d[h].Y};b[g]=c}return b}};D.shapeop=function(a,g,c){a=D.shapeconvert(a);var b=D.shapeconvert(g);ClipperLib.JS.ScaleUpPaths(a,1E3);ClipperLib.JS.ScaleUpPaths(b,1E3);g=new ClipperLib.Clipper;g.AddPaths(a,ClipperLib.PolyType.ptSubject,!0);g.AddPaths(b,ClipperLib.PolyType.ptClip,!0);var b=a=ClipperLib.PolyFillType.pftNonZero,
d=new ClipperLib.Paths;g.Execute(c,d,a,b);ClipperLib.JS.ScaleDownPaths(d,1E3);return{ctype:"shape",type:"polygon",value:d}};D.shapecommon=function(a,g){return D.shapeop(a,g,ClipperLib.ClipType.ctIntersection)};D.shaperemove=function(a,g){return D.shapeop(a,g,ClipperLib.ClipType.ctDifference)};D.shapeconcat=function(a,g){return D.shapeop(a,g,ClipperLib.ClipType.ctUnion)};t.key$0=function(a,g){return{ctype:"string",value:Yc}};t.keycode$0=function(a,g){return m.real(Zc)};t.mouse$0=function(a,g){return h.realVector([ra[0],
ra[1]])};t.mover$0=function(a,g){if(ja&&ja.mover)return{ctype:"geo",value:ja.mover};console.log("Not moving anything at the moment");return k};t.translate$1=function(a,g){var c=B(a[0]);"list"===c.ctype&&h.isNumberVector(c)&&2===c.value.length&&y.translate(c.value[0].value.real,c.value[1].value.real);return k};t.rotate$1=function(a,g){var c=B(a[0]);"number"===c.ctype&&y.rotate(c.value.real);return k};t.scale$1=function(a,g){var c=B(a[0]);"number"===c.ctype&&y.scale(c.value.real);return k};t.greset$0=
function(a,g){var c=eb.stack.length;y.greset();for(var b=0;b<c;b++)A.restore();return k};t.gsave$0=function(a,g){y.gsave();A.save();return k};t.grestore$0=function(a,g){y.grestore();A.restore();return k};t.color$1=function(a,g){var c=B(a[0]);"list"===c.ctype&&h.isNumberVector(c).value&&y.setcolor(c);return k};t.linecolor$1=function(a,g){var c=B(a[0]);"list"===c.ctype&&h.isNumberVector(c).value&&y.setlinecolor(c);return k};t.pointcolor$1=function(a,g){var c=B(a[0]);"list"===c.ctype&&h.isNumberVector(c).value&&
y.setpointcolor(c);return k};t.alpha$1=function(a,g){var c=B(a[0]);"number"===c.ctype&&y.setalpha(c);return k};t.pointsize$1=function(a,g){var c=B(a[0]);"number"===c.ctype&&y.setpointsize(c);return k};t.linesize$1=function(a,g){var c=B(a[0]);"number"===c.ctype&&y.setlinesize(c);return k};t.textsize$1=function(a,g){var c=B(a[0]);"number"===c.ctype&&y.settextsize(c);return k};t.playanimation$0=function(a,g){M();return k};t.pauseanimation$0=function(a,g){Ga();return k};t.stopanimation$0=function(a,g){Ha();
return k};t.text$1=function(a,g){var c=B(a[0]);return w.string(Z(c))};t.replace$3=function(a,g){var c=z(a[0]),b=z(a[1]),d=z(a[2]);if("string"===c.ctype&&"string"===b.ctype&&"string"===d.ctype)return c=c.value,b=b.value.replace(/[^A-Za-z0-9]/g,"\\$&"),d=d.value.replace(/\$/g,"$$$$"),c=c.replace(new RegExp(b,"g"),d),{ctype:"string",value:c}};t.replace$2=function(a,g){function c(a,c,g){var h="";d=b=-1;for(var e=0;e<c.length;e++){var f=c[e][0],k=a.indexOf(f,g);-1!==k&&(-1===b?(h=f,b=k,d=e):k<b&&(h=f,
b=k,d=e))}return h}var b,d,h,e=z(a[0]);h=z(a[1]);if("string"===e.ctype&&"list"===h.ctype){for(var e=e.value,f=[],m=0;m<h.value.length;m++){var l=h.value[m];"list"===l.ctype&&2===l.value.length&&"string"===l.value[0].ctype&&"string"===l.value[1].ctype&&(f[f.length]=[l.value[0].value,l.value[1].value])}b=-1;for(h=c(e,f,0);-1!==b;)e=e.substring(0,b)+f[d][1]+e.substring(b+h.length,e.length),h=b+f[d][1].length,h=c(e,f,h);return{ctype:"string",value:e}}return k};t.substring$3=function(a,g){var c=z(a[0]),
b=B(a[1]),d=B(a[2]);return"string"===c.ctype&&"number"===b.ctype&&"number"===d.ctype?{ctype:"string",value:c.value.substring(Math.floor(b.value.real),Math.floor(d.value.real))}:k};t.tokenize$2=function(a,g){var c=z(a[0]),b=z(a[1]);if("string"===c.ctype&&"string"===b.ctype)return t.tokenize$2([c,h.turnIntoCSList([b])],g);if("string"===c.ctype&&"list"===b.ctype){c=c.value;if(0===b.value.length){b=!0;if(void 0!==g.autoconvert){var d=z(g.autoconvert);"boolean"===d.ctype&&(b=d.value)}return b&&""!==c&&
(b=Number(c),!isNaN(b))?m.real(b):w.string(c)}var d=b.value[0],e=h.turnIntoCSList(b.value.slice(1)),c=c.split(d.value);return h.turnIntoCSList(c.map(function(a){return t.tokenize$2([w.string(a),e],g)}))}return k};t.indexof$2=function(a,g){var c=z(a[0]),b=z(a[1]);return"string"===c.ctype&&"string"===b.ctype?(c=c.value.indexOf(b.value),m.real(c+1)):k};t.indexof$3=function(a,g){var c=z(a[0]),b=z(a[1]),d=z(a[2]);return"string"===c.ctype&&"string"===b.ctype&&"number"===d.ctype?(c=c.value.indexOf(b.value,
Math.round(d.value.real)-1),m.real(c+1)):k};t.parse$1=function(a,g){var c=z(a[0]);return"string"===c.ctype?(c=Ua(c.value),z(c)):k};t.unicode$1=function(a,g){var c;c=z(a[0]);var b=16;if(g.base){var d=z(g.base);"number"===d.ctype&&(b=d.value.real)}if("string"===c.ctype)c=parseInt(c.value,b);else if("number"===c.ctype)c=c.value.real;else return k;"undefined"!==typeof String.fromCodePoint?c=String.fromCodePoint(c):65535>=c?c=String.fromCharCode(c):(c-=65536,c=String.fromCharCode((c>>10)+55296,(c&1023)+
56320));return w.string(c)};t.international$1=function(a,g){return t.international$2([a[0],null],g)};t.international$2=function(a,g){var c=z(a[0]);if("string"!==c.ctype)return k;var b=(p.translations||{})[p.language||"en"]||{};if(!b.hasOwnProperty(c.value))return c;var d=b[c.value];if("string"===typeof d)return w.string(d);if(null===a[1])return c;var h=z(a[1]),h="number"===h.ctype?h.value.real:0,b=(b._pluralFormFunction||ce)(h);return b<d.length?w.string(d[b]):c};t.currentlanguage$0=function(a,g){return w.string(p.language||
"en")};D.basismap=function(a,g,c,b){var d=h.turnIntoCSList([a,g,c]),d=h.adjoint3(h.transpose(d));b=w.mult(d,b);d=h.turnIntoCSList([w.mult(b.value[0],a),w.mult(b.value[1],g),w.mult(b.value[2],c)]);return h.transpose(d)};t.map$8=function(a,g){var c=K(a[0]),b=K(a[1]),d=K(a[2]),e=K(a[3]),f=K(a[4]),m=K(a[5]),l=K(a[6]),n=K(a[7]);return f!==k&&m!==k&&l!==k&&n!==k&&c!==k&&b!==k&&d!==k&&e!==k?(f=D.basismap(f,m,l,n),c=D.basismap(c,b,d,e),c=w.mult(f,h.adjoint3(c)),h.normalizeMax(c)):k};t.map$6=function(a,g){var c=
K(a[0]),b=K(a[1]),d=K(a[2]),e=h.realVector([0,0,1]),f=h.cross,m=f(f(d,f(e,f(c,b))),f(b,f(e,f(c,d)))),l=K(a[3]),n=K(a[4]),p=K(a[5]),e=f(f(p,f(e,f(l,n))),f(n,f(e,f(l,p))));return l!==k&&n!==k&&p!==k&&e!==k&&c!==k&&b!==k&&d!==k&&m!==k?(l=D.basismap(l,n,p,e),c=D.basismap(c,b,d,m),c=w.mult(l,h.adjoint3(c)),h.normalizeMax(c)):k};t.map$4=function(a,g){var c=h.ii,b=h.jj,d=K(a[0]),e=K(a[1]),f=K(a[2]),m=K(a[3]);return f!==k&&m!==k&&d!==k&&e!==k?(f=D.basismap(f,m,c,b),c=D.basismap(d,e,c,b),c=w.mult(f,h.adjoint3(c)),
h.normalizeMax(c)):k};t.map$2=function(a,g){var c=h.ii,b=h.jj,d=K(a[0]),e=w.add(h.realVector([1,0,0]),d),f=K(a[1]),m=w.add(h.realVector([1,0,0]),f);return f!==k&&m!==k&&d!==k&&e!==k?(f=D.basismap(f,m,c,b),c=D.basismap(d,e,c,b),c=w.mult(f,h.adjoint3(c)),h.normalizeMax(c)):k};t.pointreflect$1=function(a,g){var c=h.ii,b=h.jj,d=K(a[0]),e=w.add(h.realVector([1,0,0]),d),f=w.add(h.realVector([-1,0,0]),d);return f!==k&&d!==k&&e!==k?(f=D.basismap(d,f,c,b),c=D.basismap(d,e,c,b),c=w.mult(f,h.adjoint3(c)),h.normalizeMax(c)):
k};t.linereflect$1=function(a,g){var c=h.ii,b=h.jj,d=K(a[0]),e=h.realVector([Math.random(),Math.random(),Math.random()]),f=h.realVector([Math.random(),Math.random(),Math.random()]),e=h.cross(e,d),f=h.cross(f,d);return d!==k&&e!==k?(d=D.basismap(e,f,c,b),c=D.basismap(e,f,b,c),c=w.mult(d,h.adjoint3(c)),h.normalizeMax(c)):k};D.extractPointVec=function(a){var g={ok:!1};if("geo"===a.ctype){var c=a.value;if("P"===c.kind)return g.x=ta.getField(c,"x"),g.y=ta.getField(c,"y"),g.z=m.real(1),g.ok=!0,g}if("list"!==
a.ctype)return g;var b=a.value;if(2===b.length&&(a=b[0],c=b[1],"number"===a.ctype&&"number"===c.ctype))return g.x=a,g.y=c,g.z=m.real(1),g.ok=!0,g;3===b.length&&(a=b[0],c=b[1],b=b[2],"number"===a.ctype&&"number"===c.ctype&&"number"===b.ctype&&(g.x=m.div(a,b),g.y=m.div(c,b),g.z=m.real(1),g.ok=!0));return g};t.polygon$1=function(a,g){var c=z(a[0]);if("list"===c.ctype){for(var b=[],d=0;d<c.value.length;d++){var h=D.extractPoint(c.value[d]);if(!h.ok)return k;b[d]={X:h.x,Y:h.y}}return{ctype:"shape",type:"polygon",
value:[b]}}return k};t.circle$2=function(a,g){var c=B(a[0]),b=B(a[1]),c=D.extractPointVec(c);if(!c.ok||"number"!==b.ctype)return k;c=h.turnIntoCSList([c.x,c.y,c.z]);return{ctype:"shape",type:"circle",value:h.turnIntoCSList([c,b])}};t.screen$0=function(a,g){var c=y.drawingstate.initialmatrix,b=function(a,g){var b=a-c.tx,d=g+c.ty;return{X:(b*c.d-d*c.b)/c.det,Y:-(-b*c.c+d*c.a)/c.det}};return{ctype:"shape",type:"polygon",value:[[b(0,0),b(ca,0),b(ca,da),b(0,da)]]}};t.halfplane$2=function(a,g){var c=B(a[0]),
b=B(a[1]),d=K(c),e=K(b);if(c!==k&&b!==k){var f=b.usage,b=d,l=e;if("Line"===c.usage||"Point"===f)b=e,l=d;c=h.turnIntoCSList([l.value[0],l.value[1],m.zero]);c=h.cross(c,b);c=h.cross(l,c);c=w.div(c,c.value[2]);b=w.div(b,b.value[2]);b=h.sub(b,c);l=h.abs(b);b=w.div(b,l);l=c.value[0].value.real;c=c.value[1].value.real;d=1E3*b.value[0].value.real;b=1E3*b.value[1].value.real;return{ctype:"shape",type:"polygon",value:[[{X:l+b/2,Y:c-d/2},{X:l+b/2+d,Y:c-d/2+b},{X:l-b/2+d,Y:c+d/2+b},{X:l-b/2,Y:c+d/2}]]}}return k};
t.element$1=function(a,g){var c=z(a[0]);return"string"===c.ctype&&v.csnames.hasOwnProperty(c.value)?{ctype:"geo",value:v.csnames[c.value]}:k};D.all$1=function(a,g){var c=z(a[0]);return"geo"===c.ctype&&c.value.incidences?h.ofGeos(c.value.incidences.map(function(a){return v.csnames[a]}).filter(g)):h.nil};t.allpoints$0=function(a,g){return h.ofGeos(v.points)};t.allpoints$1=function(a,g){return D.all$1(a,function(a){return"P"===a.kind})};t.allmasses$0=function(a,g){return h.ofGeos(ma)};t.allmasses$1=
function(a,g){return D.all$1(a,function(a){return"P"===a.kind&&a.behavior&&"Mass"===a.behavior.type})};t.allsprings$0=function(a,g){return h.ofGeos(Hc)};t.allsprings$1=function(a,g){return D.all$1(a,function(a){return"S"===a.kind&&a.behavior&&"Spring"===a.behavior.type})};t.alllines$0=function(a,g){return h.ofGeos(v.lines)};t.alllines$1=function(a,g){return D.all$1(a,function(a){return"L"===a.kind||"S"===a.kind})};t.allsegments$0=function(a,g){return h.ofGeos(v.lines.filter(function(a){return"S"===
a.kind}))};t.allsegments$1=function(a,g){return D.all$1(a,function(a){return"S"===a.kind})};t.allconics$0=function(a,g){return h.ofGeos(v.conics)};t.allconics$1=function(a,g){return D.all$1(a,function(a){return"C"===a.kind})};t.allcircles$0=function(a,g){return h.ofGeos(v.conics.filter(function(a){return"Circle"===a.matrix.usage}))};t.allcircles$1=function(a,g){return D.all$1(a,function(a){return"C"===a.kind&&"Circle"===a.matrix.usage})};t.allelements$0=function(a,g){return h.ofGeos(v.gslp)};t.allelements$1=
function(a,g){return D.all$1(a,function(a){return!0})};t.elementsatmouse$0=function(a,g){var c=h.realVector([ra[0],ra[1],1]),b=function(a){if(m._helper.isAlmostZero(a.value[2]))return Infinity;a=h.normalizeZ(a);return h.abs(h.sub(a,c)).value.real},d=function(a){a=h.turnIntoCSList([a.value[0],a.value[1],m.zero]);return h.normalizeMax(h.cross(c,a))},e=function(a){var g=w.mult(a.matrix,c),g=d(g);a=l._helper.IntersectLC(g,a.matrix).map(function(a){return b(a)});return.5>Math.min(a[0],a[1])},f=v.points.filter(function(a){return.5>
b(a.homog)}),k=v.lines.filter(function(a){var g;g=d(a.homog);g=h.normalizeMax(h.cross(a.homog,g));if((g=.5>b(g))&&"S"===a.kind){var e=a.homog,e=h.turnIntoCSList([e.value[0],e.value[1],m.zero]);a=h.crossratio3(a.farpoint,a.startpos,a.endpos,c,e).value.real;if(0>a||1<a)g=!1}return g}),n=v.conics.filter(function(a){var g=e(a);if(g&&a.isArc){var b=h.crossratio3harm(a.startPoint,a.endPoint,a.viaPoint,c,h.ii);a=b.value[0];b=b.value[1];m._helper.isAlmostZero(a)?(a=m.div(a,b),b=m.real(1)):(b=m.div(b,a),a=
m.real(1));var d=h.abs(h.turnIntoCSList([b,a]));a=m.div(a,d);b=m.div(b,d);b=m.mult(b,a);0>a.value.real&&(b=m.neg(b));0>b.value.real&&(g=!1)}return g}),f=f.concat(k,n);return h.ofGeos(f)};t.incidences$1=t.allelements$1;t.createpoint$2=function(a,g){var c=z(a[0]),b=K(a[1]);return"string"!==c.ctype?(ka("Name must be a string"),k):"list"!==b.ctype&&h.isNumberVector(b)?(ka("Position must be a number vector"),k):Ka({name:c.value,type:"Free",labeled:!0,pos:b})};t.create$3=function(a,g){var c=z(a[0]),b=z(a[1]),
d=z(a[2]),e,f;if("string"===c.ctype)e=c.value;else{if("list"!==c.ctype)return ka("Names must be a string or a list of strings"),k;if(1!==c.value.length){e=w.string(c.value.map(function(a){return a.value}).join("__"));e=t.create$3([e,b,d],g);if(e!==k)for(b=w.string(e.kind.replace(/^(.*)s$/,"Select$1")),d=h.turnIntoCSList([w.string(e.name)]),f=0;f<c.value.length;++f)t.create$3([c.value[f],b,d],{index:m.real(f+1)});return e}if("string"!==c.value[0].ctype)return ka("Element of names list must be a string"),
k;e=c.value[0].value}if("string"!==b.ctype)return ka("Type must be a string"),k;if("list"!==d.ctype)return ka("Arguments must be a list"),k;if(!l.hasOwnProperty(b.value)&&!Ac.hasOwnProperty(b.value)&&!zd.hasOwnProperty(b.value))return ka("Invalid geometric operation: '"+b.value+"'"),k;var c=[],n=null;for(f=0;f<d.value.length;f++){var p=d.value[f];if("string"===p.ctype)c.push(p.value);else if("geo"===p.ctype)c.push(p.value.name);else if(n=K(p),n===k)return ka("Unknown argument type"),k}e={name:e,type:b.value,
labeled:!0};n&&(e.pos=n);0<c.length&&(e.args=c);b=B(g.index);"number"===b.ctype&&(e.index=b.value.real|0);return Ka(e)};t.javascript$1=function(a,g){var c=z(a[0]);"string"===c.ctype&&(new Function(c.value)).call(sa);return k};t.use$1=function(a,g){function c(a,c,g){t[a.toLowerCase()+"$"+c]=g}var b=z(a[0]);if("string"===b.ctype){var b=b.value,d;p.plugins&&(d=p.plugins[b]);d||(d=va._pluginRegistry[b]);if(d)return d({instance:sa,config:p,nada:k,evaluate:z,extractPoint:D.extractPoint,evaluateAndVal:B,
defineFunction:c,addShutdownHook:jb.push.bind(jb),addAutoCleaningEventListener:H,getVariable:J.getvar.bind(J),getInitialMatrix:function(){return y.drawingstate.initialmatrix},setTextRenderer:function(a,c){Jc=a;c&&(Bd=c)},getImage:function(a,c){"string"===typeof a&&(a=w.string(a));var g=Ja(a);if(!g)return null;!c&&g.cdyUpdate&&g.cdyUpdate();return g},getMyfunction:function(a){return db.hasOwnProperty(a)?db[a]:null}}),{ctype:"boolean",value:!0};ka("Plugin "+b+" not found");return{ctype:"boolean",value:!1}}return k};
t.format$2=function(a,g){function c(a){a=a.toFixed(e);var c;do c=a,a=a.substring(0,a.length-1);while(""!==a&&"-"!==a&&+a===+c);return""+c}function b(a){var g;return"number"===a.ctype?(g=c(a.value.real),a=c(a.value.imag),g="0"===a?g:"-"===a.substring(0,1)?g+" - i*"+a.substring(1):g+" + i*"+a,{ctype:"string",value:g}):"list"===a.ctype?{ctype:"list",value:a.value.map(b)}:{ctype:"string",value:Z(a).toString()}}var d=B(a[0]),h=B(a[1]),e;return"number"!==d.ctype&&"list"!==d.ctype||"number"!==h.ctype?k:
(e=Math.max(0,Math.min(20,Math.round(h.value.real))),b(d))};Date.now||(Date.now=function(){return(new Date).getTime()});var Pd=0;t.timestamp$0=function(a,g){return m.real(Date.now())};t.seconds$0=function(a,g){return m.real((Date.now()-Pd)/1E3)};t.resetclock$0=function(a,g){Pd=Date.now();return k};t.time$0=function(a,g){var c=new Date;return h.realVector([c.getHours(),c.getMinutes(),c.getSeconds(),c.getMilliseconds()])};t.date$0=function(a,g){var c=new Date;return h.realVector([c.getFullYear(),c.getMonth()+
1,c.getDate()])};t.simulationtime$0=function(a,g){return m.real(Ib*Md)};t.settimeout$2=function(a,g){function c(){z(d);e()}var b=z(a[0]),d=a[1];"number"===b.ctype&&"undefined"!==typeof window&&window.setTimeout(c,1E3*b.value.real);return k};D.formatForWebGL=function(a){return a.toFixed(10)};t.generateWebGL$2=function(a,g){var c=D.formatForWebGL,b=a[0],d=z(a[1]);console.log(d);if("list"!==d.ctype)return k;for(var h=[],e=0;e<d.value.length;e++)"string"===d.value[e].ctype&&h.push(d.value[e].value);console.log("***********");
console.log(h);d=D.plotvars(b);console.log(d);-1===d.indexOf("a")&&-1===d.indexOf("b")&&-1===d.indexOf("c")&&-1===d.indexOf("d")&&-1===d.indexOf("e")&&-1===d.indexOf("f")&&(b=B(b));if("number"===b.ctype)return{ctype:"string",value:"vec2("+c(b.value.real)+","+c(b.value.imag)+")"};if("variable"===b.ctype)return{ctype:"string",value:b.name};if("string"===b.ctype||"void"===b.ctype)return b;if(2===b.args.length&&("infix"===b.ctype||"function"===b.ctype)){c=t.compileToWebGL$1([b.args[0]],{});d=t.compileToWebGL$1([b.args[1]],
{});if("+"===b.oper||"add"===b.oper)return void 0===c.value||"void"===c.ctype?{ctype:"string",value:d.value}:{ctype:"string",value:"addc("+c.value+","+d.value+")"};if("*"===b.oper||"mult"===b.oper)return{ctype:"string",value:"multc("+c.value+","+d.value+")"};if("/"===b.oper||"div"===b.oper)return{ctype:"string",value:"divc("+c.value+","+d.value+")"};if("-"===b.oper||"sub"===b.oper)return void 0===c.value||"void"===c.ctype?{ctype:"string",value:"negc("+d.value+")"}:{ctype:"string",value:"subc("+c.value+
","+d.value+")"};if("^"===b.oper||"pow"===b.oper)return{ctype:"string",value:"powc("+c.value+","+d.value+")"}}if("function"===b.ctype&&1===b.args.length){c=t.compileToWebGL$1([b.args[0]],{});if("sin$1"===b.oper)return{ctype:"string",value:"sinc("+c.value+")"};if("cos$1"===b.oper)return{ctype:"string",value:"cosc("+c.value+")"};if("tan$1"===b.oper)return{ctype:"string",value:"tanc("+c.value+")"};if("exp$1"===b.oper)return{ctype:"string",value:"expc("+c.value+")"};if("log$1"===b.oper)return{ctype:"string",
value:"logc("+c.value+")"};if("arctan$1"===b.oper)return{ctype:"string",value:"arctanc("+c.value+")"};if("arcsin$1"===b.oper)return{ctype:"string",value:"arcsinc("+c.value+")"};if("arccos$1"===b.oper)return{ctype:"string",value:"arccosc("+c.value+")"};if("sqrt$1"===b.oper)return{ctype:"string",value:"sqrtc("+c.value+")"}}return k};t.compileToWebGL$1=function(a,g){var c,b;c=D.formatForWebGL;var d=a[0];b=D.plotvars(d);-1===b.indexOf("a")&&-1===b.indexOf("b")&&-1===b.indexOf("c")&&-1===b.indexOf("d")&&
-1===b.indexOf("e")&&-1===b.indexOf("f")&&(d=B(d));if("number"===d.ctype)return{ctype:"string",value:"vec2("+c(d.value.real)+","+c(d.value.imag)+")"};if("variable"===d.ctype)return{ctype:"string",value:d.name};if("string"===d.ctype||"void"===d.ctype)return d;if(2===d.args.length&&("infix"===d.ctype||"function"===d.ctype)){c=t.compileToWebGL$1([d.args[0]],{});b=t.compileToWebGL$1([d.args[1]],{});if("+"===d.oper||"add"===d.oper)return void 0===c.value||"void"===c.ctype?{ctype:"string",value:b.value}:
{ctype:"string",value:"addc("+c.value+","+b.value+")"};if("*"===d.oper||"mult"===d.oper)return{ctype:"string",value:"multc("+c.value+","+b.value+")"};if("/"===d.oper||"div"===d.oper)return{ctype:"string",value:"divc("+c.value+","+b.value+")"};if("-"===d.oper||"sub"===d.oper)return void 0===c.value||"void"===c.ctype?{ctype:"string",value:"negc("+b.value+")"}:{ctype:"string",value:"subc("+c.value+","+b.value+")"};if("^"===d.oper||"pow"===d.oper)return{ctype:"string",value:"powc("+c.value+","+b.value+
")"}}if("function"===d.ctype&&1===d.args.length){c=t.compileToWebGL$1([d.args[0]],{});if("sin$1"===d.oper)return{ctype:"string",value:"sinc("+c.value+")"};if("cos$1"===d.oper)return{ctype:"string",value:"cosc("+c.value+")"};if("tan$1"===d.oper)return{ctype:"string",value:"tanc("+c.value+")"};if("exp$1"===d.oper)return{ctype:"string",value:"expc("+c.value+")"};if("log$1"===d.oper)return{ctype:"string",value:"logc("+c.value+")"};if("arctan$1"===d.oper)return{ctype:"string",value:"arctanc("+c.value+
")"};if("arcsin$1"===d.oper)return{ctype:"string",value:"arcsinc("+c.value+")"};if("arccos$1"===d.oper)return{ctype:"string$1",value:"arccosc("+c.value+")"};if("sqrt$1"===d.oper)return{ctype:"string",value:"sqrtc("+c.value+")"}}return k};t.setsimulationspeed$1=function(a,g){var c=B(a[0]);"number"===c.ctype&&ha(c.value.real);return k};t.setsimulationaccuracy$1=function(a,g){var c=B(a[0]);"number"===c.ctype&&"undefined"!==typeof O&&"undefined"!==typeof O.env&&(O.env.accuracy=Math.max(1,c.value.real|
0));return k};t.setsimulationquality$1=function(a,g){var c=B(a[0]);"number"===c.ctype&&"undefined"!==typeof O&&"undefined"!==typeof O.env&&(c=c.value.real,0===c&&(O.env.errorbound=.01,O.env.lowestdeltat=1E-5,O.env.slowdownfactor=2),1===c&&(O.env.errorbound=.001,O.env.lowestdeltat=1E-7,O.env.slowdownfactor=2),2===c&&(O.env.errorbound=1E-5,O.env.lowestdeltat=1E-10,O.env.slowdownfactor=4),3===c&&(O.env.errorbound=1E-6,O.env.lowestdeltat=1E-12,O.env.slowdownfactor=4));return k};var fc=null,mc=null;t.createtool$3=
function(a,g){var c,b="left",d="top",h=null;g.space&&(c=z(g.space),"number"===c.ctype&&(h=c.value.real/2));var e=null;g.toolbar&&(c=z(g.toolbar),"string"===c.ctype&&((e=document.getElementById(c.value))||console.warn("Element #"+c.value+" not found")));if(!e){if(g.reference){var f=z(g.reference);if("string"===f.ctype)switch(f.value){case "UR":b="right";break;case "LL":d="bottom";break;case "LR":b="right",d="bottom"}}e=document.createElement("div");e.className="CindyJS-toolbar";na.parentNode.appendChild(e);
f=z(a[1]);c=z(a[2]);"number"===f.ctype&&(e.style[b]=f.value.real+"px");"number"===c.ctype&&(e.style[d]=c.value.real+"px");null!==h&&(e.style.margin=-h+"px")}f=z(a[0]);if("string"===f.ctype)f=[[f.value]];else if("list"===f.ctype)f=f.value.map(function(a){return"string"===a.ctype?[a.value]:"list"===a.ctype?a.value.map(function(a){return"string"===a.ctype?a.value:null}):[null]});else return ka("Name must be a string or a list of strings"),k;if(g.flipped&&(c=z(g.flipped),"boolean"===c.ctype&&c.value)){ka("Flipping");
var m=0;c=f.length;f.forEach(function(a){a.length>m&&(m=a.length)});for(var l=[],n=0;n<m;++n){l[n]=[];for(var p=0;p<c;++p)l[n][p]=f[p][n]||null}f=l}"bottom"===d&&f.reverse();f.forEach(function(a){"right"===b&&a.reverse();var c=document.createElement("div");e.appendChild(c);a.forEach(function(a){function g(){fc&&fc.classList.remove("CindyJS-active");fc=d;d.classList.add("CindyJS-active");xc=a;var c=G[xc].actions;mc&&(mc.textContent=c[0].tooltip||"");Aa=[];xb=Ya=0}G.hasOwnProperty(a)||(ka("Tool '"+
a+"' not implemented yet."),a=null);if(null===a){var b=document.createElement("span");b.className="CindyJS-spacer";c.appendChild(b)}else{var d=document.createElement("button"),b=document.createElement("img");b.src=va.getBaseDir()+"images/"+a+".png";d.appendChild(b);d.addEventListener("click",g);fc||g();null!==h&&(d.style.margin=h+"px");c.appendChild(d)}})});return k};t.dropped$0=function(){return rc};t.droppoint$0=function(){return sc};t.parsecsv$1=function(a,g){var c=!0,b=B(g.autoconvert);"boolean"===
b.ctype&&(c=b.value);var d=null,b=B(g.delimiter);"string"===b.ctype&&/^[^\"\r\n]$/.test(b.value)&&(d=b.value);b=B(a[0]);if("string"!==b.ctype)return ka("CSV data is not a string"),k;var b=b.value,e='(?:"((?:[^"]+|"")*)"|([^]*?))(\r\n|(,)|[\r\n]|$)';d&&(d=d.replace(/[^A-Za-z0-9]/g,"\\$&").replace(/\$/g,"$$$$"),e=e.replace(/,/g,d));for(var e=new RegExp(e,"g"),d=[],f=[],l=null;e.lastIndex<b.length;){var n=e.exec(b),p=n[2];"string"===typeof n[1]&&(p=n[1].replace(/""/g,'"'));p=c?/^[Tt]rue$/.test(p)?w.bool(!0):
/^[Ff]alse$/.test(p)?w.bool(!1):/^[\-+]?([0-9]+(\.[0-9]*)?|\.[0-9]+|Infinity)$/.test(p)?m.real(Number(p)):w.string(p):w.string(p);d.push(p);n[4]&&e.lastIndex===b.length&&(d.push(w.string("")),n={});if(!n[4]){null===l&&(l=d.length);if(l<d.length)for(l=d.length,n=0;n<f.length;++n)for(p=f[n].length;p<l;++p)f[n][p]=k;else if(l>d.length)for(n=d.length;n<l;++n)d[n]=k;f.push(d);d=[]}}return h.turnIntoCSList(f.map(h.turnIntoCSList))};t.load$2=function(a,g){return t.load$3([a[0],null,a[1]],g)};t.load$3=function(a,
g){function c(){if(f.readyState===XMLHttpRequest.DONE){var c;200===f.status?c=w.string(String(f.responseText)):(ka("Failed to load "+h+": "+f.statusText),c=k);J.newvar(b);J.setvar(b,c);z(a[2]);J.removevar(b);e()}}var b="#";null!==a[1]&&"variable"===a[1].ctype&&(b=a[1].name);var d=B(a[0]),h=null,f=null;"string"===d.ctype&&/^https?:\/\//.test(d.value)&&(h=d.value);return null!==h?(f=new XMLHttpRequest,f.onreadystatechange=c,f.open("GET",h),f.send(),w.bool(!0)):k};D.extractPoint=function(a){var g={ok:!1};
if("geo"===a.ctype){var c=a.value;if("P"===c.kind)return g.x=ta.getField(c,"x").value.real,g.y=ta.getField(c,"y").value.real,g.ok=!0,g}if("list"!==a.ctype)return g;var b=a.value;if(2===b.length&&(a=b[0],c=b[1],"number"===a.ctype&&"number"===c.ctype))return g.x=a.value.real,g.y=c.value.real,g.ok=!0,g;3===b.length&&(a=b[0],c=b[1],b=b[2],"number"===a.ctype&&"number"===c.ctype&&"number"===b.ctype&&(a=m.div(a,b),c=m.div(c,b),g.x=a.value.real,g.y=c.value.real,g.ok=!0));return g};t.draw$1=function(a,g){var c=
B(a[0]);if("shape"===c.ctype)D.drawshape(c,g);else if("Line"===c.usage)x.handleModifs(g,x.lineModifs),x.drawline(c);else{var b=D.extractPoint(c);if(!b.ok){if("undefined"!==typeof c.value&&2===c.value.length)return t.draw$2(c.value,g);return}null!==g&&x.handleModifs(g,x.pointModifs);x.drawpoint(b)}return k};t.draw$2=function(a,g){var c=B(a[0]),b=B(a[1]),c=D.extractPoint(c),b=D.extractPoint(b);if(!c.ok||!b.ok)return k;null!==g&&x.handleModifs(g,x.lineModifs);x.drawsegcore(c,b);return k};t.drawcircle$2=
function(a,g){return D.drawcircle(a,g,"D")};D.arcHelper=function(a){var g={};g.startPoint=K(a[0]);g.viaPoint=K(a[1]);g.endPoint=K(a[2]);return g};t.fillcircle$2=function(a,g){return D.drawcircle(a,g,"F")};t.drawarc$3=function(a,g){var c=D.arcHelper(a);return D.drawarc(c,g,"D")};t.fillarc$3=function(a,g){var c=D.arcHelper(a);return D.drawarc(c,g,"F")};D.drawarc=function(a,g,c){var b=a.startPoint,d=a.viaPoint;a=a.endPoint;if(!h._helper.isAlmostReal(h.turnIntoCSList([b,d,a])))return k;x.handleModifs(g,
x.conicModifs);x.preDrawCurve();g=h.det3(b,d,a);if(1E-12<Math.abs(g.value.real)){g=l._helper.ConicBy5(null,b,d,a,h.ii,h.jj);var e=l._helper.CenterOfConic(g),e=h.normalizeMax(e);g=m.real(0);var f=h.turnIntoCSList([h.turnIntoCSList([e.value[2],g,m.neg(e.value[0])]),h.turnIntoCSList([g,e.value[2],m.neg(e.value[1])]),h.turnIntoCSList([g,g,e.value[2]])]);g=h.normalizeZ(w.mult(f,b));h.normalizeZ(w.mult(f,d));f=h.normalizeZ(w.mult(f,a));g=-Math.atan2(g.value[1].value.real,g.value[0].value.real);f=-Math.atan2(f.value[1].value.real,
f.value[0].value.real);e=h.normalizeZ(e);b=h.normalizeZ(b);d=h.normalizeZ(d);a=h.normalizeZ(a);var n=h.abs(h.sub(b,e)),p=[e.value[0].value.real,e.value[1].value.real],e=y.drawingstate.matrix,r=p[0]*e.a-p[1]*e.b+e.tx,p=p[0]*e.c-p[1]*e.d-e.ty,b=0<h.det3(b,d,a).value.real;A.save();A.beginPath();A.translate(r,p);A.arc(0,0,n.value.real*e.sdet,g,f,b);"F"===c&&(A.fillStyle=x.lineColor,A.closePath(),A.fill());"D"===c&&A.stroke();A.restore()}else{if("D"!==c)return k;c=D.extractPoint(b);g=D.extractPoint(d);
f=D.extractPoint(a);if(!c.ok||!g.ok||!f.ok)return k;n=(c.x-f.x)*(c.x-f.x)+(c.y-f.y)*(c.y-f.y);e=(f.x-g.x)*(f.x-g.x)+(f.y-g.y)*(f.y-g.y);if(1E-12>(c.x-g.x)*(c.x-g.x)+(c.y-g.y)*(c.y-g.y)||1E-12>n||1E-12>e)return k;0>h.crossratio3(b,a,d,h.cross(h.cross(b,d),h.linfty),h.ii).value.real?x.drawsegcore(c,f):x.drawRaySegment(b,a)}return k};D.drawcircle=function(a,g,c){var b=B(a[0]);a=B(a[1]);var d=D.extractPoint(b);if(!d.ok||"number"!==a.ctype||!m._helper.isAlmostReal(a))return k;var b=y.drawingstate.matrix,
e=d.x*b.a-d.y*b.b+b.tx,d=d.x*b.c-d.y*b.d-b.ty;x.handleModifs(g,x.conicModifs);x.preDrawCurve();A.lineJoin="miter";A.beginPath();A.arc(e,d,Math.abs(a.value.real)*b.sdet,0,2*Math.PI);A.closePath();"D"===c&&A.stroke();"F"===c&&(A.fillStyle=x.lineColor,A.fill());"C"===c&&A.clip();return k};t.drawconic$1=function(a,b){var c=B(a[0]);if("list"!==c.ctype||3!==c.value.length&&6!==c.value.length)return console.error("could not parse conic"),k;if(6===c.value.length){for(var d=0;6>d;d++)if("number"!==c.value[d].ctype)return console.error("could not parse conic"),
k;var e=m.real(.5),d=c.value[0],f=c.value[2],f=m.mult(f,e),l=c.value[1],n=c.value[3],n=m.mult(n,e),p=c.value[4],p=m.mult(p,e),c=c.value[5],c=h.turnIntoCSList([h.turnIntoCSList([d,f,n]),h.turnIntoCSList([f,l,p]),h.turnIntoCSList([n,p,c])])}else{if(!h.isNumberMatrix(c).value||3!==c.value.length||3!==c.value[0].value.length)return k;d=h.transpose(c);h.equals(c,d).value||(c=h.add(d,c))}return D.drawconic(c,b)};D.drawconic=function(a,b){function c(a,c){var b=(p*a+r*c+t)*a+(u*c+v)*c+w;return 0<=b?1:0>b?
-1:NaN}function d(a){K.next=a;a.prev=K;return K=a}function e(a,b,g,d){return{a:a,b1:b,b2:g,vertical:!0,index:d,sign:function(b){return c(a,b)},mkp:function(c){return{x:a,y:c}},sol:Jb(u,r*a+v,(p*a+t)*a+w),discr:function(){return Jb(E,-2*C,z)},tpt:function(a){return{x:a,y:-.5*(r*a+v)/u}}}}function f(a,b,g,d){return{a:a,b1:b,b2:g,vertical:!1,index:d,sign:function(b){return c(b,a)},mkp:function(c){return{x:c,y:a}},sol:Jb(p,r*a+t,(u*a+v)*a+w),discr:function(){return Jb(E,-2*F,D)},tpt:function(a){return{x:-.5*
(r*a+t)/p,y:a}}}}function m(a){var c=Math.min(a.b1,a.b2),b=Math.max(a.b1,a.b2),g=a.sign(c),e=a.sign(b);if(!isFinite(g*e))return!1;var h=a.sol,f;if(g!==e){if(null===h)return!1;f=.5*(h[0]+h[1]);f>c&&f<b?(c=a.sign(f),f=h[c===e?0:1]):(g=.5*(c+b),f=h[Math.abs(g-h[0])<Math.abs(g-h[1])?0:1]);N.push(d(a.mkp(f)))}else{if(null===h){if(0>=G)return!0;h=a.discr();if(null===h)return!0;a=a.tpt(h[a.index]);a.x>=H&&a.x<=J&&a.y>=L&&a.y<=M&&d(a);return!0}f=.5*(h[0]+h[1]);if(!(f>c&&f<b))return!0;c=a.sign(f);if(c===g||
isNaN(c))return!0;a.b1>a.b2&&(h=[h[1],h[0]]);N.push(d(a.mkp(h[0])));N.push(d(a.mkp(h[1])))}return!0}function k(a,c,b,g,d){var e=c-g,h=b-a,q=a*g-c*b,f=C*e+F*h+E*q;if(1E-14>Math.abs(f))return A.lineTo(b,g);var m=(z*e+B*h+C*q)/f,e=(B*e+D*h+F*q)/f;if(!isFinite(m)||!isFinite(e)||.04>Math.abs(a*e+m*g+b*c-b*e-m*c-a*g))return A.lineTo(b,g);do if(!(10<d)){var q=.5*(a+b),h=.5*(c+g),l=m-q,f=e-h;if(!(.04>l*l+f*f)){var n=p*l*l+r*l*f+u*f*f,oa=2*p*l*q+r*(l*h+f*q)+2*u*f*h+t*l+v*f,W=(p*q+r*h+t)*q+(u*h+v)*h+w,xa=Jb(n,
oa,W);xa||(xa=[-.5*oa/n,-2*W/oa]);if(0<xa[0])xa=xa[0];else if(0<=xa[1])xa=xa[1];else break;l=q+xa*l;f=h+xa*f;q=l-.5*(m+q);h=f-.5*(e+h);if(!(.04>q*q+h*h)){k(a,c,l,f,d+1);k(l,f,b,g,d+1);return}}}while(0);A.quadraticCurveTo(m,e,b,g)}x.handleModifs(b,x.conicModifs);if(0!==x.lsize){x.preDrawCurve();var l;l=h.normalizeMax(a);if(h._helper.isAlmostReal(l)){var n=y.toMat();l=h.mult(h.transpose(n),l);l=h.mult(l,n);l=h.normalizeMax(l);var p=l.value[0].value[0].value.real,r=2*l.value[0].value[1].value.real,t=
2*l.value[0].value[2].value.real,u=l.value[1].value[1].value.real,v=2*l.value[1].value[2].value.real,w=l.value[2].value[2].value.real,z=4*w*u-v*v,B=v*t-2*w*r,C=v*r-2*u*t,D=4*w*p-t*t,F=t*r-2*v*p,E=4*u*p-r*r,G=E;l=u*D+r*B+p*z-w*E;0>l&&(p=-p,r=-r,t=-t,u=-u,v=-v,w=-w,l=-l);l=x.lsize;var H=-l,L=-l,J=ca+l,M=da+l,N=[],K=l={};if(m(e(H,L,M,0))&&m(f(M,H,J,1))&&m(e(J,M,L,1))&&m(f(L,J,H,0))&&K!==l){K.next=l.next;l.next.prev=K;A.beginPath();var I,O;if(0===N.length){I=K;A.moveTo(I.x,I.y);do O=I.next,k(I.x,I.y,
O.x,O.y,0),I=O;while(I!==K);A.closePath()}n=1===c(H,L)?0:1;if(4===N.length){var P=0;for(l=0;2>l;++l){I=N[l];O=N[l+2];var Q=O.x-I.x;I=O.y-I.y;I=(p*Q+r*I)*Q+u*I*I;Math.abs(I)>Math.abs(P)&&(P=I)}if(isNaN(P))return;0<=P&&(n=1-n)}for(l=n;l<N.length;l+=2)for(I=N[l],n=N[(l+1)%N.length],A.moveTo(I.x,I.y),O=I.next;I!==n;O=(I=O).next)k(I.x,I.y,O.x,O.y,0);A.stroke()}}}};t.drawall$1=function(a,b){var c=z(a[0]);if("list"===c.ctype){x.handleModifs(b,x.pointAndLineModifs);for(var d=0;d<c.value.length;d++)t.draw$1([c.value[d]],
null)}return k};t.connect$1=function(a,b){return D.drawpolygon(a,b,"D",!1)};t.drawpoly$1=function(a,b){return D.drawpolygon(a,b,"D",!0)};t.fillpoly$1=function(a,b){return D.drawpolygon(a,b,"F",!0)};t.drawpolygon$1=function(a,b){return D.drawpolygon(a,b,"D",!0)};t.fillpolygon$1=function(a,b){return D.drawpolygon(a,b,"F",!0)};D.drawpolygon=function(a,b,c,d){function e(){for(var a=m.value,c=0;c<a.length;c++){var b=a[c],g;for(g=0;g<b.length;g++){var d=b[g],h=d.X*f.a-d.Y*f.b+f.tx,d=d.X*f.c-d.Y*f.d-f.ty;
0===g?A.moveTo(h,d):A.lineTo(h,d)}A.closePath()}}function h(){var a;for(a=0;a<m.value.length;a++){var c=D.extractPoint(m.value[a]);if(!c.ok)return;var b=c.x*f.a-c.y*f.b+f.tx,c=c.x*f.c-c.y*f.d-f.ty;0===a?A.moveTo(b,c):A.lineTo(b,c)}d&&A.closePath()}x.handleModifs(b,x.conicModifs);x.preDrawCurve();var f=y.drawingstate.matrix,m=z(a[0]);A.beginPath();"list"===m.ctype&&h();"shape"===m.ctype&&e();"D"===c&&(x.fillColor&&(A.fillStyle=x.fillColor,A.fill(x.fillrule)),A.stroke());"F"===c&&(A.fillStyle=x.lineColor,
A.fill(x.fillrule));"C"===c&&A.clip();return k};var Jc=fd,Bd=function(a,b,c){if(-1!==b.indexOf("\n"))for(b=b.split("\n"),a.textContent=b[0],c=1;c<b.length;++c)a.appendChild(document.createElement("br")),a.appendChild(document.createTextNode(b[c]));else a.textContent=b};D.drawtext=function(a,b,c){var d=B(a[0]);a=z(a[1]);var e=D.extractPoint(d);if(!e.ok)return null;x.handleModifs(b,x.textModifs);b=y.drawingstate.textsize;null===b&&(b=ga.textsize);null!==x.size&&(b=x.size);A.fillStyle=x.textColor;var h=
y.drawingstate.matrix,d=e.x*h.a-e.y*h.b+h.tx+x.xOffset,e=e.x*h.c-e.y*h.d-h.ty-x.yOffset;a=Z(a);va._pluginRegistry.katex||"string"!==typeof a||3<=a.split("$").length&&pa("katex","katex-plugin.js",!0);h=x.bold+x.italics+Math.round(10*b)/10+"px "+x.family;A.font=h;return c?c(a,h,d,e,x.align,b):Jc(A,a,d,e,x.align,b,b*ga.lineHeight)};t.drawtext$2=function(a,b){D.drawtext(a,b,null);return k};t.drawtable$2=function(a,b){var c=B(a[0]),d=B(a[1]),e=D.extractPoint(c);if(!e.ok||"list"!==d.ctype)return k;var d=
d.value,c=d.length,f=-1,m;for(m=0;m<c;++m)"list"===d[m].ctype&&d[m].value.length>f&&(f=d[m].value.length);-1===f?(d=d.map(function(a){return[a]}),f=1):d=d.map(function(a){return h.asList(a).value});var l=100,n=null,p=!0,r=y.drawingstate.textcolor;x.handleModifs(b,{size:!0,color:function(a){h._helper.isNumberVecN(a,3)&&(r=x.makeColor([a.value[0].value.real,a.value[1].value.real,a.value[2].value.real]))},alpha:!0,bold:!0,italics:!0,family:!0,align:!0,x_offset:!0,y_offset:!0,offset:!0,width:function(a){"number"===
a.ctype&&(l=a.value.real)},height:function(a){"number"===a.ctype&&(n=a.value.real)},border:function(a){"boolean"===a.ctype&&(p=a.value)}});var t=y.drawingstate.textsize;null===t&&(t=ga.textsize);null!==x.size&&(t=x.size);null===n&&(n=1.6*t);A.font=x.bold+x.italics+Math.round(10*t)/10+"px "+x.family;m=y.drawingstate.matrix;var u=f*l,v=c*n,t=e.x*m.a-e.y*m.b+m.tx+x.xOffset,w=e.x*m.c-e.y*m.d-m.ty-x.yOffset-v;if(p){x.preDrawCurve();A.strokeStyle=x.lineColor;A.beginPath();for(m=1;m<c;++m)A.moveTo(t,w+m*
n),A.lineTo(t+u,w+m*n);for(e=1;e<f;++e)A.moveTo(t+e*l,w),A.lineTo(t+e*l,w+v);A.stroke();A.lineWidth=x.lsize+1;A.beginPath();A.rect(t,w,u,v);A.stroke()}t+=x.align*l+(1-2*x.align)*n*.3;w+=.7*n;A.fillStyle=r;for(m=0;m<c;++m)for(e=0;e<f;++e)u=Z(d[m][e]),Jc(A,u,t+e*l,w+m*n,x.align);return k};D.drawshape=function(a,b){return"polygon"===a.type?D.drawpolygon([a],b,"D",1):"circle"===a.type?D.drawcircle([a.value.value[0],a.value.value[1]],b,"D"):k};D.fillshape=function(a,b){return"polygon"===a.type?D.drawpolygon([a],
b,"F",1):"circle"===a.type?D.drawcircle([a.value.value[0],a.value.value[1]],b,"F"):k};D.clipshape=function(a,b){return"polygon"===a.type?D.drawpolygon([a],b,"C",1):"circle"===a.type?D.drawcircle([a.value.value[0],a.value.value[1]],b,"C"):k};t.fill$1=function(a,b){var c=z(a[0]);return"shape"===c.ctype?D.fillshape(c,b):k};t.clip$1=function(a,b){var c=z(a[0]);return"shape"===c.ctype?D.clipshape(c,b):"list"===c.ctype?(c=t.polygon$1(a,[]),t.clip$1([c],[])):k};t.plot$1=function(a,b){return t.plot$2([a[0],
null],b)};t.plot$2=function(a,b){function c(a){return"number"===a.ctype&&m._helper.isAlmostReal(a)}function d(a,c,b,g,e){n++;c=+c.value.real;e=+g.value.real;g=c*E.a-e*E.b+E.tx;c=c*E.c-e*E.d-E.ty;a=+a.value.real;e=+b.value.real;b=a*E.a-e*E.b+E.tx;a=a*E.c-e*E.d-E.ty;p?(A.lineTo(b,a),A.lineTo(g,c)):(A.beginPath(),A.moveTo(b,a),A.lineTo(g,c),p=!0)}function e(a,b,g,h,k){var n=c(g),r=c(h);if(.001>k)!f&&p&&(A.stroke(),p=!1);else if(n||r){var t=m.real((a.value.real+b.value.real)/2);J.setvar(B,t);var u=z(w),
v=c(u);if(n&&r&&v){var Wb=g.value.real,r=u.value.real,v=h.value.real;if(n=1>Math.abs(Wb+v-2*r)/l){var Wa=m.real((a.value.real+t.value.real)/2);J.setvar(B,Wa);var Wa=z(w),Ra=m.real((t.value.real+b.value.real)/2);J.setvar(B,Ra);Ra=z(w);Wb=Math.abs(Wb+r-2*Wa.value.real)/l;r=Math.abs(r+v-2*Ra.value.real)/l;n=n&&1>Wb&&1>r}n?(d(a,t,g,u,k/2),d(t,b,u,h,k/2)):(e(a,t,g,u,k/2),e(t,b,u,h,k/2))}else e(a,t,g,u,k/2),e(t,b,u,h,k/2)}}var f=!1,l=.2/Tb,n=0,p=!1,r=-10,t=10,u=.1,v=1E3,w=a[0],B;if(null!==a[1]&&"variable"===
a[1].ctype)B=a[1].name;else{var C=D.plotvars(w);B="#";-1!==C.indexOf("t")&&(B="t");-1!==C.indexOf("z")&&(B="z");-1!==C.indexOf("y")&&(B="y");-1!==C.indexOf("x")&&(B="x")}J.newvar(B);var E=y.drawingstate.matrix;x.handleModifs(b,{color:!0,alpha:!0,size:!0,dashpattern:!0,dashtype:!0,dashing:!0,lineCap:!0,lineJoin:!0,miterLimit:!0,connect:function(a){"boolean"===a.ctype&&(f=a.value)},start:function(a){"number"===a.ctype&&(r=a.value.real)},stop:function(a){"number"===a.ctype&&(t=a.value.real)},steps:function(a){"number"===
a.ctype&&(v=a.value.real)}});A.strokeStyle=x.lineColor;A.lineWidth=x.lsize;var F,G,H,I,p=!1,C=m.real(14.32);J.setvar(B,C);H=z(w);if("number"!==H.ctype){if(h.isNumberVector(H).value&&2===H.value.length){p=!1;u=(t-r)/v;for(C=r;C<t;C+=u)J.setvar(B,m.real(C)),I=z(w),h.isNumberVector(I).value&&2===I.value.length&&(F=+I.value[0].value.real,G=+I.value[1].value.real,I=F*E.a-G*E.b+E.tx,F=F*E.c-G*E.d-E.ty,p?A.lineTo(I,F):(A.beginPath(),A.moveTo(I,F),p=!0));A.stroke();J.removevar(B)}return k}for(I=r;I<t+u;I+=
u)C=m.real(I),J.setvar(B,C),H=z(w),C.value.real>r&&e(F,C,G,H,u),F=C,G=H;J.removevar(B);p&&A.stroke();return k};t.plotX$1=function(a,b){var c=a[0],d=D.plotvars(c),e="#";-1!==d.indexOf("t")&&(e="t");-1!==d.indexOf("z")&&(e="z");-1!==d.indexOf("y")&&(e="y");-1!==d.indexOf("x")&&(e="x");J.newvar(e);d=y.drawingstate.matrix;A.fillStyle=y.drawingstate.linecolor;A.lineWidth=1;A.lineCap=x.lineCap;A.lineJoin=x.lineJoin;A.miterLimit=x.miterLimit;for(var h=!1,f=-10;10>f;f+=.01){J.setvar(e,m.real(f));var l=z(c);
if("number"===l.ctype){var n=+l.value.real,l=f*d.a-n*d.b+d.tx,n=f*d.c-n*d.d-d.ty;h?A.lineTo(l,n):(A.beginPath(),A.moveTo(l,n),h=!0)}}A.stroke();J.removevar(e);return k};D.plotvars=function(a){function b(a,c){var g={},d;for(d=a.length-1;0<=d;--d)g[a[d]]=a[d];for(d=c.length-1;0<=d;--d)g[c[d]]=c[d];d=[];for(var e in g)g.hasOwnProperty(e)&&d.push(g[e]);return d}function c(a,c){for(var b=0;b<a.length;b++)a[b]===c&&(a.splice(b,1),b--);return a}var d,e,h,f;if("variable"===a.ctype)return[a.name];if("infix"===
a.ctype)return d=D.plotvars(a.args[0]),a=D.plotvars(a.args[1]),b(d,a);if("list"===a.ctype){h=a.value;e=[];for(f=0;f<h.length;f++)d=D.plotvars(h[f]),e=b(e,d);return e}if("function"===a.ctype){h=a.args;e=[];for(f=0;f<h.length;f++)d=D.plotvars(h[f]),e=b(e,d);"apply"!==a.oper&&"select"!==a.oper&&"forall"!==a.oper&&"sum"!==a.oper&&"product"!==a.oper&&"repeat"!==a.oper&&"min"!==a.oper&&"max"!==a.oper&&"sort"!==a.oper||"variable"!==a.args[1].ctype||(e=c(e,a.args[1].name));return e}return[]};t.clrscr$0=function(a,
b){"undefined"!==typeof ca&&"undefined"!==typeof da&&A.clearRect(0,0,ca,da);return k};t.repaint$0=function(a,b){e();return k};t.screenbounds$0=function(a,b){var c=w.withUsage(h.realVector(y.to(0,0)),"Point"),d=w.withUsage(h.realVector(y.to(ca,0)),"Point"),e=w.withUsage(h.realVector(y.to(ca,da)),"Point"),f=w.withUsage(h.realVector(y.to(0,da)),"Point");return h.turnIntoCSList([c,d,e,f])};t.createimage$3=function(a,b){var c=z(a[0]),d=B(a[1]),e=B(a[2]);if("number"!==d.ctype||"number"!==e.ctype||"string"!==
c.ctype)return k;var h=document.createElement("canvas");h.id=c.value;h.width=d.value.real;h.height=e.value.real;h.style.display="none";document.body.appendChild(h);bb[c.value]=fa(h,!1);return k};t.clearimage$1=function(a,b){var c=z(a[0]);if("string"!==c.ctype&&"image"!==c.ctype)return k;c=Ja(c);if(!c)return k;var d=c.img;if("undefined"===typeof d||null===d)return k;var e=c.width,h=c.height;d.getContext("2d").clearRect(0,0,e,h);c.generation++;return k};t.canvas$4=function(a,b){var c=B(a[0]),d=B(a[1]),
e=z(a[2]),h=a[3],f=D.extractPoint(c),m=D.extractPoint(d);if(!f.ok||!m.ok||"string"!==e.ctype&&"image"!==e.ctype)return k;e=Ja(e);if(!e||!e.img.getContext)return k;var d=e.img,l=e.width,c=e.height,n=m.x-f.x,p=m.y-f.y,r=f.x-p*c/l,t=f.y+n*c/l,p=m.x-p*c/l,n=m.y+n*c/l,m=y.from(f.x,f.y,1),r=y.from(r,t,1),p=y.from(p,n,1),f=m[0],t=m[1],n=r[0],u=r[1],v=p[0],w=p[1],r=l*(t-u)/((f-n)*(t-w)-(f-v)*(t-u)),l=l*(f-n)/((t-u)*(f-v)-(t-w)*(f-n)),p=-r*f-l*t,m=(c*(t-w)-c*(t-u))/((f-n)*(t-w)-(f-v)*(t-u)),n=(c*(f-v)-c*(f-
n))/((t-u)*(f-v)-(t-w)*(f-n)),c=c-m*f-n*t,d=d.getContext("2d"),f=A;A=d;A.save();A.transform(r,m,l,n,p,c);e.generation++;z(h);A.restore();A=f};t.canvas$5=function(a,b){var c=B(a[0]),d=B(a[1]),e=B(a[2]),h=z(a[3]),f=a[4],c=D.extractPoint(c),m=D.extractPoint(d),l=D.extractPoint(e);if(!c.ok||!m.ok||!l.ok||"string"!==h.ctype&&"image"!==h.ctype)return k;h=Ja(h);if(!h||!h.img.getContext)return k;var e=h.img,n=h.width,d=h.height,p=y.from(c.x,c.y,1),r=y.from(m.x,m.y,1),m=y.from(l.x,l.y,1),c=p[0],l=p[1],t=r[0],
u=r[1],v=m[0],w=m[1],m=((0-n)*(l-w)-0*(l-u))/((c-t)*(l-w)-(c-v)*(l-u)),n=((0-n)*(c-v)-0*(c-t))/((l-u)*(c-v)-(l-w)*(c-t)),r=0-m*c-n*l,p=((d-d)*(l-w)-(d-0)*(l-u))/((c-t)*(l-w)-(c-v)*(l-u)),t=((d-d)*(c-v)-(d-0)*(c-t))/((l-u)*(c-v)-(l-w)*(c-t)),d=d-p*c-t*l,e=e.getContext("2d"),c=A;A=e;A.save();A.transform(m,p,n,t,r,d);h.generation++;z(f);A.restore();A=c};t.screenresolution$0=function(a,b){return m.real(y.drawingstate.matrix.a)};t.layer$1=function(a,b){};t.imagesize$1=function(a,b){var c=Ja(B(a[0]));return c?
h.realVector([+c.width,+c.height]):k};t.imageready$1=function(a,b){var c=Ja(B(a[0]));return w.bool(!(!c||!c.ready))};t.drawimage$2=function(a,b){function c(){var a=1,c=1,d=1,f=1,q=0,m=1,n=D.extractPoint(e);if(!n.ok)return k;l=Ja(l);if(!l)return k;A.save();var p;void 0!==b.angle&&(p=z(b.angle),"number"===p.ctype&&(q=p.value.real));void 0!==b.rotation&&(p=z(b.rotation),"number"===p.ctype&&(q=p.value.real));void 0!==b.scale&&(p=B(b.scale),"number"===p.ctype&&(c=a=p.value.real),h.isNumberVector(p).value&&
2===p.value.length&&(a=p.value[0].value.real,c=p.value[1].value.real));void 0!==b.scalex&&(p=z(b.scalex),"number"===p.ctype&&(a=p.value.real));void 0!==b.scaley&&(p=z(b.scaley),"number"===p.ctype&&(c=p.value.real));void 0!==b.flipx&&(p=z(b.flipx),"boolean"===p.ctype&&p.value&&(d=-1));void 0!==b.flipy&&(p=z(b.flipy),"boolean"===p.ctype&&p.value&&(f=-1));void 0!==b.alpha&&(p=z(b.alpha),"number"===p.ctype&&(m=p.value.real));var r=y.drawingstate.matrix,W=y.drawingstate.initialmatrix,t=l.width,u=l.height;
p=n.x*r.a-n.y*r.b+r.tx;var v=n.x*r.c-n.y*r.d-r.ty,xa=(n.x+1)*r.a-n.y*r.b+r.tx-p,r=(n.x+1)*r.c-n.y*r.d-r.ty-v,w=(n.x+1)*W.a-n.y*W.b+W.tx-(n.x*W.a-n.y*W.b+W.tx),W=(n.x+1)*W.c-n.y*W.d-W.ty-(n.x*W.c-n.y*W.d-W.ty),n=Math.sqrt(xa*xa+r*r)/Math.sqrt(w*w+W*W),xa=-Math.atan2(xa,r)+Math.atan2(w,W),r=y.drawingstate.matrix.sdet/72,a=a*r,c=c*r;1!==m&&(A.globalAlpha=m);A.translate(p,v);A.scale(a*d*n,c*f*n);A.rotate(q+xa);A.translate(-p,-v);A.translate(-t/2,-u/2);a=l;a.drawTo?a.drawTo(A,p,v):A.drawImage(a.img,p,
v);A.globalAlpha=1;A.restore()}function d(){var a=1,c=1,h=1,q=1,n=D.extractPoint(e),p=D.extractPoint(f),r;if(!n.ok||!p.ok)return k;l=Ja(l);if(!l)return k;var t=l.width,u=l.height;if(0===m)r={},r.x=n.x-(p.y-n.y),r.y=n.y+(p.x-n.x),q=u/t;else if(r=D.extractPoint(m),!n.ok)return k;A.save();var v;void 0!==b.alpha&&(v=z(b.alpha),"number"===v.ctype&&(a=v.value.real));void 0!==b.aspect&&(v=z(b.aspect),"number"===v.ctype&&(q=v.value.real));void 0!==b.flipx&&(v=z(b.flipx),"boolean"===v.ctype&&v.value&&(c=-1));
void 0!==b.flipy&&(v=z(b.flipy),"boolean"===v.ctype&&v.value&&(h=-1));v=y.drawingstate.matrix;1!==a&&(A.globalAlpha=a);a=n.x*v.a-n.y*v.b+v.tx;n=n.x*v.c-n.y*v.d-v.ty;A.transform(p.x*v.a-p.y*v.b+v.tx-a,p.x*v.c-p.y*v.d-v.ty-n,r.x*v.a-r.y*v.b+v.tx-a,r.x*v.c-r.y*v.d-v.ty-n,a,n);A.scale(1/t,-1/u*q);A.translate(t/2,-u/2);A.scale(c,h);A.translate(-t/2,u/2);A.translate(0,-u);c=l;c.drawTo?c.drawTo(A,0,0):A.drawImage(c.img,0,0);A.globalAlpha=1;A.restore()}var e,f,m,l;return 2===a.length?(e=B(a[0]),l=B(a[1]),
c()):3===a.length?(e=B(a[0]),f=B(a[1]),m=0,l=B(a[2]),d()):4===a.length?(e=B(a[0]),f=B(a[1]),m=B(a[2]),l=B(a[3]),d()):k};t.drawimage$3=t.drawimage$2;t.drawimage$4=t.drawimage$2;t.allimages$0=function(){var a=[];Object.keys(bb).forEach(function(b){a.push({ctype:"string",value:b})});return h.turnIntoCSList(a)};t.cameravideo$0=function(a,b){function c(a){return{video:{width:a,advanced:[{width:{max:a,min:a}},{width:{ideal:a}}]},audio:!1}}var d=!0,e={};if(void 0!==b.resolution){var f=z(b.resolution);"string"===
f.ctype&&"maximal"===f.value?d=!0:"number"===f.ctype?(d=!1,e=c(f.value.real)):h._helper.isNumberVecN(f,2)&&(d=!1,e=c(f.value[0].value.real),f=f.value[1].value.real,10>f||!Number.isInteger(f)?(e.video.aspectRatio=f,e.video.advanced[0].aspectRatio={min:f,max:f},e.video.advanced[1].aspectRatio={ideal:f}):(e.video.height=f,e.video.advanced[0].height={min:f,max:f},e.video.advanced[1].height={ideal:f}))}d&&(e=[320,640,1024,1280,1920,2560],e=e.map(function(a){return{width:{min:a}}}),e={video:{width:16E3,
height:9E3,advanced:e},audio:!1});var d=null,m=navigator.mediaDevices&&navigator.mediaDevices.getUserMedia;m?d=function(a,c){navigator.mediaDevices.getUserMedia(e).then(a,c)}:(m=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia)&&(d=function(a,c){m.call(navigator,e,a,c)});if(!d)return console.warn("getUserMedia call not supported"),k;var l=document.createElement("video");l.autoplay=!0;f=fa(l,!0);console.log("Opening stream.");d(function(a){l.srcObject=
a;l.setAttribute("autoplay","");l.setAttribute("muted","");l.setAttribute("playsinline","");l.play();l.addEventListener("loadeddata",M)},function(a){console.error("Could not get user video:",String(a),a)});return f};t.playvideo$1=function(a,b){var c=Ja(B(a[0]));c.live&&c.img.play&&c.img.play();return k};t.pausevideo$1=function(a,b){var c=Ja(B(a[0]));c.live&&c.img.pause&&c.img.pause();return k};var Kb;t.imagergba$3=function(a,b){var c=Ja(B(a[0])),d=B(a[1]),e=B(a[2]);if(!c||"number"!==d.ctype||"number"!==
e.ctype||!c.ready)return k;d=Math.round(d.value.real);e=Math.round(e.value.real);if(!Ia(d)||!Ia(e))return k;c=pb(c,d,e,1,1);return h.realVector([255*c[0],255*c[1],255*c[2],c[3]])};t.imagergb$3=t.imagergba$3;t.imagergba$4=function(a,b){var c=Ja(B(a[2]));if(!c||!c.ready)return k;var d=c.width,e=c.height,f=K(a[0]),m=K(a[1]),l=K(h.realVector([0,e,1])),d=K(h.realVector([d,e,1]));if(f===k||m===k||n===k)return k;var n=h.ii,e=h.jj,l=D.basismap(l,d,n,e),f=D.basismap(f,m,e,n),n=K(a[3]);var p=D.extractPoint(w.mult(l,
w.mult(h.adjoint3(f),n)));if(p.ok){var m=c.width,l=c.height,n=!0,r=!1;void 0!==b.interpolate&&(f=z(b.interpolate),"boolean"===f.ctype&&(n=f.value));void 0!==b.repeat&&(f=z(b.repeat),"boolean"===f.ctype&&(r=f.value));n&&(p.x-=.5,p.y-=.5);r&&(p.x=(p.x%m+m)%m,p.y=(p.y%l+l)%l);d=Math.floor(p.x);e=Math.floor(p.y);if(Ia(d)&&Ia(e)){f=[0,0,0,0];if(n){var n=p.x-d,p=p.y-e,t=pb(c,d,e,2,2);if(r){if(d===m-1||e===l-1)var r=pb(c,(d+1)%m,e,1,1),v=pb(c,d,(e+1)%l,1,1),c=pb(c,(d+1)%m,(e+1)%l,1,1),t=t.slice(0,4).concat(r,
v,c)}else{if(-1===d||d===m-1)n=Math.round(n);if(-1===e||e===l-1)p=Math.round(p)}for(c=0;4>c;c++)f[c]=(1-p)*((1-n)*t[c]+n*t[c+4])+p*((1-n)*t[c+8]+n*t[c+12])}else f=pb(c,d,e,1,1);c=h.realVector(f)}else c=k}else c=k;return c};t.imagergb$4=function(a,b){var c=t.imagergba$4(a,b);return c===k?k:h.turnIntoCSList(c.value.slice(0,3))};t.readpixels$1=function(a,b){for(var c=Ja(B(a[0])),c=pb(c,0,0,c.width,c.height),d=[],e=0;e+3<c.length;e+=4)d.push(h.turnIntoCSList([m.real(c[e+0]),m.real(c[e+1]),m.real(c[e+
2]),m.real(c[e+3])]));return h.turnIntoCSList(d)};"use strict";var ze=[{key:[":"],field:["."],deg:["\u00b0"],take:["_"]},{functionCall:!0},{rassoc:!0,pow:["^"],sqrt:["\u221a"]},{mul:["*","\u2062","\u22c5","\u00b7"],cross:["\u00d7"],div:["/","\u00f7","\u2215","\u2236"]},{add:["+"],sub:["-","\u2212"],neg:["!","\u00ac"]},{seq:[".."]},{eq:["==","\u225f"],ne:["!=","<>","\u2260"],lt:["<"],gt:[">"],le:["<=","\u2264","\u2266"],ge:[">=","\u2265","\u2267"],aeq:["~=","\u2248"],ane:["~!=","\u2249"],alt:["~<",
"\u2a89"],agt:["~>","\u2a8a"],ale:["~<=","\u2a85"],age:["~>=","\u2a86"],"in":["\u2208"],nin:["\u2209"]},{and:["&","\u2227"],or:["%","\u2228"]},{rassoc:!0,prepend:["<:"]},{concat:["++","\u222a"],remove:["--","\u2216"],common:["~~","\u2229"],append:[":>"]},{rassoc:!0,assign:["="],define:[":="],undefine:[":=_"],bdefine:["::="]},{seq:[";"]},{modif:["->","\u2192"]},{rassoc:!0,list:[","]}],Ae=["+","-"],Be=["!","\u221a"],Ce=["\u00b0",":=_"],De=[";",","],Kc=[],Ca={},kd;(function(){var a=0;ze.forEach(function(b){a+=
2;var c=!!b.rassoc;b.functionCall&&(kd=a);for(var d in b){var e=b[d];if("boolean"!==typeof e)for(var h={name:d,sym:e[0],symbols:e,rassoc:c,precedence:a,prefix:!1,postfix:!1,infix:!0,bare:!1},f=0;f<e.length;++f){var m=e[f];if(Ca.hasOwnProperty(m))throw Error("Duplicate operator: "+m);Ca[m]=h;Kc.push(m)}}});Ae.forEach(function(a){Ca[a].prefix=!0});Be.forEach(function(a){Ca[a].prefix=!0;Ca[a].infix=!1});Ce.forEach(function(a){Ca[a].postfix=!0;Ca[a].infix=!1});De.forEach(function(a){Ca[a].prefix=!0;Ca[a].postfix=
!0;Ca[a].infix=!0;Ca[a].bare=!0})})();Kc.sort(function(a,b){return b.length-a.length});var Ee="(?:[0-9](?: [0-9])*(?: \\.(?! \\.)(?: [0-9])*)?|\\.(?: [0-9])+)(?: [Ee](?: [+-])?(?: [0-9])+)?".replace(/ /g,"[ \t]*"),Fe="(?:[\u207a\u207b] )?[\u2070\u00b9\u00b2\u00b3\u2074\u2075\u2076\u2077\u2078\u2079](?: [\u2070\u00b9\u00b2\u00b3\u2074\u2075\u2076\u2077\u2078\u2079])*".replace(/ /g,"[ \t]*"),Ge="(?:[\u208a\u208b] )?[\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089](?: [\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089])*".replace(/ /g,
"[ \t]*"),Lc=function(a,b,c){var d,e,h=0,f="(?:[",m=b.length;for(d=0;d<m;++d)e=b.charCodeAt(d),55296<=e?(f+="]|"+b.charAt(d)+"[",h=56320):(f+=String.fromCharCode(e=h=a[e-32]+h),h+=a[b.charCodeAt(++d)-32],h!==e&&(h!==e+1&&(f+="-"),f+=String.fromCharCode(h)));return f+"]|["+c+"][\udc00-\udfff])"}([2,0,106,3,4,1,6,5,7,11,17,8,12,21,9,22,30,10,15,24,25,16,13,42,46,14,18,19,29,37,27,28,35,26,32,36,40,43,47,53,20,48,50,56,33,34,39,51,52,55,63,64,65,68,85,23,31,38,45,49,105,59,66,69,72,88,102,114,117,128,
157,191,41,44,54,60,67,70,71,73,74,75,76,80,81,82,83,84,86,87,89,93,94,98,99,107,108,116,122,130,132,134,138,160,165,185,195,196,255,268,277,310,332,339,362,365,390,449,457,470,512,513,541,568,582,619,673,726,768,820,921,991,1164,2684,6581,8453,11171,20949],"T4(4I!)!'!&/ 0 \u0096')2$+! !\u0083$ %## !(!   ! ; u \u0086.\u0088 =#!+YoA& 87C% } !5%+%) #!*! <0a,!4B1%'!&-'!1!$!33`HsG$!;!+.52'(#%#- & !$#$!*!9%  2%H''%#- & % % %B# !H *+   - & % $$!;!5%3!,(#%#- & % $$!X%  5!:! '$  #$% ! %$%$ $)W!G(   / 2$!> &%C(   / . $$!L! %5%;(   D#!*!* 4'&*$W + !#&]F %6&]% !#% !#!(# &   ! !#% # %1!#$ !/#L!S( @?$\u00817-!*''#$!$%+ ',6!:= !&!#7 \u0090 ##& ! ##D ##B ##& ! ##9 K ##^Y2*V#'$\u009d#5 4&p((+, #2*2*2,  5OC!'!Uy.D !&_)0J<#$,E'4Q/1Pv!|8:&K<9%)E>@7 )@\u0080# #$%1gT\u008e#'#=#'#( ! ! ! 0#P & !$  &$##'',&  &d!9!*,b!'!#. !$$(! ! ! # 1##&$'!G%\u00a58 8 \u0084(#$%6= !&!#Q+!*/1& & & & & & & &t!\u0097%E$&%'V(  z #&D${:Aj2\u0099\u00a6q\u00a9E\u00a4UZ#\u008d$2)%-8*0#_J+#b#M#(S1   # /0O2[R'$! !6>)/A?+8<!*$ .)$ D3  (-/$!$[ !$%#$#! !4 #1+ 6'#'#'1& & 7 .)c0\u00a86/'I\u00a7\u0093#\\N&6$&! . , $ ! % % \u007fM\u0092;R#Gh)d$ \u0085=4(4,a$'#'#'# \ud800!) 4 : % 9#6@\u0082\u0094?$IIX*5 ((=)<#@'(\ud801!f~N.Of\u008f1-)(\ud802!'#! E %$!#/)/10^: %)-)4nQ(%T!5#   AZ?$?C( >?G)-):9*\ud803!`KJ9J\ud804#PriL3>@7M$!6F2#/! !C* 3V& ! # 9 .+8N(#%#- & % $$!;!6$\ud805eF-% !\u008987#=F-!k7x4\ud806\u0087RB!\u0095K\ud808!\u00a2\ud809e\u008a\ud80d!8\ud811!\u009c\ud81a!\u009b+0c<;F*#BH&:\ud81b\u00a0U,!l,\ud82c!%\ud82f!\"&,$++.\ud835!w m %#!#%## ) ! & S ##( & > # $ !$& \u0091#3 3 0 3 0 3 0 3 0 3 (\ud83a!\u008b\ud83b\u0098# A % !#! . # ! !(!'! ! !   % !#! ! ! ! ! % !## & # # ! . 5&  $ 5\ud869!\u009f7\u008c\ud86d!\u00a1,g\ud86e!<#\u00a3\ud873!\u009e\ud87e!\u009a",
"\ud80c\ud840-\ud868\ud86a-\ud86c\ud86f-\ud872"),He=("#(?: [1-9])?|(?:'|"+Lc+")(?: (?:[0-9']|"+Lc+"))*").replace(/ /g,"[ \t]*"),hd=["([ \t\n]+)|(//.*)|(/\\*)","("+Ee+")","("+Kc.map(gd).join("|")+")","("+"[](){}||".split("").map(gd).join("|")+")","("+Ge+")","("+Fe+")","("+He+")",'("[^"]*")|($)'].join("|"),Ie=new RegExp("[ \t]*".replace(/\*$/,"+"),"g"),Mc="ANY WS COMMENT START_COMMENT NUM OP BRA SUB SUP ID STR EOF".split(" ");(function(){var a=(new RegExp(hd,"g")).exec("");if(a.hasOwnProperty(Mc.length))throw Error("RE has more groups than expected");
if(!a.hasOwnProperty(Mc.length-1))throw Error("RE has fewer groups than expected");})();qb.prototype.advanceBy=function(a){this.advanceTo(this.pos+a)};qb.prototype.advanceTo=function(a){for(this.pos=a;this.bols[0]<=a;)this.bol=this.bols.shift(),this.line++};qb.prototype.curPos=function(){return{row:this.line,col:this.pos-this.bol,pos:this.pos}};qb.prototype.nextInternal=function(){var a=this.re.exec(this.input);if(a.index!==this.pos)throw la("Invalid token",this.curPos(),this.input.substring(this.pos,
a.index));var b=this.curPos();this.advanceBy(a[0].length);var c=this.curPos(),d;for(d=1;null==a[d];++d);return{start:b,end:c,raw:a[0],text:a[0].replace(Ie,""),toktype:Mc[d]}};qb.prototype.next=function(){var a;do if(a=this.nextInternal(),"START_COMMENT"===a.toktype){var b=/\*\/|\/\*/g;b.lastIndex=a.start.pos+2;for(var c=1,d;0<c;)if(d=b.exec(this.input))"/*"===d[0]?++c:--c;else throw la("Unterminated comment",a.start,a.text);this.re.lastIndex=b.lastIndex;this.advanceTo(b.lastIndex);a.end=this.curPos();
a.raw=this.input.substring(a.start.pos,a.end.pos);a.text=a.raw;a.toktype="COMMENT"}while("WS"===a.toktype||"COMMENT"===a.toktype);return a};var Je={ctype:"void"};Lb.prototype.postprocess=function(a){if(null===a)return Je;if(a){if("infix"===a.ctype)if(":="===a.oper){var b=a.args[0];if("function"===b.ctype)b.args.forEach(function(c){if(null===c||"variable"!==c.ctype)throw la("Function argument must be an identifier",c.start||a.start);});else if("variable"!==b.ctype)throw la(a.oper+" can only be used to define functions or variables",
a.start);}else if(","===a.oper)throw la("comma may only be used to delimit list elements",a.start);a.args&&(a.args=a.args.map(this.postprocess,this));if(a.modifs)for(var c in a.modifs)a.modifs[c]=this.postprocess(a.modifs[c]);if("paren"===a.ctype)return a.args[0];if("infix"===a.ctype){if("."===a.oper){if(!a.args[1]||"variable"!==a.args[1].ctype)throw la("Field name must be identifier",a.start,a.text);a.ctype="field";a.obj=a.args[0];a.key=a.args[1].name;delete a.args}if(":"===a.oper){if(!a.args[1])throw la("Data key undefined",
a.start,a.text);a.ctype="userdata";a.obj=a.args[0];a.key=a.args[1];delete a.args}this.infixmap&&(a.impl=this.infixmap[a.oper])}else"variable"===a.ctype?this.usedVariables[a.name]=!0:"function"===a.ctype&&(this.usedFunctions[a.oper]=!0)}if("infix"===a.ctype)return{ctype:"infix",oper:String(a.oper),args:[a.args[0],a.args[1]],impl:a.impl};if("variable"===a.ctype)return{ctype:"variable",name:String(a.name)};if("number"===a.ctype)return{ctype:"number",value:{real:+a.value.real,imag:+a.value.imag}};if("string"===
a.ctype)return{ctype:"string",value:String(a.value)};if("list"===a.ctype)return{ctype:"list",value:a.value};if("function"===a.ctype)return{ctype:"function",oper:String(a.oper),args:a.args,modifs:a.modifs};if("field"===a.ctype)return{ctype:"field",obj:a.obj,key:String(a.key)};if("userdata"===a.ctype)return{ctype:"userdata",obj:a.obj,key:a.key};throw Error("Unsupported AST node of type "+a.ctype);};Lb.prototype.parse=function(a){try{var b=jd(new qb(a));if("EOF"!==b.closedBy.toktype)throw la("Closing bracket never opened.",
b.closedBy.start,b.closedBy.text);return this.postprocess(b.expr)}catch(c){return c.ctype="error",c}};"undefined"!==typeof process&&"undefined"!==typeof module&&"undefined"!==typeof module.exports&&"undefined"===typeof window&&(module.exports.Parser=Lb,module.exports.Tokenizer=qb,module.exports.unicodeLetters=Lc,module.exports.parse=function(a){return(new Lb).parse(a)});var hb={},Mb=[],Nc;Nc=[0,0,0,0,0,0,0,0,0,0,0,0];t.playsin$1=function(a,b){var c=B(a[0]),d=0;if("number"===c.ctype){var e;void 0!==
b.line&&(e=z(b.line),"number"===e.ctype&&(d=Math.floor(e.value.real),0>d&&(d=0),10<d&&(d=10)));c=c.value.real;0!==Nc[d]&&Nc[d].set({freq:c})}return k};var P={printArr:function(a){for(var b=a.value.length,c=[],d=[],e=!1,h=0;h<b;h++)c[h]=a.value[h].value.real,d[h]=a.value[h].value.imag,0!==d[h]&&(e=!0);console.log(c);e&&console.log(d)},zero:function(a){for(var b=[],c=m.real(0),d=0;d<a.value.real;d++)b[d]=c;return h.turnIntoCSList(b)},number:function(a,b){var c=P.zero(b);c.value[0]=a;return c},variable:function(a,
b){var c=P.zero(b);c.value[0]=a;c.value[1]=m.real(1);return c},add:function(a,b){return h.add(a,b)},sub:function(a,b){return h.sub(a,b)},mult:function(a,b){if(a.value.length!==b.value.length)return console.error("dims don't fit return nada"),k;for(var c=a.value.length,d=P.zero(m.real(c)),e=m.real(0),h=0;h<c;h++){for(var f=0;f<=h;f++)e=m.add(e,m.mult(a.value[f],b.value[h-f]));d.value[h]=e;e=m.real(0)}return d},pow:function(a,b){if(0>b.value.real||b.value.real!==Math.floor(b.value.real))return P.root(a,
b);for(var c=a,d=1;d<b.value.real;d++)c=P.mult(c,a);return c},root:function(a,b){var c=m.real(0),d=m.real(1),e=m.add(d,b),h=a.value.length,f=P.zero(m.real(h));f.value[0]=m.pow(a.value[0],b);for(var k=c,l,n,p=1;p<h;p++){n=m.real(p);for(var r=1;r<=p;r++)l=m.mult(e,m.real(r)),l=m.div(l,n),l=m.sub(l,d),l=m.mult(l,a.value[r]),l=m.mult(l,f.value[p-r]),k=m.add(k,l);k=m.div(k,a.value[0]);f.value[p]=k;k=c}return f},findFirstNoneZero:function(a,b,c){for(var d=Infinity,e=Infinity,h=c;h<a.value.length;h++)if(1E-12<
m.abs2(a.value[h]).value.real){d=h;break}for(a=c;a<b.value.length;a++)if(1E-12<m.abs2(b.value[a]).value.real){e=a;break}return[d,e]},div:function(a,b){if(a.value.length!==b.value.length)return console.log("dims don't fit - return nada"),k;for(var c=a.value.length,d=m.real(0),e=P.zero(m.real(c)),h=d,f,l=0;l<c;l++){f=P.findFirstNoneZero(a,b,l);l<f[0]&&f[0]===f[1]&&Infinity!==f[0]&&(a.value.splice(l,f[0]),b.value.splice(l,f[0]),e.value.splice(l,f[0]),c-=f[0]);f=a.value[l];for(var n=0;n<l;n++)h=m.add(h,
m.mult(e.value[n],b.value[l-n]));f=m.sub(f,h);f=m.div(f,b.value[0]);e.value[l]=f;h=d}return e},exp:function(a){var b=m.real(0),c=a.value.length,d=P.zero(m.real(c)),e=b,h;d.value[0]=m.exp(a.value[0]);for(var f=1;f<c;f++){for(var k=1;k<=f;k++)h=m.mult(m.real(k),a.value[k]),h=m.mult(h,d.value[f-k]),e=m.add(e,h);d.value[f]=m.div(e,m.real(f));e=b}return d},log:function(a){var b=m.real(0),c=a.value.length,d=P.zero(m.real(c));d.value[0]=m.log(a.value[0]);for(var e=b,h,f,k=1;k<c;k++){h=a.value[k];for(var l=
1;l<k;l++)f=m.mult(m.real(l),d.value[l]),f=m.mult(f,a.value[k-l]),e=m.add(e,f);e=m.div(e,m.real(k));h=m.sub(h,e);h=m.div(h,a.value[0]);d.value[k]=h;e=b}return d},sincos:function(a){var b=m.real(0),c=a.value.length,d=P.zero(m.real(c)),e=P.zero(m.real(c));d.value[0]=m.sin(a.value[0]);e.value[0]=m.cos(a.value[0]);for(var h=b,f=b,k,l,n,p=1;p<c;p++){n=m.real(p);for(var r=1;r<=p;r++)l=m.mult(m.real(r),a.value[r]),k=m.mult(l,e.value[p-r]),l=m.mult(l,d.value[p-r]),f=m.add(f,k),h=m.add(h,l);f=m.div(f,n);h=
m.div(h,m.neg(n));d.value[p]=f;e.value[p]=h;h=f=b}P.sinsave=d;P.cossave=e;return[d,e]},sin:function(a){return P.sincos(a)[0]},cos:function(a){return P.sincos(a)[1]},faculty:function(a){var b=[];b[0]=m.real(1);for(var c=1,d=1;d<=a.value.real;d++)c*=d,b[d]=m.real(c);return b=h.turnIntoCSList(b)},diff:function(a,b,c,d){var e;if("variable"===a.ctype)e=a.name!==b?P.number(z(a),d):P.variable(c,d);else if("number"===a.ctype)e=P.number(a,d);else{if("infix"===a.ctype){if("*"===a.oper)return P.mult(P.diff(a.args[0],
b,c,d),P.diff(a.args[1],b,c,d));if("^"===a.oper)return P.pow(P.diff(a.args[0],b,c,d),P.diff(a.args[1],b,c,d).value[0]);if("/"===a.oper)return P.div(P.diff(a.args[0],b,c,d),P.diff(a.args[1],b,c,d));if("+"===a.oper)return P.add(P.diff(a.args[0],b,c,d),P.diff(a.args[1],b,c,d));if("-"===a.oper)return P.sub(P.diff(a.args[0],b,c,d),P.diff(a.args[1],b,c,d));console.log("infix not found",a.oper);return k}if("function"===a.ctype){if("exp$1"===a.oper)return P.exp(P.diff(a.args[0],b,c,d));if("log$1"===a.oper)return P.log(P.diff(a.args[0],
b,c,d));if("sin$1"===a.oper)return P.sin(P.diff(a.args[0],b,c,d));if("cos$1"===a.oper)return P.cos(P.diff(a.args[0],b,c,d))}else return console.log("ctype not found",a.ctype),k}return e},adevaluate:function(a,b,c,d){a=P.diff(a,b,c,d);d=P.faculty(d);for(b=2;b<a.value.length;b++)a.value[b]=m.mult(a.value[b],d.value[b]);return a},autodiff:function(a,b,c,d){for(var e=[],f=c.value.length,m,k=0;k<f;k++)m=P.adevaluate(a,b,c.value[k],d),e[k]=m;return e=h.turnIntoCSList(e)}},x={handleModifs:function(a,b){x.dashing&&
x.unSetDash();x.colorraw=null;x.fillcolorraw=null;x.fillrule="nonzero";x.size=null;0>=x.psize&&(x.psize=0);0>=x.lsize&&(x.lsize=0);x.overhang=1;x.dashing=!1;x.isArrow=!1;x.arrowSides="==>";x.arrowposition=1;x.headlen=10;x.arrowShape=x.arrowShapes.line;x.alpha=y.drawingstate.alpha;x.fillalpha=0;x.bold="";x.italics="";x.family="sans-serif";x.align=0;x.xOffset=0;x.yOffset=0;x.lineCap="round";x.lineJoin="round";x.miterLimit=10;x.noborder=!1;var c,d;for(c in a){var e=a[c];e&&((d=b[c])?(!0===d&&(d=x.modifHandlers[c]),
d(z(e))):console.log("Modifier not supported: "+c))}null!==x.size?x.psize=x.lsize=x.size:(x.psize=y.drawingstate.pointsize,x.lsize=y.drawingstate.linesize);x.dashing&&x.dashing(x.lsize);null!==x.colorraw?x.pointColor=x.lineColor=x.textColor=x.makeColor(x.colorraw):1===x.alpha?(x.pointColor=y.drawingstate.pointcolor,x.lineColor=y.drawingstate.linecolor,x.textColor=y.drawingstate.textcolor):(x.pointColor=x.makeColor(y.drawingstate.pointcolorraw),x.lineColor=x.makeColor(y.drawingstate.linecolorraw),
x.textColor=x.makeColor(y.drawingstate.textcolorraw));x.black=1===x.alpha?"rgb(0,0,0)":"rgba(0,0,0,"+x.alpha+")";x.fillColor=x.fillcolorraw&&0<x.fillalpha?x.makeColor(x.fillcolorraw,x.fillalpha):null},modifHandlers:{size:function(a){"number"===a.ctype&&(x.size=a.value.real,0>x.size&&(x.size=0),1E3<x.size&&(x.size=1E3))},color:function(a){h.isNumberVector(a).value&&3===a.value.length&&(x.colorraw=[a.value[0].value.real,a.value[1].value.real,a.value[2].value.real])},fillcolor:function(a){h.isNumberVector(a).value&&
3===a.value.length&&(x.fillcolorraw=[a.value[0].value.real,a.value[1].value.real,a.value[2].value.real])},alpha:function(a){"number"===a.ctype&&(x.alpha=a.value.real)},fillalpha:function(a){"number"===a.ctype&&(x.fillalpha=a.value.real)},dashpattern:function(a){if("list"===a.ctype){for(var b=[],c=0,d=0;c<a.value.length;c++)"number"===a.value[c].ctype&&(b[d++]=a.value[c].value.real);x.dashing=x.setDash.bind(null,b)}},dashtype:function(a){if("number"===a.ctype)a=Math.floor(a.value.real);else if("string"===
a.ctype)a=a.value;else return;if(a=x.dashTypes[a])x.dashing=x.setDash.bind(null,a)},dashing:function(a){"number"===a.ctype&&(a=Math.floor(a.value.real),x.dashing=x.setDash.bind(null,[2*a,a]))},overhang:function(a){"number"===a.ctype&&(x.overhang=x.overhang*a.value.real+(1-x.overhang)*(1-a.value.real))},arrow:function(a){"boolean"===a.ctype?x.isArrow=a.value:console.error("arrow needs to be of type boolean")},arrowshape:function(a){"string"!==a.ctype?console.error("arrowshape needs to be of type string"):
x.arrowShapes.hasOwnProperty(a.value)?(x.arrowShape=x.arrowShapes[a.value],x.isArrow=!0,x.arrowShape.deprecated&&(console.log("arrowshape "+a.value+" is deprecated, use "+x.arrowShape.deprecated+" instead."),x.arrowShape.deprecated=null)):(a=Object.keys(x.arrowShapes),a.sort(),a=a.join(", "),console.error("arrowshape needs to be one of "+a))},arrowsides:function(a){"string"!==a.ctype?console.error("arrowsides is not of type string"):"==>"!==a.value&&"<==>"!==a.value&&"<=="!==a.value?console.error("arrowsides is unknows"):
(x.arrowSides=a.value,x.isArrow=!0)},arrowposition:function(a){"number"!==a.ctype?console.error("arrowposition is not of type number"):0>a.value.real?console.error("arrowposition has to be positive"):1<a.value.real?x.overhang=x.overhang*a.value.real+(1-x.overhang)*(1-a.value.real):(x.arrowposition=a.value.real,x.isArrow=!0)},arrowsize:function(a){"number"!==a.ctype?console.error("arrowsize is not of type number"):0>a.value.real?console.error("arrowsize has to be positive"):x.headlen*=a.value.real},
bold:function(a){"boolean"===a.ctype&&a.value&&(x.bold="bold ")},italics:function(a){"boolean"===a.ctype&&a.value&&(x.italics="italic ")},family:function(a){"string"===a.ctype&&(x.family=a.value)},align:function(a){"string"===a.ctype&&(a=a.value,"left"===a&&(x.align=0),"right"===a&&(x.align=1),"mid"===a||"center"===a)&&(x.align=.5)},x_offset:function(a){"number"===a.ctype&&(x.xOffset=a.value.real)},y_offset:function(a){"number"===a.ctype&&(x.yOffset=a.value.real)},offset:function(a){"list"===a.ctype&&
2===a.value.length&&"number"===a.value[0].ctype&&"number"===a.value[1].ctype&&(x.xOffset=a.value[0].value.real,x.yOffset=a.value[1].value.real)},lineCap:function(a){"string"!==a.ctype||"round"!==a.value&&"square"!==a.value&&"butt"!==a.value||(x.lineCap=a.value)},lineJoin:function(a){"string"!==a.ctype||"round"!==a.value&&"bevel"!==a.value&&"miter"!==a.value||(x.lineJoin=a.value)},fillrule:function(a){"string"!==a.ctype||"nonzero"!==a.value&&"evenodd"!==a.value||(x.fillrule=a.value)},miterLimit:function(a){"number"===
a.ctype&&0<a.value.real&&(x.miterLimit=Math.round(a.value.real))},noborder:function(a){"boolean"===a.ctype?x.noborder=a.value:console.error("noborder needs to be of type boolean")},border:function(a){"boolean"===a.ctype?x.noborder=!a.value:console.error("border needs to be of type boolean")}},lineModifs:{size:!0,color:!0,alpha:!0,dashpattern:!0,dashtype:!0,dashing:!0,overhang:!0,arrow:!0,arrowshape:!0,arrowsides:!0,arrowposition:!0,arrowsize:!0,lineCap:!0,lineJoin:!0,miterLimit:!0},pointModifs:{size:!0,
color:!0,alpha:!0,noborder:!0,border:!0}};x.pointAndLineModifs=x.lineModifs;x.conicModifs={size:!0,color:!0,alpha:!0,fillcolor:!0,fillrule:!0,fillalpha:!0,lineCap:!0,lineJoin:!0,miterLimit:!0};x.textModifs={size:!0,color:!0,alpha:!0,bold:!0,italics:!0,family:!0,align:!0,x_offset:!0,y_offset:!0,offset:!0};x.makeColor=function(a,b){void 0===b&&(b=x.alpha);return"rgba("+Math.floor(255*a[0])+","+Math.floor(255*a[1])+","+Math.floor(255*a[2])+","+b+")"};x.preDrawCurve=function(){A.lineWidth=x.lsize;A.lineCap=
x.lineCap;A.lineJoin=x.lineJoin;A.mozFillRule=x.fillrule;A.fillrule=x.fillrule;A.miterLimit=x.miterLimit;A.strokeStyle=x.lineColor};x.arrowShapes={"default":{close:!1,fill:!1,ratio:1,deprecated:"line"},line:{close:!1,fill:!1,ratio:1},empty:{close:!0,fill:!1,ratio:1},hollow:{close:!0,fill:!1,ratio:1,deprecated:"empty"},full:{close:!0,fill:!0,ratio:1},jet:{close:!0,fill:!0,ratio:1.5},delta:{close:!0,fill:!0,ratio:1.5,deprecated:"jet"}};x.clipSegment=function(a,b){var c=b.x-a.x,d=b.y-a.y,e=x.clipLineCore(-d,
c,a.x*b.y-b.x*a.y);if(2!==e.length)return[];var h=e[0],e=e[1],f=1/(c*c+d*d),m=((h.x-a.x)*c+(h.y-a.y)*d)*f,c=((e.x-a.x)*c+(e.y-a.y)*d)*f;0>m&&(h=a);1<m&&(h=b);0>c&&(e=a);1<c&&(e=b);return h===e?[]:[h,e]};x.drawsegcore=function(a,b){function c(a,b,c,g){var d=a-g*r+.5*t,e=b-g*t-.5*r,h=a-g*r-.5*t;g=b-g*t+.5*r;A.beginPath();x.arrowShape.fill&&(A.lineWidth=x.lsize/2);A.moveTo(d,e);A.lineTo(a,b);A.lineTo(h,g);x.arrowShape.close&&(A.fillStyle=x.lineColor,A.lineTo(a-c*r,b-c*t),A.closePath(),x.arrowShape.fill&&
A.fill());A.stroke()}var d=y.drawingstate.matrix,e=a.x*d.a-a.y*d.b+d.tx,h=a.x*d.c-a.y*d.d-d.ty,f=b.x*d.a-b.y*d.b+d.tx,m=b.x*d.c-b.y*d.d-d.ty,k=x.overhang,l=1-k,d=k*e+l*f,n=k*h+l*m,p=k*f+l*e,k=k*m+l*h;if(0>d||d>ca||0>n||n>da||0>p||p>ca||0>k||k>da){k=x.clipSegment({x:d,y:n},{x:p,y:k});if(2!==k.length||.01>x.lsize)return;d=k[0].x;n=k[0].y;p=k[1].x;k=k[1].y}x.preDrawCurve();if(!x.isArrow||e===h&&f===m).01>x.lsize||(A.beginPath(),A.moveTo(d,n),A.lineTo(p,k),A.stroke());else{var e=f-e,h=m-h,f=x.headlen/
Math.sqrt(e*e+h*h),r=e*f,t=h*f,m=x.arrowposition,l=1-m,h=m*d+l*p,e=m*n+l*k,f=m*p+l*d,m=m*k+l*n,l=x.arrowSides;A.beginPath();x.arrowShape.close?("<==>"===l||"<=="===l?(1>x.arrowposition&&(A.moveTo(d,n),A.lineTo(h,e)),A.moveTo(h+r,e+t)):A.moveTo(d,n),"==>"===l||"<==>"===l?(A.lineTo(f-r,m-t),1>x.arrowposition&&(A.moveTo(f,m),A.lineTo(p,k))):A.lineTo(p,k)):(A.moveTo(d,n),A.lineTo(p,k));A.stroke();"==>"!==l&&"<==>"!==l||c(f,m,1,x.arrowShape.ratio);"<=="!==l&&"<==>"!==l||c(h,e,-1,-x.arrowShape.ratio)}};
x.drawpoint=function(a){var b=y.drawingstate.matrix,c=a.x*b.a-a.y*b.b+b.tx;a=a.x*b.c-a.y*b.d-b.ty;A.lineWidth=.3*x.psize;A.beginPath();A.arc(c,a,x.psize,0,2*Math.PI);A.fillStyle=x.pointColor;A.fill();x.noborder||(A.beginPath(),A.arc(c,a,1.15*x.psize,0,2*Math.PI),A.fillStyle=x.black,A.strokeStyle=x.black,A.stroke())};x.clipLineCore=function(a,b,c){var d=Math.SQRT1_2*x.lsize,e=0-d,h=ca+d,f=0-d,d=da+d,m=0>e*a+f*b+c,k=0>h*a+f*b+c,l=0>e*a+d*b+c,n=0>h*a+d*b+c,p=[];m!==k&&p.push({x:(-c-b*f)/a,y:f});k!==
n&&p.push({x:h,y:(-c-a*h)/b});l!==n&&p.push({x:(-c-b*d)/a,y:d});m!==l&&p.push({x:e,y:(-c-a*e)/b});return p};x.clipLine=function(a){a=h.normalizeMax(h.productVM(a,y.toMat()));return x.clipLineCore(a.value[0].value.real,a.value[1].value.real,a.value[2].value.real)};x.drawline=function(a){h._helper.isAlmostReal(a)&&(a=x.clipLine(a),2===a.length&&.01<=x.lsize&&(x.preDrawCurve(),A.beginPath(),A.moveTo(a[0].x,a[0].y),A.lineTo(a[1].x,a[1].y),A.stroke()))};x.drawRaySegment=function(a,b){var c=D.extractPoint(a),
d=D.extractPoint(b);if(c.ok&&d.ok){var e=c.x-d.x,h=c.y-d.y,f=25E3/y.drawingstate.matrix.sdet/Math.sqrt(e*e+h*h),e=e*f,h=h*f;x.drawsegcore(c,{x:c.x+e,y:c.y+h});x.drawsegcore(d,{x:d.x-e,y:d.y-h})}};x.dashTypes={solid:[],dashed:[10,10],tightdash:[10,4],dotted:[1,3],dashdot:[10,5,1,5],"dashvalue.solid":[],"dashvalue.dashed":[10,10],"dashvalue.tightdash":[10,4],"dashvalue.dotted":[1,3],"dashvalue.dashdot":[10,5,1,5],0:[],1:[10,10],2:[10,4],3:[1,3],4:[10,5,1,5]};x.setDash=function(a,b){var c=Math.sqrt(b);
a=a.slice();for(var d=0;d<a.length;d++)a[d]*=c;A.webkitLineDash=a;A.setLineDash(a);A.mozDash=a};x.unSetDash=function(){A.webkitLineDash=[];A.setLineDash([]);A.mozDash=[]};ld.prototype={set fillStyle(a){var b=this;ac(a,function(a,d,e,h){b._fill="#"+rb(a.toString(16),2)+rb(d.toString(16),2)+rb(e.toString(16),2);b._fillOpacity=255===h?null:h})},set strokeStyle(a){var b=this;ac(a,function(a,d,e,h){b._stroke="#"+rb(a.toString(16),2)+rb(d.toString(16),2)+rb(e.toString(16),2);b._strokeOpacity=255===h?null:
h})},clearRect:function(){},beginPath:function(){this._path=[]},_pathcmd:function(){this._path.push.apply(this._path,arguments)},closePath:function(){this._pathcmd("Z")},moveTo:function(a,b){this._pathcmd("M",a,b)},lineTo:function(a,b){this._pathcmd("L",a,b)},bezierCurveTo:function(a,b,c,d,e,h){this._pathcmd("C",a,b,c,d,e,h)},quadraticCurveTo:function(a,b,c,d){this._pathcmd("Q",a,b,c,d)},arc:function(a,b,c,d,e,h){var f=c*Math.cos(d)+a,m=c*Math.sin(d)+b,k=c*Math.cos(e)+a,l=c*Math.sin(e)+b;e=h?d-e:
e-d;e>=2*Math.PI?this._pathcmd(this._path.length?"L":"M",f,m,"A",c,c,0,0,h?1:0,a-c*Math.cos(d),b-c*Math.sin(d),"A",c,c,0,0,h?1:0,f,m):this._pathcmd(this._path.length?"L":"M",f,m,"A",c,c,0,e>Math.PI?1:0,h?1:0,k,l)},rect:function(a,b,c,d){this._pathcmd("M",a,b,"h",c,"v",d,"h",-c,"z")},_cmd:function(a){1!==this.globalAlpha?(this._body.push('<g opacity="'+this.globalAlpha+'">'),this._body.push(a),this._body.push("</g>")):this._body.push(a)},_attrs:function(a){var b="",c;for(c in a)null!==a[c]&&(b+=" "+
c+'="'+a[c]+'"');return b},fill:function(){this._cmd("<path"+this._attrs({d:this._path.join(" "),fill:this._fill,"fill-opacity":this._fillOpacity})+"/>")},stroke:function(){this._cmd("<path"+this._attrs({d:this._path.join(" "),stroke:this._stroke,"stroke-opacity":this._strokeOpacity,"stroke-width":this.lineWidth,"stroke-linecap":this.lineCap,"stroke-linejoin":this.lineJoin,"stroke-miterlimit":"miter"===this.lineJoin?this.miterLimit:null})+"/>")},clip:function(){++this._clipIndex;this._body.push('<clipPath id="clip'+
this._clipIndex+'"><path d="'+this._path.join(" ")+'"/></clipPath>','<g clip-path="url(#clip'+this._clipIndex+')">');this._saveStack[this._saveStack.length-1]+="</g>"},save:function(){this._saveStack.push("")},restore:function(){this._body.push(this._saveStack.pop());0===this._saveStack.length&&this._saveStack.push("")},_transform:function(a){this._body.push('<g transform="'+a+'">');this._saveStack[this._saveStack.length-1]+="</g>"},translate:function(a,b){this._transform("translate("+a+" "+b+")")},
rotate:function(a){this._transform("rotate("+Math.PI/180*a+")")},scale:function(a,b){this._transform("scale("+a+" "+b+")")},transform:function(a,b,c,d,e,h){this._transform("matrix("+[a,b,c,d,e,h].join(" ")+")")},drawImage:function(a,b,c){if(3!==arguments.length)throw Error("SvgWriterContext only supports 3-argument version of drawImage");var d=this._imgcache.indexOf(a);if(-1===d){var d=this._imgcache.length,e;e=a.cachedDataURL?a.cachedDataURL:nd(a);this._defs.push('<image id="img'+d+'" x="0" y="0" width="'+
a.width+'" height="'+a.height+'" xlink:href="'+e+'"/>');this._imgcache.push(a)}this._cmd('<use x="'+b+'" y="'+c+'" xlink:href="#img'+d+'"/>')},toBlob:function(){for(;1<this._saveStack.length||""!==this._saveStack[0];)this.restore();var a='<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="'+this.width+'px" height="'+this.height+'px">\n'+this._defs.join("\n")+'\n</defs>\n<g stroke="none" fill="none">\n'+
this._body.join("\n")+"\n</g>\n</svg>\n";return new Blob([a],{type:"image/svg+xml"})}};md.prototype={_cmd:function(){this._body.push(Array.prototype.join.call(arguments," "))},_setAlpha:function(a,b,c){var d=Math.round(255*a*this._globalAlpha);b+=d;this._extGState[b]="<< /"+c+" "+d/255+" >>";this._cmd("/"+b,"gs");return a},set globalAlpha(a){this._globalAlpha=a;this._setAlpha(this._strokeAlpha,"As","CA");this._setAlpha(this._fillAlpha,"Af","ca")},set fillStyle(a){var b=this;ac(a,function(a,d,e,h){b._cmd(a/
255,d/255,e/255,"rg");b._setAlpha(b._fillAlpha=h,"Af","ca")})},set strokeStyle(a){var b=this;ac(a,function(a,d,e,h){b._cmd(a/255,d/255,e/255,"RG");b._setAlpha(b._strokeAlpha=h,"As","CA")})},set lineWidth(a){this._cmd(a,"w")},set lineCap(a){this._cmd({butt:0,round:1,square:2}[a],"J")},set lineJoin(a){this._cmd({miter:0,round:1,bevel:2}[a],"j")},set miterLimit(a){this._cmd(a,"M")},clearRect:function(){},beginPath:function(){this._pathUsed=!1},closePath:function(){this._cmd("h")},moveTo:function(a,b){this._cmd(this._xPos=
a,this._yPos=-b,"m")},lineTo:function(a,b){this._cmd(this._xPos=a,this._yPos=-b,"l")},bezierCurveTo:function(a,b,c,d,e,h){this._cmd(a,-b,c,-d,this._xPos=e,this._yPos=-h,"c")},quadraticCurveTo:function(a,b,c,d){this.bezierCurveTo((2*a+this._xPos)/3,(2*b-this._yPos)/3,(c+2*a)/3,(d+2*b)/3,c,d)},_kappa:.5522847498307935,arc:function(a,b,c,d,e,h){if(0===d&&e===2*Math.PI)d=this._kappa*c,this.moveTo(a+c,b),this.bezierCurveTo(a+c,b+d,a+d,b+c,a,b+c),this.bezierCurveTo(a-d,b+c,a-c,b+d,a-c,b),this.bezierCurveTo(a-
c,b-d,a-d,b-c,a,b-c),this.bezierCurveTo(a+d,b-c,a+c,b-d,a+c,b);else throw Error("PdfWriterContext.arc only supports full circles");},rect:function(a,b,c,d){this._cmd(a,-b,c,-d,"re")},_usePath:function(a){if(this._pathUsed){var b=this._body[this._pathUsed],c={"S + f":"B","f + S":"B","W n + S":"W S","W n + f":"W f","S + W n":"W S","f + W n":"W f","B + W n":"W B","W S + f":"W B","W f + S":"W B"}[b+" + "+a];if(!c)throw Error("Don't know how to combine '"+b+"' and '"+a+"'");this._body.splice(this._pathUsed,
1);a=c}this._pathUsed=this._body.length;this._cmd(a)},fill:function(){this._usePath("f")},stroke:function(){this._usePath("S")},clip:function(){this._usePath("W n")},save:function(){this._cmd("q")},restore:function(){this._cmd("Q")},translate:function(a,b){this.transform(1,0,0,1,a,b)},rotate:function(a){var b=Math.cos(a);a=Math.sin(a);this.transform(b,a,-a,b,0,0)},scale:function(a,b){this.transform(a,0,0,b,0,0)},transform:function(a,b,c,d,e,h){this._cmd(a,-b,-c,d,e,-h,"cm")},_png:function(a){if("data:image/png;base64,"!==
a.substr(0,22))return{error:"Not a base64-encoded PNG file"};a=de(a.substr(22));var b=ee(a);console.log("PNG chunks:",b.map(function(a){return a.type}));if("IHDR"!==b[0].type)throw Error("Image does not start with an IHDR");var c=b[0].data;a=(c[0]<<24|c[1]<<16|c[2]<<8|c[3])>>>0;var d=(c[4]<<24|c[5]<<16|c[6]<<8|c[7])>>>0,e=c[8],h=c[9],f=0===(h&2),m=0!==(h&4),k=c[10],l=c[11],c=c[12];if(0!==k)throw Error("Unsupported PNG compression method: "+k);if(0!==l)throw Error("Unsupported PNG filter method: "+
l);if(0!==c)return{error:"Interlaced image not supported"};if(0!==(h&1))return{error:"Indexed PNG image not supported"};l=null;h=f?1:3;k=b.filter(function(a){return"IDAT"===a.type}).map(function(a){return a.data});if(m){m=window.pako;l=new m.Inflate;for(b=0;b<k.length;++b)l.push(k[b],b+1===k.length);if(l.err)throw Error(l.err);l=l.result;c=e>>>3;if(l.length!==d*(a*(h+1)*c+1))throw Error("Data length mismatch");for(var n=h*c,k=new Uint8Array(d*(a*n+1)),p=new Uint8Array(d*(a*c+1)),r=0,t=0,v=0,u=0;u<
d;++u){k[t++]=p[v++]=l[r++];for(var w=0;w<a;++w){for(b=0;b<n;++b)k[t++]=l[r++];for(b=0;b<c;++b)p[v++]=l[r++]}}if(r!==l.length||t!==k.length||v!==p.length)throw Error("Seems we garbled our index computation somehow");p=m.deflate(p);l=this._strm({Type:"/XObject",Subtype:"/Image",Width:a,Height:d,ColorSpace:"/DeviceGray",BitsPerComponent:e,Filter:"/FlateDecode",DecodeParms:this._dict({Predictor:15,Colors:1,BitsPerComponent:e,Columns:a})},p).ref;k=[m.deflate(k)]}var x=0;k.forEach(function(a){x+=a.length});
return this._obj([this._dict({Type:"/XObject",Subtype:"/Image",Name:"/img"+this._imgcache.length,Width:a,Height:d,ColorSpace:f?"/DeviceGray":"/DeviceRGB",SMask:l,BitsPerComponent:e,Length:x,Filter:"/FlateDecode",DecodeParms:this._dict({Predictor:15,Colors:h,BitsPerComponent:e,Columns:a})}),"\nstream\n"].concat(k,["\nendstream"]))},drawImage:function(a,b,c){if(3!==arguments.length)throw Error("PdfWriterContext only supports 3-argument version of drawImage");var d=this._imgcache.indexOf(a);if(-1===
d){d=this._imgcache.length;this._imgcache.push(a);var e=this._png(a.cachedDataURL||"");e.hasOwnProperty("error")&&(e=this._png(nd(a)));if(e.hasOwnProperty("error"))throw Error(e.error);this._xobjects["img"+d]=e.ref}this._cmd("q");this._setAlpha(1,"Af","ca");this._cmd(a.width,0,0,a.height,b,-c-a.height,"cm");this._cmd("/img"+d,"Do");this._cmd("Q")},_dict:function(a){var b="<<",c;for(c in a)b+=" /"+c+" "+a[c];return b+" >>"},_obj:function(a,b){b||(b=this._nextIndex++);Array.isArray(a)||(a=[this._dict(a)]);
a.index=b;a.ref=b+" 0 R";a.offset=this._offset;var c=0;a.unshift(b+" 0 obj\n");a.push("\nendobj\n");for(var d=0;d<a.length;++d)c+=a[d].length;this._offset+=c;this._objects.push(a);return a},_strm:function(a,b,c){a.Length=b.length;return this._obj([this._dict(a),"\nstream\n",b,"\nendstream"],c)},toBlob:function(){var a;a="["+[0,-this.height,this.width,0].join(" ")+"]";this._obj({Type:"/Catalog",Pages:"2 0 R"},1);this._obj({Type:"/Pages",Kids:"[3 0 R]",Count:1},2);this._obj({Type:"/Page",Parent:"2 0 R",
MediaBox:a,Contents:"4 0 R",Resources:this._dict({ProcSet:"[/PDF /Text /ImageB /ImageC /ImageI]",XObject:this._dict(this._xobjects),ExtGState:this._dict(this._extGState)})},3);var b=this._body.join("\n"),c=new Uint8Array(b.length);for(a=0;a<b.length;++a)c[a]=b.charCodeAt(a)&255;b=window.pako.deflate(c);this._strm({Filter:"/FlateDecode"},b,4);var b=this._objects,d=[];for(a=1;a<b.length;++a)d[b[a].index]=b[a];c="xref\n0 "+d.length+"\n";for(a=0;a<d.length;++a)c=d[a]?c+(rb(String(d[a].offset),10)+" 00000 n \n"):
c+"0000000000 65535 f \n";a="trailer\n"+this._dict({Size:d.length,Root:"1 0 R"})+"\nstartxref\n"+this._offset+"\n%%EOF\n";b=Array.prototype.concat.apply([],b);b.push(c,a);return new Blob(b,{type:"application/pdf"})}};var Nb=null;jb.push(od);sa.exportSVG=function(){pd(ld)};sa.exportPDF=function(){va.loadScript("pako","pako.min.js",function(){pd(md)})};sa.exportPNG=function(){qd(A.canvas.toDataURL())};var qd=function(a){var b=document.createElement("a");document.body.appendChild(b);b.style="display: none";
b.href=a;b.download="CindyJSExport";b.click();setTimeout(function(){document.body.removeChild(b);od()},100)},xc="Move",Pb,Aa=[],Ya=0,ge=0,xb=0,G={Delete:{}};G.Delete.actions=[];G.Delete.actions[0]={};G.Delete.actions[0].event="mousedown";G.Delete.actions[0].tooltip="...";G.Delete.actions[0]["do"]=function(){ja=Ob(aa);null!==ja&&vd(ja.mover.name);return!0};G.Move={};G.Move.actions=[];G.Move.actions[0]={};G.Move.actions[0].event="mousedown";G.Move.actions[0].tooltip="Move free elements by dragging the mouse";
G.Move.actions[0]["do"]=function(){for(var a=aa,b=null,c=1E6,d,e=0;e<v.free.length;e++){var f=v.free[e];if(!f.pinned&&!1!==f.visible&&!0!==f.tmp){var k,l,n,p=y.drawingstate.matrix.sdet;if("P"===f.kind){l=h.normalizeZ(f.homog);if(!h._helper.isAlmostReal(l))continue;k=l.value[0].value.real-a.x;l=l.value[1].value.real-a.y;n=Math.sqrt(k*k+l*l);if(f.narrow&&n>("number"===typeof f.narrow?f.narrow:20)/p)continue}else if("C"===f.kind){l=h.normalizeZ(v.csnames[f.args[0]].homog);k=f.radius;if(!h._helper.isAlmostReal(l)||
!m._helper.isAlmostReal(k))continue;n=l.value[0].value.real;var r=l.value[1].value.real;l=a.x-n;var t=a.y-r,u=Math.sqrt(l*l+t*t);if(0===u)continue;r+=t/u*k.value.real;k=n+l/u*k.value.real-a.x;l=r-a.y;n=Math.sqrt(k*k+l*l);n+=30/p;if(f.narrow&&n>(("number"===typeof f.narrow?f.narrow:20)+30)/p)continue}else if("L"===f.kind)k=f.homog,n=m,l=n.add(n.mult(k.value[0],n.conjugate(k.value[0])),n.mult(k.value[1],n.conjugate(k.value[1]))),l=h.scaldiv(n.sqrt(l),k),n=l.value[0].value.real*a.x+l.value[1].value.real*
a.y+l.value[2].value.real,k=-l.value[0].value.real*n,l=-l.value[1].value.real*n,0>n&&(n=-n),n+=25/p;else if("Text"===f.kind){if(!f.homog||f.dock||!f._bbox)continue;l=y.from(a.x,a.y,1);k=Math.max(0,l[0]-f._bbox.right,f._bbox.left-l[0]);l=Math.max(0,l[1]-f._bbox.bottom,f._bbox.top-l[1]);n=Math.sqrt(k*k+l*l);if(20<n)continue;n/=p;l=h.normalizeZ(f.homog);if(!h._helper.isAlmostReal(l))continue;k=l.value[0].value.real-a.x;l=l.value[1].value.real-a.y}else continue;n<c+.2/p&&(c=n,b=f,d={x:k,y:l})}}console.log("Moving "+
(b?b.name:"nothing"));ja=null===b?null:{mover:b,offset:d,prev:{x:a.x,y:a.y}};return!0};G.Point={};G.Point.actions=[];G.Point.actions[0]={};G.Point.actions[0].event="mousedown";G.Point.actions[0].tooltip="Add a single point with the mouse";G.Point.actions[0]["do"]=function(){Ka({type:"Free",name:Xa(),labeled:!0,pos:[ra[0],ra[1],1]});return!0};G.Mid={};G.Mid.actions=[];G.Mid.actions[0]={};G.Mid.actions[0].event="mousedown";G.Mid.actions[0].tooltip="Construct two points and their midpoint by dragging";
G.Mid.actions[0]["do"]=function(){sb();return!0};G.Mid.actions[1]={};G.Mid.actions[1].event="mousemove";G.Mid.actions[1]["do"]=function(){bc("Mid");return!0};G.Mid.actions[2]={};G.Mid.actions[2].event="mouseup";G.Mid.actions[2]["do"]=function(){yb();return!0};G.Circle={};G.Circle.actions=[];G.Circle.actions[0]={};G.Circle.actions[0].event="mousedown";G.Circle.actions[0].tooltip="Construct two points and a circle by dragging the mouse";G.Circle.actions[0]["do"]=function(){sb();return!0};G.Circle.actions[1]=
{};G.Circle.actions[1].event="mousemove";G.Circle.actions[1]["do"]=function(){bc("CircleMP");return!0};G.Circle.actions[2]={};G.Circle.actions[2].event="mouseup";G.Circle.actions[2]["do"]=function(){yb();return!0};G.Compass={};G.Compass.actions=[];G.Compass.actions[0]={};G.Compass.actions[0].event="mousedown";G.Compass.actions[0].tooltip="...";G.Compass.actions[0]["do"]=function(){sb();return!0};G.Compass.actions[1]={};G.Compass.actions[1].event="mousedown";G.Compass.actions[1].tooltip="...";G.Compass.actions[1]["do"]=
function(){sb();return!0};G.Compass.actions[2]={};G.Compass.actions[2].event="mousedown";G.Compass.actions[2].tooltip="...";G.Compass.actions[2]["do"]=function(){sb();Ka({type:"Compass",name:Xa(),labeled:!0,args:[Aa[0].name,Aa[1].name,Aa[2].name]});return!0};G.Line={};G.Line.actions=[];G.Line.actions[0]={};G.Line.actions[0].event="mousedown";G.Line.actions[0].tooltip="Construct two points and their connecting line by dragging the mouse";G.Line.actions[0]["do"]=function(){sb();return!0};G.Line.actions[1]=
{};G.Line.actions[1].event="mousemove";G.Line.actions[1]["do"]=function(){bc("Join");return!0};G.Line.actions[2]={};G.Line.actions[2].event="mouseup";G.Line.actions[2]["do"]=function(){yb();return!0};G.Segment={};G.Segment.actions=[];G.Segment.actions[0]={};G.Segment.actions[0].event="mousedown";G.Segment.actions[0].tooltip="Draw a segment by dragging the mouse";G.Segment.actions[0]["do"]=function(){sb();return!0};G.Segment.actions[1]={};G.Segment.actions[1].event="mousemove";G.Segment.actions[1]["do"]=
function(){bc("Segment");return!0};G.Segment.actions[2]={};G.Segment.actions[2].event="mouseup";G.Segment.actions[2]["do"]=function(){yb();return!0};G.Parallel={};G.Parallel.actions=[];G.Parallel.actions[0]={};G.Parallel.actions[0].event="mousedown";G.Parallel.actions[0].tooltip="Construct a parallel line by dragging a line";G.Parallel.actions[0]["do"]=function(){return td()};G.Parallel.actions[1]={};G.Parallel.actions[1].event="mousemove";G.Parallel.actions[1]["do"]=function(){var a={type:"Free",
name:Xa(),labeled:!0,pos:[ra[0],ra[1],1],tmp:!0},a=Ka(a);Pb=Ka({type:"Para",name:Xa(),labeled:!0,args:[Aa[0].name,a.name]});zc(a);return!0};G.Parallel.actions[2]={};G.Parallel.actions[2].event="mouseup";G.Parallel.actions[2]["do"]=function(){yb();return!0};G.Orthogonal={};G.Orthogonal.actions=[];G.Orthogonal.actions[0]={};G.Orthogonal.actions[0].event="mousedown";G.Orthogonal.actions[0].tooltip="Construct a orthogonal line by dragging a line";G.Orthogonal.actions[0]["do"]=function(){if(td()){var a=
{type:"Free",name:Xa(),labeled:!0,pos:[ra[0],ra[1],1],tmp:!0},a=Ka(a);Pb=Ka({type:"Perp",name:Xa(),labeled:!0,args:[Aa[0].name,a.name]});zc(a);return!0}return!1};G.Orthogonal.actions[1]={};G.Orthogonal.actions[1].event="mouseup";G.Orthogonal.actions[1]["do"]=function(){yb();return!0};G.Intersection={};G.Intersection.actions=[];G.Intersection.actions[0]={};G.Intersection.actions[0].event="mousedown";G.Intersection.actions[0].tooltip="Select two elements to define their intersection";G.Intersection.actions[0]["do"]=
function(){return ud()};G.Intersection.actions[1]={};G.Intersection.actions[1].event="mousedown";G.Intersection.actions[1]["do"]=function(){return ud()?(Pb=Ka({type:"Meet",name:Xa(),labeled:!0,args:[Aa[0].name,Aa[1].name]}),!0):!1};var eb={},y={drawingstate:{}};y.drawingstate.linecolor="rgb(0,0,255)";y.drawingstate.linecolorraw=[0,0,1];y.drawingstate.pointcolor="rgb(0,255,0)";y.drawingstate.pointcolorraw=[0,1,0];y.drawingstate.textcolor="rgb(0,0,0)";y.drawingstate.textcolorraw=[0,0,0];y.drawingstate.alpha=
1;y.drawingstate.pointsize=4;y.drawingstate.linesize=1;y.drawingstate.textsize=null;y.drawingstate.matrix={};y.drawingstate.matrix.a=25;y.drawingstate.matrix.b=0;y.drawingstate.matrix.c=0;y.drawingstate.matrix.d=25;y.drawingstate.matrix.tx=250.5;y.drawingstate.matrix.ty=250.5;y.drawingstate.matrix.det=y.drawingstate.matrix.a*y.drawingstate.matrix.d-y.drawingstate.matrix.b*y.drawingstate.matrix.c;y.drawingstate.matrix.sdet=Math.sqrt(y.drawingstate.matrix.det);y.drawingstate.initialmatrix={};y.drawingstate.initialmatrix.a=
y.drawingstate.matrix.a;y.drawingstate.initialmatrix.b=y.drawingstate.matrix.b;y.drawingstate.initialmatrix.c=y.drawingstate.matrix.c;y.drawingstate.initialmatrix.d=y.drawingstate.matrix.d;y.drawingstate.initialmatrix.tx=y.drawingstate.matrix.tx;y.drawingstate.initialmatrix.ty=y.drawingstate.matrix.ty;y.drawingstate.initialmatrix.det=y.drawingstate.matrix.det;y.drawingstate.initialmatrix.sdet=y.drawingstate.matrix.sdet;y.clone=function(a){if(null===a||"object"!==typeof a)return a;var b=a.constructor(),
c;for(c in a)b[c]=y.clone(a[c]);return b};eb.backup=y.clone(y.drawingstate);eb.stack=[];y.clone(y.drawingstate);y.reset=function(){y.drawingstate.matrix.a=y.drawingstate.initialmatrix.a;y.drawingstate.matrix.b=y.drawingstate.initialmatrix.b;y.drawingstate.matrix.c=y.drawingstate.initialmatrix.c;y.drawingstate.matrix.d=y.drawingstate.initialmatrix.d;y.drawingstate.matrix.tx=y.drawingstate.initialmatrix.tx;y.drawingstate.matrix.ty=y.drawingstate.initialmatrix.ty;y.drawingstate.matrix.det=y.drawingstate.initialmatrix.det;
y.drawingstate.matrix.sdet=y.drawingstate.initialmatrix.sdet};y.from=function(a,b,c){a/=c;b/=c;c=y.drawingstate.matrix;return[a*c.a-b*c.b+c.tx,a*c.c-b*c.d-c.ty]};y.to=function(a,b){var c=y.drawingstate.matrix,d=a-c.tx,e=b+c.ty;return[(d*c.d-e*c.b)/c.det,-(-d*c.c+e*c.a)/c.det,1]};y.toMat=function(){var a=y.drawingstate.matrix;return h.realMatrix([[a.d,-a.b,-a.tx*a.d-a.ty*a.b],[a.c,-a.a,-a.tx*a.c-a.ty*a.a],[0,0,a.det]])};y.dumpTrafo=function(){function a(a){return Math.round(1E3*a)/1E3}var b=y.drawingstate.matrix;
console.log("a:"+a(b.a)+" b:"+a(b.b)+" c:"+a(b.c)+" d:"+a(b.d)+" tx:"+a(b.ty)+" ty:"+a(b.tx))};y.setMat=function(a,b,c,d,e,h){var f=y.drawingstate.matrix;f.a=a;f.b=b;f.c=c;f.d=d;f.tx=e;f.ty=h;f.det=a*d-b*c;f.sdet=Math.sqrt(f.det)};y.scaleAndOrigin=function(a,b,c){y.setMat(a,0,0,a,b,c)};y.visibleRect=function(a,b,c,d){var e=c-a,h=b-d,e=ca*h<da*e?ca/e:da/h;y.setMat(e,0,0,e,(ca-e*(a+c))/2,(da-e*(b+d))/2)};y.applyMat=function(a,b,c,d,e,h){var f=y.drawingstate.matrix;y.setMat(f.a*a+f.c*b,f.b*a+f.d*b,f.a*
c+f.c*d,f.b*c+f.d*d,f.a*e+f.c*h+f.tx,f.b*e+f.d*h+f.ty)};y.translate=function(a,b){y.applyMat(1,0,0,1,a,b)};y.rotate=function(a){var b=Math.cos(a);a=Math.sin(a);y.applyMat(b,a,-a,b,0,0)};y.scale=function(a){y.applyMat(a,0,0,a,0,0)};y.gsave=function(){eb.stack.push(y.clone(y.drawingstate))};y.grestore=function(){0!==eb.stack.length&&(y.drawingstate=eb.stack.pop())};y.greset=function(){y.drawingstate=y.clone(eb.backup);y.drawingstate.matrix.ty-=da;y.drawingstate.initialmatrix.ty-=da;eb.stack=[]};y.createnewbackup=
function(){y.drawingstate.initialmatrix.a=y.drawingstate.matrix.a;y.drawingstate.initialmatrix.b=y.drawingstate.matrix.b;y.drawingstate.initialmatrix.c=y.drawingstate.matrix.c;y.drawingstate.initialmatrix.d=y.drawingstate.matrix.d;y.drawingstate.initialmatrix.tx=y.drawingstate.matrix.tx;y.drawingstate.initialmatrix.ty=y.drawingstate.matrix.ty;y.drawingstate.initialmatrix.det=y.drawingstate.matrix.det;y.drawingstate.initialmatrix.sdet=y.drawingstate.matrix.sdet;eb.backup=y.clone(y.drawingstate)};y.makecolor=
function(a,b,c){a=Math.floor(255*a);b=Math.floor(255*b);c=Math.floor(255*c);return 1===y.drawingstate.alpha?"rgb("+a+","+b+","+c+")":"rgba("+a+","+b+","+c+","+y.drawingstate.alpha+")"};y.setcolor=function(a){var b=a.value[0].value.real,c=a.value[1].value.real;a=a.value[2].value.real;y.drawingstate.linecolor=y.drawingstate.pointcolor=y.makecolor(b,c,a);y.drawingstate.linecolorraw=y.drawingstate.pointcolorraw=[b,c,a]};y.setlinecolor=function(a){var b=a.value[0].value.real,c=a.value[1].value.real;a=
a.value[2].value.real;y.drawingstate.linecolor=y.makecolor(b,c,a);y.drawingstate.linecolorraw=[b,c,a]};y.settextcolor=function(a){var b=a.value[0].value.real,c=a.value[1].value.real;a=a.value[2].value.real;y.drawingstate.textcolor=y.makecolor(b,c,a);y.drawingstate.textcolorraw=[b,c,a]};y.setpointcolor=function(a){var b=a.value[0].value.real,c=a.value[1].value.real;a=a.value[2].value.real;y.drawingstate.pointcolor=y.makecolor(b,c,a);y.drawingstate.pointcolorraw=[b,c,a]};y.setalpha=function(a){y.drawingstate.alpha=
a.value.real;y.drawingstate.linecolor=y.makecolor(y.drawingstate.linecolorraw[0],y.drawingstate.linecolorraw[1],y.drawingstate.linecolorraw[2]);y.drawingstate.pointcolor=y.makecolor(y.drawingstate.pointcolorraw[0],y.drawingstate.pointcolorraw[1],y.drawingstate.pointcolorraw[2]);y.drawingstate.textcolor=y.makecolor(y.drawingstate.textcolorraw[0],y.drawingstate.textcolorraw[1],y.drawingstate.textcolorraw[2])};y.setpointsize=function(a){y.drawingstate.pointsize=a.value.real};y.setlinesize=function(a){y.drawingstate.linesize=
a.value.real};y.settextsize=function(a){y.drawingstate.textsize=a.value.real};var ga={clip:"none",pointColor:[1,0,0],lineColor:[0,0,1],pointSize:5,lineSize:1,alpha:1,overhangLine:1,overhangSeg:1,dimDependent:.7,fontFamily:"sans-serif",textColor:[0,0,0],textsize:20,noborder:!1,lineHeight:1.45};p.defaultAppearance&&he(p.defaultAppearance);var dc={},Cd={UL:0,UR:1,LR:2,LL:3},Cc=["in","out","good","backup"],nb=new Float64Array(0),ib={};Cc.forEach(function(a){ib[a]=nb});var qa=nb,Oa=nb,Da=nb,Ba,Ea,lb,Ma,
Ab,Dc=!1,Ed={toString:function(){return"RefineException"}},Hd=null,L=null;p.enableTraceLog&&(L={logLength:Infinity,fullLog:[],currentMouseAndScripts:null,currentMover:null,currentStep:null,currentElement:null,currentParam:null,labelTracing2:w.wrap("tracing2"),labelTracing4:w.wrap("tracing4"),labelTracingSesq:w.wrap("tracingSesq"),postMouseHooks:[]},"number"===typeof p.enableTraceLog&&(L.logLength=p.enableTraceLog),sa.getTraceLog=ne,sa.formatTraceLog=oe,sa.addTraceHook=L.postMouseHooks.push.bind(L.postMouseHooks));
Pa.stateSize=12;Fc.stateSize=24;Qb.stateSize=24;var ob=[];mb.P=function(a){v.lines.forEach(function(b){b=Kd(a,b);b.holds()&&ob.push(b)});v.conics.forEach(function(b){b=Ld(a,b);b.holds()&&ob.push(b)})};mb.L=function(a){v.points.forEach(function(b){b=Kd(b,a);b.holds()&&ob.push(b)})};mb.S=mb.L;mb.C=function(a){v.points.forEach(function(b){b=Ld(b,a);b.holds()&&ob.push(b)})};var l={_helper:{},RandomLine:{}};l.RandomLine.kind="L";l.RandomLine.signature=[];l.RandomLine.updatePosition=function(a){a.homog=
h.realVector([Math.random()-.5,Math.random()-.5,Math.random()-.5]);a.homog=h.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Line")};l.FreeLine={};l.FreeLine.kind="L";l.FreeLine.signature=[];l.FreeLine.isMovable=!0;l.FreeLine.initialize=function(a){a=l._helper.initializeLine(a);T(a)};l.FreeLine.getParamForInput=function(a,b,c){"mouse"===c?(a=h.cross(b,h.ez),a=h.cross(a,b)):a="homog"===c?b:h.turnIntoCSList([m.zero,m.zero,m.zero]);return h.normalizeMax(a)};l.FreeLine.getParamFromState=function(a){return X(3)};
l.FreeLine.putParamToState=function(a,b){T(b)};l.FreeLine.updatePosition=function(a){var b=X(3);T(b);a.homog=w.withUsage(b,"Line")};l.FreeLine.stateSize=6;l.RandomPoint={};l.RandomPoint.kind="P";l.RandomPoint.signature=[];l.RandomPoint.updatePosition=function(a){a.homog=h.realVector([100*Math.random(),100*Math.random(),100*Math.random()]);a.homog=h.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Point")};l.Join={};l.Join.kind="L";l.Join.signature=["P","P"];l.Join.updatePosition=function(a){a.homog=
h.cross(v.csnames[a.args[0]].homog,v.csnames[a.args[1]].homog);a.homog=h.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Line")};l.Segment={};l.Segment.kind="S";l.Segment.signature=["P","P"];l.Segment.updatePosition=function(a){var b=v.csnames[a.args[0]],c=v.csnames[a.args[1]];l.Segment.setSegmentPos(a,h.cross(b.homog,c.homog),h.scalmult(c.homog.value[2],b.homog),h.scalmult(b.homog.value[2],c.homog))};l.Segment.setSegmentPos=function(a,b,c,d){b=h.normalizeMax(b);a.homog=w.withUsage(b,"Line");b=
h.turnIntoCSList([c,d]);b=h.normalizeMax(b);a.startpos=b.value[0];a.endpos=b.value[1]};l.Meet={};l.Meet.kind="P";l.Meet.signature=["L","L"];l.Meet.updatePosition=function(a){a.homog=h.cross(v.csnames[a.args[0]].homog,v.csnames[a.args[1]].homog);a.homog=h.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Point")};l.Meet.visiblecheck=function(a){var b=!0,c=v.csnames[a.args[0]],d=v.csnames[a.args[1]];"S"===c.kind&&(b=Ad(a,c));b&&"S"===d.kind&&(b=Ad(a,d));a.isshowing=b};l._helper.midpoint=function(a,
b){return h.normalizeMax(h.add(h.scalmult(b.value[2],a),h.scalmult(a.value[2],b)))};l.Mid={};l.Mid.kind="P";l.Mid.signature=["P","P"];l.Mid.updatePosition=function(a){var b=l._helper.midpoint(v.csnames[a.args[0]].homog,v.csnames[a.args[1]].homog);a.homog=w.withUsage(b,"Point")};l.Perp={};l.Perp.kind="L";l.Perp.signature=["L","P"];l.Perp.updatePosition=function(a){var b=v.csnames[a.args[0]].homog,c=v.csnames[a.args[1]].homog,b=h.turnIntoCSList([b.value[0],b.value[1],m.zero]);a.homog=h.cross(b,c);a.homog=
h.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Line")};l.Para={};l.Para.kind="L";l.Para.signature=["L","P"];l.Para.updatePosition=function(a){var b=v.csnames[a.args[1]].homog;a.homog=h.cross(h.cross(h.linfty,v.csnames[a.args[0]].homog),b);a.homog=h.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Line")};l.Horizontal={};l.Horizontal.kind="L";l.Horizontal.signature=["P"];l.Horizontal.updatePosition=function(a){a.homog=h.cross(h.ex,v.csnames[a.args[0]].homog);a.homog=h.normalizeMax(a.homog);
a.homog=w.withUsage(a.homog,"Line")};l.HorizontalLine={};l.HorizontalLine.kind="L";l.HorizontalLine.signature=[];l.HorizontalLine.isMovable=!0;l.HorizontalLine.initialize=function(a){a=l._helper.initializeLine(a);a=h.turnIntoCSList([m.zero,a.value[1],a.value[2]]);a=h.normalizeMax(a);T(a)};l.HorizontalLine.getParamForInput=function(a,b,c){if("mouse"===c)b=h.cross(b,h.ex);else if("homog"===c){if(0!==b.value[0].real||0!==b.value[0].imag)b=h.turnIntoCSList([m.zero,b.value[1],b.value[2]])}else b=h.turnIntoCSList([m.zero,
m.zero,m.zero]);return h.normalizeMax(b)};l.HorizontalLine.getParamFromState=function(a){return X(3)};l.HorizontalLine.putParamToState=function(a,b){T(b)};l.HorizontalLine.updatePosition=function(a){var b=X(3);T(b);a.homog=w.withUsage(b,"Line")};l.HorizontalLine.stateSize=6;l.Vertical={};l.Vertical.kind="L";l.Vertical.signature=["P"];l.Vertical.updatePosition=function(a){a.homog=h.cross(h.ey,v.csnames[a.args[0]].homog);a.homog=h.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Line")};l.VerticalLine=
{};l.VerticalLine.kind="L";l.VerticalLine.signature=[];l.VerticalLine.isMovable=!0;l.VerticalLine.initialize=function(a){a=l._helper.initializeLine(a);a=h.turnIntoCSList([a.value[0],m.zero,a.value[2]]);a=h.normalizeMax(a);T(a)};l.VerticalLine.getParamForInput=function(a,b,c){if("mouse"===c)b=h.cross(b,h.ey);else if("homog"===c){if(0!==b.value[1].real||0!==b.value[1].imag)b=h.turnIntoCSList([b.value[0],m.zero,b.value[2]])}else b=h.turnIntoCSList([m.zero,m.zero,m.zero]);return h.normalizeMax(b)};l.VerticalLine.getParamFromState=
function(a){return X(3)};l.VerticalLine.putParamToState=function(a,b){T(b)};l.VerticalLine.updatePosition=function(a){var b=X(3);T(b);a.homog=w.withUsage(b,"Line")};l.VerticalLine.stateSize=6;l.LineByFixedAngle={};l.LineByFixedAngle.kind="L";l.LineByFixedAngle.signature=["L","P"];l.LineByFixedAngle.initialize=function(a){var b=m._helper.input(a.angle),c=m.cos(b),b=m.sin(b);a.rot=h.turnIntoCSList([h.turnIntoCSList([b,c,m.zero]),h.turnIntoCSList([m.neg(c),b,m.zero]),h.turnIntoCSList([m.zero,m.zero,
m.zero])])};l.LineByFixedAngle.updatePosition=function(a){var b=v.csnames[a.args[1]],c=h.productMV(a.rot,v.csnames[a.args[0]].homog);a.homog=h.cross(b.homog,c);a.homog=h.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Line")};l.Through={};l.Through.kind="L";l.Through.signature=["P"];l.Through.isMovable=!0;l.Through.initialize=function(a){a=a.dir?w.wrap(a.dir):h.realVector([a.pos[1],-a.pos[0],0]);T(a)};l.Through.getParamForInput=function(a,b,c){a="dir"===c||"mouse"===c?h.cross(v.csnames[a.args[0]].homog,
b):"homog"===c?b:h.turnIntoCSList([m.zero,m.zero,m.zero]);a=h.cross(h.linfty,a);return h.normalizeMax(a)};l.Through.getParamFromState=function(a){return X(3)};l.Through.putParamToState=function(a,b){T(b)};l.Through.updatePosition=function(a){var b=X(3);T(b);b=h.cross(v.csnames[a.args[0]].homog,b);b=h.normalizeMax(b);a.homog=w.withUsage(b,"Line")};l.Through.stateSize=6;l.Through.set_angle=function(a,b){if("number"===b.ctype){var c=m.cos(b),d=m.sin(b),c=h.turnIntoCSList([c,d,m.real(0)]);La(a,c,"dir")}};
l.Through.set_slope=function(a,b){if("number"===b.ctype){var c=h.turnIntoCSList([m.real(1),b,m.real(0)]);La(a,c,"dir")}};l.Free={};l.Free.kind="P";l.Free.signature=[];l.Free.isMovable=!0;l.Free.initialize=function(a){a=l._helper.initializePoint(a);T(a)};l.Free.getParamForInput=function(a,b,c){if("mouse"===c&&Eb&&0!==za){b=h.normalizeZ(b);a=b.value[0].value.real;c=b.value[1].value.real;var d=Math.round(a/za)*za,e=Math.round(c/za)*za;.2>Math.abs(d-a)&&.2>Math.abs(e-c)&&(b=h.realVector([d,e,1]))}return h.normalizeMax(b)};
l.Free.getParamFromState=function(a){return X(3)};l.Free.putParamToState=function(a,b){T(b)};l.Free.updatePosition=function(a){var b=X(3);T(b);a.homog=w.withUsage(b,"Point")};l.Free.stateSize=6;l._helper.projectPointToLine=function(a,b){var c=h.turnIntoCSList([b.value[0],b.value[1],m.zero]),c=h.cross(c,a);return h.normalizeMax(h.cross(c,b))};l.PointOnLine={};l.PointOnLine.kind="P";l.PointOnLine.signature=["L"];l.PointOnLine.isMovable=!0;l.PointOnLine.initialize=function(a){var b=l._helper.initializePoint(a);
a=v.csnames[a.args[0]].homog;var b=l._helper.projectPointToLine(b,a),b=h.normalizeMax(b),c=h.cross(h.linfty,b);h.normalizeMax(c);T(b);T(a);lb=!1};l.PointOnLine.updatePosition=function(a,b){var c,d=v.csnames[a.args[0]].homog;c=X(3);X(3);if(!b){Ba=a.stateIdx;var e=qa;qa=Da;var f=X(3),m=X(3);qa=e;e=h.cross(m,d);h._helper.isAlmostZero(e)&&(e=h.cross(h.linfty,d));f=l._helper.CircleMP(e,f);f=l._helper.IntersectLC(d,f);e=l._helper.pointReflection(e,c);c=Ec(f[0],f[1],c,e)[0]}c=h.normalizeMax(c);T(c);T(d);
a.homog=w.withUsage(c,"Point")};l.PointOnLine.getParamForInput=function(a,b,c){a=v.csnames[a.args[0]].homog;b=l._helper.projectPointToLine(b,a);"mouse"===c&&Eb&&0!==za&&(b=l._helper.snapPointToLine(b,a));return b};l.PointOnLine.getParamFromState=function(a){return X(3)};l.PointOnLine.putParamToState=function(a,b){return T(b)};l.PointOnLine.stateSize=12;l.PointOnCircle={};l.PointOnCircle.kind="P";l.PointOnCircle.signature=["C"];l.PointOnCircle.isMovable=!0;l.PointOnCircle.initialize=function(a){var b=
v.csnames[a.args[0]];a=h.normalizeZ(l._helper.initializePoint(a));var c=h.normalizeZ(l._helper.CenterOfCircle(b.matrix)),d=h.sub(a,c),d=h.turnIntoCSList([d.value[1],m.neg(d.value[0]),m.zero]),c=h.cross(a,c),b=l._helper.IntersectLC(c,b.matrix),c=h.projectiveDistMinScal(a,b[0]);h.projectiveDistMinScal(a,b[1])<c?(a=b[1],b=b[0]):(a=b[0],b=b[1]);T(d);T(a);T(b);lb=!1};l.PointOnCircle.putParamToState=function(a,b){T(b)};l.PointOnCircle.getParamFromState=function(a){return X(3)};l.PointOnCircle.getParamForInput=
function(a,b,c){c=h.normalizeZ(l._helper.CenterOfCircle(v.csnames[a.args[0]].matrix));b=h.sub(b,c);Ba=a.stateIdx;a=X(3);var d=h.normalizeZ(X(3));c=h.sub(d,c);0>m.sub(m.mult(a.value[0],c.value[1]),m.mult(a.value[1],c.value[0])).value.real&&(b=h.neg(b));return h.turnIntoCSList([b.value[1],m.neg(b.value[0]),m.zero])};l.PointOnCircle.parameterPath=function(a,b,c,d,e){d=h.normalizeAbs(d);e=h.normalizeAbs(e);var f=h.scalproduct(d,e);if(0<=f.value.real)return Fd(a,b,c,d,e);a=h.turnIntoCSList([m.sub(d.value[1],
e.value[1]),m.sub(e.value[0],d.value[0]),m.zero]);f=h.scalproduct(d,a);0>f.value.real&&(a=h.neg(a));0>b?(b=2*b+1,c=b*b,f=.25/(1+c),c=m.complex(2*b*f+.25,(1-c)*f)):(b=2*b-1,c=b*b,f=.25/(1+c),c=m.complex(2*b*f+.75,(1-c)*f));var k=m.sub(m.real(1),c);b=m.mult(c,c);f=m.mult(k,k);c=m.mult(c,k);d=h.scalmult(f,d);d=h.add(d,h.scalmult(c,a));return d=h.add(d,h.scalmult(b,e))};l.PointOnCircle.updatePosition=function(a){var b=X(3);T(b);var c=v.csnames[a.args[0]],b=h.productMV(c.matrix,b),c=l._helper.IntersectLC(b,
c.matrix),c=Pa(c[0],c[1]),b=h.normalizeMax(c.value[0]);a.homog=w.withUsage(b,"Point");a.antipodalPoint=c.value[1]};l.PointOnCircle.stateSize=6+Pa.stateSize;l.OtherPointOnCircle={};l.OtherPointOnCircle.kind="P";l.OtherPointOnCircle.signature=["P"];l.OtherPointOnCircle.signatureConstraints=function(a){return"PointOnCircle"===v.csnames[a.args[0]].type};l.OtherPointOnCircle.updatePosition=function(a){var b=v.csnames[a.args[0]].antipodalPoint,b=h.normalizeMax(b);a.homog=w.withUsage(b,"Point")};l.PointOnSegment=
{};l.PointOnSegment.kind="P";l.PointOnSegment.signature=["S"];l.PointOnSegment.isMovable=!0;l.PointOnSegment.initialize=function(a){var b=l._helper.initializePoint(a);a=l.PointOnSegment.getParamForInput(a,b);Za(a)};l.PointOnSegment.getParamForInput=function(a,b,c){a=v.csnames[a.args[0]];var d=a.homog;"mouse"===c&&Eb&&0!==za&&(b=l._helper.snapPointToLine(b,d));c=h.turnIntoCSList([d.value[0],d.value[1],m.zero]);d=h.sub(a.startpos,a.endpos);b=h.crossratio3(d,a.startpos,a.endpos,b,c);0>b.value.real&&
(b=m.complex(0,b.value.imag));1<b.value.real&&(b=m.complex(1,b.value.imag));return b};l.PointOnSegment.getParamFromState=function(a){return Bb()};l.PointOnSegment.putParamToState=function(a,b){Za(b)};l.PointOnSegment.updatePosition=function(a){var b=Bb();Za(b);var c=v.csnames[a.args[0]],d=c.startpos,c=h.sub(c.endpos,d),b=h.add(d,h.scalmult(b,c)),b=h.normalizeMax(b);a.homog=w.withUsage(b,"Point")};l.PointOnSegment.stateSize=2;l._helper.projectPointToCircle=function(a,b){var c=l._helper.CenterOfCircle(a.matrix),
c=h.normalizeMax(c),c=h.normalizeMax(h.cross(b,c)),c=l._helper.IntersectLC(c,a.matrix),d=h.projectiveDistMinScal(b,c[0]),e=h.projectiveDistMinScal(b,c[1]);return d<e?c[0]:c[1]};l.PointOnArc={};l.PointOnArc.kind="P";l.PointOnArc.signature=["C"];l.PointOnArc.signatureConstraints=function(a){return v.csnames[a.args[0]].isArc};l.PointOnArc.isMovable=!0;l.PointOnArc.initialize=function(a){var b=l._helper.initializePoint(a);a=l.PointOnArc.getParamForInput(a,b);T(a)};l.PointOnArc.getParamForInput=function(a,
b){var c=v.csnames[a.args[0]],d=l._helper.projectPointToCircle(c,b),c=h.normalizeMax(h.crossratio3harm(c.startPoint,c.endPoint,c.viaPoint,d,h.ii)),d=m.div(c.value[0],c.value[1]);0>d.value.real&&(c=-1>d.value.real?h.realVector([1,0]):h.realVector([0,1]));return c};l.PointOnArc.getParamFromState=function(a){return X(2)};l.PointOnArc.putParamToState=function(a,b){T(b)};l.PointOnArc.updatePosition=function(a){var b=v.csnames[a.args[0]],c=b.startPoint,d=b.viaPoint,e=b.endPoint,f=h.ii,k=h.cross(c,f),d=
h.cross(d,f),n=h.cross(e,f),n=h.turnIntoCSList([k,n]),k=h.transpose(n),n=h.conjugate(n),k=h.productMM(n,k),d=h.productMV(n,d),k=h.productMV(h.adjoint2(k),d),d=k.value[0],k=k.value[1],n=X(2);T(n);c=h.normalizeMax(h.add(h.scalmult(m.mult(d,n.value[0]),c),h.scalmult(m.mult(k,n.value[1]),e)));b=l._helper.conicOtherIntersection(b.matrix,f,c);a.homog=w.withUsage(b,"Point")};l.PointOnArc.stateSize=4;l._helper.CenterOfCircle=function(a){return h.turnIntoCSList([a.value[2].value[0],a.value[2].value[1],m.neg(a.value[0].value[0])])};
l._helper.CenterOfConic=function(a){a=h.adjoint3(a);return{ctype:"list",value:[a.value[2].value[0],a.value[2].value[1],a.value[2].value[2]]}};l.CenterOfConic={};l.CenterOfConic.kind="P";l.CenterOfConic.signature=["C"];l.CenterOfConic.updatePosition=function(a){var b=l._helper.CenterOfConic(v.csnames[a.args[0]].matrix);a.homog=b;a.homog=h.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Point")};l._helper.CircleMP=function(a,b){var c=a.value[0],d=a.value[1],e=m.neg(a.value[2]),f=m.zero,c=h.turnIntoCSList([h.turnIntoCSList([e,
f,c]),h.turnIntoCSList([f,e,d]),h.turnIntoCSList([c,d,f])]),e=w.mult(w.mult(b,c),b),d=w.mult(w.mult(b,h.fund),b),e=w.mult(e,h.fund),c=w.mult(d,c);return h.sub(e,c)};l.CircleMP={};l.CircleMP.kind="C";l.CircleMP.signature=["P","P"];l.CircleMP.updatePosition=function(a){a.matrix=l._helper.CircleMP(v.csnames[a.args[0]].homog,v.csnames[a.args[1]].homog);a.matrix=h.normalizeMax(a.matrix);a.matrix=w.withUsage(a.matrix,"Circle")};l.CircleMr={};l.CircleMr.kind="C";l.CircleMr.signature=["P"];l.CircleMr.isMovable=
!0;l.CircleMr.initialize=function(a){Za(m.real(a.radius))};l.CircleMr.getParamForInput=function(a,b,c){if("radius"===c)return b;a=v.csnames[a.args[0]].homog;a=h.normalizeZ(a);b=h.normalizeZ(b);b=h.sub(a,b);return b=h.abs(b)};l.CircleMr.getParamFromState=function(a){return Bb()};l.CircleMr.putParamToState=function(a,b){Za(b)};l.CircleMr.updatePosition=function(a){var b=Bb();Za(b);var c=v.csnames[a.args[0]].homog,d=m.mult(c.value[2],b),d=m.mult(d,d);if(!m._helper.isFinite(d)&&!m._helper.isNaN(d))return h.fund;
c=l._helper.ScaledCircleMrr(c,d);a.matrix=w.withUsage(c,"Circle");a.radius=b};l.CircleMr.stateSize=2;l.CircleMr.set_radius=function(a,b){"number"===b.ctype&&La(a,b,"radius")};l._helper.ScaledCircleMrr=function(a,b){var c=a.value[0],d=a.value[1],e=m.neg(a.value[2]),e=h.scalmult(e,h.turnIntoCSList([c,d,e])).value,c=h.turnIntoCSList([c,d]),c=m.sub(h.scalproduct(c,c),b),e=l._helper.buildConicMatrix([e[2],m.zero,e[2],e[0],e[1],c]);return h.normalizeMax(e)};l.Compass={};l.Compass.kind="C";l.Compass.signature=
["P","P","P"];l.Compass.updatePosition=function(a){var b=v.csnames[a.args[0]].homog,c=v.csnames[a.args[1]].homog,d=v.csnames[a.args[2]].homog,e=b.value[2],f=c.value[2],k=d.value[2],b=h.scalmult(m.mult(f,k),b),c=h.scalmult(m.mult(e,k),c),d=h.scalmult(m.mult(e,f),d),b=h.sub(c,b),d=l._helper.ScaledCircleMrr(d,h.scalproduct(b,b));a.matrix=w.withUsage(d,"Circle")};l._helper.getConicType=function(a){if(1E-16>m.abs(h.det(a)).value.real)return"degenerate";var b=m.mult(a.value[0].value[0],a.value[1].value[1]),
b=m.sub(b,m.pow(a.value[0].value[1],m.real(2))),b=b.value.real;return 1E-16>Math.abs(b)?"parabola":1E-16<b?"ellipsoid":"hyperbola"};l._helper.ConicBy5=function(a,b,c,d,e,f){a=h.turnIntoCSList([h.cross(c,d)]);var m=h.turnIntoCSList([h.cross(b,e)]);b=h.turnIntoCSList([h.cross(b,c)]);d=h.turnIntoCSList([h.cross(d,e)]);return l._helper.conicFromTwoDegenerates(a,m,b,d,f)};l._helper.conicFromTwoDegenerates=function(a,b,c,d,e){a=w.mult(h.transpose(b),a);c=w.mult(h.transpose(d),c);a=h.add(a,h.transpose(a));
c=h.add(c,h.transpose(c));d=w.mult(w.mult(e,a),e);e=w.mult(w.mult(e,c),e);c=w.mult(d,c);e=w.mult(e,a);return h.sub(c,e)};l.ConicBy5={};l.ConicBy5.kind="C";l.ConicBy5.signature=["P","P","P","P","P"];l.ConicBy5.updatePosition=function(a){var b=l._helper.ConicBy5(a,v.csnames[a.args[0]].homog,v.csnames[a.args[1]].homog,v.csnames[a.args[2]].homog,v.csnames[a.args[3]].homog,v.csnames[a.args[4]].homog);a.matrix=b;a.matrix=h.normalizeMax(a.matrix);a.matrix=w.withUsage(a.matrix,"Conic")};l.FreeConic={};l.FreeConic.kind=
"C";l.FreeConic.signature=[];l.FreeConic.initialize=function(a){var b;b=a.pos?l._helper.inputConic(a.pos):h.zeromatrix(m.real(3),m.real(3));l.FreeConic.putParamToState(a,b)};l.FreeConic.getParamForInput=function(a,b,c){return h.normalizeMax(b)};l.FreeConic.getParamFromState=function(a){return l._helper.buildConicMatrix(X(6).value)};l.FreeConic.putParamToState=function(a,b){for(var c=0;3>c;++c)for(var d=0;d<=c;++d)Za(b.value[c].value[d])};l.FreeConic.updatePosition=function(a){var b=X(6);T(b);a.matrix=
l._helper.buildConicMatrix(b.value);a.matrix=h.normalizeMax(a.matrix);a.matrix=w.withUsage(a.matrix,"Conic")};l.FreeConic.set_matrix=function(a,b){h._helper.isNumberMatrixMN(b,3,3)&&La(a,h.add(b,h.transpose(b)),"matrix")};l.FreeConic.stateSize=12;l._helper.buildConicMatrix=function(a){var b=a[1],c=a[2],d=a[3],e=a[4],f=a[5];return h.turnIntoCSList([h.turnIntoCSList([a[0],b,d]),h.turnIntoCSList([b,c,e]),h.turnIntoCSList([d,e,f])])};l._helper.flattenConicMatrix=function(a){return h.turnIntoCSList([a.value[0].value[0],
a.value[0].value[1],a.value[1].value[1],a.value[0].value[2],a.value[1].value[2],a.value[2].value[2]])};l._helper.splitDegenConic=function(a){var b=h.adjoint3(a),c=0,d,e,f=m.abs2(b.value[0].value[0]).value.real;for(d=1;3>d;d++)e=m.abs2(b.value[d].value[d]).value.real,e>f&&(c=d,f=e);d=m.sqrt(m.mult(m.real(-1),b.value[c].value[c]));if(1E-16>m.abs2(d).value.real)return a=h.turnIntoCSList([m.zero,m.zero,m.zero]),[a,a];c=m.real(c+1);e=h.column(b,c);e=h.scaldiv(d,e);d=e.value[0];f=e.value[1];e=e.value[2];
d=h.turnIntoCSList([h.turnIntoCSList([m.real(0),e,m.mult(m.real(-1),f)]),h.turnIntoCSList([m.mult(m.real(-1),e),m.real(0),d]),h.turnIntoCSList([f,m.mult(m.real(-1),d),m.real(0)])]);a=h.add(a,d);var k=0;for(d=f=b=0;3>d;d++)for(c=0;3>c;c++)e=m.abs2(a.value[d].value[c]).value.real,e>f&&(k=d,b=c,f=e);d=a.value[k];a=h.transpose(a);a=a.value[b];d=h.normalizeMax(d);a=h.normalizeMax(a);d=w.withUsage(d,"Line");a=w.withUsage(a,"Line");return[d,a]};l._helper.inputConic=function(a){var b="xx xy yy xz yz zz".split(" ").map(function(b){var d=
m._helper.input(a[b]);b[0]!==b[1]&&(d=m.realmult(.5,d));return d});return l._helper.buildConicMatrix(b)};l.SelectConic={};l.SelectConic.kind="C";l.SelectConic.signature=["Cs"];l.SelectConic.initialize=function(a){if(void 0!==a.index)return a.index-1;var b=l._helper.inputConic(a.pos);a=v.csnames[a.args[0]].results;for(var c=h.conicDist(b,a[0]),d=0,e=1;e<a.length;++e){var f=h.conicDist(b,a[e]);f<c&&(c=f,d=e)}return d};l.SelectConic.updatePosition=function(a){a.matrix=v.csnames[a.args[0]].results[a.param];
a.matrix=h.normalizeMax(a.matrix);a.matrix=w.withUsage(a.matrix,"Conic")};l._helper.ConicBy4p1l=function(a,b,c,d,e,f){var k=h.scalproduct(b,f),n=h.scalproduct(c,f),p=h.scalproduct(d,f),r=h.scalproduct(e,f),t=h.det3(c,d,e),v=h.det3(b,c,e),u=h.det3(b,d,e),w=h.det3(b,c,d),x=m.mult,n=m.sqrt(x(x(n,r),x(t,v))),k=m.sqrt(x(x(k,p),x(u,w))),p=h.cross(h.cross(b,d),f);f=h.cross(h.cross(c,e),f);p=h.scalmult(n,p);k=h.scalmult(k,f);f=h.normalizeMax(h.add(p,k));k=h.normalizeMax(h.sub(p,k));k=Pa(f,k);f=l._helper.ConicBy5(a,
b,c,d,e,k.value[0]);a=l._helper.ConicBy5(a,b,c,d,e,k.value[1]);return[h.normalizeMax(f),h.normalizeMax(a)]};l.ConicBy4p1l={};l.ConicBy4p1l.kind="Cs";l.ConicBy4p1l.signature=["P","P","P","P","L"];l.ConicBy4p1l.updatePosition=function(a){var b=l._helper.ConicBy4p1l(a,v.csnames[a.args[0]].homog,v.csnames[a.args[1]].homog,v.csnames[a.args[2]].homog,v.csnames[a.args[3]].homog,v.csnames[a.args[4]].homog);a.results=b};l.ConicBy4p1l.stateSize=Pa.stateSize;l._helper.ConicBy3p2l=function(a,b,c,d,e){function f(a,
b,c,d){return m.sub(m.mult(a,d),m.mult(b,c))}var k=h.cross(a,b),l=h.cross(d,e);d=h.cross(d,k);e=h.cross(e,k);k=h.turnIntoCSList([d,e,l]);c=h.productVM(c,h.adjoint3(k));l=h.adjoint3(h.turnIntoCSList([h.scalmult(c.value[0],d),h.scalmult(c.value[1],e),h.scalmult(c.value[2],l)]));c=h.transpose(l);d=m.mult;e=h.productMV(c,a);a=e.value[0];e=e.value[1];k=h.productMV(c,b);b=k.value[0];var k=k.value[1],n=m.sqrt(d(a,e)),p=m.sqrt(d(b,k)),r,t=Array(4);for(r=0;4>r;++r){var v=(r&2)-1,u=d(m.real(((r&1)<<1)-1),n),
w=d(m.real(v),p),x=f(e,u,k,w),y=f(b,w,a,u),v=f(a,e,b,k),z=m.add(m.add(f(b,k,a,e),f(k,w,e,u)),f(w,b,u,a)),u=d(x,x),w=d(y,y),A=d(z,z),B=d(x,y),x=d(x,z),y=d(y,z),B=m.sub(B,d(m.real(.5),d(v,v))),v=h.turnIntoCSList([h.turnIntoCSList([u,B,x]),h.turnIntoCSList([B,w,y]),h.turnIntoCSList([x,y,A])]),v=h.productMM(l,h.productMM(v,c)),v=h.turnIntoCSList([v.value[0].value[0],v.value[0].value[1],v.value[0].value[2],v.value[1].value[1],v.value[1].value[2],v.value[2].value[2]]);t[r]=v}return t};l.ConicBy3p2l={};
l.ConicBy3p2l.kind="Cs";l.ConicBy3p2l.signature=["P","P","P","L","L"];l.ConicBy3p2l.updatePosition=function(a){for(var b=l._helper.ConicBy3p2l(v.csnames[a.args[0]].homog,v.csnames[a.args[1]].homog,v.csnames[a.args[2]].homog,v.csnames[a.args[3]].homog,v.csnames[a.args[4]].homog),b=Id(b),c=Array(4),d=0;4>d;++d){var e=b[d].value;c[d]=h.turnIntoCSList([h.turnIntoCSList([e[0],e[1],e[2]]),h.turnIntoCSList([e[1],e[3],e[4]]),h.turnIntoCSList([e[2],e[4],e[5]])])}a.results=c};l.ConicBy3p2l.stateSize=48;l.ConicBy2p3l=
{};l.ConicBy2p3l.kind="Cs";l.ConicBy2p3l.signature=["P","P","L","L","L"];l.ConicBy2p3l.updatePosition=function(a){for(var b=l._helper.ConicBy3p2l(v.csnames[a.args[2]].homog,v.csnames[a.args[3]].homog,v.csnames[a.args[4]].homog,v.csnames[a.args[0]].homog,v.csnames[a.args[1]].homog),b=Id(b),c=Array(4),d=0;4>d;++d){var e=b[d].value,e=h.turnIntoCSList([h.turnIntoCSList([e[0],e[1],e[2]]),h.turnIntoCSList([e[1],e[3],e[4]]),h.turnIntoCSList([e[2],e[4],e[5]])]);c[d]=h.normalizeMax(h.adjoint3(e))}a.results=
c};l.ConicBy2p3l.stateSize=48;l.ConicBy1p4l={};l.ConicBy1p4l.kind="Cs";l.ConicBy1p4l.signature=["P","L","L","L","L"];l.ConicBy1p4l.updatePosition=function(a){var b=l._helper.ConicBy4p1l(a,v.csnames[a.args[1]].homog,v.csnames[a.args[2]].homog,v.csnames[a.args[3]].homog,v.csnames[a.args[4]].homog,v.csnames[a.args[0]].homog),c=b[0],b=b[1],c=h.adjoint3(c),b=h.adjoint3(b),b=[c,b];a.results=b};l.ConicBy1p4l.stateSize=Pa.stateSize;l.ConicParabolaPL={};l.ConicParabolaPL.kind="C";l.ConicParabolaPL.signature=
["P","L"];l.ConicParabolaPL.updatePosition=function(a){var b=v.csnames[a.args[0]].homog.value,c=v.csnames[a.args[1]].homog.value,d=m.mult,e=m.neg,f=m.add,k=m.sub,n=b[0],p=b[1],r=b[2],t=c[0],b=c[1],c=c[2],u=d(r,r),x=d(t,t),y=d(b,b),z=d(r,c),A=e(r),r=f(x,y),y=d(u,y),x=d(u,x),e=d(e(u),d(t,b)),t=d(A,f(d(n,r),d(z,t))),b=d(A,f(d(p,r),d(z,b))),d=k(d(f(d(n,n),d(p,p)),r),d(u,d(c,c))),d=l._helper.buildConicMatrix([y,e,x,t,b,d]),d=h.normalizeMax(d);a.matrix=w.withUsage(d,"Conic")};l.ConicBy2Foci1P={};l.ConicBy2Foci1P.kind=
"Cs";l.ConicBy2Foci1P.signature=["P","P","P"];l.ConicBy2Foci1P.updatePosition=function(a){var b=v.csnames[a.args[0]].homog,c=v.csnames[a.args[1]].homog,d=v.csnames[a.args[2]].homog,e=h.ii,f=h.jj,k=h.normalizeMax(h.cross(b,d)),n=h.normalizeMax(h.cross(c,d)),p=h.normalizeMax(h.cross(d,e)),d=h.normalizeMax(h.cross(d,f)),n=l._helper.coHarmonic(p,d,k,n),k=h.normalizeMax(n[0]),n=h.normalizeMax(n[1]),e=h.turnIntoCSList([e]),p=h.turnIntoCSList([f]),d=h.turnIntoCSList([b]),r=h.turnIntoCSList([c]),f=l._helper.conicFromTwoDegenerates(e,
p,d,r,k),f=h.normalizeMax(f),e=l._helper.conicFromTwoDegenerates(e,p,d,r,n),e=h.normalizeMax(e),f=h.normalizeMax(h.adjoint3(f)),e=h.normalizeMax(h.adjoint3(e));"ellipsoid"!==l._helper.getConicType(f)&&(k=f,f=e,e=k);h.almostequals(b,c).value&&(b=m.real(3),e=h.zeromatrix(b,b));a.results=[f,e]};l.ConicBy2Pol1P={};l.ConicBy2Pol1P.kind="C";l.ConicBy2Pol1P.signature=["P","L","P","L","P"];l.ConicBy2Pol1P.updatePosition=function(a){var b=v.csnames[a.args[0]].homog,c=v.csnames[a.args[1]].homog,d=v.csnames[a.args[2]].homog,
e=v.csnames[a.args[3]].homog,f=v.csnames[a.args[4]].homog,k=h.scalproduct,l=h.scalmult,n=h.sub,p=h.productMM,r=m.realmult,t=h.transpose,u=h.turnIntoCSList,x=n(l(k(c,b),f),l(r(2,k(c,f)),b)),y=n(l(k(e,d),f),l(r(2,k(e,f)),d)),z=u([h.cross(b,f)]),f=u([h.cross(d,f)]),y=p(t(z),u([h.cross(b,y)])),u=p(t(f),u([h.cross(d,x)])),p=p(t(z),f),b=k(b,e),c=k(d,c),d=h.add(l(c,y),l(b,u)),d=n(d,l(r(2,m.mult(b,c)),p)),d=h.add(d,t(d)),d=h.normalizeMax(d),d=w.withUsage(d,"Conic");a.matrix=d};l.ConicBy2Pol1L={};l.ConicBy2Pol1L.kind=
"C";l.ConicBy2Pol1L.signature=["P","L","P","L","L"];l.ConicBy2Pol1L.updatePosition=function(a){var b=v.csnames[a.args[0]].homog,c=v.csnames[a.args[1]].homog,d=v.csnames[a.args[2]].homog,e=v.csnames[a.args[3]].homog,f=v.csnames[a.args[4]].homog,k=h.scalproduct,l=h.scalmult,n=h.productMM,p=m.mult,r=h.transpose,t=h.turnIntoCSList,u=k(c,b),x=k(c,d),y=k(e,b),z=k(e,d),A=k(f,b),k=k(f,d),B=t([h.sub(l(p(y,k),c),l(p(x,A),e))]),b=h.add(n(r(t([l(p(y,x),f)])),t([h.sub(h.add(l(m.sub(p(u,k),p(x,A)),e),l(m.sub(p(z,
A),p(y,k)),c)),l(h.det3(c,e,f),h.cross(b,d)))])),n(r(B),B)),b=h.add(b,r(b)),b=h.normalizeMax(b),b=w.withUsage(b,"Conic");a.matrix=b};l._helper.conic1Pol3Inc=function(a,b,c,d,e){var f=h.scalproduct,k=h.scalmult,l=h.productMM,n=h.cross,p=m.realmult,r=m.mult,t=h.transpose,v=h.turnIntoCSList,u=h.det3,w=u(a,c,d),x=v([n(c,e)]),y=v([n(a,e)]),z=v([n(c,d)]),A=f(b,a),B=f(b,c);b=f(b,e);n=v([n(d,h.sub(k(A,e),k(p(2,b),a)))]);x=k(w,l(t(x),n));a=p(2,m.add(r(u(a,d,e),B),r(w,b)));a=m.sub(r(u(c,d,e),A),a);x=h.add(x,
k(a,l(t(y),z)));x=h.add(x,t(x));return x=h.normalizeMax(x)};l.ConicBy1Pol3P={};l.ConicBy1Pol3P.kind="C";l.ConicBy1Pol3P.signature=["P","L","P","P","P"];l.ConicBy1Pol3P.updatePosition=function(a){var b=l._helper.conic1Pol3Inc(v.csnames[a.args[0]].homog,v.csnames[a.args[1]].homog,v.csnames[a.args[2]].homog,v.csnames[a.args[3]].homog,v.csnames[a.args[4]].homog),b=w.withUsage(b,"Conic");a.matrix=b};l.ConicBy1Pol3L={};l.ConicBy1Pol3L.kind="C";l.ConicBy1Pol3L.signature=["P","L","L","L","L"];l.ConicBy1Pol3L.updatePosition=
function(a){var b=l._helper.conic1Pol3Inc(v.csnames[a.args[1]].homog,v.csnames[a.args[0]].homog,v.csnames[a.args[2]].homog,v.csnames[a.args[3]].homog,v.csnames[a.args[4]].homog),b=h.normalizeMax(h.adjoint3(b)),b=w.withUsage(b,"Conic");a.matrix=b};l.ConicBy1Pol2P1L={};l.ConicBy1Pol2P1L.kind="Cs";l.ConicBy1Pol2P1L.signature=["P","L","P","P","L"];l.ConicBy1Pol2P1L.updatePosition=function(a){var b=v.csnames[a.args[0]].homog,c=v.csnames[a.args[1]].homog,d=v.csnames[a.args[2]].homog,e=v.csnames[a.args[3]].homog,
f=v.csnames[a.args[4]].homog,k=m.add,l=h.turnIntoCSList,n=h.cross,p=h.productMM,r=m.mult,t=m.realmult,u=h.scalmult,w=h.scalproduct,x=m.sub,y=h.transpose,z=w(c,b),A=w(c,d),B=w(c,e),c=w(f,b),C=w(f,d),w=w(f,e),f=l([n(b,d)]),b=l([n(b,e)]),d=l([n(d,e)]),e=m.sqrt(r(r(C,w),r(x(r(z,C),t(2,r(c,A))),x(r(z,w),t(2,r(c,B)))))),l=p(y(f),b),e=u(e,h.add(l,y(l))),k=u(x(r(z,r(C,w)),k(r(c,r(A,w)),r(c,r(C,B)))),l),t=h.add(h.sub(u(B,f),u(A,b)),u(t(.5,z),d)),k=h.add(k,u(r(c,c),p(y(d),t))),k=h.add(k,y(k)),p=h.normalizeMax(h.add(e,
k)),r=h.normalizeMax(h.sub(e,k));a.results=Qb(p,r).value};l.ConicBy1Pol2P1L.stateSize=Qb.stateSize;l.ConicBy1Pol1P2L={};l.ConicBy1Pol1P2L.kind="Cs";l.ConicBy1Pol1P2L.signature=["P","L","P","L","L"];l.ConicBy1Pol1P2L.updatePosition=function(a){var b=v.csnames[a.args[0]].homog,c=v.csnames[a.args[1]].homog,d=v.csnames[a.args[2]].homog,e=v.csnames[a.args[3]].homog,f=v.csnames[a.args[4]].homog,k=m.add,l=h.turnIntoCSList,n=h.cross,p=h.productMM,r=m.mult,t=m.realmult,u=h.scalmult,w=h.scalproduct,x=m.sub,
y=h.transpose,z=w(c,b),A=w(c,d),B=w(e,b),C=w(e,d),D=w(f,b),E=w(f,d),F=r(z,z),G=r(z,A),w=r(A,A),H=r(B,B),I=r(B,C),L=r(C,C),N=r(D,D),J=r(D,E),M=r(E,E),K=r(r(F,L),M),K=x(K,t(2,r(r(G,I),M))),K=x(K,t(2,r(r(G,L),J))),K=k(K,t(.5,r(r(w,H),M))),K=k(K,t(3,r(r(w,I),J))),K=k(K,t(.5,r(r(w,L),N))),J=r(r(z,C),E),J=x(J,r(r(A,B),E)),J=x(J,r(r(A,C),D)),J=r(J,r(w,D)),M=x(r(z,C),t(2,r(A,B))),M=r(M,r(w,r(C,D))),K=p(y(l([c])),l([h.add(h.add(u(K,c),u(J,e)),u(M,f))])),J=l([e]),K=h.add(K,u(t(.5,r(r(w,w),N)),p(y(J),J))),K=
h.add(K,u(w,p(y(l([f])),l([h.add(u(x(x(t(2,r(G,I)),r(F,L)),t(.5,r(w,H))),f),u(r(h.det3(c,e,f),x(r(z,C),r(A,B))),n(b,d)))])))),K=h.add(K,y(K)),b=m.sqrt(r(r(C,E),r(x(r(z,C),t(2,r(A,B))),x(r(z,E),t(2,r(A,D)))))),c=p(y(l([c])),l([h.sub(u(x(r(A,k(r(B,E),r(C,D))),r(z,r(C,E))),c),u(w,h.add(u(D,e),u(B,f))))])),c=h.add(c,u(r(z,w),p(y(l([e])),l([f])))),c=u(b,c),c=h.add(c,y(c)),e=h.normalizeMax(h.add(K,c)),f=h.normalizeMax(h.sub(K,c));a.results=Qb(e,f).value};l.ConicBy1Pol1P2L.stateSize=Qb.stateSize;l._helper.coHarmonic=
function(a,b,c,d){var e=h.realVector([100*Math.random(),100*Math.random(),1]),f=h.det3(e,c,a),k=h.det3(e,c,b);c=h.det3(e,d,a);d=h.det3(e,d,b);d=m.sqrt(m.mult(d,k));f=m.sqrt(m.mult(c,f));a=w.mult(a,d);f=w.mult(b,f);b=h.add(a,f);a=h.sub(a,f);return[b,a]};l.ConicInSquare={};l.ConicInSquare.kind="C";l.ConicInSquare.signature=["P","P","P","P"];l.ConicInSquare.updatePosition=function(a){var b=D.basismap(v.csnames[a.args[0]].homog,v.csnames[a.args[1]].homog,v.csnames[a.args[2]].homog,v.csnames[a.args[3]].homog),
c=m.one,c=l._helper.buildConicMatrix([c,c,c,m.real(-3),c,c]),b=h.adjoint3(b),b=h.productMM(h.productMM(h.transpose(b),c),b),b=h.normalizeMax(b);a.matrix=w.withUsage(b,"Conic")};l.ConicBy5lines={};l.ConicBy5lines.kind="C";l.ConicBy5lines.signature=["L","L","L","L","L"];l.ConicBy5lines.updatePosition=function(a){var b=l._helper.ConicBy5(a,v.csnames[a.args[0]].homog,v.csnames[a.args[1]].homog,v.csnames[a.args[2]].homog,v.csnames[a.args[3]].homog,v.csnames[a.args[4]].homog),b=h.adjoint3(b);a.matrix=b;
a.matrix=h.normalizeMax(a.matrix);a.matrix=w.withUsage(a.matrix,"Conic")};l.ConicFromPrincipalDirections={};l.ConicFromPrincipalDirections.kind="C";l.ConicFromPrincipalDirections.signature=["P","P","P"];l.ConicFromPrincipalDirections.updatePosition=function(a){var b=v.csnames[a.args[0]].homog,c=v.csnames[a.args[1]].homog,d=v.csnames[a.args[2]].homog,e=l._helper.pointReflection(b,c),f=h.cross(c,b),b=h.turnIntoCSList([f.value[0],f.value[1],m.zero]),f=h.turnIntoCSList([f]),c=h.turnIntoCSList([h.cross(c,
b)]),e=h.turnIntoCSList([h.cross(e,b)]);a.matrix=l._helper.conicFromTwoDegenerates(f,f,c,e,d);a.matrix=h.normalizeMax(a.matrix);a.matrix=w.withUsage(a.matrix,"Conic")};l.CircleBy3={};l.CircleBy3.kind="C";l.CircleBy3.signature=["P","P","P"];l.CircleBy3.updatePosition=function(a){var b=l._helper.ConicBy5(a,v.csnames[a.args[0]].homog,v.csnames[a.args[1]].homog,h.ii,h.jj,v.csnames[a.args[2]].homog);a.matrix=h.normalizeMax(b);a.matrix=w.withUsage(a.matrix,"Circle")};l.ArcBy3={};l.ArcBy3.kind="C";l.ArcBy3.signature=
["P","P","P"];l.ArcBy3.updatePosition=function(a){l.CircleBy3.updatePosition(a);a.startPoint=v.csnames[a.args[0]].homog;a.viaPoint=v.csnames[a.args[1]].homog;a.endPoint=v.csnames[a.args[2]].homog};l.ArcBy3.initialize=function(a){a.startPoint=v.csnames[a.args[0]].homog;a.viaPoint=v.csnames[a.args[1]].homog;a.endPoint=v.csnames[a.args[2]].homog;a.isArc=!0};l.PolarOfPoint={};l.PolarOfPoint.kind="L";l.PolarOfPoint.signature=["P","C"];l.PolarOfPoint.updatePosition=function(a){var b=w.mult(v.csnames[a.args[1]].matrix,
v.csnames[a.args[0]].homog),b=h.normalizeMax(b);a.homog=w.withUsage(b,"Line")};l.PolarOfLine={};l.PolarOfLine.kind="P";l.PolarOfLine.signature=["L","C"];l.PolarOfLine.updatePosition=function(a){var b=v.csnames[a.args[0]],c=h.adjoint3(v.csnames[a.args[1]].matrix),b=w.mult(c,b.homog),b=h.normalizeMax(b);a.homog=w.withUsage(b,"Point")};l.AngleBisector={};l.AngleBisector.kind="Ls";l.AngleBisector.signature=["L","L","P"];l.AngleBisector.updatePosition=function(a){var b=v.csnames[a.args[0]].homog,c=v.csnames[a.args[1]].homog,
d=v.csnames[a.args[2]].homog,e=h.add,f=h.sub,k=h.abs,l=h.cross,m=h.scalmult,n=h.normalizeMax,p=h._helper.isAlmostZero,r=h.linfty,t=m(k(l(l(r,c),r)),b),b=m(k(l(l(r,b),r)),c),f=f(t,b),e=e(t,b);p(f)&&(f=l(l(l(r,e),r),d));p(e)&&(e=l(l(l(r,f),r),d));a.results=Pa(n(f),n(e))};l.AngleBisector.stateSize=Pa.stateSize;l._helper.IntersectLC=function(a,b){var c=m,d=h.crossOperator(a),e=h.transpose(d),e=w.mult(e,w.mult(b,d)),f=h.maxIndex(a,m.abs2),k,l,n,p;0===f?(f=e.value[1].value[1],k=e.value[1].value[2],l=e.value[2].value[1],
n=e.value[2].value[2],p=a.value[0]):1===f?(f=e.value[0].value[0],k=e.value[0].value[2],l=e.value[2].value[0],n=e.value[2].value[2],p=a.value[1]):(f=e.value[0].value[0],k=e.value[0].value[1],l=e.value[1].value[0],n=e.value[1].value[1],p=a.value[2]);c=c.div(c.sqrt(c.sub(c.mult(k,l),c.mult(f,n))),p);c=h.add(e,h.scalmult(c,d));f=h.maxIndex(c,h.abs2);d=c.value[f];d=h.normalizeMax(d);d=w.withUsage(d,"Point");c=h.transpose(c);f=h.maxIndex(c,h.abs2);c=c.value[f];c=h.normalizeMax(c);c=w.withUsage(c,"Point");
return[d,c]};l.IntersectLC={};l.IntersectLC.kind="Ps";l.IntersectLC.signature=["L","C"];l.IntersectLC.updatePosition=function(a){var b=l._helper.IntersectLC(v.csnames[a.args[0]].homog,v.csnames[a.args[1]].matrix);a.results=Pa(b[0],b[1])};l.IntersectLC.stateSize=Pa.stateSize;l.OtherIntersectionCL={};l.OtherIntersectionCL.kind="P";l.OtherIntersectionCL.signature=["C","L","P"];l.OtherIntersectionCL.updatePosition=function(a){var b=v.csnames[a.args[2]].homog,c=l._helper.IntersectLC(v.csnames[a.args[1]].homog,
v.csnames[a.args[0]].matrix),d=c[0],c=c[1],e=h.projectiveDistMinScal(d,b),b=h.projectiveDistMinScal(c,b);a.homog=e<b?c:d;a.homog=h.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Point")};l.IntersectCirCir={};l.IntersectCirCir.kind="Ps";l.IntersectCirCir.signature=["C","C"];l.IntersectCirCir.updatePosition=function(a){var b=v.csnames[a.args[0]].matrix,c=v.csnames[a.args[1]].matrix,d=h.scalmult(c.value[0].value[0],b.value[2]),c=h.scalmult(b.value[0].value[0],c.value[2]),d=h.sub(d,c),d=h.turnIntoCSList([d.value[0],
d.value[1],m.realmult(.5,d.value[2])]),d=h.normalizeMax(d),b=l._helper.IntersectLC(d,b);a.results=Pa(b[0],b[1])};l.IntersectCirCir.stateSize=Pa.stateSize;l.OtherIntersectionCC={};l.OtherIntersectionCC.kind="P";l.OtherIntersectionCC.signature=["C","C","P"];l.OtherIntersectionCC.updatePosition=function(a){var b=v.csnames[a.args[0]].matrix,c=v.csnames[a.args[1]].matrix,d=v.csnames[a.args[2]].homog,e=h.scalmult(c.value[0].value[0],b.value[2]),c=h.scalmult(b.value[0].value[0],c.value[2]),e=h.sub(e,c),
e=h.turnIntoCSList([e.value[0],e.value[1],m.realmult(.5,e.value[2])]),e=h.normalizeMax(e),e=l._helper.IntersectLC(e,b),b=e[0],e=e[1],c=h.projectiveDistMinScal(b,d),d=h.projectiveDistMinScal(e,d);a.homog=c<d?e:b;a.homog=h.normalizeMax(a.homog);a.homog=w.withUsage(a.homog,"Point")};l._helper.IntersectConicConic=function(a,b){var c=a.value[0],d=a.value[1],e=a.value[2],f=b.value[0],k=b.value[1],n=b.value[2],p=h.det3(c,d,e),r=m.add(m.add(h.det3(c,d,n),h.det3(c,k,e)),h.det3(f,d,e)),c=m.add(m.add(h.det3(c,
k,n),h.det3(f,d,n)),h.det3(f,k,e)),f=h.det3(f,k,n),n=m.abs2(p).value.real,k=m.abs2(f).value.real;n<k&&(n=a,a=b,b=n,n=f,f=p,p=n,n=c,c=r,r=n,n=k);1E-24>n?(p=a,c=b):(r=m.solveCubic(p,r,c,f),c=m.abs2(m.sub(r[0],r[1])).value.real,f=m.abs2(m.sub(r[0],r[2])).value.real,k=m.abs2(m.sub(r[1],r[2])).value.real,c>f?(p=r[1],r=c>k?r[0]:r[2]):(p=r[2],r=f>k?r[0]:r[1]),p=h.add(h.scalmult(p,a),b),c=h.add(h.scalmult(r,a),b));r=l._helper.splitDegenConic(p);p=r[0];r=r[1];c=l._helper.splitDegenConic(c);k=c[0];f=c[1];c=
h.cross(p,k);k=h.cross(r,k);p=h.cross(p,f);r=h.cross(r,f);c=h.normalizeMax(c);k=h.normalizeMax(k);p=h.normalizeMax(p);r=h.normalizeMax(r);c=w.withUsage(c,"Point");k=w.withUsage(k,"Point");p=w.withUsage(p,"Point");r=w.withUsage(r,"Point");return[c,k,p,r]};l.IntersectConicConic={};l.IntersectConicConic.kind="Ps";l.IntersectConicConic.signature=["C","C"];l.IntersectConicConic.updatePosition=function(a){var b=l._helper.IntersectConicConic(v.csnames[a.args[0]].matrix,v.csnames[a.args[1]].matrix),b=Fc(b[0],
b[1],b[2],b[3]);a.results=b};l.IntersectConicConic.stateSize=Fc.stateSize;l.SelectP={};l.SelectP.kind="P";l.SelectP.signature=["Ps"];l.SelectP.initialize=function(a){if(void 0!==a.index)return a.index-1;var b=v.csnames[a.args[0]].results.value;a=l._helper.initializePoint(a);for(var c=h.projectiveDistMinScal(a,b[0]),d=0,e=1;e<b.length;++e){var f=h.projectiveDistMinScal(a,b[e]);f<c&&(c=f,d=e)}return d};l.SelectP.updatePosition=function(a){a.homog=v.csnames[a.args[0]].results.value[a.param]};l.SelectL=
{};l.SelectL.kind="L";l.SelectL.signature=["Ls"];l.SelectL.initialize=function(a){if(void 0!==a.index)return a.index-1;var b=v.csnames[a.args[0]].results.value;a=l._helper.initializeLine(a);for(var c=h.projectiveDistMinScal(a,b[0]),d=0,e=1;e<b.length;++e){var f=h.projectiveDistMinScal(a,b[e]);f<c&&(c=f,d=e)}return d};l.SelectL.updatePosition=function(a){a.homog=v.csnames[a.args[0]].results.value[a.param];a.homog=w.withUsage(a.homog,"Line")};l._helper.moebiusStep=function(a,b,c){var d=m.add,e=m.sub,
f=m.mult,h=a.value[0],k=a.value[1];a=a.value[2];var l=b.value[0],n=b.value[1];b=b.value[2];var p=c.value[0],r=c.value[1],t=c.value[2];c=e(f(b,p),f(l,t));var u=e(f(b,r),f(n,t)),p=e(f(h,t),f(a,p)),r=e(f(k,t),f(a,r));return[e(f(h,c),f(k,u)),d(f(k,c),f(h,u)),f(a,c),f(a,u),e(f(l,p),f(n,r)),d(f(n,p),f(l,r)),f(b,p),f(b,r)]};l.TrMoebius={};l.TrMoebius.kind="Mt";l.TrMoebius.signature="PPPPPP".split("");l.TrMoebius.updatePosition=function(a){var b=m.neg,c=l._helper.moebiusStep(v.csnames[a.args[0]].homog,v.csnames[a.args[2]].homog,
v.csnames[a.args[4]].homog),d=l._helper.moebiusStep(v.csnames[a.args[1]].homog,v.csnames[a.args[3]].homog,v.csnames[a.args[5]].homog),d=h.normalizeMax(h.matrix([[d[0],b(d[1]),d[4],b(d[5])],[d[1],d[0],d[5],d[4]],[d[2],b(d[3]),d[6],b(d[7])],[d[3],d[2],d[7],d[6]]])),b=h.normalizeMax(h.matrix([[c[6],b(c[4])],[c[7],b(c[5])],[b(c[2]),c[0]],[b(c[3]),c[1]]])),b=h.normalizeMax(h.productMM(d,b));a.moebius={anti:!1,ar:b.value[0].value[0],ai:b.value[1].value[0],br:b.value[0].value[1],bi:b.value[1].value[1],cr:b.value[2].value[0],
ci:b.value[3].value[0],dr:b.value[2].value[1],di:b.value[3].value[1]};l._helper.moebiusPair(a)};l._helper.moebiusPair=function(a){var b=a.moebius,c=m.neg,d=b.anti?c:w.identity,b=h.normalizeMax(h.turnIntoCSList([h.matrix([[c(b.cr),d(b.ci),c(b.dr)],[b.ci,d(b.cr),b.di],[b.ar,c(d(b.ai)),b.br]]),h.matrix([[c(b.ci),c(d(b.cr)),c(b.di)],[c(b.cr),d(b.ci),c(b.dr)],[b.ai,d(b.ar),b.bi]])]));a.mat1=b.value[0];a.mat2=b.value[1]};l._helper.inverseMoebius=function(a){var b=m.neg,c=a.anti?b:w.identity;return{anti:a.anti,
ar:a.dr,ai:c(a.di),br:b(a.br),bi:b(c(a.bi)),cr:b(a.cr),ci:b(c(a.ci)),dr:a.ar,di:c(a.ai)}};l.TrInverseMoebius={};l.TrInverseMoebius.kind="Mt";l.TrInverseMoebius.signature=["Mt"];l.TrInverseMoebius.updatePosition=function(a){a.moebius=l._helper.inverseMoebius(v.csnames[a.args[0]].moebius);l._helper.moebiusPair(a)};l.TrMoebiusP={};l.TrMoebiusP.kind="P";l.TrMoebiusP.signature=["Mt","P"];l.TrMoebiusP.updatePosition=function(a){var b=v.csnames[a.args[0]],c=v.csnames[a.args[1]].homog,d=h.productMV(b.mat1,
c),b=h.productMV(b.mat2,c);a.homog=h.normalizeMax(h.cross(d,b));a.homog=w.withUsage(a.homog,"Point")};l._helper.TrMoebiusP=function(a,b){var c=h.productMV(b.mat1,a),d=h.productMV(b.mat2,a);return h.normalizeMax(h.cross(c,d))};l.TrMoebiusL={};l.TrMoebiusL.kind="C";l.TrMoebiusL.signature=["Mt","L"];l.TrMoebiusL.updatePosition=function(a){var b=v.csnames[a.args[0]],c=v.csnames[a.args[1]].homog,d=function(){var a=h.realVector([Math.random()-.5,Math.random()-.5,Math.random()-.5]);return h.normalizeMax(a)},
e=h.cross(d(),c),f=h.cross(d(),c),c=h.cross(d(),c),e=l._helper.TrMoebiusP(e,b),f=l._helper.TrMoebiusP(f,b),b=l._helper.TrMoebiusP(c,b);a.matrix=h.normalizeMax(l._helper.ConicBy5(null,e,f,b,h.ii,h.jj));a.matrix=w.withUsage(a.matrix,"Circle")};l.TrMoebiusS={};l.TrMoebiusS.kind="C";l.TrMoebiusS.signature=["Mt","S"];l.TrMoebiusS.updatePosition=function(a){var b=v.csnames[a.args[0]],c=v.csnames[a.args[1]],d=c.startpos,c=c.endpos,e=h.add(d,c),d=l._helper.TrMoebiusP(d,b),e=l._helper.TrMoebiusP(e,b),b=l._helper.TrMoebiusP(c,
b);a.startPoint=d;a.viaPoint=e;a.endPoint=b;a.isArc=!0;a.matrix=h.normalizeMax(l._helper.ConicBy5(null,d,e,b,h.ii,h.jj));a.matrix=w.withUsage(a.matrix,"Circle")};l.TrMoebiusC={};l.TrMoebiusC.kind="C";l.TrMoebiusC.signature=["Mt","C"];l.TrMoebiusC.signatureConstraints=function(a){return"Circle"===v.csnames[a.args[1]].matrix.usage};l.TrMoebiusC.updatePosition=function(a){var b=v.csnames[a.args[0]],c=v.csnames[a.args[1]].matrix,d=function(){var a=h.realVector([Math.random()-.5,Math.random()-.5,Math.random()-
.5]);return h.normalizeMax(a)},e=l._helper.IntersectLC(d(),c),d=l._helper.IntersectLC(d(),c),c=e[1],d=d[1],e=l._helper.TrMoebiusP(e[0],b),c=l._helper.TrMoebiusP(c,b),b=l._helper.TrMoebiusP(d,b);a.matrix=h.normalizeMax(l._helper.ConicBy5(null,e,c,b,h.ii,h.jj));a.matrix=w.withUsage(a.matrix,"Circle")};l.TrMoebiusArc={};l.TrMoebiusArc.kind="C";l.TrMoebiusArc.signature=["Mt","C"];l.TrMoebiusArc.signatureConstraints=function(a){return v.csnames[a.args[1]].isArc};l.TrMoebiusArc.updatePosition=function(a){var b=
v.csnames[a.args[0]],c=v.csnames[a.args[1]],d=c.viaPoint,e=c.endPoint,c=l._helper.TrMoebiusP(c.startPoint,b),d=l._helper.TrMoebiusP(d,b),b=l._helper.TrMoebiusP(e,b);a.startPoint=c;a.viaPoint=d;a.endPoint=b;a.isArc=!0;a.matrix=h.normalizeMax(l._helper.ConicBy5(null,c,d,b,h.ii,h.jj));a.matrix=w.withUsage(a.matrix,"Circle")};l._helper.trBuildMatrix=function(a,b){var c=b(0),d=b(1),e=h.productMM(d,h.adjoint3(c));a.matrix=h.normalizeMax(e);e=h.transpose(h.productMM(c,h.adjoint3(d)));a.dualMatrix=h.normalizeMax(e)};
l.TrProjection={};l.TrProjection.kind="Tr";l.TrProjection.signature="PPPPPPPP".split("");l.TrProjection.initialize=function(a){a.isEuclidean=0};l.TrProjection.updatePosition=function(a){l._helper.trBuildMatrix(a,function(b){return D.basismap(v.csnames[a.args[0+b]].homog,v.csnames[a.args[2+b]].homog,v.csnames[a.args[4+b]].homog,v.csnames[a.args[6+b]].homog)})};l.TrAffine={};l.TrAffine.kind="Tr";l.TrAffine.signature="PPPPPP".split("");l.TrAffine.initialize=function(a){a.isEuclidean=0};l.TrAffine.updatePosition=
function(a){var b=m.mult,c=h.scalmult,d=h.turnIntoCSList,e=h.transpose,f=h.normalizeMax,k=h.productMM,l=h.adjoint3,n=d([v.csnames[a.args[0]].homog,v.csnames[a.args[2]].homog,v.csnames[a.args[4]].homog]),p=d([v.csnames[a.args[1]].homog,v.csnames[a.args[3]].homog,v.csnames[a.args[5]].homog]),r=e(n),e=e(p),t=r.value[2].value,u=e.value[2].value,w=[b(t[0],u[2]),b(t[1],u[0]),b(t[2],u[1])],r=l(r).value;a.matrix=f(k(e,d([c(b(w[0],u[1]),r[0]),c(b(w[1],u[2]),r[1]),c(b(w[2],u[0]),r[2])])));r=n.value;a.dualMatrix=
f(k(l(p),d([c(b(t[2],w[1]),r[0]),c(b(t[0],w[2]),r[1]),c(b(t[1],w[0]),r[2])])))};l.TrSimilarity={};l.TrSimilarity.kind="Tr";l.TrSimilarity.signature=["P","P","P","P"];l.TrSimilarity.initialize=function(a){a.isEuclidean=1};l.TrSimilarity.updatePosition=function(a){l._helper.trBuildMatrix(a,function(b){return D.basismap(v.csnames[a.args[0+b]].homog,v.csnames[a.args[2+b]].homog,h.ii,h.jj)})};l.TrTranslation={};l.TrTranslation.kind="Tr";l.TrTranslation.signature=["P","P"];l.TrTranslation.initialize=function(a){a.isEuclidean=
1};l.TrTranslation.updatePosition=function(a){var b=v.csnames[a.args[0]].homog,c=v.csnames[a.args[1]].homog,d=h.cross(b,c).value,b=m.mult(b.value[2],c.value[2]),c=h.turnIntoCSList,e=m.neg,f=m.zero,d=c([c([b,f,d[1]]),c([f,b,e(d[0])]),c([f,f,b])]),d=h.normalizeMax(d);a.matrix=d;b=e(d.value[0].value[0]);d=c([c([b,f,f]),c([f,b,f]),c([d.value[0].value[2],d.value[1].value[2],b])]);a.dualMatrix=d};l.TrReflectionP={};l.TrReflectionP.kind="Tr";l.TrReflectionP.signature=["P"];l.TrReflectionP.initialize=function(a){a.isEuclidean=
1};l.TrReflectionP.updatePosition=function(a){var b=v.csnames[a.args[0]].homog.value,c=m.realmult(-.5,b[2]),d=m.zero,b=h.turnIntoCSList([h.turnIntoCSList([c,d,b[0]]),h.turnIntoCSList([d,c,b[1]]),h.turnIntoCSList([d,d,m.neg(c)])]),b=h.normalizeMax(b);a.matrix=b;a.dualMatrix=h.transpose(b)};l.TrReflectionL={};l.TrReflectionL.kind="Tr";l.TrReflectionL.signature=["L"];l.TrReflectionL.initialize=function(a){a.isEuclidean=-1};l.TrReflectionL.updatePosition=function(a){var b=m.mult,c=m.realmult,d=m.zero,
e=v.csnames[a.args[0]].homog.value,f=e[0],k=e[1],e=e[2],l=b(f,f),n=b(k,k),p=c(-.5,m.sub(l,n)),r=b(f,k),b=h.turnIntoCSList([h.turnIntoCSList([m.neg(p),r,b(f,e)]),h.turnIntoCSList([r,p,b(k,e)]),h.turnIntoCSList([d,d,c(-.5,m.add(l,n))])]),b=h.normalizeMax(b);a.matrix=b;a.dualMatrix=h.transpose(b)};l.TrReflectionS={};l.TrReflectionS.kind="Tr";l.TrReflectionS.signature=["S"];l.TrReflectionS.updatePosition=l.TrReflectionL.updatePosition;l.TrReflectionC={};l.TrReflectionC.kind="Mt";l.TrReflectionC.signature=
["C"];l.TrReflectionC.signatureConstraints=function(a){return"Circle"===v.csnames[a.args[0]].matrix.usage};l.TrReflectionC.updatePosition=function(a){var b=v.csnames[a.args[0]].matrix,c=b.value[0].value[2],d=b.value[1].value[2],e=m.neg;a.moebius={anti:!0,ar:c,ai:d,br:b.value[2].value[2],bi:m.zero,cr:e(b.value[0].value[0]),ci:m.zero,dr:e(c),di:d};l._helper.moebiusPair(a)};l.TrInverse={};l.TrInverse.kind="Tr";l.TrInverse.signature=["Tr"];l.TrInverse.initialize=function(a){a.isEuclidean=v.csnames[a.args[0]].isEuclidean};
l.TrInverse.updatePosition=function(a){var b=v.csnames[a.args[0]];a.dualMatrix=h.transpose(b.matrix);a.matrix=h.transpose(b.dualMatrix)};l.TransformC={};l.TransformC.kind="C";l.TransformC.signature=["Tr","C"];l.TransformC.updatePosition=function(a){var b=v.csnames[a.args[0]].dualMatrix,b=h.productMM(h.productMM(b,v.csnames[a.args[1]].matrix),h.transpose(b)),b=h.normalizeMax(b);a.matrix=w.withUsage(b,"Conic")};l.TransformArc={};l.TransformArc.kind="C";l.TransformArc.signature=["Tr","C"];l.TransformArc.signatureConstraints=
function(a){return v.csnames[a.args[0]].isArc};l.TransformArc.updatePosition=function(a){var b=v.csnames[a.args[0]].matrix,c=v.csnames[a.args[1]],d=c.viaPoint,e=c.endPoint,c=h.normalizeMax(h.productMV(b,c.startPoint)),d=h.normalizeMax(h.productMV(b,d)),b=h.normalizeMax(h.productMV(b,e));a.startPoint=c;a.viaPoint=d;a.endPoint=b;a.isArc=!0;a.matrix=h.normalizeMax(l._helper.ConicBy5(null,c,d,b,h.ii,h.jj));a.matrix=w.withUsage(a.matrix,"Circle")};l.TransformP={};l.TransformP.kind="P";l.TransformP.signature=
["Tr","P"];l.TransformP.updatePosition=function(a){a.homog=h.normalizeMax(h.productMV(v.csnames[a.args[0]].matrix,v.csnames[a.args[1]].homog));a.homog=w.withUsage(a.homog,"Point")};l.TransformL={};l.TransformL.kind="L";l.TransformL.signature=["Tr","L"];l.TransformL.updatePosition=function(a){a.homog=h.normalizeMax(h.productMV(v.csnames[a.args[0]].dualMatrix,v.csnames[a.args[1]].homog));a.homog=w.withUsage(a.homog,"Line")};l.TransformS={};l.TransformS.kind="S";l.TransformS.signature=["Tr","S"];l.TransformS.updatePosition=
function(a){var b=v.csnames[a.args[0]],c=v.csnames[a.args[1]];l.Segment.setSegmentPos(a,h.productMV(b.dualMatrix,c.homog),h.productMV(b.matrix,c.startpos),h.productMV(b.matrix,c.endpos))};l.TransformPolygon={};l.TransformPolygon.kind="Poly";l.TransformPolygon.signature=["Tr","Poly"];l.TransformPolygon.updatePosition=function(a){var b=v.csnames[a.args[0]].matrix;a.vertices=h.turnIntoCSList(v.csnames[a.args[1]].vertices.value.map(function(a){a=h.normalizeMax(h.productMV(b,a));return a=w.withUsage(a,
"Point")}))};l.TrComposeTrTr={};l.TrComposeTrTr.kind="Tr";l.TrComposeTrTr.signature=["Tr","Tr"];l.TrComposeTrTr.initialize=function(a){a.isEuclidean=v.csnames[a.args[0]].isEuclidean*v.csnames[a.args[1]].isEuclidean};l.TrComposeTrTr.updatePosition=function(a){var b=v.csnames[a.args[0]],c=v.csnames[a.args[1]];a.matrix=h.normalizeMax(h.productMM(c.matrix,b.matrix));a.dualMatrix=h.normalizeMax(h.productMM(c.dualMatrix,b.dualMatrix))};l._helper.composeMtMt=function(a,b,c){function d(a,b,c,e){return k(p(a,
b),p(c,e))}function e(a,b,c,g,f,h,l,m){return k(d(a,b,c,g),d(f,h,l,m))}function f(a,b,c,e,g,h,k,l){return n(d(a,b,c,e),d(g,h,k,l))}var k=m.add,n=m.sub,p=m.mult,r=c.anti?f:e,t=c.anti?e:f,r=h.normalizeMax(h.turnIntoCSList([t(b.ar,c.ar,b.cr,c.br,b.ai,c.ai,b.ci,c.bi),r(b.ar,c.ai,b.cr,c.bi,b.ai,c.ar,b.ci,c.br),t(b.br,c.ar,b.dr,c.br,b.bi,c.ai,b.di,c.bi),r(b.br,c.ai,b.dr,c.bi,b.bi,c.ar,b.di,c.br),t(b.ar,c.cr,b.cr,c.dr,b.ai,c.ci,b.ci,c.di),r(b.ar,c.ci,b.cr,c.di,b.ai,c.cr,b.ci,c.dr),t(b.br,c.cr,b.dr,c.dr,
b.bi,c.ci,b.di,c.di),r(b.br,c.ci,b.dr,c.di,b.bi,c.cr,b.di,c.dr)])).value;a.moebius={anti:b.anti!==c.anti,ar:r[0],ai:r[1],br:r[2],bi:r[3],cr:r[4],ci:r[5],dr:r[6],di:r[7]};l._helper.moebiusPair(a)};l._helper.euc2moeb=function(a){var b=a.matrix.value;return{anti:0>a.isEuclidean,ar:b[0].value[0],ai:b[1].value[0],br:b[0].value[2],bi:b[1].value[2],cr:m.zero,ci:m.zero,dr:b[2].value[2],di:m.zero}};l.TrComposeMtMt={};l.TrComposeMtMt.kind="Mt";l.TrComposeMtMt.signature=["Mt","Mt"];l.TrComposeMtMt.updatePosition=
function(a){l._helper.composeMtMt(a,v.csnames[a.args[0]].moebius,v.csnames[a.args[1]].moebius)};l.TrComposeTrMt={};l.TrComposeTrMt.kind="Mt";l.TrComposeTrMt.signature=["Tr","Mt"];l.TrComposeTrMt.signatureConstraints=function(a){return!!v.csnames[a.args[0]].isEuclidean};l.TrComposeTrMt.updatePosition=function(a){l._helper.composeMtMt(a,l._helper.euc2moeb(v.csnames[a.args[0]]),v.csnames[a.args[1]].moebius)};l.TrComposeMtTr={};l.TrComposeMtTr.kind="Mt";l.TrComposeMtTr.signature=["Mt","Tr"];l.TrComposeMtTr.signatureConstraints=
function(a){return!!v.csnames[a.args[1]].isEuclidean};l.TrComposeMtTr.updatePosition=function(a){l._helper.composeMtMt(a,v.csnames[a.args[0]].moebius,l._helper.euc2moeb(v.csnames[a.args[1]]))};l._helper.pointReflection=function(a,b){return h.normalizeMax(h.sub(h.scalmult(m.realmult(2,b.value[2]),a),h.scalmult(a.value[2],b)))};l._helper.conicOtherIntersection=function(a,b,c){var d=h.productMV(a,c);a=h.scalproduct(c,d);d=h.scalproduct(b,d);d=m.realmult(-2,d);b=h.scalmult(a,b);c=h.scalmult(d,c);c=h.add(b,
c);return c=h.normalizeMax(c)};l.Dist={};l.Dist.kind="V";l.Dist.signature=["P","P"];l.Dist.updatePosition=function(a){var b=v.csnames[a.args[1]].homog;a.value=h.abs(h.sub(h.normalizeZ(v.csnames[a.args[0]].homog),h.normalizeZ(b)))};l.Angle={};l.Angle.kind="V";l.Angle.signature=["L","L","P"];l.Angle.initialize=function(a){void 0===a.angle&&(a.angle=.5*Math.PI);Za(m._helper.input(a.angle))};l.Angle.updatePosition=function(a){var b=v.csnames[a.args[1]].homog,c=v.csnames[a.args[2]].homog,d=h.cross(v.csnames[a.args[0]].homog,
h.linfty),b=h.cross(b,h.linfty),c=h.crossratio3(d,b,h.ii,h.jj,c),c=m.mult(m.complex(0,.5),m.log(c)),d=(Bb().value.real-c.value.real)/Math.PI,b=Math.round(d);!lb&&.01<Math.abs(b-d)&&ec();c=m.complex(b*Math.PI+c.value.real,c.value.imag);Za(c);a.value=w.withUsage(c,"Angle")};l.Angle.stateSize=2;l.Text={};l.Text.kind="Text";l.Text.signature="**";l.Text.isMovable=!0;l.Text.updatePosition=Sa;l.Text.initialize=function(a){a.text=String(a.text);a.pos&&(a.homog=l._helper.initializePoint(a));a.dock&&(a.dock.offset=
a.dock.offset&&2===a.dock.offset.length?h.realVector([+a.dock.offset[0],+a.dock.offset[1]]):h.realVector([0,0]))};l.Text.getParamForInput=function(a,b,c){return l.Free.getParamForInput(a,b,c)};l.Text.getParamFromState=function(a){return a.homog};l.Text.putParamToState=function(a,b){a.homog=b};l.Calculation={};l.Calculation.kind="Text";l.Calculation.signature="**";l.Calculation.isMovable=!0;l.Calculation.updatePosition=Sa;l.Calculation.initialize=function(a){l.Text.initialize(a);a.calculation=Ua(a.text)};
l.Calculation.getText=function(a){return Z(z(a.calculation))};l.Calculation.getParamForInput=l.Text.getParamForInput;l.Calculation.getParamFromState=l.Text.getParamFromState;l.Calculation.putParamToState=l.Text.putParamToState;l.Equation={};l.Equation.kind="Text";l.Equation.isMovable=!0;l.Equation.signature="**";l.Equation.updatePosition=Sa;l.Equation.initialize=function(a){l.Text.initialize(a);a.calculation=Ua(a.text)};l.Equation.getText=function(a){return a.text+" = "+Z(z(a.calculation))};l.Equation.getParamForInput=
l.Text.getParamForInput;l.Equation.getParamFromState=l.Text.getParamFromState;l.Equation.putParamToState=l.Text.putParamToState;l.Evaluate={};l.Evaluate.kind="Text";l.Evaluate.isMovable=!0;l.Evaluate.signature="**";l.Evaluate.updatePosition=Sa;l.Evaluate.initialize=function(a){l.Text.initialize(a);a.calculation=Ua(a.text)};l.Evaluate.getText=function(a){z(a.calculation);return a.text};l.Evaluate.getParamForInput=l.Text.getParamForInput;l.Evaluate.getParamFromState=l.Text.getParamFromState;l.Evaluate.putParamToState=
l.Text.putParamToState;l.Plot={};l.Plot.kind="Text";l.Plot.isMovable=!0;l.Plot.signature="**";l.Plot.updatePosition=Sa;l.Plot.initialize=function(a){l.Text.initialize(a);a.calculation=Ua("plot(("+a.text+"))")};l.Plot.getText=function(a){z(a.calculation);return a.text};l.Plot.getParamForInput=l.Text.getParamForInput;l.Plot.getParamFromState=l.Text.getParamFromState;l.Plot.putParamToState=l.Text.putParamToState;l.Button={};l.Button.kind="Text";l.Button.signature="**";l.Button.isMovable=!0;l.Button.updatePosition=
Sa;l.Button.initialize=function(a){var b=document.createElement("button");Gc(a,"click",b)};l.Button.getParamForInput=l.Text.getParamForInput;l.Button.getParamFromState=l.Text.getParamFromState;l.Button.putParamToState=l.Text.putParamToState;l.Button.set_fillcolor=function(a,b){h._helper.isNumberVecN(b,3)&&(a.fillcolor=b.value.map(function(a){return a.value.real}),a.html.style.backgroundColor=x.makeColor(a.fillcolor,a.fillalpha))};l.ToggleButton={};l.ToggleButton.kind="Text";l.ToggleButton.signature=
"**";l.ToggleButton.isMovable=!0;l.ToggleButton.updatePosition=Sa;l.ToggleButton.initialize=function(a){var b;b=void 0;void 0===b&&(b="CindyJSid");b+=++Qa;var c=document.createElement("input"),d=document.createElement("label");c.setAttribute("id",b);d.setAttribute("for",b);c.setAttribute("type","checkbox");a.pressed&&(c.checked=!0);a.checkbox=c;Gc(a,"change",c,d)};l.ToggleButton.getParamForInput=l.Text.getParamForInput;l.ToggleButton.getParamFromState=l.Text.getParamFromState;l.ToggleButton.putParamToState=
l.Text.putParamToState;l.ToggleButton.set_fillcolor=l.Button.set_fillcolor;l.EditableText={};l.EditableText.kind="Text";l.EditableText.isMovable=!0;l.EditableText.signature=[];l.EditableText.updatePosition=Sa;l.EditableText.initialize=function(a){var b=document.createElement("input");b.setAttribute("type","text");b.className="CindyJS-editabletext";Ia(a.minwidth)&&(b.style.width=a.minwidth-3+"px");"string"===typeof a.text&&(b.value=a.text);b.addEventListener("keydown",function(c){13===c.keyCode&&(a.text=
a.html.value,b.blur())});b.addEventListener("change",function(b){a.text=a.html.value});Gc(a,"change",b)};l.EditableText.getText=function(a){return!1};l.EditableText.getParamForInput=l.Text.getParamForInput;l.EditableText.getParamFromState=l.Text.getParamFromState;l.EditableText.putParamToState=l.Text.putParamToState;l.EditableText.set_fillcolor=l.Button.set_fillcolor;l.EditableText.get_currenttext=function(a){return w.string(String(a.html.value))};l.EditableText.get_text=function(a){return w.string(String(a.text))};
l.EditableText.set_currenttext=function(a,b){a.html.value=a.text=Z(b)};l.EditableText.get_text=l.EditableText.get_text;l.EditableText.set_text=l.EditableText.set_currenttext;l.EditableText.get_val=l.EditableText.get_text;l.EditableText.set_val=l.EditableText.set_currenttext;l.EditableText.get_currenttext=l.EditableText.get_currenttext;l.EditableText.set_currenttext=l.EditableText.set_currenttext;l._helper.initializePoint=function(a){var b=0,c=0,d=0;if(a.pos){if("list"===a.pos.ctype&&h.isNumberVector(a.pos))return a.pos;
2===a.pos.length&&(b=a.pos[0],c=a.pos[1],d=1);3===a.pos.length&&(b=a.pos[0],c=a.pos[1],d=a.pos[2])}a=h.turnIntoCSList([m._helper.input(b),m._helper.input(c),m._helper.input(d)]);return a=h.normalizeMax(a)};l._helper.initializeLine=function(a){var b=0,c=0,d=0;if(a.pos){if("list"===a.pos.ctype&&h.isNumberVector(a.pos))return a.pos;3===a.pos.length&&(b=a.pos[0],c=a.pos[1],d=a.pos[2])}a=h.turnIntoCSList([m._helper.input(b),m._helper.input(c),m._helper.input(d)]);return a=h.normalizeMax(a)};l.Poly={};
l.Poly.kind="Poly";l.Poly.signature="P*";l.Poly.updatePosition=function(a){a.vertices=h.turnIntoCSList(a.args.map(function(a){return v.csnames[a].homog}))};var U=null;l.IFS={};l.IFS.kind="IFS";l.IFS.signature="**";l.IFS.signatureConstraints=function(a){for(var b=0;b<a.args.length;++b){var c=v.csnames[a.args[b]].kind;if("Tr"!==c&&"Mt"!==c)return!1}return 0<a.args.length};l.IFS.initialize=function(a){if(U)U.dirty=!0;else if(a=va.getBaseDir(),!1!==a){U={dirty:!1,params:{generation:0}};var b=U.worker=
new Worker(a+"ifs.js");b.onmessage=function(a){U.img&&"function"===typeof U.img.close&&U.img.close();if(!Yb){a=a.data;if(a.generation===U.params.generation){if(a.buffer){U.canvas||(U.canvas=document.createElement("canvas"),U.ctx=U.canvas.getContext("2d"));U.canvas.width=a.width;U.canvas.height=a.height;var d=new Uint8ClampedArray(a.buffer,a.imgPtr,a.width*a.height*4),d=new ImageData(d,a.width,a.height);U.ctx.putImageData(d,0,0);U.img=U.canvas}else U.img=a.img;e()}else U.img=null;a.buffer?b.postMessage({cmd:"next",
buffer:a.buffer},[a.buffer]):b.postMessage({cmd:"next"})}};jb.push(b.terminate.bind(b))}};l.IFS.updatePosition=function(a){U.dirty=!0};l.IFS.updateParameters=function(){if(U.worker){var a={cmd:"init",generation:U.params.generation,width:4*ca,height:4*da};a.systems=v.ifs.map(function(a){var b=0,d,e=a.ifs||[],f=a.args.map(function(a,b){var c=e[b]||{};return{prob:c.prob||1,color:c.color||[0,0,0]}});for(d=0;d<f.length;++d)b+=f[d].prob;d=h.realMatrix([[1,0,0],[0,1,0],[0,0,4]]);var k=h.productMM(y.toMat(),
d);for(d=0;d<a.args.length;++d){var n=v.csnames[a.args[d]],p=n.kind,r=f[d];r.kind=p;r.prob/=b;if("Tr"===p)n=h.normalizeMax(h.productMM(h.adjoint3(k),h.productMM(n.matrix,k))),h._helper.isAlmostReal(n)?r.mat=n.value.map(function(a){return a.value.map(function(a){return a.value.real})}):r.kind="cplx";else if("Mt"===p){var p=y.drawingstate.matrix,p={anti:0<p.det,ar:m.real(p.a),ai:m.real(p.c),br:m.real(p.tx),bi:m.real(-p.ty),cr:m.zero,ci:m.zero,dr:m.real(.25),di:m.zero},t={};l._helper.composeMtMt(t,n.moebius,
p);p=l._helper.inverseMoebius(p);l._helper.composeMtMt(t,p,t.moebius);p=t.moebius;p=h.turnIntoCSList([p.ar,p.ai,p.br,p.bi,p.cr,p.ci,p.dr,p.di]);h._helper.isAlmostReal(p)?(p=p.value,r.moebius={ar:p[0].value.real,ai:p[1].value.real,br:p[2].value.real,bi:p[3].value.real,cr:p[4].value.real,ci:p[5].value.real,dr:p[6].value.real,di:p[7].value.real,sign:n.moebius.anti?-1:1}):r.kind="cplx"}}return{trafos:f}});w.deeplyEqual(a,U.params)||(++a.generation,U.img=null,U.params=a,U.mat=y.drawingstate.matrix,U.worker.postMessage(a))}};
l.IFS.probSetter=function(a,b,c){"number"===c.ctype&&(b.ifs[a].prob=c.value.real,U.dirty=!0)};(function(){for(var a=0;10>a;++a)l.IFS["set_prob"+a]=l.IFS.probSetter.bind(null,a)})();l._helper.snapPointToLine=function(a,b){if(m._helper.isAlmostZero(a.value[2]))return a;var c=l._helper.projectPointToLine(a,b),c=h.normalizeZ(c),d=c.value[0].value.real,c=c.value[1].value.real,e=Math.round(d/za)*za,f=Math.round(c/za)*za,k=h.realVector([e,f,1]);.2>Math.abs(e-d)&&.2>Math.abs(f-c)&&m._helper.isAlmostZero(h.scalproduct(b,
k))&&(a=l._helper.projectPointToLine(k,b));return a};var Ac={CircleByRadius:"CircleMr",IntersectionCircleCircle:"IntersectCirCir",IntersectionConicConic:"IntersectConicConic",FreePoint:"Free",Orthogonal:"Perp",Parallel:"Para",Pole:"PolarOfLine",Polar:"PolarOfPoint",Arc:"ArcBy3",EuclideanMid:"Mid",AngularBisector:"AngleBisector",TransformConic:"TransformC",TransformSegment:"TransformS",TrMoebiusSegment:"TrMoebiusS",ReflectCC:"TrMoebiusC",ReflectCL:"TrMoebiusL",ReflectCP:"TrMoebiusP",ReflectCArc:"TrMoebiusArc",
ReflectCS:"TrMoebiusS",TrMoebiusCircle:"TrMoebiusC"},zd={CircleMFixedr:function(a){a.pinned=!0;a.type="CircleMr";return[a]},CircleByFixedRadius:function(a){a.pinned=!0;a.type="CircleMr";return[a]},IntersectionConicLine:function(a){a.args=[a.args[1],a.args[0]];a.type="IntersectLC";return[a]},angleBisector:function(a){var b={name:a.name+"_Intersection",type:"Meet",args:a.args,visible:!1};a.type="AngleBisector";a.args=[a.args[0],a.args[1],b.name];return[b,a]},Transform:function(a){var b=v.csnames[a.args[1]],
b={Tr:"Transform",Mt:"TrMoebius"}[v.csnames[a.args[0]].kind]+(b.isArc?"Arc":b.kind);if(l.hasOwnProperty(b))return a.type=b,[a];console.log(b+" not implemented yet");return[]},TrReflection:function(a){var b="TrReflection"+v.csnames[a.args[0]].kind;if(l.hasOwnProperty(b))return a.type=b,[a];console.log(b+" not implemented yet");return[]},TrCompose:function(a){var b="TrCompose"+a.args.map(function(a){return v.csnames[a].kind}).join("");if(l.hasOwnProperty(b))return a.type=b,[a];console.log(b+" not implemented yet");
return[]}},te="align alpha angle args arrow arrowposition arrowshape arrowsides arrowsize clip color dashtype drawtrace fillalpha fillcolor filled labeled labelpos name overhang pinned printname radius size text text_fontfamily textbold textitalics textsize tracedim tracelength traceskip tracing type visible".split(" ");sa.saveState=function(){return{geometry:ue()}};var ya={},Qd,Rb,Rd,Sd;Qd=[[],[.2],[.075,.225],[44/45,-56/15,32/9],[19372/6561,-25360/2187,64448/6561,-212/729],[9017/3168,-355/33,46732/
5247,49/176,-5103/18656],[35/384,0,500/1113,125/192,-2187/6784,11/84]];Rb=[0,.2,.3,.8,8/9,1,1];Rd=[35/384,0,500/1113,125/192,-2187/6784,11/84,0];Sd=[5179/57600,0,7571/16695,.6140625,-92097/339200,187/2100,.025];var Fa,ma=[],Hc=[],qc=!1;ya.tick=function(a){a/=Vb;for(var b=0;b<Vb;b++)ya.tick1(a),Ib+=a,z(R.simulationstep)};ya.tick1=function(a){for(var b=a,c=0;0<a&&c<.999*a||0>a&&c>.999*a;)b=ya.oneRKStep(b),c+=b,b=Math.min(2*b,a-c),b=Math.max(b,1E-16),ya.restorePosition(),ya.doCollisions(),ya.calculateForces(),
ya.moveToFinalPos();return!0};ya.restorePosition=function(){Fa.forEach(function(a){O[a.type].restorePos(a,9)})};ya.doCollisions=function(){Fa.forEach(function(a){O[a.type].doCollisions(a)})};ya.calculateForces=function(){Fa.forEach(function(a){O[a.type].calculateForces(a)})};ya.moveToFinalPos=function(){Fa.forEach(function(a){O[a.type].move(a)})};ya.oneRKStep=function(a){for(var b=function(a){Fa.forEach(function(b){O[b.type].initRK(b,a);O[b.type].storePosition(b)})},c=function(a){Fa.forEach(function(b){O[b.type].setToTimestep(b,
Rb[a])})},d=function(a){Fa.forEach(function(b){O[b.type].proceedMotion(b,Rb[a],a,Qd[a])})},e=function(){Fa.forEach(function(a){O[a.type].resetForces(a)})},f=function(a){Fa.forEach(function(b){O[b.type].calculateDelta(b,a)})},h=function(b){var c=0;Fa.forEach(function(a){O[a.type].proceedMotion(a,Rb[6],7,Rd);O[a.type].savePos(a,8);O[a.type].proceedMotion(a,Rb[6],7,Sd);O[a.type].savePos(a,9);c+=O[a.type].sqDist(a,8,9)});return c=Math.sqrt(c)/a},k=function(a){Fa.forEach(function(a){O[a.type].recallPosition(a)})},
l=!1;!l;){b(a);for(var m=0;7>m;m++)c(m),d(m),e(),ya.calculateForces(),f(m);h(a)>O.env.errorbound&&a>O.env.lowestdeltat?(a/=O.env.slowdownfactor,k()):l=!0}return a};var O={Mass:{reset:function(a,b){a.vel=[0,0,0];a.pos=[0,0,0,0];a.el=b;"undefined"===typeof a.mass&&(a.mass=1);"undefined"===typeof a.charge&&(a.charge=0);"undefined"===typeof a.friction&&(a.friction=0);a.lnfrict=0;"undefined"===typeof a.limitspeed&&(a.limitspeed=!1);"undefined"===typeof a.fixed&&(a.fixed=!1);"undefined"===typeof a.radius&&
(a.radius=1);a.internalmove=!1;a.fx=0;a.fy=0;a.fz=0;a.vx=a.vx||0;a.vy=a.vy||0;a.vz=a.vz||0;a.mtype=0;a.env=O.env;a.deltat=0;a.mx=0;a.my=0;a.mz=0;a.mvx=0;a.mvy=0;a.mvz=0;a.dx=[0,0,0,0,0,0,0,0,0,0];a.dy=[0,0,0,0,0,0,0,0,0,0];a.dz=[0,0,0,0,0,0,0,0,0,0];a.dvx=[0,0,0,0,0,0,0,0,0,0];a.dvy=[0,0,0,0,0,0,0,0,0,0];a.dvz=[0,0,0,0,0,0,0,0,0,0];a.midx=0;a.midy=0;a.midz=0;a.lx=0;a.ly=0;a.lz=0},resetForces:function(a){a.fx=0;a.fy=0;a.fz=0},getBlock:!1,setToTimestep:function(a,b,c){},initRK:function(a,b){var c=D.extractPoint(a.el.homog);
a.x=c.x;a.y=c.y;a.z=0;a.xo=a.x;a.yo=a.y;a.zo=a.z;a.vxo=a.vx;a.vyo=a.vy;a.vzo=a.vz;a.deltat=b;a.fx=0;a.fy=0;a.fz=0},setVelocity:function(a,b,c,d){d||(d=0);a.vx=b;a.vy=c;a.vz=d},move:function(a){a.pos=[a.x,a.y,1];a.internalmove=!0;ja&&aa.down&&a.el===ja.mover||La(a.el,h.realVector(a.pos),"homog");a.el.sx=a.x;a.el.sy=a.y;a.internalmove=!1},proceedMotion:function(a,b,c,d){if(!a.fixed)for(a.x=a.mx,a.y=a.my,a.z=a.mz,a.vx=a.mvx,a.vy=a.mvy,a.vz=a.mvz,b=0;b<c;b++)a.x+=d[b]*a.dx[b]*a.deltat,a.y+=d[b]*a.dy[b]*
a.deltat,a.z+=d[b]*a.dz[b]*a.deltat,a.vx+=d[b]*a.dvx[b]*a.deltat,a.vy+=d[b]*a.dvy[b]*a.deltat,a.vz+=d[b]*a.dvz[b]*a.deltat},calculateForces:function(a){var b=Math.sqrt(a.vx*a.vx+a.vy*a.vy+a.vz*a.vz);a.lnfrict=-Math.log((1-a.friction)*(1-a.env.friction)*(.1<b&&a.limitSpeed?.1/b:1));a.fx+=-a.vx*a.lnfrict*a.mass;a.fy+=-a.vy*a.lnfrict*a.mass;a.fz+=-a.vz*a.lnfrict*a.mass},calculateDelta:function(a,b){a.dx[b]=a.vx;a.dy[b]=a.vy;a.dz[b]=a.vz;a.dvx[b]=a.fx/a.mass;a.dvy[b]=a.fy/a.mass;a.dvz[b]=a.fz/a.mass},
savePos:function(a,b){a.dx[b]=a.x;a.dy[b]=a.y;a.dz[b]=a.z;a.dvx[b]=a.vx;a.dvy[b]=a.vy;a.dvz[b]=a.vz},restorePos:function(a,b){a.fixed||(a.x=a.dx[b],a.y=a.dy[b],a.z=a.dz[b],a.vx=a.dvx[b],a.vy=a.dvy[b],a.vz=a.dvz[b])},sqDist:function(a,b,c){var d=(a.dx[b]-a.dx[c])*(a.dx[b]-a.dx[c]),d=d+(a.dy[b]-a.dy[c])*(a.dy[b]-a.dy[c]),d=d+(a.dz[b]-a.dz[c])*(a.dz[b]-a.dz[c]),d=d+(a.dvx[b]-a.dvx[c])*(a.dvx[b]-a.dvx[c]),d=d+(a.dvy[b]-a.dvy[c])*(a.dvy[b]-a.dvy[c]);return d+=(a.dvz[b]-a.dvz[c])*(a.dvz[b]-a.dvz[c])},kineticEnergy:function(a){return.5*
a.mass*(a.vx*a.vx+a.vy*a.vy+a.vz*a.vz)},storePosition:function(a){a.mx=a.x;a.my=a.y;a.mz=a.z;a.mvx=a.vx;a.mvy=a.vy;a.mvz=a.vz},recallPosition:function(a){a.fixed||(a.x=a.mx,a.y=a.my,a.z=a.mz,a.vx=a.mvx,a.vy=a.mvy,a.vz=a.mvz)},doCollisions:function(a){}},Sun:{reset:function(a,b){a.vel=[0,0,0];a.pos=[0,0,0,0];a.el=b;"undefined"===typeof a.mass&&(a.mass=10);"undefined"===typeof a.friction&&(a.friction=0);a.charge=0;a.x=0;a.y=0;a.z=0},resetForces:function(a){},getBlock:!1,setToTimestep:function(a,b,c){},
initRK:function(a,b){var c=D.extractPoint(a.el.homog);a.x=c.x;a.y=c.y;a.z=0},setVelocity:function(a,b,c,d){},move:function(a){},proceedMotion:function(a,b,c,d){},calculateDelta:function(a,b){},calculateForces:function(a){for(var b=a.x,c=a.y,d=a.z,e=0;e<ma.length;e++){var f=ma[e],h=f.behavior.x,k=f.behavior.y,l=f.behavior.z,m=Math.sqrt((b-h)*(b-h)+(c-k)*(c-k)+(d-l)*(d-l)),k=(c-k)*a.mass*f.behavior.mass/(m*m*m),l=(d-l)*a.mass*f.behavior.mass/(m*m*m);f.behavior.fx+=(b-h)*a.mass*f.behavior.mass/(m*m*
m)*f.behavior.mass;f.behavior.fy+=k*f.behavior.mass;f.behavior.fz+=l*f.behavior.mass}},savePos:function(a,b){},restorePos:function(a,b){},sqDist:function(a,b,c){return 0},kineticEnergy:function(a){},storePosition:function(a){},recallPosition:function(a){},doCollisions:function(a){}},Velocity:{reset:function(a){var b=v.csnames[a.geo[1]];console.log(b);var c=D.extractPoint(b.homog);a=D.extractPoint(v.csnames[a.geo[2]].homog);b=b.behavior;O[b.type].setVelocity(b,a.x-c.x,a.y-c.y,0)},resetForces:function(a){},
getBlock:!1,setToTimestep:function(a,b,c){},initRK:function(a,b){},setVelocity:function(a,b,c,d){},move:function(a){var b=v.csnames[a.geo[2]];if(!ja||!aa.down||b!==ja.mover){var c=v.csnames[a.geo[1]];a=D.extractPoint(c.homog);c=c.behavior;a=h.realVector([a.x+c.vx,a.y+c.vy,1]);La(b,a,"homog")}},proceedMotion:function(a,b,c,d){},calculateForces:function(a){},calculateDelta:function(a,b){},savePos:function(a,b){},restorePos:function(a,b){},sqDist:function(a,b,c){return 0},kineticEnergy:function(a){},
storePosition:function(a){},recallPosition:function(a){},doCollisions:function(a){}},Gravity:{reset:function(a,b){a.vel=[0,0,0];a.pos=[0,0,0,0];a.el=b;"undefined"===typeof a.strength&&(a.strength=1);a.namea=b.args[0];a.nameb=b.args[1];a.ma=v.csnames[a.namea];a.mb=v.csnames[a.nameb]},resetForces:function(a){},getBlock:!1,setToTimestep:function(a,b,c){},initRK:function(a,b){},setVelocity:function(a,b,c,d){},move:function(a){},proceedMotion:function(a,b,c,d){},calculateDelta:function(a,b){},calculateForces:function(a){var b=
D.extractPoint(a.ma.homog),c=D.extractPoint(a.mb.homog),d=(c.x-b.x)*a.strength;a=(c.y-b.y)*a.strength;for(b=0;b<ma.length;b++)c=ma[b],c.behavior.fx+=d*c.behavior.mass,c.behavior.fy+=a*c.behavior.mass,c.behavior.fz+=0*c.behavior.mass},savePos:function(a,b){},restorePos:function(a,b){},sqDist:function(a,b,c){return 0},kineticEnergy:function(a){},storePosition:function(a){},recallPosition:function(a){},doCollisions:function(a){}},Spring:{reset:function(a,b){a.el=b;"undefined"===typeof a.strength&&(a.strength=
1);"undefined"===typeof a.amplitude&&(a.amplitude=0);"undefined"===typeof a.phase&&(a.phase=0);"undefined"===typeof a.speed&&(a.speed=1);"undefined"===typeof a.l0&&(a.l0=0);"undefined"===typeof a.stype&&(a.stype=1);"undefined"===typeof a.readOnInit&&(a.readOnInit=!1);a.namea=b.args[0];a.nameb=b.args[1];a.ma=v.csnames[a.namea];a.mb=v.csnames[a.nameb];var c=D.extractPoint(a.ma.homog),d=D.extractPoint(a.mb.homog);a.l0=Math.sqrt((c.x-d.x)*(c.x-d.x)+(c.y-d.y)*(c.y-d.y));a.env=O.env;a.ldiff=0},resetForces:function(a){},
getBlock:!1,setToTimestep:function(a,b,c){},initRK:function(a,b){},setVelocity:function(a,b,c,d){},move:function(a){},proceedMotion:function(a,b,c,d){},calculateForces:function(a){var b,c,d,e;!a.ma.behavior||ja&&aa.down&&a.ma===ja.mover?(c=D.extractPoint(a.ma.homog),b=c.x,d=c.y):(b=a.ma.behavior.x,d=a.ma.behavior.y);!a.mb.behavior||ja&&aa.down&&a.mb===ja.mover?(e=D.extractPoint(a.mb.homog),c=e.x,e=e.y):(c=a.mb.behavior.x,e=a.mb.behavior.y);var f=Math.sqrt((b-c)*(b-c)+(d-e)*(d-e)),h=a.l0;a.ldiff=f-
h;var k=a.stype;1===k&&(h=0);var l=0;if(2===k||3===k)l=a.ma.behavior.mass*a.mb.behavior.mass*a.strength;2===k&&(l=-l);var m,n;if(0===f||0!==k&&1!==k)if(a.ma.behavior&&a.mb.behavior&&0!==f){if(f*=f*f,2===k||3===k)m=(b-c)*l/f,n=(d-e)*l/f}else m=n=0;else m=-(b-c)*a.strength*(f-h)/f*a.env.springstrength,n=-(d-e)*a.strength*(f-h)/f*a.env.springstrength;a.ma.behavior&&(a.ma.behavior.fx+=m,a.ma.behavior.fy+=n);a.mb.behavior&&(a.mb.behavior.fx-=m,a.mb.behavior.fy-=n)},calculateDelta:function(a,b){},savePos:function(a,
b){},restorePos:function(a,b){},sqDist:function(a,b,c){return 0},kineticEnergy:function(a){},storePosition:function(a){},recallPosition:function(a){},doCollisions:function(a){}},det:function(a,b,c,d,e,f){return c*f-e*d+e*b-a*f+a*d-c*b},Bouncer:{reset:function(a,b){a.el=b;"undefined"===typeof a.xdamp&&(a.xdamp=0);"undefined"===typeof a.ydamp&&(a.ydamp=0);"undefined"===typeof a.motorchanger&&(a.motorchanger=!0);a.namea=b.args[0];a.nameb=b.args[1];a.ma=v.csnames[a.namea];a.mb=v.csnames[a.nameb];var c=
D.extractPoint(a.ma.homog),d=D.extractPoint(a.mb.homog);a.x1o=1.01*c.x-.01*d.x;a.y1o=1.01*c.y-.01*d.y;a.x2o=1.01*d.x-.01*c.x;a.y2o=1.01*d.y-.01*c.y;a.env=O.env},resetForces:function(a){},getBlock:!1,setToTimestep:function(a,b,c){},initRK:function(a,b){a.deltat=b},setVelocity:function(a,b,c,d){},move:function(a){},proceedMotion:function(a,b,c,d){},calculateForces:function(a){},calculateDelta:function(a,b){},savePos:function(a,b){},restorePos:function(a,b){},sqDist:function(a,b,c){return 0},kineticEnergy:function(a){},
storePosition:function(a){},recallPosition:function(a){},doCollisions:function(a){for(var b=D.extractPoint(a.ma.homog),c=D.extractPoint(a.mb.homog),d=b.x,b=b.y,e=c.x,c=c.y,f=a.x1o,h=a.y1o,k=a.x2o,l=a.y2o,n=Math.sqrt((d-e)*(d-e)+(b-c)*(b-c)),p=(d-e)/n,n=(b-c)/n,r=0;r<ma.length;r++){var t=ma[r],u=t.behavior.xo,v=t.behavior.yo,w=t.behavior.x,x=t.behavior.y,y=m.mult(m.complex(f,h),m.complex(e,c)),z=m.mult(m.complex(k,l),m.complex(d,b)),y=m.sub(y,z),z=m.mult(m.complex(u,v),m.complex(d,b)),y=m.add(y,z),
z=m.mult(m.complex(u,v),m.complex(e,c)),y=m.sub(y,z),z=m.sub(m.complex(f,h),m.complex(k,l)),y=m.div(y,z);0>O.det(d,b,e,c,w,x)*O.det(d,b,e,c,y.value.real,y.value.imag)&&0>O.det(d,b,w,x,y.value.real,y.value.imag)*O.det(e,c,w,x,y.value.real,y.value.imag)&&(v=t.behavior.mvx+a.deltat*(-y.value.real+t.behavior.xo),w=t.behavior.mvy+a.deltat*(-y.value.imag+t.behavior.yo),u=p*v+n*w,v=n*v-p*w,t.behavior.x=y.value.real,t.behavior.y=y.value.imag,t.behavior.vx=p*u*(1-a.xdamp),t.behavior.vy=n*u*(1-a.xdamp),t.behavior.vx+=
-n*v*(1-a.ydamp),t.behavior.vy+=p*v*(1-a.ydamp))}a.x1o=d;a.y1o=b;a.x2o=e;a.y2o=c}},Environment:{init:function(a){"undefined"===typeof a.gravity&&(a.gravity=0);"undefined"===typeof a.friction&&(a.friction=0);"undefined"===typeof a.springstrength&&(a.springstrength=1);"undefined"!==typeof a.accuracy&&(Vb=a.accuracy);"undefined"!==typeof a.deltat&&ha(a.deltat/.6);"undefined"===typeof a.charges&&(a.charges=!1);"undefined"===typeof a.balls&&(a.balls=!1);"undefined"===typeof a.newton&&(a.newton=!1);"undefined"===
typeof a.ballInteractionBoosting&&(a.ballInteractionBoosting=1);O.env=a;a.errorbound=.001;a.lowestdeltat=1E-7;a.slowdownfactor=2},reset:function(a){},resetForces:function(a){},getBlock:!1,setToTimestep:function(a,b,c){},initRK:function(a,b){},setVelocity:function(a,b,c,d){},move:function(a){},proceedMotion:function(a,b,c,d){},calculateForces:function(a){var b,c,d,e,f,h,k,l,m,n;if(a.newton)for(b=0;b<ma.length-1;b++)for(c=ma[b],d=c.behavior.x,e=c.behavior.y,f=b+1;f<ma.length;f++)h=ma[f],k=h.behavior.x,
l=h.behavior.y,n=Math.sqrt((d-k)*(d-k)+(e-l)*(e-l)),k=(d-k)*c.behavior.mass*h.behavior.mass/(n*n*n),l=(e-l)*c.behavior.mass*h.behavior.mass/(n*n*n),c.behavior.fx-=k,c.behavior.fy-=l,h.behavior.fx+=k,h.behavior.fy+=l;if(a.charges)for(b=0;b<ma.length-1;b++)for(c=ma[b],d=c.behavior.x,e=c.behavior.y,f=b+1;f<ma.length;f++)h=ma[f],k=h.behavior.x,l=h.behavior.y,n=Math.sqrt((d-k)*(d-k)+(e-l)*(e-l)),k=(d-k)*c.behavior.charge*h.behavior.charge/(n*n*n),l=(e-l)*c.behavior.charge*h.behavior.charge/(n*n*n),c.behavior.fx+=
k,c.behavior.fy+=l,h.behavior.fx-=k,h.behavior.fy-=l;if(a.balls)for(b=0;b<ma.length-1;b++)if(c=ma[b],0!==c.behavior.radius)for(d=c.behavior.x,e=c.behavior.y,f=b+1;f<ma.length;f++)h=ma[f],0!==h.behavior.radius&&(k=h.behavior.x,l=h.behavior.y,m=c.behavior.radius+h.behavior.radius,n=Math.sqrt((d-k)*(d-k)+(e-l)*(e-l)),0===a.ballInteractionBoosting?(k=(d-k)/(n*n*n)*(n>m?0:(n-m)*(n-m)),l=(e-l)/(n*n*n)*(n>m?0:(n-m)*(n-m))):1===a.ballInteractionBoosting?(k=(d-k)/(n*n*n*n)*(n>m?0:(n-m)*(n-m)),l=(e-l)/(n*n*
n*n)*(n>m?0:(n-m)*(n-m))):(k=(d-k)/(n*n*n*n*n)*(n>m?0:(n-m)*(n-m)),l=(e-l)/(n*n*n*n*n)*(n>m?0:(n-m)*(n-m))),c.behavior.fx+=k,c.behavior.fy+=l,h.behavior.fx-=k,h.behavior.fy-=l);for(b=0;b<ma.length;b++)c=ma[b],c.behavior.fx+=0,c.behavior.fy+=-a.gravity*c.behavior.mass,c.behavior.fz+=0},calculateDelta:function(a,b){},savePos:function(a,b){},restorePos:function(a,b){},sqDist:function(a,b,c){return 0},kineticEnergy:function(a){},storePosition:function(a){},recallPosition:function(a){},doCollisions:function(a){}}};
return sa};return F}(),createCindy=CindyJS;"undefined"!==typeof process&&"undefined"!==typeof module&&"undefined"!==typeof module.exports&&"undefined"===typeof window&&(module.exports=CindyJS);
//# sourceMappingURL=Cindy.js.map

