import{A as e,E as t,O as n,St as r,Tt as i,Z as a,h as o,l as s,p as c,r as l,s as u,u as d}from"./runtime-core.esm-bundler-BhgiVlyD.js";import{t as f}from"./_plugin-vue_export-helper-BDNMzG2s.js";var p={class:`ingestion-status`},m={class:`content`},h={key:0,class:`status-card`},g={class:`status-header`},_={class:`status-grid`},v={class:`stat`},y={class:`value`},b={class:`stat`},x={class:`value error`},S={class:`stat`},C={class:`value`},w={key:0,class:`stat`},T={class:`value`},E={key:0,class:`error-section`},D={key:1,class:`loading`},O={class:`history-section`},k={class:`history-table`},A=f(o({__name:`IngestionStatus`,setup(o){let f=a(null),A=a([]),j=a(!0),M=a(null),N=async()=>{try{let e=await fetch(`/api/market/ingest/latest`,{headers:{"X-KArtSell-User":`ingestion-user`,"X-KArtSell-Role":`DataAdmin`}});if(e.ok)f.value=await e.json();else if(e.status===404)f.value=null;else throw Error(`API error: ${e.status}`)}catch(e){console.error(`Failed to fetch latest job:`,e),f.value=null}},P=async()=>{try{let e=await fetch(`/api/market/ingest/history?limit=10`,{headers:{"X-KArtSell-User":`ingestion-user`,"X-KArtSell-Role":`DataAdmin`}});e.ok&&(A.value=await e.json())}catch(e){console.error(`Failed to fetch recent jobs:`,e),M.value=`Failed to load job history`}finally{j.value=!1}};t(()=>{N(),P();let e=setInterval(()=>{(f.value?.status===`Running`||f.value?.status===`Queued`)&&N()},1e4);return()=>clearInterval(e)});let F=e=>{let t=e.rowsProcessed+e.rowsFailed+(e.rowsSkipped||0);return t===0?0:Math.round(e.rowsProcessed/t*100)};return(t,a)=>(n(),d(`div`,p,[a[8]||=u(`div`,{class:`header`},[u(`h1`,null,`Market Data Ingestion`),u(`p`,{class:`subtitle`},`Monitor data collection status`)],-1),u(`div`,m,[f.value?(n(),d(`div`,h,[u(`div`,g,[u(`h2`,null,`Job `+i(f.value.jobId.substring(0,8)),1),u(`span`,{class:r([`status-badge`,`status-${f.value.status.toLowerCase()}`])},i(f.value.status),3)]),u(`div`,_,[u(`div`,v,[a[0]||=u(`span`,{class:`label`},`Rows Processed`,-1),u(`span`,y,i(f.value.rowsProcessed.toLocaleString()),1)]),u(`div`,b,[a[1]||=u(`span`,{class:`label`},`Rows Failed`,-1),u(`span`,x,i(f.value.rowsFailed),1)]),u(`div`,S,[a[2]||=u(`span`,{class:`label`},`Quality Score`,-1),u(`span`,C,i(F(f.value))+`%`,1)]),f.value.durationSeconds?(n(),d(`div`,w,[a[3]||=u(`span`,{class:`label`},`Duration`,-1),u(`span`,T,i(f.value.durationSeconds)+`s`,1)])):s(``,!0)]),f.value.errorMessage?(n(),d(`div`,E,[a[4]||=u(`strong`,null,`Error:`,-1),c(` `+i(f.value.errorMessage),1)])):s(``,!0)])):(n(),d(`div`,D,[...a[5]||=[u(`p`,null,`Fetching ingestion status...`,-1)]])),u(`div`,O,[a[7]||=u(`h3`,null,`Recent Ingestions`,-1),u(`table`,k,[a[6]||=u(`thead`,null,[u(`tr`,null,[u(`th`,null,`Job ID`),u(`th`,null,`Status`),u(`th`,null,`Rows`),u(`th`,null,`Duration`),u(`th`,null,`Completed`)])],-1),u(`tbody`,null,[(n(!0),d(l,null,e(A.value,(e,t)=>(n(),d(`tr`,{key:t,class:r(`status-${e.status.toLowerCase()}`)},[u(`td`,null,i(e.jobId.substring(0,8)),1),u(`td`,null,[u(`span`,{class:r([`status-badge`,`status-${e.status.toLowerCase()}`])},i(e.status),3)]),u(`td`,null,i(e.rowsProcessed),1),u(`td`,null,i(e.durationSeconds?`${e.durationSeconds}s`:`—`),1),u(`td`,null,i(e.completedAt?new Date(e.completedAt).toLocaleDateString():`—`),1)],2))),128))])])])])]))}}),[[`__scopeId`,`data-v-d0303ae1`]]);export{A as default};