"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5042],{"./public/app/features/dashboard/dashgrid/DashboardPanel.tsx":(e,t,n)=>{n.d(t,{l:()=>ue});var a,s,i,r=n("./node_modules/react/index.js"),o=n("./node_modules/react-redux/es/index.js"),l=n("./node_modules/classnames/index.js"),d=n.n(l),p=n("./node_modules/rxjs/dist/esm5/internal/Subscription.js"),c=n("./packages/grafana-runtime/src/index.ts"),h=n("./packages/grafana-data/src/index.ts"),u=n("./packages/grafana-ui/src/index.ts"),g=n("./packages/grafana-e2e-selectors/src/index.ts"),m=n("./node_modules/@emotion/css/dist/emotion-css.esm.js"),b=n("./public/app/features/dashboard/services/TimeSrv.ts"),f=n("./public/app/features/inspector/types.ts"),v=n("./node_modules/react/jsx-runtime.js");function x(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!function(e){e.Error="Error",e.Info="Info",e.Links="Links"}(i||(i={}));class y extends r.Component{constructor(...e){super(...e),x(this,"timeSrv",(0,b.$t)()),x(this,"getInfoMode",(()=>{const{panel:e,error:t}=this.props;return t?i.Error:e.description?i.Info:e.links&&e.links.length?i.Links:void 0})),x(this,"getInfoContent",(()=>{const{panel:e}=this.props,t=e.description||"",n=(0,c.getTemplateSrv)().replace(t,e.scopedVars),a=(0,h.renderMarkdown)(n),s=this.props.links&&this.props.links.getLinks(e.replaceVariables);return(0,v.jsxs)("div",{className:"panel-info-content markdown-html",children:[(0,v.jsx)("div",{dangerouslySetInnerHTML:{__html:a}}),s&&s.length>0&&(0,v.jsx)("ul",{className:"panel-info-corner-links",children:s.map(((e,t)=>(0,v.jsx)("li",{children:(0,v.jsx)("a",{className:"panel-info-corner-links__item",href:e.href,target:e.target,children:e.title})},t)))})]})})),x(this,"onClickError",(()=>{(0,c.getLocationSrv)().update({partial:!0,query:{inspect:this.props.panel.id,inspectTab:f.q.Error}})}))}renderCornerType(e,t,n){const r=e===i.Error?"error":"info",o=`panel-info-corner panel-info-corner--${e.toLowerCase()}`,l=g.wl.components.Panels.Panel.headerCornerInfo(e.toLowerCase());return(0,v.jsx)(u.Tooltip,{content:t,placement:"top-start",theme:r,children:(0,v.jsxs)("section",{className:o,onClick:n,"aria-label":l,children:[a||(a=(0,v.jsx)("i",{"aria-hidden":!0,className:"fa"})),s||(s=(0,v.jsx)("span",{className:"panel-info-corner-inner"}))]})})}render(){const{error:e}=this.props,t=this.getInfoMode();return t?t===i.Error&&e?this.renderCornerType(t,e,this.onClickError):t===i.Info||t===i.Links?this.renderCornerType(t,this.getInfoContent):null:null}}const C=y;var S=n("./public/app/features/panel/panellinks/linkSuppliers.ts");const w=({notice:e,onClick:t})=>{const n="error"===e.severity||"warning"===e.severity?"exclamation-triangle":"info-circle";return(0,v.jsx)(u.Tooltip,{content:e.text,children:e.inspect?(0,v.jsx)("div",{className:"panel-info-notice pointer",onClick:n=>t(n,e.inspect),children:(0,v.jsx)(u.Icon,{name:n,style:{marginRight:"8px"}})}):(0,v.jsx)("a",{className:"panel-info-notice",href:e.link,target:"_blank",rel:"noreferrer",children:(0,v.jsx)(u.Icon,{name:n,style:{marginRight:"8px"}})})},e.severity)},k=({frames:e,panelId:t})=>{const n=(0,r.useCallback)(((e,n)=>{e.stopPropagation(),c.locationService.partial({inspect:t,inspectTab:n})}),[t]),a={};for(const t of e)if(t.meta&&t.meta.notices)for(const e of t.meta.notices)a[e.severity]=e;return(0,v.jsx)(v.Fragment,{children:Object.values(a).map((e=>(0,v.jsx)(w,{notice:e,onClick:n},e.severity)))})},j=["children"];const P=e=>{let{children:t}=e,n=function(e,t){if(null==e)return{};var n,a,s={},i=Object.keys(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)>=0||(s[n]=e[n]);return s}(e,j);const[a,s]=(0,r.useState)({x:0,y:0}),[i,o]=(0,r.useState)(!1),l=(0,r.useCallback)((e=>{var t,n;(t=a,(n=I(e)).x===t.x&&n.y===t.y)&&(e.stopPropagation(),o(!i))}),[a,i,o]),d=(0,r.useCallback)((e=>{s(I(e))}),[s]);return(0,v.jsx)("header",Object.assign({},n,{className:"panel-title-container",onClick:l,onMouseDown:d,children:t({panelMenuOpen:i,closeMenu:()=>o(!1)})}))};function I(e){return{x:Math.floor(e.clientX),y:Math.floor(e.clientY)}}var D;const N=({state:e,onClick:t})=>{const n=(0,u.useStyles)(E);return e===h.LoadingState.Loading?(0,v.jsx)("div",{className:"panel-loading",onClick:t,children:D||(D=(0,v.jsx)(u.Tooltip,{content:"Cancel query",children:(0,v.jsx)(u.Icon,{className:"panel-loading__spinner spin-clockwise",name:"sync"})}))}):e===h.LoadingState.Streaming?(0,v.jsx)("div",{className:"panel-loading",onClick:t,children:(0,v.jsx)("div",{title:"Streaming (click to stop)",className:n.streamIndicator})}):null};function E(e){return{streamIndicator:m.css`
      width: 10px;
      height: 10px;
      background: ${e.colors.textFaint};
      box-shadow: 0 0 2px ${e.colors.textFaint};
      border-radius: 50%;
      position: relative;
      top: 6px;
      right: 1px;
    `}}var O=n("./public/app/store/store.ts"),T=n("./public/app/features/dashboard/utils/panel.ts"),L=n("./public/app/features/library-panels/guard.ts"),M=n("./public/app/core/services/context_srv.ts"),R=n("./public/app/features/explore/state/main.ts"),A=n("./public/app/core/utils/explore.ts"),F=n("./public/app/core/config.ts");const V=({panel:e,dashboard:t,children:n})=>{const[a,s]=(0,r.useState)([]),i=(0,o.useSelector)((t=>{var n;return(null===(n=t.dashboard.panels[e.id])||void 0===n?void 0:n.angularComponent)||null}));return(0,r.useEffect)((()=>{s(function(e,t,n){const a=e=>{e.preventDefault(),c.locationService.partial({viewPanel:t.id})},s=e=>{e.preventDefault(),c.locationService.partial({editPanel:t.id})},i=n=>{n.preventDefault(),(0,T.Kq)(e,t)},r=e=>{e.preventDefault(),(0,T.oe)(t)},o=e=>{c.locationService.partial({inspect:t.id,inspectTab:e})},l=e=>{e.preventDefault()},d=n=>{n.preventDefault(),(0,T.jN)(e,t)},p=e=>{e.preventDefault(),(0,T.bY)(t)},h=n=>{n.preventDefault(),(0,T.WJ)(e,t,!0)},u=e=>{e.preventDefault();const n=e.ctrlKey||e.metaKey?e=>window.open(`${F.ZP.appSubUrl}${e}`):void 0;O.h.dispatch((0,R.m$)(t,{getDataSourceSrv:c.getDataSourceSrv,getTimeSrv:b.$t,getExploreUrl:A.H6,openInNewWindow:n}))},g=[];t.isEditing||g.push({text:"View",iconClassName:"eye",onClick:a,shortcut:"v"}),e.canEditPanel(t)&&!t.isEditing&&g.push({text:"Edit",iconClassName:"edit",onClick:s,shortcut:"e"}),g.push({text:"Share",iconClassName:"share-alt",onClick:n=>{n.preventDefault(),(0,T.Po)(e,t)},shortcut:"p s"}),!M.Vt.hasAccessToExplore()||t.plugin&&t.plugin.meta.skipDataQuery||g.push({text:"Explore",iconClassName:"compass",shortcut:"x",onClick:u});const m=[];t.plugin&&!t.plugin.meta.skipDataQuery&&(m.push({text:"Data",onClick:e=>o("data")}),e.meta.canEdit&&m.push({text:"Query",onClick:e=>o("query")})),m.push({text:"Panel JSON",onClick:e=>o("json")}),g.push({type:"submenu",text:"Inspect",iconClassName:"info-circle",onClick:e=>o(),shortcut:"i",subMenu:m});const f=[];if(!e.canEditPanel(t)||t.isViewing||t.isEditing||(f.push({text:"Duplicate",onClick:d,shortcut:"p d"}),f.push({text:"Copy",onClick:p}),(0,L.V)(t)?f.push({text:"Unlink library panel",onClick:r}):f.push({text:"Create library panel",onClick:i})),n){const e=n.getScope(),t=e.$$childHead.ctrl,a=t.getExtendedMenu();for(const n of a){const a={text:n.text,href:n.href,shortcut:n.shortcut};n.click&&(a.onClick=()=>{e.$eval(n.click,{ctrl:t})}),f.push(a)}}return!t.isEditing&&f.length&&g.push({type:"submenu",text:"More...",iconClassName:"cube",subMenu:f,onClick:l}),!e.canEditPanel(t)||t.isEditing||t.isViewing||(g.push({type:"divider",text:""}),g.push({text:"Remove",iconClassName:"trash-alt",onClick:h,shortcut:"p r"})),g}(t,e,i))}),[t,e,i,s]),n({items:a})};var U=n("./public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenuItem.tsx");class Q extends r.PureComponent{constructor(...e){var t,n,a;super(...e),a=(e,t=!1)=>(0,v.jsx)("ul",{className:"dropdown-menu dropdown-menu--menu panel-menu",role:t?"":"menu",children:e.map(((e,t)=>(0,v.jsx)(U.u,{type:e.type,text:e.text,iconClassName:e.iconClassName,onClick:e.onClick,shortcut:e.shortcut,children:e.subMenu&&this.renderItems(e.subMenu,!0)},`${e.text}${t}`)))}),(n="renderItems")in(t=this)?Object.defineProperty(t,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[n]=a}render(){return(0,v.jsx)("div",{className:"panel-menu-container dropdown open",children:this.renderItems(this.props.items)})}}const q=({show:e,onClose:t,panel:n,dashboard:a})=>e?(0,v.jsx)(u.ClickOutsideWrapper,{onClick:t,parent:document,children:(0,v.jsx)(V,{panel:n,dashboard:a,children:({items:e})=>(0,v.jsx)(Q,{items:e})})}):null;var H,$;const _=({panel:e,error:t,isViewing:n,isEditing:a,data:s,alertState:i,dashboard:r})=>{const o=e.getDisplayTitle(),l=(0,m.cx)("panel-header",n||a?"":"grid-drag-handle"),d=(0,u.useStyles2)(z);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(N,{state:s.state,onClick:()=>e.getQueryRunner().cancelQuery()}),(0,v.jsx)(C,{panel:e,title:e.title,description:e.description,scopedVars:e.scopedVars,links:(0,S.H)(e),error:t}),(0,v.jsx)("div",{className:l,children:(0,v.jsx)(P,{"data-testid":g.wl.components.Panels.Panel.title(o),children:({closeMenu:t,panelMenuOpen:n})=>(0,v.jsxs)("div",{className:"panel-title",children:[(0,v.jsx)(k,{frames:s.series,panelId:e.id}),i?(0,v.jsx)(u.Icon,{name:"alerting"===i?"heart-break":"heart",className:"icon-gf panel-alert-icon",style:{marginRight:"4px"},size:"sm"}):null,(0,v.jsx)("h2",{className:d.titleText,children:o}),H||(H=(0,v.jsx)(u.Icon,{name:"angle-down",className:"panel-menu-toggle"})),(0,v.jsx)(q,{panel:e,dashboard:r,show:n,onClose:t}),s.request&&s.request.timeInfo&&(0,v.jsxs)("span",{className:"panel-time-info",children:[$||($=(0,v.jsx)(u.Icon,{name:"clock-nine",size:"sm"}))," ",s.request.timeInfo]})]})})})]})},z=e=>({titleText:m.css`
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
      max-width: calc(100% - 38px);
      cursor: pointer;
      font-weight: ${e.typography.fontWeightMedium};
      font-size: ${e.typography.body.fontSize};
      margin: 0;

      &:hover {
        color: ${e.colors.text.primary};
      }
      .panel-has-alert & {
        max-width: calc(100% - 54px);
      }
    `});var W=n("./public/app/core/profiler.ts"),B=n("./public/app/core/constants.ts"),Z=n("./public/app/features/dashboard/utils/loadSnapshotData.ts"),K=n("./public/app/types/events.ts");const J=(e,t)=>({matcher:{id:h.FieldMatcherID.byName,options:e},properties:[X(t)]}),X=e=>({id:"color",value:{mode:h.FieldColorModeId.Fixed,fixedColor:e}});var Y=n("./public/app/features/dashboard/dashgrid/SeriesVisibilityConfigFactory.ts"),G=n("./public/app/features/annotations/api.ts"),ee=n("./public/app/features/query/state/DashboardQueryRunner/DashboardQueryRunner.ts"),te=n("./public/app/features/dashboard/dashgrid/liveTimer.ts");function ne(e){return null==e?void 0:e.toLowerCase().includes("/d-solo/")}function ae(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class se extends r.Component{constructor(e){super(e),ae(this,"timeSrv",(0,b.$t)()),ae(this,"subs",new p.w0),ae(this,"eventFilter",{onlyLocal:!0}),ae(this,"onSeriesColorChange",((e,t)=>{this.onFieldConfigChange(((e,t,n)=>{const{overrides:a}=n,s=n.overrides.findIndex((t=>t.matcher.id===h.FieldMatcherID.byName&&t.matcher.options===e));if(s<0)return Object.assign({},n,{overrides:[...n.overrides,J(e,t)]});const i=Array.from(a),r=i[s],o=r.properties.findIndex((e=>"color"===e.id));if(o<0)return i[s]=Object.assign({},r,{properties:[...r.properties,X(t)]}),Object.assign({},n,{overrides:i});const l=Array.from(r.properties);return l[o]=X(t),i[s]=Object.assign({},r,{properties:l}),Object.assign({},n,{overrides:i})})(e,t,this.props.panel.fieldConfig))})),ae(this,"onSeriesVisibilityChange",((e,t)=>{this.onFieldConfigChange((0,Y.N)(e,t,this.props.panel.fieldConfig,this.state.data.series))})),ae(this,"onRefresh",(()=>{const{panel:e,isInView:t,width:n}=this.props;if(!t)return void this.setState({refreshWhenInView:!0});const a=(0,T.W1)(e,this.timeSrv.timeRange());if(this.wantsQueryExecution){if(n<0)return;this.state.refreshWhenInView&&this.setState({refreshWhenInView:!1}),e.runAllPanelQueries(this.props.dashboard.id,this.props.dashboard.getTimezone(),a,n)}else this.setState({data:Object.assign({},this.state.data,{timeRange:this.timeSrv.timeRange()}),renderCounter:this.state.renderCounter+1,liveTime:void 0})})),ae(this,"onRender",(()=>{const e={renderCounter:this.state.renderCounter+1};this.setState(e)})),ae(this,"onOptionsChange",(e=>{this.props.panel.updateOptions(e)})),ae(this,"onFieldConfigChange",(e=>{this.props.panel.updateFieldConfig(e)})),ae(this,"onPanelError",(e=>{this.state.errorMessage!==e&&this.setState({errorMessage:e})})),ae(this,"onAnnotationCreate",(async e=>{const t=e.from!==e.to,n={dashboardId:this.props.dashboard.id,panelId:this.props.panel.id,isRegion:t,time:e.from,timeEnd:t?e.to:0,tags:e.tags,text:e.description};await(0,G.xD)(n),(0,ee.kt)().run({dashboard:this.props.dashboard,range:this.timeSrv.timeRange()}),this.state.context.eventBus.publish(new h.AnnotationChangeEvent(n))})),ae(this,"onAnnotationDelete",(async e=>{await(0,G.Dl)({id:e}),(0,ee.kt)().run({dashboard:this.props.dashboard,range:this.timeSrv.timeRange()}),this.state.context.eventBus.publish(new h.AnnotationChangeEvent({id:e}))})),ae(this,"onAnnotationUpdate",(async e=>{const t=e.from!==e.to,n={id:e.id,dashboardId:this.props.dashboard.id,panelId:this.props.panel.id,isRegion:t,time:e.from,timeEnd:t?e.to:0,tags:e.tags,text:e.description};await(0,G._E)(n),(0,ee.kt)().run({dashboard:this.props.dashboard,range:this.timeSrv.timeRange()}),this.state.context.eventBus.publish(new h.AnnotationChangeEvent(n))})),ae(this,"onChangeTimeRange",(e=>{this.timeSrv.setTime({from:(0,h.toUtc)(e.from),to:(0,h.toUtc)(e.to)})}));const t=e.dashboard.events.newScopedBus(`panel:${e.panel.id}`,this.eventFilter);this.state={isFirstLoad:!0,renderCounter:0,refreshWhenInView:!1,context:{sync:e.isEditing?h.DashboardCursorSync.Off:e.dashboard.graphTooltip,eventBus:t,onSeriesColorChange:this.onSeriesColorChange,onToggleSeriesVisibility:this.onSeriesVisibilityChange,onAnnotationCreate:this.onAnnotationCreate,onAnnotationUpdate:this.onAnnotationUpdate,onAnnotationDelete:this.onAnnotationDelete,canAddAnnotations:()=>Boolean(e.dashboard.meta.canEdit||e.dashboard.meta.canMakeEditable)},data:this.getInitialPanelDataState()}}getInitialPanelDataState(){return{state:h.LoadingState.NotStarted,series:[],timeRange:(0,h.getDefaultTimeRange)()}}componentDidMount(){const{panel:e,dashboard:t}=this.props;this.subs.add(e.events.subscribe(K.U5,this.onRefresh)),this.subs.add(e.events.subscribe(K._z,this.onRender)),t.panelInitialized(this.props.panel),this.hasPanelSnapshot?this.setState({data:(0,Z.y)(e,t),isFirstLoad:!1}):(this.wantsQueryExecution||this.setState({isFirstLoad:!1}),this.subs.add(e.getQueryRunner().getData({withTransforms:!0,withFieldConfig:!0}).subscribe({next:e=>this.onDataUpdate(e)})),te.A.listen(this))}componentWillUnmount(){this.subs.unsubscribe(),te.A.remove(this)}liveTimeChanged(e){const{data:t}=this.state;if(t.timeRange){const n=e.to.valueOf()-t.timeRange.to.valueOf();if(n<100)return void console.log("Skip tick render",this.props.panel.title,n)}this.setState({liveTime:e})}componentDidUpdate(e){const{isInView:t,isEditing:n,width:a}=this.props;e.dashboard.graphTooltip!==this.props.dashboard.graphTooltip&&this.setState((e=>({context:Object.assign({},e.context,{sync:n?h.DashboardCursorSync.Off:this.props.dashboard.graphTooltip})}))),n!==e.isEditing&&this.setState((e=>({context:Object.assign({},e.context,{sync:n?h.DashboardCursorSync.Off:this.props.dashboard.graphTooltip})}))),t!==e.isInView&&t&&this.state.refreshWhenInView&&this.onRefresh(),a!==e.width&&te.A.updateInterval(this)}shouldComponentUpdate(e,t){const{plugin:n,panel:a}=this.props;return e.plugin===n||(a.getQueryRunner().resendLastResult(),!1)}onDataUpdate(e){const{dashboard:t,panel:n,plugin:a}=this.props;if(a.meta.skipDataQuery)return void this.setState({data:this.getInitialPanelDataState()});let s,{isFirstLoad:i}=this.state;switch(e.state){case h.LoadingState.Loading:if(this.state.data.state===h.LoadingState.Loading)return;break;case h.LoadingState.Error:const{error:a}=e;a&&s!==a.message&&(s=a.message);break;case h.LoadingState.Done:t.snapshot&&(n.snapshotData=e.series.map((e=>(0,h.toDataFrameDTO)(e)))),i&&(i=!1)}this.setState({isFirstLoad:i,errorMessage:s,data:e,liveTime:void 0})}get hasPanelSnapshot(){const{panel:e}=this.props;return e.snapshotData&&e.snapshotData.length}get wantsQueryExecution(){return!(this.props.plugin.meta.skipDataQuery||this.hasPanelSnapshot)}shouldSignalRenderingCompleted(e,t){return e===h.LoadingState.Done||t.skipDataQuery}skipFirstRender(e){const{isFirstLoad:t}=this.state;return this.wantsQueryExecution&&t&&(e===h.LoadingState.Loading||e===h.LoadingState.NotStarted)}renderPanel(e,t){var n,a;const{panel:s,plugin:i,dashboard:r}=this.props,{renderCounter:o,data:l}=this.state,{theme:p}=F.ZP,{state:c}=l;if(this.skipFirstRender(c))return null;this.shouldSignalRenderingCompleted(c,i.meta)&&W.r.renderingCompleted();const h=i.panel,g=null!==(n=null!==(a=this.state.liveTime)&&void 0!==a?a:l.timeRange)&&void 0!==n?n:this.timeSrv.timeRange(),m=this.hasOverlayHeader()?0:p.panelHeaderHeight,b=i.noPadding?0:p.panelPadding,f=e-2*b-B.QO,x=t-m-2*b-B.QO,y=d()({"panel-content":!0,"panel-content--no-padding":i.noPadding}),C=s.getOptions();return this.eventFilter.onlyLocal=0===r.graphTooltip,(0,v.jsx)(v.Fragment,{children:(0,v.jsx)("div",{className:y,children:(0,v.jsx)(u.PanelContextProvider,{value:this.state.context,children:(0,v.jsx)(h,{id:s.id,data:l,title:s.title,timeRange:g,timeZone:this.props.dashboard.getTimezone(),options:C,fieldConfig:s.fieldConfig,transparent:s.transparent,width:f,height:x,renderCounter:o,replaceVariables:s.replaceVariables,onOptionsChange:this.onOptionsChange,onFieldConfigChange:this.onFieldConfigChange,onChangeTimeRange:this.onChangeTimeRange,eventBus:r.events})})})})}hasOverlayHeader(){const{panel:e}=this.props,{data:t}=this.state;return(!t.request||!t.request.timeInfo)&&!e.hasTitle()}render(){var e;const{dashboard:t,panel:n,isViewing:a,isEditing:s,width:i,height:r}=this.props,{errorMessage:o,data:l}=this.state,{transparent:p}=n;let h=F.ZP.unifiedAlertingEnabled||null===(e=l.alertState)||void 0===e?void 0:e.state;const m=d()({"panel-container":!0,"panel-container--absolute":ne(c.locationService.getLocation().pathname),"panel-container--transparent":p,"panel-container--no-title":this.hasOverlayHeader(),[`panel-alert-state--${h}`]:void 0!==h});return(0,v.jsxs)("section",{className:m,"aria-label":g.wl.components.Panels.Panel.containerByTitle(n.title),children:[(0,v.jsx)(_,{panel:n,dashboard:t,title:n.title,description:n.description,links:n.links,error:o,isEditing:s,isViewing:a,alertState:h,data:l}),(0,v.jsx)(u.ErrorBoundary,{children:({error:e})=>e?(this.onPanelError(e.message||"Error in plugin"),null):this.renderPanel(i,r)})]})}}var ie=n("./public/app/features/dashboard/state/reducers.ts");function re(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class oe extends r.PureComponent{constructor(e){super(e),re(this,"element",null),re(this,"timeSrv",(0,b.$t)()),re(this,"scopeProps",void 0),re(this,"subs",new p.w0),this.state={data:{state:h.LoadingState.NotStarted,series:[],timeRange:(0,h.getDefaultTimeRange)()}}}componentDidMount(){const{panel:e}=this.props;this.loadAngularPanel();const t=e.getQueryRunner();this.subs.add(t.getData({withTransforms:!1,withFieldConfig:!1}).subscribe({next:e=>this.onPanelDataUpdate(e)}))}onPanelDataUpdate(e){let t;if(e.state===h.LoadingState.Error){const{error:n}=e;n&&t!==n.message&&(t=n.message)}this.setState({data:e,errorMessage:t})}componentWillUnmount(){this.cleanUpAngularPanel(),this.subs.unsubscribe()}componentDidUpdate(e,t){const{plugin:n,height:a,width:s,panel:i}=this.props;e.plugin!==n&&(this.cleanUpAngularPanel(),this.loadAngularPanel()),e.width===s&&e.height===a||this.scopeProps&&(this.scopeProps.size.height=this.getInnerPanelHeight(),this.scopeProps.size.width=this.getInnerPanelWidth(),i.render())}getInnerPanelHeight(){const{plugin:e,height:t}=this.props,{theme:n}=F.ZP;return t-(this.hasOverlayHeader()?0:n.panelHeaderHeight)-2*(e.noPadding?0:n.panelPadding)-B.QO}getInnerPanelWidth(){const{plugin:e,width:t}=this.props,{theme:n}=F.ZP;return t-2*(e.noPadding?0:n.panelPadding)-B.QO}loadAngularPanel(){const{panel:e,dashboard:t,setPanelAngularComponent:n}=this.props;if(!this.element)return;const a=(0,c.getAngularLoader)();this.scopeProps={panel:e,dashboard:t,size:{width:this.getInnerPanelWidth(),height:this.getInnerPanelHeight()}},n({panelId:e.id,angularComponent:a.load(this.element,this.scopeProps,'<plugin-component type="panel" class="panel-height-helper"></plugin-component>')})}cleanUpAngularPanel(){const{angularComponent:e,setPanelAngularComponent:t,panel:n}=this.props;e&&e.destroy(),t({panelId:n.id,angularComponent:null})}hasOverlayHeader(){const{panel:e}=this.props,{data:t}=this.state;return(!t.request||!t.request.timeInfo)&&!e.hasTitle()}render(){var e;const{dashboard:t,panel:n,isViewing:a,isEditing:s,plugin:i}=this.props,{errorMessage:r,data:o}=this.state,{transparent:l}=n;let p=F.ZP.unifiedAlertingEnabled||null===(e=o.alertState)||void 0===e?void 0:e.state;const h=d()({"panel-container":!0,"panel-container--absolute":ne(c.locationService.getLocation().pathname),"panel-container--transparent":l,"panel-container--no-title":this.hasOverlayHeader(),"panel-has-alert":void 0!==n.alert,[`panel-alert-state--${p}`]:void 0!==p}),u=d()({"panel-content":!0,"panel-content--no-padding":i.noPadding});return(0,v.jsxs)("div",{className:h,"aria-label":g.wl.components.Panels.Panel.containerByTitle(n.title),children:[(0,v.jsx)(_,{panel:n,dashboard:t,title:n.title,description:n.description,links:n.links,error:r,isViewing:a,isEditing:s,data:o,alertState:p}),(0,v.jsx)("div",{className:u,children:(0,v.jsx)("div",{ref:e=>this.element=e,className:"panel-height-helper"})})]})}}const le={setPanelAngularComponent:ie.o8},de=(0,o.connect)(((e,t)=>({angularComponent:e.dashboard.panels[t.panel.id].angularComponent})),le)(oe);const pe={initDashboardPanel:n("./public/app/features/dashboard/state/actions.ts").PX},ce=(0,o.connect)(((e,t)=>{const n=e.dashboard.panels[t.panel.id];return n?{plugin:n.plugin}:{plugin:null}}),pe);class he extends r.PureComponent{constructor(e){var t,n,a;super(e),a={},(n="specialPanels")in(t=this)?Object.defineProperty(t,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[n]=a,this.state={isLazy:!e.isInView}}componentDidMount(){this.props.initDashboardPanel(this.props.panel)}componentDidUpdate(){this.state.isLazy&&this.props.isInView&&this.setState({isLazy:!1})}renderPanel(e){const{dashboard:t,panel:n,isViewing:a,isInView:s,isEditing:i,width:r,height:o}=this.props;return e.angularPanelCtrl?(0,v.jsx)(de,{plugin:e,panel:n,dashboard:t,isViewing:a,isEditing:i,isInView:s,width:r,height:o}):(0,v.jsx)(se,{plugin:e,panel:n,dashboard:t,isViewing:a,isEditing:i,isInView:s,width:r,height:o})}render(){const{plugin:e}=this.props,{isLazy:t}=this.state;return e?t?null:this.renderPanel(e):null}}const ue=ce(he)},"./public/app/features/dashboard/dashgrid/SeriesVisibilityConfigFactory.ts":(e,t,n)=>{n.d(t,{N:()=>o});var a=n("./packages/grafana-data/src/index.ts"),s=n("./packages/grafana-ui/src/index.ts");const i="hideSeriesFrom",r=(0,a.isSystemOverrideWithRef)(i);function o(e,t,n,a){const{overrides:i}=n,o=e,u=i.findIndex(r);if(u<0){if(t===s.SeriesVisibilityChangeMode.ToggleSelection){const e=l([o]);return Object.assign({},n,{overrides:[...n.overrides,e]})}const e=l(h(a,o));return Object.assign({},n,{overrides:[...n.overrides,e]})}const g=Array.from(i),[m]=g.splice(u,1);if(t===s.SeriesVisibilityChangeMode.ToggleSelection){const e=p(m);if(e[0]===o&&1===e.length)return Object.assign({},n,{overrides:g});const t=l([o]);return Object.assign({},n,{overrides:[...g,t]})}const b=d(m,o);return c(b,a)?Object.assign({},n,{overrides:g}):Object.assign({},n,{overrides:[...g,b]})}function l(e,t=a.ByNamesMatcherMode.exclude,n){var s;return n=null!==(s=n)&&void 0!==s?s:{id:"custom.hideFrom",value:{viz:!0,legend:!1,tooltip:!1}},{__systemRef:i,matcher:{id:a.FieldMatcherID.byNames,options:{mode:t,names:e,prefix:t===a.ByNamesMatcherMode.exclude?"All except:":void 0,readOnly:!0}},properties:[Object.assign({},n,{value:{viz:!0,legend:!1,tooltip:!1}})]}}const d=(e,t,n=a.ByNamesMatcherMode.exclude)=>{const s=e.properties.find((e=>"custom.hideFrom"===e.id)),i=p(e),r=i.findIndex((e=>e===t));return r<0?i.push(t):i.splice(r,1),l(i,n,s)},p=e=>{var t;const n=null===(t=e.matcher.options)||void 0===t?void 0:t.names;return Array.isArray(n)?n:[]},c=(e,t)=>p(e).length===h(t).length,h=(e,t)=>{const n=new Set;for(const s of e)for(const i of s.fields){if(i.type!==a.FieldType.number)continue;const r=(0,a.getFieldDisplayName)(i,s,e);r!==t&&n.add(r)}return Array.from(n)}},"./public/app/features/dashboard/state/initDashboard.ts":(e,t,n)=>{n.d(t,{m:()=>x});var a=n("./public/app/core/copy/appNotification.ts"),s=n("./public/app/core/services/backend_srv.ts"),i=n("./public/app/features/dashboard/services/DashboardSrv.ts"),r=n("./public/app/features/dashboard/services/DashboardLoaderSrv.ts"),o=n("./public/app/features/dashboard/services/TimeSrv.ts"),l=n("./public/app/core/services/keybindingSrv.ts"),d=n("./public/app/core/actions/index.ts"),p=n("./public/app/features/dashboard/state/reducers.ts"),c=n("./public/app/types/index.ts"),h=n("./public/app/features/dashboard/state/DashboardModel.ts"),u=n("./packages/grafana-data/src/index.ts"),g=n("./public/app/features/variables/state/actions.ts"),m=n("./packages/grafana-runtime/src/index.ts");var b=n("./public/app/features/live/dashboard/dashboardWatcher.ts"),f=n("./public/app/features/query/state/DashboardQueryRunner/DashboardQueryRunner.ts");async function v(e,t,n){try{switch(e.routeName){case c.vq.Home:{const e=await s.ae.get("/api/dashboards/home");if(e.redirectUri){const t=u.locationUtil.stripBaseFromUrl(e.redirectUri);return m.locationService.replace(t),null}return e.meta.canSave=!1,e.meta.canShare=!1,e.meta.canStar=!1,e}case c.vq.Normal:{const t=await r.pD.loadDashboard(e.urlType,e.urlSlug,e.urlUid);if(e.fixUrl&&t.meta.url){const e=u.locationUtil.stripBaseFromUrl(t.meta.url),n=m.locationService.getLocation().pathname;e!==n&&(m.locationService.replace(Object.assign({},m.locationService.getLocation(),{pathname:e})),console.log("not correct url correcting",e,n))}return t}case c.vq.New:return function(e){const t={meta:{canStar:!1,canShare:!1,isNew:!0,folderId:0},dashboard:{title:"New dashboard",panels:[{type:"add-panel",gridPos:{x:0,y:0,w:12,h:9},title:"Panel Title"}]}};e&&(t.meta.folderId=parseInt(e,10));return t}(e.urlFolderId);default:throw{message:"Unknown route "+e.routeName}}}catch(e){return e.cancelled||(t((0,p.jA)({message:"Failed to fetch dashboard",error:e})),console.error(e)),null}}function x(e){return async(t,n)=>{t((0,p.sf)()),setTimeout((()=>{null===n().dashboard.getModel()&&t((0,p.rq)())}),500);const s=await v(e,t);if(!s)return;let r;t((0,p.Nv)());try{r=new h.f(s.dashboard,s.meta)}catch(e){return t((0,p.jA)({message:"Failed create dashboard model",error:e})),void console.error(e)}const u=n(),x=m.locationService.getSearchObject();x.orgId||m.locationService.partial({orgId:u.user.orgId},!0);const y=(0,o.$t)();if((0,i.h4)().setCurrent(r),y.init(r),u.dashboard.modifiedQueries){const{panelId:e,queries:t}=u.dashboard.modifiedQueries;r.meta.fromExplore=!(!e||!t)}await t((0,g.LX)(e.urlUid,r));if((0,f.Tl)({dashboard:r,timeSrv:y}).run({dashboard:r,range:y.timeRange()}),n().templating.transaction.uid===e.urlUid&&n().dashboard.initPhase===c.bG.Services){try{r.processRepeats(),x.autofitpanels&&r.autoFitPanels(window.innerHeight,x.kiosk),l.K.setupDashboardBindings(r)}catch(e){t((0,d.$l)((0,a.t_)("Dashboard init failed",e))),console.error(e)}if(u.dashboard.modifiedQueries){const{panelId:e,queries:n}=u.dashboard.modifiedQueries;!function(e,t,n,a){const s=t.panels.findIndex((e=>e.id===n));s>-1&&(t.panels[s].targets=a);e((0,p.yD)())}(t,r,e,n)}e.routeName!==c.vq.New?(!function(e){const t={dashboardId:e.id,dashboardName:e.title,dashboardUid:e.uid,folderName:e.meta.folderTitle,eventName:m.MetaAnalyticsEventName.DashboardView};(0,m.reportMetaAnalytics)(t)}(r),b.H.watch(r.uid)):b.H.leave(),t((0,p.dS)(r))}}}},"./public/app/features/inspector/types.ts":(e,t,n)=>{let a;n.d(t,{q:()=>a}),function(e){e.Data="data",e.Meta="meta",e.Error="error",e.Stats="stats",e.JSON="json",e.Query="query",e.Actions="actions"}(a||(a={}))}}]);
//# sourceMappingURL=5042.8128b05ac04b15cbf98d.js.map