import{ao as a,L as S,ck as q,bT as D,M as H,bU as c,c4 as R,bc as U,az as N,f0 as m,dK as W,aF as _,dv as $,m as z,o as B,cu as M,W as K,p as O,E as Y,r as k,v as G,T as J,f as Q,e as X}from"./app-k0jcl5PQ.js";import{l as n}from"./DLmnDxSd.chunk.js";import{F as L}from"./DV1GpLCe.chunk.js";import{F as Z,u as ee}from"./C3DvQ1wU.chunk.js";import{V as ie,T as ae}from"./BhYYYlpK.chunk.js";import"./CW7x8M-z.chunk.js";import"./Di9d6zcy.chunk.js";import"./CKctgafI.chunk.js";import"./FGhEvk_q.chunk.js";import"./WCBjpMHJ.chunk.js";import"./DoFMWlew.chunk.js";import"./CMnqIsoM.chunk.js";const te="shared.editClipDetails",s=S.encloseNamespace(te),se=n.object().shape({name:n.string().trim().max(255,()=>s("titleTooLong")).required(()=>s("titleRequired")).default(""),description:n.string().trim().max(16e3,()=>s("descriptionTooLong")).default(""),startTime:n.number().required(),endTime:n.number().required(),status:n.mixed()}).noUnknown();function ne(e){const t=ee();return a.jsxs(q,{children:[a.jsxs("div",{className:"row form-group",children:[a.jsx("div",{className:"col-5",children:a.jsx(ie,{video:{_parentVideo:e.video,typeId:H.Clip,...t.values},type:"cosmetic",imageOptions:{size:D.Small},textPosition:ae.Independent,preload:!0})}),a.jsx("div",{className:"col-7",children:a.jsx("h2",{className:"h6",children:t.values.name})})]}),a.jsx(L,{label:s("nameLabel"),type:"text",name:"name",id:"name",placeholder:s("namePlaceholder"),autoFocus:!0,value:t.values.name}),a.jsx(L,{label:s("descriptionLabel"),component:"textarea",name:"description",id:"description",placeholder:s("descriptionPlaceholder"),value:t.values.description}),a.jsxs(c,{children:[a.jsx(c.Cancel,{onClick:e.onClickCancel}),a.jsx(c.Submit,{isNew:e.isNew,text:e.isNew&&s("createClip"),variant:"dark"})]})]})}function oe(e){var t;return a.jsx(Z,{initialValues:e.clip,validationSchema:se,onSubmit:e.saveClip,allowInitialSubmit:e.allowInitialSubmit,children:a.jsx(ne,{video:e.video,isNew:!((t=e.clip)!=null&&t.id)||e.isCopying,onClickCancel:e.onClickCancel})})}const le="shared.editClipDetailsView",o=S.encloseNamespace(le);function Te(e){var C,h,x,g,v,P,T,b,f;const t=R(),u=U(),i=N(!!e.id&&m.clip(e.id)),l=((h=(C=i.data)==null?void 0:C._parentVideo)==null?void 0:h.id)||e.videoId,p=N(!!l&&W.video(l)),F=isNaN(e.startTime)?(x=i==null?void 0:i.data)==null?void 0:x.startTime:e.startTime,I=isNaN(e.endTime)?(g=i==null?void 0:i.data)==null?void 0:g.endTime:e.endTime;function V(d){const j=r=>{u.success(o("success",{name:d.name,escapeText:!0})),B.logUserAction(M.getAnalyticsData(r),{actionType:e.id?k.Edit:k.Create,entity:Y.Clip,location:O.Popup,workflowPhase:K.Complete}),G.trigger({application:X.CLIPS,action:Q.Clips.PLAY_CLIP,args:[r.id,J.slugify(r.name)]})},y=()=>{u.error(o("error"))},w=()=>{e.closePopup()},E=e.id&&!e.isCopying?m.updateClip(e.id,d,j,y,w):m.createClip(l,d,j,y,w);z(t,E)}if(!e.id&&!e.videoId)return a.jsx(a.Fragment,{});const A=!!p.data&&(!e.id||!!i.data);return a.jsx(_,{title:o(e.id?"editPopupHeading":"createPopupHeading"),closePopup:e.closePopup,showLoadingSpinner:!A,children:a.jsx(oe,{video:p.data,clip:{id:(v=i==null?void 0:i.data)==null?void 0:v.id,name:e.isCopying?`${o("copyPrefix")} ${(P=i==null?void 0:i.data)==null?void 0:P.name}`:(T=i==null?void 0:i.data)==null?void 0:T.name,description:(b=i==null?void 0:i.data)==null?void 0:b.description,startTime:F,endTime:I,status:$.Published,thumbnail:(f=i==null?void 0:i.data)==null?void 0:f._thumbnail},saveClip:V,onClickCancel:e.closePopup,isCopying:!!e.isCopying,allowInitialSubmit:!0})})}export{Te as EditClipDetailsView};
//# sourceMappingURL=DSBeUyp4.chunk.js.map
