VictoriaMetrics/app/vmselect/vmui/static/js/main.7fc9cf07.chunk.js
Yury Molodov 9baad51004
vmui: introduce application mode (#1949)
* feat: add a label for the Query field

* fix: change zoom position

* fix: add description and error code to alerts

* fix: correct logic query history

* fix: correct update query history

* feat: add custom step

* update package-lock.json

* feat: introduce application mode

* build vmui

* Revert "build vmui"

This reverts commit c0e2415550.

* app/vmselect/vmui: `make vmui-update`

Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
2021-12-15 21:33:25 +02:00

1 line
47 KiB
JavaScript

(this.webpackJsonpvmui=this.webpackJsonpvmui||[]).push([[0],{204:function(e,t,n){},219:function(e,t){},223:function(e,t,n){},224:function(e,t,n){},234:function(e,t,n){"use strict";n.r(t);var a=n(1),r=n.n(a),c=n(53),i=n.n(c),o=(n(204),n(9)),s=n(318),l=n(317),u=n(0),d=Object(a.createContext)({showInfoMessage:function(){}}),j=function(e){var t=e.children,n=Object(a.useState)({}),r=Object(o.a)(n,2),c=r[0],i=r[1],j=Object(a.useState)(!1),b=Object(o.a)(j,2),p=b[0],O=b[1],h=Object(a.useState)(void 0),f=Object(o.a)(h,2),x=f[0],v=f[1];Object(a.useEffect)((function(){x&&(i({message:x,key:(new Date).getTime()}),O(!0))}),[x]);return Object(u.jsxs)(d.Provider,{value:{showInfoMessage:v},children:[Object(u.jsx)(s.a,{open:p,autoHideDuration:4e3,onClose:function(e,t){"clickaway"!==t&&(v(void 0),O(!1))},children:Object(u.jsx)(l.a,{children:c.message})},c.key),t]})},b=n(352),p=n(353),O=n(328),h=n(246),f=n(344),x=n(242),v=n(329),m=n(331),y=n(323),g=n(327),S=n(149),E=n.n(S),_=n(3),T=n(16),w=n(40),C=n.n(w),A=n(145),R=n.n(A),I=n(146),k=n.n(I),U=n(105),M=n.n(U);C.a.extend(R.a),C.a.extend(k.a);var H,D=window.innerWidth/2,N=1,L=1578e8,P="YYYY-MM-DD[T]HH:mm:ss",q=[{long:"days",short:"d",possible:"day"},{long:"weeks",short:"w",possible:"week"},{long:"months",short:"M",possible:"mon"},{long:"years",short:"y",possible:"year"},{long:"hours",short:"h",possible:"hour"},{long:"minutes",short:"m",possible:"min"},{long:"seconds",short:"s",possible:"sec"},{long:"milliseconds",short:"ms",possible:"millisecond"}],Y=q.map((function(e){return e.short})),B=function(e){return+M()(e).format("0.000")},F=function(e){var t=e.match(/\d+/g),n=e.match(/[a-zA-Z]+/g);if(n&&t&&Y.includes(n[0]))return Object(_.a)({},n[0],t[0])},Q=function(e,t){var n=(t||new Date).valueOf()/1e3,a=e.trim().split(" ").reduce((function(e,t){var n=F(t);return n?Object(T.a)(Object(T.a)({},e),n):Object(T.a)({},e)}),{}),r=C.a.duration(a).asSeconds();return{start:n-r,end:n,step:B(r/D)||.001,date:z(t||new Date)}},z=function(e){return C()(e).utc().format(P)},G=function(e){var t=Math.floor(e%1e3),n=Math.floor(e/1e3%60),a=Math.floor(e/1e3/60%60),r=Math.floor(e/1e3/3600%24),c=Math.floor(e/864e5),i=["d","h","m","s","ms"];return[c,r,a,n,t].map((function(e,t){return e?"".concat(e).concat(i[t]):""})).filter((function(e){return e})).join(" ")},W=function(e){return new Date(1e3*e)},V=function(e,t){t?window.localStorage.setItem(e,JSON.stringify({value:t})):K([e])},J=function(e){var t=window.localStorage.getItem(e);if(null!==t)try{var n;return null===(n=JSON.parse(t))||void 0===n?void 0:n.value}catch(a){return t}},K=function(e){return e.forEach((function(e){return window.localStorage.removeItem(e)}))},X=["BASIC_AUTH_DATA","BEARER_AUTH_DATA"],Z=n(147),$=n.n(Z),ee=n(117),te=n.n(ee),ne=function(){var e,t=(null===(e=document.getElementById("root"))||void 0===e?void 0:e.dataset.params)||"{}";return JSON.parse(t)},ae=function(){return!!Object.keys(ne()).length},re={"time.duration":"range_input","time.period.date":"end_input","time.period.step":"step_input",displayType:"tab"},ce=ae(),ie=function(e){var t=window;if(t){var n="".concat(t.location.protocol,"//").concat(t.location.host).concat(t.location.pathname).concat(e?"?":"").concat(e);t.history.pushState({path:n},"",n)}},oe=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window.location.search,a=$.a.parse(n,{ignoreQueryPrefix:!0});return te()(a,e,t||"")},se=oe("g0.range_input","1h"),le=(H=oe("g0.end_input",new Date(C()().utc().format(P))),C()(H).utcOffset(0,!0).local().format(P)),ue=function(){var e,t=(null===(e=window.location.search.match(/g\d+.expr/gim))||void 0===e?void 0:e.length)||1;return new Array(t).fill(1).map((function(e,t){return oe("g".concat(t,".expr"),"")}))}(),de={serverUrl:window.location.href.replace(/\/(?:prometheus\/)?(?:graph|vmui)\/.*/,"/prometheus/"),displayType:oe("tab","chart"),query:ue,queryHistory:ue.map((function(e){return{index:0,values:[e]}})),time:{duration:se,period:Q(se,new Date(le))},queryControls:{autoRefresh:!1,autocomplete:J("AUTOCOMPLETE")||!1,nocache:J("NO_CACHE")||!1}};function je(e,t){switch(t.type){case"SET_DISPLAY_TYPE":return Object(T.a)(Object(T.a)({},e),{},{displayType:t.payload});case"SET_SERVER":return Object(T.a)(Object(T.a)({},e),{},{serverUrl:t.payload});case"SET_QUERY":return Object(T.a)(Object(T.a)({},e),{},{query:t.payload});case"SET_QUERY_HISTORY":return Object(T.a)(Object(T.a)({},e),{},{queryHistory:t.payload});case"SET_QUERY_HISTORY_BY_INDEX":return e.queryHistory.splice(t.payload.queryNumber,1,t.payload.value),Object(T.a)(Object(T.a)({},e),{},{queryHistory:e.queryHistory});case"SET_DURATION":return Object(T.a)(Object(T.a)({},e),{},{time:Object(T.a)(Object(T.a)({},e.time),{},{duration:t.payload,period:Q(t.payload,W(e.time.period.end))})});case"SET_UNTIL":return Object(T.a)(Object(T.a)({},e),{},{time:Object(T.a)(Object(T.a)({},e.time),{},{period:Q(e.time.duration,t.payload)})});case"SET_PERIOD":var n=function(e){var t=e.to.valueOf()-e.from.valueOf();return G(t)}(t.payload);return Object(T.a)(Object(T.a)({},e),{},{queryControls:Object(T.a)(Object(T.a)({},e.queryControls),{},{autoRefresh:!1}),time:Object(T.a)(Object(T.a)({},e.time),{},{duration:n,period:Q(n,t.payload.to)})});case"TOGGLE_AUTOREFRESH":return Object(T.a)(Object(T.a)({},e),{},{queryControls:Object(T.a)(Object(T.a)({},e.queryControls),{},{autoRefresh:!e.queryControls.autoRefresh})});case"TOGGLE_AUTOCOMPLETE":return Object(T.a)(Object(T.a)({},e),{},{queryControls:Object(T.a)(Object(T.a)({},e.queryControls),{},{autocomplete:!e.queryControls.autocomplete})});case"NO_CACHE":return Object(T.a)(Object(T.a)({},e),{},{queryControls:Object(T.a)(Object(T.a)({},e.queryControls),{},{nocache:!e.queryControls.nocache})});case"RUN_QUERY":return Object(T.a)(Object(T.a)({},e),{},{time:Object(T.a)(Object(T.a)({},e.time),{},{period:Q(e.time.duration,W(e.time.period.end))})});case"RUN_QUERY_TO_NOW":return Object(T.a)(Object(T.a)({},e),{},{time:Object(T.a)(Object(T.a)({},e.time),{},{period:Q(e.time.duration)})});default:throw new Error}}var be=Object(a.createContext)({}),pe=function(){return Object(a.useContext)(be).state},Oe=function(){return Object(a.useContext)(be).dispatch},he=Object.entries(de).reduce((function(e,t){var n=Object(o.a)(t,2),a=n[0],r=n[1];return Object(T.a)(Object(T.a)({},e),{},Object(_.a)({},a,oe(a)||r))}),{}),fe=function(e){var t=e.children,n=Object(a.useReducer)(je,he),r=Object(o.a)(n,2),c=r[0],i=r[1];Object(a.useEffect)((function(){!function(e){if(ce)ie("");else{var t=new Map(Object.entries(re)),n=te()(e,"query",""),a=[];n.forEach((function(n,r){t.forEach((function(t,n){var c=te()(e,n,"");if(c){var i=encodeURIComponent(c);a.push("g".concat(r,".").concat(t,"=").concat(i))}})),a.push("g".concat(r,".expr=").concat(n))})),ie(a.join("&"))}}(c)}),[c]);var s=Object(a.useMemo)((function(){return{state:c,dispatch:i}}),[c,i]);return Object(u.jsx)(be.Provider,{value:s,children:t})},xe=function(e){return Object(u.jsxs)(O.a,{position:"relative",display:"inline-flex",children:[Object(u.jsx)(v.a,Object(T.a)({variant:"determinate"},e)),Object(u.jsx)(O.a,{top:0,left:0,bottom:0,right:0,position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",children:Object(u.jsx)(h.a,{variant:"caption",component:"div",children:"".concat(e.label,"s")})})]})},ve=n(314),me=n(10),ye=n(330),ge=Object(me.a)(ye.a)((function(){return{padding:10,"& .MuiSwitch-track":{borderRadius:14,"&:before, &:after":{content:'""',position:"absolute",top:"50%",transform:"translateY(-50%)",width:14,height:14}},"& .MuiSwitch-thumb":{boxShadow:"none",width:12,height:12,margin:4}}})),Se=Object(ve.a)({colorizing:{color:"white"}}),Ee=function(){var e=Se(),t=Oe(),n=pe().queryControls.autoRefresh,c=Object(a.useState)(5),i=Object(o.a)(c,2),s=i[0],l=i[1],d=Object(a.useState)(),j=Object(o.a)(d,2),b=j[0],p=j[1],h=r.a.useState(100),f=Object(o.a)(h,2),x=f[0],v=f[1];Object(a.useEffect)((function(){var e;return n&&(p((new Date).valueOf()),e=setInterval((function(){p((new Date).valueOf()),t({type:"RUN_QUERY_TO_NOW"})}),1e3*s)),function(){e&&clearInterval(e)}}),[s,n]),Object(a.useEffect)((function(){var e=setInterval((function(){if(n&&b){var e=((new Date).valueOf()-b)/1e3,t=Math.floor(e/s*100);v(t)}}),16);return function(){clearInterval(e)}}),[n,b,s]);var S=function(){l((function(e){switch(e){case 1:return 2;default:return 5;case 5:return 1}}))};return Object(u.jsxs)(O.a,{display:"flex",alignItems:"center",children:[Object(u.jsx)(m.a,{control:Object(u.jsx)(ge,{className:e.colorizing,checked:n,onChange:function(){t({type:"TOGGLE_AUTOREFRESH"})}}),label:"Auto-refresh"}),n&&Object(u.jsxs)(u.Fragment,{children:[Object(u.jsx)(xe,{className:e.colorizing,label:s,value:x,onClick:function(){S()}}),Object(u.jsx)(y.a,{title:"Change delay refresh",children:Object(u.jsx)(O.a,{ml:1,children:Object(u.jsx)(g.a,{onClick:function(){S()},children:Object(u.jsx)(E.a,{style:{color:"white"}})})})})]})]})},_e=n(152),Te=n.n(_e),we=n(150),Ce=n.n(we),Ae=n(151),Re=n.n(Ae),Ie=n(333),ke=n(324),Ue=n(332),Me=Object(Ue.a)({root:{display:"grid",gridTemplateColumns:"18px auto",gridGap:6,padding:"8px 12px",color:"white",lineHeight:"19px","&.Mui-selected":{color:"white"}}})(Ie.a),He=function(){var e=pe().displayType,t=Oe();return Object(u.jsxs)(ke.a,{value:e,exclusive:!0,onChange:function(n,a){return t({type:"SET_DISPLAY_TYPE",payload:null!==a&&void 0!==a?a:e})},children:[Object(u.jsxs)(Me,{value:"chart","aria-label":"display as chart",children:[Object(u.jsx)(Ce.a,{}),Object(u.jsx)("span",{children:"Query Range as Chart"})]}),Object(u.jsxs)(Me,{value:"code","aria-label":"display as code",children:[Object(u.jsx)(Re.a,{}),Object(u.jsx)("span",{children:"Instant Query as JSON"})]}),Object(u.jsxs)(Me,{value:"table","aria-label":"display as table",children:[Object(u.jsx)(Te.a,{}),Object(u.jsx)("span",{children:"Instant Query as Table"})]})]})},De=n(21),Ne=n(153),Le={customStep:{enable:!1,value:1},yaxis:{limits:{enable:!1,range:{1:[0,0]}}}};function Pe(e,t){switch(t.type){case"TOGGLE_ENABLE_YAXIS_LIMITS":return Object(T.a)(Object(T.a)({},e),{},{yaxis:Object(T.a)(Object(T.a)({},e.yaxis),{},{limits:Object(T.a)(Object(T.a)({},e.yaxis.limits),{},{enable:!e.yaxis.limits.enable})})});case"TOGGLE_CUSTOM_STEP":return Object(T.a)(Object(T.a)({},e),{},{customStep:Object(T.a)(Object(T.a)({},e.customStep),{},{enable:!e.customStep.enable})});case"SET_CUSTOM_STEP":return Object(T.a)(Object(T.a)({},e),{},{customStep:Object(T.a)(Object(T.a)({},e.customStep),{},{value:t.payload})});case"SET_YAXIS_LIMITS":return Object(T.a)(Object(T.a)({},e),{},{yaxis:Object(T.a)(Object(T.a)({},e.yaxis),{},{limits:Object(T.a)(Object(T.a)({},e.yaxis.limits),{},{range:t.payload})})});default:throw new Error}}var qe,Ye=Object(a.createContext)({}),Be=function(){return Object(a.useContext)(Ye).state},Fe=function(){return Object(a.useContext)(Ye).dispatch},Qe=function(e){var t=e.children,n=Object(a.useReducer)(Pe,Le),r=Object(o.a)(n,2),c=r[0],i=r[1],s=Object(a.useMemo)((function(){return{state:c,dispatch:i}}),[c,i]);return Object(u.jsx)(Ye.Provider,{value:s,children:t})},ze=function(e){if(7!=e.length)return"0, 0, 0";var t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16);return"".concat(t,", ").concat(n,", ").concat(a)},Ge={height:500,legend:{show:!1},cursor:{drag:{x:!1,y:!1},focus:{prox:30},bind:{mouseup:function(){return null},mousedown:function(){return null},click:function(){return null},dblclick:function(){return null},mouseenter:function(){return null}}}},We=function(e,t){return t.map((function(e){return e>1e3?M()(e).format("0.0a"):e}))},Ve=function(e,t){return function(e){for(var t=0,n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);for(var a="#",r=0;r<3;r++)a+=("00"+(t>>8*r&255).toString(16)).substr(-2);return a}("".concat(e).concat(t))},Je=function(e){return e<=1?[]:[4*e,1.2*e]},Ke=function(e){for(var t=e.length,n=-1/0;t--;)e[t]>n&&(n=e[t]);return n},Xe=function(e){for(var t=e.length,n=1/0;t--;)e[t]<n&&(n=e[t]);return n},Ze=function(e){return Array.from(new Set(e.map((function(e){return e.scale})))).map((function(e){var t={scale:e,show:!0,font:"10px Arial",values:We};return e?Number(e)%2?t:Object(T.a)(Object(T.a)({},t),{},{side:1}):{space:80}}))},$e=function(e){var t,n,a=e.u,r=e.tooltipIdx,c=e.metrics,i=e.series,o=e.tooltip,s=e.tooltipOffset,l=r.seriesIdx,u=r.dataIdx,d=a.data[l][u],j=a.data[0][u],b=(null===(t=c[l-1])||void 0===t?void 0:t.metric)||{},p=Ve(Number(i[l].scale||0),i[l].label||""),O=a.over.getBoundingClientRect(),h=O.width,f=O.height,x=a.valToPos(d||0,(null===(n=i[l])||void 0===n?void 0:n.scale)||"1"),v=a.valToPos(j,"x"),m=o.getBoundingClientRect(),y=m.width,g=m.height,S=v+y>=h,E=x+g>=f;o.style.display="grid",o.style.top="".concat(s.top+x+10-(E?g+10:0),"px"),o.style.left="".concat(s.left+v+10-(S?y+20:0),"px");var _=C()(new Date(1e3*j)).format("YYYY-MM-DD HH:mm:ss:SSS (Z)"),T=Object.keys(b).filter((function(e){return"__name__"!==e})).map((function(e){return"<div><b>".concat(e,"</b>: ").concat(b[e],"</div>")})).join(""),w='<div class="u-tooltip__marker" style="background: '.concat(p,'"></div>');o.innerHTML="<div>".concat(_,'</div>\n <div class="u-tooltip-data">\n ').concat(w).concat(b.__name__||"",': <b class="u-tooltip-data__value">').concat(d,'</b>\n </div>\n <div class="u-tooltip__info">').concat(T,"</div>")},et=n(154),tt=n.n(et);n(222),n(223);!function(e){e.xRange="xRange",e.yRange="yRange",e.data="data"}(qe||(qe={}));var nt,at=function(e){var t=e.data,n=e.series,r=e.metrics,c=void 0===r?[]:r,i=e.limits,s=Oe(),l=pe().time.period,d=Be().yaxis,j=Object(a.useRef)(null),b=Object(a.useRef)(null),p=Object(a.useState)(!1),O=Object(o.a)(p,2),h=O[0],f=O[1],x=Object(a.useState)({min:l.start,max:l.end}),v=Object(o.a)(x,2),m=v[0],y=v[1],g=Object(a.useState)(),S=Object(o.a)(g,2),E=S[0],_=S[1],w=document.createElement("div");w.className="u-tooltip";var C={seriesIdx:1,dataIdx:0},A={left:0,top:0},R=Object(a.useCallback)(tt()((function(e){var t=e.min,n=e.max;s({type:"SET_PERIOD",payload:{from:new Date(1e3*t),to:new Date(1e3*n)}})}),500),[]),I=function(e){var t=e.u,n=e.min,a=e.max,r=1e3*(a-n);r<N||r>L||(t.setScale("x",{min:n,max:a}),y({min:n,max:a}),R({min:n,max:a}))},k=function(){return[m.min,m.max]},U=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3?arguments[3]:void 0;return d.limits.enable?d.limits.range[a]:t&&n?[t-.05*t,n+.05*n]:i[a]},M=Object(T.a)(Object(T.a)({},Ge),{},{series:n,axes:Ze(n),scales:Object(T.a)({},function(){var e={x:{range:k}};return Object.keys(d.limits.range).forEach((function(t){e[t]={range:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return U(e,n,a,t)}}})),e}()),width:j.current?j.current.offsetWidth:400,plugins:[{hooks:{ready:function(e){var t,n=.85;A.left=parseFloat(e.over.style.left),A.top=parseFloat(e.over.style.top),null===(t=e.root.querySelector(".u-wrap"))||void 0===t||t.appendChild(w),e.over.addEventListener("mousedown",(function(t){return function(e){var t=e.e,n=e.factor,a=void 0===n?.85:n,r=e.u,c=e.setPanning,i=e.setPlotScale;if(0===t.button){t.preventDefault(),c(!0);var o=t.clientX,s=r.posToVal(1,"x")-r.posToVal(0,"x"),l=r.scales.x.min||0,u=r.scales.x.max||0,d=function(e){e.preventDefault();var t=s*((e.clientX-o)*a);i({u:r,min:l-t,max:u-t})};document.addEventListener("mousemove",d),document.addEventListener("mouseup",(function e(){c(!1),document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",e)}))}}({u:e,e:t,setPanning:f,setPlotScale:I,factor:n})})),e.over.addEventListener("wheel",(function(t){if(t.ctrlKey||t.metaKey){t.preventDefault();var a=e.over.getBoundingClientRect().width,r=e.cursor.left&&e.cursor.left>0?e.cursor.left:0,c=e.posToVal(r,"x"),i=(e.scales.x.max||0)-(e.scales.x.min||0),o=t.deltaY<0?i*n:i/n,s=c-r/a*o,l=s+o;e.batch((function(){return I({u:e,min:s,max:l})}))}}))},setCursor:function(e){C.dataIdx!==e.cursor.idx&&(C.dataIdx=e.cursor.idx||0,C.seriesIdx&&C.dataIdx&&$e({u:e,tooltipIdx:C,metrics:c,series:n,tooltip:w,tooltipOffset:A}))},setSeries:function(e,t){C.seriesIdx!==t&&(C.seriesIdx=t||0,t&&C.dataIdx?$e({u:e,tooltipIdx:C,metrics:c,series:n,tooltip:w,tooltipOffset:A}):w.style.display="none")}}}]}),H=function(e){if(E){switch(e){case qe.xRange:E.scales.x.range=k;break;case qe.yRange:Object.keys(d.limits.range).forEach((function(e){E.scales[e]&&(E.scales[e].range=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return U(t,n,a,e)})}));break;case qe.data:E.setData(t)}E.redraw()}};return Object(a.useEffect)((function(){return y({min:l.start,max:l.end})}),[l]),Object(a.useEffect)((function(){if(b.current){var e=new Ne.a(M,t,b.current);return _(e),y({min:l.start,max:l.end}),e.destroy}}),[b.current,n]),Object(a.useEffect)((function(){return H(qe.data)}),[t]),Object(a.useEffect)((function(){return H(qe.xRange)}),[m]),Object(a.useEffect)((function(){return H(qe.yRange)}),[d]),Object(u.jsx)("div",{ref:j,style:{pointerEvents:h?"none":"auto",height:"500px"},children:Object(u.jsx)("div",{ref:b})})},rt=(n(224),function(e){var t=e.labels,n=e.onChange,r=pe().query,c=Object(a.useMemo)((function(){return Array.from(new Set(t.map((function(e){return e.group}))))}),[t]);return Object(u.jsx)("div",{className:"legendWrapper",children:c.map((function(e){return Object(u.jsxs)("div",{className:"legendGroup",children:[Object(u.jsxs)("div",{className:"legendGroupTitle",children:[Object(u.jsx)("svg",{className:"legendGroupLine",width:"33",height:"3",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:Object(u.jsx)("line",{strokeWidth:"3",x1:"0",y1:"0",x2:"33",y2:"0",stroke:"#363636",strokeDasharray:Je(e).join(",")})}),Object(u.jsxs)("b",{children:['"',r[e-1],'"']}),":"]}),Object(u.jsx)("div",{children:t.filter((function(t){return t.group===e})).map((function(e){return Object(u.jsxs)("div",{className:e.checked?"legendItem":"legendItem legendItemHide",onClick:function(t){return n(e,t.ctrlKey||t.metaKey)},children:[Object(u.jsx)("div",{className:"legendMarker",style:{borderColor:e.color,backgroundColor:"rgba(".concat(ze(e.color),", 0.1)")}}),Object(u.jsx)("div",{className:"legendLabel",children:e.label})]},"".concat(e.group,".").concat(e.label))}))})]},e)}))})}),ct=n(115),it=["__name__"],ot=function(e,t){var n=function(e){if(0===Object.keys(e.metric).length)return"Query result";var t=e.metric,n=t.__name__,a=Object(ct.a)(t,it);return"".concat(n||""," {").concat(Object.entries(a).map((function(e){return"".concat(e[0],": ").concat(e[1])})).join(", "),"}")}(e);return{label:n,dash:Je(e.group),width:1.5,stroke:Ve(e.group,n),show:!lt(n,e.group,t),scale:String(e.group)}},st=function(e,t){return{group:t,label:e.label||"",color:e.stroke,checked:e.show||!1}},lt=function(e,t,n){return n.includes("".concat(t,".").concat(e))},ut=n(156),dt=n.n(ut),jt=n(315),bt=n(106),pt=n.n(bt),Ot=function(){var e=Be().yaxis,t=Fe(),n=Object(a.useMemo)((function(){return Object.keys(e.limits.range)}),[e.limits.range]),r=Object(a.useCallback)(pt()((function(n,a,r){var c=e.limits.range;c[a][r]=+n.target.value,t({type:"SET_YAXIS_LIMITS",payload:c})}),500),[e.limits.range]);return Object(u.jsxs)(O.a,{display:"grid",alignItems:"center",gap:2,children:[Object(u.jsx)(m.a,{control:Object(u.jsx)(ge,{checked:e.limits.enable,onChange:function(){t({type:"TOGGLE_ENABLE_YAXIS_LIMITS"})}}),label:"Fix the limits for y-axis"}),Object(u.jsx)(O.a,{display:"grid",alignItems:"center",gap:2,children:n.map((function(t){return Object(u.jsxs)(O.a,{display:"grid",gridTemplateColumns:"120px 120px",gap:1,children:[Object(u.jsx)(jt.a,{label:"Min ".concat(t),type:"number",size:"small",variant:"outlined",disabled:!e.limits.enable,defaultValue:e.limits.range[t][0],onChange:function(e){return r(e,t,0)}}),Object(u.jsx)(jt.a,{label:"Max ".concat(t),type:"number",size:"small",variant:"outlined",disabled:!e.limits.enable,defaultValue:e.limits.range[t][1],onChange:function(e){return r(e,t,1)}})]},t)}))})]})},ht=n(325),ft=n(178),xt=n(155),vt=n.n(xt),mt=n(157),yt=n.n(mt),gt=Object(ve.a)({popover:{position:"absolute",display:"grid",gridGap:"16px",padding:"0 0 25px",zIndex:2},popoverHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",background:"#3F51B5",padding:"6px 6px 6px 12px",borderRadius:"4px 4px 0 0",color:"#FFF",cursor:"move"},popoverBody:{display:"grid",gridGap:"6px",padding:"0 14px"}}),St=function(){var e=Object(a.useState)(!1),t=Object(o.a)(e,2),n=t[0],r=t[1],c=Object(a.useRef)(null),i=gt();return Object(u.jsxs)(O.a,{display:"flex",px:2,children:[Object(u.jsxs)(ht.a,{onClick:function(){return r((function(e){return!e}))},variant:"outlined",children:[Object(u.jsx)(dt.a,{sx:{fontSize:16,marginRight:"4px"}}),Object(u.jsxs)("span",{style:{lineHeight:1,paddingTop:"1px"},children:[n?"Hide":"Show"," graph settings"]})]}),n&&Object(u.jsx)(vt.a,{nodeRef:c,defaultPosition:{x:173,y:0},handle:"#handle",children:Object(u.jsxs)(ft.a,{elevation:3,className:i.popover,ref:c,children:[Object(u.jsxs)("div",{id:"handle",className:i.popoverHeader,children:[Object(u.jsx)(h.a,{variant:"body1",children:Object(u.jsx)("b",{children:"Graph Settings"})}),Object(u.jsx)(g.a,{size:"small",onClick:function(){return r(!1)},children:Object(u.jsx)(yt.a,{style:{color:"white"}})})]}),Object(u.jsx)(O.a,{className:i.popoverBody,children:Object(u.jsx)(Ot,{})})]})})]})},Et=function(e){var t=e.data,n=void 0===t?[]:t,r=Fe(),c=Object(a.useState)([[]]),i=Object(o.a)(c,2),s=i[0],l=i[1],d=Object(a.useState)([]),j=Object(o.a)(d,2),b=j[0],p=j[1],O=Object(a.useState)([]),h=Object(o.a)(O,2),f=h[0],x=h[1],v=Object(a.useState)([]),m=Object(o.a)(v,2),y=m[0],g=m[1],S=Object(a.useState)({1:[0,1]}),E=Object(o.a)(S,2),_=E[0],T=E[1],w=function(e){var t=function(e){var t={};for(var n in e){var a=e[n],r=Xe(a),c=Ke(a);t[n]=[r-.05*r,c+.05*c]}return t}(e);T(t),r({type:"SET_YAXIS_LIMITS",payload:t})};return Object(a.useEffect)((function(){var e=[],t={},a=[],r=[];null===n||void 0===n||n.forEach((function(n){var c=ot(n,y);r.push(c),a.push(st(c,n.group)),n.values.forEach((function(a){e.push(a[0]),t[n.group]?t[n.group].push(+a[1]):t[n.group]=[+a[1]]}))}));var c=function(e){var t=Array.from(new Set(e)).sort((function(e,t){return e-t})),n=Xe(t.map((function(e,n){return t[n+1]-e}))),a=t[0]||0;return new Array(t.length).fill(a).map((function(e,t){return B(e+n*t)}))}(e);l([c].concat(Object(De.a)(n.map((function(e){return new Array(c.length).fill(1).map((function(t,n){return e.values[n]?+e.values[n][1]:null}))}))))),w(t);var i=[{}].concat(r);JSON.stringify(i)!==JSON.stringify(b)&&(p(i),x(a))}),[n]),Object(a.useEffect)((function(){var e=[],t=[];null===n||void 0===n||n.forEach((function(n){var a=ot(n,y);t.push(a),e.push(st(a,n.group))})),p([{}].concat(t)),x(e)}),[y]),Object(u.jsx)(u.Fragment,{children:n.length>0?Object(u.jsxs)("div",{children:[Object(u.jsx)(St,{}),Object(u.jsx)(at,{data:s,series:b,metrics:n,limits:_}),Object(u.jsx)(rt,{labels:f,onChange:function(e,t){g(function(e){var t=e.hideSeries,n=e.legend,a=e.metaKey,r=e.series,c="".concat(n.group,".").concat(n.label),i=lt(n.label,n.group,t),o=r.map((function(e){return"".concat(e.scale,".").concat(e.label)}));return a&&i?Object(De.a)(o.filter((function(e){return e!==c}))):a&&!i?t.length>=r.length-1?[]:Object(De.a)(o.filter((function(e){return e!==c}))):i?t.filter((function(e){return e!==c})):[].concat(Object(De.a)(t),[c])}({hideSeries:y,legend:e,metaKey:t,series:b}))}})]}):Object(u.jsx)("div",{style:{textAlign:"center"},children:"No data to show"})})},_t=n(338),Tt=n(339),wt=n(340),Ct=n(341),At=n(342),Rt=n(343),It=Object(ve.a)({deemphasized:{opacity:.4}}),kt=function(e){var t=e.data,n=It(),r=function(e){return Object(a.useMemo)((function(){var t={};return e.forEach((function(e){return Object.entries(e.metric).forEach((function(e){return t[e[0]]?t[e[0]].options.add(e[1]):t[e[0]]={options:new Set([e[1]])}}))})),Object.entries(t).map((function(e){return{key:e[0],variations:e[1].options.size}})).sort((function(e,t){return e.variations-t.variations}))}),[e])}(t),c=Object(a.useMemo)((function(){return null===t||void 0===t?void 0:t.map((function(e){return{metadata:r.map((function(t){return e.metric[t.key]||"-"})),value:e.value?e.value[1]:"-"}}))}),[r,t]);return Object(u.jsx)(u.Fragment,{children:c.length>0?Object(u.jsx)(_t.a,{component:ft.a,children:Object(u.jsxs)(Tt.a,{"aria-label":"simple table",children:[Object(u.jsx)(wt.a,{children:Object(u.jsxs)(Ct.a,{children:[r.map((function(e,t){return Object(u.jsx)(At.a,{style:{textTransform:"capitalize"},children:e.key},t)})),Object(u.jsx)(At.a,{align:"right",children:"Value"})]})}),Object(u.jsx)(Rt.a,{children:c.map((function(e,t){return Object(u.jsxs)(Ct.a,{children:[e.metadata.map((function(e,a){var r=c[t-1]&&c[t-1].metadata[a];return Object(u.jsx)(At.a,{className:r===e?n.deemphasized:void 0,children:e},a)})),Object(u.jsx)(At.a,{align:"right",children:e.value})]},t)}))})]})}):Object(u.jsx)("div",{style:{textAlign:"center"},children:"No data to show"})})},Ut=n(321),Mt=n(350),Ht=n(351),Dt=n(326),Nt=n(6),Lt=n(13),Pt=n(110),qt=n(172),Yt=n(174);!function(e){e.emptyServer="Please enter Server URL",e.validServer="Please provide a valid Server URL",e.validQuery="Please enter a valid Query and execute it"}(nt||(nt={}));var Bt=function(e){var t=e.index,n=e.query,r=e.queryHistory,c=e.setHistoryIndex,i=e.setQuery,s=e.runQuery,l=e.server,d=e.oneLiner,j=void 0!==d&&d,b=e.autocomplete,p=e.error,O=Object(a.useRef)(null),h=Object(a.useState)(),f=Object(o.a)(h,2),x=f[0],v=f[1],m=Object(a.useState)(!1),y=Object(o.a)(m,2),g=y[0],S=y[1];Object(a.useEffect)((function(){return O.current&&v(new Lt.d({parent:O.current})),function(){return null===x||void 0===x?void 0:x.destroy()}}),[]),Object(a.useEffect)((function(){var e=new qt.a;e.activateCompletion(b),e.setComplete({remote:{url:l}});var a=Lt.d.updateListener.of((function(e){e.focusChanged&&S((null===x||void 0===x?void 0:x.hasFocus)||!1),e.docChanged&&i(e.state.doc.toJSON().map((function(e){return e.trim()})).join(""),t)}));null===x||void 0===x||x.setState(Nt.f.create({doc:n,extensions:[Yt.a,Lt.k.of(Pt.a),a,e.asExtension()]}))}),[l,x,b,r]);return Object(u.jsxs)("div",{className:"query-editor-container \n ".concat(g?"query-editor-container_focus":"","\n query-editor-container-").concat(j?"one-line":"multi-line","\n ").concat(p===nt.validQuery?"query-editor-container_error":""),children:[Object(u.jsx)("label",{className:"query-editor-label",children:"Query"}),Object(u.jsx)("div",{className:"query-editor",ref:O,onKeyUp:function(e){var n=e.key,a=e.ctrlKey,r=e.metaKey,i=a||r;"Enter"===n&&i?s():"ArrowUp"===n&&i?c(-1,t):"ArrowDown"===n&&i&&c(1,t)}})]})},Ft=n(336),Qt=n(312),zt=function(){return Object(u.jsx)(_t.a,{component:ft.a,children:Object(u.jsxs)(Tt.a,{"aria-label":"simple table",size:"small",children:[Object(u.jsx)(wt.a,{children:Object(u.jsxs)(Ct.a,{children:[Object(u.jsx)(At.a,{children:"Long"}),Object(u.jsx)(At.a,{children:"Short"})]})}),Object(u.jsx)(Rt.a,{children:q.map((function(e,t){return Object(u.jsxs)(Ct.a,{children:[Object(u.jsx)(At.a,{component:"th",scope:"row",children:e.long}),Object(u.jsx)(At.a,{children:e.short})]},t)}))})]})})},Gt=Object(ve.a)({inlineBtn:{"&:hover":{cursor:"pointer"}}}),Wt=function(e){var t=e.handler,n=e.text,a=Gt();return Object(u.jsx)(f.a,{component:"span",className:a.inlineBtn,onClick:t,children:n})},Vt=Object(ve.a)({container:{display:"grid",gridTemplateColumns:"auto auto",height:"100%",padding:"18px 14px",borderRadius:"4px",borderColor:"#b9b9b9",borderStyle:"solid",borderWidth:"1px"}}),Jt=function(e){var t=e.setDuration,n=Vt(),c=Object(a.useState)(!1),i=Object(o.a)(c,2),s=i[0],l=i[1],d=r.a.useState(null),j=Object(o.a)(d,2),b=j[0],p=j[1],f=Object(a.useState)(),x=Object(o.a)(f,2),v=x[0],m=x[1],y=pe().time,g=y.period.end,S=y.duration,E=Oe(),_=Object(a.useState)(S),w=Object(o.a)(_,2),A=w[0],R=w[1];Object(a.useEffect)((function(){R(S)}),[S]),Object(a.useEffect)((function(){m(function(e){return C()(e).format(P)}(W(g)))}),[g]),Object(a.useEffect)((function(){if(!s){var e=function(e){var t=e.trim().split(" ").reduce((function(e,t){var n=F(t);return n?Object(T.a)(Object(T.a)({},e),n):Object(T.a)({},e)}),{}),n=C.a.duration(t).asMilliseconds();return n<N?G(N):n>L?G(L):e}(A);R(e),t(e)}}),[A,s]);var I=function(){p(null)},k=Boolean(b);return Object(u.jsxs)(O.a,{className:n.container,children:[Object(u.jsxs)(O.a,{px:1,children:[Object(u.jsx)(O.a,{children:Object(u.jsx)(jt.a,{label:"Duration",value:A,onChange:function(e){R(e.target.value)},variant:"standard",fullWidth:!0,onKeyUp:function(e){if("Enter"===e.key){var t=e.target;t.blur(),R(t.value)}},onBlur:function(){l(!1)},onFocus:function(){l(!0)}})}),Object(u.jsx)(O.a,{mt:2,children:Object(u.jsxs)(h.a,{variant:"body2",children:[Object(u.jsx)("span",{"aria-owns":k?"mouse-over-popover":void 0,"aria-haspopup":"true",style:{cursor:"pointer"},onMouseEnter:function(e){p(e.currentTarget)},onMouseLeave:I,children:"Possible options:\xa0"}),Object(u.jsx)(Ft.a,{open:k,anchorEl:b,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},style:{pointerEvents:"none"},onClose:I,disableRestoreFocus:!0,children:Object(u.jsx)(zt,{})}),Object(u.jsx)(Wt,{handler:function(){return R("5m")},text:"5m"}),",\xa0",Object(u.jsx)(Wt,{handler:function(){return R("1h")},text:"1h"}),",\xa0",Object(u.jsx)(Wt,{handler:function(){return R("1h 30m")},text:"1h 30m"})]})})]}),Object(u.jsxs)(O.a,{px:1,children:[Object(u.jsx)(O.a,{children:Object(u.jsx)(Qt.a,{label:"Until",ampm:!1,value:v,onChange:function(e){return E({type:"SET_UNTIL",payload:e})},onError:console.log,inputFormat:"DD/MM/YYYY HH:mm:ss",mask:"__/__/____ __:__:__",renderInput:function(e){return Object(u.jsx)(jt.a,Object(T.a)(Object(T.a)({},e),{},{variant:"standard"}))}})}),Object(u.jsx)(O.a,{mt:2,children:Object(u.jsxs)(h.a,{variant:"body2",children:["Will be changed to current time for auto-refresh mode.\xa0",Object(u.jsx)(Wt,{handler:function(){return E({type:"RUN_QUERY_TO_NOW"})},text:"Switch to now"})]})})]})]})},Kt=n(162),Xt=n.n(Kt),Zt=n(164),$t=n.n(Zt),en=n(165),tn=n.n(en),nn=n(163),an=n.n(nn),rn=n(302),cn=n(161),on=n.n(cn),sn=n(309),ln=n(307),un=n(347),dn=n(349),jn=n(316),bn=n(345),pn=n(335),On=n(322),hn=n(334),fn=n(346),xn=n(320),vn=n(337),mn=n(348),yn=n(308),gn=["children","value","index"],Sn=function(e){var t=e.children,n=e.value,a=e.index,r=Object(ct.a)(e,gn);return Object(u.jsx)("div",Object(T.a)(Object(T.a)({role:"tabpanel",hidden:n!==a,id:"auth-config-tabpanel-".concat(a),"aria-labelledby":"auth-config-tab-".concat(a)},r),{},{children:n===a&&Object(u.jsx)(O.a,{py:2,children:t})}))},En=n(159),_n=n.n(En),Tn=n(160),wn=n.n(Tn),Cn={authMethod:"NO_AUTH",saveAuthLocally:!1},An=J("AUTH_TYPE"),Rn=J("BASIC_AUTH_DATA"),In=J("BEARER_AUTH_DATA"),kn=Object(T.a)(Object(T.a)({},Cn),{},{authMethod:An||Cn.authMethod,basicData:Rn,bearerData:In,saveAuthLocally:!(!Rn&&!In)}),Un=function(){K(X)};function Mn(e,t){switch(t.type){case"SET_BASIC_AUTH":return t.payload.checkbox?V("BASIC_AUTH_DATA",t.payload.value):Un(),V("AUTH_TYPE","BASIC_AUTH"),Object(T.a)(Object(T.a)({},e),{},{authMethod:"BASIC_AUTH",basicData:t.payload.value});case"SET_BEARER_AUTH":return t.payload.checkbox?V("BEARER_AUTH_DATA",t.payload.value):Un(),V("AUTH_TYPE","BEARER_AUTH"),Object(T.a)(Object(T.a)({},e),{},{authMethod:"BEARER_AUTH",bearerData:t.payload.value});case"SET_NO_AUTH":return!t.payload.checkbox&&Un(),V("AUTH_TYPE","NO_AUTH"),Object(T.a)(Object(T.a)({},e),{},{authMethod:"NO_AUTH"});default:throw new Error}}var Hn=Object(a.createContext)({}),Dn=function(){return Object(a.useContext)(Hn).state},Nn=function(e){var t=e.children,n=Object(a.useReducer)(Mn,kn),r=Object(o.a)(n,2),c=r[0],i=r[1],s=Object(a.useMemo)((function(){return{state:c,dispatch:i}}),[c,i]);return Object(u.jsx)(Hn.Provider,{value:s,children:t})},Ln=Object(ve.a)((function(){return Object(yn.a)({tabsContent:{height:"200px"}})})),Pn="Bearer ",qn=[{title:"No auth",id:"NO_AUTH"},{title:"Basic Auth",id:"BASIC_AUTH"},{title:"Bearer Token",id:"BEARER_AUTH"}],Yn=function(e){var t=Ln(),n=e.onClose,r=e.open,c=Dn(),i=c.saveAuthLocally,s=c.basicData,l=c.bearerData,d=c.authMethod,j=Object(a.useContext)(Hn).dispatch,b=Object(a.useState)(i),p=Object(o.a)(b,2),f=p[0],x=p[1],v=Object(a.useState)(s||{password:"",login:""}),y=Object(o.a)(v,2),g=y[0],S=y[1],E=Object(a.useState)((null===l||void 0===l?void 0:l.token)||Pn),_=Object(o.a)(E,2),w=_[0],C=_[1],A=Object(a.useState)(qn.findIndex((function(e){return e.id===d}))||0),R=Object(o.a)(A,2),I=R[0],k=R[1],U=function(){n()};return Object(u.jsxs)(ln.a,{onClose:U,"aria-labelledby":"simple-dialog-title",open:r,children:[Object(u.jsx)(sn.a,{id:"simple-dialog-title",children:"Request Auth Settings"}),Object(u.jsxs)(un.a,{children:[Object(u.jsx)(dn.a,{children:"This affects Authorization header sent to the server you specify. Not shown in URL and can be optionally stored on a client side"}),Object(u.jsx)(jn.a,{value:I,onChange:function(e,t){k(t)},indicatorColor:"primary",textColor:"primary",children:qn.map((function(e){return Object(u.jsx)(bn.a,{label:e.title},e.id)}))}),Object(u.jsxs)(O.a,{p:0,display:"flex",flexDirection:"column",className:t.tabsContent,children:[Object(u.jsxs)(O.a,{flexGrow:1,children:[Object(u.jsx)(Sn,{value:I,index:0,children:Object(u.jsx)(h.a,{style:{fontStyle:"italic"},children:"No Authorization Header"})}),Object(u.jsxs)(Sn,{value:I,index:1,children:[Object(u.jsxs)(pn.a,{margin:"dense",fullWidth:!0,children:[Object(u.jsx)(On.a,{htmlFor:"basic-login",children:"User"}),Object(u.jsx)(hn.a,{id:"basic-login",startAdornment:Object(u.jsx)(fn.a,{position:"start",children:Object(u.jsx)(_n.a,{})}),required:!0,onChange:function(e){return S((function(t){return Object(T.a)(Object(T.a)({},t),{},{login:e.target.value||""})}))},value:(null===g||void 0===g?void 0:g.login)||""})]}),Object(u.jsxs)(pn.a,{margin:"dense",fullWidth:!0,children:[Object(u.jsx)(On.a,{htmlFor:"basic-pass",children:"Password"}),Object(u.jsx)(hn.a,{id:"basic-pass",startAdornment:Object(u.jsx)(fn.a,{position:"start",children:Object(u.jsx)(wn.a,{})}),onChange:function(e){return S((function(t){return Object(T.a)(Object(T.a)({},t),{},{password:e.target.value||""})}))},value:(null===g||void 0===g?void 0:g.password)||""})]})]}),Object(u.jsx)(Sn,{value:I,index:2,children:Object(u.jsx)(jt.a,{id:"bearer-auth",label:"Bearer token",multiline:!0,fullWidth:!0,value:w,onChange:function(e){var t=e.target.value;t.startsWith(Pn)?C(t):C(Pn)},InputProps:{onPaste:function(e){var t=e.clipboardData.getData("text/plain");t.startsWith(Pn)?C(t):C(Pn+t),e.preventDefault()}},maxRows:6})})]}),Object(u.jsxs)(pn.a,{children:[Object(u.jsx)(m.a,{control:Object(u.jsx)(xn.a,{checked:f,onChange:function(){return x((function(e){return!e}))},name:"checkedB",color:"primary"}),label:"Persist Auth Data Locally"}),Object(u.jsx)(vn.a,{children:f?"Auth Data and the Selected method will be saved to LocalStorage":"Auth Data won't be saved. All previously saved Auth Data will be removed"})]})]})]}),Object(u.jsx)(mn.a,{children:Object(u.jsx)(ht.a,{onClick:function(){switch(I){case 0:j({type:"SET_NO_AUTH",payload:{checkbox:f}});break;case 1:j({type:"SET_BASIC_AUTH",payload:{checkbox:f,value:g}});break;case 2:j({type:"SET_BEARER_AUTH",payload:{checkbox:f,value:{token:w}}})}U()},color:"primary",children:"Apply"})})]})},Bn=function(e){var t=e.error,n=ae(),r=ne().serverURL,c=pe().serverUrl,i=Oe(),s=Object(a.useState)(!1),l=Object(o.a)(s,2),d=l[0],j=l[1];return Object(a.useEffect)((function(){n&&i({type:"SET_SERVER",payload:r})}),[r]),Object(u.jsxs)(u.Fragment,{children:[Object(u.jsxs)(O.a,{display:"grid",gridTemplateColumns:"1fr auto",gap:"4px",alignItems:"center",width:"100%",mb:2,minHeight:50,children:[Object(u.jsx)(jt.a,{variant:"outlined",fullWidth:!0,label:"Server URL",value:c||"",disabled:n,error:t===nt.validServer||t===nt.emptyServer,inputProps:{style:{fontFamily:"Monospace"}},onChange:function(e){var t=e.target.value;i({type:"SET_SERVER",payload:t})}}),Object(u.jsx)(O.a,{children:Object(u.jsx)(y.a,{title:"Request Auth Settings",children:Object(u.jsx)(g.a,{onClick:function(){return j(!0)},children:Object(u.jsx)(on.a,{})})})})]}),Object(u.jsx)(Yn,{open:d,onClose:function(){return j(!1)}})]})},Fn=function(){var e=Be().customStep,t=Fe(),n=Object(a.useState)(!1),r=Object(o.a)(n,2),c=r[0],i=r[1],s=pe().time,l=s.period.step,d=s.duration,j=Object(a.useCallback)(pt()((function(e){var n=+e.target.value;n>0?(t({type:"SET_CUSTOM_STEP",payload:n}),i(!1)):i(!0)}),500),[e.value]),b=function(){i(!1),t({type:"TOGGLE_CUSTOM_STEP"})};return Object(a.useEffect)((function(){e.enable&&b()}),[d]),Object(a.useEffect)((function(){e.enable||t({type:"SET_CUSTOM_STEP",payload:l||1})}),[l]),Object(u.jsxs)(O.a,{display:"grid",gridTemplateColumns:"auto 120px",alignItems:"center",children:[Object(u.jsx)(m.a,{control:Object(u.jsx)(ge,{checked:e.enable,onChange:b}),label:"Override step value"}),e.enable&&Object(u.jsx)(jt.a,{label:"Step value",type:"number",size:"small",variant:"outlined",defaultValue:e.value,error:c,helperText:c?"step is out of allowed range":" ",onChange:j})]})},Qn=function(){var e=pe().queryControls,t=e.autocomplete,n=e.nocache,a=Oe();return Object(u.jsxs)(O.a,{display:"flex",alignItems:"center",children:[Object(u.jsx)(O.a,{children:Object(u.jsx)(m.a,{label:"Enable autocomplete",control:Object(u.jsx)(ge,{checked:t,onChange:function(){a({type:"TOGGLE_AUTOCOMPLETE"}),V("AUTOCOMPLETE",!t)}})})}),Object(u.jsx)(O.a,{ml:2,children:Object(u.jsx)(m.a,{label:"Enable cache",control:Object(u.jsx)(ge,{checked:!n,onChange:function(){a({type:"NO_CACHE"}),V("NO_CACHE",!n)}})})}),Object(u.jsx)(O.a,{ml:2,children:Object(u.jsx)(Fn,{})})]})},zn=function(e){var t=e.error,n=pe(),r=n.serverUrl,c=n.query,i=n.queryHistory,s=n.time.duration,l=n.queryControls.autocomplete,d=Oe(),j=Object(a.useState)(!0),b=Object(o.a)(j,2),p=b[0],f=b[1],x=Object(a.useRef)(null),v=Object(a.useRef)(c);Object(a.useEffect)((function(){v.current=c}),[c]);var m=function(){d({type:"SET_QUERY_HISTORY",payload:c.map((function(e,t){var n=i[t]||{values:[]},a=e===n.values[n.values.length-1];return{index:n.values.length-Number(a),values:!a&&e?[].concat(Object(De.a)(n.values),[e]):n.values}}))}),d({type:"SET_QUERY",payload:c}),d({type:"RUN_QUERY"})},S=function(e,t){var n=Object(De.a)(v.current);n[t]=e,d({type:"SET_QUERY",payload:n})},E=function(e,t){var n=i[t],a=n.index,r=n.values,c=a+e;c<0||c>=r.length||(S(r[c]||"",t),d({type:"SET_QUERY_HISTORY_BY_INDEX",payload:{value:{values:r,index:c},queryNumber:t}}))};return Object(u.jsx)(u.Fragment,{children:Object(u.jsxs)(Ut.a,{expanded:p,onChange:function(){return f((function(e){return!e}))},children:[Object(u.jsxs)(Mt.a,{expandIcon:Object(u.jsx)(g.a,{children:Object(u.jsx)(Xt.a,{})}),"aria-controls":"panel1a-content",id:"panel1a-header",sx:{alignItems:"flex-start",padding:"15px"},children:[Object(u.jsx)(O.a,{mr:2,children:Object(u.jsx)(h.a,{variant:"h6",component:"h2",children:"Query Configuration"})}),Object(u.jsx)(O.a,{flexGrow:1,onClick:function(e){return e.stopPropagation()},onFocusCapture:function(e){return e.stopPropagation()},children:Object(u.jsx)(rn.a,{disablePortal:!p,container:x.current,children:c.map((function(e,n){return Object(u.jsxs)(O.a,{display:"grid",gridTemplateColumns:"1fr auto",gap:"4px",width:"100%",mb:n===c.length-1?0:2,children:[Object(u.jsx)(Bt,{server:r,query:c[n],index:n,oneLiner:!p,autocomplete:l,queryHistory:i[n],error:t,setHistoryIndex:E,runQuery:m,setQuery:S}),0===n&&Object(u.jsx)(y.a,{title:"Execute Query",children:Object(u.jsx)(g.a,{onClick:m,children:Object(u.jsx)(an.a,{})})}),n>0&&Object(u.jsx)(y.a,{title:"Remove Query",children:Object(u.jsx)(g.a,{onClick:function(){return function(e){var t=Object(De.a)(v.current);t.splice(e,1),d({type:"SET_QUERY",payload:t})}(n)},children:Object(u.jsx)($t.a,{})})})]},n)}))})})]}),Object(u.jsx)(Ht.a,{children:Object(u.jsxs)(Dt.a,{container:!0,columnSpacing:2,children:[Object(u.jsxs)(Dt.a,{item:!0,xs:6,minWidth:400,children:[Object(u.jsx)(Bn,{error:t}),Object(u.jsx)("div",{ref:x}),c.length<2&&Object(u.jsx)(O.a,{display:"inline-block",minHeight:"40px",mt:2,children:Object(u.jsxs)(ht.a,{onClick:function(){return d({type:"SET_QUERY",payload:[].concat(Object(De.a)(v.current),[""])})},variant:"outlined",children:[Object(u.jsx)(tn.a,{sx:{fontSize:16,marginRight:"4px"}}),Object(u.jsx)("span",{style:{lineHeight:1,paddingTop:"1px"},children:"Query"})]})})]}),Object(u.jsx)(Dt.a,{item:!0,xs:!0,children:Object(u.jsx)(Jt,{setDuration:function(e){return d({type:"SET_DURATION",payload:e})},duration:s})}),Object(u.jsx)(Dt.a,{item:!0,xs:12,pt:1,children:Object(u.jsx)(Qn,{})})]})})]})})},Gn=n(81),Wn=n.n(Gn),Vn=n(166),Jn=n(167),Kn=ae(),Xn=ne().serverURL,Zn=function(){var e=pe(),t=e.query,n=e.displayType,r=e.serverUrl,c=e.time.period,i=e.queryControls.nocache,s=Dn(),l=s.basicData,u=s.bearerData,d=s.authMethod,j=Be().customStep,b=Object(a.useState)(!1),p=Object(o.a)(b,2),O=p[0],h=p[1],f=Object(a.useState)(),x=Object(o.a)(f,2),v=x[0],m=x[1],y=Object(a.useState)(),g=Object(o.a)(y,2),S=g[0],E=g[1],_=Object(a.useState)(),w=Object(o.a)(_,2),C=w[0],A=w[1],R=Object(a.useState)(),I=Object(o.a)(R,2),k=I[0],U=I[1];Object(a.useEffect)((function(){C&&(m(void 0),E(void 0))}),[C]);var M=Object(a.useMemo)((function(){if(!k)return!0;var e=(k.end-k.start)/3,t=e/(c.end-c.start)>=.7,n=c.end>k.end+e,a=c.start<k.start-e;return t||n||a}),[c]),H=function(){var e=Object(Vn.a)(Wn.a.mark((function e(){var t,a,r,i,o,s;return Wn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===D||void 0===D?void 0:D.length){e.next=2;break}return e.abrupt("return");case 2:return h(!0),U(c),t=new Headers,"BASIC_AUTH"===d&&t.set("Authorization","Basic "+btoa("".concat((null===l||void 0===l?void 0:l.login)||"",":").concat((null===l||void 0===l?void 0:l.password)||""))),"BEARER_AUTH"===d&&t.set("Authorization",(null===u||void 0===u?void 0:u.token)||""),e.prev=7,e.delegateYield(Wn.a.mark((function e(){var c,l,u,d,j;return Wn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all(D.map((function(e){return fetch(e,{headers:t})})));case 2:c=e.sent,l=[],u=1,a=!1,r=!1,e.prev=7,o=Object(Jn.a)(c);case 9:return e.next=11,o.next();case 11:if(!(a=!(s=e.sent).done)){e.next=20;break}return d=s.value,e.next=15,d.json();case 15:j=e.sent,d.ok?(A(void 0),l.push.apply(l,Object(De.a)(j.data.result.map((function(e){return e.group=u,e})))),u++):A("".concat(j.errorType,"\r\n").concat(null===j||void 0===j?void 0:j.error));case 17:a=!1,e.next=9;break;case 20:e.next=26;break;case 22:e.prev=22,e.t0=e.catch(7),r=!0,i=e.t0;case 26:if(e.prev=26,e.prev=27,!a||null==o.return){e.next=31;break}return e.next=31,o.return();case 31:if(e.prev=31,!r){e.next=34;break}throw i;case 34:return e.finish(31);case 35:return e.finish(26);case 36:"chart"===n?m(l):E(l);case 37:case"end":return e.stop()}}),e,null,[[7,22,26,36],[27,,31,35]])}))(),"t0",9);case 9:e.next=14;break;case 11:e.prev=11,e.t1=e.catch(7),e.t1 instanceof Error&&A("".concat(e.t1.name,": ").concat(e.t1.message));case 14:h(!1);case 15:case"end":return e.stop()}}),e,null,[[7,11]])})));return function(){return e.apply(this,arguments)}}(),D=Object(a.useMemo)((function(){var e=Kn?Xn:r;if(c)if(e)if(t.every((function(e){return!e.trim()})))A(nt.validQuery);else{if(function(e){var t;try{t=new URL(e)}catch(n){return!1}return"http:"===t.protocol||"https:"===t.protocol}(e)){var a=(c.end-c.start)/2,o=Object(T.a)(Object(T.a)({},c),{},{start:c.start-a,end:c.end+a});return j.enable&&(o.step=j.value),t.filter((function(e){return e.trim()})).map((function(t){return"chart"===n?function(e,t,n,a){return"".concat(e,"/api/v1/query_range?query=").concat(encodeURIComponent(t),"&start=").concat(n.start,"&end=").concat(n.end,"&step=").concat(n.step).concat(a?"&nocache=1":"")}(e,t,o,i):function(e,t,n){return"".concat(e,"/api/v1/query?query=").concat(encodeURIComponent(t),"&start=").concat(n.start,"&end=").concat(n.end,"&step=").concat(n.step)}(e,t,c)}))}A(nt.validServer)}else A(nt.emptyServer)}),[r,c,n,j]);return Object(a.useEffect)((function(){U(void 0)}),[t]),Object(a.useEffect)((function(){H()}),[r,n,j]),Object(a.useEffect)((function(){M&&H()}),[c]),{fetchUrl:D,isLoading:O,graphData:v,liveData:S,error:C}},$n=function(e){var t=e.data,n=Object(a.useContext)(d).showInfoMessage,r=Object(a.useMemo)((function(){return JSON.stringify(t,null,2)}),[t]);return Object(u.jsxs)(O.a,{position:"relative",children:[Object(u.jsx)(O.a,{flexDirection:"column",justifyContent:"flex-end",display:"flex",style:{position:"fixed",right:"16px"},children:Object(u.jsx)(ht.a,{variant:"outlined",onClick:function(e){navigator.clipboard.writeText(r),n("Formatted JSON has been copied"),e.preventDefault()},children:"Copy JSON"})}),Object(u.jsx)("pre",{children:r})]})},ea=function(){var e=pe(),t=e.displayType,n=e.time.period,a=Zn(),r=a.isLoading,c=a.liveData,i=a.graphData,o=a.error;return Object(u.jsxs)(u.Fragment,{children:[Object(u.jsx)(b.a,{position:"static",children:Object(u.jsxs)(p.a,{children:[Object(u.jsxs)(O.a,{display:"flex",children:[Object(u.jsxs)(h.a,{variant:"h5",children:[Object(u.jsx)("span",{style:{fontWeight:"bolder"},children:"VM"}),Object(u.jsx)("span",{style:{fontWeight:"lighter"},children:"UI"})]}),Object(u.jsx)("div",{style:{fontSize:"10px",marginTop:"-2px"},children:Object(u.jsx)("div",{children:"BETA"})})]}),Object(u.jsx)("div",{style:{fontSize:"10px",position:"absolute",top:"40px",opacity:".4"},children:Object(u.jsx)(f.a,{color:"inherit",href:"https://github.com/VictoriaMetrics/VictoriaMetrics/issues/new",target:"_blank",children:"Create an issue"})}),Object(u.jsx)(O.a,{ml:4,flexGrow:1,children:Object(u.jsx)(Ee,{})}),Object(u.jsx)(He,{})]})}),Object(u.jsxs)(O.a,{p:4,display:"grid",gridTemplateRows:"auto 1fr",gap:"20px",style:{minHeight:"calc(100vh - 64px)"},children:[Object(u.jsx)(O.a,{children:Object(u.jsx)(zn,{error:o})}),Object(u.jsxs)(O.a,{height:"100%",children:[r&&Object(u.jsx)(x.a,{in:r,style:{transitionDelay:r?"300ms":"0ms"},children:Object(u.jsx)(O.a,{alignItems:"center",justifyContent:"center",flexDirection:"column",display:"flex",style:{width:"100%",maxWidth:"calc(100vw - 32px)",position:"absolute",height:"50%",background:"linear-gradient(rgba(255,255,255,.7), rgba(255,255,255,.7), rgba(255,255,255,0))"},children:Object(u.jsx)(v.a,{})})}),Object(u.jsxs)(O.a,{height:"100%",bgcolor:"#fff",children:[o&&Object(u.jsx)(l.a,{color:"error",severity:"error",style:{fontSize:"14px",whiteSpace:"pre-wrap"},children:o}),i&&n&&"chart"===t&&Object(u.jsx)(Et,{data:i}),c&&"code"===t&&Object(u.jsx)($n,{data:c}),c&&"table"===t&&Object(u.jsx)(kt,{data:c})]})]})]})]})},ta=n(311),na=n(354),aa=n(173),ra=Object(aa.a)({palette:{primary:{main:"#3F51B5"},secondary:{main:"#F50057"},error:{main:"#FF4141"}},components:{MuiFormHelperText:{styleOverrides:{root:{position:"absolute",top:"36px",left:"2px",margin:0}}},MuiInputLabel:{styleOverrides:{root:{fontSize:"12px",letterSpacing:"normal",lineHeight:"1"}}},MuiInputBase:{styleOverrides:{root:{"&.Mui-focused fieldset":{borderWidth:"1px !important"}}}},MuiSwitch:{defaultProps:{color:"secondary"}},MuiAccordion:{styleOverrides:{root:{boxShadow:"rgba(0, 0, 0, 0.16) 0px 1px 4px;"}}},MuiPaper:{styleOverrides:{elevation3:{boxShadow:"rgba(0, 0, 0, 0.2) 0px 3px 8px;"}}},MuiIconButton:{defaultProps:{size:"large"},styleOverrides:{sizeLarge:{borderRadius:"20%",height:"40px",width:"41px"},sizeMedium:{borderRadius:"20%"},sizeSmall:{borderRadius:"20%"}}}},typography:{fontSize:10}}),ca=n(310),ia=n(306),oa=n(168),sa=function(){return Object(u.jsxs)(u.Fragment,{children:[Object(u.jsx)(ca.a,{})," ",Object(u.jsxs)(ia.b,{dateAdapter:oa.a,children:[" ",Object(u.jsx)(ta.a,{injectFirst:!0,children:Object(u.jsxs)(na.a,{theme:ra,children:[" ",Object(u.jsxs)(fe,{children:[" ",Object(u.jsxs)(Nn,{children:[" ",Object(u.jsxs)(Qe,{children:[" ",Object(u.jsxs)(j,{children:[" ",Object(u.jsx)(ea,{})]})]})]})]})]})})]})]})},la=function(e){e&&e instanceof Function&&n.e(3).then(n.bind(null,356)).then((function(t){var n=t.getCLS,a=t.getFID,r=t.getFCP,c=t.getLCP,i=t.getTTFB;n(e),a(e),r(e),c(e),i(e)}))};i.a.render(Object(u.jsx)(r.a.StrictMode,{children:Object(u.jsx)(sa,{})}),document.getElementById("root")),la()}},[[234,1,2]]]);