function LineChart(t){const a=d3.format(",.0f"),e=Object.assign({container:"",width:400,height:250,marginTop:35,marginBottom:30,marginLeft:5,marginRight:5,format:a,chartType:""},t);let n,i,r,l,o,s,p;function d(){n=d3.select(e.container).html(""),function(){const t=n.node().getBoundingClientRect();t.width&&(e.width=t.width);t.height&&(e.height=t.height);i=e.width-e.marginLeft-e.marginRight,r=e.height-e.marginTop-e.marginBottom}(),function(){if(s=n.append("svg").attr("width",e.width).attr("height",e.height),p=s.append("g").attr("transform",`translate(${e.marginLeft}, ${e.marginTop})`),"all"!==dataKind&&"supply_demand_ratio"===e.chartType)s.html("").append("text").text("N/A").attr("text-anchor","middle").attr("x",e.width/2).attr("y",e.height/2).attr("dy","0.35em").attr("class","aver-number")}(),l=d3.scale.linear().domain([d3.min(e.data.flatMap(t=>t.line.map(t=>t.x))),d3.max(e.data.flatMap(t=>t.line.map(t=>t.x)))]).range([0,i]),o="supply_demand_ratio"!==e.chartType?d3.scale.linear().domain([0,1]).range([r-60,0]):d3.scale.linear().domain([d3.min(e.data.flatMap(t=>t.line.map(t=>t.y))),d3.max(e.data.flatMap(t=>t.line.map(t=>t.y)))]).range([r-40,0]),function(){const t=l.ticks(),a=d3.svg.axis().scale(l).tickSize(.5).orient(["bottom"]);p.append("g").attr("class","xAxis").attr("transform",`translate(0, ${r})`).call(a).call(a=>{a.selectAll(".tick text").html((a,e)=>0===e||e===t.length-1?a:"").style("text-anchor",(a,e)=>e===t.length-1?"end":0===e?"start":"middle").attr("fill","#5C6268").attr("font-size",14).attr("font-family","Inter")})}(),function(){const t=d3.svg.line().x(function(t){return l(t.x)}).y(function(t){return o("supply_demand_ratio"!==e.chartType?t.ratio:t.y)}).interpolate("linear");p.selectAll("g.line-group").data(e.data).enter().append("g").attr("class","line-group").append("path").attr("d",a=>t(a.line)).attr("fill","none").attr("stroke-dasharray",t=>t.strokeDasharray).attr("stroke",t=>t.stroke).attr("stroke-width",t=>"National"!==t.name?2:1)}(),function(){const t=e.data.map((t,a)=>{let n=!1;const i=a?e.data[a-1]:e.data[a+1];return i&&(n=Math.abs(o(i.line[i.line.length-1].y)-o(t.line[t.line.length-1].y))<15),{name:t.name,isDataClose:n,compareData:i?i.line[i.line.length-1].y:null,points:[t.line[0],t.line[t.line.length-1]],allPoints:t.line}}),a=p.selectAll("g.circle-group").data(t).enter().append("g").attr("class","circle-group"),n=a.selectAll("circle").data(t=>t.allPoints).enter().append("circle").attr("class","year-circles").style("opacity",t=>2010!==t.x&&2024!==t.x?0:1).attr("fill",t=>0!==t.index?"#009AF1":"#00000").attr("transform",t=>`translate(${l(t.x)}, ${o("supply_demand_ratio"!==e.chartType?t.ratio:t.y)})`).attr("r",t=>2010===t.x||2024===t.x?2.5:15),i=t[0].allPoints.filter(t=>2010===t.x)[0].y,r=t[1]?t[1].allPoints.filter(t=>2010===t.x)[0].y:"";n.each(function(t){this._tippy&&this._tippy.destroy(),2010!==t.x&&2024!==t.x&&tippy(this,{content:`<div> \n          ${"supply_demand_ratio"!==e.chartType?t.y-(0===t.index?i:r)/t.y>0?"+"+Math.abs(e.format((t.y-(0===t.index?i:r))/t.y*100))+"%":"-"+Math.abs(e.format((t.y-(0===t.index?i:r))/t.y*100))+"%":e.format(t.y)} - ${t.x}\n            </div>\n        </div>`,allowHTML:!0,arrow:!1})}),a.selectAll("text").data(t).enter().append("text").attr("fill",t=>"National"!==t.name?"#009AF1":"#00000").attr("font-size",17).attr("font-family","Inter").attr("font-weight",400).attr("dy","0.35em").text(t=>"supply_demand_ratio"!==e.chartType?(t.points[1].y-t.points[0].y)/t.points[1].y>0?"+"+Math.abs(e.format((t.points[1].y-t.points[0].y)/t.points[1].y*100))+"%":"-"+Math.abs(e.format((t.points[1].y-t.points[0].y)/t.points[1].y*100))+"%":e.format(t.points[1].y)).attr("transform",t=>{let a=0;return t.isDataClose&&t.compareData&&(a=t.compareData>t.points[1].y?20:-20),`translate(${l(t.points[1].x)+5}, ${o("supply_demand_ratio"!==e.chartType?t.points[1].ratio:t.points[1].y)+("National"===t.name?25:-25)})`}).attr("text-anchor","end")}()}return d(),{resize:d}}