UNPKG

@getontime/cli

Version:
3 lines (2 loc) 12.7 kB
import{j as e,a7 as W,r as d,y as Y,ab as ee}from"./vendor-DFNUfA2K.js";import{g as f,i as o,o as te,P as se,b as F,s as $,a as ne,u as ae,d as ie,L as re,f as q,v as ce,w as oe,x as le,h as de,O as me,r as ue,y as he}from"./index-BNit4nUw.js";import{g as fe}from"./getProgress-Dgt_8BYF.js";import{E as xe}from"./Empty-BLJKwoJq.js";import{E as ve}from"./EmptyPage-dVRQ987V.js";import{T as z}from"./TitleCard-Bnxx8KS3.js";import{V as pe}from"./ViewLogo-BhUYUzFU.js";import{O as B,i as A,m as ge,d as ye,g as V,V as _e}from"./ViewParamsEditor-C6i_vUmm.js";import{u as je}from"./useWindowTitle-Bgl000Se.js";import{S as x,a as Ne}from"./viewLoader.utils-CeLIIcNn.js";import{b as we,i as Se,u as be}from"./useRundown-DgZv-crd.js";import{g as Ee}from"./offset-DC4blUxG.js";import{g as ke}from"./common.options-CwGs4uxL.js";import{u as Pe}from"./useCustomFields-C60U2vqf.js";import{u as Ie}from"./useProjectData-BfKJevmX.js";import"./Select-Bp_h4xvR.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="58df87c0-de3b-4047-8c5f-f1afbde10447",t._sentryDebugIdIdentifier="sentry-dbid-58df87c0-de3b-4047-8c5f-f1afbde10447")}catch{}})();function Oe(t){const{current:s,duration:n,className:a}=t,i=fe(s,n);return e.jsx("div",{className:`progress-bar__bg ${a}`,children:e.jsx("div",{className:"progress-bar__indicator",style:{width:`${i}%`}})})}function Ce(t){return{timeStart:t.timeStart,timeEnd:t.timeEnd,delay:t.skip?0:t.delay}}const Te={title:B.Schedule,collapsible:!0,options:[{id:"stopCycle",title:"Stop cycling through event pages",description:"Schedule will not auto-cycle through events",type:"boolean",defaultValue:!1},{id:"cycleInterval",title:"Cycle interval",description:"How long (in seconds) should each schedule page be shown.",type:"number",defaultValue:10},{id:"showExpected",title:"Show expected time",description:"Whether the times shown should account for the runtime offset.",type:"boolean",defaultValue:!1}]};function Ve(t){return{cycleInterval:Number(t.get("cycleInterval"))||10,stopCycle:A(t.get("stopCycle")),showExpected:A(t.get("showExpected"))}}function Q(){const[t]=W();return d.useMemo(()=>Ve(t),[t])}const U=d.createContext(void 0),Be=({children:t,selectedEventId:s})=>{const{cycleInterval:n,stopCycle:a}=Q(),{data:i}=we(l=>Se(l)),[r,c]=d.useState(-1),[h,v]=d.useState(0),[p,g]=d.useState(0),b=d.useRef(-1),m=d.useRef(void 0),j=d.useRef(null);d.useLayoutEffect(()=>{if(!j.current)return;const l=Array.from(j.current.children);if(l.length===0)return;const k=j.current.clientHeight;let N=0,C=1,P=1,I=-1,O=!1;for(let u=0;u<l.length;u++){const y=l[u].clientHeight,S=N+y>k;S&&(N=0,P+=1),u<r?T(l[u]):I===-1?(O=!0,C=P):S&&(O=!1),O?(I=u,w(l[u],N)):T(l[u]),N+=y}g(C),v(P),b.current=I;function w(u,y){u.style.top=`${y}px`}function T(u){u.style.top="-1000px"}},[r,i]),d.useEffect(()=>{if(a){g(1),c(0);return}m.current&&clearInterval(m.current);const l=setInterval(()=>{c(p===h?0:b.current+1)},n*1e3);return m.current=l,()=>clearInterval(m.current)},[n,h,a,p]);let E=i.findIndex(l=>l.id===s);const H=i.slice(E+1);return E=0,e.jsx(U.Provider,{value:{events:H,selectedEventId:s,numPages:h,visiblePage:p,containerRef:j},children:t})},Z=()=>{const t=d.useContext(U);if(!t)throw new Error("useSchedule() can only be used inside a ScheduleContext");return t},_={format12:"hh:mm a",format24:"HH:mm"};function He(t){const{timeStart:s,timeEnd:n,title:a,colour:i,skip:r,delay:c}=t,{showExpected:h}=Q();if(h)return e.jsx(Me,{timeStart:s,timeEnd:n,title:a,colour:i,skip:r,delay:c});if(c>0)return e.jsx(Fe,{timeStart:s,timeEnd:n,title:a,colour:i,skip:r,delay:c});const v=f(s,_),p=f(n,_);return e.jsxs("li",{className:o(["entry",r&&"entry--skip"]),children:[e.jsxs("div",{className:"entry-times",children:[e.jsx("span",{className:"entry-colour",style:{backgroundColor:i}}),e.jsx(x,{time:v}),"→",e.jsx(x,{time:p})]}),e.jsx("div",{className:"entry-title",children:a})]})}function Fe(t){const{timeStart:s,timeEnd:n,title:a,colour:i,skip:r,delay:c}=t,h=f(s,_),v=f(n,_),p=f(s+c,_),g=f(n+c,_);return e.jsxs("li",{className:o(["entry",r&&"entry--skip"]),children:[e.jsxs("div",{className:"entry-times",children:[e.jsxs("span",{className:"entry-times--delayed",children:[e.jsx("span",{className:"entry-colour",style:{backgroundColor:i}}),e.jsx(x,{time:h}),"→",e.jsx(x,{time:v})]}),e.jsxs("span",{className:"entry-times--delay",children:[e.jsx(x,{time:p}),"→",e.jsx(x,{time:g})]})]}),e.jsx("div",{className:"entry-title",children:a})]})}function Me(t){const{timeStart:s,timeEnd:n,title:a,colour:i,skip:r,delay:c}=t;return e.jsxs("li",{className:o(["entry",r&&"entry--skip"]),children:[e.jsxs("div",{className:"entry-times",children:[e.jsx("span",{className:"entry-colour",style:{backgroundColor:i}}),e.jsx(D,{time:s,delay:c}),"→",e.jsx(D,{time:n,delay:c})]}),e.jsx("div",{className:"entry-title",children:a})]})}function D(t){const{time:s,delay:n}=t,{offset:a}=te(),i=a-n,r=f(s-a,_),c=Ee(i);return e.jsx(x,{className:`entry-times--${c}`,time:r})}function Re({className:t}){const{events:s,containerRef:n}=Z();return(s==null?void 0:s.length)<1?null:e.jsx("ul",{className:o(["schedule",t]),ref:n,children:s.map(a=>{const{timeStart:i,timeEnd:r,delay:c}=Ce(a);return e.jsx(He,{timeStart:i,timeEnd:r,title:a.title,colour:a.colour,skip:a.skip,delay:c},a.id)})})}function Le({className:t}){const{numPages:s,visiblePage:n}=Z();return s>10?e.jsxs("div",{className:o(["schedule-nav",t]),children:[e.jsx("div",{className:o(["schedule-nav__item",n===1&&"schedule-nav__item--selected"])}),e.jsx("div",{className:o(["schedule-nav__item",n===2&&"schedule-nav__item--selected"])}),e.jsx("div",{className:o(["schedule-nav__item",n===3&&"schedule-nav__item--selected"])}),e.jsx("div",{className:o(["schedule-nav__item",n===4&&"schedule-nav__item--selected"])}),e.jsx("div",{className:o(["schedule-nav__item",n===5&&"schedule-nav__item--selected"])}),e.jsx("div",{className:o(["schedule-nav__item","schedule-nav__item--indeterminate",n>5&&n<s-4&&"schedule-nav__item--selected"])}),e.jsx("div",{className:o(["schedule-nav__item",n===s-4&&"schedule-nav__item--selected"])}),e.jsx("div",{className:o(["schedule-nav__item",n===s-3&&"schedule-nav__item--selected"])}),e.jsx("div",{className:o(["schedule-nav__item",n===s-2&&"schedule-nav__item--selected"])}),e.jsx("div",{className:o(["schedule-nav__item",n===s-1&&"schedule-nav__item--selected"])}),e.jsx("div",{className:o(["schedule-nav__item",n===s&&"schedule-nav__item--selected"])})]}):e.jsx("div",{className:o(["schedule-nav",t]),children:s>1&&[...Array(s).keys()].map(a=>e.jsx("div",{className:o(["schedule-nav__item",a+1===n&&"schedule-nav__item--selected"])},a))})}const $e=d.memo(ze);function ze(t){const{selectedId:s}=t;return e.jsxs(Be,{selectedEventId:s,children:[e.jsx(Le,{className:"schedule-nav-container"}),e.jsx(Re,{className:"schedule-container"})]})}const Ae=(t,s,n)=>{const a=ge(s,[{value:"note",label:"Note"}]),i=ye(n);return[{title:B.ClockOptions,collapsible:!0,options:[ke(t)]},{title:B.DataSources,collapsible:!0,options:[{id:"secondary-src",title:"Event secondary text",description:"Select the data source for auxiliary text shown in now and next cards",type:"option",values:a,defaultValue:""}]},Te,{title:B.ElementVisibility,collapsible:!0,options:[{id:"extra-info",title:"Extra info",description:"Select a project data source to show in the view",type:"option",values:i,defaultValue:""}]}]};function De(t,s){const n=a=>(s==null?void 0:s.get(a))??t.get(a);return{secondarySource:n("secondary-src"),extraInfo:n("extra-info")}}function We(){const[t]=W(),s=d.use(se);return d.useMemo(()=>{const a=s?new URLSearchParams(s.search):void 0;return De(t,a)},[s,t])}function qe(t){return(t??0)<0}function Qe(t){return t!==F.Stop}function Ue(t,s){return t===F.Roll&&s===ne.Pending}function Ze(t,s,n,a,i){if(i===F.Stop)return{showNow:!1,nowMain:void 0,nowSecondary:void 0,showNext:!1,nextMain:void 0,nextSecondary:void 0};const r=V(t,n)||$,c=V(t,a),h=V(s,n)||$,v=V(s,a);return{showNow:t!==null,nowMain:r,nowSecondary:c,showNext:s!==null,nextMain:h,nextSecondary:v}}function Ge(){const t=ae(p=>p.mirror),{data:s,status:n}=be(),{data:a,status:i}=Ie(),{data:r,status:c}=ie(),{data:h,status:v}=Pe();return{data:{events:s,customFields:h,projectData:a,isMirrored:t,settings:r},status:Ne([n,i,c,v])}}function xt(){const{data:t,status:s}=Ge();return je("Backstage"),s==="pending"?e.jsx(re,{}):s==="error"?e.jsx(ve,{text:"There was an error fetching data, please refresh the page."}):e.jsx(Je,{...t})}function Je({events:t,customFields:s,projectData:n,isMirrored:a,settings:i}){const{getLocalizedString:r}=q(),{secondarySource:c,extraInfo:h}=We(),{eventNext:v,eventNow:p,rundown:g,selectedEventId:b,time:m}=ce(),[j,E]=d.useState(!1),{height:H}=Y();d.useEffect(()=>{E(!1);const X=setTimeout(()=>{E(!0)},10);return()=>clearTimeout(X)},[b]);const l=t.length>0,{showNow:k,nowMain:N,nowSecondary:C,showNext:P,nextMain:I,nextSecondary:O}=Ze(p,v,"title",c,m.playback),w=Ue(m.playback,m.phase),T=w?f(m.secondaryTimer):f(m.startedAt),u=(()=>{if(!k&&l)return f(g.plannedStart,{format12:"hh:mm a",format24:"HH:mm"})})(),y=(()=>{if(!k&&l)return f(g.plannedEnd,{format12:"hh:mm a",format24:"HH:mm"})})();let S=oe(m.current,{fallback:he});S=le(S);const M=Math.max(window.innerWidth/15,72),G=Qe(m.playback),R=l&&H>420,J=u&&y,L=de(i==null?void 0:i.timeFormat),K=d.useMemo(()=>Ae(L,s,n),[L,s,n]);return e.jsxs("div",{className:`backstage ${a?"mirror":""}`,"data-testid":"backstage-view",children:[e.jsx(_e,{target:me.Backstage,viewOptions:K}),e.jsxs("div",{className:"project-header",children:[(n==null?void 0:n.logo)&&e.jsx(pe,{name:n.logo,className:"logo"}),e.jsx("div",{className:"title",children:n.title}),e.jsx(Xe,{})]}),G&&e.jsx(Oe,{className:"progress-container",current:m.current,duration:m.duration}),!l&&e.jsx(xe,{text:r("common.no_data"),className:"empty-container"}),e.jsxs("div",{className:"card-container",children:[k&&e.jsxs("div",{className:o(["event","now",j&&"blink"]),children:[e.jsx(z,{title:N,secondary:C}),e.jsxs("div",{className:"timer-group",children:[e.jsxs("div",{className:"time-entry",children:[e.jsx("div",{className:o(["time-entry__label",w&&"time-entry--pending"]),children:r(w?"countdown.waiting":"common.started_at")}),e.jsx(x,{time:T,className:"time-entry__value"})]}),e.jsx("div",{className:"timer-gap"}),e.jsxs("div",{className:"time-entry",children:[e.jsx("div",{className:"time-entry__label",children:r("common.expected_finish")}),qe(m.current)?e.jsx("div",{className:"time-entry__value",children:r("countdown.overtime")}):e.jsx(x,{time:f(m.expectedFinish),className:"time-entry__value"})]}),e.jsx("div",{className:"timer-gap"}),e.jsxs("div",{className:"time-entry",children:[e.jsx("div",{className:"time-entry__label",children:r("common.stage_timer")}),e.jsx("div",{className:"time-entry__value",children:S})]})]})]}),J&&e.jsxs("div",{className:"event",children:[e.jsx("div",{className:"title-card__placeholder",children:r("countdown.waiting")}),e.jsxs("div",{className:"timer-group",children:[e.jsxs("div",{className:"time-entry",children:[e.jsx("div",{className:o(["time-entry__label",w&&"time-entry--pending"]),children:r("common.scheduled_start")}),e.jsx(x,{time:u,className:"time-entry__value"})]}),e.jsx("div",{className:"timer-gap"}),e.jsxs("div",{className:"time-entry",children:[e.jsx("div",{className:"time-entry__label",children:r("common.scheduled_end")}),e.jsx(x,{time:y,className:"time-entry__value"})]})]})]}),P&&l&&e.jsx(z,{className:"event",label:"next",title:I,secondary:O})]}),R&&e.jsx($e,{selectedId:b}),e.jsxs("div",{className:o(["info",!R&&"info--stretch"]),children:[h&&e.jsx(Ke,{projectData:n,size:M,source:h}),e.jsxs("div",{className:"info-card",children:[n.url&&e.jsx(ee,{value:n.url,size:M,level:"L",className:"info-card__qr"}),n.info&&e.jsx("div",{className:"info-card__message",children:n.info})]})]})]})}function Ke({projectData:t,size:s,source:n}){const a=t.custom.find((i,r)=>`${r}-${i.title}`===n);return a?e.jsxs("div",{className:"info-card",children:[a.url&&e.jsx("img",{className:"info-card__img",width:s,src:a.url,onError:i=>i.currentTarget.style.display="none"}),e.jsxs("div",{className:"info__column",children:[a.title&&e.jsx("div",{className:"info-card__label",children:a.title}),a.value&&e.jsx("div",{className:"info-card__message",children:a.value})]})]}):null}function Xe(){const{getLocalizedString:t}=q(),{clock:s}=ue(),n=f(s);return e.jsxs("div",{className:"clock-container",children:[e.jsx("div",{className:"label",children:t("common.time_now")}),e.jsx(x,{time:n,className:"time"})]})}export{xt as default}; //# sourceMappingURL=Backstage-CFV0YhNP.js.map