import{L as S,e3 as A,ao as o,ck as P,bk as w,bU as c,aI as p,b0 as v,bc as E,az as x,aj as D,v as L,f as T,e as M,aF as V,o as I,p as H,W as q,r as R,E as N}from"./app-k0jcl5PQ.js";import{F as U}from"./C3DvQ1wU.chunk.js";import{T as g,D as C}from"./CXQbE3g_.chunk.js";import{M as k}from"./BKH_iZiB.chunk.js";import{u as _}from"./DADIK7sb.chunk.js";import{l as m}from"./DLmnDxSd.chunk.js";import{F as y}from"./DV1GpLCe.chunk.js";import{T as W}from"./CxXrZYi8.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 O="myVideos.addFolder",t=S.encloseNamespace(O),$=m.object().shape({name:m.string().required(()=>t("nameRequired")).max(255,()=>t("maxNameLength")),folder:m.object().required()});function B(e){const a=A();return o.jsxs(P,{children:[o.jsx(y,{label:t("name"),type:"text",name:"name",id:"name",placeholder:t("placeholder"),autoFocus:!0,value:a.values.name,required:!0}),o.jsx(y,{label:t("parentFolder"),name:"folder",children:()=>{var r;return o.jsx(w.Scrollbars,{autoHeight:!0,autoHeightMax:300,className:"border rounded-3",children:o.jsx(W,{tree:e.folders,onSelect:n=>a.setFieldValue("folder",n),selectedIds:(r=a.values.folder)!=null&&r.id?[a.values.folder.id]:void 0,selectedLinkClassName:"bg-light",openDepth:1,maxDisplayDepth:6})})}}),o.jsxs(c,{children:[o.jsx(c.Cancel,{onClick:e.onClickCancel}),o.jsx(c.Submit,{variant:"dark",showSpinner:e.showSpinner})]})]})}const X="myVideos.addFolder",u=S.encloseNamespace(X);function le(e){const[a,r]=p.useState(!1),n=v(),h=E(),i=x(D.workspace()),s=x(k.workspaceWithCategories()),l=_(s.data),b=p.useMemo(()=>g.find(l,e.parentFolderId),[l,e.parentFolderId]);p.useEffect(()=>{s.data&&g.findDepth(s.data,e.parentFolderId)===C&&L.trigger({application:M.MY_VIDEOS,action:T.MyVideos.MAX_FOLDER_DEPTH,args:[C]})},[s.hasCompleted]);async function j(d){r(!0);try{const F=await n(k.addFolder({collectionId:i.data.id,name:d.name,parentCategoryId:d.folder.id===i.data.id?void 0:d.folder.id}));h.success(u("success")),e.closePopup(),I.logUserAction({id:F.id,name:F.name},{entity:N.Folder,actionType:R.Create,workflowPhase:q.Complete,location:H.Popup})}catch{h.error(u("error")),e.closePopup()}}const f=i.hasCompleted&&s.hasCompleted;return o.jsx(V,{title:u("title"),closePopup:e.closePopup,showLoadingSpinner:!f,children:f&&o.jsx(U,{initialValues:{name:"",folder:b},validationSchema:$,onSubmit:j,validateOnMount:!0,children:o.jsx(B,{onClickCancel:e.closePopup,folders:l,showSpinner:a})})})}export{le as AddFolderView};
//# sourceMappingURL=Bh4uZRyz.chunk.js.map
