import{ao as w,r as c,j as e,B as t,aG as H,di as I}from"./index-dP1W1_bd.js";const j=[{duration:"5m",label:"5 min"},{duration:"15m",label:"15 min"},{duration:"30m",label:"30 min"},{duration:"1h",label:"1 hr"},{duration:"5h",label:"5 hr"},{duration:"24h",label:"24 hr"}],a={THEME:"light",DURATION_TO:"now",REFRESH:"10s",HEIGHT:"300px",PANEL_WIDTH:"50%",DURATION_FROM:"15m"},O=({panels:i,panelDurationsControls:n=j})=>{const{colorMode:l}=w(),[s,o]=c.useState(a.DURATION_FROM),u=({urlPath:r,refresh:m=a.REFRESH,theme:f=a.THEME,variables:x,panelId:E,duration:b=s,to:D=a.DURATION_TO})=>{const T={...x.reduce((R,d)=>({...R,[`var-${d.name}`]:d.value}),{}),theme:f,refresh:m,panelId:E,from:`now-${b}`,to:D,orgId:1},g=I.stringify(T);return`/hopsworks-api/${r}?${g}`},h=c.useCallback(r=>()=>{o(r)},[o]);return e.jsxs(e.Fragment,{children:[n.length>0&&e.jsx(t,{flexDirection:"row",mb:20,children:n.map(r=>e.jsx(H,{onClick:h(r.duration),intent:r.duration===s?"primary":"secondary",children:r.label},`option-${r.label}`))}),i.length>0&&e.jsx(t,{justifyContent:"space-between",alignItems:"center",flexDirection:"row",flexWrap:"wrap",sx:{...l==="dark"?{filter:"invert(92%)"}:{}},children:i.map(r=>e.jsx(t,{width:r.width??a.PANEL_WIDTH,sx:{...l==="dark"&&{filter:"invert(92%)"}},children:e.jsx("iframe",{title:r.title,src:u({...r.linkParams}),width:"100%",height:r.height??a.HEIGHT,frameBorder:"0"})},`panel-${r.title.replace(/\s/g,"")}`))})]})};export{O as G};
