import{aI as b,c4 as D,bc as I,b0 as w,az as E,dK as d,ao as t,aF as T,L,aq as h,bU as i,m as R,o as m,W as k,p as y,E as j,r as v,a as F,e as A,f as x,v as _}from"./app-k0jcl5PQ.js";const l="shared.deleteVideo",s=L.encloseNamespace(l);function o(e){return Array.isArray(e)&&e.length>1}function O(e){var f;const[p,n]=b.useState(!1),C=D(),c=I(),S=w(),a=E(!o(e.id)&&d.video(e.id)),r=!((f=a.data)!=null&&f.name);async function P(){if(n(!0),!o(e.id)){R(C,d.delete(e.id,()=>{const u=r?s("successPrivate"):s("success",{video:a.data.name,escapeText:!0});c.success(u),m.logUserAction({id:e.id},{actionType:v.Delete,entity:j.Video,location:y.Popup,workflowPhase:k.Complete}),n(!1),e.closePopup();const g=F.getCurrentRoute().appLink,V=[x.Videos.PLAY_VIDEO,x.Share.VIEW_SHARE_LINK];g.application===A.VIDEOS&&V.includes(g.action)&&_.trigger({application:A.MY_VIDEOS,action:x.MyVideos.MY_VIDEOS})},()=>{const u=r?s("errorPrivate"):s("error",{video:a.data.name,escapeText:!0});c.error(u),n(!1),e.closePopup()}));return}try{await S(d.deleteBulk(e.id,e.libraryId,e.categoryId)),c.success(s("bulkSuccess",{count:e.id.length,escapeText:!0})),m.logUserAction({id:e.id.join(",")},{actionType:v.Delete,entity:j.Video,location:y.Popup,workflowPhase:k.Complete}),n(!1),e.closePopup()}catch{c.error(s("bulkError",{count:e.id.length,escapeText:!0})),n(!1),e.closePopup()}}return t.jsxs(T,{title:s(o(e.id)?"bulkTitle":"title"),closePopup:e.closePopup,showLoadingSpinner:!o(e.id)&&!a.hasCompleted,children:[a.hasCompleted&&t.jsxs(t.Fragment,{children:[t.jsx("p",{children:r?t.jsx(h,{namespace:l,phrase:"infoPrivate"}):t.jsx(h,{namespace:l,phrase:"info",options:{video:a.data.name}})}),t.jsxs(i,{children:[t.jsx(i.Cancel,{onClick:e.closePopup}),t.jsx(i.Submit,{variant:"danger",text:s("delete"),showSpinner:p,onClick:P})]})]}),o(e.id)&&t.jsxs(t.Fragment,{children:[t.jsx("p",{children:t.jsx(h,{namespace:l,phrase:"bulkInfo",options:{count:e.id.length}})}),t.jsxs(i,{children:[t.jsx(i.Cancel,{onClick:e.closePopup}),t.jsx(i.Submit,{variant:"danger",text:s("bulkDelete"),showSpinner:p,onClick:P})]})]})]})}export{O as DeleteVideoView};
//# sourceMappingURL=D15_I2SX.chunk.js.map
