import{k as b,l as v,cB as U,o as r,S as u,j as o,E as D,G as M,gV as s,bh as y,bi as R,F as j}from"./app-BgLa5dit.js";import{u as x,g as E,L as w}from"./OYSTrPbt.chunk.js";import{L as g}from"./CCXfeKmU.chunk.js";import{P as z}from"./CY0zrGLk.chunk.js";import"./BSRfXcBg.chunk.js";import"./DG2-quVR.chunk.js";import"./CRMfsAcH.chunk.js";import"./XPx5cqyz.chunk.js";const A="streamable.updateLivestream",I=j.encloseNamespace(A);function $(i){var p;const f=b(),c=v(),L=U(),{updateAudiences:T,updateClassifications:S}=x(),a=r(g.livestream(i.id)),e=r(z.streamablePresentation()),n=r(e.data&&u.presentationAudiences(e.data.id)),d=r(e.data&&u.getClassificationTree(e.data.id));async function h(t){const l=y.convertToUTCString(`${t.startDate}T${t.startTime}`),P=R.add(l,+t.duration,"minutes").toISOString();try{await f(g.updateLivestream(a.data.id,{companyMasterId:t.contentPartner,description:t.description,startDateTime:l,endDateTime:P,name:t.name,pastRecordingMasterId:t.pastRecordingMasterId,presentationId:a.data.presentationId,recordingMasterId:t.recordingMasterId,registrationUrl:t.registrationUrl,timezone:t.timezone,livestreamUrl:s.buildLivestreamUrl(t.livestreamUrlId),status:a.data.status})),await T(a.data,t.audiences,n.data),await S(a.data,t.classifications,d.data),L(["streamable:livestreams","streamable:livestream"]),c.success(I("success"))}catch{c.error(I("error"))}i.closePopup()}const m=a.data&&n.data&&e.data&&d.data;return o.jsx(D,{title:"Edit livestream",closePopup:i.closePopup,showLoadingSpinner:!m,backdrop:"static",children:m&&o.jsx(M,{initialValues:{name:i.name||a.data.name||"",contentPartner:a.data.company.id,startDate:s.getStartDate(a.data),startTime:s.getStartTime(a.data),duration:s.getDuration(a.data),timezone:a.data.timezone,description:a.data.description,recordingMasterId:a.data.recordingMasterId||"",pastRecordingMasterId:a.data.pastRecordingMasterId||"",livestreamUrlId:s.getLivestreamUrlId(a.data),registrationUrl:a.data.registrationUrl||"",audiences:a.data.audiences?a.data.audiences.map(t=>t.id):[],classifications:a.data.classifications?a.data.classifications.map(t=>t.id):[]},validationSchema:E((p=a.data.description)==null?void 0:p.length),onSubmit:h,children:o.jsx(w,{closePopup:i.closePopup,company:a.data.company,audiences:n.data,presentation:e.data,classificationTree:d.data,initialEndDateTime:a.data.endDateTime,isEdit:!0})})})}export{$ as StreamableEditLivestreamView};
//# sourceMappingURL=DNXiiuc5.chunk.js.map
