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