import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{U as t,f as n,k as r,mt as i,p as a,s as o,u as s,x as c,y as l,z as u}from"./antd-NNbrPHoG.js";import{et as d,h as f}from"./antd-icons-BW4cpGcx.js";import{t as p}from"./i18n-BuHCC44e.js";import{n as m}from"./api-BW0YTlHd.js";import{t as h}from"./react-vendor-nIJYBVRh.js";import{t as g}from"./ConsolePage-BgvAIq9_.js";import{t as _}from"./PageToolbar-Dmyk1Tio.js";import{n as v,r as y,t as b}from"./useInitialTableLoading-adK-LcHZ.js";var x=e(i(),1),S=h(),{Text:C}=o,w=[`Pending`,`DeadLetter`,`RetryScheduled`,`Inflight`];function T(e){return e===`Pending`||e===`RetryScheduled`?`gold`:e===`DeadLetter`?`red`:e===`Succeeded`?`green`:e===`Inflight`?`blue`:`default`}function E(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MiB`:e>=1024?`${(e/1024).toFixed(1)} KiB`:`${e} B`}function D(){let{t:e}=p(),[i,o]=(0,x.useState)([]),[h,D]=(0,x.useState)(`Pending`),[O,k]=(0,x.useState)(!1),[A,j]=(0,x.useState)(null),M=b(O),N=(0,x.useCallback)(async()=>{k(!0);try{o(y(await m.listRuleOutbox({status:h,limit:500}),e=>e.updated_at_ms))}finally{k(!1)}},[h]);(0,x.useEffect)(()=>{N()},[N]);let P=(0,x.useMemo)(()=>w.map(t=>({value:t,label:e(`ruleOutbox.statuses.${t}`)})),[e]),F=(0,x.useCallback)(t=>e(`ruleOutbox.statuses.${t}`),[e]),I=(0,x.useCallback)(async t=>{j(t.id);try{let n=await m.retryRuleOutbox(t.id);n.success?c.success(e(`ruleOutbox.retrySuccess`)):c.error(n.error||e(`ruleOutbox.retryFailed`)),await N()}finally{j(null)}},[N,e]),L=(0,x.useCallback)(async t=>{j(t.id);try{await m.deleteRuleOutbox(t.id),c.success(e(`ruleOutbox.deleteSuccess`)),await N()}finally{j(null)}},[N,e]),R=(0,x.useMemo)(()=>[{title:e(`ruleOutbox.rule`),dataIndex:`rule_name`,width:220,render:(e,t)=>(0,S.jsxs)(r,{direction:`vertical`,size:0,children:[(0,S.jsx)(C,{strong:!0,children:t.rule_name||t.rule_id}),(0,S.jsx)(C,{type:`secondary`,style:{fontSize:12},children:t.rule_id})]})},{title:e(`ruleOutbox.action`),dataIndex:`action_type`,width:160,render:(e,t)=>(0,S.jsxs)(r,{direction:`vertical`,size:0,children:[(0,S.jsx)(C,{children:t.action_type}),(0,S.jsx)(C,{type:`secondary`,style:{fontSize:12},children:t.datasource_id||`-`})]})},{title:e(`ruleOutbox.status`),dataIndex:`status`,width:140,render:(e,t)=>(0,S.jsxs)(r,{direction:`vertical`,size:0,children:[(0,S.jsx)(n,{color:T(e),children:F(e)}),(0,S.jsxs)(C,{type:`secondary`,style:{fontSize:12},children:[t.attempts,`/`,t.max_attempts]})]})},{title:e(`ruleOutbox.payload`),dataIndex:`payload_bytes`,width:120,render:e=>E(e)},{title:e(`ruleOutbox.error`),dataIndex:`last_error`,ellipsis:!0,render:e=>e||`-`},{title:e(`ruleOutbox.updatedAt`),dataIndex:`updated_at_ms`,width:190,render:e=>v(e)},{title:e(`common.actions`),key:`actions`,width:180,fixed:`right`,render:(t,n)=>(0,S.jsxs)(r,{children:[(0,S.jsx)(u,{size:`small`,icon:(0,S.jsx)(f,{}),loading:A===n.id,onClick:()=>void I(n),children:e(`ruleOutbox.retry`)}),(0,S.jsx)(l,{title:e(`common.deleteConfirm`),okText:e(`common.remove`),cancelText:e(`common.cancel`),onConfirm:()=>void L(n),children:(0,S.jsx)(u,{size:`small`,danger:!0,icon:(0,S.jsx)(s,{}),loading:A===n.id})})]})}],[A,L,F,I,e]);return(0,S.jsx)(g,{title:e(`ruleOutbox.title`),actions:(0,S.jsxs)(_,{wrap:!0,children:[(0,S.jsx)(t,{value:h,options:P,style:{width:180},onChange:D}),(0,S.jsx)(u,{icon:(0,S.jsx)(d,{}),onClick:()=>void N(),loading:O,children:e(`common.refresh`)})]}),children:(0,S.jsx)(a,{rowKey:`id`,columns:R,dataSource:i,loading:M,locale:{emptyText:e(`ruleOutbox.empty`)},pagination:{pageSize:20,showSizeChanger:!0},scroll:{x:1180}})})}export{D as default};