(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1693],{23008:(e,s,i)=>{"use strict";i.r(s),i.d(s,{default:()=>m});var r=i(90637),n=i(60857),a=i(2911),t=i(27639),o=i(17522),c=i(83035),l=i(20708),d=i(95918),u=i(50234),h=i(85044),x=i(56372),p=i(97329),f=i(41151),y=i(68126),j=i(20135);function m(){let{t:e}=(0,a.Bd)(),s=(0,j.J)(),i=(0,y.sp)(),{getBucketLifecycleConfiguration:m,deleteBucketLifecycle:N,putBucketLifecycleConfiguration:C}=(0,p.o)(),[g,D]=(0,n.useState)(null),[T,b]=(0,n.useState)([]),[k,v]=(0,n.useState)(!1),[S,E]=(0,n.useState)(!1),F=(0,n.useCallback)(async()=>{if(!g)return void b([]);v(!0);try{let e=await m(g),s=[...e?.Rules??[]].map(e=>e).sort((e,s)=>(e.ID??"").localeCompare(s.ID??""));b(s)}catch{b([])}finally{v(!1)}},[g,m]);(0,n.useEffect)(()=>{F()},[F]);let V=(0,n.useMemo)(()=>[{id:"type",header:()=>e("Type"),accessorFn:e=>e.Transitions||e.NoncurrentVersionTransitions?"Transition":"Expire"},{id:"version",header:()=>e("Version"),accessorFn:s=>s.NoncurrentVersionExpiration||s.NoncurrentVersionTransitions?e("Non-current Version"):e("Current Version")},{id:"deleteMarker",header:()=>e("Expiration Delete Mark"),accessorFn:s=>s.Expiration?.ExpiredObjectDeleteMarker?e("On"):e("Off")},{id:"tier",header:()=>e("Tier"),accessorFn:e=>e.Transitions?.[0]?.StorageClass||e.NoncurrentVersionTransitions?.[0]?.StorageClass||"--"},{id:"prefix",header:()=>e("Prefix"),accessorFn:e=>e.Filter?.Prefix||e.Filter?.And?.Prefix||""},{id:"timeCycle",header:()=>`${e("Time Cycle")} (${e("Days")})`,accessorFn:e=>e.Expiration?.Days??e.NoncurrentVersionExpiration?.NoncurrentDays??e.Transitions?.[0]?.Days??e.NoncurrentVersionTransitions?.[0]?.NoncurrentDays??""},{id:"status",header:()=>e("Status"),accessorFn:e=>e.Status??"-",cell:({row:e})=>(0,r.jsx)(c.E,{variant:"Enabled"===e.original.Status?"secondary":"destructive",children:e.original.Status??"-"})},{id:"actions",header:()=>e("Actions"),enableSorting:!1,cell:({row:s})=>(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsxs)(o.$,{variant:"outline",size:"sm",onClick:()=>O(s.original),children:[(0,r.jsx)(t.tqC,{className:"size-4","aria-hidden":!0}),(0,r.jsx)("span",{children:e("Delete")})]})})}],[e]),{table:w}=(0,x.u)({data:T,columns:V,getRowId:e=>e.ID??JSON.stringify(e)}),O=s=>{i.error({title:e("Warning"),content:e("Are you sure you want to delete this rule?"),positiveText:e("Confirm"),negativeText:e("Cancel"),onPositiveClick:()=>_(s)})},_=async i=>{let r=T.filter(e=>e.ID!==i.ID);if(g)try{0===r.length?await N(g):await C(g,{Rules:r}),s.success(e("Delete Success")),F()}catch(i){s.error(i.message||e("Delete Failed"))}};return(0,r.jsxs)(l.Y,{children:[(0,r.jsx)(d.z,{actions:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.g,{value:g,onChange:D,placeholder:e("Please select bucket")}),(0,r.jsxs)(o.$,{variant:"outline",onClick:()=>E(!0),disabled:!g,children:[(0,r.jsx)(t.Ld_,{className:"size-4","aria-hidden":!0}),(0,r.jsx)("span",{children:e("Add Lifecycle Rule")})]}),(0,r.jsxs)(o.$,{variant:"outline",onClick:F,children:[(0,r.jsx)(t.Ll9,{className:"size-4","aria-hidden":!0}),(0,r.jsx)("span",{children:e("Refresh")})]})]}),children:(0,r.jsx)("h1",{className:"text-2xl font-bold",children:e("Lifecycle")})}),(0,r.jsx)(h.b,{table:w,isLoading:k,emptyTitle:e("No Data"),emptyDescription:e("Create lifecycle rules to automate object transitions and expiration.")}),g&&(0,r.jsx)(f.T,{open:S,onOpenChange:E,bucketName:g,onSuccess:F})]})}},62409:(e,s,i)=>{Promise.resolve().then(i.bind(i,23008))}},e=>{e.O(0,[9608,2026,6865,4510,7500,670,5719,6477,5678,3099,9137,1387,3677,2972,3412,914,9605,8500,67,7699,1151,8589,6670,7358],()=>e(e.s=62409)),_N_E=e.O()}]);