文件操作 - azureMonitorPlugin.2427a858f877b88b2243.js
返回文件管理
返回主菜单
删除本文件
文件: /usr/share/grafana/public/build/azureMonitorPlugin.2427a858f877b88b2243.js
编辑文件内容
(window.webpackJsonp=window.webpackJsonp||[]).push([[43],{CLTJ:function(e,t,r){"use strict";r.r(t);var n=r("Obii"),a=r("LvDl"),i=r.n(a),o=r("LzXI"),s=r("PbtU");function u(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 c=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r,n;return t=e,n=[{key:"createISO8601Duration",value:function(e,t){return i.a.includes(["hour","minute","h","m"],t)?"PT".concat(e).concat(t[0].toUpperCase()):"P".concat(e).concat(t[0].toUpperCase())}},{key:"createISO8601DurationFromInterval",value:function(t){var r=+t.slice(0,t.length-1),n=t[t.length-1];if(t.indexOf("ms")>-1)return e.createISO8601Duration(1,"m");if("s"===t[t.length-1]){var a=60*r%60;return a<1&&(a=1),e.createISO8601Duration(a,"m")}return e.createISO8601Duration(r,n)}},{key:"findClosestTimeGrain",value:function(e,t){for(var r=i.a.filter(t,(function(e){return"auto"!==e})),n=r[0],a=s.a.interval_to_ms(e),o=0;o<r.length;o++)a>s.a.interval_to_ms(r[o])&&(n=o+1<r.length?r[o+1]:r[o]);return n}},{key:"createTimeGrainFromISO8601Duration",value:function(t){var r=1;"PT"===t.substring(0,2)&&(r=2);var n=t.substring(r,t.length-1),a=t.substring(t.length-1);return n+" "+e.timeUnitToText(+n,a)}},{key:"timeUnitToText",value:function(e,t){var r="";return"S"===t&&(r="second"),"M"===t&&(r="minute"),"H"===t&&(r="hour"),"D"===t&&(r="day"),e>1?r+"s":r}},{key:"createKbnUnitFromISO8601Duration",value:function(t){if("auto"===t)return"auto";var r=1;"PT"===t.substring(0,2)&&(r=2);var n=t.substring(r,t.length-1),a=t.substring(t.length-1);return n+e.timeUnitToKbn(+n,a)}},{key:"timeUnitToKbn",value:function(e,t){return"S"===t?"s":"M"===t?"m":"H"===t?"h":"D"===t?"d":""}}],(r=null)&&u(t.prototype,r),n&&u(t,n),e}(),l=r("mkUw"),p=r("q1tI"),f=r.n(p),h=r("wZee"),m=r.n(h);var d=r("kDLi");function g(){return(g=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 y(e){return(y="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 v(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b(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 w(e,t,r){return t&&b(e.prototype,t),r&&b(e,r),e}function x(e,t){return!t||"object"!==y(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 S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function k(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&&M(e,t)}function M(e,t){return(M=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var A=function(e){function t(){var e,r;v(this,t);for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return(r=x(this,(e=S(t)).call.apply(e,[this].concat(a)))).getRef=function(e){r.el=e},r}return k(t,e),w(t,[{key:"componentDidUpdate",value:function(e){this.props.isSelected&&!e.isSelected&&function(e){if(e&&e.offsetParent){var t=e.offsetParent;(e.offsetTop>t.scrollTop+t.offsetHeight||e.offsetTop<t.scrollTop)&&(t.scrollTop=e.offsetTop-t.offsetTop)}}(this.el)}},{key:"render",value:function(){var e=this.props,t=e.hint,r=e.isSelected,n=e.label,a=e.onClickItem,i=r?"typeahead-item typeahead-item__selected":"typeahead-item";return f.a.createElement("li",{ref:this.getRef,className:i,onClick:function(){return a(n)}},n,t&&r?f.a.createElement("div",{className:"typeahead-item-hint"},t):null)}}]),t}(f.a.PureComponent),C=function(e){function t(){return v(this,t),x(this,S(t).apply(this,arguments))}return k(t,e),w(t,[{key:"render",value:function(){var e=this.props,t=e.items,r=e.label,n=e.selected,a=e.onClickItem;return f.a.createElement("li",{className:"typeahead-group"},f.a.createElement("div",{className:"typeahead-group__title"},r),f.a.createElement("ul",{className:"typeahead-group__list"},t.map((function(e){var t="object"===y(e)?e.text:e,r="object"===y(e)?e.display||e.text:e;return f.a.createElement(A,{key:t,onClickItem:a,isSelected:n.indexOf(t)>-1,hint:e.hint,label:r})}))))}}]),t}(f.a.PureComponent),D=function(e){function t(){return v(this,t),x(this,S(t).apply(this,arguments))}return k(t,e),w(t,[{key:"render",value:function(){var e=this.props,t=e.groupedItems,r=e.menuRef,n=e.selectedItems,a=e.onClickItem;return f.a.createElement("ul",{className:"typeahead",ref:r},t.map((function(e){return f.a.createElement(C,g({key:e.label,onClickItem:a,selected:n},e))})))}}]),t}(f.a.PureComponent),I=r("WUic"),O=r("0aAt"),T=r("LBMm"),z=r("i8i4"),N=r.n(z);function R(e){return(R="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 _(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function E(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 j(e,t,r){return t&&E(e.prototype,t),r&&E(e,r),e}function P(e,t){return!t||"object"!==R(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 G(e){return(G=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function F(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&&q(e,t)}function q(e,t){return(q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function L(e){return e?e.reduce((function(e,t){return e.concat(t.items)}),[]):[]}var X=function(e){function t(e){var r;_(this,t),r=P(this,G(t).call(this,e));var n=e.index,a=void 0===n?0:n,i=e.prefix,o=void 0===i?"query":i;return r.node=document.createElement("div"),r.node.classList.add("slate-typeahead","slate-typeahead-".concat(o,"-").concat(a)),document.body.appendChild(r.node),r}return F(t,e),j(t,[{key:"componentWillUnmount",value:function(){document.body.removeChild(this.node)}},{key:"render",value:function(){return N.a.createPortal(this.props.children,this.node)}}]),t}(f.a.Component),U=function(e){function t(e,r){var n;_(this,t),(n=P(this,G(t).call(this,e,r))).keybindingSrv=Object(I.a)(),n.onChange=function(e){var t=e.value,r=t.document!==n.state.value.document;n.setState({value:t},(function(){r&&(requestAnimationFrame((function(){return n.onTypeahead()})),n.onChangeQuery())}))},n.request=function(e){return n.props.request?n.props.request(e):fetch(e)},n.onChangeQuery=function(){var e=n.props.onQueryChange;e&&e(l.a.serialize(n.state.value))},n.onKeyDown=function(e,t,r){var a=n.state,i=a.typeaheadIndex,o=a.suggestions,s=e;switch(s.key){case"Escape":if(n.menuEl)return s.preventDefault(),s.stopPropagation(),n.resetTypeahead(),!0;break;case" ":if(s.ctrlKey)return s.preventDefault(),n.onTypeahead(!0),!0;break;case"Tab":case"Enter":if(n.menuEl&&null!==i){if(s.preventDefault(),!o||!o.length||s.shiftKey||s.ctrlKey)return r();var u=L(o),c=u[Math.abs(i)%u.length||0];return n.applyTypeahead(t,c)}break;case"ArrowDown":n.menuEl&&(s.preventDefault(),n.setState({typeaheadIndex:(i||0)+1}));break;case"ArrowUp":n.menuEl&&(s.preventDefault(),n.setState({typeaheadIndex:Math.max(0,(i||0)-1)}))}return r()},n.onTypeahead=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];arguments.length>1&&arguments[1];return e},n.applyTypeahead=function(e,t){return{value:new O.n}},n.resetTypeahead=function(e){n.setState({suggestions:[],typeaheadIndex:null,typeaheadPrefix:"",typeaheadContext:null},e)},n.handleBlur=function(e,t,r){var a=n.props.onBlur;return n.resetTimer=setTimeout(n.resetTypeahead,100),a&&a(),n.restoreEscapeKeyBinding(),r()},n.handleFocus=function(e,t,r){var a=n.props.onFocus;return a&&a(),n.removeEscapeKeyBinding(),r()},n.onClickItem=function(e){var t=n.state.suggestions;if(t&&0!==t.length){var r=n.applyTypeahead();n.onChange(r)}},n.updateMenu=function(){var e=n.state.suggestions,t=n.menuEl,r=window.getSelection().anchorNode;if(t)if(e&&e.length>0){if(r&&r.parentElement){var a=r.parentElement.getBoundingClientRect(),i=window.scrollX,o=window.scrollY,s=window.innerHeight,u=a.left+i-2,c=a.top+o+a.height+4,l=s-c-10;requestAnimationFrame((function(){t.style.opacity=1,t.style.top="".concat(c,"px"),t.style.left="".concat(u,"px"),t.style.maxHeight="".concat(l,"px")}))}}else t.removeAttribute("style")},n.menuRef=function(e){n.menuEl=e},n.renderMenu=function(){var e=n.props.portalPrefix,t=n.state,r=t.suggestions,a=t.typeaheadIndex;if(!(r&&r.length>0))return null;var i=Math.max(a,0),o=L(r);i=i%o.length||0;var s=(null!==a&&o.length>0?[o[i]]:[]).map((function(e){return"object"===R(e)?e.text:e}));return f.a.createElement(X,{prefix:e},f.a.createElement(D,{menuRef:n.menuRef,selectedItems:s,onClickItem:n.onClickItem,groupedItems:r}))};var a,i,o,s,u,c,p=e.prismDefinition,h=void 0===p?{}:p,g=e.prismLanguage,y=void 0===g?"kusto":g;return n.plugins=[Object(d.BracesPlugin)(),Object(d.ClearPlugin)(),Object(d.RunnerPlugin)({handler:e.onPressEnter}),Object(d.NewlinePlugin)(),(a={definition:h,language:y},i=a.definition,o=a.language,i&&(m.a.languages[o]=m.a.languages[o]||i),{renderDecoration:function(e,t,r){var n=e.children,a=e.decoration;if("prism-token"!==a.type)return r();var i="token ".concat(a.data.get("types"));return f.a.createElement("span",{className:i},n)},decorateNode:function(e,t,r){if("paragraph"!==e.type)return[];var n=e.getTexts().toArray(),a=n.map((function(e){return e.text})).join("\n"),i=m.a.languages[o],s=m.a.tokenize(a,i),u=[],c=n.shift(),l=c,p=0,f=0,h=0;function d(t,r){var a="".concat(r||""," ").concat(t.type||""," ").concat(t.alias||"");if("string"==typeof t||"string"==typeof t.content){c=l,p=f;var i="string"==typeof t?t:t.content,o=i.split("\n").length-1,s=i.length-o,m=h+s,g=c.text.length-p,y=s;for(f=p+y;g<y;)y=s-g,g=(l=n.shift()).text.length,f=y;if("string"!=typeof t||r){var v=e.createDecoration({anchor:{key:c.key,offset:p},focus:{key:l.key,offset:f},type:"prism-token",data:{types:a}});u.push(v)}h=m}else if(t.content&&t.content.length){var b=!0,w=!1,x=void 0;try{for(var S,k=t.content[Symbol.iterator]();!(b=(S=k.next()).done);b=!0)d(S.value,a)}catch(e){w=!0,x=e}finally{try{b||null==k.return||k.return()}finally{if(w)throw x}}}}var g=!0,y=!1,v=void 0;try{for(var b,w=s[Symbol.iterator]();!(g=(b=w.next()).done);g=!0)d(b.value)}catch(e){y=!0,v=e}finally{try{g||null==w.return||w.return()}finally{if(y)throw v}}return u}})],n.state={labelKeys:{},labelValues:{},suggestions:[],typeaheadIndex:null,typeaheadPrefix:"",value:(s=e.initialQuery||"",O.n.create({document:(u=s,c=u.split("\n").map((function(e){return O.a.create({type:"paragraph",nodes:[O.m.create(e)]})})),O.d.create({nodes:c}))}))},n}return F(t,e),j(t,[{key:"componentDidMount",value:function(){this.updateMenu()}},{key:"componentWillUnmount",value:function(){this.restoreEscapeKeyBinding(),clearTimeout(this.resetTimer)}},{key:"componentDidUpdate",value:function(){this.updateMenu()}},{key:"removeEscapeKeyBinding",value:function(){this.keybindingSrv.unbind("esc","keydown")}},{key:"restoreEscapeKeyBinding",value:function(){this.keybindingSrv.setupGlobal()}},{key:"render",value:function(){return f.a.createElement("div",{className:"slate-query-field"},this.renderMenu(),f.a.createElement(T.a,{autoCorrect:!1,onBlur:this.handleBlur,onKeyDown:this.onKeyDown,onChange:this.onChange,onFocus:this.handleFocus,placeholder:this.props.placeholder,plugins:this.plugins,spellCheck:!1,value:this.state.value}))}}]),t}(f.a.Component),V=r("sEfC"),Q=r.n(V),W=[{text:"!between",hint:"Matches the input that is outside the inclusive range."},{text:"as",hint:"Binds a name to the operator's input tabular expression."},{text:"between",hint:"Matches the input that is inside the inclusive range."},{text:"consume",hint:"The `consume` operator consumes the tabular data stream handed to it. It is\r\nmostly used for triggering the query side-effect without actually returning\r\nthe results back to the caller."},{text:"count",hint:"Returns the number of records in the input record set."},{text:"datatable",hint:"Returns a table whose schema and values are defined in the query itself."},{text:"distinct",hint:"Produces a table with the distinct combination of the provided columns of the input table."},{text:"evaluate",hint:"Invokes a service-side query extension (plugin)."},{text:"extend",hint:"Create calculated columns and append them to the result set."},{text:"externaldata",hint:"Returns a table whose schema is defined in the query itself, and whose data is read from an external raw file."},{text:"facet",hint:"Returns a set of tables, one for each specified column.\r\nEach table specifies the list of values taken by its column.\r\nAn additional table can be created by using the `with` clause."},{text:"find",hint:"Finds rows that match a predicate across a set of tables."},{text:"fork",hint:"Runs multiple consumer operators in parallel."},{text:"getschema",hint:"Produce a table that represents a tabular schema of the input."},{text:"in",hint:"Filters a recordset based on the provided set of values."},{text:"invoke",hint:"Invokes lambda that receives the source of `invoke` as tabular parameter argument."},{text:"join",hint:"Merge the rows of two tables to form a new table by matching values of the specified column(s) from each table."},{text:"limit",hint:"Return up to the specified number of rows."},{text:"make-series",hint:"Create series of specified aggregated values along specified axis."},{text:"mvexpand",hint:"Expands multi-value array or property bag."},{text:"order",hint:"Sort the rows of the input table into order by one or more columns."},{text:"parse",hint:"Evaluates a string expression and parses its value into one or more calculated columns."},{text:"print",hint:"Evaluates one or more scalar expressions and inserts the results (as a single-row table with as many columns as there are expressions) into the output."},{text:"project",hint:"Select the columns to include, rename or drop, and insert new computed columns."},{text:"project-away",hint:"Select what columns to exclude from the input."},{text:"project-rename",hint:"Renames columns in the result output."},{text:"range",hint:"Generates a single-column table of values."},{text:"reduce",hint:"Groups a set of strings together based on values similarity."},{text:"render",hint:"Instructs the user agent to render the results of the query in a particular way."},{text:"sample",hint:"Returns up to the specified number of random rows from the input table."},{text:"sample-distinct",hint:"Returns a single column that contains up to the specified number of distinct values of the requested column."},{text:"search",hint:"The search operator provides a multi-table/multi-column search experience."},{text:"serialize",hint:"Marks that order of the input row set is safe for window functions usage."},{text:"sort",hint:"Sort the rows of the input table into order by one or more columns."},{text:"summarize",hint:"Produces a table that aggregates the content of the input table."},{text:"take",hint:"Return up to the specified number of rows."},{text:"top",hint:"Returns the first *N* records sorted by the specified columns."},{text:"top-hitters",hint:"Returns an approximation of the first *N* results (assuming skewed distribution of the input)."},{text:"top-nested",hint:"Produces hierarchical top results, where each level is a drill-down based on previous level values."},{text:"union",hint:"Takes two or more tables and returns the rows of all of them."},{text:"where",hint:"Filters a table to the subset of rows that satisfy a predicate."}],B=[{text:"abs",hint:"Calculates the absolute value of the input."},{text:"acos",hint:"Returns the angle whose cosine is the specified number (the inverse operation of [`cos()`](cosfunction.md)) ."},{text:"ago",hint:"Subtracts the given timespan from the current UTC clock time."},{text:"any",hint:"Returns random non-empty value from the specified expression values."},{text:"arg_max",hint:"Finds a row in the group that maximizes *ExprToMaximize*, and returns the value of *ExprToReturn* (or `*` to return the entire row)."},{text:"arg_min",hint:"Finds a row in the group that minimizes *ExprToMinimize*, and returns the value of *ExprToReturn* (or `*` to return the entire row)."},{text:"argmax",hint:"Finds a row in the group that maximizes *ExprToMaximize*, and returns the value of *ExprToReturn* (or `*` to return the entire row)."},{text:"argmin",hint:"Finds a row in the group that minimizes *ExprToMinimize*, and returns the value of *ExprToReturn* (or `*` to return the entire row)."},{text:"array_concat",hint:"Concatenates a number of dynamic arrays to a single array."},{text:"array_length",hint:"Calculates the number of elements in a dynamic array."},{text:"array_slice",hint:"Extracts a slice of a dynamic array."},{text:"array_split",hint:"Splits an array to multiple arrays according to the split indices and packs the generated array in a dynamic array."},{text:"asin",hint:"Returns the angle whose sine is the specified number (the inverse operation of [`sin()`](sinfunction.md)) ."},{text:"assert",hint:"Checks for a condition; if the condition is false, outputs error messages and fails the query."},{text:"atan",hint:"Returns the angle whose tangent is the specified number (the inverse operation of [`tan()`](tanfunction.md)) ."},{text:"atan2",hint:"Calculates the angle, in radians, between the positive x-axis and the ray from the origin to the point (y, x)."},{text:"avg",hint:"Calculates the average of *Expr* across the group."},{text:"avgif",hint:"Calculates the [average](avg-aggfunction.md) of *Expr* across the group for which *Predicate* evaluates to `true`."},{text:"bag_keys",hint:"Enumerates all the root keys in a dynamic property-bag object."},{text:"base64_decodestring",hint:"Decodes a base64 string to a UTF-8 string"},{text:"base64_encodestring",hint:"Encodes a string as base64 string"},{text:"beta_cdf",hint:"Returns the standard cumulative beta distribution function."},{text:"beta_inv",hint:"Returns the inverse of the beta cumulative probability beta density function."},{text:"beta_pdf",hint:"Returns the probability density beta function."},{text:"bin",hint:"Rounds values down to an integer multiple of a given bin size."},{text:"bin_at",hint:"Rounds values down to a fixed-size 'bin', with control over the bin's starting point.\r\n(See also [`bin function`](./binfunction.md).)"},{text:"bin_auto",hint:"Rounds values down to a fixed-size 'bin', with control over the bin size and starting point provided by a query property."},{text:"binary_and",hint:"Returns a result of the bitwise `and` operation between two values."},{text:"binary_not",hint:"Returns a bitwise negation of the input value."},{text:"binary_or",hint:"Returns a result of the bitwise `or` operation of the two values."},{text:"binary_shift_left",hint:"Returns binary shift left operation on a pair of numbers."},{text:"binary_shift_right",hint:"Returns binary shift right operation on a pair of numbers."},{text:"binary_xor",hint:"Returns a result of the bitwise `xor` operation of the two values."},{text:"buildschema",hint:"Returns the minimal schema that admits all values of *DynamicExpr*."},{text:"case",hint:"Evaluates a list of predicates and returns the first result expression whose predicate is satisfied."},{text:"ceiling",hint:"Calculates the smallest integer greater than, or equal to, the specified numeric expression."},{text:"cluster",hint:"Changes the reference of the query to a remote cluster."},{text:"coalesce",hint:"Evaluates a list of expressions and returns the first non-null (or non-empty for string) expression."},{text:"cos",hint:"Returns the cosine function."},{text:"cot",hint:"Calculates the trigonometric cotangent of the specified angle, in radians."},{text:"count",hint:"Returns a count of the records per summarization group (or in total if summarization is done without grouping)."},{text:"countif",hint:"Returns a count of rows for which *Predicate* evaluates to `true`."},{text:"countof",hint:"Counts occurrences of a substring in a string. Plain string matches may overlap; regex matches do not."},{text:"current_principal",hint:"Returns the current principal running this query."},{text:"cursor_after",hint:"A predicate over the records of a table to compare their ingestion time\r\nagainst a database cursor."},{text:"cursor_before_or_at",hint:"A predicate over the records of a table to compare their ingestion time\r\nagainst a database cursor."},{text:"database",hint:"Changes the reference of the query to a specific database within the cluster scope."},{text:"datetime_add",hint:"Calculates a new [datetime](./scalar-data-types/datetime.md) from a specified datepart multiplied by a specified amount, added to a specified [datetime](./scalar-data-types/datetime.md)."},{text:"datetime_diff",hint:"Calculates calendarian difference between two [datetime](./scalar-data-types/datetime.md) values."},{text:"datetime_part",hint:"Extracts the requested date part as an integer value."},{text:"dayofmonth",hint:"Returns the integer number representing the day number of the given month"},{text:"dayofweek",hint:"Returns the integer number of days since the preceding Sunday, as a `timespan`."},{text:"dayofyear",hint:"Returns the integer number represents the day number of the given year."},{text:"dcount",hint:"Returns an estimate of the number of distinct values of *Expr* in the group."},{text:"dcount_hll",hint:"Calculates the dcount from hll results (which was generated by [hll](hll-aggfunction.md) or [hll_merge](hll-merge-aggfunction.md))."},{text:"dcountif",hint:"Returns an estimate of the number of distinct values of *Expr* of rows for which *Predicate* evaluates to `true`."},{text:"degrees",hint:"Converts angle value in radians into value in degrees, using formula `degrees = (180 / PI ) * angle_in_radians`"},{text:"distance",hint:"Returns the distance between two points in meters."},{text:"endofday",hint:"Returns the end of the day containing the date, shifted by an offset, if provided."},{text:"endofmonth",hint:"Returns the end of the month containing the date, shifted by an offset, if provided."},{text:"endofweek",hint:"Returns the end of the week containing the date, shifted by an offset, if provided."},{text:"endofyear",hint:"Returns the end of the year containing the date, shifted by an offset, if provided."},{text:"estimate_data_size",hint:"Returns an estimated data size of the selected columns of the tabular expression."},{text:"exp",hint:"The base-e exponential function of x, which is e raised to the power x: e^x."},{text:"exp10",hint:"The base-10 exponential function of x, which is 10 raised to the power x: 10^x. \r\n**Syntax**"},{text:"exp2",hint:"The base-2 exponential function of x, which is 2 raised to the power x: 2^x."},{text:"extent_id",hint:'Returns a unique identifier that identifies the data shard ("extent") that the current record resides in.'},{text:"extent_tags",hint:'Returns a dynamic array with the [tags](../management/extents-overview.md#extent-tagging) of the data shard ("extent") that the current record resides in.'},{text:"extract",hint:"Get a match for a [regular expression](./re2.md) from a text string."},{text:"extract_all",hint:"Get all matches for a [regular expression](./re2.md) from a text string."},{text:"extractjson",hint:"Get a specified element out of a JSON text using a path expression."},{text:"floor",hint:"An alias for [`bin()`](binfunction.md)."},{text:"format_datetime",hint:"Formats a datetime parameter based on the format pattern parameter."},{text:"format_timespan",hint:"Formats a timespan parameter based on the format pattern parameter."},{text:"gamma",hint:"Computes [gamma function](https://en.wikipedia.org/wiki/Gamma_function)"},{text:"getmonth",hint:"Get the month number (1-12) from a datetime."},{text:"gettype",hint:"Returns the runtime type of its single argument."},{text:"getyear",hint:"Returns the year part of the `datetime` argument."},{text:"hash",hint:"Returns a hash value for the input value."},{text:"hash_sha256",hint:"Returns a sha256 hash value for the input value."},{text:"hll",hint:"Calculates the Intermediate results of [dcount](dcount-aggfunction.md) across the group."},{text:"hll_merge",hint:"Merges hll results (scalar version of the aggregate version [`hll_merge()`](hll-merge-aggfunction.md))."},{text:"hourofday",hint:"Returns the integer number representing the hour number of the given date"},{text:"iff",hint:"Evaluates the first argument (the predicate), and returns the value of either the second or third arguments, depending on whether the predicate evaluated to `true` (second) or `false` (third)."},{text:"iif",hint:"Evaluates the first argument (the predicate), and returns the value of either the second or third arguments, depending on whether the predicate evaluated to `true` (second) or `false` (third)."},{text:"indexof",hint:"Function reports the zero-based index of the first occurrence of a specified string within input string."},{text:"ingestion_time",hint:"Retrieves the record's `$IngestionTime` hidden `datetime` column, or null."},{text:"iscolumnexists",hint:"Returns a boolean value indicating if the given string argument exists in the schema produced by the preceding tabular operator."},{text:"isempty",hint:"Returns `true` if the argument is an empty string or is null."},{text:"isfinite",hint:"Returns whether input is a finite value (is neither infinite nor NaN)."},{text:"isinf",hint:"Returns whether input is an infinite (positive or negative) value."},{text:"isnan",hint:"Returns whether input is Not-a-Number (NaN) value."},{text:"isnotempty",hint:"Returns `true` if the argument is not an empty string nor it is a null."},{text:"isnotnull",hint:"Returns `true` if the argument is not null."},{text:"isnull",hint:"Evaluates its sole argument and returns a `bool` value indicating if the argument evaluates to a null value."},{text:"log",hint:"Returns the natural logarithm function."},{text:"log10",hint:"Returns the common (base-10) logarithm function."},{text:"log2",hint:"Returns the base-2 logarithm function."},{text:"loggamma",hint:"Computes log of absolute value of the [gamma function](https://en.wikipedia.org/wiki/Gamma_function)"},{text:"make_datetime",hint:"Creates a [datetime](./scalar-data-types/datetime.md) scalar value from the specified date and time."},{text:"make_dictionary",hint:"Returns a `dynamic` (JSON) property-bag (dictionary) of all the values of *Expr* in the group."},{text:"make_string",hint:"Returns the string generated by the Unicode characters."},{text:"make_timespan",hint:"Creates a [timespan](./scalar-data-types/timespan.md) scalar value from the specified time period."},{text:"makelist",hint:"Returns a `dynamic` (JSON) array of all the values of *Expr* in the group."},{text:"makeset",hint:"Returns a `dynamic` (JSON) array of the set of distinct values that *Expr* takes in the group."},{text:"materialize",hint:"Allows caching a sub-query result during the time of query execution in a way that other subqueries can reference the partial result."},{text:"max",hint:"Returns the maximum value across the group."},{text:"max_of",hint:"Returns the maximum value of several evaluated numeric expressions."},{text:"merge_tdigests",hint:"Merges tdigest results (scalar version of the aggregate version [`merge_tdigests()`](merge-tdigests-aggfunction.md))."},{text:"min",hint:"Returns the minimum value agross the group."},{text:"min_of",hint:"Returns the minimum value of several evaluated numeric expressions."},{text:"monthofyear",hint:"Returns the integer number represents the month number of the given year."},{text:"next",hint:"Returns the value of a column in a row that it at some offset following the\r\ncurrent row in a [serialized row set](./windowsfunctions.md#serialized-row-set)."},{text:"not",hint:"Reverses the value of its `bool` argument."},{text:"now",hint:"Returns the current UTC clock time, optionally offset by a given timespan.\r\nThis function can be used multiple times in a statement and the clock time being referenced will be the same for all instances."},{text:"pack",hint:"Creates a `dynamic` object (property bag) from a list of names and values."},{text:"pack_all",hint:"Creates a `dynamic` object (property bag) from all the columns of the tabular expression."},{text:"pack_array",hint:"Packs all input values into a dynamic array."},{text:"parse_ipv4",hint:"Converts input to integer (signed 64-bit) number representation."},{text:"parse_json",hint:"Interprets a `string` as a [JSON value](https://json.org/)) and returns the value as [`dynamic`](./scalar-data-types/dynamic.md). \r\nIt is superior to using [extractjson() function](./extractjsonfunction.md)\r\nwhen you need to extract more than one element of a JSON compound object."},{text:"parse_path",hint:'Parses a file path `string` and returns a [`dynamic`](./scalar-data-types/dynamic.md) object that contains the following parts of the path: \r\nScheme, RootPath, DirectoryPath, DirectoryName, FileName, Extension, AlternateDataStreamName.\r\nIn addition to the simple paths with both types of slashes, supports paths with schemas (e.g. "file://..."), shared paths (e.g. "\\\\shareddrive\\users..."), long paths (e.g "\\\\?\\C:...""), alternate data streams (e.g. "file1.exe:file2.exe")'},{text:"parse_url",hint:"Parses an absolute URL `string` and returns a [`dynamic`](./scalar-data-types/dynamic.md) object contains all parts of the URL (Scheme, Host, Port, Path, Username, Password, Query Parameters, Fragment)."},{text:"parse_urlquery",hint:"Parses a url query `string` and returns a [`dynamic`](./scalar-data-types/dynamic.md) object contains the Query parameters."},{text:"parse_user_agent",hint:"Interprets a user-agent string, which identifies the user's browser and provides certain system details to servers hosting the websites the user visits. The result is returned as [`dynamic`](./scalar-data-types/dynamic.md)."},{text:"parse_version",hint:"Converts input string representation of version to a comparable decimal number."},{text:"parse_xml",hint:"Interprets a `string` as a XML value, converts the value to a [JSON value](https://json.org/) and returns the value as [`dynamic`](./scalar-data-types/dynamic.md)."},{text:"percentile",hint:"Returns an estimate for the specified [nearest-rank percentile](#nearest-rank-percentile) of the population defined by *Expr*. \r\nThe accuracy depends on the density of population in the region of the percentile."},{text:"percentile_tdigest",hint:"Calculates the percentile result from tdigest results (which was generated by [tdigest](tdigest-aggfunction.md) or [merge-tdigests](merge-tdigests-aggfunction.md))"},{text:"percentrank_tdigest",hint:"Calculates the approximate rank of the value in a set where rank is expressed as percentage of set's size. \r\nThis function can be viewed as the inverse of the percentile."},{text:"pi",hint:"Returns the constant value of Pi (π)."},{text:"point",hint:"Returns a dynamic array representation of a point."},{text:"pow",hint:"Returns a result of raising to power"},{text:"prev",hint:"Returns the value of a column in a row that it at some offset prior to the\r\ncurrent row in a [serialized row set](./windowsfunctions.md#serialized-row-set)."},{text:"radians",hint:"Converts angle value in degrees into value in radians, using formula `radians = (PI / 180 ) * angle_in_degrees`"},{text:"rand",hint:"Returns a random number."},{text:"range",hint:"Generates a dynamic array holding a series of equally-spaced values."},{text:"repeat",hint:"Generates a dynamic array holding a series of equal values."},{text:"replace",hint:"Replace all regex matches with another string."},{text:"reverse",hint:"Function makes reverse of input string."},{text:"round",hint:"Returns the rounded source to the specified precision."},{text:"row_cumsum",hint:"Calculates the cumulative sum of a column in a [serialized row set](./windowsfunctions.md#serialized-row-set)."},{text:"row_number",hint:"Returns the current row's index in a [serialized row set](./windowsfunctions.md#serialized-row-set).\r\nThe row index starts by default at `1` for the first row, and is incremented by `1` for each additional row.\r\nOptionally, the row index can start at a different value than `1`.\r\nAdditionally, the row index may be reset according to some provided predicate."},{text:"series_add",hint:"Calculates the element-wise addition of two numeric series inputs."},{text:"series_decompose",hint:"Applies a decomposition transformation on a series."},{text:"series_decompose_anomalies",hint:"Anomaly Detection based on series decomposition (refer to [series_decompose()](series-decomposefunction.md))"},{text:"series_decompose_forecast",hint:"Forecast based on series decomposition."},{text:"series_divide",hint:"Calculates the element-wise division of two numeric series inputs."},{text:"series_equals",hint:"Calculates the element-wise equals (`==`) logic operation of two numeric series inputs."},{text:"series_fill_backward",hint:"Performs backward fill interpolation of missing values in a series."},{text:"series_fill_const",hint:"Replaces missing values in a series with a specified constant value."},{text:"series_fill_forward",hint:"Performs forward fill interpolation of missing values in a series."},{text:"series_fill_linear",hint:"Performs linear interpolation of missing values in a series."},{text:"series_fir",hint:"Applies a Finite Impulse Response filter on a series."},{text:"series_fit_2lines",hint:"Applies two segments linear regression on a series, returning multiple columns."},{text:"series_fit_2lines_dynamic",hint:"Applies two segments linear regression on a series, returning dynamic object."},{text:"series_fit_line",hint:"Applies linear regression on a series, returning multiple columns."},{text:"series_fit_line_dynamic",hint:"Applies linear regression on a series, returning dynamic object."},{text:"series_greater",hint:"Calculates the element-wise greater (`>`) logic operation of two numeric series inputs."},{text:"series_greater_equals",hint:"Calculates the element-wise greater or equals (`>=`) logic operation of two numeric series inputs."},{text:"series_iir",hint:"Applies a Infinite Impulse Response filter on a series."},{text:"series_less",hint:"Calculates the element-wise less (`<`) logic operation of two numeric series inputs."},{text:"series_less_equals",hint:"Calculates the element-wise less or equal (`<=`) logic operation of two numeric series inputs."},{text:"series_multiply",hint:"Calculates the element-wise multiplication of two numeric series inputs."},{text:"series_not_equals",hint:"Calculates the element-wise not equals (`!=`) logic operation of two numeric series inputs."},{text:"series_outliers",hint:"Scores anomaly points in a series."},{text:"series_periods_detect",hint:"Finds the most significant periods that exist in a time series."},{text:"series_periods_validate",hint:"Checks whether a time series contains periodic patterns of given lengths."},{text:"series_seasonal",hint:"Calculates the seasonal component of a series according to the detected or given seasonal period."},{text:"series_stats",hint:"Returns statistics for a series in multiple columns."},{text:"series_stats_dynamic",hint:"Returns statistics for a series in dynamic object."},{text:"series_subtract",hint:"Calculates the element-wise subtraction of two numeric series inputs."},{text:"sign",hint:"Sign of a numeric expression"},{text:"sin",hint:"Returns the sine function."},{text:"split",hint:"Splits a given string according to a given delimiter and returns a string array with the contained substrings."},{text:"sqrt",hint:"Returns the square root function."},{text:"startofday",hint:"Returns the start of the day containing the date, shifted by an offset, if provided."},{text:"startofmonth",hint:"Returns the start of the month containing the date, shifted by an offset, if provided."},{text:"startofweek",hint:"Returns the start of the week containing the date, shifted by an offset, if provided."},{text:"startofyear",hint:"Returns the start of the year containing the date, shifted by an offset, if provided."},{text:"stdev",hint:"Calculates the standard deviation of *Expr* across the group, considering the group as a [sample](https://en.wikipedia.org/wiki/Sample_%28statistics%29)."},{text:"stdevif",hint:"Calculates the [stdev](stdev-aggfunction.md) of *Expr* across the group for which *Predicate* evaluates to `true`."},{text:"stdevp",hint:"Calculates the standard deviation of *Expr* across the group, considering the group as a [population](https://en.wikipedia.org/wiki/Statistical_population)."},{text:"strcat",hint:"Concatenates between 1 and 64 arguments."},{text:"strcat_array",hint:"Creates a concatenated string of array values using specified delimiter."},{text:"strcat_delim",hint:"Concatenates between 2 and 64 arguments, with delimiter, provided as first argument."},{text:"strcmp",hint:"Compares two strings."},{text:"string_size",hint:"Returns the size, in bytes, of the input string."},{text:"strlen",hint:"Returns the length, in characters, of the input string."},{text:"strrep",hint:"Repeats given [string](./scalar-data-types/string.md) provided amount of times."},{text:"substring",hint:"Extracts a substring from a source string starting from some index to the end of the string."},{text:"sum",hint:"Calculates the sum of *Expr* across the group."},{text:"sumif",hint:"Returns a sum of *Expr* for which *Predicate* evaluates to `true`."},{text:"table",hint:"References specific table using an query-time evaluated string-expression."},{text:"tan",hint:"Returns the tangent function."},{text:"tdigest",hint:"Calculates the Intermediate results of [`percentiles()`](percentiles-aggfunction.md) across the group."},{text:"tdigest_merge",hint:"Merges tdigest results (scalar version of the aggregate version [`tdigest_merge()`](tdigest-merge-aggfunction.md))."},{text:"tobool",hint:"Converts input to boolean (signed 8-bit) representation."},{text:"todatetime",hint:"Converts input to [datetime](./scalar-data-types/datetime.md) scalar."},{text:"todecimal",hint:"Converts input to decimal number representation."},{text:"todouble",hint:"Converts the input to a value of type `real`. (`todouble()` and `toreal()` are synonyms.)"},{text:"todynamic",hint:"Interprets a `string` as a [JSON value](https://json.org/) and returns the value as [`dynamic`](./scalar-data-types/dynamic.md)."},{text:"toguid",hint:"Converts input to [`guid`](./scalar-data-types/guid.md) representation."},{text:"tohex",hint:"Converts input to a hexadecimal string."},{text:"toint",hint:"Converts input to integer (signed 32-bit) number representation."},{text:"tolong",hint:"Converts input to long (signed 64-bit) number representation."},{text:"tolower",hint:"Converts input string to lower case."},{text:"toscalar",hint:"Returns a scalar constant value of the evaluated expression."},{text:"tostring",hint:"Converts input to a string representation."},{text:"totimespan",hint:"Converts input to [timespan](./scalar-data-types/timespan.md) scalar."},{text:"toupper",hint:"Converts a string to upper case."},{text:"translate",hint:"Replaces a set of characters ('searchList') with another set of characters ('replacementList') in a given a string.\r\nThe function searches for characters in the 'searchList' and replaces them with the corresponding characters in 'replacementList'"},{text:"treepath",hint:"Enumerates all the path expressions that identify leaves in a dynamic object."},{text:"trim",hint:"Removes all leading and trailing matches of the specified regular expression."},{text:"trim_end",hint:"Removes trailing match of the specified regular expression."},{text:"trim_start",hint:"Removes leading match of the specified regular expression."},{text:"url_decode",hint:"The function converts encoded URL into a to regular URL representation."},{text:"url_encode",hint:"The function converts characters of the input URL into a format that can be transmitted over the Internet."},{text:"variance",hint:"Calculates the variance of *Expr* across the group, considering the group as a [sample](https://en.wikipedia.org/wiki/Sample_%28statistics%29)."},{text:"varianceif",hint:"Calculates the [variance](variance-aggfunction.md) of *Expr* across the group for which *Predicate* evaluates to `true`."},{text:"variancep",hint:"Calculates the variance of *Expr* across the group, considering the group as a [population](https://en.wikipedia.org/wiki/Statistical_population)."},{text:"weekofyear",hint:"Returns the integer number represents the week number."},{text:"welch_test",hint:"Computes the p_value of the [Welch-test function](https://en.wikipedia.org/wiki/Welch%27s_t-test)"},{text:"zip",hint:"The `zip` function accepts any number of `dynamic` arrays, and returns an\r\narray whose elements are each an array holding the elements of the input\r\narrays of the same index."}],J=["by","on","contains","notcontains","containscs","notcontainscs","startswith","has","matches","regex","true","false","and","or","typeof","int","string","date","datetime","time","long","real","boolean","bool"],K=[{text:"$__timeFilter",display:"$__timeFilter()",hint:"Macro that uses the selected timerange in Grafana to filter the query."},{text:"$__timeTo",display:"$__timeTo()",hint:"Returns the From datetime from the Grafana picker. Example: datetime(2018-06-05T20:09:58.907Z)."},{text:"$__timeFrom",display:"$__timeFrom()",hint:"Returns the From datetime from the Grafana picker. Example: datetime(2018-06-05T18:09:58.907Z)."},{text:"$__escapeMulti",display:"$__escapeMulti()",hint:"Macro to escape multi-value template variables that contain illegal characters."},{text:"$__contains",display:"$__contains()",hint:"Macro for multi-value template variables."}],$={comment:{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0},"function-context":{pattern:/[a-z0-9_]+\([^)]*\)?/i,inside:{}},duration:{pattern:new RegExp("".concat(["SECONDS","MINUTES","HOURS","DAYS","WEEKS","MONTHS","YEARS"].join("?|"),"?"),"i"),alias:"number"},builtin:new RegExp("\\b(?:".concat(B.map((function(e){return e.text})).join("|"),")(?=\\s*\\()"),"i"),string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},keyword:new RegExp("\\b(?:".concat(J.join("|"),"|").concat(W.map((function(e){return e.text})).join("|"),"|\\*)\\b"),"i"),boolean:/\b(?:true|false)\b/,number:/\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/-|\+|\*|\/|>|<|==|<=?|>=?|<>|!~|~|=|\|/,punctuation:/[{};(),.:]/,variable:/(\[\[(.+?)\]\])|(\$(.+?))\b/};$["function-context"].inside={argument:{pattern:/[a-z0-9_]+(?=:)/i,alias:"symbol"},duration:$.duration,number:$.number,builtin:$.builtin,string:$.string,variable:$.variable};var H=$;function Z(e){return(Z="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 Y(e,t,r,n,a,i,o){try{var s=e[i](o),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,a)}function ee(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 te(e,t){return!t||"object"!==Z(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 re(e,t,r){return(re="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=ne(e)););return e}(e,t);if(n){var a=Object.getOwnPropertyDescriptor(n,t);return a.get?a.get.call(r):a.value}})(e,t,r||e)}function ne(e){return(ne=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ae(e,t){return(ae=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var ie=function(e){return e.replace(/[{}[\]="(),!~+\-*/^%]/g,"").trim()},oe=function(e){return{text:e}},se=function(e){function t(e,r){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=te(this,ne(t).call(this,e,r))).onTypeahead=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=window.getSelection();if(t.anchorNode){var r=t.anchorNode.parentElement;if(null===r)return;var a=r.closest(".slate-query-field");if(!a||n.state.value.isBlurred)return;var i=t.getRangeAt(0),o=t.anchorNode.textContent;if(null===o)return;var s=i.startOffset,u=ie(o.substr(0,s)),c=n.state.value.anchorOffset,p=n.state.value.anchorText.text.slice(0,c),f=[],h=r.classList,m=null;if(h.contains("function-context"))m="context-function",f=n.getColumnSuggestions();else if(p.match(/(where\s(\w+\b)?$)/i))m="context-where",f=n.getColumnSuggestions();else if(p.match(/(summarize\s(\w+\b)?$)/i))m="context-summarize",f=n.getFunctionSuggestions();else if(p.match(/(summarize\s(.+\s)?by\s+([^,\s]+,\s*)*([^,\s]+\b)?$)/i))m="context-summarize-by",f=n.getColumnSuggestions();else if(p.match(/(by\s+([^,\s]+,\s*)*([^,\s]+\b)?$)/i))m="context-by",f=n.getColumnSuggestions();else if(p.match(/(on\s(.+\b)?$)/i))m="context-join-on",f=n.getColumnSuggestions();else if(p.match(/(join\s+(\(\s+)?(\w+\b)?$)/i))m="context-join",f=n.getTableSuggestions();else if(p.match(/(distinct\s(.+\b)?$)/i))m="context-distinct",f=n.getColumnSuggestions();else if(p.match(/(database\(\"(\w+)\"\)\.(.+\b)?$)/i)){m="context-database-table";var d=n.getDBFromDatabaseFunction(p);console.log(d),f=n.getTableSuggestions(d),u=u.replace(".","")}else if(ce(l.a.serialize(n.state.value)).match(/^\s*\w*$/i)){if(m="context-new",!n.schema)return n.fetchSchema(),void setTimeout(n.onTypeahead,0);f=n.getInitialSuggestions()}else if(!u||h.contains("argument")||e)!0===e&&(m="context-builtin-forced",p.match(/\s$/i)&&(u=""),f=n.getKeywordSuggestions());else{if(p.match(/\s$/i))return void(u="");u=le(u),m="context-builtin",f=n.getKeywordSuggestions()}var g=0;u=u.toLowerCase();var y=f.map((function(e){return e.items&&u&&!e.skipFilter&&(e.items=e.items.filter((function(e){return e.text.length>=u.length})),e.prefixMatch?e.items=e.items.filter((function(e){return 0===e.text.toLowerCase().indexOf(u)})):e.items=e.items.filter((function(e){return e.text.toLowerCase().indexOf(u)>-1}))),g+=e.items.length,e})).filter((function(e){return e.items.length>0}));n.setState({typeaheadPrefix:u,typeaheadContext:m,typeaheadText:o,suggestions:g>0?y:[]})}},n.applyTypeahead=function(e,t){var r=n.state,a=r.typeaheadPrefix,i=r.typeaheadContext,o=r.typeaheadText,s=t.text||t,u=d.DOMUtil.getNextCharacter();"function"===t.type?u&&"("===u||(s+="("):"context-function"===i?u&&")"===u||(s+=")"):u&&" "===u||(s+=" ");var c=t.deleteBackwards||a.length,l=ie(o).length-a.length,p=o.indexOf(a),f=a&&(l>0&&p>-1||s===o)?l+p:0;return n.resetTypeahead((function(){return e.deleteBackward(c).deleteForward(f).insertText(s).moveForward(0).focus()})),e},n.schema={Databases:{Default:{}}},n.onTypeahead=Q()(n.onTypeahead,100),n}var r,n,a,o,s;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&&ae(e,t)}(t,e),r=t,(n=[{key:"componentDidMount",value:function(){re(ne(t.prototype),"componentDidMount",this).call(this),this.fetchSchema()}},{key:"getInitialSuggestions",value:function(){return this.getTableSuggestions()}},{key:"getKeywordSuggestions",value:function(){return[{prefixMatch:!0,label:"Keywords",items:J.map(oe)},{prefixMatch:!0,label:"Operators",items:W},{prefixMatch:!0,label:"Functions",items:B.map((function(e){return e.type="function",e}))},{prefixMatch:!0,label:"Macros",items:K.map((function(e){return e.type="function",e}))},{prefixMatch:!0,label:"Tables",items:i.a.map(this.schema.Databases.Default.Tables,(function(e){return{text:e.Name}}))}]}},{key:"getFunctionSuggestions",value:function(){return[{prefixMatch:!0,label:"Functions",items:B.map((function(e){return e.type="function",e}))},{prefixMatch:!0,label:"Macros",items:K.map((function(e){return e.type="function",e}))}]}},{key:"getTableSuggestions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Default";return this.schema.Databases[e]?[{prefixMatch:!0,label:"Tables",items:i.a.map(this.schema.Databases[e].Tables,(function(e){return{text:e.Name}}))}]:[]}},{key:"getColumnSuggestions",value:function(){var e=this.getTableFromContext();if(e){var t=this.schema.Databases.Default.Tables[e];if(t)return[{prefixMatch:!0,label:"Fields",items:i.a.map(t.OrderedColumns,(function(e){return{text:e.Name,hint:e.Type}}))}]}return[]}},{key:"getTableFromContext",value:function(){var e=ce(l.a.serialize(this.state.value)),t=/^\s*(\w+)\s*|/g.exec(e);return t&&t.length>1&&t[0]&&t[1]?t[1]:null}},{key:"getDBFromDatabaseFunction",value:function(e){var t=/database\(\"(\w+)\"\)/gi.exec(e);return t&&t.length>1&&t[0]&&t[1]?t[1]:null}},{key:"fetchSchema",value:(o=regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.props.getSchema();case 2:(t=e.sent)?("AppInsights"===t.Type&&(t=ue(t)),this.schema=t):this.schema={Databases:{Default:{}}};case 4:case"end":return e.stop()}}),e,this)})),s=function(){var e=this,t=arguments;return new Promise((function(r,n){var a=o.apply(e,t);function i(e){Y(a,r,n,i,s,"next",e)}function s(e){Y(a,r,n,i,s,"throw",e)}i(void 0)}))},function(){return s.apply(this,arguments)})}])&&ee(r.prototype,n),a&&ee(r,a),t}(U);function ue(e){var t={Databases:{Default:{}}};return t.Databases.Default=e,t}function ce(e){var t=e.replace(/\/\/.*$/gm,"");return t=t.replace("\n"," ")}function le(e){var t=/(?:.*\s)?([^\s]+\s*)$/gi.exec(e);return t&&t.length>1?t[1]:""}var pe=r("txxJ");function fe(e){return(fe="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 he(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 me(e,t){return!t||"object"!==fe(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 de(e){return(de=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ge(e,t){return(ge=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var ye=function(e){function t(e){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(r=me(this,de(t).call(this,e))).onChangeQuery=function(e){var t=r.props,n=t.index,a=t.change,i=r.state.query!==e;r.setState({edited:i,query:e}),a&&a(e,n)},r.onPressEnter=function(){var e=r.props.execute;e&&e()},r.state={edited:!1,query:e.query||""},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&&ge(e,t)}(t,e),r=t,(n=[{key:"render",value:function(){var e=this.props,t=e.variables,r=e.getSchema,n=e.placeholder,a=this.state,i=a.edited,o=a.query;return f.a.createElement("div",{className:"gf-form-input",style:{height:"auto"}},f.a.createElement(se,{initialQuery:i?null:o,onPressEnter:this.onPressEnter,onQueryChange:this.onChangeQuery,prismLanguage:"kusto",prismDefinition:H,placeholder:n,templateVariables:t,getSchema:r}))}}])&&he(r.prototype,n),a&&he(r,a),t}(p.Component);function ve(e){return(ve="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 be(e,t,r,n,a,i,o){try{var s=e[i](o),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,a)}function we(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 xe(e){return(xe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Se(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ke(e,t){return(ke=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}ye.defaultProps={placeholder:"Enter a query"},pe.c.directive("kustoEditor",["reactDirective",function(e){return e(ye,["change","database","execute","query","variables","placeholder",["getSchema",{watchDepth:"reference"}]])}]);var Me=function(e){function t(e,r,a){var o,s,u;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),s=this,u=xe(t).call(this,e,r),(o=!u||"object"!==ve(u)&&"function"!=typeof u?Se(s):u).templateSrv=a,o.defaultDropdownValue="select",o.dummyDiminsionString="+",o.defaults={queryType:"Azure Monitor",azureMonitor:{resourceGroup:o.defaultDropdownValue,metricDefinition:o.defaultDropdownValue,resourceName:o.defaultDropdownValue,metricNamespace:o.defaultDropdownValue,metricName:o.defaultDropdownValue,dimensionFilter:"*",timeGrain:"auto",top:"10",aggOptions:[],timeGrains:[]},azureLogAnalytics:{query:["//change this example to create your own time series query","<table name> //the table to query (e.g. Usage, Heartbeat, Perf)","| where $__timeFilter(TimeGenerated) //this is a macro used to show the full chart’s time range, choose the datetime column here","| summarize count() by <group by column>, bin(TimeGenerated, $__interval) //change “group by column” to a column in your table, such as “Computer”. The $__interval macro is used to auto-select the time grain. Can also use 1h, 5m etc.","| order by TimeGenerated asc"].join("\n"),resultFormat:"time_series",workspace:o.datasource&&o.datasource.azureLogAnalyticsDatasource?o.datasource.azureLogAnalyticsDatasource.defaultOrFirstWorkspace:""},appInsights:{metricName:o.defaultDropdownValue,timeGrain:"auto"},insightsAnalytics:{query:"",resultFormat:"time_series"}},o.getWorkspaces=function(){return o.datasource.azureLogAnalyticsDatasource.getWorkspaces(o.target.subscription).then((function(e){return o.workspaces=e,e.length>0&&!o.target.azureLogAnalytics.workspace&&(o.datasource.azureLogAnalyticsDatasource.defaultOrFirstWorkspace&&(o.target.azureLogAnalytics.workspace=o.datasource.azureLogAnalyticsDatasource.defaultOrFirstWorkspace),o.target.azureLogAnalytics.workspace||(o.target.azureLogAnalytics.workspace=e[0].value)),o.workspaces})).catch(o.handleQueryCtrlError.bind(Se(o)))},o.getAzureLogAnalyticsSchema=function(){return o.getWorkspaces().then((function(){return o.datasource.azureLogAnalyticsDatasource.getSchema(o.target.azureLogAnalytics.workspace)})).catch(o.handleQueryCtrlError.bind(Se(o)))},o.onLogAnalyticsQueryChange=function(e){o.target.azureLogAnalytics.query=e},o.onLogAnalyticsQueryExecute=function(){o.panelCtrl.refresh()},o.onInsightsAnalyticsQueryChange=function(e){o.target.insightsAnalytics.query=e},o.onQueryExecute=function(){return o.refresh()},o.getAppInsightsQuerySchema=function(){return o.datasource.appInsightsDatasource.getQuerySchema().catch(o.handleQueryCtrlError.bind(Se(o)))},o.removeGroupBy=function(e){o.target.appInsights.dimension.splice(e,1),o.refresh()},i.a.defaultsDeep(o.target,o.defaults),o.migrateTimeGrains(),o.migrateToFromTimes(),o.migrateToDefaultNamespace(),o.migrateApplicationInsightsKeys(),o.migrateApplicationInsightsDimensions(),Ae(o.target.azureMonitor),o.panelCtrl.events.on(n.PanelEvents.dataReceived,o.onDataReceived.bind(Se(o)),e),o.panelCtrl.events.on(n.PanelEvents.dataError,o.onDataError.bind(Se(o)),e),o.resultFormats=[{text:"Time series",value:"time_series"},{text:"Table",value:"table"}],o.getSubscriptions(),"Azure Log Analytics"===o.target.queryType&&o.getWorkspaces(),o}var r,a,o,u,l;return t.$inject=["$scope","$injector","templateSrv"],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&&ke(e,t)}(t,e),r=t,(a=[{key:"onDataReceived",value:function(e){this.lastQueryError=void 0,this.lastQuery="";var t=i.a.find(e,{refId:this.target.refId});t&&t.meta&&(this.lastQuery=t.meta.query)}},{key:"onDataError",value:function(e){this.handleQueryCtrlError(e)}},{key:"handleQueryCtrlError",value:function(e){e.query&&e.query.refId&&e.query.refId!==this.target.refId||(e.error&&e.error.data&&e.error.data.error&&e.error.data.error.innererror?e.error.data.error.innererror.innererror?this.lastQueryError=e.error.data.error.innererror.innererror.message:this.lastQueryError=e.error.data.error.innererror.message:e.error&&e.error.data&&e.error.data.error?this.lastQueryError=e.error.data.error.message:e.error&&e.error.data?this.lastQueryError=e.error.data.message:e.data&&e.data.error?this.lastQueryError=e.data.error.message:e.data&&e.data.message?this.lastQueryError=e.data.message:this.lastQueryError=e)}},{key:"migrateTimeGrains",value:function(){this.target.azureMonitor.timeGrainUnit&&("auto"!==this.target.azureMonitor.timeGrain&&(this.target.azureMonitor.timeGrain=c.createISO8601Duration(this.target.azureMonitor.timeGrain,this.target.azureMonitor.timeGrainUnit)),delete this.target.azureMonitor.timeGrainUnit,this.onMetricNameChange()),this.target.appInsights.timeGrainUnit&&"auto"!==this.target.appInsights.timeGrain&&(this.target.appInsights.timeGrainCount?this.target.appInsights.timeGrain=c.createISO8601Duration(this.target.appInsights.timeGrainCount,this.target.appInsights.timeGrainUnit):(this.target.appInsights.timeGrainCount=this.target.appInsights.timeGrain,this.target.appInsights.timeGrain=c.createISO8601Duration(this.target.appInsights.timeGrain,this.target.appInsights.timeGrainUnit)));var e=this.target.azureMonitor.timeGrains;e&&e.length>0&&(!this.target.azureMonitor.allowedTimeGrainsMs||0===this.target.azureMonitor.allowedTimeGrainsMs.length)&&(this.target.azureMonitor.allowedTimeGrainsMs=this.convertTimeGrainsToMs(e)),this.target.appInsights.timeGrains&&this.target.appInsights.timeGrains.length>0&&(!this.target.appInsights.allowedTimeGrainsMs||0===this.target.appInsights.allowedTimeGrainsMs.length)&&(this.target.appInsights.allowedTimeGrainsMs=this.convertTimeGrainsToMs(this.target.appInsights.timeGrains))}},{key:"migrateToFromTimes",value:function(){this.target.azureLogAnalytics.query=this.target.azureLogAnalytics.query.replace(/\$__from\s/gi,"$__timeFrom() "),this.target.azureLogAnalytics.query=this.target.azureLogAnalytics.query.replace(/\$__to\s/gi,"$__timeTo() ")}},{key:"migrateToDefaultNamespace",value:(u=regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.target.azureMonitor.metricNamespace||this.target.azureMonitor.metricNamespace===this.defaultDropdownValue||!this.target.azureMonitor.metricDefinition){e.next=2;break}return e.abrupt("return");case 2:this.target.azureMonitor.metricNamespace=this.target.azureMonitor.metricDefinition;case 3:case"end":return e.stop()}}),e,this)})),l=function(){var e=this,t=arguments;return new Promise((function(r,n){var a=u.apply(e,t);function i(e){be(a,r,n,i,o,"next",e)}function o(e){be(a,r,n,i,o,"throw",e)}i(void 0)}))},function(){return l.apply(this,arguments)})},{key:"migrateApplicationInsightsKeys",value:function(){var e=this.target.appInsights,t={xaxis:"timeColumn",yaxis:"valueColumn",spliton:"segmentColumn",groupBy:"dimension",groupByOptions:"dimensions",filter:"dimensionFilter"};for(var r in t)e[r]&&(e[t[r]]=e[r],delete e[r])}},{key:"migrateApplicationInsightsDimensions",value:function(){var e=this.target.appInsights;e.dimension||(e.dimension=[]),i.a.isString(e.dimension)&&(e.dimension=[e.dimension])}},{key:"replace",value:function(e){return this.templateSrv.replace(e,this.panelCtrl.panel.scopedVars)}},{key:"onQueryTypeChange",value:function(){if("Azure Log Analytics"===this.target.queryType)return this.getWorkspaces()}},{key:"getSubscriptions",value:function(){var e=this;if(this.datasource.azureMonitorDatasource.isConfigured())return this.datasource.azureMonitorDatasource.getSubscriptions().then((function(t){return e.subscriptions=t,e.target.subscription||"Azure Monitor"!==e.target.queryType?e.target.subscription||"Azure Log Analytics"!==e.target.queryType||(e.target.subscription=e.datasource.azureLogAnalyticsDatasource.logAnalyticsSubscriptionId):e.target.subscription=e.datasource.azureMonitorDatasource.subscriptionId,!e.target.subscription&&e.subscriptions.length>0&&(e.target.subscription=e.subscriptions[0].value),e.subscriptions}))}},{key:"onSubscriptionChange",value:function(){if("Azure Log Analytics"===this.target.queryType)return this.getWorkspaces();"Azure Monitor"===this.target.queryType&&(this.target.azureMonitor.resourceGroup=this.defaultDropdownValue,this.target.azureMonitor.metricDefinition=this.defaultDropdownValue,this.target.azureMonitor.resourceName=this.defaultDropdownValue,this.target.azureMonitor.metricName=this.defaultDropdownValue,this.target.azureMonitor.aggregation="",this.target.azureMonitor.timeGrain="",this.target.azureMonitor.dimensionFilters=[])}},{key:"getResourceGroups",value:function(e){if("Azure Monitor"===this.target.queryType&&this.datasource.azureMonitorDatasource.isConfigured())return this.datasource.getResourceGroups(this.replace(this.target.subscription||this.datasource.azureMonitorDatasource.subscriptionId)).catch(this.handleQueryCtrlError.bind(this))}},{key:"getMetricDefinitions",value:function(e){if("Azure Monitor"===this.target.queryType&&this.target.azureMonitor.resourceGroup&&this.target.azureMonitor.resourceGroup!==this.defaultDropdownValue)return this.datasource.getMetricDefinitions(this.replace(this.target.subscription||this.datasource.azureMonitorDatasource.subscriptionId),this.replace(this.target.azureMonitor.resourceGroup)).catch(this.handleQueryCtrlError.bind(this))}},{key:"getResourceNames",value:function(e){if("Azure Monitor"===this.target.queryType&&this.target.azureMonitor.resourceGroup&&this.target.azureMonitor.resourceGroup!==this.defaultDropdownValue&&this.target.azureMonitor.metricDefinition&&this.target.azureMonitor.metricDefinition!==this.defaultDropdownValue)return this.datasource.getResourceNames(this.replace(this.target.subscription||this.datasource.azureMonitorDatasource.subscriptionId),this.replace(this.target.azureMonitor.resourceGroup),this.replace(this.target.azureMonitor.metricDefinition)).catch(this.handleQueryCtrlError.bind(this))}},{key:"getMetricNamespaces",value:function(){if("Azure Monitor"===this.target.queryType&&this.target.azureMonitor.resourceGroup&&this.target.azureMonitor.resourceGroup!==this.defaultDropdownValue&&this.target.azureMonitor.metricDefinition&&this.target.azureMonitor.metricDefinition!==this.defaultDropdownValue&&this.target.azureMonitor.resourceName&&this.target.azureMonitor.resourceName!==this.defaultDropdownValue)return this.datasource.getMetricNamespaces(this.replace(this.target.subscription||this.datasource.azureMonitorDatasource.subscriptionId),this.replace(this.target.azureMonitor.resourceGroup),this.replace(this.target.azureMonitor.metricDefinition),this.replace(this.target.azureMonitor.resourceName)).catch(this.handleQueryCtrlError.bind(this))}},{key:"getMetricNames",value:function(){if("Azure Monitor"===this.target.queryType&&this.target.azureMonitor.resourceGroup&&this.target.azureMonitor.resourceGroup!==this.defaultDropdownValue&&this.target.azureMonitor.metricDefinition&&this.target.azureMonitor.metricDefinition!==this.defaultDropdownValue&&this.target.azureMonitor.resourceName&&this.target.azureMonitor.resourceName!==this.defaultDropdownValue&&this.target.azureMonitor.metricNamespace&&this.target.azureMonitor.metricNamespace!==this.defaultDropdownValue)return this.datasource.getMetricNames(this.replace(this.target.subscription||this.datasource.azureMonitorDatasource.subscriptionId),this.replace(this.target.azureMonitor.resourceGroup),this.replace(this.target.azureMonitor.metricDefinition),this.replace(this.target.azureMonitor.resourceName),this.replace(this.target.azureMonitor.metricNamespace)).catch(this.handleQueryCtrlError.bind(this))}},{key:"onResourceGroupChange",value:function(){this.target.azureMonitor.metricDefinition=this.defaultDropdownValue,this.target.azureMonitor.resourceName=this.defaultDropdownValue,this.target.azureMonitor.metricNamespace=this.defaultDropdownValue,this.target.azureMonitor.metricName=this.defaultDropdownValue,this.target.azureMonitor.aggregation="",this.target.azureMonitor.timeGrain="",this.target.azureMonitor.dimensionFilters=[],this.refresh()}},{key:"onMetricDefinitionChange",value:function(){this.target.azureMonitor.resourceName=this.defaultDropdownValue,this.target.azureMonitor.metricNamespace=this.defaultDropdownValue,this.target.azureMonitor.metricName=this.defaultDropdownValue,this.target.azureMonitor.aggregation="",this.target.azureMonitor.timeGrain="",this.target.azureMonitor.dimensionFilters=[]}},{key:"onResourceNameChange",value:function(){this.target.azureMonitor.metricNamespace=this.defaultDropdownValue,this.target.azureMonitor.metricName=this.defaultDropdownValue,this.target.azureMonitor.aggregation="",this.target.azureMonitor.timeGrain="",this.target.azureMonitor.dimensionFilters=[],this.refresh()}},{key:"onMetricNamespacesChange",value:function(){this.target.azureMonitor.metricName=this.defaultDropdownValue,this.target.azureMonitor.dimensionFilters=[]}},{key:"onMetricNameChange",value:function(){var e=this;return this.target.azureMonitor.metricName&&this.target.azureMonitor.metricName!==this.defaultDropdownValue?this.datasource.getMetricMetadata(this.replace(this.target.subscription),this.replace(this.target.azureMonitor.resourceGroup),this.replace(this.target.azureMonitor.metricDefinition),this.replace(this.target.azureMonitor.resourceName),this.replace(this.target.azureMonitor.metricNamespace),this.replace(this.target.azureMonitor.metricName)).then((function(t){console.log("Update metadata",t),e.target.azureMonitor.aggregation=t.primaryAggType,e.target.azureMonitor.timeGrain="auto",e.target.azureMonitor.allowedTimeGrainsMs=e.convertTimeGrainsToMs(t.supportedTimeGrains||[]);var r=e.target.azureMonitor;return r.aggOptions=t.supportedAggTypes||[t.primaryAggType],r.timeGrains=[{text:"auto",value:"auto"}].concat(t.supportedTimeGrains),r.dimensions=t.dimensions,t.dimensions.length,e.refresh()})).catch(this.handleQueryCtrlError.bind(this)):Promise.resolve()}},{key:"convertTimeGrainsToMs",value:function(e){var t=[];return e.forEach((function(e){"auto"!==e.value&&t.push(s.a.interval_to_ms(c.createKbnUnitFromISO8601Duration(e.value)))})),t}},{key:"generateAutoUnits",value:function(e,t){return"auto"===e?c.findClosestTimeGrain(this.templateSrv.getBuiltInIntervalValue(),i.a.map(t,(function(e){return c.createKbnUnitFromISO8601Duration(e.value)}))||["1m","5m","15m","30m","1h","6h","12h","1d"]):""}},{key:"getAzureMonitorAutoInterval",value:function(){return this.generateAutoUnits(this.target.azureMonitor.timeGrain,this.target.azureMonitor.timeGrains)}},{key:"getApplicationInsightAutoInterval",value:function(){return this.generateAutoUnits(this.target.appInsights.timeGrain,this.target.appInsights.timeGrains)}},{key:"azureMonitorAddDimensionFilter",value:function(){console.log("Add dimension",this.target.azureMonitor),this.target.azureMonitor.dimensionFilters.push({dimension:"",operator:"eq",filter:""})}},{key:"azureMonitorRemoveDimensionFilter",value:function(e){this.target.azureMonitor.dimensionFilters.splice(e,1),this.refresh(),console.log("Remove dimension",e,this.target.azureMonitor)}},{key:"getAppInsightsAutoInterval",value:function(){var e=this.templateSrv.getBuiltInIntervalValue();return"s"===e[e.length-1]?"1m":e}},{key:"getAppInsightsMetricNames",value:function(){if(this.datasource.appInsightsDatasource.isConfigured())return this.datasource.getAppInsightsMetricNames().catch(this.handleQueryCtrlError.bind(this))}},{key:"getAppInsightsColumns",value:function(){return this.datasource.getAppInsightsColumns(this.target.refId)}},{key:"onAppInsightsColumnChange",value:function(){return this.refresh()}},{key:"onAppInsightsMetricNameChange",value:function(){var e=this;if(this.target.appInsights.metricName&&this.target.appInsights.metricName!==this.defaultDropdownValue)return this.datasource.getAppInsightsMetricMetadata(this.replace(this.target.appInsights.metricName)).then((function(t){return e.target.appInsights.aggOptions=t.supportedAggTypes,e.target.appInsights.dimensions=t.supportedGroupBy,e.target.appInsights.aggregation=t.primaryAggType,e.refresh()})).catch(this.handleQueryCtrlError.bind(this))}},{key:"getAppInsightsGroupBySegments",value:function(e){var t=this.target.appInsights;return this.dummyDiminsionString&&this.dummyDiminsionString.length&&"+"!==this.dummyDiminsionString&&(t.dimension||(t.dimension=[]),t.dimension.push(this.dummyDiminsionString),this.dummyDiminsionString="+",this.refresh()),i.a.map(t.dimensions,(function(e){return{text:e,value:e}}))}},{key:"resetAppInsightsGroupBy",value:function(){this.target.appInsights.dimension="none",this.refresh()}},{key:"updateTimeGrainType",value:function(){"specific"===this.target.appInsights.timeGrainType?(this.target.appInsights.timeGrainCount="1",this.target.appInsights.timeGrainUnit="minute",this.target.appInsights.timeGrain=c.createISO8601Duration(this.target.appInsights.timeGrainCount,this.target.appInsights.timeGrainUnit)):(this.target.appInsights.timeGrainCount="",this.target.appInsights.timeGrainUnit="")}},{key:"updateAppInsightsTimeGrain",value:function(){this.target.appInsights.timeGrainUnit&&this.target.appInsights.timeGrainCount&&(this.target.appInsights.timeGrain=c.createISO8601Duration(this.target.appInsights.timeGrainCount,this.target.appInsights.timeGrainUnit)),this.refresh()}},{key:"templateVariables",get:function(){return this.templateSrv.getVariables().map((function(e){return"$"+e.name}))}}])&&we(r.prototype,a),o&&we(r,o),t}(o.QueryCtrl);function Ae(e){e.dimensionFilters||(e.dimensionFilters=[]);var t=e.dimension;t&&"None"!==t&&(e.dimensionFilters.push({dimension:t,operator:"eq",filter:e.dimensionFilter}),delete e.dimension,delete e.dimensionFilter)}function Ce(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)}}Me.templateUrl="partials/query.editor.html";var De=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r,n;return t=e,n=[{key:"buildAzureMonitorGetMetricNamespacesUrl",value:function(e,t,r,n,a,i){if((n.match(/\//g)||[]).length>1){var o=a.split("/"),s=n.substring(n.lastIndexOf("/")+1),u=n.substring(0,n.lastIndexOf("/"));return"".concat(e,"/").concat(t,"/resourceGroups/").concat(r,"/providers/").concat(u,"/").concat(o[0],"/").concat(s,"/").concat(o[1])+"/providers/microsoft.insights/metricNamespaces?api-version=".concat(i)}return"".concat(e,"/").concat(t,"/resourceGroups/").concat(r,"/providers/").concat(n,"/").concat(a)+"/providers/microsoft.insights/metricNamespaces?api-version=".concat(i)}},{key:"buildAzureMonitorGetMetricNamesUrl",value:function(e,t,r,n,a,i,o){if((n.match(/\//g)||[]).length>1){var s=a.split("/"),u=n.substring(n.lastIndexOf("/")+1),c=n.substring(0,n.lastIndexOf("/"));return"".concat(e,"/").concat(t,"/resourceGroups/").concat(r,"/providers/").concat(c,"/").concat(s[0],"/").concat(u,"/").concat(s[1])+"/providers/microsoft.insights/metricdefinitions?api-version=".concat(o,"&metricnamespace=").concat(encodeURIComponent(i))}return"".concat(e,"/").concat(t,"/resourceGroups/").concat(r,"/providers/").concat(n,"/").concat(a)+"/providers/microsoft.insights/metricdefinitions?api-version=".concat(o,"&metricnamespace=").concat(encodeURIComponent(i))}}],(r=null)&&Ce(t.prototype,r),n&&Ce(t,n),e}();function Ie(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 Oe=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r,n;return t=e,n=[{key:"parseResponseValues",value:function(e,t,r){var n=[];if(!e)return n;for(var a=0;a<e.data.value.length;a++)if(!i.a.find(n,["value",i.a.get(e.data.value[a],r)])){var o=i.a.get(e.data.value[a],r),s=i.a.get(e.data.value[a],t,o);n.push({text:s,value:o})}return n}},{key:"parseResourceNames",value:function(e,t){var r=[];if(!e)return r;for(var n=0;n<e.data.value.length;n++)e.data.value[n].type===t&&r.push({text:e.data.value[n].name,value:e.data.value[n].name});return r}},{key:"parseMetadata",value:function(t,r){var n=["None","Average","Minimum","Maximum","Total","Count"];if(!t)return{primaryAggType:"",supportedAggTypes:n,supportedTimeGrains:[],dimensions:[]};var a=i.a.find(t.data.value,(function(e){return i.a.get(e,"name.value")===r}));return{primaryAggType:a.primaryAggregationType,supportedAggTypes:a.supportedAggregationTypes||n,supportedTimeGrains:e.parseTimeGrains(a.metricAvailabilities||[]),dimensions:e.parseDimensions(a)}}},{key:"parseTimeGrains",value:function(e){var t=[];return e?(e.forEach((function(e){e.timeGrain&&t.push({text:c.createTimeGrainFromISO8601Duration(e.timeGrain),value:e.timeGrain})})),t):t}},{key:"parseDimensions",value:function(e){var t=[];if(!e.dimensions||0===e.dimensions.length)return t;for(var r=0;r<e.dimensions.length;r++){var n=e.dimensions[r].localizedValue,a=e.dimensions[r].value;t.push({text:n||a,value:a})}return t}},{key:"parseSubscriptions",value:function(e){var t=[];if(!e)return t;for(var r=0;r<e.data.value.length;r++)i.a.find(t,["value",i.a.get(e.data.value[r],"subscriptionId")])||t.push({text:"".concat(i.a.get(e.data.value[r],"displayName")," - ").concat(i.a.get(e.data.value[r],"subscriptionId")),value:i.a.get(e.data.value[r],"subscriptionId")});return t}},{key:"parseSubscriptionsForSelect",value:function(e){var t=[];if(!e)return t;for(var r=0;r<e.data.value.length;r++)i.a.find(t,["value",i.a.get(e.data.value[r],"subscriptionId")])||t.push({label:"".concat(i.a.get(e.data.value[r],"displayName")," - ").concat(i.a.get(e.data.value[r],"subscriptionId")),value:i.a.get(e.data.value[r],"subscriptionId")});return t}},{key:"parseWorkspacesForSelect",value:function(e){var t=[];if(!e)return t;for(var r=0;r<e.data.value.length;r++)i.a.find(t,["value",i.a.get(e.data.value[r].properties,"customerId")])||t.push({label:i.a.get(e.data.value[r],"name"),value:i.a.get(e.data.value[r].properties,"customerId")});return t}}],(r=null)&&Ie(t.prototype,r),n&&Ie(t,n),e}();function Te(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 ze,Ne=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.cloudName=t,this.supportedMetricNamespaces={azuremonitor:["Microsoft.AnalysisServices/servers","Microsoft.ApiManagement/service","Microsoft.Automation/automationAccounts","Microsoft.Batch/batchAccounts","Microsoft.Cache/redis","Microsoft.ClassicCompute/virtualMachines","Microsoft.ClassicCompute/domainNames/slots/roles","Microsoft.CognitiveServices/accounts","Microsoft.Compute/virtualMachines","Microsoft.Compute/virtualMachineScaleSets","Microsoft.ContainerInstance/containerGroups","Microsoft.ContainerRegistry/registries","Microsoft.ContainerService/managedClusters","Microsoft.CustomerInsights/hubs","Microsoft.DataBoxEdge/dataBoxEdgeDevices","Microsoft.DataFactory/datafactories","Microsoft.DataFactory/factories","Microsoft.DataLakeAnalytics/accounts","Microsoft.DataLakeStore/accounts","Microsoft.DBforMariaDB/servers","Microsoft.DBforMySQL/servers","Microsoft.DBforPostgreSQL/servers","Microsoft.Devices/IotHubs","Microsoft.Devices/provisioningServices","Microsoft.DocumentDB/databaseAccounts","Microsoft.EventGrid/topics","Microsoft.EventGrid/eventSubscriptions","Microsoft.EventGrid/extensionTopics","Microsoft.EventHub/namespaces","Microsoft.EventHub/clusters","Microsoft.HDInsight/clusters","Microsoft.Insights/AutoscaleSettings","Microsoft.Insights/components","Microsoft.KeyVault/vaults","Microsoft.Kusto/clusters","Microsoft.LocationBasedServices/accounts","Microsoft.Logic/workflows","Microsoft.Logic/integrationServiceEnvironments","Microsoft.NetApp/netAppAccounts/capacityPools","Microsoft.NetApp/netAppAccounts/capacityPools/Volumes","Microsoft.Network/networkInterfaces","Microsoft.Network/loadBalancers","Microsoft.Network/dnsZones","Microsoft.Network/publicIPAddresses","Microsoft.Network/azureFirewalls","Microsoft.Network/applicationGateways","Microsoft.Network/virtualNetworkGateways","Microsoft.Network/expressRouteCircuits","Microsoft.Network/expressRouteCircuits/Peerings","Microsoft.Network/connections","Microsoft.Network/trafficManagerProfiles","Microsoft.Network/networkWatchers/connectionMonitors","Microsoft.Network/frontdoors","Microsoft.NotificationHubs/namespaces/notificationHubs","Microsoft.OperationalInsights/workspaces","Microsoft.PowerBIDedicated/capacities","Microsoft.Relay/namespaces","Microsoft.Search/searchServices","Microsoft.ServiceBus/namespaces","Microsoft.Sql/servers/databases","Microsoft.Sql/servers/elasticPools","Microsoft.Sql/managedInstances","Microsoft.Storage/storageAccounts","Microsoft.Storage/storageAccounts/blobServices","Microsoft.Storage/storageAccounts/fileServices","Microsoft.Storage/storageAccounts/queueServices","Microsoft.Storage/storageAccounts/tableServices","Microsoft.StorageSync/storageSyncServices","Microsoft.StorageSync/storageSyncServices/syncGroups","Microsoft.StorageSync/storageSyncServices/syncGroups/serverEndpoints","Microsoft.StorageSync/storageSyncServices/registeredServers","Microsoft.StreamAnalytics/streamingJobs","Microsoft.Web/serverfarms","Microsoft.Web/sites","Microsoft.Web/sites/slots","Microsoft.Web/hostingEnvironments/multiRolePools","Microsoft.Web/hostingEnvironments/workerPools"],govazuremonitor:["Microsoft.AnalysisServices/servers","Microsoft.ApiManagement/service","Microsoft.Batch/batchAccounts","Microsoft.Cache/redis","Microsoft.ClassicCompute/virtualMachines","Microsoft.ClassicCompute/domainNames/slots/roles","Microsoft.CognitiveServices/accounts","Microsoft.Compute/virtualMachines","Microsoft.Compute/virtualMachineScaleSets","Microsoft.ContainerRegistry/registries","Microsoft.DBforMySQL/servers","Microsoft.DBforPostgreSQL/servers","Microsoft.Devices/IotHubs","Microsoft.Devices/provisioningServices","Microsoft.EventGrid/topics","Microsoft.EventGrid/eventSubscriptions","Microsoft.EventGrid/extensionTopics","Microsoft.EventHub/namespaces","Microsoft.EventHub/clusters","Microsoft.Insights/AutoscaleSettings","Microsoft.KeyVault/vaults","Microsoft.Logic/workflows","Microsoft.Network/networkInterfaces","Microsoft.Network/loadBalancers","Microsoft.Network/dnsZones","Microsoft.Network/publicIPAddresses","Microsoft.Network/azureFirewalls","Microsoft.Network/applicationGateways","Microsoft.Network/virtualNetworkGateways","Microsoft.Network/expressRouteCircuits","Microsoft.Network/expressRouteCircuits/Peerings","Microsoft.Network/connections","Microsoft.Network/trafficManagerProfiles","Microsoft.Network/networkWatchers/connectionMonitors","Microsoft.Network/frontdoors","Microsoft.NotificationHubs/namespaces/notificationHubs","Microsoft.OperationalInsights/workspaces","Microsoft.PowerBIDedicated/capacities","Microsoft.Relay/namespaces","Microsoft.ServiceBus/namespaces","Microsoft.Sql/servers/databases","Microsoft.Sql/servers/elasticPools","Microsoft.Sql/managedInstances","Microsoft.Storage/storageAccounts","Microsoft.Storage/storageAccounts/blobServices","Microsoft.Storage/storageAccounts/fileServices","Microsoft.Storage/storageAccounts/queueServices","Microsoft.Storage/storageAccounts/tableServices","Microsoft.Web/serverfarms","Microsoft.Web/sites","Microsoft.Web/sites/slots","Microsoft.Web/hostingEnvironments/multiRolePools","Microsoft.Web/hostingEnvironments/workerPools"],germanyazuremonitor:["Microsoft.AnalysisServices/servers","Microsoft.Batch/batchAccounts","Microsoft.Cache/redis","Microsoft.ClassicCompute/virtualMachines","Microsoft.ClassicCompute/domainNames/slots/roles","Microsoft.Compute/virtualMachines","Microsoft.Compute/virtualMachineScaleSets","Microsoft.DBforMySQL/servers","Microsoft.DBforPostgreSQL/servers","Microsoft.Devices/IotHubs","Microsoft.Devices/provisioningServices","Microsoft.EventHub/namespaces","Microsoft.EventHub/clusters","Microsoft.Insights/AutoscaleSettings","Microsoft.KeyVault/vaults","Microsoft.Network/networkInterfaces","Microsoft.Network/loadBalancers","Microsoft.Network/dnsZones","Microsoft.Network/publicIPAddresses","Microsoft.Network/azureFirewalls","Microsoft.Network/applicationGateways","Microsoft.Network/virtualNetworkGateways","Microsoft.Network/expressRouteCircuits","Microsoft.Network/expressRouteCircuits/Peerings","Microsoft.Network/connections","Microsoft.Network/trafficManagerProfiles","Microsoft.Network/networkWatchers/connectionMonitors","Microsoft.Network/frontdoors","Microsoft.NotificationHubs/namespaces/notificationHubs","Microsoft.OperationalInsights/workspaces","Microsoft.PowerBIDedicated/capacities","Microsoft.Relay/namespaces","Microsoft.ServiceBus/namespaces","Microsoft.Sql/servers/databases","Microsoft.Sql/servers/elasticPools","Microsoft.Sql/managedInstances","Microsoft.Storage/storageAccounts","Microsoft.Storage/storageAccounts/blobServices","Microsoft.Storage/storageAccounts/fileServices","Microsoft.Storage/storageAccounts/queueServices","Microsoft.Storage/storageAccounts/tableServices","Microsoft.StreamAnalytics/streamingJobs","Microsoft.Web/serverfarms","Microsoft.Web/sites","Microsoft.Web/sites/slots","Microsoft.Web/hostingEnvironments/multiRolePools","Microsoft.Web/hostingEnvironments/workerPools"],chinaazuremonitor:["Microsoft.AnalysisServices/servers","Microsoft.Batch/batchAccounts","Microsoft.Cache/redis","Microsoft.ClassicCompute/virtualMachines","Microsoft.ClassicCompute/domainNames/slots/roles","Microsoft.CognitiveServices/accounts","Microsoft.Compute/virtualMachines","Microsoft.Compute/virtualMachineScaleSets","Microsoft.ContainerRegistry/registries","Microsoft.DBforMySQL/servers","Microsoft.DBforPostgreSQL/servers","Microsoft.Devices/IotHubs","Microsoft.Devices/provisioningServices","Microsoft.EventHub/namespaces","Microsoft.Insights/AutoscaleSettings","Microsoft.KeyVault/vaults","Microsoft.Logic/workflows","Microsoft.Network/networkInterfaces","Microsoft.Network/loadBalancers","Microsoft.Network/dnsZones","Microsoft.Network/publicIPAddresses","Microsoft.Network/azureFirewalls","Microsoft.Network/applicationGateways","Microsoft.Network/virtualNetworkGateways","Microsoft.Network/expressRouteCircuits","Microsoft.Network/expressRouteCircuits/Peerings","Microsoft.Network/connections","Microsoft.Network/trafficManagerProfiles","Microsoft.Network/networkWatchers/connectionMonitors","Microsoft.Network/frontdoors","Microsoft.NotificationHubs/namespaces/notificationHubs","Microsoft.PowerBIDedicated/capacities","Microsoft.Relay/namespaces","Microsoft.ServiceBus/namespaces","Microsoft.Sql/servers/databases","Microsoft.Sql/servers/elasticPools","Microsoft.Sql/managedInstances","Microsoft.Storage/storageAccounts","Microsoft.Storage/storageAccounts/blobServices","Microsoft.Storage/storageAccounts/fileServices","Microsoft.Storage/storageAccounts/queueServices","Microsoft.Storage/storageAccounts/tableServices","Microsoft.StreamAnalytics/streamingJobs","Microsoft.Web/serverfarms","Microsoft.Web/sites","Microsoft.Web/sites/slots","Microsoft.Web/hostingEnvironments/multiRolePools","Microsoft.Web/hostingEnvironments/workerPools"]}}var t,r,n;return t=e,(r=[{key:"get",value:function(){return this.supportedMetricNamespaces[this.cloudName]}}])&&Te(t.prototype,r),n&&Te(t,n),e}();!function(e){e.AzureMonitor="Azure Monitor",e.ApplicationInsights="Application Insights",e.InsightsAnalytics="Insights Analytics",e.LogAnalytics="Azure Log Analytics"}(ze||(ze={}));var Re=r("t8hP");function _e(e){return(_e="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 Ee(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 je(e,t){return!t||"object"!==_e(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 Pe(e){return(Pe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ge(e,t){return(Ge=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Fe=function(e){function t(e){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(r=je(this,Pe(t).call(this,e))).instanceSettings=e,r.apiVersion="2018-01-01",r.apiPreviewVersion="2017-12-01-preview",r.supportedMetricNamespaces=[],r.subscriptionId=e.jsonData.subscriptionId,r.cloudName=e.jsonData.cloudName||"azuremonitor",r.baseUrl="/".concat(r.cloudName,"/subscriptions"),r.url=e.url,r.supportedMetricNamespaces=new Ne(r.cloudName).get(),r}var r,n,i;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&&Ge(e,t)}(t,e),r=t,(n=[{key:"isConfigured",value:function(){return!!this.subscriptionId&&this.subscriptionId.length>0}},{key:"filterQuery",value:function(e){return!0!==e.hide&&e.azureMonitor.resourceGroup&&"select"!==e.azureMonitor.resourceGroup&&e.azureMonitor.resourceName&&"select"!==e.azureMonitor.resourceName&&e.azureMonitor.metricDefinition&&"select"!==e.azureMonitor.metricDefinition&&e.azureMonitor.metricName&&"select"!==e.azureMonitor.metricName}},{key:"applyTemplateVariables",value:function(e,t){var r=e.azureMonitor;r.timeGrainUnit&&"auto"!==r.timeGrain&&(r.timeGrain=c.createISO8601Duration(r.timeGrain,r.timeGrainUnit));var n=Object(Re.getTemplateSrv)(),a=n.replace(e.subscription||this.subscriptionId,t),i=n.replace(r.resourceGroup,t),o=n.replace(r.resourceName,t),s=n.replace(r.metricNamespace,t),u=n.replace(r.metricDefinition,t),l=n.replace((r.timeGrain||"").toString(),t),p=n.replace(r.aggregation,t),f=n.replace(r.top||"",t),h=r.dimensionFilters.filter((function(e){return e.dimension&&"None"!==e.dimension})).map((function(e){var r=n.replace(e.filter,t);return{dimension:n.replace(e.dimension,t),operator:e.operator||"eq",filter:r||"*"}}));return{refId:e.refId,subscription:a,queryType:ze.AzureMonitor,azureMonitor:{resourceGroup:i,resourceName:o,metricDefinition:u,timeGrain:l,allowedTimeGrainsMs:r.allowedTimeGrainsMs,metricName:n.replace(r.metricName,t),metricNamespace:s&&"select"!==s?s:u,aggregation:p,dimensionsFilters:h,top:f||"10",alias:r.alias,format:e.format}}}},{key:"metricFindQuery",value:function(e){if(e.match(/^Subscriptions\(\)/i))return this.getSubscriptions();if(e.match(/^ResourceGroups\(\)/i))return this.getResourceGroups(this.subscriptionId);var t=e.match(/^ResourceGroups\(([^\)]+?)(,\s?([^,]+?))?\)/i);if(t)return this.getResourceGroups(this.toVariable(t[1]));var r=e.match(/^Namespaces\(([^\)]+?)(,\s?([^,]+?))?\)/i);if(r&&!r[3])return this.getMetricDefinitions(this.subscriptionId,this.toVariable(r[1]));var n=e.match(/^Namespaces\(([^,]+?),\s?([^,]+?)\)/i);if(n)return this.getMetricDefinitions(this.toVariable(n[1]),this.toVariable(n[2]));var a=e.match(/^ResourceNames\(([^,]+?),\s?([^,]+?)\)/i);if(a){var i=this.toVariable(a[1]),o=this.toVariable(a[2]);return this.getResourceNames(this.subscriptionId,i,o)}var s=e.match(/^ResourceNames\(([^,]+?),\s?([^,]+?),\s?(.+?)\)/i);if(s){var u=this.toVariable(s[1]),c=this.toVariable(s[2]),l=this.toVariable(s[3]);return this.getResourceNames(u,c,l)}var p=e.match(/^MetricNamespace\(([^,]+?),\s?([^,]+?),\s?([^,]+?)\)/i);if(p){var f=this.toVariable(p[1]),h=this.toVariable(p[2]),m=this.toVariable(p[3]);return this.getMetricNamespaces(this.subscriptionId,f,h,m)}var d=e.match(/^metricnamespace\(([^,]+?),\s?([^,]+?),\s?([^,]+?),\s?([^,]+?)\)/i);if(d){var g=this.toVariable(d[1]),y=this.toVariable(d[2]),v=this.toVariable(d[3]),b=this.toVariable(d[4]);return this.getMetricNamespaces(g,y,v,b)}var w=e.match(/^MetricNames\(([^,]+?),\s?([^,]+?),\s?([^,]+?),\s?([^,]+?)\)/i);if(w&&-1===w[3].indexOf(",")){var x=this.toVariable(w[1]),S=this.toVariable(w[2]),k=this.toVariable(w[3]),M=this.toVariable(w[4]);return this.getMetricNames(this.subscriptionId,x,S,k,M)}var A=e.match(/^MetricNames\(([^,]+?),\s?([^,]+?),\s?([^,]+?),\s?([^,]+?),\s?(.+?)\)/i);if(A){var C=this.toVariable(A[1]),D=this.toVariable(A[2]),I=this.toVariable(A[3]),O=this.toVariable(A[4]),T=this.toVariable(A[5]);return this.getMetricNames(C,D,I,O,T)}}},{key:"toVariable",value:function(e){return Object(Re.getTemplateSrv)().replace((e||"").trim())}},{key:"getSubscriptions",value:function(e){var t="/".concat(e||this.cloudName,"/subscriptions?api-version=2019-03-01");return this.doRequest(t).then((function(e){return Oe.parseSubscriptions(e)}))}},{key:"getResourceGroups",value:function(e){var t="".concat(this.baseUrl,"/").concat(e,"/resourceGroups?api-version=").concat(this.apiVersion);return this.doRequest(t).then((function(e){return Oe.parseResponseValues(e,"name","name")}))}},{key:"getMetricDefinitions",value:function(e,t){var r=this,n="".concat(this.baseUrl,"/").concat(e,"/resourceGroups/").concat(t,"/resources?api-version=").concat(this.apiVersion);return this.doRequest(n).then((function(e){return Oe.parseResponseValues(e,"type","type")})).then((function(e){return Object(a.filter)(e,(function(e){for(var t=0;t<r.supportedMetricNamespaces.length;t++)if(e.value.toLowerCase()===r.supportedMetricNamespaces[t].toLowerCase())return!0;return!1}))})).then((function(e){for(var t=!1,r=0;r<e.length;r++)if("Microsoft.Storage/storageAccounts"===e[r].value){t=!0;break}return t&&(e.push({text:"Microsoft.Storage/storageAccounts/blobServices",value:"Microsoft.Storage/storageAccounts/blobServices"}),e.push({text:"Microsoft.Storage/storageAccounts/fileServices",value:"Microsoft.Storage/storageAccounts/fileServices"}),e.push({text:"Microsoft.Storage/storageAccounts/tableServices",value:"Microsoft.Storage/storageAccounts/tableServices"}),e.push({text:"Microsoft.Storage/storageAccounts/queueServices",value:"Microsoft.Storage/storageAccounts/queueServices"})),e}))}},{key:"getResourceNames",value:function(e,t,r){var n="".concat(this.baseUrl,"/").concat(e,"/resourceGroups/").concat(t,"/resources?api-version=").concat(this.apiVersion);return this.doRequest(n).then((function(e){if(!Object(a.startsWith)(r,"Microsoft.Storage/storageAccounts/"))return Oe.parseResourceNames(e,r);for(var t=Oe.parseResourceNames(e,"Microsoft.Storage/storageAccounts"),n=0;n<t.length;n++)t[n].text+="/default",t[n].value+="/default";return t}))}},{key:"getMetricNamespaces",value:function(e,t,r,n){var a=De.buildAzureMonitorGetMetricNamespacesUrl(this.baseUrl,e,t,r,n,this.apiPreviewVersion);return this.doRequest(a).then((function(e){return Oe.parseResponseValues(e,"name","properties.metricNamespaceName")}))}},{key:"getMetricNames",value:function(e,t,r,n,a){var i=De.buildAzureMonitorGetMetricNamesUrl(this.baseUrl,e,t,r,n,a,this.apiVersion);return this.doRequest(i).then((function(e){return Oe.parseResponseValues(e,"name.localizedValue","name.value")}))}},{key:"getMetricMetadata",value:function(e,t,r,n,a,i){var o=De.buildAzureMonitorGetMetricNamesUrl(this.baseUrl,e,t,r,n,a,this.apiVersion);return this.doRequest(o).then((function(e){return Oe.parseMetadata(e,i)}))}},{key:"testDatasource",value:function(){if(!this.isValidConfigField(this.instanceSettings.jsonData.tenantId))return Promise.resolve({status:"error",message:"The Tenant Id field is required."});if(!this.isValidConfigField(this.instanceSettings.jsonData.clientId))return Promise.resolve({status:"error",message:"The Client Id field is required."});var e="/".concat(this.cloudName,"/subscriptions?api-version=2019-03-01");return this.doRequest(e).then((function(e){return 200===e.status?{status:"success",message:"Successfully queried the Azure Monitor service.",title:"Success"}:{status:"error",message:"Returned http status code "+e.status}})).catch((function(e){var t="Azure Monitor: ";return t+=e.statusText?e.statusText+": ":"",e.data&&e.data.error&&e.data.error.code?t+=e.data.error.code+". "+e.data.error.message:e.data&&e.data.error?t+=e.data.error:e.data?t+=e.data:t+="Cannot connect to Azure Monitor REST API.",{status:"error",message:t}}))}},{key:"isValidConfigField",value:function(e){return e&&e.length>0}},{key:"doRequest",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return Object(Re.getBackendSrv)().datasourceRequest({url:this.url+e,method:"GET"}).catch((function(n){if(r>0)return t.doRequest(e,r-1);throw n}))}}])&&Ee(r.prototype,n),i&&Ee(r,i),t}(Re.DataSourceWithBackend);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)}}var Le=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.results=t}var t,r,a;return t=e,a=[{key:"isSingleValue",value:function(t){return!e.hasSegmentsField(t)}},{key:"findOrCreateBucket",value:function(e,t){var r=i.a.find(e,["target",t]);return r||(r={target:t,datapoints:[]},e.push(r)),r}},{key:"hasSegmentsField",value:function(e){var t=i.a.keys(e);return i.a.indexOf(t,"segments")>-1}},{key:"getMetricFieldKey",value:function(e){var t=i.a.keys(e);return i.a.filter(i.a.without(t,"start","end"),(function(t){return i.a.isObject(e[t])}))[0]}},{key:"getKeyForAggregationField",value:function(e){var t=i.a.keys(e);return i.a.intersection(t,["sum","avg","min","max","count","unique"])[0]}},{key:"dateTimeToEpoch",value:function(e){return Object(n.dateTime)(e).valueOf()}},{key:"parseMetricNames",value:function(t){var r=i.a.keys(t.data.metrics);return e.toTextValueList(r)}},{key:"toTextValueList",value:function(e){for(var t=[],r=0;r<e.length;r++)t.push({text:e[r],value:e[r]});return t}}],(r=[{key:"parseQueryResult",value:function(){for(var e=[],t=[],r=0;r<this.results.length;r++)if(this.results[r].query.raw){var n=this.results[r].query.xaxis,a=this.results[r].query.yaxis,o=this.results[r].query.spliton;t=this.results[r].result.data.Tables[0].Columns;var s=this.results[r].result.data.Tables[0].Rows;e=i.a.concat(e,this.parseRawQueryResultRow(this.results[r].query,t,s,n,a,o))}else{var u=this.results[r].result.data.value,c=this.results[r].query.alias;e=i.a.concat(e,this.parseQueryResultRow(this.results[r].query,u,c))}return e}},{key:"parseRawQueryResultRow",value:function(t,r,n,a,o,s){var u=[],c=i.a.map(r,(function(e){return{text:e.ColumnName,value:e.ColumnName}})),l=r.findIndex((function(e){return e.ColumnName===a})),p=o.split(","),f={};i.a.forEach(p,(function(e){f[e]=r.findIndex((function(t){return t.ColumnName===e}))}));var h=r.findIndex((function(e){return e.ColumnName===s})),m="timestamp"===a;return i.a.forEach(n,(function(r){i.a.forEach(f,(function(n,a){var i=-1===h?e.findOrCreateBucket(u,a):e.findOrCreateBucket(u,r[h]),o=m?e.dateTimeToEpoch(r[l]):r[l];i.datapoints.push([r[n],o]),i.refId=t.refId,i.query=t.query,i.columnsForDropdown=c}))})),u}},{key:"parseQueryResultRow",value:function(t,r,n){var a=[];if(e.isSingleValue(r)){var i=e.getMetricFieldKey(r),o=e.getKeyForAggregationField(r[i]),s=e.dateTimeToEpoch(r.end);return a.push({target:i,datapoints:[[r[i][o],s]],refId:t.refId,query:t.query}),a}if(e.hasSegmentsField(r.segments[0]))for(var u=0;u<r.segments.length;u++)for(var c=e.dateTimeToEpoch(r.segments[u].end),l=0;l<r.segments[u].segments.length;l++){var p=e.getMetricFieldKey(r.segments[u].segments[l]),f=e.getKeyForAggregationField(r.segments[u].segments[l][p]),h=this.getTargetName(r.segments[u].segments[l],n),m=e.findOrCreateBucket(a,h);m.datapoints.push([r.segments[u].segments[l][p][f],c]),m.refId=t.refId,m.meta={query:t.query}}else{for(var d=e.getMetricFieldKey(r.segments[0]),g=e.findOrCreateBucket(a,d),y=0;y<r.segments.length;y++){var v=e.dateTimeToEpoch(r.segments[y].end),b=e.getKeyForAggregationField(r.segments[y][d]);g.datapoints.push([r.segments[y][d][b],v])}g.refId=t.refId,g.query=t.query}return a}},{key:"getTargetName",value:function(e,t){var r="",n="",a="";for(var o in e)i.a.isObject(e[o])?r=o:(n=o,a=e[o]);return t?t.replace(/\{\{([\s\S]+?)\}\}/g,(function(e,t,i){var o=t||i;return"metric"===o?r:"groupbyname"===o?n:"groupbyvalue"===o?a:e})):r+"{".concat(n,'="').concat(a,'"}')}},{key:"parseMetadata",value:function(e){var t=this.results.data.metrics[e];if(!t)throw Error("No data found for metric: "+e);return{primaryAggType:t.defaultAggregation,supportedAggTypes:t.supportedAggregations,supportedGroupBy:t.supportedGroupBy.all}}},{key:"parseGroupBys",value:function(){return e.toTextValueList(this.results.supportedGroupBy)}},{key:"parseQuerySchema",value:function(){var e={Type:"AppInsights",Tables:{}};if(this.results&&this.results.data&&this.results.data.Tables)for(var t=0;t<this.results.data.Tables[0].Rows.length;t++){var r=this.results.data.Tables[0].Rows[t],n=r[0],a=r[1],i=r[2];e.Tables[n]?e.Tables[n].OrderedColumns.push({Name:a,Type:i}):e.Tables[n]={Name:n,OrderedColumns:[{Name:a,Type:i}]}}return e}}])&&qe(t.prototype,r),a&&qe(t,a),e}();function Xe(e){return(Xe="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 Ue(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 Ve(e,t){return!t||"object"!==Xe(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 Qe(e){return(Qe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function We(e,t){return(We=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Be=function(e){function t(e){var r,n;switch(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=Ve(this,Qe(t).call(this,e))).version="beta",n.logAnalyticsColumns={},n.applicationId=e.jsonData.appInsightsAppId||"",null===(r=e.jsonData)||void 0===r?void 0:r.cloudName){case"govazuremonitor":case"germanyazuremonitor":break;case"chinaazuremonitor":n.baseUrl="/chinaappinsights/".concat(n.version,"/apps/").concat(n.applicationId);break;default:n.baseUrl="/appinsights/".concat(n.version,"/apps/").concat(n.applicationId)}return n.url=e.url||"",n}var r,n,i;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:"isConfigured",value:function(){return!!this.applicationId&&this.applicationId.length>0}},{key:"createRawQueryRequest",value:function(e,t,r){return e.xaxis&&!e.timeColumn&&(e.timeColumn=e.xaxis),e.yaxis&&!e.valueColumn&&(e.valueColumn=e.yaxis),e.spliton&&!e.segmentColumn&&(e.segmentColumn=e.spliton),{type:"timeSeriesQuery",raw:!1,appInsights:{rawQuery:!0,rawQueryString:Object(Re.getTemplateSrv)().replace(e.rawQueryString,t.scopedVars),timeColumn:e.timeColumn,valueColumn:e.valueColumn,segmentColumn:e.segmentColumn}}}},{key:"applyTemplateVariables",value:function(e,t){var r=e.appInsights,n=r;n.timeGrainCount?r.timeGrain=c.createISO8601Duration(n.timeGrainCount,r.timeGrainUnit):r.timeGrainUnit&&"auto"!==r.timeGrain&&(r.timeGrain=c.createISO8601Duration(r.timeGrain,r.timeGrainUnit)),n.groupBy&&!r.dimension&&(r.dimension=[n.groupBy]),n.filter&&!r.dimensionFilter&&(r.dimensionFilter=n.filter),Object(a.isString)(r.dimension)&&("None"===r.dimension?r.dimension=[]:r.dimension=[r.dimension]),r.dimension||(r.dimension=[]);var i=Object(Re.getTemplateSrv)();return{type:"timeSeriesQuery",refId:e.refId,format:e.format,queryType:ze.ApplicationInsights,appInsights:{timeGrain:i.replace((r.timeGrain||"").toString(),t),allowedTimeGrainsMs:r.allowedTimeGrainsMs,metricName:i.replace(r.metricName,t),aggregation:i.replace(r.aggregation,t),dimension:r.dimension.map((function(e){return i.replace(e,t)})),dimensionFilter:i.replace(r.dimensionFilter,t),alias:r.alias,format:e.format}}}},{key:"metricFindQuery",value:function(e){if(e.match(/^AppInsightsMetricNames\(\)/i))return this.getMetricNames();var t=e.match(/^AppInsightsGroupBys\(([^\)]+?)(,\s?([^,]+?))?\)/i);if(t){var r=t[1];return this.getGroupBys(Object(Re.getTemplateSrv)().replace(r))}}},{key:"testDatasource",value:function(){var e="".concat(this.baseUrl,"/metrics/metadata");return this.doRequest(e).then((function(e){return 200===e.status?{status:"success",message:"Successfully queried the Application Insights service.",title:"Success"}:{status:"error",message:"Application Insights: Returned http status code "+e.status}})).catch((function(e){var t="Application Insights: ";return t+=e.statusText?e.statusText+": ":"",e.data&&e.data.error&&"PathNotFoundError"===e.data.error.code?t+="Invalid Application Id for Application Insights service.":e.data&&e.data.error?t+=e.data.error.code+". "+e.data.error.message:t+="Cannot connect to Application Insights REST API.",{status:"error",message:t}}))}},{key:"doRequest",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return Object(Re.getBackendSrv)().datasourceRequest({url:this.url+e,method:"GET"}).catch((function(n){if(r>0)return t.doRequest(e,r-1);throw n}))}},{key:"getMetricNames",value:function(){var e="".concat(this.baseUrl,"/metrics/metadata");return this.doRequest(e).then(Le.parseMetricNames)}},{key:"getMetricMetadata",value:function(e){var t="".concat(this.baseUrl,"/metrics/metadata");return this.doRequest(t).then((function(t){return new Le(t).parseMetadata(e)}))}},{key:"getGroupBys",value:function(e){return this.getMetricMetadata(e).then((function(e){return new Le(e).parseGroupBys()}))}},{key:"getQuerySchema",value:function(){var e="".concat(this.baseUrl,"/query/schema");return this.doRequest(e).then((function(e){return new Le(e).parseQuerySchema()}))}}])&&Ue(r.prototype,n),i&&Ue(r,i),t}(Re.DataSourceWithBackend);function Je(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 Ke=function(){function e(t,r,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.rawQueryString=t,this.options=r,this.defaultTimeField=n}var t,r,a;return t=e,(r=[{key:"generate",value:function(){var e=this,t=this.rawQueryString,r=/\$__([_a-zA-Z0-9]+)\(([^\)]*)\)/gi;t=(t=t.replace(r,(function(t,r,n){return"contains"===r?e.getMultiContains(n):t}))).replace(/\$__escapeMulti\(('[^]*')\)/gi,(function(t,r){return e.escape(r)})),this.options&&(t=(t=t.replace(r,(function(t,r,n){return"timeFilter"===r?e.getTimeFilter(n,e.options):"timeFrom"===r?e.getFrom(e.options):"timeTo"===r?e.getUntil(e.options):t}))).replace(/\$__interval/gi,this.options.interval));var n=t;return t=encodeURIComponent(t),{uriString:"query=".concat(t),rawQuery:n}}},{key:"getFrom",value:function(e){var t=e.range.from;return"datetime(".concat(Object(n.dateTime)(t).startOf("minute").toISOString(),")")}},{key:"getUntil",value:function(e){if("now"===e.rangeRaw.to){var t=Date.now();return"datetime(".concat(Object(n.dateTime)(t).startOf("minute").toISOString(),")")}var r=e.range.to;return"datetime(".concat(Object(n.dateTime)(r).startOf("minute").toISOString(),")")}},{key:"getTimeFilter",value:function(e,t){var r=e||this.defaultTimeField;return"now"===t.rangeRaw.to?"".concat(r," >= ").concat(this.getFrom(t)):"".concat(r," >= ").concat(this.getFrom(t)," and ").concat(r," <= ").concat(this.getUntil(t))}},{key:"getMultiContains",value:function(e){var t=e.indexOf(","),r=e.substring(0,t),n=e.substring(e.indexOf(",")+1);return n&&"all"===n.toLowerCase().trim()?"1 == 1":"".concat(r.trim()," in (").concat(n.trim(),")")}},{key:"escape",value:function(e){return e.substring(1,e.length-1).split("','").map((function(e){return"@'".concat(e,"'")})).join(", ")}}])&&Je(t.prototype,r),a&&Je(t,a),e}();function $e(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 He=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.results=t}var t,r,a;return t=e,a=[{key:"findOrCreateBucket",value:function(e,t){var r=i.a.find(e,["target",t]);return r||(r={target:t,datapoints:[],refId:"",query:""},e.push(r)),r}},{key:"dateTimeToEpoch",value:function(e){return Object(n.dateTime)(e).valueOf()}}],(r=[{key:"parseQueryResult",value:function(){for(var e=[],t=[],r=0;r<this.results.length;r++)if(0!==this.results[r].result.data.tables.length){t=this.results[r].result.data.tables[0].columns;var n=this.results[r].result.data.tables[0].rows;e="time_series"===this.results[r].query.resultFormat?i.a.concat(e,this.parseTimeSeriesResult(this.results[r].query,t,n)):i.a.concat(e,this.parseTableResult(this.results[r].query,t,n))}return e}},{key:"parseTimeSeriesResult",value:function(t,r,n){for(var a=[],o=-1,s=-1,u=-1,c=0;c<r.length;c++)-1===o&&"datetime"===r[c].type&&(o=c),-1===s&&"string"===r[c].type&&(s=c),-1===u&&["int","long","real","double"].indexOf(r[c].type)>-1&&(u=c);if(-1===o)throw new Error("No datetime column found in the result. The Time Series format requires a time column.");return i.a.forEach(n,(function(n){var i=e.dateTimeToEpoch(n[o]),c=s>-1?n[s]:r[u].name,l=e.findOrCreateBucket(a,c);l.datapoints.push([n[u],i]),l.refId=t.refId,l.meta={executedQueryString:t.query}})),a}},{key:"parseTableResult",value:function(e,t,r){return{type:"table",columns:i.a.map(t,(function(e){return{text:e.name,type:e.type}})),rows:r,refId:e.refId,meta:{executedQueryString:e.query}}}},{key:"parseToVariables",value:function(){var e=this.parseQueryResult(),t=[];return i.a.forEach(e,(function(e){i.a.forEach(i.a.flattenDeep(e.rows),(function(e){t.push({text:e,value:e})}))})),t}},{key:"transformToAnnotations",value:function(t){var r=this.parseQueryResult(),n=[];return i.a.forEach(r,(function(r){for(var a=-1,o=-1,s=-1,u=0;u<r.columns.length;u++)-1===a&&"datetime"===r.columns[u].type&&(a=u),-1===o&&"text"===r.columns[u].text.toLowerCase()&&(o=u),-1===s&&"tags"===r.columns[u].text.toLowerCase()&&(s=u);i.a.forEach(r.rows,(function(r){n.push({annotation:t.annotation,time:Math.floor(e.dateTimeToEpoch(r[a])),text:r[o]?r[o].toString():"",tags:r[s]?r[s].trim().split(/\s*,\s*/):[]})}))})),n}},{key:"parseSchemaResult",value:function(){return{Plugins:[{Name:"pivot"}],Databases:this.createSchemaDatabaseWithTables()}}},{key:"createSchemaDatabaseWithTables",value:function(){return{Default:{Name:"Default",Tables:this.createSchemaTables(),Functions:this.createSchemaFunctions()}}}},{key:"createSchemaTables",value:function(){var e={},t=!0,r=!1,n=void 0;try{for(var a,i=this.results.tables[Symbol.iterator]();!(t=(a=i.next()).done);t=!0){var o=a.value;e[o.name]={Name:o.name,OrderedColumns:[]};var s=!0,u=!1,c=void 0;try{for(var l,p=o.columns[Symbol.iterator]();!(s=(l=p.next()).done);s=!0){var f=l.value;e[o.name].OrderedColumns.push(this.convertToKustoColumn(f))}}catch(e){u=!0,c=e}finally{try{s||null==p.return||p.return()}finally{if(u)throw c}}}}catch(e){r=!0,n=e}finally{try{t||null==i.return||i.return()}finally{if(r)throw n}}return e}},{key:"convertToKustoColumn",value:function(e){return{Name:e.name,Type:e.type}}},{key:"createSchemaFunctions",value:function(){var e={};if(!this.results.functions)return e;var t=!0,r=!1,n=void 0;try{for(var a,i=this.results.functions[Symbol.iterator]();!(t=(a=i.next()).done);t=!0){var o=a.value;e[o.name]={Name:o.name,Body:o.body,DocString:o.displayName,Folder:o.category,FunctionKind:"Unknown",InputParameters:[],OutputColumns:[]}}}catch(e){r=!0,n=e}finally{try{t||null==i.return||i.return()}finally{if(r)throw n}}return e}}])&&$e(t.prototype,r),a&&$e(t,a),e}();function Ze(e){return(Ze="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 Ye(e,t,r,n,a,i,o){try{var s=e[i](o),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,a)}function et(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){Ye(i,n,a,o,s,"next",e)}function s(e){Ye(i,n,a,o,s,"throw",e)}o(void 0)}))}}function tt(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 rt(e,t){return!t||"object"!==Ze(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 nt(e){return(nt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function at(e,t){return(at=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var it=function(e){function t(e){var r;switch(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(r=rt(this,nt(t).call(this,e))).instanceSettings=e,r.cache=new Map,r.instanceSettings.jsonData.cloudName){case"govazuremonitor":r.baseUrl="/govloganalyticsazure";break;case"germanyazuremonitor":break;case"chinaazuremonitor":r.baseUrl="/chinaloganalyticsazure";break;default:r.baseUrl="/loganalyticsazure"}return r.url=e.url||"",r.defaultOrFirstWorkspace=r.instanceSettings.jsonData.logAnalyticsDefaultWorkspace||"",r.setWorkspaceUrl(),r}var r,n,a,o,s,u,c,l;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&&at(e,t)}(t,e),r=t,(n=[{key:"isConfigured",value:function(){return!!this.instanceSettings.jsonData.logAnalyticsSubscriptionId&&this.instanceSettings.jsonData.logAnalyticsSubscriptionId.length>0||!!this.instanceSettings.jsonData.azureLogAnalyticsSameAs}},{key:"setWorkspaceUrl",value:function(){if(this.instanceSettings.jsonData.subscriptionId||this.instanceSettings.jsonData.azureLogAnalyticsSameAs){this.subscriptionId=this.instanceSettings.jsonData.subscriptionId;var e=this.instanceSettings.jsonData.cloudName||"azuremonitor";this.azureMonitorUrl="/".concat(e,"/subscriptions")}else switch(this.subscriptionId=this.instanceSettings.jsonData.logAnalyticsSubscriptionId||"",this.instanceSettings.jsonData.cloudName){case"govazuremonitor":this.azureMonitorUrl="/govworkspacesloganalytics/subscriptions";break;case"germanyazuremonitor":break;case"chinaazuremonitor":this.azureMonitorUrl="/chinaworkspacesloganalytics/subscriptions";break;default:this.azureMonitorUrl="/workspacesloganalytics/subscriptions"}}},{key:"getWorkspaces",value:(l=et(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getWorkspaceList(t);case 2:return r=e.sent,e.abrupt("return",i.a.map(r.data.value,(function(e){return{text:e.name,value:e.properties.customerId}}))||[]);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"getWorkspaceList",value:function(e){var t=Object(Re.getTemplateSrv)().replace(e||this.subscriptionId),r=this.azureMonitorUrl+"/".concat(t,"/providers/Microsoft.OperationalInsights/workspaces?api-version=2017-04-26-preview");return this.doRequest(r,!0)}},{key:"getSchema",value:function(e){if(!e)return Promise.resolve();var t="".concat(this.baseUrl,"/").concat(Object(Re.getTemplateSrv)().replace(e,{}),"/metadata");return this.doRequest(t).then((function(e){return new He(e.data).parseSchemaResult()}))}},{key:"applyTemplateVariables",value:function(e,t){var r=e.azureLogAnalytics,n=Object(Re.getTemplateSrv)(),a=n.replace(r.workspace,t);!a&&this.defaultOrFirstWorkspace&&(a=this.defaultOrFirstWorkspace);var i=n.replace(e.subscription||this.subscriptionId,t),o=n.replace(r.query,t,this.interpolateVariable);return{refId:e.refId,format:e.format,queryType:ze.LogAnalytics,subscriptionId:i,azureLogAnalytics:{resultFormat:r.resultFormat,query:o,workspace:a}}}},{key:"processResponse",value:(c=et(regeneratorRuntime.mark((function e(t){var r,n,a,i,o,s,u,c,l,p,f,h,m,d,g;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.data){e.next=50;break}r=!0,n=!1,a=void 0,e.prev=4,i=t.data[Symbol.iterator]();case 6:if(r=(o=i.next()).done){e.next=36;break}if(c=o.value,!((l=null===(s=c.meta)||void 0===s?void 0:null===(u=s.custom)||void 0===u?void 0:u.encodedQuery)&&l.length>0)){e.next=33;break}return e.next=12,this.buildDeepLink(c.meta);case 12:if(!(null==(p=e.sent)?void 0:p.length)){e.next=33;break}for(f=!0,h=!1,m=void 0,e.prev=17,d=c.fields[Symbol.iterator]();!(f=(g=d.next()).done);f=!0)g.value.config.links=[{url:p,title:"View in Azure Portal",targetBlank:!0}];e.next=25;break;case 21:e.prev=21,e.t0=e.catch(17),h=!0,m=e.t0;case 25:e.prev=25,e.prev=26,f||null==d.return||d.return();case 28:if(e.prev=28,!h){e.next=31;break}throw m;case 31:return e.finish(28);case 32:return e.finish(25);case 33:r=!0,e.next=6;break;case 36:e.next=42;break;case 38:e.prev=38,e.t1=e.catch(4),n=!0,a=e.t1;case 42:e.prev=42,e.prev=43,r||null==i.return||i.return();case 45:if(e.prev=45,!n){e.next=48;break}throw a;case 48:return e.finish(45);case 49:return e.finish(42);case 50:return e.abrupt("return",t);case 51:case"end":return e.stop()}}),e,this,[[4,38,42,50],[17,21,25,33],[26,,28,32],[43,,45,49]])}))),function(e){return c.apply(this,arguments)})},{key:"buildDeepLink",value:(u=et(regeneratorRuntime.mark((function e(t){var r,n,a,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=encodeURIComponent(t.custom.encodedQuery),n=t.custom.workspace,a=t.custom.subscription,e.next=5,this.getWorkspaceDetails(n);case 5:if((i=e.sent).workspace&&i.resourceGroup){e.next=8;break}return e.abrupt("return","");case 8:return o="https://portal.azure.com/#blade/Microsoft_OperationsManagementSuite_Workspace/AnalyticsBlade/initiator/AnalyticsShareLinkToQuery/isQueryEditorVisible/true/scope/"+"%7B%22resources%22%3A%5B%7B%22resourceId%22%3A%22%2Fsubscriptions%2F".concat(a)+"%2Fresourcegroups%2F".concat(i.resourceGroup,"%2Fproviders%2Fmicrosoft.operationalinsights%2Fworkspaces%2F").concat(i.workspace)+"%22%7D%5D%7D/query/".concat(r,"/isQueryBase64Compressed/true/timespanInIsoFormat/P1D"),e.abrupt("return",o);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"getWorkspaceDetails",value:(s=et(regeneratorRuntime.mark((function e(t){var r,n,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getWorkspaceList(this.subscriptionId);case 2:if(r=e.sent,n=r.data.value.find((function(e){return e.properties.customerId===t}))){e.next=6;break}return e.abrupt("return",{});case 6:if((a=/.*resourcegroups\/(.*)\/providers.*/.exec(n.id))&&!(a.length<2)){e.next=10;break}return e.abrupt("return",{});case 10:return e.abrupt("return",{workspace:n.name,resourceGroup:a[1]});case 11:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"metricFindQuery",value:function(e){var t=this;if(e.match(/^workspaces\(\)/i))return this.getWorkspaces(this.subscriptionId);var r=e.match(/^workspaces\(["']?([^\)]+?)["']?\)/i);return r?this.getWorkspaces((r[1]||"").trim()):this.getDefaultOrFirstWorkspace().then((function(r){var n=t.buildQuery(e,null,r),a=t.doQueries(n);return Promise.all(a).then((function(e){return new He(e).parseToVariables()})).catch((function(e){if(e.error&&e.error.data&&e.error.data.error&&e.error.data.error.innererror&&e.error.data.error.innererror.innererror)throw{message:e.error.data.error.innererror.innererror.message};if(e.error&&e.error.data&&e.error.data.error)throw{message:e.error.data.error.message}}))}))}},{key:"buildQuery",value:function(e,t,r){var n=new Ke(Object(Re.getTemplateSrv)().replace(e,{},this.interpolateVariable),t,"TimeGenerated").generate().uriString,a="".concat(this.baseUrl,"/").concat(r,"/query?").concat(n),i=[];return i.push({datasourceId:this.id,url:a,resultFormat:"table"}),i}},{key:"interpolateVariable",value:function(e,t){return"string"==typeof e?t.multi||t.includeAll?"'"+e+"'":e:"number"==typeof e?e:i.a.map(e,(function(t){return"number"==typeof e?e:"'"+t+"'"})).join(",")}},{key:"getDefaultOrFirstWorkspace",value:function(){var e=this;return this.defaultOrFirstWorkspace?Promise.resolve(this.defaultOrFirstWorkspace):this.getWorkspaces(this.subscriptionId).then((function(t){return e.defaultOrFirstWorkspace=t[0].value,e.defaultOrFirstWorkspace}))}},{key:"annotationQuery",value:function(e){if(!e.annotation.rawQuery)return Promise.reject({message:"Query missing in annotation definition"});var t=this.buildQuery(e.annotation.rawQuery,e,e.annotation.workspace),r=this.doQueries(t);return Promise.all(r).then((function(t){return new He(t).transformToAnnotations(e)}))}},{key:"doQueries",value:function(e){var t=this;return i.a.map(e,(function(e){return t.doRequest(e.url).then((function(t){return{result:t,query:e}})).catch((function(t){throw{error:t,query:e}}))}))}},{key:"doRequest",value:(o=et(regeneratorRuntime.mark((function e(t){var r,n,a,i=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],n=i.length>2&&void 0!==i[2]?i[2]:1,e.prev=2,!r||!this.cache.has(t)){e.next=5;break}return e.abrupt("return",this.cache.get(t));case 5:return e.next=7,Object(Re.getBackendSrv)().datasourceRequest({url:this.url+t,method:"GET"});case 7:return a=e.sent,r&&this.cache.set(t,a),e.abrupt("return",a);case 12:if(e.prev=12,e.t0=e.catch(2),!(n>0)){e.next=16;break}return e.abrupt("return",this.doRequest(t,r,n-1));case 16:throw e.t0;case 17:case"end":return e.stop()}}),e,this,[[2,12]])}))),function(e){return o.apply(this,arguments)})},{key:"testDatasource",value:function(){var e=this,t=this.isValidConfig();return t?Promise.resolve(t):this.getDefaultOrFirstWorkspace().then((function(t){var r="".concat(e.baseUrl,"/").concat(t,"/metadata");return e.doRequest(r)})).then((function(e){return 200===e.status?{status:"success",message:"Successfully queried the Azure Log Analytics service.",title:"Success"}:{status:"error",message:"Returned http status code "+e.status}})).catch((function(t){var r="Azure Log Analytics: ";return t.config&&t.config.url&&t.config.url.indexOf("workspacesloganalytics")>-1&&(r="Azure Log Analytics requires access to Azure Monitor but had the following error: "),{status:"error",message:r=e.getErrorMessage(r,t)}}))}},{key:"getErrorMessage",value:function(e,t){return e+=t.statusText?t.statusText+": ":"",t.data&&t.data.error&&t.data.error.code?e+=t.data.error.code+". "+t.data.error.message:t.data&&t.data.error?e+=t.data.error:t.data?e+=t.data:e+="Cannot connect to Azure Log Analytics REST API.",e}},{key:"isValidConfig",value:function(){if(!this.instanceSettings.jsonData.azureLogAnalyticsSameAs)return this.isValidConfigField(this.instanceSettings.jsonData.logAnalyticsSubscriptionId)?this.isValidConfigField(this.instanceSettings.jsonData.logAnalyticsTenantId)?this.isValidConfigField(this.instanceSettings.jsonData.logAnalyticsClientId)?void 0:{status:"error",message:"The Client Id field is required."}:{status:"error",message:"The Tenant Id field is required."}:{status:"error",message:"The Subscription Id field is required."}}},{key:"isValidConfigField",value:function(e){return e&&e.length>0}}])&&tt(r.prototype,n),a&&tt(r,a),t}(Re.DataSourceWithBackend),ot=r("0/uQ"),st=r("F/XL");function ut(e){return(ut="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 ct(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 lt(e,t){return!t||"object"!==ut(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 pt(e){return(pt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ft(e,t){return(ft=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var ht=function(e){function t(e){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),lt(this,pt(t).call(this,e))}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&&ft(e,t)}(t,e),r=t,(n=[{key:"applyTemplateVariables",value:function(e,t){var r=e.insightsAnalytics,n=r;return n.rawQueryString&&!r.query&&(r.query=n.rawQueryString),{refId:e.refId,queryType:ze.InsightsAnalytics,insightsAnalytics:{query:Object(Re.getTemplateSrv)().replace(r.query,t),resultFormat:r.resultFormat}}}}])&&ct(r.prototype,n),a&&ct(r,a),t}(Be);function mt(e){return(mt="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 dt(e,t,r,n,a,i,o){try{var s=e[i](o),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,a)}function gt(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){dt(i,n,a,o,s,"next",e)}function s(e){dt(i,n,a,o,s,"throw",e)}o(void 0)}))}}function yt(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 vt(e,t){return!t||"object"!==mt(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 bt(e){return(bt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function wt(e,t){return(wt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var xt=function(e){function t(e){var r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(r=vt(this,bt(t).call(this,e))).azureMonitorDatasource=new Fe(e),r.appInsightsDatasource=new Be(e),r.azureLogAnalyticsDatasource=new it(e),r.insightsAnalyticsDatasource=new ht(e);var n={};n[ze.ApplicationInsights]=r.appInsightsDatasource,n[ze.AzureMonitor]=r.azureMonitorDatasource,n[ze.InsightsAnalytics]=r.insightsAnalyticsDatasource,n[ze.LogAnalytics]=r.azureLogAnalyticsDatasource,r.pseudoDatasource=n;var a={};return a[ze.ApplicationInsights]="appInsights",a[ze.AzureMonitor]="azureMonitor",a[ze.InsightsAnalytics]="insightsAnalytics",a[ze.LogAnalytics]="azureLogAnalytics",r.optionsKey=a,r}var r,a,o,s,u,c;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&&wt(e,t)}(t,e),r=t,(a=[{key:"query",value:function(e){var t=this,r={},a=!0,o=!1,s=void 0;try{for(var u,c=e.targets[Symbol.iterator]();!(a=(u=c.next()).done);a=!0){var l=u.value;l.queryType===ze.ApplicationInsights&&l.appInsights.rawQuery&&(l.queryType=ze.InsightsAnalytics,l.insightsAnalytics=l.appInsights,delete l.appInsights),l.queryType||(l.queryType=ze.AzureMonitor),l.queryType===ze.AzureMonitor&&Ae(l.azureMonitor);var p=l[this.optionsKey[l.queryType]];if(!l.hide&&p){var f=r[l.queryType];f||((f=i.a.cloneDeep(e)).targets=[],r[l.queryType]=f),f.targets.push(l)}}}catch(e){o=!0,s=e}finally{try{a||null==c.return||c.return()}finally{if(o)throw s}}var h=Object.keys(r).map((function(e){var n=r[e];return t.pseudoDatasource[e].query(n)}));if(1===h.length)return h[0];if(h.length>1){var m=h.map((function(e){return e.toPromise()}));return Object(ot.a)(Promise.all(m).then((function(e){return{data:i.a.flatten(e)}})))}return Object(st.a)({state:n.LoadingState.Done})}},{key:"annotationQuery",value:(c=gt(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.azureLogAnalyticsDatasource.annotationQuery(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"metricFindQuery",value:(u=gt(regeneratorRuntime.mark((function e(t){var r,n,a;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:if(!(r=this.appInsightsDatasource.metricFindQuery(t))){e.next=5;break}return e.abrupt("return",r);case 5:if(!(n=this.azureMonitorDatasource.metricFindQuery(t))){e.next=8;break}return e.abrupt("return",n);case 8:if(!(a=this.azureLogAnalyticsDatasource.metricFindQuery(t))){e.next=11;break}return e.abrupt("return",a);case 11:return e.abrupt("return",Promise.resolve([]));case 12:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"testDatasource",value:(s=gt(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=[],this.azureMonitorDatasource.isConfigured()&&t.push(this.azureMonitorDatasource.testDatasource()),this.appInsightsDatasource.isConfigured()&&t.push(this.appInsightsDatasource.testDatasource()),this.azureLogAnalyticsDatasource.isConfigured()&&t.push(this.azureLogAnalyticsDatasource.testDatasource()),0!==t.length){e.next=6;break}return e.abrupt("return",{status:"error",message:"Nothing configured. At least one of the API's must be configured.",title:"Error"});case 6:return e.abrupt("return",Promise.all(t).then((function(e){for(var t="success",r="",n=0;n<e.length;n++)"success"!==e[n].status&&(t=e[n].status),r+="".concat(n+1,". ").concat(e[n].message," ");return{status:t,message:r,title:i.a.upperFirst(t)}})));case 7:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"getResourceGroups",value:function(e){return this.azureMonitorDatasource.getResourceGroups(e)}},{key:"getMetricDefinitions",value:function(e,t){return this.azureMonitorDatasource.getMetricDefinitions(e,t)}},{key:"getResourceNames",value:function(e,t,r){return this.azureMonitorDatasource.getResourceNames(e,t,r)}},{key:"getMetricNames",value:function(e,t,r,n,a){return this.azureMonitorDatasource.getMetricNames(e,t,r,n,a)}},{key:"getMetricNamespaces",value:function(e,t,r,n){return this.azureMonitorDatasource.getMetricNamespaces(e,t,r,n)}},{key:"getMetricMetadata",value:function(e,t,r,n,a,i){return this.azureMonitorDatasource.getMetricMetadata(e,t,r,n,a,i)}},{key:"getAppInsightsMetricNames",value:function(){return this.appInsightsDatasource.getMetricNames()}},{key:"getAppInsightsMetricMetadata",value:function(e){return this.appInsightsDatasource.getMetricMetadata(e)}},{key:"getAppInsightsColumns",value:function(e){return this.appInsightsDatasource.logAnalyticsColumns[e]}},{key:"getAzureLogAnalyticsWorkspaces",value:function(e){return this.azureLogAnalyticsDatasource.getWorkspaces(e)}},{key:"getSubscriptions",value:function(){return this.azureMonitorDatasource.getSubscriptions()}}])&&yt(r.prototype,a),o&&yt(r,o),t}(n.DataSourceApi);function St(e){return(St="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 kt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Mt(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"!==St(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 Ct(e){return(Ct=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Dt(e,t){return(Dt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var It=d.LegacyForms.Select,Ot=d.LegacyForms.Input,Tt=function(e){function t(){return kt(this,t),At(this,Ct(t).apply(this,arguments))}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&&Dt(e,t)}(t,e),r=t,(n=[{key:"render",value:function(){var e=this.props,t=e.selectedAzureCloud,r=e.selectedSubscription,n=e.tenantId,a=e.clientId,i=e.clientSecret,o=e.clientSecretConfigured,s=e.azureCloudOptions,u=e.subscriptionOptions,c=e.onAzureCloudChange,l=e.onSubscriptionSelectChange,p=e.onTenantIdChange,h=e.onClientIdChange,m=e.onClientSecretChange,g=e.onResetClientSecret,y=e.onLoadSubscriptions,v=n&&a&&(i||o),b=y&&u;return f.a.createElement(f.a.Fragment,null,f.a.createElement("div",{className:"gf-form-group"},s&&f.a.createElement("div",{className:"gf-form-inline"},f.a.createElement("div",{className:"gf-form"},f.a.createElement(d.InlineFormLabel,{className:"width-12",tooltip:"Choose an Azure Cloud."},"Azure Cloud"),f.a.createElement(It,{className:"width-15",value:s.find((function(e){return e.value===t})),options:s,defaultValue:t,onChange:c}))),f.a.createElement("div",{className:"gf-form-inline"},f.a.createElement("div",{className:"gf-form"},f.a.createElement(d.InlineFormLabel,{className:"width-12"},"Directory (tenant) ID"),f.a.createElement("div",{className:"width-15"},f.a.createElement(Ot,{className:"width-30",placeholder:"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",value:n||"",onChange:p})))),f.a.createElement("div",{className:"gf-form-inline"},f.a.createElement("div",{className:"gf-form"},f.a.createElement(d.InlineFormLabel,{className:"width-12"},"Application (client) ID"),f.a.createElement("div",{className:"width-15"},f.a.createElement(Ot,{className:"width-30",placeholder:"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",value:a||"",onChange:h})))),o?f.a.createElement("div",{className:"gf-form-inline"},f.a.createElement("div",{className:"gf-form"},f.a.createElement(d.InlineFormLabel,{className:"width-12"},"Client Secret"),f.a.createElement(Ot,{className:"width-25",placeholder:"configured",disabled:!0})),f.a.createElement("div",{className:"gf-form"},f.a.createElement("div",{className:"max-width-30 gf-form-inline"},f.a.createElement(d.Button,{variant:"secondary",type:"button",onClick:g},"reset")))):f.a.createElement("div",{className:"gf-form-inline"},f.a.createElement("div",{className:"gf-form"},f.a.createElement(d.InlineFormLabel,{className:"width-12"},"Client Secret"),f.a.createElement("div",{className:"width-15"},f.a.createElement(Ot,{className:"width-30",placeholder:"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",value:i||"",onChange:m})))),b&&f.a.createElement(f.a.Fragment,null,f.a.createElement("div",{className:"gf-form-inline"},f.a.createElement("div",{className:"gf-form"},f.a.createElement(d.InlineFormLabel,{className:"width-12"},"Default Subscription"),f.a.createElement("div",{className:"width-25"},f.a.createElement(It,{value:u.find((function(e){return e.value===r})),options:u,defaultValue:r,onChange:l})))),f.a.createElement("div",{className:"gf-form-inline"},f.a.createElement("div",{className:"gf-form"},f.a.createElement("div",{className:"max-width-30 gf-form-inline"},f.a.createElement(d.Button,{variant:"secondary",size:"sm",type:"button",onClick:y,disabled:!v},"Load Subscriptions")))))))}}])&&Mt(r.prototype,n),a&&Mt(r,a),t}(p.PureComponent);function zt(e){return(zt="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 Nt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Rt(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 _t(e,t){return!t||"object"!==zt(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 Et(e){return(Et=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function jt(e,t){return(jt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Pt=[{value:"azuremonitor",label:"Azure"},{value:"govazuremonitor",label:"Azure US Government"},{value:"germanyazuremonitor",label:"Azure Germany"},{value:"chinaazuremonitor",label:"Azure China"}],Gt=function(e){function t(){var e,r;Nt(this,t);for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return(r=_t(this,(e=Et(t)).call.apply(e,[this].concat(a)))).onAzureCloudSelect=function(e){r.props.onUpdateJsonDataOption("cloudName",e.value)},r.onTenantIdChange=function(e){r.props.onUpdateJsonDataOption("tenantId",e.target.value)},r.onClientIdChange=function(e){r.props.onUpdateJsonDataOption("clientId",e.target.value)},r.onClientSecretChange=function(e){var t=r.props,n=t.options,a=t.makeSameAs;n.jsonData.azureLogAnalyticsSameAs&&e.target.value?a(e.target.value):r.props.onUpdateSecureJsonDataOption("clientSecret",e.target.value)},r.onResetClientSecret=function(){r.props.onResetOptionKey("clientSecret")},r.onSubscriptionSelect=function(e){r.props.onUpdateJsonDataOption("subscriptionId",e.value)},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&&jt(e,t)}(t,e),r=t,(n=[{key:"render",value:function(){var e=this.props,t=e.options,r=e.subscriptions;return f.a.createElement(f.a.Fragment,null,f.a.createElement("h3",{className:"page-heading"},"Azure Monitor Details"),f.a.createElement(Tt,{selectedAzureCloud:t.jsonData.cloudName||"azuremonitor",azureCloudOptions:Pt,subscriptionOptions:r,selectedSubscription:t.jsonData.subscriptionId,tenantId:t.jsonData.tenantId,clientId:t.jsonData.clientId,clientSecret:t.secureJsonData.clientSecret,clientSecretConfigured:t.secureJsonFields.clientSecret,onAzureCloudChange:this.onAzureCloudSelect,onSubscriptionSelectChange:this.onSubscriptionSelect,onTenantIdChange:this.onTenantIdChange,onClientIdChange:this.onClientIdChange,onClientSecretChange:this.onClientSecretChange,onResetClientSecret:this.onResetClientSecret,onLoadSubscriptions:this.props.onLoadSubscriptions}))}}])&&Rt(r.prototype,n),a&&Rt(r,a),t}(p.PureComponent);function Ft(e){return(Ft="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 qt(){return(qt=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 Lt(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 Xt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Lt(Object(r),!0).forEach((function(t){Ut(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Lt(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Ut(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Vt(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 Qt(e,t){return!t||"object"!==Ft(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 Wt(e){return(Wt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Bt(e,t){return(Bt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Jt=d.LegacyForms.Select,Kt=d.LegacyForms.Switch,$t=function(e){function t(e){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(r=Qt(this,Wt(t).call(this,e))).onLogAnalyticsTenantIdChange=function(e){r.props.onUpdateJsonDataOption("logAnalyticsTenantId",e.target.value)},r.onLogAnalyticsClientIdChange=function(e){r.props.onUpdateJsonDataOption("logAnalyticsClientId",e.target.value)},r.onLogAnalyticsClientSecretChange=function(e){r.props.onUpdateSecureJsonDataOption("logAnalyticsClientSecret",e.target.value)},r.onLogAnalyticsSubscriptionSelect=function(e){r.props.onUpdateJsonDataOption("logAnalyticsSubscriptionId",e.value)},r.onWorkspaceSelectChange=function(e){r.props.onUpdateJsonDataOption("logAnalyticsDefaultWorkspace",e.value)},r.onAzureLogAnalyticsSameAsChange=function(){var e=r.props,t=e.options,n=e.onUpdateDatasourceOptions,a=e.makeSameAs;!t.jsonData.azureLogAnalyticsSameAs&&t.secureJsonData.clientSecret?a():t.jsonData.azureLogAnalyticsSameAs?r.props.onUpdateJsonDataOption("azureLogAnalyticsSameAs",!t.jsonData.azureLogAnalyticsSameAs):(n(Xt({},t,{jsonData:Xt({},t.jsonData,{azureLogAnalyticsSameAs:!t.jsonData.azureLogAnalyticsSameAs}),secureJsonData:Xt({},t.secureJsonData,{clientSecret:""}),secureJsonFields:{clientSecret:!1}})),r.setState({sameAsSwitched:!0}))},r.onLogAnalyticsResetClientSecret=function(){r.props.onResetOptionKey("logAnalyticsClientSecret")},r.hasWorkspaceRequiredFields=function(){var e=r.props.options,t=e.jsonData,n=e.secureJsonData,a=e.secureJsonFields;return t.azureLogAnalyticsSameAs?t.tenantId&&t.clientId&&t.subscriptionId&&(n.clientSecret||a.clientSecret):t.logAnalyticsTenantId&&t.logAnalyticsTenantId.length&&t.logAnalyticsClientId&&t.logAnalyticsClientId.length&&t.logAnalyticsSubscriptionId&&(a.logAnalyticsClientSecret||n.logAnalyticsClientSecret)},r.state={sameAsSwitched:!1},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&&Bt(e,t)}(t,e),r=t,(n=[{key:"render",value:function(){var e=this,t=this.props,r=t.options,n=r.jsonData,a=r.secureJsonData,i=r.secureJsonFields,o=t.subscriptions,s=t.workspaces,u=this.state.sameAsSwitched;n.hasOwnProperty("azureLogAnalyticsSameAs")||(n.azureLogAnalyticsSameAs=!0);var c=Xt({},n.azureLogAnalyticsSameAs&&{tooltip:"Workspaces are pulled from default subscription selected above."}),l=u&&n.azureLogAnalyticsSameAs&&i&&!i.clientSecret&&!a.clientSecret;return f.a.createElement(f.a.Fragment,null,f.a.createElement("h3",{className:"page-heading"},"Azure Log Analytics API Details"),f.a.createElement(Kt,qt({label:"Same details as Azure Monitor API",checked:n.azureLogAnalyticsSameAs,onChange:this.onAzureLogAnalyticsSameAsChange},c)),l&&f.a.createElement("div",{className:"grafana-info-box m-t-2"},f.a.createElement("div",{className:"alert-body"},f.a.createElement("p",null,"Re-enter your Azure Monitor Client Secret to use this setting."))),!n.azureLogAnalyticsSameAs&&f.a.createElement(Tt,{subscriptionOptions:o,selectedSubscription:n.logAnalyticsSubscriptionId,tenantId:n.logAnalyticsTenantId,clientId:n.logAnalyticsClientId,clientSecret:a.logAnalyticsClientSecret,clientSecretConfigured:i.logAnalyticsClientSecret,onSubscriptionSelectChange:this.onLogAnalyticsSubscriptionSelect,onTenantIdChange:this.onLogAnalyticsTenantIdChange,onClientIdChange:this.onLogAnalyticsClientIdChange,onClientSecretChange:this.onLogAnalyticsClientSecretChange,onResetClientSecret:this.onLogAnalyticsResetClientSecret,onLoadSubscriptions:function(){return e.props.onLoadSubscriptions("workspacesloganalytics")}}),f.a.createElement("div",{className:"gf-form-group"},f.a.createElement("div",{className:"gf-form-inline"},f.a.createElement("div",{className:"gf-form"},f.a.createElement(d.InlineFormLabel,{className:"width-12",tooltip:"Choose the default/preferred Workspace for Azure Log Analytics queries."},"Default Workspace"),f.a.createElement("div",{className:"width-25"},f.a.createElement(Jt,{value:s.find((function(e){return e.value===n.logAnalyticsDefaultWorkspace})),options:s,defaultValue:n.logAnalyticsDefaultWorkspace,onChange:this.onWorkspaceSelectChange})))),f.a.createElement("div",{className:"gf-form-inline"},f.a.createElement("div",{className:"gf-form"},f.a.createElement("div",{className:"max-width-30 gf-form-inline"},f.a.createElement(d.Button,{variant:"secondary",size:"sm",type:"button",onClick:function(){return e.props.onLoadWorkspaces()},disabled:!this.hasWorkspaceRequiredFields()},"Load Workspaces"))))))}}])&&Vt(r.prototype,n),a&&Vt(r,a),t}(p.PureComponent),Ht=r("5kRJ");function Zt(e){return(Zt="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 Yt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function er(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 tr(e,t){return!t||"object"!==Zt(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 rr(e){return(rr=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function nr(e,t){return(nr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var ar=d.LegacyForms.Input,ir=function(e){function t(){var e,r;Yt(this,t);for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return(r=tr(this,(e=rr(t)).call.apply(e,[this].concat(a)))).onAppInsightsResetApiKey=function(){r.props.onResetOptionKey("appInsightsApiKey")},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&&nr(e,t)}(t,e),r=t,(n=[{key:"render",value:function(){var e=this.props,t=e.options,r=e.onUpdateJsonDataOption,n=e.onUpdateSecureJsonDataOption;return f.a.createElement(f.a.Fragment,null,f.a.createElement("h3",{className:"page-heading"},"Application Insights Details"),f.a.createElement("div",{className:"gf-form-group"},t.secureJsonFields.appInsightsApiKey?f.a.createElement("div",{className:"gf-form-inline"},f.a.createElement("div",{className:"gf-form"},f.a.createElement(d.InlineFormLabel,{className:"width-12"},"API Key"),f.a.createElement(ar,{className:"width-25",placeholder:"configured",disabled:!0})),f.a.createElement("div",{className:"gf-form"},f.a.createElement("div",{className:"max-width-30 gf-form-inline"},f.a.createElement(d.Button,{variant:"secondary",type:"button",onClick:this.onAppInsightsResetApiKey},"reset")))):f.a.createElement("div",{className:"gf-form-inline"},f.a.createElement("div",{className:"gf-form"},f.a.createElement(d.InlineFormLabel,{className:"width-12"},"API Key"),f.a.createElement("div",{className:"width-15"},f.a.createElement(ar,{className:"width-30",placeholder:"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",value:t.secureJsonData.appInsightsApiKey||"",onChange:n("appInsightsApiKey")})))),f.a.createElement("div",{className:"gf-form-inline"},f.a.createElement("div",{className:"gf-form"},f.a.createElement(d.InlineFormLabel,{className:"width-12"},"Application ID"),f.a.createElement("div",{className:"width-15"},f.a.createElement(ar,{className:"width-30",value:t.jsonData.appInsightsAppId||"",onChange:r("appInsightsAppId")}))))))}}])&&er(r.prototype,n),a&&er(r,a),t}(p.PureComponent),or=r("sGFA");function sr(e){return(sr="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 ur(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 cr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ur(Object(r),!0).forEach((function(t){lr(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ur(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function lr(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function pr(e,t,r,n,a,i,o){try{var s=e[i](o),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,a)}function fr(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){pr(i,n,a,o,s,"next",e)}function s(e){pr(i,n,a,o,s,"throw",e)}o(void 0)}))}}function hr(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 mr(e,t){return!t||"object"!==sr(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 dr(e){return(dr=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function gr(e,t){return(gr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var yr=function(e){function t(e){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(r=mr(this,dr(t).call(this,e))).initPromise=null,r.templateSrv=null,r.init=fr(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.getSubscriptions();case 2:if(r.props.options.jsonData.azureLogAnalyticsSameAs){e.next=5;break}return e.next=5,r.getLogAnalyticsSubscriptions();case 5:case"end":return e.stop()}}),e)}))),r.updateJsonDataOption=function(e,t){Object(n.updateDatasourcePluginJsonDataOption)(r.props,e,t)},r.updateSecureJsonDataOption=function(e,t){Object(n.updateDatasourcePluginSecureJsonDataOption)(r.props,e,t)},r.resetSecureKey=function(e){Object(n.updateDatasourcePluginResetOption)(r.props,e)},r.onUpdateJsonDataOption=function(e){return function(t){r.updateJsonDataOption(e,t.currentTarget.value)}},r.onUpdateSecureJsonDataOption=function(e){return function(t){r.updateSecureJsonDataOption(e,t.currentTarget.value)}},r.makeSameAs=function(e){var t=r.props.options,n=e||t.secureJsonData.clientSecret;r.props.onOptionsChange(cr({},t,{jsonData:cr({},t.jsonData,{azureLogAnalyticsSameAs:!0,logAnalyticsSubscriptionId:t.jsonData.subscriptionId,logAnalyticsTenantId:t.jsonData.tenantId,logAnalyticsClientId:t.jsonData.clientId}),secureJsonData:cr({},t.secureJsonData,{clientSecret:n,logAnalyticsClientSecret:n})}))},r.hasNecessaryCredentials=function(){return!(!r.props.options.secureJsonFields.clientSecret&&!r.props.options.secureJsonData.clientSecret)&&!(!r.props.options.jsonData.clientId||!r.props.options.jsonData.tenantId)},r.logAnalyticsHasNecessaryCredentials=function(){return!(!r.props.options.secureJsonFields.logAnalyticsClientSecret&&!r.props.options.secureJsonData.logAnalyticsClientSecret)&&!(!r.props.options.jsonData.logAnalyticsClientId||!r.props.options.jsonData.logAnalyticsTenantId)},r.onLoadSubscriptions=function(){var e=fr(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Object(Re.getBackendSrv)().put("/api/datasources/".concat(r.props.options.id),r.props.options).then((function(e){Object(n.updateDatasourcePluginOption)(r.props,"version",e.version)}));case 2:t&&"workspacesloganalytics"===t?r.getLogAnalyticsSubscriptions():r.getSubscriptions();case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),r.loadSubscriptions=function(){var e=fr(regeneratorRuntime.mark((function e(t){var n,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="/".concat(t||r.props.options.jsonData.cloudName,"/subscriptions?api-version=2019-03-01"),e.next=3,Object(Re.getBackendSrv)().datasourceRequest({url:r.props.options.url+n,method:"GET"});case 3:return a=e.sent,e.abrupt("return",Oe.parseSubscriptionsForSelect(a));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),r.loadWorkspaces=function(){var e=fr(regeneratorRuntime.mark((function e(t){var n,a,i,o,s,u,c,l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.props.options.jsonData,a=n.azureLogAnalyticsSameAs,i=n.cloudName,o=n.logAnalyticsSubscriptionId,s="",u=r.templateSrv.replace(t||r.props.options.jsonData.subscriptionId),a?s="/".concat(i||"azuremonitor","/subscriptions"):(u=o,s="/workspacesloganalytics/subscriptions"),c=s+"/".concat(u,"/providers/Microsoft.OperationalInsights/workspaces?api-version=2017-04-26-preview"),e.next=6,Object(Re.getBackendSrv)().datasourceRequest({url:r.props.options.url+c,method:"GET"});case 6:return l=e.sent,e.abrupt("return",Oe.parseWorkspacesForSelect(l));case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),r.getSubscriptions=fr(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.hasNecessaryCredentials()){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,r.loadSubscriptions();case 4:if(e.t0=e.sent,e.t0){e.next=7;break}e.t0=[];case 7:if((t=e.t0)&&t.length>0&&(r.setState({subscriptions:t}),r.updateJsonDataOption("subscriptionId",r.props.options.jsonData.subscriptionId||t[0].value)),!r.props.options.jsonData.subscriptionId||!r.props.options.jsonData.azureLogAnalyticsSameAs){e.next=12;break}return e.next=12,r.getWorkspaces();case 12:case"end":return e.stop()}}),e)}))),r.getLogAnalyticsSubscriptions=fr(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.logAnalyticsHasNecessaryCredentials()){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,r.loadSubscriptions("workspacesloganalytics");case 4:if(e.t0=e.sent,e.t0){e.next=7;break}e.t0=[];case 7:if((t=e.t0)&&t.length>0&&(r.setState({logAnalyticsSubscriptions:t}),r.updateJsonDataOption("logAnalyticsSubscriptionId",r.props.options.jsonData.logAnalyticsSubscriptionId||t[0].value)),!r.props.options.jsonData.logAnalyticsSubscriptionId){e.next=12;break}return e.next=12,r.getWorkspaces();case 12:case"end":return e.stop()}}),e)}))),r.getWorkspaces=fr(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((t=r.props.options.jsonData.azureLogAnalyticsSameAs&&r.props.options.jsonData.subscriptionId)||r.props.options.jsonData.logAnalyticsSubscriptionId){e.next=3;break}return e.abrupt("return");case 3:return e.next=5,r.loadWorkspaces(t?r.props.options.jsonData.subscriptionId:r.props.options.jsonData.logAnalyticsSubscriptionId);case 5:(n=e.sent).length>0&&(r.setState({logAnalyticsWorkspaces:n}),r.updateJsonDataOption("logAnalyticsDefaultWorkspace",r.props.options.jsonData.logAnalyticsDefaultWorkspace||n[0].value));case 7:case"end":return e.stop()}}),e)}))),r.state={subscriptions:[],logAnalyticsSubscriptions:[],logAnalyticsWorkspaces:[],subscriptionId:"",logAnalyticsSubscriptionId:""},r.templateSrv=new Ht.a,r.props.options.id&&Object(n.updateDatasourcePluginOption)(r.props,"url","/api/datasources/proxy/"+r.props.options.id),r}var r,a,i;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&&gr(e,t)}(t,e),r=t,(a=[{key:"componentDidMount",value:function(){this.initPromise=Object(or.a)(this.init()),this.initPromise.promise.catch((function(e){e.isCanceled&&console.warn("Azure Monitor ConfigEditor has unmounted, intialization was canceled")}))}},{key:"componentWillUnmount",value:function(){this.initPromise.cancel()}},{key:"render",value:function(){var e=this.state,t=e.subscriptions,r=e.logAnalyticsSubscriptions,n=e.logAnalyticsWorkspaces,a=this.props.options;return a.jsonData.cloudName=a.jsonData.cloudName||"azuremonitor",a.secureJsonData=a.secureJsonData||{},f.a.createElement(f.a.Fragment,null,f.a.createElement(Gt,{options:a,subscriptions:t,makeSameAs:this.makeSameAs,onLoadSubscriptions:this.onLoadSubscriptions,onUpdateJsonDataOption:this.updateJsonDataOption,onUpdateSecureJsonDataOption:this.updateSecureJsonDataOption,onResetOptionKey:this.resetSecureKey}),f.a.createElement($t,{options:a,workspaces:n,subscriptions:r,makeSameAs:this.makeSameAs,onUpdateDatasourceOptions:this.props.onOptionsChange,onUpdateJsonDataOption:this.updateJsonDataOption,onUpdateSecureJsonDataOption:this.updateSecureJsonDataOption,onResetOptionKey:this.resetSecureKey,onLoadSubscriptions:this.onLoadSubscriptions,onLoadWorkspaces:this.getWorkspaces}),f.a.createElement(ir,{options:a,onUpdateJsonDataOption:this.onUpdateJsonDataOption,onUpdateSecureJsonDataOption:this.onUpdateSecureJsonDataOption,onResetOptionKey:this.resetSecureKey}))}}])&&hr(r.prototype,a),i&&hr(r,i),t}(p.PureComponent);function vr(e,t,r,n,a,i,o){try{var s=e[i](o),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,a)}function br(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){vr(i,n,a,o,s,"next",e)}function s(e){vr(i,n,a,o,s,"throw",e)}o(void 0)}))}}function wr(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 xr=function(){function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.templateSrv=t,this.defaultQuery='<your table>\n| where $__timeFilter() \n| project TimeGenerated, Text=YourTitleColumn, Tags="tag1,tag2"',this.getAzureLogAnalyticsSchema=function(){return r.getWorkspaces().then((function(){return r.datasource.azureLogAnalyticsDatasource.getSchema(r.annotation.workspace)})).catch((function(){}))},this.onSubscriptionChange=function(){r.getWorkspaces(!0)},this.onLogAnalyticsQueryChange=function(e){r.annotation.rawQuery=e},this.annotation.queryType=this.annotation.queryType||"Azure Log Analytics",this.annotation.rawQuery=this.annotation.rawQuery||this.defaultQuery,this.initDropdowns()}var t,r,n,a,i,o;return e.$inject=["templateSrv"],t=e,(r=[{key:"initDropdowns",value:(o=br(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getSubscriptions();case 2:return e.next=4,this.getWorkspaces();case 4:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"getSubscriptions",value:(i=br(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.datasource.azureMonitorDatasource.isConfigured()){e.next=2;break}return e.abrupt("return");case 2:return e.abrupt("return",this.datasource.azureMonitorDatasource.getSubscriptions().then((function(e){t.subscriptions=e,t.annotation.subscription||"Azure Log Analytics"!==t.annotation.queryType||(t.annotation.subscription=t.datasource.azureLogAnalyticsDatasource.subscriptionId),!t.annotation.subscription&&t.subscriptions.length>0&&(t.annotation.subscription=t.subscriptions[0].value)})));case 3:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getWorkspaces",value:(a=br(regeneratorRuntime.mark((function e(t){var r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(!t&&this.workspaces&&this.workspaces.length>0)){e.next=2;break}return e.abrupt("return",this.workspaces);case 2:return e.abrupt("return",this.datasource.getAzureLogAnalyticsWorkspaces(this.annotation.subscription).then((function(e){return r.workspaces=e,e.length>0&&!r.annotation.workspace&&(r.annotation.workspace=e[0].value),r.workspaces})).catch((function(){})));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"templateVariables",get:function(){return this.templateSrv.getVariables().map((function(e){return"$"+e.name}))}}])&&wr(t.prototype,r),n&&wr(t,n),e}();xr.templateUrl="partials/annotations.editor.html",r.d(t,"plugin",(function(){return Sr}));var Sr=new n.DataSourcePlugin(xt).setConfigEditor(yr).setQueryCtrl(Me).setAnnotationQueryCtrl(xr)},sGFA:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));var n=function(e){var t=!1;return{promise:new Promise((function(r,n){e.then((function(e){return t?n({isCanceled:!0}):r(e)})),e.catch((function(e){return n(t?{isCanceled:!0}:e)}))})),cancel:function(){t=!0}}}}}]); //# sourceMappingURL=azureMonitorPlugin.2427a858f877b88b2243.js.map
修改文件时间
将文件时间修改为当前时间的前一年
删除文件