File: //opt/netdata/usr/local/share/netdata/web/v3/1550.79787b4c37d1540e1cb9.chunk.js
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"6866bb78c87eb499c83445c224071f481cf2061d"};var t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5e6be235-7782-4daa-88a0-390b1b6306cd",e._sentryDebugIdIdentifier="sentry-dbid-5e6be235-7782-4daa-88a0-390b1b6306cd")}catch(e){}}(),(globalThis.webpackChunkcloud_frontend=globalThis.webpackChunkcloud_frontend||[]).push([[1550],{14109(e,t,n){n.r(t),n.d(t,{default:()=>Ve});var a=n(96540),o=n(38429),l=n(6304),s=n(41579),i=n(67294),r=n(76667),d=n(32788),c=n(29263),h=n(47410),u=n(16866),p=n(19186),m=n(24609),x=n(5907),g=n(82418),b=n(38757),y=n(882);const f=y.default.img.withConfig({displayName:"styled__Illustration",componentId:"sc-1yhntgl-0"})(["margin:0 auto;"]),j=(0,y.default)(o.Text).withConfig({displayName:"styled__StyledText",componentId:"sc-1yhntgl-1"})(["display:block;"]),w=y.default.div.withConfig({displayName:"styled__TextHeader",componentId:"sc-1yhntgl-2"})(["margin-bottom:",";font-weight:700;"],(0,o.getSizeBy)(2)),C=y.default.div.withConfig({displayName:"styled__StaticCheckmarks",componentId:"sc-1yhntgl-3"})(["margin-top:",";margin-bottom:",";"],(0,o.getSizeBy)(2),(0,o.getSizeBy)(5)),A=y.default.div.withConfig({displayName:"styled__CheckmarkLine",componentId:"sc-1yhntgl-4"})(["display:flex;align-items:center;"]),v=(0,y.default)(o.Icon).withConfig({displayName:"styled__StyledIcon",componentId:"sc-1yhntgl-5"})(["margin-right:4px;height:18px;> use{fill:",";}"],(0,o.getColor)("primary")),T=(0,y.default)(v).withConfig({displayName:"styled__HelpIcon",componentId:"sc-1yhntgl-6"})(["vertical-align:middle;"]),k=y.default.div.withConfig({displayName:"styled__LearnMoreSection",componentId:"sc-1yhntgl-7"})(["margin-top:",";"],(0,o.getSizeBy)(4)),S=y.default.a.withConfig({displayName:"styled__Link",componentId:"sc-1yhntgl-8"})(["text-decoration:underline;color:",";&:visited{color:",";}"],(0,o.getColor)("success"),(0,o.getColor)("success"));var D=n(74848);const I=e=>{let{onClose:t}=e;const n=(0,r.Zp)(),[l,s]=(0,a.useState)(!1),[i,y]=(0,a.useState)(""),{id:I,slug:F}=(0,m.ap)(),L=(0,p.ID)(),M=(0,p.QW)(),B=(0,a.useCallback)(e=>{let{slug:a}=e;t(),n(`/spaces/${F}/rooms/${M}/dashboards/${a}`)},[F,M]),$=(0,x.Dn)(I,L,{onSuccess:B}),E=(0,a.useCallback)(()=>$({name:i}),[i]),N=i.length>0;return(0,D.jsxs)(d.GO,{onClose:t,children:[(0,D.jsx)(c.z,{onClose:t,title:"New Dashboard",children:(0,D.jsx)(o.Button,{label:"Add",icon:"plus",onClick:E,"data-testid":"addNewDashboardModal-add-button"})}),(0,D.jsx)(h.U,{children:"Create new Dashboard"}),(0,D.jsxs)(d.Yv,{children:[(0,D.jsx)(b.A,{value:i,label:"Name",onChange:e=>{y(e.target.value)},isValid:l,setIsValid:s,isDirty:N,instantFeedback:"all",onKeyDown:e=>e.keyCode===u.I7&&l&&E,"data-testid":"addNewDashboardModal-dashboardName-input",containerStyles:{flex:{grow:0,shrink:0},margin:[0,0,4,0]}}),(0,D.jsxs)(j,{children:[(0,D.jsx)(w,{children:"What can you do with Dashboards?"}),"Combine all the metrics that matter to you, from all the nodes that matter to you, into one clean interface that helps you visually detect anomalies as they\u2019re happening. Building a new dashboard will only take a few minutes, and the metrics are always real-time."]}),(0,D.jsxs)(C,{children:[(0,D.jsxs)(A,{children:[(0,D.jsx)(v,{name:"check"}),(0,D.jsx)(o.Text,{children:"Add charts from your infrastructure"})]}),(0,D.jsxs)(A,{children:[(0,D.jsx)(v,{name:"check"}),(0,D.jsx)(o.Text,{children:"Group information in a meaningful way"})]}),(0,D.jsxs)(k,{children:[(0,D.jsx)(T,{name:"help"}),(0,D.jsx)(o.Text,{children:"Learn more about Dashboards"})," ",(0,D.jsx)(S,{href:"https://learn.netdata.cloud/docs/dashboards-and-charts/",target:"_blank",rel:"noopener noreferrer",children:"In our documentation"})]})]}),(0,D.jsx)(f,{src:g.$h})]})]})};var F=n(63474),L=n(63950),M=n.n(L),B=(n(74423),n(98992),n(81454),n(37550),n(82308)),$=n(51262),E=n(39175);const N=e=>{let{handleOpenAddDashboardModal:t,handleOpenImport:n,hasPermissionToAddDashboard:o,hasPermissionToDeleteDashboard:l,refetch:s,duplicateDashboard:d}=e;const c=(0,r.Zp)(),h=(0,p.GJ)(),u=(0,p.XA)("name"),m=(0,x.Ts)(),g=(0,B.Uu)(),b=(0,B.lZ)(),y=(0,i.q)(),f=(0,a.useMemo)(()=>y.some(e=>e===E.LA),[y]),{hasLimitations:j,maxDashboards:w}=(0,$.A)(),C=o&&!(j&&y.length-(f?1:0)>=w),A=async(e,t)=>{const n=(Array.isArray(e)?e:[e]).map(e=>{let{id:t}=e;return t});await m({ids:n},{onSuccess:()=>t.toggleAllRowsSelected(!1)}),s()},v=(0,a.useMemo)(()=>({edit:{confirmation:!1,handleAction:e=>c(e.slug),tooltipText:"Open dashboard"},duplicate:{icon:"copy",handleAction:e=>d(e.id),tooltipText:"Duplicate dashboard",confirmLabel:"Duplicate",confirmationMessage:e=>`A new dashboard named "Copy of ${e.name}" will be created in this room with the same layout and card configuration. Node selections will be reset so you can configure them for the new dashboard.`,confirmationTitle:e=>`Duplicate ${e.name}`,declineLabel:"Cancel",isDisabled:()=>!C,disabledTooltipText:o?`Your plan does not allow you to create more than ${w} dashboards.`:"You don't have permission to create dashboards"},delete:{confirmLabel:"Yes, delete",confirmationMessage:e=>(0,D.jsxs)(D.Fragment,{children:["You are about to delete ",(0,D.jsx)("strong",{children:e.name})," from ",(0,D.jsx)("strong",{children:u}),".",(0,D.jsx)("br",{}),"Are you sure you want to continue?"]}),confirmationTitle:e=>`Delete ${e.name}`,declineLabel:"Cancel",handleAction:A,tooltipText:"Delete dashboard",isDisabled:e=>!l||h&&e.id===E.LA,disabledTooltipText:l?"Local dashboard cannot be deleted":"Only admins can delete"},export:{icon:"download",confirmation:!1,handleAction:e=>g(e.id),tooltipText:"Export dashboard"}}),[l,C,d,w,o,c]),T=(0,a.useMemo)(()=>({addEntry:{handleAction:t,isVisible:o,tooltipText:"Create dashboard",disabledTooltipText:`Your plan does not allow you to create more than ${w} dashboards.`,disabled:j&&y.length-(f?1:0)>=w},delete:{confirmLabel:"Yes, delete",confirmationMessage:(e,t)=>(0,D.jsxs)(D.Fragment,{children:["You are about to delete"," ",(0,D.jsx)("strong",{children:t.length>1?`${t.length} dashboards`:t[0].name})," ","from ",(0,D.jsx)("strong",{children:u}),".",(0,D.jsx)("br",{}),"Are you sure you want to continue?"]}),confirmationTitle:()=>"Delete",disabledTooltipText:"Delete is disabled because you haven't selected dashboards",declineLabel:"Cancel",handleAction:A,tooltipText:"Delete dashboards",isVisible:l},export:{icon:"download",handleAction:e=>b(e.map(e=>e.id)),tooltipText:"Export selected dashboards",confirmation:!1,isVisible:!0},import:{icon:"upload",handleAction:()=>n?.(),tooltipText:"Import dashboard",confirmation:!1,alwaysEnabled:!0,isVisible:!0}}));return{rowActions:l||C?v:[],bulkActions:T}};var _=n(96957),R=n(64587),P=n(45087),V=n(79748);const O=e=>{let{name:t}=e;return(0,D.jsxs)(o.Flex,{width:"300px",column:!0,gap:1,children:[(0,D.jsx)(o.Text,{strong:!0,children:"Locked!"}),(0,D.jsxs)(o.Text,{children:["The dashboard ",(0,D.jsx)(o.Text,{strong:!0,children:t})," is locked."]}),(0,D.jsx)(o.Text,{children:"Your plan is limited to 1 dashboard. You can delete some dashboards or upgrade your plan for no limitations."})]})},U=e=>{let{getValue:t,row:n}=e;const a="notAvailable"==n?.original?.state,l=t();return a?(0,D.jsx)(P.A,{content:(0,D.jsx)(O,{name:l}),align:"bottom",isBasic:!0,children:(0,D.jsxs)(o.Flex,{alignItems:"center",children:[(0,D.jsx)(o.Text,{children:l}),(0,D.jsx)(o.Icon,{name:"padlock",height:"12px",color:"text"})]})}):(0,D.jsx)(V.A,{as:"Link",to:n.original.slug,children:l})},Y=e=>{let{getValue:t}=e;const{localeDateString:n}=(0,R.$j)(),a=t();return a?(0,D.jsx)(o.TextSmall,{whiteSpace:"nowrap",children:n(new Date(a))}):(0,D.jsx)(o.TextSmall,{children:"-"})};var z=n(99728),K=n(57738);const G=e=>{let{refetch:t,handleOpenAddDashboardModal:n,handleOpenImport:o}=e;const[,l]=(0,a.useState)(),s=(0,i.q)(),r=(0,_.Sf)(s),{localeDateString:d}=(0,R.$j)(),c=(0,z.JT)("dashboard:Create"),h=(0,z.JT)("dashboard:Delete"),u=(0,K.L)(),p=(0,a.useMemo)(()=>[{id:"name",accessorKey:"name",header:"Name",cell:U},{id:"updatedAt",accessorKey:"updatedAt",header:"Last modified",cell:Y,sortingFn:"datetime"},{id:"createdAt",accessorKey:"createdAt",header:"Created",cell:Y,sortingFn:"datetime"}],[]),{rowActions:m,bulkActions:x}=N({dashboards:r,handleOpenAddDashboardModal:n,handleOpenImport:o,hasPermissionToAddDashboard:c,hasPermissionToDeleteDashboard:h,refetch:t,duplicateDashboard:u});return{rowActions:m,bulkActions:x,data:r,enableSelection:h,columns:p,enableSorting:!0,globalFilterFn:(0,a.useCallback)((e,t,n)=>{const a=n?.toLowerCase?.()||"",o=e.getValue("name")?.toLowerCase?.()||"",l=d(new Date(e.getValue("updatedAt"))).toLowerCase(),s=d(new Date(e.getValue("createdAt"))).toLowerCase();return o.includes(a)||l.includes(a)||s.includes(a)},[d]),setGlobalFilter:l}};var H=n(63872),q=n(72402),Z=n(93337);const W=()=>{const e=(0,a.useRef)(null),[t,n]=(0,a.useState)(null),[,o]=(0,H.A)(),l=(0,r.Zp)(),s=(0,m.bq)(),i=(0,p.QW)(),d=(0,B.NV)(),c=(0,a.useCallback)(async e=>{const t=e.target.files?.[0];if(e.target.value="",!t)return;const a=await t.text(),l=(0,q.DK)(a);if(!l.ok)return void o({header:"Import",text:l.error});const s=(0,q.L8)(l.value);s.ok?n(l.value):o({header:"Import",text:`Invalid dashboard file: ${s.error}`})},[o]),h=(0,a.useCallback)(()=>e.current?.click(),[]),u=(0,a.useCallback)(()=>n(null),[]),x=(0,a.useCallback)(async e=>{n(null);const t=await d(e);t?.ok&&t.dashboard?.slug&&l(`/spaces/${s}/rooms/${i}/dashboards/${t.dashboard.slug}`)},[d,l,s,i]);return{openImport:h,importUi:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("input",{ref:e,type:"file",accept:".json,application/json",style:{display:"none"},onChange:c,"data-testid":"importDashboardFileInput"}),t&&(0,D.jsx)(Z.A,{payload:t,mode:"new",onConfirm:x,onClose:u})]})}},J=[{id:"updatedAt",desc:!0}],Q=e=>{let{refetch:t=M(),handleOpenAddDashboardModal:n}=e;const{openImport:a,importUi:l}=W(),{enableSelection:s,columns:i,data:r,rowActions:d,bulkActions:c,enableSorting:h,globalFilterFn:u,setGlobalFilter:p}=G({refetch:t,handleOpenAddDashboardModal:n,handleOpenImport:a});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(o.Table,{rowActions:d,enableSelection:s,data:r,dataColumns:i,bulkActions:c,enableSorting:h,globalFilterFn:u,onSearch:p,testPrefixCallback:e=>e.name,sortBy:J,title:"Dashboards"}),l]})};var X=n(60908),ee=n(1011),te=n(63928),ne=n(591),ae=n(54148);const oe=function(){let{onSuccess:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=(0,te.yK)({onSuccess:e});return(0,a.useCallback)(function(){let{name:e,entries:n=[],transition:a=ae.Ez,loop:o=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const l=Date.now();return t({type:ae.Zg,scope:ae.CA,entity:ae.w0,name:e||"Untitled playlist",path:ae.Bb,value:{entries:n,transition:a,loop:o,createdAt:l,updatedAt:l}})},[t])};n(54520),n(25509),n(65223),n(60321),n(41927),n(11632),n(64377),n(66771),n(12516),n(68931),n(52514),n(35694),n(52774),n(49536),n(21926),n(94483),n(16215);const le=e=>{let{addedDashboardIds:t,onAdd:n}=e;const[l,s]=(0,a.useState)(""),r=(0,i.q)(),d=(0,_.Sf)(r),{localeDateString:c}=(0,R.$j)(),h=(0,a.useMemo)(()=>new Set(t),[t]),u=d.filter(e=>e?.name?.toLowerCase().includes(l.toLowerCase()));return(0,D.jsxs)(o.Flex,{column:!0,gap:2,flex:"1",padding:[2],height:"100%",overflow:"hidden",children:[(0,D.jsx)(o.TextInput,{placeholder:"Search dashboards\u2026",value:l,onChange:e=>s(e.target.value)}),(0,D.jsx)(o.Flex,{column:!0,flex:"1",overflow:{vertical:"auto"},children:u.map(e=>{const t=h.has(e.id);return(0,D.jsxs)(o.Flex,{padding:[1.25,2],cursor:t?"not-allowed":"pointer",opacity:t?.5:1,onClick:()=>!t&&n(e.id),gap:2,alignItems:"center",justifyContent:"between",_hover:t?void 0:{background:"secondaryHighlight"},children:[(0,D.jsxs)(o.Flex,{column:!0,gap:.5,children:[(0,D.jsx)(o.Text,{children:e.name}),e.updatedAt&&(0,D.jsxs)(o.TextSmall,{color:"textLite",children:["Modified ",c(new Date(e.updatedAt))]})]}),t&&(0,D.jsx)(o.TextSmall,{color:"textLite",children:"Added"})]},e.id)})})]})};n(72577);var se=n(43375),ie=n(43627),re=n(74979),de=n(80221);const ce=e=>{let{entry:t,index:n,isOnly:a,isEditing:l,onEdit:s,onRemove:i}=e;const r=(0,_.fz)(t.dashboardId),{attributes:d,listeners:c,setNodeRef:h,transform:u,transition:p}=(0,ie.gl)({id:t.id}),m={transform:re.Ks.Transform.toString(u),transition:p};return(0,D.jsx)("div",{ref:h,style:m,...d,children:(0,D.jsxs)(o.Flex,{gap:3,padding:[2,3],alignItems:"center",justifyContent:"between",background:l?"secondaryHighlight":"elementBackground",border:{side:"all",color:l?"primary":"border"},round:!0,cursor:"pointer",onClick:s,_hover:{background:"secondaryHighlight"},children:[(0,D.jsxs)(o.Flex,{gap:2,alignItems:"center",flex:"1",overflow:"hidden",children:[!a&&(0,D.jsx)(o.Icon,{name:"nav_dots",color:"textLite",cursor:"grab",size:"small",...c,onClick:e=>e.stopPropagation()}),(0,D.jsx)(o.TextSmall,{color:"textLite",children:n+1}),(0,D.jsx)(o.Text,{truncate:!0,children:r?.name||t.dashboardId})]}),(0,D.jsxs)(o.Flex,{gap:2,alignItems:"center",children:[(0,D.jsxs)(o.Pill,{flavour:"neutral",size:"small",children:[Math.round(t.durationMs/1e3),"s"]}),(0,D.jsx)(o.Pill,{flavour:"neutral",size:"small",children:t.mode}),(0,D.jsx)(o.Pill,{flavour:"neutral",size:"small",children:(0,de.j)(t.timeRange)})]}),!a&&(0,D.jsx)(o.IconButton,{icon:"x",flavour:"borderless",tooltip:"Remove",onClick:e=>{e.stopPropagation(),i()}})]})})};const he=n(71336).AE.map(e=>({label:e.period,value:{after:1e3*e.value,before:0}})),ue=e=>{let{entry:t,onChange:n,onClose:l}=e;const s=(0,_.fz)(t.dashboardId),i=e=>n({...t,...e}),[r,d]=(0,a.useState)(()=>String(Math.round(t.durationMs/1e3)));(0,a.useEffect)(()=>{d(String(Math.round(t.durationMs/1e3)))},[t.id]);return(0,D.jsxs)(o.Flex,{column:!0,gap:3,padding:[3],background:"elementBackground",border:{side:"all",color:"primary"},round:!0,width:{max:"640px"},children:[(0,D.jsx)(o.TextBig,{strong:!0,children:s?.name||t.dashboardId}),(0,D.jsx)(o.TextInput,{label:"Duration (seconds)",type:"number",min:1,value:r,onChange:e=>{const t=e.target.value;if(d(t),""===t)return;const n=Number(t);!Number.isFinite(n)||n<1||i({durationMs:1e3*n})},onBlur:()=>{const e=Number(r);(!Number.isFinite(e)||e<1)&&d(String(Math.round(t.durationMs/1e3)))}}),(0,D.jsxs)(o.Flex,{column:!0,gap:1,children:[(0,D.jsx)(o.Text,{strong:!0,children:"Playback"}),(0,D.jsx)(o.Flex,{gap:1,children:["static","scroll"].map(e=>(0,D.jsx)(o.Button,{flavour:t.mode===e?"default":"hollow",onClick:()=>i({mode:e}),children:"static"===e?"Static":"Scroll"},e))})]}),(0,D.jsxs)(o.Flex,{column:!0,gap:1,children:[(0,D.jsx)(o.Text,{strong:!0,children:"Time range"}),(0,D.jsx)(o.Flex,{gap:1,flexWrap:!0,width:"100%",children:he.map(e=>{return(0,D.jsx)(o.Button,{flavour:(n=t.timeRange,a=e.value,n&&a&&n.after===a.after&&n.before===a.before?"default":"hollow"),margin:[0,0,1,0],onClick:()=>i({timeRange:e.value}),children:e.label},e.label);var n,a})})]}),(0,D.jsx)(o.Box,{children:(0,D.jsx)(o.Button,{onClick:l,children:"Done"})})]})},pe=e=>{let{draft:t,onChange:n}=e;const[l,s]=(0,a.useState)(null),i=(0,se.FR)((0,se.MS)(se.AN),(0,se.MS)(se.uN,{coordinateGetter:ie.JR})),r=(0,a.useCallback)(e=>{const{active:a,over:o}=e;if(a?.id&&o?.id&&a.id!==o.id){const e=t.entries.map(e=>e.id),l=e.indexOf(a.id),s=e.indexOf(o.id);n({...t,entries:(0,ie.be)(t.entries,l,s)})}},[t,n]),d=t.entries.find(e=>e.id===l);return(0,D.jsxs)(o.Flex,{column:!0,gap:3,flex:"1",padding:[2],height:"100%",overflow:"hidden",children:[(0,D.jsx)(o.TextInput,{value:t.name,onChange:e=>n({...t,name:e.target.value}),placeholder:"Playlist name"}),(0,D.jsxs)(o.Flex,{gap:2,alignItems:"center",children:[(0,D.jsx)(o.Text,{children:"Transition:"}),ae.iH.map(e=>(0,D.jsx)(o.Button,{flavour:t.transition===e?"default":"hollow",onClick:()=>n({...t,transition:e}),children:e},e))]}),(0,D.jsx)(o.Flex,{gap:2,alignItems:"center",children:(0,D.jsx)(o.Checkbox,{checked:t.loop,onChange:e=>n({...t,loop:e}),label:"Loop"})}),(0,D.jsxs)(o.Flex,{column:!0,flex:"1",overflow:{vertical:"auto"},gap:2,children:[(0,D.jsx)(se.Mp,{sensors:i,collisionDetection:se.fp,onDragEnd:r,children:(0,D.jsx)(ie.gB,{items:t.entries.map(e=>e.id),strategy:ie._G,children:(0,D.jsx)(o.Flex,{column:!0,gap:1,children:t.entries.map((e,a)=>(0,D.jsx)(ce,{entry:e,index:a,isOnly:1===t.entries.length,isEditing:e.id===l,onEdit:()=>s(e.id),onRemove:()=>{return a=e.id,n({...t,entries:t.entries.filter(e=>e.id!==a)});var a}},e.id))})})}),d&&(0,D.jsx)(ue,{entry:d,onChange:e=>n({...t,entries:t.entries.map(t=>t.id===e.id?e:t)}),onClose:()=>s(null)})]})]})},me=e=>e?{name:e.name,transition:e.transition,loop:e.loop,entries:e.entries}:{name:"",transition:ae.Ez,loop:!0,entries:[]},xe=e=>{let{mode:t,playlist:n,onSave:l,onClose:s}=e;const[i,r]=(0,a.useState)(()=>me(n)),[d,c]=(0,a.useState)(!1),h=(0,a.useCallback)(e=>{r(t=>({...t,entries:[...t.entries,{id:(0,ee.A)(),dashboardId:e,durationMs:ae.lR,mode:ae.hO,timeRange:ae.sV}]}))},[]),u=i.name.trim()&&i.entries.length>0&&!d;return(0,D.jsx)(o.Modal,{backdropProps:{backdropBlur:!0},onClickOutside:s,onEsc:s,children:(0,D.jsxs)(o.ModalContent,{width:"1000px",height:"80vh",children:[(0,D.jsxs)(o.ModalHeader,{children:["create"===t?"New playlist":`Edit playlist: ${n?.name??""}`,(0,D.jsx)(o.ModalCloseButton,{onClose:s})]}),(0,D.jsx)(o.ModalBody,{height:"100%",overflow:"hidden",children:(0,D.jsxs)(o.Flex,{gap:3,width:"100%",height:"100%",overflow:"hidden",children:[(0,D.jsx)(o.Flex,{width:{base:"40%"},height:"100%",overflow:"hidden",children:(0,D.jsx)(le,{addedDashboardIds:i.entries.map(e=>e.dashboardId),onAdd:h})}),(0,D.jsx)(o.Flex,{width:{base:"60%"},height:"100%",overflow:"hidden",children:(0,D.jsx)(pe,{draft:i,onChange:r})})]})}),(0,D.jsxs)(o.ModalFooter,{gap:2,children:[(0,D.jsx)(o.Button,{flavour:"hollow",onClick:s,children:"Cancel"}),(0,D.jsx)(o.Button,{onClick:async()=>{c(!0);try{await l(i),s()}finally{c(!1)}},disabled:!u,children:d?"Saving\u2026":"Save"})]})]})})};var ge=n(67916),be=n(12273),ye=n(81214);const fe=e=>{let{playlistId:t,spaceId:n,roomId:l,onClose:s}=e;const[i,r]=(0,a.useState)(!1),[d,c]=(0,a.useState)(null),[h,u]=(0,a.useState)(!1);return(0,D.jsx)(o.Modal,{backdropProps:{backdropBlur:!0},onClickOutside:s,onEsc:s,children:(0,D.jsxs)(o.ModalContent,{width:"600px",children:[(0,D.jsxs)(o.ModalHeader,{children:["Playlist TV URL",(0,D.jsx)(o.ModalCloseButton,{onClose:s})]}),(0,D.jsx)(o.ModalBody,{column:!0,gap:4,children:d?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(be.FU,{children:d}),(0,D.jsx)(o.Flex,{alignItems:"center",background:"warningBackground",gap:4,padding:[3,3],round:!0,children:(0,D.jsx)(o.Text,{color:"warning",children:"This URL contains a unique access token. Share only with trusted users."})})]}):(0,D.jsx)(o.Text,{children:"Create a shareable TV-mode URL for this playlist. A new access token will be created automatically."})}),(0,D.jsxs)(o.ModalFooter,{gap:2,children:[(0,D.jsx)(o.Button,{flavour:"hollow",onClick:s,children:"Cancel"}),d?(0,D.jsx)(o.Button,{onClick:async()=>{if(d)try{await(0,ye.A)(d)&&(u(!0),setTimeout(()=>u(!1),2e3))}catch(e){console.error("Failed to copy URL:",e)}},children:h?"Copied!":"Copy URL"}):(0,D.jsx)(o.Button,{onClick:async()=>{r(!0);try{const{data:e}=await(0,ge.Ey)({description:(0,ae.HR)(t),scope:"scope:all"});c(((e,t,n,a)=>{const o=window.location.origin,l=new URLSearchParams(location.search).get("agent");return`${o}/webviews/playlists/${t}?space_id=${n}&room_id=${a}${l?`&agent=${l}`:""}#token=${e}`})(e.token,t,n,l))}catch(e){console.error("Failed to create token:",e)}finally{r(!1)}},disabled:i,children:i?"Generating...":"Generate a new URL"})]})]})})};var je=n(68453);const we=e=>{let{playlistId:t,onClose:n}=e;const l=(0,m.vt)(),s=(0,p.ID)(),i=(0,ne.W9)(t),r=(0,a.useRef)(null);return(0,a.useEffect)(()=>{const e=r.current;return e?.requestFullscreen&&e.requestFullscreen().catch(()=>{}),()=>{document.fullscreenElement&&document.exitFullscreen().catch(()=>{})}},[]),(0,D.jsx)(o.Layer,{full:!0,backdrop:!0,onEsc:n,children:(0,D.jsx)(o.Flex,{ref:r,flex:"1",width:"100vw",height:"100vh",background:"mainBackground",position:"relative",children:(0,D.jsx)(je.A,{playlist:i,spaceId:l,roomId:s,mode:"layer",onClose:n})})})},Ce=e=>{let{onCreate:t}=e;return(0,D.jsxs)(o.Flex,{flex:"1",column:!0,alignItems:"center",justifyContent:"center",gap:2,children:[(0,D.jsx)(o.H3,{children:"No playlists yet"}),(0,D.jsx)(o.Text,{children:"Create a playlist to cycle through dashboards on a NOC wall or presentation."}),(0,D.jsx)(o.Button,{onClick:t,children:"New playlist"})]})};n(8872);const Ae=e=>e.reduce((e,t)=>e+(t.durationMs||0),0),ve=e=>{const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),a=t%60;return a?`${n}m ${a}s`:`${n}m`},Te=e=>function(t){let{getValue:n,row:a}=t;return(0,D.jsx)(V.A,{onClick:()=>e(a.original),children:n()})},ke=e=>{let{getValue:t}=e;const{localeDateString:n}=(0,R.$j)(),a=t();return a?(0,D.jsx)(o.TextSmall,{whiteSpace:"nowrap",children:n(new Date(a))}):(0,D.jsx)(o.TextSmall,{children:"-"})},Se=e=>{let{row:t}=e;return(0,D.jsx)(o.TextSmall,{children:t.original.entries.length})},De=e=>{let{row:t}=e;return(0,D.jsx)(o.TextSmall,{children:ve(Ae(t.original.entries))})},Ie=e=>{let{getValue:t}=e;return(0,D.jsx)(o.TextSmall,{children:t()||"-"})},Fe=e=>{let{getValue:t}=e;return(0,D.jsx)(o.TextSmall,{children:t()?"Yes":"No"})};const Le=async e=>{if(!e.length)return;const t=new Set(e);try{const{data:e}=await(0,ge.li)(),n=(e||[]).filter(e=>t.has(e.description));await Promise.all(n.map(e=>(0,ge.ni)(e.id).catch(()=>{})))}catch{}},Me=e=>{let{onPlay:t,onEdit:n,onTvUrl:l,onCreate:s}=e;const i=(()=>{const e=oe();return(0,a.useCallback)(t=>e({name:`${t.name} (copy)`,entries:t.entries.map(e=>({...e,id:(0,ee.A)()})),transition:t.transition,loop:t.loop}),[e])})(),r=(0,te.z2)(),d=async(e,t)=>{const n=(Array.isArray(e)?e:[e]).map(e=>e.playlistId);await Promise.all(n.map(e=>r(e))),Le(n.map(ae.HR)),t?.toggleAllRowsSelected?.(!1)};return{rowActions:(0,a.useMemo)(()=>({play:{icon:"playOutline",confirmation:!1,handleAction:e=>t(e),tooltipText:"Play playlist"},edit:{handleAction:e=>n(e),tooltipText:"Edit playlist"},duplicate:{icon:"copy",confirmation:!0,handleAction:e=>i(e),tooltipText:"Duplicate playlist",confirmLabel:"Duplicate",confirmationMessage:e=>`A copy named "${e.name} (copy)" will be created with the same entries and settings.`,confirmationTitle:e=>`Duplicate ${e.name}`,declineLabel:"Cancel"},tvUrl:{icon:"share",confirmation:!1,handleAction:e=>l(e),tooltipText:"Get TV URL"},delete:{confirmLabel:"Yes, delete",confirmationMessage:e=>(0,D.jsxs)(D.Fragment,{children:["You are about to delete ",(0,D.jsx)("strong",{children:e.name}),".",(0,D.jsx)("br",{}),"Are you sure you want to continue?"]}),confirmationTitle:e=>`Delete ${e.name}`,declineLabel:"Cancel",handleAction:d,tooltipText:"Delete playlist"}}),[t,n,l,i]),bulkActions:(0,a.useMemo)(()=>({addEntry:{handleAction:s,tooltipText:"New playlist"},delete:{confirmLabel:"Yes, delete",confirmationMessage:(e,t)=>(0,D.jsxs)(o.Text,{children:["You are about to delete"," ",(0,D.jsx)("strong",{children:t.length>1?`${t.length} playlists`:t[0].name}),".",(0,D.jsx)("br",{}),"Are you sure you want to continue?"]}),confirmationTitle:()=>"Delete",declineLabel:"Cancel",handleAction:d,tooltipText:"Delete playlists",disabledTooltipText:"Delete is disabled because you haven't selected playlists"}}),[s])}},Be=e=>{let{onPlay:t,onEdit:n,onTvUrl:o,onCreate:l}=e;const[,s]=(0,a.useState)(),i=(0,ne.ng)(),{localeDateString:r}=(0,R.$j)(),d=(0,a.useMemo)(()=>(e=>{let{onEdit:t}=e;return[{id:"name",accessorKey:"name",header:"Name",cell:Te(t)},{id:"entries",accessorFn:e=>e.entries.length,header:"Entries",cell:Se,sortingFn:"basic"},{id:"duration",accessorFn:e=>Ae(e.entries),header:"Duration",cell:De,sortingFn:"basic"},{id:"transition",accessorKey:"transition",header:"Transition",cell:Ie},{id:"loop",accessorKey:"loop",header:"Loop",cell:Fe},{id:"updatedAt",accessorKey:"updatedAt",header:"Last modified",cell:ke,sortingFn:"datetime"},{id:"createdAt",accessorKey:"createdAt",header:"Created",cell:ke,sortingFn:"datetime"}]})({onEdit:n}),[n]),{rowActions:c,bulkActions:h}=Me({onPlay:t,onEdit:n,onTvUrl:o,onCreate:l});return{data:i,columns:d,rowActions:c,bulkActions:h,globalFilterFn:(0,a.useCallback)((e,t,n)=>{const a=n?.toLowerCase?.()||"",o=e.getValue("name")?.toLowerCase?.()||"",l=r(new Date(e.getValue("updatedAt"))).toLowerCase(),s=r(new Date(e.getValue("createdAt"))).toLowerCase();return o.includes(a)||l.includes(a)||s.includes(a)},[r]),setGlobalFilter:s}},$e=[{id:"updatedAt",desc:!0}],Ee={transition:!1,loop:!1,createdAt:!1},Ne=e=>{let{editor:t,onClose:n}=e;const o=(e=>{const t=(0,ne.yp)(e),n=(0,te.xS)(e);return(0,a.useCallback)(function(){let{name:a,entries:o,transition:l,loop:s}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!t)return Promise.resolve();const i=Date.now();return n({id:e,type:ae.Zg,entity:ae.w0,scope:ae.CA,name:a??t.name,path:ae.Bb,value:{entries:o??t.value.entries,transition:l??t.value.transition,loop:s??t.value.loop,createdAt:t.value.createdAt,updatedAt:i}})},[e,t,n])})(t.playlist?.playlistId),l=oe();return(0,D.jsx)(xe,{mode:t.mode,playlist:t.playlist,onSave:async e=>{"create"===t.mode?await l(e):await o(e)},onClose:n})},_e=()=>{const e=(0,ne.ng)(),t=(0,m.vt)(),n=(0,p.ID)(),[l,s]=(0,a.useState)(null),[i,r]=(0,a.useState)(null),[d,c]=(0,a.useState)(null),h=()=>s({mode:"create",playlist:null}),{data:u,columns:x,rowActions:g,bulkActions:b,globalFilterFn:y,setGlobalFilter:f}=Be({onPlay:e=>r(e.playlistId),onEdit:e=>s({mode:"edit",playlist:e}),onTvUrl:e=>c(e),onCreate:h});return e.length||l?(0,D.jsxs)(o.Flex,{column:!0,flex:"1",height:"100%",overflow:"hidden",children:[(0,D.jsx)(o.Table,{data:u,dataColumns:x,rowActions:g,bulkActions:b,enableSelection:!0,enableSorting:!0,enableColumnVisibility:!0,columnVisibility:Ee,sortBy:$e,globalFilterFn:y,onSearch:f,testPrefixCallback:e=>e.name,title:"Playlists"}),l&&(0,D.jsx)(Ne,{editor:l,onClose:()=>s(null)}),i&&(0,D.jsx)(we,{playlistId:i,onClose:()=>r(null)}),d&&(0,D.jsx)(fe,{playlistId:d.playlistId,spaceId:t,roomId:n,onClose:()=>c(null)})]}):(0,D.jsx)(Ce,{onCreate:h})},Re=()=>{(0,s.A)();return(0,i.RQ)()?(0,D.jsx)(X.Ay,{feature:"DashboardPlaylists",children:(0,D.jsx)(o.Flex,{width:"100%",height:"100%",flex:"1",column:!0,padding:[3,3,0],overflow:"hidden",children:(0,D.jsx)(_e,{})})}):(0,D.jsx)(F.Ki,{})};var Pe=n(78152);const Ve=()=>{const e=(0,s.A)(),[t,n]=(0,a.useState)(0),[r,,d,c]=(0,l.A)(!1);return(0,i.RQ)()?(0,D.jsx)(X.Ay,{feature:"DashboardOverview",children:(0,D.jsxs)(o.Flex,{position:"relative",width:"100%",height:"100%",flex:"1",column:!0,padding:[3,3,0],overflow:"hidden",children:[Pe.Cx?(0,D.jsxs)(o.Tabs,{selected:t,onChange:n,height:"100%",gap:2,noDefaultBorder:!0,children:[(0,D.jsx)(o.Tab,{label:(0,D.jsx)(o.Text,{children:"Dashboards"}),padding:[2,4],children:(0,D.jsx)(Q,{refetch:e,handleOpenAddDashboardModal:d})}),(0,D.jsx)(o.Tab,{label:(0,D.jsx)(o.Text,{children:"Playlists"}),padding:[2,4],"data-testid":"playlists-tab-button",children:(0,D.jsx)(Re,{})})]}):(0,D.jsx)(Q,{refetch:e,handleOpenAddDashboardModal:d}),r&&(0,D.jsx)(I,{onClose:c})]})}):(0,D.jsx)(F.Ki,{})}},47154(e,t,n){var a=n(66118);a.t1.register(...a.$L)}}]);