function nmap_extend(t,e){var a={};for(var r in t)a[r]=t[r];for(r in e)a[r]=e[r];return a}var nmap_element=function(t){function e(){}var a={id:1,klass:1,weight:1,x:0,y:0},r=nmap_extend(a,t);return e.attr=function(){return r},e.getX=function(){return parseFloat(r.x)},e.setX=function(t){r.x=t},e.getY=function(){return parseFloat(r.y)},e.setY=function(t){r.y=t},e.getId=function(){return r.id},e.setId=function(t){r.id=t},e.getKlass=function(){return parseFloat(r.klass)},e.setKlass=function(t){r.klass=t},e.getWeight=function(){return parseFloat(r.weight)},e.setWeight=function(t){r.weight=t},e},nmap_boundingbox=function(t){function e(){}var a={x:0,y:0,width:0,height:0,element:null},r=nmap_extend(a,t);return e.attr=function(){return r},e.setBounds=function(t){r=nmap_extend(r,t)},e.getElement=function(){return r.element},e.setElement=function(t){r.element=t},e},nmap=function(t){function e(){null===r.visualSpace&&(r.visualSpace=new nmap_boundingbox({x:r.x,y:r.y,height:r.height,width:r.width}))}var a={x:0,y:0,width:1,height:1,visualSpace:null,HORIZONTAL:!0,VERTICAL:!1},r=nmap_extend(a,t);return e(),e.attr=function(){return r},e.normalize=function(t){if(null!==t){for(var e=Number.MIN_VALUE,a=Number.MAX_VALUE,i=Number.MIN_VALUE,n=Number.MAX_VALUE,h=0;he.getX()?1:0},e.sortByY=function(t,e){return t.getY()e.getY()?1:0},e.alternateCut=function(t){var a={elements:null,visualSpace:r.visualSpace,bisection:null};if(t=nmap_extend(a,t),t.elements=e.normalize(t.elements),null===t.bisection){var i;t.visualSpace.attr().width>t.visualSpace.attr().height?t.bisection=r.HORIZONTAL:t.bisection=r.VERTICAL}var n=[];if(1===t.elements.length){var h=new nmap_boundingbox({x:t.visualSpace.attr().x,y:t.visualSpace.attr().y,width:t.visualSpace.attr().width,height:t.visualSpace.attr().height,element:t.elements[0]});n.push(h)}else{t.bisection===r.HORIZONTAL?t.elements.sort(e.sortByX):t.elements.sort(e.sortByY);for(var s=Math.floor(t.elements.length/2),l=t.elements.slice(0,s),g=t.elements.slice(s,t.elements.length),u=0,o=0;ot.visualSpace.attr().height&&(t.bisection=r.HORIZONTAL),t.bisection===r.HORIZONTAL?t.elements.sort(e.sortByX):t.elements.sort(e.sortByY);for(var h=0,s=0,l=0,g=0,u=1,o=0;o