import{r as x,j as r}from"./vendor-react-wBh_31cN.js";import{T as E,a as H,b as D}from"./tabs-BZDPsi5L.js";import{aT as R,a5 as I}from"./index-dNe6i2rS.js";const N=[{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"}],e={THEME:"light",DURATION_TO:"now",REFRESH:"10s",HEIGHT:"300px",PANEL_WIDTH:"50%",DURATION_FROM:"15m"},P=({panels:i,panelDurationsControls:n=N})=>{const[o,c]=x.useState(e.DURATION_FROM),m=({urlPath:a,refresh:t=e.REFRESH,theme:s=e.THEME,variables:l,panelId:u,duration:h=o,to:b=e.DURATION_TO})=>{const T={...l.reduce((f,d)=>({...f,[`var-${d.name}`]:d.value}),{}),theme:s,refresh:t,panelId:u,from:`now-${h}`,to:b,orgId:1},g=R.stringify(T);return`${I}/${a}?${g}`};return r.jsxs(r.Fragment,{children:[n.length>0&&r.jsx(E,{value:o,onValueChange:c,className:"mb-4",children:r.jsx(H,{children:n.map(a=>r.jsx(D,{value:a.duration,children:a.label},a.duration))})}),i.length>0&&r.jsx("div",{className:"flex flex-wrap gap-4",style:void 0,children:i.map(a=>{const t=a.width??e.PANEL_WIDTH,s=t==="100%"?"100%":`calc(${t} - 0.5rem)`,l=a.height??e.HEIGHT;return r.jsx("div",{className:"transform-gpu overflow-hidden rounded-md border border-border bg-card",style:{width:s},children:r.jsx("iframe",{className:"block",title:a.title,src:m({...a.linkParams}),frameBorder:"0",style:{width:"calc(100% + 8px)",height:`calc(${l} + 8px)`,margin:"-4px"}})},`panel-${a.title.replace(/\s/g,"")}`)})})]})};export{P as G};
