Files

210 lines
293 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{d as Q,t as wo,a as So,u as To,r as Eo,q as Ma,Q as yt,h as kt,T as D,y as x,b as e,x as Re,N as Ia,c as R,A as Z,e as b,k as q,f as Y,g as Mt,i as ct,$ as It,M as xo,D as Mr,I as Ao,j as me,F as yn,O as Lo,l as Dt,m as Ir,n as At,_ as ko,L as Dr,o as Mo,p as Da,H as Io,R as Do,s as fe,v as Ro}from"./vendor-BR6Q0Fin.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))a(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&a(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function a(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();Q.extend(wo);Q.extend(So);Q.extend(To);Q.extend(Eo);const K={home:"/",metrics:"/metrics",dashboards:"/dashboards",cardinality:"/cardinality",topQueries:"/top-queries",trace:"/trace",withTemplate:"/expand-with-exprs",relabel:"/relabeling",activeQueries:"/active-queries",queryAnalyzer:"/query-analyzer",icons:"/icons",query:"/query",rawQuery:"/raw-query",downsamplingDebug:"/downsampling-filters-debug",retentionDebug:"/retention-filters-debug",rules:"/rules",notifiers:"/notifiers"},Zr={header:{tenant:!0,stepControl:!0,timeSelector:!0,executionControls:{tooltip:"Refresh dashboard",useAutorefresh:!0}}},Wt={[K.home]:{title:"Query",...Zr},[K.rawQuery]:{title:"Raw query",header:{tenant:!0,stepControl:!1,timeSelector:!0,executionControls:{tooltip:"Refresh dashboard",useAutorefresh:!0}}},[K.metrics]:{title:"Explore Prometheus metrics",header:{tenant:!0,stepControl:!0,timeSelector:!0}},[K.cardinality]:{title:"Explore cardinality",header:{tenant:!0,cardinalityDatePicker:!0}},[K.topQueries]:{title:"Top queries",header:{tenant:!0}},[K.trace]:{title:"Trace analyzer",header:{}},[K.queryAnalyzer]:{title:"Query analyzer",header:{}},[K.dashboards]:{title:"Dashboards",...Zr},[K.rules]:{title:"Rules",header:{executionControls:{tooltip:"Refresh alerts",useAutorefresh:!1}}},[K.notifiers]:{title:"Notifiers",header:{executionControls:{tooltip:"Refresh notifiers",useAutorefresh:!1}}},[K.withTemplate]:{title:"WITH templates",header:{}},[K.relabel]:{title:"Metric relabel debug",header:{}},[K.activeQueries]:{title:"Active Queries",header:{}},[K.icons]:{title:"Icons",header:{}},[K.query]:{title:"Query",...Zr},[K.downsamplingDebug]:{title:"Downsampling filters debug",header:{}},[K.retentionDebug]:{title:"Retention filters debug",header:{}}},Kt=()=>{const t=document.getElementById("root")?.dataset.params||"{}";try{return JSON.parse(t)}catch(r){return console.error(r),{}}},Me=()=>!!Object.keys(Kt()).length,Po="VMUI:",$o=["AUTOCOMPLETE","NO_CACHE","QUERY_TRACING","SERIES_LIMITS","LEGEND_AUTO_COLLAPSE","TABLE_COMPACT","TIMEZONE","DISABLED_DEFAULT_TIMEZONE","THEME","EXPLORE_METRICS_TIPS","METRICS_QUERY_HISTORY","SERVER_URL","POINTS_SHOW_ALL"],_n=t=>`${Po}${t}`,Ne=(t,r,n=!0)=>{try{const a=n?_n(t):t;r?window.localStorage.setItem(a,JSON.stringify({value:r})):window.localStorage.removeItem(a),window.dispatchEvent(new Event("storage"))}catch(a){console.error(a)}},be=(t,r=!0)=>{const n=r?_n(t):t,a=window.localStorage.getItem(n);if(a!==null)try{return JSON.parse(a)?.value}catch{return a}},gr=(t,r=!0)=>{(r?t.map(_n):t).forEach(a=>window.localStorage.removeItem(a))},Oo=()=>{const t={migrated:[],removed:[],skipped:[]};for(const r of $o){const n=r,a=be(n,!1),s=be(n,!0);if(a===void 0){t.skipped.push(n);continue}if(s!==void 0){gr([n],!1),t.removed.push(n);continue}Ne(n,a,!0),gr([n],!1),t.migrated.push(n)}return t},Ho=t=>t.replace(/(\/(?:prometheus\/)?(?:graph|vmui)\/.*|\/#\/.*)/,"/prometheus"),zo=()=>{const{serverURL:t}=Kt(),r=be("SERVER_URL"),n=Ho(window.location.href);return t||r||n};var pe=(t=>(t.table="table",t.chart="chart",t.code="code",t))(pe||{}),ge=(t=>(t.emptyServer="Please enter Server URL",t.validServer="Please provide a valid Server URL",t.validQuery="Please enter a valid Query and execute it",t.traceNotFound="Not found the tracing information",t.emptyTitle="Please enter title",t.positiveNumber="Please enter positive number",t.validStep="Please enter a valid step",t.unknownType="Unknown server response format: must have 'errorType'",t))(ge||{}),Ve=(t=>(t.system="system",t.light="light",t.dark="dark",t))(Ve||{}),xe=(t=>(t.empty="empty",t.metricsql="metricsql",t.label="label",t.labelValue="labelValue",t))(xe||{});const tt=t=>getComputedStyle(document.documentElement).getPropertyValue(`--${t}`),Tt=(t,r)=>{document.documentElement.style.setProperty(`--${t}`,r)},br=()=>window.matchMedia("(prefers-color-scheme: dark)").matches,Fo=t=>t===Ve.system&&br()||t===Ve.dark,yr=t=>{let r;try{r=new URL(t)}catch{return!1}return r.protocol==="http:"||r.protocol==="https:"},Ra=t=>t.replace(/\/$/,""),Vo=(t,r)=>{if(Array.from(t.entries()).length!==Array.from(r.entries()).length)return!1;for(const[n,a]of t)if(r.get(n)!==a)return!1;return!0},Uo=t=>{try{const r=t.match(/\/api\/v1\/[^?]+/);return r?r[0]:null}catch(r){return console.error("Invalid URL:",r),null}},Cn=/(\/select\/)(\d+(?::\d+)?)(\/.*)?$/,qo=(t,r)=>t.replace(Cn,`$1${r}$3`),Pa=t=>t.match(Cn)?.[2]??"",Bo=t=>t.replace(Cn,""),na=Ra(zo()),Qo={serverUrl:na,tenantId:Pa(na),theme:be("THEME")||Ve.system,isDarkTheme:null,appConfig:{}};function jo(t,r){switch(r.type){case"SET_SERVER":return{...t,tenantId:Pa(r.payload),serverUrl:Ra(r.payload)};case"SET_THEME":return Ne("THEME",r.payload),{...t,theme:r.payload};case"SET_DARK_THEME":return{...t,isDarkTheme:Fo(t.theme)};case"SET_APP_CONFIG":return{...t,appConfig:r.payload};default:throw new Error}}const _r=10,$a=25,Oa={table:100,chart:20,code:1e3},Ha=100,Cr=[{id:"small",isDefault:!0,height:()=>window.innerHeight*.2},{id:"medium",height:()=>window.innerHeight*.4},{id:"large",height:()=>window.innerHeight*.8}],Nn=["min","median","max"],ue=(t,r)=>{const n=window.location.hash.split("?")[1];return Ma.parse(n,{ignoreQueryPrefix:!0})?.[t]||r||""},za=()=>{const r=(window.location.hash.split("?")[1]||"").match(/g\d+\.expr/g)?.length||1;return new Array(r>_r?_r:r).fill(1).map((n,a)=>ue(`g${a}.expr`,""))},wn=yt({}),ne=()=>Re(wn).state,Jt=()=>Re(wn).dispatch,Yo=Object.entries(Qo).reduce((t,[r,n])=>({...t,[r]:ue(r)||n}),{}),Go=({children:t})=>{const[r,n]=kt(jo,Yo),a=D(()=>({state:r,dispatch:n}),[r,n]);return x(()=>{if(!r.serverUrl)return;!!be("SERVER_URL")?Ne("SERVER_URL",r.serverUrl):gr(["SERVER_URL"])},[r.serverUrl]),e(wn.Provider,{value:a,children:t})},it="YYYY-MM-DD",qe="YYYY-MM-DD HH:mm:ss",Nr="YYYY-MM-DD HH:mm:ss:SSS (Z)",Rr="YYYY-MM-DD[T]HH:mm:ss",Fa="YYYY-MM-DD_HHmmss",Wo=["Africa/Abidjan","Africa/Accra","Africa/Addis_Ababa","Africa/Algiers","Africa/Asmera","Africa/Bamako","Africa/Bangui","Africa/Banjul","Africa/Bissau","Africa/Blantyre","Africa/Brazzaville","Africa/Bujumbura","Africa/Cairo","Africa/Casablanca","Africa/Ceuta","Africa/Conakry","Africa/Dakar","Africa/Dar_es_Salaam","Africa/Djibouti","Africa/Douala","Africa/El_Aaiun","Africa/Freetown","Africa/Gaborone","Africa/Harare","Africa/Johannesburg","Africa/Juba","Africa/Kampala","Africa/Khartoum","Africa/Kigali","Africa/Kinshasa","Africa/Lagos","Africa/Libreville","Africa/Lome","Africa/Luanda","Africa/Lubumbashi","Africa/Lusaka","Africa/Malabo","Africa/Maputo","Africa/Maseru","Africa/Mbabane","Africa/Mogadishu","Africa/Monrovia","Africa/Nairobi","Africa/Ndjamena","Africa/Niamey","Africa/Nouakchott","Africa/Ouagadougou","Africa/Porto-Novo","Africa/Sao_Tome","Africa/Tripoli","Africa/Tunis","Africa/Windhoek","America/Adak","America/Anchorage","America/Anguilla","America/Antigua","America/Araguaina","America/Argentina/La_Rioja","America/Argentina/Rio_Gallegos","America/Argentina/Salta","America/Argentina/San_Juan","America/Argentina/San_Luis","America/Argentina/Tucuman","America/Argentina/Ushuaia","America/Aruba","America/Asuncion","America/Bahia","America/Bahia_Banderas","America/Barbados","America/Belem","America/Belize","America/Blanc-Sablon","America/Boa_Vista","America/Bogota","America/Boise","America/Buenos_Aires","America/Cambridge_Bay","America/Campo_Grande","America/Cancun","America/Caracas","America/Catamarca","America/Cayenne","America/Cayman","America/Chicago","America/Chihuahua","America/Coral_Harbour","America/Cordoba","America/Costa_Rica","America/Creston","America/Cuiaba","America/Curacao","America/Danmarkshavn","America/Dawson","America/Dawson_Creek","America/Denver","America/Detroit","America/Dominica","America/Edmonton","America/Eirunepe","America/El_Salvador","America/Fort_Nelson","America/Fortaleza","America/Glace_Bay","America/Godthab","America/Goose_Bay","America/Grand_Turk","America/Grenada","America/Guadeloupe","America/Guatemala","America/Guayaquil","America/Guyana","America/Halifax","America/Havana","America/Hermosillo","America/Indiana/Knox","America/Indiana/Marengo","America/Indiana/Petersburg","America/Indiana/Tell_City","America/Indiana/Vevay","America/Indiana/Vincennes","America/Indiana/Winamac","America/Indianapolis","America/Inuvik","America/Iqaluit","America/Jamaica","America/Jujuy","America/Juneau","America/Kentucky/Monticello","America/Kralendijk","America/La_Paz","America/Lima","America/Los_Angeles","America/Louisville","America/Lower_Princes","America/Maceio","America/Managua","America/Manaus","America/Marigot","America/Martinique","America/Matamoros","America/Mazatlan","America/Mendoza","America/Menominee","America/Merida","America/Metlakatla","America/Mexico_City","America/Miquelon","America/Moncton","America/Monterrey","America/Montevideo","America/Montreal","America/Montserrat","America/Nassau","America/New_York","America/Nipigon","America/Nome","America/Noronha","America/North_Dakota/Beulah","America/North_Dakota/Center","America/North_Dakota/New_Salem","America/Ojinaga","America/Panama","America/Pangnirtung","America/Paramaribo","America/Phoenix","America/Port-au-Prince","America/Port_of_Spain","America/Porto_Velho","America/Puerto_Rico","America/Punta_Arenas","America/Rainy_River","America/Rankin_Inlet","America/Recife","America/Regina","America/Resolute","America/Rio_Branco","America/Santa_Isabel","America/Santarem","America/Santiago","America/Santo_Domingo","America/Sao_Paulo","America/Scoresbysund","America/Sitka","America/St_Barthelemy","America/St_Johns","America/St_Kitts","America/St_Lucia","America/St_Thomas","America/St_Vincent","America/Swift_Current","America/Tegucigalpa","America/Thule","America/Thunder_Bay","America/Tijuana","America/Toronto","America/Tortola","America/Vancouver","America/Whitehorse","America/Winnipeg","America/Yakutat","America/Yellowknife","Antarctica/Casey","Antarctica/Davis","Antarctica/DumontDUrville","Antarctica/Macquarie","Antarctica/Mawson","Antarctica/McMurdo","Antarctica/Palmer","Antarctica/Rothera","Antarctica/Syowa","Antarctica/Troll","Antarctica/Vostok","Arctic/Longyearbyen","Asia/Aden","Asia/Almaty","Asia/Amman","Asia/Anadyr","Asia/Aqtau","Asia/Aqtobe","Asia/Ashgabat","Asia/Atyrau","Asia/Baghdad","Asia/Bahrain","Asia/Baku","Asia/Bangkok","Asia/Barnaul","Asia/Beirut","Asia/Bishkek","Asia/Brunei","Asia/Calcutta","Asia/Chita","Asia/Choibalsan","Asia/Colombo","Asia/Damascus","Asia/Dhaka","Asia/Dili","Asia/Dubai","Asia/Dushanbe","Asia/Famagusta","Asia/Gaza","Asia/Hebron","Asia/Hong_Kong","Asia/Hovd","Asia/Irkutsk","Asia/Jakarta","Asia/Jayapura","Asia/Jerusalem","Asia/Kabul","Asia/Kamchatka","Asia/Karachi","Asia/Katmandu","Asia/Khandyga","Asia/Krasnoyarsk","Asia/Kuala_Lumpur","Asia/Kuching","Asia/Kuwait","Asia/Macau","Asia/Magadan","Asia/Makassar","Asia/Manila","Asia/Muscat","Asia/Nicosia","Asia/Novokuznetsk","Asia/Novosibirsk","Asia/Omsk","Asia/Oral","Asia/Phnom_Penh","Asia/Pontianak","Asia/Pyongyang","Asia/Qatar","Asia/Qostanay","Asia/Qyzylorda","Asia/Rangoon","Asia/Riyadh","Asia/Saigon","Asia/Sakhalin","Asia/Samarkand","Asia/Seoul","Asia/Shanghai","Asia/Singapore","Asia/Srednekolymsk","Asia/Taipei","Asia/Tashkent","Asia/Tbilisi","Asia/Tehran","Asia/Thimphu","Asia/Tokyo","Asia/Tomsk","Asia/Ulaanbaatar","Asia/Urumqi","Asia/Ust-Nera","Asia/Vientiane","Asia/Vladivostok","Asia/Yakutsk","Asia/Yekaterinburg","Asia/Yerevan","Atlantic/Azores","Atlantic/Bermuda","Atlantic/Canary","Atlantic/Cape_Verde","Atlantic/Faeroe","Atlantic/Madeira","Atlantic/Reykjavik","Atlantic/South_Georgia","Atlantic/St_Helena","Atlantic/Stanley","Australia/Adelaide","Australia/Brisbane","Australia/Broken_Hill","Australia/Currie","Australia/Darwin","Australia/Eucla","Australia/Hobart","Australia/Lindeman","Australia/Lord_Howe","Australia/Melbourne","Australia/Perth","Australia/Sydney","Europe/Amsterdam","Europe/Andorra","Europe/Astrakhan","Europe/Athens","Europe/Belgrade","Europe/Berlin","Europe/Bratislava","Europe/Brussels","Europe/Bucharest","Europe/Budapest","Europe/Busingen","Europe/Chisinau","Europe/Copenhagen","Europe/Dublin","Europe/Gibraltar","Europe/Guernsey","Europe/Helsinki","Europe/Isle_of_Man","Europe/Istanbul","Europe/Jersey","Europe/Kaliningrad","Europe/Kiev","Europe/Kirov","Europe/Lisbon","Europe/Ljubljana","Europe/London","Europe/Luxembourg","Europe/Madrid","Europe/Malta","Europe/Mariehamn","Europe/Minsk","Europe/Monaco","Europe/Moscow","Europe/Oslo","Europe/Paris","Europe/Podgorica","Europe/Prague","Europe/Riga","Europe/Rome","Europe/Samara","Europe/San_Marino","Europe/Sarajevo","Europe/Saratov","Europe/Simferopol","Europe/Skopje","Europe/Sofia","Europe/Stockholm","Europe/Tallinn","Europe/Tirane","Europe/Ulyanovsk","Europe/Uzhgorod","Europe/Vaduz","Europe/Vatican","Europe/Vienna","Europe/Vilnius","Europe/Volgograd","Europe/Warsaw","Europe/Zagreb","Europe/Zaporozhye","Europe/Zurich","Indian/Antananarivo","Indian/Chagos","Indian/Christmas","Indian/Cocos","Indian/Comoro","Indian/Kerguelen","Indian/Mahe","Indian/Maldives","Indian/Mauritius","Indian/Mayotte","Indian/Reunion","Pacific/Apia","Pacific/Auckland","Pacific/Bougainville","Pacific/Chatham","Pacific/Easter","Pacific/Efate","Pacific/Enderbury","Pacific/Fakaofo","Pacific/Fiji","Pacific/Funafuti","Pacific/Galapagos","Pacific/Gambier","Pacific/Guadalcanal","Pacific/Guam","Pacific/Honolulu","Pacific/Johnston","Pacific/Kiritimati","Pacific/Kosrae","Pacific/Kwajalein","Pacific/Majuro","Pacific/Marquesas","Pacific/Midway","Pacific/Nauru","Pacific/Niue","Pacific/Norfolk","Pacific/Noumea","Pacific/Pago_Pago","Pacific/Palau","Pacific/Pitcairn","Pacific/Ponape","Pacific/Port_Moresby","Pacific/Rarotonga","Pacific/Saipan","Pacific/Tahiti","Pacific/Tarawa","Pacific/Tongatapu","Pacific/Truk","Pacific/Wake","Pacific/Wallis"];function Va(t,r,n=0,a=t.length-1,s=Ko){for(;a>n;){if(a-n>600){const c=a-n+1,m=r-n+1,d=Math.log(c),u=.5*Math.exp(2*d/3),h=.5*Math.sqrt(d*u*(c-u)/c)*(m-c/2<0?-1:1),p=Math.max(n,Math.floor(r-m*u/c+h)),v=Math.min(a,Math.floor(r+(c-m)*u/c+h));Va(t,r,p,v,s)}const o=t[r];let i=n,l=a;for(zt(t,n,r),s(t[a],o)>0&&zt(t,n,a);i<l;){for(zt(t,i,l),i++,l--;s(t[i],o)<0;)i++;for(;s(t[l],o)>0;)l--}s(t[n],o)===0?zt(t,n,l):(l++,zt(t,l,a)),l<=r&&(n=l+1),r<=l&&(a=l-1)}}function zt(t,r,n){const a=t[r];t[r]=t[n],t[n]=a}function Ko(t,r){return t<r?-1:t>r?1:0}const je=t=>Math.round(t*1e3)/1e3,Jo=t=>{const r=t.length;if(r===0)return null;const n=r>>1;Va(t,n);const a=t[n];if(r&1)return a;let s=-1/0;for(let o=0;o<n;o++){const i=t[o];i>s&&(s=i)}return(s+a)/2},Ua=(t,r)=>{const n=!!r.min,a=!!r.max,s=!!r.avg,o=!!r.median;if(!n&&!a&&!s&&!o)return{min:null,max:null,median:null,avg:null};let i=1/0,l=-1/0,c=0,m=0;const d=[];for(const u of t)u==null||!Number.isFinite(u)||(n&&u<i&&(i=u),a&&u>l&&(l=u),s&&(m++,c+=(u-c)/m),o&&d.push(u));return{min:Number.isFinite(i)?i:null,max:Number.isFinite(l)?l:null,avg:m?c:null,median:d&&o?Jo(d):null}},Zo=window.innerWidth/4,Xo=window.innerWidth/40,aa={min:1,max:1578e8},sa=Intl.supportedValuesOf,ei=sa?sa("timeZone"):Wo,Sn=[{long:"years",short:"y",possible:"year"},{long:"weeks",short:"w",possible:"week"},{long:"days",short:"d",possible:"day"},{long:"hours",short:"h",possible:"hour"},{long:"minutes",short:"m",possible:"min"},{long:"seconds",short:"s",possible:"sec"},{long:"milliseconds",short:"ms",possible:"millisecond"}],ti=Sn.map(t=>t.short),ri=(t,r)=>je(t)===je(r),Tn=t=>$r(Q.duration(t,"seconds").asMilliseconds()),dn=t=>{let r=je(t);const n=Math.round(t);return t>=100&&(r=n-n%10),t<100&&t>=10&&(r=n-n%5),t<10&&t>=1&&(r=n),t<1&&t>.01&&(r=Math.round(t*40)/40),Tn(r||.001).replace(/\s/g,"")},qa=t=>{if(!t)return;const n=t.trim().replace(/,/g,".").match(/\d*\.?\d+\s*[a-zA-Z]+/g);if(!n)return;const a={};for(const s of n){const o=s.match(/\d*\.?\d+/)?.[0],i=s.match(/[a-zA-Z]+/)?.[0]?.toLowerCase();if(!o||!i||!ti.includes(i))return;a[i]=o}return Object.keys(a).length?a:void 0},En=t=>{const r=Sn.map(o=>o.short).join("|"),n=new RegExp(`\\d+(\\.\\d+)?[${r}]+`,"g"),s=(t.match(n)||[]).reduce((o,i)=>{const l=qa(i);return l?{...o,...l}:{...o}},{});return Q.duration(s).asSeconds()},ni=[pe.table,pe.code],Pr=(t,r,n)=>n&&ni.includes(n)?dn(t):dn(t/(r?Xo:Zo)),Et=(t,r)=>{const n=(r||Q().toDate()).valueOf()/1e3,a=En(t);return{start:n-a,end:n,step:Pr(a),date:Ba(r||Q().toDate())}},ai=t=>Q(t).utcOffset(0,!0).toDate(),Ba=t=>Q.tz(t).utc().format(Rr),Ut=t=>Q.tz(t).format(Rr),si=()=>Q().utc().format(Rr),$r=t=>{const r=Math.floor(t%1e3),n=Math.floor(t/1e3%60),a=Math.floor(t/1e3/60%60),s=Math.floor(t/1e3/3600%24),o=Math.floor(t/(1e3*60*60*24)),i=["d","h","m","s","ms"];return[o,s,a,n,r].map((c,m)=>c?`${c}${i[m]}`:"").filter(c=>c).join("")},oi=t=>{const r=t.to.valueOf()-t.from.valueOf();return $r(r)},Ye=t=>{const r=Q(t*1e3);return r.isValid()?r.toDate():new Date},ii=()=>Q().tz().subtract(1,"day").endOf("day").toDate(),li=()=>Q().tz().endOf("day").toDate(),wr=[{title:"Last 5 minutes",duration:"5m"},{title:"Last 15 minutes",duration:"15m"},{title:"Last 30 minutes",duration:"30m",isDefault:!0},{title:"Last 1 hour",duration:"1h"},{title:"Last 3 hours",duration:"3h"},{title:"Last 6 hours",duration:"6h"},{title:"Last 12 hours",duration:"12h"},{title:"Last 24 hours",duration:"24h"},{title:"Last 2 days",duration:"2d"},{title:"Last 7 days",duration:"7d"},{title:"Last 30 days",duration:"30d"},{title:"Last 90 days",duration:"90d"},{title:"Last 180 days",duration:"180d"},{title:"Last 1 year",duration:"1y"},{title:"Yesterday",duration:"1d",until:ii},{title:"Today",duration:"1d",until:li}].map(t=>({id:t.title.replace(/\s/g,"_").toLocaleLowerCase(),until:t.until?t.until:()=>Q().tz().toDate(),...t})),xn=({relativeTimeId:t,defaultDuration:r,defaultEndInput:n})=>{const a=wr.find(i=>i.isDefault)?.id,s=t||ue("g0.relative_time",a),o=wr.find(i=>i.id===s);return{relativeTimeId:o?s:"none",duration:o?o.duration:r,endInput:o?o.until():n}},qt=t=>`UTC${Q().tz(t).format("Z")}`,oa=(t="")=>{const r=new RegExp(t,"i");return ei.reduce((n,a)=>{const s=(a.match(/^(.*?)\//)||[])[1]||"unknown",o=qt(a),i=o.replace(/UTC|0/,""),l=a.replace(/[/_]/g," "),c={region:a,utc:o,search:`${a} ${o} ${l} ${i}`},m=!t||t&&r.test(c.search);return m&&n[s]?n[s].push(c):m&&(n[s]=[c]),n},{})},Qa=t=>{Q.tz.setDefault(t)},ci=t=>{try{return Q().tz(t),!0}catch{return!1}},An=()=>{const t=Q.tz.guess(),r=ci(t);return{isValid:r,title:r?`Browser Time (${t})`:"Browser timezone (UTC)",region:r?t:"UTC"}},ia=t=>{if(!t)return 0n;const r=Q(t).valueOf();if(!t.includes("."))return BigInt(r)*1000000n;const n=t.match(/\.(\d+)Z/);if(!n)return BigInt(r)*1000000n;let a=n[1];a=a.padEnd(9,"0");const s=parseInt(a.slice(3),10);return BigInt(r)*1000000n+BigInt(s)},ja=be("TIMEZONE")||An().region;Qa(ja);const Ya=()=>{const t=ue("g0.range_input"),{duration:r,endInput:n,relativeTimeId:a}=xn({defaultDuration:t||"1h",defaultEndInput:ai(ue("g0.end_input",si())),relativeTimeId:t?ue("g0.relative_time","none"):void 0});return{duration:r,period:Et(r,n),relativeTime:a}},di={...Ya(),timezone:ja};function mi(t,r){switch(r.type){case"SET_TIME_STATE":return{...t,...r.payload};case"SET_DURATION":return{...t,duration:r.payload,period:Et(r.payload,Ye(t.period.end)),relativeTime:"none"};case"SET_RELATIVE_TIME":return{...t,duration:r.payload.duration,period:Et(r.payload.duration,r.payload.until),relativeTime:r.payload.id};case"SET_PERIOD":const n=oi(r.payload);return{...t,duration:n,period:Et(n,r.payload.to),relativeTime:"none"};case"RUN_QUERY":const{duration:a,endInput:s}=xn({relativeTimeId:t.relativeTime,defaultDuration:t.duration,defaultEndInput:Ye(t.period.end)});return{...t,period:Et(a,s)};case"RUN_QUERY_TO_NOW":return{...t,period:Et(t.duration)};case"SET_TIMEZONE":return Qa(r.payload),Ne("TIMEZONE",r.payload),t.defaultTimezone&&Ne("DISABLED_DEFAULT_TIMEZONE",r.payload!==t.defaultTimezone),{...t,timezone:r.payload};case"SET_DEFAULT_TIMEZONE":return{...t,defaultTimezone:r.payload};default:throw new Error}}const Ln=yt({}),he=()=>Re(Ln).state,Ge=()=>Re(Ln).dispatch,ui=({children:t})=>{const[r,n]=kt(mi,di),a=D(()=>({state:r,dispatch:n}),[r,n]);return e(Ln.Provider,{value:a,children:t})},Or=t=>{const r=be(t);return r?JSON.parse(r):{}},hi=(t,r,n)=>{const a=Or(t);Ne(t,JSON.stringify({...a,[r]:n}))},Ft=(t,r)=>Or(t)[r]||[],pi=(t,r)=>{const n=r.map(c=>c.values[c.index]),a=Or(t),s=a.QUERY_HISTORY||[];s[0]||(s[0]=[]);const o=s[0],i=$a*_r;n.forEach(c=>{!o.includes(c)&&c&&o.unshift(c),o.length>i&&o.pop()});const l={...a,QUERY_HISTORY:[o]};Ne(t,JSON.stringify(l))},vi=(t,r)=>{hi(t,"QUERY_FAVORITES",r)},fi=(t,r)=>{const n=Or(t);Ne(t,JSON.stringify({...n,[r]:[]}))},gi=(t,r)=>{const n=r||{values:[]},a=t===n.values[n.values.length-1],s=!a&&t?[...n.values,t]:n.values;return s.length>$a&&s.shift(),{index:n.values.length-Number(a),values:s}},Sr={displayResults:50,queryLimit:1e3,cacheLimit:1e3};class bi{maxSize;map;constructor(){this.maxSize=Sr.cacheLimit,this.map=new Map}get(r){for(const[n,a]of this.map){const s=JSON.parse(n),o=s.start===r.start&&s.end===r.end,i=s.type===r.type,l=r.value&&s.value&&r.value.includes(s.value),c=s.match===r.match||l,m=a.length<Sr.queryLimit;if(c&&o&&i&&m)return a}return this.map.get(JSON.stringify(r))}put(r,n){if(this.map.size>=this.maxSize){const a=this.map.keys().next().value;a&&this.map.delete(a)}this.map.set(JSON.stringify(r),n)}}const la=za(),yi={query:la,queryHistory:la.map(t=>({index:0,values:[t]})),autocomplete:be("AUTOCOMPLETE")||!1,autocompleteQuick:!1,autocompleteCache:new bi,metricsQLFunctions:[]};function _i(t,r){switch(r.type){case"SET_QUERY":return{...t,query:r.payload.map(n=>n)};case"SET_QUERY_HISTORY":return pi(r.payload.key,r.payload.history),{...t,queryHistory:r.payload.history};case"SET_QUERY_HISTORY_BY_INDEX":return t.queryHistory.splice(r.payload.queryNumber,1,r.payload.value),{...t,queryHistory:t.queryHistory};case"TOGGLE_AUTOCOMPLETE":return Ne("AUTOCOMPLETE",!t.autocomplete),{...t,autocomplete:!t.autocomplete};case"SET_AUTOCOMPLETE_QUICK":return{...t,autocompleteQuick:r.payload};case"SET_AUTOCOMPLETE_CACHE":return t.autocompleteCache.put(r.payload.key,r.payload.value),{...t};case"SET_METRICSQL_FUNCTIONS":return{...t,metricsQLFunctions:r.payload};default:throw new Error}}const kn=yt({}),Pe=()=>Re(kn).state,Zt=()=>Re(kn).dispatch,Ci=({children:t})=>{const[r,n]=kt(_i,yi),a=D(()=>({state:r,dispatch:n}),[r,n]);return e(kn.Provider,{value:a,children:t})},Ga=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M10.975 14.51a1.05 1.05 0 0 0 0-1.485 2.95 2.95 0 0 1 0-4.172l3.536-3.535a2.95 2.95 0 1 1 4.172 4.172l-1.093 1.092a1.05 1.05 0 0 0 1.485 1.485l1.093-1.092a5.05 5.05 0 0 0-7.142-7.142L9.49 7.368a5.05 5.05 0 0 0 0 7.142c.41.41 1.075.41 1.485 0m2.05-5.02a1.05 1.05 0 0 0 0 1.485 2.95 2.95 0 0 1 0 4.172l-3.5 3.5a2.95 2.95 0 1 1-4.171-4.172l1.025-1.025a1.05 1.05 0 0 0-1.485-1.485L3.87 12.99a5.05 5.05 0 0 0 7.142 7.142l3.5-3.5a5.05 5.05 0 0 0 0-7.142 1.05 1.05 0 0 0-1.485 0z"})}),Wa=()=>e("svg",{fill:"currentColor",viewBox:"0 0 512 512",children:e("path",{d:"M170.667 64v42.667h-64v298.666h64V448H64V64zM448 64v384H341.333v-42.667h64V106.667h-64V64zm-85.333 256v42.667H149.333V320zm0-85.333v42.666H149.333v-42.666zm0-85.334V192H149.333v-42.667z"})}),Hr=()=>e("svg",{fill:"currentColor",viewBox:"0 0 20 20",children:e("path",{d:"M12 3a2 2 0 1 0-4 0 2 2 0 0 0 4 0m-2 5a2 2 0 1 1 0 4 2 2 0 0 1 0-4m0 7a2 2 0 1 1 0 4 2 2 0 0 1 0-4"})}),Ka=()=>e("svg",{viewBox:"-1 0 30 30",fill:"currentColor",children:e("path",{d:"m3 24 3-6v-8a8 8 0 0 1 16 0v8l3 6zm11 4a2.99 2.99 0 0 1-2.816-2h5.632A2.99 2.99 0 0 1 14 28m10-10v-8c0-5.522-4.478-10-10-10S4 4.478 4 10v8l-4 8h9.101a5 5 0 0 0 9.798 0H28z"})}),Ja=()=>e("svg",{viewBox:"411.014 448.582 21.637 17.836",fill:"currentColor",children:e("path",{d:"M411.47 453.837a.72.72 0 0 0-.422.679c0 .319.137.535.422.667.139.065.322.068 3.814.069l3.668.001.164-.083c.484-.245.535-.904.096-1.254l-.141-.112-3.746-.008c-3.05-.006-3.766.001-3.855.041m-.016 5.54c-.284.124-.44.372-.439.701.001.354.204.614.553.708.092.025 1.214.034 3.267.028 3.481-.011 3.23.008 3.468-.264a.714.714 0 0 0-.003-.963c-.249-.283-.03-.267-3.564-.266-2.735 0-3.171.008-3.282.056m-.018 5.016a.72.72 0 0 0-.422.679c0 .319.137.535.422.667.139.065.322.068 3.814.069l3.668.001.164-.083c.484-.245.535-.904.096-1.254l-.141-.112-3.746-.008c-3.05-.006-3.766.001-3.855.041m.161-15.761a.85.85 0 0 0-.389.417c-.023.07-.034.224-.026.343.018.239.078.345.301.525l.139.112 8.729.01 8.73.009.163-.079c.193-.093.36-.332.395-.565a.75.75 0 0 0-.388-.75c-.142-.072-.227-.073-8.844-.072-7.105.002-8.721.011-8.81.05m14.005 2.595c-.286.18-.371.401-.371.961v.334l-.499.024c-.598.028-.961.126-1.456.392a3.5 3.5 0 0 0-1.721 2.199c-.081.307-.091.479-.115 1.923-.027 1.566-.028 1.59-.138 1.966-.145.496-.557 1.361-.929 1.945a5 5 0 0 0-.368.677c-.1.292-.095.679.013.982.112.32.461.686.75.789.276.099 1.255.259 2.268.373l.84.095.028.287q.089.935.767 1.579a2.383 2.383 0 0 0 3.659-.434c.227-.351.36-.745.396-1.161l.023-.283.291-.027c.956-.093 2.47-.32 2.715-.408.393-.14.694-.464.817-.875.16-.539.093-.833-.354-1.554-.373-.601-.832-1.565-.956-2.007-.083-.29-.093-.448-.119-1.903-.027-1.427-.039-1.619-.118-1.924a3.5 3.5 0 0 0-1.895-2.327c-.422-.202-.758-.282-1.309-.312l-.489-.025-.022-.473c-.022-.521-.062-.621-.325-.806-.124-.088-.182-.096-.69-.096-.489.001-.57.012-.693.089m2.696 2.786c.546.176.994.583 1.249 1.135l.149.326.025 1.543c.027 1.672.046 1.837.286 2.598.166.52.621 1.468.974 2.028.189.303.274.472.244.492-.104.066-1.778.288-2.915.387-.788.068-3.246.068-4.037 0-1.154-.099-2.811-.32-2.919-.39-.035-.023.03-.16.223-.469.375-.603.805-1.493.976-2.024.246-.763.272-1 .272-2.426 0-.701.019-1.398.043-1.549.083-.554.47-1.148.931-1.429.103-.063.308-.157.453-.209.258-.092.315-.094 2.025-.096 1.642-.001 1.776.005 2.021.083m-1.384 10.771a1.06 1.06 0 0 1-.748.2c-.394-.066-.776-.451-.835-.841l-.026-.168h2.005v.108z"})}),Za=()=>e("svg",{viewBox:"411.014 448.582 23.358 18.492",fill:"currentColor",children:[e("path",{d:"M411.47 453.837a.72.72 0 0 0-.422.679c0 .319.137.535.422.667.139.065.322.068 3.814.069l3.668.001.164-.083c.484-.245.535-.904.096-1.254l-.141-.112-3.746-.008c-3.05-.006-3.766.001-3.855.041m15.967 7.103a1.592 1.612 0 1 1 1.592-1.612 1.592 1.612 0 0 1-1.592 1.612m0-1.612"}),e("path",{d:"M427.405 466.377a6.966 7.052 0 1 1 6.965-7.053 6.974 7.06 0 0 1-6.965 7.053m0-12.09a4.975 5.037 0 1 0 4.975 5.037 4.981 5.043 0 0 0-4.975-5.037"}),e("path",{d:"M421.832 467.074a.996 1.008 0 0 1-.708-1.715l3.582-3.675a.995 1.008 0 0 1 1.417 1.415l-3.582 3.675a.995 1.007 0 0 1-.709.3m-10.378-7.697c-.284.124-.44.372-.439.701.001.354.204.614.553.708.092.025 1.214.034 3.267.028 3.481-.011 3.23.008 3.468-.264a.714.714 0 0 0-.003-.963c-.249-.283-.03-.267-3.564-.266-2.735 0-3.171.008-3.282.056m-.018 5.016a.72.72 0 0 0-.422.679c0 .319.137.535.422.667.139.065.322.068 3.814.069l3.668.001.164-.083c.484-.245.535-.904.096-1.254l-.141-.112-3.746-.008c-3.05-.006-3.766.001-3.855.041m.161-15.761a.85.85 0 0 0-.389.417c-.023.07-.034.224-.026.343.018.239.078.345.301.525l.139.112 8.729.01 8.73.009.163-.079c.193-.093.36-.332.395-.565a.75.75 0 0 0-.388-.75c-.142-.072-.227-.073-8.844-.072-7.105.002-8.721.011-8.81.05"})]}),Xa=()=>e("svg",{viewBox:"0 0 74 24",fill:"currentColor",children:e("path",{d:"M6.12 10.48c.36.28.8.43 1.26.43h.05c.48 0 .96-.19 1.25-.44 1.5-1.28 5.88-5.29 5.88-5.29C15.73 4.1 12.46 3.01 7.43 3h-.06C2.33 3-.93 4.1.24 5.18c0 0 4.37 4 5.88 5.3Zm2.56 2.16c-.36.28-.8.44-1.26.45h-.04c-.46 0-.9-.17-1.26-.45-1.04-.88-4.74-4.22-6.12-5.5v1.94c0 .21.08.5.22.63l.07.06c1.05.96 4.55 4.16 5.83 5.25.36.28.8.43 1.26.44h.04c.49-.02.96-.2 1.26-.44 1.3-1.11 4.94-4.45 5.88-5.31.15-.14.23-.42.23-.63V7.15a454.94 454.94 0 0 1-6.11 5.5Zm-1.26 4.99c.46 0 .9-.16 1.26-.44a454.4 454.4 0 0 0 6.1-5.5v1.94c0 .2-.07.48-.22.62-.94.87-4.57 4.2-5.88 5.3-.3.26-.77.44-1.26.45h-.04c-.46 0-.9-.16-1.26-.44-1.2-1.02-4.38-3.92-5.62-5.06l-.28-.25c-.14-.14-.22-.42-.22-.62v-1.94c1.38 1.26 5.08 4.6 6.12 5.5.36.28.8.43 1.26.44h.04ZM35 5l-5.84 14.46h-2.43L20.89 5h2.16a.9.9 0 0 1 .9.61l3.41 8.82a18.8 18.8 0 0 1 .62 2.02 19.44 19.44 0 0 1 .57-2.02l3.39-8.82c.05-.15.16-.3.31-.42a.9.9 0 0 1 .58-.19H35Zm17.18 0v14.46H49.8v-9.34c0-.37.02-.78.06-1.21l-4.37 8.21c-.21.4-.53.59-.95.59h-.38c-.43 0-.75-.2-.95-.59L38.8 8.88a22.96 22.96 0 0 1 .07 1.24v9.34H36.5V5h2.03l.3.01c.1 0 .17.02.24.05.07.03.13.07.19.13a1 1 0 0 1 .17.24l4.33 8.03a16.97 16.97 0 0 1 .6 1.36 14.34 14.34 0 0 1 .6-1.38l4.28-8.01c.05-.1.1-.18.17-.24.06-.06.12-.1.19-.13a.9.9 0 0 1 .24-.05l.3-.01h2.04Zm8.88 13.73a4.5 4.5 0 0 0 1.82-.35 3.96 3.96 0 0 0 2.22-2.47c.2-.57.3-1.19.3-1.85V5.31h1.02v8.75c0 .78-.12 1.51-.37 2.19a4.88 4.88 0 0 1-2.76 2.95c-.66.29-1.4.43-2.23.43-.82 0-1.57-.14-2.24-.43a5.01 5.01 0 0 1-2.75-2.95 6.37 6.37 0 0 1-.37-2.19V5.31h1.03v8.74c0 .66.1 1.28.3 1.85a3.98 3.98 0 0 0 2.21 2.47c.53.24 1.14.36 1.82.36Zm10.38.73h-1.03V5.31h1.03v14.15Z"})}),es=()=>e("svg",{viewBox:"0 0 15 17",fill:"currentColor",children:e("path",{d:"M6.11767 7.47586C6.47736 7.75563 6.91931 7.90898 7.37503 7.91213H7.42681C7.90756 7.90474 8.38832 7.71987 8.67677 7.46846C10.1856 6.18921 14.5568 2.18138 14.5568 2.18138C15.7254 1.09438 12.4637 0.00739 7.42681 0H7.36764C2.3308 0.00739 -0.930935 1.09438 0.237669 2.18138C0.237669 2.18138 4.60884 6.18921 6.11767 7.47586ZM8.67677 9.64243C8.31803 9.92483 7.87599 10.0808 7.41941 10.0861H7.37503C6.91845 10.0808 6.47641 9.92483 6.11767 9.64243C5.0822 8.75513 1.38409 5.42018 0.000989555 4.14832V6.07829C0.000989555 6.29273 0.0823481 6.57372 0.222877 6.70682L0.293316 6.7712L0.293344 6.77122C1.33784 7.72579 4.83903 10.9255 6.11767 12.0161C6.47641 12.2985 6.91845 12.4545 7.37503 12.4597H7.41941C7.90756 12.4449 8.38092 12.2601 8.67677 12.0161C9.9859 10.9069 13.6249 7.57198 14.5642 6.70682C14.7121 6.57372 14.7861 6.29273 14.7861 6.07829V4.14832C12.7662 5.99804 10.7297 7.82949 8.67677 9.64243ZM7.41941 14.6263C7.87513 14.6232 8.31708 14.4698 8.67677 14.19C10.7298 12.3746 12.7663 10.5407 14.7861 8.68853V10.6259C14.7861 10.8329 14.7121 11.1139 14.5642 11.247C13.6249 12.1196 9.9859 15.4471 8.67677 16.5563C8.38092 16.8077 7.90756 16.9926 7.41941 17H7.37503C6.91931 16.9968 6.47736 16.8435 6.11767 16.5637C4.91427 15.5373 1.74219 12.6364 0.502294 11.5025C0.393358 11.4029 0.299337 11.3169 0.222877 11.247C0.0823481 11.1139 0.000989555 10.8329 0.000989555 10.6259V8.68853C1.38409 9.95303 5.0822 13.2953 6.11767 14.1827C6.47641 14.4651 6.91845 14.6211 7.37503 14.6263H7.41941Z"})}),vt=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"})}),De=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})}),ft=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8zm-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91z"})}),lt=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"})}),Xt=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8"})}),Mn=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"})}),ts=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})}),rs=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"})}),Qt=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z"})}),Ae=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"})}),Xe=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"m7 10 5 5 5-5z"})}),jt=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:[e("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),e("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"})]}),Tr=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 18H4V8h16v13z"})}),ns=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"m22 5.72-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM7.88 3.39 6.6 1.86 2 5.71l1.29 1.53 4.59-3.85zM12.5 8H11v6l4.75 2.85.75-1.23-4-2.37V8zM12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9c4.97 0 9-4.03 9-9s-4.03-9-9-9zm0 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"})}),as=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-9 3h2v2h-2V8zm0 3h2v2h-2v-2zM8 8h2v2H8V8zm0 3h2v2H8v-2zm-1 2H5v-2h2v2zm0-3H5V8h2v2zm9 7H8v-2h8v2zm0-4h-2v-2h2v2zm0-3h-2V8h2v2zm3 3h-2v-2h2v2zm0-3h-2V8h2v2z"})}),dt=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M8 5v14l11-7z"})}),zr=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"m10 16.5 6-4.5-6-4.5v9zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"})}),In=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"m3.5 18.49 6-6.01 4 4L22 6.92l-1.41-1.41-7.09 7.97-4-4L2 16.99z"})}),Fr=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M10 10.02h5V21h-5zM17 21h3c1.1 0 2-.9 2-2v-9h-5v11zm3-18H5c-1.1 0-2 .9-2 2v3h19V5c0-1.1-.9-2-2-2zM3 19c0 1.1.9 2 2 2h3V10H3v9z"})}),er=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M9.4 16.6 4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0 4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"})}),Vr=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})}),Dn=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"})}),ss=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M19 13H5v-2h14v2z"})}),Ur=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M8.9999 14.7854L18.8928 4.8925C19.0803 4.70497 19.3347 4.59961 19.5999 4.59961C19.8651 4.59961 20.1195 4.70497 20.307 4.8925L21.707 6.2925C22.0975 6.68303 22.0975 7.31619 21.707 7.70672L9.70701 19.7067C9.31648 20.0972 8.68332 20.0972 8.2928 19.7067L2.6928 14.1067C2.50526 13.9192 2.3999 13.6648 2.3999 13.3996C2.3999 13.1344 2.50526 12.88 2.6928 12.6925L4.0928 11.2925C4.48332 10.902 5.11648 10.902 5.50701 11.2925L8.9999 14.7854Z"})}),Rn=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"})}),os=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"})}),is=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M19 9l1.25-2.75L23 5l-2.75-1.25L19 1l-1.25 2.75L15 5l2.75 1.25L19 9zm-7.5.5L9 4 6.5 9.5 1 12l5.5 2.5L9 20l2.5-5.5L17 12l-5.5-2.5zM19 15l-1.25 2.75L15 19l2.75 1.25L19 23l1.25-2.75L23 19l-2.75-1.25L19 15z"})}),_t=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})}),Pn=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M20 9H4v2h16V9zM4 15h16v-2H4v2z"})}),Er=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M23 8c0 1.1-.9 2-2 2-.18 0-.35-.02-.51-.07l-3.56 3.55c.05.16.07.34.07.52 0 1.1-.9 2-2 2s-2-.9-2-2c0-.18.02-.36.07-.52l-2.55-2.55c-.16.05-.34.07-.52.07s-.36-.02-.52-.07l-4.55 4.56c.05.16.07.33.07.51 0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2c.18 0 .35.02.51.07l4.56-4.55C8.02 9.36 8 9.18 8 9c0-1.1.9-2 2-2s2 .9 2 2c0 .18-.02.36-.07.52l2.55 2.55c.16-.05.34-.07.52-.07s.36.02.52.07l3.55-3.56C19.02 8.35 19 8.18 19 8c0-1.1.9-2 2-2s2 .9 2 2z"})}),gt=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:[e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21 5C19.89 4.65 18.67 4.5 17.5 4.5C15.55 4.5 13.45 4.9 12 6C10.55 4.9 8.45 4.5 6.5 4.5C5.33 4.5 4.11 4.65 3 5C2.25 5.25 1.6 5.55 1 6V20.6C1 20.85 1.25 21.1 1.5 21.1C1.6 21.1 1.65 21.1 1.75 21.05C3.15 20.3 4.85 20 6.5 20C8.2 20 10.65 20.65 12 21.5C13.35 20.65 15.8 20 17.5 20C19.15 20 20.85 20.3 22.25 21.05C22.35 21.1 22.4 21.1 22.5 21.1C22.75 21.1 23 20.85 23 20.6V6C22.4 5.55 21.75 5.25 21 5ZM21 18.5C19.9 18.15 18.7 18 17.5 18C15.8 18 13.35 18.65 12 19.5C10.65 18.65 8.2 18 6.5 18C5.3 18 4.1 18.15 3 18.5V7C4.1 6.65 5.3 6.5 6.5 6.5C8.2 6.5 10.65 7.15 12 8C13.35 7.15 15.8 6.5 17.5 6.5C18.7 6.5 19.9 6.65 21 7V18.5Z"}),e("path",{d:"M17.5 10.5C18.38 10.5 19.23 10.59 20 10.76V9.24C19.21 9.09 18.36 9 17.5 9C15.8 9 14.26 9.29 13 9.83V11.49C14.13 10.85 15.7 10.5 17.5 10.5ZM13 12.49V14.15C14.13 13.51 15.7 13.16 17.5 13.16C18.38 13.16 19.23 13.25 20 13.42V11.9C19.21 11.75 18.36 11.66 17.5 11.66C15.8 11.66 14.26 11.96 13 12.49ZM17.5 14.33C15.8 14.33 14.26 14.62 13 15.16V16.82C14.13 16.18 15.7 15.83 17.5 15.83C18.38 15.83 19.23 15.92 20 16.09V14.57C19.21 14.41 18.36 14.33 17.5 14.33Z"}),e("path",{d:"M6.5 10.5C5.62 10.5 4.77 10.59 4 10.76V9.24C4.79 9.09 5.64 9 6.5 9C8.2 9 9.74 9.29 11 9.83V11.49C9.87 10.85 8.3 10.5 6.5 10.5ZM11 12.49V14.15C9.87 13.51 8.3 13.16 6.5 13.16C5.62 13.16 4.77 13.25 4 13.42V11.9C4.79 11.75 5.64 11.66 6.5 11.66C8.2 11.66 9.74 11.96 11 12.49ZM6.5 14.33C8.2 14.33 9.74 14.62 11 15.16V16.82C9.87 16.18 8.3 15.83 6.5 15.83C5.62 15.83 4.77 15.92 4 16.09V14.57C4.79 14.41 5.64 14.33 6.5 14.33Z"})]}),ls=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M12 2C6.49 2 2 6.49 2 12s4.49 10 10 10 10-4.49 10-10S17.51 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm3-8c0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-3 3 1.34 3 3z"})}),cs=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM12 6C9.79 6 8 7.79 8 10H10C10 8.9 10.9 8 12 8C13.1 8 14 8.9 14 10C14 10.8792 13.4202 11.3236 12.7704 11.8217C11.9421 12.4566 11 13.1787 11 15H13C13 13.9046 13.711 13.2833 14.4408 12.6455C15.21 11.9733 16 11.2829 16 10C16 7.79 14.21 6 12 6ZM13 16V18H11V16H13Z"})}),xr=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M4 20h16c1.1 0 2-.9 2-2s-.9-2-2-2H4c-1.1 0-2 .9-2 2s.9 2 2 2zm0-3h2v2H4v-2zM2 6c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2s-.9-2-2-2H4c-1.1 0-2 .9-2 2zm4 1H4V5h2v2zm-2 7h16c1.1 0 2-.9 2-2s-.9-2-2-2H4c-1.1 0-2 .9-2 2s.9 2 2 2zm0-3h2v2H4v-2z"})}),$n=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})}),ds=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M3 17v2h6v-2H3zM3 5v2h10V5H3zm10 16v-2h8v-2h-8v-2h-2v6h2zM7 9v2H3v2h4v2h2V9H7zm14 4v-2H11v2h10zm-6-4h2V7h4V5h-4V3h-2v6z"})}),tr=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M7 20h4c0 1.1-.9 2-2 2s-2-.9-2-2zm-2-1h8v-2H5v2zm11.5-9.5c0 3.82-2.66 5.86-3.77 6.5H5.27c-1.11-.64-3.77-2.68-3.77-6.5C1.5 5.36 4.86 2 9 2s7.5 3.36 7.5 7.5zm4.87-2.13L20 8l1.37.63L22 10l.63-1.37L24 8l-1.37-.63L22 6l-.63 1.37zM19 6l.94-2.06L22 3l-2.06-.94L19 0l-.94 2.06L16 3l2.06.94L19 6z"})}),Ni=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M3 14h4v-4H3v4zm0 5h4v-4H3v4zM3 9h4V5H3v4zm5 5h13v-4H8v4zm0 5h13v-4H8v4zM8 5v4h13V5H8z"})}),ms=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"m22 9.24-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z"})}),us=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"})}),hs=()=>e("svg",{viewBox:"0 0 16 16",fill:tt("color-error"),children:e("path",{d:"M13.5095 4L8.50952 1H7.50952L2.50952 4L2.01953 4.85999V10.86L2.50952 11.71L7.50952 14.71H8.50952L13.5095 11.71L13.9995 10.86V4.85999L13.5095 4ZM7.50952 13.5601L3.00952 10.86V5.69995L7.50952 8.15002V13.5601ZM3.26953 4.69995L8.00952 1.85999L12.7495 4.69995L8.00952 7.29004L3.26953 4.69995ZM13.0095 10.86L8.50952 13.5601V8.15002L13.0095 5.69995V10.86Z"})}),ps=()=>e("svg",{viewBox:"0 0 16 16",fill:tt("color-primary"),children:e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 5H4V4H1.5L1 4.5V12.5L1.5 13H4V12H2V5ZM14.5 4H12V5H14V12H12V13H14.5L15 12.5V4.5L14.5 4ZM11.76 6.56995L12 7V9.51001L11.7 9.95996L7.19995 11.96H6.73999L4.23999 10.46L4 10.03V7.53003L4.30005 7.06995L8.80005 5.06995H9.26001L11.76 6.56995ZM5 9.70996L6.5 10.61V9.28003L5 8.38V9.70996ZM5.57996 7.56006L7.03003 8.43005L10.42 6.93005L8.96997 6.06006L5.57996 7.56006ZM7.53003 10.73L11.03 9.17004V7.77002L7.53003 9.31995V10.73Z"})}),vs=()=>e("svg",{viewBox:"0 0 16 16",fill:tt("color-warning"),children:e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14 2H8L7 3V6H8V3H14V8H10V9H14L15 8V3L14 2ZM9 6H13V7H9.41L9 6.59V6ZM7 7H2L1 8V13L2 14H8L9 13V8L8 7H7ZM8 13H2V8H8V9V13ZM3 9H7V10H3V9ZM3 11H7V12H3V11ZM9 4H13V5H9V4Z"})}),fs=()=>e("svg",{viewBox:"0 0 16 16",fill:tt("color-primary"),children:e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 3L8 2H14L15 3V8L14 9H10V8H14V3H8V6H7V3ZM9 9V8L8 7H7H2L1 8V13L2 14H8L9 13V9ZM8 8V9V13H2V8H7H8ZM9.41421 7L9 6.58579V6H13V7H9.41421ZM9 4H13V5H9V4ZM7 10H3V11H7V10Z"})}),On=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"})}),gs=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M12 5.83 15.17 9l1.41-1.41L12 3 7.41 7.59 8.83 9zm0 12.34L8.83 15l-1.41 1.41L12 21l4.59-4.59L15.17 15z"})}),bs=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M7.41 18.59 8.83 20 12 16.83 15.17 20l1.41-1.41L12 14zm9.18-13.18L15.17 4 12 7.17 8.83 4 7.41 5.41 12 10z"})}),Rt=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"})}),ys=()=>e("svg",{viewBox:"0 0 24 24",children:e("path",{fill:"currentColor",d:"M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z",children:e("animateTransform",{attributeName:"transform",dur:"0.75s",repeatCount:"indefinite",type:"rotate",values:"0 12 12;360 12 12"})})}),_s=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M21.99 4c0-1.1-.89-2-1.99-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h14l4 4zM18 14H6v-2h12zm0-3H6V9h12zm0-3H6V6h12z"})}),Cs=()=>e("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:e("path",{d:"M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"})}),wi=Object.freeze(Object.defineProperty({__proto__:null,AlarmIcon:ns,AlertIcon:Ka,AlertingRuleIcon:Ja,ArrowDownIcon:Ae,ArrowDropDownIcon:Xe,CalendarIcon:Tr,ChartIcon:In,ClockIcon:jt,CloseIcon:De,CodeIcon:er,CollapseIcon:bs,CommentIcon:_s,CopyIcon:_t,DebugIcon:Cs,DeleteIcon:Vr,DetailsIcon:Hr,DoneIcon:Ur,DownloadIcon:On,DragIcon:Pn,ErrorIcon:ts,ExpandIcon:gs,FunctionIcon:ps,GroupIcon:Wa,InfoIcon:lt,InfoOutlinedIcon:Xt,IssueIcon:ls,KeyboardIcon:as,LabelIcon:vs,LinkIcon:Ga,ListIcon:Ni,LogoIcon:Xa,LogoShortIcon:es,MetricIcon:hs,MinusIcon:ss,MoreIcon:$n,PlayCircleOutlineIcon:zr,PlayIcon:dt,PlusIcon:Dn,Prettify:is,QuestionIcon:cs,RecordingRuleIcon:Za,RefreshIcon:Qt,RestartIcon:ft,SearchIcon:Rt,SettingsIcon:vt,SpinnerIcon:ys,StarBorderIcon:ms,StarIcon:us,StorageIcon:xr,SuccessIcon:rs,TableIcon:Fr,TimelineIcon:Er,TipIcon:tr,TuneIcon:ds,ValueIcon:fs,VisibilityIcon:Rn,VisibilityOffIcon:os,WarningIcon:Mn,WikiIcon:gt},Symbol.toStringTag,{value:"Module"})),Si=({to:t,isNavLink:r,children:n,...a})=>r?e(Ia,{to:t,...a,children:n}):e("div",{...a,children:n}),Ti=({activeItem:t,item:r,color:n=tt("color-primary"),activeNavRef:a,onChange:s,isNavLink:o})=>{const i=l=>()=>{s&&s(l)};return e(Si,{className:R({"vm-tabs-item":!0,"vm-tabs-item_active":t===r.value,[r.className||""]:r.className}),isNavLink:o,to:r.value,style:{color:n},onClick:i(r.value),ref:t===r.value?a:void 0,children:[r.icon&&e("div",{className:R({"vm-tabs-item__icon":!0,"vm-tabs-item__icon_single":!r.label}),children:r.icon}),r.label]})};function oe(t,r,n,a){const s=Z(r);x(()=>{s.current=r},[r]),x(()=>{const o=n?.current??window;if(!(o&&o.addEventListener))return;const i=l=>s.current(l);return o.addEventListener(t,i,a),()=>{o.removeEventListener(t,i,a)}},[t,n,a])}const Ct=()=>{const[t,r]=b({width:0,height:0}),n=()=>{r({width:window.innerWidth,height:window.innerHeight})};return oe("resize",n),x(n,[]),t},rr=({activeItem:t,items:r,color:n=tt("color-primary"),onChange:a,indicatorPlacement:s="bottom",isNavLink:o})=>{const i=Ct(),l=Z(null),[c,m]=b({left:0,width:0,bottom:0});return x(()=>{if(l.current?.base instanceof HTMLElement){const{offsetLeft:d,offsetWidth:u,offsetHeight:h}=l.current.base;m({left:d,width:u,bottom:s==="top"?h-2:0})}},[i,t,l,r]),e("div",{className:"vm-tabs",children:[r.map(d=>e(Ti,{activeItem:t,item:d,onChange:a,color:n,activeNavRef:l,isNavLink:o},d.value)),e("div",{className:"vm-tabs__indicator",style:{...c,borderColor:n}})]})},Lt=[{value:pe.chart,icon:e(In,{}),label:"Graph",prometheusCode:0},{value:pe.code,icon:e(er,{}),label:"JSON",prometheusCode:3},{value:pe.table,icon:e(Fr,{}),label:"Table",prometheusCode:1}],Ns=({tabFilter:t})=>{const{displayType:r}=$e(),n=Pt(),a=o=>{n({type:"SET_DISPLAY_TYPE",payload:o??r})},s=Lt.filter(t??(()=>!0));return e(rr,{activeItem:r,items:s,onChange:a})},ws=()=>{const t=ue("g0.tab",0);return Lt.find(n=>n.prometheusCode===+t||n.value===t)?.value||pe.chart},ca=be("SERIES_LIMITS"),Ei={displayType:ws(),nocache:!1,isTracingEnabled:!1,seriesLimits:ca?JSON.parse(ca):Oa,tableCompact:be("TABLE_COMPACT")||!1,reduceMemUsage:!1};function xi(t,r){switch(r.type){case"SET_DISPLAY_TYPE":return{...t,displayType:r.payload};case"SET_SERIES_LIMITS":return Ne("SERIES_LIMITS",JSON.stringify(r.payload)),{...t,seriesLimits:r.payload};case"TOGGLE_QUERY_TRACING":return{...t,isTracingEnabled:!t.isTracingEnabled};case"TOGGLE_NO_CACHE":return{...t,nocache:!t.nocache};case"TOGGLE_TABLE_COMPACT":return Ne("TABLE_COMPACT",!t.tableCompact),{...t,tableCompact:!t.tableCompact};case"TOGGLE_REDUCE_MEM_USAGE":return Ne("TABLE_COMPACT",!t.reduceMemUsage),{...t,reduceMemUsage:!t.reduceMemUsage};default:throw new Error}}const Hn=yt({}),$e=()=>Re(Hn).state,Pt=()=>Re(Hn).dispatch,Ai=({children:t})=>{const[r,n]=kt(xi,Ei),a=D(()=>({state:r,dispatch:n}),[r,n]);return e(Hn.Provider,{value:a,children:t})},Li={customStep:ue("g0.step_input",""),yaxis:{limits:{enable:!1,range:{1:[0,0]}}},isHistogram:!1,isEmptyHistogram:!1,spanGaps:!1,showAllPoints:!!be("POINTS_SHOW_ALL"),openSettings:!1};function ki(t,r){switch(r.type){case"TOGGLE_ENABLE_YAXIS_LIMITS":return{...t,yaxis:{...t.yaxis,limits:{...t.yaxis.limits,enable:!t.yaxis.limits.enable}}};case"SET_CUSTOM_STEP":return{...t,customStep:r.payload};case"SET_YAXIS_LIMITS":return{...t,yaxis:{...t.yaxis,limits:{...t.yaxis.limits,range:r.payload}}};case"SET_IS_HISTOGRAM":return{...t,isHistogram:r.payload};case"SET_IS_EMPTY_HISTOGRAM":return{...t,isEmptyHistogram:r.payload};case"SET_SPAN_GAPS":return{...t,spanGaps:r.payload};case"SET_SHOW_POINTS":return Ne("POINTS_SHOW_ALL",r.payload),{...t,showAllPoints:r.payload};case"SET_OPEN_SETTINGS":return{...t,openSettings:r.payload};default:throw new Error}}const zn=yt({}),Oe=()=>Re(zn).state,rt=()=>Re(zn).dispatch,Mi=({children:t})=>{const[r,n]=kt(ki,Li),a=D(()=>({state:r,dispatch:n}),[r,n]);return e(zn.Provider,{value:a,children:t})},Ii={dashboardsSettings:[],dashboardsLoading:!1,dashboardsError:""};function Di(t,r){switch(r.type){case"SET_DASHBOARDS_SETTINGS":return{...t,dashboardsSettings:r.payload};case"SET_DASHBOARDS_LOADING":return{...t,dashboardsLoading:r.payload};case"SET_DASHBOARDS_ERROR":return{...t,dashboardsError:r.payload};default:throw new Error}}const Fn=yt({}),Ss=()=>Re(Fn).state,Ri=()=>Re(Fn).dispatch,Pi=({children:t})=>{const[r,n]=kt(Di,Ii),a=D(()=>({state:r,dispatch:n}),[r,n]);return e(Fn.Provider,{value:a,children:t})},Ts={windows:"Windows",mac:"Mac OS",linux:"Linux"},$i=()=>Object.values(Ts).find(t=>navigator.userAgent.indexOf(t)>=0)||"unknown",qr=()=>$i()===Ts.mac,Oi=()=>["Android","webOS","iPhone","iPad","iPod","BlackBerry","Windows Phone"].map(n=>navigator.userAgent.match(new RegExp(n,"i"))).some(n=>n);function W(){const t=Ct(),r=()=>{const s=Oi(),o=window.innerWidth<500;return s||o},[n,a]=b(r());return x(()=>{a(r())},[t]),{isMobile:n}}const Hi={success:e(rs,{}),error:e(ts,{}),warning:e(Mn,{}),info:e(lt,{})},te=({variant:t,children:r})=>{const{isDarkTheme:n}=ne(),{isMobile:a}=W();return e("div",{className:R({"vm-alert":!0,[`vm-alert_${t}`]:t,"vm-alert_dark":n,"vm-alert_mobile":a}),children:[e("div",{className:"vm-alert__icon",children:Hi[t||"info"]}),e("div",{className:"vm-alert__content",children:r})]})},Es=yt({showInfoMessage:()=>{}}),Vn=()=>Re(Es),zi=({children:t})=>{const{isMobile:r}=W(),[n,a]=b({text:"",type:"info"}),[s,o]=b(!1),[i,l]=b(null);x(()=>{if(!i)return;a({...i,key:Date.now()}),o(!0);const m=setTimeout(c,i.timeout||4e3);return()=>clearTimeout(m)},[i]);const c=()=>{l(null),o(!1)};return e(Es.Provider,{value:{showInfoMessage:l},children:[s&&e("div",{className:R({"vm-snackbar":!0,"vm-snackbar_mobile":r}),children:e(te,{variant:n.type,children:e("div",{className:"vm-snackbar-content",children:[e("span",{children:n.text}),e("div",{className:"vm-snackbar-content__close",onClick:c,children:e(De,{})})]})})}),t]})},Fi=(...t)=>t.reduce((r,n)=>({children:a})=>e(r,{children:e(n,{children:a})}),({children:r})=>e(q,{children:r})),Vi=[Go,ui,Ci,Ai,Mi,zi,Pi],Ui=Fi(...Vi);var Yt=(t=>(t[t.internalLink=0]="internalLink",t[t.externalLink=1]="externalLink",t))(Yt||{});const qi=t=>[{value:K.trace},{value:K.queryAnalyzer},{value:K.withTemplate},{value:K.relabel},{value:K.downsamplingDebug,hide:!t},{value:K.retentionDebug,hide:!t}],Bi=()=>[{value:K.metrics},{value:K.cardinality},{value:K.topQueries},{value:K.activeQueries}],Qi=()=>[{value:K.rules},{value:K.notifiers}],ji=({isEnterpriseLicense:t,showPredefinedDashboards:r,showAlerting:n})=>[{value:K.home},{value:K.rawQuery},{label:"Explore",submenu:Bi()},{label:"Tools",submenu:qi(t)},{value:K.dashboards,hide:!r},{value:"Alerting",submenu:Qi(),hide:!n}],mn=({activeMenu:t,label:r,value:n,type:a,color:s})=>a===Yt.externalLink?e("a",{className:R({"vm-header-nav-item":!0,"vm-header-nav-item_active":t===n}),style:{color:s},href:n,target:"_blank",rel:"noreferrer",children:r}):e(Ia,{className:R({"vm-header-nav-item":!0,"vm-header-nav-item_active":t===n}),style:{color:s},to:n,children:r}),Br=(t,r,n)=>{const a=Y(s=>{const o=t?.current,i=s.target,l=n?.current&&n.current.contains(i);!o||o.contains(s?.target||null)||l||r(s)},[t,r]);oe("mouseup",a),oe("touchstart",a)},O=({variant:t="contained",color:r="primary",size:n="medium",ariaLabel:a,children:s,endIcon:o,startIcon:i,fullWidth:l=!1,className:c,disabled:m,onClick:d,onMouseDown:u,"data-id":h})=>{const p=R({"vm-button":!0,[`vm-button_${t}_${r}`]:!0,[`vm-button_${n}`]:n,"vm-button_icon_only":(i||o)&&!s,"vm-button_full-width":l,"vm-button_with-icons":i||o,[c||""]:c});return e("button",{className:p,disabled:m,"aria-label":a,onClick:d,onMouseDown:u,"data-id":h,children:[i,s,o]})},We=({children:t,buttonRef:r,placement:n="bottom-left",placementPosition:a,open:s=!1,onClose:o,offset:i={top:6,left:0},clickOutside:l=!0,fullWidth:c,title:m,disabledFullScreen:d,classes:u,variant:h})=>{const{isMobile:p}=W(),v=Mt(),y=ct(),[f,g]=b({width:0,height:0}),[_,C]=b(!1),w=Z(null);x(()=>(C(s),!s&&o&&o(),s&&p&&!d&&(document.body.style.overflow="hidden"),()=>{document.body.style.overflow="auto"}),[s]),x(()=>{g({width:w?.current?.clientWidth||0,height:w?.current?.clientHeight||0}),C(!1)},[w]);const N=D(()=>{if(!r)return{};const I=r.current;if(!I||!_)return{};const k=I.getBoundingClientRect(),L={top:0,left:0,width:"auto"},$=n?.includes("right"),V=n?.includes("top"),H=n?.includes("center"),z=i?.top||0,j=i?.left||0;if(L.left=L.left=k.left+j,L.top=k.height+k.top+z,$&&(L.left=k.right-f.width),V&&(L.top=k.top-f.height-z),H&&(L.top=k.top+(k.height-f.height)/2-z),n==="fixed"&&a)return L.top=Math.max(a.top+i.top,0),L.left=Math.max(a.left+i.left,0),L;const{innerWidth:ee,innerHeight:X}=window,B=L.top+f.height>X,ae=L.top<0,le=L.left+f.width>ee,F=L.left<0;return B&&(L.top=k.top-f.height-z),ae&&(L.top=k.height+k.top+z),le&&(L.left=k.right-f.width-j),F&&(L.left=k.left+j),c&&(L.width=`${k.width}px`),L.top<0&&(L.top=0),L.left<0&&(L.left=0),L},[r,n,_,t,c]),S=I=>{I.stopPropagation(),o()},A=()=>{C(!1),o()},T=()=>{l&&A()};x(()=>{if(!w.current||!_||p&&!d)return;const{right:I,width:k}=w.current.getBoundingClientRect();if(I>window.innerWidth){const L=window.innerWidth-k;w.current.style.left=`${L}px`}},[_,w,a]);const E=Y(()=>{_&&p&&!d&&(v(y,{replace:!0}),o())},[_,p,d,y,o]);oe("scroll",A),oe("popstate",E),Br(w,T,r);const M={};return(u||[]).forEach(I=>{M[I]=!0}),e(q,{children:(_||!f.width)&&It(e("div",{className:R({"vm-popper":!0,[`vm-popper_${h}`]:h,"vm-popper_mobile":p&&!d,"vm-popper_open":(p||Object.keys(N).length)&&_,...M}),ref:w,style:p&&!d?{}:N,children:[(m||p&&!d)&&e("div",{className:"vm-popper-header",children:[e("p",{className:"vm-popper-header__title",children:m}),e(O,{variant:"text",color:h==="dark"?"white":"primary",size:"small",onClick:S,ariaLabel:"close",children:e(De,{})})]}),t]}),document.body)})},de=t=>{const[r,n]=b(!!t),a=Y(()=>n(!0),[]),s=Y(()=>n(!1),[]),o=Y(()=>n(i=>!i),[]);return{value:r,setValue:n,setTrue:a,setFalse:s,toggle:o}},Yi=({activeMenu:t,label:r,color:n,background:a,submenu:s,direction:o="row"})=>{const{pathname:i}=ct(),[l,c]=b(null),m=Z(null),{value:d,setFalse:u,setTrue:h}=de(!1),p=()=>{(o==="row"||!d)&&h(),o==="column"&&d&&u(),o==="row"&&l&&clearTimeout(l)},v=()=>{l&&clearTimeout(l);const f=setTimeout(u,300);c(f)},y=()=>{l&&clearTimeout(l)};return x(()=>{u()},[i]),e("div",{className:R({"vm-header-nav-item_open":d}),style:{color:n},onMouseEnter:o==="column"?void 0:p,onMouseLeave:o==="column"?void 0:v,onClick:o==="column"?p:void 0,ref:m,children:[e("div",{className:R({"vm-header-nav-item":!0,"vm-header-nav-item_sub":!0,"vm-header-nav-item_active":s.find(f=>f.value===t)}),children:[r,e(Xe,{})]}),o==="column"?e("div",{className:"vm-header-nav-item-submenu",style:{background:a},children:s.map(f=>e(mn,{activeMenu:t,value:f.value||"",label:f.label||"",color:n,type:f.type||Yt.internalLink},f.value))}):e(We,{open:d,placement:"bottom-left",offset:{top:12,left:0},onClose:u,buttonRef:m,children:e("div",{className:"vm-header-nav-item-submenu",style:{background:a},onMouseLeave:v,onMouseEnter:y,children:s.map(f=>e(mn,{activeMenu:t,value:f.value||"",label:f.label||"",color:n,type:f.type||Yt.internalLink},f.value))})})]})},Gi=t=>{try{return t.replace(/^\/+/,"").replace(/-/g," ").trim().replace(/^\w/,r=>r.toUpperCase())}catch{return t}},xs=t=>t.filter(r=>!r.hide).map(r=>{const n={...r};return n.value&&!n.label&&(n.label=Wt[n.value]?.title||Gi(n.value)),n.submenu&&n.submenu.length>0&&(n.submenu=xs(n.submenu)),n}),Wi=()=>{const t=Me(),{dashboardsSettings:r}=Ss(),{serverUrl:n,appConfig:a}=ne(),s=a.license?.type==="enterprise",o=a?.vmalert?.enabled||!1,i=!!(!t&&r.length),l=D(()=>({serverUrl:n,isEnterpriseLicense:s,showAlerting:o,showPredefinedDashboards:i}),[n,s,o,i]),c=D(()=>ji(l),[l]);return xs(c)},As=({color:t,background:r,direction:n})=>{const{pathname:a}=ct(),[s,o]=b(a),i=Wi();return x(()=>{o(a)},[a]),e("nav",{className:R({"vm-header-nav":!0,[`vm-header-nav_${n}`]:n}),children:i.map(l=>l.submenu?e(Yi,{activeMenu:s,label:l.label||"",submenu:l.submenu,color:t,background:r,direction:n},l.label):e(mn,{activeMenu:s,value:l.value||"",label:l.label||"",color:t,type:l.type||Yt.internalLink},l.value))})},we=({title:t,children:r,onClose:n,className:a,isOpen:s=!0})=>{const{isMobile:o}=W(),i=Mt(),l=ct(),c=Y(h=>{s&&h.key==="Escape"&&n()},[s]),m=h=>{h.stopPropagation()},d=Y(()=>{s&&(i(l,{replace:!0}),n())},[s,l,n]);return x(()=>{if(s)return document.body.style.overflow="hidden",()=>{document.body.style.overflow="auto"}},[s]),oe("popstate",d),oe("keyup",c),It(e("div",{className:R({"vm-modal":!0,"vm-modal_mobile":o,[`${a}`]:a}),onMouseDown:n,children:e("div",{className:"vm-modal-content",onMouseDown:m,children:[e("div",{className:"vm-modal-content-header",children:[t&&e("div",{className:"vm-modal-content-header__title",children:t}),e("div",{className:"vm-modal-header__close",children:e(O,{variant:"text",size:"small",onClick:n,ariaLabel:"close",children:e(De,{})})})]}),e("div",{className:"vm-modal-content-body",tabIndex:0,children:r})]})}),document.body)},G=({children:t,title:r,open:n,placement:a="bottom-center",offset:s={top:6,left:0}})=>{const{isMobile:o}=W(),[i,l]=b(!1),[c,m]=b({width:0,height:0}),d=Z(null),u=Z(null),h=()=>l(!1);x(()=>{if(!(!u.current||!i))return m({width:u.current.clientWidth,height:u.current.clientHeight}),window.addEventListener("scroll",h),()=>{window.removeEventListener("scroll",h)}},[i,r]);const p=D(()=>{const f=d?.current?.base;if(!f||!i)return{};const g=f.getBoundingClientRect(),_={top:0,left:0},C=a==="bottom-right"||a==="top-right",w=a==="bottom-left"||a==="top-left",N=a?.includes("top"),S=s?.top||0,A=s?.left||0;_.left=g.left-(c.width-g.width)/2+A,_.top=g.height+g.top+S,C&&(_.left=g.right-c.width),w&&(_.left=g.left+A),N&&(_.top=g.top-c.height-S);const{innerWidth:T,innerHeight:E}=window,M=20,I=_.top+c.height+M>E,k=_.top-M<0,L=_.left+c.width+M>T,$=_.left-M<0;return I&&(_.top=g.top-c.height-S),k&&(_.top=g.height+g.top+S),L&&(_.left=g.right-c.width-A),$&&(_.left=g.left+A),_.top<0&&(_.top=20),_.left<0&&(_.left=20),_},[d,a,i,c]),v=()=>{typeof n!="boolean"&&l(!0)},y=()=>{l(!1)};return x(()=>{typeof n=="boolean"&&l(n)},[n]),x(()=>{const f=d?.current?.base;if(f)return f.addEventListener("mouseenter",v),f.addEventListener("mouseleave",y),()=>{f.removeEventListener("mouseenter",v),f.removeEventListener("mouseleave",y)}},[d]),e(q,{children:[e(q,{ref:d,children:t}),!o&&i&&It(e("div",{className:"vm-tooltip",ref:u,style:p,children:r}),document.body)]})},fr=e("code",{children:qr()?"Cmd":"Ctrl"}),Ki=[{title:"Zoom in",description:e(q,{children:["To zoom in, hold down the ",fr," + ",e("code",{children:"scroll up"}),", or press the ",e("code",{children:"+"}),". Also, you can zoom in on a range on the graph by holding down your mouse button and selecting the range."]})},{title:"Zoom out",description:e(q,{children:["To zoom out, hold down the ",fr," + ",e("code",{children:"scroll down"}),", or press the ",e("code",{children:"-"}),"."]})},{title:"Move horizontal axis",description:e(q,{children:["To move the graph, hold down the ",fr," + ",e("code",{children:"drag"})," the graph to the right or left."]})},{title:"Fixing a tooltip",description:e(q,{children:["To fix the tooltip, ",e("code",{children:"click"})," mouse when it's open. Then, you can drag the fixed tooltip by ",e("code",{children:"clicking"})," and ",e("code",{children:"dragging"})," on the ",e(Pn,{})," icon."]})},{title:"Set a custom range for the vertical axis",description:e(q,{children:["To set a custom range for the vertical axis, click on the ",e(vt,{})," icon located in the upper right corner of the graph, activate the toggle, and set the values."]})}],Ji=[{title:"Show/hide a legend item",description:e(q,{children:[e("code",{children:"click"})," on a legend item to isolate it on the graph.",fr," + ",e("code",{children:"click"})," on a legend item to remove it from the graph. To revert to the previous state, click again."]})},{title:"Copy label key-value pairs",description:e(q,{children:[e("code",{children:"click"})," on a label key-value pair to save it to the clipboard."]})},{title:"Collapse/Expand the legend group",description:e(q,{children:[e("code",{children:"click"})," on the group name (e.g. ",e("b",{children:'Query 1: {__name__!=""}'}),") to collapse or expand the legend."]})}],Zi=Ki.concat(Ji),Un=()=>{const{value:t,setFalse:r,setTrue:n}=de(!1);return e(q,{children:[e(G,{title:"Show tips on working with the graph",children:e(O,{variant:"text",color:"gray",startIcon:e(tr,{}),onClick:n,ariaLabel:"open the tips"})}),t&&e(we,{title:"Tips on working with the graph and the legend",onClose:r,children:e("div",{className:"fc-graph-tips",children:Zi.map(({title:a,description:s})=>e("div",{className:"fc-graph-tips-item",children:[e("h4",{className:"fc-graph-tips-item__action",children:a}),e("p",{className:"fc-graph-tips-item__description",children:s})]},a))})})]})},mt=e("code",{children:qr()?"Cmd":"Ctrl"}),Ls=e(q,{children:[e("code",{children:qr()?"Option":"Ctrl"})," + ",e("code",{children:"Space"})]}),Xi=[{title:"Query",list:[{keys:e("code",{children:"Enter"}),description:"Run"},{keys:e(q,{children:[e("code",{children:"Shift"})," + ",e("code",{children:"Enter"})]}),description:"Multi-line queries"},{keys:e(q,{children:[mt," + ",e("code",{children:"Arrow Up"})]}),description:"Previous command from the Query history"},{keys:e(q,{children:[mt," + ",e("code",{children:"Arrow Down"})]}),description:"Next command from the Query history"},{keys:e(q,{children:[mt," + ",e("code",{children:"click"})," by ",e(Rn,{})]}),description:"Toggle multiple queries"},{keys:Ls,description:"Show quick autocomplete tips"}]},{title:"Graph",readMore:e(Un,{}),list:[{keys:e(q,{children:[mt," + ",e("code",{children:"scroll Up"})," or ",e("code",{children:"+"})]}),description:"Zoom in"},{keys:e(q,{children:[mt," + ",e("code",{children:"scroll Down"})," or ",e("code",{children:"-"})]}),description:"Zoom out"},{keys:e(q,{children:[mt," + ",e("code",{children:"drag"})]}),description:"Move the graph left/right"},{keys:e(q,{children:e("code",{children:"click"})}),description:"Select the series in the legend"},{keys:e(q,{children:[mt," + ",e("code",{children:"click"})]}),description:"Toggle multiple series in the legend"}]}],Xr="Shortcut keys",un=qr(),el=un?"Cmd + /":"F1",ks=({showTitle:t})=>{const r=Me(),{value:n,setTrue:a,setFalse:s}=de(!1),o=Y(i=>{const l=un&&i.key==="/"&&i.metaKey,c=!un&&i.key==="F1"&&!i.metaKey;(l||c)&&a()},[a]);return oe("keydown",o),e(q,{children:[e(G,{open:t===!0?!1:void 0,title:`${Xr} (${el})`,placement:"bottom-center",children:e(O,{className:r?"":"vm-header-button",variant:"contained",color:"primary",startIcon:e(as,{}),onClick:a,ariaLabel:Xr,children:t&&Xr})}),n&&e(we,{title:"Shortcut keys",onClose:s,children:e("div",{className:"vm-shortcuts",children:Xi.map(i=>e("div",{className:"vm-shortcuts-section",children:[i.readMore&&e("div",{className:"vm-shortcuts-section__read-more",children:i.readMore}),e("h3",{className:"vm-shortcuts-section__title",children:i.title}),e("div",{className:"vm-shortcuts-section-list",children:i.list.map((l,c)=>e("div",{className:"vm-shortcuts-section-list-item",children:[e("div",{className:"vm-shortcuts-section-list-item__key",children:l.keys}),e("p",{className:"vm-shortcuts-section-list-item__description",children:l.description})]},`${i.title}_${c}`))})]},i.title))})})]})},tl=({open:t})=>e("button",{className:R({"vm-menu-burger":!0,"vm-menu-burger_opened":t}),"aria-label":"menu",children:e("span",{})}),rl=({background:t,color:r})=>{const{pathname:n}=ct(),{isMobile:a}=W(),s=Z(null),{value:o,toggle:i,setFalse:l}=de(!1);return x(l,[n]),Br(s,l),e("div",{className:"vm-header-sidebar",ref:s,children:[e("div",{className:R({"vm-header-sidebar-button":!0,"vm-header-sidebar-button_open":o}),onClick:i,children:e(tl,{open:o})}),e("div",{className:R({"vm-header-sidebar-menu":!0,"vm-header-sidebar-menu_open":o}),children:[e("div",{className:"vm-header-sidebar-scrollable",children:e(As,{color:r,background:t,direction:"column"})}),e("div",{className:"vm-header-sidebar-menu-settings",children:!a&&e(ks,{showTitle:!0})})]})]})},nl=t=>`${Bo(t)}/admin/tenants`,al=()=>{const{useTenantID:t}=Kt(),r=Me(),{tenantId:n,serverUrl:a}=ne(),[s,o]=b(!1),[i,l]=b(),[c,m]=b([]),d=D(()=>nl(a),[a]),u=D(()=>!!n,[n]),h=r?!t:!u;return x(()=>{if(h)return;(async()=>{o(!0);try{const v=await fetch(d),y=await v.json(),f=y.data||[];m(f.sort((g,_)=>g.localeCompare(_))),v.ok?l(void 0):l(`${y.errorType}\r
${y?.error}`)}catch(v){v instanceof Error&&l(`${v.name}: ${v.message}`)}o(!1)})().catch(console.error)},[d]),{accountIds:c,isLoading:s,error:i}},sl=({controlsComponent:t,isMobile:r,...n})=>{const a=Me(),{pathname:s}=ct(),{accountIds:o}=al(),{value:i,toggle:l,setFalse:c}=de(!1),m=D(()=>(Wt[s]||{}).header||{},[s]),d=e(t,{...n,isMobile:r,accountIds:o,headerSetup:m,closeModal:c});return r?e(q,{children:[e("div",{className:"vm-header-controls vm-header-controls_mobile",children:e(O,{className:R({"vm-header-button":!a}),startIcon:e($n,{}),onClick:l,ariaLabel:"controls"})}),e(we,{title:"Controls",onClose:c,isOpen:i,className:R({"vm-header-controls-modal":!0,"vm-header-controls-modal_open":i}),children:d})]}):d},ol=({controlsComponent:t})=>{const{isMobile:r}=W(),n=Ct(),a=D(()=>window.innerWidth<1230,[n]),{isDarkTheme:s}=ne(),o=Me(),i=D(()=>tt(s?"color-background-block":"color-primary"),[s]),{background:l,color:c}=D(()=>{const{headerStyles:{background:u=o?"#FFF":i,color:h=o?i:"#FFF"}={}}=Kt();return{background:u,color:h}},[i]),m=Mt(),d=()=>{m({pathname:K.home}),window.location.reload()};return e("header",{className:R({"vm-header":!0,"vm-header_app":o,"vm-header_dark":s,"vm-header_sidebar":a,"vm-header_mobile":r}),style:{background:l,color:c},children:[e("div",{className:R({"vm-header-logo":!0,"vm-header-logo_mobile":a}),onClick:d,style:{color:c},children:e(Xa,{})}),a?e(rl,{background:l,color:c}):e(As,{color:c,background:l}),e(sl,{controlsComponent:t,displaySidebar:a,isMobile:r,closeModal:()=>{}})]})},il={href:"https://github.com/VictoriaMetrics/VictoriaMetrics/issues/new/choose",Icon:ls,title:"Create an issue"},ll=[{href:"https://docs.victoriametrics.com/victoriametrics/metricsql/",Icon:er,title:"MetricsQL"},{href:"https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#vmui",Icon:gt,title:"Documentation"},il],cl=xo(({links:t=ll})=>{const r=`2019-${new Date().getFullYear()}`,{appConfig:n}=ne(),a=n?.version;return e("footer",{className:"vm-footer",children:[e("a",{className:"vm-link vm-footer__link",target:"_blank",href:"https://victoriametrics.com/",rel:"me noreferrer",children:[e(es,{}),"victoriametrics.com"]}),t.map(({href:s,Icon:o,title:i})=>e("a",{className:"vm-link vm-footer__link",target:"_blank",href:s,rel:"help noreferrer",children:[e(o,{}),i]},`${s}-${i}`)),e("div",{className:"vm-footer__copyright",children:["© ",r," VictoriaMetrics.",a&&e("span",{className:"vm-footer__version",children:[" Version: ",a]})]})]})}),dl=async t=>await(await fetch(`./dashboards/${t}`)).json(),ml=()=>{const t=Me(),{serverUrl:r}=ne(),n=Ri(),[a,s]=b(!1),[o,i]=b(""),[l,c]=b([]),m=async()=>{try{const u=window.__VMUI_PREDEFINED_DASHBOARDS__;if(!u?.length)return[];const h=await Promise.all(u.map(async p=>dl(p)));c(p=>[...h,...p])}catch(u){u instanceof Error&&i(`${u.name}: ${u.message}`)}},d=async()=>{if(r){i(""),s(!0);try{const u=await fetch(`${r}/vmui/custom-dashboards`),h=await u.json();if(u.ok){const{dashboardsSettings:p}=h;p&&p.length>0?c(v=>[...v,...p]):await m(),s(!1)}else await m(),i(h.error),s(!1)}catch(u){s(!1),u instanceof Error&&i(`${u.name}: ${u.message}`),await m()}}};return x(()=>{t||(c([]),d())},[r]),x(()=>{n({type:"SET_DASHBOARDS_SETTINGS",payload:l})},[l]),x(()=>{n({type:"SET_DASHBOARDS_LOADING",payload:a})},[a]),x(()=>{n({type:"SET_DASHBOARDS_ERROR",payload:o})},[o]),{dashboardsSettings:l,isLoading:a,error:o}},ul=({error:t,warning:r,info:n})=>{const a=Z(null),[s,o]=b(!1),[i,l]=b(!1),m=`${D(()=>t?"ERROR: ":r?"WARNING: ":"",[t,r])}${t||r||n}`,d=()=>{const h=a.current;if(h){const{offsetWidth:p,scrollWidth:v,offsetHeight:y,scrollHeight:f}=h,g=p+1<v||y+1<f;o(g)}else o(!1)},u=()=>{s&&(l(!0),o(!1))};return x(()=>{l(!1),d()},[a,m]),oe("resize",d),!t&&!r&&!n?null:e("span",{className:R({"vm-text-field__error":!0,"vm-text-field__warning":r&&!t,"vm-text-field__helper-text":!r&&!t,"vm-text-field__error_overflowed":s,"vm-text-field__error_full":i}),"data-show":!!m,ref:a,onClick:u,children:m})},ie=({label:t,value:r,type:n="text",error:a="",warning:s="",helperText:o="",placeholder:i,endIcon:l,startIcon:c,disabled:m=!1,autofocus:d=!1,inputmode:u="text",caretPosition:h,onChange:p,onEnter:v,onKeyDown:y,onFocus:f,onBlur:g,onChangeCaret:_})=>{const{isDarkTheme:C}=ne(),{isMobile:w}=W(),N=Z(null),S=Z(null),A=D(()=>n==="textarea"?S:N,[n]),T=R({"vm-text-field__input":!0,"vm-text-field__input_error":a,"vm-text-field__input_warning":!a&&s,"vm-text-field__input_icon-start":c,"vm-text-field__input_textarea":n==="textarea"}),E=z=>{if(!_)return;const{selectionStart:j,selectionEnd:ee}=z;_&&_([j||0,ee||0])},M=z=>{E(z.currentTarget)},I=z=>{y&&y(z);const{key:j,ctrlKey:ee,metaKey:X}=z,B=j==="Enter";(n!=="textarea"?B:B&&(X||ee))&&v&&(z.preventDefault(),v())},k=z=>{E(z.currentTarget)},L=z=>{m||(p&&p(z.currentTarget.value),E(z.currentTarget))},$=()=>{f&&f()},V=()=>{g&&g()},H=z=>{try{A.current&&A.current.setSelectionRange(z[0],z[1])}catch(j){return j}};return x(()=>{!d||w||A?.current?.focus&&A.current.focus()},[A,d]),x(()=>{h&&H(h)},[h]),e("label",{className:R({"vm-text-field":!0,"vm-text-field_textarea":n==="textarea","vm-text-field_dark":C,"vm-text-field_disabled":m}),"data-replicated-value":r,children:[c&&e("div",{className:"vm-text-field__icon-start",children:c}),l&&e("div",{className:"vm-text-field__icon-end",children:l}),t&&e("span",{className:"vm-text-field__label",children:t}),n==="textarea"?e("textarea",{className:T,disabled:m,ref:S,value:r,rows:1,inputMode:u,placeholder:i,autoCapitalize:"none",onInput:L,onKeyDown:I,onKeyUp:k,onFocus:$,onBlur:V,onMouseUp:M}):e("input",{className:T,disabled:m,ref:N,value:r,type:n,placeholder:i,inputMode:u,autoCapitalize:"none",onInput:L,onKeyDown:I,onKeyUp:k,onFocus:$,onBlur:V,onMouseUp:M}),e(ul,{error:a,warning:s,info:o})]})},hl=({accountIds:t})=>{const r=Me(),{isMobile:n}=W(),{tenantId:a,serverUrl:s}=ne(),o=Jt(),i=Ge(),[l,c]=b(""),m=Z(null),{value:d,toggle:u,setFalse:h}=de(!1),p=D(()=>{if(!l)return t;try{const f=new RegExp(l,"i");return t.filter(_=>f.test(_)).sort((_,C)=>(_.match(f)?.index||0)-(C.match(f)?.index||0))}catch{return[]}},[l,t]),v=D(()=>{const f=!t.length,g=t.length===1&&t[0]==="0:0";return!f&&!g},[t]),y=f=>()=>{if(s){const g=qo(s,f);if(g===s)return;o({type:"SET_SERVER",payload:g}),i({type:"RUN_QUERY"})}h()};return v?e("div",{className:"vm-tenant-input",children:[e(G,{title:"Define Tenant ID if you need request to another storage",children:e("div",{ref:m,children:n?e("div",{className:"vm-mobile-option",onClick:u,children:[e("span",{className:"vm-mobile-option__icon",children:e(xr,{})}),e("div",{className:"vm-mobile-option-text",children:[e("span",{className:"vm-mobile-option-text__label",children:"Tenant ID"}),e("span",{className:"vm-mobile-option-text__value",children:a})]}),e("span",{className:"vm-mobile-option__arrow",children:e(Ae,{})})]}):e(O,{className:r?"":"vm-header-button",variant:"contained",color:"primary",fullWidth:!0,startIcon:e(xr,{}),endIcon:e("div",{className:R({"vm-execution-controls-buttons__arrow":!0,"vm-execution-controls-buttons__arrow_open":d}),children:e(Ae,{})}),onClick:u,children:a})})}),e(We,{open:d,placement:"bottom-right",onClose:h,buttonRef:m,title:n?"Define Tenant ID":void 0,children:e("div",{className:R({"vm-list vm-tenant-input-list":!0,"vm-list vm-tenant-input-list_mobile":n}),children:[e("div",{className:"vm-tenant-input-list__search",children:e(ie,{autofocus:!0,label:"Search",value:l,onChange:c,type:"search"})}),p.map(f=>e("div",{className:R({"vm-list-item":!0,"vm-list-item_mobile":n,"vm-list-item_active":f===a}),onClick:y(f),children:f},f))]})})]}):null};function Gt(t){const r=Z();return x(()=>{r.current=t},[t]),r.current}const Ce=({text:t,href:r,children:n,colored:a=!0,underlined:s=!1,withIcon:o=!1})=>e("a",{href:r,className:R({"vm-link":!0,"vm-link_colored":a,"vm-link_underlined":s,"vm-link_with-icon":o}),target:"_blank",rel:"noreferrer",children:t||n}),pl=()=>{const t=Me(),{isMobile:r}=W(),{customStep:n,isHistogram:a}=Oe(),{period:{step:s,end:o,start:i}}=he(),l=rt(),{displayType:c}=$e(),m=Gt(o-i),d=D(()=>Pr(o-i,a,c),[o,i,a,c]),u=Gt(d),[h,p]=b(n||d),[v,y]=b(""),f=n===d,{value:g,toggle:_,setFalse:C}=de(!1),w=Z(null),N=I=>{const k=I||h||d||"1s",$=(k.match(/[a-zA-Z]+/g)||[]).length?k:`${k}s`;l({type:"SET_CUSTOM_STEP",payload:$}),p($),y("")},S=()=>{N(),C()},A=()=>{document.activeElement instanceof HTMLInputElement&&document.activeElement.select()},T=()=>{N(),S()},E=I=>{const k=I.match(/[-+]?([0-9]*\.[0-9]+|[0-9]+)/g)||[],L=I.match(/[a-zA-Z]+/g)||[],$=k.length&&k.every(z=>parseFloat(z)>0),V=L.every(z=>Sn.find(j=>j.short===z)),H=$&&V;p(I),y(H?"":ge.validStep)},M=()=>{const I=d||"1s";E(I),N(I)};return x(()=>{n&&N(n)},[n]),x(()=>{!n&&d&&N(d)},[d]),x(()=>{o-i===m||!m||n!==u||d&&N(d)},[m,d]),x(()=>{(s===n||s===d)&&N(d)},[a,c]),e("div",{className:"vm-step-control",ref:w,children:[r?e("div",{className:"vm-mobile-option",onClick:_,children:[e("span",{className:"vm-mobile-option__icon",children:e(Er,{})}),e("div",{className:"vm-mobile-option-text",children:[e("span",{className:"vm-mobile-option-text__label",children:"Step"}),e("span",{className:"vm-mobile-option-text__value",children:h})]}),e("span",{className:"vm-mobile-option__arrow",children:e(Ae,{})})]}):e(O,{className:t?"":"vm-header-button",variant:"contained",color:"primary",startIcon:e(Er,{}),onClick:_,children:["Step: ",f?`auto (${h})`:h]}),e(We,{open:g,placement:"bottom-right",onClose:S,buttonRef:w,title:r?"Query resolution step width":void 0,children:e("div",{className:R({"vm-step-control-popper":!0,"vm-step-control-popper_mobile":r}),children:[e(ie,{autofocus:!0,label:"Step value",value:h,error:v,onChange:E,onEnter:T,onFocus:A,onBlur:N,endIcon:e(G,{title:`Reset to auto step (${d})`,children:e(O,{size:"small",variant:"text",color:"primary",startIcon:e(ft,{}),onClick:M,ariaLabel:"reset step"})})}),e("div",{className:"vm-step-control-popper-info",children:[e("p",{children:[e("code",{children:"step"})," - the ",e(Ce,{href:"https://prometheus.io/docs/prometheus/latest/querying/basics/#time-durations",text:"interval"})," between datapoints, which must be returned from the range query. The ",e("code",{children:"query"})," is executed at ",e("code",{children:"start"}),", ",e("code",{children:"start+step"}),", ",e("code",{children:"start+2*step"}),", …, ",e("code",{children:"end"})," timestamps."]}),e("p",{children:["Read more about ",e(Ce,{href:"https://docs.victoriametrics.com/victoriametrics/keyconcepts/#range-query",text:"Range"})," and ",e(Ce,{href:"https://docs.victoriametrics.com/victoriametrics/keyconcepts/#instant-query",text:"Instant"})," queries."]})]})]})})]})},vl=({relativeTime:t,setDuration:r})=>{const{isMobile:n}=W(),a=s=>()=>{r(s)};return e("div",{className:R({"vm-time-duration":!0,"vm-time-duration_mobile":n}),children:wr.map(({id:s,duration:o,until:i,title:l})=>e("div",{className:R({"vm-list-item":!0,"vm-list-item_mobile":n,"vm-list-item_active":s===t}),onClick:a({duration:o,until:i(),id:s}),children:l||o},s))})},fl=({hasPrev:t,hasNext:r,viewDate:n,showArrowNav:a,onChangeViewDate:s,toggleDisplayYears:o})=>{const i=()=>{s(n.subtract(1,"month"))},l=()=>{s(n.add(1,"month"))};return e("div",{className:"vm-calendar-header",children:[e("div",{className:"vm-calendar-header-left",onClick:o,children:[e("span",{className:"vm-calendar-header-left__date",children:n.format("MMMM YYYY")}),e("div",{className:"vm-calendar-header-left__select-year",children:e(Xe,{})})]}),a&&e("div",{className:"vm-calendar-header-right",children:[e("div",{className:R({"vm-calendar-header-right__prev":!0,"vm-calendar-header-right_disabled":!t}),onClick:t?i:void 0,children:e(Ae,{})}),e("div",{className:R({"vm-calendar-header-right__next":!0,"vm-calendar-header-right_disabled":!r}),onClick:r?l:void 0,children:e(Ae,{})})]})]})},gl=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],bl=({minDate:t,maxDate:r,viewDate:n,selectDate:a,onChangeSelectDate:s})=>{const o="YYYY-MM-DD",i=Q.tz(),l=Q(n.format(o)),c=D(()=>{const d=new Array(42).fill(null),u=l.startOf("month"),p=l.endOf("month").diff(u,"day")+1,v=new Array(p).fill(u).map((f,g)=>f.add(g,"day")),y=u.day();return d.splice(y,p,...v),d},[l]),m=d=>()=>{d&&s(d)};return e("div",{className:"vm-calendar-body",children:[gl.map(d=>e(G,{title:d,children:e("div",{className:"vm-calendar-body-cell vm-calendar-body-cell_weekday",children:d[0]})},d)),c.map((d,u)=>{const h=d&&(t&&d.isBefore(t)||r&&d.isAfter(r));return e("div",{className:R({"vm-calendar-body-cell":!0,"vm-calendar-body-cell_day":!0,"vm-calendar-body-cell_day_empty":!d,"vm-calendar-body-cell_day_active":(d&&d.format(o))===a.format(o),"vm-calendar-body-cell_day_today":(d&&d.format(o))===i.format(o),"vm-calendar-body-cell_day_disabled":h}),onClick:h?void 0:m(d),children:d&&d.format("D")},d?d.format(o):u)})]})},yl=({minDate:t,maxDate:r,viewDate:n,onChangeViewDate:a})=>{const s=Q().format("YYYY"),o=D(()=>n.format("YYYY"),[n]),i=D(()=>{const d=Q().subtract(18/2,"year");return new Array(18).fill(d).map((u,h)=>u.add(h,"year"))},[n]);x(()=>{const c=document.getElementById(`vm-calendar-year-${o}`);c&&c.scrollIntoView({block:"center"})},[]);const l=c=>()=>{a(c)};return e("div",{className:"vm-calendar-years",children:i.map(c=>{const m=c&&t&&c.isBefore(t)||r&&c.isAfter(r);return e("div",{className:R({"vm-calendar-years__year":!0,"vm-calendar-years__year_selected":c.format("YYYY")===o,"vm-calendar-years__year_today":c.format("YYYY")===s,"vm-calendar-years__year_disabled":m}),id:`vm-calendar-year-${c.format("YYYY")}`,onClick:m?void 0:l(c),children:c.format("YYYY")},c.format("YYYY"))})})},_l=({minDate:t,maxDate:r,viewDate:n,selectDate:a,onChangeViewDate:s})=>{const o=Q().format("MM"),i=D(()=>a.format("MM"),[a]),l=D(()=>new Array(12).fill("").map((m,d)=>Q(n).month(d)),[n]);x(()=>{const m=document.getElementById(`vm-calendar-year-${i}`);m&&m.scrollIntoView({block:"center"})},[]);const c=m=>()=>{s(m)};return e("div",{className:"vm-calendar-years",children:l.map(m=>{const d=m&&(t&&m.isBefore(t)||r&&m.isAfter(r));return e("div",{className:R({"vm-calendar-years__year":!0,"vm-calendar-years__year_selected":m.format("MM")===i,"vm-calendar-years__year_today":m.format("MM")===o,"vm-calendar-years__year_disabled":d}),id:`vm-calendar-year-${m.format("MM")}`,onClick:d?void 0:c(m),children:m.format("MMMM")},m.format("MM"))})})},Cl=({date:t,minDate:r,maxDate:n,format:a=qe,onChange:s})=>{const[o,i]=b(0),[l,c]=b(Q.tz(t)),[m,d]=b(Q.tz(t)),u=Q.tz(),h=u.format(it)===l.format(it),{isMobile:p}=W(),v=r?Q(r):void 0,y=n?Q(n):void 0,f=()=>{i(w=>w===2?0:2)},g=w=>{c(w),i(N=>N===2?1:0)},_=w=>{d(w)},C=()=>{c(u)};return x(()=>{m.format()!==Q.tz(t).format()&&s(m.format(a))},[m]),x(()=>{const w=Q.tz(t);c(w),d(w)},[t]),e("div",{className:R({"vm-calendar":!0,"vm-calendar_mobile":p}),children:[e(fl,{viewDate:l,onChangeViewDate:g,toggleDisplayYears:f,showArrowNav:o===0,hasPrev:o===0&&(!v||l.startOf("month").isAfter(v)),hasNext:o===0&&(!y||l.endOf("month").isBefore(y))}),o===0&&e(bl,{minDate:v,maxDate:y,viewDate:l,selectDate:m,onChangeSelectDate:_}),o===2&&e(yl,{minDate:v,maxDate:y,viewDate:l,onChangeViewDate:g}),o===1&&e(_l,{minDate:v,maxDate:y,selectDate:m,viewDate:l,onChangeViewDate:g}),!h&&o===0&&e("div",{className:"vm-calendar-footer",children:e(O,{variant:"text",size:"small",onClick:C,children:"show today"})})]})},Ms=Mr(({date:t,targetRef:r,format:n=qe,onChange:a,label:s,minDate:o,maxDate:i},l)=>{const c=D(()=>Q(t).isValid()?Q.tz(t):Q().tz(),[t]),{isMobile:m}=W(),{value:d,toggle:u,setFalse:h}=de(!1),p=y=>{a(y),h()},v=y=>{(y.key==="Escape"||y.key==="Enter")&&h()};return oe("click",u,r),oe("keyup",v),e(q,{children:e(We,{open:d,buttonRef:r,placement:"bottom-right",onClose:h,title:m?s:void 0,children:e("div",{ref:l,children:e(Cl,{date:c,format:n,onChange:p,minDate:o,maxDate:i})})})})}),da=(t,r)=>Q(t).isValid()?Q.tz(t).format(r):t,Nl={[Rr]:"9999-99-99T99:99:99",[it]:"9999-99-99",[qe]:"9999-99-99 99:99:99"},ma=({value:t="",format:r=qe,minDate:n,maxDate:a,label:s,pickerLabel:o,pickerRef:i,onChange:l,onEnter:c,disabled:m})=>{const d=Z(null),[u,h]=b(null),p=Nl[r],[v,y]=b(da(t,r)),[f,g]=b(!1),[_,C]=b(!1),w=Q(v).isValid()?"":"Invalid date format",N=E=>{y(E.currentTarget.value)},S=()=>{l(v)},A=E=>{E.key==="Enter"&&(l(v),C(!0))},T=E=>{y(E),g(!0)};return x(()=>{const E=da(t,r);E!==v&&y(E),_&&(c(),C(!1))},[t]),x(()=>{f&&u&&(u.focus(),u.setSelectionRange(11,11),g(!1))},[f]),e("div",{className:R({"vm-date-time-input":!0,"vm-date-time-input_error":w,"vm-date-time-input_disabled":m}),children:[e("label",{children:s}),e(Ao,{tabIndex:1,inputRef:h,mask:p,placeholder:r,value:v,autoCapitalize:"none",inputMode:"numeric",maskChar:null,onChange:N,onBlur:S,onKeyUp:A,disabled:m}),w&&e("span",{className:"vm-date-time-input__error-text",children:w}),e("div",{className:"vm-date-time-input__icon",ref:d,children:e(O,{variant:"text",color:"gray",size:"small",startIcon:e(Tr,{}),ariaLabel:"calendar",disabled:m})}),e(Ms,{label:o,ref:i,date:v,onChange:T,targetRef:d,minDate:n,maxDate:a,format:r})]})},wl=()=>{const{isMobile:t}=W(),{isDarkTheme:r}=ne(),n=Z(null),a=Ct(),s=D(()=>a.width>1120,[a]),[o,i]=b(),[l,c]=b(),{period:{end:m,start:d},relativeTime:u,timezone:h,duration:p}=he(),v=Ge(),y=Me(),f=Gt(h),{value:g,toggle:_,setFalse:C}=de(!1),w=D(()=>({region:h,utc:qt(h)}),[h]);x(()=>{i(Ut(Ye(m)))},[h,m]),x(()=>{c(Ut(Ye(d)))},[h,d]);const N=({duration:$,until:V,id:H})=>{v({type:"SET_RELATIVE_TIME",payload:{duration:$,until:V,id:H}}),C()},S=D(()=>{const $=Q.tz(Ye(d)).format(qe),V=Q.tz(Ye(m)).format(qe);return{start:$,end:V}},[d,m,h]),A=D(()=>u&&u!=="none"?u.replace(/_/g," "):`${S.start} - ${S.end}`,[u,S]),T=Z(null),E=Z(null),M=Z(null),I=()=>{l&&o&&v({type:"SET_PERIOD",payload:{from:Q.tz(l).toDate(),to:Q.tz(o).toDate()}}),C()},k=()=>v({type:"RUN_QUERY_TO_NOW"}),L=()=>{i(Ut(Ye(m))),c(Ut(Ye(d))),C()};return x(()=>{const $=xn({relativeTimeId:u,defaultDuration:p,defaultEndInput:Ye(m)});f&&h!==f&&N({id:$.relativeTimeId,duration:$.duration,until:$.endInput})},[h,f]),Br(n,$=>{if(t)return;const V=$.target,H=T?.current&&T?.current?.contains(V),z=E?.current&&E?.current?.contains(V);H||z||C()}),e(q,{children:[e("div",{ref:M,children:t?e("div",{className:"vm-mobile-option",onClick:_,children:[e("span",{className:"vm-mobile-option__icon",children:e(jt,{})}),e("div",{className:"vm-mobile-option-text",children:[e("span",{className:"vm-mobile-option-text__label",children:"Time range"}),e("span",{className:"vm-mobile-option-text__value",children:A})]}),e("span",{className:"vm-mobile-option__arrow",children:e(Ae,{})})]}):e(G,{title:s?"Time range controls":A,children:e(O,{className:y?"":"vm-header-button",variant:"contained",color:"primary",startIcon:e(jt,{}),onClick:_,ariaLabel:"time range controls",children:s&&e("span",{children:A})})})}),e(We,{open:g,buttonRef:M,placement:"bottom-right",onClose:C,clickOutside:!1,title:t?"Time range controls":"",children:e("div",{className:R({"vm-time-selector":!0,"vm-time-selector_mobile":t}),ref:n,children:[e("div",{className:"vm-time-selector-left",children:[e("div",{className:R({"vm-time-selector-left-inputs":!0,"vm-time-selector-left-inputs_dark":r}),children:[e(ma,{value:l,label:"From:",pickerLabel:"Date From",pickerRef:T,onChange:c,onEnter:I}),e(ma,{value:o,label:"To:",pickerLabel:"Date To",pickerRef:E,onChange:i,onEnter:I})]}),e("div",{className:"vm-time-selector-left-timezone",children:[e("div",{className:"vm-time-selector-left-timezone__title",children:w.region}),e("div",{className:"vm-time-selector-left-timezone__utc",children:w.utc})]}),e(O,{variant:"text",startIcon:e(ns,{}),onClick:k,children:"switch to now"}),e("div",{className:"vm-time-selector-left__controls",children:[e(O,{color:"error",variant:"outlined",onClick:L,children:"Cancel"}),e(O,{color:"primary",onClick:I,children:"Apply"})]})]}),e(vl,{relativeTime:u||"",setDuration:N})]})})]})},nt=()=>{const[t,r]=me();return{setSearchParamsFromKeys:Y(a=>{const s=!!t.size,o=new URLSearchParams(t),i=t.toString();for(const[l,c]of Object.entries(a)){if(c==null||c===""){o.delete(l);continue}const d=String(c);o.get(l)!==d&&o.set(l,d)}i!==o.toString()&&r(o,{replace:!s})},[t,r])}},Sl=()=>{const{isMobile:t}=W(),r=Me(),n=Z(null),[a]=me(),{setSearchParamsFromKeys:s}=nt(),o=a.get("date")||Q().tz().format(it),i=D(()=>Q.tz(o).format(it),[o]),l=c=>{s({date:c})};return x(()=>{l(o)},[]),e("div",{children:[e("div",{ref:n,children:t?e("div",{className:"vm-mobile-option",children:[e("span",{className:"vm-mobile-option__icon",children:e(Tr,{})}),e("div",{className:"vm-mobile-option-text",children:[e("span",{className:"vm-mobile-option-text__label",children:"Date control"}),e("span",{className:"vm-mobile-option-text__value",children:i})]}),e("span",{className:"vm-mobile-option__arrow",children:e(Ae,{})})]}):e(G,{title:"Date control",children:e(O,{className:r?"":"vm-header-button",variant:"contained",color:"primary",startIcon:e(Tr,{}),children:i})})}),e(Ms,{label:"Date control",date:o||"",format:it,onChange:l,targetRef:n})]})},en=[{seconds:0,title:"Off"},{seconds:1,title:"1s"},{seconds:2,title:"2s"},{seconds:5,title:"5s"},{seconds:10,title:"10s"},{seconds:30,title:"30s"},{seconds:60,title:"1m"},{seconds:300,title:"5m"},{seconds:900,title:"15m"},{seconds:1800,title:"30m"},{seconds:3600,title:"1h"},{seconds:7200,title:"2h"}],Tl=({tooltip:t,useAutorefresh:r,closeModal:n})=>{const{isMobile:a}=W(),s=Ge(),o=Me(),[i,l]=b(!1),[c,m]=b(en[0]),{value:d,toggle:u,setFalse:h}=de(!1),p=Z(null),v=g=>{(i&&!g.seconds||!i&&g.seconds)&&l(_=>!_),m(g),h()},y=()=>{s({type:"RUN_QUERY"}),!r&&a&&n()};x(()=>{const g=c.seconds;let _;return i?_=setInterval(()=>{s({type:"RUN_QUERY"})},g*1e3):m(en[0]),()=>{_&&clearInterval(_)}},[c,i]);const f=g=>()=>{v(g)};return e(q,{children:[e("div",{className:"vm-execution-controls",children:e("div",{className:R({"vm-execution-controls-buttons":!0,"vm-execution-controls-buttons_mobile":a,"vm-header-button":!o,"vm-autorefresh":r}),children:r?a?e("div",{className:"vm-mobile-option",onClick:u,children:[e("span",{className:"vm-mobile-option__icon",children:e(ft,{})}),e("div",{className:"vm-mobile-option-text",children:[e("span",{className:"vm-mobile-option-text__label",children:"Auto-refresh"}),e("span",{className:"vm-mobile-option-text__value",children:c.title})]}),e("span",{className:"vm-mobile-option__arrow",children:e(Ae,{})})]}):e(q,{children:[e(G,{title:t,children:e(O,{variant:"contained",color:"primary",onClick:y,startIcon:e(Qt,{}),ariaLabel:t})}),e(G,{title:"Auto-refresh control",children:e("div",{ref:p,children:e(O,{variant:"contained",color:"primary",fullWidth:!0,endIcon:e("div",{className:R({"vm-execution-controls-buttons__arrow":!0,"vm-execution-controls-buttons__arrow_open":d}),children:e(Ae,{})}),onClick:u,children:c.title})})})]}):a?e("div",{className:"vm-mobile-option",onClick:y,children:[e("span",{className:"vm-mobile-option__icon",children:e(ft,{})}),e("div",{className:"vm-mobile-option-text",children:e("span",{className:"vm-mobile-option-text__label",children:"Refresh"})})]}):e(O,{variant:"contained",color:"primary",onClick:y,startIcon:e(Qt,{}),ariaLabel:t})})}),r&&e(We,{open:d,placement:"bottom-right",onClose:h,buttonRef:p,title:a?"Auto-refresh duration":void 0,children:e("div",{className:R({"vm-execution-controls-list":!0,"vm-execution-controls-list_mobile":a}),children:en.map(g=>e("div",{className:R({"vm-list-item":!0,"vm-list-item_mobile":a,"vm-list-item_active":g.seconds===c.seconds}),onClick:f(g),children:g.title},g.seconds))})})]})},ua={enable:"Enable to save the modified server URL to local storage, preventing reset upon page refresh.",disable:"Disable to stop saving the server URL to local storage, reverting to the default URL on page refresh."},El=Mr(({onClose:t},r)=>{const{serverUrl:n}=ne(),a=Jt(),{value:s,toggle:o}=de(!!be("SERVER_URL")),[i,l]=b(n),[c,m]=b(""),d=h=>{l(h||""),m("")},u=Y(()=>{a({type:"SET_SERVER",payload:i}),t()},[i]);return x(()=>{n||m(ge.emptyServer),yr(n)||m(ge.validServer)},[n]),x(()=>{s?Ne("SERVER_URL",i):gr(["SERVER_URL"])},[s]),x(()=>{n!==i&&l(n)},[n]),yn(r,()=>({handleApply:u}),[u]),e("div",{children:[e("div",{className:"vm-server-configurator__title",children:"Server URL"}),e("div",{className:"vm-server-configurator-url",children:[e(ie,{autofocus:!0,value:i,error:c,onChange:d,onEnter:u,inputmode:"url"}),e(G,{title:s?ua.disable:ua.enable,children:e(O,{className:"vm-server-configurator-url__button",variant:"text",color:s?"primary":"gray",onClick:o,startIcon:e(xr,{})})})]})]})}),Ie=({value:t=!1,disabled:r=!1,label:n,color:a="secondary",fullWidth:s,onChange:o})=>{const i=()=>{r||o(!t)},l=R({"vm-switch":!0,"vm-switch_full-width":s,"vm-switch_disabled":r,"vm-switch_active":t,[`vm-switch_${a}_active`]:t,[`vm-switch_${a}`]:a});return e("div",{className:l,onClick:i,children:[e("div",{className:"vm-switch-track",children:e("div",{className:"vm-switch-track__thumb"})}),n&&e("span",{className:"vm-switch__label",children:n})]})},xl=[{label:"Graph",type:pe.chart},{label:"JSON",type:pe.code},{label:"Table",type:pe.table}],Al=Mr(({onClose:t},r)=>{const{isMobile:n}=W(),{seriesLimits:a}=$e(),s=Pt(),o=be("LEGEND_AUTO_COLLAPSE"),[i,l]=b(o?o==="true":!0),[c,m]=b(a),[d,u]=b({table:"",chart:"",code:""}),h=()=>{m(Oa)},p=y=>f=>{const g=f||"";u(_=>({..._,[y]:+g<0?ge.positiveNumber:""})),m({...c,[y]:g||1/0})},v=Y(()=>{s({type:"SET_SERIES_LIMITS",payload:c}),t()},[c]);return x(()=>{Ne("LEGEND_AUTO_COLLAPSE",`${i}`)},[i]),yn(r,()=>({handleApply:v}),[v]),e("div",{className:"vm-limits-configurator",children:[e("div",{className:"vm-server-configurator__title",children:["Series limits by tabs",e(G,{title:"Set to 0 to disable the limit",children:e(O,{variant:"text",color:"primary",size:"small",startIcon:e(lt,{})})}),e("div",{className:"vm-limits-configurator-title__reset",children:e(O,{variant:"text",color:"primary",size:"small",startIcon:e(ft,{}),onClick:h,children:"Reset limits"})})]}),e("div",{className:R({"vm-limits-configurator__inputs":!0,"vm-limits-configurator__inputs_mobile":n}),children:xl.map(y=>e("div",{children:e(ie,{label:y.label,value:c[y.type],error:d[y.type],onChange:p(y.type),onEnter:v,type:"number"})},y.type))}),e("div",{className:"vm-graph-settings-row",children:[e("span",{className:"vm-graph-settings-row__label",children:"Auto-collapse legend"}),e(Ie,{value:i,onChange:l,label:i?"Enabled":"Disabled",fullWidth:n}),e("span",{className:"vm-legend-configs-item__info",children:["Collapses the legend when series count exceeds ",Ha," to reduce UI load."]})]})]})}),Nt=({defaultExpanded:t=!1,onChange:r,title:n,children:a,id:s})=>{const[o,i]=b(t),l=c=>{const m=window.getSelection();if(c.target.closest("button")){c.preventDefault();return}if(m&&m.toString()){c.preventDefault();return}i(d=>{const u=!d;return r&&r(u),u})};return x(()=>{i(t)},[t]),e(q,{children:[e("header",{className:R({"vm-accordion-header":!0,"vm-accordion-header_open":o}),onClick:l,id:s,children:[n,e("div",{className:R({"vm-accordion-header__arrow":!0,"vm-accordion-header__arrow_open":o}),children:e(Ae,{})})]}),o&&e("section",{className:"vm-accordion-section",children:a},"content")]})},Ll="Browser timezone is not recognized, supported, or could not be determined.",kl=()=>e(G,{title:Ll,children:e(Mn,{})}),lr=An(),Ml=Mr((t,r)=>{const{isMobile:n}=W(),a=oa(),{timezone:s,defaultTimezone:o}=he(),i=Ge(),[l,c]=b(s),[m,d]=b(""),u=Z(null),{value:h,toggle:p,setFalse:v}=de(!1),y=D(()=>[{title:`Default time (${o})`,region:o,utc:o?qt(o):"UTC"},{title:lr.title,region:lr.region,utc:qt(lr.region),isInvalid:!lr.isValid},{title:"UTC (Coordinated Universal Time)",region:"UTC",utc:"UTC"}].filter(S=>S.region),[o]),f=D(()=>{if(!m)return a;try{return oa(m)}catch{return{}}},[m,a]),g=D(()=>Object.keys(f),[f]),_=D(()=>({region:l,utc:qt(l)}),[l]),C=S=>{d(S)},w=S=>{c(S.region),d(""),v()},N=S=>()=>{w(S)};return x(()=>{c(s)},[s]),yn(r,()=>({handleApply:()=>{i({type:"SET_TIMEZONE",payload:l})}}),[l]),e("div",{className:"vm-timezones",children:[e("div",{className:"vm-server-configurator__title",children:"Time zone"}),e("div",{className:"vm-timezones-item vm-timezones-item_selected",onClick:p,ref:u,children:[e("div",{className:"vm-timezones-item__title",children:_.region}),e("div",{className:"vm-timezones-item__utc",children:_.utc}),e("div",{className:R({"vm-timezones-item__icon":!0,"vm-timezones-item__icon_open":h}),children:e(Xe,{})})]}),e(We,{open:h,buttonRef:u,placement:"bottom-left",onClose:v,fullWidth:!0,title:n?"Time zone":void 0,children:e("div",{className:R({"vm-timezones-list":!0,"vm-timezones-list_mobile":n}),children:[e("div",{className:"vm-timezones-list-header",children:[e("div",{className:"vm-timezones-list-header__search",children:e(ie,{autofocus:!0,label:"Search",value:m,onChange:C})}),y.map((S,A)=>S&&e("div",{className:"vm-timezones-item vm-timezones-list-group-options__item",onClick:N(S),children:[e("div",{className:"vm-timezones-item__title",children:[S.title,S.isInvalid&&e(kl,{})]}),e("div",{className:"vm-timezones-item__utc",children:S.utc})]},`${A}_${S.region}`))]}),g.map(S=>e("div",{className:"vm-timezones-list-group",children:e(Nt,{defaultExpanded:!0,title:e("div",{className:"vm-timezones-list-group__title",children:S}),children:e("div",{className:"vm-timezones-list-group-options",children:f[S]&&f[S].map(A=>e("div",{className:"vm-timezones-item vm-timezones-list-group-options__item",onClick:N(A),children:[e("div",{className:"vm-timezones-item__title",children:A.region}),e("div",{className:"vm-timezones-item__utc",children:A.utc})]},A.search))})})},S))]})})]})}),Il=({options:t,value:r,label:n,onChange:a})=>{const s=Z(null),[o,i]=b({width:"0px",left:"0px",borderRadius:"0px"}),l=c=>()=>{a(c)};return x(()=>{if(!s.current){i({width:"0px",left:"0px",borderRadius:"0px"});return}const c=t.findIndex(p=>p.value===r),{width:m}=s.current.getBoundingClientRect();let d=m,u=c*d,h="0";c===0&&(h="16px 0 0 16px"),c===t.length-1&&(h="10px",u-=1,h="0 16px 16px 0"),c!==0&&c!==t.length-1&&(d+=1,u-=1),i({width:`${d}px`,left:`${u}px`,borderRadius:h})},[s,r,t]),e("div",{className:"vm-toggles",children:[n&&e("label",{className:"vm-toggles__label",children:n}),e("div",{className:"vm-toggles-group",style:{gridTemplateColumns:`repeat(${t.length}, 1fr)`},children:[o.borderRadius&&e("div",{className:"vm-toggles-group__highlight",style:o}),t.map((c,m)=>e("div",{className:R({"vm-toggles-group-item":!0,"vm-toggles-group-item_first":m===0,"vm-toggles-group-item_active":c.value===r,"vm-toggles-group-item_icon":c.icon&&c.title}),onClick:l(c.value),ref:c.value===r?s:null,children:[c.icon,c.title]},c.value))]})]})},Dl=Object.values(Ve).map(t=>({title:t,value:t})),Rl=()=>{const{isMobile:t}=W(),r=Jt(),{theme:n}=ne(),a=s=>{r({type:"SET_THEME",payload:s})};return e("div",{className:R({"vm-theme-control":!0,"vm-theme-control_mobile":t}),children:[e("div",{className:"vm-server-configurator__title",children:"Theme preferences"}),e("div",{className:"vm-theme-control__toggle",children:e(Il,{options:Dl,value:n,onChange:a})},`${t}`)]})},tn="Settings",Pl=()=>{const{isMobile:t}=W(),r=Me(),n=Z(null),a=Z(null),s=Z(null),{value:o,setTrue:i,setFalse:l}=de(!1),c=()=>{n.current&&n.current.handleApply(),a.current&&a.current.handleApply(),s.current&&s.current.handleApply(),l()},m=[{show:!r,component:e(El,{ref:n,onClose:l})},{show:!0,component:e(Al,{ref:a,onClose:l})},{show:!0,component:e(Ml,{ref:s})},{show:!r,component:e(Rl,{})}].filter(d=>d.show);return e(q,{children:[t?e("div",{className:"vm-mobile-option",onClick:i,children:[e("span",{className:"vm-mobile-option__icon",children:e(vt,{})}),e("div",{className:"vm-mobile-option-text",children:e("span",{className:"vm-mobile-option-text__label",children:tn})}),e("span",{className:"vm-mobile-option__arrow",children:e(Ae,{})})]}):e(G,{title:tn,children:e(O,{className:R({"vm-header-button":!r}),variant:"contained",color:"primary",startIcon:e(vt,{}),onClick:i,ariaLabel:"settings"})}),o&&e(we,{title:tn,onClose:l,children:e("div",{className:R({"vm-server-configurator":!0,"vm-server-configurator_mobile":t}),children:[m.map((d,u)=>e("div",{className:"vm-server-configurator__input",children:d.component},u)),e("div",{className:"vm-server-configurator-footer",children:[e(O,{color:"error",variant:"outlined",onClick:l,children:"Cancel"}),e(O,{color:"primary",variant:"contained",onClick:c,children:"Apply"})]})]})})]})},$l=({displaySidebar:t,isMobile:r,headerSetup:n,accountIds:a,closeModal:s})=>e("div",{className:R({"vm-header-controls":!0,"vm-header-controls_mobile":r}),children:[n?.tenant&&e(hl,{accountIds:a||[]}),n?.stepControl&&e(pl,{}),n?.timeSelector&&e(wl,{}),n?.cardinalityDatePicker&&e(Sl,{}),n?.executionControls&&e(Tl,{tooltip:n?.executionControls?.tooltip,useAutorefresh:n?.executionControls?.useAutorefresh,closeModal:s}),e(Pl,{}),!t&&e(ks,{})]}),Ol=!!be("DISABLED_DEFAULT_TIMEZONE"),Hl=()=>{const{serverUrl:t}=ne(),r=Ge(),[n,a]=b(!1),[s,o]=b(""),i=c=>{const m=c.toLowerCase()==="local"?An().region:c;try{if(Q().tz(m).isValid(),r({type:"SET_DEFAULT_TIMEZONE",payload:m}),Ol)return;r({type:"SET_TIMEZONE",payload:m})}catch(d){d instanceof Error&&o(`${d.name}: ${d.message}`)}},l=async()=>{if(t){o(""),a(!0);try{const c=await fetch(`${t}/vmui/timezone`),m=await c.json();c.ok?(i(m.timezone),a(!1)):(o(m.error),a(!1))}catch(c){a(!1),c instanceof Error&&o(`${c.name}: ${c.message}`)}}};return x(()=>{l()},[t]),{isLoading:n,error:s}},zl=()=>{const{serverUrl:t}=ne(),r=Jt(),[n,a]=b(!1),[s,o]=b("");return x(()=>{(async()=>{o(""),a(!0);try{const c=await(await fetch(`${t}/vmui/config.json`)).json();r({type:"SET_APP_CONFIG",payload:c||{}})}catch(l){a(!1),l instanceof Error&&o(`${l.name}: ${l.message}`)}})()},[t]),{isLoading:n,error:s}};var Ze=(t=>(t.NO_STORAGE="NO_STORAGE",t.SECURITY_ERROR="SECURITY_ERROR",t.QUOTA_EXCEEDED="QUOTA_EXCEEDED",t.UNKNOWN="UNKNOWN",t))(Ze||{});const Fl={[Ze.NO_STORAGE]:{title:"Storage unavailable",description:"Browser storage is not available for this website.",fix:["Disable Private/Incognito mode and reload the page.","Disable privacy or ad-blocking extensions for this site and reload.","Open the site in another browser."]},[Ze.SECURITY_ERROR]:{title:"Storage access blocked",description:"Browser settings or an extension are blocking access to browser storage.",fix:["Disable Private/Incognito mode and reload the page.","Disable privacy or ad-blocking extensions for this site and reload.","Open the site in a regular browser tab (not embedded)."]},[Ze.QUOTA_EXCEEDED]:{title:"Storage quota exceeded",description:"The storage limit for this website has been reached.",fix:["Clear this website’s stored data and reload the page.","Close other tabs for this website and try again.","Use another browser or browser profile."]},[Ze.UNKNOWN]:{title:"Storage error",description:"An unexpected error occurred while accessing browser storage.",fix:["Reload the page.","Update the browser and try again.","Disable browser extensions and reload."]}},Vl=t=>{if(!(t instanceof DOMException))return Ze.UNKNOWN;switch(t.name){case"QuotaExceededError":return Ze.QUOTA_EXCEEDED;case"SecurityError":return Ze.SECURITY_ERROR;default:return Ze.UNKNOWN}},Ul=t=>{if(!t)return Ze.NO_STORAGE;try{const r="__vmui_test__";return t.setItem(r,"1"),t.removeItem(r),null}catch(r){return Vl(r)}},ql=()=>{const{showInfoMessage:t}=Vn();return x(()=>{const r=Ul(window.localStorage);if(r){const{title:n,description:a,fix:s}=Fl[r],o=e("div",{className:"vm-storage-check",children:[e("h3",{children:n}),e("p",{children:a}),!!s?.length&&e("div",{className:"vm-storage-check__fix",children:[e("div",{children:"Try this:"}),e("ul",{children:s.map((i,l)=>e("li",{children:i},`${l}-${i}`))})]})]});t({text:o,type:"error",timeout:6e5})}},[]),null},Bl=()=>{const t=Me(),{isMobile:r}=W(),{pathname:n}=ct(),[a,s]=me();ml(),Hl(),zl();const o=()=>{const l="vmui",c=Wt[n]?.title;document.title=c?`${c} - ${l}`:l},i=()=>{const{search:l,href:c}=window.location;if(l){const d=Ma.parse(l,{ignoreQueryPrefix:!0});Object.entries(d).forEach(([u,h])=>a.set(u,h)),s(a),window.location.search=""}const m=c.replace(/\/\?#\//,"/#/");m!==c&&window.location.replace(m)};return x(o,[n]),x(i,[]),x(()=>{const l=Oo();(l.removed.length||l.migrated.length)&&console.info(l)},[]),e("section",{className:"vm-container",children:[e(ol,{controlsComponent:$l}),e("div",{className:R({"vm-container-body":!0,"vm-container-body_mobile":r,"vm-container-body_app":t}),children:e(Lo,{})}),!t&&e(cl,{}),e(ql,{})]})},Ql=`No match!
This query hasn't selected any time series from database.
Either the requested metrics are missing in the database,
or there is a typo in series selector.`,jl=`The shown results are marked as PARTIAL.
The result is marked as partial if one or more vmstorage nodes failed to respond to the query.`,Yl=({value:t,onChange:r,onEnter:n,onArrowUp:a,onArrowDown:s,autocomplete:o,autocompleteEl:i,error:l,stats:c,label:m,disabled:d=!1,includeFunctions:u=!0})=>{const{autocompleteQuick:h}=Pe(),{isMobile:p}=W(),[v,y]=b(!1),[f,g]=b([0,0]),[_,C]=b([0,0]),w=Z(null),[N,S]=b(!1),A=Z(Dt(S,500)).current,T=[{show:c?.seriesFetched==="0"&&!c.resultLength,text:Ql},{show:c?.isPartial,text:jl}].filter(L=>L.show).map(L=>L.text).join("");c&&(m=`${m} (${c.executionTimeMsec||0}ms)`);const E=(L,$)=>{r(L),C([$,$])},M=L=>{const{key:$,ctrlKey:V,metaKey:H,shiftKey:z}=L,ee=(L.target.value||"").split(`
`).length>1,X=V||H,B=$==="ArrowUp",ae=$==="ArrowDown",le=$==="Enter";B&&X&&(L.preventDefault(),a()),ae&&X&&(L.preventDefault(),s()),le&&v&&L.preventDefault(),le&&!z&&(!ee||X)&&!v&&(L.preventDefault(),n())},I=L=>{y(!!L.length)},k=L=>{g($=>$[0]===L[0]&&$[1]===L[1]?$:L)};return x(()=>{y(!!i&&h)},[h]),x(()=>{S(!1),A(f.every(Boolean))},[f]),e("div",{className:"vm-query-editor",ref:w,children:[e(ie,{value:t,label:m,type:"textarea",autofocus:!p,error:l,warning:T,onKeyDown:M,onChange:r,onChangeCaret:k,disabled:d,inputmode:"search",caretPosition:_}),N&&o&&i&&e(i,{value:t,anchorEl:w,caretPosition:f,hasHelperText:!!(T||l),includeFunctions:u,onSelect:E,onFoundOptions:I})]})},ha=({isMobile:t,hideButtons:r})=>{const{autocomplete:n}=Pe(),a=Zt(),{nocache:s,isTracingEnabled:o,reduceMemUsage:i}=$e(),l=Pt(),c=()=>{l({type:"TOGGLE_NO_CACHE"})},m=()=>{l({type:"TOGGLE_REDUCE_MEM_USAGE"})},d=()=>{l({type:"TOGGLE_QUERY_TRACING"})},u=()=>{a({type:"TOGGLE_AUTOCOMPLETE"})},h=()=>{a({type:"SET_AUTOCOMPLETE_QUICK",payload:!0})};return oe("keydown",v=>{const{code:y,ctrlKey:f,altKey:g}=v;y==="Space"&&(f||g)&&(v.preventDefault(),h())}),e("div",{className:R({"vm-additional-settings":!0,"vm-additional-settings_mobile":t}),children:[!r?.autocomplete&&e(G,{title:e(q,{children:["Quick tip: ",Ls]}),children:e(Ie,{label:"Autocomplete",value:n,onChange:u,fullWidth:t})}),!r?.disableCache&&e(Ie,{label:"Disable cache",value:s,onChange:c,fullWidth:t}),!r?.reduceMemUsage&&e(Ie,{label:"Disable deduplication",value:i,onChange:m,fullWidth:t}),!r?.traceQuery&&e(Ie,{label:"Trace query",value:o,onChange:d,fullWidth:t})]})},Gl=t=>{const{isMobile:r}=W(),n=Z(null),{value:a,toggle:s,setFalse:o}=de(!1);return r?e(q,{children:[e("div",{ref:n,children:e(O,{variant:"outlined",startIcon:e(ds,{}),onClick:s,ariaLabel:"additional the query settings"})}),e(We,{open:a,buttonRef:n,placement:"bottom-left",onClose:o,title:"Query settings",children:e(ha,{isMobile:r,...t})})]}):e(ha,{...t})},Qr=(t,r)=>t.length===r.length&&t.every((n,a)=>n===r[a]),Wl=()=>{const{serverUrl:t}=ne();return async n=>{try{const a=encodeURIComponent(n),s=`${t}/prettify-query?query=${a}`,o=await fetch(s);if(o.status!=200)return{query:n,error:"Error requesting /prettify-query, status: "+o.status};const i=await o.json();return i.status!="success"?{query:n,error:String(i.msg)}:{query:String(i.query),error:""}}catch(a){return console.error(a),a instanceof Error&&a.name!=="AbortError"?{query:n,error:`${a.name}: ${a.message}`}:{query:n,error:String(a)}}}},Ke=()=>{const{showInfoMessage:t}=Vn();return async(r,n)=>{if(!navigator?.clipboard)return t({text:e(Kl,{}),type:"error",timeout:2e4}),!1;try{return await navigator.clipboard.writeText(r),n&&t({text:n,type:"success"}),!0}catch(a){return a instanceof Error&&t({text:`${a.name}: ${a.message}`,type:"error"}),console.warn("Copy failed",a),!1}}},Kl=()=>e("div",{className:"vm-snackbar-details",children:[e("p",{className:"vm-snackbar-details__title",children:"Clipboard not supported"}),window.isSecureContext?e("p",{className:"vm-snackbar-details__msg",children:[e("p",{children:"Common reasons:"}),e("ul",{children:[e("li",{children:"Browser restrictions"}),e("li",{children:"Insecure connection (HTTP)"}),e("li",{children:"Permissions not granted"})]}),e("p",{children:["For detailed information, visit the ",e("a",{className:"vm-link vm-link_underlined vm-link_colored",href:"https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API#security_considerations",target:"_blank",rel:"noopener noreferrer",children:"Clipboard API documentation"})]})]}):e("p",{className:"vm-snackbar-details__msg",children:[e("p",{children:"This page is not running in a secure context (HTTPS)."}),e("p",{children:"Clipboard operations require a secure context."}),e("a",{className:"vm-link vm-link_underlined vm-link_colored",href:"https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts",target:"_blank",rel:"noopener noreferrer",children:"Learn more about secure contexts"})]})]}),Jl=({query:t,favorites:r,onRun:n,onToggleFavorite:a})=>{const s=Ke(),o=D(()=>r.includes(t),[t,r]);return e("div",{className:"vm-query-history-item",children:[e("span",{className:"vm-query-history-item__value",children:t}),e("div",{className:"vm-query-history-item__buttons",children:[e(G,{title:"Execute query",children:e(O,{size:"small",variant:"text",onClick:()=>{n(t)},startIcon:e(zr,{})})}),e(G,{title:"Copy query",children:e(O,{size:"small",variant:"text",onClick:async()=>{await s(t,"Query has been copied")},startIcon:e(_t,{})})}),e(G,{title:o?"Remove Favorite":"Add to Favorites",children:e(O,{size:"small",variant:"text",color:o?"warning":"primary",onClick:()=>{a(t,o)},startIcon:o?e(us,{}):e(ms,{})})})]})]})},ut={session:"session",storage:"saved",favorite:"favorite"},pa=[{label:"Session history",value:ut.session},{label:"Saved history",value:ut.storage},{label:"Favorite queries",value:ut.favorite}],Zl=({handleSelectQuery:t,historyKey:r})=>{const{queryHistory:n}=Pe(),{isMobile:a}=W(),{value:s,setTrue:o,setFalse:i}=de(!1),[l,c]=b(pa[0].value),[m,d]=b(Ft(r,"QUERY_HISTORY")),[u,h]=b(Ft(r,"QUERY_FAVORITES")),p=D(()=>n.map(N=>N.values.filter(S=>S).reverse()),[n]),v=D(()=>{switch(l){case ut.favorite:return u;case ut.storage:return m;default:return p}},[l,u,m,p]),y=v?.every(N=>!N.length),f=D(()=>l===ut.favorite?`Favorites queries are empty.
To see your favorites, mark a query as a favorite.`:`Query history is empty.
To see the history, please make a query.`,[l]),g=N=>S=>{t(S,N),i()},_=(N,S)=>{h(A=>{const T=A[0]||[];return S?[T.filter(E=>E!==N)]:!S&&!T.includes(N)?[[...T,N]]:A})},C=()=>{d(Ft(r,"QUERY_HISTORY")),h(Ft(r,"QUERY_FAVORITES"))},w=()=>{fi(r,"QUERY_HISTORY")};return x(()=>{const N=u[0]||[],S=Ft(r,"QUERY_FAVORITES")[0]||[];Qr(N,S)||vi(r,u)},[u]),oe("storage",C),e(q,{children:[e(G,{title:"Show history",children:e(O,{color:"primary",variant:"text",onClick:o,startIcon:e(jt,{}),ariaLabel:"Show history"})}),s&&e(we,{title:"Query history",onClose:i,children:e("div",{className:R({"vm-query-history":!0,"vm-query-history_mobile":a}),children:[e("div",{className:R({"vm-query-history__tabs":!0,"vm-section-header__tabs":!0,"vm-query-history__tabs_mobile":a}),children:e(rr,{activeItem:l,items:pa,onChange:c})}),e("div",{className:"vm-query-history-list",children:[y&&e("div",{className:"vm-query-history-list__no-data",children:f}),v.map((N,S)=>e("div",{children:[v.length>1&&e("div",{className:R({"vm-query-history-list__group-title":!0,"vm-query-history-list__group-title_first":S===0}),children:["Query ",S+1]}),N.map((A,T)=>e(Jl,{query:A,favorites:u.flat(),onRun:g(S),onToggleFavorite:_},T))]},S)),l===ut.storage&&!y&&e("div",{className:"vm-query-history-footer",children:e(O,{color:"error",variant:"outlined",size:"small",startIcon:e(Vr,{}),onClick:w,children:"clear history"})})]})]})})]})},Is=({value:t,itemClassName:r,options:n,anchor:a,disabled:s,minLength:o=2,fullWidth:i,selected:l,noOptionsText:c,label:m,disabledFullScreen:d,offset:u,maxDisplayResults:h,loading:p,onSelect:v,onOpenAutocomplete:y,onFoundOptions:f,onChangeWrapperRef:g})=>{const{isMobile:_}=W(),C=Z(null),[w,N]=b({index:-1}),[S,A]=b(""),[T,E]=b(0),{value:M,setValue:I,setFalse:k}=de(!1),L=D(()=>{if(!M)return[];try{const B=new RegExp(String(t.trim()),"i"),le=n.filter(F=>B.test(F.value)).sort((F,P)=>F.value.toLowerCase()===t.trim().toLowerCase()?-1:P.value.toLowerCase()===t.trim().toLowerCase()?1:(F.value.match(B)?.index||0)-(P.value.match(B)?.index||0));return E(le.length),A(le.length>Number(h?.limit)&&h?.message||""),h?.limit?le.slice(0,h.limit):le}catch{return[]}},[M,n,t]),$=D(()=>L.length===1&&L[0]?.value===t,[L]),V=D(()=>c&&!L.length,[c,L]),H=B=>()=>{s||(v(B.value,B),l||k())},z=B=>()=>{N({index:B,type:0})},j=()=>{N({index:-1})},ee=()=>{if(!C.current||w.type===0)return;const B=C.current.childNodes[w.index];B?.scrollIntoView&&B.scrollIntoView({block:"center"})},X=Y(B=>{const{key:ae,ctrlKey:le,metaKey:F,shiftKey:P}=B,U=le||F||P,J=L.length&&!$;if(ae==="ArrowUp"&&!U&&J&&(B.preventDefault(),N(({index:re})=>({index:re<=0?0:re-1,type:1}))),ae==="ArrowDown"&&!U&&J){B.preventDefault();const re=L.length-1;N(({index:se})=>({index:se>=re?re:se+1,type:1}))}if(ae==="Enter"){const re=L[w.index];re&&v(re.value,re),l||k()}ae==="Escape"&&k()},[w,L,$,k,v,l]);return x(()=>{I(t.length>=o)},[t,n]),oe("keydown",X),x(ee,[w,L]),x(()=>{N({index:-1})},[L]),x(()=>{y&&y(M)},[M]),x(()=>{f&&f($?[]:L)},[L,$]),x(()=>{g&&g(C)},[C]),e(We,{open:M,buttonRef:a,placement:"bottom-left",onClose:k,fullWidth:i,title:_?m:void 0,disabledFullScreen:d,offset:u,children:[e("div",{className:R({"vm-autocomplete":!0,"vm-autocomplete_mobile":_&&!d}),ref:C,children:[p&&e("div",{className:"vm-autocomplete__loader",children:[e(Qt,{}),e("span",{children:"Loading..."})]}),V&&e("div",{className:"vm-autocomplete__no-options",children:c}),!$&&L.map((B,ae)=>e("div",{className:R({"vm-list-item":!0,"vm-list-item_mobile":_,"vm-list-item_active":ae===w.index,"vm-list-item_multiselect":l,"vm-list-item_multiselect_selected":l?.includes(B.value),"vm-list-item_with-icon":B.icon}),id:`$autocomplete$${B.value}`,onClick:H(B),onMouseEnter:z(ae),onMouseLeave:j,children:[l?.includes(B.value)&&e(Ur,{}),e(q,{children:B.icon}),e("div",{className:`vm-list-item-inner ${r} ${B.value.toLowerCase().replace(" ","-")}`,children:e("span",{children:B.value})})]},`${ae}${B.value}`))]}),S&&e("div",{className:"vm-autocomplete-message",children:["Shown ",h?.limit," results out of ",T,". ",S]}),L[w.index]?.description&&e("div",{className:"vm-autocomplete-info",children:[e("div",{className:"vm-autocomplete-info__type",children:L[w.index].type}),e("div",{className:"vm-autocomplete-info__description",dangerouslySetInnerHTML:{__html:L[w.index].description||""}})]})]})},Ar=t=>t.replace(/[/\-\\^$*+?.()|[\]{}]/g,"\\$&"),cr=t=>JSON.stringify(t).slice(1,-1),Ds=t=>{const r=t.match(/["`']/g);return r?r.length%2!==0:!1},Xl={metric:e(hs,{}),label:e(vs,{}),labelValue:e(fs,{})},ec=({valueByContext:t,metric:r,label:n,context:a,labelMatchers:s})=>{const{serverUrl:o}=ne(),{period:{start:i,end:l}}=he(),{autocompleteCache:c}=Pe(),m=Zt(),[d,u]=b(!1),[h,p]=b(t),v=Dt(p,500);x(()=>(v(t),v.cancel),[t,v]);const[y,f]=b([]),[g,_]=b([]),[C,w]=b([]),N=Z(new AbortController),S=Y(E=>{const M=Q(i*1e3).startOf("day").valueOf()/1e3,I=Q(l*1e3).endOf("day").valueOf()/1e3;return new URLSearchParams({...E||{},limit:`${Sr.queryLimit}`,start:`${M}`,end:`${I}`})},[i,l]),A=(E,M)=>E.map(I=>({value:I,type:`${M}`,icon:Xl[M]})),T=async({value:E,urlSuffix:M,setter:I,type:k,params:L})=>{if(!E&&k==="metric")return;N.current.abort(),N.current=new AbortController;const{signal:$}=N.current,V={type:k,value:E,start:L?.get("start")||"",end:L?.get("end")||"",match:L?.get("match[]")||""};u(!0);try{const H=c.get(V);if(H){I(A(H,k)),u(!1);return}const z=await fetch(`${o}/api/v1/${M}?${L}`,{signal:$});if(z.ok){const{data:j}=await z.json();I(A(j,k)),m({type:"SET_AUTOCOMPLETE_CACHE",payload:{key:V,value:j}})}u(!1)}catch(H){H instanceof Error&&H.name!=="AbortError"&&(m({type:"SET_AUTOCOMPLETE_CACHE",payload:{key:V,value:[]}}),u(!1),console.error(H))}};return x(()=>{const E=a!==xe.metricsql&&a!==xe.empty;if(!o||!r||E)return;f([]);const M=cr(Ar(r));return T({value:h,urlSuffix:"label/__name__/values",setter:f,type:"metric",params:S({"match[]":`{__name__=~".*${M}.*"}`})}),()=>N.current?.abort()},[o,h,a,r]),x(()=>{if(!o||a!==xe.label)return;_([]);const E=cr(r),I=[r?`__name__="${E}"`:"",...s].filter(Boolean).join(",");return T({value:h,urlSuffix:"labels",setter:_,type:"label",params:S({"match[]":`{${I}}`})}),()=>N.current?.abort()},[o,h,a,r,s]),x(()=>{if(!o||!n||a!==xe.labelValue)return;w([]);const E=cr(r),M=cr(Ar(h)),I=r?`__name__="${E}"`:"",k=`${n}=~".*${M}.*"`,L=[I,...s,k].filter(Boolean).join(",");return T({value:h,urlSuffix:`label/${n}/values`,setter:w,type:"labelValue",params:S({"match[]":`{${L}}`})}),()=>N.current?.abort()},[o,h,a,r,n,s]),{metrics:y,labels:g,labelValues:C,loading:d}},tc=""+new URL("MetricsQL-DDLrk-ox.md",import.meta.url).href,Rs="h3",rc="h4",nc="p",ac="https://docs.victoriametrics.com/victoriametrics/metricsql/",sc="vm-link vm-link_colored",oc=t=>{const r=`$1 target="_blank" class="${sc}" $2${ac}#`;return t.replace(/(<a) (href=")#/gm,r)},ic=t=>{const r=[];let n=t.nextElementSibling;for(;n&&n.tagName.toLowerCase()===nc;)n&&r.push(n),n=n.nextElementSibling;return r},lc=(t,r)=>{const n=r.textContent??"",s=ic(r).map(o=>o.outerHTML??"").join(`
`);return{type:t,value:n,description:oc(s),icon:e(ps,{})}},cc=t=>{let r="";return Array.from(t).map(n=>{const a=n.tagName.toLowerCase()===Rs;return r=a?n.textContent??"":r,a?null:lc(r,n)}).filter(Boolean)},dc=t=>{const{metricsQLFunctions:r}=Pe(),n=Zt(),a=s=>{const o=document.createElement("div");o.innerHTML=Ir(s);const i=o.querySelectorAll(`${Rs}, ${rc}`);return cc(i)};return x(()=>{if(!t||r.length)return;(async()=>{try{const i=await(await fetch(tc)).text(),l=a(i);n({type:"SET_METRICSQL_FUNCTIONS",payload:l})}catch(o){console.error("Error fetching or processing the MetricsQL.md file:",o)}})()},[]),t?r:[]};function mc(t){const r=/\s(or|and|unless|default|ifnot|if|group_left|group_right)\s|}|\+|\|-|\*|\/|\^/i,n=t.split(r),a=n[n.length-1].trim(),s=/.*\(([^)]*)$/,o=a.match(s);if(o&&o[1]){const i=o[1];if(i.lastIndexOf("{")>i.lastIndexOf("}")){const c=i.match(/([\w_.:]+)\{[^}]*$/);return c?c[0]:a}const l=i.lastIndexOf(",");return l!==-1?i.substring(l+1).trim():i}return a}function uc(t){const r=t.match(/([\w_.:]+(?![},]))$/);return r?r[0]:""}function hc(t){const r=/([{(),+\-*/^]|\b(?:or|and|unless|default|ifnot|if|group_left|group_right|by|without|on|ignoring)\b)/i,n=t.split(/\s+/),a=n.length,s=n[a-1],o=n[a-2],i=!s&&Ds(t),l=(!s||n.length>1)&&!r.test(o);return i||l}function pc(t,r="",n=""){const a=t.trim(),s=["}",")"].some(m=>a.endsWith(m)),o=!Ds(a)&&["`","'",'"'].some(m=>a.endsWith(m));if(!a||s||o||hc(a))return xe.empty;const i=/(?:by|without|on|ignoring)\s*\(\s*[^)]*$|\{[^}]*$/i,l=`(${Ar(r)})?{?.+${Ar(n)}(=|!=|=~|!~)"?([^"]*)$`,c=new RegExp(l,"g");switch(!0){case c.test(a):return xe.labelValue;case i.test(a):return xe.label;default:return xe.metricsql}}const vc=(t,r)=>r[0]!==r[1]?{beforeCursor:t,afterCursor:""}:{beforeCursor:t.substring(0,r[0]),afterCursor:t.substring(r[1])},fc=t=>{const r=/\w+\((?<metricName>[^)]+)\)\s+(by|without|on|ignoring)\s*\(\w*/gi,n=[...t.matchAll(r)];if(n[0]?.groups?.metricName)return n[0].groups.metricName;const a=/^\s*\b(?<metricName>[^{}(),\s]+)(?={|$)/g;return[...t.matchAll(a)][0]?.groups?.metricName||""},gc=t=>{const r=/[a-z_:-][\w\-.:/]*\b(?=\s*(=|!=|=~|!~))/g,n=t.match(r);return n?n[n.length-1]:""},bc=(t,r)=>{const n=/([a-z_:-][\w\-.:/]*)\s*(?:=|!=|=~|!~)\s*"[^"]*"/g,a=[...t.matchAll(n)];return r?a.filter(s=>s[1]!==r).map(s=>s[0]):a.map(s=>s[0])},yc=({value:t,anchorEl:r,caretPosition:n,hasHelperText:a,includeFunctions:s,onSelect:o,onFoundOptions:i})=>{const[l,c]=b({top:0,left:0}),m=dc(s),d=D(()=>vc(t,n),[t,n]),u=D(()=>mc(d.beforeCursor),[d.beforeCursor]),h=D(()=>fc(u),[u]),p=D(()=>gc(u),[u]),v=D(()=>pc(d.beforeCursor,h,p),[d.beforeCursor,h,p]),y=D(()=>uc(d.beforeCursor),[d.beforeCursor]),f=D(()=>bc(d.beforeCursor,p),[d.beforeCursor,p]),{metrics:g,labels:_,labelValues:C,loading:w}=ec({valueByContext:y,metric:h,label:p,context:v,labelMatchers:f}),N=D(()=>{switch(v){case xe.metricsql:return[...g,...m];case xe.label:return _;case xe.labelValue:return C;default:return[]}},[v,g,_,C,m]),S=Y(A=>{const T=d.beforeCursor;let E=d.afterCursor;const M=T.lastIndexOf(y,n[0]),I=M+y.length,k=T.substring(0,M),L=T.substring(I);if(v===xe.labelValue){E=E.replace(/^[^\s"|},]*/,"");const H=/(?:=|!=|=~|!~)$/.test(k),z=E.trim()[0]!=='"';A=`${H?'"':""}${A}${z?'"':""}`}v===xe.label&&(E=E.replace(/^[^\s=!,{}()"|+\-/*^]*/,"")),v===xe.metricsql&&(E=E.replace(/^[^\s[\]{}()"|+\-/*^]*/,""));const $=`${k}${A}${L}${E}`;o($,k.length+A.length)},[d.beforeCursor,d.afterCursor,y,n,v,o]);return x(()=>{if(!r.current){c({top:0,left:0});return}const A=r.current.querySelector("textarea")||r.current,T=window.getComputedStyle(A),E=`${T.getPropertyValue("font-size")}`,M=`${T.getPropertyValue("font-family")}`,I=parseInt(`${T.getPropertyValue("line-height")}`),k=document.createElement("div");k.style.font=`${E} ${M}`,k.style.padding=T.getPropertyValue("padding"),k.style.lineHeight=`${I}px`,k.style.width=`${A.offsetWidth}px`,k.style.maxWidth=`${A.offsetWidth}px`,k.style.whiteSpace=T.getPropertyValue("white-space"),k.style.overflowWrap=T.getPropertyValue("overflow-wrap");const L=document.createElement("span");k.appendChild(document.createTextNode(d.beforeCursor)),k.appendChild(L),k.appendChild(document.createTextNode(d.afterCursor)),document.body.appendChild(k);const $=k.getBoundingClientRect(),V=L.getBoundingClientRect(),H=V.left-$.left,z=V.bottom-$.bottom-(a?I:0);c({top:z,left:H}),k.remove(),L.remove()},[r,n,a,d.beforeCursor,d.afterCursor]),e(q,{children:e(Is,{loading:w,disabledFullScreen:!0,value:y,options:N,anchor:r,minLength:0,offset:l,onSelect:S,onFoundOptions:i,maxDisplayResults:{limit:Sr.displayResults,message:"Please, specify the query more precisely."}})})},_c=ue("expr.hide",""),Cc=_c.split(",").filter(t=>t).map(Number),Ps=({queryErrors:t,setQueryErrors:r,setHideError:n,stats:a,label:s,isLoading:o,includeFunctions:i=!0,onHideQuery:l,onRunQuery:c,abortFetch:m,hideButtons:d})=>{const{isMobile:u}=W(),{query:h,queryHistory:p,autocomplete:v,autocompleteQuick:y}=Pe(),f=Zt(),g=Ge(),{setSearchParamsFromKeys:_}=nt(),[C,w]=b(h||[]),[N,S]=b(Cc),[A,T]=b(!1),E=Gt(C),M=Wl(),I=()=>{f({type:"SET_QUERY_HISTORY",payload:{key:"METRICS_QUERY_HISTORY",history:C.map((F,P)=>gi(F,p[P]))}})},k=()=>{if(o){m&&m();return}I(),f({type:"SET_QUERY",payload:C}),g({type:"RUN_QUERY"}),c()},L=()=>{w(F=>[...F,""])},$=F=>{w(P=>P.filter((U,J)=>J!==F))},V=(F,P)=>{const{ctrlKey:U,metaKey:J}=F;if(U||J){const se=C.map((ce,He)=>He).filter(ce=>ce!==P);S(ce=>Qr(se,ce)?[]:se)}else S(se=>se.includes(P)?se.filter(ce=>ce!==P):[...se,P])},H=(F,P)=>{w(U=>U.map((J,re)=>re===P?F:J))},z=(F,P)=>{H(F,P),T(!0)},j=(F,P)=>{const{index:U,values:J}=p[P],re=U+F;re<0||re>=J.length||(H(J[re]||"",P),f({type:"SET_QUERY_HISTORY_BY_INDEX",payload:{value:{values:J,index:re},queryNumber:P}}))},ee=(F,P)=>()=>{j(F,P)},X=F=>P=>{H(P,F),f({type:"SET_AUTOCOMPLETE_QUICK",payload:!1})},B=F=>()=>{$(F),S(P=>P.includes(F)?P.filter(U=>U!==F):P.map(U=>U>F?U-1:U))},ae=F=>P=>{V(P,F)},le=async F=>{const P=await M(C[F]);n(!1),H(P.query,F),r(U=>(U[F]=P.error,[...U]))};return x(()=>{E&&C.length<E.length&&k()},[C]),x(()=>{l&&l(N),_({"expr.hide":N.join(",")})},[N]),x(()=>{A&&(k(),T(!1))},[C,A]),x(()=>{w(h||[])},[h]),e("div",{className:R({"vm-query-configurator":!0,"vm-block":!0,"vm-block_mobile":u}),children:[e("div",{className:"vm-query-configurator-list",children:C.map((F,P)=>e("div",{className:R({"vm-query-configurator-list-row":!0,"vm-query-configurator-list-row_disabled":N.includes(P),"vm-query-configurator-list-row_mobile":u}),children:[e(Yl,{value:C[P],autocomplete:!d?.autocomplete&&(v||y),autocompleteEl:yc,error:t&&t[P],stats:a[P],onArrowUp:ee(-1,P),onArrowDown:ee(1,P),onEnter:k,onChange:X(P),label:`${s||"Query"} ${C.length>1?P+1:""}`,disabled:N.includes(P),includeFunctions:i}),l&&e(G,{title:N.includes(P)?"Enable query":"Disable query",children:e("div",{className:"vm-query-configurator-list-row__button",children:e(O,{variant:"text",color:"gray",startIcon:N.includes(P)?e(os,{}):e(Rn,{}),onClick:ae(P),ariaLabel:"visibility query"})})}),!d?.prettify&&e(G,{title:"Prettify query",children:e("div",{className:"vm-query-configurator-list-row__button",children:e(O,{variant:"text",color:"gray",startIcon:e(is,{}),onClick:async()=>await le(P),className:"prettify",ariaLabel:"prettify the query"})})}),C.length>1&&e(G,{title:"Remove Query",children:e("div",{className:"vm-query-configurator-list-row__button",children:e(O,{variant:"text",color:"error",startIcon:e(Vr,{}),onClick:B(P),ariaLabel:"remove query"})})})]},P))}),e("div",{className:"vm-query-configurator-settings",children:[e(Gl,{hideButtons:d}),e("div",{className:"vm-query-configurator-settings__buttons",children:[e(Zl,{handleSelectQuery:z,historyKey:"METRICS_QUERY_HISTORY"}),!d?.addQuery&&C.length<_r&&e(O,{variant:"outlined",onClick:L,startIcon:e(Dn,{}),children:"Add Query"}),e(O,{variant:"contained",onClick:k,startIcon:o?e(ys,{}):e(dt,{}),children:`${o?"Cancel":"Execute"} ${u?"":"Query"}`})]})]})]})},Nc=(t,r,n,a,s)=>`${t}/api/v1/query_range?query=${encodeURIComponent(r)}&start=${n.start}&end=${n.end}&step=${n.step}${a?"&nocache=1":""}${s?"&trace=1":""}`,wc=(t,r,n,a,s)=>`${t}/api/v1/query?query=${encodeURIComponent(r)}&time=${n.end}&step=${n.step}${a?"&nocache=1":""}${s?"&trace=1":""}`,Sc=(t,r,n,a)=>{const s=new URLSearchParams({"match[]":r,start:n.start.toString(),end:n.end.toString()});return a&&s.set("reduce_mem_usage","1"),`${t}/api/v1/export?${s}`},Tc=(t,r,n,a)=>{const s=new URLSearchParams({start:n.start.toString(),end:n.end.toString(),format:"__name__,__value__,__timestamp__:unix_ms"});return r.forEach((o=>s.append("match[]",o))),a&&s.set("reduce_mem_usage","1"),`${t}/api/v1/export/csv?${s}`},Ec=(t,r,n,a)=>{const s=new URLSearchParams({start:n.start.toString(),end:n.end.toString()});return r.forEach((o=>s.append("match[]",o))),a&&s.set("reduce_mem_usage","1"),`${t}/api/v1/export?${s}`};let xc=0;class bt{tracing;query;tracingChildren;originalTracing;id;constructor(r,n){this.tracing=r,this.originalTracing=JSON.parse(JSON.stringify(r)),this.query=n,this.id=xc++;const a=r.children||[];this.tracingChildren=a.map(s=>new bt(s,n))}get queryValue(){return this.query}get idValue(){return this.id}get children(){return this.tracingChildren}get message(){return this.tracing.message}get duration(){return this.tracing.duration_msec}get JSON(){return JSON.stringify(this.tracing,null,2)}get originalJSON(){return JSON.stringify(this.originalTracing,null,2)}setTracing(r){this.tracing=r;const n=r.children||[];this.tracingChildren=n.map(a=>new bt(a,this.query))}setQuery(r){this.query=r}resetTracing(){this.tracing=this.originalTracing}}const hn=(t,r,n=!0)=>{const{__name__:a,...s}=t.metric,o=n?`[Query ${t.group}] `:"";if(r)return $s(t.metric,r);const i=`${o}${a||""}`;if(Object.keys(s).length===0)return i||"value";const l=Object.entries(s).map(([c,m])=>`${c}=${JSON.stringify(m)}`).join(", ");return`${i}{${l}}`},$s=(t,r)=>r.replace(/\{\{(\w+)}}/g,(n,a)=>t[a]||""),Lr=t=>{switch(t){case"NaN":return NaN;case"Inf":case"+Inf":return 1/0;case"-Inf":return-1/0;default:return parseFloat(t)}},qn=t=>{if(t.length<2)return!1;const r=["le","vmrange"],n=Object.keys(t[0].metric).filter(s=>!r.includes(s));return t.every(s=>{const o=Object.keys(s.metric).filter(i=>!r.includes(i));return n.length===o.length&&o.every(i=>s.metric[i]===t[0].metric[i])})&&t.every(s=>r.some(o=>o in s.metric))},Bn=({predefinedQuery:t,visible:r,display:n,customStep:a,hideQuery:s,showAllSeries:o})=>{const{query:i}=Pe(),{period:l}=he(),{displayType:c,nocache:m,isTracingEnabled:d,seriesLimits:u}=$e(),{serverUrl:h}=ne(),{isHistogram:p}=Oe(),[v,y]=b(!1),[f,g]=b(),[_,C]=b(),[w,N]=b(),[S,A]=b(),[T,E]=b([]),[M,I]=b([]),[k,L]=b(),[$,V]=b([]),[H,z]=b(!1),j=D(()=>{const{end:P,start:U}=l;return Pr(P-U,p,c)},[l,p,c]),X=Y(Dt(async({fetchUrl:P,displayType:U,query:J,stateSeriesLimits:re,showAllSeries:se,hideQuery:ce})=>{const He=new AbortController;V(ye=>[...ye,He]);try{const ye=U===pe.chart,Le=se?1/0:+re[U]||1/0;let et=Le;const Te=[],wt=[],ke=[],_e=[];let ve=1,ze=0,Je=!1;for await(const at of P){if(ce?.includes(ve-1)){_e.push(""),ke.push({}),ve++;continue}const Ot=new URL(at),Ht=await fetch(`${Ot.origin}${Ot.pathname}`,{signal:He.signal,method:"POST",body:Ot.searchParams}),Ee=await Ht.json();if(Ht.ok){if(ke.push({...Ee?.stats,isPartial:Ee?.isPartial,resultLength:Ee.data.result.length}),_e.push(""),Ee.trace){const Be=new bt(Ee.trace,J[ve-1]);wt.push(Be)}const St=!!ue("display_mode",null);Je=ye&&!St&&qn(Ee.data.result),et=Je?1/0:Le;const ir=Math.max(0,et-Te.length);Ee.data.result.slice(0,ir).forEach(Be=>{Be.group=ve,Te.push(Be)}),ze+=Ee.data.result.length}else{Te.push({metric:{},values:[],group:ve});const St=Ee.errorType||ge.unknownType,ir=Ee?.error||Ee?.message||"see console for more details",Be=[St,ir].join(`,\r
`);_e.push(Be),console.error(`Fetch query error: ${St}`,Ee)}ve++}E(_e),I(ke);const Fe=Te.length;L(Fe<ze?`Showing ${Fe} series out of ${ze} series due to performance reasons. Please narrow down the query, so it returns fewer series`:""),ye?g(Te):C(Te),N(wt),z(at=>ze?Je:at)}catch(ye){const Le=ye;if(Le.name==="AbortError"){y(!1);return}let Te=`Error executing query: ${Le.message}. Please check your serverURL settings and confirm server availability.`;Le.message==="Unexpected end of JSON input"&&(Te+=`
Additionally, this error can occur if the server response is too large to process. Apply more specific filters to reduce the data volume.`),A(Te)}y(!1)},300),[]),B=D(()=>{const P=(t??i).filter(Boolean),U=(n||c)===pe.chart;if(!l||!h||!yr(h)||!P.length)return;const J={...l,step:a};return P.map(re=>U?Nc(h,re,J,m,d):wc(h,re,J,m,d))},[h,l,c,a,m,d,n,t,i]),ae=Y(()=>{$.forEach(P=>P.abort()),V([]),g([]),C([])},[$]),[le,F]=b([]);return x(()=>{const P=B===le&&!!t;if(!r||!B?.length||P)return;y(!0),X({fetchUrl:B,displayType:n||c,query:t??i,stateSeriesLimits:u,showAllSeries:o,hideQuery:s}),F(B)},[B,r,u,o]),x(()=>{const P=$.slice(0,-1);P.length&&(P.map(U=>U.abort()),V(U=>U.filter(J=>!J.signal.aborted)))},[$]),x(()=>{j===a&&g([])},[H]),x(()=>{A(""),E([]),I([]);const P=t??i;if(l){if(!h){A(ge.emptyServer);return}if(!yr(h)){A(ge.validServer);return}P.every(U=>!U.trim())&&E(P.map(()=>ge.validQuery))}},[h,l,c,a,m,d,n,t,i]),{fetchUrl:B,isLoading:v,graphData:f,liveData:_,error:S,queryErrors:T,setQueryErrors:E,queryStats:M,warning:k,traces:w,isHistogram:H,abortFetch:ae}},Os=()=>e("div",{className:"vm-line-loader",children:[e("div",{className:"vm-line-loader__background"}),e("div",{className:"vm-line-loader__line"})]}),Hs=()=>{const{displayType:t}=$e(),{query:r}=Pe(),{duration:n,relativeTime:a,period:{date:s,step:o}}=he(),{customStep:i}=Oe(),[l,c]=me(),m=Ge(),d=rt(),u=Zt(),h=Pt(),[p,v]=b(!1),y=Y(()=>{if(p){v(!1);return}const f=new URLSearchParams(l);r.forEach((_,C)=>{const w=`g${C}`;l.get(`${w}.expr`)!==_&&_&&f.set(`${w}.expr`,_),l.get(`${w}.range_input`)!==n&&f.set(`${w}.range_input`,n),l.get(`${w}.end_input`)!==s&&f.set(`${w}.end_input`,s),l.get(`${w}.relative_time`)!==a&&f.set(`${w}.relative_time`,a||"none");const N=l.get("expr.hide")||"";N!==""&&f.set("expr.hide",N);const S=l.get(`${w}.step_input`)||o;S&&S!==i&&f.set(`${w}.step_input`,i);const A=`${Lt.find(T=>T.value===t)?.prometheusCode||0}`;l.get(`${w}.tab`)!==A&&f.set(`${w}.tab`,`${A}`)});const g=r.length-1;Array.from(f.keys()).forEach(_=>{const C=_.match(/^g(\d+)\./);C&&parseInt(C[1],10)>g&&f.delete(_)}),!(Vo(f,l)||!f.size)&&c(f)},[t,r,n,a,s,o,i]);x(()=>{const f=setTimeout(y,200);return()=>clearTimeout(f)},[y]),x(()=>{if(!p)return;const f=Ya(),g=f.duration!==n,_=f.relativeTime!==a,C=f.relativeTime==="none"&&f.period.date!==s;(g||_||C)&&m({type:"SET_TIME_STATE",payload:f});const N=ws();N!==t&&h({type:"SET_DISPLAY_TYPE",payload:N});const S=za();Qr(S,r)||(u({type:"SET_QUERY",payload:S}),m({type:"RUN_QUERY"}));const A=setTimeout(()=>{const T=l.get("g0.step_input")||o;T&&T!==i&&d({type:"SET_CUSTOM_STEP",payload:T})},50);return()=>clearTimeout(A)},[l,p]),oe("popstate",()=>{v(!0)})},Ac=e(Ce,{text:"last_over_time",href:"https://docs.victoriametrics.com/victoriametrics/metricsql/#last_over_time",underlined:!0}),Lc=e(Ce,{text:"instant query",href:"https://docs.victoriametrics.com/victoriametrics/keyconcepts/#instant-query",underlined:!0}),kc=()=>{const{customStep:t}=Oe();return e("div",{children:[e("p",{children:["This tab shows ",Lc," results for the last ",t||"5m"," (defined by the ",e("code",{children:"step"}),") ending at the selected time range."]}),e("p",{children:["Please wrap the query into ",Ac," if you need results over arbitrary lookbehind interval."]})]})},zs=({value:t,hideValue:r})=>e("div",{className:"vm-line-progress",children:[e("div",{className:"vm-line-progress-track",children:e("div",{className:"vm-line-progress-track__thumb",style:{width:`${t}%`}})}),!r&&e("span",{children:[t.toFixed(2),"%"]})]}),Fs=({isRoot:t,trace:r,totalMsec:n,isExpandedAll:a})=>{const{isDarkTheme:s}=ne(),{isMobile:o}=W(),[i,l]=b({}),c=Z(null),[m,d]=b(!1),[u,h]=b(!1),p=Tn(r.duration/1e3)||`${r.duration}ms`;x(()=>{if(!c.current)return;const C=c.current,w=c.current.children[0],{height:N}=w.getBoundingClientRect();d(N>C.clientHeight)},[r]);const v=C=>{C.stopPropagation(),h(w=>!w)},y=r.children&&!!r.children.length,f=r.duration/n*100,g=C=>()=>{y&&l(w=>({...w,[C]:!w[C]}))},_=C=>{const w=[C.idValue];return C?.children?.forEach(N=>{w.push(..._(N))}),w};return x(()=>{if(!a){l([]);return}const C=_(r),w={};C.forEach(N=>{w[N]=!0}),l(w)},[a]),e("div",{className:R({"vm-nested-nav":!0,"vm-nested-nav_root":t,"vm-nested-nav_dark":s,"vm-nested-nav_mobile":o}),children:[e("div",{className:R({"vm-nested-nav-header":!0,"vm-nested-nav-header_open":i[r.idValue]}),onClick:g(r.idValue),children:[y&&e("div",{className:R({"vm-nested-nav-header__icon":!0,"vm-nested-nav-header__icon_open":i[r.idValue]}),children:e(Ae,{})}),e("div",{className:"vm-nested-nav-header__progress",children:e(zs,{value:f})}),e("div",{className:R({"vm-nested-nav-header__message":!0,"vm-nested-nav-header__message_show-full":u}),ref:c,children:[e("span",{className:"vm-nested-nav-header__message_duration",children:p}),": ",e("span",{children:r.message})]}),e("div",{className:"vm-nested-nav-header-bottom",children:(m||u)&&e(O,{variant:"text",size:"small",onClick:v,children:u?"Hide":"Show full query"})})]}),i[r.idValue]&&e("div",{className:"vm-nested-nav__childrens",children:y&&r.children.map(C=>e(Fs,{trace:C,totalMsec:n,isExpandedAll:a},C.duration))})]})},Vs=({editable:t=!1,defaultTile:r="JSON",displayTitle:n=!0,defaultJson:a="",resetValue:s="",onClose:o,onUpload:i})=>{const l=Ke(),{isMobile:c}=W(),[m,d]=b(a),[u,h]=b(r),[p,v]=b(""),[y,f]=b(""),g=D(()=>{try{const A=JSON.parse(m),T=A.trace||A;return T.duration_msec?(new bt(T,""),""):ge.traceNotFound}catch(A){return A instanceof Error?A.message:"Unknown error"}},[m]),_=A=>{h(A)},C=A=>{f(""),d(A)},w=async()=>{await l(m,"Formatted JSON has been copied")},N=()=>{d(s)},S=()=>{f(g),u.trim()||v(ge.emptyTitle),!(g||p)&&(i(m,u),o())};return e("div",{className:R({"vm-json-form":!0,"vm-json-form_one-field":!n,"vm-json-form_one-field_mobile":!n&&c,"vm-json-form_mobile":c}),children:[n&&e(ie,{value:u,label:"Title",error:p,onEnter:S,onChange:_}),e(ie,{value:m,label:"JSON",type:"textarea",error:y,autofocus:!0,onChange:C,onEnter:S,disabled:!t}),e("div",{className:"vm-json-form-footer",children:[e("div",{className:"vm-json-form-footer__controls",children:[e(O,{variant:"outlined",startIcon:e(_t,{}),onClick:w,children:"Copy JSON"}),s&&e(O,{variant:"text",startIcon:e(ft,{}),onClick:N,children:"Reset JSON"})]}),e("div",{className:"vm-json-form-footer__controls vm-json-form-footer__controls_right",children:[e(O,{variant:"outlined",color:"error",onClick:o,children:"Cancel"}),e(O,{variant:"contained",onClick:S,children:"apply"})]})]})]})},Us=(t,r)=>{const n=document.createElement("a"),a=URL.createObjectURL(t);n.setAttribute("href",a),n.setAttribute("download",r),document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(a)},qs=(t,r)=>{const n=new Blob([t],{type:"text/csv;charset=utf-8;"});Us(n,r)},jr=(t,r)=>{const n=new Blob([t],{type:"application/json"});Us(n,r)},Qn=({traces:t,jsonEditor:r=!1,onDeleteClick:n})=>{const{isMobile:a}=W(),[s,o]=b(null),[i,l]=b([]),c=()=>{o(null)},m=(v,y)=>{if(!(!r||!s))try{s.setTracing(JSON.parse(v)),s.setQuery(y),o(null)}catch(f){console.error(f)}};if(!t.length)return e(te,{variant:"info",children:"Please re-run the query to see results of the tracing"});const d=v=>()=>{n(v)},u=v=>()=>{o(v)},h=v=>()=>{jr(v.originalJSON,`vmui_trace_${v.queryValue}.json`)},p=v=>()=>{l(y=>y.includes(v.idValue)?y.filter(f=>f!==v.idValue):[...y,v.idValue])};return e(q,{children:[e("div",{className:"vm-tracings-view",children:t.map(v=>e("div",{className:"vm-tracings-view-trace vm-block vm-block_empty-padding",children:[e("div",{className:"vm-tracings-view-trace-header",children:[e("h3",{className:"vm-tracings-view-trace-header-title",children:["Trace for ",e("b",{className:"vm-tracings-view-trace-header-title__query",children:v.queryValue})]}),e(G,{title:i.includes(v.idValue)?"Collapse All":"Expand All",children:e(O,{variant:"text",startIcon:i.includes(v.idValue)?e(bs,{}):e(gs,{}),onClick:p(v),ariaLabel:i.includes(v.idValue)?"Collapse All":"Expand All"})}),e(G,{title:"Save Trace to JSON",children:e(O,{variant:"text",startIcon:e(On,{}),onClick:h(v),ariaLabel:"Save trace to JSON"})}),e(G,{title:"Open JSON",children:e(O,{variant:"text",startIcon:e(er,{}),onClick:u(v),ariaLabel:"open JSON"})}),e(G,{title:"Remove trace",children:e(O,{variant:"text",color:"error",startIcon:e(Vr,{}),onClick:d(v),ariaLabel:"remove trace"})})]}),e("nav",{className:R({"vm-tracings-view-trace__nav":!0,"vm-tracings-view-trace__nav_mobile":a}),children:e(Fs,{isRoot:!0,trace:v,totalMsec:v.duration,isExpandedAll:i.includes(v.idValue)})})]},v.idValue))}),s&&e(we,{title:s.queryValue,onClose:c,children:e(Vs,{editable:r,displayTitle:r,defaultTile:s.queryValue,defaultJson:s.JSON,resetValue:s.originalJSON,onClose:c,onUpload:m})})]})},Mc=({traces:t,displayType:r})=>{const{isTracingEnabled:n}=$e(),[a,s]=b([]),o=i=>{const l=a.filter(c=>c.idValue!==i.idValue);s([...l])};return x(()=>{t&&s([...a,...t])},[t]),x(()=>{s([])},[r]),e(q,{children:n&&e("div",{className:"vm-custom-panel__trace",children:e(Qn,{traces:a,onDeleteClick:o})})})},jn=({warning:t,query:r,onChange:n})=>{const{isMobile:a}=W(),{value:s,setTrue:o,setFalse:i}=de(!1);return x(i,[r]),x(()=>{n(s)},[s]),e(te,{variant:"warning",children:e("div",{className:R({"vm-custom-panel__warning":!0,"vm-custom-panel__warning_mobile":a}),children:[e("p",{children:t}),e(O,{color:"warning",variant:"outlined",onClick:o,children:"Show all"})]})})},Ic=(t,r,n="")=>{const a=r[0],s=r[r.length-1];return n?r.map(o=>`${ht(o,a,s)} ${n}`):r.map(o=>ht(o,a,s))},ht=(t,r,n)=>{if(t==null)return"";n=n||0,r=r||0;const a=Math.abs(n-r);if(isNaN(a)||a==0)return Math.abs(t)>=1e3?t.toLocaleString("en-US"):t.toString();let s=3+Math.floor(1+Math.log10(Math.max(Math.abs(r),Math.abs(n)))-Math.log10(a));return(isNaN(s)||s>20)&&(s=20),t.toLocaleString("en-US",{minimumSignificantDigits:1,maximumSignificantDigits:s})},Dc=(t,r)=>{const n=document.createElement("span");n.innerText=t,n.style.cssText=`position: absolute; z-index: -1; pointer-events: none; opacity: 0; font: ${r}`,document.body.appendChild(n);const a=n.offsetWidth;return n.remove(),a},Rc=(t,r)=>{if(r?.hasAlias&&r?.label)return r.label;const n=t?.metric||{},s=Object.keys(n).filter(i=>i!="__name__").map(i=>`${i}=${JSON.stringify(n[i])}`);let o=n.__name__||"";return s.length>0&&(o+="{"+s.join(",")+"}"),o},Pc=[[3600*24*365,"{YYYY}",null,null,null,null,null,null,1],[3600*24*28,"{MMM}",`
{YYYY}`,null,null,null,null,null,1],[3600*24,"{MM}-{DD}",`
{YYYY}`,null,null,null,null,null,1],[3600,"{HH}:{mm}",`
{YYYY}-{MM}-{DD}`,null,`
{MM}-{DD}`,null,null,null,1],[60,"{HH}:{mm}",`
{YYYY}-{MM}-{DD}`,null,`
{MM}-{DD}`,null,null,null,1],[1,"{HH}:{mm}:{ss}",`
{YYYY}-{MM}-{DD}`,null,`
{MM}-{DD} {HH}:{mm}`,null,null,null,1],[.001,":{ss}.{fff}",`
{YYYY}-{MM}-{DD} {HH}:{mm}`,null,`
{MM}-{DD} {HH}:{mm}`,null,`
{HH}:{mm}`,null,1]],Bs=(t,r)=>Array.from(new Set(t.map(n=>n.scale))).map(n=>{const a="10px Arial",s=tt("color-text"),o={scale:n,show:!0,size:Qs,stroke:s,font:a,values:(i,l)=>Ic(i,l,r)};return n?!(Number(n)%2)&&n!=="y"?{...o,side:1}:o:{space:80,values:Pc,stroke:s,font:a}}),$c=(t,r,n,a)=>{const s=je(r.start),o=je(r.end),i=En(t)||.001,l=Math.max(.001,je(i)),c=je(a??s),m=(g,_)=>{const C=g%_;return C<0?C+_:C},d=m(c,l);let u=je(s+m(d-m(s,l),l));if(u<s&&(u=je(u+l)),u>o)return[s,o];const h=Math.floor((o-u)/l)+1,p=Math.max(1,Math.ceil(h/n)),v=Math.max(.001,je(l*p)),y=Math.min(n,Math.floor((o-u)/v)+1),f=new Array(y);for(let g=0;g<y;g++)f[g]=je(u+g*v);return f},pn=(t,r)=>{if(t==null||r==null)return[-1,1];const a=.02*(Math.abs(r-t)||Math.abs(t)||1);return[t-a,r+a]},Qs=(t,r,n,a)=>{const s=t.axes[n];if(a>1)return s._size||60;let o=6+(s?.ticks?.size||0)+(s.gap||0);const i=(r??[]).reduce((l,c)=>c?.length>l.length?c:l,"");return i!=""&&(o+=Dc(i,"10px Arial")),Math.ceil(o)},va=["#e54040","#32a9dc","#2ee329","#7126a1","#e38f0f","#3d811a","#ffea00","#2d2d2d","#da42a6","#a44e0c"],Oc=t=>{let a=1,s=0,o=1;if(t.length>0)for(let l=0;l<t.length;l++)t[l].charCodeAt(0)>s&&(s=t[l].charCodeAt(0)),o=parseInt(String(16777215/s)),a=(a+t[l].charCodeAt(0)*o*49979693)%16777215;let i=(a*t.length%16777215).toString(16);return i=i.padEnd(6,i),`#${i}`},Hc=t=>{let r=t.replace("#","").trim();if(r.length===3&&(r=r[0]+r[0]+r[1]+r[1]+r[2]+r[2]),r.length!==6)throw new Error("Invalid HEX color.");const n=parseInt(r.slice(0,2),16),a=parseInt(r.slice(2,4),16),s=parseInt(r.slice(4,6),16);return(n*299+a*587+s*114)/1e3>=128?"#000000":"#FFFFFF"},zc=(t,r,n)=>{const a=[];for(let s=0;s<n;s++){const o=s/(n-1),i=t[0]+(r[0]-t[0])*o,l=t[1]+(r[1]-t[1])*o,c=t[2]+(r[2]-t[2])*o;a.push([i,l,c].map(m=>Math.round(m)).join(", "))}return a.map(s=>`rgb(${s})`)},Yn=zc([246,226,219],[127,39,4],16),Fc=(t,r)=>{const n=t.data[r][2],a=Yn,s=0;let o=1/0,i=-1/0;for(let d=0;d<n.length;d++)n[d]>s&&(o=Math.min(o,n[d]),i=Math.max(i,n[d]));if(!isFinite(o)||!isFinite(i))return n.map(()=>-1);const l=i-o;if(l===0)return n.map(d=>d>s?0:-1);const c=a.length,m=Array(n.length);for(let d=0;d<n.length;d++)m[d]=n[d]===0?-1:Math.min(c-1,Math.floor(c*(n[d]-o)/l));return m},Vc=()=>(t,r)=>{const n=Math.round(devicePixelRatio);At.orient(t,r,(a,s,o,i,l,c,m,d,u,h,p,v,y,f)=>{const[g,_,C]=t.data[r],w=g.length,N=Fc(t,r),S=Yn??[...Array.from(new Set(N))],A=S.map(()=>new Path2D),T=w-_.lastIndexOf(_[0]),E=w/T,M=_[1]-_[0],I=g[T]-g[0],k=c(I,i,h,d)-c(0,i,h,d)-n,L=m(M,l,p,u)-m(0,l,p,u)+n,$=_.slice(0,T).map(H=>Math.round(m(H,l,p,u)-L/2)),V=Array.from({length:E},(H,z)=>Math.round(c(g[z*T],i,h,d)-k));for(let H=0;H<w;H++)if(C[H]>0&&g[H]>=(i.min||-1/0)&&g[H]<=(i.max||1/0)&&_[H]>=(l.min||-1/0)&&_[H]<=(l.max||1/0)){const z=V[~~(H/T)],j=$[H%T],ee=A[N[H]];f(ee,z,j,k,L)}t.ctx.save(),t.ctx.rect(t.bbox.left,t.bbox.top,t.bbox.width,t.bbox.height),t.ctx.clip(),A.forEach((H,z)=>{t.ctx.fillStyle=S[z],t.ctx.fill(H)}),t.ctx.restore()})},Uc=t=>{if(!t.every(o=>o.metric.le))return t;const r=t.sort((o,i)=>parseFloat(o.metric.le)-parseFloat(i.metric.le)),n=t[0]?.group||1;let a={metric:{le:""},values:[]};const s=[];for(const o of r){const i=[a.metric.le,o.metric.le].filter(c=>c).join("..."),l=[];for(const[c,m]of o.values){const d=a.values.find(h=>h[0]===c)?.[1]||0,u=+m-+d;l.push([c,`${u}`])}s.push({metric:{vmrange:i},values:l,group:n}),a=o}return s},fa=t=>{const r=(t.metric.vmrange||t.metric.le||"").split("...");return Lr(r[r.length-1])},qc=(t,r)=>fa(t)-fa(r),Bc=(t,r)=>{if(!r)return t;const n=t.sort(qc),a=Uc(n),s={};a.forEach(d=>d.values.forEach(([u,h])=>{const p=Number(h),v=isNaN(p)?0:p,y=s[u]||0;s[u]=y+v}));const o=a.map(d=>{const u=d.values.map(([h,p])=>{const v=s[h];return[h,`${Math.round(+p/v*100)}`]});return{...d,values:u}}),i=o.map((d,u)=>d.values.every(h=>h[1]==="0")?-1:u).filter(d=>d!==-1),l=i.length;if(l===0||o.length<=3)return o;if(l>1)return o.filter((d,u)=>i.includes(u));const c=i[0],m=new Set([c]);return c-1>=0&&m.add(c-1),c+1<o.length&&m.add(c+1),o.filter((d,u)=>m.has(u))},Qc=t=>{Object.keys(t.hooks).forEach(r=>{t.hooks[r]=[]})},jc=2*Math.PI,Yc=4,Gc=1.2,Wc=(t,r)=>{const n=Yc*At.pxRatio,a=n/2,s=n*Gc,o=s/2,i=(l,c,m,d,u,h,p,v,y,f,g,_,C,w,N)=>{const S=l?.stroke;typeof S=="function"&&(t.ctx.fillStyle=S());const A=new Path2D,T=new Path2D,E=Number(d.min),M=Number(d.max),I=Number(u.min),k=Number(u.max),L=new Map,$=c.length;for(let H=0;H<$;H++){const z=c[H],j=m[H];if(z==null||j==null)continue;const ee=Number(z),X=Number(j);if(!Number.isFinite(ee)||!Number.isFinite(X))continue;const B=`${ee}|${X}`;L.set(B,(L.get(B)??0)+1)}const V=new Set;for(const[H,z]of L)z>1&&V.add(H);for(let H=0;H<$;H++){const z=c[H],j=m[H];if(z==null||j==null)continue;const ee=Number(z),X=Number(j);if(!Number.isFinite(ee)||!Number.isFinite(X)||ee<E||ee>M||X<I||X>k)continue;const B=h(ee,d,f,v),ae=p(X,u,g,y),le=`${ee}|${X}`;V.has(le)?w(T,B-o,ae-o,s,s):(A.moveTo(B+a,ae),N(A,B,ae,a,0,jc))}t.ctx.fill(A),t.ctx.lineWidth=1.4*At.pxRatio,t.ctx.strokeStyle=t.ctx.fillStyle,t.ctx.stroke(T)};return At.orient(t,r,i),null},Kc=(t,r,n,a,s)=>{const o={},i=Math.min(t.length,va.length);for(let l=0;l<i;l++){const c=hn(t[l],n[t[l].group-1]);o[c]=va[l]}return l=>{const c=n[l.group-1],m=hn(l,c);return{label:m,hasAlias:!!c,width:1.4,stroke:o[m]||Oc(m),points:ed(a,s),spanGaps:!1,freeFormFields:l.metric,show:!Ys(m,r),scale:"1",paths:s?Wc:void 0,...Jc(l)}}},Jc=t=>{const r=t.values.map(o=>Lr(o[1])),{min:n,max:a,median:s}=Ua(r,{min:!0,max:!0,median:!0});return{median:Number(s),statsFormatted:{min:ht(n,n,a),max:ht(a,n,a),median:ht(s,n,a)}}},js=t=>typeof t.label=="string"?t.label:"",ga=(t,r)=>({group:r,label:js(t),color:t.stroke,checked:t.show||!1,freeFormFields:t.freeFormFields,statsFormatted:t.statsFormatted,median:t.median,hasAlias:t.hasAlias||!1}),Zc=({hideSeries:t,legend:r,metaKey:n,series:a})=>{const{label:s}=r,o=Ys(s,t),i=a.map(js);return n?o?t.filter(l=>l!==s):[...t,s]:t.length?o?[...i.filter(l=>l!==s)]:[]:[...i.filter(l=>l!==s)]},Ys=(t,r)=>r.includes(`${t}`),Gs=t=>{for(let r=t.series.length-1;r>=0;r--)r&&t.delSeries(r)},Xc=(t,r,n=!1,a=!1,s)=>{r.forEach((o,i)=>{o.label&&(o.spanGaps=n),o.points&&(o.points.filter=a||s?void 0:Ws),i&&t.addSeries(o)})},ed=(t=!1,r)=>({size:r?0:4,width:0,show:!0,filter:t||r?null:Ws}),Ws=(t,r)=>{const n=t.data[r],a=[];for(let s=0;s<n.length;s++){const o=n[s-1],i=n[s+1];(o===null||i===null)&&a.push(s)}return a},Ks=({width:t=400,height:r=500})=>({width:t,height:r,series:[],tzDate:n=>Q(Ut(Ye(n))).local().toDate(),legend:{show:!1},cursor:{drag:{x:!0,y:!1},focus:{prox:30},points:{size:5.6,width:1.4},bind:{click:()=>null,dblclick:()=>null}}}),Js=t=>{Gs(t),Qc(t),t.setData([])},Zs=({min:t,max:r})=>[t,r],Xs=(t,r=0,n=1,a,s)=>s.limits.enable?s.limits.range[a]:pn(r,n),td=(t,r)=>{const n={x:{range:()=>Zs(r)}},a=Object.keys(t.limits.range);return(a.length?a:["1"]).forEach(s=>{n[s]={range:(o,i=0,l=1)=>Xs(o,i,l,s,t)}}),n},eo=t=>r=>{const n=r.posToVal(r.select.left,"x"),a=r.posToVal(r.select.left+r.select.width,"x");t({min:n,max:a})},rd=t=>t instanceof MouseEvent,ba=t=>rd(t)?t.clientX:t.touches[0].clientX,nd=({dragSpeed:t=.85,setPanning:r,setPlotScale:n})=>{const a=Z({leftStart:0,xUnitsPerPx:0,scXMin:0,scXMax:0}),s=l=>{l.preventDefault();const c=ba(l),{leftStart:m,xUnitsPerPx:d,scXMin:u,scXMax:h}=a.current,p=d*((c-m)*t);n({min:u-p,max:h-p})},o=()=>{r(!1),document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",o),document.removeEventListener("touchmove",s),document.removeEventListener("touchend",o)},i=()=>{document.addEventListener("mousemove",s),document.addEventListener("mouseup",o),document.addEventListener("touchmove",s),document.addEventListener("touchend",o)};return({e:l,u:c})=>{l.preventDefault(),r(!0),a.current={leftStart:ba(l),xUnitsPerPx:c.posToVal(1,"x")-c.posToVal(0,"x"),scXMin:c.scales.x.min||0,scXMax:c.scales.x.max||0},i()}},ad=t=>{const{ctrlKey:r,metaKey:n,button:a}=t;return a===0&&(r||n)},rn=.9,to=t=>{const[r,n]=b(!1),a=nd({dragSpeed:rn,setPanning:n,setPlotScale:t});return{onReadyChart:o=>{const i=c=>{const m=c instanceof MouseEvent&&ad(c),d=window.TouchEvent&&c instanceof TouchEvent&&c.touches.length>1;(m||d)&&a({u:o,e:c})},l=c=>{if(!c.ctrlKey&&!c.metaKey)return;c.preventDefault();const{width:m}=o.over.getBoundingClientRect(),d=o.cursor.left&&o.cursor.left>0?o.cursor.left:0,u=o.posToVal(d,"x"),h=(o.scales.x.max||0)-(o.scales.x.min||0),p=c.deltaY<0?h*rn:h/rn,v=u-d/m*p,y=v+p;o.batch(()=>t({min:v,max:y}))};o.over.addEventListener("mousedown",i),o.over.addEventListener("touchstart",i),o.over.addEventListener("wheel",l)},isPanning:r}},ya=t=>{const r=t[0].clientX-t[1].clientX,n=t[0].clientY-t[1].clientY;return Math.sqrt(r*r+n*n)},ro=({uPlotInst:t,xRange:r,setPlotScale:n})=>{const[a,s]=b(0),o=Y(c=>{const{target:m,ctrlKey:d,metaKey:u,key:h}=c,p=m instanceof HTMLInputElement||m instanceof HTMLTextAreaElement;if(!t||p)return;const v=h==="+"||h==="=";if((h==="-"||v)&&!(d||u)){c.preventDefault();const g=(r.max-r.min)/10*(v?1:-1);n({min:r.min+g,max:r.max-g})}},[t,r]),i=c=>{c.touches.length===2&&(c.preventDefault(),s(ya(c.touches)))},l=Y(c=>{if(!t||c.touches.length!==2)return;c.preventDefault();const m=ya(c.touches),d=a-m,u=t.scales.x.max||r.max,h=t.scales.x.min||r.min,p=u-h,v=d>0?-1:1,y=p/50*v;t.batch(()=>n({min:h+y,max:u-y}))},[t,a,r]);return oe("keydown",o),oe("touchmove",l),oe("touchstart",i),null},no=({period:t,setPeriod:r})=>{const[n,a]=b({min:t.start,max:t.end}),s=({min:o,max:i})=>{const l=(i-o)*1e3;l<aa.min||l>aa.max||r({from:Q(o*1e3).toDate(),to:Q(i*1e3).toDate()})};return x(()=>{a({min:t.start,max:t.end})},[t]),{xRange:n,setPlotScale:s}},sd=({u:t,metrics:r,series:n,unit:a})=>{const[s,o]=b(!1),[i,l]=b({seriesIdx:-1,dataIdx:-1}),[c,m]=b([]),d=()=>{m([]),l({seriesIdx:-1,dataIdx:-1})},u=f=>{const g=f.cursor.idx??-1;l(_=>({..._,dataIdx:g}))},h=(f,g)=>{const _=g??-1;l(C=>({...C,seriesIdx:_}))},p=Y(()=>{const{seriesIdx:f,dataIdx:g}=i,_=r[f-1],C=n[f],w=new Set(r.map(k=>k.group)),N=_?.group||0,S=t?.data?.[f]?.[g]||0,A=t?.scales?.[1]?.min||0,T=t?.scales?.[1]?.max||1,E=t?.data?.[0]?.[g]||0;let M=1;if(t&&f>0&&g>=0){const k=t.data[0],L=t.data[f],$=k[g],V=L[g];if($!=null&&V!=null){M=0;for(let H=0;H<k.length;H++)k[H]===$&&L[H]===V&&M++}}const I={top:t?t.valToPos(S||0,C?.scale||"1"):0,left:t?t.valToPos(E,"x"):0};return{unit:a,point:I,u:t,id:`${f}_${g}`,title:w.size>1?`Query ${N}`:"",dates:[E?Q(E*1e3).tz().format(Nr):"-"],value:ht(S,A,T),info:Rc(_,C),statsFormatted:C?.statsFormatted,marker:`${C?.stroke}`,duplicateCount:M}},[t,i,r,n,a]),v=Y(()=>{if(!s)return;const f=p();c.find(g=>g.id===f.id)||m(g=>[...g,f])},[p,c,s]),y=f=>{m(g=>g.filter(_=>_.id!==f))};return x(()=>{o(i.dataIdx!==-1&&i.seriesIdx!==-1)},[i]),oe("click",v),{showTooltip:s,stickyTooltips:c,handleUnStick:y,getTooltipProps:p,seriesFocus:h,setCursor:u,resetTooltips:d}},_a=({u:t,id:r,title:n,dates:a,value:s,point:o,unit:i="",info:l,statsFormatted:c,isSticky:m,marker:d,duplicateCount:u=0,onClose:h})=>{const p=Z(null),[v,y]=b({top:-999,left:-999}),[f,g]=b(!1),[_,C]=b(!1),w=()=>{h&&h(r)},N=E=>{C(!0),g(!0);const{clientX:M,clientY:I}=E;y({top:I,left:M})},S=Y(E=>{if(!f)return;const{clientX:M,clientY:I}=E;y({top:I,left:M})},[f]),A=()=>{g(!1)};return x(()=>{if(!p.current||!t)return;const{top:E,left:M}=o,I={left:parseFloat(t.over.style.left),top:parseFloat(t.over.style.top)},{width:k,height:L}=t.over.getBoundingClientRect(),{width:$,height:V}=p.current.getBoundingClientRect(),H=10,z=M+$>=k?$+2*H:0,j=E+V>=L?V+2*H:0,ee={top:E+I.top+H-j,left:M+I.left+H-z};ee.left<0&&(ee.left=20),ee.top<0&&(ee.top=20),y(ee)},[t,s,o,p]),oe("mousemove",S),oe("mouseup",A),t?It(e("div",{className:R({"vm-chart-tooltip":!0,"vm-chart-tooltip_sticky":m,"vm-chart-tooltip_moved":_}),ref:p,style:v,children:[e("div",{className:"vm-chart-tooltip-header",children:[n&&e("div",{className:"vm-chart-tooltip-header__title",children:n}),e("div",{className:"vm-chart-tooltip-header__date",children:a.map((E,M)=>e("span",{children:E},M))}),m&&e(q,{children:[e(O,{className:"vm-chart-tooltip-header__drag",variant:"text",size:"small",startIcon:e(Pn,{}),onMouseDown:N,ariaLabel:"drag the tooltip"}),e(O,{className:"vm-chart-tooltip-header__close",variant:"text",size:"small",startIcon:e(De,{}),onClick:w,ariaLabel:"close the tooltip"})]})]}),e("div",{className:"vm-chart-tooltip-data",children:[d&&e("span",{className:"vm-chart-tooltip-data__marker",style:{background:d}}),e("p",{className:"vm-chart-tooltip-data__value",children:[e("b",{children:s}),i]}),u>1&&e("p",{children:["(overlapping points: ",u,")"]})]}),c&&e("table",{className:"vm-chart-tooltip-stats",children:Nn.map((E,M)=>e("div",{className:"vm-chart-tooltip-stats-row",children:[e("span",{className:"vm-chart-tooltip-stats-row__key",children:[E,":"]}),e("span",{className:"vm-chart-tooltip-stats-row__value",children:c[E]})]},M))}),l&&e("p",{className:"vm-chart-tooltip__info",children:l})]}),t.root):null},ao=({showTooltip:t,tooltipProps:r,stickyTooltips:n,handleUnStick:a})=>e(q,{children:[t&&r&&e(_a,{...r}),n.map(s=>ko(_a,{...s,isSticky:!0,key:s.id,onClose:a}))]}),od=({data:t,series:r,metrics:n=[],period:a,yaxis:s,unit:o,setPeriod:i,layoutSize:l,height:c,spanGaps:m=!1,showAllPoints:d=!1})=>{const{isDarkTheme:u}=ne(),h=Z(null),[p,v]=b(),{xRange:y,setPlotScale:f}=no({period:a,setPeriod:i}),{onReadyChart:g,isPanning:_}=to(f);ro({uPlotInst:p,xRange:y,setPlotScale:f});const{showTooltip:C,stickyTooltips:w,handleUnStick:N,getTooltipProps:S,seriesFocus:A,setCursor:T,resetTooltips:E}=sd({u:p,metrics:n,series:r,unit:o}),M={...Ks({width:l.width,height:c}),series:r,axes:Bs([{},{scale:"1"}],o),scales:td(s,y),hooks:{ready:[g],setSeries:[A],setCursor:[T],setSelect:[eo(f)],destroy:[Js]},bands:[]};return x(()=>{if(E(),!h.current)return;p&&p.destroy();const I=new At(M,t,h.current);return v(I),I.destroy},[h,u]),x(()=>{p&&(p.setData(t),p.redraw())},[t]),x(()=>{p&&(Gs(p),Xc(p,r,m,d),p.redraw())},[r,m,d]),x(()=>{p&&(Object.keys(s.limits.range).forEach(I=>{p.scales[I]&&(p.scales[I].range=(k,L=0,$=1)=>Xs(k,L,$,I,s))}),p.redraw())},[s]),x(()=>{p&&(p.scales.x.range=()=>Zs(y),p.redraw())},[y]),x(()=>{p&&(p.setSize({width:l.width||400,height:c||500}),p.redraw())},[c,l]),e("div",{className:R({"vm-line-chart":!0,"vm-line-chart_panning":_}),style:{minWidth:`${l.width||400}px`,minHeight:`${c||500}px`},children:[e("div",{className:"vm-line-chart__u-plot",ref:h}),e(ao,{showTooltip:C,tooltipProps:S(),stickyTooltips:w,handleUnStick:N})]})};var $t=(t=>(t.view="legend_view",t.hideDuplicates="legend_hide_duplicates",t.hideStats="legend_hide_stats",t.format="legend_format",t.group="legend_group",t))($t||{}),vn=(t=>(t.table="table",t.lines="lines",t))(vn||{});const dr=$t.view,so=()=>{const[t,r]=me(),n=t.get(dr),[a,s]=b(n||"lines"),o=i=>{i==="table"?t.set(dr,i):t.delete(dr),s(i),r(t)};return x(()=>{const i=t.get(dr);i!==a&&s(i)},[t]),{view:a,isLinesView:a==="lines",isTableView:a==="table",onChange:o}},id=t=>Object.keys(t.freeFormFields).filter(n=>n!=="__name__").map(n=>{const a=`${n}=${JSON.stringify(t.freeFormFields[n])}`;return{id:`${t.label}.${a}`,freeField:a,key:n}}),mr=$t.hideStats,Gn=()=>{const[t,r]=me(),n=t.get(mr)==="true",[a,s]=b(n),o=i=>{i?t.set(mr,"true"):t.delete(mr),s(i),r(t)};return x(()=>{const i=t.get(mr)==="true";i!==a&&s(i)},[t]),{hideStats:a,onChange:o}},ur=$t.format,oo=()=>{const[t,r]=me(),n=t.get(ur)||"",[a,s]=b(n),o=l=>{s(l)},i=()=>{a?t.set(ur,a):t.delete(ur),r(t)};return x(()=>{const l=t.get(ur);l!==a&&s(l||"")},[t]),{format:a,onChange:o,onApply:i}},ld=({legend:t,onChange:r,duplicateFields:n})=>{const a=Ke(),{hideStats:s}=Gn(),{format:o}=oo(),i=$s(t.freeFormFields,o),l=D(()=>{const h=id(t);return n?.length?h.filter(p=>!n.includes(p.key)):h},[t,n]),c=t.statsFormatted,m=Object.values(c).some(h=>h),d=h=>p=>{r&&r(h,p.ctrlKey||p.metaKey)},u=h=>async p=>{p.stopPropagation(),await a(h,`${h} has been copied`)};return e("div",{className:R({"vm-legend-item":!0,"vm-legend-row":!0,"vm-legend-item_hide":!t.checked}),onClick:d(t),children:[e("div",{className:"vm-legend-item__marker",style:{backgroundColor:t.color}}),e("div",{className:"vm-legend-item-info",children:e("span",{className:"vm-legend-item-info__label",children:[t.hasAlias&&t.label,!t.hasAlias&&o&&i,!t.hasAlias&&!o&&e(q,{children:[t.freeFormFields.__name__,!!l.length&&e(q,{children:" {"}),l.map((h,p)=>e("span",{className:"vm-legend-item-info__free-fields",onClick:u(h.freeField),title:"copy to clipboard",children:[h.freeField,p+1<l.length&&","]},h.key)),!!l.length&&e(q,{children:"}"})]})]})}),!s&&m&&e("div",{className:"vm-legend-item-stats",children:Nn.map((h,p)=>e("div",{className:"vm-legend-item-stats-row",children:[e("span",{className:"vm-legend-item-stats-row__key",children:[h,":"]}),e("span",{className:"vm-legend-item-stats-row__value",children:c[h]})]},p))})]})},cd=({labels:t,duplicateFields:r,onChange:n})=>e("div",{className:"vm-legend-item-container",children:t.map(a=>e(ld,{legend:a,duplicateFields:r,onChange:n},a.label))});function dd(t,r){return Object.fromEntries(Object.entries(t).filter(r))}function Yr(t){return dd(t,r=>!!r[1]||typeof r[1]=="number")}const Ca=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),io=(t,r)=>Ca(t)&&t[r]?t[r]:r.split(".").reduce((n,a)=>{if(Ca(n))return n[a];if(Array.isArray(n)){const s=parseInt(a,10);return n[s]!==void 0?n[s]:void 0}},t),md=Nn.map(t=>({key:`statsFormatted.${t}`,title:t})),ud=({labels:t,duplicateFields:r,onChange:n})=>{const{hideStats:a}=Gn(),s=a?[]:md,i=D(()=>{const m=[...new Set(t.flatMap(d=>Object.keys(d.freeFormFields)))].map(d=>({key:`freeFormFields.${d}`,title:d}));return r?.length?m.filter(d=>!r.includes(d.title)):m},[t,r]).concat(s),l=m=>d=>{n&&n(m,d.ctrlKey||d.metaKey)},c=Y((m,d)=>{const u=io(m,d);return typeof u=="string"?u:""},[]);return e("div",{className:"vm-legend-table__wrapper",children:e("table",{className:"vm-legend-table",children:[e("thead",{className:"vm-legend-table-thead",children:e("tr",{className:"vm-legend-table-row vm-legend-table_thead",children:[e("th",{className:"vm-legend-table-col vm-legend-table-col_marker vm-legend-table-col_thead"}),i.map(m=>e("th",{className:"vm-legend-table-col vm-legend-table-col_thead",children:m.title},m.key))]})}),e("tbody",{className:"vm-legend-table-tbody",children:t.map(m=>e("tr",{className:R({"vm-legend-table-row":!0,"vm-legend-table-row_tbody":!0,"vm-legend-table-row_exclude":!m.checked}),onClick:l(m),children:[e("td",{className:"vm-legend-table-col vm-legend-table-col_marker",children:e("div",{className:"vm-legend-item__marker",style:{backgroundColor:m.color}})}),i.map(d=>e("td",{className:"vm-legend-table-col",children:e("span",{className:"vm-legend-table-col__content",children:c(m,d.key)})},`${d.key}_${m.label}`))]},m.label))})]})})},hr=$t.hideDuplicates,lo=t=>{const[r,n]=me(),a=r.get(hr)==="true",[s,o]=b(a),i=c=>{c?r.set(hr,"true"):r.delete(hr),o(c),n(r)};x(()=>{const c=r.get(hr)==="true";c!==s&&o(c)},[r]);const l=D(()=>!s||!t?.length||t?.length<2?[]:[...new Set(t.flatMap(m=>Object.keys(m.freeFormFields||{})))].filter(m=>{const d=t.find(u=>u.freeFormFields[m])?.freeFormFields[m];return t.every(u=>u.freeFormFields[m]===d)}),[t,s]);return{hideDuplicates:s,onChange:i,duplicateFields:l}},fn="Ungrouped",pr=$t.group,Wn=()=>{const[t,r]=me(),n=t.get(pr)||"",[a,s]=b(n),o=i=>{i&&i!==fn?t.set(pr,i):t.delete(pr),s(i),r(t)};return x(()=>{const i=t.get(pr);i!==a&&s(i||"")},[t]),{groupByLabel:a,onChange:o}},hd=({labels:t,group:r,onChange:n})=>{const{isTableView:a}=so(),{groupByLabel:s}=Wn(),o=Ke(),{duplicateFields:i}=lo(t),l=D(()=>t.sort((p,v)=>(v.median||0)-(p.median||0)),[t]),c=p=>async v=>{v.stopPropagation(),await o(p,`${p} has been copied`)},m=a?ud:cd,u=be("LEGEND_AUTO_COLLAPSE")==="false"?!0:l.length<=Ha,h=e("span",{className:"vm-legend-group-header__warning",children:["Legend collapsed by default (",l.length," series) — click to expand."]});return e("div",{className:"vm-legend-group",children:e(Nt,{defaultExpanded:u,title:e("div",{className:"vm-legend-group-header",children:[e("div",{className:"vm-legend-group-header-title",children:["Group by",s?"":" query",": ",e("b",{children:r})," ",!u&&h]}),!!i.length&&e("div",{className:"vm-legend-group-header-labels",children:["common labels: {",i.map(p=>e("div",{onClick:c(`${p}="${t[0].freeFormFields[p]}"`),className:"vm-legend-group-header-labels__item",children:`${p}="${t[0].freeFormFields[p]}"`},p)),"}"]})]}),children:e(m,{labels:l,duplicateFields:i,onChange:n})})},r)},pd=({labels:t,query:r,groupByLabel:n})=>D(()=>vd(t,r,n),[t,r,n]),vd=(t,r,n)=>{const a=new Map;for(const s of t){const o=n?`${n}="${s.freeFormFields[n]??""}"`:`${r[s.group-1]}`;a.has(o)||a.set(o,{group:String(o),items:[]});const i=a.get(o);i.items.some(c=>c.label===s.label)||i.items.push(s)}return Array.from(a.values())},fd=({values:t,itemClassName:r,onRemoveItem:n})=>{const{isMobile:a}=W(),s=o=>i=>{n(o),i.stopPropagation()};return a?e("span",{className:"vm-select-input-content__counter",children:["selected ",t.length]}):e(q,{children:t.map(o=>e("div",{className:`vm-select-input-content__selected ${r} ${o.toLowerCase().replace(" ","-")}`,children:[e("span",{children:o}),e("div",{onClick:s(o),children:e(De,{})})]},o))})},ot=({value:t,list:r,label:n,itemClassName:a,placeholder:s,noOptionsText:o,clearable:i=!1,searchable:l=!1,autofocus:c,disabled:m,includeAll:d,onChange:u})=>{const{isDarkTheme:h}=ne(),{isMobile:p}=W(),[v,y]=b(""),f=Z(null),[g,_]=b(null),[C,w]=b(!1),N=[...r],S=Z(null),A=Array.isArray(t);let T=Array.isArray(t)?t.slice():[];const E=p&&A&&!!T?.length,M=D(()=>C?v:Array.isArray(t)?"":t,[t,v,C,A]),I=D(()=>C?v||"(.+)":"",[v,C]),k=()=>{S.current&&S.current.blur()},L=()=>{w(!1),k()},$=()=>{m||w(!0)},V=()=>{N.includes(v)&&u(v)},H=B=>{B.target instanceof HTMLInputElement||m||w(ae=>!ae)},z=B=>{y(""),u(B),A||L(),A&&S.current&&S.current.focus()},j=B=>{y(B.target.value)},ee=B=>ae=>{z(B),ae.stopPropagation()},X=B=>{S.current!==B.target&&w(!1)};return x(()=>{y(""),C&&S.current&&S.current.focus(),C||k()},[C,S]),x(()=>{!c||!S.current||p||S.current.focus()},[c,S]),oe("keyup",X),Br(f,L,g),d&&!N.includes("All")&&N.push("All"),d&&(!T?.length||T?.length===N?.length)&&(T=["All"]),e("div",{className:R({"vm-select":!0,"vm-select_dark":h,"vm-select_disabled":m}),children:[n&&e("span",{className:"vm-text-field__label",children:n}),e("div",{className:"vm-select-input",onClick:H,ref:f,children:[e("div",{className:"vm-select-input-content",children:[!!T?.length&&e(fd,{itemClassName:a,values:T,onRemoveItem:z}),!E&&e("input",{value:M,type:"text",placeholder:s,onInput:j,onFocus:$,onBlur:V,disabled:m,ref:S,readOnly:p||!l})]}),i&&t&&e("div",{className:"vm-select-input__icon",onClick:ee(""),children:e(De,{})}),e("div",{className:R({"vm-select-input__icon":!0,"vm-select-input__icon_open":C}),children:e(Xe,{})})]}),e(Is,{itemClassName:a,label:n,value:I,options:N.map(B=>({value:B})),anchor:f,selected:T,minLength:1,fullWidth:!0,noOptionsText:o,onSelect:z,onOpenAutocomplete:w,onChangeWrapperRef:_})]})},co=({data:t,isCompact:r})=>{const{isTableView:n,onChange:a}=so(),{hideDuplicates:s,onChange:o}=lo(),{hideStats:i,onChange:l}=Gn(),{format:c,onChange:m,onApply:d}=oo(),{groupByLabel:u,onChange:h}=Wn(),p=rt(),v=D(()=>{if(!t||!t.length)return[];const C=t.flatMap(w=>Object.keys(w.metric));return Array.from(new Set(C))},[t]),y=C=>{const w=C?vn.table:vn.lines;a(w)},f=()=>{p({type:"SET_OPEN_SETTINGS",payload:!0})},g=[{label:"Table View",value:n,onChange:y,info:"If enabled, the legend will be displayed in a table format."},{label:"Hide Common Labels",value:s,onChange:o,info:"If enabled, hides labels that are the same for all series."},{label:"Hide Statistics",value:i,onChange:l,info:"If enabled, hides the display of min, median, and max values."}],_=r?G:q;return e("div",{className:R({"vm-legend-configs":!0,"vm-legend-configs_compact":r}),children:[g.map(({label:C,value:w,onChange:N,info:S})=>e(_,{title:S,children:e("div",{className:"vm-legend-configs-item vm-legend-configs-item_switch",children:[e("span",{className:"vm-legend-configs-item__label",children:C}),e(Ie,{label:`${r?C:w?"Enabled":"Disabled"}`,value:w,onChange:N}),e("span",{className:"vm-legend-configs-item__info",children:S})]})},C)),r&&e(O,{size:"small",variant:"text",startIcon:e(vt,{}),onClick:f,children:"Settings"}),!r&&e(q,{children:[e("div",{className:"vm-legend-configs-item",children:[e(ie,{label:"Custom Legend Format",placeholder:"{{label_name}}",value:c,onChange:m,onBlur:d,onEnter:d}),e("span",{className:"vm-legend-configs-item__info vm-legend-configs-item__info_input",children:"Customize legend labels with text and {{label_name}} placeholders."})]}),e("div",{className:"vm-legend-configs-item",children:[e(ot,{label:"Group Legend By",value:u,list:[fn,...v],placeholder:fn,onChange:h,searchable:!0}),e("span",{className:"vm-legend-configs-item__info",children:"Choose a label to group the legend. By default, legends are grouped by query."})]})]})]})},gd=({labels:t,query:r,isPredefinedPanel:n,onChange:a})=>{const{groupByLabel:s}=Wn(),o=pd({labels:t,query:r,groupByLabel:s});return e("div",{className:"vm-legend",children:[!n&&e(co,{isCompact:!0}),e("div",{children:o.map(({group:i,items:l})=>e(hd,{labels:l,group:i,onChange:a},i))})]})},bd=({min:t,max:r,legendValue:n})=>{const[a,s]=b(0),[o,i]=b(""),[l,c]=b(""),[m,d]=b(""),u=D(()=>{const h=Number(String(n?.value??"").replace("%","").replace(",","."));return Number.isFinite(h)?h:0},[n?.value]);return x(()=>{s(u?(u-t)/(r-t)*100:0),i(u?`${u}%`:""),c(`${t}%`),d(`${r}%`)},[u,t,r]),e("div",{className:"vm-legend-heatmap__wrapper",children:e("div",{className:"vm-legend-heatmap",children:[e("div",{className:"vm-legend-heatmap-gradient",style:{background:`linear-gradient(to right, ${Yn.join(", ")})`},children:!!u&&e("div",{className:"vm-legend-heatmap-gradient__value",style:{left:`${a}%`},children:e("span",{children:o})})}),e("div",{className:"vm-legend-heatmap__value",children:l}),e("div",{className:"vm-legend-heatmap__value",children:m})]})})},yd=({u:t,metrics:r,unit:n})=>{const[a,s]=b({left:0,top:0}),[o,i]=b([]),l=()=>{i([]),s({left:0,top:0})},c=h=>{const p=h.cursor.left||0,v=h.cursor.top||0;s({left:p,top:v})},m=Y(()=>{const{left:h,top:p}=a,v=t?.data[1][0]||[],y=t?t.posToVal(h,"x"):0,f=t?t.posToVal(p,"y"):0,g=v.findIndex((M,I)=>y>=M&&y<v[I+1])||-1,_=v[g+1],C=r[Math.round(f)]||{values:[]},[w=0,N=""]=C.values.find(M=>M[0]===_)||[],S=v[g],A=Q(S*1e3).tz().format(Nr),T=Q(w*1e3).tz().format(Nr),E=C?.metric?.vmrange||"";return{unit:n,point:a,u:t,id:`${E}_${A}`,dates:[A,T],value:`${N}%`,info:E,show:+N>0}},[t,a,r,n]),d=Y(()=>{const h=m();h.show&&(o.find(p=>p.id===h.id)||i(p=>[...p,h]))},[m,o]),u=h=>{i(p=>p.filter(v=>v.id!==h))};return oe("click",d),{stickyTooltips:o,handleUnStick:u,getTooltipProps:m,setCursor:c,resetTooltips:l}},_d=({data:t,metrics:r=[],period:n,unit:a,setPeriod:s,layoutSize:o,height:i,onChangeLegend:l})=>{const{isDarkTheme:c}=ne(),m=Z(null),[d,u]=b(),{xRange:h,setPlotScale:p}=no({period:n,setPeriod:s}),{onReadyChart:v,isPanning:y}=to(p);ro({uPlotInst:d,xRange:h,setPlotScale:p});const{stickyTooltips:f,handleUnStick:g,getTooltipProps:_,setCursor:C,resetTooltips:w}=yd({u:d,metrics:r,unit:a}),N=D(()=>_(),[_]),S=()=>{const T=Bs([{}],a);return[...T,{scale:"y",stroke:T[0].stroke,font:T[0].font,size:Qs,splits:r.map((E,M)=>M),values:r.map(E=>E.metric.vmrange)}]},A={...Ks({width:o.width,height:i}),mode:2,series:[{},{paths:Vc(),facets:[{scale:"x",auto:!0,sorted:1},{scale:"y",auto:!0}]}],axes:S(),scales:{x:{time:!0},y:{log:2,time:!1,range:(T,E,M)=>[E-1,M+1]}},hooks:{ready:[v],setCursor:[C],setSelect:[eo(p)],destroy:[Js]}};return x(()=>{w();const T=t[0]===null&&Array.isArray(t[1]);if(!m.current||!T)return;const E=new At(A,t,m.current);return u(E),E.destroy},[m,t,c]),x(()=>{d&&(d.setSize({width:o.width||400,height:i||500}),d.redraw())},[i,o]),x(()=>{l(N)},[N]),e("div",{className:R({"vm-line-chart":!0,"vm-line-chart_panning":y}),style:{minWidth:`${o.width||400}px`,minHeight:`${i||500}px`},children:[e("div",{className:"vm-line-chart__u-plot",ref:m}),e(ao,{showTooltip:!!N.show,tooltipProps:N,stickyTooltips:f,handleUnStick:g})]})},Cd=()=>{const[t,r]=b(null),[n,a]=b({width:0,height:0}),s=Y(()=>{a({width:t?.offsetWidth||0,height:t?.offsetHeight||0})},[t?.offsetHeight,t?.offsetWidth]);return oe("resize",s),x(s,[t?.offsetHeight,t?.offsetWidth]),[r,n]},Gr=({data:t=[],period:r,customStep:n,query:a,yaxis:s,unit:o,showLegend:i=!0,setYaxisLimits:l,setPeriod:c,alias:m=[],fullWidth:d=!0,height:u,isHistogram:h,isPredefinedPanel:p,spanGaps:v,showAllPoints:y})=>{const f=ct(),g=D(()=>f.pathname===K.rawQuery,[f.pathname]),_=rt(),[C,w]=Cd(),{isMobile:N}=W(),{timezone:S}=he(),A=D(()=>n||r.step||"1s",[r.step,n]),T=D(()=>Bc(t,h),[h,t]),[E,M]=b([[]]),[I,k]=b([]),[L,$]=b([]),[V,H]=b([]),[z,j]=b(null),ee=D(()=>Kc(T,V,m,y,g),[T,V,m,y,g]),X=(F,P)=>{let U=Number.isFinite(F)?F:0,J=Number.isFinite(P)?P:1;U>J&&([U,J]=[J,U]),l({1:h?[U,J]:pn(U,J)})},B=(F,P)=>{H(Zc({hideSeries:V,legend:F,metaKey:P,series:I}))},ae=F=>{const P=F.slice(1,F.length),U=[],J=[];P.forEach((se,ce)=>{se.forEach((He,ye)=>{const Le=ye*P.length+ce;J[Le]=He})}),F[0].forEach(se=>{const ce=new Array(P.length).fill(se);U.push(...ce)});const re=new Array(U.length).fill(0).map((se,ce)=>ce%P.length);return[null,[U,re,J]]};x(()=>{const F=T.length,P=T?.[0]?.values?.[0]?.[0],U=[],J=new Array(F),re=new Array(F+1);re[0]={};let se=1/0,ce=-1/0;for(let ke=0;ke<F;ke++){const _e=T[ke],ve=ee(_e);re[ke+1]=ve,J[ke]=ga(ve,_e.group);const ze=_e.values;for(let Je=0,Fe=ze.length;Je<Fe;Je++){const at=ze[Je];g&&U.push(at[0]);const st=Lr(at[1]);Number.isFinite(st)&&(st<se&&(se=st),st>ce&&(ce=st))}}const He=window.devicePixelRatio||1,ye=w.width||window.innerWidth||4096,Le=Math.max(1,Math.floor(ye*Math.max(1,He))),et=g?U.sort((ke,_e)=>ke-_e):$c(A,r,Le,P),Te=T.map(ke=>{const _e=et.length,ve=new Array(_e),ze=ke.values,Je=ze.length;let Fe=0;for(let Be=0;Be<_e;Be++){const ea=et[Be];for(;Fe<Je&&ze[Fe][0]<ea;)Fe++;let ta=null;if(Fe<Je&&ri(ze[Fe][0],ea)){const ra=Lr(ze[Fe][1]);ta=Number.isFinite(ra)?ra:null,Fe++}ve[Be]=ta}const{min:at,max:st,avg:Ot}=Ua(ve,{min:!0,max:!0,avg:!0}),Ht=Math.abs(Number(Ot)),Ee=pn(at,st),St=Math.abs(Ee[1]-Ee[0]);return Ht>St*1e10?ve.fill(Ht):ve});Te.unshift(et);const wt=h?ae(Te):Te;X(se,ce),M(wt),k(re),$(J)},[T,S,h,A,g]),x(()=>{const F=T.length,P=new Array(F),U=new Array(F+1);U[0]={};for(let J=0;J<F;J++){const re=T[J],se=ee(re);U[J+1]=se,P[J]=ga(se,re.group)}k(U),$(P)},[V]);const le=E[0]?.length>0;return x(()=>{const P=(()=>{if(!h||!T[1])return!1;try{return(E?.[1]?.[2]||[]).every(J=>J===null)}catch{return!1}})();_({type:"SET_IS_EMPTY_HISTOGRAM",payload:P})},[E,h]),e("div",{className:R({"vm-graph-view":!0,"vm-graph-view_full-width":d,"vm-graph-view_full-width_mobile":d&&N}),ref:C,children:[!h&&le&&e(od,{data:E,series:I,metrics:T,period:r,yaxis:s,unit:o,setPeriod:c,layoutSize:w,height:u,spanGaps:v,showAllPoints:g?!0:y}),h&&e(_d,{data:E,metrics:T,period:r,unit:o,setPeriod:c,layoutSize:w,height:u,onChangeLegend:j}),!h&&i&&e(gd,{labels:L,query:a,onChange:B,isPredefinedPanel:p}),h&&i&&e(bd,{min:s.limits.range[1][0]||0,max:s.limits.range[1][1]||0,legendValue:z})]})},Nd=({yaxis:t,setYaxisLimits:r,toggleEnableLimits:n})=>{const{isMobile:a}=W(),s=D(()=>Object.keys(t.limits.range),[t.limits.range]),i=Y(Dt((c,m,d)=>{const u=t.limits.range;u[m][d]=+c,!(u[m][0]===u[m][1]||u[m][0]>u[m][1])&&r(u)},500),[t.limits.range]),l=(c,m)=>d=>{i(d,c,m)};return e("div",{className:R({"vm-axes-limits":!0,"vm-axes-limits_mobile":a}),children:[e("div",{className:"vm-graph-settings-row",children:[e("span",{className:"vm-graph-settings-row__label",children:"Fixed Y-axis limits"}),e(Ie,{value:t.limits.enable,onChange:n,label:t.limits.enable?"Enabled":"Disabled",fullWidth:a})]}),e("span",{className:"vm-legend-configs-item__info",children:"Enables manual setting of min and max values for the y-axis."}),t.limits.enable&&e("div",{className:"vm-axes-limits-list",children:s.map(c=>e("div",{className:"vm-axes-limits-list__inputs",children:[e(ie,{label:`Min ${c}`,type:"number",disabled:!t.limits.enable,value:t.limits.range[c][0],onChange:l(c,0)}),e(ie,{label:`Max ${c}`,type:"number",disabled:!t.limits.enable,value:t.limits.range[c][1],onChange:l(c,1)})]},c))})]})},wd=({spanGaps:t,onChange:r})=>{const{isMobile:n}=W();return e("div",{className:"vm-graph-settings-row",children:[e("span",{className:"vm-graph-settings-row__label",children:"Connect null values"}),e(Ie,{value:t,onChange:r,label:t?"Enabled":"Disabled",fullWidth:n}),e("span",{className:"vm-legend-configs-item__info",children:"Connects data points by skipping null values instead of gaps."})]})},mo=()=>{const[t,r]=me(),n=Ge();return{handleChange:(s,o)=>{s?t.delete("display_mode"):t.set("display_mode","lines"),r(t),n({type:"RUN_QUERY"}),o&&o()}}},Sd=({onChange:t})=>{const{isMobile:r}=W(),{handleChange:n}=mo(),[a]=me(),s=!a.get("display_mode");return e("div",{className:"vm-graph-settings-row",children:[e("span",{className:"vm-graph-settings-row__label",children:"Histogram mode"}),e(Ie,{value:s,onChange:i=>{n(i,t)},label:s?"Enabled":"Disabled",fullWidth:r})]})},Td=({showAllPoints:t,onChangeShow:r})=>{const{isMobile:n}=W();return e(q,{children:e("div",{className:"vm-graph-settings-row",children:[e("span",{className:"vm-graph-settings-row__label",children:"Show all data points"}),e(Ie,{value:t,onChange:r,label:t?"Enabled":"Disabled",fullWidth:n}),e("span",{className:"vm-legend-configs-item__info",children:"Display every data point, even when no line can be drawn."})]})})},Na="Graph & Legend Settings",Kn=({data:t,yaxis:r,setYaxisLimits:n,toggleEnableLimits:a,spanGaps:s,showAllPoints:o})=>{const{openSettings:i}=Oe(),l=rt(),c=Z(null),m=Z(null),d=qn(t),{value:u,setTrue:h,setFalse:p}=de(!1);return x(()=>{i&&(h(),l({type:"SET_OPEN_SETTINGS",payload:!1}))},[i]),e("div",{className:"vm-graph-settings",children:[e(G,{title:Na,children:e("div",{ref:m,children:e(O,{variant:"text",startIcon:e(vt,{}),onClick:h,ariaLabel:"settings"})})}),u&&e(we,{onClose:p,title:Na,className:"vm-graph-settings-modal",children:e("div",{className:"vm-graph-settings-body",ref:c,children:[e("div",{className:"vm-graph-settings-body-section",children:[e("h3",{className:"vm-graph-settings-body-section__title",children:"Graph Options"}),e("div",{className:"vm-graph-settings-body-section-content",children:[e(Nd,{yaxis:r,setYaxisLimits:n,toggleEnableLimits:a}),e(wd,{spanGaps:s.value,onChange:s.onChange}),e(Td,{showAllPoints:o.value,onChangeShow:o.onChange}),d&&e(Sd,{onChange:p})]})]}),e("div",{className:"vm-graph-settings-body-section",children:[e("h3",{className:"vm-graph-settings-body-section__title",children:"Legend Options"}),e("div",{className:"vm-graph-settings-body-section-content",children:e(co,{data:t})})]})]})})]})},Ed=({isHistogram:t,graphData:r,controlsRef:n})=>{const{isMobile:a}=W(),{customStep:s,yaxis:o,spanGaps:i,showAllPoints:l}=Oe(),{period:c}=he(),{query:m}=Pe(),d=Ge(),u=rt(),h=Y(_=>{u({type:"SET_YAXIS_LIMITS",payload:_})},[u]),p=Y(()=>{u({type:"TOGGLE_ENABLE_YAXIS_LIMITS"})},[u]),v=Y(_=>{u({type:"SET_SPAN_GAPS",payload:_})},[u]),y=Y(({from:_,to:C})=>{d({type:"SET_PERIOD",payload:{from:_,to:C}})},[d]),f=Y(_=>{u({type:"SET_SHOW_POINTS",payload:_})},[u]),g=e("div",{className:"vm-custom-panel-body-header__graph-controls",children:[e(Un,{}),e(Kn,{data:r,yaxis:o,isHistogram:t,setYaxisLimits:h,toggleEnableLimits:p,spanGaps:{value:i,onChange:v},showAllPoints:{value:l,onChange:f}})]});return e(q,{children:[n.current&&It(g,n.current),e(Gr,{data:r,period:c,customStep:s,query:m,yaxis:o,setYaxisLimits:h,setPeriod:y,height:a?window.innerHeight*.5:500,isHistogram:t,spanGaps:i,showAllPoints:l})]})},Jn=({data:t})=>{const r=Ke(),n=D(()=>JSON.stringify(t,null,2),[t]);return e("div",{className:"vm-json-view",children:[e("div",{className:"vm-json-view__copy",children:e(O,{variant:"outlined",onClick:async()=>{await r(n,"Formatted JSON has been copied")},children:"Copy JSON"})}),e("pre",{className:"vm-json-view__code",children:e("code",{children:n})})]})},nr=t=>{const r={};return t.forEach(n=>Object.entries(n.metric).forEach(a=>r[a[0]]?r[a[0]].options.add(a[1]):r[a[0]]={options:new Set([a[1]])})),Object.entries(r).map(n=>({key:n[0],variations:n[1].options.size})).sort((n,a)=>n.variations-a.variations)},wa=(t,r)=>D(()=>r?nr(t).filter(a=>r.includes(a.key)):[],[t,r]),uo=({data:t,displayColumns:r})=>{const n=Ke(),{isMobile:a}=W(),{tableCompact:s}=$e(),o=Z(null),[i,l]=b(""),[c,m]=b("asc"),d=s?wa([{group:0,metric:{Data:"Data"}}],["Data"]):wa(t,r),u=C=>{const{__name__:w,...N}=C;return!w&&!Object.keys(N).length?"":w?`${w} ${JSON.stringify(N)}`:`${JSON.stringify(N)}`},p=new Set(t?.map(C=>C.group)).size>1,v=D(()=>{const C=t?.map(S=>({metadata:d.map(A=>s?hn(S,"",p):S.metric[A.key]||"-"),value:S.value?S.value[1]:"-",values:S.values?S.values.map(([A,T])=>`${T} @${A}`):[],copyValue:u(S.metric)})),w=i==="Value",N=d.findIndex(S=>S.key===i);return!w&&N===-1?C:C.sort((S,A)=>{const T=w?Number(S.value):S.metadata[N],E=w?Number(A.value):A.metadata[N];return(c==="asc"?T<E:T>E)?-1:1})},[d,t,i,c,s]),y=D(()=>v.some(C=>C.copyValue),[v]),f=C=>{m(w=>w==="asc"&&i===C?"desc":"asc"),l(C)},g=C=>()=>{f(C)},_=C=>async()=>{await n(C,"Row has been copied")};return v.length?e("div",{className:R({"vm-table-view":!0,"vm-table-view_mobile":a}),children:e("table",{className:"vm-table",ref:o,children:[e("thead",{className:"vm-table-header",children:e("tr",{className:"vm-table__row vm-table__row_header",children:[d.map((C,w)=>e("td",{className:"vm-table-cell vm-table-cell_header vm-table-cell_sort",onClick:g(C.key),children:e("div",{className:"vm-table-cell__content",children:[C.key,e("div",{className:R({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":i===C.key,"vm-table__sort-icon_desc":c==="desc"&&i===C.key}),children:e(Xe,{})})]})},w)),e("td",{className:"vm-table-cell vm-table-cell_header vm-table-cell_right vm-table-cell_sort",onClick:g("Value"),children:e("div",{className:"vm-table-cell__content",children:[e("div",{className:R({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":i==="Value","vm-table__sort-icon_desc":c==="desc"}),children:e(Xe,{})}),"Value"]})}),y&&e("td",{className:"vm-table-cell vm-table-cell_header"})]})}),e("tbody",{className:"vm-table-body",children:v.map((C,w)=>e("tr",{className:"vm-table__row",children:[C.metadata.map((N,S)=>e("td",{className:R({"vm-table-cell vm-table-cell_no-wrap":!0,"vm-table-cell_gray":v[w-1]&&v[w-1].metadata[S]===N}),children:N},S)),e("td",{className:"vm-table-cell vm-table-cell_right vm-table-cell_no-wrap",children:C.values.length?C.values.map(N=>e("p",{children:N},N)):C.value}),y&&e("td",{className:"vm-table-cell vm-table-cell_right",children:C.copyValue&&e("div",{className:"vm-table-cell__content",children:e(G,{title:"Copy row",children:e(O,{variant:"text",color:"gray",size:"small",startIcon:e(_t,{}),onClick:_(C.copyValue),ariaLabel:"copy row"})})})})]},w))})]})}):e(te,{variant:"warning",children:"No data to show"})},gn=({checked:t=!1,disabled:r=!1,label:n,color:a="secondary",onChange:s})=>{const o=()=>{r||s(!t)},i=R({"vm-checkbox":!0,"vm-checkbox_disabled":r,"vm-checkbox_active":t,[`vm-checkbox_${a}_active`]:t,[`vm-checkbox_${a}`]:a});return e("div",{className:i,onClick:o,children:[e("div",{className:"vm-checkbox-track",children:e("div",{className:"vm-checkbox-track__thumb",children:e(Ur,{})})}),n&&e("span",{className:"vm-checkbox__label",children:n})]})},nn="Table settings",ho=({columns:t,selectedColumns:r=[],tableCompact:n,onChangeColumns:a,toggleTableCompact:s})=>{const[o,i]=me(),l=Z(null),{value:c,toggle:m,setFalse:d}=de(!1),[u,h]=b(""),[p,v]=b(-1),y=D(()=>r.filter(T=>!t.includes(T)),[t,r]),f=D(()=>{const T=y.concat(t);return(u?T.filter(M=>M.includes(u)):T).sort((M,I)=>M.localeCompare(I))},[t,y,u]),g=D(()=>f.every(T=>r.includes(T)),[r,f]),_=T=>{a(T);const E=new URLSearchParams(o.toString());T.length===t.length?E.delete("columns"):E.set("columns",T.map(encodeURIComponent).join(",")),i(E)},C=T=>{const E=r.includes(T)?r.filter(M=>M!==T):[...r,T];_(E)},w=()=>{_(g?r.filter(T=>!f.includes(T)):f)},N=T=>()=>{C(T)},S=()=>{v(-1)},A=T=>{const E=T.key==="ArrowUp",M=T.key==="ArrowDown",I=T.key==="Enter";(M||E||I)&&T.preventDefault(),M?v(k=>k+1>f.length-1?k:k+1):E?v(k=>k-1<0?k:k-1):I&&C(f[p])};return x(()=>{Qr(t,r)||o.has("columns")||a(t)},[t]),x(()=>{if(!o.has("columns"))return;const M=(o.get("columns")||"").split(",").map(decodeURIComponent).filter(Boolean);a(M)},[]),e("div",{className:"vm-table-settings",children:[e(G,{title:nn,children:e("div",{ref:l,children:e(O,{variant:"text",startIcon:e(vt,{}),onClick:m,ariaLabel:nn})})}),c&&e(we,{title:nn,className:"vm-table-settings-modal",onClose:d,children:[e("div",{className:"vm-table-settings-modal-section",children:[e("div",{className:"vm-table-settings-modal-section__title",children:"Customize columns"}),e("div",{className:"vm-table-settings-modal-columns",children:[e("div",{className:"vm-table-settings-modal-columns__search",children:e(ie,{placeholder:"Search columns",startIcon:e(Rt,{}),value:u,onChange:h,onBlur:S,onKeyDown:A,type:"search"})}),e("div",{className:"vm-table-settings-modal-columns-list",children:[!!f.length&&e("div",{className:"vm-table-settings-modal-columns-list__item vm-table-settings-modal-columns-list__item_all",children:e(gn,{checked:g,onChange:w,label:g?"Uncheck all":"Check all",disabled:n})}),!f.length&&e("div",{className:"vm-table-settings-modal-columns-no-found",children:e("p",{className:"vm-table-settings-modal-columns-no-found__info",children:"No columns found."})}),f.map((T,E)=>e("div",{className:R({"vm-table-settings-modal-columns-list__item":!0,"vm-table-settings-modal-columns-list__item_focus":E===p,"vm-table-settings-modal-columns-list__item_custom":y.includes(T)}),children:e(gn,{checked:r.includes(T),onChange:N(T),label:T,disabled:n})},T))]})]})]}),s&&n!==void 0&&e("div",{className:"vm-table-settings-modal-section",children:[e("div",{className:"vm-table-settings-modal-section__title",children:"Table view"}),e("div",{className:"vm-table-settings-modal-columns-list__item",children:e(Ie,{label:"Compact view",value:n,onChange:s})})]})]})]})},xd=({liveData:t,controlsRef:r})=>{const{tableCompact:n}=$e(),a=Pt(),[s,o]=b(),i=D(()=>nr(t||[]).map(m=>m.key),[t]),c=e(ho,{columns:i,selectedColumns:s,onChangeColumns:o,tableCompact:n,toggleTableCompact:()=>{a({type:"TOGGLE_TABLE_COMPACT"})}});return e(q,{children:[r.current&&It(c,r.current),e(uo,{data:t,displayColumns:s})]})},po=({graphData:t,liveData:r,isHistogram:n,displayType:a,controlsRef:s})=>a===pe.code&&r?e(Jn,{data:r}):a===pe.table&&r?e(xd,{liveData:r,controlsRef:s}):a===pe.chart&&t?e(Ed,{graphData:t,isHistogram:n,controlsRef:s}):null,Ad=e(q,{children:[e("p",{children:"Filename - specify the name for your report file."}),e("p",{children:["Default format: ",e("code",{children:["vmui_report_$",Fa,".json"]}),"."]}),e("p",{children:"This name will be used when saving your report on your device."})]}),Ld=e(q,{children:[e("p",{children:["Title - specify the title that will be displayed on the ",e(Dr,{to:K.queryAnalyzer,target:"_blank",rel:"noreferrer",className:"vm-link vm-link_underlined",children:Wt[K.queryAnalyzer].title})," page."]}),e("p",{children:"This helps identify your report in the interface."})]}),kd=e(q,{children:[e("p",{children:"Comment (optional) - add a comment to your report."}),e("p",{children:"This can be any additional information that will be useful when reviewing the report later."})]}),Md=e(q,{children:[e("p",{children:"Query trace - enable this option to include a query trace in your report."}),e("p",{children:"This will assist in analyzing and diagnosing the query processing."})]}),Id=e(q,{children:[e("p",{children:"Generate Report - click this button to generate and save your report. "}),e("p",{children:["After creation, the report can be downloaded and examined on the ",e(Dr,{to:K.queryAnalyzer,target:"_blank",rel:"noreferrer",className:"vm-link vm-link_underlined",children:Wt[K.queryAnalyzer].title})," page."]})]}),Dd=[Ad,Ld,kd,Md,Id],vo=t=>{try{return JSON.parse(t)}catch{return null}},Rd=[{title:"Write",value:!1},{title:"Preview",value:!0}],Pd=({value:t,onChange:r})=>{const{value:n,setTrue:a,setFalse:s}=de(!1);return e("div",{className:"vm-markdown-editor",children:[e("div",{className:"vm-markdown-editor-header",children:[e("div",{className:"vm-markdown-editor-header-tabs",children:Rd.map(({title:o,value:i})=>e("div",{className:R({"vm-markdown-editor-header-tabs__tab":!0,"vm-markdown-editor-header-tabs__tab_active":n===i}),onClick:i?a:s,children:o},o))}),e("span",{className:"vm-markdown-editor-header__info",children:"Markdown is supported"})]}),n?e("div",{className:"vm-markdown-editor-preview vm-markdown",dangerouslySetInnerHTML:{__html:Ir(t)}}):e(ie,{type:"textarea",value:t,onChange:r})]})},$d=t=>t===1?"Raw report":"Report",Od=t=>{const r=Q().utc().format(Fa);return`vmui_${t.toLowerCase().replace(/ /g,"_")}_${r}`},Hd=({fetchUrl:t,reportType:r=0})=>{const{query:n}=Pe(),a=$d(r),s=Od(a),[o,i]=b(a),[l,c]=b(s),[m,d]=b(""),[u,h]=b(r===0),[p,v]=b(),[y,f]=b(!1),g=Z(null),_=Z(null),C=Z(null),w=Z(null),N=Z(null),S=[_,g,C,w,N],[A,T]=b(0),{value:E,toggle:M,setFalse:I}=de(!1),{value:k,toggle:L,setFalse:$}=de(!1),V=Y(()=>{if(t)try{return t.map((F,P)=>{const U=new URL(F);return u?U.searchParams.set("trace","1"):U.searchParams.delete("trace"),{id:P,url:U}})}catch(F){v(String(F))}},[t,u]),H=Y(F=>{const P=JSON.stringify(F,null,2);jr(P,`${l||s}.json`),I()},[l]),z=({id:F,url:P,comment:U,title:J})=>({id:F,title:J||a,comment:U,endpoint:Uo(P.pathname)||"",params:Object.fromEntries(P.searchParams)}),j=async(F,P)=>{const U=[],J=await F.text();return F.ok?J.split(`
`).filter(se=>se).forEach(se=>{const ce=vo(se);ce&&U.push({metric:ce.metric,values:ce.values.map((He,ye)=>[ce.timestamps[ye]/1e3,He])})}):v(String(J)),{data:{result:U,resultType:"matrix"},vmui:z(P)}},ee=async(F,P)=>{const U=await F.json();if(F.ok)return U.vmui=z(P),U;{const J=U.errorType?`${U.errorType}\r
`:"";v(`${J}${U?.error||U?.message||"unknown error"}`)}},X=async(F,P)=>r===1?await j(F,P):await ee(F,P),B=Y(async()=>{const F=V();if(!F){v(P=>P||ge.validQuery);return}v(""),f(!0);try{const P=[];for await(const U of F){if(!U)continue;const{url:J,id:re}=U,se=await fetch(J),ce=await X(se,{id:re,url:J,comment:m,title:o});P.push(ce)}P.length&&H(P)}catch(P){P instanceof Error&&P.name!=="AbortError"&&v(`${P.name}: ${P.message}`)}finally{f(!1)}},[V,m,H,n,o]),ae=F=>()=>{const P=U=>{const J=U+F;return S[J]?.current?J:P(J)};T(P)};return x(()=>{v(""),c(s),d("")},[E]),x(()=>{T(0)},[k]),e(q,{children:[e(G,{title:"Debug query",children:e(O,{variant:"text",startIcon:e(Cs,{}),onClick:M,ariaLabel:"Debug query"})}),E&&e(we,{title:"Debug query",onClose:I,isOpen:E,children:e("div",{className:"vm-download-report",children:[e("div",{className:"vm-download-report-settings",children:[e("div",{ref:_,children:[e("div",{className:"vm-download-report-settings__title",children:"Filename"}),e(ie,{value:l,onChange:c})]}),e("div",{ref:g,children:[e("div",{className:"vm-download-report-settings__title",children:"Report title"}),e(ie,{value:o,onChange:i})]}),e("div",{ref:C,children:[e("div",{className:"vm-download-report-settings__title",children:"Comment"}),e(Pd,{value:m,onChange:d})]}),r===0&&e(q,{children:[e("div",{ref:w,children:e(gn,{checked:u,onChange:h,label:"Include query trace"})}),e(te,{variant:"info",children:["If confused with the query results, try viewing the raw samples for selected series in ",e(()=>e(Dr,{className:"vm-link vm-link_underlined vm-link_colored",to:K.rawQuery,children:"Raw Query"}),{})," tab."]})]})]}),p&&e(te,{variant:"error",children:p}),e("div",{className:"vm-download-report__buttons",children:[e(O,{variant:"text",onClick:L,children:"Help"}),e("div",{ref:N,children:e(O,{onClick:B,disabled:y,children:y?"Loading data...":"Generate Report"})})]}),e(We,{open:k,buttonRef:S[A],placement:"top-left",variant:"dark",onClose:$,children:e("div",{className:"vm-download-report-helper",children:[e("div",{className:"vm-download-report-helper__description",children:Dd[A]}),e("div",{className:"vm-download-report-helper__buttons",children:[A!==0&&e(O,{onClick:ae(-1),size:"small",color:"white",children:"Prev"}),e(O,{onClick:A===S.length-1?$:ae(1),size:"small",color:"white",variant:"text",children:A===S.length-1?"Close":"Next"})]})]})})]})})]})},fo=()=>{const{isEmptyHistogram:t}=Oe(),{handleChange:r}=mo();return t?e(te,{variant:"warning",children:e("div",{className:"vm-warning-heatmap-to-line",children:[e("p",{className:"vm-warning-heatmap-to-line__text",children:'The expression cannot be displayed as a heatmap. To make the graph work, disable the heatmap in the "Graph settings" or modify the expression.'}),e(O,{size:"small",color:"primary",variant:"text",onClick:()=>r(!1),children:"Switch to line chart"})]})}):null},go=({title:t,downloadFormatOptions:r,onDownload:n})=>{const{value:a,setTrue:s,setFalse:o}=de(!1),i=Z(null),l=Y(()=>{if(a){o();return}r&&r.length>0?s():(n(),o())},[n,o,a,s]),c=Y(d=>r?.includes(d),[r]),m=Y(d=>{const h=d.currentTarget.textContent;h&&c(h)?n(h):n(),o()},[n]);return e(q,{children:[e("div",{ref:i,children:e(G,{title:t,children:e(O,{variant:"text",startIcon:e(On,{}),onClick:l,ariaLabel:t})})}),r&&r.length>0&&e(We,{open:a,onClose:o,buttonRef:i,placement:"bottom-right",children:r.map(d=>e("div",{className:"vm-download-button__format-option",children:e(O,{variant:"text",onClick:m,className:"vm-download-button__format-option-button",children:d})},d))})]})},zd=t=>t.includes(",")||t.includes(`
`)||t.includes('"')?'"'+t.replace(/"/g,'""')+'"':t,Fd=t=>nr(t).map(({key:r})=>r).join(","),Vd=(t,r)=>t?.map(n=>r.map(a=>zd(n.metric[a.key]||"-")).join(",")),Ud=t=>{const r=Fd(t);if(!r.length)return"";const n=Vd(t,nr(t));return[r,...n].join(`
`)},qd=()=>{Hs();const{isMobile:t}=W(),{displayType:r}=$e(),{query:n}=Pe(),{customStep:a}=Oe(),s=rt(),[o,i]=b([]),[l,c]=b(!n[0]),[m,d]=b(!1),u=Z(null),{fetchUrl:h,isLoading:p,liveData:v,graphData:y,error:f,queryErrors:g,setQueryErrors:_,queryStats:C,warning:w,traces:N,isHistogram:S,abortFetch:A}=Bn({visible:!0,customStep:a,hideQuery:o,showAllSeries:m}),T=D(()=>{const $=V=>`vmui_export_${n.join("_")}.${V}`;return{csv:async()=>{if(!v)return;const V=Ud(v);qs(V,$("csv"))},json:async()=>{jr(JSON.stringify(v),$("json"))}}},[v,n]),E=Y($=>{$&&T[$]()},[T]),M=!v?.length&&r!==pe.chart,I=!l&&f,k=Y($=>{i($)},[]),L=Y(()=>{c(!1)},[]);return x(()=>{s({type:"SET_IS_HISTOGRAM",payload:S})},[S]),e("div",{className:R({"vm-custom-panel":!0,"vm-custom-panel_mobile":t}),children:[e(Ps,{queryErrors:l?void 0:g,setQueryErrors:_,setHideError:c,stats:C,isLoading:p,onHideQuery:k,onRunQuery:L,abortFetch:A,hideButtons:{reduceMemUsage:!0}}),e(Mc,{traces:N,displayType:r}),I&&e(te,{variant:"error",children:f}),M&&e(te,{variant:"info",children:e(kc,{})}),e(fo,{}),w&&e(jn,{warning:w,query:n,onChange:d}),e("div",{className:R({"vm-custom-panel-body":!0,"vm-custom-panel-body_mobile":t,"vm-block":!0,"vm-block_mobile":t}),children:[p&&e(Os,{}),e("div",{className:"vm-custom-panel-body-header",ref:u,children:[e("div",{className:"vm-custom-panel-body-header__tabs",children:e(Ns,{})}),r==="table"&&e(go,{title:"Export query",onDownload:E,downloadFormatOptions:["json","csv"]}),(y||v)&&r!=="code"&&e(Hd,{fetchUrl:h})]}),e(po,{graphData:y,liveData:v,isHistogram:S,displayType:r,controlsRef:u})]})]})},Se=({containerStyles:t,message:r})=>{const{isDarkTheme:n}=ne();return e("div",{className:R({"vm-spinner":!0,"vm-spinner_dark":n}),style:t,children:[e("div",{className:"half-circle-spinner",children:[e("div",{className:"circle circle-1"}),e("div",{className:"circle circle-2"})]}),r&&e("div",{className:"vm-spinner__message",children:r})]})},Bd=({title:t,description:r,unit:n,expr:a,showLegend:s,filename:o,alias:i})=>{const{isMobile:l}=W(),{period:c}=he(),{customStep:m}=Oe(),d=Ge(),u=Z(null),[h,p]=b(!1),[v,y]=b(!1),[f,g]=b(!1),[_,C]=b({limits:{enable:!1,range:{1:[0,0]}}}),w=D(()=>Array.isArray(a)&&a.every(L=>L),[a]),{isLoading:N,graphData:S,error:A,warning:T}=Bn({predefinedQuery:w?a:[],display:pe.chart,visible:h,customStep:m}),E=L=>{const $={..._};$.limits.range=L,C($)},M=()=>{const L={..._};L.limits.enable=!L.limits.enable,C(L)},I=({from:L,to:$})=>{d({type:"SET_PERIOD",payload:{from:L,to:$}})};return x(()=>{const L=new IntersectionObserver($=>{$.forEach(V=>p(V.isIntersecting))},{threshold:.1});return u.current&&L.observe(u.current),()=>{u.current&&L.unobserve(u.current)}},[u]),w?e("div",{className:"vm-predefined-panel",ref:u,children:[e("div",{className:"vm-predefined-panel-header",children:[e(G,{title:e(()=>e("div",{className:"vm-predefined-panel-header__description vm-default-styles",children:[r&&e(q,{children:[e("div",{children:[e("span",{children:"Description:"}),e("div",{dangerouslySetInnerHTML:{__html:Ir(r)}})]}),e("hr",{})]}),e("div",{children:[e("span",{children:"Queries:"}),e("div",{children:a.map((L,$)=>e("div",{children:L},`${$}_${L}`))})]})]}),{}),children:e("div",{className:"vm-predefined-panel-header__info",children:e(lt,{})})}),e("h3",{className:"vm-predefined-panel-header__title",children:t||""}),e(Kn,{data:S||[],yaxis:_,setYaxisLimits:E,toggleEnableLimits:M,spanGaps:{value:v,onChange:y},showAllPoints:{value:f,onChange:g}})]}),e("div",{className:"vm-predefined-panel-body",children:[N&&e(Se,{}),A&&e(te,{variant:"error",children:A}),T&&e(te,{variant:"warning",children:T}),S&&e(Gr,{isPredefinedPanel:!0,data:S,period:c,customStep:m,query:a,yaxis:_,unit:n,alias:i,showLegend:s,setYaxisLimits:E,setPeriod:I,fullWidth:!1,height:l?window.innerHeight*.5:500,spanGaps:v,showAllPoints:f})]})]}):e(te,{variant:"error",children:[e("code",{children:'"expr"'})," not found. Check the configuration file ",e("b",{children:o}),"."]})},Qd=({index:t,title:r,panels:n,filename:a})=>{const s=Ct(),o=D(()=>s.width/12,[s]),[i,l]=b(!t),[c,m]=b([]);x(()=>{m(n&&n.map(_=>_.width||12))},[n]);const[d,u]=b({start:0,target:0,enable:!1}),h=Y(_=>{if(!d.enable)return;const{start:C}=d,w=Math.ceil((C-_.clientX)/o);if(Math.abs(w)>=12)return;const N=c.map((S,A)=>S-(A===d.target?w:0));m(N)},[d,o]),p=(_,C)=>{u({start:_.clientX,target:C,enable:!0})},v=Y(()=>{u({...d,enable:!1})},[d]),y=_=>l(_),f=_=>C=>{p(C,_)};return oe("mousemove",h),oe("mouseup",v),e("div",{className:"vm-predefined-dashboard",children:e(Nt,{defaultExpanded:i,onChange:y,title:e(()=>e("div",{className:R({"vm-predefined-dashboard-header":!0,"vm-predefined-dashboard-header_open":i}),children:[(r||a)&&e("span",{className:"vm-predefined-dashboard-header__title",children:r||`${t+1}. ${a}`}),n&&e("span",{className:"vm-predefined-dashboard-header__count",children:["(",n.length," panels)"]})]}),{}),children:e("div",{className:"vm-predefined-dashboard-panels",children:Array.isArray(n)&&n.length?n.map((_,C)=>e("div",{className:"vm-predefined-dashboard-panels-panel vm-block vm-block_empty-padding",style:{gridColumn:`span ${c[C]}`},children:[e(Bd,{title:_.title,description:_.description,unit:_.unit,expr:_.expr,alias:_.alias,filename:a,showLegend:_.showLegend}),e("button",{className:"vm-predefined-dashboard-panels-panel__resizer",onMouseDown:f(C),"aria-label":"resize the panel"})]},C)):e("div",{className:"vm-predefined-dashboard-panels-panel__alert",children:e(te,{variant:"error",children:[e("code",{children:'"panels"'})," not found. Check the configuration file ",e("b",{children:a}),"."]})})})})})},jd=()=>{const{duration:t,relativeTime:r,period:{date:n}}=he(),{customStep:a}=Oe(),{setSearchParamsFromKeys:s}=nt(),o=()=>{const i=Yr({"g0.range_input":t,"g0.end_input":n,"g0.step_input":a,"g0.relative_time":r});s(i)};x(o,[t,r,n,a]),x(o,[])},Yd=()=>{jd();const{isMobile:t}=W(),{dashboardsSettings:r,dashboardsLoading:n,dashboardsError:a}=Ss(),[s,o]=b(0),i=D(()=>r.map((p,v)=>({label:p.title||"",value:v})),[r]),l=D(()=>r[s]||{},[r,s]),c=D(()=>l?.rows,[l]),m=D(()=>l.title||l.filename||"",[l]),d=D(()=>Array.isArray(c)&&!!c.length,[c]),u=p=>{o(p)},h=p=>()=>{u(p)};return e("div",{className:"vm-predefined-panels",children:[n&&e(Se,{}),!r.length&&a&&e(te,{variant:"error",children:a}),!r.length&&e(te,{variant:"info",children:"Dashboards not found"}),i.length>1&&e("div",{className:R({"vm-predefined-panels-tabs":!0,"vm-predefined-panels-tabs_mobile":t}),children:i.map(p=>e("div",{className:R({"vm-predefined-panels-tabs__tab":!0,"vm-predefined-panels-tabs__tab_active":p.value==s}),onClick:h(p.value),children:p.label},p.value))}),e("div",{className:"vm-predefined-panels__dashboards",children:[d&&c.map((p,v)=>e(Qd,{index:v,filename:m,title:p.title,panels:p.panels},`${s}_${v}`)),!!r.length&&!d&&e(te,{variant:"error",children:[e("code",{children:'"rows"'})," not found. Check the configuration file ",e("b",{children:m}),"."]})]})]})},an=(t,r)=>{const n=r.match?"&match[]="+encodeURIComponent(r.match):"",a=r.focusLabel?"&focusLabel="+encodeURIComponent(r.focusLabel):"";return`${t}/api/v1/status/tsdb?topN=${r.topN}&date=${r.date}${n}${a}`},Gd=(t,r)=>{const n=new URLSearchParams(Object.entries(r).filter(([a,s])=>s!=null)).toString();return`${t}/api/v1/status/metric_names_stats?${n}`},ar={id:"action",label:"",modifiers:["action"]},sr={id:"diff",label:"1d",info:"Shows the absolute difference compared to the previous day.",sortable:!0,modifiers:["compact"]},or={id:"diffPercent",label:"1d %",info:"Shows the percentage difference compared to the previous day.",sortable:!0,modifiers:["compact"]},Wr={id:"value",label:"Number of series",sortable:!0,modifiers:["compact"]},Wd=[{id:"name",label:"Metric name",sortable:!0},Wr,{id:"requestsCount",label:"Requests count",sortable:!0,modifiers:["compact"],info:"The number of times this metric was queried since stats collection began."},{id:"lastRequestTimestamp",label:"Last request",sortable:!0,modifiers:["compact"],info:"The last time this metric was used in a query since stats collection began."},sr,or,{id:"percentage",label:"Share in total",info:"Shows the share of a metric to the total number of series"},ar],Kd=[{id:"name",label:"Label name",sortable:!0},Wr,sr,or,{id:"percentage",label:"Share in total",info:"Shows the share of the label to the total number of series"},ar],Jd=[{id:"name",label:"Label value",sortable:!0},Wr,sr,or,{id:"percentage",label:"Share in total"},ar],Zd=[{id:"name",label:"Label=value pair",sortable:!0},Wr,sr,or,{id:"percentage",label:"Share in total",info:"Shows the share of the label value pair to the total number of series"},ar],Xd=[{id:"name",label:"Label name",sortable:!0},{id:"value",label:"Number of unique values",sortable:!0,modifiers:["compact"]},sr,or,ar];class em{tsdbStatus;metricNameStats;tabsNames;isPrometheus;constructor(){this.tsdbStatus=this.defaultTSDBStatus,this.metricNameStats=this.defaultMetricNameStats,this.tabsNames=["table","graph"],this.isPrometheus=!1,this.getDefaultState=this.getDefaultState.bind(this)}set tsdbStatusData(r){this.isPrometheus=!!r?.headStats,this.tsdbStatus=r}set metricNameStatsData(r){this.metricNameStats=r}get tsdbStatusData(){return this.tsdbStatus}get metricNameStatsData(){return this.metricNameStats}get defaultTSDBStatus(){return{totalSeries:0,totalSeriesPrev:0,totalSeriesByAll:0,totalLabelValuePairs:0,seriesCountByMetricName:[],seriesCountByLabelName:[],seriesCountByFocusLabelValue:[],seriesCountByLabelValuePair:[],labelValueCountByLabelName:[]}}get defaultMetricNameStats(){return{statsCollectedSince:0,statsCollectedRecordsTotal:0,trackerMemoryMaxSizeBytes:0,trackerCurrentMemoryUsageBytes:0}}get isPrometheusData(){return this.isPrometheus}keys(r,n){const a=r&&/__name__=".+"/.test(r),s=r&&/{.+=".+"}/g.test(r),o=r&&/__name__=".+", .+!=""/g.test(r);let i=[];return n||o?i=i.concat("seriesCountByFocusLabelValue"):a?i=i.concat("labelValueCountByLabelName"):s?i=i.concat("seriesCountByMetricName","seriesCountByLabelName"):i=i.concat("seriesCountByMetricName","seriesCountByLabelName","seriesCountByLabelValuePair","labelValueCountByLabelName"),i}getDefaultState(r,n){return this.keys(r,n).reduce((a,s)=>({...a,tabs:{...a.tabs,[s]:this.tabsNames},containerRefs:{...a.containerRefs,[s]:Z(null)}}),{tabs:{},containerRefs:{}})}sectionsTitles(r){return{seriesCountByMetricName:"Metric names with the highest number of series",seriesCountByLabelName:"Labels with the highest number of series",seriesCountByFocusLabelValue:`Values for "${r}" label with the highest number of series`,seriesCountByLabelValuePair:"Label=value pairs with the highest number of series",labelValueCountByLabelName:"Labels with the highest number of unique values"}}get sectionsTips(){return{seriesCountByMetricName:`
<p>
This table returns a list of metrics with the highest cardinality.
The cardinality of a metric is the number of time series associated with that metric,
where each time series is defined as a unique combination of key-value label pairs.
</p>
<p>
When looking to reduce the number of active series in your data source,
you can start by inspecting individual metrics with high cardinality
(i.e. that have lots of active time series associated with them),
since that single metric contributes a large fraction of the series that make up your total series count.
</p>`,seriesCountByLabelName:`
<p>
This table returns a list of the labels with the highest number of series.
</p>
<p>
Use this table to identify labels that are storing dimensions with high cardinality
(many different label values).
</p>
<p>
It is recommended to choose labels such that they have a finite set of values,
since every unique combination of key-value label pairs creates a new time series
and therefore can dramatically increase the number of time series in your system.
</p>`,seriesCountByFocusLabelValue:`
<p>
This table returns a list of unique label values per selected label.
</p>
<p>
Use this table to identify label values that are storing per each selected series.
</p>`,labelValueCountByLabelName:`
<p>
This table returns a list of labels with the highest number of the unique values.
</p>
`,seriesCountByLabelValuePair:`
<p>
This table returns a list of the label values pairs with the highest number of series.
</p>
<p>
Use this table to identify unique label values pairs. This helps to identify same labels
is applied to count timeseries in your system, since every unique combination of key-value label pairs
creates a new time series and therefore can dramatically increase the number of time series in your system
</p>`}}get tablesHeaders(){return{seriesCountByMetricName:Wd,seriesCountByLabelName:Kd,seriesCountByFocusLabelValue:Jd,seriesCountByLabelValuePair:Zd,labelValueCountByLabelName:Xd}}totalSeries(r,n=!1){return r==="labelValueCountByLabelName"?-1:n?this.tsdbStatus.totalSeriesPrev:this.tsdbStatus.totalSeries}}const tm=()=>{const t=new em,[r]=me(),n=r.get("match"),a=r.get("focusLabel"),s=+(r.get("topN")||10),o=r.get("date")||Q().tz().format(it),i=Gt(o),l=Z(),{tenantId:c,serverUrl:m}=ne(),[d,u]=b(!1),[h,p]=b(),[v,y]=b(t.defaultTSDBStatus),[f,g]=b(t.defaultMetricNameStats),[_,C]=b(!1),w=async T=>{const E=await fetch(T),M=await E.json();if(E.ok)return M;console.error(`Error fetching ${T}:`,M);const I=M.errorType||ge.unknownType,k=M?.error||M?.message||"see console for more details",L=[I,k].join(`\r
`);throw new Error(L)},N=(T,E)=>{Object.keys(T).forEach(M=>{const I=M,k=T[I],L=E[I];Array.isArray(k)&&Array.isArray(L)&&k.forEach($=>{const V=L.find(j=>j.name===$.name)?.value,H=V?$.value-V:0,z=V?H/V*100:0;$.diff=H,$.diffPercent=z,$.valuePrev=V||0})})},S=async T=>{if(!m)return;p(""),u(!0),y(t.defaultTSDBStatus);const E={...T,date:T.date,topN:0,match:"",focusLabel:""},M={...T,date:Q(T.date).subtract(1,"day").format(it)},I=[an(m,T),an(m,M)];i!==o&&(T.match||T.focusLabel)&&I.push(an(m,E));try{const[k,L,$]=await Promise.all(I.map(w)),V={...L.data},{data:H}=$||l.current||k;l.current={data:H};const z={...k.data,totalSeries:k.data?.totalSeries||k.data?.headStats?.numSeries||0,totalLabelValuePairs:k.data?.totalLabelValuePairs||k.data?.headStats?.numLabelValuePairs||0,seriesCountByLabelName:k.data?.seriesCountByLabelName||[],seriesCountByFocusLabelValue:k.data?.seriesCountByFocusLabelValue||[],totalSeriesByAll:H?.totalSeries||H?.headStats?.numSeries||v.totalSeriesByAll||0,totalSeriesPrev:V?.totalSeries||V?.headStats?.numSeries||0},j=n?.replace(/[{}"]/g,"");z.seriesCountByLabelValuePair=z.seriesCountByLabelValuePair.filter(ee=>ee.name!==j),N(z,V),y(z),u(!1)}catch(k){u(!1),k instanceof Error&&p(`${k.name}: ${k.message}`)}},A=async()=>{if(!m)return;p(""),u(!0);const T=Gd(m,{limit:1});try{const E=await w(T);g(E),u(!1)}catch(E){u(!1),g(t.defaultMetricNameStats),console.error(E)}};return x(()=>{S({topN:s,match:n,date:o,focusLabel:a})},[m,n,a,s,o]),x(()=>{A()},[m]),x(()=>{h&&(y(t.defaultTSDBStatus),u(!1))},[h]),x(()=>{C(!!c)},[c]),t.tsdbStatusData=v,t.metricNameStatsData=f,{isLoading:d,appConfigurator:t,error:h,isCluster:_}},rm={seriesCountByMetricName:({query:t})=>sn("__name__",t),seriesCountByLabelName:({query:t})=>`{${t}!=""}`,seriesCountByFocusLabelValue:({query:t,focusLabel:r})=>sn(r,t),seriesCountByLabelValuePair:({query:t})=>{const r=t.split("="),n=r[0],a=r.slice(1).join("=");return sn(n,a)},labelValueCountByLabelName:({query:t,match:r})=>r===""?`{${t}!=""}`:`${r.replace("}","")}, ${t}!=""}`},sn=(t,r)=>t?"{"+t+"="+JSON.stringify(r)+"}":"",nm=({metricNameStats:t})=>{const{statsCollectedSince:r,statsCollectedRecordsTotal:n=0,trackerMemoryMaxSizeBytes:a=0,trackerCurrentMemoryUsageBytes:s=0}=t,o=r?Q.unix(r).format(qe):" - ",i=a?`${(s/a*100).toFixed(2)}%`:" - ",l=n.toLocaleString("en-US");return e("div",{className:"vm-cardinality-totals-card",children:[e("h4",{className:"vm-cardinality-totals-card__title",children:[e(G,{placement:"bottom-left",title:e("div",{className:"vm-cardinality-totals-card__tooltip",children:r?e(q,{children:[e("p",{children:["Total entries in cache since ",o]}),e("p",{children:["Cache utilization: ",i]})]}):e(q,{children:[e("p",{children:"Metric names tracker is likely disabled."}),e("p",{children:"No data available. See documentation for enabling the metric names tracker."})]})}),children:e("div",{className:"vm-cardinality-totals-card__info-icon",children:e(Xt,{})})}),"Total metric names"]}),e("span",{className:"vm-cardinality-totals-card__value",children:l}),e("span",{className:"vm-cardinality-totals-card__link",children:e(Ce,{href:"https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#track-ingested-metrics-usage",children:"Docs ↗"})})]})},am=({totalSeries:t=0,totalSeriesPrev:r=0,totalSeriesAll:n=0,metricNameStats:a,isPrometheus:s})=>{const{isMobile:o}=W(),[i]=me(),l=i.get("match"),c=i.get("focusLabel"),m=/__name__/.test(l||""),d=t/n*100,u=t-r,h=Math.abs(u)/r*100,p=[{title:"Total series",value:t.toLocaleString("en-US"),dynamic:!t||!r||s?"":`${h.toFixed(2)}%`,display:!c,info:`The total number of unique time series for a selected day.
A time series is uniquely identified by its name plus a set of its labels.
For example, temperature{city="NY",country="US"} and temperature{city="SF",country="US"}
are two distinct series, since they differ by the "city" label.`},{title:"Percentage from total",value:isNaN(d)?"-":`${d.toFixed(2)}%`,display:m,info:"The share of these series in the total number of time series."}].filter(v=>v.display);return p.length?e("div",{className:R({"vm-cardinality-totals":!0,"vm-cardinality-totals_mobile":o}),children:[p.map(({title:v,value:y,info:f,dynamic:g})=>e("div",{className:"vm-cardinality-totals-card",children:[e("h4",{className:"vm-cardinality-totals-card__title",children:[f&&e(G,{title:e("p",{className:"vm-cardinality-totals-card__tooltip",children:f}),children:e("div",{className:"vm-cardinality-totals-card__info-icon",children:e(Xt,{})})}),v]}),e("span",{className:"vm-cardinality-totals-card__value",children:y}),!!g&&e(G,{title:`in relation to the previous day: ${r.toLocaleString("en-US")}`,placement:"bottom-left",children:e("span",{className:R({"vm-dynamic-number":!0,"vm-dynamic-number_positive vm-dynamic-number_down":u<0,"vm-dynamic-number_negative vm-dynamic-number_up":u>0}),children:g})})]},v)),e(nm,{metricNameStats:a})]}):null},pt=(t,r)=>{const[n]=me(),a=n.get(r)?n.get(r):t,[s,o]=b(a);return x(()=>{a!==s&&o(a)},[a]),[s,o]},Vt=10,sm=({isPrometheus:t,isCluster:r,...n})=>{const{isMobile:a}=W(),[s]=me(),{setSearchParamsFromKeys:o}=nt(),i=s.get("tips")||"",[l,c]=pt("","match"),[m,d]=pt("","focusLabel"),[u,h]=pt(Vt,"topN"),p=!!(l||m||u!==Vt&&!t),v=D(()=>u<0?"Number must be bigger than zero":"",[u]),y=C=>{const w=+C;h(isNaN(w)?0:w)},f=()=>{o({match:l,topN:u,focusLabel:m})},g=()=>{o({match:"",focusLabel:"",topN:""}),c(""),d(""),h(Vt)},_=()=>{const C=s.get("tips")||"";o({tips:C?"":"true"})};return x(()=>{const C=s.get("match"),w=+(s.get("topN")||Vt),N=s.get("focusLabel");C!==l&&c(C||""),w!==u&&h(w),N!==m&&d(N||"")},[s]),e("div",{className:R({"vm-cardinality-configurator":!0,"vm-cardinality-configurator_mobile":a,"vm-block":!0,"vm-block_mobile":a}),children:[e("div",{className:"vm-cardinality-configurator-controls",children:[e("div",{className:"vm-cardinality-configurator-controls__query",children:e(ie,{label:"Time series selector",type:"string",value:l,onChange:c,onEnter:f})}),e("div",{className:"vm-cardinality-configurator-controls__item",children:e(ie,{label:"Focus label",type:"text",value:m||"",onChange:d,onEnter:f,endIcon:e(G,{title:e("div",{children:e("p",{children:"To identify values with the highest number of series for the selected label."})}),children:e(cs,{})})})}),e("div",{className:"vm-cardinality-configurator-controls__item vm-cardinality-configurator-controls__item_limit",children:e(ie,{label:"Limit entries",type:"number",value:t?Vt:u,error:v,disabled:t,helperText:t?"not available for Prometheus":"",onChange:y,onEnter:f})})]}),e("div",{className:"vm-cardinality-configurator-bottom",children:[e(am,{isPrometheus:t,isCluster:r,...n}),r&&e("div",{className:"vm-cardinality-configurator-bottom-helpful",children:e(Ce,{href:"https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#cardinality-explorer-statistic-inaccuracy",withIcon:!0,children:[e(gt,{}),"Statistic inaccuracy explanation"]})}),e("div",{className:"vm-cardinality-configurator-bottom-helpful",children:e(Ce,{href:"https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#cardinality-explorer",withIcon:!0,children:[e(gt,{}),"Documentation"]})}),e("div",{className:"vm-cardinality-configurator-bottom__execute",children:[e(G,{title:i?"Hide tips":"Show tips",children:e(O,{variant:"text",color:i?"warning":"gray",startIcon:e(tr,{}),onClick:_,ariaLabel:"visibility tips"})}),e(O,{variant:"text",startIcon:e(ft,{}),onClick:g,disabled:!p,children:"Reset filters"}),e(O,{startIcon:e(dt,{}),onClick:f,children:"Execute Query"})]})]})]})};function om(t){const{order:r,orderBy:n,onRequestSort:a,headerCells:s}=t,o=i=>l=>{a(l,i)};return e("thead",{className:"vm-table-header vm-cardinality-panel-table__header",children:e("tr",{className:"vm-table__row vm-table__row_header",children:s.map(i=>e("th",{className:R({"vm-table-cell vm-table-cell_header":!0,"vm-table-cell_sort":i.sortable,"vm-table-cell_right":i.id==="action"}),onClick:i.sortable?o(i.id):void 0,children:e("div",{className:"vm-table-cell__content",children:[i.info&&e(G,{title:i.info,children:e("div",{className:"vm-metrics-content-header__tip-icon",children:e(Xt,{})})}),i.label,i.sortable&&e("div",{className:R({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":n===i.id,"vm-table__sort-icon_desc":r==="desc"&&n===i.id}),children:e(Xe,{})})]})},i.id))})})}const im=["date","timestamp","time"];function Sa(t,r,n){const a=t[n],s=r[n];if(a==null&&s==null)return 0;if(a==null)return 1;if(s==null)return-1;const o=String(a),i=String(s);if(im.includes(String(n))){const u=ia(o),h=ia(i);return h<u?-1:h>u?1:0}const c=Number(o),m=Number(i);return!isNaN(c)&&!isNaN(m)?m-c:i<o?-1:i>o?1:0}function Zn(t,r){return t==="desc"?(n,a)=>Sa(n,a,r):(n,a)=>-Sa(n,a,r)}function Xn(t,r){const n=t.map((a,s)=>[a,s]);return n.sort((a,s)=>{const o=r(a[0],s[0]);return o!==0?o:a[1]-s[1]}),n.map(a=>a[0])}const lm=({rows:t,headerCells:r,defaultSortColumn:n,tableCells:a})=>{const[s,o]=b("desc"),[i,l]=b(n),c=(d,u)=>{o(i===u&&s==="asc"?"desc":"asc"),l(u)},m=Xn(t,Zn(s,i));return e("table",{className:"vm-table vm-cardinality-panel-table",children:[e(om,{order:s,orderBy:i,onRequestSort:c,rowCount:t.length,headerCells:r}),e("tbody",{className:"vm-table-header",children:m.map(d=>e("tr",{className:"vm-table__row",children:a(d)},d.name))})]})},cm=({row:t,tableHeaderCells:r,totalSeries:n,totalSeriesPrev:a,onActionClick:s})=>{const o=n>0?t.value/n*100:-1,i=a>0?t.valuePrev/a*100:-1,l=[o,i].some(M=>M===-1),c=t.value.toLocaleString("en-US"),m=t.valuePrev.toLocaleString("en-US"),d=Math.abs(t.diff).toLocaleString("en-US"),u=o-i,h=l?"":`${Math.abs(u).toFixed(2)}%`,p=`${Math.abs(t.diffPercent).toFixed(2)}%`,v=t.requestsCount===0,f=t.requestsCount==null?"n/a":t.requestsCount.toLocaleString("en-US"),g=t.lastRequestTimestamp===0,_=t.lastRequestTimestamp==null,C=!g&&!_,w=g?"never":"n/a",N=C?Q().diff(t.lastRequestTimestamp*1e3,"seconds"):0,S=C?Q.unix(t.lastRequestTimestamp).format(qe):"-",A=C?Q.duration(-N,"seconds").humanize(!0):w,T=()=>{s(t.name)},E=M=>{switch(M.id){case"name":return e("span",{className:"vm-link vm-link_colored",onClick:T,children:t.name});case"value":return c;case"requestsCount":return e("div",{className:R({"vm-dynamic-number":!0,"vm-dynamic-number_negative":v}),children:f});case"lastRequestTimestamp":return e(G,{title:`${S}`,children:e("span",{className:R({"vm-dynamic-number":!0,"vm-dynamic-number_negative":g||N>=30*86400,"vm-dynamic-number_warning":N>=7*86400&&N<30*86400}),children:A})});case"diff":return e(G,{title:`in relation to the previous day: ${m}`,children:e("span",{className:R({"vm-dynamic-number":!0,"vm-dynamic-number_positive vm-dynamic-number_down":t.diff<0,"vm-dynamic-number_negative vm-dynamic-number_up":t.diff>0}),children:d})});case"diffPercent":return e(G,{title:`in relation to the previous day: ${m}`,children:e("div",{className:R({"vm-dynamic-number":!0,"vm-dynamic-number_positive vm-dynamic-number_down":t.diff<0,"vm-dynamic-number_negative vm-dynamic-number_up":t.diff>0}),children:p})});case"percentage":return e("div",{className:"vm-cardinality-panel-table__progress",children:[e(zs,{value:o,hideValue:!0}),e("span",{className:"vm-dynamic-number vm-dynamic-number_static",children:[o.toFixed(2),"%"]}),e(G,{title:"in relation to the previous day",children:e("span",{className:R({"vm-dynamic-number":!0,"vm-dynamic-number_no-change":u===0,"vm-dynamic-number_positive vm-dynamic-number_down":u<0,"vm-dynamic-number_negative vm-dynamic-number_up":u>0}),children:h})})]});case"action":return e("div",{className:"vm-table-cell__content",children:e(G,{title:e("span",{children:["Filter by ",e("code",{children:["`",t.name,"`"]})]}),children:e(O,{variant:"text",size:"small",onClick:T,startIcon:e(zr,{})})})});default:return M.id in t?t[M.id]:""}};return e(q,{children:r.map(M=>e("td",{className:R("vm-table-cell",...M.modifiers?.map(I=>`vm-table-cell_${I}`)??[]),children:E(M)},M.id))})},dm=({data:t})=>{const[r,n]=b([]),[a,s]=b([0,0]),o=i=>{const l=i.map(u=>u.value),c=Math.ceil(l[0]||1),m=10,d=c/(m-1);return new Array(m+1).fill(c+d).map((u,h)=>Math.round(u-d*h))};return x(()=>{const i=t.sort((c,m)=>m.value-c.value),l=o(i);s(l),n(i.map(c=>({...c,percentage:c.value/l[0]*100})))},[t]),e("div",{className:"vm-simple-bar-chart",children:[e("div",{className:"vm-simple-bar-chart-y-axis",children:a.map(i=>e("div",{className:"vm-simple-bar-chart-y-axis__tick",children:i},i))}),e("div",{className:"vm-simple-bar-chart-data",children:r.map(({name:i,value:l,percentage:c})=>e(G,{title:`${i}: ${l}`,placement:"top-center",children:e("div",{className:"vm-simple-bar-chart-data-item",style:{maxHeight:`${c||0}%`}})},`${i}_${l}`))})]})},mm=({rows:t,tabs:r=[],chartContainer:n,totalSeries:a,totalSeriesPrev:s,onActionClick:o,sectionTitle:i,tip:l,tableHeaderCells:c,isPrometheus:m})=>{const{isMobile:d}=W(),[u,h]=b("table"),p=m&&!t.length,v=f=>e(cm,{row:f,tableHeaderCells:c,totalSeries:a,totalSeriesPrev:s,onActionClick:o}),y=D(()=>r.map((f,g)=>({value:f,label:f,icon:g===0?e(Fr,{}):e(In,{})})),[r]);return e("div",{className:R({"vm-metrics-content":!0,"vm-metrics-content_mobile":d,"vm-block":!0,"vm-block_mobile":d}),children:[e("div",{className:"vm-metrics-content-header vm-section-header",children:[e("h5",{className:R({"vm-metrics-content-header__title":!0,"vm-section-header__title":!0,"vm-section-header__title_mobile":d}),children:[!d&&l&&e(G,{title:e("p",{dangerouslySetInnerHTML:{__html:l},className:"vm-metrics-content-header__tip"}),children:e("div",{className:"vm-metrics-content-header__tip-icon",children:e(Xt,{})})}),i]}),e("div",{className:"vm-section-header__tabs",children:e(rr,{activeItem:u,items:y,onChange:h})})]}),p&&e("div",{className:"vm-metrics-content-prom-data",children:[e("div",{className:"vm-metrics-content-prom-data__icon",children:e(lt,{})}),e("h3",{className:"vm-metrics-content-prom-data__title",children:"Prometheus Data Limitation"}),e("p",{className:"vm-metrics-content-prom-data__text",children:["Due to missing data from your Prometheus source, some tables may appear empty.",e("br",{}),"This does not indicate an issue with your system or our tool."]})]}),!p&&u==="table"&&e("div",{ref:n,className:R({"vm-metrics-content__table":!0,"vm-metrics-content__table_mobile":d}),children:e(lm,{rows:t,headerCells:c,defaultSortColumn:"value",tableCells:v})}),!p&&u==="graph"&&e("div",{className:"vm-metrics-content__chart",children:e(dm,{data:t.map(({name:f,value:g})=>({name:f,value:g}))})})]})},Kr=({title:t,children:r})=>e("div",{className:"vm-cardinality-tip",children:[e("div",{className:"vm-cardinality-tip-header",children:[e("div",{className:"vm-cardinality-tip-header__tip-icon",children:e(tr,{})}),e("h4",{className:"vm-cardinality-tip-header__title",children:t||"Tips"})]}),e("p",{className:"vm-cardinality-tip__description",children:r})]}),um=()=>e(Kr,{title:"Metrics with a high number of series",children:e("ul",{children:[e("li",{children:["Identify and eliminate labels with frequently changed values to reduce their ",e(Ce,{href:"https://docs.victoriametrics.com/victoriametrics/faq/#what-is-high-cardinality",children:"cardinality"})," and ",e(Ce,{href:"https://docs.victoriametrics.com/victoriametrics/faq/#what-is-high-churn-rate",children:"high churn rate"})]}),e("li",{children:["Find unused time series and ",e(Ce,{href:"https://docs.victoriametrics.com/victoriametrics/relabeling/",children:"drop entire metrics"})]}),e("li",{children:["Aggregate time series before they got ingested into the database via ",e(Ce,{href:"https://docs.victoriametrics.com/victoriametrics/stream-aggregation/",children:"streaming aggregation"})]})]})}),hm=()=>e(Kr,{title:"Labels with a high number of unique values",children:e("ul",{children:[e("li",{children:"Decrease the number of unique label values to reduce cardinality"}),e("li",{children:["Drop the label entirely via ",e(Ce,{href:"https://docs.victoriametrics.com/victoriametrics/relabeling/",children:"relabeling"})]}),e("li",{children:"For volatile label values (such as URL path, user session, etc.) consider printing them to the log file instead of adding to time series"})]})}),pm=()=>e(Kr,{title:"Dashboard of a single metric",children:[e("p",{children:"This dashboard helps to understand the cardinality of a single metric."}),e("p",{children:"Each time series is a unique combination of key-value label pairs. Therefore a label key with many values can create a lot of time series for a particular metric. If you’re trying to decrease the cardinality of a metric, start by looking at the labels with the highest number of values."}),e("p",{children:"Use the series selector at the top of the page to apply additional filters."})]}),vm=()=>e(Kr,{title:"Dashboard of a label",children:[e("p",{children:"This dashboard helps you understand the count of time series per label."}),e("p",{children:"Use the selector at the top of the page to pick a label name you’d like to inspect. For the selected label name, you’ll see the label values that have the highest number of series associated with them. So if you’ve chosen `instance` as your label name, you may see that `657` time series have value “host-1” attached to them and `580` time series have value `host-2` attached to them."}),e("p",{children:"This can be helpful in allowing you to determine where the bulk of your time series are coming from. If the label “instance=host-1” was applied to 657 series and the label “instance=host-2” was only applied to 580 series, you’d know, for example, that host-01 was responsible for sending the majority of the time series."})]}),fm=`Please wait while cardinality stats is calculated.
This may take some time if the db contains big number of time series.`,gm=()=>{const{isMobile:t}=W(),[r]=me(),{setSearchParamsFromKeys:n}=nt(),a=r.get("tips")||"",s=r.get("match")||"",o=r.get("focusLabel")||"",{isLoading:i,appConfigurator:l,error:c,isCluster:m}=tm(),{tsdbStatusData:d,metricNameStatsData:u,getDefaultState:h,tablesHeaders:p,sectionsTips:v}=l,y=h(s,o),f=g=>_=>{const w={match:rm[g]({query:_,focusLabel:o,match:s})};(g==="labelValueCountByLabelName"||g=="seriesCountByLabelName")&&(w.focusLabel=_),g=="seriesCountByFocusLabelValue"&&(w.focusLabel=""),n(w)};return e("div",{className:R({"vm-cardinality-panel":!0,"vm-cardinality-panel_mobile":t}),children:[i&&e(Se,{message:fm}),e(sm,{isPrometheus:l.isPrometheusData,totalSeries:d.totalSeries,totalSeriesPrev:d.totalSeriesPrev,totalSeriesAll:d.totalSeriesByAll,totalLabelValuePairs:d.totalLabelValuePairs,seriesCountByMetricName:d.seriesCountByMetricName,metricNameStats:u,isCluster:m}),a&&e("div",{className:"vm-cardinality-panel-tips",children:[!s&&!o&&e(um,{}),s&&!o&&e(pm,{}),!s&&!o&&e(hm,{}),o&&e(vm,{})]}),c&&e(te,{variant:"error",children:c}),l.keys(s,o).map(g=>e(mm,{sectionTitle:l.sectionsTitles(o)[g],tip:v[g],rows:d[g],onActionClick:f(g),tabs:y.tabs[g],chartContainer:y.containerRefs[g],totalSeriesPrev:l.totalSeries(g,!0),totalSeries:l.totalSeries(g),tableHeaderCells:p[g],isPrometheus:l.isPrometheusData},g))]})},bm=(t,r,n)=>`${t}/api/v1/status/top_queries?topN=${r||""}&maxLifetime=${n||""}`,ym=(t,r)=>{const{query:n,timeRangeSeconds:a}=t,s=[`g0.expr=${encodeURIComponent(n)}`],o=wr.find(i=>i.duration===r)?.id;return o&&s.push(`g0.relative_time=${o}`),a&&s.push(`g0.range_input=${r}`),`${K.home}?${s.join("&")}`},_m=t=>(["topByAvgDuration","topByCount","topBySumDuration","topByAvgMemoryUsage"].forEach(n=>{const a=t[n];Array.isArray(a)&&a.forEach(s=>{const o=$r(s.timeRangeSeconds*1e3);s.url=ym(s,o),s.timeRange=o})}),t),Cm=({topN:t,maxLifetime:r})=>{const{serverUrl:n}=ne(),{setSearchParamsFromKeys:a}=nt(),[s,o]=b(null),[i,l]=b(!1),[c,m]=b(),d=D(()=>bm(n,t,r),[n,t,r]);return{data:s,error:c,loading:i,fetch:async()=>{l(!0),a({topN:t,maxLifetime:r});try{const h=await fetch(d),p=await h.json();o(h.ok?_m(p):null),m(String(p.error||""))}catch(h){h instanceof Error&&h.name!=="AbortError"&&m(`${h.name}: ${h.message}`)}l(!1)}}},Nm=({rows:t,columns:r,defaultOrderBy:n})=>{const a=Ke(),[s,o]=b(n||"count"),[i,l]=b("desc"),c=D(()=>Xn(t,Zn(i,s)),[t,s,i]),m=h=>{l(p=>p==="asc"&&s===h?"desc":"asc"),o(h)},d=h=>()=>{m(h)},u=({query:h})=>async()=>{await a(h,"Query has been copied")};return e("table",{className:"vm-table",children:[e("thead",{className:"vm-table-header",children:e("tr",{className:"vm-table__row vm-table__row_header",children:[r.map(h=>e("th",{className:"vm-table-cell vm-table-cell_header vm-table-cell_sort",onClick:d(h.sortBy||h.key),children:e("div",{className:"vm-table-cell__content",children:[h.title||h.key,e("div",{className:R({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":s===h.key,"vm-table__sort-icon_desc":i==="desc"&&s===h.key}),children:e(Xe,{})})]})},h.key)),e("th",{className:"vm-table-cell vm-table-cell_header"})," "]})}),e("tbody",{className:"vm-table-body",children:c.map((h,p)=>e("tr",{className:"vm-table__row",children:[r.map(v=>e("td",{className:"vm-table-cell",children:h[v.key]||"-"},v.key)),e("td",{className:"vm-table-cell vm-table-cell_no-padding",children:e("div",{className:"vm-top-queries-panels__table-actions",children:[h.url&&e(G,{title:"Execute query",children:e(Dr,{to:h.url,target:"_blank",rel:"noreferrer","aria-disabled":!0,children:e(O,{variant:"text",size:"small",startIcon:e(zr,{}),ariaLabel:"execute query"})})}),e(G,{title:"Copy query",children:e(O,{variant:"text",size:"small",startIcon:e(_t,{}),onClick:u(h),ariaLabel:"copy query"})})]})})]},p))})]})},wm=["table","JSON"].map((t,r)=>({value:String(r),label:t,icon:r===0?e(Fr,{}):e(er,{})})),vr=({rows:t,title:r,columns:n,defaultOrderBy:a})=>{const{isMobile:s}=W(),[o,i]=b(0),l=c=>{i(+c)};return e("div",{className:R({"vm-top-queries-panel":!0,"vm-block":!0,"vm-block_mobile":s}),children:[e("div",{className:R({"vm-top-queries-panel-header":!0,"vm-section-header":!0,"vm-top-queries-panel-header_mobile":s}),children:[e("h5",{className:R({"vm-section-header__title":!0,"vm-section-header__title_mobile":s}),children:r}),e("div",{className:"vm-section-header__tabs",children:e(rr,{activeItem:String(o),items:wm,onChange:l})})]}),e("div",{className:R({"vm-top-queries-panel__table":!0,"vm-top-queries-panel__table_mobile":s}),children:[o===0&&e(Nm,{rows:t,columns:n,defaultOrderBy:a}),o===1&&e(Jn,{data:t})]})]})},Sm="30ms, 15s, 3d4h, 1y2w",Tm=()=>{const{isMobile:t}=W(),[r,n]=pt(10,"topN"),[a,s]=pt("10m","maxLifetime"),{data:o,error:i,loading:l,fetch:c}=Cm({topN:r,maxLifetime:a}),m=D(()=>{const _=a.trim().split(" ").reduce((w,N)=>{const S=qa(N);return S?{...w,...S}:{...w}},{});return!!Q.duration(_).asMilliseconds()},[a]),d=D(()=>!!r&&r<1,[r]),u=D(()=>d?"Number must be bigger than zero":"",[d]),h=D(()=>m?"":"Invalid duration value",[m]),p=g=>{if(!o)return g;const _=o[g];return typeof _=="number"?ht(_,_,_):_||g},v=g=>{n(+g)},y=g=>{s(g)},f=g=>{g.key==="Enter"&&c()};return x(()=>{o&&(r||n(+o.topN),a||s(o.maxLifetime))},[o]),x(()=>(c(),window.addEventListener("popstate",c),()=>{window.removeEventListener("popstate",c)}),[]),e("div",{className:R({"vm-top-queries":!0,"vm-top-queries_mobile":t}),children:[l&&e(Se,{containerStyles:{height:"500px"}}),e("div",{className:R({"vm-top-queries-controls":!0,"vm-block":!0,"vm-block_mobile":t}),children:[e("div",{className:"vm-top-queries-controls-fields",children:[e("div",{className:"vm-top-queries-controls-fields__item",children:e(ie,{label:"Max lifetime",value:a,error:h,helperText:`For example ${Sm}`,onChange:y,onKeyDown:f})}),e("div",{className:"vm-top-queries-controls-fields__item",children:e(ie,{label:"Number of returned queries",type:"number",value:r||"",error:u,onChange:v,onKeyDown:f})})]}),e("div",{className:R({"vm-top-queries-controls-bottom":!0,"vm-top-queries-controls-bottom_mobile":t}),children:[e("div",{className:"vm-top-queries-controls-bottom__info",children:["VictoriaMetrics tracks the last ",e(G,{title:"search.queryStats.lastQueriesCount",children:e("b",{children:p("search.queryStats.lastQueriesCount")})})," queries with durations at least ",e(G,{title:"search.queryStats.minQueryDuration",children:e("b",{children:p("search.queryStats.minQueryDuration")})})]}),e("div",{className:"vm-top-queries-controls-bottom__button",children:e(O,{startIcon:e(dt,{}),onClick:c,children:"Execute"})})]})]}),i&&e(te,{variant:"error",children:i}),o&&e(q,{children:e("div",{className:"vm-top-queries-panels",children:[e(vr,{rows:o.topBySumDuration,title:"Queries with most summary time to execute",columns:[{key:"query"},{key:"sumDurationSeconds",title:"sum duration, sec"},{key:"timeRange",sortBy:"timeRangeSeconds",title:"query time interval"},{key:"count"}],defaultOrderBy:"sumDurationSeconds"}),e(vr,{rows:o.topByAvgDuration,title:"Most heavy queries",columns:[{key:"query"},{key:"avgDurationSeconds",title:"avg duration, sec"},{key:"timeRange",sortBy:"timeRangeSeconds",title:"query time interval"},{key:"count"}],defaultOrderBy:"avgDurationSeconds"}),e(vr,{rows:o.topByCount,title:"Most frequently executed queries",columns:[{key:"query"},{key:"timeRange",sortBy:"timeRangeSeconds",title:"query time interval"},{key:"count"}]}),e(vr,{rows:o.topByAvgMemoryUsage,title:"Queries with most memory to execute",columns:[{key:"query"},{key:"avgMemoryBytes",title:"avg memory usage, bytes"},{key:"timeRange",sortBy:"timeRangeSeconds",title:"query time interval"},{key:"count"}],defaultOrderBy:"avgMemoryBytes"})]})})]})},on={"color-primary":"#589df6","color-secondary":"#316eca","color-error":"#e5534b","color-background-error":"#240705","color-warning":"#c69026","color-background-warning":"#221906","color-info":"#539bf5","color-background-info":"#021327","color-success":"#57ab5a","color-background-success":"#0e1b0e","color-passive":"#a7acb3","color-code":"#4e5a6a","color-background-body":"#22272e","color-background-block":"#2d333b","color-background-tooltip":"rgba(22, 22, 22, 0.8)","color-background-item":"#313944","color-background-badge":"#4e5a6a","color-background-hover":"#3D4652","color-text":"#cdd9e5","color-text-secondary":"#768390","color-text-disabled":"#636e7b","box-shadow":"rgba(0, 0, 0, 0.16) 1px 2px 6px","box-shadow-popper":"rgba(0, 0, 0, 0.2) 0px 2px 8px 0px","border-divider":"1px solid rgba(99, 110, 123, 0.5)","color-hover-black":"rgba(0, 0, 0, 0.2)","color-log-hits-bar-0":"rgba(255, 255, 255, 0.18)","color-log-hits-bar-1":"#FFB74D","color-log-hits-bar-2":"#81C784","color-log-hits-bar-3":"#64B5F6","color-log-hits-bar-4":"#E57373","color-log-hits-bar-5":"#8a62f0"},ln={"color-primary":"#3f51b5","color-secondary":"#e91e63","color-error":"#fd080e","color-background-error":"#ffd7d8","color-warning":"#ff8308","color-background-warning":"#ffd6ad","color-info":"#03a9f4","color-background-info":"#d7f2fe","color-success":"#4caf50","color-background-success":"#d4ecd5","color-passive":"#5d6267","color-code":"#ecedee","color-background-body":"#FEFEFF","color-background-block":"#FFFFFF","color-background-tooltip":"rgba(80,80,80,0.9)","color-background-item":"#f8f9fa","color-background-badge":"#e1e4e7","color-background-hover":"#edf0f2","color-text":"#110f0f","color-text-secondary":"#706F6F","color-text-disabled":"#A09F9F","box-shadow":"rgba(0, 0, 0, 0.08) 1px 2px 6px","box-shadow-popper":"rgba(0, 0, 0, 0.1) 0px 2px 8px 0px","border-divider":"1px solid rgba(0, 0, 0, 0.15)","color-hover-black":"rgba(0, 0, 0, 0.06)","color-log-hits-bar-0":"rgba(0, 0, 0, 0.18)","color-log-hits-bar-1":"#FFB74D","color-log-hits-bar-2":"#81C784","color-log-hits-bar-3":"#64B5F6","color-log-hits-bar-4":"#E57373","color-log-hits-bar-5":"#8a62f0"},Em=()=>{const[t,r]=b(br()),n=(a=>{r(a.matches)});return x(()=>{const a=window.matchMedia("(prefers-color-scheme: dark)");return a.addEventListener("change",n),()=>a.removeEventListener("change",n)},[]),t},cn=["primary","secondary","error","warning","info","success"],xm=({onLoaded:t})=>{const r=Me(),{palette:n={}}=Kt(),{theme:a}=ne(),s=Em(),o=Jt(),i=Ct(),[l,c]=b({[Ve.dark]:on,[Ve.light]:ln,[Ve.system]:br()?on:ln}),m=()=>{const{innerWidth:v,innerHeight:y}=window,{clientWidth:f,clientHeight:g}=document.documentElement;Tt("scrollbar-width",`${v-f}px`),Tt("scrollbar-height",`${y-g}px`),Tt("vh",`${y*.01}px`)},d=()=>{cn.forEach((v,y)=>{const f=tt(`color-${v}`),g=Hc(f);Tt(`${v}-text`,g),y===cn.length-1&&(o({type:"SET_DARK_THEME"}),t(!0))})},u=()=>{cn.forEach(v=>{const y=n[v];y&&Tt(`color-${v}`,y)}),d()},h=()=>{const v=be("THEME")||Ve.system,y=l[v];Object.entries(y).forEach(([f,g])=>{Tt(f,g)}),d(),r&&u()},p=()=>{const v=br()?on:ln;if(l[Ve.system]===v){h();return}c(y=>({...y,[Ve.system]:v}))};return x(()=>{m(),h()},[l]),x(m,[i]),x(p,[a,s]),x(()=>{r&&o({type:"SET_THEME",payload:Ve.light})},[]),null},bo=()=>{const[t,r]=b([]),[n,a]=b(!1),s=Z(document.body),o=m=>{const d=Array.from(m||[]);r(d)},i=m=>{m.preventDefault(),m.stopPropagation(),m.type==="dragenter"||m.type==="dragover"?a(!0):m.type==="dragleave"&&a(!1)},l=m=>{m.preventDefault(),m.stopPropagation(),a(!1),m?.dataTransfer?.files&&m.dataTransfer.files[0]&&o(m.dataTransfer.files)},c=m=>{const d=m.clipboardData?.items;if(!d)return;const u=Array.from(d).filter(h=>h.type==="application/json").map(h=>h.getAsFile()).filter(h=>h!==null);r(u)};return oe("dragenter",i,s),oe("dragleave",i,s),oe("dragover",i,s),oe("drop",l,s),oe("paste",c,s),{files:t,dragging:n}},kr=({onOpenModal:t,onChange:r})=>e("div",{className:"vm-upload-json-buttons",children:[e(O,{variant:"outlined",onClick:t,children:"Paste JSON"}),e("div",{className:"vm-upload-json-buttons__upload",children:[e(O,{children:"Upload Files"}),e("input",{id:"json",name:"json",type:"file",accept:"application/json",multiple:!0,title:" ",onChange:r})]})]}),Am=()=>{const[t,r]=b([]),[n,a]=b([]),s=D(()=>!!t.length,[t]),{value:o,setTrue:i,setFalse:l}=de(!1),c=(g,_="")=>{a(C=>[{filename:_,text:`: ${g.message}`},...C])},m=(g,_)=>{try{const C=JSON.parse(g),w=C.trace||C;if(!w.duration_msec){c(new Error(ge.traceNotFound),_);return}const N=new bt(w,_);r(S=>[N,...S])}catch(C){C instanceof Error&&c(C,_)}},d=g=>{g.map(_=>{const C=new FileReader,w=_?.name||"";C.onload=N=>{const S=String(N.target?.result);m(S,w)},C.readAsText(_)})},u=g=>{if(!g.target)return;const _=g.target;a([]);const C=Array.from(_.files||[]);d(C),_.value=""},h=g=>{const _=t.filter(C=>C.idValue!==g.idValue);r([..._])},p=g=>{a(_=>_.filter((C,w)=>w!==g))},v=g=>()=>{p(g)},{files:y,dragging:f}=bo();return x(()=>{d(y)},[y]),e("div",{className:"vm-trace-page",children:[e("div",{className:"vm-trace-page-header",children:[e("div",{className:"vm-trace-page-header-errors",children:n.map((g,_)=>e("div",{className:"vm-trace-page-header-errors-item",children:[e(te,{variant:"error",children:[e("b",{className:"vm-trace-page-header-errors-item__filename",children:g.filename}),e("span",{children:g.text})]}),e(O,{className:"vm-trace-page-header-errors-item__close",startIcon:e(De,{}),variant:"text",color:"error",onClick:v(_)})]},`${g}_${_}`))}),e("div",{children:s&&e(kr,{onOpenModal:i,onChange:u})})]}),s&&e("div",{children:e(Qn,{jsonEditor:!0,traces:t,onDeleteClick:h})}),!s&&e("div",{className:"vm-trace-page-preview",children:[e("p",{className:"vm-trace-page-preview__text",children:["Please, upload file with JSON response content.",`
`,"The file must contain tracing information in JSON format.",`
`,"In order to use tracing please refer to the doc: ",e("a",{className:"vm-link vm-link_colored",href:"https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#query-tracing",target:"_blank",rel:"help noreferrer",children:"https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#query-tracing"}),`
`,"Tracing graph will be displayed after file upload.",`
`,"Attach files by dragging & dropping, selecting or pasting them."]}),e(kr,{onOpenModal:i,onChange:u})]}),o&&e(we,{title:"Paste JSON",onClose:l,children:e(Vs,{editable:!0,displayTitle:!0,defaultTile:`JSON ${t.length+1}`,onClose:l,onUpload:m})}),f&&e("div",{className:"vm-trace-page__dropzone"})]})},Lm=({job:t,instance:r,metrics:n,size:a})=>{const{duration:s,relativeTime:o,period:{date:i}}=he(),{customStep:l}=Oe(),{setSearchParamsFromKeys:c}=nt(),m=()=>{const d=Yr({"g0.range_input":s,"g0.end_input":i,"g0.step_input":l,"g0.relative_time":o,size:a,job:t,instance:r,metrics:n});c(d)};x(m,[s,o,i,l,t,r,n,a]),x(m,[])},km=(t,r)=>`${t}/api/v1/label/job/values?start=${r.start}&end=${r.end}`,Mm=(t,r,n)=>{const a=`{job=${JSON.stringify(n)}}`;return`${t}/api/v1/label/instance/values?match[]=${encodeURIComponent(a)}&start=${r.start}&end=${r.end}`},Im=(t,r,n,a)=>{const o=`{${Object.entries({job:n,instance:a}).filter(i=>i[1]).map(([i,l])=>`${i}=${JSON.stringify(l)}`).join(",")}}`;return`${t}/api/v1/label/__name__/values?match[]=${encodeURIComponent(o)}&start=${r.start}&end=${r.end}`},Dm=()=>{const{serverUrl:t}=ne(),{period:r}=he(),[n,a]=b([]),[s,o]=b(!1),[i,l]=b(),c=D(()=>km(t,r),[t,r]);return x(()=>{(async()=>{o(!0);try{const d=await fetch(c),u=await d.json(),h=u.data||[];a(h.sort((p,v)=>p.localeCompare(v))),d.ok?l(void 0):l(`${u.errorType}\r
${u?.error}`)}catch(d){d instanceof Error&&l(`${d.name}: ${d.message}`)}o(!1)})().catch(console.error)},[c]),{jobs:n,isLoading:s,error:i}},Rm=t=>{const{serverUrl:r}=ne(),{period:n}=he(),[a,s]=b([]),[o,i]=b(!1),[l,c]=b(),m=D(()=>Mm(r,n,t),[r,n,t]);return x(()=>{if(!t)return;(async()=>{i(!0);try{const u=await fetch(m),h=await u.json(),p=h.data||[];s(p.sort((v,y)=>v.localeCompare(y))),u.ok?c(void 0):c(`${h.errorType}\r
${h?.error}`)}catch(u){u instanceof Error&&c(`${u.name}: ${u.message}`)}i(!1)})().catch(console.error)},[m]),{instances:a,isLoading:o,error:l}},Pm=(t,r)=>{const{serverUrl:n}=ne(),{period:a}=he(),[s,o]=b([]),[i,l]=b(!1),[c,m]=b(),d=D(()=>Im(n,a,t,r),[n,a,t,r]);return x(()=>{if(!t)return;(async()=>{l(!0);try{const h=await fetch(d),p=await h.json(),v=p.data||[];o(v.sort((y,f)=>y.localeCompare(f))),h.ok?m(void 0):m(`${p.errorType}\r
${p?.error}`)}catch(h){h instanceof Error&&m(`${h.name}: ${h.message}`)}l(!1)})().catch(console.error)},[d]),{names:s,isLoading:i,error:c}},$m=({name:t,job:r,instance:n,rateEnabled:a,isBucket:s,height:o})=>{const{isMobile:i}=W(),{customStep:l,yaxis:c}=Oe(),{period:m}=he(),d=rt(),u=Ge(),h=Pr(m.end-m.start),p=En(l),v=$r(p*10*1e3),[y,f]=b(!1),[g,_]=b(!1),C=y&&l===h?v:l,w=D(()=>{const L=Object.entries({job:r,instance:n}).filter(H=>H[1]).map(([H,z])=>`${H}=${JSON.stringify(z)}`);L.push(`__name__=${JSON.stringify(t)}`),t=="node_cpu_seconds_total"&&L.push('mode!="idle"');const $=`{${L.join(",")}}`;return s?[`sum(rate(${$})) by (vmrange, le)`]:[`
with (q = ${a?`rollup_rate(${$})`:`rollup(${$})`}) (
alias(min(label_match(q, "rollup", "min")), "min"),
alias(max(label_match(q, "rollup", "max")), "max"),
alias(avg(label_match(q, "rollup", "avg")), "avg"),
)`]},[t,r,n,a,s]),{isLoading:N,graphData:S,error:A,queryErrors:T,warning:E,isHistogram:M}=Bn({predefinedQuery:w,visible:!0,customStep:C,showAllSeries:g}),I=L=>{d({type:"SET_YAXIS_LIMITS",payload:L})},k=({from:L,to:$})=>{u({type:"SET_PERIOD",payload:{from:L,to:$}})};return x(()=>{f(M)},[M]),e("div",{className:R({"vm-explore-metrics-graph":!0,"vm-explore-metrics-graph_mobile":i}),children:[N&&e(Se,{}),A&&e(te,{variant:"error",children:A}),T[0]&&e(te,{variant:"error",children:T[0]}),E&&e(jn,{warning:E,query:w,onChange:_}),S&&m&&e(Gr,{data:S,period:m,customStep:C,query:w,yaxis:c,setYaxisLimits:I,setPeriod:k,showLegend:!1,height:o,isHistogram:M})]})},Om=({name:t,index:r,length:n,isBucket:a,rateEnabled:s,onChangeRate:o,onRemoveItem:i,onChangeOrder:l})=>{const{isMobile:c}=W(),{value:m,setTrue:d,setFalse:u}=de(!1),h=()=>{i(t)},p=()=>{l(t,r,r+1)},v=()=>{l(t,r,r-1)};return c?e("div",{className:"vm-explore-metrics-item-header vm-explore-metrics-item-header_mobile",children:[e("div",{className:"vm-explore-metrics-item-header__name",children:t}),e(O,{variant:"text",size:"small",startIcon:e($n,{}),onClick:d,ariaLabel:"open panel settings"}),m&&e(we,{title:t,onClose:u,children:e("div",{className:"vm-explore-metrics-item-header-modal",children:[e("div",{className:"vm-explore-metrics-item-header-modal-order",children:[e(O,{startIcon:e(ss,{}),variant:"outlined",onClick:v,disabled:r===0,ariaLabel:"move graph up"}),e("p",{children:["position:",e("span",{className:"vm-explore-metrics-item-header-modal-order__index",children:["#",r+1]})]}),e(O,{endIcon:e(Dn,{}),variant:"outlined",onClick:p,disabled:r===n-1,ariaLabel:"move graph down"})]}),!a&&e("div",{className:"vm-explore-metrics-item-header-modal__rate",children:[e(Ie,{label:e("span",{children:["enable ",e("code",{children:"rate()"})]}),value:s,onChange:o,fullWidth:!0}),e("p",{children:"calculates the average per-second speed of metrics change"})]}),e(O,{startIcon:e(De,{}),color:"error",variant:"outlined",onClick:h,fullWidth:!0,children:"Remove graph"})]})})]}):e("div",{className:"vm-explore-metrics-item-header",children:[e("div",{className:"vm-explore-metrics-item-header-order",children:[e(G,{title:"move graph up",children:e(O,{className:"vm-explore-metrics-item-header-order__up",startIcon:e(Ae,{}),variant:"text",color:"gray",size:"small",onClick:v,ariaLabel:"move graph up"})}),e("div",{className:"vm-explore-metrics-item-header__index",children:["#",r+1]}),e(G,{title:"move graph down",children:e(O,{className:"vm-explore-metrics-item-header-order__down",startIcon:e(Ae,{}),variant:"text",color:"gray",size:"small",onClick:p,ariaLabel:"move graph down"})})]}),e("div",{className:"vm-explore-metrics-item-header__name",children:t}),!a&&e("div",{className:"vm-explore-metrics-item-header__rate",children:e(G,{title:"calculates the average per-second speed of metric's change",children:e(Ie,{label:e("span",{children:["enable ",e("code",{children:"rate()"})]}),value:s,onChange:o})})}),e("div",{className:"vm-explore-metrics-item-header__close",children:e(G,{title:"close graph",children:e(O,{startIcon:e(De,{}),variant:"text",color:"gray",size:"small",onClick:h,ariaLabel:"close graph"})})})]})},Hm=({name:t,job:r,instance:n,index:a,length:s,size:o,onRemoveItem:i,onChangeOrder:l})=>{const c=D(()=>/_sum$|_total$|_count$/.test(t),[t]),m=D(()=>/_bucket$/.test(t),[t]),[d,u]=b(c),h=Ct(),p=D(o.height,[o,h]);return x(()=>{u(c)},[r]),e("div",{className:"vm-explore-metrics-item vm-block vm-block_empty-padding",children:[e(Om,{name:t,index:a,length:s,isBucket:m,rateEnabled:d,size:o.id,onChangeRate:u,onRemoveItem:i,onChangeOrder:l}),e($m,{name:t,job:r,instance:n,rateEnabled:d,isBucket:m,height:p},`${t}_${r}_${n}_${d}`)]})},zm=Cr.map(t=>t.id),Fm=({jobs:t,instances:r,names:n,job:a,instance:s,size:o,selectedMetrics:i,onChangeJob:l,onChangeInstance:c,onToggleMetric:m,onChangeSize:d})=>{const u=D(()=>a?"":"No instances. Please select job",[a]),h=D(()=>a?"":"No metric names. Please select job",[a]),{isMobile:p}=W(),{value:v,toggle:y,setFalse:f}=de(be("EXPLORE_METRICS_TIPS")!=="false");return x(()=>{Ne("EXPLORE_METRICS_TIPS",`${v}`)},[v]),e(q,{children:[e("div",{className:R({"vm-explore-metrics-header":!0,"vm-explore-metrics-header_mobile":p,"vm-block":!0,"vm-block_mobile":p}),children:[e("div",{className:"vm-explore-metrics-header__job",children:e(ot,{value:a,list:t,label:"Job",placeholder:"Please select job",onChange:l,autofocus:!a&&!!t.length&&!p,searchable:!0})}),e("div",{className:"vm-explore-metrics-header__instance",children:e(ot,{value:s,list:r,label:"Instance",placeholder:"Please select instance",onChange:c,noOptionsText:u,clearable:!0,searchable:!0})}),e("div",{className:"vm-explore-metrics-header__size",children:[e(ot,{label:"Size graphs",value:o,list:zm,onChange:d}),e(G,{title:`${v?"Hide":"Show"} tip`,children:e(O,{variant:"text",color:v?"warning":"gray",startIcon:e(tr,{}),onClick:y,ariaLabel:"visibility tips"})})]}),e("div",{className:"vm-explore-metrics-header-metrics",children:e(ot,{label:"Metrics",value:i,list:n,placeholder:"Search metric name",onChange:m,noOptionsText:h,clearable:!0,searchable:!0})})]}),v&&e(te,{variant:"warning",children:e("div",{className:"vm-explore-metrics-header-description",children:[e("p",{children:["Please note: this page is solely designed for exploring Prometheus metrics. Prometheus metrics always contain ",e("code",{children:"job"})," and ",e("code",{children:"instance"})," labels (see ",e("a",{className:"vm-link vm-link_colored",href:"https://prometheus.io/docs/concepts/jobs_instances/",children:"these docs"}),"), and this page relies on them as filters. ",e("br",{}),"Please use this page for Prometheus metrics only, in accordance with their naming conventions."]}),e(O,{variant:"text",size:"small",startIcon:e(De,{}),onClick:f,ariaLabel:"close tips"})]})})]})},Vm=ue("job",""),Um=ue("instance",""),Ta=ue("metrics",""),Ea=ue("size",""),qm=Cr.find(t=>Ea?t.id===Ea:t.isDefault)||Cr[0],Bm=()=>{const[t,r]=b(Vm),[n,a]=b(Um),[s,o]=b(Ta?Ta.split("&"):[]),[i,l]=b(qm);Lm({job:t,instance:n,metrics:s.join("&"),size:i.id});const{jobs:c,isLoading:m,error:d}=Dm(),{instances:u,isLoading:h,error:p}=Rm(t),{names:v,isLoading:y,error:f}=Pm(t,n),g=D(()=>m||h||y,[m,h,y]),_=D(()=>d||p||f,[d,p,f]),C=S=>{o(S?A=>A.includes(S)?A.filter(T=>T!==S):[...A,S]:[])},w=S=>{const A=Cr.find(T=>T.id===S);A&&l(A)},N=(S,A,T)=>{const E=T>s.length-1;T<0||E||o(I=>{const k=[...I],[L]=k.splice(A,1);return k.splice(T,0,L),k})};return x(()=>{n&&u.length&&!u.includes(n)&&a("")},[u,n]),e("div",{className:"vm-explore-metrics",children:[e(Fm,{jobs:c,instances:u,names:v,job:t,size:i.id,instance:n,selectedMetrics:s,onChangeJob:r,onChangeSize:w,onChangeInstance:a,onToggleMetric:C}),g&&e(Se,{}),_&&e(te,{variant:"error",children:_}),!t&&e(te,{variant:"info",children:"Please select job to see list of metric names."}),t&&!s.length&&e(te,{variant:"info",children:"Please select metric names to see the graphs."}),e("div",{className:"vm-explore-metrics-body",children:s.map((S,A)=>e(Hm,{name:S,job:t,instance:n,index:A,length:s.length,size:i,onRemoveItem:C,onChangeOrder:N},S))})]})},Qm=()=>{const t=Ke(),r=n=>async()=>{await t(`<${n}/>`,`<${n}/> has been copied`)};return e("div",{className:"vm-preview-icons",children:Object.entries(wi).map(([n,a])=>e("div",{className:"vm-preview-icons-item",onClick:r(n),children:[e("div",{className:"vm-preview-icons-item__svg",children:a()}),e("div",{className:"vm-preview-icons-item__name",children:`<${n}/>`})]},n))})},Qe=({code:t})=>{const r=Ke(),[n,a]=b("Copy"),s=async()=>{await r(t),a("Copied")};return x(()=>{let o=null;return n==="Copied"&&(o=setTimeout(()=>a("Copy"),1e3)),()=>{o&&clearTimeout(o)}},[n]),e("code",{className:"vm-code-example",children:[t,e("div",{className:"vm-code-example__copy",children:e(G,{title:n,children:e(O,{size:"small",variant:"text",onClick:s,startIcon:e(_t,{}),ariaLabel:"close"})})})]})},jm=()=>e("a",{className:"vm-link vm-link_colored",href:"https://docs.victoriametrics.com/victoriametrics/metricsql/",target:"_blank",rel:"help noreferrer",children:"MetricsQL"}),xa=()=>e("a",{className:"vm-link vm-link_colored",href:"https://grafana.com/grafana/dashboards/1860",target:"_blank",rel:"help noreferrer",children:"Node Exporter Full"}),Ym=()=>e("section",{className:"vm-with-template-tutorial",children:[e("h2",{className:"vm-with-template-tutorial__title",children:["Tutorial for WITH expressions in ",e(jm,{})]}),e("div",{className:"vm-with-template-tutorial-section",children:[e("p",{className:"vm-with-template-tutorial-section__text",children:["Let's look at the following real query from ",e(xa,{})," dashboard:"]}),e(Qe,{code:`(
(
node_memory_MemTotal_bytes{instance=~"$node:$port", job=~"$job"}
-
node_memory_MemFree_bytes{instance=~"$node:$port", job=~"$job"}
)
/
node_memory_MemTotal_bytes{instance=~"$node:$port", job=~"$job"}
) * 100`}),e("p",{className:"vm-with-template-tutorial-section__text",children:"It is clear the query calculates the percentage of used memory for the given $node, $port and $job. Isn't it? :)"})]}),e("div",{className:"vm-with-template-tutorial-section",children:[e("p",{className:"vm-with-template-tutorial-section__text",children:"What's wrong with this query? Copy-pasted label filters for distinct timeseries which makes it easy to mistype these filters during modification. Let's simplify the query with WITH expressions:"}),e(Qe,{code:`WITH (
commonFilters = {instance=~"$node:$port",job=~"$job"}
)
(
node_memory_MemTotal_bytes{commonFilters}
-
node_memory_MemFree_bytes{commonFilters}
)
/
node_memory_MemTotal_bytes{commonFilters} * 100`})]}),e("div",{className:"vm-with-template-tutorial-section",children:[e("p",{className:"vm-with-template-tutorial-section__text",children:["Now label filters are located in a single place instead of three distinct places. The query mentions node_memory_MemTotal_bytes metric twice and ","{commonFilters}"," three times. WITH expressions may improve this:"]}),e(Qe,{code:`WITH (
my_resource_utilization(free, limit, filters) = (limit{filters} - free{filters}) / limit{filters} * 100
)
my_resource_utilization(
node_memory_MemFree_bytes,
node_memory_MemTotal_bytes,
{instance=~"$node:$port",job=~"$job"},
)`}),e("p",{className:"vm-with-template-tutorial-section__text",children:"Now the template function my_resource_utilization() may be used for monitoring arbitrary resources - memory, CPU, network, storage, you name it."})]}),e("div",{className:"vm-with-template-tutorial-section",children:[e("p",{className:"vm-with-template-tutorial-section__text",children:["Let's take another nice query from ",e(xa,{})," dashboard:"]}),e(Qe,{code:`(
(
(
count(
count(node_cpu_seconds_total{instance=~"$node:$port",job=~"$job"}) by (cpu)
)
)
-
avg(
sum by (mode) (rate(node_cpu_seconds_total{mode='idle',instance=~"$node:$port",job=~"$job"}[5m]))
)
)
*
100
)
/
count(
count(node_cpu_seconds_total{instance=~"$node:$port",job=~"$job"}) by (cpu)
)`}),e("p",{className:"vm-with-template-tutorial-section__text",children:"Do you understand what does this mess do? Is it manageable? :) WITH expressions are happy to help in a few iterations."})]}),e("div",{className:"vm-with-template-tutorial-section",children:[e("p",{className:"vm-with-template-tutorial-section__text",children:"1. Extract common filters used in multiple places into a commonFilters variable:"}),e(Qe,{code:`WITH (
commonFilters = {instance=~"$node:$port",job=~"$job"}
)
(
(
(
count(
count(node_cpu_seconds_total{commonFilters}) by (cpu)
)
)
-
avg(
sum by (mode) (rate(node_cpu_seconds_total{mode='idle',commonFilters}[5m]))
)
)
*
100
)
/
count(
count(node_cpu_seconds_total{commonFilters}) by (cpu)
)`})]}),e("div",{className:"vm-with-template-tutorial-section",children:[e("p",{className:"vm-with-template-tutorial-section__text",children:'2. Extract "count(count(...) by (cpu))" into cpuCount variable:'}),e(Qe,{code:`WITH (
commonFilters = {instance=~"$node:$port",job=~"$job"},
cpuCount = count(count(node_cpu_seconds_total{commonFilters}) by (cpu))
)
(
(
cpuCount
-
avg(
sum by (mode) (rate(node_cpu_seconds_total{mode='idle',commonFilters}[5m]))
)
)
*
100
) / cpuCount`})]}),e("div",{className:"vm-with-template-tutorial-section",children:[e("p",{className:"vm-with-template-tutorial-section__text",children:"3. Extract rate(...) part into cpuIdle variable, since it is clear now that this part calculates the number of idle CPUs:"}),e(Qe,{code:`WITH (
commonFilters = {instance=~"$node:$port",job=~"$job"},
cpuCount = count(count(node_cpu_seconds_total{commonFilters}) by (cpu)),
cpuIdle = sum(rate(node_cpu_seconds_total{mode='idle',commonFilters}[5m]))
)
((cpuCount - cpuIdle) * 100) / cpuCount`})]}),e("div",{className:"vm-with-template-tutorial-section",children:[e("p",{className:"vm-with-template-tutorial-section__text",children:["4. Put node_cpu_seconds_total","{commonFilters}"," into its own variable with the name cpuSeconds:"]}),e(Qe,{code:`WITH (
cpuSeconds = node_cpu_seconds_total{instance=~"$node:$port",job=~"$job"},
cpuCount = count(count(cpuSeconds) by (cpu)),
cpuIdle = sum(rate(cpuSeconds{mode='idle'}[5m]))
)
((cpuCount - cpuIdle) * 100) / cpuCount`}),e("p",{className:"vm-with-template-tutorial-section__text",children:"Now the query became more clear comparing to the initial query."})]}),e("div",{className:"vm-with-template-tutorial-section",children:[e("p",{className:"vm-with-template-tutorial-section__text",children:"WITH expressions may be nested and may be put anywhere. Try expanding the following query:"}),e(Qe,{code:`WITH (
f(a, b) = WITH (
f1(x) = b-x,
f2(x) = x+x
) f1(a)*f2(b)
) f(foo, with(x=bar) x)`})]})]}),Gm=(t,r)=>`${t}/expand-with-exprs?query=${encodeURIComponent(r)}&format=json`,Wm=()=>{const{serverUrl:t}=ne(),[r,n]=me(),[a,s]=b(""),[o,i]=b(!1),[l,c]=b();return{data:a,error:l,loading:o,expand:async d=>{r.set("expr",d),n(r);const u=Gm(t,d);i(!0);try{const p=await(await fetch(u)).json();s(p?.expr||""),c(String(p.error||""))}catch(h){h instanceof Error&&h.name!=="AbortError"&&c(`${h.name}: ${h.message}`)}i(!1)}}},Km=()=>{const[t]=me(),{data:r,loading:n,error:a,expand:s}=Wm(),[o,i]=b(t.get("expr")||""),l=m=>{i(m)},c=()=>{s(o)};return x(()=>{o&&s(o)},[]),e("section",{className:"vm-with-template",children:[n&&e(Se,{}),e("div",{className:"vm-with-template-body vm-block",children:[e("div",{className:"vm-with-template-body__expr",children:e(ie,{type:"textarea",label:"MetricsQL query with optional WITH expressions",value:o,error:a,autofocus:!0,onEnter:c,onChange:l})}),e("div",{className:"vm-with-template-body__result",children:e(ie,{type:"textarea",label:"MetricsQL query after expanding WITH expressions and applying other optimizations",value:r,disabled:!0})}),e("div",{className:"vm-with-template-body-top",children:e(O,{variant:"contained",onClick:c,startIcon:e(dt,{}),children:"Expand"})})]}),e("div",{className:"vm-block",children:e(Ym,{})})]})},Jm=(t,r,n)=>{const a=["format=json",`relabel_configs=${encodeURIComponent(r)}`,`metric=${encodeURIComponent(n)}`];return`${t}/metric-relabel-debug?${a.join("&")}`},Zm=()=>{const{serverUrl:t}=ne(),[r,n]=b(null),[a,s]=b(!1),[o,i]=b();return{data:r,error:o,loading:a,fetchData:async(c,m)=>{const d=Jm(t,c,m);s(!0);try{const h=await(await fetch(d)).json();n(h.error?null:h),i(String(h.error||""))}catch(u){u instanceof Error&&u.name!=="AbortError"&&i(`${u.name}: ${u.message}`)}s(!1)}}},Xm={config:`- if: '{bar_label=~"b.*"}'
source_labels: [foo_label, bar_label]
separator: "_"
target_label: foobar
- action: labeldrop
regex: "foo_.*"
- target_label: job
replacement: "my-application-2"`,labels:'{__name__="my_metric", bar_label="bar", foo_label="foo", job="my-application", instance="192.168.0.1"}'},eu=()=>{const[t,r]=me(),{data:n,loading:a,error:s,fetchData:o}=Zm(),[i,l]=pt("","config"),[c,m]=pt("","labels"),d=v=>{l(v||"")},u=v=>{m(v||"")},h=Y(()=>{o(i,c),t.set("config",i),t.set("labels",c),r(t)},[i,c]),p=()=>{const{config:v,labels:y}=Xm;l(v),m(y),o(v,y),t.set("config",v),t.set("labels",y),r(t)};return x(()=>{const v=t.get("config")||"",y=t.get("labels")||"";(y||v)&&(o(v,y),l(v),m(y))},[]),e("section",{className:"vm-relabeling",children:[a&&e(Se,{}),e("div",{className:"vm-relabeling-header vm-block",children:[e("div",{className:"vm-relabeling-header-configs",children:e(ie,{type:"textarea",label:"Relabel configs",value:i,autofocus:!0,onChange:d,onEnter:h})}),e("div",{className:"vm-relabeling-header__labels",children:e(ie,{type:"textarea",label:"Labels",value:c,onChange:u,onEnter:h})}),e("div",{className:"vm-relabeling-header-bottom",children:[e("a",{className:"vm-link vm-link_with-icon",target:"_blank",href:"https://docs.victoriametrics.com/victoriametrics/relabeling/",rel:"help noreferrer",children:[e(lt,{}),"Relabeling cookbook"]}),e("a",{className:"vm-link vm-link_with-icon",target:"_blank",href:"https://docs.victoriametrics.com/victoriametrics/relabeling/",rel:"help noreferrer",children:[e(gt,{}),"Documentation"]}),e(O,{variant:"text",onClick:p,children:"Try example"}),e(O,{variant:"contained",onClick:h,startIcon:e(dt,{}),children:"Submit"})]})]}),s&&e(te,{variant:"error",children:s}),n&&e("div",{className:"vm-relabeling-steps vm-block",children:[n.originalLabels&&e("div",{className:"vm-relabeling-steps-item",children:e("div",{className:"vm-relabeling-steps-item__row",children:[e("span",{children:"Original labels:"}),e("code",{dangerouslySetInnerHTML:{__html:n.originalLabels}})]})}),n.steps.map((v,y)=>e("div",{className:"vm-relabeling-steps-item",children:[e("div",{className:"vm-relabeling-steps-item__row",children:[e("span",{children:"Step:"}),y+1]}),e("div",{className:"vm-relabeling-steps-item__row",children:[e("span",{children:"Relabeling Rule:"}),e("code",{children:e("pre",{children:v.rule})})]}),e("div",{className:"vm-relabeling-steps-item__row",children:[e("span",{children:"Input Labels:"}),e("code",{children:e("pre",{dangerouslySetInnerHTML:{__html:v.errors?.inLabels||v.inLabels}})})]}),e("div",{className:"vm-relabeling-steps-item__row",children:[e("span",{children:"Output labels:"}),e("code",{children:e("pre",{dangerouslySetInnerHTML:{__html:v.errors?.outLabels||v.outLabels}})})]})]},y)),n.resultingLabels&&e("div",{className:"vm-relabeling-steps-item",children:e("div",{className:"vm-relabeling-steps-item__row",children:[e("span",{children:"Resulting labels:"}),e("code",{dangerouslySetInnerHTML:{__html:n.resultingLabels}})]})})]})]})},tu=t=>`${t}/api/v1/status/active_queries`,ru=()=>{const{serverUrl:t}=ne(),[r,n]=b([]),[a,s]=b(Q().format(Nr)),[o,i]=b(!1),[l,c]=b(),m=D(()=>tu(t),[t]),d=async()=>{i(!0);try{const u=await fetch(m),h=await u.json();n(h.data),s(Q().format("HH:mm:ss:SSS")),u.ok?c(void 0):c(`${h.errorType}\r
${h?.error}`)}catch(u){u instanceof Error&&c(`${u.name}: ${u.message}`)}i(!1)};return x(()=>{d().catch(console.error)},[m]),{data:r,lastUpdated:a,isLoading:o,error:l,fetchData:d}},nu=({rows:t,columns:r,defaultOrderBy:n,defaultOrderDir:a,copyToClipboard:s,paginationOffset:o,rowClasses:i,rowAction:l=c=>()=>{}})=>{const c=Ke(),[m,d]=b(n),[u,h]=b(a||"desc"),[p,v]=b(null),[y,f]=b(new Map);x(()=>{const N=new Map;t.forEach(S=>{N.set(S.id,Mo())}),f(N)},[t]);const g=D(()=>{const{startIndex:N,endIndex:S}=o;return Xn(t,Zn(u,m)).slice(N,S)},[t,m,u,o]),_=N=>()=>{h(S=>S==="asc"&&m===N?"desc":"asc"),d(N)},C=(N,S)=>async()=>{if(p!==S)try{await c(String(N)),v(S)}catch(A){console.error(A)}};x(()=>{if(p===null)return;const N=setTimeout(()=>v(null),2e3);return()=>clearTimeout(N)},[p]);const w=s&&r.find(N=>N.key==s);return e("table",{className:"vm-table",children:[e("thead",{className:"vm-table-header",children:e("tr",{className:"vm-table__row vm-table__row_header",children:[r.map(N=>e("th",{className:"vm-table-cell vm-table-cell_header vm-table-cell_sort",onClick:_(N.key),children:e("div",{className:"vm-table-cell__content",children:[e("div",{children:String(N.title||N.key)}),e("div",{className:R({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":m===N.key,"vm-table__sort-icon_desc":u==="desc"&&m===N.key}),children:e(Xe,{})})]})},String(N.key))),s&&e("th",{className:"vm-table-cell vm-table-cell_header"})]})}),e("tbody",{className:"vm-table-body",children:g.map((N,S)=>e("tr",{className:R({"vm-table__row":!0,...i?i(N):{}}),id:N.id,ref:y.get(N.id),onClick:l(y.get(N.id)),children:[r.map(A=>e("td",{className:R({"vm-table-cell":!0,[`${A.className}`]:A.className}),children:(A.format?A.format(N):String(N[A.key]))||"-"},String(A.key))),s&&w&&e("td",{className:"vm-table-cell vm-table-cell_right",children:N[s]&&e("div",{className:"vm-table-cell__content",children:e(G,{title:p===S?"Copied":"Copy row",children:e(O,{variant:"text",color:p===S?"success":"gray",size:"small",startIcon:p===S?e(Ur,{}):e(_t,{}),onClick:C(w.format?w.format(N):String(N[s]),S),ariaLabel:"copy row"})})})})]},S))})]})},au=()=>{const{isMobile:t}=W(),{timezone:r}=he(),{data:n,lastUpdated:a,isLoading:s,error:o,fetchData:i}=ru(),l=D(()=>n.map(d=>{const u=Q(d.start).tz().format(qe),h=Q(d.end).tz().format(qe);return{duration:d.duration,remote_addr:d.remote_addr,query:d.query,args:`${u} to ${h}, step=${dn(d.step)}`,data:JSON.stringify(d,null,2)}}),[n,r]),c=D(()=>{if(!l?.length)return[];const d=Object.keys(l[0]),u={remote_addr:"client address"},h=["data"];return d.filter(p=>!h.includes(p)).map(p=>({key:p,title:u[p]||p}))},[l]),m=async()=>{i().catch(console.error)};return e("div",{className:"vm-active-queries",children:[s&&e(Se,{}),e("div",{className:"vm-active-queries-header",children:[!l.length&&!o&&e(te,{variant:"info",children:"There are currently no active queries running"}),o&&e(te,{variant:"error",children:o}),e("div",{className:"vm-active-queries-header-controls",children:[e(O,{variant:"contained",onClick:m,startIcon:e(Qt,{}),children:"Update"}),e("div",{className:"vm-active-queries-header__update-msg",children:["Last updated: ",a]})]})]}),!!l.length&&e("div",{className:R({"vm-block":!0,"vm-block_mobile":t}),children:e(nu,{rows:l,columns:c,defaultOrderBy:"duration",copyToClipboard:"data",paginationOffset:{startIndex:0,endIndex:1/0}})})]})},su=({onClose:t,onUpload:r})=>{const{isMobile:n}=W(),[a,s]=b(""),[o,i]=b(""),l=D(()=>{try{return JSON.parse(a),""}catch(d){return d instanceof Error?d.message:"Unknown error"}},[a]),c=d=>{i(""),s(d)},m=()=>{i(l),!l&&(r(a),t())};return e("div",{className:R({"vm-json-form vm-json-form_one-field":!0,"vm-json-form_mobile vm-json-form_one-field_mobile":n}),children:[e(ie,{value:a,label:"JSON",type:"textarea",error:o,autofocus:!0,onChange:c,onEnter:m}),e("div",{className:"vm-json-form-footer",children:e("div",{className:"vm-json-form-footer__controls vm-json-form-footer__controls_right",children:[e(O,{variant:"outlined",color:"error",onClick:t,children:"Cancel"}),e(O,{variant:"contained",onClick:m,children:"apply"})]})})]})},ou=({data:t,period:r})=>{const{isMobile:n}=W(),[a,s]=me(),{tableCompact:o}=$e(),i=Pt(),[l,c]=b([]),[m,d]=b(),[u,h]=b(),[p,v]=b(!1),[y,f]=b([]),[g,_]=b(),C=D(()=>nr(u||[]).map(j=>j.key),[u]),w=D(()=>{const j=t.some(X=>X.data.resultType==="matrix");return t.some(X=>X.data.resultType==="vector")&&j?Lt:j?Lt.filter(X=>X.value==="chart"):Lt.filter(X=>X.value!=="chart")},[t]),[N,S]=b(w[0].value),{yaxis:A,spanGaps:T,showAllPoints:E}=Oe(),M=rt(),I=j=>{M({type:"SET_YAXIS_LIMITS",payload:j})},k=()=>{M({type:"TOGGLE_ENABLE_YAXIS_LIMITS"})},L=j=>{M({type:"SET_SPAN_GAPS",payload:j})},$=j=>{M({type:"SET_SHOW_POINTS",payload:j})},V=j=>{S(j)},H=j=>{c(ee=>ee.filter(X=>X.idValue!==j.idValue))},z=()=>{i({type:"TOGGLE_TABLE_COMPACT"})};return x(()=>{const j=N==="chart"?"matrix":"vector",ee=t.filter(X=>X.data.resultType===j&&X.trace).map(X=>X.trace?new bt(X.trace,X?.vmui?.params?.query||"Query"):null);c(ee.filter(Boolean))},[t,N]),x(()=>{const j=[],ee=[],X=[];t.forEach((B,ae)=>{const le=B.data.result.map(F=>({...F,group:Number(B.vmui?.params?.id??ae)+1}));B.data.resultType==="matrix"?(ee.push(...le),j.push(B.vmui?.params?.query||"Query")):X.push(...le)}),f(j),d(ee),h(X),a.delete("display_mode"),s(a)},[t]),x(()=>{const j=!a.get("display_mode");v(!!m&&j&&qn(m))},[m,a]),e("div",{className:R({"vm-query-analyzer-view":!0,"vm-query-analyzer-view_mobile":n}),children:[!!l.length&&e(Qn,{traces:l,onDeleteClick:H}),e(fo,{}),e("div",{className:R({"vm-block":!0,"vm-block_mobile":n}),children:[e("div",{className:"vm-custom-panel-body-header",children:[e("div",{className:"vm-custom-panel-body-header__tabs",children:e(rr,{activeItem:N,items:w,onChange:V})}),e("div",{className:"vm-custom-panel-body-header__graph-controls",children:[N==="chart"&&e(Un,{}),N==="chart"&&e(Kn,{data:m||[],yaxis:A,isHistogram:p,setYaxisLimits:I,toggleEnableLimits:k,spanGaps:{value:T,onChange:L},showAllPoints:{value:E,onChange:$}}),N==="table"&&e(ho,{columns:C,selectedColumns:g,onChangeColumns:_,tableCompact:o,toggleTableCompact:z})]})]}),m&&r&&N==="chart"&&e(Gr,{data:m,period:r,customStep:r.step||"1s",query:y,yaxis:A,setYaxisLimits:I,setPeriod:()=>null,height:n?window.innerHeight*.5:500,isHistogram:p,spanGaps:T,showAllPoints:E}),u&&N==="code"&&e(Jn,{data:u}),u&&N==="table"&&e(uo,{data:u,displayColumns:g})]})]})},iu=({data:t,period:r})=>{const n=D(()=>t.filter(d=>d.vmui||d.stats),[t]),a=n.find(d=>d?.vmui?.title)?.vmui?.title||"Report",s=n.find(d=>d?.vmui?.comment)?.vmui?.comment,o=D(()=>["vmui.endpoint",...new Set(n.flatMap(d=>[...Object.keys(d.vmui?.params||[]).map(u=>`vmui.params.${u}`),...Object.keys(d.stats||[]).map(u=>`stats.${u}`),"isPartial"]))].map(d=>({column:d.split(".").pop(),values:n.map(u=>{const h=io(u,d);return typeof h=="string"?h:"-"})})).filter(({values:d})=>d.length&&d.every(u=>u!=="-")),[n]),i=D(()=>{if(!r)return"";const d=Q(r.start*1e3).tz().format(qe),u=Q(r.end*1e3).tz().format(qe);return`${d} - ${u}`},[r]),{value:l,setTrue:c,setFalse:m}=de(!1);return e(q,{children:[e("div",{className:"vm-query-analyzer-info-header",children:[e("h1",{className:"vm-query-analyzer-info-header__title",children:a}),i&&e("div",{className:"vm-query-analyzer-info-header__timerange",children:[e(jt,{})," ",i]}),r?.step&&e("div",{className:"vm-query-analyzer-info-header__timerange",children:[e(Er,{})," step ",r.step]}),(s||!!o.length)&&e("div",{className:"vm-query-analyzer-info-header__info",children:e(O,{startIcon:e(lt,{}),variant:"outlined",color:"warning",onClick:c,children:["Show stats",s&&" & comments"]})})]}),l&&e(we,{title:a,onClose:m,children:e("div",{className:"vm-query-analyzer-info__modal",children:[!!o.length&&e("div",{className:"vm-query-analyzer-info-stats",children:[e("div",{className:"vm-query-analyzer-info-comment-header",children:[e(lt,{}),"Stats"]}),e("table",{children:[e("thead",{children:e("tr",{children:o.map(({column:d})=>e("th",{children:d},d))})}),e("tbody",{children:o[0]?.values.map((d,u)=>e("tr",{children:o.map(({values:h},p)=>e("td",{children:h[u]},p))},u))})]})]}),s&&e("div",{className:"vm-query-analyzer-info-comment",children:[e("div",{className:"vm-query-analyzer-info-comment-header",children:[e(_s,{}),"Comments"]}),e("div",{className:"vm-query-analyzer-info-comment-body vm-markdown",dangerouslySetInnerHTML:{__html:Ir(s)||s}})]})]})})]})},lu=t=>{const r=t.slice(1).map((o,i)=>o-t[i]),n={};r.forEach(o=>{const i=o.toString();n[i]=(n[i]||0)+1});let a=0,s=0;for(const o in n)n[o]>s&&(s=n[o],a=Number(o));return a},cu=()=>{const[t,r]=b([]),[n,a]=b(""),s=D(()=>!!t.length,[t]),{value:o,setTrue:i,setFalse:l}=de(!1),c=D(()=>{if(!t)return;const f=t[0]?.vmui?.params,g={start:+(f?.start||0),end:+(f?.end||0),step:f?.step,date:""};if(!f){const C=t.filter(N=>N.data.resultType==="matrix").map(N=>N.data.result).flat().map(N=>N.values?N.values?.map(S=>S[0]):[0]).flat(),w=Array.from(new Set(C.filter(Boolean))).sort((N,S)=>N-S);g.start=w[0],g.end=w[w.length-1],g.step=Tn(lu(w))}return g.date=Ba(Ye(g.end)),g},[t]),m=f=>f.every(g=>{if(typeof g=="object"&&g!==null){const _=g.data;if(typeof _=="object"&&_!==null){const C=_.result,w=_.resultType;return Array.isArray(C)&&typeof w=="string"}}return!1}),d=f=>{try{const g=JSON.parse(f),_=Array.isArray(g)?g:[g];m(_)?r(_):(a("Invalid structure - JSON does not match the expected format"),r([]))}catch(g){g instanceof Error&&(a(`${g.name}: ${g.message}`),r([]))}},u=f=>{f.map(g=>{const _=new FileReader;_.onload=C=>{const w=String(C.target?.result);d(w)},_.readAsText(g)})},h=f=>{if(!f.target)return;const g=f.target;a("");const _=Array.from(g.files||[]);u(_),g.value=""},p=()=>{a("")},{files:v,dragging:y}=bo();return x(()=>{u(v)},[v]),e("div",{className:"vm-query-analyzer",children:[s&&e("div",{className:"vm-query-analyzer-header",children:[e(iu,{data:t,period:c}),e(kr,{onOpenModal:i,onChange:h})]}),s&&e(ou,{data:t,period:c}),!s&&e("div",{className:"vm-trace-page-preview",children:[e("p",{className:"vm-trace-page-preview__text",children:["Please, upload file with JSON response content.",`
`,"The file must contain query information in JSON format.",`
`,"Graph will be displayed after file upload.",`
`,"Attach files by dragging & dropping, selecting or pasting them."]}),e(kr,{onOpenModal:i,onChange:h})]}),n&&e("div",{className:"vm-query-analyzer-error",children:[e(te,{variant:"error",children:n}),e(O,{className:"vm-query-analyzer-error__close",startIcon:e(De,{}),variant:"text",color:"error",onClick:p})]}),o&&e(we,{title:"Paste JSON",onClose:l,children:e(su,{onClose:l,onUpload:d})}),y&&e("div",{className:"vm-trace-page__dropzone"})]})},du=(t,r,n)=>{const a=[`flags=${encodeURIComponent(r)}`,`metrics=${encodeURIComponent(n)}`];return`${t}/downsampling-filters-debug?${a.join("&")}`},mu=()=>{const{serverUrl:t}=ne(),[r,n]=me(),[a,s]=b(new Map),[o,i]=b(!1),[l,c]=b(),[m,d]=b(),[u,h]=b(),p=Y(async(v,y)=>{if(c(y?"":"metrics are required"),d(v?"":"flags are required"),!y||!v)return;r.set("flags",v),r.set("metrics",y),n(r);const f=du(t,v,y);i(!0);try{const _=await(await fetch(f)).json();s(new Map(Object.entries(_.result||{}))),c(_.error?.metrics||""),d(_.error?.flags||""),h("")}catch(g){g instanceof Error&&g.name!=="AbortError"&&h(`${g.name}: ${g.message}`)}i(!1)},[t]);return{data:a,error:u,metricsError:l,flagsError:m,loading:o,applyFilters:p}},Aa={flags:`-downsampling.period={env="dev"}:7d:5m,{env="dev"}:30d:30m
-downsampling.period=30d:1m
-downsampling.period=60d:5m
`,metrics:`up
up{env="dev"}
up{env="prod"}`},uu=()=>{const[t]=me(),{data:r,loading:n,error:a,metricsError:s,flagsError:o,applyFilters:i}=mu(),[l,c]=b(t.get("metrics")||""),[m,d]=b(t.get("flags")||""),u=Y(f=>{c(f)},[c]),h=Y(f=>{d(f)},[d]),p=Y(()=>{i(m,l)},[i,m,l]),v=Y(()=>{const{flags:f,metrics:g}=Aa;d(f),c(g),i(f,g),t.set("flags",f),t.set("metrics",g)},[Aa,d,c,t]);x(()=>{m&&l&&p()},[]);const y=[];for(const[f,g]of r)y.push(e("tr",{className:"vm-table__row",children:[e("td",{className:"vm-table-cell",children:f}),e("td",{className:R({"vm-table-cell":!0,"vm-table-cell_empty":!g}),children:g?g.join(" "):"No matching rules found!"})]}));return e("section",{className:"vm-downsampling-filters",children:[n&&e(Se,{}),e("div",{className:"vm-downsampling-filters-body vm-block",children:[e("div",{className:"vm-downsampling-filters-body__expr",children:[e("div",{className:"vm-retention-filters-body__title",children:e("p",{children:["Provide a list of flags for downsampling configuration. Note that only ",e("code",{children:"-downsampling.period"})," and ",e("code",{children:"-dedup.minScrapeInterval"})," flags are supported"]})}),e(ie,{type:"textarea",label:"Flags",value:m,error:a||o,autofocus:!0,onEnter:p,onChange:h,placeholder:"-downsampling.period=30d:1m -downsampling.period=7d:5m -dedup.minScrapeInterval=30s"})]}),e("div",{className:"vm-downsampling-filters-body__expr",children:[e("div",{className:"vm-retention-filters-body__title",children:e("p",{children:"Provide a list of metrics to check downsampling configuration."})}),e(ie,{type:"textarea",label:"Metrics",value:l,error:a||s,onEnter:p,onChange:u,placeholder:`up{env="dev"}
up{env="prod"}
`})]}),e("div",{className:"vm-downsampling-filters-body__result",children:e("table",{className:"vm-table",children:[e("thead",{className:"vm-table-header",children:e("tr",{children:[e("th",{className:"vm-table-cell vm-table-cell_header",children:"Metric"}),e("th",{className:"vm-table-cell vm-table-cell_header",children:"Applied downsampling rules"})]})}),e("tbody",{className:"vm-table-body",children:y})]})}),e("div",{className:"vm-downsampling-filters-body-top",children:[e("a",{className:"vm-link vm-link_with-icon",target:"_blank",href:"https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#downsampling",rel:"help noreferrer",children:[e(gt,{}),"Documentation"]}),e(O,{variant:"text",onClick:v,children:"Try example"}),e(O,{variant:"contained",onClick:p,startIcon:e(dt,{}),children:"Apply"})]})]})]})},hu=(t,r,n)=>{const a=[`flags=${encodeURIComponent(r)}`,`metrics=${encodeURIComponent(n)}`];return`${t}/retention-filters-debug?${a.join("&")}`},pu=()=>{const{serverUrl:t}=ne(),[r,n]=me(),[a,s]=b(new Map),[o,i]=b(!1),[l,c]=b(),[m,d]=b(),[u,h]=b(),p=Y(async(v,y)=>{if(c(y?"":"metrics are required"),d(v?"":"flags are required"),!y||!v)return;r.set("flags",v),r.set("metrics",y),n(r);const f=hu(t,v,y);i(!0);try{const _=await(await fetch(f)).json();s(new Map(Object.entries(_.result||{}))),c(_.error?.metrics||""),d(_.error?.flags||""),h("")}catch(g){g instanceof Error&&g.name!=="AbortError"&&h(`${g.name}: ${g.message}`)}i(!1)},[t]);return{data:a,error:u,metricsError:l,flagsError:m,loading:o,applyFilters:p}},La={flags:`-retentionPeriod=1y
-retentionFilter={env!="prod"}:2w
`,metrics:`up
up{env="dev"}
up{env="prod"}`},vu=()=>{const[t]=me(),{data:r,loading:n,error:a,metricsError:s,flagsError:o,applyFilters:i}=pu(),[l,c]=b(t.get("metrics")||""),[m,d]=b(t.get("flags")||""),u=Y(f=>{c(f)},[c]),h=Y(f=>{d(f)},[d]),p=Y(()=>{i(m,l)},[i,m,l]),v=Y(()=>{const{flags:f,metrics:g}=La;d(f),c(g),i(f,g),t.set("flags",f),t.set("metrics",g)},[La,d,c,t]);x(()=>{m&&l&&p()},[]);const y=[];for(const[f,g]of r)y.push(e("tr",{className:"vm-table__row",children:[e("td",{className:"vm-table-cell",children:f}),e("td",{className:"vm-table-cell",children:g})]}));return e("section",{className:"vm-retention-filters",children:[n&&e(Se,{}),e("div",{className:"vm-retention-filters-body vm-block",children:[e("div",{className:"vm-retention-filters-body__expr",children:[e("div",{className:"vm-retention-filters-body__title",children:e("p",{children:["Provide a list of flags for retention configuration. Note that only ",e("code",{children:"-retentionPeriod"})," and ",e("code",{children:"-retentionFilter"})," flags are supported."]})}),e(ie,{type:"textarea",label:"Flags",value:m,error:a||o,autofocus:!0,onEnter:p,onChange:h,placeholder:'-retentionPeriod=4w -retentionFilter=up{env="dev"}:2w'})]}),e("div",{className:"vm-retention-filters-body__expr",children:[e("div",{className:"vm-retention-filters-body__title",children:e("p",{children:"Provide a list of metrics to check retention configuration."})}),e(ie,{type:"textarea",label:"Metrics",value:l,error:a||s,onEnter:p,onChange:u,placeholder:`up{env="dev"}
up{env="prod"}
`})]}),e("div",{className:"vm-retention-filters-body__result",children:e("table",{className:"vm-table",children:[e("thead",{className:"vm-table-header",children:e("tr",{children:[e("th",{className:"vm-table-cell vm-table-cell_header",children:"Metric"}),e("th",{className:"vm-table-cell vm-table-cell_header",children:"Applied retention"})]})}),e("tbody",{className:"vm-table-body",children:y})]})}),e("div",{className:"vm-retention-filters-body-top",children:[e("a",{className:"vm-link vm-link_with-icon",target:"_blank",href:"https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#retention-filters",rel:"help noreferrer",children:[e(gt,{}),"Documentation"]}),e(O,{variant:"text",onClick:v,children:"Try example"}),e(O,{variant:"contained",onClick:p,startIcon:e(dt,{}),children:"Apply"})]})]})]})},fu=({hideQuery:t,showAllSeries:r})=>{const{query:n}=Pe(),{period:a}=he(),{displayType:s,reduceMemUsage:o,seriesLimits:i}=$e(),{serverUrl:l}=ne(),{showInfoMessage:c}=Vn(),[m,d]=b(!1),[u,h]=b(),[p,v]=b(),[y,f]=b([]),[g,_]=b(),C=Z(new AbortController),w=D(()=>{if(v(""),f([]),!!a)if(!l)v(ge.emptyServer);else if(n.every(E=>!E.trim()))f(n.map(()=>ge.validQuery));else if(yr(l)){const E={...a};return n.map(M=>Sc(l,M,E,o))}else v(ge.validServer)},[l,a,t,o]),N=D(()=>{const E=M=>`vmui_export_${n.join("_")}_${a.start}_${a.end}.${M}`;return{csv:async()=>{const M=Tc(l,n,a,o),I=await fetch(M);try{let k=await I.text();k=`name,value,timestamp
`+k,qs(k,E("csv"))}catch(k){console.error(k),c({text:"Couldn't fetch data for CSV export. Please try again",type:"error"})}},json:async()=>{const M=Ec(l,n,a,o);try{const k=await(await fetch(M)).text();jr(k,E("json"))}catch(I){console.error(I),c({text:"Couldn't fetch data for JSON export. Please try again",type:"error"})}}}},[n,a,l,o]),S=Y(async({fetchUrl:E,stateSeriesLimits:M,showAllSeries:I})=>{C.current.abort(),C.current=new AbortController;const{signal:k}=C.current;d(!0);try{const L=Math.floor(window.innerWidth/4),$=30*1024*1024,V=[],H=I?1/0:+M[s]||1/0;let z=1,j=0;for await(const X of E){if(t?.includes(z-1)){f(P=>[...P,""]),z++;continue}const ae=await fetch(X,{signal:k}),le=await ae.text();if(new TextEncoder().encode(le).length>$){const P="Response too large to display (over 30 MiB). Please narrow your query.";v(P),f(U=>[...U,P]);continue}if(!ae.ok||!ae.body)V.push({metric:{},values:[],group:z}),v(le),f(P=>[...P,`${le}`]);else{f(re=>[...re,""]);const P=H-V.length,U=le.split(`
`).filter(re=>re),J=U.slice(0,P).sort();for(const re of J){const se=vo(re);if(!se)continue;const{values:ce,timestamps:He}=se,ye=ce.length,Le=ye>L,et=Le?L:ye,Te=Le?ye/L:1,wt=Array.from({length:et},(ke,_e)=>{const ve=Le?Math.floor(_e*Te):_e;return[He[ve]/1e3,ce[ve]]});V.push({group:z,metric:se.metric,values:wt})}j+=U.length}z++}const ee=`Showing ${V.length} series out of ${j} series due to performance reasons. Please narrow down the query, so it returns fewer series`;_(j>H?ee:""),h(V),d(!1)}catch(L){d(!1),L instanceof Error&&L.name!=="AbortError"&&(v(String(L)),console.error(L))}},[s,t]),A=Y(E=>{if(p)return;const M={...a};N[E](l,n,M,o)},[l,n,a,o,p,N]),T=Y(()=>{C.current.abort(),h([])},[C]);return x(()=>{if(!w?.length)return;const E=setTimeout(S,400,{fetchUrl:w,stateSeriesLimits:i,showAllSeries:r});return()=>{C.current?.abort(),clearTimeout(E)}},[w,i,r]),{fetchUrl:w,isLoading:m,data:u,error:p,queryErrors:y,setQueryErrors:f,warning:g,abortFetch:T,exportData:A}},gu=()=>e(Ce,{href:"https://docs.victoriametrics.com/victoriametrics/keyconcepts/#raw-samples",underlined:!0,children:"raw samples"}),bu=()=>e(Ce,{underlined:!0,href:"https://docs.victoriametrics.com/victoriametrics/keyconcepts/#query-data",children:"Query API"}),yu=()=>e(Ce,{underlined:!0,href:"https://docs.victoriametrics.com/victoriametrics/keyconcepts/#filtering",children:"time series selector"}),_u=()=>{Hs();const{isMobile:t}=W(),{displayType:r}=$e(),{query:n}=Pe(),[a,s]=b([]),[o,i]=b(!n[0]),[l,c]=b(!1),[m,d]=b(!0),{data:u,error:h,isLoading:p,warning:v,queryErrors:y,setQueryErrors:f,abortFetch:g,exportData:_}=fu({hideQuery:a,showAllSeries:l}),C=Z(null),w=!o&&h,N=E=>{s(E)},S=()=>{i(!1)},A=()=>{d(!1)},T=Y(async E=>{E&&_(E)},[_]);return e("div",{className:R({"vm-custom-panel":!0,"vm-custom-panel_mobile":t}),children:[e(Ps,{label:"Time series selector",queryErrors:o?[]:y,setQueryErrors:f,setHideError:i,stats:[],isLoading:p,onHideQuery:N,onRunQuery:S,abortFetch:g,hideButtons:{traceQuery:!0,disableCache:!0},includeFunctions:!1}),m&&e(te,{variant:"info",children:e("div",{className:"vm-explore-metrics-header-description",children:[e("ul",{children:[e("li",{children:["This page provides a dedicated view for querying and displaying ",e(gu,{})," from VictoriaMetrics."]}),e("li",{children:["It expects only ",e(yu,{})," as a query argument."]}),e("li",{children:["Deduplication can only be disabled if it was previously enabled on the server (",e("code",{children:"-dedup.minScrapeInterval"}),")."]}),e("li",{children:["Users often assume that the ",e(bu,{})," returns data exactly as stored, but data samples and timestamps may be modified by the API."]})]}),e(O,{variant:"text",size:"small",startIcon:e(De,{}),onClick:A,ariaLabel:"close tips"})]})}),w&&e(te,{variant:"error",children:h}),v&&e(jn,{warning:v,query:n,onChange:c}),e("div",{className:R({"vm-custom-panel-body":!0,"vm-custom-panel-body_mobile":t,"vm-block":!0,"vm-block_mobile":t}),children:[p&&e(Os,{}),e("div",{className:"vm-custom-panel-body-header",ref:C,children:[e("div",{className:"vm-custom-panel-body-header__tabs",children:e(Ns,{tabFilter:E=>E.value!==pe.table})}),u&&e(go,{title:"Export query",downloadFormatOptions:["json","csv"],onDownload:T})]}),e(po,{graphData:u,liveData:u,isHistogram:!1,displayType:r,controlsRef:C})]})]})},Cu=({types:t,states:r,search:n,rule_id:a,alert_id:s,group_id:o})=>{const{setSearchParamsFromKeys:i}=nt();x(()=>{const c=Yr({types:t,states:r,search:n,alert_id:s,rule_id:a,group_id:o});i(c)},[t,r,n,a,o,s])},Nu=({kinds:t,search:r})=>{const{setSearchParamsFromKeys:n}=nt();x(()=>{const s=Yr({kinds:t,search:r});n(s)},[t,r])},wu=t=>`${t}/vmalert/api/v1/rules?datasource_type=prometheus`,Su=(t,r,n,a)=>`${t}/vmalert/api/v1/${a}?group_id=${r}&${a}_id=${n}`,Tu=(t,r)=>`${t}/vmalert/api/v1/group?group_id=${r}`,Eu=t=>`${t}/vmalert/api/v1/notifiers`,xu=({blockFetch:t})=>{const{serverUrl:r}=ne(),{period:n}=he(),[a,s]=b([]),[o,i]=b(!1),[l,c]=b(),m=D(()=>wu(r),[r]),d=!!a.length||!t;return x(()=>{if(t)return;(async()=>{i(!0);try{const h=await fetch(m),p=await h.json();if(h.ok){const v=p.data.groups||[];s(v.sort((y,f)=>y.name.localeCompare(f.name))),c(void 0)}else c(`${p.errorType}\r
${p?.error}`)}catch(h){h instanceof Error&&c(`${h.name}: ${h.message}`)}i(!1)})().catch(console.error)},[m,n,d]),{groups:a,isLoading:o,error:l}},Au=({types:t,allTypes:r,allStates:n,states:a,search:s,onChangeTypes:o,onChangeStates:i,onChangeSearch:l})=>{const c=D(()=>t.length?"":"No states. Please select rule states",[t]),{isMobile:m}=W();return e(q,{children:e("div",{className:R({"vm-explore-alerts-header":!0,"vm-explore-alerts-header_mobile":m,"vm-block":!0,"vm-block_mobile":m}),children:[e("div",{className:"vm-explore-alerts-header__rule_type",children:e(ot,{value:t,list:r,label:"Rules type",placeholder:"Please select rule type",onChange:o,autofocus:!!t.length&&!m,includeAll:!0,searchable:!0})}),e("div",{className:"vm-explore-alerts-header__state",children:e(ot,{itemClassName:"vm-badge-menu-item",value:a,list:n,label:"State",placeholder:"Please select rule state",onChange:i,noOptionsText:c,includeAll:!0,searchable:!0})}),e("div",{className:"vm-explore-alerts-header-search",children:e(ie,{label:"Search",value:s,placeholder:"Filter by rule, name or labels",startIcon:e(Rt,{}),onChange:l})})]})})},Ue=({items:t,children:r,align:n="start"})=>e("div",{className:"vm-badges",style:{"justify-content":n},children:[Object.entries(t).map(([a,s])=>e("span",{className:`vm-badge ${s.color}`,children:s.value?`${a}: ${s.value}`:a},a)),r]}),Lu=({group:t})=>{const{isMobile:r}=W(),n=Mt(),a=async()=>{n({pathname:"/rules",search:`group_id=${t.id}`})},s=R({"vm-explore-alerts-group-header":!0,"vm-explore-alerts-group-header_mobile":r});return e("div",{className:s,children:[e("div",{className:"vm-explore-alerts-group-header__desc",children:[e("div",{className:"vm-explore-alerts-group-header__name",children:t.name}),!r&&e("div",{className:"vm-explore-alerts-group-header__file",children:t.file})]}),e("div",{className:"vm-explore-alerts-controls",children:[e(Ue,{align:"end",items:Object.fromEntries(Object.entries(t.states||{}).map(([o,i])=>[o.toLowerCase(),{color:o.toLowerCase().replace(" ","-"),value:i}]))}),e(O,{className:"vm-button-borderless",size:"small",color:"gray",variant:"outlined",startIcon:e(Hr,{}),onClick:a})]})]})},Jr=({name:t,id:r,groupId:n,entity:a,type:s,states:o,onClose:i})=>{const{isMobile:l}=W(),{serverUrl:c}=ne(),m=Mt(),d=Ke(),u=()=>{m({pathname:"/rules",search:`group_id=${n}&${a}_id=${r}`})},h=async()=>{let f=`${c}/vmui/#/rules?group_id=${n}`;s&&(f=`${f}&${a}_id=${r}`),await d(f,`Link to ${a} has been copied`)},p=R({"vm-explore-alerts-item-header":!0,"vm-explore-alerts-item-header_mobile":l}),v=()=>{switch(a){case"alert":return e(G,{title:"Alert",children:e(Ka,{})});case"group":return e(G,{title:"Group",children:e(Wa,{})});default:return s==="alerting"?e(G,{title:"Alerting rule",children:e(Ja,{})}):e(G,{title:"Recording rule",children:e(Za,{})})}},y=D(()=>Object.fromEntries(Object.entries(o||{}).map(([f,g])=>[f,{color:f.toLowerCase().replace(" ","-"),value:g==1?0:g}])),[o]);return e("div",{className:p,id:`rule-${r}`,children:[e("div",{className:"vm-explore-alerts-item-header__title",children:[v(),e("div",{className:"vm-explore-alerts-item-header__name",children:t})]}),e("div",{className:"vm-explore-alerts-controls",children:[e(Ue,{align:"end",items:y}),i?e(O,{className:"vm-back-button",size:"small",variant:"outlined",color:"gray",startIcon:e(Ga,{}),onClick:h,children:e("span",{className:"vm-button-text",children:"Copy Link"})}):e(O,{className:"vm-button-borderless",size:"small",variant:"outlined",color:"gray",startIcon:e(Hr,{}),onClick:u})]})]})},Bt=t=>{const r=Q.duration(Math.round(t*1e3)),n=[];return r.get("day")&&n.push("D[d]"),r.get("hour")&&n.push("H[h]"),r.get("minute")&&n.push("m[m]"),r.get("millisecond")?n.push("s.SSS[s]"):(!n.length||r.get("second"))&&n.push("s[s]"),r.format(n.join(" "))},xt=t=>{const r=Q(t);return r.year()<=1?"Never":r.format("DD MMM YYYY HH:mm:ss")},yo=({item:t})=>{const r=t?.query,n=Mt(),a=l=>()=>{n({pathname:"/rules",search:`group_id=${t.group_id}&alert_id=${l}`})},s=t?.labels||{},o=D(()=>Object.fromEntries(Object.entries(s).map(([l,c])=>[l,{color:"passive",value:c}])),[s]);return e("div",{className:"vm-explore-alerts-rule-item",children:[e("table",{children:[e("colgroup",{children:[e("col",{className:"vm-col-md"}),e("col",{})]}),e("tbody",{children:[e("tr",{children:e("td",{style:{"text-align":"end"},colSpan:2,children:e(O,{size:"small",variant:"outlined",color:"gray",startIcon:e(Rt,{}),onClick:()=>{const l={"g0.expr":r,"g0.end_time":""};window.open(`#/?${Da(l).toString()}`,"_blank","noopener noreferrer")},children:e("span",{className:"vm-button-text",children:"Run query"})})})}),e("tr",{children:[e("td",{children:"Query"}),e("td",{children:e(Qe,{code:r})})]}),!!t.duration&&e("tr",{children:[e("td",{children:"For"}),e("td",{children:Bt(t.duration)})]}),e("tr",{children:[e("td",{children:"Last evaluation"}),e("td",{children:xt(t.lastEvaluation)})]}),!!t.lastError&&t.health!=="ok"&&e("tr",{children:[e("td",{children:"Last error"}),e("td",{children:e(te,{variant:"error",children:t.lastError})})]}),!!Object.keys(o).length&&e("tr",{children:[e("td",{children:"Labels"}),e("td",{children:e(Ue,{items:o})})]})]})]}),!!Object.keys(t?.annotations||{}).length&&e(q,{children:[e("span",{className:"vm-alerts-title",children:"Annotations"}),e("table",{children:[e("colgroup",{children:[e("col",{className:"vm-col-md"}),e("col",{})]}),e("tbody",{children:Object.entries(t.annotations||{}).map(([l,c])=>e("tr",{children:[e("td",{children:l}),e("td",{children:c})]},l))})]})]}),!!t?.updates?.length&&e(q,{children:[e("span",{className:"vm-alerts-title",children:`Last updates ${t.updates.length}/${t.max_updates_entries}`}),e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"Updated at"}),e("th",{children:"Series returned"}),e("th",{children:"Series fetched"}),e("th",{children:"Duration"}),e("th",{children:"Execution timestamp"})]})}),e("tbody",{children:t.updates.map(l=>e("tr",{children:[e("td",{children:xt(l.time)}),e("td",{children:l.samples}),e("td",{children:l.series_fetched}),e("td",{children:Bt(l.duration/1e9)}),e("td",{children:xt(l.at)})]},l.at))})]})]}),!!t?.alerts?.length&&e(q,{children:[e("span",{className:"vm-alerts-title",children:"Alerts"}),e("table",{className:"vm-alerts-table",children:[e("colgroup",{children:[e("col",{className:"vm-col-sm"}),e("col",{className:"vm-col-sm"}),e("col",{className:"vm-col-sm"}),e("col",{}),e("col",{className:"vm-col-hidden"})]}),e("thead",{children:e("tr",{children:[e("th",{children:"Active since"}),e("th",{children:"State"}),e("th",{children:"Value"}),e("th",{className:"vm-alerts-title",children:"Labels"}),e("th",{})]})}),e("tbody",{children:t.alerts.map(l=>e("tr",{id:`alert-${l.id}`,children:[e("td",{children:xt(l.activeAt)}),e("td",{children:e(Ue,{items:{[l.state]:{color:l.state}}})}),e("td",{children:e(Ue,{items:{[l.value]:{color:"passive"}}})}),e("td",{children:e(Ue,{align:"start",items:Object.fromEntries(Object.entries(l.labels||{}).map(([c,m])=>[c,{color:"passive",value:m}]))})}),e("td",{children:e(O,{className:"vm-button-borderless",size:"small",variant:"outlined",color:"gray",startIcon:e(Hr,{}),onClick:a(l.id)})})]},l.id))})]})]})]})},ku=({states:t,rule:r})=>{const n=Object.keys(t).length>0?Object.keys(t)[0]:"ok";return e("div",{className:`vm-explore-alerts-rule vm-badge-item ${n.replace(" ","-")}`,children:e(Nt,{title:e(Jr,{entity:"rule",type:r.type,groupId:r.group_id,states:t,id:r.id,name:r.name}),children:e(yo,{item:r})},`rule-${r.id}`)})},_o=({groupId:t,id:r,mode:n})=>{const{serverUrl:a}=ne(),{period:s}=he(),[o,i]=b(),[l,c]=b(!1),[m,d]=b(),u=D(()=>Su(a,t,r,n),[a,t,r,n]);return x(()=>{(async()=>{c(!0);try{const p=await fetch(u),v=await p.json();p.ok?(i(v),d(void 0)):d(`${v.errorType}\r
${v?.error}`)}catch(p){p instanceof Error&&d(`${p.name}: ${p.message}`)}c(!1)})().catch(console.error)},[u,s]),{item:o,isLoading:l,error:m}},bn=(t,r)=>{if(t==="All")return[];const n=new Set(r);return n.has(t)?n.delete(t):n.add(t),Array.from(n)},Co=t=>{let r=t?.state||"ok";return t?.health!=="ok"?r="unhealthy":!t?.lastSamples&&!t?.lastSeriesFetched&&(r="no match"),r},No=t=>{const r={};return(t?.alerts?.length||0)>0?t.alerts.forEach(a=>{a.state in r?r[a.state]+=1:r[a.state]=1}):r[Co(t)]=1,r},Mu=(t,r,n,a)=>{const s=new Set,o=new Set,i=[];return t.forEach(l=>{const c=[],m={};if(l.rules.forEach(d=>{const u=d.type.charAt(0).toUpperCase()+d.type.slice(1);if(s.add(u),r?.length&&!r.includes(u))return;const h=Co(d),p=h.charAt(0).toUpperCase()+h.slice(1);if(o.add(p),n?.length&&!n.includes(p)||a&&!d.name.toLowerCase().includes(a.toLowerCase())&&!l.name.toLowerCase().includes(a.toLowerCase())&&!l.file.toLowerCase().includes(a.toLowerCase())||(c.push(d),h!=="no match"&&h!=="unhealthy"&&h!=="firing"&&h!=="pending"))return;const v=h==="firing"||h==="pending"?d?.alerts?.length:1;p in m?m[p]+=v:m[p]=v}),c.length){const d=Object.assign({},l);d.rules=c,d.states=m,i.push(d)}}),{filteredGroups:i,allTypes:s,allStates:o}},Iu=({groupId:t,id:r,mode:n,onClose:a})=>{const{item:s,isLoading:o,error:i}=_o({groupId:t,id:r,mode:n});if(o)return e(Se,{});if(i)return e(te,{variant:"error",children:i});const l=`No rule with group ID=${t}, rule ID=${r} found!`;return e(we,{className:"vm-explore-alerts",title:s?e(Jr,{entity:"rule",type:s.type,groupId:s.group_id,states:No(s),id:s.id,name:s.name,onClose:a}):"Rule not found",onClose:a,children:e("div",{className:"vm-explore-alerts",children:s&&e(yo,{item:s})||e(te,{variant:"info",children:l})})})},Du=({item:t})=>{const r=t?.expression,n=t?.labels||{},a=D(()=>Object.fromEntries(Object.entries(n).map(([o,i])=>[o,{color:"passive",value:i}])),[n]);return e("div",{className:"vm-explore-alerts-alert-item",children:[e("table",{children:[e("colgroup",{children:[e("col",{className:"vm-col-md"}),e("col",{})]}),e("tbody",{children:[e("tr",{children:e("td",{style:{"text-align":"end"},colSpan:2,children:e(O,{size:"small",variant:"outlined",color:"gray",startIcon:e(Rt,{}),onClick:()=>{const o={"g0.expr":r,"g0.end_time":""};window.open(`#/?${Da(o).toString()}`,"_blank","noopener noreferrer")},children:e("span",{className:"vm-button-text",children:"Run query"})})})}),e("tr",{children:[e("td",{children:"Query"}),e("td",{children:e(Qe,{code:r})})]}),e("tr",{children:[e("td",{children:"Active at"}),e("td",{children:xt(t.activeAt)})]}),!!Object.keys(n).length&&e("tr",{children:[e("td",{children:"Labels"}),e("td",{children:e(Ue,{items:a})})]})]})]}),!!Object.keys(t.annotations||{}).length&&e(q,{children:[e("span",{className:"vm-alerts-title",children:"Annotations"}),e("table",{children:[e("colgroup",{children:[e("col",{className:"vm-col-md"}),e("col",{})]}),e("tbody",{children:Object.entries(t.annotations||{}).map(([o,i])=>e("tr",{children:[e("td",{children:o}),e("td",{children:i})]},o))})]})]})]})},Ru=({groupId:t,id:r,mode:n,onClose:a})=>{const{item:s,isLoading:o,error:i}=_o({groupId:t,id:r,mode:n});if(o)return e(Se,{});if(i)return e(te,{variant:"error",children:i});const l=`No alert with group ID=${t}, alert ID=${r} found!`,c={firing:1};return e(we,{className:"vm-explore-alerts",title:s?e(Jr,{entity:"alert",type:"alerting",groupId:s.group_id,id:s.id,name:s.name,states:c,onClose:a}):"Alert not found",onClose:a,children:e("div",{className:"vm-explore-alerts",children:s&&e(Du,{item:s})||e(te,{variant:"info",children:l})})})},Pu=({id:t})=>{const{serverUrl:r}=ne(),{period:n}=he(),[a,s]=b(),[o,i]=b(!1),[l,c]=b(),m=D(()=>Tu(r,t),[r,t]);return x(()=>{(async()=>{i(!0);try{const u=await fetch(m);if(u.headers.get("Content-Type")==="application/json"){const h=await u.json();u.ok?(s(h),c(void 0)):c(`${h.errorType}\r
${h?.error}`)}else{let h=await u.text();h.startsWith("unsupported path requested")?h=`Failed to show group details. Request to ${m} failed with error: ${h.trim()}.
Make sure that vmalert is reachable at ${m} and is of the same or higher version than vmselect`:h=`${u.statusText}\r
${h}`,c(h)}}catch(u){u instanceof Error&&c(`${u.name}: ${u.message}`)}i(!1)})().catch(console.error)},[m,n]),{group:a,isLoading:o,error:l}},$u=({group:t})=>{const r=t?.labels||{},n=D(()=>Object.fromEntries(Object.entries(r).map(([m,d])=>[m,{color:"passive",value:d}])),[r]),a=t?.params||[],s=D(()=>Object.fromEntries(a.map(m=>[m,{color:"passive"}])),[a]),o=t?.headers||[],i=D(()=>Object.fromEntries(o.map(m=>[m,{color:"passive"}])),[o]),l=t?.notifier_headers||[],c=D(()=>Object.fromEntries(l.map(m=>[m,{color:"passive"}])),[l]);return e("div",{className:"vm-explore-alerts-group",children:e("table",{children:e("tbody",{children:[!!t.interval&&e("tr",{children:[e("td",{className:"vm-col-md",children:"Interval"}),e("td",{children:Bt(t.interval)})]}),e("tr",{children:[e("td",{className:"vm-col-md",children:"Last evaluation"}),e("td",{children:xt(t.lastEvaluation)})]}),!!t.eval_offset&&e("tr",{children:[e("td",{className:"vm-col-md",children:"Eval offset"}),e("td",{children:Bt(t.eval_offset)})]}),!!t.eval_delay&&e("tr",{children:[e("td",{className:"vm-col-md",children:"Eval delay"}),e("td",{children:Bt(t.eval_delay)})]}),!!t.file&&e("tr",{children:[e("td",{className:"vm-col-md",children:"File"}),e("td",{children:t.file})]}),!!t.concurrency&&e("tr",{children:[e("td",{className:"vm-col-md",children:"Concurrency"}),e("td",{children:t.concurrency})]}),!!Object.keys(r).length&&e("tr",{children:[e("td",{className:"vm-col-md",children:"Labels"}),e("td",{children:e(Ue,{items:n})})]}),!!a.length&&e("tr",{children:[e("td",{className:"vm-col-md",children:"Params"}),e("td",{children:e(Ue,{items:s})})]}),!!o.length&&e("tr",{children:[e("td",{className:"vm-col-md",children:"Headers"}),e("td",{children:e(Ue,{items:i})})]}),!!l.length&&e("tr",{children:[e("td",{className:"vm-col-md",children:"Notifier headers"}),e("td",{children:e(Ue,{items:c})})]})]})})})},Ou=({id:t,onClose:r})=>{const{group:n,isLoading:a,error:s}=Pu({id:t});if(a)return e(Se,{});if(s)return e(te,{variant:"error",children:s});const o=`No group ID=${t} found!`;return e(we,{className:"vm-explore-alerts",title:n?e(Jr,{entity:"group",groupId:t,name:n.name,states:n.states,onClose:r}):"Rule not found",onClose:r,children:e("div",{className:"vm-explore-alerts",children:n&&e($u,{group:n})||e(te,{variant:"info",children:o})})})},Hu=ue("types",""),zu=Hu.split("&").filter(t=>t),Fu=ue("states",""),Vu=Fu.split("&").filter(t=>t),Uu=ue("search",""),qu=()=>{const t=ue("group_id",""),r=ue("rule_id",""),n=ue("alert_id",""),[a,s]=b(Uu),[o,i]=b(zu),[l,c]=b(Vu),[m,d]=b(!0),[u,h]=me();x(()=>{d(!!t)},[t]),Cu({types:o.join("&"),states:l.join("&"),search:a,group_id:t,alert_id:n,rule_id:r});const p=Y(I=>{s(I||"")},[a]),v=()=>{if(r)return e(Iu,{groupId:t,id:r,mode:r?"rule":"alert",onClose:f});if(n)return e(Ru,{groupId:t,id:n,mode:r?"rule":"alert",onClose:f});if(t)return e(Ou,{id:t,onClose:f})},y="No rules found!",f=()=>{const I=new URLSearchParams(u);I.delete("group_id"),I.delete("rule_id"),I.delete("alert_id"),h(I),d(!1)},{groups:g,isLoading:_,error:C}=xu({blockFetch:m}),{filteredGroups:w,allTypes:N,allStates:S}=D(()=>Mu(g||[],o,l,a),[g,o,l,a]);o.every(I=>N.has(I))||i([]);const A=N.size===o.length?[]:o;l.every(I=>S.has(I))||c([]);const T=S.size===l.length?[]:l,E=Y(I=>{c(bn(I,T))},[l]),M=Y(I=>{i(bn(I,A))},[o]);return e(q,{children:[m&&v(),(!m||!!S?.size)&&e("div",{className:"vm-explore-alerts",children:[e(Au,{types:A,allTypes:Array.from(N),states:T,allStates:Array.from(S),search:a,onChangeTypes:M,onChangeStates:E,onChangeSearch:Dt(p,500)}),_&&e(Se,{})||C&&e(te,{variant:"error",children:C})||!w.length&&e(te,{variant:"info",children:y})||e("div",{className:"vm-explore-alerts-body",children:w.map(I=>e("div",{className:"vm-explore-alert-group vm-block vm-block_empty-padding",children:e(Nt,{id:`group-${I.id}`,title:e(Lu,{group:I}),children:e("div",{className:"vm-explore-alerts-items",children:I.rules.map(k=>e(ku,{rule:k,states:No(k)},`rule-${k.id}`))})},`group-${I.id}`)},I.id))})]})]})},Bu=()=>{const{serverUrl:t}=ne(),{period:r}=he(),[n,a]=b([]),[s,o]=b(!1),[i,l]=b(),c=D(()=>Eu(t),[t]);return x(()=>{(async()=>{o(!0);try{const d=await fetch(c),u=await d.json();if(d.ok){const h=u.data.notifiers||[];a(h.sort((p,v)=>p.kind.localeCompare(v.kind))),l(void 0)}else l(`${u.errorType}\r
${u?.error}`)}catch(d){d instanceof Error&&l(`${d.name}: ${d.message}`)}o(!1)})().catch(console.error)},[c,r]),{notifiers:n,isLoading:s,error:i}},Qu=({kinds:t,allKinds:r,search:n,onChangeKinds:a,onChangeSearch:s})=>{const{isMobile:o}=W();return e(q,{children:e("div",{className:R({"vm-explore-alerts-header":!0,"vm-explore-alerts-header_mobile":o,"vm-block":!0,"vm-block_mobile":o}),children:[e("div",{className:"vm-explore-alerts-header__rule_type",children:e(ot,{value:t,list:r,label:"Notifier type",placeholder:"Please select notifier type",onChange:a,autofocus:!!t.length&&!o,includeAll:!0,searchable:!0})}),e("div",{className:"vm-explore-alerts-header-search",children:e(ie,{label:"Search",value:n,placeholder:"Filter by kind, address or labels",startIcon:e(Rt,{}),onChange:s})})]})})},ju=({notifier:t})=>{const{isMobile:r}=W();return e("div",{className:R({"vm-explore-alerts-notifier-header":!0,"vm-explore-alerts-notifier-header_mobile":r}),children:e("div",{className:"vm-explore-alerts-notifier-header__name",children:t.kind})})},Yu=({target:t})=>{const r=t?.lastError?"unhealthy":"ok",n=t?.labels||{},a=D(()=>Object.fromEntries(Object.entries(n).map(([s,o])=>[s,{value:o,color:"passive"}])),[n]);return e("div",{className:`vm-explore-alerts-target vm-badge-item ${r.replace(" ","-")}`,children:t?.labels?.length||t?.lastError?e(Nt,{title:e("div",{className:"vm-explore-alerts-target-header__name",children:t.address}),children:e("div",{className:"vm-explore-alerts-target-item",children:e("table",{children:e("tbody",{children:[!!Object.keys(n).length&&e("tr",{children:[e("td",{className:"vm-col-md",children:"Labels"}),e("td",{children:e(Ue,{items:a})})]}),!!t.lastError&&e("tr",{children:[e("td",{className:"vm-col-md",children:"Last error"}),e("td",{children:e(te,{variant:"error",children:t.lastError})})]})]})})})},`target-${t.address}`):e("span",{children:t.address})})},Gu=ue("kinds",""),Wu=Gu.split("&").filter(t=>t),Ku=ue("search",""),Ju=()=>{const{notifiers:t,isLoading:r,error:n}=Bu(),[a,s]=b(Ku),[o,i]=b(Wu);Nu({kinds:o.join("&"),search:a});const l=u=>{s(u||"")},c=new Set,m=[];t.forEach(u=>{const h=[];if((u.targets||[]).forEach(v=>{c.add(u.kind),!(o?.length&&!o.includes(u.kind))&&(a&&!v.address.toLowerCase().includes(a.toLowerCase())&&!u.kind.toLowerCase().includes(a.toLowerCase())||h.push(v))}),h.length){const v=Object.assign({},u);v.targets=h,m.push(v)}});const d=u=>{i(bn(u,o))};return e("div",{className:"vm-explore-alerts",children:[e(Qu,{kinds:o,allKinds:Array.from(c),search:a,onChangeKinds:d,onChangeSearch:Dt(l,500)}),r&&e(Se,{})||n&&e(te,{variant:"error",children:n})||!m.length&&e(te,{variant:"info",children:"No notifiers found!"})||e("div",{className:"vm-explore-alerts-body",children:m.map(u=>e("div",{className:"vm-explore-alert-group vm-block vm-block_empty-padding",children:e(Nt,{id:`notifier-${u.kind}`,title:e(ju,{notifier:u}),children:e("div",{className:"vm-explore-alerts-items",children:u.targets.map(h=>e(Yu,{target:h},`target-${h.address}`))})},`notifier-${u.kind}`)},u.kind))})]})},Zu=()=>{const[t,r]=b(!1);return e(q,{children:e(Io,{children:e(Ui,{children:e(q,{children:[e(xm,{onLoaded:r}),t&&e(Do,{children:e(fe,{path:"/",element:e(Bl,{}),children:[e(fe,{path:K.home,element:e(qd,{})}),e(fe,{path:K.rawQuery,element:e(_u,{})}),e(fe,{path:K.metrics,element:e(Bm,{})}),e(fe,{path:K.cardinality,element:e(gm,{})}),e(fe,{path:K.topQueries,element:e(Tm,{})}),e(fe,{path:K.trace,element:e(Am,{})}),e(fe,{path:K.queryAnalyzer,element:e(cu,{})}),e(fe,{path:K.dashboards,element:e(Yd,{})}),e(fe,{path:K.withTemplate,element:e(Km,{})}),e(fe,{path:K.relabel,element:e(eu,{})}),e(fe,{path:K.activeQueries,element:e(au,{})}),e(fe,{path:K.icons,element:e(Qm,{})}),e(fe,{path:K.downsamplingDebug,element:e(uu,{})}),e(fe,{path:K.retentionDebug,element:e(vu,{})}),e(fe,{path:K.rules,element:e(qu,{})}),e(fe,{path:K.notifiers,element:e(Ju,{})})]})})]})})})})},ka=document.getElementById("root");ka&&Ro(e(Zu,{}),ka);