import{j as e,G as v,aA as t,dg as A,b9 as y,az as F,ax as p,aJ as r,dh as I,h as x,i as S,am as N,k as T,l as E,o as l,r as h,p as D,aR as q,aS as L}from"./app-BgLa5dit.js";import{O as k}from"./B-fq6xxv.chunk.js";import{F as V}from"./w68yffRy.chunk.js";import{B as P}from"./CGwLt1AI.chunk.js";import{E as U}from"./kJGoOu-N.chunk.js";import{C as B}from"./BHQAWhAu.chunk.js";import{A as b}from"./DFA8aJel.chunk.js";import"./BfMtaC_g.chunk.js";const R=t.object().shape({name:t.string().trim().max(255,()=>"Title is too long").required(()=>"Title is required").default(""),description:t.string().trim().max(16e3,()=>"Description is too long").default(""),startTime:t.number().required(),endTime:t.number().required(),thumbnail:A,status:t.mixed()}).noUnknown();function _(){const a=y();return e.jsxs(F,{children:[e.jsx(p,{label:"Name",type:"text",name:"name",id:"name",placeholder:"Name your clip",autoFocus:!0,value:a.values.name}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Status"}),e.jsx("div",{children:e.jsx("span",{className:`badge ${P.getStatusBadgeClass(a.values.status)}`,children:r[a.values.status]})})]}),e.jsx(p,{label:"Description",component:"textarea",name:"description",id:"description",placeholder:"Add a meaningful description to your clip",value:a.values.description}),e.jsx(I,{imageType:N.Thumbnails,fieldName:"thumbnail",uploadAppLink:{application:S.CLIPS,action:x.Clips.UPLOAD_IMAGE}}),e.jsx("div",{className:"d-flex justify-content-end",children:e.jsx(V,{isNew:!1,variant:"dark"})})]})}function w(a){return e.jsx(v,{initialValues:{...a.clip,thumbnail:a.clip.thumbnail||a.clip._parentVideo.thumbnail},validationSchema:R,onSubmit:a.saveClip,children:e.jsx(_,{})})}function $(a){const f=T(),o=E(),i=l(h.clip(a.clipId)),c=l(D.getAssemblyLineVideo(a.clipId)),s=l(q.currentUser());function j(d,C){var m,u;let n=d;((m=d.thumbnail)==null?void 0:m.id)===((u=i.data._parentVideo.thumbnail)==null?void 0:u.id)&&(n=L.omit(n,["thumbnail"])),f(h.updateClip(a.clipId,n)).then(()=>o.success("Successfully updated clip")).catch(()=>o.error("Failed to update clip")).finally(C)}const g=!!i.data&&!!s.data&&!!c.hasCompleted;return e.jsxs(e.Fragment,{children:[!!s.data&&e.jsx(U,{clipId:a.clipId,activeAction:x.Clips.EDIT_CLIP_DETAILS,currentUser:s.data}),g&&e.jsxs(e.Fragment,{children:[i.data.status===r.Published&&e.jsxs(b,{variant:"info",className:"mt-3 mb-1",children:["This clip is ",e.jsx("strong",{children:"published"})," and cannot be edited or deleted. You may archive it if you believe it should no longer be in use."]}),i.data.status===r.Archived&&e.jsxs(b,{variant:"info",className:"mt-3 mb-1",children:["This clip is ",e.jsx("strong",{children:"archived"}),". You may publish it again from the options menu."]}),e.jsx(k,{object:{name:i.data.name,status:i.data.status},actions:B.getClipActions(i.data,c.data),actionsDropdownClassName:"btn btn-outline-dark"}),e.jsx(w,{clip:i.data,saveClip:j})]})]})}export{$ as EditClipDetailsView};
//# sourceMappingURL=DTsWQ5Ue.chunk.js.map
