import{A as e,L as t,N as n,P as r,a as i,b as a,c as o,d as s,f as c,o as l,rt as u,s as d,u as f,v as p}from"./runtime-core.esm-bundler.BCIfMFaf.js";import{x as m}from"./colord.BTI3XySM.js";import{g as h,h as g,l as _,n as v,p as y,r as b,t as x,u as S}from"./index.CEybYocr.js";import{c as C,f as w,i as T,o as E,r as D,t as O}from"./chartjs-adapter-dayjs-4.esm.C9oU2YB_.js";var k={class:`ui header`},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=y(c({__name:`RepoRecentCommits`,props:{locale:{}},setup(c){let{pageData:y}=window.config;T.defaults.color=_.text,T.defaults.borderColor=_.border,T.register(C,E,D,w);let P=r(!1),F=r(``),I=y.repoLink,L=n([]);p(()=>{R()});async function R(){P.value=!0;try{let e;do e=await g(`${I}/activity/recent-commits/data`),e.status===202&&await m(1e3);while(e.status===202);if(e.ok){let t=await e.json(),n=Object.values(t)[0].week;L.value=x(b(n,v(new Date)),t).slice(-52),F.value=``}else F.value=e.statusText}catch(e){F.value=S(e)}finally{P.value=!1}}function z(e){return{datasets:[{data:e.map(e=>({x:e.week,y:e.commits})),label:`Commits`,backgroundColor:_.commits,borderWidth:0,tension:.3}]}}let B={responsive:!0,maintainAspectRatio:!1,scales:{x:{type:`time`,grid:{display:!1},time:{minUnit:`week`},ticks:{maxRotation:0,maxTicksLimit:52}},y:{ticks:{maxTicksLimit:6}}}};return(n,r)=>(a(),o(`div`,null,[i(`div`,k,u(P.value?c.locale.loadingTitle:F.value?c.locale.loadingTitleFailed:`Number of commits in the past year`),1),i(`div`,A,[P.value||F.value!==``?(a(),o(`div`,j,[P.value?(a(),o(`div`,M,[s(t(h),{name:`gitea-running`,class:`tw-mr-2 rotate-clockwise`}),f(` `+u(c.locale.loadingInfo),1)])):(a(),o(`div`,N,[s(t(h),{name:`octicon-x-circle-fill`}),f(` `+u(F.value),1)]))])):d(``,!0),L.value.length===0?d(``,!0):e(L.value,()=>(a(),l(t(O),{key:1,data:z(L.value),options:B},null,8,[`data`])),r,0)])]))}}),[[`__scopeId`,`data-v-3435bdc9`]]);export{P as default};
//# sourceMappingURL=RepoRecentCommits.DVgbMzrQ.js.map