text: !function(e){function i(e,i){var n=e.x-i.x,r=e.y-i.y;return t>n*n+r*r}function n(e){for(var t=e.head;t;){var i=t.next;t.next=t.prev,t.prev=i,t=i}var i=e.head;e.head=e.tail,e.tail=i}function r(e){this.level=e,this.s=null,this.count=0}function a(e){if(e)this.drawContour=e;else{var t=this;t.contours={},this.drawContour=function(e,i,n,a,o,s){var l=t.contours[s];l||(l=t.contours[s]=new r(o)),l.addSegment({x:e,y:i},{x:n,y:a})},this.contourList=function(){var e=[],i=t.contours;for(var n in i)for(var r=i[n].s,a=i[n].level;r;){var o=r.head,s=[];for(s.level=a,s.k=n;o&&o.p;)s.push(o.p),o=o.next;e.push(s),r=r.next}return e.sort(function(e,t){return e.k-t.k}),e}}this.h=new Array(5),this.sh=new Array(5),this.xh=new Array(5),this.yh=new Array(5)}e.Conrec=a;var t=1e-10;r.prototype.remove_seq=function(e){e.prev?e.prev.next=e.next:this.s=e.next,e.next&&(e.next.prev=e.prev),--this.count},r.prototype.addSegment=function(e,t){for(var r=this.s,a=null,o=null,s=!1,l=!1;r&&(null==a&&(i(e,r.head.p)?(a=r,s=!0):i(e,r.tail.p)&&(a=r)),null==o&&(i(t,r.head.p)?(o=r,l=!0):i(t,r.tail.p)&&(o=r)),null==o||null==a);)r=r.next;var c=(null!=a?1:0)|(null!=o?2:0);switch(c){case 0:var u={p:e,prev:null},d={p:t,next:null};u.next=d,d.prev=u,a={head:u,tail:d,next:this.s,prev:null,closed:!1},this.s&&(this.s.prev=a),this.s=a,++this.count;break;case 1:var f={p:t};s?(f.next=a.head,f.prev=null,a.head.prev=f,a.head=f):(f.next=null,f.prev=a.tail,a.tail.next=f,a.tail=f);break;case 2:var f={p:e};l?(f.next=o.head,f.prev=null,o.head.prev=f,o.head=f):(f.next=null,f.prev=o.tail,o.tail.next=f,o.tail=f);break;case 3:if(a===o){var f={p:a.tail.p,next:a.head,prev:null};a.head.prev=f,a.head=f,a.closed=!0;break}switch((s?1:0)|(l?2:0)){case 0:n(a);case 1:o.tail.next=a.head,a.head.prev=o.tail,o.tail=a.tail,this.remove_seq(a);break;case 3:n(a);case 2:a.tail.next=o.head,o.head.prev=a.tail,a.tail=o.tail,this.remove_seq(o)}}},a.prototype.contour=function(e,i,n,r,a,o,s,l,c){var u=this.h,d=this.sh,f=this.xh,p=this.yh,h=this.drawContour;this.contours={};for(var v,y,b,x,w,_,m=function(e,t){return(u[t]*f[e]-u[e]*f[t])/(u[t]-u[e])},g=function(e,t){return(u[t]*p[e]-u[e]*p[t])/(u[t]-u[e])},k=0,C=0,T=0,S=0,E=[0,1,1,0],N=[0,0,1,1],j=[[[0,0,8],[0,2,5],[7,6,9]],[[0,3,4],[1,3,1],[4,3,0]],[[9,6,7],[5,2,0],[8,0,0]]],D=a-1;D>=r;D--)for(var $=i;n-1>=$;$++){var A,M;if(A=Math.min(e[$][D],e[$][D+1]),M=Math.min(e[$+1][D],e[$+1][D+1]),w=Math.min(A,M),A=Math.max(e[$][D],e[$][D+1]),M=Math.max(e[$+1][D],e[$+1][D+1]),_=Math.max(A,M),_>=c[0]&&w<=c[l-1])for(var O=0;l>O;O++)if(c[O]>=w&&c[O]<=_){for(var I=4;I>=0;I--)I>0?(u[I]=e[$+E[I-1]][D+N[I-1]]-c[O],f[I]=o[$+E[I-1]],p[I]=s[D+N[I-1]]):(u[0]=.25*(u[1]+u[2]+u[3]+u[4]),f[0]=.5*(o[$]+o[$+1]),p[0]=.5*(s[D]+s[D+1])),u[I]>t?d[I]=1:u[I]<-t?d[I]=-1:d[I]=0;for(I=1;4>=I;I++)if(v=I,y=0,b=4!=I?I+1:1,x=j[d[v]+1][d[y]+1][d[b]+1],0!=x){switch(x){case 1:k=f[v],T=p[v],C=f[y],S=p[y];break;case 2:k=f[y],T=p[y],C=f[b],S=p[b];break;case 3:k=f[b],T=p[b],C=f[v],S=p[v];break;case 4:k=f[v],T=p[v],C=m(y,b),S=g(y,b);break;case 5:k=f[y],T=p[y],C=m(b,v),S=g(b,v);break;case 6:k=f[b],T=p[b],C=m(v,y),S=g(v,y);break;case 7:k=m(v,y),T=g(v,y),C=m(y,b),S=g(y,b);break;case 8:k=m(y,b),T=g(y,b),C=m(b,v),S=g(b,v);break;case 9:k=m(b,v),T=g(b,v),C=m(v,y),S=g(v,y)}h(k,T,C,S,c[O],O)}}}}}("undefined"!=typeof exports?exports:window);