"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9782],{79456:(e,t,i)=>{i.r(t),i.d(t,{default:()=>go});var s=i(77813),o=i(76687),n=i(30415),r=i(49622),a=i(51397),l=i(74692),c=i(85999),d=i(59269),h=i(3276),p=i(88254),u=i(352),g=i(33306),f=i(42681),m=i(25596);const y=e=>{let{exploreIdLeft:t,exploreIdRight:i}=e;const[s,n]=(0,o.useState)([]),{query:r}=(0,p.useKBar)(),a=(0,u.I0)(),l=(0,u.v9)(m.p);return(0,o.useEffect)((()=>{const e={name:"Explore",priority:p.Priority.HIGH+1},s=[];l?(s.push({id:"explore/run-query-left",name:"Run query (left)",keywords:"query left",perform:()=>{a((0,f.aA)(t))},section:e}),i&&(s.push({id:"explore/run-query-right",name:"Run query (right)",keywords:"query right",perform:()=>{a((0,f.aA)(i))},section:e}),s.push({id:"explore/split-view-close-left",name:"Close split view left",keywords:"split",perform:()=>{a((0,g.YV)(t))},section:e}),s.push({id:"explore/split-view-close-right",name:"Close split view right",keywords:"split",perform:()=>{a((0,g.YV)(i))},section:e}))):(s.push({id:"explore/run-query",name:"Run query",keywords:"query",perform:()=>{a((0,f.aA)(t))},section:e}),s.push({id:"explore/split-view-open",name:"Open split view",keywords:"split",perform:()=>{a((0,g.bW)())},section:e})),n(s)}),[t,i,l,r,a]),(0,p.useRegisterActions)(r?s:[],[s,r]),null};var x=i(16360),v=i(38826),b=i(28441),w=i(27668),S=i(72e3),R=i(22814),j=i(74624),C=i(32098),z=i(48889),I=i(60861),T=i(86832),k=i(65677),F=i(53508),O=i(77212),D=i(2343),$=i(11263),N=i(27091),H=i(77230),L=i(35263),E=i(70194),P=i(33225),A=i(310),q=i(9897),M=i(80410),_=i(90033),B=i(5034),W=i(35027),Q=i(53185),Z=i(5679),U=i(96690),V=i(20202),G=i(53620),K=i(98277),Y=i(98189),J=i(39756),X=i(86201),ee=i(67880),te=i(45667);var ie=i(52010);function se(e){let{data:t,height:i,width:n,timeZone:r,absoluteRange:a,onChangeTime:l,loadingState:c,annotations:d,onHiddenSeriesChanged:h,splitOpenFn:p,graphStyle:u,tooltipDisplayMode:g=K.f3.Single}=e;const f=(0,w.l4)(),[m,y]=(0,o.useState)(!1),[x,v]=(0,o.useState)(1),b=(0,_.Z)(t),S=(0,o.useRef)(0),R=x+S.current,j=(0,_.Z)(R),[C,z]=(0,o.useState)({defaults:{color:{mode:B.S.PaletteClassic},custom:{drawStyle:K.l8.Line,fillOpacity:0,pointSize:5}},overrides:[]});t&&b&&!(0,W.nl)(b,t,W.Ch)&&(S.current++,j===R&&z(Object.assign({},C,{overrides:[]})));const I=(0,w.wW)(oe),k={from:(0,Q.CQ)(a.from),to:(0,Q.CQ)(a.to),raw:{from:(0,Q.CQ)(a.from),to:(0,Q.CQ)(a.to)}},F=(0,o.useMemo)((()=>{const e=(0,Z.j)((0,X.F)(X.r),"Explore"),i=function(e,t){return(0,te.ZP)(e,(e=>{void 0===e.defaults.custom&&(e.defaults.custom={});const{custom:i}=e.defaults;switch(void 0===i.stacking&&(i.stacking={group:"A"}),t){case"lines":i.drawStyle=K.l8.Line,i.stacking.mode=K.o0.None,i.fillOpacity=0;break;case"bars":i.drawStyle=K.l8.Bars,i.stacking.mode=K.o0.None,i.fillOpacity=100;break;case"points":i.drawStyle=K.l8.Points,i.stacking.mode=K.o0.None,i.fillOpacity=0;break;case"stacked_lines":i.drawStyle=K.l8.Line,i.stacking.mode=K.o0.Normal,i.fillOpacity=100;break;case"stacked_bars":i.drawStyle=K.l8.Bars,i.stacking.mode=K.o0.Normal,i.fillOpacity=100;break;default:throw new Error(`Invalid graph-style: ${t}`)}}))}(C,u);return(0,U.SM)({fieldConfig:i,data:t,timeZone:r,replaceVariables:e=>e,theme:f,fieldConfigRegistry:e})}),[C,u,t,r,f]);(0,o.useEffect)((()=>{if(h){const e=[];F.forEach((t=>{t.fields.map((e=>{var t,i,s;return null===(t=e.config)||void 0===t||null===(i=t.custom)||void 0===i||null===(s=i.hideFrom)||void 0===s?void 0:s.viz})).every(T.identity)&&e.push((0,V.n)(t))})),h(e)}}),[F,h]);const O=m?F:F.slice(0,20),D={eventBus:P.Z,onSplitOpen:p,onToggleSeriesVisibility(e,i){v((e=>e+1)),z((0,ee.N)(e,i,C,t))}};return(0,ie.jsxs)(Y._w,{value:D,children:[F.length>20&&!m&&(0,ie.jsxs)("div",{className:(0,s.cx)([I.timeSeriesDisclaimer]),children:[(0,ie.jsx)(J.J,{className:I.disclaimerIcon,name:"exclamation-triangle"}),"Showing only 20 time series. ",(0,ie.jsx)("span",{className:(0,s.cx)([I.showAllTimeSeries]),onClick:()=>{S.current++,y(!0)},children:`Show all ${F.length}`})]}),(0,ie.jsx)(G.$,{data:{series:O,timeRange:k,structureRev:R,state:c,annotations:d},pluginId:"timeseries",title:"",width:n,height:i,onChangeTimeRange:l,timeZone:r,options:{tooltip:{mode:g,sort:K.As.None},legend:{displayMode:K.jK.List,showLegend:!0,placement:"bottom",calcs:[]}}})]})}const oe=e=>({timeSeriesDisclaimer:s.css`
    label: time-series-disclaimer;
    width: 300px;
    margin: ${e.spacing(1)} auto;
    padding: 10px 0;
    border-radius: ${e.spacing(2)};
    text-align: center;
    background-color: ${e.colors.background.primary};
  `,disclaimerIcon:s.css`
    label: disclaimer-icon;
    color: ${e.colors.warning.main};
    margin-right: ${e.spacing(.5)};
  `,showAllTimeSeries:s.css`
    label: show-all-time-series;
    cursor: pointer;
    color: ${e.colors.text.link};
  `});var ne=i(81377);const re=u.f0.map((e=>({value:e,label:e[0].toUpperCase()+e.slice(1).replace(/_/," ")}))),ae=(0,s.css)({display:"flex",justifyContent:"space-between"});function le(e){const{graphStyle:t,onChangeGraphStyle:i}=e;return(0,ie.jsxs)("div",{className:ae,children:["Graph",(0,ie.jsx)(ne.S,{size:"sm",options:re,value:t,onChange:i})]})}var ce,de=i(91996),he=i(57057),pe=i(25593),ue=(ce=function(e,t){return ce=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},ce(e,t)},function(e,t){function i(){this.constructor=e}ce(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),ge=function(){return ge=Object.assign||function(e){for(var t,i=1,s=arguments.length;i<s;i++)for(var o in t=arguments[i])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ge.apply(this,arguments)},fe={width:"100%",height:"10px",top:"0px",left:"0px",cursor:"row-resize"},me={width:"10px",height:"100%",top:"0px",left:"0px",cursor:"col-resize"},ye={width:"20px",height:"20px",position:"absolute"},xe={top:ge(ge({},fe),{top:"-5px"}),right:ge(ge({},me),{left:void 0,right:"-5px"}),bottom:ge(ge({},fe),{top:void 0,bottom:"-5px"}),left:ge(ge({},me),{left:"-5px"}),topRight:ge(ge({},ye),{right:"-10px",top:"-10px",cursor:"ne-resize"}),bottomRight:ge(ge({},ye),{right:"-10px",bottom:"-10px",cursor:"se-resize"}),bottomLeft:ge(ge({},ye),{left:"-10px",bottom:"-10px",cursor:"sw-resize"}),topLeft:ge(ge({},ye),{left:"-10px",top:"-10px",cursor:"nw-resize"})},ve=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onMouseDown=function(e){t.props.onResizeStart(e,t.props.direction)},t.onTouchStart=function(e){t.props.onResizeStart(e,t.props.direction)},t}return ue(t,e),t.prototype.render=function(){return o.createElement("div",{className:this.props.className||"",style:ge(ge({position:"absolute",userSelect:"none"},xe[this.props.direction]),this.props.replaceStyles||{}),onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart},this.props.children)},t}(o.PureComponent),be=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){function s(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}}(),we=function(){return we=Object.assign||function(e){for(var t,i=1,s=arguments.length;i<s;i++)for(var o in t=arguments[i])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},we.apply(this,arguments)},Se={width:"auto",height:"auto"},Re=function(e,t,i){return Math.max(Math.min(e,i),t)},je=function(e,t){return Math.round(e/t)*t},Ce=function(e,t){return new RegExp(e,"i").test(t)},ze=function(e){return Boolean(e.touches&&e.touches.length)},Ie=function(e,t,i){void 0===i&&(i=0);var s=t.reduce((function(i,s,o){return Math.abs(s-e)<Math.abs(t[i]-e)?o:i}),0),o=Math.abs(t[s]-e);return 0===i||o<i?t[s]:e},Te=function(e){return"auto"===(e=e.toString())||e.endsWith("px")||e.endsWith("%")||e.endsWith("vh")||e.endsWith("vw")||e.endsWith("vmax")||e.endsWith("vmin")?e:e+"px"},ke=function(e,t,i,s){if(e&&"string"==typeof e){if(e.endsWith("px"))return Number(e.replace("px",""));if(e.endsWith("%"))return t*(Number(e.replace("%",""))/100);if(e.endsWith("vw"))return i*(Number(e.replace("vw",""))/100);if(e.endsWith("vh"))return s*(Number(e.replace("vh",""))/100)}return e},Fe=["as","style","className","grid","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],Oe="__resizable_base__",De=function(e){function t(t){var i=e.call(this,t)||this;return i.ratio=1,i.resizable=null,i.parentLeft=0,i.parentTop=0,i.resizableLeft=0,i.resizableRight=0,i.resizableTop=0,i.resizableBottom=0,i.targetLeft=0,i.targetTop=0,i.appendBase=function(){if(!i.resizable||!i.window)return null;var e=i.parentNode;if(!e)return null;var t=i.window.document.createElement("div");return t.style.width="100%",t.style.height="100%",t.style.position="absolute",t.style.transform="scale(0, 0)",t.style.left="0",t.style.flex="0 0 100%",t.classList?t.classList.add(Oe):t.className+=Oe,e.appendChild(t),t},i.removeBase=function(e){var t=i.parentNode;t&&t.removeChild(e)},i.ref=function(e){e&&(i.resizable=e)},i.state={isResizing:!1,width:void 0===(i.propsSize&&i.propsSize.width)?"auto":i.propsSize&&i.propsSize.width,height:void 0===(i.propsSize&&i.propsSize.height)?"auto":i.propsSize&&i.propsSize.height,direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},i.onResizeStart=i.onResizeStart.bind(i),i.onMouseMove=i.onMouseMove.bind(i),i.onMouseUp=i.onMouseUp.bind(i),i}return be(t,e),Object.defineProperty(t.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"window",{get:function(){return this.resizable&&this.resizable.ownerDocument?this.resizable.ownerDocument.defaultView:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||Se},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){var e=0,t=0;if(this.resizable&&this.window){var i=this.resizable.offsetWidth,s=this.resizable.offsetHeight,o=this.resizable.style.position;"relative"!==o&&(this.resizable.style.position="relative"),e="auto"!==this.resizable.style.width?this.resizable.offsetWidth:i,t="auto"!==this.resizable.style.height?this.resizable.offsetHeight:s,this.resizable.style.position=o}return{width:e,height:t}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sizeStyle",{get:function(){var e=this,t=this.props.size,i=function(t){if(void 0===e.state[t]||"auto"===e.state[t])return"auto";if(e.propsSize&&e.propsSize[t]&&e.propsSize[t].toString().endsWith("%")){if(e.state[t].toString().endsWith("%"))return e.state[t].toString();var i=e.getParentSize();return Number(e.state[t].toString().replace("px",""))/i[t]*100+"%"}return Te(e.state[t])};return{width:t&&void 0!==t.width&&!this.state.isResizing?Te(t.width):i("width"),height:t&&void 0!==t.height&&!this.state.isResizing?Te(t.height):i("height")}},enumerable:!1,configurable:!0}),t.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var e=this.appendBase();if(!e)return{width:0,height:0};var t=!1,i=this.parentNode.style.flexWrap;"wrap"!==i&&(t=!0,this.parentNode.style.flexWrap="wrap"),e.style.position="relative",e.style.minWidth="100%",e.style.minHeight="100%";var s={width:e.offsetWidth,height:e.offsetHeight};return t&&(this.parentNode.style.flexWrap=i),this.removeBase(e),s},t.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},t.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},t.prototype.componentDidMount=function(){if(this.resizable&&this.window){var e=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:"auto"!==e.flexBasis?e.flexBasis:void 0})}},t.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},t.prototype.createSizeForCssProperty=function(e,t){var i=this.propsSize&&this.propsSize[t];return"auto"!==this.state[t]||this.state.original[t]!==e||void 0!==i&&"auto"!==i?e:"auto"},t.prototype.calculateNewMaxFromBoundary=function(e,t){var i,s,o=this.props.boundsByDirection,n=this.state.direction,r=o&&Ce("left",n),a=o&&Ce("top",n);if("parent"===this.props.bounds){var l=this.parentNode;l&&(i=r?this.resizableRight-this.parentLeft:l.offsetWidth+(this.parentLeft-this.resizableLeft),s=a?this.resizableBottom-this.parentTop:l.offsetHeight+(this.parentTop-this.resizableTop))}else"window"===this.props.bounds?this.window&&(i=r?this.resizableRight:this.window.innerWidth-this.resizableLeft,s=a?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(i=r?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),s=a?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return i&&Number.isFinite(i)&&(e=e&&e<i?e:i),s&&Number.isFinite(s)&&(t=t&&t<s?t:s),{maxWidth:e,maxHeight:t}},t.prototype.calculateNewSizeFromDirection=function(e,t){var i=this.props.scale||1,s=this.props.resizeRatio||1,o=this.state,n=o.direction,r=o.original,a=this.props,l=a.lockAspectRatio,c=a.lockAspectRatioExtraHeight,d=a.lockAspectRatioExtraWidth,h=r.width,p=r.height,u=c||0,g=d||0;return Ce("right",n)&&(h=r.width+(e-r.x)*s/i,l&&(p=(h-g)/this.ratio+u)),Ce("left",n)&&(h=r.width-(e-r.x)*s/i,l&&(p=(h-g)/this.ratio+u)),Ce("bottom",n)&&(p=r.height+(t-r.y)*s/i,l&&(h=(p-u)*this.ratio+g)),Ce("top",n)&&(p=r.height-(t-r.y)*s/i,l&&(h=(p-u)*this.ratio+g)),{newWidth:h,newHeight:p}},t.prototype.calculateNewSizeFromAspectRatio=function(e,t,i,s){var o=this.props,n=o.lockAspectRatio,r=o.lockAspectRatioExtraHeight,a=o.lockAspectRatioExtraWidth,l=void 0===s.width?10:s.width,c=void 0===i.width||i.width<0?e:i.width,d=void 0===s.height?10:s.height,h=void 0===i.height||i.height<0?t:i.height,p=r||0,u=a||0;if(n){var g=(d-p)*this.ratio+u,f=(h-p)*this.ratio+u,m=(l-u)/this.ratio+p,y=(c-u)/this.ratio+p,x=Math.max(l,g),v=Math.min(c,f),b=Math.max(d,m),w=Math.min(h,y);e=Re(e,x,v),t=Re(t,b,w)}else e=Re(e,l,c),t=Re(t,d,h);return{newWidth:e,newHeight:t}},t.prototype.setBoundingClientRect=function(){if("parent"===this.props.bounds){var e=this.parentNode;if(e){var t=e.getBoundingClientRect();this.parentLeft=t.left,this.parentTop=t.top}}if(this.props.bounds&&"string"!=typeof this.props.bounds){var i=this.props.bounds.getBoundingClientRect();this.targetLeft=i.left,this.targetTop=i.top}if(this.resizable){var s=this.resizable.getBoundingClientRect(),o=s.left,n=s.top,r=s.right,a=s.bottom;this.resizableLeft=o,this.resizableRight=r,this.resizableTop=n,this.resizableBottom=a}},t.prototype.onResizeStart=function(e,t){if(this.resizable&&this.window){var i,s=0,o=0;if(e.nativeEvent&&function(e){return Boolean((e.clientX||0===e.clientX)&&(e.clientY||0===e.clientY))}(e.nativeEvent)?(s=e.nativeEvent.clientX,o=e.nativeEvent.clientY):e.nativeEvent&&ze(e.nativeEvent)&&(s=e.nativeEvent.touches[0].clientX,o=e.nativeEvent.touches[0].clientY),this.props.onResizeStart)if(this.resizable)if(!1===this.props.onResizeStart(e,t,this.resizable))return;this.props.size&&(void 0!==this.props.size.height&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),void 0!==this.props.size.width&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio="number"==typeof this.props.lockAspectRatio?this.props.lockAspectRatio:this.size.width/this.size.height;var n=this.window.getComputedStyle(this.resizable);if("auto"!==n.flexBasis){var r=this.parentNode;if(r){var a=this.window.getComputedStyle(r).flexDirection;this.flexDir=a.startsWith("row")?"row":"column",i=n.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var l={original:{x:s,y:o,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:we(we({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(e.target).cursor||"auto"}),direction:t,flexBasis:i};this.setState(l)}},t.prototype.onMouseMove=function(e){var t=this;if(this.state.isResizing&&this.resizable&&this.window){if(this.window.TouchEvent&&ze(e))try{e.preventDefault(),e.stopPropagation()}catch(e){}var i=this.props,s=i.maxWidth,o=i.maxHeight,n=i.minWidth,r=i.minHeight,a=ze(e)?e.touches[0].clientX:e.clientX,l=ze(e)?e.touches[0].clientY:e.clientY,c=this.state,d=c.direction,h=c.original,p=c.width,u=c.height,g=this.getParentSize(),f=function(e,t,i,s,o,n,r){return s=ke(s,e.width,t,i),o=ke(o,e.height,t,i),n=ke(n,e.width,t,i),r=ke(r,e.height,t,i),{maxWidth:void 0===s?void 0:Number(s),maxHeight:void 0===o?void 0:Number(o),minWidth:void 0===n?void 0:Number(n),minHeight:void 0===r?void 0:Number(r)}}(g,this.window.innerWidth,this.window.innerHeight,s,o,n,r);s=f.maxWidth,o=f.maxHeight,n=f.minWidth,r=f.minHeight;var m=this.calculateNewSizeFromDirection(a,l),y=m.newHeight,x=m.newWidth,v=this.calculateNewMaxFromBoundary(s,o);this.props.snap&&this.props.snap.x&&(x=Ie(x,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(y=Ie(y,this.props.snap.y,this.props.snapGap));var b=this.calculateNewSizeFromAspectRatio(x,y,{width:v.maxWidth,height:v.maxHeight},{width:n,height:r});if(x=b.newWidth,y=b.newHeight,this.props.grid){var w=je(x,this.props.grid[0]),S=je(y,this.props.grid[1]),R=this.props.snapGap||0;x=0===R||Math.abs(w-x)<=R?w:x,y=0===R||Math.abs(S-y)<=R?S:y}var j={width:x-h.width,height:y-h.height};if(p&&"string"==typeof p)if(p.endsWith("%"))x=x/g.width*100+"%";else if(p.endsWith("vw")){x=x/this.window.innerWidth*100+"vw"}else if(p.endsWith("vh")){x=x/this.window.innerHeight*100+"vh"}if(u&&"string"==typeof u)if(u.endsWith("%"))y=y/g.height*100+"%";else if(u.endsWith("vw")){y=y/this.window.innerWidth*100+"vw"}else if(u.endsWith("vh")){y=y/this.window.innerHeight*100+"vh"}var C={width:this.createSizeForCssProperty(x,"width"),height:this.createSizeForCssProperty(y,"height")};"row"===this.flexDir?C.flexBasis=C.width:"column"===this.flexDir&&(C.flexBasis=C.height),(0,pe.flushSync)((function(){t.setState(C)})),this.props.onResize&&this.props.onResize(e,d,this.resizable,j)}},t.prototype.onMouseUp=function(e){var t=this.state,i=t.isResizing,s=t.direction,o=t.original;if(i&&this.resizable){var n={width:this.size.width-o.width,height:this.size.height-o.height};this.props.onResizeStop&&this.props.onResizeStop(e,s,this.resizable,n),this.props.size&&this.setState(this.props.size),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:we(we({},this.state.backgroundStyle),{cursor:"auto"})})}},t.prototype.updateSize=function(e){this.setState({width:e.width,height:e.height})},t.prototype.renderResizer=function(){var e=this,t=this.props,i=t.enable,s=t.handleStyles,n=t.handleClasses,r=t.handleWrapperStyle,a=t.handleWrapperClass,l=t.handleComponent;if(!i)return null;var c=Object.keys(i).map((function(t){return!1!==i[t]?o.createElement(ve,{key:t,direction:t,onResizeStart:e.onResizeStart,replaceStyles:s&&s[t],className:n&&n[t]},l&&l[t]?l[t]:null):null}));return o.createElement("div",{className:a,style:r},c)},t.prototype.render=function(){var e=this,t=Object.keys(this.props).reduce((function(t,i){return-1!==Fe.indexOf(i)||(t[i]=e.props[i]),t}),{}),i=we(we(we({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(i.flexBasis=this.state.flexBasis);var s=this.props.as||"div";return o.createElement(s,we({ref:this.ref,style:i,className:this.props.className},t),this.state.isResizing&&o.createElement("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer())},t.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},t}(o.PureComponent),$e=i(20821);const Ne=e=>s.keyframes`
  0% {
    transform: translateY(${e.components.horizontalDrawer.defaultHeight}px);
  }

  100% {
    transform: translateY(0px);
  }
`,He=(0,$e.B)((e=>({container:s.css`
      position: fixed !important;
      bottom: 0;
      background: ${e.colors.background.primary};
      border-top: 1px solid ${e.colors.border.weak};
      margin: ${e.spacing(0,-2,0,-2)};
      box-shadow: ${e.shadows.z3};
      z-index: ${e.zIndex.navbarFixed};
    `,drawerActive:s.css`
      opacity: 1;
      animation: 0.5s ease-out ${Ne(e)};
    `,rzHandle:s.css`
      background: ${e.colors.secondary.main};
      transition: 0.3s background ease-in-out;
      position: relative;
      width: 200px !important;
      height: 7px !important;
      left: calc(50% - 100px) !important;
      top: -4px !important;
      cursor: grab;
      border-radius: 4px;
      &:hover {
        background: ${e.colors.secondary.shade};
      }
    `})));function Le(e){const{width:t,children:i,onResize:o}=e,n=(0,w.l4)(),r=He(n),a=`${t+31.5}px`;return(0,ie.jsx)(De,{className:(0,s.cx)(r.container,r.drawerActive),defaultSize:{width:a,height:`${n.components.horizontalDrawer.defaultHeight}px`},handleClasses:{top:r.rzHandle},enable:{top:!0,right:!1,bottom:!1,left:!1,topRight:!1,bottomRight:!1,bottomLeft:!1,topLeft:!1},maxHeight:"100vh",maxWidth:a,minWidth:a,onResize:o,children:i})}var Ee=i(44014),Pe=i(55523),Ae=i(51414),qe=i(95506),Me=i(94073);const _e={runQueries:f.aA},Be=(0,n.connect)((function(e,t){let{exploreId:i}=t;const s=e.explore[i],{loading:o,queryResponse:n}=s;return{loading:o,queryResponse:n}}),_e)((function(e){var t;const{loading:i,width:s,onClose:n,queryResponse:r,timeZone:a}=e,l=(null==r?void 0:r.series)||[],c=null==r?void 0:r.error;(0,o.useEffect)((()=>{(0,$.ff)("grafana_explore_query_inspector_opened")}),[]);const d={label:"Stats",value:"stats",icon:"chart-line",content:(0,ie.jsx)(qe.f,{data:r,timeZone:null==r||null===(t=r.request)||void 0===t?void 0:t.timezone})},h={label:"JSON",value:"json",icon:"brackets-curly",content:(0,ie.jsx)(Ae.W,{data:r,onClose:n})},p={label:"Data",value:"data",icon:"database",content:(0,ie.jsx)(Ee.E,{data:l,isLoading:i,options:{withTransforms:!1,withFieldConfig:!1},timeZone:a,app:de.zj.Explore})},u=[d,{label:"Query",value:"query",icon:"info-circle",content:(0,ie.jsx)(Me.D,{data:l,onRefreshQuery:()=>e.runQueries(e.exploreId)})},h,p];if(c){const e={label:"Error",value:"error",icon:"exclamation-triangle",content:(0,ie.jsx)(Pe.l,{error:c})};u.push(e)}return(0,ie.jsx)(Le,{width:s,children:(0,ie.jsx)(he.W,{tabs:u,onClose:n,closeIconTooltip:"Close query inspector"})})}));var We=i(10661),Qe=i(67273),Ze=i(35695),Ue=i(21733),Ve=i(4651),Ge=i(5562),Ke=i(31271),Ye=i(19926),Je=i(42246),Xe=i(33414),et=i(18259),tt=i(14238),it=i(34222),st=i(56670),ot=i(33097);function nt(e){const{onClick:t,isSynced:i}=e;return(0,ie.jsx)(ot.u,{content:()=>{const{isSynced:t}=e,i=t?"Unsync all views":"Sync all views to this time range";return(0,ie.jsx)(ie.Fragment,{children:i})},placement:"bottom",children:(0,ie.jsx)(Ve.h,{icon:"link",variant:i?"active":"default","aria-label":i?"Synced times":"Unsynced times",onClick:t})})}function rt(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class at extends o.Component{constructor(){super(...arguments),rt(this,"onMoveTimePicker",(e=>{const{range:t,onChangeTime:i,timeZone:s}=this.props,{from:o,to:n}=(0,st.e)(e,t);i({from:(0,Q.GY)(s,o),to:(0,Q.GY)(s,n)})})),rt(this,"onMoveForward",(()=>this.onMoveTimePicker(1))),rt(this,"onMoveBack",(()=>this.onMoveTimePicker(-1))),rt(this,"onChangeTimePicker",(e=>{const t=tt.isMathString(e.raw.from)?e.raw.from:e.from,i=tt.isMathString(e.raw.to)?e.raw.to:e.to;this.props.onChangeTime({from:t,to:i}),(0,$.ff)("grafana_explore_time_picker_time_range_changed",{timeRangeFrom:t,timeRangeTo:i})})),rt(this,"onZoom",(()=>{const{range:e,onChangeTime:t,timeZone:i}=this.props,{from:s,to:o}=(0,st.h)(e,2);t({from:(0,Q.GY)(i,s),to:(0,Q.GY)(i,o)})}))}render(){const{range:e,timeZone:t,fiscalYearStartMonth:i,splitted:s,syncedTimes:o,onChangeTimeSync:n,hideText:r,onChangeTimeZone:a,onChangeFiscalYearStartMonth:l}=this.props,c=s?(0,ie.jsx)(nt,{onClick:n,isSynced:o}):void 0,d={value:e,timeZone:t,fiscalYearStartMonth:i,onMoveBackward:this.onMoveBack,onMoveForward:this.onMoveForward,onZoom:this.onZoom,hideText:r};return(0,ie.jsx)(it.a,Object.assign({},d,{timeSyncButton:c,isSynced:o,widthOverride:s?window.innerWidth/2:void 0,onChange:this.onChangeTimePicker,onChangeTimeZone:a,onChangeFiscalYearStartMonth:l}))}}var lt=i(73093),ct=i(37263);function dt(e){const{start:t,pause:i,resume:s,isLive:o,isPaused:n,stop:r,splitted:a}=e,l=o&&!n?"active":"default",c=o?n?s:i:t;return(0,ie.jsxs)(ct.h,{children:[(0,ie.jsx)(ot.u,{content:o&&!n?(0,ie.jsx)(ie.Fragment,{children:"Pause the live stream"}):(0,ie.jsx)(ie.Fragment,{children:"Start live stream your logs"}),placement:"bottom",children:(0,ie.jsx)(Ve.h,{iconOnly:a,variant:l,icon:!o||n?"play":"pause",onClick:c,children:o&&n?"Paused":"Live"})}),(0,ie.jsx)(lt.Z,{mountOnEnter:!0,unmountOnExit:!0,timeout:100,in:o,classNames:{enter:ht.stopButtonEnter,enterActive:ht.stopButtonEnterActive,exit:ht.stopButtonExit,exitActive:ht.stopButtonExitActive},children:(0,ie.jsx)(ot.u,{content:(0,ie.jsx)(ie.Fragment,{children:"Stop and exit the live stream"}),placement:"bottom",children:(0,ie.jsx)(Ve.h,{variant:l,onClick:r,icon:"square-shape"})})})]})}const ht={stopButtonEnter:s.css`
    label: stopButtonEnter;
    width: 0;
    opacity: 0;
    overflow: hidden;
  `,stopButtonEnterActive:s.css`
    label: stopButtonEnterActive;
    opacity: 1;
    width: 32px;
  `,stopButtonExit:s.css`
    label: stopButtonExit;
    width: 32px;
    opacity: 1;
    overflow: hidden;
  `,stopButtonExitActive:s.css`
    label: stopButtonExitActive;
    opacity: 0;
    width: 0;
  `};var pt=i(75783),ut=i(24178);function gt(e){const t=function(e){const t=(0,u.I0)(),i=(0,o.useCallback)((()=>{t((0,f.sQ)({exploreId:e,isPaused:!0}))}),[e,t]),s=(0,o.useCallback)((()=>{t((0,f.sQ)({exploreId:e,isPaused:!1}))}),[e,t]),n=(0,o.useCallback)((()=>{i(),t((0,ut.oz)(e,Ze.dP.offOption.value)),t((0,f.aA)(e))}),[e,t,i]),r=(0,o.useCallback)((()=>{t((0,ut.oz)(e,Ze.dP.liveOption.value))}),[e,t]);return{pause:i,resume:s,stop:n,start:r}}(e.exploreId);return e.children(t)}function ft(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const mt=(0,o.lazy)((()=>i.e(5872).then(i.bind(i,35872)).then((e=>{let{AddToDashboard:t}=e;return{default:t}}))));class yt extends o.PureComponent{constructor(){var e;super(...arguments),e=this,ft(this,"onChangeDatasource",(async e=>{const{changeDatasource:t,exploreId:i}=this.props;t(i,e.uid,{importQueries:!0})})),ft(this,"onRunQuery",(function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{runQueries:i,cancelQueries:s,exploreId:o}=e.props;return t?s(o):i(o)})),ft(this,"onChangeRefreshInterval",(e=>{const{changeRefreshInterval:t,exploreId:i}=this.props;t(i,e)})),ft(this,"onChangeTimeSync",(()=>{const{syncTimes:e,exploreId:t}=this.props;e(t)})),ft(this,"onCopyShortLink",(async()=>{await(0,Ye.L)(window.location.href),(0,$.ff)("grafana_explore_shortened_link_clicked")})),ft(this,"onOpenSplitView",(()=>{const{split:e}=this.props;e(),(0,$.ff)("grafana_explore_split_view_opened",{origin:"menu"})})),ft(this,"onCloseSplitView",(()=>{const{closeSplit:e,exploreId:t}=this.props;e(t),(0,$.ff)("grafana_explore_split_view_closed")})),ft(this,"renderRefreshPicker",(e=>{const{loading:t,refreshInterval:i,isLive:s}=this.props;let o,n=t?"Cancel":"Run query",r="108px";return e&&(o=n,n=void 0,r="35px"),(0,ie.jsx)(Ze.dP,{onIntervalChanged:this.onChangeRefreshInterval,value:i,isLoading:t,text:n,tooltip:o,intervals:(0,Xe.$t)().getValidIntervals(Ze.o5),isLive:s,onRefresh:()=>this.onRunQuery(t),noIntervalPicker:s,primary:!0,width:r})}))}render(){const{datasourceMissing:e,exploreId:t,loading:i,range:s,timeZone:n,fiscalYearStartMonth:r,splitted:a,syncedTimes:l,refreshInterval:d,onChangeTime:h,hasLiveOption:p,isLive:g,isPaused:f,containerWidth:m,onChangeTimeZone:y,onChangeFiscalYearStartMonth:x,topOfViewRef:v}=this.props,b=(a?m<700:m<800)||!1,w=a||m<1210,S=Ke.Vt.hasAccess(u.bW.DashboardsCreate,Ke.Vt.isEditor)||Ke.Vt.hasAccess(u.bW.DashboardsWrite,Ke.Vt.isEditor);return(0,ie.jsx)("div",{ref:v,children:(0,ie.jsx)(Ue.X,{"aria-label":"Explore toolbar",title:t===c.K.left?"Explore":void 0,pageIcon:t===c.K.left?"compass":void 0,leftItems:[t===c.K.left&&(0,ie.jsx)(Je.u,{tooltip:"Copy shortened link",icon:"share-alt",onClick:this.onCopyShortLink,"aria-label":"Copy shortened link"},"share"),!e&&(0,ie.jsx)(We.q,{mixed:!0===Qe.v.featureToggles.exploreMixedDatasource,onChange:this.onChangeDatasource,current:this.props.datasourceRef,hideTextValue:b,width:b?8:void 0},`${t}-ds-picker`)].filter(Boolean),children:(0,ie.jsxs)(ie.Fragment,{children:[a?(0,ie.jsx)(Ve.h,{tooltip:"Close split pane",onClick:this.onCloseSplitView,icon:"times",children:"Close"}):(0,ie.jsx)(Ve.h,{tooltip:"Split the pane",onClick:this.onOpenSplitView,icon:"columns",disabled:g,children:"Split"}),Qe.v.featureToggles.explore2Dashboard&&S&&(0,ie.jsx)(o.Suspense,{fallback:null,children:(0,ie.jsx)(mt,{exploreId:t})}),!g&&(0,ie.jsx)(at,{exploreId:t,range:s,timeZone:n,fiscalYearStartMonth:r,onChangeTime:h,splitted:a,syncedTimes:l,onChangeTimeSync:this.onChangeTimeSync,hideText:w,onChangeTimeZone:y,onChangeFiscalYearStartMonth:x}),this.renderRefreshPicker(w),d&&(0,ie.jsx)(Ge.F,{func:this.onRunQuery,interval:d,loading:i}),p&&(0,ie.jsx)(gt,{exploreId:t,children:e=>{const t=Object.assign({},e,{start:()=>{(0,$.ff)("grafana_explore_logs_live_tailing_clicked",{datasourceType:this.props.datasourceType}),e.start()}});return(0,ie.jsx)(dt,{splitted:a,isLive:g,isPaused:f,start:t.start,pause:t.pause,resume:t.resume,stop:t.stop})}})]})})})}}const xt={changeDatasource:pt.zU,changeRefreshInterval:ut.oz,cancelQueries:f.ci,runQueries:f.aA,closeSplit:g.YV,split:g.bW,syncTimes:ut.mG,onChangeTimeZone:et.YT,onChangeFiscalYearStartMonth:et.rf},vt=(0,n.connect)(((e,t)=>{var i;let{exploreId:s}=t;const{syncedTimes:o}=e.explore,n=e.explore[s],{datasourceInstance:r,datasourceMissing:a,range:l,refreshInterval:c,loading:d,isLive:h,isPaused:p,containerWidth:u}=n,g=!(null==r||null===(i=r.meta)||void 0===i||!i.streaming);return{datasourceMissing:a,datasourceRef:null==r?void 0:r.getRef(),datasourceType:null==r?void 0:r.type,loading:d,range:l,timeZone:(0,I.Z)(e.user),fiscalYearStartMonth:(0,I.i)(e.user),splitted:(0,m.p)(e),refreshInterval:c,hasLiveOption:g,isLive:h,isPaused:p,syncedTimes:o,containerWidth:u}}),xt)(yt);var bt=i(65039),wt=i(32172),St=i.n(wt),Rt=i(84738),jt=i(55312),Ct=i(79448),zt=i(93197),It=i(89177);const Tt=e=>{let{timeInMs:t,className:i,humanize:s}=e;return(0,ie.jsx)("span",{className:i,children:kt(t,s)})},kt=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=e/1e3;if(!t)return`${i.toFixed(1)}s`;const s=(0,Q.Ks)(i,"seconds"),o=s.hours(),n=s.minutes(),r=s.seconds();return o?`${o}h ${n}m ${r}s`:n?`${n}m ${r}s`:`${r}s`},Ft=e=>{let{resetKey:t,humanize:i,className:s}=e;const[n,r]=(0,o.useState)(0);return(0,It.Z)((()=>r(n+150)),150),(0,o.useEffect)((()=>r(0)),[t]),(0,ie.jsx)(Tt,{timeInMs:n,className:s,humanize:i})};var Ot;function Dt(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class $t extends o.PureComponent{constructor(e){super(e),Dt(this,"liveEndDiv",null),Dt(this,"scrollContainerRef",o.createRef()),Dt(this,"onScroll",(e=>{const{isPaused:t,onPause:i}=this.props,{scrollTop:s,clientHeight:o,scrollHeight:n}=e.currentTarget;n-(s+o)>=5&&!t&&i()})),Dt(this,"rowsToRender",(()=>{const{isPaused:e}=this.props;let{logRowsToRender:t=[]}=this.state;return e||(t=t.slice(-100)),t})),this.state={logRowsToRender:e.logRows}}static getDerivedStateFromProps(e,t){return e.isPaused?null:{logRowsToRender:e.logRows}}render(){const{theme:e,timeZone:t,onPause:i,onResume:o,isPaused:n}=this.props,r=(e=>({logsRowsLive:s.css`
    label: logs-rows-live;
    font-family: ${e.typography.fontFamilyMonospace};
    font-size: ${e.typography.bodySmall.fontSize};
    display: flex;
    flex-flow: column nowrap;
    height: 60vh;
    overflow-y: scroll;
    :first-child {
      margin-top: auto !important;
    }
  `,logsRowFade:s.css`
    label: logs-row-fresh;
    color: ${e.colors.text};
    background-color: ${St()(e.colors.info.transparent).setAlpha(.25).toString()};
    animation: fade 1s ease-out 1s 1 normal forwards;
    @keyframes fade {
      from {
        background-color: ${St()(e.colors.info.transparent).setAlpha(.25).toString()};
      }
      to {
        background-color: transparent;
      }
    }
  `,logsRowsIndicator:s.css`
    font-size: ${e.typography.h6.fontSize};
    padding-top: ${e.spacing(1)};
    display: flex;
    align-items: center;
  `,button:s.css`
    margin-right: ${e.spacing(1)};
  `,fullWidth:s.css`
    width: 100%;
  `}))(e),{logsRow:a,logsRowLocalTime:l,logsRowMessage:c}=(0,zt.h)(e);return(0,ie.jsxs)("div",{children:[(0,ie.jsx)("table",{className:r.fullWidth,children:(0,ie.jsxs)("tbody",{onScroll:n?void 0:this.onScroll,className:r.logsRowsLive,ref:this.scrollContainerRef,children:[this.rowsToRender().map((e=>(0,ie.jsxs)("tr",{className:(0,s.cx)(a,r.logsRowFade),children:[(0,ie.jsx)("td",{className:l,children:(0,Rt.dq)(e.timeEpochMs,{timeZone:t})}),(0,ie.jsx)("td",{className:c,children:e.hasAnsi?(0,ie.jsx)(Ct.Q,{value:e.raw}):e.entry})]},e.uid))),(0,ie.jsx)("tr",{ref:e=>{var t,i;(this.liveEndDiv=e,this.liveEndDiv&&null!==(t=this.scrollContainerRef.current)&&void 0!==t&&t.scrollTo&&!n)&&(null===(i=this.scrollContainerRef.current)||void 0===i||i.scrollTo(0,this.scrollContainerRef.current.scrollHeight))}})]})}),(0,ie.jsxs)("div",{className:r.logsRowsIndicator,children:[(0,ie.jsxs)(jt.zx,{variant:"secondary",onClick:n?o:i,className:r.button,children:[(0,ie.jsx)(J.J,{name:n?"play":"pause"})," ",n?"Resume":"Pause"]}),(0,ie.jsxs)(jt.zx,{variant:"secondary",onClick:this.props.stopLive,className:r.button,children:[Ot||(Ot=(0,ie.jsx)(J.J,{name:"square-shape",size:"lg",type:"mono"})),"  Exit live mode"]}),n||(0,ie.jsxs)("span",{children:["Last line received: ",(0,ie.jsx)(Ft,{resetKey:this.props.logRows,humanize:!0})," ago"]})]})]})}}const Nt=(0,w.HE)($t);var Ht=i(31757),Lt=i(23277),Et=i(50385),Pt=i(46286),At=i(83427),qt=i(97269),Mt=i(68707),_t=i(23790);const Bt=e=>({metaContainer:s.css`
    flex: 1;
    color: ${e.colors.text.secondary};
    margin-bottom: ${e.spacing(2)};
    min-width: 30%;
    display: flex;
    flex-wrap: wrap;
  `,metaItem:s.css`
    margin-right: ${e.spacing(2)};
    margin-top: ${e.spacing(.5)};
    display: flex;
    align-items: baseline;

    .logs-meta-item__error {
      color: ${e.colors.error.text};
    }
  `,metaLabel:s.css`
    margin-right: calc(${e.spacing(2)} / 2);
    font-size: ${e.typography.bodySmall.fontSize};
    font-weight: ${e.typography.fontWeightMedium};
  `,metaValue:s.css`
    font-family: ${e.typography.fontFamilyMonospace};
    font-size: ${e.typography.bodySmall.fontSize};
  `}),Wt=(0,o.memo)((function(e){const t=(0,w.wW)(Bt),{label:i,value:s}=e;return(0,ie.jsxs)("div",{"data-testid":"meta-info-text-item",className:t.metaItem,children:[i&&(0,ie.jsxs)("span",{className:t.metaLabel,children:[i,":"]}),(0,ie.jsx)("span",{className:t.metaValue,children:s})]})})),Qt=(0,o.memo)((function(e){const t=(0,w.wW)(Bt),{metaItems:i}=e;return(0,ie.jsx)("div",{className:t.metaContainer,"data-testid":"meta-info-text",children:i.map(((e,t)=>(0,ie.jsx)(Wt,{label:e.label,value:e.value},`${t}-${e.label}`)))})})),Zt=o.memo((e=>{let{meta:t,dedupStrategy:i,dedupCount:s,showDetectedFields:o,clearDetectedFields:n,hasUnescapedContent:r,forceEscape:a,onEscapeNewlines:l,logRows:c}=e;const d=[...t];return i!==bt.Y4.none&&d.push({label:"Dedup count",value:s,kind:bt.Ku.Number}),c.some((e=>e.entry.length>_t.n))&&d.push({label:"Info",value:"Logs with more than 100,000 characters could not be parsed and highlighted",kind:bt.Ku.String}),(null==o?void 0:o.length)>0&&d.push({label:"Showing only detected fields",value:Ut(o,bt.Ku.LabelsMap)},{label:"",value:(0,ie.jsx)(jt.zx,{variant:"secondary",size:"sm",onClick:n,children:"Show original line"})}),r&&d.push({label:"Your logs might have incorrectly escaped content",value:(0,ie.jsx)(ot.u,{content:"Fix incorrectly escaped newline and tab sequences in log lines. Manually review the results to confirm that the replacements are correct.",placement:"right",children:(0,ie.jsx)(jt.zx,{variant:"secondary",size:"sm",onClick:l,children:a?"Remove escaping":"Escape newlines"})})}),(0,ie.jsx)(ie.Fragment,{children:d&&(0,ie.jsx)(Qt,{metaItems:d.map((e=>({label:e.label,value:"kind"in e?Ut(e.value,e.kind):e.value})))})})}));function Ut(e,t){return t===bt.Ku.LabelsMap?(0,ie.jsx)(Mt.j,{labels:e}):t===bt.Ku.Error?(0,ie.jsx)("span",{className:"logs-meta-item__error",children:e}):e}Zt.displayName="LogsMetaRow";var Vt,Gt=i(55816),Kt=i(11444);function Yt(e){let{pages:t,currentPageIndex:i,oldestLogsFirst:o,timeZone:n,loading:r,changeTime:a}=e;const l=e=>`${(0,Rt.dq)(e,{format:Kt.U6.interval.second,timeZone:n})}`,c=(e,t)=>{if(i===t&&r)return Vt||(Vt=(0,ie.jsx)(Gt.$,{}));return`${l(o?e.logsRange.from:e.logsRange.to)} — ${l(o?e.logsRange.to:e.logsRange.from)}`},d=(0,w.l4)(),h=Jt(d,r);return(0,ie.jsx)(H.$,{autoHide:!0,children:(0,ie.jsx)("div",{className:h.pagesWrapper,"data-testid":"logsNavigationPages",children:(0,ie.jsx)("div",{className:h.pagesContainer,children:t.map(((e,t)=>(0,ie.jsxs)("div",{"data-testid":`page${t+1}`,className:h.page,onClick:()=>{(0,$.ff)("grafana_explore_logs_pagination_clicked",{pageType:"page",pageNumber:t+1}),!r&&a({from:e.queryRange.from,to:e.queryRange.to})},children:[(0,ie.jsx)("div",{className:(0,s.cx)(h.line,{selectedBg:i===t})}),(0,ie.jsx)("div",{className:(0,s.cx)(h.time,{selectedText:i===t}),children:c(e,t)})]},e.queryRange.to)))})})})}const Jt=(e,t)=>({pagesWrapper:s.css`
      height: 100%;
      padding-left: ${e.spacing(.5)};
      display: flex;
      flex-direction: column;
      overflow-y: scroll;
      &::after {
        content: '';
        display: block;
        background: repeating-linear-gradient(
          135deg,
          ${e.colors.background.primary},
          ${e.colors.background.primary} 5px,
          ${e.colors.background.secondary} 5px,
          ${e.colors.background.secondary} 15px
        );
        width: 3px;
        height: inherit;
        margin-bottom: 8px;
      }
    `,pagesContainer:s.css`
      display: flex;
      padding: 0;
      flex-direction: column;
    `,page:s.css`
      display: flex;
      margin: ${e.spacing(2)} 0;
      cursor: ${t?"auto":"pointer"};
      white-space: normal;
      .selectedBg {
        background: ${e.colors.primary.main};
      }
      .selectedText {
        color: ${e.colors.primary.main};
      }
    `,line:s.css`
      width: 3px;
      height: 100%;
      align-items: center;
      background: ${e.colors.text.secondary};
    `,time:s.css`
      width: 60px;
      min-height: 80px;
      font-size: ${e.v1.typography.size.sm};
      padding-left: ${e.spacing(.5)};
      display: flex;
      align-items: center;
    `});var Xt,ei,ti;function ii(e){let{absoluteRange:t,logsSortOrder:i,timeZone:s,loading:n,onChangeTime:r,scrollToTopLogs:a,visibleRange:l,queries:c,clearCache:d,addResultsToCache:h}=e;const[p,u]=(0,o.useState)([]),[g,f]=(0,o.useState)(0),m=(0,o.useRef)(),y=(0,o.useRef)(),x=(0,o.useRef)(0),v=i===bt.UV.Ascending,b=v?g===p.length-1:0===g,S=v?0===g:g===p.length-1,R=(0,w.l4)(),j=oi(R,v,n);(0,o.useEffect)((()=>{const e={logsRange:l,queryRange:t};let s=[];if((0,T.isEqual)(y.current,t)&&(0,T.isEqual)(m.current,c)){u((t=>(s=t.filter((t=>!(0,T.isEqual)(e.queryRange,t.queryRange))),s=[...s,e].sort(((e,t)=>z(e,t,i))),s)));const o=s.findIndex((e=>e.queryRange.to===t.to));f(o)}else d(),u([e]),f(0),m.current=c,x.current=t.to-t.from;h()}),[l,t,i,c,d,h]),(0,o.useEffect)((()=>{d()}),[]);const C=e=>{let{from:t,to:i}=e;y.current={from:t,to:i},r({from:t,to:i})},z=(e,t,i)=>i===bt.UV.Ascending?e.queryRange.to>t.queryRange.to?1:-1:e.queryRange.to>t.queryRange.to?-1:1,I=(0,ie.jsx)(jt.zx,{"data-testid":"olderLogsButton",className:j.navButton,variant:"secondary",onClick:()=>{if((0,$.ff)("grafana_explore_logs_pagination_clicked",{pageType:"olderLogsButton"}),S)C({from:l.from-x.current,to:l.from});else{const e=v?-1:1;C({from:p[g+e].queryRange.from,to:p[g+e].queryRange.to})}},disabled:n,children:(0,ie.jsxs)("div",{className:j.navButtonContent,children:[n?Xt||(Xt=(0,ie.jsx)(Gt.$,{})):(0,ie.jsx)(J.J,{name:v?"angle-up":"angle-down",size:"lg"}),"Older logs"]})}),k=(0,ie.jsx)(jt.zx,{"data-testid":"newerLogsButton",className:j.navButton,variant:"secondary",onClick:()=>{if((0,$.ff)("grafana_explore_logs_pagination_clicked",{pageType:"newerLogsButton"}),!b){const e=v?1:-1;C({from:p[g+e].queryRange.from,to:p[g+e].queryRange.to})}},disabled:n||b,children:(0,ie.jsxs)("div",{className:j.navButtonContent,children:[n&&(ei||(ei=(0,ie.jsx)(Gt.$,{}))),b||n?null:(0,ie.jsx)(J.J,{name:v?"angle-down":"angle-up",size:"lg"}),b?"Start of range":"Newer logs"]})});return(0,ie.jsxs)("div",{className:j.navContainer,children:[v?I:k,(0,ie.jsx)(Yt,{pages:p,currentPageIndex:g,oldestLogsFirst:v,timeZone:s,loading:n,changeTime:C}),v?k:I,(0,ie.jsx)(jt.zx,{"data-testid":"scrollToTop",className:j.scrollToTopButton,variant:"secondary",onClick:a,title:"Scroll to top",children:ti||(ti=(0,ie.jsx)(J.J,{name:"arrow-up",size:"lg"}))})]})}const si=(0,o.memo)(ii),oi=(e,t,i)=>({navContainer:s.css`
      max-height: 95vh;
      display: flex;
      flex-direction: column;
      justify-content: ${t?"flex-start":"space-between"};
      position: sticky;
      top: ${e.spacing(2)};
      right: 0;
    `,navButton:s.css`
      width: 58px;
      height: 68px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      line-height: 1;
    `,navButtonContent:s.css`
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      width: 100%;
      height: 100%;
      white-space: normal;
    `,scrollToTopButton:s.css`
      width: 40px;
      height: 40px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      margin-top: ${e.spacing(1)};
    `});var ni,ri,ai=i(35562);function li(e){var t;const[i,s]=(0,o.useState)(!1),n=e.error.message||(null===(t=e.error.data)||void 0===t?void 0:t.message)||"",r=!i&&n.length>100;return(0,ie.jsx)(ai.b,{title:"Failed to load log volume for this query",severity:"warning",children:r?(0,ie.jsx)(jt.zx,{variant:"secondary",size:"xs",onClick:()=>{s(!0)},children:"Show details"}):n})}function ci(e){const{width:t,timeZone:i,splitOpen:s,onUpdateTimeRange:o,onLoadLogsVolume:n,onHiddenSeriesChanged:r}=e,a=(0,w.l4)(),l=(0,w.wW)(di),c=parseInt(a.spacing(2).slice(0,-2),10),d=function(e,t,i,s){return void 0!==i?{logsVolumeData:i,fullRangeData:!0,range:s}:void 0!==e?{logsVolumeData:e,fullRangeData:!1,range:t||s}:void 0}(e.logLinesBasedData,e.logLinesBasedDataVisibleRange,e.logsVolumeData,e.absoluteRange);if(void 0===d)return null;const{logsVolumeData:h,fullRangeData:p,range:u}=d;if(void 0!==h.error)return(0,ie.jsx)(li,{error:h.error});let g,f;if((null==h?void 0:h.state)===O.Gu.Loading?g=ni||(ni=(0,ie.jsx)("span",{children:"Log volume is loading..."})):null!=h&&h.data&&(g=h.data.length>0?(0,ie.jsx)(se,{graphStyle:"lines",loadingState:O.Gu.Done,data:h.data,height:150,width:t-c,absoluteRange:u,onChangeTime:o,timeZone:i,splitOpenFn:s,tooltipDisplayMode:K.f3.Multi,onHiddenSeriesChanged:r}):ri||(ri=(0,ie.jsx)("span",{children:"No volume data."}))),p){const e=function(e,t){var i,s;const o=e&&e.data[0]&&(null===(i=e.data[0].meta)||void 0===i||null===(s=i.custom)||void 0===s?void 0:s.absoluteRange);return o?(t.from-t.to)/(o.from-o.to):void 0}(h,u);void 0!==e&&e<1&&(f=(0,ie.jsx)(Et._,{label:"Reload log volume",transparent:!0,children:(0,ie.jsx)(jt.zx,{size:"xs",icon:"sync",variant:"secondary",onClick:n,id:"reload-volume"})}))}else f=(0,ie.jsx)("div",{className:l.oldInfoText,children:"This datasource does not support full-range histograms. The graph is based on the logs seen in the response."});return(0,ie.jsxs)(N.U,{label:"",isOpen:!0,children:[(0,ie.jsx)("div",{style:{height:150},className:l.contentContainer,children:g}),(0,ie.jsx)("div",{className:l.extraInfoContainer,children:f})]})}const di=e=>({extraInfoContainer:s.css`
      display: flex;
      justify-content: end;
      position: absolute;
      right: 5px;
      top: 5px;
    `,contentContainer:s.css`
      display: flex;
      align-items: center;
      justify-content: center;
    `,oldInfoText:s.css`
      font-size: ${e.typography.size.sm};
      color: ${e.colors.text.secondary};
    `});function hi(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const pi="grafana.explore.logs.showLabels",ui="grafana.explore.logs.showTime",gi="grafana.explore.logs.wrapLogMessage",fi="grafana.explore.logs.prettifyLogMessage",mi="grafana.explore.logs.sortOrder";class yi extends o.PureComponent{constructor(){super(...arguments),hi(this,"flipOrderTimer",void 0),hi(this,"cancelFlippingTimer",void 0),hi(this,"topLogsRef",(0,o.createRef)()),hi(this,"state",{showLabels:R.Z.getBool(pi,!1),showTime:R.Z.getBool(ui,!0),wrapLogMessage:R.Z.getBool(gi,!0),prettifyLogMessage:R.Z.getBool(fi,!1),dedupStrategy:bt.Y4.none,hiddenLogLevels:[],logsSortOrder:R.Z.get(mi)||bt.UV.Descending,isFlipping:!1,showDetectedFields:[],forceEscape:!1}),hi(this,"onChangeLogsSortOrder",(()=>{this.setState({isFlipping:!0}),this.flipOrderTimer=window.setTimeout((()=>{this.setState((e=>{const t=e.logsSortOrder===bt.UV.Descending?bt.UV.Ascending:bt.UV.Descending;return R.Z.set(mi,t),{logsSortOrder:t}}))}),0),this.cancelFlippingTimer=window.setTimeout((()=>this.setState({isFlipping:!1})),1e3)})),hi(this,"onEscapeNewlines",(()=>{this.setState((e=>({forceEscape:!e.forceEscape})))})),hi(this,"onChangeDedup",(e=>{(0,$.ff)("grafana_explore_logs_deduplication_clicked",{deduplicationType:e,datasourceType:this.props.datasourceType}),this.setState({dedupStrategy:e})})),hi(this,"onChangeLabels",(e=>{const{target:t}=e;if(t){const e=t.checked;this.setState({showLabels:e}),R.Z.set(pi,e)}})),hi(this,"onChangeTime",(e=>{const{target:t}=e;if(t){const e=t.checked;this.setState({showTime:e}),R.Z.set(ui,e)}})),hi(this,"onChangeWrapLogMessage",(e=>{const{target:t}=e;if(t){const e=t.checked;this.setState({wrapLogMessage:e}),R.Z.set(gi,e)}})),hi(this,"onChangePrettifyLogMessage",(e=>{const{target:t}=e;if(t){const e=t.checked;this.setState({prettifyLogMessage:e}),R.Z.set(fi,e)}})),hi(this,"onToggleLogLevel",(e=>{const t=e.map((e=>bt.in[e]));this.setState({hiddenLogLevels:t})})),hi(this,"onClickScan",(e=>{e.preventDefault(),this.props.onStartScanning&&this.props.onStartScanning()})),hi(this,"onClickStopScan",(e=>{e.preventDefault(),this.props.onStopScanning&&this.props.onStopScanning()})),hi(this,"showDetectedField",(e=>{-1===this.state.showDetectedFields.indexOf(e)&&this.setState((t=>({showDetectedFields:t.showDetectedFields.concat(e)})))})),hi(this,"hideDetectedField",(e=>{this.state.showDetectedFields.indexOf(e)>-1&&this.setState((t=>({showDetectedFields:t.showDetectedFields.filter((t=>e!==t))})))})),hi(this,"clearDetectedFields",(()=>{this.setState((e=>({showDetectedFields:[]})))})),hi(this,"checkUnescapedContent",(0,x.Z)((e=>!!e.some((e=>e.hasUnescapedContent))))),hi(this,"dedupRows",(0,x.Z)(((e,t)=>{const i=(0,At.UW)(e,t),s=i.reduce(((e,t)=>t.duplicates?e+t.duplicates:e),0);return{dedupedRows:i,dedupCount:s}}))),hi(this,"filterRows",(0,x.Z)(((e,t)=>(0,At.nu)(e,new Set(t))))),hi(this,"createNavigationRange",(0,x.Z)((e=>{if(!e||0===e.length)return;const t=e[0].timeEpochMs,i=e[e.length-1].timeEpochMs;return i<t?{from:i,to:t}:{from:t,to:i}}))),hi(this,"scrollToTopLogs",(()=>{var e;return null===(e=this.topLogsRef.current)||void 0===e?void 0:e.scrollIntoView()}))}componentWillUnmount(){this.flipOrderTimer&&window.clearTimeout(this.flipOrderTimer),this.cancelFlippingTimer&&window.clearTimeout(this.cancelFlippingTimer)}render(){const{width:e,splitOpen:t,logRows:i,logsMeta:s,logsSeries:o,visibleRange:n,logsVolumeData:r,loadLogsVolumeData:a,loading:l=!1,loadingState:c,onClickFilterLabel:d,onClickFilterOutLabel:h,timeZone:p,scanning:u,scanRange:g,showContextToggle:f,absoluteRange:m,onChangeTime:y,getFieldLinks:x,theme:v,logsQueries:b,clearCache:w,addResultsToCache:S,exploreId:R}=this.props,{showLabels:j,showTime:C,wrapLogMessage:z,prettifyLogMessage:I,dedupStrategy:k,hiddenLogLevels:F,logsSortOrder:O,isFlipping:D,showDetectedFields:$,forceEscape:N}=this.state,H=vi(v,z),L=i&&i.length>0,E=this.checkUnescapedContent(i),P=this.filterRows(i,F),{dedupedRows:A,dedupCount:q}=this.dedupRows(P,k),M=this.createNavigationRange(i),_=g?`Scanning ${Ht.describeTimeRange(g)}`:"Scanning...";return(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(ci,{absoluteRange:m,width:e,logsVolumeData:r,logLinesBasedData:o?{data:o,state:c}:void 0,logLinesBasedDataVisibleRange:n,onUpdateTimeRange:y,timeZone:p,splitOpen:t,onLoadLogsVolume:()=>a(R),onHiddenSeriesChanged:this.onToggleLogLevel}),(0,ie.jsxs)("div",{className:H.logOptions,ref:this.topLogsRef,children:[(0,ie.jsxs)(Lt.Z,{children:[(0,ie.jsx)(Et._,{label:"Time",className:H.horizontalInlineLabel,transparent:!0,children:(0,ie.jsx)(Pt.x,{value:C,onChange:this.onChangeTime,className:H.horizontalInlineSwitch,transparent:!0,id:`show-time_${R}`})}),(0,ie.jsx)(Et._,{label:"Unique labels",className:H.horizontalInlineLabel,transparent:!0,children:(0,ie.jsx)(Pt.x,{value:j,onChange:this.onChangeLabels,className:H.horizontalInlineSwitch,transparent:!0,id:`unique-labels_${R}`})}),(0,ie.jsx)(Et._,{label:"Wrap lines",className:H.horizontalInlineLabel,transparent:!0,children:(0,ie.jsx)(Pt.x,{value:z,onChange:this.onChangeWrapLogMessage,className:H.horizontalInlineSwitch,transparent:!0,id:`wrap-lines_${R}`})}),(0,ie.jsx)(Et._,{label:"Prettify JSON",className:H.horizontalInlineLabel,transparent:!0,children:(0,ie.jsx)(Pt.x,{value:I,onChange:this.onChangePrettifyLogMessage,className:H.horizontalInlineSwitch,transparent:!0,id:`prettify_${R}`})}),(0,ie.jsx)(Et._,{label:"Dedup",className:H.horizontalInlineLabel,transparent:!0,children:(0,ie.jsx)(ne.S,{options:Object.values(bt.Y4).map((e=>({label:(0,T.capitalize)(e),value:e,description:bt.Uv[e]}))),value:k,onChange:this.onChangeDedup,className:H.radioButtons})})]}),(0,ie.jsx)("div",{children:(0,ie.jsx)(Et._,{label:"Display results",className:H.horizontalInlineLabel,transparent:!0,children:(0,ie.jsx)(ne.S,{disabled:D,options:[{label:"Newest first",value:bt.UV.Descending,description:"Show results newest to oldest"},{label:"Oldest first",value:bt.UV.Ascending,description:"Show results oldest to newest"}],value:O,onChange:this.onChangeLogsSortOrder,className:H.radioButtons})})})]}),(0,ie.jsx)(Zt,{logRows:i,meta:s||[],dedupStrategy:k,dedupCount:q,hasUnescapedContent:E,forceEscape:N,showDetectedFields:$,onEscapeNewlines:this.onEscapeNewlines,clearDetectedFields:this.clearDetectedFields}),(0,ie.jsxs)("div",{className:H.logsSection,children:[(0,ie.jsx)("div",{className:H.logRows,"data-testid":"logRows",children:(0,ie.jsx)(qt.w,{logRows:i,deduplicatedRows:A,dedupStrategy:k,getRowContext:this.props.getRowContext,onClickFilterLabel:d,onClickFilterOutLabel:h,showContextToggle:f,showLabels:j,showTime:C,enableLogDetails:!0,forceEscape:N,wrapLogMessage:z,prettifyLogMessage:I,timeZone:p,getFieldLinks:x,logsSortOrder:O,showDetectedFields:$,onClickShowDetectedField:this.showDetectedField,onClickHideDetectedField:this.hideDetectedField,app:de.zj.Explore})}),(0,ie.jsx)(si,{logsSortOrder:O,visibleRange:null!=M?M:m,absoluteRange:m,timeZone:p,onChangeTime:y,loading:l,queries:null!=b?b:[],scrollToTopLogs:this.scrollToTopLogs,addResultsToCache:S,clearCache:w})]}),!l&&!L&&!u&&(0,ie.jsxs)("div",{className:H.noData,children:["No logs found.",(0,ie.jsx)(jt.zx,{size:"xs",fill:"text",onClick:this.onClickScan,children:"Scan for older logs"})]}),u&&(0,ie.jsxs)("div",{className:H.noData,children:[(0,ie.jsx)("span",{children:_}),(0,ie.jsx)(jt.zx,{size:"xs",fill:"text",onClick:this.onClickStopScan,children:"Stop scan"})]})]})}}const xi=(0,w.HE)(yi),vi=(e,t)=>({noData:s.css`
      > * {
        margin-left: 0.5em;
      }
    `,logOptions:s.css`
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      flex-wrap: wrap;
      background-color: ${e.colors.background.primary};
      padding: ${e.spacing(1,2)};
      border-radius: ${e.shape.borderRadius()};
      margin: ${e.spacing(2,0,1)};
      border: 1px solid ${e.colors.border.medium};
    `,headerButton:s.css`
      margin: ${e.spacing(.5,0,0,1)};
    `,horizontalInlineLabel:s.css`
      > label {
        margin-right: 0;
      }
    `,horizontalInlineSwitch:s.css`
      padding: 0 ${e.spacing(1)} 0 0;
    `,radioButtons:s.css`
      margin: 0;
    `,logsSection:s.css`
      display: flex;
      flex-direction: row;
      justify-content: space-between;
    `,logRows:s.css`
      overflow-x: ${t?"unset":"scroll"};
      overflow-y: visible;
      width: 100%;
    `}),bi=(0,x.Z)((()=>({logsEnter:s.css`
      label: logsEnter;
      position: absolute;
      opacity: 0;
      height: auto;
      width: 100%;
    `,logsEnterActive:s.css`
      label: logsEnterActive;
      opacity: 1;
      transition: opacity ${500}ms ease-out ${100}ms;
    `,logsExit:s.css`
      label: logsExit;
      position: absolute;
      opacity: 1;
      height: auto;
      width: 100%;
    `,logsExitActive:s.css`
      label: logsExitActive;
      opacity: 0;
      transition: opacity ${500}ms ease-out ${100}ms;
    `})));function wi(e){const{visible:t,children:i}=e,s=bi();return(0,ie.jsx)(lt.Z,{in:t,mountOnEnter:!0,unmountOnExit:!0,timeout:600,classNames:{enter:s.logsEnter,enterActive:s.logsEnterActive,exit:s.logsExit,exitActive:s.logsExitActive},children:i})}var Si=i(49647);function Ri(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class ji extends o.PureComponent{constructor(){super(...arguments),Ri(this,"onChangeTime",(e=>{const{exploreId:t,updateTimeRange:i}=this.props;i({exploreId:t,absoluteRange:e})})),Ri(this,"getLogRowContext",(async(e,t)=>{const{datasourceInstance:i,logsQueries:s}=this.props;if((0,bt.Q4)(i)){const o=(null!=s?s:[]).find((t=>t.refId===e.dataFrame.refId&&null!=t.datasource&&t.datasource.type===i.type));return i.getLogRowContext(e,t,o)}return[]})),Ri(this,"showContextToggle",(e=>{const{datasourceInstance:t}=this.props;return!!(0,bt.Q4)(t)&&t.showContextToggle(e)})),Ri(this,"getFieldLinks",((e,t)=>{const{splitOpenFn:i,range:s}=this.props;return(0,Si.a)({field:e,rowIndex:t,splitOpenFn:i,range:s})}))}render(){var e;const{loading:t,loadingState:i,logRows:o,logsMeta:n,logsSeries:r,logsQueries:a,logsVolumeData:l,loadLogsVolumeData:c,onClickFilterLabel:d,onClickFilterOutLabel:h,onStartScanning:p,onStopScanning:u,absoluteRange:g,timeZone:f,visibleRange:m,scanning:y,range:x,width:v,splitOpenFn:b,isLive:w,exploreId:S,addResultsToCache:R,clearCache:j}=this.props;if(!o)return null;const C=s.css`
      & > div {
        overflow: visible;
        & > div {
          overflow: visible;
        }
      }
    `;return(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(wi,{visible:w,children:(0,ie.jsx)(N.U,{label:"Logs",loading:!1,isOpen:!0,children:(0,ie.jsx)(gt,{exploreId:S,children:e=>(0,ie.jsx)(Nt,{logRows:o,timeZone:f,stopLive:e.stop,isPaused:this.props.isPaused,onPause:e.pause,onResume:e.resume})})})}),(0,ie.jsx)(wi,{visible:!w,children:(0,ie.jsx)(N.U,{label:"Logs",loading:t,isOpen:!0,className:C,children:(0,ie.jsx)(xi,{exploreId:S,datasourceType:null===(e=this.props.datasourceInstance)||void 0===e?void 0:e.type,logRows:o,logsMeta:n,logsSeries:r,logsVolumeData:l,logsQueries:a,width:v,splitOpen:b,loading:t,loadingState:i,loadLogsVolumeData:c,onChangeTime:this.onChangeTime,onClickFilterLabel:d,onClickFilterOutLabel:h,onStartScanning:p,onStopScanning:u,absoluteRange:g,visibleRange:m,timeZone:f,scanning:y,scanRange:x.raw,showContextToggle:this.showContextToggle,getRowContext:this.getLogRowContext,getFieldLinks:this.getFieldLinks,addResultsToCache:()=>R(S),clearCache:()=>j(S)})})})]})}}const Ci={updateTimeRange:ut.cD,addResultsToCache:f.K8,clearCache:f.LK,loadLogsVolumeData:f.QH},zi=(0,n.connect)((function(e,t){let{exploreId:i}=t;const s=e.explore[i],{logsResult:o,loading:n,scanning:r,datasourceInstance:a,isLive:l,isPaused:c,range:d,absoluteRange:h,logsVolumeDataProvider:p,logsVolumeData:u}=s,g=(0,I.Z)(e.user);return{loading:n,logRows:null==o?void 0:o.rows,logsMeta:null==o?void 0:o.meta,logsSeries:null==o?void 0:o.series,logsQueries:null==o?void 0:o.queries,visibleRange:null==o?void 0:o.visibleRange,scanning:r,timeZone:g,datasourceInstance:a,isLive:l,isPaused:c,range:d,absoluteRange:h,logsVolumeDataProvider:p,logsVolumeData:u}}),Ci)(ji),Ii=()=>{const e=(0,w.wW)(Ti);return(0,ie.jsx)(ie.Fragment,{children:(0,ie.jsx)(L.l,{"data-testid":"explore-no-data",className:e.wrapper,children:(0,ie.jsx)("span",{className:e.message,children:"No data"})})})},Ti=e=>({wrapper:s.css`
    label: no-data-card;
    padding: ${e.spacing(3)};
    background: ${e.colors.background.primary};
    border-radius: ${e.shape.borderRadius(2)};
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
  `,message:s.css`
    font-size: ${e.typography.h2.fontSize};
    padding: ${e.spacing(4)};
    color: ${e.colors.text.disabled};
  `});var ki,Fi,Oi=i(66367);const Di=()=>{const e=(0,w.l4)(),t=Ke.Vt.hasPermission(u.bW.DataSourcesCreate)&&Ke.Vt.hasPermission(u.bW.DataSourcesWrite),i=(0,ie.jsxs)(ie.Fragment,{children:[ki||(ki=(0,ie.jsx)(J.J,{name:"rocket"})),(0,ie.jsx)(ie.Fragment,{children:" ProTip: You can also define data sources through configuration files. "}),Fi||(Fi=(0,ie.jsx)("a",{href:"http://docs.grafana.org/administration/provisioning/#datasources?utm_source=explore",target:"_blank",rel:"noreferrer",className:"text-link",children:"Learn more"}))]}),o=(0,ie.jsx)(jt.Qj,{size:"lg",href:"datasources/new",icon:"database",disabled:!t,children:"Add data source"}),n=s.css`
    max-width: ${e.breakpoints.values.lg}px;
    margin-top: ${e.spacing(2)};
    align-self: center;
  `;return(0,ie.jsx)(Oi._,{callToActionElement:o,className:n,footer:i,message:"Explore requires at least one data source. Once you have added a data source, you can query it here."})};var $i,Ni=i(20673),Hi=i(20592),Li=i(94903),Ei=i(27007),Pi=i(99835);const Ai=e=>({warningText:s.css`
    label: warningText;
    font-size: ${e.typography.bodySmall.fontSize};
    color: ${e.colors.text.secondary};
  `});const qi=(0,n.connect)((function(e,t){let{exploreId:i}=t;return{range:e.explore[i].range}}),{})((function(e){var t;const{dataFrames:i,range:s,splitOpenFn:n,withTraceView:r,datasourceType:a}=e,l=(0,Si.u)(s,n),c=(0,w.l4)(),d=(0,w.wW)(Ai),h=(0,U.SM)({fieldConfig:{defaults:{},overrides:[]},data:i,replaceVariables:e=>e,theme:c}),{nodes:p}=(0,Pi.Y)(h),[u,g]=(0,Ni.Z)(!1),{height:f}=(0,Hi.Z)(),m=(0,o.useRef)(null),[y,x]=(0,o.useState)(250);(0,o.useEffect)((()=>{if(m.current){const{top:e}=m.current.getBoundingClientRect();x(e)}}),[m]);const v=f-y-32,b=r&&(null===(t=p[0])||void 0===t?void 0:t.length)>1e3?(0,ie.jsxs)("span",{className:d.warningText,children:[" (",p[0].length," nodes, can be slow to load)"]}):null;return(0,ie.jsx)(N.U,{label:(0,ie.jsxs)("span",{children:["Node graph",b," ",$i||($i=(0,ie.jsx)(Li.C,{text:"Beta",color:"blue",icon:"rocket",tooltip:"This visualization is in beta"}))]}),collapsible:r,isOpen:!r||u,onToggle:r?()=>(g(),void(0,$.ff)("grafana_traces_node_graph_panel_clicked",{datasourceType:a,expanded:!u})):void 0,children:(0,ie.jsx)("div",{ref:m,style:r?{height:500}:{minHeight:600,height:v},children:(0,ie.jsx)(Ei.E,{dataFrames:h,getLinks:l})})})}));var Mi=i(8973),_i=i(83820),Bi=i(59990);const Wi=e=>{let{exploreId:t}=e;const i=(0,u.I0)(),{getQueries:s,getDatasourceInstanceSettings:n,getQueryResponse:r,getHistory:a,getEventBridge:l}=(0,o.useMemo)((()=>(e=>{const t=(0,m.F)(e);return{getQueries:(0,Mi.P1)(t,(e=>e.queries)),getQueryResponse:(0,Mi.P1)(t,(e=>e.queryResponse)),getHistory:(0,Mi.P1)(t,(e=>e.history)),getEventBridge:(0,Mi.P1)(t,(e=>e.eventBridge)),getDatasourceInstanceSettings:(0,Mi.P1)(t,(e=>{var t;return(0,z.ak)().getInstanceSettings(null===(t=e.datasourceInstance)||void 0===t?void 0:t.uid)}))}})(t)),[t]),c=(0,u.v9)(s),d=(0,u.v9)(n),h=(0,u.v9)(r),p=(0,u.v9)(a),g=(0,u.v9)(l),y=(0,o.useCallback)((()=>{i((0,f.aA)(t))}),[i,t]),x=(0,o.useCallback)((e=>{i((0,f.PM)({queries:e,exploreId:t})),e.length<c.length&&y()}),[i,t,y,c]),v=(0,o.useCallback)((e=>{x([...c,Object.assign({},e,{refId:(0,_i.Hs)(c)})])}),[x,c]);return(0,ie.jsx)(Bi.l,{dsSettings:d,onDatasourceChange:(e,s)=>(async(e,s)=>{const o=await(0,D.F)().get(s.datasource),n=await(0,D.F)().get({uid:e.uid});i((0,f.GJ)(t,c,o,n,s.refId))})(e,s),queries:c,onQueriesChange:x,onAddQuery:v,onRunQueries:y,onQueryCopied:()=>{(0,$.ff)("grafana_explore_query_row_copy")},onQueryRemoved:()=>{(0,$.ff)("grafana_explore_query_row_remove")},onQueryToggled:e=>{(0,$.ff)("grafana_query_row_toggle",void 0===e?{}:{queryEnabled:e})},data:h,app:de.zj.Explore,history:p,eventBus:g})};var Qi=i(32201);const Zi=e=>{const t={transition:`opacity ${e.duration}ms linear`,opacity:0},i={exited:{opacity:0,display:"none"},entering:{opacity:0},entered:{opacity:1},exiting:{opacity:0}};return(0,ie.jsx)(Qi.ZP,{in:e.in,timeout:e.duration,unmountOnExit:e.unmountOnExit||!1,onExited:e.onExited,children:s=>(0,ie.jsx)("div",{style:Object.assign({},t,i[s]),children:e.children})})},Ui=e=>{var t;const{queryError:i}=e,s=!!i,o=s?100:10,n=i?"Query error":"Unknown error",r=(null==i?void 0:i.message)||(null==i||null===(t=i.data)||void 0===t?void 0:t.message)||null;return(0,ie.jsx)(Zi,{in:s,duration:o,children:(0,ie.jsx)(ai.b,{severity:"error",title:n,topSpacing:2,children:r})})};function Vi(e){const t=(0,u.v9)((t=>{var i;return null===(i=t.explore[e.exploreId])||void 0===i?void 0:i.queryResponse})),i=(null==t?void 0:t.state)===O.Gu.Error?null==t?void 0:t.error:void 0;return null!=i&&i.refId?null:(0,ie.jsx)(Ui,{queryError:i})}var Gi=i(86339),Ki=i(38865),Yi=i(11614),Ji=i(62533),Xi=i(3357),es=i(50859),ts=i(2338),is=i(29877),ss=i(94843),os=i(96572);const ns={changeDatasource:pt.zU,deleteHistoryItem:Gi.NV,commentHistoryItem:Gi.Ff,starHistoryItem:Gi.ev,setQueries:f.KO},rs=(0,n.connect)((function(e,t){let{exploreId:i}=t;const s=e.explore,{datasourceInstance:o}=s[i];return{exploreId:i,datasourceInstance:o}}),ns),as=(0,$e.B)(((e,t)=>{const i="240px",o="170px",n=e.colors.bg2;return{queryCard:s.css`
      display: flex;
      flex-direction: column;
      border: 1px solid ${e.colors.border1};
      margin: ${e.spacing.sm} 0;
      background-color: ${n};
      border-radius: ${e.border.radius.sm};
      .starred {
        color: ${e.palette.orange};
      }
    `,cardRow:s.css`
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: ${e.spacing.sm};
      border-bottom: none;
      :first-of-type {
        border-bottom: 1px solid ${e.colors.border1};
        padding: ${e.spacing.xs} ${e.spacing.sm};
      }
      img {
        height: ${e.typography.size.base};
        max-width: ${e.typography.size.base};
        margin-right: ${e.spacing.sm};
      }
    `,datasourceContainer:s.css`
      display: flex;
      align-items: center;
      font-size: ${e.typography.size.sm};
      font-weight: ${e.typography.weight.semibold};
    `,queryActionButtons:s.css`
      max-width: ${o};
      display: flex;
      justify-content: flex-end;
      font-size: ${e.typography.size.base};
      button {
        margin-left: ${e.spacing.sm};
      }
    `,queryContainer:s.css`
      font-weight: ${e.typography.weight.semibold};
      width: calc(100% - ${i});
    `,queryRow:s.css`
      border-top: 1px solid ${e.colors.border1};
      word-break: break-all;
      padding: 4px 2px;
      :first-child {
        border-top: none;
        padding: 0 0 4px 0;
      }
    `,updateCommentContainer:s.css`
      width: calc(100% + ${i});
      margin-top: ${e.spacing.sm};
    `,comment:s.css`
      overflow-wrap: break-word;
      font-size: ${e.typography.size.sm};
      font-weight: ${e.typography.weight.regular};
      margin-top: ${e.spacing.xs};
    `,commentButtonRow:s.css`
      > * {
        margin-right: ${e.spacing.sm};
      }
    `,textArea:s.css`
      width: 100%;
    `,runButton:s.css`
      max-width: ${o};
      display: flex;
      justify-content: flex-end;
      button {
        height: auto;
        padding: ${e.spacing.xs} ${e.spacing.md};
        line-height: 1.4;
        span {
          white-space: normal !important;
        }
      }
    `}}));const ls=rs((function(e){var t;const{query:i,dsImg:n,isRemoved:r,commentHistoryItem:a,starHistoryItem:l,deleteHistoryItem:c,changeDatasource:d,exploreId:h,datasourceInstance:p,setQueries:u}=e,[g,f]=(0,o.useState)(!1),[m,y]=(0,o.useState)(i.comment),[x,v]=(0,o.useState)(void 0);(0,o.useEffect)((()=>{(async()=>{const e=await(0,D.F)().get(i.datasourceUid);v(e)})()}),[i.datasourceUid]);const b=(0,w.Fg)(),S=as(b,r),R=()=>{a(i.id,m),f(!1),(0,$.ff)("grafana_explore_query_history_commented",{queryHistoryEnabled:Qe.v.queryHistoryEnabled})},C=()=>{f(!1),y(i.comment)},z=(0,ie.jsxs)("div",{className:S.updateCommentContainer,"aria-label":m?"Update comment form":"Add comment form",children:[(0,ie.jsx)(es.K,{value:m,placeholder:m?void 0:"An optional description of what the query does.",onChange:e=>y(e.currentTarget.value),className:S.textArea}),(0,ie.jsxs)("div",{className:S.commentButtonRow,children:[(0,ie.jsx)(jt.zx,{onClick:R,"aria-label":"Submit button",children:"Save comment"}),(0,ie.jsx)(jt.zx,{variant:"secondary",onClick:C,children:"Cancel"})]})]}),I=(0,ie.jsxs)("div",{className:S.queryActionButtons,children:[(0,ie.jsx)(ts.h,{name:"comment-alt",onClick:()=>f(!g),title:(null===(t=i.comment)||void 0===t?void 0:t.length)>0?"Edit comment":"Add comment"}),(0,ie.jsx)(ts.h,{name:"copy",onClick:()=>{const e=i.queries.map((e=>(0,Ki.OH)(e,x))).join("\n");(0,j.n9)(e),(0,os.WI)((0,is.$l)((0,ss.AT)("Query copied to clipboard")))},title:"Copy query to clipboard"}),!r&&(0,ie.jsx)(ts.h,{name:"share-alt",onClick:async()=>{const e=(0,Ki.t2)(i);await(0,Ye.L)(e)},title:"Copy shortened link to clipboard"}),(0,ie.jsx)(ts.h,{name:"trash-alt",title:"Delete query",onClick:()=>{const e=e=>{c(e),(0,os.WI)((0,is.$l)((0,ss.AT)("Query deleted"))),(0,$.ff)("grafana_explore_query_history_deleted",{queryHistoryEnabled:Qe.v.queryHistoryEnabled})};i.starred?P.Z.publish(new M.VJ({title:"Delete",text:"Are you sure you want to permanently delete your starred query?",yesText:"Delete",icon:"trash-alt",onConfirm:()=>e(i.id)})):e(i.id)}}),(0,ie.jsx)(ts.h,{name:i.starred?"favorite":"star",iconType:i.starred?"mono":"default",onClick:()=>{l(i.id,!i.starred),(0,$.ff)("grafana_explore_query_history_starred",{queryHistoryEnabled:Qe.v.queryHistoryEnabled,newValue:!i.starred})},title:i.starred?"Unstar query":"Star query"})]});return(0,ie.jsxs)("div",{className:S.queryCard,onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||e.ctrlKey)&&R(),"Escape"===e.key&&C()},children:[(0,ie.jsxs)("div",{className:S.cardRow,children:[(0,ie.jsxs)("div",{className:S.datasourceContainer,children:[(0,ie.jsx)("img",{src:n,"aria-label":"Data source icon"}),(0,ie.jsx)("div",{"aria-label":"Data source name",children:r?"Data source does not exist anymore":i.datasourceName})]}),I]}),(0,ie.jsxs)("div",{className:(0,s.cx)(S.cardRow),children:[(0,ie.jsxs)("div",{className:S.queryContainer,children:[i.queries.map(((e,t)=>{const i=(0,Ki.OH)(e,x);return(0,ie.jsx)("div",{"aria-label":"Query text",className:S.queryRow,children:i},`${e}-${t}`)})),!g&&i.comment&&(0,ie.jsx)("div",{"aria-label":"Query comment",className:S.comment,children:i.comment}),g&&z]}),!g&&(0,ie.jsx)("div",{className:S.runButton,children:(0,ie.jsx)(jt.zx,{variant:"secondary",onClick:async()=>{const e=i.queries,t=i.datasourceUid!==(null==p?void 0:p.uid);t?(await d(h,i.datasourceUid,{importQueries:!0}),u(h,e)):u(h,e),(0,$.ff)("grafana_explore_query_history_run",{queryHistoryEnabled:Qe.v.queryHistoryEnabled,differentDataSource:t})},disabled:r,children:(null==p?void 0:p.uid)===i.datasourceUid?"Run query":"Switch data source and run query"})})]})]})}));var cs,ds;const hs=(0,$e.B)(((e,t)=>{const i=e.isLight?e.palette.gray5:e.palette.dark4;return{container:s.css`
      display: flex;
    `,labelSlider:s.css`
      font-size: ${e.typography.size.sm};
      &:last-of-type {
        margin-top: ${e.spacing.lg};
      }
      &:first-of-type {
        font-weight: ${e.typography.weight.semibold};
        margin-bottom: ${e.spacing.md};
      }
    `,containerContent:s.css`
      /* 134px is based on the width of the Query history tabs bar, so the content is aligned to right side of the tab */
      width: calc(100% - 134px);
    `,containerSlider:s.css`
      width: 129px;
      margin-right: ${e.spacing.sm};
    `,fixedSlider:s.css`
      position: fixed;
    `,slider:s.css`
      bottom: 10px;
      height: ${t-180}px;
      width: 129px;
      padding: ${e.spacing.sm} 0;
    `,selectors:s.css`
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
    `,filterInput:s.css`
      margin-bottom: ${e.spacing.sm};
    `,multiselect:s.css`
      width: 100%;
      margin-bottom: ${e.spacing.sm};
      .gf-form-select-box__multi-value {
        background-color: ${i};
        padding: ${e.spacing.xxs} ${e.spacing.xs} ${e.spacing.xxs} ${e.spacing.sm};
        border-radius: ${e.border.radius.sm};
      }
    `,sort:s.css`
      width: 170px;
    `,sessionName:s.css`
      display: flex;
      align-items: flex-start;
      justify-content: flex-start;
      margin-top: ${e.spacing.lg};
      h4 {
        margin: 0 10px 0 0;
      }
    `,heading:s.css`
      font-size: ${e.typography.heading.h4};
      margin: ${e.spacing.md} ${e.spacing.xxs} ${e.spacing.sm} ${e.spacing.xxs};
    `,footer:s.css`
      height: 60px;
      margin: ${e.spacing.lg} auto;
      display: flex;
      justify-content: center;
      font-weight: ${e.typography.weight.light};
      font-size: ${e.typography.size.sm};
      a {
        font-weight: ${e.typography.weight.semibold};
        margin-left: ${e.spacing.xxs};
      }
    `,queries:s.css`
      font-size: ${e.typography.size.sm};
      font-weight: ${e.typography.weight.regular};
      margin-left: ${e.spacing.xs};
    `}}));function ps(e){const{queries:t,totalQueries:i,loading:s,richHistorySearchFilters:n,updateFilters:r,clearRichHistoryResults:a,loadMoreRichHistory:l,richHistorySettings:c,exploreId:d,height:h,activeDatasourceInstance:p}=e,u=(0,w.Fg)(),g=hs(u,h),f=(0,Ki.DR)();if((0,o.useEffect)((()=>{const e=!c.activeDatasourceOnly&&c.lastUsedDatasourceFilters?c.lastUsedDatasourceFilters:[p],t={search:"",sortOrder:Ki.As.Descending,datasourceFilters:e,from:0,to:c.retentionPeriod,starred:!1};return r(t),()=>{a()}}),[]),!n)return cs||(cs=(0,ie.jsx)("span",{children:"Loading..."}));const m=(0,Ki.k4)(t,n.sortOrder),y=js(),x=t.length&&t.length!==i;return(0,ie.jsxs)("div",{className:g.container,children:[(0,ie.jsx)("div",{className:g.containerSlider,children:(0,ie.jsxs)("div",{className:g.fixedSlider,children:[(0,ie.jsx)("div",{className:g.labelSlider,children:"Filter history"}),(0,ie.jsx)("div",{className:g.labelSlider,children:(0,Ki.bQ)(n.from)}),(0,ie.jsx)("div",{className:g.slider,children:(0,ie.jsx)(Yi.U,{tooltipAlwaysVisible:!1,min:0,max:c.retentionPeriod,value:[n.from,n.to],orientation:"vertical",formatTooltipResult:Ki.bQ,reverse:!0,onAfterChange:e=>{r({from:e[0],to:e[1]})}})}),(0,ie.jsx)("div",{className:g.labelSlider,children:(0,Ki.bQ)(n.to)})]})}),(0,ie.jsxs)("div",{className:g.containerContent,children:[(0,ie.jsxs)("div",{className:g.selectors,children:[!c.activeDatasourceOnly&&(0,ie.jsx)(Ji.NU,{className:g.multiselect,options:f.map((e=>({value:e.name,label:e.name}))),value:n.datasourceFilters,placeholder:"Filter queries for data sources(s)","aria-label":"Filter queries for data sources(s)",onChange:e=>{r({datasourceFilters:e.map((e=>e.value))})}}),(0,ie.jsx)("div",{className:g.filterInput,children:(0,ie.jsx)(Xi.H,{placeholder:"Search queries",value:n.search,onChange:e=>r({search:e})})}),(0,ie.jsx)("div",{"aria-label":"Sort queries",className:g.sort,children:(0,ie.jsx)(Ji.Ph,{value:y.filter((e=>e.value===n.sortOrder)),options:y,placeholder:"Sort queries by",onChange:e=>r({sortOrder:e.value})})})]}),s&&(ds||(ds=(0,ie.jsx)("span",{children:"Loading results..."}))),!s&&Object.keys(m).map((e=>(0,ie.jsxs)("div",{children:[(0,ie.jsxs)("div",{className:g.heading,children:[e," ",(0,ie.jsxs)("span",{className:g.queries,children:[x?"Displaying ":"",m[e].length," queries"]})]}),m[e].map((e=>{const t=f.findIndex((t=>t.uid===e.datasourceUid));return(0,ie.jsx)(ls,{query:e,exploreId:d,dsImg:-1===t?"public/img/icn-datasource.svg":f[t].imgUrl,isRemoved:-1===t},e.id)}))]},e))),x?(0,ie.jsxs)("div",{children:["Showing ",t.length," of ",i," ",(0,ie.jsx)(jt.zx,{onClick:l,children:"Load more"})]}):null,(0,ie.jsx)("div",{className:g.footer,children:Qe.v.queryHistoryEnabled?"":"The history is local to your browser and is not shared with others."})]})]})}var us=i(45550),gs=i(55e3);const fs=(0,$e.B)((e=>({container:s.css`
      font-size: ${e.typography.size.sm};
    `,spaceBetween:s.css`
      margin-bottom: ${e.spacing.lg};
    `,input:s.css`
      max-width: 200px;
    `}))),ms=[{value:2,label:"2 days"},{value:5,label:"5 days"},{value:7,label:"1 week"},{value:14,label:"2 weeks"}];function ys(e){const{retentionPeriod:t,starredTabAsFirstTab:i,activeDatasourceOnly:o,onChangeRetentionPeriod:n,toggleStarredTabAsFirstTab:r,toggleactiveDatasourceOnly:a,deleteRichHistory:l}=e,c=(0,w.Fg)(),d=fs(c),h=ms.find((e=>e.value===t));return(0,ie.jsxs)("div",{className:d.container,children:[(0,A.X)().changeRetention?(0,ie.jsx)(us.g,{label:"History time span",description:`Select the period of time for which Grafana will save your query history. Up to ${gs.H6} entries will be stored.`,children:(0,ie.jsx)("div",{className:d.input,children:(0,ie.jsx)(Ji.Ph,{value:h,options:ms,onChange:n})})}):(0,ie.jsxs)(ai.b,{severity:"info",title:"History time span",children:["Grafana will keep entries up to ",null==h?void 0:h.label,"."]}),(0,ie.jsx)(Et._,{label:"Change the default active tab from “Query history” to “Starred”",className:d.spaceBetween,children:(0,ie.jsx)(Pt.x,{id:"explore-query-history-settings-default-active-tab",value:i,onChange:r})}),(0,A.X)().onlyActiveDataSource&&(0,ie.jsx)(Et._,{label:"Only show queries for data source currently active in Explore",className:d.spaceBetween,children:(0,ie.jsx)(Pt.x,{id:"explore-query-history-settings-data-source-behavior",value:o,onChange:a})}),(0,A.X)().clearHistory&&(0,ie.jsxs)("div",{children:[(0,ie.jsx)("div",{className:s.css`
              font-weight: ${c.typography.weight.bold};
            `,children:"Clear query history"}),(0,ie.jsx)("div",{className:s.css`
              margin-bottom: ${c.spacing.sm};
            `,children:"Delete all of your query history, permanently."}),(0,ie.jsx)(jt.zx,{variant:"destructive",onClick:()=>{P.Z.publish(new M.VJ({title:"Delete",text:"Are you sure you want to permanently delete your query history?",yesText:"Delete",icon:"trash-alt",onConfirm:()=>{l(),(0,os.WI)((0,is.$l)((0,ss.AT)("Query history deleted")))}}))},children:"Clear query history"})]})]})}var xs,vs;const bs=(0,$e.B)((e=>{const t=e.isLight?e.palette.gray5:e.palette.dark4;return{container:s.css`
      display: flex;
    `,containerContent:s.css`
      width: 100%;
    `,selectors:s.css`
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
    `,multiselect:s.css`
      width: 100%;
      margin-bottom: ${e.spacing.sm};
      .gf-form-select-box__multi-value {
        background-color: ${t};
        padding: ${e.spacing.xxs} ${e.spacing.xs} ${e.spacing.xxs} ${e.spacing.sm};
        border-radius: ${e.border.radius.sm};
      }
    `,filterInput:s.css`
      margin-bottom: ${e.spacing.sm};
    `,sort:s.css`
      width: 170px;
    `,footer:s.css`
      height: 60px;
      margin-top: ${e.spacing.lg};
      display: flex;
      justify-content: center;
      font-weight: ${e.typography.weight.light};
      font-size: ${e.typography.size.sm};
      a {
        font-weight: ${e.typography.weight.semibold};
        margin-left: ${e.spacing.xxs};
      }
    `}}));function ws(e){const{updateFilters:t,clearRichHistoryResults:i,loadMoreRichHistory:s,activeDatasourceInstance:n,richHistorySettings:r,queries:a,totalQueries:l,loading:c,richHistorySearchFilters:d,exploreId:h}=e,p=(0,w.Fg)(),u=bs(p),g=(0,Ki.DR)();if((0,o.useEffect)((()=>{const e=r.activeDatasourceOnly&&r.lastUsedDatasourceFilters?r.lastUsedDatasourceFilters:[n],s={search:"",sortOrder:Ki.As.Descending,datasourceFilters:e,from:0,to:r.retentionPeriod,starred:!0};return t(s),()=>{i()}}),[]),!d)return xs||(xs=(0,ie.jsx)("span",{children:"Loading..."}));const f=js();return(0,ie.jsx)("div",{className:u.container,children:(0,ie.jsxs)("div",{className:u.containerContent,children:[(0,ie.jsxs)("div",{className:u.selectors,children:[!r.activeDatasourceOnly&&(0,ie.jsx)(Ji.NU,{className:u.multiselect,options:g.map((e=>({value:e.name,label:e.name}))),value:d.datasourceFilters,placeholder:"Filter queries for data sources(s)","aria-label":"Filter queries for data sources(s)",onChange:e=>{t({datasourceFilters:e.map((e=>e.value))})}}),(0,ie.jsx)("div",{className:u.filterInput,children:(0,ie.jsx)(Xi.H,{placeholder:"Search queries",value:d.search,onChange:e=>t({search:e})})}),(0,ie.jsx)("div",{"aria-label":"Sort queries",className:u.sort,children:(0,ie.jsx)(Ji.Ph,{value:f.filter((e=>e.value===d.sortOrder)),options:f,placeholder:"Sort queries by",onChange:e=>t({sortOrder:e.value})})})]}),c&&(vs||(vs=(0,ie.jsx)("span",{children:"Loading results..."}))),!c&&a.map((e=>{const t=g.findIndex((t=>t.uid===e.datasourceUid));return(0,ie.jsx)(ls,{query:e,exploreId:h,dsImg:-1===t?"public/img/icn-datasource.svg":g[t].imgUrl,isRemoved:-1===t},e.id)})),a.length&&a.length!==l?(0,ie.jsxs)("div",{children:["Showing ",a.length," of ",l," ",(0,ie.jsx)(jt.zx,{onClick:s,children:"Load more"})]}):null,(0,ie.jsx)("div",{className:u.footer,children:Qe.v.queryHistoryEnabled?"":"The history is local to your browser and is not shared with others."})]})})}function Ss(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}let Rs;!function(e){e.RichHistory="Query history",e.Starred="Starred",e.Settings="Settings"}(Rs||(Rs={}));const js=()=>[{label:"Newest first",value:Ki.As.Descending},{label:"Oldest first",value:Ki.As.Ascending},{label:"Data source A-Z",value:Ki.As.DatasourceAZ},{label:"Data source Z-A",value:Ki.As.DatasourceZA}].filter((e=>(0,A.X)().availableFilters.includes(e.value)));class Cs extends o.PureComponent{constructor(){super(...arguments),Ss(this,"state",{loading:!1}),Ss(this,"updateSettings",(e=>{this.props.updateHistorySettings(Object.assign({},this.props.richHistorySettings,e))})),Ss(this,"updateFilters",(e=>{const t=Object.assign({},this.props.richHistorySearchFilters,e,{page:1});this.props.updateHistorySearchFilters(this.props.exploreId,t),this.loadRichHistory()})),Ss(this,"clearResults",(()=>{this.props.clearRichHistoryResults(this.props.exploreId)})),Ss(this,"loadRichHistory",(0,T.debounce)((()=>{this.props.loadRichHistory(this.props.exploreId),this.setState({loading:!0})}),300)),Ss(this,"onChangeRetentionPeriod",(e=>{void 0!==e.value&&this.updateSettings({retentionPeriod:e.value})})),Ss(this,"toggleStarredTabAsFirstTab",(()=>this.updateSettings({starredTabAsFirstTab:!this.props.richHistorySettings.starredTabAsFirstTab}))),Ss(this,"toggleActiveDatasourceOnly",(()=>this.updateSettings({activeDatasourceOnly:!this.props.richHistorySettings.activeDatasourceOnly})))}componentDidUpdate(e,t,i){e.richHistory!==this.props.richHistory&&this.setState({loading:!1})}render(){const{richHistory:e,richHistoryTotal:t,height:i,exploreId:s,deleteRichHistory:o,onClose:n,firstTab:r,activeDatasourceInstance:a}=this.props,{loading:l}=this.state;let c=[{label:"Query history",value:Rs.RichHistory,content:(0,ie.jsx)(ps,{queries:e,totalQueries:t||0,loading:l,updateFilters:this.updateFilters,clearRichHistoryResults:()=>this.props.clearRichHistoryResults(this.props.exploreId),loadMoreRichHistory:()=>this.props.loadMoreRichHistory(this.props.exploreId),activeDatasourceInstance:a,richHistorySettings:this.props.richHistorySettings,richHistorySearchFilters:this.props.richHistorySearchFilters,exploreId:s,height:i}),icon:"history"},{label:"Starred",value:Rs.Starred,content:(0,ie.jsx)(ws,{queries:e,totalQueries:t||0,loading:l,activeDatasourceInstance:a,updateFilters:this.updateFilters,clearRichHistoryResults:()=>this.props.clearRichHistoryResults(this.props.exploreId),loadMoreRichHistory:()=>this.props.loadMoreRichHistory(this.props.exploreId),richHistorySettings:this.props.richHistorySettings,richHistorySearchFilters:this.props.richHistorySearchFilters,exploreId:s}),icon:"star"},{label:"Settings",value:Rs.Settings,content:(0,ie.jsx)(ys,{retentionPeriod:this.props.richHistorySettings.retentionPeriod,starredTabAsFirstTab:this.props.richHistorySettings.starredTabAsFirstTab,activeDatasourceOnly:this.props.richHistorySettings.activeDatasourceOnly,onChangeRetentionPeriod:this.onChangeRetentionPeriod,toggleStarredTabAsFirstTab:this.toggleStarredTabAsFirstTab,toggleactiveDatasourceOnly:this.toggleActiveDatasourceOnly,deleteRichHistory:o}),icon:"sliders-v-alt"}];return(0,ie.jsx)(he.W,{tabs:c,onClose:n,defaultTab:r,closeIconTooltip:"Close query history"})}}const zs=(0,w.Zz)(Cs);var Is;const Ts={initRichHistory:Gi.sO,loadRichHistory:Gi.TV,loadMoreRichHistory:Gi.io,clearRichHistoryResults:Gi.Cs,updateHistorySettings:Gi.ch,updateHistorySearchFilters:Gi.KZ,deleteRichHistory:Gi.ik},ks=(0,n.connect)((function(e,t){let{exploreId:i}=t;const s=e.explore,o=s[i],n=o.richHistorySearchFilters,r=s.richHistorySettings,{datasourceInstance:a}=o,l=null!=r&&r.starredTabAsFirstTab?Rs.Starred:Rs.RichHistory,{richHistory:c,richHistoryTotal:d}=o;return{richHistory:c,richHistoryTotal:d,firstTab:l,activeDatasourceInstance:a.name,richHistorySettings:r,richHistorySearchFilters:n}}),Ts);const Fs=ks((function(e){const t=(0,w.l4)(),[i,s]=(0,o.useState)(t.components.horizontalDrawer.defaultHeight),{richHistory:n,richHistoryTotal:r,width:a,firstTab:l,activeDatasourceInstance:c,exploreId:d,deleteRichHistory:h,initRichHistory:p,loadRichHistory:u,loadMoreRichHistory:g,clearRichHistoryResults:f,richHistorySettings:m,updateHistorySettings:y,richHistorySearchFilters:x,updateHistorySearchFilters:v,onClose:b}=e;return(0,o.useEffect)((()=>{p(),(0,$.ff)("grafana_explore_query_history_opened",{queryHistoryEnabled:Qe.v.queryHistoryEnabled})}),[p]),m?(0,ie.jsx)(Le,{width:a,onResize:(e,t,i)=>{s(Number(i.style.height.slice(0,-2)))},children:(0,ie.jsx)(zs,{richHistory:n,richHistoryTotal:r,firstTab:l,activeDatasourceInstance:c,exploreId:d,onClose:b,height:i,deleteRichHistory:h,richHistorySettings:m,richHistorySearchFilters:x,updateHistorySettings:y,updateHistorySearchFilters:v,loadRichHistory:u,loadMoreRichHistory:g,clearRichHistoryResults:f})}):Is||(Is=(0,ie.jsx)("span",{children:"Loading..."}))}));var Os=i(7053);function Ds(e){const t=(e=>({containerMargin:s.css`
      margin-top: ${e.spacing(2)};
    `}))((0,w.l4)());return(0,ie.jsx)("div",{className:t.containerMargin,children:(0,ie.jsxs)(Os.Lh,{children:[!e.addQueryRowButtonHidden&&(0,ie.jsx)(jt.zx,{variant:"secondary","aria-label":"Add row button",onClick:e.onClickAddQueryRowButton,disabled:e.addQueryRowButtonDisabled,icon:"plus",children:"Add query"}),!e.richHistoryRowButtonHidden&&(0,ie.jsx)(jt.zx,{variant:"secondary","aria-label":"Rich history button",className:(0,s.cx)({"explore-active-button":e.richHistoryButtonActive}),onClick:e.onClickRichHistoryButton,icon:"history",children:"Query history"}),(0,ie.jsx)(jt.zx,{variant:"secondary","aria-label":"Query inspector button",className:(0,s.cx)({"explore-active-button":e.queryInspectorButtonActive}),onClick:e.onClickQueryInspectorButton,icon:"info-circle",children:"Inspector"})]})})}var $s=i(31013),Ns=i(56921);const Hs=(0,n.connect)((function(e,t){let{exploreId:i}=t;const s=e.explore[i],{loading:o,tableResult:n,range:r}=s;return{loading:!(n&&n.length>0)&&o,tableResult:n,range:r}}),{});class Ls extends o.PureComponent{getTableHeight(){const{tableResult:e}=this.props;return e&&0!==e.length?Math.max(Math.min(600,35*e.length)+35):200}render(){var e,t;const{loading:i,onCellFilterAdded:s,tableResult:o,width:n,splitOpenFn:r,range:a,ariaLabel:l,timeZone:c}=this.props,d=this.getTableHeight(),h=n-2*S.vc.theme.panelPadding-Ns.QO;let p=o;if(null!==(e=p)&&void 0!==e&&e.length){p=(0,U.SM)({data:[p],timeZone:c,theme:S.vc.theme2,replaceVariables:e=>e,fieldConfig:{defaults:{},overrides:[]}})[0];for(const e of p.fields)e.getLinks=t=>(0,Si.a)({field:e,rowIndex:t.valueRowIndex,splitOpenFn:r,range:a,dataFrame:p})}return(0,ie.jsx)(N.U,{label:"Table",loading:i,isOpen:!0,children:null!==(t=p)&&void 0!==t&&t.length?(0,ie.jsx)($s.i,{ariaLabel:l,data:p,width:h,height:d,onCellFilterAdded:s}):(0,ie.jsx)(Qt,{metaItems:[{value:"0 series returned"}]})})}}const Es=Hs(Ls);var Ps=i(69346),As=i(14343),qs=i(25575),Ms=i(41907),_s=i(32413);function Bs(e){const t=e.dataFrames[0],{dataFrames:i,splitOpenFn:s,exploreId:n,scrollElement:r,topOfViewRef:a,queryResponse:l}=e,c=(0,o.useMemo)((()=>(0,_s.N)(t)),[t]),{search:d,setSearch:h,spanFindMatches:p}=(0,Ms.R)(null==c?void 0:c.spans),[g,f]=(0,o.useState)(""),[m,y]=(0,o.useState)(""),x=(0,u.v9)((t=>{var i,s;return null!==(i=null===(s=t.explore[e.exploreId])||void 0===s?void 0:s.datasourceInstance)&&void 0!==i?i:void 0}));return c?(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(Ps.Z,{navigable:!0,searchValue:d,setSearch:h,spanFindMatches:p,searchBarSuffix:m,setSearchBarSuffix:y,focusedSpanIdForSearch:g,setFocusedSpanIdForSearch:f}),(0,ie.jsx)(N.U,{label:"Trace View",isOpen:!0,children:(0,ie.jsx)(qs.m,{exploreId:n,dataFrames:i,splitOpenFn:s,scrollElement:r,traceProp:c,spanFindMatches:p,search:d,focusedSpanIdForSearch:g,queryResponse:l,datasource:x,topOfViewRef:a,topOfViewRefType:As.l4.Explore})})]}):null}var Ws,Qs,Zs=i(96440);function Us(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var Vs;!function(e){e[e.RichHistory=0]="RichHistory",e[e.QueryInspector=1]="QueryInspector"}(Vs||(Vs={}));class Gs extends o.PureComponent{constructor(e){super(e),Us(this,"scrollElement",void 0),Us(this,"absoluteTimeUnsubsciber",void 0),Us(this,"topOfViewRef",(0,o.createRef)()),Us(this,"onChangeTime",(e=>{const{updateTimeRange:t,exploreId:i}=this.props;t({exploreId:i,rawRange:e})})),Us(this,"onClickExample",(e=>{this.props.setQueries(this.props.exploreId,[e])})),Us(this,"onCellFilterAdded",(e=>{const{value:t,key:i,operator:s}=e;s===E.PT&&this.onClickFilterLabel(i,t),s===E.tE&&this.onClickFilterOutLabel(i,t)})),Us(this,"onClickFilterLabel",((e,t)=>{this.onModifyQueries({type:"ADD_FILTER",options:{key:e,value:t}})})),Us(this,"onClickFilterOutLabel",((e,t)=>{this.onModifyQueries({type:"ADD_FILTER_OUT",options:{key:e,value:t}})})),Us(this,"onClickAddQueryRowButton",(()=>{const{exploreId:e,queryKeys:t}=this.props;this.props.addQueryRow(e,t.length)})),Us(this,"onMakeAbsoluteTime",(()=>{const{makeAbsoluteTime:e}=this.props;e()})),Us(this,"onModifyQueries",((e,t)=>{const{datasourceInstance:i}=this.props;if(null!=i&&i.modifyQuery){const s=(e,t)=>i.modifyQuery(e,t);this.props.modifyQueries(this.props.exploreId,e,s,t)}})),Us(this,"onResize",(e=>{this.props.changeSize(this.props.exploreId,e)})),Us(this,"onStartScanning",(()=>{this.props.scanStart(this.props.exploreId)})),Us(this,"onStopScanning",(()=>{this.props.scanStopAction({exploreId:this.props.exploreId})})),Us(this,"onUpdateTimeRange",(e=>{const{exploreId:t,updateTimeRange:i}=this.props;i({exploreId:t,absoluteRange:e})})),Us(this,"onChangeGraphStyle",(e=>{const{exploreId:t,changeGraphStyle:i}=this.props;i(t,e)})),Us(this,"toggleShowRichHistory",(()=>{this.setState((e=>({openDrawer:e.openDrawer===Vs.RichHistory?void 0:Vs.RichHistory})))})),Us(this,"toggleShowQueryInspector",(()=>{this.setState((e=>({openDrawer:e.openDrawer===Vs.QueryInspector?void 0:Vs.QueryInspector})))})),Us(this,"onSplitOpen",(e=>async t=>{if(this.props.splitOpen(t),t&&this.props.datasourceInstance){const i=(await(0,D.F)().get(t.datasourceUid)).type,s=this.props.datasourceInstance.uid===C.D?(0,T.get)(this.props.queries,"0.datasource.type"):this.props.datasourceInstance.type,o={origin:"panel",panelType:e,source:s,target:i,exploreId:this.props.exploreId};(0,$.ff)("grafana_explore_split_view_opened",o)}})),Us(this,"memoizedGetNodeGraphDataFrames",(0,x.Z)(q.Ee)),this.state={openDrawer:void 0}}componentDidMount(){this.absoluteTimeUnsubsciber=P.Z.subscribe(M.QI,this.onMakeAbsoluteTime)}componentWillUnmount(){var e;null===(e=this.absoluteTimeUnsubsciber)||void 0===e||e.unsubscribe()}renderEmptyState(e){return(0,ie.jsx)("div",{className:(0,s.cx)(e),children:Ws||(Ws=(0,ie.jsx)(Di,{}))})}renderNoData(){return Qs||(Qs=(0,ie.jsx)(Ii,{}))}renderGraphPanel(e){const{graphResult:t,absoluteRange:i,timeZone:s,queryResponse:o,loading:n,theme:r,graphStyle:a}=this.props,l=parseInt(r.spacing(2).slice(0,-2),10),c=(0,ie.jsx)(le,{graphStyle:a,onChangeGraphStyle:this.onChangeGraphStyle});return(0,ie.jsx)(N.U,{label:c,loading:n,isOpen:!0,children:(0,ie.jsx)(se,{graphStyle:a,data:t,height:400,width:e-l,absoluteRange:i,onChangeTime:this.onUpdateTimeRange,timeZone:s,annotations:o.annotations,splitOpenFn:this.onSplitOpen("graph"),loadingState:o.state})})}renderTablePanel(e){const{exploreId:t,datasourceInstance:i,timeZone:s}=this.props;return(0,ie.jsx)(Es,{ariaLabel:b.wl.pages.Explore.General.table,width:e,exploreId:t,onCellFilterAdded:null!=i&&i.modifyQuery?this.onCellFilterAdded:void 0,timeZone:s,splitOpenFn:this.onSplitOpen("table")})}renderLogsPanel(e){const{exploreId:t,syncedTimes:i,theme:s,queryResponse:o}=this.props,n=parseInt(s.spacing(2).slice(0,-2),10);return(0,ie.jsx)(zi,{exploreId:t,loadingState:o.state,syncedTimes:i,width:e-n,onClickFilterLabel:this.onClickFilterLabel,onClickFilterOutLabel:this.onClickFilterOutLabel,onStartScanning:this.onStartScanning,onStopScanning:this.onStopScanning,splitOpenFn:this.onSplitOpen("logs")})}renderNodeGraphPanel(){const{exploreId:e,showTrace:t,queryResponse:i,datasourceInstance:s}=this.props,o=s?null==s?void 0:s.type:"unknown";return(0,ie.jsx)(qi,{dataFrames:this.memoizedGetNodeGraphDataFrames(i.series),exploreId:e,withTraceView:t,datasourceType:o,splitOpenFn:this.onSplitOpen("nodeGraph")})}renderTraceViewPanel(){const{queryResponse:e,exploreId:t}=this.props,i=e.series.filter((e=>{var t;return"trace"===(null===(t=e.meta)||void 0===t?void 0:t.preferredVisualisationType)}));return i.length&&(0,ie.jsx)(Bs,{exploreId:t,dataFrames:i,splitOpenFn:this.onSplitOpen("traceView"),scrollElement:this.scrollElement,queryResponse:e,topOfViewRef:this.topOfViewRef})}render(){const{datasourceInstance:e,datasourceMissing:t,exploreId:i,graphResult:o,queryResponse:n,isLive:r,theme:l,showMetrics:c,showTable:d,showLogs:h,showTrace:p,showNodeGraph:u,timeZone:g}=this.props,{openDrawer:f}=this.state,m=(e=>({exploreMain:s.css`
      label: exploreMain;
      // Is needed for some transition animations to work.
      position: relative;
      margin-top: 21px;
    `,button:s.css`
      label: button;
      margin: 1em 4px 0 0;
    `,queryContainer:s.css`
      label: queryContainer;
      // Need to override normal css class and don't want to count on ordering of the classes in html.
      height: auto !important;
      flex: unset !important;
      display: unset !important;
      padding: ${e.spacing(1)};
    `,exploreContainer:s.css`
      display: flex;
      flex: 1 1 auto;
      flex-direction: column;
      padding: ${e.spacing(2)};
      padding-top: 0;
    `}))(l),y=n&&n.state!==O.Gu.NotStarted,x=f===Vs.RichHistory,v=!(0,A.X)().queryHistoryAvailable,w=f===Vs.QueryInspector,S=n.state===O.Gu.Done&&[n.logsFrames,n.graphFrames,n.nodeGraphFrames,n.tableFrames,n.traceFrames].every((e=>0===e.length));return(0,ie.jsxs)(H.$,{testId:b.wl.pages.Explore.General.scrollView,autoHeightMin:"100%",scrollRefCallback:e=>this.scrollElement=e||void 0,children:[(0,ie.jsx)(vt,{exploreId:i,onChangeTime:this.onChangeTime,topOfViewRef:this.topOfViewRef}),t?this.renderEmptyState(m.exploreContainer):null,e&&(0,ie.jsxs)("div",{className:(0,s.cx)(m.exploreContainer),children:[(0,ie.jsxs)(L.l,{className:m.queryContainer,children:[(0,ie.jsx)(Wi,{exploreId:i}),(0,ie.jsx)(Ds,{addQueryRowButtonDisabled:r,addQueryRowButtonHidden:!1,richHistoryRowButtonHidden:v,richHistoryButtonActive:x,queryInspectorButtonActive:w,onClickAddQueryRowButton:this.onClickAddQueryRowButton,onClickRichHistoryButton:this.toggleShowRichHistory,onClickQueryInspectorButton:this.toggleShowQueryInspector}),(0,ie.jsx)(Vi,{exploreId:i})]}),(0,ie.jsx)(k.Z,{onResize:this.onResize,disableHeight:!0,children:e=>{let{width:t}=e;return 0===t?null:(0,ie.jsx)("main",{className:(0,s.cx)(m.exploreMain),style:{width:t},children:(0,ie.jsxs)(a.z4,{children:[y&&(0,ie.jsxs)(ie.Fragment,{children:[c&&o&&(0,ie.jsx)(a.z4,{children:this.renderGraphPanel(t)}),d&&(0,ie.jsx)(a.z4,{children:this.renderTablePanel(t)}),h&&(0,ie.jsx)(a.z4,{children:this.renderLogsPanel(t)}),u&&(0,ie.jsx)(a.z4,{children:this.renderNodeGraphPanel()}),p&&(0,ie.jsx)(a.z4,{children:this.renderTraceViewPanel()}),S&&(0,ie.jsx)(a.z4,{children:this.renderNoData()})]}),x&&(0,ie.jsx)(Fs,{width:t,exploreId:i,onClose:this.toggleShowRichHistory}),w&&(0,ie.jsx)(Be,{exploreId:i,width:t,onClose:this.toggleShowQueryInspector,timeZone:g})]})})}})]})]})}}const Ks={changeSize:Zs.qN,changeGraphStyle:Zs.Rl,modifyQueries:f.sK,scanStart:f.EA,scanStopAction:f.P4,setQueries:f.KO,updateTimeRange:ut.cD,makeAbsoluteTime:ut.F9,addQueryRow:f.CS,splitOpen:g.bW},Ys=(0,n.connect)((function(e,t){let{exploreId:i}=t;const s=e.explore,{syncedTimes:o}=s,n=s[i],r=(0,I.Z)(e.user),{datasourceInstance:a,datasourceMissing:l,queryKeys:c,queries:d,isLive:h,graphResult:p,logsResult:u,showLogs:g,showMetrics:f,showTable:m,showTrace:y,absoluteRange:x,queryResponse:v,showNodeGraph:b,loading:w,graphStyle:S}=n;return{datasourceInstance:a,datasourceMissing:l,queryKeys:c,queries:d,isLive:h,graphResult:p,logsResult:null!=u?u:void 0,absoluteRange:x,queryResponse:v,syncedTimes:o,timeZone:r,showLogs:g,showMetrics:f,showTable:m,showTrace:y,showNodeGraph:b,loading:w,graphStyle:S}}),Ks),Js=(0,F.compose)(Ys,w.HE)(Gs);var Xs=i(72921);function eo(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class to extends o.PureComponent{constructor(e){super(e),eo(this,"el",null),eo(this,"exploreEvents",void 0),eo(this,"refreshExplore",(e=>{const{exploreId:t,urlQuery:i}=this.props;i!==e&&i!==g.IS[t]&&this.props.refreshExplore(t,i)})),eo(this,"getRef",(e=>{this.el=e})),this.exploreEvents=new v.F,this.state={openDrawer:void 0}}async componentDidMount(){var e,t;const{initialized:i,exploreId:s,initialDatasource:o,initialQueries:n,initialRange:r,panelsState:a,orgId:l}=this.props,c=null!==(e=null===(t=this.el)||void 0===t?void 0:t.offsetWidth)&&void 0!==e?e:0;if(!i){var d;let e,t;if((!n||0===n.length)&&o){if(!(o===C.D||o.uid===C.D)){const{instance:t}=await(0,Xs.r_)(l,o);e=t.getRef()}}let i=await(0,j.Z8)(n,e);if(!(0,j._o)(i).noneHaveDatasource&&!(0,j._o)(i).allDatasourceSame)if(S.vc.featureToggles.exploreMixedDatasource)t=await(0,z.ak)().get(C.D);else{const e=i.find((e=>{var t;return null===(t=e.datasource)||void 0===t?void 0:t.uid})).datasource.uid;if(e){t=e;const n=await(0,z.ak)().get(e),r=await(0,z.ak)().get(o);await this.props.importQueries(s,i,r,n),await this.props.stateSave({replace:!0}),i=this.props.initialQueries}}this.props.initializeExplore(s,t||(null===(d=i[0])||void 0===d?void 0:d.datasource)||o,i,r,c,this.exploreEvents,a)}}componentWillUnmount(){this.exploreEvents.removeAllListeners(),this.props.cleanupPaneAction({exploreId:this.props.exploreId})}componentDidUpdate(e){this.refreshExplore(e.urlQuery)}render(){const{theme:e,split:t,exploreId:i,initialized:o}=this.props,n=(e=>({explore:s.css`
      display: flex;
      flex: 1 1 auto;
      flex-direction: column;
      & + & {
        border-left: 1px dotted ${e.colors.border.medium};
      }
    `,exploreSplit:s.css`
      width: 50%;
    `}))(e),r=(0,s.cx)(n.explore,t&&n.exploreSplit);return(0,ie.jsx)("div",{className:r,ref:this.getRef,"data-testid":b.wl.pages.Explore.General.container,children:o&&(0,ie.jsx)(Js,{exploreId:i})})}}const io=(0,x.Z)(j.vP);const so={initializeExplore:Zs.CK,refreshExplore:Zs.Om,cleanupPaneAction:g.Jt,importQueries:f.GJ,stateSave:g.og},oo=(0,n.connect)((function(e,t){var i;const s=(0,j.J5)(t.urlQuery),o=(0,I.Z)(e.user),n=(0,I.i)(e.user),{datasource:r,queries:a,range:l,panelsState:c}=s||{},d=r||R.Z.get((0,j.I$)(e.user.orgId)),h=l?io(l,o,n):(0,j.OQ)(o,j.UI,n);return{initialized:null===(i=e.explore[t.exploreId])||void 0===i?void 0:i.initialized,initialDatasource:d,initialQueries:a,initialRange:h,panelsState:c,orgId:e.user.orgId}}),so),no=(0,w.HE)(oo(to));const ro={pageScrollbarWrapper:s.css`
    width: 100%;
    flex-grow: 1;
    min-height: 0;
  `,exploreWrapper:s.css`
    display: flex;
    height: 100%;
  `},ao={resetExploreAction:g.WK,richHistoryUpdatedAction:g.ZU},lo=(0,n.connect)((e=>({navModel:(0,h.h)(e.navIndex,"explore"),exploreState:e.explore})),ao);class co extends o.PureComponent{componentWillUnmount(){this.props.resetExploreAction({})}componentDidMount(){this.context.chrome.update({sectionNav:this.props.navModel.node}),this.context.keybindings.setupTimeRangeBindings(!1),g.IS.left=void 0,g.IS.right=void 0;const e=r.E1.getSearchObject();(e.from||e.to)&&r.E1.partial({from:void 0,to:void 0},!0)}componentDidUpdate(){var e,t,i,s;const{left:o,right:n}=this.props.queryParams,r=Boolean(o)&&Boolean(n)?`${null===(e=this.props.exploreState.left.datasourceInstance)||void 0===e?void 0:e.name} | ${null===(t=this.props.exploreState.right)||void 0===t||null===(i=t.datasourceInstance)||void 0===i?void 0:i.name}`:`${null===(s=this.props.exploreState.left.datasourceInstance)||void 0===s?void 0:s.name}`,a=`${this.props.navModel.main.text} - ${r} - ${d.c.AppTitle}`;document.title=a}render(){const{left:e,right:t}=this.props.queryParams,i=Boolean(e)&&Boolean(t);return(0,ie.jsxs)("div",{className:ro.pageScrollbarWrapper,children:[(0,ie.jsx)(y,{exploreIdLeft:c.K.left,exploreIdRight:c.K.right}),(0,ie.jsxs)("div",{className:ro.exploreWrapper,children:[(0,ie.jsx)(a.z4,{style:"page",children:(0,ie.jsx)(no,{split:i,exploreId:c.K.left,urlQuery:e})}),i&&(0,ie.jsx)(a.z4,{style:"page",children:(0,ie.jsx)(no,{split:i,exploreId:c.K.right,urlQuery:t})})]})]})}}var ho,po,uo;ho=co,po="contextType",uo=l.h,po in ho?Object.defineProperty(ho,po,{value:uo,enumerable:!0,configurable:!0,writable:!0}):ho[po]=uo;const go=lo(co)},25596:(e,t,i)=>{i.d(t,{F:()=>n,p:()=>o});var s=i(352);const o=e=>Boolean(e.explore[s.Kd.left]&&e.explore[s.Kd.right]),n=e=>t=>t.explore[e]},89177:(e,t,i)=>{i.d(t,{Z:()=>o});var s=i(76687);const o=function(e,t){var i=(0,s.useRef)((function(){}));(0,s.useEffect)((function(){i.current=e})),(0,s.useEffect)((function(){if(null!==t){var e=setInterval((function(){return i.current()}),t||0);return function(){return clearInterval(e)}}}),[t])}},45667:(e,t,i)=>{function s(e){for(var t=arguments.length,i=Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];throw Error("[Immer] minified error nr: "+e+(i.length?" "+i.map((function(e){return"'"+e+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function o(e){return!!e&&!!e[Q]}function n(e){return!!e&&(function(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var i=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return i===Object||"function"==typeof i&&Function.toString.call(i)===Z}(e)||Array.isArray(e)||!!e[W]||!!e.constructor[W]||p(e)||u(e))}function r(e,t,i){void 0===i&&(i=!1),0===a(e)?(i?Object.keys:U)(e).forEach((function(s){i&&"symbol"==typeof s||t(s,e[s],e)})):e.forEach((function(i,s){return t(s,i,e)}))}function a(e){var t=e[Q];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:p(e)?2:u(e)?3:0}function l(e,t){return 2===a(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function c(e,t){return 2===a(e)?e.get(t):e[t]}function d(e,t,i){var s=a(e);2===s?e.set(t,i):3===s?(e.delete(t),e.add(i)):e[t]=i}function h(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function p(e){return q&&e instanceof Map}function u(e){return M&&e instanceof Set}function g(e){return e.o||e.t}function f(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=V(e);delete t[Q];for(var i=U(t),s=0;s<i.length;s++){var o=i[s],n=t[o];!1===n.writable&&(n.writable=!0,n.configurable=!0),(n.get||n.set)&&(t[o]={configurable:!0,writable:!0,enumerable:n.enumerable,value:e[o]})}return Object.create(Object.getPrototypeOf(e),t)}function m(e,t){return void 0===t&&(t=!1),x(e)||o(e)||!n(e)||(a(e)>1&&(e.set=e.add=e.clear=e.delete=y),Object.freeze(e),t&&r(e,(function(e,t){return m(t,!0)}),!0)),e}function y(){s(2)}function x(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function v(e){var t=G[e];return t||s(18,e),t}function b(){return P}function w(e,t){t&&(v("Patches"),e.u=[],e.s=[],e.v=t)}function S(e){R(e),e.p.forEach(C),e.p=null}function R(e){e===P&&(P=e.l)}function j(e){return P={p:[],l:P,h:e,m:!0,_:0}}function C(e){var t=e[Q];0===t.i||1===t.i?t.j():t.O=!0}function z(e,t){t._=t.p.length;var i=t.p[0],o=void 0!==e&&e!==i;return t.h.g||v("ES5").S(t,e,o),o?(i[Q].P&&(S(t),s(4)),n(e)&&(e=I(t,e),t.l||k(t,e)),t.u&&v("Patches").M(i[Q].t,e,t.u,t.s)):e=I(t,i,[]),S(t),t.u&&t.v(t.u,t.s),e!==B?e:void 0}function I(e,t,i){if(x(t))return t;var s=t[Q];if(!s)return r(t,(function(o,n){return T(e,s,t,o,n,i)}),!0),t;if(s.A!==e)return t;if(!s.P)return k(e,s.t,!0),s.t;if(!s.I){s.I=!0,s.A._--;var o=4===s.i||5===s.i?s.o=f(s.k):s.o;r(3===s.i?new Set(o):o,(function(t,n){return T(e,s,o,t,n,i)})),k(e,o,!1),i&&e.u&&v("Patches").R(s,i,e.u,e.s)}return s.o}function T(e,t,i,s,r,a){if(o(r)){var c=I(e,r,a&&t&&3!==t.i&&!l(t.D,s)?a.concat(s):void 0);if(d(i,s,c),!o(c))return;e.m=!1}if(n(r)&&!x(r)){if(!e.h.F&&e._<1)return;I(e,r),t&&t.A.l||k(e,r)}}function k(e,t,i){void 0===i&&(i=!1),e.h.F&&e.m&&m(t,i)}function F(e,t){var i=e[Q];return(i?g(i):e)[t]}function O(e,t){if(t in e)for(var i=Object.getPrototypeOf(e);i;){var s=Object.getOwnPropertyDescriptor(i,t);if(s)return s;i=Object.getPrototypeOf(i)}}function D(e){e.P||(e.P=!0,e.l&&D(e.l))}function $(e){e.o||(e.o=f(e.t))}function N(e,t,i){var s=p(t)?v("MapSet").N(t,i):u(t)?v("MapSet").T(t,i):e.g?function(e,t){var i=Array.isArray(e),s={i:i?1:0,A:t?t.A:b(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},o=s,n=K;i&&(o=[s],n=Y);var r=Proxy.revocable(o,n),a=r.revoke,l=r.proxy;return s.k=l,s.j=a,l}(t,i):v("ES5").J(t,i);return(i?i.A:b()).p.push(s),s}function H(e){return o(e)||s(22,e),function e(t){if(!n(t))return t;var i,s=t[Q],o=a(t);if(s){if(!s.P&&(s.i<4||!v("ES5").K(s)))return s.t;s.I=!0,i=L(t,o),s.I=!1}else i=L(t,o);return r(i,(function(t,o){s&&c(s.t,t)===o||d(i,t,e(o))})),3===o?new Set(i):i}(e)}function L(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return f(e)}i.d(t,{ZP:()=>te});var E,P,A="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),q="undefined"!=typeof Map,M="undefined"!=typeof Set,_="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,B=A?Symbol.for("immer-nothing"):((E={})["immer-nothing"]=!0,E),W=A?Symbol.for("immer-draftable"):"__$immer_draftable",Q=A?Symbol.for("immer-state"):"__$immer_state",Z=("undefined"!=typeof Symbol&&Symbol.iterator,""+Object.prototype.constructor),U="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,V=Object.getOwnPropertyDescriptors||function(e){var t={};return U(e).forEach((function(i){t[i]=Object.getOwnPropertyDescriptor(e,i)})),t},G={},K={get:function(e,t){if(t===Q)return e;var i=g(e);if(!l(i,t))return function(e,t,i){var s,o=O(t,i);return o?"value"in o?o.value:null===(s=o.get)||void 0===s?void 0:s.call(e.k):void 0}(e,i,t);var s=i[t];return e.I||!n(s)?s:s===F(e.t,t)?($(e),e.o[t]=N(e.A.h,s,e)):s},has:function(e,t){return t in g(e)},ownKeys:function(e){return Reflect.ownKeys(g(e))},set:function(e,t,i){var s=O(g(e),t);if(null==s?void 0:s.set)return s.set.call(e.k,i),!0;if(!e.P){var o=F(g(e),t),n=null==o?void 0:o[Q];if(n&&n.t===i)return e.o[t]=i,e.D[t]=!1,!0;if(h(i,o)&&(void 0!==i||l(e.t,t)))return!0;$(e),D(e)}return e.o[t]===i&&"number"!=typeof i&&(void 0!==i||t in e.o)||(e.o[t]=i,e.D[t]=!0,!0)},deleteProperty:function(e,t){return void 0!==F(e.t,t)||t in e.t?(e.D[t]=!1,$(e),D(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var i=g(e),s=Reflect.getOwnPropertyDescriptor(i,t);return s?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:s.enumerable,value:i[t]}:s},defineProperty:function(){s(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){s(12)}},Y={};r(K,(function(e,t){Y[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Y.deleteProperty=function(e,t){return Y.set.call(this,e,t,void 0)},Y.set=function(e,t,i){return K.set.call(this,e[0],t,i,e[0])};var J=function(){function e(e){var t=this;this.g=_,this.F=!0,this.produce=function(e,i,o){if("function"==typeof e&&"function"!=typeof i){var r=i;i=e;var a=t;return function(e){var t=this;void 0===e&&(e=r);for(var s=arguments.length,o=Array(s>1?s-1:0),n=1;n<s;n++)o[n-1]=arguments[n];return a.produce(e,(function(e){var s;return(s=i).call.apply(s,[t,e].concat(o))}))}}var l;if("function"!=typeof i&&s(6),void 0!==o&&"function"!=typeof o&&s(7),n(e)){var c=j(t),d=N(t,e,void 0),h=!0;try{l=i(d),h=!1}finally{h?S(c):R(c)}return"undefined"!=typeof Promise&&l instanceof Promise?l.then((function(e){return w(c,o),z(e,c)}),(function(e){throw S(c),e})):(w(c,o),z(l,c))}if(!e||"object"!=typeof e){if(void 0===(l=i(e))&&(l=e),l===B&&(l=void 0),t.F&&m(l,!0),o){var p=[],u=[];v("Patches").M(e,l,p,u),o(p,u)}return l}s(21,e)},this.produceWithPatches=function(e,i){if("function"==typeof e)return function(i){for(var s=arguments.length,o=Array(s>1?s-1:0),n=1;n<s;n++)o[n-1]=arguments[n];return t.produceWithPatches(i,(function(t){return e.apply(void 0,[t].concat(o))}))};var s,o,n=t.produce(e,i,(function(e,t){s=e,o=t}));return"undefined"!=typeof Promise&&n instanceof Promise?n.then((function(e){return[e,s,o]})):[n,s,o]},"boolean"==typeof(null==e?void 0:e.useProxies)&&this.setUseProxies(e.useProxies),"boolean"==typeof(null==e?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze)}var t=e.prototype;return t.createDraft=function(e){n(e)||s(8),o(e)&&(e=H(e));var t=j(this),i=N(this,e,void 0);return i[Q].C=!0,R(t),i},t.finishDraft=function(e,t){var i=(e&&e[Q]).A;return w(i,t),z(void 0,i)},t.setAutoFreeze=function(e){this.F=e},t.setUseProxies=function(e){e&&!_&&s(20),this.g=e},t.applyPatches=function(e,t){var i;for(i=t.length-1;i>=0;i--){var s=t[i];if(0===s.path.length&&"replace"===s.op){e=s.value;break}}i>-1&&(t=t.slice(i+1));var n=v("Patches").$;return o(e)?n(e,t):this.produce(e,(function(e){return n(e,t)}))},e}(),X=new J,ee=X.produce;X.produceWithPatches.bind(X),X.setAutoFreeze.bind(X),X.setUseProxies.bind(X),X.applyPatches.bind(X),X.createDraft.bind(X),X.finishDraft.bind(X);const te=ee}}]);
//# sourceMappingURL=explore.ad1393e3833793b47103.js.map