import{L as e,N as t,a as n,b as r,c as i,d as a,f as o,k as s,o as c,rt as l,s as u,u as d,v as f}from"./runtime-core.esm-bundler.-wy0QUpZ.js";import{v as p}from"./utils.CNePm0t_.js";import{f as m,h,l as g,m as _,n as v,r as y,t as b}from"./index.CzQRfW04.js";import{a as x,c as S,i as C,l as w,n as T,o as E,s as D,u as O}from"./chartjs-adapter-dayjs-4.esm.BNunhXdr.js";var k={class:`ui header tw-flex tw-items-center tw-justify-between`},A={class:`tw-flex ui segment main-graph`},j={key:0,class:`tw-m-auto`},M={key:0},N={key:1,class:`tw-text-red`},P=m(o({__name:`RepoCodeFrequency`,props:{locale:{}},setup(o){let{pageData:m}=window.config;C.defaults.color=g.text,C.defaults.borderColor=g.border,C.register(S,E,O,D,x,w);let P=t(!1),F=t(``),I=m.repoLink,L=t([]);f(()=>{R()});async function R(){P.value=!0;try{let e;do e=await _(`${I}/activity/code-frequency/data`),e.status===202&&await p(1e3);while(e.status===202);if(e.ok){let t=await e.json(),n=Object.values(t)[0].week;L.value=b(y(n,v(new Date)),t),F.value=``}else F.value=e.statusText}catch(e){F.value=e.message}finally{P.value=!1}}function z(e){return{datasets:[{data:e.map(e=>({x:e.week,y:e.additions})),pointRadius:0,pointHitRadius:0,fill:!0,label:`Additions`,backgroundColor:g.additions,borderWidth:0,tension:.3},{data:e.map(e=>({x:e.week,y:-e.deletions})),pointRadius:0,pointHitRadius:0,fill:!0,label:`Deletions`,backgroundColor:g.deletions,borderWidth:0,tension:.3}]}}let B={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!0}},scales:{x:{type:`time`,grid:{display:!1},time:{minUnit:`month`},ticks:{maxRotation:0,maxTicksLimit:12}},y:{ticks:{maxTicksLimit:6}}}};return(t,f)=>(r(),i(`div`,null,[n(`div`,k,l(P.value?o.locale.loadingTitle:F.value?o.locale.loadingTitleFailed:`Code frequency over the history of ${e(I).slice(1)}`),1),n(`div`,A,[P.value||F.value!==``?(r(),i(`div`,j,[P.value?(r(),i(`div`,M,[a(e(h),{name:`gitea-running`,class:`tw-mr-2 rotate-clockwise`}),d(` `+l(o.locale.loadingInfo),1)])):(r(),i(`div`,N,[a(e(h),{name:`octicon-x-circle-fill`}),d(` `+l(F.value),1)]))])):u(``,!0),L.value.length===0?u(``,!0):s(L.value,()=>(r(),c(e(T),{key:1,data:z(L.value),options:B},null,8,[`data`])),f,0)])]))}}),[[`__scopeId`,`data-v-7ab1b32b`]]);export{P as default};
//# sourceMappingURL=RepoCodeFrequency.CjdYylyh.js.map