import{al as H,r as c,j as e,a as t,aJ as R,dU as j,du as w}from"./index-_eM6l4Nf.js";const O=[{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"},_=({panels:n,panelDurationsControls:i=O})=>{const{colorMode:l}=H(),[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((g,d)=>({...g,[`var-${d.name}`]:d.value}),{}),theme:f,refresh:m,panelId:E,from:`now-${b}`,to:D,orgId:1},I=j.stringify(T);return`${w}/${r}?${I}`},h=c.useCallback(r=>()=>{o(r)},[o]);return e.jsxs(e.Fragment,{children:[i.length>0&&e.jsx(t,{flexDirection:"row",mb:20,children:i.map(r=>e.jsx(R,{onClick:h(r.duration),intent:r.duration===s?"primary":"secondary",children:r.label},`option-${r.label}`))}),n.length>0&&e.jsx(t,{justifyContent:"space-between",alignItems:"center",flexDirection:"row",flexWrap:"wrap",sx:{...l==="dark"?{filter:"invert(92%)"}:{}},children:n.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{_ as G};
