import{w as v,L as n,b0 as M,bc as R,aI as P,az as a,f7 as H,aj as N,t as O,ao as t,aF as q,aq as I,bU as c,o as U,p as _,W,r as Y,E as B,a as z,v as G,T as J,f as k,e as K}from"./app-k0jcl5PQ.js";import{u as Q}from"./BCc8At9P.chunk.js";import{T as X}from"./CXQbE3g_.chunk.js";import{u as Z}from"./K3ic94bc.chunk.js";import{M as l}from"./BKH_iZiB.chunk.js";import{u as $}from"./DADIK7sb.chunk.js";const d="myVideos.folderNotEmptyError";class ee extends v{constructor(){super("Folder is not empty")}get name(){return"FolderNotEmptyError"}get dialogOptions(){return{title:n.getPhrase(d,"title"),text:n.getPhrase(d,"instructions"),buttons:[{text:n.getPhrase(d,"close"),className:"btn btn-dark",close:!0}]}}}const A="myVideos.deleteFolder",r=n.encloseNamespace(A);function ie(e){var y,x,C;const V=M(),p=R(),[b,j]=P.useState(!1),s=a(H.folder(e.id)),u=Z(e.id),m=a(l.workspaceWithCategories()),D=$(m.data),h=a(l.videos(e.id)),g=a(N.workspace());Q(s.statusCode);const i=((x=(y=h.data)==null?void 0:y.data)==null?void 0:x.length)||((C=u.items)==null?void 0:C.length);P.useEffect(()=>{i&&O.throw(new ee)},[i]);async function L(){j(!0);try{await V(l.deleteFolder(e.id)),p.success(r("success")),e.closePopup(),U.logUserAction({id:s.data.id,name:s.data.name},{entity:B.Folder,actionType:Y.Delete,workflowPhase:W.Complete,location:_.Popup}),T()}catch{p.error(r("error")),e.closePopup()}}function T(){var w,F;const{appLink:E}=z.getCurrentRoute();if(((w=E.args[0])==null?void 0:w.toString())!==((F=e.id)==null?void 0:F.toString()))return;const o=X.getParent(D,e.id),S=!o||o.id.toString()===g.data.id.toString();G.trigger({application:K.MY_VIDEOS,action:S?k.MyVideos.MY_VIDEOS:k.MyVideos.MY_VIDEOS_FOLDER,args:S?void 0:[o.id,J.slugify(o.name)]})}const f=!!s.data&&u.hasCompleted&&h.hasCompleted&&m.hasCompleted&&g.hasCompleted&&!i;return t.jsx(q,{title:r("title"),closePopup:e.closePopup,showLoadingSpinner:!f,children:f&&t.jsxs(t.Fragment,{children:[t.jsx("p",{children:t.jsx(I,{namespace:A,phrase:"message",options:{folderName:s.data.name}})}),t.jsxs(c,{children:[t.jsx(c.Cancel,{onClick:e.closePopup}),t.jsx(c.Submit,{onClick:L,text:r("remove"),variant:"danger",showSpinner:b})]})]})})}export{ie as DeleteFolderView};
//# sourceMappingURL=D7u00DWS.chunk.js.map
