text: /*! For license information please see lokiPlugin.8727e0c1843e7fde919e.js.LICENSE.txt */
  (window.webpackJsonp=window.webpackJsonp||[]).push([[64],{"+2Nz":function(e,t,r){"use strict";r.r(t);var n,a=r("Obii"),o=r("LvDl"),i=r.n(o),u=r("XlPw"),s=r("F/XL"),c=r("p0ib"),l=r("67Y/"),f=r("9Z1F"),p=r("15JJ"),m=r("wZee"),d=r.n(m),b=r("t8hP"),v=r("eqT+"),h=r("NPB1"),y=r("m257"),g=r("aCH8"),O=r.n(g),x=r("iZOS"),w=r("kGJw"),j=r.n(w);function k(e){return"".concat(e||"").trim()}function _(e){for(var t=e,r=[];t;){var n=t.search(/\|=|\|~|!=|!~/);if(-1===n)break;var a=t.substr(n,2),o=0===t.substr(n).search(/!=|!~/);if(t=t.substr(n+2),!o){var i=t.search(/\|=|\|~|!=|!~/),u=void 0;-1===i?u=t.trim():(u=t.substr(0,i).trim(),t=t.substr(i));var s=u.match(/^"((?:[^\\"]|\\")*)"$/);if(!s)return[];var c=s[1],l="|~"===a;r.push(l?c:j()(c))}}return r}function E(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?E(Object(r),!0).forEach((function(t){T(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function T(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function L(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function P(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e))&&"[object Arguments]"!==Object.prototype.toString.call(e))return;var r=[],n=!0,a=!1,o=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){a=!0,o=e}finally{try{n||null==u.return||u.return()}finally{if(a)throw o}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function C(e,t,r){var n=e.stream,o=Object.entries(n).map((function(e){var t=P(e,2),r=t[0],n=t[1];return"".concat(r,'="').concat(n,'"')})).sort().join(""),i=new a.ArrayVector([]),u=new a.ArrayVector([]),s=new a.ArrayVector([]),c=new a.ArrayVector([]),l={},f=!0,p=!1,m=void 0;try{for(var d,b=e.values[Symbol.iterator]();!(f=(d=b.next()).done);f=!0){var v=P(d.value,2),h=v[0],y=v[1];i.add(new Date(parseInt(h.substr(0,h.length-6),10)).toISOString()),u.add(h),s.add(y),c.add(F(h,o,y,l,r))}}catch(e){p=!0,m=e}finally{try{f||null==b.return||b.return()}finally{if(p)throw m}}return function(e,t,r,n,o,i,u){var s={refId:u,fields:[{name:"ts",type:a.FieldType.time,config:{displayName:"Time"},values:e},{name:"line",type:a.FieldType.string,config:{},values:r,labels:o},{name:"id",type:a.FieldType.string,config:{},values:n},{name:"tsNs",type:a.FieldType.time,config:{displayName:"Time ns"},values:t}],length:e.length};if(i){var c=new a.MutableDataFrame(s);return c.reverse(),c}return s}(i,u,s,c,n,t,r)}function R(e,t){var r=e.streams;if(r&&r.length){var n={},o=!0,i=!1,u=void 0;try{for(var s,c=t.fields[Symbol.iterator]();!(o=(s=c.next()).done);o=!0){var l=s.value;if(l.type===a.FieldType.string){l.labels&&(n=l.labels);break}}}catch(e){i=!0,u=e}finally{try{o||null==c.return||c.return()}finally{if(i)throw u}}var f=t.fields[0],p=t.fields[1],m=t.fields[2],d=t.fields[3],b=t.fields[4],v={},h=!0,y=!1,g=void 0;try{for(var O,x=r[Symbol.iterator]();!(h=(O=x.next()).done);h=!0){var w=O.value,j=Object(a.findUniqueLabels)(w.stream,n),k=Object.entries(w.stream).map((function(e){var t=P(e,2),r=t[0],n=t[1];return"".concat(r,'="').concat(n,'"')})).sort().join(""),_=!0,E=!1,S=void 0;try{for(var T,L=w.values[Symbol.iterator]();!(_=(T=L.next()).done);_=!0){var C=P(T.value,2),R=C[0],D=C[1];f.values.add(new Date(parseInt(R.substr(0,R.length-6),10)).toISOString()),p.values.add(R),m.values.add(D),d.values.add(j),b.values.add(F(R,k,D,v,t.refId))}}catch(e){E=!0,S=e}finally{try{_||null==L.return||L.return()}finally{if(E)throw S}}}}catch(e){y=!0,g=e}finally{try{h||null==x.return||x.return()}finally{if(y)throw g}}}}function F(e,t,r,n,a){var o=O()("".concat(e,"_").concat(t,"_").concat(r));if(o in n){var i=n[o]+1;n[o]=i,o="".concat(o,"_").concat(i)}else n[o]=0;return a?"".concat(o,"_").concat(a):o}function D(e,t){var r=function(e,t){var r,n=void 0===t||i.a.isEmpty(t.legendFormat)?function(e){var t=e.__name__||"";delete e.__name__;var r=Object.entries(e).map((function(e){return"".concat(e[0],'="').concat(e[1],'"')})).join(",");return"".concat(t,"{").concat(r,"}")}(e):(a=Object(b.getTemplateSrv)().replace(null!==(r=t.legendFormat)&&void 0!==r?r:"",t.scopedVars),o=e,a.replace(/\{\{\s*(.+?)\s*\}\}/g,(function(e,t){return o[t]?o[t]:t})));var a,o;!n&&t&&(n=t.query);return n}(e.metric,t);return{target:r,title:r,datapoints:I(e.values,t),tags:e.metric,meta:t.meta,refId:t.refId}}function I(e,t){var r=1e3*t.step,n=[],a=t.start/1e6,o=!0,i=!1,u=void 0;try{for(var s,c=e[Symbol.iterator]();!(o=(s=c.next()).done);o=!0){var l=P(s.value,2),f=l[0],p=l[1],m=parseFloat(p);isNaN(m)&&(m=null);for(var d=1e3*f,b=a;b<d;b+=r)n.push([null,b]);a=d+r,n.push([m,d])}}catch(e){i=!0,u=e}finally{try{o||null==c.return||c.return()}finally{if(i)throw u}}for(var v=t.end/1e6,h=a;h<=v;h+=r)n.push([null,h]);return n}function A(e,t,r,n,o){if(!e||0===e.length)return new x.a;var i=L(new Set(e.reduce((function(e,t){return e.concat(Object.keys(t.metric))}),[])).values()).sort(),u=new x.a;return u.refId=r,u.meta=n,u.columns=[{text:"Time",type:a.FieldType.time}].concat(L(i.map((function(e){return{text:e,filterable:!0,type:a.FieldType.string}}))),[{text:t>1||o?"Value #".concat(r):"Value",type:a.FieldType.number}]),e.forEach((function(e){var t,r={metric:e.metric,values:e.value?[e.value]:e.values};r.values&&(r.metric?(t=u.rows).push.apply(t,L(r.values.map((function(e){var t=P(e,2),n=t[0],a=t[1];return[1e3*n].concat(L(i.map((function(e){return r.metric[e]||""}))),[parseFloat(a)])})))):u.rows.concat(r.values.map((function(e){var t=P(e,2),r=t[0],n=t[1];return[1e3*r,parseFloat(n)]}))))})),u}function N(e){var t=[];if(!e)return t;for(var r in e){var n=e[r];for(var a in n){var o=n[a],u=void 0;/time/i.test(a)&&o?u="s":/bytes.*persecond/i.test(a)?u="Bps":/bytes/i.test(a)&&(u="decbytes");var s="".concat(i.a.capitalize(r),": ").concat(a.replace(/[A-Z]/g,(function(e){return" ".concat(e.toLowerCase())})));t.push({displayName:s,value:o,unit:u})}}return t}function q(e,t,r,n){var a=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=r>0?e.data.result:[],i=N(e.data.stats),u={lokiQueryStatKey:"Summary: total bytes processed"},s={searchWords:_(k(t.expr)),limit:r,stats:i,custom:u,preferredVisualisationType:"logs"},c=o.map((function(e){var r=C(e,a,t.refId);return Q(r,n),s.custom&&r.fields.some((function(e){return e.labels&&Object.keys(e.labels).some((function(e){return"__error__"===e}))}))&&(s.custom.error="Error when parsing some of the logs"),S({},r,{refId:t.refId,meta:s})}));return i.length&&!o.length?[{fields:[],length:0,refId:t.refId,meta:s}]:c}!function(e){e.Stream="streams",e.Vector="vector",e.Matrix="matrix"}(n||(n={}));var Q=function(e,t){var r;if(t){var n=null!==(r=t.derivedFields)&&void 0!==r?r:[];if(n.length){var o=i.a.groupBy(n,"name"),u=Object.values(o).map(B);new a.DataFrameView(e).forEach((function(e){var t=!0,r=!1,n=void 0;try{for(var a,i=u[Symbol.iterator]();!(t=(a=i.next()).done);t=!0){var s=a.value,c=e.line.match(o[s.name][0].matcherRegex);s.values.add(c&&c[1])}}catch(e){r=!0,n=e}finally{try{t||null==i.return||i.return()}finally{if(r)throw n}}})),e.fields=[].concat(L(e.fields),L(u))}}};function B(e){var t=Object(b.getDataSourceSrv)(),r=e.reduce((function(e,r){if(r.datasourceUid){var n,a=t.getInstanceSettings(r.datasourceUid);e.push({title:"",url:"",internal:{query:{query:r.url},datasourceUid:r.datasourceUid,datasourceName:null!==(n=null==a?void 0:a.name)&&void 0!==n?n:"Data source not found"}})}else r.url&&e.push({title:"",url:r.url});return e}),[]);return{name:e[0].name,type:a.FieldType.string,config:{links:r},values:new a.ArrayVector([])}}function V(e,t,r,a,o){var i,u={format:r.format,legendFormat:null!==(i=r.legendFormat)&&void 0!==i?i:"",start:t.start,end:t.end,step:t.step,query:t.query,responseListLength:a,refId:r.refId,meta:{preferredVisualisationType:"graph"},valueWithRefId:r.valueWithRefId,scopedVars:o};switch(e.data.resultType){case n.Vector:return e.data.result.map((function(e){return D({metric:e.metric,values:[e.value]},u)}));case n.Matrix:return e.data.result.map((function(e){return D(e,u)}));default:return[]}}function W(e,t,r,a,o,i,u){var c=arguments.length>7&&void 0!==arguments[7]&&arguments[7];switch(e.data.resultType){case n.Stream:return Object(s.a)({data:q(e,t,o,i,c),key:"".concat(t.refId,"_log")});case n.Vector:case n.Matrix:return Object(s.a)({data:V(e,r,S({},t,{format:"time_series"}),a,u),key:t.refId});default:throw new Error('Unknown result type "'.concat(e.data.resultType,'".'))}}var U=r("gI3B"),M=r("4HpG"),z=r("K9Ia"),K=r("FFOo"),H=r("6blF"),J=r("pugT"),$=r("S5bw"),Z={url:"",deserializer:function(e){return JSON.parse(e.data)},serializer:function(e){return JSON.stringify(e)}},X=function(e){function t(t,r){var n=e.call(this)||this;if(t instanceof H.a)n.destination=r,n.source=t;else{var a=n._config=M.a({},Z);if(n._output=new z.b,"string"==typeof t)a.url=t;else for(var o in t)t.hasOwnProperty(o)&&(a[o]=t[o]);if(!a.WebSocketCtor&&WebSocket)a.WebSocketCtor=WebSocket;else if(!a.WebSocketCtor)throw new Error("no WebSocket constructor can be found");n.destination=new $.a}return n}return M.b(t,e),t.prototype.lift=function(e){var r=new t(this._config,this.destination);return r.operator=e,r.source=this,r},t.prototype._resetState=function(){this._socket=null,this.source||(this.destination=new $.a),this._output=new z.b},t.prototype.multiplex=function(e,t,r){var n=this;return new H.a((function(a){try{n.next(e())}catch(e){a.error(e)}var o=n.subscribe((function(e){try{r(e)&&a.next(e)}catch(e){a.error(e)}}),(function(e){return a.error(e)}),(function(){return a.complete()}));return function(){try{n.next(t())}catch(e){a.error(e)}o.unsubscribe()}}))},t.prototype._connectSocket=function(){var e=this,t=this._config,r=t.WebSocketCtor,n=t.protocol,a=t.url,o=t.binaryType,i=this._output,u=null;try{u=n?new r(a,n):new r(a),this._socket=u,o&&(this._socket.binaryType=o)}catch(e){return void i.error(e)}var s=new J.a((function(){e._socket=null,u&&1===u.readyState&&u.close()}));u.onopen=function(t){if(!e._socket)return u.close(),void e._resetState();var r=e._config.openObserver;r&&r.next(t);var n=e.destination;e.destination=K.a.create((function(t){if(1===u.readyState)try{var r=e._config.serializer;u.send(r(t))}catch(t){e.destination.error(t)}}),(function(t){var r=e._config.closingObserver;r&&r.next(void 0),t&&t.code?u.close(t.code,t.reason):i.error(new TypeError("WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }")),e._resetState()}),(function(){var t=e._config.closingObserver;t&&t.next(void 0),u.close(),e._resetState()})),n&&n instanceof $.a&&s.add(n.subscribe(e.destination))},u.onerror=function(t){e._resetState(),i.error(t)},u.onclose=function(t){e._resetState();var r=e._config.closeObserver;r&&r.next(t),t.wasClean?i.complete():i.error(t)},u.onmessage=function(t){try{var r=e._config.deserializer;i.next(r(t))}catch(e){i.error(e)}}},t.prototype._subscribe=function(e){var t=this,r=this.source;return r?r.subscribe(e):(this._socket||this._connectSocket(),this._output.subscribe(e),e.add((function(){var e=t._socket;0===t._output.observers.length&&(e&&1===e.readyState&&e.close(),t._resetState())})),e)},t.prototype.unsubscribe=function(){var t=this._socket;t&&1===t.readyState&&t.close(),this._resetState(),e.prototype.unsubscribe.call(this)},t}(z.a);function G(e){return new X(e)}var Y=r("ZqrO"),ee=r("psW0"),te=r("2WpN");function re(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ne(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?re(Object(r),!0).forEach((function(t){ae(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):re(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function ae(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function oe(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var ie=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.streams={}}var t,r,n;return t=e,(r=[{key:"getStream",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3,n=this.streams[e.url];if(n)return n;var o=new a.CircularDataFrame({capacity:e.size});return o.addField({name:"ts",type:a.FieldType.time,config:{displayName:"Time"}}),o.addField({name:"tsNs",type:a.FieldType.time,config:{displayName:"Time ns"}}),o.addField({name:"line",type:a.FieldType.string}).labels=Object(a.parseLabels)(e.query),o.addField({name:"labels",type:a.FieldType.other}),o.addField({name:"id",type:a.FieldType.string}),o.meta=ne({},o.meta,{preferredVisualisationType:"logs"}),o.refId=e.refId,n=G(e.url).pipe(Object(l.a)((function(e){return R(e,o),[o]})),Object(Y.a)((function(e){return e.pipe(Object(ee.b)((function(e,t){var n=t+1;return 1006===e.code&&n<30?(n>10&&console.warn("Websocket connection is being disrupted. We keep reconnecting but consider starting new live tailing again. Error: ".concat(e.reason)),Object(U.a)(r)):Object(u.a)(e)})))})),Object(te.a)((function(){delete t.streams[e.url]}))),this.streams[e.url]=n,n}}])&&oe(t.prototype,r),n&&oe(t,n),e}(),ue=r("HyWp"),se=r.n(ue),ce=r("ceQ3"),le=[{label:"json",insertText:"json",documentation:"Extracting labels from the log line using json parser. Only available in Loki 2.0+."},{label:"regexp",insertText:'regexp ""',documentation:"Extracting labels from the log line using regexp parser. Only available in Loki 2.0+.",move:-1},{label:"logfmt",insertText:"logfmt",documentation:"Extracting labels from the log line using logfmt parser. Only available in Loki 2.0+."}],fe=[{label:"unwrap",insertText:"unwrap",detail:"unwrap identifier",documentation:"Take labels and use the values as sample data for metric aggregations. Only available in Loki 2.0+."},{label:"label_format",insertText:"label_format",documentation:"Only available in Loki 2.0+."},{label:"line_format",insertText:"line_format",documentation:"Only available in Loki 2.0+."}],pe=[].concat([{label:"sum",insertText:"sum",documentation:"Calculate sum over dimensions"},{label:"min",insertText:"min",documentation:"Select minimum over dimensions"},{label:"max",insertText:"max",documentation:"Select maximum over dimensions"},{label:"avg",insertText:"avg",documentation:"Calculate the average over dimensions"},{label:"stddev",insertText:"stddev",documentation:"Calculate population standard deviation over dimensions"},{label:"stdvar",insertText:"stdvar",documentation:"Calculate population standard variance over dimensions"},{label:"count",insertText:"count",documentation:"Count number of elements in the vector"},{label:"bottomk",insertText:"bottomk",documentation:"Smallest k elements by sample value"},{label:"topk",insertText:"topk",documentation:"Largest k elements by sample value"}],[{insertText:"avg_over_time",label:"avg_over_time",detail:"avg_over_time(range-vector)",documentation:"The average of all values in the specified interval. Only available in Loki 2.0+."},{insertText:"min_over_time",label:"min_over_time",detail:"min_over_time(range-vector)",documentation:"The minimum of all values in the specified interval. Only available in Loki 2.0+."},{insertText:"max_over_time",label:"max_over_time",detail:"max_over_time(range-vector)",documentation:"The maximum of all values in the specified interval. Only available in Loki 2.0+."},{insertText:"sum_over_time",label:"sum_over_time",detail:"sum_over_time(range-vector)",documentation:"The sum of all values in the specified interval. Only available in Loki 2.0+."},{insertText:"count_over_time",label:"count_over_time",detail:"count_over_time(range-vector)",documentation:"The count of all values in the specified interval."},{insertText:"stdvar_over_time",label:"stdvar_over_time",detail:"stdvar_over_time(range-vector)",documentation:"The population standard variance of the values in the specified interval. Only available in Loki 2.0+."},{insertText:"stddev_over_time",label:"stddev_over_time",detail:"stddev_over_time(range-vector)",documentation:"The population standard deviation of the values in the specified interval. Only available in Loki 2.0+."},{insertText:"quantile_over_time",label:"quantile_over_time",detail:"quantile_over_time(scalar, range-vector)",documentation:"The φ-quantile (0 ≤ φ ≤ 1) of the values in the specified interval. Only available in Loki 2.0+."},{insertText:"bytes_over_time",label:"bytes_over_time",detail:"bytes_over_time(range-vector)",documentation:"Counts the amount of bytes used by each log stream for a given range"},{insertText:"bytes_rate",label:"bytes_rate",detail:"bytes_rate(range-vector)",documentation:"Calculates the number of bytes per second for each stream."},{insertText:"rate",label:"rate",detail:"rate(v range-vector)",documentation:"Calculates the per-second average rate of increase of the time series in the range vector. Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for. Also, the calculation extrapolates to the ends of the time range, allowing for missed scrapes or imperfect alignment of scrape cycles with the range's time period."}]),me={comment:{pattern:/#.*/},"context-aggregation":{pattern:/((without|by)\s*)\([^)]*\)/,lookbehind:!0,inside:{"label-key":{pattern:/[^(),\s][^,)]*[^),\s]*/,alias:"attr-name"},punctuation:/[()]/}},"context-labels":{pattern:/\{[^}]*(?=}?)/,greedy:!0,inside:{comment:{pattern:/#.*/},"label-key":{pattern:/[a-z_]\w*(?=\s*(=|!=|=~|!~))/,alias:"attr-name",greedy:!0},"label-value":{pattern:/"(?:\\.|[^\\"])*"/,greedy:!0,alias:"attr-value"},punctuation:/[{]/}},"context-pipe":{pattern:/\s\|[^=~]\s?\w*/i,inside:{"pipe-operator":{pattern:/\|/i,alias:"operator"},"pipe-operations":{pattern:new RegExp("".concat([].concat(le,fe).map((function(e){return e.label})).join("|")),"i"),alias:"keyword"}}},function:new RegExp("\\b(?:".concat(pe.map((function(e){return e.label})).join("|"),")(?=\\s*\\()"),"i"),"context-range":[{pattern:/\[[^\]]*(?=\])/,inside:{"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}},{pattern:/(offset\s+)\w+/,lookbehind:!0,inside:{"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}}],number:/\b-?\d+((\.\d*)?([eE][+-]?\d+)?)?\b/,operator:/\s?(\|[=~]?|!=?|<(?:=>?|<|>)?|>[>=]?)\s?/i,punctuation:/[{}()`,.]/},de=r("itod");function be(e){return(be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ve(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function he(e,t,r,n,a,o,i){try{var u=e[o](i),s=u.value}catch(e){return void r(e)}u.done?t(s):Promise.resolve(s).then(n,a)}function ye(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){he(o,n,a,i,u,"next",e)}function u(e){he(o,n,a,i,u,"throw",e)}i(void 0)}))}}function ge(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Oe(e){return(Oe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function xe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function we(e,t){return(we=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function je(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ke(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?je(Object(r),!0).forEach((function(t){_e(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):je(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Ee=["job","namespace"],Se=function(e){return{label:e,filterText:'"'.concat(e,'"')}},Te=function(e){return{start:1e6*e.from,end:1e6*e.to}};var Le=function(e){function t(e,r){var n,a,o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),a=this,o=Oe(t).call(this),(n=!o||"object"!==be(o)&&"function"!=typeof o?xe(a):o).seriesCache=new se.a(10),n.labelsCache=new se.a(10),n.cleanText=function(e){return e.replace(/[{}[\]="(),!~+\-*/^%\|]/g,"").trim()},n.request=function(){var e=ye(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,n.datasource.metadataRequest(t,r);case 3:return e.abrupt("return",e.sent);case 6:e.prev=6,e.t0=e.catch(0),console.error(e.t0);case 9:return e.abrupt("return",void 0);case 10:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(t,r){return e.apply(this,arguments)}}(),n.start=function(){return n.startTask||(n.startTask=n.fetchLogLabels(n.initialRange).then((function(){return n.started=!0,[]}))),n.startTask},n.getBeginningCompletionItems=function(e){return{suggestions:[].concat(ve(n.getEmptyCompletionItems(e).suggestions),ve(n.getTermCompletionItems().suggestions))}},n.getTermCompletionItems=function(){var e=[];return e.push({prefixMatch:!0,label:"Functions",items:pe.map((function(e){return ke({},e,{kind:"function"})}))}),{suggestions:e}},n.getPipeCompletionItem=function(){var e=[];return e.push({label:"Operators",items:fe.map((function(e){return ke({},e,{kind:"operators"})}))}),e.push({label:"Parsers",items:le.map((function(e){return ke({},e,{kind:"parsers"})}))}),{suggestions:e}},n.fetchSeriesLabels=function(){var e=ye(regeneratorRuntime.mark((function e(t,r){var a,o,i,u,s,c,l,f,p,m;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=r?Te(r):{start:0,end:0},o="/loki/api/v1/series",i=a.start,u=a.end,s=n.generateCacheKey(o,i,u,t),c={match:t,start:i,end:u},l=n.seriesCache.get(s)){e.next=14;break}return n.seriesCache.set(s,{}),e.next=10,n.request(o,c);case 10:f=e.sent,p=Object(ce.h)(f),m=p.values,l=m,n.seriesCache.set(s,l);case 14:return e.abrupt("return",l);case 15:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),n.addLabelValuesToOptions=function(e,t){return n.logLabelOptions.map((function(r){return r.value===e?ke({},r,{children:t.map((function(e){return{label:e,value:e}}))}):r}))},n.datasource=e,n.labelKeys=[],n.logLabelFetchTs=0,Object.assign(xe(n),r),n}var r,n,o,u,s,c,l,f,p,m,d,b;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&we(e,t)}(t,e),r=t,(n=[{key:"getSyntax",value:function(){return me}},{key:"getLabelKeys",value:function(){return this.labelKeys}},{key:"provideCompletionItems",value:(b=ye(regeneratorRuntime.mark((function e(t,r){var n,a,o,i,u,s,c,l,f,p,m,d,b,v,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.wrapperClasses,a=t.value,o=t.prefix,i=t.text,u={suggestions:[]},a){e.next=4;break}return e.abrupt("return",u);case 4:if(s=0===(null==a?void 0:a.document.text.length),c=a.document.getTextsAtRange(a.selection),l=1===c.size?c.first().getText():null,f=l?l[a.selection.anchor.offset]:null,p=n.length>3,m=o&&!p,d=!f||")"===f,b=o&&!i.match(/^['"~=\]})\s]+$/)&&d,v=/[+\-*/^%]/,h=i.match(v),!n.includes("context-range")){e.next=18;break}return e.abrupt("return",this.getRangeCompletionItems());case 18:if(!n.includes("context-labels")){e.next=24;break}return e.next=21,this.getLabelCompletionItems(t,r);case 21:return e.abrupt("return",e.sent);case 24:if(!n.includes("context-pipe")){e.next=28;break}return e.abrupt("return",this.getPipeCompletionItem());case 28:if(!s){e.next=32;break}return e.abrupt("return",this.getEmptyCompletionItems(r));case 32:if(!m||!d||h){e.next=36;break}return e.abrupt("return",this.getBeginningCompletionItems(r));case 36:if(!m||!b){e.next=38;break}return e.abrupt("return",this.getTermCompletionItems());case 38:return e.abrupt("return",u);case 39:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"getEmptyCompletionItems",value:function(e){var t=null==e?void 0:e.history,r=[];if(null==t?void 0:t.length){var n=i.a.chain(t).map((function(e){return e.query.expr})).filter().uniq().take(10).map(Se).map((function(e){return function(e,t){var r=Date.now()-864e5,n=t.filter((function(t){return t.ts>r&&t.query.expr===e.label})),o="Queried ".concat(n.length," times in the last 24h."),i=n[0];if(i){var u=Object(a.dateTime)(i.ts).fromNow();o="".concat(o," Last queried ").concat(u,".")}return ke({},e,{documentation:o})}(e,t)})).value();r.push({prefixMatch:!0,skipSort:!0,label:"History",items:n})}return{suggestions:r}}},{key:"getRangeCompletionItems",value:function(){return{context:"context-range",suggestions:[{label:"Range vector",items:ve(de.b)}]}}},{key:"getLabelCompletionItems",value:(d=ye(regeneratorRuntime.mark((function e(t,r){var n,a,o,u,s,c,l,f,p,m,d,b,v,h,y,g,O,x,w,j;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.text,a=t.wrapperClasses,o=t.labelKey,u=t.value,s=r.absoluteRange,c="context-labels",l=[],u){e.next=6;break}return e.abrupt("return",{context:c,suggestions:[]});case 6:f=u.anchorBlock.getText(),p=u.selection.anchor.offset,m=n.match(/^(=|=~|!=|!~)/);try{b=Object(ce.f)(f,p),d=b.selector}catch(e){d="{}"}if(m||"{}"!==d){e.next=15;break}return e.next=13,this.start();case 13:return v=this.getLabelKeys(),e.abrupt("return",{context:c,suggestions:[{label:"Labels",items:v.map(Se)}]});case 15:if(h=b?b.labelKeys:[],!d){e.next=27;break}if("{}"!==d||!o){e.next=24;break}return e.next=20,this.getLabelValues(o,s);case 20:g=e.sent,y=_e({},o,g),e.next=27;break;case 24:return e.next=26,this.getSeriesLabels(d,s);case 26:y=e.sent;case 27:if(y){e.next=30;break}return console.warn("Server did not return any values for selector = ".concat(d)),e.abrupt("return",{context:c,suggestions:l});case 30:return n&&m||a.includes("attr-value")?o&&y[o]&&(c="context-label-values",l.push({label:'Label values for "'.concat(o,'"'),items:y[o].map(Se).filter((function(e){return e.filterText!==n}))})):(O=y?Object.keys(y):Ee)&&(x=i.a.difference(O,h)).length&&(w=x.map((function(e){return{label:e}})),j={label:"Labels",items:w},l.push(j)),e.abrupt("return",{context:c,suggestions:l});case 32:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"importQueries",value:(m=ye(regeneratorRuntime.mark((function e(t,r){var n=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("prometheus"!==r){e.next=2;break}return e.abrupt("return",Promise.all(t.map(function(){var e=ye(regeneratorRuntime.mark((function e(t){var r,a,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.importPrometheusQuery(t.expr);case 2:return r=e.sent,a=t,o=Object.assign({},a),e.abrupt("return",ke({},o,{expr:r}));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())));case 2:return e.abrupt("return",t.map((function(e){return{refId:e.refId,expr:""}})));case 3:case"end":return e.stop()}}),e)}))),function(e,t){return m.apply(this,arguments)})},{key:"importPrometheusQuery",value:(p=ye(regeneratorRuntime.mark((function e(t){var r,n,a,o,i,u,s,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return","");case 2:if(r=t.match(ce.k)){e.next=5;break}return e.abrupt("return","");case 5:return n=r[0],a={},n.replace(ce.d,(function(e,t,r,n){return a[t]={value:n,operator:r},""})),e.next=10,this.start();case 10:if(o=this.labelKeys,i={},o&&o.length)for(u in a)o&&o.includes(u)&&(i[u]=a[u]);else i=a;return s=Object.keys(i).sort(),c=s.map((function(e){return"".concat(e).concat(i[e].operator).concat(i[e].value)})).join(","),e.abrupt("return",["{",c,"}"].join(""));case 16:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"getSeriesLabels",value:(f=ye(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.lookupsDisabled){e.next=2;break}return e.abrupt("return",void 0);case 2:return e.prev=2,e.next=5,this.fetchSeriesLabels(t,r);case 5:return e.abrupt("return",e.sent);case 8:return e.prev=8,e.t0=e.catch(2),console.error(e.t0),e.abrupt("return",void 0);case 12:case"end":return e.stop()}}),e,this,[[2,8]])}))),function(e,t){return f.apply(this,arguments)})},{key:"fetchLogLabels",value:(l=ye(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=1,this.logLabelFetchTs=Date.now().valueOf(),r=t?Te(t):{},e.next=6,this.request("/loki/api/v1/label",r);case 6:n=e.sent,this.labelKeys=n.slice().sort(),this.logLabelOptions=this.labelKeys.map((function(e){return{label:e,value:e,isLeaf:!1}})),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),console.error(e.t0);case 14:return e.abrupt("return",[]);case 15:case"end":return e.stop()}}),e,this,[[1,11]])}))),function(e){return l.apply(this,arguments)})},{key:"refreshLogLabels",value:(c=ye(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.labelKeys&&Date.now().valueOf()-this.logLabelFetchTs>3e4||r)){e.next=3;break}return e.next=3,this.fetchLogLabels(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"generateCacheKey",value:function(e,t,r,n){return[e,this.roundTime(t),this.roundTime(r),n].join()}},{key:"roundTime",value:function(e){return e?Math.floor(e/1e6/1e3/60/5):0}},{key:"getLabelValues",value:(s=ye(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:this.initialRange,e.next=3,this.fetchLabelValues(t,r);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"fetchLabelValues",value:(u=ye(regeneratorRuntime.mark((function e(t,r){var n,a,o,i,u,s,c,l,f,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a="/loki/api/v1/label/".concat(t,"/values"),o=[],i=r?Te(r):{start:0,end:0},u=i.start,s=i.end,c=this.generateCacheKey(a,u,s,t),l={start:u,end:s},f=this.labelsCache.get(c)){e.next=24;break}return e.prev=8,this.labelsCache.set(c,[]),e.next=12,this.request(a,l);case 12:p=e.sent,o=p.slice().sort(),f=o,this.labelsCache.set(c,f),this.logLabelOptions=this.addLabelValuesToOptions(t,o),e.next=22;break;case 19:e.prev=19,e.t0=e.catch(8),console.error(e.t0);case 22:e.next=25;break;case 24:this.logLabelOptions=this.addLabelValuesToOptions(t,f);case 25:return e.abrupt("return",null!==(n=f)&&void 0!==n?n:[]);case 26:case"end":return e.stop()}}),e,this,[[8,19]])}))),function(e,t){return u.apply(this,arguments)})}])&&ge(r.prototype,n),o&&ge(r,o),t}(a.LanguageProvider),Pe=r("zsCE");function Ce(e){return(Ce="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Re(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function Fe(e,t,r,n,a,o,i){try{var u=e[o](i),s=u.value}catch(e){return void r(e)}u.done?t(s):Promise.resolve(s).then(n,a)}function De(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){Fe(o,n,a,i,u,"next",e)}function u(e){Fe(o,n,a,i,u,"throw",e)}i(void 0)}))}}function Ie(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ae(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ie(Object(r),!0).forEach((function(t){Ne(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ie(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Ne(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function qe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Qe(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Be(e,t){return!t||"object"!==Ce(t)&&"function"!=typeof t?We(e):t}function Ve(e){return(Ve=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function We(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ue(e,t){return(Ue=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Me="".concat("/loki/api/v1","/query_range"),ze="".concat("/loki/api/v1","/query"),Ke={direction:"BACKWARD",limit:1e3,query:""};function He(e){return"string"==typeof e?e.replace(/'/g,"\\\\'"):e}function Je(e){return"string"==typeof e?He(e.replace(/\\/g,"\\\\\\\\").replace(/[$^*{}\[\]+?.()|]/g,"\\\\$&")):e}function $e(e){return d.a.tokenize(e,me).some((function(e){return"string"!=typeof e&&"function"===e.type}))}var Ze=function(e){function t(e){var r,o,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Object(b.getTemplateSrv)(),c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Object(h.a)();qe(this,t),(o=Be(this,Ve(t).call(this,e))).instanceSettings=e,o.templateSrv=i,o.timeSrv=c,o.streams=new ie,o.runInstantQuery=function(e,t,r){var a=o.getTime(t.range.to,!0),i=$e(e.expr)?t.maxDataPoints:e.maxLines,u={query:e.expr,time:"".concat(a+(1e9-a%1e9)),limit:Math.min(i||1/0,o.maxLines)},s={preferredVisualisationType:"table"};return o._request(ze,u).pipe(Object(l.a)((function(t){return t.data.data.resultType===n.Stream?{data:t.data?q(t.data,e,u.limit,o.instanceSettings.jsonData):[],key:"".concat(e.refId,"_instant")}:{data:[A(t.data.data.result,r,e.refId,s,!0)],key:"".concat(e.refId,"_instant")}})),Object(f.a)((function(t){return o.throwUnless(t,404===t.status,e)})))},o.runRangeQuery=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=$e(e.expr)?t.maxDataPoints||o.maxLines:e.maxLines||o.maxLines;if(t.liveStreaming)return o.runLiveQuery(e,n);var a=o.createRangeQuery(e,t,n);return o._request(Me,a).pipe(Object(f.a)((function(t){return o.throwUnless(t,404===t.status,e)})),Object(p.a)((function(i){return W(i.data,e,a,r,n,o.instanceSettings.jsonData,t.scopedVars,t.reverse)})))},o.runLiveQuery=function(e,t){var r=o.createLiveTarget(e,t);return o.streams.getStream(r).pipe(Object(l.a)((function(e){return{data:e||[],key:"loki-".concat(r.refId),state:a.LoadingState.Streaming}})),Object(f.a)((function(e){return Object(u.a)("Live tailing was stopped due to following error: ".concat(e.reason))})))},o.getLogRowContext=function(e,t){var r=o.prepareLogRowContextQueryTarget(e,t&&t.limit||10,t&&t.direction||"BACKWARD"),n=t&&"FORWARD"===t.direction;return o._request(Me,r).pipe(Object(f.a)((function(e){if(404===e.status)return Object(s.a)(e);throw{message:"Error during context query. Please check JS console logs.",status:e.status,statusText:e.statusText}})),Object(p.a)((function(e){return Object(s.a)({data:e.data?e.data.data.result.map((function(e){return C(e,n)})):[]})}))).toPromise()},o.prepareLogRowContextQueryTarget=function(e,t,r){var n=Object.keys(e.labels).map((function(t){return"".concat(t,'="').concat(e.labels[t].replace(/\\/g,"\\\\"),'"')})).join(","),o={limit:t,query:"{".concat(n,"}"),expr:"{".concat(n,"}"),direction:r},i=new a.FieldCache(e.dataFrame).getFieldByName("tsNs").values.get(e.rowIndex);return Ae({},o,"BACKWARD"===r?{start:e.timeEpochMs-72e5+"000000",end:i,direction:r}:{start:i,end:e.timeEpochMs+72e5+"000000"})},o.languageProvider=new Le(We(o));var m=e.jsonData||{};return o.maxLines=parseInt(null!==(r=m.maxLines)&&void 0!==r?r:"0",10)||1e3,o}var r,i,m,d,g,O,x,w,j,k;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ue(e,t)}(t,e),r=t,(i=[{key:"_request",value:function(e,t,r){var n=this.instanceSettings.url,a=t?Object(Pe.d)(t):"",o=Ae({},r,{url:"".concat(n).concat(e).concat(a.length?"?".concat(a):"")});return Object(b.getBackendSrv)().fetch(o)}},{key:"query",value:function(e){var t=this,r=[],n=e.targets.filter((function(e){return e.expr&&!e.hide})).map((function(r){return Ae({},r,{expr:t.templateSrv.replace(r.expr,e.scopedVars,t.interpolateQueryExpr)})})),i=!0,u=!1,l=void 0;try{for(var f,p=n[Symbol.iterator]();!(i=(f=p.next()).done);i=!0){var m=f.value;m.instant?r.push(this.runInstantQuery(m,e,n.length)):r.push(this.runRangeQuery(m,e,n.length))}}catch(e){u=!0,l=e}finally{try{i||null==p.return||p.return()}finally{if(u)throw l}}return Object(o.isEmpty)(r)?Object(s.a)({data:[],state:a.LoadingState.Done}):c.a.apply(void 0,r)}},{key:"createRangeQuery",value:function(e,t,r){var n=e.expr,a={};if(t.range){var o=this.getTime(t.range.from,!1),i=this.getTime(t.range.to,!0),u=Math.ceil((i-o)/1e6),s=this.adjustInterval(t.intervalMs||1e3,u)/1e3,c=Math.ceil(1e3*s)/1e3,l={start:o-o%1e9,end:i+(1e9-i%1e9)};a={start:l.start,end:l.end,step:c}}return Ae({},Ke,{},a,{query:n,limit:r})}},{key:"createLiveTarget",value:function(e,t){var r=e.expr,n=this.instanceSettings.url,a=Object(Pe.d)({query:r});return{query:r,url:Object(y.d)("".concat(n,"/loki/api/v1/tail?").concat(a)),refId:e.refId,size:t}}},{key:"interpolateVariablesInQueries",value:function(e,t){var r=this,n=e;return e&&e.length&&(n=e.map((function(e){return Ae({},e,{datasource:r.name,expr:r.templateSrv.replace(e.expr,t,r.interpolateQueryExpr)})}))),n}},{key:"getQueryDisplayText",value:function(e){return e.expr}},{key:"importQueries",value:(k=De(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.languageProvider.importQueries(t,r.id));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return k.apply(this,arguments)})},{key:"metadataRequest",value:(j=De(regeneratorRuntime.mark((function e(t,r){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._request(t,r,{hideFromInspector:!0}).toPromise();case 2:return n=e.sent,e.abrupt("return",n.data.data||n.data.values||[]);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return j.apply(this,arguments)})},{key:"metricFindQuery",value:(w=De(regeneratorRuntime.mark((function e(t,r){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return",Promise.resolve([]));case 2:return n=this.templateSrv.replace(t,{},this.interpolateQueryExpr),e.next=5,this.processMetricFindQuery(n,null==r?void 0:r.range);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return w.apply(this,arguments)})},{key:"processMetricFindQuery",value:(x=De(regeneratorRuntime.mark((function e(t,r){var n,a,o,i,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=/^label_names\(\)\s*$/,a=/^label_values\((?:(.+),\s*)?([a-zA-Z_][a-zA-Z0-9_]*)\)\s*$/,o=r||this.timeSrv.timeRange(),i=Te({from:o.from.valueOf(),to:o.to.valueOf()}),!t.match(n)){e.next=9;break}return e.next=8,this.labelNamesQuery(i);case 8:return e.abrupt("return",e.sent);case 9:if(!(u=t.match(a))){e.next=14;break}return e.next=13,this.labelValuesQuery(u[2],i);case 13:return e.abrupt("return",e.sent);case 14:return e.abrupt("return",Promise.resolve([]));case 15:case"end":return e.stop()}}),e,this)}))),function(e,t){return x.apply(this,arguments)})},{key:"labelNamesQuery",value:(O=De(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="".concat("/loki/api/v1","/label"),e.next=3,this.metadataRequest(r,t);case 3:return n=e.sent,e.abrupt("return",n.map((function(e){return{text:e}})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return O.apply(this,arguments)})},{key:"labelValuesQuery",value:(g=De(regeneratorRuntime.mark((function e(t,r){var n,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="".concat("/loki/api/v1","/label/").concat(t,"/values"),e.next=3,this.metadataRequest(n,r);case 3:return a=e.sent,e.abrupt("return",a.map((function(e){return{text:e}})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return g.apply(this,arguments)})},{key:"interpolateQueryExpr",value:function(e,t){return t.multi||t.includeAll?"string"==typeof e?Je(e):Object(o.map)(e,Je).join("|"):He(e)}},{key:"modifyQuery",value:function(e,t){var r,n=null!==(r=e.expr)&&void 0!==r?r:"";switch(t.type){case"ADD_FILTER":n=Object(v.a)(n,t.key,t.value,void 0,!0);break;case"ADD_FILTER_OUT":n=Object(v.a)(n,t.key,t.value,"!=",!0)}return Ae({},e,{expr:n})}},{key:"getHighlighterExpression",value:function(e){return _(e.expr)}},{key:"getTime",value:function(e,t){return"string"==typeof e&&(e=a.dateMath.parse(e,t)),Math.ceil(1e6*e.valueOf())}},{key:"testDatasource",value:function(){var e=Date.now()-6e5,t="".concat(e,"000000");return this._request("".concat("/loki/api/v1","/label"),{start:t}).pipe(Object(l.a)((function(e){var t,r;return((null==e||null===(t=e.data)||void 0===t?void 0:t.data)||(null==e||null===(r=e.data)||void 0===r?void 0:r.values)||[]).length>0?{status:"success",message:"Data source connected and labels found."}:{status:"error",message:"Data source connected, but no labels received. Verify that Loki and Promtail is configured properly."}})),Object(f.a)((function(e){var t="Loki: ";return e.statusText?t+=e.statusText:t+="Cannot connect to Loki",e.status&&(t+=". ".concat(e.status)),e.data&&e.data.message?t+=". ".concat(e.data.message):e.data&&(t+=". ".concat(e.data)),Object(s.a)({status:"error",message:t})}))).toPromise()}},{key:"annotationQuery",value:(d=De(regeneratorRuntime.mark((function e(t){var r,n,o,i,u,s,c,l,f,p,m;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.annotation.expr){e.next=2;break}return e.abrupt("return",[]);case 2:return r=this.templateSrv.replace(t.annotation.expr,{},this.interpolateQueryExpr),n={refId:"annotation-".concat(t.annotation.name),expr:r},e.next=6,this.runRangeQuery(n,t).toPromise();case 6:for(o=e.sent,i=o.data,u=[],s=!0,c=!1,l=void 0,e.prev=12,f=function(){var e=m.value,t=[],r=!0,n=!1,o=void 0;try{for(var i,s=e.fields[Symbol.iterator]();!(r=(i=s.next()).done);r=!0){var c=i.value;c.labels&&t.push.apply(t,Re(new Set(Object.values(c.labels).map((function(e){return e.trim()})))))}}catch(e){n=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw o}}new a.DataFrameView(e).forEach((function(e){u.push({time:new Date(e.ts).valueOf(),text:e.line,tags:t})}))},p=i[Symbol.iterator]();!(s=(m=p.next()).done);s=!0)f();e.next=21;break;case 17:e.prev=17,e.t0=e.catch(12),c=!0,l=e.t0;case 21:e.prev=21,e.prev=22,s||null==p.return||p.return();case 24:if(e.prev=24,!c){e.next=27;break}throw l;case 27:return e.finish(24);case 28:return e.finish(21);case 29:return e.abrupt("return",u);case 30:case"end":return e.stop()}}),e,this,[[12,17,21,29],[22,,24,28]])}))),function(e){return d.apply(this,arguments)})},{key:"showContextToggle",value:function(e){return!0===(e&&e.searchWords&&e.searchWords.length>0)}},{key:"throwUnless",value:function(e,t,r){if(t)return Object(s.a)(e);throw this.processError(e,r)}},{key:"processError",value:function(e,t){var r=Object(o.cloneDeep)(e);return e.data.message.includes("escape")&&t.expr.includes("\\")&&(r.data.message="Error: ".concat(e.data.message,". Make sure that all special characters are escaped with \\. For more information on escaping of special characters visit LogQL documentation at https://grafana.com/docs/loki/latest/logql/.")),r}},{key:"adjustInterval",value:function(e,t){return 0!==e&&t/e>11e3&&(e=Math.ceil(t/11e3)),Math.max(e,1)}}])&&Qe(r.prototype,i),m&&Qe(r,m),t}(a.DataSourceApi),Xe=r("q1tI"),Ge=r.n(Xe);function Ye(e){return(Ye="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function et(e,t,r,n,a,o,i){try{var u=e[o](i),s=u.value}catch(e){return void r(e)}u.done?t(s):Promise.resolve(s).then(n,a)}function tt(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){et(o,n,a,i,u,"next",e)}function u(e){et(o,n,a,i,u,"throw",e)}i(void 0)}))}}function rt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function nt(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function at(e,t){return!t||"object"!==Ye(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function ot(e){return(ot=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function it(e,t){return(it=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var ut=['{job="default/prometheus"}'],st=["job","app","k8s_app"],ct=[{title:"Log pipeline",expression:'{job="mysql"} |= "metrics" | logfmt | duration > 10s',label:'This query targets the MySQL job, filters out logs that don’t contain the word "metrics" and parses each log line to extract more labels and filters with them.'},{title:"Count over time",expression:'count_over_time({job="mysql"}[5m])',label:"This query counts all the log lines within the last five minutes for the MySQL job."},{title:"Rate",expression:'rate(({job="mysql"} |= "error" != "timeout")[10s])',label:"This query gets the per-second rate of all non-timeout errors within the last ten seconds for the MySQL job."},{title:"Aggregate, count, and group",expression:'sum(count_over_time({job="mysql"}[5m])) by (level)',label:"Get the count of logs during the last five minutes, grouping by level."}],lt=function(e){function t(){var e,r;rt(this,t);for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return(r=at(this,(e=ot(t)).call.apply(e,[this].concat(a)))).state={userExamples:ut},r.checkUserLabels=tt(regeneratorRuntime.mark((function e(){var t,n,a,i,u,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=null===(t=r.props.datasource)||void 0===t?void 0:t.languageProvider).started){e.next=12;break}if(a=n.getLabelKeys()||[],!(i=st.find((function(e){return a.includes(e)})))){e.next=10;break}return e.next=7,n.getLabelValues(i);case 7:u=e.sent,s=Object(o.shuffle)(u).slice(0,5).map((function(e){return"{".concat(i,'="').concat(e,'"}')})),r.setState({userExamples:s});case 10:e.next=13;break;case 12:r.scheduleUserLabelChecking();case 13:case"end":return e.stop()}}),e)}))),r}var r,n,a;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&it(e,t)}(t,e),r=t,(n=[{key:"componentDidMount",value:function(){this.scheduleUserLabelChecking()}},{key:"componentWillUnmount",value:function(){clearTimeout(this.userLabelTimer)}},{key:"scheduleUserLabelChecking",value:function(){this.userLabelTimer=setTimeout(this.checkUserLabels,1e3)}},{key:"renderExpression",value:function(e){var t=this.props.onClickExample;return Ge.a.createElement("div",{className:"cheat-sheet-item__example",key:e,onClick:function(r){return t({refId:"A",expr:e})}},Ge.a.createElement("code",null,e))}},{key:"render",value:function(){var e=this,t=this.state.userExamples;return Ge.a.createElement("div",null,Ge.a.createElement("h2",null,"Loki Cheat Sheet"),Ge.a.createElement("div",{className:"cheat-sheet-item"},Ge.a.createElement("div",{className:"cheat-sheet-item__title"},"See your logs"),Ge.a.createElement("div",{className:"cheat-sheet-item__label"},"Start by selecting a log stream from the Log labels selector."),Ge.a.createElement("div",{className:"cheat-sheet-item__label"},"Alternatively, you can write a stream selector into the query field:"),this.renderExpression('{job="default/prometheus"}'),t!==ut&&t.length>0?Ge.a.createElement("div",null,Ge.a.createElement("div",{className:"cheat-sheet-item__label"},"Here are some example streams from your logs:"),t.map((function(t){return e.renderExpression(t)}))):null),Ge.a.createElement("div",{className:"cheat-sheet-item"},Ge.a.createElement("div",{className:"cheat-sheet-item__title"},"Combine stream selectors"),this.renderExpression('{app="cassandra",namespace="prod"}'),Ge.a.createElement("div",{className:"cheat-sheet-item__label"},"Returns all log lines from streams that have both labels.")),Ge.a.createElement("div",{className:"cheat-sheet-item"},Ge.a.createElement("div",{className:"cheat-sheet-item__title"},"Filtering for search terms."),this.renderExpression('{app="cassandra"} |~ "(duration|latency)s*(=|is|of)s*[d.]+"'),this.renderExpression('{app="cassandra"} |= "exact match"'),this.renderExpression('{app="cassandra"} != "do not match"'),Ge.a.createElement("div",{className:"cheat-sheet-item__label"},Ge.a.createElement("a",{href:"https://grafana.com/docs/loki/latest/logql/#log-pipeline",target:"logql"},"LogQL")," ","supports exact and regular expression filters.")),ct.map((function(t){return Ge.a.createElement("div",{className:"cheat-sheet-item",key:t.expression},Ge.a.createElement("div",{className:"cheat-sheet-item__title"},t.title),e.renderExpression(t.expression),Ge.a.createElement("div",{className:"cheat-sheet-item__label"},t.label))})))}}])&&nt(r.prototype,n),a&&nt(r,a),t}(Xe.PureComponent),ft=r("KwPh"),pt=r("Imda");function mt(){return(mt=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function dt(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var bt=function(e){var t=e.datasource,r=e.range,n=dt(e,["datasource","range"]),a={from:r.from.valueOf(),to:r.to.valueOf()},o=Object(pt.a)(t.languageProvider,a),i=o.setActiveOption,u=o.refreshLabels,s=o.logLabelOptions,c=o.labelsLoaded;return Ge.a.createElement(ft.a,mt({datasource:t,onLoadOptions:i,onLabelsRefresh:u,absoluteRange:a,labelsLoaded:c,logLabelOptions:s},n))};var vt=Object(Xe.memo)((function(e){var t=e.range,r=e.query,n=e.data,a=e.datasource,o=e.history,i=e.onChange,u=e.onRunQuery;return Ge.a.createElement(bt,{datasource:a,query:r,onChange:i,onBlur:function(){},onRunQuery:u,history:o,data:n,range:t})})),ht=r("kDLi");function yt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function gt(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Ot=Object(Xe.memo)((function(e){var t=e.range,r=e.query,n=e.data,a=e.datasource,o=e.onChange,i=e.onRunQuery,u=Ge.a.createElement("div",{className:"gf-form-inline"},Ge.a.createElement("div",{className:"gf-form"},Ge.a.createElement(ht.InlineFormLabel,{width:6,tooltip:"Controls the name of the time series, using name or pattern. For example {{hostname}} will be replaced with label value for the label hostname. The legend only applies to metric queries."},"Legend"),Ge.a.createElement("input",{type:"text",className:"gf-form-input",placeholder:"legend format",value:r.legendFormat||"",onChange:function(e){var t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?yt(Object(r),!0).forEach((function(t){gt(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):yt(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},r,{legendFormat:e.currentTarget.value});o(t)},onBlur:i})));return Ge.a.createElement(bt,{datasource:a,query:r,onChange:o,onRunQuery:i,onBlur:i,history:[],data:n,range:t,runOnBlur:!0,ExtraFieldElement:u})}));function xt(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var wt=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.annotation.target=this.annotation.target||{},this.onQueryChange=this.onQueryChange.bind(this)}var t,r,n;return t=e,(r=[{key:"onQueryChange",value:function(e){this.annotation.expr=e}}])&&xt(t.prototype,r),n&&xt(t,n),e}();wt.templateUrl="partials/annotations.editor.html";var jt=ht.LegacyForms.FormField,kt=function(e){var t=e.value,r=e.onChange;return Ge.a.createElement(jt,{label:"Maximum lines",labelWidth:11,inputWidth:20,inputEl:Ge.a.createElement("input",{type:"number",className:"gf-form-input width-8 gf-form-input--has-help-icon",value:t,onChange:function(e){return r(e.currentTarget.value)},spellCheck:!1,placeholder:"1000"}),tooltip:Ge.a.createElement(Ge.a.Fragment,null,"Loki queries must contain a limit of the maximum number of lines returned (default: 1000). Increase this limit to have a bigger result set for ad-hoc analysis. Decrease this limit if your browser becomes sluggish when displaying the log results.")})},_t=r("kDDq"),Et=r("Wkk1"),St=r("tLXD");function Tt(){var e=Nt(["\n          width: 100%;\n        "]);return Tt=function(){return e},e}function Lt(){var e=Nt(["\n            margin-left: 8px;\n          "]);return Lt=function(){return e},e}function Pt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ct(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Pt(Object(r),!0).forEach((function(t){Rt(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Pt(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Rt(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ft(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e))&&"[object Arguments]"!==Object.prototype.toString.call(e))return;var r=[],n=!0,a=!1,o=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){a=!0,o=e}finally{try{n||null==u.return||u.return()}finally{if(a)throw o}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function Dt(){var e=Nt(["\n    flex: 3;\n  "]);return Dt=function(){return e},e}function It(){var e=Nt(["\n    flex: 2;\n  "]);return It=function(){return e},e}function At(){var e=Nt(["\n    display: flex;\n    align-items: baseline;\n  "]);return At=function(){return e},e}function Nt(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var qt=ht.LegacyForms.Switch,Qt=ht.LegacyForms.FormField,Bt=Object(ht.stylesFactory)((function(){return{row:Object(_t.css)(At()),nameField:Object(_t.css)(It()),regexField:Object(_t.css)(Dt())}})),Vt=function(e){var t=e.value,r=e.onChange,n=e.onDelete,a=e.suggestions,o=e.className,i=Bt(),u=Ft(Object(Xe.useState)(!!t.datasourceUid),2),s=u[0],c=u[1],l=Object(St.a)(t.datasourceUid);Object(Xe.useEffect)((function(){l||!t.datasourceUid||s||c(!0),l&&!t.datasourceUid&&s&&c(!1)}),[l,t.datasourceUid,s]);var f=function(e){return function(n){r(Ct({},t,Rt({},e,n.currentTarget.value)))}};return Ge.a.createElement("div",{className:o},Ge.a.createElement("div",{className:i.row},Ge.a.createElement(Qt,{className:i.nameField,labelWidth:5,inputWidth:null,label:"Name",type:"text",value:t.name,onChange:f("name")}),Ge.a.createElement(Qt,{className:i.regexField,inputWidth:null,label:"Regex",type:"text",value:t.matcherRegex,onChange:f("matcherRegex"),tooltip:"Use to parse and capture some part of the log message. You can use the captured groups in the template."}),Ge.a.createElement(ht.Button,{variant:"destructive",title:"Remove field",icon:"times",onClick:function(e){e.preventDefault(),n()},className:Object(_t.css)(Lt())})),Ge.a.createElement(Qt,{label:s?"Query":"URL",labelWidth:5,inputEl:Ge.a.createElement(ht.DataLinkInput,{placeholder:s?"${__value.raw}":"http://example.com/${__value.raw}",value:t.url||"",onChange:function(e){return r(Ct({},t,{url:e}))},suggestions:a}),className:Object(_t.css)(Tt())}),Ge.a.createElement("div",{className:i.row},Ge.a.createElement(qt,{label:"Internal link",checked:s,onChange:function(){s&&r(Ct({},t,{datasourceUid:void 0})),c(!s)}}),s&&Ge.a.createElement(Et.a,{tracing:!0,onChange:function(e){return r(Ct({},t,{datasourceUid:e.uid}))},current:t.datasourceUid})))},Wt=r("TSYQ"),Ut=r.n(Wt),Mt=r("Xc1M");function zt(){var e=function(e,t){t||(t=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(["\n                width: 100%;\n              "]);return zt=function(){return e},e}function Kt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e))&&"[object Arguments]"!==Object.prototype.toString.call(e))return;var r=[],n=!0,a=!1,o=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){a=!0,o=e}finally{try{n||null==u.return||u.return()}finally{if(a)throw o}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var Ht=ht.LegacyForms.FormField,Jt=function(e){var t=e.derivedFields,r=e.className,n=Kt(Object(Xe.useState)(""),2),o=n[0],i=n[1],u=[];return o&&t&&(u=function(e,t){return e.filter((function(e){return e.name&&e.matcherRegex})).map((function(e){try{var r=t.match(e.matcherRegex),n=r&&r[1],o=null;return e.url&&n&&(o=Object(Mt.a)({field:{name:"",type:a.FieldType.string,values:new a.ArrayVector([n]),config:{links:[{title:"",url:e.url}]}},rowIndex:0,range:{}})[0]),{name:e.name,value:n||"<no match>",href:o&&o.href}}catch(t){return{name:e.name,error:t}}}))}(t,o)),Ge.a.createElement("div",{className:r},Ge.a.createElement(Ht,{labelWidth:12,label:"Debug log message",inputEl:Ge.a.createElement("textarea",{placeholder:"Paste an example log line here to test the regular expressions of your derived fields",className:Ut()("gf-form-input gf-form-textarea",Object(_t.css)(zt())),value:o,onChange:function(e){return i(e.currentTarget.value)}})}),!!u.length&&Ge.a.createElement($t,{fields:u}))},$t=function(e){var t=e.fields;return Ge.a.createElement("table",{className:"filter-table"},Ge.a.createElement("thead",null,Ge.a.createElement("tr",null,Ge.a.createElement("th",null,"Name"),Ge.a.createElement("th",null,"Value"),Ge.a.createElement("th",null,"Url"))),Ge.a.createElement("tbody",null,t.map((function(e){var t=e.value;return e.error?t=e.error.message:e.href&&(t=Ge.a.createElement("a",{href:e.href},t)),Ge.a.createElement("tr",{key:"".concat(e.name,"=").concat(e.value)},Ge.a.createElement("td",null,e.name),Ge.a.createElement("td",null,t),Ge.a.createElement("td",null,e.href?Ge.a.createElement("a",{href:e.href},e.href):""))}))))};function Zt(){var e=rr(["\n              margin-bottom: 10px;\n            "]);return Zt=function(){return e},e}function Xt(){var e=rr(["\n              margin-right: 10px;\n            "]);return Xt=function(){return e},e}function Gt(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function Yt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e))&&"[object Arguments]"!==Object.prototype.toString.call(e))return;var r=[],n=!0,a=!1,o=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){a=!0,o=e}finally{try{n||null==u.return||u.return()}finally{if(a)throw o}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function er(){var e=rr(["\n    margin-bottom: ",";\n  "]);return er=function(){return e},e}function tr(){var e=rr(["\n    padding-bottom: ",";\n    color: ",";\n  "]);return tr=function(){return e},e}function rr(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var nr=Object(ht.stylesFactory)((function(e){return{infoText:Object(_t.css)(tr(),e.spacing.md,e.colors.textWeak),derivedField:Object(_t.css)(er(),e.spacing.sm)}})),ar=function(e){var t=e.value,r=e.onChange,n=Object(ht.useTheme)(),o=nr(n),i=Yt(Object(Xe.useState)(!1),2),u=i[0],s=i[1];return Ge.a.createElement(Ge.a.Fragment,null,Ge.a.createElement("h3",{className:"page-heading"},"Derived fields"),Ge.a.createElement("div",{className:o.infoText},"Derived fields can be used to extract new fields from a log message and create a link from its value."),Ge.a.createElement("div",{className:"gf-form-group"},t&&t.map((function(e,n){return Ge.a.createElement(Vt,{className:o.derivedField,key:n,value:e,onChange:function(e){var a=Gt(t);a.splice(n,1,e),r(a)},onDelete:function(){var e=Gt(t);e.splice(n,1),r(e)},suggestions:[{value:a.DataLinkBuiltInVars.valueRaw,label:"Raw value",documentation:"Exact string captured by the regular expression",origin:a.VariableOrigin.Value}]})})),Ge.a.createElement("div",null,Ge.a.createElement(ht.Button,{variant:"secondary",className:Object(_t.css)(Xt()),icon:"plus",onClick:function(e){e.preventDefault();var n=[].concat(Gt(t||[]),[{name:"",matcherRegex:""}]);r(n)}},"Add"),t&&t.length>0&&Ge.a.createElement(ht.Button,{variant:"secondary",onClick:function(){return s(!u)}},u?"Hide example log message":"Show example log message"))),u&&Ge.a.createElement("div",{className:"gf-form-group"},Ge.a.createElement(Jt,{className:Object(_t.css)(Zt()),derivedFields:t})))};function or(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ir(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?or(Object(r),!0).forEach((function(t){ur(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):or(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function ur(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var sr=function(e){return function(t,r){return ir({},t,{jsonData:ir({},t.jsonData,ur({},e,r))})}},cr=sr("maxLines"),lr=sr("derivedFields");r.d(t,"plugin",(function(){return fr}));var fr=new a.DataSourcePlugin(Ze).setQueryEditor(Ot).setConfigEditor((function(e){var t=e.options,r=e.onOptionsChange;return Ge.a.createElement(Ge.a.Fragment,null,Ge.a.createElement(ht.DataSourceHttpSettings,{defaultUrl:"http://localhost:3100",dataSourceConfig:t,showAccessOptions:!1,onChange:r}),Ge.a.createElement("div",{className:"gf-form-group"},Ge.a.createElement("div",{className:"gf-form-inline"},Ge.a.createElement("div",{className:"gf-form"},Ge.a.createElement(kt,{value:t.jsonData.maxLines||"",onChange:function(e){return r(cr(t,e))}})))),Ge.a.createElement(ar,{value:t.jsonData.derivedFields,onChange:function(e){return r(lr(t,e))}}))})).setExploreQueryField(vt).setQueryEditorHelp(lt).setAnnotationQueryCtrl(wt)},ANhw:function(e,t){var r,n;r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],r=0,n=0;r<e.length;r++,n+=8)t[n>>>5]|=e[r]<<24-n%32;return t},wordsToBytes:function(e){for(var t=[],r=0;r<32*e.length;r+=8)t.push(e[r>>>5]>>>24-r%32&255);return t},bytesToHex:function(e){for(var t=[],r=0;r<e.length;r++)t.push((e[r]>>>4).toString(16)),t.push((15&e[r]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],r=0;r<e.length;r+=2)t.push(parseInt(e.substr(r,2),16));return t},bytesToBase64:function(e){for(var t=[],n=0;n<e.length;n+=3)for(var a=e[n]<<16|e[n+1]<<8|e[n+2],o=0;o<4;o++)8*n+6*o<=8*e.length?t.push(r.charAt(a>>>6*(3-o)&63)):t.push("=");return t.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var t=[],n=0,a=0;n<e.length;a=++n%4)0!=a&&t.push((r.indexOf(e.charAt(n-1))&Math.pow(2,-2*a+8)-1)<<2*a|r.indexOf(e.charAt(n))>>>6-2*a);return t}},e.exports=n},BEtg:function(e,t){function r(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(r(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&r(e.slice(0,0))}(e)||!!e._isBuffer)}},aCH8:function(e,t,r){var n,a,o,i,u;n=r("ANhw"),a=r("mmNF").utf8,o=r("BEtg"),i=r("mmNF").bin,(u=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?i.stringToBytes(e):a.stringToBytes(e):o(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||(e=e.toString());for(var r=n.bytesToWords(e),s=8*e.length,c=1732584193,l=-271733879,f=-1732584194,p=271733878,m=0;m<r.length;m++)r[m]=16711935&(r[m]<<8|r[m]>>>24)|4278255360&(r[m]<<24|r[m]>>>8);r[s>>>5]|=128<<s%32,r[14+(s+64>>>9<<4)]=s;var d=u._ff,b=u._gg,v=u._hh,h=u._ii;for(m=0;m<r.length;m+=16){var y=c,g=l,O=f,x=p;c=d(c,l,f,p,r[m+0],7,-680876936),p=d(p,c,l,f,r[m+1],12,-389564586),f=d(f,p,c,l,r[m+2],17,606105819),l=d(l,f,p,c,r[m+3],22,-1044525330),c=d(c,l,f,p,r[m+4],7,-176418897),p=d(p,c,l,f,r[m+5],12,1200080426),f=d(f,p,c,l,r[m+6],17,-1473231341),l=d(l,f,p,c,r[m+7],22,-45705983),c=d(c,l,f,p,r[m+8],7,1770035416),p=d(p,c,l,f,r[m+9],12,-1958414417),f=d(f,p,c,l,r[m+10],17,-42063),l=d(l,f,p,c,r[m+11],22,-1990404162),c=d(c,l,f,p,r[m+12],7,1804603682),p=d(p,c,l,f,r[m+13],12,-40341101),f=d(f,p,c,l,r[m+14],17,-1502002290),c=b(c,l=d(l,f,p,c,r[m+15],22,1236535329),f,p,r[m+1],5,-165796510),p=b(p,c,l,f,r[m+6],9,-1069501632),f=b(f,p,c,l,r[m+11],14,643717713),l=b(l,f,p,c,r[m+0],20,-373897302),c=b(c,l,f,p,r[m+5],5,-701558691),p=b(p,c,l,f,r[m+10],9,38016083),f=b(f,p,c,l,r[m+15],14,-660478335),l=b(l,f,p,c,r[m+4],20,-405537848),c=b(c,l,f,p,r[m+9],5,568446438),p=b(p,c,l,f,r[m+14],9,-1019803690),f=b(f,p,c,l,r[m+3],14,-187363961),l=b(l,f,p,c,r[m+8],20,1163531501),c=b(c,l,f,p,r[m+13],5,-1444681467),p=b(p,c,l,f,r[m+2],9,-51403784),f=b(f,p,c,l,r[m+7],14,1735328473),c=v(c,l=b(l,f,p,c,r[m+12],20,-1926607734),f,p,r[m+5],4,-378558),p=v(p,c,l,f,r[m+8],11,-2022574463),f=v(f,p,c,l,r[m+11],16,1839030562),l=v(l,f,p,c,r[m+14],23,-35309556),c=v(c,l,f,p,r[m+1],4,-1530992060),p=v(p,c,l,f,r[m+4],11,1272893353),f=v(f,p,c,l,r[m+7],16,-155497632),l=v(l,f,p,c,r[m+10],23,-1094730640),c=v(c,l,f,p,r[m+13],4,681279174),p=v(p,c,l,f,r[m+0],11,-358537222),f=v(f,p,c,l,r[m+3],16,-722521979),l=v(l,f,p,c,r[m+6],23,76029189),c=v(c,l,f,p,r[m+9],4,-640364487),p=v(p,c,l,f,r[m+12],11,-421815835),f=v(f,p,c,l,r[m+15],16,530742520),c=h(c,l=v(l,f,p,c,r[m+2],23,-995338651),f,p,r[m+0],6,-198630844),p=h(p,c,l,f,r[m+7],10,1126891415),f=h(f,p,c,l,r[m+14],15,-1416354905),l=h(l,f,p,c,r[m+5],21,-57434055),c=h(c,l,f,p,r[m+12],6,1700485571),p=h(p,c,l,f,r[m+3],10,-1894986606),f=h(f,p,c,l,r[m+10],15,-1051523),l=h(l,f,p,c,r[m+1],21,-2054922799),c=h(c,l,f,p,r[m+8],6,1873313359),p=h(p,c,l,f,r[m+15],10,-30611744),f=h(f,p,c,l,r[m+6],15,-1560198380),l=h(l,f,p,c,r[m+13],21,1309151649),c=h(c,l,f,p,r[m+4],6,-145523070),p=h(p,c,l,f,r[m+11],10,-1120210379),f=h(f,p,c,l,r[m+2],15,718787259),l=h(l,f,p,c,r[m+9],21,-343485551),c=c+y>>>0,l=l+g>>>0,f=f+O>>>0,p=p+x>>>0}return n.endian([c,l,f,p])})._ff=function(e,t,r,n,a,o,i){var u=e+(t&r|~t&n)+(a>>>0)+i;return(u<<o|u>>>32-o)+t},u._gg=function(e,t,r,n,a,o,i){var u=e+(t&n|r&~n)+(a>>>0)+i;return(u<<o|u>>>32-o)+t},u._hh=function(e,t,r,n,a,o,i){var u=e+(t^r^n)+(a>>>0)+i;return(u<<o|u>>>32-o)+t},u._ii=function(e,t,r,n,a,o,i){var u=e+(r^(t|~n))+(a>>>0)+i;return(u<<o|u>>>32-o)+t},u._blocksize=16,u._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var r=n.wordsToBytes(u(e,t));return t&&t.asBytes?r:t&&t.asString?i.bytesToString(r):n.bytesToHex(r)}},kGJw:function(e,t,r){var n=r("dt0z"),a=/[\\^$.*+?()[\]{}|]/g,o=RegExp(a.source);e.exports=function(e){return(e=n(e))&&o.test(e)?e.replace(a,"\\$&"):e}},mmNF:function(e,t){var r={utf8:{stringToBytes:function(e){return r.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(r.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],r=0;r<e.length;r++)t.push(255&e.charCodeAt(r));return t},bytesToString:function(e){for(var t=[],r=0;r<e.length;r++)t.push(String.fromCharCode(e[r]));return t.join("")}}};e.exports=r},tLXD:function(e,t,r){"use strict";var n=r("q1tI");t.a=function(e){var t=Object(n.useRef)();return Object(n.useEffect)((function(){t.current=e})),t.current}}}]);
  //# sourceMappingURL=lokiPlugin.8727e0c1843e7fde919e.js.map