import{b as h,e as S,j as a,P as L,f,bg as v,k as x,o as A,q as E,p as _,i as I}from"./app-BgLa5dit.js";import{A as P,a as T,T as y,b as w}from"./DwHsqWZr.chunk.js";import{A as C,a as j,u as N}from"./Cs6SwFTB.chunk.js";import{u as k}from"./B_g5BN6j.chunk.js";import{L as q}from"./CCXfeKmU.chunk.js";import{T as M}from"./lZO4aq5x.chunk.js";import{s as d}from"./CwUNbMbl.chunk.js";import"./1Of0XWgF.chunk.js";import"./BwrBcwEI.chunk.js";import"./BD9MrUJP.chunk.js";import"./EZim8aq-.chunk.js";import"./s6cGcwlA.chunk.js";import"./Zwjmkasg.chunk.js";import"./4qGb1BIY.chunk.js";import"./DnXDEnAR.chunk.js";import"./DpUpv6rY.chunk.js";import"./CG7zbly5.chunk.js";import"./m4aqaK_l.chunk.js";import"./MEkA24R1.chunk.js";import"./C53kfXmd.chunk.js";import"./BT3VnoQK.chunk.js";import"./kiNvuUO3.chunk.js";import"./Bkj-W53y.chunk.js";import"./KIVqng-q.chunk.js";import"./oUIMm7ik.chunk.js";import"./DD0tWTM_.chunk.js";import"./CPXlV0fg.chunk.js";import"./DFA8aJel.chunk.js";import"./CNqb5wo2.chunk.js";import"./HrByhRZi.chunk.js";import"./BSRfXcBg.chunk.js";import"./DG2-quVR.chunk.js";import"./CRMfsAcH.chunk.js";import"./yL1Poddl.chunk.js";import"./CCcwLDvu.chunk.js";import"./DDfKZ_ng.chunk.js";import"./CY0zrGLk.chunk.js";import"./Brw8lpR5.chunk.js";import"./0GREfvNX.chunk.js";import"./BE59vaMU.chunk.js";import"./C8_78Eqq.chunk.js";const R={table:"w-100",header:"fw-semibold",headerCell:`px-3 py-1 mh-100 align-items-center bg-white ${d.headerCell} text-nowrap`,row:`${d.row} ${d.livestreamRow}`,cell:`d-flex align-items-center border-end border-light ${d.cell} ${d.livestreamCell}`};function B(e){var m,t;const{hasPermissions:r}=h(),n=S.getColumns({stage:e.stage,hasPermissions:r},e.stage,"livestream",null);return a.jsxs(a.Fragment,{children:[!e.livestreams&&a.jsx(P,{}),((m=e.livestreams)==null?void 0:m.data)&&!e.livestreams.data.length&&a.jsx(T,{queryParams:e.queryParams,pipelineId:"streamable"}),((t=e.livestreams)==null?void 0:t.data)&&e.livestreams.data.length&&a.jsxs(a.Fragment,{children:[a.jsx(M,{columns:n,data:e.livestreams.data,defaultPinnedColumns:e.columnVisibility,columnPinning:{left:S.getPinnedTopicColumnIds()},pinnedColumnsKey:j,columnResizerKey:`${C}:livestream`,scrollable:!0,resizable:!0,virtualiser:{on:!0,rowHeight:60,containerHeight:"75vh"},theme:R}),a.jsx("div",{className:"d-flex flex-row justify-content-end",children:a.jsx(L,{cursors:e.livestreams.pagination.cursors||{next:null,previous:null},appLink:f.getCurrentRoute().appLink,buttonVariant:"outline-dark",className:"text-end pe-1 mt-2"})})]})]})}const V={getBackendParams(e,r,n){const m=()=>["asc","desc"].includes(e.sort)?e.sort:"asc",t={name:e.query,cursor:e.cursor,order:m()};switch(r){case"draft_livestreams":{t.status=v.Draft;break}case"past_livestreams":{t.status=v.Published,t.withRecordings=!1,t.to=y;break}case"upcoming_livestreams":{t.status=v.Published,t.withRecordings=!1,t.from=y;break}case"completed_livestreams":{t.withRecordings=!0;break}}return n.reduce((s,i)=>{var g,l,o,u,b,c;switch(i.field){case"object_status":{s.status=(l=(g=i.values)==null?void 0:g[0])==null?void 0:l.value;break}case"content_partner":{s.companyId=(u=(o=i.values)==null?void 0:o[0])==null?void 0:u.value;break}case"classification":{s.topicId=(b=i.values)==null?void 0:b.map(p=>p.value);break}case"audience":{s.audienceId=(c=i.values)==null?void 0:c.map(p=>p.value);break}}return s},t)}};function Ie(e){var l,o,u;const r=N(e.queryParams,e.subStage,"livestream"),n=k(e.queryParams,e.subStage),m=V.getBackendParams(e.queryParams,e.subStage,n),t=x(),s=A(q.livestreams({...m,query:"audiences,classifications"})),i=S.getNextStage(e.subStage);async function g(b){const c=S.mapStageToAction(i);if(await t(_.updateTopicStage(b,e.subStage,i)),!!c)return{application:I.ASSEMBLY_LINE,action:c,params:e.queryParams}}return a.jsx(E,{subStage:e.subStage,pipelineId:e.pipelineId,children:a.jsx(w,{stage:e.stage,subStage:e.subStage,objectType:"livestream",pipelineId:e.pipelineId,queryParams:e.queryParams,columnVisibility:r,filters:n,counts:{showing:((o=(l=s.data)==null?void 0:l.data)==null?void 0:o.length)??0,total:((u=s.data)==null?void 0:u.count)??0},children:a.jsx(B,{stage:e.subStage,onClickMoveToNextStage:g,livestreams:s.data,queryParams:e.queryParams,columnVisibility:r})})})}export{Ie as AssemblyLineLivestreamStageView};
//# sourceMappingURL=zo7KvToC.chunk.js.map
