import{B as e,E as t,O as n,St as r,Z as i,c as a,h as o,l as s,m as c,p as l,rt as u,s as d,u as f}from"./runtime-core.esm-bundler-A2Q6NZG4.js";import{t as p}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{n as m}from"./KsInlineMessage-t_pxFiJO.js";import{o as h}from"./components-KD31URIh.js";import{t as g}from"./DataGridShell-DYZf00at.js";import{t as _}from"./BatchOperationsPageV2-CKYquI9Y.js";import{i as v,r as y,t as b}from"./financial-BRiI2vgB.js";var x={key:0},S={class:`status-header`},C={class:`status-grid`},w={class:`stat`},T={class:`value`},E={class:`stat`},D={class:`value error`},O={class:`stat`},k={class:`value`},A={key:0,class:`stat`},j={class:`value`},M={key:0,class:`error-section`},N={key:1,class:`hint`},P=p(o({__name:`IngestionStatus`,setup(o){let p=i(null),P=i([]),F=i(!0),I=i(null),L=i(`LOADING`),R=[{field:`jobId`,header:`Job ID`,formatter:e=>String(e).substring(0,8)},{field:`status`,header:`상태`},{field:`rowsProcessed`,header:`처리 행`,formatter:e=>v(e,0)},{field:`durationSeconds`,header:`소요 시간`,formatter:e=>e?`${e}초`:`—`},{field:`completedAt`,header:`완료 시각`,formatter:e=>e?b(e):`—`}];function z(e){let t=e.toLowerCase();return t===`completed`?`success`:t===`failed`?`danger`:t===`running`?`info`:`warning`}let B=async()=>{try{let e=await fetch(`/api/market/ingest/latest`,{headers:{"X-KArtSell-User":`ingestion-user`,"X-KArtSell-Role":`DataAdmin`}});if(e.ok)p.value=await e.json();else if(e.status===404)p.value=null;else throw Error(`API error: ${e.status}`)}catch(e){console.error(`Failed to fetch latest job:`,e),p.value=null}},V=async()=>{try{let e=await fetch(`/api/market/ingest/history?limit=10`,{headers:{"X-KArtSell-User":`ingestion-user`,"X-KArtSell-Role":`DataAdmin`}});e.ok&&(P.value=await e.json())}catch(e){console.error(`Failed to fetch recent jobs:`,e),I.value=`수집 이력을 불러오지 못했습니다.`}finally{F.value=!1,L.value=`READY`}};function H(){L.value=`LOADING`,Promise.all([B(),V()]).finally(()=>{L.value=`READY`})}t(()=>{B(),V();let e=setInterval(()=>{(p.value?.status===`Running`||p.value?.status===`Queued`)&&B()},1e4);return()=>clearInterval(e)});let U=e=>{let t=e.rowsProcessed+e.rowsFailed+(e.rowsSkipped||0);return t===0?0:Math.round(e.rowsProcessed/t*100)};return(t,i)=>(n(),a(_,{title:`시장 데이터 수집 현황`,subtitle:`데이터 수집 작업 상태를 모니터링합니다.`,state:L.value},{actions:e(()=>[c(u(m),{severity:`secondary`,label:`새로고침`,onClick:H})]),timeline:e(()=>[p.value?(n(),f(`div`,x,[d(`div`,S,[d(`h2`,null,`Job `+r(p.value.jobId.substring(0,8)),1),c(u(h),{value:p.value.status,severity:z(p.value.status)},null,8,[`value`,`severity`])]),d(`div`,C,[d(`div`,w,[i[0]||=d(`span`,{class:`label`},`처리된 행`,-1),d(`span`,T,r(u(v)(p.value.rowsProcessed,0)),1)]),d(`div`,E,[i[1]||=d(`span`,{class:`label`},`실패한 행`,-1),d(`span`,D,r(u(v)(p.value.rowsFailed,0)),1)]),d(`div`,O,[i[2]||=d(`span`,{class:`label`},`품질 점수`,-1),d(`span`,k,r(u(y)(U(p.value)/100,0)),1)]),p.value.durationSeconds?(n(),f(`div`,A,[i[3]||=d(`span`,{class:`label`},`소요 시간`,-1),d(`span`,j,r(p.value.durationSeconds)+`초`,1)])):s(``,!0)]),p.value.errorMessage?(n(),f(`p`,M,[i[4]||=d(`strong`,null,`오류:`,-1),l(` `+r(p.value.errorMessage),1)])):s(``,!0)])):(n(),f(`p`,N,`수집 상태를 불러오는 중입니다...`))]),records:e(()=>[c(g,{rows:P.value,columns:R,"empty-message":`최근 수집 이력이 없습니다.`},null,8,[`rows`])]),reprocess:e(()=>[...i[5]||=[d(`p`,{class:`hint`},`진행 중이거나 대기 중인 작업이 있으면 10초 간격으로 자동 새로고침됩니다.`,-1)]]),_:1},8,[`state`]))}}),[[`__scopeId`,`data-v-1dbdbefb`]]);export{P as default};