import{u as b,R as d,j as t,dt as g,ar as V,o as j,S as E,ai as W,ag as S}from"./app-BgLa5dit.js";import{W as D}from"./MEkA24R1.chunk.js";import{g as P,b as _,c as l}from"./BwfkiyJS.chunk.js";import"./B3eOBVf8.chunk.js";import"./3nM7jLnE.chunk.js";import"./CPXlV0fg.chunk.js";import"./DJ0pq8J_.chunk.js";import"./CKjyFQLY.chunk.js";import"./C53kfXmd.chunk.js";import"./CG7zbly5.chunk.js";function y(n){var i;const[s,r]=b(n.viewModelKey),{setDisableNext:o}=d.useContext(D);return d.useEffect(()=>{var e;r("subAction","addToAudiences"),(e=s==null?void 0:s.assocIds)!=null&&e.length||r("assocIds",[])},[]),d.useEffect(()=>{var e;o(!((e=s==null?void 0:s.assocIds)!=null&&e.length))},[s==null?void 0:s.assocIds]),d.useEffect(()=>{var e,a,c,u;!((e=s.assocIds)!=null&&e.length)&&((a=n.presentationAudiences)!=null&&a.length)&&r("assocIds",[(u=(c=n.presentationAudiences)==null?void 0:c[0])==null?void 0:u.masterId.toString()])},[n.currentPresentationId,(i=n.presentationAudiences)==null?void 0:i.length]),t.jsxs("div",{className:"pb-3",children:[t.jsx("h2",{className:"h4",children:"Add to Audience"}),t.jsx("p",{className:"fw-semibold",children:"Select a presentation to view it's audiences."}),t.jsx("div",{className:"w-100 pb-3",children:t.jsx(g,{presentations:n.presentations,currentPresentationId:n.currentPresentationId,setCurrentPresentation:e=>{n.setCurrentPresentationId(e.id),r("assocIds",[])}})}),t.jsx(t.Fragment,{children:(()=>{var e;return n.presentationAudiences?t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"form-label",children:"Audience"}),n.presentationAudiences.length?t.jsx("select",{id:"audience-ids",value:(e=s.assocIds)==null?void 0:e[0],onChange:a=>{r("assocIds",[a.target.value])},className:"w-100 form-select",children:n.presentationAudiences.map(a=>t.jsx("option",{value:a.masterId.toString(),children:a.name},a.masterId))}):t.jsx("p",{children:"This presentation has no audiences."})]}):t.jsx("div",{className:"text-center p-5",children:t.jsx(V,{as:"div",animation:"border",role:"status"})})})()})]})}function R(n){var m,h,I;const[s,r]=b(l.VIDEO_VIEW_MODEL_KEY),o=P(n.listId),i=j(E.presentations(W.Subject)),[e,a]=d.useState((s==null?void 0:s.presentationId)||((h=(m=i.data)==null?void 0:m[0])==null?void 0:h.id)),c=j(e&&E.presentationAudiences(e));d.useEffect(()=>{var p,f,x,A;!e&&((f=(p=i.data)==null?void 0:p[0])!=null&&f.id)&&a((A=(x=i.data)==null?void 0:x[0])==null?void 0:A.id)},[(I=i.data)==null?void 0:I.length]),d.useEffect(()=>{r("presentationId",e)},[e]);const u=!!i.data;return t.jsx(_,{appLinks:o,currentStep:"action-details",viewModelKey:l.VIDEO_VIEW_MODEL_KEY,type:S.Video,loaded:u,listId:n.listId,children:t.jsx(y,{appLinks:o,viewModelKey:l.VIDEO_VIEW_MODEL_KEY,presentations:i.data,currentPresentationId:e,setCurrentPresentationId:a,presentationAudiences:c.data})})}export{R as WorkbenchVideoActionsAddToAudiencesDetailsView};
//# sourceMappingURL=Bk4rz0h4.chunk.js.map
