import{Ct as e,D as t,T as n,Y as r,bt as i,h as a,k as o,l as s,p as c,r as l,s as u,u as d}from"./runtime-core.esm-bundler-DJThmTxA.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(a({__name:`IngestionStatus`,setup(a){let f=r(null),A=r([]),j=r(!0),M=r(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}};n(()=>{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(n,r)=>(t(),d(`div`,p,[r[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?(t(),d(`div`,h,[u(`div`,g,[u(`h2`,null,`Job `+e(f.value.jobId.substring(0,8)),1),u(`span`,{class:i([`status-badge`,`status-${f.value.status.toLowerCase()}`])},e(f.value.status),3)]),u(`div`,_,[u(`div`,v,[r[0]||=u(`span`,{class:`label`},`Rows Processed`,-1),u(`span`,y,e(f.value.rowsProcessed.toLocaleString()),1)]),u(`div`,b,[r[1]||=u(`span`,{class:`label`},`Rows Failed`,-1),u(`span`,x,e(f.value.rowsFailed),1)]),u(`div`,S,[r[2]||=u(`span`,{class:`label`},`Quality Score`,-1),u(`span`,C,e(F(f.value))+`%`,1)]),f.value.durationSeconds?(t(),d(`div`,w,[r[3]||=u(`span`,{class:`label`},`Duration`,-1),u(`span`,T,e(f.value.durationSeconds)+`s`,1)])):s(``,!0)]),f.value.errorMessage?(t(),d(`div`,E,[r[4]||=u(`strong`,null,`Error:`,-1),c(` `+e(f.value.errorMessage),1)])):s(``,!0)])):(t(),d(`div`,D,[...r[5]||=[u(`p`,null,`Fetching ingestion status...`,-1)]])),u(`div`,O,[r[7]||=u(`h3`,null,`Recent Ingestions`,-1),u(`table`,k,[r[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,[(t(!0),d(l,null,o(A.value,(n,r)=>(t(),d(`tr`,{key:r,class:i(`status-${n.status.toLowerCase()}`)},[u(`td`,null,e(n.jobId.substring(0,8)),1),u(`td`,null,[u(`span`,{class:i([`status-badge`,`status-${n.status.toLowerCase()}`])},e(n.status),3)]),u(`td`,null,e(n.rowsProcessed),1),u(`td`,null,e(n.durationSeconds?`${n.durationSeconds}s`:`—`),1),u(`td`,null,e(n.completedAt?new Date(n.completedAt).toLocaleDateString():`—`),1)],2))),128))])])])])]))}}),[[`__scopeId`,`data-v-d0303ae1`]]);export{A as default};