import{R as g,o as x,r as d,k as j,l as C,aJ as m,j as e,E as S,a9 as a,g as f,h as y,i as w}from"./app-BgLa5dit.js";function P(s){var o;const[p,n]=g.useState(!1),t=x(d.clip(s.id)),u=j(),i=C();function h(){var c;n(!0),u(d.deleteClip(s.id,(c=t.data._parentVideo)==null?void 0:c.id)).then(()=>{var r;i.success(`Successfully deleted <strong>${t.data.name}</strong>.`),f.trigger({application:w.VIDEOS,action:y.Videos.EDIT_VIDEO_CLIPS,args:[(r=t.data._parentVideo)==null?void 0:r.id]},{replace:!0}),s.closePopup()}).catch(()=>{i.error(`Something went wrong while trying to delete <strong>${t.data.name}</strong>. Please try again.`),n(!1)})}const l=((o=t.data)==null?void 0:o.status)===m.Draft;return e.jsx(S,{title:l?"Delete draft clip":"Cannot delete clip",closePopup:s.closePopup,showLoadingSpinner:!t.data,children:l?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Are you sure you want to delete ",e.jsx("strong",{children:t.data.name}),"?"]}),e.jsx("p",{children:"This clip has not been published, which means it has not had any usage and is safe to delete."}),e.jsxs(a,{children:[e.jsx(a.Cancel,{onClick:s.closePopup}),e.jsx(a.Submit,{variant:"danger",type:"button",text:"Delete clip",onClick:h,showSpinner:p})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"Only draft clips can be deleted."}),e.jsx(a,{children:e.jsx(a.Submit,{variant:"dark",type:"button",text:"Close",onClick:s.closePopup})})]})})}export{P as DeleteClipView};
//# sourceMappingURL=AEOrH8A6.chunk.js.map
