UNPKG

@getontime/cli

Version:

Time keeping for live events

7 lines 224 kB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CustomTranslationModal-DB3zaP4N.js","./constants-8b9Q9Bj6.js","./jsx-runtime-BNC90REB.js","./Button-CsttsbOH.js","./useSocket-B9-0Z7zf.js","./Button-DiI6nd38.css","./index-qU8RbaVt.js","./useIsSmallScreen-Db4lRgi0.js","./useMutation-BQgDt5L8.js","./assets-DU19UGw8.js","./NavigationMenu-6SsQpfey.js","./Input-D-3bhaHU.js","./Input-C9TDHweP.css","./Tooltip-DJ2_sn6r.js","./Tooltip-C0bTEpWY.css","./PresetContext-DZh_OrO5.js","./viewOptions-z3iLoQCB.js","./NavigationMenu-DPX7dRN-.css","./useSettings-CeUw01Bu.js","./viewParamsEditor.store-BcLRa99Z.js","./useFadeOutOnInactivity-u16Uck_y.js","./throttle-W86nehU0.js","./use-hotkeys-B1NTwV1d.js","./exports-BUXB5LA6.js","./index-CHpQBF7q.css","./Info-QUjDr4I8.js","./Info-birRg9AV.css","./Modal-Cvhkq0Va.js","./Modal-83tC6k71.css","./CustomTranslationModal-r-0IzHkl.css","./StyleEditor-G-lGCUzh.js","./StyleEditor-DPo3ak9O.css","./RundownExport-CBb7XL5-.js","./GenerateLinkFormExport-Bw4qLQsu.js","./useCustomFields-BMD3tm-0.js","./SwatchPicker-C0WK8dMM.js","./Select-CujoWFOD.js","./Select-JjSntbFg.css","./SwatchPicker-DhYAZ2UE.css","./QrCode-BsFmnkyr.js","./QrCode-BtdMKiNf.css","./use-local-storage-BwNknOH8.js","./GenerateLinkFormExport-ayIFcrEX.css","./useReport-CrYKGJAO.js","./useRundown-BubT2Cyp.js","./DelayIndicator-CDgZjI5P.js","./editorSettings-Cicapa9i.js","./validateEvent-Blu2IJUG.js","./editorSettings-dK8ts-CP.css","./EmptyFill-D1gAY2Dp.js","./Empty-CSL3pipV.js","./Empty-Bpka2Pt4.css","./EmptyFill-B7HcqrTP.css","./parseUserTime-CtxwbCYB.js","./DelayIndicator-C2Yy1DYy.css","./EditorUtils-CCdI8uXK.js","./tb-CLik_SnZ.js","./EditorUtils-BIAiI5ZG.css","./cuesheetColsFactory-CRj8VWIi.js","./AppLink-BD-RI_dT.js","./AppLink-DFH1DAbp.css","./offset-69iljPHz.js","./cuesheetColsFactory-tgwD_xnP.css","./KeyboardShortcuts-Bd2_HD9N.js","./KeyboardShortcuts-Cti0pn1q.css","./ProtectRoute-BH4thnew.js","./ProtectRoute-KY-q-K4q.css","./Tag-DCe8BaWk.js","./Tag-DgDpLVZw.css","./useAnimatedProgress-DJlteBY2.js","./playbackstate-C3qVH4fY.js","./RundownExport-mSWkFOLm.css","./TimerControlExport-DohR02KP.js","./TimerDisplay-CW7H8H-n.js","./TimerDisplay-CkxXGV7E.css","./TimerControlExport-Cx7ZATHp.css","./MessageControlExport-D2ZmM_Yg.js","./MessageControlExport-CS0cQD4F.css"])))=>i.map(i=>d[i]);
(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`f14ad0099eab1969fdd065b56af5fdd3cf530de6`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`4ac6a489-7bee-4e56-8cc6-b2f061b6e27e`,e._sentryDebugIdIdentifier=`sentry-dbid-4ac6a489-7bee-4e56-8cc6-b2f061b6e27e`)}catch{}})();import{a as e,n as t,t as n}from"./jsx-runtime-BNC90REB.js";import{$ as r,At as i,Bt as a,C as o,Ct as s,Ft as c,G as l,It as u,J as d,Jt as f,K as p,Kt as m,Lt as h,Mt as g,N as _,Nt as v,Pt as y,Q as b,Rt as x,Tt as S,U as C,Ut as w,W as T,Xt as E,Y as D,_t as O,at as k,bt as ee,c as te,ct as A,en as ne,it as re,jt as ie,k as ae,kt as oe,n as se,o as ce,pt as le,qt as ue,s as de,t as fe,ut as pe,w as me,zt as he}from"./useSocket-B9-0Z7zf.js";import{$ as ge,D as _e,Er as ve,Hn as ye,J as be,K as xe,Mn as Se,Nn as Ce,Nt as we,O as Te,P as Ee,Pn as De,Sn as Oe,Sr as ke,T as Ae,Tr as je,Un as Me,Y as Ne,_t as Pe,bn as Fe,cn as Ie,dn as Le,dt as Re,et as j,fn as ze,gn as Be,gr as Ve,ht as He,it as Ue,kr as We,kt as Ge,mn as Ke,mr as qe,nn as Je,nt as Ye,o as Xe,on as Ze,rn as Qe,rt as $e,sn as et,t as M,tt as N,vr as tt,w as nt,wn as rt,xn as it,yn as at,yr as ot,yt as st}from"./Button-CsttsbOH.js";import{t as ct}from"./Tooltip-DJ2_sn6r.js";import{A as lt,B as ut,F as dt,M as ft,N as pt,T as mt,a as ht,d as gt,j as _t,n as vt,o as yt,r as P}from"./useIsSmallScreen-Db4lRgi0.js";import{A as bt,C as xt,D as St,E as Ct,I as wt,M as Tt,N as Et,O as Dt,P as Ot,R as kt,S as At,T as jt,U as Mt,W as Nt,_ as Pt,c as Ft,d as It,g as Lt,h as Rt,j as zt,k as Bt,l as Vt,m as Ht,n as Ut,r as Wt,t as Gt,v as Kt,w as qt,x as Jt,y as Yt,z as Xt}from"./Select-CujoWFOD.js";import{A as Zt,C as Qt,Ct as $t,D as F,E as en,Et as tn,F as nn,Jt as rn,K as an,Kt as on,L as sn,M as cn,N as ln,O as un,Ot as dn,P as fn,Q as I,Qt as pn,St as mn,T as hn,U as gn,V as _n,Wt as vn,Yt as yn,_n as bn,_t as xn,an as Sn,at as Cn,b as wn,bn as Tn,cn as En,d as Dn,dn as On,en as kn,fn as An,ft as jn,gn as Mn,gt as Nn,hn as Pn,i as Fn,it as In,jt as Ln,k as Rn,kt as zn,lt as Bn,mt as Vn,n as Hn,on as Un,ot as Wn,qt as Gn,rt as Kn,sn as qn,tt as Jn,u as Yn,ut as Xn,vn as Zn,vt as Qn,w as $n,wt as er,xt as tr,z as nr}from"./constants-8b9Q9Bj6.js";import{t as rr}from"./useMutation-BQgDt5L8.js";import{c as ir,l as ar,n as or}from"./SwatchPicker-C0WK8dMM.js";import{a as sr,c as cr,d as lr,f as ur,g as dr,h as fr,i as pr,l as mr,m as hr,n as gr,p as _r,s as vr,t as yr,v as br}from"./NavigationMenu-6SsQpfey.js";import{t as xr}from"./use-local-storage-BwNknOH8.js";import{A as Sr,C as Cr,D as wr,E as Tr,M as Er,N as Dr,O as Or,T as kr,b as Ar,c as jr,f as Mr,g as Nr,j as Pr,k as Fr,l as Ir,n as Lr,r as Rr,s as zr,t as Br,u as Vr,w as Hr}from"./GenerateLinkFormExport-Bw4qLQsu.js";import{t as Ur}from"./use-hotkeys-B1NTwV1d.js";import{n as Wr,r as Gr,t as Kr}from"./TimerDisplay-CW7H8H-n.js";import{t as qr}from"./parseUserTime-CtxwbCYB.js";import{a as Jr,n as Yr,o as Xr,r as Zr,t as Qr}from"./Tag-DCe8BaWk.js";import{a as $r,i as ei,n as ti,o as ni,r as ri,t as ii}from"./useSettings-CeUw01Bu.js";import{a as ai,d as oi,f as si,h as ci,l as li,u as ui}from"./useRundown-BubT2Cyp.js";import{n as di,r as L,t as R}from"./Input-D-3bhaHU.js";import"./PresetContext-DZh_OrO5.js";import"./viewOptions-z3iLoQCB.js";import{t as fi}from"./errorboundary-BKENFA_Y.js";import{a as pi,r as mi,t as hi}from"./assets-DU19UGw8.js";import{A as gi,C as _i,D as vi,E as yi,M as bi,N as xi,O as Si,S as z,T as B,_ as Ci,b as V,d as H,f as U,g as W,h as G,i as wi,k as Ti,m as Ei,p as Di,u as Oi,v as ki,w as Ai,x as ji,y as Mi}from"./index-qU8RbaVt.js";import{t as Ni}from"./ProtectRoute-BH4thnew.js";import{i as Pi,r as Fi,t as K}from"./Info-QUjDr4I8.js";import{t as Ii}from"./Modal-Cvhkq0Va.js";import{u as Li}from"./tb-CLik_SnZ.js";import{i as Ri,s as zi}from"./EditorUtils-CCdI8uXK.js";import{n as Bi,t as Vi}from"./AppLink-BD-RI_dT.js";import{n as Hi,t as Ui}from"./useReport-CrYKGJAO.js";import{t as Wi}from"./useWindowTitle-Dvj2xEXy.js";import{n as Gi,r as Ki,t as qi}from"./editorSettings-Cicapa9i.js";import{a as Ji,i as Yi,n as Xi,o as Zi,r as Qi,s as $i,t as ea}from"./TimeElements-sSX9BxuU.js";import"./useAutoTickingClock-CjJeDQz8.js";import"./SuperscriptPeriod-maMkyH91.js";import{i as ta,n as na,r as ra,t as ia}from"./useCustomFields-BMD3tm-0.js";import"./QrCode-BsFmnkyr.js";import{n as aa,r as oa,t as sa}from"./useProjectData-DHesqFeW.js";import{_ as ca,a as la,c as ua,d as da,f as fa,g as pa,h as ma,i as ha,l as ga,m as _a,o as va,p as ya,r as ba,s as xa,u as Sa,v as Ca}from"./useCuesheetRundownSelection-B3ooF8fh.js";function wa(e){return e.trim().replaceAll(` `,`_`)}var q=e(t(),1),Ta=(e,t,n={})=>{let{isDisabled:r=!1}=n,i=(0,q.useCallback)(n=>{n.key===t&&!n.repeat&&!r&&(n.preventDefault(),e())},[e,r,t]);(0,q.useEffect)(()=>(document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`keydown`,i)}),[i])},Ea={blink:`_blink_1x7ve_1`,fourtyfive:`_fourtyfive_1x7ve_13`,contentWrapper:`_contentWrapper_1x7ve_17`,corner:`_corner_1x7ve_26`,content:`_content_1x7ve_17`},J=n();function Da({onClose:e,children:t}){return(0,J.jsxs)(`div`,{className:Ea.contentWrapper,children:[(0,J.jsx)(`div`,{className:Ea.corner,children:(0,J.jsxs)(M,{size:`large`,onClick:e,children:[`Close settings `,(0,J.jsx)(Vn,{})]})}),(0,J.jsx)(`div`,{className:Ea.content,children:t})]})}async function Oa(e){let t=await bn.get($n,{signal:e?.signal});return{url:t.data.html_url,version:t.data.tag_name}}var ka={url:``,version:``,hasUpdates:!1};function Aa(){let{data:e,status:t,isFetching:n,isError:r,refetch:i}=Zn({queryKey:Fn,queryFn:({signal:e})=>Oa({signal:e}),placeholderData:(e,t)=>e,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:!1,staleTime:S,enabled:fn}),a=e?.version&&!e.version.includes(`4.13.0-beta.1`);return{data:e?{...e,hasUpdates:a}:ka,placeholder:ka,status:t,isFetching:n,isError:r,refetch:i}}var ja=[{id:`settings`,label:`Settings`,secondary:[{id:`settings__data`,label:`Project data`,keywords:[`title`,`description`,`logo`,`url`,`info`]},{id:`settings__general`,label:`General settings`,keywords:[`pin`,`password`,`lock`,`language`,`time format`,`timezone`]},{id:`settings__view`,label:`View settings`,keywords:[`css`,`style`,`theme`,`translation`,`freeze`,`overtime`]},{id:`settings__custom-views`,label:`Custom views`,keywords:[`html`,`upload`,`external`,`embed`]},{id:`settings__mcp`,label:`MCP Server`,keywords:[`ai`,`agent`,`model`]},...[{id:`settings__port`,label:`Server port`,keywords:[`http`,`network`,`address`]}]]},{id:`project`,label:`Project`,secondary:[{id:`project__create`,label:`Create...`,keywords:[`new project`,`quick start`,`wizard`]},{id:`project__list`,label:`Manage projects`,keywords:[`load`,`open`,`rename`,`duplicate`,`delete`,`download`,`import`,`backup`,`merge`]}]},{id:`manage`,label:`Project settings`,secondary:[{id:`manage__defaults`,label:`Rundown defaults`,keywords:[`duration`,`warning`,`danger`,`defaults`]},{id:`manage__custom`,label:`Custom fields`,keywords:[`metadata`,`columns`,`extra data`,`image field`]},{id:`manage__rundowns`,label:`Manage rundowns`,keywords:[`rundown`,`xlsx`,`excel`,`load`,`export`]},{id:`manage__sheets`,label:`Import spreadsheet`,keywords:[`google sheet`,`sync`,`spreadsheet`,`xlsx`,`excel`,`csv`,`export`]}]},{id:`automation`,label:`Automation`,secondary:[{id:`automation__settings`,label:`Automation settings`,keywords:[`osc input`,`port`,`enable`,`remote control`]},{id:`automation__automations`,label:`Manage automations`,keywords:[`osc`,`http`,`webhook`,`integration`,`api`,`output`,`action`]},{id:`automation__triggers`,label:`Manage triggers`,keywords:[`lifecycle`,`on load`,`on start`,`on finish`,`on update`]}]},{id:`sharing`,label:`Sharing and reporting`,secondary:[{id:`sharing__presets`,label:`URL Presets`,keywords:[`alias`,`link`,`url`,`shortcut`]},{id:`sharing__link`,label:`Share link`,keywords:[`qr code`,`guest`,`cuesheet link`,`permissions`,`read only`]},{id:`sharing__report`,label:`Runtime report`,keywords:[`actual times`,`csv`,`export`,`history`]}]},{id:`network`,label:`Network`,secondary:[{id:`network__log`,label:`Event log`,keywords:[`debug`,`errors`,`console`,`export log`]},{id:`network__clients`,label:`Manage clients`,keywords:[`redirect`,`identify`,`rename client`,`connected`]}]},{id:`about`,label:`About`,keywords:[`version`,`update`,`licence`,`license`,`credits`]},{id:`shutdown`,label:`Shutdown`,keywords:[`quit`,`exit`,`close ontime`]}];function Ma(e){return e.trim().toLowerCase()}function Na(e,t){let n=Ma(t);return n?Ma(e.label).includes(n)?!0:!!e.keywords?.some(e=>e.includes(n)):!1}function Pa(e,t){let n=Ma(t);return n?e.reduce((e,t)=>{if(Na(t,n))return e.push(t),e;if(t.secondary){let r=t.secondary.filter(e=>Na(e,n));r.length&&e.push({...t,secondary:r})}return e},[]):[...e]}function Fa(){let{data:e}=Aa();return{options:(0,q.useMemo)(()=>ja.map(t=>t.id===`about`&&e.hasUpdates?Object.assign({},t,{highlight:`New version available`}):t),[e])}}var Ia={blink:`_blink_170ss_1`,fourtyfive:`_fourtyfive_170ss_13`,search:`_search_170ss_17`,icon:`_icon_170ss_25`,input:`_input_170ss_32`,clear:`_clear_170ss_37`};function La({query:e,onQueryChange:t,onSubmit:n}){let r=(0,q.useRef)(null),i=e.trim().length>0;return(0,J.jsxs)(`div`,{className:Ia.search,children:[(0,J.jsx)(Sn,{className:Ia.icon}),(0,J.jsx)(R,{ref:r,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{if(e.key===`Escape`&&i){e.stopPropagation(),t(``);return}e.key===`Enter`&&n()},placeholder:`Search settings`,className:Ia.input,fluid:!0}),i&&(0,J.jsx)(L,{variant:`ghosted-white`,size:`small`,"aria-label":`Clear search`,className:Ia.clear,onClick:()=>{t(``),r.current?.focus()},children:(0,J.jsx)(Vn,{})})]})}var Ra={blink:`_blink_q5mud_1`,fourtyfive:`_fourtyfive_q5mud_13`,container:`_container_q5mud_17`,tabs:`_tabs_q5mud_27`,primary:`_primary_q5mud_39`,secondary:`_secondary_q5mud_40`,groupActive:`_groupActive_q5mud_64`,active:`_active_q5mud_68`,highlight:`_highlight_q5mud_74`};function za(e,t){let n=e[0];return n?Na(n,t.trim().toLowerCase())?n.id:n.secondary?.[0]?.id??null:null}function Ba({selectedPanel:e,location:t}){let{options:n}=Fa(),{setLocation:r}=Yr(),[i,a]=(0,q.useState)(``),o=Pa(n,i);return(0,J.jsxs)(`div`,{className:Ra.container,children:[(0,J.jsx)(La,{query:i,onQueryChange:a,onSubmit:()=>{let e=za(o,i);e&&(r(e),a(``))}}),o.length===0?(0,J.jsx)(Ei,{title:`No settings match`,description:`Nothing found for "${i.trim()}"`}):(0,J.jsx)(`ul`,{className:Ra.tabs,children:o.map(n=>{let r=e===n.id;return n.highlight?(0,J.jsx)(ct,{text:n.highlight,render:(0,J.jsx)(`span`,{}),children:(0,J.jsx)(Va,{panel:n,location:t,isSelected:r})},n.id):(0,J.jsx)(Va,{panel:n,location:t,isSelected:r},n.id)})})]})}function Va({panel:e,isSelected:t,location:n}){let{setLocation:r}=Yr(),i=!!(t&&e.secondary?.some(e=>e.id.split(`__`)[1]===n));return(0,J.jsxs)(q.Fragment,{children:[(0,J.jsx)(`li`,{onClick:()=>r(e.id),onKeyDown:t=>{vr(t)&&r(e.id)},className:an([Ra.primary,t&&!i&&Ra.active,i&&Ra.groupActive,e.highlight&&Ra.highlight]),tabIndex:0,role:`button`,children:e.label},e.id),e.secondary?.map((e,i)=>{let a=e.id.split(`__`)[1];return(0,J.jsx)(`li`,{onClick:()=>r(e.id),onKeyDown:t=>{vr(t)&&r(e.id)},className:an([Ra.secondary,t&&n===a?Ra.active:null]),tabIndex:0,role:`button`,children:e.label},e.id+i)})]},e.id)}function Ha(e){return Mn({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`},child:[{tag:`path`,attr:{fillRule:`evenodd`,d:`M16.72 7.72a.75.75 0 0 1 1.06 0l3.75 3.75a.75.75 0 0 1 0 1.06l-3.75 3.75a.75.75 0 1 1-1.06-1.06l2.47-2.47H3a.75.75 0 0 1 0-1.5h16.19l-2.47-2.47a.75.75 0 0 1 0-1.06Z`,clipRule:`evenodd`},child:[]}]})(e)}var Ua={blink:`_blink_ac6dr_1`,fourtyfive:`_fourtyfive_ac6dr_13`,link:`_link_ac6dr_17`,inline:`_inline_ac6dr_27`,icon:`_icon_ac6dr_37`};function Wa({href:e,inline:t,className:n,children:r}){return(0,J.jsxs)(`a`,{href:`#!`,target:`_blank`,rel:`noreferrer`,className:an([Ua.link,t&&Ua.inline,n]),onClick:t=>{t.preventDefault(),ur(e)},children:[r,(0,J.jsx)(Ha,{className:Ua.icon})]})}var Ga={blink:`_blink_a0pg1_1`,fourtyfive:`_fourtyfive_a0pg1_13`,updateIndicator:`_updateIndicator_a0pg1_17`};function Ka(){let{data:e,isError:t}=Aa();return t?(0,J.jsx)(z,{children:(0,J.jsx)(W,{title:`Ontime ${hn}`,description:``,error:`Could not fetch version information`})}):e.hasUpdates?(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:Ga.updateIndicator,"aria-hidden":`true`}),`Ontime ${hn}`]}),description:nn?`Version ${e.version} is available. Restart your stage to update.`:`Version ${e.version} is available.`}),!nn&&(0,J.jsx)(Wa,{href:`https://www.getontime.no`,children:`Download the latest version from Ontime's page`})]}):(0,J.jsx)(z,{children:(0,J.jsx)(W,{title:`Ontime ${hn}`,description:`You are using the latest version.`})})}var qa={blink:`_blink_1csyf_1`,fourtyfive:`_fourtyfive_1csyf_13`,card:`_card_1csyf_17`,eyebrow:`_eyebrow_1csyf_23`,title:`_title_1csyf_31`,description:`_description_1csyf_38`,portability:`_portability_1csyf_48`,benefits:`_benefits_1csyf_55`,actions:`_actions_1csyf_76`};function Ja(){return nn?null:(0,J.jsx)(B,{children:(0,J.jsxs)(H,{className:qa.card,children:[(0,J.jsx)(`span`,{className:qa.eyebrow,children:`Ontime Cloud`}),(0,J.jsx)(`h3`,{className:qa.title,children:`Run Ontime online with zero setup`}),(0,J.jsxs)(`p`,{className:qa.description,children:[(0,J.jsx)(`span`,{children:`Ontime Cloud lets you run and share Ontime online with your team. Subscriptions support continued development while Ontime remains fully open-source and self-hostable.`}),(0,J.jsx)(`span`,{className:qa.portability,children:`Project files work locally and in Cloud, so your shows can move freely.`})]}),(0,J.jsxs)(`ul`,{className:qa.benefits,children:[(0,J.jsxs)(`li`,{children:[(0,J.jsx)(Xn,{}),`Start in minutes, with no setup or maintenance`]}),(0,J.jsxs)(`li`,{children:[(0,J.jsx)(Xn,{}),`Coordinate multi-track rundowns with Overview views`]}),(0,J.jsxs)(`li`,{children:[(0,J.jsx)(Xn,{}),`Manage every instance from one dashboard`]}),(0,J.jsxs)(`li`,{children:[(0,J.jsx)(Xn,{}),`Share secure read-only views with collaborators`]})]}),(0,J.jsx)(`div`,{className:qa.actions,children:(0,J.jsx)(Wa,{href:_n,children:`Learn more about Ontime Cloud`})})]})})}var Ya={blink:`_blink_yanwg_1`,fourtyfive:`_fourtyfive_yanwg_13`,link:`_link_yanwg_17`,action:`_action_yanwg_27`};function Xa({href:e,title:t,description:n}){return(0,J.jsx)(z,{interactive:!0,children:(0,J.jsxs)(Wa,{href:e,className:Ya.link,children:[(0,J.jsx)(W,{title:t,description:n}),(0,J.jsx)(`span`,{className:Ya.action,children:`Open`})]})})}function Za(){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ci,{children:`About Ontime`}),(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[(0,J.jsx)(yi,{children:`Ontime`}),(0,J.jsx)(Di,{}),(0,J.jsx)(K,{children:`Free, open-source software for managing rundowns and event timers.`}),(0,J.jsxs)(ji,{children:[(0,J.jsx)(Xa,{href:_n,title:`www.getontime.no`,description:`App site and downloads`}),(0,J.jsx)(Xa,{href:cn,title:`GitHub Sponsors`,description:`Support development through GitHub`}),(0,J.jsx)(Xa,{href:F,title:`Buy Me a Coffee`,description:`Make a one-time contribution`})]})]})}),(0,J.jsx)(Ja,{}),(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[(0,J.jsx)(yi,{children:`Current version`}),(0,J.jsx)(Di,{}),(0,J.jsx)(ji,{children:(0,J.jsx)(Ka,{})})]})}),(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[(0,J.jsx)(yi,{children:`Helpful links`}),(0,J.jsx)(Di,{}),(0,J.jsxs)(ji,{children:[(0,J.jsx)(Xa,{href:Zt,title:`Read the docs`,description:`Setup guides and feature documentation`}),(0,J.jsx)(Xa,{href:ln,title:`GitHub`,description:`Report issues or contribute to Ontime`}),(0,J.jsx)(Xa,{href:gn,title:`YouTube`,description:`Watch tutorials and feature walkthroughs`}),(0,J.jsx)(Xa,{href:Rn,title:`Discord`,description:`Get help and share suggestions`}),(0,J.jsx)(Xa,{href:nr,title:`Reddit`,description:`Join the Ontime community discussion`})]})]})})]})}function Qa(e,t){let n=(0,q.useRef)(null);return(0,q.useEffect)(()=>{t&&n.current&&t===e&&n.current.scrollIntoView({behavior:`smooth`,block:`center`})},[t,e]),n}var $a=`https://docs.getontime.no/api/protocols/osc/`;function eo({enabledAutomations:e,enabledOscIn:t,oscPortIn:n,automationState:r,oscInputState:i,isLoading:a}){let{handleSubmit:o,reset:s,register:c,setError:l,watch:u,setValue:f,formState:{errors:p,isSubmitting:m,isDirty:h,isValid:g}}=Pi({mode:`onChange`,defaultValues:{enabledAutomations:e,enabledOscIn:t,oscPortIn:n},resetOptions:{keepDirtyValues:!1}}),_=async e=>{try{await Fr(e),s(e)}catch(e){l(`root`,{message:d(e)})}},v=()=>{s({enabledAutomations:e,enabledOscIn:t,oscPortIn:n})},y=!m&&h&&g,b=u(`enabledAutomations`),x=u(`enabledOscIn`);return(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[(0,J.jsx)(_i,{isLoading:!!a}),(0,J.jsxs)(yi,{children:[`Automation settings`,(0,J.jsxs)(V,{children:[(0,J.jsx)(M,{variant:`ghosted`,onClick:v,disabled:!y,children:`Revert to saved`}),(0,J.jsx)(M,{variant:`primary`,type:`submit`,form:`automation-settings-form`,disabled:!y,loading:m,children:`Save`})]})]}),p?.root&&(0,J.jsx)(G,{children:p.root.message}),(0,J.jsx)(Di,{}),(0,J.jsx)(B,{children:(0,J.jsxs)(K,{children:[(0,J.jsx)(`span`,{children:`Control Ontime and share its data with external systems in your workflow.`}),(0,J.jsx)(`span`,{children:`- Automations allow Ontime to send its data on lifecycle triggers.`}),(0,J.jsx)(`span`,{children:`- OSC Input tells Ontime to listen to messages on the specific port.`}),(0,J.jsx)(Wa,{href:$a,children:`See the docs`})]})}),(0,J.jsxs)(B,{as:`form`,id:`automation-settings-form`,onSubmit:o(_),onKeyDown:e=>cr(e,v),children:[(0,J.jsx)(Ti,{children:`Automation`}),(0,J.jsx)(ji,{children:(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:`Enable automations`}),r===!1&&(0,J.jsx)(Qr,{variant:`warning`,children:`OFF`})]}),description:r===!1?`Automations are OFF. Triggers stay configured, but Ontime will not send messages.`:`Allow Ontime to send messages on lifecycle triggers`,descriptionTone:r===!1?`warning`:`default`,error:p.enabledAutomations?.message}),(0,J.jsx)(ir,{size:`large`,checked:b,onCheckedChange:e=>f(`enabledAutomations`,e,{shouldDirty:!0,shouldValidate:!0})})]})}),(0,J.jsx)(Ti,{children:`OSC Input`}),(0,J.jsxs)(ji,{children:[nn&&(0,J.jsx)(K,{children:`For security reasons OSC integrations are not available in the cloud service.`}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:`OSC input`}),i===!1&&(0,J.jsx)(Qr,{variant:`warning`,children:`OFF`})]}),description:i===!1?`OSC input is OFF. Ontime will not listen for incoming OSC control messages.`:`Allow control of Ontime through OSC`,descriptionTone:i===!1?`warning`:`default`,error:p.enabledOscIn?.message}),(0,J.jsx)(ir,{size:`large`,checked:x,onCheckedChange:e=>f(`enabledOscIn`,e,{shouldDirty:!0,shouldValidate:!0})})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Listen on port`,description:`Port for incoming OSC. Default: 8888`,error:p.oscPortIn?.message}),(0,J.jsx)(R,{id:`oscPortIn`,placeholder:`8888`,maxLength:5,style:{textAlign:`right`,width:`5rem`},type:`number`,fluid:!0,...c(`oscPortIn`,{required:{value:!0,message:`Required field`},max:{value:65535,message:`Port must be within range 1024 - 65535`},min:{value:1024,message:`Port must be within range 1024 - 65535`},pattern:{value:jr,message:`Value should be numeric`}})})]})]})]})]})})}var to=[{id:1,label:`On Load`,value:`onLoad`},{id:2,label:`On Start`,value:`onStart`},{id:3,label:`On Pause`,value:`onPause`},{id:4,label:`On Stop`,value:`onStop`},{id:5,label:`Every second`,value:`onClock`},{id:6,label:`On Timer Update`,value:`onUpdate`},{id:7,label:`On Finish`,value:`onFinish`},{id:8,label:`On Warning`,value:`onWarning`},{id:9,label:`On Danger`,value:`onDanger`}];function no(e){return Object.hasOwn(e,`id`)}var ro=[{value:null,label:`Select field`},{value:`eventNow.id`,label:`ID`},{value:`eventNow.title`,label:`Title`},{value:`eventNow.cue`,label:`Cue`},{value:`eventNow.countToEnd`,label:`Count to end`},{value:`eventNow.note`,label:`Note`},{value:`eventNow.colour`,label:`Colour`}],io=[{value:`eventNext.id`,label:`Next ID`},{value:`eventNext.title`,label:`Next Title`},{value:`eventNext.cue`,label:`Next Cue`}];function ao(e){return[...ro,...Object.entries(e).map(([e,{label:t}])=>({value:`eventNow.custom.${e}`,label:`Custom: ${t}`})),...io,...Object.entries(e).map(([e,{label:t}])=>({value:`eventNext.custom.${e}`,label:`Next custom: ${t}`}))]}function oo(e){let t={},n=[];for(let r=0;r<e.length;r++){let i=e[r];Object.hasOwn(t,i.trigger)||(t[i.trigger]=[]),t[i.trigger].includes(i.automationId)?n.push(r):t[i.trigger].push(i.automationId)}return n.length>0?n:void 0}function so(e,t,n,r,i,a,o,s,c,l=2){let u=Ge(n.current,{event:e,orientation:r,loopFocus:i,rtl:a,cols:l,disabledIndices:o,minIndex:s,maxIndex:c,prevIndex:t>c?s:t,stopEvent:!0});return we(n.current,u)?void 0:u}var co=q.createContext(void 0),lo=q.createContext(void 0),uo=q.createContext(void 0),fo=q.createContext(!1),po=q.createContext(``);function mo(){let e=q.useContext(co);if(!e)throw Error(je(22));return e}function ho(){let e=q.useContext(lo);if(!e)throw Error(je(23));return e}function go(){let e=q.useContext(uo);if(!e)throw Error(je(24));return e}function _o(){return q.useContext(po)}function vo(){return q.useContext(fo)}var Y={id:N(e=>e.id),labelId:N(e=>e.labelId),items:N(e=>e.items),selectedValue:N(e=>e.selectedValue),hasSelectionChips:N(e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0}),hasSelectedValue:N(e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0}),hasNullItemLabel:N((e,t)=>t?Lt(e.items):!1),open:N(e=>e.open),mounted:N(e=>e.mounted),forceMounted:N(e=>e.forceMounted),inline:N(e=>e.inline),activeIndex:N(e=>e.activeIndex),selectedIndex:N(e=>e.selectedIndex),isActive:N((e,t)=>e.activeIndex===t),isSelected:N((e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>Jt(t,e,n)):Jt(t,r,n)}),transitionStatus:N(e=>e.transitionStatus),popupProps:N(e=>e.popupProps),inputProps:N(e=>e.inputProps),triggerProps:N(e=>e.triggerProps),itemProps:N(e=>e.itemProps),positionerElement:N(e=>e.positionerElement),listElement:N(e=>e.listElement),popupId:N(e=>e.popupId),triggerElement:N(e=>e.triggerElement),inputElement:N(e=>e.inputElement),inputGroupElement:N(e=>e.inputGroupElement),popupSide:N(e=>e.popupSide),openMethod:N(e=>e.openMethod),inputInsidePopup:N(e=>e.inputInsidePopup),inputOwnsFormValue:N(e=>e.inputOwnsFormValue),selectionMode:N(e=>e.selectionMode),name:N(e=>e.name),form:N(e=>e.form),disabled:N(e=>e.disabled),readOnly:N(e=>e.readOnly),required:N(e=>e.required),grid:N(e=>e.grid),virtualized:N(e=>e.virtualized),itemToStringLabel:N(e=>e.itemToStringLabel),isItemEqualToValue:N(e=>e.isItemEqualToValue),modal:N(e=>e.modal),autoHighlight:N(e=>e.autoHighlight),submitOnItemClick:N(e=>e.submitOnItemClick)};function yo(e){return e==null?void 0:`${e}-popup`}function bo(e,t){return(n,r)=>{if(n==null)return!1;let i=Kt(n,t);return e.contains(i,r)}}function xo(e,t,n){return(r,i)=>{if(r==null)return!1;if(!i)return!0;let a=Kt(r,t),o=n==null?``:Kt(n,t);return o&&e.contains(o,i)&&o.length===i.length?!0:e.contains(a,i)}}function So(e){return Array.isArray(e)?e.map(e=>So(e)).join(`,`):e==null?``:String(e)}var Co=new Map;function wo(e={}){let t={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...e},n=`${So(e.locale)}|${JSON.stringify(t)}`,r=Co.get(n);if(r)return r;let i=new Intl.Collator(e.locale,t),a={contains(e,t,n){if(!t)return!0;let r=Kt(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(i.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=Kt(e,n);return i.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=Kt(e,n),a=t.length;return r.length>=a&&i.compare(r.slice(r.length-a),t)===0}};return Co.set(n,a),a}var To=wo,Eo=Symbol(`none`),Do={value:Eo,index:-1};function Oo(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:a,defaultInputValue:o,inputValue:s,open:c,defaultOpen:l=!1,selectionMode:u=`none`,onItemHighlighted:d,name:f,form:p,disabled:m=!1,readOnly:h=!1,required:g=!1,inputRef:_,grid:v=!1,items:y,filteredItems:b,filter:x,openOnInputClick:S=!0,autoHighlight:C=!1,keepHighlight:w=!1,highlightItemOnHover:T=!0,loopFocus:E=!0,itemToStringLabel:D,itemToStringValue:O,isItemEqualToValue:k=At,virtualized:ee=!1,inline:te=!1,fillInputOnItemPress:A=!0,modal:ne=!1,limit:re=-1,autoComplete:ie=`list`,formAutoComplete:ae,locale:oe,submitOnItemClick:se=!1}=e,{clearErrors:ce}=Rt(),{setDirty:le,validityData:ue,setFilled:de,name:fe,disabled:pe,setTouched:me,setFocused:he,validationMode:_e,validation:be}=zt(),we=dt(),Te=Ct({id:t}),ke=To({locale:oe}),[Ae,je]=q.useState(!1),[Pe,Re]=q.useState(null),Be=q.useRef([]),Ve=q.useRef([]),He=q.useRef(null),Ue=q.useRef(null),Ge=q.useRef(null),Ke=q.useRef(null),qe=q.useRef(null),Xe=q.useRef(!0),M=q.useRef(!1),N=q.useRef(null),tt=q.useRef(null),nt=q.useRef(null),at=q.useRef(Do),ot=q.useRef(null),ct=q.useRef([]),lt=q.useRef([]),ft=pe||m,pt=fe??f,mt=u===`multiple`,ht=u===`single`,gt=s!==void 0||o!==void 0,_t=y!==void 0,vt=b!==void 0,yt;yt=C===`always`?`always`:C?`input-change`:!1;let[P,bt]=Ot({controlled:i,default:mt?r??Se:r,name:`Combobox`,state:`selectedValue`}),St=q.useMemo(()=>x===null?()=>!0:x===void 0?ht&&!Ae?xo(ke,D,P):bo(ke,D):x,[x,ht,P,Ae,ke,D]),Tt=We(()=>gt?o??``:ht?Kt(P,D):``).current,[Et,Ft]=Ot({controlled:s,default:Tt,name:`Combobox`,state:`inputValue`}),[It,Lt]=Ot({controlled:c,default:l,name:`Combobox`,state:`open`}),Bt=Pt(y),Vt=Pe??(Et===``?``:String(Et).trim()),Ut=ht?Kt(P,D):``,Wt=ht&&!Ae&&Vt!==``&&Ut!==``&&Ut.length===Vt.length&&ke.contains(Ut,Vt),Gt=Wt?``:Vt,Xt=_t&&vt&&Wt,Zt=q.useMemo(()=>y?Bt?y.flatMap(e=>e.items):y:Se,[y,Bt]),Qt=q.useMemo(()=>{if(b&&!Xt)return b;if(!y)return Se;if(Bt){let e=y,t=[],n=0;for(let r of e){if(re>-1&&n>=re)break;let e=Gt===``?r.items:r.items.filter(e=>St(e,Gt,D));if(e.length===0)continue;let i=re>-1?re-n:1/0,a=e.slice(0,i);if(a.length>0){let e={...r,items:a};t.push(e),n+=a.length}}return t}if(Gt===``)return re>-1?Zt.slice(0,re):Zt;let e=[];for(let t of Zt){if(re>-1&&e.length>=re)break;St(t,Gt,D)&&e.push(t)}return e},[b,Xt,y,Bt,Gt,re,St,D,Zt]),$t=q.useMemo(()=>Bt?Qt.flatMap(e=>e.items):Qt,[Qt,Bt]),F=We(()=>new ge({id:Te,labelId:void 0,selectedValue:P,open:It,filter:St,query:Vt,items:y,selectionMode:u,listRef:Be,labelsRef:Ve,popupRef:He,emptyRef:qe,inputRef:Ue,startDismissRef:Ge,endDismissRef:Ke,keyboardActiveRef:Xe,chipsContainerRef:N,clearRef:tt,valuesRef:ct,allValuesRef:lt,selectionEventRef:nt,name:pt,form:p,disabled:ft,readOnly:h,required:g,grid:v,isGrouped:Bt,virtualized:ee,openOnInputClick:S,itemToStringLabel:D,isItemEqualToValue:k,modal:ne,autoHighlight:yt,submitOnItemClick:se,hasInputValue:gt,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:te,activeIndex:null,selectedIndex:null,popupProps:{},inputProps:{},triggerProps:{},itemProps:Ce,positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:u===`none`,onOpenChangeComplete:n||De,setOpen:De,setInputValue:De,setSelectedValue:De,setIndices:De,onItemHighlighted:De,handleSelection:De,forceMount:De,requestSubmit:De})).current,en=u===`none`?Et:P,tn=q.useMemo(()=>u===`none`?en:Array.isArray(P)?P.map(e=>Yt(e,O)):Yt(P,O),[en,O,u,P]),nn=Ze(d),rn=Ze(n),an=j(F,Y.activeIndex),on=j(F,Y.selectedIndex),sn=j(F,Y.positionerElement),cn=j(F,Y.listElement),ln=j(F,Y.triggerElement),un=j(F,Y.inputElement),dn=j(F,Y.inputGroupElement),fn=j(F,Y.inline),I=j(F,Y.inputInsidePopup),pn=j(F,Y.inputOwnsFormValue),mn=et(ln),{mounted:hn,setMounted:gn,transitionStatus:_n}=Ne(It),{openMethod:vn,triggerProps:yn}=wt(It),bn=Ze(()=>tn);Dt(I?mn:Ue,Te,en,bn,!ft,f);let xn=Ze(()=>{y?Ve.current=$t.map(e=>Kt(e,D)):F.set(`forceMounted`,!0)}),Sn=q.useRef(P);ve(()=>{P!==Sn.current&&xn()},[xn,P]);let Cn=Ze(e=>{F.update(e);let t=e.type||`none`;if(e.activeIndex!==void 0)if(e.activeIndex===null)at.current!==Do&&(at.current=Do,nn(void 0,ze(t,void 0,{index:-1})));else{let n=ct.current[e.activeIndex];at.current={value:n,index:e.activeIndex},nn(n,ze(t,void 0,{index:e.activeIndex}))}}),wn=Ze((t,n)=>{if(M.current=n.reason===Fe,e.onInputValueChange?.(t,n),!n.isCanceled){if(n.reason===`input-change`){let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&je(!0),ot.current={hasQuery:e},e&&yt&&F.state.activeIndex==null&&F.set(`activeIndex`,0)}}Ft(t)}}),Tn=Ze((t,n)=>{if(It!==t&&(n.reason===`escape-key`&&_t&&$t.length===0&&!F.state.emptyRef.current&&n.allowPropagation(),e.onOpenChange?.(t,n),!n.isCanceled&&(t&&mt&&I&&!fn&&Pe!==null&&(je(!1),Re(null),Et!==``&&wn(``,Le(Fe,n.event))),!t&&Ae&&(ht?(fn||Re(Vt),Vt===``&&je(!1)):mt&&(fn||Re(Vt),I&&Cn({activeIndex:null}),(!I||fn)&&wn(``,Le(Fe,n.event)))),Lt(t),!t&&I&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(me(!0),he(!1),_e===`onBlur`)))){let e=u===`none`?Et:P;be.commit(e)}}),En=Ze((e,t)=>{a?.(e,t),!t.isCanceled&&(bt(e),(u===`none`&&He.current&&A||ht&&!F.state.inputInsidePopup)&&wn(Kt(e,D),Le(t.reason,t.event)),ht&&e!=null&&t.reason!==`input-change`&&Ae&&!fn&&Re(Vt))}),Dn=Ze((e,t)=>{let n=t;if(n===void 0){if(an===null)return;n=ct.current[an]}let r=Me(e),i=nt.current??e;nt.current=null;let a=Le(Oe,i),o=r?.closest(`a`)?.getAttribute(`href`);if(o){o.startsWith(`#`)&&Tn(!1,a);return}if(mt){let e=Array.isArray(P)?P:[];if(En(jt(e,n,F.state.isItemEqualToValue)?qt(e,n,F.state.isItemEqualToValue):[...e,n],a),a.isCanceled||!(Ue.current&&Ue.current.value.trim()!==``))return;F.state.inputInsidePopup?wn(``,Le(Fe,a.event)):Tn(!1,a)}else{if(En(n,a),a.isCanceled)return;Tn(!1,a)}}),On=Ze(()=>{if(!F.state.submitOnItemClick)return;let e=be.inputRef.current?.form??F.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),kn=Ze(()=>{if(gn(!1),rn?.(!1),je(!1),Re(null),Cn(u===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),mt&&Ue.current&&Ue.current.value!==``&&!M.current&&wn(``,Le(Fe)),ht)if(F.state.inputInsidePopup)Ue.current&&Ue.current.value!==``&&wn(``,Le(Fe));else{let e=Kt(P,D);Ue.current&&Ue.current.value!==e&&wn(e,Le(e===``?Fe:rt))}}),An=q.useMemo(()=>fn&&sn?{current:sn.closest(`[role="dialog"]`)}:He,[fn,sn]);xe({enabled:!e.actionsRef,open:It,ref:An,onComplete(){It||kn()}}),q.useImperativeHandle(e.actionsRef,()=>({unmount:kn}),[kn]),ve(function(){if(It||u===`none`)return;let e=y?Zt:lt.current;if(mt){let t=Array.isArray(P)?P:[],n=t[t.length-1],r=xt(e,n,k);Cn({selectedIndex:r===-1?null:r})}else{let t=xt(e,P,k);Cn({selectedIndex:t===-1?null:t})}},[It,P,y,u,Zt,mt,k,Cn]),ve(()=>{y&&(ct.current=$t,Be.current.length=$t.length)},[y,$t]),ve(()=>{let e=ot.current;if(e&&(e.hasQuery?yt&&F.set(`activeIndex`,0):yt===`always`&&F.set(`activeIndex`,0),ot.current=null),!It&&!fn)return;let t=_t||vt?$t:ct.current,n=F.state.activeIndex;if(n==null){if(yt===`always`&&t.length>0){F.set(`activeIndex`,0);return}at.current!==Do&&(at.current=Do,F.state.onItemHighlighted(void 0,ze(rt,void 0,{index:-1})));return}if(n>=t.length){at.current!==Do&&(at.current=Do,F.state.onItemHighlighted(void 0,ze(rt,void 0,{index:-1}))),F.set(`activeIndex`,null);return}let r=t[n],i=at.current.value,a=i!==Eo&&Jt(r,i,F.state.isItemEqualToValue);(at.current.index!==n||!a)&&(at.current={value:r,index:n},F.state.onItemHighlighted(r,ze(rt,void 0,{index:n})))},[an,yt,vt,_t,$t,fn,It,F]),ve(()=>{if(u===`none`){de(String(Et)!==``);return}de(mt?Array.isArray(P)&&P.length>0:P!=null)},[de,u,Et,P,mt]),q.useEffect(()=>{_t&&yt&&$t.length===0&&Cn({activeIndex:null})},[_t,yt,$t.length,Cn]);function jn(e){let t=ue.initialValue;return Array.isArray(e)&&Array.isArray(t)?!Ht(e,t,(e,t)=>Jt(e,t,k)):e!==t}kt(Vt,()=>{!It||Vt===``||Vt===String(Tt)||je(!0)}),kt(P,()=>{if(u!==`none`&&(ce(pt),le(jn(P)),be.change(P),ht&&!gt&&!I)){let e=Kt(P,D);Et!==e&&wn(e,Le(rt))}}),kt(Et,()=>{u===`none`&&(ce(pt),le(Et!==ue.initialValue),be.change(Et))}),kt(y,()=>{if(!ht||gt||I||Ae)return;let e=Kt(P,D);Et!==e&&wn(e,Le(rt))});let Mn=ut({open:fn?!0:It,onOpenChange:Tn,elements:{reference:I?ln:un,floating:sn}}),Nn,Pn;fn||(Nn=v?`grid`:`listbox`,Pn=It?`true`:`false`);let Fn=q.useMemo(()=>{let e=un?.tagName===`INPUT`,t=un==null||e,n=t||It,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=Pn,r[`aria-haspopup`]=Nn,r[`aria-controls`]=It?cn?.id:void 0,r[`aria-autocomplete`]=ie),{reference:r,floating:{role:`presentation`}}},[un,It,Pn,Nn,cn?.id,ie]),In=Nt(Mn,{enabled:!h&&!ft&&S,event:`mousedown-only`,toggle:!1,touchOpenDelay:I?0:100,reason:it}),Ln=$e(Mn,{enabled:!h&&!ft&&!fn,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:fn?!0:void 0,outsidePress(e){let t=Me(e);return!ye(ln,t)&&!ye(tt.current,t)&&!ye(N.current,t)&&!ye(dn,t)}}),Rn=Mt(Mn,{enabled:!h&&!ft,id:Te,listRef:Be,activeIndex:an,selectedIndex:on,virtual:!0,loopFocus:E,allowEscape:E&&!yt,focusItemOnOpen:Ae||u===`none`&&!yt?!1:`auto`,focusItemOnHover:T,resetOnPointerLeave:!w,orientation:v?`horizontal`:void 0,rtl:we===`rtl`,disabledIndices:Se,grid:v?so:void 0,onNavigate(e,t){!t&&!It||_n===`ending`||Cn(t?{activeIndex:e,type:Xe.current?`keyboard`:`pointer`}:{activeIndex:e})}}),zn=q.useMemo(()=>st(Rn.reference,{onKeyDown(e){v&&F.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},Ln.reference,In.reference,Fn.reference),[Rn.reference,Ln.reference,In.reference,Fn.reference,v,F]),Bn=q.useMemo(()=>st(Ee,Rn.floating,Ln.floating,Fn.floating),[Rn.floating,Ln.floating,Fn.floating]),Vn=q.useMemo(()=>{let e=Rn.item;return e?{...e,onFocus:void 0}:Ce},[Rn.item]);Ye(()=>{F.update({inline:te,popupProps:Bn,inputProps:zn,triggerProps:yn,itemProps:Vn,setOpen:Tn,setInputValue:wn,setSelectedValue:En,setIndices:Cn,onItemHighlighted:nn,handleSelection:Dn,forceMount:xn,requestSubmit:On})}),ve(()=>{F.update({id:Te,selectedValue:P,open:It,mounted:hn,transitionStatus:_n,items:y,inline:te,popupProps:Bn,inputProps:zn,triggerProps:yn,openMethod:vn,itemProps:Vn,selectionMode:u,name:pt,form:p,disabled:ft,readOnly:h,required:g,grid:v,isGrouped:Bt,virtualized:ee,onOpenChangeComplete:rn,openOnInputClick:S,itemToStringLabel:D,modal:ne,autoHighlight:yt,isItemEqualToValue:k,submitOnItemClick:se,hasInputValue:gt,requestSubmit:On,inputOwnsFormValue:u===`none`&&(te||!F.state.inputInsidePopup)})},[F,Te,P,It,hn,_n,y,Bn,zn,Vn,vn,yn,u,pt,ft,h,g,be,v,Bt,ee,rn,S,D,ne,k,se,gt,te,On,yt,p]);let Hn=Ie(_,be.inputRef),Un=q.useMemo(()=>({query:Vt,hasItems:_t,filteredItems:Qt,flatFilteredItems:$t}),[Vt,_t,Qt,$t]),Wn=q.useMemo(()=>Array.isArray(en)?``:Yt(en,O),[en,O]),Gn=mt&&Array.isArray(P)&&P.length>0,Kn=mt||u===`none`&&pn?void 0:pt,qn=q.useMemo(()=>!mt||!Array.isArray(P)||!pt?null:P.map(e=>{let t=Yt(e,O);return(0,J.jsx)(`input`,{type:`hidden`,form:p,name:pt,value:t,disabled:ft},t)}),[mt,P,p,pt,O,ft]),Jn=(0,J.jsxs)(q.Fragment,{children:[e.children,(0,J.jsx)(`input`,{...be.getValidationProps(ft,{onFocus(){if(I){ln?.focus();return}(Ue.current||ln)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||ft||h)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=Le(rt,e.nativeEvent),i=()=>ct.current.findIndex(e=>Yt(e,O).toLowerCase()===n||Kt(e,D).toLowerCase()===n);function a(){if(mt)return;if(u===`none`){wn(t,r);return}let e=i();e===-1&&(e=ct.current.findIndex((e,t)=>{let r=Ve.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:ct.current[e];a!=null&&En?.(a,r)}ht&&(xn(),y&&i()===-1&&F.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:Te&&Kn==null?`${Te}-hidden-input`:void 0,form:p,name:Kn,autoComplete:ae,disabled:ft,required:g&&!Gn,readOnly:h,value:Wn,ref:Hn,style:Kn?Qe:Je,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),qn]});return(0,J.jsx)(co.Provider,{value:F,children:(0,J.jsx)(lo.Provider,{value:Mn,children:(0,J.jsx)(fo.Provider,{value:_t,children:(0,J.jsx)(uo.Provider,{value:Un,children:(0,J.jsx)(po.Provider,{value:Et,children:Jn})})})})})}function ko(e){let{openOnInputClick:t=!1,value:n,defaultValue:r,onValueChange:i,mode:a=`list`,itemToStringValue:o,...s}=e,c=a===`inline`||a===`both`,l=a===`inline`||a===`none`,u=n!==void 0,[d,f]=q.useState(r??``),[p,m]=q.useState(``);q.useEffect(()=>{u&&m(``)},[n,u]);let h;h=c&&p!==``?p:u?n??``:d;let g=To(),_=q.useMemo(()=>s.filter===void 0?g.contains:s.filter,[s.filter,g]),v=String(u?n:d).trim(),y=q.useMemo(()=>a===`both`?_===null?null:(e,t,n)=>_(e,v,n):l?null:_,[_,a,v,l]);function b(e,t){m(``),u||f(e),i?.(e,t)}function x(t,n){e.onItemHighlighted?.(t,n),n.reason!==`pointer`&&m(c?t==null?``:Kt(t,o):``)}return(0,J.jsx)(Oo,{...s,itemToStringLabel:o,openOnInputClick:t,selectionMode:`none`,fillInputOnItemPress:!0,filter:y,autoComplete:a,inputValue:h,defaultInputValue:r,onInputValueChange:b,onItemHighlighted:x})}var Ao={...Te,...Et,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":``}:null},jo=q.createContext(void 0);function Mo(){return q.useContext(jo)}var No=q.createContext(void 0);function Po(e){let t=q.useContext(No);if(t===void 0&&!e)throw Error(je(21));return t}var Fo=q.forwardRef(function(e,t){let n=mo(),{buttonRef:r,getButtonProps:i}=Xt({native:!1}),a=Ie(t,r);function o(e){n.state.setOpen(!1,Le(Ke,e.nativeEvent,e.currentTarget))}return(0,J.jsx)(`span`,{ref:a,...i({onClick:o}),"aria-label":`Dismiss`,tabIndex:void 0,style:Qe})}),Io=q.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...s}=e,{state:c,disabled:l,setTouched:u,setFocused:d,validationMode:f,validation:p}=zt(),{labelId:m}=St(),h=Mo(),g=!!Po(!0),_=mo(),{filteredItems:v}=go(),y=_o(),b=dt(),x=j(_,Y.required),S=j(_,Y.disabled),C=j(_,Y.readOnly),w=j(_,Y.name),T=j(_,Y.form),E=j(_,Y.selectionMode),D=j(_,Y.autoHighlight),O=j(_,Y.inputProps),k=j(_,Y.triggerProps),ee=j(_,Y.open),te=j(_,Y.mounted),A=j(_,Y.selectedValue),ne=j(_,Y.popupSide),re=j(_,Y.positionerElement),ie=j(_,Y.id),ae=j(_,Y.inline),oe=j(_,Y.modal),se=!!D,ce=te&&re?ne:null,le=l||S||i,ue=v.length===0,de=g||ae,fe=!de||oe,pe=Ae(a??(de?void 0:ie)),me=It(m,void 0),he=g?Tt:c,[ge,_e]=q.useState(null),ve=q.useRef(!1),ye=q.useRef(null),be=q.useRef(!1),xe=E===`none`&&!g,Se=Ze(e=>{let t=g||_.state.inline;t&&!_.state.hasInputValue&&_.state.setInputValue(``,Le(rt)),_.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:xe})}),Ce=g||!p?s:p.getValidationProps(le,s),we={...he,open:ee,disabled:le,readOnly:C,popupSide:ce,listEmpty:ue};function Te(e){if(!h)return;let t,{highlightedChipIndex:n}=h,r=h.chipsRef.current.length,i=b===`rtl`,a=i?`ArrowRight`:`ArrowLeft`,o=i?`ArrowLeft`:`ArrowRight`;if(n!==void 0){if(e.key===a)e.preventDefault(),t=n>0?n-1:void 0;else if(e.key===o)e.preventDefault(),t=n<r-1?n+1:void 0;else if(e.key===`Backspace`||e.key===`Delete`){e.preventDefault();let r=n>=A.length-1?A.length-2:n;t=r>=0?r:void 0,_.state.setIndices({activeIndex:null,selectedIndex:null,type:`keyboard`})}return t}return e.key===a&&(e.currentTarget.selectionStart??0)===0&&A.length>0?(e.preventDefault(),t=r>0?r-1:void 0):e.key===`Backspace`&&e.currentTarget.value===``&&A.length>0&&(_.state.setIndices({activeIndex:null,selectedIndex:null,type:`keyboard`}),e.preventDefault()),t}let Ee=Pe(`input`,e,{state:we,ref:[t,_.state.inputRef,Se],props:[O,k,{type:`text`,value:e.value??ge??y,"aria-readonly":C||void 0,"aria-required":x||void 0,"aria-labelledby":me,disabled:le,readOnly:C,required:E===`none`?x:void 0,form:T,...xe&&w&&{name:w},id:pe,onFocus(){if(d(!0),!ae||!be.current)return;be.current=!1;let e=ye.current;e==null||!Object.hasOwn(_.state.valuesRef.current,e)||_.state.setIndices({activeIndex:e})},onBlur(){u(!0),d(!1);let e=_.state.activeIndex;if(ae&&e!==null&&D!==`always`&&(ye.current=e,be.current=!0,_.state.setIndices({activeIndex:null})),f===`onBlur`){let e=E===`none`?y:A;p.commit(e)}},onCompositionStart(e){tt||(ve.current=!0,_e(e.currentTarget.value))},onCompositionEnd(e){ve.current=!1;let t=e.currentTarget.value;_e(null),_.state.setInputValue(t,Le(at,e.nativeEvent))},onChange(e){let t=e.nativeEvent.inputType,n=!t||t===`insertReplacementText`,r=ve.current||!n;if(ve.current){let t=e.currentTarget.value;_e(t),t===``&&!_.state.openOnInputClick&&!_.state.inputInsidePopup&&_.state.setOpen(!1,Le(Fe,e.nativeEvent));let n=t.trim(),i=se&&n!==``;!C&&!le&&n&&r&&(_.state.setOpen(!0,Le(at,e.nativeEvent)),se||_.state.setIndices({activeIndex:null,selectedIndex:null,type:_.state.keyboardActiveRef.current?`keyboard`:`pointer`})),ee&&_.state.activeIndex!==null&&!i&&_.state.setIndices({activeIndex:null,selectedIndex:null,type:_.state.keyboardActiveRef.current?`keyboard`:`pointer`});return}let i=Le(at,e.nativeEvent);if(_.state.setInputValue(e.currentTarget.value,i),i.isCanceled)return;let a=e.currentTarget.value===``,o=Le(Fe,e.nativeEvent);a&&!_.state.inputInsidePopup&&(E===`single`&&_.state.setSelectedValue(null,o),_.state.openOnInputClick||_.state.setOpen(!1,o));let s=e.currentTarget.value.trim();!C&&!le&&s&&r&&(_.state.setOpen(!0,Le(at,e.nativeEvent)),se||_.state.setIndices({activeIndex:null,selectedIndex:null,type:_.state.keyboardActiveRef.current?`keyboard`:`pointer`})),ee&&_.state.activeIndex!==null&&!se&&_.state.setIndices({activeIndex:null,selectedIndex:null,type:_.state.keyboardActiveRef.current?`keyboard`:`pointer`})},onKeyDown(e){if(le||C||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;_.state.keyboardActiveRef.current=!0;let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=b===`rtl`;if(e.key===`Home`){qe(e);let n=Ve&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){qe(e);let i=Ve&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!te&&e.key===`Escape`){let t=E===`multiple`&&Array.isArray(A)?A.length===0:A===null,n=Le(Be,e.nativeEvent),r=E===`multiple`?[]:null;_.state.setInputValue(``,n),_.state.setSelectedValue(r,n),!t&&!_.state.inline&&!n.isPropagationAllowed&&e.stopPropagation();return}if(h&&e.key===`Backspace`&&t.value===``&&h.highlightedChipIndex===void 0&&Array.isArray(A)&&A.length>0){let t=h.chipsRef.current.length,n=t>0?t-1:A.length-1,r=A.filter((e,t)=>t!==n);_.state.setIndices({activeIndex:null,selectedIndex:null,type:_.state.keyboardActiveRef.current?`keyboard`:`pointer`}),_.state.setSelectedValue(r,Le(rt,e.nativeEvent));return}let i=h?.highlightedChipIndex!==void 0,a=Te(e);if(h?.setHighlightedChipIndex(a),a===void 0?i&&_.state.inputRef.current?.focus():h?.chipsRef.current[a]?.focus(),e.which!==229&&e.key===`Enter`&&ee){let t=_.state.activeIndex,n=e.nativeEvent;if(t===null){if(ae)return;_.state.setOpen(!1,Le(rt,n));return}qe(e);let r=_.state.listRef.current[t];r&&(_.state.selectionEventRef.current=n,r.click(),_.state.selectionEventRef.current=null)}},onPointerMove(){_.state.keyboardActiveRef.current=!1},onPointerDown(){_.state.keyboardActiveRef.current=!1}},Ce],stateAttributesMapping:Ao}),De=g?(0,J.jsx)(bt.Provider,{value:Bt,children:Ee}):Ee;return(0,J.jsxs)(q.Fragment,{children:[ee&&fe&&(0,J.jsx)(Fo,{ref:_.state.startDismissRef}),De]})}),Lo=q.createContext(null);function Ro(){return q.useContext(Lo)}function zo(e){let{children:t}=e,{filteredItems:n}=go(),r=Ro(),i=r?r.items:n;return i?(0,J.jsx)(q.Fragment,{children:i.map(t)}):null}var Bo=q.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=mo(),l=ho(),u=!!Po(!0),{filteredItems:d,hasItems:f}=go(),p=j(c,Y.selectionMode),m=j(c,Y.grid),h=j(c,Y.popupProps),g=j(c,Y.virtualized),_=j(c,Y.forceMounted),v=p===`multiple`,y=d.length===0,b=Ze(e=>{c.set(`positionerElement`,e)}),x=Ze(e=>{c.set(`listElement`,e)}),S=q.useMemo(()=>typeof o==`function`?n||(n=(0,J.jsx)(zo,{children:o})):o,[o]),C={empty:y},w=l.useState(`floatingId`),T=Pe(`div`,e,{state:C,ref:[t,x,u?null:b],props:[h,{children:S,tabIndex:-1,id:w,role:m?`grid`:`listbox`,"aria-multiselectable":v?`true`:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;qe(e);let n=e.nativeEvent,r=c.state.listRef.current[t];r&&(c.state.selectionEventRef.current=n,r.click(),c.state.selectionEventRef.current=null)}},onKeyDownCapture(){c.state.keyboardActiveRef.current=!0},onPointerMoveCapture(){c.state.keyboardActiveRef.current=!1}},s]});if(g)return T;let E=f&&!_?void 0:c.state.labelsRef;return(0,J.jsx)(Vt,{elementsRef:c.state.listRef,labelsRef:E,children:T})}),Vo=`⁠`;function Ho(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(;t.nextNode();){let e=t.currentNode;e.nodeValue!==``&&(n=e)}return n}function Uo(){let e=ke(),t=q.useRef(null);return q.useEffect(()=>{if(ot)return;let n=t.current;if(n==null)return;let r=Ho(n);if(r==null)return;let i=r.nodeValue??``,a=`${i}${Vo}`;return r.nodeValue=a,e.start(200,()=>{r.nodeValue===a&&(r.nodeValue=i)}),()=>{e.clear(),r.nodeValue===a&&(r.nodeValue=i)}},[t,e]),t}var Wo=q.createContext(void 0);function Go(){let e=q.useContext(Wo);if(e===void 0)throw Error(je(20));return e}var Ko=q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=mo(),a=j(i,Y.mounted),o=j(i,Y.forceMounted);return a||n||o?(0,J.jsx)(Wo.Provider,{value:n,children:(0,J.jsx)(Re,{ref:t,...r})}):null}),qo=q.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`bottom`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=He,style:g,..._}=e,v=mo(),{filteredItems:y}=go(),b=ho(),x=Go(),S=j(v,Y.modal),C=j(v,Y.open),w=j(v,Y.mounted),T=j(v,Y.openMethod),E=j(v,Y.positionerElement),D=j(v,Y.triggerElement),O=j(v,Y.inputElement),k=j(v,Y.inputGroupElement),ee=j(v,Y.inputInsidePopup),te=j(v,Y.transitionStatus),A=y.length===0,ne=pt({anchor:i??(ee?D:k??O),floatingRootContext:b,positionMethod:a,mounted:w,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:x,collisionAvoidance:h,lazyFlip:!0});Ft(C&&S,T===`touch`,E,D);let re={open:C,side:ne.side,align:ne.align,anchorHidden:ne.anchorHidden,empty:A};ve(()=>{v.set(`popupSide`,ne.side)},[v,ne.side]);let ie=Ze(e=>{v.set(`positionerElement`,e)}),ae=_t(e,re,{styles:ne.positionerStyles,transitionStatus:te,props:_,refs:[t,ie],hidden:!w,inert:!C});return(0,J.jsxs)(No.Provider,{value:ne,children:[w&&S&&(0,J.jsx)(Xe,{inert:nt(!C),cutout:k??O??D}),ae]})}),Jo={..._e,...be},Yo=q.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=mo(),l=Po(),u=ho(),{filteredItems:d}=go(),f=j(c,Y.mounted),p=j(c,Y.open),m=j(c,Y.openMethod),h=j(c,Y.transitionStatus),g=j(c,Y.inputInsidePopup),_=j(c,Y.inputElement),v=j(c,Y.modal),y=j(c,Y.id),b=d.length===0,x=s.id??(g?yo(y):void 0);ve(()=>(c.set(`popupId`,c.state.popupRef.current?.id||x),()=>{c.set(`popupId`,void 0)}),[c,x]),xe({open:p,ref:c.state.popupRef,onComplete(){p&&c.state.onOpenChangeComplete(!0)}});let S=Pe(`div`,e,{state:{open:p,side:l.side,align:l.align,anchorHidden:l.anchorHidden,transitionStatus:h,empty:b},ref:[t,c.state.popupRef],props:[{id:x,role:g?`dialog`:`presentation`,tabIndex:-1,onFocus(e){let t=Me(e.nativeEvent);m!==`touch`&&(ye(c.state.listElement,t)||t===e.currentTarget)&&c.state.inputRef.current?.focus()}},ft(h),s],stateAttributesMapping:Jo}),C=a===void 0?g?e=>e===`touch`?c.state.popupRef.current:_:!1:a,w;w=o??(g?void 0:!1);let T=!g||v;return(0,J.jsx)(Ue,{context:u,disabled:!f,modal:T,openInteractionType:m,initialFocus:C,returnFocus:w,getInsideElements:()=>[c.state.startDismissRef.current,c.state.endDismissRef.current],children:(0,J.jsxs)(q.Fragment,{children:[S,T&&(0,J.jsx)(Fo,{ref:c.state.endDismissRef})]})})}),Xo=q.createContext(void 0),Zo=q.createContext(!1);function Qo(){return q.useContext(Zo)}var $o=e(ne(),1);function es(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:c=null,index:l,disabled:u=!1,nativeButton:d=!1,...f}=t,p=q.useRef(!1),m=q.useRef(null),h=Wt({index:l,textRef:m,indexGuessBehavior:Ut.GuessFromOrder}),g=mo(),_=Qo(),v=vo(),y=j(g,Y.open),b=j(g,Y.selectionMode),x=j(g,Y.readOnly),S=j(g,Y.isItemEqualToValue),C=b!==`none`,w=l??(r?i??-1:h.index),T=h.index!==-1,E=j(g,Y.id),D=j(g,Y.isActive,w),O=j(g,Y.isSelected,c),k=j(g,Y.itemProps),ee=q.useRef(null),te=E!=null&&T?`${E}-${w}`:void 0,A=O&&C;ve(()=>{if(!(T&&(r||l!=null)))return;let e=g.state.listRef.current;return e[w]=ee.current,()=>{delete e[w]}},[T,r,w,l,g]),ve(()=>{if(!T||v)return;let e=g.state.valuesRef.current;return e[w]=c,b!==`none`&&g.state.allValuesRef.current.push(c),()=>{delete e[w]}},[T,v,w,c,g,b]),ve(()=>{if(!y){p.current=!1;return}if(!T||v)return;let e=g.state.selectedValue;Jt(c,Array.isArray(e)?e[e.length-1]:e,S)&&g.set(`selectedIndex`,w)},[T,v,y,g,w,c,S]);let{getButtonProps:ne,buttonRef:re}=Xt({disabled:u,focusableWhenDisabled:!0,native:d,composite:!0}),ie={disabled:u,selected:A,highlighted:D};function ae(e){function t(){g.state.handleSelection(e,c)}g.state.submitOnItemClick?($o.flushSync(t),g.state.requestSubmit()):t()}let oe={id:te,role:_?`gridcell`:`option`,"aria-selected":C?A:void 0,tabIndex:void 0,onPointerDownCapture(e){p.current=!0,e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){u||x||ae(e.nativeEvent)},onMouseUp(e){let t=p.current;p.current=!1,!(u||x||e.button!==0||t||!D)&&ae(e.nativeEvent)}},se=Pe(`div`,t,{ref:[re,n,h.ref,ee],state:ie,props:[k,oe,f,ne]}),ce=q.useMemo(()=>({selected:A,textRef:m}),[A,m]);return(0,J.jsx)(Xo.Provider,{value:ce,children:se})}function ts(e){let{componentProps:t,forwardedRef:n}=e,r=j(mo(),Y.isItemEqualToValue),{flatFilteredItems:i}=go();return(0,J.jsx)(es,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:xt(i,t.value??null,r)})}var ns=q.memo(q.forwardRef(function(e,t){let n=j(mo(),Y.virtualized);return n&&e.index==null?(0,J.jsx)(ts,{componentProps:e,forwardedRef:t}):(0,J.jsx)(es,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})})),rs=q.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=go(),c=mo(),l=Uo(),u=s.length===0?a:null;return Pe(`div`,e,{ref:[t,c.state.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})}),is=[`{{human.clock}}`,`{{human.duration}}`,`{{human.expectedEnd}}`,`{{human.runningTimer}}`,`{{human.elapsedTime}}`,`{{human.startedAt}}`],as=[`{{clock}}`,`{{timer.addedTime}}`,`{{timer.current}}`,`{{timer.duration}}`,`{{timer.elapsed}}`,`{{timer.expectedFinish}}`,`{{timer.secondaryTimer}}`,`{{timer.startedAt}}`,`{{rundown.selectedEventIndex}}`,`{{rundown.numEvents}}`,`{{rundown.plannedStart}}`,`{{rundown.plannedEnd}}`,`{{rundown.actualStart}}`,`{{offset.absolute}}`,`{{offset.relative}}`,`{{offset.expectedRundownEnd}}`,`{{offset.expectedGroupEnd}}`,`{{offset.expectedFlagStart}}`],os=[`{{eventNow.id}}`,`{{eventNow.cue}}`,`{{eventNow.title}}`,`{{eventNow.note}}`,`{{eventNow.timeStart}}`,`{{eventNow.timeEnd}}`,`{{eventNow.duration}}`,`{{eventNow.colour}}`,`{{eventNow.delay}}`],ss=[`{{eventNext.id}}`,`{{eventNext.cue}}`,`{{eventNext.title}}`,`{{eventNext.note}}`,`{{eventNext.timeStart}}`,`{{eventNext.timeEnd}}`,`{{eventNext.duration}}`,`{{eventNext.colour}}`,`{{eventNext.delay}}`],cs=[`{{groupNow.id}}`,`{{groupNow.title}}`,`{{groupNow.note}}`,`{{groupNow.colour}}`,`{{groupNow.timeStart}}`,`{{groupNow.timeEnd}}`,`{{groupNow.duration}}`],ls=e=>[`{{auxtimer${e}.current}}`,`{{auxtimer${e}.duration}}`,`{{auxtimer${e}.playback}}`,`{{auxtimer${e}.direction}}`];function us(e){return[...is,...as,...os,...Object.entries(e).map(([e])=>`{{eventNow.custom.${e}}}`),...ss,...Object.entries(e).map(([e])=>`{{eventNext.custom.${e}}}`),...cs,...Object.entries(e).map(([e])=>`{{groupNow.custom.${e}}}`),...ls(1),...ls(2),...ls(3)]}function ds(e,t){if(e===t)return``;if(e.endsWith(`{{`)&&t.startsWith(`{{`))return t.substring(2);if(e.endsWith(`{`)&&t.startsWith(`{{`))return t.substring(1);for(let n=0;n<t.length;n++){let r=t.substring(0,n+1);if(e.endsWith(r))return t.substring(n+1)}return``}function fs(e,t=e.length){let n=e.slice(0,t),r=n.lastIndexOf(`{{`);if(r===-1||n.lastIndexOf(`}}`)>r)return null;let i=e.indexOf(`}}`,r),a=e.indexOf(`{{`,t);return{end:i!==-1&&(a===-1||i<a)?i+2:t,start:r,template:e.slice(r,t)}}function ps(e,t=e.length){return fs(e,t)?.template??``}function ms(e,t,n=e.length){let r=fs(e,n);if(!r){let n=e+ds(e,t);return{value:n,cursorIndex:n.length}}return{value:`${e.slice(0,r.start)}${t}${e.slice(r.end)}`,cursorIndex:r.start+t.length}}function hs(e,t){return e?.selectionStart??t.length}function gs(e,t){requestAnimationFrame(()=>{e?.focus(),e?.setSelectionRange(t,t)})}function _s(e,t,n,r){let[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(e.length),c=ps(e,o),l=(0,q.useMemo)(()=>c?t.filter(e=>e.startsWith(c)):[],[c,t]),u=(0,q.useCallback)((e,t)=>{s(t),a(!!ps(e,t))},[]),d=(0,q.useCallback)(()=>{u(e,hs(n.current,e))},[n,u,e]);return{handleValueChange:(0,q.useCallback)((t,i)=>{if(i.reason===`item-press`){i.cancel();let a=ms(e,t,o);u(a.value,a.cursorIndex),r(a.value),gs(n.current,a.cursorIndex);return}u(t,hs(n.current,t)),r(t)},[o,n,r,u,e]),open:i&&l.length>0,setCursorForValue:u,setShowSuggestions:a,suggestions:l,updateCursor:d}}var vs={blink:`_blink_1u4lw_1`,fourtyfive:`_fourtyfive_1u4lw_13`,inputShell:`_inputShell_1u4lw_17`,fluid:`_fluid_1u4lw_21`,input:`_input_1u4lw_17`,expandButton:`_expandButton_1u4lw_29`,positioner:`_positioner_1u4lw_36`,popup:`_popup_1u4lw_40`,list:`_list_1u4lw_50`,item:`_item_1u4lw_59`,expandedEditor:`_expandedEditor_1u4lw_72`,footerHint:`_footerHint_1u4lw_78`};function ys(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function bs(e,t,n){n?.({target:{name:e,value:t},currentTarget:{name:e,value:t}})}function xs({className:e,disabled:t,fluid:n,height:r=`medium`,onChange:i,readOnly:a,ref:o,value:s,variant:c=`subtle`,...l}){let{data:u}=ia(),d=(0,q.useRef)(null),[f,p]=(0,q.useState)(s||``),[m,h]=(0,q.useState)(!1),g=(0,q.useMemo)(()=>us(u),[u]),_=(0,q.useCallback)(e=>{p(e),bs(l.name,e,i)},[i,l.name]),v=_s(f,g,d,_),{setCursorForValue:y}=v;(0,q.useEffect)(()=>{let e=s||``;p(e),y(e,e.length)},[y,s]);let b=(0,q.useCallback)(e=>{d.current=e,ys(o,e)},[o]),x=()=>{v.setShowSuggestions(!1),h(!0)},S=()=>{h(!1)},C=e=>{_(e),v.setCursorForValue(e,e.length),h(!1)};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ss,{autocomplete:v,value:f,children:(0,J.jsxs)(`div`,{className:an([vs.inputShell,n&&vs.fluid]),children:[(0,J.jsx)(Io,{ref:b,className:an([di.input,di[c],di[r],n&&di.fluid,vs.input,e]),...l,disabled:t,onClick:v.updateCursor,onFocus:v.updateCursor,onKeyUp:v.updateCursor,onSelect:v.updateCursor,readOnly:a}),(0,J.jsx)(L,{"aria-label":`Expand template editor`,className:vs.expandButton,disabled:t||a,onClick:x,size:`small`,title:`Expand template editor`,variant:`ghosted-white`,children:(0,J.jsx)(dn,{})})]})}),(0,J.jsx)(Cs,{autocompleteList:g,isOpen:m,onClose:S,onSave:C,value:f})]})}function Ss({autocomplete:e,children:t,value:n}){return(0,J.jsxs)(ko,{items:e.suggestions,autoHighlight:!0,highlightItemOnHover:!0,mode:`none`,open:e.open,value:n,onOpenChange:e.setShowSuggestions,onValueChange:e.handleValueChange,children:[t,(0,J.jsx)(ws,{})]})}function Cs({autocompleteList:e,isOpen:t,onClose:n,onSave:r,value:i}){let a=(0,q.useRef)(null),[o,s]=(0,q.useState)(i),c=_s(o,e,a,s),{setShowSuggestions:l}=c;(0,q.useEffect)(()=>{t&&(s(i),l(!1))},[t,l,i]);let u=()=>{l(!1),n()};return(0,J.jsx)(Ii,{isOpen:t,onClose:u,showBackdrop:!0,showCloseButton:!0,title:`Edit template`,bodyElements:(0,J.jsx)(Ss,{autocomplete:c,value:o,children:(0,J.jsx)(Io,{autoFocus:!0,className:vs.expandedEditor,onClick:c.updateCursor,onFocus:c.updateCursor,onKeyUp:c.updateCursor,onSelect:c.updateCursor,render:(0,J.jsx)(Ki,{ref:a,fluid:!0,resize:`none`,rows:8})})}),footerElements:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:vs.footerHint,children:[`Start a template with `,`{{`,` to see autocomplete.`]}),(0,J.jsx)(M,{onClick:u,children:`Cancel`}),(0,J.jsx)(M,{onClick:()=>{l(!1),r(o)},variant:`primary`,children:`Save`})]})})}function ws(){return(0,J.jsx)(Ko,{children:(0,J.jsx)(qo,{side:`bottom`,align:`start`,className:vs.positioner,children:(0,J.jsx)(Yo,{className:vs.popup,children:(0,J.jsx)(Bo,{className:vs.list,children:(0,J.jsx)(zo,{children:e=>(0,J.jsx)(ns,{value:e,className:vs.item,children:e},e)})})})})})}var Ts={blink:`_blink_xhhrk_1`,fourtyfive:`_fourtyfive_xhhrk_13`,outerColumn:`_outerColumn_xhhrk_17`,innerColumn:`_innerColumn_xhhrk_30`,ruleSection:`_ruleSection_xhhrk_36`,titleSection:`_titleSection_xhhrk_42`,filterSection:`_filterSection_xhhrk_43`,oscSection:`_oscSection_xhhrk_44`,httpSection:`_httpSection_xhhrk_45`,actionSection:`_actionSection_xhhrk_46`,test:`_test_xhhrk_100`,outputCard:`_outputCard_xhhrk_104`};function Es({index:e,register:t,setValue:n,rowErrors:r,value:i,children:a,watch:o}){let[s,c]=(0,q.useState)(i),l=t=>{n(`outputs.${e}.action`,t,{shouldDirty:!0}),c(t)};return(0,J.jsxs)(`div`,{className:Ts.actionSection,children:[(0,J.jsxs)(`label`,{children:[`Action`,(0,J.jsx)(Gt,{onValueChange:e=>{e!==null&&l(e)},value:o(`outputs.${e}.action`),options:[{value:`aux1-pause`,label:`Aux 1: pause`},{value:`aux2-pause`,label:`Aux 2: pause`},{value:`aux3-pause`,label:`Aux 3: pause`},{value:`aux1-start`,label:`Aux 1: start`},{value:`aux2-start`,label:`Aux 2: start`},{value:`aux3-start`,label:`Aux 3: start`},{value:`aux1-stop`,label:`Aux 1: stop`},{value:`aux2-stop`,label:`Aux 2: stop`},{value:`aux3-stop`,label:`Aux 3: stop`},{value:`aux1-set`,label:`Aux 1: set`},{value:`aux2-set`,label:`Aux 2: set`},{value:`aux3-set`,label:`Aux 3: set`},{value:`playback-start`,label:`Playback: start`},{value:`playback-stop`,label:`Playback: stop`},{value:`playback-pause`,label:`Playback: pause`},{value:`playback-roll`,label:`Playback: roll`},{value:`message-set`,label:`Primary Message`},{value:`message-secondary`,label:`Secondary Message`}]}),(0,J.jsx)(G,{children:r?.action?.message})]}),s.startsWith(`aux`)&&s.endsWith(`set`)&&(0,J.jsxs)(`label`,{children:[`New time`,(0,J.jsx)(R,{...t(`outputs.${e}.time`,{required:{value:!0,message:`Required field`}}),fluid:!0,placeholder:`eg: 10m5s`}),(0,J.jsx)(G,{children:r?.time?.message})]}),s===`message-set`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`label`,{children:[`Text (leave empty for no change)`,(0,J.jsx)(xs,{...t(`outputs.${e}.text`),value:o(`outputs.${e}.text`)??``,fluid:!0,placeholder:`eg: Timer is finished`}),(0,J.jsx)(G,{children:r?.text?.message})]}),(0,J.jsxs)(`label`,{children:[`Visibility`,(0,J.jsx)(Gt,{onValueChange:t=>{let r=t===null?void 0:t;n(`outputs.${e}.visible`,r,{shouldDirty:!0})},value:o(`outputs.${e}.visible`),options:[{value:null,label:`Untouched`},{value:!0,label:`Show`},{value:!1,label:`Hide`}]}),(0,J.jsx)(G,{children:r?.visible?.message})]})]}),s===`message-secondary`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`label`,{children:[`Text (leave empty for no change)`,(0,J.jsx)(xs,{...t(`outputs.${e}.text`),value:o(`outputs.${e}.text`)??``,fluid:!0,placeholder:`eg: Next up: keynote`}),(0,J.jsx)(G,{children:r?.text?.message})]}),(0,J.jsxs)(`label`,{children:[`Timer secondary source`,(0,J.jsx)(Gt,{onValueChange:t=>{if(t!==null){if(t===`no-change`){n(`outputs.${e}.secondarySource`,void 0,{shouldDirty:!0});return}if(t===`null`){n(`outputs.${e}.secondarySource`,null,{shouldDirty:!0});return}n(`outputs.${e}.secondarySource`,t,{shouldDirty:!0})}},value:o(`outputs.${e}.secondarySource`)??`no-change`,options:[{value:`no-change`,label:`No change`},{value:`aux1`,label:`Auxiliary timer 1`},{value:`aux2`,label:`Auxiliary timer 2`},{value:`aux3`,label:`Auxiliary timer 3`},{value:`secondary`,label:`Secondary`},{value:`null`,label:`None`}]}),(0,J.jsx)(G,{children:r?.secondarySource?.message})]})]}),(0,J.jsx)(`div`,{className:Ts.test,children:a})]})}var Ds=`https://docs.getontime.no/api/automation/#using-variables-in-automation`,Os=`automation-form`;function ks({automation:e,onClose:t}){let n=no(e),{data:r}=ia(),{refetch:i}=Cr(),a=(0,q.useMemo)(()=>ao(r),[r]),{control:o,handleSubmit:s,getValues:c,register:l,setError:u,setFocus:f,setValue:p,watch:m,formState:{errors:h,isSubmitting:_,isDirty:v,isValid:y}}=Pi({mode:`onChange`,defaultValues:{title:e?.title??``,filterRule:e?.filterRule??`all`,filters:e?.filters??[],outputs:e?.outputs??[]},resetOptions:{keepDirtyValues:!0}}),{fields:b,append:x,remove:S}=Fi({name:`filters`,control:o}),{fields:C,append:w,remove:T}=Fi({name:`outputs`,control:o});(0,q.useEffect)(()=>{f(`title`)},[f]);let E=()=>{x({field:``,operator:`equals`,value:``})},D=()=>{w({type:`osc`,targetIP:``,targetPort:void 0,address:``,args:``})},O=()=>{w({type:`http`,url:``})},k=()=>{w({type:`ontime`,action:`aux1-start`})},ee=async e=>{try{let t=c(`outputs.${e}`);if(!t.targetIP||!t.targetPort||!t.address)return;await Pr({type:`osc`,targetIP:t.targetIP,targetPort:t.targetPort,address:t.address,args:t.args})}catch{}},te=async e=>{try{let t=c(`outputs.${e}`);if(!t.url)return;await Pr({type:`http`,url:t.url})}catch{}},A=async e=>{try{await Pr({...c(`outputs.${e}`),type:`ontime`})}catch{}},ne=async n=>{no(e)?await r(e.id,{id:e.id,...n}):await a(n),i();async function r(e,n){try{await Or(e,n),t()}catch(e){u(`root`,{message:d(e)})}}async function a(e){try{await Hr(e),t()}catch(e){u(`root`,{message:d(e)})}}},re=!_&&v&&y;return(0,J.jsx)(Ii,{isOpen:!0,onClose:t,showBackdrop:!0,showCloseButton:!0,title:n?`Edit automation`:`Create automation`,bodyElements:(0,J.jsxs)(`form`,{id:Os,onSubmit:s(ne),className:Ts.outerColumn,children:[(0,J.jsxs)(`div`,{className:Ts.innerColumn,children:[(0,J.jsx)(`h3`,{children:`Automation options`}),(0,J.jsxs)(`div`,{className:Ts.titleSection,children:[(0,J.jsxs)(`label`,{children:[`Title`,(0,J.jsx)(R,{...l(`title`,{required:{value:!0,message:`Required field`}}),fluid:!0,placeholder:`Load preset`})]}),(0,J.jsx)(G,{children:h.title?.message})]})]}),(0,J.jsxs)(`div`,{className:Ts.innerColumn,children:[(0,J.jsx)(`h3`,{children:`Filters (optional)`}),(0,J.jsxs)(`div`,{className:Ts.ruleSection,children:[(0,J.jsxs)(`label`,{children:[`Trigger outputs if`,(0,J.jsx)(Rr,{orientation:`horizontal`,value:m(`filterRule`),onValueChange:e=>p(`filterRule`,e,{shouldDirty:!0}),items:[{value:`all`,label:`All filters pass`},{value:`any`,label:`Any filter passes`}]})]}),b.map((e,t)=>{let n=`filters.${t}.field.${e.id}`;return(0,J.jsxs)(`div`,{className:Ts.filterSection,children:[(0,J.jsxs)(`label`,{children:[`Runtime data source`,(0,J.jsx)(Gt,{value:m(`filters.${t}.field`)||null,onValueChange:e=>{e!==null&&p(`filters.${t}.field`,e,{shouldDirty:!0})},options:a.map(({value:e,label:t})=>({value:e,label:t,disabled:e===null})),"aria-label":`Event field`}),(0,J.jsx)(G,{children:h.filters?.[t]?.field?.message})]}),(0,J.jsxs)(`label`,{children:[`Matching condition`,(0,J.jsx)(Gt,{value:m(`filters.${t}.operator`),onValueChange:e=>{e!==null&&p(`filters.${t}.operator`,e,{shouldDirty:!0})},options:[{value:`equals`,label:`equals`},{value:`not_equals`,label:`not equals`},{value:`contains`,label:`contains`}],"aria-label":`Operator`}),(0,J.jsx)(G,{children:h.filters?.[t]?.operator?.message})]}),(0,J.jsxs)(`label`,{children:[`Value to match`,(0,J.jsx)(R,{...l(`filters.${t}.value`),fluid:!0,placeholder:`<empty / no value>`})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:`\xA0`}),(0,J.jsx)(`div`,{children:(0,J.jsx)(L,{"aria-label":`Delete`,variant:`ghosted-destructive`,onClick:()=>S(t),children:(0,J.jsx)(On,{})})})]})]},n)}),(0,J.jsx)(`div`,{children:(0,J.jsxs)(M,{onClick:E,children:[`Add filter `,(0,J.jsx)(I,{})]})})]})]}),(0,J.jsxs)(`div`,{className:Ts.innerColumn,children:[(0,J.jsx)(`h3`,{children:`Outputs`}),(0,J.jsxs)(K,{children:[`Automation outputs can be used to send data from Ontime to external software `,(0,J.jsx)(`br`,{}),`or to change properties of Ontime itself. `,(0,J.jsx)(`br`,{}),` `,(0,J.jsx)(`br`,{}),`Use Ontime runtime data in these fields with template strings. Type `,`{{`,` to see autocomplete, or`,` `,(0,J.jsx)(Wa,{href:Ds,children:`read the docs`})]}),C.map((e,t)=>{if(ie(e)){let n=h.outputs?.[t];return(0,J.jsxs)(`div`,{className:Ts.outputCard,children:[(0,J.jsx)(Qr,{children:`OSC`}),(0,J.jsxs)(`div`,{className:Ts.oscSection,children:[(0,J.jsxs)(`label`,{children:[`Target IP`,(0,J.jsx)(R,{...l(`outputs.${t}.targetIP`,{required:{value:!0,message:`Required field`}}),fluid:!0,placeholder:`127.0.0.1`}),(0,J.jsx)(G,{children:n?.targetIP?.message})]}),(0,J.jsxs)(`label`,{children:[`Target Port`,(0,J.jsx)(R,{...l(`outputs.${t}.targetPort`,{required:{value:!0,message:`Required field`},setValueAs:e=>e===``?0:Number(e),max:{value:65535,message:`Port must be within range 1024 - 65535`},min:{value:1024,message:`Port must be within range 1024 - 65535`}}),fluid:!0,type:`number`,maxLength:5,placeholder:`8000`}),(0,J.jsx)(G,{children:n?.targetPort?.message})]}),(0,J.jsxs)(`label`,{children:[`Address`,(0,J.jsx)(xs,{...l(`outputs.${t}.address`),value:e.address,fluid:!0,placeholder:`/cue/start`}),(0,J.jsx)(G,{children:n?.address?.message})]}),(0,J.jsxs)(`label`,{children:[`Arguments`,(0,J.jsx)(xs,{...l(`outputs.${t}.args`),value:e.args,fluid:!0,placeholder:`1`}),(0,J.jsx)(G,{children:n?.args?.message})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:`\xA0`}),(0,J.jsxs)(V,{relation:`inner`,children:[(0,J.jsx)(M,{variant:`ghosted-white`,onClick:()=>ee(t),children:`Test`}),(0,J.jsx)(L,{"aria-label":`Delete`,variant:`ghosted-destructive`,onClick:()=>T(t),children:(0,J.jsx)(On,{})})]})]})]})]},e.id)}if(oe(e)){let n=h.outputs?.[t];return(0,J.jsxs)(`div`,{className:Ts.outputCard,children:[(0,J.jsx)(Qr,{children:`HTTP`}),(0,J.jsxs)(`div`,{className:Ts.httpSection,children:[(0,J.jsxs)(`label`,{children:[`Target URL`,(0,J.jsx)(xs,{...l(`outputs.${t}.url`,{required:{value:!0,message:`Required field`},pattern:{value:Vr,message:`HTTP messages should target http:// or https://`}}),value:e.url,fluid:!0,placeholder:`http://127.0.0.1/start/1`}),(0,J.jsx)(G,{children:n?.url?.message})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:`\xA0`}),(0,J.jsxs)(V,{relation:`inner`,children:[(0,J.jsx)(M,{variant:`ghosted-white`,onClick:()=>te(t),children:`Test`}),(0,J.jsx)(L,{"aria-label":`Delete`,variant:`ghosted-destructive`,onClick:()=>T(t),children:(0,J.jsx)(On,{})})]})]})]})]},e.id)}if(g(e)){let n=h.outputs?.[t];return(0,J.jsxs)(`div`,{className:Ts.outputCard,children:[(0,J.jsx)(Qr,{children:`Ontime action`}),(0,J.jsxs)(Es,{value:e.action,index:t,register:l,rowErrors:n,setValue:p,watch:m,children:[(0,J.jsx)(`span`,{children:`\xA0`}),(0,J.jsxs)(V,{relation:`inner`,children:[(0,J.jsx)(M,{variant:`ghosted-white`,onClick:()=>A(t),children:`Test`}),(0,J.jsx)(L,{"aria-label":`Delete`,variant:`ghosted-destructive`,onClick:()=>T(t),children:(0,J.jsx)(On,{})})]})]})]},e.id)}return null}),(0,J.jsxs)(V,{relation:`inner`,children:[(0,J.jsxs)(M,{onClick:D,children:[`OSC `,(0,J.jsx)(I,{})]}),(0,J.jsxs)(M,{onClick:O,children:[`HTTP `,(0,J.jsx)(I,{})]}),(0,J.jsxs)(M,{onClick:k,children:[`Ontime action `,(0,J.jsx)(I,{})]})]})]})]}),footerElements:(0,J.jsxs)(J.Fragment,{children:[h?.root&&(0,J.jsx)(G,{children:h.root.message}),(0,J.jsx)(M,{onClick:t,children:`Cancel`}),(0,J.jsx)(M,{variant:`primary`,type:`submit`,form:Os,disabled:!re,loading:_,children:`Save`})]})})}var As={title:``,filterRule:`all`,filters:[],outputs:[]};function js({automations:e,enabledAutomations:t,isLoading:n}){let{refetch:r}=Cr(),[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(null),c=async e=>{try{s(null),await Tr(e)}catch(e){s(d(e))}finally{r()}},l=Object.keys(e);return(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[i!==null&&(0,J.jsx)(ks,{automation:i,onClose:()=>a(null)}),(0,J.jsxs)(yi,{children:[`Manage automations`,(0,J.jsxs)(M,{onClick:()=>a(As),children:[`New `,(0,J.jsx)(I,{})]})]}),(0,J.jsx)(Di,{}),(0,J.jsxs)(B,{children:[t===!1&&(0,J.jsx)(K,{children:`Automations are disabled. You can still manage automation definitions here, but they will not run until enabled.`}),(0,J.jsxs)(vi,{children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{style:{width:`45%`},children:`Title`}),(0,J.jsx)(`th`,{style:{width:`15%`},children:`Trigger rule`}),(0,J.jsx)(`th`,{style:{width:`15%`},children:`Filters`}),(0,J.jsx)(`th`,{style:{width:`15%`},children:`Outputs`}),(0,J.jsx)(`th`,{})]})}),(0,J.jsxs)(`tbody`,{children:[!n&&l.length===0&&(0,J.jsx)(Si,{title:`No automations yet`,description:`An automation sends OSC or HTTP messages, or runs an Ontime action, whenever a trigger fires.`,action:(0,J.jsxs)(M,{variant:`primary`,onClick:()=>a(As),children:[`Create automation `,(0,J.jsx)(I,{})]})}),l.map(t=>Object.hasOwn(e,t)?(0,J.jsx)(q.Fragment,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:e[t].title}),(0,J.jsx)(`td`,{children:(0,J.jsx)(Qr,{children:e[t].filterRule})}),(0,J.jsx)(`td`,{children:e[t].filters.length}),(0,J.jsx)(`td`,{children:e[t].outputs.length}),(0,J.jsxs)(V,{align:`end`,relation:`inner`,as:`td`,children:[(0,J.jsx)(L,{variant:`ghosted-white`,"aria-label":`Edit entry`,onClick:()=>a(e[t]),children:(0,J.jsx)(Gn,{})}),(0,J.jsx)(L,{variant:`ghosted-destructive`,"aria-label":`Delete entry`,onClick:()=>c(t),children:(0,J.jsx)(On,{})})]})]})},t):null),o&&(0,J.jsx)(`tr`,{children:(0,J.jsx)(`td`,{colSpan:5,children:(0,J.jsx)(G,{children:o})})})]})]})]})]})})}var Ms=`trigger-form`;function Ns({automations:e,trigger:t,onCancel:n,postSubmit:r}){let{handleSubmit:i,register:a,setFocus:o,setError:s,watch:c,setValue:l,formState:{errors:u,isSubmitting:f,isValid:p,isDirty:m}}=Pi({defaultValues:{title:t?.title,trigger:t?.trigger??to[0].value,automationId:t?.automationId??e?.[Object.keys(e)[0]]?.id},resetOptions:{keepDirtyValues:!0}});(0,q.useEffect)(()=>{o(`title`)},[o]);let h=async e=>{if(t){try{await Sr(t.id,{id:t.id,...e}),r()}catch(e){s(`root`,{message:`Failed to save changes to trigger ${d(e)}`})}return}try{await kr(e),r()}catch(e){s(`root`,{message:`Failed to save trigger ${d(e)}`})}},g=Object.keys(e).map(t=>({value:t,label:e[t].title})),_=m&&p;return(0,J.jsx)(Ii,{isOpen:!0,onClose:n,showBackdrop:!0,showCloseButton:!0,size:`compact`,title:t?`Edit trigger`:`Create trigger`,bodyElements:(0,J.jsxs)(`form`,{id:Ms,onSubmit:i(h),children:[(0,J.jsxs)(`label`,{children:[`Title`,(0,J.jsx)(R,{...a(`title`,{required:{value:!0,message:`Required field`}}),fluid:!0,defaultValue:t?.title}),(0,J.jsx)(G,{children:u.title?.message})]}),(0,J.jsxs)(`label`,{children:[`Lifecycle trigger`,(0,J.jsx)(Gt,{value:c(`trigger`),onValueChange:e=>{e!==null&&l(`trigger`,e,{shouldDirty:!0})},options:to.map(e=>({value:e.value,label:e.label})),"aria-label":`Lifecycle trigger`}),(0,J.jsx)(G,{children:u.trigger?.message})]}),(0,J.jsxs)(`label`,{children:[`Automation title`,(0,J.jsx)(Gt,{value:c(`automationId`),onValueChange:e=>{e!==null&&l(`automationId`,e,{shouldDirty:!0})},options:g,"aria-label":`Automation title`}),(0,J.jsx)(G,{children:u.automationId?.message})]})]}),footerElements:(0,J.jsxs)(J.Fragment,{children:[u.root&&(0,J.jsx)(G,{children:u.root.message}),(0,J.jsx)(M,{disabled:f,onClick:n,children:`Cancel`}),(0,J.jsx)(M,{type:`submit`,form:Ms,variant:`primary`,disabled:!_,loading:f,children:`Save`})]})})}function Ps(e){let{automations:t,trigger:n,duplicate:r,handleEdit:i,handleDelete:a}=e;return(0,J.jsxs)(`tr`,{"data-warn":r,children:[(0,J.jsxs)(V,{as:`td`,relation:`inner`,children:[r&&(0,J.jsx)(Pn,{color:`#FFBC56`}),n.title]}),(0,J.jsx)(`td`,{children:(0,J.jsx)(Qr,{children:to.find(e=>e.value===n.trigger)?.label})}),(0,J.jsx)(`td`,{children:(0,J.jsx)(Qr,{children:t?.[n.automationId]?.title})}),(0,J.jsxs)(V,{align:`end`,relation:`inner`,as:`td`,children:[(0,J.jsx)(L,{variant:`ghosted-white`,"aria-label":`Edit entry`,onClick:i,children:(0,J.jsx)(Gn,{})}),(0,J.jsx)(L,{variant:`ghosted-destructive`,"aria-label":`Delete entry`,onClick:a,children:(0,J.jsx)(On,{})})]})]})}function Fs({triggers:e,automations:t,enabledAutomations:n,isLoading:r}){let[i,a]=(0,q.useState)({isOpen:!1,trigger:void 0}),{refetch:o}=Cr(),[s,c]=(0,q.useState)(null),l=()=>a({isOpen:!0}),u=e=>a({isOpen:!0,trigger:e}),f=()=>a({isOpen:!1,trigger:void 0}),p=async e=>{try{c(null),await wr(e)}catch(e){c(d(e))}finally{o()}},m=()=>{f(),o()},h=(0,q.useMemo)(()=>oo(e),[e]),g=Object.keys(t).length>0;return(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[i.isOpen&&(0,J.jsx)(Ns,{automations:t,trigger:i.trigger??null,onCancel:f,postSubmit:m}),(0,J.jsxs)(yi,{children:[`Manage triggers`,(0,J.jsxs)(M,{disabled:!g,onClick:l,children:[`New `,(0,J.jsx)(I,{})]})]}),(0,J.jsx)(Di,{}),(0,J.jsxs)(B,{children:[n===!1&&(0,J.jsx)(K,{children:`Automations are disabled. You can still manage triggers here, but they will not run until enabled.`}),h&&(0,J.jsx)(G,{children:`You have created multiple links between the same trigger and automation which can cause performance issues.`}),(0,J.jsxs)(vi,{children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{style:{width:`35%`},children:`Title`}),(0,J.jsx)(`th`,{style:{width:`25%`},children:`Lifecycle trigger`}),(0,J.jsx)(`th`,{style:{width:`25%`},children:`Automation`}),(0,J.jsx)(`th`,{})]})}),(0,J.jsxs)(`tbody`,{children:[!r&&e.length===0&&(0,J.jsx)(Si,{title:`No triggers yet`,description:g?`Triggers run an automation at a given point of the timer lifecycle, like when an event starts or finishes.`:`Create an automation first, then add a trigger to decide when it should run.`,action:g&&(0,J.jsxs)(M,{variant:`primary`,onClick:l,children:[`Create trigger `,(0,J.jsx)(I,{})]})}),e.map((e,n)=>(0,J.jsx)(q.Fragment,{children:(0,J.jsx)(Ps,{automations:t,trigger:e,duplicate:h?.includes(n),handleEdit:()=>u(e),handleDelete:()=>p(e.id)})},e.id)),s&&(0,J.jsx)(`tr`,{children:(0,J.jsx)(`td`,{colSpan:5,children:(0,J.jsx)(G,{children:s})})})]})]})]})]})})}function Is({location:e}){let{data:t,status:n}=Cr(),r=Qa(`settings`,e),i=Qa(`triggers`,e),a=Qa(`automations`,e),o=n===`pending`,s=o?void 0:t.enabledAutomations,c=o?void 0:t.enabledOscIn;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ci,{children:`Automation`}),(0,J.jsx)(`div`,{ref:r,children:(0,J.jsx)(eo,{enabledAutomations:t.enabledAutomations,enabledOscIn:t.enabledOscIn,oscPortIn:t.oscPortIn,automationState:s,oscInputState:c,isLoading:o})}),(0,J.jsx)(`div`,{ref:a,children:(0,J.jsx)(js,{automations:t.automations,enabledAutomations:s,isLoading:o})}),(0,J.jsx)(`div`,{ref:i,children:(0,J.jsx)(Fs,{triggers:t.triggers,automations:t.automations,enabledAutomations:s,isLoading:o})})]})}var Ls={blink:`_blink_1fzu7_1`,fourtyfive:`_fourtyfive_1fzu7_13`,goIcon:`_goIcon_1fzu7_17`};function Rs(){let{data:e}=pr(),t=e=>ur(e);return(0,J.jsx)(V,{wrap:`wrap`,children:e.networkInterfaces.map(e=>{if(e.name===`localhost`&&!fn)return null;let n=lr(e.address);return(0,J.jsxs)(gr,{copyValue:n,onClick:()=>t(n),children:[`${e.name} - ${e.address}`,` `,(0,J.jsx)(Cn,{className:Ls.goIcon})]},e.name)})})}var zs=typeof global<`u`?global:typeof self<`u`?self:typeof window<`u`?window:{},Bs=[],Vs=[],Hs=typeof Uint8Array<`u`?Uint8Array:Array,Us=!1;function Ws(){Us=!0;for(var e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,t=0,n=e.length;t<n;++t)Bs[t]=e[t],Vs[e.charCodeAt(t)]=t;Vs[45]=62,Vs[95]=63}function Gs(e){Us||Ws();var t,n,r,i,a,o,s=e.length;if(s%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);a=e[s-2]===`=`?2:e[s-1]===`=`?1:0,o=new Hs(s*3/4-a),r=a>0?s-4:s;var c=0;for(t=0,n=0;t<r;t+=4,n+=3)i=Vs[e.charCodeAt(t)]<<18|Vs[e.charCodeAt(t+1)]<<12|Vs[e.charCodeAt(t+2)]<<6|Vs[e.charCodeAt(t+3)],o[c++]=i>>16&255,o[c++]=i>>8&255,o[c++]=i&255;return a===2?(i=Vs[e.charCodeAt(t)]<<2|Vs[e.charCodeAt(t+1)]>>4,o[c++]=i&255):a===1&&(i=Vs[e.charCodeAt(t)]<<10|Vs[e.charCodeAt(t+1)]<<4|Vs[e.charCodeAt(t+2)]>>2,o[c++]=i>>8&255,o[c++]=i&255),o}function Ks(e){return Bs[e>>18&63]+Bs[e>>12&63]+Bs[e>>6&63]+Bs[e&63]}function qs(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16)+(e[a+1]<<8)+e[a+2],i.push(Ks(r));return i.join(``)}function Js(e){Us||Ws();for(var t,n=e.length,r=n%3,i=``,a=[],o=16383,s=0,c=n-r;s<c;s+=o)a.push(qs(e,s,s+o>c?c:s+o));return r===1?(t=e[n-1],i+=Bs[t>>2],i+=Bs[t<<4&63],i+=`==`):r===2&&(t=(e[n-2]<<8)+e[n-1],i+=Bs[t>>10],i+=Bs[t>>4&63],i+=Bs[t<<2&63],i+=`=`),a.push(i),a.join(``)}function Ys(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)}function Xs(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128}var Zs={}.toString,Qs=Array.isArray||function(e){return Zs.call(e)==`[object Array]`},$s=50;X.TYPED_ARRAY_SUPPORT=zs.TYPED_ARRAY_SUPPORT===void 0?!0:zs.TYPED_ARRAY_SUPPORT,ec();function ec(){return X.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function tc(e,t){if(ec()<t)throw RangeError(`Invalid typed array length`);return X.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=X.prototype):(e===null&&(e=new X(t)),e.length=t),e}function X(e,t,n){if(!X.TYPED_ARRAY_SUPPORT&&!(this instanceof X))return new X(e,t,n);if(typeof e==`number`){if(typeof t==`string`)throw Error(`If encoding is specified then the first argument must be a string`);return ac(this,e)}return nc(this,e,t,n)}X.poolSize=8192,X._augment=function(e){return e.__proto__=X.prototype,e};function nc(e,t,n,r){if(typeof t==`number`)throw TypeError(`"value" argument must not be a number`);return typeof ArrayBuffer<`u`&&t instanceof ArrayBuffer?cc(e,t,n,r):typeof t==`string`?oc(e,t,n):lc(e,t)}X.from=function(e,t,n){return nc(null,e,t,n)},X.TYPED_ARRAY_SUPPORT&&(X.prototype.__proto__=Uint8Array.prototype,X.__proto__=Uint8Array,typeof Symbol<`u`&&Symbol.species&&X[Symbol.species]);function rc(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be a number`);if(e<0)throw RangeError(`"size" argument must not be negative`)}function ic(e,t,n,r){return rc(t),t<=0||n===void 0?tc(e,t):typeof r==`string`?tc(e,t).fill(n,r):tc(e,t).fill(n)}X.alloc=function(e,t,n){return ic(null,e,t,n)};function ac(e,t){if(rc(t),e=tc(e,t<0?0:uc(t)|0),!X.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}X.allocUnsafe=function(e){return ac(null,e)},X.allocUnsafeSlow=function(e){return ac(null,e)};function oc(e,t,n){if((typeof n!=`string`||n===``)&&(n=`utf8`),!X.isEncoding(n))throw TypeError(`"encoding" must be a valid string encoding`);var r=fc(t,n)|0;e=tc(e,r);var i=e.write(t,n);return i!==r&&(e=e.slice(0,i)),e}function sc(e,t){var n=t.length<0?0:uc(t.length)|0;e=tc(e,n);for(var r=0;r<n;r+=1)e[r]=t[r]&255;return e}function cc(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw RangeError(`'offset' is out of bounds`);if(t.byteLength<n+(r||0))throw RangeError(`'length' is out of bounds`);return t=n===void 0&&r===void 0?new Uint8Array(t):r===void 0?new Uint8Array(t,n):new Uint8Array(t,n,r),X.TYPED_ARRAY_SUPPORT?(e=t,e.__proto__=X.prototype):e=sc(e,t),e}function lc(e,t){if(dc(t)){var n=uc(t.length)|0;return e=tc(e,n),e.length===0||t.copy(e,0,0,n),e}if(t){if(typeof ArrayBuffer<`u`&&t.buffer instanceof ArrayBuffer||`length`in t)return typeof t.length!=`number`||qc(t.length)?tc(e,0):sc(e,t);if(t.type===`Buffer`&&Qs(t.data))return sc(e,t.data)}throw TypeError(`First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.`)}function uc(e){if(e>=ec())throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+ec().toString(16)+` bytes`);return e|0}X.isBuffer=Jc;function dc(e){return!!(e!=null&&e._isBuffer)}X.compare=function(e,t){if(!dc(e)||!dc(t))throw TypeError(`Arguments must be Buffers`);if(e===t)return 0;for(var n=e.length,r=t.length,i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},X.isEncoding=function(e){switch(String(e).toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`latin1`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return!0;default:return!1}},X.concat=function(e,t){if(!Qs(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return X.alloc(0);var n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=X.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var a=e[n];if(!dc(a))throw TypeError(`"list" argument must be an Array of Buffers`);a.copy(r,i),i+=a.length}return r};function fc(e,t){if(dc(e))return e.length;if(typeof ArrayBuffer<`u`&&typeof ArrayBuffer.isView==`function`&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;typeof e!=`string`&&(e=``+e);var n=e.length;if(n===0)return 0;for(var r=!1;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:case void 0:return Hc(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return Gc(e).length;default:if(r)return Hc(e).length;t=(``+t).toLowerCase(),r=!0}}X.byteLength=fc;function pc(e,t,n){var r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||(e=`utf8`);;)switch(e){case`hex`:return kc(this,t,n);case`utf8`:case`utf-8`:return wc(this,t,n);case`ascii`:return Dc(this,t,n);case`latin1`:case`binary`:return Oc(this,t,n);case`base64`:return Cc(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return Ac(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}X.prototype._isBuffer=!0;function mc(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}X.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(var t=0;t<e;t+=2)mc(this,t,t+1);return this},X.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(var t=0;t<e;t+=4)mc(this,t,t+3),mc(this,t+1,t+2);return this},X.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(var t=0;t<e;t+=8)mc(this,t,t+7),mc(this,t+1,t+6),mc(this,t+2,t+5),mc(this,t+3,t+4);return this},X.prototype.toString=function(){var e=this.length|0;return e===0?``:arguments.length===0?wc(this,0,e):pc.apply(this,arguments)},X.prototype.equals=function(e){if(!dc(e))throw TypeError(`Argument must be a Buffer`);return this===e?!0:X.compare(this,e)===0},X.prototype.inspect=function(){var e=``,t=$s;return this.length>0&&(e=this.toString(`hex`,0,t).match(/.{2}/g).join(` `),this.length>t&&(e+=` ... `)),`<Buffer `+e+`>`},X.prototype.compare=function(e,t,n,r,i){if(!dc(e))throw TypeError(`Argument must be a Buffer`);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;for(var a=i-r,o=n-t,s=Math.min(a,o),c=this.slice(r,i),l=e.slice(t,n),u=0;u<s;++u)if(c[u]!==l[u]){a=c[u],o=l[u];break}return a<o?-1:o<a?1:0};function hc(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t==`string`&&(t=X.from(t,r)),dc(t))return t.length===0?-1:gc(e,t,n,r,i);if(typeof t==`number`)return t&=255,X.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==`function`?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):gc(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function gc(e,t,n,r,i){var a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}var l;if(i){var u=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,u===-1?0:l-u)){if(u===-1&&(u=l),l-u+1===s)return u*a}else u!==-1&&(l-=l-u),u=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){for(var d=!0,f=0;f<s;f++)if(c(e,l+f)!==c(t,f)){d=!1;break}if(d)return l}return-1}X.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},X.prototype.indexOf=function(e,t,n){return hc(this,e,t,n,!0)},X.prototype.lastIndexOf=function(e,t,n){return hc(this,e,t,n,!1)};function _c(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var a=t.length;if(a%2!=0)throw TypeError(`Invalid hex string`);r>a/2&&(r=a/2);for(var o=0;o<r;++o){var s=parseInt(t.substr(o*2,2),16);if(isNaN(s))return o;e[n+o]=s}return o}function vc(e,t,n,r){return Kc(Hc(t,e.length-n),e,n,r)}function yc(e,t,n,r){return Kc(Uc(t),e,n,r)}function bc(e,t,n,r){return yc(e,t,n,r)}function xc(e,t,n,r){return Kc(Gc(t),e,n,r)}function Sc(e,t,n,r){return Kc(Wc(t,e.length-n),e,n,r)}X.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t|=0,isFinite(n)?(n|=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);var i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||(r=`utf8`);for(var a=!1;;)switch(r){case`hex`:return _c(this,e,t,n);case`utf8`:case`utf-8`:return vc(this,e,t,n);case`ascii`:return yc(this,e,t,n);case`latin1`:case`binary`:return bc(this,e,t,n);case`base64`:return xc(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return Sc(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},X.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function Cc(e,t,n){return t===0&&n===e.length?Js(e):Js(e.slice(t,n))}function wc(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var a=e[i],o=null,s=a>239?4:a>223?3:a>191?2:1;if(i+s<=n){var c,l,u,d;switch(s){case 1:a<128&&(o=a);break;case 2:c=e[i+1],(c&192)==128&&(d=(a&31)<<6|c&63,d>127&&(o=d));break;case 3:c=e[i+1],l=e[i+2],(c&192)==128&&(l&192)==128&&(d=(a&15)<<12|(c&63)<<6|l&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:c=e[i+1],l=e[i+2],u=e[i+3],(c&192)==128&&(l&192)==128&&(u&192)==128&&(d=(a&15)<<18|(c&63)<<12|(l&63)<<6|u&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|o&1023),r.push(o),i+=s}return Ec(r)}var Tc=4096;function Ec(e){var t=e.length;if(t<=Tc)return String.fromCharCode.apply(String,e);for(var n=``,r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Tc));return n}function Dc(e,t,n){var r=``;n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function Oc(e,t,n){var r=``;n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function kc(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i=``,a=t;a<n;++a)i+=Vc(e[a]);return i}function Ac(e,t,n){for(var r=e.slice(t,n),i=``,a=0;a<r.length;a+=2)i+=String.fromCharCode(r[a]+r[a+1]*256);return i}X.prototype.slice=function(e,t){var n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);var r;if(X.TYPED_ARRAY_SUPPORT)r=this.subarray(e,t),r.__proto__=X.prototype;else{var i=t-e;r=new X(i,void 0);for(var a=0;a<i;++a)r[a]=this[a+e]}return r};function jc(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}X.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||jc(e,t,this.length);for(var r=this[e],i=1,a=0;++a<t&&(i*=256);)r+=this[e+a]*i;return r},X.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||jc(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},X.prototype.readUInt8=function(e,t){return t||jc(e,1,this.length),this[e]},X.prototype.readUInt16LE=function(e,t){return t||jc(e,2,this.length),this[e]|this[e+1]<<8},X.prototype.readUInt16BE=function(e,t){return t||jc(e,2,this.length),this[e]<<8|this[e+1]},X.prototype.readUInt32LE=function(e,t){return t||jc(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},X.prototype.readUInt32BE=function(e,t){return t||jc(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},X.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||jc(e,t,this.length);for(var r=this[e],i=1,a=0;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},X.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||jc(e,t,this.length);for(var r=t,i=1,a=this[e+--r];r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},X.prototype.readInt8=function(e,t){return t||jc(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},X.prototype.readInt16LE=function(e,t){t||jc(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},X.prototype.readInt16BE=function(e,t){t||jc(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},X.prototype.readInt32LE=function(e,t){return t||jc(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},X.prototype.readInt32BE=function(e,t){return t||jc(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},X.prototype.readFloatLE=function(e,t){return t||jc(e,4,this.length),Ys(this,e,!0,23,4)},X.prototype.readFloatBE=function(e,t){return t||jc(e,4,this.length),Ys(this,e,!1,23,4)},X.prototype.readDoubleLE=function(e,t){return t||jc(e,8,this.length),Ys(this,e,!0,52,8)},X.prototype.readDoubleBE=function(e,t){return t||jc(e,8,this.length),Ys(this,e,!1,52,8)};function Mc(e,t,n,r,i,a){if(!dc(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}X.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t|=0,n|=0,!r){var i=2**(8*n)-1;Mc(this,e,t,n,i,0)}var a=1,o=0;for(this[t]=e&255;++o<n&&(a*=256);)this[t+o]=e/a&255;return t+n},X.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t|=0,n|=0,!r){var i=2**(8*n)-1;Mc(this,e,t,n,i,0)}var a=n-1,o=1;for(this[t+a]=e&255;--a>=0&&(o*=256);)this[t+a]=e/o&255;return t+n},X.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||Mc(this,e,t,1,255,0),X.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e&255,t+1};function Nc(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,a=Math.min(e.length-n,2);i<a;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>(r?i:1-i)*8}X.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||Mc(this,e,t,2,65535,0),X.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Nc(this,e,t,!0),t+2},X.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||Mc(this,e,t,2,65535,0),X.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Nc(this,e,t,!1),t+2};function Pc(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,a=Math.min(e.length-n,4);i<a;++i)e[n+i]=t>>>(r?i:3-i)*8&255}X.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||Mc(this,e,t,4,4294967295,0),X.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255):Pc(this,e,t,!0),t+4},X.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||Mc(this,e,t,4,4294967295,0),X.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):Pc(this,e,t,!1),t+4},X.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=2**(8*n-1);Mc(this,e,t,n,i-1,-i)}var a=0,o=1,s=0;for(this[t]=e&255;++a<n&&(o*=256);)e<0&&s===0&&this[t+a-1]!==0&&(s=1),this[t+a]=(e/o>>0)-s&255;return t+n},X.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=2**(8*n-1);Mc(this,e,t,n,i-1,-i)}var a=n-1,o=1,s=0;for(this[t+a]=e&255;--a>=0&&(o*=256);)e<0&&s===0&&this[t+a+1]!==0&&(s=1),this[t+a]=(e/o>>0)-s&255;return t+n},X.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||Mc(this,e,t,1,127,-128),X.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=e&255,t+1},X.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||Mc(this,e,t,2,32767,-32768),X.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Nc(this,e,t,!0),t+2},X.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||Mc(this,e,t,2,32767,-32768),X.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Nc(this,e,t,!1),t+2},X.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||Mc(this,e,t,4,2147483647,-2147483648),X.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Pc(this,e,t,!0),t+4},X.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||Mc(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),X.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):Pc(this,e,t,!1),t+4};function Fc(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function Ic(e,t,n,r,i){return i||Fc(e,t,n,4),Xs(e,t,n,r,23,4),n+4}X.prototype.writeFloatLE=function(e,t,n){return Ic(this,e,t,!0,n)},X.prototype.writeFloatBE=function(e,t,n){return Ic(this,e,t,!1,n)};function Lc(e,t,n,r,i){return i||Fc(e,t,n,8),Xs(e,t,n,r,52,8),n+8}X.prototype.writeDoubleLE=function(e,t,n){return Lc(this,e,t,!0,n)},X.prototype.writeDoubleBE=function(e,t,n){return Lc(this,e,t,!1,n)},X.prototype.copy=function(e,t,n,r){if(n||(n=0),!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`sourceStart out of bounds`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i=r-n,a;if(this===e&&n<t&&t<r)for(a=i-1;a>=0;--a)e[a+t]=this[a+n];else if(i<1e3||!X.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)e[a+t]=this[a+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},X.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),e.length===1){var i=e.charCodeAt(0);i<256&&(e=i)}if(r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!X.isEncoding(r))throw TypeError(`Unknown encoding: `+r)}else typeof e==`number`&&(e&=255);if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||(e=0);var a;if(typeof e==`number`)for(a=t;a<n;++a)this[a]=e;else{var o=dc(e)?e:Hc(new X(e,r).toString()),s=o.length;for(a=0;a<n-t;++a)this[a+t]=o[a%s]}return this};var Rc=/[^+\/0-9A-Za-z-_]/g;function zc(e){if(e=Bc(e).replace(Rc,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function Bc(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,``)}function Vc(e){return e<16?`0`+e.toString(16):e.toString(16)}function Hc(e,t){t=t||1/0;for(var n,r=e.length,i=null,a=[],o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function Uc(e){for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function Wc(e,t){for(var n,r,i,a=[],o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function Gc(e){return Gs(zc(e))}function Kc(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function qc(e){return e!==e}function Jc(e){return e!=null&&(!!e._isBuffer||Yc(e)||Xc(e))}function Yc(e){return!!e.constructor&&typeof e.constructor.isBuffer==`function`&&e.constructor.isBuffer(e)}function Xc(e){return typeof e.readFloatLE==`function`&&typeof e.slice==`function`&&Yc(e.slice(0,0))}var Zc=46,Qc=/\\(\\)?/g,$c=RegExp(`[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,`g`),el=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,tl=/^\w*$/,nl=function(e){return Object.prototype.toString.call(e)},rl=function(e){let t=typeof e;return t===`symbol`||t===`object`&&e&&nl(e)===`[object Symbol]`},il=function(e,t){if(Array.isArray(e))return!1;let n=typeof e;return n===`number`||n===`symbol`||n===`boolean`||!e||rl(e)?!0:tl.test(e)||!el.test(e)||t!=null&&e in Object(t)},al=function(e){let t=[];return e.charCodeAt(0)===Zc&&t.push(``),e.replace($c,function(e,n,r,i){let a=e;r?a=i.replace(Qc,`$1`):n&&(a=n.trim()),t.push(a)}),t},ol=function(e,t){return Array.isArray(e)?e:il(e,t)?[e]:al(e)},sl=function(e){if(typeof e==`string`||rl(e))return e;let t=`${e}`;return t==`0`&&1/e==-INFINITY?`-0`:t},cl=function(e,t){t=ol(t,e);let n=0,r=t.length;for(;e!=null&&n<r;)e=e[sl(t[n++])];return n&&n===r?e:void 0},ll=function(e){return typeof e==`object`&&!!e&&!Array.isArray(e)},ul=function(e){if(e==null)return[void 0,void 0];if(typeof e!=`object`)return[Error(`Invalid option "columns": expect an array or an object`)];if(Array.isArray(e)){let t=[];for(let n of e)if(typeof n==`string`)t.push({key:n,header:n});else if(typeof n==`object`&&n&&!Array.isArray(n)){if(!n.key)return[Error(`Invalid column definition: property "key" is required`)];n.header===void 0&&(n.header=n.key),t.push(n)}else return[Error(`Invalid column definition: expect a string or an object`)];e=t}else{let t=[];for(let n in e)t.push({key:n,header:e[n]});e=t}return[void 0,e]},dl=class e extends Error{constructor(t,n,...r){Array.isArray(n)&&(n=n.join(` `)),super(n),Error.captureStackTrace!==void 0&&Error.captureStackTrace(this,e),this.code=t;for(let e of r)for(let t in e){let n=e[t];this[t]=Jc(n)?n.toString():n==null?n:JSON.parse(JSON.stringify(n))}}},fl=function(e){return e.replace(/([A-Z])/g,function(e,t){return`_`+t.toLowerCase()})},pl=function(e){let t={};for(let n in e)t[fl(n)]=e[n];if(t.bom===void 0||t.bom===null||t.bom===!1)t.bom=!1;else if(t.bom!==!0)return[new dl(`CSV_OPTION_BOOLEAN_INVALID_TYPE`,["option `bom` is optional and must be a boolean value,",`got ${JSON.stringify(t.bom)}`])];if(t.delimiter===void 0||t.delimiter===null)t.delimiter=`,`;else if(Jc(t.delimiter))t.delimiter=t.delimiter.toString();else if(typeof t.delimiter!=`string`)return[new dl(`CSV_OPTION_DELIMITER_INVALID_TYPE`,["option `delimiter` must be a buffer or a string,",`got ${JSON.stringify(t.delimiter)}`])];if(t.quote===void 0||t.quote===null)t.quote=`"`;else if(t.quote===!0)t.quote=`"`;else if(t.quote===!1)t.quote=``;else if(Jc(t.quote))t.quote=t.quote.toString();else if(typeof t.quote!=`string`)return[new dl(`CSV_OPTION_QUOTE_INVALID_TYPE`,["option `quote` must be a boolean, a buffer or a string,",`got ${JSON.stringify(t.quote)}`])];if((t.quoted===void 0||t.quoted===null)&&(t.quoted=!1),t.escape_formulas===void 0||t.escape_formulas===null)t.escape_formulas=!1;else if(typeof t.escape_formulas!=`boolean`)return[new dl(`CSV_OPTION_ESCAPE_FORMULAS_INVALID_TYPE`,["option `escape_formulas` must be a boolean,",`got ${JSON.stringify(t.escape_formulas)}`])];if((t.quoted_empty===void 0||t.quoted_empty===null)&&(t.quoted_empty=void 0),t.quoted_match===void 0||t.quoted_match===null||t.quoted_match===!1?t.quoted_match=null:Array.isArray(t.quoted_match)||(t.quoted_match=[t.quoted_match]),t.quoted_match)for(let e of t.quoted_match){let t=typeof e==`string`,n=e instanceof RegExp;if(!t&&!n)return[Error(`Invalid Option: quoted_match must be a string or a regex, got ${JSON.stringify(e)}`)]}if((t.quoted_string===void 0||t.quoted_string===null)&&(t.quoted_string=!1),(t.eof===void 0||t.eof===null)&&(t.eof=!0),t.escape===void 0||t.escape===null)t.escape=`"`;else if(Jc(t.escape))t.escape=t.escape.toString();else if(typeof t.escape!=`string`)return[Error(`Invalid Option: escape must be a buffer or a string, got ${JSON.stringify(t.escape)}`)];if(t.escape.length>1)return[Error(`Invalid Option: escape must be one character, got ${t.escape.length} characters`)];(t.header===void 0||t.header===null)&&(t.header=!1);let[n,r]=ul(t.columns);if(n!==void 0)return[n];if(t.columns=r,(t.quoted===void 0||t.quoted===null)&&(t.quoted=!1),(t.cast===void 0||t.cast===null)&&(t.cast={}),(t.cast.bigint===void 0||t.cast.bigint===null)&&(t.cast.bigint=e=>``+e),(t.cast.boolean===void 0||t.cast.boolean===null)&&(t.cast.boolean=e=>e?`1`:``),(t.cast.date===void 0||t.cast.date===null)&&(t.cast.date=e=>``+e.getTime()),(t.cast.number===void 0||t.cast.number===null)&&(t.cast.number=e=>``+e),(t.cast.object===void 0||t.cast.object===null)&&(t.cast.object=e=>JSON.stringify(e)),(t.cast.string===void 0||t.cast.string===null)&&(t.cast.string=function(e){return e}),t.on_record!==void 0&&typeof t.on_record!=`function`)return[Error(`Invalid Option: "on_record" must be a function.`)];if(t.record_delimiter===void 0||t.record_delimiter===null)t.record_delimiter=`
`;else if(Jc(t.record_delimiter))t.record_delimiter=t.record_delimiter.toString();else if(typeof t.record_delimiter!=`string`)return[Error(`Invalid Option: record_delimiter must be a buffer or a string, got ${JSON.stringify(t.record_delimiter)}`)];switch(t.record_delimiter){case`unix`:t.record_delimiter=`
`;break;case`mac`:t.record_delimiter=`\r`;break;case`windows`:t.record_delimiter=`\r
`;break;case`ascii`:t.record_delimiter=``;break;case`unicode`:t.record_delimiter=`\u2028`;break}return[void 0,t]},ml=X.from([239,187,191]),hl=function(e,t,n){return{options:e,state:t,info:n,__transform:function(e,t){if(!Array.isArray(e)&&typeof e!=`object`)return Error(`Invalid Record: expect an array or an object, got ${JSON.stringify(e)}`);if(this.info.records===0){if(Array.isArray(e)){if(this.options.header===!0&&this.options.columns===void 0)return Error(`Undiscoverable Columns: header option requires column option or object records`)}else if(this.options.columns===void 0){let[t,n]=ul(Object.keys(e));if(t)return;this.options.columns=n}}if(this.info.records===0){this.bom(t);let e=this.headers(t);if(e)return e}try{this.options.on_record&&this.options.on_record(e,this.info.records)}catch(e){return e}let n,r;if(this.options.eof){if([n,r]=this.stringify(e),n)return n;if(r===void 0)return;r+=this.options.record_delimiter}else{if([n,r]=this.stringify(e),n)return n;if(r===void 0)return;(this.options.header||this.info.records)&&(r=this.options.record_delimiter+r)}this.info.records++,t(r)},stringify:function(e,t=!1){if(typeof e!=`object`)return[void 0,e];let{columns:n}=this.options,r=[];if(Array.isArray(e)){n&&e.splice(n.length);for(let n=0;n<e.length;n++){let i=e[n],[a,o]=this.__cast(i,{index:n,column:n,records:this.info.records,header:t});if(a)return[a];r[n]=[o,i]}}else for(let i=0;i<n.length;i++){let a=cl(e,n[i].key),[o,s]=this.__cast(a,{index:i,column:n[i].key,records:this.info.records,header:t});if(o)return[o];r[i]=[s,a]}let i=``;for(let e=0;e<r.length;e++){let t,n,[a,o]=r[e];if(typeof a==`string`)t=this.options;else if(ll(a)){if(t=a,a=t.value,delete t.value,typeof a!=`string`&&a!=null&&n)return[Error(`Invalid Casting Value: returned value must return a string, null or undefined, got ${JSON.stringify(a)}`)];if(t={...this.options,...t},[n,t]=pl(t),n!==void 0)return[n]}else if(a==null)t=this.options;else return[Error(`Invalid Casting Value: returned value must return a string, an object, null or undefined, got ${JSON.stringify(a)}`)];let{delimiter:s,escape:c,quote:l,quoted:u,quoted_empty:d,quoted_string:f,quoted_match:p,record_delimiter:m,escape_formulas:h}=t;if(a===``&&o===``){let e=p&&p.filter(e=>typeof e==`string`?a.indexOf(e)!==-1:e.test(a));e=e&&e.length>0,(e||!0===d||!0===f&&!1!==d)===!0&&(a=l+a+l),i+=a}else if(a){if(typeof a!=`string`)return[Error(`Formatter must return a string, null or undefined, got ${JSON.stringify(a)}`)];let e=s.length&&a.indexOf(s)>=0,t=l!==``&&a.indexOf(l)>=0,n=a.indexOf(c)>=0&&c!==l,r=a.indexOf(m)>=0,d=f&&typeof o==`string`,g=p&&p.filter(e=>typeof e==`string`?a.indexOf(e)!==-1:e.test(a));if(g=g&&g.length>0,h)switch(a[0]){case`=`:case`+`:case`-`:case`@`:case`	`:case`\r`:case`=`:case`+`:case`-`:case`@`:a=`'${a}`;break}let _=t===!0||e||r||u||d||g;if(_===!0&&n===!0){let e=c===`\\`?new RegExp(c+c,`g`):new RegExp(c,`g`);a=a.replace(e,c+c)}if(t===!0){let e=new RegExp(l,`g`);a=a.replace(e,c+l)}_===!0&&(a=l+a+l),i+=a}else (d===!0||o===``&&f===!0&&d!==!1)&&(i+=l+l);e!==r.length-1&&(i+=s)}return[void 0,i]},bom:function(e){this.options.bom===!0&&e(ml)},headers:function(e){if(this.options.header===!1||this.options.columns===void 0)return;let t,n=this.options.columns.map(e=>e.header);if(this.options.eof?([t,n]=this.stringify(n,!0),n+=this.options.record_delimiter):[t,n]=this.stringify(n),t)return t;e(n)},__cast:function(e,t){let n=typeof e;try{return n===`string`?[void 0,this.options.cast.string(e,t)]:n===`bigint`?[void 0,this.options.cast.bigint(e,t)]:n===`number`?[void 0,this.options.cast.number(e,t)]:n===`boolean`?[void 0,this.options.cast.boolean(e,t)]:e instanceof Date?[void 0,this.options.cast.date(e,t)]:n===`object`&&e!==null?[void 0,this.options.cast.object(e,t)]:[void 0,e,e]}catch(e){return[e]}}}},gl=function(e,t={}){let n=[],[r,i]=pl(t);if(r!==void 0)throw r;let a=hl(i,{stop:!1},{records:0});for(let t of e){let e=a.__transform(t,function(e){n.push(e)});if(e!==void 0)throw e}if(n.length===0){a.bom(e=>{n.push(e)});let e=a.headers(e=>{n.push(e)});if(e!==void 0)throw e}return n.join(``)};function _l(e){return gl(e)}function vl(e,t,n){if(Object.keys(e).length===0||n.length===0)return[];let r=[],i=1;for(let a=0;a<n.length;a++){let o=n[a],s=t[o];!s||!y(s)||(o in e||r.push({id:o,index:i,title:s.title,cue:s.cue,scheduledStart:s.timeStart,actualEnd:null,scheduledEnd:s.timeEnd,actualStart:null}),o in e&&r.push({id:o,index:i,title:s.title,cue:s.cue,scheduledStart:s.timeStart,actualEnd:e[o].endedAt,scheduledEnd:s.timeEnd,actualStart:e[o].startedAt}),i++)}return r}var yl=[`Index`,`Title`,`Cue`,`Scheduled Start`,`Actual Start`,`Scheduled End`,`Actual End`];function bl(e){let t=[];t.push(yl);for(let n of e)t.push([String(n.index),n.title,n.cue,r(n.scheduledStart),r(n.actualStart),r(n.scheduledEnd),r(n.actualEnd)]);return _l(t)}var xl={blink:`_blink_qqr9x_1`,fourtyfive:`_fourtyfive_qqr9x_13`,over:`_over_qqr9x_17`,under:`_under_qqr9x_21`};function Sl(){let{data:e}=Ui(),{data:t}=ai(),n=async()=>await Hi(),i=e=>{e&&l(T(bl(e),`text/csv;charset=utf-8;`),`ontime-report.csv`)},a=(0,q.useMemo)(()=>vl(e,t.entries,t.flatOrder),[e,t.entries,t.flatOrder]);return(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[(0,J.jsx)(yi,{children:`Report`}),(0,J.jsx)(Di,{}),(0,J.jsx)(B,{children:(0,J.jsxs)(Ti,{children:[`Manage report`,(0,J.jsxs)(V,{children:[(0,J.jsxs)(M,{onClick:()=>i(a),disabled:a.length===0,children:[(0,J.jsx)(An,{}),`Export CSV`]}),(0,J.jsxs)(M,{variant:`subtle-destructive`,onClick:n,disabled:a.length===0,children:[(0,J.jsx)(An,{}),`Clear All`]})]})]})}),(0,J.jsx)(B,{children:(0,J.jsxs)(vi,{children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`#`}),(0,J.jsx)(`th`,{children:`Cue`}),(0,J.jsx)(`th`,{children:`Title`}),(0,J.jsx)(`th`,{children:`Scheduled Start`}),(0,J.jsx)(`th`,{children:`Actual Start`}),(0,J.jsx)(`th`,{children:`Scheduled End`}),(0,J.jsx)(`th`,{children:`Actual End`})]})}),(0,J.jsxs)(`tbody`,{children:[a.length===0&&(0,J.jsx)(Si,{title:`No report data yet`,description:`Reports are generated as you run through the show, comparing scheduled times against what actually happened.`}),a.map(e=>{let t=e.actualStart===null?null:e.actualStart<=e.scheduledStart?`under`:`over`,n=e.actualEnd===null?null:e.actualEnd<=e.scheduledEnd?`under`:`over`;return(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:e.index}),(0,J.jsx)(`th`,{children:e.cue}),(0,J.jsx)(`th`,{children:e.title}),(0,J.jsx)(`th`,{className:an([t&&xl[t]]),children:r(e.scheduledStart)}),(0,J.jsx)(`th`,{className:an([t&&xl[t]]),children:r(e.actualStart)}),(0,J.jsx)(`th`,{className:an([n&&xl[n]]),children:r(e.scheduledEnd)}),(0,J.jsx)(`th`,{className:an([n&&xl[n]]),children:r(e.actualEnd)})]},e.id)})]})]})})]})})}var Cl={blink:`_blink_1sy0c_1`,fourtyfive:`_fourtyfive_1sy0c_13`,expand:`_expand_1sy0c_17`,column:`_column_1sy0c_21`},wl=[{value:m.Cuesheet,label:`Cuesheet`},{value:m.Operator,label:`Operator`},{value:m.Timer,label:`Timer`},{value:m.Backstage,label:`Backstage`},{value:m.Timeline,label:`Timeline`},{value:m.StudioClock,label:`Studio Clock`},{value:m.Countdown,label:`Countdown`},{value:m.ProjectInfo,label:`Project Info`},{value:m.Teleprompter,label:`Teleprompter`}],Tl=`url-preset-form`,El={alias:``,target:m.Timer,search:``,enabled:!0,displayInNav:!1};function Dl({urlPreset:e,onClose:t}){let{addPreset:n,updatePreset:r,isMutating:i}=vt(),{handleSubmit:a,register:o,setFocus:s,setError:c,clearErrors:l,setValue:u,getValues:f,watch:p,formState:{errors:h,isSubmitting:g,isValid:_,isDirty:v}}=Pi({defaultValues:e??El,mode:`onChange`,resetOptions:{keepDirtyValues:!0}}),y=(0,q.useRef)(null),b=(0,q.useRef)({read:e?.options?.read??`full`,write:e?.options?.write??`full`}),[x,S]=(0,q.useState)(b.current);(0,q.useEffect)(()=>{b.current={read:e?.options?.read??`full`,write:e?.options?.write??`full`},S(b.current)},[]);let C=e&&e.target===m.Cuesheet,w=p(`target`)===m.Cuesheet,T=w&&(x.read!==b.current.read||x.write!==b.current.write),E=w&&x.read===`-`,O=async i=>{try{let a=i.target===m.Cuesheet?{...i,target:m.Cuesheet,options:x}:i;e?await r(e.alias,a):await n(a),t()}catch(e){c(`root`,{message:d(e)})}};(0,q.useEffect)(()=>{s(`alias`)},[s]);let k=()=>{l();try{let e=gi(f(`alias`),y.current?.value.trim()??``);u(`target`,e.target,{shouldDirty:!0,shouldValidate:!0}),u(`search`,e.search,{shouldDirty:!0,shouldValidate:!0})}catch(e){c(`root`,{message:D(e)});return}},ee=e=>{try{return new URLSearchParams(e),!0}catch(e){return D(e)||`Invalid URL parameters`}};return(0,J.jsx)(Ii,{isOpen:!0,onClose:t,showBackdrop:!0,showCloseButton:!0,size:`compact`,title:e?`Edit URL preset`:`Create URL preset`,bodyElements:(0,J.jsxs)(`form`,{id:Tl,onSubmit:a(O),className:Cl.column,children:[(0,J.jsx)(`input`,{hidden:!0,name:`enabled`,value:`true`}),(0,J.jsx)(`div`,{children:`1. Enter URL and let Ontime generate the preset options`}),(0,J.jsxs)(V,{children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(U,{children:`Alias`}),(0,J.jsx)(R,{...o(`alias`,{required:`Alias is required`,pattern:{value:Ir,message:`Field can only contain URL safe characters (a-z, 0-9, _ and -)`}})})]}),(0,J.jsxs)(`div`,{className:Cl.expand,children:[(0,J.jsx)(U,{children:`Generate options (paste URL to generate options)`}),(0,J.jsxs)(V,{children:[(0,J.jsx)(R,{placeholder:`Paste URL`,fluid:!0,ref:y,disabled:C}),(0,J.jsx)(M,{onClick:k,disabled:C,children:`Generate`})]})]})]}),h.alias?.message&&(0,J.jsx)(G,{children:h.alias.message}),!C&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{children:[`–`,` or `,`–`]}),(0,J.jsx)(`div`,{children:`2. Choose a view and its parameters`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(U,{children:`Target`}),(0,J.jsx)(Gt,{options:wl,...o(`target`,{required:`Target is required`}),value:p(`target`),onValueChange:e=>{e!==null&&u(`target`,e,{shouldDirty:!0})}})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(U,{children:`Parameters`}),(0,J.jsx)(Ki,{fluid:!0,rows:3,...o(`search`,{validate:ee})}),(0,J.jsx)(G,{children:h.search?.message})]})]}),w&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(U,{children:`Permissions`}),(0,J.jsx)(Lr,{initialRead:b.current.read,initialWrite:b.current.write,onChange:S})]})]}),footerElements:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(G,{children:h.root?.message}),(0,J.jsx)(M,{onClick:t,children:`Cancel`}),(0,J.jsx)(M,{variant:`primary`,type:`submit`,form:Tl,disabled:!_||!v&&!T||E,loading:g||i,children:`Save`})]})})}var Ol=`https://docs.getontime.no/features/url-presets/`;function kl(){let[e,t]=(0,q.useState)({isOpen:!1,preset:void 0}),[n,r]=(0,q.useState)(null),{data:i,status:a}=P(),{updatePreset:o,deletePreset:s,isMutating:c}=vt(),l=()=>t({isOpen:!0}),u=e=>t({isOpen:!0,preset:e}),f=()=>t({isOpen:!1,preset:void 0}),p=async e=>{r(null);try{await o(e.alias,e)}catch(e){r(d(e))}};return(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[e.isOpen&&(0,J.jsx)(Dl,{urlPreset:e.preset,onClose:f}),(0,J.jsxs)(yi,{children:[`URL presets`,(0,J.jsxs)(M,{onClick:l,children:[`New `,(0,J.jsx)(I,{})]})]}),(0,J.jsx)(Di,{}),(0,J.jsx)(B,{children:(0,J.jsxs)(K,{children:[`URL presets are user pre-defined aliases to Ontime URLs.`,(0,J.jsx)(`br`,{}),`This URL can contain full configuration including parameters, or simply route to a specific view.`,(0,J.jsx)(`br`,{}),(0,J.jsx)(`br`,{}),`The easiest way to get started is to copy an URL from your browser and paste it into the form.`,(0,J.jsx)(Wa,{href:Ol,children:`See the docs`})]})}),(0,J.jsxs)(B,{children:[(0,J.jsx)(_i,{isLoading:a===`pending`}),n&&(0,J.jsx)(G,{children:n}),(0,J.jsxs)(vi,{children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`Enabled`}),(0,J.jsx)(`th`,{children:`Show in nav`}),(0,J.jsx)(`th`,{children:`Target view`}),(0,J.jsx)(`th`,{children:`Alias`}),(0,J.jsx)(`th`,{})]})}),(0,J.jsxs)(`tbody`,{children:[i.length===0&&(0,J.jsx)(Si,{title:`No URL presets yet`,description:`A preset gives one of your views a short, memorable address, with all of its options baked in.`,action:(0,J.jsxs)(M,{variant:`primary`,onClick:l,children:[`Create preset `,(0,J.jsx)(I,{})]})}),i.map((e,t)=>{let n=e.target===m.Cuesheet;return(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:(0,J.jsx)(ir,{checked:e.enabled,onCheckedChange:t=>p({...e,enabled:t}),disabled:c,"aria-label":`Toggle preset enabled`})}),(0,J.jsx)(`td`,{children:(0,J.jsx)(ir,{checked:e.displayInNav,onCheckedChange:t=>p({...e,displayInNav:t}),disabled:c||n})}),(0,J.jsx)(`td`,{children:(0,J.jsx)(Qr,{children:e.target})}),(0,J.jsx)(`td`,{style:{width:`100%`},children:e.alias}),(0,J.jsxs)(V,{relation:`inner`,as:`td`,children:[(0,J.jsx)(L,{variant:`ghosted-white`,onClick:t=>mr(e.alias,t),disabled:c,children:(0,J.jsx)(vn,{})}),(0,J.jsx)(L,{onClick:()=>u(e),variant:`ghosted-white`,"aria-label":`Edit entry`,"data-testid":`field__edit_${t}`,disabled:c,children:(0,J.jsx)(Gn,{})}),(0,J.jsx)(L,{onClick:()=>s(e.alias),variant:`ghosted-destructive`,"aria-label":`Delete entry`,"data-testid":`field__delete_${t}`,disabled:c,children:(0,J.jsx)(On,{})})]})]},e.alias)})]})]})]})]})})}function Al({location:e}){let t=Qa(`presets`,e),n=Qa(`link`,e),r=Qa(`report`,e);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ci,{children:`Sharing and reporting`}),(0,J.jsx)(`div`,{ref:t,children:(0,J.jsx)(kl,{})}),(0,J.jsx)(`div`,{ref:n,children:(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[(0,J.jsx)(yi,{children:`Share Ontime Link`}),!nn&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ai,{children:`Ontime is streaming on the following network interfaces`}),(0,J.jsx)(Rs,{})]}),(0,J.jsx)(Di,{}),(0,J.jsx)(Br,{})]})})}),(0,J.jsx)(`div`,{ref:r,children:(0,J.jsx)(Sl,{})})]})}var jl={blink:`_blink_1fjfd_1`,fourtyfive:`_fourtyfive_1fjfd_13`,halfWidth:`_halfWidth_1fjfd_17`,fullWidth:`_fullWidth_1fjfd_21`,twoCols:`_twoCols_1fjfd_25`,formColumn:`_formColumn_1fjfd_31`,current:`_current_1fjfd_37`};function Ml(e){let{colour:t,label:n,fieldKey:r,type:i,onEdit:a,onDelete:o}=e;return(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:(0,J.jsx)(Dr,{color:t})}),(0,J.jsx)(`td`,{children:(0,J.jsx)(Qr,{children:i})}),(0,J.jsx)(`td`,{className:jl.halfWidth,children:n}),(0,J.jsx)(`td`,{className:jl.fullWidth,children:(0,J.jsx)(gr,{size:`small`,copyValue:r,children:r})}),(0,J.jsxs)(V,{relation:`inner`,as:`td`,children:[(0,J.jsx)(L,{variant:`ghosted-white`,"aria-label":`Edit entry`,onClick:a,children:(0,J.jsx)(Gn,{})}),(0,J.jsx)(L,{variant:`ghosted-destructive`,"aria-label":`Delete entry`,onClick:()=>o(r),children:(0,J.jsx)(On,{})})]})]})}var Nl=`custom-field-form`;function Pl({onSubmit:e,onCancel:t,initialColour:n,initialLabel:r,initialKey:i,initialType:a}){let{data:o}=ia(),[s,c]=(0,q.useState)(n||``),{handleSubmit:l,register:u,setFocus:f,setError:p,setValue:m,getValues:h,watch:g,formState:{errors:_,isSubmitting:v,isValid:y,isDirty:b}}=Pi({defaultValues:{type:a??`text`,label:r||``,colour:n||``},resetOptions:{keepDirtyValues:!0}}),x=async t=>{let{type:n,label:r,colour:i}=t,a={type:n,colour:i,label:r};try{await e(a)}catch(e){p(`root`,{type:`custom`,message:d(e)})}};(0,q.useEffect)(()=>{f(`label`)},[f]);let S=e=>{c(e),m(`colour`,e,{shouldDirty:!0})},C=h(`colour`),w=b&&y,T=i!==void 0;return(0,J.jsx)(Ii,{isOpen:!0,onClose:t,showBackdrop:!0,showCloseButton:!0,size:`compact`,title:T?`Edit custom field`:`Create custom field`,bodyElements:(0,J.jsxs)(`form`,{id:Nl,onSubmit:l(x),className:jl.formColumn,children:[(0,J.jsxs)(K,{children:[`Please note that images can quickly deteriorate your app's performance.`,(0,J.jsx)(`br`,{}),`Prefer using small, and compressed images.`]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(U,{children:`Type`}),(0,J.jsx)(Rr,{orientation:`horizontal`,disabled:T,onValueChange:e=>m(`type`,e,{shouldDirty:!0}),value:g(`type`),items:[{value:`text`,label:`Text`},{value:`image`,label:`Image`}]})]}),(0,J.jsxs)(`div`,{className:jl.twoCols,children:[(0,J.jsxs)(`label`,{children:[(0,J.jsx)(U,{children:`Label (only alphanumeric characters are allowed)`}),_.label&&(0,J.jsx)(G,{children:_.label.message}),(0,J.jsx)(R,{...u(`label`,{required:{value:!0,message:`Required field`},onChange:()=>m(`key`,wa(h(`label`))??`N/A`),validate:e=>e.trim().length===0?`Required field`:bi.isAlphanumericWithSpace(e)?!T&&Object.hasOwn(o,wa(e)??``)?`Custom fields must be unique`:!0:`Only alphanumeric characters and space are allowed`}),fluid:!0})]}),(0,J.jsxs)(`label`,{children:[(0,J.jsx)(U,{children:`Key (use in Integrations and API)`}),(0,J.jsx)(R,{...u(`key`),variant:`ghosted`,readOnly:!0,fluid:!0})]})]}),(0,J.jsxs)(`label`,{children:[(0,J.jsx)(U,{children:`Colour`}),(0,J.jsx)(Er,{name:`colour`,value:C,handleChange:(e,t)=>S(t)})]})]}),footerElements:(0,J.jsxs)(J.Fragment,{children:[_.root&&(0,J.jsx)(G,{children:_.root.message}),(0,J.jsx)(M,{variant:`ghosted`,onClick:t,children:`Cancel`}),(0,J.jsx)(M,{type:`submit`,form:Nl,variant:`primary`,disabled:!w,loading:v,children:`Save`})]})})}function Fl(){let{data:e,refetch:t}=ia(),[n,r]=(0,q.useState)({isOpen:!1,field:void 0}),i=()=>r({isOpen:!0}),a=e=>r({isOpen:!0,field:e}),o=()=>r({isOpen:!1,field:void 0}),s=async e=>{let r=n.field;r?await ra(r.key,e):await ta(e),t(),o()},c=async e=>{try{await na(e),t()}catch{}},l=Object.entries(e);return(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[n.isOpen&&(0,J.jsx)(Pl,{onSubmit:s,onCancel:o,initialColour:n.field?.colour,initialLabel:n.field?.label,initialKey:n.field?.key,initialType:n.field?.type}),(0,J.jsxs)(yi,{children:[`Custom fields`,(0,J.jsxs)(M,{onClick:i,children:[`New `,(0,J.jsx)(I,{})]})]}),(0,J.jsx)(Di,{}),(0,J.jsx)(B,{children:(0,J.jsxs)(K,{children:[(0,J.jsx)(`span`,{children:`Custom fields allow for additional information to be added to an event.`}),(0,J.jsxs)(`span`,{children:[`To use custom fields as a data source in an`,` `,(0,J.jsx)(Vi,{search:`settings=automation__automations`,children:`Automation`}),`, please note the generated key.`]}),(0,J.jsx)(Wa,{href:un,children:`See the docs`})]})}),(0,J.jsx)(B,{children:(0,J.jsxs)(vi,{children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`Colour`}),(0,J.jsx)(`th`,{children:`Type`}),(0,J.jsx)(`th`,{children:`Name`}),(0,J.jsx)(`th`,{children:`Key (used in Automations)`}),(0,J.jsx)(`th`,{})]})}),(0,J.jsxs)(`tbody`,{children:[l.length===0&&(0,J.jsx)(Si,{title:`No custom fields yet`,description:`Custom fields add your own columns to the rundown, and can be shown in views or used in automations.`,action:(0,J.jsxs)(M,{variant:`primary`,onClick:i,children:[`Create custom field `,(0,J.jsx)(I,{})]})}),l.map(([e,{colour:t,label:n,type:r}])=>(0,J.jsx)(Ml,{fieldKey:e,colour:t,label:n,type:r,onEdit:()=>a({key:e,colour:t,label:n,type:r}),onDelete:c},e))]})]})})]})})}var Il=`${wn}/excel`;async function Ll(e,t){let n=new FormData;return n.append(`excel`,e),(await bn.post(`${Il}/upload`,n,{signal:t?.signal,timeout:t?.timeout??xi.longTimeout,headers:{"Content-Type":`multipart/form-data`}})).data}async function Rl(e,t){return(await bn.post(`${Il}/preview`,{options:e},{signal:t?.signal,timeout:t?.timeout??xi.longTimeout})).data}async function zl(e,t){return(await bn.post(`${Il}/metadata`,{worksheet:e},{signal:t?.signal,timeout:t?.timeout??xi.longTimeout})).data}async function Bl(e,t,n){try{l((await bn.get(`${Il}/${e}/export`,{signal:n?.signal,timeout:n?.timeout??xi.longTimeout,responseType:`blob`})).data,`${t??`Ontime_rundown`}.xlsx`)}catch(e){console.error(`Error downloading file:`,e)}}function Vl({onSubmit:e,onCancel:t,initialTitle:n}){let{handleSubmit:r,register:i,setFocus:a,setError:o,formState:{errors:s,isSubmitting:c,isValid:l,isDirty:u}}=Pi({defaultValues:{title:n},mode:`onChange`}),f=async t=>{try{await e(t.title)}catch(e){o(`root`,{type:`custom`,message:d(e)})}};(0,q.useEffect)(()=>{a(`title`)},[a]);let p=u&&l;return(0,J.jsxs)(Mi,{as:`form`,onSubmit:r(f),onKeyDown:e=>cr(e,t),children:[(0,J.jsxs)(`label`,{children:[(0,J.jsx)(U,{children:`Rundown title`}),(0,J.jsx)(R,{...i(`title`,{required:{value:!0,message:`Title is required`},validate:e=>e.trim().length===0?`Title cannot be empty`:bi.isAlphanumericWithSpace(e)===!1?`Title can only contain alphanumeric characters, spaces and underscores`:!0}),maxLength:64,fluid:!0}),s.title&&(0,J.jsx)(G,{children:s.title.message})]}),s.root&&(0,J.jsx)(G,{children:s.root.message}),(0,J.jsxs)(V,{relation:`inner`,align:`end`,children:[(0,J.jsx)(M,{variant:`ghosted`,onClick:t,children:`Cancel`}),(0,J.jsx)(M,{type:`submit`,variant:`primary`,disabled:!p,loading:c,children:`Save`})]})]})}var Hl=`new-rundown-form`;function Ul({onClose:e}){let{create:t}=li(),{handleSubmit:n,register:r,setFocus:i,setError:a,formState:{errors:o,isSubmitting:s}}=Pi({defaultValues:{title:``}});return(0,q.useEffect)(()=>{i(`title`)},[i]),(0,J.jsx)(Ii,{isOpen:!0,onClose:e,showBackdrop:!0,showCloseButton:!0,size:`small`,title:`Create rundown`,bodyElements:(0,J.jsx)(`form`,{id:Hl,onSubmit:n(async n=>{try{await t(n.title||`untitled`),e()}catch(e){a(`root`,{message:`Failed to create rundown. ${e}`})}}),children:(0,J.jsxs)(`label`,{children:[(0,J.jsx)(U,{children:`Rundown title`}),(0,J.jsx)(R,{...r(`title`),fluid:!0,placeholder:`Your rundown name`,maxLength:64})]})}),footerElements:(0,J.jsxs)(J.Fragment,{children:[o.root&&(0,J.jsx)(G,{children:o.root.message}),(0,J.jsx)(M,{variant:`ghosted`,disabled:s,onClick:e,children:`Cancel`}),(0,J.jsx)(M,{type:`submit`,form:Hl,variant:`primary`,disabled:s,children:`Create rundown`})]})})}function Wl(){let{data:e}=ui(),{duplicate:t,remove:n,load:r,rename:i}=li(),[a,o]=br(),[s,c]=br(),[l,u]=br(),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(null),v=e=>{_(null),p(e),c.open()},y=e=>{_(null),p(e),o.open()},b=e=>{_(null),h(e)},x=async()=>{try{await r(f)}catch(e){_(`Failed to load rundown. ${d(e)}`)}finally{c.close()}},S=async e=>{_(null),h(null),p(``);try{await t(e)}catch(e){_(`Failed to duplicate rundown. ${d(e)}`)}},C=async(e,t)=>{try{await i([e,t]),h(null)}catch(e){_(`Failed to rename rundown. ${d(e)}`)}},w=async()=>{try{await n(f)}catch(e){_(`Failed to delete rundown. ${d(e)}`)}finally{o.close()}},T=async(e,t)=>{await Bl(e,t)},E=ba();return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[(0,J.jsxs)(yi,{children:[`Manage project rundowns`,(0,J.jsx)(V,{children:(0,J.jsxs)(M,{onClick:()=>{_(null),u.open()},children:[`New `,(0,J.jsx)(I,{})]})})]}),(0,J.jsx)(Di,{}),(0,J.jsxs)(B,{children:[l&&(0,J.jsx)(Ul,{onClose:u.close}),g&&(0,J.jsx)(G,{children:g}),(0,J.jsxs)(vi,{children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`# Entries`}),(0,J.jsx)(`th`,{style:{width:`100%`},children:`Title`}),(0,J.jsx)(`th`,{})]})}),(0,J.jsx)(`tbody`,{children:e?.rundowns?.map(({id:t,numEntries:n,title:r})=>{let i=e.loaded===t;return m===t?(0,J.jsx)(`tr`,{children:(0,J.jsx)(`td`,{colSpan:3,children:(0,J.jsx)(Vl,{onCancel:()=>h(null),onSubmit:e=>C(t,e),initialTitle:r})})},t):(0,J.jsxs)(`tr`,{className:an([i&&jl.current]),children:[(0,J.jsx)(`td`,{children:n}),(0,J.jsxs)(`td`,{children:[r,` `,i&&(0,J.jsx)(Qr,{variant:`active`,children:`Loaded`})]}),(0,J.jsx)(`td`,{children:(0,J.jsx)(Nr,{render:(0,J.jsx)(L,{variant:`ghosted-white`,"data-testId":`rundown_menu`}),items:[{type:`item`,icon:rn,label:`Rename`,onClick:()=>b(t)},{type:`item`,icon:$t,label:`Load`,onClick:()=>v(t),disabled:i},{type:`item`,icon:mn,label:`Download .xlsx`,onClick:()=>T(t,r)},{type:`item`,icon:er,label:`Duplicate`,onClick:()=>S(t)},{type:`item`,icon:Li,label:`Edit in cuesheet`,onClick:()=>E(t)},{type:`divider`},{type:`destructive`,icon:On,label:`Delete`,onClick:()=>y(t),disabled:i}],children:(0,J.jsx)(tn,{})})})]},t)})})]})]})]})}),(0,J.jsx)(dr,{isOpen:a,onClose:o.close,title:`Delete rundown`,showBackdrop:!0,showCloseButton:!0,bodyElements:(0,J.jsxs)(J.Fragment,{children:[`You will lose all data in your rundown. `,(0,J.jsx)(`br`,{}),` Are you sure?`]}),footerElements:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(M,{size:`large`,onClick:o.close,children:`Cancel`}),(0,J.jsx)(M,{variant:`destructive`,size:`large`,onClick:w,children:`Delete rundown`})]})}),(0,J.jsx)(dr,{isOpen:s,onClose:c.close,title:`Load rundown`,showBackdrop:!0,showCloseButton:!0,bodyElements:(0,J.jsxs)(J.Fragment,{children:[`The current playback will be stopped. `,(0,J.jsx)(`br`,{}),` Are you sure?`]}),footerElements:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(M,{size:`large`,onClick:c.close,children:`Cancel`}),(0,J.jsx)(M,{variant:`primary`,size:`large`,onClick:x,children:`Load rundown`})]})})]})}function Gl(){let{defaultDuration:e,linkPrevious:t,defaultTimeStrategy:n,defaultWarnTime:r,defaultDangerTime:i,defaultTimerType:a,defaultEndAction:o,inheritGroupColour:s,setDefaultDuration:c,setLinkPrevious:l,setTimeStrategy:u,setWarnTime:d,setDangerTime:p,setDefaultTimerType:m,setDefaultEndAction:h,setInheritGroupColour:g}=Gi(e=>e),_=qr(e),v=qr(r),y=qr(i);return(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[(0,J.jsx)(yi,{children:`Rundown defaults`}),(0,J.jsx)(Di,{}),(0,J.jsxs)(B,{children:[(0,J.jsx)(Ti,{children:`Default settings for new events`}),(0,J.jsxs)(ji,{children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Link previous`,description:`Whether the start time of new events should be linked to the previous event end time`}),(0,J.jsx)(ir,{size:`large`,checked:t,onCheckedChange:l})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Inherit group colour`,description:`Whether new events and milestones inherit the colour of their parent group`}),(0,J.jsx)(ir,{size:`large`,checked:s,onCheckedChange:g})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Timer strategy`,description:`Which time should be maintained when event schedule is recalculated`}),(0,J.jsx)(Gt,{value:n,onValueChange:e=>{e!==null&&u(e)},options:[{value:f.LockDuration,label:`Duration`},{value:f.LockEnd,label:`End Time`}]})]})]}),(0,J.jsxs)(ji,{children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Default duration`,description:`Default duration for new events`}),(0,J.jsx)(Bi,{name:`defaultDuration`,submitHandler:(e,t)=>c(t),time:_,placeholder:qi.duration})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Timer type`,description:`Default type of timer for new events`}),(0,J.jsx)(Gt,{value:a,onValueChange:e=>{e!==null&&m(e)},options:[{value:ue.CountDown,label:`Count down`},{value:ue.CountUp,label:`Count up`},{value:ue.Clock,label:`Clock`},{value:ue.None,label:`None`}]})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`End Action`,description:`Default end action for new events`}),(0,J.jsx)(Gt,{value:o,onValueChange:e=>{e!==null&&h(e)},options:[{value:E.None,label:`None`},{value:E.LoadNext,label:`Load next`},{value:E.PlayNext,label:`Play next`}]})]})]}),(0,J.jsxs)(ji,{children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Warning time`,description:`Default threshold for warning time in an event`}),(0,J.jsx)(Bi,{name:`warnTime`,submitHandler:(e,t)=>d(t),time:v,placeholder:qi.warnTime})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Danger time`,description:`Default threshold for danger time in an event`}),(0,J.jsx)(Bi,{name:`dangerTime`,submitHandler:(e,t)=>p(t),time:y,placeholder:qi.dangerTime})]})]})]})]})})}var Kl=`${wn}/sheets`,ql=async()=>(await bn.get(`${Kl}/connect`)).data,Jl=async(e,t,n)=>{let r=new FormData;return r.append(`client_secret`,e),(await bn.post(`${Kl}/${t}/connect`,r,{signal:n?.signal,timeout:n?.timeout??xi.longTimeout,headers:{"Content-Type":`multipart/form-data`}})).data},Yl=async()=>(await bn.post(`${Kl}/revoke`)).data,Xl=async(e,t,n)=>(await bn.post(`${Kl}/${e}/read`,{options:t},{signal:n?.signal,timeout:n?.timeout??xi.longTimeout})).data,Zl=async(e,t,n)=>(await bn.post(`${Kl}/${e}/metadata`,{worksheet:t},{signal:n?.signal,timeout:n?.timeout??xi.longTimeout})).data,Ql=async(e,t)=>(await bn.post(`${Kl}/${e}/worksheet-options`,void 0,{signal:t?.signal,timeout:t?.timeout??xi.longTimeout})).data,$l=async(e,t,n)=>(await bn.post(`${Kl}/${e}/write`,{options:t},{signal:n?.signal,timeout:n?.timeout??xi.longTimeout})).data;function eu(e){if(!ru(e))throw Error(`Unknown file type`);if(e.size===0)throw Error(`File is empty`);if(e.size>1e7)throw Error(`File size limit (10MB) exceeded`)}function tu(e){if(!iu(e))throw Error(`Unknown file type`);if(e.size===0)throw Error(`File is empty`);if(e.size>2e6)throw Error(`File size limit (2MB) exceeded`)}function nu(e){let t=e.lastIndexOf(`.`);return t<=0?e:e.slice(0,t)}function ru(e){return e?.name.endsWith(`.xlsx`)}function iu(e){return e?.name.endsWith(`.json`)}function au(e){if(e.size===0)throw Error(`File is empty`);if(e.size>15e5)throw Error(`File size limit (1.5MB) exceeded`)}var ou=/\/spreadsheets\/d\/([a-zA-Z0-9_-]+)/,su=pe(`gsheet:lastSheetId`);function cu(e){let t=e.trim(),n=t.match(ou);return n?n[1]:t.split(/[?#]/)[0]}function lu(){return localStorage.getItem(su)??``}function uu(e){localStorage.setItem(su,e)}var Z={blink:`_blink_1x0da_1`,fourtyfive:`_fourtyfive_1x0da_13`,introStack:`_introStack_1x0da_17`,setupLead:`_setupLead_1x0da_23`,finishTitle:`_finishTitle_1x0da_24`,setupBody:`_setupBody_1x0da_31`,finishDescription:`_finishDescription_1x0da_32`,sourceDescription:`_sourceDescription_1x0da_33`,sourceGrid:`_sourceGrid_1x0da_39`,finishSection:`_finishSection_1x0da_40`,finishActions:`_finishActions_1x0da_44`,sourceCard:`_sourceCard_1x0da_57`,setupBlock:`_setupBlock_1x0da_59`,sourceHeader:`_sourceHeader_1x0da_73`,setupIntroText:`_setupIntroText_1x0da_74`,sourceTitle:`_sourceTitle_1x0da_80`,sourceMeta:`_sourceMeta_1x0da_87`,setupHint:`_setupHint_1x0da_88`,finishBadge:`_finishBadge_1x0da_103`,setupShell:`_setupShell_1x0da_115`,setupIntro:`_setupIntro_1x0da_74`,setupActions:`_setupActions_1x0da_135`,statusIdle:`_statusIdle_1x0da_139`,statusPending:`_statusPending_1x0da_144`,statusReady:`_statusReady_1x0da_149`};function du(e){let{onCancel:t,onSheetLoaded:n,closedByUser:r}=e,[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(lu),[c,l]=(0,q.useState)(`not_authenticated`),[u,f]=(0,q.useState)(null),[p,m]=(0,q.useState)(``),[h,g]=(0,q.useState)(``),[_,v]=(0,q.useState)(``),[y,b]=(0,q.useState)(``),x=(0,q.useRef)(null),S=(0,q.useRef)(null),C=(0,q.useRef)(null),w=(0,q.useCallback)(()=>{x.current!==null&&(window.clearTimeout(x.current),x.current=null)},[]),T=(0,q.useCallback)(()=>{S.current!==null&&(window.clearTimeout(S.current),S.current=null)},[]),E=(0,q.useCallback)(()=>{C.current!==null&&(window.removeEventListener(`focus`,C.current),C.current=null)},[]),D=(0,q.useCallback)(async e=>{let t=await Ql(e);uu(e),n(e,t),b(``)},[n]),O=(0,q.useCallback)(async(e=0)=>{if(w(),!r)try{let t=await ql();if(l(t.authenticated),s(t.sheetId),t.authenticated===`pending`){if(e<10){x.current=window.setTimeout(()=>{O(e+1)},2e3);return}f(null),g(``);return}if(t.authenticated===`authenticated`&&t.sheetId){g(`load-sheet`);try{await D(t.sheetId)}catch(e){b(d(e))}}f(null),g(``)}catch(e){v(d(e)),f(null),g(``)}},[w,D,r]);(0,q.useEffect)(()=>(v(``),O(),()=>{E(),w(),T()}),[T,E,w,O]);let k=async()=>{g(`cancel`);try{l((await Yl()).authenticated),s(``),f(null),m(``),v(``),b(``)}catch(e){v(d(e))}finally{g(``)}},ee=()=>{t()},te=e=>{e.target.files?.length&&a(e.target.files[0])},A=async()=>{if(i&&o){g(`connect`),v(``),b(``);try{let e=await Jl(i,o);m(e.verification_url),f(e.user_code)}catch(e){v(d(e))}finally{g(``)}}},ne=()=>{g(`authenticate`),v(``),E(),w(),T(),ur(p),S.current=window.setTimeout(()=>{document.hasFocus()&&g(``)},1500);function e(){T(),E(),O()}C.current=e,window.addEventListener(`focus`,e,{once:!0})},re=async()=>{if(o){g(`load-sheet`),b(``);try{await D(o)}catch(e){b(d(e))}finally{g(``)}}},ie=!!i&&!!o,ae=!!o,oe=!!u&&!!p,se=!!h,ce=c===`authenticated`,le=c===`pending`,ue=ce?`Connected`:le?`Waiting for confirmation`:`Not connected`,de=ce?Z.statusReady:le?Z.statusPending:Z.statusIdle,fe=ce?`default`:`warning`,pe=ce?`Load a spreadsheet by its Google Sheet ID.`:oe?`Finish the device verification in your browser, then return here.`:`Upload your client secret and enter the sheet ID you want to access.`;return(0,J.jsxs)(B,{className:Z.setupShell,children:[(0,J.jsxs)(Ti,{children:[`Sync with Google Sheet (experimental)`,ce?(0,J.jsx)(M,{onClick:k,loading:h===`cancel`,children:`Revoke Authentication`}):(0,J.jsx)(M,{onClick:ee,children:`Go Back`})]}),(0,J.jsxs)(`div`,{className:Z.setupIntro,children:[(0,J.jsxs)(`div`,{className:Z.setupIntroText,children:[(0,J.jsx)(`p`,{className:Z.setupLead,children:ue}),(0,J.jsx)(`p`,{className:Z.setupBody,children:pe})]}),(0,J.jsx)(Qr,{className:de,variant:fe,children:ue})]}),!ce&&(0,J.jsxs)(ji,{className:Z.setupBlock,children:[(0,J.jsx)(U,{children:`Upload Client Secret provided by Google`}),(0,J.jsx)(G,{children:_}),(0,J.jsx)(R,{fluid:!0,type:`file`,onChange:te,accept:`.json`,disabled:se||oe}),(0,J.jsx)(`div`,{className:Z.setupHint,children:`Use the OAuth client JSON downloaded from your Google Cloud project.`})]}),ce&&_&&(0,J.jsx)(ji,{className:Z.setupBlock,children:(0,J.jsx)(G,{children:_})}),(0,J.jsxs)(ji,{className:Z.setupBlock,children:[(0,J.jsx)(U,{children:`Enter ID of sheet to synchronize`}),(0,J.jsx)(G,{children:y}),(0,J.jsx)(R,{fluid:!0,value:o,placeholder:`Sheet ID or Google Sheets URL`,onChange:e=>{b(``),s(cu(e.target.value))},disabled:se||oe}),(0,J.jsx)(`div`,{className:Z.setupHint,children:`Paste a Google Sheets URL or the sheet ID from the URL bar.`})]}),ce?(0,J.jsxs)(ji,{className:Z.setupBlock,children:[(0,J.jsx)(U,{children:`Load the current spreadsheet configuration`}),(0,J.jsx)(V,{wrap:`wrap`,className:Z.setupActions,children:(0,J.jsxs)(M,{onClick:re,disabled:!ae||se,loading:h===`load-sheet`,children:[(0,J.jsx)(Nn,{}),`Load sheet`]})})]}):oe?(0,J.jsxs)(ji,{className:Z.setupBlock,children:[(0,J.jsx)(U,{children:`Copy the device code, then authenticate with Google`}),(0,J.jsxs)(V,{wrap:`wrap`,className:Z.setupActions,children:[le&&(0,J.jsx)(`span`,{children:`Authenticating...`}),(0,J.jsx)(gr,{copyValue:u??``,children:u}),(0,J.jsxs)(M,{onClick:ne,disabled:se,loading:h===`authenticate`,children:[(0,J.jsx)(qn,{}),`Authenticate`]})]}),(0,J.jsx)(`div`,{className:Z.setupHint,children:`Copy the code, then open the browser prompt to complete the flow.`})]}):(0,J.jsxs)(ji,{className:Z.setupBlock,children:[(0,J.jsx)(U,{children:`Generate a Google device code`}),(0,J.jsx)(V,{wrap:`wrap`,className:Z.setupActions,children:(0,J.jsxs)(M,{onClick:A,disabled:!ie||se,loading:h===`connect`,children:[(0,J.jsx)(Bn,{}),`Connect`]})})]})]})}function fu({preview:e,mode:t,disabled:n,loading:r,onApply:i}){let a=o(),s=ae(),c=s?e?.rundown.entries[s]:void 0,l=!(c!==void 0&&y(c)&&h(c)),u=a!==w.Stop&&(t===`new`||l),[d,f]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{f(!1)},[t,e]),(0,J.jsx)(M,{variant:`primary`,onClick:()=>{if(u&&!d){f(!0);return}i()},disabled:n,loading:r,children:u&&d?`Confirm — stop playback & apply import`:`Apply import`})}function pu(e){return e?.trim().toLowerCase()??``}function mu(e,t){let n=new Set,r=[];for(let e of t){let t=pu(e);!t||n.has(t)||(n.add(t),r.push(e.trim()))}let i=new Set;for(let t of e.builtIn){if(!t.enabled)continue;let e=pu(t.header);e&&i.add(e)}for(let{importName:t}of e.custom){let e=pu(t);e&&i.add(e)}return{sampleHeaders:r,assignedHeaders:new Set(r.filter(e=>i.has(pu(e))))}}var hu=[{label:`Flag`,importKey:`flag`,defaultHeader:`flag`},{label:`Start`,importKey:`timeStart`,defaultHeader:`time start`},{label:`Link start`,importKey:`linkStart`,defaultHeader:`link start`},{label:`End`,importKey:`timeEnd`,defaultHeader:`time end`},{label:`Duration`,importKey:`duration`,defaultHeader:`duration`},{label:`Cue`,importKey:`cue`,defaultHeader:`cue`},{label:`Title`,importKey:`title`,defaultHeader:`title`},{label:`Count to end`,importKey:`countToEnd`,defaultHeader:`count to end`},{label:`Skip`,importKey:`skip`,defaultHeader:`skip`},{label:`Note`,importKey:`note`,defaultHeader:`notes`},{label:`Colour`,importKey:`colour`,defaultHeader:`colour`},{label:`End action`,importKey:`endAction`,defaultHeader:`end action`},{label:`Timer type`,importKey:`timerType`,defaultHeader:`timer type`},{label:`Time warning`,importKey:`timeWarning`,defaultHeader:`warning time`},{label:`Time danger`,importKey:`timeDanger`,defaultHeader:`danger time`},{label:`ID`,importKey:`id`,defaultHeader:`id`}];function gu(){return{worksheet:`event schedule`,builtIn:hu.map(e=>({header:e.defaultHeader,enabled:e.defaultHeader.trim().length>0})),custom:[]}}function _u(e){let t=hu.findIndex(e=>e.importKey===`id`),n=e.builtIn[t];return!!(n?.enabled&&n.header.trim())}function vu(e){return e.replace(/[^a-z0-9 ]+/gi,` `).replace(/\s+/g,` `).trim()}function yu(e){return e.map(({importName:e})=>{let t=e.trim();if(!t)return{importName:``,ontimeName:``};let n=vu(t);return n?{importName:t,ontimeName:n}:{importName:t,ontimeName:``}})}function bu(e){let t=[];for(let[n,r]of Object.entries(e))n===`worksheet`||n===`custom`||n===`id`||typeof r==`string`&&r.trim()!==``&&t.push(n);return{event:t,custom:Object.keys(e.custom)}}function xu(e){let t=yu(e.custom).reduce((e,{ontimeName:t,importName:n})=>(t&&n&&(e[t]=n),e),{}),n={worksheet:e.worksheet,custom:t};for(let t=0;t<hu.length;t++){let r=hu[t];n[r.importKey]=e.builtIn[t].enabled?e.builtIn[t].header:``}return n}function Su(e){return pe(`import-map:${e}`)}function Cu(e,t){localStorage.setItem(Su(e),JSON.stringify(t))}function wu(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.worksheet==`string`&&Array.isArray(t.builtIn)&&t.builtIn.length===hu.length&&Array.isArray(t.custom)}function Tu(e){let t=Su(e);try{let e=localStorage.getItem(t);if(!e)return{values:gu(),isPersisted:!1};let n=JSON.parse(e);return wu(n)?{values:n,isPersisted:!0}:(localStorage.removeItem(t),{values:gu(),isPersisted:!1})}catch{return localStorage.removeItem(t),{values:gu(),isPersisted:!1}}}var Eu=`override`;function Du(e){return pe(`import-mode:${e}`)}function Ou(e,t){localStorage.setItem(Du(e),t)}function ku(e){let t=localStorage.getItem(Du(e));return t===`new`||t===`merge`||t===`override`?t:Eu}function Au(e,t){let n=new Set(t.map(pu).filter(Boolean)),r=new Set(hu.map(e=>e.label.toLowerCase())),i=new Set,a=new Set,o={};for(let t=0;t<e.builtIn.length;t++){let r=e.builtIn[t];if(!r.enabled)continue;let a=pu(r.header);if(!a)continue;let s=`builtIn.${t}.header`;i.has(a)?o[s]={kind:`duplicate`}:n.size>0&&!n.has(a)&&(o[s]={kind:`missing`}),i.add(a)}return e.custom.forEach(({importName:e},t)=>{let s=pu(e);if(!s)return;let c=`custom.${t}.importName`,l=vu(e);if(i.has(s))o[c]={kind:`duplicate`};else if(!l)o[c]={kind:`invalid-name`};else if(n.size>0&&!n.has(s))o[c]={kind:`missing`};else{let e=l.toLowerCase();(r.has(e)||a.has(e))&&(o[c]={kind:`name-collision`})}i.add(s),l&&a.add(l.toLowerCase())}),o}var ju=new Map(hu.map(e=>[e.label,e.importKey]));function Mu(e){return e?`Yes`:``}function Nu(e,t){let n=ju.get(e);if(!n)return``;switch(n){case`flag`:return y(t)?Mu(t.flag):``;case`timeStart`:return`timeStart`in t?O(t.timeStart):``;case`linkStart`:return y(t)?Mu(t.linkStart):``;case`timeEnd`:return y(t)?O(t.timeEnd):``;case`duration`:return y(t)?O(t.duration):``;case`cue`:return y(t)||u(t)?t.cue:``;case`title`:return`title`in t?t.title:``;case`countToEnd`:return y(t)?Mu(t.countToEnd):``;case`skip`:return y(t)?Mu(t.skip):``;case`note`:return`note`in t?t.note??``:``;case`colour`:return`colour`in t?t.colour??``:``;case`endAction`:return y(t)?t.endAction:``;case`timerType`:return y(t)?t.timerType:``;case`timeWarning`:return y(t)?O(t.timeWarning):``;case`timeDanger`:return y(t)?O(t.timeDanger):``;case`id`:return t.id;default:return``}}function Pu(e,t,n){let r=n.get(e);return r&&`custom`in t?t.custom?.[r]??``:Nu(e,t)}var Fu={blink:`_blink_uj4mr_1`,fourtyfive:`_fourtyfive_uj4mr_13`,table:`_table_uj4mr_17`,rowNumber:`_rowNumber_uj4mr_62`,rowType:`_rowType_uj4mr_63`,numericCell:`_numericCell_uj4mr_92`,multilineCell:`_multilineCell_uj4mr_97`,eventRow:`_eventRow_uj4mr_104`,groupRow:`_groupRow_uj4mr_108`,milestoneRow:`_milestoneRow_uj4mr_118`},Iu=[`Title`,`Cue`,`Start`,`End`,`Duration`],Lu=new Set([`Start`,`End`,`Duration`,`Time warning`,`Time danger`]),Ru=`transparent`;function zu(e,t){if(c(e))return{rowClassName:Fu.groupRow,entryColour:e.colour,entryType:`Group`};let n=t??Ru;return u(e)?{rowClassName:Fu.milestoneRow,entryColour:n,entryType:`Milestone`}:v(e)?{rowClassName:Fu.eventRow,entryColour:n,entryType:`Delay`}:{rowClassName:Fu.eventRow,entryColour:n,entryType:`Event`}}function Bu(e,t){if(t.includes(`
`))return Fu.multilineCell;if(Lu.has(e))return Fu.numericCell}function Vu(e){return[...e].sort((e,t)=>{let n=Iu.indexOf(e),r=Iu.indexOf(t);return(n===-1?Iu.length:n)-(r===-1?Iu.length:r)})}function Hu({preview:e,columnLabels:t,canRefresh:n,isLoadingMetadata:r,isRefreshing:i,needsPreviewRefresh:a,onRefresh:o,worksheetHeaders:s}){let c=(0,q.useMemo)(()=>e?new Map(Object.entries(e.customFields).map(([e,t])=>[t.label,e])):new Map,[e]),l=(0,q.useMemo)(()=>Vu(t),[t]),u=(0,q.useMemo)(()=>e?si(e.rundown,null):null,[e]);if(!e){let e=`Preview not generated`,t=`Select the fields you want to import, then click Preview import.`;return r?(e=`Loading worksheet`,t=`Loading worksheet metadata...`):s.length===0?(e=`No headers found`,t=`No column headers detected in this worksheet. Try a different worksheet or ensure the first row contains column headers.`):a&&(e=`Preview needs updating`,t=`Your column mapping changed. Preview the import again to update this table.`),(0,J.jsx)(Ei,{title:e,description:t,action:a&&(0,J.jsx)(M,{variant:`primary`,onClick:o,disabled:!n,loading:i,children:`Refresh preview`})})}return(0,J.jsxs)(`table`,{className:Fu.table,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{className:Fu.rowNumber,children:`#`}),(0,J.jsx)(`th`,{className:Fu.rowType,children:`Type`}),l.map((e,t)=>(0,J.jsx)(`th`,{children:e},`${e}-${t}`))]})}),(0,J.jsx)(`tbody`,{children:e.rundown.flatOrder.map(t=>{let n=e.rundown.entries[t],r=y(n),i=u?.[t],{rowClassName:a,entryColour:o,entryType:s}=zu(n,i?.groupColour);return(0,J.jsxs)(`tr`,{className:a,style:{"--entry-colour":o},children:[(0,J.jsx)(`td`,{className:Fu.rowNumber,children:r?i?.eventIndex:``}),(0,J.jsx)(`td`,{className:Fu.rowType,children:(0,J.jsx)(Qr,{children:s})}),l.map((e,r)=>{let i=Pu(e,n,c);return(0,J.jsx)(`td`,{className:Bu(e,i),"data-empty":i===``,title:i||void 0,children:i},`${t}-${r}`)})]},t)})})]})}function Uu(e){let t=e?.parentElement??null;for(;t;){let{overflowY:e}=window.getComputedStyle(t);if(e===`auto`||e===`scroll`||e===`overlay`)return t;t=t.parentElement}return window}var Wu={blink:`_blink_16fk7_1`,fourtyfive:`_fourtyfive_16fk7_13`,positioner:`_positioner_16fk7_17`,popup:`_popup_16fk7_21`,list:`_list_16fk7_36`,item:`_item_16fk7_47`,empty:`_empty_16fk7_48`,itemLabel:`_itemLabel_16fk7_68`};function Gu({className:e,disabled:t,emptyLabel:n,fluid:r,height:i=`medium`,inputRef:a,onValueChange:o,options:s,openOnFocus:c=!1,trailingElement:l,value:u,variant:d=`subtle`,...f}){let p=(0,q.useRef)(null),[m,h]=(0,q.useState)(!1),{onFocus:g,..._}=f;return(0,q.useEffect)(()=>{if(!m)return;let e=Uu(p.current),t=()=>h(!1);return e.addEventListener(`scroll`,t,{passive:!0}),window.addEventListener(`resize`,t,{passive:!0}),()=>{e.removeEventListener(`scroll`,t),window.removeEventListener(`resize`,t)}},[m]),(0,J.jsxs)(ko,{items:s,autoHighlight:!0,highlightItemOnHover:!0,disabled:t,open:m,value:u,onOpenChange:h,onValueChange:o,children:[(0,J.jsx)(Io,{ref:e=>{if(p.current=e,a){if(typeof a==`function`){a(e);return}a.current=e}},onFocus:e=>{g?.(e),c&&h(!0)},className:an([di.input,di[d],di[i],r&&di.fluid,e]),..._}),(0,J.jsx)(Ko,{children:(0,J.jsx)(qo,{side:`bottom`,align:`start`,className:Wu.positioner,children:(0,J.jsx)(Yo,{className:Wu.popup,"data-hide-empty":n?void 0:``,children:(0,J.jsxs)(Bo,{className:Wu.list,children:[(0,J.jsx)(zo,{children:e=>(0,J.jsxs)(ns,{value:e,className:Wu.item,children:[(0,J.jsx)(`span`,{className:Wu.itemLabel,children:e}),l?.(e)]},e)}),n&&(0,J.jsx)(rs,{className:Wu.empty,children:n})]})})})})]})}var Q={blink:`_blink_1bj11_1`,fourtyfive:`_fourtyfive_1bj11_13`,editor:`_editor_1bj11_17`,editorToolbar:`_editorToolbar_1bj11_27`,editorFooter:`_editorFooter_1bj11_35`,worksheetControl:`_worksheetControl_1bj11_39`,worksheetLabel:`_worksheetLabel_1bj11_45`,importModeTrigger:`_importModeTrigger_1bj11_52`,addColumnTrigger:`_addColumnTrigger_1bj11_57`,editorBody:`_editorBody_1bj11_62`,mappingPane:`_mappingPane_1bj11_70`,previewPane:`_previewPane_1bj11_71`,mappingPaneHeader:`_mappingPaneHeader_1bj11_81`,previewPaneHeader:`_previewPaneHeader_1bj11_82`,mappingPaneActions:`_mappingPaneActions_1bj11_97`,mappingPaneTitle:`_mappingPaneTitle_1bj11_104`,previewPaneTitle:`_previewPaneTitle_1bj11_105`,toolbarWarning:`_toolbarWarning_1bj11_111`,mappingList:`_mappingList_1bj11_119`,mappingField:`_mappingField_1bj11_128`,mappingFieldHeader:`_mappingFieldHeader_1bj11_134`,mappingFieldTitle:`_mappingFieldTitle_1bj11_141`,mappingFieldLabel:`_mappingFieldLabel_1bj11_148`,mappingFieldWarning:`_mappingFieldWarning_1bj11_154`,tableShell:`_tableShell_1bj11_160`,columnInput:`_columnInput_1bj11_166`,columnInputWarn:`_columnInputWarn_1bj11_170`};function Ku(e){switch(e.kind){case`duplicate`:return`Column mapped more than once`;case`missing`:return`Column not in current headers, check preview`;case`invalid-name`:return`Column cannot be converted into an Ontime field name`;case`name-collision`:return`Column name resolves to a duplicate Ontime field`;default:return``}}function qu({header:e,value:t,onValueChange:n,warning:r,options:i,assigned:a,disabled:o=!1}){let s=r?Ku(r):void 0;return(0,J.jsxs)(`div`,{className:Q.mappingField,children:[e,s&&(0,J.jsx)(`span`,{className:Q.mappingFieldWarning,children:s}),(0,J.jsx)(Gu,{className:an([Q.columnInput,r&&Q.columnInputWarn]),maxLength:50,options:i,openOnFocus:!0,trailingElement:e=>a.has(e)?(0,J.jsx)(Bn,{}):null,placeholder:`Spreadsheet column`,disabled:o,title:s,value:t,onValueChange:n})]})}function Ju({values:e,setValue:t,warnings:n,sampleHeaders:r,assignedHeaders:i,fields:a,addCustomField:o,removeCustomField:s,isBusy:c}){let l=(0,q.useRef)(null),u=yu(e.custom);return(0,J.jsxs)(`section`,{className:Q.mappingPane,children:[(0,J.jsxs)(V,{align:`apart`,className:Q.mappingPaneHeader,children:[(0,J.jsx)(`span`,{className:Q.mappingPaneTitle,children:`Column mapping`}),(0,J.jsx)(V,{relation:`inner`,className:Q.mappingPaneActions,children:(0,J.jsxs)(M,{className:Q.addColumnTrigger,onClick:()=>{o(),requestAnimationFrame(()=>l.current?.scrollTo({top:l.current.scrollHeight,behavior:`smooth`}))},disabled:c,children:[(0,J.jsx)(I,{}),`Add`]})})]}),(0,J.jsxs)(`div`,{ref:l,className:Q.mappingList,children:[hu.map((a,o)=>(0,J.jsx)(qu,{header:(0,J.jsxs)(`label`,{className:Q.mappingFieldTitle,children:[(0,J.jsx)(ar,{checked:e.builtIn[o]?.enabled!==!1,onCheckedChange:e=>t(`builtIn.${o}.enabled`,e===!0,{shouldDirty:!0,shouldValidate:!0})}),(0,J.jsx)(`span`,{className:Q.mappingFieldLabel,children:a.label})]}),value:e.builtIn[o]?.header??``,onValueChange:e=>t(`builtIn.${o}.header`,e,{shouldDirty:!0,shouldValidate:!0}),warning:e.builtIn[o]?.enabled===!1?void 0:n[`builtIn.${o}.header`],options:r,assigned:i,disabled:e.builtIn[o]?.enabled===!1},a.importKey)),a.map((a,o)=>(0,J.jsx)(qu,{header:(0,J.jsxs)(`div`,{className:Q.mappingFieldHeader,children:[(0,J.jsx)(`span`,{className:Q.mappingFieldLabel,children:u[o]?.ontimeName||e.custom[o]?.importName||`Custom ${o+1}`}),(0,J.jsx)(L,{variant:`ghosted-destructive`,"aria-label":`Delete custom column ${u[o]?.ontimeName||e.custom[o]?.importName||`Custom ${o+1}`}`,onClick:()=>s(o),children:(0,J.jsx)(On,{})})]}),value:e.custom[o]?.importName??``,onValueChange:e=>{t(`custom.${o}.importName`,e,{shouldDirty:!0,shouldValidate:!0}),t(`custom.${o}.ontimeName`,``,{shouldDirty:!0,shouldValidate:!0})},warning:n[`custom.${o}.importName`],options:r,assigned:i},a.id))]})]})}var Yu={loading:``,error:``,preview:null,needsPreviewRefresh:!1};function Xu(e,t){switch(t.type){case`startPreview`:return{...e,loading:`preview`,error:``};case`startApply`:return{...e,loading:`apply`,error:``};case`startExport`:return{...e,loading:`export`,error:``};case`previewSuccess`:return{loading:``,error:``,preview:t.preview,needsPreviewRefresh:!1};case`applySuccess`:case`exportSuccess`:return{...e,loading:``};case`clearPreview`:return{...e,error:t.error??``,preview:null,needsPreviewRefresh:t.needsRefresh??!1};case`failure`:return e.loading===`preview`?{loading:``,error:t.error,preview:null,needsPreviewRefresh:!1}:{...e,loading:``,error:t.error};case`reset`:return Yu;default:return e}}function Zu(e,t,n){return e.includes(t)?t:e.includes(n)?n:e[0]??``}var Qu=[];function $u(e){let t=[];for(let n=0;n<e.builtIn.length;n++)e.builtIn[n].enabled&&t.push(hu[n].label);let n=[];for(let{ontimeName:t}of yu(e.custom))t&&n.push(t);return[...t,...n]}function ed({sourceKey:e,defaultRundownName:t,worksheetNames:n,initialMetadata:r,loadMetadata:i,previewImport:a,onApply:o,onExport:s}){let{initialFormValues:l,skipAutoPreview:f}=(0,q.useMemo)(()=>{let{values:t,isPersisted:i}=Tu(e),a=Zu(n,t.worksheet,r?.worksheet??``),o=t.worksheet!==a;return{initialFormValues:{...t,worksheet:a},skipAutoPreview:i&&o}},[r?.worksheet,e,n]),{control:p,handleSubmit:m,getValues:h,reset:g,setValue:_,watch:v,formState:{isValid:y}}=Pi({mode:`onChange`,defaultValues:l}),{fields:x,append:S,remove:C}=Fi({control:p,name:`custom`}),w=v(),T=Tn();(0,q.useEffect)(()=>{T.removeQueries({queryKey:[`worksheet-metadata`,e]}),r&&T.setQueryData([`worksheet-metadata`,e,r.worksheet],r)},[r,e,T]);let E=Zn({queryKey:[`worksheet-metadata`,e,w.worksheet],queryFn:()=>i(w.worksheet),enabled:!!w.worksheet&&n.includes(w.worksheet),staleTime:1/0}),D=E.data?.headers??Qu,k=E.isLoading,te=E.error?d(E.error):``,{sampleHeaders:A,assignedHeaders:ne}=mu(w,D),re=$u(w),[ie,ae]=(0,q.useReducer)(Xu,Yu),[oe,se]=(0,q.useState)(()=>ku(e)),[ce,le]=(0,q.useState)(t),ue=Au(w,D),de=Object.values(ue).filter(Boolean).length,fe=(0,q.useRef)(null),pe=(0,q.useRef)(!1);(0,q.useEffect)(()=>{pe.current=!1,g(l),ae({type:`reset`})},[l,g]),(0,q.useEffect)(()=>{se(ku(e)),le(t)},[e,t]),(0,q.useEffect)(()=>{n.length!==0&&(n.includes(w.worksheet)||_(`worksheet`,n[0],{shouldDirty:!0,shouldValidate:!0}))},[_,w.worksheet,n]),(0,q.useEffect)(()=>{fe.current=ie.preview},[ie.preview]),(0,q.useEffect)(()=>{let e=v(()=>{fe.current&&(fe.current=null,ae({type:`clearPreview`,needsRefresh:!0}))});return()=>e.unsubscribe()},[v]);let me=(0,q.useRef)(0),he=(0,q.useCallback)(async e=>{let t=xu(e),n=++me.current;try{ae({type:`startPreview`});let e=await a(t);if(me.current!==n)return;ae({type:`previewSuccess`,preview:e})}catch(e){if(me.current!==n)return;ae({type:`failure`,error:d(e)})}},[a]);(0,q.useEffect)(()=>{pe.current||f||!y||D.length===0||(pe.current=!0,m(he)())},[f,y,D,m,he]);let ge=(0,q.useCallback)(async()=>{if(ie.preview)try{ae({type:`startApply`});let t=bu(xu(h()));await o(ie.preview,oe,ce,t),Cu(e,h()),Ou(e,oe),ae({type:`applySuccess`})}catch(e){ae({type:`failure`,error:d(e)})}},[h,oe,ce,o,e,ie.preview]),_e=(0,q.useCallback)(async e=>{if(s)try{ae({type:`startExport`}),await s(xu(e)),ae({type:`exportSuccess`})}catch(e){ae({type:`failure`,error:d(e)})}},[s]),ve=!!ie.loading,ye=y&&!k&&!ve&&n.length>0,be=te||ie.error;return{values:w,setValue:_,fields:x,addCustomField:(0,q.useCallback)(()=>{S({importName:``,ontimeName:``})},[S]),removeCustomField:C,sampleHeaders:A,assignedHeaders:ne,warnings:ue,columnLabels:re,worksheetHeaders:D,state:ie,toolbarStatus:(()=>{if(!ie.preview)return{entries:`–`,groups:`–`,milestones:`–`,start:`–`,end:`–`,duration:`–`,warnings:de};let{entries:e,flatOrder:t}=ie.preview.rundown,{start:n,end:r,duration:i}=ie.preview.summary,a=0,o=0;for(let n of t){let t=e[n];c(t)?a++:u(t)&&o++}return{entries:t.length,groups:a,milestones:o,start:ee(O(n)),end:ee(O(r)),duration:b(i),warnings:de}})(),isLoadingMetadata:k,isBusy:ve,canPreview:ye,displayError:be,importMode:oe,setImportMode:se,newRundownTitle:ce,setNewRundownTitle:le,handlePreviewSubmit:m(he),handleExportSubmit:m(_e),handleApply:ge}}var td=[{value:`override`,label:`Replace current rundown`,description:`Spreadsheet data completely replaces current rundown`},{value:`merge`,label:`Merge with current rundown`,description:`Merge entries referencing their IDs, entries not present in spreadsheet rundown are deleted`},{value:`new`,label:`New rundown`,description:`Create a new rundown to import the data into. Loads the new rundown`}];function nd({sourceKey:e,defaultRundownName:t,worksheetNames:n,initialMetadata:r,loadMetadata:i,previewImport:a,onApply:o,onCancel:s,onExport:c}){let{values:l,setValue:u,fields:d,addCustomField:f,removeCustomField:p,sampleHeaders:m,assignedHeaders:h,warnings:g,columnLabels:_,worksheetHeaders:v,state:y,toolbarStatus:b,isLoadingMetadata:x,isBusy:S,canPreview:C,displayError:w,importMode:T,setImportMode:E,newRundownTitle:D,setNewRundownTitle:O,handlePreviewSubmit:k,handleExportSubmit:ee,handleApply:te}=ed({sourceKey:e,defaultRundownName:t,worksheetNames:n,initialMetadata:r,loadMetadata:i,previewImport:a,onApply:o,onExport:c}),A=td.find(e=>e.value===T)??td[0],ne=(0,q.useMemo)(()=>td.map(e=>({type:`item`,label:e.label,description:e.description,icon:T===e.value?Bn:void 0,onClick:()=>E(e.value)})),[T,E]);return(0,J.jsxs)(B,{as:`form`,id:`spreadsheet-import-workspace`,className:Q.editor,onSubmit:k,children:[(0,J.jsxs)(V,{align:`apart`,wrap:`wrap`,className:Q.editorToolbar,children:[(0,J.jsxs)(`label`,{className:Q.worksheetControl,children:[(0,J.jsx)(`span`,{className:Q.worksheetLabel,children:`Worksheet`}),(0,J.jsx)(Gt,{options:n.map(e=>({value:e,label:e})),value:l.worksheet,onValueChange:e=>u(`worksheet`,e??``,{shouldDirty:!0,shouldValidate:!0})})]}),b&&(0,J.jsxs)(U,{children:[b.entries===`–`?`No import preview yet`:`${b.entries} entries · ${b.groups} groups · ${b.milestones} milestones · ${b.start}–${b.end} · ${b.duration}`,b.warnings>0&&(0,J.jsxs)(`span`,{className:Q.toolbarWarning,children:[` · `,b.warnings,` warnings`]})]})]}),(0,J.jsxs)(`div`,{className:Q.editorBody,children:[(0,J.jsx)(Ju,{values:l,setValue:u,warnings:g,sampleHeaders:m,assignedHeaders:h,fields:d,addCustomField:f,removeCustomField:p,isBusy:S}),(0,J.jsxs)(`section`,{className:Q.previewPane,children:[(0,J.jsx)(`div`,{className:Q.previewPaneHeader,children:(0,J.jsx)(`div`,{className:Q.previewPaneHeading,children:(0,J.jsx)(`span`,{className:Q.previewPaneTitle,children:`Import preview`})})}),(0,J.jsx)(`div`,{className:Q.tableShell,children:(0,J.jsx)(Hu,{preview:y.preview,columnLabels:_,canRefresh:C,isLoadingMetadata:x,isRefreshing:y.loading===`preview`,needsPreviewRefresh:y.needsPreviewRefresh,onRefresh:k,worksheetHeaders:v})})]})]}),w&&(0,J.jsx)(G,{children:w}),T===`merge`&&!_u(l)&&(0,J.jsxs)(U,{tone:`warning`,children:[(0,J.jsx)(Pn,{}),` No ID column mapped — merge matches entries by ID, so it will behave like Replace. Export your rundown to a spreadsheet first to keep its IDs.`]}),(0,J.jsxs)(V,{align:`apart`,wrap:`wrap`,className:Q.editorFooter,children:[(0,J.jsxs)(V,{wrap:`wrap`,children:[(0,J.jsxs)(`label`,{className:Q.worksheetControl,children:[(0,J.jsx)(`span`,{className:Q.worksheetLabel,children:`Import mode`}),(0,J.jsxs)(Nr,{render:(0,J.jsx)(M,{className:Q.importModeTrigger,variant:`subtle-white`}),items:ne,children:[A.label,(0,J.jsx)(jn,{})]})]}),T===`new`&&(0,J.jsxs)(`label`,{className:Q.worksheetControl,children:[(0,J.jsx)(`span`,{className:Q.worksheetLabel,children:`New rundown name`}),(0,J.jsx)(R,{value:D,onChange:e=>O(e.target.value),placeholder:y.preview?.rundown.title||`Imported rundown`,"aria-label":`New rundown name`})]})]}),(0,J.jsxs)(V,{wrap:`wrap`,children:[(0,J.jsx)(M,{onClick:s,disabled:S,children:`Cancel`}),c&&(0,J.jsxs)(M,{onClick:ee,disabled:!C,loading:y.loading===`export`,children:[(0,J.jsx)(Wn,{}),`Export`]}),(0,J.jsxs)(M,{variant:y.preview?void 0:`primary`,onClick:k,disabled:!C,loading:y.loading===`preview`,children:[(0,J.jsx)(zn,{}),`Preview import`]}),(0,J.jsx)(fu,{preview:y.preview,mode:T,disabled:!y.preview||S,loading:y.loading===`apply`,onApply:te})]})]})]})}function rd(){return{applyImport:(0,q.useCallback)(async e=>{await ci(e)},[])}}var id=`https://docs.getontime.no/features/import-spreadsheet-gsheet/`;function ad(){let[e,t]=(0,q.useState)(`none`),[n,r]=(0,q.useState)(``),[i,a]=(0,q.useState)(`none`),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(``),{data:u}=ai(),{applyImport:d}=rd(),f=mt(),p=(0,q.useRef)(null),m=async e=>{let n=e.target.files?.[0];if(!n){s(null),a(`none`);return}try{a(`loading`),r(``),eu(n);let e=await Ll(n);s({kind:`excel`,fileName:n.name,worksheetNames:e.worksheets,initialWorksheetMetadata:e.metadata,closedByUser:!1}),t(`excel`),a(`done`)}catch(e){r(`Error uploading file: ${ni(e)}`),s(null),a(`none`)}},h=()=>{p.current?.click()},g=()=>{t(`none`),a(`none`),s(null),r(``),l(``)},_=()=>{r(``),s(null),t(`gsheet`)},v=()=>{g()},y=()=>{o&&o.kind===`gsheet`?(s({...o,closedByUser:!0}),r(``)):g()},b=e=>{t(`finished`),a(`none`),s(null),r(``),l(e)},x=async(e,t,n,r)=>{if(t===`new`){let t=n.trim()||e.rundown.title;await d({mode:`new`,rundown:{...e.rundown,title:t},customFields:e.customFields}),b(t);return}if(!u)throw Error(`No current rundown loaded`);await d({mode:t,targetRundownId:u.id,rundown:e.rundown,customFields:e.customFields,providedFields:r}),b(u.title)},S=(0,q.useCallback)(e=>{if(!o)throw Error(`No spreadsheet source loaded`);return o.kind===`excel`?zl(e):Zl(o.sheetId,e)},[o]),C=(0,q.useCallback)(e=>{if(!o)throw Error(`No spreadsheet source loaded`);return o.kind===`excel`?Rl(e):Xl(o.sheetId,e)},[o]),w=(0,q.useCallback)(e=>{if(!o||o.kind!==`gsheet`)throw Error(`Google Sheet source not available`);return $l(o.sheetId,e)},[o]),T=(0,q.useCallback)((e,t)=>{s({kind:`gsheet`,sheetId:e,worksheetNames:t.worksheets,initialWorksheetMetadata:t.metadata,title:t.title??``,closedByUser:!1})},[]),E=o?.closedByUser??!1,D=e===`gsheet`,O=e===`none`,k=e===`finished`,ee=o!==null&&!E,te=o?o.kind===`excel`?`Import spreadsheet`:o.title?`Sync: ${o.title}`:`Synchronize with Google Sheet`:``,A=o?o.kind===`excel`?`excel`:`gsheet:${o.sheetId}`:null,ne=o?o.kind===`excel`?nu(o.fileName):o.title:``;return(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[(0,J.jsx)(yi,{children:`Synchronize your rundown with an external source`}),n&&(0,J.jsx)(G,{children:n}),O&&(0,J.jsxs)(`div`,{className:Z.introStack,children:[(0,J.jsxs)(K,{children:[(0,J.jsx)(K.Title,{children:`Choose between a quick file import or a live Google Sheet connection.`}),(0,J.jsx)(K.Body,{children:`Google Sheets sync needs a client secret and a one-time device authentication before you can load a sheet by ID.`}),(0,J.jsx)(K.Footer,{children:(0,J.jsx)(Wa,{href:id,children:`Read setup guide`})})]}),(0,J.jsx)(`input`,{ref:p,style:{display:`none`},type:`file`,onChange:m,accept:`.xlsx`,"data-testid":`file-input`}),(0,J.jsxs)(`div`,{className:Z.sourceGrid,children:[(0,J.jsxs)(`section`,{className:Z.sourceCard,children:[(0,J.jsx)(`div`,{className:Z.sourceHeader,children:(0,J.jsx)(`h4`,{className:Z.sourceTitle,children:`Import spreadsheet`})}),(0,J.jsx)(`p`,{className:Z.sourceDescription,children:`Bring in a one-off spreadsheet, review the mapping, and apply the data to the current rundown.`}),(0,J.jsx)(`div`,{className:Z.sourceMeta,children:"Accepts `.xlsx` files"}),(0,J.jsxs)(M,{variant:`primary`,size:`large`,fluid:!0,onClick:h,loading:i===`loading`,children:[(0,J.jsx)($t,{}),`Import from spreadsheet`]})]}),(0,J.jsxs)(`section`,{className:Z.sourceCard,children:[(0,J.jsx)(`div`,{className:Z.sourceHeader,children:(0,J.jsx)(`h4`,{className:Z.sourceTitle,children:`Synchronize with Google`})}),(0,J.jsx)(`p`,{className:Z.sourceDescription,children:`Connect a Google account once, then load any sheet by ID and keep the import flow inside Ontime.`}),(0,J.jsx)(`div`,{className:Z.sourceMeta,children:`Requires Google OAuth client credentials`}),(0,J.jsxs)(M,{variant:`primary`,size:`large`,fluid:!0,onClick:_,disabled:i!==`none`,children:[(0,J.jsx)(xn,{}),`Synchronize with Google`]})]})]})]}),k&&(0,J.jsxs)(`div`,{className:Z.finishSection,children:[(0,J.jsx)(`span`,{className:Z.finishBadge,children:`Import complete`}),(0,J.jsxs)(`div`,{className:Z.finishTitle,children:[`Spreadsheet data applied to `,c||`your rundown`,`.`]}),(0,J.jsx)(`div`,{className:Z.finishDescription,children:`Review the imported rundown in the editor or start another import.`}),(0,J.jsxs)(`div`,{className:Z.finishActions,children:[(0,J.jsx)(M,{variant:`primary`,onClick:()=>f(`/editor`),children:`Open editor`}),(0,J.jsx)(M,{variant:`subtle-white`,onClick:g,children:`Import another`})]})]}),D&&(0,J.jsx)(du,{onCancel:v,onSheetLoaded:T,closedByUser:E}),(0,J.jsx)(Ii,{isOpen:ee,title:te,showBackdrop:!0,showCloseButton:!0,size:`wide`,onClose:y,bodyElements:(0,J.jsx)(nd,{sourceKey:A??`spreadsheet`,defaultRundownName:ne,worksheetNames:o?.worksheetNames??[],initialMetadata:o?.initialWorksheetMetadata??null,loadMetadata:S,previewImport:C,onApply:x,onCancel:y,onExport:o?.kind===`gsheet`?w:void 0})})]})})}function od({location:e}){let t=Qa(`defaults`,e),n=Qa(`custom`,e),r=Qa(`rundowns`,e),i=Qa(`sheets`,e);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ci,{children:`Project data`}),(0,J.jsx)(`div`,{ref:t,children:(0,J.jsx)(Gl,{})}),(0,J.jsx)(`div`,{ref:n,children:(0,J.jsx)(Fl,{})}),(0,J.jsx)(`div`,{ref:r,children:(0,J.jsx)(Wl,{})}),(0,J.jsx)(`div`,{ref:i,children:(0,J.jsx)(ad,{})})]})}var sd={blink:`_blink_v67sj_1`,fourtyfive:`_fourtyfive_v67sj_13`,section:`_section_v67sj_17`,sectionHeader:`_sectionHeader_v67sj_27`,separator:`_separator_v67sj_33`,textEntry:`_textEntry_v67sj_49`,inlineEntry:`_inlineEntry_v67sj_58`,redirect:`_redirect_v67sj_65`,label:`_label_v67sj_69`,description:`_description_v67sj_75`,origin:`_origin_v67sj_80`};function cd({id:e,isOpen:t,name:n,currentPath:r,origin:i,onClose:a}){let{data:o}=P(),[s,c]=(0,q.useState)(r),[l,u]=(0,q.useState)(`/`),{setRedirect:d}=se,f=t=>{t===`/`||t===r||(t.startsWith(`preset-`)?d({target:e,redirect:t.slice(7)}):d({target:e,redirect:t}),a())},p=o.filter(e=>e.enabled),m=`${window.location.origin}${en}/?settings=sharing__presets`,h=[...le.map(e=>({value:`/${e.url}`,label:e.label})),...p.map(e=>({value:`preset-${e.alias}`,label:`URL Preset: ${e.alias}`}))];return(0,J.jsx)(dr,{isOpen:t,onClose:a,showCloseButton:!0,showBackdrop:!0,title:`Redirect: ${n}`,bodyElements:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(K,{children:[(0,J.jsx)(K.Body,{children:`Remotely redirect the client to a different URL. Choose a custom path or select a URL Preset.`}),(0,J.jsx)(K.Footer,{children:(0,J.jsx)(Wa,{href:m,children:`Manage URL Presets`})})]}),(0,J.jsxs)(`section`,{className:sd.section,children:[(0,J.jsxs)(`div`,{className:sd.sectionHeader,children:[(0,J.jsx)(`span`,{className:sd.label,children:`Enter custom path`}),(0,J.jsx)(`span`,{className:sd.description,children:`Type the path the client should open.`})]}),(0,J.jsxs)(`div`,{className:sd.inlineEntry,children:[(0,J.jsxs)(`label`,{className:sd.textEntry,children:[(0,J.jsx)(`span`,{className:sd.origin,children:i}),(0,J.jsx)(R,{placeholder:`eg. /timer`,fluid:!0,value:s,onChange:e=>c(e.target.value)})]}),(0,J.jsxs)(M,{variant:`primary`,"aria-label":`Redirect to custom path`,disabled:s===r||s===``,className:sd.redirect,onClick:()=>f(s),children:[`Redirect`,(0,J.jsx)(In,{})]})]})]}),(0,J.jsx)(`div`,{className:sd.separator,role:`separator`,children:(0,J.jsx)(`span`,{children:`Or`})}),(0,J.jsxs)(`section`,{className:sd.section,children:[(0,J.jsxs)(`div`,{className:sd.sectionHeader,children:[(0,J.jsx)(`span`,{className:sd.label,children:`Select view or URL Preset`}),(0,J.jsx)(`span`,{className:sd.description,children:`Choose from the available destinations.`})]}),(0,J.jsxs)(`div`,{className:sd.inlineEntry,children:[(0,J.jsxs)(`label`,{className:sd.textEntry,children:[(0,J.jsx)(`span`,{className:sd.origin,children:i}),(0,J.jsx)(Gt,{fluid:!0,options:h,defaultValue:h[0].value,onValueChange:e=>{e!==null&&u(e)},disabled:p.length===0})]}),(0,J.jsxs)(M,{variant:`primary`,"aria-label":`Redirect to preset`,className:sd.redirect,disabled:p.length===0||l===`/`,onClick:()=>f(l),children:[`Redirect `,(0,J.jsx)(In,{})]})]})]})]})})}var ld={blink:`_blink_142rp_1`,fourtyfive:`_fourtyfive_142rp_13`,fullWidth:`_fullWidth_142rp_17`,halfWidth:`_halfWidth_142rp_21`,halfWidthNoWrap:`_halfWidthNoWrap_142rp_25`,copiable:`_copiable_142rp_30`,actionsCell:`_actionsCell_142rp_35`,actionsHeader:`_actionsHeader_142rp_41`,actionsGroup:`_actionsGroup_142rp_45`,current:`_current_142rp_50`};function ud(){let e=A(e=>e.id),t=A(e=>e.clients),[n,r]=br(),[i,a]=br(),{setIdentify:o}=se,[s,c]=(0,q.useState)(``),l=e=>{c(e),a.open()},u=e=>{c(e),r.open()},d=Object.entries(t).filter(([e,{type:t}])=>t===`ontime`),f=Object.entries(t).filter(([e,{type:t}])=>t!==`ontime`),p=t[s];return(0,J.jsxs)(J.Fragment,{children:[n&&p!==void 0&&(0,J.jsx)(cd,{id:s,name:p.name,origin:p.origin,currentPath:p.path,isOpen:n,onClose:r.close}),i&&(0,J.jsx)(fr,{id:s,name:p?.name,isOpen:i,onClose:a.close}),(0,J.jsxs)(B,{children:[(0,J.jsxs)(Ti,{children:[`Ontime Clients (`,d.length,`)`]}),(0,J.jsxs)(vi,{children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{style:{width:`20%`},children:`Client Name`}),(0,J.jsx)(`td`,{children:`Path`}),(0,J.jsx)(`td`,{className:ld.actionsHeader})]})}),(0,J.jsxs)(`tbody`,{children:[d.length===0&&(0,J.jsx)(Si,{title:`No Ontime clients connected`,description:`Editor, cuesheet and operator windows appear here as they connect.`}),d.map(([t,n])=>{let{identify:r,name:i,path:a}=n,s=e===t;return(0,J.jsxs)(`tr`,{className:an([s&&ld.current]),children:[(0,J.jsxs)(V,{relation:`inner`,as:`td`,children:[s&&(0,J.jsx)(Qr,{variant:`active`,children:`SELF`}),i]}),(0,J.jsx)(`td`,{className:ld.copiable,children:a}),(0,J.jsx)(`td`,{className:ld.actionsCell,children:(0,J.jsxs)(V,{relation:`inner`,align:`end`,className:ld.actionsGroup,children:[(0,J.jsx)(M,{size:`small`,className:`${r?ld.blink:``}`,disabled:s,variant:r?`primary`:`subtle`,"data-testid":s?``:`not-self-identify`,onClick:()=>{o({target:t,identify:!r})},children:`Identify`}),(0,J.jsx)(M,{size:`small`,"data-testid":s?``:`not-self-rename`,onClick:()=>l(t),children:`Rename`}),(0,J.jsx)(M,{size:`small`,disabled:s,"data-testid":s?``:`not-self-redirect`,onClick:()=>u(t),children:`Redirect`})]})})]},t)})]})]})]}),(0,J.jsx)(Di,{}),(0,J.jsxs)(B,{children:[(0,J.jsxs)(Ti,{children:[`Other Clients (`,f.length,`)`]}),(0,J.jsxs)(vi,{children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{className:ld.halfWidthNoWrap,children:`Client Name`}),(0,J.jsx)(`td`,{className:ld.halfWidthNoWrap,children:`Client type`})]})}),(0,J.jsxs)(`tbody`,{children:[f.length===0&&(0,J.jsx)(Si,{title:`No other clients connected`,description:`Views and integrations connected to this server are listed here.`}),f.map(([e,t])=>{let{name:n,type:r}=t;return(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:n}),(0,J.jsx)(`td`,{children:r})]},e)})]})]})]})]})}function dd(){return(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[(0,J.jsx)(yi,{children:`Manage clients`}),(0,J.jsx)(Di,{}),(0,J.jsx)(ud,{})]})})}var fd={blink:`_blink_l21m9_1`,fourtyfive:`_fourtyfive_l21m9_13`,iconRotate:`_iconRotate_l21m9_17`};function pd(){return(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[(0,J.jsxs)(yi,{children:[`Event log`,(0,J.jsxs)(M,{onClick:e=>{mr(`log`,e)},children:[`Extract `,(0,J.jsx)(Cn,{className:fd.iconRotate})]})]}),(0,J.jsx)(Di,{}),(0,J.jsx)(Oi,{})]})})}function md({location:e}){let t=Qa(`clients`,e),n=Qa(`log`,e);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ci,{children:`Network`}),!1,(0,J.jsx)(`div`,{ref:n,children:(0,J.jsx)(pd,{})}),(0,J.jsx)(`div`,{ref:t,children:(0,J.jsx)(dd,{})})]})}var hd={project:{title:``},settings:{timeFormat:`24`,language:`en`}};function gd({isOpen:e,onClose:t}){let{defaultWarnTime:n,defaultDangerTime:r,setDangerTime:i,setWarnTime:a}=Gi(),{handleSubmit:o,register:s,formState:{errors:c,isSubmitting:l,isValid:u},watch:f,setError:m,setValue:h}=Pi({defaultValues:hd,values:hd,resetOptions:{keepDirtyValues:!0}}),g=async e=>{try{e.project.title===``&&(e.project.title=`untitled`),await fa(e),await p(),t()}catch(e){m(`root`,{message:d(e)})}},_=qr(n),v=qr(r);return(0,J.jsx)(Ii,{isOpen:e,onClose:t,showBackdrop:!0,showCloseButton:!0,title:`Create new project...`,bodyElements:(0,J.jsxs)(`form`,{onSubmit:o(g),id:`quick-start`,children:[(0,J.jsxs)(ji,{children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Project title`,description:`Shown as the title in some views`}),(0,J.jsx)(R,{maxLength:150,placeholder:`Project title`,fluid:!0,...s(`project.title`)})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Time format`,description:`Default time format to show in views 12 / 24 hours`,error:c.settings?.timeFormat?.message}),(0,J.jsx)(Gt,{value:f(`settings.timeFormat`),onValueChange:e=>{e!==null&&h(`settings.timeFormat`,e,{shouldDirty:!0})},defaultValue:`24`,options:[{value:`12`,label:`12 hours 11:00:10 PM`},{value:`24`,label:`24 hours 23:00:10`}]})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Views language`,description:`Language to be displayed in views`,error:c.settings?.language?.message}),(0,J.jsx)(Gt,{value:f(`settings.language`),onValueChange:e=>{e!==null&&h(`settings.language`,e,{shouldDirty:!0})},defaultValue:`en`,options:[{value:`en`,label:`English`},{value:`fr`,label:`French`},{value:`de`,label:`German`},{value:`it`,label:`Italian`},{value:`pt`,label:`Portuguese`},{value:`es`,label:`Spanish`}]})]})]}),(0,J.jsxs)(ji,{children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Warning time`,description:`Default threshold for warning time in an event`}),(0,J.jsx)(Bi,{name:`warnTime`,submitHandler:(e,t)=>a(t),time:_,placeholder:qi.warnTime})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Danger time`,description:`Default threshold for danger time in an event`}),(0,J.jsx)(Bi,{name:`dangerTime`,submitHandler:(e,t)=>i(t),time:v,placeholder:qi.dangerTime})]})]})]}),footerElements:(0,J.jsxs)(J.Fragment,{children:[c?.root&&(0,J.jsx)(G,{children:c.root.message}),(0,J.jsx)(M,{variant:`ghosted`,onClick:t,disabled:!1,children:`Cancel`}),(0,J.jsx)(M,{variant:`primary`,type:`submit`,form:`quick-start`,disabled:!u,loading:l,children:`Create project`})]})})}var $={blink:`_blink_1qku8_1`,fourtyfive:`_fourtyfive_1qku8_13`,current:`_current_1qku8_17`,isEditing:`_isEditing_1qku8_21`,form:`_form_1qku8_25`,formInput:`_formInput_1qku8_33`,saveButton:`_saveButton_1qku8_37`,containCell:`_containCell_1qku8_41`,sortableHeader:`_sortableHeader_1qku8_45`,fullWidth:`_fullWidth_1qku8_51`,innerColumn:`_innerColumn_1qku8_55`,inlineLabels:`_inlineLabels_1qku8_63`,warningInfo:`_warningInfo_1qku8_68`,loaderBox:`_loaderBox_1qku8_72`,mergeBody:`_mergeBody_1qku8_77`,mergeIntro:`_mergeIntro_1qku8_81`,sourceFile:`_sourceFile_1qku8_87`,mergeSummary:`_mergeSummary_1qku8_95`,mergeWarningInfo:`_mergeWarningInfo_1qku8_101`,optionList:`_optionList_1qku8_105`,optionRow:`_optionRow_1qku8_114`,optionCopy:`_optionCopy_1qku8_124`,optionTitle:`_optionTitle_1qku8_131`,optionBody:`_optionBody_1qku8_138`,footerContent:`_footerContent_1qku8_144`,footerActions:`_footerActions_1qku8_151`};function _d({action:e,filename:t,onSubmit:n,onCancel:r}){let{handleSubmit:i,register:a,formState:{isSubmitting:o,isDirty:s,isValid:c},setFocus:l}=Pi({defaultValues:{filename:t},values:{filename:t},resetOptions:{keepDirtyValues:!0}});return(0,q.useEffect)(()=>{l(`filename`)},[l]),(0,J.jsxs)(`form`,{onSubmit:i(n),onKeyDown:e=>cr(e,r),className:$.form,children:[(0,J.jsx)(R,{className:$.formInput,id:`filename`,placeholder:`Enter new name`,...a(`filename`,{required:!0})}),(0,J.jsxs)(V,{relation:`inner`,children:[(0,J.jsx)(M,{onClick:r,variant:`ghosted`,disabled:o,children:`Cancel`}),(0,J.jsx)(M,{variant:`primary`,disabled:!s||!c||o,type:`submit`,className:$.saveButton,children:e})]})]})}async function vd(e,t){let n={};for(let r in t)i(r,e)&&t[r]&&(r===`rundowns`&&(n.customFields=e.customFields),Object.assign(n,{[r]:e[r]}));return n}var yd=`project-merge-form`;function bd({onClose:e,fileName:t}){let[n,r]=(0,q.useState)(null),i=Tn(),{handleSubmit:a,watch:o,setValue:s,formState:{isSubmitting:c,isValid:l,isDirty:u}}=Pi({defaultValues:{project:!1,rundowns:!1,viewSettings:!1,urlPresets:!1,automation:!1},resetOptions:{keepDirtyValues:!0}});return(0,J.jsx)(Ii,{isOpen:!0,onClose:e,showBackdrop:!0,showCloseButton:!0,size:`compact`,title:`Partial project merge`,bodyElements:(0,J.jsx)(`form`,{id:yd,onSubmit:a(async n=>{if(Object.values(n).every(e=>!e)){r(`At least one option must be selected`);return}try{r(null);let{data:a}=await ua(t);if(!a.settings.version.startsWith(`4.`)){r(`The project you are attempting to merge is from an older version and it need to be migrated first`);return}await da(await vd(a,n)),await i.invalidateQueries({queryKey:Dn}),e()}catch(e){r(d(e))}}),children:(0,J.jsxs)(B,{className:$.mergeBody,children:[(0,J.jsxs)(`div`,{className:$.mergeIntro,children:[(0,J.jsxs)(U,{children:[`Select the sections from `,(0,J.jsx)(`span`,{className:$.sourceFile,children:`"${t}"`}),` that you want to merge into the current project.`]}),(0,J.jsx)(`div`,{className:$.mergeSummary,children:`Only the enabled sections are copied. Existing data stays intact.`})]}),(0,J.jsxs)(K,{type:`warning`,className:$.mergeWarningInfo,children:[(0,J.jsx)(K.Title,{children:`Back up before merging`}),(0,J.jsx)(K.Body,{children:`This action can overwrite project data. Create a duplicate project first if you want a recovery point.`})]}),(0,J.jsxs)(ji,{className:$.optionList,children:[(0,J.jsx)(z,{children:(0,J.jsxs)(`label`,{className:$.optionRow,children:[(0,J.jsxs)(`div`,{className:$.optionCopy,children:[(0,J.jsx)(`span`,{className:$.optionTitle,children:`Project data`}),(0,J.jsx)(`span`,{className:$.optionBody,children:`Core project metadata and settings.`})]}),(0,J.jsx)(ir,{size:`large`,checked:o(`project`),onCheckedChange:e=>s(`project`,e,{shouldDirty:!0})})]})}),(0,J.jsx)(z,{children:(0,J.jsxs)(`label`,{className:$.optionRow,children:[(0,J.jsxs)(`div`,{className:$.optionCopy,children:[(0,J.jsx)(`span`,{className:$.optionTitle,children:`Rundown + Custom Fields`}),(0,J.jsx)(`span`,{className:$.optionBody,children:`Copies all rundowns and any associated custom fields.`})]}),(0,J.jsx)(ir,{size:`large`,checked:o(`rundowns`),onCheckedChange:e=>s(`rundowns`,e,{shouldDirty:!0})})]})}),(0,J.jsx)(z,{children:(0,J.jsxs)(`label`,{className:$.optionRow,children:[(0,J.jsxs)(`div`,{className:$.optionCopy,children:[(0,J.jsx)(`span`,{className:$.optionTitle,children:`View Settings`}),(0,J.jsx)(`span`,{className:$.optionBody,children:`View configuration, and display preferences.`})]}),(0,J.jsx)(ir,{size:`large`,checked:o(`viewSettings`),onCheckedChange:e=>s(`viewSettings`,e,{shouldDirty:!0})})]})}),(0,J.jsx)(z,{children:(0,J.jsxs)(`label`,{className:$.optionRow,children:[(0,J.jsxs)(`div`,{className:$.optionCopy,children:[(0,J.jsx)(`span`,{className:$.optionTitle,children:`URL Presets`}),(0,J.jsx)(`span`,{className:$.optionBody,children:`Saved links and preset launch parameters.`})]}),(0,J.jsx)(ir,{size:`large`,checked:o(`urlPresets`),onCheckedChange:e=>s(`urlPresets`,e,{shouldDirty:!0})})]})}),(0,J.jsx)(z,{children:(0,J.jsxs)(`label`,{className:$.optionRow,children:[(0,J.jsxs)(`div`,{className:$.optionCopy,children:[(0,J.jsx)(`span`,{className:$.optionTitle,children:`Automation Settings`}),(0,J.jsx)(`span`,{className:$.optionBody,children:`Triggers and automation configuration.`})]}),(0,J.jsx)(ir,{size:`large`,checked:o(`automation`),onCheckedChange:e=>s(`automation`,e,{shouldDirty:!0})})]})})]})]})}),footerElements:(0,J.jsxs)(`div`,{className:$.footerContent,children:[n&&(0,J.jsx)(G,{children:n}),(0,J.jsxs)(`div`,{className:$.footerActions,children:[(0,J.jsx)(M,{onClick:e,variant:`ghosted`,disabled:c,children:`Cancel`}),(0,J.jsx)(M,{type:`submit`,form:yd,disabled:!l||!u,loading:c,variant:`primary`,children:`Merge`})]})]})})}function xd({current:e,updatedAt:t,editingFilename:n,editingMode:r,filename:i,onRefetch:a,onSubmit:o,onToggleEditMode:s}){let[c,l]=(0,q.useState)(null),[u,f]=(0,q.useState)(!1),[m,h]=(0,q.useState)(!1),g=e=>async t=>{f(!0),l(null);try{if(!t.filename){l(`Filename cannot be blank`);return}await(e===`rename`?ya:xa)(i,t.filename),await a(),o()}catch(e){l(d(e))}finally{f(!1)}},_=async e=>{f(!0),l(null);try{await Sa(e),await a(),await p()}catch(e){l(d(e))}finally{f(!1)}},v=async e=>{f(!0),l(null);try{await la(e),await a()}catch(e){l(d(e))}finally{f(!1)}},y=async()=>{await v(i),h(!1)},b=(e,t)=>{l(null),s(e,t)},x=()=>{b(null,null)},S=i===n,C=(r===`rename`||r===`duplicate`)&&i===n,w=r===`merge`&&S,T=an([e&&!S&&$.current,S&&$.isEditing]);return(0,J.jsxs)(J.Fragment,{children:[c&&(0,J.jsx)(`tr`,{children:(0,J.jsx)(`td`,{colSpan:99,children:(0,J.jsx)(G,{children:c})})},`filename-error`),(0,J.jsx)(`tr`,{className:T,children:C?(0,J.jsx)(`td`,{colSpan:99,children:(0,J.jsx)(_d,{action:r,filename:i,onSubmit:g(r===`duplicate`?`duplicate`:`rename`),onCancel:x})}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`td`,{className:$.containCell,children:i}),(0,J.jsx)(`td`,{children:e?(0,J.jsx)(Qr,{variant:`active`,children:`Loaded`}):new Date(t).toLocaleString()}),(0,J.jsx)(`td`,{children:(0,J.jsx)(Sd,{current:e,filename:i,onChangeEditMode:b,onDelete:()=>h(!0),onLoad:_,isDisabled:u||w,onMerge:e=>b(`merge`,e)})})]})},i),w&&(0,J.jsx)(bd,{onClose:x,fileName:i}),(0,J.jsx)(dr,{isOpen:m,onClose:()=>h(!1),title:`Delete project`,showBackdrop:!0,showCloseButton:!0,bodyElements:`You will permanently remove this project file. Are you sure?`,footerElements:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(M,{size:`large`,onClick:()=>h(!1),children:`Cancel`}),(0,J.jsx)(M,{variant:`destructive`,size:`large`,onClick:y,loading:u,children:`Delete project`})]})})]})}function Sd(e){let{current:t,filename:n,isDisabled:r,onChangeEditMode:i,onDelete:a,onLoad:o,onMerge:s}=e;return(0,J.jsx)(Nr,{render:(0,J.jsx)(L,{variant:`ghosted-white`}),disabled:r,items:[{type:`item`,icon:$t,label:`Load`,onClick:()=>o(n),disabled:t},{type:`item`,icon:$t,label:`Partial Load`,onClick:()=>s(n),disabled:t},{type:`item`,icon:rn,label:`Rename`,onClick:()=>{i(`rename`,n)}},{type:`item`,icon:tr,label:`Duplicate`,onClick:()=>{i(`duplicate`,n)}},{type:`item`,icon:mn,label:`Download`,onClick:async()=>{await va(n)}},{type:`divider`},{type:`item`,icon:On,label:`Delete`,onClick:a,disabled:t}],children:(0,J.jsx)(tn,{})})}function Cd(){let[e,t]=(0,q.useState)(null),[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(`modified-desc`),{data:o,refetch:s,status:c}=ha(i),l=(e,i)=>{t(t=>t===e&&i===n?null:e),r(i)},u=()=>{t(null),r(null)},d=async()=>{await s()},f=e=>{a(t=>`${e}-${t===`${e}-asc`?`desc`:`asc`}`)};if(c===`pending`)return(0,J.jsx)(`div`,{className:$.loaderBox,children:(0,J.jsx)(_i,{isLoading:!0})});let p=o.reorderedProjectFiles.length;return(0,J.jsxs)(J.Fragment,{children:[p>20&&(0,J.jsxs)(K,{className:$.warningInfo,type:`warning`,children:[`You have `,p,` projects. Consider deleting unused projects to improve performance.`]}),(0,J.jsxs)(vi,{children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{className:$.containCell,onClick:()=>f(`alphabetical`),children:(0,J.jsxs)(`span`,{className:$.sortableHeader,children:[`File Name`,(0,J.jsx)(wd,{sortMode:i,type:`alphabetical`})]})}),(0,J.jsx)(`th`,{onClick:()=>f(`modified`),children:(0,J.jsxs)(`span`,{className:$.sortableHeader,children:[`Last Used`,(0,J.jsx)(wd,{sortMode:i,type:`modified`})]})}),(0,J.jsx)(`th`,{})]})}),(0,J.jsxs)(`tbody`,{children:[p===0&&(0,J.jsx)(Si,{title:`No projects yet`,description:`Projects are the show files Ontime saves your rundown and settings into. Create one to get started.`}),o.reorderedProjectFiles.map(t=>(0,J.jsx)(xd,{filename:t.filename,updatedAt:t.updatedAt,onToggleEditMode:l,onSubmit:u,onRefetch:d,editingFilename:n,editingMode:e,current:t.filename===o.lastLoadedProject},t.filename))]})]})]})}function wd({sortMode:e,type:t}){let n=`${t}-`;return e===`${n}asc`?(0,J.jsx)(Kn,{}):e===`${n}desc`?(0,J.jsx)(Cn,{}):null}function Td(){let{setLocation:e}=Yr(),[t,n]=(0,q.useState)(``),[r,i]=(0,q.useState)(null),a=(0,q.useRef)(null),o=()=>{a.current?.click()};return(0,J.jsxs)(B,{children:[(0,J.jsx)(`input`,{ref:a,style:{display:`none`},type:`file`,onChange:async e=>{let t=e.target?.files?.[0];if(t){i(`import`);try{tu(t),await _a(t)}catch(e){n(`Error uploading file: ${d(e)}`)}finally{await p()}i(null)}},accept:`.json`,"data-testid":`file-input`}),(0,J.jsxs)(H,{children:[(0,J.jsxs)(yi,{children:[`Manage projects`,(0,J.jsxs)(V,{children:[(0,J.jsx)(M,{onClick:o,disabled:!!r,loading:r===`import`,children:`Import`}),(0,J.jsxs)(M,{onClick:()=>e(`project__create`),disabled:!!r,children:[`New `,(0,J.jsx)(I,{})]})]})]}),t&&(0,J.jsx)(G,{children:t}),(0,J.jsx)(Di,{}),(0,J.jsx)(Cd,{})]})]})}function Ed({location:e,setLocation:t}){let n=Qa(`list`,e);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ci,{children:`Project`}),(0,J.jsx)(gd,{isOpen:e===`create`,onClose:()=>{t(`project`)}}),(0,J.jsx)(`div`,{ref:n,children:(0,J.jsx)(Td,{})})]})}var Dd=`${wn}/custom-views`;async function Od(e){return(await bn.get(Dd,{signal:e?.signal,timeout:e?.timeout??xi.shortTimeout})).data}async function kd(e,t,n){let r=new FormData;return r.append(`indexHtml`,t),(await bn.post(`${Dd}/${encodeURIComponent(e)}/upload`,r,{signal:n?.signal,timeout:n?.timeout??xi.longTimeout,headers:{"Content-Type":`multipart/form-data`}})).data}async function Ad(e,t){l((await bn.get(`${Dd}/${encodeURIComponent(e)}/download`,{signal:t?.signal,timeout:t?.timeout??xi.longTimeout,responseType:`blob`})).data,`${e}-index.html`)}async function jd(e){return(await bn.post(`${Dd}/restore-demo`,null,{signal:e?.signal,timeout:e?.timeout??xi.longTimeout})).data}async function Md(e,t){await bn.delete(`${Dd}/${encodeURIComponent(e)}`,{signal:t?.signal,timeout:t?.timeout??xi.longTimeout})}var Nd={views:[]};function Pd(){let{data:e,status:t,refetch:n}=Zn({queryKey:Yn,queryFn:({signal:e})=>Od({signal:e}),placeholderData:(e,t)=>e,refetchInterval:yt});return{data:e??Nd,status:t,refetch:n}}var Fd=`https://docs.getontime.no/features/custom-views/`,Id=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/,Ld=4e6,Rd=`${Ld/1e6}MB`;function zd(e){return e?Id.test(e)?null:`Use lowercase letters, numbers, and dashes only.`:`Name is required.`}function Bd(e){return e?e.name.toLowerCase()===`index.html`?e.size===0?`Uploaded file is empty.`:e.size>Ld?`File size limit (${Rd}) exceeded.`:null:`Only index.html uploads are supported.`:`index.html is required.`}function Vd(e){let t=new URL(sn),n=e?`external/${encodeURIComponent(e)}/`:`external/`;return t.pathname=en?`${en}/${n}`:`/${n}`,t.toString()}var Hd={blink:`_blink_hbyi7_1`,fourtyfive:`_fourtyfive_hbyi7_13`,uploadForm:`_uploadForm_hbyi7_17`,step:`_step_hbyi7_23`,stepTitle:`_stepTitle_hbyi7_29`,filePicker:`_filePicker_hbyi7_34`,fileName:`_fileName_hbyi7_38`,missing:`_missing_hbyi7_43`,urlCell:`_urlCell_hbyi7_47`,actionsHeader:`_actionsHeader_hbyi7_54`,actionsCell:`_actionsCell_hbyi7_58`,actionsGroup:`_actionsGroup_hbyi7_64`},Ud=`custom-view-form`;function Wd({onComplete:e,onClose:t}){let[n,r]=(0,q.useState)(``),[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(!1),[u,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(null),h=(0,q.useRef)(null),g=(0,q.useMemo)(()=>n.trim().toLowerCase(),[n]),_=Vd(g),v=(0,q.useMemo)(()=>zd(g),[g]),y=(0,q.useMemo)(()=>Bd(i),[i]),b=!!(g&&i)&&!v&&!y&&!u;return(0,J.jsx)(Ii,{isOpen:!0,onClose:t,showBackdrop:!0,showCloseButton:!0,size:`compact`,title:`Upload custom view`,bodyElements:(0,J.jsxs)(`form`,{id:Ud,onSubmit:async t=>{if(t.preventDefault(),!(!i||v||y))try{f(!0),m(null),await kd(g,i),e()}catch(e){m(d(e))}finally{f(!1)}},className:Hd.uploadForm,children:[(0,J.jsx)(`input`,{ref:h,style:{display:`none`},type:`file`,onChange:e=>{a(e.target.files?.[0]??null),l(!0),m(null)},accept:`.html,text/html`}),(0,J.jsxs)(`div`,{className:Hd.step,children:[(0,J.jsx)(`div`,{className:Hd.stepTitle,children:`1. Choose a name`}),(0,J.jsx)(U,{children:`Name`}),(0,J.jsx)(R,{value:n,onChange:e=>{r(e.target.value),s(!0)},placeholder:`my-view`,"aria-label":`Custom view name`,autoCapitalize:`off`,autoComplete:`off`,fluid:!0}),(0,J.jsxs)(U,{children:[`Use lowercase letters, numbers, and dashes. Example: `,(0,J.jsx)(ki,{children:`my-view`})]}),(0,J.jsxs)(U,{children:[`Preview URL: `,(0,J.jsx)(ki,{children:_})]}),o&&v&&(0,J.jsx)(G,{children:v})]}),(0,J.jsxs)(`div`,{className:Hd.step,children:[(0,J.jsx)(`div`,{className:Hd.stepTitle,children:`2. Select index.html`}),(0,J.jsx)(U,{children:`Upload file`}),(0,J.jsxs)(V,{wrap:`wrap`,className:Hd.filePicker,children:[(0,J.jsx)(M,{onClick:()=>h.current?.click(),children:i?`Replace index.html`:`Choose index.html`}),(0,J.jsx)(`span`,{className:Hd.fileName,children:i?`${i.name} (${Math.ceil(i.size/1024)} KB)`:`No file selected`})]}),(0,J.jsxs)(U,{children:[`Accepted: index.html only, maximum `,Rd,`.`]}),c&&y&&(0,J.jsx)(G,{children:y})]})]}),footerElements:(0,J.jsxs)(J.Fragment,{children:[p&&(0,J.jsx)(G,{children:p}),(0,J.jsx)(M,{onClick:t,children:`Cancel`}),(0,J.jsxs)(M,{variant:`primary`,type:`submit`,form:Ud,loading:u,disabled:!b,children:[`Upload view `,(0,J.jsx)(Qn,{})]})]})})}function Gd({slug:e,index:t,onDelete:n,onError:r}){let i=()=>{mr(`external/${encodeURIComponent(e)}/`)},a=async()=>{try{await Ad(e)}catch(e){r(d(e))}};return(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:e}),(0,J.jsx)(`td`,{className:Hd.urlCell,children:Vd(e)}),(0,J.jsx)(`td`,{className:Hd.actionsCell,children:(0,J.jsxs)(V,{relation:`inner`,align:`end`,className:Hd.actionsGroup,children:[(0,J.jsx)(L,{variant:`ghosted-white`,onClick:i,"aria-label":`Preview custom view`,"data-testid":`custom-view__preview_${t}`,children:(0,J.jsx)(vn,{})}),(0,J.jsx)(L,{variant:`ghosted-white`,onClick:a,"aria-label":`Download custom view`,"data-testid":`custom-view__download_${t}`,children:(0,J.jsx)($t,{})}),(0,J.jsx)(L,{variant:`ghosted-destructive`,onClick:()=>n(e),"aria-label":`Delete custom view`,"data-testid":`custom-view__delete_${t}`,children:(0,J.jsx)(On,{})})]})})]})}function Kd({views:e,onOpenUpload:t,onMutate:n,onError:r}){let[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(!1),c=e=>{a(e)};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(vi,{children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`Name`}),(0,J.jsx)(`th`,{children:`URL`}),(0,J.jsx)(`th`,{className:Hd.actionsHeader})]})}),(0,J.jsxs)(`tbody`,{children:[e.length===0&&(0,J.jsx)(Si,{title:`No custom views yet`,description:`Upload a self-contained index.html to serve your own view alongside the built-in ones.`,action:(0,J.jsxs)(M,{variant:`primary`,onClick:t,children:[`Upload view `,(0,J.jsx)(Qn,{})]})}),e.map((e,t)=>(0,J.jsx)(Gd,{slug:e.slug,index:t,onDelete:c,onError:r},e.slug))]})]}),(0,J.jsx)(dr,{isOpen:i!==null,onClose:()=>a(null),title:`Delete custom view`,showBackdrop:!0,showCloseButton:!0,bodyElements:`You will permanently delete this file. Are you sure?`,footerElements:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(M,{size:`large`,onClick:()=>a(null),children:`Cancel`}),(0,J.jsx)(M,{variant:`destructive`,size:`large`,onClick:async()=>{if(i)try{s(!0),await Md(i),n()}catch(e){r(d(e))}finally{s(!1),a(null)}},loading:o,children:`Delete custom view`})]})})]})}function qd(){let{data:e,refetch:t,status:n}=Pd(),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(null),s=e.views.some(e=>e.slug===`demo`);return(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[r&&(0,J.jsx)(Wd,{onComplete:async()=>{i(!1),await t()},onClose:()=>i(!1)}),(0,J.jsxs)(yi,{children:[`Custom views`,(0,J.jsxs)(V,{children:[(0,J.jsx)(M,{variant:`ghosted`,onClick:async()=>{try{o(null),await jd(),await t()}catch(e){o(d(e))}},disabled:s,children:`Restore demo`}),(0,J.jsxs)(M,{onClick:()=>i(!0),children:[`New `,(0,J.jsx)(I,{})]})]})]}),(0,J.jsx)(Di,{}),(0,J.jsx)(B,{children:(0,J.jsxs)(K,{children:[(0,J.jsxs)(`span`,{children:[`Upload one `,(0,J.jsx)(`strong`,{children:`index.html`}),` per view to `,(0,J.jsx)(`strong`,{children:`/external/<name>/`}),`.`]}),`External imports are not allowed, include all assets inside the html file.`,(0,J.jsx)(Wa,{href:Fd,children:`See the docs`})]})}),(0,J.jsxs)(B,{children:[(0,J.jsx)(_i,{isLoading:n===`pending`}),a&&(0,J.jsx)(G,{children:a}),(0,J.jsx)(Kd,{views:e.views,onOpenUpload:()=>i(!0),onMutate:()=>t(),onError:o})]})]})})}var Jd={blink:`_blink_cq029_1`,fourtyfive:`_fourtyfive_cq029_13`,container:`_container_cq029_17`};function Yd({register:e,formName:t,disabled:n}){let[r,i]=(0,q.useState)(!1);return(0,J.jsxs)(`div`,{className:Jd.container,children:[(0,J.jsx)(R,{type:r?`text`:`password`,maxLength:4,...e(t,{pattern:{value:zr,message:`Only alphanumeric characters are allowed`}}),placeholder:`-`,disabled:n}),(0,J.jsx)(L,{onMouseDown:()=>i(!0),onMouseUp:()=>i(!1),variant:`ghosted`,"aria-label":`Show pin code`,children:(0,J.jsx)(Ln,{})})]})}var Xd=(0,q.lazy)(()=>lt(()=>import(`./CustomTranslationModal-DB3zaP4N.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29]),import.meta.url));function Zd(){let{data:e,status:t,refetch:n}=ii(),{handleSubmit:r,register:i,reset:a,setError:o,watch:s,setValue:c,formState:{isSubmitting:l,isDirty:u,isValid:f,errors:p}}=Pi({mode:`onChange`,defaultValues:e,resetOptions:{keepDirtyValues:!0}}),[m,h]=br();(0,q.useEffect)(()=>{e&&a(e)},[e,a]);let g=async e=>{try{await ei(e)}catch(e){o(`root`,{message:d(e)})}finally{await n()}},_=t===`pending`,v=l||!u||!f,y=()=>{a(e)},b=t===`pending`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Xd,{isOpen:m,onClose:h.close}),(0,J.jsx)(B,{as:`form`,onSubmit:r(g),onKeyDown:e=>cr(e,y),id:`app-settings`,children:(0,J.jsxs)(H,{children:[(0,J.jsxs)(yi,{children:[`General settings`,(0,J.jsxs)(V,{children:[(0,J.jsx)(M,{disabled:!u||l,variant:`ghosted`,onClick:y,children:`Revert to saved`}),(0,J.jsx)(M,{type:`submit`,form:`app-settings`,name:`general-settings-submit`,loading:l,disabled:v,variant:`primary`,children:`Save`})]})]}),``,(0,J.jsx)(Di,{}),(0,J.jsxs)(B,{children:[(0,J.jsx)(K,{children:`Changes to the views language does not affect the editor view`}),(0,J.jsx)(_i,{isLoading:b}),(0,J.jsxs)(ji,{children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Editor pin code`,description:`Protect the editor view with a pin code`,error:p.editorKey?.message}),(0,J.jsx)(Yd,{register:i,formName:`editorKey`,disabled:_})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Operator pin code`,description:`Protect the operator and cuesheet views with a pin code`,error:p.operatorKey?.message}),(0,J.jsx)(Yd,{register:i,formName:`operatorKey`,disabled:_})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Time format`,description:`Default time format to show in views 12 / 24 hours`,error:p.timeFormat?.message}),(0,J.jsx)(Gt,{value:s(`timeFormat`),onValueChange:e=>{e!==null&&c(`timeFormat`,e,{shouldDirty:!0})},defaultValue:`24`,options:[{value:`12`,label:`12 hours 11:00:10 PM`},{value:`24`,label:`24 hours 23:00:10`}]})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Views language`,description:`Language to be displayed in views`,error:p.language?.message}),(0,J.jsx)(Gt,{value:s(`language`),onValueChange:e=>{e!==null&&c(`language`,e,{shouldDirty:!0})},disabled:_,defaultValue:`en`,options:[{value:`en`,label:`English`},{value:`fr`,label:`French`},{value:`de`,label:`German`},{value:`it`,label:`Italian`},{value:`pt`,label:`Portuguese`},{value:`es`,label:`Spanish`},{value:`custom`,label:`Custom`}]}),(0,J.jsx)(M,{onClick:h.open,children:`Edit custom translation`})]})]})]})]})})]})}function Qd(){let[e,t]=(0,q.useState)(``);(0,q.useEffect)(()=>{sr({baseUrl:sn,path:`mcp`,authenticate:!0,lockConfig:!1,lockNav:!1}).then(t).catch(()=>{t(``)})},[]);let n=e?JSON.stringify({mcpServers:{ontime:{url:e}}},null,2):``;return(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[(0,J.jsx)(yi,{children:`MCP Server`}),(0,J.jsx)(Ai,{children:`Connect any MCP-compatible AI agent to Ontime using the endpoint below.`}),(0,J.jsx)(Di,{}),(0,J.jsxs)(ji,{children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Endpoint URL`,description:`Add this URL to your MCP client settings`}),e&&(0,J.jsx)(gr,{copyValue:e,children:e})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Client configuration snippet`,description:`Paste this into your AI agent settings under "mcpServers"`}),e&&(0,J.jsx)(gr,{copyValue:n,children:n})]})]})]})})}var $d={blink:`_blink_1p5nj_1`,fourtyfive:`_fourtyfive_1p5nj_13`,uploadLogoCard:`_uploadLogoCard_1p5nj_17`,logoActions:`_logoActions_1p5nj_32`,customDataItem:`_customDataItem_1p5nj_37`,titleRow:`_titleRow_1p5nj_44`,customImage:`_customImage_1p5nj_53`,imageContainer:`_imageContainer_1p5nj_59`};function ef(){let{data:e,status:t}=sa(),{updateProjectData:n}=aa(),[r,i]=(0,q.useState)(null),{handleSubmit:a,register:o,reset:s,formState:{isSubmitting:c,isValid:l,isDirty:u,errors:f},setError:p,clearErrors:m,watch:h,control:g,setValue:_}=Pi({defaultValues:e,resetOptions:{keepDirtyValues:!0},mode:`onChange`}),{fields:v,append:y,remove:b}=Fi({control:g,name:`custom`});(0,q.useEffect)(()=>{e&&s(e)},[e,s]),(0,q.useEffect)(()=>()=>{r&&URL.revokeObjectURL(r.previewUrl)},[r]);let x=e=>{let t=e.target.files?.[0];if(m(`logo`),t)try{au(t),i({file:t,previewUrl:URL.createObjectURL(t)})}catch(e){p(`logo`,{message:d(e)})}finally{e.target.value=``}},{ref:S,...C}=o(`logo`),w=(0,q.useRef)(null),T=()=>{w.current?.click()},E=e=>{e.preventDefault(),e.stopPropagation(),i(null),_(`logo`,null,{shouldDirty:!0})},D=()=>{y({title:``,value:``,url:``})},O=async()=>{if(!r)return null;if(r.uploadedFilename)return r.uploadedFilename;let e=(await oa(r.file)).data.logoFilename;return i(t=>t?.file===r.file?{...t,uploadedFilename:e}:t),e},k=async e=>{try{m();let t=await O()??e.logo;await n({...e,logo:t}),i(null)}catch(e){p(`root`,{message:d(e)})}},ee=()=>{i(null),s(e)},te=t===`pending`,A=h(`logo`);return(0,J.jsx)(B,{as:`form`,onSubmit:a(k),onKeyDown:e=>cr(e,ee),children:(0,J.jsxs)(H,{children:[(0,J.jsxs)(yi,{children:[`Project data`,(0,J.jsxs)(V,{children:[(0,J.jsx)(M,{onClick:ee,disabled:c||!u,children:`Revert to saved`}),(0,J.jsx)(M,{variant:`primary`,type:`submit`,disabled:!u&&!r||!l,loading:c,children:`Save`})]})]}),(0,J.jsx)(Di,{}),(0,J.jsxs)(B,{children:[(0,J.jsx)(_i,{isLoading:te}),(0,J.jsxs)(`label`,{children:[`Project title`,(0,J.jsx)(R,{fluid:!0,maxLength:50,placeholder:`Project title is shown in production views`,...o(`title`)})]}),(0,J.jsx)(B,{style:{marginTop:0},children:(0,J.jsxs)(`label`,{children:[`Project logo`,(0,J.jsx)(`input`,{type:`file`,style:{display:`none`},accept:`image/*`,...C,ref:e=>{S(e),w.current=e},onChange:x}),(0,J.jsxs)(H,{className:$d.uploadLogoCard,children:[A||r?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`img`,{src:r?r.previewUrl:`${Qt}/${A}`}),(0,J.jsxs)(`div`,{className:$d.logoActions,children:[(0,J.jsxs)(M,{disabled:c,onClick:T,type:`button`,children:[(0,J.jsx)($t,{}),`Replace logo`]}),(0,J.jsxs)(M,{variant:`subtle-destructive`,disabled:c||!A&&!r,onClick:E,type:`button`,children:[(0,J.jsx)(On,{}),`Delete`]})]})]}):(0,J.jsxs)(M,{disabled:c,onClick:T,type:`button`,children:[(0,J.jsx)($t,{}),`Upload logo`]}),f?.logo?.message&&(0,J.jsx)(G,{children:f.logo.message})]})]})}),(0,J.jsxs)(`label`,{children:[`Project description`,(0,J.jsx)(R,{fluid:!0,maxLength:100,placeholder:`Euro Love, Malmö 2024`,...o(`description`)})]}),(0,J.jsxs)(`label`,{children:[`Project info`,(0,J.jsx)(Ki,{fluid:!0,maxLength:150,placeholder:`Wi-Fi password: 1234`,resize:`vertical`,...o(`info`)})]}),(0,J.jsxs)(`label`,{children:[`Project QR code URL`,(0,J.jsx)(R,{fluid:!0,placeholder:Zt,...o(`url`)})]}),(0,J.jsxs)(B,{style:{marginTop:0},children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Custom data`,description:``}),(0,J.jsxs)(M,{onClick:D,children:[`Add `,(0,J.jsx)(I,{})]})]}),v.length>0&&v.map((e,t)=>{let n=f.custom?.[t];return(0,J.jsxs)(`div`,{className:$d.customDataItem,children:[(0,J.jsxs)(`div`,{className:$d.titleRow,children:[(0,J.jsxs)(`label`,{className:$d.title,children:[`Title`,(0,J.jsx)(R,{fluid:!0,defaultValue:e.title,placeholder:`Title of your custom data`,...o(`custom.${t}.title`,{required:{value:!0,message:`Field cannot be empty`}})})]}),(0,J.jsxs)(M,{variant:`subtle-destructive`,onClick:()=>b(t),children:[(0,J.jsx)(On,{}),`Delete`]})]}),n?.title?.message&&(0,J.jsx)(G,{children:n.title.message}),(0,J.jsxs)(`label`,{children:[`Text`,(0,J.jsx)(Ki,{fluid:!0,rows:3,resize:`vertical`,defaultValue:e.value,placeholder:`Text of your custom data`,...o(`custom.${t}.value`,{required:{value:!0,message:`Field cannot be empty`}})}),n?.value?.message&&(0,J.jsx)(G,{children:n.value.message})]}),(0,J.jsxs)(`label`,{children:[`Image URL (optional)`,(0,J.jsxs)(`div`,{className:$d.customImage,children:[(0,J.jsx)(R,{fluid:!0,defaultValue:e.url,placeholder:`Paste image URL (optional)`,...o(`custom.${t}.url`)}),(0,J.jsx)(`div`,{className:$d.imageContainer,children:h(`custom.${t}.url`)&&(0,J.jsx)(`img`,{src:h(`custom.${t}.url`),alt:``,loading:`lazy`,className:`info__image`})})]})]})]},e.id)})]})]})]})})}var tf={port:4001,pendingRestart:!1};function nf(){let{data:e,status:t,isError:n,refetch:r}=Zn({queryKey:Hn,queryFn:({signal:e})=>ti({signal:e}),placeholderData:e=>e,refetchInterval:yt}),{mutateAsync:i}=rr({mutationFn:async e=>(await ri(e)).data,onMutate:()=>{k.cancelQueries({queryKey:Hn})},onSuccess:e=>{k.setQueryData(Hn,e)}});return{data:e??tf,status:t,isError:n,refetch:r,mutateAsync:i}}function rf(){let{data:e,status:t,isError:n,refetch:r,mutateAsync:i}=nf(),{handleSubmit:a,register:o,reset:s,setError:c,clearErrors:l,formState:{isSubmitting:u,isDirty:f,isValid:p,errors:m}}=Pi({mode:`onChange`,defaultValues:{serverPort:4001}});(0,q.useEffect)(()=>{s({serverPort:e.port})},[e.pendingRestart,e.port,s]);let h=async e=>{if(e.serverPort<1024||e.serverPort>65535){c(`serverPort`,{message:`Port must be within range 1024 - 65535`});return}try{l(`root`),await i(e.serverPort)}catch(e){c(`root`,{message:d(e)})}},g=async()=>{l(`root`);let t=await r();if(t.isError){c(`root`,{message:`Failed to load server port`});return}s({serverPort:t.data?.port??e.port})},_=n?`Failed to load server port`:m.root?.message;return(0,J.jsx)(B,{as:`form`,onSubmit:a(h),onKeyDown:e=>cr(e,g),id:`server-port-settings`,children:(0,J.jsxs)(H,{children:[(0,J.jsxs)(yi,{children:[`Server port`,(0,J.jsxs)(V,{children:[(0,J.jsx)(M,{disabled:!f||u,variant:`ghosted`,onClick:g,children:`Revert to saved`}),(0,J.jsx)(M,{type:`submit`,form:`server-port-settings`,name:`server-port-settings-submit`,loading:u,disabled:!f||!p||u,variant:`primary`,children:`Save`})]})]}),_&&(0,J.jsx)(G,{children:_}),(0,J.jsx)(Di,{}),(0,J.jsxs)(B,{children:[(0,J.jsx)(_i,{isLoading:t===`pending`}),e.pendingRestart&&(0,J.jsx)(K,{type:`warning`,children:`A port change is pending and will happen on the next restart.`}),(0,J.jsx)(ji,{children:(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Ontime server port`,description:`Port ontime server listens in. Defaults to 4001 (needs app restart)`,error:m.serverPort?.message}),(0,J.jsx)(R,{id:`serverPort`,type:`number`,maxLength:5,style:{width:`75px`},...o(`serverPort`,{required:{value:!0,message:`Required field`},max:{value:65535,message:`Port must be within range 1024 - 65535`},min:{value:1024,message:`Port must be within range 1024 - 65535`},pattern:{value:jr,message:`Value should be numeric`}})})]})})]})]})})}var af={blink:`_blink_6wtn0_1`,fourtyfive:`_fourtyfive_6wtn0_13`,editorActions:`_editorActions_6wtn0_17`,right:`_right_6wtn0_21`,column:`_column_6wtn0_26`,editorBody:`_editorBody_6wtn0_33`},of=(0,q.lazy)(()=>lt(()=>import(`./StyleEditor-G-lGCUzh.js`),__vite__mapDeps([30,2,31]),import.meta.url));function sf({isOpen:e,onClose:t}){let[n,r]=(0,q.useState)(``),[i,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(null),m=n.trim()!==i.trim();return(0,q.useEffect)(()=>{let t=!1;async function n(){if(e)try{p(null),s(!0);let e=await hi();if(t)return;r(e),a(e)}catch{if(t)return;r(``),a(``),p(`Failed to load CSS from server`)}finally{t||s(!1)}}return n(),()=>{t=!0}},[e]),(0,J.jsx)(Ii,{title:`Edit CSS override`,size:`wide`,isOpen:e,onClose:t,showCloseButton:!0,showBackdrop:!0,bodyElements:(0,J.jsxs)(`div`,{className:af.editorBody,children:[(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(_i,{isLoading:!0}),children:(0,J.jsx)(of,{value:i,onChange:a})}),(0,J.jsx)(_i,{isLoading:o})]}),footerElements:(0,J.jsxs)(`div`,{className:af.column,children:[(0,J.jsx)(K,{children:`Invalid CSS will be refused by the browser`}),f&&(0,J.jsx)(G,{className:af.right,children:`Error: ${f}`}),(0,J.jsxs)(V,{align:`apart`,className:af.editorActions,children:[(0,J.jsx)(M,{variant:`ghosted`,onClick:async()=>{try{d(!0),a(await pi())}catch{}finally{d(!1)}},disabled:c||u,children:`Reset to example`}),(0,J.jsxs)(V,{children:[(0,J.jsx)(M,{variant:`ghosted`,onClick:()=>a(``),children:`Clear`}),(0,J.jsx)(M,{onClick:t,children:`Cancel`}),(0,J.jsx)(M,{variant:`primary`,onClick:async()=>{try{l(!0),await mi(i),r(i)}catch{}finally{l(!1)}},disabled:c||u||!m,loading:c,children:`Save changes`})]})]})]})})}var cf=`https://docs.getontime.no/features/custom-styling/`;function lf(){let{data:e,status:t,mutateAsync:n}=wi(),[r,i]=br(),{control:a,handleSubmit:o,setError:s,reset:c,setValue:l,watch:u,formState:{isSubmitting:f,isDirty:p,errors:m}}=Pi({defaultValues:e,resetOptions:{keepDirtyValues:!0}});(0,q.useEffect)(()=>{e&&c(e)},[e,c]);let h=async e=>{try{n(e)}catch(e){s(`root`,{message:d(e)})}},g=()=>{c(e)},_=u(`overrideStyles`);return a?(0,J.jsx)(B,{as:`form`,onSubmit:o(h),onKeyDown:e=>cr(e,g),id:`view-settings`,children:(0,J.jsxs)(H,{children:[(0,J.jsxs)(yi,{children:[`View settings`,(0,J.jsxs)(V,{children:[(0,J.jsx)(M,{disabled:!p,variant:`ghosted`,onClick:g,children:`Revert to saved`}),(0,J.jsx)(M,{type:`submit`,loading:f,disabled:!p,variant:`primary`,children:`Save`})]})]}),(0,J.jsx)(Di,{}),(0,J.jsxs)(K,{children:[`You can customise the styles applied to Ontime views by providing overriding CSS rules.`,(0,J.jsx)(`br`,{}),(0,J.jsx)(Wa,{href:cf,children:`See the docs`})]}),(0,J.jsxs)(B,{children:[(0,J.jsx)(_i,{isLoading:t===`pending`}),(0,J.jsx)(G,{children:m.root?.message}),(0,J.jsxs)(ji,{children:[(0,J.jsx)(sf,{isOpen:r,onClose:i.close}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:`Override CSS styles`}),_&&(0,J.jsx)(Qr,{variant:`warning`,children:`ON`})]}),description:_?`CSS override is ON. Ontime views will use the custom override stylesheet.`:`Enables overriding view styles with custom stylesheet`,descriptionTone:_?`warning`:`default`}),(0,J.jsx)(ir,{size:`large`,checked:_,onCheckedChange:e=>l(`overrideStyles`,e,{shouldDirty:!0})}),(0,J.jsx)(M,{onClick:i.open,disabled:f,children:`Edit CSS override`})]})]}),(0,J.jsxs)(ji,{children:[(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Timer colour`,description:`Default colour of a running timer`}),(0,J.jsx)(or,{name:`normalColor`,control:a})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Warning colour`,description:`Colour of a running timer in warning mode`}),(0,J.jsx)(or,{name:`warningColor`,control:a})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(W,{title:`Danger colour`,description:`Colour of a running timer in danger mode`}),(0,J.jsx)(or,{name:`dangerColor`,control:a})]})]})]})]})}):null}function uf({location:e}){let t=Qa(`data`,e),n=Qa(`general`,e),r=Qa(`view`,e),i=Qa(`custom-views`,e),a=Qa(`mcp`,e),o=Qa(`port`,e);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ci,{children:`Settings`}),(0,J.jsx)(`div`,{ref:t,children:(0,J.jsx)(ef,{})}),(0,J.jsx)(`div`,{ref:n,children:(0,J.jsx)(Zd,{})}),(0,J.jsx)(`div`,{ref:r,children:(0,J.jsx)(lf,{})}),(0,J.jsx)(`div`,{ref:i,children:(0,J.jsx)(qd,{})}),(0,J.jsx)(`div`,{ref:a,children:(0,J.jsx)(Qd,{})}),(0,J.jsx)(`div`,{ref:o,children:(0,J.jsx)(rf,{})})]})}function df(){let{isElectron:e,sendToElectron:t}=_r(),[n,r]=br(),i=(0,q.useRef)(null),a=()=>{t(`shutdown`,`now`),r.close()},o=e||fn;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ci,{children:`Shutdown Ontime`}),(0,J.jsx)(B,{children:(0,J.jsxs)(H,{children:[(0,J.jsx)(yi,{children:`Shutdown`}),(0,J.jsx)(Di,{}),nn?(0,J.jsx)(K,{type:`warning`,children:`For security reasons, shutting down the server must be done from the Ontime Cloud dashboard.`}):(0,J.jsx)(W,{title:`Stop the Ontime server`,description:`The runtime state will be lost, but your project is kept for next time.`}),!nn&&(0,J.jsxs)(B,{children:[(0,J.jsx)(M,{variant:`destructive`,onClick:r.open,disabled:!o,children:`Shutdown ontime`}),!o&&(0,J.jsx)(U,{children:`Only available from the machine running Ontime.`})]})]})}),(0,J.jsx)(dr,{isOpen:n,title:`Shutdown Ontime`,showCloseButton:!0,onClose:r.close,bodyElements:(0,J.jsxs)(Ai,{children:[`This will shutdown the Ontime server. `,(0,J.jsx)(`br`,{}),` Are you sure?`]}),footerElements:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(M,{ref:i,onClick:r.close,variant:`ghosted-white`,children:`Cancel`}),(0,J.jsx)(M,{variant:`destructive`,onClick:a,disabled:!o,children:`Shutdown`})]})})]})}var ff={blink:`_blink_1fy3l_1`,fourtyfive:`_fourtyfive_1fy3l_13`,container:`_container_1fy3l_17`};function pf(){let{close:e,panel:t,location:n,setLocation:r}=Yr();return Ta(e,`Escape`),(0,J.jsx)(`div`,{className:ff.container,children:(0,J.jsxs)(fi,{children:[(0,J.jsx)(Ba,{selectedPanel:t,location:n}),(0,J.jsxs)(Da,{onClose:e,children:[t===`settings`&&(0,J.jsx)(uf,{location:n}),t===`project`&&(0,J.jsx)(Ed,{location:n,setLocation:r}),t===`manage`&&(0,J.jsx)(od,{location:n}),t===`automation`&&(0,J.jsx)(Is,{location:n}),t===`sharing`&&(0,J.jsx)(Al,{location:n}),t===`network`&&(0,J.jsx)(md,{location:n}),t===`about`&&(0,J.jsx)(Za,{}),t===`shutdown`&&(0,J.jsx)(df,{})]})]})})}var mf=(0,q.memo)(hf);function hf({children:e}){let{layoutMode:t}=Xr();return(0,J.jsxs)(ma,{navElements:e,children:[t===Jr.PLANNING&&(0,J.jsx)(gf,{}),t===Jr.TRACKING&&(0,J.jsx)(_f,{}),t===Jr.CONTROL&&(0,J.jsx)(vf,{})]})}function gf(){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:pa.inline,children:[(0,J.jsx)(Ca,{}),(0,J.jsx)(Zi,{shouldFormat:!0}),(0,J.jsx)(Yi,{})]}),(0,J.jsx)(ea,{shouldFormat:!0})]})}function _f(){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:pa.inline,children:[(0,J.jsx)($i,{shouldFormat:!0}),(0,J.jsx)(Ji,{}),(0,J.jsx)(Qi,{})]}),(0,J.jsx)(Xi,{}),(0,J.jsx)(ea,{shouldFormat:!0})]})}function vf(){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ca,{}),(0,J.jsxs)(`div`,{className:pa.inline,children:[(0,J.jsx)($i,{shouldFormat:!0}),(0,J.jsx)(Ji,{}),(0,J.jsx)(Qi,{})]}),(0,J.jsx)(Xi,{}),(0,J.jsx)(ea,{shouldFormat:!0})]})}var yf={blink:`_blink_1m3st_1`,fourtyfive:`_fourtyfive_1m3st_13`,container:`_container_1m3st_17`,itemGroup:`_itemGroup_1m3st_27`,goButton:`_goButton_1m3st_34`,iconButtonWithLabel:`_iconButtonWithLabel_1m3st_35`,iconButton:`_iconButton_1m3st_35`,goLabel:`_goLabel_1m3st_55`,shortcutHint:`_shortcutHint_1m3st_61`,addSection:`_addSection_1m3st_66`,separator:`_separator_1m3st_70`,timerSection:`_timerSection_1m3st_77`,negativeIndicator:`_negativeIndicator_1m3st_84`,auxSection:`_auxSection_1m3st_95`,auxControls:`_auxControls_1m3st_103`,auxTimeInput:`_auxTimeInput_1m3st_108`,auxTimeDisplay:`_auxTimeDisplay_1m3st_109`};function bf(){let e=_(),{playback:t,numEvents:n,selectedEventIndex:r}=me(),{playback:i,direction:o}=de(1),s=te(1),[c]=xr({key:`add-time`,defaultValue:3e5}),{disableGo:l,disableNext:u,disableAddTime:d,isPlaying:f,goAction:p,goLabel:m}=Wr({playback:t,numEvents:n,selectedEventIndex:r,timerPhase:e.phase}),h=d||c===0,g=e=>{h||(e===`add`?ce.addTime(c):ce.addTime(-1*c))},v=()=>{i===a.Start?fe.pause(1):fe.start(1)},y=()=>{fe.stop(1)},S=()=>{let e=o===he.CountDown?he.CountUp:he.CountDown;fe.setDirection(1,e)},C=(e,t)=>{let n=qr(t);fe.setDuration(1,n)};Ur([[`Space`,()=>!l&&p(),{preventDefault:!0}],[`N`,()=>!u&&ce.next(),{preventDefault:!0}],[`Escape`,()=>t!==w.Stop&&ce.stop(),{preventDefault:!0}]]);let T=e.phase===x.Pending,E=e.phase===x.Overtime,D=T?e.secondaryTimer:e.current,k=b(c);return(0,J.jsxs)(`div`,{className:yf.container,children:[(0,J.jsxs)(`div`,{className:yf.itemGroup,children:[(0,J.jsxs)(Gr,{onClick:p,disabled:l,theme:w.Play,active:f,className:yf.goButton,children:[(0,J.jsx)(`span`,{className:yf.goLabel,children:m}),(0,J.jsx)(`span`,{className:yf.shortcutHint,children:`[space]`})]}),(0,J.jsxs)(Gr,{onClick:ce.next,disabled:u,className:yf.iconButtonWithLabel,aspect:`square`,children:[(0,J.jsx)(pn,{}),(0,J.jsx)(`span`,{className:yf.shortcutHint,children:`[n]`})]}),(0,J.jsxs)(Gr,{onClick:ce.stop,disabled:t===w.Stop,className:yf.iconButtonWithLabel,aspect:`square`,children:[(0,J.jsx)(En,{}),(0,J.jsx)(`span`,{className:yf.shortcutHint,children:`[esc]`})]}),(0,J.jsxs)(`div`,{className:yf.addSection,children:[(0,J.jsx)(`div`,{className:yf.separator}),(0,J.jsxs)(Gr,{onClick:()=>g(`remove`),disabled:h,className:yf.iconButtonWithLabel,aspect:`square`,children:[(0,J.jsx)(kn,{}),k]}),(0,J.jsxs)(Gr,{onClick:()=>g(`add`),disabled:h,className:yf.iconButtonWithLabel,aspect:`square`,children:[(0,J.jsx)(I,{}),k]})]})]}),(0,J.jsxs)(`div`,{className:yf.timerSection,children:[(0,J.jsx)(`span`,{className:yf.negativeIndicator,"data-active":E,children:`–`}),(0,J.jsx)(Kr,{time:D,phase:e.phase})]}),(0,J.jsxs)(`div`,{className:yf.auxSection,children:[(0,J.jsx)(Gr,{onClick:v,className:yf.iconButton,theme:w.Play,aspect:`square`,children:i===a.Start?(0,J.jsx)(on,{}):(0,J.jsx)(yn,{})}),(0,J.jsx)(Gr,{onClick:y,disabled:i===a.Stop,className:yf.iconButton,theme:w.Stop,aspect:`square`,children:(0,J.jsx)(En,{})}),i===a.Stop?(0,J.jsx)(Bi,{name:`aux1-tracking`,submitHandler:C,time:s,className:yf.auxTimeInput}):(0,J.jsx)(`div`,{className:yf.auxTimeDisplay,children:O(s)}),(0,J.jsx)(Gr,{onClick:S,disabled:i!==a.Stop,className:yf.iconButton,aspect:`square`,children:o===he.CountDown?(0,J.jsx)(Kn,{}):(0,J.jsx)(Cn,{})})]})]})}var xf=5;function Sf(e){let t=e.findIndex(e=>e.isLoaded),n=t===-1?null:e[t],r=n?.eventIndex??0;return{index:t,id:n?.id??null,eventIndex:r,upcomingChipLimit:r>0?r+xf:xf}}var Cf={blink:`_blink_qfgjn_1`,fourtyfive:`_fourtyfive_qfgjn_13`,container:`_container_qfgjn_17`,emptyState:`_emptyState_qfgjn_22`,emptyMessage:`_emptyMessage_qfgjn_30`,emptyTitle:`_emptyTitle_qfgjn_36`,emptyBody:`_emptyBody_qfgjn_43`};function wf(){return(0,J.jsx)(`div`,{className:Cf.container,children:(0,J.jsx)(`div`,{className:Cf.emptyState,children:(0,J.jsxs)(`div`,{className:Cf.emptyMessage,children:[(0,J.jsx)(`h3`,{className:Cf.emptyTitle,children:`No events yet`}),(0,J.jsx)(`p`,{className:Cf.emptyBody,children:`Add events in the rundown to populate this list.`})]})})})}var Tf={blink:`_blink_qs5et_1`,fourtyfive:`_fourtyfive_qs5et_13`,item:`_item_qs5et_17`,title:`_title_qs5et_36`,colourBar:`_colourBar_qs5et_76`,chipSlot:`_chipSlot_qs5et_100`,chipText:`_chipText_qs5et_121`},Ef=(0,q.memo)(Df);function Df({entry:e,currentEventIndex:t,upcomingChipLimit:n,isRunning:r,mode:i,isGroupEnd:a,onSelect:o}){let s=(0,q.useCallback)(()=>{o({id:e.id,index:e.eventIndex-1,parent:e.parent??void 0})},[o,e.id,e.eventIndex,e.parent]),c=t>0&&e.eventIndex>t&&e.eventIndex<=t+2,l=i===ht.Run&&e.isPast,u=e.isLoaded?i===ht.Run?`running`:`selected`:l?`past`:c?`next`:`default`,d=r&&!e.isLoaded&&!e.isPast&&!e.skip,f=d&&e.eventIndex<=n;return(0,J.jsxs)(`li`,{"data-state":u,"data-skipped":e.skip||void 0,"data-group-end":a||void 0,className:Tf.item,onClick:s,children:[(0,J.jsx)(`div`,{className:Tf.colourBar,style:{backgroundColor:e.groupColour||`transparent`}}),(0,J.jsx)(`span`,{className:Tf.title,children:e.title||`Untitled`}),d&&(0,J.jsx)(Of,{timeStart:e.timeStart,delay:e.delay,dayOffset:e.dayOffset,totalGap:e.totalGap,isLinkedToLoaded:e.isLinkedToLoaded,isLoaded:e.isLoaded,showOnHover:!f})]})}var Of=(0,q.memo)(kf);function kf({timeStart:e,delay:t,dayOffset:n,totalGap:r,isLinkedToLoaded:i,isLoaded:a,showOnHover:o}){let c=re({timeStart:e,delay:t,dayOffset:n},{totalGap:r,isLinkedToLoaded:i}),l=!a&&c<1e3,u=`LIVE`;a||(u=l?`DUE`:b(Math.abs(c),c>2*s));let d=a?`live`:l?`due`:`pending`;return(0,J.jsx)(ct,{text:`Expected time until start`,className:Tf.chipSlot,"data-hover-only":o||void 0,children:(0,J.jsx)(`span`,{"data-chip-status":d,className:Tf.chipText,children:u})})}var Af={blink:`_blink_kcrvg_1`,fourtyfive:`_fourtyfive_kcrvg_13`,container:`_container_kcrvg_17`,list:`_list_kcrvg_24`,bottomSpacer:`_bottomSpacer_kcrvg_30`};function jf({mode:e}){let{data:t}=ai(),n=ae(),r=Ar(e=>e.cursor),i=(0,q.useMemo)(()=>e===ht.Run?n:r,[e,n,r]),a=(0,q.useMemo)(()=>oi(t,i).filter(y),[t,i]);return a.length===0?(0,J.jsx)(wf,{}):(0,J.jsx)(Mf,{mode:e,eventData:a,selectedEventId:n,resolvedFollowEventId:i,rundownId:t.id})}function Mf({mode:e,eventData:t,selectedEventId:n,resolvedFollowEventId:r,rundownId:i}){"use memo";let a=(0,q.useRef)(null),o=(0,q.useRef)(null),s=Zr(i),c=(0,q.useMemo)(()=>Sf(t),[t]),l=(0,q.useMemo)(()=>r?t.findIndex(e=>e.id===r):-1,[t,r]),u=(0,q.useCallback)(e=>{s(e)},[s]);(0,q.useEffect)(()=>{if(!a.current)return;let t=l===-1?c.index:l;t!==-1&&(e===ht.Edit&&t<=3||a.current.scrollToIndex({index:t,align:`start`,behavior:`smooth`,offset:-50}))},[c.index,l,e]);let d=(0,q.useCallback)((r,i)=>{let a=t[r+1],o=!!i.parent&&i.parent!==(a?.parent??null);return(0,J.jsx)(Ef,{entry:i,currentEventIndex:c.eventIndex,upcomingChipLimit:c.upcomingChipLimit,isRunning:e===ht.Run&&n!==null,mode:e,onSelect:u,isGroupEnd:o},i.id)},[t,c.eventIndex,c.upcomingChipLimit,e,n,u]);return(0,J.jsx)(ca,{className:Af.container,ref:o,children:(0,J.jsx)(Mr,{ref:a,data:t,computeItemKey:(e,t)=>t.id,itemContent:d,increaseViewportBy:{top:200,bottom:200},customScrollParent:o.current??void 0,components:{List:Nf,Footer:Pf}})})}function Nf({children:e,...t}){return(0,J.jsx)(`ul`,{...t,className:Af.list,children:e})}Nf.displayName=`VirtuosoListComponent`;function Pf(){return(0,J.jsx)(`div`,{className:Af.bottomSpacer})}var Ff={blink:`_blink_1exbp_1`,fourtyfive:`_fourtyfive_1exbp_13`,panelContainer:`_panelContainer_1exbp_17`,panelContainerTracking:`_panelContainerTracking_1exbp_26`,left:`_left_1exbp_31`,rundownLayout:`_rundownLayout_1exbp_40`,rundownPanel:`_rundownPanel_1exbp_48`,titlesPanel:`_titlesPanel_1exbp_55`},If=(0,q.lazy)(()=>lt(()=>import(`./RundownExport-CBb7XL5-.js`),__vite__mapDeps([32,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,33,34,35,25,26,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,27,28,61,62,63,64,65,66,67,68,69,70,71]),import.meta.url)),Lf=(0,q.lazy)(()=>lt(()=>import(`./TimerControlExport-DohR02KP.js`),__vite__mapDeps([72,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,43,55,56,57,59,53,60,65,66,73,74,41,75]),import.meta.url)),Rf=(0,q.lazy)(()=>lt(()=>import(`./MessageControlExport-D2ZmM_Yg.js`),__vite__mapDeps([76,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,55,56,57,65,66,36,37,77]),import.meta.url));function zf(){let{layoutMode:e}=Xr();return e===Jr.CONTROL?(0,J.jsxs)(`div`,{id:`panels`,className:Ff.panelContainer,children:[(0,J.jsxs)(`div`,{className:Ff.left,children:[(0,J.jsx)(Lf,{}),(0,J.jsx)(Rf,{})]}),(0,J.jsx)(If,{})]}):e===Jr.TRACKING?(0,J.jsxs)(`div`,{id:`panels`,className:`${Ff.panelContainer} ${Ff.panelContainerTracking}`,children:[(0,J.jsxs)(`div`,{className:Ff.rundownLayout,children:[(0,J.jsx)(`div`,{className:Ff.titlesPanel,children:(0,J.jsx)(jf,{mode:ht.Run})}),(0,J.jsx)(`div`,{className:Ff.rundownPanel,children:(0,J.jsx)(If,{})})]}),(0,J.jsx)(bf,{})]}):(0,J.jsx)(`div`,{id:`panels`,className:Ff.panelContainer,children:(0,J.jsxs)(`div`,{className:Ff.rundownLayout,children:[(0,J.jsx)(`div`,{className:Ff.titlesPanel,children:(0,J.jsx)(jf,{mode:ht.Edit})}),(0,J.jsx)(`div`,{className:Ff.rundownPanel,children:(0,J.jsx)(If,{})})]})})}var Bf=(0,q.memo)(Vf);function Vf(){let{layoutMode:e,setLayoutMode:t}=Xr(),n=(0,q.useMemo)(()=>[{type:`item`,label:`Planning`,description:`Edit focused list with planning stats`,icon:e===Jr.PLANNING?Bn:void 0,onClick:()=>t(Jr.PLANNING)},{type:`item`,label:`Tracking`,description:`Live timing view with progress and offsets`,icon:e===Jr.TRACKING?Bn:void 0,onClick:()=>t(Jr.TRACKING)},{type:`item`,label:`Control`,description:`All controls and rundown together`,icon:e===Jr.CONTROL?Bn:void 0,onClick:()=>t(Jr.CONTROL)}],[e,t]);return(0,J.jsx)(Nr,{render:(0,J.jsx)(L,{"aria-label":`Layout mode`,variant:`subtle-white`,size:`xlarge`}),items:n,children:(0,J.jsx)(gt,{})})}function Hf({onFinish:e}){let t=(0,q.useRef)(null),n=()=>{t.current?.click()};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{ref:t,style:{display:`none`},type:`file`,onChange:async t=>{let n=t.target?.files?.[0];if(n)try{tu(n),await _a(n)}catch{}finally{await p(),e()}},accept:`.json`,"data-testid":`file-input`}),(0,J.jsx)(M,{onClick:n,children:`Import project`})]})}var Uf={blink:`_blink_1atdi_1`,fourtyfive:`_fourtyfive_1atdi_13`,sections:`_sections_1atdi_17`,column:`_column_1atdi_23`,about:`_about_1atdi_23`,inline:`_inline_1atdi_35`,header:`_header_1atdi_41`,logo:`_logo_1atdi_48`,buttonRow:`_buttonRow_1atdi_53`,tableContainer:`_tableContainer_1atdi_62`,table:`_table_1atdi_62`,current:`_current_1atdi_75`};function Wf(e){let{loadProject:t,onClose:n}=e,{data:r}=ha();return(0,J.jsx)(`tbody`,{children:r.reorderedProjectFiles.map(e=>e.filename===r.lastLoadedProject?(0,J.jsxs)(`tr`,{className:Uf.current,onClick:n,children:[(0,J.jsx)(`td`,{children:e.filename}),(0,J.jsx)(`td`,{children:`Loaded from last session`})]},e.filename):(0,J.jsxs)(`tr`,{onClick:()=>t(e.filename),children:[(0,J.jsx)(`td`,{children:e.filename}),(0,J.jsx)(`td`,{children:new Date(e.updatedAt).toLocaleString()})]},e.filename))})}function Gf({onClose:e}){let t=mt(),n=async t=>{try{await Sa(t),await p(),e()}catch{}},r=async()=>{try{await ga(),await p(),e()}catch{}},i=()=>{t(`/editor?settings=project__create`),e()};return(0,J.jsx)(Ii,{isOpen:!0,onClose:()=>e(),showBackdrop:!0,bodyElements:(0,J.jsxs)(`div`,{className:Uf.sections,children:[(0,J.jsxs)(`div`,{className:Uf.about,children:[(0,J.jsx)(`img`,{src:`ontime-logo.png`,alt:`ontime`,className:Uf.logo}),(0,J.jsxs)(`div`,{children:[`Ontime v`,hn]}),(0,J.jsx)(Wa,{href:_n,children:`Website`}),(0,J.jsx)(Wa,{href:Zt,children:`Read the docs`}),(0,J.jsx)(Wa,{href:Rn,children:`Discord server`})]}),(0,J.jsxs)(`div`,{className:Uf.column,children:[(0,J.jsxs)(`div`,{className:Uf.header,children:[`Welcome to Ontime`,(0,J.jsx)(L,{"aria-label":`close welcome modal`,variant:`subtle-white`,onClick:()=>e(),children:(0,J.jsx)(Vn,{})})]}),(0,J.jsx)(zi,{children:`Select project`}),(0,J.jsx)(`div`,{className:Uf.tableContainer,children:(0,J.jsxs)(`table`,{className:Uf.table,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:`File Name`}),(0,J.jsx)(`th`,{children:`Last Used`})]})}),(0,J.jsx)(Wf,{loadProject:n,onClose:()=>e()})]})})]})]}),footerElements:(0,J.jsxs)(`div`,{className:Uf.column,children:[(0,J.jsxs)(`div`,{className:Uf.buttonRow,children:[(0,J.jsx)(M,{onClick:r,children:`Load demo project`}),(0,J.jsx)(Hf,{onFinish:()=>e()}),(0,J.jsx)(M,{variant:`primary`,onClick:i,children:`Create new...`})]}),(0,J.jsxs)(Ri,{className:Uf.inline,children:[(0,J.jsx)(ar,{defaultChecked:!0,onCheckedChange:e=>$r(e)}),`Show this modal on next startup`]})]})})}function Kf(){let e=C(e=>e.showDialog),t=C(e=>e.clearDialog);return e?(0,J.jsx)(Gf,{onClose:t}):null}var qf={blink:`_blink_1m0yz_1`,fourtyfive:`_fourtyfive_1m0yz_13`,mainContainer:`_mainContainer_1m0yz_17`};function Jf(){let{isOpen:e,setLocation:t,close:n}=Yr(),[r,i]=br();Wi(`Editor`),hr(),(0,q.useEffect)(()=>{window.process?.type===`renderer`&&window.ipcRenderer.on(`user-request-shutdown`,()=>{t(`shutdown`)})},[t]);let a=(0,q.useCallback)(()=>{e?n():t(`settings`)},[n,e,t]);return Ur([[`mod + ,`,a]]),(0,J.jsx)(Ni,{permission:`editor`,children:(0,J.jsxs)(`div`,{className:qf.mainContainer,"data-testid":`event-editor`,children:[(0,J.jsx)(Kf,{}),(0,J.jsx)(yr,{isOpen:r,onClose:i.close}),e?(0,J.jsx)(pf,{}):(0,J.jsx)(zf,{}),(0,J.jsxs)(mf,{children:[(0,J.jsx)(L,{"aria-label":`Toggle navigation`,variant:`subtle-white`,size:`xlarge`,onClick:i.open,children:(0,J.jsx)(Jn,{})}),(0,J.jsx)(L,{"aria-label":`Toggle settings`,variant:`subtle-white`,size:`xlarge`,onClick:a,children:e?(0,J.jsx)(Vn,{}):(0,J.jsx)(Un,{})}),(0,J.jsx)(Bf,{})]})]})})}export{Jf as default};
//# sourceMappingURL=ProtectedEditor-4V77q3HL.js.map