(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3386],{8697:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>m});var n=i(90637),a=i(60857),s=i(2911),o=i(27639),l=i(17522),r=i(20708),u=i(95918),c=i(50234),d=i(85044),f=i(56372),p=i(57364),h=i(31941),b=i(97329),C=i(68126),g=i(20135);function m(){let{t:e}=(0,s.Bd)(),t=(0,g.J)(),i=(0,C.sp)(),{listBucketNotifications:m,putBucketNotifications:x}=(0,b.o)(),[y,S]=(0,a.useState)(null),[v,F]=(0,a.useState)([]),[j,N]=(0,a.useState)(!1),[k,w]=(0,a.useState)(!1),L=(0,a.useCallback)(async()=>{if(!y)return void F([]);N(!0);try{let e=await m(y),t=[],i=(e,i,n)=>{(e??[]).forEach(e=>{let a=e.Filter?.Key?.FilterRules?.find(e=>"Prefix"===e.Name)?.Value,s=e.Filter?.Key?.FilterRules?.find(e=>"Suffix"===e.Name)?.Value,o=e[n];t.push({id:e.Id??"",type:i,arn:o??"",events:e.Events??[],prefix:a,suffix:s,filterRules:e.Filter?.Key?.FilterRules??[]})})};i(e?.LambdaFunctionConfigurations??[],"Lambda","LambdaFunctionArn"),i(e?.QueueConfigurations??[],"SQS","QueueArn"),i(e?.TopicConfigurations??[],"SNS","TopicArn"),F(t)}catch(t){console.error(e("Get Notification Config Failed"),t),F([])}finally{N(!1)}},[y,m,e]);(0,a.useEffect)(()=>{L()},[L]);let E=(0,a.useCallback)(async n=>{if(await new Promise(t=>{i.warning({title:e("Confirm Delete"),content:e("Are you sure you want to delete this notification configuration?"),positiveText:e("Delete"),negativeText:e("Cancel"),onPositiveClick:()=>t(!0),onNegativeClick:()=>t(!1)})})&&y)try{N(!0);let i=await m(y)??{},a=i["Lambda"===n.type?"LambdaFunctionConfigurations":"SQS"===n.type?"QueueConfigurations":"TopicConfigurations"],s=a?.filter(e=>e.Id!==n.id)??[],o={...i,..."Lambda"===n.type?{LambdaFunctionConfigurations:s}:"SQS"===n.type?{QueueConfigurations:s}:{TopicConfigurations:s}};await x(y,o),t.success(e("Delete Success")),L()}catch(i){console.error(e("Delete Failed"),i),t.error(`${e("Delete Failed")}: ${i.message??i}`)}finally{N(!1)}},[y,i,m,L,t,x,e]),D=(0,a.useMemo)(()=>(0,h.h)(e,E),[e,E]),{table:Q}=(0,f.u)({data:v,columns:D,getRowId:e=>e.id});return(0,n.jsxs)(r.Y,{children:[(0,n.jsx)(u.z,{actions:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(c.g,{value:y,onChange:S,placeholder:e("Please select bucket"),selectorClass:"w-full"}),(0,n.jsxs)(l.$,{type:"button",variant:"outline",onClick:()=>w(!0),disabled:!y,children:[(0,n.jsx)(o.Ld_,{className:"size-4","aria-hidden":!0}),(0,n.jsx)("span",{children:e("Add Event Subscription")})]}),(0,n.jsxs)(l.$,{type:"button",variant:"outline",onClick:L,disabled:j,children:[(0,n.jsx)(o.Ll9,{className:"size-4","aria-hidden":!0}),(0,n.jsx)("span",{children:e("Refresh")})]})]}),children:(0,n.jsx)("h1",{className:"text-2xl font-bold",children:e("Events")})}),(0,n.jsx)(d.b,{table:Q,isLoading:j,emptyTitle:e("No Data"),emptyDescription:e("Add Event Subscription to get started")}),y&&(0,n.jsx)(p.m,{open:k,onOpenChange:w,bucketName:y,onSuccess:L})]})}},66652:(e,t,i)=>{Promise.resolve().then(i.bind(i,8697))}},e=>{e.O(0,[9608,2026,6865,4510,7500,670,5719,6477,5678,3099,9137,1387,3677,2972,3412,9605,8500,67,7699,4328,8589,6670,7358],()=>e(e.s=66652)),_N_E=e.O()}]);