import{e3 as j,ao as o,ck as w,L as k,bk as P,bU as c,aI as A,b0 as I,bc as M,az as m,aj as L,aC as T,aF as E,f as D,e as H,A as N,o as R,p as O,W as U,r as W,E as q}from"./app-k0jcl5PQ.js";import{F as _}from"./C3DvQ1wU.chunk.js";import{u as $}from"./BCc8At9P.chunk.js";import{M as p}from"./BKH_iZiB.chunk.js";import{u as B}from"./DADIK7sb.chunk.js";import{l as g}from"./DLmnDxSd.chunk.js";import{F as Y}from"./DV1GpLCe.chunk.js";import{T as z}from"./CxXrZYi8.chunk.js";import"./CXQbE3g_.chunk.js";import"./CW7x8M-z.chunk.js";import"./Di9d6zcy.chunk.js";import"./CKctgafI.chunk.js";import"./BDviDDog.chunk.js";import"./wCY37Ze3.chunk.js";import"./sncKO62z.chunk.js";import"./Bdp-qhf0.chunk.js";const G="myVideos.moveVideo",v=k.encloseNamespace(G),J=g.object().shape({folder:g.object().required()});function K(e){const i=j();return o.jsxs(w,{children:[o.jsx(Y,{label:v("parentFolder"),name:"folder",children:()=>{var d;return o.jsx(P.Scrollbars,{autoHeight:!0,autoHeightMax:300,className:"border rounded-3",children:o.jsx(z,{tree:e.folders,onSelect:a=>{a&&i.setFieldValue("folder",a)},selectedIds:(d=i.values.folder)!=null&&d.id?[i.values.folder.id]:void 0,selectedLinkClassName:"bg-light",openDepth:1,isDisabled:a=>a.id===e.folderId,maxDisplayDepth:6})})}}),o.jsxs(c,{children:[o.jsx(c.Cancel,{onClick:e.onClickCancel}),o.jsx(c.Submit,{variant:"dark",showSpinner:e.showSpinner,text:v("moveVideo")})]})]})}const Q="myVideos.moveVideo",t=k.encloseNamespace(Q);function fe(e){var x,F;const[i,d]=A.useState(!1),a=I(),u=M(),r=m(L.workspace()),l=m(r.data&&p.videoFolders(T.first(e.id),r.data.id)),f=m(p.workspaceWithCategories()),y=B(f.data);$(r.statusCode,l.statusCode);const n=((F=(x=l.data)==null?void 0:x.data)==null?void 0:F.find(s=>{var S,V;return(V=(S=s.libraries)==null?void 0:S.data)==null?void 0:V.some(b=>b.id===r.data.id)}))??r.data;async function C(s){d(!0);try{a(p.moveVideo({newFolderId:s.folder.id,oldFolderId:n.id,videoId:e.id})),u.success({type:N.Success,heading:e.id.length>1?t("moveVideosSucccessHeading"):t("moveVideoSucccessHeading"),message:t("moveVideosSuccess",{smartCount:e.id.length,fromFolder:n.name,toFolder:s.folder.name,escapeText:!0}),appLink:{application:H.MY_VIDEOS,action:D.MyVideos.MY_VIDEOS_FOLDER,args:[s.folder.id,s.folder.name]},appLinkText:t("goToFolder",{folder:s.folder.name,escapeText:!0}),appLinkClassName:"text-info"}),e.closePopup(),R.logUserAction({id:e.id.join(","),newFolderId:s.folder.id,oldFolderId:n.id},{entity:q.Video,actionType:W.Move,workflowPhase:U.Complete,location:O.Popup})}catch{u.error(t("error")),e.closePopup()}}const h=!!f.data&&!!l.data;return o.jsx(E,{title:t("title"),closePopup:e.closePopup,showLoadingSpinner:!h,children:h&&o.jsx(_,{initialValues:{folder:null},validationSchema:J,onSubmit:C,validateOnMount:!0,children:o.jsx(K,{folderId:n.id,onClickCancel:e.closePopup,showSpinner:i,folders:y})})})}export{fe as MoveVideoView};
//# sourceMappingURL=Dj-O05h_.chunk.js.map
