import{a as e,n as t,t as n}from"./jsx-runtime-CutOxEx1.js";import{l as r}from"./chunk-6CSD65Y2-BjfinoX-.js";import{f as i,s as a,t as o}from"./taskStore-B6nkxJKo.js";import{n as s,t as c}from"./useTaskStore-rjS8TwDm.js";var l=e(t(),1),u=n(),d={running:`进行中`,done:`已完成`,failed:`失败`,cancelled:`已取消`};function f({status:e}){return e===`running`?(0,u.jsx)(`span`,{className:`td-dot td-dot-running`,"aria-hidden":!0}):(0,u.jsx)(`span`,{className:`td-dot td-dot-${e}`,"aria-hidden":!0})}function p(e){let t=e.finishedAt||Date.now(),n=Math.max(0,Math.round((t-e.startedAt)/1e3));return n<60?`${n}s`:`${Math.floor(n/60)}m${n%60}s`}function m(){let e=r(),t=c(),{unseenDone:n,running:m}=s(),[h,g]=(0,l.useState)(!1);if(t.length===0)return null;let _=t=>{i(t.id),g(!1);try{e(t.path)}catch{}},v=m+n;return(0,u.jsxs)(`div`,{className:`td-root`,children:[h?(0,u.jsxs)(`div`,{className:`td-panel`,role:`dialog`,"aria-label":`后台任务`,children:[(0,u.jsxs)(`div`,{className:`td-panel-head`,children:[(0,u.jsx)(`span`,{className:`td-panel-title`,children:`后台任务`}),(0,u.jsx)(`button`,{type:`button`,className:`td-close`,onClick:()=>g(!1),"aria-label":`收起`,children:(0,u.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,children:[(0,u.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`}),(0,u.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`})]})})]}),(0,u.jsx)(`div`,{className:`td-list`,children:t.map(e=>(0,u.jsxs)(`div`,{className:`td-item td-item-${e.status}`,children:[(0,u.jsx)(f,{status:e.status}),(0,u.jsxs)(`button`,{type:`button`,className:`td-item-main`,onClick:()=>_(e),title:`回到${e.toolLabel}`,children:[(0,u.jsx)(`span`,{className:`td-item-tool`,children:e.toolLabel}),(0,u.jsx)(`span`,{className:`td-item-title`,children:e.title||d[e.status]}),(0,u.jsxs)(`span`,{className:`td-item-meta`,children:[d[e.status],` · `,p(e),typeof e.pointsCharged==`number`&&e.pointsCharged>0?` · ${e.pointsCharged} 积分`:``]}),e.status===`failed`&&e.error?(0,u.jsx)(`span`,{className:`td-item-err`,children:e.error}):null]}),e.status===`running`?(0,u.jsx)(`button`,{type:`button`,className:`td-item-action`,onClick:()=>o(e.id),title:`取消任务`,children:`取消`}):(0,u.jsx)(`button`,{type:`button`,className:`td-item-action`,onClick:()=>a(e.id),title:`移除`,"aria-label":`移除`,children:(0,u.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,children:[(0,u.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`}),(0,u.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`})]})})]},e.id))})]}):null,(0,u.jsxs)(`button`,{type:`button`,className:`td-fab${m>0?` td-fab-running`:``}`,onClick:()=>g(e=>!e),"aria-label":`后台任务`,children:[m>0?(0,u.jsx)(`span`,{className:`td-spinner`,"aria-hidden":!0}):(0,u.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`20`,height:`20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,u.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,u.jsx)(`path`,{d:`M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11`})]}),v>0?(0,u.jsx)(`span`,{className:`td-badge`,children:v>9?`9+`:v}):null]})]})}export{m as default};