text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3-axis"),require("d3-array"),require("d3-time-format"),require("d3-time"),require("d3-scale"),require("d3-selection"),require("d3-zoom")):"function"==typeof define&&define.amd?define(["exports","d3-axis","d3-array","d3-time-format","d3-time","d3-scale","d3-selection","d3-zoom"],e):e(t.d3=t.d3||{},t.d3,t.d3,t.d3,t.d3,t.d3,t.d3,t.d3)}(this,function(t,e,n,r,i,a,o,l){"use strict";var c=function(){function t(t){function r(t){var e=Math.floor(t/86400),n=Math.floor((t-86400*e)/3600),r=Math.floor((t-86400*e-3600*n)/60),i=t-86400*e-3600*n-60*r,a="";return i&&(a=i+"s"),r&&(a=r+"m "+a),n&&(a=n+"h "+a),e&&(a=e+"d "+a),a}function i(t,e){return I.left+(t.starting_time-z)*nt}function c(t,e){var n=c.canvas||(c.canvas=document.createElement("canvas")),r=n.getContext("2d");return r.font=e,r.measureText(t).width}function h(t,e,n,r){var i=0;if(t.ending_time&&(i=(t.ending_time-t.starting_time)/2*nt),n&&r){var a=getComputedStyle(document.querySelector(r)),o=a.fontSize+" "+a.fontFamily,l=c(n,o),s=l/2;return I.left+(t.starting_time-z)*nt+i-s}return I.left+(t.starting_time-z)*nt+5}function p(t,e,n){n=n||"timeline-line",it.append("svg:line").attr("x1",t).attr("y1",e.marginTop).attr("x2",t).attr("y2",w-e.marginBottom).attr("class",n).style("stroke",e.color).style("stroke-width",e.width)}var x=t.node().getBoundingClientRect(),A=o.select(t.node()),q=t.append("g").attr("class","container"),j={},P=1,G=0,$=0;!function(){if(k||x.width){if(!k&&x.width)try{k=x.width}catch(t){console.log(t)}}else try{if(!(k=A.node().attr("width")))throw"width of the timeline is not set. As of Firefox 27, timeline().with(x) needs to be explicitly set in order to render"}catch(t){console.log(t)}}(),L&&q.each(function(t,e){var n=0;t.forEach(function(t,e){t.times.forEach(function(t,r){0===e&&0===r?(n=t.starting_time,t.starting_time=0,t.ending_time=t.ending_time-n):(t.starting_time=t.starting_time-n,t.ending_time=t.ending_time-n)})})}),(O||0===C||0===z)&&(q.each(function(t,e){t.forEach(function(t,e){O&&-1==Object.keys(j).indexOf(e)&&(j[e]=P,P++),t.times.forEach(function(t,e){0===z&&(t.starting_time<G||0===G&&!1===L)&&(G=t.starting_time),0===C&&t.ending_time>$&&($=t.ending_time)})})}),0===C&&(C=$),0===z&&(z=G));var tt,et,nt=1/(C-z)*(k-I.left-I.right);"bottom"==v?et=e.axisBottom():"top"==v&&(et=e.axisTop()),N?(tt=a.scaleLinear().domain([z,C]).range([I.left,k-I.right]),et.scale(tt).tickFormat(r).tickValues(n.range(0,C,86400))):(tt=a.scaleTime().domain([z,C]).range([I.left,k-I.right]),et.scale(tt).tickFormat(_.format).tickSize(_.tickSize)),null!==_.tickValues?et.tickValues(_.tickValues):et.tickArguments(_.numTicks||[_.tickTime,_.tickInterval]);var it=q.append("g").attr("class","view");q.each(function(e,n){F=e,e.forEach(function(e,n){function r(t,e){return O?I.top+(H+Z)*j[n]:I.top}function a(t,e){return O?I.top+(H+Z)*j[n]+.75*H:I.top+.75*H}var l=e.times;l.forEach(function(t){t.name=e.name});var c=void 0!==e.label;if(void 0!==e.id&&console.warn("d3Timeline Warning: Ids per dataset is deprecated in favor of a 'class' key. Ids are now per data element."),b&&ct(j,n,q,l,e),it.selectAll("svg").data(l).enter().append(function(t,e){return document.createElementNS(o.namespaces.svg,"display"in t?t.display:S)}).attr("x",i).attr("y",r).attr("width",function(t,e){return(t.ending_time-t.starting_time)*nt}).attr("cy",function(t,e){return r(t,e)+H/2}).attr("cx",i).attr("r",H/2).attr("rx",function(t,e){return H/4}).attr("ry",function(t,e){return H/2}).attr("height",H).style("fill",function(t,r){var i;return t.color?t.color:E?(i=t[E],B(i?i:e[E])):B(n)}).on("mousemove",function(t,r){s(t,n,e,r)}).on("mouseover",function(t,n){u(t,n,e,n)}).on("mouseout",function(t,n){f(t,n,e,n)}).on("click",function(t,r){var i=o.mouse(this),a=o.select(this).node(),l="text#"+a.id+".textnumbers",c=o.select(l).node();d(t,n,e,c,a,tt.invert(i[0]))}).attr("class",function(t,r){return e.class?"timelineSeries_"+e.class:"timelineSeries_"+n}).attr("id",function(t,r){return e.id&&!t.id?"timelineItem_"+e.id:t.id?t.id:"timelineItem_"+n+"_"+r}),it.selectAll("svg").data(l).enter().append("text").attr("class","textlabels").attr("id",function(t){return t.id}).attr("x",function(t,e){return h(t,e,t.label,".textlabels")}).attr("y",a()-g).text(function(t){return t.label}).on("click",function(t,r){var i=o.mouse(this),a=this.id,l="text#"+a+".textnumbers",c=o.select(l).node(),s="rect#"+a,u=o.select(s).node();d(t,n,e,c,u,tt.invert(i[0]))}),it.selectAll("svg").data(l).enter().filter(function(t){return void 0!==t.labelNumber}).append("text").attr("class","textnumbers").attr("id",function(t){return t.id}).attr("x",function(t,e){return h(t,e,t.labelNumber,".textnumbers")}).attr("y",a).text(function(t){return t.labelNumber}).on("click",function(t,r){var i=o.mouse(this),a=this.id,l=o.select(this).node(),c="rect#"+a,s=o.select(c).node();d(t,n,e,l,s,tt.invert(i[0]))}),y){var m=H+Z/2+I.top+(H+Z)*j[n];t.append("svg:line").attr("class","row-separator").attr("x1",0+I.left).attr("x2",k-I.right).attr("y1",m).attr("y2",m).attr("stroke-width",1).attr("stroke",y)}c&&st(t,j,n,c,e),void 0!==e.icon&&t.append("image").attr("class","timeline-label").attr("transform","translate(0,"+(I.top+(H+Z)*j[n])+")").attr("xlink:href",e.icon).attr("width",I.left).attr("height",H)})});var at=I.top+(H+Z)*P,ot=I.top,ut=D?ot:at;if(R&&rt(q,et,ut),X&&lt(q,et,P),k>x.width)var ft=function(){q.select(".view").attr("transform","translate("+o.event.transform.x+",0)scale("+o.event.transform.k+" 1)"),q.selectAll(".timeline-xAxis").attr("transform",function(t){return"translate("+o.event.transform.x+", "+ut+")scale("+o.event.transform.k+" 1)"});var t=o.event.transform.rescaleX(tt);q.selectAll(".timeline-xAxis").call(function(e){et.scale(t)});var e=-o.event.transform.x;m(e,tt)};var dt=l.zoom().scaleExtent([T?Y:1,T?M:1]).translateExtent([[0,0],[k,0]]).on("zoom",ft);t.classed("scrollable",!0).call(dt),V&&q.selectAll(".tick text").attr("transform",function(t){return"rotate("+V+")translate("+(this.getBBox().width/2+10)+","+this.getBBox().height/2+")"});var mt=q.node().getBoundingClientRect();if(function(){if(w||x.height)w?A.node().attr("height",w):w=x.height;else{if(!H)throw"height of the timeline is not set";w=mt.height+mt.top-x.top,o.select(t).node().attr("height",w)}}(),K&&q.each(function(t,e){t.forEach(function(t){t.times.forEach(function(t){p(tt(t.starting_time),Q,U),p(tt(t.ending_time),Q,U)})})}),W){p(tt(new Date),J)}}var c=["circle","rect","ellipse"],s=function(){},u=function(){},f=function(){},d=function(){},m=function(){},h=function(t){return t},g=0,p=function(){},x=function(){},v="bottom",k=null,w=null,y=null,b=null,_={format:r.timeFormat("%I %p"),tickTime:i.timeHour,tickInterval:1,tickSize:6,tickValues:null},T=!0,A="white",F={},B=a.scaleOrdinal(a.schemeCategory10),E=null,S="rect",z=0,q=0,C=0,I={left:30,right:30,top:30,bottom:30},M=5,Y=1,O=!1,V=!1,L=!1,N=!1,j=!1,H=20,Z=5,P=60,R=!0,D=!1,W=!1,X=!1,G={stroke:"stroke-dasharray",spacing:"4 10"},J={marginTop:25,marginBottom:0,width:1,color:B},K=!1,Q={marginTop:25,marginBottom:0,width:1,color:B},U="timeline-border-line",$=!1,tt=!1,et=!1,nt="timeline-xAxis",rt=function(t,e,n){return $&&ot(t,0,0),tt&&at(t),t.append("g").attr("class",nt).attr("transform","translate(0,"+n+")").call(e)},it=function(t){var e=z.getFullYear();z.getFullYear()!=C.getFullYear()&&(e=z.getFullYear()+"-"+C.getFullYear()),t.append("text").attr("transform","translate(20, 0)").attr("x",0).attr("y",14).attr("class","calendarYear").text(e)},at=function(t){var e=I.left-P,n=(k-I.left)/6,r=k-I.right-n+P,i=t.append("g").attr("class","axis").attr("transform","translate(0, 20)");et&&it(i),i.append("text").attr("transform","translate("+e+", 0)").attr("x",0).attr("y",14).attr("class","chevron").text("<").on("click",function(){return p(z,F)}),i.append("text").attr("transform","translate("+r+", 0)").attr("x",0).attr("y",14).attr("class","chevron").text(">").on("click",function(){return x(C,F)})},ot=function(t,e,n){t.insert("rect").attr("class","row-green-bar").attr("x",e).attr("width",k).attr("y",n).attr("height",H).attr("fill",A)},lt=function(t,e,n){t.append("g").attr("class","axis").attr("transform","translate(0,"+(I.top+(H+Z)*n)+")").attr(G.stroke,G.spacing).call(e.tickFormat("").tickSize(-(I.top+(H+Z)*(n-1)+3),0,0))},ct=function(t,e,n,r,i){var a=(H+Z)*t[e]+I.top;n.selectAll("svg").data(r).enter().insert("rect",":first-child").attr("class","row-green-bar").attr("x",j?0:I.left).attr("width",j?k:k-I.right-I.left).attr("y",a).attr("height",H).attr("fill",b instanceof Function?b(i,e):b)},st=function(t,e,n,r,i){var a=H+Z,l=I.top+a/2+a*(e[n]||1);t.append("text").attr("class","timeline-label").attr("transform","translate("+q+","+l+")").text(r?h(i.label):i.id).on("click",function(e,r){console.log("label click!");var a=o.mouse(this);t.append("rect").attr("id","clickpoint").attr("x",a[0]).attr("width",10).attr("height",H),d(e,n,i,a,xScale.invert(a[0]))})};return t.margin=function(e){return arguments.length?(I=e,t):I},t.orient=function(e){return arguments.length?(v=e,t):v},t.itemHeight=function(e){return arguments.length?(H=e,t):H},t.itemMargin=function(e){return arguments.length?(Z=e,t):Z},t.navMargin=function(e){return arguments.length?(P=e,t):P},t.height=function(e){return arguments.length?(w=e,t):w},t.width=function(e){return arguments.length?(k=e,t):k},t.display=function(e){return arguments.length&&-1!=c.indexOf(e)?(S=e,t):S},t.labelFormat=function(e){return arguments.length?(h=e,t):h},t.tickFormat=function(e){return arguments.length?(_=e,t):_},t.allowZoom=function(e){return arguments.length?(T=e,t):T},t.maxZoom=function(e){return arguments.length?(M=e,t):M},t.minZoom=function(e){return arguments.length?(Y=e,t):Y},t.hover=function(e){return arguments.length?(s=e,t):s},t.mouseover=function(e){return arguments.length?(u=e,t):u},t.mouseout=function(e){return arguments.length?(f=e,t):f},t.click=function(e){return arguments.length?(d=e,t):d},t.scroll=function(e){return arguments.length?(m=e,t):m},t.colors=function(e){return arguments.length?(B=e,t):B},t.beginning=function(e){return arguments.length?(z=e,t):z},t.ending=function(e){return arguments.length?(C=e,t):C},t.labelMargin=function(e){return arguments.length?(q=e,t):q},t.labelFloat=function(e){return arguments.length?(g=e,t):g},t.rotateTicks=function(e){return arguments.length?(V=e,t):V},t.stack=function(){return O=!O,t},t.relativeTime=function(){return L=!L,t},t.linearTime=function(){return N=!N,t},t.showBorderLine=function(){return K=!K,t},t.showBorderFormat=function(e){return arguments.length?(Q=e,t):Q},t.showBorderLineClass=function(e){return arguments.length?(U=e,t):U},t.showToday=function(){return W=!W,t},t.showTodayFormat=function(e){return arguments.length?(J=e,t):J},t.colorProperty=function(e){return arguments.length?(E=e,t):E},t.rowSeparators=function(e){return arguments.length?(y=e,t):y},t.background=function(e){return arguments.length?(b=e,t):b},t.showTimeAxis=function(){return R=!R,t},t.showAxisTop=function(){return D=!D,t},t.showAxisCalendarYear=function(){return et=!et,t},t.showTimeAxisTick=function(){return X=!X,t},t.fullLengthBackgrounds=function(){return j=!j,t},t.showTimeAxisTickFormat=function(e){return arguments.length?(G=e,t):G},t.showAxisHeaderBackground=function(e){return $=!$,e&&(A=e),t},t.xAxisClass=function(e){return arguments.length?(nt=e,t):nt},t.navigate=function(e,n){return arguments.length?(p=e,x=n,tt=!tt,t):[p,x]},t.version=function(){return"1.0.0"},t};t.timelines=c,Object.defineProperty(t,"__esModule",{value:!0})});