prometheus-query
Version:
A Javascript client for Prometheus query API
9 lines (8 loc) • 46.1 kB
JavaScript
/*!
* prometheus-query v3.5.1
* github.com/samber/prometheus-query-js
* (c) 2025 prometheus-query-js Contributors
* Released under the MIT License
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Prometheus={})}(this,(function(e){"use strict";function t(e,t){return function(){return e.apply(t,arguments)}}const{toString:r}=Object.prototype,{getPrototypeOf:n}=Object,{iterator:o,toStringTag:s}=Symbol,i=(a=Object.create(null),e=>{const t=r.call(e);return a[t]||(a[t]=t.slice(8,-1).toLowerCase())});var a;const c=e=>(e=e.toLowerCase(),t=>i(t)===e),l=e=>t=>typeof t===e,{isArray:u}=Array,f=l("undefined");function d(e){return null!==e&&!f(e)&&null!==e.constructor&&!f(e.constructor)&&m(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const h=c("ArrayBuffer");const p=l("string"),m=l("function"),y=l("number"),b=e=>null!==e&&"object"==typeof e,g=e=>{if("object"!==i(e))return!1;const t=n(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||s in e||o in e)},w=c("Date"),E=c("File"),O=c("Blob"),T=c("FileList"),S=c("URLSearchParams"),[R,v,A,x]=["ReadableStream","Request","Response","Headers"].map(c);function N(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,o;if("object"!=typeof e&&(e=[e]),u(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(d(e))return;const o=r?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let i;for(n=0;n<s;n++)i=o[n],t.call(null,e[i],i,e)}}function P(e,t){if(d(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n,o=r.length;for(;o-- >0;)if(n=r[o],t===n.toLowerCase())return n;return null}const j="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,C=e=>!f(e)&&e!==j;const U=(_="undefined"!=typeof Uint8Array&&n(Uint8Array),e=>_&&e instanceof _);var _;const L=c("HTMLFormElement"),F=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),q=c("RegExp"),k=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};N(r,((r,o)=>{let s;!1!==(s=t(r,o,e))&&(n[o]=s||r)})),Object.defineProperties(e,n)};const D=c("AsyncFunction"),B=(I="function"==typeof setImmediate,J=m(j.postMessage),I?setImmediate:J?(M=`axios@${Math.random()}`,G=[],j.addEventListener("message",(({source:e,data:t})=>{e===j&&t===M&&G.length&&G.shift()()}),!1),e=>{G.push(e),j.postMessage(M,"*")}):e=>setTimeout(e));var I,J,M,G;const z="undefined"!=typeof queueMicrotask?queueMicrotask.bind(j):"undefined"!=typeof process&&process.nextTick||B;var $={isArray:u,isArrayBuffer:h,isBuffer:d,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||m(e.append)&&("formdata"===(t=i(e))||"object"===t&&m(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&h(e.buffer),t},isString:p,isNumber:y,isBoolean:e=>!0===e||!1===e,isObject:b,isPlainObject:g,isEmptyObject:e=>{if(!b(e)||d(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:R,isRequest:v,isResponse:A,isHeaders:x,isUndefined:f,isDate:w,isFile:E,isBlob:O,isRegExp:q,isFunction:m,isStream:e=>b(e)&&m(e.pipe),isURLSearchParams:S,isTypedArray:U,isFileList:T,forEach:N,merge:function e(){const{caseless:t,skipUndefined:r}=C(this)&&this||{},n={},o=(o,s)=>{const i=t&&P(n,s)||s;g(n[i])&&g(o)?n[i]=e(n[i],o):g(o)?n[i]=e({},o):u(o)?n[i]=o.slice():r&&f(o)||(n[i]=o)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&N(arguments[e],o);return n},extend:(e,r,n,{allOwnKeys:o}={})=>(N(r,((r,o)=>{n&&m(r)?e[o]=t(r,n):e[o]=r}),{allOwnKeys:o}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,o)=>{let s,i,a;const c={};if(t=t||{},null==e)return t;do{for(s=Object.getOwnPropertyNames(e),i=s.length;i-- >0;)a=s[i],o&&!o(a,e,t)||c[a]||(t[a]=e[a],c[a]=!0);e=!1!==r&&n(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:i,kindOfTest:c,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(u(e))return e;let t=e.length;if(!y(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[o]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:L,hasOwnProperty:F,hasOwnProp:F,reduceDescriptors:k,freezeMethods:e=>{k(e,((t,r)=>{if(m(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];m(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach((e=>{r[e]=!0}))};return u(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:P,global:j,isContextDefined:C,isSpecCompliantForm:function(e){return!!(e&&m(e.append)&&"FormData"===e[s]&&e[o])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(b(e)){if(t.indexOf(e)>=0)return;if(d(e))return e;if(!("toJSON"in e)){t[n]=e;const o=u(e)?[]:{};return N(e,((e,t)=>{const s=r(e,n+1);!f(s)&&(o[t]=s)})),t[n]=void 0,o}}return e};return r(e,0)},isAsyncFn:D,isThenable:e=>e&&(b(e)||m(e))&&m(e.then)&&m(e.catch),setImmediate:B,asap:z,isIterable:e=>null!=e&&m(e[o])};function H(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o,this.status=o.status?o.status:null)}$.inherits(H,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:$.toJSONObject(this.config),code:this.code,status:this.status}}});const W=H.prototype,V={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{V[e]={value:e}})),Object.defineProperties(H,V),Object.defineProperty(W,"isAxiosError",{value:!0}),H.from=(e,t,r,n,o,s)=>{const i=Object.create(W);$.toFlatObject(e,i,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e));const a=e&&e.message?e.message:"Error",c=null==t&&e?e.code:t;return H.call(i,a,c,r,n,o),e&&null==i.cause&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};function K(e){return $.isPlainObject(e)||$.isArray(e)}function X(e){return $.endsWith(e,"[]")?e.slice(0,-2):e}function Q(e,t,r){return e?e.concat(t).map((function(e,t){return e=X(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}const Z=$.toFlatObject($,{},null,(function(e){return/^is[A-Z]/.test(e)}));function Y(e,t,r){if(!$.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=$.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!$.isUndefined(t[e])}))).metaTokens,o=r.visitor||l,s=r.dots,i=r.indexes,a=(r.Blob||"undefined"!=typeof Blob&&Blob)&&$.isSpecCompliantForm(t);if(!$.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if($.isDate(e))return e.toISOString();if($.isBoolean(e))return e.toString();if(!a&&$.isBlob(e))throw new H("Blob is not supported. Use a Buffer instead.");return $.isArrayBuffer(e)||$.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function l(e,r,o){let a=e;if(e&&!o&&"object"==typeof e)if($.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if($.isArray(e)&&function(e){return $.isArray(e)&&!e.some(K)}(e)||($.isFileList(e)||$.endsWith(r,"[]"))&&(a=$.toArray(e)))return r=X(r),a.forEach((function(e,n){!$.isUndefined(e)&&null!==e&&t.append(!0===i?Q([r],n,s):null===i?r:r+"[]",c(e))})),!1;return!!K(e)||(t.append(Q(o,r,s),c(e)),!1)}const u=[],f=Object.assign(Z,{defaultVisitor:l,convertValue:c,isVisitable:K});if(!$.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!$.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),$.forEach(r,(function(r,s){!0===(!($.isUndefined(r)||null===r)&&o.call(t,r,$.isString(s)?s.trim():s,n,f))&&e(r,n?n.concat(s):[s])})),u.pop()}}(e),t}function ee(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function te(e,t){this._pairs=[],e&&Y(e,this,t)}const re=te.prototype;function ne(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function oe(e,t,r){if(!t)return e;const n=r&&r.encode||ne;$.isFunction(r)&&(r={serialize:r});const o=r&&r.serialize;let s;if(s=o?o(t,r):$.isURLSearchParams(t)?t.toString():new te(t,r).toString(n),s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}re.append=function(e,t){this._pairs.push([e,t])},re.toString=function(e){const t=e?function(t){return e.call(this,t,ee)}:ee;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};class se{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){$.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}var ie={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ae={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:te,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ce="undefined"!=typeof window&&"undefined"!=typeof document,le="object"==typeof navigator&&navigator||void 0,ue=ce&&(!le||["ReactNative","NativeScript","NS"].indexOf(le.product)<0),fe="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,de=ce&&window.location.href||"http://localhost";var he={...Object.freeze({__proto__:null,hasBrowserEnv:ce,hasStandardBrowserEnv:ue,hasStandardBrowserWebWorkerEnv:fe,navigator:le,origin:de}),...ae};function pe(e){function t(e,r,n,o){let s=e[o++];if("__proto__"===s)return!0;const i=Number.isFinite(+s),a=o>=e.length;if(s=!s&&$.isArray(n)?n.length:s,a)return $.hasOwnProp(n,s)?n[s]=[n[s],r]:n[s]=r,!i;n[s]&&$.isObject(n[s])||(n[s]=[]);return t(e,r,n[s],o)&&$.isArray(n[s])&&(n[s]=function(e){const t={},r=Object.keys(e);let n;const o=r.length;let s;for(n=0;n<o;n++)s=r[n],t[s]=e[s];return t}(n[s])),!i}if($.isFormData(e)&&$.isFunction(e.entries)){const r={};return $.forEachEntry(e,((e,n)=>{t(function(e){return $.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,r,0)})),r}return null}const me={transitional:ie,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,o=$.isObject(e);o&&$.isHTMLForm(e)&&(e=new FormData(e));if($.isFormData(e))return n?JSON.stringify(pe(e)):e;if($.isArrayBuffer(e)||$.isBuffer(e)||$.isStream(e)||$.isFile(e)||$.isBlob(e)||$.isReadableStream(e))return e;if($.isArrayBufferView(e))return e.buffer;if($.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Y(e,new he.classes.URLSearchParams,{visitor:function(e,t,r,n){return he.isNode&&$.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((s=$.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Y(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||n?(t.setContentType("application/json",!1),function(e,t,r){if($.isString(e))try{return(t||JSON.parse)(e),$.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||me.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if($.isResponse(e)||$.isReadableStream(e))return e;if(e&&$.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e,this.parseReviver)}catch(e){if(r){if("SyntaxError"===e.name)throw H.from(e,H.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:he.classes.FormData,Blob:he.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};$.forEach(["delete","get","head","post","put","patch"],(e=>{me.headers[e]={}}));const ye=$.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const be=Symbol("internals");function ge(e){return e&&String(e).trim().toLowerCase()}function we(e){return!1===e||null==e?e:$.isArray(e)?e.map(we):String(e)}function Ee(e,t,r,n,o){return $.isFunction(n)?n.call(this,t,r):(o&&(t=r),$.isString(t)?$.isString(n)?-1!==t.indexOf(n):$.isRegExp(n)?n.test(t):void 0:void 0)}let Oe=class{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function o(e,t,r){const o=ge(t);if(!o)throw new Error("header name must be a non-empty string");const s=$.findKey(n,o);(!s||void 0===n[s]||!0===r||void 0===r&&!1!==n[s])&&(n[s||t]=we(e))}const s=(e,t)=>$.forEach(e,((e,r)=>o(e,r,t)));if($.isPlainObject(e)||e instanceof this.constructor)s(e,t);else if($.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))s((e=>{const t={};let r,n,o;return e&&e.split("\n").forEach((function(e){o=e.indexOf(":"),r=e.substring(0,o).trim().toLowerCase(),n=e.substring(o+1).trim(),!r||t[r]&&ye[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)})),t})(e),t);else if($.isObject(e)&&$.isIterable(e)){let r,n,o={};for(const t of e){if(!$.isArray(t))throw TypeError("Object iterator must return a key-value pair");o[n=t[0]]=(r=o[n])?$.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}s(o,t)}else null!=e&&o(t,e,r);return this}get(e,t){if(e=ge(e)){const r=$.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if($.isFunction(t))return t.call(this,e,r);if($.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ge(e)){const r=$.findKey(this,e);return!(!r||void 0===this[r]||t&&!Ee(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function o(e){if(e=ge(e)){const o=$.findKey(r,e);!o||t&&!Ee(0,r[o],o,t)||(delete r[o],n=!0)}}return $.isArray(e)?e.forEach(o):o(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const o=t[r];e&&!Ee(0,this[o],o,e,!0)||(delete this[o],n=!0)}return n}normalize(e){const t=this,r={};return $.forEach(this,((n,o)=>{const s=$.findKey(r,o);if(s)return t[s]=we(n),void delete t[o];const i=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(o):String(o).trim();i!==o&&delete t[o],t[i]=we(n),r[i]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return $.forEach(this,((r,n)=>{null!=r&&!1!==r&&(t[n]=e&&$.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[be]=this[be]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=ge(e);t[n]||(!function(e,t){const r=$.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+r,{value:function(e,r,o){return this[n].call(this,t,e,r,o)},configurable:!0})}))}(r,e),t[n]=!0)}return $.isArray(e)?e.forEach(n):n(e),this}};function Te(e,t){const r=this||me,n=t||r,o=Oe.from(n.headers);let s=n.data;return $.forEach(e,(function(e){s=e.call(r,s,o.normalize(),t?t.status:void 0)})),o.normalize(),s}function Se(e){return!(!e||!e.__CANCEL__)}function Re(e,t,r){H.call(this,null==e?"canceled":e,H.ERR_CANCELED,t,r),this.name="CanceledError"}function ve(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new H("Request failed with status code "+r.status,[H.ERR_BAD_REQUEST,H.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}Oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),$.reduceDescriptors(Oe.prototype,(({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}})),$.freezeMethods(Oe),$.inherits(Re,H,{__CANCEL__:!0});const Ae=(e,t,r=3)=>{let n=0;const o=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o,s=0,i=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),l=n[i];o||(o=c),r[s]=a,n[s]=c;let u=i,f=0;for(;u!==s;)f+=r[u++],u%=e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),c-o<t)return;const d=l&&c-l;return d?Math.round(1e3*f/d):void 0}}(50,250);return function(e,t){let r,n,o=0,s=1e3/t;const i=(t,s=Date.now())=>{o=s,r=null,n&&(clearTimeout(n),n=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-o;a>=s?i(e,t):(r=e,n||(n=setTimeout((()=>{n=null,i(r)}),s-a)))},()=>r&&i(r)]}((r=>{const s=r.loaded,i=r.lengthComputable?r.total:void 0,a=s-n,c=o(a);n=s;e({loaded:s,total:i,progress:i?s/i:void 0,bytes:a,rate:c||void 0,estimated:c&&i&&s<=i?(i-s)/c:void 0,event:r,lengthComputable:null!=i,[t?"download":"upload"]:!0})}),r)},xe=(e,t)=>{const r=null!=e;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},Ne=e=>(...t)=>$.asap((()=>e(...t)));var Pe=he.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,he.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(he.origin),he.navigator&&/(msie|trident)/i.test(he.navigator.userAgent)):()=>!0,je=he.hasStandardBrowserEnv?{write(e,t,r,n,o,s){const i=[e+"="+encodeURIComponent(t)];$.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),$.isString(n)&&i.push("path="+n),$.isString(o)&&i.push("domain="+o),!0===s&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Ce(e,t,r){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==r)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Ue=e=>e instanceof Oe?{...e}:e;function _e(e,t){t=t||{};const r={};function n(e,t,r,n){return $.isPlainObject(e)&&$.isPlainObject(t)?$.merge.call({caseless:n},e,t):$.isPlainObject(t)?$.merge({},t):$.isArray(t)?t.slice():t}function o(e,t,r,o){return $.isUndefined(t)?$.isUndefined(e)?void 0:n(void 0,e,0,o):n(e,t,0,o)}function s(e,t){if(!$.isUndefined(t))return n(void 0,t)}function i(e,t){return $.isUndefined(t)?$.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function a(r,o,s){return s in t?n(r,o):s in e?n(void 0,r):void 0}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(e,t,r)=>o(Ue(e),Ue(t),0,!0)};return $.forEach(Object.keys({...e,...t}),(function(n){const s=c[n]||o,i=s(e[n],t[n],n);$.isUndefined(i)&&s!==a||(r[n]=i)})),r}var Le=e=>{const t=_e({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Oe.from(i),t.url=oe(Ce(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),$.isFormData(r))if(he.hasStandardBrowserEnv||he.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if($.isFunction(r.getHeaders)){const e=r.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach((([e,r])=>{t.includes(e.toLowerCase())&&i.set(e,r)}))}if(he.hasStandardBrowserEnv&&(n&&$.isFunction(n)&&(n=n(t)),n||!1!==n&&Pe(t.url))){const e=o&&s&&je.read(s);e&&i.set(o,e)}return t};var Fe="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){const n=Le(e);let o=n.data;const s=Oe.from(n.headers).normalize();let i,a,c,l,u,{responseType:f,onUploadProgress:d,onDownloadProgress:h}=n;function p(){l&&l(),u&&u(),n.cancelToken&&n.cancelToken.unsubscribe(i),n.signal&&n.signal.removeEventListener("abort",i)}let m=new XMLHttpRequest;function y(){if(!m)return;const n=Oe.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());ve((function(e){t(e),p()}),(function(e){r(e),p()}),{data:f&&"text"!==f&&"json"!==f?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:n,config:e,request:m}),m=null}m.open(n.method.toUpperCase(),n.url,!0),m.timeout=n.timeout,"onloadend"in m?m.onloadend=y:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(y)},m.onabort=function(){m&&(r(new H("Request aborted",H.ECONNABORTED,e,m)),m=null)},m.onerror=function(t){const n=new H(t&&t.message?t.message:"Network Error",H.ERR_NETWORK,e,m);n.event=t||null,r(n),m=null},m.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const o=n.transitional||ie;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),r(new H(t,o.clarifyTimeoutError?H.ETIMEDOUT:H.ECONNABORTED,e,m)),m=null},void 0===o&&s.setContentType(null),"setRequestHeader"in m&&$.forEach(s.toJSON(),(function(e,t){m.setRequestHeader(t,e)})),$.isUndefined(n.withCredentials)||(m.withCredentials=!!n.withCredentials),f&&"json"!==f&&(m.responseType=n.responseType),h&&([c,u]=Ae(h,!0),m.addEventListener("progress",c)),d&&m.upload&&([a,l]=Ae(d),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",l)),(n.cancelToken||n.signal)&&(i=t=>{m&&(r(!t||t.type?new Re(null,e,m):t),m.abort(),m=null)},n.cancelToken&&n.cancelToken.subscribe(i),n.signal&&(n.signal.aborted?i():n.signal.addEventListener("abort",i)));const b=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);b&&-1===he.protocols.indexOf(b)?r(new H("Unsupported protocol "+b+":",H.ERR_BAD_REQUEST,e)):m.send(o||null)}))};const qe=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let r,n=new AbortController;const o=function(e){if(!r){r=!0,i();const t=e instanceof Error?e:this.reason;n.abort(t instanceof H?t:new Re(t instanceof Error?t.message:t))}};let s=t&&setTimeout((()=>{s=null,o(new H(`timeout ${t} of ms exceeded`,H.ETIMEDOUT))}),t);const i=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)})),e=null)};e.forEach((e=>e.addEventListener("abort",o)));const{signal:a}=n;return a.unsubscribe=()=>$.asap(i),a}},ke=function*(e,t){let r=e.byteLength;if(r<t)return void(yield e);let n,o=0;for(;o<r;)n=o+t,yield e.slice(o,n),o=n},De=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)break;yield r}}finally{await t.cancel()}},Be=(e,t,r,n)=>{const o=async function*(e,t){for await(const r of De(e))yield*ke(r,t)}(e,t);let s,i=0,a=e=>{s||(s=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await o.next();if(t)return a(),void e.close();let s=n.byteLength;if(r){let e=i+=s;r(e)}e.enqueue(new Uint8Array(n))}catch(e){throw a(e),e}},cancel:e=>(a(e),o.return())},{highWaterMark:2})},{isFunction:Ie}=$,Je=(({fetch:e,Request:t,Response:r})=>({fetch:e,Request:t,Response:r}))($.global),{ReadableStream:Me,TextEncoder:Ge}=$.global,ze=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},$e=e=>{const{fetch:t,Request:r,Response:n}=Object.assign({},Je,e),o=Ie(t),s=Ie(r),i=Ie(n);if(!o)return!1;const a=o&&Ie(Me),c=o&&("function"==typeof Ge?(l=new Ge,e=>l.encode(e)):async e=>new Uint8Array(await new r(e).arrayBuffer()));var l;const u=s&&a&&ze((()=>{let e=!1;const t=new r(he.origin,{body:new Me,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),f=i&&a&&ze((()=>$.isReadableStream(new n("").body))),d={stream:f&&(e=>e.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!d[e]&&(d[e]=(t,r)=>{let n=t&&t[e];if(n)return n.call(t);throw new H(`Response type '${e}' is not supported`,H.ERR_NOT_SUPPORT,r)})}));const h=async(e,t)=>{const n=$.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if($.isBlob(e))return e.size;if($.isSpecCompliantForm(e)){const t=new r(he.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return $.isArrayBufferView(e)||$.isArrayBuffer(e)?e.byteLength:($.isURLSearchParams(e)&&(e+=""),$.isString(e)?(await c(e)).byteLength:void 0)})(t):n};return async e=>{let{url:o,method:i,data:a,signal:c,cancelToken:l,timeout:p,onDownloadProgress:m,onUploadProgress:y,responseType:b,headers:g,withCredentials:w="same-origin",fetchOptions:E}=Le(e);b=b?(b+"").toLowerCase():"text";let O=qe([c,l&&l.toAbortSignal()],p),T=null;const S=O&&O.unsubscribe&&(()=>{O.unsubscribe()});let R;try{if(y&&u&&"get"!==i&&"head"!==i&&0!==(R=await h(g,a))){let e,t=new r(o,{method:"POST",body:a,duplex:"half"});if($.isFormData(a)&&(e=t.headers.get("content-type"))&&g.setContentType(e),t.body){const[e,r]=xe(R,Ae(Ne(y)));a=Be(t.body,65536,e,r)}}$.isString(w)||(w=w?"include":"omit");const c=s&&"credentials"in r.prototype,l={...E,signal:O,method:i.toUpperCase(),headers:g.normalize().toJSON(),body:a,duplex:"half",credentials:c?w:void 0};T=s&&new r(o,l);let p=await(s?t(T,E):t(o,l));const v=f&&("stream"===b||"response"===b);if(f&&(m||v&&S)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=p[t]}));const t=$.toFiniteNumber(p.headers.get("content-length")),[r,o]=m&&xe(t,Ae(Ne(m),!0))||[];p=new n(Be(p.body,65536,r,(()=>{o&&o(),S&&S()})),e)}b=b||"text";let A=await d[$.findKey(d,b)||"text"](p,e);return!v&&S&&S(),await new Promise(((t,r)=>{ve(t,r,{data:A,headers:Oe.from(p.headers),status:p.status,statusText:p.statusText,config:e,request:T})}))}catch(t){if(S&&S(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new H("Network Error",H.ERR_NETWORK,e,T),{cause:t.cause||t});throw H.from(t,t&&t.code,e,T)}}},He=new Map,We=e=>{let t=$.merge.call({skipUndefined:!0},Je,e?e.env:null);const{fetch:r,Request:n,Response:o}=t,s=[n,o,r];let i,a,c=s.length,l=He;for(;c--;)i=s[c],a=l.get(i),void 0===a&&l.set(i,a=c?new Map:$e(t)),l=a;return a};We();const Ve={http:null,xhr:Fe,fetch:{get:We}};$.forEach(Ve,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const Ke=e=>`- ${e}`,Xe=e=>$.isFunction(e)||null===e||!1===e;var Qe=(e,t)=>{e=$.isArray(e)?e:[e];const{length:r}=e;let n,o;const s={};for(let i=0;i<r;i++){let r;if(n=e[i],o=n,!Xe(n)&&(o=Ve[(r=String(n)).toLowerCase()],void 0===o))throw new H(`Unknown adapter '${r}'`);if(o&&($.isFunction(o)||(o=o.get(t))))break;s[r||"#"+i]=o}if(!o){const e=Object.entries(s).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new H("There is no suitable adapter to dispatch the request "+(r?e.length>1?"since :\n"+e.map(Ke).join("\n"):" "+Ke(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return o};function Ze(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Re(null,e)}function Ye(e){Ze(e),e.headers=Oe.from(e.headers),e.data=Te.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Qe(e.adapter||me.adapter,e)(e).then((function(t){return Ze(e),t.data=Te.call(e,e.transformResponse,t),t.headers=Oe.from(t.headers),t}),(function(t){return Se(t)||(Ze(e),t&&t.response&&(t.response.data=Te.call(e,e.transformResponse,t.response),t.response.headers=Oe.from(t.response.headers))),Promise.reject(t)}))}const et="1.12.0",tt={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{tt[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const rt={};tt.transitional=function(e,t,r){function n(e,t){return"[Axios v"+et+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,o,s)=>{if(!1===e)throw new H(n(o," has been removed"+(t?" in "+t:"")),H.ERR_DEPRECATED);return t&&!rt[o]&&(rt[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,o,s)}},tt.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};var nt={assertOptions:function(e,t,r){if("object"!=typeof e)throw new H("options must be an object",H.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const s=n[o],i=t[s];if(i){const t=e[s],r=void 0===t||i(t,s,e);if(!0!==r)throw new H("option "+s+" must be "+r,H.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new H("Unknown option "+s,H.ERR_BAD_OPTION)}},validators:tt};const ot=nt.validators;let st=class{constructor(e){this.defaults=e||{},this.interceptors={request:new se,response:new se}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const r=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?r&&!String(e.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+r):e.stack=r}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=_e(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:o}=t;void 0!==r&&nt.assertOptions(r,{silentJSONParsing:ot.transitional(ot.boolean),forcedJSONParsing:ot.transitional(ot.boolean),clarifyTimeoutError:ot.transitional(ot.boolean)},!1),null!=n&&($.isFunction(n)?t.paramsSerializer={serialize:n}:nt.assertOptions(n,{encode:ot.function,serialize:ot.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),nt.assertOptions(t,{baseUrl:ot.spelling("baseURL"),withXsrfToken:ot.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=o&&$.merge(o.common,o[t.method]);o&&$.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete o[e]})),t.headers=Oe.concat(s,o);const i=[];let a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,i.unshift(e.fulfilled,e.rejected))}));const c=[];let l;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let u,f=0;if(!a){const e=[Ye.bind(this),void 0];for(e.unshift(...i),e.push(...c),u=e.length,l=Promise.resolve(t);f<u;)l=l.then(e[f++],e[f++]);return l}u=i.length;let d=t;for(f=0;f<u;){const e=i[f++],t=i[f++];try{d=e(d)}catch(e){t.call(this,e);break}}try{l=Ye.call(this,d)}catch(e){return Promise.reject(e)}for(f=0,u=c.length;f<u;)l=l.then(c[f++],c[f++]);return l}getUri(e){return oe(Ce((e=_e(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};$.forEach(["delete","get","head","options"],(function(e){st.prototype[e]=function(t,r){return this.request(_e(r||{},{method:e,url:t,data:(r||{}).data}))}})),$.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,o){return this.request(_e(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}st.prototype[e]=t(),st.prototype[e+"Form"]=t(!0)}));const it={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(it).forEach((([e,t])=>{it[t]=e}));const at=function e(r){const n=new st(r),o=t(st.prototype.request,n);return $.extend(o,st.prototype,n,{allOwnKeys:!0}),$.extend(o,n,null,{allOwnKeys:!0}),o.create=function(t){return e(_e(r,t))},o}(me);at.Axios=st,at.CanceledError=Re,at.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const r=this;this.promise.then((e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,o){r.reason||(r.reason=new Re(e,n,o),t(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e((function(e){t=e})),cancel:t}}},at.isCancel=Se,at.VERSION=et,at.toFormData=Y,at.AxiosError=H,at.Cancel=at.CanceledError,at.all=function(e){return Promise.all(e)},at.spread=function(e){return function(t){return e.apply(null,t)}},at.isAxiosError=function(e){return $.isObject(e)&&!0===e.isAxiosError},at.mergeConfig=_e,at.AxiosHeaders=Oe,at.formToJSON=e=>pe($.isHTMLForm(e)?new FormData(e):e),at.getAdapter=Qe,at.HttpStatusCode=it,at.default=at;const{Axios:ct,AxiosError:lt,CanceledError:ut,isCancel:ft,CancelToken:dt,VERSION:ht,all:pt,Cancel:mt,isAxiosError:yt,spread:bt,toFormData:gt,AxiosHeaders:wt,HttpStatusCode:Et,formToJSON:Ot,getAdapter:Tt,mergeConfig:St}=at;var Rt;e.ResponseType=void 0,(Rt=e.ResponseType||(e.ResponseType={})).MATRIX="matrix",Rt.VECTOR="vector",Rt.SCALAR="scalar",Rt.STRING="string";class vt{constructor(e,t){if(e&&"string"!=typeof e)throw new Error("Wrong name format. Expected string.");if(t&&"object"!=typeof t)throw new Error("Wrong labels format. Expected object.");this.name=e,this.labels=t}static fromJSON(e){const t=e.__name__,r=Object.assign({},e);return delete r.__name__,new vt(t,r)}toString(){return(this.name?this.name:"")+"{"+Object.keys(this.labels).map((e=>e+'="'+this.labels[e]+'"')).join(", ")+"}"}}class At{constructor(e,t){if("object"!=typeof e||"Date"!=e.constructor.name)throw new Error("Wrong time format. Expected Date.");if("number"!=typeof t)throw new Error("Wrong value format. Expected float.");this.time=e,this.value=t}static fromJSON(e){const t=new Date(1e3*e[0]),r=parseFloat(e[1]);return new At(t,r)}toString(){return this.time+": "+this.value}}class xt{constructor(e,t){this.metric=e,this.values=t}static fromJSON(e){const t=e.metric?vt.fromJSON(e.metric):null,r=e.values.map(At.fromJSON);return new xt(t,r)}}class Nt{constructor(e,t){this.metric=e,this.value=t}static fromJSON(e){const t=e.metric?vt.fromJSON(e.metric):null,r=At.fromJSON(e.value);return new Nt(t,r)}}class Pt{constructor(e,t){this.resultType=e,this.result=t}static fromJSON(t){const r=t.resultType;let n=null;switch(r){case e.ResponseType.MATRIX:n=t.result.map(xt.fromJSON);break;case e.ResponseType.VECTOR:n=t.result.map(Nt.fromJSON);break;case e.ResponseType.SCALAR:case e.ResponseType.STRING:n=t.result;break;default:throw new Error(`Unexpected resultType: ${r}`)}return new Pt(r,n)}}class jt{constructor(e,t,r,n,o,s,i,a){if(e&&"object"!=typeof e)throw new Error(`Unexpected format for discoveredLabels. Got ${typeof e} instead of object`);if(t&&"object"!=typeof t)throw new Error(`Unexpected format for labels. Got ${typeof t} instead of object`);if(r&&"string"!=typeof r)throw new Error(`Unexpected format for scrapePool. Got ${typeof r} instead of string`);if(n&&"string"!=typeof n)throw new Error(`Unexpected format for scrapeUrl. Got ${typeof n} instead of string`);if(o&&"string"!=typeof o)throw new Error(`Unexpected format for lastError. Got ${typeof o} instead of string`);if(s&&("object"!=typeof s||"Date"!=s.constructor.name))throw new Error(`Unexpected format for lastScrape. Got ${typeof s} instead of object`);if(i&&"number"!=typeof i)throw new Error(`Unexpected format for lastScrapeDuration. Got ${typeof i} instead of number`);if(a&&"string"!=typeof a)throw new Error(`Unexpected format for health. Got ${typeof a} instead of string`);this.discoveredLabels=e,this.labels=t,this.scrapePool=r,this.scrapeUrl=n,this.lastError=o,this.lastScrape=s,this.lastScrapeDuration=i,this.health=a}static fromJSON(e){return new jt(e.discoveredLabels,e.labels,e.scrapePool,e.scrapeUrl,e.lastError,e.lastScrape?new Date(e.lastScrape):null,e.lastScrapeDuration?parseFloat(e.lastScrapeDuration):null,e.health)}}class Ct{constructor(e,t,r,n,o){if(e&&("object"!=typeof e||"Date"!=e.constructor.name))throw new Error(`Unexpected format for activeAt. Got ${typeof e} instead of object`);if(t&&"object"!=typeof t)throw new Error(`Unexpected format for annotations. Got ${typeof t} instead of object`);if(r&&"object"!=typeof r)throw new Error(`Unexpected format for labels. Got ${typeof r} instead of object`);if(o&&"number"!=typeof o)throw new Error(`Unexpected format for value. Got ${typeof o} instead of number`);this.activeAt=e,this.annotations=t,this.labels=r,this.state=n,this.value=o}static fromJSON(e){return new Ct(e.activeAt?new Date(e.activeAt):null,e.annotations,e.labels,e.state,e.value?parseFloat(e.value):null)}}class Ut{constructor(e,t,r,n,o,s,i,a){this.alerts=e,this.annotations=t,this.duration=r,this.health=n,this.labels=o,this.name=s,this.query=i,this.type=a}static fromJSON(e){return new Ut(e.alerts?e.alerts.map(Ct.fromJSON):[],e.annotations,e.duration,e.health,e.labels,e.name,e.query,e.type)}}class _t{constructor(e,t,r,n){this.rules=e,this.file=t,this.interval=r,this.name=n}static fromJSON(e){return new _t(e.rules?e.rules.map(Ut.fromJSON):[],e.file,e.interval,e.name)}}class Lt{constructor(){this.baseURL="/api/v1/",this.headers={},this.auth=null,this.proxy=null,this.withCredentials=!1,this.timeout=1e4,this.preferPost=!1,this.warningHook=null}}e.Alert=Ct,e.InstantVector=Nt,e.Metric=vt,e.PrometheusConnectionOptions=Lt,e.PrometheusDriver=class{constructor(e){if(this.listifyIfNeeded=e=>e instanceof Array?e:[e],this.formatPromQlParams=e=>Object.entries(null!=e?e:{}).reduce(((e,[t,r])=>(null!=r&&(r instanceof Array?r.filter((e=>null!=e)).forEach((r=>e.append(`${t}[]`,r))):e.append(t,r)),e)),new URLSearchParams),!(e=e||new Lt).endpoint)throw"Endpoint is required";e.endpoint=e.endpoint.replace(/\/$/,""),e.baseURL=e.baseURL||"/api/v1/",e.withCredentials=e.withCredentials||!1,e.timeout=e.timeout||1e4,this.options=e,this.axiosInstance=at.create(),this.options.requestInterceptor&&this.axiosInstance.interceptors.request.use(this.options.requestInterceptor.onFulfilled,this.options.requestInterceptor.onRejected),this.options.responseInterceptor&&this.axiosInstance.interceptors.response.use(this.options.responseInterceptor.onFulfilled,this.options.responseInterceptor.onRejected)}request(e,t,r,n){var o,s,i,a,c,l;const u=Object.assign({},this.options.headers||{});return this.axiosInstance.request({baseURL:this.options.endpoint+this.options.baseURL,url:t,method:e,params:this.formatPromQlParams(r),data:this.formatPromQlParams(n),headers:u,auth:(null===(o=this.options.auth)||void 0===o?void 0:o.username)&&(null===(s=this.options.auth)||void 0===s?void 0:s.password)?{username:this.options.auth.username,password:this.options.auth.password}:null,proxy:(null===(i=this.options.proxy)||void 0===i?void 0:i.host)&&(null===(a=this.options.proxy)||void 0===a?void 0:a.port)?{host:null===(c=this.options.proxy)||void 0===c?void 0:c.host,port:null===(l=this.options.proxy)||void 0===l?void 0:l.port}:null,withCredentials:this.options.withCredentials,timeout:this.options.timeout}).then((e=>this.handleResponse(e))).catch((e=>this.handleResponse(e,!0)))}handleResponse(e,t=!1){var r,n,o,s,i;const a=!0===(null==e?void 0:e.isAxiosError),c=t||a,l=a?e:void 0,u=a?l.response:c?null==e?void 0:e.response:e;if(!u){const t=null!==(r=null==l?void 0:l.code)&&void 0!==r?r:null==e?void 0:e.code,i=null!==(o=null!==(n=null==l?void 0:l.message)&&void 0!==n?n:null==e?void 0:e.message)&&void 0!==o?o:"unexpected network error";throw{status:"error",errorType:"ECONNABORTED"===t?"timeout_error":(null===(s=null==t?void 0:t.startsWith)||void 0===s?void 0:s.call(t,"ERR_SSL"))?"ssl_error":"network_error",error:i,code:t,original:e}}this.options.warningHook&&Array.isArray(u.warnings)&&u.warnings.length&&this.options.warningHook(u.warnings);const f=u.data;if(!f||null==f.status)throw{status:"error",errorType:"client_error",error:"unexpected client error",data:f};if(c)throw{status:"error",errorType:"http_error",httpStatus:u.status,error:null!==(i=f.error)&&void 0!==i?i:u.statusText,prometheus:f};return f.data}formatTimeToPrometheus(e,t){var r;if(e||(e=t),"number"==typeof e)return e/1e3;if("object"==typeof e&&"Date"==(null===(r=null==e?void 0:e.constructor)||void 0===r?void 0:r.name))return e.getTime()/1e3;throw new Error("Wrong time format. Expected number or Date.")}instantQuery(e,t,r){const n={query:e,time:this.formatTimeToPrometheus(t,new Date),timeout:r};return(this.options.preferPost?this.request("POST","query",null,n):this.request("GET","query",n)).then((e=>Pt.fromJSON(e)))}rangeQuery(e,t,r,n,o){const s={query:e,start:this.formatTimeToPrometheus(t),end:this.formatTimeToPrometheus(r),step:n,timeout:o};return(this.options.preferPost?this.request("POST","query_range",null,s):this.request("GET","query_range",s)).then((e=>Pt.fromJSON(e)))}series(e,t,r){const n={match:this.listifyIfNeeded(e),start:this.formatTimeToPrometheus(t),end:this.formatTimeToPrometheus(r)};return(this.options.preferPost?this.request("POST","series",null,n):this.request("GET","series",n)).then((e=>e.map(vt.fromJSON)))}labelNames(e,t,r){const n={match:this.listifyIfNeeded(e),start:t?this.formatTimeToPrometheus(t):void 0,end:r?this.formatTimeToPrometheus(r):void 0};return this.options.preferPost?this.request("POST","labels",null,n):this.request("GET","labels",n)}labelValues(e,t,r,n){const o={match:this.listifyIfNeeded(t),start:r?this.formatTimeToPrometheus(r):void 0,end:n?this.formatTimeToPrometheus(n):void 0};return this.request("GET",`label/${e}/values`,o)}targets(e){const t={query:e||"any"};return this.request("GET","targets",t).then((e=>({activeTargets:e.activeTargets?e.activeTargets.map(jt.fromJSON):[],droppedTargets:e.droppedTargets?e.droppedTargets.map(jt.fromJSON):[]})))}targetsMetadata(e,t,r){const n={match_target:e,metric:t,limit:r};return this.request("GET","targets/metadata",n)}metadata(e,t){const r={metric:e,limit:t};return this.request("GET","metadata",r)}rules(){return this.request("GET","rules").then((e=>(e.groups?e.groups:[]).map(_t.fromJSON)))}alerts(){return this.request("GET","alerts").then((e=>(e.alerts?e.alerts:[]).map(Ct.fromJSON)))}alertmanagers(){return this.request("GET","alertmanagers")}status(){return this.request("GET","status/config")}statusFlags(){return this.request("GET","status/flags")}statusRuntimeInfo(){return this.request("GET","status/runtimeinfo")}statusBuildinfo(){return this.request("GET","status/buildinfo")}statusTSDB(){return this.request("GET","status/tsdb")}adminSnapshot(e){const t={skip_head:e};return this.request("POST","admin/tsdb/snapshot",t)}adminDeleteSeries(e,t,r){const n={match:this.listifyIfNeeded(e),start:this.formatTimeToPrometheus(t),end:this.formatTimeToPrometheus(r)};return this.request("POST","admin/tsdb/delete_series",n)}adminCleanTombstones(){return this.request("POST","admin/tsdb/clean_tombstones")}},e.QueryResult=Pt,e.RangeVector=xt,e.Rule=Ut,e.RuleGroup=_t,e.SampleValue=At,e.Target=jt}));
//# sourceMappingURL=prometheus-query.umd.js.map