From 9204a2f1162c47ee9bb86e297aaa3be65b6a5c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Thu, 7 Nov 2019 10:54:44 -0500 Subject: [PATCH 01/12] bump version, webpack plugin, artifacts --- dash_bio/bundle.js | 2 +- dash_bio/package-info.json | 2 +- package-lock.json | 8 ++++---- package.json | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dash_bio/bundle.js b/dash_bio/bundle.js index c30cc720e..3c92d5ede 100644 --- a/dash_bio/bundle.js +++ b/dash_bio/bundle.js @@ -1 +1 @@ -window.dash_bio=function(n){function t(t){for(var e,o,a=t[0],i=t[1],u=0,s=[];u0&&(o=1/Math.sqrt(o),n[0]=t[0]*o,n[1]=t[1]*o),n},u.dot=function(n,t){return n[0]*t[0]+n[1]*t[1]},u.cross=function(n,t,e){var r=t[0]*e[1]-t[1]*e[0];return n[0]=n[1]=0,n[2]=r,n},u.lerp=function(n,t,e,r){var o=t[0],a=t[1];return n[0]=o+r*(e[0]-o),n[1]=a+r*(e[1]-a),n},u.random=function(n,t){t=t||1;var e=2*r()*Math.PI;return n[0]=Math.cos(e)*t,n[1]=Math.sin(e)*t,n},u.transformMat2=function(n,t,e){var r=t[0],o=t[1];return n[0]=e[0]*r+e[2]*o,n[1]=e[1]*r+e[3]*o,n},u.transformMat2d=function(n,t,e){var r=t[0],o=t[1];return n[0]=e[0]*r+e[2]*o+e[4],n[1]=e[1]*r+e[3]*o+e[5],n},u.transformMat3=function(n,t,e){var r=t[0],o=t[1];return n[0]=e[0]*r+e[3]*o+e[6],n[1]=e[1]*r+e[4]*o+e[7],n},u.transformMat4=function(n,t,e){var r=t[0],o=t[1];return n[0]=e[0]*r+e[4]*o+e[12],n[1]=e[1]*r+e[5]*o+e[13],n},u.forEach=(i=u.create(),function(n,t,e,r,o,a){var u,s;for(t||(t=2),e||(e=0),s=r?Math.min(r*t+e,n.length):n.length,u=e;u0&&(a=1/Math.sqrt(a),n[0]=t[0]*a,n[1]=t[1]*a,n[2]=t[2]*a),n},s.dot=function(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]},s.cross=function(n,t,e){var r=t[0],o=t[1],a=t[2],i=e[0],u=e[1],s=e[2];return n[0]=o*s-a*u,n[1]=a*i-r*s,n[2]=r*u-o*i,n},s.lerp=function(n,t,e,r){var o=t[0],a=t[1],i=t[2];return n[0]=o+r*(e[0]-o),n[1]=a+r*(e[1]-a),n[2]=i+r*(e[2]-i),n},s.random=function(n,t){t=t||1;var e=2*r()*Math.PI,o=2*r()-1,a=Math.sqrt(1-o*o)*t;return n[0]=Math.cos(e)*a,n[1]=Math.sin(e)*a,n[2]=o*t,n},s.transformMat4=function(n,t,e){var r=t[0],o=t[1],a=t[2],i=e[3]*r+e[7]*o+e[11]*a+e[15];return i=i||1,n[0]=(e[0]*r+e[4]*o+e[8]*a+e[12])/i,n[1]=(e[1]*r+e[5]*o+e[9]*a+e[13])/i,n[2]=(e[2]*r+e[6]*o+e[10]*a+e[14])/i,n},s.transformMat3=function(n,t,e){var r=t[0],o=t[1],a=t[2];return n[0]=r*e[0]+o*e[3]+a*e[6],n[1]=r*e[1]+o*e[4]+a*e[7],n[2]=r*e[2]+o*e[5]+a*e[8],n},s.transformQuat=function(n,t,e){var r=t[0],o=t[1],a=t[2],i=e[0],u=e[1],s=e[2],l=e[3],c=l*r+u*a-s*o,f=l*o+s*r-i*a,p=l*a+i*o-u*r,h=-i*r-u*o-s*a;return n[0]=c*l+h*-i+f*-s-p*-u,n[1]=f*l+h*-u+p*-i-c*-s,n[2]=p*l+h*-s+c*-u-f*-i,n},s.rotateX=function(n,t,e,r){var o=[],a=[];return o[0]=t[0]-e[0],o[1]=t[1]-e[1],o[2]=t[2]-e[2],a[0]=o[0],a[1]=o[1]*Math.cos(r)-o[2]*Math.sin(r),a[2]=o[1]*Math.sin(r)+o[2]*Math.cos(r),n[0]=a[0]+e[0],n[1]=a[1]+e[1],n[2]=a[2]+e[2],n},s.rotateY=function(n,t,e,r){var o=[],a=[];return o[0]=t[0]-e[0],o[1]=t[1]-e[1],o[2]=t[2]-e[2],a[0]=o[2]*Math.sin(r)+o[0]*Math.cos(r),a[1]=o[1],a[2]=o[2]*Math.cos(r)-o[0]*Math.sin(r),n[0]=a[0]+e[0],n[1]=a[1]+e[1],n[2]=a[2]+e[2],n},s.rotateZ=function(n,t,e,r){var o=[],a=[];return o[0]=t[0]-e[0],o[1]=t[1]-e[1],o[2]=t[2]-e[2],a[0]=o[0]*Math.cos(r)-o[1]*Math.sin(r),a[1]=o[0]*Math.sin(r)+o[1]*Math.cos(r),a[2]=o[2],n[0]=a[0]+e[0],n[1]=a[1]+e[1],n[2]=a[2]+e[2],n},s.forEach=function(){var n=s.create();return function(t,e,r,o,a,i){var u,s;for(e||(e=3),r||(r=0),s=o?Math.min(o*e+r,t.length):t.length,u=r;u1?0:Math.acos(o)},s.str=function(n){return"vec3("+n[0]+", "+n[1]+", "+n[2]+")"},void 0!==n&&(n.vec3=s);var l={create:function(){var n=new e(4);return n[0]=0,n[1]=0,n[2]=0,n[3]=0,n},clone:function(n){var t=new e(4);return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t},fromValues:function(n,t,r,o){var a=new e(4);return a[0]=n,a[1]=t,a[2]=r,a[3]=o,a},copy:function(n,t){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n},set:function(n,t,e,r,o){return n[0]=t,n[1]=e,n[2]=r,n[3]=o,n},add:function(n,t,e){return n[0]=t[0]+e[0],n[1]=t[1]+e[1],n[2]=t[2]+e[2],n[3]=t[3]+e[3],n},subtract:function(n,t,e){return n[0]=t[0]-e[0],n[1]=t[1]-e[1],n[2]=t[2]-e[2],n[3]=t[3]-e[3],n}};l.sub=l.subtract,l.multiply=function(n,t,e){return n[0]=t[0]*e[0],n[1]=t[1]*e[1],n[2]=t[2]*e[2],n[3]=t[3]*e[3],n},l.mul=l.multiply,l.divide=function(n,t,e){return n[0]=t[0]/e[0],n[1]=t[1]/e[1],n[2]=t[2]/e[2],n[3]=t[3]/e[3],n},l.div=l.divide,l.min=function(n,t,e){return n[0]=Math.min(t[0],e[0]),n[1]=Math.min(t[1],e[1]),n[2]=Math.min(t[2],e[2]),n[3]=Math.min(t[3],e[3]),n},l.max=function(n,t,e){return n[0]=Math.max(t[0],e[0]),n[1]=Math.max(t[1],e[1]),n[2]=Math.max(t[2],e[2]),n[3]=Math.max(t[3],e[3]),n},l.scale=function(n,t,e){return n[0]=t[0]*e,n[1]=t[1]*e,n[2]=t[2]*e,n[3]=t[3]*e,n},l.scaleAndAdd=function(n,t,e,r){return n[0]=t[0]+e[0]*r,n[1]=t[1]+e[1]*r,n[2]=t[2]+e[2]*r,n[3]=t[3]+e[3]*r,n},l.distance=function(n,t){var e=t[0]-n[0],r=t[1]-n[1],o=t[2]-n[2],a=t[3]-n[3];return Math.sqrt(e*e+r*r+o*o+a*a)},l.dist=l.distance,l.squaredDistance=function(n,t){var e=t[0]-n[0],r=t[1]-n[1],o=t[2]-n[2],a=t[3]-n[3];return e*e+r*r+o*o+a*a},l.sqrDist=l.squaredDistance,l.length=function(n){var t=n[0],e=n[1],r=n[2],o=n[3];return Math.sqrt(t*t+e*e+r*r+o*o)},l.len=l.length,l.squaredLength=function(n){var t=n[0],e=n[1],r=n[2],o=n[3];return t*t+e*e+r*r+o*o},l.sqrLen=l.squaredLength,l.negate=function(n,t){return n[0]=-t[0],n[1]=-t[1],n[2]=-t[2],n[3]=-t[3],n},l.inverse=function(n,t){return n[0]=1/t[0],n[1]=1/t[1],n[2]=1/t[2],n[3]=1/t[3],n},l.normalize=function(n,t){var e=t[0],r=t[1],o=t[2],a=t[3],i=e*e+r*r+o*o+a*a;return i>0&&(i=1/Math.sqrt(i),n[0]=t[0]*i,n[1]=t[1]*i,n[2]=t[2]*i,n[3]=t[3]*i),n},l.dot=function(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]*t[3]},l.lerp=function(n,t,e,r){var o=t[0],a=t[1],i=t[2],u=t[3];return n[0]=o+r*(e[0]-o),n[1]=a+r*(e[1]-a),n[2]=i+r*(e[2]-i),n[3]=u+r*(e[3]-u),n},l.random=function(n,t){return t=t||1,n[0]=r(),n[1]=r(),n[2]=r(),n[3]=r(),l.normalize(n,n),l.scale(n,n,t),n},l.transformMat4=function(n,t,e){var r=t[0],o=t[1],a=t[2],i=t[3];return n[0]=e[0]*r+e[4]*o+e[8]*a+e[12]*i,n[1]=e[1]*r+e[5]*o+e[9]*a+e[13]*i,n[2]=e[2]*r+e[6]*o+e[10]*a+e[14]*i,n[3]=e[3]*r+e[7]*o+e[11]*a+e[15]*i,n},l.transformQuat=function(n,t,e){var r=t[0],o=t[1],a=t[2],i=e[0],u=e[1],s=e[2],l=e[3],c=l*r+u*a-s*o,f=l*o+s*r-i*a,p=l*a+i*o-u*r,h=-i*r-u*o-s*a;return n[0]=c*l+h*-i+f*-s-p*-u,n[1]=f*l+h*-u+p*-i-c*-s,n[2]=p*l+h*-s+c*-u-f*-i,n},l.forEach=function(){var n=l.create();return function(t,e,r,o,a,i){var u,s;for(e||(e=4),r||(r=0),s=o?Math.min(o*e+r,t.length):t.length,u=r;u.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(s.cross(d,t,e),n[0]=d[0],n[1]=d[1],n[2]=d[2],n[3]=1+r,y.normalize(n,n))}),y.setAxes=(g=p.create(),function(n,t,e,r){return g[0]=e[0],g[3]=e[1],g[6]=e[2],g[1]=r[0],g[4]=r[1],g[7]=r[2],g[2]=-t[0],g[5]=-t[1],g[8]=-t[2],y.normalize(n,y.fromMat3(n,g))}),y.clone=l.clone,y.fromValues=l.fromValues,y.copy=l.copy,y.set=l.set,y.identity=function(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n},y.setAxisAngle=function(n,t,e){e*=.5;var r=Math.sin(e);return n[0]=r*t[0],n[1]=r*t[1],n[2]=r*t[2],n[3]=Math.cos(e),n},y.add=l.add,y.multiply=function(n,t,e){var r=t[0],o=t[1],a=t[2],i=t[3],u=e[0],s=e[1],l=e[2],c=e[3];return n[0]=r*c+i*u+o*l-a*s,n[1]=o*c+i*s+a*u-r*l,n[2]=a*c+i*l+r*s-o*u,n[3]=i*c-r*u-o*s-a*l,n},y.mul=y.multiply,y.scale=l.scale,y.rotateX=function(n,t,e){e*=.5;var r=t[0],o=t[1],a=t[2],i=t[3],u=Math.sin(e),s=Math.cos(e);return n[0]=r*s+i*u,n[1]=o*s+a*u,n[2]=a*s-o*u,n[3]=i*s-r*u,n},y.rotateY=function(n,t,e){e*=.5;var r=t[0],o=t[1],a=t[2],i=t[3],u=Math.sin(e),s=Math.cos(e);return n[0]=r*s-a*u,n[1]=o*s+i*u,n[2]=a*s+r*u,n[3]=i*s-o*u,n},y.rotateZ=function(n,t,e){e*=.5;var r=t[0],o=t[1],a=t[2],i=t[3],u=Math.sin(e),s=Math.cos(e);return n[0]=r*s+o*u,n[1]=o*s-r*u,n[2]=a*s+i*u,n[3]=i*s-a*u,n},y.calculateW=function(n,t){var e=t[0],r=t[1],o=t[2];return n[0]=e,n[1]=r,n[2]=o,n[3]=Math.sqrt(Math.abs(1-e*e-r*r-o*o)),n},y.dot=l.dot,y.lerp=l.lerp,y.slerp=function(n,t,e,r){var o,a,i,u,s,l=t[0],c=t[1],f=t[2],p=t[3],h=e[0],d=e[1],m=e[2],v=e[3];return(a=l*h+c*d+f*m+p*v)<0&&(a=-a,h=-h,d=-d,m=-m,v=-v),1-a>1e-6?(o=Math.acos(a),i=Math.sin(o),u=Math.sin((1-r)*o)/i,s=Math.sin(r*o)/i):(u=1-r,s=r),n[0]=u*l+s*h,n[1]=u*c+s*d,n[2]=u*f+s*m,n[3]=u*p+s*v,n},y.invert=function(n,t){var e=t[0],r=t[1],o=t[2],a=t[3],i=e*e+r*r+o*o+a*a,u=i?1/i:0;return n[0]=-e*u,n[1]=-r*u,n[2]=-o*u,n[3]=a*u,n},y.conjugate=function(n,t){return n[0]=-t[0],n[1]=-t[1],n[2]=-t[2],n[3]=t[3],n},y.length=l.length,y.len=y.length,y.squaredLength=l.squaredLength,y.sqrLen=y.squaredLength,y.normalize=l.normalize,y.fromMat3=function(n,t){var e,r=t[0]+t[4]+t[8];if(r>0)e=Math.sqrt(r+1),n[3]=.5*e,e=.5/e,n[0]=(t[5]-t[7])*e,n[1]=(t[6]-t[2])*e,n[2]=(t[1]-t[3])*e;else{var o=0;t[4]>t[0]&&(o=1),t[8]>t[3*o+o]&&(o=2);var a=(o+1)%3,i=(o+2)%3;e=Math.sqrt(t[3*o+o]-t[3*a+a]-t[3*i+i]+1),n[o]=.5*e,e=.5/e,n[3]=(t[3*a+i]-t[3*i+a])*e,n[a]=(t[3*a+o]+t[3*o+a])*e,n[i]=(t[3*i+o]+t[3*o+i])*e}return n},y.str=function(n){return"quat("+n[0]+", "+n[1]+", "+n[2]+", "+n[3]+")"},void 0!==n&&(n.quat=y)}(e.exports)}()},function(n,t,e){"use strict";var r=e(7),o=e(6),a=e(20);function i(n,t,e){return Math.min(t,Math.max(n,e))}n.exports.new=function(){return{aspect:1,zoom:.125,translation:{x:0,y:0},atomScale:.6,relativeAtomScale:1,bondScale:.5,rotation:r.mat4.create(),ao:.75,aoRes:256,brightness:.5,outline:0,spf:32,bonds:!1,bondThreshold:1.2,bondShade:.5,atomShade:.5,resolution:768,dofStrength:0,dofPosition:.5,fxaa:1}},n.exports.center=function(n,t){for(var e=-1/0,a=1/0,i=-1/0,u=1/0,s=0;st&&(t=u,n.farAtom=r)}return n.farAtom});n.exports.getRadius=function(n){var t=u(n),e=a.MAX_ATOM_RADIUS,r=2.5*Math.sqrt(e*e+e*e+e*e);return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z)+r}},function(n,t,e){n.exports=function(n){function t(r){if(e[r])return e[r].exports;var o=e[r]={exports:{},id:r,loaded:!1};return n[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var e={};return t.m=n,t.c=e,t.p="",t(0)}([function(n,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FornaContainer=function(n,t){function e(n){return Math.sqrt(n[0]*n[0]+n[1]*n[1])}function o(n){var t=n,r=n.prevNode;if(null!==r&&n.linked){var o=[-(t.x-r.x),-(t.y-r.y)],i=[-(o=[o[0]/e(o),o[1]/e(o)])[1],o[0]],u=[n.radius*o[0],n.radius*o[1]],s="M"+(u[0]+6*(o[0]+i[0])/2)+","+(u[1]+6*(o[1]+i[1])/2)+"L"+u[0]+","+u[1]+"L"+(u[0]+6*(o[0]-i[0])/2)+","+(u[1]+6*(o[1]-i[1])/2);a.default.select(this).attr("d",s)}}function c(n){return"basepair"==n.linkType||"backbone"==n.linkType||"pseudoknot"==n.linkType||"label_link"==n.linkType||"external"==n.linkType||"chain_chain"==n.linkType}function f(n,t,e){if(n.hasOwnProperty(t.num)){var r=parseFloat(n[t.num]);return isNaN(r)?n[t.num]:e(r)}return"white"}function p(){b=null,x=null}function h(n){var t=R.selectAll("g.gnode");return t.filter(function(n){return n.selected})}function d(n){var t=n.radius+16,e=n.x-t,r=n.x+t,o=n.y-t,a=n.y+t;return function(t,i,u,s,l){if(t.point&&t.point!==n){var c=n.x-t.point.x,f=n.y-t.point.y,p=Math.sqrt(c*c+f*f),h=n.radius+t.point.radius;h>p&&(p=(p-h)/p*.1,n.x-=c*=p,n.y-=f*=p,t.point.x+=c,t.point.y+=f)}return i>r||e>s||u>a||o>l}}function m(){if(!g.deaf&&!N){switch(a.default.event.keyCode){case 16:N=!0;break;case 17:O=!0;break;case 67:g.centerView()}(N||O)&&(S.call(g.zoomer).on("mousedown.zoom",null).on("touchstart.zoom",null).on("touchmove.zoom",null).on("touchend.zoom",null),T.selectAll("g.gnode").on("mousedown.drag",null)),O&&(A.select(".background").style("cursor","crosshair"),A.call(g.brusher))}}function v(){N=!1,O=!1,A.call(g.brusher).on("mousedown.brush",null).on("touchstart.brush",null).on("touchmove.brush",null).on("touchend.brush",null),A.select(".background").style("cursor","auto"),S.call(g.zoomer),T.selectAll("g.gnode").call(C)}var g=this;if(g.options={displayAllLinks:!1,labelInterval:10,applyForce:!0,initialSize:null,allowPanningAndZooming:!0,transitionDuration:500,resizeSvgOnResize:!0},arguments.length>1)for(var y in t)g.options.hasOwnProperty(y)&&(g.options[y]=t[y]);null!==g.options.initialSize?(g.options.svgW=g.options.initialSize[0],g.options.svgH=g.options.initialSize[1]):(g.options.svgW=800,g.options.svgH=800),a.default.scale.category20();var b=null,x=null,M=a.default.scale.linear().domain([0,g.options.svgW]).range([0,g.options.svgW]),w=a.default.scale.linear().domain([0,g.options.svgH]).range([0,g.options.svgH]),k=g.graph={nodes:[],links:[]};g.linkStrengths={pseudoknot:0,proteinChain:0,chainChain:0,intermolecule:10,external:0,other:10},g.displayParameters={displayBackground:"true",displayNumbering:"true",displayNodeOutline:"true",displayNodeLabel:"true",displayLinks:"true",displayPseudoknotLinks:"true",displayProteinLinks:"true"},g.colorScheme="structure",g.customColors={},g.animation=g.options.applyForce,g.deaf=!1,g.rnas={},g.extraLinks=[],Array.prototype.equals=function(n){if(!n)return!1;if(this.length!=n.length)return!1;for(var t=0,e=this.length;e>t;t++)if(this[t]instanceof Array&&n[t]instanceof Array){if(!this[t].equals(n[t]))return!1}else if(this[t]!=n[t])return!1;return!0},g.createInitialLayout=function(n,t){var e={sequence:"",name:"empty",positions:[],labelInterval:g.options.labelInterval,avoidOthers:!0,uids:[],circularizeExternal:!0};if(2==arguments.length)for(var r in t)e.hasOwnProperty(r)&&(e[r]=t[r]);var o=new u.RNAGraph(e.sequence,n,e.name);o.circularizeExternal=e.circularizeExternal;var a=o.recalculateElements();return 0===e.positions.length&&(e.positions=(0,s.simpleXyCoordinates)(a.pairtable)),a=a.elementsToJson().addUids(e.uids).addPositions("nucleotide",e.positions).addLabels(1,e.labelInterval).reinforceStems().reinforceLoops().connectFakeNodes().reassignLinkUids().breakNodesToFakeNodes()},g.addRNA=function(n,t){var e=g.createInitialLayout(n,t);if(1===arguments.length&&(t={}),"extraLinks"in t){var r=g.addExternalLinks(e,t.extraLinks);g.extraLinks=g.extraLinks.concat(r)}return"avoidOthers"in t?g.addRNAJSON(e,t.avoidOthers):g.addRNAJSON(e,!0),e},g.addExternalLinks=function(n,t){for(var e=[],r=0;r0?a.default.max(g.graph.nodes.map(function(n){return n.x})):0,r=a.default.min(n.nodes.map(function(n){return n.x})),n.nodes.forEach(function(n){n.x+=e-r+20,n.px+=e-r})),n.nodes.forEach(function(t){t.rna=n}),g.rnas[n.uid]=n,g.recalculateGraph(),g.update(),g.centerView(),n},g.transitionRNA=function(n,t){var e=g.options.transitionDuration,r=g.graph.nodes.filter(function(n){return"nucleotide"==n.nodeType}).map(function(n){return n.uid}),a={uids:r},i=g.createInitialLayout(n,a),u=R.selectAll("g.gnode").data(i.nodes,U),e=g.options.transitionDuration;0===e?u.attr("transform",function(n){return"translate("+[n.x,n.y]+")"}):u.transition().attr("transform",function(n){return"translate("+[n.x,n.y]+")"}).duration(e);var s=E.selectAll("line.link").data(i.links.filter(c),L),l=g.createNewNodes(u.enter()).attr("transform",function(n){return void 0!==n.x&&void 0!==n.y?"translate("+[0,0]+")":""});0===e?u.exit().remove():u.exit().transition().attr("transform",function(n){return void 0!==n.x&&void 0!==n.y?"translate("+[0,0]+")":""}),u.select("path").each(o),g.graph.nodes=u.data(),g.updateStyle(),g.centerView(e),s.exit().remove(),0===e?(s.attr("x1",function(n){return n.source.x}).attr("y1",function(n){return n.source.y}).attr("x2",function(n){return n.target.x}).attr("y2",function(n){return n.target.y}),g.createNewLinks(s.enter()),g.graph.links=s.data(),g.updateStyle()):s.transition().attr("x1",function(n){return n.source.x}).attr("y1",function(n){return n.source.y}).attr("x2",function(n){return n.target.x}).attr("y2",function(n){return n.target.y}).duration(e).call(function(n,t){0===n.size()&&setTimeout(t,e);var r=0;n.each(function(){++r}).each("end",function(){--r||t.apply(this,arguments)})},function(){g.createNewLinks(s.enter()),g.graph.links=s.data(),g.updateStyle(),void 0!==t&&t()}),0===e?l.attr("transform",function(n){return void 0!==n.x&&void 0!==n.y?"translate("+[n.x,n.y]+")":""}):l.transition().attr("transform",function(n){return void 0!==n.x&&void 0!==n.y?"translate("+[n.x,n.y]+")":""})},g.recalculateGraph=function(){for(var n in g.graph.nodes=[],g.graph.links=[],g.rnas)g.graph.nodes=g.graph.nodes.concat(g.rnas[n].nodes),g.graph.links=g.graph.links.concat(g.rnas[n].links);for(var t={},e=0;e0?(maxX=a.default.max(g.graph.nodes.map(function(n){return n.x})),maxY=a.default.max(g.graph.nodes.map(function(n){return n.y}))):(maxX=0,maxY=0),n.nodes.forEach(function(n){n.rna.uid in g.rnas||(g.rnas[n.rna.uid]=n.rna),n.x+=maxX,n.px+=maxX}),r=new u.RNAGraph("",""),r.nodes=n.nodes,r.links=n.links,g.recalculateGraph(),g.update(),g.centerView()},g.addCustomColors=function(n){g.customColors=n},g.addCustomColorsText=function(n){var t=new l.ColorScheme(n);g.customColors=t.colorsJson,g.changeColorScheme("custom")},g.clearNodes=function(){g.graph.nodes=[],g.graph.links=[],g.rnas={},g.extraLinks=[],g.update()},g.toJSON=function(){var n={rnas:g.rnas,extraLinks:g.extraLinks},t=JSON.stringify(n,function(n,t){return"rna"==n?void 0:t},"\t");return t},g.fromJSON=function(n){var t,e;try{var o=JSON.parse(n);t=o.rnas,e=o.extraLinks}catch(n){throw n}for(var a in t)"rna"==t[a].type?(r=new u.RNAGraph,r.seq=t[a].seq,r.dotbracket=t[a].dotbracket,r.circular=t[a].circular,r.pairtable=t[a].pairtable,r.uid=t[a].uid,r.structName=t[a].structName,r.nodes=t[a].nodes,r.links=t[a].links,r.rnaLength=t[a].rnaLength,r.elements=t[a].elements,r.nucsToNodes=t[a].nucsToNodes,r.pseudoknotPairs=t[a].pseudoknotPairs):(r=new ProteinGraph,r.size=t[a].size,r.nodes=t[a].nodes,r.uid=t[a].uid),g.addRNAJSON(r,!1);e.forEach(function(n){g.extraLinks.push(n)}),g.recalculateGraph(),g.update()},g.setSize=function(){if(null==g.options.initialSize){var t=a.default.select(n).node().offsetHeight,e=a.default.select(n).node().offsetWidth;g.options.svgW=e,g.options.svgH=t,M.range([0,e]).domain([0,e]),w.range([0,t]).domain([0,t]),g.zoomer.x(M).y(w),g.brusher.x(M).y(w),g.centerView(),g.options.resizeSvgOnResize&&_.attr("width",e).attr("height",t)}},g.setOutlineColor=function(n){var t=R.selectAll("g.gnode").select("[node_type=nucleotide]");t.style("fill",n)},g.changeColorScheme=function(n){var t=R.selectAll("[node_type=protein]");t.classed("protein",!0).attr("r",function(n){return n.radius});var e=(R.selectAll("g.gnode"),R.selectAll("g.gnode").selectAll("circle"),R.selectAll("g.gnode").select("[node_type=nucleotide]"));if(g.colorScheme=n,"sequence"==n){var r=a.default.scale.ordinal().range(["#dbdb8d","#98df8a","#ff9896","#aec7e8","#aec7e8"]).domain(["A","C","G","U","T"]);e.style("fill",function(n){return r(n.name)})}else if("structure"==n){var r=a.default.scale.category10().domain(["s","m","i","e","t","h","x"]).range(["lightgreen","#ff9896","#dbdb8d","lightsalmon","lightcyan","lightblue","transparent"]);e.style("fill",function(n){return r(n.elemType)})}else if("positions"==n)e.style("fill",function(n){var t=a.default.scale.linear().range(["#98df8a","#dbdb8d","#ff9896"]).interpolate(a.default.interpolateLab).domain([1,1+(n.rna.rnaLength-1)/2,n.rna.rnaLength]);return t(n.num)});else if("custom"==n){if(void 0!==g.customColors&&"domain"in g.customColors&&"range"in g.customColors)var r=a.default.scale.linear().interpolate(a.default.interpolateLab).domain(g.customColors.domain).range(g.customColors.range);e.style("fill",function(n){if(void 0===g.customColors||!g.customColors.hasOwnProperty("colorValues"))return"white";if(g.customColors.colorValues.hasOwnProperty(n.structName)&&g.customColors.colorValues[n.structName].hasOwnProperty(n.num)){var t=g.customColors.colorValues[n.structName];return f(t,n,r)}if(g.customColors.colorValues.hasOwnProperty("")){var t=g.customColors.colorValues[""];return f(t,n,r)}return"white"})}},window.addEventListener("resize",g.setSize,!1),g.zoomer=a.default.behavior.zoom().scaleExtent([.1,10]).x(M).y(w).on("zoomstart",function(){var n=R.selectAll("g.gnode").selectAll(".outline_node");n.each(function(n){n.selected=!1,n.previouslySelected=!1}),n.classed("selected",!1)}).on("zoom",function(){T.attr("transform","translate("+a.default.event.translate+") scale("+a.default.event.scale+")")}),a.default.select(n).select("svg").remove();var _=a.default.select(n).attr("tabindex",1).on("keydown.brush",m).on("keyup.brush",v).each(function(){this.focus()}).append("svg:svg").attr("width",g.options.svgW).attr("height",g.options.svgH).attr("id","plotting-area");g.options.svg=_;var S=_.append("svg:g").on("mousemove",function(){b&&(mpos=a.default.mouse(T.node()),P.attr("x1",b.x).attr("y1",b.y).attr("x2",mpos[0]).attr("y2",mpos[1]))}).on("mousedown",function(){}).on("mouseup",function(){b&&P.attr("class","drag_line_hidden"),p()});g.options.allowPanningAndZooming&&S.call(g.zoomer);var A=S.append("g").datum(function(){return{selected:!1,previouslySelected:!1}}).attr("class","brush"),T=S.append("svg:g"),E=T.append("svg:g"),R=T.append("svg:g");g.brusher=a.default.svg.brush().x(M).y(w).on("brushstart",function(n){var t=R.selectAll("g.gnode").selectAll(".outline_node");t.each(function(n){n.previouslySelected=O&&n.selected})}).on("brush",function(){var n=R.selectAll("g.gnode").selectAll(".outline_node"),t=a.default.event.target.extent();n.classed("selected",function(n){return n.selected=g.options.applyForce&&n.previouslySelected^(t[0][0]<=n.x&&n.x-1){if(n.source.rna==n.target.rna){var t=n.source.rna;t.addPseudoknots(),t.pairtable[n.source.num]=0,t.pairtable[n.target.num]=0,D(t)}else extraLinkIndex=g.extraLinks.indexOf(n),g.extraLinks.splice(extraLinkIndex,1);g.recalculateGraph()}g.update()}(n))};g.addLink=function(n){n.source.rna==n.target.rna?(r=n.source.rna,r.pairtable[n.source.num]=n.target.num,r.pairtable[n.target.num]=n.source.num,D(r)):(n.linkType="intermolecule",g.extraLinks.push(n)),g.recalculateGraph(),g.update()};var F=function(n){if(!a.default.event.defaultPrevented){if(!O){var t=R.selectAll("g.gnode").selectAll(".outline_node");t.classed("selected",function(n){return n.selected=g.options.applyForce&&(n.previouslySelected=!1)})}a.default.select(this).select("circle").classed("selected",n.selected=g.options.applyForce&&!n.previouslySelected)}},q=function(n){if(b){if((x=n)==b)return void p();var t={source:b,target:x,linkType:"basepair",value:1,uid:generateUUID()};for(i=0;in?-1:n>t?1:n>=t?0:NaN}function s(n){return null===n?NaN:+n}function l(n){return!isNaN(n)}function c(n){return{left:function(t,e,r,o){for(arguments.length<3&&(r=0),arguments.length<4&&(o=t.length);o>r;){var a=r+o>>>1;n(t[a],e)<0?r=a+1:o=a}return r},right:function(t,e,r,o){for(arguments.length<3&&(r=0),arguments.length<4&&(o=t.length);o>r;){var a=r+o>>>1;n(t[a],e)>0?o=a:r=a+1}return r}}}function f(n){return n.length}function p(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function h(){this._=Object.create(null)}function d(n){return(n+="")===da||n[0]===ma?ma+n:n}function m(n){return(n+="")[0]===ma?n.slice(1):n}function v(n){return d(n)in this._}function g(n){return(n=d(n))in this._&&delete this._[n]}function y(){var n=[];for(var t in this._)n.push(m(t));return n}function b(){var n=0;for(var t in this._)++n;return n}function x(){for(var n in this._)return!1;return!0}function M(){this._=Object.create(null)}function w(n){return n}function k(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function _(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=va.length;r>e;++e){var o=va[e]+t;if(o in n)return o}}function S(){}function A(){}function T(n){function t(){for(var t,r=e,o=-1,a=r.length;++oe;e++)for(var o,a=n[e],i=0,u=a.length;u>i;i++)(o=a[i])&&t(o,i,e);return n}function Y(n){return ya(n,_a),n}function W(n,t,e){function r(){var t=this[o];t&&(this.removeEventListener(n,t,t.$),delete this[o])}var o="__on"+n,a=n.indexOf("."),i=Z;a>0&&(n=n.slice(0,a));var u=Sa.get(n);return u&&(n=u,i=J),a?t?function(){var a=i(t,aa(arguments));r.call(this),this.addEventListener(n,this[o]=a,a.$=e),a._=t}:r:t?S:function(){var t,e=new RegExp("^__on([^.]+)"+ra.requote(n)+"$");for(var r in this)if(t=r.match(e)){var o=this[r];this.removeEventListener(t[1],o,o.$),delete this[r]}}}function Z(n,t){return function(e){var r=ra.event;ra.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{ra.event=r}}}function J(n,t){var e=Z(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function $(n){var t=".dragsuppress-"+ ++Ta,e="click"+t,r=ra.select(i(n)).on("touchmove"+t,E).on("dragstart"+t,E).on("selectstart"+t,E);if(null==Aa&&(Aa=!("onselectstart"in n)&&_(n.style,"userSelect")),Aa){var o=a(n).style,u=o[Aa];o[Aa]="none"}return function(n){if(r.on(t,null),Aa&&(o[Aa]=u),n){var a=function(){r.on(e,null)};r.on(e,function(){E(),a()},!0),setTimeout(a,0)}}}function K(n,t){t.changedTouches&&(t=t.changedTouches[0]);var e=n.ownerSVGElement||n;if(e.createSVGPoint){var r=e.createSVGPoint();if(0>Ea){var o=i(n);if(o.scrollX||o.scrollY){var a=(e=ra.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important"))[0][0].getScreenCTM();Ea=!(a.f||a.e),e.remove()}}return Ea?(r.x=t.pageX,r.y=t.pageY):(r.x=t.clientX,r.y=t.clientY),[(r=r.matrixTransform(n.getScreenCTM().inverse())).x,r.y]}var u=n.getBoundingClientRect();return[t.clientX-u.left-n.clientLeft,t.clientY-u.top-n.clientTop]}function Q(){return ra.event.changedTouches[0].identifier}function nn(n){return n>0?1:0>n?-1:0}function tn(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function en(n){return n>1?0:-1>n?Na:Math.acos(n)}function rn(n){return n>1?La:-1>n?-La:Math.asin(n)}function on(n){return((n=Math.exp(n))+1/n)/2}function an(n){return(n=Math.sin(n/2))*n}function un(){}function sn(n,t,e){return this instanceof sn?(this.h=+n,this.s=+t,void(this.l=+e)):arguments.length<2?n instanceof sn?new sn(n.h,n.s,n.l):wn(""+n,kn,sn):new sn(n,t,e)}function ln(n,t,e){function r(n){return Math.round(255*function(n){return n>360?n-=360:0>n&&(n+=360),60>n?o+(a-o)*n/60:180>n?a:240>n?o+(a-o)*(240-n)/60:o}(n))}var o,a;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,o=2*(e=0>e?0:e>1?1:e)-(a=.5>=e?e*(1+t):e+t-e*t),new yn(r(n+120),r(n),r(n-120))}function cn(n,t,e){return this instanceof cn?(this.h=+n,this.c=+t,void(this.l=+e)):arguments.length<2?n instanceof cn?new cn(n.h,n.c,n.l):dn(n instanceof pn?n.l:(n=_n((n=ra.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new cn(n,t,e)}function fn(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new pn(e,Math.cos(n*=Ua)*t,Math.sin(n)*t)}function pn(n,t,e){return this instanceof pn?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof pn?new pn(n.l,n.a,n.b):n instanceof cn?fn(n.h,n.c,n.l):_n((n=yn(n)).r,n.g,n.b):new pn(n,t,e)}function hn(n,t,e){var r=(n+16)/116,o=r+t/500,a=r-e/200;return o=mn(o)*Va,r=mn(r)*Xa,a=mn(a)*Ga,new yn(gn(3.2404542*o-1.5371385*r-.4985314*a),gn(-.969266*o+1.8760108*r+.041556*a),gn(.0556434*o-.2040259*r+1.0572252*a))}function dn(n,t,e){return n>0?new cn(Math.atan2(e,t)*Da,Math.sqrt(t*t+e*e),n):new cn(NaN,NaN,n)}function mn(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function vn(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function gn(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function yn(n,t,e){return this instanceof yn?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof yn?new yn(n.r,n.g,n.b):wn(""+n,yn,ln):new yn(n,t,e)}function bn(n){return new yn(n>>16,n>>8&255,255&n)}function xn(n){return bn(n)+""}function Mn(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function wn(n,t,e){var r,o,a,i=0,u=0,s=0;if(r=/([a-z]+)\((.*)\)/.exec(n=n.toLowerCase()))switch(o=r[2].split(","),r[1]){case"hsl":return e(parseFloat(o[0]),parseFloat(o[1])/100,parseFloat(o[2])/100);case"rgb":return t(An(o[0]),An(o[1]),An(o[2]))}return(a=Za.get(n))?t(a.r,a.g,a.b):(null==n||"#"!==n.charAt(0)||isNaN(a=parseInt(n.slice(1),16))||(4===n.length?(i=(3840&a)>>4,i|=i>>4,u=240&a,u|=u>>4,s=15&a,s|=s<<4):7===n.length&&(i=(16711680&a)>>16,u=(65280&a)>>8,s=255&a)),t(i,u,s))}function kn(n,t,e){var r,o,a=Math.min(n/=255,t/=255,e/=255),i=Math.max(n,t,e),u=i-a,s=(i+a)/2;return u?(o=.5>s?u/(i+a):u/(2-i-a),r=n==i?(t-e)/u+(e>t?6:0):t==i?(e-n)/u+2:(n-t)/u+4,r*=60):(r=NaN,o=s>0&&1>s?0:r),new sn(r,o,s)}function _n(n,t,e){n=Sn(n),t=Sn(t),e=Sn(e);var r=vn((.4124564*n+.3575761*t+.1804375*e)/Va),o=vn((.2126729*n+.7151522*t+.072175*e)/Xa),a=vn((.0193339*n+.119192*t+.9503041*e)/Ga);return pn(116*o-16,500*(r-o),200*(o-a))}function Sn(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function An(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function Tn(n){return"function"==typeof n?n:function(){return n}}function En(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),Rn(t,e,n,r)}}function Rn(n,t,e,r){function o(){var n,t=s.status;if(!t&&function(n){var t=n.responseType;return t&&"text"!==t?n.response:n.responseText}(s)||t>=200&&300>t||304===t){try{n=e.call(a,s)}catch(n){return void i.error.call(a,n)}i.load.call(a,n)}else i.error.call(a,s)}var a={},i=ra.dispatch("beforesend","progress","load","error"),u={},s=new XMLHttpRequest,l=null;return!this.XDomainRequest||"withCredentials"in s||!/^(http(s)?:)?\/\//.test(n)||(s=new XDomainRequest),"onload"in s?s.onload=s.onerror=o:s.onreadystatechange=function(){s.readyState>3&&o()},s.onprogress=function(n){var t=ra.event;ra.event=n;try{i.progress.call(a,s)}finally{ra.event=t}},a.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?u[n]:(null==t?delete u[n]:u[n]=t+"",a)},a.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",a):t},a.responseType=function(n){return arguments.length?(l=n,a):l},a.response=function(n){return e=n,a},["get","post"].forEach(function(n){a[n]=function(){return a.send.apply(a,[n].concat(aa(arguments)))}}),a.send=function(e,r,o){if(2===arguments.length&&"function"==typeof r&&(o=r,r=null),s.open(e,n,!0),null==t||"accept"in u||(u.accept=t+",*/*"),s.setRequestHeader)for(var c in u)s.setRequestHeader(c,u[c]);return null!=t&&s.overrideMimeType&&s.overrideMimeType(t),null!=l&&(s.responseType=l),null!=o&&a.on("error",o).on("load",function(n){o(null,n)}),i.beforesend.call(a,s),s.send(null==r?null:r),a},a.abort=function(){return s.abort(),a},ra.rebind(a,i,"on"),null==r?a:a.get(function(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}(r))}function Pn(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var o=e+t,a={c:n,t:o,n:null};return $a?$a.n=a:Ja=a,$a=a,Ka||(Qa=clearTimeout(Qa),Ka=1,ni(Nn)),a}function Nn(){var n=On(),t=Cn()-n;t>24?(isFinite(t)&&(clearTimeout(Qa),Qa=setTimeout(Nn,t)),Ka=0):(Ka=1,ni(Nn))}function On(){for(var n=Date.now(),t=Ja;t;)n>=t.t&&t.c(n-t.t)&&(t.c=null),t=t.n;return n}function Cn(){for(var n,t=Ja,e=1/0;t;)t.c?(t.t1?Date.UTC.apply(this,arguments):arguments[0])}function zn(n,t,e){function r(t){var e=n(t),r=a(e,1);return r-t>t-e?e:r}function o(e){return t(e=n(new ai(e-1)),1),e}function a(n,e){return t(n=new ai(+n),e),n}function i(n,r,a){var i=o(n),u=[];if(a>1)for(;r>i;)e(i)%a||u.push(new Date(+i)),t(i,1);else for(;r>i;)u.push(new Date(+i)),t(i,1);return u}n.floor=n,n.round=r,n.ceil=o,n.offset=a,n.range=i;var u=n.utc=Fn(n);return u.floor=u,u.round=Fn(r),u.ceil=Fn(o),u.offset=Fn(a),u.range=function(n,t,e){try{ai=Dn;var r=new Dn;return r._=n,i(r,t,e)}finally{ai=Date}},n}function Fn(n){return function(t,e){try{ai=Dn;var r=new Dn;return r._=t,n(r,e)._}finally{ai=Date}}}function qn(n,t,e){var r=0>n?"-":"",o=(r?-n:n)+"",a=o.length;return r+(e>a?new Array(e-a+1).join(t)+o:o)}function jn(n){return new RegExp("^(?:"+n.map(ra.requote).join("|")+")","i")}function Bn(n){for(var t=new h,e=-1,r=n.length;++e68?1900:2e3)}(+r[0]),e+r[0].length):-1}function Yn(n,t,e){return/^[+-]\d{4}$/.test(t=t.slice(e,e+5))?(n.Z=-t,e+5):-1}function Wn(n,t,e){si.lastIndex=0;var r=si.exec(t.slice(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function Zn(n,t,e){si.lastIndex=0;var r=si.exec(t.slice(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function Jn(n,t,e){si.lastIndex=0;var r=si.exec(t.slice(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function $n(n,t,e){si.lastIndex=0;var r=si.exec(t.slice(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function Kn(n,t,e){si.lastIndex=0;var r=si.exec(t.slice(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function Qn(n,t,e){si.lastIndex=0;var r=si.exec(t.slice(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function nt(n,t,e){si.lastIndex=0;var r=si.exec(t.slice(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function tt(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=ha(t)/60|0,o=ha(t)%60;return e+qn(r,"0",2)+qn(o,"0",2)}function et(n,t,e){li.lastIndex=0;var r=li.exec(t.slice(e,e+1));return r?e+r[0].length:-1}function rt(n){for(var t=n.length,e=-1;++e=0?1:-1,u=i*e,s=Math.cos(t),l=Math.sin(t),c=a*l,f=o*s+c*Math.cos(u),p=c*i*Math.sin(u);mi.add(Math.atan2(p,f)),r=n,o=s,a=l}var t,e,r,o,a;vi.point=function(i,u){vi.point=n,r=(t=i)*Ua,o=Math.cos(u=(e=u)*Ua/2+Na/4),a=Math.sin(u)},vi.lineEnd=function(){n(t,e)}}function ct(n){var t=n[0],e=n[1],r=Math.cos(e);return[r*Math.cos(t),r*Math.sin(t),Math.sin(e)]}function ft(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function pt(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function ht(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function dt(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function mt(n){var t=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function vt(n){return[Math.atan2(n[1],n[0]),rn(n[2])]}function gt(n,t){return ha(n[0]-t[0])u;++u)o.point((e=n[u])[0],e[1]);return void o.lineEnd()}var s=new Tt(e,n,null,!0),l=new Tt(e,null,s,!1);s.o=l,a.push(s),i.push(l),s=new Tt(r,n,null,!1),l=new Tt(r,null,s,!0),s.o=l,a.push(s),i.push(l)}}),i.sort(t),At(a),At(i),a.length){for(var u=0,s=e,l=i.length;l>u;++u)i[u].e=s=!s;for(var c,f,p=a[0];;){for(var h=p,d=!0;h.v;)if((h=h.n)===p)return;c=h.z,o.lineStart();do{if(h.v=h.o.v=!0,h.e){if(d)for(var u=0,l=c.length;l>u;++u)o.point((f=c[u])[0],f[1]);else r(h.x,h.n.x,1,o);h=h.n}else{if(d)for(var u=(c=h.p.z).length-1;u>=0;--u)o.point((f=c[u])[0],f[1]);else r(h.x,h.p.x,-1,o);h=h.p}h=h.o,c=h.z,d=!d}while(!h.v);o.lineEnd()}}}function At(n){if(t=n.length){for(var t,e,r=0,o=n[0];++r0){for(M||(a.polygonStart(),M=!0),a.lineStart();++i1&&2&t&&e.push(e.pop().concat(e.shift())),h.push(e.filter(Rt))}var h,d,m,v=t(a),g=o.invert(r[0],r[1]),y={point:i,lineStart:s,lineEnd:l,polygonStart:function(){y.point=c,y.lineStart=f,y.lineEnd=p,h=[],d=[]},polygonEnd:function(){y.point=i,y.lineStart=s,y.lineEnd=l,h=ra.merge(h);var n=function(n,t){var e=n[0],r=n[1],o=[Math.sin(e),-Math.cos(e),0],a=0,i=0;mi.reset();for(var u=0,s=t.length;s>u;++u){var l=t[u],c=l.length;if(c)for(var f=l[0],p=f[0],h=f[1]/2+Na/4,d=Math.sin(h),m=Math.cos(h),v=1;;){v===c&&(v=0);var g=(n=l[v])[0],y=n[1]/2+Na/4,b=Math.sin(y),x=Math.cos(y),M=g-p,w=M>=0?1:-1,k=w*M,_=k>Na,S=d*b;if(mi.add(Math.atan2(S*w*Math.sin(k),m*x+S*Math.cos(k))),a+=_?M+w*Oa:M,_^p>=e^g>=e){var A=pt(ct(f),ct(n));mt(A);var T=pt(o,A);mt(T);var E=(_^M>=0?-1:1)*rn(T[2]);(r>E||r===E&&(A[0]||A[1]))&&(i+=_^M>=0?1:-1)}if(!v++)break;p=g,d=b,m=x,f=n}}return(-Ra>a||Ra>a&&0>mi)^1&i}(g,d);h.length?(M||(a.polygonStart(),M=!0),St(h,Nt,n,e,a)):n&&(M||(a.polygonStart(),M=!0),a.lineStart(),e(null,null,1,a),a.lineEnd()),M&&(a.polygonEnd(),M=!1),h=d=null},sphere:function(){a.polygonStart(),a.lineStart(),e(null,null,1,a),a.lineEnd(),a.polygonEnd()}},b=Pt(),x=t(b),M=!1;return y}}function Rt(n){return n.length>1}function Pt(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:S,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function Nt(n,t){return((n=n.x)[0]<0?n[1]-La-Ra:La-n[1])-((t=t.x)[0]<0?t[1]-La-Ra:La-t[1])}function Ot(n,t,e,r){return function(o){var a,i=o.a,u=o.b,s=i.x,l=i.y,c=u.x,f=u.y,p=0,h=1,d=c-s,m=f-l;if(a=n-s,d||!(a>0)){if(a/=d,0>d){if(p>a)return;h>a&&(h=a)}else if(d>0){if(a>h)return;a>p&&(p=a)}if(a=e-s,d||!(0>a)){if(a/=d,0>d){if(a>h)return;a>p&&(p=a)}else if(d>0){if(p>a)return;h>a&&(h=a)}if(a=t-l,m||!(a>0)){if(a/=m,0>m){if(p>a)return;h>a&&(h=a)}else if(m>0){if(a>h)return;a>p&&(p=a)}if(a=r-l,m||!(0>a)){if(a/=m,0>m){if(a>h)return;a>p&&(p=a)}else if(m>0){if(p>a)return;h>a&&(h=a)}return p>0&&(o.a={x:s+p*d,y:l+p*m}),1>h&&(o.b={x:s+h*d,y:l+h*m}),o}}}}}}function Ct(n,t,e,r){function o(r,o){return ha(r[0]-n)0?0:3:ha(r[0]-e)0?2:1:ha(r[1]-t)0?1:0:o>0?3:2}function a(n,t){return i(n.x,t.x)}function i(n,t){var e=o(n,1),r=o(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}return function(u){function s(a,u,s,l){var c=0,f=0;if(null==a||(c=o(a,s))!==(f=o(u,s))||i(a,u)<0^s>0)do{l.point(0===c||3===c?n:e,c>1?r:t)}while((c=(c+s+4)%4)!==f);else l.point(u[0],u[1])}function l(o,a){return o>=n&&e>=o&&a>=t&&r>=a}function c(n,t){l(n,t)&&u.point(n,t)}function f(n,t){n=Math.max(-Pi,Math.min(Pi,n)),t=Math.max(-Pi,Math.min(Pi,t));var e=l(n,t);if(h&&d.push([n,t]),M)m=n,v=t,g=e,M=!1,e&&(u.lineStart(),u.point(n,t));else if(e&&x)u.point(n,t);else{var r={a:{x:y,y:b},b:{x:n,y:t}};S(r)?(x||(u.lineStart(),u.point(r.a.x,r.a.y)),u.point(r.b.x,r.b.y),e||u.lineEnd(),w=!1):e&&(u.lineStart(),u.point(n,t),w=!1)}y=n,b=t,x=e}var p,h,d,m,v,g,y,b,x,M,w,k=u,_=Pt(),S=Ot(n,t,e,r),A={point:c,lineStart:function(){A.point=f,h&&h.push(d=[]),M=!0,x=!1,y=b=NaN},lineEnd:function(){p&&(f(m,v),g&&x&&_.rejoin(),p.push(_.buffer())),A.point=c,x&&u.lineEnd()},polygonStart:function(){u=_,p=[],h=[],w=!0},polygonEnd:function(){u=k,p=ra.merge(p);var t=function(n){for(var t=0,e=h.length,r=n[1],o=0;e>o;++o)for(var a,i=1,u=h[o],s=u.length,l=u[0];s>i;++i)a=u[i],l[1]<=r?a[1]>r&&tn(l,a,n)>0&&++t:a[1]<=r&&tn(l,a,n)<0&&--t,l=a;return 0!==t}([n,r]),e=w&&t,o=p.length;(e||o)&&(u.polygonStart(),e&&(u.lineStart(),s(null,null,1,u),u.lineEnd()),o&&St(p,a,t,s,u),u.polygonEnd()),p=h=d=null}};return A}}function Lt(n){var t=0,e=Na/3,r=Wt(n),o=r(t,e);return o.parallels=function(n){return arguments.length?r(t=n[0]*Na/180,e=n[1]*Na/180):[t/Na*180,e/Na*180]},o}function Ut(n,t){function e(n,t){var e=Math.sqrt(a-2*o*Math.sin(t))/o;return[e*Math.sin(n*=o),i-e*Math.cos(n)]}var r=Math.sin(n),o=(r+Math.sin(t))/2,a=1+r*(2*o-r),i=Math.sqrt(a)/o;return e.invert=function(n,t){var e=i-t;return[Math.atan2(n,e)/o,rn((a-(n*n+e*e)*o*o)/(2*o))]},e}function Dt(){function n(n,t){Oi+=o*n-r*t,r=n,o=t}var t,e,r,o;zi.point=function(a,i){zi.point=n,t=r=a,e=o=i},zi.lineEnd=function(){n(t,e)}}function zt(){function n(n,t){i.push("M",n,",",t,a)}function t(n,t){i.push("M",n,",",t),u.point=e}function e(n,t){i.push("L",n,",",t)}function r(){u.point=n}function o(){i.push("Z")}var a=Ft(4.5),i=[],u={point:n,lineStart:function(){u.point=t},lineEnd:r,polygonStart:function(){u.lineEnd=o},polygonEnd:function(){u.lineEnd=r,u.point=n},pointRadius:function(n){return a=Ft(n),u},result:function(){if(i.length){var n=i.join("");return i=[],n}}};return u}function Ft(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function qt(n,t){bi+=n,xi+=t,++Mi}function jt(){function n(n,r){var o=n-t,a=r-e,i=Math.sqrt(o*o+a*a);wi+=i*(t+n)/2,ki+=i*(e+r)/2,_i+=i,qt(t=n,e=r)}var t,e;qi.point=function(r,o){qi.point=n,qt(t=r,e=o)}}function Bt(){qi.point=qt}function It(){function n(n,t){var e=n-r,a=t-o,i=Math.sqrt(e*e+a*a);wi+=i*(r+n)/2,ki+=i*(o+t)/2,_i+=i,Si+=(i=o*n-r*t)*(r+n),Ai+=i*(o+t),Ti+=3*i,qt(r=n,o=t)}var t,e,r,o;qi.point=function(a,i){qi.point=n,qt(t=r=a,e=o=i)},qi.lineEnd=function(){n(t,e)}}function Ht(n){function t(t,e){n.moveTo(t+i,e),n.arc(t,e,i,0,Oa)}function e(t,e){n.moveTo(t,e),u.point=r}function r(t,e){n.lineTo(t,e)}function o(){u.point=t}function a(){n.closePath()}var i=4.5,u={point:t,lineStart:function(){u.point=e},lineEnd:o,polygonStart:function(){u.lineEnd=a},polygonEnd:function(){u.lineEnd=o,u.point=t},pointRadius:function(n){return i=n,u},result:S};return u}function Vt(n){function t(n){return(u?r:e)(n)}function e(t){return Gt(t,function(e,r){e=n(e,r),t.point(e[0],e[1])})}function r(t){function e(e,r){e=n(e,r),t.point(e[0],e[1])}function r(){y=NaN,k.point=a,t.lineStart()}function a(e,r){var a=ct([e,r]),i=n(e,r);o(y,b,g,x,M,w,y=i[0],b=i[1],g=e,x=a[0],M=a[1],w=a[2],u,t),t.point(y,b)}function i(){k.point=e,t.lineEnd()}function s(){r(),k.point=l,k.lineEnd=c}function l(n,t){a(f=n,t),p=y,h=b,d=x,m=M,v=w,k.point=a}function c(){o(y,b,g,x,M,w,p,h,f,d,m,v,u,t),k.lineEnd=i,i()}var f,p,h,d,m,v,g,y,b,x,M,w,k={point:e,lineStart:r,lineEnd:i,polygonStart:function(){t.polygonStart(),k.lineStart=s},polygonEnd:function(){t.polygonEnd(),k.lineStart=r}};return k}function o(t,e,r,u,s,l,c,f,p,h,d,m,v,g){var y=c-t,b=f-e,x=y*y+b*b;if(x>4*a&&v--){var M=u+h,w=s+d,k=l+m,_=Math.sqrt(M*M+w*w+k*k),S=Math.asin(k/=_),A=ha(ha(k)-1)a||ha((y*P+b*N)/x-.5)>.3||i>u*h+s*d+l*m)&&(o(t,e,r,u,s,l,E,R,A,M/=_,w/=_,k,v,g),g.point(E,R),o(E,R,A,M,w,k,c,f,p,h,d,m,v,g))}}var a=.5,i=Math.cos(30*Ua),u=16;return t.precision=function(n){return arguments.length?(u=(a=n*n)>0&&16,t):Math.sqrt(a)},t}function Xt(n){this.stream=n}function Gt(n,t){return{point:t,sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function Yt(n){return Wt(function(){return n})()}function Wt(n){function t(n){return[(n=u(n[0]*Ua,n[1]*Ua))[0]*p+s,l-n[1]*p]}function e(n){return(n=u.invert((n[0]-s)/p,(l-n[1])/p))&&[n[0]*Da,n[1]*Da]}function r(){u=kt(i=Kt(g,y,b),a);var n=a(m,v);return s=h-n[0]*p,l=d+n[1]*p,o()}function o(){return c&&(c.valid=!1,c=null),t}var a,i,u,s,l,c,f=Vt(function(n,t){return[(n=a(n,t))[0]*p+s,l-n[1]*p]}),p=150,h=480,d=250,m=0,v=0,g=0,y=0,b=0,x=Ri,M=w,k=null,_=null;return t.stream=function(n){return c&&(c.valid=!1),(c=Zt(x(i,f(M(n))))).valid=!0,c},t.clipAngle=function(n){return arguments.length?(x=null==n?(k=n,Ri):function(n){function t(n,t){return Math.cos(n)*Math.cos(t)>o}function e(n,t,e){var r=ct(n),a=ct(t),i=[1,0,0],u=pt(r,a),s=ft(u,u),l=u[0],c=s-l*l;if(!c)return!e&&n;var f=o*s/c,p=-o*l/c,h=pt(i,u),d=dt(i,f),m=dt(u,p);ht(d,m);var v=h,g=ft(d,v),y=ft(v,v),b=g*g-y*(ft(d,d)-1);if(!(0>b)){var x=Math.sqrt(b),M=dt(v,(-g-x)/y);if(ht(M,d),M=vt(M),!e)return M;var w,k=n[0],_=t[0],S=n[1],A=t[1];k>_&&(w=k,k=_,_=w);var T=_-k,E=ha(T-Na)T;if(!E&&S>A&&(w=S,S=A,A=w),R?E?S+A>0^M[1]<(ha(M[0]-k)Na^(k<=M[0]&&M[0]<=_)){var P=dt(v,(-g+x)/y);return ht(P,d),[M,vt(P)]}}}function r(t,e){var r=a?n:Na-n,o=0;return-r>t?o|=1:t>r&&(o|=2),-r>e?o|=4:e>r&&(o|=8),o}var o=Math.cos(n),a=o>0,i=ha(o)>Ra;return Et(t,function(n){var o,u,s,l,c;return{lineStart:function(){l=s=!1,c=1},point:function(f,p){var h,d=[f,p],m=t(f,p),v=a?m?0:r(f,p):m?r(f+(0>f?Na:-Na),p):0;if(!o&&(l=s=m)&&n.lineStart(),m!==s&&(h=e(o,d),(gt(o,h)||gt(d,h))&&(d[0]+=Ra,d[1]+=Ra,m=t(d[0],d[1]))),m!==s)c=0,m?(n.lineStart(),h=e(d,o),n.point(h[0],h[1])):(h=e(o,d),n.point(h[0],h[1]),n.lineEnd()),o=h;else if(i&&o&&a^m){var g;v&u||!(g=e(d,o,!0))||(c=0,a?(n.lineStart(),n.point(g[0][0],g[0][1]),n.point(g[1][0],g[1][1]),n.lineEnd()):(n.point(g[1][0],g[1][1]),n.lineEnd(),n.lineStart(),n.point(g[0][0],g[0][1])))}!m||o&>(o,d)||n.point(d[0],d[1]),o=d,s=m,u=v},lineEnd:function(){s&&n.lineEnd(),o=null},clean:function(){return c|(l&&s)<<1}}},ee(n,6*Ua),a?[0,-n]:[-Na,n-Na])}((k=+n)*Ua),o()):k},t.clipExtent=function(n){return arguments.length?(_=n,M=n?Ct(n[0][0],n[0][1],n[1][0],n[1][1]):w,o()):_},t.scale=function(n){return arguments.length?(p=+n,r()):p},t.translate=function(n){return arguments.length?(h=+n[0],d=+n[1],r()):[h,d]},t.center=function(n){return arguments.length?(m=n[0]%360*Ua,v=n[1]%360*Ua,r()):[m*Da,v*Da]},t.rotate=function(n){return arguments.length?(g=n[0]%360*Ua,y=n[1]%360*Ua,b=n.length>2?n[2]%360*Ua:0,r()):[g*Da,y*Da,b*Da]},ra.rebind(t,f,"precision"),function(){return a=n.apply(this,arguments),t.invert=a.invert&&e,r()}}function Zt(n){return Gt(n,function(t,e){n.point(t*Ua,e*Ua)})}function Jt(n,t){return[n,t]}function $t(n,t){return[n>Na?n-Oa:-Na>n?n+Oa:n,t]}function Kt(n,t,e){return n?t||e?kt(ne(n),te(t,e)):ne(n):t||e?te(t,e):$t}function Qt(n){return function(t,e){return[(t+=n)>Na?t-Oa:-Na>t?t+Oa:t,e]}}function ne(n){var t=Qt(n);return t.invert=Qt(-n),t}function te(n,t){function e(n,t){var e=Math.cos(t),u=Math.cos(n)*e,s=Math.sin(n)*e,l=Math.sin(t),c=l*r+u*o;return[Math.atan2(s*a-c*i,u*r-l*o),rn(c*a+s*i)]}var r=Math.cos(n),o=Math.sin(n),a=Math.cos(t),i=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),u=Math.cos(n)*e,s=Math.sin(n)*e,l=Math.sin(t),c=l*a-s*i;return[Math.atan2(s*a+l*i,u*r+c*o),rn(c*r-u*o)]},e}function ee(n,t){var e=Math.cos(n),r=Math.sin(n);return function(o,a,i,u){var s=i*t;null!=o?(o=re(e,o),a=re(e,a),(i>0?a>o:o>a)&&(o+=i*Oa)):(o=n+i*Oa,a=n-.5*s);for(var l,c=o;i>0?c>a:a>c;c-=s)u.point((l=vt([e,-r*Math.cos(c),-r*Math.sin(c)]))[0],l[1])}}function re(n,t){var e=ct(t);e[0]-=n,mt(e);var r=en(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Ra)%(2*Math.PI)}function oe(n,t,e){var r=ra.range(n,t-Ra,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function ae(n,t,e){var r=ra.range(n,t-Ra,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function ie(n){return n.source}function ue(n){return n.target}function se(n,t){function e(t,e){var r=Math.cos(t),o=Math.cos(e),a=n(r*o);return[a*o*Math.sin(t),a*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),o=t(r),a=Math.sin(o),i=Math.cos(o);return[Math.atan2(n*a,r*i),Math.asin(r&&e*a/r)]},e}function le(n,t){function e(n,t){i>0?-La+Ra>t&&(t=-La+Ra):t>La-Ra&&(t=La-Ra);var e=i/Math.pow(o(t),a);return[e*Math.sin(a*n),i-e*Math.cos(a*n)]}var r=Math.cos(n),o=function(n){return Math.tan(Na/4+n/2)},a=n===t?Math.sin(n):Math.log(r/Math.cos(t))/Math.log(o(t)/o(n)),i=r*Math.pow(o(n),a)/a;return a?(e.invert=function(n,t){var e=i-t,r=nn(a)*Math.sqrt(n*n+e*e);return[Math.atan2(n,e)/a,2*Math.atan(Math.pow(i/r,1/a))-La]},e):fe}function ce(n,t){function e(n,t){var e=a-t;return[e*Math.sin(o*n),a-e*Math.cos(o*n)]}var r=Math.cos(n),o=n===t?Math.sin(n):(r-Math.cos(t))/(t-n),a=r/o+n;return ha(o)o;o++){for(;r>1&&tn(n[e[r-2]],n[e[r-1]],n[o])<=0;)--r;e[r++]=o}return e.slice(0,r)}function ge(n,t){return n[0]-t[0]||n[1]-t[1]}function ye(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function be(n,t,e,r){var o=n[0],a=e[0],i=t[0]-o,u=r[0]-a,s=n[1],l=e[1],c=t[1]-s,f=r[1]-l,p=(u*(s-l)-f*(o-a))/(f*i-u*c);return[o+p*i,s+p*c]}function xe(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function Me(){je(this),this.edge=this.site=this.circle=null}function we(n){var t=Qi.pop()||new Me;return t.site=n,t}function ke(n){Oe(n),Ji.remove(n),Qi.push(n),je(n)}function _e(n){var t=n.circle,e=t.x,r=t.cy,o={x:e,y:r},a=n.P,i=n.N,u=[n];ke(n);for(var s=a;s.circle&&ha(e-s.circle.x)c;++c)l=u[c],s=u[c-1],ze(l.edge,s.site,l.site,o);s=u[0],(l=u[f-1]).edge=Ue(s.site,l.site,null,o),Ne(s),Ne(l)}function Se(n){for(var t,e,r,o,a=n.x,i=n.y,u=Ji._;u;)if((r=Ae(u,i)-a)>Ra)u=u.L;else{if(!((o=a-Te(u,i))>Ra)){r>-Ra?(t=u.P,e=u):o>-Ra?(t=u,e=u.N):t=e=u;break}if(!u.R){t=u;break}u=u.R}var s=we(n);if(Ji.insert(t,s),t||e){if(t===e)return Oe(t),e=we(t.site),Ji.insert(s,e),s.edge=e.edge=Ue(t.site,s.site),Ne(t),void Ne(e);if(!e)return void(s.edge=Ue(t.site,s.site));Oe(t),Oe(e);var l=t.site,c=l.x,f=l.y,p=n.x-c,h=n.y-f,d=e.site,m=d.x-c,v=d.y-f,g=2*(p*v-h*m),y=p*p+h*h,b=m*m+v*v,x={x:(v*y-h*b)/g+c,y:(p*b-m*y)/g+f};ze(e.edge,l,d,x),s.edge=Ue(l,n,null,x),e.edge=Ue(n,d,null,x),Ne(t),Ne(e)}}function Ae(n,t){var e=n.site,r=e.x,o=e.y,a=o-t;if(!a)return r;var i=n.P;if(!i)return-1/0;var u=(e=i.site).x,s=e.y,l=s-t;if(!l)return u;var c=u-r,f=1/a-1/l,p=c/l;return f?(-p+Math.sqrt(p*p-2*f*(c*c/(-2*l)-s+l/2+o-a/2)))/f+r:(r+u)/2}function Te(n,t){var e=n.N;if(e)return Ae(e,t);var r=n.site;return r.y===t?r.x:1/0}function Ee(n){this.site=n,this.edges=[]}function Re(n,t){return t.angle-n.angle}function Pe(){je(this),this.x=this.y=this.arc=this.site=this.cy=null}function Ne(n){var t=n.P,e=n.N;if(t&&e){var r=t.site,o=n.site,a=e.site;if(r!==a){var i=o.x,u=o.y,s=r.x-i,l=r.y-u,c=a.x-i,f=a.y-u,p=2*(s*f-l*c);if(!(p>=-Pa)){var h=s*s+l*l,d=c*c+f*f,m=(f*h-l*d)/p,v=(s*d-c*h)/p,f=v+u,g=nu.pop()||new Pe;g.arc=n,g.site=o,g.x=m+i,g.y=f+Math.sqrt(m*m+v*v),g.cy=f,n.circle=g;for(var y=null,b=Ki._;b;)if(g.yv||v>=u)return;if(p>d){if(a){if(a.y>=l)return}else a={x:v,y:s};e={x:v,y:l}}else{if(a){if(a.yr||r>1)if(p>d){if(a){if(a.y>=l)return}else a={x:(s-o)/r,y:s};e={x:(l-o)/r,y:l}}else{if(a){if(a.yh){if(a){if(a.x>=u)return}else a={x:i,y:r*i+o};e={x:u,y:r*u+o}}else{if(a){if(a.xi;)c=u[i].end(),r=c.x,o=c.y,l=u[++i%s].start(),t=l.x,e=l.y,(ha(r-t)>Ra||ha(o-e)>Ra)&&(u.splice(i,0,new Fe(De(a.site,c,ha(r-f)Ra?{x:f,y:ha(t-f)Ra?{x:ha(e-d)Ra?{x:p,y:ha(t-p)Ra?{x:ha(e-h)a&&(o=t.slice(a,o),u[i]?u[i]+=o:u[++i]=o),(e=e[0])===(r=r[0])?u[i]?u[i]+=r:u[++i]=r:(u[++i]=null,s.push({i:i,x:$e(e,r)})),a=ru.lastIndex;return ar;++r)u[(e=s[r]).i]=e.x(n);return u.join("")})}function Qe(n,t){for(var e,r=ra.interpolators.length;--r>=0&&!(e=ra.interpolators[r](n,t)););return e}function nr(n,t){var e,r=[],o=[],a=n.length,i=t.length,u=Math.min(n.length,t.length);for(e=0;u>e;++e)r.push(Qe(n[e],t[e]));for(;a>e;++e)o[e]=n[e];for(;i>e;++e)o[e]=t[e];return function(n){for(e=0;u>e;++e)o[e]=r[e](n);return o}}function tr(n){return function(t){return 1-n(1-t)}}function er(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function rr(n){return n*n}function or(n){return n*n*n}function ar(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function ir(n){return 1-Math.cos(n*La)}function ur(n){return Math.pow(2,10*(n-1))}function sr(n){return 1-Math.sqrt(1-n*n)}function lr(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function cr(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function fr(n){var t=[n.a,n.b],e=[n.c,n.d],r=hr(t),o=pr(t,e),a=hr(function(n,t,e){return n[0]+=e*t[0],n[1]+=e*t[1],n}(e,t,-o))||0;t[0]*e[1]180?t+=360:t-n>180&&(n+=360),r.push({i:e.push(dr(e)+"rotate(",null,")")-2,x:$e(n,t)})):t&&e.push(dr(e)+"rotate("+t+")")}(n.rotate,t.rotate,e,r),function(n,t,e,r){n!==t?r.push({i:e.push(dr(e)+"skewX(",null,")")-2,x:$e(n,t)}):t&&e.push(dr(e)+"skewX("+t+")")}(n.skew,t.skew,e,r),function(n,t,e,r){if(n[0]!==t[0]||n[1]!==t[1]){var o=e.push(dr(e)+"scale(",null,",",null,")");r.push({i:o-4,x:$e(n[0],t[0])},{i:o-2,x:$e(n[1],t[1])})}else(1!==t[0]||1!==t[1])&&e.push(dr(e)+"scale("+t+")")}(n.scale,t.scale,e,r),n=t=null,function(n){for(var t,o=-1,a=r.length;++o=0;)e.push(o[r])}function Ar(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(a=n.children)&&(o=a.length))for(var o,a,i=-1;++ie;++e)(t=n[e][1])>o&&(r=e,o=t);return r}function zr(n){return n.reduce(Fr,0)}function Fr(n,t){return n+t[1]}function qr(n,t){return jr(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function jr(n,t){for(var e=-1,r=+n[0],o=(n[1]-r)/t,a=[];++e<=t;)a[e]=o*e+r;return a}function Br(n){return[ra.min(n),ra.max(n)]}function Ir(n,t){return n.value-t.value}function Hr(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function Vr(n,t){n._pack_next=t,t._pack_prev=n}function Xr(n,t){var e=t.x-n.x,r=t.y-n.y,o=n.r+t.r;return.999*o*o>e*e+r*r}function Gr(n){function t(n){c=Math.min(n.x-n.r,c),f=Math.max(n.x+n.r,f),p=Math.min(n.y-n.r,p),h=Math.max(n.y+n.r,h)}if((e=n.children)&&(l=e.length)){var e,r,o,a,i,u,s,l,c=1/0,f=-1/0,p=1/0,h=-1/0;if(e.forEach(Yr),(r=e[0]).x=-r.r,r.y=0,t(r),l>1&&((o=e[1]).x=o.r,o.y=0,t(o),l>2))for(a=e[2],Zr(r,o,a),t(a),Hr(r,a),r._pack_prev=a,Hr(a,o),o=r._pack_next,i=3;l>i;i++){Zr(r,o,a=e[i]);var d=0,m=1,v=1;for(u=o._pack_next;u!==o;u=u._pack_next,m++)if(Xr(u,a)){d=1;break}if(1==d)for(s=r._pack_prev;s!==u._pack_prev&&!Xr(s,a);s=s._pack_prev,v++);d?(v>m||m==v&&o.ri;i++)(a=e[i]).x-=g,a.y-=y,b=Math.max(b,a.r+Math.sqrt(a.x*a.x+a.y*a.y));n.r=b,e.forEach(Wr)}}function Yr(n){n._pack_next=n._pack_prev=n}function Wr(n){delete n._pack_next,delete n._pack_prev}function Zr(n,t,e){var r=n.r+e.r,o=t.x-n.x,a=t.y-n.y;if(r&&(o||a)){var i=t.r+e.r,u=o*o+a*a,s=.5+((r*=r)-(i*=i))/(2*u),l=Math.sqrt(Math.max(0,2*i*(r+u)-(r-=u)*r-i*i))/(2*u);e.x=n.x+s*o+l*a,e.y=n.y+s*a-l*o}else e.x=n.x+r,e.y=n.y}function Jr(n,t){return n.parent==t.parent?1:2}function $r(n){var t=n.children;return t.length?t[0]:n.t}function Kr(n){var t,e=n.children;return(t=e.length)?e[t-1]:n.t}function Qr(n,t,e){var r=e/(t.i-n.i);t.c-=r,t.s+=e,n.c+=r,t.z+=e,t.m+=e}function no(n,t,e){return n.a.parent===t.parent?n.a:e}function to(n){return{x:n.x,y:n.y,dx:n.dx,dy:n.dy}}function eo(n,t){var e=n.x+t[3],r=n.y+t[0],o=n.dx-t[1]-t[3],a=n.dy-t[0]-t[2];return 0>o&&(e+=o/2,o=0),0>a&&(r+=a/2,a=0),{x:e,y:r,dx:o,dy:a}}function ro(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function oo(n){return n.rangeExtent?n.rangeExtent():ro(n.range())}function ao(n,t,e,r){var o=e(n[0],n[1]),a=r(t[0],t[1]);return function(n){return a(o(n))}}function io(n,t){var e,r=0,o=n.length-1,a=n[r],i=n[o];return a>i&&(e=r,r=o,o=e,e=a,a=i,i=e),n[r]=t.floor(a),n[o]=t.ceil(i),n}function uo(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:du}function so(n,t,e,r){var o=[],a=[],i=0,u=Math.min(n.length,t.length)-1;for(n[u]=a?o*=10:.35>=a?o*=5:.75>=a&&(o*=2),e[0]=Math.ceil(e[0]/o)*o,e[1]=Math.floor(e[1]/o)*o+.5*o,e[2]=o,e}function po(n,t){return ra.range.apply(ra,fo(n,t))}function ho(n,t,e){var r=fo(n,t);if(e){var o=ei.exec(e);if(o.shift(),"s"===o[8]){var a=ra.formatPrefix(Math.max(ha(r[0]),ha(r[1])));return o[7]||(o[7]="."+mo(a.scale(r[2]))),o[8]="f",e=ra.format(o.join("")),function(n){return e(a.scale(n))+a.symbol}}o[7]||(o[7]="."+function(n,t){var e=mo(t[2]);return n in mu?Math.abs(e-mo(Math.max(ha(t[0]),ha(t[1]))))+ +("e"!==n):e-2*("%"===n)}(o[8],r)),e=o.join("")}else e=",."+mo(r[2])+"f";return ra.format(e)}function mo(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function vo(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function go(){return 0}function yo(n){return n.innerRadius}function bo(n){return n.outerRadius}function xo(n){return n.startAngle}function Mo(n){return n.endAngle}function wo(n){return n&&n.padAngle}function ko(n,t,e,r){return(n-e)*t-(t-r)*n>0?0:1}function _o(n,t,e,r,o){var a=n[0]-t[0],i=n[1]-t[1],u=(o?r:-r)/Math.sqrt(a*a+i*i),s=u*i,l=-u*a,c=n[0]+s,f=n[1]+l,p=t[0]+s,h=t[1]+l,d=(c+p)/2,m=(f+h)/2,v=p-c,g=h-f,y=v*v+g*g,b=e-r,x=c*h-p*f,M=(0>g?-1:1)*Math.sqrt(Math.max(0,b*b*y-x*x)),w=(x*g-v*M)/y,k=(-x*v-g*M)/y,_=(x*g+v*M)/y,S=(-x*v+g*M)/y,A=w-d,T=k-m,E=_-d,R=S-m;return A*A+T*T>E*E+R*R&&(w=_,k=S),[[w-s,k-l],[w*e/b,k*e/b]]}function So(n){function t(t){function i(){l.push("M",a(n(c),u))}for(var s,l=[],c=[],f=-1,p=t.length,h=Tn(e),d=Tn(r);++f1?n.join("L"):n+"Z"}function To(n){return n.join("L")+"Z"}function Eo(n){for(var t=0,e=n.length,r=n[0],o=[r[0],",",r[1]];++t1){u=t[1],a=n[s],s++,r+="C"+(o[0]+i[0])+","+(o[1]+i[1])+","+(a[0]-u[0])+","+(a[1]-u[1])+","+a[0]+","+a[1];for(var l=2;l9&&(o=3*t/Math.sqrt(o),i[u]=o*e,i[u+1]=o*r));for(u=-1;++u<=s;)o=(n[Math.min(s,u+1)][0]-n[Math.max(0,u-1)][0])/(6*(1+i[u]*i[u])),a.push([o||0,i[u]*o||0]);return a}function zo(n){for(var t,e,r,o=-1,a=n.length;++o+h){var m=p[h];m.timer.c=null,m.timer.t=NaN,--p.count,delete p[h]}s.c=i,Pn(function(){return s.c&&i(e||1)&&(s.c=null,s.t=NaN),1},0,u),p.active=r,d.event&&d.event.start.call(n,n.__data__,t),f=[],d.tween.forEach(function(e,r){(r=r.call(n,n.__data__,t))&&f.push(r)}),c=d.ease,l=d.duration}function i(o){for(var a=o/l,i=c(a),u=f.length;u>0;)f[--u].call(n,i);return a>=1?(d.event&&d.event.end.call(n,n.__data__,t),--p.count?delete p[r]:delete n[e],1):void 0}var u,s,l,c,f,p=n[e]||(n[e]={active:0,count:0}),d=p[r];d||(u=o.time,s=Pn(function(n){var t=d.delay;return s.t=t+u,n>=t?a(n-t):void(s.c=a)},0,u),d=p[r]={tween:new h,time:u,timer:s,delay:o.delay,duration:o.duration,ease:o.ease,index:t},o=null,++p.count)}function Jo(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate("+(isFinite(r)?r:e(n))+",0)"})}function $o(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate(0,"+(isFinite(r)?r:e(n))+")"})}function Ko(n){return n.toISOString()}function Qo(n,t,e){function r(t){return n(t)}function o(n,e){var r=n[1]-n[0],o=r/e,a=ra.bisect(Iu,o);return a==Iu.length?[t.year,fo(n.map(function(n){return n/31536e6}),e)[2]]:a?t[o/Iu[a-1]1?{floor:function(t){for(;e(t=n.floor(t));)t=na(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=na(+t+1);return t}}:n))},r.ticks=function(n,t){var e=ro(r.domain()),a=null==n?o(e,10):"number"==typeof n?o(e,n):!n.range&&[{range:n},t];return a&&(n=a[0],t=a[1]),n.range(e[0],na(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return Qo(n.copy(),t,e)},lo(r,n)}function na(n){return new Date(n)}function ta(n){return JSON.parse(n.responseText)}function ea(n){var t=ia.createRange();return t.selectNode(ia.body),t.createContextualFragment(n.responseText)}var ra={version:"3.5.13"},oa=[].slice,aa=function(n){return oa.call(n)},ia=this.document;if(ia)try{aa(ia.documentElement.childNodes)[0].nodeType}catch(n){aa=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}if(Date.now||(Date.now=function(){return+new Date}),ia)try{ia.createElement("DIV").style.setProperty("opacity",0,"")}catch(n){var ua=this.Element.prototype,sa=ua.setAttribute,la=ua.setAttributeNS,ca=this.CSSStyleDeclaration.prototype,fa=ca.setProperty;ua.setAttribute=function(n,t){sa.call(this,n,t+"")},ua.setAttributeNS=function(n,t,e){la.call(this,n,t,e+"")},ca.setProperty=function(n,t,e){fa.call(this,n,t+"",e)}}ra.ascending=u,ra.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:NaN},ra.min=function(n,t){var e,r,o=-1,a=n.length;if(1===arguments.length){for(;++o=r){e=r;break}for(;++or&&(e=r)}else{for(;++o=r){e=r;break}for(;++or&&(e=r)}return e},ra.max=function(n,t){var e,r,o=-1,a=n.length;if(1===arguments.length){for(;++o=r){e=r;break}for(;++oe&&(e=r)}else{for(;++o=r){e=r;break}for(;++oe&&(e=r)}return e},ra.extent=function(n,t){var e,r,o,a=-1,i=n.length;if(1===arguments.length){for(;++a=r){e=o=r;break}for(;++ar&&(e=r),r>o&&(o=r))}else{for(;++a=r){e=o=r;break}for(;++ar&&(e=r),r>o&&(o=r))}return[e,o]},ra.sum=function(n,t){var e,r=0,o=n.length,a=-1;if(1===arguments.length)for(;++a1?i/(c-1):void 0},ra.deviation=function(){var n=ra.variance.apply(this,arguments);return n?Math.sqrt(n):n};var pa=c(u);ra.bisectLeft=pa.left,ra.bisect=ra.bisectRight=pa.right,ra.bisector=function(n){return c(1===n.length?function(t,e){return u(n(t),e)}:n)},ra.shuffle=function(n,t,e){(a=arguments.length)<3&&(e=n.length,2>a&&(t=0));for(var r,o,a=e-t;a;)o=Math.random()*a--|0,r=n[a+t],n[a+t]=n[o+t],n[o+t]=r;return n},ra.permute=function(n,t){for(var e=t.length,r=new Array(e);e--;)r[e]=n[t[e]];return r},ra.pairs=function(n){for(var t=0,e=n.length-1,r=n[0],o=new Array(0>e?0:e);e>t;)o[t]=[r,r=n[++t]];return o},ra.zip=function(){if(!(r=arguments.length))return[];for(var n=-1,t=ra.min(arguments,f),e=new Array(t);++n=0;)for(r=n[o],t=r.length;--t>=0;)e[--i]=r[t];return e};var ha=Math.abs;ra.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),(t-n)/e==1/0)throw new Error("infinite range");var r,o=[],a=function(n){for(var t=1;n*t%1;)t*=10;return t}(ha(e)),i=-1;if(n*=a,t*=a,0>(e*=a))for(;(r=n+e*++i)>t;)o.push(r/a);else for(;(r=n+e*++i)=o.length)return e?e.call(r,i):t?i.sort(t):i;for(var s,l,c,f,p=-1,d=i.length,m=o[u++],v=new h;++p=o.length)return t;var r=[],i=a[e++];return t.forEach(function(t,o){r.push({key:t,values:n(o,e)})}),i?r.sort(function(n,t){return i(n.key,t.key)}):r}(n(ra.map,t,0),0)},r.key=function(n){return o.push(n),r},r.sortKeys=function(n){return a[o.length-1]=n,r},r.sortValues=function(n){return t=n,r},r.rollup=function(n){return e=n,r},r},ra.set=function(n){var t=new M;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},p(M,{has:v,add:function(n){return this._[d(n+="")]=!0,n},remove:g,values:y,size:b,empty:x,forEach:function(n){for(var t in this._)n.call(this,m(t))}}),ra.behavior={},ra.rebind=function(n,t){for(var e,r=1,o=arguments.length;++r=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},ra.event=null,ra.requote=function(n){return n.replace(ga,"\\$&")};var ga=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,ya={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},ba=function(n,t){return t.querySelector(n)},xa=function(n,t){return t.querySelectorAll(n)},Ma=function(n,t){var e=n.matches||n[_(n,"matchesSelector")];return(Ma=function(n,t){return e.call(n,t)})(n,t)};"function"==typeof Sizzle&&(ba=function(n,t){return Sizzle(n,t)[0]||null},xa=Sizzle,Ma=Sizzle.matchesSelector),ra.selection=function(){return ra.select(ia.documentElement)};var wa=ra.selection.prototype=[];wa.select=function(n){var t,e,r,o,a=[];n=O(n);for(var i=-1,u=this.length;++i=0&&"xmlns"!==(e=n.slice(0,t))&&(n=n.slice(t+1)),ka.hasOwnProperty(e)?{space:ka[e],local:n}:n}},wa.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return(n=ra.ns.qualify(n)).local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(L(t,n[t]));return this}return this.each(L(n,t))},wa.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=z(n)).length,o=-1;if(t=e.classList){for(;++or){if("string"!=typeof n){for(e in 2>r&&(t=""),n)this.each(j(e,n[e],t));return this}if(2>r){var o=this.node();return i(o).getComputedStyle(o,null).getPropertyValue(n)}e=""}return this.each(j(n,t,e))},wa.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(B(t,n[t]));return this}return this.each(B(n,t))},wa.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},wa.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},wa.append=function(n){return n=I(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},wa.insert=function(n,t){return n=I(n),t=O(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},wa.remove=function(){return this.each(H)},wa.data=function(n,t){function e(n,e){var r,o,a,i=n.length,c=e.length,f=Math.min(i,c),p=new Array(c),d=new Array(c),m=new Array(i);if(t){var v,g=new h,y=new Array(i);for(r=-1;++rr;++r)d[r]=V(e[r]);for(;i>r;++r)m[r]=n[r]}d.update=p,d.parentNode=p.parentNode=m.parentNode=n.parentNode,u.push(d),s.push(p),l.push(m)}var r,o,a=-1,i=this.length;if(!arguments.length){for(n=new Array(i=(r=this[0]).length);++aa;a++){o.push(t=[]),t.parentNode=(e=this[a]).parentNode;for(var u=0,s=e.length;s>u;u++)(r=e[u])&&n.call(r,r.__data__,u,a)&&t.push(r)}return N(o)},wa.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[o])&&(a&&a!==e.nextSibling&&a.parentNode.insertBefore(e,a),a=e);return this},wa.sort=function(n){n=function(n){return arguments.length||(n=u),function(t,e){return t&&e?n(t.__data__,e.__data__):!t-!e}}.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,o=e.length;o>r;r++){var a=e[r];if(a)return a}return null},wa.size=function(){var n=0;return G(this,function(){++n}),n};var _a=[];ra.selection.enter=Y,ra.selection.enter.prototype=_a,_a.append=wa.append,_a.empty=wa.empty,_a.node=wa.node,_a.call=wa.call,_a.size=wa.size,_a.select=function(n){for(var t,e,r,o,a,i=[],u=-1,s=this.length;++u=t&&(t=o+1);!(i=u[t])&&++tr){if("string"!=typeof n){for(e in 2>r&&(t=!1),n)this.each(W(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(W(n,t,e))};var Sa=ra.map({mouseenter:"mouseover",mouseleave:"mouseout"});ia&&Sa.forEach(function(n){"on"+n in ia&&Sa.remove(n)});var Aa,Ta=0;ra.mouse=function(n){return K(n,R())};var Ea=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;ra.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=R().changedTouches),t)for(var r,o=0,a=t.length;a>o;++o)if((r=t[o]).identifier===e)return K(n,r)},ra.behavior.drag=function(){function n(){this.on("mousedown.drag",o).on("touchstart.drag",a)}function t(n,t,o,a,i){return function(){var u,s=this,l=ra.event.target,c=s.parentNode,f=e.of(s,arguments),p=0,h=n(),d=".drag"+(null==h?"":"-"+h),m=ra.select(o(l)).on(a+d,function(){var n,e,r=t(c,h);r&&(n=r[0]-g[0],e=r[1]-g[1],p|=n|e,g=r,f({type:"drag",x:r[0]+u[0],y:r[1]+u[1],dx:n,dy:e}))}).on(i+d,function(){t(c,h)&&(m.on(a+d,null).on(i+d,null),v(p),f({type:"dragend"}))}),v=$(l),g=t(c,h);u=r?[(u=r.apply(s,arguments)).x-g[0],u.y-g[1]]:[0,0],f({type:"dragstart"})}}var e=P(n,"drag","dragstart","dragend"),r=null,o=t(S,ra.mouse,i,"mousemove","mouseup"),a=t(Q,ra.touch,w,"touchmove","touchend");return n.origin=function(t){return arguments.length?(r=t,n):r},ra.rebind(n,e,"on")},ra.touches=function(n,t){return arguments.length<2&&(t=R().touches),t?aa(t).map(function(t){var e=K(n,t);return e.identifier=t.identifier,e}):[]};var Ra=1e-6,Pa=Ra*Ra,Na=Math.PI,Oa=2*Na,Ca=Oa-Ra,La=Na/2,Ua=Na/180,Da=180/Na,za=Math.SQRT2;ra.interpolateZoom=function(n,t){var e,r,o=n[0],a=n[1],i=n[2],u=t[0],s=t[1],l=t[2],c=u-o,f=s-a,p=c*c+f*f;if(Pa>p)r=Math.log(l/i)/za,e=function(n){return[o+n*c,a+n*f,i*Math.exp(za*n*r)]};else{var h=Math.sqrt(p),d=(l*l-i*i+4*p)/(2*i*2*h),m=(l*l-i*i-4*p)/(2*l*2*h),v=Math.log(Math.sqrt(d*d+1)-d),g=Math.log(Math.sqrt(m*m+1)-m);r=(g-v)/za,e=function(n){var t=n*r,e=on(v),u=i/(2*h)*(e*function(n){return((n=Math.exp(2*n))-1)/(n+1)}(za*t+v)-function(n){return((n=Math.exp(n))-1/n)/2}(v));return[o+u*c,a+u*f,i*e/on(za*t+v)]}}return e.duration=1e3*r,e},ra.behavior.zoom=function(){function n(n){n.on(R,c).on(qa+".zoom",p).on("dblclick.zoom",h).on(C,f)}function t(n){return[(n[0]-k.x)/k.k,(n[1]-k.y)/k.k]}function e(n){k.k=Math.max(S[0],Math.min(S[1],n))}function r(n,t){t=function(n){return[n[0]*k.k+k.x,n[1]*k.k+k.y]}(t),k.x+=n[0]-t[0],k.y+=n[1]-t[1]}function o(t,o,a,i){t.__chart__={x:k.x,y:k.y,k:k.k},e(Math.pow(2,i)),r(m=o,a),t=ra.select(t),A>0&&(t=t.transition().duration(A)),t.call(n.event)}function a(){x&&x.domain(b.range().map(function(n){return(n-k.x)/k.k}).map(b.invert)),w&&w.domain(M.range().map(function(n){return(n-k.y)/k.k}).map(M.invert))}function u(n){T++||n({type:"zoomstart"})}function s(n){a(),n({type:"zoom",scale:k.k,translate:[k.x,k.y]})}function l(n){--T||(n({type:"zoomend"}),m=null)}function c(){var n=this,e=L.of(n,arguments),o=0,a=ra.select(i(n)).on(N,function(){o=1,r(ra.mouse(n),c),s(e)}).on(O,function(){a.on(N,null).on(O,null),f(o),l(e)}),c=t(ra.mouse(n)),f=$(n);Ou.call(n),u(e)}function f(){function n(){var n=ra.touches(d);return h=k.k,n.forEach(function(n){n.identifier in v&&(v[n.identifier]=t(n))}),n}function a(){var t=ra.event.target;ra.select(t).on(x,i).on(M,p),w.push(t);for(var e=ra.event.changedTouches,r=0,a=e.length;a>r;++r)v[e[r].identifier]=null;var u=n(),s=Date.now();if(1===u.length){if(500>s-y){var l=u[0];o(d,l,v[l.identifier],Math.floor(Math.log(k.k)/Math.LN2)+1),E()}y=s}else if(u.length>1){var l=u[0],c=u[1],f=l[0]-c[0],h=l[1]-c[1];g=f*f+h*h}}function i(){var n,t,o,a,i=ra.touches(d);Ou.call(d);for(var u=0,l=i.length;l>u;++u,a=null)if(o=i[u],a=v[o.identifier]){if(t)break;n=o,t=a}if(a){var c=(c=o[0]-n[0])*c+(c=o[1]-n[1])*c,f=g&&Math.sqrt(c/g);n=[(n[0]+o[0])/2,(n[1]+o[1])/2],t=[(t[0]+a[0])/2,(t[1]+a[1])/2],e(f*h)}y=null,r(n,t),s(m)}function p(){if(ra.event.touches.length){for(var t=ra.event.changedTouches,e=0,r=t.length;r>e;++e)delete v[t[e].identifier];for(var o in v)return void n()}ra.selectAll(w).on(b,null),_.on(R,c).on(C,f),S(),l(m)}var h,d=this,m=L.of(d,arguments),v={},g=0,b=".zoom-"+ra.event.changedTouches[0].identifier,x="touchmove"+b,M="touchend"+b,w=[],_=ra.select(d),S=$(d);a(),u(m),_.on(R,null).on(C,a)}function p(){var n=L.of(this,arguments);g?clearTimeout(g):(Ou.call(this),d=t(m=v||ra.mouse(this)),u(n)),g=setTimeout(function(){g=null,l(n)},50),E(),e(Math.pow(2,.002*Fa())*k.k),r(m,d),s(n)}function h(){var n=ra.mouse(this),e=Math.log(k.k)/Math.LN2;o(this,n,t(n),ra.event.shiftKey?Math.ceil(e)-1:Math.floor(e)+1)}var d,m,v,g,y,b,x,M,w,k={x:0,y:0,k:1},_=[960,500],S=ja,A=250,T=0,R="mousedown.zoom",N="mousemove.zoom",O="mouseup.zoom",C="touchstart.zoom",L=P(n,"zoomstart","zoom","zoomend");return qa||(qa="onwheel"in ia?(Fa=function(){return-ra.event.deltaY*(ra.event.deltaMode?120:1)},"wheel"):"onmousewheel"in ia?(Fa=function(){return ra.event.wheelDelta},"mousewheel"):(Fa=function(){return-ra.event.detail},"MozMousePixelScroll")),n.event=function(n){n.each(function(){var n=L.of(this,arguments),t=k;Pu?ra.select(this).transition().each("start.zoom",function(){k=this.__chart__||{x:0,y:0,k:1},u(n)}).tween("zoom:zoom",function(){var e=_[0],r=_[1],o=m?m[0]:e/2,a=m?m[1]:r/2,i=ra.interpolateZoom([(o-k.x)/k.k,(a-k.y)/k.k,e/k.k],[(o-t.x)/t.k,(a-t.y)/t.k,e/t.k]);return function(t){var r=i(t),u=e/r[2];this.__chart__=k={x:o-r[0]*u,y:a-r[1]*u,k:u},s(n)}}).each("interrupt.zoom",function(){l(n)}).each("end.zoom",function(){l(n)}):(this.__chart__=k,u(n),s(n),l(n))})},n.translate=function(t){return arguments.length?(k={x:+t[0],y:+t[1],k:k.k},a(),n):[k.x,k.y]},n.scale=function(t){return arguments.length?(k={x:k.x,y:k.y,k:null},e(+t),a(),n):k.k},n.scaleExtent=function(t){return arguments.length?(S=null==t?ja:[+t[0],+t[1]],n):S},n.center=function(t){return arguments.length?(v=t&&[+t[0],+t[1]],n):v},n.size=function(t){return arguments.length?(_=t&&[+t[0],+t[1]],n):_},n.duration=function(t){return arguments.length?(A=+t,n):A},n.x=function(t){return arguments.length?(x=t,b=t.copy(),k={x:0,y:0,k:1},n):x},n.y=function(t){return arguments.length?(w=t,M=t.copy(),k={x:0,y:0,k:1},n):w},ra.rebind(n,L,"on")};var Fa,qa,ja=[0,1/0];ra.color=un,un.prototype.toString=function(){return this.rgb()+""},ra.hsl=sn;var Ba=sn.prototype=new un;Ba.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new sn(this.h,this.s,this.l/n)},Ba.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new sn(this.h,this.s,n*this.l)},Ba.rgb=function(){return ln(this.h,this.s,this.l)},ra.hcl=cn;var Ia=cn.prototype=new un;Ia.brighter=function(n){return new cn(this.h,this.c,Math.min(100,this.l+Ha*(arguments.length?n:1)))},Ia.darker=function(n){return new cn(this.h,this.c,Math.max(0,this.l-Ha*(arguments.length?n:1)))},Ia.rgb=function(){return fn(this.h,this.c,this.l).rgb()},ra.lab=pn;var Ha=18,Va=.95047,Xa=1,Ga=1.08883,Ya=pn.prototype=new un;Ya.brighter=function(n){return new pn(Math.min(100,this.l+Ha*(arguments.length?n:1)),this.a,this.b)},Ya.darker=function(n){return new pn(Math.max(0,this.l-Ha*(arguments.length?n:1)),this.a,this.b)},Ya.rgb=function(){return hn(this.l,this.a,this.b)},ra.rgb=yn;var Wa=yn.prototype=new un;Wa.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,o=30;return t||e||r?(t&&o>t&&(t=o),e&&o>e&&(e=o),r&&o>r&&(r=o),new yn(Math.min(255,t/n),Math.min(255,e/n),Math.min(255,r/n))):new yn(o,o,o)},Wa.darker=function(n){return new yn((n=Math.pow(.7,arguments.length?n:1))*this.r,n*this.g,n*this.b)},Wa.hsl=function(){return kn(this.r,this.g,this.b)},Wa.toString=function(){return"#"+Mn(this.r)+Mn(this.g)+Mn(this.b)};var Za=ra.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});Za.forEach(function(n,t){Za.set(n,bn(t))}),ra.functor=Tn,ra.xhr=En(w),ra.dsv=function(n,t){function e(n,e,a){arguments.length<3&&(a=e,e=null);var i=Rn(n,t,null==e?r:o(e),a);return i.row=function(n){return arguments.length?i.response(null==(e=n)?r:o(n)):e},i}function r(n){return e.parse(n.responseText)}function o(n){return function(t){return e.parse(t.responseText,n)}}function a(t){return t.map(i).join(n)}function i(n){return u.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var u=new RegExp('["'+n+"\n]"),s=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var o=new Function("d","return {"+n.map(function(n,t){return JSON.stringify(n)+": d["+t+"]"}).join(",")+"}");r=t?function(n,e){return t(o(n),e)}:o})},e.parseRows=function(n,t){function e(){if(c>=l)return i;if(o)return o=!1,a;var t=c;if(34===n.charCodeAt(t)){for(var e=t;e++c;){var r=n.charCodeAt(c++),u=1;if(10===r)o=!0;else if(13===r)o=!0,10===n.charCodeAt(c)&&(++c,++u);else if(r!==s)continue;return n.slice(t,c-u)}return n.slice(t)}for(var r,o,a={},i={},u=[],l=n.length,c=0,f=0;(r=e())!==i;){for(var p=[];r!==a&&r!==i;)p.push(r),r=e();t&&null==(p=t(p,f++))||u.push(p)}return u},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new M,o=[];return t.forEach(function(n){for(var t in n)r.has(t)||o.push(r.add(t))}),[o.map(i).join(n)].concat(t.map(function(t){return o.map(function(n){return i(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(a).join("\n")},e},ra.csv=ra.dsv(",","text/csv"),ra.tsv=ra.dsv("\t","text/tab-separated-values");var Ja,$a,Ka,Qa,ni=this[_(this,"requestAnimationFrame")]||function(n){setTimeout(n,17)};ra.timer=function(){Pn.apply(this,arguments)},ra.timer.flush=function(){On(),Cn()},ra.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)};var ti=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"].map(function(n,t){var e=Math.pow(10,3*ha(8-t));return{scale:t>8?function(n){return n/e}:function(n){return n*e},symbol:n}});ra.formatPrefix=function(n,t){var e=0;return(n=+n)&&(0>n&&(n*=-1),t&&(n=ra.round(n,Ln(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),ti[8+e/3]};var ei=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,ri=ra.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=ra.round(n,Ln(n,t))).toFixed(Math.max(0,Math.min(20,Ln(n*(1+1e-15),t))))}}),oi=ra.time={},ai=Date;Dn.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){ii.setUTCDate.apply(this._,arguments)},setDay:function(){ii.setUTCDay.apply(this._,arguments)},setFullYear:function(){ii.setUTCFullYear.apply(this._,arguments)},setHours:function(){ii.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){ii.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){ii.setUTCMinutes.apply(this._,arguments)},setMonth:function(){ii.setUTCMonth.apply(this._,arguments)},setSeconds:function(){ii.setUTCSeconds.apply(this._,arguments)},setTime:function(){ii.setTime.apply(this._,arguments)}};var ii=Date.prototype;oi.year=zn(function(n){return(n=oi.day(n)).setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),oi.years=oi.year.range,oi.years.utc=oi.year.utc.range,oi.day=zn(function(n){var t=new ai(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),oi.days=oi.day.range,oi.days.utc=oi.day.utc.range,oi.dayOfYear=function(n){var t=oi.year(n);return Math.floor((n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(n,t){t=7-t;var e=oi[n]=zn(function(n){return(n=oi.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+7*Math.floor(t))},function(n){var e=oi.year(n).getDay();return Math.floor((oi.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});oi[n+"s"]=e.range,oi[n+"s"].utc=e.utc.range,oi[n+"OfYear"]=function(n){var e=oi.year(n).getDay();return Math.floor((oi.dayOfYear(n)+(e+t)%7)/7)}}),oi.week=oi.sunday,oi.weeks=oi.sunday.range,oi.weeks.utc=oi.sunday.utc.range,oi.weekOfYear=oi.sundayOfYear;var ui={"-":"",_:" ",0:"0"},si=/^\s*\d+/,li=/^%/;ra.locale=function(n){return{numberFormat:function(n){var t=n.decimal,e=n.thousands,r=n.grouping,o=n.currency,a=r&&e?function(n,t){for(var o=n.length,a=[],i=0,u=r[0],s=0;o>0&&u>0&&(s+u+1>t&&(u=Math.max(1,t-s)),a.push(n.substring(o-=u,o+u)),!((s+=u+1)>t));)u=r[i=(i+1)%r.length];return a.reverse().join(e)}:w;return function(n){var e=ei.exec(n),r=e[1]||" ",i=e[2]||">",u=e[3]||"-",s=e[4]||"",l=e[5],c=+e[6],f=e[7],p=e[8],h=e[9],d=1,m="",v="",g=!1,y=!0;switch(p&&(p=+p.substring(1)),(l||"0"===r&&"="===i)&&(l=r="0",i="="),h){case"n":f=!0,h="g";break;case"%":d=100,v="%",h="f";break;case"p":d=100,v="%",h="r";break;case"b":case"o":case"x":case"X":"#"===s&&(m="0"+h.toLowerCase());case"c":y=!1;case"d":g=!0,p=0;break;case"s":d=-1,h="r"}"$"===s&&(m=o[0],v=o[1]),"r"!=h||p||(h="g"),null!=p&&("g"==h?p=Math.max(1,Math.min(21,p)):("e"==h||"f"==h)&&(p=Math.max(0,Math.min(20,p)))),h=ri.get(h)||Un;var b=l&&f;return function(n){var e=v;if(g&&n%1)return"";var o=0>n||0===n&&0>1/n?(n=-n,"-"):"-"===u?"":u;if(0>d){var s=ra.formatPrefix(n,p);n=s.scale(n),e=s.symbol+v}else n*=d;var x,M,w=(n=h(n,p)).lastIndexOf(".");if(0>w){var k=y?n.lastIndexOf("e"):-1;0>k?(x=n,M=""):(x=n.substring(0,k),M=n.substring(k))}else x=n.substring(0,w),M=t+n.substring(w+1);!l&&f&&(x=a(x,1/0));var _=m.length+x.length+M.length+(b?0:o.length),S=c>_?new Array(_=c-_+1).join(r):"";return b&&(x=a(S+x,S.length?c-M.length:1/0)),o+=m,n=x+M,("<"===i?o+n+S:">"===i?S+o+n:"^"===i?S.substring(0,_>>=1)+o+n+S.substring(_):o+(b?n:S+n))+e}}}(n),timeFormat:function(n){function t(n){function t(t){for(var e,o,a,i=[],u=-1,s=0;++uu;){if(r>=l)return-1;if(37===(o=t.charCodeAt(u++))){if(i=t.charAt(u++),!(a=M[i in ui?t.charAt(u++):i])||(r=a(n,e,r))<0)return-1}else if(o!=e.charCodeAt(r++))return-1}return r}var r=n.dateTime,o=n.date,a=n.time,i=n.periods,u=n.days,s=n.shortDays,l=n.months,c=n.shortMonths;t.utc=function(n){function e(n){try{var t=new(ai=Dn);return t._=n,r(t)}finally{ai=Date}}var r=t(n);return e.parse=function(n){try{ai=Dn;var t=r.parse(n);return t&&t._}finally{ai=Date}},e.toString=r.toString,e},t.multi=t.utc.multi=rt;var f=ra.map(),p=jn(u),h=Bn(u),d=jn(s),m=Bn(s),v=jn(l),g=Bn(l),y=jn(c),b=Bn(c);i.forEach(function(n,t){f.set(n.toLowerCase(),t)});var x={a:function(n){return s[n.getDay()]},A:function(n){return u[n.getDay()]},b:function(n){return c[n.getMonth()]},B:function(n){return l[n.getMonth()]},c:t(r),d:function(n,t){return qn(n.getDate(),t,2)},e:function(n,t){return qn(n.getDate(),t,2)},H:function(n,t){return qn(n.getHours(),t,2)},I:function(n,t){return qn(n.getHours()%12||12,t,2)},j:function(n,t){return qn(1+oi.dayOfYear(n),t,3)},L:function(n,t){return qn(n.getMilliseconds(),t,3)},m:function(n,t){return qn(n.getMonth()+1,t,2)},M:function(n,t){return qn(n.getMinutes(),t,2)},p:function(n){return i[+(n.getHours()>=12)]},S:function(n,t){return qn(n.getSeconds(),t,2)},U:function(n,t){return qn(oi.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return qn(oi.mondayOfYear(n),t,2)},x:t(o),X:t(a),y:function(n,t){return qn(n.getFullYear()%100,t,2)},Y:function(n,t){return qn(n.getFullYear()%1e4,t,4)},Z:tt,"%":function(){return"%"}},M={a:function(n,t,e){d.lastIndex=0;var r=d.exec(t.slice(e));return r?(n.w=m.get(r[0].toLowerCase()),e+r[0].length):-1},A:function(n,t,e){p.lastIndex=0;var r=p.exec(t.slice(e));return r?(n.w=h.get(r[0].toLowerCase()),e+r[0].length):-1},b:function(n,t,e){y.lastIndex=0;var r=y.exec(t.slice(e));return r?(n.m=b.get(r[0].toLowerCase()),e+r[0].length):-1},B:function(n,t,e){v.lastIndex=0;var r=v.exec(t.slice(e));return r?(n.m=g.get(r[0].toLowerCase()),e+r[0].length):-1},c:function(n,t,r){return e(n,x.c.toString(),t,r)},d:Zn,e:Zn,H:$n,I:$n,j:Jn,L:nt,m:Wn,M:Kn,p:function(n,t,e){var r=f.get(t.slice(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)},S:Qn,U:Hn,w:In,W:Vn,x:function(n,t,r){return e(n,x.x.toString(),t,r)},X:function(n,t,r){return e(n,x.X.toString(),t,r)},y:Gn,Y:Xn,Z:Yn,"%":et};return t}(n)}};var ci=ra.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});ra.format=ci.numberFormat,ra.geo={},ot.prototype={s:0,t:0,add:function(n){at(n,this.t,fi),at(fi.s,this.s,this),this.s?this.t+=fi.t:this.s=fi.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var fi=new ot;ra.geo.stream=function(n,t){n&&pi.hasOwnProperty(n.type)?pi[n.type](n,t):it(n,t)};var pi={Feature:function(n,t){it(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,o=e.length;++rn?4*Na+n:n,vi.lineStart=vi.lineEnd=vi.point=S}};ra.geo.bounds=function(){function n(n,t){b.push(x=[c=n,p=n]),f>t&&(f=t),t>h&&(h=t)}function t(t,e){var r=ct([t*Ua,e*Ua]);if(g){var o=pt(g,r),a=[o[1],-o[0],0],i=pt(a,o);mt(i),i=vt(i);var s=t-d,l=s>0?1:-1,m=i[0]*Da*l,v=ha(s)>180;if(v^(m>l*d&&l*t>m)){var y=i[1]*Da;y>h&&(h=y)}else if(v^((m=(m+360)%360-180)>l*d&&l*t>m)){var y=-i[1]*Da;f>y&&(f=y)}else f>e&&(f=e),e>h&&(h=e);v?d>t?u(c,t)>u(c,p)&&(p=t):u(t,p)>u(c,p)&&(c=t):p>=c?(c>t&&(c=t),t>p&&(p=t)):t>d?u(c,t)>u(c,p)&&(p=t):u(t,p)>u(c,p)&&(c=t)}else n(t,e);g=r,d=t}function e(){M.point=t}function r(){x[0]=c,x[1]=p,M.point=n,g=null}function o(n,e){if(g){var r=n-d;y+=ha(r)>180?r+(r>0?360:-360):r}else m=n,v=e;vi.point(n,e),t(n,e)}function a(){vi.lineStart()}function i(){o(m,v),vi.lineEnd(),ha(y)>Ra&&(c=-(p=180)),x[0]=c,x[1]=p,g=null}function u(n,t){return(t-=n)<0?t+360:t}function s(n,t){return n[0]-t[0]}function l(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:nmi?(c=-(p=180),f=-(h=90)):y>Ra?h=90:-Ra>y&&(f=-90),x[0]=c,x[1]=p}};return function(n){h=p=-(c=f=1/0),b=[],ra.geo.stream(n,M);var t=b.length;if(t){b.sort(s);for(var e=1,r=b[0],o=[r];t>e;++e)l((i=b[e])[0],r)||l(i[1],r)?(u(r[0],i[1])>u(r[0],r[1])&&(r[1]=i[1]),u(i[0],r[1])>u(r[0],r[1])&&(r[0]=i[0])):o.push(r=i);for(var a,i,d=-1/0,t=o.length-1,e=0,r=o[t];t>=e;r=i,++e)i=o[e],(a=u(r[1],i[0]))>d&&(d=a,c=i[0],p=r[1])}return b=x=null,c===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[c,f],[p,h]]}}(),ra.geo.centroid=function(n){gi=yi=bi=xi=Mi=wi=ki=_i=Si=Ai=Ti=0,ra.geo.stream(n,Ei);var t=Si,e=Ai,r=Ti,o=t*t+e*e+r*r;return Pa>o&&(t=wi,e=ki,r=_i,Ra>yi&&(t=bi,e=xi,r=Mi),Pa>(o=t*t+e*e+r*r))?[NaN,NaN]:[Math.atan2(e,t)*Da,rn(r/Math.sqrt(o))*Da]};var gi,yi,bi,xi,Mi,wi,ki,_i,Si,Ai,Ti,Ei={sphere:S,point:yt,lineStart:xt,lineEnd:Mt,polygonStart:function(){Ei.lineStart=wt},polygonEnd:function(){Ei.lineStart=xt}},Ri=Et(_t,function(n){var t,e=NaN,r=NaN,o=NaN;return{lineStart:function(){n.lineStart(),t=1},point:function(a,i){var u=a>0?Na:-Na,s=ha(a-e);ha(s-Na)0?La:-La),n.point(o,r),n.lineEnd(),n.lineStart(),n.point(u,r),n.point(a,r),t=0):o!==u&&s>=Na&&(ha(e-o)Ra?Math.atan((Math.sin(t)*(a=Math.cos(r))*Math.sin(e)-Math.sin(r)*(o=Math.cos(t))*Math.sin(n))/(o*a*i)):(t+r)/2}(e,r,a,i),n.point(o,r),n.lineEnd(),n.lineStart(),n.point(u,r),t=0),n.point(e=a,r=i),o=u},lineEnd:function(){n.lineEnd(),e=r=NaN},clean:function(){return 2-t}}},function(n,t,e,r){var o;if(null==n)o=e*La,r.point(-Na,o),r.point(0,o),r.point(Na,o),r.point(Na,0),r.point(Na,-o),r.point(0,-o),r.point(-Na,-o),r.point(-Na,0),r.point(-Na,o);else if(ha(n[0]-t[0])>Ra){var a=n[0]=.12&&.234>o&&r>=-.425&&-.214>r?i:o>=.166&&.234>o&&r>=-.214&&-.115>r?u:a).invert(n)},n.stream=function(n){var t=a.stream(n),e=i.stream(n),r=u.stream(n);return{point:function(n,o){t.point(n,o),e.point(n,o),r.point(n,o)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},n.precision=function(t){return arguments.length?(a.precision(t),i.precision(t),u.precision(t),n):a.precision()},n.scale=function(t){return arguments.length?(a.scale(t),i.scale(.35*t),u.scale(t),n.translate(a.translate())):a.scale()},n.translate=function(t){if(!arguments.length)return a.translate();var l=a.scale(),c=+t[0],f=+t[1];return e=a.translate(t).clipExtent([[c-.455*l,f-.238*l],[c+.455*l,f+.238*l]]).stream(s).point,r=i.translate([c-.307*l,f+.201*l]).clipExtent([[c-.425*l+Ra,f+.12*l+Ra],[c-.214*l-Ra,f+.234*l-Ra]]).stream(s).point,o=u.translate([c-.205*l,f+.212*l]).clipExtent([[c-.214*l+Ra,f+.166*l+Ra],[c-.115*l-Ra,f+.234*l-Ra]]).stream(s).point,n},n.scale(1070)};var Ni,Oi,Ci,Li,Ui,Di,zi={point:S,lineStart:S,lineEnd:S,polygonStart:function(){Oi=0,zi.lineStart=Dt},polygonEnd:function(){zi.lineStart=zi.lineEnd=zi.point=S,Ni+=ha(Oi/2)}},Fi={point:function(n,t){Ci>n&&(Ci=n),n>Ui&&(Ui=n),Li>t&&(Li=t),t>Di&&(Di=t)},lineStart:S,lineEnd:S,polygonStart:S,polygonEnd:S},qi={point:qt,lineStart:jt,lineEnd:Bt,polygonStart:function(){qi.lineStart=It},polygonEnd:function(){qi.point=qt,qi.lineStart=jt,qi.lineEnd=Bt}};ra.geo.path=function(){function n(n){return n&&("function"==typeof u&&a.pointRadius(+u.apply(this,arguments)),i&&i.valid||(i=o(a)),ra.geo.stream(n,i)),a.result()}function t(){return i=null,n}var e,r,o,a,i,u=4.5;return n.area=function(n){return Ni=0,ra.geo.stream(n,o(zi)),Ni},n.centroid=function(n){return bi=xi=Mi=wi=ki=_i=Si=Ai=Ti=0,ra.geo.stream(n,o(qi)),Ti?[Si/Ti,Ai/Ti]:_i?[wi/_i,ki/_i]:Mi?[bi/Mi,xi/Mi]:[NaN,NaN]},n.bounds=function(n){return Ui=Di=-(Ci=Li=1/0),ra.geo.stream(n,o(Fi)),[[Ci,Li],[Ui,Di]]},n.projection=function(n){return arguments.length?(o=(e=n)?n.stream||function(n){var t=Vt(function(t,e){return n([t*Da,e*Da])});return function(n){return Zt(t(n))}}(n):w,t()):e},n.context=function(n){return arguments.length?(a=null==(r=n)?new zt:new Ht(n),"function"!=typeof u&&a.pointRadius(u),t()):r},n.pointRadius=function(t){return arguments.length?(u="function"==typeof t?t:(a.pointRadius(+t),+t),n):u},n.projection(ra.geo.albersUsa()).context(null)},ra.geo.transform=function(n){return{stream:function(t){var e=new Xt(t);for(var r in n)e[r]=n[r];return e}}},Xt.prototype={point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},ra.geo.projection=Yt,ra.geo.projectionMutator=Wt,(ra.geo.equirectangular=function(){return Yt(Jt)}).raw=Jt.invert=Jt,ra.geo.rotation=function(n){function t(t){return(t=n(t[0]*Ua,t[1]*Ua))[0]*=Da,t[1]*=Da,t}return n=Kt(n[0]%360*Ua,n[1]*Ua,n.length>2?n[2]*Ua:0),t.invert=function(t){return(t=n.invert(t[0]*Ua,t[1]*Ua))[0]*=Da,t[1]*=Da,t},t},$t.invert=Jt,ra.geo.circle=function(){function n(){var n="function"==typeof r?r.apply(this,arguments):r,t=Kt(-n[0]*Ua,-n[1]*Ua,0).invert,o=[];return e(null,null,1,{point:function(n,e){o.push(n=t(n,e)),n[0]*=Da,n[1]*=Da}}),{type:"Polygon",coordinates:[o]}}var t,e,r=[0,0],o=6;return n.origin=function(t){return arguments.length?(r=t,n):r},n.angle=function(r){return arguments.length?(e=ee((t=+r)*Ua,o*Ua),n):t},n.precision=function(r){return arguments.length?(e=ee(t*Ua,(o=+r)*Ua),n):o},n.angle(90)},ra.geo.distance=function(n,t){var e,r=(t[0]-n[0])*Ua,o=n[1]*Ua,a=t[1]*Ua,i=Math.sin(r),u=Math.cos(r),s=Math.sin(o),l=Math.cos(o),c=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((e=f*i)*e+(e=l*c-s*f*u)*e),s*c+l*f*u)},ra.geo.graticule=function(){function n(){return{type:"MultiLineString",coordinates:t()}}function t(){return ra.range(Math.ceil(a/v)*v,o,v).map(p).concat(ra.range(Math.ceil(l/g)*g,s,g).map(h)).concat(ra.range(Math.ceil(r/d)*d,e,d).filter(function(n){return ha(n%v)>Ra}).map(c)).concat(ra.range(Math.ceil(u/m)*m,i,m).filter(function(n){return ha(n%g)>Ra}).map(f))}var e,r,o,a,i,u,s,l,c,f,p,h,d=10,m=d,v=90,g=360,y=2.5;return n.lines=function(){return t().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[p(a).concat(h(s).slice(1),p(o).reverse().slice(1),h(l).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.majorExtent(t).minorExtent(t):n.minorExtent()},n.majorExtent=function(t){return arguments.length?(a=+t[0][0],o=+t[1][0],l=+t[0][1],s=+t[1][1],a>o&&(t=a,a=o,o=t),l>s&&(t=l,l=s,s=t),n.precision(y)):[[a,l],[o,s]]},n.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],u=+t[0][1],i=+t[1][1],r>e&&(t=r,r=e,e=t),u>i&&(t=u,u=i,i=t),n.precision(y)):[[r,u],[e,i]]},n.step=function(t){return arguments.length?n.majorStep(t).minorStep(t):n.minorStep()},n.majorStep=function(t){return arguments.length?(v=+t[0],g=+t[1],n):[v,g]},n.minorStep=function(t){return arguments.length?(d=+t[0],m=+t[1],n):[d,m]},n.precision=function(t){return arguments.length?(y=+t,c=oe(u,i,90),f=ae(r,e,y),p=oe(l,s,90),h=ae(a,o,y),n):y},n.majorExtent([[-180,-90+Ra],[180,90-Ra]]).minorExtent([[-180,-80-Ra],[180,80+Ra]])},ra.geo.greatArc=function(){function n(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||o.apply(this,arguments)]}}var t,e,r=ie,o=ue;return n.distance=function(){return ra.geo.distance(t||r.apply(this,arguments),e||o.apply(this,arguments))},n.source=function(e){return arguments.length?(r=e,t="function"==typeof e?null:e,n):r},n.target=function(t){return arguments.length?(o=t,e="function"==typeof t?null:t,n):o},n.precision=function(){return arguments.length?n:0},n},ra.geo.interpolate=function(n,t){return function(n,t,e,r){var o=Math.cos(t),a=Math.sin(t),i=Math.cos(r),u=Math.sin(r),s=o*Math.cos(n),l=o*Math.sin(n),c=i*Math.cos(e),f=i*Math.sin(e),p=2*Math.asin(Math.sqrt(an(r-t)+o*i*an(e-n))),h=1/Math.sin(p),d=p?function(n){var t=Math.sin(n*=p)*h,e=Math.sin(p-n)*h,r=e*s+t*c,o=e*l+t*f,i=e*a+t*u;return[Math.atan2(o,r)*Da,Math.atan2(i,Math.sqrt(r*r+o*o))*Da]}:function(){return[n*Da,t*Da]};return d.distance=p,d}(n[0]*Ua,n[1]*Ua,t[0]*Ua,t[1]*Ua)},ra.geo.length=function(n){return ji=0,ra.geo.stream(n,Bi),ji};var ji,Bi={sphere:S,point:S,lineStart:function(){function n(n,o){var a=Math.sin(o*=Ua),i=Math.cos(o),u=ha((n*=Ua)-t),s=Math.cos(u);ji+=Math.atan2(Math.sqrt((u=i*Math.sin(u))*u+(u=r*a-e*i*s)*u),e*a+r*i*s),t=n,e=a,r=i}var t,e,r;Bi.point=function(o,a){t=o*Ua,e=Math.sin(a*=Ua),r=Math.cos(a),Bi.point=n},Bi.lineEnd=function(){Bi.point=Bi.lineEnd=S}},lineEnd:S,polygonStart:S,polygonEnd:S},Ii=se(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(ra.geo.azimuthalEqualArea=function(){return Yt(Ii)}).raw=Ii;var Hi=se(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},w);(ra.geo.azimuthalEquidistant=function(){return Yt(Hi)}).raw=Hi,(ra.geo.conicConformal=function(){return Lt(le)}).raw=le,(ra.geo.conicEquidistant=function(){return Lt(ce)}).raw=ce;var Vi=se(function(n){return 1/n},Math.atan);(ra.geo.gnomonic=function(){return Yt(Vi)}).raw=Vi,fe.invert=function(n,t){return[n,2*Math.atan(Math.exp(t))-La]},(ra.geo.mercator=function(){return pe(fe)}).raw=fe;var Xi=se(function(){return 1},Math.asin);(ra.geo.orthographic=function(){return Yt(Xi)}).raw=Xi;var Gi=se(function(n){return 1/(1+n)},function(n){return 2*Math.atan(n)});(ra.geo.stereographic=function(){return Yt(Gi)}).raw=Gi,he.invert=function(n,t){return[-t,2*Math.atan(Math.exp(n))-La]},(ra.geo.transverseMercator=function(){var n=pe(he),t=n.center,e=n.rotate;return n.center=function(n){return n?t([-n[1],n[0]]):[(n=t())[1],-n[0]]},n.rotate=function(n){return n?e([n[0],n[1],n.length>2?n[2]+90:90]):[(n=e())[0],n[1],n[2]-90]},e([0,0,90])}).raw=he,ra.geom={},ra.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,o=Tn(e),a=Tn(r),i=n.length,u=[],s=[];for(t=0;i>t;t++)u.push([+o.call(this,n[t],t),+a.call(this,n[t],t),t]);for(u.sort(ge),t=0;i>t;t++)s.push([u[t][0],-u[t][1]]);var l=ve(u),c=ve(s),f=c[0]===l[0],p=c[c.length-1]===l[l.length-1],h=[];for(t=l.length-1;t>=0;--t)h.push(n[u[l[t]][2]]);for(t=+f;t=r&&l.x<=a&&l.y>=o&&l.y<=i?[[r,i],[a,i],[a,o],[r,o]]:[];c.point=n[u]}),t}function e(n){return n.map(function(n,t){return{x:Math.round(a(n,t)/Ra)*Ra,y:Math.round(i(n,t)/Ra)*Ra,i:t}})}var r=de,o=me,a=r,i=o,u=tu;return n?t(n):(t.links=function(n){return Ve(e(n)).edges.filter(function(n){return n.l&&n.r}).map(function(t){return{source:n[t.l.i],target:n[t.r.i]}})},t.triangles=function(n){var t=[];return Ve(e(n)).cells.forEach(function(e,r){for(var o,a=e.site,i=e.edges.sort(Re),u=-1,s=i.length,l=i[s-1].edge,c=l.l===a?l.r:l.l;++u=l,p=r>=c,h=p<<1|f;n.leaf=!1,n=n.nodes[h]||(n.nodes[h]={leaf:!0,nodes:[],point:null,x:null,y:null}),f?o=l:u=l,p?i=c:s=c,a(n,t,e,r,o,i,u,s)}var c,f,p,h,d,m,v,g,y,b=Tn(u),x=Tn(s);if(null!=t)m=t,v=e,g=r,y=o;else if(g=y=-(m=v=1/0),f=[],p=[],d=n.length,i)for(h=0;d>h;++h)(c=n[h]).xg&&(g=c.x),c.y>y&&(y=c.y),f.push(c.x),p.push(c.y);else for(h=0;d>h;++h){var M=+b(c=n[h],h),w=+x(c,h);m>M&&(m=M),v>w&&(v=w),M>g&&(g=M),w>y&&(y=w),f.push(M),p.push(w)}var k=g-m,_=y-v;k>_?y=v+k:g=m+_;var S={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(n){a(S,n,+b(n,++h),+x(n,h),m,v,g,y)},visit:function(n){!function n(t,e,r,o,a,i){if(!t(e,r,o,a,i)){var u=.5*(r+a),s=.5*(o+i),l=e.nodes;l[0]&&n(t,l[0],r,o,u,s),l[1]&&n(t,l[1],u,o,a,s),l[2]&&n(t,l[2],r,s,u,i),l[3]&&n(t,l[3],u,s,a,i)}}(n,S,m,v,g,y)},find:function(n){return function(n,t,e,r,o,a,i){var u,s=1/0;return function n(l,c,f,p,h){if(!(c>a||f>i||r>p||o>h)){if(d=l.point){var d,m=t-l.x,v=e-l.y,g=m*m+v*v;if(s>g){var y=Math.sqrt(s=g);r=t-y,o=e-y,a=t+y,i=e+y,u=d}}for(var b=l.nodes,x=.5*(c+p),M=.5*(f+h),w=t>=x,k=e>=M,_=k<<1|w,S=_+4;S>_;++_)if(l=b[3&_])switch(3&_){case 0:n(l,c,f,x,M);break;case 1:n(l,x,f,p,M);break;case 2:n(l,c,M,x,h);break;case 3:n(l,x,M,p,h)}}}(n,r,o,a,i),u}(S,n[0],n[1],m,v,g,y)}};if(h=-1,null==t){for(;++h=0?n.slice(0,t):n,r=t>=0?n.slice(t+1):"in";return e=au.get(e)||ou,function(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}((r=iu.get(r)||w)(e.apply(null,oa.call(arguments,1))))},ra.interpolateHcl=function(n,t){n=ra.hcl(n),t=ra.hcl(t);var e=n.h,r=n.c,o=n.l,a=t.h-e,i=t.c-r,u=t.l-o;return isNaN(i)&&(i=0,r=isNaN(r)?t.c:r),isNaN(a)?(a=0,e=isNaN(e)?t.h:e):a>180?a-=360:-180>a&&(a+=360),function(n){return fn(e+a*n,r+i*n,o+u*n)+""}},ra.interpolateHsl=function(n,t){n=ra.hsl(n),t=ra.hsl(t);var e=n.h,r=n.s,o=n.l,a=t.h-e,i=t.s-r,u=t.l-o;return isNaN(i)&&(i=0,r=isNaN(r)?t.s:r),isNaN(a)?(a=0,e=isNaN(e)?t.h:e):a>180?a-=360:-180>a&&(a+=360),function(n){return ln(e+a*n,r+i*n,o+u*n)+""}},ra.interpolateLab=function(n,t){n=ra.lab(n),t=ra.lab(t);var e=n.l,r=n.a,o=n.b,a=t.l-e,i=t.a-r,u=t.b-o;return function(n){return hn(e+a*n,r+i*n,o+u*n)+""}},ra.interpolateRound=cr,ra.transform=function(n){var t=ia.createElementNS(ra.ns.prefix.svg,"g");return(ra.transform=function(n){if(null!=n){t.setAttribute("transform",n);var e=t.transform.baseVal.consolidate()}return new fr(e?e.matrix:uu)})(n)},fr.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var uu={a:1,b:0,c:0,d:1,e:0,f:0};ra.interpolateTransform=mr,ra.layout={},ra.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++eu*u/g){if(m>s){var l=t.charge/s;n.px-=a*l,n.py-=i*l}return!0}if(t.point&&s&&m>s){var l=t.pointCharge/s;n.px-=a*l,n.py-=i*l}}return!t.charge}}function t(n){n.px=ra.event.x,n.py=ra.event.y,s.resume()}var e,r,o,a,i,u,s={},l=ra.dispatch("start","tick","end"),c=[1,1],f=.9,p=su,h=lu,d=-30,m=cu,v=.1,g=.64,y=[],b=[];return s.tick=function(){if((o*=.99)<.005)return e=null,l.end({type:"end",alpha:o=0}),!0;var t,r,s,p,h,m,g,x,M,w=y.length,k=b.length;for(r=0;k>r;++r)s=b[r],p=s.source,h=s.target,x=h.x-p.x,M=h.y-p.y,(m=x*x+M*M)&&(m=o*i[r]*((m=Math.sqrt(m))-a[r])/m,x*=m,M*=m,h.x-=x*(g=p.weight+h.weight?p.weight/(p.weight+h.weight):.5),h.y-=M*g,p.x+=x*(g=1-g),p.y+=M*g);if((g=o*v)&&(x=c[0]/2,M=c[1]/2,r=-1,g))for(;++r0?o=n:(e.c=null,e.t=NaN,e=null,l.end({type:"end",alpha:o=0})):n>0&&(l.start({type:"start",alpha:o=n}),e=Pn(s.tick)),s):o},s.start=function(){function n(n,r){if(!e){for(e=new Array(o),s=0;o>s;++s)e[s]=[];for(s=0;l>s;++s){var a=b[s];e[a.source.index].push(a.target),e[a.target.index].push(a.source)}}for(var i,u=e[t],s=-1,c=u.length;++st;++t)(r=y[t]).index=t,r.weight=0;for(t=0;l>t;++t)"number"==typeof(r=b[t]).source&&(r.source=y[r.source]),"number"==typeof r.target&&(r.target=y[r.target]),++r.source.weight,++r.target.weight;for(t=0;o>t;++t)r=y[t],isNaN(r.x)&&(r.x=n("x",f)),isNaN(r.y)&&(r.y=n("y",m)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(a=[],"function"==typeof p)for(t=0;l>t;++t)a[t]=+p.call(this,b[t],t);else for(t=0;l>t;++t)a[t]=p;if(i=[],"function"==typeof h)for(t=0;l>t;++t)i[t]=+h.call(this,b[t],t);else for(t=0;l>t;++t)i[t]=h;if(u=[],"function"==typeof d)for(t=0;o>t;++t)u[t]=+d.call(this,y[t],t);else for(t=0;o>t;++t)u[t]=d;return s.resume()},s.resume=function(){return s.alpha(.1)},s.stop=function(){return s.alpha(0)},s.drag=function(){return r||(r=ra.behavior.drag().origin(w).on("dragstart.force",xr).on("drag.force",t).on("dragend.force",Mr)),arguments.length?void this.on("mouseover.force",wr).on("mouseout.force",kr).call(r):r},ra.rebind(s,l,"on")};var su=20,lu=1,cu=1/0;ra.layout.hierarchy=function(){function n(o){var a,i=[o],u=[];for(o.depth=0;null!=(a=i.pop());)if(u.push(a),(l=e.call(n,a,a.depth))&&(s=l.length)){for(var s,l,c;--s>=0;)i.push(c=l[s]),c.parent=a,c.depth=a.depth+1;r&&(a.value=0),a.children=l}else r&&(a.value=+r.call(n,a,a.depth)||0),delete a.children;return Ar(o,function(n){var e,o;t&&(e=n.children)&&e.sort(t),r&&(o=n.parent)&&(o.value+=n.value)}),u}var t=Rr,e=Tr,r=Er;return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Sr(t,function(n){n.children&&(n.value=0)}),Ar(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},ra.layout.partition=function(){function n(n,r){var o=t.call(this,n,r);return function n(t,e,r,o){var a=t.children;if(t.x=e,t.y=t.depth*o,t.dx=r,t.dy=o,a&&(i=a.length)){var i,u,s,l=-1;for(r=t.value?r/t.value:0;++lf?-1:1),d=ra.sum(l),m=d?(f-s*h)/d:0,v=ra.range(s),g=[];return null!=e&&v.sort(e===fu?function(n,t){return l[t]-l[n]}:function(n,t){return e(i[n],i[t])}),v.forEach(function(n){g[n]={data:i[n],value:u=l[n],startAngle:c,endAngle:c+=u*m+h,padAngle:p}}),g}var t=Number,e=fu,r=0,o=Oa,a=0;return n.value=function(e){return arguments.length?(t=e,n):t},n.sort=function(t){return arguments.length?(e=t,n):e},n.startAngle=function(t){return arguments.length?(r=t,n):r},n.endAngle=function(t){return arguments.length?(o=t,n):o},n.padAngle=function(t){return arguments.length?(a=t,n):a},n};var fu={};ra.layout.stack=function(){function n(u,s){if(!(p=u.length))return u;var l=u.map(function(e,r){return t.call(n,e,r)}),c=l.map(function(t){return t.map(function(t,e){return[a.call(n,t,e),i.call(n,t,e)]})}),f=e.call(n,c,s);l=ra.permute(l,f),c=ra.permute(c,f);var p,h,d,m,v=r.call(n,c,s),g=l[0].length;for(d=0;g>d;++d)for(o.call(n,l[0][d],m=v[d],c[0][d][1]),h=1;p>h;++h)o.call(n,l[h][d],m+=c[h-1][d][1],c[h][d][1]);return u}var t=w,e=Lr,r=Ur,o=Cr,a=Nr,i=Or;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:pu.get(t)||Lr,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:hu.get(t)||Ur,n):r},n.x=function(t){return arguments.length?(a=t,n):a},n.y=function(t){return arguments.length?(i=t,n):i},n.out=function(t){return arguments.length?(o=t,n):o},n};var pu=ra.map({"inside-out":function(n){var t,e,r=n.length,o=n.map(Dr),a=n.map(zr),i=ra.range(r).sort(function(n,t){return o[n]-o[t]}),u=0,s=0,l=[],c=[];for(t=0;r>t;++t)e=i[t],s>u?(u+=a[e],l.push(e)):(s+=a[e],c.push(e));return c.reverse().concat(l)},reverse:function(n){return ra.range(n.length).reverse()},default:Lr}),hu=ra.map({silhouette:function(n){var t,e,r,o=n.length,a=n[0].length,i=[],u=0,s=[];for(e=0;a>e;++e){for(t=0,r=0;o>t;t++)r+=n[t][e][1];r>u&&(u=r),i.push(r)}for(e=0;a>e;++e)s[e]=(u-i[e])/2;return s},wiggle:function(n){var t,e,r,o,a,i,u,s,l,c=n.length,f=n[0],p=f.length,h=[];for(h[0]=s=l=0,e=1;p>e;++e){for(t=0,o=0;c>t;++t)o+=n[t][e][1];for(t=0,a=0,u=f[e][0]-f[e-1][0];c>t;++t){for(r=0,i=(n[t][e][1]-n[t][e-1][1])/(2*u);t>r;++r)i+=(n[r][e][1]-n[r][e-1][1])/u;a+=i*n[t][e][1]}h[e]=s-=o?a/o*u:0,l>s&&(l=s)}for(e=0;p>e;++e)h[e]-=l;return h},expand:function(n){var t,e,r,o=n.length,a=n[0].length,i=1/o,u=[];for(e=0;a>e;++e){for(t=0,r=0;o>t;t++)r+=n[t][e][1];if(r)for(t=0;o>t;t++)n[t][e][1]/=r;else for(t=0;o>t;t++)n[t][e][1]=i}for(e=0;a>e;++e)u[e]=0;return u},zero:Ur});ra.layout.histogram=function(){function n(n,a){for(var i,u,s=[],l=n.map(e,this),c=r.call(this,l,a),f=o.call(this,c,l,a),a=-1,p=l.length,h=f.length-1,d=t?1:1/p;++a0)for(a=-1;++a=c[0]&&u<=c[1]&&((i=s[ra.bisect(f,u,1,h)-1]).y+=d,i.push(n[a]));return s}var t=!0,e=Number,r=Br,o=qr;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=Tn(t),n):r},n.bins=function(t){return arguments.length?(o="number"==typeof t?function(n){return jr(n,t)}:Tn(t),n):o},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},ra.layout.pack=function(){function n(n,a){var i=e.call(this,n,a),u=i[0],s=o[0],l=o[1],c=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(u.x=u.y=0,Ar(u,function(n){n.r=+c(n.value)}),Ar(u,Gr),r){var f=r*(t?1:Math.max(2*u.r/s,2*u.r/l))/2;Ar(u,function(n){n.r+=f}),Ar(u,Gr),Ar(u,function(n){n.r-=f})}return function n(t,e,r,o){var a=t.children;if(t.x=e+=o*t.x,t.y=r+=o*t.y,t.r*=o,a)for(var i=-1,u=a.length;++ii;++i)r.push((a[i]=o={_:a[i],parent:t,children:(o=a[i].children)&&o.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:i}).a=o);return e.children[0]}(c);if(Ar(f,t),f.parent.m=-f.z,Sr(f,e),u)Sr(c,r);else{var p=c,h=c,d=c;Sr(c,function(n){n.xh.x&&(h=n),n.depth>d.depth&&(d=n)});var m=a(p,h)/2-p.x,v=i[0]/(h.x+a(h,p)/2+m),g=i[1]/(d.depth||1);Sr(c,function(n){n.x=(n.x+m)*v,n.y=n.depth*g})}return l}function t(n){var t=n.children,e=n.parent.children,r=n.i?e[n.i-1]:null;if(t.length){!function(n){for(var t,e=0,r=0,o=n.children,a=o.length;--a>=0;)(t=o[a]).z+=e,t.m+=e,e+=t.s+(r+=t.c)}(n);var o=(t[0].z+t[t.length-1].z)/2;r?(n.z=r.z+a(n._,r._),n.m=n.z-o):n.z=o}else r&&(n.z=r.z+a(n._,r._));n.parent.A=function(n,t,e){if(t){for(var r,o=n,i=n,u=t,s=o.parent.children[0],l=o.m,c=i.m,f=u.m,p=s.m;u=Kr(u),o=$r(o),u&&o;)s=$r(s),(i=Kr(i)).a=n,(r=u.z+f-o.z-l+a(u._,o._))>0&&(Qr(no(u,n,e),n,r),l+=r,c+=r),f+=u.m,l+=o.m,p+=s.m,c+=i.m;u&&!Kr(i)&&(i.t=u,i.m+=f-c),o&&!$r(s)&&(s.t=o,s.m+=l-p,e=n)}return e}(n,r,n.parent.A||e[0])}function e(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function r(n){n.x*=i[0],n.y=n.depth*i[1]}var o=ra.layout.hierarchy().sort(null).value(null),a=Jr,i=[1,1],u=null;return n.separation=function(t){return arguments.length?(a=t,n):a},n.size=function(t){return arguments.length?(u=null==(i=t)?r:null,n):u?null:i},n.nodeSize=function(t){return arguments.length?(u=null==(i=t)?null:r,n):u?i:null},_r(n,o)},ra.layout.cluster=function(){function n(n,a){var i,u=t.call(this,n,a),s=u[0],l=0;Ar(s,function(n){var t=n.children;t&&t.length?(n.x=function(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}(t),n.y=function(n){return 1+ra.max(n,function(n){return n.y})}(t)):(n.x=i?l+=e(n,i):0,n.y=0,i=n)});var c=function n(t){var e=t.children;return e&&e.length?n(e[0]):t}(s),f=function n(t){var e,r=t.children;return r&&(e=r.length)?n(r[e-1]):t}(s),p=c.x-e(c,f)/2,h=f.x+e(f,c)/2;return Ar(s,o?function(n){n.x=(n.x-s.x)*r[0],n.y=(s.y-n.y)*r[1]}:function(n){n.x=(n.x-p)/(h-p)*r[0],n.y=(1-(s.y?n.y/s.y:1))*r[1]}),u}var t=ra.layout.hierarchy().sort(null).value(null),e=Jr,r=[1,1],o=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(o=null==(r=t),n):o?null:r},n.nodeSize=function(t){return arguments.length?(o=null!=(r=t),n):o?r:null},_r(n,t)},ra.layout.treemap=function(){function n(n,t){for(var e,r,o=-1,a=n.length;++ot?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var a=e.children;if(a&&a.length){var i,u,s,l=f(e),c=[],p=a.slice(),d=1/0,m="slice"===h?l.dx:"dice"===h?l.dy:"slice-dice"===h?1&e.depth?l.dy:l.dx:Math.min(l.dx,l.dy);for(n(p,l.dx*l.dy/e.value),c.area=0;(s=p.length)>0;)c.push(i=p[s-1]),c.area+=i.area,"squarify"!==h||(u=r(c,m))<=d?(p.pop(),d=u):(c.area-=c.pop().area,o(c,m,l,!1),m=Math.min(l.dx,l.dy),c.length=c.area=0,d=1/0);c.length&&(o(c,m,l,!0),c.length=c.area=0),a.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var a,i=f(t),u=r.slice(),s=[];for(n(u,i.dx*i.dy/t.value),s.area=0;a=u.pop();)s.push(a),s.area+=a.area,null!=a.z&&(o(s,a.z?i.dx:i.dy,i,!u.length),s.length=s.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,o=0,a=1/0,i=-1,u=n.length;++ie&&(a=e),e>o&&(o=e));return t*=t,(r*=r)?Math.max(t*o*d/r,r/(t*a*d)):1/0}function o(n,t,e,r){var o,a=-1,i=n.length,u=e.x,l=e.y,c=t?s(n.area/t):0;if(t==e.dx){for((r||c>e.dy)&&(c=e.dy);++ae.dx)&&(c=e.dx);++ae&&(t=1),1>e&&(n=0),function(){var e,r,o;do{e=2*Math.random()-1,r=2*Math.random()-1,o=e*e+r*r}while(!o||o>1);return n+t*e*Math.sqrt(-2*Math.log(o)/o)}},logNormal:function(){var n=ra.random.normal.apply(ra,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=ra.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},ra.scale={};var du={floor:w,ceil:w};ra.scale.linear=function(){return function n(t,e,r,o){function a(){var n=Math.min(t.length,e.length)>2?so:ao,a=o?gr:vr;return u=n(t,e,a,r),s=n(e,t,a,Qe),i}function i(n){return u(n)}var u,s;return i.invert=function(n){return s(n)},i.domain=function(n){return arguments.length?(t=n.map(Number),a()):t},i.range=function(n){return arguments.length?(e=n,a()):e},i.rangeRound=function(n){return i.range(n).interpolate(cr)},i.clamp=function(n){return arguments.length?(o=n,a()):o},i.interpolate=function(n){return arguments.length?(r=n,a()):r},i.ticks=function(n){return po(t,n)},i.tickFormat=function(n,e){return ho(t,n,e)},i.nice=function(n){return co(t,n),a()},i.copy=function(){return n(t,e,r,o)},a()}([0,1],[0,1],Qe,!1)};var mu={s:1,g:1,p:1,r:1,e:1};ra.scale.log=function(){return function n(t,e,r,o){function a(n){return(r?Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(e)}function i(n){return r?Math.pow(e,n):-Math.pow(e,-n)}function u(n){return t(a(n))}return u.invert=function(n){return i(t.invert(n))},u.domain=function(n){return arguments.length?(r=n[0]>=0,t.domain((o=n.map(Number)).map(a)),u):o},u.base=function(n){return arguments.length?(e=+n,t.domain(o.map(a)),u):e},u.nice=function(){var n=io(o.map(a),r?Math:gu);return t.domain(n),o=n.map(i),u},u.ticks=function(){var n=ro(o),t=[],u=n[0],s=n[1],l=Math.floor(a(u)),c=Math.ceil(a(s)),f=e%1?2:e;if(isFinite(c-l)){if(r){for(;c>l;l++)for(var p=1;f>p;p++)t.push(i(l)*p);t.push(i(l))}else for(t.push(i(l));l++0;p--)t.push(i(l)*p);for(l=0;t[l]s;c--);t=t.slice(l,c)}return t},u.tickFormat=function(n,t){if(!arguments.length)return vu;arguments.length<2?t=vu:"function"!=typeof t&&(t=ra.format(t));var r=Math.max(1,e*n/u.ticks().length);return function(n){var o=n/i(Math.round(a(n)));return e-.5>o*e&&(o*=e),r>=o?t(n):""}},u.copy=function(){return n(t.copy(),e,r,o)},lo(u,t)}(ra.scale.linear().domain([0,1]),10,!0,[1,10])};var vu=ra.format(".0e"),gu={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};ra.scale.pow=function(){return function n(t,e,r){function o(n){return t(a(n))}var a=vo(e),i=vo(1/e);return o.invert=function(n){return i(t.invert(n))},o.domain=function(n){return arguments.length?(t.domain((r=n.map(Number)).map(a)),o):r},o.ticks=function(n){return po(r,n)},o.tickFormat=function(n,t){return ho(r,n,t)},o.nice=function(n){return o.domain(co(r,n))},o.exponent=function(n){return arguments.length?(a=vo(e=n),i=vo(1/e),t.domain(r.map(a)),o):e},o.copy=function(){return n(t.copy(),e,r)},lo(o,t)}(ra.scale.linear(),1,[0,1])},ra.scale.sqrt=function(){return ra.scale.pow().exponent(.5)},ra.scale.ordinal=function(){return function n(t,e){function r(n){return i[((a.get(n)||("range"===e.t?a.set(n,t.push(n)):NaN))-1)%i.length]}function o(n,e){return ra.range(t.length).map(function(t){return n+e*t})}var a,i,u;return r.domain=function(n){if(!arguments.length)return t;t=[],a=new h;for(var o,i=-1,u=n.length;++i(n=e.indexOf(n))?[NaN,NaN]:[n>0?a[n-1]:t[0],n(n=r.indexOf(n))?NaN:n/i+t,n+1/i]},o.copy=function(){return n(t,e,r)},a()}(0,1,[0,1])},ra.scale.threshold=function(){return function n(t,e){function r(n){return n>=n?e[ra.bisect(t,n)]:void 0}return r.domain=function(n){return arguments.length?(t=n,r):t},r.range=function(n){return arguments.length?(e=n,r):e},r.invertExtent=function(n){return n=e.indexOf(n),[t[n-1],t[n]]},r.copy=function(){return n(t,e)},r}([.5],[0,1])},ra.scale.identity=function(){return function n(t){function e(n){return+n}return e.invert=e,e.domain=e.range=function(n){return arguments.length?(t=n.map(e),e):t},e.ticks=function(n){return po(t,n)},e.tickFormat=function(n,e){return ho(t,n,e)},e.copy=function(){return n(t)},e}([0,1])},ra.svg={},ra.svg.arc=function(){function n(){var n=Math.max(0,+e.apply(this,arguments)),l=Math.max(0,+r.apply(this,arguments)),c=i.apply(this,arguments)-La,f=u.apply(this,arguments)-La,p=Math.abs(f-c),h=c>f?0:1;if(n>l&&(d=l,l=n,n=d),p>=Ca)return t(l,h)+(n?t(n,1-h):"")+"Z";var d,m,v,g,y,b,x,M,w,k,_,S,A=0,T=0,E=[];if((g=(+s.apply(this,arguments)||0)/2)&&(v=a===wu?Math.sqrt(n*n+l*l):+a.apply(this,arguments),h||(T*=-1),l&&(T=rn(v/l*Math.sin(g))),n&&(A=rn(v/n*Math.sin(g)))),l){y=l*Math.cos(c+T),b=l*Math.sin(c+T),x=l*Math.cos(f-T),M=l*Math.sin(f-T);var R=Math.abs(f-c-2*T)<=Na?0:1;if(T&&ko(y,b,x,M)===h^R){var P=(c+f)/2;y=l*Math.cos(P),b=l*Math.sin(P),x=M=null}}else y=b=0;if(n){w=n*Math.cos(f-A),k=n*Math.sin(f-A),_=n*Math.cos(c+A),S=n*Math.sin(c+A);var N=Math.abs(c-f+2*A)<=Na?0:1;if(A&&ko(w,k,_,S)===1-h^N){var O=(c+f)/2;w=n*Math.cos(O),k=n*Math.sin(O),_=S=null}}else w=k=0;if(p>Ra&&(d=Math.min(Math.abs(l-n)/2,+o.apply(this,arguments)))>.001){m=l>n^h?0:1;var C=d,L=d;if(Na>p){var U=null==_?[w,k]:null==x?[y,b]:be([y,b],[_,S],[x,M],[w,k]),D=y-U[0],z=b-U[1],F=x-U[0],q=M-U[1],j=1/Math.sin(Math.acos((D*F+z*q)/(Math.sqrt(D*D+z*z)*Math.sqrt(F*F+q*q)))/2),B=Math.sqrt(U[0]*U[0]+U[1]*U[1]);L=Math.min(d,(n-B)/(j-1)),C=Math.min(d,(l-B)/(j+1))}if(null!=x){var I=_o(null==_?[w,k]:[_,S],[y,b],l,C,h),H=_o([x,M],[w,k],l,C,h);d===C?E.push("M",I[0],"A",C,",",C," 0 0,",m," ",I[1],"A",l,",",l," 0 ",1-h^ko(I[1][0],I[1][1],H[1][0],H[1][1]),",",h," ",H[1],"A",C,",",C," 0 0,",m," ",H[0]):E.push("M",I[0],"A",C,",",C," 0 1,",m," ",H[0])}else E.push("M",y,",",b);if(null!=_){var V=_o([y,b],[_,S],n,-L,h),X=_o([w,k],null==x?[y,b]:[x,M],n,-L,h);d===L?E.push("L",X[0],"A",L,",",L," 0 0,",m," ",X[1],"A",n,",",n," 0 ",h^ko(X[1][0],X[1][1],V[1][0],V[1][1]),",",1-h," ",V[1],"A",L,",",L," 0 0,",m," ",V[0]):E.push("L",X[0],"A",L,",",L," 0 0,",m," ",V[0])}else E.push("L",w,",",k)}else E.push("M",y,",",b),null!=x&&E.push("A",l,",",l," 0 ",R,",",h," ",x,",",M),E.push("L",w,",",k),null!=_&&E.push("A",n,",",n," 0 ",N,",",1-h," ",_,",",S);return E.push("Z"),E.join("")}function t(n,t){return"M0,"+n+"A"+n+","+n+" 0 1,"+t+" 0,"+-n+"A"+n+","+n+" 0 1,"+t+" 0,"+n}var e=yo,r=bo,o=go,a=wu,i=xo,u=Mo,s=wo;return n.innerRadius=function(t){return arguments.length?(e=Tn(t),n):e},n.outerRadius=function(t){return arguments.length?(r=Tn(t),n):r},n.cornerRadius=function(t){return arguments.length?(o=Tn(t),n):o},n.padRadius=function(t){return arguments.length?(a=t==wu?wu:Tn(t),n):a},n.startAngle=function(t){return arguments.length?(i=Tn(t),n):i},n.endAngle=function(t){return arguments.length?(u=Tn(t),n):u},n.padAngle=function(t){return arguments.length?(s=Tn(t),n):s},n.centroid=function(){var n=(+e.apply(this,arguments)+ +r.apply(this,arguments))/2,t=(+i.apply(this,arguments)+ +u.apply(this,arguments))/2-La;return[Math.cos(t)*n,Math.sin(t)*n]},n};var wu="auto";ra.svg.line=function(){return So(w)};var ku=ra.map({linear:Ao,"linear-closed":To,step:function(n){for(var t=0,e=n.length,r=n[0],o=[r[0],",",r[1]];++t1&&o.push("H",r[0]),o.join("")},"step-before":Eo,"step-after":Ro,basis:Oo,"basis-open":function(n){if(n.length<4)return Ao(n);for(var t,e=[],r=-1,o=n.length,a=[0],i=[0];++r<3;)t=n[r],a.push(t[0]),i.push(t[1]);for(e.push(Co(Au,a)+","+Co(Au,i)),--r;++rNa)+",1 "+t}function r(n,t,e,r){return"Q 0,0 "+r}var o=ie,a=ue,i=qo,u=xo,s=Mo;return n.radius=function(t){return arguments.length?(i=Tn(t),n):i},n.source=function(t){return arguments.length?(o=Tn(t),n):o},n.target=function(t){return arguments.length?(a=Tn(t),n):a},n.startAngle=function(t){return arguments.length?(u=Tn(t),n):u},n.endAngle=function(t){return arguments.length?(s=Tn(t),n):s},n},ra.svg.diagonal=function(){function n(n,o){var a=t.call(this,n,o),i=e.call(this,n,o),u=(a.y+i.y)/2,s=[a,{x:a.x,y:u},{x:i.x,y:u},i];return"M"+(s=s.map(r))[0]+"C"+s[1]+" "+s[2]+" "+s[3]}var t=ie,e=ue,r=jo;return n.source=function(e){return arguments.length?(t=Tn(e),n):t},n.target=function(t){return arguments.length?(e=Tn(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},ra.svg.diagonal.radial=function(){var n=ra.svg.diagonal(),t=jo,e=n.projection;return n.projection=function(n){return arguments.length?e(function(n){return function(){var t=n.apply(this,arguments),e=t[0],r=t[1]-La;return[e*Math.cos(r),e*Math.sin(r)]}}(t=n)):t},n},ra.svg.symbol=function(){function n(n,r){return(Tu.get(t.call(this,n,r))||Ho)(e.call(this,n,r))}var t=Io,e=Bo;return n.type=function(e){return arguments.length?(t=Tn(e),n):t},n.size=function(t){return arguments.length?(e=Tn(t),n):e},n};var Tu=ra.map({circle:Ho,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*Ru)),e=t*Ru;return"M0,"+-t+"L"+e+",0 0,"+t+" "+-e+",0Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/Eu),e=t*Eu/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/Eu),e=t*Eu/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});ra.svg.symbolTypes=Tu.keys();var Eu=Math.sqrt(3),Ru=Math.tan(30*Ua);wa.transition=function(n){for(var t,e,r=Pu||++Lu,o=Wo(n),a=[],i=Nu||{time:Date.now(),ease:ar,delay:0,duration:250},u=-1,s=this.length;++uo;o++){r.push(t=[]);for(var i=this[o],u=0,s=i.length;s>u;u++)(e=i[u])&&n.call(e,e.__data__,u,o)&&t.push(e)}return Xo(r,this.namespace,this.id)},Cu.tween=function(n,t){var e=this.id,r=this.namespace;return arguments.length<2?this.node()[r][e].tween.get(n):G(this,null==t?function(t){t[r][e].tween.remove(n)}:function(o){o[r][e].tween.set(n,t)})},Cu.attr=function(n,t){function e(){this.removeAttribute(a)}function r(){this.removeAttributeNS(a.space,a.local)}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var o="transform"==n?mr:Qe,a=ra.ns.qualify(n);return Go(this,"attr."+n,t,a.local?function(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(a.space,a.local);return e!==n&&(t=o(e,n),function(n){this.setAttributeNS(a.space,a.local,t(n))})})}:function(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(a);return e!==n&&(t=o(e,n),function(n){this.setAttribute(a,t(n))})})})},Cu.attrTween=function(n,t){var e=ra.ns.qualify(n);return this.tween("attr."+n,e.local?function(n,r){var o=t.call(this,n,r,this.getAttributeNS(e.space,e.local));return o&&function(n){this.setAttributeNS(e.space,e.local,o(n))}}:function(n,r){var o=t.call(this,n,r,this.getAttribute(e));return o&&function(n){this.setAttribute(e,o(n))}})},Cu.style=function(n,t,e){function r(){this.style.removeProperty(n)}var o=arguments.length;if(3>o){if("string"!=typeof n){for(e in 2>o&&(t=""),n)this.style(e,n[e],t);return this}e=""}return Go(this,"style."+n,t,function(t){return null==t?r:(t+="",function(){var r,o=i(this).getComputedStyle(this,null).getPropertyValue(n);return o!==t&&(r=Qe(o,t),function(t){this.style.setProperty(n,r(t),e)})})})},Cu.styleTween=function(n,t,e){return arguments.length<3&&(e=""),this.tween("style."+n,function(r,o){var a=t.call(this,r,o,i(this).getComputedStyle(this,null).getPropertyValue(n));return a&&function(t){this.style.setProperty(n,a(t),e)}})},Cu.text=function(n){return Go(this,"text",n,Yo)},Cu.remove=function(){var n=this.namespace;return this.each("end.transition",function(){var t;this[n].count<2&&(t=this.parentNode)&&t.removeChild(this)})},Cu.ease=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].ease:("function"!=typeof n&&(n=ra.ease.apply(ra,arguments)),G(this,function(r){r[e][t].ease=n}))},Cu.delay=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].delay:G(this,"function"==typeof n?function(r,o,a){r[e][t].delay=+n.call(r,r.__data__,o,a)}:(n=+n,function(r){r[e][t].delay=n}))},Cu.duration=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].duration:G(this,"function"==typeof n?function(r,o,a){r[e][t].duration=Math.max(1,n.call(r,r.__data__,o,a))}:(n=Math.max(1,n),function(r){r[e][t].duration=n}))},Cu.each=function(n,t){var e=this.id,r=this.namespace;if(arguments.length<2){var o=Nu,a=Pu;try{Pu=e,G(this,function(t,o,a){Nu=t[r][e],n.call(t,t.__data__,o,a)})}finally{Nu=o,Pu=a}}else G(this,function(o){var a=o[r][e];(a.event||(a.event=ra.dispatch("start","end","interrupt"))).on(n,t)});return this},Cu.transition=function(){for(var n,t,e,r=this.id,o=++Lu,a=this.namespace,i=[],u=0,s=this.length;s>u;u++){i.push(n=[]);for(var l=this[u],c=0,f=l.length;f>c;c++)(t=l[c])&&(e=t[a][r],Zo(t,c,a,o,{time:e.time,ease:e.ease,delay:e.delay+e.duration,duration:e.duration})),n.push(t)}return Xo(i,a,o)},ra.svg.axis=function(){function n(n){n.each(function(){var n,l=ra.select(this),c=this.__chart__||e,f=this.__chart__=e.copy(),p=null==s?f.ticks?f.ticks.apply(f,u):f.domain():s,h=null==t?f.tickFormat?f.tickFormat.apply(f,u):w:t,d=l.selectAll(".tick").data(p,f),m=d.enter().insert("g",".domain").attr("class","tick").style("opacity",Ra),v=ra.transition(d.exit()).style("opacity",Ra).remove(),g=ra.transition(d.order()).style("opacity",1),y=Math.max(o,0)+i,b=oo(f),x=l.selectAll(".domain").data([0]),M=(x.enter().append("path").attr("class","domain"),ra.transition(x));m.append("line"),m.append("text");var k,_,S,A,T=m.select("line"),E=g.select("line"),R=d.select("text").text(h),P=m.select("text"),N=g.select("text"),O="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(n=Jo,k="x",S="y",_="x2",A="y2",R.attr("dy",0>O?"0em":".71em").style("text-anchor","middle"),M.attr("d","M"+b[0]+","+O*a+"V0H"+b[1]+"V"+O*a)):(n=$o,k="y",S="x",_="y2",A="x2",R.attr("dy",".32em").style("text-anchor",0>O?"end":"start"),M.attr("d","M"+O*a+","+b[0]+"H0V"+b[1]+"H"+O*a)),T.attr(A,O*o),P.attr(S,O*y),E.attr(_,0).attr(A,O*o),N.attr(k,0).attr(S,O*y),f.rangeBand){var C=f,L=C.rangeBand()/2;c=f=function(n){return C(n)+L}}else c.rangeBand?c=f:v.call(n,f,c);m.call(n,c,f),g.call(n,f,f)})}var t,e=ra.scale.linear(),r=Uu,o=6,a=6,i=3,u=[10],s=null;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in Du?t+"":Uu,n):r},n.ticks=function(){return arguments.length?(u=aa(arguments),n):u},n.tickValues=function(t){return arguments.length?(s=t,n):s},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t){var e=arguments.length;return e?(o=+t,a=+arguments[e-1],n):o},n.innerTickSize=function(t){return arguments.length?(o=+t,n):o},n.outerTickSize=function(t){return arguments.length?(a=+t,n):a},n.tickPadding=function(t){return arguments.length?(i=+t,n):i},n.tickSubdivide=function(){return arguments.length&&n},n};var Uu="bottom",Du={top:1,right:1,bottom:1,left:1};ra.svg.brush=function(){function n(a){a.each(function(){var a=ra.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",o).on("touchstart.brush",o),i=a.selectAll(".background").data([0]);i.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),a.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var u=a.selectAll(".resize").data(m,w);u.exit().remove(),u.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return zu[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),u.style("display",n.empty()?"none":null);var s,f=ra.transition(a),p=ra.transition(i);l&&(s=oo(l),p.attr("x",s[0]).attr("width",s[1]-s[0]),e(f)),c&&(s=oo(c),p.attr("y",s[0]).attr("height",s[1]-s[0]),r(f)),t(f)})}function t(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+f[+/e$/.test(n)]+","+p[+/^s/.test(n)]+")"})}function e(n){n.select(".extent").attr("x",f[0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1]-f[0])}function r(n){n.select(".extent").attr("y",p[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",p[1]-p[0])}function o(){function o(){var n=ra.mouse(b),o=!1;y&&(n[0]+=y[0],n[1]+=y[1]),A||(ra.event.altKey?(g||(g=[(f[0]+f[1])/2,(p[0]+p[1])/2]),R[0]=f[+(n[0]c?(o=r,r=c):o=c),m[0]!=r||m[1]!=o?(e?u=null:a=null,m[0]=r,m[1]=o,!0):void 0}function v(){o(),w.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),ra.select("body").style("cursor",null),P.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),T(),M({type:"brushend"})}var g,y,b=this,x=ra.select(ra.event.target),M=s.of(b,arguments),w=ra.select(b),k=x.datum(),_=!/^(n|s)$/.test(k)&&l,S=!/^(e|w)$/.test(k)&&c,A=x.classed("extent"),T=$(b),R=ra.mouse(b),P=ra.select(i(b)).on("keydown.brush",function(){32==ra.event.keyCode&&(A||(g=null,R[0]-=f[1],R[1]-=p[1],A=2),E())}).on("keyup.brush",function(){32==ra.event.keyCode&&2==A&&(R[0]+=f[1],R[1]+=p[1],A=0,E())});if(ra.event.changedTouches?P.on("touchmove.brush",o).on("touchend.brush",v):P.on("mousemove.brush",o).on("mouseup.brush",v),w.interrupt().selectAll("*").interrupt(),A)R[0]=f[0]-R[0],R[1]=p[0]-R[1];else if(k){var N=+/w$/.test(k),O=+/^n/.test(k);y=[f[1-N]-R[0],p[1-O]-R[1]],R[0]=f[N],R[1]=p[O]}else ra.event.altKey&&(g=R.slice());w.style("pointer-events","none").selectAll(".resize").style("display",null),ra.select("body").style("cursor",x.style("cursor")),M({type:"brushstart"}),o()}var a,u,s=P(n,"brushstart","brush","brushend"),l=null,c=null,f=[0,0],p=[0,0],h=!0,d=!0,m=Fu[0];return n.event=function(n){n.each(function(){var n=s.of(this,arguments),t={x:f,y:p,i:a,j:u},e=this.__chart__||t;this.__chart__=t,Pu?ra.select(this).transition().each("start.brush",function(){a=e.i,u=e.j,f=e.x,p=e.y,n({type:"brushstart"})}).tween("brush:brush",function(){var e=nr(f,t.x),r=nr(p,t.y);return a=u=null,function(o){f=t.x=e(o),p=t.y=r(o),n({type:"brush",mode:"resize"})}}).each("end.brush",function(){a=t.i,u=t.j,n({type:"brush",mode:"resize"}),n({type:"brushend"})}):(n({type:"brushstart"}),n({type:"brush",mode:"resize"}),n({type:"brushend"}))})},n.x=function(t){return arguments.length?(m=Fu[!(l=t)<<1|!c],n):l},n.y=function(t){return arguments.length?(m=Fu[!l<<1|!(c=t)],n):c},n.clamp=function(t){return arguments.length?(l&&c?(h=!!t[0],d=!!t[1]):l?h=!!t:c&&(d=!!t),n):l&&c?[h,d]:l?h:c?d:null},n.extent=function(t){var e,r,o,i,s;return arguments.length?(l&&(e=t[0],r=t[1],c&&(e=e[0],r=r[0]),a=[e,r],l.invert&&(e=l(e),r=l(r)),e>r&&(s=e,e=r,r=s),(e!=f[0]||r!=f[1])&&(f=[e,r])),c&&(o=t[0],i=t[1],l&&(o=o[1],i=i[1]),u=[o,i],c.invert&&(o=c(o),i=c(i)),o>i&&(s=o,o=i,i=s),(o!=p[0]||i!=p[1])&&(p=[o,i])),n):(l&&(a?(e=a[0],r=a[1]):(e=f[0],r=f[1],l.invert&&(e=l.invert(e),r=l.invert(r)),e>r&&(s=e,e=r,r=s))),c&&(u?(o=u[0],i=u[1]):(o=p[0],i=p[1],c.invert&&(o=c.invert(o),i=c.invert(i)),o>i&&(s=o,o=i,i=s))),l&&c?[[e,o],[r,i]]:l?[e,r]:c&&[o,i])},n.clear=function(){return n.empty()||(f=[0,0],p=[0,0],a=u=null),n},n.empty=function(){return!!l&&f[0]==f[1]||!!c&&p[0]==p[1]},ra.rebind(n,s,"on")};var zu={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Fu=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],qu=oi.format=ci.timeFormat,ju=qu.utc,Bu=ju("%Y-%m-%dT%H:%M:%S.%LZ");qu.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Ko:Bu,Ko.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},Ko.toString=Bu.toString,oi.second=zn(function(n){return new ai(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),oi.seconds=oi.second.range,oi.seconds.utc=oi.second.utc.range,oi.minute=zn(function(n){return new ai(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),oi.minutes=oi.minute.range,oi.minutes.utc=oi.minute.utc.range,oi.hour=zn(function(n){var t=n.getTimezoneOffset()/60;return new ai(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),oi.hours=oi.hour.range,oi.hours.utc=oi.hour.utc.range,oi.month=zn(function(n){return(n=oi.day(n)).setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),oi.months=oi.month.range,oi.months.utc=oi.month.utc.range;var Iu=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Hu=[[oi.second,1],[oi.second,5],[oi.second,15],[oi.second,30],[oi.minute,1],[oi.minute,5],[oi.minute,15],[oi.minute,30],[oi.hour,1],[oi.hour,3],[oi.hour,6],[oi.hour,12],[oi.day,1],[oi.day,2],[oi.week,1],[oi.month,1],[oi.month,3],[oi.year,1]],Vu=qu.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",_t]]),Xu={range:function(n,t,e){return ra.range(Math.ceil(n/e)*e,+t,e).map(na)},floor:w,ceil:w};Hu.year=oi.year,oi.scale=function(){return Qo(ra.scale.linear(),Hu,Vu)};var Gu=Hu.map(function(n){return[n[0].utc,n[1]]}),Yu=ju.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",_t]]);Gu.year=oi.year.utc,oi.scale.utc=function(){return Qo(ra.scale.linear(),Gu,Yu)},ra.text=En(function(n){return n.responseText}),ra.json=function(n,t){return Rn(n,"application/json",ta,t)},ra.html=function(n,t){return Rn(n,"text/html",ea,t)},ra.xml=En(function(n){return n.responseXML}),this.d3=ra,void 0===(o="function"==typeof(r=ra)?r.call(t,e,t,n):r)||(n.exports=o)}()},function(n,t,e){var r=e(3);"string"==typeof r&&(r=[[n.id,r,""]]),e(5)(r,{}),r.locals&&(n.exports=r.locals)},function(n,t,e){(n.exports=e(4)()).push([n.id,"svg {\n display: block;\n min-width: 100%;\n width: 100%;\n min-height: 100%;\n}\n\ncircle.node {\n stroke: #ccc;\n stroke-width: 1px;\n opacity: 1;\n fill: white;\n}\n\npolygon.node {\n stroke: #ccc;\n stroke-width: 1px;\n opacity: 1;\n fill: white;\n}\n\ncircle.node.label {\n stroke: transparent;\n stroke-width: 0;\n fill: white;\n display: inline;\n}\n\ncircle.outline_node {\n stroke-width: 1px;\n fill: red;\n}\n\ncircle.protein {\n fill: gray;\n fill-opacity: 0.5;\n stroke-width: 4;\n}\n\ncircle.hidden_outline {\n stroke-width: 0px;\n}\n\n\nline.link {\n stroke: #999;\n stroke-opacity: 0.8;\n stroke-width: 2;\n}\n\nline.pseudoknot {\n stroke: red;\n}\n\nline.basepair {\n stroke: red;\n}\n\nline.intermolecule {\n stroke: blue;\n}\n\nline.chain_chain {\n stroke-dasharray: 3,3;\n}\n\nline.fake {\n stroke: green;\n}\n\n.transparent {\n fill: transparent;\n stroke-width: 0;\n stroke-opacity: 0;\n opacity: 0;\n visibility: hidden;\n}\n\n.drag_line {\n stroke: #999;\n stroke-width: 2;\n pointer-events: none;\n}\n\n.drag_line_hidden {\n stroke: #999;\n stroke-width: 0;\n pointer-events: none;\n}\n\n.d3-tip {\n line-height: 1;\n font-weight: bold;\n padding: 6px;\n background: rgba(0, 0, 0, 0.6);\n color: #fff;\n border-radius: 4px;\n pointer-events: none;\n }\n\ntext.node-label {\n font-weight: bold;\n font-family: Tahoma, Geneva, sans-serif;\n color: rgb(100,100,100);\n pointer-events: none;\n}\n\ntext {\n pointer-events: none;\n}\n\ng.gnode {\n\n}\n\ncircle.outline_node.selected {\n visibility: visible;\n}\n\ncircle.outline_node {\n visibility: hidden;\n}\n\n.brush .extent {\n fill-opacity: .1;\n stroke: #fff;\n shape-rendering: crispEdges;\n}\n\n.noselect {\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -khtml-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n",""])},function(n,t){n.exports=function(){var n=[];return n.toString=function(){for(var n=[],t=0;t=0&&g.splice(t,1)}function u(n){var t=document.createElement("style");return t.type="text/css",a(n,t),t}function s(n){var t=document.createElement("link");return t.rel="stylesheet",a(n,t),t}function l(n,t){var e,r,o;if(t.singleton){var a=v++;e=m||(m=u(t)),r=c.bind(null,e,a,!1),o=c.bind(null,e,a,!0)}else n.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(e=s(t),r=function(n,t){var e=t.css,r=(t.media,t.sourceMap);r&&(e+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var o=new Blob([e],{type:"text/css"}),a=n.href;n.href=URL.createObjectURL(o),a&&URL.revokeObjectURL(a)}.bind(null,e),o=function(){i(e),e.href&&URL.revokeObjectURL(e.href)}):(e=u(t),r=function(n,t){var e=t.css,r=t.media;if(t.sourceMap,r&&n.setAttribute("media",r),n.styleSheet)n.styleSheet.cssText=e;else{for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(document.createTextNode(e))}}.bind(null,e),o=function(){i(e)});return r(n),function(t){if(t){if(t.css===n.css&&t.media===n.media&&t.sourceMap===n.sourceMap)return;r(n=t)}else o()}}function c(n,t,e,r){var o=e?"":r.css;if(n.styleSheet)n.styleSheet.cssText=y(t,o);else{var a=document.createTextNode(o),i=n.childNodes;i[t]&&n.removeChild(i[t]),i.length?n.insertBefore(a,i[t]):n.appendChild(a)}}var f={},p=function(n){var t;return function(){return void 0===t&&(t=n.apply(this,arguments)),t}},h=p(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),d=p(function(){return document.head||document.getElementsByTagName("head")[0]}),m=null,v=0,g=[];n.exports=function(n,t){void 0===(t=t||{}).singleton&&(t.singleton=h()),void 0===t.insertAt&&(t.insertAt="bottom");var e=o(n);return r(e,t),function(n){for(var a=[],i=0;i0&&"*"==a.dotbracket[a.dotbracket.length-1]&&(a.dotbracket=a.dotbracket.slice(0,a.dotbracket.length-1),a.circular=!0),a.uid=r(),a.elements=[],a.pseudoknotPairs=[],a.nucsToNodes={},a.addUids=function(n){for(var t=a.nodes.filter(function(n){return"nucleotide"==n.nodeType}),e=0;e=0;)t.push(e),n=n.substring(0,e)+"oo"+n.substring(e+1,n.length);return{targetString:n,breaks:t}};var s=a.removeBreaks(a.dotbracket);a.dotbracket=s.targetString,a.dotBracketBreaks=s.breaks,s=a.removeBreaks(a.seq),a.seq=s.targetString,a.seqBreaks=s.breaks,a.calculateStartNumberArray=function(){a.startNumberArray=[];for(var n=0;n=0&&(e=!0);e?a.elements[t][2].map(function(n){0!=n&&(a.nodes[n-1].elemType="e")}):a.elements[t][2].map(function(n){0!=n&&(a.nodes[n-1].elemType=a.elements[t][0])})}return a},a.getPositions=function(n){for(var t=[],e=a.nodes.filter(function(t){return t.nodeType==n}),r=0;r=4}),e=0;ea.dotbracket.length)){a.links.push({source:a.nodes[n[f]-1],target:a.nodes[a.nodes.length-1],linkType:"fake",value:e,uid:r()}),n.length>4&&a.links.push({source:a.nodes[n[f]-1],target:a.nodes[n[(f+Math.floor(n.length/2))%n.length]-1],linkType:"fake",value:2*e,uid:r()});var p=3.14159*(n.length-2)/n.length,h=2*Math.cos(1.570795-p/2);a.links.push({source:a.nodes[n[f]-1],target:a.nodes[n[(f+2)%n.length]-1],linkType:"fake",value:h});var d=a.nodes[n[f]-1];"x"in d&&(s+=d.x,l+=d.y,c+=1)}return c>0&&(u.x=s/c,u.y=l/c,u.px=u.x,u.py=u.y),a},a.connectFakeNodes=function(){for(var n={},t=a.nodes.filter(function(n){return"middle"==n.nodeType}),e=new Set,r=1;r<=a.nodes.length;r++)n[r]=[];for(var r=0;r=0||a.dotBracketBreaks.indexOf(e-2)>=0)&&(u=""),a.nodes.push({name:u,num:e+a.startNumberArray[e-1]-1,radius:5,rna:a,nodeType:"nucleotide",structName:a.structName,elemType:t[e],uid:r(),linked:!1})}for(var e=0;e1&&-1===a.dotBracketBreaks.indexOf(e-1)&&-1==a.dotBracketBreaks.indexOf(e-2)&&-1==a.dotBracketBreaks.indexOf(e-3)&&(a.links.push({source:a.nodes[e-2],target:a.nodes[e-1],linkType:"backbone",value:1,uid:r()}),a.nodes[e-1].linked=!0);for(var e=0;er)return[];for(;0===n[e];e++)i.push(e);for(;0===n[r];r--)s.push(r);if(e>r){if(i.push(e),0===t)return[["e",t,i.sort(u)]];for(var l=!1,c=[],f=[],p=0;p=0&&(l=!0);return[["h",t,i.sort(u)]]}if(n[e]!=r){var h=i,p=e;for(h.push(p);r>=p;){for(o=o.concat(a.ptToElements(n,t,p,n[p])),h.push(n[p]),p=n[p]+1;0===n[p]&&r>=p;p++)h.push(p);h.push(p)}return h.pop(),(h=h.concat(s)).length>0&&(0===t?o.push(["e",t,h.sort(u)]):o.push(["m",t,h.sort(u)])),o}if(n[e]===r){i.push(e),s.push(r);var d=i.concat(s);d.length>4&&(0===t?o.push(["e",t,i.concat(s).sort(u)]):o.push(["i",t,i.concat(s).sort(u)]))}for(var m=[];n[e]===r&&r>e;)m.push(e),m.push(r),e+=1,r-=1,t+=1;return i=[e-1],s=[r+1],o.push(["s",t,m.sort(u)]),o.concat(a.ptToElements(n,t,e,r))},a.addLabels=function(n,t){if(0===arguments.length&&(n=1,t=10),1===arguments.length&&(t=10),0===t)return a;0>=t&&console.log("The label interval entered in invalid:",t);for(var e=1;e<=a.pairtable[0];e++)if(e%t==0){var o,i,u,s,l=a.nodes[e-1];1==a.rnaLength?(s=[l.x-15,l.y],u=[l.x-15,l.y]):(o=1==e?a.nodes[a.rnaLength-1]:a.nodes[e-2],i=e==a.rnaLength?a.nodes[0]:a.nodes[e],0!==a.pairtable[i.num]&&0!==a.pairtable[o.num]&&0!==a.pairtable[l.num]&&(o=i=a.nodes[a.pairtable[l.num]-1]),0===a.pairtable[l.num]||0!==a.pairtable[i.num]&&0!==a.pairtable[o.num]?(s=[i.x-l.x,i.y-l.y],u=[o.x-l.x,o.y-l.y]):(s=[l.x-i.x,l.y-i.y],u=[l.x-o.x,l.y-o.y]));var c=[s[0]+u[0],s[1]+u[1]],f=Math.sqrt(c[0]*c[0]+c[1]*c[1]),p=[c[0]/f,c[1]/f],h=[-15*p[0],-15*p[1]],d=a.nodes[e-1].x+h[0],m=a.nodes[e-1].y+h[1],v={name:e+a.startNumberArray[e-1]-1,num:-1,radius:6,rna:a,nodeType:"label",structName:a.structName,elemType:"l",x:d,y:m,px:d,py:m,uid:r()},g={source:a.nodes[e-1],target:v,value:1,linkType:"label_link",uid:r()};a.nodes.push(v),a.links.push(g)}return a},a.recalculateElements=function(){if(a.removePseudoknots(),a.elements=a.ptToElements(a.pairtable,0,1,a.dotbracket.length),a.circular&&(externalLoop=a.elements.filter(function(n){return"e"==n[0]||void 0}),externalLoop.length>0)){eloop=externalLoop[0],nucs=eloop[2].sort(u),prev=nucs[0],hloop=!0,numGreater=0;for(var n=1;n1&&(numGreater+=1),prev=nucs[n];1==numGreater?eloop[0]="h":2==numGreater?eloop[0]="i":eloop[0]="m"}return a},a.reassignLinkUids=function(){for(var n=0;n1&&(a.pseudoknotPairs=a.pseudoknotPairs.concat(i.rnaUtilities.removePseudoknotsFromPairtable(a.pairtable))),a},a.addPseudoknots=function(){for(var n=a.pairtable,t=a.pseudoknotPairs,e=0;e0&&a.recalculateElements()}Object.defineProperty(t,"__esModule",{value:!0}),t.ProteinGraph=o,t.RNAGraph=a,t.moleculesToJson=function(n){for(var t={},e=[],i=[],u=0;uabcdefghijklmnopqrstuvwxyz".split(""),n.inverseBrackets=function(n){for(var t={},e=0;e=r;r++){e[r]=new Array(t+1);for(var o=r;t>=o;o++)e[r][o]=0}for(var a=0,r=t-0-1;r>0;r--)for(var o=r+0+1;t>=o;o++){a=e[r][o-1];for(var i=o-0-1;i>=r;i--)n[i]===o&&(a=Math.max(a,(i>r?e[r][i-1]:0)+1+(o-i-1>0?e[i+1][o-1]:0)));e[r][o]=a}return a=e[1][t],e},n.backtrackMaximumMatching=function(t,e){var r=Array.apply(null,Array(t.length)).map(function(){return 0});return n.mmBt(t,r,e,1,t.length-1),r},n.mmBt=function(t,e,r,o,a){var i=t[o][a];if(!(0>a-o-1)){if(t[o][a-1]==i)return void n.mmBt(t,e,r,o,a-1);for(var u=a-0-1;u>=o;u--)if(r[a]===u){var s=u>o?t[o][u-1]:0,l=a-u-1>0?t[u+1][a-1]:0;if(s+l+1==i)return e[u]=a,e[a]=u,u>o&&n.mmBt(t,e,r,o,u-1),void n.mmBt(t,e,r,u+1,a-1)}console.log("FAILED!!!"+o+","+a+": backtracking failed!")}},n.dotbracketToPairtable=function(t){var e=Array.apply(null,new Array(t.length+1)).map(Number.prototype.valueOf,0);e[0]=t.length;for(var r={},o=0;o0)throw"Unmatched base at position "+r[c][0];return e},n.insertIntoStack=function(n,t,e){for(var r=0;n[r].length>0&&n[r][n[r].length-1]r?n.bracketLeft[n.insertIntoStack(e,r,t[r])]:n.bracketRight[n.deleteFromStack(e,r)]}return a},n.findUnmatched=function(t,e,r){for(var o=[],a=[],i=e,u=r,s=e;r>=s;s++)0!==t[s]&&(t[s]r)&&a.push([s,t[s]]);for(var s=i;u>=s;s++){for(;0===t[s]&&u>=s;)s++;for(r=t[s];t[s]===r;)s++,r--;o=o.concat(n.findUnmatched(t,s,r))}return a.length>0&&o.push(a),o},n.removePseudoknotsFromPairtable=function(t){for(var e=n.maximumMatching(t),r=n.backtrackMaximumMatching(e,t),o=[],a=1;aa)return[];for(;0===t[o];o++)s.push(o);for(;0===t[a];a--)l.push(a);if(o>a){if(s.push(o),0===e)return[["e",e,s.sort(r)]];for(var c=!1,f=[],p=[],h=0;h=0&&(c=!0);return[["h",e,s.sort(r)]]}if(t[o]!=a){var d=s,h=o;for(d.push(h);a>=h;){for(u=u.concat(n.ptToElements(t,e,h,t[h],i)),d.push(t[h]),h=t[h]+1;0===t[h]&&a>=h;h++)d.push(h);d.push(h)}return d.pop(),(d=d.concat(l)).length>0&&(0===e?u.push(["e",e,d.sort(r)]):u.push(["m",e,d.sort(r)])),u}if(t[o]===a){s.push(o),l.push(a);var m=s.concat(l);m.length>4&&(0===e?u.push(["e",e,s.concat(l).sort(r)]):u.push(["i",e,s.concat(l).sort(r)]))}for(var v=[];t[o]===a&&a>o;)v.push(o),v.push(a),o+=1,a-=1,e+=1;return s=[o-1],l=[a+1],u.push(["s",e,v.sort(r)]),u.concat(n.ptToElements(t,e,o,a,i))}}Object.defineProperty(t,"__esModule",{value:!0}),t.arraysEqual=function(n,t){if(n===t)return!0;if(null===n||null===t)return!1;if(n.length!=t.length)return!1;for(var e=0;e=u;u++)e.push(u);else console.log("Malformed range (too many dashes):",n)}return e},t.parseColorText=function(n){for(var e=n.split("\n"),r="",o=1,a={colorValues:{"":{}},range:["white","steelblue"]},i=[],u=0;u"!=e[u][0])for(var s=e[u].trim().split(/[\s]+/),l=0;ln&&(r=n),n>o&&(o=n));for(a in t.colorsJson.colorValues[e])"number"==typeof(n=t.colorsJson.colorValues[e][a])&&(t.colorsJson.colorValues[e][a]=(n-r)/(o-r))}return t},t.parseColorText(t.colorsText),t};var r=function(n,t){return n-t};t.rnaUtilities=new e}])},function(n,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.simpleXyCoordinates=function(n){var t,e,r,o=[],a=[];e=n[0];var i=Array.apply(null,new Array(e+5)).map(Number.prototype.valueOf,0),u=Array.apply(null,new Array(16+Math.floor(e/5))).map(Number.prototype.valueOf,0),s=Array.apply(null,new Array(16+Math.floor(e/5))).map(Number.prototype.valueOf,0),l=0,c=0,f=Math.PI/2;(function n(t,e,r){var o,a,p,h,d,m,v,g,y,b,x,M,w=2,k=0,_=0,S=Array.apply(null,new Array(3+2*Math.floor((e-t)/5))).map(Number.prototype.valueOf,0);for(o=t-1,e++;t!=e;)if((a=r[t])&&0!=t){w+=2,p=t,h=a,S[++k]=p,S[++k]=h,t=a+1,d=p,m=h,g=0;do{p++,h--,g++}while(r[p]==h&&r[p]>p);if(v=g-2,g>=2&&(i[d+1+v]+=f,i[m-1-v]+=f,i[d]+=f,i[m]+=f,g>2))for(;v>=1;v--)i[d+v]=Math.PI,i[m-v]=Math.PI;s[++c]=g,h>=p&&n(p,h,r)}else t++,w++,_++;for(M=Math.PI*(w-2)/w,S[++k]=e,y=0>o?0:o,b=1;k>=b;b++){for(x=S[b]-y,v=0;x>=v;v++)i[y+v]+=M;if(b>k)break;y=S[++b]}u[++l]=_})(0,e+1,n),u[l]-=2,r=0,o[0]=100,a[0]=100;var p=[];for(p.push([o[0],a[0]]),t=1;e>t;t++)o[t]=o[t-1]+15*Math.cos(r),a[t]=a[t-1]+15*Math.sin(r),p.push([o[t],a[t]]),r+=Math.PI-i[t+1];return p}}])},function(n,t,e){"use strict";var r=e(24);function o(){}n.exports=function(){function n(n,t,e,o,a,i){if(i!==r){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function t(){return n}n.isRequired=n;var e={array:n,bool:n,func:n,number:n,object:n,string:n,symbol:n,any:n,arrayOf:t,element:n,instanceOf:t,node:n,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return e.checkPropTypes=o,e.PropTypes=e,e}},function(n,t,e){"use strict";n.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(n,t,e){"use strict";var r=e(7),o=e(26),a=e(27),i=e(6),u=e(8),s=e(21),l=e(28);function c(n,t){return t=t.split("// __split__"),new o.Program(n,t[0],t[1])}n.exports=function(n,t,e){var f,p,h,d,m,v,g,y,b,x,M,w,k,_,S,A,T,E,R,P,N,O,C,L,U,D,z,F=this,q=null,j=null,B=null,I=null,H=null,V=null,X=0,G=!1,Y=!1;function W(n){h.viewport(0,0,e,e);var o=u.clone(n);o.zoom=1/f,o.translation.x=0,o.translation.y=0;for(var a=r.mat4.create(),i=0;i<3;i++){var s=r.vec3.random(r.vec3.create(),1);r.mat4.rotate(a,a,10*Math.random(),s)}o.rotation=r.mat4.multiply(r.mat4.create(),a,o.rotation),T.bind(),h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT);var l=u.getRect(o),c=r.mat4.create();r.mat4.ortho(c,l.left,l.right,l.bottom,l.top,0,f);var p=r.mat4.create();r.mat4.lookAt(p,[0,0,0],[0,0,-1],[0,1,0]);var d=r.mat4.create();r.mat4.translate(d,d,[0,0,-f/2]),r.mat4.multiply(d,d,o.rotation),N.setUniform("uProjection","Matrix4fv",!1,c),N.setUniform("uView","Matrix4fv",!1,p),N.setUniform("uModel","Matrix4fv",!1,d),N.setUniform("uBottomLeft","2fv",[l.left,l.bottom]),N.setUniform("uTopRight","2fv",[l.right,l.top]),N.setUniform("uAtomScale","1f",2.5*o.atomScale),N.setUniform("uRelativeAtomScale","1f",n.relativeAtomScale),N.setUniform("uRes","1f",e),N.setUniform("uDepth","1f",f),N.setUniform("uMode","1i",0),N.setUniform("uAtomShade","1f",n.atomShade),q.render(),n.bonds&&null!=j&&(O.setUniform("uProjection","Matrix4fv",!1,c),O.setUniform("uView","Matrix4fv",!1,p),O.setUniform("uModel","Matrix4fv",!1,d),O.setUniform("uRotation","Matrix4fv",!1,o.rotation),O.setUniform("uDepth","1f",f),O.setUniform("uBottomLeft","2fv",[l.left,l.bottom]),O.setUniform("uTopRight","2fv",[l.right,l.top]),O.setUniform("uRes","1f",e),O.setUniform("uBondRadius","1f",2.5*u.getBondRadius(n)),O.setUniform("uBondShade","1f",n.bondShade),O.setUniform("uAtomScale","1f",2.5*n.atomScale),O.setUniform("uRelativeAtomScale","1f",n.relativeAtomScale),O.setUniform("uMode","1i",0),j.render()),h.viewport(0,0,t,t);var y=u.getRect(n),x=u.getRect(o),M=r.mat4.invert(r.mat4.create(),a);E.bind(),h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT),C.setUniform("uSceneDepth","1i",v.index),C.setUniform("uSceneNormal","1i",m.index),C.setUniform("uRandRotDepth","1i",g.index),C.setUniform("uAccumulator","1i",b.index),C.setUniform("uSceneBottomLeft","2fv",[y.left,y.bottom]),C.setUniform("uSceneTopRight","2fv",[y.right,y.top]),C.setUniform("uRotBottomLeft","2fv",[x.left,x.bottom]),C.setUniform("uRotTopRight","2fv",[x.right,x.top]),C.setUniform("uRes","1f",t),C.setUniform("uDepth","1f",f),C.setUniform("uRot","Matrix4fv",!1,a),C.setUniform("uInvRot","Matrix4fv",!1,M),C.setUniform("uSampleCount","1i",X),B.render(),b.activate(),b.bind(),h.copyTexImage2D(h.TEXTURE_2D,0,h.RGBA,0,0,t,t,0)}F.getAOProgress=function(){return X/1024},F.initialize=function(){n.width=n.height=t,(h=n.getContext("webgl")).enable(h.DEPTH_TEST),h.enable(h.CULL_FACE),h.clearColor(0,0,0,0),h.clearDepth(1),h.viewport(0,0,t,t),window.gl=h,o.getExtensions(h,["EXT_frag_depth","WEBGL_depth_texture"]),F.createTextures(),N=c(h,l.shaders.atom),O=c(h,l.shaders.bond),z=c(h,l.shaders["textured-quad"]),C=c(h,l.shaders.accumulator),L=c(h,l.shaders.ao),U=c(h,l.shaders.fxaa),D=c(h,l.shaders.dof);var e=[-1,-1,0,1,-1,0,1,1,0,-1,-1,0,1,1,0,-1,1,0],r=o.buildAttribs(h,{aPosition:3});r.aPosition.buffer.set(new Float32Array(e));var a=e.length/9;new o.Renderable(h,z,r,a),B=new o.Renderable(h,C,r,a),I=new o.Renderable(h,L,r,a),V=new o.Renderable(h,U,r,a),H=new o.Renderable(h,D,r,a),0},F.createTextures=function(){y=new o.Texture(h,0,null,e,e),g=new o.Texture(h,1,null,e,e,{internalFormat:h.DEPTH_COMPONENT,format:h.DEPTH_COMPONENT,type:h.UNSIGNED_SHORT}),T=new o.Framebuffer(h,[y],g),d=new o.Texture(h,2,null,t,t),m=new o.Texture(h,3,null,t,t),v=new o.Texture(h,4,null,t,t,{internalFormat:h.DEPTH_COMPONENT,format:h.DEPTH_COMPONENT,type:h.UNSIGNED_SHORT}),S=new o.Framebuffer(h,[d],v),A=new o.Framebuffer(h,[m],v),b=new o.Texture(h,5,null,t,t),x=new o.Texture(h,6,null,t,t),E=new o.Framebuffer(h,[x]),_=new o.Texture(h,7,null,t,t),P=new o.Framebuffer(h,[_]),M=new o.Texture(h,8,null,t,t),w=new o.Texture(h,9,null,t,t),R=new o.Framebuffer(h,[w]),k=new o.Texture(h,10,null,t,t),new o.Framebuffer(h,[k])},F.setResolution=function(r,o){e=o,t=r,n.width=n.height=t,h.viewport(0,0,t,t),F.createTextures()},F.setSystem=function(n,t){function e(n){for(var t=[],e=0;e<36;e++)t.push.apply(t,n);return t}p=n;for(var r=o.buildAttribs(h,{aImposter:3,aPosition:3,aRadius:1,aColor:3}),u=[],s=[],l=[],c=[],f=0;f0)){r=o.buildAttribs(h,{aImposter:3,aPosA:3,aPosB:3,aRadA:1,aRadB:1,aColA:3,aColB:3}),u=[];var g=[],y=[],b=[],x=[],M=[],w=[];for(f=0;ft.bondThreshold)break;u.push.apply(u,a.position),g.push.apply(g,e([k.posA.x,k.posA.y,k.posA.z])),y.push.apply(y,e([k.posB.x,k.posB.y,k.posB.z])),b.push.apply(b,e([k.radA])),x.push.apply(x,e([k.radB])),M.push.apply(M,e([k.colA.r,k.colA.g,k.colA.b])),w.push.apply(w,e([k.colB.r,k.colB.g,k.colB.b]))}r.aImposter.buffer.set(new Float32Array(u)),r.aPosA.buffer.set(new Float32Array(g)),r.aPosB.buffer.set(new Float32Array(y)),r.aRadA.buffer.set(new Float32Array(b)),r.aRadB.buffer.set(new Float32Array(x)),r.aColA.buffer.set(new Float32Array(M)),r.aColB.buffer.set(new Float32Array(w));v=u.length/9;j=new o.Renderable(h,O,r,v)}},F.reset=function(){X=0,G=!1,Y=!1,b.reset(),x.reset()},F.render=function(n){if(void 0!==p&&null!=q){if(f=2*s.getRadius(p),G)if(Y)for(var e=0;e1024);e++)W(n),X++;else!function(n){Y=!0,h.viewport(0,0,t,t),A.bind(),h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT);var e=u.getRect(n),o=r.mat4.create();r.mat4.ortho(o,e.left,e.right,e.bottom,e.top,0,f);var a=r.mat4.create();r.mat4.lookAt(a,[0,0,0],[0,0,-1],[0,1,0]);var i=r.mat4.create();r.mat4.translate(i,i,[0,0,-f/2]),r.mat4.multiply(i,i,n.rotation),N.setUniform("uProjection","Matrix4fv",!1,o),N.setUniform("uView","Matrix4fv",!1,a),N.setUniform("uModel","Matrix4fv",!1,i),N.setUniform("uBottomLeft","2fv",[e.left,e.bottom]),N.setUniform("uTopRight","2fv",[e.right,e.top]),N.setUniform("uAtomScale","1f",2.5*n.atomScale),N.setUniform("uRelativeAtomScale","1f",n.relativeAtomScale),N.setUniform("uRes","1f",t),N.setUniform("uDepth","1f",f),N.setUniform("uMode","1i",1),N.setUniform("uAtomShade","1f",n.atomShade),q.render(),n.bonds&&null!=j&&(A.bind(),O.setUniform("uProjection","Matrix4fv",!1,o),O.setUniform("uView","Matrix4fv",!1,a),O.setUniform("uModel","Matrix4fv",!1,i),O.setUniform("uRotation","Matrix4fv",!1,n.rotation),O.setUniform("uDepth","1f",f),O.setUniform("uBottomLeft","2fv",[e.left,e.bottom]),O.setUniform("uTopRight","2fv",[e.right,e.top]),O.setUniform("uRes","1f",t),O.setUniform("uBondRadius","1f",2.5*u.getBondRadius(n)),O.setUniform("uBondShade","1f",n.bondShade),O.setUniform("uAtomScale","1f",2.5*n.atomScale),O.setUniform("uRelativeAtomScale","1f",n.relativeAtomScale),O.setUniform("uMode","1i",1),j.render())}(n);else!function(n){G=!0,h.viewport(0,0,t,t),S.bind(),h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT);var e=u.getRect(n),o=r.mat4.create();r.mat4.ortho(o,e.left,e.right,e.bottom,e.top,0,f);var a=r.mat4.create();r.mat4.lookAt(a,[0,0,0],[0,0,-1],[0,1,0]);var i=r.mat4.create();r.mat4.translate(i,i,[0,0,-f/2]),r.mat4.multiply(i,i,n.rotation),N.setUniform("uProjection","Matrix4fv",!1,o),N.setUniform("uView","Matrix4fv",!1,a),N.setUniform("uModel","Matrix4fv",!1,i),N.setUniform("uBottomLeft","2fv",[e.left,e.bottom]),N.setUniform("uTopRight","2fv",[e.right,e.top]),N.setUniform("uAtomScale","1f",2.5*n.atomScale),N.setUniform("uRelativeAtomScale","1f",n.relativeAtomScale),N.setUniform("uRes","1f",t),N.setUniform("uDepth","1f",f),N.setUniform("uMode","1i",0),N.setUniform("uAtomShade","1f",n.atomShade),q.render(),n.bonds&&null!=j&&(S.bind(),O.setUniform("uProjection","Matrix4fv",!1,o),O.setUniform("uView","Matrix4fv",!1,a),O.setUniform("uModel","Matrix4fv",!1,i),O.setUniform("uRotation","Matrix4fv",!1,n.rotation),O.setUniform("uDepth","1f",f),O.setUniform("uBottomLeft","2fv",[e.left,e.bottom]),O.setUniform("uTopRight","2fv",[e.right,e.top]),O.setUniform("uRes","1f",t),O.setUniform("uBondRadius","1f",2.5*u.getBondRadius(n)),O.setUniform("uBondShade","1f",n.bondShade),O.setUniform("uAtomScale","1f",2.5*n.atomScale),O.setUniform("uRelativeAtomScale","1f",n.relativeAtomScale),O.setUniform("uMode","1i",0),j.render())}(n);!function(n){h.viewport(0,0,t,t),n.fxaa>0||n.dofStrength>0?P.bind():h.bindFramebuffer(h.FRAMEBUFFER,null);if(h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT),L.setUniform("uSceneColor","1i",d.index),L.setUniform("uSceneDepth","1i",v.index),L.setUniform("uAccumulatorOut","1i",x.index),L.setUniform("uRes","1f",t),L.setUniform("uAO","1f",2*n.ao),L.setUniform("uBrightness","1f",2*n.brightness),L.setUniform("uOutlineStrength","1f",n.outline),I.render(),n.fxaa>0){n.dofStrength>0?R.bind():h.bindFramebuffer(h.FRAMEBUFFER,null);for(var e=0;e0&&(h.bindFramebuffer(h.FRAMEBUFFER,null),h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT),n.fxaa>0?D.setUniform("uColor","1i",M.index):D.setUniform("uColor","1i",_.index),D.setUniform("uDepth","1i",v.index),D.setUniform("uDOFPosition","1f",n.dofPosition),D.setUniform("uDOFStrength","1f",n.dofStrength),D.setUniform("uRes","1f",t),H.render())}(n)}},F.initialize()}},function(n,t){function e(n){var t=this;t.initialize=function(){t.buffer=n.createBuffer()},t.bind=function(){n.bindBuffer(n.ARRAY_BUFFER,t.buffer)},t.set=function(e){t.bind(),n.bufferData(n.ARRAY_BUFFER,e,n.STATIC_DRAW)},t.initialize()}n.exports.buildAttribs=function(n,t){var r={};for(var o in t)r[o]={buffer:new e(n),size:t[o]};return r},n.exports.getExtensions=function(n,t){for(var e={},r=0;r1){for(var a=[],i=0;i 0.0) {\n float depth = texture2D(uSceneDepth, p).r;\n float r = 1.0/511.0;\n float d0 = abs(texture2D(uSceneDepth, p + vec2(-r, 0)).r - depth);\n float d1 = abs(texture2D(uSceneDepth, p + vec2( r, 0)).r - depth);\n float d2 = abs(texture2D(uSceneDepth, p + vec2( 0, -r)).r - depth);\n float d3 = abs(texture2D(uSceneDepth, p + vec2( 0, r)).r - depth);\n float d = max(d0, d1);\n d = max(d, d2);\n d = max(d, d3);\n sceneColor.rgb *= pow(1.0 - d, uOutlineStrength * 32.0);\n sceneColor.a = max(step(0.003, d), sceneColor.a);\n }\n vec4 dAccum = texture2D(uAccumulatorOut, p);\n float shade = max(0.0, 1.0 - (dAccum.r + dAccum.g + dAccum.b + dAccum.a) * 0.25 * uAO);\n shade = pow(shade, 2.0);\n gl_FragColor = vec4(uBrightness * sceneColor.rgb * shade, sceneColor.a);\n}\n",atom:"#version 100\nprecision highp float;\n\nattribute vec3 aImposter;\nattribute vec3 aPosition;\nattribute float aRadius;\nattribute vec3 aColor;\n\nuniform mat4 uView;\nuniform mat4 uProjection;\nuniform mat4 uModel;\nuniform float uAtomScale;\nuniform float uRelativeAtomScale;\nuniform float uAtomShade;\n\nvarying vec3 vColor;\nvarying vec3 vPosition;\nvarying float vRadius;\n\nvoid main() {\n vRadius = uAtomScale * (1.0 + (aRadius - 1.0) * uRelativeAtomScale);\n gl_Position = uProjection * uView * uModel * vec4(vRadius * aImposter + aPosition, 1.0);\n vColor = mix(aColor, vec3(1,1,1), uAtomShade);\n vPosition = vec3(uModel * vec4(aPosition, 1));\n}\n\n\n// __split__\n\n\n#version 100\n#extension GL_EXT_frag_depth: enable\nprecision highp float;\n\nuniform vec2 uBottomLeft;\nuniform vec2 uTopRight;\nuniform float uRes;\nuniform float uDepth;\nuniform int uMode;\n\nvarying vec3 vPosition;\nvarying float vRadius;\nvarying vec3 vColor;\n\nvec2 res = vec2(uRes, uRes);\n\nfloat raySphereIntersect(vec3 r0, vec3 rd) {\n float a = dot(rd, rd);\n vec3 s0_r0 = r0 - vPosition;\n float b = 2.0 * dot(rd, s0_r0);\n float c = dot(s0_r0, s0_r0) - (vRadius * vRadius);\n float disc = b*b - 4.0*a*c;\n if (disc <= 0.0) {\n return -1.0;\n }\n return (-b - sqrt(disc))/(2.0*a);\n}\n\nvoid main() {\n vec3 r0 = vec3(uBottomLeft + (gl_FragCoord.xy/res) * (uTopRight - uBottomLeft), 0.0);\n vec3 rd = vec3(0, 0, -1);\n float t = raySphereIntersect(r0, rd);\n if (t < 0.0) {\n discard;\n }\n vec3 coord = r0 + rd * t;\n vec3 normal = normalize(coord - vPosition);\n if (uMode == 0) {\n gl_FragColor = vec4(vColor, 1);\n } else if (uMode == 1) {\n gl_FragColor = vec4(normal * 0.5 + 0.5, 1.0);\n }\n gl_FragDepthEXT = -coord.z/uDepth;\n}\n",blur:"#version 100\nprecision highp float;\n\nattribute vec3 aPosition;\n\nvoid main() {\n gl_Position = vec4(aPosition, 1);\n}\n\n\n// __split__\n\n\n#version 100\nprecision highp float;\n\nuniform sampler2D uTexture;\nuniform float uRes;\nuniform int leftRight;\n\nvoid main() {\n vec2 dir;\n if (leftRight == 1) {\n dir = vec2(1,0)/uRes;\n } else {\n dir = vec2(0,1)/uRes;\n }\n const int range = 16;\n vec4 sample = vec4(0,0,0,0);\n for (int i = -range; i <= range; i++) {\n vec2 p = gl_FragCoord.xy/uRes + dir * float(i);\n sample += texture2D(uTexture, p);\n }\n sample /= float(range) * 2.0 + 1.0;\n gl_FragColor = sample;\n}\n",bond:"#version 100\nprecision highp float;\n\nattribute vec3 aImposter;\nattribute vec3 aPosA;\nattribute vec3 aPosB;\nattribute float aRadA;\nattribute float aRadB;\nattribute vec3 aColA;\nattribute vec3 aColB;\n\nuniform mat4 uView;\nuniform mat4 uProjection;\nuniform mat4 uModel;\nuniform mat4 uRotation;\nuniform float uBondRadius;\nuniform float uAtomScale;\nuniform float uRelativeAtomScale;\n\nvarying vec3 vNormal;\nvarying vec3 vPosA, vPosB;\nvarying float vRadA, vRadB;\nvarying vec3 vColA, vColB;\nvarying float vRadius;\n\nmat3 alignVector(vec3 a, vec3 b) {\n vec3 v = cross(a, b);\n float s = length(v);\n float c = dot(a, b);\n mat3 I = mat3(\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n );\n mat3 vx = mat3(\n 0, v.z, -v.y,\n -v.z, 0, v.x,\n v.y, -v.x, 0\n );\n return I + vx + vx * vx * ((1.0 - c) / (s * s));\n}\n\nvoid main() {\n vRadius = uBondRadius;\n vec3 pos = vec3(aImposter);\n // Scale the box in x and z to be bond-radius.\n pos = pos * vec3(vRadius, 1, vRadius);\n // Shift the origin-centered cube so that the bottom is at the origin.\n pos = pos + vec3(0, 1, 0);\n // Stretch the box in y so that it is the length of the bond.\n pos = pos * vec3(1, length(aPosA - aPosB) * 0.5, 1);\n // Find the rotation that aligns vec3(0, 1, 0) with vec3(uPosB - uPosA) and apply it.\n vec3 a = normalize(vec3(-0.000001, 1.000001, 0.000001));\n vec3 b = normalize(aPosB - aPosA);\n mat3 R = alignVector(a, b);\n pos = R * pos;\n // Shift the cube so that the bottom is centered at the middle of atom A.\n pos = pos + aPosA;\n\n vec4 position = uModel * vec4(pos, 1);\n gl_Position = uProjection * uView * position;\n vPosA = aPosA;\n vPosB = aPosB;\n vRadA = uAtomScale * (1.0 + (aRadA - 1.0) * uRelativeAtomScale);\n vRadB = uAtomScale * (1.0 + (aRadB - 1.0) * uRelativeAtomScale);\n vColA = aColA;\n vColB = aColB;\n}\n\n\n// __split__\n\n\n#version 100\n#extension GL_EXT_frag_depth: enable\nprecision highp float;\n\nuniform mat4 uRotation;\nuniform vec2 uBottomLeft;\nuniform vec2 uTopRight;\nuniform float uDepth;\nuniform float uRes;\nuniform float uBondShade;\nuniform int uMode;\n\nvarying vec3 vPosA, vPosB;\nvarying float vRadA, vRadB;\nvarying vec3 vColA, vColB;\nvarying float vRadius;\n\nmat3 alignVector(vec3 a, vec3 b) {\n vec3 v = cross(a, b);\n float s = length(v);\n float c = dot(a, b);\n mat3 I = mat3(\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n );\n mat3 vx = mat3(\n 0, v.z, -v.y,\n -v.z, 0, v.x,\n v.y, -v.x, 0\n );\n return I + vx + vx * vx * ((1.0 - c) / (s * s));\n}\n\nvoid main() {\n\n vec2 res = vec2(uRes, uRes);\n vec3 r0 = vec3(uBottomLeft + (gl_FragCoord.xy/res) * (uTopRight - uBottomLeft), uDepth/2.0);\n vec3 rd = vec3(0, 0, -1);\n\n vec3 i = normalize(vPosB - vPosA);\n i = vec3(uRotation * vec4(i, 0));\n vec3 j = normalize(vec3(-0.000001, 1.000001, 0.000001));\n mat3 R = alignVector(i, j);\n\n vec3 r0p = r0 - vec3(uRotation * vec4(vPosA, 0));\n r0p = R * r0p;\n vec3 rdp = R * rd;\n\n float a = dot(rdp.xz, rdp.xz);\n float b = 2.0 * dot(rdp.xz, r0p.xz);\n float c = dot(r0p.xz, r0p.xz) - vRadius*vRadius;\n float disc = b*b - 4.0*a*c;\n if (disc <= 0.0) {\n discard;\n }\n float t = (-b - sqrt(disc))/(2.0*a);\n if (t < 0.0) {\n discard;\n }\n\n vec3 coord = r0p + rdp * t;\n if (coord.y < 0.0 || coord.y > length(vPosA - vPosB)) {\n discard;\n }\n\n vec3 color;\n if (coord.y < vRadA + 0.5 * (length(vPosA - vPosB) - (vRadA + vRadB))) {\n color = vColA;\n } else {\n color = vColB;\n }\n\n color = mix(color, vec3(1,1,1), uBondShade);\n\n R = alignVector(j, i);\n vec3 normal = normalize(R * vec3(coord.x, 0, coord.z));\n\n coord = r0 + rd * t;\n if (uMode == 0) {\n gl_FragColor = vec4(color, 1);\n } else if (uMode == 1) {\n gl_FragColor = vec4(normal * 0.5 + 0.5, 1.0);\n }\n gl_FragDepthEXT = -(coord.z - uDepth/2.0)/uDepth;\n}\n",dof:"#version 100\nprecision highp float;\n\nattribute vec3 aPosition;\n\nvoid main() {\n gl_Position = vec4(aPosition, 1);\n}\n\n\n// __split__\n\n\n#version 100\nprecision highp float;\n\nuniform sampler2D uColor;\nuniform sampler2D uDepth;\nuniform float uRes;\nuniform float uDOFPosition;\nuniform float uDOFStrength;\nuniform int leftRight;\n\nvoid main() {\n\n vec2 samples[64];\n samples[0] = vec2(0.857612, 0.019885);\n samples[1] = vec2(0.563809, -0.028071);\n samples[2] = vec2(0.825599, -0.346856);\n samples[3] = vec2(0.126584, -0.380959);\n samples[4] = vec2(0.782948, 0.594322);\n samples[5] = vec2(0.292148, -0.543265);\n samples[6] = vec2(0.130700, 0.330220);\n samples[7] = vec2(0.236088, 0.159604);\n samples[8] = vec2(-0.305259, 0.810505);\n samples[9] = vec2(0.269616, 0.923026);\n samples[10] = vec2(0.484486, 0.371845);\n samples[11] = vec2(-0.638057, 0.080447);\n samples[12] = vec2(0.199629, 0.667280);\n samples[13] = vec2(-0.861043, -0.370583);\n samples[14] = vec2(-0.040652, -0.996174);\n samples[15] = vec2(0.330458, -0.282111);\n samples[16] = vec2(0.647795, -0.214354);\n samples[17] = vec2(0.030422, -0.189908);\n samples[18] = vec2(0.177430, -0.721124);\n samples[19] = vec2(-0.461163, -0.327434);\n samples[20] = vec2(-0.410012, -0.734504);\n samples[21] = vec2(-0.616334, -0.626069);\n samples[22] = vec2(0.590759, -0.726479);\n samples[23] = vec2(-0.590794, 0.805365);\n samples[24] = vec2(-0.924561, -0.163739);\n samples[25] = vec2(-0.323028, 0.526960);\n samples[26] = vec2(0.642128, 0.752577);\n samples[27] = vec2(0.173625, -0.952386);\n samples[28] = vec2(0.759014, 0.330311);\n samples[29] = vec2(-0.360526, -0.032013);\n samples[30] = vec2(-0.035320, 0.968156);\n samples[31] = vec2(0.585478, -0.431068);\n samples[32] = vec2(-0.244766, -0.906947);\n samples[33] = vec2(-0.853096, 0.184615);\n samples[34] = vec2(-0.089061, 0.104648);\n samples[35] = vec2(-0.437613, 0.285308);\n samples[36] = vec2(-0.654098, 0.379841);\n samples[37] = vec2(-0.128663, 0.456572);\n samples[38] = vec2(0.015980, -0.568170);\n samples[39] = vec2(-0.043966, -0.771940);\n samples[40] = vec2(0.346512, -0.071238);\n samples[41] = vec2(-0.207921, -0.209121);\n samples[42] = vec2(-0.624075, -0.189224);\n samples[43] = vec2(-0.120618, 0.689339);\n samples[44] = vec2(-0.664679, -0.410200);\n samples[45] = vec2(0.371945, -0.880573);\n samples[46] = vec2(-0.743251, 0.629998);\n samples[47] = vec2(-0.191926, -0.413946);\n samples[48] = vec2(0.449574, 0.833373);\n samples[49] = vec2(0.299587, 0.449113);\n samples[50] = vec2(-0.900432, 0.399319);\n samples[51] = vec2(0.762613, -0.544796);\n samples[52] = vec2(0.606462, 0.174233);\n samples[53] = vec2(0.962185, -0.167019);\n samples[54] = vec2(0.960990, 0.249552);\n samples[55] = vec2(0.570397, 0.559146);\n samples[56] = vec2(-0.537514, 0.555019);\n samples[57] = vec2(0.108491, -0.003232);\n samples[58] = vec2(-0.237693, -0.615428);\n samples[59] = vec2(-0.217313, 0.261084);\n samples[60] = vec2(-0.998966, 0.025692);\n samples[61] = vec2(-0.418554, -0.527508);\n samples[62] = vec2(-0.822629, -0.567797);\n samples[63] = vec2(0.061945, 0.522105);\n\n float invRes = 1.0/uRes;\n vec2 coord = gl_FragCoord.xy * invRes;\n\n float strength = uDOFStrength * uRes/768.0;\n\n float depth = texture2D(uDepth, coord).r;\n float range = uDOFPosition - depth;\n float scale = abs(range);\n\n vec4 sample = texture2D(uColor, coord);\n float count = 1.0;\n for(int i = 0; i < 64; i++) {\n vec2 p = samples[i];\n p = coord + scale * 64.0 * strength * p * invRes;\n float d = texture2D(uDepth, p).r;\n float r = uDOFPosition - d;\n float s = abs(r);\n sample += texture2D(uColor, p) * s;\n count += s;\n }\n\n gl_FragColor = sample/count;\n}",fxaa:"#version 100\nprecision highp float;\n\nattribute vec3 aPosition;\n\nvoid main() {\n gl_Position = vec4(aPosition, 1);\n}\n\n\n// __split__\n\n\n#version 100\nprecision highp float;\n\nuniform sampler2D uTexture;\nuniform float uRes;\n\nvoid main() {\n float FXAA_SPAN_MAX = 8.0;\n float FXAA_REDUCE_MUL = 1.0/8.0;\n float FXAA_REDUCE_MIN = 1.0/128.0;\n\n vec2 texCoords = gl_FragCoord.xy/uRes;\n\n vec4 rgbNW = texture2D(uTexture, texCoords + (vec2(-1.0, -1.0) / uRes));\n vec4 rgbNE = texture2D(uTexture, texCoords + (vec2(1.0, -1.0) / uRes));\n vec4 rgbSW = texture2D(uTexture, texCoords + (vec2(-1.0, 1.0) / uRes));\n vec4 rgbSE = texture2D(uTexture, texCoords + (vec2(1.0, 1.0) / uRes));\n vec4 rgbM = texture2D(uTexture, texCoords);\n\n vec4 luma = vec4(0.299, 0.587, 0.114, 1.0);\n float lumaNW = dot(rgbNW, luma);\n float lumaNE = dot(rgbNE, luma);\n float lumaSW = dot(rgbSW, luma);\n float lumaSE = dot(rgbSE, luma);\n float lumaM = dot(rgbM, luma);\n\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce);\n\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) / uRes;\n\n vec4 rgbA = (1.0/2.0) * \n (texture2D(uTexture, texCoords.xy + dir * (1.0/3.0 - 0.5)) + \n texture2D(uTexture, texCoords.xy + dir * (2.0/3.0 - 0.5)));\n vec4 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * \n (texture2D(uTexture, texCoords.xy + dir * (0.0/3.0 - 0.5)) +\n texture2D(uTexture, texCoords.xy + dir * (3.0/3.0 - 0.5)));\n float lumaB = dot(rgbB, luma);\n\n if((lumaB < lumaMin) || (lumaB > lumaMax)){\n gl_FragColor = rgbA;\n } else {\n gl_FragColor = rgbB;\n }\n\n}","textured-quad":"#version 100\nprecision highp float;\n\nattribute vec3 aPosition;\n\nvoid main() {\n gl_Position = vec4(aPosition, 1);\n}\n\n\n// __split__\n\n\n#version 100\nprecision highp float;\n\nuniform sampler2D uTexture;\nuniform float uRes;\n\nvoid main() {\n gl_FragColor = texture2D(uTexture, gl_FragCoord.xy/uRes);\n}\n"};n.exports={shaders:r}},function(n,t,e){"use strict";var r=e(8);n.exports=function(n){if(arguments.length>1)throw"Error: The Speck Interactions module has changed!";if(0===arguments.length||"object"!=typeof n)throw"Error: Arguments not provided to interactions";var t=void 0===n.scrollZoom||n.scrollZoom,e=n.container,o=n.getRotation,a=n.setRotation,i=n.getTranslation,u=n.setTranslation,s=n.getZoom,l=n.setZoom,c=n.refreshView,f={buttonDown:!1,shiftDown:!1,lastX:0,lastY:0};function p(n){0===n.button&&(f={buttonDown:!0,shiftDown:f.shiftDown,lastX:n.clientX,lastY:n.clientY})}function h(n){if(0===n.button){if(!f.buttonDown)return;f.buttonDown=!1}}function d(n){f.shiftDown=n.shiftKey}function m(n){if(f.buttonDown&&0!==n.buttons){n.preventDefault();var t=n.clientX-f.lastX,e=n.clientY-f.lastY;if(0!==t||0!==e){if(f.lastX=n.clientX,f.lastY=n.clientY,f.shiftDown){var l=i(),p=.001/s();u({x:l.x-t*p,y:l.y+e*p})}else{var h={rotation:new Float32Array(o())};r.rotate(h,t,e),a(h.rotation)}c()}}}function v(n){n.preventDefault(),l(s()*(n.deltaY<0?1/.9:.9)),c()}return e.addEventListener("mousedown",p),window.addEventListener("mouseup",h),window.addEventListener("keydown",d),window.addEventListener("keyup",d),window.addEventListener("mousemove",m),t&&e.addEventListener("wheel",v),function(){e.removeEventListener("mousedown",p),window.removeEventListener("mouseup",h),window.removeEventListener("keydown",d),window.removeEventListener("keyup",d),window.removeEventListener("mousemove",m),e.removeEventListener("wheel",v)}}},function(n,t){n.exports={default:{atomScale:.6,relativeAtomScale:1,bondScale:.5,ao:.75,aoRes:256,brightness:.5,outline:0,spf:32,bonds:!1,bondThreshold:1.2,bondShade:.5,atomShade:.5,dofStrength:0,dofPosition:.5,fxaa:1},stickball:{atomScale:.24,relativeAtomScale:.64,bondScale:.5,bonds:!0,bondThreshold:1.2},toon:{ao:0,spf:0,brightness:.5,outline:1},licorice:{atomScale:.1,relativeAtomScale:0,bondScale:1,bonds:!0,bondThreshold:1.2}}},function(n,t,e){"use strict";e.r(t);var r=e(10),o=e(18),a=e(1),i=e.n(a),u=e(0),s=e.n(u),l=e(22),c=e(43);function f(n){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function p(n,t){for(var e=0;e=0;)t=p[e],Object(i.a)(t,n)&&!d(r,t)&&(r[r.length]=t),e-=1;return r}):Object(s.a)(function(n){return Object(n)!==n?[]:Object.keys(n)}),v=Object(s.a)(function(n){return null===n?"Null":void 0===n?"Undefined":Object.prototype.toString.call(n).slice(8,-1)});function g(n,t,e,r){var i=o(n);function u(n,t){return y(n,t,e.slice(),r.slice())}return!a(function(n,t){return!a(u,t,n)},o(t),i)}function y(n,t,e,r){if(u(n,t))return!0;var o,a,s=v(n);if(s!==v(t))return!1;if(null==n||null==t)return!1;if("function"==typeof n["fantasy-land/equals"]||"function"==typeof t["fantasy-land/equals"])return"function"==typeof n["fantasy-land/equals"]&&n["fantasy-land/equals"](t)&&"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](n);if("function"==typeof n.equals||"function"==typeof t.equals)return"function"==typeof n.equals&&n.equals(t)&&"function"==typeof t.equals&&t.equals(n);switch(s){case"Arguments":case"Array":case"Object":if("function"==typeof n.constructor&&"Promise"===(o=n.constructor,null==(a=String(o).match(/^function (\w*)/))?"":a[1]))return n===t;break;case"Boolean":case"Number":case"String":if(typeof n!=typeof t||!u(n.valueOf(),t.valueOf()))return!1;break;case"Date":if(!u(n.valueOf(),t.valueOf()))return!1;break;case"Error":return n.name===t.name&&n.message===t.message;case"RegExp":if(n.source!==t.source||n.global!==t.global||n.ignoreCase!==t.ignoreCase||n.multiline!==t.multiline||n.sticky!==t.sticky||n.unicode!==t.unicode)return!1}for(var l=e.length-1;l>=0;){if(e[l]===n)return r[l]===t;l-=1}switch(s){case"Map":return n.size===t.size&&g(n.entries(),t.entries(),e.concat([n]),r.concat([t]));case"Set":return n.size===t.size&&g(n.values(),t.values(),e.concat([n]),r.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var c=m(n);if(c.length!==m(t).length)return!1;var f=e.concat([n]),p=r.concat([t]);for(l=c.length-1;l>=0;){var h=c[l];if(!Object(i.a)(h,t)||!y(t[h],n[h],f,p))return!1;l-=1}return!0}var b=Object(r.a)(function(n,t){return y(n,t,[],[])});t.a=b}]); \ No newline at end of file +window.dash_bio=function(n){function t(t){for(var e,o,a=t[0],i=t[1],u=0,s=[];u0&&(o=1/Math.sqrt(o),n[0]=t[0]*o,n[1]=t[1]*o),n},u.dot=function(n,t){return n[0]*t[0]+n[1]*t[1]},u.cross=function(n,t,e){var r=t[0]*e[1]-t[1]*e[0];return n[0]=n[1]=0,n[2]=r,n},u.lerp=function(n,t,e,r){var o=t[0],a=t[1];return n[0]=o+r*(e[0]-o),n[1]=a+r*(e[1]-a),n},u.random=function(n,t){t=t||1;var e=2*r()*Math.PI;return n[0]=Math.cos(e)*t,n[1]=Math.sin(e)*t,n},u.transformMat2=function(n,t,e){var r=t[0],o=t[1];return n[0]=e[0]*r+e[2]*o,n[1]=e[1]*r+e[3]*o,n},u.transformMat2d=function(n,t,e){var r=t[0],o=t[1];return n[0]=e[0]*r+e[2]*o+e[4],n[1]=e[1]*r+e[3]*o+e[5],n},u.transformMat3=function(n,t,e){var r=t[0],o=t[1];return n[0]=e[0]*r+e[3]*o+e[6],n[1]=e[1]*r+e[4]*o+e[7],n},u.transformMat4=function(n,t,e){var r=t[0],o=t[1];return n[0]=e[0]*r+e[4]*o+e[12],n[1]=e[1]*r+e[5]*o+e[13],n},u.forEach=(i=u.create(),function(n,t,e,r,o,a){var u,s;for(t||(t=2),e||(e=0),s=r?Math.min(r*t+e,n.length):n.length,u=e;u0&&(a=1/Math.sqrt(a),n[0]=t[0]*a,n[1]=t[1]*a,n[2]=t[2]*a),n},s.dot=function(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]},s.cross=function(n,t,e){var r=t[0],o=t[1],a=t[2],i=e[0],u=e[1],s=e[2];return n[0]=o*s-a*u,n[1]=a*i-r*s,n[2]=r*u-o*i,n},s.lerp=function(n,t,e,r){var o=t[0],a=t[1],i=t[2];return n[0]=o+r*(e[0]-o),n[1]=a+r*(e[1]-a),n[2]=i+r*(e[2]-i),n},s.random=function(n,t){t=t||1;var e=2*r()*Math.PI,o=2*r()-1,a=Math.sqrt(1-o*o)*t;return n[0]=Math.cos(e)*a,n[1]=Math.sin(e)*a,n[2]=o*t,n},s.transformMat4=function(n,t,e){var r=t[0],o=t[1],a=t[2],i=e[3]*r+e[7]*o+e[11]*a+e[15];return i=i||1,n[0]=(e[0]*r+e[4]*o+e[8]*a+e[12])/i,n[1]=(e[1]*r+e[5]*o+e[9]*a+e[13])/i,n[2]=(e[2]*r+e[6]*o+e[10]*a+e[14])/i,n},s.transformMat3=function(n,t,e){var r=t[0],o=t[1],a=t[2];return n[0]=r*e[0]+o*e[3]+a*e[6],n[1]=r*e[1]+o*e[4]+a*e[7],n[2]=r*e[2]+o*e[5]+a*e[8],n},s.transformQuat=function(n,t,e){var r=t[0],o=t[1],a=t[2],i=e[0],u=e[1],s=e[2],l=e[3],c=l*r+u*a-s*o,f=l*o+s*r-i*a,p=l*a+i*o-u*r,h=-i*r-u*o-s*a;return n[0]=c*l+h*-i+f*-s-p*-u,n[1]=f*l+h*-u+p*-i-c*-s,n[2]=p*l+h*-s+c*-u-f*-i,n},s.rotateX=function(n,t,e,r){var o=[],a=[];return o[0]=t[0]-e[0],o[1]=t[1]-e[1],o[2]=t[2]-e[2],a[0]=o[0],a[1]=o[1]*Math.cos(r)-o[2]*Math.sin(r),a[2]=o[1]*Math.sin(r)+o[2]*Math.cos(r),n[0]=a[0]+e[0],n[1]=a[1]+e[1],n[2]=a[2]+e[2],n},s.rotateY=function(n,t,e,r){var o=[],a=[];return o[0]=t[0]-e[0],o[1]=t[1]-e[1],o[2]=t[2]-e[2],a[0]=o[2]*Math.sin(r)+o[0]*Math.cos(r),a[1]=o[1],a[2]=o[2]*Math.cos(r)-o[0]*Math.sin(r),n[0]=a[0]+e[0],n[1]=a[1]+e[1],n[2]=a[2]+e[2],n},s.rotateZ=function(n,t,e,r){var o=[],a=[];return o[0]=t[0]-e[0],o[1]=t[1]-e[1],o[2]=t[2]-e[2],a[0]=o[0]*Math.cos(r)-o[1]*Math.sin(r),a[1]=o[0]*Math.sin(r)+o[1]*Math.cos(r),a[2]=o[2],n[0]=a[0]+e[0],n[1]=a[1]+e[1],n[2]=a[2]+e[2],n},s.forEach=function(){var n=s.create();return function(t,e,r,o,a,i){var u,s;for(e||(e=3),r||(r=0),s=o?Math.min(o*e+r,t.length):t.length,u=r;u1?0:Math.acos(o)},s.str=function(n){return"vec3("+n[0]+", "+n[1]+", "+n[2]+")"},void 0!==n&&(n.vec3=s);var l={create:function(){var n=new e(4);return n[0]=0,n[1]=0,n[2]=0,n[3]=0,n},clone:function(n){var t=new e(4);return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t},fromValues:function(n,t,r,o){var a=new e(4);return a[0]=n,a[1]=t,a[2]=r,a[3]=o,a},copy:function(n,t){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n},set:function(n,t,e,r,o){return n[0]=t,n[1]=e,n[2]=r,n[3]=o,n},add:function(n,t,e){return n[0]=t[0]+e[0],n[1]=t[1]+e[1],n[2]=t[2]+e[2],n[3]=t[3]+e[3],n},subtract:function(n,t,e){return n[0]=t[0]-e[0],n[1]=t[1]-e[1],n[2]=t[2]-e[2],n[3]=t[3]-e[3],n}};l.sub=l.subtract,l.multiply=function(n,t,e){return n[0]=t[0]*e[0],n[1]=t[1]*e[1],n[2]=t[2]*e[2],n[3]=t[3]*e[3],n},l.mul=l.multiply,l.divide=function(n,t,e){return n[0]=t[0]/e[0],n[1]=t[1]/e[1],n[2]=t[2]/e[2],n[3]=t[3]/e[3],n},l.div=l.divide,l.min=function(n,t,e){return n[0]=Math.min(t[0],e[0]),n[1]=Math.min(t[1],e[1]),n[2]=Math.min(t[2],e[2]),n[3]=Math.min(t[3],e[3]),n},l.max=function(n,t,e){return n[0]=Math.max(t[0],e[0]),n[1]=Math.max(t[1],e[1]),n[2]=Math.max(t[2],e[2]),n[3]=Math.max(t[3],e[3]),n},l.scale=function(n,t,e){return n[0]=t[0]*e,n[1]=t[1]*e,n[2]=t[2]*e,n[3]=t[3]*e,n},l.scaleAndAdd=function(n,t,e,r){return n[0]=t[0]+e[0]*r,n[1]=t[1]+e[1]*r,n[2]=t[2]+e[2]*r,n[3]=t[3]+e[3]*r,n},l.distance=function(n,t){var e=t[0]-n[0],r=t[1]-n[1],o=t[2]-n[2],a=t[3]-n[3];return Math.sqrt(e*e+r*r+o*o+a*a)},l.dist=l.distance,l.squaredDistance=function(n,t){var e=t[0]-n[0],r=t[1]-n[1],o=t[2]-n[2],a=t[3]-n[3];return e*e+r*r+o*o+a*a},l.sqrDist=l.squaredDistance,l.length=function(n){var t=n[0],e=n[1],r=n[2],o=n[3];return Math.sqrt(t*t+e*e+r*r+o*o)},l.len=l.length,l.squaredLength=function(n){var t=n[0],e=n[1],r=n[2],o=n[3];return t*t+e*e+r*r+o*o},l.sqrLen=l.squaredLength,l.negate=function(n,t){return n[0]=-t[0],n[1]=-t[1],n[2]=-t[2],n[3]=-t[3],n},l.inverse=function(n,t){return n[0]=1/t[0],n[1]=1/t[1],n[2]=1/t[2],n[3]=1/t[3],n},l.normalize=function(n,t){var e=t[0],r=t[1],o=t[2],a=t[3],i=e*e+r*r+o*o+a*a;return i>0&&(i=1/Math.sqrt(i),n[0]=t[0]*i,n[1]=t[1]*i,n[2]=t[2]*i,n[3]=t[3]*i),n},l.dot=function(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]*t[3]},l.lerp=function(n,t,e,r){var o=t[0],a=t[1],i=t[2],u=t[3];return n[0]=o+r*(e[0]-o),n[1]=a+r*(e[1]-a),n[2]=i+r*(e[2]-i),n[3]=u+r*(e[3]-u),n},l.random=function(n,t){return t=t||1,n[0]=r(),n[1]=r(),n[2]=r(),n[3]=r(),l.normalize(n,n),l.scale(n,n,t),n},l.transformMat4=function(n,t,e){var r=t[0],o=t[1],a=t[2],i=t[3];return n[0]=e[0]*r+e[4]*o+e[8]*a+e[12]*i,n[1]=e[1]*r+e[5]*o+e[9]*a+e[13]*i,n[2]=e[2]*r+e[6]*o+e[10]*a+e[14]*i,n[3]=e[3]*r+e[7]*o+e[11]*a+e[15]*i,n},l.transformQuat=function(n,t,e){var r=t[0],o=t[1],a=t[2],i=e[0],u=e[1],s=e[2],l=e[3],c=l*r+u*a-s*o,f=l*o+s*r-i*a,p=l*a+i*o-u*r,h=-i*r-u*o-s*a;return n[0]=c*l+h*-i+f*-s-p*-u,n[1]=f*l+h*-u+p*-i-c*-s,n[2]=p*l+h*-s+c*-u-f*-i,n},l.forEach=function(){var n=l.create();return function(t,e,r,o,a,i){var u,s;for(e||(e=4),r||(r=0),s=o?Math.min(o*e+r,t.length):t.length,u=r;u.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(s.cross(d,t,e),n[0]=d[0],n[1]=d[1],n[2]=d[2],n[3]=1+r,y.normalize(n,n))}),y.setAxes=(g=p.create(),function(n,t,e,r){return g[0]=e[0],g[3]=e[1],g[6]=e[2],g[1]=r[0],g[4]=r[1],g[7]=r[2],g[2]=-t[0],g[5]=-t[1],g[8]=-t[2],y.normalize(n,y.fromMat3(n,g))}),y.clone=l.clone,y.fromValues=l.fromValues,y.copy=l.copy,y.set=l.set,y.identity=function(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n},y.setAxisAngle=function(n,t,e){e*=.5;var r=Math.sin(e);return n[0]=r*t[0],n[1]=r*t[1],n[2]=r*t[2],n[3]=Math.cos(e),n},y.add=l.add,y.multiply=function(n,t,e){var r=t[0],o=t[1],a=t[2],i=t[3],u=e[0],s=e[1],l=e[2],c=e[3];return n[0]=r*c+i*u+o*l-a*s,n[1]=o*c+i*s+a*u-r*l,n[2]=a*c+i*l+r*s-o*u,n[3]=i*c-r*u-o*s-a*l,n},y.mul=y.multiply,y.scale=l.scale,y.rotateX=function(n,t,e){e*=.5;var r=t[0],o=t[1],a=t[2],i=t[3],u=Math.sin(e),s=Math.cos(e);return n[0]=r*s+i*u,n[1]=o*s+a*u,n[2]=a*s-o*u,n[3]=i*s-r*u,n},y.rotateY=function(n,t,e){e*=.5;var r=t[0],o=t[1],a=t[2],i=t[3],u=Math.sin(e),s=Math.cos(e);return n[0]=r*s-a*u,n[1]=o*s+i*u,n[2]=a*s+r*u,n[3]=i*s-o*u,n},y.rotateZ=function(n,t,e){e*=.5;var r=t[0],o=t[1],a=t[2],i=t[3],u=Math.sin(e),s=Math.cos(e);return n[0]=r*s+o*u,n[1]=o*s-r*u,n[2]=a*s+i*u,n[3]=i*s-a*u,n},y.calculateW=function(n,t){var e=t[0],r=t[1],o=t[2];return n[0]=e,n[1]=r,n[2]=o,n[3]=Math.sqrt(Math.abs(1-e*e-r*r-o*o)),n},y.dot=l.dot,y.lerp=l.lerp,y.slerp=function(n,t,e,r){var o,a,i,u,s,l=t[0],c=t[1],f=t[2],p=t[3],h=e[0],d=e[1],m=e[2],v=e[3];return(a=l*h+c*d+f*m+p*v)<0&&(a=-a,h=-h,d=-d,m=-m,v=-v),1-a>1e-6?(o=Math.acos(a),i=Math.sin(o),u=Math.sin((1-r)*o)/i,s=Math.sin(r*o)/i):(u=1-r,s=r),n[0]=u*l+s*h,n[1]=u*c+s*d,n[2]=u*f+s*m,n[3]=u*p+s*v,n},y.invert=function(n,t){var e=t[0],r=t[1],o=t[2],a=t[3],i=e*e+r*r+o*o+a*a,u=i?1/i:0;return n[0]=-e*u,n[1]=-r*u,n[2]=-o*u,n[3]=a*u,n},y.conjugate=function(n,t){return n[0]=-t[0],n[1]=-t[1],n[2]=-t[2],n[3]=t[3],n},y.length=l.length,y.len=y.length,y.squaredLength=l.squaredLength,y.sqrLen=y.squaredLength,y.normalize=l.normalize,y.fromMat3=function(n,t){var e,r=t[0]+t[4]+t[8];if(r>0)e=Math.sqrt(r+1),n[3]=.5*e,e=.5/e,n[0]=(t[5]-t[7])*e,n[1]=(t[6]-t[2])*e,n[2]=(t[1]-t[3])*e;else{var o=0;t[4]>t[0]&&(o=1),t[8]>t[3*o+o]&&(o=2);var a=(o+1)%3,i=(o+2)%3;e=Math.sqrt(t[3*o+o]-t[3*a+a]-t[3*i+i]+1),n[o]=.5*e,e=.5/e,n[3]=(t[3*a+i]-t[3*i+a])*e,n[a]=(t[3*a+o]+t[3*o+a])*e,n[i]=(t[3*i+o]+t[3*o+i])*e}return n},y.str=function(n){return"quat("+n[0]+", "+n[1]+", "+n[2]+", "+n[3]+")"},void 0!==n&&(n.quat=y)}(e.exports)}()},function(n,t,e){"use strict";var r=e(7),o=e(6),a=e(20);function i(n,t,e){return Math.min(t,Math.max(n,e))}n.exports.new=function(){return{aspect:1,zoom:.125,translation:{x:0,y:0},atomScale:.6,relativeAtomScale:1,bondScale:.5,rotation:r.mat4.create(),ao:.75,aoRes:256,brightness:.5,outline:0,spf:32,bonds:!1,bondThreshold:1.2,bondShade:.5,atomShade:.5,resolution:768,dofStrength:0,dofPosition:.5,fxaa:1}},n.exports.center=function(n,t){for(var e=-1/0,a=1/0,i=-1/0,u=1/0,s=0;st&&(t=u,n.farAtom=r)}return n.farAtom});n.exports.getRadius=function(n){var t=u(n),e=a.MAX_ATOM_RADIUS,r=2.5*Math.sqrt(e*e+e*e+e*e);return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z)+r}},function(n,t,e){n.exports=function(n){function t(r){if(e[r])return e[r].exports;var o=e[r]={exports:{},id:r,loaded:!1};return n[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var e={};return t.m=n,t.c=e,t.p="",t(0)}([function(n,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FornaContainer=function(n,t){function e(n){return Math.sqrt(n[0]*n[0]+n[1]*n[1])}function o(n){var t=n,r=n.prevNode;if(null!==r&&n.linked){var o=[-(t.x-r.x),-(t.y-r.y)],i=[-(o=[o[0]/e(o),o[1]/e(o)])[1],o[0]],u=[n.radius*o[0],n.radius*o[1]],s="M"+(u[0]+6*(o[0]+i[0])/2)+","+(u[1]+6*(o[1]+i[1])/2)+"L"+u[0]+","+u[1]+"L"+(u[0]+6*(o[0]-i[0])/2)+","+(u[1]+6*(o[1]-i[1])/2);a.default.select(this).attr("d",s)}}function c(n){return"basepair"==n.linkType||"backbone"==n.linkType||"pseudoknot"==n.linkType||"label_link"==n.linkType||"external"==n.linkType||"chain_chain"==n.linkType}function f(n,t,e){if(n.hasOwnProperty(t.num)){var r=parseFloat(n[t.num]);return isNaN(r)?n[t.num]:e(r)}return"white"}function p(){b=null,x=null}function h(n){var t=R.selectAll("g.gnode");return t.filter(function(n){return n.selected})}function d(n){var t=n.radius+16,e=n.x-t,r=n.x+t,o=n.y-t,a=n.y+t;return function(t,i,u,s,l){if(t.point&&t.point!==n){var c=n.x-t.point.x,f=n.y-t.point.y,p=Math.sqrt(c*c+f*f),h=n.radius+t.point.radius;h>p&&(p=(p-h)/p*.1,n.x-=c*=p,n.y-=f*=p,t.point.x+=c,t.point.y+=f)}return i>r||e>s||u>a||o>l}}function m(){if(!g.deaf&&!N){switch(a.default.event.keyCode){case 16:N=!0;break;case 17:O=!0;break;case 67:g.centerView()}(N||O)&&(S.call(g.zoomer).on("mousedown.zoom",null).on("touchstart.zoom",null).on("touchmove.zoom",null).on("touchend.zoom",null),T.selectAll("g.gnode").on("mousedown.drag",null)),O&&(A.select(".background").style("cursor","crosshair"),A.call(g.brusher))}}function v(){N=!1,O=!1,A.call(g.brusher).on("mousedown.brush",null).on("touchstart.brush",null).on("touchmove.brush",null).on("touchend.brush",null),A.select(".background").style("cursor","auto"),S.call(g.zoomer),T.selectAll("g.gnode").call(C)}var g=this;if(g.options={displayAllLinks:!1,labelInterval:10,applyForce:!0,initialSize:null,allowPanningAndZooming:!0,transitionDuration:500,resizeSvgOnResize:!0},arguments.length>1)for(var y in t)g.options.hasOwnProperty(y)&&(g.options[y]=t[y]);null!==g.options.initialSize?(g.options.svgW=g.options.initialSize[0],g.options.svgH=g.options.initialSize[1]):(g.options.svgW=800,g.options.svgH=800),a.default.scale.category20();var b=null,x=null,M=a.default.scale.linear().domain([0,g.options.svgW]).range([0,g.options.svgW]),w=a.default.scale.linear().domain([0,g.options.svgH]).range([0,g.options.svgH]),k=g.graph={nodes:[],links:[]};g.linkStrengths={pseudoknot:0,proteinChain:0,chainChain:0,intermolecule:10,external:0,other:10},g.displayParameters={displayBackground:"true",displayNumbering:"true",displayNodeOutline:"true",displayNodeLabel:"true",displayLinks:"true",displayPseudoknotLinks:"true",displayProteinLinks:"true"},g.colorScheme="structure",g.customColors={},g.animation=g.options.applyForce,g.deaf=!1,g.rnas={},g.extraLinks=[],Array.prototype.equals=function(n){if(!n)return!1;if(this.length!=n.length)return!1;for(var t=0,e=this.length;e>t;t++)if(this[t]instanceof Array&&n[t]instanceof Array){if(!this[t].equals(n[t]))return!1}else if(this[t]!=n[t])return!1;return!0},g.createInitialLayout=function(n,t){var e={sequence:"",name:"empty",positions:[],labelInterval:g.options.labelInterval,avoidOthers:!0,uids:[],circularizeExternal:!0};if(2==arguments.length)for(var r in t)e.hasOwnProperty(r)&&(e[r]=t[r]);var o=new u.RNAGraph(e.sequence,n,e.name);o.circularizeExternal=e.circularizeExternal;var a=o.recalculateElements();return 0===e.positions.length&&(e.positions=(0,s.simpleXyCoordinates)(a.pairtable)),a=a.elementsToJson().addUids(e.uids).addPositions("nucleotide",e.positions).addLabels(1,e.labelInterval).reinforceStems().reinforceLoops().connectFakeNodes().reassignLinkUids().breakNodesToFakeNodes()},g.addRNA=function(n,t){var e=g.createInitialLayout(n,t);if(1===arguments.length&&(t={}),"extraLinks"in t){var r=g.addExternalLinks(e,t.extraLinks);g.extraLinks=g.extraLinks.concat(r)}return"avoidOthers"in t?g.addRNAJSON(e,t.avoidOthers):g.addRNAJSON(e,!0),e},g.addExternalLinks=function(n,t){for(var e=[],r=0;r0?a.default.max(g.graph.nodes.map(function(n){return n.x})):0,r=a.default.min(n.nodes.map(function(n){return n.x})),n.nodes.forEach(function(n){n.x+=e-r+20,n.px+=e-r})),n.nodes.forEach(function(t){t.rna=n}),g.rnas[n.uid]=n,g.recalculateGraph(),g.update(),g.centerView(),n},g.transitionRNA=function(n,t){var e=g.options.transitionDuration,r=g.graph.nodes.filter(function(n){return"nucleotide"==n.nodeType}).map(function(n){return n.uid}),a={uids:r},i=g.createInitialLayout(n,a),u=R.selectAll("g.gnode").data(i.nodes,U),e=g.options.transitionDuration;0===e?u.attr("transform",function(n){return"translate("+[n.x,n.y]+")"}):u.transition().attr("transform",function(n){return"translate("+[n.x,n.y]+")"}).duration(e);var s=E.selectAll("line.link").data(i.links.filter(c),L),l=g.createNewNodes(u.enter()).attr("transform",function(n){return void 0!==n.x&&void 0!==n.y?"translate("+[0,0]+")":""});0===e?u.exit().remove():u.exit().transition().attr("transform",function(n){return void 0!==n.x&&void 0!==n.y?"translate("+[0,0]+")":""}),u.select("path").each(o),g.graph.nodes=u.data(),g.updateStyle(),g.centerView(e),s.exit().remove(),0===e?(s.attr("x1",function(n){return n.source.x}).attr("y1",function(n){return n.source.y}).attr("x2",function(n){return n.target.x}).attr("y2",function(n){return n.target.y}),g.createNewLinks(s.enter()),g.graph.links=s.data(),g.updateStyle()):s.transition().attr("x1",function(n){return n.source.x}).attr("y1",function(n){return n.source.y}).attr("x2",function(n){return n.target.x}).attr("y2",function(n){return n.target.y}).duration(e).call(function(n,t){0===n.size()&&setTimeout(t,e);var r=0;n.each(function(){++r}).each("end",function(){--r||t.apply(this,arguments)})},function(){g.createNewLinks(s.enter()),g.graph.links=s.data(),g.updateStyle(),void 0!==t&&t()}),0===e?l.attr("transform",function(n){return void 0!==n.x&&void 0!==n.y?"translate("+[n.x,n.y]+")":""}):l.transition().attr("transform",function(n){return void 0!==n.x&&void 0!==n.y?"translate("+[n.x,n.y]+")":""})},g.recalculateGraph=function(){for(var n in g.graph.nodes=[],g.graph.links=[],g.rnas)g.graph.nodes=g.graph.nodes.concat(g.rnas[n].nodes),g.graph.links=g.graph.links.concat(g.rnas[n].links);for(var t={},e=0;e0?(maxX=a.default.max(g.graph.nodes.map(function(n){return n.x})),maxY=a.default.max(g.graph.nodes.map(function(n){return n.y}))):(maxX=0,maxY=0),n.nodes.forEach(function(n){n.rna.uid in g.rnas||(g.rnas[n.rna.uid]=n.rna),n.x+=maxX,n.px+=maxX}),r=new u.RNAGraph("",""),r.nodes=n.nodes,r.links=n.links,g.recalculateGraph(),g.update(),g.centerView()},g.addCustomColors=function(n){g.customColors=n},g.addCustomColorsText=function(n){var t=new l.ColorScheme(n);g.customColors=t.colorsJson,g.changeColorScheme("custom")},g.clearNodes=function(){g.graph.nodes=[],g.graph.links=[],g.rnas={},g.extraLinks=[],g.update()},g.toJSON=function(){var n={rnas:g.rnas,extraLinks:g.extraLinks},t=JSON.stringify(n,function(n,t){return"rna"==n?void 0:t},"\t");return t},g.fromJSON=function(n){var t,e;try{var o=JSON.parse(n);t=o.rnas,e=o.extraLinks}catch(n){throw n}for(var a in t)"rna"==t[a].type?(r=new u.RNAGraph,r.seq=t[a].seq,r.dotbracket=t[a].dotbracket,r.circular=t[a].circular,r.pairtable=t[a].pairtable,r.uid=t[a].uid,r.structName=t[a].structName,r.nodes=t[a].nodes,r.links=t[a].links,r.rnaLength=t[a].rnaLength,r.elements=t[a].elements,r.nucsToNodes=t[a].nucsToNodes,r.pseudoknotPairs=t[a].pseudoknotPairs):(r=new ProteinGraph,r.size=t[a].size,r.nodes=t[a].nodes,r.uid=t[a].uid),g.addRNAJSON(r,!1);e.forEach(function(n){g.extraLinks.push(n)}),g.recalculateGraph(),g.update()},g.setSize=function(){if(null==g.options.initialSize){var t=a.default.select(n).node().offsetHeight,e=a.default.select(n).node().offsetWidth;g.options.svgW=e,g.options.svgH=t,M.range([0,e]).domain([0,e]),w.range([0,t]).domain([0,t]),g.zoomer.x(M).y(w),g.brusher.x(M).y(w),g.centerView(),g.options.resizeSvgOnResize&&_.attr("width",e).attr("height",t)}},g.setOutlineColor=function(n){var t=R.selectAll("g.gnode").select("[node_type=nucleotide]");t.style("fill",n)},g.changeColorScheme=function(n){var t=R.selectAll("[node_type=protein]");t.classed("protein",!0).attr("r",function(n){return n.radius});var e=(R.selectAll("g.gnode"),R.selectAll("g.gnode").selectAll("circle"),R.selectAll("g.gnode").select("[node_type=nucleotide]"));if(g.colorScheme=n,"sequence"==n){var r=a.default.scale.ordinal().range(["#dbdb8d","#98df8a","#ff9896","#aec7e8","#aec7e8"]).domain(["A","C","G","U","T"]);e.style("fill",function(n){return r(n.name)})}else if("structure"==n){var r=a.default.scale.category10().domain(["s","m","i","e","t","h","x"]).range(["lightgreen","#ff9896","#dbdb8d","lightsalmon","lightcyan","lightblue","transparent"]);e.style("fill",function(n){return r(n.elemType)})}else if("positions"==n)e.style("fill",function(n){var t=a.default.scale.linear().range(["#98df8a","#dbdb8d","#ff9896"]).interpolate(a.default.interpolateLab).domain([1,1+(n.rna.rnaLength-1)/2,n.rna.rnaLength]);return t(n.num)});else if("custom"==n){if(void 0!==g.customColors&&"domain"in g.customColors&&"range"in g.customColors)var r=a.default.scale.linear().interpolate(a.default.interpolateLab).domain(g.customColors.domain).range(g.customColors.range);e.style("fill",function(n){if(void 0===g.customColors||!g.customColors.hasOwnProperty("colorValues"))return"white";if(g.customColors.colorValues.hasOwnProperty(n.structName)&&g.customColors.colorValues[n.structName].hasOwnProperty(n.num)){var t=g.customColors.colorValues[n.structName];return f(t,n,r)}if(g.customColors.colorValues.hasOwnProperty("")){var t=g.customColors.colorValues[""];return f(t,n,r)}return"white"})}},window.addEventListener("resize",g.setSize,!1),g.zoomer=a.default.behavior.zoom().scaleExtent([.1,10]).x(M).y(w).on("zoomstart",function(){var n=R.selectAll("g.gnode").selectAll(".outline_node");n.each(function(n){n.selected=!1,n.previouslySelected=!1}),n.classed("selected",!1)}).on("zoom",function(){T.attr("transform","translate("+a.default.event.translate+") scale("+a.default.event.scale+")")}),a.default.select(n).select("svg").remove();var _=a.default.select(n).attr("tabindex",1).on("keydown.brush",m).on("keyup.brush",v).each(function(){this.focus()}).append("svg:svg").attr("width",g.options.svgW).attr("height",g.options.svgH).attr("id","plotting-area");g.options.svg=_;var S=_.append("svg:g").on("mousemove",function(){b&&(mpos=a.default.mouse(T.node()),P.attr("x1",b.x).attr("y1",b.y).attr("x2",mpos[0]).attr("y2",mpos[1]))}).on("mousedown",function(){}).on("mouseup",function(){b&&P.attr("class","drag_line_hidden"),p()});g.options.allowPanningAndZooming&&S.call(g.zoomer);var A=S.append("g").datum(function(){return{selected:!1,previouslySelected:!1}}).attr("class","brush"),T=S.append("svg:g"),E=T.append("svg:g"),R=T.append("svg:g");g.brusher=a.default.svg.brush().x(M).y(w).on("brushstart",function(n){var t=R.selectAll("g.gnode").selectAll(".outline_node");t.each(function(n){n.previouslySelected=O&&n.selected})}).on("brush",function(){var n=R.selectAll("g.gnode").selectAll(".outline_node"),t=a.default.event.target.extent();n.classed("selected",function(n){return n.selected=g.options.applyForce&&n.previouslySelected^(t[0][0]<=n.x&&n.x-1){if(n.source.rna==n.target.rna){var t=n.source.rna;t.addPseudoknots(),t.pairtable[n.source.num]=0,t.pairtable[n.target.num]=0,D(t)}else extraLinkIndex=g.extraLinks.indexOf(n),g.extraLinks.splice(extraLinkIndex,1);g.recalculateGraph()}g.update()}(n))};g.addLink=function(n){n.source.rna==n.target.rna?(r=n.source.rna,r.pairtable[n.source.num]=n.target.num,r.pairtable[n.target.num]=n.source.num,D(r)):(n.linkType="intermolecule",g.extraLinks.push(n)),g.recalculateGraph(),g.update()};var F=function(n){if(!a.default.event.defaultPrevented){if(!O){var t=R.selectAll("g.gnode").selectAll(".outline_node");t.classed("selected",function(n){return n.selected=g.options.applyForce&&(n.previouslySelected=!1)})}a.default.select(this).select("circle").classed("selected",n.selected=g.options.applyForce&&!n.previouslySelected)}},q=function(n){if(b){if((x=n)==b)return void p();var t={source:b,target:x,linkType:"basepair",value:1,uid:generateUUID()};for(i=0;in?-1:n>t?1:n>=t?0:NaN}function s(n){return null===n?NaN:+n}function l(n){return!isNaN(n)}function c(n){return{left:function(t,e,r,o){for(arguments.length<3&&(r=0),arguments.length<4&&(o=t.length);o>r;){var a=r+o>>>1;n(t[a],e)<0?r=a+1:o=a}return r},right:function(t,e,r,o){for(arguments.length<3&&(r=0),arguments.length<4&&(o=t.length);o>r;){var a=r+o>>>1;n(t[a],e)>0?o=a:r=a+1}return r}}}function f(n){return n.length}function p(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function h(){this._=Object.create(null)}function d(n){return(n+="")===da||n[0]===ma?ma+n:n}function m(n){return(n+="")[0]===ma?n.slice(1):n}function v(n){return d(n)in this._}function g(n){return(n=d(n))in this._&&delete this._[n]}function y(){var n=[];for(var t in this._)n.push(m(t));return n}function b(){var n=0;for(var t in this._)++n;return n}function x(){for(var n in this._)return!1;return!0}function M(){this._=Object.create(null)}function w(n){return n}function k(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function _(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=va.length;r>e;++e){var o=va[e]+t;if(o in n)return o}}function S(){}function A(){}function T(n){function t(){for(var t,r=e,o=-1,a=r.length;++oe;e++)for(var o,a=n[e],i=0,u=a.length;u>i;i++)(o=a[i])&&t(o,i,e);return n}function Y(n){return ya(n,_a),n}function W(n,t,e){function r(){var t=this[o];t&&(this.removeEventListener(n,t,t.$),delete this[o])}var o="__on"+n,a=n.indexOf("."),i=Z;a>0&&(n=n.slice(0,a));var u=Sa.get(n);return u&&(n=u,i=J),a?t?function(){var a=i(t,aa(arguments));r.call(this),this.addEventListener(n,this[o]=a,a.$=e),a._=t}:r:t?S:function(){var t,e=new RegExp("^__on([^.]+)"+ra.requote(n)+"$");for(var r in this)if(t=r.match(e)){var o=this[r];this.removeEventListener(t[1],o,o.$),delete this[r]}}}function Z(n,t){return function(e){var r=ra.event;ra.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{ra.event=r}}}function J(n,t){var e=Z(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function $(n){var t=".dragsuppress-"+ ++Ta,e="click"+t,r=ra.select(i(n)).on("touchmove"+t,E).on("dragstart"+t,E).on("selectstart"+t,E);if(null==Aa&&(Aa=!("onselectstart"in n)&&_(n.style,"userSelect")),Aa){var o=a(n).style,u=o[Aa];o[Aa]="none"}return function(n){if(r.on(t,null),Aa&&(o[Aa]=u),n){var a=function(){r.on(e,null)};r.on(e,function(){E(),a()},!0),setTimeout(a,0)}}}function K(n,t){t.changedTouches&&(t=t.changedTouches[0]);var e=n.ownerSVGElement||n;if(e.createSVGPoint){var r=e.createSVGPoint();if(0>Ea){var o=i(n);if(o.scrollX||o.scrollY){var a=(e=ra.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important"))[0][0].getScreenCTM();Ea=!(a.f||a.e),e.remove()}}return Ea?(r.x=t.pageX,r.y=t.pageY):(r.x=t.clientX,r.y=t.clientY),[(r=r.matrixTransform(n.getScreenCTM().inverse())).x,r.y]}var u=n.getBoundingClientRect();return[t.clientX-u.left-n.clientLeft,t.clientY-u.top-n.clientTop]}function Q(){return ra.event.changedTouches[0].identifier}function nn(n){return n>0?1:0>n?-1:0}function tn(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function en(n){return n>1?0:-1>n?Na:Math.acos(n)}function rn(n){return n>1?La:-1>n?-La:Math.asin(n)}function on(n){return((n=Math.exp(n))+1/n)/2}function an(n){return(n=Math.sin(n/2))*n}function un(){}function sn(n,t,e){return this instanceof sn?(this.h=+n,this.s=+t,void(this.l=+e)):arguments.length<2?n instanceof sn?new sn(n.h,n.s,n.l):wn(""+n,kn,sn):new sn(n,t,e)}function ln(n,t,e){function r(n){return Math.round(255*function(n){return n>360?n-=360:0>n&&(n+=360),60>n?o+(a-o)*n/60:180>n?a:240>n?o+(a-o)*(240-n)/60:o}(n))}var o,a;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,o=2*(e=0>e?0:e>1?1:e)-(a=.5>=e?e*(1+t):e+t-e*t),new yn(r(n+120),r(n),r(n-120))}function cn(n,t,e){return this instanceof cn?(this.h=+n,this.c=+t,void(this.l=+e)):arguments.length<2?n instanceof cn?new cn(n.h,n.c,n.l):dn(n instanceof pn?n.l:(n=_n((n=ra.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new cn(n,t,e)}function fn(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new pn(e,Math.cos(n*=Ua)*t,Math.sin(n)*t)}function pn(n,t,e){return this instanceof pn?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof pn?new pn(n.l,n.a,n.b):n instanceof cn?fn(n.h,n.c,n.l):_n((n=yn(n)).r,n.g,n.b):new pn(n,t,e)}function hn(n,t,e){var r=(n+16)/116,o=r+t/500,a=r-e/200;return o=mn(o)*Va,r=mn(r)*Xa,a=mn(a)*Ga,new yn(gn(3.2404542*o-1.5371385*r-.4985314*a),gn(-.969266*o+1.8760108*r+.041556*a),gn(.0556434*o-.2040259*r+1.0572252*a))}function dn(n,t,e){return n>0?new cn(Math.atan2(e,t)*Da,Math.sqrt(t*t+e*e),n):new cn(NaN,NaN,n)}function mn(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function vn(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function gn(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function yn(n,t,e){return this instanceof yn?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof yn?new yn(n.r,n.g,n.b):wn(""+n,yn,ln):new yn(n,t,e)}function bn(n){return new yn(n>>16,n>>8&255,255&n)}function xn(n){return bn(n)+""}function Mn(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function wn(n,t,e){var r,o,a,i=0,u=0,s=0;if(r=/([a-z]+)\((.*)\)/.exec(n=n.toLowerCase()))switch(o=r[2].split(","),r[1]){case"hsl":return e(parseFloat(o[0]),parseFloat(o[1])/100,parseFloat(o[2])/100);case"rgb":return t(An(o[0]),An(o[1]),An(o[2]))}return(a=Za.get(n))?t(a.r,a.g,a.b):(null==n||"#"!==n.charAt(0)||isNaN(a=parseInt(n.slice(1),16))||(4===n.length?(i=(3840&a)>>4,i|=i>>4,u=240&a,u|=u>>4,s=15&a,s|=s<<4):7===n.length&&(i=(16711680&a)>>16,u=(65280&a)>>8,s=255&a)),t(i,u,s))}function kn(n,t,e){var r,o,a=Math.min(n/=255,t/=255,e/=255),i=Math.max(n,t,e),u=i-a,s=(i+a)/2;return u?(o=.5>s?u/(i+a):u/(2-i-a),r=n==i?(t-e)/u+(e>t?6:0):t==i?(e-n)/u+2:(n-t)/u+4,r*=60):(r=NaN,o=s>0&&1>s?0:r),new sn(r,o,s)}function _n(n,t,e){n=Sn(n),t=Sn(t),e=Sn(e);var r=vn((.4124564*n+.3575761*t+.1804375*e)/Va),o=vn((.2126729*n+.7151522*t+.072175*e)/Xa),a=vn((.0193339*n+.119192*t+.9503041*e)/Ga);return pn(116*o-16,500*(r-o),200*(o-a))}function Sn(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function An(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function Tn(n){return"function"==typeof n?n:function(){return n}}function En(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),Rn(t,e,n,r)}}function Rn(n,t,e,r){function o(){var n,t=s.status;if(!t&&function(n){var t=n.responseType;return t&&"text"!==t?n.response:n.responseText}(s)||t>=200&&300>t||304===t){try{n=e.call(a,s)}catch(n){return void i.error.call(a,n)}i.load.call(a,n)}else i.error.call(a,s)}var a={},i=ra.dispatch("beforesend","progress","load","error"),u={},s=new XMLHttpRequest,l=null;return!this.XDomainRequest||"withCredentials"in s||!/^(http(s)?:)?\/\//.test(n)||(s=new XDomainRequest),"onload"in s?s.onload=s.onerror=o:s.onreadystatechange=function(){s.readyState>3&&o()},s.onprogress=function(n){var t=ra.event;ra.event=n;try{i.progress.call(a,s)}finally{ra.event=t}},a.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?u[n]:(null==t?delete u[n]:u[n]=t+"",a)},a.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",a):t},a.responseType=function(n){return arguments.length?(l=n,a):l},a.response=function(n){return e=n,a},["get","post"].forEach(function(n){a[n]=function(){return a.send.apply(a,[n].concat(aa(arguments)))}}),a.send=function(e,r,o){if(2===arguments.length&&"function"==typeof r&&(o=r,r=null),s.open(e,n,!0),null==t||"accept"in u||(u.accept=t+",*/*"),s.setRequestHeader)for(var c in u)s.setRequestHeader(c,u[c]);return null!=t&&s.overrideMimeType&&s.overrideMimeType(t),null!=l&&(s.responseType=l),null!=o&&a.on("error",o).on("load",function(n){o(null,n)}),i.beforesend.call(a,s),s.send(null==r?null:r),a},a.abort=function(){return s.abort(),a},ra.rebind(a,i,"on"),null==r?a:a.get(function(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}(r))}function Pn(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var o=e+t,a={c:n,t:o,n:null};return $a?$a.n=a:Ja=a,$a=a,Ka||(Qa=clearTimeout(Qa),Ka=1,ni(Nn)),a}function Nn(){var n=On(),t=Cn()-n;t>24?(isFinite(t)&&(clearTimeout(Qa),Qa=setTimeout(Nn,t)),Ka=0):(Ka=1,ni(Nn))}function On(){for(var n=Date.now(),t=Ja;t;)n>=t.t&&t.c(n-t.t)&&(t.c=null),t=t.n;return n}function Cn(){for(var n,t=Ja,e=1/0;t;)t.c?(t.t1?Date.UTC.apply(this,arguments):arguments[0])}function zn(n,t,e){function r(t){var e=n(t),r=a(e,1);return r-t>t-e?e:r}function o(e){return t(e=n(new ai(e-1)),1),e}function a(n,e){return t(n=new ai(+n),e),n}function i(n,r,a){var i=o(n),u=[];if(a>1)for(;r>i;)e(i)%a||u.push(new Date(+i)),t(i,1);else for(;r>i;)u.push(new Date(+i)),t(i,1);return u}n.floor=n,n.round=r,n.ceil=o,n.offset=a,n.range=i;var u=n.utc=Fn(n);return u.floor=u,u.round=Fn(r),u.ceil=Fn(o),u.offset=Fn(a),u.range=function(n,t,e){try{ai=Dn;var r=new Dn;return r._=n,i(r,t,e)}finally{ai=Date}},n}function Fn(n){return function(t,e){try{ai=Dn;var r=new Dn;return r._=t,n(r,e)._}finally{ai=Date}}}function qn(n,t,e){var r=0>n?"-":"",o=(r?-n:n)+"",a=o.length;return r+(e>a?new Array(e-a+1).join(t)+o:o)}function jn(n){return new RegExp("^(?:"+n.map(ra.requote).join("|")+")","i")}function Bn(n){for(var t=new h,e=-1,r=n.length;++e68?1900:2e3)}(+r[0]),e+r[0].length):-1}function Yn(n,t,e){return/^[+-]\d{4}$/.test(t=t.slice(e,e+5))?(n.Z=-t,e+5):-1}function Wn(n,t,e){si.lastIndex=0;var r=si.exec(t.slice(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function Zn(n,t,e){si.lastIndex=0;var r=si.exec(t.slice(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function Jn(n,t,e){si.lastIndex=0;var r=si.exec(t.slice(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function $n(n,t,e){si.lastIndex=0;var r=si.exec(t.slice(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function Kn(n,t,e){si.lastIndex=0;var r=si.exec(t.slice(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function Qn(n,t,e){si.lastIndex=0;var r=si.exec(t.slice(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function nt(n,t,e){si.lastIndex=0;var r=si.exec(t.slice(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function tt(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=ha(t)/60|0,o=ha(t)%60;return e+qn(r,"0",2)+qn(o,"0",2)}function et(n,t,e){li.lastIndex=0;var r=li.exec(t.slice(e,e+1));return r?e+r[0].length:-1}function rt(n){for(var t=n.length,e=-1;++e=0?1:-1,u=i*e,s=Math.cos(t),l=Math.sin(t),c=a*l,f=o*s+c*Math.cos(u),p=c*i*Math.sin(u);mi.add(Math.atan2(p,f)),r=n,o=s,a=l}var t,e,r,o,a;vi.point=function(i,u){vi.point=n,r=(t=i)*Ua,o=Math.cos(u=(e=u)*Ua/2+Na/4),a=Math.sin(u)},vi.lineEnd=function(){n(t,e)}}function ct(n){var t=n[0],e=n[1],r=Math.cos(e);return[r*Math.cos(t),r*Math.sin(t),Math.sin(e)]}function ft(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function pt(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function ht(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function dt(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function mt(n){var t=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function vt(n){return[Math.atan2(n[1],n[0]),rn(n[2])]}function gt(n,t){return ha(n[0]-t[0])u;++u)o.point((e=n[u])[0],e[1]);return void o.lineEnd()}var s=new Tt(e,n,null,!0),l=new Tt(e,null,s,!1);s.o=l,a.push(s),i.push(l),s=new Tt(r,n,null,!1),l=new Tt(r,null,s,!0),s.o=l,a.push(s),i.push(l)}}),i.sort(t),At(a),At(i),a.length){for(var u=0,s=e,l=i.length;l>u;++u)i[u].e=s=!s;for(var c,f,p=a[0];;){for(var h=p,d=!0;h.v;)if((h=h.n)===p)return;c=h.z,o.lineStart();do{if(h.v=h.o.v=!0,h.e){if(d)for(var u=0,l=c.length;l>u;++u)o.point((f=c[u])[0],f[1]);else r(h.x,h.n.x,1,o);h=h.n}else{if(d)for(var u=(c=h.p.z).length-1;u>=0;--u)o.point((f=c[u])[0],f[1]);else r(h.x,h.p.x,-1,o);h=h.p}h=h.o,c=h.z,d=!d}while(!h.v);o.lineEnd()}}}function At(n){if(t=n.length){for(var t,e,r=0,o=n[0];++r0){for(M||(a.polygonStart(),M=!0),a.lineStart();++i1&&2&t&&e.push(e.pop().concat(e.shift())),h.push(e.filter(Rt))}var h,d,m,v=t(a),g=o.invert(r[0],r[1]),y={point:i,lineStart:s,lineEnd:l,polygonStart:function(){y.point=c,y.lineStart=f,y.lineEnd=p,h=[],d=[]},polygonEnd:function(){y.point=i,y.lineStart=s,y.lineEnd=l,h=ra.merge(h);var n=function(n,t){var e=n[0],r=n[1],o=[Math.sin(e),-Math.cos(e),0],a=0,i=0;mi.reset();for(var u=0,s=t.length;s>u;++u){var l=t[u],c=l.length;if(c)for(var f=l[0],p=f[0],h=f[1]/2+Na/4,d=Math.sin(h),m=Math.cos(h),v=1;;){v===c&&(v=0);var g=(n=l[v])[0],y=n[1]/2+Na/4,b=Math.sin(y),x=Math.cos(y),M=g-p,w=M>=0?1:-1,k=w*M,_=k>Na,S=d*b;if(mi.add(Math.atan2(S*w*Math.sin(k),m*x+S*Math.cos(k))),a+=_?M+w*Oa:M,_^p>=e^g>=e){var A=pt(ct(f),ct(n));mt(A);var T=pt(o,A);mt(T);var E=(_^M>=0?-1:1)*rn(T[2]);(r>E||r===E&&(A[0]||A[1]))&&(i+=_^M>=0?1:-1)}if(!v++)break;p=g,d=b,m=x,f=n}}return(-Ra>a||Ra>a&&0>mi)^1&i}(g,d);h.length?(M||(a.polygonStart(),M=!0),St(h,Nt,n,e,a)):n&&(M||(a.polygonStart(),M=!0),a.lineStart(),e(null,null,1,a),a.lineEnd()),M&&(a.polygonEnd(),M=!1),h=d=null},sphere:function(){a.polygonStart(),a.lineStart(),e(null,null,1,a),a.lineEnd(),a.polygonEnd()}},b=Pt(),x=t(b),M=!1;return y}}function Rt(n){return n.length>1}function Pt(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:S,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function Nt(n,t){return((n=n.x)[0]<0?n[1]-La-Ra:La-n[1])-((t=t.x)[0]<0?t[1]-La-Ra:La-t[1])}function Ot(n,t,e,r){return function(o){var a,i=o.a,u=o.b,s=i.x,l=i.y,c=u.x,f=u.y,p=0,h=1,d=c-s,m=f-l;if(a=n-s,d||!(a>0)){if(a/=d,0>d){if(p>a)return;h>a&&(h=a)}else if(d>0){if(a>h)return;a>p&&(p=a)}if(a=e-s,d||!(0>a)){if(a/=d,0>d){if(a>h)return;a>p&&(p=a)}else if(d>0){if(p>a)return;h>a&&(h=a)}if(a=t-l,m||!(a>0)){if(a/=m,0>m){if(p>a)return;h>a&&(h=a)}else if(m>0){if(a>h)return;a>p&&(p=a)}if(a=r-l,m||!(0>a)){if(a/=m,0>m){if(a>h)return;a>p&&(p=a)}else if(m>0){if(p>a)return;h>a&&(h=a)}return p>0&&(o.a={x:s+p*d,y:l+p*m}),1>h&&(o.b={x:s+h*d,y:l+h*m}),o}}}}}}function Ct(n,t,e,r){function o(r,o){return ha(r[0]-n)0?0:3:ha(r[0]-e)0?2:1:ha(r[1]-t)0?1:0:o>0?3:2}function a(n,t){return i(n.x,t.x)}function i(n,t){var e=o(n,1),r=o(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}return function(u){function s(a,u,s,l){var c=0,f=0;if(null==a||(c=o(a,s))!==(f=o(u,s))||i(a,u)<0^s>0)do{l.point(0===c||3===c?n:e,c>1?r:t)}while((c=(c+s+4)%4)!==f);else l.point(u[0],u[1])}function l(o,a){return o>=n&&e>=o&&a>=t&&r>=a}function c(n,t){l(n,t)&&u.point(n,t)}function f(n,t){n=Math.max(-Pi,Math.min(Pi,n)),t=Math.max(-Pi,Math.min(Pi,t));var e=l(n,t);if(h&&d.push([n,t]),M)m=n,v=t,g=e,M=!1,e&&(u.lineStart(),u.point(n,t));else if(e&&x)u.point(n,t);else{var r={a:{x:y,y:b},b:{x:n,y:t}};S(r)?(x||(u.lineStart(),u.point(r.a.x,r.a.y)),u.point(r.b.x,r.b.y),e||u.lineEnd(),w=!1):e&&(u.lineStart(),u.point(n,t),w=!1)}y=n,b=t,x=e}var p,h,d,m,v,g,y,b,x,M,w,k=u,_=Pt(),S=Ot(n,t,e,r),A={point:c,lineStart:function(){A.point=f,h&&h.push(d=[]),M=!0,x=!1,y=b=NaN},lineEnd:function(){p&&(f(m,v),g&&x&&_.rejoin(),p.push(_.buffer())),A.point=c,x&&u.lineEnd()},polygonStart:function(){u=_,p=[],h=[],w=!0},polygonEnd:function(){u=k,p=ra.merge(p);var t=function(n){for(var t=0,e=h.length,r=n[1],o=0;e>o;++o)for(var a,i=1,u=h[o],s=u.length,l=u[0];s>i;++i)a=u[i],l[1]<=r?a[1]>r&&tn(l,a,n)>0&&++t:a[1]<=r&&tn(l,a,n)<0&&--t,l=a;return 0!==t}([n,r]),e=w&&t,o=p.length;(e||o)&&(u.polygonStart(),e&&(u.lineStart(),s(null,null,1,u),u.lineEnd()),o&&St(p,a,t,s,u),u.polygonEnd()),p=h=d=null}};return A}}function Lt(n){var t=0,e=Na/3,r=Wt(n),o=r(t,e);return o.parallels=function(n){return arguments.length?r(t=n[0]*Na/180,e=n[1]*Na/180):[t/Na*180,e/Na*180]},o}function Ut(n,t){function e(n,t){var e=Math.sqrt(a-2*o*Math.sin(t))/o;return[e*Math.sin(n*=o),i-e*Math.cos(n)]}var r=Math.sin(n),o=(r+Math.sin(t))/2,a=1+r*(2*o-r),i=Math.sqrt(a)/o;return e.invert=function(n,t){var e=i-t;return[Math.atan2(n,e)/o,rn((a-(n*n+e*e)*o*o)/(2*o))]},e}function Dt(){function n(n,t){Oi+=o*n-r*t,r=n,o=t}var t,e,r,o;zi.point=function(a,i){zi.point=n,t=r=a,e=o=i},zi.lineEnd=function(){n(t,e)}}function zt(){function n(n,t){i.push("M",n,",",t,a)}function t(n,t){i.push("M",n,",",t),u.point=e}function e(n,t){i.push("L",n,",",t)}function r(){u.point=n}function o(){i.push("Z")}var a=Ft(4.5),i=[],u={point:n,lineStart:function(){u.point=t},lineEnd:r,polygonStart:function(){u.lineEnd=o},polygonEnd:function(){u.lineEnd=r,u.point=n},pointRadius:function(n){return a=Ft(n),u},result:function(){if(i.length){var n=i.join("");return i=[],n}}};return u}function Ft(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function qt(n,t){bi+=n,xi+=t,++Mi}function jt(){function n(n,r){var o=n-t,a=r-e,i=Math.sqrt(o*o+a*a);wi+=i*(t+n)/2,ki+=i*(e+r)/2,_i+=i,qt(t=n,e=r)}var t,e;qi.point=function(r,o){qi.point=n,qt(t=r,e=o)}}function Bt(){qi.point=qt}function It(){function n(n,t){var e=n-r,a=t-o,i=Math.sqrt(e*e+a*a);wi+=i*(r+n)/2,ki+=i*(o+t)/2,_i+=i,Si+=(i=o*n-r*t)*(r+n),Ai+=i*(o+t),Ti+=3*i,qt(r=n,o=t)}var t,e,r,o;qi.point=function(a,i){qi.point=n,qt(t=r=a,e=o=i)},qi.lineEnd=function(){n(t,e)}}function Ht(n){function t(t,e){n.moveTo(t+i,e),n.arc(t,e,i,0,Oa)}function e(t,e){n.moveTo(t,e),u.point=r}function r(t,e){n.lineTo(t,e)}function o(){u.point=t}function a(){n.closePath()}var i=4.5,u={point:t,lineStart:function(){u.point=e},lineEnd:o,polygonStart:function(){u.lineEnd=a},polygonEnd:function(){u.lineEnd=o,u.point=t},pointRadius:function(n){return i=n,u},result:S};return u}function Vt(n){function t(n){return(u?r:e)(n)}function e(t){return Gt(t,function(e,r){e=n(e,r),t.point(e[0],e[1])})}function r(t){function e(e,r){e=n(e,r),t.point(e[0],e[1])}function r(){y=NaN,k.point=a,t.lineStart()}function a(e,r){var a=ct([e,r]),i=n(e,r);o(y,b,g,x,M,w,y=i[0],b=i[1],g=e,x=a[0],M=a[1],w=a[2],u,t),t.point(y,b)}function i(){k.point=e,t.lineEnd()}function s(){r(),k.point=l,k.lineEnd=c}function l(n,t){a(f=n,t),p=y,h=b,d=x,m=M,v=w,k.point=a}function c(){o(y,b,g,x,M,w,p,h,f,d,m,v,u,t),k.lineEnd=i,i()}var f,p,h,d,m,v,g,y,b,x,M,w,k={point:e,lineStart:r,lineEnd:i,polygonStart:function(){t.polygonStart(),k.lineStart=s},polygonEnd:function(){t.polygonEnd(),k.lineStart=r}};return k}function o(t,e,r,u,s,l,c,f,p,h,d,m,v,g){var y=c-t,b=f-e,x=y*y+b*b;if(x>4*a&&v--){var M=u+h,w=s+d,k=l+m,_=Math.sqrt(M*M+w*w+k*k),S=Math.asin(k/=_),A=ha(ha(k)-1)a||ha((y*P+b*N)/x-.5)>.3||i>u*h+s*d+l*m)&&(o(t,e,r,u,s,l,E,R,A,M/=_,w/=_,k,v,g),g.point(E,R),o(E,R,A,M,w,k,c,f,p,h,d,m,v,g))}}var a=.5,i=Math.cos(30*Ua),u=16;return t.precision=function(n){return arguments.length?(u=(a=n*n)>0&&16,t):Math.sqrt(a)},t}function Xt(n){this.stream=n}function Gt(n,t){return{point:t,sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function Yt(n){return Wt(function(){return n})()}function Wt(n){function t(n){return[(n=u(n[0]*Ua,n[1]*Ua))[0]*p+s,l-n[1]*p]}function e(n){return(n=u.invert((n[0]-s)/p,(l-n[1])/p))&&[n[0]*Da,n[1]*Da]}function r(){u=kt(i=Kt(g,y,b),a);var n=a(m,v);return s=h-n[0]*p,l=d+n[1]*p,o()}function o(){return c&&(c.valid=!1,c=null),t}var a,i,u,s,l,c,f=Vt(function(n,t){return[(n=a(n,t))[0]*p+s,l-n[1]*p]}),p=150,h=480,d=250,m=0,v=0,g=0,y=0,b=0,x=Ri,M=w,k=null,_=null;return t.stream=function(n){return c&&(c.valid=!1),(c=Zt(x(i,f(M(n))))).valid=!0,c},t.clipAngle=function(n){return arguments.length?(x=null==n?(k=n,Ri):function(n){function t(n,t){return Math.cos(n)*Math.cos(t)>o}function e(n,t,e){var r=ct(n),a=ct(t),i=[1,0,0],u=pt(r,a),s=ft(u,u),l=u[0],c=s-l*l;if(!c)return!e&&n;var f=o*s/c,p=-o*l/c,h=pt(i,u),d=dt(i,f),m=dt(u,p);ht(d,m);var v=h,g=ft(d,v),y=ft(v,v),b=g*g-y*(ft(d,d)-1);if(!(0>b)){var x=Math.sqrt(b),M=dt(v,(-g-x)/y);if(ht(M,d),M=vt(M),!e)return M;var w,k=n[0],_=t[0],S=n[1],A=t[1];k>_&&(w=k,k=_,_=w);var T=_-k,E=ha(T-Na)T;if(!E&&S>A&&(w=S,S=A,A=w),R?E?S+A>0^M[1]<(ha(M[0]-k)Na^(k<=M[0]&&M[0]<=_)){var P=dt(v,(-g+x)/y);return ht(P,d),[M,vt(P)]}}}function r(t,e){var r=a?n:Na-n,o=0;return-r>t?o|=1:t>r&&(o|=2),-r>e?o|=4:e>r&&(o|=8),o}var o=Math.cos(n),a=o>0,i=ha(o)>Ra;return Et(t,function(n){var o,u,s,l,c;return{lineStart:function(){l=s=!1,c=1},point:function(f,p){var h,d=[f,p],m=t(f,p),v=a?m?0:r(f,p):m?r(f+(0>f?Na:-Na),p):0;if(!o&&(l=s=m)&&n.lineStart(),m!==s&&(h=e(o,d),(gt(o,h)||gt(d,h))&&(d[0]+=Ra,d[1]+=Ra,m=t(d[0],d[1]))),m!==s)c=0,m?(n.lineStart(),h=e(d,o),n.point(h[0],h[1])):(h=e(o,d),n.point(h[0],h[1]),n.lineEnd()),o=h;else if(i&&o&&a^m){var g;v&u||!(g=e(d,o,!0))||(c=0,a?(n.lineStart(),n.point(g[0][0],g[0][1]),n.point(g[1][0],g[1][1]),n.lineEnd()):(n.point(g[1][0],g[1][1]),n.lineEnd(),n.lineStart(),n.point(g[0][0],g[0][1])))}!m||o&>(o,d)||n.point(d[0],d[1]),o=d,s=m,u=v},lineEnd:function(){s&&n.lineEnd(),o=null},clean:function(){return c|(l&&s)<<1}}},ee(n,6*Ua),a?[0,-n]:[-Na,n-Na])}((k=+n)*Ua),o()):k},t.clipExtent=function(n){return arguments.length?(_=n,M=n?Ct(n[0][0],n[0][1],n[1][0],n[1][1]):w,o()):_},t.scale=function(n){return arguments.length?(p=+n,r()):p},t.translate=function(n){return arguments.length?(h=+n[0],d=+n[1],r()):[h,d]},t.center=function(n){return arguments.length?(m=n[0]%360*Ua,v=n[1]%360*Ua,r()):[m*Da,v*Da]},t.rotate=function(n){return arguments.length?(g=n[0]%360*Ua,y=n[1]%360*Ua,b=n.length>2?n[2]%360*Ua:0,r()):[g*Da,y*Da,b*Da]},ra.rebind(t,f,"precision"),function(){return a=n.apply(this,arguments),t.invert=a.invert&&e,r()}}function Zt(n){return Gt(n,function(t,e){n.point(t*Ua,e*Ua)})}function Jt(n,t){return[n,t]}function $t(n,t){return[n>Na?n-Oa:-Na>n?n+Oa:n,t]}function Kt(n,t,e){return n?t||e?kt(ne(n),te(t,e)):ne(n):t||e?te(t,e):$t}function Qt(n){return function(t,e){return[(t+=n)>Na?t-Oa:-Na>t?t+Oa:t,e]}}function ne(n){var t=Qt(n);return t.invert=Qt(-n),t}function te(n,t){function e(n,t){var e=Math.cos(t),u=Math.cos(n)*e,s=Math.sin(n)*e,l=Math.sin(t),c=l*r+u*o;return[Math.atan2(s*a-c*i,u*r-l*o),rn(c*a+s*i)]}var r=Math.cos(n),o=Math.sin(n),a=Math.cos(t),i=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),u=Math.cos(n)*e,s=Math.sin(n)*e,l=Math.sin(t),c=l*a-s*i;return[Math.atan2(s*a+l*i,u*r+c*o),rn(c*r-u*o)]},e}function ee(n,t){var e=Math.cos(n),r=Math.sin(n);return function(o,a,i,u){var s=i*t;null!=o?(o=re(e,o),a=re(e,a),(i>0?a>o:o>a)&&(o+=i*Oa)):(o=n+i*Oa,a=n-.5*s);for(var l,c=o;i>0?c>a:a>c;c-=s)u.point((l=vt([e,-r*Math.cos(c),-r*Math.sin(c)]))[0],l[1])}}function re(n,t){var e=ct(t);e[0]-=n,mt(e);var r=en(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Ra)%(2*Math.PI)}function oe(n,t,e){var r=ra.range(n,t-Ra,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function ae(n,t,e){var r=ra.range(n,t-Ra,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function ie(n){return n.source}function ue(n){return n.target}function se(n,t){function e(t,e){var r=Math.cos(t),o=Math.cos(e),a=n(r*o);return[a*o*Math.sin(t),a*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),o=t(r),a=Math.sin(o),i=Math.cos(o);return[Math.atan2(n*a,r*i),Math.asin(r&&e*a/r)]},e}function le(n,t){function e(n,t){i>0?-La+Ra>t&&(t=-La+Ra):t>La-Ra&&(t=La-Ra);var e=i/Math.pow(o(t),a);return[e*Math.sin(a*n),i-e*Math.cos(a*n)]}var r=Math.cos(n),o=function(n){return Math.tan(Na/4+n/2)},a=n===t?Math.sin(n):Math.log(r/Math.cos(t))/Math.log(o(t)/o(n)),i=r*Math.pow(o(n),a)/a;return a?(e.invert=function(n,t){var e=i-t,r=nn(a)*Math.sqrt(n*n+e*e);return[Math.atan2(n,e)/a,2*Math.atan(Math.pow(i/r,1/a))-La]},e):fe}function ce(n,t){function e(n,t){var e=a-t;return[e*Math.sin(o*n),a-e*Math.cos(o*n)]}var r=Math.cos(n),o=n===t?Math.sin(n):(r-Math.cos(t))/(t-n),a=r/o+n;return ha(o)o;o++){for(;r>1&&tn(n[e[r-2]],n[e[r-1]],n[o])<=0;)--r;e[r++]=o}return e.slice(0,r)}function ge(n,t){return n[0]-t[0]||n[1]-t[1]}function ye(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function be(n,t,e,r){var o=n[0],a=e[0],i=t[0]-o,u=r[0]-a,s=n[1],l=e[1],c=t[1]-s,f=r[1]-l,p=(u*(s-l)-f*(o-a))/(f*i-u*c);return[o+p*i,s+p*c]}function xe(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function Me(){je(this),this.edge=this.site=this.circle=null}function we(n){var t=Qi.pop()||new Me;return t.site=n,t}function ke(n){Oe(n),Ji.remove(n),Qi.push(n),je(n)}function _e(n){var t=n.circle,e=t.x,r=t.cy,o={x:e,y:r},a=n.P,i=n.N,u=[n];ke(n);for(var s=a;s.circle&&ha(e-s.circle.x)c;++c)l=u[c],s=u[c-1],ze(l.edge,s.site,l.site,o);s=u[0],(l=u[f-1]).edge=Ue(s.site,l.site,null,o),Ne(s),Ne(l)}function Se(n){for(var t,e,r,o,a=n.x,i=n.y,u=Ji._;u;)if((r=Ae(u,i)-a)>Ra)u=u.L;else{if(!((o=a-Te(u,i))>Ra)){r>-Ra?(t=u.P,e=u):o>-Ra?(t=u,e=u.N):t=e=u;break}if(!u.R){t=u;break}u=u.R}var s=we(n);if(Ji.insert(t,s),t||e){if(t===e)return Oe(t),e=we(t.site),Ji.insert(s,e),s.edge=e.edge=Ue(t.site,s.site),Ne(t),void Ne(e);if(!e)return void(s.edge=Ue(t.site,s.site));Oe(t),Oe(e);var l=t.site,c=l.x,f=l.y,p=n.x-c,h=n.y-f,d=e.site,m=d.x-c,v=d.y-f,g=2*(p*v-h*m),y=p*p+h*h,b=m*m+v*v,x={x:(v*y-h*b)/g+c,y:(p*b-m*y)/g+f};ze(e.edge,l,d,x),s.edge=Ue(l,n,null,x),e.edge=Ue(n,d,null,x),Ne(t),Ne(e)}}function Ae(n,t){var e=n.site,r=e.x,o=e.y,a=o-t;if(!a)return r;var i=n.P;if(!i)return-1/0;var u=(e=i.site).x,s=e.y,l=s-t;if(!l)return u;var c=u-r,f=1/a-1/l,p=c/l;return f?(-p+Math.sqrt(p*p-2*f*(c*c/(-2*l)-s+l/2+o-a/2)))/f+r:(r+u)/2}function Te(n,t){var e=n.N;if(e)return Ae(e,t);var r=n.site;return r.y===t?r.x:1/0}function Ee(n){this.site=n,this.edges=[]}function Re(n,t){return t.angle-n.angle}function Pe(){je(this),this.x=this.y=this.arc=this.site=this.cy=null}function Ne(n){var t=n.P,e=n.N;if(t&&e){var r=t.site,o=n.site,a=e.site;if(r!==a){var i=o.x,u=o.y,s=r.x-i,l=r.y-u,c=a.x-i,f=a.y-u,p=2*(s*f-l*c);if(!(p>=-Pa)){var h=s*s+l*l,d=c*c+f*f,m=(f*h-l*d)/p,v=(s*d-c*h)/p,f=v+u,g=nu.pop()||new Pe;g.arc=n,g.site=o,g.x=m+i,g.y=f+Math.sqrt(m*m+v*v),g.cy=f,n.circle=g;for(var y=null,b=Ki._;b;)if(g.yv||v>=u)return;if(p>d){if(a){if(a.y>=l)return}else a={x:v,y:s};e={x:v,y:l}}else{if(a){if(a.yr||r>1)if(p>d){if(a){if(a.y>=l)return}else a={x:(s-o)/r,y:s};e={x:(l-o)/r,y:l}}else{if(a){if(a.yh){if(a){if(a.x>=u)return}else a={x:i,y:r*i+o};e={x:u,y:r*u+o}}else{if(a){if(a.xi;)c=u[i].end(),r=c.x,o=c.y,l=u[++i%s].start(),t=l.x,e=l.y,(ha(r-t)>Ra||ha(o-e)>Ra)&&(u.splice(i,0,new Fe(De(a.site,c,ha(r-f)Ra?{x:f,y:ha(t-f)Ra?{x:ha(e-d)Ra?{x:p,y:ha(t-p)Ra?{x:ha(e-h)a&&(o=t.slice(a,o),u[i]?u[i]+=o:u[++i]=o),(e=e[0])===(r=r[0])?u[i]?u[i]+=r:u[++i]=r:(u[++i]=null,s.push({i:i,x:$e(e,r)})),a=ru.lastIndex;return ar;++r)u[(e=s[r]).i]=e.x(n);return u.join("")})}function Qe(n,t){for(var e,r=ra.interpolators.length;--r>=0&&!(e=ra.interpolators[r](n,t)););return e}function nr(n,t){var e,r=[],o=[],a=n.length,i=t.length,u=Math.min(n.length,t.length);for(e=0;u>e;++e)r.push(Qe(n[e],t[e]));for(;a>e;++e)o[e]=n[e];for(;i>e;++e)o[e]=t[e];return function(n){for(e=0;u>e;++e)o[e]=r[e](n);return o}}function tr(n){return function(t){return 1-n(1-t)}}function er(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function rr(n){return n*n}function or(n){return n*n*n}function ar(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function ir(n){return 1-Math.cos(n*La)}function ur(n){return Math.pow(2,10*(n-1))}function sr(n){return 1-Math.sqrt(1-n*n)}function lr(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function cr(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function fr(n){var t=[n.a,n.b],e=[n.c,n.d],r=hr(t),o=pr(t,e),a=hr(function(n,t,e){return n[0]+=e*t[0],n[1]+=e*t[1],n}(e,t,-o))||0;t[0]*e[1]180?t+=360:t-n>180&&(n+=360),r.push({i:e.push(dr(e)+"rotate(",null,")")-2,x:$e(n,t)})):t&&e.push(dr(e)+"rotate("+t+")")}(n.rotate,t.rotate,e,r),function(n,t,e,r){n!==t?r.push({i:e.push(dr(e)+"skewX(",null,")")-2,x:$e(n,t)}):t&&e.push(dr(e)+"skewX("+t+")")}(n.skew,t.skew,e,r),function(n,t,e,r){if(n[0]!==t[0]||n[1]!==t[1]){var o=e.push(dr(e)+"scale(",null,",",null,")");r.push({i:o-4,x:$e(n[0],t[0])},{i:o-2,x:$e(n[1],t[1])})}else(1!==t[0]||1!==t[1])&&e.push(dr(e)+"scale("+t+")")}(n.scale,t.scale,e,r),n=t=null,function(n){for(var t,o=-1,a=r.length;++o=0;)e.push(o[r])}function Ar(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(a=n.children)&&(o=a.length))for(var o,a,i=-1;++ie;++e)(t=n[e][1])>o&&(r=e,o=t);return r}function zr(n){return n.reduce(Fr,0)}function Fr(n,t){return n+t[1]}function qr(n,t){return jr(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function jr(n,t){for(var e=-1,r=+n[0],o=(n[1]-r)/t,a=[];++e<=t;)a[e]=o*e+r;return a}function Br(n){return[ra.min(n),ra.max(n)]}function Ir(n,t){return n.value-t.value}function Hr(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function Vr(n,t){n._pack_next=t,t._pack_prev=n}function Xr(n,t){var e=t.x-n.x,r=t.y-n.y,o=n.r+t.r;return.999*o*o>e*e+r*r}function Gr(n){function t(n){c=Math.min(n.x-n.r,c),f=Math.max(n.x+n.r,f),p=Math.min(n.y-n.r,p),h=Math.max(n.y+n.r,h)}if((e=n.children)&&(l=e.length)){var e,r,o,a,i,u,s,l,c=1/0,f=-1/0,p=1/0,h=-1/0;if(e.forEach(Yr),(r=e[0]).x=-r.r,r.y=0,t(r),l>1&&((o=e[1]).x=o.r,o.y=0,t(o),l>2))for(a=e[2],Zr(r,o,a),t(a),Hr(r,a),r._pack_prev=a,Hr(a,o),o=r._pack_next,i=3;l>i;i++){Zr(r,o,a=e[i]);var d=0,m=1,v=1;for(u=o._pack_next;u!==o;u=u._pack_next,m++)if(Xr(u,a)){d=1;break}if(1==d)for(s=r._pack_prev;s!==u._pack_prev&&!Xr(s,a);s=s._pack_prev,v++);d?(v>m||m==v&&o.ri;i++)(a=e[i]).x-=g,a.y-=y,b=Math.max(b,a.r+Math.sqrt(a.x*a.x+a.y*a.y));n.r=b,e.forEach(Wr)}}function Yr(n){n._pack_next=n._pack_prev=n}function Wr(n){delete n._pack_next,delete n._pack_prev}function Zr(n,t,e){var r=n.r+e.r,o=t.x-n.x,a=t.y-n.y;if(r&&(o||a)){var i=t.r+e.r,u=o*o+a*a,s=.5+((r*=r)-(i*=i))/(2*u),l=Math.sqrt(Math.max(0,2*i*(r+u)-(r-=u)*r-i*i))/(2*u);e.x=n.x+s*o+l*a,e.y=n.y+s*a-l*o}else e.x=n.x+r,e.y=n.y}function Jr(n,t){return n.parent==t.parent?1:2}function $r(n){var t=n.children;return t.length?t[0]:n.t}function Kr(n){var t,e=n.children;return(t=e.length)?e[t-1]:n.t}function Qr(n,t,e){var r=e/(t.i-n.i);t.c-=r,t.s+=e,n.c+=r,t.z+=e,t.m+=e}function no(n,t,e){return n.a.parent===t.parent?n.a:e}function to(n){return{x:n.x,y:n.y,dx:n.dx,dy:n.dy}}function eo(n,t){var e=n.x+t[3],r=n.y+t[0],o=n.dx-t[1]-t[3],a=n.dy-t[0]-t[2];return 0>o&&(e+=o/2,o=0),0>a&&(r+=a/2,a=0),{x:e,y:r,dx:o,dy:a}}function ro(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function oo(n){return n.rangeExtent?n.rangeExtent():ro(n.range())}function ao(n,t,e,r){var o=e(n[0],n[1]),a=r(t[0],t[1]);return function(n){return a(o(n))}}function io(n,t){var e,r=0,o=n.length-1,a=n[r],i=n[o];return a>i&&(e=r,r=o,o=e,e=a,a=i,i=e),n[r]=t.floor(a),n[o]=t.ceil(i),n}function uo(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:du}function so(n,t,e,r){var o=[],a=[],i=0,u=Math.min(n.length,t.length)-1;for(n[u]=a?o*=10:.35>=a?o*=5:.75>=a&&(o*=2),e[0]=Math.ceil(e[0]/o)*o,e[1]=Math.floor(e[1]/o)*o+.5*o,e[2]=o,e}function po(n,t){return ra.range.apply(ra,fo(n,t))}function ho(n,t,e){var r=fo(n,t);if(e){var o=ei.exec(e);if(o.shift(),"s"===o[8]){var a=ra.formatPrefix(Math.max(ha(r[0]),ha(r[1])));return o[7]||(o[7]="."+mo(a.scale(r[2]))),o[8]="f",e=ra.format(o.join("")),function(n){return e(a.scale(n))+a.symbol}}o[7]||(o[7]="."+function(n,t){var e=mo(t[2]);return n in mu?Math.abs(e-mo(Math.max(ha(t[0]),ha(t[1]))))+ +("e"!==n):e-2*("%"===n)}(o[8],r)),e=o.join("")}else e=",."+mo(r[2])+"f";return ra.format(e)}function mo(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function vo(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function go(){return 0}function yo(n){return n.innerRadius}function bo(n){return n.outerRadius}function xo(n){return n.startAngle}function Mo(n){return n.endAngle}function wo(n){return n&&n.padAngle}function ko(n,t,e,r){return(n-e)*t-(t-r)*n>0?0:1}function _o(n,t,e,r,o){var a=n[0]-t[0],i=n[1]-t[1],u=(o?r:-r)/Math.sqrt(a*a+i*i),s=u*i,l=-u*a,c=n[0]+s,f=n[1]+l,p=t[0]+s,h=t[1]+l,d=(c+p)/2,m=(f+h)/2,v=p-c,g=h-f,y=v*v+g*g,b=e-r,x=c*h-p*f,M=(0>g?-1:1)*Math.sqrt(Math.max(0,b*b*y-x*x)),w=(x*g-v*M)/y,k=(-x*v-g*M)/y,_=(x*g+v*M)/y,S=(-x*v+g*M)/y,A=w-d,T=k-m,E=_-d,R=S-m;return A*A+T*T>E*E+R*R&&(w=_,k=S),[[w-s,k-l],[w*e/b,k*e/b]]}function So(n){function t(t){function i(){l.push("M",a(n(c),u))}for(var s,l=[],c=[],f=-1,p=t.length,h=Tn(e),d=Tn(r);++f1?n.join("L"):n+"Z"}function To(n){return n.join("L")+"Z"}function Eo(n){for(var t=0,e=n.length,r=n[0],o=[r[0],",",r[1]];++t1){u=t[1],a=n[s],s++,r+="C"+(o[0]+i[0])+","+(o[1]+i[1])+","+(a[0]-u[0])+","+(a[1]-u[1])+","+a[0]+","+a[1];for(var l=2;l9&&(o=3*t/Math.sqrt(o),i[u]=o*e,i[u+1]=o*r));for(u=-1;++u<=s;)o=(n[Math.min(s,u+1)][0]-n[Math.max(0,u-1)][0])/(6*(1+i[u]*i[u])),a.push([o||0,i[u]*o||0]);return a}function zo(n){for(var t,e,r,o=-1,a=n.length;++o+h){var m=p[h];m.timer.c=null,m.timer.t=NaN,--p.count,delete p[h]}s.c=i,Pn(function(){return s.c&&i(e||1)&&(s.c=null,s.t=NaN),1},0,u),p.active=r,d.event&&d.event.start.call(n,n.__data__,t),f=[],d.tween.forEach(function(e,r){(r=r.call(n,n.__data__,t))&&f.push(r)}),c=d.ease,l=d.duration}function i(o){for(var a=o/l,i=c(a),u=f.length;u>0;)f[--u].call(n,i);return a>=1?(d.event&&d.event.end.call(n,n.__data__,t),--p.count?delete p[r]:delete n[e],1):void 0}var u,s,l,c,f,p=n[e]||(n[e]={active:0,count:0}),d=p[r];d||(u=o.time,s=Pn(function(n){var t=d.delay;return s.t=t+u,n>=t?a(n-t):void(s.c=a)},0,u),d=p[r]={tween:new h,time:u,timer:s,delay:o.delay,duration:o.duration,ease:o.ease,index:t},o=null,++p.count)}function Jo(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate("+(isFinite(r)?r:e(n))+",0)"})}function $o(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate(0,"+(isFinite(r)?r:e(n))+")"})}function Ko(n){return n.toISOString()}function Qo(n,t,e){function r(t){return n(t)}function o(n,e){var r=n[1]-n[0],o=r/e,a=ra.bisect(Iu,o);return a==Iu.length?[t.year,fo(n.map(function(n){return n/31536e6}),e)[2]]:a?t[o/Iu[a-1]1?{floor:function(t){for(;e(t=n.floor(t));)t=na(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=na(+t+1);return t}}:n))},r.ticks=function(n,t){var e=ro(r.domain()),a=null==n?o(e,10):"number"==typeof n?o(e,n):!n.range&&[{range:n},t];return a&&(n=a[0],t=a[1]),n.range(e[0],na(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return Qo(n.copy(),t,e)},lo(r,n)}function na(n){return new Date(n)}function ta(n){return JSON.parse(n.responseText)}function ea(n){var t=ia.createRange();return t.selectNode(ia.body),t.createContextualFragment(n.responseText)}var ra={version:"3.5.13"},oa=[].slice,aa=function(n){return oa.call(n)},ia=this.document;if(ia)try{aa(ia.documentElement.childNodes)[0].nodeType}catch(n){aa=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}if(Date.now||(Date.now=function(){return+new Date}),ia)try{ia.createElement("DIV").style.setProperty("opacity",0,"")}catch(n){var ua=this.Element.prototype,sa=ua.setAttribute,la=ua.setAttributeNS,ca=this.CSSStyleDeclaration.prototype,fa=ca.setProperty;ua.setAttribute=function(n,t){sa.call(this,n,t+"")},ua.setAttributeNS=function(n,t,e){la.call(this,n,t,e+"")},ca.setProperty=function(n,t,e){fa.call(this,n,t+"",e)}}ra.ascending=u,ra.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:NaN},ra.min=function(n,t){var e,r,o=-1,a=n.length;if(1===arguments.length){for(;++o=r){e=r;break}for(;++or&&(e=r)}else{for(;++o=r){e=r;break}for(;++or&&(e=r)}return e},ra.max=function(n,t){var e,r,o=-1,a=n.length;if(1===arguments.length){for(;++o=r){e=r;break}for(;++oe&&(e=r)}else{for(;++o=r){e=r;break}for(;++oe&&(e=r)}return e},ra.extent=function(n,t){var e,r,o,a=-1,i=n.length;if(1===arguments.length){for(;++a=r){e=o=r;break}for(;++ar&&(e=r),r>o&&(o=r))}else{for(;++a=r){e=o=r;break}for(;++ar&&(e=r),r>o&&(o=r))}return[e,o]},ra.sum=function(n,t){var e,r=0,o=n.length,a=-1;if(1===arguments.length)for(;++a1?i/(c-1):void 0},ra.deviation=function(){var n=ra.variance.apply(this,arguments);return n?Math.sqrt(n):n};var pa=c(u);ra.bisectLeft=pa.left,ra.bisect=ra.bisectRight=pa.right,ra.bisector=function(n){return c(1===n.length?function(t,e){return u(n(t),e)}:n)},ra.shuffle=function(n,t,e){(a=arguments.length)<3&&(e=n.length,2>a&&(t=0));for(var r,o,a=e-t;a;)o=Math.random()*a--|0,r=n[a+t],n[a+t]=n[o+t],n[o+t]=r;return n},ra.permute=function(n,t){for(var e=t.length,r=new Array(e);e--;)r[e]=n[t[e]];return r},ra.pairs=function(n){for(var t=0,e=n.length-1,r=n[0],o=new Array(0>e?0:e);e>t;)o[t]=[r,r=n[++t]];return o},ra.zip=function(){if(!(r=arguments.length))return[];for(var n=-1,t=ra.min(arguments,f),e=new Array(t);++n=0;)for(r=n[o],t=r.length;--t>=0;)e[--i]=r[t];return e};var ha=Math.abs;ra.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),(t-n)/e==1/0)throw new Error("infinite range");var r,o=[],a=function(n){for(var t=1;n*t%1;)t*=10;return t}(ha(e)),i=-1;if(n*=a,t*=a,0>(e*=a))for(;(r=n+e*++i)>t;)o.push(r/a);else for(;(r=n+e*++i)=o.length)return e?e.call(r,i):t?i.sort(t):i;for(var s,l,c,f,p=-1,d=i.length,m=o[u++],v=new h;++p=o.length)return t;var r=[],i=a[e++];return t.forEach(function(t,o){r.push({key:t,values:n(o,e)})}),i?r.sort(function(n,t){return i(n.key,t.key)}):r}(n(ra.map,t,0),0)},r.key=function(n){return o.push(n),r},r.sortKeys=function(n){return a[o.length-1]=n,r},r.sortValues=function(n){return t=n,r},r.rollup=function(n){return e=n,r},r},ra.set=function(n){var t=new M;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},p(M,{has:v,add:function(n){return this._[d(n+="")]=!0,n},remove:g,values:y,size:b,empty:x,forEach:function(n){for(var t in this._)n.call(this,m(t))}}),ra.behavior={},ra.rebind=function(n,t){for(var e,r=1,o=arguments.length;++r=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},ra.event=null,ra.requote=function(n){return n.replace(ga,"\\$&")};var ga=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,ya={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},ba=function(n,t){return t.querySelector(n)},xa=function(n,t){return t.querySelectorAll(n)},Ma=function(n,t){var e=n.matches||n[_(n,"matchesSelector")];return(Ma=function(n,t){return e.call(n,t)})(n,t)};"function"==typeof Sizzle&&(ba=function(n,t){return Sizzle(n,t)[0]||null},xa=Sizzle,Ma=Sizzle.matchesSelector),ra.selection=function(){return ra.select(ia.documentElement)};var wa=ra.selection.prototype=[];wa.select=function(n){var t,e,r,o,a=[];n=O(n);for(var i=-1,u=this.length;++i=0&&"xmlns"!==(e=n.slice(0,t))&&(n=n.slice(t+1)),ka.hasOwnProperty(e)?{space:ka[e],local:n}:n}},wa.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return(n=ra.ns.qualify(n)).local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(L(t,n[t]));return this}return this.each(L(n,t))},wa.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=z(n)).length,o=-1;if(t=e.classList){for(;++or){if("string"!=typeof n){for(e in 2>r&&(t=""),n)this.each(j(e,n[e],t));return this}if(2>r){var o=this.node();return i(o).getComputedStyle(o,null).getPropertyValue(n)}e=""}return this.each(j(n,t,e))},wa.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(B(t,n[t]));return this}return this.each(B(n,t))},wa.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},wa.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},wa.append=function(n){return n=I(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},wa.insert=function(n,t){return n=I(n),t=O(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},wa.remove=function(){return this.each(H)},wa.data=function(n,t){function e(n,e){var r,o,a,i=n.length,c=e.length,f=Math.min(i,c),p=new Array(c),d=new Array(c),m=new Array(i);if(t){var v,g=new h,y=new Array(i);for(r=-1;++rr;++r)d[r]=V(e[r]);for(;i>r;++r)m[r]=n[r]}d.update=p,d.parentNode=p.parentNode=m.parentNode=n.parentNode,u.push(d),s.push(p),l.push(m)}var r,o,a=-1,i=this.length;if(!arguments.length){for(n=new Array(i=(r=this[0]).length);++aa;a++){o.push(t=[]),t.parentNode=(e=this[a]).parentNode;for(var u=0,s=e.length;s>u;u++)(r=e[u])&&n.call(r,r.__data__,u,a)&&t.push(r)}return N(o)},wa.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[o])&&(a&&a!==e.nextSibling&&a.parentNode.insertBefore(e,a),a=e);return this},wa.sort=function(n){n=function(n){return arguments.length||(n=u),function(t,e){return t&&e?n(t.__data__,e.__data__):!t-!e}}.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,o=e.length;o>r;r++){var a=e[r];if(a)return a}return null},wa.size=function(){var n=0;return G(this,function(){++n}),n};var _a=[];ra.selection.enter=Y,ra.selection.enter.prototype=_a,_a.append=wa.append,_a.empty=wa.empty,_a.node=wa.node,_a.call=wa.call,_a.size=wa.size,_a.select=function(n){for(var t,e,r,o,a,i=[],u=-1,s=this.length;++u=t&&(t=o+1);!(i=u[t])&&++tr){if("string"!=typeof n){for(e in 2>r&&(t=!1),n)this.each(W(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(W(n,t,e))};var Sa=ra.map({mouseenter:"mouseover",mouseleave:"mouseout"});ia&&Sa.forEach(function(n){"on"+n in ia&&Sa.remove(n)});var Aa,Ta=0;ra.mouse=function(n){return K(n,R())};var Ea=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;ra.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=R().changedTouches),t)for(var r,o=0,a=t.length;a>o;++o)if((r=t[o]).identifier===e)return K(n,r)},ra.behavior.drag=function(){function n(){this.on("mousedown.drag",o).on("touchstart.drag",a)}function t(n,t,o,a,i){return function(){var u,s=this,l=ra.event.target,c=s.parentNode,f=e.of(s,arguments),p=0,h=n(),d=".drag"+(null==h?"":"-"+h),m=ra.select(o(l)).on(a+d,function(){var n,e,r=t(c,h);r&&(n=r[0]-g[0],e=r[1]-g[1],p|=n|e,g=r,f({type:"drag",x:r[0]+u[0],y:r[1]+u[1],dx:n,dy:e}))}).on(i+d,function(){t(c,h)&&(m.on(a+d,null).on(i+d,null),v(p),f({type:"dragend"}))}),v=$(l),g=t(c,h);u=r?[(u=r.apply(s,arguments)).x-g[0],u.y-g[1]]:[0,0],f({type:"dragstart"})}}var e=P(n,"drag","dragstart","dragend"),r=null,o=t(S,ra.mouse,i,"mousemove","mouseup"),a=t(Q,ra.touch,w,"touchmove","touchend");return n.origin=function(t){return arguments.length?(r=t,n):r},ra.rebind(n,e,"on")},ra.touches=function(n,t){return arguments.length<2&&(t=R().touches),t?aa(t).map(function(t){var e=K(n,t);return e.identifier=t.identifier,e}):[]};var Ra=1e-6,Pa=Ra*Ra,Na=Math.PI,Oa=2*Na,Ca=Oa-Ra,La=Na/2,Ua=Na/180,Da=180/Na,za=Math.SQRT2;ra.interpolateZoom=function(n,t){var e,r,o=n[0],a=n[1],i=n[2],u=t[0],s=t[1],l=t[2],c=u-o,f=s-a,p=c*c+f*f;if(Pa>p)r=Math.log(l/i)/za,e=function(n){return[o+n*c,a+n*f,i*Math.exp(za*n*r)]};else{var h=Math.sqrt(p),d=(l*l-i*i+4*p)/(2*i*2*h),m=(l*l-i*i-4*p)/(2*l*2*h),v=Math.log(Math.sqrt(d*d+1)-d),g=Math.log(Math.sqrt(m*m+1)-m);r=(g-v)/za,e=function(n){var t=n*r,e=on(v),u=i/(2*h)*(e*function(n){return((n=Math.exp(2*n))-1)/(n+1)}(za*t+v)-function(n){return((n=Math.exp(n))-1/n)/2}(v));return[o+u*c,a+u*f,i*e/on(za*t+v)]}}return e.duration=1e3*r,e},ra.behavior.zoom=function(){function n(n){n.on(R,c).on(qa+".zoom",p).on("dblclick.zoom",h).on(C,f)}function t(n){return[(n[0]-k.x)/k.k,(n[1]-k.y)/k.k]}function e(n){k.k=Math.max(S[0],Math.min(S[1],n))}function r(n,t){t=function(n){return[n[0]*k.k+k.x,n[1]*k.k+k.y]}(t),k.x+=n[0]-t[0],k.y+=n[1]-t[1]}function o(t,o,a,i){t.__chart__={x:k.x,y:k.y,k:k.k},e(Math.pow(2,i)),r(m=o,a),t=ra.select(t),A>0&&(t=t.transition().duration(A)),t.call(n.event)}function a(){x&&x.domain(b.range().map(function(n){return(n-k.x)/k.k}).map(b.invert)),w&&w.domain(M.range().map(function(n){return(n-k.y)/k.k}).map(M.invert))}function u(n){T++||n({type:"zoomstart"})}function s(n){a(),n({type:"zoom",scale:k.k,translate:[k.x,k.y]})}function l(n){--T||(n({type:"zoomend"}),m=null)}function c(){var n=this,e=L.of(n,arguments),o=0,a=ra.select(i(n)).on(N,function(){o=1,r(ra.mouse(n),c),s(e)}).on(O,function(){a.on(N,null).on(O,null),f(o),l(e)}),c=t(ra.mouse(n)),f=$(n);Ou.call(n),u(e)}function f(){function n(){var n=ra.touches(d);return h=k.k,n.forEach(function(n){n.identifier in v&&(v[n.identifier]=t(n))}),n}function a(){var t=ra.event.target;ra.select(t).on(x,i).on(M,p),w.push(t);for(var e=ra.event.changedTouches,r=0,a=e.length;a>r;++r)v[e[r].identifier]=null;var u=n(),s=Date.now();if(1===u.length){if(500>s-y){var l=u[0];o(d,l,v[l.identifier],Math.floor(Math.log(k.k)/Math.LN2)+1),E()}y=s}else if(u.length>1){var l=u[0],c=u[1],f=l[0]-c[0],h=l[1]-c[1];g=f*f+h*h}}function i(){var n,t,o,a,i=ra.touches(d);Ou.call(d);for(var u=0,l=i.length;l>u;++u,a=null)if(o=i[u],a=v[o.identifier]){if(t)break;n=o,t=a}if(a){var c=(c=o[0]-n[0])*c+(c=o[1]-n[1])*c,f=g&&Math.sqrt(c/g);n=[(n[0]+o[0])/2,(n[1]+o[1])/2],t=[(t[0]+a[0])/2,(t[1]+a[1])/2],e(f*h)}y=null,r(n,t),s(m)}function p(){if(ra.event.touches.length){for(var t=ra.event.changedTouches,e=0,r=t.length;r>e;++e)delete v[t[e].identifier];for(var o in v)return void n()}ra.selectAll(w).on(b,null),_.on(R,c).on(C,f),S(),l(m)}var h,d=this,m=L.of(d,arguments),v={},g=0,b=".zoom-"+ra.event.changedTouches[0].identifier,x="touchmove"+b,M="touchend"+b,w=[],_=ra.select(d),S=$(d);a(),u(m),_.on(R,null).on(C,a)}function p(){var n=L.of(this,arguments);g?clearTimeout(g):(Ou.call(this),d=t(m=v||ra.mouse(this)),u(n)),g=setTimeout(function(){g=null,l(n)},50),E(),e(Math.pow(2,.002*Fa())*k.k),r(m,d),s(n)}function h(){var n=ra.mouse(this),e=Math.log(k.k)/Math.LN2;o(this,n,t(n),ra.event.shiftKey?Math.ceil(e)-1:Math.floor(e)+1)}var d,m,v,g,y,b,x,M,w,k={x:0,y:0,k:1},_=[960,500],S=ja,A=250,T=0,R="mousedown.zoom",N="mousemove.zoom",O="mouseup.zoom",C="touchstart.zoom",L=P(n,"zoomstart","zoom","zoomend");return qa||(qa="onwheel"in ia?(Fa=function(){return-ra.event.deltaY*(ra.event.deltaMode?120:1)},"wheel"):"onmousewheel"in ia?(Fa=function(){return ra.event.wheelDelta},"mousewheel"):(Fa=function(){return-ra.event.detail},"MozMousePixelScroll")),n.event=function(n){n.each(function(){var n=L.of(this,arguments),t=k;Pu?ra.select(this).transition().each("start.zoom",function(){k=this.__chart__||{x:0,y:0,k:1},u(n)}).tween("zoom:zoom",function(){var e=_[0],r=_[1],o=m?m[0]:e/2,a=m?m[1]:r/2,i=ra.interpolateZoom([(o-k.x)/k.k,(a-k.y)/k.k,e/k.k],[(o-t.x)/t.k,(a-t.y)/t.k,e/t.k]);return function(t){var r=i(t),u=e/r[2];this.__chart__=k={x:o-r[0]*u,y:a-r[1]*u,k:u},s(n)}}).each("interrupt.zoom",function(){l(n)}).each("end.zoom",function(){l(n)}):(this.__chart__=k,u(n),s(n),l(n))})},n.translate=function(t){return arguments.length?(k={x:+t[0],y:+t[1],k:k.k},a(),n):[k.x,k.y]},n.scale=function(t){return arguments.length?(k={x:k.x,y:k.y,k:null},e(+t),a(),n):k.k},n.scaleExtent=function(t){return arguments.length?(S=null==t?ja:[+t[0],+t[1]],n):S},n.center=function(t){return arguments.length?(v=t&&[+t[0],+t[1]],n):v},n.size=function(t){return arguments.length?(_=t&&[+t[0],+t[1]],n):_},n.duration=function(t){return arguments.length?(A=+t,n):A},n.x=function(t){return arguments.length?(x=t,b=t.copy(),k={x:0,y:0,k:1},n):x},n.y=function(t){return arguments.length?(w=t,M=t.copy(),k={x:0,y:0,k:1},n):w},ra.rebind(n,L,"on")};var Fa,qa,ja=[0,1/0];ra.color=un,un.prototype.toString=function(){return this.rgb()+""},ra.hsl=sn;var Ba=sn.prototype=new un;Ba.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new sn(this.h,this.s,this.l/n)},Ba.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new sn(this.h,this.s,n*this.l)},Ba.rgb=function(){return ln(this.h,this.s,this.l)},ra.hcl=cn;var Ia=cn.prototype=new un;Ia.brighter=function(n){return new cn(this.h,this.c,Math.min(100,this.l+Ha*(arguments.length?n:1)))},Ia.darker=function(n){return new cn(this.h,this.c,Math.max(0,this.l-Ha*(arguments.length?n:1)))},Ia.rgb=function(){return fn(this.h,this.c,this.l).rgb()},ra.lab=pn;var Ha=18,Va=.95047,Xa=1,Ga=1.08883,Ya=pn.prototype=new un;Ya.brighter=function(n){return new pn(Math.min(100,this.l+Ha*(arguments.length?n:1)),this.a,this.b)},Ya.darker=function(n){return new pn(Math.max(0,this.l-Ha*(arguments.length?n:1)),this.a,this.b)},Ya.rgb=function(){return hn(this.l,this.a,this.b)},ra.rgb=yn;var Wa=yn.prototype=new un;Wa.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,o=30;return t||e||r?(t&&o>t&&(t=o),e&&o>e&&(e=o),r&&o>r&&(r=o),new yn(Math.min(255,t/n),Math.min(255,e/n),Math.min(255,r/n))):new yn(o,o,o)},Wa.darker=function(n){return new yn((n=Math.pow(.7,arguments.length?n:1))*this.r,n*this.g,n*this.b)},Wa.hsl=function(){return kn(this.r,this.g,this.b)},Wa.toString=function(){return"#"+Mn(this.r)+Mn(this.g)+Mn(this.b)};var Za=ra.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});Za.forEach(function(n,t){Za.set(n,bn(t))}),ra.functor=Tn,ra.xhr=En(w),ra.dsv=function(n,t){function e(n,e,a){arguments.length<3&&(a=e,e=null);var i=Rn(n,t,null==e?r:o(e),a);return i.row=function(n){return arguments.length?i.response(null==(e=n)?r:o(n)):e},i}function r(n){return e.parse(n.responseText)}function o(n){return function(t){return e.parse(t.responseText,n)}}function a(t){return t.map(i).join(n)}function i(n){return u.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var u=new RegExp('["'+n+"\n]"),s=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var o=new Function("d","return {"+n.map(function(n,t){return JSON.stringify(n)+": d["+t+"]"}).join(",")+"}");r=t?function(n,e){return t(o(n),e)}:o})},e.parseRows=function(n,t){function e(){if(c>=l)return i;if(o)return o=!1,a;var t=c;if(34===n.charCodeAt(t)){for(var e=t;e++c;){var r=n.charCodeAt(c++),u=1;if(10===r)o=!0;else if(13===r)o=!0,10===n.charCodeAt(c)&&(++c,++u);else if(r!==s)continue;return n.slice(t,c-u)}return n.slice(t)}for(var r,o,a={},i={},u=[],l=n.length,c=0,f=0;(r=e())!==i;){for(var p=[];r!==a&&r!==i;)p.push(r),r=e();t&&null==(p=t(p,f++))||u.push(p)}return u},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new M,o=[];return t.forEach(function(n){for(var t in n)r.has(t)||o.push(r.add(t))}),[o.map(i).join(n)].concat(t.map(function(t){return o.map(function(n){return i(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(a).join("\n")},e},ra.csv=ra.dsv(",","text/csv"),ra.tsv=ra.dsv("\t","text/tab-separated-values");var Ja,$a,Ka,Qa,ni=this[_(this,"requestAnimationFrame")]||function(n){setTimeout(n,17)};ra.timer=function(){Pn.apply(this,arguments)},ra.timer.flush=function(){On(),Cn()},ra.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)};var ti=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"].map(function(n,t){var e=Math.pow(10,3*ha(8-t));return{scale:t>8?function(n){return n/e}:function(n){return n*e},symbol:n}});ra.formatPrefix=function(n,t){var e=0;return(n=+n)&&(0>n&&(n*=-1),t&&(n=ra.round(n,Ln(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),ti[8+e/3]};var ei=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,ri=ra.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=ra.round(n,Ln(n,t))).toFixed(Math.max(0,Math.min(20,Ln(n*(1+1e-15),t))))}}),oi=ra.time={},ai=Date;Dn.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){ii.setUTCDate.apply(this._,arguments)},setDay:function(){ii.setUTCDay.apply(this._,arguments)},setFullYear:function(){ii.setUTCFullYear.apply(this._,arguments)},setHours:function(){ii.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){ii.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){ii.setUTCMinutes.apply(this._,arguments)},setMonth:function(){ii.setUTCMonth.apply(this._,arguments)},setSeconds:function(){ii.setUTCSeconds.apply(this._,arguments)},setTime:function(){ii.setTime.apply(this._,arguments)}};var ii=Date.prototype;oi.year=zn(function(n){return(n=oi.day(n)).setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),oi.years=oi.year.range,oi.years.utc=oi.year.utc.range,oi.day=zn(function(n){var t=new ai(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),oi.days=oi.day.range,oi.days.utc=oi.day.utc.range,oi.dayOfYear=function(n){var t=oi.year(n);return Math.floor((n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(n,t){t=7-t;var e=oi[n]=zn(function(n){return(n=oi.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+7*Math.floor(t))},function(n){var e=oi.year(n).getDay();return Math.floor((oi.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});oi[n+"s"]=e.range,oi[n+"s"].utc=e.utc.range,oi[n+"OfYear"]=function(n){var e=oi.year(n).getDay();return Math.floor((oi.dayOfYear(n)+(e+t)%7)/7)}}),oi.week=oi.sunday,oi.weeks=oi.sunday.range,oi.weeks.utc=oi.sunday.utc.range,oi.weekOfYear=oi.sundayOfYear;var ui={"-":"",_:" ",0:"0"},si=/^\s*\d+/,li=/^%/;ra.locale=function(n){return{numberFormat:function(n){var t=n.decimal,e=n.thousands,r=n.grouping,o=n.currency,a=r&&e?function(n,t){for(var o=n.length,a=[],i=0,u=r[0],s=0;o>0&&u>0&&(s+u+1>t&&(u=Math.max(1,t-s)),a.push(n.substring(o-=u,o+u)),!((s+=u+1)>t));)u=r[i=(i+1)%r.length];return a.reverse().join(e)}:w;return function(n){var e=ei.exec(n),r=e[1]||" ",i=e[2]||">",u=e[3]||"-",s=e[4]||"",l=e[5],c=+e[6],f=e[7],p=e[8],h=e[9],d=1,m="",v="",g=!1,y=!0;switch(p&&(p=+p.substring(1)),(l||"0"===r&&"="===i)&&(l=r="0",i="="),h){case"n":f=!0,h="g";break;case"%":d=100,v="%",h="f";break;case"p":d=100,v="%",h="r";break;case"b":case"o":case"x":case"X":"#"===s&&(m="0"+h.toLowerCase());case"c":y=!1;case"d":g=!0,p=0;break;case"s":d=-1,h="r"}"$"===s&&(m=o[0],v=o[1]),"r"!=h||p||(h="g"),null!=p&&("g"==h?p=Math.max(1,Math.min(21,p)):("e"==h||"f"==h)&&(p=Math.max(0,Math.min(20,p)))),h=ri.get(h)||Un;var b=l&&f;return function(n){var e=v;if(g&&n%1)return"";var o=0>n||0===n&&0>1/n?(n=-n,"-"):"-"===u?"":u;if(0>d){var s=ra.formatPrefix(n,p);n=s.scale(n),e=s.symbol+v}else n*=d;var x,M,w=(n=h(n,p)).lastIndexOf(".");if(0>w){var k=y?n.lastIndexOf("e"):-1;0>k?(x=n,M=""):(x=n.substring(0,k),M=n.substring(k))}else x=n.substring(0,w),M=t+n.substring(w+1);!l&&f&&(x=a(x,1/0));var _=m.length+x.length+M.length+(b?0:o.length),S=c>_?new Array(_=c-_+1).join(r):"";return b&&(x=a(S+x,S.length?c-M.length:1/0)),o+=m,n=x+M,("<"===i?o+n+S:">"===i?S+o+n:"^"===i?S.substring(0,_>>=1)+o+n+S.substring(_):o+(b?n:S+n))+e}}}(n),timeFormat:function(n){function t(n){function t(t){for(var e,o,a,i=[],u=-1,s=0;++uu;){if(r>=l)return-1;if(37===(o=t.charCodeAt(u++))){if(i=t.charAt(u++),!(a=M[i in ui?t.charAt(u++):i])||(r=a(n,e,r))<0)return-1}else if(o!=e.charCodeAt(r++))return-1}return r}var r=n.dateTime,o=n.date,a=n.time,i=n.periods,u=n.days,s=n.shortDays,l=n.months,c=n.shortMonths;t.utc=function(n){function e(n){try{var t=new(ai=Dn);return t._=n,r(t)}finally{ai=Date}}var r=t(n);return e.parse=function(n){try{ai=Dn;var t=r.parse(n);return t&&t._}finally{ai=Date}},e.toString=r.toString,e},t.multi=t.utc.multi=rt;var f=ra.map(),p=jn(u),h=Bn(u),d=jn(s),m=Bn(s),v=jn(l),g=Bn(l),y=jn(c),b=Bn(c);i.forEach(function(n,t){f.set(n.toLowerCase(),t)});var x={a:function(n){return s[n.getDay()]},A:function(n){return u[n.getDay()]},b:function(n){return c[n.getMonth()]},B:function(n){return l[n.getMonth()]},c:t(r),d:function(n,t){return qn(n.getDate(),t,2)},e:function(n,t){return qn(n.getDate(),t,2)},H:function(n,t){return qn(n.getHours(),t,2)},I:function(n,t){return qn(n.getHours()%12||12,t,2)},j:function(n,t){return qn(1+oi.dayOfYear(n),t,3)},L:function(n,t){return qn(n.getMilliseconds(),t,3)},m:function(n,t){return qn(n.getMonth()+1,t,2)},M:function(n,t){return qn(n.getMinutes(),t,2)},p:function(n){return i[+(n.getHours()>=12)]},S:function(n,t){return qn(n.getSeconds(),t,2)},U:function(n,t){return qn(oi.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return qn(oi.mondayOfYear(n),t,2)},x:t(o),X:t(a),y:function(n,t){return qn(n.getFullYear()%100,t,2)},Y:function(n,t){return qn(n.getFullYear()%1e4,t,4)},Z:tt,"%":function(){return"%"}},M={a:function(n,t,e){d.lastIndex=0;var r=d.exec(t.slice(e));return r?(n.w=m.get(r[0].toLowerCase()),e+r[0].length):-1},A:function(n,t,e){p.lastIndex=0;var r=p.exec(t.slice(e));return r?(n.w=h.get(r[0].toLowerCase()),e+r[0].length):-1},b:function(n,t,e){y.lastIndex=0;var r=y.exec(t.slice(e));return r?(n.m=b.get(r[0].toLowerCase()),e+r[0].length):-1},B:function(n,t,e){v.lastIndex=0;var r=v.exec(t.slice(e));return r?(n.m=g.get(r[0].toLowerCase()),e+r[0].length):-1},c:function(n,t,r){return e(n,x.c.toString(),t,r)},d:Zn,e:Zn,H:$n,I:$n,j:Jn,L:nt,m:Wn,M:Kn,p:function(n,t,e){var r=f.get(t.slice(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)},S:Qn,U:Hn,w:In,W:Vn,x:function(n,t,r){return e(n,x.x.toString(),t,r)},X:function(n,t,r){return e(n,x.X.toString(),t,r)},y:Gn,Y:Xn,Z:Yn,"%":et};return t}(n)}};var ci=ra.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});ra.format=ci.numberFormat,ra.geo={},ot.prototype={s:0,t:0,add:function(n){at(n,this.t,fi),at(fi.s,this.s,this),this.s?this.t+=fi.t:this.s=fi.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var fi=new ot;ra.geo.stream=function(n,t){n&&pi.hasOwnProperty(n.type)?pi[n.type](n,t):it(n,t)};var pi={Feature:function(n,t){it(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,o=e.length;++rn?4*Na+n:n,vi.lineStart=vi.lineEnd=vi.point=S}};ra.geo.bounds=function(){function n(n,t){b.push(x=[c=n,p=n]),f>t&&(f=t),t>h&&(h=t)}function t(t,e){var r=ct([t*Ua,e*Ua]);if(g){var o=pt(g,r),a=[o[1],-o[0],0],i=pt(a,o);mt(i),i=vt(i);var s=t-d,l=s>0?1:-1,m=i[0]*Da*l,v=ha(s)>180;if(v^(m>l*d&&l*t>m)){var y=i[1]*Da;y>h&&(h=y)}else if(v^((m=(m+360)%360-180)>l*d&&l*t>m)){var y=-i[1]*Da;f>y&&(f=y)}else f>e&&(f=e),e>h&&(h=e);v?d>t?u(c,t)>u(c,p)&&(p=t):u(t,p)>u(c,p)&&(c=t):p>=c?(c>t&&(c=t),t>p&&(p=t)):t>d?u(c,t)>u(c,p)&&(p=t):u(t,p)>u(c,p)&&(c=t)}else n(t,e);g=r,d=t}function e(){M.point=t}function r(){x[0]=c,x[1]=p,M.point=n,g=null}function o(n,e){if(g){var r=n-d;y+=ha(r)>180?r+(r>0?360:-360):r}else m=n,v=e;vi.point(n,e),t(n,e)}function a(){vi.lineStart()}function i(){o(m,v),vi.lineEnd(),ha(y)>Ra&&(c=-(p=180)),x[0]=c,x[1]=p,g=null}function u(n,t){return(t-=n)<0?t+360:t}function s(n,t){return n[0]-t[0]}function l(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:nmi?(c=-(p=180),f=-(h=90)):y>Ra?h=90:-Ra>y&&(f=-90),x[0]=c,x[1]=p}};return function(n){h=p=-(c=f=1/0),b=[],ra.geo.stream(n,M);var t=b.length;if(t){b.sort(s);for(var e=1,r=b[0],o=[r];t>e;++e)l((i=b[e])[0],r)||l(i[1],r)?(u(r[0],i[1])>u(r[0],r[1])&&(r[1]=i[1]),u(i[0],r[1])>u(r[0],r[1])&&(r[0]=i[0])):o.push(r=i);for(var a,i,d=-1/0,t=o.length-1,e=0,r=o[t];t>=e;r=i,++e)i=o[e],(a=u(r[1],i[0]))>d&&(d=a,c=i[0],p=r[1])}return b=x=null,c===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[c,f],[p,h]]}}(),ra.geo.centroid=function(n){gi=yi=bi=xi=Mi=wi=ki=_i=Si=Ai=Ti=0,ra.geo.stream(n,Ei);var t=Si,e=Ai,r=Ti,o=t*t+e*e+r*r;return Pa>o&&(t=wi,e=ki,r=_i,Ra>yi&&(t=bi,e=xi,r=Mi),Pa>(o=t*t+e*e+r*r))?[NaN,NaN]:[Math.atan2(e,t)*Da,rn(r/Math.sqrt(o))*Da]};var gi,yi,bi,xi,Mi,wi,ki,_i,Si,Ai,Ti,Ei={sphere:S,point:yt,lineStart:xt,lineEnd:Mt,polygonStart:function(){Ei.lineStart=wt},polygonEnd:function(){Ei.lineStart=xt}},Ri=Et(_t,function(n){var t,e=NaN,r=NaN,o=NaN;return{lineStart:function(){n.lineStart(),t=1},point:function(a,i){var u=a>0?Na:-Na,s=ha(a-e);ha(s-Na)0?La:-La),n.point(o,r),n.lineEnd(),n.lineStart(),n.point(u,r),n.point(a,r),t=0):o!==u&&s>=Na&&(ha(e-o)Ra?Math.atan((Math.sin(t)*(a=Math.cos(r))*Math.sin(e)-Math.sin(r)*(o=Math.cos(t))*Math.sin(n))/(o*a*i)):(t+r)/2}(e,r,a,i),n.point(o,r),n.lineEnd(),n.lineStart(),n.point(u,r),t=0),n.point(e=a,r=i),o=u},lineEnd:function(){n.lineEnd(),e=r=NaN},clean:function(){return 2-t}}},function(n,t,e,r){var o;if(null==n)o=e*La,r.point(-Na,o),r.point(0,o),r.point(Na,o),r.point(Na,0),r.point(Na,-o),r.point(0,-o),r.point(-Na,-o),r.point(-Na,0),r.point(-Na,o);else if(ha(n[0]-t[0])>Ra){var a=n[0]=.12&&.234>o&&r>=-.425&&-.214>r?i:o>=.166&&.234>o&&r>=-.214&&-.115>r?u:a).invert(n)},n.stream=function(n){var t=a.stream(n),e=i.stream(n),r=u.stream(n);return{point:function(n,o){t.point(n,o),e.point(n,o),r.point(n,o)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},n.precision=function(t){return arguments.length?(a.precision(t),i.precision(t),u.precision(t),n):a.precision()},n.scale=function(t){return arguments.length?(a.scale(t),i.scale(.35*t),u.scale(t),n.translate(a.translate())):a.scale()},n.translate=function(t){if(!arguments.length)return a.translate();var l=a.scale(),c=+t[0],f=+t[1];return e=a.translate(t).clipExtent([[c-.455*l,f-.238*l],[c+.455*l,f+.238*l]]).stream(s).point,r=i.translate([c-.307*l,f+.201*l]).clipExtent([[c-.425*l+Ra,f+.12*l+Ra],[c-.214*l-Ra,f+.234*l-Ra]]).stream(s).point,o=u.translate([c-.205*l,f+.212*l]).clipExtent([[c-.214*l+Ra,f+.166*l+Ra],[c-.115*l-Ra,f+.234*l-Ra]]).stream(s).point,n},n.scale(1070)};var Ni,Oi,Ci,Li,Ui,Di,zi={point:S,lineStart:S,lineEnd:S,polygonStart:function(){Oi=0,zi.lineStart=Dt},polygonEnd:function(){zi.lineStart=zi.lineEnd=zi.point=S,Ni+=ha(Oi/2)}},Fi={point:function(n,t){Ci>n&&(Ci=n),n>Ui&&(Ui=n),Li>t&&(Li=t),t>Di&&(Di=t)},lineStart:S,lineEnd:S,polygonStart:S,polygonEnd:S},qi={point:qt,lineStart:jt,lineEnd:Bt,polygonStart:function(){qi.lineStart=It},polygonEnd:function(){qi.point=qt,qi.lineStart=jt,qi.lineEnd=Bt}};ra.geo.path=function(){function n(n){return n&&("function"==typeof u&&a.pointRadius(+u.apply(this,arguments)),i&&i.valid||(i=o(a)),ra.geo.stream(n,i)),a.result()}function t(){return i=null,n}var e,r,o,a,i,u=4.5;return n.area=function(n){return Ni=0,ra.geo.stream(n,o(zi)),Ni},n.centroid=function(n){return bi=xi=Mi=wi=ki=_i=Si=Ai=Ti=0,ra.geo.stream(n,o(qi)),Ti?[Si/Ti,Ai/Ti]:_i?[wi/_i,ki/_i]:Mi?[bi/Mi,xi/Mi]:[NaN,NaN]},n.bounds=function(n){return Ui=Di=-(Ci=Li=1/0),ra.geo.stream(n,o(Fi)),[[Ci,Li],[Ui,Di]]},n.projection=function(n){return arguments.length?(o=(e=n)?n.stream||function(n){var t=Vt(function(t,e){return n([t*Da,e*Da])});return function(n){return Zt(t(n))}}(n):w,t()):e},n.context=function(n){return arguments.length?(a=null==(r=n)?new zt:new Ht(n),"function"!=typeof u&&a.pointRadius(u),t()):r},n.pointRadius=function(t){return arguments.length?(u="function"==typeof t?t:(a.pointRadius(+t),+t),n):u},n.projection(ra.geo.albersUsa()).context(null)},ra.geo.transform=function(n){return{stream:function(t){var e=new Xt(t);for(var r in n)e[r]=n[r];return e}}},Xt.prototype={point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},ra.geo.projection=Yt,ra.geo.projectionMutator=Wt,(ra.geo.equirectangular=function(){return Yt(Jt)}).raw=Jt.invert=Jt,ra.geo.rotation=function(n){function t(t){return(t=n(t[0]*Ua,t[1]*Ua))[0]*=Da,t[1]*=Da,t}return n=Kt(n[0]%360*Ua,n[1]*Ua,n.length>2?n[2]*Ua:0),t.invert=function(t){return(t=n.invert(t[0]*Ua,t[1]*Ua))[0]*=Da,t[1]*=Da,t},t},$t.invert=Jt,ra.geo.circle=function(){function n(){var n="function"==typeof r?r.apply(this,arguments):r,t=Kt(-n[0]*Ua,-n[1]*Ua,0).invert,o=[];return e(null,null,1,{point:function(n,e){o.push(n=t(n,e)),n[0]*=Da,n[1]*=Da}}),{type:"Polygon",coordinates:[o]}}var t,e,r=[0,0],o=6;return n.origin=function(t){return arguments.length?(r=t,n):r},n.angle=function(r){return arguments.length?(e=ee((t=+r)*Ua,o*Ua),n):t},n.precision=function(r){return arguments.length?(e=ee(t*Ua,(o=+r)*Ua),n):o},n.angle(90)},ra.geo.distance=function(n,t){var e,r=(t[0]-n[0])*Ua,o=n[1]*Ua,a=t[1]*Ua,i=Math.sin(r),u=Math.cos(r),s=Math.sin(o),l=Math.cos(o),c=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((e=f*i)*e+(e=l*c-s*f*u)*e),s*c+l*f*u)},ra.geo.graticule=function(){function n(){return{type:"MultiLineString",coordinates:t()}}function t(){return ra.range(Math.ceil(a/v)*v,o,v).map(p).concat(ra.range(Math.ceil(l/g)*g,s,g).map(h)).concat(ra.range(Math.ceil(r/d)*d,e,d).filter(function(n){return ha(n%v)>Ra}).map(c)).concat(ra.range(Math.ceil(u/m)*m,i,m).filter(function(n){return ha(n%g)>Ra}).map(f))}var e,r,o,a,i,u,s,l,c,f,p,h,d=10,m=d,v=90,g=360,y=2.5;return n.lines=function(){return t().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[p(a).concat(h(s).slice(1),p(o).reverse().slice(1),h(l).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.majorExtent(t).minorExtent(t):n.minorExtent()},n.majorExtent=function(t){return arguments.length?(a=+t[0][0],o=+t[1][0],l=+t[0][1],s=+t[1][1],a>o&&(t=a,a=o,o=t),l>s&&(t=l,l=s,s=t),n.precision(y)):[[a,l],[o,s]]},n.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],u=+t[0][1],i=+t[1][1],r>e&&(t=r,r=e,e=t),u>i&&(t=u,u=i,i=t),n.precision(y)):[[r,u],[e,i]]},n.step=function(t){return arguments.length?n.majorStep(t).minorStep(t):n.minorStep()},n.majorStep=function(t){return arguments.length?(v=+t[0],g=+t[1],n):[v,g]},n.minorStep=function(t){return arguments.length?(d=+t[0],m=+t[1],n):[d,m]},n.precision=function(t){return arguments.length?(y=+t,c=oe(u,i,90),f=ae(r,e,y),p=oe(l,s,90),h=ae(a,o,y),n):y},n.majorExtent([[-180,-90+Ra],[180,90-Ra]]).minorExtent([[-180,-80-Ra],[180,80+Ra]])},ra.geo.greatArc=function(){function n(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||o.apply(this,arguments)]}}var t,e,r=ie,o=ue;return n.distance=function(){return ra.geo.distance(t||r.apply(this,arguments),e||o.apply(this,arguments))},n.source=function(e){return arguments.length?(r=e,t="function"==typeof e?null:e,n):r},n.target=function(t){return arguments.length?(o=t,e="function"==typeof t?null:t,n):o},n.precision=function(){return arguments.length?n:0},n},ra.geo.interpolate=function(n,t){return function(n,t,e,r){var o=Math.cos(t),a=Math.sin(t),i=Math.cos(r),u=Math.sin(r),s=o*Math.cos(n),l=o*Math.sin(n),c=i*Math.cos(e),f=i*Math.sin(e),p=2*Math.asin(Math.sqrt(an(r-t)+o*i*an(e-n))),h=1/Math.sin(p),d=p?function(n){var t=Math.sin(n*=p)*h,e=Math.sin(p-n)*h,r=e*s+t*c,o=e*l+t*f,i=e*a+t*u;return[Math.atan2(o,r)*Da,Math.atan2(i,Math.sqrt(r*r+o*o))*Da]}:function(){return[n*Da,t*Da]};return d.distance=p,d}(n[0]*Ua,n[1]*Ua,t[0]*Ua,t[1]*Ua)},ra.geo.length=function(n){return ji=0,ra.geo.stream(n,Bi),ji};var ji,Bi={sphere:S,point:S,lineStart:function(){function n(n,o){var a=Math.sin(o*=Ua),i=Math.cos(o),u=ha((n*=Ua)-t),s=Math.cos(u);ji+=Math.atan2(Math.sqrt((u=i*Math.sin(u))*u+(u=r*a-e*i*s)*u),e*a+r*i*s),t=n,e=a,r=i}var t,e,r;Bi.point=function(o,a){t=o*Ua,e=Math.sin(a*=Ua),r=Math.cos(a),Bi.point=n},Bi.lineEnd=function(){Bi.point=Bi.lineEnd=S}},lineEnd:S,polygonStart:S,polygonEnd:S},Ii=se(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(ra.geo.azimuthalEqualArea=function(){return Yt(Ii)}).raw=Ii;var Hi=se(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},w);(ra.geo.azimuthalEquidistant=function(){return Yt(Hi)}).raw=Hi,(ra.geo.conicConformal=function(){return Lt(le)}).raw=le,(ra.geo.conicEquidistant=function(){return Lt(ce)}).raw=ce;var Vi=se(function(n){return 1/n},Math.atan);(ra.geo.gnomonic=function(){return Yt(Vi)}).raw=Vi,fe.invert=function(n,t){return[n,2*Math.atan(Math.exp(t))-La]},(ra.geo.mercator=function(){return pe(fe)}).raw=fe;var Xi=se(function(){return 1},Math.asin);(ra.geo.orthographic=function(){return Yt(Xi)}).raw=Xi;var Gi=se(function(n){return 1/(1+n)},function(n){return 2*Math.atan(n)});(ra.geo.stereographic=function(){return Yt(Gi)}).raw=Gi,he.invert=function(n,t){return[-t,2*Math.atan(Math.exp(n))-La]},(ra.geo.transverseMercator=function(){var n=pe(he),t=n.center,e=n.rotate;return n.center=function(n){return n?t([-n[1],n[0]]):[(n=t())[1],-n[0]]},n.rotate=function(n){return n?e([n[0],n[1],n.length>2?n[2]+90:90]):[(n=e())[0],n[1],n[2]-90]},e([0,0,90])}).raw=he,ra.geom={},ra.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,o=Tn(e),a=Tn(r),i=n.length,u=[],s=[];for(t=0;i>t;t++)u.push([+o.call(this,n[t],t),+a.call(this,n[t],t),t]);for(u.sort(ge),t=0;i>t;t++)s.push([u[t][0],-u[t][1]]);var l=ve(u),c=ve(s),f=c[0]===l[0],p=c[c.length-1]===l[l.length-1],h=[];for(t=l.length-1;t>=0;--t)h.push(n[u[l[t]][2]]);for(t=+f;t=r&&l.x<=a&&l.y>=o&&l.y<=i?[[r,i],[a,i],[a,o],[r,o]]:[];c.point=n[u]}),t}function e(n){return n.map(function(n,t){return{x:Math.round(a(n,t)/Ra)*Ra,y:Math.round(i(n,t)/Ra)*Ra,i:t}})}var r=de,o=me,a=r,i=o,u=tu;return n?t(n):(t.links=function(n){return Ve(e(n)).edges.filter(function(n){return n.l&&n.r}).map(function(t){return{source:n[t.l.i],target:n[t.r.i]}})},t.triangles=function(n){var t=[];return Ve(e(n)).cells.forEach(function(e,r){for(var o,a=e.site,i=e.edges.sort(Re),u=-1,s=i.length,l=i[s-1].edge,c=l.l===a?l.r:l.l;++u=l,p=r>=c,h=p<<1|f;n.leaf=!1,n=n.nodes[h]||(n.nodes[h]={leaf:!0,nodes:[],point:null,x:null,y:null}),f?o=l:u=l,p?i=c:s=c,a(n,t,e,r,o,i,u,s)}var c,f,p,h,d,m,v,g,y,b=Tn(u),x=Tn(s);if(null!=t)m=t,v=e,g=r,y=o;else if(g=y=-(m=v=1/0),f=[],p=[],d=n.length,i)for(h=0;d>h;++h)(c=n[h]).xg&&(g=c.x),c.y>y&&(y=c.y),f.push(c.x),p.push(c.y);else for(h=0;d>h;++h){var M=+b(c=n[h],h),w=+x(c,h);m>M&&(m=M),v>w&&(v=w),M>g&&(g=M),w>y&&(y=w),f.push(M),p.push(w)}var k=g-m,_=y-v;k>_?y=v+k:g=m+_;var S={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(n){a(S,n,+b(n,++h),+x(n,h),m,v,g,y)},visit:function(n){!function n(t,e,r,o,a,i){if(!t(e,r,o,a,i)){var u=.5*(r+a),s=.5*(o+i),l=e.nodes;l[0]&&n(t,l[0],r,o,u,s),l[1]&&n(t,l[1],u,o,a,s),l[2]&&n(t,l[2],r,s,u,i),l[3]&&n(t,l[3],u,s,a,i)}}(n,S,m,v,g,y)},find:function(n){return function(n,t,e,r,o,a,i){var u,s=1/0;return function n(l,c,f,p,h){if(!(c>a||f>i||r>p||o>h)){if(d=l.point){var d,m=t-l.x,v=e-l.y,g=m*m+v*v;if(s>g){var y=Math.sqrt(s=g);r=t-y,o=e-y,a=t+y,i=e+y,u=d}}for(var b=l.nodes,x=.5*(c+p),M=.5*(f+h),w=t>=x,k=e>=M,_=k<<1|w,S=_+4;S>_;++_)if(l=b[3&_])switch(3&_){case 0:n(l,c,f,x,M);break;case 1:n(l,x,f,p,M);break;case 2:n(l,c,M,x,h);break;case 3:n(l,x,M,p,h)}}}(n,r,o,a,i),u}(S,n[0],n[1],m,v,g,y)}};if(h=-1,null==t){for(;++h=0?n.slice(0,t):n,r=t>=0?n.slice(t+1):"in";return e=au.get(e)||ou,function(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}((r=iu.get(r)||w)(e.apply(null,oa.call(arguments,1))))},ra.interpolateHcl=function(n,t){n=ra.hcl(n),t=ra.hcl(t);var e=n.h,r=n.c,o=n.l,a=t.h-e,i=t.c-r,u=t.l-o;return isNaN(i)&&(i=0,r=isNaN(r)?t.c:r),isNaN(a)?(a=0,e=isNaN(e)?t.h:e):a>180?a-=360:-180>a&&(a+=360),function(n){return fn(e+a*n,r+i*n,o+u*n)+""}},ra.interpolateHsl=function(n,t){n=ra.hsl(n),t=ra.hsl(t);var e=n.h,r=n.s,o=n.l,a=t.h-e,i=t.s-r,u=t.l-o;return isNaN(i)&&(i=0,r=isNaN(r)?t.s:r),isNaN(a)?(a=0,e=isNaN(e)?t.h:e):a>180?a-=360:-180>a&&(a+=360),function(n){return ln(e+a*n,r+i*n,o+u*n)+""}},ra.interpolateLab=function(n,t){n=ra.lab(n),t=ra.lab(t);var e=n.l,r=n.a,o=n.b,a=t.l-e,i=t.a-r,u=t.b-o;return function(n){return hn(e+a*n,r+i*n,o+u*n)+""}},ra.interpolateRound=cr,ra.transform=function(n){var t=ia.createElementNS(ra.ns.prefix.svg,"g");return(ra.transform=function(n){if(null!=n){t.setAttribute("transform",n);var e=t.transform.baseVal.consolidate()}return new fr(e?e.matrix:uu)})(n)},fr.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var uu={a:1,b:0,c:0,d:1,e:0,f:0};ra.interpolateTransform=mr,ra.layout={},ra.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++eu*u/g){if(m>s){var l=t.charge/s;n.px-=a*l,n.py-=i*l}return!0}if(t.point&&s&&m>s){var l=t.pointCharge/s;n.px-=a*l,n.py-=i*l}}return!t.charge}}function t(n){n.px=ra.event.x,n.py=ra.event.y,s.resume()}var e,r,o,a,i,u,s={},l=ra.dispatch("start","tick","end"),c=[1,1],f=.9,p=su,h=lu,d=-30,m=cu,v=.1,g=.64,y=[],b=[];return s.tick=function(){if((o*=.99)<.005)return e=null,l.end({type:"end",alpha:o=0}),!0;var t,r,s,p,h,m,g,x,M,w=y.length,k=b.length;for(r=0;k>r;++r)s=b[r],p=s.source,h=s.target,x=h.x-p.x,M=h.y-p.y,(m=x*x+M*M)&&(m=o*i[r]*((m=Math.sqrt(m))-a[r])/m,x*=m,M*=m,h.x-=x*(g=p.weight+h.weight?p.weight/(p.weight+h.weight):.5),h.y-=M*g,p.x+=x*(g=1-g),p.y+=M*g);if((g=o*v)&&(x=c[0]/2,M=c[1]/2,r=-1,g))for(;++r0?o=n:(e.c=null,e.t=NaN,e=null,l.end({type:"end",alpha:o=0})):n>0&&(l.start({type:"start",alpha:o=n}),e=Pn(s.tick)),s):o},s.start=function(){function n(n,r){if(!e){for(e=new Array(o),s=0;o>s;++s)e[s]=[];for(s=0;l>s;++s){var a=b[s];e[a.source.index].push(a.target),e[a.target.index].push(a.source)}}for(var i,u=e[t],s=-1,c=u.length;++st;++t)(r=y[t]).index=t,r.weight=0;for(t=0;l>t;++t)"number"==typeof(r=b[t]).source&&(r.source=y[r.source]),"number"==typeof r.target&&(r.target=y[r.target]),++r.source.weight,++r.target.weight;for(t=0;o>t;++t)r=y[t],isNaN(r.x)&&(r.x=n("x",f)),isNaN(r.y)&&(r.y=n("y",m)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(a=[],"function"==typeof p)for(t=0;l>t;++t)a[t]=+p.call(this,b[t],t);else for(t=0;l>t;++t)a[t]=p;if(i=[],"function"==typeof h)for(t=0;l>t;++t)i[t]=+h.call(this,b[t],t);else for(t=0;l>t;++t)i[t]=h;if(u=[],"function"==typeof d)for(t=0;o>t;++t)u[t]=+d.call(this,y[t],t);else for(t=0;o>t;++t)u[t]=d;return s.resume()},s.resume=function(){return s.alpha(.1)},s.stop=function(){return s.alpha(0)},s.drag=function(){return r||(r=ra.behavior.drag().origin(w).on("dragstart.force",xr).on("drag.force",t).on("dragend.force",Mr)),arguments.length?void this.on("mouseover.force",wr).on("mouseout.force",kr).call(r):r},ra.rebind(s,l,"on")};var su=20,lu=1,cu=1/0;ra.layout.hierarchy=function(){function n(o){var a,i=[o],u=[];for(o.depth=0;null!=(a=i.pop());)if(u.push(a),(l=e.call(n,a,a.depth))&&(s=l.length)){for(var s,l,c;--s>=0;)i.push(c=l[s]),c.parent=a,c.depth=a.depth+1;r&&(a.value=0),a.children=l}else r&&(a.value=+r.call(n,a,a.depth)||0),delete a.children;return Ar(o,function(n){var e,o;t&&(e=n.children)&&e.sort(t),r&&(o=n.parent)&&(o.value+=n.value)}),u}var t=Rr,e=Tr,r=Er;return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Sr(t,function(n){n.children&&(n.value=0)}),Ar(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},ra.layout.partition=function(){function n(n,r){var o=t.call(this,n,r);return function n(t,e,r,o){var a=t.children;if(t.x=e,t.y=t.depth*o,t.dx=r,t.dy=o,a&&(i=a.length)){var i,u,s,l=-1;for(r=t.value?r/t.value:0;++lf?-1:1),d=ra.sum(l),m=d?(f-s*h)/d:0,v=ra.range(s),g=[];return null!=e&&v.sort(e===fu?function(n,t){return l[t]-l[n]}:function(n,t){return e(i[n],i[t])}),v.forEach(function(n){g[n]={data:i[n],value:u=l[n],startAngle:c,endAngle:c+=u*m+h,padAngle:p}}),g}var t=Number,e=fu,r=0,o=Oa,a=0;return n.value=function(e){return arguments.length?(t=e,n):t},n.sort=function(t){return arguments.length?(e=t,n):e},n.startAngle=function(t){return arguments.length?(r=t,n):r},n.endAngle=function(t){return arguments.length?(o=t,n):o},n.padAngle=function(t){return arguments.length?(a=t,n):a},n};var fu={};ra.layout.stack=function(){function n(u,s){if(!(p=u.length))return u;var l=u.map(function(e,r){return t.call(n,e,r)}),c=l.map(function(t){return t.map(function(t,e){return[a.call(n,t,e),i.call(n,t,e)]})}),f=e.call(n,c,s);l=ra.permute(l,f),c=ra.permute(c,f);var p,h,d,m,v=r.call(n,c,s),g=l[0].length;for(d=0;g>d;++d)for(o.call(n,l[0][d],m=v[d],c[0][d][1]),h=1;p>h;++h)o.call(n,l[h][d],m+=c[h-1][d][1],c[h][d][1]);return u}var t=w,e=Lr,r=Ur,o=Cr,a=Nr,i=Or;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:pu.get(t)||Lr,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:hu.get(t)||Ur,n):r},n.x=function(t){return arguments.length?(a=t,n):a},n.y=function(t){return arguments.length?(i=t,n):i},n.out=function(t){return arguments.length?(o=t,n):o},n};var pu=ra.map({"inside-out":function(n){var t,e,r=n.length,o=n.map(Dr),a=n.map(zr),i=ra.range(r).sort(function(n,t){return o[n]-o[t]}),u=0,s=0,l=[],c=[];for(t=0;r>t;++t)e=i[t],s>u?(u+=a[e],l.push(e)):(s+=a[e],c.push(e));return c.reverse().concat(l)},reverse:function(n){return ra.range(n.length).reverse()},default:Lr}),hu=ra.map({silhouette:function(n){var t,e,r,o=n.length,a=n[0].length,i=[],u=0,s=[];for(e=0;a>e;++e){for(t=0,r=0;o>t;t++)r+=n[t][e][1];r>u&&(u=r),i.push(r)}for(e=0;a>e;++e)s[e]=(u-i[e])/2;return s},wiggle:function(n){var t,e,r,o,a,i,u,s,l,c=n.length,f=n[0],p=f.length,h=[];for(h[0]=s=l=0,e=1;p>e;++e){for(t=0,o=0;c>t;++t)o+=n[t][e][1];for(t=0,a=0,u=f[e][0]-f[e-1][0];c>t;++t){for(r=0,i=(n[t][e][1]-n[t][e-1][1])/(2*u);t>r;++r)i+=(n[r][e][1]-n[r][e-1][1])/u;a+=i*n[t][e][1]}h[e]=s-=o?a/o*u:0,l>s&&(l=s)}for(e=0;p>e;++e)h[e]-=l;return h},expand:function(n){var t,e,r,o=n.length,a=n[0].length,i=1/o,u=[];for(e=0;a>e;++e){for(t=0,r=0;o>t;t++)r+=n[t][e][1];if(r)for(t=0;o>t;t++)n[t][e][1]/=r;else for(t=0;o>t;t++)n[t][e][1]=i}for(e=0;a>e;++e)u[e]=0;return u},zero:Ur});ra.layout.histogram=function(){function n(n,a){for(var i,u,s=[],l=n.map(e,this),c=r.call(this,l,a),f=o.call(this,c,l,a),a=-1,p=l.length,h=f.length-1,d=t?1:1/p;++a0)for(a=-1;++a=c[0]&&u<=c[1]&&((i=s[ra.bisect(f,u,1,h)-1]).y+=d,i.push(n[a]));return s}var t=!0,e=Number,r=Br,o=qr;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=Tn(t),n):r},n.bins=function(t){return arguments.length?(o="number"==typeof t?function(n){return jr(n,t)}:Tn(t),n):o},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},ra.layout.pack=function(){function n(n,a){var i=e.call(this,n,a),u=i[0],s=o[0],l=o[1],c=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(u.x=u.y=0,Ar(u,function(n){n.r=+c(n.value)}),Ar(u,Gr),r){var f=r*(t?1:Math.max(2*u.r/s,2*u.r/l))/2;Ar(u,function(n){n.r+=f}),Ar(u,Gr),Ar(u,function(n){n.r-=f})}return function n(t,e,r,o){var a=t.children;if(t.x=e+=o*t.x,t.y=r+=o*t.y,t.r*=o,a)for(var i=-1,u=a.length;++ii;++i)r.push((a[i]=o={_:a[i],parent:t,children:(o=a[i].children)&&o.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:i}).a=o);return e.children[0]}(c);if(Ar(f,t),f.parent.m=-f.z,Sr(f,e),u)Sr(c,r);else{var p=c,h=c,d=c;Sr(c,function(n){n.xh.x&&(h=n),n.depth>d.depth&&(d=n)});var m=a(p,h)/2-p.x,v=i[0]/(h.x+a(h,p)/2+m),g=i[1]/(d.depth||1);Sr(c,function(n){n.x=(n.x+m)*v,n.y=n.depth*g})}return l}function t(n){var t=n.children,e=n.parent.children,r=n.i?e[n.i-1]:null;if(t.length){!function(n){for(var t,e=0,r=0,o=n.children,a=o.length;--a>=0;)(t=o[a]).z+=e,t.m+=e,e+=t.s+(r+=t.c)}(n);var o=(t[0].z+t[t.length-1].z)/2;r?(n.z=r.z+a(n._,r._),n.m=n.z-o):n.z=o}else r&&(n.z=r.z+a(n._,r._));n.parent.A=function(n,t,e){if(t){for(var r,o=n,i=n,u=t,s=o.parent.children[0],l=o.m,c=i.m,f=u.m,p=s.m;u=Kr(u),o=$r(o),u&&o;)s=$r(s),(i=Kr(i)).a=n,(r=u.z+f-o.z-l+a(u._,o._))>0&&(Qr(no(u,n,e),n,r),l+=r,c+=r),f+=u.m,l+=o.m,p+=s.m,c+=i.m;u&&!Kr(i)&&(i.t=u,i.m+=f-c),o&&!$r(s)&&(s.t=o,s.m+=l-p,e=n)}return e}(n,r,n.parent.A||e[0])}function e(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function r(n){n.x*=i[0],n.y=n.depth*i[1]}var o=ra.layout.hierarchy().sort(null).value(null),a=Jr,i=[1,1],u=null;return n.separation=function(t){return arguments.length?(a=t,n):a},n.size=function(t){return arguments.length?(u=null==(i=t)?r:null,n):u?null:i},n.nodeSize=function(t){return arguments.length?(u=null==(i=t)?null:r,n):u?i:null},_r(n,o)},ra.layout.cluster=function(){function n(n,a){var i,u=t.call(this,n,a),s=u[0],l=0;Ar(s,function(n){var t=n.children;t&&t.length?(n.x=function(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}(t),n.y=function(n){return 1+ra.max(n,function(n){return n.y})}(t)):(n.x=i?l+=e(n,i):0,n.y=0,i=n)});var c=function n(t){var e=t.children;return e&&e.length?n(e[0]):t}(s),f=function n(t){var e,r=t.children;return r&&(e=r.length)?n(r[e-1]):t}(s),p=c.x-e(c,f)/2,h=f.x+e(f,c)/2;return Ar(s,o?function(n){n.x=(n.x-s.x)*r[0],n.y=(s.y-n.y)*r[1]}:function(n){n.x=(n.x-p)/(h-p)*r[0],n.y=(1-(s.y?n.y/s.y:1))*r[1]}),u}var t=ra.layout.hierarchy().sort(null).value(null),e=Jr,r=[1,1],o=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(o=null==(r=t),n):o?null:r},n.nodeSize=function(t){return arguments.length?(o=null!=(r=t),n):o?r:null},_r(n,t)},ra.layout.treemap=function(){function n(n,t){for(var e,r,o=-1,a=n.length;++ot?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var a=e.children;if(a&&a.length){var i,u,s,l=f(e),c=[],p=a.slice(),d=1/0,m="slice"===h?l.dx:"dice"===h?l.dy:"slice-dice"===h?1&e.depth?l.dy:l.dx:Math.min(l.dx,l.dy);for(n(p,l.dx*l.dy/e.value),c.area=0;(s=p.length)>0;)c.push(i=p[s-1]),c.area+=i.area,"squarify"!==h||(u=r(c,m))<=d?(p.pop(),d=u):(c.area-=c.pop().area,o(c,m,l,!1),m=Math.min(l.dx,l.dy),c.length=c.area=0,d=1/0);c.length&&(o(c,m,l,!0),c.length=c.area=0),a.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var a,i=f(t),u=r.slice(),s=[];for(n(u,i.dx*i.dy/t.value),s.area=0;a=u.pop();)s.push(a),s.area+=a.area,null!=a.z&&(o(s,a.z?i.dx:i.dy,i,!u.length),s.length=s.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,o=0,a=1/0,i=-1,u=n.length;++ie&&(a=e),e>o&&(o=e));return t*=t,(r*=r)?Math.max(t*o*d/r,r/(t*a*d)):1/0}function o(n,t,e,r){var o,a=-1,i=n.length,u=e.x,l=e.y,c=t?s(n.area/t):0;if(t==e.dx){for((r||c>e.dy)&&(c=e.dy);++ae.dx)&&(c=e.dx);++ae&&(t=1),1>e&&(n=0),function(){var e,r,o;do{e=2*Math.random()-1,r=2*Math.random()-1,o=e*e+r*r}while(!o||o>1);return n+t*e*Math.sqrt(-2*Math.log(o)/o)}},logNormal:function(){var n=ra.random.normal.apply(ra,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=ra.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},ra.scale={};var du={floor:w,ceil:w};ra.scale.linear=function(){return function n(t,e,r,o){function a(){var n=Math.min(t.length,e.length)>2?so:ao,a=o?gr:vr;return u=n(t,e,a,r),s=n(e,t,a,Qe),i}function i(n){return u(n)}var u,s;return i.invert=function(n){return s(n)},i.domain=function(n){return arguments.length?(t=n.map(Number),a()):t},i.range=function(n){return arguments.length?(e=n,a()):e},i.rangeRound=function(n){return i.range(n).interpolate(cr)},i.clamp=function(n){return arguments.length?(o=n,a()):o},i.interpolate=function(n){return arguments.length?(r=n,a()):r},i.ticks=function(n){return po(t,n)},i.tickFormat=function(n,e){return ho(t,n,e)},i.nice=function(n){return co(t,n),a()},i.copy=function(){return n(t,e,r,o)},a()}([0,1],[0,1],Qe,!1)};var mu={s:1,g:1,p:1,r:1,e:1};ra.scale.log=function(){return function n(t,e,r,o){function a(n){return(r?Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(e)}function i(n){return r?Math.pow(e,n):-Math.pow(e,-n)}function u(n){return t(a(n))}return u.invert=function(n){return i(t.invert(n))},u.domain=function(n){return arguments.length?(r=n[0]>=0,t.domain((o=n.map(Number)).map(a)),u):o},u.base=function(n){return arguments.length?(e=+n,t.domain(o.map(a)),u):e},u.nice=function(){var n=io(o.map(a),r?Math:gu);return t.domain(n),o=n.map(i),u},u.ticks=function(){var n=ro(o),t=[],u=n[0],s=n[1],l=Math.floor(a(u)),c=Math.ceil(a(s)),f=e%1?2:e;if(isFinite(c-l)){if(r){for(;c>l;l++)for(var p=1;f>p;p++)t.push(i(l)*p);t.push(i(l))}else for(t.push(i(l));l++0;p--)t.push(i(l)*p);for(l=0;t[l]s;c--);t=t.slice(l,c)}return t},u.tickFormat=function(n,t){if(!arguments.length)return vu;arguments.length<2?t=vu:"function"!=typeof t&&(t=ra.format(t));var r=Math.max(1,e*n/u.ticks().length);return function(n){var o=n/i(Math.round(a(n)));return e-.5>o*e&&(o*=e),r>=o?t(n):""}},u.copy=function(){return n(t.copy(),e,r,o)},lo(u,t)}(ra.scale.linear().domain([0,1]),10,!0,[1,10])};var vu=ra.format(".0e"),gu={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};ra.scale.pow=function(){return function n(t,e,r){function o(n){return t(a(n))}var a=vo(e),i=vo(1/e);return o.invert=function(n){return i(t.invert(n))},o.domain=function(n){return arguments.length?(t.domain((r=n.map(Number)).map(a)),o):r},o.ticks=function(n){return po(r,n)},o.tickFormat=function(n,t){return ho(r,n,t)},o.nice=function(n){return o.domain(co(r,n))},o.exponent=function(n){return arguments.length?(a=vo(e=n),i=vo(1/e),t.domain(r.map(a)),o):e},o.copy=function(){return n(t.copy(),e,r)},lo(o,t)}(ra.scale.linear(),1,[0,1])},ra.scale.sqrt=function(){return ra.scale.pow().exponent(.5)},ra.scale.ordinal=function(){return function n(t,e){function r(n){return i[((a.get(n)||("range"===e.t?a.set(n,t.push(n)):NaN))-1)%i.length]}function o(n,e){return ra.range(t.length).map(function(t){return n+e*t})}var a,i,u;return r.domain=function(n){if(!arguments.length)return t;t=[],a=new h;for(var o,i=-1,u=n.length;++i(n=e.indexOf(n))?[NaN,NaN]:[n>0?a[n-1]:t[0],n(n=r.indexOf(n))?NaN:n/i+t,n+1/i]},o.copy=function(){return n(t,e,r)},a()}(0,1,[0,1])},ra.scale.threshold=function(){return function n(t,e){function r(n){return n>=n?e[ra.bisect(t,n)]:void 0}return r.domain=function(n){return arguments.length?(t=n,r):t},r.range=function(n){return arguments.length?(e=n,r):e},r.invertExtent=function(n){return n=e.indexOf(n),[t[n-1],t[n]]},r.copy=function(){return n(t,e)},r}([.5],[0,1])},ra.scale.identity=function(){return function n(t){function e(n){return+n}return e.invert=e,e.domain=e.range=function(n){return arguments.length?(t=n.map(e),e):t},e.ticks=function(n){return po(t,n)},e.tickFormat=function(n,e){return ho(t,n,e)},e.copy=function(){return n(t)},e}([0,1])},ra.svg={},ra.svg.arc=function(){function n(){var n=Math.max(0,+e.apply(this,arguments)),l=Math.max(0,+r.apply(this,arguments)),c=i.apply(this,arguments)-La,f=u.apply(this,arguments)-La,p=Math.abs(f-c),h=c>f?0:1;if(n>l&&(d=l,l=n,n=d),p>=Ca)return t(l,h)+(n?t(n,1-h):"")+"Z";var d,m,v,g,y,b,x,M,w,k,_,S,A=0,T=0,E=[];if((g=(+s.apply(this,arguments)||0)/2)&&(v=a===wu?Math.sqrt(n*n+l*l):+a.apply(this,arguments),h||(T*=-1),l&&(T=rn(v/l*Math.sin(g))),n&&(A=rn(v/n*Math.sin(g)))),l){y=l*Math.cos(c+T),b=l*Math.sin(c+T),x=l*Math.cos(f-T),M=l*Math.sin(f-T);var R=Math.abs(f-c-2*T)<=Na?0:1;if(T&&ko(y,b,x,M)===h^R){var P=(c+f)/2;y=l*Math.cos(P),b=l*Math.sin(P),x=M=null}}else y=b=0;if(n){w=n*Math.cos(f-A),k=n*Math.sin(f-A),_=n*Math.cos(c+A),S=n*Math.sin(c+A);var N=Math.abs(c-f+2*A)<=Na?0:1;if(A&&ko(w,k,_,S)===1-h^N){var O=(c+f)/2;w=n*Math.cos(O),k=n*Math.sin(O),_=S=null}}else w=k=0;if(p>Ra&&(d=Math.min(Math.abs(l-n)/2,+o.apply(this,arguments)))>.001){m=l>n^h?0:1;var C=d,L=d;if(Na>p){var U=null==_?[w,k]:null==x?[y,b]:be([y,b],[_,S],[x,M],[w,k]),D=y-U[0],z=b-U[1],F=x-U[0],q=M-U[1],j=1/Math.sin(Math.acos((D*F+z*q)/(Math.sqrt(D*D+z*z)*Math.sqrt(F*F+q*q)))/2),B=Math.sqrt(U[0]*U[0]+U[1]*U[1]);L=Math.min(d,(n-B)/(j-1)),C=Math.min(d,(l-B)/(j+1))}if(null!=x){var I=_o(null==_?[w,k]:[_,S],[y,b],l,C,h),H=_o([x,M],[w,k],l,C,h);d===C?E.push("M",I[0],"A",C,",",C," 0 0,",m," ",I[1],"A",l,",",l," 0 ",1-h^ko(I[1][0],I[1][1],H[1][0],H[1][1]),",",h," ",H[1],"A",C,",",C," 0 0,",m," ",H[0]):E.push("M",I[0],"A",C,",",C," 0 1,",m," ",H[0])}else E.push("M",y,",",b);if(null!=_){var V=_o([y,b],[_,S],n,-L,h),X=_o([w,k],null==x?[y,b]:[x,M],n,-L,h);d===L?E.push("L",X[0],"A",L,",",L," 0 0,",m," ",X[1],"A",n,",",n," 0 ",h^ko(X[1][0],X[1][1],V[1][0],V[1][1]),",",1-h," ",V[1],"A",L,",",L," 0 0,",m," ",V[0]):E.push("L",X[0],"A",L,",",L," 0 0,",m," ",V[0])}else E.push("L",w,",",k)}else E.push("M",y,",",b),null!=x&&E.push("A",l,",",l," 0 ",R,",",h," ",x,",",M),E.push("L",w,",",k),null!=_&&E.push("A",n,",",n," 0 ",N,",",1-h," ",_,",",S);return E.push("Z"),E.join("")}function t(n,t){return"M0,"+n+"A"+n+","+n+" 0 1,"+t+" 0,"+-n+"A"+n+","+n+" 0 1,"+t+" 0,"+n}var e=yo,r=bo,o=go,a=wu,i=xo,u=Mo,s=wo;return n.innerRadius=function(t){return arguments.length?(e=Tn(t),n):e},n.outerRadius=function(t){return arguments.length?(r=Tn(t),n):r},n.cornerRadius=function(t){return arguments.length?(o=Tn(t),n):o},n.padRadius=function(t){return arguments.length?(a=t==wu?wu:Tn(t),n):a},n.startAngle=function(t){return arguments.length?(i=Tn(t),n):i},n.endAngle=function(t){return arguments.length?(u=Tn(t),n):u},n.padAngle=function(t){return arguments.length?(s=Tn(t),n):s},n.centroid=function(){var n=(+e.apply(this,arguments)+ +r.apply(this,arguments))/2,t=(+i.apply(this,arguments)+ +u.apply(this,arguments))/2-La;return[Math.cos(t)*n,Math.sin(t)*n]},n};var wu="auto";ra.svg.line=function(){return So(w)};var ku=ra.map({linear:Ao,"linear-closed":To,step:function(n){for(var t=0,e=n.length,r=n[0],o=[r[0],",",r[1]];++t1&&o.push("H",r[0]),o.join("")},"step-before":Eo,"step-after":Ro,basis:Oo,"basis-open":function(n){if(n.length<4)return Ao(n);for(var t,e=[],r=-1,o=n.length,a=[0],i=[0];++r<3;)t=n[r],a.push(t[0]),i.push(t[1]);for(e.push(Co(Au,a)+","+Co(Au,i)),--r;++rNa)+",1 "+t}function r(n,t,e,r){return"Q 0,0 "+r}var o=ie,a=ue,i=qo,u=xo,s=Mo;return n.radius=function(t){return arguments.length?(i=Tn(t),n):i},n.source=function(t){return arguments.length?(o=Tn(t),n):o},n.target=function(t){return arguments.length?(a=Tn(t),n):a},n.startAngle=function(t){return arguments.length?(u=Tn(t),n):u},n.endAngle=function(t){return arguments.length?(s=Tn(t),n):s},n},ra.svg.diagonal=function(){function n(n,o){var a=t.call(this,n,o),i=e.call(this,n,o),u=(a.y+i.y)/2,s=[a,{x:a.x,y:u},{x:i.x,y:u},i];return"M"+(s=s.map(r))[0]+"C"+s[1]+" "+s[2]+" "+s[3]}var t=ie,e=ue,r=jo;return n.source=function(e){return arguments.length?(t=Tn(e),n):t},n.target=function(t){return arguments.length?(e=Tn(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},ra.svg.diagonal.radial=function(){var n=ra.svg.diagonal(),t=jo,e=n.projection;return n.projection=function(n){return arguments.length?e(function(n){return function(){var t=n.apply(this,arguments),e=t[0],r=t[1]-La;return[e*Math.cos(r),e*Math.sin(r)]}}(t=n)):t},n},ra.svg.symbol=function(){function n(n,r){return(Tu.get(t.call(this,n,r))||Ho)(e.call(this,n,r))}var t=Io,e=Bo;return n.type=function(e){return arguments.length?(t=Tn(e),n):t},n.size=function(t){return arguments.length?(e=Tn(t),n):e},n};var Tu=ra.map({circle:Ho,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*Ru)),e=t*Ru;return"M0,"+-t+"L"+e+",0 0,"+t+" "+-e+",0Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/Eu),e=t*Eu/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/Eu),e=t*Eu/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});ra.svg.symbolTypes=Tu.keys();var Eu=Math.sqrt(3),Ru=Math.tan(30*Ua);wa.transition=function(n){for(var t,e,r=Pu||++Lu,o=Wo(n),a=[],i=Nu||{time:Date.now(),ease:ar,delay:0,duration:250},u=-1,s=this.length;++uo;o++){r.push(t=[]);for(var i=this[o],u=0,s=i.length;s>u;u++)(e=i[u])&&n.call(e,e.__data__,u,o)&&t.push(e)}return Xo(r,this.namespace,this.id)},Cu.tween=function(n,t){var e=this.id,r=this.namespace;return arguments.length<2?this.node()[r][e].tween.get(n):G(this,null==t?function(t){t[r][e].tween.remove(n)}:function(o){o[r][e].tween.set(n,t)})},Cu.attr=function(n,t){function e(){this.removeAttribute(a)}function r(){this.removeAttributeNS(a.space,a.local)}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var o="transform"==n?mr:Qe,a=ra.ns.qualify(n);return Go(this,"attr."+n,t,a.local?function(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(a.space,a.local);return e!==n&&(t=o(e,n),function(n){this.setAttributeNS(a.space,a.local,t(n))})})}:function(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(a);return e!==n&&(t=o(e,n),function(n){this.setAttribute(a,t(n))})})})},Cu.attrTween=function(n,t){var e=ra.ns.qualify(n);return this.tween("attr."+n,e.local?function(n,r){var o=t.call(this,n,r,this.getAttributeNS(e.space,e.local));return o&&function(n){this.setAttributeNS(e.space,e.local,o(n))}}:function(n,r){var o=t.call(this,n,r,this.getAttribute(e));return o&&function(n){this.setAttribute(e,o(n))}})},Cu.style=function(n,t,e){function r(){this.style.removeProperty(n)}var o=arguments.length;if(3>o){if("string"!=typeof n){for(e in 2>o&&(t=""),n)this.style(e,n[e],t);return this}e=""}return Go(this,"style."+n,t,function(t){return null==t?r:(t+="",function(){var r,o=i(this).getComputedStyle(this,null).getPropertyValue(n);return o!==t&&(r=Qe(o,t),function(t){this.style.setProperty(n,r(t),e)})})})},Cu.styleTween=function(n,t,e){return arguments.length<3&&(e=""),this.tween("style."+n,function(r,o){var a=t.call(this,r,o,i(this).getComputedStyle(this,null).getPropertyValue(n));return a&&function(t){this.style.setProperty(n,a(t),e)}})},Cu.text=function(n){return Go(this,"text",n,Yo)},Cu.remove=function(){var n=this.namespace;return this.each("end.transition",function(){var t;this[n].count<2&&(t=this.parentNode)&&t.removeChild(this)})},Cu.ease=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].ease:("function"!=typeof n&&(n=ra.ease.apply(ra,arguments)),G(this,function(r){r[e][t].ease=n}))},Cu.delay=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].delay:G(this,"function"==typeof n?function(r,o,a){r[e][t].delay=+n.call(r,r.__data__,o,a)}:(n=+n,function(r){r[e][t].delay=n}))},Cu.duration=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].duration:G(this,"function"==typeof n?function(r,o,a){r[e][t].duration=Math.max(1,n.call(r,r.__data__,o,a))}:(n=Math.max(1,n),function(r){r[e][t].duration=n}))},Cu.each=function(n,t){var e=this.id,r=this.namespace;if(arguments.length<2){var o=Nu,a=Pu;try{Pu=e,G(this,function(t,o,a){Nu=t[r][e],n.call(t,t.__data__,o,a)})}finally{Nu=o,Pu=a}}else G(this,function(o){var a=o[r][e];(a.event||(a.event=ra.dispatch("start","end","interrupt"))).on(n,t)});return this},Cu.transition=function(){for(var n,t,e,r=this.id,o=++Lu,a=this.namespace,i=[],u=0,s=this.length;s>u;u++){i.push(n=[]);for(var l=this[u],c=0,f=l.length;f>c;c++)(t=l[c])&&(e=t[a][r],Zo(t,c,a,o,{time:e.time,ease:e.ease,delay:e.delay+e.duration,duration:e.duration})),n.push(t)}return Xo(i,a,o)},ra.svg.axis=function(){function n(n){n.each(function(){var n,l=ra.select(this),c=this.__chart__||e,f=this.__chart__=e.copy(),p=null==s?f.ticks?f.ticks.apply(f,u):f.domain():s,h=null==t?f.tickFormat?f.tickFormat.apply(f,u):w:t,d=l.selectAll(".tick").data(p,f),m=d.enter().insert("g",".domain").attr("class","tick").style("opacity",Ra),v=ra.transition(d.exit()).style("opacity",Ra).remove(),g=ra.transition(d.order()).style("opacity",1),y=Math.max(o,0)+i,b=oo(f),x=l.selectAll(".domain").data([0]),M=(x.enter().append("path").attr("class","domain"),ra.transition(x));m.append("line"),m.append("text");var k,_,S,A,T=m.select("line"),E=g.select("line"),R=d.select("text").text(h),P=m.select("text"),N=g.select("text"),O="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(n=Jo,k="x",S="y",_="x2",A="y2",R.attr("dy",0>O?"0em":".71em").style("text-anchor","middle"),M.attr("d","M"+b[0]+","+O*a+"V0H"+b[1]+"V"+O*a)):(n=$o,k="y",S="x",_="y2",A="x2",R.attr("dy",".32em").style("text-anchor",0>O?"end":"start"),M.attr("d","M"+O*a+","+b[0]+"H0V"+b[1]+"H"+O*a)),T.attr(A,O*o),P.attr(S,O*y),E.attr(_,0).attr(A,O*o),N.attr(k,0).attr(S,O*y),f.rangeBand){var C=f,L=C.rangeBand()/2;c=f=function(n){return C(n)+L}}else c.rangeBand?c=f:v.call(n,f,c);m.call(n,c,f),g.call(n,f,f)})}var t,e=ra.scale.linear(),r=Uu,o=6,a=6,i=3,u=[10],s=null;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in Du?t+"":Uu,n):r},n.ticks=function(){return arguments.length?(u=aa(arguments),n):u},n.tickValues=function(t){return arguments.length?(s=t,n):s},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t){var e=arguments.length;return e?(o=+t,a=+arguments[e-1],n):o},n.innerTickSize=function(t){return arguments.length?(o=+t,n):o},n.outerTickSize=function(t){return arguments.length?(a=+t,n):a},n.tickPadding=function(t){return arguments.length?(i=+t,n):i},n.tickSubdivide=function(){return arguments.length&&n},n};var Uu="bottom",Du={top:1,right:1,bottom:1,left:1};ra.svg.brush=function(){function n(a){a.each(function(){var a=ra.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",o).on("touchstart.brush",o),i=a.selectAll(".background").data([0]);i.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),a.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var u=a.selectAll(".resize").data(m,w);u.exit().remove(),u.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return zu[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),u.style("display",n.empty()?"none":null);var s,f=ra.transition(a),p=ra.transition(i);l&&(s=oo(l),p.attr("x",s[0]).attr("width",s[1]-s[0]),e(f)),c&&(s=oo(c),p.attr("y",s[0]).attr("height",s[1]-s[0]),r(f)),t(f)})}function t(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+f[+/e$/.test(n)]+","+p[+/^s/.test(n)]+")"})}function e(n){n.select(".extent").attr("x",f[0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1]-f[0])}function r(n){n.select(".extent").attr("y",p[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",p[1]-p[0])}function o(){function o(){var n=ra.mouse(b),o=!1;y&&(n[0]+=y[0],n[1]+=y[1]),A||(ra.event.altKey?(g||(g=[(f[0]+f[1])/2,(p[0]+p[1])/2]),R[0]=f[+(n[0]c?(o=r,r=c):o=c),m[0]!=r||m[1]!=o?(e?u=null:a=null,m[0]=r,m[1]=o,!0):void 0}function v(){o(),w.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),ra.select("body").style("cursor",null),P.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),T(),M({type:"brushend"})}var g,y,b=this,x=ra.select(ra.event.target),M=s.of(b,arguments),w=ra.select(b),k=x.datum(),_=!/^(n|s)$/.test(k)&&l,S=!/^(e|w)$/.test(k)&&c,A=x.classed("extent"),T=$(b),R=ra.mouse(b),P=ra.select(i(b)).on("keydown.brush",function(){32==ra.event.keyCode&&(A||(g=null,R[0]-=f[1],R[1]-=p[1],A=2),E())}).on("keyup.brush",function(){32==ra.event.keyCode&&2==A&&(R[0]+=f[1],R[1]+=p[1],A=0,E())});if(ra.event.changedTouches?P.on("touchmove.brush",o).on("touchend.brush",v):P.on("mousemove.brush",o).on("mouseup.brush",v),w.interrupt().selectAll("*").interrupt(),A)R[0]=f[0]-R[0],R[1]=p[0]-R[1];else if(k){var N=+/w$/.test(k),O=+/^n/.test(k);y=[f[1-N]-R[0],p[1-O]-R[1]],R[0]=f[N],R[1]=p[O]}else ra.event.altKey&&(g=R.slice());w.style("pointer-events","none").selectAll(".resize").style("display",null),ra.select("body").style("cursor",x.style("cursor")),M({type:"brushstart"}),o()}var a,u,s=P(n,"brushstart","brush","brushend"),l=null,c=null,f=[0,0],p=[0,0],h=!0,d=!0,m=Fu[0];return n.event=function(n){n.each(function(){var n=s.of(this,arguments),t={x:f,y:p,i:a,j:u},e=this.__chart__||t;this.__chart__=t,Pu?ra.select(this).transition().each("start.brush",function(){a=e.i,u=e.j,f=e.x,p=e.y,n({type:"brushstart"})}).tween("brush:brush",function(){var e=nr(f,t.x),r=nr(p,t.y);return a=u=null,function(o){f=t.x=e(o),p=t.y=r(o),n({type:"brush",mode:"resize"})}}).each("end.brush",function(){a=t.i,u=t.j,n({type:"brush",mode:"resize"}),n({type:"brushend"})}):(n({type:"brushstart"}),n({type:"brush",mode:"resize"}),n({type:"brushend"}))})},n.x=function(t){return arguments.length?(m=Fu[!(l=t)<<1|!c],n):l},n.y=function(t){return arguments.length?(m=Fu[!l<<1|!(c=t)],n):c},n.clamp=function(t){return arguments.length?(l&&c?(h=!!t[0],d=!!t[1]):l?h=!!t:c&&(d=!!t),n):l&&c?[h,d]:l?h:c?d:null},n.extent=function(t){var e,r,o,i,s;return arguments.length?(l&&(e=t[0],r=t[1],c&&(e=e[0],r=r[0]),a=[e,r],l.invert&&(e=l(e),r=l(r)),e>r&&(s=e,e=r,r=s),(e!=f[0]||r!=f[1])&&(f=[e,r])),c&&(o=t[0],i=t[1],l&&(o=o[1],i=i[1]),u=[o,i],c.invert&&(o=c(o),i=c(i)),o>i&&(s=o,o=i,i=s),(o!=p[0]||i!=p[1])&&(p=[o,i])),n):(l&&(a?(e=a[0],r=a[1]):(e=f[0],r=f[1],l.invert&&(e=l.invert(e),r=l.invert(r)),e>r&&(s=e,e=r,r=s))),c&&(u?(o=u[0],i=u[1]):(o=p[0],i=p[1],c.invert&&(o=c.invert(o),i=c.invert(i)),o>i&&(s=o,o=i,i=s))),l&&c?[[e,o],[r,i]]:l?[e,r]:c&&[o,i])},n.clear=function(){return n.empty()||(f=[0,0],p=[0,0],a=u=null),n},n.empty=function(){return!!l&&f[0]==f[1]||!!c&&p[0]==p[1]},ra.rebind(n,s,"on")};var zu={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Fu=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],qu=oi.format=ci.timeFormat,ju=qu.utc,Bu=ju("%Y-%m-%dT%H:%M:%S.%LZ");qu.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Ko:Bu,Ko.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},Ko.toString=Bu.toString,oi.second=zn(function(n){return new ai(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),oi.seconds=oi.second.range,oi.seconds.utc=oi.second.utc.range,oi.minute=zn(function(n){return new ai(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),oi.minutes=oi.minute.range,oi.minutes.utc=oi.minute.utc.range,oi.hour=zn(function(n){var t=n.getTimezoneOffset()/60;return new ai(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),oi.hours=oi.hour.range,oi.hours.utc=oi.hour.utc.range,oi.month=zn(function(n){return(n=oi.day(n)).setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),oi.months=oi.month.range,oi.months.utc=oi.month.utc.range;var Iu=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Hu=[[oi.second,1],[oi.second,5],[oi.second,15],[oi.second,30],[oi.minute,1],[oi.minute,5],[oi.minute,15],[oi.minute,30],[oi.hour,1],[oi.hour,3],[oi.hour,6],[oi.hour,12],[oi.day,1],[oi.day,2],[oi.week,1],[oi.month,1],[oi.month,3],[oi.year,1]],Vu=qu.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",_t]]),Xu={range:function(n,t,e){return ra.range(Math.ceil(n/e)*e,+t,e).map(na)},floor:w,ceil:w};Hu.year=oi.year,oi.scale=function(){return Qo(ra.scale.linear(),Hu,Vu)};var Gu=Hu.map(function(n){return[n[0].utc,n[1]]}),Yu=ju.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",_t]]);Gu.year=oi.year.utc,oi.scale.utc=function(){return Qo(ra.scale.linear(),Gu,Yu)},ra.text=En(function(n){return n.responseText}),ra.json=function(n,t){return Rn(n,"application/json",ta,t)},ra.html=function(n,t){return Rn(n,"text/html",ea,t)},ra.xml=En(function(n){return n.responseXML}),this.d3=ra,void 0===(o="function"==typeof(r=ra)?r.call(t,e,t,n):r)||(n.exports=o)}()},function(n,t,e){var r=e(3);"string"==typeof r&&(r=[[n.id,r,""]]),e(5)(r,{}),r.locals&&(n.exports=r.locals)},function(n,t,e){(n.exports=e(4)()).push([n.id,"svg {\n display: block;\n min-width: 100%;\n width: 100%;\n min-height: 100%;\n}\n\ncircle.node {\n stroke: #ccc;\n stroke-width: 1px;\n opacity: 1;\n fill: white;\n}\n\npolygon.node {\n stroke: #ccc;\n stroke-width: 1px;\n opacity: 1;\n fill: white;\n}\n\ncircle.node.label {\n stroke: transparent;\n stroke-width: 0;\n fill: white;\n display: inline;\n}\n\ncircle.outline_node {\n stroke-width: 1px;\n fill: red;\n}\n\ncircle.protein {\n fill: gray;\n fill-opacity: 0.5;\n stroke-width: 4;\n}\n\ncircle.hidden_outline {\n stroke-width: 0px;\n}\n\n\nline.link {\n stroke: #999;\n stroke-opacity: 0.8;\n stroke-width: 2;\n}\n\nline.pseudoknot {\n stroke: red;\n}\n\nline.basepair {\n stroke: red;\n}\n\nline.intermolecule {\n stroke: blue;\n}\n\nline.chain_chain {\n stroke-dasharray: 3,3;\n}\n\nline.fake {\n stroke: green;\n}\n\n.transparent {\n fill: transparent;\n stroke-width: 0;\n stroke-opacity: 0;\n opacity: 0;\n visibility: hidden;\n}\n\n.drag_line {\n stroke: #999;\n stroke-width: 2;\n pointer-events: none;\n}\n\n.drag_line_hidden {\n stroke: #999;\n stroke-width: 0;\n pointer-events: none;\n}\n\n.d3-tip {\n line-height: 1;\n font-weight: bold;\n padding: 6px;\n background: rgba(0, 0, 0, 0.6);\n color: #fff;\n border-radius: 4px;\n pointer-events: none;\n }\n\ntext.node-label {\n font-weight: bold;\n font-family: Tahoma, Geneva, sans-serif;\n color: rgb(100,100,100);\n pointer-events: none;\n}\n\ntext {\n pointer-events: none;\n}\n\ng.gnode {\n\n}\n\ncircle.outline_node.selected {\n visibility: visible;\n}\n\ncircle.outline_node {\n visibility: hidden;\n}\n\n.brush .extent {\n fill-opacity: .1;\n stroke: #fff;\n shape-rendering: crispEdges;\n}\n\n.noselect {\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -khtml-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n",""])},function(n,t){n.exports=function(){var n=[];return n.toString=function(){for(var n=[],t=0;t=0&&g.splice(t,1)}function u(n){var t=document.createElement("style");return t.type="text/css",a(n,t),t}function s(n){var t=document.createElement("link");return t.rel="stylesheet",a(n,t),t}function l(n,t){var e,r,o;if(t.singleton){var a=v++;e=m||(m=u(t)),r=c.bind(null,e,a,!1),o=c.bind(null,e,a,!0)}else n.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(e=s(t),r=function(n,t){var e=t.css,r=(t.media,t.sourceMap);r&&(e+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var o=new Blob([e],{type:"text/css"}),a=n.href;n.href=URL.createObjectURL(o),a&&URL.revokeObjectURL(a)}.bind(null,e),o=function(){i(e),e.href&&URL.revokeObjectURL(e.href)}):(e=u(t),r=function(n,t){var e=t.css,r=t.media;if(t.sourceMap,r&&n.setAttribute("media",r),n.styleSheet)n.styleSheet.cssText=e;else{for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(document.createTextNode(e))}}.bind(null,e),o=function(){i(e)});return r(n),function(t){if(t){if(t.css===n.css&&t.media===n.media&&t.sourceMap===n.sourceMap)return;r(n=t)}else o()}}function c(n,t,e,r){var o=e?"":r.css;if(n.styleSheet)n.styleSheet.cssText=y(t,o);else{var a=document.createTextNode(o),i=n.childNodes;i[t]&&n.removeChild(i[t]),i.length?n.insertBefore(a,i[t]):n.appendChild(a)}}var f={},p=function(n){var t;return function(){return void 0===t&&(t=n.apply(this,arguments)),t}},h=p(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),d=p(function(){return document.head||document.getElementsByTagName("head")[0]}),m=null,v=0,g=[];n.exports=function(n,t){void 0===(t=t||{}).singleton&&(t.singleton=h()),void 0===t.insertAt&&(t.insertAt="bottom");var e=o(n);return r(e,t),function(n){for(var a=[],i=0;i0&&"*"==a.dotbracket[a.dotbracket.length-1]&&(a.dotbracket=a.dotbracket.slice(0,a.dotbracket.length-1),a.circular=!0),a.uid=r(),a.elements=[],a.pseudoknotPairs=[],a.nucsToNodes={},a.addUids=function(n){for(var t=a.nodes.filter(function(n){return"nucleotide"==n.nodeType}),e=0;e=0;)t.push(e),n=n.substring(0,e)+"oo"+n.substring(e+1,n.length);return{targetString:n,breaks:t}};var s=a.removeBreaks(a.dotbracket);a.dotbracket=s.targetString,a.dotBracketBreaks=s.breaks,s=a.removeBreaks(a.seq),a.seq=s.targetString,a.seqBreaks=s.breaks,a.calculateStartNumberArray=function(){a.startNumberArray=[];for(var n=0;n=0&&(e=!0);e?a.elements[t][2].map(function(n){0!=n&&(a.nodes[n-1].elemType="e")}):a.elements[t][2].map(function(n){0!=n&&(a.nodes[n-1].elemType=a.elements[t][0])})}return a},a.getPositions=function(n){for(var t=[],e=a.nodes.filter(function(t){return t.nodeType==n}),r=0;r=4}),e=0;ea.dotbracket.length)){a.links.push({source:a.nodes[n[f]-1],target:a.nodes[a.nodes.length-1],linkType:"fake",value:e,uid:r()}),n.length>4&&a.links.push({source:a.nodes[n[f]-1],target:a.nodes[n[(f+Math.floor(n.length/2))%n.length]-1],linkType:"fake",value:2*e,uid:r()});var p=3.14159*(n.length-2)/n.length,h=2*Math.cos(1.570795-p/2);a.links.push({source:a.nodes[n[f]-1],target:a.nodes[n[(f+2)%n.length]-1],linkType:"fake",value:h});var d=a.nodes[n[f]-1];"x"in d&&(s+=d.x,l+=d.y,c+=1)}return c>0&&(u.x=s/c,u.y=l/c,u.px=u.x,u.py=u.y),a},a.connectFakeNodes=function(){for(var n={},t=a.nodes.filter(function(n){return"middle"==n.nodeType}),e=new Set,r=1;r<=a.nodes.length;r++)n[r]=[];for(var r=0;r=0||a.dotBracketBreaks.indexOf(e-2)>=0)&&(u=""),a.nodes.push({name:u,num:e+a.startNumberArray[e-1]-1,radius:5,rna:a,nodeType:"nucleotide",structName:a.structName,elemType:t[e],uid:r(),linked:!1})}for(var e=0;e1&&-1===a.dotBracketBreaks.indexOf(e-1)&&-1==a.dotBracketBreaks.indexOf(e-2)&&-1==a.dotBracketBreaks.indexOf(e-3)&&(a.links.push({source:a.nodes[e-2],target:a.nodes[e-1],linkType:"backbone",value:1,uid:r()}),a.nodes[e-1].linked=!0);for(var e=0;er)return[];for(;0===n[e];e++)i.push(e);for(;0===n[r];r--)s.push(r);if(e>r){if(i.push(e),0===t)return[["e",t,i.sort(u)]];for(var l=!1,c=[],f=[],p=0;p=0&&(l=!0);return[["h",t,i.sort(u)]]}if(n[e]!=r){var h=i,p=e;for(h.push(p);r>=p;){for(o=o.concat(a.ptToElements(n,t,p,n[p])),h.push(n[p]),p=n[p]+1;0===n[p]&&r>=p;p++)h.push(p);h.push(p)}return h.pop(),(h=h.concat(s)).length>0&&(0===t?o.push(["e",t,h.sort(u)]):o.push(["m",t,h.sort(u)])),o}if(n[e]===r){i.push(e),s.push(r);var d=i.concat(s);d.length>4&&(0===t?o.push(["e",t,i.concat(s).sort(u)]):o.push(["i",t,i.concat(s).sort(u)]))}for(var m=[];n[e]===r&&r>e;)m.push(e),m.push(r),e+=1,r-=1,t+=1;return i=[e-1],s=[r+1],o.push(["s",t,m.sort(u)]),o.concat(a.ptToElements(n,t,e,r))},a.addLabels=function(n,t){if(0===arguments.length&&(n=1,t=10),1===arguments.length&&(t=10),0===t)return a;0>=t&&console.log("The label interval entered in invalid:",t);for(var e=1;e<=a.pairtable[0];e++)if(e%t==0){var o,i,u,s,l=a.nodes[e-1];1==a.rnaLength?(s=[l.x-15,l.y],u=[l.x-15,l.y]):(o=1==e?a.nodes[a.rnaLength-1]:a.nodes[e-2],i=e==a.rnaLength?a.nodes[0]:a.nodes[e],0!==a.pairtable[i.num]&&0!==a.pairtable[o.num]&&0!==a.pairtable[l.num]&&(o=i=a.nodes[a.pairtable[l.num]-1]),0===a.pairtable[l.num]||0!==a.pairtable[i.num]&&0!==a.pairtable[o.num]?(s=[i.x-l.x,i.y-l.y],u=[o.x-l.x,o.y-l.y]):(s=[l.x-i.x,l.y-i.y],u=[l.x-o.x,l.y-o.y]));var c=[s[0]+u[0],s[1]+u[1]],f=Math.sqrt(c[0]*c[0]+c[1]*c[1]),p=[c[0]/f,c[1]/f],h=[-15*p[0],-15*p[1]],d=a.nodes[e-1].x+h[0],m=a.nodes[e-1].y+h[1],v={name:e+a.startNumberArray[e-1]-1,num:-1,radius:6,rna:a,nodeType:"label",structName:a.structName,elemType:"l",x:d,y:m,px:d,py:m,uid:r()},g={source:a.nodes[e-1],target:v,value:1,linkType:"label_link",uid:r()};a.nodes.push(v),a.links.push(g)}return a},a.recalculateElements=function(){if(a.removePseudoknots(),a.elements=a.ptToElements(a.pairtable,0,1,a.dotbracket.length),a.circular&&(externalLoop=a.elements.filter(function(n){return"e"==n[0]||void 0}),externalLoop.length>0)){eloop=externalLoop[0],nucs=eloop[2].sort(u),prev=nucs[0],hloop=!0,numGreater=0;for(var n=1;n1&&(numGreater+=1),prev=nucs[n];1==numGreater?eloop[0]="h":2==numGreater?eloop[0]="i":eloop[0]="m"}return a},a.reassignLinkUids=function(){for(var n=0;n1&&(a.pseudoknotPairs=a.pseudoknotPairs.concat(i.rnaUtilities.removePseudoknotsFromPairtable(a.pairtable))),a},a.addPseudoknots=function(){for(var n=a.pairtable,t=a.pseudoknotPairs,e=0;e0&&a.recalculateElements()}Object.defineProperty(t,"__esModule",{value:!0}),t.ProteinGraph=o,t.RNAGraph=a,t.moleculesToJson=function(n){for(var t={},e=[],i=[],u=0;uabcdefghijklmnopqrstuvwxyz".split(""),n.inverseBrackets=function(n){for(var t={},e=0;e=r;r++){e[r]=new Array(t+1);for(var o=r;t>=o;o++)e[r][o]=0}for(var a=0,r=t-0-1;r>0;r--)for(var o=r+0+1;t>=o;o++){a=e[r][o-1];for(var i=o-0-1;i>=r;i--)n[i]===o&&(a=Math.max(a,(i>r?e[r][i-1]:0)+1+(o-i-1>0?e[i+1][o-1]:0)));e[r][o]=a}return a=e[1][t],e},n.backtrackMaximumMatching=function(t,e){var r=Array.apply(null,Array(t.length)).map(function(){return 0});return n.mmBt(t,r,e,1,t.length-1),r},n.mmBt=function(t,e,r,o,a){var i=t[o][a];if(!(0>a-o-1)){if(t[o][a-1]==i)return void n.mmBt(t,e,r,o,a-1);for(var u=a-0-1;u>=o;u--)if(r[a]===u){var s=u>o?t[o][u-1]:0,l=a-u-1>0?t[u+1][a-1]:0;if(s+l+1==i)return e[u]=a,e[a]=u,u>o&&n.mmBt(t,e,r,o,u-1),void n.mmBt(t,e,r,u+1,a-1)}console.log("FAILED!!!"+o+","+a+": backtracking failed!")}},n.dotbracketToPairtable=function(t){var e=Array.apply(null,new Array(t.length+1)).map(Number.prototype.valueOf,0);e[0]=t.length;for(var r={},o=0;o0)throw"Unmatched base at position "+r[c][0];return e},n.insertIntoStack=function(n,t,e){for(var r=0;n[r].length>0&&n[r][n[r].length-1]r?n.bracketLeft[n.insertIntoStack(e,r,t[r])]:n.bracketRight[n.deleteFromStack(e,r)]}return a},n.findUnmatched=function(t,e,r){for(var o=[],a=[],i=e,u=r,s=e;r>=s;s++)0!==t[s]&&(t[s]r)&&a.push([s,t[s]]);for(var s=i;u>=s;s++){for(;0===t[s]&&u>=s;)s++;for(r=t[s];t[s]===r;)s++,r--;o=o.concat(n.findUnmatched(t,s,r))}return a.length>0&&o.push(a),o},n.removePseudoknotsFromPairtable=function(t){for(var e=n.maximumMatching(t),r=n.backtrackMaximumMatching(e,t),o=[],a=1;aa)return[];for(;0===t[o];o++)s.push(o);for(;0===t[a];a--)l.push(a);if(o>a){if(s.push(o),0===e)return[["e",e,s.sort(r)]];for(var c=!1,f=[],p=[],h=0;h=0&&(c=!0);return[["h",e,s.sort(r)]]}if(t[o]!=a){var d=s,h=o;for(d.push(h);a>=h;){for(u=u.concat(n.ptToElements(t,e,h,t[h],i)),d.push(t[h]),h=t[h]+1;0===t[h]&&a>=h;h++)d.push(h);d.push(h)}return d.pop(),(d=d.concat(l)).length>0&&(0===e?u.push(["e",e,d.sort(r)]):u.push(["m",e,d.sort(r)])),u}if(t[o]===a){s.push(o),l.push(a);var m=s.concat(l);m.length>4&&(0===e?u.push(["e",e,s.concat(l).sort(r)]):u.push(["i",e,s.concat(l).sort(r)]))}for(var v=[];t[o]===a&&a>o;)v.push(o),v.push(a),o+=1,a-=1,e+=1;return s=[o-1],l=[a+1],u.push(["s",e,v.sort(r)]),u.concat(n.ptToElements(t,e,o,a,i))}}Object.defineProperty(t,"__esModule",{value:!0}),t.arraysEqual=function(n,t){if(n===t)return!0;if(null===n||null===t)return!1;if(n.length!=t.length)return!1;for(var e=0;e=u;u++)e.push(u);else console.log("Malformed range (too many dashes):",n)}return e},t.parseColorText=function(n){for(var e=n.split("\n"),r="",o=1,a={colorValues:{"":{}},range:["white","steelblue"]},i=[],u=0;u"!=e[u][0])for(var s=e[u].trim().split(/[\s]+/),l=0;ln&&(r=n),n>o&&(o=n));for(a in t.colorsJson.colorValues[e])"number"==typeof(n=t.colorsJson.colorValues[e][a])&&(t.colorsJson.colorValues[e][a]=(n-r)/(o-r))}return t},t.parseColorText(t.colorsText),t};var r=function(n,t){return n-t};t.rnaUtilities=new e}])},function(n,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.simpleXyCoordinates=function(n){var t,e,r,o=[],a=[];e=n[0];var i=Array.apply(null,new Array(e+5)).map(Number.prototype.valueOf,0),u=Array.apply(null,new Array(16+Math.floor(e/5))).map(Number.prototype.valueOf,0),s=Array.apply(null,new Array(16+Math.floor(e/5))).map(Number.prototype.valueOf,0),l=0,c=0,f=Math.PI/2;(function n(t,e,r){var o,a,p,h,d,m,v,g,y,b,x,M,w=2,k=0,_=0,S=Array.apply(null,new Array(3+2*Math.floor((e-t)/5))).map(Number.prototype.valueOf,0);for(o=t-1,e++;t!=e;)if((a=r[t])&&0!=t){w+=2,p=t,h=a,S[++k]=p,S[++k]=h,t=a+1,d=p,m=h,g=0;do{p++,h--,g++}while(r[p]==h&&r[p]>p);if(v=g-2,g>=2&&(i[d+1+v]+=f,i[m-1-v]+=f,i[d]+=f,i[m]+=f,g>2))for(;v>=1;v--)i[d+v]=Math.PI,i[m-v]=Math.PI;s[++c]=g,h>=p&&n(p,h,r)}else t++,w++,_++;for(M=Math.PI*(w-2)/w,S[++k]=e,y=0>o?0:o,b=1;k>=b;b++){for(x=S[b]-y,v=0;x>=v;v++)i[y+v]+=M;if(b>k)break;y=S[++b]}u[++l]=_})(0,e+1,n),u[l]-=2,r=0,o[0]=100,a[0]=100;var p=[];for(p.push([o[0],a[0]]),t=1;e>t;t++)o[t]=o[t-1]+15*Math.cos(r),a[t]=a[t-1]+15*Math.sin(r),p.push([o[t],a[t]]),r+=Math.PI-i[t+1];return p}}])},function(n,t,e){"use strict";var r=e(24);function o(){}n.exports=function(){function n(n,t,e,o,a,i){if(i!==r){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function t(){return n}n.isRequired=n;var e={array:n,bool:n,func:n,number:n,object:n,string:n,symbol:n,any:n,arrayOf:t,element:n,instanceOf:t,node:n,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return e.checkPropTypes=o,e.PropTypes=e,e}},function(n,t,e){"use strict";n.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(n,t,e){"use strict";var r=e(7),o=e(26),a=e(27),i=e(6),u=e(8),s=e(21),l=e(28);function c(n,t){return t=t.split("// __split__"),new o.Program(n,t[0],t[1])}n.exports=function(n,t,e){var f,p,h,d,m,v,g,y,b,x,M,w,k,_,S,A,T,E,R,P,N,O,C,L,U,D,z,F=this,q=null,j=null,B=null,I=null,H=null,V=null,X=0,G=!1,Y=!1;function W(n){h.viewport(0,0,e,e);var o=u.clone(n);o.zoom=1/f,o.translation.x=0,o.translation.y=0;for(var a=r.mat4.create(),i=0;i<3;i++){var s=r.vec3.random(r.vec3.create(),1);r.mat4.rotate(a,a,10*Math.random(),s)}o.rotation=r.mat4.multiply(r.mat4.create(),a,o.rotation),T.bind(),h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT);var l=u.getRect(o),c=r.mat4.create();r.mat4.ortho(c,l.left,l.right,l.bottom,l.top,0,f);var p=r.mat4.create();r.mat4.lookAt(p,[0,0,0],[0,0,-1],[0,1,0]);var d=r.mat4.create();r.mat4.translate(d,d,[0,0,-f/2]),r.mat4.multiply(d,d,o.rotation),N.setUniform("uProjection","Matrix4fv",!1,c),N.setUniform("uView","Matrix4fv",!1,p),N.setUniform("uModel","Matrix4fv",!1,d),N.setUniform("uBottomLeft","2fv",[l.left,l.bottom]),N.setUniform("uTopRight","2fv",[l.right,l.top]),N.setUniform("uAtomScale","1f",2.5*o.atomScale),N.setUniform("uRelativeAtomScale","1f",n.relativeAtomScale),N.setUniform("uRes","1f",e),N.setUniform("uDepth","1f",f),N.setUniform("uMode","1i",0),N.setUniform("uAtomShade","1f",n.atomShade),q.render(),n.bonds&&null!=j&&(O.setUniform("uProjection","Matrix4fv",!1,c),O.setUniform("uView","Matrix4fv",!1,p),O.setUniform("uModel","Matrix4fv",!1,d),O.setUniform("uRotation","Matrix4fv",!1,o.rotation),O.setUniform("uDepth","1f",f),O.setUniform("uBottomLeft","2fv",[l.left,l.bottom]),O.setUniform("uTopRight","2fv",[l.right,l.top]),O.setUniform("uRes","1f",e),O.setUniform("uBondRadius","1f",2.5*u.getBondRadius(n)),O.setUniform("uBondShade","1f",n.bondShade),O.setUniform("uAtomScale","1f",2.5*n.atomScale),O.setUniform("uRelativeAtomScale","1f",n.relativeAtomScale),O.setUniform("uMode","1i",0),j.render()),h.viewport(0,0,t,t);var y=u.getRect(n),x=u.getRect(o),M=r.mat4.invert(r.mat4.create(),a);E.bind(),h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT),C.setUniform("uSceneDepth","1i",v.index),C.setUniform("uSceneNormal","1i",m.index),C.setUniform("uRandRotDepth","1i",g.index),C.setUniform("uAccumulator","1i",b.index),C.setUniform("uSceneBottomLeft","2fv",[y.left,y.bottom]),C.setUniform("uSceneTopRight","2fv",[y.right,y.top]),C.setUniform("uRotBottomLeft","2fv",[x.left,x.bottom]),C.setUniform("uRotTopRight","2fv",[x.right,x.top]),C.setUniform("uRes","1f",t),C.setUniform("uDepth","1f",f),C.setUniform("uRot","Matrix4fv",!1,a),C.setUniform("uInvRot","Matrix4fv",!1,M),C.setUniform("uSampleCount","1i",X),B.render(),b.activate(),b.bind(),h.copyTexImage2D(h.TEXTURE_2D,0,h.RGBA,0,0,t,t,0)}F.getAOProgress=function(){return X/1024},F.initialize=function(){n.width=n.height=t,(h=n.getContext("webgl")).enable(h.DEPTH_TEST),h.enable(h.CULL_FACE),h.clearColor(0,0,0,0),h.clearDepth(1),h.viewport(0,0,t,t),window.gl=h,o.getExtensions(h,["EXT_frag_depth","WEBGL_depth_texture"]),F.createTextures(),N=c(h,l.shaders.atom),O=c(h,l.shaders.bond),z=c(h,l.shaders["textured-quad"]),C=c(h,l.shaders.accumulator),L=c(h,l.shaders.ao),U=c(h,l.shaders.fxaa),D=c(h,l.shaders.dof);var e=[-1,-1,0,1,-1,0,1,1,0,-1,-1,0,1,1,0,-1,1,0],r=o.buildAttribs(h,{aPosition:3});r.aPosition.buffer.set(new Float32Array(e));var a=e.length/9;new o.Renderable(h,z,r,a),B=new o.Renderable(h,C,r,a),I=new o.Renderable(h,L,r,a),V=new o.Renderable(h,U,r,a),H=new o.Renderable(h,D,r,a),0},F.createTextures=function(){y=new o.Texture(h,0,null,e,e),g=new o.Texture(h,1,null,e,e,{internalFormat:h.DEPTH_COMPONENT,format:h.DEPTH_COMPONENT,type:h.UNSIGNED_SHORT}),T=new o.Framebuffer(h,[y],g),d=new o.Texture(h,2,null,t,t),m=new o.Texture(h,3,null,t,t),v=new o.Texture(h,4,null,t,t,{internalFormat:h.DEPTH_COMPONENT,format:h.DEPTH_COMPONENT,type:h.UNSIGNED_SHORT}),S=new o.Framebuffer(h,[d],v),A=new o.Framebuffer(h,[m],v),b=new o.Texture(h,5,null,t,t),x=new o.Texture(h,6,null,t,t),E=new o.Framebuffer(h,[x]),_=new o.Texture(h,7,null,t,t),P=new o.Framebuffer(h,[_]),M=new o.Texture(h,8,null,t,t),w=new o.Texture(h,9,null,t,t),R=new o.Framebuffer(h,[w]),k=new o.Texture(h,10,null,t,t),new o.Framebuffer(h,[k])},F.setResolution=function(r,o){e=o,t=r,n.width=n.height=t,h.viewport(0,0,t,t),F.createTextures()},F.setSystem=function(n,t){function e(n){for(var t=[],e=0;e<36;e++)t.push.apply(t,n);return t}p=n;for(var r=o.buildAttribs(h,{aImposter:3,aPosition:3,aRadius:1,aColor:3}),u=[],s=[],l=[],c=[],f=0;f0)){r=o.buildAttribs(h,{aImposter:3,aPosA:3,aPosB:3,aRadA:1,aRadB:1,aColA:3,aColB:3}),u=[];var g=[],y=[],b=[],x=[],M=[],w=[];for(f=0;ft.bondThreshold)break;u.push.apply(u,a.position),g.push.apply(g,e([k.posA.x,k.posA.y,k.posA.z])),y.push.apply(y,e([k.posB.x,k.posB.y,k.posB.z])),b.push.apply(b,e([k.radA])),x.push.apply(x,e([k.radB])),M.push.apply(M,e([k.colA.r,k.colA.g,k.colA.b])),w.push.apply(w,e([k.colB.r,k.colB.g,k.colB.b]))}r.aImposter.buffer.set(new Float32Array(u)),r.aPosA.buffer.set(new Float32Array(g)),r.aPosB.buffer.set(new Float32Array(y)),r.aRadA.buffer.set(new Float32Array(b)),r.aRadB.buffer.set(new Float32Array(x)),r.aColA.buffer.set(new Float32Array(M)),r.aColB.buffer.set(new Float32Array(w));v=u.length/9;j=new o.Renderable(h,O,r,v)}},F.reset=function(){X=0,G=!1,Y=!1,b.reset(),x.reset()},F.render=function(n){if(void 0!==p&&null!=q){if(f=2*s.getRadius(p),G)if(Y)for(var e=0;e1024);e++)W(n),X++;else!function(n){Y=!0,h.viewport(0,0,t,t),A.bind(),h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT);var e=u.getRect(n),o=r.mat4.create();r.mat4.ortho(o,e.left,e.right,e.bottom,e.top,0,f);var a=r.mat4.create();r.mat4.lookAt(a,[0,0,0],[0,0,-1],[0,1,0]);var i=r.mat4.create();r.mat4.translate(i,i,[0,0,-f/2]),r.mat4.multiply(i,i,n.rotation),N.setUniform("uProjection","Matrix4fv",!1,o),N.setUniform("uView","Matrix4fv",!1,a),N.setUniform("uModel","Matrix4fv",!1,i),N.setUniform("uBottomLeft","2fv",[e.left,e.bottom]),N.setUniform("uTopRight","2fv",[e.right,e.top]),N.setUniform("uAtomScale","1f",2.5*n.atomScale),N.setUniform("uRelativeAtomScale","1f",n.relativeAtomScale),N.setUniform("uRes","1f",t),N.setUniform("uDepth","1f",f),N.setUniform("uMode","1i",1),N.setUniform("uAtomShade","1f",n.atomShade),q.render(),n.bonds&&null!=j&&(A.bind(),O.setUniform("uProjection","Matrix4fv",!1,o),O.setUniform("uView","Matrix4fv",!1,a),O.setUniform("uModel","Matrix4fv",!1,i),O.setUniform("uRotation","Matrix4fv",!1,n.rotation),O.setUniform("uDepth","1f",f),O.setUniform("uBottomLeft","2fv",[e.left,e.bottom]),O.setUniform("uTopRight","2fv",[e.right,e.top]),O.setUniform("uRes","1f",t),O.setUniform("uBondRadius","1f",2.5*u.getBondRadius(n)),O.setUniform("uBondShade","1f",n.bondShade),O.setUniform("uAtomScale","1f",2.5*n.atomScale),O.setUniform("uRelativeAtomScale","1f",n.relativeAtomScale),O.setUniform("uMode","1i",1),j.render())}(n);else!function(n){G=!0,h.viewport(0,0,t,t),S.bind(),h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT);var e=u.getRect(n),o=r.mat4.create();r.mat4.ortho(o,e.left,e.right,e.bottom,e.top,0,f);var a=r.mat4.create();r.mat4.lookAt(a,[0,0,0],[0,0,-1],[0,1,0]);var i=r.mat4.create();r.mat4.translate(i,i,[0,0,-f/2]),r.mat4.multiply(i,i,n.rotation),N.setUniform("uProjection","Matrix4fv",!1,o),N.setUniform("uView","Matrix4fv",!1,a),N.setUniform("uModel","Matrix4fv",!1,i),N.setUniform("uBottomLeft","2fv",[e.left,e.bottom]),N.setUniform("uTopRight","2fv",[e.right,e.top]),N.setUniform("uAtomScale","1f",2.5*n.atomScale),N.setUniform("uRelativeAtomScale","1f",n.relativeAtomScale),N.setUniform("uRes","1f",t),N.setUniform("uDepth","1f",f),N.setUniform("uMode","1i",0),N.setUniform("uAtomShade","1f",n.atomShade),q.render(),n.bonds&&null!=j&&(S.bind(),O.setUniform("uProjection","Matrix4fv",!1,o),O.setUniform("uView","Matrix4fv",!1,a),O.setUniform("uModel","Matrix4fv",!1,i),O.setUniform("uRotation","Matrix4fv",!1,n.rotation),O.setUniform("uDepth","1f",f),O.setUniform("uBottomLeft","2fv",[e.left,e.bottom]),O.setUniform("uTopRight","2fv",[e.right,e.top]),O.setUniform("uRes","1f",t),O.setUniform("uBondRadius","1f",2.5*u.getBondRadius(n)),O.setUniform("uBondShade","1f",n.bondShade),O.setUniform("uAtomScale","1f",2.5*n.atomScale),O.setUniform("uRelativeAtomScale","1f",n.relativeAtomScale),O.setUniform("uMode","1i",0),j.render())}(n);!function(n){h.viewport(0,0,t,t),n.fxaa>0||n.dofStrength>0?P.bind():h.bindFramebuffer(h.FRAMEBUFFER,null);if(h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT),L.setUniform("uSceneColor","1i",d.index),L.setUniform("uSceneDepth","1i",v.index),L.setUniform("uAccumulatorOut","1i",x.index),L.setUniform("uRes","1f",t),L.setUniform("uAO","1f",2*n.ao),L.setUniform("uBrightness","1f",2*n.brightness),L.setUniform("uOutlineStrength","1f",n.outline),I.render(),n.fxaa>0){n.dofStrength>0?R.bind():h.bindFramebuffer(h.FRAMEBUFFER,null);for(var e=0;e0&&(h.bindFramebuffer(h.FRAMEBUFFER,null),h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT),n.fxaa>0?D.setUniform("uColor","1i",M.index):D.setUniform("uColor","1i",_.index),D.setUniform("uDepth","1i",v.index),D.setUniform("uDOFPosition","1f",n.dofPosition),D.setUniform("uDOFStrength","1f",n.dofStrength),D.setUniform("uRes","1f",t),H.render())}(n)}},F.initialize()}},function(n,t){function e(n){var t=this;t.initialize=function(){t.buffer=n.createBuffer()},t.bind=function(){n.bindBuffer(n.ARRAY_BUFFER,t.buffer)},t.set=function(e){t.bind(),n.bufferData(n.ARRAY_BUFFER,e,n.STATIC_DRAW)},t.initialize()}n.exports.buildAttribs=function(n,t){var r={};for(var o in t)r[o]={buffer:new e(n),size:t[o]};return r},n.exports.getExtensions=function(n,t){for(var e={},r=0;r1){for(var a=[],i=0;i 0.0) {\n float depth = texture2D(uSceneDepth, p).r;\n float r = 1.0/511.0;\n float d0 = abs(texture2D(uSceneDepth, p + vec2(-r, 0)).r - depth);\n float d1 = abs(texture2D(uSceneDepth, p + vec2( r, 0)).r - depth);\n float d2 = abs(texture2D(uSceneDepth, p + vec2( 0, -r)).r - depth);\n float d3 = abs(texture2D(uSceneDepth, p + vec2( 0, r)).r - depth);\n float d = max(d0, d1);\n d = max(d, d2);\n d = max(d, d3);\n sceneColor.rgb *= pow(1.0 - d, uOutlineStrength * 32.0);\n sceneColor.a = max(step(0.003, d), sceneColor.a);\n }\n vec4 dAccum = texture2D(uAccumulatorOut, p);\n float shade = max(0.0, 1.0 - (dAccum.r + dAccum.g + dAccum.b + dAccum.a) * 0.25 * uAO);\n shade = pow(shade, 2.0);\n gl_FragColor = vec4(uBrightness * sceneColor.rgb * shade, sceneColor.a);\n}\n",atom:"#version 100\nprecision highp float;\n\nattribute vec3 aImposter;\nattribute vec3 aPosition;\nattribute float aRadius;\nattribute vec3 aColor;\n\nuniform mat4 uView;\nuniform mat4 uProjection;\nuniform mat4 uModel;\nuniform float uAtomScale;\nuniform float uRelativeAtomScale;\nuniform float uAtomShade;\n\nvarying vec3 vColor;\nvarying vec3 vPosition;\nvarying float vRadius;\n\nvoid main() {\n vRadius = uAtomScale * (1.0 + (aRadius - 1.0) * uRelativeAtomScale);\n gl_Position = uProjection * uView * uModel * vec4(vRadius * aImposter + aPosition, 1.0);\n vColor = mix(aColor, vec3(1,1,1), uAtomShade);\n vPosition = vec3(uModel * vec4(aPosition, 1));\n}\n\n\n// __split__\n\n\n#version 100\n#extension GL_EXT_frag_depth: enable\nprecision highp float;\n\nuniform vec2 uBottomLeft;\nuniform vec2 uTopRight;\nuniform float uRes;\nuniform float uDepth;\nuniform int uMode;\n\nvarying vec3 vPosition;\nvarying float vRadius;\nvarying vec3 vColor;\n\nvec2 res = vec2(uRes, uRes);\n\nfloat raySphereIntersect(vec3 r0, vec3 rd) {\n float a = dot(rd, rd);\n vec3 s0_r0 = r0 - vPosition;\n float b = 2.0 * dot(rd, s0_r0);\n float c = dot(s0_r0, s0_r0) - (vRadius * vRadius);\n float disc = b*b - 4.0*a*c;\n if (disc <= 0.0) {\n return -1.0;\n }\n return (-b - sqrt(disc))/(2.0*a);\n}\n\nvoid main() {\n vec3 r0 = vec3(uBottomLeft + (gl_FragCoord.xy/res) * (uTopRight - uBottomLeft), 0.0);\n vec3 rd = vec3(0, 0, -1);\n float t = raySphereIntersect(r0, rd);\n if (t < 0.0) {\n discard;\n }\n vec3 coord = r0 + rd * t;\n vec3 normal = normalize(coord - vPosition);\n if (uMode == 0) {\n gl_FragColor = vec4(vColor, 1);\n } else if (uMode == 1) {\n gl_FragColor = vec4(normal * 0.5 + 0.5, 1.0);\n }\n gl_FragDepthEXT = -coord.z/uDepth;\n}\n",blur:"#version 100\nprecision highp float;\n\nattribute vec3 aPosition;\n\nvoid main() {\n gl_Position = vec4(aPosition, 1);\n}\n\n\n// __split__\n\n\n#version 100\nprecision highp float;\n\nuniform sampler2D uTexture;\nuniform float uRes;\nuniform int leftRight;\n\nvoid main() {\n vec2 dir;\n if (leftRight == 1) {\n dir = vec2(1,0)/uRes;\n } else {\n dir = vec2(0,1)/uRes;\n }\n const int range = 16;\n vec4 sample = vec4(0,0,0,0);\n for (int i = -range; i <= range; i++) {\n vec2 p = gl_FragCoord.xy/uRes + dir * float(i);\n sample += texture2D(uTexture, p);\n }\n sample /= float(range) * 2.0 + 1.0;\n gl_FragColor = sample;\n}\n",bond:"#version 100\nprecision highp float;\n\nattribute vec3 aImposter;\nattribute vec3 aPosA;\nattribute vec3 aPosB;\nattribute float aRadA;\nattribute float aRadB;\nattribute vec3 aColA;\nattribute vec3 aColB;\n\nuniform mat4 uView;\nuniform mat4 uProjection;\nuniform mat4 uModel;\nuniform mat4 uRotation;\nuniform float uBondRadius;\nuniform float uAtomScale;\nuniform float uRelativeAtomScale;\n\nvarying vec3 vNormal;\nvarying vec3 vPosA, vPosB;\nvarying float vRadA, vRadB;\nvarying vec3 vColA, vColB;\nvarying float vRadius;\n\nmat3 alignVector(vec3 a, vec3 b) {\n vec3 v = cross(a, b);\n float s = length(v);\n float c = dot(a, b);\n mat3 I = mat3(\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n );\n mat3 vx = mat3(\n 0, v.z, -v.y,\n -v.z, 0, v.x,\n v.y, -v.x, 0\n );\n return I + vx + vx * vx * ((1.0 - c) / (s * s));\n}\n\nvoid main() {\n vRadius = uBondRadius;\n vec3 pos = vec3(aImposter);\n // Scale the box in x and z to be bond-radius.\n pos = pos * vec3(vRadius, 1, vRadius);\n // Shift the origin-centered cube so that the bottom is at the origin.\n pos = pos + vec3(0, 1, 0);\n // Stretch the box in y so that it is the length of the bond.\n pos = pos * vec3(1, length(aPosA - aPosB) * 0.5, 1);\n // Find the rotation that aligns vec3(0, 1, 0) with vec3(uPosB - uPosA) and apply it.\n vec3 a = normalize(vec3(-0.000001, 1.000001, 0.000001));\n vec3 b = normalize(aPosB - aPosA);\n mat3 R = alignVector(a, b);\n pos = R * pos;\n // Shift the cube so that the bottom is centered at the middle of atom A.\n pos = pos + aPosA;\n\n vec4 position = uModel * vec4(pos, 1);\n gl_Position = uProjection * uView * position;\n vPosA = aPosA;\n vPosB = aPosB;\n vRadA = uAtomScale * (1.0 + (aRadA - 1.0) * uRelativeAtomScale);\n vRadB = uAtomScale * (1.0 + (aRadB - 1.0) * uRelativeAtomScale);\n vColA = aColA;\n vColB = aColB;\n}\n\n\n// __split__\n\n\n#version 100\n#extension GL_EXT_frag_depth: enable\nprecision highp float;\n\nuniform mat4 uRotation;\nuniform vec2 uBottomLeft;\nuniform vec2 uTopRight;\nuniform float uDepth;\nuniform float uRes;\nuniform float uBondShade;\nuniform int uMode;\n\nvarying vec3 vPosA, vPosB;\nvarying float vRadA, vRadB;\nvarying vec3 vColA, vColB;\nvarying float vRadius;\n\nmat3 alignVector(vec3 a, vec3 b) {\n vec3 v = cross(a, b);\n float s = length(v);\n float c = dot(a, b);\n mat3 I = mat3(\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n );\n mat3 vx = mat3(\n 0, v.z, -v.y,\n -v.z, 0, v.x,\n v.y, -v.x, 0\n );\n return I + vx + vx * vx * ((1.0 - c) / (s * s));\n}\n\nvoid main() {\n\n vec2 res = vec2(uRes, uRes);\n vec3 r0 = vec3(uBottomLeft + (gl_FragCoord.xy/res) * (uTopRight - uBottomLeft), uDepth/2.0);\n vec3 rd = vec3(0, 0, -1);\n\n vec3 i = normalize(vPosB - vPosA);\n i = vec3(uRotation * vec4(i, 0));\n vec3 j = normalize(vec3(-0.000001, 1.000001, 0.000001));\n mat3 R = alignVector(i, j);\n\n vec3 r0p = r0 - vec3(uRotation * vec4(vPosA, 0));\n r0p = R * r0p;\n vec3 rdp = R * rd;\n\n float a = dot(rdp.xz, rdp.xz);\n float b = 2.0 * dot(rdp.xz, r0p.xz);\n float c = dot(r0p.xz, r0p.xz) - vRadius*vRadius;\n float disc = b*b - 4.0*a*c;\n if (disc <= 0.0) {\n discard;\n }\n float t = (-b - sqrt(disc))/(2.0*a);\n if (t < 0.0) {\n discard;\n }\n\n vec3 coord = r0p + rdp * t;\n if (coord.y < 0.0 || coord.y > length(vPosA - vPosB)) {\n discard;\n }\n\n vec3 color;\n if (coord.y < vRadA + 0.5 * (length(vPosA - vPosB) - (vRadA + vRadB))) {\n color = vColA;\n } else {\n color = vColB;\n }\n\n color = mix(color, vec3(1,1,1), uBondShade);\n\n R = alignVector(j, i);\n vec3 normal = normalize(R * vec3(coord.x, 0, coord.z));\n\n coord = r0 + rd * t;\n if (uMode == 0) {\n gl_FragColor = vec4(color, 1);\n } else if (uMode == 1) {\n gl_FragColor = vec4(normal * 0.5 + 0.5, 1.0);\n }\n gl_FragDepthEXT = -(coord.z - uDepth/2.0)/uDepth;\n}\n",dof:"#version 100\nprecision highp float;\n\nattribute vec3 aPosition;\n\nvoid main() {\n gl_Position = vec4(aPosition, 1);\n}\n\n\n// __split__\n\n\n#version 100\nprecision highp float;\n\nuniform sampler2D uColor;\nuniform sampler2D uDepth;\nuniform float uRes;\nuniform float uDOFPosition;\nuniform float uDOFStrength;\nuniform int leftRight;\n\nvoid main() {\n\n vec2 samples[64];\n samples[0] = vec2(0.857612, 0.019885);\n samples[1] = vec2(0.563809, -0.028071);\n samples[2] = vec2(0.825599, -0.346856);\n samples[3] = vec2(0.126584, -0.380959);\n samples[4] = vec2(0.782948, 0.594322);\n samples[5] = vec2(0.292148, -0.543265);\n samples[6] = vec2(0.130700, 0.330220);\n samples[7] = vec2(0.236088, 0.159604);\n samples[8] = vec2(-0.305259, 0.810505);\n samples[9] = vec2(0.269616, 0.923026);\n samples[10] = vec2(0.484486, 0.371845);\n samples[11] = vec2(-0.638057, 0.080447);\n samples[12] = vec2(0.199629, 0.667280);\n samples[13] = vec2(-0.861043, -0.370583);\n samples[14] = vec2(-0.040652, -0.996174);\n samples[15] = vec2(0.330458, -0.282111);\n samples[16] = vec2(0.647795, -0.214354);\n samples[17] = vec2(0.030422, -0.189908);\n samples[18] = vec2(0.177430, -0.721124);\n samples[19] = vec2(-0.461163, -0.327434);\n samples[20] = vec2(-0.410012, -0.734504);\n samples[21] = vec2(-0.616334, -0.626069);\n samples[22] = vec2(0.590759, -0.726479);\n samples[23] = vec2(-0.590794, 0.805365);\n samples[24] = vec2(-0.924561, -0.163739);\n samples[25] = vec2(-0.323028, 0.526960);\n samples[26] = vec2(0.642128, 0.752577);\n samples[27] = vec2(0.173625, -0.952386);\n samples[28] = vec2(0.759014, 0.330311);\n samples[29] = vec2(-0.360526, -0.032013);\n samples[30] = vec2(-0.035320, 0.968156);\n samples[31] = vec2(0.585478, -0.431068);\n samples[32] = vec2(-0.244766, -0.906947);\n samples[33] = vec2(-0.853096, 0.184615);\n samples[34] = vec2(-0.089061, 0.104648);\n samples[35] = vec2(-0.437613, 0.285308);\n samples[36] = vec2(-0.654098, 0.379841);\n samples[37] = vec2(-0.128663, 0.456572);\n samples[38] = vec2(0.015980, -0.568170);\n samples[39] = vec2(-0.043966, -0.771940);\n samples[40] = vec2(0.346512, -0.071238);\n samples[41] = vec2(-0.207921, -0.209121);\n samples[42] = vec2(-0.624075, -0.189224);\n samples[43] = vec2(-0.120618, 0.689339);\n samples[44] = vec2(-0.664679, -0.410200);\n samples[45] = vec2(0.371945, -0.880573);\n samples[46] = vec2(-0.743251, 0.629998);\n samples[47] = vec2(-0.191926, -0.413946);\n samples[48] = vec2(0.449574, 0.833373);\n samples[49] = vec2(0.299587, 0.449113);\n samples[50] = vec2(-0.900432, 0.399319);\n samples[51] = vec2(0.762613, -0.544796);\n samples[52] = vec2(0.606462, 0.174233);\n samples[53] = vec2(0.962185, -0.167019);\n samples[54] = vec2(0.960990, 0.249552);\n samples[55] = vec2(0.570397, 0.559146);\n samples[56] = vec2(-0.537514, 0.555019);\n samples[57] = vec2(0.108491, -0.003232);\n samples[58] = vec2(-0.237693, -0.615428);\n samples[59] = vec2(-0.217313, 0.261084);\n samples[60] = vec2(-0.998966, 0.025692);\n samples[61] = vec2(-0.418554, -0.527508);\n samples[62] = vec2(-0.822629, -0.567797);\n samples[63] = vec2(0.061945, 0.522105);\n\n float invRes = 1.0/uRes;\n vec2 coord = gl_FragCoord.xy * invRes;\n\n float strength = uDOFStrength * uRes/768.0;\n\n float depth = texture2D(uDepth, coord).r;\n float range = uDOFPosition - depth;\n float scale = abs(range);\n\n vec4 sample = texture2D(uColor, coord);\n float count = 1.0;\n for(int i = 0; i < 64; i++) {\n vec2 p = samples[i];\n p = coord + scale * 64.0 * strength * p * invRes;\n float d = texture2D(uDepth, p).r;\n float r = uDOFPosition - d;\n float s = abs(r);\n sample += texture2D(uColor, p) * s;\n count += s;\n }\n\n gl_FragColor = sample/count;\n}",fxaa:"#version 100\nprecision highp float;\n\nattribute vec3 aPosition;\n\nvoid main() {\n gl_Position = vec4(aPosition, 1);\n}\n\n\n// __split__\n\n\n#version 100\nprecision highp float;\n\nuniform sampler2D uTexture;\nuniform float uRes;\n\nvoid main() {\n float FXAA_SPAN_MAX = 8.0;\n float FXAA_REDUCE_MUL = 1.0/8.0;\n float FXAA_REDUCE_MIN = 1.0/128.0;\n\n vec2 texCoords = gl_FragCoord.xy/uRes;\n\n vec4 rgbNW = texture2D(uTexture, texCoords + (vec2(-1.0, -1.0) / uRes));\n vec4 rgbNE = texture2D(uTexture, texCoords + (vec2(1.0, -1.0) / uRes));\n vec4 rgbSW = texture2D(uTexture, texCoords + (vec2(-1.0, 1.0) / uRes));\n vec4 rgbSE = texture2D(uTexture, texCoords + (vec2(1.0, 1.0) / uRes));\n vec4 rgbM = texture2D(uTexture, texCoords);\n\n vec4 luma = vec4(0.299, 0.587, 0.114, 1.0);\n float lumaNW = dot(rgbNW, luma);\n float lumaNE = dot(rgbNE, luma);\n float lumaSW = dot(rgbSW, luma);\n float lumaSE = dot(rgbSE, luma);\n float lumaM = dot(rgbM, luma);\n\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce);\n\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) / uRes;\n\n vec4 rgbA = (1.0/2.0) * \n (texture2D(uTexture, texCoords.xy + dir * (1.0/3.0 - 0.5)) + \n texture2D(uTexture, texCoords.xy + dir * (2.0/3.0 - 0.5)));\n vec4 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * \n (texture2D(uTexture, texCoords.xy + dir * (0.0/3.0 - 0.5)) +\n texture2D(uTexture, texCoords.xy + dir * (3.0/3.0 - 0.5)));\n float lumaB = dot(rgbB, luma);\n\n if((lumaB < lumaMin) || (lumaB > lumaMax)){\n gl_FragColor = rgbA;\n } else {\n gl_FragColor = rgbB;\n }\n\n}","textured-quad":"#version 100\nprecision highp float;\n\nattribute vec3 aPosition;\n\nvoid main() {\n gl_Position = vec4(aPosition, 1);\n}\n\n\n// __split__\n\n\n#version 100\nprecision highp float;\n\nuniform sampler2D uTexture;\nuniform float uRes;\n\nvoid main() {\n gl_FragColor = texture2D(uTexture, gl_FragCoord.xy/uRes);\n}\n"};n.exports={shaders:r}},function(n,t,e){"use strict";var r=e(8);n.exports=function(n){if(arguments.length>1)throw"Error: The Speck Interactions module has changed!";if(0===arguments.length||"object"!=typeof n)throw"Error: Arguments not provided to interactions";var t=void 0===n.scrollZoom||n.scrollZoom,e=n.container,o=n.getRotation,a=n.setRotation,i=n.getTranslation,u=n.setTranslation,s=n.getZoom,l=n.setZoom,c=n.refreshView,f={buttonDown:!1,shiftDown:!1,lastX:0,lastY:0};function p(n){0===n.button&&(f={buttonDown:!0,shiftDown:f.shiftDown,lastX:n.clientX,lastY:n.clientY})}function h(n){if(0===n.button){if(!f.buttonDown)return;f.buttonDown=!1}}function d(n){f.shiftDown=n.shiftKey}function m(n){if(f.buttonDown&&0!==n.buttons){n.preventDefault();var t=n.clientX-f.lastX,e=n.clientY-f.lastY;if(0!==t||0!==e){if(f.lastX=n.clientX,f.lastY=n.clientY,f.shiftDown){var l=i(),p=.001/s();u({x:l.x-t*p,y:l.y+e*p})}else{var h={rotation:new Float32Array(o())};r.rotate(h,t,e),a(h.rotation)}c()}}}function v(n){n.preventDefault(),l(s()*(n.deltaY<0?1/.9:.9)),c()}return e.addEventListener("mousedown",p),window.addEventListener("mouseup",h),window.addEventListener("keydown",d),window.addEventListener("keyup",d),window.addEventListener("mousemove",m),t&&e.addEventListener("wheel",v),function(){e.removeEventListener("mousedown",p),window.removeEventListener("mouseup",h),window.removeEventListener("keydown",d),window.removeEventListener("keyup",d),window.removeEventListener("mousemove",m),e.removeEventListener("wheel",v)}}},function(n,t){n.exports={default:{atomScale:.6,relativeAtomScale:1,bondScale:.5,ao:.75,aoRes:256,brightness:.5,outline:0,spf:32,bonds:!1,bondThreshold:1.2,bondShade:.5,atomShade:.5,dofStrength:0,dofPosition:.5,fxaa:1},stickball:{atomScale:.24,relativeAtomScale:.64,bondScale:.5,bonds:!0,bondThreshold:1.2},toon:{ao:0,spf:0,brightness:.5,outline:1},licorice:{atomScale:.1,relativeAtomScale:0,bondScale:1,bonds:!0,bondThreshold:1.2}}},function(n,t,e){"use strict";e.r(t);var r=e(10),o=e(18),a=e(1),i=e.n(a),u=e(0),s=e.n(u),l=e(22),c=e(43);function f(n){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function p(n,t){for(var e=0;e=0;)t=p[e],Object(i.a)(t,n)&&!d(r,t)&&(r[r.length]=t),e-=1;return r}):Object(s.a)(function(n){return Object(n)!==n?[]:Object.keys(n)}),v=Object(s.a)(function(n){return null===n?"Null":void 0===n?"Undefined":Object.prototype.toString.call(n).slice(8,-1)});function g(n,t,e,r){var i=o(n);function u(n,t){return y(n,t,e.slice(),r.slice())}return!a(function(n,t){return!a(u,t,n)},o(t),i)}function y(n,t,e,r){if(u(n,t))return!0;var o,a,s=v(n);if(s!==v(t))return!1;if(null==n||null==t)return!1;if("function"==typeof n["fantasy-land/equals"]||"function"==typeof t["fantasy-land/equals"])return"function"==typeof n["fantasy-land/equals"]&&n["fantasy-land/equals"](t)&&"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](n);if("function"==typeof n.equals||"function"==typeof t.equals)return"function"==typeof n.equals&&n.equals(t)&&"function"==typeof t.equals&&t.equals(n);switch(s){case"Arguments":case"Array":case"Object":if("function"==typeof n.constructor&&"Promise"===(o=n.constructor,null==(a=String(o).match(/^function (\w*)/))?"":a[1]))return n===t;break;case"Boolean":case"Number":case"String":if(typeof n!=typeof t||!u(n.valueOf(),t.valueOf()))return!1;break;case"Date":if(!u(n.valueOf(),t.valueOf()))return!1;break;case"Error":return n.name===t.name&&n.message===t.message;case"RegExp":if(n.source!==t.source||n.global!==t.global||n.ignoreCase!==t.ignoreCase||n.multiline!==t.multiline||n.sticky!==t.sticky||n.unicode!==t.unicode)return!1}for(var l=e.length-1;l>=0;){if(e[l]===n)return r[l]===t;l-=1}switch(s){case"Map":return n.size===t.size&&g(n.entries(),t.entries(),e.concat([n]),r.concat([t]));case"Set":return n.size===t.size&&g(n.values(),t.values(),e.concat([n]),r.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var c=m(n);if(c.length!==m(t).length)return!1;var f=e.concat([n]),p=r.concat([t]);for(l=c.length-1;l>=0;){var h=c[l];if(!Object(i.a)(h,t)||!y(t[h],n[h],f,p))return!1;l-=1}return!0}var b=Object(r.a)(function(n,t){return y(n,t,[],[])});t.a=b}]); \ No newline at end of file diff --git a/dash_bio/package-info.json b/dash_bio/package-info.json index 2f57f6db5..4333709cc 100644 --- a/dash_bio/package-info.json +++ b/dash_bio/package-info.json @@ -1 +1 @@ -{"name": "dash_bio", "version": "0.4.0", "author": "The Plotly Team "} \ No newline at end of file +{"name": "dash_bio", "version": "0.4.1", "author": "The Plotly Team "} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 55d7f094b..30f0eed64 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "dash-bio", - "version": "0.3.0", + "version": "0.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1370,9 +1370,9 @@ } }, "@plotly/webpack-dash-dynamic-import": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@plotly/webpack-dash-dynamic-import/-/webpack-dash-dynamic-import-1.1.1.tgz", - "integrity": "sha512-Yrc7XZOMQuyh2TkbEMr3i6hfdAS/DMFDfvhdD3C28/G6aRWfPRTZ2Tb+IeyOhZTX41IoNmJ6YciLooME8zP5ag==", + "version": "1.1.3-rc1", + "resolved": "https://registry.npmjs.org/@plotly/webpack-dash-dynamic-import/-/webpack-dash-dynamic-import-1.1.3-rc1.tgz", + "integrity": "sha512-d0eOj6cekYSkYHc/AOvKpp4L6jJE1Jp1FTchID3KIhJNVuW2cyIgdJsSVnnm4Ugqq2t6ul7AcSk0lmbxYsZKmg==", "dev": true }, "@types/accepts": { diff --git a/package.json b/package.json index 81a7a83f4..2e6a1bec8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dash-bio", - "version": "0.4.0", + "version": "0.4.1", "description": "Dash components for bioinformatics", "repository": { "type": "git", @@ -49,7 +49,7 @@ "@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/preset-env": "^7.4.1", "@babel/preset-react": "^7.0.0", - "@plotly/webpack-dash-dynamic-import": "^1.1.1", + "@plotly/webpack-dash-dynamic-import": "^1.1.3-rc1", "babel-eslint": "^10.0.0", "babel-jest": "^24.5.0", "babel-loader": "^8.0.0", From c063ca1f1ae9854bbd285484daeef110ed063893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Rivet?= Date: Thu, 7 Nov 2019 17:34:45 -0500 Subject: [PATCH 02/12] - env presets - es5 check - build artifacts --- .babelrc | 9 - babel.config.js | 9 + dash_bio/async~alignment.js | 225144 ++++++++++++++++++++++++++- dash_bio/async~circos.js | 27978 +++- dash_bio/async~ideogram.js | 8408 +- dash_bio/async~moleculeviewer2.js | 19177 ++- dash_bio/async~moleculeviewer3.js | 16536 +- dash_bio/async~needle.js | 1163 +- dash_bio/async~needleplot.js | 1 - dash_bio/async~onco.js | 1014 +- dash_bio/async~sequence.js | 1890 +- dash_bio/async~speck.js | 534 +- dash_bio/bundle.js | 10208 +- package-lock.json | 452 +- package.json | 2 + webpack.config.js | 10 +- 16 files changed, 312465 insertions(+), 70 deletions(-) delete mode 100644 .babelrc create mode 100644 babel.config.js delete mode 100644 dash_bio/async~needleplot.js diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 433bae612..000000000 --- a/.babelrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "presets": [ - "@babel/env", - "@babel/react" - ], - "plugins": [ - "@babel/plugin-syntax-dynamic-import" - ] -} \ No newline at end of file diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 000000000..a42b35e42 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,9 @@ +module.exports = { + presets: [ + '@babel/preset-env', + '@babel/preset-react' + ], + plugins: [ + '@babel/plugin-syntax-dynamic-import' + ] +} \ No newline at end of file diff --git a/dash_bio/async~alignment.js b/dash_bio/async~alignment.js index 79c8c8dd7..0d840f72f 100644 --- a/dash_bio/async~alignment.js +++ b/dash_bio/async~alignment.js @@ -1,25 +1,55649 @@ -(window.webpackJsonpdash_bio=window.webpackJsonpdash_bio||[]).push([[0],Array(34).concat([function(t,e,r){"use strict";r.r(e),r.d(e,"default",function(){return d});var n=r(1),i=r.n(n),a=r(181),o=r(10),s=r(85);function l(t){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function u(){return(u=Object.assign||function(t){for(var e=1;e * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */(function(){var a,o=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",l="Expected a function",u="__lodash_hash_undefined__",c=500,f="__lodash_placeholder__",h=1,p=2,d=4,v=1,g=2,m=1,y=2,x=4,b=8,_=16,w=32,k=64,A=128,T=256,M=512,E=30,S="...",C=800,L=16,O=1,I=2,P=1/0,D=9007199254740991,z=1.7976931348623157e308,R=NaN,F=4294967295,B=F-1,N=F>>>1,j=[["ary",A],["bind",m],["bindKey",y],["curry",b],["curryRight",_],["flip",M],["partial",w],["partialRight",k],["rearg",T]],V="[object Arguments]",U="[object Array]",H="[object AsyncFunction]",q="[object Boolean]",G="[object Date]",W="[object DOMException]",Y="[object Error]",X="[object Function]",Z="[object GeneratorFunction]",$="[object Map]",J="[object Number]",K="[object Null]",Q="[object Object]",tt="[object Proxy]",et="[object RegExp]",rt="[object Set]",nt="[object String]",it="[object Symbol]",at="[object Undefined]",ot="[object WeakMap]",st="[object WeakSet]",lt="[object ArrayBuffer]",ut="[object DataView]",ct="[object Float32Array]",ft="[object Float64Array]",ht="[object Int8Array]",pt="[object Int16Array]",dt="[object Int32Array]",vt="[object Uint8Array]",gt="[object Uint8ClampedArray]",mt="[object Uint16Array]",yt="[object Uint32Array]",xt=/\b__p \+= '';/g,bt=/\b(__p \+=) '' \+/g,_t=/(__e\(.*?\)|\b__t\)) \+\n'';/g,wt=/&(?:amp|lt|gt|quot|#39);/g,kt=/[&<>"']/g,At=RegExp(wt.source),Tt=RegExp(kt.source),Mt=/<%-([\s\S]+?)%>/g,Et=/<%([\s\S]+?)%>/g,St=/<%=([\s\S]+?)%>/g,Ct=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Lt=/^\w*$/,Ot=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,It=/[\\^$.*+?()[\]{}|]/g,Pt=RegExp(It.source),Dt=/^\s+|\s+$/g,zt=/^\s+/,Rt=/\s+$/,Ft=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Bt=/\{\n\/\* \[wrapped with (.+)\] \*/,Nt=/,? & /,jt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Vt=/\\(\\)?/g,Ut=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ht=/\w*$/,qt=/^[-+]0x[0-9a-f]+$/i,Gt=/^0b[01]+$/i,Wt=/^\[object .+?Constructor\]$/,Yt=/^0o[0-7]+$/i,Xt=/^(?:0|[1-9]\d*)$/,Zt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,$t=/($^)/,Jt=/['\n\r\u2028\u2029\\]/g,Kt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Qt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",te="[\\ud800-\\udfff]",ee="["+Qt+"]",re="["+Kt+"]",ne="\\d+",ie="[\\u2700-\\u27bf]",ae="[a-z\\xdf-\\xf6\\xf8-\\xff]",oe="[^\\ud800-\\udfff"+Qt+ne+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",se="\\ud83c[\\udffb-\\udfff]",le="[^\\ud800-\\udfff]",ue="(?:\\ud83c[\\udde6-\\uddff]){2}",ce="[\\ud800-\\udbff][\\udc00-\\udfff]",fe="[A-Z\\xc0-\\xd6\\xd8-\\xde]",he="(?:"+ae+"|"+oe+")",pe="(?:"+fe+"|"+oe+")",de="(?:"+re+"|"+se+")"+"?",ve="[\\ufe0e\\ufe0f]?"+de+("(?:\\u200d(?:"+[le,ue,ce].join("|")+")[\\ufe0e\\ufe0f]?"+de+")*"),ge="(?:"+[ie,ue,ce].join("|")+")"+ve,me="(?:"+[le+re+"?",re,ue,ce,te].join("|")+")",ye=RegExp("['’]","g"),xe=RegExp(re,"g"),be=RegExp(se+"(?="+se+")|"+me+ve,"g"),_e=RegExp([fe+"?"+ae+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[ee,fe,"$"].join("|")+")",pe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[ee,fe+he,"$"].join("|")+")",fe+"?"+he+"+(?:['’](?:d|ll|m|re|s|t|ve))?",fe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ne,ge].join("|"),"g"),we=RegExp("[\\u200d\\ud800-\\udfff"+Kt+"\\ufe0e\\ufe0f]"),ke=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ae=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Te=-1,Me={};Me[ct]=Me[ft]=Me[ht]=Me[pt]=Me[dt]=Me[vt]=Me[gt]=Me[mt]=Me[yt]=!0,Me[V]=Me[U]=Me[lt]=Me[q]=Me[ut]=Me[G]=Me[Y]=Me[X]=Me[$]=Me[J]=Me[Q]=Me[et]=Me[rt]=Me[nt]=Me[ot]=!1;var Ee={};Ee[V]=Ee[U]=Ee[lt]=Ee[ut]=Ee[q]=Ee[G]=Ee[ct]=Ee[ft]=Ee[ht]=Ee[pt]=Ee[dt]=Ee[$]=Ee[J]=Ee[Q]=Ee[et]=Ee[rt]=Ee[nt]=Ee[it]=Ee[vt]=Ee[gt]=Ee[mt]=Ee[yt]=!0,Ee[Y]=Ee[X]=Ee[ot]=!1;var Se={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ce=parseFloat,Le=parseInt,Oe="object"==typeof t&&t&&t.Object===Object&&t,Ie="object"==typeof self&&self&&self.Object===Object&&self,Pe=Oe||Ie||Function("return this")(),De=e&&!e.nodeType&&e,ze=De&&"object"==typeof n&&n&&!n.nodeType&&n,Re=ze&&ze.exports===De,Fe=Re&&Oe.process,Be=function(){try{var t=ze&&ze.require&&ze.require("util").types;return t||Fe&&Fe.binding&&Fe.binding("util")}catch(t){}}(),Ne=Be&&Be.isArrayBuffer,je=Be&&Be.isDate,Ve=Be&&Be.isMap,Ue=Be&&Be.isRegExp,He=Be&&Be.isSet,qe=Be&&Be.isTypedArray;function Ge(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function We(t,e,r,n){for(var i=-1,a=null==t?0:t.length;++i-1}function Ke(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function br(t,e){for(var r=t.length;r--&&sr(e,t[r],0)>-1;);return r}var _r=hr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),wr=hr({"&":"&","<":"<",">":">",'"':""","'":"'"});function kr(t){return"\\"+Se[t]}function Ar(t){return we.test(t)}function Tr(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function Mr(t,e){return function(r){return t(e(r))}}function Er(t,e){for(var r=-1,n=t.length,i=0,a=[];++r",""":'"',"'":"'"});var Pr=function t(e){var r,n=(e=null==e?Pe:Pr.defaults(Pe.Object(),e,Pr.pick(Pe,Ae))).Array,i=e.Date,Kt=e.Error,Qt=e.Function,te=e.Math,ee=e.Object,re=e.RegExp,ne=e.String,ie=e.TypeError,ae=n.prototype,oe=Qt.prototype,se=ee.prototype,le=e["__core-js_shared__"],ue=oe.toString,ce=se.hasOwnProperty,fe=0,he=(r=/[^.]+$/.exec(le&&le.keys&&le.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",pe=se.toString,de=ue.call(ee),ve=Pe._,ge=re("^"+ue.call(ce).replace(It,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),me=Re?e.Buffer:a,be=e.Symbol,we=e.Uint8Array,Se=me?me.allocUnsafe:a,Oe=Mr(ee.getPrototypeOf,ee),Ie=ee.create,De=se.propertyIsEnumerable,ze=ae.splice,Fe=be?be.isConcatSpreadable:a,Be=be?be.iterator:a,ir=be?be.toStringTag:a,hr=function(){try{var t=Ba(ee,"defineProperty");return t({},"",{}),t}catch(t){}}(),Dr=e.clearTimeout!==Pe.clearTimeout&&e.clearTimeout,zr=i&&i.now!==Pe.Date.now&&i.now,Rr=e.setTimeout!==Pe.setTimeout&&e.setTimeout,Fr=te.ceil,Br=te.floor,Nr=ee.getOwnPropertySymbols,jr=me?me.isBuffer:a,Vr=e.isFinite,Ur=ae.join,Hr=Mr(ee.keys,ee),qr=te.max,Gr=te.min,Wr=i.now,Yr=e.parseInt,Xr=te.random,Zr=ae.reverse,$r=Ba(e,"DataView"),Jr=Ba(e,"Map"),Kr=Ba(e,"Promise"),Qr=Ba(e,"Set"),tn=Ba(e,"WeakMap"),en=Ba(ee,"create"),rn=tn&&new tn,nn={},an=co($r),on=co(Jr),sn=co(Kr),ln=co(Qr),un=co(tn),cn=be?be.prototype:a,fn=cn?cn.valueOf:a,hn=cn?cn.toString:a;function pn(t){if(Ss(t)&&!ms(t)&&!(t instanceof mn)){if(t instanceof gn)return t;if(ce.call(t,"__wrapped__"))return fo(t)}return new gn(t)}var dn=function(){function t(){}return function(e){if(!Es(e))return{};if(Ie)return Ie(e);t.prototype=e;var r=new t;return t.prototype=a,r}}();function vn(){}function gn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=a}function mn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=F,this.__views__=[]}function yn(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function zn(t,e,r,n,i,o){var s,l=e&h,u=e&p,c=e&d;if(r&&(s=i?r(t,n,i,o):r(t)),s!==a)return s;if(!Es(t))return t;var f=ms(t);if(f){if(s=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&ce.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!l)return ra(t,s)}else{var v=Va(t),g=v==X||v==Z;if(_s(t))return $i(t,l);if(v==Q||v==V||g&&!i){if(s=u||g?{}:Ha(t),!l)return u?function(t,e){return na(t,ja(t),e)}(t,function(t,e){return t&&na(e,al(e),t)}(s,t)):function(t,e){return na(t,Na(t),e)}(t,On(s,t))}else{if(!Ee[v])return i?t:{};s=function(t,e,r){var n,i,a,o=t.constructor;switch(e){case lt:return Ji(t);case q:case G:return new o(+t);case ut:return function(t,e){var r=e?Ji(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case ct:case ft:case ht:case pt:case dt:case vt:case gt:case mt:case yt:return Ki(t,r);case $:return new o;case J:case nt:return new o(t);case et:return(a=new(i=t).constructor(i.source,Ht.exec(i))).lastIndex=i.lastIndex,a;case rt:return new o;case it:return n=t,fn?ee(fn.call(n)):{}}}(t,v,l)}}o||(o=new wn);var m=o.get(t);if(m)return m;o.set(t,s),Ps(t)?t.forEach(function(n){s.add(zn(n,e,r,n,t,o))}):Cs(t)&&t.forEach(function(n,i){s.set(i,zn(n,e,r,i,t,o))});var y=f?a:(c?u?Oa:La:u?al:il)(t);return Ye(y||t,function(n,i){y&&(n=t[i=n]),Sn(s,i,zn(n,e,r,i,t,o))}),s}function Rn(t,e,r){var n=r.length;if(null==t)return!n;for(t=ee(t);n--;){var i=r[n],o=e[i],s=t[i];if(s===a&&!(i in t)||!o(s))return!1}return!0}function Fn(t,e,r){if("function"!=typeof t)throw new ie(l);return no(function(){t.apply(a,r)},e)}function Bn(t,e,r,n){var i=-1,a=Je,s=!0,l=t.length,u=[],c=e.length;if(!l)return u;r&&(e=Qe(e,gr(r))),n?(a=Ke,s=!1):e.length>=o&&(a=yr,s=!1,e=new _n(e));t:for(;++i-1},xn.prototype.set=function(t,e){var r=this.__data__,n=Cn(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},bn.prototype.clear=function(){this.size=0,this.__data__={hash:new yn,map:new(Jr||xn),string:new yn}},bn.prototype.delete=function(t){var e=Ra(this,t).delete(t);return this.size-=e?1:0,e},bn.prototype.get=function(t){return Ra(this,t).get(t)},bn.prototype.has=function(t){return Ra(this,t).has(t)},bn.prototype.set=function(t,e){var r=Ra(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},_n.prototype.add=_n.prototype.push=function(t){return this.__data__.set(t,u),this},_n.prototype.has=function(t){return this.__data__.has(t)},wn.prototype.clear=function(){this.__data__=new xn,this.size=0},wn.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},wn.prototype.get=function(t){return this.__data__.get(t)},wn.prototype.has=function(t){return this.__data__.has(t)},wn.prototype.set=function(t,e){var r=this.__data__;if(r instanceof xn){var n=r.__data__;if(!Jr||n.length0&&r(s)?e>1?qn(s,e-1,r,n,i):tr(i,s):n||(i[i.length]=s)}return i}var Gn=sa(),Wn=sa(!0);function Yn(t,e){return t&&Gn(t,e,il)}function Xn(t,e){return t&&Wn(t,e,il)}function Zn(t,e){return $e(e,function(e){return As(t[e])})}function $n(t,e){for(var r=0,n=(e=Wi(e,t)).length;null!=t&&re}function ti(t,e){return null!=t&&ce.call(t,e)}function ei(t,e){return null!=t&&e in ee(t)}function ri(t,e,r){for(var i=r?Ke:Je,o=t[0].length,s=t.length,l=s,u=n(s),c=1/0,f=[];l--;){var h=t[l];l&&e&&(h=Qe(h,gr(e))),c=Gr(h.length,c),u[l]=!r&&(e||o>=120&&h.length>=120)?new _n(l&&h):a}h=t[0];var p=-1,d=u[0];t:for(;++p=s)return l;var u=r[n];return l*("desc"==u?-1:1)}}return t.index-e.index}(t,e,r)})}function yi(t,e,r){for(var n=-1,i=e.length,a={};++n-1;)s!==t&&ze.call(s,l,1),ze.call(t,l,1);return t}function bi(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==a){var a=i;Ga(i)?ze.call(t,i,1):Bi(t,i)}}return t}function _i(t,e){return t+Br(Xr()*(e-t+1))}function wi(t,e){var r="";if(!t||e<1||e>D)return r;do{e%2&&(r+=t),(e=Br(e/2))&&(t+=t)}while(e);return r}function ki(t,e){return io(Qa(t,e,Ll),t+"")}function Ai(t){return An(pl(t))}function Ti(t,e){var r=pl(t);return so(r,Dn(e,0,r.length))}function Mi(t,e,r,n){if(!Es(t))return t;for(var i=-1,o=(e=Wi(e,t)).length,s=o-1,l=t;null!=l&&++ia?0:a+e),(r=r>a?a:r)<0&&(r+=a),a=e>r?0:r-e>>>0,e>>>=0;for(var o=n(a);++i>>1,o=t[a];null!==o&&!zs(o)&&(r?o<=e:o=o){var c=e?null:wa(t);if(c)return Sr(c);s=!1,i=yr,u=new _n}else u=e?[]:l;t:for(;++n=n?t:Li(t,e,r)}var Zi=Dr||function(t){return Pe.clearTimeout(t)};function $i(t,e){if(e)return t.slice();var r=t.length,n=Se?Se(r):new t.constructor(r);return t.copy(n),n}function Ji(t){var e=new t.constructor(t.byteLength);return new we(e).set(new we(t)),e}function Ki(t,e){var r=e?Ji(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function Qi(t,e){if(t!==e){var r=t!==a,n=null===t,i=t==t,o=zs(t),s=e!==a,l=null===e,u=e==e,c=zs(e);if(!l&&!c&&!o&&t>e||o&&s&&u&&!l&&!c||n&&s&&u||!r&&u||!i)return 1;if(!n&&!o&&!c&&t1?r[i-1]:a,s=i>2?r[2]:a;for(o=t.length>3&&"function"==typeof o?(i--,o):a,s&&Wa(r[0],r[1],s)&&(o=i<3?a:o,i=1),e=ee(e);++n-1?i[o?e[s]:s]:a}}function ha(t){return Ca(function(e){var r=e.length,n=r,i=gn.prototype.thru;for(t&&e.reverse();n--;){var o=e[n];if("function"!=typeof o)throw new ie(l);if(i&&!s&&"wrapper"==Pa(o))var s=new gn([],!0)}for(n=s?n:r;++n1&&b.reverse(),h&&cl))return!1;var c=o.get(t);if(c&&o.get(e))return c==e;var f=-1,h=!0,p=r&g?new _n:a;for(o.set(t,e),o.set(e,t);++f-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Ft,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return Ye(j,function(r){var n="_."+r[0];e&r[1]&&!Je(t,n)&&t.push(n)}),t.sort()}(function(t){var e=t.match(Bt);return e?e[1].split(Nt):[]}(n),r)))}function oo(t){var e=0,r=0;return function(){var n=Wr(),i=L-(n-r);if(r=n,i>0){if(++e>=C)return arguments[0]}else e=0;return t.apply(a,arguments)}}function so(t,e){var r=-1,n=t.length,i=n-1;for(e=e===a?n:e;++r1?t[e-1]:a;return r="function"==typeof r?(t.pop(),r):a,Io(t,r)});function No(t){var e=pn(t);return e.__chain__=!0,e}function jo(t,e){return e(t)}var Vo=Ca(function(t){var e=t.length,r=e?t[0]:0,n=this.__wrapped__,i=function(e){return Pn(e,t)};return!(e>1||this.__actions__.length)&&n instanceof mn&&Ga(r)?((n=n.slice(r,+r+(e?1:0))).__actions__.push({func:jo,args:[i],thisArg:a}),new gn(n,this.__chain__).thru(function(t){return e&&!t.length&&t.push(a),t})):this.thru(i)});var Uo=ia(function(t,e,r){ce.call(t,r)?++t[r]:In(t,r,1)});var Ho=fa(go),qo=fa(mo);function Go(t,e){return(ms(t)?Ye:Nn)(t,za(e,3))}function Wo(t,e){return(ms(t)?Xe:jn)(t,za(e,3))}var Yo=ia(function(t,e,r){ce.call(t,r)?t[r].push(e):In(t,r,[e])});var Xo=ki(function(t,e,r){var i=-1,a="function"==typeof e,o=xs(t)?n(t.length):[];return Nn(t,function(t){o[++i]=a?Ge(e,t,r):ni(t,e,r)}),o}),Zo=ia(function(t,e,r){In(t,r,e)});function $o(t,e){return(ms(t)?Qe:hi)(t,za(e,3))}var Jo=ia(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]});var Ko=ki(function(t,e){if(null==t)return[];var r=e.length;return r>1&&Wa(t,e[0],e[1])?e=[]:r>2&&Wa(e[0],e[1],e[2])&&(e=[e[0]]),mi(t,qn(e,1),[])}),Qo=zr||function(){return Pe.Date.now()};function ts(t,e,r){return e=r?a:e,e=t&&null==e?t.length:e,Aa(t,A,a,a,a,a,e)}function es(t,e){var r;if("function"!=typeof e)throw new ie(l);return t=Vs(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=a),r}}var rs=ki(function(t,e,r){var n=m;if(r.length){var i=Er(r,Da(rs));n|=w}return Aa(t,n,e,r,i)}),ns=ki(function(t,e,r){var n=m|y;if(r.length){var i=Er(r,Da(ns));n|=w}return Aa(e,n,t,r,i)});function is(t,e,r){var n,i,o,s,u,c,f=0,h=!1,p=!1,d=!0;if("function"!=typeof t)throw new ie(l);function v(e){var r=n,o=i;return n=i=a,f=e,s=t.apply(o,r)}function g(t){var r=t-c;return c===a||r>=e||r<0||p&&t-f>=o}function m(){var t=Qo();if(g(t))return y(t);u=no(m,function(t){var r=e-(t-c);return p?Gr(r,o-(t-f)):r}(t))}function y(t){return u=a,d&&n?v(t):(n=i=a,s)}function x(){var t=Qo(),r=g(t);if(n=arguments,i=this,c=t,r){if(u===a)return function(t){return f=t,u=no(m,e),h?v(t):s}(c);if(p)return Zi(u),u=no(m,e),v(c)}return u===a&&(u=no(m,e)),s}return e=Hs(e)||0,Es(r)&&(h=!!r.leading,o=(p="maxWait"in r)?qr(Hs(r.maxWait)||0,e):o,d="trailing"in r?!!r.trailing:d),x.cancel=function(){u!==a&&Zi(u),f=0,n=c=i=u=a},x.flush=function(){return u===a?s:y(Qo())},x}var as=ki(function(t,e){return Fn(t,1,e)}),os=ki(function(t,e,r){return Fn(t,Hs(e)||0,r)});function ss(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ie(l);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],a=r.cache;if(a.has(i))return a.get(i);var o=t.apply(this,n);return r.cache=a.set(i,o)||a,o};return r.cache=new(ss.Cache||bn),r}function ls(t){if("function"!=typeof t)throw new ie(l);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}ss.Cache=bn;var us=Yi(function(t,e){var r=(e=1==e.length&&ms(e[0])?Qe(e[0],gr(za())):Qe(qn(e,1),gr(za()))).length;return ki(function(n){for(var i=-1,a=Gr(n.length,r);++i=e}),gs=ii(function(){return arguments}())?ii:function(t){return Ss(t)&&ce.call(t,"callee")&&!De.call(t,"callee")},ms=n.isArray,ys=Ne?gr(Ne):function(t){return Ss(t)&&Kn(t)==lt};function xs(t){return null!=t&&Ms(t.length)&&!As(t)}function bs(t){return Ss(t)&&xs(t)}var _s=jr||Hl,ws=je?gr(je):function(t){return Ss(t)&&Kn(t)==G};function ks(t){if(!Ss(t))return!1;var e=Kn(t);return e==Y||e==W||"string"==typeof t.message&&"string"==typeof t.name&&!Os(t)}function As(t){if(!Es(t))return!1;var e=Kn(t);return e==X||e==Z||e==H||e==tt}function Ts(t){return"number"==typeof t&&t==Vs(t)}function Ms(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=D}function Es(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ss(t){return null!=t&&"object"==typeof t}var Cs=Ve?gr(Ve):function(t){return Ss(t)&&Va(t)==$};function Ls(t){return"number"==typeof t||Ss(t)&&Kn(t)==J}function Os(t){if(!Ss(t)||Kn(t)!=Q)return!1;var e=Oe(t);if(null===e)return!0;var r=ce.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ue.call(r)==de}var Is=Ue?gr(Ue):function(t){return Ss(t)&&Kn(t)==et};var Ps=He?gr(He):function(t){return Ss(t)&&Va(t)==rt};function Ds(t){return"string"==typeof t||!ms(t)&&Ss(t)&&Kn(t)==nt}function zs(t){return"symbol"==typeof t||Ss(t)&&Kn(t)==it}var Rs=qe?gr(qe):function(t){return Ss(t)&&Ms(t.length)&&!!Me[Kn(t)]};var Fs=xa(fi),Bs=xa(function(t,e){return t<=e});function Ns(t){if(!t)return[];if(xs(t))return Ds(t)?Or(t):ra(t);if(Be&&t[Be])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[Be]());var e=Va(t);return(e==$?Tr:e==rt?Sr:pl)(t)}function js(t){return t?(t=Hs(t))===P||t===-P?(t<0?-1:1)*z:t==t?t:0:0===t?t:0}function Vs(t){var e=js(t),r=e%1;return e==e?r?e-r:e:0}function Us(t){return t?Dn(Vs(t),0,F):0}function Hs(t){if("number"==typeof t)return t;if(zs(t))return R;if(Es(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Es(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Dt,"");var r=Gt.test(t);return r||Yt.test(t)?Le(t.slice(2),r?2:8):qt.test(t)?R:+t}function qs(t){return na(t,al(t))}function Gs(t){return null==t?"":Ri(t)}var Ws=aa(function(t,e){if($a(e)||xs(e))na(e,il(e),t);else for(var r in e)ce.call(e,r)&&Sn(t,r,e[r])}),Ys=aa(function(t,e){na(e,al(e),t)}),Xs=aa(function(t,e,r,n){na(e,al(e),t,n)}),Zs=aa(function(t,e,r,n){na(e,il(e),t,n)}),$s=Ca(Pn);var Js=ki(function(t,e){t=ee(t);var r=-1,n=e.length,i=n>2?e[2]:a;for(i&&Wa(e[0],e[1],i)&&(n=1);++r1),e}),na(t,Oa(t),r),n&&(r=zn(r,h|p|d,Ea));for(var i=e.length;i--;)Bi(r,e[i]);return r});var ul=Ca(function(t,e){return null==t?{}:function(t,e){return yi(t,e,function(e,r){return tl(t,r)})}(t,e)});function cl(t,e){if(null==t)return{};var r=Qe(Oa(t),function(t){return[t]});return e=za(e),yi(t,r,function(t,r){return e(t,r[0])})}var fl=ka(il),hl=ka(al);function pl(t){return null==t?[]:mr(t,il(t))}var dl=ua(function(t,e,r){return e=e.toLowerCase(),t+(r?vl(e):e)});function vl(t){return kl(Gs(t).toLowerCase())}function gl(t){return(t=Gs(t))&&t.replace(Zt,_r).replace(xe,"")}var ml=ua(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),yl=ua(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),xl=la("toLowerCase");var bl=ua(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()});var _l=ua(function(t,e,r){return t+(r?" ":"")+kl(e)});var wl=ua(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),kl=la("toUpperCase");function Al(t,e,r){return t=Gs(t),(e=r?a:e)===a?function(t){return ke.test(t)}(t)?function(t){return t.match(_e)||[]}(t):function(t){return t.match(jt)||[]}(t):t.match(e)||[]}var Tl=ki(function(t,e){try{return Ge(t,a,e)}catch(t){return ks(t)?t:new Kt(t)}}),Ml=Ca(function(t,e){return Ye(e,function(e){e=uo(e),In(t,e,rs(t[e],t))}),t});function El(t){return function(){return t}}var Sl=ha(),Cl=ha(!0);function Ll(t){return t}function Ol(t){return li("function"==typeof t?t:zn(t,h))}var Il=ki(function(t,e){return function(r){return ni(r,t,e)}}),Pl=ki(function(t,e){return function(r){return ni(t,r,e)}});function Dl(t,e,r){var n=il(e),i=Zn(e,n);null!=r||Es(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Zn(e,il(e)));var a=!(Es(r)&&"chain"in r&&!r.chain),o=As(t);return Ye(i,function(r){var n=e[r];t[r]=n,o&&(t.prototype[r]=function(){var e=this.__chain__;if(a||e){var r=t(this.__wrapped__);return(r.__actions__=ra(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,tr([this.value()],arguments))})}),t}function zl(){}var Rl=ga(Qe),Fl=ga(Ze),Bl=ga(nr);function Nl(t){return Ya(t)?fr(uo(t)):function(t){return function(e){return $n(e,t)}}(t)}var jl=ya(),Vl=ya(!0);function Ul(){return[]}function Hl(){return!1}var ql=va(function(t,e){return t+e},0),Gl=_a("ceil"),Wl=va(function(t,e){return t/e},1),Yl=_a("floor");var Xl,Zl=va(function(t,e){return t*e},1),$l=_a("round"),Jl=va(function(t,e){return t-e},0);return pn.after=function(t,e){if("function"!=typeof e)throw new ie(l);return t=Vs(t),function(){if(--t<1)return e.apply(this,arguments)}},pn.ary=ts,pn.assign=Ws,pn.assignIn=Ys,pn.assignInWith=Xs,pn.assignWith=Zs,pn.at=$s,pn.before=es,pn.bind=rs,pn.bindAll=Ml,pn.bindKey=ns,pn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return ms(t)?t:[t]},pn.chain=No,pn.chunk=function(t,e,r){e=(r?Wa(t,e,r):e===a)?1:qr(Vs(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var o=0,s=0,l=n(Fr(i/e));oi?0:i+r),(n=n===a||n>i?i:Vs(n))<0&&(n+=i),n=r>n?0:Us(n);r>>0)?(t=Gs(t))&&("string"==typeof e||null!=e&&!Is(e))&&!(e=Ri(e))&&Ar(t)?Xi(Or(t),0,r):t.split(e,r):[]},pn.spread=function(t,e){if("function"!=typeof t)throw new ie(l);return e=null==e?0:qr(Vs(e),0),ki(function(r){var n=r[e],i=Xi(r,0,e);return n&&tr(i,n),Ge(t,this,i)})},pn.tail=function(t){var e=null==t?0:t.length;return e?Li(t,1,e):[]},pn.take=function(t,e,r){return t&&t.length?Li(t,0,(e=r||e===a?1:Vs(e))<0?0:e):[]},pn.takeRight=function(t,e,r){var n=null==t?0:t.length;return n?Li(t,(e=n-(e=r||e===a?1:Vs(e)))<0?0:e,n):[]},pn.takeRightWhile=function(t,e){return t&&t.length?ji(t,za(e,3),!1,!0):[]},pn.takeWhile=function(t,e){return t&&t.length?ji(t,za(e,3)):[]},pn.tap=function(t,e){return e(t),t},pn.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ie(l);return Es(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),is(t,e,{leading:n,maxWait:e,trailing:i})},pn.thru=jo,pn.toArray=Ns,pn.toPairs=fl,pn.toPairsIn=hl,pn.toPath=function(t){return ms(t)?Qe(t,uo):zs(t)?[t]:ra(lo(Gs(t)))},pn.toPlainObject=qs,pn.transform=function(t,e,r){var n=ms(t),i=n||_s(t)||Rs(t);if(e=za(e,4),null==r){var a=t&&t.constructor;r=i?n?new a:[]:Es(t)&&As(a)?dn(Oe(t)):{}}return(i?Ye:Yn)(t,function(t,n,i){return e(r,t,n,i)}),r},pn.unary=function(t){return ts(t,1)},pn.union=So,pn.unionBy=Co,pn.unionWith=Lo,pn.uniq=function(t){return t&&t.length?Fi(t):[]},pn.uniqBy=function(t,e){return t&&t.length?Fi(t,za(e,2)):[]},pn.uniqWith=function(t,e){return e="function"==typeof e?e:a,t&&t.length?Fi(t,a,e):[]},pn.unset=function(t,e){return null==t||Bi(t,e)},pn.unzip=Oo,pn.unzipWith=Io,pn.update=function(t,e,r){return null==t?t:Ni(t,e,Gi(r))},pn.updateWith=function(t,e,r,n){return n="function"==typeof n?n:a,null==t?t:Ni(t,e,Gi(r),n)},pn.values=pl,pn.valuesIn=function(t){return null==t?[]:mr(t,al(t))},pn.without=Po,pn.words=Al,pn.wrap=function(t,e){return cs(Gi(e),t)},pn.xor=Do,pn.xorBy=zo,pn.xorWith=Ro,pn.zip=Fo,pn.zipObject=function(t,e){return Hi(t||[],e||[],Sn)},pn.zipObjectDeep=function(t,e){return Hi(t||[],e||[],Mi)},pn.zipWith=Bo,pn.entries=fl,pn.entriesIn=hl,pn.extend=Ys,pn.extendWith=Xs,Dl(pn,pn),pn.add=ql,pn.attempt=Tl,pn.camelCase=dl,pn.capitalize=vl,pn.ceil=Gl,pn.clamp=function(t,e,r){return r===a&&(r=e,e=a),r!==a&&(r=(r=Hs(r))==r?r:0),e!==a&&(e=(e=Hs(e))==e?e:0),Dn(Hs(t),e,r)},pn.clone=function(t){return zn(t,d)},pn.cloneDeep=function(t){return zn(t,h|d)},pn.cloneDeepWith=function(t,e){return zn(t,h|d,e="function"==typeof e?e:a)},pn.cloneWith=function(t,e){return zn(t,d,e="function"==typeof e?e:a)},pn.conformsTo=function(t,e){return null==e||Rn(t,e,il(e))},pn.deburr=gl,pn.defaultTo=function(t,e){return null==t||t!=t?e:t},pn.divide=Wl,pn.endsWith=function(t,e,r){t=Gs(t),e=Ri(e);var n=t.length,i=r=r===a?n:Dn(Vs(r),0,n);return(r-=e.length)>=0&&t.slice(r,i)==e},pn.eq=ps,pn.escape=function(t){return(t=Gs(t))&&Tt.test(t)?t.replace(kt,wr):t},pn.escapeRegExp=function(t){return(t=Gs(t))&&Pt.test(t)?t.replace(It,"\\$&"):t},pn.every=function(t,e,r){var n=ms(t)?Ze:Vn;return r&&Wa(t,e,r)&&(e=a),n(t,za(e,3))},pn.find=Ho,pn.findIndex=go,pn.findKey=function(t,e){return ar(t,za(e,3),Yn)},pn.findLast=qo,pn.findLastIndex=mo,pn.findLastKey=function(t,e){return ar(t,za(e,3),Xn)},pn.floor=Yl,pn.forEach=Go,pn.forEachRight=Wo,pn.forIn=function(t,e){return null==t?t:Gn(t,za(e,3),al)},pn.forInRight=function(t,e){return null==t?t:Wn(t,za(e,3),al)},pn.forOwn=function(t,e){return t&&Yn(t,za(e,3))},pn.forOwnRight=function(t,e){return t&&Xn(t,za(e,3))},pn.get=Qs,pn.gt=ds,pn.gte=vs,pn.has=function(t,e){return null!=t&&Ua(t,e,ti)},pn.hasIn=tl,pn.head=xo,pn.identity=Ll,pn.includes=function(t,e,r,n){t=xs(t)?t:pl(t),r=r&&!n?Vs(r):0;var i=t.length;return r<0&&(r=qr(i+r,0)),Ds(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&sr(t,e,r)>-1},pn.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:Vs(r);return i<0&&(i=qr(n+i,0)),sr(t,e,i)},pn.inRange=function(t,e,r){return e=js(e),r===a?(r=e,e=0):r=js(r),function(t,e,r){return t>=Gr(e,r)&&t=-D&&t<=D},pn.isSet=Ps,pn.isString=Ds,pn.isSymbol=zs,pn.isTypedArray=Rs,pn.isUndefined=function(t){return t===a},pn.isWeakMap=function(t){return Ss(t)&&Va(t)==ot},pn.isWeakSet=function(t){return Ss(t)&&Kn(t)==st},pn.join=function(t,e){return null==t?"":Ur.call(t,e)},pn.kebabCase=ml,pn.last=ko,pn.lastIndexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=n;return r!==a&&(i=(i=Vs(r))<0?qr(n+i,0):Gr(i,n-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,i):or(t,ur,i,!0)},pn.lowerCase=yl,pn.lowerFirst=xl,pn.lt=Fs,pn.lte=Bs,pn.max=function(t){return t&&t.length?Un(t,Ll,Qn):a},pn.maxBy=function(t,e){return t&&t.length?Un(t,za(e,2),Qn):a},pn.mean=function(t){return cr(t,Ll)},pn.meanBy=function(t,e){return cr(t,za(e,2))},pn.min=function(t){return t&&t.length?Un(t,Ll,fi):a},pn.minBy=function(t,e){return t&&t.length?Un(t,za(e,2),fi):a},pn.stubArray=Ul,pn.stubFalse=Hl,pn.stubObject=function(){return{}},pn.stubString=function(){return""},pn.stubTrue=function(){return!0},pn.multiply=Zl,pn.nth=function(t,e){return t&&t.length?gi(t,Vs(e)):a},pn.noConflict=function(){return Pe._===this&&(Pe._=ve),this},pn.noop=zl,pn.now=Qo,pn.pad=function(t,e,r){t=Gs(t);var n=(e=Vs(e))?Lr(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return ma(Br(i),r)+t+ma(Fr(i),r)},pn.padEnd=function(t,e,r){t=Gs(t);var n=(e=Vs(e))?Lr(t):0;return e&&ne){var n=t;t=e,e=n}if(r||t%1||e%1){var i=Xr();return Gr(t+i*(e-t+Ce("1e-"+((i+"").length-1))),e)}return _i(t,e)},pn.reduce=function(t,e,r){var n=ms(t)?er:pr,i=arguments.length<3;return n(t,za(e,4),r,i,Nn)},pn.reduceRight=function(t,e,r){var n=ms(t)?rr:pr,i=arguments.length<3;return n(t,za(e,4),r,i,jn)},pn.repeat=function(t,e,r){return e=(r?Wa(t,e,r):e===a)?1:Vs(e),wi(Gs(t),e)},pn.replace=function(){var t=arguments,e=Gs(t[0]);return t.length<3?e:e.replace(t[1],t[2])},pn.result=function(t,e,r){var n=-1,i=(e=Wi(e,t)).length;for(i||(i=1,t=a);++nD)return[];var r=F,n=Gr(t,F);e=za(e),t-=F;for(var i=vr(n,e);++r=o)return t;var l=r-Lr(n);if(l<1)return n;var u=s?Xi(s,0,l).join(""):t.slice(0,l);if(i===a)return u+n;if(s&&(l+=u.length-l),Is(i)){if(t.slice(l).search(i)){var c,f=u;for(i.global||(i=re(i.source,Gs(Ht.exec(i))+"g")),i.lastIndex=0;c=i.exec(f);)var h=c.index;u=u.slice(0,h===a?l:h)}}else if(t.indexOf(Ri(i),l)!=l){var p=u.lastIndexOf(i);p>-1&&(u=u.slice(0,p))}return u+n},pn.unescape=function(t){return(t=Gs(t))&&At.test(t)?t.replace(wt,Ir):t},pn.uniqueId=function(t){var e=++fe;return Gs(t)+e},pn.upperCase=wl,pn.upperFirst=kl,pn.each=Go,pn.eachRight=Wo,pn.first=xo,Dl(pn,(Xl={},Yn(pn,function(t,e){ce.call(pn.prototype,e)||(Xl[e]=t)}),Xl),{chain:!1}),pn.VERSION="4.17.15",Ye(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){pn[t].placeholder=pn}),Ye(["drop","take"],function(t,e){mn.prototype[t]=function(r){r=r===a?1:qr(Vs(r),0);var n=this.__filtered__&&!e?new mn(this):this.clone();return n.__filtered__?n.__takeCount__=Gr(r,n.__takeCount__):n.__views__.push({size:Gr(r,F),type:t+(n.__dir__<0?"Right":"")}),n},mn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Ye(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==O||3==r;mn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:za(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),Ye(["head","last"],function(t,e){var r="take"+(e?"Right":"");mn.prototype[t]=function(){return this[r](1).value()[0]}}),Ye(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");mn.prototype[t]=function(){return this.__filtered__?new mn(this):this[r](1)}}),mn.prototype.compact=function(){return this.filter(Ll)},mn.prototype.find=function(t){return this.filter(t).head()},mn.prototype.findLast=function(t){return this.reverse().find(t)},mn.prototype.invokeMap=ki(function(t,e){return"function"==typeof t?new mn(this):this.map(function(r){return ni(r,t,e)})}),mn.prototype.reject=function(t){return this.filter(ls(za(t)))},mn.prototype.slice=function(t,e){t=Vs(t);var r=this;return r.__filtered__&&(t>0||e<0)?new mn(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==a&&(r=(e=Vs(e))<0?r.dropRight(-e):r.take(e-t)),r)},mn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},mn.prototype.toArray=function(){return this.take(F)},Yn(mn.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),n=/^(?:head|last)$/.test(e),i=pn[n?"take"+("last"==e?"Right":""):e],o=n||/^find/.test(e);i&&(pn.prototype[e]=function(){var e=this.__wrapped__,s=n?[1]:arguments,l=e instanceof mn,u=s[0],c=l||ms(e),f=function(t){var e=i.apply(pn,tr([t],s));return n&&h?e[0]:e};c&&r&&"function"==typeof u&&1!=u.length&&(l=c=!1);var h=this.__chain__,p=!!this.__actions__.length,d=o&&!h,v=l&&!p;if(!o&&c){e=v?e:new mn(this);var g=t.apply(e,s);return g.__actions__.push({func:jo,args:[f],thisArg:a}),new gn(g,h)}return d&&v?t.apply(this,s):(g=this.thru(f),d?n?g.value()[0]:g.value():g)})}),Ye(["pop","push","shift","sort","splice","unshift"],function(t){var e=ae[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);pn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(ms(i)?i:[],t)}return this[r](function(r){return e.apply(ms(r)?r:[],t)})}}),Yn(mn.prototype,function(t,e){var r=pn[e];if(r){var n=r.name+"";ce.call(nn,n)||(nn[n]=[]),nn[n].push({name:e,func:r})}}),nn[pa(a,y).name]=[{name:"wrapper",func:a}],mn.prototype.clone=function(){var t=new mn(this.__wrapped__);return t.__actions__=ra(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=ra(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=ra(this.__views__),t},mn.prototype.reverse=function(){if(this.__filtered__){var t=new mn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},mn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=ms(t),n=e<0,i=r?t.length:0,a=function(t,e,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:t,value:t?a:this.__values__[this.__index__++]}},pn.prototype.plant=function(t){for(var e,r=this;r instanceof vn;){var n=fo(r);n.__index__=0,n.__values__=a,e?i.__wrapped__=n:e=n;var i=n;r=r.__wrapped__}return i.__wrapped__=t,e},pn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof mn){var e=t;return this.__actions__.length&&(e=new mn(this)),(e=e.reverse()).__actions__.push({func:jo,args:[Eo],thisArg:a}),new gn(e,this.__chain__)}return this.thru(Eo)},pn.prototype.toJSON=pn.prototype.valueOf=pn.prototype.value=function(){return Vi(this.__wrapped__,this.__actions__)},pn.prototype.first=pn.prototype.head,Be&&(pn.prototype[Be]=function(){return this}),pn}();Pe._=Pr,(i=function(){return Pr}.call(e,r,e,n))===a||(n.exports=i)}).call(this)}).call(this,r(51),r(87)(t))},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},,,function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},i=r(70),a={};e.default=a,a.read=function(t,e){var r,n=(r=this,function(t,n,i){return a._onRetrieval(t,i,e,r)});return void 0===e?new Promise(function(r,a){e=function(t,e){t?a(t):r(e)},i(t,n)}):i(t,n)},a._onRetrieval=function(t,e,r,n){var i=void 0;return void 0!==t&&(i=n.parse(e)),r.call(n,t,i)},a.extend=function(t,e){return extend(a,t,e)},a.mixin=function(t){return"object"!==(void 0===t?"undefined":n(t))&&(t=t.prototype),["read"].forEach(function(e){t[e]=a[e]},this),t}},,,,,,,,,,function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=a(r(88)),i=a(r(89));function a(t){return t&&t.__esModule?t:{default:t}}var o=(0,n.default)(i.default);e.default=o,t.exports=e.default},function(t,e,r){"use strict";var n=r(97);t.exports=Function.prototype.bind||n},function(t,e,r){"use strict";var n=Function.prototype.toString,i=/^\s*class\b/,a=function(t){try{var e=n.call(t);return i.test(e)}catch(t){return!1}},o=Object.prototype.toString,s="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;t.exports=function(t){if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;if("function"==typeof t&&!t.prototype)return!0;if(s)return function(t){try{return!a(t)&&(n.call(t),!0)}catch(t){return!1}}(t);if(a(t))return!1;var e=o.call(t);return"[object Function]"===e||"[object GeneratorFunction]"===e}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n={};e.default=n,n.getMeta=function(t){var e,r,n=!1,i=!1,a={},o={},s=t.split(" ");if(s.length>=1?(n=s.shift(),i=s.join(" ")):n=t,n){var l=n.split("|");for(e=l.pop(),o.en=e;0!=l.length;){var u=l.shift(),c=l.shift();a[u]=c}}else e=n;if(i){var f=i.split("=");if(f.length>1){var h,p;f.length;f.forEach(function(t){var e,n=(t=t.trim()).split(" ");if(n.length>1?(p=n.pop(),e=n.join(" ")):e=t,h){var i=h.toLowerCase();o[i]=e}else r=e;h=p})}else r=f.shift()}var d={name:e,ids:a,details:o};return r&&(d.desc=r),d};var i={sp:{link:"http://www.uniprot.org/%s",name:"Uniprot"},tr:{link:"http://www.uniprot.org/%s",name:"Trembl"},gb:{link:"http://www.ncbi.nlm.nih.gov/nuccore/%s",name:"Genbank"},pdb:{link:"http://www.rcsb.org/pdb/explore/explore.do?structureId=%s",name:"PDB"}};n.buildLinks=function(t){var e={};return t=t||{},Object.keys(t).forEach(function(r){if(r in i){var n=i[r],a=n.link.replace("%s",t[r]);e[n.name]=a}}),e},n.contains=function(t,e){return-1!=="".indexOf.call(t,e,0)},n.splitNChars=function(t,e){var r,n;e=e||80;var i=[];for(r=0,n=t.length-1;r<=n;r+=e)i.push(t.substr(r,e));return i},n.reverse=function(t){return t.split("").reverse().join("")},n.complement=function(t){var e=t+"",r=[[/g/g,"0"],[/c/g,"1"],[/0/g,"c"],[/1/g,"g"],[/G/g,"0"],[/C/g,"1"],[/0/g,"C"],[/1/g,"G"],[/a/g,"0"],[/t/g,"1"],[/0/g,"t"],[/1/g,"a"],[/A/g,"0"],[/T/g,"1"],[/0/g,"T"],[/1/g,"A"]];for(var n in r)e=e.replace(r[n][0],r[n][1]);return e},n.reverseComplement=function(t){return n.reverse(n.complement(t))},n.model=function(t,e,r){this.seq=t,this.name=e,this.id=r,this.ids={}}},,function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var n=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(t,r):{};n.get||n.set?Object.defineProperty(e,r,n):e[r]=t[r]}return e.default=t,e}(r(1)),i=f(r(0)),a=f(r(50)),o=f(r(64)),s=r(90),l=r(75),u=r(76),c=r(120);function f(t){return t&&t.__esModule?t:{default:t}}function h(t){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function p(){return(p=Object.assign||function(t){for(var e=1;eJ&&(J=e):e=(0,l.getConservation)(t),e}),Z="entropy"===x?Z.map(function(t){return 1-t/J}):Z.map(function(t){return t/P})),_&&($=I.map(function(t){return a.default.countBy(t)["-"]/P})),b)for(var K=0;KBar weights",titlefont:{size:12},showgrid:!1,zeroline:!1,domain:[.75,1]}):3===h?(S.yaxis.domain=[0,.64],S.yaxis2={title:"Conservation",titlefont:{size:12},showgrid:!1,zeroline:!1,domain:[.65,.89]},S.yaxis3={title:"Gap",titlefont:{size:12},showgrid:!1,zeroline:!1,domain:[.9,1]}):S.yaxis.domain=[0,1],"heatmap"===m?(S.xaxis.rangeslider={autorange:!0},S.xaxis.tick0=x,S.xaxis.dtick=b,S.margin={t:20,r:20,b:20}):"slider"===m?S.sliders=[{currentvalue:{prefix:"Position ",suffix:""},steps:o}]:(S.xaxis.tick0=x,S.xaxis.dtick=b,S.margin={t:20,r:20,b:20}),{layout:S,width:e,height:n}}},{key:"componentDidMount",value:function(){var t=this.resetWindowing(this.props),e=t.xStart,r=t.xEnd;this.setState({xStart:e,xEnd:r})}},{key:"componentDidUpdate",value:function(t,e){if(this.props.data!==t.data){var r=this.resetWindowing(this.props),n=r.xStart,i=r.xEnd;this.setState({xStart:n,xEnd:i})}}},{key:"render",value:function(){var t=this.getData(),e=t.data,r=t.length,i=t.count,a=t.labels,s=t.tick,l=t.plotCount,u=this.getLayout({length:r,count:i,labels:a,tick:s,plotCount:l}),c=u.layout,f={style:{width:u.width,height:u.height},useResizeHandler:!0};return n.default.createElement("div",null,n.default.createElement(o.default,p({data:e,layout:c,onClick:this.handleChange,onHover:this.handleChange,onRelayout:this.handleChange},f)))}}])&&v(r.prototype,i),f&&v(r,f),e}();e.default=x,x.propTypes={data:i.default.string,extension:i.default.string,colorscale:i.default.oneOfType([i.default.string,i.default.object]),opacity:i.default.oneOfType([i.default.number,i.default.string]),textcolor:i.default.string,textsize:i.default.oneOfType([i.default.number,i.default.string]),showlabel:i.default.bool,showid:i.default.bool,showconservation:i.default.bool,conservationcolor:i.default.string,conservationcolorscale:i.default.oneOfType([i.default.string,i.default.array]),conservationopacity:i.default.oneOfType([i.default.number,i.default.string]),conservationmethod:i.default.oneOf(["conservation","entropy"]),correctgap:i.default.bool,showgap:i.default.bool,gapcolor:i.default.string,gapcolorscale:i.default.oneOfType([i.default.string,i.default.array]),gapopacity:i.default.oneOfType([i.default.number,i.default.string]),groupbars:i.default.bool,showconsensus:i.default.bool,tilewidth:i.default.number,tileheight:i.default.number,overview:i.default.oneOf(["heatmap","slider","none"]),numtiles:i.default.number,scrollskip:i.default.number,tickstart:i.default.oneOfType([i.default.number,i.default.string]),ticksteps:i.default.oneOfType([i.default.number,i.default.string]),width:i.default.oneOfType([i.default.number,i.default.string]),height:i.default.oneOfType([i.default.number,i.default.string])},x.defaultProps={extension:"fasta",colorscale:"clustal2",opacity:null,textcolor:null,textsize:10,showlabel:!0,showid:!0,showconservation:!0,conservationcolor:null,conservationcolorscale:"Viridis",conservationopacity:null,conservationmethod:"entropy",correctgap:!0,showgap:!0,gapcolor:"grey",gapcolorscale:null,gapopacity:null,groupbars:!1,showconsensus:!0,tilewidth:16,tileheight:16,numtiles:null,overview:"heatmap",scrollskip:10,tickstart:null,ticksteps:null,width:null,height:900}},function(t,e,r){"use strict";var n=r(93),i=r(94),a=r(95),o=r(111);function s(t,e,r){var n=t;return i(e)?(r=e,"string"==typeof t&&(n={uri:t})):n=o(e,{uri:t}),n.callback=r,n}function l(t,e,r){return u(e=s(t,e,r))}function u(t){if(void 0===t.callback)throw new Error("callback argument missing");var e=!1,r=function(r,n,i){e||(e=!0,t.callback(r,n,i))};function n(t){return clearTimeout(c),t instanceof Error||(t=new Error(""+(t||"Unknown XMLHttpRequest Error"))),t.statusCode=0,r(t,m)}function i(){if(!s){var e;clearTimeout(c),e=t.useXDR&&void 0===u.status?200:1223===u.status?204:u.status;var n=m,i=null;return 0!==e?(n={body:function(){var t=void 0;if(t=u.response?u.response:u.responseText||function(t){try{if("document"===t.responseType)return t.responseXML;var e=t.responseXML&&"parsererror"===t.responseXML.documentElement.nodeName;if(""===t.responseType&&!e)return t.responseXML}catch(t){}return null}(u),g)try{t=JSON.parse(t)}catch(t){}return t}(),statusCode:e,method:h,headers:{},url:f,rawRequest:u},u.getAllResponseHeaders&&(n.headers=a(u.getAllResponseHeaders()))):i=new Error("Internal XMLHttpRequest Error"),r(i,n,n.body)}}var o,s,u=t.xhr||null;u||(u=t.cors||t.useXDR?new l.XDomainRequest:new l.XMLHttpRequest);var c,f=u.url=t.uri||t.url,h=u.method=t.method||"GET",p=t.body||t.data,d=u.headers=t.headers||{},v=!!t.sync,g=!1,m={body:void 0,headers:{},statusCode:0,method:h,url:f,rawRequest:u};if("json"in t&&!1!==t.json&&(g=!0,d.accept||d.Accept||(d.Accept="application/json"),"GET"!==h&&"HEAD"!==h&&(d["content-type"]||d["Content-Type"]||(d["Content-Type"]="application/json"),p=JSON.stringify(!0===t.json?p:t.json))),u.onreadystatechange=function(){4===u.readyState&&setTimeout(i,0)},u.onload=i,u.onerror=n,u.onprogress=function(){},u.onabort=function(){s=!0},u.ontimeout=n,u.open(h,f,!v,t.username,t.password),v||(u.withCredentials=!!t.withCredentials),!v&&t.timeout>0&&(c=setTimeout(function(){if(!s){s=!0,u.abort("timeout");var t=new Error("XMLHttpRequest timeout");t.code="ETIMEDOUT",n(t)}},t.timeout)),u.setRequestHeader)for(o in d)d.hasOwnProperty(o)&&u.setRequestHeader(o,d[o]);else if(t.headers&&!function(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}(t.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in t&&(u.responseType=t.responseType),"beforeSend"in t&&"function"==typeof t.beforeSend&&t.beforeSend(u),u.send(p||null),u}t.exports=l,t.exports.default=l,l.XMLHttpRequest=n.XMLHttpRequest||function(){},l.XDomainRequest="withCredentials"in new l.XMLHttpRequest?l.XMLHttpRequest:n.XDomainRequest,function(t,e){for(var r=0;r2?arguments[2]:{},a=n(e);i&&(a=o.call(a,Object.getOwnPropertySymbols(e)));for(var s=0;s0&&(n=(r=t.split(" "))[0],i=r[1].replace(/"/g,""),e[n]=i)}),e}function i(t){var e=t.toString(16);return 1===e.length?"0"+e:e}function a(t,e,r){return 3===t.length?a(t[0],t[1],t[2]):"#"+i(t)+i(e)+i(r)}Object.defineProperty(e,"__esModule",{value:!0}),e.extractKeys=n,e.rgbToHex=a,e.default={extractKeys:n,rgbToHex:a}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getConsensus=e.getConservation=e.getEntropy=void 0;var n,i=(n=r(50))&&n.__esModule?n:{default:n};e.getEntropy=function(t){var e;e=i.default.isString(t)?t.split(""):t;var r={};return e.forEach(function(t){return r[t]?r[t]++:r[t]=1}),Object.keys(r).reduce(function(t,n){var i=r[n]/e.length;return t-i*Math.log(i)},0)};e.getConservation=function(t){var e;return e=i.default.isString(t)?t.split(""):t,(0,i.default)(e).countBy().entries().maxBy("[1]")[1]};e.getConsensus=function(t){return t.map(function(t){return(0,i.default)(t).countBy().entries().maxBy("[1]")[0]})}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getVisualizations=e.getTicks=e.getHovertext=e.getWidth=e.SUBPLOT_RATIOS=void 0;var n,i=(n=r(50))&&n.__esModule?n:{default:n};e.SUBPLOT_RATIOS={1:1,2:.75,3:.65};e.getWidth=function(t){return i.default.isNumber(t)?t:t.includes("%")?parseFloat(t)/100*window.innerWidth:parseFloat(t)};e.getHovertext=function(t,e){for(var r=[],n=function(n){var i=[],a=0;t[n].forEach(function(t){a+=1;var r=["Name: ".concat(e[n].name),"Organism: ".concat(e[n].os?e[n].os:"N/A"),"ID: ".concat(e[n].id,"
"),"Position: (".concat(a,", ").concat(n,")"),"Letter: ".concat(t)].join("
");i.push(r)}),r.push(i)},a=0;a=0||(i[r]=t[r]);return i}(e,["children"]);if(delete n.in,delete n.mountOnEnter,delete n.unmountOnExit,delete n.appear,delete n.enter,delete n.exit,delete n.timeout,delete n.addEndListener,delete n.onEnter,delete n.onEntering,delete n.onEntered,delete n.onExit,delete n.onExiting,delete n.onExited,"function"==typeof r)return r(t,n);var a=i.default.Children.only(r);return i.default.cloneElement(a,n)},n}(i.default.Component);function p(){}h.contextTypes={transitionGroup:n.object},h.childContextTypes={transitionGroup:function(){}},h.propTypes={},h.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:p,onEntering:p,onEntered:p,onExit:p,onExiting:p,onExited:p},h.UNMOUNTED=0,h.EXITED=1,h.ENTERING=2,h.ENTERED=3,h.EXITING=4;var d=(0,o.polyfill)(h);e.default=d},function(t,e,r){"use strict";function n(){var t=this.constructor.getDerivedStateFromProps(this.props,this.state);null!=t&&this.setState(t)}function i(t){this.setState(function(e){var r=this.constructor.getDerivedStateFromProps(t,e);return null!=r?r:null}.bind(this))}function a(t,e){try{var r=this.props,n=this.state;this.props=t,this.state=e,this.__reactInternalSnapshotFlag=!0,this.__reactInternalSnapshot=this.getSnapshotBeforeUpdate(r,n)}finally{this.props=r,this.state=n}}function o(t){var e=t.prototype;if(!e||!e.isReactComponent)throw new Error("Can only polyfill class components");if("function"!=typeof t.getDerivedStateFromProps&&"function"!=typeof e.getSnapshotBeforeUpdate)return t;var r=null,o=null,s=null;if("function"==typeof e.componentWillMount?r="componentWillMount":"function"==typeof e.UNSAFE_componentWillMount&&(r="UNSAFE_componentWillMount"),"function"==typeof e.componentWillReceiveProps?o="componentWillReceiveProps":"function"==typeof e.UNSAFE_componentWillReceiveProps&&(o="UNSAFE_componentWillReceiveProps"),"function"==typeof e.componentWillUpdate?s="componentWillUpdate":"function"==typeof e.UNSAFE_componentWillUpdate&&(s="UNSAFE_componentWillUpdate"),null!==r||null!==o||null!==s){var l=t.displayName||t.name,u="function"==typeof t.getDerivedStateFromProps?"getDerivedStateFromProps()":"getSnapshotBeforeUpdate()";throw Error("Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n"+l+" uses "+u+" but also contains the following legacy lifecycles:"+(null!==r?"\n "+r:"")+(null!==o?"\n "+o:"")+(null!==s?"\n "+s:"")+"\n\nThe above lifecycles should be removed. Learn more about this warning here:\nhttps://fb.me/react-async-component-lifecycle-hooks")}if("function"==typeof t.getDerivedStateFromProps&&(e.componentWillMount=n,e.componentWillReceiveProps=i),"function"==typeof e.getSnapshotBeforeUpdate){if("function"!=typeof e.componentDidUpdate)throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");e.componentWillUpdate=a;var c=e.componentDidUpdate;e.componentDidUpdate=function(t,e,r){var n=this.__reactInternalSnapshotFlag?this.__reactInternalSnapshot:r;c.call(this,t,e,n)}}return t}r.r(e),r.d(e,"polyfill",function(){return o}),n.__suppressDeprecationWarning=!0,i.__suppressDeprecationWarning=!0,a.__suppressDeprecationWarning=!0},function(t,e,r){"use strict";e.__esModule=!0,e.classNamesShape=e.timeoutsShape=void 0;var n;(n=r(0))&&n.__esModule;e.timeoutsShape=null;e.classNamesShape=null},function(t,e,r){"use strict";e.__esModule=!0,e.default=void 0;var n=s(r(0)),i=s(r(1)),a=r(78),o=r(149);function s(t){return t&&t.__esModule?t:{default:t}}function l(){return(l=Object.assign||function(t){for(var e=1;e=0||(i[r]=t[r]);return i}(t,["component","childFactory"]),a=c(this.state.children).map(r);return delete n.appear,delete n.enter,delete n.exit,null===e?a:i.default.createElement(e,n,a)},n}(i.default.Component);f.childContextTypes={transitionGroup:n.default.object.isRequired},f.propTypes={},f.defaultProps={component:"div",childFactory:function(t){return t}};var h=(0,a.polyfill)(f);e.default=h,t.exports=e.default},,,,,function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"AlignmentViewer",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(e,"AlignmentChart",{enumerable:!0,get:function(){return i.default}});var n=a(r(86)),i=a(r(69));function a(t){return t&&t.__esModule?t:{default:t}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var n=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(t,r):{};n.get||n.set?Object.defineProperty(e,r,n):e[r]=t[r]}return e.default=t,e}(r(1)),i=u(r(0)),a=u(r(69)),o=r(135),s=r(76),l=r(150);function u(t){return t&&t.__esModule?t:{default:t}}function c(t){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function f(){return(f=Object.assign||function(t){for(var e=1;e=0||(i[r]=t[r]);return i}(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(i[r]=t[r])}return i}function p(t,e){for(var r=0;r:not(.watermark)":"opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;","X:hover .modebar--hover .modebar-group":"opacity:1;","X .modebar-group":"float:left;display:inline-block;box-sizing:border-box;padding-left:8px;position:relative;vertical-align:middle;white-space:nowrap;","X .modebar-btn":"position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;","X .modebar-btn svg":"position:relative;top:2px;","X .modebar.vertical":"display:flex;flex-direction:column;flex-wrap:wrap;align-content:flex-end;max-height:100%;","X .modebar.vertical svg":"top:-1px;","X .modebar.vertical .modebar-group":"display:block;float:none;padding-left:0px;padding-bottom:8px;","X .modebar.vertical .modebar-group .modebar-btn":"display:block;text-align:center;","X [data-title]:before,X [data-title]:after":"position:absolute;-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-ms-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);display:none;opacity:0;z-index:1001;pointer-events:none;top:110%;right:50%;","X [data-title]:hover:before,X [data-title]:hover:after":"display:block;opacity:1;","X [data-title]:before":"content:'';position:absolute;background:transparent;border:6px solid transparent;z-index:1002;margin-top:-12px;border-bottom-color:#69738a;margin-right:-6px;","X [data-title]:after":"content:attr(data-title);background:#69738a;color:white;padding:8px 10px;font-size:12px;line-height:12px;white-space:nowrap;margin-right:-18px;border-radius:2px;","X .vertical [data-title]:before,X .vertical [data-title]:after":"top:0%;right:200%;","X .vertical [data-title]:before":"border:6px solid transparent;border-left-color:#69738a;margin-top:8px;margin-right:-30px;","X .select-outline":"fill:none;stroke-width:1;shape-rendering:crispEdges;","X .select-outline-1":"stroke:white;","X .select-outline-2":"stroke:black;stroke-dasharray:2px 2px;",Y:"font-family:'Open Sans';position:fixed;top:50px;right:20px;z-index:10000;font-size:10pt;max-width:180px;","Y p":"margin:0;","Y .notifier-note":"min-width:180px;max-width:250px;border:1px solid #fff;z-index:3000;margin:0;background-color:#8c97af;background-color:rgba(140,151,175,0.9);color:#fff;padding:10px;overflow-wrap:break-word;word-wrap:break-word;-ms-hyphens:auto;-webkit-hyphens:auto;hyphens:auto;","Y .notifier-close":"color:#fff;opacity:0.8;float:right;padding:0 5px;background:none;border:none;font-size:20px;font-weight:bold;line-height:20px;","Y .notifier-close:hover":"color:#444;text-decoration:none;cursor:pointer;"};for(var a in i){var o=a.replace(/^,/," ,").replace(/X/g,".js-plotly-plot .plotly").replace(/Y/g,".plotly-notifier");n.addStyleRule(o,i[a])}},{"../src/lib":703}],2:[function(t,e,r){"use strict";e.exports={undo:{width:857.1,height:1e3,path:"m857 350q0-87-34-166t-91-137-137-92-166-34q-96 0-183 41t-147 114q-4 6-4 13t5 11l76 77q6 5 14 5 9-1 13-7 41-53 100-82t126-29q58 0 110 23t92 61 61 91 22 111-22 111-61 91-92 61-110 23q-55 0-105-20t-90-57l77-77q17-16 8-38-10-23-33-23h-250q-15 0-25 11t-11 25v250q0 24 22 33 22 10 39-8l72-72q60 57 137 88t159 31q87 0 166-34t137-92 91-137 34-166z",transform:"matrix(1 0 0 -1 0 850)"},home:{width:928.6,height:1e3,path:"m786 296v-267q0-15-11-26t-25-10h-214v214h-143v-214h-214q-15 0-25 10t-11 26v267q0 1 0 2t0 2l321 264 321-264q1-1 1-4z m124 39l-34-41q-5-5-12-6h-2q-7 0-12 3l-386 322-386-322q-7-4-13-4-7 2-12 7l-35 41q-4 5-3 13t6 12l401 334q18 15 42 15t43-15l136-114v109q0 8 5 13t13 5h107q8 0 13-5t5-13v-227l122-102q5-5 6-12t-4-13z",transform:"matrix(1 0 0 -1 0 850)"},"camera-retro":{width:1e3,height:1e3,path:"m518 386q0 8-5 13t-13 5q-37 0-63-27t-26-63q0-8 5-13t13-5 12 5 5 13q0 23 16 38t38 16q8 0 13 5t5 13z m125-73q0-59-42-101t-101-42-101 42-42 101 42 101 101 42 101-42 42-101z m-572-320h858v71h-858v-71z m643 320q0 89-62 152t-152 62-151-62-63-152 63-151 151-63 152 63 62 151z m-571 358h214v72h-214v-72z m-72-107h858v143h-462l-36-71h-360v-72z m929 143v-714q0-30-21-51t-50-21h-858q-29 0-50 21t-21 51v714q0 30 21 51t50 21h858q29 0 50-21t21-51z",transform:"matrix(1 0 0 -1 0 850)"},zoombox:{width:1e3,height:1e3,path:"m1000-25l-250 251c40 63 63 138 63 218 0 224-182 406-407 406-224 0-406-182-406-406s183-406 407-406c80 0 155 22 218 62l250-250 125 125z m-812 250l0 438 437 0 0-438-437 0z m62 375l313 0 0-312-313 0 0 312z",transform:"matrix(1 0 0 -1 0 850)"},pan:{width:1e3,height:1e3,path:"m1000 350l-187 188 0-125-250 0 0 250 125 0-188 187-187-187 125 0 0-250-250 0 0 125-188-188 186-187 0 125 252 0 0-250-125 0 187-188 188 188-125 0 0 250 250 0 0-126 187 188z",transform:"matrix(1 0 0 -1 0 850)"},zoom_plus:{width:875,height:1e3,path:"m1 787l0-875 875 0 0 875-875 0z m687-500l-187 0 0-187-125 0 0 187-188 0 0 125 188 0 0 187 125 0 0-187 187 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},zoom_minus:{width:875,height:1e3,path:"m0 788l0-876 875 0 0 876-875 0z m688-500l-500 0 0 125 500 0 0-125z",transform:"matrix(1 0 0 -1 0 850)"},autoscale:{width:1e3,height:1e3,path:"m250 850l-187 0-63 0 0-62 0-188 63 0 0 188 187 0 0 62z m688 0l-188 0 0-62 188 0 0-188 62 0 0 188 0 62-62 0z m-875-938l0 188-63 0 0-188 0-62 63 0 187 0 0 62-187 0z m875 188l0-188-188 0 0-62 188 0 62 0 0 62 0 188-62 0z m-125 188l-1 0-93-94-156 156 156 156 92-93 2 0 0 250-250 0 0-2 93-92-156-156-156 156 94 92 0 2-250 0 0-250 0 0 93 93 157-156-157-156-93 94 0 0 0-250 250 0 0 0-94 93 156 157 156-157-93-93 0 0 250 0 0 250z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_basic:{width:1500,height:1e3,path:"m375 725l0 0-375-375 375-374 0-1 1125 0 0 750-1125 0z",transform:"matrix(1 0 0 -1 0 850)"},tooltip_compare:{width:1125,height:1e3,path:"m187 786l0 2-187-188 188-187 0 0 937 0 0 373-938 0z m0-499l0 1-187-188 188-188 0 0 937 0 0 376-938-1z",transform:"matrix(1 0 0 -1 0 850)"},plotlylogo:{width:1542,height:1e3,path:"m0-10h182v-140h-182v140z m228 146h183v-286h-183v286z m225 714h182v-1000h-182v1000z m225-285h182v-715h-182v715z m225 142h183v-857h-183v857z m231-428h182v-429h-182v429z m225-291h183v-138h-183v138z",transform:"matrix(1 0 0 -1 0 850)"},"z-axis":{width:1e3,height:1e3,path:"m833 5l-17 108v41l-130-65 130-66c0 0 0 38 0 39 0-1 36-14 39-25 4-15-6-22-16-30-15-12-39-16-56-20-90-22-187-23-279-23-261 0-341 34-353 59 3 60 228 110 228 110-140-8-351-35-351-116 0-120 293-142 474-142 155 0 477 22 477 142 0 50-74 79-163 96z m-374 94c-58-5-99-21-99-40 0-24 65-43 144-43 79 0 143 19 143 43 0 19-42 34-98 40v216h87l-132 135-133-135h88v-216z m167 515h-136v1c16 16 31 34 46 52l84 109v54h-230v-71h124v-1c-16-17-28-32-44-51l-89-114v-51h245v72z",transform:"matrix(1 0 0 -1 0 850)"},"3d_rotate":{width:1e3,height:1e3,path:"m922 660c-5 4-9 7-14 11-359 263-580-31-580-31l-102 28 58-400c0 1 1 1 2 2 118 108 351 249 351 249s-62 27-100 42c88 83 222 183 347 122 16-8 30-17 44-27-2 1-4 2-6 4z m36-329c0 0 64 229-88 296-62 27-124 14-175-11 157-78 225-208 249-266 8-19 11-31 11-31 2 5 6 15 11 32-5-13-8-20-8-20z m-775-239c70-31 117-50 198-32-121 80-199 346-199 346l-96-15-58-12c0 0 55-226 155-287z m603 133l-317-139c0 0 4-4 19-14 7-5 24-15 24-15s-177-147-389 4c235-287 536-112 536-112l31-22 100 299-4-1z m-298-153c6-4 14-9 24-15 0 0-17 10-24 15z",transform:"matrix(1 0 0 -1 0 850)"},camera:{width:1e3,height:1e3,path:"m500 450c-83 0-150-67-150-150 0-83 67-150 150-150 83 0 150 67 150 150 0 83-67 150-150 150z m400 150h-120c-16 0-34 13-39 29l-31 93c-6 15-23 28-40 28h-340c-16 0-34-13-39-28l-31-94c-6-15-23-28-40-28h-120c-55 0-100-45-100-100v-450c0-55 45-100 100-100h800c55 0 100 45 100 100v450c0 55-45 100-100 100z m-400-550c-138 0-250 112-250 250 0 138 112 250 250 250 138 0 250-112 250-250 0-138-112-250-250-250z m365 380c-19 0-35 16-35 35 0 19 16 35 35 35 19 0 35-16 35-35 0-19-16-35-35-35z",transform:"matrix(1 0 0 -1 0 850)"},movie:{width:1e3,height:1e3,path:"m938 413l-188-125c0 37-17 71-44 94 64 38 107 107 107 187 0 121-98 219-219 219-121 0-219-98-219-219 0-61 25-117 66-156h-115c30 33 49 76 49 125 0 103-84 187-187 187s-188-84-188-187c0-57 26-107 65-141-38-22-65-62-65-109v-250c0-70 56-126 125-126h500c69 0 125 56 125 126l188-126c34 0 62 28 62 63v375c0 35-28 63-62 63z m-750 0c-69 0-125 56-125 125s56 125 125 125 125-56 125-125-56-125-125-125z m406-1c-87 0-157 70-157 157 0 86 70 156 157 156s156-70 156-156-70-157-156-157z",transform:"matrix(1 0 0 -1 0 850)"},question:{width:857.1,height:1e3,path:"m500 82v107q0 8-5 13t-13 5h-107q-8 0-13-5t-5-13v-107q0-8 5-13t13-5h107q8 0 13 5t5 13z m143 375q0 49-31 91t-77 65-95 23q-136 0-207-119-9-14 4-24l74-55q4-4 10-4 9 0 14 7 30 38 48 51 19 14 48 14 27 0 48-15t21-33q0-21-11-34t-38-25q-35-16-65-48t-29-70v-20q0-8 5-13t13-5h107q8 0 13 5t5 13q0 10 12 27t30 28q18 10 28 16t25 19 25 27 16 34 7 45z m214-107q0-117-57-215t-156-156-215-58-216 58-155 156-58 215 58 215 155 156 216 58 215-58 156-156 57-215z",transform:"matrix(1 0 0 -1 0 850)"},disk:{width:857.1,height:1e3,path:"m214-7h429v214h-429v-214z m500 0h72v500q0 8-6 21t-11 20l-157 156q-5 6-19 12t-22 5v-232q0-22-15-38t-38-16h-322q-22 0-37 16t-16 38v232h-72v-714h72v232q0 22 16 38t37 16h465q22 0 38-16t15-38v-232z m-214 518v178q0 8-5 13t-13 5h-107q-7 0-13-5t-5-13v-178q0-8 5-13t13-5h107q7 0 13 5t5 13z m357-18v-518q0-22-15-38t-38-16h-750q-23 0-38 16t-16 38v750q0 22 16 38t38 16h517q23 0 50-12t42-26l156-157q16-15 27-42t11-49z",transform:"matrix(1 0 0 -1 0 850)"},lasso:{width:1031,height:1e3,path:"m1018 538c-36 207-290 336-568 286-277-48-473-256-436-463 10-57 36-108 76-151-13-66 11-137 68-183 34-28 75-41 114-42l-55-70 0 0c-2-1-3-2-4-3-10-14-8-34 5-45 14-11 34-8 45 4 1 1 2 3 2 5l0 0 113 140c16 11 31 24 45 40 4 3 6 7 8 11 48-3 100 0 151 9 278 48 473 255 436 462z m-624-379c-80 14-149 48-197 96 42 42 109 47 156 9 33-26 47-66 41-105z m-187-74c-19 16-33 37-39 60 50-32 109-55 174-68-42-25-95-24-135 8z m360 75c-34-7-69-9-102-8 8 62-16 128-68 170-73 59-175 54-244-5-9 20-16 40-20 61-28 159 121 317 333 354s407-60 434-217c28-159-121-318-333-355z",transform:"matrix(1 0 0 -1 0 850)"},selectbox:{width:1e3,height:1e3,path:"m0 850l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-285l0-143 143 0 0 143-143 0z m857 0l0-143 143 0 0 143-143 0z m-857-286l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z m285 0l0-143 143 0 0 143-143 0z m286 0l0-143 143 0 0 143-143 0z",transform:"matrix(1 0 0 -1 0 850)"},spikeline:{width:1e3,height:1e3,path:"M512 409c0-57-46-104-103-104-57 0-104 47-104 104 0 57 47 103 104 103 57 0 103-46 103-103z m-327-39l92 0 0 92-92 0z m-185 0l92 0 0 92-92 0z m370-186l92 0 0 93-92 0z m0-184l92 0 0 92-92 0z",transform:"matrix(1.5 0 0 -1.5 0 850)"},newplotlylogo:{name:"newplotlylogo",svg:"plotly-logomark"}}},{}],3:[function(t,e,r){"use strict";e.exports=t("../src/transforms/aggregate")},{"../src/transforms/aggregate":1210}],4:[function(t,e,r){"use strict";e.exports=t("../src/traces/bar")},{"../src/traces/bar":848}],5:[function(t,e,r){"use strict";e.exports=t("../src/traces/barpolar")},{"../src/traces/barpolar":860}],6:[function(t,e,r){"use strict";e.exports=t("../src/traces/box")},{"../src/traces/box":870}],7:[function(t,e,r){"use strict";e.exports=t("../src/components/calendars")},{"../src/components/calendars":578}],8:[function(t,e,r){"use strict";e.exports=t("../src/traces/candlestick")},{"../src/traces/candlestick":879}],9:[function(t,e,r){"use strict";e.exports=t("../src/traces/carpet")},{"../src/traces/carpet":898}],10:[function(t,e,r){"use strict";e.exports=t("../src/traces/choropleth")},{"../src/traces/choropleth":912}],11:[function(t,e,r){"use strict";e.exports=t("../src/traces/cone")},{"../src/traces/cone":920}],12:[function(t,e,r){"use strict";e.exports=t("../src/traces/contour")},{"../src/traces/contour":935}],13:[function(t,e,r){"use strict";e.exports=t("../src/traces/contourcarpet")},{"../src/traces/contourcarpet":946}],14:[function(t,e,r){"use strict";e.exports=t("../src/core")},{"../src/core":682}],15:[function(t,e,r){"use strict";e.exports=t("../src/transforms/filter")},{"../src/transforms/filter":1211}],16:[function(t,e,r){"use strict";e.exports=t("../src/traces/funnel")},{"../src/traces/funnel":958}],17:[function(t,e,r){"use strict";e.exports=t("../src/traces/funnelarea")},{"../src/traces/funnelarea":967}],18:[function(t,e,r){"use strict";e.exports=t("../src/transforms/groupby")},{"../src/transforms/groupby":1212}],19:[function(t,e,r){"use strict";e.exports=t("../src/traces/heatmap")},{"../src/traces/heatmap":980}],20:[function(t,e,r){"use strict";e.exports=t("../src/traces/heatmapgl")},{"../src/traces/heatmapgl":989}],21:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram")},{"../src/traces/histogram":1001}],22:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram2d")},{"../src/traces/histogram2d":1007}],23:[function(t,e,r){"use strict";e.exports=t("../src/traces/histogram2dcontour")},{"../src/traces/histogram2dcontour":1011}],24:[function(t,e,r){"use strict";var n=t("./core");n.register([t("./bar"),t("./box"),t("./heatmap"),t("./histogram"),t("./histogram2d"),t("./histogram2dcontour"),t("./contour"),t("./scatterternary"),t("./violin"),t("./funnel"),t("./waterfall"),t("./pie"),t("./sunburst"),t("./funnelarea"),t("./scatter3d"),t("./surface"),t("./isosurface"),t("./volume"),t("./mesh3d"),t("./cone"),t("./streamtube"),t("./scattergeo"),t("./choropleth"),t("./scattergl"),t("./splom"),t("./pointcloud"),t("./heatmapgl"),t("./parcoords"),t("./parcats"),t("./scattermapbox"),t("./sankey"),t("./table"),t("./carpet"),t("./scattercarpet"),t("./contourcarpet"),t("./ohlc"),t("./candlestick"),t("./scatterpolar"),t("./scatterpolargl"),t("./barpolar")]),n.register([t("./aggregate"),t("./filter"),t("./groupby"),t("./sort")]),n.register([t("./calendars")]),e.exports=n},{"./aggregate":3,"./bar":4,"./barpolar":5,"./box":6,"./calendars":7,"./candlestick":8,"./carpet":9,"./choropleth":10,"./cone":11,"./contour":12,"./contourcarpet":13,"./core":14,"./filter":15,"./funnel":16,"./funnelarea":17,"./groupby":18,"./heatmap":19,"./heatmapgl":20,"./histogram":21,"./histogram2d":22,"./histogram2dcontour":23,"./isosurface":25,"./mesh3d":26,"./ohlc":27,"./parcats":28,"./parcoords":29,"./pie":30,"./pointcloud":31,"./sankey":32,"./scatter3d":33,"./scattercarpet":34,"./scattergeo":35,"./scattergl":36,"./scattermapbox":37,"./scatterpolar":38,"./scatterpolargl":39,"./scatterternary":40,"./sort":41,"./splom":42,"./streamtube":43,"./sunburst":44,"./surface":45,"./table":46,"./violin":47,"./volume":48,"./waterfall":49}],25:[function(t,e,r){"use strict";e.exports=t("../src/traces/isosurface")},{"../src/traces/isosurface":1016}],26:[function(t,e,r){"use strict";e.exports=t("../src/traces/mesh3d")},{"../src/traces/mesh3d":1021}],27:[function(t,e,r){"use strict";e.exports=t("../src/traces/ohlc")},{"../src/traces/ohlc":1026}],28:[function(t,e,r){"use strict";e.exports=t("../src/traces/parcats")},{"../src/traces/parcats":1035}],29:[function(t,e,r){"use strict";e.exports=t("../src/traces/parcoords")},{"../src/traces/parcoords":1044}],30:[function(t,e,r){"use strict";e.exports=t("../src/traces/pie")},{"../src/traces/pie":1055}],31:[function(t,e,r){"use strict";e.exports=t("../src/traces/pointcloud")},{"../src/traces/pointcloud":1064}],32:[function(t,e,r){"use strict";e.exports=t("../src/traces/sankey")},{"../src/traces/sankey":1070}],33:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatter3d")},{"../src/traces/scatter3d":1106}],34:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattercarpet")},{"../src/traces/scattercarpet":1112}],35:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattergeo")},{"../src/traces/scattergeo":1119}],36:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattergl")},{"../src/traces/scattergl":1127}],37:[function(t,e,r){"use strict";e.exports=t("../src/traces/scattermapbox")},{"../src/traces/scattermapbox":1133}],38:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatterpolar")},{"../src/traces/scatterpolar":1140}],39:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatterpolargl")},{"../src/traces/scatterpolargl":1144}],40:[function(t,e,r){"use strict";e.exports=t("../src/traces/scatterternary")},{"../src/traces/scatterternary":1150}],41:[function(t,e,r){"use strict";e.exports=t("../src/transforms/sort")},{"../src/transforms/sort":1214}],42:[function(t,e,r){"use strict";e.exports=t("../src/traces/splom")},{"../src/traces/splom":1155}],43:[function(t,e,r){"use strict";e.exports=t("../src/traces/streamtube")},{"../src/traces/streamtube":1160}],44:[function(t,e,r){"use strict";e.exports=t("../src/traces/sunburst")},{"../src/traces/sunburst":1166}],45:[function(t,e,r){"use strict";e.exports=t("../src/traces/surface")},{"../src/traces/surface":1175}],46:[function(t,e,r){"use strict";e.exports=t("../src/traces/table")},{"../src/traces/table":1183}],47:[function(t,e,r){"use strict";e.exports=t("../src/traces/violin")},{"../src/traces/violin":1191}],48:[function(t,e,r){"use strict";e.exports=t("../src/traces/volume")},{"../src/traces/volume":1199}],49:[function(t,e,r){"use strict";e.exports=t("../src/traces/waterfall")},{"../src/traces/waterfall":1205}],50:[function(t,e,r){"use strict";e.exports=function(t){var e=(t=t||{}).eye||[0,0,1],r=t.center||[0,0,0],s=t.up||[0,1,0],l=t.distanceLimits||[0,1/0],u=t.mode||"turntable",c=n(),f=i(),h=a();return c.setDistanceLimits(l[0],l[1]),c.lookAt(0,e,r,s),f.setDistanceLimits(l[0],l[1]),f.lookAt(0,e,r,s),h.setDistanceLimits(l[0],l[1]),h.lookAt(0,e,r,s),new o({turntable:c,orbit:f,matrix:h},u)};var n=t("turntable-camera-controller"),i=t("orbit-camera-controller"),a=t("matrix-camera-controller");function o(t,e){this._controllerNames=Object.keys(t),this._controllerList=this._controllerNames.map(function(e){return t[e]}),this._mode=e,this._active=t[e],this._active||(this._mode="turntable",this._active=t.turntable),this.modes=this._controllerNames,this.computedMatrix=this._active.computedMatrix,this.computedEye=this._active.computedEye,this.computedUp=this._active.computedUp,this.computedCenter=this._active.computedCenter,this.computedRadius=this._active.computedRadius}var s=o.prototype;[["flush",1],["idle",1],["lookAt",4],["rotate",4],["pan",4],["translate",4],["setMatrix",2],["setDistanceLimits",2],["setDistance",2]].forEach(function(t){for(var e=t[0],r=[],n=0;na&&(b=a);var o=e.min(i,function(t){return(y-n-(t.length-1)*b)/e.sum(t,c)});i.forEach(function(t){t.forEach(function(t,e){t.y1=(t.y0=e)+t.value*o})}),t.links.forEach(function(t){t.width=t.value*o})})(),d();for(var a=1,o=T;o>0;--o)l(a*=.99),d(),s(a),d();function s(t){i.forEach(function(r){r.forEach(function(r){if(r.targetLinks.length){var n=(e.sum(r.targetLinks,h)/e.sum(r.targetLinks,c)-f(r))*t;r.y0+=n,r.y1+=n}})})}function l(t){i.slice().reverse().forEach(function(r){r.forEach(function(r){if(r.sourceLinks.length){var n=(e.sum(r.sourceLinks,p)/e.sum(r.sourceLinks,c)-f(r))*t;r.y0+=n,r.y1+=n}})})}function d(){i.forEach(function(t){var e,r,i,a=n,o=t.length;for(t.sort(u),i=0;i0&&(e.y0+=r,e.y1+=r),a=e.y1+b;if((r=a-b-y)>0)for(a=e.y0-=r,e.y1-=r,i=o-2;i>=0;--i)e=t[i],(r=e.y1+b-a)>0&&(e.y0-=r,e.y1-=r),a=e.y0})}}(a),S(a),a}function S(t){t.nodes.forEach(function(t){t.sourceLinks.sort(l),t.targetLinks.sort(s)}),t.nodes.forEach(function(t){var e=t.y0,r=e;t.sourceLinks.forEach(function(t){t.y0=e+t.width/2,e+=t.width}),t.targetLinks.forEach(function(t){t.y1=r+t.width/2,r+=t.width})})}return E.update=function(t){return S(t),t},E.nodeId=function(t){return arguments.length?(_="function"==typeof t?t:o(t),E):_},E.nodeAlign=function(t){return arguments.length?(w="function"==typeof t?t:o(t),E):w},E.nodeWidth=function(t){return arguments.length?(x=+t,E):x},E.nodePadding=function(t){return arguments.length?(b=+t,E):b},E.nodes=function(t){return arguments.length?(k="function"==typeof t?t:o(t),E):k},E.links=function(t){return arguments.length?(A="function"==typeof t?t:o(t),E):A},E.size=function(e){return arguments.length?(t=n=0,i=+e[0],y=+e[1],E):[i-t,y-n]},E.extent=function(e){return arguments.length?(t=+e[0][0],i=+e[1][0],n=+e[0][1],y=+e[1][1],E):[[t,n],[i,y]]},E.iterations=function(t){return arguments.length?(T=+t,E):T},E},t.sankeyCenter=function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?e.min(t.sourceLinks,i)-1:0},t.sankeyLeft=function(t){return t.depth},t.sankeyRight=function(t,e){return e-1-t.height},t.sankeyJustify=a,t.sankeyLinkHorizontal=function(){return n.linkHorizontal().source(y).target(x)},Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof r&&void 0!==e?i(r,t("d3-array"),t("d3-collection"),t("d3-shape")):i(n.d3=n.d3||{},n.d3,n.d3,n.d3)},{"d3-array":145,"d3-collection":146,"d3-shape":155}],52:[function(t,e,r){"use strict";var n="undefined"==typeof WeakMap?t("weak-map"):WeakMap,i=t("gl-buffer"),a=t("gl-vao"),o=new n;e.exports=function(t){var e=o.get(t),r=e&&(e._triangleBuffer.handle||e._triangleBuffer.buffer);if(!r||!t.isBuffer(r)){var n=i(t,new Float32Array([-1,-1,-1,4,4,-1]));(e=a(t,[{buffer:n,type:t.FLOAT,size:2}]))._triangleBuffer=n,o.set(t,e)}e.bind(),t.drawArrays(t.TRIANGLES,0,3),e.unbind()}},{"gl-buffer":240,"gl-vao":322,"weak-map":539}],53:[function(t,e,r){e.exports=function(t){var e=0,r=0,n=0,i=0;return t.map(function(t){var a=(t=t.slice())[0],o=a.toUpperCase();if(a!=o)switch(t[0]=o,a){case"a":t[6]+=n,t[7]+=i;break;case"v":t[1]+=i;break;case"h":t[1]+=n;break;default:for(var s=1;si&&(i=t[o]),t[o]>> 1; + + /** Used to associate wrap methods with their bit flags. */ + var wrapFlags = [ + ['ary', WRAP_ARY_FLAG], + ['bind', WRAP_BIND_FLAG], + ['bindKey', WRAP_BIND_KEY_FLAG], + ['curry', WRAP_CURRY_FLAG], + ['curryRight', WRAP_CURRY_RIGHT_FLAG], + ['flip', WRAP_FLIP_FLAG], + ['partial', WRAP_PARTIAL_FLAG], + ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], + ['rearg', WRAP_REARG_FLAG] + ]; + + /** `Object#toString` result references. */ + var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + asyncTag = '[object AsyncFunction]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + domExcTag = '[object DOMException]', + errorTag = '[object Error]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + mapTag = '[object Map]', + numberTag = '[object Number]', + nullTag = '[object Null]', + objectTag = '[object Object]', + promiseTag = '[object Promise]', + proxyTag = '[object Proxy]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + symbolTag = '[object Symbol]', + undefinedTag = '[object Undefined]', + weakMapTag = '[object WeakMap]', + weakSetTag = '[object WeakSet]'; + + var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + + /** Used to match empty string literals in compiled template source. */ + var reEmptyStringLeading = /\b__p \+= '';/g, + reEmptyStringMiddle = /\b(__p \+=) '' \+/g, + reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; + + /** Used to match HTML entities and HTML characters. */ + var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, + reUnescapedHtml = /[&<>"']/g, + reHasEscapedHtml = RegExp(reEscapedHtml.source), + reHasUnescapedHtml = RegExp(reUnescapedHtml.source); + + /** Used to match template delimiters. */ + var reEscape = /<%-([\s\S]+?)%>/g, + reEvaluate = /<%([\s\S]+?)%>/g, + reInterpolate = /<%=([\s\S]+?)%>/g; + + /** Used to match property names within property paths. */ + var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/, + rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; + + /** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ + var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, + reHasRegExpChar = RegExp(reRegExpChar.source); + + /** Used to match leading and trailing whitespace. */ + var reTrim = /^\s+|\s+$/g, + reTrimStart = /^\s+/, + reTrimEnd = /\s+$/; + + /** Used to match wrap detail comments. */ + var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, + reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, + reSplitDetails = /,? & /; + + /** Used to match words composed of alphanumeric characters. */ + var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; + + /** Used to match backslashes in property paths. */ + var reEscapeChar = /\\(\\)?/g; + + /** + * Used to match + * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). + */ + var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; + + /** Used to match `RegExp` flags from their coerced string values. */ + var reFlags = /\w*$/; + + /** Used to detect bad signed hexadecimal string values. */ + var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + + /** Used to detect binary string values. */ + var reIsBinary = /^0b[01]+$/i; + + /** Used to detect host constructors (Safari). */ + var reIsHostCtor = /^\[object .+?Constructor\]$/; + + /** Used to detect octal string values. */ + var reIsOctal = /^0o[0-7]+$/i; + + /** Used to detect unsigned integer values. */ + var reIsUint = /^(?:0|[1-9]\d*)$/; + + /** Used to match Latin Unicode letters (excluding mathematical operators). */ + var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; + + /** Used to ensure capturing order of template delimiters. */ + var reNoMatch = /($^)/; + + /** Used to match unescaped characters in compiled string literals. */ + var reUnescapedString = /['\n\r\u2028\u2029\\]/g; + + /** Used to compose unicode character classes. */ + var rsAstralRange = '\\ud800-\\udfff', + rsComboMarksRange = '\\u0300-\\u036f', + reComboHalfMarksRange = '\\ufe20-\\ufe2f', + rsComboSymbolsRange = '\\u20d0-\\u20ff', + rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, + rsDingbatRange = '\\u2700-\\u27bf', + rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', + rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', + rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', + rsPunctuationRange = '\\u2000-\\u206f', + rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000', + rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', + rsVarRange = '\\ufe0e\\ufe0f', + rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; + + /** Used to compose unicode capture groups. */ + var rsApos = "['\u2019]", + rsAstral = '[' + rsAstralRange + ']', + rsBreak = '[' + rsBreakRange + ']', + rsCombo = '[' + rsComboRange + ']', + rsDigits = '\\d+', + rsDingbat = '[' + rsDingbatRange + ']', + rsLower = '[' + rsLowerRange + ']', + rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', + rsFitz = '\\ud83c[\\udffb-\\udfff]', + rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', + rsNonAstral = '[^' + rsAstralRange + ']', + rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', + rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', + rsUpper = '[' + rsUpperRange + ']', + rsZWJ = '\\u200d'; + + /** Used to compose unicode regexes. */ + var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', + rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', + rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', + rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', + reOptMod = rsModifier + '?', + rsOptVar = '[' + rsVarRange + ']?', + rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', + rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', + rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', + rsSeq = rsOptVar + reOptMod + rsOptJoin, + rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, + rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; + + /** Used to match apostrophes. */ + var reApos = RegExp(rsApos, 'g'); + + /** + * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and + * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). + */ + var reComboMark = RegExp(rsCombo, 'g'); + + /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ + var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); + + /** Used to match complex or compound words. */ + var reUnicodeWord = RegExp([ + rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', + rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', + rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, + rsUpper + '+' + rsOptContrUpper, + rsOrdUpper, + rsOrdLower, + rsDigits, + rsEmoji + ].join('|'), 'g'); + + /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ + var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); + + /** Used to detect strings that need a more robust regexp to match words. */ + var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; + + /** Used to assign default `context` object properties. */ + var contextProps = [ + 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', + 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', + 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', + 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', + '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' + ]; + + /** Used to make template sourceURLs easier to identify. */ + var templateCounter = -1; + + /** Used to identify `toStringTag` values of typed arrays. */ + var typedArrayTags = {}; + typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = + typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = + typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = + typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = + typedArrayTags[uint32Tag] = true; + typedArrayTags[argsTag] = typedArrayTags[arrayTag] = + typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = + typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = + typedArrayTags[errorTag] = typedArrayTags[funcTag] = + typedArrayTags[mapTag] = typedArrayTags[numberTag] = + typedArrayTags[objectTag] = typedArrayTags[regexpTag] = + typedArrayTags[setTag] = typedArrayTags[stringTag] = + typedArrayTags[weakMapTag] = false; + + /** Used to identify `toStringTag` values supported by `_.clone`. */ + var cloneableTags = {}; + cloneableTags[argsTag] = cloneableTags[arrayTag] = + cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = + cloneableTags[boolTag] = cloneableTags[dateTag] = + cloneableTags[float32Tag] = cloneableTags[float64Tag] = + cloneableTags[int8Tag] = cloneableTags[int16Tag] = + cloneableTags[int32Tag] = cloneableTags[mapTag] = + cloneableTags[numberTag] = cloneableTags[objectTag] = + cloneableTags[regexpTag] = cloneableTags[setTag] = + cloneableTags[stringTag] = cloneableTags[symbolTag] = + cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = + cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; + cloneableTags[errorTag] = cloneableTags[funcTag] = + cloneableTags[weakMapTag] = false; + + /** Used to map Latin Unicode letters to basic Latin letters. */ + var deburredLetters = { + // Latin-1 Supplement block. + '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', + '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', + '\xc7': 'C', '\xe7': 'c', + '\xd0': 'D', '\xf0': 'd', + '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', + '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', + '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', + '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', + '\xd1': 'N', '\xf1': 'n', + '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', + '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', + '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', + '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', + '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', + '\xc6': 'Ae', '\xe6': 'ae', + '\xde': 'Th', '\xfe': 'th', + '\xdf': 'ss', + // Latin Extended-A block. + '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', + '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', + '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', + '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', + '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', + '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', + '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', + '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', + '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', + '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', + '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', + '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', + '\u0134': 'J', '\u0135': 'j', + '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', + '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', + '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', + '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', + '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', + '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', + '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', + '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', + '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', + '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', + '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', + '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', + '\u0163': 't', '\u0165': 't', '\u0167': 't', + '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', + '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', + '\u0174': 'W', '\u0175': 'w', + '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', + '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', + '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', + '\u0132': 'IJ', '\u0133': 'ij', + '\u0152': 'Oe', '\u0153': 'oe', + '\u0149': "'n", '\u017f': 's' + }; + + /** Used to map characters to HTML entities. */ + var htmlEscapes = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' + }; + + /** Used to map HTML entities to characters. */ + var htmlUnescapes = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + ''': "'" + }; + + /** Used to escape characters for inclusion in compiled string literals. */ + var stringEscapes = { + '\\': '\\', + "'": "'", + '\n': 'n', + '\r': 'r', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; + + /** Built-in method references without a dependency on `root`. */ + var freeParseFloat = parseFloat, + freeParseInt = parseInt; + + /** Detect free variable `global` from Node.js. */ + var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; + + /** Detect free variable `self`. */ + var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + + /** Used as a reference to the global object. */ + var root = freeGlobal || freeSelf || Function('return this')(); + + /** Detect free variable `exports`. */ + var freeExports = true && exports && !exports.nodeType && exports; + + /** Detect free variable `module`. */ + var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; + + /** Detect the popular CommonJS extension `module.exports`. */ + var moduleExports = freeModule && freeModule.exports === freeExports; + + /** Detect free variable `process` from Node.js. */ + var freeProcess = moduleExports && freeGlobal.process; + + /** Used to access faster Node.js helpers. */ + var nodeUtil = (function() { + try { + // Use `util.types` for Node.js 10+. + var types = freeModule && freeModule.require && freeModule.require('util').types; + + if (types) { + return types; + } + + // Legacy `process.binding('util')` for Node.js < 10. + return freeProcess && freeProcess.binding && freeProcess.binding('util'); + } catch (e) {} + }()); + + /* Node.js helper references. */ + var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, + nodeIsDate = nodeUtil && nodeUtil.isDate, + nodeIsMap = nodeUtil && nodeUtil.isMap, + nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, + nodeIsSet = nodeUtil && nodeUtil.isSet, + nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; + + /*--------------------------------------------------------------------------*/ + + /** + * A faster alternative to `Function#apply`, this function invokes `func` + * with the `this` binding of `thisArg` and the arguments of `args`. + * + * @private + * @param {Function} func The function to invoke. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} args The arguments to invoke `func` with. + * @returns {*} Returns the result of `func`. + */ + function apply(func, thisArg, args) { + switch (args.length) { + case 0: return func.call(thisArg); + case 1: return func.call(thisArg, args[0]); + case 2: return func.call(thisArg, args[0], args[1]); + case 3: return func.call(thisArg, args[0], args[1], args[2]); + } + return func.apply(thisArg, args); + } + + /** + * A specialized version of `baseAggregator` for arrays. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform keys. + * @param {Object} accumulator The initial aggregated object. + * @returns {Function} Returns `accumulator`. + */ + function arrayAggregator(array, setter, iteratee, accumulator) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + var value = array[index]; + setter(accumulator, value, iteratee(value), array); + } + return accumulator; + } + + /** + * A specialized version of `_.forEach` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ + function arrayEach(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } + } + return array; + } + + /** + * A specialized version of `_.forEachRight` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ + function arrayEachRight(array, iteratee) { + var length = array == null ? 0 : array.length; + + while (length--) { + if (iteratee(array[length], length, array) === false) { + break; + } + } + return array; + } + + /** + * A specialized version of `_.every` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. + */ + function arrayEvery(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (!predicate(array[index], index, array)) { + return false; + } + } + return true; + } + + /** + * A specialized version of `_.filter` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ + function arrayFilter(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[resIndex++] = value; + } + } + return result; + } + + /** + * A specialized version of `_.includes` for arrays without support for + * specifying an index to search from. + * + * @private + * @param {Array} [array] The array to inspect. + * @param {*} target The value to search for. + * @returns {boolean} Returns `true` if `target` is found, else `false`. + */ + function arrayIncludes(array, value) { + var length = array == null ? 0 : array.length; + return !!length && baseIndexOf(array, value, 0) > -1; + } + + /** + * This function is like `arrayIncludes` except that it accepts a comparator. + * + * @private + * @param {Array} [array] The array to inspect. + * @param {*} target The value to search for. + * @param {Function} comparator The comparator invoked per element. + * @returns {boolean} Returns `true` if `target` is found, else `false`. + */ + function arrayIncludesWith(array, value, comparator) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (comparator(value, array[index])) { + return true; + } + } + return false; + } + + /** + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ + function arrayMap(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; + } + + /** + * Appends the elements of `values` to `array`. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to append. + * @returns {Array} Returns `array`. + */ + function arrayPush(array, values) { + var index = -1, + length = values.length, + offset = array.length; + + while (++index < length) { + array[offset + index] = values[index]; + } + return array; + } + + /** + * A specialized version of `_.reduce` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initAccum] Specify using the first element of `array` as + * the initial value. + * @returns {*} Returns the accumulated value. + */ + function arrayReduce(array, iteratee, accumulator, initAccum) { + var index = -1, + length = array == null ? 0 : array.length; + + if (initAccum && length) { + accumulator = array[++index]; + } + while (++index < length) { + accumulator = iteratee(accumulator, array[index], index, array); + } + return accumulator; + } + + /** + * A specialized version of `_.reduceRight` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initAccum] Specify using the last element of `array` as + * the initial value. + * @returns {*} Returns the accumulated value. + */ + function arrayReduceRight(array, iteratee, accumulator, initAccum) { + var length = array == null ? 0 : array.length; + if (initAccum && length) { + accumulator = array[--length]; + } + while (length--) { + accumulator = iteratee(accumulator, array[length], length, array); + } + return accumulator; + } + + /** + * A specialized version of `_.some` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ + function arraySome(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; + } + + /** + * Gets the size of an ASCII `string`. + * + * @private + * @param {string} string The string inspect. + * @returns {number} Returns the string size. + */ + var asciiSize = baseProperty('length'); + + /** + * Converts an ASCII `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ + function asciiToArray(string) { + return string.split(''); + } + + /** + * Splits an ASCII `string` into an array of its words. + * + * @private + * @param {string} The string to inspect. + * @returns {Array} Returns the words of `string`. + */ + function asciiWords(string) { + return string.match(reAsciiWord) || []; + } + + /** + * The base implementation of methods like `_.findKey` and `_.findLastKey`, + * without support for iteratee shorthands, which iterates over `collection` + * using `eachFunc`. + * + * @private + * @param {Array|Object} collection The collection to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {Function} eachFunc The function to iterate over `collection`. + * @returns {*} Returns the found element or its key, else `undefined`. + */ + function baseFindKey(collection, predicate, eachFunc) { + var result; + eachFunc(collection, function(value, key, collection) { + if (predicate(value, key, collection)) { + result = key; + return false; + } + }); + return result; + } + + /** + * The base implementation of `_.findIndex` and `_.findLastIndex` without + * support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {number} fromIndex The index to search from. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function baseFindIndex(array, predicate, fromIndex, fromRight) { + var length = array.length, + index = fromIndex + (fromRight ? 1 : -1); + + while ((fromRight ? index-- : ++index < length)) { + if (predicate(array[index], index, array)) { + return index; + } + } + return -1; + } + + /** + * The base implementation of `_.indexOf` without `fromIndex` bounds checks. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function baseIndexOf(array, value, fromIndex) { + return value === value + ? strictIndexOf(array, value, fromIndex) + : baseFindIndex(array, baseIsNaN, fromIndex); + } + + /** + * This function is like `baseIndexOf` except that it accepts a comparator. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @param {Function} comparator The comparator invoked per element. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function baseIndexOfWith(array, value, fromIndex, comparator) { + var index = fromIndex - 1, + length = array.length; + + while (++index < length) { + if (comparator(array[index], value)) { + return index; + } + } + return -1; + } + + /** + * The base implementation of `_.isNaN` without support for number objects. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. + */ + function baseIsNaN(value) { + return value !== value; + } + + /** + * The base implementation of `_.mean` and `_.meanBy` without support for + * iteratee shorthands. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {number} Returns the mean. + */ + function baseMean(array, iteratee) { + var length = array == null ? 0 : array.length; + return length ? (baseSum(array, iteratee) / length) : NAN; + } + + /** + * The base implementation of `_.property` without support for deep paths. + * + * @private + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new accessor function. + */ + function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; + } + + /** + * The base implementation of `_.propertyOf` without support for deep paths. + * + * @private + * @param {Object} object The object to query. + * @returns {Function} Returns the new accessor function. + */ + function basePropertyOf(object) { + return function(key) { + return object == null ? undefined : object[key]; + }; + } + + /** + * The base implementation of `_.reduce` and `_.reduceRight`, without support + * for iteratee shorthands, which iterates over `collection` using `eachFunc`. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} accumulator The initial value. + * @param {boolean} initAccum Specify using the first or last element of + * `collection` as the initial value. + * @param {Function} eachFunc The function to iterate over `collection`. + * @returns {*} Returns the accumulated value. + */ + function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { + eachFunc(collection, function(value, index, collection) { + accumulator = initAccum + ? (initAccum = false, value) + : iteratee(accumulator, value, index, collection); + }); + return accumulator; + } + + /** + * The base implementation of `_.sortBy` which uses `comparer` to define the + * sort order of `array` and replaces criteria objects with their corresponding + * values. + * + * @private + * @param {Array} array The array to sort. + * @param {Function} comparer The function to define sort order. + * @returns {Array} Returns `array`. + */ + function baseSortBy(array, comparer) { + var length = array.length; + + array.sort(comparer); + while (length--) { + array[length] = array[length].value; + } + return array; + } + + /** + * The base implementation of `_.sum` and `_.sumBy` without support for + * iteratee shorthands. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {number} Returns the sum. + */ + function baseSum(array, iteratee) { + var result, + index = -1, + length = array.length; + + while (++index < length) { + var current = iteratee(array[index]); + if (current !== undefined) { + result = result === undefined ? current : (result + current); + } + } + return result; + } + + /** + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. + * + * @private + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the array of results. + */ + function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); + + while (++index < n) { + result[index] = iteratee(index); + } + return result; + } + + /** + * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array + * of key-value pairs for `object` corresponding to the property names of `props`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the key-value pairs. + */ + function baseToPairs(object, props) { + return arrayMap(props, function(key) { + return [key, object[key]]; + }); + } + + /** + * The base implementation of `_.unary` without support for storing metadata. + * + * @private + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. + */ + function baseUnary(func) { + return function(value) { + return func(value); + }; + } + + /** + * The base implementation of `_.values` and `_.valuesIn` which creates an + * array of `object` property values corresponding to the property names + * of `props`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the array of property values. + */ + function baseValues(object, props) { + return arrayMap(props, function(key) { + return object[key]; + }); + } + + /** + * Checks if a `cache` value for `key` exists. + * + * @private + * @param {Object} cache The cache to query. + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function cacheHas(cache, key) { + return cache.has(key); + } + + /** + * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol + * that is not found in the character symbols. + * + * @private + * @param {Array} strSymbols The string symbols to inspect. + * @param {Array} chrSymbols The character symbols to find. + * @returns {number} Returns the index of the first unmatched string symbol. + */ + function charsStartIndex(strSymbols, chrSymbols) { + var index = -1, + length = strSymbols.length; + + while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} + return index; + } + + /** + * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol + * that is not found in the character symbols. + * + * @private + * @param {Array} strSymbols The string symbols to inspect. + * @param {Array} chrSymbols The character symbols to find. + * @returns {number} Returns the index of the last unmatched string symbol. + */ + function charsEndIndex(strSymbols, chrSymbols) { + var index = strSymbols.length; + + while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} + return index; + } + + /** + * Gets the number of `placeholder` occurrences in `array`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} placeholder The placeholder to search for. + * @returns {number} Returns the placeholder count. + */ + function countHolders(array, placeholder) { + var length = array.length, + result = 0; + + while (length--) { + if (array[length] === placeholder) { + ++result; + } + } + return result; + } + + /** + * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A + * letters to basic Latin letters. + * + * @private + * @param {string} letter The matched letter to deburr. + * @returns {string} Returns the deburred letter. + */ + var deburrLetter = basePropertyOf(deburredLetters); + + /** + * Used by `_.escape` to convert characters to HTML entities. + * + * @private + * @param {string} chr The matched character to escape. + * @returns {string} Returns the escaped character. + */ + var escapeHtmlChar = basePropertyOf(htmlEscapes); + + /** + * Used by `_.template` to escape characters for inclusion in compiled string literals. + * + * @private + * @param {string} chr The matched character to escape. + * @returns {string} Returns the escaped character. + */ + function escapeStringChar(chr) { + return '\\' + stringEscapes[chr]; + } + + /** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ + function getValue(object, key) { + return object == null ? undefined : object[key]; + } + + /** + * Checks if `string` contains Unicode symbols. + * + * @private + * @param {string} string The string to inspect. + * @returns {boolean} Returns `true` if a symbol is found, else `false`. + */ + function hasUnicode(string) { + return reHasUnicode.test(string); + } + + /** + * Checks if `string` contains a word composed of Unicode symbols. + * + * @private + * @param {string} string The string to inspect. + * @returns {boolean} Returns `true` if a word is found, else `false`. + */ + function hasUnicodeWord(string) { + return reHasUnicodeWord.test(string); + } + + /** + * Converts `iterator` to an array. + * + * @private + * @param {Object} iterator The iterator to convert. + * @returns {Array} Returns the converted array. + */ + function iteratorToArray(iterator) { + var data, + result = []; + + while (!(data = iterator.next()).done) { + result.push(data.value); + } + return result; + } + + /** + * Converts `map` to its key-value pairs. + * + * @private + * @param {Object} map The map to convert. + * @returns {Array} Returns the key-value pairs. + */ + function mapToArray(map) { + var index = -1, + result = Array(map.size); + + map.forEach(function(value, key) { + result[++index] = [key, value]; + }); + return result; + } + + /** + * Creates a unary function that invokes `func` with its argument transformed. + * + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ + function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; + } + + /** + * Replaces all `placeholder` elements in `array` with an internal placeholder + * and returns an array of their indexes. + * + * @private + * @param {Array} array The array to modify. + * @param {*} placeholder The placeholder to replace. + * @returns {Array} Returns the new array of placeholder indexes. + */ + function replaceHolders(array, placeholder) { + var index = -1, + length = array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (value === placeholder || value === PLACEHOLDER) { + array[index] = PLACEHOLDER; + result[resIndex++] = index; + } + } + return result; + } + + /** + * Converts `set` to an array of its values. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the values. + */ + function setToArray(set) { + var index = -1, + result = Array(set.size); + + set.forEach(function(value) { + result[++index] = value; + }); + return result; + } + + /** + * Converts `set` to its value-value pairs. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the value-value pairs. + */ + function setToPairs(set) { + var index = -1, + result = Array(set.size); + + set.forEach(function(value) { + result[++index] = [value, value]; + }); + return result; + } + + /** + * A specialized version of `_.indexOf` which performs strict equality + * comparisons of values, i.e. `===`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function strictIndexOf(array, value, fromIndex) { + var index = fromIndex - 1, + length = array.length; + + while (++index < length) { + if (array[index] === value) { + return index; + } + } + return -1; + } + + /** + * A specialized version of `_.lastIndexOf` which performs strict equality + * comparisons of values, i.e. `===`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function strictLastIndexOf(array, value, fromIndex) { + var index = fromIndex + 1; + while (index--) { + if (array[index] === value) { + return index; + } + } + return index; + } + + /** + * Gets the number of symbols in `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the string size. + */ + function stringSize(string) { + return hasUnicode(string) + ? unicodeSize(string) + : asciiSize(string); + } + + /** + * Converts `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ + function stringToArray(string) { + return hasUnicode(string) + ? unicodeToArray(string) + : asciiToArray(string); + } + + /** + * Used by `_.unescape` to convert HTML entities to characters. + * + * @private + * @param {string} chr The matched character to unescape. + * @returns {string} Returns the unescaped character. + */ + var unescapeHtmlChar = basePropertyOf(htmlUnescapes); + + /** + * Gets the size of a Unicode `string`. + * + * @private + * @param {string} string The string inspect. + * @returns {number} Returns the string size. + */ + function unicodeSize(string) { + var result = reUnicode.lastIndex = 0; + while (reUnicode.test(string)) { + ++result; + } + return result; + } + + /** + * Converts a Unicode `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ + function unicodeToArray(string) { + return string.match(reUnicode) || []; + } + + /** + * Splits a Unicode `string` into an array of its words. + * + * @private + * @param {string} The string to inspect. + * @returns {Array} Returns the words of `string`. + */ + function unicodeWords(string) { + return string.match(reUnicodeWord) || []; + } + + /*--------------------------------------------------------------------------*/ + + /** + * Create a new pristine `lodash` function using the `context` object. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category Util + * @param {Object} [context=root] The context object. + * @returns {Function} Returns a new `lodash` function. + * @example + * + * _.mixin({ 'foo': _.constant('foo') }); + * + * var lodash = _.runInContext(); + * lodash.mixin({ 'bar': lodash.constant('bar') }); + * + * _.isFunction(_.foo); + * // => true + * _.isFunction(_.bar); + * // => false + * + * lodash.isFunction(lodash.foo); + * // => false + * lodash.isFunction(lodash.bar); + * // => true + * + * // Create a suped-up `defer` in Node.js. + * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; + */ + var runInContext = (function runInContext(context) { + context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); + + /** Built-in constructor references. */ + var Array = context.Array, + Date = context.Date, + Error = context.Error, + Function = context.Function, + Math = context.Math, + Object = context.Object, + RegExp = context.RegExp, + String = context.String, + TypeError = context.TypeError; + + /** Used for built-in method references. */ + var arrayProto = Array.prototype, + funcProto = Function.prototype, + objectProto = Object.prototype; + + /** Used to detect overreaching core-js shims. */ + var coreJsData = context['__core-js_shared__']; + + /** Used to resolve the decompiled source of functions. */ + var funcToString = funcProto.toString; + + /** Used to check objects for own properties. */ + var hasOwnProperty = objectProto.hasOwnProperty; + + /** Used to generate unique IDs. */ + var idCounter = 0; + + /** Used to detect methods masquerading as native. */ + var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; + }()); + + /** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ + var nativeObjectToString = objectProto.toString; + + /** Used to infer the `Object` constructor. */ + var objectCtorString = funcToString.call(Object); + + /** Used to restore the original `_` reference in `_.noConflict`. */ + var oldDash = root._; + + /** Used to detect if a method is native. */ + var reIsNative = RegExp('^' + + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' + ); + + /** Built-in value references. */ + var Buffer = moduleExports ? context.Buffer : undefined, + Symbol = context.Symbol, + Uint8Array = context.Uint8Array, + allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, + getPrototype = overArg(Object.getPrototypeOf, Object), + objectCreate = Object.create, + propertyIsEnumerable = objectProto.propertyIsEnumerable, + splice = arrayProto.splice, + spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, + symIterator = Symbol ? Symbol.iterator : undefined, + symToStringTag = Symbol ? Symbol.toStringTag : undefined; + + var defineProperty = (function() { + try { + var func = getNative(Object, 'defineProperty'); + func({}, '', {}); + return func; + } catch (e) {} + }()); + + /** Mocked built-ins. */ + var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, + ctxNow = Date && Date.now !== root.Date.now && Date.now, + ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; + + /* Built-in method references for those with the same name as other `lodash` methods. */ + var nativeCeil = Math.ceil, + nativeFloor = Math.floor, + nativeGetSymbols = Object.getOwnPropertySymbols, + nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, + nativeIsFinite = context.isFinite, + nativeJoin = arrayProto.join, + nativeKeys = overArg(Object.keys, Object), + nativeMax = Math.max, + nativeMin = Math.min, + nativeNow = Date.now, + nativeParseInt = context.parseInt, + nativeRandom = Math.random, + nativeReverse = arrayProto.reverse; + + /* Built-in method references that are verified to be native. */ + var DataView = getNative(context, 'DataView'), + Map = getNative(context, 'Map'), + Promise = getNative(context, 'Promise'), + Set = getNative(context, 'Set'), + WeakMap = getNative(context, 'WeakMap'), + nativeCreate = getNative(Object, 'create'); + + /** Used to store function metadata. */ + var metaMap = WeakMap && new WeakMap; + + /** Used to lookup unminified function names. */ + var realNames = {}; + + /** Used to detect maps, sets, and weakmaps. */ + var dataViewCtorString = toSource(DataView), + mapCtorString = toSource(Map), + promiseCtorString = toSource(Promise), + setCtorString = toSource(Set), + weakMapCtorString = toSource(WeakMap); + + /** Used to convert symbols to primitives and strings. */ + var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, + symbolToString = symbolProto ? symbolProto.toString : undefined; + + /*------------------------------------------------------------------------*/ + + /** + * Creates a `lodash` object which wraps `value` to enable implicit method + * chain sequences. Methods that operate on and return arrays, collections, + * and functions can be chained together. Methods that retrieve a single value + * or may return a primitive value will automatically end the chain sequence + * and return the unwrapped value. Otherwise, the value must be unwrapped + * with `_#value`. + * + * Explicit chain sequences, which must be unwrapped with `_#value`, may be + * enabled using `_.chain`. + * + * The execution of chained methods is lazy, that is, it's deferred until + * `_#value` is implicitly or explicitly called. + * + * Lazy evaluation allows several methods to support shortcut fusion. + * Shortcut fusion is an optimization to merge iteratee calls; this avoids + * the creation of intermediate arrays and can greatly reduce the number of + * iteratee executions. Sections of a chain sequence qualify for shortcut + * fusion if the section is applied to an array and iteratees accept only + * one argument. The heuristic for whether a section qualifies for shortcut + * fusion is subject to change. + * + * Chaining is supported in custom builds as long as the `_#value` method is + * directly or indirectly included in the build. + * + * In addition to lodash methods, wrappers have `Array` and `String` methods. + * + * The wrapper `Array` methods are: + * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` + * + * The wrapper `String` methods are: + * `replace` and `split` + * + * The wrapper methods that support shortcut fusion are: + * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, + * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, + * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` + * + * The chainable wrapper methods are: + * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, + * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, + * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, + * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, + * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, + * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, + * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, + * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, + * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, + * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, + * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, + * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, + * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, + * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, + * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, + * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, + * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, + * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, + * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, + * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, + * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, + * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, + * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, + * `zipObject`, `zipObjectDeep`, and `zipWith` + * + * The wrapper methods that are **not** chainable by default are: + * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, + * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, + * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, + * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, + * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, + * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, + * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, + * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, + * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, + * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, + * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, + * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, + * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, + * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, + * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, + * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, + * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, + * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, + * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, + * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, + * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, + * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, + * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, + * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, + * `upperFirst`, `value`, and `words` + * + * @name _ + * @constructor + * @category Seq + * @param {*} value The value to wrap in a `lodash` instance. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * function square(n) { + * return n * n; + * } + * + * var wrapped = _([1, 2, 3]); + * + * // Returns an unwrapped value. + * wrapped.reduce(_.add); + * // => 6 + * + * // Returns a wrapped value. + * var squares = wrapped.map(square); + * + * _.isArray(squares); + * // => false + * + * _.isArray(squares.value()); + * // => true + */ + function lodash(value) { + if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { + if (value instanceof LodashWrapper) { + return value; + } + if (hasOwnProperty.call(value, '__wrapped__')) { + return wrapperClone(value); + } + } + return new LodashWrapper(value); + } + + /** + * The base implementation of `_.create` without support for assigning + * properties to the created object. + * + * @private + * @param {Object} proto The object to inherit from. + * @returns {Object} Returns the new object. + */ + var baseCreate = (function() { + function object() {} + return function(proto) { + if (!isObject(proto)) { + return {}; + } + if (objectCreate) { + return objectCreate(proto); + } + object.prototype = proto; + var result = new object; + object.prototype = undefined; + return result; + }; + }()); + + /** + * The function whose prototype chain sequence wrappers inherit from. + * + * @private + */ + function baseLodash() { + // No operation performed. + } + + /** + * The base constructor for creating `lodash` wrapper objects. + * + * @private + * @param {*} value The value to wrap. + * @param {boolean} [chainAll] Enable explicit method chain sequences. + */ + function LodashWrapper(value, chainAll) { + this.__wrapped__ = value; + this.__actions__ = []; + this.__chain__ = !!chainAll; + this.__index__ = 0; + this.__values__ = undefined; + } + + /** + * By default, the template delimiters used by lodash are like those in + * embedded Ruby (ERB) as well as ES2015 template strings. Change the + * following template settings to use alternative delimiters. + * + * @static + * @memberOf _ + * @type {Object} + */ + lodash.templateSettings = { + + /** + * Used to detect `data` property values to be HTML-escaped. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + 'escape': reEscape, + + /** + * Used to detect code to be evaluated. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + 'evaluate': reEvaluate, + + /** + * Used to detect `data` property values to inject. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + 'interpolate': reInterpolate, + + /** + * Used to reference the data object in the template text. + * + * @memberOf _.templateSettings + * @type {string} + */ + 'variable': '', + + /** + * Used to import variables into the compiled template. + * + * @memberOf _.templateSettings + * @type {Object} + */ + 'imports': { + + /** + * A reference to the `lodash` function. + * + * @memberOf _.templateSettings.imports + * @type {Function} + */ + '_': lodash + } + }; + + // Ensure wrappers are instances of `baseLodash`. + lodash.prototype = baseLodash.prototype; + lodash.prototype.constructor = lodash; + + LodashWrapper.prototype = baseCreate(baseLodash.prototype); + LodashWrapper.prototype.constructor = LodashWrapper; + + /*------------------------------------------------------------------------*/ + + /** + * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. + * + * @private + * @constructor + * @param {*} value The value to wrap. + */ + function LazyWrapper(value) { + this.__wrapped__ = value; + this.__actions__ = []; + this.__dir__ = 1; + this.__filtered__ = false; + this.__iteratees__ = []; + this.__takeCount__ = MAX_ARRAY_LENGTH; + this.__views__ = []; + } + + /** + * Creates a clone of the lazy wrapper object. + * + * @private + * @name clone + * @memberOf LazyWrapper + * @returns {Object} Returns the cloned `LazyWrapper` object. + */ + function lazyClone() { + var result = new LazyWrapper(this.__wrapped__); + result.__actions__ = copyArray(this.__actions__); + result.__dir__ = this.__dir__; + result.__filtered__ = this.__filtered__; + result.__iteratees__ = copyArray(this.__iteratees__); + result.__takeCount__ = this.__takeCount__; + result.__views__ = copyArray(this.__views__); + return result; + } + + /** + * Reverses the direction of lazy iteration. + * + * @private + * @name reverse + * @memberOf LazyWrapper + * @returns {Object} Returns the new reversed `LazyWrapper` object. + */ + function lazyReverse() { + if (this.__filtered__) { + var result = new LazyWrapper(this); + result.__dir__ = -1; + result.__filtered__ = true; + } else { + result = this.clone(); + result.__dir__ *= -1; + } + return result; + } + + /** + * Extracts the unwrapped value from its lazy wrapper. + * + * @private + * @name value + * @memberOf LazyWrapper + * @returns {*} Returns the unwrapped value. + */ + function lazyValue() { + var array = this.__wrapped__.value(), + dir = this.__dir__, + isArr = isArray(array), + isRight = dir < 0, + arrLength = isArr ? array.length : 0, + view = getView(0, arrLength, this.__views__), + start = view.start, + end = view.end, + length = end - start, + index = isRight ? end : (start - 1), + iteratees = this.__iteratees__, + iterLength = iteratees.length, + resIndex = 0, + takeCount = nativeMin(length, this.__takeCount__); + + if (!isArr || (!isRight && arrLength == length && takeCount == length)) { + return baseWrapperValue(array, this.__actions__); + } + var result = []; + + outer: + while (length-- && resIndex < takeCount) { + index += dir; + + var iterIndex = -1, + value = array[index]; + + while (++iterIndex < iterLength) { + var data = iteratees[iterIndex], + iteratee = data.iteratee, + type = data.type, + computed = iteratee(value); + + if (type == LAZY_MAP_FLAG) { + value = computed; + } else if (!computed) { + if (type == LAZY_FILTER_FLAG) { + continue outer; + } else { + break outer; + } + } + } + result[resIndex++] = value; + } + return result; + } + + // Ensure `LazyWrapper` is an instance of `baseLodash`. + LazyWrapper.prototype = baseCreate(baseLodash.prototype); + LazyWrapper.prototype.constructor = LazyWrapper; + + /*------------------------------------------------------------------------*/ + + /** + * Creates a hash object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function Hash(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + + /** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ + function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; + this.size = 0; + } + + /** + * Removes `key` and its value from the hash. + * + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; + } + + /** + * Gets the hash value for `key`. + * + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED ? undefined : result; + } + return hasOwnProperty.call(data, key) ? data[key] : undefined; + } + + /** + * Checks if a hash value for `key` exists. + * + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function hashHas(key) { + var data = this.__data__; + return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); + } + + /** + * Sets the hash `key` to `value`. + * + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. + */ + function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; + } + + // Add methods to `Hash`. + Hash.prototype.clear = hashClear; + Hash.prototype['delete'] = hashDelete; + Hash.prototype.get = hashGet; + Hash.prototype.has = hashHas; + Hash.prototype.set = hashSet; + + /*------------------------------------------------------------------------*/ + + /** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function ListCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + + /** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ + function listCacheClear() { + this.__data__ = []; + this.size = 0; + } + + /** + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function listCacheDelete(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + --this.size; + return true; + } + + /** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function listCacheGet(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + return index < 0 ? undefined : data[index][1]; + } + + /** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; + } + + /** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ + function listCacheSet(key, value) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; + } + + // Add methods to `ListCache`. + ListCache.prototype.clear = listCacheClear; + ListCache.prototype['delete'] = listCacheDelete; + ListCache.prototype.get = listCacheGet; + ListCache.prototype.has = listCacheHas; + ListCache.prototype.set = listCacheSet; + + /*------------------------------------------------------------------------*/ + + /** + * Creates a map cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function MapCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + + /** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ + function mapCacheClear() { + this.size = 0; + this.__data__ = { + 'hash': new Hash, + 'map': new (Map || ListCache), + 'string': new Hash + }; + } + + /** + * Removes `key` and its value from the map. + * + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function mapCacheDelete(key) { + var result = getMapData(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; + } + + /** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function mapCacheGet(key) { + return getMapData(this, key).get(key); + } + + /** + * Checks if a map value for `key` exists. + * + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function mapCacheHas(key) { + return getMapData(this, key).has(key); + } + + /** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ + function mapCacheSet(key, value) { + var data = getMapData(this, key), + size = data.size; + + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; + } + + // Add methods to `MapCache`. + MapCache.prototype.clear = mapCacheClear; + MapCache.prototype['delete'] = mapCacheDelete; + MapCache.prototype.get = mapCacheGet; + MapCache.prototype.has = mapCacheHas; + MapCache.prototype.set = mapCacheSet; + + /*------------------------------------------------------------------------*/ + + /** + * + * Creates an array cache object to store unique values. + * + * @private + * @constructor + * @param {Array} [values] The values to cache. + */ + function SetCache(values) { + var index = -1, + length = values == null ? 0 : values.length; + + this.__data__ = new MapCache; + while (++index < length) { + this.add(values[index]); + } + } + + /** + * Adds `value` to the array cache. + * + * @private + * @name add + * @memberOf SetCache + * @alias push + * @param {*} value The value to cache. + * @returns {Object} Returns the cache instance. + */ + function setCacheAdd(value) { + this.__data__.set(value, HASH_UNDEFINED); + return this; + } + + /** + * Checks if `value` is in the array cache. + * + * @private + * @name has + * @memberOf SetCache + * @param {*} value The value to search for. + * @returns {number} Returns `true` if `value` is found, else `false`. + */ + function setCacheHas(value) { + return this.__data__.has(value); + } + + // Add methods to `SetCache`. + SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; + SetCache.prototype.has = setCacheHas; + + /*------------------------------------------------------------------------*/ + + /** + * Creates a stack cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function Stack(entries) { + var data = this.__data__ = new ListCache(entries); + this.size = data.size; + } + + /** + * Removes all key-value entries from the stack. + * + * @private + * @name clear + * @memberOf Stack + */ + function stackClear() { + this.__data__ = new ListCache; + this.size = 0; + } + + /** + * Removes `key` and its value from the stack. + * + * @private + * @name delete + * @memberOf Stack + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function stackDelete(key) { + var data = this.__data__, + result = data['delete'](key); + + this.size = data.size; + return result; + } + + /** + * Gets the stack value for `key`. + * + * @private + * @name get + * @memberOf Stack + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function stackGet(key) { + return this.__data__.get(key); + } + + /** + * Checks if a stack value for `key` exists. + * + * @private + * @name has + * @memberOf Stack + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function stackHas(key) { + return this.__data__.has(key); + } + + /** + * Sets the stack `key` to `value`. + * + * @private + * @name set + * @memberOf Stack + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the stack cache instance. + */ + function stackSet(key, value) { + var data = this.__data__; + if (data instanceof ListCache) { + var pairs = data.__data__; + if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { + pairs.push([key, value]); + this.size = ++data.size; + return this; + } + data = this.__data__ = new MapCache(pairs); + } + data.set(key, value); + this.size = data.size; + return this; + } + + // Add methods to `Stack`. + Stack.prototype.clear = stackClear; + Stack.prototype['delete'] = stackDelete; + Stack.prototype.get = stackGet; + Stack.prototype.has = stackHas; + Stack.prototype.set = stackSet; + + /*------------------------------------------------------------------------*/ + + /** + * Creates an array of the enumerable property names of the array-like `value`. + * + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. + */ + function arrayLikeKeys(value, inherited) { + var isArr = isArray(value), + isArg = !isArr && isArguments(value), + isBuff = !isArr && !isArg && isBuffer(value), + isType = !isArr && !isArg && !isBuff && isTypedArray(value), + skipIndexes = isArr || isArg || isBuff || isType, + result = skipIndexes ? baseTimes(value.length, String) : [], + length = result.length; + + for (var key in value) { + if ((inherited || hasOwnProperty.call(value, key)) && + !(skipIndexes && ( + // Safari 9 has enumerable `arguments.length` in strict mode. + key == 'length' || + // Node.js 0.10 has enumerable non-index properties on buffers. + (isBuff && (key == 'offset' || key == 'parent')) || + // PhantomJS 2 has enumerable non-index properties on typed arrays. + (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || + // Skip index properties. + isIndex(key, length) + ))) { + result.push(key); + } + } + return result; + } + + /** + * A specialized version of `_.sample` for arrays. + * + * @private + * @param {Array} array The array to sample. + * @returns {*} Returns the random element. + */ + function arraySample(array) { + var length = array.length; + return length ? array[baseRandom(0, length - 1)] : undefined; + } + + /** + * A specialized version of `_.sampleSize` for arrays. + * + * @private + * @param {Array} array The array to sample. + * @param {number} n The number of elements to sample. + * @returns {Array} Returns the random elements. + */ + function arraySampleSize(array, n) { + return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); + } + + /** + * A specialized version of `_.shuffle` for arrays. + * + * @private + * @param {Array} array The array to shuffle. + * @returns {Array} Returns the new shuffled array. + */ + function arrayShuffle(array) { + return shuffleSelf(copyArray(array)); + } + + /** + * This function is like `assignValue` except that it doesn't assign + * `undefined` values. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ + function assignMergeValue(object, key, value) { + if ((value !== undefined && !eq(object[key], value)) || + (value === undefined && !(key in object))) { + baseAssignValue(object, key, value); + } + } + + /** + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ + function assignValue(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || + (value === undefined && !(key in object))) { + baseAssignValue(object, key, value); + } + } + + /** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } + } + return -1; + } + + /** + * Aggregates elements of `collection` on `accumulator` with keys transformed + * by `iteratee` and values set by `setter`. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform keys. + * @param {Object} accumulator The initial aggregated object. + * @returns {Function} Returns `accumulator`. + */ + function baseAggregator(collection, setter, iteratee, accumulator) { + baseEach(collection, function(value, key, collection) { + setter(accumulator, value, iteratee(value), collection); + }); + return accumulator; + } + + /** + * The base implementation of `_.assign` without support for multiple sources + * or `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ + function baseAssign(object, source) { + return object && copyObject(source, keys(source), object); + } + + /** + * The base implementation of `_.assignIn` without support for multiple sources + * or `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ + function baseAssignIn(object, source) { + return object && copyObject(source, keysIn(source), object); + } + + /** + * The base implementation of `assignValue` and `assignMergeValue` without + * value checks. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ + function baseAssignValue(object, key, value) { + if (key == '__proto__' && defineProperty) { + defineProperty(object, key, { + 'configurable': true, + 'enumerable': true, + 'value': value, + 'writable': true + }); + } else { + object[key] = value; + } + } + + /** + * The base implementation of `_.at` without support for individual paths. + * + * @private + * @param {Object} object The object to iterate over. + * @param {string[]} paths The property paths to pick. + * @returns {Array} Returns the picked elements. + */ + function baseAt(object, paths) { + var index = -1, + length = paths.length, + result = Array(length), + skip = object == null; + + while (++index < length) { + result[index] = skip ? undefined : get(object, paths[index]); + } + return result; + } + + /** + * The base implementation of `_.clamp` which doesn't coerce arguments. + * + * @private + * @param {number} number The number to clamp. + * @param {number} [lower] The lower bound. + * @param {number} upper The upper bound. + * @returns {number} Returns the clamped number. + */ + function baseClamp(number, lower, upper) { + if (number === number) { + if (upper !== undefined) { + number = number <= upper ? number : upper; + } + if (lower !== undefined) { + number = number >= lower ? number : lower; + } + } + return number; + } + + /** + * The base implementation of `_.clone` and `_.cloneDeep` which tracks + * traversed objects. + * + * @private + * @param {*} value The value to clone. + * @param {boolean} bitmask The bitmask flags. + * 1 - Deep clone + * 2 - Flatten inherited properties + * 4 - Clone symbols + * @param {Function} [customizer] The function to customize cloning. + * @param {string} [key] The key of `value`. + * @param {Object} [object] The parent object of `value`. + * @param {Object} [stack] Tracks traversed objects and their clone counterparts. + * @returns {*} Returns the cloned value. + */ + function baseClone(value, bitmask, customizer, key, object, stack) { + var result, + isDeep = bitmask & CLONE_DEEP_FLAG, + isFlat = bitmask & CLONE_FLAT_FLAG, + isFull = bitmask & CLONE_SYMBOLS_FLAG; + + if (customizer) { + result = object ? customizer(value, key, object, stack) : customizer(value); + } + if (result !== undefined) { + return result; + } + if (!isObject(value)) { + return value; + } + var isArr = isArray(value); + if (isArr) { + result = initCloneArray(value); + if (!isDeep) { + return copyArray(value, result); + } + } else { + var tag = getTag(value), + isFunc = tag == funcTag || tag == genTag; + + if (isBuffer(value)) { + return cloneBuffer(value, isDeep); + } + if (tag == objectTag || tag == argsTag || (isFunc && !object)) { + result = (isFlat || isFunc) ? {} : initCloneObject(value); + if (!isDeep) { + return isFlat + ? copySymbolsIn(value, baseAssignIn(result, value)) + : copySymbols(value, baseAssign(result, value)); + } + } else { + if (!cloneableTags[tag]) { + return object ? value : {}; + } + result = initCloneByTag(value, tag, isDeep); + } + } + // Check for circular references and return its corresponding clone. + stack || (stack = new Stack); + var stacked = stack.get(value); + if (stacked) { + return stacked; + } + stack.set(value, result); + + if (isSet(value)) { + value.forEach(function(subValue) { + result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); + }); + } else if (isMap(value)) { + value.forEach(function(subValue, key) { + result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + } + + var keysFunc = isFull + ? (isFlat ? getAllKeysIn : getAllKeys) + : (isFlat ? keysIn : keys); + + var props = isArr ? undefined : keysFunc(value); + arrayEach(props || value, function(subValue, key) { + if (props) { + key = subValue; + subValue = value[key]; + } + // Recursively populate clone (susceptible to call stack limits). + assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + return result; + } + + /** + * The base implementation of `_.conforms` which doesn't clone `source`. + * + * @private + * @param {Object} source The object of property predicates to conform to. + * @returns {Function} Returns the new spec function. + */ + function baseConforms(source) { + var props = keys(source); + return function(object) { + return baseConformsTo(object, source, props); + }; + } + + /** + * The base implementation of `_.conformsTo` which accepts `props` to check. + * + * @private + * @param {Object} object The object to inspect. + * @param {Object} source The object of property predicates to conform to. + * @returns {boolean} Returns `true` if `object` conforms, else `false`. + */ + function baseConformsTo(object, source, props) { + var length = props.length; + if (object == null) { + return !length; + } + object = Object(object); + while (length--) { + var key = props[length], + predicate = source[key], + value = object[key]; + + if ((value === undefined && !(key in object)) || !predicate(value)) { + return false; + } + } + return true; + } + + /** + * The base implementation of `_.delay` and `_.defer` which accepts `args` + * to provide to `func`. + * + * @private + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @param {Array} args The arguments to provide to `func`. + * @returns {number|Object} Returns the timer id or timeout object. + */ + function baseDelay(func, wait, args) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + return setTimeout(function() { func.apply(undefined, args); }, wait); + } + + /** + * The base implementation of methods like `_.difference` without support + * for excluding multiple arrays or iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Array} values The values to exclude. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of filtered values. + */ + function baseDifference(array, values, iteratee, comparator) { + var index = -1, + includes = arrayIncludes, + isCommon = true, + length = array.length, + result = [], + valuesLength = values.length; + + if (!length) { + return result; + } + if (iteratee) { + values = arrayMap(values, baseUnary(iteratee)); + } + if (comparator) { + includes = arrayIncludesWith; + isCommon = false; + } + else if (values.length >= LARGE_ARRAY_SIZE) { + includes = cacheHas; + isCommon = false; + values = new SetCache(values); + } + outer: + while (++index < length) { + var value = array[index], + computed = iteratee == null ? value : iteratee(value); + + value = (comparator || value !== 0) ? value : 0; + if (isCommon && computed === computed) { + var valuesIndex = valuesLength; + while (valuesIndex--) { + if (values[valuesIndex] === computed) { + continue outer; + } + } + result.push(value); + } + else if (!includes(values, computed, comparator)) { + result.push(value); + } + } + return result; + } + + /** + * The base implementation of `_.forEach` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + */ + var baseEach = createBaseEach(baseForOwn); + + /** + * The base implementation of `_.forEachRight` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + */ + var baseEachRight = createBaseEach(baseForOwnRight, true); + + /** + * The base implementation of `_.every` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false` + */ + function baseEvery(collection, predicate) { + var result = true; + baseEach(collection, function(value, index, collection) { + result = !!predicate(value, index, collection); + return result; + }); + return result; + } + + /** + * The base implementation of methods like `_.max` and `_.min` which accepts a + * `comparator` to determine the extremum value. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The iteratee invoked per iteration. + * @param {Function} comparator The comparator used to compare values. + * @returns {*} Returns the extremum value. + */ + function baseExtremum(array, iteratee, comparator) { + var index = -1, + length = array.length; + + while (++index < length) { + var value = array[index], + current = iteratee(value); + + if (current != null && (computed === undefined + ? (current === current && !isSymbol(current)) + : comparator(current, computed) + )) { + var computed = current, + result = value; + } + } + return result; + } + + /** + * The base implementation of `_.fill` without an iteratee call guard. + * + * @private + * @param {Array} array The array to fill. + * @param {*} value The value to fill `array` with. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns `array`. + */ + function baseFill(array, value, start, end) { + var length = array.length; + + start = toInteger(start); + if (start < 0) { + start = -start > length ? 0 : (length + start); + } + end = (end === undefined || end > length) ? length : toInteger(end); + if (end < 0) { + end += length; + } + end = start > end ? 0 : toLength(end); + while (start < end) { + array[start++] = value; + } + return array; + } + + /** + * The base implementation of `_.filter` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ + function baseFilter(collection, predicate) { + var result = []; + baseEach(collection, function(value, index, collection) { + if (predicate(value, index, collection)) { + result.push(value); + } + }); + return result; + } + + /** + * The base implementation of `_.flatten` with support for restricting flattening. + * + * @private + * @param {Array} array The array to flatten. + * @param {number} depth The maximum recursion depth. + * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. + * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. + * @param {Array} [result=[]] The initial result value. + * @returns {Array} Returns the new flattened array. + */ + function baseFlatten(array, depth, predicate, isStrict, result) { + var index = -1, + length = array.length; + + predicate || (predicate = isFlattenable); + result || (result = []); + + while (++index < length) { + var value = array[index]; + if (depth > 0 && predicate(value)) { + if (depth > 1) { + // Recursively flatten arrays (susceptible to call stack limits). + baseFlatten(value, depth - 1, predicate, isStrict, result); + } else { + arrayPush(result, value); + } + } else if (!isStrict) { + result[result.length] = value; + } + } + return result; + } + + /** + * The base implementation of `baseForOwn` which iterates over `object` + * properties returned by `keysFunc` and invokes `iteratee` for each property. + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ + var baseFor = createBaseFor(); + + /** + * This function is like `baseFor` except that it iterates over properties + * in the opposite order. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ + var baseForRight = createBaseFor(true); + + /** + * The base implementation of `_.forOwn` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ + function baseForOwn(object, iteratee) { + return object && baseFor(object, iteratee, keys); + } + + /** + * The base implementation of `_.forOwnRight` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ + function baseForOwnRight(object, iteratee) { + return object && baseForRight(object, iteratee, keys); + } + + /** + * The base implementation of `_.functions` which creates an array of + * `object` function property names filtered from `props`. + * + * @private + * @param {Object} object The object to inspect. + * @param {Array} props The property names to filter. + * @returns {Array} Returns the function names. + */ + function baseFunctions(object, props) { + return arrayFilter(props, function(key) { + return isFunction(object[key]); + }); + } + + /** + * The base implementation of `_.get` without support for default values. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @returns {*} Returns the resolved value. + */ + function baseGet(object, path) { + path = castPath(path, object); + + var index = 0, + length = path.length; + + while (object != null && index < length) { + object = object[toKey(path[index++])]; + } + return (index && index == length) ? object : undefined; + } + + /** + * The base implementation of `getAllKeys` and `getAllKeysIn` which uses + * `keysFunc` and `symbolsFunc` to get the enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Function} symbolsFunc The function to get the symbols of `object`. + * @returns {Array} Returns the array of property names and symbols. + */ + function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); + } + + /** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ + function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); + } + + /** + * The base implementation of `_.gt` which doesn't coerce arguments. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. + */ + function baseGt(value, other) { + return value > other; + } + + /** + * The base implementation of `_.has` without support for deep paths. + * + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. + */ + function baseHas(object, key) { + return object != null && hasOwnProperty.call(object, key); + } + + /** + * The base implementation of `_.hasIn` without support for deep paths. + * + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. + */ + function baseHasIn(object, key) { + return object != null && key in Object(object); + } + + /** + * The base implementation of `_.inRange` which doesn't coerce arguments. + * + * @private + * @param {number} number The number to check. + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @returns {boolean} Returns `true` if `number` is in the range, else `false`. + */ + function baseInRange(number, start, end) { + return number >= nativeMin(start, end) && number < nativeMax(start, end); + } + + /** + * The base implementation of methods like `_.intersection`, without support + * for iteratee shorthands, that accepts an array of arrays to inspect. + * + * @private + * @param {Array} arrays The arrays to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of shared values. + */ + function baseIntersection(arrays, iteratee, comparator) { + var includes = comparator ? arrayIncludesWith : arrayIncludes, + length = arrays[0].length, + othLength = arrays.length, + othIndex = othLength, + caches = Array(othLength), + maxLength = Infinity, + result = []; + + while (othIndex--) { + var array = arrays[othIndex]; + if (othIndex && iteratee) { + array = arrayMap(array, baseUnary(iteratee)); + } + maxLength = nativeMin(array.length, maxLength); + caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) + ? new SetCache(othIndex && array) + : undefined; + } + array = arrays[0]; + + var index = -1, + seen = caches[0]; + + outer: + while (++index < length && result.length < maxLength) { + var value = array[index], + computed = iteratee ? iteratee(value) : value; + + value = (comparator || value !== 0) ? value : 0; + if (!(seen + ? cacheHas(seen, computed) + : includes(result, computed, comparator) + )) { + othIndex = othLength; + while (--othIndex) { + var cache = caches[othIndex]; + if (!(cache + ? cacheHas(cache, computed) + : includes(arrays[othIndex], computed, comparator)) + ) { + continue outer; + } + } + if (seen) { + seen.push(computed); + } + result.push(value); + } + } + return result; + } + + /** + * The base implementation of `_.invert` and `_.invertBy` which inverts + * `object` with values transformed by `iteratee` and set by `setter`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform values. + * @param {Object} accumulator The initial inverted object. + * @returns {Function} Returns `accumulator`. + */ + function baseInverter(object, setter, iteratee, accumulator) { + baseForOwn(object, function(value, key, object) { + setter(accumulator, iteratee(value), key, object); + }); + return accumulator; + } + + /** + * The base implementation of `_.invoke` without support for individual + * method arguments. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the method to invoke. + * @param {Array} args The arguments to invoke the method with. + * @returns {*} Returns the result of the invoked method. + */ + function baseInvoke(object, path, args) { + path = castPath(path, object); + object = parent(object, path); + var func = object == null ? object : object[toKey(last(path))]; + return func == null ? undefined : apply(func, object, args); + } + + /** + * The base implementation of `_.isArguments`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + */ + function baseIsArguments(value) { + return isObjectLike(value) && baseGetTag(value) == argsTag; + } + + /** + * The base implementation of `_.isArrayBuffer` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. + */ + function baseIsArrayBuffer(value) { + return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; + } + + /** + * The base implementation of `_.isDate` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a date object, else `false`. + */ + function baseIsDate(value) { + return isObjectLike(value) && baseGetTag(value) == dateTag; + } + + /** + * The base implementation of `_.isEqual` which supports partial comparisons + * and tracks traversed objects. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {boolean} bitmask The bitmask flags. + * 1 - Unordered comparison + * 2 - Partial comparison + * @param {Function} [customizer] The function to customize comparisons. + * @param {Object} [stack] Tracks traversed `value` and `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ + function baseIsEqual(value, other, bitmask, customizer, stack) { + if (value === other) { + return true; + } + if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); + } + + /** + * A specialized version of `baseIsEqual` for arrays and objects which performs + * deep comparisons and tracks traversed objects enabling objects with circular + * references to be compared. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { + var objIsArr = isArray(object), + othIsArr = isArray(other), + objTag = objIsArr ? arrayTag : getTag(object), + othTag = othIsArr ? arrayTag : getTag(other); + + objTag = objTag == argsTag ? objectTag : objTag; + othTag = othTag == argsTag ? objectTag : othTag; + + var objIsObj = objTag == objectTag, + othIsObj = othTag == objectTag, + isSameTag = objTag == othTag; + + if (isSameTag && isBuffer(object)) { + if (!isBuffer(other)) { + return false; + } + objIsArr = true; + objIsObj = false; + } + if (isSameTag && !objIsObj) { + stack || (stack = new Stack); + return (objIsArr || isTypedArray(object)) + ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) + : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); + } + if (!(bitmask & COMPARE_PARTIAL_FLAG)) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); + + if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, + othUnwrapped = othIsWrapped ? other.value() : other; + + stack || (stack = new Stack); + return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); + } + } + if (!isSameTag) { + return false; + } + stack || (stack = new Stack); + return equalObjects(object, other, bitmask, customizer, equalFunc, stack); + } + + /** + * The base implementation of `_.isMap` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a map, else `false`. + */ + function baseIsMap(value) { + return isObjectLike(value) && getTag(value) == mapTag; + } + + /** + * The base implementation of `_.isMatch` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Array} matchData The property names, values, and compare flags to match. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + */ + function baseIsMatch(object, source, matchData, customizer) { + var index = matchData.length, + length = index, + noCustomizer = !customizer; + + if (object == null) { + return !length; + } + object = Object(object); + while (index--) { + var data = matchData[index]; + if ((noCustomizer && data[2]) + ? data[1] !== object[data[0]] + : !(data[0] in object) + ) { + return false; + } + } + while (++index < length) { + data = matchData[index]; + var key = data[0], + objValue = object[key], + srcValue = data[1]; + + if (noCustomizer && data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } + } else { + var stack = new Stack; + if (customizer) { + var result = customizer(objValue, srcValue, key, object, source, stack); + } + if (!(result === undefined + ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) + : result + )) { + return false; + } + } + } + return true; + } + + /** + * The base implementation of `_.isNative` without bad shim checks. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + */ + function baseIsNative(value) { + if (!isObject(value) || isMasked(value)) { + return false; + } + var pattern = isFunction(value) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); + } + + /** + * The base implementation of `_.isRegExp` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. + */ + function baseIsRegExp(value) { + return isObjectLike(value) && baseGetTag(value) == regexpTag; + } + + /** + * The base implementation of `_.isSet` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a set, else `false`. + */ + function baseIsSet(value) { + return isObjectLike(value) && getTag(value) == setTag; + } + + /** + * The base implementation of `_.isTypedArray` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + */ + function baseIsTypedArray(value) { + return isObjectLike(value) && + isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; + } + + /** + * The base implementation of `_.iteratee`. + * + * @private + * @param {*} [value=_.identity] The value to convert to an iteratee. + * @returns {Function} Returns the iteratee. + */ + function baseIteratee(value) { + // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. + // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. + if (typeof value == 'function') { + return value; + } + if (value == null) { + return identity; + } + if (typeof value == 'object') { + return isArray(value) + ? baseMatchesProperty(value[0], value[1]) + : baseMatches(value); + } + return property(value); + } + + /** + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ + function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; + } + + /** + * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ + function baseKeysIn(object) { + if (!isObject(object)) { + return nativeKeysIn(object); + } + var isProto = isPrototype(object), + result = []; + + for (var key in object) { + if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { + result.push(key); + } + } + return result; + } + + /** + * The base implementation of `_.lt` which doesn't coerce arguments. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than `other`, + * else `false`. + */ + function baseLt(value, other) { + return value < other; + } + + /** + * The base implementation of `_.map` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ + function baseMap(collection, iteratee) { + var index = -1, + result = isArrayLike(collection) ? Array(collection.length) : []; + + baseEach(collection, function(value, key, collection) { + result[++index] = iteratee(value, key, collection); + }); + return result; + } + + /** + * The base implementation of `_.matches` which doesn't clone `source`. + * + * @private + * @param {Object} source The object of property values to match. + * @returns {Function} Returns the new spec function. + */ + function baseMatches(source) { + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + return matchesStrictComparable(matchData[0][0], matchData[0][1]); + } + return function(object) { + return object === source || baseIsMatch(object, source, matchData); + }; + } + + /** + * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. + * + * @private + * @param {string} path The path of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ + function baseMatchesProperty(path, srcValue) { + if (isKey(path) && isStrictComparable(srcValue)) { + return matchesStrictComparable(toKey(path), srcValue); + } + return function(object) { + var objValue = get(object, path); + return (objValue === undefined && objValue === srcValue) + ? hasIn(object, path) + : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); + }; + } + + /** + * The base implementation of `_.merge` without support for multiple sources. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {number} srcIndex The index of `source`. + * @param {Function} [customizer] The function to customize merged values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + */ + function baseMerge(object, source, srcIndex, customizer, stack) { + if (object === source) { + return; + } + baseFor(source, function(srcValue, key) { + stack || (stack = new Stack); + if (isObject(srcValue)) { + baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); + } + else { + var newValue = customizer + ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) + : undefined; + + if (newValue === undefined) { + newValue = srcValue; + } + assignMergeValue(object, key, newValue); + } + }, keysIn); + } + + /** + * A specialized version of `baseMerge` for arrays and objects which performs + * deep merges and tracks traversed objects enabling objects with circular + * references to be merged. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {string} key The key of the value to merge. + * @param {number} srcIndex The index of `source`. + * @param {Function} mergeFunc The function to merge values. + * @param {Function} [customizer] The function to customize assigned values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + */ + function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { + var objValue = safeGet(object, key), + srcValue = safeGet(source, key), + stacked = stack.get(srcValue); + + if (stacked) { + assignMergeValue(object, key, stacked); + return; + } + var newValue = customizer + ? customizer(objValue, srcValue, (key + ''), object, source, stack) + : undefined; + + var isCommon = newValue === undefined; + + if (isCommon) { + var isArr = isArray(srcValue), + isBuff = !isArr && isBuffer(srcValue), + isTyped = !isArr && !isBuff && isTypedArray(srcValue); + + newValue = srcValue; + if (isArr || isBuff || isTyped) { + if (isArray(objValue)) { + newValue = objValue; + } + else if (isArrayLikeObject(objValue)) { + newValue = copyArray(objValue); + } + else if (isBuff) { + isCommon = false; + newValue = cloneBuffer(srcValue, true); + } + else if (isTyped) { + isCommon = false; + newValue = cloneTypedArray(srcValue, true); + } + else { + newValue = []; + } + } + else if (isPlainObject(srcValue) || isArguments(srcValue)) { + newValue = objValue; + if (isArguments(objValue)) { + newValue = toPlainObject(objValue); + } + else if (!isObject(objValue) || isFunction(objValue)) { + newValue = initCloneObject(srcValue); + } + } + else { + isCommon = false; + } + } + if (isCommon) { + // Recursively merge objects and arrays (susceptible to call stack limits). + stack.set(srcValue, newValue); + mergeFunc(newValue, srcValue, srcIndex, customizer, stack); + stack['delete'](srcValue); + } + assignMergeValue(object, key, newValue); + } + + /** + * The base implementation of `_.nth` which doesn't coerce arguments. + * + * @private + * @param {Array} array The array to query. + * @param {number} n The index of the element to return. + * @returns {*} Returns the nth element of `array`. + */ + function baseNth(array, n) { + var length = array.length; + if (!length) { + return; + } + n += n < 0 ? length : 0; + return isIndex(n, length) ? array[n] : undefined; + } + + /** + * The base implementation of `_.orderBy` without param guards. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. + * @param {string[]} orders The sort orders of `iteratees`. + * @returns {Array} Returns the new sorted array. + */ + function baseOrderBy(collection, iteratees, orders) { + var index = -1; + iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee())); + + var result = baseMap(collection, function(value, key, collection) { + var criteria = arrayMap(iteratees, function(iteratee) { + return iteratee(value); + }); + return { 'criteria': criteria, 'index': ++index, 'value': value }; + }); + + return baseSortBy(result, function(object, other) { + return compareMultiple(object, other, orders); + }); + } + + /** + * The base implementation of `_.pick` without support for individual + * property identifiers. + * + * @private + * @param {Object} object The source object. + * @param {string[]} paths The property paths to pick. + * @returns {Object} Returns the new object. + */ + function basePick(object, paths) { + return basePickBy(object, paths, function(value, path) { + return hasIn(object, path); + }); + } + + /** + * The base implementation of `_.pickBy` without support for iteratee shorthands. + * + * @private + * @param {Object} object The source object. + * @param {string[]} paths The property paths to pick. + * @param {Function} predicate The function invoked per property. + * @returns {Object} Returns the new object. + */ + function basePickBy(object, paths, predicate) { + var index = -1, + length = paths.length, + result = {}; + + while (++index < length) { + var path = paths[index], + value = baseGet(object, path); + + if (predicate(value, path)) { + baseSet(result, castPath(path, object), value); + } + } + return result; + } + + /** + * A specialized version of `baseProperty` which supports deep paths. + * + * @private + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new accessor function. + */ + function basePropertyDeep(path) { + return function(object) { + return baseGet(object, path); + }; + } + + /** + * The base implementation of `_.pullAllBy` without support for iteratee + * shorthands. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to remove. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns `array`. + */ + function basePullAll(array, values, iteratee, comparator) { + var indexOf = comparator ? baseIndexOfWith : baseIndexOf, + index = -1, + length = values.length, + seen = array; + + if (array === values) { + values = copyArray(values); + } + if (iteratee) { + seen = arrayMap(array, baseUnary(iteratee)); + } + while (++index < length) { + var fromIndex = 0, + value = values[index], + computed = iteratee ? iteratee(value) : value; + + while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { + if (seen !== array) { + splice.call(seen, fromIndex, 1); + } + splice.call(array, fromIndex, 1); + } + } + return array; + } + + /** + * The base implementation of `_.pullAt` without support for individual + * indexes or capturing the removed elements. + * + * @private + * @param {Array} array The array to modify. + * @param {number[]} indexes The indexes of elements to remove. + * @returns {Array} Returns `array`. + */ + function basePullAt(array, indexes) { + var length = array ? indexes.length : 0, + lastIndex = length - 1; + + while (length--) { + var index = indexes[length]; + if (length == lastIndex || index !== previous) { + var previous = index; + if (isIndex(index)) { + splice.call(array, index, 1); + } else { + baseUnset(array, index); + } + } + } + return array; + } + + /** + * The base implementation of `_.random` without support for returning + * floating-point numbers. + * + * @private + * @param {number} lower The lower bound. + * @param {number} upper The upper bound. + * @returns {number} Returns the random number. + */ + function baseRandom(lower, upper) { + return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); + } + + /** + * The base implementation of `_.range` and `_.rangeRight` which doesn't + * coerce arguments. + * + * @private + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @param {number} step The value to increment or decrement by. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the range of numbers. + */ + function baseRange(start, end, step, fromRight) { + var index = -1, + length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), + result = Array(length); + + while (length--) { + result[fromRight ? length : ++index] = start; + start += step; + } + return result; + } + + /** + * The base implementation of `_.repeat` which doesn't coerce arguments. + * + * @private + * @param {string} string The string to repeat. + * @param {number} n The number of times to repeat the string. + * @returns {string} Returns the repeated string. + */ + function baseRepeat(string, n) { + var result = ''; + if (!string || n < 1 || n > MAX_SAFE_INTEGER) { + return result; + } + // Leverage the exponentiation by squaring algorithm for a faster repeat. + // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. + do { + if (n % 2) { + result += string; + } + n = nativeFloor(n / 2); + if (n) { + string += string; + } + } while (n); + + return result; + } + + /** + * The base implementation of `_.rest` which doesn't validate or coerce arguments. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. + */ + function baseRest(func, start) { + return setToString(overRest(func, start, identity), func + ''); + } + + /** + * The base implementation of `_.sample`. + * + * @private + * @param {Array|Object} collection The collection to sample. + * @returns {*} Returns the random element. + */ + function baseSample(collection) { + return arraySample(values(collection)); + } + + /** + * The base implementation of `_.sampleSize` without param guards. + * + * @private + * @param {Array|Object} collection The collection to sample. + * @param {number} n The number of elements to sample. + * @returns {Array} Returns the random elements. + */ + function baseSampleSize(collection, n) { + var array = values(collection); + return shuffleSelf(array, baseClamp(n, 0, array.length)); + } + + /** + * The base implementation of `_.set`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. + */ + function baseSet(object, path, value, customizer) { + if (!isObject(object)) { + return object; + } + path = castPath(path, object); + + var index = -1, + length = path.length, + lastIndex = length - 1, + nested = object; + + while (nested != null && ++index < length) { + var key = toKey(path[index]), + newValue = value; + + if (index != lastIndex) { + var objValue = nested[key]; + newValue = customizer ? customizer(objValue, key, nested) : undefined; + if (newValue === undefined) { + newValue = isObject(objValue) + ? objValue + : (isIndex(path[index + 1]) ? [] : {}); + } + } + assignValue(nested, key, newValue); + nested = nested[key]; + } + return object; + } + + /** + * The base implementation of `setData` without support for hot loop shorting. + * + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. + */ + var baseSetData = !metaMap ? identity : function(func, data) { + metaMap.set(func, data); + return func; + }; + + /** + * The base implementation of `setToString` without support for hot loop shorting. + * + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ + var baseSetToString = !defineProperty ? identity : function(func, string) { + return defineProperty(func, 'toString', { + 'configurable': true, + 'enumerable': false, + 'value': constant(string), + 'writable': true + }); + }; + + /** + * The base implementation of `_.shuffle`. + * + * @private + * @param {Array|Object} collection The collection to shuffle. + * @returns {Array} Returns the new shuffled array. + */ + function baseShuffle(collection) { + return shuffleSelf(values(collection)); + } + + /** + * The base implementation of `_.slice` without an iteratee call guard. + * + * @private + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. + */ + function baseSlice(array, start, end) { + var index = -1, + length = array.length; + + if (start < 0) { + start = -start > length ? 0 : (length + start); + } + end = end > length ? length : end; + if (end < 0) { + end += length; + } + length = start > end ? 0 : ((end - start) >>> 0); + start >>>= 0; + + var result = Array(length); + while (++index < length) { + result[index] = array[index + start]; + } + return result; + } + + /** + * The base implementation of `_.some` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ + function baseSome(collection, predicate) { + var result; + + baseEach(collection, function(value, index, collection) { + result = predicate(value, index, collection); + return !result; + }); + return !!result; + } + + /** + * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which + * performs a binary search of `array` to determine the index at which `value` + * should be inserted into `array` in order to maintain its sort order. + * + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {boolean} [retHighest] Specify returning the highest qualified index. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + */ + function baseSortedIndex(array, value, retHighest) { + var low = 0, + high = array == null ? low : array.length; + + if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { + while (low < high) { + var mid = (low + high) >>> 1, + computed = array[mid]; + + if (computed !== null && !isSymbol(computed) && + (retHighest ? (computed <= value) : (computed < value))) { + low = mid + 1; + } else { + high = mid; + } + } + return high; + } + return baseSortedIndexBy(array, value, identity, retHighest); + } + + /** + * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` + * which invokes `iteratee` for `value` and each element of `array` to compute + * their sort ranking. The iteratee is invoked with one argument; (value). + * + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} iteratee The iteratee invoked per element. + * @param {boolean} [retHighest] Specify returning the highest qualified index. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + */ + function baseSortedIndexBy(array, value, iteratee, retHighest) { + value = iteratee(value); + + var low = 0, + high = array == null ? 0 : array.length, + valIsNaN = value !== value, + valIsNull = value === null, + valIsSymbol = isSymbol(value), + valIsUndefined = value === undefined; + + while (low < high) { + var mid = nativeFloor((low + high) / 2), + computed = iteratee(array[mid]), + othIsDefined = computed !== undefined, + othIsNull = computed === null, + othIsReflexive = computed === computed, + othIsSymbol = isSymbol(computed); + + if (valIsNaN) { + var setLow = retHighest || othIsReflexive; + } else if (valIsUndefined) { + setLow = othIsReflexive && (retHighest || othIsDefined); + } else if (valIsNull) { + setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); + } else if (valIsSymbol) { + setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); + } else if (othIsNull || othIsSymbol) { + setLow = false; + } else { + setLow = retHighest ? (computed <= value) : (computed < value); + } + if (setLow) { + low = mid + 1; + } else { + high = mid; + } + } + return nativeMin(high, MAX_ARRAY_INDEX); + } + + /** + * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without + * support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @returns {Array} Returns the new duplicate free array. + */ + function baseSortedUniq(array, iteratee) { + var index = -1, + length = array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index], + computed = iteratee ? iteratee(value) : value; + + if (!index || !eq(computed, seen)) { + var seen = computed; + result[resIndex++] = value === 0 ? 0 : value; + } + } + return result; + } + + /** + * The base implementation of `_.toNumber` which doesn't ensure correct + * conversions of binary, hexadecimal, or octal string values. + * + * @private + * @param {*} value The value to process. + * @returns {number} Returns the number. + */ + function baseToNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol(value)) { + return NAN; + } + return +value; + } + + /** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ + function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isArray(value)) { + // Recursively convert values (susceptible to call stack limits). + return arrayMap(value, baseToString) + ''; + } + if (isSymbol(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; + } + + /** + * The base implementation of `_.uniqBy` without support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new duplicate free array. + */ + function baseUniq(array, iteratee, comparator) { + var index = -1, + includes = arrayIncludes, + length = array.length, + isCommon = true, + result = [], + seen = result; + + if (comparator) { + isCommon = false; + includes = arrayIncludesWith; + } + else if (length >= LARGE_ARRAY_SIZE) { + var set = iteratee ? null : createSet(array); + if (set) { + return setToArray(set); + } + isCommon = false; + includes = cacheHas; + seen = new SetCache; + } + else { + seen = iteratee ? [] : result; + } + outer: + while (++index < length) { + var value = array[index], + computed = iteratee ? iteratee(value) : value; + + value = (comparator || value !== 0) ? value : 0; + if (isCommon && computed === computed) { + var seenIndex = seen.length; + while (seenIndex--) { + if (seen[seenIndex] === computed) { + continue outer; + } + } + if (iteratee) { + seen.push(computed); + } + result.push(value); + } + else if (!includes(seen, computed, comparator)) { + if (seen !== result) { + seen.push(computed); + } + result.push(value); + } + } + return result; + } + + /** + * The base implementation of `_.unset`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The property path to unset. + * @returns {boolean} Returns `true` if the property is deleted, else `false`. + */ + function baseUnset(object, path) { + path = castPath(path, object); + object = parent(object, path); + return object == null || delete object[toKey(last(path))]; + } + + /** + * The base implementation of `_.update`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to update. + * @param {Function} updater The function to produce the updated value. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. + */ + function baseUpdate(object, path, updater, customizer) { + return baseSet(object, path, updater(baseGet(object, path)), customizer); + } + + /** + * The base implementation of methods like `_.dropWhile` and `_.takeWhile` + * without support for iteratee shorthands. + * + * @private + * @param {Array} array The array to query. + * @param {Function} predicate The function invoked per iteration. + * @param {boolean} [isDrop] Specify dropping elements instead of taking them. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the slice of `array`. + */ + function baseWhile(array, predicate, isDrop, fromRight) { + var length = array.length, + index = fromRight ? length : -1; + + while ((fromRight ? index-- : ++index < length) && + predicate(array[index], index, array)) {} + + return isDrop + ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) + : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); + } + + /** + * The base implementation of `wrapperValue` which returns the result of + * performing a sequence of actions on the unwrapped `value`, where each + * successive action is supplied the return value of the previous. + * + * @private + * @param {*} value The unwrapped value. + * @param {Array} actions Actions to perform to resolve the unwrapped value. + * @returns {*} Returns the resolved value. + */ + function baseWrapperValue(value, actions) { + var result = value; + if (result instanceof LazyWrapper) { + result = result.value(); + } + return arrayReduce(actions, function(result, action) { + return action.func.apply(action.thisArg, arrayPush([result], action.args)); + }, result); + } + + /** + * The base implementation of methods like `_.xor`, without support for + * iteratee shorthands, that accepts an array of arrays to inspect. + * + * @private + * @param {Array} arrays The arrays to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of values. + */ + function baseXor(arrays, iteratee, comparator) { + var length = arrays.length; + if (length < 2) { + return length ? baseUniq(arrays[0]) : []; + } + var index = -1, + result = Array(length); + + while (++index < length) { + var array = arrays[index], + othIndex = -1; + + while (++othIndex < length) { + if (othIndex != index) { + result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); + } + } + } + return baseUniq(baseFlatten(result, 1), iteratee, comparator); + } + + /** + * This base implementation of `_.zipObject` which assigns values using `assignFunc`. + * + * @private + * @param {Array} props The property identifiers. + * @param {Array} values The property values. + * @param {Function} assignFunc The function to assign values. + * @returns {Object} Returns the new object. + */ + function baseZipObject(props, values, assignFunc) { + var index = -1, + length = props.length, + valsLength = values.length, + result = {}; + + while (++index < length) { + var value = index < valsLength ? values[index] : undefined; + assignFunc(result, props[index], value); + } + return result; + } + + /** + * Casts `value` to an empty array if it's not an array like object. + * + * @private + * @param {*} value The value to inspect. + * @returns {Array|Object} Returns the cast array-like object. + */ + function castArrayLikeObject(value) { + return isArrayLikeObject(value) ? value : []; + } + + /** + * Casts `value` to `identity` if it's not a function. + * + * @private + * @param {*} value The value to inspect. + * @returns {Function} Returns cast function. + */ + function castFunction(value) { + return typeof value == 'function' ? value : identity; + } + + /** + * Casts `value` to a path array if it's not one. + * + * @private + * @param {*} value The value to inspect. + * @param {Object} [object] The object to query keys on. + * @returns {Array} Returns the cast property path array. + */ + function castPath(value, object) { + if (isArray(value)) { + return value; + } + return isKey(value, object) ? [value] : stringToPath(toString(value)); + } + + /** + * A `baseRest` alias which can be replaced with `identity` by module + * replacement plugins. + * + * @private + * @type {Function} + * @param {Function} func The function to apply a rest parameter to. + * @returns {Function} Returns the new function. + */ + var castRest = baseRest; + + /** + * Casts `array` to a slice if it's needed. + * + * @private + * @param {Array} array The array to inspect. + * @param {number} start The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the cast slice. + */ + function castSlice(array, start, end) { + var length = array.length; + end = end === undefined ? length : end; + return (!start && end >= length) ? array : baseSlice(array, start, end); + } + + /** + * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). + * + * @private + * @param {number|Object} id The timer id or timeout object of the timer to clear. + */ + var clearTimeout = ctxClearTimeout || function(id) { + return root.clearTimeout(id); + }; + + /** + * Creates a clone of `buffer`. + * + * @private + * @param {Buffer} buffer The buffer to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Buffer} Returns the cloned buffer. + */ + function cloneBuffer(buffer, isDeep) { + if (isDeep) { + return buffer.slice(); + } + var length = buffer.length, + result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); + + buffer.copy(result); + return result; + } + + /** + * Creates a clone of `arrayBuffer`. + * + * @private + * @param {ArrayBuffer} arrayBuffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. + */ + function cloneArrayBuffer(arrayBuffer) { + var result = new arrayBuffer.constructor(arrayBuffer.byteLength); + new Uint8Array(result).set(new Uint8Array(arrayBuffer)); + return result; + } + + /** + * Creates a clone of `dataView`. + * + * @private + * @param {Object} dataView The data view to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned data view. + */ + function cloneDataView(dataView, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; + return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); + } + + /** + * Creates a clone of `regexp`. + * + * @private + * @param {Object} regexp The regexp to clone. + * @returns {Object} Returns the cloned regexp. + */ + function cloneRegExp(regexp) { + var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); + result.lastIndex = regexp.lastIndex; + return result; + } + + /** + * Creates a clone of the `symbol` object. + * + * @private + * @param {Object} symbol The symbol object to clone. + * @returns {Object} Returns the cloned symbol object. + */ + function cloneSymbol(symbol) { + return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; + } + + /** + * Creates a clone of `typedArray`. + * + * @private + * @param {Object} typedArray The typed array to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned typed array. + */ + function cloneTypedArray(typedArray, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; + return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); + } + + /** + * Compares values to sort them in ascending order. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {number} Returns the sort order indicator for `value`. + */ + function compareAscending(value, other) { + if (value !== other) { + var valIsDefined = value !== undefined, + valIsNull = value === null, + valIsReflexive = value === value, + valIsSymbol = isSymbol(value); + + var othIsDefined = other !== undefined, + othIsNull = other === null, + othIsReflexive = other === other, + othIsSymbol = isSymbol(other); + + if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || + (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || + (valIsNull && othIsDefined && othIsReflexive) || + (!valIsDefined && othIsReflexive) || + !valIsReflexive) { + return 1; + } + if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || + (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || + (othIsNull && valIsDefined && valIsReflexive) || + (!othIsDefined && valIsReflexive) || + !othIsReflexive) { + return -1; + } + } + return 0; + } + + /** + * Used by `_.orderBy` to compare multiple properties of a value to another + * and stable sort them. + * + * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, + * specify an order of "desc" for descending or "asc" for ascending sort order + * of corresponding values. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {boolean[]|string[]} orders The order to sort by for each property. + * @returns {number} Returns the sort order indicator for `object`. + */ + function compareMultiple(object, other, orders) { + var index = -1, + objCriteria = object.criteria, + othCriteria = other.criteria, + length = objCriteria.length, + ordersLength = orders.length; + + while (++index < length) { + var result = compareAscending(objCriteria[index], othCriteria[index]); + if (result) { + if (index >= ordersLength) { + return result; + } + var order = orders[index]; + return result * (order == 'desc' ? -1 : 1); + } + } + // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications + // that causes it, under certain circumstances, to provide the same value for + // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 + // for more details. + // + // This also ensures a stable sort in V8 and other engines. + // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. + return object.index - other.index; + } + + /** + * Creates an array that is the composition of partially applied arguments, + * placeholders, and provided arguments into a single array of arguments. + * + * @private + * @param {Array} args The provided arguments. + * @param {Array} partials The arguments to prepend to those provided. + * @param {Array} holders The `partials` placeholder indexes. + * @params {boolean} [isCurried] Specify composing for a curried function. + * @returns {Array} Returns the new array of composed arguments. + */ + function composeArgs(args, partials, holders, isCurried) { + var argsIndex = -1, + argsLength = args.length, + holdersLength = holders.length, + leftIndex = -1, + leftLength = partials.length, + rangeLength = nativeMax(argsLength - holdersLength, 0), + result = Array(leftLength + rangeLength), + isUncurried = !isCurried; + + while (++leftIndex < leftLength) { + result[leftIndex] = partials[leftIndex]; + } + while (++argsIndex < holdersLength) { + if (isUncurried || argsIndex < argsLength) { + result[holders[argsIndex]] = args[argsIndex]; + } + } + while (rangeLength--) { + result[leftIndex++] = args[argsIndex++]; + } + return result; + } + + /** + * This function is like `composeArgs` except that the arguments composition + * is tailored for `_.partialRight`. + * + * @private + * @param {Array} args The provided arguments. + * @param {Array} partials The arguments to append to those provided. + * @param {Array} holders The `partials` placeholder indexes. + * @params {boolean} [isCurried] Specify composing for a curried function. + * @returns {Array} Returns the new array of composed arguments. + */ + function composeArgsRight(args, partials, holders, isCurried) { + var argsIndex = -1, + argsLength = args.length, + holdersIndex = -1, + holdersLength = holders.length, + rightIndex = -1, + rightLength = partials.length, + rangeLength = nativeMax(argsLength - holdersLength, 0), + result = Array(rangeLength + rightLength), + isUncurried = !isCurried; + + while (++argsIndex < rangeLength) { + result[argsIndex] = args[argsIndex]; + } + var offset = argsIndex; + while (++rightIndex < rightLength) { + result[offset + rightIndex] = partials[rightIndex]; + } + while (++holdersIndex < holdersLength) { + if (isUncurried || argsIndex < argsLength) { + result[offset + holders[holdersIndex]] = args[argsIndex++]; + } + } + return result; + } + + /** + * Copies the values of `source` to `array`. + * + * @private + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. + */ + function copyArray(source, array) { + var index = -1, + length = source.length; + + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; + } + + /** + * Copies properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property identifiers to copy. + * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. + * @returns {Object} Returns `object`. + */ + function copyObject(source, props, object, customizer) { + var isNew = !object; + object || (object = {}); + + var index = -1, + length = props.length; + + while (++index < length) { + var key = props[index]; + + var newValue = customizer + ? customizer(object[key], source[key], key, object, source) + : undefined; + + if (newValue === undefined) { + newValue = source[key]; + } + if (isNew) { + baseAssignValue(object, key, newValue); + } else { + assignValue(object, key, newValue); + } + } + return object; + } + + /** + * Copies own symbols of `source` to `object`. + * + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. + */ + function copySymbols(source, object) { + return copyObject(source, getSymbols(source), object); + } + + /** + * Copies own and inherited symbols of `source` to `object`. + * + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. + */ + function copySymbolsIn(source, object) { + return copyObject(source, getSymbolsIn(source), object); + } + + /** + * Creates a function like `_.groupBy`. + * + * @private + * @param {Function} setter The function to set accumulator values. + * @param {Function} [initializer] The accumulator object initializer. + * @returns {Function} Returns the new aggregator function. + */ + function createAggregator(setter, initializer) { + return function(collection, iteratee) { + var func = isArray(collection) ? arrayAggregator : baseAggregator, + accumulator = initializer ? initializer() : {}; + + return func(collection, setter, getIteratee(iteratee, 2), accumulator); + }; + } + + /** + * Creates a function like `_.assign`. + * + * @private + * @param {Function} assigner The function to assign values. + * @returns {Function} Returns the new assigner function. + */ + function createAssigner(assigner) { + return baseRest(function(object, sources) { + var index = -1, + length = sources.length, + customizer = length > 1 ? sources[length - 1] : undefined, + guard = length > 2 ? sources[2] : undefined; + + customizer = (assigner.length > 3 && typeof customizer == 'function') + ? (length--, customizer) + : undefined; + + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + customizer = length < 3 ? undefined : customizer; + length = 1; + } + object = Object(object); + while (++index < length) { + var source = sources[index]; + if (source) { + assigner(object, source, index, customizer); + } + } + return object; + }); + } + + /** + * Creates a `baseEach` or `baseEachRight` function. + * + * @private + * @param {Function} eachFunc The function to iterate over a collection. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ + function createBaseEach(eachFunc, fromRight) { + return function(collection, iteratee) { + if (collection == null) { + return collection; + } + if (!isArrayLike(collection)) { + return eachFunc(collection, iteratee); + } + var length = collection.length, + index = fromRight ? length : -1, + iterable = Object(collection); + + while ((fromRight ? index-- : ++index < length)) { + if (iteratee(iterable[index], index, iterable) === false) { + break; + } + } + return collection; + }; + } + + /** + * Creates a base function for methods like `_.forIn` and `_.forOwn`. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ + function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var index = -1, + iterable = Object(object), + props = keysFunc(object), + length = props.length; + + while (length--) { + var key = props[fromRight ? length : ++index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } + } + return object; + }; + } + + /** + * Creates a function that wraps `func` to invoke it with the optional `this` + * binding of `thisArg`. + * + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {*} [thisArg] The `this` binding of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createBind(func, bitmask, thisArg) { + var isBind = bitmask & WRAP_BIND_FLAG, + Ctor = createCtor(func); + + function wrapper() { + var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + return fn.apply(isBind ? thisArg : this, arguments); + } + return wrapper; + } + + /** + * Creates a function like `_.lowerFirst`. + * + * @private + * @param {string} methodName The name of the `String` case method to use. + * @returns {Function} Returns the new case function. + */ + function createCaseFirst(methodName) { + return function(string) { + string = toString(string); + + var strSymbols = hasUnicode(string) + ? stringToArray(string) + : undefined; + + var chr = strSymbols + ? strSymbols[0] + : string.charAt(0); + + var trailing = strSymbols + ? castSlice(strSymbols, 1).join('') + : string.slice(1); + + return chr[methodName]() + trailing; + }; + } + + /** + * Creates a function like `_.camelCase`. + * + * @private + * @param {Function} callback The function to combine each word. + * @returns {Function} Returns the new compounder function. + */ + function createCompounder(callback) { + return function(string) { + return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); + }; + } + + /** + * Creates a function that produces an instance of `Ctor` regardless of + * whether it was invoked as part of a `new` expression or by `call` or `apply`. + * + * @private + * @param {Function} Ctor The constructor to wrap. + * @returns {Function} Returns the new wrapped function. + */ + function createCtor(Ctor) { + return function() { + // Use a `switch` statement to work with class constructors. See + // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist + // for more details. + var args = arguments; + switch (args.length) { + case 0: return new Ctor; + case 1: return new Ctor(args[0]); + case 2: return new Ctor(args[0], args[1]); + case 3: return new Ctor(args[0], args[1], args[2]); + case 4: return new Ctor(args[0], args[1], args[2], args[3]); + case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); + case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); + case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + } + var thisBinding = baseCreate(Ctor.prototype), + result = Ctor.apply(thisBinding, args); + + // Mimic the constructor's `return` behavior. + // See https://es5.github.io/#x13.2.2 for more details. + return isObject(result) ? result : thisBinding; + }; + } + + /** + * Creates a function that wraps `func` to enable currying. + * + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {number} arity The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createCurry(func, bitmask, arity) { + var Ctor = createCtor(func); + + function wrapper() { + var length = arguments.length, + args = Array(length), + index = length, + placeholder = getHolder(wrapper); + + while (index--) { + args[index] = arguments[index]; + } + var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) + ? [] + : replaceHolders(args, placeholder); + + length -= holders.length; + if (length < arity) { + return createRecurry( + func, bitmask, createHybrid, wrapper.placeholder, undefined, + args, holders, undefined, undefined, arity - length); + } + var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + return apply(fn, this, args); + } + return wrapper; + } + + /** + * Creates a `_.find` or `_.findLast` function. + * + * @private + * @param {Function} findIndexFunc The function to find the collection index. + * @returns {Function} Returns the new find function. + */ + function createFind(findIndexFunc) { + return function(collection, predicate, fromIndex) { + var iterable = Object(collection); + if (!isArrayLike(collection)) { + var iteratee = getIteratee(predicate, 3); + collection = keys(collection); + predicate = function(key) { return iteratee(iterable[key], key, iterable); }; + } + var index = findIndexFunc(collection, predicate, fromIndex); + return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; + }; + } + + /** + * Creates a `_.flow` or `_.flowRight` function. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new flow function. + */ + function createFlow(fromRight) { + return flatRest(function(funcs) { + var length = funcs.length, + index = length, + prereq = LodashWrapper.prototype.thru; + + if (fromRight) { + funcs.reverse(); + } + while (index--) { + var func = funcs[index]; + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + if (prereq && !wrapper && getFuncName(func) == 'wrapper') { + var wrapper = new LodashWrapper([], true); + } + } + index = wrapper ? index : length; + while (++index < length) { + func = funcs[index]; + + var funcName = getFuncName(func), + data = funcName == 'wrapper' ? getData(func) : undefined; + + if (data && isLaziable(data[0]) && + data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && + !data[4].length && data[9] == 1 + ) { + wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); + } else { + wrapper = (func.length == 1 && isLaziable(func)) + ? wrapper[funcName]() + : wrapper.thru(func); + } + } + return function() { + var args = arguments, + value = args[0]; + + if (wrapper && args.length == 1 && isArray(value)) { + return wrapper.plant(value).value(); + } + var index = 0, + result = length ? funcs[index].apply(this, args) : value; + + while (++index < length) { + result = funcs[index].call(this, result); + } + return result; + }; + }); + } + + /** + * Creates a function that wraps `func` to invoke it with optional `this` + * binding of `thisArg`, partial application, and currying. + * + * @private + * @param {Function|string} func The function or method name to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to prepend to those provided to + * the new function. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [partialsRight] The arguments to append to those provided + * to the new function. + * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { + var isAry = bitmask & WRAP_ARY_FLAG, + isBind = bitmask & WRAP_BIND_FLAG, + isBindKey = bitmask & WRAP_BIND_KEY_FLAG, + isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), + isFlip = bitmask & WRAP_FLIP_FLAG, + Ctor = isBindKey ? undefined : createCtor(func); + + function wrapper() { + var length = arguments.length, + args = Array(length), + index = length; + + while (index--) { + args[index] = arguments[index]; + } + if (isCurried) { + var placeholder = getHolder(wrapper), + holdersCount = countHolders(args, placeholder); + } + if (partials) { + args = composeArgs(args, partials, holders, isCurried); + } + if (partialsRight) { + args = composeArgsRight(args, partialsRight, holdersRight, isCurried); + } + length -= holdersCount; + if (isCurried && length < arity) { + var newHolders = replaceHolders(args, placeholder); + return createRecurry( + func, bitmask, createHybrid, wrapper.placeholder, thisArg, + args, newHolders, argPos, ary, arity - length + ); + } + var thisBinding = isBind ? thisArg : this, + fn = isBindKey ? thisBinding[func] : func; + + length = args.length; + if (argPos) { + args = reorder(args, argPos); + } else if (isFlip && length > 1) { + args.reverse(); + } + if (isAry && ary < length) { + args.length = ary; + } + if (this && this !== root && this instanceof wrapper) { + fn = Ctor || createCtor(fn); + } + return fn.apply(thisBinding, args); + } + return wrapper; + } + + /** + * Creates a function like `_.invertBy`. + * + * @private + * @param {Function} setter The function to set accumulator values. + * @param {Function} toIteratee The function to resolve iteratees. + * @returns {Function} Returns the new inverter function. + */ + function createInverter(setter, toIteratee) { + return function(object, iteratee) { + return baseInverter(object, setter, toIteratee(iteratee), {}); + }; + } + + /** + * Creates a function that performs a mathematical operation on two values. + * + * @private + * @param {Function} operator The function to perform the operation. + * @param {number} [defaultValue] The value used for `undefined` arguments. + * @returns {Function} Returns the new mathematical operation function. + */ + function createMathOperation(operator, defaultValue) { + return function(value, other) { + var result; + if (value === undefined && other === undefined) { + return defaultValue; + } + if (value !== undefined) { + result = value; + } + if (other !== undefined) { + if (result === undefined) { + return other; + } + if (typeof value == 'string' || typeof other == 'string') { + value = baseToString(value); + other = baseToString(other); + } else { + value = baseToNumber(value); + other = baseToNumber(other); + } + result = operator(value, other); + } + return result; + }; + } + + /** + * Creates a function like `_.over`. + * + * @private + * @param {Function} arrayFunc The function to iterate over iteratees. + * @returns {Function} Returns the new over function. + */ + function createOver(arrayFunc) { + return flatRest(function(iteratees) { + iteratees = arrayMap(iteratees, baseUnary(getIteratee())); + return baseRest(function(args) { + var thisArg = this; + return arrayFunc(iteratees, function(iteratee) { + return apply(iteratee, thisArg, args); + }); + }); + }); + } + + /** + * Creates the padding for `string` based on `length`. The `chars` string + * is truncated if the number of characters exceeds `length`. + * + * @private + * @param {number} length The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padding for `string`. + */ + function createPadding(length, chars) { + chars = chars === undefined ? ' ' : baseToString(chars); + + var charsLength = chars.length; + if (charsLength < 2) { + return charsLength ? baseRepeat(chars, length) : chars; + } + var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); + return hasUnicode(chars) + ? castSlice(stringToArray(result), 0, length).join('') + : result.slice(0, length); + } + + /** + * Creates a function that wraps `func` to invoke it with the `this` binding + * of `thisArg` and `partials` prepended to the arguments it receives. + * + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} partials The arguments to prepend to those provided to + * the new function. + * @returns {Function} Returns the new wrapped function. + */ + function createPartial(func, bitmask, thisArg, partials) { + var isBind = bitmask & WRAP_BIND_FLAG, + Ctor = createCtor(func); + + function wrapper() { + var argsIndex = -1, + argsLength = arguments.length, + leftIndex = -1, + leftLength = partials.length, + args = Array(leftLength + argsLength), + fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + + while (++leftIndex < leftLength) { + args[leftIndex] = partials[leftIndex]; + } + while (argsLength--) { + args[leftIndex++] = arguments[++argsIndex]; + } + return apply(fn, isBind ? thisArg : this, args); + } + return wrapper; + } + + /** + * Creates a `_.range` or `_.rangeRight` function. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new range function. + */ + function createRange(fromRight) { + return function(start, end, step) { + if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { + end = step = undefined; + } + // Ensure the sign of `-0` is preserved. + start = toFinite(start); + if (end === undefined) { + end = start; + start = 0; + } else { + end = toFinite(end); + } + step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); + return baseRange(start, end, step, fromRight); + }; + } + + /** + * Creates a function that performs a relational operation on two values. + * + * @private + * @param {Function} operator The function to perform the operation. + * @returns {Function} Returns the new relational operation function. + */ + function createRelationalOperation(operator) { + return function(value, other) { + if (!(typeof value == 'string' && typeof other == 'string')) { + value = toNumber(value); + other = toNumber(other); + } + return operator(value, other); + }; + } + + /** + * Creates a function that wraps `func` to continue currying. + * + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {Function} wrapFunc The function to create the `func` wrapper. + * @param {*} placeholder The placeholder value. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to prepend to those provided to + * the new function. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { + var isCurry = bitmask & WRAP_CURRY_FLAG, + newHolders = isCurry ? holders : undefined, + newHoldersRight = isCurry ? undefined : holders, + newPartials = isCurry ? partials : undefined, + newPartialsRight = isCurry ? undefined : partials; + + bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); + bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); + + if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { + bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); + } + var newData = [ + func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, + newHoldersRight, argPos, ary, arity + ]; + + var result = wrapFunc.apply(undefined, newData); + if (isLaziable(func)) { + setData(result, newData); + } + result.placeholder = placeholder; + return setWrapToString(result, func, bitmask); + } + + /** + * Creates a function like `_.round`. + * + * @private + * @param {string} methodName The name of the `Math` method to use when rounding. + * @returns {Function} Returns the new round function. + */ + function createRound(methodName) { + var func = Math[methodName]; + return function(number, precision) { + number = toNumber(number); + precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); + if (precision && nativeIsFinite(number)) { + // Shift with exponential notation to avoid floating-point issues. + // See [MDN](https://mdn.io/round#Examples) for more details. + var pair = (toString(number) + 'e').split('e'), + value = func(pair[0] + 'e' + (+pair[1] + precision)); + + pair = (toString(value) + 'e').split('e'); + return +(pair[0] + 'e' + (+pair[1] - precision)); + } + return func(number); + }; + } + + /** + * Creates a set object of `values`. + * + * @private + * @param {Array} values The values to add to the set. + * @returns {Object} Returns the new set. + */ + var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { + return new Set(values); + }; + + /** + * Creates a `_.toPairs` or `_.toPairsIn` function. + * + * @private + * @param {Function} keysFunc The function to get the keys of a given object. + * @returns {Function} Returns the new pairs function. + */ + function createToPairs(keysFunc) { + return function(object) { + var tag = getTag(object); + if (tag == mapTag) { + return mapToArray(object); + } + if (tag == setTag) { + return setToPairs(object); + } + return baseToPairs(object, keysFunc(object)); + }; + } + + /** + * Creates a function that either curries or invokes `func` with optional + * `this` binding and partially applied arguments. + * + * @private + * @param {Function|string} func The function or method name to wrap. + * @param {number} bitmask The bitmask flags. + * 1 - `_.bind` + * 2 - `_.bindKey` + * 4 - `_.curry` or `_.curryRight` of a bound function + * 8 - `_.curry` + * 16 - `_.curryRight` + * 32 - `_.partial` + * 64 - `_.partialRight` + * 128 - `_.rearg` + * 256 - `_.ary` + * 512 - `_.flip` + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to be partially applied. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { + var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; + if (!isBindKey && typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + var length = partials ? partials.length : 0; + if (!length) { + bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); + partials = holders = undefined; + } + ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); + arity = arity === undefined ? arity : toInteger(arity); + length -= holders ? holders.length : 0; + + if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { + var partialsRight = partials, + holdersRight = holders; + + partials = holders = undefined; + } + var data = isBindKey ? undefined : getData(func); + + var newData = [ + func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, + argPos, ary, arity + ]; + + if (data) { + mergeData(newData, data); + } + func = newData[0]; + bitmask = newData[1]; + thisArg = newData[2]; + partials = newData[3]; + holders = newData[4]; + arity = newData[9] = newData[9] === undefined + ? (isBindKey ? 0 : func.length) + : nativeMax(newData[9] - length, 0); + + if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { + bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); + } + if (!bitmask || bitmask == WRAP_BIND_FLAG) { + var result = createBind(func, bitmask, thisArg); + } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { + result = createCurry(func, bitmask, arity); + } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { + result = createPartial(func, bitmask, thisArg, partials); + } else { + result = createHybrid.apply(undefined, newData); + } + var setter = data ? baseSetData : setData; + return setWrapToString(setter(result, newData), func, bitmask); + } + + /** + * Used by `_.defaults` to customize its `_.assignIn` use to assign properties + * of source objects to the destination object for all destination properties + * that resolve to `undefined`. + * + * @private + * @param {*} objValue The destination value. + * @param {*} srcValue The source value. + * @param {string} key The key of the property to assign. + * @param {Object} object The parent object of `objValue`. + * @returns {*} Returns the value to assign. + */ + function customDefaultsAssignIn(objValue, srcValue, key, object) { + if (objValue === undefined || + (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { + return srcValue; + } + return objValue; + } + + /** + * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source + * objects into destination objects that are passed thru. + * + * @private + * @param {*} objValue The destination value. + * @param {*} srcValue The source value. + * @param {string} key The key of the property to merge. + * @param {Object} object The parent object of `objValue`. + * @param {Object} source The parent object of `srcValue`. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + * @returns {*} Returns the value to assign. + */ + function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { + if (isObject(objValue) && isObject(srcValue)) { + // Recursively merge objects and arrays (susceptible to call stack limits). + stack.set(srcValue, objValue); + baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); + stack['delete'](srcValue); + } + return objValue; + } + + /** + * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain + * objects. + * + * @private + * @param {*} value The value to inspect. + * @param {string} key The key of the property to inspect. + * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. + */ + function customOmitClone(value) { + return isPlainObject(value) ? undefined : value; + } + + /** + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. + * + * @private + * @param {Array} array The array to compare. + * @param {Array} other The other array to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `array` and `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + */ + function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, + arrLength = array.length, + othLength = other.length; + + if (arrLength != othLength && !(isPartial && othLength > arrLength)) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(array); + if (stacked && stack.get(other)) { + return stacked == other; + } + var index = -1, + result = true, + seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; + + stack.set(array, other); + stack.set(other, array); + + // Ignore non-index properties. + while (++index < arrLength) { + var arrValue = array[index], + othValue = other[index]; + + if (customizer) { + var compared = isPartial + ? customizer(othValue, arrValue, index, other, array, stack) + : customizer(arrValue, othValue, index, array, other, stack); + } + if (compared !== undefined) { + if (compared) { + continue; + } + result = false; + break; + } + // Recursively compare arrays (susceptible to call stack limits). + if (seen) { + if (!arraySome(other, function(othValue, othIndex) { + if (!cacheHas(seen, othIndex) && + (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { + return seen.push(othIndex); + } + })) { + result = false; + break; + } + } else if (!( + arrValue === othValue || + equalFunc(arrValue, othValue, bitmask, customizer, stack) + )) { + result = false; + break; + } + } + stack['delete'](array); + stack['delete'](other); + return result; + } + + /** + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. + * + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { + switch (tag) { + case dataViewTag: + if ((object.byteLength != other.byteLength) || + (object.byteOffset != other.byteOffset)) { + return false; + } + object = object.buffer; + other = other.buffer; + + case arrayBufferTag: + if ((object.byteLength != other.byteLength) || + !equalFunc(new Uint8Array(object), new Uint8Array(other))) { + return false; + } + return true; + + case boolTag: + case dateTag: + case numberTag: + // Coerce booleans to `1` or `0` and dates to milliseconds. + // Invalid dates are coerced to `NaN`. + return eq(+object, +other); + + case errorTag: + return object.name == other.name && object.message == other.message; + + case regexpTag: + case stringTag: + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring + // for more details. + return object == (other + ''); + + case mapTag: + var convert = mapToArray; + + case setTag: + var isPartial = bitmask & COMPARE_PARTIAL_FLAG; + convert || (convert = setToArray); + + if (object.size != other.size && !isPartial) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + bitmask |= COMPARE_UNORDERED_FLAG; + + // Recursively compare objects (susceptible to call stack limits). + stack.set(object, other); + var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); + stack['delete'](object); + return result; + + case symbolTag: + if (symbolValueOf) { + return symbolValueOf.call(object) == symbolValueOf.call(other); + } + } + return false; + } + + /** + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, + objProps = getAllKeys(object), + objLength = objProps.length, + othProps = getAllKeys(other), + othLength = othProps.length; + + if (objLength != othLength && !isPartial) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { + return false; + } + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked && stack.get(other)) { + return stacked == other; + } + var result = true; + stack.set(object, other); + stack.set(other, object); + + var skipCtor = isPartial; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], + othValue = other[key]; + + if (customizer) { + var compared = isPartial + ? customizer(othValue, objValue, key, other, object, stack) + : customizer(objValue, othValue, key, object, other, stack); + } + // Recursively compare objects (susceptible to call stack limits). + if (!(compared === undefined + ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) + : compared + )) { + result = false; + break; + } + skipCtor || (skipCtor = key == 'constructor'); + } + if (result && !skipCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; + + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && + ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && + typeof othCtor == 'function' && othCtor instanceof othCtor)) { + result = false; + } + } + stack['delete'](object); + stack['delete'](other); + return result; + } + + /** + * A specialized version of `baseRest` which flattens the rest array. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @returns {Function} Returns the new function. + */ + function flatRest(func) { + return setToString(overRest(func, undefined, flatten), func + ''); + } + + /** + * Creates an array of own enumerable property names and symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ + function getAllKeys(object) { + return baseGetAllKeys(object, keys, getSymbols); + } + + /** + * Creates an array of own and inherited enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ + function getAllKeysIn(object) { + return baseGetAllKeys(object, keysIn, getSymbolsIn); + } + + /** + * Gets metadata for `func`. + * + * @private + * @param {Function} func The function to query. + * @returns {*} Returns the metadata for `func`. + */ + var getData = !metaMap ? noop : function(func) { + return metaMap.get(func); + }; + + /** + * Gets the name of `func`. + * + * @private + * @param {Function} func The function to query. + * @returns {string} Returns the function name. + */ + function getFuncName(func) { + var result = (func.name + ''), + array = realNames[result], + length = hasOwnProperty.call(realNames, result) ? array.length : 0; + + while (length--) { + var data = array[length], + otherFunc = data.func; + if (otherFunc == null || otherFunc == func) { + return data.name; + } + } + return result; + } + + /** + * Gets the argument placeholder value for `func`. + * + * @private + * @param {Function} func The function to inspect. + * @returns {*} Returns the placeholder value. + */ + function getHolder(func) { + var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; + return object.placeholder; + } + + /** + * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, + * this function returns the custom method, otherwise it returns `baseIteratee`. + * If arguments are provided, the chosen function is invoked with them and + * its result is returned. + * + * @private + * @param {*} [value] The value to convert to an iteratee. + * @param {number} [arity] The arity of the created iteratee. + * @returns {Function} Returns the chosen function or its result. + */ + function getIteratee() { + var result = lodash.iteratee || iteratee; + result = result === iteratee ? baseIteratee : result; + return arguments.length ? result(arguments[0], arguments[1]) : result; + } + + /** + * Gets the data for `map`. + * + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ + function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; + } + + /** + * Gets the property names, values, and compare flags of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the match data of `object`. + */ + function getMatchData(object) { + var result = keys(object), + length = result.length; + + while (length--) { + var key = result[length], + value = object[key]; + + result[length] = [key, value, isStrictComparable(value)]; + } + return result; + } + + /** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ + function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : undefined; + } + + /** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ + function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag), + tag = value[symToStringTag]; + + try { + value[symToStringTag] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag] = tag; + } else { + delete value[symToStringTag]; + } + } + return result; + } + + /** + * Creates an array of the own enumerable symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ + var getSymbols = !nativeGetSymbols ? stubArray : function(object) { + if (object == null) { + return []; + } + object = Object(object); + return arrayFilter(nativeGetSymbols(object), function(symbol) { + return propertyIsEnumerable.call(object, symbol); + }); + }; + + /** + * Creates an array of the own and inherited enumerable symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ + var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { + var result = []; + while (object) { + arrayPush(result, getSymbols(object)); + object = getPrototype(object); + } + return result; + }; + + /** + * Gets the `toStringTag` of `value`. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ + var getTag = baseGetTag; + + // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. + if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || + (Map && getTag(new Map) != mapTag) || + (Promise && getTag(Promise.resolve()) != promiseTag) || + (Set && getTag(new Set) != setTag) || + (WeakMap && getTag(new WeakMap) != weakMapTag)) { + getTag = function(value) { + var result = baseGetTag(value), + Ctor = result == objectTag ? value.constructor : undefined, + ctorString = Ctor ? toSource(Ctor) : ''; + + if (ctorString) { + switch (ctorString) { + case dataViewCtorString: return dataViewTag; + case mapCtorString: return mapTag; + case promiseCtorString: return promiseTag; + case setCtorString: return setTag; + case weakMapCtorString: return weakMapTag; + } + } + return result; + }; + } + + /** + * Gets the view, applying any `transforms` to the `start` and `end` positions. + * + * @private + * @param {number} start The start of the view. + * @param {number} end The end of the view. + * @param {Array} transforms The transformations to apply to the view. + * @returns {Object} Returns an object containing the `start` and `end` + * positions of the view. + */ + function getView(start, end, transforms) { + var index = -1, + length = transforms.length; + + while (++index < length) { + var data = transforms[index], + size = data.size; + + switch (data.type) { + case 'drop': start += size; break; + case 'dropRight': end -= size; break; + case 'take': end = nativeMin(end, start + size); break; + case 'takeRight': start = nativeMax(start, end - size); break; + } + } + return { 'start': start, 'end': end }; + } + + /** + * Extracts wrapper details from the `source` body comment. + * + * @private + * @param {string} source The source to inspect. + * @returns {Array} Returns the wrapper details. + */ + function getWrapDetails(source) { + var match = source.match(reWrapDetails); + return match ? match[1].split(reSplitDetails) : []; + } + + /** + * Checks if `path` exists on `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @param {Function} hasFunc The function to check properties. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + */ + function hasPath(object, path, hasFunc) { + path = castPath(path, object); + + var index = -1, + length = path.length, + result = false; + + while (++index < length) { + var key = toKey(path[index]); + if (!(result = object != null && hasFunc(object, key))) { + break; + } + object = object[key]; + } + if (result || ++index != length) { + return result; + } + length = object == null ? 0 : object.length; + return !!length && isLength(length) && isIndex(key, length) && + (isArray(object) || isArguments(object)); + } + + /** + * Initializes an array clone. + * + * @private + * @param {Array} array The array to clone. + * @returns {Array} Returns the initialized clone. + */ + function initCloneArray(array) { + var length = array.length, + result = new array.constructor(length); + + // Add properties assigned by `RegExp#exec`. + if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { + result.index = array.index; + result.input = array.input; + } + return result; + } + + /** + * Initializes an object clone. + * + * @private + * @param {Object} object The object to clone. + * @returns {Object} Returns the initialized clone. + */ + function initCloneObject(object) { + return (typeof object.constructor == 'function' && !isPrototype(object)) + ? baseCreate(getPrototype(object)) + : {}; + } + + /** + * Initializes an object clone based on its `toStringTag`. + * + * **Note:** This function only supports cloning values with tags of + * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. + * + * @private + * @param {Object} object The object to clone. + * @param {string} tag The `toStringTag` of the object to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the initialized clone. + */ + function initCloneByTag(object, tag, isDeep) { + var Ctor = object.constructor; + switch (tag) { + case arrayBufferTag: + return cloneArrayBuffer(object); + + case boolTag: + case dateTag: + return new Ctor(+object); + + case dataViewTag: + return cloneDataView(object, isDeep); + + case float32Tag: case float64Tag: + case int8Tag: case int16Tag: case int32Tag: + case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: + return cloneTypedArray(object, isDeep); + + case mapTag: + return new Ctor; + + case numberTag: + case stringTag: + return new Ctor(object); + + case regexpTag: + return cloneRegExp(object); + + case setTag: + return new Ctor; + + case symbolTag: + return cloneSymbol(object); + } + } + + /** + * Inserts wrapper `details` in a comment at the top of the `source` body. + * + * @private + * @param {string} source The source to modify. + * @returns {Array} details The details to insert. + * @returns {string} Returns the modified source. + */ + function insertWrapDetails(source, details) { + var length = details.length; + if (!length) { + return source; + } + var lastIndex = length - 1; + details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; + details = details.join(length > 2 ? ', ' : ' '); + return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); + } + + /** + * Checks if `value` is a flattenable `arguments` object or array. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. + */ + function isFlattenable(value) { + return isArray(value) || isArguments(value) || + !!(spreadableSymbol && value && value[spreadableSymbol]); + } + + /** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ + function isIndex(value, length) { + var type = typeof value; + length = length == null ? MAX_SAFE_INTEGER : length; + + return !!length && + (type == 'number' || + (type != 'symbol' && reIsUint.test(value))) && + (value > -1 && value % 1 == 0 && value < length); + } + + /** + * Checks if the given arguments are from an iteratee call. + * + * @private + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, + * else `false`. + */ + function isIterateeCall(value, index, object) { + if (!isObject(object)) { + return false; + } + var type = typeof index; + if (type == 'number' + ? (isArrayLike(object) && isIndex(index, object.length)) + : (type == 'string' && index in object) + ) { + return eq(object[index], value); + } + return false; + } + + /** + * Checks if `value` is a property name and not a property path. + * + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + */ + function isKey(value, object) { + if (isArray(value)) { + return false; + } + var type = typeof value; + if (type == 'number' || type == 'symbol' || type == 'boolean' || + value == null || isSymbol(value)) { + return true; + } + return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || + (object != null && value in Object(object)); + } + + /** + * Checks if `value` is suitable for use as unique object key. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + */ + function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); + } + + /** + * Checks if `func` has a lazy counterpart. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` has a lazy counterpart, + * else `false`. + */ + function isLaziable(func) { + var funcName = getFuncName(func), + other = lodash[funcName]; + + if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { + return false; + } + if (func === other) { + return true; + } + var data = getData(other); + return !!data && func === data[0]; + } + + /** + * Checks if `func` has its source masked. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. + */ + function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); + } + + /** + * Checks if `func` is capable of being masked. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `func` is maskable, else `false`. + */ + var isMaskable = coreJsData ? isFunction : stubFalse; + + /** + * Checks if `value` is likely a prototype object. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. + */ + function isPrototype(value) { + var Ctor = value && value.constructor, + proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; + + return value === proto; + } + + /** + * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` if suitable for strict + * equality comparisons, else `false`. + */ + function isStrictComparable(value) { + return value === value && !isObject(value); + } + + /** + * A specialized version of `matchesProperty` for source values suitable + * for strict equality comparisons, i.e. `===`. + * + * @private + * @param {string} key The key of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ + function matchesStrictComparable(key, srcValue) { + return function(object) { + if (object == null) { + return false; + } + return object[key] === srcValue && + (srcValue !== undefined || (key in Object(object))); + }; + } + + /** + * A specialized version of `_.memoize` which clears the memoized function's + * cache when it exceeds `MAX_MEMOIZE_SIZE`. + * + * @private + * @param {Function} func The function to have its output memoized. + * @returns {Function} Returns the new memoized function. + */ + function memoizeCapped(func) { + var result = memoize(func, function(key) { + if (cache.size === MAX_MEMOIZE_SIZE) { + cache.clear(); + } + return key; + }); + + var cache = result.cache; + return result; + } + + /** + * Merges the function metadata of `source` into `data`. + * + * Merging metadata reduces the number of wrappers used to invoke a function. + * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` + * may be applied regardless of execution order. Methods like `_.ary` and + * `_.rearg` modify function arguments, making the order in which they are + * executed important, preventing the merging of metadata. However, we make + * an exception for a safe combined case where curried functions have `_.ary` + * and or `_.rearg` applied. + * + * @private + * @param {Array} data The destination metadata. + * @param {Array} source The source metadata. + * @returns {Array} Returns `data`. + */ + function mergeData(data, source) { + var bitmask = data[1], + srcBitmask = source[1], + newBitmask = bitmask | srcBitmask, + isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); + + var isCombo = + ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || + ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || + ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); + + // Exit early if metadata can't be merged. + if (!(isCommon || isCombo)) { + return data; + } + // Use source `thisArg` if available. + if (srcBitmask & WRAP_BIND_FLAG) { + data[2] = source[2]; + // Set when currying a bound function. + newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; + } + // Compose partial arguments. + var value = source[3]; + if (value) { + var partials = data[3]; + data[3] = partials ? composeArgs(partials, value, source[4]) : value; + data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; + } + // Compose partial right arguments. + value = source[5]; + if (value) { + partials = data[5]; + data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; + data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; + } + // Use source `argPos` if available. + value = source[7]; + if (value) { + data[7] = value; + } + // Use source `ary` if it's smaller. + if (srcBitmask & WRAP_ARY_FLAG) { + data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); + } + // Use source `arity` if one is not provided. + if (data[9] == null) { + data[9] = source[9]; + } + // Use source `func` and merge bitmasks. + data[0] = source[0]; + data[1] = newBitmask; + + return data; + } + + /** + * This function is like + * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * except that it includes inherited enumerable properties. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ + function nativeKeysIn(object) { + var result = []; + if (object != null) { + for (var key in Object(object)) { + result.push(key); + } + } + return result; + } + + /** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ + function objectToString(value) { + return nativeObjectToString.call(value); + } + + /** + * A specialized version of `baseRest` which transforms the rest array. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @param {Function} transform The rest array transform. + * @returns {Function} Returns the new function. + */ + function overRest(func, start, transform) { + start = nativeMax(start === undefined ? (func.length - 1) : start, 0); + return function() { + var args = arguments, + index = -1, + length = nativeMax(args.length - start, 0), + array = Array(length); + + while (++index < length) { + array[index] = args[start + index]; + } + index = -1; + var otherArgs = Array(start + 1); + while (++index < start) { + otherArgs[index] = args[index]; + } + otherArgs[start] = transform(array); + return apply(func, this, otherArgs); + }; + } + + /** + * Gets the parent value at `path` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} path The path to get the parent value of. + * @returns {*} Returns the parent value. + */ + function parent(object, path) { + return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); + } + + /** + * Reorder `array` according to the specified indexes where the element at + * the first index is assigned as the first element, the element at + * the second index is assigned as the second element, and so on. + * + * @private + * @param {Array} array The array to reorder. + * @param {Array} indexes The arranged array indexes. + * @returns {Array} Returns `array`. + */ + function reorder(array, indexes) { + var arrLength = array.length, + length = nativeMin(indexes.length, arrLength), + oldArray = copyArray(array); + + while (length--) { + var index = indexes[length]; + array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; + } + return array; + } + + /** + * Gets the value at `key`, unless `key` is "__proto__" or "constructor". + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ + function safeGet(object, key) { + if (key === 'constructor' && typeof object[key] === 'function') { + return; + } + + if (key == '__proto__') { + return; + } + + return object[key]; + } + + /** + * Sets metadata for `func`. + * + * **Note:** If this function becomes hot, i.e. is invoked a lot in a short + * period of time, it will trip its breaker and transition to an identity + * function to avoid garbage collection pauses in V8. See + * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) + * for more details. + * + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. + */ + var setData = shortOut(baseSetData); + + /** + * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). + * + * @private + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @returns {number|Object} Returns the timer id or timeout object. + */ + var setTimeout = ctxSetTimeout || function(func, wait) { + return root.setTimeout(func, wait); + }; + + /** + * Sets the `toString` method of `func` to return `string`. + * + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ + var setToString = shortOut(baseSetToString); + + /** + * Sets the `toString` method of `wrapper` to mimic the source of `reference` + * with wrapper details in a comment at the top of the source body. + * + * @private + * @param {Function} wrapper The function to modify. + * @param {Function} reference The reference function. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @returns {Function} Returns `wrapper`. + */ + function setWrapToString(wrapper, reference, bitmask) { + var source = (reference + ''); + return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); + } + + /** + * Creates a function that'll short out and invoke `identity` instead + * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` + * milliseconds. + * + * @private + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new shortable function. + */ + function shortOut(func) { + var count = 0, + lastCalled = 0; + + return function() { + var stamp = nativeNow(), + remaining = HOT_SPAN - (stamp - lastCalled); + + lastCalled = stamp; + if (remaining > 0) { + if (++count >= HOT_COUNT) { + return arguments[0]; + } + } else { + count = 0; + } + return func.apply(undefined, arguments); + }; + } + + /** + * A specialized version of `_.shuffle` which mutates and sets the size of `array`. + * + * @private + * @param {Array} array The array to shuffle. + * @param {number} [size=array.length] The size of `array`. + * @returns {Array} Returns `array`. + */ + function shuffleSelf(array, size) { + var index = -1, + length = array.length, + lastIndex = length - 1; + + size = size === undefined ? length : size; + while (++index < size) { + var rand = baseRandom(index, lastIndex), + value = array[rand]; + + array[rand] = array[index]; + array[index] = value; + } + array.length = size; + return array; + } + + /** + * Converts `string` to a property path array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the property path array. + */ + var stringToPath = memoizeCapped(function(string) { + var result = []; + if (string.charCodeAt(0) === 46 /* . */) { + result.push(''); + } + string.replace(rePropName, function(match, number, quote, subString) { + result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); + }); + return result; + }); + + /** + * Converts `value` to a string key if it's not a string or symbol. + * + * @private + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the key. + */ + function toKey(value) { + if (typeof value == 'string' || isSymbol(value)) { + return value; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; + } + + /** + * Converts `func` to its source code. + * + * @private + * @param {Function} func The function to convert. + * @returns {string} Returns the source code. + */ + function toSource(func) { + if (func != null) { + try { + return funcToString.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; + } + + /** + * Updates wrapper `details` based on `bitmask` flags. + * + * @private + * @returns {Array} details The details to modify. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @returns {Array} Returns `details`. + */ + function updateWrapDetails(details, bitmask) { + arrayEach(wrapFlags, function(pair) { + var value = '_.' + pair[0]; + if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { + details.push(value); + } + }); + return details.sort(); + } + + /** + * Creates a clone of `wrapper`. + * + * @private + * @param {Object} wrapper The wrapper to clone. + * @returns {Object} Returns the cloned wrapper. + */ + function wrapperClone(wrapper) { + if (wrapper instanceof LazyWrapper) { + return wrapper.clone(); + } + var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); + result.__actions__ = copyArray(wrapper.__actions__); + result.__index__ = wrapper.__index__; + result.__values__ = wrapper.__values__; + return result; + } + + /*------------------------------------------------------------------------*/ + + /** + * Creates an array of elements split into groups the length of `size`. + * If `array` can't be split evenly, the final chunk will be the remaining + * elements. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to process. + * @param {number} [size=1] The length of each chunk + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the new array of chunks. + * @example + * + * _.chunk(['a', 'b', 'c', 'd'], 2); + * // => [['a', 'b'], ['c', 'd']] + * + * _.chunk(['a', 'b', 'c', 'd'], 3); + * // => [['a', 'b', 'c'], ['d']] + */ + function chunk(array, size, guard) { + if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { + size = 1; + } else { + size = nativeMax(toInteger(size), 0); + } + var length = array == null ? 0 : array.length; + if (!length || size < 1) { + return []; + } + var index = 0, + resIndex = 0, + result = Array(nativeCeil(length / size)); + + while (index < length) { + result[resIndex++] = baseSlice(array, index, (index += size)); + } + return result; + } + + /** + * Creates an array with all falsey values removed. The values `false`, `null`, + * `0`, `""`, `undefined`, and `NaN` are falsey. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to compact. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * _.compact([0, 1, false, 2, '', 3]); + * // => [1, 2, 3] + */ + function compact(array) { + var index = -1, + length = array == null ? 0 : array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (value) { + result[resIndex++] = value; + } + } + return result; + } + + /** + * Creates a new array concatenating `array` with any additional arrays + * and/or values. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to concatenate. + * @param {...*} [values] The values to concatenate. + * @returns {Array} Returns the new concatenated array. + * @example + * + * var array = [1]; + * var other = _.concat(array, 2, [3], [[4]]); + * + * console.log(other); + * // => [1, 2, 3, [4]] + * + * console.log(array); + * // => [1] + */ + function concat() { + var length = arguments.length; + if (!length) { + return []; + } + var args = Array(length - 1), + array = arguments[0], + index = length; + + while (index--) { + args[index - 1] = arguments[index]; + } + return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); + } + + /** + * Creates an array of `array` values not included in the other given arrays + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. The order and references of result values are + * determined by the first array. + * + * **Note:** Unlike `_.pullAll`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @returns {Array} Returns the new array of filtered values. + * @see _.without, _.xor + * @example + * + * _.difference([2, 1], [2, 3]); + * // => [1] + */ + var difference = baseRest(function(array, values) { + return isArrayLikeObject(array) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) + : []; + }); + + /** + * This method is like `_.difference` except that it accepts `iteratee` which + * is invoked for each element of `array` and `values` to generate the criterion + * by which they're compared. The order and references of result values are + * determined by the first array. The iteratee is invoked with one argument: + * (value). + * + * **Note:** Unlike `_.pullAllBy`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); + * // => [1.2] + * + * // The `_.property` iteratee shorthand. + * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); + * // => [{ 'x': 2 }] + */ + var differenceBy = baseRest(function(array, values) { + var iteratee = last(values); + if (isArrayLikeObject(iteratee)) { + iteratee = undefined; + } + return isArrayLikeObject(array) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) + : []; + }); + + /** + * This method is like `_.difference` except that it accepts `comparator` + * which is invoked to compare elements of `array` to `values`. The order and + * references of result values are determined by the first array. The comparator + * is invoked with two arguments: (arrVal, othVal). + * + * **Note:** Unlike `_.pullAllWith`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * + * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); + * // => [{ 'x': 2, 'y': 1 }] + */ + var differenceWith = baseRest(function(array, values) { + var comparator = last(values); + if (isArrayLikeObject(comparator)) { + comparator = undefined; + } + return isArrayLikeObject(array) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) + : []; + }); + + /** + * Creates a slice of `array` with `n` elements dropped from the beginning. + * + * @static + * @memberOf _ + * @since 0.5.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to drop. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.drop([1, 2, 3]); + * // => [2, 3] + * + * _.drop([1, 2, 3], 2); + * // => [3] + * + * _.drop([1, 2, 3], 5); + * // => [] + * + * _.drop([1, 2, 3], 0); + * // => [1, 2, 3] + */ + function drop(array, n, guard) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; + } + n = (guard || n === undefined) ? 1 : toInteger(n); + return baseSlice(array, n < 0 ? 0 : n, length); + } + + /** + * Creates a slice of `array` with `n` elements dropped from the end. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to drop. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.dropRight([1, 2, 3]); + * // => [1, 2] + * + * _.dropRight([1, 2, 3], 2); + * // => [1] + * + * _.dropRight([1, 2, 3], 5); + * // => [] + * + * _.dropRight([1, 2, 3], 0); + * // => [1, 2, 3] + */ + function dropRight(array, n, guard) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; + } + n = (guard || n === undefined) ? 1 : toInteger(n); + n = length - n; + return baseSlice(array, 0, n < 0 ? 0 : n); + } + + /** + * Creates a slice of `array` excluding elements dropped from the end. + * Elements are dropped until `predicate` returns falsey. The predicate is + * invoked with three arguments: (value, index, array). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the slice of `array`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; + * + * _.dropRightWhile(users, function(o) { return !o.active; }); + * // => objects for ['barney'] + * + * // The `_.matches` iteratee shorthand. + * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); + * // => objects for ['barney', 'fred'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.dropRightWhile(users, ['active', false]); + * // => objects for ['barney'] + * + * // The `_.property` iteratee shorthand. + * _.dropRightWhile(users, 'active'); + * // => objects for ['barney', 'fred', 'pebbles'] + */ + function dropRightWhile(array, predicate) { + return (array && array.length) + ? baseWhile(array, getIteratee(predicate, 3), true, true) + : []; + } + + /** + * Creates a slice of `array` excluding elements dropped from the beginning. + * Elements are dropped until `predicate` returns falsey. The predicate is + * invoked with three arguments: (value, index, array). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the slice of `array`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * _.dropWhile(users, function(o) { return !o.active; }); + * // => objects for ['pebbles'] + * + * // The `_.matches` iteratee shorthand. + * _.dropWhile(users, { 'user': 'barney', 'active': false }); + * // => objects for ['fred', 'pebbles'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.dropWhile(users, ['active', false]); + * // => objects for ['pebbles'] + * + * // The `_.property` iteratee shorthand. + * _.dropWhile(users, 'active'); + * // => objects for ['barney', 'fred', 'pebbles'] + */ + function dropWhile(array, predicate) { + return (array && array.length) + ? baseWhile(array, getIteratee(predicate, 3), true) + : []; + } + + /** + * Fills elements of `array` with `value` from `start` up to, but not + * including, `end`. + * + * **Note:** This method mutates `array`. + * + * @static + * @memberOf _ + * @since 3.2.0 + * @category Array + * @param {Array} array The array to fill. + * @param {*} value The value to fill `array` with. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns `array`. + * @example + * + * var array = [1, 2, 3]; + * + * _.fill(array, 'a'); + * console.log(array); + * // => ['a', 'a', 'a'] + * + * _.fill(Array(3), 2); + * // => [2, 2, 2] + * + * _.fill([4, 6, 8, 10], '*', 1, 3); + * // => [4, '*', '*', 10] + */ + function fill(array, value, start, end) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; + } + if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { + start = 0; + end = length; + } + return baseFill(array, value, start, end); + } + + /** + * This method is like `_.find` except that it returns the index of the first + * element `predicate` returns truthy for instead of the element itself. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=0] The index to search from. + * @returns {number} Returns the index of the found element, else `-1`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * _.findIndex(users, function(o) { return o.user == 'barney'; }); + * // => 0 + * + * // The `_.matches` iteratee shorthand. + * _.findIndex(users, { 'user': 'fred', 'active': false }); + * // => 1 + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findIndex(users, ['active', false]); + * // => 0 + * + * // The `_.property` iteratee shorthand. + * _.findIndex(users, 'active'); + * // => 2 + */ + function findIndex(array, predicate, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; + } + var index = fromIndex == null ? 0 : toInteger(fromIndex); + if (index < 0) { + index = nativeMax(length + index, 0); + } + return baseFindIndex(array, getIteratee(predicate, 3), index); + } + + /** + * This method is like `_.findIndex` except that it iterates over elements + * of `collection` from right to left. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=array.length-1] The index to search from. + * @returns {number} Returns the index of the found element, else `-1`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; + * + * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); + * // => 2 + * + * // The `_.matches` iteratee shorthand. + * _.findLastIndex(users, { 'user': 'barney', 'active': true }); + * // => 0 + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findLastIndex(users, ['active', false]); + * // => 2 + * + * // The `_.property` iteratee shorthand. + * _.findLastIndex(users, 'active'); + * // => 0 + */ + function findLastIndex(array, predicate, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; + } + var index = length - 1; + if (fromIndex !== undefined) { + index = toInteger(fromIndex); + index = fromIndex < 0 + ? nativeMax(length + index, 0) + : nativeMin(index, length - 1); + } + return baseFindIndex(array, getIteratee(predicate, 3), index, true); + } + + /** + * Flattens `array` a single level deep. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to flatten. + * @returns {Array} Returns the new flattened array. + * @example + * + * _.flatten([1, [2, [3, [4]], 5]]); + * // => [1, 2, [3, [4]], 5] + */ + function flatten(array) { + var length = array == null ? 0 : array.length; + return length ? baseFlatten(array, 1) : []; + } + + /** + * Recursively flattens `array`. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to flatten. + * @returns {Array} Returns the new flattened array. + * @example + * + * _.flattenDeep([1, [2, [3, [4]], 5]]); + * // => [1, 2, 3, 4, 5] + */ + function flattenDeep(array) { + var length = array == null ? 0 : array.length; + return length ? baseFlatten(array, INFINITY) : []; + } + + /** + * Recursively flatten `array` up to `depth` times. + * + * @static + * @memberOf _ + * @since 4.4.0 + * @category Array + * @param {Array} array The array to flatten. + * @param {number} [depth=1] The maximum recursion depth. + * @returns {Array} Returns the new flattened array. + * @example + * + * var array = [1, [2, [3, [4]], 5]]; + * + * _.flattenDepth(array, 1); + * // => [1, 2, [3, [4]], 5] + * + * _.flattenDepth(array, 2); + * // => [1, 2, 3, [4], 5] + */ + function flattenDepth(array, depth) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; + } + depth = depth === undefined ? 1 : toInteger(depth); + return baseFlatten(array, depth); + } + + /** + * The inverse of `_.toPairs`; this method returns an object composed + * from key-value `pairs`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} pairs The key-value pairs. + * @returns {Object} Returns the new object. + * @example + * + * _.fromPairs([['a', 1], ['b', 2]]); + * // => { 'a': 1, 'b': 2 } + */ + function fromPairs(pairs) { + var index = -1, + length = pairs == null ? 0 : pairs.length, + result = {}; + + while (++index < length) { + var pair = pairs[index]; + result[pair[0]] = pair[1]; + } + return result; + } + + /** + * Gets the first element of `array`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @alias first + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the first element of `array`. + * @example + * + * _.head([1, 2, 3]); + * // => 1 + * + * _.head([]); + * // => undefined + */ + function head(array) { + return (array && array.length) ? array[0] : undefined; + } + + /** + * Gets the index at which the first occurrence of `value` is found in `array` + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. If `fromIndex` is negative, it's used as the + * offset from the end of `array`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} [fromIndex=0] The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + * @example + * + * _.indexOf([1, 2, 1, 2], 2); + * // => 1 + * + * // Search from the `fromIndex`. + * _.indexOf([1, 2, 1, 2], 2, 2); + * // => 3 + */ + function indexOf(array, value, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; + } + var index = fromIndex == null ? 0 : toInteger(fromIndex); + if (index < 0) { + index = nativeMax(length + index, 0); + } + return baseIndexOf(array, value, index); + } + + /** + * Gets all but the last element of `array`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to query. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.initial([1, 2, 3]); + * // => [1, 2] + */ + function initial(array) { + var length = array == null ? 0 : array.length; + return length ? baseSlice(array, 0, -1) : []; + } + + /** + * Creates an array of unique values that are included in all given arrays + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. The order and references of result values are + * determined by the first array. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of intersecting values. + * @example + * + * _.intersection([2, 1], [2, 3]); + * // => [2] + */ + var intersection = baseRest(function(arrays) { + var mapped = arrayMap(arrays, castArrayLikeObject); + return (mapped.length && mapped[0] === arrays[0]) + ? baseIntersection(mapped) + : []; + }); + + /** + * This method is like `_.intersection` except that it accepts `iteratee` + * which is invoked for each element of each `arrays` to generate the criterion + * by which they're compared. The order and references of result values are + * determined by the first array. The iteratee is invoked with one argument: + * (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of intersecting values. + * @example + * + * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); + * // => [2.1] + * + * // The `_.property` iteratee shorthand. + * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 1 }] + */ + var intersectionBy = baseRest(function(arrays) { + var iteratee = last(arrays), + mapped = arrayMap(arrays, castArrayLikeObject); + + if (iteratee === last(mapped)) { + iteratee = undefined; + } else { + mapped.pop(); + } + return (mapped.length && mapped[0] === arrays[0]) + ? baseIntersection(mapped, getIteratee(iteratee, 2)) + : []; + }); + + /** + * This method is like `_.intersection` except that it accepts `comparator` + * which is invoked to compare elements of `arrays`. The order and references + * of result values are determined by the first array. The comparator is + * invoked with two arguments: (arrVal, othVal). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of intersecting values. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * + * _.intersectionWith(objects, others, _.isEqual); + * // => [{ 'x': 1, 'y': 2 }] + */ + var intersectionWith = baseRest(function(arrays) { + var comparator = last(arrays), + mapped = arrayMap(arrays, castArrayLikeObject); + + comparator = typeof comparator == 'function' ? comparator : undefined; + if (comparator) { + mapped.pop(); + } + return (mapped.length && mapped[0] === arrays[0]) + ? baseIntersection(mapped, undefined, comparator) + : []; + }); + + /** + * Converts all elements in `array` into a string separated by `separator`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to convert. + * @param {string} [separator=','] The element separator. + * @returns {string} Returns the joined string. + * @example + * + * _.join(['a', 'b', 'c'], '~'); + * // => 'a~b~c' + */ + function join(array, separator) { + return array == null ? '' : nativeJoin.call(array, separator); + } + + /** + * Gets the last element of `array`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the last element of `array`. + * @example + * + * _.last([1, 2, 3]); + * // => 3 + */ + function last(array) { + var length = array == null ? 0 : array.length; + return length ? array[length - 1] : undefined; + } + + /** + * This method is like `_.indexOf` except that it iterates over elements of + * `array` from right to left. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} [fromIndex=array.length-1] The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + * @example + * + * _.lastIndexOf([1, 2, 1, 2], 2); + * // => 3 + * + * // Search from the `fromIndex`. + * _.lastIndexOf([1, 2, 1, 2], 2, 2); + * // => 1 + */ + function lastIndexOf(array, value, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; + } + var index = length; + if (fromIndex !== undefined) { + index = toInteger(fromIndex); + index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); + } + return value === value + ? strictLastIndexOf(array, value, index) + : baseFindIndex(array, baseIsNaN, index, true); + } + + /** + * Gets the element at index `n` of `array`. If `n` is negative, the nth + * element from the end is returned. + * + * @static + * @memberOf _ + * @since 4.11.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=0] The index of the element to return. + * @returns {*} Returns the nth element of `array`. + * @example + * + * var array = ['a', 'b', 'c', 'd']; + * + * _.nth(array, 1); + * // => 'b' + * + * _.nth(array, -2); + * // => 'c'; + */ + function nth(array, n) { + return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; + } + + /** + * Removes all given values from `array` using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` + * to remove elements from an array by predicate. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {...*} [values] The values to remove. + * @returns {Array} Returns `array`. + * @example + * + * var array = ['a', 'b', 'c', 'a', 'b', 'c']; + * + * _.pull(array, 'a', 'c'); + * console.log(array); + * // => ['b', 'b'] + */ + var pull = baseRest(pullAll); + + /** + * This method is like `_.pull` except that it accepts an array of values to remove. + * + * **Note:** Unlike `_.difference`, this method mutates `array`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {Array} values The values to remove. + * @returns {Array} Returns `array`. + * @example + * + * var array = ['a', 'b', 'c', 'a', 'b', 'c']; + * + * _.pullAll(array, ['a', 'c']); + * console.log(array); + * // => ['b', 'b'] + */ + function pullAll(array, values) { + return (array && array.length && values && values.length) + ? basePullAll(array, values) + : array; + } + + /** + * This method is like `_.pullAll` except that it accepts `iteratee` which is + * invoked for each element of `array` and `values` to generate the criterion + * by which they're compared. The iteratee is invoked with one argument: (value). + * + * **Note:** Unlike `_.differenceBy`, this method mutates `array`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {Array} values The values to remove. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns `array`. + * @example + * + * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; + * + * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); + * console.log(array); + * // => [{ 'x': 2 }] + */ + function pullAllBy(array, values, iteratee) { + return (array && array.length && values && values.length) + ? basePullAll(array, values, getIteratee(iteratee, 2)) + : array; + } + + /** + * This method is like `_.pullAll` except that it accepts `comparator` which + * is invoked to compare elements of `array` to `values`. The comparator is + * invoked with two arguments: (arrVal, othVal). + * + * **Note:** Unlike `_.differenceWith`, this method mutates `array`. + * + * @static + * @memberOf _ + * @since 4.6.0 + * @category Array + * @param {Array} array The array to modify. + * @param {Array} values The values to remove. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns `array`. + * @example + * + * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; + * + * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); + * console.log(array); + * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] + */ + function pullAllWith(array, values, comparator) { + return (array && array.length && values && values.length) + ? basePullAll(array, values, undefined, comparator) + : array; + } + + /** + * Removes elements from `array` corresponding to `indexes` and returns an + * array of removed elements. + * + * **Note:** Unlike `_.at`, this method mutates `array`. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {...(number|number[])} [indexes] The indexes of elements to remove. + * @returns {Array} Returns the new array of removed elements. + * @example + * + * var array = ['a', 'b', 'c', 'd']; + * var pulled = _.pullAt(array, [1, 3]); + * + * console.log(array); + * // => ['a', 'c'] + * + * console.log(pulled); + * // => ['b', 'd'] + */ + var pullAt = flatRest(function(array, indexes) { + var length = array == null ? 0 : array.length, + result = baseAt(array, indexes); + + basePullAt(array, arrayMap(indexes, function(index) { + return isIndex(index, length) ? +index : index; + }).sort(compareAscending)); + + return result; + }); + + /** + * Removes all elements from `array` that `predicate` returns truthy for + * and returns an array of the removed elements. The predicate is invoked + * with three arguments: (value, index, array). + * + * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` + * to pull elements from an array by value. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Array + * @param {Array} array The array to modify. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new array of removed elements. + * @example + * + * var array = [1, 2, 3, 4]; + * var evens = _.remove(array, function(n) { + * return n % 2 == 0; + * }); + * + * console.log(array); + * // => [1, 3] + * + * console.log(evens); + * // => [2, 4] + */ + function remove(array, predicate) { + var result = []; + if (!(array && array.length)) { + return result; + } + var index = -1, + indexes = [], + length = array.length; + + predicate = getIteratee(predicate, 3); + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result.push(value); + indexes.push(index); + } + } + basePullAt(array, indexes); + return result; + } + + /** + * Reverses `array` so that the first element becomes the last, the second + * element becomes the second to last, and so on. + * + * **Note:** This method mutates `array` and is based on + * [`Array#reverse`](https://mdn.io/Array/reverse). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to modify. + * @returns {Array} Returns `array`. + * @example + * + * var array = [1, 2, 3]; + * + * _.reverse(array); + * // => [3, 2, 1] + * + * console.log(array); + * // => [3, 2, 1] + */ + function reverse(array) { + return array == null ? array : nativeReverse.call(array); + } + + /** + * Creates a slice of `array` from `start` up to, but not including, `end`. + * + * **Note:** This method is used instead of + * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are + * returned. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. + */ + function slice(array, start, end) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; + } + if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { + start = 0; + end = length; + } + else { + start = start == null ? 0 : toInteger(start); + end = end === undefined ? length : toInteger(end); + } + return baseSlice(array, start, end); + } + + /** + * Uses a binary search to determine the lowest index at which `value` + * should be inserted into `array` in order to maintain its sort order. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + * @example + * + * _.sortedIndex([30, 50], 40); + * // => 1 + */ + function sortedIndex(array, value) { + return baseSortedIndex(array, value); + } + + /** + * This method is like `_.sortedIndex` except that it accepts `iteratee` + * which is invoked for `value` and each element of `array` to compute their + * sort ranking. The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + * @example + * + * var objects = [{ 'x': 4 }, { 'x': 5 }]; + * + * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); + * // => 0 + * + * // The `_.property` iteratee shorthand. + * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); + * // => 0 + */ + function sortedIndexBy(array, value, iteratee) { + return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); + } + + /** + * This method is like `_.indexOf` except that it performs a binary + * search on a sorted `array`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + * @example + * + * _.sortedIndexOf([4, 5, 5, 5, 6], 5); + * // => 1 + */ + function sortedIndexOf(array, value) { + var length = array == null ? 0 : array.length; + if (length) { + var index = baseSortedIndex(array, value); + if (index < length && eq(array[index], value)) { + return index; + } + } + return -1; + } + + /** + * This method is like `_.sortedIndex` except that it returns the highest + * index at which `value` should be inserted into `array` in order to + * maintain its sort order. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + * @example + * + * _.sortedLastIndex([4, 5, 5, 5, 6], 5); + * // => 4 + */ + function sortedLastIndex(array, value) { + return baseSortedIndex(array, value, true); + } + + /** + * This method is like `_.sortedLastIndex` except that it accepts `iteratee` + * which is invoked for `value` and each element of `array` to compute their + * sort ranking. The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + * @example + * + * var objects = [{ 'x': 4 }, { 'x': 5 }]; + * + * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); + * // => 1 + * + * // The `_.property` iteratee shorthand. + * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); + * // => 1 + */ + function sortedLastIndexBy(array, value, iteratee) { + return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); + } + + /** + * This method is like `_.lastIndexOf` except that it performs a binary + * search on a sorted `array`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + * @example + * + * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); + * // => 3 + */ + function sortedLastIndexOf(array, value) { + var length = array == null ? 0 : array.length; + if (length) { + var index = baseSortedIndex(array, value, true) - 1; + if (eq(array[index], value)) { + return index; + } + } + return -1; + } + + /** + * This method is like `_.uniq` except that it's designed and optimized + * for sorted arrays. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @returns {Array} Returns the new duplicate free array. + * @example + * + * _.sortedUniq([1, 1, 2]); + * // => [1, 2] + */ + function sortedUniq(array) { + return (array && array.length) + ? baseSortedUniq(array) + : []; + } + + /** + * This method is like `_.uniqBy` except that it's designed and optimized + * for sorted arrays. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @returns {Array} Returns the new duplicate free array. + * @example + * + * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); + * // => [1.1, 2.3] + */ + function sortedUniqBy(array, iteratee) { + return (array && array.length) + ? baseSortedUniq(array, getIteratee(iteratee, 2)) + : []; + } + + /** + * Gets all but the first element of `array`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to query. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.tail([1, 2, 3]); + * // => [2, 3] + */ + function tail(array) { + var length = array == null ? 0 : array.length; + return length ? baseSlice(array, 1, length) : []; + } + + /** + * Creates a slice of `array` with `n` elements taken from the beginning. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to take. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.take([1, 2, 3]); + * // => [1] + * + * _.take([1, 2, 3], 2); + * // => [1, 2] + * + * _.take([1, 2, 3], 5); + * // => [1, 2, 3] + * + * _.take([1, 2, 3], 0); + * // => [] + */ + function take(array, n, guard) { + if (!(array && array.length)) { + return []; + } + n = (guard || n === undefined) ? 1 : toInteger(n); + return baseSlice(array, 0, n < 0 ? 0 : n); + } + + /** + * Creates a slice of `array` with `n` elements taken from the end. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to take. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.takeRight([1, 2, 3]); + * // => [3] + * + * _.takeRight([1, 2, 3], 2); + * // => [2, 3] + * + * _.takeRight([1, 2, 3], 5); + * // => [1, 2, 3] + * + * _.takeRight([1, 2, 3], 0); + * // => [] + */ + function takeRight(array, n, guard) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; + } + n = (guard || n === undefined) ? 1 : toInteger(n); + n = length - n; + return baseSlice(array, n < 0 ? 0 : n, length); + } + + /** + * Creates a slice of `array` with elements taken from the end. Elements are + * taken until `predicate` returns falsey. The predicate is invoked with + * three arguments: (value, index, array). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the slice of `array`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; + * + * _.takeRightWhile(users, function(o) { return !o.active; }); + * // => objects for ['fred', 'pebbles'] + * + * // The `_.matches` iteratee shorthand. + * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); + * // => objects for ['pebbles'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.takeRightWhile(users, ['active', false]); + * // => objects for ['fred', 'pebbles'] + * + * // The `_.property` iteratee shorthand. + * _.takeRightWhile(users, 'active'); + * // => [] + */ + function takeRightWhile(array, predicate) { + return (array && array.length) + ? baseWhile(array, getIteratee(predicate, 3), false, true) + : []; + } + + /** + * Creates a slice of `array` with elements taken from the beginning. Elements + * are taken until `predicate` returns falsey. The predicate is invoked with + * three arguments: (value, index, array). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the slice of `array`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * _.takeWhile(users, function(o) { return !o.active; }); + * // => objects for ['barney', 'fred'] + * + * // The `_.matches` iteratee shorthand. + * _.takeWhile(users, { 'user': 'barney', 'active': false }); + * // => objects for ['barney'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.takeWhile(users, ['active', false]); + * // => objects for ['barney', 'fred'] + * + * // The `_.property` iteratee shorthand. + * _.takeWhile(users, 'active'); + * // => [] + */ + function takeWhile(array, predicate) { + return (array && array.length) + ? baseWhile(array, getIteratee(predicate, 3)) + : []; + } + + /** + * Creates an array of unique values, in order, from all given arrays using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of combined values. + * @example + * + * _.union([2], [1, 2]); + * // => [2, 1] + */ + var union = baseRest(function(arrays) { + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); + }); + + /** + * This method is like `_.union` except that it accepts `iteratee` which is + * invoked for each element of each `arrays` to generate the criterion by + * which uniqueness is computed. Result values are chosen from the first + * array in which the value occurs. The iteratee is invoked with one argument: + * (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of combined values. + * @example + * + * _.unionBy([2.1], [1.2, 2.3], Math.floor); + * // => [2.1, 1.2] + * + * // The `_.property` iteratee shorthand. + * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 1 }, { 'x': 2 }] + */ + var unionBy = baseRest(function(arrays) { + var iteratee = last(arrays); + if (isArrayLikeObject(iteratee)) { + iteratee = undefined; + } + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); + }); + + /** + * This method is like `_.union` except that it accepts `comparator` which + * is invoked to compare elements of `arrays`. Result values are chosen from + * the first array in which the value occurs. The comparator is invoked + * with two arguments: (arrVal, othVal). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of combined values. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * + * _.unionWith(objects, others, _.isEqual); + * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] + */ + var unionWith = baseRest(function(arrays) { + var comparator = last(arrays); + comparator = typeof comparator == 'function' ? comparator : undefined; + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); + }); + + /** + * Creates a duplicate-free version of an array, using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons, in which only the first occurrence of each element + * is kept. The order of result values is determined by the order they occur + * in the array. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @returns {Array} Returns the new duplicate free array. + * @example + * + * _.uniq([2, 1, 2]); + * // => [2, 1] + */ + function uniq(array) { + return (array && array.length) ? baseUniq(array) : []; + } + + /** + * This method is like `_.uniq` except that it accepts `iteratee` which is + * invoked for each element in `array` to generate the criterion by which + * uniqueness is computed. The order of result values is determined by the + * order they occur in the array. The iteratee is invoked with one argument: + * (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new duplicate free array. + * @example + * + * _.uniqBy([2.1, 1.2, 2.3], Math.floor); + * // => [2.1, 1.2] + * + * // The `_.property` iteratee shorthand. + * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 1 }, { 'x': 2 }] + */ + function uniqBy(array, iteratee) { + return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; + } + + /** + * This method is like `_.uniq` except that it accepts `comparator` which + * is invoked to compare elements of `array`. The order of result values is + * determined by the order they occur in the array.The comparator is invoked + * with two arguments: (arrVal, othVal). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new duplicate free array. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * + * _.uniqWith(objects, _.isEqual); + * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] + */ + function uniqWith(array, comparator) { + comparator = typeof comparator == 'function' ? comparator : undefined; + return (array && array.length) ? baseUniq(array, undefined, comparator) : []; + } + + /** + * This method is like `_.zip` except that it accepts an array of grouped + * elements and creates an array regrouping the elements to their pre-zip + * configuration. + * + * @static + * @memberOf _ + * @since 1.2.0 + * @category Array + * @param {Array} array The array of grouped elements to process. + * @returns {Array} Returns the new array of regrouped elements. + * @example + * + * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); + * // => [['a', 1, true], ['b', 2, false]] + * + * _.unzip(zipped); + * // => [['a', 'b'], [1, 2], [true, false]] + */ + function unzip(array) { + if (!(array && array.length)) { + return []; + } + var length = 0; + array = arrayFilter(array, function(group) { + if (isArrayLikeObject(group)) { + length = nativeMax(group.length, length); + return true; + } + }); + return baseTimes(length, function(index) { + return arrayMap(array, baseProperty(index)); + }); + } + + /** + * This method is like `_.unzip` except that it accepts `iteratee` to specify + * how regrouped values should be combined. The iteratee is invoked with the + * elements of each group: (...group). + * + * @static + * @memberOf _ + * @since 3.8.0 + * @category Array + * @param {Array} array The array of grouped elements to process. + * @param {Function} [iteratee=_.identity] The function to combine + * regrouped values. + * @returns {Array} Returns the new array of regrouped elements. + * @example + * + * var zipped = _.zip([1, 2], [10, 20], [100, 200]); + * // => [[1, 10, 100], [2, 20, 200]] + * + * _.unzipWith(zipped, _.add); + * // => [3, 30, 300] + */ + function unzipWith(array, iteratee) { + if (!(array && array.length)) { + return []; + } + var result = unzip(array); + if (iteratee == null) { + return result; + } + return arrayMap(result, function(group) { + return apply(iteratee, undefined, group); + }); + } + + /** + * Creates an array excluding all given values using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * **Note:** Unlike `_.pull`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...*} [values] The values to exclude. + * @returns {Array} Returns the new array of filtered values. + * @see _.difference, _.xor + * @example + * + * _.without([2, 1, 2, 3], 1, 2); + * // => [3] + */ + var without = baseRest(function(array, values) { + return isArrayLikeObject(array) + ? baseDifference(array, values) + : []; + }); + + /** + * Creates an array of unique values that is the + * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) + * of the given arrays. The order of result values is determined by the order + * they occur in the arrays. + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of filtered values. + * @see _.difference, _.without + * @example + * + * _.xor([2, 1], [2, 3]); + * // => [1, 3] + */ + var xor = baseRest(function(arrays) { + return baseXor(arrayFilter(arrays, isArrayLikeObject)); + }); + + /** + * This method is like `_.xor` except that it accepts `iteratee` which is + * invoked for each element of each `arrays` to generate the criterion by + * which by which they're compared. The order of result values is determined + * by the order they occur in the arrays. The iteratee is invoked with one + * argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); + * // => [1.2, 3.4] + * + * // The `_.property` iteratee shorthand. + * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 2 }] + */ + var xorBy = baseRest(function(arrays) { + var iteratee = last(arrays); + if (isArrayLikeObject(iteratee)) { + iteratee = undefined; + } + return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); + }); + + /** + * This method is like `_.xor` except that it accepts `comparator` which is + * invoked to compare elements of `arrays`. The order of result values is + * determined by the order they occur in the arrays. The comparator is invoked + * with two arguments: (arrVal, othVal). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * + * _.xorWith(objects, others, _.isEqual); + * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] + */ + var xorWith = baseRest(function(arrays) { + var comparator = last(arrays); + comparator = typeof comparator == 'function' ? comparator : undefined; + return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); + }); + + /** + * Creates an array of grouped elements, the first of which contains the + * first elements of the given arrays, the second of which contains the + * second elements of the given arrays, and so on. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {...Array} [arrays] The arrays to process. + * @returns {Array} Returns the new array of grouped elements. + * @example + * + * _.zip(['a', 'b'], [1, 2], [true, false]); + * // => [['a', 1, true], ['b', 2, false]] + */ + var zip = baseRest(unzip); + + /** + * This method is like `_.fromPairs` except that it accepts two arrays, + * one of property identifiers and one of corresponding values. + * + * @static + * @memberOf _ + * @since 0.4.0 + * @category Array + * @param {Array} [props=[]] The property identifiers. + * @param {Array} [values=[]] The property values. + * @returns {Object} Returns the new object. + * @example + * + * _.zipObject(['a', 'b'], [1, 2]); + * // => { 'a': 1, 'b': 2 } + */ + function zipObject(props, values) { + return baseZipObject(props || [], values || [], assignValue); + } + + /** + * This method is like `_.zipObject` except that it supports property paths. + * + * @static + * @memberOf _ + * @since 4.1.0 + * @category Array + * @param {Array} [props=[]] The property identifiers. + * @param {Array} [values=[]] The property values. + * @returns {Object} Returns the new object. + * @example + * + * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); + * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } + */ + function zipObjectDeep(props, values) { + return baseZipObject(props || [], values || [], baseSet); + } + + /** + * This method is like `_.zip` except that it accepts `iteratee` to specify + * how grouped values should be combined. The iteratee is invoked with the + * elements of each group: (...group). + * + * @static + * @memberOf _ + * @since 3.8.0 + * @category Array + * @param {...Array} [arrays] The arrays to process. + * @param {Function} [iteratee=_.identity] The function to combine + * grouped values. + * @returns {Array} Returns the new array of grouped elements. + * @example + * + * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { + * return a + b + c; + * }); + * // => [111, 222] + */ + var zipWith = baseRest(function(arrays) { + var length = arrays.length, + iteratee = length > 1 ? arrays[length - 1] : undefined; + + iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; + return unzipWith(arrays, iteratee); + }); + + /*------------------------------------------------------------------------*/ + + /** + * Creates a `lodash` wrapper instance that wraps `value` with explicit method + * chain sequences enabled. The result of such sequences must be unwrapped + * with `_#value`. + * + * @static + * @memberOf _ + * @since 1.3.0 + * @category Seq + * @param {*} value The value to wrap. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 }, + * { 'user': 'pebbles', 'age': 1 } + * ]; + * + * var youngest = _ + * .chain(users) + * .sortBy('age') + * .map(function(o) { + * return o.user + ' is ' + o.age; + * }) + * .head() + * .value(); + * // => 'pebbles is 1' + */ + function chain(value) { + var result = lodash(value); + result.__chain__ = true; + return result; + } + + /** + * This method invokes `interceptor` and returns `value`. The interceptor + * is invoked with one argument; (value). The purpose of this method is to + * "tap into" a method chain sequence in order to modify intermediate results. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Seq + * @param {*} value The value to provide to `interceptor`. + * @param {Function} interceptor The function to invoke. + * @returns {*} Returns `value`. + * @example + * + * _([1, 2, 3]) + * .tap(function(array) { + * // Mutate input array. + * array.pop(); + * }) + * .reverse() + * .value(); + * // => [2, 1] + */ + function tap(value, interceptor) { + interceptor(value); + return value; + } + + /** + * This method is like `_.tap` except that it returns the result of `interceptor`. + * The purpose of this method is to "pass thru" values replacing intermediate + * results in a method chain sequence. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Seq + * @param {*} value The value to provide to `interceptor`. + * @param {Function} interceptor The function to invoke. + * @returns {*} Returns the result of `interceptor`. + * @example + * + * _(' abc ') + * .chain() + * .trim() + * .thru(function(value) { + * return [value]; + * }) + * .value(); + * // => ['abc'] + */ + function thru(value, interceptor) { + return interceptor(value); + } + + /** + * This method is the wrapper version of `_.at`. + * + * @name at + * @memberOf _ + * @since 1.0.0 + * @category Seq + * @param {...(string|string[])} [paths] The property paths to pick. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; + * + * _(object).at(['a[0].b.c', 'a[1]']).value(); + * // => [3, 4] + */ + var wrapperAt = flatRest(function(paths) { + var length = paths.length, + start = length ? paths[0] : 0, + value = this.__wrapped__, + interceptor = function(object) { return baseAt(object, paths); }; + + if (length > 1 || this.__actions__.length || + !(value instanceof LazyWrapper) || !isIndex(start)) { + return this.thru(interceptor); + } + value = value.slice(start, +start + (length ? 1 : 0)); + value.__actions__.push({ + 'func': thru, + 'args': [interceptor], + 'thisArg': undefined + }); + return new LodashWrapper(value, this.__chain__).thru(function(array) { + if (length && !array.length) { + array.push(undefined); + } + return array; + }); + }); + + /** + * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. + * + * @name chain + * @memberOf _ + * @since 0.1.0 + * @category Seq + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 } + * ]; + * + * // A sequence without explicit chaining. + * _(users).head(); + * // => { 'user': 'barney', 'age': 36 } + * + * // A sequence with explicit chaining. + * _(users) + * .chain() + * .head() + * .pick('user') + * .value(); + * // => { 'user': 'barney' } + */ + function wrapperChain() { + return chain(this); + } + + /** + * Executes the chain sequence and returns the wrapped result. + * + * @name commit + * @memberOf _ + * @since 3.2.0 + * @category Seq + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var array = [1, 2]; + * var wrapped = _(array).push(3); + * + * console.log(array); + * // => [1, 2] + * + * wrapped = wrapped.commit(); + * console.log(array); + * // => [1, 2, 3] + * + * wrapped.last(); + * // => 3 + * + * console.log(array); + * // => [1, 2, 3] + */ + function wrapperCommit() { + return new LodashWrapper(this.value(), this.__chain__); + } + + /** + * Gets the next value on a wrapped object following the + * [iterator protocol](https://mdn.io/iteration_protocols#iterator). + * + * @name next + * @memberOf _ + * @since 4.0.0 + * @category Seq + * @returns {Object} Returns the next iterator value. + * @example + * + * var wrapped = _([1, 2]); + * + * wrapped.next(); + * // => { 'done': false, 'value': 1 } + * + * wrapped.next(); + * // => { 'done': false, 'value': 2 } + * + * wrapped.next(); + * // => { 'done': true, 'value': undefined } + */ + function wrapperNext() { + if (this.__values__ === undefined) { + this.__values__ = toArray(this.value()); + } + var done = this.__index__ >= this.__values__.length, + value = done ? undefined : this.__values__[this.__index__++]; + + return { 'done': done, 'value': value }; + } + + /** + * Enables the wrapper to be iterable. + * + * @name Symbol.iterator + * @memberOf _ + * @since 4.0.0 + * @category Seq + * @returns {Object} Returns the wrapper object. + * @example + * + * var wrapped = _([1, 2]); + * + * wrapped[Symbol.iterator]() === wrapped; + * // => true + * + * Array.from(wrapped); + * // => [1, 2] + */ + function wrapperToIterator() { + return this; + } + + /** + * Creates a clone of the chain sequence planting `value` as the wrapped value. + * + * @name plant + * @memberOf _ + * @since 3.2.0 + * @category Seq + * @param {*} value The value to plant. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * function square(n) { + * return n * n; + * } + * + * var wrapped = _([1, 2]).map(square); + * var other = wrapped.plant([3, 4]); + * + * other.value(); + * // => [9, 16] + * + * wrapped.value(); + * // => [1, 4] + */ + function wrapperPlant(value) { + var result, + parent = this; + + while (parent instanceof baseLodash) { + var clone = wrapperClone(parent); + clone.__index__ = 0; + clone.__values__ = undefined; + if (result) { + previous.__wrapped__ = clone; + } else { + result = clone; + } + var previous = clone; + parent = parent.__wrapped__; + } + previous.__wrapped__ = value; + return result; + } + + /** + * This method is the wrapper version of `_.reverse`. + * + * **Note:** This method mutates the wrapped array. + * + * @name reverse + * @memberOf _ + * @since 0.1.0 + * @category Seq + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var array = [1, 2, 3]; + * + * _(array).reverse().value() + * // => [3, 2, 1] + * + * console.log(array); + * // => [3, 2, 1] + */ + function wrapperReverse() { + var value = this.__wrapped__; + if (value instanceof LazyWrapper) { + var wrapped = value; + if (this.__actions__.length) { + wrapped = new LazyWrapper(this); + } + wrapped = wrapped.reverse(); + wrapped.__actions__.push({ + 'func': thru, + 'args': [reverse], + 'thisArg': undefined + }); + return new LodashWrapper(wrapped, this.__chain__); + } + return this.thru(reverse); + } + + /** + * Executes the chain sequence to resolve the unwrapped value. + * + * @name value + * @memberOf _ + * @since 0.1.0 + * @alias toJSON, valueOf + * @category Seq + * @returns {*} Returns the resolved unwrapped value. + * @example + * + * _([1, 2, 3]).value(); + * // => [1, 2, 3] + */ + function wrapperValue() { + return baseWrapperValue(this.__wrapped__, this.__actions__); + } + + /*------------------------------------------------------------------------*/ + + /** + * Creates an object composed of keys generated from the results of running + * each element of `collection` thru `iteratee`. The corresponding value of + * each key is the number of times the key was returned by `iteratee`. The + * iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 0.5.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee to transform keys. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * _.countBy([6.1, 4.2, 6.3], Math.floor); + * // => { '4': 1, '6': 2 } + * + * // The `_.property` iteratee shorthand. + * _.countBy(['one', 'two', 'three'], 'length'); + * // => { '3': 2, '5': 1 } + */ + var countBy = createAggregator(function(result, value, key) { + if (hasOwnProperty.call(result, key)) { + ++result[key]; + } else { + baseAssignValue(result, key, 1); + } + }); + + /** + * Checks if `predicate` returns truthy for **all** elements of `collection`. + * Iteration is stopped once `predicate` returns falsey. The predicate is + * invoked with three arguments: (value, index|key, collection). + * + * **Note:** This method returns `true` for + * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because + * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of + * elements of empty collections. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. + * @example + * + * _.every([true, 1, null, 'yes'], Boolean); + * // => false + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; + * + * // The `_.matches` iteratee shorthand. + * _.every(users, { 'user': 'barney', 'active': false }); + * // => false + * + * // The `_.matchesProperty` iteratee shorthand. + * _.every(users, ['active', false]); + * // => true + * + * // The `_.property` iteratee shorthand. + * _.every(users, 'active'); + * // => false + */ + function every(collection, predicate, guard) { + var func = isArray(collection) ? arrayEvery : baseEvery; + if (guard && isIterateeCall(collection, predicate, guard)) { + predicate = undefined; + } + return func(collection, getIteratee(predicate, 3)); + } + + /** + * Iterates over elements of `collection`, returning an array of all elements + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). + * + * **Note:** Unlike `_.remove`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + * @see _.reject + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; + * + * _.filter(users, function(o) { return !o.active; }); + * // => objects for ['fred'] + * + * // The `_.matches` iteratee shorthand. + * _.filter(users, { 'age': 36, 'active': true }); + * // => objects for ['barney'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.filter(users, ['active', false]); + * // => objects for ['fred'] + * + * // The `_.property` iteratee shorthand. + * _.filter(users, 'active'); + * // => objects for ['barney'] + */ + function filter(collection, predicate) { + var func = isArray(collection) ? arrayFilter : baseFilter; + return func(collection, getIteratee(predicate, 3)); + } + + /** + * Iterates over elements of `collection`, returning the first element + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=0] The index to search from. + * @returns {*} Returns the matched element, else `undefined`. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false }, + * { 'user': 'pebbles', 'age': 1, 'active': true } + * ]; + * + * _.find(users, function(o) { return o.age < 40; }); + * // => object for 'barney' + * + * // The `_.matches` iteratee shorthand. + * _.find(users, { 'age': 1, 'active': true }); + * // => object for 'pebbles' + * + * // The `_.matchesProperty` iteratee shorthand. + * _.find(users, ['active', false]); + * // => object for 'fred' + * + * // The `_.property` iteratee shorthand. + * _.find(users, 'active'); + * // => object for 'barney' + */ + var find = createFind(findIndex); + + /** + * This method is like `_.find` except that it iterates over elements of + * `collection` from right to left. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Collection + * @param {Array|Object} collection The collection to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=collection.length-1] The index to search from. + * @returns {*} Returns the matched element, else `undefined`. + * @example + * + * _.findLast([1, 2, 3, 4], function(n) { + * return n % 2 == 1; + * }); + * // => 3 + */ + var findLast = createFind(findLastIndex); + + /** + * Creates a flattened array of values by running each element in `collection` + * thru `iteratee` and flattening the mapped results. The iteratee is invoked + * with three arguments: (value, index|key, collection). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new flattened array. + * @example + * + * function duplicate(n) { + * return [n, n]; + * } + * + * _.flatMap([1, 2], duplicate); + * // => [1, 1, 2, 2] + */ + function flatMap(collection, iteratee) { + return baseFlatten(map(collection, iteratee), 1); + } + + /** + * This method is like `_.flatMap` except that it recursively flattens the + * mapped results. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new flattened array. + * @example + * + * function duplicate(n) { + * return [[[n, n]]]; + * } + * + * _.flatMapDeep([1, 2], duplicate); + * // => [1, 1, 2, 2] + */ + function flatMapDeep(collection, iteratee) { + return baseFlatten(map(collection, iteratee), INFINITY); + } + + /** + * This method is like `_.flatMap` except that it recursively flattens the + * mapped results up to `depth` times. + * + * @static + * @memberOf _ + * @since 4.7.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {number} [depth=1] The maximum recursion depth. + * @returns {Array} Returns the new flattened array. + * @example + * + * function duplicate(n) { + * return [[[n, n]]]; + * } + * + * _.flatMapDepth([1, 2], duplicate, 2); + * // => [[1, 1], [2, 2]] + */ + function flatMapDepth(collection, iteratee, depth) { + depth = depth === undefined ? 1 : toInteger(depth); + return baseFlatten(map(collection, iteratee), depth); + } + + /** + * Iterates over elements of `collection` and invokes `iteratee` for each element. + * The iteratee is invoked with three arguments: (value, index|key, collection). + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * **Note:** As with other "Collections" methods, objects with a "length" + * property are iterated like arrays. To avoid this behavior use `_.forIn` + * or `_.forOwn` for object iteration. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @alias each + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + * @see _.forEachRight + * @example + * + * _.forEach([1, 2], function(value) { + * console.log(value); + * }); + * // => Logs `1` then `2`. + * + * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). + */ + function forEach(collection, iteratee) { + var func = isArray(collection) ? arrayEach : baseEach; + return func(collection, getIteratee(iteratee, 3)); + } + + /** + * This method is like `_.forEach` except that it iterates over elements of + * `collection` from right to left. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @alias eachRight + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + * @see _.forEach + * @example + * + * _.forEachRight([1, 2], function(value) { + * console.log(value); + * }); + * // => Logs `2` then `1`. + */ + function forEachRight(collection, iteratee) { + var func = isArray(collection) ? arrayEachRight : baseEachRight; + return func(collection, getIteratee(iteratee, 3)); + } + + /** + * Creates an object composed of keys generated from the results of running + * each element of `collection` thru `iteratee`. The order of grouped values + * is determined by the order they occur in `collection`. The corresponding + * value of each key is an array of elements responsible for generating the + * key. The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee to transform keys. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * _.groupBy([6.1, 4.2, 6.3], Math.floor); + * // => { '4': [4.2], '6': [6.1, 6.3] } + * + * // The `_.property` iteratee shorthand. + * _.groupBy(['one', 'two', 'three'], 'length'); + * // => { '3': ['one', 'two'], '5': ['three'] } + */ + var groupBy = createAggregator(function(result, value, key) { + if (hasOwnProperty.call(result, key)) { + result[key].push(value); + } else { + baseAssignValue(result, key, [value]); + } + }); + + /** + * Checks if `value` is in `collection`. If `collection` is a string, it's + * checked for a substring of `value`, otherwise + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * is used for equality comparisons. If `fromIndex` is negative, it's used as + * the offset from the end of `collection`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object|string} collection The collection to inspect. + * @param {*} value The value to search for. + * @param {number} [fromIndex=0] The index to search from. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. + * @returns {boolean} Returns `true` if `value` is found, else `false`. + * @example + * + * _.includes([1, 2, 3], 1); + * // => true + * + * _.includes([1, 2, 3], 1, 2); + * // => false + * + * _.includes({ 'a': 1, 'b': 2 }, 1); + * // => true + * + * _.includes('abcd', 'bc'); + * // => true + */ + function includes(collection, value, fromIndex, guard) { + collection = isArrayLike(collection) ? collection : values(collection); + fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; + + var length = collection.length; + if (fromIndex < 0) { + fromIndex = nativeMax(length + fromIndex, 0); + } + return isString(collection) + ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) + : (!!length && baseIndexOf(collection, value, fromIndex) > -1); + } + + /** + * Invokes the method at `path` of each element in `collection`, returning + * an array of the results of each invoked method. Any additional arguments + * are provided to each invoked method. If `path` is a function, it's invoked + * for, and `this` bound to, each element in `collection`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Array|Function|string} path The path of the method to invoke or + * the function invoked per iteration. + * @param {...*} [args] The arguments to invoke each method with. + * @returns {Array} Returns the array of results. + * @example + * + * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); + * // => [[1, 5, 7], [1, 2, 3]] + * + * _.invokeMap([123, 456], String.prototype.split, ''); + * // => [['1', '2', '3'], ['4', '5', '6']] + */ + var invokeMap = baseRest(function(collection, path, args) { + var index = -1, + isFunc = typeof path == 'function', + result = isArrayLike(collection) ? Array(collection.length) : []; + + baseEach(collection, function(value) { + result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); + }); + return result; + }); + + /** + * Creates an object composed of keys generated from the results of running + * each element of `collection` thru `iteratee`. The corresponding value of + * each key is the last element responsible for generating the key. The + * iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee to transform keys. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * var array = [ + * { 'dir': 'left', 'code': 97 }, + * { 'dir': 'right', 'code': 100 } + * ]; + * + * _.keyBy(array, function(o) { + * return String.fromCharCode(o.code); + * }); + * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } + * + * _.keyBy(array, 'dir'); + * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } + */ + var keyBy = createAggregator(function(result, value, key) { + baseAssignValue(result, key, value); + }); + + /** + * Creates an array of values by running each element in `collection` thru + * `iteratee`. The iteratee is invoked with three arguments: + * (value, index|key, collection). + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. + * + * The guarded methods are: + * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, + * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, + * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, + * `template`, `trim`, `trimEnd`, `trimStart`, and `words` + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + * @example + * + * function square(n) { + * return n * n; + * } + * + * _.map([4, 8], square); + * // => [16, 64] + * + * _.map({ 'a': 4, 'b': 8 }, square); + * // => [16, 64] (iteration order is not guaranteed) + * + * var users = [ + * { 'user': 'barney' }, + * { 'user': 'fred' } + * ]; + * + * // The `_.property` iteratee shorthand. + * _.map(users, 'user'); + * // => ['barney', 'fred'] + */ + function map(collection, iteratee) { + var func = isArray(collection) ? arrayMap : baseMap; + return func(collection, getIteratee(iteratee, 3)); + } + + /** + * This method is like `_.sortBy` except that it allows specifying the sort + * orders of the iteratees to sort by. If `orders` is unspecified, all values + * are sorted in ascending order. Otherwise, specify an order of "desc" for + * descending or "asc" for ascending sort order of corresponding values. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] + * The iteratees to sort by. + * @param {string[]} [orders] The sort orders of `iteratees`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'fred', 'age': 48 }, + * { 'user': 'barney', 'age': 34 }, + * { 'user': 'fred', 'age': 40 }, + * { 'user': 'barney', 'age': 36 } + * ]; + * + * // Sort by `user` in ascending order and by `age` in descending order. + * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] + */ + function orderBy(collection, iteratees, orders, guard) { + if (collection == null) { + return []; + } + if (!isArray(iteratees)) { + iteratees = iteratees == null ? [] : [iteratees]; + } + orders = guard ? undefined : orders; + if (!isArray(orders)) { + orders = orders == null ? [] : [orders]; + } + return baseOrderBy(collection, iteratees, orders); + } + + /** + * Creates an array of elements split into two groups, the first of which + * contains elements `predicate` returns truthy for, the second of which + * contains elements `predicate` returns falsey for. The predicate is + * invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the array of grouped elements. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': true }, + * { 'user': 'pebbles', 'age': 1, 'active': false } + * ]; + * + * _.partition(users, function(o) { return o.active; }); + * // => objects for [['fred'], ['barney', 'pebbles']] + * + * // The `_.matches` iteratee shorthand. + * _.partition(users, { 'age': 1, 'active': false }); + * // => objects for [['pebbles'], ['barney', 'fred']] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.partition(users, ['active', false]); + * // => objects for [['barney', 'pebbles'], ['fred']] + * + * // The `_.property` iteratee shorthand. + * _.partition(users, 'active'); + * // => objects for [['fred'], ['barney', 'pebbles']] + */ + var partition = createAggregator(function(result, value, key) { + result[key ? 0 : 1].push(value); + }, function() { return [[], []]; }); + + /** + * Reduces `collection` to a value which is the accumulated result of running + * each element in `collection` thru `iteratee`, where each successive + * invocation is supplied the return value of the previous. If `accumulator` + * is not given, the first element of `collection` is used as the initial + * value. The iteratee is invoked with four arguments: + * (accumulator, value, index|key, collection). + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.reduce`, `_.reduceRight`, and `_.transform`. + * + * The guarded methods are: + * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, + * and `sortBy` + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @returns {*} Returns the accumulated value. + * @see _.reduceRight + * @example + * + * _.reduce([1, 2], function(sum, n) { + * return sum + n; + * }, 0); + * // => 3 + * + * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { + * (result[value] || (result[value] = [])).push(key); + * return result; + * }, {}); + * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) + */ + function reduce(collection, iteratee, accumulator) { + var func = isArray(collection) ? arrayReduce : baseReduce, + initAccum = arguments.length < 3; + + return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); + } + + /** + * This method is like `_.reduce` except that it iterates over elements of + * `collection` from right to left. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @returns {*} Returns the accumulated value. + * @see _.reduce + * @example + * + * var array = [[0, 1], [2, 3], [4, 5]]; + * + * _.reduceRight(array, function(flattened, other) { + * return flattened.concat(other); + * }, []); + * // => [4, 5, 2, 3, 0, 1] + */ + function reduceRight(collection, iteratee, accumulator) { + var func = isArray(collection) ? arrayReduceRight : baseReduce, + initAccum = arguments.length < 3; + + return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); + } + + /** + * The opposite of `_.filter`; this method returns the elements of `collection` + * that `predicate` does **not** return truthy for. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + * @see _.filter + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': true } + * ]; + * + * _.reject(users, function(o) { return !o.active; }); + * // => objects for ['fred'] + * + * // The `_.matches` iteratee shorthand. + * _.reject(users, { 'age': 40, 'active': true }); + * // => objects for ['barney'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.reject(users, ['active', false]); + * // => objects for ['fred'] + * + * // The `_.property` iteratee shorthand. + * _.reject(users, 'active'); + * // => objects for ['barney'] + */ + function reject(collection, predicate) { + var func = isArray(collection) ? arrayFilter : baseFilter; + return func(collection, negate(getIteratee(predicate, 3))); + } + + /** + * Gets a random element from `collection`. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Collection + * @param {Array|Object} collection The collection to sample. + * @returns {*} Returns the random element. + * @example + * + * _.sample([1, 2, 3, 4]); + * // => 2 + */ + function sample(collection) { + var func = isArray(collection) ? arraySample : baseSample; + return func(collection); + } + + /** + * Gets `n` random elements at unique keys from `collection` up to the + * size of `collection`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Collection + * @param {Array|Object} collection The collection to sample. + * @param {number} [n=1] The number of elements to sample. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the random elements. + * @example + * + * _.sampleSize([1, 2, 3], 2); + * // => [3, 1] + * + * _.sampleSize([1, 2, 3], 4); + * // => [2, 3, 1] + */ + function sampleSize(collection, n, guard) { + if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { + n = 1; + } else { + n = toInteger(n); + } + var func = isArray(collection) ? arraySampleSize : baseSampleSize; + return func(collection, n); + } + + /** + * Creates an array of shuffled values, using a version of the + * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to shuffle. + * @returns {Array} Returns the new shuffled array. + * @example + * + * _.shuffle([1, 2, 3, 4]); + * // => [4, 1, 3, 2] + */ + function shuffle(collection) { + var func = isArray(collection) ? arrayShuffle : baseShuffle; + return func(collection); + } + + /** + * Gets the size of `collection` by returning its length for array-like + * values or the number of own enumerable string keyed properties for objects. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object|string} collection The collection to inspect. + * @returns {number} Returns the collection size. + * @example + * + * _.size([1, 2, 3]); + * // => 3 + * + * _.size({ 'a': 1, 'b': 2 }); + * // => 2 + * + * _.size('pebbles'); + * // => 7 + */ + function size(collection) { + if (collection == null) { + return 0; + } + if (isArrayLike(collection)) { + return isString(collection) ? stringSize(collection) : collection.length; + } + var tag = getTag(collection); + if (tag == mapTag || tag == setTag) { + return collection.size; + } + return baseKeys(collection).length; + } + + /** + * Checks if `predicate` returns truthy for **any** element of `collection`. + * Iteration is stopped once `predicate` returns truthy. The predicate is + * invoked with three arguments: (value, index|key, collection). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + * @example + * + * _.some([null, 0, 'yes', false], Boolean); + * // => true + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false } + * ]; + * + * // The `_.matches` iteratee shorthand. + * _.some(users, { 'user': 'barney', 'active': false }); + * // => false + * + * // The `_.matchesProperty` iteratee shorthand. + * _.some(users, ['active', false]); + * // => true + * + * // The `_.property` iteratee shorthand. + * _.some(users, 'active'); + * // => true + */ + function some(collection, predicate, guard) { + var func = isArray(collection) ? arraySome : baseSome; + if (guard && isIterateeCall(collection, predicate, guard)) { + predicate = undefined; + } + return func(collection, getIteratee(predicate, 3)); + } + + /** + * Creates an array of elements, sorted in ascending order by the results of + * running each element in a collection thru each iteratee. This method + * performs a stable sort, that is, it preserves the original sort order of + * equal elements. The iteratees are invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {...(Function|Function[])} [iteratees=[_.identity]] + * The iteratees to sort by. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'fred', 'age': 48 }, + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 }, + * { 'user': 'barney', 'age': 34 } + * ]; + * + * _.sortBy(users, [function(o) { return o.user; }]); + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] + * + * _.sortBy(users, ['user', 'age']); + * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] + */ + var sortBy = baseRest(function(collection, iteratees) { + if (collection == null) { + return []; + } + var length = iteratees.length; + if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { + iteratees = []; + } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { + iteratees = [iteratees[0]]; + } + return baseOrderBy(collection, baseFlatten(iteratees, 1), []); + }); + + /*------------------------------------------------------------------------*/ + + /** + * Gets the timestamp of the number of milliseconds that have elapsed since + * the Unix epoch (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Date + * @returns {number} Returns the timestamp. + * @example + * + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); + * // => Logs the number of milliseconds it took for the deferred invocation. + */ + var now = ctxNow || function() { + return root.Date.now(); + }; + + /*------------------------------------------------------------------------*/ + + /** + * The opposite of `_.before`; this method creates a function that invokes + * `func` once it's called `n` or more times. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {number} n The number of calls before `func` is invoked. + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * var saves = ['profile', 'settings']; + * + * var done = _.after(saves.length, function() { + * console.log('done saving!'); + * }); + * + * _.forEach(saves, function(type) { + * asyncSave({ 'type': type, 'complete': done }); + * }); + * // => Logs 'done saving!' after the two async saves have completed. + */ + function after(n, func) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + n = toInteger(n); + return function() { + if (--n < 1) { + return func.apply(this, arguments); + } + }; + } + + /** + * Creates a function that invokes `func`, with up to `n` arguments, + * ignoring any additional arguments. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {Function} func The function to cap arguments for. + * @param {number} [n=func.length] The arity cap. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Function} Returns the new capped function. + * @example + * + * _.map(['6', '8', '10'], _.ary(parseInt, 1)); + * // => [6, 8, 10] + */ + function ary(func, n, guard) { + n = guard ? undefined : n; + n = (func && n == null) ? func.length : n; + return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); + } + + /** + * Creates a function that invokes `func`, with the `this` binding and arguments + * of the created function, while it's called less than `n` times. Subsequent + * calls to the created function return the result of the last `func` invocation. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {number} n The number of calls at which `func` is no longer invoked. + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * jQuery(element).on('click', _.before(5, addContactToList)); + * // => Allows adding up to 4 contacts to the list. + */ + function before(n, func) { + var result; + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + n = toInteger(n); + return function() { + if (--n > 0) { + result = func.apply(this, arguments); + } + if (n <= 1) { + func = undefined; + } + return result; + }; + } + + /** + * Creates a function that invokes `func` with the `this` binding of `thisArg` + * and `partials` prepended to the arguments it receives. + * + * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, + * may be used as a placeholder for partially applied arguments. + * + * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" + * property of bound functions. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to bind. + * @param {*} thisArg The `this` binding of `func`. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new bound function. + * @example + * + * function greet(greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * } + * + * var object = { 'user': 'fred' }; + * + * var bound = _.bind(greet, object, 'hi'); + * bound('!'); + * // => 'hi fred!' + * + * // Bound with placeholders. + * var bound = _.bind(greet, object, _, '!'); + * bound('hi'); + * // => 'hi fred!' + */ + var bind = baseRest(function(func, thisArg, partials) { + var bitmask = WRAP_BIND_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, getHolder(bind)); + bitmask |= WRAP_PARTIAL_FLAG; + } + return createWrap(func, bitmask, thisArg, partials, holders); + }); + + /** + * Creates a function that invokes the method at `object[key]` with `partials` + * prepended to the arguments it receives. + * + * This method differs from `_.bind` by allowing bound functions to reference + * methods that may be redefined or don't yet exist. See + * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) + * for more details. + * + * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. + * + * @static + * @memberOf _ + * @since 0.10.0 + * @category Function + * @param {Object} object The object to invoke the method on. + * @param {string} key The key of the method. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new bound function. + * @example + * + * var object = { + * 'user': 'fred', + * 'greet': function(greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * } + * }; + * + * var bound = _.bindKey(object, 'greet', 'hi'); + * bound('!'); + * // => 'hi fred!' + * + * object.greet = function(greeting, punctuation) { + * return greeting + 'ya ' + this.user + punctuation; + * }; + * + * bound('!'); + * // => 'hiya fred!' + * + * // Bound with placeholders. + * var bound = _.bindKey(object, 'greet', _, '!'); + * bound('hi'); + * // => 'hiya fred!' + */ + var bindKey = baseRest(function(object, key, partials) { + var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, getHolder(bindKey)); + bitmask |= WRAP_PARTIAL_FLAG; + } + return createWrap(key, bitmask, object, partials, holders); + }); + + /** + * Creates a function that accepts arguments of `func` and either invokes + * `func` returning its result, if at least `arity` number of arguments have + * been provided, or returns a function that accepts the remaining `func` + * arguments, and so on. The arity of `func` may be specified if `func.length` + * is not sufficient. + * + * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, + * may be used as a placeholder for provided arguments. + * + * **Note:** This method doesn't set the "length" property of curried functions. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Function + * @param {Function} func The function to curry. + * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Function} Returns the new curried function. + * @example + * + * var abc = function(a, b, c) { + * return [a, b, c]; + * }; + * + * var curried = _.curry(abc); + * + * curried(1)(2)(3); + * // => [1, 2, 3] + * + * curried(1, 2)(3); + * // => [1, 2, 3] + * + * curried(1, 2, 3); + * // => [1, 2, 3] + * + * // Curried with placeholders. + * curried(1)(_, 3)(2); + * // => [1, 2, 3] + */ + function curry(func, arity, guard) { + arity = guard ? undefined : arity; + var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); + result.placeholder = curry.placeholder; + return result; + } + + /** + * This method is like `_.curry` except that arguments are applied to `func` + * in the manner of `_.partialRight` instead of `_.partial`. + * + * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for provided arguments. + * + * **Note:** This method doesn't set the "length" property of curried functions. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {Function} func The function to curry. + * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Function} Returns the new curried function. + * @example + * + * var abc = function(a, b, c) { + * return [a, b, c]; + * }; + * + * var curried = _.curryRight(abc); + * + * curried(3)(2)(1); + * // => [1, 2, 3] + * + * curried(2, 3)(1); + * // => [1, 2, 3] + * + * curried(1, 2, 3); + * // => [1, 2, 3] + * + * // Curried with placeholders. + * curried(3)(1, _)(2); + * // => [1, 2, 3] + */ + function curryRight(func, arity, guard) { + arity = guard ? undefined : arity; + var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); + result.placeholder = curryRight.placeholder; + return result; + } + + /** + * Creates a debounced function that delays invoking `func` until after `wait` + * milliseconds have elapsed since the last time the debounced function was + * invoked. The debounced function comes with a `cancel` method to cancel + * delayed `func` invocations and a `flush` method to immediately invoke them. + * Provide `options` to indicate whether `func` should be invoked on the + * leading and/or trailing edge of the `wait` timeout. The `func` is invoked + * with the last arguments provided to the debounced function. Subsequent + * calls to the debounced function return the result of the last `func` + * invocation. + * + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the debounced function + * is invoked more than once during the `wait` timeout. + * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. + * + * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) + * for details over the differences between `_.debounce` and `_.throttle`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to debounce. + * @param {number} [wait=0] The number of milliseconds to delay. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=false] + * Specify invoking on the leading edge of the timeout. + * @param {number} [options.maxWait] + * The maximum time `func` is allowed to be delayed before it's invoked. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. + * @returns {Function} Returns the new debounced function. + * @example + * + * // Avoid costly calculations while the window size is in flux. + * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); + * + * // Invoke `sendMail` when clicked, debouncing subsequent calls. + * jQuery(element).on('click', _.debounce(sendMail, 300, { + * 'leading': true, + * 'trailing': false + * })); + * + * // Ensure `batchLog` is invoked once after 1 second of debounced calls. + * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); + * var source = new EventSource('/stream'); + * jQuery(source).on('message', debounced); + * + * // Cancel the trailing debounced invocation. + * jQuery(window).on('popstate', debounced.cancel); + */ + function debounce(func, wait, options) { + var lastArgs, + lastThis, + maxWait, + result, + timerId, + lastCallTime, + lastInvokeTime = 0, + leading = false, + maxing = false, + trailing = true; + + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + wait = toNumber(wait) || 0; + if (isObject(options)) { + leading = !!options.leading; + maxing = 'maxWait' in options; + maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; + trailing = 'trailing' in options ? !!options.trailing : trailing; + } + + function invokeFunc(time) { + var args = lastArgs, + thisArg = lastThis; + + lastArgs = lastThis = undefined; + lastInvokeTime = time; + result = func.apply(thisArg, args); + return result; + } + + function leadingEdge(time) { + // Reset any `maxWait` timer. + lastInvokeTime = time; + // Start the timer for the trailing edge. + timerId = setTimeout(timerExpired, wait); + // Invoke the leading edge. + return leading ? invokeFunc(time) : result; + } + + function remainingWait(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime, + timeWaiting = wait - timeSinceLastCall; + + return maxing + ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) + : timeWaiting; + } + + function shouldInvoke(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime; + + // Either this is the first call, activity has stopped and we're at the + // trailing edge, the system time has gone backwards and we're treating + // it as the trailing edge, or we've hit the `maxWait` limit. + return (lastCallTime === undefined || (timeSinceLastCall >= wait) || + (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); + } + + function timerExpired() { + var time = now(); + if (shouldInvoke(time)) { + return trailingEdge(time); + } + // Restart the timer. + timerId = setTimeout(timerExpired, remainingWait(time)); + } + + function trailingEdge(time) { + timerId = undefined; + + // Only invoke if we have `lastArgs` which means `func` has been + // debounced at least once. + if (trailing && lastArgs) { + return invokeFunc(time); + } + lastArgs = lastThis = undefined; + return result; + } + + function cancel() { + if (timerId !== undefined) { + clearTimeout(timerId); + } + lastInvokeTime = 0; + lastArgs = lastCallTime = lastThis = timerId = undefined; + } + + function flush() { + return timerId === undefined ? result : trailingEdge(now()); + } + + function debounced() { + var time = now(), + isInvoking = shouldInvoke(time); + + lastArgs = arguments; + lastThis = this; + lastCallTime = time; + + if (isInvoking) { + if (timerId === undefined) { + return leadingEdge(lastCallTime); + } + if (maxing) { + // Handle invocations in a tight loop. + clearTimeout(timerId); + timerId = setTimeout(timerExpired, wait); + return invokeFunc(lastCallTime); + } + } + if (timerId === undefined) { + timerId = setTimeout(timerExpired, wait); + } + return result; + } + debounced.cancel = cancel; + debounced.flush = flush; + return debounced; + } + + /** + * Defers invoking the `func` until the current call stack has cleared. Any + * additional arguments are provided to `func` when it's invoked. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to defer. + * @param {...*} [args] The arguments to invoke `func` with. + * @returns {number} Returns the timer id. + * @example + * + * _.defer(function(text) { + * console.log(text); + * }, 'deferred'); + * // => Logs 'deferred' after one millisecond. + */ + var defer = baseRest(function(func, args) { + return baseDelay(func, 1, args); + }); + + /** + * Invokes `func` after `wait` milliseconds. Any additional arguments are + * provided to `func` when it's invoked. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @param {...*} [args] The arguments to invoke `func` with. + * @returns {number} Returns the timer id. + * @example + * + * _.delay(function(text) { + * console.log(text); + * }, 1000, 'later'); + * // => Logs 'later' after one second. + */ + var delay = baseRest(function(func, wait, args) { + return baseDelay(func, toNumber(wait) || 0, args); + }); + + /** + * Creates a function that invokes `func` with arguments reversed. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Function + * @param {Function} func The function to flip arguments for. + * @returns {Function} Returns the new flipped function. + * @example + * + * var flipped = _.flip(function() { + * return _.toArray(arguments); + * }); + * + * flipped('a', 'b', 'c', 'd'); + * // => ['d', 'c', 'b', 'a'] + */ + function flip(func) { + return createWrap(func, WRAP_FLIP_FLAG); + } + + /** + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided, it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the map cache key. The `func` + * is invoked with the `this` binding of the memoized function. + * + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) + * method interface of `clear`, `delete`, `get`, `has`, and `set`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoized function. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * var other = { 'c': 3, 'd': 4 }; + * + * var values = _.memoize(_.values); + * values(object); + * // => [1, 2] + * + * values(other); + * // => [3, 4] + * + * object.a = 2; + * values(object); + * // => [1, 2] + * + * // Modify the result cache. + * values.cache.set(object, ['a', 'b']); + * values(object); + * // => ['a', 'b'] + * + * // Replace `_.memoize.Cache`. + * _.memoize.Cache = WeakMap; + */ + function memoize(func, resolver) { + if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; + + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result) || cache; + return result; + }; + memoized.cache = new (memoize.Cache || MapCache); + return memoized; + } + + // Expose `MapCache`. + memoize.Cache = MapCache; + + /** + * Creates a function that negates the result of the predicate `func`. The + * `func` predicate is invoked with the `this` binding and arguments of the + * created function. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {Function} predicate The predicate to negate. + * @returns {Function} Returns the new negated function. + * @example + * + * function isEven(n) { + * return n % 2 == 0; + * } + * + * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); + * // => [1, 3, 5] + */ + function negate(predicate) { + if (typeof predicate != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + return function() { + var args = arguments; + switch (args.length) { + case 0: return !predicate.call(this); + case 1: return !predicate.call(this, args[0]); + case 2: return !predicate.call(this, args[0], args[1]); + case 3: return !predicate.call(this, args[0], args[1], args[2]); + } + return !predicate.apply(this, args); + }; + } + + /** + * Creates a function that is restricted to invoking `func` once. Repeat calls + * to the function return the value of the first invocation. The `func` is + * invoked with the `this` binding and arguments of the created function. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * var initialize = _.once(createApplication); + * initialize(); + * initialize(); + * // => `createApplication` is invoked once + */ + function once(func) { + return before(2, func); + } + + /** + * Creates a function that invokes `func` with its arguments transformed. + * + * @static + * @since 4.0.0 + * @memberOf _ + * @category Function + * @param {Function} func The function to wrap. + * @param {...(Function|Function[])} [transforms=[_.identity]] + * The argument transforms. + * @returns {Function} Returns the new function. + * @example + * + * function doubled(n) { + * return n * 2; + * } + * + * function square(n) { + * return n * n; + * } + * + * var func = _.overArgs(function(x, y) { + * return [x, y]; + * }, [square, doubled]); + * + * func(9, 3); + * // => [81, 6] + * + * func(10, 5); + * // => [100, 10] + */ + var overArgs = castRest(function(func, transforms) { + transforms = (transforms.length == 1 && isArray(transforms[0])) + ? arrayMap(transforms[0], baseUnary(getIteratee())) + : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); + + var funcsLength = transforms.length; + return baseRest(function(args) { + var index = -1, + length = nativeMin(args.length, funcsLength); + + while (++index < length) { + args[index] = transforms[index].call(this, args[index]); + } + return apply(func, this, args); + }); + }); + + /** + * Creates a function that invokes `func` with `partials` prepended to the + * arguments it receives. This method is like `_.bind` except it does **not** + * alter the `this` binding. + * + * The `_.partial.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. + * + * **Note:** This method doesn't set the "length" property of partially + * applied functions. + * + * @static + * @memberOf _ + * @since 0.2.0 + * @category Function + * @param {Function} func The function to partially apply arguments to. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new partially applied function. + * @example + * + * function greet(greeting, name) { + * return greeting + ' ' + name; + * } + * + * var sayHelloTo = _.partial(greet, 'hello'); + * sayHelloTo('fred'); + * // => 'hello fred' + * + * // Partially applied with placeholders. + * var greetFred = _.partial(greet, _, 'fred'); + * greetFred('hi'); + * // => 'hi fred' + */ + var partial = baseRest(function(func, partials) { + var holders = replaceHolders(partials, getHolder(partial)); + return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); + }); + + /** + * This method is like `_.partial` except that partially applied arguments + * are appended to the arguments it receives. + * + * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. + * + * **Note:** This method doesn't set the "length" property of partially + * applied functions. + * + * @static + * @memberOf _ + * @since 1.0.0 + * @category Function + * @param {Function} func The function to partially apply arguments to. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new partially applied function. + * @example + * + * function greet(greeting, name) { + * return greeting + ' ' + name; + * } + * + * var greetFred = _.partialRight(greet, 'fred'); + * greetFred('hi'); + * // => 'hi fred' + * + * // Partially applied with placeholders. + * var sayHelloTo = _.partialRight(greet, 'hello', _); + * sayHelloTo('fred'); + * // => 'hello fred' + */ + var partialRight = baseRest(function(func, partials) { + var holders = replaceHolders(partials, getHolder(partialRight)); + return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); + }); + + /** + * Creates a function that invokes `func` with arguments arranged according + * to the specified `indexes` where the argument value at the first index is + * provided as the first argument, the argument value at the second index is + * provided as the second argument, and so on. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {Function} func The function to rearrange arguments for. + * @param {...(number|number[])} indexes The arranged argument indexes. + * @returns {Function} Returns the new function. + * @example + * + * var rearged = _.rearg(function(a, b, c) { + * return [a, b, c]; + * }, [2, 0, 1]); + * + * rearged('b', 'c', 'a') + * // => ['a', 'b', 'c'] + */ + var rearg = flatRest(function(func, indexes) { + return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); + }); + + /** + * Creates a function that invokes `func` with the `this` binding of the + * created function and arguments from `start` and beyond provided as + * an array. + * + * **Note:** This method is based on the + * [rest parameter](https://mdn.io/rest_parameters). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Function + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. + * @example + * + * var say = _.rest(function(what, names) { + * return what + ' ' + _.initial(names).join(', ') + + * (_.size(names) > 1 ? ', & ' : '') + _.last(names); + * }); + * + * say('hello', 'fred', 'barney', 'pebbles'); + * // => 'hello fred, barney, & pebbles' + */ + function rest(func, start) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + start = start === undefined ? start : toInteger(start); + return baseRest(func, start); + } + + /** + * Creates a function that invokes `func` with the `this` binding of the + * create function and an array of arguments much like + * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). + * + * **Note:** This method is based on the + * [spread operator](https://mdn.io/spread_operator). + * + * @static + * @memberOf _ + * @since 3.2.0 + * @category Function + * @param {Function} func The function to spread arguments over. + * @param {number} [start=0] The start position of the spread. + * @returns {Function} Returns the new function. + * @example + * + * var say = _.spread(function(who, what) { + * return who + ' says ' + what; + * }); + * + * say(['fred', 'hello']); + * // => 'fred says hello' + * + * var numbers = Promise.all([ + * Promise.resolve(40), + * Promise.resolve(36) + * ]); + * + * numbers.then(_.spread(function(x, y) { + * return x + y; + * })); + * // => a Promise of 76 + */ + function spread(func, start) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + start = start == null ? 0 : nativeMax(toInteger(start), 0); + return baseRest(function(args) { + var array = args[start], + otherArgs = castSlice(args, 0, start); + + if (array) { + arrayPush(otherArgs, array); + } + return apply(func, this, otherArgs); + }); + } + + /** + * Creates a throttled function that only invokes `func` at most once per + * every `wait` milliseconds. The throttled function comes with a `cancel` + * method to cancel delayed `func` invocations and a `flush` method to + * immediately invoke them. Provide `options` to indicate whether `func` + * should be invoked on the leading and/or trailing edge of the `wait` + * timeout. The `func` is invoked with the last arguments provided to the + * throttled function. Subsequent calls to the throttled function return the + * result of the last `func` invocation. + * + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the throttled function + * is invoked more than once during the `wait` timeout. + * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. + * + * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) + * for details over the differences between `_.throttle` and `_.debounce`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to throttle. + * @param {number} [wait=0] The number of milliseconds to throttle invocations to. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=true] + * Specify invoking on the leading edge of the timeout. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. + * @returns {Function} Returns the new throttled function. + * @example + * + * // Avoid excessively updating the position while scrolling. + * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); + * + * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. + * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); + * jQuery(element).on('click', throttled); + * + * // Cancel the trailing throttled invocation. + * jQuery(window).on('popstate', throttled.cancel); + */ + function throttle(func, wait, options) { + var leading = true, + trailing = true; + + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + if (isObject(options)) { + leading = 'leading' in options ? !!options.leading : leading; + trailing = 'trailing' in options ? !!options.trailing : trailing; + } + return debounce(func, wait, { + 'leading': leading, + 'maxWait': wait, + 'trailing': trailing + }); + } + + /** + * Creates a function that accepts up to one argument, ignoring any + * additional arguments. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Function + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. + * @example + * + * _.map(['6', '8', '10'], _.unary(parseInt)); + * // => [6, 8, 10] + */ + function unary(func) { + return ary(func, 1); + } + + /** + * Creates a function that provides `value` to `wrapper` as its first + * argument. Any additional arguments provided to the function are appended + * to those provided to the `wrapper`. The wrapper is invoked with the `this` + * binding of the created function. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {*} value The value to wrap. + * @param {Function} [wrapper=identity] The wrapper function. + * @returns {Function} Returns the new function. + * @example + * + * var p = _.wrap(_.escape, function(func, text) { + * return '

' + func(text) + '

'; + * }); + * + * p('fred, barney, & pebbles'); + * // => '

fred, barney, & pebbles

' + */ + function wrap(value, wrapper) { + return partial(castFunction(wrapper), value); + } + + /*------------------------------------------------------------------------*/ + + /** + * Casts `value` as an array if it's not one. + * + * @static + * @memberOf _ + * @since 4.4.0 + * @category Lang + * @param {*} value The value to inspect. + * @returns {Array} Returns the cast array. + * @example + * + * _.castArray(1); + * // => [1] + * + * _.castArray({ 'a': 1 }); + * // => [{ 'a': 1 }] + * + * _.castArray('abc'); + * // => ['abc'] + * + * _.castArray(null); + * // => [null] + * + * _.castArray(undefined); + * // => [undefined] + * + * _.castArray(); + * // => [] + * + * var array = [1, 2, 3]; + * console.log(_.castArray(array) === array); + * // => true + */ + function castArray() { + if (!arguments.length) { + return []; + } + var value = arguments[0]; + return isArray(value) ? value : [value]; + } + + /** + * Creates a shallow clone of `value`. + * + * **Note:** This method is loosely based on the + * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) + * and supports cloning arrays, array buffers, booleans, date objects, maps, + * numbers, `Object` objects, regexes, sets, strings, symbols, and typed + * arrays. The own enumerable properties of `arguments` objects are cloned + * as plain objects. An empty object is returned for uncloneable values such + * as error objects, functions, DOM nodes, and WeakMaps. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to clone. + * @returns {*} Returns the cloned value. + * @see _.cloneDeep + * @example + * + * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * + * var shallow = _.clone(objects); + * console.log(shallow[0] === objects[0]); + * // => true + */ + function clone(value) { + return baseClone(value, CLONE_SYMBOLS_FLAG); + } + + /** + * This method is like `_.clone` except that it accepts `customizer` which + * is invoked to produce the cloned value. If `customizer` returns `undefined`, + * cloning is handled by the method instead. The `customizer` is invoked with + * up to four arguments; (value [, index|key, object, stack]). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to clone. + * @param {Function} [customizer] The function to customize cloning. + * @returns {*} Returns the cloned value. + * @see _.cloneDeepWith + * @example + * + * function customizer(value) { + * if (_.isElement(value)) { + * return value.cloneNode(false); + * } + * } + * + * var el = _.cloneWith(document.body, customizer); + * + * console.log(el === document.body); + * // => false + * console.log(el.nodeName); + * // => 'BODY' + * console.log(el.childNodes.length); + * // => 0 + */ + function cloneWith(value, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); + } + + /** + * This method is like `_.clone` except that it recursively clones `value`. + * + * @static + * @memberOf _ + * @since 1.0.0 + * @category Lang + * @param {*} value The value to recursively clone. + * @returns {*} Returns the deep cloned value. + * @see _.clone + * @example + * + * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * + * var deep = _.cloneDeep(objects); + * console.log(deep[0] === objects[0]); + * // => false + */ + function cloneDeep(value) { + return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); + } + + /** + * This method is like `_.cloneWith` except that it recursively clones `value`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to recursively clone. + * @param {Function} [customizer] The function to customize cloning. + * @returns {*} Returns the deep cloned value. + * @see _.cloneWith + * @example + * + * function customizer(value) { + * if (_.isElement(value)) { + * return value.cloneNode(true); + * } + * } + * + * var el = _.cloneDeepWith(document.body, customizer); + * + * console.log(el === document.body); + * // => false + * console.log(el.nodeName); + * // => 'BODY' + * console.log(el.childNodes.length); + * // => 20 + */ + function cloneDeepWith(value, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); + } + + /** + * Checks if `object` conforms to `source` by invoking the predicate + * properties of `source` with the corresponding property values of `object`. + * + * **Note:** This method is equivalent to `_.conforms` when `source` is + * partially applied. + * + * @static + * @memberOf _ + * @since 4.14.0 + * @category Lang + * @param {Object} object The object to inspect. + * @param {Object} source The object of property predicates to conform to. + * @returns {boolean} Returns `true` if `object` conforms, else `false`. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * + * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); + * // => true + * + * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); + * // => false + */ + function conformsTo(object, source) { + return source == null || baseConformsTo(object, source, keys(source)); + } + + /** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ + function eq(value, other) { + return value === other || (value !== value && other !== other); + } + + /** + * Checks if `value` is greater than `other`. + * + * @static + * @memberOf _ + * @since 3.9.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. + * @see _.lt + * @example + * + * _.gt(3, 1); + * // => true + * + * _.gt(3, 3); + * // => false + * + * _.gt(1, 3); + * // => false + */ + var gt = createRelationalOperation(baseGt); + + /** + * Checks if `value` is greater than or equal to `other`. + * + * @static + * @memberOf _ + * @since 3.9.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than or equal to + * `other`, else `false`. + * @see _.lte + * @example + * + * _.gte(3, 1); + * // => true + * + * _.gte(3, 3); + * // => true + * + * _.gte(1, 3); + * // => false + */ + var gte = createRelationalOperation(function(value, other) { + return value >= other; + }); + + /** + * Checks if `value` is likely an `arguments` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + * else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ + var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { + return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && + !propertyIsEnumerable.call(value, 'callee'); + }; + + /** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ + var isArray = Array.isArray; + + /** + * Checks if `value` is classified as an `ArrayBuffer` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. + * @example + * + * _.isArrayBuffer(new ArrayBuffer(2)); + * // => true + * + * _.isArrayBuffer(new Array(2)); + * // => false + */ + var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; + + /** + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @example + * + * _.isArrayLike([1, 2, 3]); + * // => true + * + * _.isArrayLike(document.body.children); + * // => true + * + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); + * // => false + */ + function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction(value); + } + + /** + * This method is like `_.isArrayLike` except that it also checks if `value` + * is an object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array-like object, + * else `false`. + * @example + * + * _.isArrayLikeObject([1, 2, 3]); + * // => true + * + * _.isArrayLikeObject(document.body.children); + * // => true + * + * _.isArrayLikeObject('abc'); + * // => false + * + * _.isArrayLikeObject(_.noop); + * // => false + */ + function isArrayLikeObject(value) { + return isObjectLike(value) && isArrayLike(value); + } + + /** + * Checks if `value` is classified as a boolean primitive or object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. + * @example + * + * _.isBoolean(false); + * // => true + * + * _.isBoolean(null); + * // => false + */ + function isBoolean(value) { + return value === true || value === false || + (isObjectLike(value) && baseGetTag(value) == boolTag); + } + + /** + * Checks if `value` is a buffer. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. + * @example + * + * _.isBuffer(new Buffer(2)); + * // => true + * + * _.isBuffer(new Uint8Array(2)); + * // => false + */ + var isBuffer = nativeIsBuffer || stubFalse; + + /** + * Checks if `value` is classified as a `Date` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a date object, else `false`. + * @example + * + * _.isDate(new Date); + * // => true + * + * _.isDate('Mon April 23 2012'); + * // => false + */ + var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; + + /** + * Checks if `value` is likely a DOM element. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. + * @example + * + * _.isElement(document.body); + * // => true + * + * _.isElement(''); + * // => false + */ + function isElement(value) { + return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); + } + + /** + * Checks if `value` is an empty object, collection, map, or set. + * + * Objects are considered empty if they have no own enumerable string keyed + * properties. + * + * Array-like values such as `arguments` objects, arrays, buffers, strings, or + * jQuery-like collections are considered empty if they have a `length` of `0`. + * Similarly, maps and sets are considered empty if they have a `size` of `0`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is empty, else `false`. + * @example + * + * _.isEmpty(null); + * // => true + * + * _.isEmpty(true); + * // => true + * + * _.isEmpty(1); + * // => true + * + * _.isEmpty([1, 2, 3]); + * // => false + * + * _.isEmpty({ 'a': 1 }); + * // => false + */ + function isEmpty(value) { + if (value == null) { + return true; + } + if (isArrayLike(value) && + (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || + isBuffer(value) || isTypedArray(value) || isArguments(value))) { + return !value.length; + } + var tag = getTag(value); + if (tag == mapTag || tag == setTag) { + return !value.size; + } + if (isPrototype(value)) { + return !baseKeys(value).length; + } + for (var key in value) { + if (hasOwnProperty.call(value, key)) { + return false; + } + } + return true; + } + + /** + * Performs a deep comparison between two values to determine if they are + * equivalent. + * + * **Note:** This method supports comparing arrays, array buffers, booleans, + * date objects, error objects, maps, numbers, `Object` objects, regexes, + * sets, strings, symbols, and typed arrays. `Object` objects are compared + * by their own, not inherited, enumerable properties. Functions and DOM + * nodes are compared by strict equality, i.e. `===`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.isEqual(object, other); + * // => true + * + * object === other; + * // => false + */ + function isEqual(value, other) { + return baseIsEqual(value, other); + } + + /** + * This method is like `_.isEqual` except that it accepts `customizer` which + * is invoked to compare values. If `customizer` returns `undefined`, comparisons + * are handled by the method instead. The `customizer` is invoked with up to + * six arguments: (objValue, othValue [, index|key, object, other, stack]). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * function isGreeting(value) { + * return /^h(?:i|ello)$/.test(value); + * } + * + * function customizer(objValue, othValue) { + * if (isGreeting(objValue) && isGreeting(othValue)) { + * return true; + * } + * } + * + * var array = ['hello', 'goodbye']; + * var other = ['hi', 'goodbye']; + * + * _.isEqualWith(array, other, customizer); + * // => true + */ + function isEqualWith(value, other, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + var result = customizer ? customizer(value, other) : undefined; + return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; + } + + /** + * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, + * `SyntaxError`, `TypeError`, or `URIError` object. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an error object, else `false`. + * @example + * + * _.isError(new Error); + * // => true + * + * _.isError(Error); + * // => false + */ + function isError(value) { + if (!isObjectLike(value)) { + return false; + } + var tag = baseGetTag(value); + return tag == errorTag || tag == domExcTag || + (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); + } + + /** + * Checks if `value` is a finite primitive number. + * + * **Note:** This method is based on + * [`Number.isFinite`](https://mdn.io/Number/isFinite). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. + * @example + * + * _.isFinite(3); + * // => true + * + * _.isFinite(Number.MIN_VALUE); + * // => true + * + * _.isFinite(Infinity); + * // => false + * + * _.isFinite('3'); + * // => false + */ + function isFinite(value) { + return typeof value == 'number' && nativeIsFinite(value); + } + + /** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ + function isFunction(value) { + if (!isObject(value)) { + return false; + } + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = baseGetTag(value); + return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; + } + + /** + * Checks if `value` is an integer. + * + * **Note:** This method is based on + * [`Number.isInteger`](https://mdn.io/Number/isInteger). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an integer, else `false`. + * @example + * + * _.isInteger(3); + * // => true + * + * _.isInteger(Number.MIN_VALUE); + * // => false + * + * _.isInteger(Infinity); + * // => false + * + * _.isInteger('3'); + * // => false + */ + function isInteger(value) { + return typeof value == 'number' && value == toInteger(value); + } + + /** + * Checks if `value` is a valid array-like length. + * + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ + function isLength(value) { + return typeof value == 'number' && + value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; + } + + /** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ + function isObject(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); + } + + /** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ + function isObjectLike(value) { + return value != null && typeof value == 'object'; + } + + /** + * Checks if `value` is classified as a `Map` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a map, else `false`. + * @example + * + * _.isMap(new Map); + * // => true + * + * _.isMap(new WeakMap); + * // => false + */ + var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; + + /** + * Performs a partial deep comparison between `object` and `source` to + * determine if `object` contains equivalent property values. + * + * **Note:** This method is equivalent to `_.matches` when `source` is + * partially applied. + * + * Partial comparisons will match empty array and empty object `source` + * values against any array or object value, respectively. See `_.isEqual` + * for a list of supported value comparisons. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * + * _.isMatch(object, { 'b': 2 }); + * // => true + * + * _.isMatch(object, { 'b': 1 }); + * // => false + */ + function isMatch(object, source) { + return object === source || baseIsMatch(object, source, getMatchData(source)); + } + + /** + * This method is like `_.isMatch` except that it accepts `customizer` which + * is invoked to compare values. If `customizer` returns `undefined`, comparisons + * are handled by the method instead. The `customizer` is invoked with five + * arguments: (objValue, srcValue, index|key, object, source). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + * @example + * + * function isGreeting(value) { + * return /^h(?:i|ello)$/.test(value); + * } + * + * function customizer(objValue, srcValue) { + * if (isGreeting(objValue) && isGreeting(srcValue)) { + * return true; + * } + * } + * + * var object = { 'greeting': 'hello' }; + * var source = { 'greeting': 'hi' }; + * + * _.isMatchWith(object, source, customizer); + * // => true + */ + function isMatchWith(object, source, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return baseIsMatch(object, source, getMatchData(source), customizer); + } + + /** + * Checks if `value` is `NaN`. + * + * **Note:** This method is based on + * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as + * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for + * `undefined` and other non-number values. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. + * @example + * + * _.isNaN(NaN); + * // => true + * + * _.isNaN(new Number(NaN)); + * // => true + * + * isNaN(undefined); + * // => true + * + * _.isNaN(undefined); + * // => false + */ + function isNaN(value) { + // An `NaN` primitive is the only value that is not equal to itself. + // Perform the `toStringTag` check first to avoid errors with some + // ActiveX objects in IE. + return isNumber(value) && value != +value; + } + + /** + * Checks if `value` is a pristine native function. + * + * **Note:** This method can't reliably detect native functions in the presence + * of the core-js package because core-js circumvents this kind of detection. + * Despite multiple requests, the core-js maintainer has made it clear: any + * attempt to fix the detection will be obstructed. As a result, we're left + * with little choice but to throw an error. Unfortunately, this also affects + * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), + * which rely on core-js. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + * @example + * + * _.isNative(Array.prototype.push); + * // => true + * + * _.isNative(_); + * // => false + */ + function isNative(value) { + if (isMaskable(value)) { + throw new Error(CORE_ERROR_TEXT); + } + return baseIsNative(value); + } + + /** + * Checks if `value` is `null`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `null`, else `false`. + * @example + * + * _.isNull(null); + * // => true + * + * _.isNull(void 0); + * // => false + */ + function isNull(value) { + return value === null; + } + + /** + * Checks if `value` is `null` or `undefined`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is nullish, else `false`. + * @example + * + * _.isNil(null); + * // => true + * + * _.isNil(void 0); + * // => true + * + * _.isNil(NaN); + * // => false + */ + function isNil(value) { + return value == null; + } + + /** + * Checks if `value` is classified as a `Number` primitive or object. + * + * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are + * classified as numbers, use the `_.isFinite` method. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a number, else `false`. + * @example + * + * _.isNumber(3); + * // => true + * + * _.isNumber(Number.MIN_VALUE); + * // => true + * + * _.isNumber(Infinity); + * // => true + * + * _.isNumber('3'); + * // => false + */ + function isNumber(value) { + return typeof value == 'number' || + (isObjectLike(value) && baseGetTag(value) == numberTag); + } + + /** + * Checks if `value` is a plain object, that is, an object created by the + * `Object` constructor or one with a `[[Prototype]]` of `null`. + * + * @static + * @memberOf _ + * @since 0.8.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * _.isPlainObject(new Foo); + * // => false + * + * _.isPlainObject([1, 2, 3]); + * // => false + * + * _.isPlainObject({ 'x': 0, 'y': 0 }); + * // => true + * + * _.isPlainObject(Object.create(null)); + * // => true + */ + function isPlainObject(value) { + if (!isObjectLike(value) || baseGetTag(value) != objectTag) { + return false; + } + var proto = getPrototype(value); + if (proto === null) { + return true; + } + var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; + return typeof Ctor == 'function' && Ctor instanceof Ctor && + funcToString.call(Ctor) == objectCtorString; + } + + /** + * Checks if `value` is classified as a `RegExp` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. + * @example + * + * _.isRegExp(/abc/); + * // => true + * + * _.isRegExp('/abc/'); + * // => false + */ + var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; + + /** + * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 + * double precision number which isn't the result of a rounded unsafe integer. + * + * **Note:** This method is based on + * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. + * @example + * + * _.isSafeInteger(3); + * // => true + * + * _.isSafeInteger(Number.MIN_VALUE); + * // => false + * + * _.isSafeInteger(Infinity); + * // => false + * + * _.isSafeInteger('3'); + * // => false + */ + function isSafeInteger(value) { + return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; + } + + /** + * Checks if `value` is classified as a `Set` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a set, else `false`. + * @example + * + * _.isSet(new Set); + * // => true + * + * _.isSet(new WeakSet); + * // => false + */ + var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; + + /** + * Checks if `value` is classified as a `String` primitive or object. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a string, else `false`. + * @example + * + * _.isString('abc'); + * // => true + * + * _.isString(1); + * // => false + */ + function isString(value) { + return typeof value == 'string' || + (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); + } + + /** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ + function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike(value) && baseGetTag(value) == symbolTag); + } + + /** + * Checks if `value` is classified as a typed array. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + * @example + * + * _.isTypedArray(new Uint8Array); + * // => true + * + * _.isTypedArray([]); + * // => false + */ + var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; + + /** + * Checks if `value` is `undefined`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. + * @example + * + * _.isUndefined(void 0); + * // => true + * + * _.isUndefined(null); + * // => false + */ + function isUndefined(value) { + return value === undefined; + } + + /** + * Checks if `value` is classified as a `WeakMap` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. + * @example + * + * _.isWeakMap(new WeakMap); + * // => true + * + * _.isWeakMap(new Map); + * // => false + */ + function isWeakMap(value) { + return isObjectLike(value) && getTag(value) == weakMapTag; + } + + /** + * Checks if `value` is classified as a `WeakSet` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. + * @example + * + * _.isWeakSet(new WeakSet); + * // => true + * + * _.isWeakSet(new Set); + * // => false + */ + function isWeakSet(value) { + return isObjectLike(value) && baseGetTag(value) == weakSetTag; + } + + /** + * Checks if `value` is less than `other`. + * + * @static + * @memberOf _ + * @since 3.9.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than `other`, + * else `false`. + * @see _.gt + * @example + * + * _.lt(1, 3); + * // => true + * + * _.lt(3, 3); + * // => false + * + * _.lt(3, 1); + * // => false + */ + var lt = createRelationalOperation(baseLt); + + /** + * Checks if `value` is less than or equal to `other`. + * + * @static + * @memberOf _ + * @since 3.9.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than or equal to + * `other`, else `false`. + * @see _.gte + * @example + * + * _.lte(1, 3); + * // => true + * + * _.lte(3, 3); + * // => true + * + * _.lte(3, 1); + * // => false + */ + var lte = createRelationalOperation(function(value, other) { + return value <= other; + }); + + /** + * Converts `value` to an array. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Lang + * @param {*} value The value to convert. + * @returns {Array} Returns the converted array. + * @example + * + * _.toArray({ 'a': 1, 'b': 2 }); + * // => [1, 2] + * + * _.toArray('abc'); + * // => ['a', 'b', 'c'] + * + * _.toArray(1); + * // => [] + * + * _.toArray(null); + * // => [] + */ + function toArray(value) { + if (!value) { + return []; + } + if (isArrayLike(value)) { + return isString(value) ? stringToArray(value) : copyArray(value); + } + if (symIterator && value[symIterator]) { + return iteratorToArray(value[symIterator]()); + } + var tag = getTag(value), + func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); + + return func(value); + } + + /** + * Converts `value` to a finite number. + * + * @static + * @memberOf _ + * @since 4.12.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted number. + * @example + * + * _.toFinite(3.2); + * // => 3.2 + * + * _.toFinite(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toFinite(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toFinite('3.2'); + * // => 3.2 + */ + function toFinite(value) { + if (!value) { + return value === 0 ? value : 0; + } + value = toNumber(value); + if (value === INFINITY || value === -INFINITY) { + var sign = (value < 0 ? -1 : 1); + return sign * MAX_INTEGER; + } + return value === value ? value : 0; + } + + /** + * Converts `value` to an integer. + * + * **Note:** This method is loosely based on + * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. + * @example + * + * _.toInteger(3.2); + * // => 3 + * + * _.toInteger(Number.MIN_VALUE); + * // => 0 + * + * _.toInteger(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toInteger('3.2'); + * // => 3 + */ + function toInteger(value) { + var result = toFinite(value), + remainder = result % 1; + + return result === result ? (remainder ? result - remainder : result) : 0; + } + + /** + * Converts `value` to an integer suitable for use as the length of an + * array-like object. + * + * **Note:** This method is based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. + * @example + * + * _.toLength(3.2); + * // => 3 + * + * _.toLength(Number.MIN_VALUE); + * // => 0 + * + * _.toLength(Infinity); + * // => 4294967295 + * + * _.toLength('3.2'); + * // => 3 + */ + function toLength(value) { + return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; + } + + /** + * Converts `value` to a number. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to process. + * @returns {number} Returns the number. + * @example + * + * _.toNumber(3.2); + * // => 3.2 + * + * _.toNumber(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toNumber(Infinity); + * // => Infinity + * + * _.toNumber('3.2'); + * // => 3.2 + */ + function toNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol(value)) { + return NAN; + } + if (isObject(value)) { + var other = typeof value.valueOf == 'function' ? value.valueOf() : value; + value = isObject(other) ? (other + '') : other; + } + if (typeof value != 'string') { + return value === 0 ? value : +value; + } + value = value.replace(reTrim, ''); + var isBinary = reIsBinary.test(value); + return (isBinary || reIsOctal.test(value)) + ? freeParseInt(value.slice(2), isBinary ? 2 : 8) + : (reIsBadHex.test(value) ? NAN : +value); + } + + /** + * Converts `value` to a plain object flattening inherited enumerable string + * keyed properties of `value` to own properties of the plain object. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {Object} Returns the converted plain object. + * @example + * + * function Foo() { + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.assign({ 'a': 1 }, new Foo); + * // => { 'a': 1, 'b': 2 } + * + * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); + * // => { 'a': 1, 'b': 2, 'c': 3 } + */ + function toPlainObject(value) { + return copyObject(value, keysIn(value)); + } + + /** + * Converts `value` to a safe integer. A safe integer can be compared and + * represented correctly. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. + * @example + * + * _.toSafeInteger(3.2); + * // => 3 + * + * _.toSafeInteger(Number.MIN_VALUE); + * // => 0 + * + * _.toSafeInteger(Infinity); + * // => 9007199254740991 + * + * _.toSafeInteger('3.2'); + * // => 3 + */ + function toSafeInteger(value) { + return value + ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) + : (value === 0 ? value : 0); + } + + /** + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' + */ + function toString(value) { + return value == null ? '' : baseToString(value); + } + + /*------------------------------------------------------------------------*/ + + /** + * Assigns own enumerable string keyed properties of source objects to the + * destination object. Source objects are applied from left to right. + * Subsequent sources overwrite property assignments of previous sources. + * + * **Note:** This method mutates `object` and is loosely based on + * [`Object.assign`](https://mdn.io/Object/assign). + * + * @static + * @memberOf _ + * @since 0.10.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.assignIn + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * function Bar() { + * this.c = 3; + * } + * + * Foo.prototype.b = 2; + * Bar.prototype.d = 4; + * + * _.assign({ 'a': 0 }, new Foo, new Bar); + * // => { 'a': 1, 'c': 3 } + */ + var assign = createAssigner(function(object, source) { + if (isPrototype(source) || isArrayLike(source)) { + copyObject(source, keys(source), object); + return; + } + for (var key in source) { + if (hasOwnProperty.call(source, key)) { + assignValue(object, key, source[key]); + } + } + }); + + /** + * This method is like `_.assign` except that it iterates over own and + * inherited source properties. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @alias extend + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.assign + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * function Bar() { + * this.c = 3; + * } + * + * Foo.prototype.b = 2; + * Bar.prototype.d = 4; + * + * _.assignIn({ 'a': 0 }, new Foo, new Bar); + * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } + */ + var assignIn = createAssigner(function(object, source) { + copyObject(source, keysIn(source), object); + }); + + /** + * This method is like `_.assignIn` except that it accepts `customizer` + * which is invoked to produce the assigned values. If `customizer` returns + * `undefined`, assignment is handled by the method instead. The `customizer` + * is invoked with five arguments: (objValue, srcValue, key, object, source). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @alias extendWith + * @category Object + * @param {Object} object The destination object. + * @param {...Object} sources The source objects. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @see _.assignWith + * @example + * + * function customizer(objValue, srcValue) { + * return _.isUndefined(objValue) ? srcValue : objValue; + * } + * + * var defaults = _.partialRight(_.assignInWith, customizer); + * + * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } + */ + var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { + copyObject(source, keysIn(source), object, customizer); + }); + + /** + * This method is like `_.assign` except that it accepts `customizer` + * which is invoked to produce the assigned values. If `customizer` returns + * `undefined`, assignment is handled by the method instead. The `customizer` + * is invoked with five arguments: (objValue, srcValue, key, object, source). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} sources The source objects. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @see _.assignInWith + * @example + * + * function customizer(objValue, srcValue) { + * return _.isUndefined(objValue) ? srcValue : objValue; + * } + * + * var defaults = _.partialRight(_.assignWith, customizer); + * + * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } + */ + var assignWith = createAssigner(function(object, source, srcIndex, customizer) { + copyObject(source, keys(source), object, customizer); + }); + + /** + * Creates an array of values corresponding to `paths` of `object`. + * + * @static + * @memberOf _ + * @since 1.0.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {...(string|string[])} [paths] The property paths to pick. + * @returns {Array} Returns the picked values. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; + * + * _.at(object, ['a[0].b.c', 'a[1]']); + * // => [3, 4] + */ + var at = flatRest(baseAt); + + /** + * Creates an object that inherits from the `prototype` object. If a + * `properties` object is given, its own enumerable string keyed properties + * are assigned to the created object. + * + * @static + * @memberOf _ + * @since 2.3.0 + * @category Object + * @param {Object} prototype The object to inherit from. + * @param {Object} [properties] The properties to assign to the object. + * @returns {Object} Returns the new object. + * @example + * + * function Shape() { + * this.x = 0; + * this.y = 0; + * } + * + * function Circle() { + * Shape.call(this); + * } + * + * Circle.prototype = _.create(Shape.prototype, { + * 'constructor': Circle + * }); + * + * var circle = new Circle; + * circle instanceof Circle; + * // => true + * + * circle instanceof Shape; + * // => true + */ + function create(prototype, properties) { + var result = baseCreate(prototype); + return properties == null ? result : baseAssign(result, properties); + } + + /** + * Assigns own and inherited enumerable string keyed properties of source + * objects to the destination object for all destination properties that + * resolve to `undefined`. Source objects are applied from left to right. + * Once a property is set, additional values of the same property are ignored. + * + * **Note:** This method mutates `object`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.defaultsDeep + * @example + * + * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } + */ + var defaults = baseRest(function(object, sources) { + object = Object(object); + + var index = -1; + var length = sources.length; + var guard = length > 2 ? sources[2] : undefined; + + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + length = 1; + } + + while (++index < length) { + var source = sources[index]; + var props = keysIn(source); + var propsIndex = -1; + var propsLength = props.length; + + while (++propsIndex < propsLength) { + var key = props[propsIndex]; + var value = object[key]; + + if (value === undefined || + (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { + object[key] = source[key]; + } + } + } + + return object; + }); + + /** + * This method is like `_.defaults` except that it recursively assigns + * default properties. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 3.10.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.defaults + * @example + * + * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); + * // => { 'a': { 'b': 2, 'c': 3 } } + */ + var defaultsDeep = baseRest(function(args) { + args.push(undefined, customDefaultsMerge); + return apply(mergeWith, undefined, args); + }); + + /** + * This method is like `_.find` except that it returns the key of the first + * element `predicate` returns truthy for instead of the element itself. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category Object + * @param {Object} object The object to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {string|undefined} Returns the key of the matched element, + * else `undefined`. + * @example + * + * var users = { + * 'barney': { 'age': 36, 'active': true }, + * 'fred': { 'age': 40, 'active': false }, + * 'pebbles': { 'age': 1, 'active': true } + * }; + * + * _.findKey(users, function(o) { return o.age < 40; }); + * // => 'barney' (iteration order is not guaranteed) + * + * // The `_.matches` iteratee shorthand. + * _.findKey(users, { 'age': 1, 'active': true }); + * // => 'pebbles' + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findKey(users, ['active', false]); + * // => 'fred' + * + * // The `_.property` iteratee shorthand. + * _.findKey(users, 'active'); + * // => 'barney' + */ + function findKey(object, predicate) { + return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); + } + + /** + * This method is like `_.findKey` except that it iterates over elements of + * a collection in the opposite order. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Object + * @param {Object} object The object to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {string|undefined} Returns the key of the matched element, + * else `undefined`. + * @example + * + * var users = { + * 'barney': { 'age': 36, 'active': true }, + * 'fred': { 'age': 40, 'active': false }, + * 'pebbles': { 'age': 1, 'active': true } + * }; + * + * _.findLastKey(users, function(o) { return o.age < 40; }); + * // => returns 'pebbles' assuming `_.findKey` returns 'barney' + * + * // The `_.matches` iteratee shorthand. + * _.findLastKey(users, { 'age': 36, 'active': true }); + * // => 'barney' + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findLastKey(users, ['active', false]); + * // => 'fred' + * + * // The `_.property` iteratee shorthand. + * _.findLastKey(users, 'active'); + * // => 'pebbles' + */ + function findLastKey(object, predicate) { + return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); + } + + /** + * Iterates over own and inherited enumerable string keyed properties of an + * object and invokes `iteratee` for each property. The iteratee is invoked + * with three arguments: (value, key, object). Iteratee functions may exit + * iteration early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @since 0.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forInRight + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forIn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). + */ + function forIn(object, iteratee) { + return object == null + ? object + : baseFor(object, getIteratee(iteratee, 3), keysIn); + } + + /** + * This method is like `_.forIn` except that it iterates over properties of + * `object` in the opposite order. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forIn + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forInRight(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. + */ + function forInRight(object, iteratee) { + return object == null + ? object + : baseForRight(object, getIteratee(iteratee, 3), keysIn); + } + + /** + * Iterates over own enumerable string keyed properties of an object and + * invokes `iteratee` for each property. The iteratee is invoked with three + * arguments: (value, key, object). Iteratee functions may exit iteration + * early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @since 0.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forOwnRight + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). + */ + function forOwn(object, iteratee) { + return object && baseForOwn(object, getIteratee(iteratee, 3)); + } + + /** + * This method is like `_.forOwn` except that it iterates over properties of + * `object` in the opposite order. + * + * @static + * @memberOf _ + * @since 2.0.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forOwn + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwnRight(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. + */ + function forOwnRight(object, iteratee) { + return object && baseForOwnRight(object, getIteratee(iteratee, 3)); + } + + /** + * Creates an array of function property names from own enumerable properties + * of `object`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to inspect. + * @returns {Array} Returns the function names. + * @see _.functionsIn + * @example + * + * function Foo() { + * this.a = _.constant('a'); + * this.b = _.constant('b'); + * } + * + * Foo.prototype.c = _.constant('c'); + * + * _.functions(new Foo); + * // => ['a', 'b'] + */ + function functions(object) { + return object == null ? [] : baseFunctions(object, keys(object)); + } + + /** + * Creates an array of function property names from own and inherited + * enumerable properties of `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to inspect. + * @returns {Array} Returns the function names. + * @see _.functions + * @example + * + * function Foo() { + * this.a = _.constant('a'); + * this.b = _.constant('b'); + * } + * + * Foo.prototype.c = _.constant('c'); + * + * _.functionsIn(new Foo); + * // => ['a', 'b', 'c'] + */ + function functionsIn(object) { + return object == null ? [] : baseFunctions(object, keysIn(object)); + } + + /** + * Gets the value at `path` of `object`. If the resolved value is + * `undefined`, the `defaultValue` is returned in its place. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.get(object, 'a[0].b.c'); + * // => 3 + * + * _.get(object, ['a', '0', 'b', 'c']); + * // => 3 + * + * _.get(object, 'a.b.c', 'default'); + * // => 'default' + */ + function get(object, path, defaultValue) { + var result = object == null ? undefined : baseGet(object, path); + return result === undefined ? defaultValue : result; + } + + /** + * Checks if `path` is a direct property of `object`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @example + * + * var object = { 'a': { 'b': 2 } }; + * var other = _.create({ 'a': _.create({ 'b': 2 }) }); + * + * _.has(object, 'a'); + * // => true + * + * _.has(object, 'a.b'); + * // => true + * + * _.has(object, ['a', 'b']); + * // => true + * + * _.has(other, 'a'); + * // => false + */ + function has(object, path) { + return object != null && hasPath(object, path, baseHas); + } + + /** + * Checks if `path` is a direct or inherited property of `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @example + * + * var object = _.create({ 'a': _.create({ 'b': 2 }) }); + * + * _.hasIn(object, 'a'); + * // => true + * + * _.hasIn(object, 'a.b'); + * // => true + * + * _.hasIn(object, ['a', 'b']); + * // => true + * + * _.hasIn(object, 'b'); + * // => false + */ + function hasIn(object, path) { + return object != null && hasPath(object, path, baseHasIn); + } + + /** + * Creates an object composed of the inverted keys and values of `object`. + * If `object` contains duplicate values, subsequent values overwrite + * property assignments of previous values. + * + * @static + * @memberOf _ + * @since 0.7.0 + * @category Object + * @param {Object} object The object to invert. + * @returns {Object} Returns the new inverted object. + * @example + * + * var object = { 'a': 1, 'b': 2, 'c': 1 }; + * + * _.invert(object); + * // => { '1': 'c', '2': 'b' } + */ + var invert = createInverter(function(result, value, key) { + if (value != null && + typeof value.toString != 'function') { + value = nativeObjectToString.call(value); + } + + result[value] = key; + }, constant(identity)); + + /** + * This method is like `_.invert` except that the inverted object is generated + * from the results of running each element of `object` thru `iteratee`. The + * corresponding inverted value of each inverted key is an array of keys + * responsible for generating the inverted value. The iteratee is invoked + * with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.1.0 + * @category Object + * @param {Object} object The object to invert. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Object} Returns the new inverted object. + * @example + * + * var object = { 'a': 1, 'b': 2, 'c': 1 }; + * + * _.invertBy(object); + * // => { '1': ['a', 'c'], '2': ['b'] } + * + * _.invertBy(object, function(value) { + * return 'group' + value; + * }); + * // => { 'group1': ['a', 'c'], 'group2': ['b'] } + */ + var invertBy = createInverter(function(result, value, key) { + if (value != null && + typeof value.toString != 'function') { + value = nativeObjectToString.call(value); + } + + if (hasOwnProperty.call(result, value)) { + result[value].push(key); + } else { + result[value] = [key]; + } + }, getIteratee); + + /** + * Invokes the method at `path` of `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the method to invoke. + * @param {...*} [args] The arguments to invoke the method with. + * @returns {*} Returns the result of the invoked method. + * @example + * + * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; + * + * _.invoke(object, 'a[0].b.c.slice', 1, 3); + * // => [2, 3] + */ + var invoke = baseRest(baseInvoke); + + /** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ + function keys(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); + } + + /** + * Creates an array of the own and inherited enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keysIn(new Foo); + * // => ['a', 'b', 'c'] (iteration order is not guaranteed) + */ + function keysIn(object) { + return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); + } + + /** + * The opposite of `_.mapValues`; this method creates an object with the + * same values as `object` and keys generated by running each own enumerable + * string keyed property of `object` thru `iteratee`. The iteratee is invoked + * with three arguments: (value, key, object). + * + * @static + * @memberOf _ + * @since 3.8.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns the new mapped object. + * @see _.mapValues + * @example + * + * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { + * return key + value; + * }); + * // => { 'a1': 1, 'b2': 2 } + */ + function mapKeys(object, iteratee) { + var result = {}; + iteratee = getIteratee(iteratee, 3); + + baseForOwn(object, function(value, key, object) { + baseAssignValue(result, iteratee(value, key, object), value); + }); + return result; + } + + /** + * Creates an object with the same keys as `object` and values generated + * by running each own enumerable string keyed property of `object` thru + * `iteratee`. The iteratee is invoked with three arguments: + * (value, key, object). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns the new mapped object. + * @see _.mapKeys + * @example + * + * var users = { + * 'fred': { 'user': 'fred', 'age': 40 }, + * 'pebbles': { 'user': 'pebbles', 'age': 1 } + * }; + * + * _.mapValues(users, function(o) { return o.age; }); + * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + * + * // The `_.property` iteratee shorthand. + * _.mapValues(users, 'age'); + * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + */ + function mapValues(object, iteratee) { + var result = {}; + iteratee = getIteratee(iteratee, 3); + + baseForOwn(object, function(value, key, object) { + baseAssignValue(result, key, iteratee(value, key, object)); + }); + return result; + } + + /** + * This method is like `_.assign` except that it recursively merges own and + * inherited enumerable string keyed properties of source objects into the + * destination object. Source properties that resolve to `undefined` are + * skipped if a destination value exists. Array and plain object properties + * are merged recursively. Other objects and value types are overridden by + * assignment. Source objects are applied from left to right. Subsequent + * sources overwrite property assignments of previous sources. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 0.5.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @example + * + * var object = { + * 'a': [{ 'b': 2 }, { 'd': 4 }] + * }; + * + * var other = { + * 'a': [{ 'c': 3 }, { 'e': 5 }] + * }; + * + * _.merge(object, other); + * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } + */ + var merge = createAssigner(function(object, source, srcIndex) { + baseMerge(object, source, srcIndex); + }); + + /** + * This method is like `_.merge` except that it accepts `customizer` which + * is invoked to produce the merged values of the destination and source + * properties. If `customizer` returns `undefined`, merging is handled by the + * method instead. The `customizer` is invoked with six arguments: + * (objValue, srcValue, key, object, source, stack). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} sources The source objects. + * @param {Function} customizer The function to customize assigned values. + * @returns {Object} Returns `object`. + * @example + * + * function customizer(objValue, srcValue) { + * if (_.isArray(objValue)) { + * return objValue.concat(srcValue); + * } + * } + * + * var object = { 'a': [1], 'b': [2] }; + * var other = { 'a': [3], 'b': [4] }; + * + * _.mergeWith(object, other, customizer); + * // => { 'a': [1, 3], 'b': [2, 4] } + */ + var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { + baseMerge(object, source, srcIndex, customizer); + }); + + /** + * The opposite of `_.pick`; this method creates an object composed of the + * own and inherited enumerable property paths of `object` that are not omitted. + * + * **Note:** This method is considerably slower than `_.pick`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The source object. + * @param {...(string|string[])} [paths] The property paths to omit. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.omit(object, ['a', 'c']); + * // => { 'b': '2' } + */ + var omit = flatRest(function(object, paths) { + var result = {}; + if (object == null) { + return result; + } + var isDeep = false; + paths = arrayMap(paths, function(path) { + path = castPath(path, object); + isDeep || (isDeep = path.length > 1); + return path; + }); + copyObject(object, getAllKeysIn(object), result); + if (isDeep) { + result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); + } + var length = paths.length; + while (length--) { + baseUnset(result, paths[length]); + } + return result; + }); + + /** + * The opposite of `_.pickBy`; this method creates an object composed of + * the own and inherited enumerable string keyed properties of `object` that + * `predicate` doesn't return truthy for. The predicate is invoked with two + * arguments: (value, key). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The source object. + * @param {Function} [predicate=_.identity] The function invoked per property. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.omitBy(object, _.isNumber); + * // => { 'b': '2' } + */ + function omitBy(object, predicate) { + return pickBy(object, negate(getIteratee(predicate))); + } + + /** + * Creates an object composed of the picked `object` properties. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The source object. + * @param {...(string|string[])} [paths] The property paths to pick. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.pick(object, ['a', 'c']); + * // => { 'a': 1, 'c': 3 } + */ + var pick = flatRest(function(object, paths) { + return object == null ? {} : basePick(object, paths); + }); + + /** + * Creates an object composed of the `object` properties `predicate` returns + * truthy for. The predicate is invoked with two arguments: (value, key). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The source object. + * @param {Function} [predicate=_.identity] The function invoked per property. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.pickBy(object, _.isNumber); + * // => { 'a': 1, 'c': 3 } + */ + function pickBy(object, predicate) { + if (object == null) { + return {}; + } + var props = arrayMap(getAllKeysIn(object), function(prop) { + return [prop]; + }); + predicate = getIteratee(predicate); + return basePickBy(object, props, function(value, path) { + return predicate(value, path[0]); + }); + } + + /** + * This method is like `_.get` except that if the resolved value is a + * function it's invoked with the `this` binding of its parent object and + * its result is returned. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to resolve. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; + * + * _.result(object, 'a[0].b.c1'); + * // => 3 + * + * _.result(object, 'a[0].b.c2'); + * // => 4 + * + * _.result(object, 'a[0].b.c3', 'default'); + * // => 'default' + * + * _.result(object, 'a[0].b.c3', _.constant('default')); + * // => 'default' + */ + function result(object, path, defaultValue) { + path = castPath(path, object); + + var index = -1, + length = path.length; + + // Ensure the loop is entered when path is empty. + if (!length) { + length = 1; + object = undefined; + } + while (++index < length) { + var value = object == null ? undefined : object[toKey(path[index])]; + if (value === undefined) { + index = length; + value = defaultValue; + } + object = isFunction(value) ? value.call(object) : value; + } + return object; + } + + /** + * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, + * it's created. Arrays are created for missing index properties while objects + * are created for all other missing properties. Use `_.setWith` to customize + * `path` creation. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @returns {Object} Returns `object`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.set(object, 'a[0].b.c', 4); + * console.log(object.a[0].b.c); + * // => 4 + * + * _.set(object, ['x', '0', 'y', 'z'], 5); + * console.log(object.x[0].y.z); + * // => 5 + */ + function set(object, path, value) { + return object == null ? object : baseSet(object, path, value); + } + + /** + * This method is like `_.set` except that it accepts `customizer` which is + * invoked to produce the objects of `path`. If `customizer` returns `undefined` + * path creation is handled by the method instead. The `customizer` is invoked + * with three arguments: (nsValue, key, nsObject). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @example + * + * var object = {}; + * + * _.setWith(object, '[0][1]', 'a', Object); + * // => { '0': { '1': 'a' } } + */ + function setWith(object, path, value, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return object == null ? object : baseSet(object, path, value, customizer); + } + + /** + * Creates an array of own enumerable string keyed-value pairs for `object` + * which can be consumed by `_.fromPairs`. If `object` is a map or set, its + * entries are returned. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @alias entries + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the key-value pairs. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.toPairs(new Foo); + * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) + */ + var toPairs = createToPairs(keys); + + /** + * Creates an array of own and inherited enumerable string keyed-value pairs + * for `object` which can be consumed by `_.fromPairs`. If `object` is a map + * or set, its entries are returned. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @alias entriesIn + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the key-value pairs. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.toPairsIn(new Foo); + * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) + */ + var toPairsIn = createToPairs(keysIn); + + /** + * An alternative to `_.reduce`; this method transforms `object` to a new + * `accumulator` object which is the result of running each of its own + * enumerable string keyed properties thru `iteratee`, with each invocation + * potentially mutating the `accumulator` object. If `accumulator` is not + * provided, a new object with the same `[[Prototype]]` will be used. The + * iteratee is invoked with four arguments: (accumulator, value, key, object). + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @since 1.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The custom accumulator value. + * @returns {*} Returns the accumulated value. + * @example + * + * _.transform([2, 3, 4], function(result, n) { + * result.push(n *= n); + * return n % 2 == 0; + * }, []); + * // => [4, 9] + * + * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { + * (result[value] || (result[value] = [])).push(key); + * }, {}); + * // => { '1': ['a', 'c'], '2': ['b'] } + */ + function transform(object, iteratee, accumulator) { + var isArr = isArray(object), + isArrLike = isArr || isBuffer(object) || isTypedArray(object); + + iteratee = getIteratee(iteratee, 4); + if (accumulator == null) { + var Ctor = object && object.constructor; + if (isArrLike) { + accumulator = isArr ? new Ctor : []; + } + else if (isObject(object)) { + accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; + } + else { + accumulator = {}; + } + } + (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { + return iteratee(accumulator, value, index, object); + }); + return accumulator; + } + + /** + * Removes the property at `path` of `object`. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to unset. + * @returns {boolean} Returns `true` if the property is deleted, else `false`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 7 } }] }; + * _.unset(object, 'a[0].b.c'); + * // => true + * + * console.log(object); + * // => { 'a': [{ 'b': {} }] }; + * + * _.unset(object, ['a', '0', 'b', 'c']); + * // => true + * + * console.log(object); + * // => { 'a': [{ 'b': {} }] }; + */ + function unset(object, path) { + return object == null ? true : baseUnset(object, path); + } + + /** + * This method is like `_.set` except that accepts `updater` to produce the + * value to set. Use `_.updateWith` to customize `path` creation. The `updater` + * is invoked with one argument: (value). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.6.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {Function} updater The function to produce the updated value. + * @returns {Object} Returns `object`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.update(object, 'a[0].b.c', function(n) { return n * n; }); + * console.log(object.a[0].b.c); + * // => 9 + * + * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); + * console.log(object.x[0].y.z); + * // => 0 + */ + function update(object, path, updater) { + return object == null ? object : baseUpdate(object, path, castFunction(updater)); + } + + /** + * This method is like `_.update` except that it accepts `customizer` which is + * invoked to produce the objects of `path`. If `customizer` returns `undefined` + * path creation is handled by the method instead. The `customizer` is invoked + * with three arguments: (nsValue, key, nsObject). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.6.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {Function} updater The function to produce the updated value. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @example + * + * var object = {}; + * + * _.updateWith(object, '[0][1]', _.constant('a'), Object); + * // => { '0': { '1': 'a' } } + */ + function updateWith(object, path, updater, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); + } + + /** + * Creates an array of the own enumerable string keyed property values of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property values. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.values(new Foo); + * // => [1, 2] (iteration order is not guaranteed) + * + * _.values('hi'); + * // => ['h', 'i'] + */ + function values(object) { + return object == null ? [] : baseValues(object, keys(object)); + } + + /** + * Creates an array of the own and inherited enumerable string keyed property + * values of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property values. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.valuesIn(new Foo); + * // => [1, 2, 3] (iteration order is not guaranteed) + */ + function valuesIn(object) { + return object == null ? [] : baseValues(object, keysIn(object)); + } + + /*------------------------------------------------------------------------*/ + + /** + * Clamps `number` within the inclusive `lower` and `upper` bounds. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Number + * @param {number} number The number to clamp. + * @param {number} [lower] The lower bound. + * @param {number} upper The upper bound. + * @returns {number} Returns the clamped number. + * @example + * + * _.clamp(-10, -5, 5); + * // => -5 + * + * _.clamp(10, -5, 5); + * // => 5 + */ + function clamp(number, lower, upper) { + if (upper === undefined) { + upper = lower; + lower = undefined; + } + if (upper !== undefined) { + upper = toNumber(upper); + upper = upper === upper ? upper : 0; + } + if (lower !== undefined) { + lower = toNumber(lower); + lower = lower === lower ? lower : 0; + } + return baseClamp(toNumber(number), lower, upper); + } + + /** + * Checks if `n` is between `start` and up to, but not including, `end`. If + * `end` is not specified, it's set to `start` with `start` then set to `0`. + * If `start` is greater than `end` the params are swapped to support + * negative ranges. + * + * @static + * @memberOf _ + * @since 3.3.0 + * @category Number + * @param {number} number The number to check. + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @returns {boolean} Returns `true` if `number` is in the range, else `false`. + * @see _.range, _.rangeRight + * @example + * + * _.inRange(3, 2, 4); + * // => true + * + * _.inRange(4, 8); + * // => true + * + * _.inRange(4, 2); + * // => false + * + * _.inRange(2, 2); + * // => false + * + * _.inRange(1.2, 2); + * // => true + * + * _.inRange(5.2, 4); + * // => false + * + * _.inRange(-3, -2, -6); + * // => true + */ + function inRange(number, start, end) { + start = toFinite(start); + if (end === undefined) { + end = start; + start = 0; + } else { + end = toFinite(end); + } + number = toNumber(number); + return baseInRange(number, start, end); + } + + /** + * Produces a random number between the inclusive `lower` and `upper` bounds. + * If only one argument is provided a number between `0` and the given number + * is returned. If `floating` is `true`, or either `lower` or `upper` are + * floats, a floating-point number is returned instead of an integer. + * + * **Note:** JavaScript follows the IEEE-754 standard for resolving + * floating-point values which can produce unexpected results. + * + * @static + * @memberOf _ + * @since 0.7.0 + * @category Number + * @param {number} [lower=0] The lower bound. + * @param {number} [upper=1] The upper bound. + * @param {boolean} [floating] Specify returning a floating-point number. + * @returns {number} Returns the random number. + * @example + * + * _.random(0, 5); + * // => an integer between 0 and 5 + * + * _.random(5); + * // => also an integer between 0 and 5 + * + * _.random(5, true); + * // => a floating-point number between 0 and 5 + * + * _.random(1.2, 5.2); + * // => a floating-point number between 1.2 and 5.2 + */ + function random(lower, upper, floating) { + if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { + upper = floating = undefined; + } + if (floating === undefined) { + if (typeof upper == 'boolean') { + floating = upper; + upper = undefined; + } + else if (typeof lower == 'boolean') { + floating = lower; + lower = undefined; + } + } + if (lower === undefined && upper === undefined) { + lower = 0; + upper = 1; + } + else { + lower = toFinite(lower); + if (upper === undefined) { + upper = lower; + lower = 0; + } else { + upper = toFinite(upper); + } + } + if (lower > upper) { + var temp = lower; + lower = upper; + upper = temp; + } + if (floating || lower % 1 || upper % 1) { + var rand = nativeRandom(); + return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); + } + return baseRandom(lower, upper); + } + + /*------------------------------------------------------------------------*/ + + /** + * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the camel cased string. + * @example + * + * _.camelCase('Foo Bar'); + * // => 'fooBar' + * + * _.camelCase('--foo-bar--'); + * // => 'fooBar' + * + * _.camelCase('__FOO_BAR__'); + * // => 'fooBar' + */ + var camelCase = createCompounder(function(result, word, index) { + word = word.toLowerCase(); + return result + (index ? capitalize(word) : word); + }); + + /** + * Converts the first character of `string` to upper case and the remaining + * to lower case. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to capitalize. + * @returns {string} Returns the capitalized string. + * @example + * + * _.capitalize('FRED'); + * // => 'Fred' + */ + function capitalize(string) { + return upperFirst(toString(string).toLowerCase()); + } + + /** + * Deburrs `string` by converting + * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) + * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) + * letters to basic Latin letters and removing + * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to deburr. + * @returns {string} Returns the deburred string. + * @example + * + * _.deburr('déjà vu'); + * // => 'deja vu' + */ + function deburr(string) { + string = toString(string); + return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); + } + + /** + * Checks if `string` ends with the given target string. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to inspect. + * @param {string} [target] The string to search for. + * @param {number} [position=string.length] The position to search up to. + * @returns {boolean} Returns `true` if `string` ends with `target`, + * else `false`. + * @example + * + * _.endsWith('abc', 'c'); + * // => true + * + * _.endsWith('abc', 'b'); + * // => false + * + * _.endsWith('abc', 'b', 2); + * // => true + */ + function endsWith(string, target, position) { + string = toString(string); + target = baseToString(target); + + var length = string.length; + position = position === undefined + ? length + : baseClamp(toInteger(position), 0, length); + + var end = position; + position -= target.length; + return position >= 0 && string.slice(position, end) == target; + } + + /** + * Converts the characters "&", "<", ">", '"', and "'" in `string` to their + * corresponding HTML entities. + * + * **Note:** No other characters are escaped. To escape additional + * characters use a third-party library like [_he_](https://mths.be/he). + * + * Though the ">" character is escaped for symmetry, characters like + * ">" and "/" don't need escaping in HTML and have no special meaning + * unless they're part of a tag or unquoted attribute value. See + * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) + * (under "semi-related fun fact") for more details. + * + * When working with HTML you should always + * [quote attribute values](http://wonko.com/post/html-escaping) to reduce + * XSS vectors. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category String + * @param {string} [string=''] The string to escape. + * @returns {string} Returns the escaped string. + * @example + * + * _.escape('fred, barney, & pebbles'); + * // => 'fred, barney, & pebbles' + */ + function escape(string) { + string = toString(string); + return (string && reHasUnescapedHtml.test(string)) + ? string.replace(reUnescapedHtml, escapeHtmlChar) + : string; + } + + /** + * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", + * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to escape. + * @returns {string} Returns the escaped string. + * @example + * + * _.escapeRegExp('[lodash](https://lodash.com/)'); + * // => '\[lodash\]\(https://lodash\.com/\)' + */ + function escapeRegExp(string) { + string = toString(string); + return (string && reHasRegExpChar.test(string)) + ? string.replace(reRegExpChar, '\\$&') + : string; + } + + /** + * Converts `string` to + * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the kebab cased string. + * @example + * + * _.kebabCase('Foo Bar'); + * // => 'foo-bar' + * + * _.kebabCase('fooBar'); + * // => 'foo-bar' + * + * _.kebabCase('__FOO_BAR__'); + * // => 'foo-bar' + */ + var kebabCase = createCompounder(function(result, word, index) { + return result + (index ? '-' : '') + word.toLowerCase(); + }); + + /** + * Converts `string`, as space separated words, to lower case. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the lower cased string. + * @example + * + * _.lowerCase('--Foo-Bar--'); + * // => 'foo bar' + * + * _.lowerCase('fooBar'); + * // => 'foo bar' + * + * _.lowerCase('__FOO_BAR__'); + * // => 'foo bar' + */ + var lowerCase = createCompounder(function(result, word, index) { + return result + (index ? ' ' : '') + word.toLowerCase(); + }); + + /** + * Converts the first character of `string` to lower case. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.lowerFirst('Fred'); + * // => 'fred' + * + * _.lowerFirst('FRED'); + * // => 'fRED' + */ + var lowerFirst = createCaseFirst('toLowerCase'); + + /** + * Pads `string` on the left and right sides if it's shorter than `length`. + * Padding characters are truncated if they can't be evenly divided by `length`. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.pad('abc', 8); + * // => ' abc ' + * + * _.pad('abc', 8, '_-'); + * // => '_-abc_-_' + * + * _.pad('abc', 3); + * // => 'abc' + */ + function pad(string, length, chars) { + string = toString(string); + length = toInteger(length); + + var strLength = length ? stringSize(string) : 0; + if (!length || strLength >= length) { + return string; + } + var mid = (length - strLength) / 2; + return ( + createPadding(nativeFloor(mid), chars) + + string + + createPadding(nativeCeil(mid), chars) + ); + } + + /** + * Pads `string` on the right side if it's shorter than `length`. Padding + * characters are truncated if they exceed `length`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padEnd('abc', 6); + * // => 'abc ' + * + * _.padEnd('abc', 6, '_-'); + * // => 'abc_-_' + * + * _.padEnd('abc', 3); + * // => 'abc' + */ + function padEnd(string, length, chars) { + string = toString(string); + length = toInteger(length); + + var strLength = length ? stringSize(string) : 0; + return (length && strLength < length) + ? (string + createPadding(length - strLength, chars)) + : string; + } + + /** + * Pads `string` on the left side if it's shorter than `length`. Padding + * characters are truncated if they exceed `length`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padStart('abc', 6); + * // => ' abc' + * + * _.padStart('abc', 6, '_-'); + * // => '_-_abc' + * + * _.padStart('abc', 3); + * // => 'abc' + */ + function padStart(string, length, chars) { + string = toString(string); + length = toInteger(length); + + var strLength = length ? stringSize(string) : 0; + return (length && strLength < length) + ? (createPadding(length - strLength, chars) + string) + : string; + } + + /** + * Converts `string` to an integer of the specified radix. If `radix` is + * `undefined` or `0`, a `radix` of `10` is used unless `value` is a + * hexadecimal, in which case a `radix` of `16` is used. + * + * **Note:** This method aligns with the + * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category String + * @param {string} string The string to convert. + * @param {number} [radix=10] The radix to interpret `value` by. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {number} Returns the converted integer. + * @example + * + * _.parseInt('08'); + * // => 8 + * + * _.map(['6', '08', '10'], _.parseInt); + * // => [6, 8, 10] + */ + function parseInt(string, radix, guard) { + if (guard || radix == null) { + radix = 0; + } else if (radix) { + radix = +radix; + } + return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); + } + + /** + * Repeats the given string `n` times. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to repeat. + * @param {number} [n=1] The number of times to repeat the string. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {string} Returns the repeated string. + * @example + * + * _.repeat('*', 3); + * // => '***' + * + * _.repeat('abc', 2); + * // => 'abcabc' + * + * _.repeat('abc', 0); + * // => '' + */ + function repeat(string, n, guard) { + if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { + n = 1; + } else { + n = toInteger(n); + } + return baseRepeat(toString(string), n); + } + + /** + * Replaces matches for `pattern` in `string` with `replacement`. + * + * **Note:** This method is based on + * [`String#replace`](https://mdn.io/String/replace). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to modify. + * @param {RegExp|string} pattern The pattern to replace. + * @param {Function|string} replacement The match replacement. + * @returns {string} Returns the modified string. + * @example + * + * _.replace('Hi Fred', 'Fred', 'Barney'); + * // => 'Hi Barney' + */ + function replace() { + var args = arguments, + string = toString(args[0]); + + return args.length < 3 ? string : string.replace(args[1], args[2]); + } + + /** + * Converts `string` to + * [snake case](https://en.wikipedia.org/wiki/Snake_case). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the snake cased string. + * @example + * + * _.snakeCase('Foo Bar'); + * // => 'foo_bar' + * + * _.snakeCase('fooBar'); + * // => 'foo_bar' + * + * _.snakeCase('--FOO-BAR--'); + * // => 'foo_bar' + */ + var snakeCase = createCompounder(function(result, word, index) { + return result + (index ? '_' : '') + word.toLowerCase(); + }); + + /** + * Splits `string` by `separator`. + * + * **Note:** This method is based on + * [`String#split`](https://mdn.io/String/split). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to split. + * @param {RegExp|string} separator The separator pattern to split by. + * @param {number} [limit] The length to truncate results to. + * @returns {Array} Returns the string segments. + * @example + * + * _.split('a-b-c', '-', 2); + * // => ['a', 'b'] + */ + function split(string, separator, limit) { + if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { + separator = limit = undefined; + } + limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; + if (!limit) { + return []; + } + string = toString(string); + if (string && ( + typeof separator == 'string' || + (separator != null && !isRegExp(separator)) + )) { + separator = baseToString(separator); + if (!separator && hasUnicode(string)) { + return castSlice(stringToArray(string), 0, limit); + } + } + return string.split(separator, limit); + } + + /** + * Converts `string` to + * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). + * + * @static + * @memberOf _ + * @since 3.1.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the start cased string. + * @example + * + * _.startCase('--foo-bar--'); + * // => 'Foo Bar' + * + * _.startCase('fooBar'); + * // => 'Foo Bar' + * + * _.startCase('__FOO_BAR__'); + * // => 'FOO BAR' + */ + var startCase = createCompounder(function(result, word, index) { + return result + (index ? ' ' : '') + upperFirst(word); + }); + + /** + * Checks if `string` starts with the given target string. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to inspect. + * @param {string} [target] The string to search for. + * @param {number} [position=0] The position to search from. + * @returns {boolean} Returns `true` if `string` starts with `target`, + * else `false`. + * @example + * + * _.startsWith('abc', 'a'); + * // => true + * + * _.startsWith('abc', 'b'); + * // => false + * + * _.startsWith('abc', 'b', 1); + * // => true + */ + function startsWith(string, target, position) { + string = toString(string); + position = position == null + ? 0 + : baseClamp(toInteger(position), 0, string.length); + + target = baseToString(target); + return string.slice(position, position + target.length) == target; + } + + /** + * Creates a compiled template function that can interpolate data properties + * in "interpolate" delimiters, HTML-escape interpolated data properties in + * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data + * properties may be accessed as free variables in the template. If a setting + * object is given, it takes precedence over `_.templateSettings` values. + * + * **Note:** In the development build `_.template` utilizes + * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) + * for easier debugging. + * + * For more information on precompiling templates see + * [lodash's custom builds documentation](https://lodash.com/custom-builds). + * + * For more information on Chrome extension sandboxes see + * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category String + * @param {string} [string=''] The template string. + * @param {Object} [options={}] The options object. + * @param {RegExp} [options.escape=_.templateSettings.escape] + * The HTML "escape" delimiter. + * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] + * The "evaluate" delimiter. + * @param {Object} [options.imports=_.templateSettings.imports] + * An object to import into the template as free variables. + * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] + * The "interpolate" delimiter. + * @param {string} [options.sourceURL='lodash.templateSources[n]'] + * The sourceURL of the compiled template. + * @param {string} [options.variable='obj'] + * The data object variable name. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Function} Returns the compiled template function. + * @example + * + * // Use the "interpolate" delimiter to create a compiled template. + * var compiled = _.template('hello <%= user %>!'); + * compiled({ 'user': 'fred' }); + * // => 'hello fred!' + * + * // Use the HTML "escape" delimiter to escape data property values. + * var compiled = _.template('<%- value %>'); + * compiled({ 'value': '