import{Ct as e,Tt as t}from"./vue-vendor-DMUmTARL.js";import{n}from"./index-y6crcKNt.js";var r={paramsSerializer:{indexes:null}},i=e=>n({url:`/api/admin/download/log/top/ip`,method:`get`,data:e,config:r}),a=e=>n({url:`/api/admin/download/log/top/referer`,method:`get`,data:e,config:r}),o=e=>n({url:`/api/admin/download/log/top/file`,method:`get`,data:e,config:r}),s=e=>n({url:`/api/admin/download/log/stats/overview`,method:`get`,data:e,config:r}),c=e=>n({url:`/api/admin/download/log/stats/trend`,method:`get`,data:e,config:r}),l=e=>n({url:`/api/admin/download/log/stats/top/storage`,method:`get`,data:e,config:r}),u=e=>n({url:`/api/admin/download/log/stats/scenario`,method:`get`,data:e,config:r}),d=e=>n({url:`/api/admin/download/log/stats/top/share`,method:`get`,data:e,config:r}),f=e=>n({url:`/api/admin/download/log/stats/client`,method:`get`,data:e,config:r}),p=e=>String(e).padStart(2,`0`);function m(e,t){if(!t||t.length<2)return[];let n=t[0]?.slice(0,10),r=t[t.length-1]?.slice(0,10);if(!n||!r)return[];if(e===`hour`)return Array.from({length:24},(e,t)=>`${n} ${p(t)}:00`);let i=new Date(`${n}T00:00:00`),a=new Date(`${r}T00:00:00`);if(Number.isNaN(i.getTime())||Number.isNaN(a.getTime())||i>a)return[];let o=[];for(let e=0;i<=a&&e<366;e++)o.push(`${i.getFullYear()}-${p(i.getMonth()+1)}-${p(i.getDate())}`),i.setDate(i.getDate()+1);return o}function h(e,t){if(t.length===0||e.length===0)return e;let n=[...new Set(e.map(e=>e.category).filter(e=>e!=null))];if(n.length===0)return e;let r=new Map;for(let t of e)t.category!=null&&r.set(`${t.bucket}__${t.category}`,t.count);let i=[];for(let e of t)for(let t of n)i.push({bucket:e,category:t,count:r.get(`${e}__${t}`)??0});return i}function g(){let n=e({top:20,searchDate:[]}),r=t(`day`),p=t(`file`),g=t(!0),_=t(!0),v=t({}),y=t([]),b=t([]),x=t([]),S=t([]),C=t([]),w=t(!1),T=t(!1),E=t(!1),D=t(!1),O=t(!1),k=t(!1),A=t(!1),j=t(!1),M=t(!1),N=t(!1),P=t(!1),F=t(!1),I=async()=>{w.value=!0,A.value=!1;try{v.value=(await s({...n})).data||{}}catch(e){v.value={},A.value=!0,console.error(`[download-stats] overview failed`,e)}finally{w.value=!1}},L=async()=>{T.value=!0,j.value=!1;try{let e=(await c({...n,granularity:r.value})).data||[];y.value=g.value?h(e,m(r.value,n.searchDate)):e}catch(e){y.value=[],j.value=!0,console.error(`[download-stats] trend failed`,e)}finally{T.value=!1}},R=async()=>{E.value=!0,M.value=!1;try{b.value=(await l({...n})).data||[]}catch(e){b.value=[],M.value=!0,console.error(`[download-stats] storage failed`,e)}finally{E.value=!1}},z=async()=>{D.value=!0,N.value=!1;try{let e;e=p.value===`share`?d:p.value===`ip`?i:p.value===`referer`?a:o,x.value=(await e({...n})).data||[]}catch(e){x.value=[],N.value=!0,console.error(`[download-stats] top failed`,e)}finally{D.value=!1}},B=async()=>{O.value=!0,P.value=!1;try{S.value=(await u({...n})).data||[]}catch(e){S.value=[],P.value=!0,console.error(`[download-stats] scenario failed`,e)}finally{O.value=!1}},V=async()=>{k.value=!0,F.value=!1;try{C.value=(await f({...n})).data||[]}catch(e){C.value=[],F.value=!0,console.error(`[download-stats] client stats failed`,e)}finally{k.value=!1}};return{searchParam:n,trendGranularity:r,currentType:p,trendFillZero:g,trendSmooth:_,overviewData:v,trendData:y,storageData:b,topData:x,scenarioData:S,clientData:C,overviewLoading:w,trendLoading:T,storageLoading:E,topLoading:D,scenarioLoading:O,clientLoading:k,overviewError:A,trendError:j,storageError:M,topError:N,scenarioError:P,clientError:F,loadOverviewData:I,loadTrendData:L,loadStorageData:R,loadTopData:z,loadScenarioData:B,loadClientData:V,loadAll:async()=>{await Promise.allSettled([I(),L(),R(),z(),B(),V()])}}}var _=()=>n({url:`/api/admin/dashboard/overview`,method:`get`,config:{showDefaultMsg:!1}}),v=()=>n({url:`/api/admin/dashboard/kpi-detail`,method:`get`,config:{showDefaultMsg:!1}}),y=()=>n({url:`/api/admin/dashboard/security-overview`,method:`get`,config:{showDefaultMsg:!1}}),b=e=>n({url:`/api/admin/config/dashboard-order`,method:`put`,data:{dashboardSectionOrder:e}}),x=e=>n({url:`/api/admin/config/download-trend-fill-zero`,method:`put`,data:{downloadTrendFillZero:e}}),S=e=>n({url:`/api/admin/config/download-trend-view`,method:`put`,data:e});export{x as a,s as c,b as i,v as n,S as o,y as r,g as s,_ as t};