import{l as P,k as f,o as j,p as c,aJ as S,R as r,j as e,E as C,a9 as o,g as b,h as v,i as y}from"./app-BgLa5dit.js";import{C as V}from"./Cgoejc6d.chunk.js";function I(s){var d;const i=P(),u=f(),t=j(c.getMasterVideo(s.videoId)),a=((d=t.data)==null?void 0:d.status)===S.Published,[h,n]=r.useState(!1),[p,m]=r.useState(!1);async function x(){n(!0);try{await u(c.deleteVideo(s.videoId)),i.success("Successfully deleted video"),n(!1),s.closePopup(),b.trigger({application:y.VIDEOS,action:v.Videos.VIDEOS_HOME})}catch{i.error("Failed to delete video"),n(!1),s.closePopup()}}const l=!!t.data;return e.jsx(C,{title:"Delete Video",closePopup:s.closePopup,showLoadingSpinner:!l,children:!!l&&e.jsxs(e.Fragment,{children:[a&&e.jsx("p",{children:"This video is currently published. It must be archived before it can be deleted."}),!a&&e.jsxs("div",{children:[e.jsxs("p",{children:["Are you sure you want to delete ",e.jsxs("strong",{children:[t.data.name," "]}),"? This action cannot be undone."]}),e.jsx(V,{challengePhrase:t.data.name,onChallengePass:g=>m(g)})]}),e.jsxs(o,{className:"mt-3",children:[e.jsx(o.Cancel,{onClick:s.closePopup}),e.jsx(o.Submit,{variant:"danger",onClick:x,text:"Delete",showSpinner:h,disabled:a||!p})]})]})})}export{I as DeleteVideoView};
//# sourceMappingURL=COeHOo6p.chunk.js.map
