"use strict";(self.webpackChunk=self.webpackChunk||[]).push([["code-frequency-graph"],{"./web_src/js/components/RepoCodeFrequency.vue":function(S,p,s){s.d(p,{default:function(){return D}});var e=s("./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js"),r=s("./node_modules/@vue/shared/dist/shared.esm-bundler.js");const I=t=>(_pushScopeId("data-v-8f699cd6"),t=t(),_popScopeId(),t),m={class:"ui header tw-flex tw-items-center tw-justify-between"},v={class:"tw-flex ui segment main-graph"},f={key:0,class:"gt-tc tw-m-auto"},g={key:0},y={key:1,class:"text red"};function j(t,o,i,l,c,u){const h=(0,e.g2)("SvgIcon"),R=(0,e.g2)("ChartLine");return(0,e.uX)(),(0,e.CE)("div",null,[(0,e.Lk)("div",m,(0,r.toDisplayString)(t.isLoading?i.locale.loadingTitle:t.errorText?i.locale.loadingTitleFailed:`Code frequency over the history of ${t.repoLink.slice(1)}`),1),(0,e.Lk)("div",v,[t.isLoading||t.errorText!==""?((0,e.uX)(),(0,e.CE)("div",f,[t.isLoading?((0,e.uX)(),(0,e.CE)("div",g,[(0,e.bF)(h,{name:"octicon-sync",class:"tw-mr-2 job-status-rotate"}),(0,e.eW)(" "+(0,r.toDisplayString)(i.locale.loadingInfo),1)])):((0,e.uX)(),(0,e.CE)("div",y,[(0,e.bF)(h,{name:"octicon-x-circle-fill"}),(0,e.eW)(" "+(0,r.toDisplayString)(t.errorText),1)]))])):(0,e.Q3)("v-if",!0),t.data.length!==0?(0,e.bU)(t.data,()=>((0,e.uX)(),(0,e.Wv)(R,{key:1,data:u.toGraphData(t.data),options:u.getOptions()},null,8,["data","options"])),o,0):(0,e.Q3)("v-if",!0)])])}var w=s("./web_src/js/svg.js"),a=s("./node_modules/chart.js/dist/chart.js"),b=s("./web_src/js/modules/fetch.js"),k=s("./node_modules/vue-chartjs/dist/index.js"),d=s("./web_src/js/utils/time.js"),n=s("./web_src/js/utils/color.js"),L=s("./web_src/js/utils.js"),F=s("./node_modules/chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm.js");const{pageData:x}=window.config;a.t1.defaults.color=n.K.text,a.t1.defaults.borderColor=n.K.border,a.t1.register(a.UA,a.kc,a.s$,a.FN,a.No,a.dN);var C={components:{ChartLine:k.N1,SvgIcon:w.Ah},props:{locale:{type:Object,required:!0}},data:()=>({isLoading:!1,errorText:"",repoLink:x.repoLink||[],data:[]}),mounted(){this.fetchGraphData()},methods:{async fetchGraphData(){this.isLoading=!0;try{let t;do t=await(0,b.fG)(`${this.repoLink}/activity/code-frequency/data`),t.status===202&&await(0,L.yy)(1e3);while(t.status===202);if(t.ok){this.data=await t.json();const i=Object.values(this.data)[0].week,l=(0,d.Z1)(new Date),c=(0,d.Ex)(i,l);this.data=(0,d.a$)(c,this.data),this.errorText=""}else this.errorText=t.statusText}catch(t){this.errorText=t.message}finally{this.isLoading=!1}},toGraphData(t){return{datasets:[{data:t.map(o=>({x:o.week,y:o.additions})),pointRadius:0,pointHitRadius:0,fill:!0,label:"Additions",backgroundColor:n.K.additions,borderWidth:0,tension:.3},{data:t.map(o=>({x:o.week,y:-o.deletions})),pointRadius:0,pointHitRadius:0,fill:!0,label:"Deletions",backgroundColor:n.K.deletions,borderWidth:0,tension:.3}]}},getOptions(){return{responsive:!0,maintainAspectRatio:!1,animation:!0,plugins:{legend:{display:!0}},scales:{x:{type:"time",grid:{display:!1},time:{minUnit:"month"},ticks:{maxRotation:0,maxTicksLimit:12}},y:{ticks:{maxTicksLimit:6}}}}}}},T=s("./node_modules/vue-loader/dist/exportHelper.js"),D=(0,T.A)(C,[["render",j],["__scopeId","data-v-8f699cd6"]])}}]);
