/*! For license information please see module.js.LICENSE.txt */ /* [create-plugin] version: 5.11.1 */ define(["@emotion/css","@grafana/data","@grafana/runtime","@grafana/ui","d3","lodash","module","react","react-dom","react-router","rxjs"],((__WEBPACK_EXTERNAL_MODULE__6089__,__WEBPACK_EXTERNAL_MODULE__7781__,__WEBPACK_EXTERNAL_MODULE__8531__,__WEBPACK_EXTERNAL_MODULE__2007__,__WEBPACK_EXTERNAL_MODULE__4201__,__WEBPACK_EXTERNAL_MODULE__3241__,__WEBPACK_EXTERNAL_MODULE__1308__,__WEBPACK_EXTERNAL_MODULE__5959__,__WEBPACK_EXTERNAL_MODULE__8398__,__WEBPACK_EXTERNAL_MODULE__1159__,__WEBPACK_EXTERNAL_MODULE__1269__)=>(()=>{var __webpack_modules__={6233:e=>{"use strict";e.exports=function(e,t){var n=new Array(arguments.length-1),r=0,i=2,a=!0;for(;i{"use strict";var n=t;n.length=function(e){var t=e.length;if(!t)return 0;for(var n=0;--t%4>1&&"="===e.charAt(t);)++n;return Math.ceil(3*e.length)/4-n};for(var r=new Array(64),i=new Array(123),a=0;a<64;)i[r[a]=a<26?a+65:a<52?a+71:a<62?a-4:a-59|43]=a++;n.encode=function(e,t,n){for(var i,a=null,o=[],s=0,l=0;t>2],i=(3&c)<<4,l=1;break;case 1:o[s++]=r[i|c>>4],i=(15&c)<<2,l=2;break;case 2:o[s++]=r[i|c>>6],o[s++]=r[63&c],l=0}s>8191&&((a||(a=[])).push(String.fromCharCode.apply(String,o)),s=0)}return l&&(o[s++]=r[i],o[s++]=61,1===l&&(o[s++]=61)),a?(s&&a.push(String.fromCharCode.apply(String,o.slice(0,s))),a.join("")):String.fromCharCode.apply(String,o.slice(0,s))};var o="invalid encoding";n.decode=function(e,t,n){for(var r,a=n,s=0,l=0;l1)break;if(void 0===(c=i[c]))throw Error(o);switch(s){case 0:r=c,s=1;break;case 1:t[n++]=r<<2|(48&c)>>4,r=c,s=2;break;case 2:t[n++]=(15&r)<<4|(60&c)>>2,r=c,s=3;break;case 3:t[n++]=(3&r)<<6|c,s=0}}if(1===s)throw Error(o);return n-a},n.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},7669:e=>{"use strict";function t(e,n){"string"==typeof e&&(n=e,e=void 0);var r=[];function i(e){if("string"!=typeof e){var n=a();if(t.verbose,n="return "+n,e){for(var o=Object.keys(e),s=new Array(o.length+1),l=new Array(o.length),c=0;c{"use strict";function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,n){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:n||this}),this},t.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var n=this._listeners[e],r=0;r{"use strict";e.exports=a;var r=n(6233),i=n(1925)("fs");function a(e,t,n){return"function"==typeof t?(n=t,t={}):t||(t={}),n?!t.xhr&&i&&i.readFile?i.readFile(e,(function(r,i){return r&&"undefined"!=typeof XMLHttpRequest?a.xhr(e,t,n):r?n(r):n(null,t.binary?i:i.toString("utf8"))})):a.xhr(e,t,n):r(a,this,e,t)}a.xhr=function(e,t,n){var r=new XMLHttpRequest;r.onreadystatechange=function(){if(4===r.readyState){if(0!==r.status&&200!==r.status)return n(Error("status "+r.status));if(t.binary){var e=r.response;if(!e){e=[];for(var i=0;i{"use strict";function t(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),n=new Uint8Array(t.buffer),r=128===n[3];function i(e,r,i){t[0]=e,r[i]=n[0],r[i+1]=n[1],r[i+2]=n[2],r[i+3]=n[3]}function a(e,r,i){t[0]=e,r[i]=n[3],r[i+1]=n[2],r[i+2]=n[1],r[i+3]=n[0]}function o(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],t[0]}function s(e,r){return n[3]=e[r],n[2]=e[r+1],n[1]=e[r+2],n[0]=e[r+3],t[0]}e.writeFloatLE=r?i:a,e.writeFloatBE=r?a:i,e.readFloatLE=r?o:s,e.readFloatBE=r?s:o}():function(){function t(e,t,n,r){var i=t<0?1:0;if(i&&(t=-t),0===t)e(1/t>0?0:2147483648,n,r);else if(isNaN(t))e(2143289344,n,r);else if(t>34028234663852886e22)e((i<<31|2139095040)>>>0,n,r);else if(t<11754943508222875e-54)e((i<<31|Math.round(t/1401298464324817e-60))>>>0,n,r);else{var a=Math.floor(Math.log(t)/Math.LN2);e((i<<31|a+127<<23|8388607&Math.round(t*Math.pow(2,-a)*8388608))>>>0,n,r)}}function o(e,t,n){var r=e(t,n),i=2*(r>>31)+1,a=r>>>23&255,o=8388607&r;return 255===a?o?NaN:i*(1/0):0===a?1401298464324817e-60*i*o:i*Math.pow(2,a-150)*(o+8388608)}e.writeFloatLE=t.bind(null,n),e.writeFloatBE=t.bind(null,r),e.readFloatLE=o.bind(null,i),e.readFloatBE=o.bind(null,a)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),n=new Uint8Array(t.buffer),r=128===n[7];function i(e,r,i){t[0]=e,r[i]=n[0],r[i+1]=n[1],r[i+2]=n[2],r[i+3]=n[3],r[i+4]=n[4],r[i+5]=n[5],r[i+6]=n[6],r[i+7]=n[7]}function a(e,r,i){t[0]=e,r[i]=n[7],r[i+1]=n[6],r[i+2]=n[5],r[i+3]=n[4],r[i+4]=n[3],r[i+5]=n[2],r[i+6]=n[1],r[i+7]=n[0]}function o(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],n[4]=e[r+4],n[5]=e[r+5],n[6]=e[r+6],n[7]=e[r+7],t[0]}function s(e,r){return n[7]=e[r],n[6]=e[r+1],n[5]=e[r+2],n[4]=e[r+3],n[3]=e[r+4],n[2]=e[r+5],n[1]=e[r+6],n[0]=e[r+7],t[0]}e.writeDoubleLE=r?i:a,e.writeDoubleBE=r?a:i,e.readDoubleLE=r?o:s,e.readDoubleBE=r?s:o}():function(){function t(e,t,n,r,i,a){var o=r<0?1:0;if(o&&(r=-r),0===r)e(0,i,a+t),e(1/r>0?0:2147483648,i,a+n);else if(isNaN(r))e(0,i,a+t),e(2146959360,i,a+n);else if(r>17976931348623157e292)e(0,i,a+t),e((o<<31|2146435072)>>>0,i,a+n);else{var s;if(r<22250738585072014e-324)e((s=r/5e-324)>>>0,i,a+t),e((o<<31|s/4294967296)>>>0,i,a+n);else{var l=Math.floor(Math.log(r)/Math.LN2);1024===l&&(l=1023),e(4503599627370496*(s=r*Math.pow(2,-l))>>>0,i,a+t),e((o<<31|l+1023<<20|1048576*s&1048575)>>>0,i,a+n)}}}function o(e,t,n,r,i){var a=e(r,i+t),o=e(r,i+n),s=2*(o>>31)+1,l=o>>>20&2047,c=4294967296*(1048575&o)+a;return 2047===l?c?NaN:s*(1/0):0===l?5e-324*s*c:s*Math.pow(2,l-1075)*(c+4503599627370496)}e.writeDoubleLE=t.bind(null,n,0,4),e.writeDoubleBE=t.bind(null,r,4,0),e.readDoubleLE=o.bind(null,i,0,4),e.readDoubleBE=o.bind(null,a,4,0)}(),e}function n(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}function r(e,t,n){t[n]=e>>>24,t[n+1]=e>>>16&255,t[n+2]=e>>>8&255,t[n+3]=255&e}function i(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function a(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}e.exports=t(t)},1925:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},2459:(e,t)=>{"use strict";var n=t,r=n.isAbsolute=function(e){return/^(?:\/|\w+:)/.test(e)},i=n.normalize=function(e){var t=(e=e.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),n=r(e),i="";n&&(i=t.shift()+"/");for(var a=0;a0&&".."!==t[a-1]?t.splice(--a,2):n?t.splice(a,1):++a:"."===t[a]?t.splice(a,1):++a;return i+t.join("/")};n.resolve=function(e,t,n){return n||(t=i(t)),r(t)?t:(n||(e=i(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?i(e+"/"+t):t)}},4226:e=>{"use strict";e.exports=function(e,t,n){var r=n||8192,i=r>>>1,a=null,o=r;return function(n){if(n<1||n>i)return e(n);o+n>r&&(a=e(r),o=0);var s=t.call(a,o,o+=n);return 7&o&&(o=1+(7|o)),s}}},2971:(e,t)=>{"use strict";var n=t;n.length=function(e){for(var t=0,n=0,r=0;r191&&r<224?a[o++]=(31&r)<<6|63&e[t++]:r>239&&r<365?(r=((7&r)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,a[o++]=55296+(r>>10),a[o++]=56320+(1023&r)):a[o++]=(15&r)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,a)),o=0);return i?(o&&i.push(String.fromCharCode.apply(String,a.slice(0,o))),i.join("")):String.fromCharCode.apply(String,a.slice(0,o))},n.write=function(e,t,n){for(var r,i,a=n,o=0;o>6|192,t[n++]=63&r|128):55296==(64512&r)&&56320==(64512&(i=e.charCodeAt(o+1)))?(r=65536+((1023&r)<<10)+(1023&i),++o,t[n++]=r>>18|240,t[n++]=r>>12&63|128,t[n++]=r>>6&63|128,t[n++]=63&r|128):(t[n++]=r>>12|224,t[n++]=r>>6&63|128,t[n++]=63&r|128);return n-a}},7951:(e,t,n)=>{const r=n(2880),i={};for(const e of Object.keys(r))i[r[e]]=e;const a={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};e.exports=a;for(const e of Object.keys(a)){if(!("channels"in a[e]))throw new Error("missing channels property: "+e);if(!("labels"in a[e]))throw new Error("missing channel labels property: "+e);if(a[e].labels.length!==a[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:n}=a[e];delete a[e].channels,delete a[e].labels,Object.defineProperty(a[e],"channels",{value:t}),Object.defineProperty(a[e],"labels",{value:n})}a.rgb.hsl=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=a-i;let s,l;a===i?s=0:t===a?s=(n-r)/o:n===a?s=2+(r-t)/o:r===a&&(s=4+(t-n)/o),s=Math.min(60*s,360),s<0&&(s+=360);const c=(i+a)/2;return l=a===i?0:c<=.5?o/(a+i):o/(2-a-i),[s,100*l,100*c]},a.rgb.hsv=function(e){let t,n,r,i,a;const o=e[0]/255,s=e[1]/255,l=e[2]/255,c=Math.max(o,s,l),u=c-Math.min(o,s,l),d=function(e){return(c-e)/6/u+.5};return 0===u?(i=0,a=0):(a=u/c,t=d(o),n=d(s),r=d(l),o===c?i=r-n:s===c?i=1/3+t-r:l===c&&(i=2/3+n-t),i<0?i+=1:i>1&&(i-=1)),[360*i,100*a,100*c]},a.rgb.hwb=function(e){const t=e[0],n=e[1];let r=e[2];const i=a.rgb.hsl(e)[0],o=1/255*Math.min(t,Math.min(n,r));return r=1-1/255*Math.max(t,Math.max(n,r)),[i,100*o,100*r]},a.rgb.cmyk=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,i=Math.min(1-t,1-n,1-r);return[100*((1-t-i)/(1-i)||0),100*((1-n-i)/(1-i)||0),100*((1-r-i)/(1-i)||0),100*i]},a.rgb.keyword=function(e){const t=i[e];if(t)return t;let n,a=1/0;for(const t of Object.keys(r)){const i=r[t],l=(s=i,((o=e)[0]-s[0])**2+(o[1]-s[1])**2+(o[2]-s[2])**2);l.04045?((t+.055)/1.055)**2.4:t/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92;return[100*(.4124*t+.3576*n+.1805*r),100*(.2126*t+.7152*n+.0722*r),100*(.0193*t+.1192*n+.9505*r)]},a.rgb.lab=function(e){const t=a.rgb.xyz(e);let n=t[0],r=t[1],i=t[2];n/=95.047,r/=100,i/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,i=i>.008856?i**(1/3):7.787*i+16/116;return[116*r-16,500*(n-r),200*(r-i)]},a.hsl.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;let i,a,o;if(0===n)return o=255*r,[o,o,o];i=r<.5?r*(1+n):r+n-r*n;const s=2*r-i,l=[0,0,0];for(let e=0;e<3;e++)a=t+1/3*-(e-1),a<0&&a++,a>1&&a--,o=6*a<1?s+6*(i-s)*a:2*a<1?i:3*a<2?s+(i-s)*(2/3-a)*6:s,l[e]=255*o;return l},a.hsl.hsv=function(e){const t=e[0];let n=e[1]/100,r=e[2]/100,i=n;const a=Math.max(r,.01);r*=2,n*=r<=1?r:2-r,i*=a<=1?a:2-a;return[t,100*(0===r?2*i/(a+i):2*n/(r+n)),100*((r+n)/2)]},a.hsv.rgb=function(e){const t=e[0]/60,n=e[1]/100;let r=e[2]/100;const i=Math.floor(t)%6,a=t-Math.floor(t),o=255*r*(1-n),s=255*r*(1-n*a),l=255*r*(1-n*(1-a));switch(r*=255,i){case 0:return[r,l,o];case 1:return[s,r,o];case 2:return[o,r,l];case 3:return[o,s,r];case 4:return[l,o,r];case 5:return[r,o,s]}},a.hsv.hsl=function(e){const t=e[0],n=e[1]/100,r=e[2]/100,i=Math.max(r,.01);let a,o;o=(2-n)*r;const s=(2-n)*i;return a=n*i,a/=s<=1?s:2-s,a=a||0,o/=2,[t,100*a,100*o]},a.hwb.rgb=function(e){const t=e[0]/360;let n=e[1]/100,r=e[2]/100;const i=n+r;let a;i>1&&(n/=i,r/=i);const o=Math.floor(6*t),s=1-r;a=6*t-o,1&o&&(a=1-a);const l=n+a*(s-n);let c,u,d;switch(o){default:case 6:case 0:c=s,u=l,d=n;break;case 1:c=l,u=s,d=n;break;case 2:c=n,u=s,d=l;break;case 3:c=n,u=l,d=s;break;case 4:c=l,u=n,d=s;break;case 5:c=s,u=n,d=l}return[255*c,255*u,255*d]},a.cmyk.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100,i=e[3]/100;return[255*(1-Math.min(1,t*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},a.xyz.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100;let i,a,o;return i=3.2406*t+-1.5372*n+-.4986*r,a=-.9689*t+1.8758*n+.0415*r,o=.0557*t+-.204*n+1.057*r,i=i>.0031308?1.055*i**(1/2.4)-.055:12.92*i,a=a>.0031308?1.055*a**(1/2.4)-.055:12.92*a,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,i=Math.min(Math.max(0,i),1),a=Math.min(Math.max(0,a),1),o=Math.min(Math.max(0,o),1),[255*i,255*a,255*o]},a.xyz.lab=function(e){let t=e[0],n=e[1],r=e[2];t/=95.047,n/=100,r/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116;return[116*n-16,500*(t-n),200*(n-r)]},a.lab.xyz=function(e){let t,n,r;n=(e[0]+16)/116,t=e[1]/500+n,r=n-e[2]/200;const i=n**3,a=t**3,o=r**3;return n=i>.008856?i:(n-16/116)/7.787,t=a>.008856?a:(t-16/116)/7.787,r=o>.008856?o:(r-16/116)/7.787,t*=95.047,n*=100,r*=108.883,[t,n,r]},a.lab.lch=function(e){const t=e[0],n=e[1],r=e[2];let i;i=360*Math.atan2(r,n)/2/Math.PI,i<0&&(i+=360);return[t,Math.sqrt(n*n+r*r),i]},a.lch.lab=function(e){const t=e[0],n=e[1],r=e[2]/360*2*Math.PI;return[t,n*Math.cos(r),n*Math.sin(r)]},a.rgb.ansi16=function(e,t=null){const[n,r,i]=e;let o=null===t?a.rgb.hsv(e)[2]:t;if(o=Math.round(o/50),0===o)return 30;let s=30+(Math.round(i/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return 2===o&&(s+=60),s},a.hsv.ansi16=function(e){return a.rgb.ansi16(a.hsv.rgb(e),e[2])},a.rgb.ansi256=function(e){const t=e[0],n=e[1],r=e[2];if(t===n&&n===r)return t<8?16:t>248?231:Math.round((t-8)/247*24)+232;return 16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},a.ansi16.rgb=function(e){let t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const n=.5*(1+~~(e>50));return[(1&t)*n*255,(t>>1&1)*n*255,(t>>2&1)*n*255]},a.ansi256.rgb=function(e){if(e>=232){const t=10*(e-232)+8;return[t,t,t]}let t;e-=16;return[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},a.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},a.hex.rgb=function(e){const t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let n=t[0];3===t[0].length&&(n=n.split("").map((e=>e+e)).join(""));const r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},a.rgb.hcg=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,i=Math.max(Math.max(t,n),r),a=Math.min(Math.min(t,n),r),o=i-a;let s,l;return s=o<1?a/(1-o):0,l=o<=0?0:i===t?(n-r)/o%6:i===n?2+(r-t)/o:4+(t-n)/o,l/=6,l%=1,[360*l,100*o,100*s]},a.hsl.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=n<.5?2*t*n:2*t*(1-n);let i=0;return r<1&&(i=(n-.5*r)/(1-r)),[e[0],100*r,100*i]},a.hsv.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=t*n;let i=0;return r<1&&(i=(n-r)/(1-r)),[e[0],100*r,100*i]},a.hcg.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;if(0===n)return[255*r,255*r,255*r];const i=[0,0,0],a=t%1*6,o=a%1,s=1-o;let l=0;switch(Math.floor(a)){case 0:i[0]=1,i[1]=o,i[2]=0;break;case 1:i[0]=s,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=o;break;case 3:i[0]=0,i[1]=s,i[2]=1;break;case 4:i[0]=o,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=s}return l=(1-n)*r,[255*(n*i[0]+l),255*(n*i[1]+l),255*(n*i[2]+l)]},a.hcg.hsv=function(e){const t=e[1]/100,n=t+e[2]/100*(1-t);let r=0;return n>0&&(r=t/n),[e[0],100*r,100*n]},a.hcg.hsl=function(e){const t=e[1]/100,n=e[2]/100*(1-t)+.5*t;let r=0;return n>0&&n<.5?r=t/(2*n):n>=.5&&n<1&&(r=t/(2*(1-n))),[e[0],100*r,100*n]},a.hcg.hwb=function(e){const t=e[1]/100,n=t+e[2]/100*(1-t);return[e[0],100*(n-t),100*(1-n)]},a.hwb.hcg=function(e){const t=e[1]/100,n=1-e[2]/100,r=n-t;let i=0;return r<1&&(i=(n-r)/(1-r)),[e[0],100*r,100*i]},a.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},a.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},a.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},a.gray.hsl=function(e){return[0,0,e[0]]},a.gray.hsv=a.gray.hsl,a.gray.hwb=function(e){return[0,100,e[0]]},a.gray.cmyk=function(e){return[0,0,0,e[0]]},a.gray.lab=function(e){return[e[0],0,0]},a.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),n=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(n.length)+n},a.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]}},8666:(e,t,n)=>{const r=n(7951),i=n(1247),a={};Object.keys(r).forEach((e=>{a[e]={},Object.defineProperty(a[e],"channels",{value:r[e].channels}),Object.defineProperty(a[e],"labels",{value:r[e].labels});const t=i(e);Object.keys(t).forEach((n=>{const r=t[n];a[e][n]=function(e){const t=function(...t){const n=t[0];if(null==n)return n;n.length>1&&(t=n);const r=e(t);if("object"==typeof r)for(let e=r.length,t=0;t1&&(t=n),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(r)}))})),e.exports=a},1247:(e,t,n)=>{const r=n(7951);function i(e){const t=function(){const e={},t=Object.keys(r);for(let n=t.length,r=0;r{"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},6250:(e,t,n)=>{var r=n(2880),i=n(6852),a=Object.hasOwnProperty,o=Object.create(null);for(var s in r)a.call(r,s)&&(o[r[s]]=s);var l=e.exports={to:{},get:{}};function c(e,t,n){return Math.min(Math.max(t,e),n)}function u(e){var t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}l.get=function(e){var t,n;switch(e.substring(0,3).toLowerCase()){case"hsl":t=l.get.hsl(e),n="hsl";break;case"hwb":t=l.get.hwb(e),n="hwb";break;default:t=l.get.rgb(e),n="rgb"}return t?{model:n,value:t}:null},l.get.rgb=function(e){if(!e)return null;var t,n,i,o=[0,0,0,1];if(t=e.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(i=t[2],t=t[1],n=0;n<3;n++){var s=2*n;o[n]=parseInt(t.slice(s,s+2),16)}i&&(o[3]=parseInt(i,16)/255)}else if(t=e.match(/^#([a-f0-9]{3,4})$/i)){for(i=(t=t[1])[3],n=0;n<3;n++)o[n]=parseInt(t[n]+t[n],16);i&&(o[3]=parseInt(i+i,16)/255)}else if(t=e.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)o[n]=parseInt(t[n+1],0);t[4]&&(t[5]?o[3]=.01*parseFloat(t[4]):o[3]=parseFloat(t[4]))}else{if(!(t=e.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(t=e.match(/^(\w+)$/))?"transparent"===t[1]?[0,0,0,0]:a.call(r,t[1])?((o=r[t[1]])[3]=1,o):null:null;for(n=0;n<3;n++)o[n]=Math.round(2.55*parseFloat(t[n+1]));t[4]&&(t[5]?o[3]=.01*parseFloat(t[4]):o[3]=parseFloat(t[4]))}for(n=0;n<3;n++)o[n]=c(o[n],0,255);return o[3]=c(o[3],0,1),o},l.get.hsl=function(e){if(!e)return null;var t=e.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(t){var n=parseFloat(t[4]);return[(parseFloat(t[1])%360+360)%360,c(parseFloat(t[2]),0,100),c(parseFloat(t[3]),0,100),c(isNaN(n)?1:n,0,1)]}return null},l.get.hwb=function(e){if(!e)return null;var t=e.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(t){var n=parseFloat(t[4]);return[(parseFloat(t[1])%360+360)%360,c(parseFloat(t[2]),0,100),c(parseFloat(t[3]),0,100),c(isNaN(n)?1:n,0,1)]}return null},l.to.hex=function(){var e=i(arguments);return"#"+u(e[0])+u(e[1])+u(e[2])+(e[3]<1?u(Math.round(255*e[3])):"")},l.to.rgb=function(){var e=i(arguments);return e.length<4||1===e[3]?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"},l.to.rgb.percent=function(){var e=i(arguments),t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),r=Math.round(e[2]/255*100);return e.length<4||1===e[3]?"rgb("+t+"%, "+n+"%, "+r+"%)":"rgba("+t+"%, "+n+"%, "+r+"%, "+e[3]+")"},l.to.hsl=function(){var e=i(arguments);return e.length<4||1===e[3]?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"},l.to.hwb=function(){var e=i(arguments),t="";return e.length>=4&&1!==e[3]&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"},l.to.keyword=function(e){return o[e.slice(0,3)]}},4308:(e,t,n)=>{const r=n(6250),i=n(8666),a=["keyword","gray","hex"],o={};for(const e of Object.keys(i))o[[...i[e].labels].sort().join("")]=e;const s={};function l(e,t){if(!(this instanceof l))return new l(e,t);if(t&&t in a&&(t=null),t&&!(t in i))throw new Error("Unknown model: "+t);let n,c;if(null==e)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(e instanceof l)this.model=e.model,this.color=[...e.color],this.valpha=e.valpha;else if("string"==typeof e){const t=r.get(e);if(null===t)throw new Error("Unable to parse color from string: "+e);this.model=t.model,c=i[this.model].channels,this.color=t.value.slice(0,c),this.valpha="number"==typeof t.value[c]?t.value[c]:1}else if(e.length>0){this.model=t||"rgb",c=i[this.model].channels;const n=Array.prototype.slice.call(e,0,c);this.color=p(n,c),this.valpha="number"==typeof e[c]?e[c]:1}else if("number"==typeof e)this.model="rgb",this.color=[e>>16&255,e>>8&255,255&e],this.valpha=1;else{this.valpha=1;const t=Object.keys(e);"alpha"in e&&(t.splice(t.indexOf("alpha"),1),this.valpha="number"==typeof e.alpha?e.alpha:0);const r=t.sort().join("");if(!(r in o))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=o[r];const{labels:a}=i[this.model],s=[];for(n=0;n(e%360+360)%360)),saturationl:u("hsl",1,d(100)),lightness:u("hsl",2,d(100)),saturationv:u("hsv",1,d(100)),value:u("hsv",2,d(100)),chroma:u("hcg",1,d(100)),gray:u("hcg",2,d(100)),white:u("hwb",1,d(100)),wblack:u("hwb",2,d(100)),cyan:u("cmyk",0,d(100)),magenta:u("cmyk",1,d(100)),yellow:u("cmyk",2,d(100)),black:u("cmyk",3,d(100)),x:u("xyz",0,d(95.047)),y:u("xyz",1,d(100)),z:u("xyz",2,d(108.833)),l:u("lab",0,d(100)),a:u("lab",1),b:u("lab",2),keyword(e){return void 0!==e?new l(e):i[this.model].keyword(this.color)},hex(e){return void 0!==e?new l(e):r.to.hex(this.rgb().round().color)},hexa(e){if(void 0!==e)return new l(e);const t=this.rgb().round().color;let n=Math.round(255*this.valpha).toString(16).toUpperCase();return 1===n.length&&(n="0"+n),r.to.hex(t)+n},rgbNumber(){const e=this.rgb().color;return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},luminosity(){const e=this.rgb().color,t=[];for(const[n,r]of e.entries()){const e=r/255;t[n]=e<=.04045?e/12.92:((e+.055)/1.055)**2.4}return.2126*t[0]+.7152*t[1]+.0722*t[2]},contrast(e){const t=this.luminosity(),n=e.luminosity();return t>n?(t+.05)/(n+.05):(n+.05)/(t+.05)},level(e){const t=this.contrast(e);return t>=7?"AAA":t>=4.5?"AA":""},isDark(){const e=this.rgb().color;return(2126*e[0]+7152*e[1]+722*e[2])/1e4<128},isLight(){return!this.isDark()},negate(){const e=this.rgb();for(let t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten(e){const t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken(e){const t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate(e){const t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate(e){const t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten(e){const t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken(e){const t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale(){const e=this.rgb().color,t=.3*e[0]+.59*e[1]+.11*e[2];return l.rgb(t,t,t)},fade(e){return this.alpha(this.valpha-this.valpha*e)},opaquer(e){return this.alpha(this.valpha+this.valpha*e)},rotate(e){const t=this.hsl();let n=t.color[0];return n=(n+e)%360,n=n<0?360+n:n,t.color[0]=n,t},mix(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);const n=e.rgb(),r=this.rgb(),i=void 0===t?.5:t,a=2*i-1,o=n.alpha()-r.alpha(),s=((a*o==-1?a:(a+o)/(1+a*o))+1)/2,c=1-s;return l.rgb(s*n.red()+c*r.red(),s*n.green()+c*r.green(),s*n.blue()+c*r.blue(),n.alpha()*i+r.alpha()*(1-i))}};for(const e of Object.keys(i)){if(a.includes(e))continue;const{channels:t}=i[e];l.prototype[e]=function(...t){return this.model===e?new l(this):t.length>0?new l(t,e):new l([...(n=i[this.model][e].raw(this.color),Array.isArray(n)?n:[n]),this.valpha],e);var n},l[e]=function(...n){let r=n[0];return"number"==typeof r&&(r=p(n,t)),new l(r,e)}}function c(e){return function(t){return function(e,t){return Number(e.toFixed(t))}(t,e)}}function u(e,t,n){e=Array.isArray(e)?e:[e];for(const r of e)(s[r]||(s[r]=[]))[t]=n;return e=e[0],function(r){let i;return void 0!==r?(n&&(r=n(r)),i=this[e](),i.color[t]=r,i):(i=this[e]().color[t],n&&(i=n(i)),i)}}function d(e){return function(t){return Math.max(0,Math.min(e,t))}}function p(e,t){for(let n=0;n=t.status}function a(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var o="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n.g&&n.g.global===n.g?n.g:void 0,s=o.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=o.saveAs||("object"!=typeof window||window!==o?function(){}:"download"in HTMLAnchorElement.prototype&&!s?function(e,t,n){var s=o.URL||o.webkitURL,l=document.createElement("a");t=t||e.name||"download",l.download=t,l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?a(l):i(l.href)?r(e,t,n):a(l,l.target="_blank")):(l.href=s.createObjectURL(e),setTimeout((function(){s.revokeObjectURL(l.href)}),4e4),setTimeout((function(){a(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,n,o){if(n=n||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(t(e,o),n);else if(i(e))r(e,n,o);else{var s=document.createElement("a");s.href=e,s.target="_blank",setTimeout((function(){a(s)}))}}:function(e,t,n,i){if((i=i||open("","_blank"))&&(i.document.title=i.document.body.innerText="downloading..."),"string"==typeof e)return r(e,t,n);var a="application/octet-stream"===e.type,l=/constructor/i.test(o.HTMLElement)||o.safari,c=/CriOS\/[\d]+/.test(navigator.userAgent);if((c||a&&l||s)&&"undefined"!=typeof FileReader){var u=new FileReader;u.onloadend=function(){var e=u.result;e=c?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),i?i.location.href=e:location=e,i=null},u.readAsDataURL(e)}else{var d=o.URL||o.webkitURL,p=d.createObjectURL(e);i?i.location=p:location.href=p,i=null,setTimeout((function(){d.revokeObjectURL(p)}),4e4)}});o.saveAs=l.saveAs=l,e.exports=l})?r.apply(t,i):r)||(e.exports=a)},7842:(e,t,n)=>{e=n.nmd(e);var r="__lodash_hash_undefined__",i=1,a=2,o=9007199254740991,s="[object Arguments]",l="[object Array]",c="[object AsyncFunction]",u="[object Boolean]",d="[object Date]",p="[object Error]",h="[object Function]",f="[object GeneratorFunction]",m="[object Map]",g="[object Number]",y="[object Null]",b="[object Object]",v="[object Promise]",w="[object Proxy]",S="[object RegExp]",E="[object Set]",x="[object String]",O="[object Symbol]",_="[object Undefined]",T="[object WeakMap]",C="[object ArrayBuffer]",k="[object DataView]",P=/^\[object .+?Constructor\]$/,R=/^(?:0|[1-9]\d*)$/,A={};A["[object Float32Array]"]=A["[object Float64Array]"]=A["[object Int8Array]"]=A["[object Int16Array]"]=A["[object Int32Array]"]=A["[object Uint8Array]"]=A["[object Uint8ClampedArray]"]=A["[object Uint16Array]"]=A["[object Uint32Array]"]=!0,A[s]=A[l]=A[C]=A[u]=A[k]=A[d]=A[p]=A[h]=A[m]=A[g]=A[b]=A[S]=A[E]=A[x]=A[T]=!1;var D="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,j="object"==typeof self&&self&&self.Object===Object&&self,I=D||j||Function("return this")(),N=t&&!t.nodeType&&t,L=N&&e&&!e.nodeType&&e,M=L&&L.exports===N,F=M&&D.process,$=function(){try{return F&&F.binding&&F.binding("util")}catch(e){}}(),B=$&&$.isTypedArray;function V(e,t){for(var n=-1,r=null==e?0:e.length;++nc))return!1;var d=s.get(e);if(d&&s.get(t))return d==t;var p=-1,h=!0,f=n&a?new Ce:void 0;for(s.set(e,t),s.set(t,e);++p-1},_e.prototype.set=function(e,t){var n=this.__data__,r=Re(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Te.prototype.clear=function(){this.size=0,this.__data__={hash:new Oe,map:new(pe||_e),string:new Oe}},Te.prototype.delete=function(e){var t=Fe(this,e).delete(e);return this.size-=t?1:0,t},Te.prototype.get=function(e){return Fe(this,e).get(e)},Te.prototype.has=function(e){return Fe(this,e).has(e)},Te.prototype.set=function(e,t){var n=Fe(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Ce.prototype.add=Ce.prototype.push=function(e){return this.__data__.set(e,r),this},Ce.prototype.has=function(e){return this.__data__.has(e)},ke.prototype.clear=function(){this.__data__=new _e,this.size=0},ke.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},ke.prototype.get=function(e){return this.__data__.get(e)},ke.prototype.has=function(e){return this.__data__.has(e)},ke.prototype.set=function(e,t){var n=this.__data__;if(n instanceof _e){var r=n.__data__;if(!pe||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Te(r)}return n.set(e,t),this.size=n.size,this};var Be=le?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,a=[];++n-1&&e%1==0&&e-1&&e%1==0&&e<=o}function Ye(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Xe(e){return null!=e&&"object"==typeof e}var Je=B?function(e){return function(t){return e(t)}}(B):function(e){return Xe(e)&&Ke(e.length)&&!!A[Ae(e)]};function Ze(e){return null!=(t=e)&&Ke(t.length)&&!Qe(t)?Pe(e):Ne(e);var t}e.exports=function(e,t){return je(e,t)}},1664:e=>{"use strict";var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,i){for(var a,o,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),l=1;l{"use strict";var r=n(6441);function i(){}function a(){}a.resetWarningCache=i,e.exports=function(){function e(e,t,n,i,a,o){if(o!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:i};return n.PropTypes=n,n}},2688:(e,t,n)=>{e.exports=n(362)()},6441:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},585:(e,t,n)=>{"use strict";e.exports=n(5481)},3804:(e,t,n)=>{"use strict";var r=t,i=n(2775),a=n(6866);function o(e,t,n,r){var a=!1;if(t.resolvedType)if(t.resolvedType instanceof i){e("switch(d%s){",r);for(var o=t.resolvedType.values,s=Object.keys(o),l=0;l>>0",r,r);break;case"int32":case"sint32":case"sfixed32":e("m%s=d%s|0",r,r);break;case"uint64":c=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",r,r,c)('else if(typeof d%s==="string")',r)("m%s=parseInt(d%s,10)",r,r)('else if(typeof d%s==="number")',r)("m%s=d%s",r,r)('else if(typeof d%s==="object")',r)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",r,r,r,c?"true":"");break;case"bytes":e('if(typeof d%s==="string")',r)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",r,r,r)("else if(d%s.length >= 0)",r)("m%s=d%s",r,r);break;case"string":e("m%s=String(d%s)",r,r);break;case"bool":e("m%s=Boolean(d%s)",r,r)}}return e}function s(e,t,n,r){if(t.resolvedType)t.resolvedType instanceof i?e("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",r,n,r,r,n,r,r):e("d%s=types[%i].toObject(m%s,o)",r,n,r);else{var a=!1;switch(t.type){case"double":case"float":e("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",r,r,r,r);break;case"uint64":a=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e('if(typeof m%s==="number")',r)("d%s=o.longs===String?String(m%s):m%s",r,r,r)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",r,r,r,r,a?"true":"",r);break;case"bytes":e("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",r,r,r,r,r);break;default:e("d%s=m%s",r,r)}}return e}r.fromObject=function(e){var t=e.fieldsArray,n=a.codegen(["d"],e.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!t.length)return n("return new this.ctor");n("var m=new this.ctor");for(var r=0;r{"use strict";e.exports=function(e){var t=a.codegen(["r","l"],e.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(e.fieldsArray.filter((function(e){return e.map})).length?",k,value":""))("while(r.pos>>3){");for(var n=0;n>>3){")("case 1: k=r.%s(); break",s.keyType)("case 2:"),void 0===i.basic[l]?t("value=types[%i].decode(r,r.uint32())",n):t("value=r.%s()",l),t("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),void 0!==i.long[s.keyType]?t('%s[typeof k==="object"?util.longToHash(k):k]=value',c):t("%s[k]=value",c)):s.repeated?(t("if(!(%s&&%s.length))",c,c)("%s=[]",c),void 0!==i.packed[l]&&t("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos{"use strict";e.exports=function(e){for(var t,n=a.codegen(["m","w"],e.name+"$encode")("if(!w)")("w=Writer.create()"),s=e.fieldsArray.slice().sort(a.compareFieldsById),l=0;l>>0,8|i.mapKey[c.keyType],c.keyType),void 0===p?n("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",u,t):n(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|p,d,t),n("}")("}")):c.repeated?(n("if(%s!=null&&%s.length){",t,t),c.packed&&void 0!==i.packed[d]?n("w.uint32(%i).fork()",(c.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",t)("w.%s(%s[i])",d,t)("w.ldelim()"):(n("for(var i=0;i<%s.length;++i)",t),void 0===p?o(n,c,u,t+"[i]"):n("w.uint32(%i).%s(%s[i])",(c.id<<3|p)>>>0,d,t)),n("}")):(c.optional&&n("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",t,c.name),void 0===p?o(n,c,u,t):n("w.uint32(%i).%s(%s)",(c.id<<3|p)>>>0,d,t))}return n("return w")};var r=n(2775),i=n(1517),a=n(6866);function o(e,t,n,r){return t.resolvedType.group?e("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",n,r,(t.id<<3|3)>>>0,(t.id<<3|4)>>>0):e("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",n,r,(t.id<<3|2)>>>0)}},2775:(e,t,n)=>{"use strict";e.exports=o;var r=n(4349);((o.prototype=Object.create(r.prototype)).constructor=o).className="Enum";var i=n(2815),a=n(6866);function o(e,t,n,i,a,o){if(r.call(this,e,n),t&&"object"!=typeof t)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=i,this.comments=a||{},this.valuesOptions=o,this.reserved=void 0,t)for(var s=Object.keys(t),l=0;l{"use strict";e.exports=c;var r=n(4349);((c.prototype=Object.create(r.prototype)).constructor=c).className="Field";var i,a=n(2775),o=n(1517),s=n(6866),l=/^required|optional|repeated$/;function c(e,t,n,i,a,c,u){if(s.isObject(i)?(u=a,c=i,i=a=void 0):s.isObject(a)&&(u=c,c=a,a=void 0),r.call(this,e,c),!s.isInteger(t)||t<0)throw TypeError("id must be a non-negative integer");if(!s.isString(n))throw TypeError("type must be a string");if(void 0!==i&&!l.test(i=i.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==a&&!s.isString(a))throw TypeError("extend must be a string");"proto3_optional"===i&&(i="optional"),this.rule=i&&"optional"!==i?i:void 0,this.type=n,this.id=t,this.extend=a||void 0,this.required="required"===i,this.optional=!this.required,this.repeated="repeated"===i,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!s.Long&&void 0!==o.long[n],this.bytes="bytes"===n,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=u}c.fromJSON=function(e,t){return new c(e,t.id,t.type,t.rule,t.extend,t.options,t.comment)},Object.defineProperty(c.prototype,"packed",{get:function(){return null===this._packed&&(this._packed=!1!==this.getOption("packed")),this._packed}}),c.prototype.setOption=function(e,t,n){return"packed"===e&&(this._packed=null),r.prototype.setOption.call(this,e,t,n)},c.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return s.toObject(["rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},c.prototype.resolve=function(){if(this.resolved)return this;if(void 0===(this.typeDefault=o.defaults[this.type])?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.resolvedType instanceof i?this.typeDefault=null:this.typeDefault=this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&null!=this.options.default&&(this.typeDefault=this.options.default,this.resolvedType instanceof a&&"string"==typeof this.typeDefault&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&(!0!==this.options.packed&&(void 0===this.options.packed||!this.resolvedType||this.resolvedType instanceof a)||delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=s.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"==typeof this.typeDefault){var e;s.base64.test(this.typeDefault)?s.base64.decode(this.typeDefault,e=s.newBuffer(s.base64.length(this.typeDefault)),0):s.utf8.write(this.typeDefault,e=s.newBuffer(s.utf8.length(this.typeDefault)),0),this.typeDefault=e}return this.map?this.defaultValue=s.emptyObject:this.repeated?this.defaultValue=s.emptyArray:this.defaultValue=this.typeDefault,this.parent instanceof i&&(this.parent.ctor.prototype[this.name]=this.defaultValue),r.prototype.resolve.call(this)},c.d=function(e,t,n,r){return"function"==typeof t?t=s.decorateType(t).name:t&&"object"==typeof t&&(t=s.decorateEnum(t).name),function(i,a){s.decorateType(i.constructor).add(new c(a,e,t,n,{default:r}))}},c._configure=function(e){i=e}},5481:(e,t,n)=>{"use strict";var r=e.exports=n(7134);r.build="light",r.load=function(e,t,n){return"function"==typeof t?(n=t,t=new r.Root):t||(t=new r.Root),t.load(e,n)},r.loadSync=function(e,t){return t||(t=new r.Root),t.loadSync(e)},r.encoder=n(8852),r.decoder=n(9980),r.verifier=n(3040),r.converter=n(3804),r.ReflectionObject=n(4349),r.Namespace=n(2815),r.Root=n(8038),r.Enum=n(2775),r.Type=n(6),r.Field=n(3796),r.OneOf=n(8957),r.MapField=n(9504),r.Service=n(6467),r.Method=n(3055),r.Message=n(6619),r.wrappers=n(6942),r.types=n(1517),r.util=n(6866),r.ReflectionObject._configure(r.Root),r.Namespace._configure(r.Type,r.Service,r.Enum),r.Root._configure(r.Type),r.Field._configure(r.Type)},7134:(e,t,n)=>{"use strict";var r=t;function i(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}r.build="minimal",r.Writer=n(4301),r.BufferWriter=n(8422),r.Reader=n(1137),r.BufferReader=n(4010),r.util=n(5382),r.rpc=n(9691),r.roots=n(381),r.configure=i,i()},9504:(e,t,n)=>{"use strict";e.exports=o;var r=n(3796);((o.prototype=Object.create(r.prototype)).constructor=o).className="MapField";var i=n(1517),a=n(6866);function o(e,t,n,i,o,s){if(r.call(this,e,t,i,void 0,void 0,o,s),!a.isString(n))throw TypeError("keyType must be a string");this.keyType=n,this.resolvedKeyType=null,this.map=!0}o.fromJSON=function(e,t){return new o(e,t.id,t.keyType,t.type,t.options,t.comment)},o.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return a.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},o.prototype.resolve=function(){if(this.resolved)return this;if(void 0===i.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return r.prototype.resolve.call(this)},o.d=function(e,t,n){return"function"==typeof n?n=a.decorateType(n).name:n&&"object"==typeof n&&(n=a.decorateEnum(n).name),function(r,i){a.decorateType(r.constructor).add(new o(i,e,t,n))}}},6619:(e,t,n)=>{"use strict";e.exports=i;var r=n(5382);function i(e){if(e)for(var t=Object.keys(e),n=0;n{"use strict";e.exports=a;var r=n(4349);((a.prototype=Object.create(r.prototype)).constructor=a).className="Method";var i=n(6866);function a(e,t,n,a,o,s,l,c,u){if(i.isObject(o)?(l=o,o=s=void 0):i.isObject(s)&&(l=s,s=void 0),void 0!==t&&!i.isString(t))throw TypeError("type must be a string");if(!i.isString(n))throw TypeError("requestType must be a string");if(!i.isString(a))throw TypeError("responseType must be a string");r.call(this,e,l),this.type=t||"rpc",this.requestType=n,this.requestStream=!!o||void 0,this.responseType=a,this.responseStream=!!s||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=c,this.parsedOptions=u}a.fromJSON=function(e,t){return new a(e,t.type,t.requestType,t.responseType,t.requestStream,t.responseStream,t.options,t.comment,t.parsedOptions)},a.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return i.toObject(["type","rpc"!==this.type&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",t?this.comment:void 0,"parsedOptions",this.parsedOptions])},a.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),r.prototype.resolve.call(this))}},2815:(e,t,n)=>{"use strict";e.exports=d;var r=n(4349);((d.prototype=Object.create(r.prototype)).constructor=d).className="Namespace";var i,a,o,s=n(3796),l=n(6866),c=n(8957);function u(e,t){if(e&&e.length){for(var n={},r=0;rt)return!0;return!1},d.isReservedName=function(e,t){if(e)for(var n=0;n0;){var r=e.shift();if(n.nested&&n.nested[r]){if(!((n=n.nested[r])instanceof d))throw Error("path conflicts with non-namespace objects")}else n.add(n=new d(r))}return t&&n.addJSON(t),n},d.prototype.resolveAll=function(){for(var e=this.nestedArray,t=0;t-1)return r}else if(r instanceof d&&(r=r.lookup(e.slice(1),t,!0)))return r}else for(var i=0;i{"use strict";e.exports=a,a.className="ReflectionObject";var r,i=n(6866);function a(e,t){if(!i.isString(e))throw TypeError("name must be a string");if(t&&!i.isObject(t))throw TypeError("options must be an object");this.options=t,this.parsedOptions=null,this.name=e,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}Object.defineProperties(a.prototype,{root:{get:function(){for(var e=this;null!==e.parent;)e=e.parent;return e}},fullName:{get:function(){for(var e=[this.name],t=this.parent;t;)e.unshift(t.name),t=t.parent;return e.join(".")}}}),a.prototype.toJSON=function(){throw Error()},a.prototype.onAdd=function(e){this.parent&&this.parent!==e&&this.parent.remove(this),this.parent=e,this.resolved=!1;var t=e.root;t instanceof r&&t._handleAdd(this)},a.prototype.onRemove=function(e){var t=e.root;t instanceof r&&t._handleRemove(this),this.parent=null,this.resolved=!1},a.prototype.resolve=function(){return this.resolved||this.root instanceof r&&(this.resolved=!0),this},a.prototype.getOption=function(e){if(this.options)return this.options[e]},a.prototype.setOption=function(e,t,n){return n&&this.options&&void 0!==this.options[e]||((this.options||(this.options={}))[e]=t),this},a.prototype.setParsedOption=function(e,t,n){this.parsedOptions||(this.parsedOptions=[]);var r=this.parsedOptions;if(n){var a=r.find((function(t){return Object.prototype.hasOwnProperty.call(t,e)}));if(a){var o=a[e];i.setProperty(o,n,t)}else(a={})[e]=i.setProperty({},n,t),r.push(a)}else{var s={};s[e]=t,r.push(s)}return this},a.prototype.setOptions=function(e,t){if(e)for(var n=Object.keys(e),r=0;r{"use strict";e.exports=o;var r=n(4349);((o.prototype=Object.create(r.prototype)).constructor=o).className="OneOf";var i=n(3796),a=n(6866);function o(e,t,n,i){if(Array.isArray(t)||(n=t,t=void 0),r.call(this,e,n),void 0!==t&&!Array.isArray(t))throw TypeError("fieldNames must be an Array");this.oneof=t||[],this.fieldsArray=[],this.comment=i}function s(e){if(e.parent)for(var t=0;t-1&&this.oneof.splice(t,1),e.partOf=null,this},o.prototype.onAdd=function(e){r.prototype.onAdd.call(this,e);for(var t=0;t{"use strict";e.exports=l;var r,i=n(5382),a=i.LongBits,o=i.utf8;function s(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function l(e){this.buf=e,this.pos=0,this.len=e.length}var c,u="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new l(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new l(e);throw Error("illegal buffer")},d=function(){return i.Buffer?function(e){return(l.create=function(e){return i.Buffer.isBuffer(e)?new r(e):u(e)})(e)}:u};function p(){var e=new a(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw s(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw s(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function h(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function f(){if(this.pos+8>this.len)throw s(this,8);return new a(h(this.buf,this.pos+=4),h(this.buf,this.pos+=4))}l.create=d(),l.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,l.prototype.uint32=(c=4294967295,function(){if(c=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return c;if((this.pos+=5)>this.len)throw this.pos=this.len,s(this,10);return c}),l.prototype.int32=function(){return 0|this.uint32()},l.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)},l.prototype.bool=function(){return 0!==this.uint32()},l.prototype.fixed32=function(){if(this.pos+4>this.len)throw s(this,4);return h(this.buf,this.pos+=4)},l.prototype.sfixed32=function(){if(this.pos+4>this.len)throw s(this,4);return 0|h(this.buf,this.pos+=4)},l.prototype.float=function(){if(this.pos+4>this.len)throw s(this,4);var e=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},l.prototype.double=function(){if(this.pos+8>this.len)throw s(this,4);var e=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},l.prototype.bytes=function(){var e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw s(this,e);if(this.pos+=e,Array.isArray(this.buf))return this.buf.slice(t,n);if(t===n){var r=i.Buffer;return r?r.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,t,n)},l.prototype.string=function(){var e=this.bytes();return o.read(e,0,e.length)},l.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw s(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw s(this)}while(128&this.buf[this.pos++]);return this},l.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},l._configure=function(e){r=e,l.create=d(),r._configure();var t=i.Long?"toLong":"toNumber";i.merge(l.prototype,{int64:function(){return p.call(this)[t](!1)},uint64:function(){return p.call(this)[t](!0)},sint64:function(){return p.call(this).zzDecode()[t](!1)},fixed64:function(){return f.call(this)[t](!0)},sfixed64:function(){return f.call(this)[t](!1)}})}},4010:(e,t,n)=>{"use strict";e.exports=a;var r=n(1137);(a.prototype=Object.create(r.prototype)).constructor=a;var i=n(5382);function a(e){r.call(this,e)}a._configure=function(){i.Buffer&&(a.prototype._slice=i.Buffer.prototype.slice)},a.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},a._configure()},8038:(e,t,n)=>{"use strict";e.exports=d;var r=n(2815);((d.prototype=Object.create(r.prototype)).constructor=d).className="Root";var i,a,o,s=n(3796),l=n(2775),c=n(8957),u=n(6866);function d(e){r.call(this,"",e),this.deferred=[],this.files=[]}function p(){}d.fromJSON=function(e,t){return t||(t=new d),e.options&&t.setOptions(e.options),t.addJSON(e.nested)},d.prototype.resolvePath=u.path.resolve,d.prototype.fetch=u.fetch,d.prototype.load=function e(t,n,r){"function"==typeof n&&(r=n,n=void 0);var i=this;if(!r)return u.asPromise(e,i,t,n);var s=r===p;function l(e,t){if(r){if(s)throw e;var n=r;r=null,n(e,t)}}function c(e){var t=e.lastIndexOf("google/protobuf/");if(t>-1){var n=e.substring(t);if(n in o)return n}return null}function d(e,t){try{if(u.isString(t)&&"{"===t.charAt(0)&&(t=JSON.parse(t)),u.isString(t)){a.filename=e;var r,o=a(t,i,n),d=0;if(o.imports)for(;d-1))if(i.files.push(e),e in o)s?d(e,o[e]):(++f,setTimeout((function(){--f,d(e,o[e])})));else if(s){var n;try{n=u.fs.readFileSync(e).toString("utf8")}catch(e){return void(t||l(e))}d(e,n)}else++f,i.fetch(e,(function(n,a){--f,r&&(n?t?f||l(null,i):l(n):d(e,a))}))}var f=0;u.isString(t)&&(t=[t]);for(var m,g=0;g-1&&this.deferred.splice(t,1)}}else if(e instanceof l)h.test(e.name)&&delete e.parent[e.name];else if(e instanceof r){for(var n=0;n{"use strict";e.exports={}},9691:(e,t,n)=>{"use strict";t.Service=n(4447)},4447:(e,t,n)=>{"use strict";e.exports=i;var r=n(5382);function i(e,t,n){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");r.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(n)}(i.prototype=Object.create(r.EventEmitter.prototype)).constructor=i,i.prototype.rpcCall=function e(t,n,i,a,o){if(!a)throw TypeError("request must be specified");var s=this;if(!o)return r.asPromise(e,s,t,n,i,a);if(s.rpcImpl)try{return s.rpcImpl(t,n[s.requestDelimited?"encodeDelimited":"encode"](a).finish(),(function(e,n){if(e)return s.emit("error",e,t),o(e);if(null!==n){if(!(n instanceof i))try{n=i[s.responseDelimited?"decodeDelimited":"decode"](n)}catch(e){return s.emit("error",e,t),o(e)}return s.emit("data",n,t),o(null,n)}s.end(!0)}))}catch(e){return s.emit("error",e,t),void setTimeout((function(){o(e)}),0)}else setTimeout((function(){o(Error("already ended"))}),0)},i.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},6467:(e,t,n)=>{"use strict";e.exports=s;var r=n(2815);((s.prototype=Object.create(r.prototype)).constructor=s).className="Service";var i=n(3055),a=n(6866),o=n(9691);function s(e,t){r.call(this,e,t),this.methods={},this._methodsArray=null}function l(e){return e._methodsArray=null,e}s.fromJSON=function(e,t){var n=new s(e,t.options);if(t.methods)for(var r=Object.keys(t.methods),a=0;a{"use strict";e.exports=b;var r=n(2815);((b.prototype=Object.create(r.prototype)).constructor=b).className="Type";var i=n(2775),a=n(8957),o=n(3796),s=n(9504),l=n(6467),c=n(6619),u=n(1137),d=n(4301),p=n(6866),h=n(8852),f=n(9980),m=n(3040),g=n(3804),y=n(6942);function b(e,t){r.call(this,e,t),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}function v(e){return e._fieldsById=e._fieldsArray=e._oneofsArray=null,delete e.encode,delete e.decode,delete e.verify,e}Object.defineProperties(b.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var e=Object.keys(this.fields),t=0;t{"use strict";var r=t,i=n(6866),a=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function o(e,t){var n=0,r={};for(t|=0;n{"use strict";var r,i,a=e.exports=n(5382),o=n(381);a.codegen=n(7669),a.fetch=n(9240),a.path=n(2459),a.fs=a.inquire("fs"),a.toArray=function(e){if(e){for(var t=Object.keys(e),n=new Array(t.length),r=0;r0)t[i]=e(t[i]||{},n,r);else{var a=t[i];a&&(r=[].concat(a).concat(r)),t[i]=r}return t}(e,t=t.split("."),n)},Object.defineProperty(a,"decorateRoot",{get:function(){return o.decorated||(o.decorated=new(n(8038)))}})},5003:(e,t,n)=>{"use strict";e.exports=i;var r=n(5382);function i(e,t){this.lo=e>>>0,this.hi=t>>>0}var a=i.zero=new i(0,0);a.toNumber=function(){return 0},a.zzEncode=a.zzDecode=function(){return this},a.length=function(){return 1};var o=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(e){if(0===e)return a;var t=e<0;t&&(e=-e);var n=e>>>0,r=(e-n)/4294967296>>>0;return t&&(r=~r>>>0,n=~n>>>0,++n>4294967295&&(n=0,++r>4294967295&&(r=0))),new i(n,r)},i.from=function(e){if("number"==typeof e)return i.fromNumber(e);if(r.isString(e)){if(!r.Long)return i.fromNumber(parseInt(e,10));e=r.Long.fromString(e)}return e.low||e.high?new i(e.low>>>0,e.high>>>0):a},i.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,n=~this.hi>>>0;return t||(n=n+1>>>0),-(t+4294967296*n)}return this.lo+4294967296*this.hi},i.prototype.toLong=function(e){return r.Long?new r.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var s=String.prototype.charCodeAt;i.fromHash=function(e){return e===o?a:new i((s.call(e,0)|s.call(e,1)<<8|s.call(e,2)<<16|s.call(e,3)<<24)>>>0,(s.call(e,4)|s.call(e,5)<<8|s.call(e,6)<<16|s.call(e,7)<<24)>>>0)},i.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},i.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},i.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},i.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0===n?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}},5382:function(e,t,n){"use strict";var r=t;function i(e,t,n){for(var r=Object.keys(t),i=0;i0)},r.Buffer=function(){try{var e=r.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(e){return"number"==typeof e?r.Buffer?r._Buffer_allocUnsafe(e):new r.Array(e):r.Buffer?r._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},r.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,r.Long=r.global.dcodeIO&&r.global.dcodeIO.Long||r.global.Long||r.inquire("long"),r.key2Re=/^true|false|0|1$/,r.key32Re=/^-?(?:0|[1-9][0-9]*)$/,r.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,r.longToHash=function(e){return e?r.LongBits.from(e).toHash():r.LongBits.zeroHash},r.longFromHash=function(e,t){var n=r.LongBits.fromHash(e);return r.Long?r.Long.fromBits(n.lo,n.hi,t):n.toNumber(Boolean(t))},r.merge=i,r.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},r.newError=a,r.ProtocolError=a("ProtocolError"),r.oneOfGetter=function(e){for(var t={},n=0;n-1;--n)if(1===t[e[n]]&&void 0!==this[e[n]]&&null!==this[e[n]])return e[n]}},r.oneOfSetter=function(e){return function(t){for(var n=0;n{"use strict";e.exports=function(e){var t=i.codegen(["m"],e.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),n=e.oneofsArray,r={};n.length&&t("var p={}");for(var l=0;l{"use strict";var r=t,i=n(6619);r[".google.protobuf.Any"]={fromObject:function(e){if(e&&e["@type"]){var t=e["@type"].substring(e["@type"].lastIndexOf("/")+1),n=this.lookup(t);if(n){var r="."===e["@type"].charAt(0)?e["@type"].slice(1):e["@type"];return-1===r.indexOf("/")&&(r="/"+r),this.create({type_url:r,value:n.encode(n.fromObject(e)).finish()})}}return this.fromObject(e)},toObject:function(e,t){var n="",r="";if(t&&t.json&&e.type_url&&e.value){r=e.type_url.substring(e.type_url.lastIndexOf("/")+1),n=e.type_url.substring(0,e.type_url.lastIndexOf("/")+1);var a=this.lookup(r);a&&(e=a.decode(e.value))}if(!(e instanceof this.ctor)&&e instanceof i){var o=e.$type.toObject(e,t);return""===n&&(n="type.googleapis.com/"),r=n+("."===e.$type.fullName[0]?e.$type.fullName.slice(1):e.$type.fullName),o["@type"]=r,o}return this.toObject(e,t)}}},4301:(e,t,n)=>{"use strict";e.exports=d;var r,i=n(5382),a=i.LongBits,o=i.base64,s=i.utf8;function l(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function c(){}function u(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function d(){this.len=0,this.head=new l(c,0,0),this.tail=this.head,this.states=null}var p=function(){return i.Buffer?function(){return(d.create=function(){return new r})()}:function(){return new d}};function h(e,t,n){t[n]=255&e}function f(e,t){this.len=e,this.next=void 0,this.val=t}function m(e,t,n){for(;e.hi;)t[n++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[n++]=127&e.lo|128,e.lo=e.lo>>>7;t[n++]=e.lo}function g(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}d.create=p(),d.alloc=function(e){return new i.Array(e)},i.Array!==Array&&(d.alloc=i.pool(d.alloc,i.Array.prototype.subarray)),d.prototype._push=function(e,t,n){return this.tail=this.tail.next=new l(e,t,n),this.len+=t,this},f.prototype=Object.create(l.prototype),f.prototype.fn=function(e,t,n){for(;e>127;)t[n++]=127&e|128,e>>>=7;t[n]=e},d.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new f((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},d.prototype.int32=function(e){return e<0?this._push(m,10,a.fromNumber(e)):this.uint32(e)},d.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},d.prototype.uint64=function(e){var t=a.from(e);return this._push(m,t.length(),t)},d.prototype.int64=d.prototype.uint64,d.prototype.sint64=function(e){var t=a.from(e).zzEncode();return this._push(m,t.length(),t)},d.prototype.bool=function(e){return this._push(h,1,e?1:0)},d.prototype.fixed32=function(e){return this._push(g,4,e>>>0)},d.prototype.sfixed32=d.prototype.fixed32,d.prototype.fixed64=function(e){var t=a.from(e);return this._push(g,4,t.lo)._push(g,4,t.hi)},d.prototype.sfixed64=d.prototype.fixed64,d.prototype.float=function(e){return this._push(i.float.writeFloatLE,4,e)},d.prototype.double=function(e){return this._push(i.float.writeDoubleLE,8,e)};var y=i.Array.prototype.set?function(e,t,n){t.set(e,n)}:function(e,t,n){for(var r=0;r>>0;if(!t)return this._push(h,1,0);if(i.isString(e)){var n=d.alloc(t=o.length(e));o.decode(e,n,0),e=n}return this.uint32(t)._push(y,t,e)},d.prototype.string=function(e){var t=s.length(e);return t?this.uint32(t)._push(s.write,t,e):this._push(h,1,0)},d.prototype.fork=function(){return this.states=new u(this),this.head=this.tail=new l(c,0,0),this.len=0,this},d.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new l(c,0,0),this.len=0),this},d.prototype.ldelim=function(){var e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=e.next,this.tail=t,this.len+=n),this},d.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),n=0;e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t},d._configure=function(e){r=e,d.create=p(),r._configure()}},8422:(e,t,n)=>{"use strict";e.exports=a;var r=n(4301);(a.prototype=Object.create(r.prototype)).constructor=a;var i=n(5382);function a(){r.call(this)}function o(e,t,n){e.length<40?i.utf8.write(e,t,n):t.utf8Write?t.utf8Write(e,n):t.write(e,n)}a._configure=function(){a.alloc=i._Buffer_allocUnsafe,a.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&"set"===i.Buffer.prototype.set.name?function(e,t,n){t.set(e,n)}:function(e,t,n){if(e.copy)e.copy(t,n,0,e.length);else for(var r=0;r>>0;return this.uint32(t),t&&this._push(a.writeBytesBuffer,t,e),this},a.prototype.string=function(e){var t=i.Buffer.byteLength(e);return this.uint32(t),t&&this._push(o,t,e),this},a._configure()},9111:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"DraggableCore",{enumerable:!0,get:function(){return u.default}}),t.default=void 0;var r=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=h(t);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var o=i?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(r,a,o):r[a]=e[a]}r.default=e,n&&n.set(e,r);return r}(n(5959)),i=p(n(2688)),a=p(n(8398)),o=p(n(8262)),s=n(2837),l=n(402),c=n(6732),u=p(n(1060)),d=p(n(7988));function p(e){return e&&e.__esModule?e:{default:e}}function h(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(h=function(e){return e?n:t})(e)}function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t{(0,d.default)("Draggable: onDragStart: %j",t);if(!1===this.props.onStart(e,(0,l.createDraggableData)(this,t)))return!1;this.setState({dragging:!0,dragged:!0})})),m(this,"onDrag",((e,t)=>{if(!this.state.dragging)return!1;(0,d.default)("Draggable: onDrag: %j",t);const n=(0,l.createDraggableData)(this,t),r={x:n.x,y:n.y,slackX:0,slackY:0};if(this.props.bounds){const{x:e,y:t}=r;r.x+=this.state.slackX,r.y+=this.state.slackY;const[i,a]=(0,l.getBoundPosition)(this,r.x,r.y);r.x=i,r.y=a,r.slackX=this.state.slackX+(e-r.x),r.slackY=this.state.slackY+(t-r.y),n.x=r.x,n.y=r.y,n.deltaX=r.x-this.state.x,n.deltaY=r.y-this.state.y}if(!1===this.props.onDrag(e,n))return!1;this.setState(r)})),m(this,"onDragStop",((e,t)=>{if(!this.state.dragging)return!1;if(!1===this.props.onStop(e,(0,l.createDraggableData)(this,t)))return!1;(0,d.default)("Draggable: onDragStop: %j",t);const n={dragging:!1,slackX:0,slackY:0};if(Boolean(this.props.position)){const{x:e,y:t}=this.props.position;n.x=e,n.y=t}this.setState(n)})),this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},!e.position||e.onDrag||e.onStop||console.warn("A `position` was applied to this , without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){void 0!==window.SVGElement&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.setState({dragging:!1})}findDOMNode(){var e,t;return null!==(e=null===(t=this.props)||void 0===t||null===(t=t.nodeRef)||void 0===t?void 0:t.current)&&void 0!==e?e:a.default.findDOMNode(this)}render(){const{axis:e,bounds:t,children:n,defaultPosition:i,defaultClassName:a,defaultClassNameDragging:c,defaultClassNameDragged:d,position:p,positionOffset:h,scale:m,...g}=this.props;let y={},b=null;const v=!Boolean(p)||this.state.dragging,w=p||i,S={x:(0,l.canDragX)(this)&&v?this.state.x:w.x,y:(0,l.canDragY)(this)&&v?this.state.y:w.y};this.state.isElementSVG?b=(0,s.createSVGTransform)(S,h):y=(0,s.createCSSTransform)(S,h);const E=(0,o.default)(n.props.className||"",a,{[c]:this.state.dragging,[d]:this.state.dragged});return r.createElement(u.default,f({},g,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),r.cloneElement(r.Children.only(n),{className:E,style:{...n.props.style,...y},transform:b}))}}t.default=g,m(g,"displayName","Draggable"),m(g,"propTypes",{...u.default.propTypes,axis:i.default.oneOf(["both","x","y","none"]),bounds:i.default.oneOfType([i.default.shape({left:i.default.number,right:i.default.number,top:i.default.number,bottom:i.default.number}),i.default.string,i.default.oneOf([!1])]),defaultClassName:i.default.string,defaultClassNameDragging:i.default.string,defaultClassNameDragged:i.default.string,defaultPosition:i.default.shape({x:i.default.number,y:i.default.number}),positionOffset:i.default.shape({x:i.default.oneOfType([i.default.number,i.default.string]),y:i.default.oneOfType([i.default.number,i.default.string])}),position:i.default.shape({x:i.default.number,y:i.default.number}),className:c.dontSetMe,style:c.dontSetMe,transform:c.dontSetMe}),m(g,"defaultProps",{...u.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})},1060:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=d(t);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var o=i?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(r,a,o):r[a]=e[a]}r.default=e,n&&n.set(e,r);return r}(n(5959)),i=u(n(2688)),a=u(n(8398)),o=n(2837),s=n(402),l=n(6732),c=u(n(7988));function u(e){return e&&e.__esModule?e:{default:e}}function d(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(d=function(e){return e?n:t})(e)}function p(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const h={start:"touchstart",move:"touchmove",stop:"touchend"},f={start:"mousedown",move:"mousemove",stop:"mouseup"};let m=f;class g extends r.Component{constructor(){super(...arguments),p(this,"dragging",!1),p(this,"lastX",NaN),p(this,"lastY",NaN),p(this,"touchIdentifier",null),p(this,"mounted",!1),p(this,"handleDragStart",(e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&"number"==typeof e.button&&0!==e.button)return!1;const t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw new Error(" not mounted on DragStart!");const{ownerDocument:n}=t;if(this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!(0,o.matchesSelectorAndParentsTo)(e.target,this.props.handle,t)||this.props.cancel&&(0,o.matchesSelectorAndParentsTo)(e.target,this.props.cancel,t))return;"touchstart"===e.type&&e.preventDefault();const r=(0,o.getTouchIdentifier)(e);this.touchIdentifier=r;const i=(0,s.getControlPosition)(e,r,this);if(null==i)return;const{x:a,y:l}=i,u=(0,s.createCoreData)(this,a,l);(0,c.default)("DraggableCore: handleDragStart: %j",u),(0,c.default)("calling",this.props.onStart);!1!==this.props.onStart(e,u)&&!1!==this.mounted&&(this.props.enableUserSelectHack&&(0,o.addUserSelectStyles)(n),this.dragging=!0,this.lastX=a,this.lastY=l,(0,o.addEvent)(n,m.move,this.handleDrag),(0,o.addEvent)(n,m.stop,this.handleDragStop))})),p(this,"handleDrag",(e=>{const t=(0,s.getControlPosition)(e,this.touchIdentifier,this);if(null==t)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX,t=r-this.lastY;if([e,t]=(0,s.snapToGrid)(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,r=this.lastY+t}const i=(0,s.createCoreData)(this,n,r);(0,c.default)("DraggableCore: handleDrag: %j",i);if(!1!==this.props.onDrag(e,i)&&!1!==this.mounted)this.lastX=n,this.lastY=r;else try{this.handleDragStop(new MouseEvent("mouseup"))}catch(e){const t=document.createEvent("MouseEvents");t.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(t)}})),p(this,"handleDragStop",(e=>{if(!this.dragging)return;const t=(0,s.getControlPosition)(e,this.touchIdentifier,this);if(null==t)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX||0,t=r-this.lastY||0;[e,t]=(0,s.snapToGrid)(this.props.grid,e,t),n=this.lastX+e,r=this.lastY+t}const i=(0,s.createCoreData)(this,n,r);if(!1===this.props.onStop(e,i)||!1===this.mounted)return!1;const a=this.findDOMNode();a&&this.props.enableUserSelectHack&&(0,o.removeUserSelectStyles)(a.ownerDocument),(0,c.default)("DraggableCore: handleDragStop: %j",i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&((0,c.default)("DraggableCore: Removing handlers"),(0,o.removeEvent)(a.ownerDocument,m.move,this.handleDrag),(0,o.removeEvent)(a.ownerDocument,m.stop,this.handleDragStop))})),p(this,"onMouseDown",(e=>(m=f,this.handleDragStart(e)))),p(this,"onMouseUp",(e=>(m=f,this.handleDragStop(e)))),p(this,"onTouchStart",(e=>(m=h,this.handleDragStart(e)))),p(this,"onTouchEnd",(e=>(m=h,this.handleDragStop(e))))}componentDidMount(){this.mounted=!0;const e=this.findDOMNode();e&&(0,o.addEvent)(e,h.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const e=this.findDOMNode();if(e){const{ownerDocument:t}=e;(0,o.removeEvent)(t,f.move,this.handleDrag),(0,o.removeEvent)(t,h.move,this.handleDrag),(0,o.removeEvent)(t,f.stop,this.handleDragStop),(0,o.removeEvent)(t,h.stop,this.handleDragStop),(0,o.removeEvent)(e,h.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,o.removeUserSelectStyles)(t)}}findDOMNode(){var e,t;return null!==(e=this.props)&&void 0!==e&&e.nodeRef?null===(t=this.props)||void 0===t||null===(t=t.nodeRef)||void 0===t?void 0:t.current:a.default.findDOMNode(this)}render(){return r.cloneElement(r.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}}t.default=g,p(g,"displayName","DraggableCore"),p(g,"propTypes",{allowAnyClick:i.default.bool,children:i.default.node.isRequired,disabled:i.default.bool,enableUserSelectHack:i.default.bool,offsetParent:function(e,t){if(e[t]&&1!==e[t].nodeType)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:i.default.arrayOf(i.default.number),handle:i.default.string,cancel:i.default.string,nodeRef:i.default.object,onStart:i.default.func,onDrag:i.default.func,onStop:i.default.func,onMouseDown:i.default.func,scale:i.default.number,className:l.dontSetMe,style:l.dontSetMe,transform:l.dontSetMe}),p(g,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1})},8230:(e,t,n)=>{"use strict";const{default:r,DraggableCore:i}=n(9111);e.exports=r,e.exports.default=r,e.exports.DraggableCore=i},2837:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addClassName=c,t.addEvent=function(e,t,n,r){if(!e)return;const i={capture:!0,...r};e.addEventListener?e.addEventListener(t,n,i):e.attachEvent?e.attachEvent("on"+t,n):e["on"+t]=n},t.addUserSelectStyles=function(e){if(!e)return;let t=e.getElementById("react-draggable-style-el");t||(t=e.createElement("style"),t.type="text/css",t.id="react-draggable-style-el",t.innerHTML=".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n",t.innerHTML+=".react-draggable-transparent-selection *::selection {all: inherit;}\n",e.getElementsByTagName("head")[0].appendChild(t));e.body&&c(e.body,"react-draggable-transparent-selection")},t.createCSSTransform=function(e,t){const n=l(e,t,"px");return{[(0,i.browserPrefixToKey)("transform",i.default)]:n}},t.createSVGTransform=function(e,t){return l(e,t,"")},t.getTouch=function(e,t){return e.targetTouches&&(0,r.findInArray)(e.targetTouches,(e=>t===e.identifier))||e.changedTouches&&(0,r.findInArray)(e.changedTouches,(e=>t===e.identifier))},t.getTouchIdentifier=function(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier},t.getTranslation=l,t.innerHeight=function(e){let t=e.clientHeight;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=(0,r.int)(n.paddingTop),t-=(0,r.int)(n.paddingBottom),t},t.innerWidth=function(e){let t=e.clientWidth;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=(0,r.int)(n.paddingLeft),t-=(0,r.int)(n.paddingRight),t},t.matchesSelector=s,t.matchesSelectorAndParentsTo=function(e,t,n){let r=e;do{if(s(r,t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1},t.offsetXYFromParent=function(e,t,n){const r=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect(),i=(e.clientX+t.scrollLeft-r.left)/n,a=(e.clientY+t.scrollTop-r.top)/n;return{x:i,y:a}},t.outerHeight=function(e){let t=e.clientHeight;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=(0,r.int)(n.borderTopWidth),t+=(0,r.int)(n.borderBottomWidth),t},t.outerWidth=function(e){let t=e.clientWidth;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=(0,r.int)(n.borderLeftWidth),t+=(0,r.int)(n.borderRightWidth),t},t.removeClassName=u,t.removeEvent=function(e,t,n,r){if(!e)return;const i={capture:!0,...r};e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent?e.detachEvent("on"+t,n):e["on"+t]=null},t.removeUserSelectStyles=function(e){if(!e)return;try{if(e.body&&u(e.body,"react-draggable-transparent-selection"),e.selection)e.selection.empty();else{const t=(e.defaultView||window).getSelection();t&&"Caret"!==t.type&&t.removeAllRanges()}}catch(e){}};var r=n(6732),i=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=a(t);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=i?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}r.default=e,n&&n.set(e,r);return r}(n(7350));function a(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(a=function(e){return e?n:t})(e)}let o="";function s(e,t){return o||(o=(0,r.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],(function(t){return(0,r.isFunction)(e[t])}))),!!(0,r.isFunction)(e[o])&&e[o](t)}function l(e,t,n){let{x:r,y:i}=e,a="translate(".concat(r).concat(n,",").concat(i).concat(n,")");if(t){const e="".concat("string"==typeof t.x?t.x:t.x+n),r="".concat("string"==typeof t.y?t.y:t.y+n);a="translate(".concat(e,", ").concat(r,")")+a}return a}function c(e,t){e.classList?e.classList.add(t):e.className.match(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)")))||(e.className+=" ".concat(t))}function u(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)"),"g"),"")}},7350:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.browserPrefixToKey=i,t.browserPrefixToStyle=function(e,t){return t?"-".concat(t.toLowerCase(),"-").concat(e):e},t.default=void 0,t.getPrefix=r;const n=["Moz","Webkit","O","ms"];function r(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"transform";if("undefined"==typeof window)return"";const r=null===(e=window.document)||void 0===e||null===(e=e.documentElement)||void 0===e?void 0:e.style;if(!r)return"";if(t in r)return"";for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){0}},402:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.canDragX=function(e){return"both"===e.props.axis||"x"===e.props.axis},t.canDragY=function(e){return"both"===e.props.axis||"y"===e.props.axis},t.createCoreData=function(e,t,n){const i=!(0,r.isNum)(e.lastX),o=a(e);return i?{node:o,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:o,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}},t.createDraggableData=function(e,t){const n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}},t.getBoundPosition=function(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:o}=e.props;o="string"==typeof o?o:function(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}(o);const s=a(e);if("string"==typeof o){const{ownerDocument:e}=s,t=e.defaultView;let n;if(n="parent"===o?s.parentNode:e.querySelector(o),!(n instanceof t.HTMLElement))throw new Error('Bounds selector "'+o+'" could not find an element.');const a=n,l=t.getComputedStyle(s),c=t.getComputedStyle(a);o={left:-s.offsetLeft+(0,r.int)(c.paddingLeft)+(0,r.int)(l.marginLeft),top:-s.offsetTop+(0,r.int)(c.paddingTop)+(0,r.int)(l.marginTop),right:(0,i.innerWidth)(a)-(0,i.outerWidth)(s)-s.offsetLeft+(0,r.int)(c.paddingRight)-(0,r.int)(l.marginRight),bottom:(0,i.innerHeight)(a)-(0,i.outerHeight)(s)-s.offsetTop+(0,r.int)(c.paddingBottom)-(0,r.int)(l.marginBottom)}}(0,r.isNum)(o.right)&&(t=Math.min(t,o.right));(0,r.isNum)(o.bottom)&&(n=Math.min(n,o.bottom));(0,r.isNum)(o.left)&&(t=Math.max(t,o.left));(0,r.isNum)(o.top)&&(n=Math.max(n,o.top));return[t,n]},t.getControlPosition=function(e,t,n){const r="number"==typeof t?(0,i.getTouch)(e,t):null;if("number"==typeof t&&!r)return null;const o=a(n),s=n.props.offsetParent||o.offsetParent||o.ownerDocument.body;return(0,i.offsetXYFromParent)(r||e,s,n.props.scale)},t.snapToGrid=function(e,t,n){const r=Math.round(t/e[0])*e[0],i=Math.round(n/e[1])*e[1];return[r,i]};var r=n(6732),i=n(2837);function a(e){const t=e.findDOMNode();if(!t)throw new Error(": Unmounted during event!");return t}},6732:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dontSetMe=function(e,t,n){if(e[t])return new Error("Invalid prop ".concat(t," passed to ").concat(n," - do not set this, set it on the child."))},t.findInArray=function(e,t){for(let n=0,r=e.length;n{"use strict";function r(e){var t,n,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;ti,default:()=>a});const a=i},7383:e=>{var t="undefined"!=typeof Element,n="function"==typeof Map,r="function"==typeof Set,i="function"==typeof ArrayBuffer&&!!ArrayBuffer.isView;function a(e,o){if(e===o)return!0;if(e&&o&&"object"==typeof e&&"object"==typeof o){if(e.constructor!==o.constructor)return!1;var s,l,c,u;if(Array.isArray(e)){if((s=e.length)!=o.length)return!1;for(l=s;0!=l--;)if(!a(e[l],o[l]))return!1;return!0}if(n&&e instanceof Map&&o instanceof Map){if(e.size!==o.size)return!1;for(u=e.entries();!(l=u.next()).done;)if(!o.has(l.value[0]))return!1;for(u=e.entries();!(l=u.next()).done;)if(!a(l.value[1],o.get(l.value[0])))return!1;return!0}if(r&&e instanceof Set&&o instanceof Set){if(e.size!==o.size)return!1;for(u=e.entries();!(l=u.next()).done;)if(!o.has(l.value[0]))return!1;return!0}if(i&&ArrayBuffer.isView(e)&&ArrayBuffer.isView(o)){if((s=e.length)!=o.length)return!1;for(l=s;0!=l--;)if(e[l]!==o[l])return!1;return!0}if(e.constructor===RegExp)return e.source===o.source&&e.flags===o.flags;if(e.valueOf!==Object.prototype.valueOf&&"function"==typeof e.valueOf&&"function"==typeof o.valueOf)return e.valueOf()===o.valueOf();if(e.toString!==Object.prototype.toString&&"function"==typeof e.toString&&"function"==typeof o.toString)return e.toString()===o.toString();if((s=(c=Object.keys(e)).length)!==Object.keys(o).length)return!1;for(l=s;0!=l--;)if(!Object.prototype.hasOwnProperty.call(o,c[l]))return!1;if(t&&e instanceof Element)return!1;for(l=s;0!=l--;)if(("_owner"!==c[l]&&"__v"!==c[l]&&"__o"!==c[l]||!e.$$typeof)&&!a(e[c[l]],o[c[l]]))return!1;return!0}return e!=e&&o!=o}e.exports=function(e,t){try{return a(e,t)}catch(e){if((e.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw e}}},8100:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=p(n(5959)),a=p(n(2688)),o=n(8230),s=n(936),l=n(414),c=n(906),u=n(7222),d=p(n(7256));function p(e){return e&&e.__esModule?e:{default:e}}function h(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:this.props;return{cols:e.cols,containerPadding:e.containerPadding,containerWidth:e.containerWidth,margin:e.margin,maxRows:e.maxRows,rowHeight:e.rowHeight}}},{key:"createStyle",value:function(e){var t,n=this.props,r=n.usePercentages,i=n.containerWidth;return n.useCSSTransforms?t=(0,l.setTransform)(e):(t=(0,l.setTopLeft)(e),r&&(t.left=(0,l.perc)(e.left/i),t.width=(0,l.perc)(e.width/i))),t}},{key:"mixinDraggable",value:function(e,t){return i.default.createElement(o.DraggableCore,{disabled:!t,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop,handle:this.props.handle,cancel:".react-resizable-handle"+(this.props.cancel?","+this.props.cancel:""),scale:this.props.transformScale,nodeRef:this.elementRef},e)}},{key:"mixinResizable",value:function(e,t,n){var r=this.props,a=r.cols,o=r.x,l=r.minW,u=r.minH,d=r.maxW,p=r.maxH,h=r.transformScale,f=r.resizeHandles,m=r.resizeHandle,g=this.getPositionParams(),y=(0,c.calcGridItemPosition)(g,0,0,a-o,0).width,b=(0,c.calcGridItemPosition)(g,0,0,l,u),v=(0,c.calcGridItemPosition)(g,0,0,d,p),w=[b.width,b.height],S=[Math.min(v.width,y),Math.min(v.height,1/0)];return i.default.createElement(s.Resizable,{draggableOpts:{disabled:!n},className:n?void 0:"react-resizable-hide",width:t.width,height:t.height,minConstraints:w,maxConstraints:S,onResizeStop:this.onResizeStop,onResizeStart:this.onResizeStart,onResize:this.onResize,transformScale:h,resizeHandles:f,handle:m},e)}},{key:"onResizeHandler",value:function(e,t,n){var r=t.node,i=t.size,a=this.props[n];if(a){var o=this.props,s=o.cols,l=o.x,u=o.y,d=o.i,p=o.maxH,h=o.minH,f=this.props,m=f.minW,g=f.maxW,y=(0,c.calcWH)(this.getPositionParams(),i.width,i.height,l,u),b=y.w,v=y.h;m=Math.max(m,1),g=Math.min(g,s-l),b=(0,c.clamp)(b,m,g),v=(0,c.clamp)(v,h,p),this.setState({resizing:"onResizeStop"===n?null:i}),a.call(this,d,b,v,{e,node:r,size:i})}}},{key:"render",value:function(){var e=this.props,t=e.x,n=e.y,r=e.w,a=e.h,o=e.isDraggable,s=e.isResizable,l=e.droppingPosition,u=e.useCSSTransforms,p=(0,c.calcGridItemPosition)(this.getPositionParams(),t,n,r,a,this.state),h=i.default.Children.only(this.props.children),m=i.default.cloneElement(h,{ref:this.elementRef,className:(0,d.default)("react-grid-item",h.props.className,this.props.className,{static:this.props.static,resizing:Boolean(this.state.resizing),"react-draggable":o,"react-draggable-dragging":Boolean(this.state.dragging),dropping:Boolean(l),cssTransforms:u}),style:f(f(f({},this.props.style),h.props.style),this.createStyle(p))});return m=this.mixinResizable(m,p,s),m=this.mixinDraggable(m,o)}}],n&&m(t.prototype,n),r&&m(t,r),Object.defineProperty(t,"prototype",{writable:!1}),u}(i.default.Component);t.default=S,w(S,"propTypes",{children:a.default.element,cols:a.default.number.isRequired,containerWidth:a.default.number.isRequired,rowHeight:a.default.number.isRequired,margin:a.default.array.isRequired,maxRows:a.default.number.isRequired,containerPadding:a.default.array.isRequired,x:a.default.number.isRequired,y:a.default.number.isRequired,w:a.default.number.isRequired,h:a.default.number.isRequired,minW:function(e,t){var n=e[t];return"number"!=typeof n?new Error("minWidth not Number"):n>e.w||n>e.maxW?new Error("minWidth larger than item width/maxWidth"):void 0},maxW:function(e,t){var n=e[t];return"number"!=typeof n?new Error("maxWidth not Number"):ne.h||n>e.maxH?new Error("minHeight larger than item height/maxHeight"):void 0},maxH:function(e,t){var n=e[t];return"number"!=typeof n?new Error("maxHeight not Number"):n{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var n=p(t);if(n&&n.has(e))return n.get(e);var i={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=a?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(i,o,s):i[o]=e[o]}i.default=e,n&&n.set(e,i);return i}(n(5959)),a=d(n(7842)),o=d(n(7256)),s=n(414),l=n(906),c=d(n(8100)),u=d(n(7222));function d(e){return e&&e.__esModule?e:{default:e}}function p(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(p=function(e){return e?n:t})(e)}function h(e){return function(e){if(Array.isArray(e))return b(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||y(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function m(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n0){var a=1/0,o=1/0;i.forEach((function(t){t.x>e.x&&(a=Math.min(a,t.x)),t.y>e.y&&(o=Math.min(o,t.y))})),Number.isFinite(a)&&(e.w=a-e.x),Number.isFinite(o)&&(e.h=o-e.y)}}return t||(e.w=n,e.h=r),e})),b=g(y,2),v=b[0],w=b[1];if(w){var S={w:w.w,h:w.h,x:w.x,y:w.y,static:!0,i:t};e.props.onResize(v,u,w,S,a,o),e.setState({layout:f?v:(0,s.compact)(v,(0,s.compactType)(e.props),p),activeDrag:S})}})),O(E(e),"onResizeStop",(function(t,n,r,i){var a=i.e,o=i.node,l=e.state,c=l.layout,u=l.oldResizeItem,d=e.props,p=d.cols,h=d.allowOverlap,f=(0,s.getLayoutItem)(c,t);e.props.onResizeStop(c,u,f,null,a,o);var m=h?c:(0,s.compact)(c,(0,s.compactType)(e.props),p),g=e.state.oldLayout;e.setState({activeDrag:null,layout:m,oldResizeItem:null,oldLayout:null}),e.onLayoutMaybeChanged(m,g)})),O(E(e),"onDragOver",(function(t){var n;if(t.preventDefault(),t.stopPropagation(),T&&(null===(n=t.nativeEvent.target)||void 0===n||!n.classList.contains(_)))return!1;var r=e.props,a=r.droppingItem,o=r.onDropDragOver,s=r.margin,c=r.cols,u=r.rowHeight,d=r.maxRows,p=r.width,f=r.containerPadding,g=r.transformScale,y=null==o?void 0:o(t);if(!1===y)return e.state.droppingDOMNode&&e.removeDroppingPlaceholder(),!1;var b=m(m({},a),y),v=e.state.layout,w=t.nativeEvent,S=w.layerX,E=w.layerY,x={left:S/g,top:E/g,e:t};if(e.state.droppingDOMNode){if(e.state.droppingPosition){var O=e.state.droppingPosition,C=O.left,k=O.top;(C!=S||k!=E)&&e.setState({droppingPosition:x})}}else{var P={cols:c,margin:s,maxRows:d,rowHeight:u,containerWidth:p,containerPadding:f||s},R=(0,l.calcXY)(P,E,S,b.w,b.h);e.setState({droppingDOMNode:i.createElement("div",{key:b.i}),droppingPosition:x,layout:[].concat(h(v),[m(m({},b),{},{x:R.x,y:R.y,static:!1,isDraggable:!0})])})}})),O(E(e),"removeDroppingPlaceholder",(function(){var t=e.props,n=t.droppingItem,r=t.cols,i=e.state.layout,a=(0,s.compact)(i.filter((function(e){return e.i!==n.i})),(0,s.compactType)(e.props),r);e.setState({layout:a,droppingDOMNode:null,activeDrag:null,droppingPosition:void 0})})),O(E(e),"onDragLeave",(function(t){t.preventDefault(),t.stopPropagation(),e.dragEnterCounter--,0===e.dragEnterCounter&&e.removeDroppingPlaceholder()})),O(E(e),"onDragEnter",(function(t){t.preventDefault(),t.stopPropagation(),e.dragEnterCounter++})),O(E(e),"onDrop",(function(t){t.preventDefault(),t.stopPropagation();var n=e.props.droppingItem,r=e.state.layout,i=r.find((function(e){return e.i===n.i}));e.dragEnterCounter=0,e.removeDroppingPlaceholder(),e.props.onDrop(r,i,t)})),e}return t=d,r=[{key:"getDerivedStateFromProps",value:function(e,t){var n;return t.activeDrag?null:((0,a.default)(e.layout,t.propsLayout)&&e.compactType===t.compactType?(0,s.childrenEqual)(e.children,t.children)||(n=t.layout):n=e.layout,n?{layout:(0,s.synchronizeLayoutWithChildren)(n,e.children,e.cols,(0,s.compactType)(e),e.allowOverlap),compactType:e.compactType,children:e.children,propsLayout:e.layout}:null)}}],(n=[{key:"componentDidMount",value:function(){this.setState({mounted:!0}),this.onLayoutMaybeChanged(this.state.layout,this.props.layout)}},{key:"shouldComponentUpdate",value:function(e,t){return this.props.children!==e.children||!(0,s.fastRGLPropsEqual)(this.props,e,a.default)||this.state.activeDrag!==t.activeDrag||this.state.mounted!==t.mounted||this.state.droppingPosition!==t.droppingPosition}},{key:"componentDidUpdate",value:function(e,t){if(!this.state.activeDrag){var n=this.state.layout,r=t.layout;this.onLayoutMaybeChanged(n,r)}}},{key:"containerHeight",value:function(){if(this.props.autoSize){var e=(0,s.bottom)(this.state.layout),t=this.props.containerPadding?this.props.containerPadding[1]:this.props.margin[1];return e*this.props.rowHeight+(e-1)*this.props.margin[1]+2*t+"px"}}},{key:"onLayoutMaybeChanged",value:function(e,t){t||(t=this.state.layout),(0,a.default)(t,e)||this.props.onLayoutChange(e)}},{key:"placeholder",value:function(){var e=this.state.activeDrag;if(!e)return null;var t=this.props,n=t.width,r=t.cols,a=t.margin,o=t.containerPadding,s=t.rowHeight,l=t.maxRows,u=t.useCSSTransforms,d=t.transformScale;return i.createElement(c.default,{w:e.w,h:e.h,x:e.x,y:e.y,i:e.i,className:"react-grid-placeholder",containerWidth:n,cols:r,margin:a,containerPadding:o||a,maxRows:l,rowHeight:s,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:u,transformScale:d},i.createElement("div",null))}},{key:"processGridItem",value:function(e,t){if(e&&e.key){var n=(0,s.getLayoutItem)(this.state.layout,String(e.key));if(!n)return null;var r=this.props,a=r.width,o=r.cols,l=r.margin,u=r.containerPadding,d=r.rowHeight,p=r.maxRows,h=r.isDraggable,f=r.isResizable,m=r.isBounded,g=r.useCSSTransforms,y=r.transformScale,b=r.draggableCancel,v=r.draggableHandle,w=r.resizeHandles,S=r.resizeHandle,E=this.state,x=E.mounted,O=E.droppingPosition,_="boolean"==typeof n.isDraggable?n.isDraggable:!n.static&&h,T="boolean"==typeof n.isResizable?n.isResizable:!n.static&&f,C=n.resizeHandles||w,k=_&&m&&!1!==n.isBounded;return i.createElement(c.default,{containerWidth:a,cols:o,margin:l,containerPadding:u||l,maxRows:p,rowHeight:d,cancel:b,handle:v,onDragStop:this.onDragStop,onDragStart:this.onDragStart,onDrag:this.onDrag,onResizeStart:this.onResizeStart,onResize:this.onResize,onResizeStop:this.onResizeStop,isDraggable:_,isResizable:T,isBounded:k,useCSSTransforms:g&&x,usePercentages:!x,transformScale:y,w:n.w,h:n.h,x:n.x,y:n.y,i:n.i,minH:n.minH,minW:n.minW,maxH:n.maxH,maxW:n.maxW,static:n.static,droppingPosition:t?O:void 0,resizeHandles:C,resizeHandle:S},e)}}},{key:"render",value:function(){var e=this,t=this.props,n=t.className,r=t.style,a=t.isDroppable,l=t.innerRef,c=(0,o.default)(_,n),u=m({height:this.containerHeight()},r);return i.createElement("div",{ref:l,className:c,style:u,onDrop:a?this.onDrop:s.noop,onDragLeave:a?this.onDragLeave:s.noop,onDragEnter:a?this.onDragEnter:s.noop,onDragOver:a?this.onDragOver:s.noop},i.Children.map(this.props.children,(function(t){return e.processGridItem(t)})),a&&this.state.droppingDOMNode&&this.processGridItem(this.state.droppingDOMNode,!0),this.placeholder())}}])&&v(t.prototype,n),r&&v(t,r),Object.defineProperty(t,"prototype",{writable:!1}),d}(i.Component);t.default=C,O(C,"displayName","ReactGridLayout"),O(C,"propTypes",u.default),O(C,"defaultProps",{autoSize:!0,cols:12,className:"",style:{},draggableHandle:"",draggableCancel:"",containerPadding:null,rowHeight:150,maxRows:1/0,layout:[],margin:[10,10],isBounded:!1,isDraggable:!0,isResizable:!0,allowOverlap:!1,isDroppable:!1,useCSSTransforms:!0,transformScale:1,verticalCompact:!0,compactType:"vertical",preventCollision:!1,droppingItem:{i:"__dropping-elem__",h:1,w:1},resizeHandles:["se"],onLayoutChange:s.noop,onDragStart:s.noop,onDrag:s.noop,onDragStop:s.noop,onResizeStart:s.noop,onResize:s.noop,onResizeStop:s.noop,onDrop:s.noop,onDropDragOver:s.noop})},7222:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resizeHandleType=t.resizeHandleAxesType=t.default=void 0;var r=a(n(2688)),i=a(n(5959));function a(e){return e&&e.__esModule?e:{default:e}}var o=r.default.arrayOf(r.default.oneOf(["s","w","e","n","sw","nw","se","ne"]));t.resizeHandleAxesType=o;var s=r.default.oneOfType([r.default.node,r.default.func]);t.resizeHandleType=s;var l={className:r.default.string,style:r.default.object,width:r.default.number,autoSize:r.default.bool,cols:r.default.number,draggableCancel:r.default.string,draggableHandle:r.default.string,verticalCompact:function(e){e.verticalCompact,0},compactType:r.default.oneOf(["vertical","horizontal"]),layout:function(e){var t=e.layout;void 0!==t&&n(414).validateLayout(t,"layout")},margin:r.default.arrayOf(r.default.number),containerPadding:r.default.arrayOf(r.default.number),rowHeight:r.default.number,maxRows:r.default.number,isBounded:r.default.bool,isDraggable:r.default.bool,isResizable:r.default.bool,allowOverlap:r.default.bool,preventCollision:r.default.bool,useCSSTransforms:r.default.bool,transformScale:r.default.number,isDroppable:r.default.bool,resizeHandles:o,resizeHandle:s,onLayoutChange:r.default.func,onDragStart:r.default.func,onDrag:r.default.func,onDragStop:r.default.func,onResizeStart:r.default.func,onResize:r.default.func,onResizeStop:r.default.func,onDrop:r.default.func,droppingItem:r.default.shape({i:r.default.string.isRequired,w:r.default.number.isRequired,h:r.default.number.isRequired}),children:function(e,t){var n=e[t],r={};i.default.Children.forEach(n,(function(e){if(null!=(null==e?void 0:e.key)){if(r[e.key])throw new Error('Duplicate child key "'+e.key+'" found! This will cause problems in ReactGridLayout.');r[e.key]=!0}}))},innerRef:r.default.any};t.default=l},4636:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}t.default=void 0;var i=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var n=p(t);if(n&&n.has(e))return n.get(e);var i={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=a?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(i,o,s):i[o]=e[o]}i.default=e,n&&n.set(e,i);return i}(n(5959)),a=d(n(2688)),o=d(n(7842)),s=n(414),l=n(544),c=d(n(9482)),u=["breakpoint","breakpoints","cols","layouts","margin","containerPadding","onBreakpointChange","onLayoutChange","onWidthChange"];function d(e){return e&&e.__esModule?e:{default:e}}function p(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(p=function(e){return e?n:t})(e)}function h(){return h=Object.assign||function(e){for(var t=1;t=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function m(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function g(e){for(var t=1;t{"use strict";function n(e){var t=e.margin,n=e.containerPadding,r=e.containerWidth,i=e.cols;return(r-t[0]*(i-1)-2*n[0])/i}function r(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function i(e,t,n){return Math.max(Math.min(e,n),t)}Object.defineProperty(t,"__esModule",{value:!0}),t.calcGridColWidth=n,t.calcGridItemPosition=function(e,t,i,a,o,s){var l=e.margin,c=e.containerPadding,u=e.rowHeight,d=n(e),p={};s&&s.resizing?(p.width=Math.round(s.resizing.width),p.height=Math.round(s.resizing.height)):(p.width=r(a,d,l[0]),p.height=r(o,u,l[1]));s&&s.dragging?(p.top=Math.round(s.dragging.top),p.left=Math.round(s.dragging.left)):(p.top=Math.round((u+l[1])*i+c[1]),p.left=Math.round((d+l[0])*t+c[0]));return p},t.calcGridItemWHPx=r,t.calcWH=function(e,t,r,a,o){var s=e.margin,l=e.maxRows,c=e.cols,u=e.rowHeight,d=n(e),p=Math.round((t+s[0])/(d+s[0])),h=Math.round((r+s[1])/(u+s[1]));return p=i(p,0,c-a),h=i(h,0,l-o),{w:p,h}},t.calcXY=function(e,t,r,a,o){var s=e.margin,l=e.cols,c=e.rowHeight,u=e.maxRows,d=n(e),p=Math.round((r-s[0])/(d+s[0])),h=Math.round((t-s[1])/(c+s[1]));return p=i(p,0,l-a),h=i(h,0,u-o),{x:p,y:h}},t.clamp=i},6805:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}t.default=function(e){var t;return t=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(c,t);var n,a,l=(n=c,a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=f(n);if(a){var i=f(this).constructor;e=Reflect.construct(t,arguments,i)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}(this,e)});function c(){var e;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c);for(var t=arguments.length,n=new Array(t),r=0;r=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(t,s);return n&&!this.mounted?i.createElement("div",{className:(0,o.default)(this.props.className,g),style:this.props.style,ref:this.elementRef}):i.createElement(e,u({innerRef:this.elementRef},r,this.state))}}]),c}(i.Component),m(t,"defaultProps",{measureBeforeMount:!1}),m(t,"propTypes",{measureBeforeMount:a.default.bool}),t};var i=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var n=c(t);if(n&&n.has(e))return n.get(e);var i={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=a?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(i,o,s):i[o]=e[o]}i.default=e,n&&n.set(e,i);return i}(n(5959)),a=l(n(2688)),o=l(n(7256)),s=["measureBeforeMount"];function l(e){return e&&e.__esModule?e:{default:e}}function c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(c=function(e){return e?n:t})(e)}function u(){return u=Object.assign||function(e){for(var t=1;t{e.exports=function(e,t,n){return e===t||e.className===t.className&&n(e.style,t.style)&&e.width===t.width&&e.autoSize===t.autoSize&&e.cols===t.cols&&e.draggableCancel===t.draggableCancel&&e.draggableHandle===t.draggableHandle&&n(e.verticalCompact,t.verticalCompact)&&n(e.compactType,t.compactType)&&n(e.layout,t.layout)&&n(e.margin,t.margin)&&n(e.containerPadding,t.containerPadding)&&e.rowHeight===t.rowHeight&&e.maxRows===t.maxRows&&e.isBounded===t.isBounded&&e.isDraggable===t.isDraggable&&e.isResizable===t.isResizable&&e.allowOverlap===t.allowOverlap&&e.preventCollision===t.preventCollision&&e.useCSSTransforms===t.useCSSTransforms&&e.transformScale===t.transformScale&&e.isDroppable===t.isDroppable&&n(e.resizeHandles,t.resizeHandles)&&n(e.resizeHandle,t.resizeHandle)&&e.onLayoutChange===t.onLayoutChange&&e.onDragStart===t.onDragStart&&e.onDrag===t.onDrag&&e.onDragStop===t.onDragStop&&e.onResizeStart===t.onResizeStart&&e.onResize===t.onResize&&e.onResizeStop===t.onResizeStop&&e.onDrop===t.onDrop&&n(e.droppingItem,t.droppingItem)&&n(e.innerRef,t.innerRef)}},544:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findOrGenerateResponsiveLayout=function(e,t,n,a,o,s){if(e[n])return(0,r.cloneLayout)(e[n]);for(var l=e[a],c=i(t),u=c.slice(c.indexOf(n)),d=0,p=u.length;de[s]&&(r=s)}return r},t.getColsFromBreakpoint=function(e,t){if(!t[e])throw new Error("ResponsiveReactGridLayout: `cols` entry for breakpoint "+e+" is missing!");return t[e]},t.sortBreakpoints=i;var r=n(414);function i(e){return Object.keys(e).sort((function(t,n){return e[t]-e[n]}))}},414:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bottom=d,t.childrenEqual=function(e,t){return(0,r.default)(i.default.Children.map(e,(function(e){return null==e?void 0:e.key})),i.default.Children.map(t,(function(e){return null==e?void 0:e.key})))},t.cloneLayout=p,t.cloneLayoutItem=f,t.collides=g,t.compact=y,t.compactItem=w,t.compactType=function(e){var t=e||{},n=t.verticalCompact,r=t.compactType;return!1===n?null:r},t.correctBounds=S,t.fastPositionEqual=function(e,t){return e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height},t.fastRGLPropsEqual=void 0,t.getAllCollisions=O,t.getFirstCollision=x,t.getLayoutItem=E,t.getStatics=_,t.modifyLayout=h,t.moveElement=T,t.moveElementAwayFromCollision=C,t.noop=void 0,t.perc=function(e){return 100*e+"%"},t.setTopLeft=function(e){var t=e.top,n=e.left,r=e.width,i=e.height;return{top:"".concat(t,"px"),left:"".concat(n,"px"),width:"".concat(r,"px"),height:"".concat(i,"px"),position:"absolute"}},t.setTransform=function(e){var t=e.top,n=e.left,r=e.width,i=e.height,a="translate(".concat(n,"px,").concat(t,"px)");return{transform:a,WebkitTransform:a,MozTransform:a,msTransform:a,OTransform:a,width:"".concat(r,"px"),height:"".concat(i,"px"),position:"absolute"}},t.sortLayoutItems=k,t.sortLayoutItemsByColRow=R,t.sortLayoutItemsByRowCol=P,t.synchronizeLayoutWithChildren=function(e,t,n,r,a){e=e||[];var o=[];i.default.Children.forEach(t,(function(t){if(null!=(null==t?void 0:t.key)){var n=E(e,String(t.key));if(n)o.push(f(n));else{!c&&t.props._grid&&console.warn("`_grid` properties on children have been deprecated as of React 15.2. Please use `data-grid` or add your properties directly to the `layout`.");var r=t.props["data-grid"]||t.props._grid;r?(c||A([r],"ReactGridLayout.children"),o.push(f(s(s({},r),{},{i:t.key})))):o.push(f({w:1,h:1,x:0,y:d(o),i:String(t.key)}))}}}));var l=S(o,{cols:n});return a?l:y(l,r,n)},t.validateLayout=A,t.withLayoutItem=function(e,t,n){var r=E(e,t);return r?(r=n(f(r)),[e=h(e,r),r]):[e,null]};var r=a(n(7842)),i=a(n(5959));function a(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;tn&&(n=t);return n}function p(e){for(var t=Array(e.length),n=0,r=e.length;n=t.x+t.w)&&(!(e.y+e.h<=t.y)&&!(e.y>=t.y+t.h))))}function y(e,t,n){for(var r=_(e),i=k(e,t),a=Array(e.length),o=0,s=i.length;ot.y+t.h)break;g(t,o)&&v(e,o,n+t[i],r)}}t[r]=n}function w(e,t,n,r,i){var a,o="horizontal"===n;if("vertical"===n)for(t.y=Math.min(d(e),t.y);t.y>0&&!x(e,t);)t.y--;else if(o)for(;t.x>0&&!x(e,t);)t.x--;for(;a=x(e,t);)o?v(i,t,a.x+a.w,"x"):v(i,t,a.y+a.h,"y"),o&&t.x+t.w>r&&(t.x=r-t.w,t.y++);return t.y=Math.max(t.y,0),t.x=Math.max(t.x,0),t}function S(e,t){for(var n=_(e),r=0,i=e.length;rt.cols&&(a.x=t.cols-a.w),a.x<0&&(a.x=0,a.w=t.cols),a.static)for(;x(n,a);)a.y++;else n.push(a)}return e}function E(e,t){for(var n=0,r=e.length;n=r:"horizontal"===o&&"number"==typeof n&&c>=n)&&(d=d.reverse());var h=O(d,t),f=h.length>0;if(f&&l)return p(e);if(f&&a)return D("Collision prevented on ".concat(t.i,", reverting.")),t.x=c,t.y=u,t.moved=!1,e;for(var m=0,g=h.length;mt.y||e.y===t.y&&e.x>t.x?1:e.y===t.y&&e.x===t.x?0:-1}))}function R(e){return e.slice(0).sort((function(e,t){return e.x>t.x||e.x===t.x&&e.y>t.y?1:-1}))}function A(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Layout",n=["x","y","w","h"];if(!Array.isArray(e))throw new Error(t+" must be an array!");for(var r=0,i=e.length;r{e.exports=n(9482).default,e.exports.utils=n(414),e.exports.Responsive=n(4636).default,e.exports.Responsive.utils=n(544),e.exports.WidthProvider=n(6805).default},7256:(e,t,n)=>{"use strict";function r(e){var t,n,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;ti,default:()=>a});const a=i},1794:(e,t,n)=>{"use strict";t.__esModule=!0,t.default=void 0;var r=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=l(t);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var o=i?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(r,a,o):r[a]=e[a]}r.default=e,n&&n.set(e,r);return r}(n(5959)),i=n(8230),a=n(9954),o=n(6333),s=["children","className","draggableOpts","width","height","handle","handleSize","lockAspectRatio","axis","minConstraints","maxConstraints","onResize","onResizeStop","onResizeStart","resizeHandles","transformScale"];function l(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(l=function(e){return e?n:t})(e)}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;tMath.abs(l*o)?t=e/o:e=t*o}var c=e,u=t,d=this.slack||[0,0],p=d[0],h=d[1];return e+=p,t+=h,r&&(e=Math.max(r[0],e),t=Math.max(r[1],t)),i&&(e=Math.min(i[0],e),t=Math.min(i[1],t)),this.slack=[p+(c-e),h+(u-t)],[e,t]},l.resizeHandler=function(e,t){var n=this;return function(r,i){var a=i.node,o=i.deltaX,s=i.deltaY;"onResizeStart"===e&&n.resetData();var l=("both"===n.props.axis||"x"===n.props.axis)&&"n"!==t&&"s"!==t,c=("both"===n.props.axis||"y"===n.props.axis)&&"e"!==t&&"w"!==t;if(l||c){var u=t[0],d=t[t.length-1],p=a.getBoundingClientRect();if(null!=n.lastHandleRect){if("w"===d)o+=p.left-n.lastHandleRect.left;if("n"===u)s+=p.top-n.lastHandleRect.top}n.lastHandleRect=p,"w"===d&&(o=-o),"n"===u&&(s=-s);var h=n.props.width+(l?o/n.props.transformScale:0),f=n.props.height+(c?s/n.props.transformScale:0),m=n.runConstraints(h,f);h=m[0],f=m[1];var g=h!==n.props.width||f!==n.props.height,y="function"==typeof n.props[e]?n.props[e]:null;y&&!("onResize"===e&&!g)&&(null==r.persist||r.persist(),y(r,{node:a,size:{width:h,height:f},handle:t})),"onResizeStop"===e&&n.resetData()}}},l.renderResizeHandle=function(e,t){var n=this.props.handle;if(!n)return r.createElement("span",{className:"react-resizable-handle react-resizable-handle-"+e,ref:t});if("function"==typeof n)return n(e,t);var i=d({ref:t},"string"==typeof n.type?{}:{handleAxis:e});return r.cloneElement(n,i)},l.render=function(){var e=this,t=this.props,n=t.children,o=t.className,l=t.draggableOpts,u=(t.width,t.height,t.handle,t.handleSize,t.lockAspectRatio,t.axis,t.minConstraints,t.maxConstraints,t.onResize,t.onResizeStop,t.onResizeStart,t.resizeHandles),p=(t.transformScale,function(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}(t,s));return(0,a.cloneElement)(n,d(d({},p),{},{className:(o?o+" ":"")+"react-resizable",children:[].concat(n.props.children,u.map((function(t){var n,a=null!=(n=e.handleRefs[t])?n:e.handleRefs[t]=r.createRef();return r.createElement(i.DraggableCore,c({},l,{nodeRef:a,key:"resizableHandle-"+t,onStop:e.resizeHandler("onResizeStop",t),onStart:e.resizeHandler("onResizeStart",t),onDrag:e.resizeHandler("onResize",t)}),e.renderResizeHandle(t,a))})))}))},o}(r.Component);t.default=f,f.propTypes=o.resizableProps,f.defaultProps={axis:"both",handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:["se"],transformScale:1}},6609:(e,t,n)=>{"use strict";t.default=void 0;var r=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=c(t);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var o=i?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(r,a,o):r[a]=e[a]}r.default=e,n&&n.set(e,r);return r}(n(5959)),i=l(n(2688)),a=l(n(1794)),o=n(6333),s=["handle","handleSize","onResize","onResizeStart","onResizeStop","draggableOpts","minConstraints","maxConstraints","lockAspectRatio","axis","width","height","resizeHandles","style","transformScale"];function l(e){return e&&e.__esModule?e:{default:e}}function c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(c=function(e){return e?n:t})(e)}function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0||(i[n]=e[n]);return i}(e,s);return r.createElement(a.default,{axis:f,draggableOpts:l,handle:t,handleSize:n,height:this.state.height,lockAspectRatio:h,maxConstraints:d,minConstraints:c,onResizeStart:i,onResize:this.onResize,onResizeStop:o,resizeHandles:m,transformScale:y,width:this.state.width},r.createElement("div",u({},b,{style:p(p({},g),{},{width:this.state.width+"px",height:this.state.height+"px"})})))},i}(r.Component);t.default=m,m.propTypes=p(p({},o.resizableProps),{},{children:i.default.element})},6333:(e,t,n)=>{"use strict";t.__esModule=!0,t.resizableProps=void 0;var r,i=(r=n(2688))&&r.__esModule?r:{default:r};n(8230);var a={axis:i.default.oneOf(["both","x","y","none"]),className:i.default.string,children:i.default.element.isRequired,draggableOpts:i.default.shape({allowAnyClick:i.default.bool,cancel:i.default.string,children:i.default.node,disabled:i.default.bool,enableUserSelectHack:i.default.bool,offsetParent:i.default.node,grid:i.default.arrayOf(i.default.number),handle:i.default.string,nodeRef:i.default.object,onStart:i.default.func,onDrag:i.default.func,onStop:i.default.func,onMouseDown:i.default.func,scale:i.default.number}),height:function(){for(var e=arguments.length,t=new Array(e),n=0;n{"use strict";t.__esModule=!0,t.cloneElement=function(e,t){t.style&&e.props.style&&(t.style=o(o({},e.props.style),t.style));t.className&&e.props.className&&(t.className=e.props.className+" "+t.className);return i.default.cloneElement(e,t)};var r,i=(r=n(5959))&&r.__esModule?r:{default:r};function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t{"use strict";e.exports=function(){throw new Error("Don't instantiate Resizable directly! Use require('react-resizable').Resizable")},e.exports.Resizable=n(1794).default,e.exports.ResizableBox=n(6609).default},9406:(e,t,n)=>{"use strict";var r,i=n(5959),a=(r=i)&&"object"==typeof r&&"default"in r?r.default:r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=!("undefined"==typeof window||!window.document||!window.document.createElement);e.exports=function(e,t,n){if("function"!=typeof e)throw new Error("Expected reducePropsToState to be a function.");if("function"!=typeof t)throw new Error("Expected handleStateChangeOnClient to be a function.");if(void 0!==n&&"function"!=typeof n)throw new Error("Expected mapStateOnServer to either be undefined or a function.");return function(r){if("function"!=typeof r)throw new Error("Expected WrappedComponent to be a React component.");var l,c=[];function u(){l=e(c.map((function(e){return e.props}))),d.canUseDOM?t(l):n&&(l=n(l))}var d=function(e){var t,n;function i(){return e.apply(this,arguments)||this}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n,i.peek=function(){return l},i.rewind=function(){if(i.canUseDOM)throw new Error("You may only call rewind() on the server. Call peek() to read the current state.");var e=l;return l=void 0,c=[],e};var o=i.prototype;return o.UNSAFE_componentWillMount=function(){c.push(this),u()},o.componentDidUpdate=function(){u()},o.componentWillUnmount=function(){var e=c.indexOf(this);c.splice(e,1),u()},o.render=function(){return a.createElement(r,this.props)},i}(i.PureComponent);return o(d,"displayName","SideEffect("+function(e){return e.displayName||e.name||"Component"}(r)+")"),o(d,"canUseDOM",s),d}}},4386:(e,t,n)=>{"use strict";var r=n(6212),i=n(5959),a=r.__importDefault(n(5690));t.A=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=[]);var r=a.default(e,t),o=r[0],s=r[1],l=r[2];return i.useEffect(l,n),[o,s]}},1336:(e,t,n)=>{"use strict";var r=n(5959);t.A=function(e){var t=r.useRef();return r.useEffect((function(){t.current=e})),t.current}},5690:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(5959);t.default=function(e,t){void 0===t&&(t=0);var n=r.useRef(!1),i=r.useRef(),a=r.useRef(e),o=r.useCallback((function(){return n.current}),[]),s=r.useCallback((function(){n.current=!1,i.current&&clearTimeout(i.current),i.current=setTimeout((function(){n.current=!0,a.current()}),t)}),[t]),l=r.useCallback((function(){n.current=null,i.current&&clearTimeout(i.current)}),[]);return r.useEffect((function(){a.current=e}),[e]),r.useEffect((function(){return s(),l}),[t]),[o,l,s]}},2192:(e,t,n)=>{"use strict";var r=n(5959),i=Symbol.for("react.element"),a=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,s=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,a={},c=null,u=null;for(r in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)o.call(t,r)&&!l.hasOwnProperty(r)&&(a[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===a[r]&&(a[r]=t[r]);return{$$typeof:i,type:e,key:c,ref:u,props:a,_owner:s.current}}t.Fragment=a,t.jsx=c,t.jsxs=c},2540:(e,t,n)=>{"use strict";e.exports=n(2192)},9524:(e,t,n)=>{const r=Symbol("SemVer ANY");class i{static get ANY(){return r}constructor(e,t){if(t=a(t),e instanceof i){if(e.loose===!!t.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),c("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===r?this.value="":this.value=this.operator+this.semver.version,c("comp",this)}parse(e){const t=this.options.loose?o[s.COMPARATORLOOSE]:o[s.COMPARATOR],n=e.match(t);if(!n)throw new TypeError(`Invalid comparator: ${e}`);this.operator=void 0!==n[1]?n[1]:"","="===this.operator&&(this.operator=""),n[2]?this.semver=new u(n[2],this.options.loose):this.semver=r}toString(){return this.value}test(e){if(c("Comparator.test",e,this.options.loose),this.semver===r||e===r)return!0;if("string"==typeof e)try{e=new u(e,this.options)}catch(e){return!1}return l(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof i))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new d(e.value,t).test(this.value):""===e.operator?""===e.value||new d(this.value,t).test(e.semver):(!(t=a(t)).includePrerelease||"<0.0.0-0"!==this.value&&"<0.0.0-0"!==e.value)&&(!(!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0")))&&(!(!this.operator.startsWith(">")||!e.operator.startsWith(">"))||(!(!this.operator.startsWith("<")||!e.operator.startsWith("<"))||(!(this.semver.version!==e.semver.version||!this.operator.includes("=")||!e.operator.includes("="))||(!!(l(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))||!!(l(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))))))}}e.exports=i;const a=n(7095),{safeRe:o,t:s}=n(6850),l=n(3811),c=n(9796),u=n(7944),d=n(8395)},8395:(e,t,n)=>{class r{constructor(e,t){if(t=a(t),e instanceof r)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new r(e.raw,t);if(e instanceof o)return this.raw=e.value,this.set=[[e]],this.format(),this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().split(/\s+/).join(" "),this.set=this.raw.split("||").map((e=>this.parseRange(e.trim()))).filter((e=>e.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const e=this.set[0];if(this.set=this.set.filter((e=>!g(e[0]))),0===this.set.length)this.set=[e];else if(this.set.length>1)for(const e of this.set)if(1===e.length&&y(e[0])){this.set=[e];break}}this.format()}format(){return this.range=this.set.map((e=>e.join(" ").trim())).join("||").trim(),this.range}toString(){return this.range}parseRange(e){const t=((this.options.includePrerelease&&f)|(this.options.loose&&m))+":"+e,n=i.get(t);if(n)return n;const r=this.options.loose,a=r?c[u.HYPHENRANGELOOSE]:c[u.HYPHENRANGE];e=e.replace(a,P(this.options.includePrerelease)),s("hyphen replace",e),e=e.replace(c[u.COMPARATORTRIM],d),s("comparator trim",e),e=e.replace(c[u.TILDETRIM],p),s("tilde trim",e),e=e.replace(c[u.CARETTRIM],h),s("caret trim",e);let l=e.split(" ").map((e=>v(e,this.options))).join(" ").split(/\s+/).map((e=>k(e,this.options)));r&&(l=l.filter((e=>(s("loose invalid filter",e,this.options),!!e.match(c[u.COMPARATORLOOSE]))))),s("range list",l);const y=new Map,b=l.map((e=>new o(e,this.options)));for(const e of b){if(g(e))return[e];y.set(e.value,e)}y.size>1&&y.has("")&&y.delete("");const w=[...y.values()];return i.set(t,w),w}intersects(e,t){if(!(e instanceof r))throw new TypeError("a Range is required");return this.set.some((n=>b(n,t)&&e.set.some((e=>b(e,t)&&n.every((n=>e.every((e=>n.intersects(e,t)))))))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new l(e,this.options)}catch(e){return!1}for(let t=0;t"<0.0.0-0"===e.value,y=e=>""===e.value,b=(e,t)=>{let n=!0;const r=e.slice();let i=r.pop();for(;n&&r.length;)n=r.every((e=>i.intersects(e,t))),i=r.pop();return n},v=(e,t)=>(s("comp",e,t),e=x(e,t),s("caret",e),e=S(e,t),s("tildes",e),e=_(e,t),s("xrange",e),e=C(e,t),s("stars",e),e),w=e=>!e||"x"===e.toLowerCase()||"*"===e,S=(e,t)=>e.trim().split(/\s+/).map((e=>E(e,t))).join(" "),E=(e,t)=>{const n=t.loose?c[u.TILDELOOSE]:c[u.TILDE];return e.replace(n,((t,n,r,i,a)=>{let o;return s("tilde",e,t,n,r,i,a),w(n)?o="":w(r)?o=`>=${n}.0.0 <${+n+1}.0.0-0`:w(i)?o=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(s("replaceTilde pr",a),o=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):o=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,s("tilde return",o),o}))},x=(e,t)=>e.trim().split(/\s+/).map((e=>O(e,t))).join(" "),O=(e,t)=>{s("caret",e,t);const n=t.loose?c[u.CARETLOOSE]:c[u.CARET],r=t.includePrerelease?"-0":"";return e.replace(n,((t,n,i,a,o)=>{let l;return s("caret",e,t,n,i,a,o),w(n)?l="":w(i)?l=`>=${n}.0.0${r} <${+n+1}.0.0-0`:w(a)?l="0"===n?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:o?(s("replaceCaret pr",o),l="0"===n?"0"===i?`>=${n}.${i}.${a}-${o} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${o} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${o} <${+n+1}.0.0-0`):(s("no pr"),l="0"===n?"0"===i?`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),s("caret return",l),l}))},_=(e,t)=>(s("replaceXRanges",e,t),e.split(/\s+/).map((e=>T(e,t))).join(" ")),T=(e,t)=>{e=e.trim();const n=t.loose?c[u.XRANGELOOSE]:c[u.XRANGE];return e.replace(n,((n,r,i,a,o,l)=>{s("xRange",e,n,r,i,a,o,l);const c=w(i),u=c||w(a),d=u||w(o),p=d;return"="===r&&p&&(r=""),l=t.includePrerelease?"-0":"",c?n=">"===r||"<"===r?"<0.0.0-0":"*":r&&p?(u&&(a=0),o=0,">"===r?(r=">=",u?(i=+i+1,a=0,o=0):(a=+a+1,o=0)):"<="===r&&(r="<",u?i=+i+1:a=+a+1),"<"===r&&(l="-0"),n=`${r+i}.${a}.${o}${l}`):u?n=`>=${i}.0.0${l} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${a}.0${l} <${i}.${+a+1}.0-0`),s("xRange return",n),n}))},C=(e,t)=>(s("replaceStars",e,t),e.trim().replace(c[u.STAR],"")),k=(e,t)=>(s("replaceGTE0",e,t),e.trim().replace(c[t.includePrerelease?u.GTE0PRE:u.GTE0],"")),P=e=>(t,n,r,i,a,o,s,l,c,u,d,p)=>`${n=w(r)?"":w(i)?`>=${r}.0.0${e?"-0":""}`:w(a)?`>=${r}.${i}.0${e?"-0":""}`:o?`>=${n}`:`>=${n}${e?"-0":""}`} ${l=w(c)?"":w(u)?`<${+c+1}.0.0-0`:w(d)?`<${c}.${+u+1}.0-0`:p?`<=${c}.${u}.${d}-${p}`:e?`<${c}.${u}.${+d+1}-0`:`<=${l}`}`.trim(),R=(e,t,n)=>{for(let n=0;n0){const r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}},7944:(e,t,n)=>{const r=n(9796),{MAX_LENGTH:i,MAX_SAFE_INTEGER:a}=n(9630),{safeRe:o,t:s}=n(6850),l=n(7095),{compareIdentifiers:c}=n(4031);class u{constructor(e,t){if(t=l(t),e instanceof u){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>i)throw new TypeError(`version is longer than ${i} characters`);r("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const n=e.trim().match(t.loose?o[s.LOOSE]:o[s.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>a||this.major<0)throw new TypeError("Invalid major version");if(this.minor>a||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>a||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);if(-1===r){if(t===this.prerelease.join(".")&&!1===n)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let r=[t,e];!1===n&&(r=[t]),0===c(this.prerelease[0],t)?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}e.exports=u},7994:(e,t,n)=>{const r=n(5860);e.exports=(e,t)=>{const n=r(e.trim().replace(/^[=v]+/,""),t);return n?n.version:null}},3811:(e,t,n)=>{const r=n(6909),i=n(7659),a=n(144),o=n(2077),s=n(599),l=n(7092);e.exports=(e,t,n,c)=>{switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof n&&(n=n.version),e===n;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof n&&(n=n.version),e!==n;case"":case"=":case"==":return r(e,n,c);case"!=":return i(e,n,c);case">":return a(e,n,c);case">=":return o(e,n,c);case"<":return s(e,n,c);case"<=":return l(e,n,c);default:throw new TypeError(`Invalid operator: ${t}`)}}},5334:(e,t,n)=>{const r=n(7944),i=n(5860),{safeRe:a,t:o}=n(6850);e.exports=(e,t)=>{if(e instanceof r)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let n=null;if((t=t||{}).rtl){const r=t.includePrerelease?a[o.COERCERTLFULL]:a[o.COERCERTL];let i;for(;(i=r.exec(e))&&(!n||n.index+n[0].length!==e.length);)n&&i.index+i[0].length===n.index+n[0].length||(n=i),r.lastIndex=i.index+i[1].length+i[2].length;r.lastIndex=-1}else n=e.match(t.includePrerelease?a[o.COERCEFULL]:a[o.COERCE]);if(null===n)return null;const s=n[2],l=n[3]||"0",c=n[4]||"0",u=t.includePrerelease&&n[5]?`-${n[5]}`:"",d=t.includePrerelease&&n[6]?`+${n[6]}`:"";return i(`${s}.${l}.${c}${u}${d}`,t)}},2801:(e,t,n)=>{const r=n(7944);e.exports=(e,t,n)=>{const i=new r(e,n),a=new r(t,n);return i.compare(a)||i.compareBuild(a)}},7023:(e,t,n)=>{const r=n(5380);e.exports=(e,t)=>r(e,t,!0)},5380:(e,t,n)=>{const r=n(7944);e.exports=(e,t,n)=>new r(e,n).compare(new r(t,n))},660:(e,t,n)=>{const r=n(5860);e.exports=(e,t)=>{const n=r(e,null,!0),i=r(t,null,!0),a=n.compare(i);if(0===a)return null;const o=a>0,s=o?n:i,l=o?i:n,c=!!s.prerelease.length;if(!!l.prerelease.length&&!c)return l.patch||l.minor?s.patch?"patch":s.minor?"minor":"major":"major";const u=c?"pre":"";return n.major!==i.major?u+"major":n.minor!==i.minor?u+"minor":n.patch!==i.patch?u+"patch":"prerelease"}},6909:(e,t,n)=>{const r=n(5380);e.exports=(e,t,n)=>0===r(e,t,n)},144:(e,t,n)=>{const r=n(5380);e.exports=(e,t,n)=>r(e,t,n)>0},2077:(e,t,n)=>{const r=n(5380);e.exports=(e,t,n)=>r(e,t,n)>=0},5955:(e,t,n)=>{const r=n(7944);e.exports=(e,t,n,i,a)=>{"string"==typeof n&&(a=i,i=n,n=void 0);try{return new r(e instanceof r?e.version:e,n).inc(t,i,a).version}catch(e){return null}}},599:(e,t,n)=>{const r=n(5380);e.exports=(e,t,n)=>r(e,t,n)<0},7092:(e,t,n)=>{const r=n(5380);e.exports=(e,t,n)=>r(e,t,n)<=0},2966:(e,t,n)=>{const r=n(7944);e.exports=(e,t)=>new r(e,t).major},5986:(e,t,n)=>{const r=n(7944);e.exports=(e,t)=>new r(e,t).minor},7659:(e,t,n)=>{const r=n(5380);e.exports=(e,t,n)=>0!==r(e,t,n)},5860:(e,t,n)=>{const r=n(7944);e.exports=(e,t,n=!1)=>{if(e instanceof r)return e;try{return new r(e,t)}catch(e){if(!n)return null;throw e}}},1617:(e,t,n)=>{const r=n(7944);e.exports=(e,t)=>new r(e,t).patch},9613:(e,t,n)=>{const r=n(5860);e.exports=(e,t)=>{const n=r(e,t);return n&&n.prerelease.length?n.prerelease:null}},2862:(e,t,n)=>{const r=n(5380);e.exports=(e,t,n)=>r(t,e,n)},6033:(e,t,n)=>{const r=n(2801);e.exports=(e,t)=>e.sort(((e,n)=>r(n,e,t)))},1722:(e,t,n)=>{const r=n(8395);e.exports=(e,t,n)=>{try{t=new r(t,n)}catch(e){return!1}return t.test(e)}},603:(e,t,n)=>{const r=n(2801);e.exports=(e,t)=>e.sort(((e,n)=>r(e,n,t)))},7645:(e,t,n)=>{const r=n(5860);e.exports=(e,t)=>{const n=r(e,t);return n?n.version:null}},8449:(e,t,n)=>{const r=n(6850),i=n(9630),a=n(7944),o=n(4031),s=n(5860),l=n(7645),c=n(7994),u=n(5955),d=n(660),p=n(2966),h=n(5986),f=n(1617),m=n(9613),g=n(5380),y=n(2862),b=n(7023),v=n(2801),w=n(603),S=n(6033),E=n(144),x=n(599),O=n(6909),_=n(7659),T=n(2077),C=n(7092),k=n(3811),P=n(5334),R=n(9524),A=n(8395),D=n(1722),j=n(651),I=n(7840),N=n(7930),L=n(3489),M=n(7494),F=n(5463),$=n(7871),B=n(4266),V=n(1112),z=n(1465),U=n(9252);e.exports={parse:s,valid:l,clean:c,inc:u,diff:d,major:p,minor:h,patch:f,prerelease:m,compare:g,rcompare:y,compareLoose:b,compareBuild:v,sort:w,rsort:S,gt:E,lt:x,eq:O,neq:_,gte:T,lte:C,cmp:k,coerce:P,Comparator:R,Range:A,satisfies:D,toComparators:j,maxSatisfying:I,minSatisfying:N,minVersion:L,validRange:M,outside:F,gtr:$,ltr:B,intersects:V,simplifyRange:z,subset:U,SemVer:a,re:r.re,src:r.src,tokens:r.t,SEMVER_SPEC_VERSION:i.SEMVER_SPEC_VERSION,RELEASE_TYPES:i.RELEASE_TYPES,compareIdentifiers:o.compareIdentifiers,rcompareIdentifiers:o.rcompareIdentifiers}},9630:e=>{const t=Number.MAX_SAFE_INTEGER||9007199254740991;e.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},9796:e=>{const t="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};e.exports=t},4031:e=>{const t=/^[0-9]+$/,n=(e,n)=>{const r=t.test(e),i=t.test(n);return r&&i&&(e=+e,n=+n),e===n?0:r&&!i?-1:i&&!r?1:en(t,e)}},1158:e=>{e.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){const t=this.map.get(e);return void 0===t?void 0:(this.map.delete(e),this.map.set(e,t),t)}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&void 0!==t){if(this.map.size>=this.max){const e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}},7095:e=>{const t=Object.freeze({loose:!0}),n=Object.freeze({});e.exports=e=>e?"object"!=typeof e?t:e:n},6850:(e,t,n)=>{const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:i,MAX_LENGTH:a}=n(9630),o=n(9796),s=(t=e.exports={}).re=[],l=t.safeRe=[],c=t.src=[],u=t.t={};let d=0;const p="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",a],[p,i]],f=(e,t,n)=>{const r=(e=>{for(const[t,n]of h)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e})(t),i=d++;o(e,i,t),u[e]=i,c[i]=t,s[i]=new RegExp(t,n?"g":void 0),l[i]=new RegExp(r,n?"g":void 0)};f("NUMERICIDENTIFIER","0|[1-9]\\d*"),f("NUMERICIDENTIFIERLOOSE","\\d+"),f("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${p}*`),f("MAINVERSION",`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),f("MAINVERSIONLOOSE",`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),f("PRERELEASEIDENTIFIER",`(?:${c[u.NUMERICIDENTIFIER]}|${c[u.NONNUMERICIDENTIFIER]})`),f("PRERELEASEIDENTIFIERLOOSE",`(?:${c[u.NUMERICIDENTIFIERLOOSE]}|${c[u.NONNUMERICIDENTIFIER]})`),f("PRERELEASE",`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),f("PRERELEASELOOSE",`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),f("BUILDIDENTIFIER",`${p}+`),f("BUILD",`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),f("FULLPLAIN",`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),f("FULL",`^${c[u.FULLPLAIN]}$`),f("LOOSEPLAIN",`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),f("LOOSE",`^${c[u.LOOSEPLAIN]}$`),f("GTLT","((?:<|>)?=?)"),f("XRANGEIDENTIFIERLOOSE",`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),f("XRANGEIDENTIFIER",`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),f("XRANGEPLAIN",`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),f("XRANGEPLAINLOOSE",`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),f("XRANGE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),f("XRANGELOOSE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),f("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),f("COERCE",`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),f("COERCEFULL",c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?`+`(?:${c[u.BUILD]})?(?:$|[^\\d])`),f("COERCERTL",c[u.COERCE],!0),f("COERCERTLFULL",c[u.COERCEFULL],!0),f("LONETILDE","(?:~>?)"),f("TILDETRIM",`(\\s*)${c[u.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",f("TILDE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),f("TILDELOOSE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),f("LONECARET","(?:\\^)"),f("CARETTRIM",`(\\s*)${c[u.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",f("CARET",`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),f("CARETLOOSE",`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),f("COMPARATORLOOSE",`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),f("COMPARATOR",`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),f("COMPARATORTRIM",`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",f("HYPHENRANGE",`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),f("HYPHENRANGELOOSE",`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),f("STAR","(<|>)?=?\\s*\\*"),f("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),f("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")},7871:(e,t,n)=>{const r=n(5463);e.exports=(e,t,n)=>r(e,t,">",n)},1112:(e,t,n)=>{const r=n(8395);e.exports=(e,t,n)=>(e=new r(e,n),t=new r(t,n),e.intersects(t,n))},4266:(e,t,n)=>{const r=n(5463);e.exports=(e,t,n)=>r(e,t,"<",n)},7840:(e,t,n)=>{const r=n(7944),i=n(8395);e.exports=(e,t,n)=>{let a=null,o=null,s=null;try{s=new i(t,n)}catch(e){return null}return e.forEach((e=>{s.test(e)&&(a&&-1!==o.compare(e)||(a=e,o=new r(a,n)))})),a}},7930:(e,t,n)=>{const r=n(7944),i=n(8395);e.exports=(e,t,n)=>{let a=null,o=null,s=null;try{s=new i(t,n)}catch(e){return null}return e.forEach((e=>{s.test(e)&&(a&&1!==o.compare(e)||(a=e,o=new r(a,n)))})),a}},3489:(e,t,n)=>{const r=n(7944),i=n(8395),a=n(144);e.exports=(e,t)=>{e=new i(e,t);let n=new r("0.0.0");if(e.test(n))return n;if(n=new r("0.0.0-0"),e.test(n))return n;n=null;for(let t=0;t{const t=new r(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":o&&!a(t,o)||(o=t);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}})),!o||n&&!a(n,o)||(n=o)}return n&&e.test(n)?n:null}},5463:(e,t,n)=>{const r=n(7944),i=n(9524),{ANY:a}=i,o=n(8395),s=n(1722),l=n(144),c=n(599),u=n(7092),d=n(2077);e.exports=(e,t,n,p)=>{let h,f,m,g,y;switch(e=new r(e,p),t=new o(t,p),n){case">":h=l,f=u,m=c,g=">",y=">=";break;case"<":h=c,f=d,m=l,g="<",y="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(s(e,t,p))return!1;for(let n=0;n{e.semver===a&&(e=new i(">=0.0.0")),o=o||e,s=s||e,h(e.semver,o.semver,p)?o=e:m(e.semver,s.semver,p)&&(s=e)})),o.operator===g||o.operator===y)return!1;if((!s.operator||s.operator===g)&&f(e,s.semver))return!1;if(s.operator===y&&m(e,s.semver))return!1}return!0}},1465:(e,t,n)=>{const r=n(1722),i=n(5380);e.exports=(e,t,n)=>{const a=[];let o=null,s=null;const l=e.sort(((e,t)=>i(e,t,n)));for(const e of l){r(e,t,n)?(s=e,o||(o=e)):(s&&a.push([o,s]),s=null,o=null)}o&&a.push([o,null]);const c=[];for(const[e,t]of a)e===t?c.push(e):t||e!==l[0]?t?e===l[0]?c.push(`<=${t}`):c.push(`${e} - ${t}`):c.push(`>=${e}`):c.push("*");const u=c.join(" || "),d="string"==typeof t.raw?t.raw:String(t);return u.length{const r=n(8395),i=n(9524),{ANY:a}=i,o=n(1722),s=n(5380),l=[new i(">=0.0.0-0")],c=[new i(">=0.0.0")],u=(e,t,n)=>{if(e===t)return!0;if(1===e.length&&e[0].semver===a){if(1===t.length&&t[0].semver===a)return!0;e=n.includePrerelease?l:c}if(1===t.length&&t[0].semver===a){if(n.includePrerelease)return!0;t=c}const r=new Set;let i,u,h,f,m,g,y;for(const t of e)">"===t.operator||">="===t.operator?i=d(i,t,n):"<"===t.operator||"<="===t.operator?u=p(u,t,n):r.add(t.semver);if(r.size>1)return null;if(i&&u){if(h=s(i.semver,u.semver,n),h>0)return null;if(0===h&&(">="!==i.operator||"<="!==u.operator))return null}for(const e of r){if(i&&!o(e,String(i),n))return null;if(u&&!o(e,String(u),n))return null;for(const r of t)if(!o(e,String(r),n))return!1;return!0}let b=!(!u||n.includePrerelease||!u.semver.prerelease.length)&&u.semver,v=!(!i||n.includePrerelease||!i.semver.prerelease.length)&&i.semver;b&&1===b.prerelease.length&&"<"===u.operator&&0===b.prerelease[0]&&(b=!1);for(const e of t){if(y=y||">"===e.operator||">="===e.operator,g=g||"<"===e.operator||"<="===e.operator,i)if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),">"===e.operator||">="===e.operator){if(f=d(i,e,n),f===e&&f!==i)return!1}else if(">="===i.operator&&!o(i.semver,String(e),n))return!1;if(u)if(b&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===b.major&&e.semver.minor===b.minor&&e.semver.patch===b.patch&&(b=!1),"<"===e.operator||"<="===e.operator){if(m=p(u,e,n),m===e&&m!==u)return!1}else if("<="===u.operator&&!o(u.semver,String(e),n))return!1;if(!e.operator&&(u||i)&&0!==h)return!1}return!(i&&g&&!u&&0!==h)&&(!(u&&y&&!i&&0!==h)&&(!v&&!b))},d=(e,t,n)=>{if(!e)return t;const r=s(e.semver,t.semver,n);return r>0?e:r<0||">"===t.operator&&">="===e.operator?t:e},p=(e,t,n)=>{if(!e)return t;const r=s(e.semver,t.semver,n);return r<0?e:r>0||"<"===t.operator&&"<="===e.operator?t:e};e.exports=(e,t,n={})=>{if(e===t)return!0;e=new r(e,n),t=new r(t,n);let i=!1;e:for(const r of e.set){for(const e of t.set){const t=u(r,e,n);if(i=i||null!==t,t)continue e}if(i)return!1}return!0}},651:(e,t,n)=>{const r=n(8395);e.exports=(e,t)=>new r(e,t).set.map((e=>e.map((e=>e.value)).join(" ").trim().split(" ")))},7494:(e,t,n)=>{const r=n(8395);e.exports=(e,t)=>{try{return new r(e,t).range||"*"}catch(e){return null}}},6852:(e,t,n)=>{"use strict";var r=n(8036),i=Array.prototype.concat,a=Array.prototype.slice,o=e.exports=function(e){for(var t=[],n=0,o=e.length;n{e.exports=function(e){return!(!e||"string"==typeof e)&&(e instanceof Array||Array.isArray(e)||e.length>=0&&(e.splice instanceof Function||Object.getOwnPropertyDescriptor(e,e.length-1)&&"String"!==e.constructor.name))}},6660:function(e,t,n){var r;!function(i,a){"use strict";var o="function",s="undefined",l="object",c="string",u="major",d="model",p="name",h="type",f="vendor",m="version",g="architecture",y="console",b="mobile",v="tablet",w="smarttv",S="wearable",E="embedded",x="Amazon",O="Apple",_="ASUS",T="BlackBerry",C="Browser",k="Chrome",P="Firefox",R="Google",A="Huawei",D="LG",j="Microsoft",I="Motorola",N="Opera",L="Samsung",M="Sharp",F="Sony",$="Xiaomi",B="Zebra",V="Facebook",z="Chromium OS",U="Mac OS",q=function(e){for(var t={},n=0;n0?2===s.length?typeof s[1]==o?this[s[0]]=s[1].call(this,u):this[s[0]]=s[1]:3===s.length?typeof s[1]!==o||s[1].exec&&s[1].test?this[s[0]]=u?u.replace(s[1],s[2]):a:this[s[0]]=u?s[1].call(this,u,s[2]):a:4===s.length&&(this[s[0]]=u?s[3].call(this,u.replace(s[1],s[2])):a):this[s]=u||a;d+=2}},K=function(e,t){for(var n in t)if(typeof t[n]===l&&t[n].length>0){for(var r=0;r2&&(e[d]="iPad",e[h]=v),e},this.getEngine=function(){var e={};return e[p]=a,e[m]=a,Q.call(e,r,w.engine),e},this.getOS=function(){var e={};return e[p]=a,e[m]=a,Q.call(e,r,w.os),S&&!e[p]&&y&&y.platform&&"Unknown"!=y.platform&&(e[p]=y.platform.replace(/chrome os/i,z).replace(/macos/i,U)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return r},this.setUA=function(e){return r=typeof e===c&&e.length>500?W(e,500):e,this},this.setUA(r),this};J.VERSION="1.0.38",J.BROWSER=q([p,m,u]),J.CPU=q([g]),J.DEVICE=q([d,f,h,y,b,w,v,S,E]),J.ENGINE=J.OS=q([p,m]),typeof t!==s?(e.exports&&(t=e.exports=J),t.UAParser=J):n.amdO?(r=function(){return J}.call(t,n,t,e))===a||(e.exports=r):typeof i!==s&&(i.UAParser=J);var Z=typeof i!==s&&(i.jQuery||i.Zepto);if(Z&&!Z.ua){var ee=new J;Z.ua=ee.getResult(),Z.ua.get=function(){return ee.getUA()},Z.ua.set=function(e){ee.setUA(e);var t=ee.getResult();for(var n in t)Z.ua[n]=t[n]}}}("object"==typeof window?window:this)},6089:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__6089__},7781:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__7781__},8531:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__8531__},2007:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__2007__},4201:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__4201__},3241:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__3241__},1308:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__1308__},5959:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__5959__},8398:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__8398__},1159:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__1159__},1269:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__1269__},6212:(e,t,n)=>{"use strict";n.r(t),n.d(t,{__addDisposableResource:()=>I,__assign:()=>a,__asyncDelegator:()=>_,__asyncGenerator:()=>O,__asyncValues:()=>T,__await:()=>x,__awaiter:()=>f,__classPrivateFieldGet:()=>A,__classPrivateFieldIn:()=>j,__classPrivateFieldSet:()=>D,__createBinding:()=>g,__decorate:()=>s,__disposeResources:()=>L,__esDecorate:()=>c,__exportStar:()=>y,__extends:()=>i,__generator:()=>m,__importDefault:()=>R,__importStar:()=>P,__makeTemplateObject:()=>C,__metadata:()=>h,__param:()=>l,__propKey:()=>d,__read:()=>v,__rest:()=>o,__runInitializers:()=>u,__setFunctionName:()=>p,__spread:()=>w,__spreadArray:()=>E,__spreadArrays:()=>S,__values:()=>b,default:()=>M});var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var a=function(){return a=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function l(e,t){return function(n,r){t(n,r,e)}}function c(e,t,n,r,i,a){function o(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var s,l=r.kind,c="getter"===l?"get":"setter"===l?"set":"value",u=!t&&e?r.static?e:e.prototype:null,d=t||(u?Object.getOwnPropertyDescriptor(u,r.name):{}),p=!1,h=n.length-1;h>=0;h--){var f={};for(var m in r)f[m]="access"===m?{}:r[m];for(var m in r.access)f.access[m]=r.access[m];f.addInitializer=function(e){if(p)throw new TypeError("Cannot add initializers after decoration has completed");a.push(o(e||null))};var g=(0,n[h])("accessor"===l?{get:d.get,set:d.set}:d[c],f);if("accessor"===l){if(void 0===g)continue;if(null===g||"object"!=typeof g)throw new TypeError("Object expected");(s=o(g.get))&&(d.get=s),(s=o(g.set))&&(d.set=s),(s=o(g.init))&&i.unshift(s)}else(s=o(g))&&("field"===l?i.unshift(s):d[c]=s)}u&&Object.defineProperty(u,r.name,d),p=!0}function u(e,t,n){for(var r=arguments.length>2,i=0;i0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)o.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return o}function w(){for(var e=[],t=0;t1||s(e,t)}))},t&&(r[e]=t(r[e])))}function s(e,t){try{(n=i[e](t)).value instanceof x?Promise.resolve(n.value.v).then(l,c):u(a[0][2],n)}catch(e){u(a[0][3],e)}var n}function l(e){s("next",e)}function c(e){s("throw",e)}function u(e,t){e(t),a.shift(),a.length&&s(a[0][0],a[0][1])}}function _(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:x(e[r](t)),done:!1}:i?i(t):t}:i}}function T(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=b(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,i,(t=e[n](t)).done,t.value)}))}}}function C(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var k=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function P(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&g(t,e,n);return k(t,e),t}function R(e){return e&&e.__esModule?e:{default:e}}function A(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function D(e,t,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(e,n):i?i.value=n:t.set(e,n),n}function j(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function I(e,t,n){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var r,i;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(void 0===r){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose],n&&(i=r)}if("function"!=typeof r)throw new TypeError("Object not disposable.");i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}var N="function"==typeof SuppressedError?SuppressedError:function(e,t,n){var r=new Error(n);return r.name="SuppressedError",r.error=e,r.suppressed=t,r};function L(e){function t(t){e.error=e.hasError?new N(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}return function n(){for(;e.stack.length;){var r=e.stack.pop();try{var i=r.dispose&&r.dispose.call(r.value);if(r.async)return Promise.resolve(i).then(n,(function(e){return t(e),n()}))}catch(e){t(e)}}if(e.hasError)throw e.error}()}const M={__extends:i,__assign:a,__rest:o,__decorate:s,__param:l,__metadata:h,__awaiter:f,__generator:m,__createBinding:g,__exportStar:y,__values:b,__read:v,__spread:w,__spreadArrays:S,__spreadArray:E,__await:x,__asyncGenerator:O,__asyncDelegator:_,__asyncValues:T,__makeTemplateObject:C,__importStar:P,__importDefault:R,__classPrivateFieldGet:A,__classPrivateFieldSet:D,__classPrivateFieldIn:j,__addDisposableResource:I,__disposeResources:L}}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.loaded=!0,n.exports}__webpack_require__.amdO={},__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),__webpack_require__.p="public/plugins/grafana-pyroscope-app/";var __webpack_exports__={};return(()=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{plugin:()=>lB});var e={};__webpack_require__.r(e);var t=__webpack_require__(1308),n=__webpack_require__.n(t);__webpack_require__.p=n()&&n().uri?n().uri.slice(0,n().uri.lastIndexOf("/")+1):"public/plugins/grafana-pyroscope-app/";var r=__webpack_require__(7781),i=__webpack_require__(6089),a=__webpack_require__(8531),o=__webpack_require__(2007),s="undefined"==typeof window||"Deno"in globalThis;function l(){}function c(e){return"number"==typeof e&&e>=0&&e!==1/0}function u(e,t){return Math.max(e+(t||0)-Date.now(),0)}function d(e,t){return"function"==typeof e?e(t):e}function p(e,t){return"function"==typeof e?e(t):e}function h(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o)if(r){if(t.queryHash!==m(o,t.options))return!1}else if(!y(t.queryKey,o))return!1;if("all"!==n){const e=t.isActive();if("active"===n&&!e)return!1;if("inactive"===n&&e)return!1}return("boolean"!=typeof s||t.isStale()===s)&&((!i||i===t.state.fetchStatus)&&!(a&&!a(t)))}function f(e,t){const{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(g(t.options.mutationKey)!==g(a))return!1}else if(!y(t.options.mutationKey,a))return!1}return(!r||t.state.status===r)&&!(i&&!i(t))}function m(e,t){return(t?.queryKeyHashFn||g)(e)}function g(e){return JSON.stringify(e,((e,t)=>S(t)?Object.keys(t).sort().reduce(((e,n)=>(e[n]=t[n],e)),{}):t))}function y(e,t){return e===t||typeof e==typeof t&&(!(!e||!t||"object"!=typeof e||"object"!=typeof t)&&!Object.keys(t).some((n=>!y(e[n],t[n]))))}function b(e,t){if(e===t)return e;const n=w(e)&&w(t);if(n||S(e)&&S(t)){const r=n?e:Object.keys(e),i=r.length,a=n?t:Object.keys(t),o=a.length,s=n?[]:{};let l=0;for(let i=0;in?r.slice(1):r}function _(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var T=Symbol(),C=(e,t)=>!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==T?e.queryFn:()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`));var k=function(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=e=>setTimeout(e,0);const a=r=>{t?e.push(r):i((()=>{n(r)}))},o=()=>{const t=e;e=[],t.length&&i((()=>{r((()=>{t.forEach((e=>{n(e)}))}))}))};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a((()=>{e(...t)}))},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}(),P=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},R=new class extends P{#e;#t;#n;constructor(){super(),this.#n=e=>{if(!s&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e((e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()}))}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach((t=>{t(e)}))}isFocused(){return"boolean"==typeof this.#e?this.#e:"hidden"!==globalThis.document?.visibilityState}},A=new class extends P{#r=!0;#t;#n;constructor(){super(),this.#n=e=>{if(!s&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#r!==e&&(this.#r=e,this.listeners.forEach((t=>{t(e)})))}isOnline(){return this.#r}};function D(e){return Math.min(1e3*2**e,3e4)}function j(e){return"online"!==(e??"online")||A.isOnline()}var I=class{constructor(e){this.revert=e?.revert,this.silent=e?.silent}};function N(e){return e instanceof I}function L(e){let t,n,r,i=!1,a=0,o=!1;const l=new Promise(((e,t)=>{n=e,r=t})),c=()=>R.isFocused()&&("always"===e.networkMode||A.isOnline())&&e.canRun(),u=()=>j(e.networkMode)&&e.canRun(),d=r=>{o||(o=!0,e.onSuccess?.(r),t?.(),n(r))},p=n=>{o||(o=!0,e.onError?.(n),t?.(),r(n))},h=()=>new Promise((n=>{t=e=>{(o||c())&&n(e)},e.onPause?.()})).then((()=>{t=void 0,o||e.onContinue?.()})),f=()=>{if(o)return;let t;const n=0===a?e.initialPromise:void 0;try{t=n??e.fn()}catch(e){t=Promise.reject(e)}Promise.resolve(t).then(d).catch((t=>{if(o)return;const n=e.retry??(s?0:3),r=e.retryDelay??D,l="function"==typeof r?r(a,t):r,u=!0===n||"number"==typeof n&&a{setTimeout(e,d)}))).then((()=>c()?void 0:h())).then((()=>{i?p(t):f()}))):p(t)}))};return{promise:l,cancel:t=>{o||(p(new I(t)),e.abort?.())},continue:()=>(t?.(),l),cancelRetry:()=>{i=!0},continueRetry:()=>{i=!1},canStart:u,start:()=>(u()?f():h().then(f),l)}}var M=class{#i;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),c(this.gcTime)&&(this.#i=setTimeout((()=>{this.optionalRemove()}),this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(s?1/0:3e5))}clearGcTimeout(){this.#i&&(clearTimeout(this.#i),this.#i=void 0)}},F=class extends M{#a;#o;#s;#l;#c;#u;constructor(e){super(),this.#u=!1,this.#c=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#s=e.cache,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#a=e.state||function(e){const t="function"==typeof e.initialData?e.initialData():e.initialData,n=void 0!==t,r=n?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}(this.options),this.state=this.#a,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#l?.promise}setOptions(e){this.options={...this.#c,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#s.remove(this)}setData(e,t){const n=x(this.state.data,e,this.options);return this.#d({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#d({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#l?.promise;return this.#l?.cancel(e),t?t.then(l).catch(l):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#a)}isActive(){return this.observers.some((e=>!1!==p(e.options.enabled,this)))}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return!!this.state.isInvalidated||(this.getObserversCount()>0?this.observers.some((e=>e.getCurrentResult().isStale)):void 0===this.state.data)}isStaleByTime(e=0){return this.state.isInvalidated||void 0===this.state.data||!u(this.state.dataUpdatedAt,e)}onFocus(){const e=this.observers.find((e=>e.shouldFetchOnWindowFocus()));e?.refetch({cancelRefetch:!1}),this.#l?.continue()}onOnline(){const e=this.observers.find((e=>e.shouldFetchOnReconnect()));e?.refetch({cancelRefetch:!1}),this.#l?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter((t=>t!==e)),this.observers.length||(this.#l&&(this.#u?this.#l.cancel({revert:!0}):this.#l.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#d({type:"invalidate"})}fetch(e,t){if("idle"!==this.state.fetchStatus)if(void 0!==this.state.data&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#l)return this.#l.continueRetry(),this.#l.promise;if(e&&this.setOptions(e),!this.options.queryFn){const e=this.observers.find((e=>e.options.queryFn));e&&this.setOptions(e.options)}const n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#u=!0,n.signal)})},i={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:()=>{const e=C(this.options,t),n={queryKey:this.queryKey,meta:this.meta};return r(n),this.#u=!1,this.options.persister?this.options.persister(e,n,this):e(n)}};r(i),this.options.behavior?.onFetch(i,this),this.#o=this.state,"idle"!==this.state.fetchStatus&&this.state.fetchMeta===i.fetchOptions?.meta||this.#d({type:"fetch",meta:i.fetchOptions?.meta});const a=e=>{N(e)&&e.silent||this.#d({type:"error",error:e}),N(e)||(this.#s.config.onError?.(e,this),this.#s.config.onSettled?.(this.state.data,e,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return this.#l=L({initialPromise:t?.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:e=>{void 0!==e?(this.setData(e),this.#s.config.onSuccess?.(e,this),this.#s.config.onSettled?.(e,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1):a(new Error(`${this.queryHash} data is undefined`))},onError:a,onFail:(e,t)=>{this.#d({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#d({type:"pause"})},onContinue:()=>{this.#d({type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}),this.#l.start()}#d(e){this.state=(t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...$(t.data,this.options),fetchMeta:e.meta??null};case"success":return{...t,data:e.data,dataUpdateCount:t.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=e.error;return N(n)&&n.revert&&this.#o?{...this.#o,fetchStatus:"idle"}:{...t,error:n,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}})(this.state),k.batch((()=>{this.observers.forEach((e=>{e.onQueryUpdate()})),this.#s.notify({query:this,type:"updated",action:e})}))}};function $(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:j(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}var B=class extends P{constructor(e={}){super(),this.config=e,this.#p=new Map}#p;build(e,t,n){const r=t.queryKey,i=t.queryHash??m(r,t);let a=this.get(i);return a||(a=new F({cache:this,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#p.has(e.queryHash)||(this.#p.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#p.get(e.queryHash);t&&(e.destroy(),t===e&&this.#p.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){k.batch((()=>{this.getAll().forEach((e=>{this.remove(e)}))}))}get(e){return this.#p.get(e)}getAll(){return[...this.#p.values()]}find(e){const t={exact:!0,...e};return this.getAll().find((e=>h(t,e)))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter((t=>h(e,t))):t}notify(e){k.batch((()=>{this.listeners.forEach((t=>{t(e)}))}))}onFocus(){k.batch((()=>{this.getAll().forEach((e=>{e.onFocus()}))}))}onOnline(){k.batch((()=>{this.getAll().forEach((e=>{e.onOnline()}))}))}},V=class extends M{#h;#f;#l;constructor(e){super(),this.mutationId=e.mutationId,this.#f=e.mutationCache,this.#h=[],this.state=e.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#h.includes(e)||(this.#h.push(e),this.clearGcTimeout(),this.#f.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#h=this.#h.filter((t=>t!==e)),this.scheduleGc(),this.#f.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#h.length||("pending"===this.state.status?this.scheduleGc():this.#f.remove(this))}continue(){return this.#l?.continue()??this.execute(this.state.variables)}async execute(e){this.#l=L({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(e,t)=>{this.#d({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#d({type:"pause"})},onContinue:()=>{this.#d({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#f.canRun(this)});const t="pending"===this.state.status,n=!this.#l.canStart();try{if(!t){this.#d({type:"pending",variables:e,isPaused:n}),await(this.#f.config.onMutate?.(e,this));const t=await(this.options.onMutate?.(e));t!==this.state.context&&this.#d({type:"pending",context:t,variables:e,isPaused:n})}const r=await this.#l.start();return await(this.#f.config.onSuccess?.(r,e,this.state.context,this)),await(this.options.onSuccess?.(r,e,this.state.context)),await(this.#f.config.onSettled?.(r,null,this.state.variables,this.state.context,this)),await(this.options.onSettled?.(r,null,e,this.state.context)),this.#d({type:"success",data:r}),r}catch(t){try{throw await(this.#f.config.onError?.(t,e,this.state.context,this)),await(this.options.onError?.(t,e,this.state.context)),await(this.#f.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this)),await(this.options.onSettled?.(void 0,t,e,this.state.context)),t}finally{this.#d({type:"error",error:t})}}finally{this.#f.runNext(this)}}#d(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),k.batch((()=>{this.#h.forEach((t=>{t.onMutationUpdate(e)})),this.#f.notify({mutation:this,type:"updated",action:e})}))}};var z=class extends P{constructor(e={}){super(),this.config=e,this.#m=new Map,this.#g=Date.now()}#m;#g;build(e,t,n){const r=new V({mutationCache:this,mutationId:++this.#g,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){const t=U(e),n=this.#m.get(t)??[];n.push(e),this.#m.set(t,n),this.notify({type:"added",mutation:e})}remove(e){const t=U(e);if(this.#m.has(t)){const n=this.#m.get(t)?.filter((t=>t!==e));n&&(0===n.length?this.#m.delete(t):this.#m.set(t,n))}this.notify({type:"removed",mutation:e})}canRun(e){const t=this.#m.get(U(e))?.find((e=>"pending"===e.state.status));return!t||t===e}runNext(e){const t=this.#m.get(U(e))?.find((t=>t!==e&&t.state.isPaused));return t?.continue()??Promise.resolve()}clear(){k.batch((()=>{this.getAll().forEach((e=>{this.remove(e)}))}))}getAll(){return[...this.#m.values()].flat()}find(e){const t={exact:!0,...e};return this.getAll().find((e=>f(t,e)))}findAll(e={}){return this.getAll().filter((t=>f(e,t)))}notify(e){k.batch((()=>{this.listeners.forEach((t=>{t(e)}))}))}resumePausedMutations(){const e=this.getAll().filter((e=>e.state.isPaused));return k.batch((()=>Promise.all(e.map((e=>e.continue().catch(l))))))}};function U(e){return e.options.scope?.id??String(e.mutationId)}function q(e){return{onFetch:(t,n)=>{const r=async()=>{const n=t.options,r=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],a=t.state.data?.pageParams||[],o={pages:[],pageParams:[]};let s=!1;const l=C(t.options,t.fetchOptions),c=async(e,n,r)=>{if(s)return Promise.reject();if(null==n&&e.pages.length)return Promise.resolve(e);const i={queryKey:t.queryKey,pageParam:n,direction:r?"backward":"forward",meta:t.options.meta};var a;a=i,Object.defineProperty(a,"signal",{enumerable:!0,get:()=>(t.signal.aborted?s=!0:t.signal.addEventListener("abort",(()=>{s=!0})),t.signal)});const o=await l(i),{maxPages:c}=t.options,u=r?_:O;return{pages:u(e.pages,o,c),pageParams:u(e.pageParams,n,c)}};let u;if(r&&i.length){const e="backward"===r,t={pages:i,pageParams:a},o=(e?G:H)(n,t);u=await c(t,o,e)}else{u=await c(o,a[0]??n.initialPageParam);const t=e??i.length;for(let e=1;et.options.persister?.(r,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=r}}}function H(e,{pages:t,pageParams:n}){const r=t.length-1;return e.getNextPageParam(t[r],t,n[r],n)}function G(e,{pages:t,pageParams:n}){return e.getPreviousPageParam?.(t[0],t,n[0],n)}const W=new class{#y;#f;#c;#b;#v;#w;#S;#E;constructor(e={}){this.#y=e.queryCache||new B,this.#f=e.mutationCache||new z,this.#c=e.defaultOptions||{},this.#b=new Map,this.#v=new Map,this.#w=0}mount(){this.#w++,1===this.#w&&(this.#S=R.subscribe((async e=>{e&&(await this.resumePausedMutations(),this.#y.onFocus())})),this.#E=A.subscribe((async e=>{e&&(await this.resumePausedMutations(),this.#y.onOnline())})))}unmount(){this.#w--,0===this.#w&&(this.#S?.(),this.#S=void 0,this.#E?.(),this.#E=void 0)}isFetching(e){return this.#y.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#f.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#y.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.getQueryData(e.queryKey);if(void 0===t)return this.fetchQuery(e);{const n=this.defaultQueryOptions(e),r=this.#y.build(this,n);return e.revalidateIfStale&&r.isStaleByTime(d(n.staleTime,r))&&this.prefetchQuery(n),Promise.resolve(t)}}getQueriesData(e){return this.#y.findAll(e).map((({queryKey:e,state:t})=>[e,t.data]))}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=this.#y.get(r.queryHash),a=i?.state.data,o=function(e,t){return"function"==typeof e?e(t):e}(t,a);if(void 0!==o)return this.#y.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return k.batch((()=>this.#y.findAll(e).map((({queryKey:e})=>[e,this.setQueryData(e,t,n)]))))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#y.get(t.queryHash)?.state}removeQueries(e){const t=this.#y;k.batch((()=>{t.findAll(e).forEach((e=>{t.remove(e)}))}))}resetQueries(e,t){const n=this.#y,r={type:"active",...e};return k.batch((()=>(n.findAll(e).forEach((e=>{e.reset()})),this.refetchQueries(r,t))))}cancelQueries(e={},t={}){const n={revert:!0,...t},r=k.batch((()=>this.#y.findAll(e).map((e=>e.cancel(n)))));return Promise.all(r).then(l).catch(l)}invalidateQueries(e={},t={}){return k.batch((()=>{if(this.#y.findAll(e).forEach((e=>{e.invalidate()})),"none"===e.refetchType)return Promise.resolve();const n={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(n,t)}))}refetchQueries(e={},t){const n={...t,cancelRefetch:t?.cancelRefetch??!0},r=k.batch((()=>this.#y.findAll(e).filter((e=>!e.isDisabled())).map((e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(l)),"paused"===e.state.fetchStatus?Promise.resolve():t}))));return Promise.all(r).then(l)}fetchQuery(e){const t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);const n=this.#y.build(this,t);return n.isStaleByTime(d(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(l).catch(l)}fetchInfiniteQuery(e){return e.behavior=q(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(l).catch(l)}resumePausedMutations(){return A.isOnline()?this.#f.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#y}getMutationCache(){return this.#f}getDefaultOptions(){return this.#c}setDefaultOptions(e){this.#c=e}setQueryDefaults(e,t){this.#b.set(g(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#b.values()];let n={};return t.forEach((t=>{y(e,t.queryKey)&&(n={...n,...t.defaultOptions})})),n}setMutationDefaults(e,t){this.#v.set(g(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#v.values()];let n={};return t.forEach((t=>{y(e,t.mutationKey)&&(n={...n,...t.defaultOptions})})),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#c.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=m(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.throwOnError&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),!0!==t.enabled&&t.queryFn===T&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#c.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#y.clear(),this.#f.clear()}}({defaultOptions:{queries:{networkMode:"always",retry:!1,refetchOnWindowFocus:!1}}});var Q;!function(e){e.EXCEPTION="exception",e.LOG="log",e.MEASUREMENT="measurement",e.TRACE="trace",e.EVENT="event"}(Q||(Q={}));const K={[Q.EXCEPTION]:"exceptions",[Q.LOG]:"logs",[Q.MEASUREMENT]:"measurements",[Q.TRACE]:"traces",[Q.EVENT]:"events"};function Y(){return Date.now()}function X(){return(new Date).toISOString()}function J(e){return new Date(e).toISOString()}function Z(e,t){return typeof e===t}function ee(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function te(e,t){try{return e instanceof t}catch(e){return!1}}const ne=e=>Z(e,"null"),re=e=>Z(e,"string"),ie=e=>Z(e,"number")&&!isNaN(e)||Z(e,"bigint"),ae=e=>!ne(e)&&Z(e,"object"),oe=e=>Z(e,"function"),se=e=>ee(e,"Array"),le="undefined"!=typeof Event,ce=e=>le&&te(e,Event),ue="undefined"!=typeof Error,de=e=>ue&&te(e,Error),pe=e=>ee(e,"ErrorEvent"),he=e=>ee(e,"DOMError"),fe=e=>ee(e,"DOMException");function me(e,t){if(e===t)return!0;if(Z(e,"number")&&isNaN(e))return Z(t,"number")&&isNaN(t);const n=se(e),r=se(t);if(n!==r)return!1;if(n&&r){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!=r--;)if(!me(e[r],t[r]))return!1;return!0}const i=ae(e),a=ae(t);if(i!==a)return!1;if(e&&t&&i&&a){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!me(e[r],t[r]))return!1;return!0}return!1}const ge="Error";let ye;var be;!function(e){e.TRACE="trace",e.DEBUG="debug",e.INFO="info",e.LOG="log",e.WARN="warn",e.ERROR="error"}(be||(be={}));const ve=be.LOG,we=[be.TRACE,be.DEBUG,be.INFO,be.LOG,be.WARN,be.ERROR],Se=e=>e.map((e=>{try{return String(e)}catch(e){return""}})).join(" ");function Ee(e,t,n,r,i){t.debug("Initializing API");const a=function(e,t,n,r,i){let a;return t.debug("Initializing traces API"),{getOTEL:()=>a,getTraceContext:()=>{const e=null==a?void 0:a.trace.getSpanContext(a.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,n)=>{t.debug("Initializing OpenTelemetry"),a={trace:e,context:n}},isOTELInitialized:()=>!!a,pushTraces:e=>{try{const n={type:Q.TRACE,payload:e,meta:r.value};t.debug("Pushing trace\n",n),i.execute(n)}catch(e){t.error("Error pushing trace\n",e)}}}}(0,t,0,r,i);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},a),function(e,t,n,r,i,a){var o;t.debug("Initializing exceptions API");let s=null;ye=null!==(o=n.parseStacktrace)&&void 0!==o?o:ye;const l=e=>{t.debug("Changing stacktrace parser"),ye=null!=e?e:ye};return l(n.parseStacktrace),{changeStacktraceParser:l,getStacktraceParser:()=>ye,pushError:(e,{skipDedupe:o,stackFrames:l,type:c,context:u,spanContext:d,timestampOverwriteMs:p}={})=>{c=c||e.name||ge;const h={meta:r.value,payload:{type:c,value:e.message,timestamp:p?J(p):X(),trace:d?{trace_id:d.traceId,span_id:d.spanId}:a.getTraceContext(),context:null!=u?u:{}},type:Q.EXCEPTION};(null==(l=null!=l?l:e.stack?null==ye?void 0:ye(e).frames:void 0)?void 0:l.length)&&(h.payload.stacktrace={frames:l});const f={type:h.payload.type,value:h.payload.value,stackTrace:h.payload.stacktrace,context:h.payload.context};o||!n.dedupe||ne(s)||!me(f,s)?(s=f,t.debug("Pushing exception\n",h),i.execute(h)):t.debug("Skipping error push because it is the same as the last one\n",h.payload)}}}(0,t,n,r,i,a)),function(e,t,n,r,i){let a,o,s;t.debug("Initializing meta API");const l=e=>{o&&r.remove(o),o={user:e},r.add(o)},c=e=>{a&&r.remove(a),a={session:e},r.add(a)};return{setUser:l,resetUser:l,setSession:c,resetSession:c,getSession:()=>r.value.session,setView:e=>{var t;if((null===(t=null==s?void 0:s.view)||void 0===t?void 0:t.name)===(null==e?void 0:e.name))return;const n=s;s={view:e},r.add(s),n&&r.remove(n)},getView:()=>r.value.view}}(0,t,0,r)),function(e,t,n,r,i,a){var o;t.debug("Initializing logs API");let s=null;const l=null!==(o=n.logArgsSerializer)&&void 0!==o?o:Se;return{pushLog:(e,{context:o,level:c,skipDedupe:u,spanContext:d,timestampOverwriteMs:p}={})=>{try{const h={type:Q.LOG,payload:{message:l(e),level:null!=c?c:ve,context:null!=o?o:{},timestamp:p?J(p):X(),trace:d?{trace_id:d.traceId,span_id:d.spanId}:a.getTraceContext()},meta:r.value},f={message:h.payload.message,level:h.payload.level,context:h.payload.context};if(!u&&n.dedupe&&!ne(s)&&me(f,s))return void t.debug("Skipping log push because it is the same as the last one\n",h.payload);s=f,t.debug("Pushing log\n",h),i.execute(h)}catch(e){t.error("Error pushing log\n",e)}}}}(0,t,n,r,i,a)),function(e,t,n,r,i,a){t.debug("Initializing measurements API");let o=null;return{pushMeasurement:(e,{skipDedupe:s,context:l,spanContext:c,timestampOverwriteMs:u}={})=>{try{const d={type:Q.MEASUREMENT,payload:Object.assign(Object.assign({},e),{trace:c?{trace_id:c.traceId,span_id:c.spanId}:a.getTraceContext(),timestamp:u?J(u):X(),context:null!=l?l:{}}),meta:r.value},p={type:d.payload.type,values:d.payload.values,context:d.payload.context};if(!s&&n.dedupe&&!ne(o)&&me(p,o))return void t.debug("Skipping measurement push because it is the same as the last one\n",d.payload);o=p,t.debug("Pushing measurement\n",d),i.execute(d)}catch(e){t.error("Error pushing measurement\n",e)}}}}(0,t,n,r,i,a)),function(e,t,n,r,i,a){let o=null;return{pushEvent:(e,s,l,{skipDedupe:c,spanContext:u,timestampOverwriteMs:d}={})=>{try{const p={meta:r.value,payload:{name:e,domain:null!=l?l:n.eventDomain,attributes:s,timestamp:d?J(d):X(),trace:u?{trace_id:u.traceId,span_id:u.spanId}:a.getTraceContext()},type:Q.EVENT},h={name:p.payload.name,attributes:p.payload.attributes,domain:p.payload.domain};if(!c&&n.dedupe&&!ne(o)&&me(h,o))return void t.debug("Skipping event push because it is the same as the last one\n",p.payload);o=h,t.debug("Pushing event\n",p),i.execute(p)}catch(e){t.error("Error pushing event",e)}}}}(0,t,n,r,i,a))}function xe(){}var Oe;!function(e){e[e.OFF=0]="OFF",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.VERBOSE=4]="VERBOSE"}(Oe||(Oe={}));const _e={debug:xe,error:xe,info:xe,prefix:"Faro",warn:xe},Te=Oe.ERROR,Ce=Object.assign({},console);function ke(e=Ce,t=Te){const n=_e;return t>Oe.OFF&&(n.error=t>=Oe.ERROR?function(...t){e.error(`${n.prefix}\n`,...t)}:xe,n.warn=t>=Oe.WARN?function(...t){e.warn(`${n.prefix}\n`,...t)}:xe,n.info=t>=Oe.INFO?function(...t){e.info(`${n.prefix}\n`,...t)}:xe,n.debug=t>=Oe.VERBOSE?function(...t){e.debug(`${n.prefix}\n`,...t)}:xe),n}let Pe=_e;function Re(e,t){return Pe=ke(e,t.internalLoggerLevel),Pe}const Ae="undefined"!=typeof globalThis?globalThis:void 0!==__webpack_require__.g?__webpack_require__.g:"undefined"!=typeof self?self:void 0;const De="1.10.0";const je="_faroInternal";let Ie={};function Ne(e,t,n,r,i,a,o){return t.debug("Initializing Faro"),Ie={api:a,config:n,instrumentations:o,internalLogger:t,metas:r,pause:i.pause,transports:i,unpatchedConsole:e,unpause:i.unpause},function(e){e.config.isolate?e.internalLogger.debug("Skipping registering internal Faro instance on global object"):(e.internalLogger.debug("Registering internal Faro instance on global object"),Object.defineProperty(Ae,je,{configurable:!1,enumerable:!1,writable:!1,value:e}))}(Ie),function(e){if(e.config.preventGlobalExposure)e.internalLogger.debug("Skipping registering public Faro instance in the global scope");else{if(e.internalLogger.debug(`Registering public faro reference in the global scope using "${e.config.globalObjectKey}" key`),e.config.globalObjectKey in Ae)return void e.internalLogger.warn(`Skipping global registration due to key "${e.config.globalObjectKey}" being used already. Please set "globalObjectKey" to something else or set "preventGlobalExposure" to "true"`);Object.defineProperty(Ae,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(Ie),Ie}class Le{constructor(e,t){var n,r;this.signalBuffer=[],this.itemLimit=null!==(n=null==t?void 0:t.itemLimit)&&void 0!==n?n:50,this.sendTimeout=null!==(r=null==t?void 0:t.sendTimeout)&&void 0!==r?r:250,this.paused=(null==t?void 0:t.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.flush()}))}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval((()=>this.flush()),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const t=new Map;return e.forEach((e=>{const n=JSON.stringify(e.meta);let r=t.get(n);r=void 0===r?[e]:[...r,e],t.set(n,r)})),Array.from(t.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}function Me(e){return t=>{if(t.type===Q.EXCEPTION&&t.payload){const n=t.payload,r=`${n.type}: ${n.value}`;if(function(e,t){return e.some((e=>re(e)?t.includes(e):!!t.match(e)))}(e,r))return null}return t}}function Fe(e,t,n,r){var i;t.debug("Initializing transports");const a=[];let o=n.paused,s=[];const l=e=>{let t=e;for(const e of s){const n=t.map(e).filter(Boolean);if(0===n.length)return[];t=n}return t},c=e=>{const n=l(e);if(0!==n.length)for(const e of a)t.debug(`Transporting item using ${e.name}\n`,n),e.isBatched()&&e.send(n)};let u;(null===(i=n.batching)||void 0===i?void 0:i.enabled)&&(u=new Le(c,{sendTimeout:n.batching.sendTimeout,itemLimit:n.batching.itemLimit,paused:o}));return{add:(...i)=>{t.debug("Adding transports"),i.forEach((i=>{t.debug(`Adding "${i.name}" transport`);a.some((e=>e===i))?t.warn(`Transport ${i.name} is already added`):(i.unpatchedConsole=e,i.internalLogger=t,i.config=n,i.metas=r,a.push(i))}))},addBeforeSendHooks:(...e)=>{t.debug("Adding beforeSendHooks\n",s),e.forEach((e=>{e&&s.push(e)}))},addIgnoreErrorsPatterns:(...e)=>{t.debug("Adding ignoreErrorsPatterns\n",e),e.forEach((e=>{e&&s.push(Me(e))}))},getBeforeSendHooks:()=>[...s],execute:e=>{var r;o||((null===(r=n.batching)||void 0===r?void 0:r.enabled)&&(null==u||u.addItem(e)),(e=>{var r,i;if((null===(r=n.batching)||void 0===r?void 0:r.enabled)&&a.every((e=>e.isBatched())))return;const[o]=l([e]);if(void 0!==o)for(const e of a)t.debug(`Transporting item using ${e.name}\n`,o),e.isBatched()?(null===(i=n.batching)||void 0===i?void 0:i.enabled)||e.send([o]):e.send(o)})(e))},isPaused:()=>o,pause:()=>{t.debug("Pausing transports"),null==u||u.pause(),o=!0},remove:(...e)=>{t.debug("Removing transports"),e.forEach((e=>{t.debug(`Removing "${e.name}" transport`);const n=a.indexOf(e);-1!==n?a.splice(n,1):t.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{s.filter((t=>!e.includes(t)))},get transports(){return[...a]},unpause:()=>{t.debug("Unpausing transports"),null==u||u.start(),o=!1}}}let $e=Ce;function Be(e){var t;return $e=null!==(t=e.unpatchedConsole)&&void 0!==t?t:$e,$e}function Ve(e){const t=Be(e),n=Re(t,e);if(je in Ae&&!e.isolate)return void n.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');n.debug("Initializing");const r=function(e,t,n){let r=[],i=[];const a=()=>r.reduce(((e,t)=>Object.assign(e,oe(t)?t():t)),{}),o=()=>{if(i.length){const e=a();i.forEach((t=>t(e)))}};return{add:(...e)=>{t.debug("Adding metas\n",e),r.push(...e),o()},remove:(...e)=>{t.debug("Removing metas\n",e),r=r.filter((t=>!e.includes(t))),o()},addListener:e=>{t.debug("Adding metas listener\n",e),i.push(e)},removeListener:e=>{t.debug("Removing metas listener\n",e),i=i.filter((t=>t!==e))},get value(){return a()}}}(0,n),i=Fe(t,n,e,r),a=Ee(0,n,e,r,i),o=function(e,t,n,r,i,a){t.debug("Initializing instrumentations");const o=[];return{add:(...s)=>{t.debug("Adding instrumentations"),s.forEach((s=>{t.debug(`Adding "${s.name}" instrumentation`),o.some((e=>e.name===s.name))?t.warn(`Instrumentation ${s.name} is already added`):(s.unpatchedConsole=e,s.internalLogger=t,s.config=n,s.metas=r,s.transports=i,s.api=a,o.push(s),s.initialize())}))},get instrumentations(){return[...o]},remove:(...e)=>{t.debug("Removing instrumentations"),e.forEach((e=>{var n,r;t.debug(`Removing "${e.name}" instrumentation`);const i=o.reduce(((t,n,r)=>null===t&&n.name===e.name?r:null),null);i?(null===(r=(n=o[i]).destroy)||void 0===r||r.call(n),o.splice(i,1)):t.warn(`Instrumentation "${e.name}" is not added`)}))}}}(t,n,e,r,i,a),s=Ne(t,n,e,r,i,a,o);return function(e){var t,n;const r={sdk:{version:De},app:{bundleId:e.config.app.name&&(i=e.config.app.name,null==Ae?void 0:Ae[`__faroBundleId_${i}`])}};var i;const a=null===(t=e.config.sessionTracking)||void 0===t?void 0:t.session;a&&e.api.setSession(a),e.config.app&&(r.app=Object.assign(Object.assign({},e.config.app),r.app)),e.config.user&&(r.user=e.config.user),e.config.view&&(r.view=e.config.view),e.metas.add(r,...null!==(n=e.config.metas)&&void 0!==n?n:[])}(s),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend),e.transports.addIgnoreErrorsPatterns(e.config.ignoreErrors)}(s),function(e){e.instrumentations.add(...e.config.instrumentations)}(s),s}const ze="faro",Ue={enabled:!0,sendTimeout:250,itemLimit:50},qe="browser",He="\n",Ge="eval",We="?",Qe="@",Ke=/^\s*at (?:(.*\).*?|.*?) ?\((?:address at )?)?((?:file|https?|blob|chrome-extension|address|native|eval|webpack||[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ye=/\((\S*)(?::(\d+))(?::(\d+))\)/,Xe="eval",Je="address at ",Ze=Je.length,et=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|safari-extension|safari-web-extension|capacitor)?:\/.*?|\[native code]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,tt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,nt=" > eval",rt="safari-extension",it="safari-web-extension",at=/Minified React error #\d+;/i;function ot(e,t,n,r){const i={filename:e||document.location.href,function:t||We};return void 0!==n&&(i.lineno=n),void 0!==r&&(i.colno=r),i}function st(e,t){const n=null==e?void 0:e.includes(rt),r=!n&&(null==e?void 0:e.includes(it));return n||r?[(null==e?void 0:e.includes(Qe))?e.split(Qe)[0]:e,n?`${rt}:${t}`:`${it}:${t}`]:[e,t]}function lt(e){let t=[];e.stacktrace?t=e.stacktrace.split(He).filter(((e,t)=>t%2==0)):e.stack&&(t=e.stack.split(He));const n=t.reduce(((t,n,r)=>{let i,a,o,s,l;if(i=Ke.exec(n)){if(a=i[1],o=i[2],s=i[3],l=i[4],null==o?void 0:o.startsWith(Xe)){const e=Ye.exec(o);e&&(o=e[1],s=e[2],l=e[3])}o=(null==o?void 0:o.startsWith(Je))?o.substring(Ze):o,[a,o]=st(a,o)}else if(i=et.exec(n)){if(a=i[1],o=i[3],s=i[4],l=i[5],o&&o.includes(nt)){const e=tt.exec(o);e&&(a=a||Ge,o=e[1],s=e[2])}else 0===r&&!l&&ie(e.columnNumber)&&(l=String(e.columnNumber+1));[a,o]=st(a,o)}return(o||a)&&t.push(ot(o,a,s?Number(s):void 0,l?Number(l):void 0)),t}),[]);return at.test(e.message)?n.slice(1):n}function ct(e){return{frames:lt(e)}}const ut="com.grafana.faro.session",dt=144e5,pt=9e5,ht={enabled:!0,persistent:!1,maxSessionPersistenceTime:pt};var ft=__webpack_require__(6660);const mt="unknown",gt=[()=>{const e=new ft.UAParser,{name:t,version:n}=e.getBrowser(),{name:r,version:i}=e.getOS(),a=e.getUA(),o=navigator.language,s=navigator.userAgent.includes("Mobi"),l=function(){if(!t||!n)return;if("userAgentData"in navigator&&navigator.userAgentData)return navigator.userAgentData.brands;return}();return{browser:{name:null!=t?t:mt,version:null!=n?n:mt,os:`${null!=r?r:mt} ${null!=i?i:mt}`,userAgent:null!=a?a:mt,language:null!=o?o:mt,mobile:s,brands:null!=l?l:mt,viewportWidth:`${window.innerWidth}`,viewportHeight:`${window.innerHeight}`}}},()=>({page:{url:location.href}})],yt=()=>{const e=window.k6;return{k6:Object.assign({isK6Browser:!0},(null==e?void 0:e.testRunId)&&{testRunId:null==e?void 0:e.testRunId})}};class bt{constructor(){this.unpatchedConsole=Ce,this.internalLogger=_e,this.config={},this.metas={}}logDebug(...e){this.internalLogger.debug(`${this.name}\n`,...e)}logInfo(...e){this.internalLogger.info(`${this.name}\n`,...e)}logWarn(...e){this.internalLogger.warn(`${this.name}\n`,...e)}logError(...e){this.internalLogger.error(`${this.name}\n`,...e)}}class vt extends bt{isBatched(){return!1}getIgnoreUrls(){return[]}}function wt(e,t){var n,r;if(void 0===t)return e;if(void 0===e)return{resourceSpans:t};const i=null===(n=e.resourceSpans)||void 0===n?void 0:n[0];if(void 0===i)return e;const a=(null==i?void 0:i.scopeSpans)||[],o=(null===(r=null==t?void 0:t[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},i),{scopeSpans:[...a,...o]})]})}function St(e,t){let n,r=!1;const i=()=>{null!=n?(e(...n),n=null,setTimeout(i,t)):r=!1};return(...a)=>{r?n=a:(e(...a),r=!0,setTimeout(i,t))}}const Et={session:"sessionStorage",local:"localStorage"};function xt(e){var t;try{let t;t=window[e];const n="__faro_storage_test__";return t.setItem(n,n),t.removeItem(n),!0}catch(n){return null===(t=Ie.internalLogger)||void 0===t||t.info(`Web storage of type ${e} is not available. Reason: ${n}`),!1}}function Ot(e,t){return Pt(t)?window[t].getItem(e):null}function _t(e,t,n){if(Pt(n))try{window[n].setItem(e,t)}catch(e){}}function Tt(e,t){Pt(t)&&window[t].removeItem(e)}const Ct=xt(Et.local),kt=xt(Et.session);function Pt(e){return e===Et.local?Ct:e===Et.session&&kt}function Rt(){var e,t,n;const r=Ie.config.sessionTracking;let i=null!==(n=null!==(t=null===(e=null==r?void 0:r.sampler)||void 0===e?void 0:e.call(r,{metas:Ie.metas.value}))&&void 0!==t?t:null==r?void 0:r.samplingRate)&&void 0!==n?n:1;if("number"!=typeof i){i=0}return Math.random()At[Math.floor(Math.random()*At.length)])).join("")}function jt({sessionId:e,started:t,lastActivity:n,isSampled:r=!0}={}){var i,a;const o=Y(),s=null===(a=null===(i=Ie.config)||void 0===i?void 0:i.sessionTracking)||void 0===a?void 0:a.generateSessionId;return null==e&&(e="function"==typeof s?s():Dt()),{sessionId:e,lastActivity:null!=n?n:o,started:null!=t?t:o,isSampled:r}}function It(e){if(null==e)return!1;const t=Y();if(!(t-e.startedthis.updateUserSession()),1e3),this.updateUserSession=Nt({fetchUserSession:Mt.fetchUserSession,storeUserSession:Mt.storeUserSession}),this.init()}static removeUserSession(){Tt(ut,Mt.storageTypeLocal)}static storeUserSession(e){_t(ut,JSON.stringify(e),Mt.storageTypeLocal)}static fetchUserSession(){const e=Ot(ut,Mt.storageTypeLocal);return e?JSON.parse(e):null}init(){document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&this.updateSession()})),Ie.metas.addListener((function(e){const t=e.session,n=Mt.fetchUserSession();if(t&&t.id!==(null==n?void 0:n.sessionId)){const e=Lt(jt({sessionId:t.id,isSampled:Rt()}),n);Mt.storeUserSession(e),Ie.api.setSession(e.sessionMeta)}}))}}Mt.storageTypeLocal=Et.local;class Ft{constructor(){this.updateSession=St((()=>this.updateUserSession()),1e3),this.updateUserSession=Nt({fetchUserSession:Ft.fetchUserSession,storeUserSession:Ft.storeUserSession}),this.init()}static removeUserSession(){Tt(ut,Ft.storageTypeSession)}static storeUserSession(e){_t(ut,JSON.stringify(e),Ft.storageTypeSession)}static fetchUserSession(){const e=Ot(ut,Ft.storageTypeSession);return e?JSON.parse(e):null}init(){document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&this.updateSession()})),Ie.metas.addListener((function(e){const t=e.session,n=Ft.fetchUserSession();if(t&&t.id!==(null==n?void 0:n.sessionId)){const e=Lt(jt({sessionId:t.id,isSampled:Rt()}),n);Ft.storeUserSession(e),Ie.api.setSession(e.sessionMeta)}}))}}function $t(e){return(null==e?void 0:e.persistent)?Mt:Ft}Ft.storageTypeSession=Et.session;var Bt=function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}l((r=r.apply(e,t||[])).next())}))},Vt=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);iDate.now(),this.promiseBuffer=function(e){const{size:t,concurrency:n}=e,r=[];let i=0;const a=()=>{if(i{i--,a(),t(e)}),(e=>{i--,a(),n(e)}))}};return{add:e=>{if(r.length+i>=t)throw new Error("Task buffer full");return new Promise(((t,n)=>{r.push({producer:e,resolve:t,reject:n}),a()}))}}}({size:null!==(r=e.bufferSize)&&void 0!==r?r:30,concurrency:null!==(i=e.concurrency)&&void 0!==i?i:5})}send(e){return Bt(this,void 0,void 0,(function*(){try{if(this.disabledUntil>new Date(this.getNow()))return this.logWarn(`Dropping transport item due to too many requests. Backoff until ${this.disabledUntil}`),Promise.resolve();yield this.promiseBuffer.add((()=>{const t=JSON.stringify(function(e){let t={meta:{}};return void 0!==e[0]&&(t.meta=e[0].meta),e.forEach((e=>{switch(e.type){case Q.LOG:case Q.EVENT:case Q.EXCEPTION:case Q.MEASUREMENT:const n=K[e.type],r=t[n];t=Object.assign(Object.assign({},t),{[n]:void 0===r?[e.payload]:[...r,e.payload]});break;case Q.TRACE:t=Object.assign(Object.assign({},t),{traces:wt(t.traces,e.payload.resourceSpans)})}})),t}(e)),{url:n,requestOptions:r,apiKey:i}=this.options,a=null!=r?r:{},{headers:o}=a,s=Vt(a,["headers"]);let l;const c=this.metas.value.session;return null!=c&&(l=c.id),fetch(n,Object.assign({method:"POST",headers:Object.assign(Object.assign(Object.assign({"Content-Type":"application/json"},null!=o?o:{}),i?{"x-api-key":i}:{}),l?{"x-faro-session-id":l}:{}),body:t,keepalive:t.length<=6e4},null!=s?s:{})).then((e=>Bt(this,void 0,void 0,(function*(){if(202===e.status){"invalid"===e.headers.get("X-Faro-Session-Status")&&this.extendFaroSession(this.config,this.logDebug)}return 429===e.status&&(this.disabledUntil=this.getRetryAfterDate(e),this.logWarn(`Too many requests, backing off until ${this.disabledUntil}`)),e.text().catch(xe),e})))).catch((e=>{this.logError("Failed sending payload to the receiver\n",JSON.parse(t),e)}))}))}catch(e){this.logError(e)}}))}getIgnoreUrls(){var e;return[this.options.url].concat(null!==(e=this.config.ignoreUrls)&&void 0!==e?e:[])}isBatched(){return!0}getRetryAfterDate(e){const t=this.getNow(),n=e.headers.get("Retry-After");if(n){const e=Number(n);if(!isNaN(e))return new Date(1e3*e+t);const r=Date.parse(n);if(!isNaN(r))return new Date(r)}return new Date(t+this.rateLimitBackoffMs)}extendFaroSession(e,t){const n="Session expired",r=e.sessionTracking;if(null==r?void 0:r.enabled){const{fetchUserSession:e,storeUserSession:i}=$t(r);Nt({fetchUserSession:e,storeUserSession:i})({forceSessionExtend:!0}),t(`${n} created new session.`)}else t(`${n}.`)}}class Ut extends bt{constructor(){super(...arguments),this.api={},this.transports={}}}const qt="DOMError",Ht="DOMException",Gt="Non-Error exception captured with keys:",Wt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function Qt(e){let t,n,r,i,a=[];if(pe(e)&&e.error)t=e.error.message,n=e.error.name,a=lt(e.error);else if((r=he(e))||fe(e)){const{name:i,message:a}=e;n=null!=i?i:r?qt:Ht,t=a?`${n}: ${a}`:n}else de(e)?(t=e.message,a=lt(e)):(ae(e)||(i=ce(e)))&&(n=i?e.constructor.name:void 0,t=`${Gt} ${Object.keys(e)}`);return[t,n,a]}function Kt(e){const t=window.onerror;window.onerror=(...n)=>{try{const[t,r,i,a,o]=n;let s,l,c=[];const u=re(t),d=ot(r,"?",i,a);o||!u?([s,l,c]=Qt(null!=o?o:t),0===c.length&&(c=[d])):u&&([s,l]=function(e){var t,n;const r=e.match(Wt),i=null!==(t=null==r?void 0:r[1])&&void 0!==t?t:ge;return[null!==(n=null==r?void 0:r[2])&&void 0!==n?n:e,i]}(t),c=[d]),s&&e.pushError(new Error(s),{type:l,stackFrames:c})}finally{null==t||t.apply(window,n)}}}function Yt(e){window.addEventListener("unhandledrejection",(t=>{var n,r;let i,a,o=t;o.reason?o=t.reason:(null===(n=t.detail)||void 0===n?void 0:n.reason)&&(o=null===(r=t.detail)||void 0===r?void 0:r.reason);let s=[];(e=>!ae(e)&&!oe(e))(o)?(i=`Non-Error promise rejection captured with value: ${String(o)}`,a="UnhandledRejection"):[i,a,s]=Qt(o),i&&e.pushError(new Error(i),{type:a,stackFrames:s})}))}class Xt extends Ut{constructor(){super(...arguments),this.name="@grafana/faro-web-sdk:instrumentation-errors",this.version=De}initialize(){this.logDebug("Initializing"),Kt(this.api),Yt(this.api)}}var Jt,Zt,en,tn,nn,rn=-1,an=function(e){addEventListener("pageshow",(function(t){t.persisted&&(rn=t.timeStamp,e(t))}),!0)},on=function(){var e=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart=0?r="back-forward-cache":n&&(document.prerendering||sn()>0?r="prerender":document.wasDiscarded?r="restore":n.type&&(r=n.type.replace(/_/g,"-"))),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r}},cn=function(e,t,n){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var r=new PerformanceObserver((function(e){Promise.resolve().then((function(){t(e.getEntries())}))}));return r.observe(Object.assign({type:e,buffered:!0},n||{})),r}}catch(e){}},un=function(e,t,n,r){var i,a;return function(o){t.value>=0&&(o||r)&&((a=t.value-(i||0))||void 0===i)&&(i=t.value,t.delta=a,t.rating=function(e,t){return e>t[1]?"poor":e>t[0]?"needs-improvement":"good"}(t.value,n),e(t))}},dn=function(e){requestAnimationFrame((function(){return requestAnimationFrame((function(){return e()}))}))},pn=function(e){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&e()}))},hn=function(e){var t=!1;return function(){t||(e(),t=!0)}},fn=-1,mn=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},gn=function(e){"hidden"===document.visibilityState&&fn>-1&&(fn="visibilitychange"===e.type?e.timeStamp:0,bn())},yn=function(){addEventListener("visibilitychange",gn,!0),addEventListener("prerenderingchange",gn,!0)},bn=function(){removeEventListener("visibilitychange",gn,!0),removeEventListener("prerenderingchange",gn,!0)},vn=function(){return fn<0&&(fn=mn(),yn(),an((function(){setTimeout((function(){fn=mn(),yn()}),0)}))),{get firstHiddenTime(){return fn}}},wn=function(e){document.prerendering?addEventListener("prerenderingchange",(function(){return e()}),!0):e()},Sn=[1800,3e3],En=function(e,t){t=t||{},wn((function(){var n,r=vn(),i=ln("FCP"),a=cn("paint",(function(e){e.forEach((function(e){"first-contentful-paint"===e.name&&(a.disconnect(),e.startTimet.latency){if(n)e.duration>n.latency?(n.entries=[e],n.latency=e.duration):e.duration===n.latency&&e.startTime===n.entries[0].startTime&&n.entries.push(e);else{var r={id:e.interactionId,latency:e.duration,entries:[e]};Rn.set(r.id,r),Pn.push(r)}Pn.sort((function(e,t){return t.latency-e.latency})),Pn.length>10&&Pn.splice(10).forEach((function(e){return Rn.delete(e.id)}))}}},Nn=function(e){var t=self.requestIdleCallback||self.setTimeout,n=-1;return e=hn(e),"hidden"===document.visibilityState?e():(n=t(e),pn(e)),n},Ln=[200,500],Mn=[2500,4e3],Fn={},$n=[800,1800],Bn=function e(t){document.prerendering?wn((function(){return e(t)})):"complete"!==document.readyState?addEventListener("load",(function(){return e(t)}),!0):setTimeout(t,0)},Vn={passive:!0,capture:!0},zn=new Date,Un=function(e,t){Zt||(Zt=t,en=e,tn=new Date,Gn(removeEventListener),qn())},qn=function(){if(en>=0&&en1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){Un(e,t),i()},r=function(){i()},i=function(){removeEventListener("pointerup",n,Vn),removeEventListener("pointercancel",r,Vn)};addEventListener("pointerup",n,Vn),addEventListener("pointercancel",r,Vn)}(t,e):Un(t,e)}},Gn=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,Hn,Vn)}))},Wn=[100,300];class Qn{constructor(e){this.pushMeasurement=e}initialize(){Object.entries(Qn.mapping).forEach((([e,t])=>{t((t=>{this.pushMeasurement({type:"web-vitals",values:{[e]:t.value}})}))}))}}Qn.mapping={cls:function(e,t){t=t||{},En(hn((function(){var n,r=ln("CLS",0),i=0,a=[],o=function(e){e.forEach((function(e){if(!e.hadRecentInput){var t=a[0],n=a[a.length-1];i&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(i+=e.value,a.push(e)):(i=e.value,a=[e])}})),i>r.value&&(r.value=i,r.entries=a,n())},s=cn("layout-shift",o);s&&(n=un(e,r,xn,t.reportAllChanges),pn((function(){o(s.takeRecords()),n(!0)})),an((function(){i=0,r=ln("CLS",0),n=un(e,r,xn,t.reportAllChanges),dn((function(){return n()}))})),setTimeout(n,0))})))},fcp:En,fid:function(e,t){t=t||{},wn((function(){var n,r=vn(),i=ln("FID"),a=function(e){e.startTime0&&e.responseStart(t||100)-1)return n||i;if(n=n?i+">"+n:i,r.id)break;e=r.parentNode}}catch(e){}return n},nr=-1,rr=function(){return nr},ir=function(e){addEventListener("pageshow",(function(t){t.persisted&&(nr=t.timeStamp,e(t))}),!0)},ar=function(){var e=Jn();return e&&e.activationStart||0},or=function(e,t){var n=Jn(),r="navigate";return rr()>=0?r="back-forward-cache":n&&(document.prerendering||ar()>0?r="prerender":document.wasDiscarded?r="restore":n.type&&(r=n.type.replace(/_/g,"-"))),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r}},sr=function(e,t,n){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var r=new PerformanceObserver((function(e){Promise.resolve().then((function(){t(e.getEntries())}))}));return r.observe(Object.assign({type:e,buffered:!0},n||{})),r}}catch(e){}},lr=function(e,t,n,r){var i,a;return function(o){t.value>=0&&(o||r)&&((a=t.value-(i||0))||void 0===i)&&(i=t.value,t.delta=a,t.rating=function(e,t){return e>t[1]?"poor":e>t[0]?"needs-improvement":"good"}(t.value,n),e(t))}},cr=function(e){requestAnimationFrame((function(){return requestAnimationFrame((function(){return e()}))}))},ur=function(e){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&e()}))},dr=function(e){var t=!1;return function(){t||(e(),t=!0)}},pr=-1,hr=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},fr=function(e){"hidden"===document.visibilityState&&pr>-1&&(pr="visibilitychange"===e.type?e.timeStamp:0,gr())},mr=function(){addEventListener("visibilitychange",fr,!0),addEventListener("prerenderingchange",fr,!0)},gr=function(){removeEventListener("visibilitychange",fr,!0),removeEventListener("prerenderingchange",fr,!0)},yr=function(){return pr<0&&(pr=hr(),mr(),ir((function(){setTimeout((function(){pr=hr(),mr()}),0)}))),{get firstHiddenTime(){return pr}}},br=function(e){document.prerendering?addEventListener("prerenderingchange",(function(){return e()}),!0):e()},vr=[1800,3e3],wr=function(e,t){t=t||{},br((function(){var n,r=yr(),i=or("FCP"),a=sr("paint",(function(e){e.forEach((function(e){"first-contentful-paint"===e.name&&(a.disconnect(),e.startTimet.latency){if(n)e.duration>n.latency?(n.entries=[e],n.latency=e.duration):e.duration===n.latency&&e.startTime===n.entries[0].startTime&&n.entries.push(e);else{var r={id:e.interactionId,latency:e.duration,entries:[e]};Cr.set(r.id,r),Tr.push(r)}Tr.sort((function(e,t){return t.latency-e.latency})),Tr.length>10&&Tr.splice(10).forEach((function(e){return Cr.delete(e.id)}))}}},Ar=function(e){var t=self.requestIdleCallback||self.setTimeout,n=-1;return e=dr(e),"hidden"===document.visibilityState?e():(n=t(e),ur(e)),n},Dr=[200,500],jr=function(e,t){"PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype&&(t=t||{},br((function(){var n;"interactionCount"in performance||Kn||(Kn=sr("event",_r,{type:"event",buffered:!0,durationThreshold:0}));var r,i=or("INP"),a=function(e){Ar((function(){e.forEach(Rr);var t,n=(t=Math.min(Tr.length-1,Math.floor(((Kn?Er:performance.interactionCount||0)-kr)/50)),Tr[t]);n&&n.latency!==i.value&&(i.value=n.latency,i.entries=n.entries,r())}))},o=sr("event",a,{durationThreshold:null!==(n=t.durationThreshold)&&void 0!==n?n:40});r=lr(e,i,Dr,t.reportAllChanges),o&&(o.observe({type:"first-input",buffered:!0}),ur((function(){a(o.takeRecords()),r(!0)})),ir((function(){kr=0,Tr.length=0,Cr.clear(),i=or("INP"),r=lr(e,i,Dr,t.reportAllChanges)})))})))},Ir=[],Nr=[],Lr=new WeakMap,Mr=new Map,Fr=-1,$r=function(e){Ir=Ir.concat(e),Br()},Br=function(){Fr<0&&(Fr=Ar(Vr))},Vr=function(){Mr.size>10&&Mr.forEach((function(e,t){Cr.has(t)||Mr.delete(t)}));var e=Tr.map((function(e){return Lr.get(e.entries[0])})),t=Nr.length-50;Nr=Nr.filter((function(n,r){return r>=t||e.includes(n)}));for(var n=new Set,r=0;r=0;r--){var i=Nr[r];if(Math.abs(n-i.renderTime)<=8){(t=i).startTime=Math.min(e.startTime,t.startTime),t.processingStart=Math.min(e.processingStart,t.processingStart),t.processingEnd=Math.max(e.processingEnd,t.processingEnd),t.entries.push(e);break}}t||(t={startTime:e.startTime,processingStart:e.processingStart,processingEnd:e.processingEnd,renderTime:n,entries:[e]},Nr.push(t)),(e.interactionId||"first-input"===e.entryType)&&Lr.set(e,t),Br()}));var zr,Ur,qr,Hr,Gr=function(e,t){for(var n,r=[],i=0;n=Ir[i];i++)if(!(n.startTime+n.durationt)break;r.push(n)}return r},Wr=[2500,4e3],Qr={},Kr=[800,1800],Yr=function e(t){document.prerendering?br((function(){return e(t)})):"complete"!==document.readyState?addEventListener("load",(function(){return e(t)}),!0):setTimeout(t,0)},Xr=function(e,t){t=t||{};var n=or("TTFB"),r=lr(e,n,Kr,t.reportAllChanges);Yr((function(){var i=Jn();i&&(n.value=Math.max(i.responseStart-ar(),0),n.entries=[i],r(!0),ir((function(){n=or("TTFB",0),(r=lr(e,n,Kr,t.reportAllChanges))(!0)})))}))},Jr={passive:!0,capture:!0},Zr=new Date,ei=function(e,t){zr||(zr=t,Ur=e,qr=new Date,ri(removeEventListener),ti())},ti=function(){if(Ur>=0&&Ur1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){ei(e,t),i()},r=function(){i()},i=function(){removeEventListener("pointerup",n,Jr),removeEventListener("pointercancel",r,Jr)};addEventListener("pointerup",n,Jr),addEventListener("pointercancel",r,Jr)}(t,e):ei(t,e)}},ri=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,ni,Jr)}))},ii=[100,300],ai=function(e,t){!function(e,t){t=t||{},br((function(){var n,r=yr(),i=or("FID"),a=function(e){e.startTimer.value&&(r.value=i,r.entries=a,n())},s=sr("layout-shift",o);s&&(n=lr(e,r,Sr,t.reportAllChanges),ur((function(){o(s.takeRecords()),n(!0)})),ir((function(){i=0,r=or("CLS",0),n=lr(e,r,Sr,t.reportAllChanges),cr((function(){return n()}))})),setTimeout(n,0))})))}((function(t){var n=function(e){var t,n={};if(e.entries.length){var r=e.entries.reduce((function(e,t){return e&&e.value>t.value?e:t}));if(r&&r.sources&&r.sources.length){var i=(t=r.sources).find((function(e){return e.node&&1===e.node.nodeType}))||t[0];i&&(n={largestShiftTarget:tr(i.node),largestShiftTime:r.startTime,largestShiftValue:r.value,largestShiftSource:i,largestShiftEntry:r,loadState:Zn(r.startTime)})}}return Object.assign(e,{attribution:n})}(t);e(n)}),t)}((e=>{const{loadState:t,largestShiftValue:n,largestShiftTime:r,largestShiftTarget:i}=e.attribution,a=this.buildInitialValues(e);this.addIfPresent(a,"largest_shift_value",n),this.addIfPresent(a,"largest_shift_time",r);const o=this.buildInitialContext(e);this.addIfPresent(o,si,t),this.addIfPresent(o,"largest_shift_target",i),this.pushMeasurement(a,o)}))}measureFCP(){!function(e,t){wr((function(t){var n=function(e){var t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:Zn(rr())};if(e.entries.length){var n=Jn(),r=e.entries[e.entries.length-1];if(n){var i=n.activationStart||0,a=Math.max(0,n.responseStart-i);t={timeToFirstByte:a,firstByteToFCP:e.value-a,loadState:Zn(e.entries[0].startTime),navigationEntry:n,fcpEntry:r}}}return Object.assign(e,{attribution:t})}(t);e(n)}),t)}((e=>{const{firstByteToFCP:t,timeToFirstByte:n,loadState:r}=e.attribution,i=this.buildInitialValues(e);this.addIfPresent(i,"first_byte_to_fcp",t),this.addIfPresent(i,li,n);const a=this.buildInitialContext(e);this.addIfPresent(a,si,r),this.pushMeasurement(i,a)}))}measureFID(){ai((e=>{const{eventTime:t,eventTarget:n,eventType:r,loadState:i}=e.attribution,a=this.buildInitialValues(e);this.addIfPresent(a,"event_time",t);const o=this.buildInitialContext(e);this.addIfPresent(o,"event_target",n),this.addIfPresent(o,"event_type",r),this.addIfPresent(o,si,i),this.pushMeasurement(a,o)}))}measureINP(){!function(e,t){Yn||(Yn=sr("long-animation-frame",$r)),jr((function(t){var n=function(e){var t=e.entries[0],n=Lr.get(t),r=t.processingStart,i=n.processingEnd,a=n.entries.sort((function(e,t){return e.processingStart-t.processingStart})),o=Gr(t.startTime,i),s=e.entries.find((function(e){return e.target})),l=s&&s.target||Mr.get(t.interactionId),c=[t.startTime+t.duration,i].concat(o.map((function(e){return e.startTime+e.duration}))),u=Math.max.apply(Math,c),d={interactionTarget:tr(l),interactionTargetElement:l,interactionType:t.name.startsWith("key")?"keyboard":"pointer",interactionTime:t.startTime,nextPaintTime:u,processedEventEntries:a,longAnimationFrameEntries:o,inputDelay:r-t.startTime,processingDuration:i-r,presentationDelay:Math.max(u-i,0),loadState:Zn(t.startTime)};return Object.assign(e,{attribution:d})}(t);e(n)}),t)}((e=>{const{interactionTime:t,presentationDelay:n,inputDelay:r,processingDuration:i,nextPaintTime:a,loadState:o,interactionTarget:s,interactionType:l}=e.attribution,c=this.buildInitialValues(e);this.addIfPresent(c,"interaction_time",t),this.addIfPresent(c,"presentation_delay",n),this.addIfPresent(c,"input_delay",r),this.addIfPresent(c,"processing_duration",i),this.addIfPresent(c,"next_paint_time",a);const u=this.buildInitialContext(e);this.addIfPresent(u,si,o),this.addIfPresent(u,"interaction_target",s),this.addIfPresent(u,"interaction_type",l),this.pushMeasurement(c,u)}))}measureLCP(){!function(e,t){!function(e,t){t=t||{},br((function(){var n,r=yr(),i=or("LCP"),a=function(e){t.reportAllChanges||(e=e.slice(-1)),e.forEach((function(e){e.startTime{const{elementRenderDelay:t,resourceLoadDelay:n,resourceLoadDuration:r,timeToFirstByte:i,element:a}=e.attribution,o=this.buildInitialValues(e);this.addIfPresent(o,"element_render_delay",t),this.addIfPresent(o,"resource_load_delay",n),this.addIfPresent(o,"resource_load_duration",r),this.addIfPresent(o,li,i);const s=this.buildInitialContext(e);this.addIfPresent(s,"element",a),this.pushMeasurement(o,s)}))}measureTTFB(){!function(e,t){Xr((function(t){var n=function(e){var t={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0};if(e.entries.length){var n=e.entries[0],r=n.activationStart||0,i=Math.max((n.workerStart||n.fetchStart)-r,0),a=Math.max(n.domainLookupStart-r,0),o=Math.max(n.connectStart-r,0),s=Math.max(n.connectEnd-r,0);t={waitingDuration:i,cacheDuration:a-i,dnsDuration:o-a,connectionDuration:s-o,requestDuration:e.value-s,navigationEntry:n}}return Object.assign(e,{attribution:t})}(t);e(n)}),t)}((e=>{const{dnsDuration:t,connectionDuration:n,requestDuration:r,waitingDuration:i,cacheDuration:a}=e.attribution,o=this.buildInitialValues(e);this.addIfPresent(o,"dns_duration",t),this.addIfPresent(o,"connection_duration",n),this.addIfPresent(o,"request_duration",r),this.addIfPresent(o,"waiting_duration",i),this.addIfPresent(o,"cache_duration",a);const s=this.buildInitialContext(e);this.pushMeasurement(o,s)}))}buildInitialValues(e){const t=e.name.toLowerCase();return{[t]:e.value,delta:e.delta}}buildInitialContext(e){var t;const n=null!==(t=Ot(oi,Et.session))&&void 0!==t?t:mt;return{id:e.id,rating:e.rating,navigation_type:e.navigationType,navigation_entry_id:n}}pushMeasurement(e,t){this.corePushMeasurement({type:"web-vitals",values:e},{context:t})}addIfPresent(e,t,n){n&&(e[t]=n)}}class ui extends Ut{constructor(){super(...arguments),this.name="@grafana/faro-web-sdk:instrumentation-web-vitals",this.version=De}initialize(){this.logDebug("Initializing");this.intializeWebVitalsInstrumentation().initialize()}intializeWebVitalsInstrumentation(){return this.config.trackWebVitalsAttribution?new ci(this.api.pushMeasurement):new Qn(this.api.pushMeasurement)}}const di="session_start",pi="session_resume";class hi extends Ut{constructor(){super(...arguments),this.name="@grafana/faro-web-sdk:instrumentation-session",this.version=De}sendSessionStartEvent(e){var t,n;const r=e.session;if(r&&r.id!==(null===(t=this.notifiedSession)||void 0===t?void 0:t.id)){if(this.notifiedSession&&this.notifiedSession.id===(null===(n=r.attributes)||void 0===n?void 0:n.previousSession))return this.api.pushEvent("session_extend",{},void 0,{skipDedupe:!0}),void(this.notifiedSession=r);this.notifiedSession=r,this.api.pushEvent(di,{},void 0,{skipDedupe:!0})}}createInitialSession(e,t){var n,r,i,a,o;let s,l,c=e.fetchUserSession();if(t.persistent&&t.maxSessionPersistenceTime&&c){const e=Y();c.lastActivity{var t,r,i;n();const a=null===(t=e.meta.session)||void 0===t?void 0:t.attributes;if(a&&"true"===(null==a?void 0:a.isSampled)){let t=JSON.parse(JSON.stringify(e));const n=null===(r=t.meta.session)||void 0===r?void 0:r.attributes;return null==n||delete n.isSampled,0===Object.keys(null!=n?n:{}).length&&(null===(i=t.meta.session)||void 0===i||delete i.attributes),t}return null}))}initialize(){this.logDebug("init session instrumentation");const e=this.config.sessionTracking;if(null==e?void 0:e.enabled){const t=$t(e);this.registerBeforeSendHook(t);const{initialSession:n,lifecycleType:r}=this.createInitialSession(t,e);t.storeUserSession(n);const i=n.sessionMeta;this.notifiedSession=i,this.api.setSession(i),r===di&&this.api.pushEvent(di,{},void 0,{skipDedupe:!0}),r===pi&&this.api.pushEvent(pi,{},void 0,{skipDedupe:!0})}this.metas.addListener(this.sendSessionStartEvent.bind(this))}}class fi extends Ut{constructor(){super(...arguments),this.name="@grafana/faro-web-sdk:instrumentation-view",this.version=De}sendViewChangedEvent(e){var t,n,r,i;const a=e.view;a&&a.name!==(null===(t=this.notifiedView)||void 0===t?void 0:t.name)&&(this.api.pushEvent("view_changed",{fromView:null!==(r=null===(n=this.notifiedView)||void 0===n?void 0:n.name)&&void 0!==r?r:mt,toView:null!==(i=a.name)&&void 0!==i?i:mt},void 0,{skipDedupe:!0}),this.notifiedView=a)}initialize(){this.metas.addListener(this.sendViewChangedEvent.bind(this))}}const mi=/^00-[a-f0-9]{32}-[a-f0-9]{16}-[0-9]{1,2}$/;function gi(e=[]){for(const t of e)if("traceparent"===t.name){if(!mi.test(t.description))continue;const[,e,n]=t.description.split("-");if(null!=e&&null!=n)return{traceId:e,spanId:n};break}}function yi(e=[],t){return e.some((e=>e&&null!=t.match(e)))}function bi(e,t={}){for(const[n,r]of Object.entries(t)){const t=e[n];return null!=t&&(se(r)?r.includes(t):t===r)}return!0}function vi(e){const{connectEnd:t,connectStart:n,decodedBodySize:r,domainLookupEnd:i,domainLookupStart:a,duration:o,encodedBodySize:s,fetchStart:l,initiatorType:c,name:u,nextHopProtocol:d,redirectEnd:p,redirectStart:h,renderBlockingStatus:f,requestStart:m,responseEnd:g,responseStart:y,responseStatus:b,secureConnectionStart:v,transferSize:w,workerStart:S}=e;return{name:u,duration:Si(o),tcpHandshakeTime:Si(t-n),dnsLookupTime:Si(i-a),tlsNegotiationTime:Si(m-v),responseStatus:Si(b),redirectTime:Si(p-h),requestTime:Si(y-m),responseTime:Si(g-y),fetchTime:Si(g-l),serviceWorkerTime:Si(l-S),decodedBodySize:Si(r),encodedBodySize:Si(s),cacheHitStatus:function(){let e="fullLoad";0===w?r>0&&(e="cache"):null!=b?304===b&&(e="conditionalFetch"):s>0&&w{"complete"===document.readyState&&(e(),document.removeEventListener("readystatechange",t))};document.addEventListener("readystatechange",t)}}((()=>xi(this,void 0,void 0,(function*(){const e=this.api.pushEvent,t=this.getIgnoreUrls(),{faroNavigationId:n}=yield function(e,t){let n;const r=new Promise((e=>{n=e})),i=new PerformanceObserver((r=>{var i;const[a]=r.getEntries();if(null==a||yi(t,a.name))return;const o=a.toJSON();let s=gi(null==o?void 0:o.serverTiming);const l=null!==(i=Ot(oi,Et.session))&&void 0!==i?i:mt,c=Object.assign(Object.assign({},wi(o)),{faroNavigationId:Dt(),faroPreviousNavigationId:l});_t(oi,c.faroNavigationId,Et.session),e("faro.performance.navigation",c,void 0,{spanContext:s,timestampOverwriteMs:performance.timeOrigin+o.startTime}),n(c)}));return i.observe({type:"navigation",buffered:!0}),r}(e,t);null!=n&&function(e,t,n){const r=Ie.config.trackResources;new PerformanceObserver((i=>{const a=i.getEntries();for(const i of a){if(yi(n,i.name))return;const a=i.toJSON();let o=gi(null==a?void 0:a.serverTiming);if(null==r&&bi(a,Ei)||r){const n=Object.assign(Object.assign({},vi(a)),{faroNavigationId:e,faroResourceId:Dt()});t("faro.performance.resource",n,void 0,{spanContext:o,timestampOverwriteMs:performance.timeOrigin+a.startTime})}}})).observe({type:"resource",buffered:!0})}(n,e,t)})))):this.logDebug("performance observer not supported. Disable performance instrumentation.")}getIgnoreUrls(){var e;return null===(e=this.transports.transports)||void 0===e?void 0:e.flatMap((e=>e.getIgnoreUrls()))}}class _i extends Ut{constructor(e={}){super(),this.options=e,this.name="@grafana/faro-web-sdk:instrumentation-console",this.version=De}initialize(){this.logDebug("Initializing\n",this.options),we.filter((e=>{var t;return!(null!==(t=this.options.disabledLevels)&&void 0!==t?t:_i.defaultDisabledLevels).includes(e)})).forEach((e=>{console[e]=(...t)=>{try{this.api.pushLog(t,{level:e})}catch(e){this.logError(e)}finally{this.unpatchedConsole[e](...t)}}}))}}function Ti(e={}){const t=[new Xt,new ui,new hi,new fi];return!1!==e.enablePerformanceInstrumentation&&t.unshift(new Oi),!1!==e.captureConsole&&t.push(new _i({disabledLevels:e.captureConsoleDisabledLevels})),t}function Ci(e){const t=function(e){var t,n,r,i,a,o,s,l,c;const u=[],d=ke(e.unpatchedConsole,e.internalLoggerLevel);return e.transports?((e.url||e.apiKey)&&d.error('if "transports" is defined, "url" and "apiKey" should not be defined'),u.push(...e.transports)):e.url?u.push(new zt({url:e.url,apiKey:e.apiKey})):d.error('either "url" or "transports" must be defined'),{app:e.app,batching:Object.assign(Object.assign({},Ue),e.batching),dedupe:null===(t=e.dedupe)||void 0===t||t,globalObjectKey:e.globalObjectKey||ze,instrumentations:null!==(n=e.instrumentations)&&void 0!==n?n:Ti(),internalLoggerLevel:null!==(r=e.internalLoggerLevel)&&void 0!==r?r:Te,isolate:null!==(i=e.isolate)&&void 0!==i&&i,logArgsSerializer:null!==(a=e.logArgsSerializer)&&void 0!==a?a:Se,metas:function(){const t=gt;return e.metas&&t.push(...e.metas),ae(window.k6)?[...t,yt]:t}(),parseStacktrace:ct,paused:null!==(o=e.paused)&&void 0!==o&&o,preventGlobalExposure:null!==(s=e.preventGlobalExposure)&&void 0!==s&&s,transports:u,unpatchedConsole:null!==(l=e.unpatchedConsole)&&void 0!==l?l:Ce,beforeSend:e.beforeSend,eventDomain:null!==(c=e.eventDomain)&&void 0!==c?c:qe,ignoreErrors:e.ignoreErrors,ignoreUrls:e.ignoreUrls,sessionTracking:Object.assign(Object.assign({},ht),e.sessionTracking),user:e.user,view:e.view,trackResources:e.trackResources,trackWebVitalsAttribution:e.trackWebVitalsAttribution}}(e);if(t)return Ve(t)}_i.defaultDisabledLevels=[be.DEBUG,be.TRACE,be.LOG];const ki=JSON.parse('{"id":"grafana-pyroscope-app"}'),Pi=ki.id,Ri=`/a/${Pi}`;var Ai=function(e){return e.EXPLORE="/explore",e.ADHOC="/ad-hoc",e.SETTINGS="/settings",e}({});const Di="b4013f7656edf48bc0145426a1d05fecd1bb7806",ji=[{regExp:/localhost/,environment:"local"},{regExp:/grafana-dev\.net/,environment:"dev"},{regExp:/grafana-ops\.net/,environment:"ops"},{regExp:/grafana\.net/,environment:"prod"}];function Ii(){var e,t;if(!(null===(t=window)||void 0===t||null===(e=t.location)||void 0===e?void 0:e.host))return null;const n=ji.find((({regExp:e})=>e.test(window.location.host)));return n?n.environment:null}const Ni=new Map([["dev",{environment:"dev",appName:"grafana-pyroscope-dev",faroUrl:"https://faro-collector-ops-eu-south-0.grafana-ops.net/collect/48e03a2647389f2f6494af7f975b4084"}],["ops",{environment:"ops",appName:"grafana-pyroscope-ops",faroUrl:"https://faro-collector-ops-eu-south-0.grafana-ops.net/collect/b5cfd5eeb412cf5e74bd828b4ddd17ff"}],["prod",{environment:"prod",appName:"grafana-pyroscope-prod",faroUrl:"https://faro-collector-ops-eu-south-0.grafana-ops.net/collect/6cbe17b3af4b72ce5936bf4d15a5c393"}]]);let Li=null;const Mi=()=>Li;var Fi=__webpack_require__(5959),$i=__webpack_require__.n(Fi),Bi=__webpack_require__(2540),Vi=Fi.createContext(void 0),zi=e=>{const t=Fi.useContext(Vi);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Ui=({client:e,children:t})=>(Fi.useEffect((()=>(e.mount(),()=>{e.unmount()})),[e]),(0,Bi.jsx)(Vi.Provider,{value:e,children:t}));function qi(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Hi(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}function Gi(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,Hi(e,t,"set"),n),n}function Wi(e,t,n){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return n}var Qi=new WeakMap,Ki=new WeakSet;function Yi(e,t){var n;"prod"!==function(e,t){return t.get?t.get.call(e):t.value}(n=this,Hi(n,Qi,"get"))&&console[e](...t)}const Xi=new class{trace(){var e;Wi(this,Ki,Yi).call(this,"trace",[]),null===(e=Mi())||void 0===e||e.api.pushLog([],{level:be.TRACE})}debug(...e){var t;Wi(this,Ki,Yi).call(this,"debug",e),null===(t=Mi())||void 0===t||t.api.pushLog(e,{level:be.DEBUG})}info(...e){var t;Wi(this,Ki,Yi).call(this,"info",e),null===(t=Mi())||void 0===t||t.api.pushLog(e,{level:be.INFO})}log(...e){var t;Wi(this,Ki,Yi).call(this,"log",e),null===(t=Mi())||void 0===t||t.api.pushLog(e,{level:be.LOG})}warn(...e){var t;Wi(this,Ki,Yi).call(this,"warn",e),null===(t=Mi())||void 0===t||t.api.pushLog(e,{level:be.WARN})}error(e,t){var n;Wi(this,Ki,Yi).call(this,"error",[e]),t&&Wi(this,Ki,Yi).call(this,"error",["Error context",t]),null===(n=Mi())||void 0===n||n.api.pushError(e,{context:t})}constructor(){var e,t;qi(e=this,t=Ki),t.add(e),function(e,t,n){qi(e,t),t.set(e,n)}(this,Qi,{writable:!0,value:void 0}),Gi(this,Qi,Ii())}};function Ji(e,t){var n=function(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}(e,t,"get");return function(e,t){return t.get?t.get.call(e):t.value}(e,n)}function Zi(e,t,n){!function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}(e,t),t.set(e,n)}var ea=new WeakMap;const ta=new class{has(e){return Ji(this,ea).hasOwnProperty(e)}get(e){if(!this.has(e))return null;try{return JSON.parse(Ji(this,ea).getItem(e))}catch(t){return Xi.error(t,{info:`Error parsing JSON for storage item "${e}"!`}),null}}set(e,t){try{Ji(this,ea).setItem(e,JSON.stringify(t))}catch(t){Xi.error(t,{info:`Error setting storage item "${e}"!`})}}constructor(){var e,t,n;Zi(this,ea,{writable:!0,value:window.localStorage}),e=this,t="KEYS",n={SETTINGS:`${ki.id}.userSettings`,GITHUB_INTEGRATION:`${ki.id}.gitHubIntegration`,PROFILES_EXPLORER:`${ki.id}.profilesExplorer`},t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}},na=()=>{};function ra(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class ia extends Error{constructor(e,t){let n=`HTTP ${e.status} (${e.statusText||"?"})`;(null==t?void 0:t.message)&&(n=`${n} → ${t.message}`),super(n),ra(this,"response",void 0),ra(this,"reason",void 0),this.response=e}}function aa(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function oa(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sa(e){for(var t=1;t"grafana-pyroscope-datasource"===e.type))}static selectDefaultDataSource(){var e;const t=ua.getPyroscopeDataSources(),n=new URL(window.location.href).searchParams.get("var-dataSource"),r=null===(e=ta.get(ta.KEYS.PROFILES_EXPLORER))||void 0===e?void 0:e.dataSource,i=t.find((e=>e.uid===n))||t.find((e=>e.uid===r))||t.find((e=>e.jsonData.overridesDefault))||t.find((e=>e.isDefault))||t[0];return i||(Xi.warn("Cannot find any Pyroscope data source! Please add and configure a Pyroscope data source to your Grafana instance."),{uid:"no-data-source-configured"})}static getBaseUrl(){const e=ua.selectDefaultDataSource();let t=a.config.appSubUrl||"";return"/"!==t.at(-1)&&(t+="/"),`${t}api/datasources/proxy/uid/${e.uid}`}constructor(){var e,t;super(ua.getBaseUrl().toString(),{"content-type":"application/json","X-Grafana-Org-Id":String((null===(t=a.config.bootData)||void 0===t||null===(e=t.user)||void 0===e?void 0:e.orgId)||"")})}}var da=class extends P{constructor(e,t){super(),this.options=t,this.#x=e,this.#O=null,this.bindMethods(),this.setOptions(t)}#x;#_=void 0;#T=void 0;#C=void 0;#k;#P;#O;#R;#A;#D;#j;#I;#N;#L=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#_.addObserver(this),pa(this.#_,this.options)?this.#M():this.updateResult(),this.#F())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ha(this.#_,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ha(this.#_,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#$(),this.#B(),this.#_.removeObserver(this)}setOptions(e,t){const n=this.options,r=this.#_;if(this.options=this.#x.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof p(this.options.enabled,this.#_))throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#V(),this.#_.setOptions(this.options),n._defaulted&&!v(this.options,n)&&this.#x.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#_,observer:this});const i=this.hasListeners();i&&fa(this.#_,r,this.options,n)&&this.#M(),this.updateResult(t),!i||this.#_===r&&p(this.options.enabled,this.#_)===p(n.enabled,this.#_)&&d(this.options.staleTime,this.#_)===d(n.staleTime,this.#_)||this.#z();const a=this.#U();!i||this.#_===r&&p(this.options.enabled,this.#_)===p(n.enabled,this.#_)&&a===this.#N||this.#q(a)}getOptimisticResult(e){const t=this.#x.getQueryCache().build(this.#x,e),n=this.createResult(t,e);return function(e,t){if(!v(e.getCurrentResult(),t))return!0;return!1}(this,n)&&(this.#C=n,this.#P=this.options,this.#k=this.#_.state),n}getCurrentResult(){return this.#C}trackResult(e,t){const n={};return Object.keys(e).forEach((r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(r),t?.(r),e[r])})})),n}trackProp(e){this.#L.add(e)}getCurrentQuery(){return this.#_}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#x.defaultQueryOptions(e),n=this.#x.getQueryCache().build(this.#x,t);return n.isFetchingOptimistic=!0,n.fetch().then((()=>this.createResult(n,t)))}fetch(e){return this.#M({...e,cancelRefetch:e.cancelRefetch??!0}).then((()=>(this.updateResult(),this.#C)))}#M(e){this.#V();let t=this.#_.fetch(this.options,e);return e?.throwOnError||(t=t.catch(l)),t}#z(){this.#$();const e=d(this.options.staleTime,this.#_);if(s||this.#C.isStale||!c(e))return;const t=u(this.#C.dataUpdatedAt,e)+1;this.#j=setTimeout((()=>{this.#C.isStale||this.updateResult()}),t)}#U(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#_):this.options.refetchInterval)??!1}#q(e){this.#B(),this.#N=e,!s&&!1!==p(this.options.enabled,this.#_)&&c(this.#N)&&0!==this.#N&&(this.#I=setInterval((()=>{(this.options.refetchIntervalInBackground||R.isFocused())&&this.#M()}),this.#N))}#F(){this.#z(),this.#q(this.#U())}#$(){this.#j&&(clearTimeout(this.#j),this.#j=void 0)}#B(){this.#I&&(clearInterval(this.#I),this.#I=void 0)}createResult(e,t){const n=this.#_,r=this.options,i=this.#C,a=this.#k,o=this.#P,s=e!==n?e.state:this.#T,{state:l}=e;let c,u={...l},d=!1;if(t._optimisticResults){const i=this.hasListeners(),a=!i&&pa(e,t),o=i&&fa(e,n,t,r);(a||o)&&(u={...u,...$(l.data,e.options)}),"isRestoring"===t._optimisticResults&&(u.fetchStatus="idle")}let{error:p,errorUpdatedAt:h,status:f}=u;if(t.select&&void 0!==u.data)if(i&&u.data===a?.data&&t.select===this.#R)c=this.#A;else try{this.#R=t.select,c=t.select(u.data),c=x(i?.data,c,t),this.#A=c,this.#O=null}catch(e){this.#O=e}else c=u.data;if(void 0!==t.placeholderData&&void 0===c&&"pending"===f){let e;if(i?.isPlaceholderData&&t.placeholderData===o?.placeholderData)e=i.data;else if(e="function"==typeof t.placeholderData?t.placeholderData(this.#D?.state.data,this.#D):t.placeholderData,t.select&&void 0!==e)try{e=t.select(e),this.#O=null}catch(e){this.#O=e}void 0!==e&&(f="success",c=x(i?.data,e,t),d=!0)}this.#O&&(p=this.#O,c=this.#A,h=Date.now(),f="error");const m="fetching"===u.fetchStatus,g="pending"===f,y="error"===f,b=g&&m,v=void 0!==c;return{status:f,fetchStatus:u.fetchStatus,isPending:g,isSuccess:"success"===f,isError:y,isInitialLoading:b,isLoading:b,data:c,dataUpdatedAt:u.dataUpdatedAt,error:p,errorUpdatedAt:h,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>s.dataUpdateCount||u.errorUpdateCount>s.errorUpdateCount,isFetching:m,isRefetching:m&&!g,isLoadingError:y&&!v,isPaused:"paused"===u.fetchStatus,isPlaceholderData:d,isRefetchError:y&&v,isStale:ma(e,t),refetch:this.refetch}}updateResult(e){const t=this.#C,n=this.createResult(this.#_,this.options);if(this.#k=this.#_.state,this.#P=this.options,void 0!==this.#k.data&&(this.#D=this.#_),v(n,t))return;this.#C=n;const r={};!1!==e?.listeners&&(()=>{if(!t)return!0;const{notifyOnChangeProps:e}=this.options,n="function"==typeof e?e():e;if("all"===n||!n&&!this.#L.size)return!0;const r=new Set(n??this.#L);return this.options.throwOnError&&r.add("error"),Object.keys(this.#C).some((e=>{const n=e;return this.#C[n]!==t[n]&&r.has(n)}))})()&&(r.listeners=!0),this.#H({...r,...e})}#V(){const e=this.#x.getQueryCache().build(this.#x,this.options);if(e===this.#_)return;const t=this.#_;this.#_=e,this.#T=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#F()}#H(e){k.batch((()=>{e.listeners&&this.listeners.forEach((e=>{e(this.#C)})),this.#x.getQueryCache().notify({query:this.#_,type:"observerResultsUpdated"})}))}};function pa(e,t){return function(e,t){return!1!==p(t.enabled,e)&&void 0===e.state.data&&!("error"===e.state.status&&!1===t.retryOnMount)}(e,t)||void 0!==e.state.data&&ha(e,t,t.refetchOnMount)}function ha(e,t,n){if(!1!==p(t.enabled,e)){const r="function"==typeof n?n(e):n;return"always"===r||!1!==r&&ma(e,t)}return!1}function fa(e,t,n,r){return(e!==t||!1===p(r.enabled,e))&&(!n.suspense||"error"!==e.state.status)&&ma(e,n)}function ma(e,t){return!1!==p(t.enabled,e)&&e.isStaleByTime(d(t.staleTime,e))}function ga(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var ya=Fi.createContext(ga()),ba=()=>Fi.useContext(ya),va=Fi.createContext(!1),wa=()=>Fi.useContext(va);va.Provider;function Sa(e,t){return"function"==typeof e?e(...t):!!e}function Ea(){}var xa=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},Oa=e=>{Fi.useEffect((()=>{e.clearReset()}),[e])},_a=({result:e,errorResetBoundary:t,throwOnError:n,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&Sa(n,[e.error,r]),Ta=e=>{e.suspense&&"number"!=typeof e.staleTime&&(e.staleTime=1e3)},Ca=(e,t)=>e?.suspense&&t.isPending,ka=(e,t,n)=>t.fetchOptimistic(e).catch((()=>{n.clearReset()}));function Pa(e,t){return function(e,t,n){const r=zi(n),i=wa(),a=ba(),o=r.defaultQueryOptions(e);r.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=i?"isRestoring":"optimistic",Ta(o),xa(o,a),Oa(a);const[s]=Fi.useState((()=>new t(r,o))),l=s.getOptimisticResult(o);if(Fi.useSyncExternalStore(Fi.useCallback((e=>{const t=i?()=>{}:s.subscribe(k.batchCalls(e));return s.updateResult(),t}),[s,i]),(()=>s.getCurrentResult()),(()=>s.getCurrentResult())),Fi.useEffect((()=>{s.setOptions(o,{listeners:!1})}),[o,s]),Ca(o,l))throw ka(o,s,a);if(_a({result:l,errorResetBoundary:a,throwOnError:o.throwOnError,query:r.getQueryCache().get(o.queryHash)}))throw l.error;return r.getDefaultOptions().queries?._experimental_afterQuery?.(o,l),o.notifyOnChangeProps?l:s.trackResult(l)}(e,da,t)}function Ra(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}const Aa=new class extends ua{get(){var e,t=this;return(e=function*(){const e=yield t.fetch("/querier.v1.QuerierService/GetProfileStats",{method:"POST",body:JSON.stringify({})}),n=yield e.json();return{hasIngestedData:n.dataIngested,oldestProfileTime:Number(n.oldestProfileTime),newestProfileTime:Number(n.newestProfileTime)}},function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Ra(a,r,i,o,s,"next",e)}function s(e){Ra(a,r,i,o,s,"throw",e)}o(void 0)}))})()}};function Da(){const[e,t]=(0,Fi.useState)(!1),n=ua.getPyroscopeDataSources().length,{isFetching:r,error:i,stats:a}=function({enabled:e}){const{isFetching:t,error:n,data:r,refetch:i}=Pa({enabled:e,placeholderData:()=>({hasIngestedData:!0,oldestProfileTime:0,newestProfileTime:0}),queryKey:["tenant-stats"],queryFn:()=>(Aa.abort(),Aa.get())});return{isFetching:t,error:Aa.isAbortError(n)?null:n,stats:r,refetch:i}}({enabled:n>0}),o=!r&&!(null==a?void 0:a.hasIngestedData);return{data:{shouldShowLoadingPage:!i&&r,shouldShowOnboardingPage:(i||!n||o)&&!e,shouldShowNoDataSourceBanner:!n},actions:{closeModal(){t(!0)}}}}const ja=e=>({row:(0,i.css)({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start"}),headerColumn:(0,i.css)({display:"flex",flexDirection:"column",minWidth:"120px",alignItems:"start"}),column:(0,i.css)({display:"flex",flexDirection:"column",minWidth:"120px",alignItems:"end"}),tooltip:(0,i.css)({display:"flex",color:e.colors.text.secondary,fontSize:e.typography.bodySmall.fontSize}),contentWithIcon:(0,i.css)({display:"none",[`@media ${o.styleMixins.mediaUp(e.v1.breakpoints.sm)}`]:{display:"block"}})}),Ia=e=>(0,r.formattedValueToString)((0,r.getValueFormat)("decbytes")(e)),Na=e=>(0,r.formattedValueToString)((0,r.getValueFormat)("short")(e));function La(e){const t=(0,o.useStyles2)(ja),{data:n}=e,r=Ia(n.queryImpact.totalBytesInTimeRange),i=(0,Fi.useMemo)((()=>$i().createElement("div",{"data-testid":"queryAnalysis-popup"},$i().createElement("div",{className:t.row},$i().createElement("div",{className:t.headerColumn},"Data in time range"),$i().createElement("div",{className:t.column},r),$i().createElement("div",{className:t.column}," ")),void 0!==n.queryImpact.totalQueriedSeries&&$i().createElement("div",{className:t.row},$i().createElement("div",{className:t.headerColumn},"Series in query"),$i().createElement("div",{className:t.column},Na(n.queryImpact.totalQueriedSeries)),$i().createElement("div",{className:t.column}," ")),$i().createElement("div",{className:t.row},$i().createElement("div",{className:t.headerColumn},"Deduplication"),$i().createElement("div",{className:t.column},n.queryImpact.deduplicationNeeded?"yes":"no"),$i().createElement("div",{className:t.column}," ")),$i().createElement(o.Divider,null),$i().createElement("div",{className:t.row},$i().createElement("div",{className:t.headerColumn}," "),n.queryScopes.map(((e,n)=>$i().createElement("div",{key:n,className:t.column},$i().createElement("strong",null,e.componentType))))),$i().createElement("div",{className:t.row},$i().createElement("div",{className:t.headerColumn},"Replicas"),n.queryScopes.map(((e,n)=>$i().createElement("div",{key:n,className:t.column},e.componentCount||"/")))),$i().createElement("div",{className:t.row},$i().createElement("div",{className:t.headerColumn},"Blocks"),n.queryScopes.map(((e,n)=>$i().createElement("div",{key:n,className:t.column},Na(e.blockCount)||"/")))),$i().createElement("div",{className:t.row},$i().createElement("div",{className:t.headerColumn},"Series"),n.queryScopes.map(((e,n)=>$i().createElement("div",{key:n,className:t.column},Na(e.seriesCount)||"/")))),$i().createElement("div",{className:t.row},$i().createElement("div",{className:t.headerColumn},"Profiles"),n.queryScopes.map(((e,n)=>$i().createElement("div",{key:n,className:t.column},Na(e.profileCount)||"/")))),$i().createElement("div",{className:t.row},$i().createElement("div",{className:t.headerColumn},"Samples"),n.queryScopes.map(((e,n)=>$i().createElement("div",{key:n,className:t.column},Na(e.sampleCount)||"/")))),$i().createElement("div",{className:t.row},$i().createElement("div",{className:t.headerColumn}," "),$i().createElement("div",{className:t.column}," "),$i().createElement("div",{className:t.column}," ")),$i().createElement("div",{className:t.row},$i().createElement("div",{className:t.headerColumn},"Index Store"),n.queryScopes.map(((e,n)=>$i().createElement("div",{key:n,className:t.column},Ia(e.indexBytes)||"/")))),$i().createElement("div",{className:t.row},$i().createElement("div",{className:t.headerColumn},"Profiles Store"),n.queryScopes.map(((e,n)=>$i().createElement("div",{key:n,className:t.column},Ia(e.profileBytes)||"/")))),$i().createElement("div",{className:t.row},$i().createElement("div",{className:t.headerColumn},"Symbols Store"),n.queryScopes.map(((e,n)=>$i().createElement("div",{key:n,className:t.column},Ia(e.symbolBytes)||"/")))))),[n,t,r]);return $i().createElement($i().Fragment,null,void 0!==n.queryImpact.totalBytesInTimeRange?$i().createElement(o.Toggletip,{content:i,fitContent:!0},$i().createElement("div",{className:t.tooltip,"data-testid":"queryAnalysis-tooltip"},$i().createElement("span",{className:t.contentWithIcon},"Stored data in time range: ",r)," ",$i().createElement(o.IconButton,{name:"database","aria-label":"Query info"}))):null)}var Ma,Fa,$a,Ba,Va=__webpack_require__(2688),za=__webpack_require__.n(Va),Ua=__webpack_require__(9406),qa=__webpack_require__.n(Ua),Ha=__webpack_require__(7383),Ga=__webpack_require__.n(Ha),Wa=__webpack_require__(1664),Qa=__webpack_require__.n(Wa),Ka="bodyAttributes",Ya="htmlAttributes",Xa="titleAttributes",Ja={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title"},Za=(Object.keys(Ja).map((function(e){return Ja[e]})),"charset"),eo="cssText",to="href",no="http-equiv",ro="innerHTML",io="itemprop",ao="name",oo="property",so="rel",lo="src",co="target",uo={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},po="defaultTitle",ho="defer",fo="encodeSpecialCharacters",mo="onChangeClientState",go="titleTemplate",yo=Object.keys(uo).reduce((function(e,t){return e[uo[t]]=t,e}),{}),bo=[Ja.NOSCRIPT,Ja.SCRIPT,Ja.STYLE],vo="data-react-helmet",wo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},So=function(){function e(e,t){for(var n=0;n=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n},Oo=function(e){return!1===(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])?String(e):String(e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")},_o=function(e){var t=Ro(e,Ja.TITLE),n=Ro(e,go);if(n&&t)return n.replace(/%s/g,(function(){return Array.isArray(t)?t.join(""):t}));var r=Ro(e,po);return t||r||void 0},To=function(e){return Ro(e,mo)||function(){}},Co=function(e,t){return t.filter((function(t){return void 0!==t[e]})).map((function(t){return t[e]})).reduce((function(e,t){return Eo({},e,t)}),{})},ko=function(e,t){return t.filter((function(e){return void 0!==e[Ja.BASE]})).map((function(e){return e[Ja.BASE]})).reverse().reduce((function(t,n){if(!t.length)for(var r=Object.keys(n),i=0;i=0;n--){var r=e[n];if(r.hasOwnProperty(t))return r[t]}return null},Ao=(Ma=Date.now(),function(e){var t=Date.now();t-Ma>16?(Ma=t,e(t)):setTimeout((function(){Ao(e)}),0)}),Do=function(e){return clearTimeout(e)},jo="undefined"!=typeof window?window.requestAnimationFrame&&window.requestAnimationFrame.bind(window)||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||Ao:__webpack_require__.g.requestAnimationFrame||Ao,Io="undefined"!=typeof window?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||Do:__webpack_require__.g.cancelAnimationFrame||Do,No=function(e){return console&&"function"==typeof console.warn&&console.warn(e)},Lo=null,Mo=function(e,t){var n=e.baseTag,r=e.bodyAttributes,i=e.htmlAttributes,a=e.linkTags,o=e.metaTags,s=e.noscriptTags,l=e.onChangeClientState,c=e.scriptTags,u=e.styleTags,d=e.title,p=e.titleAttributes;Bo(Ja.BODY,r),Bo(Ja.HTML,i),$o(d,p);var h={baseTag:Vo(Ja.BASE,n),linkTags:Vo(Ja.LINK,a),metaTags:Vo(Ja.META,o),noscriptTags:Vo(Ja.NOSCRIPT,s),scriptTags:Vo(Ja.SCRIPT,c),styleTags:Vo(Ja.STYLE,u)},f={},m={};Object.keys(h).forEach((function(e){var t=h[e],n=t.newTags,r=t.oldTags;n.length&&(f[e]=n),r.length&&(m[e]=h[e].oldTags)})),t&&t(),l(e,f,m)},Fo=function(e){return Array.isArray(e)?e.join(""):e},$o=function(e,t){void 0!==e&&document.title!==e&&(document.title=Fo(e)),Bo(Ja.TITLE,t)},Bo=function(e,t){var n=document.getElementsByTagName(e)[0];if(n){for(var r=n.getAttribute(vo),i=r?r.split(","):[],a=[].concat(i),o=Object.keys(t),s=0;s=0;d--)n.removeAttribute(a[d]);i.length===a.length?n.removeAttribute(vo):n.getAttribute(vo)!==o.join(",")&&n.setAttribute(vo,o.join(","))}},Vo=function(e,t){var n=document.head||document.querySelector(Ja.HEAD),r=n.querySelectorAll(e+"["+vo+"]"),i=Array.prototype.slice.call(r),a=[],o=void 0;return t&&t.length&&t.forEach((function(t){var n=document.createElement(e);for(var r in t)if(t.hasOwnProperty(r))if(r===ro)n.innerHTML=t.innerHTML;else if(r===eo)n.styleSheet?n.styleSheet.cssText=t.cssText:n.appendChild(document.createTextNode(t.cssText));else{var s=void 0===t[r]?"":t[r];n.setAttribute(r,s)}n.setAttribute(vo,"true"),i.some((function(e,t){return o=t,n.isEqualNode(e)}))?i.splice(o,1):a.push(n)})),i.forEach((function(e){return e.parentNode.removeChild(e)})),a.forEach((function(e){return n.appendChild(e)})),{oldTags:i,newTags:a}},zo=function(e){return Object.keys(e).reduce((function(t,n){var r=void 0!==e[n]?n+'="'+e[n]+'"':""+n;return t?t+" "+r:r}),"")},Uo=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).reduce((function(t,n){return t[uo[n]||n]=e[n],t}),t)},qo=function(e,t,n){switch(e){case Ja.TITLE:return{toComponent:function(){return e=t.title,n=t.titleAttributes,(r={key:e})[vo]=!0,i=Uo(n,r),[$i().createElement(Ja.TITLE,i,e)];var e,n,r,i},toString:function(){return function(e,t,n,r){var i=zo(n),a=Fo(t);return i?"<"+e+" "+vo+'="true" '+i+">"+Oo(a,r)+"":"<"+e+" "+vo+'="true">'+Oo(a,r)+""}(e,t.title,t.titleAttributes,n)}};case Ka:case Ya:return{toComponent:function(){return Uo(t)},toString:function(){return zo(t)}};default:return{toComponent:function(){return function(e,t){return t.map((function(t,n){var r,i=((r={key:n})[vo]=!0,r);return Object.keys(t).forEach((function(e){var n=uo[e]||e;if(n===ro||n===eo){var r=t.innerHTML||t.cssText;i.dangerouslySetInnerHTML={__html:r}}else i[n]=t[e]})),$i().createElement(e,i)}))}(e,t)},toString:function(){return function(e,t,n){return t.reduce((function(t,r){var i=Object.keys(r).filter((function(e){return!(e===ro||e===eo)})).reduce((function(e,t){var i=void 0===r[t]?t:t+'="'+Oo(r[t],n)+'"';return e?e+" "+i:i}),""),a=r.innerHTML||r.cssText||"",o=-1===bo.indexOf(e);return t+"<"+e+" "+vo+'="true" '+i+(o?"/>":">"+a+"")}),"")}(e,t,n)}}}},Ho=function(e){var t=e.baseTag,n=e.bodyAttributes,r=e.encode,i=e.htmlAttributes,a=e.linkTags,o=e.metaTags,s=e.noscriptTags,l=e.scriptTags,c=e.styleTags,u=e.title,d=void 0===u?"":u,p=e.titleAttributes;return{base:qo(Ja.BASE,t,r),bodyAttributes:qo(Ka,n,r),htmlAttributes:qo(Ya,i,r),link:qo(Ja.LINK,a,r),meta:qo(Ja.META,o,r),noscript:qo(Ja.NOSCRIPT,s,r),script:qo(Ja.SCRIPT,l,r),style:qo(Ja.STYLE,c,r),title:qo(Ja.TITLE,{title:d,titleAttributes:p},r)}},Go=qa()((function(e){return{baseTag:ko([to,co],e),bodyAttributes:Co(Ka,e),defer:Ro(e,ho),encode:Ro(e,fo),htmlAttributes:Co(Ya,e),linkTags:Po(Ja.LINK,[so,to],e),metaTags:Po(Ja.META,[ao,Za,no,oo,io],e),noscriptTags:Po(Ja.NOSCRIPT,[ro],e),onChangeClientState:To(e),scriptTags:Po(Ja.SCRIPT,[lo,ro],e),styleTags:Po(Ja.STYLE,[eo],e),title:_o(e),titleAttributes:Co(Xa,e)}}),(function(e){Lo&&Io(Lo),e.defer?Lo=jo((function(){Mo(e,(function(){Lo=null}))})):(Mo(e),Lo=null)}),Ho)((function(){return null})),Wo=(Fa=Go,Ba=$a=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.shouldComponentUpdate=function(e){return!Ga()(this.props,e)},t.prototype.mapNestedChildrenToProps=function(e,t){if(!t)return null;switch(e.type){case Ja.SCRIPT:case Ja.NOSCRIPT:return{innerHTML:t};case Ja.STYLE:return{cssText:t}}throw new Error("<"+e.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")},t.prototype.flattenArrayTypeChildren=function(e){var t,n=e.child,r=e.arrayTypeChildren,i=e.newChildProps,a=e.nestedChildren;return Eo({},r,((t={})[n.type]=[].concat(r[n.type]||[],[Eo({},i,this.mapNestedChildrenToProps(n,a))]),t))},t.prototype.mapObjectTypeChildren=function(e){var t,n,r=e.child,i=e.newProps,a=e.newChildProps,o=e.nestedChildren;switch(r.type){case Ja.TITLE:return Eo({},i,((t={})[r.type]=o,t.titleAttributes=Eo({},a),t));case Ja.BODY:return Eo({},i,{bodyAttributes:Eo({},a)});case Ja.HTML:return Eo({},i,{htmlAttributes:Eo({},a)})}return Eo({},i,((n={})[r.type]=Eo({},a),n))},t.prototype.mapArrayTypeChildrenToProps=function(e,t){var n=Eo({},t);return Object.keys(e).forEach((function(t){var r;n=Eo({},n,((r={})[t]=e[t],r))})),n},t.prototype.warnOnInvalidChildren=function(e,t){return!0},t.prototype.mapChildrenToProps=function(e,t){var n=this,r={};return $i().Children.forEach(e,(function(e){if(e&&e.props){var i=e.props,a=i.children,o=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).reduce((function(t,n){return t[yo[n]||n]=e[n],t}),t)}(xo(i,["children"]));switch(n.warnOnInvalidChildren(e,a),e.type){case Ja.LINK:case Ja.META:case Ja.NOSCRIPT:case Ja.SCRIPT:case Ja.STYLE:r=n.flattenArrayTypeChildren({child:e,arrayTypeChildren:r,newChildProps:o,nestedChildren:a});break;default:t=n.mapObjectTypeChildren({child:e,newProps:t,newChildProps:o,nestedChildren:a})}}})),t=this.mapArrayTypeChildrenToProps(r,t)},t.prototype.render=function(){var e=this.props,t=e.children,n=xo(e,["children"]),r=Eo({},n);return t&&(r=this.mapChildrenToProps(t,r)),$i().createElement(Fa,r)},So(t,null,[{key:"canUseDOM",set:function(e){Fa.canUseDOM=e}}]),t}($i().Component),$a.propTypes={base:za().object,bodyAttributes:za().object,children:za().oneOfType([za().arrayOf(za().node),za().node]),defaultTitle:za().string,defer:za().bool,encodeSpecialCharacters:za().bool,htmlAttributes:za().object,link:za().arrayOf(za().object),meta:za().arrayOf(za().object),noscript:za().arrayOf(za().object),onChangeClientState:za().func,script:za().arrayOf(za().object),style:za().arrayOf(za().object),title:za().string,titleAttributes:za().object,titleTemplate:za().string},$a.defaultProps={defer:!0,encodeSpecialCharacters:!0},$a.peek=Fa.peek,$a.rewind=function(){var e=Fa.rewind();return e||(e=Ho({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}})),e},Ba);Wo.renderStatic=Wo.rewind;function Qo({size:e}){const t=(0,o.useStyles2)(Yo);return $i().createElement("img",{className:(0,i.cx)(t.logo,e),src:"public/plugins/grafana-pyroscope-app/img/logo.svg"})}const Ko=$i().memo(Qo),Yo=()=>({logo:i.css` &.small { width: 16px; height: 16px; margin-right: 4px; position: relative; top: -2px; } &.large { width: 40px; height: 40px; } `}),Xo=Di,Jo=`https://github.com/grafana/explore-profiles/commit/${Xo}`,{buildInfo:Zo}=a.config;function es(){const e=(0,o.useStyles2)(rs),{meta:{info:{version:t,updated:n}}}=(0,r.usePluginContext)()||{meta:{info:{version:"?.?.?",updated:"?"}}};return $i().createElement("div",{className:e.menuHeader},$i().createElement("h5",null,$i().createElement(Ko,{size:"small"}),"Grafana Profiles Drilldown v",t),$i().createElement("div",{className:e.subTitle},"Last update: ",n))}function ts(){const e="dev"===Xo,t=e?Xo:Xo.slice(0,8);return $i().createElement(o.Menu,{header:$i().createElement(es,null)},$i().createElement(o.Menu.Item,{label:`Commit SHA: ${t}`,icon:"github",onClick:()=>window.open(Jo),disabled:e}),$i().createElement(o.Menu.Item,{label:"Changelog",icon:"list-ul",onClick:()=>window.open("https://github.com/grafana/explore-profiles/blob/main/CHANGELOG.md")}),$i().createElement(o.Menu.Item,{label:"Contribute",icon:"external-link-alt",onClick:()=>window.open("https://github.com/grafana/explore-profiles/blob/main/docs/CONTRIBUTING.md")}),$i().createElement(o.Menu.Item,{label:"Documentation",icon:"document-info",onClick:()=>window.open("https://grafana.com/docs/grafana/latest/explore/simplified-exploration/profiles")}),$i().createElement(o.Menu.Item,{label:"Report an issue",icon:"bug",onClick:()=>window.open("https://github.com/grafana/explore-profiles/issues/new?template=bug_report.md")}),$i().createElement(o.Menu.Divider,null),$i().createElement(o.Menu.Item,{label:`Grafana ${Zo.edition} v${Zo.version} (${Zo.env})`,icon:"github",onClick:()=>window.open(`https://github.com/grafana/grafana/commit/${Zo.commit}`)}))}function ns(){return $i().createElement(o.Dropdown,{overlay:()=>$i().createElement(ts,null),placement:"bottom-end"},$i().createElement(o.IconButton,{name:"info-circle","aria-label":"Plugin info",title:"Plugin info"}))}const rs=e=>({menuHeader:i.css` padding: ${e.spacing(.5,1)}; white-space: nowrap; `,subTitle:i.css` color: ${e.colors.text.secondary}; font-size: ${e.typography.bodySmall.fontSize}; `});function is({title:e,queryAnalysis:t}){const n=(0,o.useStyles2)(as),r="string"==typeof e?`${e} | Pyroscope`:"Pyroscope";return $i().createElement($i().Fragment,null,$i().createElement(Wo,null,$i().createElement("title",null,r)),$i().createElement("div",{className:n.titleContainer},$i().createElement(o.Stack,{justifyContent:"space-between"},$i().createElement("div",null,$i().createElement(Ko,{size:"large"}),$i().createElement("h1",{className:n.title,"data-testid":"page-title"},e)),$i().createElement("div",{className:n.infoArea},$i().createElement(ns,null),t?$i().createElement(La,{data:t}):null))))}const as=e=>({titleContainer:i.css` height: ${e.spacing(5)}; line-height: ${e.spacing(5)}; margin-bottom: ${e.spacing(3)}; `,title:i.css` font-size: ${e.typography.h2.fontSize}; display: inline-block; margin: 0; position: relative; top: 10px; left: ${e.spacing(1)}; `,infoArea:i.css` align-self: end; margin-bottom: 0; line-height: 20px; text-align: right; `}),os=(0,Fi.memo)(is);function ss(){return $i().createElement(a.PluginPage,{layout:r.PageLayoutType.Canvas},$i().createElement(os,{title:$i().createElement("span",null,"Loading... ",$i().createElement(o.Icon,{name:"fa fa-spinner"}))}))}const ls=e=>({link:i.css` color: ${e.colors.text.link}; &:hover { text-decoration: underline; } `});function cs({href:e,children:t}){const n=(0,o.useStyles2)(ls);return $i().createElement("a",{className:n.link,href:e,target:"_blank",rel:"noreferrer"},t," ",$i().createElement(o.Icon,{name:"external-link-alt"}))}function us(){return $i().createElement(a.PluginPage,{layout:r.PageLayoutType.Canvas},$i().createElement(os,{title:"Grafana Profiles Drilldown"}),$i().createElement(o.Alert,{severity:"error",title:"Missing Pyroscope data source!"},"This plugin requires a Pyroscope data source. Please"," ",$i().createElement(cs,{href:"/connections/datasources/new"},"add and configure a Pyroscope data source")," to your Grafana instance."))}const ds="public/plugins/grafana-pyroscope-app/img/61b4cf746a6f58780f27.png",ps="public/plugins/grafana-pyroscope-app/img/58f0b0e1cfa063e4b662.png",hs="public/plugins/grafana-pyroscope-app/img/9c9cdd5175734d579007.png",fs="public/plugins/grafana-pyroscope-app/img/bafee50693eb02088442.png";function ms(){const{instances:e}=function(){const{isFetching:e,error:t,data:n}=Pa({queryKey:["instances"],queryFn:()=>fetch("/api/plugin-proxy/cloud-home-app/grafanacom-api/instances").then((e=>e.json()))});return{isFetching:e,error:t,instances:n}}(),[t,n]=(0,Fi.useState)("https://grafana.com/auth/sign-in/"),r=/grafana(-dev|-ops)?\.net/.test(window.location.host);if(e&&e.orgSlug&&e.hpInstanceId){const r=`https://grafana.com/orgs/${e.orgSlug}/hosted-profiles/${e.hpInstanceId}`;t!==r&&n(r)}return{data:{settingsUrl:t,isCloud:r},actions:{}}}const gs=e=>({onboardingRow:i.css` background: ${e.colors.background.secondary}; display: flex; margin-top: 16px; gap: 20px; padding: 20px; margin-bottom: 2.5rem; `,onboardingParagraph:i.css` padding: 20px 64px; text-align: center; line-height: 2; flex: 1; margin: 0; `,onboardingPanel:i.css` flex: 1; display: flex; flex-flow: column wrap; -webkit-box-align: center; align-items: center; margin-top: 16px; text-align: center; `,onboardingPanelHeader:i.css` line-height: 1.5; margin-bottom: 1em; `,onboardingPanelImage:i.css` width: 5rem; margin-bottom: 1em; `,hero:i.css` display: flex; flex-direction: row; `,heroTitles:i.css` flex: 1; `,heroImage:i.css` width: 40%; margin-left: 16px; margin-top: 16px; margin-bottom: 16px; border-radius: 3px; `,onboardingPanelNumber:i.css` color: rgb(236, 109, 19); text-align: center; display: grid; place-items: center; background-image: linear-gradient(135deg, currentcolor, 75%, rgb(204, 204, 220)); border-radius: 100%; font-size: 2.5rem; line-height: 5rem; height: 5rem; width: 5rem; margin-bottom: 1em; `,color2:i.css` color: rgb(190, 85, 190); `,color3:i.css` color: rgb(126, 108, 218); `,onboardingPanelNumberSpan:i.css` color: rgb(220, 220, 220); `,onboardingPanelDescription:i.css` text-align: justify; text-align: center; line-height: 1.66; margin-top: 0; `,title:i.css` margin-bottom: 0.5em; line-height: 1.5; `,subtitle:i.css` margin-bottom: 1em; line-height: 1.5; font-size: 1.25rem; `});function ys(){const e=(0,o.useStyles2)(gs),{data:t}=ms();return $i().createElement("div",{"data-testid":"onboarding-modal"},$i().createElement("div",{className:e.hero,"data-testid":"hero"},$i().createElement("div",{className:e.heroTitles},$i().createElement("h1",{className:e.title},"Welcome to Grafana Profiles Drilldown"),$i().createElement("h2",{className:e.subtitle},"Optimize infrastructure spend, simplify debugging, and enhance application performance")),$i().createElement("img",{src:ps,className:e.heroImage})),$i().createElement("div",{"data-testid":"what-you-can-do"},$i().createElement("h3",null,"What You Can Do"),$i().createElement("div",{className:e.onboardingRow},$i().createElement("div",{className:e.onboardingPanel},$i().createElement("img",{className:e.onboardingPanelImage,src:hs}),$i().createElement("h3",{className:e.onboardingPanelHeader},"Reduce Costs"),$i().createElement("p",{className:e.onboardingPanelDescription},"Spot CPU spikes, memory leaks, and other inefficiencies with code-level visibility into resource usage. Teams can then optimize their code and lower infrastructure costs.")),$i().createElement("div",{className:e.onboardingPanel},$i().createElement("img",{className:e.onboardingPanelImage,src:ds}),$i().createElement("h3",{className:e.onboardingPanelHeader},"Decrease Latency"),$i().createElement("p",{className:e.onboardingPanelDescription},"Maintain high speed and efficiency and improve application performance. In a competitive digital world, decreasing latency translates to increasing revenue.")),$i().createElement("div",{className:e.onboardingPanel},$i().createElement("img",{className:e.onboardingPanelImage,src:fs}),$i().createElement("h3",{className:e.onboardingPanelHeader},"Resolve Incidents Faster"),$i().createElement("p",{className:e.onboardingPanelDescription},"Cut down the mean time to resolution (MTTR) by correlating continuous profiling data with metrics, logs, and traces to quickly identify the root cause of any issue.")))),$i().createElement("div",{"data-testid":"how-to-get-started"},$i().createElement("h3",null,"How to Get Started"),$i().createElement("div",{className:e.onboardingRow},t.isCloud?$i().createElement($i().Fragment,null,$i().createElement("div",{className:e.onboardingPanel},$i().createElement("div",{className:e.onboardingPanelNumber},$i().createElement("span",{className:e.onboardingPanelNumberSpan},"1")),$i().createElement("h3",{className:e.onboardingPanelHeader},"Add Profiling to Your Application"),$i().createElement("p",{className:e.onboardingPanelDescription},"Use"," ",$i().createElement(cs,{href:"https://grafana.com/docs/pyroscope/latest/configure-client/grafana-alloy/"},"Grafana Alloy")," ","or"," ",$i().createElement(cs,{href:"https://grafana.com/docs/pyroscope/next/configure-client/language-sdks/"},"Pyroscope SDKs")," ","to push profiles from your applications to Grafana Cloud.")),$i().createElement("div",{className:e.onboardingPanel},$i().createElement("div",{className:(0,i.cx)(e.onboardingPanelNumber,e.color2)},$i().createElement("span",{className:e.onboardingPanelNumberSpan},"2")),$i().createElement("h3",{className:e.onboardingPanelHeader},"Configure Your Applications"),$i().createElement("p",{className:e.onboardingPanelDescription},"Go to ",$i().createElement(cs,{href:t.settingsUrl},"Grafana Cloud Stack settings")," to find your Grafana Cloud Credentials.")),$i().createElement("div",{className:e.onboardingPanel},$i().createElement("div",{className:(0,i.cx)(e.onboardingPanelNumber,e.color3)},$i().createElement("span",{className:e.onboardingPanelNumberSpan},"3")),$i().createElement("h3",{className:e.onboardingPanelHeader},"Start Getting Performance Insights"),$i().createElement("p",{className:e.onboardingPanelDescription},"Once you're done with initial setup, refresh this page to see your profiling data."))):$i().createElement($i().Fragment,null,$i().createElement("div",{className:e.onboardingPanel},$i().createElement("div",{className:e.onboardingPanelNumber},$i().createElement("span",{className:e.onboardingPanelNumberSpan},"1")),$i().createElement("h3",{className:e.onboardingPanelHeader},"Set Up Your Pyroscope Server"),$i().createElement("p",{className:e.onboardingPanelDescription},"Install ",$i().createElement(cs,{href:"https://grafana.com/docs/pyroscope/latest/"},"Pyroscope Server")," on your infrastructure. Or if you want to use a hosted service, go to"," ",$i().createElement(cs,{href:t.settingsUrl},"Grafana Cloud Stack settings")," to find your Grafana Cloud Credentials.")),$i().createElement("div",{className:e.onboardingPanel},$i().createElement("div",{className:(0,i.cx)(e.onboardingPanelNumber,e.color2)},$i().createElement("span",{className:e.onboardingPanelNumberSpan},"2")),$i().createElement("h3",{className:e.onboardingPanelHeader},"Configure Grafana"),$i().createElement("p",{className:e.onboardingPanelDescription},"Add a new ",$i().createElement(cs,{href:"/connections/datasources/new"},"Pyroscope datasource"),". Use your Pyroscope server URL and appropriate security credentials if you use Grafana Cloud Profiles.")),$i().createElement("div",{className:e.onboardingPanel},$i().createElement("div",{className:(0,i.cx)(e.onboardingPanelNumber,e.color3)},$i().createElement("span",{className:e.onboardingPanelNumberSpan},"3")),$i().createElement("h3",{className:e.onboardingPanelHeader},"Add Profiling to Your Application"),$i().createElement("p",{className:e.onboardingPanelDescription},"Use"," ",$i().createElement(cs,{href:"https://grafana.com/docs/pyroscope/latest/configure-client/grafana-alloy/"},"Grafana Alloy")," ","or"," ",$i().createElement(cs,{href:"https://grafana.com/docs/pyroscope/next/configure-client/language-sdks/"},"Pyroscope SDKs")," ","to push profiles from your applications to Grafana Cloud."))))),t.isCloud&&$i().createElement("div",{"data-testid":"how-billing-works"},$i().createElement("h3",null,"How Billing Works"),$i().createElement("div",{className:e.onboardingRow},$i().createElement("p",{className:e.onboardingParagraph},"Usage of Grafana Cloud Profiles is subject to"," ",$i().createElement(cs,{href:"https://grafana.com/pricing/"},"Grafana Cloud Pricing")," for Profiles.",$i().createElement("br",null),"For additional information, read the announcement ",$i().createElement(cs,{href:"https://grafana.com/blog/2023/08/09/grafana-cloud-profiles-for-continuous-profiling/"},"blog post"),"."))))}const bs=e=>({onboardingPage:i.css` padding: 16px; margin: 64px; position: relative; background-color: ${e.colors.background.primary}; `,closeButton:i.css` position: absolute; top: -30px; opacity: 0.8; right: -32px; border: none; border-radius: 50%; width: 40px; height: 40px; line-height: 40px; display: block; padding: 0; margin: 0; font-size: 22px; `}),vs={text:"Onboarding"};function ws({onCloseModal:e}){const t=(0,o.useStyles2)(bs);return $i().createElement(a.PluginPage,{pageNav:vs,layout:r.PageLayoutType.Custom},$i().createElement("div",{className:t.onboardingPage},$i().createElement("button",{className:t.closeButton,onClick:e,title:"Close","data-testid":"close-onboarding-modal"},"×"),$i().createElement(ys,null)))}function Ss({children:e}){const{data:t,actions:n}=Da();return t.shouldShowLoadingPage?$i().createElement(ss,null):t.shouldShowOnboardingPage?$i().createElement(ws,{onCloseModal:n.closeModal}):t.shouldShowNoDataSourceBanner?$i().createElement(us,null):$i().createElement($i().Fragment,null,e)}var Es=__webpack_require__(1159);const xs=Ai.EXPLORE.slice(1);function Os(){const{pathname:e}=new URL(window.location.toString());return e.split("/").pop()||""}function _s(){const e={appRelease:a.config.apps[Pi].version,appVersion:Di,page:Os()};return e.page===xs&&(e.view=new URLSearchParams(window.location.search).get("explorationType")||""),e}function Ts(e,t){(0,a.reportInteraction)(e,{props:t,meta:_s()})}function Cs(e){const[t,n]=(0,Fi.useState)(!1);(0,Fi.useEffect)((()=>{t||(n(!0),Ts("g_pyroscope_app_page_initialized",{page:e}))}),[e,t])}const ks=e=>({container:i.css` display: flex; justify-content: space-between; align-items: flex-start; gap: ${e.spacing(1)}; width: 100%; `,column:i.css` width: 50%; `});function Ps({left:e,right:t}){const n=(0,o.useStyles2)(ks);return $i().createElement("div",{className:n.container},$i().createElement("div",{className:n.column},e),$i().createElement("div",{className:n.column},t))}function Rs(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function As(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function Ds(e,t){const n=t.reduce(((e,t,n)=>As(function(e){for(var t=1;t{const r=new FileReader;r.addEventListener("load",(()=>{try{t(function(e){const[,t]=e.split(";base64,");if(!t)throw new Error("No content after stripping the base64 prefix.");if(e===t)throw new Error("No base64 prefix?!");return t}(r.result))}catch(e){n(e)}})),r.addEventListener("error",(()=>{n(new Error(`Error while reading file "${e.name}"!`))})),r.readAsDataURL(e)}))}))()}};function Fs(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function $s(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Fs(a,r,i,o,s,"next",e)}function s(e){Fs(a,r,i,o,s,"throw",e)}o(void 0)}))}}function Bs(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Vs(e){for(var t=1;t()=>{Ms.abort()}),[]);const i=(0,Fi.useCallback)((()=>{Ms.abort(),t(!1),r(Us)}),[]),a=(0,Fi.useCallback)(function(){var e=$s((function*(e){i();try{t(!0);const n=yield Ms.uploadSingle(e);r(n)}catch(e){r(Us),Ms.isAbortError(e)||Ds(e,["Error while uploading profile!",e.message])}t(!1)}));return function(t){return e.apply(this,arguments)}}(),[i]),o=(0,Fi.useCallback)(function(){var e=$s((function*(e){const i=e.value;if(i&&n.id&&n.profileTypes.includes(i)){Ms.abort(),t(!1),r((e=>zs(Vs({},e),{profile:null}))),t(!0);try{const e=yield Ms.get(n.id,i);r((t=>zs(Vs({},t),{profile:e.profile})))}catch(e){Ms.isAbortError(e)||Ds(e,["Error while fetching profile!",e.message])}t(!1)}}));return function(t){return e.apply(this,arguments)}}(),[n.id,n.profileTypes]);return{processFile:a,profileTypes:n.profileTypes,selectProfileType:o,profile:n.profile,removeFile:i,isLoading:e}}function Hs(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Gs(e){for(var t=1;te>t?1:ee.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Zs="eexxaacctt",el=/\p{P}/gu,tl=["en",{numeric:!0,sensitivity:"base"}],nl=(e,t,n)=>e.replace("A-Z",t).replace("a-z",n),rl={unicode:!1,alpha:null,interSplit:"[^A-Za-z\\d']+",intraSplit:"[a-z][A-Z]",interBound:"[^A-Za-z\\d]",intraBound:"[A-Za-z]\\d|\\d[A-Za-z]|[a-z][A-Z]",interLft:0,interRgt:0,interChars:".",interIns:Xs,intraChars:"[a-z\\d']",intraIns:null,intraContr:"'[a-z]{1,2}\\b",intraMode:0,intraSlice:[1,Xs],intraSub:null,intraTrn:null,intraDel:null,intraFilt:(e,t,n)=>!0,toUpper:e=>e.toLocaleUpperCase(),toLower:e=>e.toLocaleLowerCase(),compare:null,sort:(e,t,n,r=Ys)=>{let{idx:i,chars:a,terms:o,interLft2:s,interLft1:l,start:c,intraIns:u,interIns:d,cases:p}=e;return i.map(((e,t)=>t)).sort(((e,n)=>a[n]-a[e]||u[e]-u[n]||o[n]+s[n]+.5*l[n]-(o[e]+s[e]+.5*l[e])||d[e]-d[n]||c[e]-c[n]||p[n]-p[e]||r(t[i[e]],t[i[n]])))}},il=(e,t)=>0==t?"":1==t?e+"??":t==Xs?e+"*?":e+`{0,${t}}?`,al="(?:\\b|_)";function ol(e){e=Object.assign({},rl,e);let{unicode:t,interLft:n,interRgt:r,intraMode:i,intraSlice:a,intraIns:o,intraSub:s,intraTrn:l,intraDel:c,intraContr:u,intraSplit:d,interSplit:p,intraBound:h,interBound:f,intraChars:m,toUpper:g,toLower:y,compare:b}=e;o??=i,s??=i,l??=i,c??=i,b??="undefined"==typeof Intl?Ys:new Intl.Collator(...tl).compare;let v=e.letters??e.alpha;if(null!=v){let e=g(v),t=y(v);p=nl(p,e,t),d=nl(d,e,t),f=nl(f,e,t),h=nl(h,e,t),m=nl(m,e,t),u=nl(u,e,t)}let w=t?"u":"";const S='".+?"',E=new RegExp(S,"gi"+w),x=new RegExp(`(?:\\s+|^)-(?:${m}+|${S})`,"gi"+w);let{intraRules:O}=e;null==O&&(O=e=>{let t=rl.intraSlice,n=0,r=0,i=0,u=0;if(/[^\d]/.test(e)){let d=e.length;d<=4?d>=3&&(i=Math.min(l,1),4==d&&(n=Math.min(o,1))):(t=a,n=o,r=s,i=l,u=c)}return{intraSlice:t,intraIns:n,intraSub:r,intraTrn:i,intraDel:u}});let _=!!d,T=new RegExp(d,"g"+w),C=new RegExp(p,"g"+w),k=new RegExp("^"+p+"|"+p+"$","g"+w),P=new RegExp(u,"gi"+w);const R=(e,t=!1)=>{let n=[];e=e.replace(E,(e=>(n.push(e),Zs))),e=e.replace(k,""),t||(e=y(e)),_&&(e=e.replace(T,(e=>e[0]+" "+e[1])));let r=0;return e.split(C).filter((e=>""!=e)).map((e=>e===Zs?n[r++]:e))},A=/[^\d]+|\d+/g,D=(t,a=0,s=!1)=>{let l=R(t);if(0==l.length)return[];let c,u=Array(l.length).fill("");if(l=l.map(((e,t)=>e.replace(P,(e=>(u[t]=e,""))))),1==i)c=l.map(((e,t)=>{if('"'===e[0])return Js(e.slice(1,-1));let n="";for(let r of e.matchAll(A)){let e=r[0],{intraSlice:i,intraIns:a,intraSub:o,intraTrn:s,intraDel:l}=O(e);if(a+o+s+l==0)n+=e+u[t];else{let[r,c]=i,d=e.slice(0,r),p=e.slice(c),h=e.slice(r,c);1==a&&1==d.length&&d!=h[0]&&(d+="(?!"+d+")");let f=h.length,g=[e];if(o)for(let e=0;e0&&(e=")("+e+")("),c=l.map(((t,n)=>'"'===t[0]?Js(t.slice(1,-1)):t.split("").map(((e,t,n)=>(1==o&&0==t&&n.length>1&&e!=n[t+1]&&(e+="(?!"+e+")"),e))).join(e)+u[n]))}let d=2==n?al:"",p=2==r?al:"",h=p+il(e.interChars,e.interIns)+d;return a>0?s?c=d+"("+c.join(")"+p+"|"+d+"(")+")"+p:(c="("+c.join(")("+h+")(")+")",c="(.??"+d+")"+c+"("+p+".*)"):(c=c.join(h),c=d+c+p),[new RegExp(c,"i"+w),l,u]},j=(e,t,n)=>{let[r]=D(t);if(null==r)return null;let i=[];if(null!=n)for(let t=0;t{let[o,s,l]=D(a,1),c=R(a,!0),[u]=D(a,2),d=s.length,p=Array(d),h=Array(d);for(let e=0;e=g){let e=y(l[i+1]).indexOf(o);e>-1&&(R.push(f,v,e,g),f+=F(l,i,e,g),a=o,v=g,A=!0,0==t&&(c=f))}if(b||A){let e=f-1,u=f+v,d=!1,p=!1;if(-1==e||N.test(s[e]))A&&S++,d=!0;else{if(2==n){m=!0;break}if(I&&L.test(s[e]+s[e+1]))A&&E++,d=!0;else if(1==n){let e=l[i+1],n=f+v;if(e.length>=g){let r,u=0,p=!1,h=new RegExp(o,"ig"+w);for(;r=h.exec(e);){u=r.index;let e=n+u,t=e-1;if(-1==t||N.test(s[t])){S++,p=!0;break}if(L.test(s[t]+s[e])){E++,p=!0;break}}p&&(d=!0,R.push(f,v,u,g),f+=F(l,i,u,g),a=o,v=g,A=!0,0==t&&(c=f))}if(!d){m=!0;break}}}if(u==s.length||N.test(s[u]))A&&x++,p=!0;else{if(2==r){m=!0;break}if(I&&L.test(s[u-1]+s[u]))A&&O++,p=!0;else if(1==r){m=!0;break}}A&&(_+=g,d&&p&&T++)}if(v>g&&(P+=v-g),t>0&&(k+=l[i-1].length),!e.intraFilt(o,a,f)){m=!0;break}t0?0:1/0,o=r-4;for(let t=2;t0&&(l.push(d,p),d=p=n)}p>d&&l.push(d,p),v++}}if(v{let i=e[t]+e[t+1].slice(0,n);return e[t-1]+=i,e[t]=e[t+1].slice(n,n+r),e[t+1]=e[t+1].slice(n+r),i.length};return{search:(...t)=>{let n=((t,n,r,i=1e3,a)=>{r=r?!0===r?5:r:0;let o=null,s=null,l=[];n=n.replace(x,(e=>{let t=e.trim().slice(1);return t='"'===t[0]?Js(t.slice(1,-1)):t.replace(el,""),""!=t&&l.push(t),""}));let c,u=R(n);if(l.length>0){if(c=new RegExp(l.join("|"),"i"+w),0==u.length){let e=[];for(let n=0;n0){let e=R(n);if(e.length>1){let n=e.slice().sort(((e,t)=>t.length-e.length));for(let e=0;er)return[a,null,null];o=ll(e).map((e=>e.join(" "))),s=[];let i=new Set;for(let e=0;e!i.has(e))),r=j(t,o[e],n);for(let e=0;e0?a:j(t,n)]);let d=null,p=null;if(l.length>0&&(s=s.map((e=>e.filter((e=>!c.test(t[e])))))),s.reduce(((e,t)=>e+t.length),0)<=i){d={},p=[];for(let n=0;n0)for(let e=0;e{let e={A:"ÁÀÃÂÄĄ",a:"áàãâäą",E:"ÉÈÊËĖ",e:"éèêëę",I:"ÍÌÎÏĮ",i:"íìîïį",O:"ÓÒÔÕÖ",o:"óòôõö",U:"ÚÙÛÜŪŲ",u:"úùûüūų",C:"ÇČĆ",c:"çčć",L:"Ł",l:"ł",N:"ÑŃ",n:"ñń",S:"ŠŚ",s:"šś",Z:"ŻŹ",z:"żź"},t=new Map,n="";for(let r in e)e[r].split("").forEach((e=>{n+=e,t.set(e,r)}));let r=new RegExp(`[${n}]`,"g"),i=e=>t.get(e);return e=>{if("string"==typeof e)return e.replace(r,i);let t=Array(e.length);for(let n=0;nt?`${e}`:e,ul=(e,t)=>e+t;ol.latinize=sl,ol.permute=e=>{let t=ll([...Array(e.length).keys()]).sort(((e,t)=>{for(let n=0;nt.map((t=>e[t]))))},ol.highlight=function(e,t,n=cl,r="",i=ul){r=i(r,n(e.substring(0,t[0]),!1))??r;for(let a=0;a(0,Bi.jsx)("div",{"data-testid":"contextMenu",children:(0,Bi.jsx)(o.ContextMenu,{renderMenuItems:function(){const y=(null==d?void 0:d(t,e.data,{selectedView:m,isDiff:e.isDiffFlamegraph(),search:g,collapseConfig:a}))||[];return(0,Bi.jsxs)(Bi.Fragment,{children:[(0,Bi.jsx)(o.MenuItem,{label:"Focus block",icon:"eye",onClick:()=>{r(),n()}}),(0,Bi.jsx)(o.MenuItem,{label:"Copy function name",icon:"copy",onClick:()=>{navigator.clipboard.writeText(t.label).then((()=>{n()}))}}),(0,Bi.jsx)(o.MenuItem,{label:"Sandwich view",icon:"gf-show-context",onClick:()=>{i(),n()}}),y.map((({label:e,icon:t,onClick:n})=>(0,Bi.jsx)(o.MenuItem,{label:e,icon:t,onClick:()=>n()},e))),p&&(0,Bi.jsxs)(o.MenuGroup,{label:"Grouping",children:[a?a.collapsed?(0,Bi.jsx)(o.MenuItem,{label:"Expand group",icon:"angle-double-down",onClick:()=>{s(),n()}}):(0,Bi.jsx)(o.MenuItem,{label:"Collapse group",icon:"angle-double-up",onClick:()=>{l(),n()}}):null,!h&&(0,Bi.jsx)(o.MenuItem,{label:"Expand all groups",icon:"angle-double-down",onClick:()=>{c(),n()}}),!f&&(0,Bi.jsx)(o.MenuItem,{label:"Collapse all groups",icon:"angle-double-up",onClick:()=>{u(),n()}})]})]})},x:t.posX+10,y:t.posY,focusOnOpen:!1})}),kl=({data:e,item:t,totalTicks:n,position:r,collapseConfig:i})=>{const a=(0,o.useStyles2)(Dl);if(!t||!r)return null;let s;if(e.isDiffFlamegraph()){const r=Rl(e,t,n);s=(0,Bi.jsx)(o.InteractiveTable,{className:a.tooltipTable,columns:[{id:"label",header:""},{id:"baseline",header:"Baseline"},{id:"comparison",header:"Comparison"},{id:"diff",header:"Diff"}],data:r,getRowId:e=>e.rowId})}else{const r=Pl(e,t,n);s=(0,Bi.jsxs)("p",{className:a.lastParagraph,children:[r.unitTitle,(0,Bi.jsx)("br",{}),"Total: ",(0,Bi.jsx)("b",{children:r.unitValue})," (",r.percentValue,"%)",(0,Bi.jsx)("br",{}),"Self: ",(0,Bi.jsx)("b",{children:r.unitSelf})," (",r.percentSelf,"%)",(0,Bi.jsx)("br",{}),"Samples: ",(0,Bi.jsx)("b",{children:r.samples})]})}return(0,Bi.jsx)(o.Portal,{children:(0,Bi.jsx)(o.VizTooltipContainer,{className:a.tooltipContainer,position:r,offset:{x:15,y:0},children:(0,Bi.jsxs)("div",{className:a.tooltipContent,children:[(0,Bi.jsxs)("p",{className:a.tooltipName,children:[e.getLabel(t.itemIndexes[0]),i&&i.collapsed?(0,Bi.jsxs)("span",{children:[(0,Bi.jsx)("br",{}),"and ",i.items.length," similar items"]}):""]}),s]})})})},Pl=(e,t,n)=>{const r=e.valueDisplayProcessor(t.value),i=e.getSelfDisplay(t.itemIndexes),a=Math.round(r.numeric/n*1e4)/100,o=Math.round(i.numeric/n*1e4)/100;let s=r.text+r.suffix,l=i.text+i.suffix;const c=e.getUnitTitle();return"Count"===c&&(r.suffix||(s=r.text),i.suffix||(l=i.text)),{percentValue:a,percentSelf:o,unitTitle:c,unitValue:s,unitSelf:l,samples:r.numeric.toLocaleString()}},Rl=(e,t,n)=>{const i=e.getLevels()[0][0].valueRight,a=n-i,o=t.value-t.valueRight,s=Math.round(1e4*o/a)/100,l=Math.round(1e4*t.valueRight/i)/100,c=(l-s)/s*100,u=Al(e,e.valueDisplayProcessor(o)),d=Al(e,e.valueDisplayProcessor(t.valueRight)),p=(0,r.getValueFormat)("short");return[{rowId:"1",label:"% of total",baseline:s+"%",comparison:l+"%",diff:p(c).text+"%"},{rowId:"2",label:"Value",baseline:u,comparison:d,diff:Al(e,e.valueDisplayProcessor(t.valueRight-o))},{rowId:"3",label:"Samples",baseline:p(o).text,comparison:p(t.valueRight).text,diff:p(t.valueRight-o).text}]};function Al(e,t){let n=t.text+t.suffix;return"Count"===e.getUnitTitle()&&(t.suffix||(n=t.text)),n}const Dl=e=>({tooltipContainer:(0,i.css)({title:"tooltipContainer",overflow:"hidden"}),tooltipContent:(0,i.css)({title:"tooltipContent",fontSize:e.typography.bodySmall.fontSize,width:"100%"}),tooltipName:(0,i.css)({title:"tooltipName",marginTop:0,wordBreak:"break-all"}),lastParagraph:(0,i.css)({title:"lastParagraph",marginBottom:0}),name:(0,i.css)({title:"name",marginBottom:"10px"}),tooltipTable:(0,i.css)({title:"tooltipTable",maxWidth:"400px"})});function jl(e){return jl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},jl(e)}var Il=/^\s+/,Nl=/\s+$/;function Ll(e,t){if(t=t||{},(e=e||"")instanceof Ll)return e;if(!(this instanceof Ll))return new Ll(e,t);var n=function(e){var t={r:0,g:0,b:0},n=1,r=null,i=null,a=null,o=!1,s=!1;"string"==typeof e&&(e=function(e){e=e.replace(Il,"").replace(Nl,"").toLowerCase();var t,n=!1;if(Zl[e])e=Zl[e],n=!0;else if("transparent"==e)return{r:0,g:0,b:0,a:0,format:"name"};if(t=pc.rgb.exec(e))return{r:t[1],g:t[2],b:t[3]};if(t=pc.rgba.exec(e))return{r:t[1],g:t[2],b:t[3],a:t[4]};if(t=pc.hsl.exec(e))return{h:t[1],s:t[2],l:t[3]};if(t=pc.hsla.exec(e))return{h:t[1],s:t[2],l:t[3],a:t[4]};if(t=pc.hsv.exec(e))return{h:t[1],s:t[2],v:t[3]};if(t=pc.hsva.exec(e))return{h:t[1],s:t[2],v:t[3],a:t[4]};if(t=pc.hex8.exec(e))return{r:ic(t[1]),g:ic(t[2]),b:ic(t[3]),a:lc(t[4]),format:n?"name":"hex8"};if(t=pc.hex6.exec(e))return{r:ic(t[1]),g:ic(t[2]),b:ic(t[3]),format:n?"name":"hex"};if(t=pc.hex4.exec(e))return{r:ic(t[1]+""+t[1]),g:ic(t[2]+""+t[2]),b:ic(t[3]+""+t[3]),a:lc(t[4]+""+t[4]),format:n?"name":"hex8"};if(t=pc.hex3.exec(e))return{r:ic(t[1]+""+t[1]),g:ic(t[2]+""+t[2]),b:ic(t[3]+""+t[3]),format:n?"name":"hex"};return!1}(e));"object"==jl(e)&&(hc(e.r)&&hc(e.g)&&hc(e.b)?(t=function(e,t,n){return{r:255*nc(e,255),g:255*nc(t,255),b:255*nc(n,255)}}(e.r,e.g,e.b),o=!0,s="%"===String(e.r).substr(-1)?"prgb":"rgb"):hc(e.h)&&hc(e.s)&&hc(e.v)?(r=oc(e.s),i=oc(e.v),t=function(e,t,n){e=6*nc(e,360),t=nc(t,100),n=nc(n,100);var r=Math.floor(e),i=e-r,a=n*(1-t),o=n*(1-i*t),s=n*(1-(1-i)*t),l=r%6,c=[n,o,a,a,s,n][l],u=[s,n,n,o,a,a][l],d=[a,a,s,n,n,o][l];return{r:255*c,g:255*u,b:255*d}}(e.h,r,i),o=!0,s="hsv"):hc(e.h)&&hc(e.s)&&hc(e.l)&&(r=oc(e.s),a=oc(e.l),t=function(e,t,n){var r,i,a;function o(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(e=nc(e,360),t=nc(t,100),n=nc(n,100),0===t)r=i=a=n;else{var s=n<.5?n*(1+t):n+t-n*t,l=2*n-s;r=o(l,s,e+1/3),i=o(l,s,e),a=o(l,s,e-1/3)}return{r:255*r,g:255*i,b:255*a}}(e.h,r,a),o=!0,s="hsl"),e.hasOwnProperty("a")&&(n=e.a));return n=tc(n),{ok:o,format:e.format||s,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:n}}(e);this._originalInput=e,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||n.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=n.ok}function Ml(e,t,n){e=nc(e,255),t=nc(t,255),n=nc(n,255);var r,i,a=Math.max(e,t,n),o=Math.min(e,t,n),s=(a+o)/2;if(a==o)r=i=0;else{var l=a-o;switch(i=s>.5?l/(2-a-o):l/(a+o),a){case e:r=(t-n)/l+(t>1)+720)%360;--t;)r.h=(r.h+i)%360,a.push(Ll(r));return a}function Jl(e,t){t=t||6;for(var n=Ll(e).toHsv(),r=n.h,i=n.s,a=n.v,o=[],s=1/t;t--;)o.push(Ll({h:r,s:i,v:a})),a=(a+s)%1;return o}Ll.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},getLuminance:function(){var e,t,n,r=this.toRgb();return e=r.r/255,t=r.g/255,n=r.b/255,.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))},setAlpha:function(e){return this._a=tc(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=Fl(this._r,this._g,this._b);return{h:360*e.h,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=Fl(this._r,this._g,this._b),t=Math.round(360*e.h),n=Math.round(100*e.s),r=Math.round(100*e.v);return 1==this._a?"hsv("+t+", "+n+"%, "+r+"%)":"hsva("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=Ml(this._r,this._g,this._b);return{h:360*e.h,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=Ml(this._r,this._g,this._b),t=Math.round(360*e.h),n=Math.round(100*e.s),r=Math.round(100*e.l);return 1==this._a?"hsl("+t+", "+n+"%, "+r+"%)":"hsla("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return $l(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return function(e,t,n,r,i){var a=[ac(Math.round(e).toString(16)),ac(Math.round(t).toString(16)),ac(Math.round(n).toString(16)),ac(sc(r))];if(i&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)&&a[3].charAt(0)==a[3].charAt(1))return a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0);return a.join("")}(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*nc(this._r,255))+"%",g:Math.round(100*nc(this._g,255))+"%",b:Math.round(100*nc(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*nc(this._r,255))+"%, "+Math.round(100*nc(this._g,255))+"%, "+Math.round(100*nc(this._b,255))+"%)":"rgba("+Math.round(100*nc(this._r,255))+"%, "+Math.round(100*nc(this._g,255))+"%, "+Math.round(100*nc(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(ec[$l(this._r,this._g,this._b,!0)]||!1)},toFilter:function(e){var t="#"+Bl(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var i=Ll(e);n="#"+Bl(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+n+")"},toString:function(e){var t=!!e;e=e||this._format;var n=!1,r=this._a<1&&this._a>=0;return t||!r||"hex"!==e&&"hex6"!==e&&"hex3"!==e&&"hex4"!==e&&"hex8"!==e&&"name"!==e?("rgb"===e&&(n=this.toRgbString()),"prgb"===e&&(n=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(n=this.toHexString()),"hex3"===e&&(n=this.toHexString(!0)),"hex4"===e&&(n=this.toHex8String(!0)),"hex8"===e&&(n=this.toHex8String()),"name"===e&&(n=this.toName()),"hsl"===e&&(n=this.toHslString()),"hsv"===e&&(n=this.toHsvString()),n||this.toHexString()):"name"===e&&0===this._a?this.toName():this.toRgbString()},clone:function(){return Ll(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(ql,arguments)},brighten:function(){return this._applyModification(Hl,arguments)},darken:function(){return this._applyModification(Gl,arguments)},desaturate:function(){return this._applyModification(Vl,arguments)},saturate:function(){return this._applyModification(zl,arguments)},greyscale:function(){return this._applyModification(Ul,arguments)},spin:function(){return this._applyModification(Wl,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(Xl,arguments)},complement:function(){return this._applyCombination(Ql,arguments)},monochromatic:function(){return this._applyCombination(Jl,arguments)},splitcomplement:function(){return this._applyCombination(Yl,arguments)},triad:function(){return this._applyCombination(Kl,[3])},tetrad:function(){return this._applyCombination(Kl,[4])}},Ll.fromRatio=function(e,t){if("object"==jl(e)){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]="a"===r?e[r]:oc(e[r]));e=n}return Ll(e,t)},Ll.equals=function(e,t){return!(!e||!t)&&Ll(e).toRgbString()==Ll(t).toRgbString()},Ll.random=function(){return Ll.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},Ll.mix=function(e,t,n){n=0===n?0:n||50;var r=Ll(e).toRgb(),i=Ll(t).toRgb(),a=n/100;return Ll({r:(i.r-r.r)*a+r.r,g:(i.g-r.g)*a+r.g,b:(i.b-r.b)*a+r.b,a:(i.a-r.a)*a+r.a})},Ll.readability=function(e,t){var n=Ll(e),r=Ll(t);return(Math.max(n.getLuminance(),r.getLuminance())+.05)/(Math.min(n.getLuminance(),r.getLuminance())+.05)},Ll.isReadable=function(e,t,n){var r,i,a=Ll.readability(e,t);switch(i=!1,(r=function(e){var t,n;t=((e=e||{level:"AA",size:"small"}).level||"AA").toUpperCase(),n=(e.size||"small").toLowerCase(),"AA"!==t&&"AAA"!==t&&(t="AA");"small"!==n&&"large"!==n&&(n="small");return{level:t,size:n}}(n)).level+r.size){case"AAsmall":case"AAAlarge":i=a>=4.5;break;case"AAlarge":i=a>=3;break;case"AAAsmall":i=a>=7}return i},Ll.mostReadable=function(e,t,n){var r,i,a,o,s=null,l=0;i=(n=n||{}).includeFallbackColors,a=n.level,o=n.size;for(var c=0;cl&&(l=r,s=Ll(t[c]));return Ll.isReadable(e,s,{level:a,size:o})||!i?s:(n.includeFallbackColors=!1,Ll.mostReadable(e,["#fff","#000"],n))};var Zl=Ll.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},ec=Ll.hexNames=function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[e[n]]=n);return t}(Zl);function tc(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function nc(e,t){(function(e){return"string"==typeof e&&-1!=e.indexOf(".")&&1===parseFloat(e)})(e)&&(e="100%");var n=function(e){return"string"==typeof e&&-1!=e.indexOf("%")}(e);return e=Math.min(t,Math.max(0,parseFloat(e))),n&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function rc(e){return Math.min(1,Math.max(0,e))}function ic(e){return parseInt(e,16)}function ac(e){return 1==e.length?"0"+e:""+e}function oc(e){return e<=1&&(e=100*e+"%"),e}function sc(e){return Math.round(255*parseFloat(e)).toString(16)}function lc(e){return ic(e)/255}var cc,uc,dc,pc=(uc="[\\s|\\(]+("+(cc="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+cc+")[,|\\s]+("+cc+")\\s*\\)?",dc="[\\s|\\(]+("+cc+")[,|\\s]+("+cc+")[,|\\s]+("+cc+")[,|\\s]+("+cc+")\\s*\\)?",{CSS_UNIT:new RegExp(cc),rgb:new RegExp("rgb"+uc),rgba:new RegExp("rgba"+dc),hsl:new RegExp("hsl"+uc),hsla:new RegExp("hsla"+dc),hsv:new RegExp("hsv"+uc),hsva:new RegExp("hsva"+dc),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function hc(e){return!!pc.CSS_UNIT.exec(e)}var fc=(e=>(e.Bytes="bytes",e.Short="short",e.Nanoseconds="ns",e))(fc||{}),mc=(e=>(e.TopTable="topTable",e.FlameGraph="flameGraph",e.Both="both",e))(mc||{}),gc=(e=>(e.ValueBased="valueBased",e.PackageBased="packageBased",e))(gc||{}),yc=(e=>(e.Default="default",e.DiffColorBlind="diffColorBlind",e))(yc||{}),bc=__webpack_require__(4201);const vc=[Ll({h:24,s:69,l:60}),Ll({h:34,s:65,l:65}),Ll({h:194,s:52,l:61}),Ll({h:163,s:45,l:55}),Ll({h:211,s:48,l:60}),Ll({h:246,s:40,l:65}),Ll({h:305,s:63,l:79}),Ll({h:47,s:100,l:73}),Ll({r:183,g:219,b:171}),Ll({r:244,g:213,b:152}),Ll({r:78,g:146,b:249}),Ll({r:249,g:186,b:143}),Ll({r:242,g:145,b:145}),Ll({r:130,g:181,b:216}),Ll({r:229,g:168,b:226}),Ll({r:174,g:162,b:224}),Ll({r:154,g:196,b:138}),Ll({r:242,g:201,b:109}),Ll({r:101,g:197,b:219}),Ll({r:249,g:147,b:78}),Ll({r:234,g:100,b:96}),Ll({r:81,g:149,b:206}),Ll({r:214,g:131,b:206}),Ll({r:128,g:110,b:183})],wc=`linear-gradient(90deg, ${Ec(1,100,0,1)} 0%, ${Ec(100,100,0,1)} 100%)`,Sc=`linear-gradient(90deg, ${vc[0]} 0%, ${vc[2]} 30%, ${vc[6]} 50%, ${vc[7]} 70%, ${vc[8]} 100%)`;function Ec(e,t,n,r){const i=Math.min(1,e/t/(r-n));return Ll({h:50-50*i,s:100,l:65+7*i})}function xc(e,t){const n=function(e){var t;for(const[n,r]of kc){const n=e.match(r);if(n)return(null==(t=n.groups)?void 0:t.packageName)||""}return}(e),r=function(e,t=0){let n,r,i,a,o,s,l,c;for(n=3&e.length,r=e.length-n,i=t,o=3432918353,s=461845907,c=0;c>>16)*o&65535)<<16)&4294967295,l=l<<15|l>>>17,l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295,i^=l,i=i<<13|i>>>19,a=5*(65535&i)+((5*(i>>>16)&65535)<<16)&4294967295,i=27492+(65535&a)+((58964+(a>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:l^=255&e.charCodeAt(c);default:l=(65535&l)*o+(((l>>>16)*o&65535)<<16)&4294967295,l=l<<15|l>>>17,l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295,i^=l}return i^=e.length,i^=i>>>16,i=2246822507*(65535&i)+((2246822507*(i>>>16)&65535)<<16)&4294967295,i^=i>>>13,i=3266489909*(65535&i)+((3266489909*(i>>>16)&65535)<<16)&4294967295,i^=i>>>16,i>>>0}(n||"",0),i=r%vc.length;let a=vc[i].clone();return t.isLight&&(a=a.brighten(15)),a}const Oc=["rgb(0, 170, 0)","rgb(148, 142, 142)","rgb(200, 0, 0)"],_c=`linear-gradient(90deg, ${Oc[0]} 0%, ${Oc[1]} 50%, ${Oc[2]} 100%)`,Tc=["rgb(26, 133, 255)","rgb(148, 142, 142)","rgb(220, 50, 32)"],Cc=`linear-gradient(90deg, ${Tc[0]} 0%, ${Tc[1]} 50%, ${Tc[2]} 100%)`;const kc=[["phpspy",/^(?([^\/]*\/)*)(?.*\.php+)(?.*)$/],["pyspy",/^(?([^\/]*\/)*)(?.*\.py+)(?.*)$/],["rbspy",/^(?([^\/]*\/)*)(?.*\.rb+)(?.*)$/],["nodespy",/^(\.\/node_modules\/)?(?[^/]*)(?.*\.?(jsx?|tsx?)?):(?.*):(?.*)$/],["gospy",/^(?.*?\/.*?\.|.*?\.|.+)(?.*)$/],["javaspy",/^(?.+\/)(?.+\.)(?.+)$/],["dotnetspy",/^(?.+)\.(.+)\.(.+)\(.*\)$/],["tracing",/^(?.+?):.*$/],["pyroscope-rs",/^(?[^::]+)/],["ebpfspy",/^(?.+)$/],["unknown",/^(?.+)$/]];function Pc(e){const{canvasRef:t,data:n,root:r,depth:i,direction:a,wrapperWidth:s,rangeMin:l,rangeMax:c,matchedLabels:u,textAlign:d,totalViewTicks:p,totalColorTicks:h,totalTicksRight:f,colorScheme:m,focusedItemData:g,collapsedMap:y}=e,b=function(e,t,n){const[r,i]=(0,Fi.useState)();return(0,Fi.useEffect)((()=>{if(!n||!e.current)return;const r=e.current.getContext("2d"),a=gl*n;e.current.width=Math.round(t*window.devicePixelRatio),e.current.height=Math.round(a),e.current.style.width=`${t}px`,e.current.style.height=a/window.devicePixelRatio+"px",r.textBaseline="middle",r.font=12*window.devicePixelRatio+"px monospace",r.strokeStyle="white",i(r)}),[e,i,t,n]),r}(t,s,i),v=(0,o.useTheme2)(),w=(0,Fi.useMemo)((()=>{const e=Ll(v.colors.background.secondary);return v.isLight?e.darken(10).toHexString():e.lighten(10).toHexString()}),[v]),S=function(e,t,n,r,i,a,o,s,l){return(0,Fi.useCallback)((function(c,u,d){if(d&&!s)return i;const p=void 0===c.valueRight||n!==yc.Default&&n!==yc.DiffColorBlind?n===gc.ValueBased?Ec(c.value,e,a,o):xc(u,r):function(e,t,n,r,i){const a=i===yc.Default?Oc:Tc,o=(0,bc.scaleLinear)().domain([-100,0,100]).range(a),s=e-t,l=n-r;if(0===r||0===l)return Ll(o(0));const c=Math.round(1e4*s/l)/100;return Ll(o((Math.round(1e4*t/r)/100-c)/c*100))}(c.value,c.valueRight,e,t,n);return s?s.has(u)?p.toHslString():i:c.level>l-1?p.toHslString():p.lighten(15).toHslString()}),[e,t,n,r,a,o,s,l,i])}(h,f,m,v,w,l,c,u,g?g.item.level:0),E=function(e,t,n,r,i){return(0,Fi.useMemo)((()=>{if(!e)return()=>{};const a=(a,o,s,l,c,u)=>{e.beginPath(),e.rect(o+wl,s,l,c),e.fillStyle=n(a,u,!1),e.stroke(),e.fill();const d=i.get(a);let p=u;if(d&&d.collapsed){p=`(${d.items.length}) `+u}l>=vl&&(d?(Rc(e,t,p,a,l,"left"===r?o+Ol+_l:o,s,r),function(e,t,n,r,i,a){const o=t+Ol;e.beginPath(),e.rect(t,n,o-t+El+xl,r),e.fill(),e.beginPath(),a.collapsed?e.rect(o,n+r/4,El,r/2):a.items[0]===i?e.rect(o,n+r/2,El,r/2):a.items[a.items.length-1]===i?e.rect(o,n,El,r/2):e.rect(o,n,El,r);e.fillStyle="#666",e.fill()}(e,o,s,c,a,d)):Rc(e,t,p,a,l,o,s,r))};return a}),[e,n,r,t,i])}(b,n,S,d,y);(0,Fi.useEffect)((()=>{if(!b)return;b.clearRect(0,0,b.canvas.width,b.canvas.height);const e=new Path2D;!function(e,t,n,r,i,a,o,s,l){const c=[];c.push({item:e,levelOffset:0});const u=o*window.devicePixelRatio/r/(a-i);let d;for(;c.length>0;){const{item:e,levelOffset:a}=c.shift();let o=e.value;const p=o*u<=yl,h=o*u-(p?0:2*wl),f=gl;if(h({item:e,levelOffset:a+m}))))}}(r,a,n,p,l,c,s,y,((t,n,r,i,a,o,s)=>{s?e.rect(n,r,i,a):E(t,n,r,i,a,o)})),b.fillStyle=w,b.fill(e)}),[b,n,r,s,l,c,p,a,E,y,w])}function Rc(e,t,n,r,i,a,o,s){e.save(),e.clip(),e.fillStyle="#222";const l=t.valueDisplayProcessor(r.value),c=l.suffix?l.text+l.suffix:l.text,u=e.measureText(n),d=i-Sl;let p=`${n} (${c})`,h=Math.max(a,0)+Sl;u.width>d&&(e.textAlign=s,"right"===s&&(p=n,h=a+i-Sl)),e.fillText(p,h,o+gl/2+2),e.restore()}function Ac(e,t,n,r){return(e-t*n)*r}const Dc=({data:e,rangeMin:t,rangeMax:n,matchedLabels:r,setRangeMin:i,setRangeMax:a,onItemFocused:o,focusedItemData:s,textAlign:l,onSandwich:c,colorScheme:u,totalProfileTicks:d,totalProfileTicksRight:p,totalViewTicks:h,root:f,direction:m,depth:g,showFlameGraphOnly:y,collapsedMap:b,setCollapsedMap:v,collapsing:w,getExtraContextMenuButtons:S,selectedView:E,search:x})=>{const O=jc(),[_,{width:T}]=ml(),C=(0,Fi.useRef)(null),[k,P]=(0,Fi.useState)(),[R,A]=(0,Fi.useState)();Pc({canvasRef:C,colorScheme:u,data:e,focusedItemData:s,root:f,direction:m,depth:g,rangeMax:n,rangeMin:t,matchedLabels:r,textAlign:l,totalViewTicks:h,totalColorTicks:e.isDiffFlamegraph()?d:h,totalTicksRight:p,wrapperWidth:T,collapsedMap:b});const D=(0,Fi.useCallback)((r=>{P(void 0);const i=C.current.clientWidth/h/(n-t),a=Ic({x:r.nativeEvent.offsetX,y:r.nativeEvent.offsetY},f,m,g,i,h,t,b);A(a?{posY:r.clientY,posX:r.clientX,item:a,label:e.getLabel(a.itemIndexes[0])}:void 0)}),[e,t,n,h,f,m,g,b]),[j,I]=(0,Fi.useState)(),N=(0,Fi.useCallback)((e=>{if(void 0===R){P(void 0),I(void 0);const r=C.current.clientWidth/h/(n-t),i=Ic({x:e.nativeEvent.offsetX,y:e.nativeEvent.offsetY},f,m,g,r,h,t,b);i&&(I({x:e.clientX,y:e.clientY}),P(i))}}),[t,n,h,R,I,f,m,g,b]),L=(0,Fi.useCallback)((()=>{P(void 0)}),[]);return(0,Fi.useEffect)((()=>{const e=e=>{var t;e.target instanceof HTMLElement&&"flameGraphCanvasContainer_clickOutsideCheck"!==(null==(t=e.target.parentElement)?void 0:t.id)&&A(void 0)};return window.addEventListener("click",e),()=>window.removeEventListener("click",e)}),[A]),(0,Bi.jsxs)("div",{className:O.graph,children:[(0,Bi.jsx)("div",{className:O.canvasWrapper,id:"flameGraphCanvasContainer_clickOutsideCheck",ref:_,children:(0,Bi.jsx)("canvas",{ref:C,"data-testid":"flameGraph",onClick:D,onMouseMove:N,onMouseLeave:L})}),(0,Bi.jsx)(kl,{position:j,item:k,data:e,totalTicks:h,collapseConfig:k?b.get(k):void 0}),!y&&R&&(0,Bi.jsx)(Cl,{data:e,itemData:R,collapsing:w,collapseConfig:b.get(R.item),onMenuItemClick:()=>{A(void 0)},onItemFocus:()=>{i(R.item.start/h),a((R.item.start+R.item.value)/h),o(R)},onSandwich:()=>{c(e.getLabel(R.item.itemIndexes[0]))},onExpandGroup:()=>{v(b.setCollapsedStatus(R.item,!1))},onCollapseGroup:()=>{v(b.setCollapsedStatus(R.item,!0))},onExpandAllGroups:()=>{v(b.setAllCollapsedStatus(!1))},onCollapseAllGroups:()=>{v(b.setAllCollapsedStatus(!0))},allGroupsCollapsed:Array.from(b.values()).every((e=>e.collapsed)),allGroupsExpanded:Array.from(b.values()).every((e=>!e.collapsed)),getExtraContextMenuButtons:S,selectedView:E,search:x})]})},jc=()=>({graph:(0,i.css)({label:"graph",overflow:"auto",flexGrow:1,flexBasis:"50%"}),canvasContainer:(0,i.css)({label:"canvasContainer",display:"flex"}),canvasWrapper:(0,i.css)({label:"canvasWrapper",cursor:"pointer",flex:1,overflow:"hidden"}),sandwichMarker:(0,i.css)({label:"sandwichMarker",writingMode:"vertical-lr",transform:"rotate(180deg)",overflow:"hidden",whiteSpace:"nowrap"}),sandwichMarkerIcon:(0,i.css)({label:"sandwichMarkerIcon",verticalAlign:"baseline"})}),Ic=(e,t,n,r,i,a,o,s)=>{let l=t,c="children"===n?0:r-1;const u=Math.floor(e.y/(gl/window.devicePixelRatio));let d;for(;l;){const t=l;if(l=void 0,c===u){d=t;break}const r="children"===n?t.children:t.parents||[];for(const t of r){const r=Ac(t.start,a,o,i),u=Ac(t.start+t.value,a,o,i);if(r<=e.x&&e.x{const l=(0,o.useStyles2)(Lc),c=[],u=(0,r.getValueFormat)("short")(n),d=e.valueDisplayProcessor(n);let p=d.text+d.suffix;const h=e.getUnitTitle();if("Count"===h&&(d.suffix||(p=d.text)),c.push((0,Bi.jsxs)("div",{className:l.metadataPill,children:[p," | ",u.text,u.suffix," samples (",h,")"]},"default")),i&&c.push((0,Bi.jsx)(o.Tooltip,{content:i,placement:"top",children:(0,Bi.jsxs)("div",{children:[(0,Bi.jsx)(o.Icon,{size:"sm",name:"angle-right"}),(0,Bi.jsxs)("div",{className:l.metadataPill,children:[(0,Bi.jsx)(o.Icon,{size:"sm",name:"gf-show-context"})," ",(0,Bi.jsx)("span",{className:l.metadataPillName,children:i.substring(i.lastIndexOf("/")+1)}),(0,Bi.jsx)(o.IconButton,{className:l.pillCloseButton,name:"times",size:"sm",onClick:s,tooltip:"Remove sandwich view","aria-label":"Remove sandwich view"})]})]})},"sandwich")),t){const e=n>0?Math.round(t.item.value/n*1e4)/100:0,r=e>0?"eye":"exclamation-circle";c.push((0,Bi.jsx)(o.Tooltip,{content:t.label,placement:"top",children:(0,Bi.jsxs)("div",{children:[(0,Bi.jsx)(o.Icon,{size:"sm",name:"angle-right"}),(0,Bi.jsxs)("div",{className:l.metadataPill,children:[(0,Bi.jsx)(o.Icon,{size:"sm",name:r})," ",e,"% of total",(0,Bi.jsx)(o.IconButton,{className:l.pillCloseButton,name:"times",size:"sm",onClick:a,tooltip:"Remove focus","aria-label":"Remove focus"})]})]})},"focus"))}return(0,Bi.jsx)("div",{className:l.metadata,children:c})}));Nc.displayName="FlameGraphMetadata";const Lc=e=>({metadataPill:(0,i.css)({label:"metadataPill",display:"inline-flex",alignItems:"center",background:e.colors.background.secondary,borderRadius:e.shape.borderRadius(8),padding:e.spacing(.5,1),fontSize:e.typography.bodySmall.fontSize,fontWeight:e.typography.fontWeightMedium,lineHeight:e.typography.bodySmall.lineHeight,color:e.colors.text.secondary}),pillCloseButton:(0,i.css)({label:"pillCloseButton",verticalAlign:"text-bottom",margin:e.spacing(0,.5)}),metadata:(0,i.css)({display:"flex",alignItems:"center",justifyContent:"center",margin:"8px 0"}),metadataPillName:(0,i.css)({label:"metadataPillName",maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginLeft:e.spacing(.5)})}),Mc=({data:e,rangeMin:t,rangeMax:n,matchedLabels:r,setRangeMin:a,setRangeMax:s,onItemFocused:l,focusedItemData:c,textAlign:u,onSandwich:d,sandwichItem:p,onFocusPillClick:h,onSandwichPillClick:f,colorScheme:m,showFlameGraphOnly:g,getExtraContextMenuButtons:y,collapsing:b,selectedView:v,search:w,collapsedMap:S,setCollapsedMap:E})=>{const x=Fc(),[O,_]=(0,Fi.useState)(),[T,C]=(0,Fi.useState)(),[k,P]=(0,Fi.useState)(0),[R,A]=(0,Fi.useState)(),[D,j]=(0,Fi.useState)(0);if((0,Fi.useEffect)((()=>{var t,n,r;if(e){let i,a=e.getLevels(),o=a.length?a[0][0].value:0,s=a.length?a[0][0].valueRight:void 0,l=o;if(p){const[o,s]=e.getSandwichLevels(p);a=s,i=o,l=null!=(r=null==(n=null==(t=s[0])?void 0:t[0])?void 0:n.value)?r:0}_(a),C(i),P(o),A(s),j(l)}}),[e,p]),!O)return null;const I={data:e,rangeMin:t,rangeMax:n,matchedLabels:r,setRangeMin:a,setRangeMax:s,onItemFocused:l,focusedItemData:c,textAlign:u,onSandwich:d,colorScheme:m,totalProfileTicks:k,totalProfileTicksRight:R,totalViewTicks:D,showFlameGraphOnly:g,collapsedMap:S,setCollapsedMap:E,getExtraContextMenuButtons:y,collapsing:b,search:w,selectedView:v};let N=null;return(null==T?void 0:T.length)?N=(0,Bi.jsxs)(Bi.Fragment,{children:[(0,Bi.jsxs)("div",{className:x.sandwichCanvasWrapper,children:[(0,Bi.jsxs)("div",{className:x.sandwichMarker,children:["Callers",(0,Bi.jsx)(o.Icon,{className:x.sandwichMarkerIcon,name:"arrow-down"})]}),(0,Bi.jsx)(Dc,{...I,root:T[T.length-1][0],depth:T.length,direction:"parents",collapsing:!1})]}),(0,Bi.jsxs)("div",{className:x.sandwichCanvasWrapper,children:[(0,Bi.jsxs)("div",{className:(0,i.cx)(x.sandwichMarker,x.sandwichMarkerCalees),children:[(0,Bi.jsx)(o.Icon,{className:x.sandwichMarkerIcon,name:"arrow-up"}),"Callees"]}),(0,Bi.jsx)(Dc,{...I,root:O[0][0],depth:O.length,direction:"children",collapsing:!1})]})]}):(null==O?void 0:O.length)&&(N=(0,Bi.jsx)(Dc,{...I,root:O[0][0],depth:O.length,direction:"children"})),(0,Bi.jsxs)("div",{className:x.graph,children:[(0,Bi.jsx)(Nc,{data:e,focusedItem:c,sandwichedLabel:p,totalTicks:D,onFocusPillClick:h,onSandwichPillClick:f}),N]})},Fc=()=>({graph:(0,i.css)({label:"graph",overflow:"auto",flexGrow:1,flexBasis:"50%"}),sandwichCanvasWrapper:(0,i.css)({label:"sandwichCanvasWrapper",display:"flex",marginBottom:gl/window.devicePixelRatio+"px"}),sandwichMarker:(0,i.css)({label:"sandwichMarker",writingMode:"vertical-lr",transform:"rotate(180deg)",overflow:"hidden",whiteSpace:"nowrap"}),sandwichMarkerCalees:(0,i.css)({label:"sandwichMarkerCalees",textAlign:"right"}),sandwichMarkerIcon:(0,i.css)({label:"sandwichMarkerIcon",verticalAlign:"baseline"})});var $c=__webpack_require__(3241);function Bc(e,t,n="children"){var r;const i="parents"===n?"children":"parents",a=[],o=[{previous:void 0,items:e,level:0}];for(;o.length;){const e=o.shift(),s=e.items.flatMap((e=>e.itemIndexes)),l={value:e.items.reduce(((e,t)=>e+t.value),0),itemIndexes:s,children:[],parents:[],start:0,level:e.level};if(a[e.level]=a[e.level]||[],a[e.level].push(l),e.previous){l[i]=[e.previous];const t=(null==(r=e.previous[n])?void 0:r.reduce(((e,t)=>e+t.value),0))||0;l.start=e.previous.start+t,e.previous[n].push(l)}const c=e.items.flatMap((e=>e[n]||[])),u=(0,$c.groupBy)(c,(e=>t.getLabel(e.itemIndexes[0])));for(const t of Object.values(u))o.push({previous:l,items:t,level:e.level+1})}return"parents"===n&&(a.reverse(),a.forEach(((e,t)=>{e.forEach((e=>{e.level=t}))}))),a}class Vc{constructor(e){this.map=new Map,this.map=e||new Map}get(e){return this.map.get(e)}keys(){return this.map.keys()}values(){return this.map.values()}size(){return this.map.size}setCollapsedStatus(e,t){const n=new Map(this.map),r=this.map.get(e),i={...r,collapsed:t};for(const e of r.items)n.set(e,i);return new Vc(n)}setAllCollapsedStatus(e){const t=new Map(this.map);for(const n of this.map.keys()){const r={...this.map.get(n),collapsed:e};t.set(n,r)}return new Vc(t)}}class zc{constructor(e){this.map=new Map,this.threshold=.99,void 0!==e&&(this.threshold=e)}addTree(e){var t;const n=[e];for(;n.length;){const e=n.shift();(null==(t=e.parents)?void 0:t.length)&&this.addItem(e,e.parents[0]),e.children.length&&n.unshift(...e.children)}}addItem(e,t){if(t&&e.value>t.value*this.threshold&&1===t.children.length)if(this.map.has(t)){const n=this.map.get(t);this.map.set(e,n),n.items.push(e)}else{const n={items:[t,e],collapsed:!0};this.map.set(t,n),this.map.set(e,n)}}getCollapsedMap(){return new Vc(this.map)}}class Uc{constructor(e,t,n=(0,r.createTheme)()){var i,a,o;this.data=e,this.options=t;const s=function(e){const t=[["label",[r.FieldType.string,r.FieldType.enum]],["level",[r.FieldType.number]],["value",[r.FieldType.number]],["self",[r.FieldType.number]]],n=[],i=[];for(const r of t){const[t,a]=r,o=null==e?void 0:e.fields.find((e=>e.name===t));o?a.includes(o.type)||i.push({name:t,expectedTypes:a,type:o.type}):n.push(t)}if(n.length>0||i.length>0)return{wrongTypeFields:i,missingFields:n}}(e);if(s)throw new Error(function(e){return e.missingFields.length?`Data is missing fields: ${e.missingFields.join(", ")}`:e.wrongTypeFields.length?`Data has fields of wrong type: ${e.wrongTypeFields.map((e=>`${e.name} has type ${e.type} but should be ${e.expectedTypes.join(" or ")}`)).join(", ")}`:""}(s));if(this.labelField=e.fields.find((e=>"label"===e.name)),this.levelField=e.fields.find((e=>"level"===e.name)),this.valueField=e.fields.find((e=>"value"===e.name)),this.selfField=e.fields.find((e=>"self"===e.name)),this.valueRightField=e.fields.find((e=>"valueRight"===e.name)),this.selfRightField=e.fields.find((e=>"selfRight"===e.name)),(this.valueField||this.selfField)&&(!this.valueField||!this.selfField))throw new Error("Malformed dataFrame: both valueRight and selfRight has to be present if one of them is present.");const l=null==(o=null==(a=null==(i=this.labelField)?void 0:i.config)?void 0:a.type)?void 0:o.enum;l?(this.labelDisplayProcessor=(0,r.getDisplayProcessor)({field:this.labelField,theme:n}),this.uniqueLabels=l.text||[]):(this.labelDisplayProcessor=e=>({text:e+"",numeric:0}),this.uniqueLabels=[...new Set(this.labelField.values)]),this.valueDisplayProcessor=(0,r.getDisplayProcessor)({field:this.valueField,theme:n})}isDiffFlamegraph(){return Boolean(this.valueRightField&&this.selfRightField)}getLabel(e){return this.labelDisplayProcessor(this.labelField.values[e]).text}getLevel(e){return this.levelField.values[e]}getValue(e){return qc(this.valueField,e)}getValueRight(e){return qc(this.valueRightField,e)}getSelf(e){return qc(this.selfField,e)}getSelfRight(e){return qc(this.selfRightField,e)}getSelfDisplay(e){return this.valueDisplayProcessor(this.getSelf(e))}getUniqueLabels(){return this.uniqueLabels}getUnitTitle(){switch(this.valueField.config.unit){case fc.Bytes:return"RAM";case fc.Nanoseconds:return"Time"}return"Count"}getLevels(){return this.initLevels(),this.levels}getSandwichLevels(e){const t=this.getNodesWithLabel(e);if(!(null==t?void 0:t.length))return[[],[]];const n=function(e,t){const n=function(e){return e.map((e=>{var t,n;if(!(null==(t=e.parents)?void 0:t.length))return e;const r={...e,children:[]},i=[{child:r,parent:e.parents[0]}];for(;i.length;){const e=i.shift(),t={...e.parent,children:e.child?[e.child]:[],parents:[]};e.child&&(t.value=e.child.value,e.child.parents=[t]),(null==(n=e.parent.parents)?void 0:n.length)&&i.push({child:t,parent:e.parent.parents[0]})}return r}))}(e);return Bc(n,t,"parents")}(t,this);return[n,Bc(t,this)]}getNodesWithLabel(e){return this.initLevels(),this.uniqueLabelsMap[e]}getCollapsedMap(){return this.initLevels(),this.collapsedMap}initLevels(){if(!this.levels){const[e,t,n]=function(e,t){const n=[];let r,i=0;const a={};for(let t=0;t0?e.getLevel(t-1):void 0;if(n[o]=n[o]||[],s&&s>=o){const t=n[o][n[o].length-1];i=t.start+e.getValue(t.itemIndexes[0])+e.getValueRight(t.itemIndexes[0]),r=t.parents[0]}const l={itemIndexes:[t],value:e.getValue(t)+e.getValueRight(t),valueRight:e.isDiffFlamegraph()?e.getValueRight(t):void 0,start:i,parents:r&&[r],children:[],level:o};a[e.getLabel(t)]?a[e.getLabel(t)].push(l):a[e.getLabel(t)]=[l],r&&r.children.push(l),r=l,n[o].push(l)}const o=new zc(null==t?void 0:t.collapsingThreshold);return(null==t?void 0:t.collapsing)&&o.addTree(n[0][0]),[n,a,o.getCollapsedMap()]}(this,this.options);this.levels=e,this.uniqueLabelsMap=t,this.collapsedMap=n}}}function qc(e,t){if(!e)return 0;return("number"==typeof t?[t]:t).reduce(((t,n)=>t+e.values[n]),0)}var Hc=__webpack_require__(4386),Gc=__webpack_require__(1336);const Wc=({search:e,setSearch:t,selectedView:n,setSelectedView:r,containerWidth:a,onReset:s,textAlign:l,onTextAlignChange:c,showResetButton:u,colorScheme:d,onColorSchemeChange:p,stickyHeader:h,extraHeaderElements:f,vertical:m,isDiffMode:g,setCollapsedMap:y,collapsedMap:b})=>{const v=(0,o.useStyles2)(Xc),[w,S]=function(e,t){const[n,r]=(0,Fi.useState)(e),i=(0,Gc.A)(e);return(0,Hc.A)((()=>{t(n)}),250,[n]),(0,Fi.useEffect)((()=>{i!==e&&e!==n&&r(e)}),[e,i,n]),[n,r]}(e,t),E=""!==w?(0,Bi.jsx)(o.Button,{icon:"times",fill:"text",size:"sm",onClick:()=>{t(""),S("")},children:"Clear"}):null;return(0,Bi.jsxs)("div",{className:(0,i.cx)(v.header,{[v.stickyHeader]:h}),children:[(0,Bi.jsx)("div",{className:v.inputContainer,children:(0,Bi.jsx)(o.Input,{value:w||"",onChange:e=>{S(e.currentTarget.value)},placeholder:"Search...",suffix:E})}),(0,Bi.jsxs)("div",{className:v.rightContainer,children:[u&&(0,Bi.jsx)(o.Button,{variant:"secondary",fill:"outline",size:"sm",icon:"history-alt",tooltip:"Reset focus and sandwich state",onClick:()=>{s()},className:v.buttonSpacing,"aria-label":"Reset focus and sandwich state"}),(0,Bi.jsx)(Qc,{value:d,onChange:p,isDiffMode:g}),(0,Bi.jsxs)(o.ButtonGroup,{className:v.buttonSpacing,children:[(0,Bi.jsx)(o.Button,{variant:"secondary",fill:"outline",size:"sm",tooltip:"Expand all groups",onClick:()=>{y(b.setAllCollapsedStatus(!1))},"aria-label":"Expand all groups",icon:"angle-double-down",disabled:n===mc.TopTable}),(0,Bi.jsx)(o.Button,{variant:"secondary",fill:"outline",size:"sm",tooltip:"Collapse all groups",onClick:()=>{y(b.setAllCollapsedStatus(!0))},"aria-label":"Collapse all groups",icon:"angle-double-up",disabled:n===mc.TopTable})]}),(0,Bi.jsx)(o.RadioButtonGroup,{size:"sm",disabled:n===mc.TopTable,options:Kc,value:l,onChange:c,className:v.buttonSpacing}),(0,Bi.jsx)(o.RadioButtonGroup,{size:"sm",options:Yc(a,m),value:n,onChange:r}),f&&(0,Bi.jsx)("div",{className:v.extraElements,children:f})]})]})};function Qc(e){const t=(0,o.useStyles2)(Xc);let n=(0,Bi.jsxs)(o.Menu,{children:[(0,Bi.jsx)(o.Menu.Item,{label:"By package name",onClick:()=>e.onChange(gc.PackageBased)}),(0,Bi.jsx)(o.Menu.Item,{label:"By value",onClick:()=>e.onChange(gc.ValueBased)})]});const r={[gc.ValueBased]:t.colorDotByValue,[gc.PackageBased]:t.colorDotByPackage,[yc.DiffColorBlind]:t.colorDotDiffColorBlind,[yc.Default]:t.colorDotDiffDefault}[e.value]||t.colorDotByValue;let a=(0,Bi.jsx)("span",{className:(0,i.cx)(t.colorDot,r)});return e.isDiffMode&&(n=(0,Bi.jsxs)(o.Menu,{children:[(0,Bi.jsx)(o.Menu.Item,{label:"Default (green to red)",onClick:()=>e.onChange(yc.Default)}),(0,Bi.jsx)(o.Menu.Item,{label:"Color blind (blue to red)",onClick:()=>e.onChange(yc.DiffColorBlind)})]}),a=(0,Bi.jsxs)("div",{className:(0,i.cx)(t.colorDotDiff,r),children:[(0,Bi.jsx)("div",{children:"-100% (removed)"}),(0,Bi.jsx)("div",{children:"0%"}),(0,Bi.jsx)("div",{children:"+100% (added)"})]})),(0,Bi.jsx)(o.Dropdown,{overlay:n,children:(0,Bi.jsx)(o.Button,{variant:"secondary",fill:"outline",size:"sm",tooltip:"Change color scheme",onClick:()=>{},className:t.buttonSpacing,"aria-label":"Change color scheme",children:a})})}const Kc=[{value:"left",description:"Align text left",icon:"align-left"},{value:"right",description:"Align text right",icon:"align-right"}];function Yc(e,t){let n=[{value:mc.TopTable,label:"Top Table",description:"Only show top table"},{value:mc.FlameGraph,label:"Flame Graph",description:"Only show flame graph"}];return(e>=800||t)&&n.push({value:mc.Both,label:"Both",description:"Show both the top table and flame graph"}),n}const Xc=e=>({header:(0,i.css)({label:"header",display:"flex",flexWrap:"wrap",justifyContent:"space-between",width:"100%",top:0,gap:e.spacing(1),marginTop:e.spacing(1)}),stickyHeader:(0,i.css)({zIndex:e.zIndex.navbarFixed,position:"sticky",background:e.colors.background.primary}),inputContainer:(0,i.css)({label:"inputContainer",flexGrow:1,minWidth:"150px",maxWidth:"350px"}),rightContainer:(0,i.css)({label:"rightContainer",display:"flex",alignItems:"flex-start",flexWrap:"wrap"}),buttonSpacing:(0,i.css)({label:"buttonSpacing",marginRight:e.spacing(1)}),resetButton:(0,i.css)({label:"resetButton",display:"flex",marginRight:e.spacing(2)}),resetButtonIconWrapper:(0,i.css)({label:"resetButtonIcon",padding:"0 5px",color:e.colors.text.disabled}),colorDot:(0,i.css)({label:"colorDot",display:"inline-block",width:"10px",height:"10px",borderRadius:"50%"}),colorDotDiff:(0,i.css)({label:"colorDotDiff",display:"flex",width:"200px",height:"12px",color:"white",fontSize:9,lineHeight:1.3,fontWeight:300,justifyContent:"space-between",padding:"0 2px",borderRadius:"2px"}),colorDotByValue:(0,i.css)({label:"colorDotByValue",background:wc}),colorDotByPackage:(0,i.css)({label:"colorDotByPackage",background:Sc}),colorDotDiffDefault:(0,i.css)({label:"colorDotDiffDefault",background:_c}),colorDotDiffColorBlind:(0,i.css)({label:"colorDotDiffColorBlind",background:Cc}),extraElements:(0,i.css)({label:"extraElements",marginLeft:e.spacing(1)})});let Jc;Jc="undefined"!=typeof window?window:"undefined"!=typeof self?self:__webpack_require__.g;let Zc=null,eu=null;const tu=Jc.clearTimeout,nu=Jc.setTimeout,ru=Jc.cancelAnimationFrame||Jc.mozCancelAnimationFrame||Jc.webkitCancelAnimationFrame,iu=Jc.requestAnimationFrame||Jc.mozRequestAnimationFrame||Jc.webkitRequestAnimationFrame;function au(e){let t,n,r,i,a,o,s;const l="undefined"!=typeof document&&document.attachEvent;if(!l){o=function(e){const t=e.__resizeTriggers__,n=t.firstElementChild,r=t.lastElementChild,i=n.firstElementChild;r.scrollLeft=r.scrollWidth,r.scrollTop=r.scrollHeight,i.style.width=n.offsetWidth+1+"px",i.style.height=n.offsetHeight+1+"px",n.scrollLeft=n.scrollWidth,n.scrollTop=n.scrollHeight},a=function(e){return e.offsetWidth!==e.__resizeLast__.width||e.offsetHeight!==e.__resizeLast__.height},s=function(e){if(e.target.className&&"function"==typeof e.target.className.indexOf&&e.target.className.indexOf("contract-trigger")<0&&e.target.className.indexOf("expand-trigger")<0)return;const t=this;o(this),this.__resizeRAF__&&Zc(this.__resizeRAF__),this.__resizeRAF__=eu((function(){a(t)&&(t.__resizeLast__.width=t.offsetWidth,t.__resizeLast__.height=t.offsetHeight,t.__resizeListeners__.forEach((function(n){n.call(t,e)})))}))};let e=!1,l="";r="animationstart";const c="Webkit Moz O ms".split(" ");let u="webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "),d="";{const t=document.createElement("fakeelement");if(void 0!==t.style.animationName&&(e=!0),!1===e)for(let n=0;n div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; z-index: -1; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }',a=n.head||n.getElementsByTagName("head")[0],o=n.createElement("style");o.id="detectElementResize",o.type="text/css",null!=e&&o.setAttribute("nonce",e),o.styleSheet?o.styleSheet.cssText=r:o.appendChild(n.createTextNode(r)),a.appendChild(o)}}(l),a.__resizeLast__={},a.__resizeListeners__=[],(a.__resizeTriggers__=l.createElement("div")).className="resize-triggers";const u=l.createElement("div");u.className="expand-trigger",u.appendChild(l.createElement("div"));const d=l.createElement("div");d.className="contract-trigger",a.__resizeTriggers__.appendChild(u),a.__resizeTriggers__.appendChild(d),a.appendChild(a.__resizeTriggers__),o(a),a.addEventListener("scroll",s,!0),r&&(a.__resizeTriggers__.__animationListener__=function(e){e.animationName===n&&o(a)},a.__resizeTriggers__.addEventListener(r,a.__resizeTriggers__.__animationListener__))}a.__resizeListeners__.push(c)}},removeResizeListener:function(e,t){if(l)e.detachEvent("onresize",t);else if(e.__resizeListeners__.splice(e.__resizeListeners__.indexOf(t),1),!e.__resizeListeners__.length){e.removeEventListener("scroll",s,!0),e.__resizeTriggers__.__animationListener__&&(e.__resizeTriggers__.removeEventListener(r,e.__resizeTriggers__.__animationListener__),e.__resizeTriggers__.__animationListener__=null);try{e.__resizeTriggers__=!e.removeChild(e.__resizeTriggers__)}catch(e){}}}}}null==ru||null==iu?(Zc=tu,eu=function(e){return nu(e,20)}):(Zc=function([e,t]){ru(e),tu(t)},eu=function(e){const t=iu((function(){tu(n),e()})),n=nu((function(){ru(t),e()}),20);return[t,n]});class ou extends Fi.Component{constructor(...e){super(...e),this.state={height:this.props.defaultHeight||0,scaledHeight:this.props.defaultHeight||0,scaledWidth:this.props.defaultWidth||0,width:this.props.defaultWidth||0},this._autoSizer=null,this._detectElementResize=null,this._parentNode=null,this._resizeObserver=null,this._timeoutId=null,this._onResize=()=>{this._timeoutId=null;const{disableHeight:e,disableWidth:t,onResize:n}=this.props;if(this._parentNode){const r=window.getComputedStyle(this._parentNode)||{},i=parseFloat(r.paddingLeft||"0"),a=parseFloat(r.paddingRight||"0"),o=parseFloat(r.paddingTop||"0"),s=parseFloat(r.paddingBottom||"0"),l=this._parentNode.getBoundingClientRect(),c=l.height-o-s,u=l.width-i-a,d=this._parentNode.offsetHeight-o-s,p=this._parentNode.offsetWidth-i-a;(e||this.state.height===d&&this.state.scaledHeight===c)&&(t||this.state.width===p&&this.state.scaledWidth===u)||(this.setState({height:d,width:p,scaledHeight:c,scaledWidth:u}),"function"==typeof n&&n({height:d,scaledHeight:c,scaledWidth:u,width:p}))}},this._setRef=e=>{this._autoSizer=e}}componentDidMount(){const{nonce:e}=this.props,t=this._autoSizer?this._autoSizer.parentNode:null;if(null!=t&&t.ownerDocument&&t.ownerDocument.defaultView&&t instanceof t.ownerDocument.defaultView.HTMLElement){this._parentNode=t;const n=t.ownerDocument.defaultView.ResizeObserver;null!=n?(this._resizeObserver=new n((()=>{this._timeoutId=setTimeout(this._onResize,0)})),this._resizeObserver.observe(t)):(this._detectElementResize=au(e),this._detectElementResize.addResizeListener(t,this._onResize)),this._onResize()}}componentWillUnmount(){this._parentNode&&(this._detectElementResize&&this._detectElementResize.removeResizeListener(this._parentNode,this._onResize),null!==this._timeoutId&&clearTimeout(this._timeoutId),this._resizeObserver&&this._resizeObserver.disconnect())}render(){const{children:e,defaultHeight:t,defaultWidth:n,disableHeight:r=!1,disableWidth:i=!1,doNotBailOutOnEmptyChildren:a=!1,nonce:o,onResize:s,style:l={},tagName:c="div",...u}=this.props,{height:d,scaledHeight:p,scaledWidth:h,width:f}=this.state,m={overflow:"visible"},g={};let y=!1;return r||(0===d&&(y=!0),m.height=0,g.height=d,g.scaledHeight=p),i||(0===f&&(y=!0),m.width=0,g.width=f,g.scaledWidth=h),a&&(y=!1),(0,Fi.createElement)(c,{ref:this._setRef,style:{...m,...l},...u},!y&&e(g))}}const su=(0,Fi.memo)((({data:e,onSymbolClick:t,search:n,matchedLabels:i,onSearch:a,sandwichItem:s,onSandwich:l,onTableSort:c,colorScheme:u})=>{const d=(0,Fi.useMemo)((()=>{let t={};for(let n=0;n{if(i<3||p<3)return null;const g=function(e,t,n,i,a,s,l,c,u,d){const p=function(e,t,n,i){const a={type:o.TableCellDisplayMode.Custom,cellComponent:r=>(0,Bi.jsx)(uu,{frame:r.frame,onSandwich:e,onSearch:t,search:n,sandwichItem:i,rowIndex:r.rowIndex})},s={filterable:!1,width:cu,hideHeader:!0,inspect:!1,align:"auto",cellOptions:a};return{type:r.FieldType.number,name:"actions",values:[],config:{custom:s}}}(s,a,u,d),h={type:r.FieldType.string,name:"Symbol",values:[],config:{custom:{width:n-cu-2*Tl},links:[{title:"Highlight symbol",url:"",onClick:e=>{const t=e.origin.field.values[e.origin.rowIndex];i(t)}}]}};let f;if(e.isDiffFlamegraph()){h.config.custom.width=n-cu-3*Tl;const i=lu("Baseline","percent"),a=lu("Comparison","percent"),s=lu("Diff","percent");s.config.custom.cellOptions.type=o.TableCellDisplayMode.ColorText;const[l,u]=c===yc.DiffColorBlind?[Tc[0],Tc[2]]:[Oc[0],Oc[2]];s.config.mappings=[{type:r.MappingType.ValueToText,options:{[1/0]:{text:"new",color:u}}},{type:r.MappingType.ValueToText,options:{[-100]:{text:"removed",color:l}}},{type:r.MappingType.RangeToText,options:{from:0,to:1/0,result:{color:u}}},{type:r.MappingType.RangeToText,options:{from:-1/0,to:0,result:{color:l}}}];const d=e.getLevels(),m=d.length?d[0][0].value:0,g=d.length?d[0][0].valueRight:void 0;for(let e in t){p.values.push(null),h.values.push(e);const n=t[e].total,r=t[e].totalRight,o=m-g,l=Math.round(1e4*n/o)/100,c=Math.round(1e4*r/g)/100,u=(c-l)/l*100;s.values.push(u),i.values.push(l),a.values.push(c)}f={fields:[p,h,i,a,s],length:h.values.length}}else{const n=lu("Self",e.selfField.config.unit),r=lu("Total",e.valueField.config.unit);for(let e in t)p.values.push(null),h.values.push(e),n.values.push(t[e].self),r.values.push(t[e].total);f={fields:[p,h,n,r],length:h.values.length}}const m=(0,r.applyFieldOverrides)({data:[f],fieldConfig:{defaults:{},overrides:[]},replaceVariables:e=>e,theme:l});return m[0]}(e,d,i,t,a,l,h,u,n,s);return(0,Bi.jsx)(o.Table,{initialSortBy:f,onSortByChange:e=>{e&&e.length&&(null==c||c(e[0].displayName+"_"+(e[0].desc?"desc":"asc"))),m(e)},data:g,width:i,height:p})}})})}));function lu(e,t){const n={width:Tl,align:"auto",inspect:!1,cellOptions:{type:o.TableCellDisplayMode.Auto}};return{type:r.FieldType.number,name:e,values:[],config:{unit:t,custom:n}}}su.displayName="FlameGraphTopTableContainer";const cu=61;function uu(e){var t;const n=pu(),r=null==(t=e.frame.fields.find((e=>"Symbol"===e.name)))?void 0:t.values[e.rowIndex],i=e.search===r,a=e.sandwichItem===r;return(0,Bi.jsxs)("div",{className:n.actionCellWrapper,children:[(0,Bi.jsx)(o.IconButton,{className:n.actionCellButton,name:"search",variant:i?"primary":"secondary",tooltip:i?"Clear from search":"Search for symbol","aria-label":i?"Clear from search":"Search for symbol",onClick:()=>{e.onSearch(i?"":r)}}),(0,Bi.jsx)(o.IconButton,{className:n.actionCellButton,name:"gf-show-context",tooltip:a?"Remove from sandwich view":"Show in sandwich view",variant:a?"primary":"secondary","aria-label":a?"Remove from sandwich view":"Show in sandwich view",onClick:()=>{e.onSandwich(a?void 0:r)}})]})}const du=e=>({topTableContainer:(0,i.css)({label:"topTableContainer",padding:e.spacing(1),backgroundColor:e.colors.background.secondary,height:"100%"})}),pu=()=>({actionCellWrapper:(0,i.css)({label:"actionCellWrapper",display:"flex",height:"24px"}),actionCellButton:(0,i.css)({label:"actionCellButton",marginRight:0,width:"24px"})}),hu=new ol,fu=({data:e,onTableSymbolClick:t,onViewSelected:n,onTextAlignSelected:r,onTableSort:a,getTheme:s,stickyHeader:l,extraHeaderElements:c,vertical:u,showFlameGraphOnly:d,disableCollapsing:p,keepFocusOnDataChange:h,getExtraContextMenuButtons:f})=>{const[m,g]=(0,Fi.useState)(),[y,b]=(0,Fi.useState)(0),[v,w]=(0,Fi.useState)(1),[S,E]=(0,Fi.useState)(""),[x,O]=(0,Fi.useState)(mc.Both),[_,{width:T}]=ml(),[C,k]=(0,Fi.useState)("left"),[P,R]=(0,Fi.useState)(),[A,D]=(0,Fi.useState)(new Vc),j=(0,Fi.useMemo)((()=>s()),[s]),I=(0,Fi.useMemo)((()=>{if(!e)return;const t=new Uc(e,{collapsing:!p},j);return D(t.getCollapsedMap()),t}),[e,j,p]),[N,L]=function(e){const t=(null==e?void 0:e.isDiffFlamegraph())?yc.Default:gc.PackageBased,[n,r]=(0,Fi.useState)(t);return(0,Fi.useEffect)((()=>{r(t)}),[t]),[n,r]}(I),M=function(e){return{container:(0,i.css)({label:"container",overflow:"auto",height:"100%",display:"flex",flex:"1 1 0",flexDirection:"column",minHeight:0,gap:e.spacing(1)}),body:(0,i.css)({label:"body",flexGrow:1}),tableContainer:(0,i.css)({height:800}),horizontalContainer:(0,i.css)({label:"horizontalContainer",display:"flex",minHeight:0,flexDirection:"row",columnGap:e.spacing(1),width:"100%"}),horizontalGraphContainer:(0,i.css)({flexBasis:"50%"}),horizontalTableContainer:(0,i.css)({flexBasis:"50%",maxHeight:800}),verticalGraphContainer:(0,i.css)({marginBottom:e.spacing(1)}),verticalTableContainer:(0,i.css)({height:800})}}(j),F=function(e,t){return(0,Fi.useMemo)((()=>{if(e&&t){const n=new Set;let r=hu.filter(t.getUniqueLabels(),e);if(r)for(let e of r)n.add(t.getUniqueLabels()[e]);return n}}),[e,t])}(S,I);(0,Fi.useEffect)((()=>{T>0&&T<800&&x===mc.Both&&!u&&O(mc.FlameGraph)}),[x,O,T,u]);const $=(0,Fi.useCallback)((()=>{g(void 0),b(0),w(1)}),[g,w,b]),B=(0,Fi.useCallback)((()=>{R(void 0)}),[R]);(0,Fi.useEffect)((()=>{var e;if(!h)return $(),void B();if(I&&m){const t=null==(e=I.getNodesWithLabel(m.label))?void 0:e[0];if(t){g({...m,item:t});const e=I.getLevels(),n=e.length?e[0][0].value:0;b(t.start/n),w((t.start+t.value)/n)}else g({...m,item:{start:0,value:0,itemIndexes:[],children:[],level:0}}),b(0),w(1)}}),[I,h]);const V=(0,Fi.useCallback)((e=>{S===e?E(""):(null==t||t(e),E(e),$())}),[E,$,t,S]);if(!I)return null;const z=(0,Bi.jsx)(Mc,{data:I,rangeMin:y,rangeMax:v,matchedLabels:F,setRangeMin:b,setRangeMax:w,onItemFocused:e=>g(e),focusedItemData:m,textAlign:C,sandwichItem:P,onSandwich:e=>{$(),R(e)},onFocusPillClick:$,onSandwichPillClick:B,colorScheme:N,showFlameGraphOnly:d,collapsing:!p,getExtraContextMenuButtons:f,selectedView:x,search:S,collapsedMap:A,setCollapsedMap:D}),U=(0,Bi.jsx)(su,{data:I,onSymbolClick:V,search:S,matchedLabels:F,sandwichItem:P,onSandwich:R,onSearch:E,onTableSort:a,colorScheme:N});let q;return d||x===mc.FlameGraph?q=z:x===mc.TopTable?q=(0,Bi.jsx)("div",{className:M.tableContainer,children:U}):x===mc.Both&&(q=u?(0,Bi.jsxs)("div",{children:[(0,Bi.jsx)("div",{className:M.verticalGraphContainer,children:z}),(0,Bi.jsx)("div",{className:M.verticalTableContainer,children:U})]}):(0,Bi.jsxs)("div",{className:M.horizontalContainer,children:[(0,Bi.jsx)("div",{className:M.horizontalTableContainer,children:U}),(0,Bi.jsx)("div",{className:M.horizontalGraphContainer,children:z})]})),(0,Bi.jsx)(o.ThemeContext.Provider,{value:j,children:(0,Bi.jsxs)("div",{ref:_,className:M.container,children:[!d&&(0,Bi.jsx)(Wc,{search:S,setSearch:E,selectedView:x,setSelectedView:e=>{O(e),null==n||n(e)},containerWidth:T,onReset:()=>{$(),B()},textAlign:C,onTextAlignChange:e=>{k(e),null==r||r(e)},showResetButton:Boolean(m||P),colorScheme:N,onColorSchemeChange:L,stickyHeader:Boolean(l),extraHeaderElements:c,vertical:u,isDiffMode:I.isDiffFlamegraph(),setCollapsedMap:D,collapsedMap:A}),(0,Bi.jsx)("div",{className:M.body,children:q})]})})};var mu={},gu=Uint8Array,yu=Uint16Array,bu=Int32Array,vu=new gu([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),wu=new gu([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Su=new gu([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Eu=function(e,t){for(var n=new yu(31),r=0;r<31;++r)n[r]=t+=1<>1|(21845&Ru)<<1;Au=(61680&(Au=(52428&Au)>>2|(13107&Au)<<2))>>4|(3855&Au)<<4,Pu[Ru]=((65280&Au)>>8|(255&Au)<<8)>>1}var Du=function(e,t,n){for(var r=e.length,i=0,a=new yu(t);i>l]=c}else for(o=new yu(r),i=0;i>15-e[i]);return o},ju=new gu(288);for(Ru=0;Ru<144;++Ru)ju[Ru]=8;for(Ru=144;Ru<256;++Ru)ju[Ru]=9;for(Ru=256;Ru<280;++Ru)ju[Ru]=7;for(Ru=280;Ru<288;++Ru)ju[Ru]=8;var Iu=new gu(32);for(Ru=0;Ru<32;++Ru)Iu[Ru]=5;var Nu=Du(ju,9,0),Lu=Du(ju,9,1),Mu=Du(Iu,5,0),Fu=Du(Iu,5,1),$u=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},Bu=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},Vu=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},zu=function(e){return(e+7)/8|0},Uu=function(e,t,n){return(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length),new gu(e.subarray(t,n))},qu=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Hu=function(e,t,n){var r=new Error(t||qu[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Hu),!n)throw r;return r},Gu=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new gu(0);var o=!n,s=o||2!=t.i,l=t.i;o&&(n=new gu(3*i));var c=function(e){var t=n.length;if(e>t){var r=new gu(Math.max(2*t,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,p=t.b||0,h=t.l,f=t.d,m=t.m,g=t.n,y=8*i;do{if(!h){u=Bu(e,d,1);var b=Bu(e,d+1,3);if(d+=3,!b){var v=e[(R=zu(d)+4)-4]|e[R-3]<<8,w=R+v;if(w>i){l&&Hu(0);break}s&&c(p+v),n.set(e.subarray(R,w),p),t.b=p+=v,t.p=d=8*w,t.f=u;continue}if(1==b)h=Lu,f=Fu,m=9,g=5;else if(2==b){var S=Bu(e,d,31)+257,E=Bu(e,d+10,15)+4,x=S+Bu(e,d+5,31)+1;d+=14;for(var O=new gu(x),_=new gu(19),T=0;T>4)<16)O[T++]=R;else{var D=0,j=0;for(16==R?(j=3+Bu(e,d,3),d+=2,D=O[T-1]):17==R?(j=3+Bu(e,d,7),d+=3):18==R&&(j=11+Bu(e,d,127),d+=7);j--;)O[T++]=D}}var I=O.subarray(0,S),N=O.subarray(S);m=$u(I),g=$u(N),h=Du(I,m,1),f=Du(N,g,1)}else Hu(1);if(d>y){l&&Hu(0);break}}s&&c(p+131072);for(var L=(1<>4;if((d+=15&D)>y){l&&Hu(0);break}if(D||Hu(2),$<256)n[p++]=$;else{if(256==$){F=d,h=null;break}var B=$-254;if($>264){var V=vu[T=$-257];B=Bu(e,d,(1<>4;z||Hu(3),d+=15&z;N=Cu[U];if(U>3){V=wu[U];N+=Vu(e,d)&(1<y){l&&Hu(0);break}s&&c(p+131072);var q=p+B;if(p>8},Qu=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},Ku=function(e,t){for(var n=[],r=0;rp&&(p=a[r].s);var h=new yu(p+1),f=Yu(n[u-1],h,0);if(f>t){r=0;var m=0,g=f-t,y=1<t))break;m+=y-(1<>=g;m>0;){var v=a[r].s;h[v]=0&&m;--r){var w=a[r].s;h[w]==t&&(--h[w],++m)}f=t}return{t:new gu(h),l:f}},Yu=function(e,t,n){return-1==e.s?Math.max(Yu(e.l,t,n+1),Yu(e.r,t,n+1)):t[e.s]=n},Xu=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new yu(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;s<=t;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return{c:n.subarray(0,r),n:t}},Ju=function(e,t){for(var n=0,r=0;r>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var a=0;a4&&!T[Su[k-1]];--k);var P,R,A,D,j=c+5<<3,I=Ju(i,ju)+Ju(a,Iu)+o,N=Ju(i,p)+Ju(a,m)+o+14+3*k+Ju(x,T)+2*x[16]+3*x[17]+7*x[18];if(l>=0&&j<=I&&j<=N)return Zu(t,u,e.subarray(l,l+c));if(Wu(t,u,1+(N15&&(Wu(t,u,$[O]>>5&127),u+=$[O]>>12)}}}else P=Nu,R=ju,A=Mu,D=Iu;for(O=0;O255){Qu(t,u,P[(B=V>>18&31)+257]),u+=R[B+257],B>7&&(Wu(t,u,V>>23&31),u+=vu[B]);var z=31&V;Qu(t,u,A[z]),u+=D[z],z>3&&(Qu(t,u,V>>5&8191),u+=wu[z])}else Qu(t,u,P[V]),u+=R[V]}return Qu(t,u,P[256]),u+R[256]},td=new bu([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),nd=new gu(0),rd=function(e,t,n,r,i,a){var o=a.z||e.length,s=new gu(r+o+5*(1+Math.ceil(o/7e3))+i),l=s.subarray(r,s.length-i),c=a.l,u=7&(a.r||0);if(t){u&&(l[0]=a.r>>3);for(var d=td[t-1],p=d>>13,h=8191&d,f=(1<7e3||T>24576)&&(D>423||!c)){u=ed(e,l,0,w,S,E,O,T,k,_-k,u),T=x=O=0,k=_;for(var j=0;j<286;++j)S[j]=0;for(j=0;j<30;++j)E[j]=0}var I=2,N=0,L=h,M=R-A&32767;if(D>2&&P==v(_-M))for(var F=Math.min(p,D)-1,$=Math.min(32767,_),B=Math.min(258,D);M<=$&&--L&&R!=A;){if(e[_+I]==e[_+I-M]){for(var V=0;VI){if(I=V,N=M,V>F)break;var z=Math.min(M,V-2),U=0;for(j=0;jU&&(U=H,A=q)}}}M+=(R=A)-(A=m[R])&32767}if(N){w[T++]=268435456|_u[I]<<18|ku[N];var G=31&_u[I],W=31&ku[N];O+=vu[G]+wu[W],++S[257+G],++E[W],C=_+I,++x}else w[T++]=e[_],++S[e[_]]}}for(_=Math.max(_,C);_=o&&(l[u/8|0]=c,Q=o),u=Zu(l,u+1,e.subarray(_,Q))}a.i=o}return Uu(s,0,r+zu(u)+i)},id=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(1&n&&-306674912)^n>>>1;e[t]=n}return e}(),ad=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r>>8;e=n},d:function(){return~e}}},od=function(){var e=1,t=0;return{p:function(n){for(var r=e,i=t,a=0|n.length,o=0;o!=a;){for(var s=Math.min(o+2655,a);o>16),i=(65535&i)+15*(i>>16)}e=r,t=i},d:function(){return(255&(e%=65521))<<24|(65280&e)<<8|(255&(t%=65521))<<8|t>>8}}},sd=function(e,t,n,r,i){if(!i&&(i={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new gu(a.length+e.length);o.set(a),o.set(e,a.length),e=o,i.w=a.length}return rd(e,null==t.level?6:t.level,null==t.mem?i.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,n,r,i)},ld=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},cd=function(e,t,n){for(var r=e(),i=e.toString(),a=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o>>=8},xd=function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Ed(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;r<=n.length;++r)e[r+10]=n.charCodeAt(r)}},Od=function(e){31==e[0]&&139==e[1]&&8==e[2]||Hu(6,"invalid gzip data");var t=e[3],n=10;4&t&&(n+=2+(e[10]|e[11]<<8));for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(2&t)},_d=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},Td=function(e){return 10+(e.filename?e.filename.length+1:0)},Cd=function(e,t){var n=t.level,r=0==n?0:n<6?1:9==n?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var i=od();i.p(t.dictionary),Ed(e,2,i.d())}},kd=function(e,t){return(8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Hu(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&Hu(6,"invalid zlib data: "+(32&e[1]?"need":"unexpected")+" dictionary"),2+(e[1]>>3&4)};function Pd(e,t){return"function"==typeof e&&(t=e,e={}),this.ondata=t,e}var Rd=function(){function e(e,t){if("function"==typeof e&&(t=e,e={}),this.ondata=t,this.o=e||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new gu(98304),this.o.dictionary){var n=this.o.dictionary.subarray(-32768);this.b.set(n,32768-n.length),this.s.i=32768-n.length}}return e.prototype.p=function(e,t){this.ondata(sd(e,this.o,0,0,this.s),t)},e.prototype.push=function(e,t){this.ondata||Hu(5),this.s.l&&Hu(4);var n=e.length+this.s.z;if(n>this.b.length){if(n>2*this.b.length-32768){var r=new gu(-32768&n);r.set(this.b.subarray(0,this.s.z)),this.b=r}var i=this.b.length-this.s.z;this.b.set(e.subarray(0,i),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(e.subarray(i),32768),this.s.z=e.length-i+32768,this.s.i=32766,this.s.w=32768}else this.b.set(e,this.s.z),this.s.z+=e.length;this.s.l=1&t,(this.s.z>this.s.w+8191||t)&&(this.p(this.b,t||!1),this.s.w=this.s.i,this.s.i-=2)},e.prototype.flush=function(){this.ondata||Hu(5),this.s.l&&Hu(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},e}(),Ad=function(){return function(e,t){Sd([hd,function(){return[wd,Rd]}],this,Pd.call(this,e,t),(function(e){var t=new Rd(e.data);onmessage=wd(t)}),6,1)}}();function Dd(e,t){return sd(e,t||{},0,0)}var jd=function(){function e(e,t){"function"==typeof e&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new gu(32768),this.p=new gu(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||Hu(5),this.d&&Hu(4),this.p.length){if(e.length){var t=new gu(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}}else this.p=e},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=Gu(this.p,this.s,this.o);this.ondata(Uu(n,t,this.s.b),this.d),this.o=Uu(n,this.s.b-32768),this.s.b=this.o.length,this.p=Uu(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),Id=function(){return function(e,t){Sd([pd,function(){return[wd,jd]}],this,Pd.call(this,e,t),(function(e){var t=new jd(e.data);onmessage=wd(t)}),7,0)}}();function Nd(e,t){return Gu(e,{i:2},t&&t.out,t&&t.dictionary)}var Ld=function(){function e(e,t){this.c=ad(),this.l=0,this.v=1,Rd.call(this,e,t)}return e.prototype.push=function(e,t){this.c.p(e),this.l+=e.length,Rd.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var n=sd(e,this.o,this.v&&Td(this.o),t&&8,this.s);this.v&&(xd(n,this.o),this.v=0),t&&(Ed(n,n.length-8,this.c.d()),Ed(n,n.length-4,this.l)),this.ondata(n,t)},e.prototype.flush=function(){Rd.prototype.flush.call(this)},e}(),Md=function(){return function(e,t){Sd([hd,fd,function(){return[wd,Rd,Ld]}],this,Pd.call(this,e,t),(function(e){var t=new Ld(e.data);onmessage=wd(t)}),8,1)}}();var Fd=function(){function e(e,t){this.v=1,this.r=0,jd.call(this,e,t)}return e.prototype.push=function(e,t){if(jd.prototype.e.call(this,e),this.r+=e.length,this.v){var n=this.p.subarray(this.v-1),r=n.length>3?Od(n):4;if(r>n.length){if(!t)return}else this.v>1&&this.onmember&&this.onmember(this.r-n.length);this.p=n.subarray(r),this.v=0}jd.prototype.c.call(this,t),!this.s.f||this.s.l||t||(this.v=zu(this.s.p)+9,this.s={i:0},this.o=new gu(0),this.push(new gu(0),t))},e}(),$d=function(){return function(e,t){var n=this;Sd([pd,md,function(){return[wd,jd,Fd]}],this,Pd.call(this,e,t),(function(e){var t=new Fd(e.data);t.onmember=function(e){return postMessage(e)},onmessage=wd(t)}),9,0,(function(e){return n.onmember&&n.onmember(e)}))}}();var Bd=function(){function e(e,t){this.c=od(),this.v=1,Rd.call(this,e,t)}return e.prototype.push=function(e,t){this.c.p(e),Rd.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var n=sd(e,this.o,this.v&&(this.o.dictionary?6:2),t&&4,this.s);this.v&&(Cd(n,this.o),this.v=0),t&&Ed(n,n.length-4,this.c.d()),this.ondata(n,t)},e.prototype.flush=function(){Rd.prototype.flush.call(this)},e}(),Vd=function(){return function(e,t){Sd([hd,gd,function(){return[wd,Rd,Bd]}],this,Pd.call(this,e,t),(function(e){var t=new Bd(e.data);onmessage=wd(t)}),10,1)}}();var zd=function(){function e(e,t){jd.call(this,e,t),this.v=e&&e.dictionary?2:1}return e.prototype.push=function(e,t){if(jd.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(kd(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&Hu(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),jd.prototype.c.call(this,t)},e}(),Ud=function(){return function(e,t){Sd([pd,yd,function(){return[wd,jd,zd]}],this,Pd.call(this,e,t),(function(e){var t=new zd(e.data);onmessage=wd(t)}),11,0)}}();var qd="undefined"!=typeof TextDecoder&&new TextDecoder;try{qd.decode(nd,{stream:!0}),1}catch(Jt){}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;const Hd=e=>class{constructor(){this.i=new e,this.i.ondata=(e,t)=>{this.ondata(null,e,t)}}push(e,t){try{this.queuedSize+=e.length,this.i.push(e,t),this.queuedSize-=e.length,this.ondrain&&this.ondrain(e.length)}catch(e){this.ondata(e,null,t||!1)}}};let Gd=1;try{(new Ad).terminate()}catch(Hu){Gd=0}const Wd=Gd?{gzip:Md,deflate:Vd,"deflate-raw":Ad}:{gzip:Hd(Ld),deflate:Hd(Bd),"deflate-raw":Hd(Rd)},Qd=Gd?{gzip:$d,deflate:Ud,"deflate-raw":Id}:{gzip:Hd(Fd),deflate:Hd(zd),"deflate-raw":Hd(jd)},Kd=(e,t,n)=>class extends e{constructor(e){if(!arguments.length)throw new TypeError(`Failed to construct '${n}': 1 argument required, but only 0 present.`);const r=t[e];if(!r)throw new TypeError(`Failed to construct '${n}': Unsupported compression format: '${e}'`);let i,a=new r;super({start:e=>{a.ondata=(t,n,r)=>{t?e.error(t):n&&(e.enqueue(n),r&&(i?i():e.terminate()))}},transform:e=>{if(e instanceof ArrayBuffer)e=new Uint8Array(e);else{if(!ArrayBuffer.isView(e))throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}if(a.push(e),a.queuedSize>=32768)return new Promise((e=>{a.ondrain=()=>{a.queuedSize<32768&&e()}}))},flush:()=>new Promise((e=>{i=e,a.push(new Uint8Array(0),!0)}))},{size:e=>0|e.byteLength,highWaterMark:65536},{size:e=>0|e.byteLength,highWaterMark:65536})}};const Yd="undefined"==typeof globalThis?"undefined"==typeof self?"undefined"==typeof global?{}:global:self:globalThis;var Xd;void 0===Yd.CompressionStream&&(Yd.CompressionStream=(Xd=TransformStream,Kd(Xd,Wd,"CompressionStream"))),void 0===Yd.DecompressionStream&&(Yd.DecompressionStream=function(e){return Kd(e,Qd,"DecompressionStream")}(TransformStream));var Jd=__webpack_require__(2249),Zd=__webpack_require__.n(Jd);function ep(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}const tp=new class extends ca{upload(e,t){var n,r=this;return(n=function*(){const n=yield r.fetch("/upload/v1",{method:"POST",body:JSON.stringify({name:e,profile:btoa(JSON.stringify(t)),fileTypeData:{units:t.metadata.units,spyName:t.metadata.spyName},type:"json"})});return yield n.json()},function(){var e=this,t=arguments;return new Promise((function(r,i){var a=n.apply(e,t);function o(e){ep(a,r,i,o,s,"next",e)}function s(e){ep(a,r,i,o,s,"throw",e)}o(void 0)}))})()}constructor(){super("https://flamegraph.com/api",{"content-type":"application/json"})}};var np=function(e){return e.BASELINE="baseline",e.COMPARISON="comparison",e}({});const rp=new Intl.DateTimeFormat("fr-CA",{year:"numeric",month:"2-digit",day:"2-digit",hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});function ip(e){const t=rp.formatToParts(e).reduce(((e,{type:t,value:n})=>(e[t]=n,e)),{});return`${t.year}-${t.month}-${t.day}_${t.hour}${t.minute}`}function ap(e){const t=new Date(Math.round(1e3*e.from.unix())),n=new Date(Math.round(1e3*e.to.unix()));return`${ip(t)}-to-${ip(n)}`}function op(e){const[t,n]=e===np.BASELINE?["diffFrom","diffTo"]:["diffFrom-2","diffTo-2"],i=new URLSearchParams(window.location.search),a=i.get(t),o=i.get(n);return{raw:{from:a,to:o},from:(0,r.dateTimeParse)(a),to:(0,r.dateTimeParse)(o)}}function sp(e){const t=["baseline",ap(op(np.BASELINE)),"comparison",ap(op(np.COMPARISON))];return e?[e,...t].join("_"):["flamegraph",...t].join("_")}function lp(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function cp({profile:e,enableFlameGraphDotComExport:t}){const n=function(){var t,n=(t=function*(){Ts("g_pyroscope_app_export_profile",{format:"flamegraph.com"});const t=sp(e.metadata.appName);let n;try{n=yield tp.upload(t,e)}catch(e){return void Ds(e,["Failed to export to flamegraph.com!",e.message])}const r=document.createElement("a");r.target="_blank",r.href=n.url,document.body.appendChild(r),r.click(),document.body.removeChild(r)},function(){var e=this,n=arguments;return new Promise((function(r,i){var a=t.apply(e,n);function o(e){lp(a,r,i,o,s,"next",e)}function s(e){lp(a,r,i,o,s,"throw",e)}o(void 0)}))});return function(){return n.apply(this,arguments)}}();return{data:{shouldDisplayFlamegraphDotCom:Boolean(t)},actions:{downloadPng:()=>{Ts("g_pyroscope_app_export_profile",{format:"png"});const t=`${sp(e.metadata.appName)}.png`;document.querySelector('canvas[data-testid="flameGraph"]').toBlob((e=>{if(e)Zd()(e,t);else{const e=new Error("No Blob, the image cannot be created.");Ds(e,["Failed to export to png!",e.message])}}),"image/png")},downloadJson:()=>{Ts("g_pyroscope_app_export_profile",{format:"json"});const t=`${sp(e.metadata.appName)}.json`,n=`data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(e))}`;try{Zd()(n,t)}catch(e){return void Ds(e,["Failed to export to JSON!",e.message])}},uploadToFlamegraphDotCom:n}}}function up(e){const{actions:t}=cp(e);return $i().createElement(o.Menu,null,$i().createElement(o.Menu.Item,{label:"png",onClick:t.downloadPng}),$i().createElement(o.Menu.Item,{label:"json",onClick:t.downloadJson}))}function dp(e){const{profile:t,enableFlameGraphDotComExport:n}=e;return $i().createElement(o.Dropdown,{overlay:$i().createElement(up,{profile:t,enableFlameGraphDotComExport:n})},$i().createElement(o.Button,{icon:"download-alt",size:"sm",variant:"secondary",fill:"outline","aria-label":"Export profile data",tooltip:"Export profile data"}))}const pp=(0,Fi.memo)(dp);function hp(e,t,n){const r=[],i=n?7:4;for(let a=0;afunction(e,t,n,i){if(!e.length)return;const a=[];for(let n=0;n0){const e=a[n].slice(0,-1).reduce(((e,t)=>t.offsetTotal+t.valTotal+e),0)+r.offsetTotal,t=a[n-1];let i=0;for(const n of t){const t=i+n.offsetTotal,a=t+n.valTotal;if(t<=e&&a>e){n.children.push(r);break}i+=n.offsetTotal+n.valTotal}}}const o=[a[0][0]],s=[],l=[],c=[],u=[],d=[],p=[];for(;o.length;){const e=o.shift();s.push(e.label),l.push(e.level),c.push(e.self),u.push(e.val),d.push(e.selfRight),p.push(e.valRight),o.unshift(...e.children)}let h="short";switch(n){case"samples":case"trace_samples":case"lock_nanoseconds":case"nanoseconds":h="ns";break;case"bytes":h="bytes"}const f=[{name:"level",values:l},{name:"label",values:s,type:r.FieldType.string},{name:"self",values:c,config:{unit:h}},{name:"value",values:u,config:{unit:h}}];i&&f.push({name:"selfRight",values:d,config:{unit:h}},{name:"valueRight",values:p,config:{unit:h}});const m={name:"response",meta:{preferredVisualisationType:"flamegraph"},fields:f};return(0,r.createDataFrame)(m)}(e.flamebearer.levels,e.flamebearer.names,e.metadata.units,Boolean(t))),[e,t]);return $i().createElement(fu,{data:c,disableCollapsing:!a,extraHeaderElements:$i().createElement(pp,{profile:e,enableFlameGraphDotComExport:i}),vertical:n,getTheme:()=>(0,r.createTheme)({colors:{mode:l?"light":"dark"}}),getExtraContextMenuButtons:s,keepFocusOnDataChange:!0})}const mp=(0,Fi.memo)(fp),gp=e=>({flamegraph:i.css` margin-top: ${e.spacing(2)}; `});function yp({profile:e,diff:t}){const n=(0,o.useStyles2)(gp);return $i().createElement("div",{className:n.flamegraph,"data-testid":"flamegraph"},$i().createElement(mp,{profile:e,diff:t}))}const bp=e=>({selectorContainer:i.css` display: flex; justify-content: center; margin-bottom: ${e.spacing(2)}; `});function vp({profileTypes:e,onChange:t}){const n=(0,o.useStyles2)(bp),r=(0,Fi.useMemo)((()=>e.map((e=>({value:e,label:e})))),[e]),[i,a]=(0,Fi.useState)(),s=(0,Fi.useCallback)((e=>{a(e),t(e)}),[t]);return(0,Fi.useEffect)((()=>{a(r[0])}),[r]),$i().createElement("div",{className:n.selectorContainer},$i().createElement(o.InlineFieldRow,null,$i().createElement(o.InlineField,{label:"Profile",disabled:!r.length,"data-testid":"profile-types-dropdown"},$i().createElement(o.Select,{key:null==i?void 0:i.value,value:i,options:r,onChange:s,width:16}))))}const wp=e=>({spinner:i.css` text-align: center; margin-top: ${e.spacing(2)}; `});function Sp(){const e=(0,o.useStyles2)(wp);return $i().createElement("div",{className:e.spinner},$i().createElement(o.Spinner,{size:36}))}function Ep(){const{processFile:e,profileTypes:t,selectProfileType:n,profile:r,removeFile:i,isLoading:a}=qs();return $i().createElement("div",null,$i().createElement(vp,{profileTypes:t,onChange:e=>{Ts("g_pyroscope_app_ad_hoc_profile_metric_selected"),n(e)}}),$i().createElement(Ks,{onFileDropped:t=>{Ts("g_pyroscope_app_ad_hoc_file_dropped",{fileType:t.type}),e(t)},onFileRemove:()=>{Ts("g_pyroscope_app_ad_hoc_file_removed"),i()}}),a&&!r?$i().createElement(Sp,null):null,r&&$i().createElement(yp,{profile:r}))}const xp=(0,Fi.memo)(Ep);function Op(){return $i().createElement(Ps,{left:$i().createElement(xp,null),right:$i().createElement(xp,null)})}const _p=e=>({tabContent:i.css` padding: ${e.spacing(2)}; margin: ${e.spacing(2)}; `});function Tp(){const e=(0,o.useStyles2)(_p),[t,n]=(0,Fi.useState)(0);return $i().createElement("div",null,$i().createElement(o.TabsBar,null,$i().createElement(o.Tab,{label:" Single view",active:0===t,onChangeTab:()=>n(0)}),$i().createElement(o.Tab,{label:" Comparison view",active:1===t,onChangeTab:()=>n(1)})),$i().createElement(o.TabContent,{className:e.tabContent},0===t&&$i().createElement(xp,null),1===t&&$i().createElement(Op,null)))}function Cp(){return Cs("ad_hoc"),$i().createElement($i().Fragment,null,$i().createElement(os,{title:"Ad hoc view"}),$i().createElement(Tp,null))}var kp=Object.defineProperty,Pp=Object.getOwnPropertySymbols,Rp=Object.prototype.hasOwnProperty,Ap=Object.prototype.propertyIsEnumerable,Dp=(e,t,n)=>t in e?kp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jp=(e,t)=>{for(var n in t||(t={}))Rp.call(t,n)&&Dp(e,n,t[n]);if(Pp)for(var n of Pp(t))Ap.call(t,n)&&Dp(e,n,t[n]);return e};function Ip(e,t){const n=jp({},a.locationService.getSearchObject());if(t)for(const e of Object.keys(n))t.includes(e)||delete n[e];return r.urlUtil.renderUrl(r.locationUtil.assureBaseUrl(e),n)}function Np(e,t){return $i().createElement(e.Component,{model:e,routeProps:t})}var Lp=Object.defineProperty,Mp=Object.defineProperties,Fp=Object.getOwnPropertyDescriptors,$p=Object.getOwnPropertySymbols,Bp=Object.prototype.hasOwnProperty,Vp=Object.prototype.propertyIsEnumerable,zp=(e,t,n)=>t in e?Lp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const Up=new Map;var qp=__webpack_require__(1269);const Hp={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let Gp;const Wp=new Uint8Array(16);function Qp(){if(!Gp&&(Gp="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Gp))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Gp(Wp)}const Kp=[];for(let e=0;e<256;++e)Kp.push((e+256).toString(16).slice(1));function Yp(e,t=0){return Kp[e[t+0]]+Kp[e[t+1]]+Kp[e[t+2]]+Kp[e[t+3]]+"-"+Kp[e[t+4]]+Kp[e[t+5]]+"-"+Kp[e[t+6]]+Kp[e[t+7]]+"-"+Kp[e[t+8]]+Kp[e[t+9]]+"-"+Kp[e[t+10]]+Kp[e[t+11]]+Kp[e[t+12]]+Kp[e[t+13]]+Kp[e[t+14]]+Kp[e[t+15]]}const Xp=function(e,t,n){if(Hp.randomUUID&&!t&&!e)return Hp.randomUUID();const r=(e=e||{}).random||(e.rng||Qp)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return Yp(r)};var Jp=Object.defineProperty,Zp=Object.defineProperties,eh=Object.getOwnPropertyDescriptors,th=Object.getOwnPropertySymbols,nh=Object.prototype.hasOwnProperty,rh=Object.prototype.propertyIsEnumerable,ih=(e,t,n)=>t in e?Jp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const ah=$i().memo((function(e){var t,n=e,{model:r}=n,i=((e,t)=>{var n={};for(var r in e)nh.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&th)for(var r of th(e))t.indexOf(r)<0&&rh.call(e,r)&&(n[r]=e[r]);return n})(n,["model"]);const a=null!=(t=r.constructor.Component)?t:oh,[o,s]=(0,Fi.useState)(0);return(0,Fi.useEffect)((()=>{const e=r.activate();return s((e=>e+1)),e}),[r]),r.isActive?$i().createElement(a,((e,t)=>Zp(e,eh(t)))(((e,t)=>{for(var n in t||(t={}))nh.call(t,n)&&ih(e,n,t[n]);if(th)for(var n of th(t))rh.call(t,n)&&ih(e,n,t[n]);return e})({},i),{model:r})):null}));function oh(e){return null}class sh extends r.BusEventWithPayload{}sh.type="scene-object-state-change";class lh extends r.BusEventWithPayload{}lh.type="scene-object-user-action";var ch,uh=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};class dh{constructor(e){var t,n,r,i;((e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)})(this,ch,void 0),r=e,uh(t=this,n=ch,"write to private field"),i?i.call(t,r):n.set(t,r)}resolve(){return uh(e=this,t=ch,"read from private field"),n?n.call(e):t.get(e);var e,t,n}}ch=new WeakMap;var ph=Object.defineProperty,hh=Object.getOwnPropertySymbols,fh=Object.prototype.hasOwnProperty,mh=Object.prototype.propertyIsEnumerable,gh=(e,t,n)=>t in e?ph(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yh=(e,t)=>{for(var n in t||(t={}))fh.call(t,n)&&gh(e,n,t[n]);if(hh)for(var n of hh(t))mh.call(t,n)&&gh(e,n,t[n]);return e};class bh{constructor(e){this._isActive=!1,this._activationHandlers=[],this._deactivationHandlers=new Map,this._subs=new qp.Subscription,this._refCount=0,e.key||(e.key=Xp()),this._events=new r.EventBusSrv,this._state=Object.freeze(e),this._setParent(this._state)}get state(){return this._state}get isActive(){return this._isActive}get parent(){return this._parent}get variableDependency(){return this._variableDependency}get urlSync(){return this._urlSync}get Component(){return ah}_setParent(e){wh(e,(e=>{e._parent&&e._parent!==this&&console.warn("SceneObject already has a parent set that is different from the new parent. You cannot share the same SceneObject instance in multiple scenes or in multiple different places of the same scene graph. Use SceneObject.clone() to duplicate a SceneObject or store a state key reference and use sceneGraph.findObject to locate it.",e,this),e._parent=this}))}subscribeToState(e){return this._events.subscribe(sh,(t=>{t.payload.changedObject===this&&e(t.payload.newState,t.payload.prevState)}))}subscribeToEvent(e,t){return this._events.subscribe(e,t)}setState(e){const t=this._state,n=yh(yh({},this._state),e);this._state=Object.freeze(n),this._setParent(e),this._handleActivationOfChangedStateProps(t,n),this.publishEvent(new sh({prevState:t,newState:n,partialUpdate:e,changedObject:this}),!0)}_handleActivationOfChangedStateProps(e,t){this.isActive&&(e.$behaviors!==t.$behaviors&&this._handleChangedBehaviors(e.$behaviors,t.$behaviors),e.$data!==t.$data&&this._handleChangedStateActivation(e.$data,t.$data),e.$variables!==t.$variables&&this._handleChangedStateActivation(e.$variables,t.$variables),e.$timeRange!==t.$timeRange&&this._handleChangedStateActivation(e.$timeRange,t.$timeRange))}_handleChangedStateActivation(e,t){if(e){const t=this._deactivationHandlers.get(e);t&&(t(),this._deactivationHandlers.delete(e))}t&&this._deactivationHandlers.set(t,t.activate())}_handleChangedBehaviors(e,t){if(e)for(const n of e)if(!t||!t.includes(n)){const e=this._deactivationHandlers.get(n);e&&(e(),this._deactivationHandlers.delete(n))}if(t)for(const n of t)e&&e.includes(n)||this._activateBehavior(n)}publishEvent(e,t){this._events.publish(e),t&&this.parent&&this.parent.publishEvent(e,t)}getRoot(){return this._parent?this._parent.getRoot():this}_internalActivate(){this._isActive=!0;const{$data:e,$variables:t,$timeRange:n,$behaviors:r}=this.state;if(this._activationHandlers.forEach((e=>{const t=e();t&&this._deactivationHandlers.set(t,t)})),n&&!n.isActive&&this._deactivationHandlers.set(n,n.activate()),t&&!t.isActive&&this._deactivationHandlers.set(t,t.activate()),e&&!e.isActive&&this._deactivationHandlers.set(e,e.activate()),r)for(const e of r)this._activateBehavior(e)}_activateBehavior(e){if(e instanceof bh)this._deactivationHandlers.set(e,e.activate());else if("function"==typeof e){const t=e(this);t&&this._deactivationHandlers.set(e,t)}}activate(){this.isActive||this._internalActivate(),this._refCount++;let e=!1;return()=>{if(this._refCount--,e){throw new Error("SceneObject cancelation handler returned by activate() called a second time")}e=!0,0===this._refCount&&this._internalDeactivate()}}_internalDeactivate(){this._isActive=!1;for(let e of this._deactivationHandlers.values())e();this._deactivationHandlers.clear(),this._events.removeAllListeners(),this._subs.unsubscribe(),this._subs=new qp.Subscription}useState(){return vh(this)}forceRender(){this.setState({})}clone(e){return function(e,t){const n=Ch(e.state,t);return new e.constructor(n)}(this,e)}addActivationHandler(e){this._activationHandlers.push(e)}forEachChild(e){wh(this.state,e)}getRef(){return this._ref||(this._ref=new dh(this)),this._ref}}function vh(e,t){var n;const[r,i]=(0,Fi.useState)(e.state),a=e.state,o=null!=(n=null==t?void 0:t.shouldActivateOrKeepAlive)&&n;return(0,Fi.useEffect)((()=>{let t;o&&(t=e.activate());const n=e.subscribeToState((e=>{i(e)}));return e.state!==a&&i(e.state),()=>{n.unsubscribe(),t&&t()}}),[e,o]),e.state}function wh(e,t){for(const n of Object.values(e))if(n instanceof bh&&t(n),Array.isArray(n))for(const e of n)e instanceof bh&&t(e)}var Sh=Object.defineProperty,Eh=Object.getOwnPropertySymbols,xh=Object.prototype.hasOwnProperty,Oh=Object.prototype.propertyIsEnumerable,_h=(e,t,n)=>t in e?Sh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Th=(e,t)=>{for(var n in t||(t={}))xh.call(t,n)&&_h(e,n,t[n]);if(Eh)for(var n of Eh(t))Oh.call(t,n)&&_h(e,n,t[n]);return e};function Ch(e,t){const n=Th({},e);for(const e in n){const t=n[e];if(t instanceof bh&&(n[e]=t.clone()),t instanceof dh)throw new Error("Cannot clone a SceneObject with a SceneObjectRef in state");if(Array.isArray(t)){const r=[];for(const e of t)e instanceof bh?r.push(e.clone()):r.push(e);n[e]=r}}return Object.assign(n,t),n}function kh(e,t){let n,r=e;for(;r&&!n;)n=t(r),r=r.parent;return n}class Ph extends r.DataSourceApi{constructor(e,t){super({name:"RuntimeDataSource-"+e,uid:t,type:e,id:1,readOnly:!0,jsonData:{},access:"direct",meta:{id:e,name:"RuntimeDataSource-"+e,type:r.PluginType.datasource,info:{author:{name:""},description:"",links:[],logos:{large:"",small:""},screenshots:[],updated:"",version:""},module:"",baseUrl:""}})}testDatasource(){return Promise.resolve({})}}const Rh=new Map;class Ah{constructor(){this.index=new Map}getUniqueKey(e,t){const n=this.index.get(e);if(!n)throw new Error("Cannot find any scene object that uses the key '"+e+"'");const r=n.findIndex((e=>e.sceneObject===t));return r>0?`${e}-${r+1}`:e}rebuildIndex(e){this.index.clear(),this.buildIndex(e,0)}buildIndex(e,t){if(e.urlSync)for(const n of e.urlSync.getKeys()){const r=this.index.get(n);r?(r.push({sceneObject:e,depth:t}),r.sort(((e,t)=>e.depth-t.depth))):this.index.set(n,[{sceneObject:e,depth:t}])}e.forEachChild((e=>this.buildIndex(e,t+1)))}}function Dh(e){const t=new Ah;t.rebuildIndex(e);const n={},r=e=>{if(e.urlSync){const r=e.urlSync.getUrlState();for(const[i,a]of Object.entries(r))if(null!=a){const r=t.getUniqueKey(i,e);n[r]=a}}e.forEachChild(r)};return r(e),n}function jh(e,t,n){if(e.urlSync){const r={},i=e.urlSync.getUrlState();for(const a of e.urlSync.getKeys()){const o=n.getUniqueKey(a,e),s=t.getAll(o),l=i[a];Ih(s,l)||(s.length>0?Array.isArray(l)?r[a]=s:r[a]=s[0]:r[a]=null)}Object.keys(r).length>0&&e.urlSync.updateFromUrl(r)}e.forEachChild((e=>jh(e,t,n)))}function Ih(e,t){return 0===e.length&&null==t||(Array.isArray(t)||1!==(null==e?void 0:e.length)?0===(null==t?void 0:t.length)&&null===e||(0,$c.isEqual)(e,t):t===e[0])}var Nh=(e=>(e.Linear="linear",e.Log="log",e.Ordinal="ordinal",e.Symlog="symlog",e))(Nh||{}),Lh=(e=>(e.Hue="hue",e.None="none",e.Opacity="opacity",e.Scheme="scheme",e))(Lh||{});var Mh=(e=>(e.Ascending="asc",e.Descending="desc",e.None="none",e))(Mh||{});var Fh=(e=>(e.Basic="basic",e.Gradient="gradient",e.Lcd="lcd",e))(Fh||{}),$h=(e=>(e.Color="color",e.Hidden="hidden",e.Text="text",e))($h||{}),Bh=(e=>(e.Auto="auto",e.Hidden="hidden",e.Left="left",e.Top="top",e))(Bh||{}),Vh=(e=>(e.Auto="auto",e.Manual="manual",e))(Vh||{}),zh=(e=>(e.Actions="actions",e.Auto="auto",e.BasicGauge="basic",e.ColorBackground="color-background",e.ColorBackgroundSolid="color-background-solid",e.ColorText="color-text",e.Custom="custom",e.DataLinks="data-links",e.Gauge="gauge",e.GradientGauge="gradient-gauge",e.Image="image",e.JSONView="json-view",e.LcdGauge="lcd-gauge",e.Sparkline="sparkline",e))(zh||{});var Uh=(e=>(e.CSV="csv",e.Date="date",e.Distributed="distributed",e.DoubleQuote="doublequote",e.Glob="glob",e.HTML="html",e.JSON="json",e.Lucene="lucene",e.PercentEncode="percentencode",e.Pipe="pipe",e.QueryParam="queryparam",e.Raw="raw",e.Regex="regex",e.SQLString="sqlstring",e.SingleQuote="singlequote",e.Text="text",e.UriEncode="uriencode",e))(Uh||{});zh.Auto;var qh=(e=>(e.NotStarted="NotStarted",e.Loading="Loading",e.Streaming="Streaming",e.Done="Done",e.Error="Error",e))(qh||{}),Hh=Object.defineProperty,Gh=Object.getOwnPropertySymbols,Wh=Object.prototype.hasOwnProperty,Qh=Object.prototype.propertyIsEnumerable,Kh=(e,t,n)=>t in e?Hh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const Yh={state:qh.Done,series:[],timeRange:(0,r.getDefaultTimeRange)()};class Xh{constructor(e,t){this._sceneObject=e,this._keys=t.keys}getKeys(){return"function"==typeof this._keys?this._keys():this._keys}getUrlState(){return this._sceneObject.getUrlState()}updateFromUrl(e){this._sceneObject.updateFromUrl(e)}}const Jh=/^\d+[yYmMsSwWhHdD]$/;function Zh(e){if("string"!=typeof e)return null;if(-1!==e.indexOf("now"))return e;if(Jh.test(e))return e;if(8===e.length){const t=(0,r.toUtc)(e,"YYYYMMDD");if(t.isValid())return t.toISOString()}else if(15===e.length){const t=(0,r.toUtc)(e,"YYYYMMDDTHHmmss");if(t.isValid())return t.toISOString()}else if(24===e.length){return(0,r.toUtc)(e).toISOString()}const t=parseInt(e,10);return isNaN(t)?null:(0,r.toUtc)(t).toISOString()}function ef(e,t,n,i,a){const o=a&&"now"===t;return{from:r.dateMath.parse(e,!1,n,i),to:r.dateMath.parse(o?"now-"+a:t,!0,n,i),raw:{from:e,to:t}}}var tf=Object.defineProperty,nf=Object.getOwnPropertySymbols,rf=Object.prototype.hasOwnProperty,af=Object.prototype.propertyIsEnumerable,of=(e,t,n)=>t in e?tf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class sf extends bh{constructor(e={}){var t,n;const i=null!=(t=e.from)?t:"now-6h",a=null!=(n=e.to)?n:"now",o=e.timeZone;super(((e,t)=>{for(var n in t||(t={}))rf.call(t,n)&&of(e,n,t[n]);if(nf)for(var n of nf(t))af.call(t,n)&&of(e,n,t[n]);return e})({from:i,to:a,timeZone:o,value:ef(i,a,o||(0,r.getTimeZone)(),e.fiscalYearStartMonth,e.UNSAFE_nowDelay)},e)),this._urlSync=new Xh(this,{keys:["from","to","timezone"]}),this.onTimeRangeChange=e=>{const t={},n={};"string"==typeof e.raw.from?(t.from=e.raw.from,n.from=e.raw.from):(t.from=e.raw.from.toISOString(),n.from=e.raw.from.toISOString(!0)),"string"==typeof e.raw.to?(t.to=e.raw.to,n.to=e.raw.to):(t.to=e.raw.to.toISOString(),n.to=e.raw.to.toISOString(!0)),t.value=ef(n.from,n.to,this.getTimeZone(),this.state.fiscalYearStartMonth,this.state.UNSAFE_nowDelay),t.from===this.state.from&&t.to===this.state.to||this.setState(t)},this.onTimeZoneChange=e=>{this.setState({timeZone:e})},this.onRefresh=()=>{this.setState({value:ef(this.state.from,this.state.to,this.getTimeZone(),this.state.fiscalYearStartMonth,this.state.UNSAFE_nowDelay)})},this.addActivationHandler(this._onActivate.bind(this))}_onActivate(){if(!this.state.timeZone){const e=this.getTimeZoneSource();e!==this&&this._subs.add(e.subscribeToState(((t,n)=>{void 0!==t.timeZone&&t.timeZone!==n.timeZone&&this.setState({value:ef(this.state.from,this.state.to,e.getTimeZone(),this.state.fiscalYearStartMonth,this.state.UNSAFE_nowDelay)})})))}return this.state.weekStart&&(0,r.setWeekStart)(this.state.weekStart),()=>{this.state.weekStart&&(0,r.setWeekStart)(a.config.bootData.user.weekStart)}}getTimeZoneSource(){if(!this.parent||!this.parent.parent)return this;const e=kh(this.parent.parent,(e=>{if(e.state.$timeRange&&e.state.$timeRange.state.timeZone)return e.state.$timeRange}));return e||this}getTimeZone(){if(this.state.timeZone)return this.state.timeZone;const e=this.getTimeZoneSource();return e!==this?e.state.timeZone:(0,r.getTimeZone)()}getUrlState(){const e={from:this.state.from,to:this.state.to};return this.state.timeZone&&(e.timezone=this.state.timeZone),e}updateFromUrl(e){var t,n,r;if(!e.to&&!e.from)return;const i={},a=Zh(e.from);a&&(i.from=a);const o=Zh(e.to);o&&(i.to=o),"string"==typeof e.timezone&&(i.timeZone=""!==e.timezone?e.timezone:void 0),i.value=ef(null!=(t=i.from)?t:this.state.from,null!=(n=i.to)?n:this.state.to,null!=(r=i.timeZone)?r:this.getTimeZone(),this.state.fiscalYearStartMonth,this.state.UNSAFE_nowDelay),this.setState(i)}}const lf=new class extends bh{constructor(e){super(((e,t)=>{for(var n in t||(t={}))Wh.call(t,n)&&Kh(e,n,t[n]);if(Gh)for(var n of Gh(t))Qh.call(t,n)&&Kh(e,n,t[n]);return e})({data:Yh},e))}getResultsStream(){const e={origin:this,data:this.state.data};return(0,qp.of)(e)}},cf=new sf;const uf=new class extends bh{constructor(){super({variables:[]})}getByName(e){}isVariableLoadingOrWaitingToUpdate(e){return!1}};function df(e){var t;return null!=(t=kh(e,(e=>e.state.$timeRange)))?t:cf}class pf extends r.BusEventWithPayload{}function hf(e){return"object"==typeof e&&"formatter"in e}pf.type="scene-variable-changed-value";let ff,mf={};function gf(e){const t=mf[e];return t||(mf[e]=(0,$c.property)(e))}class yf{constructor(e,t){this.state={name:e,value:t,type:"scopedvar"}}getValue(e){let{value:t}=this.state,n=t.value;return n=e?gf(e)(t.value):t.value,"string"===n||"number"===n||"boolean"===n?n:String(n)}getValueText(){const{value:e}=this.state;return null!=e.text?String(e.text):String(e)}}const bf=new r.Registry((()=>{const e=[{id:Uh.Lucene,name:"Lucene",description:"Values are lucene escaped and multi-valued variables generate an OR expression",formatter:e=>{if("string"==typeof e)return vf(e);if(Array.isArray(e)){if(0===e.length)return"__empty__";return"("+(0,$c.map)(e,(e=>'"'+vf(e)+'"')).join(" OR ")+")"}return vf(`${e}`)}},{id:Uh.Raw,name:"raw",description:"Keep value as is",formatter:e=>String(e)},{id:Uh.Regex,name:"Regex",description:"Values are regex escaped and multi-valued variables generate a (|) expression",formatter:e=>{if("string"==typeof e)return(0,r.escapeRegex)(e);if(Array.isArray(e)){const t=e.map((e=>"string"==typeof e?(0,r.escapeRegex)(e):(0,r.escapeRegex)(String(e))));return 1===t.length?t[0]:"("+t.join("|")+")"}return(0,r.escapeRegex)(`${e}`)}},{id:Uh.Pipe,name:"Pipe",description:"Values are separated by | character",formatter:e=>"string"==typeof e?e:Array.isArray(e)?e.join("|"):`${e}`},{id:Uh.Distributed,name:"Distributed",description:"Multiple values are formatted like variable=value",formatter:(e,t,n)=>"string"==typeof e?e:Array.isArray(e)?(e=(0,$c.map)(e,((e,t)=>0!==t?n.state.name+"="+e:e))).join(","):`${e}`},{id:Uh.CSV,name:"Csv",description:"Comma-separated values",formatter:e=>"string"==typeof e?e:(0,$c.isArray)(e)?e.join(","):String(e)},{id:Uh.HTML,name:"HTML",description:"HTML escaping of values",formatter:e=>"string"==typeof e?r.textUtil.escapeHtml(e):(0,$c.isArray)(e)?r.textUtil.escapeHtml(e.join(", ")):r.textUtil.escapeHtml(String(e))},{id:Uh.JSON,name:"JSON",description:"JSON stringify value",formatter:e=>"string"==typeof e?e:JSON.stringify(e)},{id:Uh.PercentEncode,name:"Percent encode",description:"Useful for URL escaping values",formatter:e=>(0,$c.isArray)(e)?wf("{"+e.join(",")+"}"):wf(e)},{id:Uh.SingleQuote,name:"Single quote",description:"Single quoted values",formatter:e=>{const t=new RegExp("'","g");if((0,$c.isArray)(e))return(0,$c.map)(e,(e=>`'${(0,$c.replace)(e,t,"\\'")}'`)).join(",");let n="string"==typeof e?e:String(e);return`'${(0,$c.replace)(n,t,"\\'")}'`}},{id:Uh.DoubleQuote,name:"Double quote",description:"Double quoted values",formatter:e=>{const t=new RegExp('"',"g");if((0,$c.isArray)(e))return(0,$c.map)(e,(e=>`"${(0,$c.replace)(e,t,'\\"')}"`)).join(",");let n="string"==typeof e?e:String(e);return`"${(0,$c.replace)(n,t,'\\"')}"`}},{id:Uh.SQLString,name:"SQL string",description:"SQL string quoting and commas for use in IN statements and other scenarios",formatter:_f},{id:Uh.Date,name:"Date",description:"Format date in different ways",formatter:(e,t)=>{var n;let i=NaN;if("number"==typeof e?i=e:"string"==typeof e&&(i=parseInt(e,10)),isNaN(i))return"NaN";const a=null!=(n=t[0])?n:"iso";switch(a){case"ms":return String(e);case"seconds":return`${Math.round(i/1e3)}`;case"iso":return(0,r.dateTime)(i).toISOString();default:return(t||[]).length>1?(0,r.dateTime)(i).format(t.join(":")):(0,r.dateTime)(i).format(a)}}},{id:Uh.Glob,name:"Glob",description:"Format multi-valued variables using glob syntax, example {value1,value2}",formatter:e=>(0,$c.isArray)(e)&&e.length>1?"{"+e.join(",")+"}":String(e)},{id:Uh.Text,name:"Text",description:"Format variables in their text representation. Example in multi-variable scenario A + B + C.",formatter:(e,t,n)=>n.getValueText?n.getValueText():String(e)},{id:Uh.QueryParam,name:"Query parameter",description:"Format variables as URL parameters. Example in multi-variable scenario A + B + C => var-foo=A&var-foo=B&var-foo=C.",formatter:(e,t,n)=>Array.isArray(e)?e.map((e=>xf(n.state.name,e))).join("&"):xf(n.state.name,e)},{id:Uh.UriEncode,name:"Percent encode as URI",description:"Useful for URL escaping values, taking into URI syntax characters",formatter:e=>(0,$c.isArray)(e)?Sf("{"+e.join(",")+"}"):Sf(e)}];return e}));function vf(e){return!1===isNaN(+e)?e:e.replace(/([\!\*\+\-\=<>\s\&\|\(\)\[\]\{\}\^\~\?\:\\/"])/g,"\\$1")}function wf(e){return"object"==typeof e&&(e=String(e)),Ef(encodeURIComponent(e))}const Sf=e=>Ef(encodeURI(String(e))),Ef=e=>e.replace(/[!'()*]/g,(e=>"%"+e.charCodeAt(0).toString(16).toUpperCase()));function xf(e,t){return`var-${e}=${wf(t)}`}const Of={"'":"''",'"':'\\"'};function _f(e){const t=new RegExp("'|\"","g");if((0,$c.isArray)(e))return(0,$c.map)(e,(e=>`'${(0,$c.replace)(e,t,(e=>{var t;return null!=(t=Of[e])?t:""}))}'`)).join(",");let n="string"==typeof e?e:String(e);return`'${(0,$c.replace)(n,t,(e=>{var t;return null!=(t=Of[e])?t:""}))}'`}const Tf="All",Cf="$__all",kf="$__auto",Pf=/\$(\w+)|\[\[(\w+?)(?::(\w+))?\]\]|\${(\w+)(?:\.([^:^\}]+))?(?::([^\}]+))?}/g,Rf="__searchFilter";function Af(e,t){const n=t.state.$variables;if(!n)return t.parent?Af(e,t.parent):null;const r=n.getByName(e);return r||(t.parent?Af(e,t.parent):null)}function Df(e,t,n,r,i){return t?(Pf.lastIndex=0,t.replace(Pf,((t,a,o,s,l,c,u)=>{const d=a||o||l,p=s||u||r,h=function(e,t,n,r){if(n&&n.hasOwnProperty(e)){const t=n[e];if(t)return function(e,t){return ff?(ff.state.name=e,ff.state.value=t):ff=new yf(e,t),ff}(e,t)}const i=Af(e,r);if(i)return i;const a=em.get(e);if(a)return new a(e,r,t,n);return null}(d,t,n,e);if(!h)return i&&i.push({match:t,variableName:d,fieldPath:c,format:p,value:t,found:!1}),t;const f=function(e,t,n,r){if(null==n)return"";if(hf(n))return Df(e,n.formatter(r));Array.isArray(n)||"object"!=typeof n||(n=`${n}`);if("function"==typeof r)return r(n,{name:t.state.name,type:t.state.type,multi:t.state.isMulti,includeAll:t.state.includeAll});let i=[];r?(i=r.split(":"),i.length>1?(r=i[0],i=i.slice(1)):i=[]):r=Uh.Glob;let a=bf.getIfExists(r);a||(console.error(`Variable format ${r} not found. Using glob format as fallback.`),a=bf.get(Uh.Glob));return a.formatter(n,i,t)}(e,h,h.getValue(c),p);return i&&i.push({match:t,variableName:d,fieldPath:c,format:p,value:f,found:f!==t}),f}))):null!=t?t:""}function jf(e){return void 0!==e.useState}function If(e){return"enrichDataRequest"in e}function Nf(e){return"isDataLayer"in e}function Lf(e){return"isQueryController"in e}function Mf(e){var t;return null!=(t=kh(e,(e=>e.state.$data)))?t:lf}function Ff(e,t,n,r){if(t(e))return e;let i=null;return e.forEachChild((e=>{if(e===n)return;let r=Ff(e,t);r&&(i=r)})),i||(r&&e.parent?Ff(e.parent,t,e,!0):null)}function $f(e,t){return Ff(e,t,void 0,!0)}new WeakMap;class Bf{constructor(e){this._value=e}formatter(){return this._value}}class Vf{constructor(e,t){this.state={name:e,type:"time_macro"},this._sceneObject=t}getValue(){const e=df(this._sceneObject);return"__from"===this.state.name?e.state.value.from.valueOf():e.state.value.to.valueOf()}getValueText(){const e=df(this._sceneObject);return"__from"===this.state.name?(0,r.dateTimeFormat)(e.state.value.from,{timeZone:e.getTimeZone()}):(0,r.dateTimeFormat)(e.state.value.to,{timeZone:e.getTimeZone()})}}class zf{constructor(e,t,n){this.state={name:e,type:"time_macro",match:n},this._sceneObject=t}getValue(){var e;const t=Mf(this._sceneObject);if(t){const n=null==(e=t.state.data)?void 0:e.request;return n?"__interval_ms"===this.state.name?n.intervalMs:n.interval:this.state.match}return this.state.match}}function Uf(e,t={}){if(e.state.$variables)for(const n of e.state.$variables.state.variables)n.state.skipUrlSync||t[n.state.name]||(t[n.state.name]=n);return e.parent&&Uf(e.parent,t),t}var qf=Object.defineProperty,Hf=Object.defineProperties,Gf=Object.getOwnPropertyDescriptors,Wf=Object.getOwnPropertySymbols,Qf=Object.prototype.hasOwnProperty,Kf=Object.prototype.propertyIsEnumerable,Yf=(e,t,n)=>t in e?qf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function Xf(e,t,n){return new Proxy({},{get:(i,a)=>"name"===a?e.name:"displayName"===a?(0,r.getFieldDisplayName)(e,t,n):"labels"===a||"formattedLabels"===a?e.labels?((e,t)=>Hf(e,Gf(t)))(((e,t)=>{for(var n in t||(t={}))Qf.call(t,n)&&Yf(e,n,t[n]);if(Wf)for(var n of Wf(t))Kf.call(t,n)&&Yf(e,n,t[n]);return e})({},e.labels),{__values:Object.values(e.labels).sort().join(", "),toString:()=>(0,r.formatLabels)(e.labels,"",!0)}):"":void 0})}const Jf=(0,r.getDisplayProcessor)();class Zf{constructor(e){this._urlQueryParams=e}formatter(e){if(!e)return this._urlQueryParams;const t=e.split(":");if("exclude"===t[0]&&t.length>1){const e=new URLSearchParams(this._urlQueryParams);for(const n of t[1].split(","))e.delete(n);return`?${e}`}if("include"===t[0]&&t.length>1){const e=new URLSearchParams(this._urlQueryParams),n=t[1].split(",");for(const t of e.keys())n.includes(t)||e.delete(t);return`?${e}`}return this._urlQueryParams}}const em=new Map([[r.DataLinkBuiltInVars.includeVars,class{constructor(e,t){this.state={name:e,type:"url_variable"},this._sceneObject=t}getValue(){const e=Uf(this._sceneObject),t=bf.get(Uh.QueryParam),n=[];for(const r of Object.keys(e)){const i=e[r],a=i.getValue();a&&(hf(a)?n.push(a.formatter(Uh.QueryParam)):n.push(t.formatter(a,[],i)))}return new Bf(n.join("&"))}getValueText(){return""}}],[r.DataLinkBuiltInVars.keepTime,class{constructor(e,t){this.state={name:e,type:"url_variable"},this._sceneObject=t}getValue(){var e;const t=null==(e=df(this._sceneObject).urlSync)?void 0:e.getUrlState();return new Bf(r.urlUtil.toUrlParams(t))}getValueText(){return""}}],["__value",class{constructor(e,t,n,r){this._match=n,this._scopedVars=r,this.state={name:e,type:"__value"}}getValue(e){var t,n;const i=null==(t=this._scopedVars)?void 0:t.__dataContext;if(!i)return this._match;const{frame:a,rowIndex:o,field:s,calculatedValue:l}=i.value;if(l)switch(e){case"numeric":case"raw":return l.numeric;case"time":return"";default:return(0,r.formattedValueToString)(l)}if(null==o)return this._match;if("time"===e){const e=a.fields.find((e=>e.type===r.FieldType.time));return e?e.values.get(o):void 0}if(!s)return this._match;const c=s.values.get(o);if("raw"===e)return c;const u=(null!=(n=s.display)?n:Jf)(c);return"numeric"===e?u.numeric:(0,r.formattedValueToString)(u)}getValueText(){return""}}],["__data",class{constructor(e,t,n,r){this._match=n,this._scopedVars=r,this.state={name:e,type:"__data"}}getValue(e){var t,n;const i=null==(t=this._scopedVars)?void 0:t.__dataContext;if(!i||!e)return this._match;const{frame:a,rowIndex:o}=i.value;if(void 0===o||void 0===e)return this._match;const s={name:a.name,refId:a.refId,fields:(0,r.getFieldDisplayValuesProxy)({frame:a,rowIndex:o})};return null!=(n=gf(e)(s))?n:""}getValueText(){return""}}],["__series",class{constructor(e,t,n,r){this._match=n,this._scopedVars=r,this.state={name:e,type:"__series"}}getValue(e){var t;const n=null==(t=this._scopedVars)?void 0:t.__dataContext;if(!n||!e)return this._match;if("name"!==e)return this._match;const{frame:i,frameIndex:a}=n.value;return(0,r.getFrameDisplayName)(i,a)}getValueText(){return""}}],["__field",class{constructor(e,t,n,r){this._match=n,this._scopedVars=r,this.state={name:e,type:"__field"}}getValue(e){var t,n;const r=null==(t=this._scopedVars)?void 0:t.__dataContext;if(!r||!e)return this._match;if(void 0===e||""===e)return this._match;const{frame:i,field:a,data:o}=r.value,s=Xf(a,i,o);return null!=(n=gf(e)(s))?n:""}getValueText(){return""}}],["__url",class{constructor(e,t){this.state={name:e,type:"url_macro"}}getValue(e){var t;const n=a.locationService.getLocation(),r=null!=(t=a.config.appSubUrl)?t:"";switch(null!=e?e:""){case"params":return new Zf(n.search);case"path":return r+n.pathname;default:return r+n.pathname+n.search}}getValueText(){return""}}],["__from",Vf],["__to",Vf],["__timezone",class{constructor(e,t){this.state={name:e,type:"time_macro"},this._sceneObject=t}getValue(){const e=df(this._sceneObject).getTimeZone();return"browser"===e?Intl.DateTimeFormat().resolvedOptions().timeZone:e}getValueText(){return this.getValue()}}],["__user",class{constructor(e,t){this.state={name:e,type:"user_macro"}}getValue(e){const t=a.config.bootData.user;switch(e){case"login":return t.login;case"email":return t.email;default:return String(t.id)}}getValueText(){return""}}],["__org",class{constructor(e,t){this.state={name:e,type:"org_macro"}}getValue(e){const t=a.config.bootData.user;return"name"===e?t.orgName:String(t.orgId)}getValueText(){return""}}],["__interval",zf],["__interval_ms",zf]]);const tm={getVariables:function(e){var t;return null!=(t=kh(e,(e=>e.state.$variables)))?t:uf},getData:Mf,getTimeRange:df,getLayout:function(e){const t=kh(e,(e=>function(e){return"isDraggable"in e}(e)?e:void 0));return t||null},getDataLayers:function(e,t=!1){let n=e,r=[];for(;n;){const e=n.state.$data;if(e){if(Nf(e)?r=r.concat(e):e.state.$data&&Nf(e.state.$data)&&(r=r.concat(e.state.$data)),t&&r.length>0)break;n=n.parent}else n=n.parent}return r},interpolate:function(e,t,n,r,i){return""===t||null==t?"":Df(e,t,n,r,i)},lookupVariable:Af,hasVariableDependencyInLoadingState:function(e){if(!e.variableDependency)return!1;for(const t of e.variableDependency.getNames()){const n=Af(t,e);if(!n)continue;if(n.parent.isVariableLoadingOrWaitingToUpdate(n))return!0}return!1},findByKey:function(e,t){const n=$f(e,(e=>e.state.key===t));if(!n)throw new Error("Unable to find scene with key "+t);return n},findByKeyAndType:function(e,t,n){const r=$f(e,(e=>e.state.key===t));if(!r)throw new Error("Unable to find scene with key "+t);if(!(r instanceof n))throw new Error(`Found scene object with key ${t} does not match type ${n.name}`);return r},findObject:$f,findAllObjects:function e(t,n){const r=[];return t.forEachChild((t=>{n(t)&&r.push(t),r.push(...e(t,n))})),r},getAncestor:function(e,t){let n=e;for(;n;){if(n instanceof t)return n;n=n.parent}if(!n)throw new Error("Unable to find parent of type "+t.name);return n},getQueryController:function(e){let t=e;for(;t;){if(t.state.$behaviors)for(const e of t.state.$behaviors)if(Lf(e))return e;t=t.parent}}};async function nm(e,t){if(null==e?void 0:e.uid){const t=Rh.get(e.uid);if(t)return t}return e&&e.query?e:await(0,a.getDataSourceSrv)().get(e,t)}function rm(e,t,...n){let r=!1;"undefined"!=typeof window&&(r="true"===localStorage.getItem("grafana.debug.scenes"))}class im{constructor(e,t){this._sceneObject=e,this._options=t,this._dependencies=new Set,this._isWaitingForVariables=!1,this.scanCount=0,this._statePaths=t.statePaths}hasDependencyOn(e){return this.getNames().has(e)}variableUpdateCompleted(e,t){const n=this.getNames();let i=!1;(n.has(e.state.name)||n.has(r.DataLinkBuiltInVars.includeVars))&&t&&(i=!0),rm(0,0,e.state.name,this._isWaitingForVariables),this._options.onAnyVariableChanged&&this._options.onAnyVariableChanged(e),this._options.onVariableUpdateCompleted&&(this._isWaitingForVariables||i)&&this._options.onVariableUpdateCompleted(),i&&(this._options.onReferencedVariableValueChanged&&this._options.onReferencedVariableValueChanged(e),this._options.onReferencedVariableValueChanged||this._options.onVariableUpdateCompleted||this._sceneObject.forceRender())}hasDependencyInLoadingState(){return tm.hasVariableDependencyInLoadingState(this._sceneObject)?(this._isWaitingForVariables=!0,!0):(this._isWaitingForVariables=!1,!1)}getNames(){const e=this._state,t=this._state=this._sceneObject.state;if(!e)return this.scanStateForDependencies(this._state),this._dependencies;if(t!==e)if(this._statePaths){for(const n of this._statePaths)if("*"===n||t[n]!==e[n]){this.scanStateForDependencies(t);break}}else this.scanStateForDependencies(t);return this._dependencies}setVariableNames(e){this._options.variableNames=e,this.scanStateForDependencies(this._state)}setPaths(e){this._statePaths=e}scanStateForDependencies(e){if(this._dependencies.clear(),this.scanCount+=1,this._options.variableNames)for(const e of this._options.variableNames)this._dependencies.add(e);if(this._statePaths)for(const t of this._statePaths){if("*"===t){this.extractVariablesFrom(e);break}{const n=e[t];n&&this.extractVariablesFrom(n)}}}extractVariablesFrom(e){Pf.lastIndex=0;const t=("string"!=typeof e?hy(e):e).matchAll(Pf);if(t)for(const e of t){const[,t,n,,r]=e,i=t||n||r;this._dependencies.add(i)}}}class am{constructor(){this._values=new Map}recordCurrentDependencyValuesForSceneObject(e){if(this.clearValues(),e.variableDependency)for(const t of e.variableDependency.getNames()){const n=tm.lookupVariable(t,e);n&&this._values.set(n.state.name,n.getValue())}}cloneAndRecordCurrentValuesForSceneObject(e){const t=new am;return t.recordCurrentDependencyValuesForSceneObject(e),t}clearValues(){this._values.clear()}hasValues(){return!!this._values}recordCurrentValue(e){this._values.set(e.state.name,e.getValue())}hasRecordedValue(e){return this._values.has(e.state.name)}hasValueChanged(e){if(this._values.has(e.state.name)){if(!py(this._values.get(e.state.name),e.getValue()))return!0}return!1}hasDependenciesChanged(e){if(!this._values)return!1;if(!e.variableDependency)return!1;for(const t of e.variableDependency.getNames()){const n=tm.lookupVariable(t,e);if(!n)continue;const r=n.state.name;if(n&&this._values.has(r)){if(!py(this._values.get(r),n.getValue()))return!0}}return!1}}function om(e){return"object"==typeof e&&"getExtraQueries"in e}var sm=Object.defineProperty,lm=Object.defineProperties,cm=Object.getOwnPropertyDescriptors,um=Object.getOwnPropertySymbols,dm=Object.prototype.hasOwnProperty,pm=Object.prototype.propertyIsEnumerable,hm=(e,t,n)=>t in e?sm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const fm=(e,t)=>(0,qp.of)(t),mm=e=>t=>t.pipe((0,qp.mergeMap)((([t,...n])=>{const r=n.flatMap((n=>{var r,i;return null!=(i=null==(r=e.get(n.request.requestId))?void 0:r(t,n))?i:(0,qp.of)(n)}));return(0,qp.forkJoin)([(0,qp.of)(t),...r])})),(0,qp.map)((([e,...t])=>{var n;return((e,t)=>lm(e,cm(t)))(((e,t)=>{for(var n in t||(t={}))dm.call(t,n)&&hm(e,n,t[n]);if(um)for(var n of um(t))pm.call(t,n)&&hm(e,n,t[n]);return e})({},e),{series:[...e.series,...t.flatMap((e=>e.series))],annotations:[...null!=(n=e.annotations)?n:[],...t.flatMap((e=>{var t;return null!=(t=e.annotations)?t:[]}))]})})));var gm=Object.defineProperty,ym=Object.defineProperties,bm=Object.getOwnPropertyDescriptors,vm=Object.getOwnPropertySymbols,wm=Object.prototype.hasOwnProperty,Sm=Object.prototype.propertyIsEnumerable,Em=(e,t,n)=>t in e?gm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xm=(e,t)=>{for(var n in t||(t={}))wm.call(t,n)&&Em(e,n,t[n]);if(vm)for(var n of vm(t))Sm.call(t,n)&&Em(e,n,t[n]);return e},Om=(e,t)=>ym(e,bm(t));function _m(e){const t=e.getRoot();return If(t)?t.enrichDataRequest(e):null}let Tm,Cm=new Set;function km(e){return t=>{const n=tm.getQueryController(e.origin);return n?new qp.Observable((r=>{e.cancel||(e.cancel=()=>r.complete()),n.queryStarted(e);let i=!1;const a=t.subscribe({next:t=>{i||t.state===qh.Loading||(i=!0,n.queryCompleted(e)),r.next(t)},error:e=>r.error(e),complete:()=>{r.complete()}});return()=>{a.unsubscribe(),i||n.queryCompleted(e)}})):t}}const Pm=new Set;function Rm(e,t){e.setState(t)}class Am extends bh{constructor(){super(...arguments),this._urlSync=new Dm(this)}validateAndUpdate(){return this.getValueOptions({}).pipe((0,qp.map)((e=>(this.updateValueGivenNewOptions(e),{}))))}onCancel(){this.setStateHelper({loading:!1});const e=this.parent;null==e||e.cancel(this)}updateValueGivenNewOptions(e){const{value:t,text:n}=this.state,r=this.getStateUpdateGivenNewOptions(e,t,n);this.interceptStateUpdateAfterValidation(r),this.setStateHelper(r),(r.value!==t||r.text!==n||this.hasAllValue())&&this.publishEvent(new pf(this),!0)}getStateUpdateGivenNewOptions(e,t,n){const r={options:e,loading:!1,value:t,text:n};if(0===e.length)return this.state.defaultToAll||this.state.includeAll?(r.value=Cf,r.text=Tf):this.state.isMulti?(r.value=[],r.text=[]):(r.value="",r.text=""),r;if(this.hasAllValue())return this.state.includeAll||(r.value=e[0].value,r.text=e[0].label,this.state.isMulti&&(r.value=[r.value],r.text=[r.text])),r;if(this.state.isMulti){const i=(Array.isArray(t)?t:[t]).filter((t=>e.find((e=>e.value===t)))),a=i.map((t=>e.find((e=>e.value===t)).label));if(0===i.length){const t=this.getDefaultMultiState(e);r.value=t.value,r.text=t.text}else(0,$c.isEqual)(i,t)||(r.value=i),(0,$c.isEqual)(a,n)||(r.text=a);return r}let i=function(e,t,n){let r;for(const i of n){if(i.value===e)return i;i.label===t&&(r=i)}return r}(t,n,e);return i?(r.text=i.label,r.value=i.value):this.state.defaultToAll?(r.value=Cf,r.text=Tf):(r.value=e[0].value,r.text=e[0].label),r}interceptStateUpdateAfterValidation(e){const t=e.value===Cf&&this.state.text===Tf;this.skipNextValidation&&e.value!==this.state.value&&!t&&(e.value=this.state.value,e.text=this.state.text),this.skipNextValidation=!1}getValue(){return this.hasAllValue()?this.state.allValue?new jm(this.state.allValue,this):this.state.options.map((e=>e.value)):this.state.value}getValueText(){return this.hasAllValue()?Tf:Array.isArray(this.state.text)?this.state.text.join(" + "):String(this.state.text)}hasAllValue(){const e=this.state.value;return e===Cf||Array.isArray(e)&&e[0]===Cf}getDefaultMultiState(e){return this.state.defaultToAll?{value:[Cf],text:[Tf]}:e.length>0?{value:[e[0].value],text:[e[0].label]}:{value:[],text:[]}}changeValueTo(e,t){if(e!==this.state.value||t!==this.state.text){if(t||(t=Array.isArray(e)?e.map((e=>this.findLabelTextForValue(e))):this.findLabelTextForValue(e)),Array.isArray(e)){if(0===e.length){const n=this.getDefaultMultiState(this.state.options);e=n.value,t=n.text}e[e.length-1]===Cf?(e=[Cf],t=[Tf]):e[0]===Cf&&e.length>1&&(e.shift(),Array.isArray(t)&&t.shift())}(0,$c.isEqual)(e,this.state.value)&&(0,$c.isEqual)(t,this.state.text)||(this.setStateHelper({value:e,text:t,loading:!1}),this.publishEvent(new pf(this),!0))}}findLabelTextForValue(e){if(e===Cf)return Tf;const t=this.state.options.find((t=>t.value===e));if(t)return t.label;const n=this.state.options.find((t=>t.label===e));return n?n.label:e}setStateHelper(e){Rm(this,e)}getOptionsForSelect(){let e=this.state.options;if(this.state.includeAll&&(e=[{value:Cf,label:Tf},...e]),!Array.isArray(this.state.value)){const t=e.find((e=>e.value===this.state.value));t||(e=[{value:this.state.value,label:String(this.state.text)},...e])}return e}}class Dm{constructor(e){this._sceneObject=e}getKey(){return`var-${this._sceneObject.state.name}`}getKeys(){return this._sceneObject.state.skipUrlSync?[]:[this.getKey()]}getUrlState(){if(this._sceneObject.state.skipUrlSync)return{};let e=null,t=this._sceneObject.state.value;return e=Array.isArray(t)?t.map(String):this._sceneObject.state.isMulti?[String(t)]:String(t),{[this.getKey()]:e}}updateFromUrl(e){let t=e[this.getKey()];null!=t&&(this._sceneObject.state.includeAll&&(t=function(e){if((0,$c.isArray)(e)&&e[0]===Tf)return[Cf];if(e===Tf)return Cf;return e}(t)),this._sceneObject.state.allValue&&this._sceneObject.state.allValue===t&&(t=Cf),this._sceneObject.isActive||(this._sceneObject.skipNextValidation=!0),this._sceneObject.changeValueTo(t))}}class jm{constructor(e,t){this._value=e,this._variable=t}formatter(e){return e===Uh.Text?Tf:e===Uh.PercentEncode?bf.get(Uh.PercentEncode).formatter(this._value,[],this._variable):e===Uh.QueryParam?bf.get(Uh.QueryParam).formatter(Tf,[],this._variable):this._value}}const Im={RadioButton:{container:"data-testid radio-button"},Breadcrumbs:{breadcrumb:e=>`data-testid ${e} breadcrumb`},TimePicker:{openButton:"data-testid TimePicker Open Button",overlayContent:"data-testid TimePicker Overlay Content",fromField:"data-testid Time Range from field",toField:"data-testid Time Range to field",applyTimeRange:"data-testid TimePicker submit button",copyTimeRange:"data-testid TimePicker copy button",pasteTimeRange:"data-testid TimePicker paste button",calendar:{label:"data-testid Time Range calendar",openButton:"data-testid Open time range calendar",closeButton:"data-testid Close time range Calendar"},absoluteTimeRangeTitle:"data-testid-absolute-time-range-narrow"},DataSourcePermissions:{form:()=>'form[name="addPermission"]',roleType:"Role to add new permission to",rolePicker:"Built-in role picker",permissionLevel:"Permission Level"},DateTimePicker:{input:"data-testid date-time-input"},DataSource:{TestData:{QueryTab:{scenarioSelectContainer:"Test Data Query scenario select container",scenarioSelect:"Test Data Query scenario select",max:"TestData max",min:"TestData min",noise:"TestData noise",seriesCount:"TestData series count",spread:"TestData spread",startValue:"TestData start value",drop:"TestData drop values"}},DataSourceHttpSettings:{urlInput:"data-testid Datasource HTTP settings url"},Jaeger:{traceIDInput:"Trace ID"},Prometheus:{configPage:{connectionSettings:"Data source connection URL",manageAlerts:"prometheus-alerts-manager",scrapeInterval:"data-testid scrape interval",queryTimeout:"data-testid query timeout",defaultEditor:"data-testid default editor",disableMetricLookup:"disable-metric-lookup",prometheusType:"data-testid prometheus type",prometheusVersion:"data-testid prometheus version",cacheLevel:"data-testid cache level",incrementalQuerying:"prometheus-incremental-querying",queryOverlapWindow:"data-testid query overlap window",disableRecordingRules:"disable-recording-rules",customQueryParameters:"data-testid custom query parameters",httpMethod:"data-testid http method",exemplarsAddButton:"data-testid Add exemplar config button",internalLinkSwitch:"data-testid Internal link switch",codeModeMetricNamesSuggestionLimit:"data-testid code mode metric names suggestion limit"},queryEditor:{explain:"data-testid prometheus explain switch wrapper",editorToggle:"data-testid QueryEditorModeToggle",options:"data-testid prometheus options",legend:"data-testid prometheus legend wrapper",format:"data-testid prometheus format",step:"prometheus-step",type:"data-testid prometheus type",exemplars:"prometheus-exemplars",builder:{metricSelect:"data-testid metric select",hints:"data-testid prometheus hints",metricsExplorer:"data-testid metrics explorer",queryAdvisor:"data-testid query advisor"},code:{queryField:"data-testid prometheus query field",metricsCountInfo:"data-testid metrics count disclaimer",metricsBrowser:{openButton:"data-testid open metrics browser",selectMetric:"data-testid select a metric",seriesLimit:"data-testid series limit",metricList:"data-testid metric list",labelNamesFilter:"data-testid label names filter",labelValuesFilter:"data-testid label values filter",useQuery:"data-testid use query",useAsRateQuery:"data-testid use as rate query",validateSelector:"data-testid validate selector",clear:"data-testid clear"}}},exemplarMarker:"data-testid Exemplar marker",variableQueryEditor:{queryType:"data-testid query type",labelnames:{metricRegex:"data-testid label names metric regex"},labelValues:{labelSelect:"data-testid label values label select"},metricNames:{metricRegex:"data-testid metric names metric regex"},varQueryResult:"data-testid variable query result",seriesQuery:"data-testid prometheus series query",classicQuery:"data-testid prometheus classic query"},annotations:{minStep:"prometheus-annotation-min-step",title:"data-testid prometheus annotation title",tags:"data-testid prometheus annotation tags",text:"data-testid prometheus annotation text",seriesValueAsTimestamp:"data-testid prometheus annotation series value as timestamp"}}},Menu:{MenuComponent:e=>`${e} menu`,MenuGroup:e=>`${e} menu group`,MenuItem:e=>`${e} menu item`,SubMenu:{container:"data-testid SubMenu container",icon:"data-testid SubMenu icon"}},Panels:{Panel:{title:e=>`data-testid Panel header ${e}`,content:"data-testid panel content",headerItems:e=>`data-testid Panel header item ${e}`,menuItems:e=>`data-testid Panel menu item ${e}`,menu:e=>`data-testid Panel menu ${e}`,containerByTitle:e=>`${e} panel`,headerCornerInfo:e=>`Panel header ${e}`,status:e=>`data-testid Panel status ${e}`,loadingBar:()=>"Panel loading bar",HoverWidget:{container:"data-testid hover-header-container",dragIcon:"data-testid drag-icon"},PanelDataErrorMessage:"data-testid Panel data error message"},Visualization:{Graph:{container:"Graph container",VisualizationTab:{legendSection:"Legend section"},Legend:{legendItemAlias:e=>`gpl alias ${e}`,showLegendSwitch:"gpl show legend"},xAxis:{labels:()=>"div.flot-x-axis > div.flot-tick-label"}},BarGauge:{value:"Bar gauge value",valueV2:"data-testid Bar gauge value"},PieChart:{svgSlice:"data testid Pie Chart Slice"},Text:{container:()=>".markdown-html"},Table:{header:"table header",footer:"table-footer",body:"data-testid table body"}}},VizLegend:{seriesName:e=>`data-testid VizLegend series ${e}`},Drawer:{General:{title:e=>`Drawer title ${e}`,expand:"Drawer expand",contract:"Drawer contract",close:"data-testid Drawer close",rcContentWrapper:()=>".rc-drawer-content-wrapper",subtitle:"data-testid drawer subtitle"},DashboardSaveDrawer:{saveButton:"data-testid Save dashboard drawer button",saveAsButton:"data-testid Save as dashboard drawer button",saveAsTitleInput:"Save dashboard title field"}},PanelEditor:{General:{content:"data-testid Panel editor content"},OptionsPane:{content:"data-testid Panel editor option pane content",select:"Panel editor option pane select",fieldLabel:e=>`${e} field property editor`,fieldInput:e=>`data-testid Panel editor option pane field input ${e}`},DataPane:{content:"data-testid Panel editor data pane content"},applyButton:"data-testid Apply changes and go back to dashboard",toggleVizPicker:"data-testid toggle-viz-picker",toggleVizOptions:"data-testid toggle-viz-options",toggleTableView:"data-testid toggle-table-view",showZoomField:"Map controls Show zoom control field property editor",showAttributionField:"Map controls Show attribution field property editor",showScaleField:"Map controls Show scale field property editor",showMeasureField:"Map controls Show measure tools field property editor",showDebugField:"Map controls Show debug field property editor",measureButton:"show measure tools"},PanelInspector:{Data:{content:"Panel inspector Data content"},Stats:{content:"Panel inspector Stats content"},Json:{content:"data-testid Panel inspector Json content"},Query:{content:"Panel inspector Query content",refreshButton:"Panel inspector Query refresh button",jsonObjectKeys:()=>".json-formatter-key"}},Tab:{title:e=>`data-testid Tab ${e}`,active:()=>'[class*="-activeTabStyle"]'},RefreshPicker:{runButton:"RefreshPicker run button",intervalButton:"RefreshPicker interval button",runButtonV2:"data-testid RefreshPicker run button",intervalButtonV2:"data-testid RefreshPicker interval button"},QueryTab:{content:"Query editor tab content",queryInspectorButton:"Query inspector button",queryHistoryButton:"data-testid query-history-button",addQuery:"data-testid query-tab-add-query",queryGroupTopSection:"data-testid query group top section",addExpression:"data-testid query-tab-add-expression"},QueryHistory:{queryText:"Query text"},QueryEditorRows:{rows:"Query editor row"},QueryEditorRow:{actionButton:e=>`data-testid ${e}`,title:e=>`Query editor row title ${e}`,container:e=>`Query editor row ${e}`},AlertTab:{content:"data-testid Alert editor tab content"},AlertRules:{groupToggle:"data-testid group-collapse-toggle",toggle:"data-testid collapse-toggle",expandedContent:"data-testid expanded-content",previewButton:"data-testid alert-rule preview-button",ruleNameField:"data-testid alert-rule name-field",newFolderButton:"data-testid alert-rule new-folder-button",newFolderNameField:"data-testid alert-rule name-folder-name-field",newFolderNameCreateButton:"data-testid alert-rule name-folder-name-create-button",newEvaluationGroupButton:"data-testid alert-rule new-evaluation-group-button",newEvaluationGroupName:"data-testid alert-rule new-evaluation-group-name",newEvaluationGroupInterval:"data-testid alert-rule new-evaluation-group-interval",newEvaluationGroupCreate:"data-testid alert-rule new-evaluation-group-create-button"},Alert:{alert:e=>`Alert ${e}`,alertV2:e=>`data-testid Alert ${e}`},TransformTab:{content:"data-testid Transform editor tab content",newTransform:e=>`data-testid New transform ${e}`,transformationEditor:e=>`data-testid Transformation editor ${e}`,transformationEditorDebugger:e=>`data-testid Transformation editor debugger ${e}`},Transforms:{card:e=>`data-testid New transform ${e}`,disableTransformationButton:"data-testid Disable transformation button",Reduce:{modeLabel:"data-testid Transform mode label",calculationsLabel:"data-testid Transform calculations label"},SpatialOperations:{actionLabel:"root Action field property editor",locationLabel:"root Location Mode field property editor",location:{autoOption:"Auto location option",coords:{option:"Coords location option",latitudeFieldLabel:"root Latitude field field property editor",longitudeFieldLabel:"root Longitude field field property editor"},geohash:{option:"Geohash location option",geohashFieldLabel:"root Geohash field field property editor"},lookup:{option:"Lookup location option",lookupFieldLabel:"root Lookup field field property editor",gazetteerFieldLabel:"root Gazetteer field property editor"}}},searchInput:"data-testid search transformations",noTransformationsMessage:"data-testid no transformations message",addTransformationButton:"data-testid add transformation button",removeAllTransformationsButton:"data-testid remove all transformations button"},NavBar:{Configuration:{button:"Configuration"},Toggle:{button:"data-testid Toggle menu"},Reporting:{button:"Reporting"}},NavMenu:{Menu:"data-testid navigation mega-menu",item:"data-testid Nav menu item"},NavToolbar:{container:"data-testid Nav toolbar",shareDashboard:"data-testid Share dashboard",markAsFavorite:"data-testid Mark as favorite",editDashboard:{editButton:"data-testid Edit dashboard button",saveButton:"data-testid Save dashboard button",exitButton:"data-testid Exit edit mode button",settingsButton:"data-testid Dashboard settings",addRowButton:"data-testid Add row button",addLibraryPanelButton:"data-testid Add a panel from the panel library button",addVisualizationButton:"data-testid Add new visualization menu item",pastePanelButton:"data-testid Paste panel button",discardChangesButton:"data-testid Discard changes button",discardLibraryPanelButton:"data-testid Discard library panel button",unlinkLibraryPanelButton:"data-testid Unlink library panel button",saveLibraryPanelButton:"data-testid Save library panel button",backToDashboardButton:"data-testid Back to dashboard button"}},PageToolbar:{container:()=>".page-toolbar",item:e=>`${e}`,itemButton:e=>`data-testid ${e}`},QueryEditorToolbarItem:{button:e=>`QueryEditor toolbar item button ${e}`},BackButton:{backArrow:"data-testid Go Back"},OptionsGroup:{group:e=>e?`data-testid Options group ${e}`:"data-testid Options group",toggle:e=>e?`data-testid Options group ${e} toggle`:"data-testid Options group toggle"},PluginVisualization:{item:e=>`Plugin visualization item ${e}`,current:()=>'[class*="-currentVisualizationItem"]'},Select:{option:"data-testid Select option",toggleAllOptions:"data-testid toggle all options",input:()=>'input[id*="time-options-input"]',singleValue:()=>'div[class*="-singleValue"]'},FieldConfigEditor:{content:"Field config editor content"},OverridesConfigEditor:{content:"Field overrides editor content"},FolderPicker:{container:"Folder picker select container",containerV2:"data-testid Folder picker select container",input:"data-testid folder-picker-input"},ReadonlyFolderPicker:{container:"data-testid Readonly folder picker select container"},DataSourcePicker:{container:"data-testid Data source picker select container",input:()=>'input[id="data-source-picker"]',inputV2:"data-testid Select a data source",dataSourceList:"data-testid Data source list dropdown",advancedModal:{dataSourceList:"data-testid Data source list",builtInDataSourceList:"data-testid Built in data source list"}},TimeZonePicker:{container:"Time zone picker select container",containerV2:"data-testid Time zone picker select container",changeTimeSettingsButton:"data-testid Time zone picker Change time settings button"},WeekStartPicker:{container:"Choose starting day of the week",containerV2:"data-testid Choose starting day of the week",placeholder:"Choose starting day of the week"},TraceViewer:{spanBar:"data-testid SpanBar--wrapper"},QueryField:{container:"data-testid Query field"},QueryBuilder:{queryPatterns:"data-testid Query patterns",labelSelect:"data-testid Select label",inputSelect:"data-testid Select label-input",valueSelect:"data-testid Select value",matchOperatorSelect:"data-testid Select match operator"},ValuePicker:{button:e=>`data-testid Value picker button ${e}`,select:e=>`data-testid Value picker select ${e}`},Search:{section:"Search section",sectionV2:"data-testid Search section",items:"Search items",itemsV2:"data-testid Search items",cards:"data-testid Search cards",collapseFolder:e=>`data-testid Collapse folder ${e}`,expandFolder:e=>`data-testid Expand folder ${e}`,dashboardItem:e=>`${Im.Search.dashboardItems} ${e}`,dashboardCard:e=>`data-testid Search card ${e}`,folderHeader:e=>`data-testid Folder header ${e}`,folderContent:e=>`data-testid Folder content ${e}`,dashboardItems:"data-testid Dashboard search item"},DashboardLinks:{container:"data-testid Dashboard link container",dropDown:"data-testid Dashboard link dropdown",link:"data-testid Dashboard link"},LoadingIndicator:{icon:"data-testid Loading indicator"},CallToActionCard:{button:e=>`Call to action button ${e}`,buttonV2:e=>`data-testid Call to action button ${e}`},DataLinksContextMenu:{singleLink:"data-testid Data link"},CodeEditor:{container:"data-testid Code editor container"},ReactMonacoEditor:{editorLazy:"data-testid ReactMonacoEditor editorLazy"},DashboardImportPage:{textarea:"data-testid-import-dashboard-textarea",submit:"data-testid-load-dashboard"},ImportDashboardForm:{name:"data-testid-import-dashboard-title",submit:"data-testid-import-dashboard-submit"},PanelAlertTabContent:{content:"data-testid Unified alert editor tab content"},VisualizationPreview:{card:e=>`data-testid suggestion-${e}`},ColorSwatch:{name:"data-testid-colorswatch"},DashboardRow:{title:e=>`data-testid dashboard-row-title-${e}`},UserProfile:{profileSaveButton:"data-testid-user-profile-save",preferencesSaveButton:"data-testid-shared-prefs-save",orgsTable:"data-testid-user-orgs-table",sessionsTable:"data-testid-user-sessions-table",extensionPointTabs:"data-testid-extension-point-tabs",extensionPointTab:e=>`data-testid-extension-point-tab-${e}`},FileUpload:{inputField:"data-testid-file-upload-input-field",fileNameSpan:"data-testid-file-upload-file-name"},DebugOverlay:{wrapper:"debug-overlay"},OrgRolePicker:{input:"Role"},AnalyticsToolbarButton:{button:"Dashboard insights"},Variables:{variableOption:"data-testid variable-option",variableLinkWrapper:"data-testid variable-link-wrapper"},Annotations:{annotationsTypeInput:"data-testid annotations-type-input",annotationsChoosePanelInput:"data-testid choose-panels-input",editor:{testButton:"data-testid annotations-test-button",resultContainer:"data-testid annotations-query-result-container"}},Tooltip:{container:"data-testid tooltip"},ReturnToPrevious:{buttonGroup:"data-testid dismissable button group",backButton:"data-testid back",dismissButton:"data-testid dismiss"},SQLQueryEditor:{selectColumn:"data-testid select-column",selectAggregation:"data-testid select-aggregation",selectAlias:"data-testid select-alias",filterConjunction:"data-testid filter-conjunction",filterField:"data-testid filter-field",filterOperator:"data-testid filter-operator",headerTableSelector:"data-testid header-table-selector",headerFilterSwitch:"data-testid header-filter-switch",headerGroupSwitch:"data-testid header-group-switch",headerOrderSwitch:"data-testid header-order-switch",headerPreviewSwitch:"data-testid header-preview-switch"},EntityNotFound:{container:"data-testid entity-not-found"}},Nm={Login:{url:"/login",username:"data-testid Username input field",password:"data-testid Password input field",submit:"data-testid Login button",skip:"data-testid Skip change password button"},Home:{url:"/"},DataSource:{name:"data-testid Data source settings page name input field",delete:"Data source settings page Delete button",readOnly:"data-testid Data source settings page read only message",saveAndTest:"data-testid Data source settings page Save and Test button",alert:"data-testid Data source settings page Alert"},DataSources:{url:"/datasources",dataSources:e=>`Data source list item ${e}`},EditDataSource:{url:e=>`/datasources/edit/${e}`,settings:"Datasource settings page basic settings"},AddDataSource:{url:"/datasources/new",dataSourcePlugins:e=>`Data source plugin item ${e}`,dataSourcePluginsV2:e=>`Add new data source ${e}`},ConfirmModal:{delete:"data-testid Confirm Modal Danger Button"},AddDashboard:{url:"/dashboard/new",itemButton:e=>`data-testid ${e}`,addNewPanel:"data-testid Add new panel",addNewRow:"data-testid Add new row",addNewPanelLibrary:"data-testid Add new panel from panel library"},Dashboard:{url:e=>`/d/${e}`,DashNav:{nav:"Dashboard navigation",navV2:"data-testid Dashboard navigation",publicDashboardTag:"data-testid public dashboard tag",shareButton:"data-testid share-button",scrollContainer:"data-testid Dashboard canvas scroll container",newShareButton:{container:"data-testid new share button",shareLink:"data-testid new share link-button",arrowMenu:"data-testid new share button arrow menu",menu:{container:"data-testid new share button menu",shareInternally:"data-testid new share button share internally",shareExternally:"data-testid new share button share externally",shareSnapshot:"data-testid new share button share snapshot"}},NewExportButton:{container:"data-testid new export button",arrowMenu:"data-testid new export button arrow menu",Menu:{container:"data-testid new export button menu",exportAsJson:"data-testid new export button export as json"}},playlistControls:{prev:"data-testid playlist previous dashboard button",stop:"data-testid playlist stop dashboard button",next:"data-testid playlist next dashboard button"}},Controls:"data-testid dashboard controls",SubMenu:{submenu:"Dashboard submenu",submenuItem:"data-testid template variable",submenuItemLabels:e=>`data-testid Dashboard template variables submenu Label ${e}`,submenuItemValueDropDownValueLinkTexts:e=>`data-testid Dashboard template variables Variable Value DropDown value link text ${e}`,submenuItemValueDropDownDropDown:"Variable options",submenuItemValueDropDownOptionTexts:e=>`data-testid Dashboard template variables Variable Value DropDown option text ${e}`,Annotations:{annotationsWrapper:"data-testid annotation-wrapper",annotationLabel:e=>`data-testid Dashboard annotations submenu Label ${e}`,annotationToggle:e=>`data-testid Dashboard annotations submenu Toggle ${e}`}},Settings:{Actions:{close:"data-testid dashboard-settings-close"},General:{deleteDashBoard:"data-testid Dashboard settings page delete dashboard button",sectionItems:e=>`Dashboard settings section item ${e}`,saveDashBoard:"Dashboard settings aside actions Save button",saveAsDashBoard:"Dashboard settings aside actions Save As button",timezone:"Time zone picker select container",title:"General"},Annotations:{List:{addAnnotationCTA:Im.CallToActionCard.button("Add annotation query"),addAnnotationCTAV2:Im.CallToActionCard.buttonV2("Add annotation query"),annotations:"data-testid list-annotations"},Settings:{name:"data-testid Annotations settings name input"},NewAnnotation:{panelFilterSelect:"data-testid annotations-panel-filter",showInLabel:"data-testid show-in-label",previewInDashboard:"data-testid annotations-preview",delete:"data-testid annotations-delete",apply:"data-testid annotations-apply",enable:"data-testid annotation-enable",hide:"data-testid annotation-hide"}},Variables:{List:{addVariableCTA:Im.CallToActionCard.button("Add variable"),addVariableCTAV2:Im.CallToActionCard.buttonV2("Add variable"),newButton:"Variable editor New variable button",table:"Variable editor Table",tableRowNameFields:e=>`Variable editor Table Name field ${e}`,tableRowDefinitionFields:e=>`Variable editor Table Definition field ${e}`,tableRowArrowUpButtons:e=>`Variable editor Table ArrowUp button ${e}`,tableRowArrowDownButtons:e=>`Variable editor Table ArrowDown button ${e}`,tableRowDuplicateButtons:e=>`Variable editor Table Duplicate button ${e}`,tableRowRemoveButtons:e=>`Variable editor Table Remove button ${e}`},Edit:{General:{headerLink:"Variable editor Header link",modeLabelNew:"Variable editor Header mode New",modeLabelEdit:"Variable editor Header mode Edit",generalNameInput:"Variable editor Form Name field",generalNameInputV2:"data-testid Variable editor Form Name field",generalTypeSelect:"Variable editor Form Type select",generalTypeSelectV2:"data-testid Variable editor Form Type select",generalLabelInput:"Variable editor Form Label field",generalLabelInputV2:"data-testid Variable editor Form Label field",generalHideSelect:"Variable editor Form Hide select",generalHideSelectV2:"data-testid Variable editor Form Hide select",selectionOptionsMultiSwitch:"data-testid Variable editor Form Multi switch",selectionOptionsIncludeAllSwitch:"data-testid Variable editor Form IncludeAll switch",selectionOptionsCustomAllInput:"data-testid Variable editor Form IncludeAll field",previewOfValuesOption:"data-testid Variable editor Preview of Values option",submitButton:"data-testid Variable editor Run Query button",applyButton:"data-testid Variable editor Apply button"},QueryVariable:{queryOptionsDataSourceSelect:Im.DataSourcePicker.inputV2,queryOptionsRefreshSelect:"Variable editor Form Query Refresh select",queryOptionsRefreshSelectV2:"data-testid Variable editor Form Query Refresh select",queryOptionsRegExInput:"Variable editor Form Query RegEx field",queryOptionsRegExInputV2:"data-testid Variable editor Form Query RegEx field",queryOptionsSortSelect:"Variable editor Form Query Sort select",queryOptionsSortSelectV2:"data-testid Variable editor Form Query Sort select",queryOptionsQueryInput:"data-testid Variable editor Form Default Variable Query Editor textarea",valueGroupsTagsEnabledSwitch:"Variable editor Form Query UseTags switch",valueGroupsTagsTagsQueryInput:"Variable editor Form Query TagsQuery field",valueGroupsTagsTagsValuesQueryInput:"Variable editor Form Query TagsValuesQuery field"},ConstantVariable:{constantOptionsQueryInput:"Variable editor Form Constant Query field",constantOptionsQueryInputV2:"data-testid Variable editor Form Constant Query field"},DatasourceVariable:{datasourceSelect:"data-testid datasource variable datasource type"},TextBoxVariable:{textBoxOptionsQueryInput:"Variable editor Form TextBox Query field",textBoxOptionsQueryInputV2:"data-testid Variable editor Form TextBox Query field"},CustomVariable:{customValueInput:"data-testid custom-variable-input"},IntervalVariable:{intervalsValueInput:"data-testid interval variable intervals input",autoEnabledCheckbox:"data-testid interval variable auto value checkbox",stepCountIntervalSelect:"data-testid interval variable step count input",minIntervalInput:"data-testid interval variable mininum interval input"},GroupByVariable:{dataSourceSelect:Im.DataSourcePicker.inputV2,infoText:"data-testid group by variable info text",modeToggle:"data-testid group by variable mode toggle"},AdHocFiltersVariable:{datasourceSelect:Im.DataSourcePicker.inputV2,infoText:"data-testid ad-hoc filters variable info text",modeToggle:"data-testid ad-hoc filters variable mode toggle"}}}},Annotations:{marker:"data-testid annotation-marker"},Rows:{Repeated:{ConfigSection:{warningMessage:"data-testid Repeated rows warning message"}}}},Dashboards:{url:"/dashboards",dashboards:e=>`Dashboard search item ${e}`},SaveDashboardAsModal:{newName:"Save dashboard title field",save:"Save dashboard button"},SaveDashboardModal:{save:"Dashboard settings Save Dashboard Modal Save button",saveVariables:"Dashboard settings Save Dashboard Modal Save variables checkbox",saveTimerange:"Dashboard settings Save Dashboard Modal Save timerange checkbox",saveRefresh:"Dashboard settings Save Dashboard Modal Save refresh checkbox"},SharePanelModal:{linkToRenderedImage:"Link to rendered image"},ShareDashboardModal:{PublicDashboard:{WillBePublicCheckbox:"data-testid public dashboard will be public checkbox",LimitedDSCheckbox:"data-testid public dashboard limited datasources checkbox",CostIncreaseCheckbox:"data-testid public dashboard cost may increase checkbox",PauseSwitch:"data-testid public dashboard pause switch",EnableAnnotationsSwitch:"data-testid public dashboard on off switch for annotations",CreateButton:"data-testid public dashboard create button",DeleteButton:"data-testid public dashboard delete button",CopyUrlInput:"data-testid public dashboard copy url input",CopyUrlButton:"data-testid public dashboard copy url button",SettingsDropdown:"data-testid public dashboard settings dropdown",TemplateVariablesWarningAlert:"data-testid public dashboard disabled template variables alert",UnsupportedDataSourcesWarningAlert:"data-testid public dashboard unsupported data sources alert",NoUpsertPermissionsWarningAlert:"data-testid public dashboard no upsert permissions alert",EnableTimeRangeSwitch:"data-testid public dashboard on off switch for time range",EmailSharingConfiguration:{Container:"data-testid email sharing config container",ShareType:"data-testid public dashboard share type",EmailSharingInput:"data-testid public dashboard email sharing input",EmailSharingInviteButton:"data-testid public dashboard email sharing invite button",EmailSharingList:"data-testid public dashboard email sharing list",DeleteEmail:"data-testid public dashboard delete email button",ReshareLink:"data-testid public dashboard reshare link button"}},SnapshotScene:{url:e=>`/dashboard/snapshot/${e}`,PublishSnapshot:"data-testid publish snapshot button",CopyUrlButton:"data-testid snapshot copy url button",CopyUrlInput:"data-testid snapshot copy url input"}},ShareDashboardDrawer:{ShareInternally:{container:"data-testid share internally drawer container",lockTimeRangeSwitch:"data-testid share internally lock time range switch",shortenUrlSwitch:"data-testid share internally shorten url switch",copyUrlButton:"data-testid share internally copy url button"},ShareExternally:{container:"data-testid share externally drawer container",publicAlert:"data-testid public share alert",emailSharingAlert:"data-testid email share alert",shareTypeSelect:"data-testid share externally share type select",Creation:{PublicShare:{createButton:"data-testid public share dashboard create button",cancelButton:"data-testid public share dashboard cancel button"},EmailShare:{createButton:"data-testid email share dashboard create button",cancelButton:"data-testid email share dashboard cancel button"},willBePublicCheckbox:"data-testid share dashboard will be public checkbox"},Configuration:{enableTimeRangeSwitch:"data-testid share externally enable time range switch",enableAnnotationsSwitch:"data-testid share externally enable annotations switch",copyUrlButton:"data-testid share externally copy url button",revokeAccessButton:"data-testid share externally revoke access button",toggleAccessButton:"data-testid share externally pause or resume access button"}},ShareSnapshot:{url:e=>`/dashboard/snapshot/${e}`,container:"data-testid share snapshot drawer container",publishSnapshot:"data-testid share snapshot publish button",copyUrlButton:"data-testid share snapshot copy url button"}},ExportDashboardDrawer:{ExportAsJson:{container:"data-testid export as json drawer container",codeEditor:"data-testid export as json code editor",exportExternallyToggle:"data-testid export as json externally switch",saveToFileButton:"data-testid export as json save to file button",copyToClipboardButton:"data-testid export as json copy to clipboard button",cancelButton:"data-testid export as json cancel button"}},PublicDashboard:{page:"public-dashboard-page",NotAvailable:{container:"public-dashboard-not-available",title:"public-dashboard-title",pausedDescription:"public-dashboard-paused-description"},footer:"public-dashboard-footer"},PublicDashboardScene:{loadingPage:"public-dashboard-scene-loading-page",page:"public-dashboard-scene-page",controls:"public-dashboard-controls"},RequestViewAccess:{form:"request-view-access-form",recipientInput:"request-view-access-recipient-input",submitButton:"request-view-access-submit-button"},PublicDashboardConfirmAccess:{submitButton:"data-testid confirm-access-submit-button"},Explore:{url:"/explore",General:{container:"data-testid Explore",graph:"Explore Graph",table:"Explore Table",scrollView:"data-testid explorer scroll view"},QueryHistory:{container:"data-testid QueryHistory"}},SoloPanel:{url:e=>`/d-solo/${e}`},PluginsList:{page:"Plugins list page",list:"Plugins list",listItem:"Plugins list item",signatureErrorNotice:"data-testid Unsigned plugins notice"},PluginPage:{page:"Plugin page",signatureInfo:"data-testid Plugin signature info",disabledInfo:"data-testid Plugin disabled info"},PlaylistForm:{name:"Playlist name",interval:"Playlist interval",itemDelete:"data-testid playlist-form-delete-item"},BrowseDashboards:{table:{body:"data-testid browse-dashboards-table",row:e=>`data-testid browse dashboards row ${e}`,checkbox:e=>`data-testid ${e} checkbox`},NewFolderForm:{form:"data-testid new folder form",nameInput:"data-testid new-folder-name-input",createButton:"data-testid new-folder-create-button"}},Search:{url:"/?search=openn",FolderView:{url:"/?search=open&layout=folders"}},PublicDashboards:{ListItem:{linkButton:"public-dashboard-link-button",configButton:"public-dashboard-configuration-button",trashcanButton:"public-dashboard-remove-button",pauseSwitch:"data-testid public dashboard pause switch"}},UserListPage:{tabs:{allUsers:"data-testid all-users-tab",orgUsers:"data-testid org-users-tab",anonUserDevices:"data-testid anon-user-devices-tab",publicDashboardsUsers:"data-testid public-dashboards-users-tab",users:"data-testid users-tab"},org:{url:"/org/users"},admin:{url:"/admin/users"},publicDashboards:{container:"data-testid public-dashboards-users-list"},UserListAdminPage:{container:"data-testid user-list-admin-page"},UsersListPage:{container:"data-testid users-list-page"},UserAnonListPage:{container:"data-testid user-anon-list-page"},UsersListPublicDashboardsPage:{container:"data-testid users-list-public-dashboards-page",DashboardsListModal:{listItem:e=>`data-testid dashboards-list-item-${e}`}}},ProfilePage:{url:"/profile"}},Lm={pages:Nm,components:Im},Mm=new Intl.Collator("en",{numeric:!0,sensitivity:"base"}).compare,Fm=1/0,$m=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Bm="eexxaacctt",Vm=/\p{P}/gu,zm=(e,t,n)=>e.replace("A-Z",t).replace("a-z",n),Um={unicode:!1,alpha:null,interSplit:"[^A-Za-z\\d']+",intraSplit:"[a-z][A-Z]",interBound:"[^A-Za-z\\d]",intraBound:"[A-Za-z]\\d|\\d[A-Za-z]|[a-z][A-Z]",interLft:0,interRgt:0,interChars:".",interIns:Fm,intraChars:"[a-z\\d']",intraIns:null,intraContr:"'[a-z]{1,2}\\b",intraMode:0,intraSlice:[1,Fm],intraSub:null,intraTrn:null,intraDel:null,intraFilt:(e,t,n)=>!0,sort:(e,t,n)=>{let{idx:r,chars:i,terms:a,interLft2:o,interLft1:s,start:l,intraIns:c,interIns:u,cases:d}=e;return r.map(((e,t)=>t)).sort(((e,n)=>i[n]-i[e]||c[e]-c[n]||a[n]+o[n]+.5*s[n]-(a[e]+o[e]+.5*s[e])||u[e]-u[n]||l[e]-l[n]||d[n]-d[e]||Mm(t[r[e]],t[r[n]])))}},qm=(e,t)=>0==t?"":1==t?e+"??":t==Fm?e+"*?":e+`{0,${t}}?`,Hm="(?:\\b|_)";function Gm(e){e=Object.assign({},Um,e);let{unicode:t,interLft:n,interRgt:r,intraMode:i,intraSlice:a,intraIns:o,intraSub:s,intraTrn:l,intraDel:c,intraContr:u,intraSplit:d,interSplit:p,intraBound:h,interBound:f,intraChars:m}=e;o??=i,s??=i,l??=i,c??=i;let g=e.letters??e.alpha;if(null!=g){let e=g.toLocaleUpperCase(),t=g.toLocaleLowerCase();p=zm(p,e,t),d=zm(d,e,t),f=zm(f,e,t),h=zm(h,e,t),m=zm(m,e,t),u=zm(u,e,t)}let y=t?"u":"";const b='".+?"',v=new RegExp(b,"gi"+y),w=new RegExp(`(?:\\s+|^)-(?:${m}+|${b})`,"gi"+y);let{intraRules:S}=e;null==S&&(S=e=>{let t=Um.intraSlice,n=0,r=0,i=0,u=0;if(/[^\d]/.test(e)){let d=e.length;d<=4?d>=3&&(i=Math.min(l,1),4==d&&(n=Math.min(o,1))):(t=a,n=o,r=s,i=l,u=c)}return{intraSlice:t,intraIns:n,intraSub:r,intraTrn:i,intraDel:u}});let E=!!d,x=new RegExp(d,"g"+y),O=new RegExp(p,"g"+y),_=new RegExp("^"+p+"|"+p+"$","g"+y),T=new RegExp(u,"gi"+y);const C=(e,t=!1)=>{let n=[];e=e.replace(v,(e=>(n.push(e),Bm))),e=e.replace(_,""),t||(e=e.toLocaleLowerCase()),E&&(e=e.replace(x,(e=>e[0]+" "+e[1])));let r=0;return e.split(O).filter((e=>""!=e)).map((e=>e===Bm?n[r++]:e))},k=/[^\d]+|\d+/g,P=(t,a=0,s=!1)=>{let l=C(t);if(0==l.length)return[];let c,u=Array(l.length).fill("");if(l=l.map(((e,t)=>e.replace(T,(e=>(u[t]=e,""))))),1==i)c=l.map(((e,t)=>{if('"'===e[0])return $m(e.slice(1,-1));let n="";for(let r of e.matchAll(k)){let e=r[0],{intraSlice:i,intraIns:a,intraSub:o,intraTrn:s,intraDel:l}=S(e);if(a+o+s+l==0)n+=e+u[t];else{let[r,c]=i,d=e.slice(0,r),p=e.slice(c),h=e.slice(r,c);1==a&&1==d.length&&d!=h[0]&&(d+="(?!"+d+")");let f=h.length,g=[e];if(o)for(let e=0;e0&&(e=")("+e+")("),c=l.map(((t,n)=>'"'===t[0]?$m(t.slice(1,-1)):t.split("").map(((e,t,n)=>(1==o&&0==t&&n.length>1&&e!=n[t+1]&&(e+="(?!"+e+")"),e))).join(e)+u[n]))}let d=2==n?Hm:"",p=2==r?Hm:"",h=p+qm(e.interChars,e.interIns)+d;return a>0?s?c=d+"("+c.join(")"+p+"|"+d+"(")+")"+p:(c="("+c.join(")("+h+")(")+")",c="(.??"+d+")"+c+"("+p+".*)"):(c=c.join(h),c=d+c+p),[new RegExp(c,"i"+y),l,u]},R=(e,t,n)=>{let[r]=P(t);if(null==r)return null;let i=[];if(null!=n)for(let t=0;t{let[o,s,l]=P(a,1),c=C(a,!0),[u]=P(a,2),d=s.length,p=Array(d),h=Array(d);for(let e=0;e=g){let e=l[i+1].toLocaleLowerCase().indexOf(o);e>-1&&(P.push(f,v,e,g),f+=N(l,i,e,g),a=o,v=g,R=!0,0==t&&(c=f))}if(b||R){let e=f-1,u=f+v,d=!1,p=!1;if(-1==e||D.test(s[e]))R&&w++,d=!0;else{if(2==n){m=!0;break}if(A&&j.test(s[e]+s[e+1]))R&&S++,d=!0;else if(1==n){let e=l[i+1],n=f+v;if(e.length>=g){let r,u=0,p=!1,h=new RegExp(o,"ig"+y);for(;r=h.exec(e);){u=r.index;let e=n+u,t=e-1;if(-1==t||D.test(s[t])){w++,p=!0;break}if(j.test(s[t]+s[e])){S++,p=!0;break}}p&&(d=!0,P.push(f,v,u,g),f+=N(l,i,u,g),a=o,v=g,R=!0,0==t&&(c=f))}if(!d){m=!0;break}}}if(u==s.length||D.test(s[u]))R&&E++,p=!0;else{if(2==r){m=!0;break}if(A&&j.test(s[u-1]+s[u]))R&&x++,p=!0;else if(1==r){m=!0;break}}R&&(O+=g,d&&p&&_++)}if(v>g&&(k+=v-g),t>0&&(C+=l[i-1].length),!e.intraFilt(o,a,f)){m=!0;break}t0?0:1/0,o=r-4;for(let t=2;t0&&(l.push(d,p),d=p=n)}p>d&&l.push(d,p),v++}}if(v{let i=e[t]+e[t+1].slice(0,n);return e[t-1]+=i,e[t]=e[t+1].slice(n,n+r),e[t+1]=e[t+1].slice(n+r),i.length};return{search:(...t)=>{let n=((t,n,r,i=1e3,a)=>{r=r?!0===r?5:r:0;let o=null,s=null,l=[];n=n.replace(w,(e=>{let t=e.trim().slice(1);return t='"'===t[0]?$m(t.slice(1,-1)):t.replace(Vm,""),""!=t&&l.push(t),""}));let c,u=C(n);if(l.length>0){if(c=new RegExp(l.join("|"),"i"+y),0==u.length){let e=[];for(let n=0;n0){let e=C(n);if(e.length>1){let n=e.slice().sort(((e,t)=>t.length-e.length));for(let e=0;er)return[a,null,null];o=Qm(e).map((e=>e.join(" "))),s=[];let i=new Set;for(let e=0;e!i.has(e))),r=R(t,o[e],n);for(let e=0;e0?a:R(t,n)]);let d=null,p=null;if(l.length>0&&(s=s.map((e=>e.filter((e=>!c.test(t[e])))))),s.reduce(((e,t)=>e+t.length),0)<=i){d={},p=[];for(let n=0;n0)for(let e=0;e{let e={A:"ÁÀÃÂÄĄ",a:"áàãâäą",E:"ÉÈÊËĖ",e:"éèêëę",I:"ÍÌÎÏĮ",i:"íìîïį",O:"ÓÒÔÕÖ",o:"óòôõö",U:"ÚÙÛÜŪŲ",u:"úùûüūų",C:"ÇČĆ",c:"çčć",L:"Ł",l:"ł",N:"ÑŃ",n:"ñń",S:"ŠŚ",s:"šś",Z:"ŻŹ",z:"żź"},t=new Map,n="";for(let r in e)e[r].split("").forEach((e=>{n+=e,t.set(e,r)}));let r=new RegExp(`[${n}]`,"g"),i=e=>t.get(e);return e=>{if("string"==typeof e)return e.replace(r,i);let t=Array(e.length);for(let n=0;nt?`${e}`:e,Ym=(e,t)=>e+t;function Xm(e,t){const n=new Gm;let r=e;const i=[],a=1e4;return t&&(r=[{value:Cf,label:Tf},...r]),e=>{if(""===e)return r.length>a?r.slice(0,a):r;if(0===i.length)for(let e=0;ea)return o;return o}return r.length>a?r.slice(0,a):r}}Gm.latinize=Wm,Gm.permute=e=>{let t=Qm([...Array(e.length).keys()]).sort(((e,t)=>{for(let n=0;nt.map((t=>e[t]))))},Gm.highlight=function(e,t,n=Km,r="",i=Ym){r=i(r,n(e.substring(0,t[0]),!1))??r;for(let a=0;at in e?Jm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const ag=()=>!0;function og({model:e}){const{value:t,text:n,key:r,options:i,includeAll:a,isReadOnly:s}=e.useState(),[l,c]=(0,Fi.useState)(""),[u,d]=(0,Fi.useState)(!1),p=function(e,t){return{value:e,label:null!=t?t:String(e)}}(t,String(n)),h=(0,Fi.useMemo)((()=>Xm(i,a)),[i,a])(l);return $i().createElement(o.Select,{id:r,isValidNewOption:e=>e.trim().length>0,placeholder:"Select value",width:"auto",disabled:s,value:p,inputValue:l,allowCustomValue:!0,virtualized:!0,filterOption:ag,tabSelectsValue:!1,onInputChange:(t,{action:n})=>"input-change"===n?(c(t),e.onSearchChange&&e.onSearchChange(t),t):t,onOpenMenu:()=>{u&&c(String(n))},onCloseMenu:()=>{c("")},options:h,"data-testid":Lm.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${t}`),onChange:t=>{e.changeValueTo(t.value,t.label),u!==t.__isNew__&&d(t.__isNew__)}})}function sg({model:e}){const{value:t,options:n,key:r,maxVisibleValues:i,noValueOnClear:a,includeAll:s,isReadOnly:l}=e.useState(),c=(0,Fi.useMemo)((()=>(0,$c.isArray)(t)?t:[t]),[t]),[u,d]=(0,Fi.useState)(c),[p,h]=(0,Fi.useState)(""),f=(0,Fi.useMemo)((()=>Xm(n,s)),[n,s]);(0,Fi.useEffect)((()=>{d(c)}),[c]);const m=n.length>0?"Select value":"",g=f(p);return $i().createElement(o.MultiSelect,{id:r,placeholder:m,width:"auto",inputValue:p,disabled:l,value:u,noMultiValueWrap:!0,maxVisibleValues:null!=i?i:5,tabSelectsValue:!1,virtualized:!0,allowCustomValue:!0,options:g,closeMenuOnSelect:!1,components:{Option:lg},isClearable:!0,hideSelectedOptions:!1,onInputChange:(t,{action:n})=>"input-change"===n?(h(t),e.onSearchChange&&e.onSearchChange(t),t):"input-blur"===n?(h(""),""):p,onBlur:()=>{e.changeValueTo(u)},filterOption:ag,"data-testid":Lm.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${u}`),onChange:(t,n)=>{"clear"===n.action&&a&&e.changeValueTo([]),d(t.map((e=>e.value)))}})}const lg=({children:e,data:t,innerProps:n,innerRef:r,isFocused:a,isSelected:s,renderOptionLabel:l})=>{var c;const u=((e,t)=>{var n={};for(var r in e)ng.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&tg)for(var r of tg(e))t.indexOf(r)<0&&rg.call(e,r)&&(n[r]=e[r]);return n})(n,["onMouseMove","onMouseOver"]),d=(0,o.useTheme2)(),p=(0,o.getSelectStyles)(d),h=(0,o.useStyles2)(cg);return $i().createElement("div",((e,t)=>Zm(e,eg(t)))(((e,t)=>{for(var n in t||(t={}))ng.call(t,n)&&ig(e,n,t[n]);if(tg)for(var n of tg(t))rg.call(t,n)&&ig(e,n,t[n]);return e})({ref:r,className:(0,i.cx)(p.option,a&&p.optionFocused)},u),{"data-testid":Lm.components.Select.option,title:t.title}),$i().createElement("div",{className:h.checkbox},$i().createElement(o.Checkbox,{value:s})),$i().createElement("div",{className:p.optionBody,"data-testid":Lm.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts(null!=(c=t.label)?c:String(t.value))},$i().createElement("span",null,e)))};lg.displayName="SelectMenuOptions";const cg=e=>({checkbox:(0,i.css)({marginRight:e.spacing(2)})});function ug(e){return e.state.isMulti?$i().createElement(sg,{model:e}):$i().createElement(og,{model:e})}class dg{constructor(e){this._sceneObject=e}getKey(){return`var-${this._sceneObject.state.name}`}getKeys(){return this._sceneObject.state.skipUrlSync?[]:[this.getKey()]}getUrlState(){return this._sceneObject.state.skipUrlSync?{}:{[this.getKey()]:pg(this._sceneObject.state.value,this._sceneObject.state.text)}}updateFromUrl(e){let t=e[this.getKey()];if(null!=t){this._sceneObject.isActive||(this._sceneObject.skipNextValidation=!0);const{values:e,texts:r}=(n=t,(n=Array.isArray(n)?n:[n]).reduce(((e,t)=>{const[n,r]=(null!=t?t:"").split(",");return e.values.push(wy(n)),e.texts.push(wy(null!=r?r:n)),e}),{values:[],texts:[]}));this._sceneObject.changeValueTo(e,r)}var n}}function pg(e,t){return e=Array.isArray(e)?e:[e],t=Array.isArray(t)?t:[t],e.map(((e,n)=>{if(null==e)return"";e=String(e);let r=t[n];return r=null==r?e:String(r),Sy(e,r)}))}function hg(e){const t=e.getRoot();return"enrichFiltersRequest"in t?t.enrichFiltersRequest(e):null}var fg=Object.defineProperty,mg=Object.defineProperties,gg=Object.getOwnPropertyDescriptors,yg=Object.getOwnPropertySymbols,bg=Object.prototype.hasOwnProperty,vg=Object.prototype.propertyIsEnumerable,wg=(e,t,n)=>t in e?fg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Sg=(e,t)=>{for(var n in t||(t={}))bg.call(t,n)&&wg(e,n,t[n]);if(yg)for(var n of yg(t))vg.call(t,n)&&wg(e,n,t[n]);return e};class Eg extends Am{constructor(e){super(((e,t)=>mg(e,gg(t)))(Sg({isMulti:!0,name:"",value:[],text:[],options:[],datasource:null,baseFilters:[],applyMode:"auto",layout:"horizontal",type:"groupby"},e),{noValueOnClear:!0})),this.isLazy=!0,this._urlSync=new dg(this),this._getKeys=async e=>{var t,n,r;const i=await(null==(n=(t=this.state).getTagKeysProvider)?void 0:n.call(t,this,null));if(i&&i.replace)return i.values;if(this.state.defaultOptions)return this.state.defaultOptions.concat(null!=(r=null==i?void 0:i.values)?r:[]);if(!e.getTagKeys)return[];const a=yy(this),o=this.state.baseFilters||[],s=tm.getTimeRange(this).state.value;let l=await e.getTagKeys(Sg({filters:o,queries:a,timeRange:s},hg(this)));i&&(l=l.concat(i.values));const c=this.state.tagKeyRegexFilter;return c&&(l=l.filter((e=>e.text.match(c)))),l},this.addActivationHandler((()=>(Pm.add(this),()=>Pm.delete(this))))}validateAndUpdate(){return this.getValueOptions({}).pipe((0,qp.map)((e=>(this._updateValueGivenNewOptions(e),{}))))}_updateValueGivenNewOptions(e){const{value:t,text:n}=this.state,r={options:e,loading:!1,value:null!=t?t:[],text:null!=n?n:[]};this.setState(r)}getValueOptions(e){return this.state.defaultOptions?(0,qp.of)(this.state.defaultOptions.map((e=>({label:e.text,value:String(e.value)})))):(this.setState({loading:!0,error:null}),(0,qp.from)(nm(this.state.datasource,{__sceneObject:{text:"__sceneObject",value:this}})).pipe((0,qp.mergeMap)((e=>(0,qp.from)(this._getKeys(e)).pipe((0,qp.take)(1),(0,qp.mergeMap)((e=>{const t=e.map((e=>({label:e.text,value:e.value?String(e.value):e.text})));return(0,qp.of)(t)})))))))}getDefaultMultiState(e){return{value:[],text:[]}}}Eg.Component=function({model:e}){const{value:t,text:n,key:r,maxVisibleValues:i,noValueOnClear:a,options:s,includeAll:l}=e.useState(),c=(0,Fi.useMemo)((()=>{const e=(0,$c.isArray)(t)?t:[t],r=(0,$c.isArray)(n)?n:[n];return e.map(((e,t)=>{var n;return{value:e,label:String(null!=(n=r[t])?n:e)}}))}),[t,n]),[u,d]=(0,Fi.useState)(!1),[p,h]=(0,Fi.useState)(!1),[f,m]=(0,Fi.useState)(""),[g,y]=(0,Fi.useState)(c),b=(0,Fi.useMemo)((()=>Xm(s,l)),[s,l]);(0,Fi.useEffect)((()=>{y(c)}),[c]);const v=b(f);return $i().createElement(o.MultiSelect,{"data-testid":`GroupBySelect-${r}`,id:r,placeholder:"Select value",width:"auto",inputValue:f,value:g,noMultiValueWrap:!0,maxVisibleValues:null!=i?i:5,tabSelectsValue:!1,virtualized:!0,options:v,filterOption:xg,closeMenuOnSelect:!1,isOpen:p,isClearable:!0,hideSelectedOptions:!1,isLoading:u,components:{Option:lg},onInputChange:(t,{action:n})=>"input-change"===n?(m(t),e.onSearchChange&&e.onSearchChange(t),t):"input-blur"===n?(m(""),""):f,onBlur:()=>{e.changeValueTo(g.map((e=>e.value)),g.map((e=>e.label)))},onChange:(t,n)=>{"clear"===n.action&&a&&e.changeValueTo([]),y(t)},onOpenMenu:async()=>{d(!0),await(0,qp.lastValueFrom)(e.validateAndUpdate()),d(!1),h(!0)},onCloseMenu:()=>{h(!1)}})};const xg=()=>!0;function Og(e){return $i().createElement(o.Tooltip,{content:"Cancel query"},$i().createElement(o.Icon,{className:"spin-clockwise",name:"sync",size:"xs",role:"button",onMouseDown:t=>{e.onCancel(t)}}))}function _g(e){const t=(0,o.useStyles2)(Tg),n=(0,o.useTheme2)(),r="vertical"===e.layout,i=Boolean(e.isLoading)?$i().createElement("div",{style:{marginLeft:n.spacing(1),marginTop:"-1px"},"aria-label":Lm.components.LoadingIndicator.icon},$i().createElement(Og,{onCancel:t=>{var n;t.preventDefault(),t.stopPropagation(),null==(n=e.onCancel)||n.call(e)}})):null;let a=null;e.error&&(a=$i().createElement(o.Tooltip,{content:e.error,placement:"bottom"},$i().createElement(o.Icon,{className:t.errorIcon,name:"exclamation-triangle"})));let s=null;e.description&&(s=$i().createElement(o.Tooltip,{content:e.description,placement:r?"top":"bottom"},$i().createElement(o.Icon,{className:t.normalIcon,name:"info-circle"})));const l="string"==typeof e.label?Lm.pages.Dashboard.SubMenu.submenuItemLabels(e.label):"";let c;return c=r?$i().createElement("label",{className:t.verticalLabel,"data-testid":l,htmlFor:e.htmlFor},e.label,s,a,e.icon&&$i().createElement(o.Icon,{name:e.icon,className:t.normalIcon}),i,e.onRemove&&$i().createElement(o.IconButton,{variant:"secondary",size:"xs",name:"times",onClick:e.onRemove,tooltip:"Remove"})):$i().createElement("label",{className:t.horizontalLabel,"data-testid":l,htmlFor:e.htmlFor},a,e.icon&&$i().createElement(o.Icon,{name:e.icon,className:t.normalIcon}),e.label,s,i),c}const Tg=e=>({horizontalLabel:(0,i.css)({background:e.isDark?e.colors.background.primary:e.colors.background.secondary,display:"flex",alignItems:"center",padding:e.spacing(0,1),fontWeight:e.typography.fontWeightMedium,fontSize:e.typography.bodySmall.fontSize,height:e.spacing(e.components.height.md),lineHeight:e.spacing(e.components.height.md),borderRadius:e.shape.borderRadius(1),border:`1px solid ${e.components.input.borderColor}`,position:"relative",right:-1,whiteSpace:"nowrap",gap:e.spacing(.5)}),verticalLabel:(0,i.css)({display:"flex",alignItems:"center",fontWeight:e.typography.fontWeightMedium,fontSize:e.typography.bodySmall.fontSize,lineHeight:e.typography.bodySmall.lineHeight,whiteSpace:"nowrap",marginBottom:e.spacing(.5),gap:e.spacing(1)}),errorIcon:(0,i.css)({color:e.colors.error.text}),normalIcon:(0,i.css)({color:e.colors.text.secondary})});function Cg(e){var t;return{label:null!=(t=e.label)?t:String(e.value),value:e.value}}function kg(e,t){return""!==e?{value:e,label:t||e}:null}const Pg=()=>!0;function Rg({filter:e,model:t}){var n,r;const a=(0,o.useStyles2)(Ag),[s,l]=(0,Fi.useState)([]),[c,u]=(0,Fi.useState)([]),[d,p]=(0,Fi.useState)(!1),[h,f]=(0,Fi.useState)(!1),[m,g]=(0,Fi.useState)(!1),[y,b]=(0,Fi.useState)(!1),[v,w]=(0,Fi.useState)(""),[S,E]=(0,Fi.useState)(!1),x=kg(e.key,e.keyLabel),O=kg(e.value,e.valueLabel),_=(0,Fi.useMemo)((()=>Xm(c.map(Cg),void 0)),[c])(v),T=$i().createElement(o.Select,{virtualized:!0,allowCustomValue:!0,isValidNewOption:e=>e.trim().length>0,allowCreateWhileLoading:!0,formatCreateLabel:e=>`Use custom value: ${e}`,disabled:t.state.readOnly,className:(0,i.cx)(a.value,m?a.widthWhenOpen:void 0),width:"auto",value:O,filterOption:Pg,placeholder:"Select value",options:_,inputValue:v,onInputChange:(e,{action:t})=>("input-change"===t&&w(e),e),onChange:n=>{t._updateFilter(e,"value",n),S!==n.__isNew__&&E(n.__isNew__)},isOpen:y&&!h,isLoading:h,autoFocus:""!==e.key&&""===e.value,openMenuOnFocus:!0,onOpenMenu:async()=>{var n;f(!0),b(!0);const r=await t._getValuesFor(e);f(!1),u(r),S&&w(null!=(n=null==O?void 0:O.label)?n:"")},onCloseMenu:()=>{b(!1),w("")}}),C=$i().createElement(o.Select,{key:""+(h?"loading":"loaded"),disabled:t.state.readOnly,className:(0,i.cx)(a.key,m?a.widthWhenOpen:void 0),width:"auto",value:x,placeholder:"Select label",options:s,onChange:n=>t._updateFilter(e,"key",n),autoFocus:""===e.key,isOpen:m&&!d,isLoading:d,onOpenMenu:async()=>{g(!0),p(!0);const n=await t._getKeys(e.key);p(!1),l(n)},onCloseMenu:()=>{g(!1)},onBlur:()=>{""===e.key&&t._removeFilter(e)},openMenuOnFocus:!0});if("vertical"===t.state.layout){if(e.key){const r=$i().createElement(_g,{layout:"vertical",label:null!=(n=e.key)?n:"",onRemove:()=>t._removeFilter(e)});return $i().createElement(o.Field,{label:r,"data-testid":`AdHocFilter-${e.key}`,className:a.field},$i().createElement("div",{className:a.wrapper},$i().createElement(o.Select,{className:a.operator,value:e.operator,disabled:t.state.readOnly,options:t._getOperators(),width:"auto",onChange:n=>t._updateFilter(e,"operator",n)}),T))}return $i().createElement(o.Field,{label:"Select label","data-testid":`AdHocFilter-${e.key}`,className:a.field},C)}return $i().createElement("div",{className:a.wrapper,"data-testid":`AdHocFilter-${e.key}`},C,$i().createElement(o.Select,{className:a.operator,value:e.operator,disabled:t.state.readOnly,options:t._getOperators(),width:"auto",onChange:n=>t._updateFilter(e,"operator",n)}),T,$i().createElement(o.Button,{variant:"secondary","aria-label":"Remove filter",title:"Remove filter",className:a.removeButton,icon:"times","data-testid":`AdHocFilter-remove-${null!=(r=e.key)?r:""}`,onClick:()=>t._removeFilter(e)}))}const Ag=e=>({field:(0,i.css)({marginBottom:0}),wrapper:(0,i.css)({display:"flex","> *":{"&:not(:first-child)":{marginLeft:-1},"&:first-child":{borderTopRightRadius:0,borderBottomRightRadius:0},"&:last-child":{borderTopLeftRadius:0,borderBottomLeftRadius:0},"&:not(:first-child):not(:last-child)":{borderRadius:0},position:"relative",zIndex:0,"&:hover":{zIndex:1},"&:focus-within":{zIndex:2}}}),widthWhenOpen:(0,i.css)({minWidth:e.spacing(16)}),value:(0,i.css)({flexShrink:1}),key:(0,i.css)({minWidth:"90px",flexShrink:1}),operator:(0,i.css)({flexShrink:0}),removeButton:(0,i.css)({paddingLeft:e.spacing(1.5),paddingRight:e.spacing(1.5),borderLeft:"none",width:e.spacing(3),marginRight:e.spacing(1),boxSizing:"border-box",position:"relative",left:"1px"})});function Dg({model:e,addFilterButtonText:t}){const{_wip:n}=e.useState();return n?$i().createElement(Rg,{filter:n,model:e}):$i().createElement(o.Button,{variant:"secondary",icon:"plus",title:"Add filter","aria-label":"Add filter","data-testid":"AdHocFilter-add",onClick:()=>e._addWip()},t)}class jg{constructor(e){this._variable=e}getKey(){return`var-${this._variable.state.name}`}getKeys(){return[this.getKey()]}getUrlState(){const e=this._variable.state.filters;if(0===e.length)return{[this.getKey()]:[""]};const t=e.filter(Kg).map((e=>function(e){return[Sy(e.key,e.keyLabel),e.operator,Sy(e.value,e.valueLabel)]}(e).map(by).join("|")));return{[this.getKey()]:t}}updateFromUrl(e){const t=e[this.getKey()];if(null==t)return;const n=function(e){if(Array.isArray(e)){return e.map(Ig).filter(Ng)}const t=Ig(e);return null===t?[]:[t]}(t);this._variable.setState({filters:n})}}function Ig(e){if("string"!=typeof e||0===e.length)return null;const[t,n,r,i,a,o]=e.split("|").reduce(((e,t)=>{const[n,r]=t.split(",");return e.push(n,null!=r?r:n),e}),[]).map(wy);return{key:t,keyLabel:n,operator:r,value:a,valueLabel:o,condition:""}}function Ng(e){return null!==e&&"string"==typeof e.key&&"string"==typeof e.value}var Lg=Object.defineProperty,Mg=Object.defineProperties,Fg=Object.getOwnPropertyDescriptors,$g=Object.getOwnPropertySymbols,Bg=Object.prototype.hasOwnProperty,Vg=Object.prototype.propertyIsEnumerable,zg=(e,t,n)=>t in e?Lg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ug=(e,t)=>{for(var n in t||(t={}))Bg.call(t,n)&&zg(e,n,t[n]);if($g)for(var n of $g(t))Vg.call(t,n)&&zg(e,n,t[n]);return e},qg=(e,t)=>Mg(e,Fg(t));class Hg extends bh{constructor(e){var t,n;super(Ug({type:"adhoc",name:null!=(t=e.name)?t:"Filters",filters:[],datasource:null,applyMode:"auto",filterExpression:null!=(n=e.filterExpression)?n:Gg(e.expressionBuilder,e.filters)},e)),this._scopedVars={__sceneObject:{value:this}},this._dataSourceSrv=(0,a.getDataSourceSrv)(),this._urlSync=new jg(this),"auto"===this.state.applyMode&&function(e){if(e.addActivationHandler((()=>(Cm.add(e),()=>Cm.delete(e)))),Tm)return;const t=(0,a.getTemplateSrv)();(null==t?void 0:t.getAdhocFilters)&&(Tm=t.getAdhocFilters,t.getAdhocFilters=function(e){var n;if(0===Cm.size)return Tm.call(t);const r=(0,a.getDataSourceSrv)().getInstanceSettings(e);if(!r)return[];for(const e of Cm.values())if((null==(n=e.state.datasource)?void 0:n.uid)===r.uid)return e.state.filters;return[]}.bind(t))}(this)}setState(e){let t=!1;e.filters&&e.filters!==this.state.filters&&!e.filterExpression&&(e.filterExpression=Gg(this.state.expressionBuilder,e.filters),t=e.filterExpression!==this.state.filterExpression),super.setState(e),t&&this.publishEvent(new pf(this),!0)}getValue(){return this.state.filterExpression}_updateFilter(e,t,{value:n,label:r}){if(null==n)return;const{filters:i,_wip:a}=this.state,o=`${t}Label`;if(e===a)return void("value"===t?this.setState({filters:[...i,qg(Ug({},a),{[t]:n,[o]:r})],_wip:void 0}):this.setState({_wip:qg(Ug({},e),{[t]:n,[o]:r})}));const s=this.state.filters.map((i=>{if(i===e){const a=qg(Ug({},i),{[t]:n,[o]:r});return"key"===t&&e[t]!==n&&(a.value="",a.valueLabel=""),a}return i}));this.setState({filters:s})}_removeFilter(e){e!==this.state._wip?this.setState({filters:this.state.filters.filter((t=>t!==e))}):this.setState({_wip:void 0})}async _getKeys(e){var t,n,r;const i=await(null==(n=(t=this.state).getTagKeysProvider)?void 0:n.call(t,this,e));if(i&&i.replace)return i.values.map(Qg);if(this.state.defaultKeys)return this.state.defaultKeys.map(Qg);const a=await this._dataSourceSrv.get(this.state.datasource,this._scopedVars);if(!a||!a.getTagKeys)return[];const o=this.state.filters.filter((t=>t.key!==e)).concat(null!=(r=this.state.baseFilters)?r:[]),s=tm.getTimeRange(this).state.value,l=this.state.useQueriesAsFilterForOptions?yy(this):void 0;let c=await a.getTagKeys(Ug({filters:o,queries:l,timeRange:s},hg(this)));i&&(c=c.concat(i.values));const u=this.state.tagKeyRegexFilter;return u&&(c=c.filter((e=>e.text.match(u)))),c.map(Qg)}async _getValuesFor(e){var t,n,r;const i=await(null==(n=(t=this.state).getTagValuesProvider)?void 0:n.call(t,this,e));if(i&&i.replace)return Yg(i.values);const a=await this._dataSourceSrv.get(this.state.datasource,this._scopedVars);if(!a||!a.getTagValues)return[];const o=this.state.filters.filter((t=>t.key!==e.key)).concat(null!=(r=this.state.baseFilters)?r:[]),s=tm.getTimeRange(this).state.value,l=this.state.useQueriesAsFilterForOptions?yy(this):void 0;let c=await a.getTagValues(Ug({key:e.key,filters:o,timeRange:s,queries:l},hg(this)));return i&&(c=c.concat(i.values)),Yg(c)}_addWip(){this.setState({_wip:{key:"",keyLabel:"",value:"",valueLabel:"",operator:"=",condition:""}})}_getOperators(){return["=","!=","<",">","=~","!~"].map((e=>({label:e,value:e})))}}function Gg(e,t){return(null!=e?e:fy)(null!=t?t:[])}Hg.Component=function({model:e}){const{filters:t,readOnly:n,addFilterButtonText:r}=e.useState(),i=(0,o.useStyles2)(Wg);return $i().createElement("div",{className:i.wrapper},t.map(((t,n)=>$i().createElement($i().Fragment,{key:n},$i().createElement(Rg,{filter:t,model:e})))),!n&&$i().createElement(Dg,{model:e,key:"'builder",addFilterButtonText:r}))};const Wg=e=>({wrapper:(0,i.css)({display:"flex",flexWrap:"wrap",alignItems:"flex-end",columnGap:e.spacing(2),rowGap:e.spacing(1)}),filterIcon:(0,i.css)({color:e.colors.text.secondary,paddingRight:e.spacing(.5)})});function Qg({text:e,value:t}){return{label:e,value:String(null!=t?t:e)}}function Kg(e){return""!==e.key&&""!==e.operator&&""!==e.value}function Yg(e){const t=[],n=new Map;for(const r of e){const e=r.group;if(e){let i=n.get(e);i||(i=[],n.set(e,i),t.push({label:e,options:i})),i.push(Qg(r))}else t.push(Qg(r))}return t}class Xg{constructor(){this._resultsMap=new Map,this._prevLayers=[]}getMergedStream(e){(function(e,t){if(e.length!==t.length)return!0;for(let n=0;ne.getResultsStream())),n=[];for(const t of e)n.push(t.activate());return(0,qp.merge)(t).pipe((0,qp.mergeAll)(),(0,qp.filter)((e=>this._resultsMap.get(e.origin.state.key)!==e)),(0,qp.map)((e=>(this._resultsMap.set(e.origin.state.key,e),this._resultsMap.values()))),(0,qp.finalize)((()=>{n.forEach((e=>e()))})))}}var Jg=Object.defineProperty,Zg=Object.defineProperties,ey=Object.getOwnPropertyDescriptors,ty=Object.getOwnPropertySymbols,ny=Object.prototype.hasOwnProperty,ry=Object.prototype.propertyIsEnumerable,iy=(e,t,n)=>t in e?Jg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ay=(e,t)=>{for(var n in t||(t={}))ny.call(t,n)&&iy(e,n,t[n]);if(ty)for(var n of ty(t))ry.call(t,n)&&iy(e,n,t[n]);return e},oy=(e,t)=>Zg(e,ey(t));let sy=100;function ly(){return"SQR"+sy++}class cy extends bh{constructor(e){super(e),this._dataLayersMerger=new Xg,this._variableValueRecorder=new am,this._results=new qp.ReplaySubject(1),this._scopedVars={__sceneObject:{value:this,text:"__sceneObject"}},this._variableDependency=new im(this,{statePaths:["queries","datasource"],onVariableUpdateCompleted:this.onVariableUpdatesCompleted.bind(this),onAnyVariableChanged:this.onAnyVariableChanged.bind(this)}),this.onDataReceived=e=>{const t=(0,r.preProcessPanelData)(e,this.state.data);this._resultAnnotations=e.annotations;const n=this._combineDataLayers(t);let i=this.state._hasFetchedData;i||t.state===qh.Loading||(i=!0),this.setState({data:n,_hasFetchedData:i}),this._results.next({origin:this,data:n})},this.addActivationHandler((()=>this._onActivate()))}getResultsStream(){return this._results}_onActivate(){const e=tm.getTimeRange(this),t=this.getClosestExtraQueryProviders();for(const e of t)this._subs.add(e.subscribeToState(((t,n)=>{e.shouldRerun(n,t)&&this.runQueries()})));return this.subscribeToTimeRangeChanges(e),this.shouldRunQueriesOnActivate()&&this.runQueries(),this._dataLayersSub||this._handleDataLayers(),()=>this._onDeactivate()}_handleDataLayers(){const e=tm.getDataLayers(this);0!==e.length&&(this._dataLayersSub=this._dataLayersMerger.getMergedStream(e).subscribe(this._onLayersReceived.bind(this)))}_onLayersReceived(e){var t,n,i,a,o;const s=tm.getTimeRange(this),{dataLayerFilter:l}=this.state;let c,u=[],d=[];for(const i of e)for(let e of i.data.series)(null==(t=e.meta)?void 0:t.dataTopic)===r.DataTopic.Annotations&&(u=u.concat(e)),(null==(n=e.meta)?void 0:n.dataTopic)===r.DataTopic.AlertStates&&(d=d.concat(e));if((null==l?void 0:l.panelId)&&(u.length>0&&(u=function(e,t){var n;if(!Array.isArray(e)||0===e.length)return e;const r=Array.from({length:e.length},(()=>new Set));let i=0;for(const a of e){for(let e=0;e"panelId"===e.name)),l=a.fields.find((e=>"source"===e.name));if(l){s&&"dashboard"===l.values[e].type&&(o=s.values[e]===t.panelId);const r=l.values[e].filter;if(r){const e=(null!=(n=r.ids)?n:[]).includes(t.panelId);r.exclude?e&&(o=!1):e||(o=!1)}}o&&r[i].add(e)}i++}const a=[];i=0;for(const t of e){const e=r[i].size,n=[];for(const e of t.fields){const a=[];for(let n=0;n0))for(const e of d){const t=new r.DataFrameView(e);for(const e of t)if(e.panelId===l.panelId){c=e;break}}if(dy(u)&&dy(this._layerAnnotations)&&(0,$c.isEqual)(c,null==(i=this.state.data)?void 0:i.alertState))return;this._layerAnnotations=u;const p=this.state.data?this.state.data:oy(ay({},Yh),{timeRange:s.state.value});this.setState({data:oy(ay({},p),{annotations:[...null!=(a=this._resultAnnotations)?a:[],...u],alertState:null!=c?c:null==(o=this.state.data)?void 0:o.alertState})})}onVariableUpdatesCompleted(){this.runQueries()}onAnyVariableChanged(e){this._adhocFiltersVar!==e&&this._groupByVar!==e&&(e instanceof Hg&&this._isRelevantAutoVariable(e)&&this.runQueries(),e instanceof Eg&&this._isRelevantAutoVariable(e)&&this.runQueries())}_isRelevantAutoVariable(e){var t,n;const r=null!=(t=this.state.datasource)?t:uy(this.state.queries);return"auto"===e.state.applyMode&&(null==r?void 0:r.uid)===(null==(n=e.state.datasource)?void 0:n.uid)}shouldRunQueriesOnActivate(){return this._variableValueRecorder.hasDependenciesChanged(this)?(rm(),!0):!this.state.data||!!this._isDataTimeRangeStale(this.state.data)}_isDataTimeRangeStale(e){const t=tm.getTimeRange(this).state.value,n=e.timeRange;return(t.from.unix()!==n.from.unix()||t.to.unix()!==n.to.unix())&&(rm(),!0)}_onDeactivate(){var e;this._querySub&&(this._querySub.unsubscribe(),this._querySub=void 0),this._dataLayersSub&&(this._dataLayersSub.unsubscribe(),this._dataLayersSub=void 0),null==(e=this._timeSub)||e.unsubscribe(),this._timeSub=void 0,this._timeSubRange=void 0,this._adhocFiltersVar=void 0,this._groupByVar=void 0,this._variableValueRecorder.recordCurrentDependencyValuesForSceneObject(this)}setContainerWidth(e){!this._containerWidth&&e>0?(this._containerWidth=e,this.state.maxDataPointsFromWidth&&!this.state.maxDataPoints&&setTimeout((()=>{this.isActive&&!this.state._hasFetchedData&&this.runQueries()}),0)):e>0&&(this._containerWidth=e)}isDataReadyToDisplay(){return Boolean(this.state._hasFetchedData)}subscribeToTimeRangeChanges(e){this._timeSubRange!==e&&(this._timeSub&&this._timeSub.unsubscribe(),this._timeSubRange=e,this._timeSub=e.subscribeToState((()=>{this.runWithTimeRange(e)})))}runQueries(){const e=tm.getTimeRange(this);this.subscribeToTimeRangeChanges(e),this.runWithTimeRange(e)}getMaxDataPoints(){var e;return this.state.maxDataPoints?this.state.maxDataPoints:this.state.maxDataPointsFromWidth&&null!=(e=this._containerWidth)?e:500}cancelQuery(){var e;null==(e=this._querySub)||e.unsubscribe(),this._dataLayersSub&&(this._dataLayersSub.unsubscribe(),this._dataLayersSub=void 0),this.setState({data:oy(ay({},this.state.data),{state:qh.Done})})}async runWithTimeRange(e){var t,n;if(!this.state.maxDataPoints&&this.state.maxDataPointsFromWidth&&!this._containerWidth)return;if(this._dataLayersSub||this._handleDataLayers(),null==(t=this._querySub)||t.unsubscribe(),this._variableDependency.hasDependencyInLoadingState())return rm(),void this.setState({data:oy(ay({},this.state.data),{state:qh.Loading})});const{queries:r}=this.state;if(null==r?void 0:r.length)try{const t=null!=(n=this.state.datasource)?n:uy(r),i=await nm(t,this._scopedVars);this.findAndSubscribeToAdHocFilters(null==t?void 0:t.uid);const o=(0,a.getRunRequest)(),{primary:s,secondaries:l,processors:c}=this.prepareRequests(e,i);rm(0,0,this.state.key);let u=o(i,s);if(l.length>0){const e=l.map((e=>o(i,e))),t=mm(c);u=(0,qp.forkJoin)([u,...e]).pipe(t)}u=u.pipe(km({type:"data",request:s,origin:this,cancel:()=>this.cancelQuery()})),this._querySub=u.subscribe(this.onDataReceived)}catch(e){console.error("PanelQueryRunner Error",e),this.onDataReceived(oy(ay(ay({},Yh),this.state.data),{state:qh.Error,errors:[(0,a.toDataQueryError)(e)]}))}else this._setNoDataState()}clone(e){var t;const n=super.clone(e);return this._resultAnnotations&&(n._resultAnnotations=this._resultAnnotations.map((e=>ay({},e)))),this._layerAnnotations&&(n._layerAnnotations=this._layerAnnotations.map((e=>ay({},e)))),n._variableValueRecorder=this._variableValueRecorder.cloneAndRecordCurrentValuesForSceneObject(this),n._containerWidth=this._containerWidth,n._results.next({origin:this,data:null!=(t=this.state.data)?t:Yh}),n}prepareRequests(e,t){var n;const{minInterval:i,queries:o}=this.state;let s=ay({app:"scenes",requestId:ly(),timezone:e.getTimeZone(),range:e.state.value,interval:"1s",intervalMs:1e3,targets:(0,$c.cloneDeep)(o),maxDataPoints:this.getMaxDataPoints(),scopedVars:this._scopedVars,startTime:Date.now(),liveStreaming:this.state.liveStreaming,rangeRaw:{from:e.state.from,to:e.state.to},cacheTimeout:this.state.cacheTimeout,queryCachingTTL:this.state.queryCachingTTL},_m(this));this._adhocFiltersVar&&(s.filters=this._adhocFiltersVar.state.filters.filter(Kg)),this._groupByVar&&(s.groupByKeys=this._groupByVar.state.value),s.targets=s.targets.map((e=>{var n;return e.datasource&&(e.datasource.uid===t.uid||(null==(n=t.meta)?void 0:n.mixed)||!a.isExpressionReference||(0,a.isExpressionReference)(e.datasource))||(e.datasource=t.getRef()),e}));const l=i||t.interval,c=r.rangeUtil.calculateInterval(e.state.value,s.maxDataPoints,l);s.scopedVars=Object.assign({},s.scopedVars,{__interval:{text:c.interval,value:c.interval},__interval_ms:{text:c.intervalMs.toString(),value:c.intervalMs}}),s.interval=c.interval,s.intervalMs=c.intervalMs;const u=e.state.value;let d=[],p=new Map;for(const e of null!=(n=this.getClosestExtraQueryProviders())?n:[])for(const{req:t,processor:n}of e.getExtraQueries(s)){const e=ly();d.push(oy(ay({},t),{requestId:e})),p.set(e,null!=n?n:fm)}return s.range=u,{primary:s,secondaries:d,processors:p}}_combineDataLayers(e){return this._layerAnnotations&&this._layerAnnotations.length>0&&(e.annotations=(e.annotations||[]).concat(this._layerAnnotations)),this.state.data&&this.state.data.alertState&&(e.alertState=this.state.data.alertState),e}_setNoDataState(){this.state.data!==Yh&&this.setState({data:Yh})}getClosestExtraQueryProviders(){const e=new Map;return this.parent?(kh(this.parent,(t=>(om(t)&&!e.has(t.constructor)&&e.set(t.constructor,t),t.forEachChild((t=>{om(t)&&!e.has(t.constructor)&&e.set(t.constructor,t)})),null))),Array.from(e.values())):[]}findAndSubscribeToAdHocFilters(e){const t=function(e){var t;for(const n of Cm.values())if((null==(t=n.state.datasource)?void 0:t.uid)===e)return n}(e);this._adhocFiltersVar!==t&&(this._adhocFiltersVar=t,this._updateExplicitVariableDependencies());const n=function(e){var t;for(const n of Pm.values())if((null==(t=n.state.datasource)?void 0:t.uid)===e)return n}(e);this._groupByVar!==n&&(this._groupByVar=n,this._updateExplicitVariableDependencies())}_updateExplicitVariableDependencies(){const e=[];this._adhocFiltersVar&&e.push(this._adhocFiltersVar.state.name),this._groupByVar&&e.push(this._groupByVar.state.name),this._variableDependency.setVariableNames(e)}}function uy(e){var t,n;return null!=(n=null==(t=e.find((e=>null!==e.datasource)))?void 0:t.datasource)?n:void 0}function dy(e){if(!e)return!0;for(let t=0;t0)return!1;return!0}function py(e,t){return e===t||(0,$c.isEqual)(e,t)}function hy(e){try{return JSON.stringify(e,(()=>{const e=new WeakSet;return(t,n)=>{if("object"==typeof n&&null!==n){if(e.has(n))return;e.add(n)}return n}})())}catch(e){console.error(e)}return""}function fy(e){return e.map((e=>function(e){let t="";t="=~"===e.operator||"!~¨"===e.operator?my(function(e){return e.replace(gy,"\\$&")}(e.value)):my(e.value);return`${e.key}${e.operator}"${t}"`}(e))).join(",")}function my(e){return e.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/"/g,'\\"')}const gy=/[*+?()|\\.\[\]{}^$]/g;function yy(e){const t=tm.findAllObjects(e.getRoot(),(e=>e instanceof cy)),n=function(e){const t={};for(const n of e)n.state.key&&(n.state.key in t||(t[n.state.key]=[]),t[n.state.key].push(n));return Object.values(t).flatMap((e=>{const t=e.filter((e=>e.isActive));return 0===t.length&&1===e.length?e:t}))}(t).filter((t=>{var n,r;return(null==(n=t.state.datasource)?void 0:n.uid)===(null==(r=e.state.datasource)?void 0:r.uid)}));if(0===n.length)return[];const r=[];return n.forEach((e=>{r.push(...e.state.queries)})),r}function by(e){return null==e?"":/\|/g[Symbol.replace](e,"__gfp__")}function vy(e){return null==e?"":/,/g[Symbol.replace](e,"__gfc__")}function wy(e){return null==e?"":(e=/__gfp__/g[Symbol.replace](e,"|"),e=/__gfc__/g[Symbol.replace](e,","))}function Sy(e,t){return t&&e!==t?[e,t].map(vy).join(","):vy(e)}var Ey=(e=>(e[e.never=0]="never",e[e.onDashboardLoad=1]="onDashboardLoad",e[e.onTimeRangeChanged=2]="onTimeRangeChanged",e))(Ey||{});var xy=(e=>(e[e.Crosshair=1]="Crosshair",e[e.Off=0]="Off",e[e.Tooltip=2]="Tooltip",e))(xy||{});var Oy=Object.defineProperty,_y=Object.defineProperties,Ty=Object.getOwnPropertyDescriptors,Cy=Object.getOwnPropertySymbols,ky=Object.prototype.hasOwnProperty,Py=Object.prototype.propertyIsEnumerable,Ry=(e,t,n)=>t in e?Oy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class Ay extends bh{constructor(e){super(((e,t)=>_y(e,Ty(t)))(((e,t)=>{for(var n in t||(t={}))ky.call(t,n)&&Ry(e,n,t[n]);if(Cy)for(var n of Cy(t))Py.call(t,n)&&Ry(e,n,t[n]);return e})({},e),{sync:e.sync||xy.Off})),this.getEventsBus=e=>{if(!this.parent)throw new Error("EnableCursorSync cannot be used as a standalone scene object");return new Dy(this.parent,e)}}getEventsScope(){if(!this.parent)throw new Error("EnableCursorSync cannot be used as a standalone scene object");return this.state.key}}class Dy{constructor(e,t){this._source=e,this._eventsOrigin=t}publish(e){e.origin=this,this._eventsOrigin.publishEvent(e,!0)}getStream(e){return new qp.Observable((t=>{const n=this._source.subscribeToEvent(e,(e=>{t.next(e)}));return()=>n.unsubscribe()}))}subscribe(e,t){return this.getStream(e).pipe().subscribe(t)}removeAllListeners(){}newScopedBus(e,t){throw new Error("For internal use only")}}var jy=function(){};var Iy="undefined"!=typeof window;const Ny=Iy?Fi.useLayoutEffect:Fi.useEffect;var Ly={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};const My=Iy&&void 0!==window.ResizeObserver?function(){var e=(0,Fi.useState)(null),t=e[0],n=e[1],r=(0,Fi.useState)(Ly),i=r[0],a=r[1],o=(0,Fi.useMemo)((function(){return new window.ResizeObserver((function(e){if(e[0]){var t=e[0].contentRect,n=t.x,r=t.y,i=t.width,o=t.height,s=t.top,l=t.left,c=t.bottom,u=t.right;a({x:n,y:r,width:i,height:o,top:s,left:l,bottom:c,right:u})}}))}),[]);return Ny((function(){if(t)return o.observe(t),function(){o.disconnect()}}),[t]),[n,i]}:function(){return[jy,Ly]};function Fy(e,t){if(t)return t;let n=e.error?e.error.message:void 0;return e.errors&&(n=e.errors.map((e=>e.message)).join(", ")),n}const $y=(0,i.css)({position:"relative",width:"100%",height:"100%"}),By=(0,i.css)({position:"absolute",width:"100%",height:"100%"}),Vy=e=>({ok:(0,i.css)({color:e.colors.success.text}),pending:(0,i.css)({color:e.colors.warning.text}),alerting:(0,i.css)({color:e.colors.error.text})});var zy=Object.defineProperty,Uy=Object.defineProperties,qy=Object.getOwnPropertyDescriptors,Hy=Object.getOwnPropertySymbols,Gy=Object.prototype.hasOwnProperty,Wy=Object.prototype.propertyIsEnumerable,Qy=(e,t,n)=>t in e?zy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ky=(e,t)=>{for(var n in t||(t={}))Gy.call(t,n)&&Qy(e,n,t[n]);if(Hy)for(var n of Hy(t))Wy.call(t,n)&&Qy(e,n,t[n]);return e},Yy=(e,t)=>Uy(e,qy(t));const Xy="hideSeriesFrom",Jy=(0,r.isSystemOverrideWithRef)(Xy);function Zy(e,t=r.ByNamesMatcherMode.exclude,n){return n=null!=n?n:{id:"custom.hideFrom",value:{viz:!0,legend:!1,tooltip:!1}},{__systemRef:Xy,matcher:{id:r.FieldMatcherID.byNames,options:{mode:t,names:e,prefix:t===r.ByNamesMatcherMode.exclude?"All except:":void 0,readOnly:!0}},properties:[Yy(Ky({},n),{value:{viz:!0,legend:!1,tooltip:!1}})]}}const eb=(e,t,n=r.ByNamesMatcherMode.exclude)=>{const i=e.properties.find((e=>"custom.hideFrom"===e.id)),a=tb(e),o=a.findIndex((e=>e===t));return o<0?a.push(t):a.splice(o,1),Zy(a,n,i)},tb=e=>{var t;const n=null==(t=e.matcher.options)?void 0:t.names;return Array.isArray(n)?[...n]:[]},nb=(e,t)=>tb(e).length===rb(t).length,rb=(e,t)=>{const n=new Set;for(const i of e)for(const a of i.fields){if(a.type!==r.FieldType.number)continue;const o=(0,r.getFieldDisplayName)(a,i,e);o!==t&&n.add(o)}return Array.from(n)},ib=(e,t)=>{var n;let i=[];for(const a of e){const e=a.properties.find((e=>"custom.hideFrom"===e.id));if(void 0!==e&&!0===(null==(n=e.value)?void 0:n.legend)){const e=r.fieldMatchers.get(a.matcher.id).get(a.matcher.options);for(const n of t)for(const a of n.fields){if(a.type!==r.FieldType.number)continue;const o=(0,r.getFieldDisplayName)(a,n,t);e(a,n,t)&&i.push(o)}}}return i};var ab=Object.defineProperty,ob=Object.defineProperties,sb=Object.getOwnPropertyDescriptors,lb=Object.getOwnPropertySymbols,cb=Object.prototype.hasOwnProperty,ub=Object.prototype.propertyIsEnumerable,db=(e,t,n)=>t in e?ab(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pb=(e,t)=>{for(var n in t||(t={}))cb.call(t,n)&&db(e,n,t[n]);if(lb)for(var n of lb(t))ub.call(t,n)&&db(e,n,t[n]);return e},hb=(e,t)=>ob(e,sb(t));const fb=(e,t)=>({matcher:{id:r.FieldMatcherID.byName,options:e},properties:[mb(t)]}),mb=e=>({id:"color",value:{mode:r.FieldColorModeId.Fixed,fixedColor:e}});var gb=Object.defineProperty,yb=Object.defineProperties,bb=Object.getOwnPropertyDescriptors,vb=Object.getOwnPropertySymbols,wb=Object.prototype.hasOwnProperty,Sb=Object.prototype.propertyIsEnumerable,Eb=(e,t,n)=>t in e?gb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xb=(e,t)=>{for(var n in t||(t={}))wb.call(t,n)&&Eb(e,n,t[n]);if(vb)for(var n of vb(t))Sb.call(t,n)&&Eb(e,n,t[n]);return e},Ob=(e,t)=>yb(e,bb(t));class _b extends bh{constructor(e){var t;super(xb({options:{},fieldConfig:{defaults:{},overrides:[]},title:"Title",pluginId:"timeseries"},e)),this._variableDependency=new im(this,{statePaths:["title","options","fieldConfig"]}),this._structureRev=0,this.onTimeRangeChange=e=>{tm.getTimeRange(this).onTimeRangeChange({raw:{from:(0,r.toUtc)(e.from),to:(0,r.toUtc)(e.to)},from:(0,r.toUtc)(e.from),to:(0,r.toUtc)(e.to)})},this.getTimeRange=e=>{const t=tm.findObject(this,(e=>e instanceof Cb)),n=tm.getTimeRange(this);if(t instanceof Cb&&t.isEnabled)return ef(n.state.from,n.state.to,n.getTimeZone(),n.state.fiscalYearStartMonth,n.state.UNSAFE_nowDelay);const r=this.getPlugin();return r&&!r.meta.skipDataQuery&&e&&e.timeRange?e.timeRange:n.state.value},this.onTitleChange=e=>{this.setState({title:e})},this.onDescriptionChange=e=>{this.setState({description:e})},this.onDisplayModeChange=e=>{this.setState({displayMode:e})},this.onOptionsChange=(e,t=!1)=>{const{fieldConfig:n,options:i}=this.state,a=t?e:(0,$c.mergeWith)((0,$c.cloneDeep)(i),e,((e,t)=>{if((0,$c.isArray)(t))return t})),o=(0,r.getPanelOptionsWithDefaults)({plugin:this._plugin,currentOptions:a,currentFieldConfig:n,isAfterPluginChange:!1});this.setState({options:o.options})},this.onFieldConfigChange=(e,t)=>{const{fieldConfig:n,options:i}=this.state,a=t?e:(0,$c.merge)((0,$c.cloneDeep)(n),e),o=(0,r.getPanelOptionsWithDefaults)({plugin:this._plugin,currentOptions:i,currentFieldConfig:a,isAfterPluginChange:!1});this._dataWithFieldConfig=void 0,this.setState({fieldConfig:o.fieldConfig})},this.interpolate=(e,t,n)=>tm.interpolate(this,e,t,n),this.getDescription=()=>{this.publishEvent(new lh({origin:this,interaction:"panel-description-shown"}),!0);const{description:e}=this.state;if(e){const t=this.interpolate(e);return(0,r.renderMarkdown)(t)}return""},this.onCancelQuery=()=>{var e;this.publishEvent(new lh({origin:this,interaction:"panel-cancel-query-clicked"}),!0);const t=tm.getData(this);null==(e=t.cancelQuery)||e.call(t)},this.onStatusMessageClick=()=>{this.publishEvent(new lh({origin:this,interaction:"panel-status-message-clicked"}),!0)},this._onSeriesColorChange=(e,t)=>{this.onFieldConfigChange(((e,t,n)=>{const{overrides:i}=n,a=n.overrides.findIndex((t=>t.matcher.id===r.FieldMatcherID.byName&&t.matcher.options===e));if(a<0)return hb(pb({},n),{overrides:[...n.overrides,fb(e,t)]});const o=Array.from(i),s=o[a],l=s.properties.findIndex((e=>"color"===e.id));if(l<0)return o[a]=hb(pb({},s),{properties:[...s.properties,mb(t)]}),hb(pb({},n),{overrides:o});const c=Array.from(s.properties);return c[l]=mb(t),o[a]=hb(pb({},s),{properties:c}),hb(pb({},n),{overrides:o})})(e,t,this.state.fieldConfig))},this._onSeriesVisibilityChange=(e,t)=>{this._dataWithFieldConfig&&this.onFieldConfigChange(function(e,t,n,r){const{overrides:i}=n,a=e,s=i.findIndex(Jy);if(s<0){if(t===o.SeriesVisibilityChangeMode.ToggleSelection){const e=Zy([a,...ib(i,r)]);return Yy(Ky({},n),{overrides:[...n.overrides,e]})}const e=Zy(rb(r,a));return Yy(Ky({},n),{overrides:[...n.overrides,e]})}const l=Array.from(i),[c]=l.splice(s,1);if(t===o.SeriesVisibilityChangeMode.ToggleSelection){let e=tb(c);const t=ib(l,r);if(t.length>0&&(e=e.filter((e=>t.indexOf(e)<0))),e[0]===a&&1===e.length)return Yy(Ky({},n),{overrides:l});const i=Zy([a,...t]);return Yy(Ky({},n),{overrides:[...l,i]})}const u=eb(c,a);return nb(u,r)?Yy(Ky({},n),{overrides:l}):Yy(Ky({},n),{overrides:[...l,u]})}(e,t,this.state.fieldConfig,this._dataWithFieldConfig.series),!0)},this._onInstanceStateChange=e=>{this._panelContext&&(this._panelContext=Ob(xb({},this._panelContext),{instanceState:e})),this.setState({_pluginInstanceState:e})},this._onToggleLegendSort=e=>{const t=this.state.options.legend;if(!t)return;let n=t.sortDesc,r=t.sortBy;e!==r&&(n=void 0),!1===n?(r=void 0,n=void 0):(n=!n,r=e),this.onOptionsChange(Ob(xb({},this.state.options),{legend:Ob(xb({},t),{sortBy:r,sortDesc:n})}),!0)},this.addActivationHandler((()=>{this._onActivate()})),null==(t=e.menu)||t.addActivationHandler((()=>{this.publishEvent(new lh({origin:this,interaction:"panel-menu-shown"}),!0)}))}_onActivate(){this._plugin||this._loadPlugin(this.state.pluginId)}async _loadPlugin(e){const t=function(e){var t;const{getPanelPluginFromCache:n}=(0,a.getPluginImportUtils)();return null!=(t=n(e))?t:Up.get(e)}(e);if(t)this._pluginLoaded(t);else{const{importPanelPlugin:t}=(0,a.getPluginImportUtils)();try{const n=await t(e);this._pluginLoaded(n)}catch(t){this._pluginLoaded(function(e){const t=new r.PanelPlugin((()=>null));return t.meta={id:e,name:e,sort:100,type:r.PluginType.panel,module:"",baseUrl:"",info:{author:{name:""},description:"",links:[],logos:{large:"",small:"public/img/grafana_icon.svg"},screenshots:[],updated:"",version:""}},t}(e)),t instanceof Error&&this.setState({_pluginLoadError:t.message})}}}getLegacyPanelId(){const e=parseInt(this.state.key.replace("panel-",""),10);return isNaN(e)?0:e}async _pluginLoaded(e){const{options:t,fieldConfig:n,title:i,pluginVersion:a,_UNSAFE_customMigrationHandler:o}=this.state,s={title:i,options:t,fieldConfig:n,id:this.getLegacyPanelId(),type:e.meta.id,pluginVersion:a},l=this._getPluginVersion(e);null==o||o(s,e),e.onPanelMigration&&l!==this.state.pluginVersion&&(s.options=await e.onPanelMigration(s));const c=(0,r.getPanelOptionsWithDefaults)({plugin:e,currentOptions:s.options,currentFieldConfig:s.fieldConfig,isAfterPluginChange:!1});if(this._plugin=e,this.setState({options:c.options,fieldConfig:c.fieldConfig,pluginVersion:l}),e.meta.skipDataQuery){const e=tm.getTimeRange(this);this._subs.add(e.subscribeToState((()=>this.forceRender())))}}_getPluginVersion(e){return e&&e.meta.info.version?e.meta.info.version:a.config.buildInfo.version}getPlugin(){return this._plugin}getPanelContext(){return null!=this._panelContext||(this._panelContext=this.buildPanelContext()),this._panelContext}clearFieldConfigCache(){this._dataWithFieldConfig=void 0}applyFieldConfig(e){var t,n,i,o;const s=this._plugin;if(!s||s.meta.skipDataQuery||!e)return Yh;if(this._prevData===e&&this._dataWithFieldConfig)return this._dataWithFieldConfig;const l=s.dataSupport||{alertStates:!1,annotations:!1},c=s.fieldConfigRegistry,u=null!=(n=null==(t=this._dataWithFieldConfig)?void 0:t.series)?n:[],d=(0,r.applyFieldOverrides)({data:e.series,fieldConfig:this.state.fieldConfig,fieldConfigRegistry:c,replaceVariables:this.interpolate,theme:a.config.theme2,timeZone:null==(i=e.request)?void 0:i.timezone});return(0,r.compareArrayValues)(d,u,r.compareDataFrameStructures)||this._structureRev++,this._dataWithFieldConfig=Ob(xb({},e),{structureRev:this._structureRev,series:d}),this._dataWithFieldConfig.annotations&&(this._dataWithFieldConfig.annotations=(0,r.applyFieldOverrides)({data:this._dataWithFieldConfig.annotations,fieldConfig:{defaults:{},overrides:[]},fieldConfigRegistry:c,replaceVariables:this.interpolate,theme:a.config.theme2,timeZone:null==(o=e.request)?void 0:o.timezone})),l.alertStates||(this._dataWithFieldConfig.alertState=void 0),l.annotations||(this._dataWithFieldConfig.annotations=void 0),this._prevData=e,this._dataWithFieldConfig}buildPanelContext(){const e=(t=this,tm.findObject(t,(e=>e instanceof Ay)));var t;const n={eventsScope:e?e.getEventsScope():"__global_",eventBus:e?e.getEventsBus(this):(0,a.getAppEvents)(),app:r.CoreApp.Unknown,sync:()=>e?e.state.sync:r.DashboardCursorSync.Off,onSeriesColorChange:this._onSeriesColorChange,onToggleSeriesVisibility:this._onSeriesVisibilityChange,onToggleLegendSort:this._onToggleLegendSort,onInstanceStateChange:this._onInstanceStateChange};return this.state.extendPanelContext&&this.state.extendPanelContext(this,n),n}}_b.Component=function({model:e}){var t;const{title:n,options:s,fieldConfig:l,_pluginLoadError:c,displayMode:u,hoverHeader:d,hoverHeaderOffset:p,menu:h,headerActions:f,titleItems:m,description:g}=e.useState(),[y,{width:b,height:v}]=My(),w=(0,Fi.useMemo)((()=>(0,a.getAppEvents)()),[]),S=(0,Fi.useCallback)((()=>w.publish(new r.SetPanelAttentionEvent({panelId:e.state.key}))),[e.state.key,w]),E=(0,Fi.useMemo)((()=>(0,$c.debounce)(S,100)),[S]),x=e.getPlugin(),{dragClass:O,dragClassCancel:_}=function(e){var t,n;const r=tm.getLayout(e),i=null==r?void 0:r.isDraggable();if(!r||!i||function(e,t){let n=e.parent;for(;n&&n!==t;){if("isDraggable"in n.state&&!1===n.state.isDraggable)return!0;n=n.parent}return!1}(e,r))return{dragClass:"",dragClassCancel:""};return{dragClass:null==(t=r.getDragClass)?void 0:t.call(r),dragClassCancel:null==(n=null==r?void 0:r.getDragClassCancel)?void 0:n.call(r)}}(e),T=tm.getData(e),C=T.useState(),k=e.applyFieldConfig(C.data),P=tm.getTimeRange(e).getTimeZone(),R=e.getTimeRange(k),A=e.interpolate(n,void 0,"text"),D=(0,o.useStyles2)(Vy);if(!x)return $i().createElement("div",null,"Loading plugin panel...");if(!x.panel)return $i().createElement("div",null,"Panel plugin has no panel component");const j=x.panel;T&&T.setContainerWidth&&T.setContainerWidth(Math.round(b));let I,N,L=[];m&&(Array.isArray(m)?L=L.concat(m.map((e=>$i().createElement(e.Component,{model:e,key:`${e.state.key}`})))):jf(m)?L.push($i().createElement(m.Component,{model:m})):L.push(m)),e.state.$timeRange&&L.push($i().createElement(e.state.$timeRange.Component,{model:e.state.$timeRange,key:e.state.key})),k.alertState&&L.push($i().createElement(o.Tooltip,{content:null!=(t=k.alertState.state)?t:"unknown",key:`alert-states-icon-${e.state.key}`},$i().createElement(o.PanelChrome.TitleItem,{className:(0,i.cx)({[D.ok]:k.alertState.state===r.AlertState.OK,[D.pending]:k.alertState.state===r.AlertState.Pending,[D.alerting]:k.alertState.state===r.AlertState.Alerting})},$i().createElement(o.Icon,{name:"alerting"===k.alertState.state?"heart-break":"heart",className:"panel-alert-icon",size:"md"})))),h&&(I=$i().createElement(h.Component,{model:h})),f&&(N=Array.isArray(f)?$i().createElement($i().Fragment,null,f.map((e=>$i().createElement(e.Component,{model:e,key:`${e.state.key}`})))):jf(f)?$i().createElement(f.Component,{model:f}):f);const M=k,F=!T.isDataReadyToDisplay||T.isDataReadyToDisplay(),$=e.getPanelContext(),B=e.getLegacyPanelId();return $i().createElement("div",{className:$y},$i().createElement("div",{ref:y,className:By,"data-viz-panel-key":e.state.key},b>0&&v>0&&$i().createElement(o.PanelChrome,{title:A,description:(null==g?void 0:g.trim())?e.getDescription:void 0,loadingState:M.state,statusMessage:Fy(M,c),statusMessageOnClick:e.onStatusMessageClick,width:b,height:v,displayMode:u,hoverHeader:d,hoverHeaderOffset:p,titleItems:L,dragClass:O,actions:N,dragClassCancel:_,padding:x.noPadding?"none":"md",menu:I,onCancelQuery:e.onCancelQuery,onFocus:S,onMouseMove:E},((t,i)=>$i().createElement($i().Fragment,null,$i().createElement(o.ErrorBoundaryAlert,{dependencies:[x,M]},$i().createElement(r.PluginContextProvider,{meta:x.meta},$i().createElement(o.PanelContextProvider,{value:$},F&&$i().createElement(j,{id:B,data:M,title:n,timeRange:R,timeZone:P,options:s,fieldConfig:l,transparent:!1,width:t,height:i,renderCounter:0,replaceVariables:e.interpolate,onOptionsChange:e.onOptionsChange,onFieldConfigChange:e.onFieldConfigChange,onChangeTimeRange:e.onTimeRangeChange,eventBus:w})))))))))};const Tb=class extends bh{constructor({enabled:e=!1}){super({enabled:e}),this.timerId=void 0,this._activationHandler=()=>(this.state.enabled&&this.enable(),()=>{window.clearInterval(this.timerId),this.timerId=void 0}),this.addActivationHandler(this._activationHandler)}enable(){window.clearInterval(this.timerId),this.timerId=void 0,this.timerId=window.setInterval((()=>{const e=tm.findAllObjects(this.getRoot(),(e=>e instanceof _b));for(const t of e)t.forceRender()}),Tb.REFRESH_RATE),this.setState({enabled:!0})}disable(){window.clearInterval(this.timerId),this.timerId=void 0,this.setState({enabled:!1})}get isEnabled(){return this.state.enabled}};let Cb=Tb;function kb(e){if("string"==typeof e)return e;if(e){if(e instanceof Error)return e.message;if((0,a.isFetchError)(e)){if(e.data&&e.data.message)return e.data.message;if(e.statusText)return e.statusText}else if(e.hasOwnProperty("message"))return e.message}return JSON.stringify(e)}Cb.REFRESH_RATE=100;var Pb=Object.defineProperty,Rb=Object.getOwnPropertySymbols,Ab=Object.prototype.hasOwnProperty,Db=Object.prototype.propertyIsEnumerable,jb=(e,t,n)=>t in e?Pb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class Ib extends bh{constructor(e,t=[]){super(((e,t)=>{for(var n in t||(t={}))Ab.call(t,n)&&jb(e,n,t[n]);if(Rb)for(var n of Rb(t))Db.call(t,n)&&jb(e,n,t[n]);return e})({isEnabled:!0},e)),this._results=new qp.ReplaySubject(1),this.isDataLayer=!0,this._variableValueRecorder=new am,this._variableDependency=new im(this,{onVariableUpdateCompleted:this.onVariableUpdateCompleted.bind(this)}),this._variableDependency.setPaths(t),this.addActivationHandler((()=>this.onActivate()))}onActivate(){return this.state.isEnabled&&this.onEnable(),this.shouldRunLayerOnActivate()&&this.runLayer(),this.subscribeToState(((e,t)=>{!e.isEnabled&&this.querySub&&(this.querySub.unsubscribe(),this.querySub=void 0,this.onDisable(),this._results.next({origin:this,data:Yh}),this.setStateHelper({data:Yh})),e.isEnabled&&!t.isEnabled&&(this.onEnable(),this.runLayer())})),()=>{this.onDeactivate()}}onDeactivate(){this.querySub&&(this.querySub.unsubscribe(),this.querySub=void 0),this.onDisable(),this._variableValueRecorder.recordCurrentDependencyValuesForSceneObject(this)}onVariableUpdateCompleted(){this.runLayer()}cancelQuery(){this.querySub&&(this.querySub.unsubscribe(),this.querySub=void 0,this.publishResults(Yh))}publishResults(e){this.state.isEnabled&&(this._results.next({origin:this,data:e}),this.setStateHelper({data:e}))}getResultsStream(){return this._results}shouldRunLayerOnActivate(){return this._variableValueRecorder.hasDependenciesChanged(this)?(rm(),!0):!this.state.data}setStateHelper(e){Rm(this,e)}}function Nb({layer:e}){var t,n;const r=`data-layer-${e.state.key}`,{data:i,isEnabled:a}=e.useState(),s=Boolean(i&&i.state===qh.Loading);return $i().createElement("div",{className:Lb},$i().createElement(_g,{htmlFor:r,isLoading:s,onCancel:()=>{var t;return null==(t=e.cancelQuery)?void 0:t.call(e)},label:e.state.name,description:e.state.description,error:null==(n=null==(t=e.state.data)?void 0:t.errors)?void 0:n[0].message}),$i().createElement(o.InlineSwitch,{id:r,value:a,onChange:()=>e.setState({isEnabled:!a})}))}(class extends bh{constructor(){super({})}}).Component=function({model:e}){const t=tm.getDataLayers(e,!0);if(0===t.length)return null;return $i().createElement($i().Fragment,null,t.map((e=>$i().createElement(e.Component,{model:e,key:e.state.key}))))};const Lb=(0,i.css)({display:"flex"});function Mb(e){return"function"==typeof e}function Fb(e){return function(t){if(function(e){return Mb(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}var $b=function(e,t){return $b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},$b(e,t)};function Bb(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}$b(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function Vb(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}l((r=r.apply(e,t||[])).next())}))}function zb(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function qb(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)o.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return o}function Hb(e,t,n){if(n||2===arguments.length)for(var r,i=0,a=t.length;i1||s(e,t)}))},t&&(r[e]=t(r[e])))}function s(e,t){try{!function(e){e.value instanceof Gb?Promise.resolve(e.value.v).then(l,c):u(a[0][2],e)}(i[e](t))}catch(e){u(a[0][3],e)}}function l(e){s("next",e)}function c(e){s("throw",e)}function u(e,t){e(t),a.shift(),a.length&&s(a[0][0],a[0][1])}}function Qb(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=Ub(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,i,(t=e[n](t)).done,t.value)}))}}}Object.create;"function"==typeof SuppressedError&&SuppressedError;var Kb,Yb,Xb=(Kb=function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}},(Yb=Kb((function(e){Error.call(e),e.stack=(new Error).stack}))).prototype=Object.create(Error.prototype),Yb.prototype.constructor=Yb,Yb);function Jb(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var Zb=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,n,r,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var o=Ub(a),s=o.next();!s.done;s=o.next()){s.value.remove(this)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else a.remove(this);var l=this.initialTeardown;if(Mb(l))try{l()}catch(e){i=e instanceof Xb?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var u=Ub(c),d=u.next();!d.done;d=u.next()){var p=d.value;try{tv(p)}catch(e){i=null!=i?i:[],e instanceof Xb?i=Hb(Hb([],qb(i)),qb(e.errors)):i.push(e)}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}if(i)throw new Xb(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)tv(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&Jb(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&Jb(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();Zb.EMPTY;function ev(e){return e instanceof Zb||e&&"closed"in e&&Mb(e.remove)&&Mb(e.add)&&Mb(e.unsubscribe)}function tv(e){Mb(e)?e():e.unsubscribe()}var nv={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},rv={setTimeout:function(e,t){for(var n=[],r=2;rt in e?Rv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const Mv={prepareAnnotation:e=>{if((0,$c.isString)(null==e?void 0:e.query)){const t=e,{query:n}=t;return((e,t)=>Av(e,Dv(t)))(((e,t)=>{for(var n in t||(t={}))Iv.call(t,n)&&Lv(e,n,t[n]);if(jv)for(var n of jv(t))Nv.call(t,n)&&Lv(e,n,t[n]);return e})({},((e,t)=>{var n={};for(var r in e)Iv.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&jv)for(var r of jv(e))t.indexOf(r)<0&&Nv.call(e,r)&&(n[r]=e[r]);return n})(t,["query"])),{target:{refId:"annotation_query",query:n},mappings:{}})}return e},prepareQuery:e=>e.target,processEvents:(e,t)=>function(e,t){return(0,qp.of)(e).pipe((e=>e.pipe(Pv((e=>{if(!(null==e?void 0:e.length))return(0,qp.of)(void 0);if(1===e.length)return(0,qp.of)(e[0]);const t={interpolate:e=>e};return(0,qp.of)(e).pipe(r.standardTransformers.mergeTransformer.operator({},t),vv((e=>e[0])))})))),vv((e=>{if(!(null==e?void 0:e.length))return[];let n=!1,i=!1;const a={};for(const t of e.fields){a[(0,r.getFieldDisplayName)(t,e).toLowerCase()]=t}t||(t={});const o=[];for(const s of $v){const l=t[s.key]||{};if(l.source===r.AnnotationEventFieldSource.Skip)continue;const c={key:s.key,split:s.split};if(l.source===r.AnnotationEventFieldSource.Text)c.text=l.value;else{const t=(l.value||s.key).toLowerCase();c.field=a[t],!c.field&&s.field&&(c.field=s.field(e))}(c.field||c.text)&&(o.push(c),"time"===c.key?n=!0:"text"===c.key&&(i=!0))}if(!n||!i)return console.error("Cannot process annotation fields. No time or text present."),[];const s=[];for(let t=0;te.fields.find((e=>e.type===r.FieldType.time)),placeholder:"time, or the first time field"},{key:"timeEnd",help:"When this field is defined, the annotation will be treated as a range"},{key:"title"},{key:"text",field:e=>e.fields.find((e=>e.type===r.FieldType.string)),placeholder:"text, or the first text field"},{key:"tags",split:",",help:"The results will be split on comma (,)"},{key:"id"}],$v=[...a.config.publicDashboardAccessToken?[{key:"color"},{key:"isRegion"},{key:"source"}]:[],...Fv,{key:"userId"},{key:"login"},{key:"email"},{key:"prevState"},{key:"newState"},{key:"data"},{key:"panelId"},{key:"alertId"},{key:"dashboardId"},{key:"dashboardUID"}];const Bv=["prometheus","loki","elasticsearch","grafana-opensearch-datasource"];var Vv=Object.defineProperty,zv=Object.defineProperties,Uv=Object.getOwnPropertyDescriptors,qv=Object.getOwnPropertySymbols,Hv=Object.prototype.hasOwnProperty,Gv=Object.prototype.propertyIsEnumerable,Wv=(e,t,n)=>t in e?Vv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qv=(e,t)=>{for(var n in t||(t={}))Hv.call(t,n)&&Wv(e,n,t[n]);if(qv)for(var n of qv(t))Gv.call(t,n)&&Wv(e,n,t[n]);return e},Kv=(e,t)=>zv(e,Uv(t));let Yv=100;function Xv(e,t,n,i){var o;if(e.annotationQuery&&function(e){const{type:t}=e;return!e.annotations||Bv.includes(t)}(e))return console.warn("Using deprecated annotationQuery method, please upgrade your datasource"),(0,qp.from)(e.annotationQuery({range:t.state.value,rangeRaw:t.state.value.raw,annotation:n,dashboard:{}})).pipe(vv((e=>({state:qh.Done,events:e}))));const s=Qv(Qv({},Mv),e.annotations),l=Qv(Qv({},null==(o=s.getDefaultQuery)?void 0:o.call(s)),n),c=s.prepareAnnotation(l);if(!c)return(0,qp.of)({state:qh.Done,events:[]});const u=s.prepareQuery(c);if(!u)return(0,qp.of)({state:qh.Done,events:[]});const d=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,p=r.rangeUtil.calculateInterval(t.state.value,d,e.interval),h={__interval:{text:p.interval,value:p.interval},__interval_ms:{text:p.intervalMs.toString(),value:p.intervalMs},__annotation:{text:c.name,value:c},__sceneObject:{text:"__sceneObject",value:i}},f=Qv(Kv(Qv({startTime:Date.now(),requestId:"AQ"+Yv++,range:t.state.value,maxDataPoints:d,scopedVars:h},p),{app:r.CoreApp.Dashboard,timezone:t.getTimeZone(),targets:[Kv(Qv({},u),{refId:"Anno"})]}),_m(i));return(0,a.getRunRequest)()(e,f).pipe(Pv((e=>{const t=(null==e?void 0:e.series.length)?e.series:e.annotations;return(null==t?void 0:t.length)?(t.forEach((e=>{var t;(null==(t=e.meta)?void 0:t.dataTopic)||(e.meta=Kv(Qv({},e.meta||{}),{dataTopic:r.DataTopic.Annotations}))})),s.processEvents(c,t).pipe(vv((t=>({state:e.state,events:t||[]}))))):(0,qp.of)({state:e.state,events:[]})})))}var Jv=Object.defineProperty,Zv=Object.getOwnPropertySymbols,ew=Object.prototype.hasOwnProperty,tw=Object.prototype.propertyIsEnumerable,nw=(e,t,n)=>t in e?Jv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function rw(e,t){e.snapshotData&&delete(e=(0,$c.cloneDeep)(e)).snapshotData;const n=t.map((t=>{var n;const r=((e,t)=>{for(var n in t||(t={}))ew.call(t,n)&&nw(e,n,t[n]);if(Zv)for(var n of Zv(t))tw.call(t,n)&&nw(e,n,t[n]);return e})({},t);switch(r.source=e,r.color=a.config.theme2.visualization.getColorByName(e.iconColor),r.type=e.name,r.isRegion=Boolean(r.timeEnd&&r.time!==r.timeEnd),null==(n=r.newState)?void 0:n.toLowerCase()){case"pending":r.color="yellow";break;case"alerting":r.color="red";break;case"ok":case"normal":r.color="green";break;case"no_data":case"nodata":r.color="gray"}return r}));return n}function iw(e){return"panel-alert"===e.eventType}var aw=Object.defineProperty,ow=Object.defineProperties,sw=Object.getOwnPropertyDescriptors,lw=Object.getOwnPropertySymbols,cw=Object.prototype.hasOwnProperty,uw=Object.prototype.propertyIsEnumerable,dw=(e,t,n)=>t in e?aw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pw=(e,t)=>{for(var n in t||(t={}))cw.call(t,n)&&dw(e,n,t[n]);if(lw)for(var n of lw(t))uw.call(t,n)&&dw(e,n,t[n]);return e},hw=(e,t)=>ow(e,sw(t));(class extends Ib{constructor(e){super(pw({isEnabled:!0},e),["query"]),this._scopedVars={__sceneObject:{value:this,text:"__sceneObject"}}}onEnable(){const e=tm.getTimeRange(this);this._timeRangeSub=e.subscribeToState((()=>{this.runWithTimeRange(e)}))}onDisable(){var e;null==(e=this._timeRangeSub)||e.unsubscribe()}runLayer(){rm();const e=tm.getTimeRange(this);this.runWithTimeRange(e)}async runWithTimeRange(e){const{query:t}=this.state;if(this.querySub&&this.querySub.unsubscribe(),this._variableDependency.hasDependencyInLoadingState())rm();else try{let n=Xv(await this.resolveDataSource(t),e,t,this).pipe(km({type:"annotations",origin:this,cancel:()=>this.cancelQuery()}),(0,qp.map)((e=>this.processEvents(t,e))));this.querySub=n.subscribe((e=>{this.publishResults(e)}))}catch(e){this.publishResults(hw(pw({},Yh),{state:qh.Error,errors:[{message:kb(e)}]})),console.error("AnnotationsDataLayer error",e)}}async resolveDataSource(e){return await nm(e.datasource||void 0,this._scopedVars)}processEvents(e,t){let n=rw(e,t.events||[]);n=function(e){let t=[];const n=(0,$c.partition)(e,"id"),r=(0,$c.groupBy)(n[0],"id");return t=(0,$c.map)(r,(e=>e.length>1&&!(0,$c.every)(e,iw)?(0,$c.find)(e,(e=>"panel-alert"!==e.eventType)):(0,$c.head)(e))),t=(0,$c.concat)(t,n[1]),t}(n);const i=hw(pw({},Yh),{state:t.state}),a=(0,r.arrayToDataFrame)(n);return a.meta=hw(pw({},a.meta),{dataTopic:r.DataTopic.Annotations}),i.series=[a],i}}).Component=function({model:e}){const{isHidden:t}=e.useState();if(t)return null;return $i().createElement(Nb,{layer:e})};Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;var fw=Object.defineProperty,mw=Object.defineProperties,gw=Object.getOwnPropertyDescriptors,yw=Object.getOwnPropertySymbols,bw=Object.prototype.hasOwnProperty,vw=Object.prototype.propertyIsEnumerable,ww=(e,t,n)=>t in e?fw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class Sw extends bh{constructor(){super(...arguments),this.isDataLayer=!0,this._results=new qp.ReplaySubject(1),this._dataLayersMerger=new Xg}subscribeToAllLayers(e){e.length>0?this.querySub=this._dataLayersMerger.getMergedStream(e).subscribe(this._onLayerUpdateReceived.bind(this)):(this._results.next({origin:this,data:Yh}),this.setStateHelper({data:Yh}))}_onLayerUpdateReceived(e){var t;let n=[];for(const r of e)(null==(t=r.data)?void 0:t.series)&&(n=n.concat(r.data.series));const r=((e,t)=>mw(e,gw(t)))(((e,t)=>{for(var n in t||(t={}))bw.call(t,n)&&ww(e,n,t[n]);if(yw)for(var n of yw(t))vw.call(t,n)&&ww(e,n,t[n]);return e})({},Yh),{series:n});this._results.next({origin:this,data:r}),this.setStateHelper({data:r})}getResultsStream(){return this._results}cancelQuery(){var e;null==(e=this.querySub)||e.unsubscribe()}setStateHelper(e){Rm(this,e)}}class Ew extends Sw{constructor(e){var t,n;super({name:null!=(t=e.name)?t:"Data layers",layers:null!=(n=e.layers)?n:[]}),this.addActivationHandler((()=>this._onActivate()))}_onActivate(){return this._subs.add(this.subscribeToState(((e,t)=>{var n;e.layers!==t.layers&&(null==(n=this.querySub)||n.unsubscribe(),this.subscribeToAllLayers(e.layers))}))),this.subscribeToAllLayers(this.state.layers),()=>{var e;null==(e=this.querySub)||e.unsubscribe()}}}Ew.Component=({model:e})=>{const{layers:t}=e.useState();return $i().createElement($i().Fragment,null,t.map((e=>$i().createElement(e.Component,{model:e,key:e.state.key}))))};var xw=Object.defineProperty,Ow=Object.defineProperties,_w=Object.getOwnPropertyDescriptors,Tw=Object.getOwnPropertySymbols,Cw=Object.prototype.hasOwnProperty,kw=Object.prototype.propertyIsEnumerable,Pw=(e,t,n)=>t in e?xw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Rw=(e,t)=>{for(var n in t||(t={}))Cw.call(t,n)&&Pw(e,n,t[n]);if(Tw)for(var n of Tw(t))kw.call(t,n)&&Pw(e,n,t[n]);return e},Aw=(e,t)=>Ow(e,_w(t));class Dw extends bh{constructor(e){super(e),this._results=new qp.ReplaySubject(1),this._variableDependency=new im(this,{statePaths:["transformations"],onReferencedVariableValueChanged:()=>this.reprocessTransformations()}),this.addActivationHandler((()=>this.activationHandler()))}activationHandler(){const e=this.getSourceData();return this._subs.add(e.subscribeToState((e=>this.transform(e.data)))),e.state.data&&this.transform(e.state.data),()=>{this._transformSub&&this._transformSub.unsubscribe()}}getSourceData(){if(this.state.$data){if(this.state.$data instanceof Ew)throw new Error("SceneDataLayerSet can not be used as data provider for SceneDataTransformer.");return this.state.$data}if(!this.parent||!this.parent.parent)throw new Error("SceneDataTransformer must either have $data set on it or have a parent.parent with $data");return tm.getData(this.parent.parent)}setContainerWidth(e){this.state.$data&&this.state.$data.setContainerWidth&&this.state.$data.setContainerWidth(e)}isDataReadyToDisplay(){const e=this.getSourceData();return!e.isDataReadyToDisplay||e.isDataReadyToDisplay()}reprocessTransformations(){this.transform(this.getSourceData().state.data,!0)}cancelQuery(){var e,t;null==(t=(e=this.getSourceData()).cancelQuery)||t.call(e)}getResultsStream(){return this._results}clone(e){const t=super.clone(e);return this._prevDataFromSource&&(t._prevDataFromSource=this._prevDataFromSource),t}haveAlreadyTransformedData(e){if(!this._prevDataFromSource)return!1;if(e===this._prevDataFromSource)return!0;const{series:t,annotations:n}=this._prevDataFromSource;return e.series===t&&e.annotations===n&&(this.state.data&&e.state!==this.state.data.state&&this.setState({data:Aw(Rw({},this.state.data),{state:e.state})}),!0)}transform(e,t=!1){var n;if(0===this.state.transformations.length||!e)return this._prevDataFromSource=e,this.setState({data:e}),void(e&&this._results.next({origin:this,data:e}));if(!t&&this.haveAlreadyTransformedData(e))return;const i=this.state.transformations.filter((e=>!("options"in e)&&!("topic"in e)||(null==e.topic||e.topic===r.DataTopic.Series))).map((e=>"operator"in e?e.operator:e)),o=this.state.transformations.filter((e=>("options"in e||"topic"in e)&&e.topic===r.DataTopic.Annotations)).map((e=>"operator"in e?e.operator:e));this._transformSub&&this._transformSub.unsubscribe();const s={interpolate:t=>{var n;return tm.interpolate(this,t,null==(n=e.request)?void 0:n.scopedVars)}};let l=[(0,r.transformDataFrame)(i,e.series,s)];e.annotations&&e.annotations.length>0&&o.length>0&&l.push((0,r.transformDataFrame)(o,null!=(n=e.annotations)?n:[])),this._transformSub=(0,qp.forkJoin)(l).pipe((0,qp.map)((t=>{const n=t[0],r=t[1];return Aw(Rw({},e),{series:n,annotations:null!=r?r:e.annotations})})),(0,qp.catchError)((t=>{var n;console.error("Error transforming data: ",t);const i=(null==(n=this.getSourceData().state.data)?void 0:n.errors)||[],o=(0,a.toDataQueryError)(t);o.message=`Error transforming data: ${o.message}`;const s=Aw(Rw({},e),{state:r.LoadingState.Error,errors:[...i,o]});return(0,qp.of)(s)}))).subscribe((t=>{this.setState({data:t}),this._results.next({origin:this,data:t}),this._prevDataFromSource=e}))}}function jw({variable:e,layout:t,showAlways:n,hideLabel:i}){return vh(e,{shouldActivateOrKeepAlive:!0}).hide!==r.VariableHide.hideVariable||n?"vertical"===t?$i().createElement("div",{className:Lw,"data-testid":Lm.pages.Dashboard.SubMenu.submenuItem},$i().createElement(Iw,{variable:e,layout:t,hideLabel:i}),$i().createElement(e.Component,{model:e})):$i().createElement("div",{className:Nw,"data-testid":Lm.pages.Dashboard.SubMenu.submenuItem},$i().createElement(Iw,{variable:e,hideLabel:i}),$i().createElement(e.Component,{model:e})):null}function Iw({variable:e,layout:t,hideLabel:n}){var i,a;const{state:o}=e;if(e.state.hide===r.VariableHide.hideLabel||n)return null;const s=`var-${o.key}`,l=null!=(i=o.label)?i:o.name;return $i().createElement(_g,{htmlFor:s,isLoading:o.loading,onCancel:()=>{var t;return null==(t=e.onCancel)?void 0:t.call(e)},label:l,error:o.error,layout:t,description:null!=(a=o.description)?a:void 0})}(class extends bh{}).Component=function({model:e}){const t=tm.getVariables(e).useState();return $i().createElement($i().Fragment,null,t.variables.map((t=>$i().createElement(jw,{key:t.state.key,variable:t,layout:e.state.layout}))))};const Nw=(0,i.css)({display:"flex"}),Lw=(0,i.css)({display:"flex",flexDirection:"column"});(class extends bh{}).Component=function({model:e}){const t=tm.lookupVariable(e.state.variableName,e);if(!t)return null;return $i().createElement(jw,{key:t.state.key,variable:t,layout:e.state.layout,showAlways:!0})};class Mw extends bh{constructor(e){super(e),this._variablesThatHaveChanged=new Set,this._variablesToUpdate=new Set,this._updating=new Map,this._variableValueRecorder=new am,this._variableDependency=new $w(this._handleParentVariableUpdatesCompleted.bind(this)),this._onActivate=()=>{const e=tm.getTimeRange(this);this._subs.add(this.subscribeToEvent(pf,(e=>this._handleVariableValueChanged(e.payload)))),this._subs.add(e.subscribeToState((()=>{this._refreshTimeRangeBasedVariables()}))),this._subs.add(this.subscribeToState(this._onStateChanged)),this._checkForVariablesThatChangedWhileInactive();for(const e of this.state.variables)this._variableNeedsUpdate(e)&&this._variablesToUpdate.add(e);return this._updateNextBatch(),this._onDeactivate},this._onDeactivate=()=>{var e;for(const t of this._updating.values())null==(e=t.subscription)||e.unsubscribe();for(const e of this.state.variables)this._variablesToUpdate.has(e)||this._updating.has(e)||this._variableValueRecorder.recordCurrentValue(e);this._variablesToUpdate.clear(),this._updating.clear()},this._onStateChanged=(e,t)=>{const n=this._variablesToUpdate.size;for(const n of t.variables)if(!e.variables.includes(n)){const e=this._updating.get(n);(null==e?void 0:e.subscription)&&e.subscription.unsubscribe(),this._updating.delete(n),this._variablesToUpdate.delete(n)}for(const n of e.variables)t.variables.includes(n)||this._variableNeedsUpdate(n)&&this._variablesToUpdate.add(n);0===n&&this._variablesToUpdate.size>0&&this._updateNextBatch()},this.addActivationHandler(this._onActivate)}getByName(e){return this.state.variables.find((t=>t.state.name===e))}_refreshTimeRangeBasedVariables(){for(const e of this.state.variables)"refresh"in e.state&&e.state.refresh===r.VariableRefresh.onTimeRangeChanged&&this._variablesToUpdate.add(e);this._updateNextBatch()}_checkForVariablesThatChangedWhileInactive(){if(this._variableValueRecorder.hasValues())for(const e of this.state.variables)this._variableValueRecorder.hasValueChanged(e)&&(Fw(e,"Changed while in-active"),this._addDependentVariablesToUpdateQueue(e))}_variableNeedsUpdate(e){return!e.isLazy&&(!!e.validateAndUpdate&&(!this._variableValueRecorder.hasRecordedValue(e)||(Fw(e,"Skipping updateAndValidate current value valid"),!1)))}_updateNextBatch(){for(const e of this._variablesToUpdate){if(!e.validateAndUpdate)throw new Error("Variable added to variablesToUpdate but does not have validateAndUpdate");if(this._updating.has(e))continue;if(tm.hasVariableDependencyInLoadingState(e))continue;const t={variable:e};this._updating.set(e,t),Fw(e,"updateAndValidate started"),t.subscription=e.validateAndUpdate().subscribe({next:()=>this._validateAndUpdateCompleted(e),complete:()=>this._validateAndUpdateCompleted(e),error:t=>this._handleVariableError(e,t)})}}_validateAndUpdateCompleted(e){var t;if(!this._updating.has(e))return;const n=this._updating.get(e);null==(t=null==n?void 0:n.subscription)||t.unsubscribe(),this._updating.delete(e),this._variablesToUpdate.delete(e),Fw(e,"updateAndValidate completed"),this._notifyDependentSceneObjects(e),this._updateNextBatch()}cancel(e){var t;const n=this._updating.get(e);null==(t=null==n?void 0:n.subscription)||t.unsubscribe(),this._updating.delete(e),this._variablesToUpdate.delete(e)}_handleVariableError(e,t){var n;const r=this._updating.get(e);null==(n=null==r?void 0:r.subscription)||n.unsubscribe(),this._updating.delete(e),this._variablesToUpdate.delete(e),e.setState({loading:!1,error:t.message}),console.error("SceneVariableSet updateAndValidate error",t),Fw(e,"updateAndValidate error",t)}_handleVariableValueChanged(e){this._variablesThatHaveChanged.add(e),this._addDependentVariablesToUpdateQueue(e),this._updating.has(e)||(this._updateNextBatch(),this._notifyDependentSceneObjects(e))}_handleParentVariableUpdatesCompleted(e,t){t&&this._addDependentVariablesToUpdateQueue(e),this._variablesToUpdate.size>0&&0===this._updating.size&&this._updateNextBatch()}_addDependentVariablesToUpdateQueue(e){for(const t of this.state.variables)t.variableDependency&&t.variableDependency.hasDependencyOn(e.state.name)&&(Fw(t,"Added to update queue, dependant variable value changed"),this._updating.has(t)&&t.onCancel&&t.onCancel(),this._variablesToUpdate.add(t))}_notifyDependentSceneObjects(e){this.parent&&(this._traverseSceneAndNotify(this.parent,e,this._variablesThatHaveChanged.has(e)),this._variablesThatHaveChanged.delete(e))}_traverseSceneAndNotify(e,t,n){if(this!==e&&e.isActive){if(e.state.$variables&&e.state.$variables!==this){if(e.state.$variables.getByName(t.state.name))return}e.variableDependency&&e.variableDependency.variableUpdateCompleted(t,n),e.forEachChild((e=>this._traverseSceneAndNotify(e,t,n)))}}isVariableLoadingOrWaitingToUpdate(e){return!(!e.isAncestorLoading||!e.isAncestorLoading())||(!(!this._variablesToUpdate.has(e)&&!this._updating.has(e))||tm.hasVariableDependencyInLoadingState(e))}}function Fw(e,t,n){rm(0,e.state.name)}class $w{constructor(e){this._variableUpdatesCompleted=e,this._emptySet=new Set}getNames(){return this._emptySet}hasDependencyOn(e){return!1}variableUpdateCompleted(e,t){this._variableUpdatesCompleted(e,t)}}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;var Bw=Object.defineProperty,Vw=Object.getOwnPropertySymbols,zw=Object.prototype.hasOwnProperty,Uw=Object.prototype.propertyIsEnumerable,qw=(e,t,n)=>t in e?Bw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class Hw extends Am{constructor(e){super(((e,t)=>{for(var n in t||(t={}))zw.call(t,n)&&qw(e,n,t[n]);if(Vw)for(var n of Vw(t))Uw.call(t,n)&&qw(e,n,t[n]);return e})({type:"custom",query:"",value:"",text:"",options:[],name:""},e)),this._variableDependency=new im(this,{statePaths:["query"]})}getValueOptions(e){var t;const n=(null!=(t=tm.interpolate(this,this.state.query).match(/(?:\\,|[^,])+/g))?t:[]).map((e=>{var t;e=e.replace(/\\,/g,",");const n=null!=(t=/^(.+)\s:\s(.+)$/g.exec(e))?t:[];if(3===n.length){const[,e,t]=n;return{label:e.trim(),value:t.trim()}}return{label:e.trim(),value:e.trim()}}));return(0,qp.of)(n)}}Hw.Component=({model:e})=>ug(e);var Gw=Object.defineProperty,Ww=Object.getOwnPropertySymbols,Qw=Object.prototype.hasOwnProperty,Kw=Object.prototype.propertyIsEnumerable,Yw=(e,t,n)=>t in e?Gw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class Xw extends Am{constructor(e){super(((e,t)=>{for(var n in t||(t={}))Qw.call(t,n)&&Yw(e,n,t[n]);if(Ww)for(var n of Ww(t))Kw.call(t,n)&&Yw(e,n,t[n]);return e})({type:"datasource",value:"",text:"",options:[],name:"",regex:"",pluginId:""},e)),this._variableDependency=new im(this,{statePaths:["regex"]})}getValueOptions(e){if(!this.state.pluginId)return(0,qp.of)([]);const t=(0,a.getDataSourceSrv)().getList({metrics:!0,variables:!1,pluginId:this.state.pluginId});let n;if(this.state.regex){const e=tm.interpolate(this,this.state.regex,void 0,"regex");n=(0,r.stringToJsRegex)(e)}const i=[];for(let e=0;eug(e);const eS=e=>Boolean(e.metricFindQuery)&&!Boolean(e.variables),tS=e=>{if(!e.variables)return!1;if(e.variables.getType()!==r.VariableSupportType.Standard)return!1;const t=e.variables;return"toDataQuery"in t&&Boolean(t.toDataQuery)},nS=e=>{if(!e.variables)return!1;if(e.variables.getType()!==r.VariableSupportType.Custom)return!1;const t=e.variables;return"query"in t&&"editor"in t&&Boolean(t.query)&&Boolean(t.editor)};var rS=Object.defineProperty,iS=Object.defineProperties,aS=Object.getOwnPropertyDescriptors,oS=Object.getOwnPropertySymbols,sS=Object.prototype.hasOwnProperty,lS=Object.prototype.propertyIsEnumerable,cS=(e,t,n)=>t in e?rS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,uS=(e,t)=>{for(var n in t||(t={}))sS.call(t,n)&&cS(e,n,t[n]);if(oS)for(var n of oS(t))lS.call(t,n)&&cS(e,n,t[n]);return e},dS=(e,t)=>iS(e,aS(t));class pS{constructor(e,t=(0,a.getRunRequest)()){this.datasource=e,this._runRequest=t}getTarget(e){if(tS(this.datasource))return this.datasource.variables.toDataQuery(function(e){var t;const n=null!=(t=e.state.query)?t:"";if("string"==typeof n)return{query:n,refId:`variable-${e.state.name}`};if(null==n.refId)return dS(uS({},n),{refId:`variable-${e.state.name}`});return e.state.query}(e));throw new Error("Couldn't create a target with supplied arguments.")}runRequest(e,t){return tS(this.datasource)?this.datasource.variables.query?this._runRequest(this.datasource,t,this.datasource.variables.query.bind(this.datasource.variables)):this._runRequest(this.datasource,t):mS()}}class hS{constructor(e){this.datasource=e}getTarget(e){if(eS(this.datasource))return e.state.query;throw new Error("Couldn't create a target with supplied arguments.")}runRequest({variable:e,searchFilter:t},n){return eS(this.datasource)?(0,qp.from)(this.datasource.metricFindQuery(e.state.query,dS(uS({},n),{variable:{name:e.state.name,type:e.state.type},searchFilter:t}))).pipe((0,qp.mergeMap)((e=>{if(!e||!e.length)return mS();const t=e;return(0,qp.of)({series:t,state:r.LoadingState.Done,timeRange:n.range})}))):mS()}}class fS{constructor(e,t=(0,a.getRunRequest)()){this.datasource=e,this._runRequest=t}getTarget(e){if(nS(this.datasource))return e.state.query;throw new Error("Couldn't create a target with supplied arguments.")}runRequest(e,t){return nS(this.datasource)?this.datasource.variables.query?this._runRequest(this.datasource,t,this.datasource.variables.query.bind(this.datasource.variables)):this._runRequest(this.datasource,t):mS()}}function mS(){return(0,qp.of)({state:r.LoadingState.Done,series:[],timeRange:(0,r.getDefaultTimeRange)()})}let gS=function(e){if(tS(e))return new pS(e,(0,a.getRunRequest)());if(eS(e))return new hS(e);if(nS(e))return new fS(e);throw new Error(`Couldn't create a query runner for datasource ${e.type}`)};const yS=(e,t)=>{const n=[];let r=null;t.lastIndex=0;do{r=t.exec(e),r&&n.push(r)}while(t.global&&r&&""!==r[0]&&void 0!==r[0]);return n},bS=(e,t)=>{if(t===r.VariableSort.disabled)return e;const n=e=>{if(!e.text)return-1;const t=e.text.match(/.*?(\d+).*/);return!t||t.length<2?-1:parseInt(t[1],10)},i=e=>e.sort(((e,t)=>e.text?t.text?e.text.localeCompare(t.text,void 0,{numeric:!0}):1:-1));switch(t){case r.VariableSort.alphabeticalAsc:e=(0,$c.sortBy)(e,"label");break;case r.VariableSort.alphabeticalDesc:e=(0,$c.sortBy)(e,"label").reverse();break;case r.VariableSort.numericalAsc:e=(0,$c.sortBy)(e,n);break;case r.VariableSort.numericalDesc:e=(e=(0,$c.sortBy)(e,n)).reverse();break;case r.VariableSort.alphabeticalCaseInsensitiveAsc:e=(0,$c.sortBy)(e,(e=>(0,$c.toLower)(e.label)));break;case r.VariableSort.alphabeticalCaseInsensitiveDesc:e=(e=(0,$c.sortBy)(e,(e=>(0,$c.toLower)(e.label)))).reverse();break;case r.VariableSort.naturalAsc||7:e=i(e);break;case r.VariableSort.naturalDesc||8:e=(e=i(e)).reverse()}return e};function vS(){return e=>e.pipe((0,qp.map)((e=>{const t=e.series;if(!t||!t.length)return[];if(function(e){if(!e)return!1;if(!e.length)return!0;const t=e[0];if((0,r.isDataFrame)(t))return!1;for(const e in t){if(!t.hasOwnProperty(e))continue;if(null!==t[e]&&"string"!=typeof t[e]&&"number"!=typeof t[e])continue;const n=e.toLowerCase();if("text"===n||"value"===n)return!0}return!1}(t))return t;if(0===t[0].fields.length)return[];const n=(0,r.getProcessedDataFrames)(t),i=[];let a=-1,o=-1,s=-1,l=-1;for(const e of n)for(let n=0;nt in e?wS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class _S extends Am{constructor(e){super(((e,t)=>{for(var n in t||(t={}))ES.call(t,n)&&OS(e,n,t[n]);if(SS)for(var n of SS(t))xS.call(t,n)&&OS(e,n,t[n]);return e})({type:"query",name:"",value:"",text:"",options:[],datasource:null,regex:"",query:{refId:"A"},refresh:r.VariableRefresh.onDashboardLoad,sort:r.VariableSort.disabled},e)),this._variableDependency=new im(this,{statePaths:["regex","query","datasource"]}),this.onSearchChange=e=>{hy(this.state.query).indexOf(Rf)>-1&&this._updateOptionsBasedOnSearchFilter(e)},this._updateOptionsBasedOnSearchFilter=(0,$c.debounce)((async e=>{const t=await(0,qp.lastValueFrom)(this.getValueOptions({searchFilter:e}));this.setState({options:t,loading:!1})}),400)}getValueOptions(e){return this.state.query?(this.setState({loading:!0,error:null}),(0,qp.from)(nm(this.state.datasource,{__sceneObject:{text:"__sceneObject",value:this}})).pipe((0,qp.mergeMap)((t=>{const n=gS(t),i=n.getTarget(this),a=this.getRequest(i,e.searchFilter);return n.runRequest({variable:this,searchFilter:e.searchFilter},a).pipe(km({type:"variable",request:a,origin:this}),(0,qp.filter)((e=>e.state===r.LoadingState.Done||e.state===r.LoadingState.Error)),(0,qp.take)(1),(0,qp.mergeMap)((e=>e.state===r.LoadingState.Error?(0,qp.throwError)((()=>e.error)):(0,qp.of)(e))),vS(),(0,qp.mergeMap)((e=>{let t="";return this.state.regex&&(t=tm.interpolate(this,this.state.regex,void 0,"regex")),(0,qp.of)(((e,t,n)=>{var i,a,o,s,l,c;let u,d=[];e&&(u=(0,r.stringToJsRegex)(e));for(let e=0;ee.groups&&e.groups.value)),n=e.find((e=>e.groups&&e.groups.text)),h=e.find((e=>e.length>1)),f=e.length>1&&h;if(t||n)p=null!=(o=null==(i=null==t?void 0:t.groups)?void 0:i.value)?o:null==(a=null==n?void 0:n.groups)?void 0:a.text,r=null!=(c=null==(s=null==n?void 0:n.groups)?void 0:s.text)?c:null==(l=null==t?void 0:t.groups)?void 0:l.value;else{if(f){for(let t=0;te.cancelled?(0,qp.of)([]):(0,qp.throwError)((()=>e)))))})))):(0,qp.of)([])}getRequest(e,t){const n={__sceneObject:{text:"__sceneObject",value:this}};t&&(n.__searchFilter={value:t,text:t});const i=tm.getTimeRange(this).state.value;return{app:r.CoreApp.Dashboard,requestId:Xp(),timezone:"",range:i,interval:"",intervalMs:0,targets:[e],scopedVars:n,startTime:Date.now()}}}function TS(e,t){const n=["A","B","C","D","E","F","G","H"],r=[];if(t>5)return[];for(const i of n){const n=`${e}${i}`;r.push({name:n,children:TS(n,t+1)})}return r}function CS(e,t,n){if(n>=t.length)return e;if("*"===t[n])return e;const r=t[n];let i=[],a=[r];r.startsWith("{")&&(a=r.replace(/\{|\}/g,"").split(","));for(const r of e)for(const e of a)if(-1!==e.indexOf("*")){const a=e.replace("*","");new RegExp(`^${a}.*`,"gi").test(r.name)&&(i=i.concat(CS([r],t,n+1)))}else r.name===e&&(i=i.concat(CS(r.children,t,n+1)));return i}function kS(e){if(0===e.indexOf("value"))return[{name:e,children:[]}];return CS(TS("",0),e.split("."),0)}_S.Component=({model:e})=>ug(e);var PS=Object.defineProperty,RS=Object.getOwnPropertySymbols,AS=Object.prototype.hasOwnProperty,DS=Object.prototype.propertyIsEnumerable,jS=(e,t,n)=>t in e?PS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function IS({model:e}){const{value:t,key:n,loading:r}=e.useState(),i=(0,Fi.useCallback)((t=>{e.setValue(t.currentTarget.value)}),[e]),a=(0,Fi.useCallback)((t=>{"Enter"===t.key&&e.setValue(t.currentTarget.value)}),[e]);return $i().createElement(o.AutoSizeInput,{id:n,placeholder:"Enter value",minWidth:15,defaultValue:t,loading:r,onBlur:i,onKeyDown:a})}(class extends Am{constructor(e,t=!1){super(((e,t)=>{for(var n in t||(t={}))AS.call(t,n)&&jS(e,n,t[n]);if(RS)for(var n of RS(t))DS.call(t,n)&&jS(e,n,t[n]);return e})({type:"custom",name:"Test",value:"Value",text:"Text",query:"Query",options:[],refresh:r.VariableRefresh.onDashboardLoad},e)),this.completeUpdate=new qp.Subject,this.isGettingValues=!0,this.getValueOptionsCount=0,this.isLazy=!1,this._variableDependency=new im(this,{statePaths:["query"]}),this.isLazy=t}getValueOptions(e){const{delayMs:t}=this.state;this.getValueOptionsCount+=1;const n=tm.getQueryController(this);return new qp.Observable((e=>{const r={type:"variable",origin:this,cancel:()=>e.complete()};if(n&&n.queryStarted(r),this.setState({loading:!0}),this.state.throwError)throw new Error(this.state.throwError);const i=tm.interpolate(this,this.state.query),a=this.getOptions(i),o=this.completeUpdate.subscribe({next:()=>{this.setState({issuedQuery:i,options:a,loading:!1}),e.next(a),e.complete()}});let s;return t?s=window.setTimeout((()=>this.signalUpdateCompleted()),t):0===t&&this.signalUpdateCompleted(),this.isGettingValues=!0,()=>{o.unsubscribe(),window.clearTimeout(s),this.isGettingValues=!1,this.state.loading&&this.setState({loading:!1}),n&&n.queryCompleted(r)}}))}cancel(){const e=kh(this,(e=>e instanceof Mw?e:void 0));null==e||e.cancel(this)}getOptions(e){return this.state.optionsToReturn?this.state.optionsToReturn:kS(e).map((e=>({label:e.name,value:e.name})))}signalUpdateCompleted(){this.completeUpdate.next(1)}}).Component=({model:e})=>ug(e);var NS=Object.defineProperty,LS=Object.getOwnPropertySymbols,MS=Object.prototype.hasOwnProperty,FS=Object.prototype.propertyIsEnumerable,$S=(e,t,n)=>t in e?NS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;(class extends bh{constructor(e){super(((e,t)=>{for(var n in t||(t={}))MS.call(t,n)&&$S(e,n,t[n]);if(LS)for(var n of LS(t))FS.call(t,n)&&$S(e,n,t[n]);return e})({type:"textbox",value:"",name:""},e)),this._urlSync=new Xh(this,{keys:()=>[this.getKey()]})}getValue(){return this.state.value}setValue(e){e!==this.state.value&&(this.setState({value:e}),this.publishEvent(new pf(this),!0))}getKey(){return`var-${this.state.name}`}getUrlState(){return{[this.getKey()]:this.state.value}}updateFromUrl(e){const t={},n=e[this.getKey()];"string"==typeof n&&(t.value=n),this.setState(t)}}).Component=({model:e})=>$i().createElement(IS,{model:e});Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;var BS=Object.defineProperty,VS=Object.getOwnPropertySymbols,zS=Object.prototype.hasOwnProperty,US=Object.prototype.propertyIsEnumerable,qS=(e,t,n)=>t in e?BS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;(class extends bh{constructor(e){super(((e,t)=>{for(var n in t||(t={}))zS.call(t,n)&&qS(e,n,t[n]);if(VS)for(var n of VS(t))US.call(t,n)&&qS(e,n,t[n]);return e})({type:"interval",value:"",intervals:["1m","10m","30m","1h","6h","12h","1d","7d","14d","30d"],name:"",autoStepCount:30,autoMinInterval:"10s",autoEnabled:!1,refresh:Ey.onTimeRangeChanged},e)),this._onChange=e=>{this.setState({value:e.value}),this.publishEvent(new pf(this),!0)},this._urlSync=new Xh(this,{keys:()=>[this.getKey()]})}getKey(){return`var-${this.state.name}`}getUrlState(){return{[this.getKey()]:this.state.value}}updateFromUrl(e){const t={},n=e[this.getKey()];"string"==typeof n&&(n.startsWith("$__auto_interval_")?t.value=kf:t.value=n),this.setState(t)}getOptionsForSelect(){const{value:e,intervals:t,autoEnabled:n}=this.state;let r=t.map((e=>({value:e,label:e})));return n&&(r=[{value:kf,label:"Auto"},...r]),e&&!r.some((t=>t.value===e))&&r.push({value:e,label:e}),r}getValue(){const{value:e,autoStepCount:t,autoMinInterval:n}=this.state;return e===kf?this.getAutoRefreshInteval(t,n):e}getAutoRefreshInteval(e,t){const n=tm.getTimeRange(this).state.value;return r.rangeUtil.calculateInterval(n,e,t).interval}validateAndUpdate(){const{value:e,intervals:t}=this.state;let n=!1;if(e===kf)n=!0;else if(!e&&t.length>0){const e=t[0];this.setState({value:e}),n=!0}return n&&this.publishEvent(new pf(this),!0),(0,qp.of)({})}}).Component=({model:e})=>{const{key:t,value:n}=e.useState();return $i().createElement(o.Select,{id:t,placeholder:"Select value",width:"auto",value:n,tabSelectsValue:!1,options:e.getOptionsForSelect(),onChange:e._onChange})};class HS{constructor(){this._urlKeyMapper=new Ah,this._stateSub=null,this._locationSub=null,this._ignoreNextLocationUpdate=!1,this._onLocationUpdate=e=>{if(this._ignoreNextLocationUpdate)return void(this._ignoreNextLocationUpdate=!1);if(this._lastPath!==e.pathname)return;const t=new URLSearchParams(e.search);this._urlKeyMapper.rebuildIndex(this._sceneRoot),jh(this._sceneRoot,t,this._urlKeyMapper),this._lastPath=e.pathname},this._onStateChanged=({payload:e})=>{const t=e.changedObject;if(t.urlSync){const e=t.urlSync.getUrlState(),n=a.locationService.getSearch(),r={};this._urlKeyMapper.rebuildIndex(this._sceneRoot);for(const[i,a]of Object.entries(e)){const e=this._urlKeyMapper.getUniqueKey(i,t);Ih(n.getAll(e),a)||(r[e]=a)}Object.keys(r).length>0&&(this._ignoreNextLocationUpdate=!0,a.locationService.partial(r,!0))}}}initSync(e){this._locationSub||(rm(),this._locationSub=a.locationService.getHistory().listen(this._onLocationUpdate)),this._stateSub&&(rm(0,0,this._sceneRoot.state.key),this._stateSub.unsubscribe()),this._sceneRoot=e,this._lastPath=a.locationService.getLocation().pathname,this._stateSub=e.subscribeToEvent(sh,this._onStateChanged),this.syncFrom(this._sceneRoot)}cleanUp(e){this._sceneRoot===e&&(rm(),this._locationSub&&(this._locationSub(),rm(),this._locationSub=null),this._stateSub&&(this._stateSub.unsubscribe(),this._stateSub=null,rm(0,0,(this._sceneRoot.state.key,e.state.key))))}syncFrom(e){const t=a.locationService.getSearch();this._urlKeyMapper.rebuildIndex(this._sceneRoot),jh(e,t,this._urlKeyMapper)}getUrlState(e){return Dh(e)}}let GS;function WS(){return GS||(GS=new HS),GS}class QS extends bh{constructor(e){super(e),this.addActivationHandler((()=>{const e=function(e){const t=window.__grafanaSceneContext;return rm(),window.__grafanaSceneContext=e,()=>{window.__grafanaSceneContext===e&&(rm(),window.__grafanaSceneContext=t)}}(this);return()=>{e(),WS().cleanUp(this)}}))}initUrlSync(){WS().initSync(this)}}QS.Component=function({model:e}){const{body:t,controls:n}=e.useState(),r=(0,o.useStyles2)(KS);return $i().createElement("div",{className:r.container},n&&$i().createElement("div",{className:r.controls},n.map((e=>$i().createElement(e.Component,{key:e.state.key,model:e})))),$i().createElement("div",{className:r.body},$i().createElement(t.Component,{model:t})))};const KS=e=>({container:(0,i.css)({flexGrow:1,display:"flex",gap:e.spacing(2),minHeight:"100%",flexDirection:"column"}),body:(0,i.css)({flexGrow:1,display:"flex",gap:e.spacing(1)}),controls:(0,i.css)({display:"flex",gap:e.spacing(2),alignItems:"flex-end",flexWrap:"wrap"})});class YS extends bh{addItem(e){this.setState({items:this.state.items?[...this.state.items,e]:[e]})}setItems(e){this.setState({items:e})}}YS.Component=function({model:e}){const{items:t=[]}=e.useState(),n=$i().useRef(null);(0,Fi.useEffect)((()=>{n.current&&n.current.focus()}),[]);const r=e=>e.map((e=>{switch(e.type){case"divider":return $i().createElement(o.Menu.Divider,{key:e.text});case"group":return $i().createElement(o.Menu.Group,{key:e.text,label:e.text},e.subMenu?r(e.subMenu):void 0);default:return $i().createElement(o.Menu.Item,{key:e.text,label:e.text,icon:e.iconClassName,childItems:e.subMenu?r(e.subMenu):void 0,url:e.href,onClick:e.onClick,shortcut:e.shortcut,testId:Lm.components.Panels.Panel.menuItems(e.text)})}}));return $i().createElement(o.Menu,{ref:n},r(t))};function XS(e){return e instanceof dx}(class extends bh{}).Component=function({model:e}){const{body:t}=e.useState(),n=e.parent;if(n&&(r=n,!(r instanceof ex))&&!XS(n))throw new Error("SceneGridItem must be a child of SceneGridLayout or SceneGridRow");var r;if(!t)return null;return $i().createElement(t.Component,{model:t})};var JS=__webpack_require__(2548),ZS=__webpack_require__.n(JS),eE=function(){function e(e,t){for(var n=0;n div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; z-index: -1; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }',a=n.head||n.getElementsByTagName("head")[0],o=n.createElement("style");o.id="detectElementResize",o.type="text/css",null!=e&&o.setAttribute("nonce",e),o.styleSheet?o.styleSheet.cssText=r:o.appendChild(n.createTextNode(r)),a.appendChild(o)}}(u),a.__resizeLast__={},a.__resizeListeners__=[],(a.__resizeTriggers__=u.createElement("div")).className="resize-triggers";var p=u.createElement("div");p.className="expand-trigger",p.appendChild(u.createElement("div"));var h=u.createElement("div");h.className="contract-trigger",a.__resizeTriggers__.appendChild(p),a.__resizeTriggers__.appendChild(h),a.appendChild(a.__resizeTriggers__),o(a),a.addEventListener("scroll",s,!0),r&&(a.__resizeTriggers__.__animationListener__=function(e){e.animationName===n&&o(a)},a.__resizeTriggers__.addEventListener(r,a.__resizeTriggers__.__animationListener__))}a.__resizeListeners__.push(c)}},removeResizeListener:function(e,t){if(l)e.detachEvent("onresize",t);else if(e.__resizeListeners__.splice(e.__resizeListeners__.indexOf(t),1),!e.__resizeListeners__.length){e.removeEventListener("scroll",s,!0),e.__resizeTriggers__.__animationListener__&&(e.__resizeTriggers__.removeEventListener(r,e.__resizeTriggers__.__animationListener__),e.__resizeTriggers__.__animationListener__=null);try{e.__resizeTriggers__=!e.removeChild(e.__resizeTriggers__)}catch(e){}}}}}null==cE||null==uE?(aE=sE,oE=function(e){return lE(e,20)}):(aE=function(e){var t=rE(e,2),n=t[0],r=t[1];cE(n),sE(r)},oE=function(e){var t=uE((function(){sE(n),e()})),n=lE((function(){cE(t),e()}),20);return[t,n]});var pE=function(e){function t(){var e,n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var i=arguments.length,a=Array(i),o=0;ot in e?mE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function wE(){const e=(0,Fi.useRef)(void 0);return null!=e.current||(e.current=(0,$c.uniqueId)()),e.current}const SE=$i().forwardRef(((e,t)=>{var n=e,{children:r,onLoad:i,onChange:a}=n,o=((e,t)=>{var n={};for(var r in e)yE.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&gE)for(var r of gE(e))t.indexOf(r)<0&&bE.call(e,r)&&(n[r]=e[r]);return n})(n,["children","onLoad","onChange"]);const s=wE(),[l,c]=(0,Fi.useState)(!1),[u,d]=(0,Fi.useState)(!1),p=(0,Fi.useRef)(null);return(0,Fi.useImperativeHandle)(t,(()=>p.current)),fE((()=>{SE.addCallback(s,(e=>{!l&&e.isIntersecting&&(c(!0),null==i||i()),d(e.isIntersecting),null==a||a(e.isIntersecting)}));const e=p.current;return e&&SE.observer.observe(e),()=>{delete SE.callbacks[s],e&&SE.observer.unobserve(e),0===Object.keys(SE.callbacks).length&&SE.observer.disconnect()}})),$i().createElement("div",((e,t)=>{for(var n in t||(t={}))yE.call(t,n)&&vE(e,n,t[n]);if(gE)for(var n of gE(t))bE.call(t,n)&&vE(e,n,t[n]);return e})({id:s,ref:p},o),l&&("function"==typeof r?r({isInView:u}):r))}));SE.displayName="LazyLoader",SE.callbacks={},SE.addCallback=(e,t)=>SE.callbacks[e]=t,SE.observer=new IntersectionObserver((e=>{for(const t of e)SE.callbacks[t.target.id](t)}),{rootMargin:"100px"});var EE=Object.defineProperty,xE=Object.defineProperties,OE=Object.getOwnPropertyDescriptors,_E=Object.getOwnPropertySymbols,TE=Object.prototype.hasOwnProperty,CE=Object.prototype.propertyIsEnumerable,kE=(e,t,n)=>t in e?EE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,PE=(e,t)=>{for(var n in t||(t={}))TE.call(t,n)&&kE(e,n,t[n]);if(_E)for(var n of _E(t))CE.call(t,n)&&kE(e,n,t[n]);return e},RE=(e,t)=>xE(e,OE(t)),AE=(e,t)=>{var n={};for(var r in e)TE.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&_E)for(var r of _E(e))t.indexOf(r)<0&&CE.call(e,r)&&(n[r]=e[r]);return n};const DE=$i().forwardRef(((e,t)=>{var n;const r=e,{grid:a,layoutItem:o,index:s,totalCount:l,isLazy:c,style:u,onLoad:d,onChange:p,children:h}=r,f=AE(r,["grid","layoutItem","index","totalCount","isLazy","style","onLoad","onChange","children"]),m=a.getSceneLayoutChild(o.i),g=null==(n=m.getClassName)?void 0:n.call(m),y=$i().createElement(m.Component,{model:m,key:m.state.key});return c?$i().createElement(SE,RE(PE({},f),{key:m.state.key,"data-griditem-key":m.state.key,className:(0,i.cx)(g,e.className),style:u,ref:t}),y,h):$i().createElement("div",RE(PE({},f),{ref:t,key:m.state.key,"data-griditem-key":m.state.key,className:(0,i.cx)(g,e.className),style:u}),y,h)}));function jE(e,t,n){e.current?t?e.current.classList.add("react-grid-layout--enable-move-animations"):e.current.classList.remove("react-grid-layout--enable-move-animations"):n||setTimeout((()=>jE(e,t,!0)),50)}DE.displayName="GridItemWrapper";const IE=$i().forwardRef(((e,t)=>{var n=AE(e,["handleAxis"]);const r=(0,o.useStyles2)(NE);return $i().createElement("div",RE(PE({ref:t},n),{className:`${r} scene-resize-handle`}),$i().createElement("svg",{width:"16px",height:"16px",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},$i().createElement("path",{d:"M21 15L15 21M21 8L8 21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})))}));function NE(e){return(0,i.css)({position:"absolute",bottom:0,right:0,zIndex:999,padding:e.spacing(1.5,0,0,1.5),color:e.colors.border.strong,cursor:"se-resize","&:hover":{color:e.colors.text.link},svg:{display:"block"},".react-resizable-hide &":{display:"none"}})}IE.displayName="ResizeHandle";var LE=Object.defineProperty,ME=Object.defineProperties,FE=Object.getOwnPropertyDescriptors,$E=Object.getOwnPropertySymbols,BE=Object.prototype.hasOwnProperty,VE=Object.prototype.propertyIsEnumerable,zE=(e,t,n)=>t in e?LE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function UE(e,t){const n=t-32,r=Math.max(...e.map((e=>e.h+e.y)))/Math.floor(n/38);return e.map((e=>((e,t)=>ME(e,FE(t)))(((e,t)=>{for(var n in t||(t={}))BE.call(t,n)&&zE(e,n,t[n]);if($E)for(var n of $E(t))VE.call(t,n)&&zE(e,n,t[n]);return e})({},e),{y:Math.round(e.y/r)||0,h:Math.round(e.h/r)||1})))}var qE=Object.defineProperty,HE=Object.defineProperties,GE=Object.getOwnPropertyDescriptors,WE=Object.getOwnPropertySymbols,QE=Object.prototype.hasOwnProperty,KE=Object.prototype.propertyIsEnumerable,YE=(e,t,n)=>t in e?qE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,XE=(e,t)=>{for(var n in t||(t={}))QE.call(t,n)&&YE(e,n,t[n]);if(WE)for(var n of WE(t))KE.call(t,n)&&YE(e,n,t[n]);return e},JE=(e,t)=>HE(e,GE(t));const ZE=class extends bh{constructor(e){super(JE(XE({},e),{children:nx(e.children)})),this._skipOnLayoutChange=!1,this._oldLayout=[],this._loadOldLayout=!1,this.onLayoutChange=e=>{if(this._skipOnLayoutChange)this._skipOnLayoutChange=!1;else{this._loadOldLayout&&(e=[...this._oldLayout],this._loadOldLayout=!1);for(const t of e){const e=this.getSceneLayoutChild(t.i),n={x:t.x,y:t.y,width:t.w,height:t.h};tx(e.state,n)||e.setState(XE({},n))}this.setState({children:nx(this.state.children)})}},this.onResizeStop=(e,t,n)=>{this.getSceneLayoutChild(n.i).setState({width:n.w,height:n.h})},this.onDragStart=e=>{this._oldLayout=[...e]},this.onDragStop=(e,t,n)=>{const r=this.getSceneLayoutChild(n.i);e=rx(e);for(let t=0;te.i===n.i));let a=this.findGridItemSceneParent(e,i-1),o=this.state.children;r instanceof dx&&a instanceof dx&&(this.isRowDropValid(e,n,i)||(this._loadOldLayout=!0),a=this),a!==r.parent&&(o=this.moveChildTo(r,a)),this.setState({children:nx(o)}),this._skipOnLayoutChange=!0}}isDraggable(){var e;return null!=(e=this.state.isDraggable)&&e}getDragClass(){return`grid-drag-handle-${this.state.key}`}getDragClassCancel(){return"grid-drag-cancel"}toggleRow(e){var t,n;if(!e.state.isCollapsed)return e.setState({isCollapsed:!0}),void this.setState({});const r=e.state.children;if(0===r.length)return e.setState({isCollapsed:!1}),void this.setState({});const i=e.state.y,a=(null!=(t=r[0].state.y)?t:i)-(i+1);let o=i;for(const e of r){const t=XE({},e.state);t.y=null!=(n=t.y)?n:i,t.y-=a,t.y!==e.state.y&&e.setState(t),o=Math.max(o,Number(t.y)+Number(t.height))}const s=o-i-1;for(const t of this.state.children)if(t.state.y>i&&this.pushChildDown(t,s),XS(t)&&t!==e)for(const e of t.state.children)e.state.y>i&&this.pushChildDown(e,s);e.setState({isCollapsed:!1}),this.setState({})}getSceneLayoutChild(e){for(const t of this.state.children){if(t.state.key===e)return t;if(t instanceof dx)for(const n of t.state.children)if(n.state.key===e)return n}throw new Error("Scene layout child not found for GridItem")}pushChildDown(e,t){e.setState({y:e.state.y+t})}findGridItemSceneParent(e,t){for(let n=t;n>=0;n--){const t=e[n],r=this.getSceneLayoutChild(t.i);if(r instanceof dx)return r.state.isCollapsed?this:r}return this}isRowDropValid(e,t,n){if(e[e.length-1].i===t.i)return!0;const r=this.getSceneLayoutChild(e[n+1].i);return r instanceof dx||r.parent instanceof ZE}moveChildTo(e,t){const n=e.parent;let r=this.state.children;const i=e.clone({key:e.state.key});if(n instanceof dx){const a=n.clone();if(a.setState({children:a.state.children.filter((t=>t.state.key!==e.state.key))}),r=r.map((e=>e===n?a:e)),t instanceof dx){const e=t.clone();e.setState({children:[...e.state.children,i]}),r=r.map((n=>n===t?e:n))}else r=[...r,i]}else if(!(t instanceof ZE)){r=r.filter((t=>t.state.key!==e.state.key));const n=t.clone();n.setState({children:[...n.state.children,i]}),r=r.map((e=>e===t?n:e))}return r}toGridCell(e){var t,n;const r=e.state;let i=null!=(t=r.x)?t:0,a=null!=(n=r.y)?n:0;const o=Number.isInteger(Number(r.width))?Number(r.width):4,s=Number.isInteger(Number(r.height))?Number(r.height):4;let l=e.state.isDraggable,c=e.state.isResizable;return e instanceof dx&&(l=!!e.state.isCollapsed,c=!1),{i:e.state.key,x:i,y:a,h:s,w:o,isResizable:c,isDraggable:l}}buildGridLayout(e,t){let n=[];for(const e of this.state.children)if(n.push(this.toGridCell(e)),e instanceof dx&&!e.state.isCollapsed)for(const t of e.state.children)n.push(this.toGridCell(t));return n=rx(n),this.state.UNSAFE_fitPanels&&(n=UE(n,t)),e<768?(this._skipOnLayoutChange=!0,n.map((e=>JE(XE({},e),{w:24})))):(this._skipOnLayoutChange=!1,n)}};let ex=ZE;function tx(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function nx(e){return e.forEach((e=>{e instanceof dx&&e.setState({children:nx(e.state.children)})})),[...e].sort(((e,t)=>e.state.y-t.state.y||e.state.x-t.state.x))}function rx(e){return[...e].sort(((e,t)=>e.y-t.y||e.x-t.x))}ex.Component=function({model:e}){const{children:t,isLazy:n,isDraggable:r,isResizable:i}=e.useState(),a=(0,Fi.useRef)(null);return(0,Fi.useEffect)((()=>{jE(a,!!r)}),[r]),function(e){if(e.some((e=>void 0===e.state.height||void 0===e.state.width||void 0===e.state.x||void 0===e.state.y)))throw new Error("All children must have a size specified")}(t),$i().createElement(hE,null,(({width:t,height:o})=>{if(0===t)return null;const s=e.buildGridLayout(t,o);return $i().createElement("div",{ref:a,style:{width:`${t}px`,height:"100%",position:"relative",zIndex:1},className:"react-grid-layout"},$i().createElement(ZS(),{width:t,isDraggable:r&&t>768,isResizable:null!=i&&i,containerPadding:[0,0],useCSSTransforms:!0,margin:[8,8],cols:24,rowHeight:30,draggableHandle:`.grid-drag-handle-${e.state.key}`,draggableCancel:".grid-drag-cancel",layout:s,onDragStart:e.onDragStart,onDragStop:e.onDragStop,onResizeStop:e.onResizeStop,onLayoutChange:e.onLayoutChange,isBounded:!1,resizeHandle:$i().createElement(IE,null)},s.map(((t,r)=>$i().createElement(DE,{key:t.i,grid:e,layoutItem:t,index:r,isLazy:n,totalCount:s.length})))))}))};var ix=Object.defineProperty,ax=Object.defineProperties,ox=Object.getOwnPropertyDescriptors,sx=Object.getOwnPropertySymbols,lx=Object.prototype.hasOwnProperty,cx=Object.prototype.propertyIsEnumerable,ux=(e,t,n)=>t in e?ix(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class dx extends bh{constructor(e){super(((e,t)=>ax(e,ox(t)))(((e,t)=>{for(var n in t||(t={}))lx.call(t,n)&&ux(e,n,t[n]);if(sx)for(var n of sx(t))cx.call(t,n)&&ux(e,n,t[n]);return e})({children:e.children||[],isCollapsible:e.isCollapsible||!0,title:e.title||""},e),{x:0,height:1,width:24})),this.onCollapseToggle=()=>{this.state.isCollapsible&&this.getGridLayout().toggleRow(this)}}getGridLayout(){const e=this.parent;if(!(e&&e instanceof ex))throw new Error("SceneGridRow must be a child of SceneGridLayout");return e}getUrlState(){return{rowc:this.state.isCollapsed?"1":"0"}}updateFromUrl(e){null!=e.rowc&&e.rowc!==this.getUrlState().rowc&&this.onCollapseToggle()}}dx.Component=function({model:e}){const t=(0,o.useStyles2)(px),{isCollapsible:n,isCollapsed:r,title:a,actions:s,children:l}=e.useState(),c=e.getGridLayout(),u=c.getDragClass(),d=c.isDraggable(),p=l?l.length:0,h=1===p?"panel":"panels";return $i().createElement("div",{className:(0,i.cx)(t.row,r&&t.rowCollapsed)},$i().createElement("div",{className:t.rowTitleAndActionsGroup},$i().createElement("button",{onClick:e.onCollapseToggle,className:t.rowTitleButton,"aria-label":r?"Expand row":"Collapse row","data-testid":Lm.components.DashboardRow.title(tm.interpolate(e,a,void 0,"text"))},n&&$i().createElement(o.Icon,{name:r?"angle-right":"angle-down"}),$i().createElement("span",{className:t.rowTitle,role:"heading"},tm.interpolate(e,a,void 0,"text"))),$i().createElement("span",{className:(0,i.cx)(t.panelCount,r&&t.panelCountCollapsed)},"(",p," ",h,")"),s&&$i().createElement("div",{className:t.rowActions},$i().createElement(s.Component,{model:s}))),d&&r&&$i().createElement("div",{className:(0,i.cx)(t.dragHandle,u)},$i().createElement(o.Icon,{name:"draggabledots"})))};const px=e=>({row:(0,i.css)({width:"100%",height:"30px",display:"flex",justifyContent:"space-between",gap:e.spacing(1)}),rowTitleButton:(0,i.css)({display:"flex",alignItems:"center",cursor:"pointer",background:"transparent",border:"none",gap:e.spacing(1)}),rowCollapsed:(0,i.css)({borderBottom:`1px solid ${e.colors.border.weak}`}),rowTitle:(0,i.css)({fontSize:e.typography.h5.fontSize,fontWeight:e.typography.fontWeightMedium}),collapsedInfo:(0,i.css)({fontSize:e.typography.bodySmall.fontSize,color:e.colors.text.secondary,display:"flex",alignItems:"center",flexGrow:1}),rowTitleAndActionsGroup:(0,i.css)({display:"flex","&:hover, &:focus-within":{"& > div":{opacity:1}}}),rowActions:(0,i.css)({display:"flex",opacity:0,transition:"200ms opacity ease-in 200ms","&:hover, &:focus-within":{opacity:1}}),dragHandle:(0,i.css)({display:"flex",padding:e.spacing(0,1),alignItems:"center",justifyContent:"flex-end",cursor:"move",color:e.colors.text.secondary,"&:hover":{color:e.colors.text.primary}}),panelCount:(0,i.css)({paddingLeft:e.spacing(2),color:e.colors.text.secondary,fontStyle:"italic",fontSize:e.typography.size.sm,fontWeight:"normal",display:"none",lineHeight:"30px"}),panelCountCollapsed:(0,i.css)({display:"inline-block"})});(class extends bh{constructor(){super(...arguments),this.onToggle=()=>{this.setState({isCollapsed:!this.state.isCollapsed})},this.onRemove=()=>{const e=this.parent;(function(e){return"body"in e.state})(e)&&e.setState({body:void 0})}}}).Component=function({model:e}){const{title:t,isCollapsed:n,canCollapse:r,canRemove:a,body:s,controls:l}=e.useState(),c=(0,o.useStyles2)(px),u=(0,o.useStyles2)(hx),d=(null!=l?l:[]).map((e=>$i().createElement(e.Component,{key:e.state.key,model:e})));a&&d.push($i().createElement(o.ToolbarButton,{icon:"times",variant:"default",onClick:e.onRemove,key:"remove-button","aria-label":"Remove scene"}));return $i().createElement("div",{className:u.wrapper},$i().createElement("div",{className:(0,i.cx)(u.row,n&&u.rowCollapsed)},$i().createElement("button",{onClick:e.onToggle,className:c.rowTitleButton,"aria-label":n?"Expand scene":"Collapse scene"},r&&$i().createElement(o.Icon,{name:n?"angle-right":"angle-down"}),$i().createElement("span",{className:c.rowTitle,role:"heading"},tm.interpolate(e,t,void 0,"text"))),$i().createElement("div",{className:u.actions},d)),!n&&$i().createElement(s.Component,{model:s}))};const hx=e=>({wrapper:(0,i.css)({display:"flex",flexDirection:"column",flexGrow:1,gap:e.spacing(1)}),row:(0,i.css)({width:"100%",display:"flex",justifyContent:"space-between",gap:e.spacing(1)}),rowCollapsed:(0,i.css)({borderBottom:`1px solid ${e.colors.border.weak}`,paddingBottom:e.spacing(1)}),actions:(0,i.css)({display:"flex",alignItems:"center",gap:e.spacing(1),justifyContent:"flex-end",flexGrow:1})});(class extends bh{constructor(){super(...arguments),this._variableDependency=new im(this,{statePaths:["text"]})}}).Component=({model:e})=>{const{text:t,fontSize:n=20,align:r="left",key:a,spacing:s}=e.useState(),l=(0,o.useTheme2)(),c=(0,i.css)({fontSize:n,display:"flex",flexGrow:1,alignItems:"center",padding:s?l.spacing(s,0):void 0,justifyContent:r});return $i().createElement("div",{className:c,"data-testid":a},tm.interpolate(e,t))};(class extends bh{}).Component=({model:e})=>{const t=e.useState();return $i().createElement(o.ToolbarButton,{onClick:t.onClick,icon:t.icon})};(class extends bh{}).Component=({model:e})=>{const t=e.useState();return $i().createElement("div",{style:{display:"flex"}},t.label&&$i().createElement(_g,{label:t.label}),$i().createElement(o.Input,{defaultValue:t.value,width:8,onBlur:t=>{e.state.onChange(parseInt(t.currentTarget.value,10))}}))};class fx extends bh{constructor(){super(...arguments),this.onZoom=()=>{const e=tm.getTimeRange(this),t=function(e,t){const n=e.to.valueOf()-e.from.valueOf(),i=e.to.valueOf()-n/2,a=0===n?3e4:n*t,o=i+a/2,s=i-a/2;return{from:(0,r.toUtc)(s),to:(0,r.toUtc)(o),raw:{from:(0,r.toUtc)(s),to:(0,r.toUtc)(o)}}}(e.state.value,2);e.onTimeRangeChange(t)},this.onChangeFiscalYearStartMonth=e=>{tm.getTimeRange(this).setState({fiscalYearStartMonth:e})},this.onMoveBackward=()=>{const e=tm.getTimeRange(this),{state:{value:t}}=e;e.onTimeRangeChange(gx(mx.Backward,t,Date.now()))},this.onMoveForward=()=>{const e=tm.getTimeRange(this),{state:{value:t}}=e;e.onTimeRangeChange(gx(mx.Forward,t,Date.now()))}}}fx.Component=function({model:e}){const{hidePicker:t,isOnCanvas:n}=e.useState(),r=tm.getTimeRange(e),i=r.getTimeZone(),a=r.useState();if(t)return null;return $i().createElement(o.TimeRangePicker,{isOnCanvas:null==n||n,value:a.value,onChange:r.onTimeRangeChange,timeZone:i,fiscalYearStartMonth:a.fiscalYearStartMonth,onMoveBackward:e.onMoveBackward,onMoveForward:e.onMoveForward,onZoom:e.onZoom,onChangeTimeZone:r.onTimeZoneChange,onChangeFiscalYearStartMonth:e.onChangeFiscalYearStartMonth})};var mx=(e=>(e[e.Backward=0]="Backward",e[e.Forward=1]="Forward",e))(mx||{});function gx(e,t,n){const i=t.to.valueOf(),a=t.from.valueOf(),o=(i-a)/2;let s,l;0===e?(s=a-o,l=i-o):(s=a+o,l=i+o,l>n&&it in e?yx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const Ox=["5s","10s","30s","1m","5m","15m","30m","1h","2h","1d"];class _x extends bh{constructor(e){var t,n,i;super(((e,t)=>bx(e,vx(t)))(((e,t)=>{for(var n in t||(t={}))Sx.call(t,n)&&xx(e,n,t[n]);if(wx)for(var n of wx(t))Ex.call(t,n)&&xx(e,n,t[n]);return e})({refresh:""},e),{autoValue:void 0,autoEnabled:null==(t=e.autoEnabled)||t,autoMinInterval:null!=(n=e.autoMinInterval)?n:a.config.minRefreshInterval,intervals:null!=(i=e.intervals)?i:Ox})),this._urlSync=new Xh(this,{keys:["refresh"]}),this.onRefresh=()=>{const e=tm.getQueryController(this);if(null==e?void 0:e.state.isRunning)return void e.cancelAll();const t=tm.getTimeRange(this);this._intervalTimer&&clearInterval(this._intervalTimer),t.onRefresh(),this.setupIntervalTimer()},this.onIntervalChanged=e=>{this.setState({refresh:e}),this.setupIntervalTimer()},this.setupAutoTimeRangeListener=()=>tm.getTimeRange(this).subscribeToState(((e,t)=>{e.from===t.from&&e.to===t.to||this.setupIntervalTimer()})),this.calculateAutoRefreshInterval=()=>{var e;const t=tm.getTimeRange(this),n=null!=(e=null==window?void 0:window.innerWidth)?e:2e3;return r.rangeUtil.calculateInterval(t.state.value,n,this.state.autoMinInterval)},this.setupIntervalTimer=()=>{var e;const t=tm.getTimeRange(this),{refresh:n,intervals:i}=this.state;if((this._intervalTimer||""===n)&&clearInterval(this._intervalTimer),""===n)return;if(n!==o.RefreshPicker.autoOption.value&&i&&!i.includes(n))return;let a;if(null==(e=this._autoTimeRangeListener)||e.unsubscribe(),n===o.RefreshPicker.autoOption.value){const e=this.calculateAutoRefreshInterval();a=e.intervalMs,this._autoTimeRangeListener=this.setupAutoTimeRangeListener(),e.interval!==this.state.autoValue&&this.setState({autoValue:e.interval})}else a=r.rangeUtil.intervalToMs(n);this._intervalTimer=setInterval((()=>{t.onRefresh()}),a)},this.addActivationHandler((()=>(this.setupIntervalTimer(),()=>{var e;this._intervalTimer&&clearInterval(this._intervalTimer),null==(e=this._autoTimeRangeListener)||e.unsubscribe()})))}getUrlState(){return{refresh:""!==this.state.refresh?this.state.refresh:void 0}}updateFromUrl(e){const t=e.refresh;"string"==typeof t?this.setState({refresh:t}):null==t&&this.setState({refresh:""})}}_x.Component=function({model:e}){var t;const{refresh:n,intervals:r,autoEnabled:i,autoValue:a,isOnCanvas:s,primary:l,withText:c}=e.useState(),u=function(e){const t=tm.getQueryController(e);if(!t)return!1;return t.useState().isRunning}(e);let d,p,h=n===(null==(t=o.RefreshPicker.autoOption)?void 0:t.value)?a:c?"Refresh":void 0;u&&(d="Cancel all queries",c&&(h="Cancel"));c&&(p="96px");return $i().createElement(o.RefreshPicker,{showAutoInterval:i,value:n,intervals:r,tooltip:d,width:p,text:h,onRefresh:e.onRefresh,primary:l,onIntervalChanged:e.onIntervalChanged,isLoading:u,isOnCanvas:null==s||s})};const Tx=e=>`${e}-compare`;var Cx=Object.defineProperty,kx=Object.defineProperties,Px=Object.getOwnPropertyDescriptors,Rx=Object.getOwnPropertySymbols,Ax=Object.prototype.hasOwnProperty,Dx=Object.prototype.propertyIsEnumerable,jx=(e,t,n)=>t in e?Cx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ix=(e,t)=>{for(var n in t||(t={}))Ax.call(t,n)&&jx(e,n,t[n]);if(Rx)for(var n of Rx(t))Dx.call(t,n)&&jx(e,n,t[n]);return e},Nx=(e,t)=>kx(e,Px(t));const Lx="__previousPeriod",Mx="__noPeriod",Fx={label:"Previous period",value:Lx},$x={label:"No comparison",value:Mx},Bx=[{label:"Day before",value:"24h"},{label:"Week before",value:"1w"},{label:"Month before",value:"1M"}];(class extends bh{constructor(e){super(Ix({compareOptions:Bx},e)),this._urlSync=new Xh(this,{keys:["compareWith"]}),this._onActivate=()=>{const e=tm.getTimeRange(this);this.setState({compareOptions:this.getCompareOptions(e.state.value)}),this._subs.add(e.subscribeToState((e=>{const t=this.getCompareOptions(e.value),n={compareOptions:t};Boolean(this.state.compareWith)&&!t.find((({value:e})=>e===this.state.compareWith))&&(n.compareWith=Lx),this.setState(n)})))},this.getCompareOptions=e=>{const t=Math.ceil(e.to.diff(e.from)),n=Bx.findIndex((({value:e})=>r.rangeUtil.intervalToMs(e)>=t));return[$x,Fx,...Bx.slice(n).map((({label:e,value:t})=>({label:e,value:t})))]},this.onCompareWithChanged=e=>{e===Mx?this.onClearCompare():this.setState({compareWith:e})},this.onClearCompare=()=>{this.setState({compareWith:void 0})},this.addActivationHandler(this._onActivate)}getExtraQueries(e){const t=[],n=this.getCompareTimeRange(e.range);if(!n)return t;const r=e.targets.filter((e=>!1!==e.timeRangeCompare));return r.length&&t.push({req:Nx(Ix({},e),{targets:r,range:n}),processor:Vx}),t}shouldRerun(e,t){return e.compareWith!==t.compareWith}getCompareTimeRange(e){let t,n;if(this.state.compareWith){if(this.state.compareWith===Lx){const i=e.to.diff(e.from);t=(0,r.dateTime)(e.from).subtract(i),n=(0,r.dateTime)(e.to).subtract(i)}else t=(0,r.dateTime)(e.from).subtract(r.rangeUtil.intervalToMs(this.state.compareWith)),n=(0,r.dateTime)(e.to).subtract(r.rangeUtil.intervalToMs(this.state.compareWith));return{from:t,to:n,raw:{from:t,to:n}}}}getUrlState(){return{compareWith:this.state.compareWith}}updateFromUrl(e){if(!e.compareWith)return;const t=Zh(e.compareWith);if(t){this.getCompareOptions(tm.getTimeRange(this).state.value).find((({value:e})=>e===t))?this.setState({compareWith:t}):this.setState({compareWith:"__previousPeriod"})}}}).Component=function({model:e}){var t;const n=(0,o.useStyles2)(zx),{compareWith:r,compareOptions:i}=e.useState(),[a,s]=$i().useState(r),l=null!=(t=i.find((({value:e})=>e===a)))?t:Fx,c=i.find((({value:e})=>e===r)),u=Boolean(c),d=()=>{u?(s(r),e.onClearCompare()):u||e.onCompareWithChanged(l.value)};return $i().createElement(o.ButtonGroup,null,$i().createElement(o.ToolbarButton,{variant:"canvas",tooltip:"Enable time frame comparison",onClick:e=>{e.stopPropagation(),e.preventDefault(),d()}},$i().createElement(o.Checkbox,{label:" ",value:u,onClick:d}),"Comparison"),u?$i().createElement(o.ButtonSelect,{variant:"canvas",value:c,options:i,onChange:t=>{e.onCompareWithChanged(t.value)}}):$i().createElement(o.ToolbarButton,{className:n.previewButton,disabled:!0,variant:"canvas",isOpen:!1},l.label))};const Vx=(e,t)=>{const n=t.timeRange.from.diff(e.timeRange.from);return t.series.forEach((e=>{e.refId=Tx(e.refId||""),e.meta=Nx(Ix({},e.meta),{timeCompare:{diffMs:n,isTimeShiftQuery:!0}}),e.fields.forEach((e=>(e.type===r.FieldType.time&&(e.values=e.values.map((e=>n<0?e-n:e+n))),e.config=Nx(Ix({},e.config),{color:{mode:"fixed",fixedColor:a.config.theme.palette.gray60}}),e)))})),(0,qp.of)(t)};function zx(e){return{previewButton:(0,i.css)({"&:disabled":{border:`1px solid ${e.colors.secondary.border}`,color:e.colors.text.disabled,opacity:1}})}}(class extends bh{constructor(e){super(e),this.addActivationHandler((()=>{const e=tm.getData(this);this._subs.add(e.subscribeToState((e=>{var t;(null==(t=e.data)?void 0:t.state)===r.LoadingState.Done&&this.performRepeat(e.data)}))),e.state.data&&this.performRepeat(e.state.data)}))}performRepeat(e){const t=[];for(let n=0;n{const{body:t}=e.useState();return $i().createElement(t.Component,{model:t})};(class extends bh{constructor(e){super(e),this._variableDependency=new im(this,{variableNames:[this.state.variableName],onVariableUpdateCompleted:()=>this.performRepeat()}),this.addActivationHandler((()=>this.performRepeat()))}performRepeat(){if(this._variableDependency.hasDependencyInLoadingState())return;const e=tm.lookupVariable(this.state.variableName,this);if(!(e instanceof Am))return void console.error("SceneByVariableRepeater: variable is not a MultiValueVariable");const t=function(e){const{value:t,text:n,options:r}=e.state;if(e.hasAllValue())return r;if(Array.isArray(t)&&Array.isArray(n))return t.map(((e,t)=>({value:e,label:n[t]})));return[{value:t,label:n}]}(e),n=[];for(const e of t){const t=this.state.getLayoutChild(e);n.push(t)}this.state.body.setState({children:n})}}).Component=({model:e})=>{const{body:t}=e.useState();return $i().createElement(t.Component,{model:t})};const Ux=class extends bh{constructor(){super({})}get Component(){return Ux.Component}};Ux.Component=e=>$i().createElement("div",{style:{flexGrow:1}});class qx extends bh{toggleDirection(){this.setState({direction:"row"===this.state.direction?"column":"row"})}isDraggable(){return!1}}qx.Component=function({model:e,parentState:t}){const{children:n,isHidden:r}=e.useState(),o=function(e,t){return(0,Fi.useMemo)((()=>{var n,r,o,s,l,c,u,d,p,h;const{direction:f="row",wrap:m}=e,g=a.config.theme2,y={};return t?Gx(y,e,t):(y.display="flex",y.flexGrow=1,y.minWidth=e.minWidth,y.minHeight=e.minHeight),y.flexDirection=f,y.gap="8px",y.flexWrap=m||"nowrap",y.alignContent="baseline",y.minWidth=y.minWidth||0,y.minHeight=y.minHeight||0,y[g.breakpoints.down("md")]={flexDirection:null!=(r=null==(n=e.md)?void 0:n.direction)?r:"column",maxWidth:null!=(s=null==(o=e.md)?void 0:o.maxWidth)?s:"unset",maxHeight:null!=(c=null==(l=e.md)?void 0:l.maxHeight)?c:"unset",height:null!=(d=null==(u=e.md)?void 0:u.height)?d:"unset",width:null!=(h=null==(p=e.md)?void 0:p.width)?h:"unset"},(0,i.css)(y)}),[t,e])}(e.state,t);if(r)return null;return $i().createElement("div",{className:o},n.map((t=>{const n=t.Component;return $i().createElement(n,{key:t.state.key,model:t,parentState:e.state})})))};class Hx extends bh{}function Gx(e,t,n){var r,i,a;const o=null!=(r=n.direction)?r:"row",{xSizing:s="fill",ySizing:l="fill"}=t;return e.display="flex",e.position="relative",e.flexDirection=o,"column"===o?(t.height?e.height=t.height:e.flexGrow="fill"===l?1:0,t.width?e.width=t.width:e.alignSelf="fill"===s?"stretch":"flex-start"):(t.height?e.height=t.height:e.alignSelf="fill"===l?"stretch":"flex-start",t.width?e.width=t.width:e.flexGrow="fill"===s?1:0),e.minWidth=t.minWidth,e.maxWidth=t.maxWidth,e.maxHeight=t.maxHeight,e.minHeight=null!=(i=t.minHeight)?i:n.minHeight,e.height=null!=(a=t.height)?a:n.height,e}Hx.Component=function({model:e,parentState:t}){if(!t)throw new Error("SceneFlexItem must be a child of SceneFlexLayout");const{body:n,isHidden:r}=e.useState(),o=function(e,t){return(0,Fi.useMemo)((()=>{var n,r,o,s,l,c,u,d,p,h;const f=a.config.theme2,m=Gx({},e,t);return m[f.breakpoints.down("md")]={maxWidth:null!=(r=null==(n=e.md)?void 0:n.maxWidth)?r:"unset",maxHeight:null!=(s=null==(o=e.md)?void 0:o.maxHeight)?s:"unset",height:null!=(u=null==(l=e.md)?void 0:l.height)?u:null==(c=t.md)?void 0:c.height,width:null!=(h=null==(d=e.md)?void 0:d.width)?h:null==(p=t.md)?void 0:p.width},(0,i.css)(m)}),[e,t])}(e.state,t);if(!n||r)return null;return $i().createElement("div",{className:o},$i().createElement(n.Component,{model:n}))};var Wx=Object.defineProperty,Qx=Object.getOwnPropertySymbols,Kx=Object.prototype.hasOwnProperty,Yx=Object.prototype.propertyIsEnumerable,Xx=(e,t,n)=>t in e?Wx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class Jx extends bh{constructor(e){var t,n;super(((e,t)=>{for(var n in t||(t={}))Kx.call(t,n)&&Xx(e,n,t[n]);if(Qx)for(var n of Qx(t))Yx.call(t,n)&&Xx(e,n,t[n]);return e})({rowGap:1,columnGap:1,templateColumns:"repeat(auto-fit, minmax(400px, 1fr))",autoRows:null!=(t=e.autoRows)?t:"320px",children:null!=(n=e.children)?n:[]},e))}isDraggable(){return!1}}Jx.Component=function({model:e}){const{children:t,isHidden:n,isLazy:r}=e.useState(),o=(s=e.state,(0,Fi.useMemo)((()=>{var e,t,n,r,o,l,c,u,d,p,h;const f={},m=a.config.theme2;return f.display="grid",f.gridTemplateColumns=s.templateColumns,f.gridTemplateRows=s.templateRows||"unset",f.gridAutoRows=s.autoRows||"unset",f.rowGap=m.spacing(null!=(e=s.rowGap)?e:1),f.columnGap=m.spacing(null!=(t=s.columnGap)?t:1),f.justifyItems=s.justifyItems||"unset",f.alignItems=s.alignItems||"unset",f.justifyContent=s.justifyContent||"unset",f.flexGrow=1,s.md&&(f[m.breakpoints.down("md")]={gridTemplateRows:null==(n=s.md)?void 0:n.templateRows,gridTemplateColumns:null==(r=s.md)?void 0:r.templateColumns,rowGap:s.md.rowGap?m.spacing(null!=(l=null==(o=s.md)?void 0:o.rowGap)?l:1):void 0,columnGap:s.md.columnGap?m.spacing(null!=(u=null==(c=s.md)?void 0:c.rowGap)?u:1):void 0,justifyItems:null==(d=s.md)?void 0:d.justifyItems,alignItems:null==(p=s.md)?void 0:p.alignItems,justifyContent:null==(h=s.md)?void 0:h.justifyContent}),(0,i.css)(f)}),[s]));var s;if(n)return null;return $i().createElement("div",{className:o},t.map((t=>{const n=t.Component;return r?$i().createElement(SE,{key:t.state.key,className:o},$i().createElement(n,{key:t.state.key,model:t,parentState:e.state})):$i().createElement(n,{key:t.state.key,model:t,parentState:e.state})})))};class Zx extends bh{}Zx.Component=function({model:e,parentState:t}){if(!t)throw new Error("SceneCSSGridItem must be a child of SceneCSSGridLayout");const{body:n,isHidden:r}=e.useState(),a=(o=e.state,(0,Fi.useMemo)((()=>{const e={};return e.gridColumn=o.gridColumn||"unset",e.gridRow=o.gridRow||"unset",e.position="relative",(0,i.css)(e)}),[o]));var o;if(!n||r)return null;return $i().createElement("div",{className:a},$i().createElement(n.Component,{model:n}))};var eO=Object.defineProperty,tO=Object.getOwnPropertySymbols,nO=Object.prototype.hasOwnProperty,rO=Object.prototype.propertyIsEnumerable,iO=(e,t,n)=>t in e?eO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,aO=(e,t)=>{for(var n in t||(t={}))nO.call(t,n)&&iO(e,n,t[n]);if(tO)for(var n of tO(t))rO.call(t,n)&&iO(e,n,t[n]);return e};const oO=.3,sO=new Set(["ArrowUp","ArrowDown"]),lO=new Set(["ArrowLeft","ArrowRight"]),cO={row:{dim:"width",axis:"clientX",min:"minWidth",max:"maxWidth"},column:{dim:"height",axis:"clientY",min:"minHeight",max:"maxHeight"}};function uO({direction:e="row",handleSize:t=32,initialSize:n="auto",primaryPaneStyles:r,secondaryPaneStyles:a,onDragFinished:s,children:l}){const c=$i().Children.toArray(l),u=(0,Fi.useRef)(null),d=(0,Fi.useRef)(null),p=(0,Fi.useRef)(null),h=(0,Fi.useRef)(null),f=(0,Fi.useRef)(null),m=(0,Fi.useRef)("1fr"),g=(0,Fi.useRef)(void 0),y=(0,Fi.useRef)(void 0),b=cO[e].dim,v=cO[e].axis,w=cO[e].min,S=cO[e].max;!function(e,t,n=0,r){const i=(0,$c.throttle)(t,n);(0,Fi.useLayoutEffect)((()=>{if(!e)return;const t=new ResizeObserver(i);return t.observe(e,{box:"device-pixel-content-box"}),()=>t.disconnect()}),r)}(h.current,(e=>{for(const t of e){if(!t.target.isSameNode(h.current))return;const e=d.current.getBoundingClientRect()[b],n=pO(d.current);u.current.ariaValueNow=`${(0,$c.clamp)((e-n[w])/(n[S]-n[w])*100,0,100)}`}}),500,[S,w,e,b]);const E=(0,Fi.useRef)(null),x=(0,Fi.useCallback)((e=>{m.current=d.current.getBoundingClientRect()[b],f.current=h.current.getBoundingClientRect()[b],E.current=e[v],u.current.setPointerCapture(e.pointerId),g.current=pO(d.current),y.current=void 0}),[b,v]),O=(0,Fi.useCallback)((e=>{if(null!==E.current&&"1fr"!==m.current){const n=e[v]-E.current,r=g.current,i=(0,$c.clamp)(m.current+n,r[w],r[S]),a=i/(f.current-t);d.current.style.flexGrow=`${a}`,p.current.style.flexGrow=""+(1-a);const o=(0,$c.clamp)((i-r[w])/(r[S]-r[w])*100,0,100);u.current.ariaValueNow=`${o}`}}),[t,v,w,S]),_=(0,Fi.useCallback)((e=>{e.preventDefault(),e.stopPropagation(),u.current.releasePointerCapture(e.pointerId),E.current=null,null==s||s(parseFloat(d.current.style.flexGrow))}),[s]),T=(0,Fi.useRef)(new Set),C=(0,Fi.useRef)(null),k=(0,Fi.useCallback)((n=>{var r;if(0===T.current.size)return void(C.current=null);if("1fr"===m.current)return;const i=(n-(null!=(r=C.current)?r:n))*oO;let a=0;"row"===e?(T.current.has("ArrowLeft")&&(a-=i),T.current.has("ArrowRight")&&(a+=i)):(T.current.has("ArrowUp")&&(a-=i),T.current.has("ArrowDown")&&(a+=i));const o=g.current,s=d.current.getBoundingClientRect()[b],l=(0,$c.clamp)(s+a,o[w],o[S]),c=l/(f.current-t);d.current.style.flexGrow=`${c}`,p.current.style.flexGrow=""+(1-c);const h=(l-o[w])/(o[S]-o[w])*100;u.current.ariaValueNow=`${(0,$c.clamp)(h,0,100)}`,C.current=n,window.requestAnimationFrame(k)}),[e,t,w,S,b]),P=(0,Fi.useCallback)((n=>{if("Enter"===n.key)return void(void 0===y.current?(y.current=d.current.style.flexGrow,d.current.style.flexGrow="0",p.current.style.flexGrow="1"):(d.current.style.flexGrow=y.current,p.current.style.flexGrow=""+(1-parseFloat(y.current)),y.current=void 0));if("Home"===n.key){g.current=pO(d.current),f.current=h.current.getBoundingClientRect()[b];const e=g.current[w]/(f.current-t);return d.current.style.flexGrow=`${e}`,p.current.style.flexGrow=""+(1-e),void(u.current.ariaValueNow="0")}if("End"===n.key){g.current=pO(d.current),f.current=h.current.getBoundingClientRect()[b];const e=g.current[S]/(f.current-t);return d.current.style.flexGrow=`${e}`,p.current.style.flexGrow=""+(1-e),void(u.current.ariaValueNow="100")}if(!("column"===e&&sO.has(n.key)||"row"===e&&lO.has(n.key))||T.current.has(n.key))return;y.current=void 0,n.preventDefault(),n.stopPropagation(),m.current=d.current.getBoundingClientRect()[b],f.current=h.current.getBoundingClientRect()[b],g.current=pO(d.current);if(!T.current.has(n.key)){const e=0===T.current.size;T.current.add(n.key),e&&window.requestAnimationFrame(k)}}),[e,k,t,S,b,w]),R=(0,Fi.useCallback)((t=>{"row"===e&&!lO.has(t.key)||"column"===e&&!sO.has(t.key)||(T.current.delete(t.key),null==s||s(parseFloat(d.current.style.flexGrow)))}),[e,s]),A=(0,Fi.useCallback)((()=>{d.current.style.flexGrow="0.5",p.current.style.flexGrow="0.5";const e=pO(d.current);g.current=e,m.current=d.current.getBoundingClientRect()[b],u.current.ariaValueNow=""+(m.current-e[w])/(e[S]-e[w])*100}),[S,b,w]),D=(0,Fi.useCallback)((()=>{T.current.size>0&&(T.current.clear(),E.current=null,null==s||s(parseFloat(d.current.style.flexGrow)))}),[s]),j=(0,o.useStyles2)(dO),I=wE(),N=2===c.length?"visible":"hidden";return $i().createElement("div",{ref:h,className:j.container,style:{flexDirection:e}},$i().createElement("div",{ref:d,className:j.panel,style:aO({flexGrow:"auto"===n?.5:(0,$c.clamp)(n,0,1),[w]:"min-content"},r),id:`start-panel-${I}`},c[0]),c[1]&&$i().createElement($i().Fragment,null,$i().createElement("div",{ref:u,style:{[b]:`${t}px`},className:(0,i.cx)(j.handle,{[j.handleHorizontal]:"column"===e}),onPointerUp:_,onPointerDown:x,onPointerMove:O,onKeyDown:P,onKeyUp:R,onDoubleClick:A,onBlur:D,role:"separator","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":50,"aria-controls":`start-panel-${I}`,"aria-label":"Pane resize widget",tabIndex:0}),$i().createElement("div",{ref:p,className:j.panel,style:aO({flexGrow:"auto"===n?.5:(0,$c.clamp)(1-n,0,1),[w]:"min-content",visibility:`${N}`},a),id:`end-panel-${I}`},c[1])))}function dO(e){return{handle:(0,i.css)({cursor:"col-resize",position:"relative",flexShrink:0,userSelect:"none","&::before":{content:'""',position:"absolute",backgroundColor:e.colors.primary.main,left:"50%",transform:"translate(-50%)",top:0,height:"100%",width:"1px",opacity:0,transition:"opacity ease-in-out 0.2s"},"&::after":{content:'""',width:"4px",borderRadius:"4px",backgroundColor:e.colors.border.weak,transition:"background-color ease-in-out 0.2s",height:"50%",top:"calc(50% - (50%) / 2)",transform:"translateX(-50%)",position:"absolute",left:"50%"},"&:hover, &:focus-visible":{outline:"none","&::before":{opacity:1},"&::after":{backgroundColor:e.colors.primary.main}}}),handleHorizontal:(0,i.css)({cursor:"row-resize","&::before":{left:"inherit",transform:"translateY(-50%)",top:"50%",height:"1px",width:"100%"},"&::after":{width:"50%",height:"4px",top:"50%",transform:"translateY(-50%)",left:"calc(50% - (50%) / 2)"}}),container:(0,i.css)({display:"flex",width:"100%",flexGrow:1,overflow:"hidden"}),panel:(0,i.css)({display:"flex",position:"relative",flexBasis:0})}}function pO(e){if(null===e)return;const t=document.body.style.overflow,n=e.style.width,r=e.style.height,i=e.style.flexGrow;document.body.style.overflow="hidden",e.style.flexGrow="0";const{width:a,height:o}=e.getBoundingClientRect();e.style.flexGrow="100";const{width:s,height:l}=e.getBoundingClientRect();return document.body.style.overflow=t,e.style.width=n,e.style.height=r,e.style.flexGrow=i,{minWidth:a,maxWidth:s,minHeight:o,maxHeight:l}}class hO extends bh{toggleDirection(){this.setState({direction:"row"===this.state.direction?"column":"row"})}isDraggable(){return!1}}hO.Component=function({model:e}){const{primary:t,secondary:n,direction:r,isHidden:i,initialSize:a,primaryPaneStyles:o,secondaryPaneStyles:s}=e.useState();if(i)return null;const l=t.Component,c=null==n?void 0:n.Component;let u=n?a:1;return $i().createElement(uO,{direction:r,initialSize:null!=u?u:.5,primaryPaneStyles:o,secondaryPaneStyles:s},$i().createElement(l,{key:t.state.key,model:t,parentState:e.state}),c&&n&&$i().createElement(c,{key:n.state.key,model:n,parentState:e.state}))};var fO=__webpack_require__(8398);new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);try{window.__reactRouterVersion="6"}catch(Jt){}new Map;Fi.startTransition,fO.flushSync,Fi.useId;"undefined"!=typeof window&&void 0!==window.document&&window.document.createElement;var mO,gO;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(mO||(mO={})),function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(gO||(gO={}));(class extends bh{enrichDataRequest(){return{app:this.state.name||"app"}}}).Component=({model:t})=>{const{pages:n}=t.useState();return $i().createElement(e.Switch,null,n.map((e=>$i().createElement(Es.Route,{key:e.state.url,exact:!1,path:e.state.url,render:t=>Np(e,t)}))))};var yO=Object.defineProperty,bO=Object.getOwnPropertySymbols,vO=Object.prototype.hasOwnProperty,wO=Object.prototype.propertyIsEnumerable,SO=(e,t,n)=>t in e?yO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class EO extends bh{}function xO({node:e}){const t=e.useState(),n=(0,o.useStyles2)(OO);return $i().createElement("div",{className:n.container},Object.keys(t).map((r=>$i().createElement("div",{className:n.row,key:r},$i().createElement("div",{className:n.keyName},r),$i().createElement("div",{className:n.value},function(e,t,n){if(null===t)return"null";switch(typeof t){case"number":return $i().createElement(o.Input,{type:"number",defaultValue:t,onBlur:t=>n.setState({[e]:t.currentTarget.valueAsNumber})});case"string":return $i().createElement(o.Input,{type:"text",defaultValue:t,onBlur:t=>n.setState({[e]:t.currentTarget.value})});case"object":return jf(t)?t.constructor.name:(0,$c.isPlainObject)(t)||(0,$c.isArray)(t)?$i().createElement(o.JSONFormatter,{json:t,open:0}):String(t);default:return typeof t}}(r,t[r],e))))))}function OO(e){return{container:(0,i.css)({flexGrow:1,display:"flex",gap:e.spacing(.5),flexDirection:"column"}),row:(0,i.css)({display:"flex",gap:e.spacing(2)}),keyName:(0,i.css)({display:"flex",flexGrow:"0",width:120,alignItems:"center",height:e.spacing(e.components.height.md)}),value:(0,i.css)({flexGrow:1,minHeight:e.spacing(e.components.height.md),display:"flex",alignItems:"center"})}}function _O({node:e,selectedObject:t,onSelect:n}){const r=(0,o.useStyles2)(TO),a=[],s=e===t;return e.forEachChild((e=>{a.push($i().createElement(_O,{node:e,key:e.state.key,selectedObject:t,onSelect:n}))})),$i().createElement("div",{className:r.container},$i().createElement("div",{className:(0,i.cx)(r.name,s&&r.selected),onClick:()=>n(e)},e.constructor.name),$i().createElement("div",{className:r.children},a))}function TO(e){return{container:(0,i.css)({flexGrow:1,display:"flex",gap:e.spacing(.5),flexDirection:"column"}),name:(0,i.css)({flexGrow:1,display:"flex",gap:e.spacing(1),fontSize:e.typography.bodySmall.fontSize,cursor:"pointer",padding:e.spacing(0,1),borderRadius:e.shape.borderRadius(2),position:"relative","&:hover":{background:e.colors.background.secondary}}),selected:(0,i.css)({"&::before":{display:"block",content:"' '",position:"absolute",left:0,width:4,bottom:2,top:2,borderRadius:e.shape.radius.default,backgroundImage:e.colors.gradients.brandVertical}}),children:(0,i.css)({flexGrow:1,display:"flex",flexDirection:"column",paddingLeft:e.spacing(1)})}}function CO({scene:e}){const t=(0,o.useStyles2)(kO),[n,r]=(0,Fi.useState)(!1),[i,a]=(0,Fi.useState)();return $i().createElement($i().Fragment,null,$i().createElement(o.ToolbarButton,{variant:"canvas",icon:"bug",onClick:()=>r(!0)}),n&&$i().createElement(o.Drawer,{title:"Scene debugger",onClose:()=>r(!1),size:"lg"},$i().createElement("div",{className:t.panes},$i().createElement("div",{className:t.pane1},$i().createElement("div",{className:t.paneHeading},"Scene graph"),$i().createElement(o.CustomScrollbar,{autoHeightMin:"100%"},$i().createElement("div",{className:t.treeWrapper},$i().createElement(_O,{node:e,selectedObject:i,onSelect:a})))),$i().createElement("div",{className:t.pane2},$i().createElement("div",{className:t.paneHeading},"Object details"),i&&$i().createElement(xO,{node:i})))))}function kO(e){return{panes:(0,i.css)({flexGrow:1,display:"flex",height:"100%",flexDirection:"row",marginTop:e.spacing(-2)}),pane1:(0,i.css)({flexGrow:0,display:"flex",height:"100%",flexDirection:"column",borderRight:`1px solid ${e.colors.border.weak}`}),pane2:(0,i.css)({flexGrow:1,display:"flex",minHeight:"100%",flexDirection:"column",paddingLeft:e.spacing(2)}),treeWrapper:(0,i.css)({paddingRight:e.spacing(2),height:"100%",marginLeft:e.spacing(-1)}),paneHeading:(0,i.css)({padding:e.spacing(1,0),fontWeight:e.typography.fontWeightMedium})}}function PO({page:e,routeProps:t}){const n=function(e){if(e.parent instanceof DO)return e.parent;return e}(e),r=n.useState(),i=function(){const e=(0,Es.useLocation)();return(0,a.locationSearchToObject)(e.search||"")}(),o=e.getScene(t.match),s=r.initializedScene===o;if((0,Fi.useLayoutEffect)((()=>{s||n.initializeScene(o)}),[o,n,s]),(0,Fi.useEffect)((()=>()=>n.setState({initializedScene:void 0})),[n]),!s)return null;const l={text:r.title,img:r.titleImg,icon:r.titleIcon,url:Ip(r.url,r.preserveUrlKeys),hideFromBreadcrumbs:r.hideFromBreadcrumbs,parentItem:RO(r.getParentPage?r.getParentPage():n.parent)};r.tabs&&(l.children=r.tabs.map((t=>({text:t.state.title,icon:t.state.titleIcon,tabSuffix:t.state.tabSuffix,active:e===t,url:Ip(t.state.url,t.state.preserveUrlKeys),parentItem:l}))));let c=[];return r.controls&&(c=r.controls.map((e=>$i().createElement(e.Component,{model:e,key:e.state.key})))),i["scene-debugger"]&&c.push($i().createElement(CO,{scene:n,key:"scene-debugger"})),$i().createElement(a.PluginPage,{pageNav:l,actions:c,renderTitle:r.renderTitle,subTitle:r.subTitle},$i().createElement(o.Component,{model:o}))}function RO(e,t){if(e instanceof DO)return{text:e.state.title,url:Ip(e.state.url,e.state.preserveUrlKeys),hideFromBreadcrumbs:e.state.hideFromBreadcrumbs,parentItem:RO(e.state.getParentPage?e.state.getParentPage():e.parent)}}function AO({drilldown:e,parent:t,routeProps:n}){return Np(t.getDrilldownPage(e,n.match),n)}EO.Component=({model:e})=>{const{component:t,props:n,reactNode:r}=e.useState();return t?$i().createElement(t,((e,t)=>{for(var n in t||(t={}))vO.call(t,n)&&SO(e,n,t[n]);if(bO)for(var n of bO(t))wO.call(t,n)&&SO(e,n,t[n]);return e})({},n)):r||null};class DO extends bh{constructor(e){super(e),this._sceneCache=new Map,this._drilldownCache=new Map,this.addActivationHandler((()=>()=>WS().cleanUp(this)))}initializeScene(e){this.setState({initializedScene:e}),WS().initSync(this)}getScene(e){let t=this._sceneCache.get(e.url);if(t)return t;if(!this.state.getScene)throw new Error("Missing getScene on SceneAppPage "+this.state.title);return t=this.state.getScene(e),this._sceneCache.set(e.url,t),t}getDrilldownPage(e,t){let n=this._drilldownCache.get(t.url);return n||(n=e.getPage(t,this),this._drilldownCache.set(t.url,n),n)}enrichDataRequest(e){if(this.state.getParentPage)return this.state.getParentPage().enrichDataRequest(e);if(!this.parent)return null;const t=this.getRoot();return If(t)?t.enrichDataRequest(e):null}}DO.Component=function({model:t,routeProps:n}){var r,i;const{tabs:a,drilldowns:o}=t.useState(),s=[];if(a&&a.length>0)for(let e=0;eNp(n,e)})),s.push($i().createElement(Es.Route,{exact:!0,key:n.state.url,path:null!=(i=n.state.routePath)?i:n.state.url,render:e=>Np(n,e)})),n.state.drilldowns)for(const e of n.state.drilldowns)s.push($i().createElement(Es.Route,{exact:!1,key:e.routePath,path:e.routePath,render:t=>$i().createElement(AO,{drilldown:e,parent:n,routeProps:t})}))}if(o)for(const e of o)s.push($i().createElement(Es.Route,{key:e.routePath,exact:!1,path:e.routePath,render:n=>$i().createElement(AO,{drilldown:e,parent:t,routeProps:n})}));if(!a&&function(e,t){if(!t.isExact)return!1;if(t.url===e.state.url)return!0;if(e.parent instanceof DO&&e.parent.state.tabs[0]===e&&e.parent.state.url===t.url)return!0;return!1}(t,n.match))return $i().createElement(PO,{page:t,routeProps:n});return s.push(function(e,t){return $i().createElement(Es.Route,{key:"fallback route",render:n=>{var r,i,a;const o=null!=(a=null==(i=(r=e.state).getFallbackPage)?void 0:i.call(r))?a:new DO({url:"",title:"Not found",subTitle:"The url did not match any page",getScene:()=>new QS({body:new qx({direction:"column",children:[new Hx({body:new EO({component:()=>$i().createElement("div",{"data-testid":"default-fallback-content"},"If you found your way here using a link then there might be a bug in this application.")})})]})})});return $i().createElement(PO,{page:o,routeProps:t})}})}(t,n)),$i().createElement(e.Switch,null,s)};var jO=(e=>(e.Always="always",e.Auto="auto",e.Never="never",e))(jO||{}),IO=(e=>(e.Hue="hue",e.None="none",e.Opacity="opacity",e.Scheme="scheme",e))(IO||{}),NO=(e=>(e.None="none",e.Normal="normal",e.Percent="percent",e))(NO||{}),LO=(e=>(e.Auto="auto",e.Horizontal="horizontal",e.Vertical="vertical",e))(LO||{}),MO=(e=>(e.Background="background",e.BackgroundSolid="background_solid",e.None="none",e.Value="value",e))(MO||{}),FO=(e=>(e.Area="area",e.Line="line",e.None="none",e))(FO||{}),$O=(e=>(e.Auto="auto",e.Center="center",e))($O||{}),BO=(e=>(e.Auto="auto",e.Name="name",e.None="none",e.Value="value",e.ValueAndName="value_and_name",e))(BO||{}),VO=(e=>(e.Inverted="inverted",e.SameAsValue="same_as_value",e.Standard="standard",e))(VO||{}),zO=(e=>(e.Multi="multi",e.None="none",e.Single="single",e))(zO||{}),UO=(e=>(e.Basic="basic",e.Gradient="gradient",e.Lcd="lcd",e))(UO||{}),qO=(e=>(e.Color="color",e.Hidden="hidden",e.Text="text",e))(qO||{}),HO=(e=>(e.Auto="auto",e.Hidden="hidden",e.Left="left",e.Top="top",e))(HO||{}),GO=(e=>(e.Auto="auto",e.Manual="manual",e))(GO||{}),WO=(e=>(e.Auto="auto",e.Lg="lg",e.Md="md",e.Sm="sm",e))(WO||{});const QO={barRadius:0,barWidth:.97,fullHighlight:!1,groupWidth:.7,orientation:LO.Auto,showValue:jO.Auto,stacking:NO.None,xTickLabelRotation:0,xTickLabelSpacing:0},KO={fillOpacity:80,gradientMode:IO.None,lineWidth:1},YO={displayMode:UO.Gradient,maxVizHeight:300,minVizHeight:16,minVizWidth:8,namePlacement:HO.Auto,showUnfilled:!0,sizing:GO.Auto,valueMode:qO.Color},XO={selectedSeries:0},JO={minVizHeight:75,minVizWidth:75,showThresholdLabels:!1,showThresholdMarkers:!0,sizing:GO.Auto},ZO={layers:[]};const e_={calculate:!1,cellGap:1,cellValues:{},color:{scheme:"Oranges",fill:"dark-orange",reverse:!1,exponent:.5,steps:64},exemplars:{color:"rgba(255,0,255,0.7)"},filterValues:{le:1e-9},legend:{show:!0},selectionMode:"x",showValue:jO.Auto,tooltip:{mode:zO.Single,yHistogram:!1,showColorScale:!1}},t_={bucketCount:30,bucketOffset:0},n_={fillOpacity:80,gradientMode:IO.None,lineWidth:1},r_={showImage:!0};const i_={displayLabels:[]},a_={colorMode:MO.Value,graphMode:FO.Area,justifyMode:$O.Auto,percentChangeColorMode:VO.Standard,showPercentChange:!1,textMode:BO.Auto,wideLayout:!0},o_={alignValue:"left",mergeValues:!0,perPage:20,rowHeight:.9,showValue:jO.Auto},s_={fillOpacity:70,lineWidth:0},l_={colWidth:.9,rowHeight:.9,showValue:jO.Auto},c_={fillOpacity:70,lineWidth:1},u_={cellHeight:WO.Sm,footer:{show:!1,countRows:!1,reducer:[]},frameIndex:0,showHeader:!0,showTypeIcons:!1,sortBy:[]};const d_={content:"# Title\n\nFor markdown syntax help: [commonmark.org/help](https://commonmark.org/help/)",mode:"markdown"};const p_={fillOpacity:50,show:"points"},h_={series:[]};class f_{constructor(){this._overrides=[]}overrideColor(e){return this._overrides[this._overrides.length-1].properties.push({id:"color",value:e}),this}overrideDecimals(e){return this._overrides[this._overrides.length-1].properties.push({id:"decimals",value:e}),this}overrideDisplayName(e){return this._overrides[this._overrides.length-1].properties.push({id:"displayName",value:e}),this}overrideFilterable(e){return this._overrides[this._overrides.length-1].properties.push({id:"filterable",value:e}),this}overrideLinks(e){return this._overrides[this._overrides.length-1].properties.push({id:"links",value:e}),this}overrideMappings(e){return this._overrides[this._overrides.length-1].properties.push({id:"mappings",value:e}),this}overrideMax(e){return this._overrides[this._overrides.length-1].properties.push({id:"max",value:e}),this}overrideMin(e){return this._overrides[this._overrides.length-1].properties.push({id:"min",value:e}),this}overrideNoValue(e){return this._overrides[this._overrides.length-1].properties.push({id:"noValue",value:e}),this}overrideThresholds(e){return this._overrides[this._overrides.length-1].properties.push({id:"thresholds",value:e}),this}overrideUnit(e){return this._overrides[this._overrides.length-1].properties.push({id:"unit",value:e}),this}}class m_ extends f_{match(e){return this._overrides.push({matcher:e,properties:[]}),this}matchFieldsWithName(e){return this._overrides.push({matcher:{id:r.FieldMatcherID.byName,options:e},properties:[]}),this}matchFieldsWithNameByRegex(e){return this._overrides.push({matcher:{id:r.FieldMatcherID.byRegexp,options:e},properties:[]}),this}matchFieldsByType(e){return this._overrides.push({matcher:{id:r.FieldMatcherID.byType,options:e},properties:[]}),this}matchFieldsByQuery(e){return this._overrides.push({matcher:{id:r.FieldMatcherID.byFrameRefID,options:e},properties:[]}),this}matchFieldsByValue(e){return this._overrides.push({matcher:{id:r.FieldMatcherID.byValue,options:e},properties:[]}),this}matchComparisonQuery(e){return this.matchFieldsByQuery(Tx(e))}overrideCustomFieldConfig(e,t){const n=`custom.${String(e)}`;return this._overrides[this._overrides.length-1].properties.push({id:n,value:t}),this}build(){return this._overrides}}var g_=Object.defineProperty,y_=Object.defineProperties,b_=Object.getOwnPropertyDescriptors,v_=Object.getOwnPropertySymbols,w_=Object.prototype.hasOwnProperty,S_=Object.prototype.propertyIsEnumerable,E_=(e,t,n)=>t in e?g_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x_=(e,t)=>{for(var n in t||(t={}))w_.call(t,n)&&E_(e,n,t[n]);if(v_)for(var n of v_(t))S_.call(t,n)&&E_(e,n,t[n]);return e},O_=(e,t)=>y_(e,b_(t));class __{constructor(e){this.defaultFieldConfig=e,this._fieldConfig={defaults:{},overrides:[]},this._overridesBuilder=new m_,this.setDefaults()}setDefaults(){const e={defaults:{custom:this.defaultFieldConfig?(0,$c.cloneDeep)(this.defaultFieldConfig()):{}},overrides:[]};this._fieldConfig=e}setColor(e){return this.setFieldConfigDefaults("color",e)}setDecimals(e){return this.setFieldConfigDefaults("decimals",e)}setDisplayName(e){return this.setFieldConfigDefaults("displayName",e)}setFilterable(e){return this.setFieldConfigDefaults("filterable",e)}setLinks(e){return this.setFieldConfigDefaults("links",e)}setMappings(e){return this.setFieldConfigDefaults("mappings",e)}setMax(e){return this.setFieldConfigDefaults("max",e)}setMin(e){return this.setFieldConfigDefaults("min",e)}setNoValue(e){return this.setFieldConfigDefaults("noValue",e)}setThresholds(e){return this.setFieldConfigDefaults("thresholds",e)}setUnit(e){return this.setFieldConfigDefaults("unit",e)}setCustomFieldConfig(e,t){return this._fieldConfig.defaults=O_(x_({},this._fieldConfig.defaults),{custom:(0,$c.merge)(this._fieldConfig.defaults.custom,{[e]:t})}),this}setOverrides(e){return e(this._overridesBuilder),this}setFieldConfigDefaults(e,t){return this._fieldConfig.defaults=O_(x_({},this._fieldConfig.defaults),{[e]:t}),this}build(){return{defaults:this._fieldConfig.defaults,overrides:this._overridesBuilder.build()}}}class T_{constructor(e){this.defaultOptions=e,this._options={},this.setDefaults()}setDefaults(){this._options=this.defaultOptions?(0,$c.cloneDeep)(this.defaultOptions()):{}}setOption(e,t){return this._options=(0,$c.merge)(this._options,{[e]:t}),this}build(){return this._options}}var C_=Object.defineProperty,k_=Object.defineProperties,P_=Object.getOwnPropertyDescriptors,R_=Object.getOwnPropertySymbols,A_=Object.prototype.hasOwnProperty,D_=Object.prototype.propertyIsEnumerable,j_=(e,t,n)=>t in e?C_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class I_{constructor(e,t,n,r){this._state={},this._state.title="",this._state.description="",this._state.displayMode="default",this._state.hoverHeader=!1,this._state.pluginId=e,this._state.pluginVersion=t,this._fieldConfigBuilder=new __(r),this._panelOptionsBuilder=new T_(n)}setTitle(e){return this._state.title=e,this}setDescription(e){return this._state.description=e,this}setDisplayMode(e){return this._state.displayMode=e,this}setHoverHeader(e){return this._state.hoverHeader=e,this}setMenu(e){return this._state.menu=e,this}setHeaderActions(e){return this._state.headerActions=e,this}setColor(e){return this._fieldConfigBuilder.setColor(e),this}setDecimals(e){return this._fieldConfigBuilder.setDecimals(e),this}setDisplayName(e){return this._fieldConfigBuilder.setDisplayName(e),this}setFilterable(e){return this._fieldConfigBuilder.setFilterable(e),this}setLinks(e){return this._fieldConfigBuilder.setLinks(e),this}setMappings(e){return this._fieldConfigBuilder.setMappings(e),this}setMax(e){return this._fieldConfigBuilder.setMax(e),this}setMin(e){return this._fieldConfigBuilder.setMin(e),this}setNoValue(e){return this._fieldConfigBuilder.setNoValue(e),this}setThresholds(e){return this._fieldConfigBuilder.setThresholds(e),this}setUnit(e){return this._fieldConfigBuilder.setUnit(e),this}setCustomFieldConfig(e,t){return this._fieldConfigBuilder.setCustomFieldConfig(e,t),this}setOverrides(e){return this._fieldConfigBuilder.setOverrides(e),this}setOption(e,t){return this._panelOptionsBuilder.setOption(e,t),this}setData(e){return this._state.$data=e,this}setTimeRange(e){return this._state.$timeRange=e,this}setVariables(e){return this._state.$variables=e,this}setBehaviors(e){return this._state.$behaviors=e,this}build(){const e=new _b(((e,t)=>k_(e,P_(t)))(((e,t)=>{for(var n in t||(t={}))A_.call(t,n)&&j_(e,n,t[n]);if(R_)for(var n of R_(t))D_.call(t,n)&&j_(e,n,t[n]);return e})({},this._state),{options:this._panelOptionsBuilder.build(),fieldConfig:this._fieldConfigBuilder.build()}));return e}}const N_={barchart:()=>new I_("barchart","10.0.0",(()=>QO),(()=>KO)),bargauge:()=>new I_("bargauge","10.0.0",(()=>YO)),datagrid:()=>new I_("datagrid","10.0.0",(()=>XO)),flamegraph:()=>new I_("flamegraph","10.0.0"),gauge:()=>new I_("gauge","10.0.0",(()=>JO)),geomap:()=>new I_("geomap","10.0.0",(()=>ZO)),heatmap:()=>new I_("heatmap","10.0.0",(()=>e_)),histogram:()=>new I_("histogram","10.0.0",(()=>t_),(()=>n_)),logs:()=>new I_("logs","10.0.0"),news:()=>new I_("news","10.0.0",(()=>r_)),nodegraph:()=>new I_("nodeGraph","10.0.0"),piechart:()=>new I_("piechart","10.0.0",(()=>i_)),stat:()=>new I_("stat","10.0.0",(()=>a_)),statetimeline:()=>new I_("state-timeline","10.0.0",(()=>o_),(()=>s_)),statushistory:()=>new I_("status-history","10.0.0",(()=>l_),(()=>c_)),table:()=>new I_("table","10.0.0",(()=>u_)),text:()=>new I_("text","10.0.0",(()=>d_)),timeseries:()=>new I_("timeseries","10.0.0"),trend:()=>new I_("trend","10.0.0"),traces:()=>new I_("traces","10.0.0"),xychart:()=>new I_("xychart","10.0.0",(()=>h_),(()=>p_))};const L_={getUrlWithAppState:Ip,registerRuntimePanelPlugin:function({pluginId:e,plugin:t}){if(Up.has(e))throw new Error(`A runtime panel plugin with id ${e} has already been registered`);t.meta=((e,t)=>Mp(e,Fp(t)))(((e,t)=>{for(var n in t||(t={}))Bp.call(t,n)&&zp(e,n,t[n]);if($p)for(var n of $p(t))Vp.call(t,n)&&zp(e,n,t[n]);return e})({},t.meta),{id:e,name:e,module:"runtime plugin",baseUrl:"runtime plugin",info:{author:{name:"Runtime plugin "+e},description:"",links:[],logos:{large:"",small:""},screenshots:[],updated:"",version:""}}),Up.set(e,t)},registerRuntimeDataSource:function({dataSource:e}){if(Rh.has(e.uid))throw new Error(`A runtime data source with uid ${e.uid} has already been registered`);Rh.set(e.uid,e)},registerVariableMacro:function(e,t){if(em.get(e))throw new Error(`Macro already registered ${e}`);return em.set(e,t),()=>{em.delete(e)}},cloneSceneObjectState:Ch,syncStateFromSearchParams:function(e,t){const n=new Ah;n.rebuildIndex(e),jh(e,t,n)},getUrlState:Dh,renderPrometheusLabelFilters:fy,isAdHocVariable:function(e){return"adhoc"===e.state.type},isConstantVariable:function(e){return"constant"===e.state.type},isCustomVariable:function(e){return"custom"===e.state.type},isDataSourceVariable:function(e){return"datasource"===e.state.type},isIntervalVariable:function(e){return"interval"===e.state.type},isQueryVariable:function(e){return"query"===e.state.type},isTextBoxVariable:function(e){return"textbox"===e.state.type},isGroupByVariable:function(e){return"groupby"===e.state.type}};function M_(){history.pushState(null,"")}class F_ extends r.BusEventWithPayload{}var $_,B_,V_;V_="timeseries-data-received",(B_="type")in($_=F_)?Object.defineProperty($_,B_,{value:V_,enumerable:!0,configurable:!0,writable:!0}):$_[B_]=V_;var z_=function(e){return e.partial="partial",e["attribute-operator-value"]="attribute-operator-value",e["attribute-operator"]="attribute-operator",e}({}),U_=function(e){return e["="]="=",e["!="]="!=",e.in="in",e["not-in"]="not-in",e["is-empty"]="is-empty",e["=~"]="=~",e["!~"]="!~",e}({}),q_=function(e){return e.attribute="attribute",e.operator="operator",e.value="value",e}({}),H_=function(e){return e.attribute="attribute",e.operator="operator",e.value="value",e}({});var G_,W_,Q_=function(){return Q_=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function X_(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)o.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return o}function J_(e,t,n){if(n||2===arguments.length)for(var r,i=0,a=t.length;i0}));if(!h)return this.next(t,n);var f=CT(Object.keys(a).map((function(e){return a[e].configuration})));return{transitions:p,exitSet:CT(d.map((function(e){return e.exitSet}))),configuration:f,source:t,actions:CT(Object.keys(a).map((function(e){return a[e].actions})))}},e.prototype._transition=function(e,t,n){return MT(e)?this.transitionLeafNode(e,t,n):1===Object.keys(e).length?this.transitionCompoundNode(e,t,n):this.transitionParallelNode(e,t,n)},e.prototype.getTransitionData=function(e,t){return this._transition(e.value,e,zT(t))},e.prototype.next=function(e,t){var n,r,i,a=this,o=t.name,s=[],l=[];try{for(var c=Y_(this.getCandidates(o)),u=c.next();!u.done;u=c.next()){var d=u.value,p=d.cond,h=d.in,f=e.context,m=!h||(MT(h)&&kC(h)?e.matches(ST(this.getStateNodeById(h).path,this.delimiter)):bT(ST(h,this.delimiter),_T(this.path.slice(0,-2))(e.value))),g=!1;try{g=!p||qT(this.machine,p,f,t,e)}catch(e){throw new Error("Unable to evaluate guard '".concat(p.name||p.type,"' in transition for event '").concat(o,"' in state node '").concat(this.id,"':\n").concat(e.message))}if(g&&m){void 0!==d.target&&(l=d.target),s.push.apply(s,J_([],X_(d.actions),!1)),i=d;break}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}if(i){if(!l.length)return{transitions:[i],exitSet:[],configuration:e.value?[this]:[],source:e,actions:s};var y=CT(l.map((function(t){return a.getRelativeStateNodes(t,e.historyValue)})));return{transitions:[i],exitSet:!!i.internal?[]:CT(l.map((function(e){return a.getPotentiallyReenteringNodes(e)}))),configuration:y,source:e,actions:s}}},e.prototype.getPotentiallyReenteringNodes=function(e){if(this.order0,p=d?e.configuration:t?t.configuration:[],h=iC(p,this),f=d?nC(this.machine,u):void 0,m=t?t.historyValue?t.historyValue:e.source?this.machine.historyValue(t.value):void 0:void 0,g=this.getActions(new Set(p),h,e,n,i,t,r),y=t?Q_({},t.activities):{};try{for(var b=Y_(g),v=b.next();!v.done;v=b.next()){var w=v.value;try{for(var S=(s=void 0,Y_(w.actions)),E=S.next();!E.done;E=S.next()){var x=E.value;x.type===eT?y[x.activity.id||x.activity.type]=x:x.type===tT&&(y[x.activity.id||x.activity.type]=!1)}}catch(e){s={error:e}}finally{try{E&&!E.done&&(l=S.return)&&l.call(S)}finally{if(s)throw s.error}}}}catch(e){a={error:e}}finally{try{v&&!v.done&&(o=b.return)&&o.call(b)}finally{if(a)throw a.error}}var O,_,T=X_(mC(this,t,n,i,g,r,this.machine.config.predictableActionArguments||this.machine.config.preserveActionOrder),2),C=T[0],k=T[1],P=X_(function(e,t){var n,r,i=X_([[],[]],2),a=i[0],o=i[1];try{for(var s=Y_(e),l=s.next();!l.done;l=s.next()){var c=l.value;t(c)?a.push(c):o.push(c)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return[a,o]}(C,QT),2),R=P[0],A=P[1],D=C.filter((function(e){var t;return e.type===eT&&(null===(t=e.activity)||void 0===t?void 0:t.type)===cT})),j=D.reduce((function(e,t){return e[t.activity.id]=function(e,t,n,r){var i,a=HT(e.src),o=null===(i=null==t?void 0:t.options.services)||void 0===i?void 0:i[a.type],s=e.data?RT(e.data,n,r):void 0,l=o?EC(o,e.id,s):SC(e.id);return l.meta=e,l}(t.activity,c.machine,k,i),e}),t?Q_({},t.children):{}),I=new bC({value:f||t.value,context:k,_event:i,_sessionid:t?t._sessionid:null,historyValue:f?m?(O=m,_=f,{current:_,states:DT(O,_)}):void 0:t?t.historyValue:void 0,history:!f||e.source?t:void 0,actions:f?A:[],activities:f?y:t?t.activities:{},events:[],configuration:p,transitions:e.transitions,children:j,done:h,tags:aC(p),machine:this}),N=n!==k;I.changed=i.name===pT||N;var L=I.history;L&&delete L.history;var M=!h&&(this._transient||u.some((function(e){return e._transient})));if(!(d||M&&i.name!==_C))return I;var F=I;if(!h)for(M&&(F=this.resolveRaisedTransition(F,{type:aT},i,r));R.length;){var $=R.shift();F=this.resolveRaisedTransition(F,$._event,i,r)}var B=F.changed||(L?!!F.actions.length||N||typeof L.value!=typeof F.value||!gC(F.value,L.value):void 0);return F.changed=B,F.history=L,F},e.prototype.getStateNode=function(e){if(kC(e))return this.machine.getStateNodeById(e);if(!this.states)throw new Error("Unable to retrieve child state '".concat(e,"' from '").concat(this.id,"'; no child states exist."));var t=this.states[e];if(!t)throw new Error("Child state '".concat(e,"' does not exist on '").concat(this.id,"'"));return t},e.prototype.getStateNodeById=function(e){var t=kC(e)?e.slice(1):e;if(t===this.id)return this;var n=this.machine.idMap[t];if(!n)throw new Error("Child state node '#".concat(t,"' does not exist on machine '").concat(this.id,"'"));return n},e.prototype.getStateNodeByPath=function(e){if("string"==typeof e&&kC(e))try{return this.getStateNodeById(e.slice(1))}catch(e){}for(var t=wT(e,this.delimiter).slice(),n=this;t.length;){var r=t.shift();if(!r.length)break;n=n.getStateNode(r)}return n},e.prototype.resolve=function(e){var t,n=this;if(!e)return this.initialStateValue||CC;switch(this.type){case"parallel":return xT(this.initialStateValue,(function(t,r){return t?n.getStateNode(r).resolve(e[r]||t):CC}));case"compound":if(MT(e)){var r=this.getStateNode(e);return"parallel"===r.type||"compound"===r.type?((t={})[e]=r.initialStateValue,t):e}return Object.keys(e).length?xT(e,(function(e,t){return e?n.getStateNode(t).resolve(e):CC})):this.initialStateValue||{};default:return e||CC}},e.prototype.getResolvedPath=function(e){if(kC(e)){var t=this.machine.idMap[e.slice(1)];if(!t)throw new Error("Unable to find state node '".concat(e,"'"));return t.path}return wT(e,this.delimiter)},Object.defineProperty(e.prototype,"initialStateValue",{get:function(){var e,t;if(this.__cache.initialStateValue)return this.__cache.initialStateValue;if("parallel"===this.type)t=OT(this.states,(function(e){return e.initialStateValue||CC}),(function(e){return!("history"===e.type)}));else if(void 0!==this.initial){if(!this.states[this.initial])throw new Error("Initial state '".concat(this.initial,"' not found on '").concat(this.key,"'"));t=KT(this.states[this.initial])?this.initial:((e={})[this.initial]=this.states[this.initial].initialStateValue,e)}else t={};return this.__cache.initialStateValue=t,this.__cache.initialStateValue},enumerable:!1,configurable:!0}),e.prototype.getInitialState=function(e,t){this._init();var n=this.getStateNodes(e);return this.resolveTransition({configuration:n,exitSet:[],transitions:[],source:void 0,actions:[]},void 0,null!=t?t:this.machine.context,void 0)},Object.defineProperty(e.prototype,"initialState",{get:function(){var e=this.initialStateValue;if(!e)throw new Error("Cannot retrieve initial state from simple state '".concat(this.id,"'."));return this.getInitialState(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){var e;if("history"===this.type){var t=this.config;e=MT(t.target)&&kC(t.target)?ET(this.machine.getStateNodeById(t.target).path.slice(this.path.length-1)):t.target}return e},enumerable:!1,configurable:!0}),e.prototype.getRelativeStateNodes=function(e,t,n){return void 0===n&&(n=!0),n?"history"===e.type?e.resolveHistory(t):e.initialStateNodes:[e]},Object.defineProperty(e.prototype,"initialStateNodes",{get:function(){var e=this;return KT(this)?[this]:"compound"!==this.type||this.initial?CT(TT(this.initialStateValue).map((function(t){return e.getFromRelativePath(t)}))):(yT||IT(!1,"Compound state node '".concat(this.id,"' has no initial state.")),[this])},enumerable:!1,configurable:!0}),e.prototype.getFromRelativePath=function(e){if(!e.length)return[this];var t=X_(e),n=t[0],r=t.slice(1);if(!this.states)throw new Error("Cannot retrieve subPath '".concat(n,"' from node with no states"));var i=this.getStateNode(n);if("history"===i.type)return i.resolveHistory();if(!this.states[n])throw new Error("Child state '".concat(n,"' does not exist on '").concat(this.id,"'"));return this.states[n].getFromRelativePath(r)},e.prototype.historyValue=function(e){if(Object.keys(this.states).length)return{current:e||this.initialStateValue,states:OT(this.states,(function(t,n){if(!e)return t.historyValue();var r=MT(e)?void 0:e[n];return t.historyValue(r||t.initialStateValue)}),(function(e){return!e.history}))}},e.prototype.resolveHistory=function(e){var t=this;if("history"!==this.type)return[this];var n=this.parent;if(!e){var r=this.target;return r?CT(TT(r).map((function(e){return n.getFromRelativePath(e)}))):n.initialStateNodes}var i,a,o=(i=n.path,a="states",function(e){var t,n,r=e;try{for(var o=Y_(i),s=o.next();!s.done;s=o.next()){var l=s.value;r=r[a][l]}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return r})(e).current;return MT(o)?[n.getStateNode(o)]:CT(TT(o).map((function(e){return"deep"===t.history?n.getFromRelativePath(e):[n.states[e[0]]]})))},Object.defineProperty(e.prototype,"stateIds",{get:function(){var e=this,t=CT(Object.keys(this.states).map((function(t){return e.states[t].stateIds})));return[this.id].concat(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"events",{get:function(){var e,t,n,r;if(this.__cache.events)return this.__cache.events;var i=this.states,a=new Set(this.ownEvents);if(i)try{for(var o=Y_(Object.keys(i)),s=o.next();!s.done;s=o.next()){var l=i[s.value];if(l.states)try{for(var c=(n=void 0,Y_(l.events)),u=c.next();!u.done;u=c.next()){var d=u.value;a.add("".concat(d))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return this.__cache.events=Array.from(a)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ownEvents",{get:function(){var e=new Set(this.transitions.filter((function(e){return!(!e.target&&!e.actions.length&&e.internal)})).map((function(e){return e.eventType})));return Array.from(e)},enumerable:!1,configurable:!0}),e.prototype.resolveTarget=function(e){var t=this;if(void 0!==e)return e.map((function(e){if(!MT(e))return e;var n=e[0]===t.delimiter;if(n&&!t.parent)return t.getStateNodeByPath(e.slice(1));var r=n?t.key+e:e;if(!t.parent)return t.getStateNodeByPath(r);try{return t.parent.getStateNodeByPath(r)}catch(e){throw new Error("Invalid transition definition for state node '".concat(t.id,"':\n").concat(e.message))}}))},e.prototype.formatTransition=function(e){var t=this,n=function(e){if(void 0!==e&&""!==e)return PT(e)}(e.target),r="internal"in e?e.internal:!n||n.some((function(e){return MT(e)&&e[0]===t.delimiter})),i=this.machine.options.guards,a=this.resolveTarget(n),o=Q_(Q_({},e),{actions:cC(PT(e.actions)),cond:FT(e.cond,i),target:a,source:this,internal:r,eventType:e.event,toJSON:function(){return Q_(Q_({},o),{target:o.target?o.target.map((function(e){return"#".concat(e.id)})):void 0,source:"#".concat(t.id)})}});return o},e.prototype.formatTransitions=function(){var e,t,n,r=this;if(this.config.on)if(Array.isArray(this.config.on))n=this.config.on;else{var i=this.config.on,a=TC,o=i[a],s=void 0===o?[]:o,l=K_(i,["*"]);n=CT(Object.keys(l).map((function(e){yT||e!==_C||IT(!1,"Empty string transition configs (e.g., `{ on: { '': ... }}`) for transient transitions are deprecated. Specify the transition in the `{ always: ... }` property instead. "+'Please check the `on` configuration for "#'.concat(r.id,'".'));var t=UT(e,l[e]);return yT||function(e,t,n){var r=n.slice(0,-1).some((function(e){return!("cond"in e)&&!("in"in e)&&(MT(e.target)||BT(e.target))})),i=t===_C?"the transient event":"event '".concat(t,"'");IT(!r,"One or more transitions for ".concat(i," on state '").concat(e.id,"' are unreachable. ")+"Make sure that the default transition is the last one defined.")}(r,e,t),t})).concat(UT(TC,s)))}else n=[];var c=this.config.always?UT("",this.config.always):[],u=this.config.onDone?UT(String(pC(this.id)),this.config.onDone):[];yT||IT(!(this.config.onDone&&!this.parent),'Root nodes cannot have an ".onDone" transition. Please check the config of "'.concat(this.id,'".'));var d=CT(this.invoke.map((function(e){var t=[];return e.onDone&&t.push.apply(t,J_([],X_(UT(String(hC(e.id)),e.onDone)),!1)),e.onError&&t.push.apply(t,J_([],X_(UT(String(fC(e.id)),e.onError)),!1)),t}))),p=this.after,h=CT(J_(J_(J_(J_([],X_(u),!1),X_(d),!1),X_(n),!1),X_(c),!1).map((function(e){return PT(e).map((function(e){return r.formatTransition(e)}))})));try{for(var f=Y_(p),m=f.next();!m.done;m=f.next()){var g=m.value;h.push(g)}}catch(t){e={error:t}}finally{try{m&&!m.done&&(t=f.return)&&t.call(f)}finally{if(e)throw e.error}}return h},e}(),RC=!1;var AC={deferEvents:!1},DC=function(){function e(e){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=Q_(Q_({},AC),e)}return e.prototype.initialize=function(e){if(this.initialized=!0,e){if(!this.options.deferEvents)return void this.schedule(e);this.process(e)}this.flushEvents()},e.prototype.schedule=function(e){if(this.initialized&&!this.processingEvent){if(0!==this.queue.length)throw new Error("Event queue should be empty when it is not processing events");this.process(e),this.flushEvents()}else this.queue.push(e)},e.prototype.clear=function(){this.queue=[]},e.prototype.flushEvents=function(){for(var e=this.queue.shift();e;)this.process(e),e=this.queue.shift()},e.prototype.process=function(e){this.processingEvent=!0;try{e()}catch(e){throw this.clear(),e}finally{this.processingEvent=!1}},e}(),jC=new Map,IC=0,NC=function(){return"x:".concat(IC++)},LC=function(e,t){return jC.set(e,t),e},MC=function(e){return jC.get(e)},FC=function(e){jC.delete(e)};function $C(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==__webpack_require__.g?__webpack_require__.g:void(yT||console.warn("XState could not find a global object in this environment. Please let the maintainers know and raise an issue here: https://github.com/statelyai/xstate/issues"))}function BC(e){if($C()){var t=function(){var e=$C();if(e&&"__xstate__"in e)return e.__xstate__}();t&&t.register(e)}}function VC(e,t){void 0===t&&(t={});var n=e.initialState,r=new Set,i=[],a=!1,o=function(e){var t;return Q_(((t={subscribe:function(){return{unsubscribe:function(){}}},id:"anonymous",getSnapshot:function(){}})[$T]=function(){return this},t),e)}({id:t.id,send:function(t){i.push(t),function(){if(!a){for(a=!0;i.length>0;){var t=i.shift();n=e.transition(n,t,s),r.forEach((function(e){return e.next(n)}))}a=!1}}()},getSnapshot:function(){return n},subscribe:function(e,t,i){var a=GT(e,t,i);return r.add(a),a.next(n),{unsubscribe:function(){r.delete(a)}}}}),s={parent:t.parent,self:o,id:t.id||"anonymous",observers:r};return n=e.start?e.start(s):n,o}var zC,UC={sync:!1,autoForward:!1};!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(zC||(zC={}));var qC=function(){function e(t,n){void 0===n&&(n=e.defaultOptions);var r=this;this.machine=t,this.delayedEventsMap={},this.listeners=new Set,this.contextListeners=new Set,this.stopListeners=new Set,this.doneListeners=new Set,this.eventListeners=new Set,this.sendListeners=new Set,this.initialized=!1,this.status=zC.NotStarted,this.children=new Map,this.forwardTo=new Set,this._outgoingQueue=[],this.init=this.start,this.send=function(e,t){if(NT(e))return r.batch(e),r.state;var n=zT(VT(e,t));if(r.status===zC.Stopped)return yT||IT(!1,'Event "'.concat(n.name,'" was sent to stopped service "').concat(r.machine.id,'". This service has already reached its final state, and will not transition.\nEvent: ').concat(JSON.stringify(n.data))),r.state;if(r.status!==zC.Running&&!r.options.deferEvents)throw new Error('Event "'.concat(n.name,'" was sent to uninitialized service "').concat(r.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.\nEvent: ').concat(JSON.stringify(n.data)));return r.scheduler.schedule((function(){r.forward(n);var e=r._nextState(n);r.update(e,n)})),r._state},this.sendTo=function(e,t,n){var i=r.parent&&(t===W_.Parent||r.parent.id===t),a=i?r.parent:MT(t)?t===W_.Internal?r:r.children.get(t)||MC(t):function(e){return!!e&&"function"==typeof e.send}(t)?t:void 0;if(a)if("machine"in a){if(r.status!==zC.Stopped||r.parent!==a||r.state.done){var o=Q_(Q_({},e),{name:e.name===dT?"".concat(fC(r.id)):e.name,origin:r.sessionId});!n&&r.machine.config.predictableActionArguments?r._outgoingQueue.push([a,o]):a.send(o)}}else!n&&r.machine.config.predictableActionArguments?r._outgoingQueue.push([a,e.data]):a.send(e.data);else{if(!i)throw new Error("Unable to send event to child '".concat(t,"' from service '").concat(r.id,"'."));yT||IT(!1,"Service '".concat(r.id,"' has no parent: unable to send event ").concat(e.type))}},this._exec=function(e,t,n,i){void 0===i&&(i=r.machine.options.actions);var a=e.exec||sC(e.type,i),o=LT(a)?a:a?a.exec:e.exec;if(o)try{return o(t,n.data,r.machine.config.predictableActionArguments?{action:e,_event:n}:{action:e,state:r.state,_event:n})}catch(e){throw r.parent&&r.parent.send({type:"xstate.error",data:e}),e}switch(e.type){case nT:var s=e;r.defer(s);break;case rT:var l=e;if("number"==typeof l.delay)return void r.defer(l);l.to?r.sendTo(l._event,l.to,n===oC):r.send(l._event);break;case iT:r.cancel(e.sendId);break;case eT:if(r.status!==zC.Running)return;var c=e.activity;if(!r.machine.config.predictableActionArguments&&!r.state.activities[c.id||c.type])break;if(c.type===G_.Invoke){var u=HT(c.src),d=r.machine.options.services?r.machine.options.services[u.type]:void 0,p=c.id,h=c.data;yT||IT(!("forward"in c),"`forward` property is deprecated (found in invocation of '".concat(c.src,"' in in machine '").concat(r.machine.id,"'). ")+"Please use `autoForward` instead.");var f="autoForward"in c?c.autoForward:!!c.forward;if(!d)return void(yT||IT(!1,"No service found for invocation '".concat(c.src,"' in machine '").concat(r.machine.id,"'.")));var m=h?RT(h,t,n):void 0;if("string"==typeof d)return;var g=LT(d)?d(t,n.data,{data:m,src:u,meta:c.meta}):d;if(!g)return;var y=void 0;BT(g)&&(g=m?g.withContext(m):g,y={autoForward:f}),r.spawn(g,p,y)}else r.spawnActivity(c);break;case tT:r.stopChild(e.activity.id);break;case sT:var b=e,v=b.label,w=b.value;v?r.logger(v,w):r.logger(w);break;default:yT||IT(!1,"No implementation found for action type '".concat(e.type,"'"))}};var i=Q_(Q_({},e.defaultOptions),n),a=i.clock,o=i.logger,s=i.parent,l=i.id,c=void 0!==l?l:t.id;this.id=c,this.logger=o,this.clock=a,this.parent=s,this.options=i,this.scheduler=new DC({deferEvents:this.options.deferEvents}),this.sessionId=NC()}return Object.defineProperty(e.prototype,"initialState",{get:function(){var e=this;return this._initialState?this._initialState:wC(this,(function(){return e._initialState=e.machine.initialState,e._initialState}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return yT||IT(this.status!==zC.NotStarted,"Attempted to read state from uninitialized service '".concat(this.id,"'. Make sure the service is started first.")),this._state},enumerable:!1,configurable:!0}),e.prototype.execute=function(e,t){var n,r;try{for(var i=Y_(e.actions),a=i.next();!a.done;a=i.next()){var o=a.value;this.exec(o,e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype.update=function(e,t){var n,r,i,a,o,s,l,c,u=this;if(e._sessionid=this.sessionId,this._state=e,this.machine.config.predictableActionArguments&&t!==oC||!this.options.execute)for(var d=void 0;d=this._outgoingQueue.shift();)d[0].send(d[1]);else this.execute(this.state);if(this.children.forEach((function(e){u.state.children[e.id]=e})),this.devTools&&this.devTools.send(t.data,e),e.event)try{for(var p=Y_(this.eventListeners),h=p.next();!h.done;h=p.next()){(0,h.value)(e.event)}}catch(e){n={error:e}}finally{try{h&&!h.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}try{for(var f=Y_(this.listeners),m=f.next();!m.done;m=f.next()){(0,m.value)(e,e.event)}}catch(e){i={error:e}}finally{try{m&&!m.done&&(a=f.return)&&a.call(f)}finally{if(i)throw i.error}}try{for(var g=Y_(this.contextListeners),y=g.next();!y.done;y=g.next()){(0,y.value)(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(e){o={error:e}}finally{try{y&&!y.done&&(s=g.return)&&s.call(g)}finally{if(o)throw o.error}}if(this.state.done){var b=e.configuration.find((function(e){return"final"===e.type&&e.parent===u.machine})),v=b&&b.doneData?RT(b.doneData,e.context,t):void 0;this._doneEvent=hC(this.id,v);try{for(var w=Y_(this.doneListeners),S=w.next();!S.done;S=w.next()){(0,S.value)(this._doneEvent)}}catch(e){l={error:e}}finally{try{S&&!S.done&&(c=w.return)&&c.call(w)}finally{if(l)throw l.error}}this._stop(),this._stopChildren(),FC(this.sessionId)}},e.prototype.onTransition=function(e){return this.listeners.add(e),this.status===zC.Running&&e(this.state,this.state.event),this},e.prototype.subscribe=function(e,t,n){var r=this,i=GT(e,t,n);this.listeners.add(i.next),this.status!==zC.NotStarted&&i.next(this.state);var a=function(){r.doneListeners.delete(a),r.stopListeners.delete(a),i.complete()};return this.status===zC.Stopped?i.complete():(this.onDone(a),this.onStop(a)),{unsubscribe:function(){r.listeners.delete(i.next),r.doneListeners.delete(a),r.stopListeners.delete(a)}}},e.prototype.onEvent=function(e){return this.eventListeners.add(e),this},e.prototype.onSend=function(e){return this.sendListeners.add(e),this},e.prototype.onChange=function(e){return this.contextListeners.add(e),this},e.prototype.onStop=function(e){return this.stopListeners.add(e),this},e.prototype.onDone=function(e){return this.status===zC.Stopped&&this._doneEvent?e(this._doneEvent):this.doneListeners.add(e),this},e.prototype.off=function(e){return this.listeners.delete(e),this.eventListeners.delete(e),this.sendListeners.delete(e),this.stopListeners.delete(e),this.doneListeners.delete(e),this.contextListeners.delete(e),this},e.prototype.start=function(e){var t=this;if(this.status===zC.Running)return this;this.machine._init(),LC(this.sessionId,this),this.initialized=!0,this.status=zC.Running;var n=void 0===e?this.initialState:wC(this,(function(){return yC(e)?t.machine.resolveState(e):t.machine.resolveState(bC.from(e,t.machine.context))}));return this.options.devTools&&this.attachDev(),this.scheduler.initialize((function(){t.update(n,oC)})),this},e.prototype._stopChildren=function(){this.children.forEach((function(e){LT(e.stop)&&e.stop()})),this.children.clear()},e.prototype._stop=function(){var e,t,n,r,i,a,o,s,l,c;try{for(var u=Y_(this.listeners),d=u.next();!d.done;d=u.next()){var p=d.value;this.listeners.delete(p)}}catch(t){e={error:t}}finally{try{d&&!d.done&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}try{for(var h=Y_(this.stopListeners),f=h.next();!f.done;f=h.next()){(p=f.value)(),this.stopListeners.delete(p)}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}try{for(var m=Y_(this.contextListeners),g=m.next();!g.done;g=m.next()){p=g.value;this.contextListeners.delete(p)}}catch(e){i={error:e}}finally{try{g&&!g.done&&(a=m.return)&&a.call(m)}finally{if(i)throw i.error}}try{for(var y=Y_(this.doneListeners),b=y.next();!b.done;b=y.next()){p=b.value;this.doneListeners.delete(p)}}catch(e){o={error:e}}finally{try{b&&!b.done&&(s=y.return)&&s.call(y)}finally{if(o)throw o.error}}if(!this.initialized)return this;this.initialized=!1,this.status=zC.Stopped,this._initialState=void 0;try{for(var v=Y_(Object.keys(this.delayedEventsMap)),w=v.next();!w.done;w=v.next()){var S=w.value;this.clock.clearTimeout(this.delayedEventsMap[S])}}catch(e){l={error:e}}finally{try{w&&!w.done&&(c=v.return)&&c.call(v)}finally{if(l)throw l.error}}this.scheduler.clear(),this.scheduler=new DC({deferEvents:this.options.deferEvents})},e.prototype.stop=function(){var e=this,t=this.scheduler;return this._stop(),t.schedule((function(){var t;if(!(null===(t=e._state)||void 0===t?void 0:t.done)){var n=zT({type:"xstate.stop"}),r=wC(e,(function(){var t=CT(J_([],X_(e.state.configuration),!1).sort((function(e,t){return t.order-e.order})).map((function(t){return cC(t.onExit,e.machine.options.actions)}))),r=X_(mC(e.machine,e.state,e.state.context,n,[{type:"exit",actions:t}],e.machine.config.predictableActionArguments?e._exec:void 0,e.machine.config.predictableActionArguments||e.machine.config.preserveActionOrder),2),i=r[0],a=r[1],o=new bC({value:e.state.value,context:a,_event:n,_sessionid:e.sessionId,historyValue:void 0,history:e.state,actions:i.filter((function(e){return!QT(e)})),activities:{},events:[],configuration:[],transitions:[],children:{},done:e.state.done,tags:e.state.tags,machine:e.machine});return o.changed=!0,o}));e.update(r,n),e._stopChildren(),FC(e.sessionId)}})),this},e.prototype.batch=function(e){var t=this;if(this.status===zC.NotStarted&&this.options.deferEvents)yT||IT(!1,"".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,'" and are deferred. Make sure .start() is called for this service.\nEvent: ').concat(JSON.stringify(event)));else if(this.status!==zC.Running)throw new Error("".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.'));if(e.length){var n=!!this.machine.config.predictableActionArguments&&this._exec;this.scheduler.schedule((function(){var r,i,a=t.state,o=!1,s=[],l=function(e){var r=zT(e);t.forward(r),a=wC(t,(function(){return t.machine.transition(a,r,void 0,n||void 0)})),s.push.apply(s,J_([],X_(t.machine.config.predictableActionArguments?a.actions:a.actions.map((function(e){return function(e,t){var n=e.exec;return Q_(Q_({},e),{exec:void 0!==n?function(){return n(t.context,t.event,{action:e,state:t,_event:t._event})}:void 0})}(e,a)}))),!1)),o=o||!!a.changed};try{for(var c=Y_(e),u=c.next();!u.done;u=c.next()){l(u.value)}}catch(e){r={error:e}}finally{try{u&&!u.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}a.changed=o,a.actions=s,t.update(a,zT(e[e.length-1]))}))}},e.prototype.sender=function(e){return this.send.bind(this,e)},e.prototype._nextState=function(e,t){var n=this;void 0===t&&(t=!!this.machine.config.predictableActionArguments&&this._exec);var r=zT(e);if(0===r.name.indexOf(uT)&&!this.state.nextEvents.some((function(e){return 0===e.indexOf(uT)})))throw r.data.data;return wC(this,(function(){return n.machine.transition(n.state,r,void 0,t||void 0)}))},e.prototype.nextState=function(e){return this._nextState(e,!1)},e.prototype.forward=function(e){var t,n;try{for(var r=Y_(this.forwardTo),i=r.next();!i.done;i=r.next()){var a=i.value,o=this.children.get(a);if(!o)throw new Error("Unable to forward event '".concat(e,"' from interpreter '").concat(this.id,"' to nonexistant child '").concat(a,"'."));o.send(e)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},e.prototype.defer=function(e){var t=this,n=this.clock.setTimeout((function(){"to"in e&&e.to?t.sendTo(e._event,e.to,!0):t.send(e._event)}),e.delay);e.id&&(this.delayedEventsMap[e.id]=n)},e.prototype.cancel=function(e){this.clock.clearTimeout(this.delayedEventsMap[e]),delete this.delayedEventsMap[e]},e.prototype.exec=function(e,t,n){void 0===n&&(n=this.machine.options.actions),this._exec(e,t.context,t._event,n)},e.prototype.removeChild=function(e){var t;this.children.delete(e),this.forwardTo.delete(e),null===(t=this.state)||void 0===t||delete t.children[e]},e.prototype.stopChild=function(e){var t=this.children.get(e);t&&(this.removeChild(e),LT(t.stop)&&t.stop())},e.prototype.spawn=function(e,t,n){if(this.status!==zC.Running)return EC(e,t);if(AT(e))return this.spawnPromise(Promise.resolve(e),t);if(LT(e))return this.spawnCallback(e,t);if(function(e){try{return"function"==typeof e.send}catch(e){return!1}}(r=e)&&"id"in r)return this.spawnActor(e,t);if(function(e){try{return"subscribe"in e&<(e.subscribe)}catch(e){return!1}}(e))return this.spawnObservable(e,t);if(BT(e))return this.spawnMachine(e,Q_(Q_({},n),{id:t}));if(function(e){return null!==e&&"object"==typeof e&&"transition"in e&&"function"==typeof e.transition}(e))return this.spawnBehavior(e,t);throw new Error('Unable to spawn entity "'.concat(t,'" of type "').concat(typeof e,'".'));var r},e.prototype.spawnMachine=function(t,n){var r=this;void 0===n&&(n={});var i=new e(t,Q_(Q_({},this.options),{parent:this,id:n.id||t.id})),a=Q_(Q_({},UC),n);a.sync&&i.onTransition((function(e){r.send(pT,{state:e,id:i.id})}));var o=i;return this.children.set(i.id,o),a.autoForward&&this.forwardTo.add(i.id),i.onDone((function(e){r.removeChild(i.id),r.send(zT(e,{origin:i.id}))})).start(),o},e.prototype.spawnBehavior=function(e,t){var n=VC(e,{id:t,parent:this});return this.children.set(t,n),n},e.prototype.spawnPromise=function(e,t){var n,r,i=this,a=!1;e.then((function(e){a||(r=e,i.removeChild(t),i.send(zT(hC(t,e),{origin:t})))}),(function(e){if(!a){i.removeChild(t);var n=fC(t,e);try{i.send(zT(n,{origin:t}))}catch(r){!function(e,t,n){if(!yT){var r=e.stack?" Stacktrace was '".concat(e.stack,"'"):"";if(e===t)console.error("Missing onError handler for invocation '".concat(n,"', error was '").concat(e,"'.").concat(r));else{var i=t.stack?" Stacktrace was '".concat(t.stack,"'"):"";console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '".concat(n,"'. ")+"Original error: '".concat(e,"'. ").concat(r," Current error is '").concat(t,"'.").concat(i))}}}(e,r,t),i.devTools&&i.devTools.send(n,i.state),i.machine.strict&&i.stop()}}}));var o=(n={id:t,send:function(){},subscribe:function(t,n,r){var i=GT(t,n,r),a=!1;return e.then((function(e){a||(i.next(e),a||i.complete())}),(function(e){a||i.error(e)})),{unsubscribe:function(){return a=!0}}},stop:function(){a=!0},toJSON:function(){return{id:t}},getSnapshot:function(){return r}},n[$T]=function(){return this},n);return this.children.set(t,o),o},e.prototype.spawnCallback=function(e,t){var n,r,i,a=this,o=!1,s=new Set,l=new Set;try{i=e((function(e){r=e,l.forEach((function(t){return t(e)})),o||a.send(zT(e,{origin:t}))}),(function(e){s.add(e)}))}catch(e){this.send(fC(t,e))}if(AT(i))return this.spawnPromise(i,t);var c=((n={id:t,send:function(e){return s.forEach((function(t){return t(e)}))},subscribe:function(e){var t=GT(e);return l.add(t.next),{unsubscribe:function(){l.delete(t.next)}}},stop:function(){o=!0,LT(i)&&i()},toJSON:function(){return{id:t}},getSnapshot:function(){return r}})[$T]=function(){return this},n);return this.children.set(t,c),c},e.prototype.spawnObservable=function(e,t){var n,r,i=this,a=e.subscribe((function(e){r=e,i.send(zT(e,{origin:t}))}),(function(e){i.removeChild(t),i.send(zT(fC(t,e),{origin:t}))}),(function(){i.removeChild(t),i.send(zT(hC(t),{origin:t}))})),o=(n={id:t,send:function(){},subscribe:function(t,n,r){return e.subscribe(t,n,r)},stop:function(){return a.unsubscribe()},getSnapshot:function(){return r},toJSON:function(){return{id:t}}},n[$T]=function(){return this},n);return this.children.set(t,o),o},e.prototype.spawnActor=function(e,t){return this.children.set(t,e),e},e.prototype.spawnActivity=function(e){var t=this.machine.options&&this.machine.options.activities?this.machine.options.activities[e.type]:void 0;if(t){var n=t(this.state.context,e);this.spawnEffect(e.id,n)}else yT||IT(!1,"No implementation found for activity '".concat(e.type,"'"))},e.prototype.spawnEffect=function(e,t){var n;this.children.set(e,((n={id:e,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},stop:t||void 0,getSnapshot:function(){},toJSON:function(){return{id:e}}})[$T]=function(){return this},n))},e.prototype.attachDev=function(){var e=$C();if(this.options.devTools&&e){if(e.__REDUX_DEVTOOLS_EXTENSION__){var t="object"==typeof this.options.devTools?this.options.devTools:void 0;this.devTools=e.__REDUX_DEVTOOLS_EXTENSION__.connect(Q_(Q_({name:this.id,autoPause:!0,stateSanitizer:function(e){return{value:e.value,context:e.context,actions:e.actions}}},t),{features:Q_({jump:!1,skip:!1},t?t.features:void 0)}),this.machine),this.devTools.init(this.state)}BC(this)}},e.prototype.toJSON=function(){return{id:this.id}},e.prototype[$T]=function(){return this},e.prototype.getSnapshot=function(){return this.status===zC.NotStarted?this.initialState:this._state},e.defaultOptions={execute:!0,deferEvents:!0,clock:{setTimeout:function(e,t){return setTimeout(e,t)},clearTimeout:function(e){return clearTimeout(e)}},logger:console.log.bind(console),devTools:!1},e.interpret=HC,e}();function HC(e,t){return new qC(e,t)}let GC=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&n[e]];return t};var WC=function(e){return{type:oT,assignment:e}};class QC extends ca{constructor(e){var t;const{dataSourceUid:n}=e;let{appSubUrl:r="",bootData:i}=a.config;"/"!==(null==r?void 0:r.at(-1))&&(r+="/"),super(`${r}api/datasources/proxy/uid/${n}`,{"content-type":"application/json","X-Grafana-Org-Id":String((null==i||null===(t=i.user)||void 0===t?void 0:t.orgId)||"")}),function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"dataSourceUid",void 0),this.dataSourceUid=e.dataSourceUid}}function KC(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function YC(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){KC(a,r,i,o,s,"next",e)}function s(e){KC(a,r,i,o,s,"throw",e)}o(void 0)}))}}class XC extends QC{static queryToMatchers(e){const t=e.indexOf("{");if(t>0){return[`{__profile_type__="${e.substring(0,t)}", ${e.substring(t+1,e.length)}`]}return 0===t?[e]:[`{__profile_type__="${e}"}`]}fetchLabels(e,t,n){var r=this;return YC((function*(){return r._post("/querier.v1.QuerierService/LabelNames",{matchers:XC.queryToMatchers(e),start:t,end:n}).then((e=>e.json()))}))()}fetchLabelValues(e,t,n,r){var i=this;return YC((function*(){return i._post("/querier.v1.QuerierService/LabelValues",{name:e,matchers:XC.queryToMatchers(t),start:n,end:r}).then((e=>e.json()))}))()}_post(e,t){return super.fetch(e,{method:"POST",body:JSON.stringify(t)})}constructor(e){super(e)}}class JC{static buildCacheKey(e){let t="";for(const n of e)t+=String(n);return t}get(e){return this.store.get(JC.buildCacheKey(e))}set(e,t){this.store.set(JC.buildCacheKey(e),t)}delete(e){this.store.delete(JC.buildCacheKey(e))}constructor(){!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"store",new Map)}}function ZC(e,t){if(!e)throw new Error(t)}function ek(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class tk{setApiClient(e){this.apiClient=e}setCacheClient(e){this.cacheClient=e}cancel(e){this.apiClient.abort(e)}constructor(e){ek(this,"apiClient",void 0),ek(this,"cacheClient",void 0),this.apiClient=e.apiClient,this.cacheClient=null==e?void 0:e.cacheClient}}function nk(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function rk(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){nk(a,r,i,o,s,"next",e)}function s(e){nk(a,r,i,o,s,"throw",e)}o(void 0)}))}}class ik extends ua{static queryToMatchers(e){const t=e.indexOf("{");if(t>0){return[`{__profile_type__="${e.substring(0,t)}", ${e.substring(t+1,e.length)}`]}return 0===t?[e]:[`{__profile_type__="${e}"}`]}fetchLabels(e,t,n){var r=this;return rk((function*(){return r._post("/querier.v1.QuerierService/LabelNames",{matchers:ik.queryToMatchers(e),start:t,end:n}).then((e=>e.json()))}))()}fetchLabelValues(e,t,n,r){var i=this;return rk((function*(){return i._post("/querier.v1.QuerierService/LabelValues",{name:e,matchers:ik.queryToMatchers(t),start:n,end:r}).then((e=>e.json()))}))()}_post(e,t){return super.fetch(e,{method:"POST",body:JSON.stringify(t)})}}function ak(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function ok(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){ak(a,r,i,o,s,"next",e)}function s(e){ak(a,r,i,o,s,"throw",e)}o(void 0)}))}}function sk(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class lk extends tk{static parseLabelsResponse(e){if(!Array.isArray(e.names))return[];return Array.from(new Set(e.names.filter(lk.isNotMetaLabelOrServiceName))).map((e=>({value:e,label:e})))}static parseLabelValuesResponse(e){if(!Array.isArray(e.names))return[];return e.names.map((e=>({value:e,label:e})))}static assertParams(e,t,n){ZC(Boolean(e),'Missing "query" parameter!'),ZC(t>0&&n>0&&n>t,"Invalid timerange!")}listLabels({query:e,from:t,to:n}){var r=this;return ok((function*(){lk.assertParams(e,t,n);const i=[r.apiClient.baseUrl,e,t,n],a=r.cacheClient.get(i);if(a){const e=yield a,t=lk.parseLabelsResponse(e);return t.length||r.cacheClient.delete(i),t}const o=r.apiClient.fetchLabels(e,t,n);r.cacheClient.set(i,o);try{const e=yield o;return lk.parseLabelsResponse(e)}catch(e){throw r.cacheClient.delete(i),e}}))()}listLabelValues({label:e,query:t,from:n,to:r}){var i=this;return ok((function*(){lk.assertParams(t,n,r),ZC(Boolean(e),"Missing label value!");const a=[i.apiClient.baseUrl,e,t,n,r],o=i.cacheClient.get(a);if(o){const e=yield o,t=lk.parseLabelsResponse(e);return t.length||i.cacheClient.delete(a),t}const s=i.apiClient.fetchLabelValues(e,t,n,r);i.cacheClient.set(a,s);try{const e=yield s;return lk.parseLabelValuesResponse(e)}catch(e){throw i.cacheClient.delete(a),e}}))()}constructor(e){super({apiClient:e.apiClient}),sk(this,"cacheClient",void 0),this.cacheClient=e.cacheClient}}sk(lk,"isNotMetaLabelOrServiceName",(e=>!/^(__.+__|service_name)$/.test(e)));const ck=new lk({apiClient:new ik,cacheClient:new JC});function uk(e,t){const n=e.filter((({type:e})=>e!==z_.partial)),r=t.filter((({type:e})=>e!==z_.partial));return n.length===r.length&&n.every((e=>r.find((({type:t,attribute:n,operator:r,value:i})=>{var a,o;return t===e.type&&n.value===e.attribute.value&&(null==r?void 0:r.value)===(null===(a=e.operator)||void 0===a?void 0:a.value)&&(null==i?void 0:i.value)===(null===(o=e.value)||void 0===o?void 0:o.value)}))))}function dk(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const pk={type:z_["attribute-operator"],operator:{value:U_["is-empty"],label:"is empty"},value:{value:U_["is-empty"],label:""}},hk=e=>function(e){for(var t=1;te!==z_.partial)).map((e=>{const{attribute:t,operator:n,value:r}=e;switch(n.value){case U_.in:return`${t.value}=~"${r.value}"`;case U_["not-in"]:return`${t.value}!~"${r.value}"`;case U_["is-empty"]:return`${t.value}=""`;default:return`${t.value}${n.value}"${r.value}"`}}));var r;const[,i]=null!==(r=e.match(/{.*(service_name="[^"]*").*}/))&&void 0!==r?r:[];return i&&n.unshift(i),e.replace(/{(.*)}$/,`{${n.join(",")}}`)}const mk=e=>e.at(-1)||null,gk=e=>e===U_.in||e===U_["not-in"],yk=e=>(ZC(Boolean(e),"The filter is falsy!"),e.type===z_.partial);function bk(e,t){return e!==t&&(t!==U_["is-empty"]&&([U_["=~"],U_["!~"],U_.in,U_["not-in"],U_["is-empty"]].includes(e)||[U_["=~"],U_["!~"],U_.in,U_["not-in"]].includes(t)))}function vk(e,t){ZC(void 0!==e.operator,"No operator for the filter under edition!");return bk(e.operator.value,t)}function wk(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Sk(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const Ek=e=>{const t=e.matchAll(/(\w+)(=|!=|=~|!~)"([^"]*)"/g);return Array.from(t).map((([,e,t,n])=>[e,t,n]))},xk=/.+:[^{]+\{(.+)\}$/,Ok=/.*(\^|\$|\*|\+|\{|\}|\?).*/;function _k(e){if(!e)return[];const t=e.match(xk);if(!t)return[];return Ek(t[1]).filter((([e])=>"service_name"!==e)).map((([e,t,n])=>{const r={id:GC(10),type:z_["attribute-operator-value"],active:!0,attribute:{value:e,label:e},operator:{value:t,label:t},value:{value:n,label:n}};if(t===U_["="]&&""===n)return hk(r);return[U_["=~"],U_["!~"]].includes(t)&&!Ok.test(n)?Sk(function(e){for(var t=1;te.trim())).join(", ")}}):r}))}function Tk(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ck(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const kk=(e,t)=>e.map((e=>e.type!==z_.partial?Ck(function(e){for(var t=1;t{ck.cancel("Discarded by user")},setFilterAttribute:WC(((e,t)=>{const n=[...e.filters,{id:GC(10),type:z_.partial,active:!1,attribute:t.data}];return Ak(Rk({},e),{filters:n,isQueryUpToDate:uk(n,_k(e.inputParams.query))})})),editFilterAttribute:WC(((e,t)=>{if(null===e.edition)throw new Error("Cannot edit filter attribute without edition data!");const{filterId:n}=e.edition,r=e.filters.map((e=>e.id===n?Ak(Rk({},e),{attribute:t.data,operator:void 0,value:void 0}):e));return Ak(Rk({},e),{filters:r,isQueryUpToDate:uk(r,_k(e.inputParams.query)),edition:null})})),setFilterOperator:WC(((e,t)=>{const n=e.filters.map((e=>{if(!yk(e))return e;const n=t.data;return n.value===U_["is-empty"]?hk(e):Ak(Rk({},e),{operator:n,value:void 0})}));return Rk({},e,Dk(n,e))})),editFilterOperator:WC(((e,t)=>{if(null===e.edition)throw new Error("Cannot edit filter operator without edition data!");const{filterId:n}=e.edition,r=t.data;let i=null;const a=e.filters.map((t=>{const a=t.operator.value;return t.id!==n||a===r.value?t:r.value===U_["is-empty"]?hk(Ak(Rk({},t),{active:!1})):(a===U_["is-empty"]&&(t.value={value:"(no value)",label:"(no value)"}),!yk(t)&&bk(a,r.value)&&(i=Ak(Rk({},e.edition),{part:q_.value})),Ak(Rk({},t),{operator:r,value:gk(a)&&!gk(r.value)&&t.value?{value:t.value.value.split("|").shift(),label:t.value.label.split(", ").shift()}:t.value,active:!1}))}));return Ak(Rk({},e,Dk(a,e)),{edition:i})})),setFilterValue:WC(((e,t)=>{const n=e.filters.map((e=>yk(e)?Ak(Rk({},e),{type:z_["attribute-operator-value"],active:!1,value:t.data}):e));return Rk({},e,Dk(n,e))})),editFilterValue:WC(((e,t)=>{if(null===e.edition)throw new Error("Cannot edit filter value without edition data!");const{filterId:n}=e.edition,r=e.filters.map((e=>e.id===n?Ak(Rk({},e),{type:z_["attribute-operator-value"],active:!1,value:t.data}):e));return Ak(Rk({},e,Dk(r,e)),{edition:null})})),removeFilter:WC(((e,t)=>{const n=t.data,r=kk(e.filters.filter((({id:e})=>e!==n)),!1);return Rk({},e,Dk(r,e))})),removeLastFilter:WC((e=>{const{filters:t}=e,n=mk(t);if(!n)return e;if(yk(n)&&n.operator){const r=t.slice(0,t.length-1).concat(Ak(Rk({},n),{operator:void 0}));return Ak(Rk({},e),{filters:r,isQueryUpToDate:!0})}const r=t.slice(0,t.length-1).map((e=>Ak(Rk({},e),{active:!1})));return Rk({},e,Dk(r,e))})),setEdition:WC({edition:(e,t)=>t.data}),changeInputParams:WC(((e,t)=>(t.data.dataSourceUid&&ck.setApiClient(new XC({dataSourceUid:t.data.dataSourceUid})),{inputParams:t.data,query:t.data.query,filters:_k(t.data.query),isQueryUpToDate:!0}))),activateFilters:WC((e=>Rk({},e,Dk(e.filters,e))))};function Ik(e){const{edition:t,filters:n}=e;ZC(null!==t,'"edition" is null!');const r=n.find((({id:e})=>e===t.filterId));return ZC(void 0!==r,"Cannot find the filter under edition!"),r}const Nk={shouldSuggestAttributes:e=>{const t=mk(e.filters);return!t||!yk(t)},shouldSuggestOperators:e=>{var t;return!(null===(t=mk(e.filters))||void 0===t?void 0:t.operator)},shouldSuggestValues:e=>{const t=mk(e.filters);return Boolean((null==t?void 0:t.operator)&&!(null==t?void 0:t.value))},isEditing:e=>null!==e.edition,shouldSuggestValuesAfterOperatorEdition:(e,t)=>!!e.edition&&vk(Ik(e),t.data.value),shouldNotSuggestValuesAfterOperatorEdition:(e,t)=>!!e.edition&&!vk(Ik(e),t.data.value),hasPartialFilter:e=>{const t=mk(e.filters);return Boolean(t&&yk(t))},shouldEditAttribute:(e,t)=>t.data.part===q_.attribute,shouldEditOperator:(e,t)=>t.data.part===q_.operator,shouldEditValue:(e,t)=>t.data.part===q_.value};function Lk(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}const Mk=new class{list(){return(e=function*(){return[{value:"=",label:"="},{value:"!=",label:"!="},{value:"is-empty",label:"is empty"},{value:"in",label:"in",description:"Is one of"},{value:"not-in",label:"not in",description:"Is not one of"},{value:"=~",label:"=~",description:"Matches regex"},{value:"!~",label:"!~",description:"Does not match regex"}]},function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Lk(a,r,i,o,s,"next",e)}function s(e){Lk(a,r,i,o,s,"throw",e)}o(void 0)}))})();var e}},Fk=e=>e.startsWith("__");function $k(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function Bk(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){$k(a,r,i,o,s,"next",e)}function s(e){$k(a,r,i,o,s,"throw",e)}o(void 0)}))}}function Vk(e,t){if(e instanceof DOMException&&"AbortError"===e.name)return[];throw Xi.error(e,{info:t}),e}const zk={fetchLabels:function(){var e=Bk((function*(e){const{from:t,to:n}=e.inputParams;try{const r=yield ck.listLabels({query:e.query,from:t,to:n}),i=[],a=[];return r.forEach((e=>{Fk(e.value)?a.push(e):i.push(e)})),[...i,...a]}catch(e){return Vk(e,"Error while fetching labels!")}}));return function(t){return e.apply(this,arguments)}}(),fetchOperators:Bk((function*(){try{return yield Mk.list()}catch(e){return Vk(e,"Error while fetching operators!")}})),fetchLabelValues:function(){var e=Bk((function*(e){let t,{query:n,edition:r,suggestions:i}=e;try{if(r){const i=e.filters.filter((e=>e.id!==r.filterId||(t=e,!1)));if(!t)throw new Error(`Impossible to edit filter id="${r.filterId}": no filter found!`);n=fk(n,i)}else if(t=mk(e.filters),(null==t?void 0:t.type)!==z_.partial)throw new Error("Impossible to load label values: no partial filter found!");if(i.disabled)return[];const a=t.attribute.value,{from:o,to:s}=e.inputParams;return yield ck.listLabelValues({label:a,query:n,from:o,to:s})}catch(e){return Vk(e,"Error while fetching label values!")}}));return function(t){return e.apply(this,arguments)}}()},Uk={always:[{cond:"shouldSuggestOperators",target:"loadOperators"},{cond:"shouldSuggestValues",target:"loadLabelValues"},{target:"idle"}]},qk={FILTER_ADD:"Filter by label values...",SELECT_LABEL:"Select a label...",SELECT_OPERATOR:"Select an operator...",SELECT_VALUE:"Select a value...",SELECT_VALUES:"Select values...",TYPE_VALUE:"Type a regex...",LOADING:"Loading...",ERROR_LOAD:"An unexpected error occurred while loading! Please try again.",SUGGESTIONS_NONE:"No suggestions available.",SUGGESTIONS_DISABLED:"Suggestions are disabled for this label."},Hk=e=>e===U_["=~"]||e===U_["!~"];function Gk(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Wk(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const Qk={entry:["cancelAllLoad",WC({suggestions:e=>{let t=qk.FILTER_ADD,n=!1;const r=mk(e.filters);return r&&yk(r)&&(r.operator?(n=Hk(r.operator.value),t=gk(r.operator.value)?qk.SELECT_VALUES:n?qk.TYPE_VALUE:qk.SELECT_VALUE):t=qk.SELECT_OPERATOR),Wk(function(e){for(var t=1;tXk(Yk({},pP.suggestions),{isVisible:!0,isLoading:!0})}),invoke:{id:"fetchLabels",src:"fetchLabels",onDone:{target:"displayLabels",actions:WC({suggestions:(e,t)=>Xk(Yk({},e.suggestions),{items:t.data.filter((({value:t})=>!e.filters.some((e=>{var n;return(null===(n=e.attribute)||void 0===n?void 0:n.value)===t})))),isLoading:!1})})},onError:{target:"displayLabels",actions:WC({suggestions:(e,t)=>Xk(Yk({},e.suggestions),{isLoading:!1,error:t.data})})}},on:{DISCARD_SUGGESTIONS:"idle"}},Zk={entry:WC({suggestions:e=>Xk(Yk({},e.suggestions),{type:H_.attribute,isVisible:!0,placeholder:qk.SELECT_LABEL})}),on:{DISCARD_SUGGESTIONS:"idle",SELECT_SUGGESTION:[{cond:"isEditing",target:"loadOperators",actions:["editFilterAttribute"]},{target:"loadOperators",actions:["setFilterAttribute"]}],REMOVE_LAST_FILTER:{target:"idle",actions:["removeLastFilter"]}}};function eP(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tP(e){for(var t=1;t{const t=e.edition?Ik(e):mk(e.filters);return ZC(void 0!==typeof(null==t?void 0:t.operator),"No operator for the target filter!"),nP(tP({},pP.suggestions),{disabled:["=~","!~"].includes(t.operator.value)||Fk(t.attribute.value),isVisible:!0,isLoading:!0})}}),invoke:{id:"fetchLabelValues",src:"fetchLabelValues",onDone:{target:"displayLabelValues",actions:WC({suggestions:(e,t)=>nP(tP({},e.suggestions),{items:t.data,isLoading:!1})})},onError:{target:"displayLabelValues",actions:WC({suggestions:(e,t)=>nP(tP({},e.suggestions),{items:[],isLoading:!1,error:t.data})})}},on:{DISCARD_SUGGESTIONS:"idle"}},iP={entry:WC({suggestions:e=>{const t=e.edition?Ik(e):mk(e.filters);ZC(void 0!==typeof(null==t?void 0:t.operator),"No operator for the target filter!");const n=t.operator.value,r=Hk(n)||e.suggestions.disabled,i=gk(n);let a,o;return a=r?qk.TYPE_VALUE:i?qk.SELECT_VALUES:qk.SELECT_VALUE,o=e.suggestions.error?qk.ERROR_LOAD:e.suggestions.disabled?qk.SUGGESTIONS_DISABLED:qk.SUGGESTIONS_NONE,nP(tP({},e.suggestions),{type:H_.value,isVisible:!0,placeholder:a,noOptionsMessage:o,allowCustomValue:r,multiple:i})}}),on:{DISCARD_SUGGESTIONS:"idle",SELECT_SUGGESTION:[{cond:"isEditing",target:"autoSuggestProxy",actions:["editFilterValue"]},{target:"idle",actions:["setFilterValue"]}],REMOVE_LAST_FILTER:{target:"loadOperators",actions:["removeLastFilter"]}}};function aP(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oP(e){for(var t=1;tsP(oP({},pP.suggestions),{isVisible:!0,isLoading:!0})}),invoke:{id:"fetchOperators",src:"fetchOperators",onDone:{target:"displayOperators",actions:WC({suggestions:(e,t)=>sP(oP({},e.suggestions),{items:t.data,isLoading:!1})})},onError:{target:"displayOperators",actions:WC({suggestions:(e,t)=>sP(oP({},e.suggestions),{items:[],isLoading:!1,error:t.data})})}},on:{DISCARD_SUGGESTIONS:"idle"}},cP={entry:WC({suggestions:e=>sP(oP({},e.suggestions),{type:H_.operator,isVisible:!0,placeholder:qk.SELECT_OPERATOR,allowCustomValue:!1,multiple:!1})}),on:{DISCARD_SUGGESTIONS:"idle",SELECT_SUGGESTION:[{cond:"shouldSuggestValuesAfterOperatorEdition",target:"loadLabelValues",actions:["editFilterOperator"]},{cond:"shouldNotSuggestValuesAfterOperatorEdition",target:"autoSuggestProxy",actions:["editFilterOperator"]},{cond:"hasPartialFilter",target:"autoSuggestProxy",actions:["setFilterOperator"]},{target:"loadLabelValues",actions:["setFilterOperator"]}],REMOVE_LAST_FILTER:{target:"loadLabels",actions:["removeLastFilter"]}}};function uP(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dP(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const pP=Object.freeze({inputParams:{query:"",from:0,to:0},query:"",filters:[],isQueryUpToDate:!0,edition:null,suggestions:{type:null,items:[],isVisible:!1,isLoading:!1,error:null,placeholder:"",noOptionsMessage:"",allowCustomValue:!1,multiple:!1,disabled:!1}}),hP=e=>({id:"query-builder",initial:"idle",context:e,predictableActionArguments:!0,states:{idle:Qk,loadLabels:Jk,displayLabels:Zk,loadOperators:lP,displayOperators:cP,loadLabelValues:rP,displayLabelValues:iP,autoSuggestProxy:Uk}}),fP={guards:Nk,services:zk,actions:jk};function mP(e){const{query:t}=e,n=dP(function(e){for(var t=1;t(t,n)=>{const r=e.some((e=>e.value===t.value)),i=e.some((e=>e.value===n.value));return r&&i?gP(t.value,n.value):i?1:r?-1:0};function bP({selection:e,suggestions:t,onCloseMenu:n}){const r=(0,o.useStyles2)(vP),i=(0,Fi.useMemo)((()=>{const t=e.value.split("|"),n=e.label.split(", ");return t.map(((e,t)=>({value:e,label:n[t]})))}),[e]),[a,s]=(0,Fi.useState)(i),l=(0,Fi.useMemo)((()=>t.items.sort(yP(a))),[t.items]),c=(0,Fi.useCallback)((e=>{s(e.map((({value:e="",label:t=""})=>({value:e,label:t}))))}),[]),u=(0,Fi.useCallback)((()=>{n(a)}),[n,a]);return $i().createElement(o.MultiSelect,{className:r.editionSelect,placeholder:t.placeholder,loadingMessage:qk.LOADING,closeMenuOnSelect:!1,hideSelectedOptions:!1,backspaceRemovesValue:!0,autoFocus:!0,value:a,onChange:c,onCloseMenu:u,options:l,isOpen:!0,isLoading:t.isLoading,invalid:Boolean(t.error),noOptionsMessage:t.noOptionsMessage})}const vP=()=>({editionSelect:i.css` position: absolute; z-index: 1; [aria-label='Remove'] svg { display: none; } `});function wP({placeholder:e,defaultValue:t,onFocus:n,onChange:r,onBlur:a}){const s=(0,o.useStyles2)(SP),l=(0,Fi.useRef)(null),[c,u]=(0,Fi.useState)(!1);return(0,Fi.useEffect)((()=>{l.current&&l.current.focus()}),[]),$i().createElement(o.Input,{ref:l,className:(0,i.cx)(t&&s.edition),invalid:c,placeholder:e,defaultValue:t,onFocus:n,onKeyUp:e=>{const t=e.target.value.trim();"Enter"===e.code&&(t?r({value:t,label:t}):u(!0))},onBlur:e=>{const t=e.target.value.trim();t?r({value:t,label:t}):a()}})}const SP=()=>({edition:i.css` position: absolute; z-index: 1; `}),EP=()=>({editionSelect:i.css` position: absolute; z-index: 1; min-width: 160px; box-shadow: none; & input:focus { outline: none !important; } `});function xP({selection:e,suggestions:t,onChange:n,onCloseMenu:r}){const i=(0,o.useStyles2)(EP);return t.allowCustomValue?$i().createElement(wP,{defaultValue:e.value,placeholder:t.placeholder,onChange:n,onBlur:r}):$i().createElement(o.Select,{className:i.editionSelect,placeholder:t.placeholder,loadingMessage:qk.LOADING,closeMenuOnSelect:!1,autoFocus:!0,value:e.value,onChange:n,onCloseMenu:r,options:t.items,isOpen:!0,isLoading:t.isLoading,invalid:Boolean(t.error),noOptionsMessage:t.noOptionsMessage})}const OP=()=>{},_P=({filter:e,onClick:t,onRemove:n})=>{const r=(0,o.useStyles2)(AP),{attribute:a,operator:s,active:l}=e,c=l?r.chiclet:(0,i.cx)(r.chiclet,r.inactiveChiclet);return $i().createElement("div",{className:c,"aria-label":"Filter"},$i().createElement(o.Tag,{"aria-label":"Filter label",className:r.chicletAttribute,name:a.label,onClick:OP}),$i().createElement(o.Tag,{"aria-label":"Filter operator",className:r.chicletOperator,name:s.label,onClick:(n,r)=>t(r,e,q_.operator),tabIndex:0}),$i().createElement(o.Tag,{"aria-label":"Remove filter",className:r.chicletRemoveButton,icon:"times",name:"",onClick:(t,r)=>n(r,e),tabIndex:0}))},TP=()=>{},CP=({filter:e,onClick:t,onRemove:n})=>{const r=(0,o.useStyles2)(AP),{attribute:a,operator:s,value:l,active:c}=e,u=c?r.chiclet:(0,i.cx)(r.chiclet,r.inactiveChiclet);return $i().createElement("div",{className:u,"aria-label":"Filter"},$i().createElement(o.Tag,{"aria-label":"Filter label",className:r.chicletAttribute,name:a.label,onClick:TP}),$i().createElement(o.Tag,{"aria-label":"Filter operator",className:r.chicletOperator,name:s.label,onClick:(n,r)=>t(r,e,q_.operator),tabIndex:0}),$i().createElement(o.Tooltip,{content:l.label},$i().createElement(o.Tag,{"aria-label":"Filter value",name:l.label,className:r.chicletValue,onClick:(n,r)=>t(r,e,q_.value),tabIndex:0})),$i().createElement(o.Tag,{"aria-label":"Remove filter",className:r.chicletRemoveButton,icon:"times",name:"",onClick:(t,r)=>n(r,e),tabIndex:0}))},kP=({filter:e,onClick:t})=>{const n=(0,o.useStyles2)(AP),{attribute:r,operator:a}=e;return r||a?$i().createElement("div",{className:(0,i.cx)(n.chiclet,n.partialChiclet),"aria-label":"Partial filter"},$i().createElement(o.Tag,{colorIndex:9,name:r.label,title:`Edit "${r.label}"`,onClick:(n,r)=>t(r,e,q_.attribute),tabIndex:0}),a&&$i().createElement(o.Tag,{colorIndex:9,name:a.label,title:`Edit "${a.label}"`,className:n.chicletOperator,onClick:(n,r)=>t(r,e,q_.operator),tabIndex:0})):null},PP="rgb(61, 113, 217)",RP="#4a4b52",AP=e=>({chiclet:i.css` display: flex; align-items: center; border: 1px solid ${PP}; border-radius: 2px; & > button { height: 30px; background-color: ${e.colors.background.primary}; color: ${e.colors.text.maxContrast}; } & > :first-child { background-color: ${PP}; color: ${"#fff"}; border-radius: 0; &:hover { cursor: not-allowed !important; } } & > :last-child { border-left: 1px solid ${PP}; border-top-left-radius: 0; border-bottom-left-radius: 0; } `,partialChiclet:i.css` border-color: ${RP}; border-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; & > :first-child { background-color: ${e.colors.background.secondary}; color: ${e.colors.text.maxContrast}; border-radius: 0; border-left: 0; &:hover { cursor: pointer !important; } } & > :last-child { border-color: ${RP}; color: ${e.colors.text.maxContrast}; } `,inactiveChiclet:i.css` border-color: ${RP}; & > button { color: ${e.colors.text.maxContrast}; } & > :first-child { background-color: ${e.colors.background.secondary}; color: ${e.colors.text.maxContrast}; } & > :last-child { border-color: ${RP}; } `,chicletAttribute:i.css` &:hover { opacity: 1 !important; } `,chicletOperator:i.css` &:hover { background-color: ${e.colors.background.secondary}; } `,chicletValue:i.css` flex-grow: 1; text-align: left; max-width: 420px; text-overflow: ellipsis; text-wrap: nowrap; overflow: hidden; &:hover { background-color: ${e.colors.background.secondary}; } `,chicletRemoveButton:i.css` &:hover { background-color: ${e.colors.background.secondary}; } & svg { width: 12px; height: 12px; } `}),DP=({filter:e,onClick:t,onRemove:n})=>{switch(e.type){case z_.partial:return $i().createElement(kP,{filter:e,onClick:t});case z_["attribute-operator-value"]:return $i().createElement(CP,{filter:e,onClick:t,onRemove:n});case z_["attribute-operator"]:return $i().createElement(_P,{filter:e,onClick:t,onRemove:n});default:throw new TypeError(`Unsupported filter type "${e.type}" (${JSON.stringify(e)})!`)}},jP=(0,Fi.memo)(DP,((e,t)=>JSON.stringify(e.filter)===JSON.stringify(t.filter))),IP=()=>({chicletsList:i.css` display: flex; align-items: center; flex-wrap: wrap; gap: 4px; `,editChicletContainer:i.css` position: relative; `});function NP({filters:e,onClickChiclet:t,onRemoveChiclet:n,edition:r,suggestions:i,onChangeSingleSuggestion:a,onCloseSingleSuggestionsMenu:s,onCloseMultipleSuggestionsMenu:l}){const c=(0,o.useStyles2)(IP);return $i().createElement("div",{className:c.chicletsList,"data-testid":"filtersList"},e.map((e=>$i().createElement("div",{key:e.id,className:c.editChicletContainer},$i().createElement(jP,{filter:e,onClick:t,onRemove:n}),(null==r?void 0:r.filterId)===e.id?i.multiple?$i().createElement(bP,{selection:e[r.part],suggestions:i,onCloseMenu:l}):$i().createElement(xP,{key:r.part,selection:e[r.part],suggestions:i,onChange:a,onCloseMenu:s}):null))))}const LP=(0,Fi.memo)(NP),MP=()=>({select:i.css` border-top-right-radius: 0; border-bottom-right-radius: 0; `});function FP({suggestions:e,onFocus:t,onChange:n,onKeyDown:r,onCloseMenu:i}){const a=(0,o.useStyles2)(MP),s=function(e){const[t,n]=(0,Fi.useState)(!1);return(0,Fi.useEffect)((()=>{!e||t?e!==t&&n(e):setTimeout((()=>n(!0)),0)}),[t,e]),t}(e.isVisible);return e.allowCustomValue?$i().createElement(wP,{placeholder:e.placeholder,onFocus:t,onChange:n,onBlur:i}):$i().createElement(o.Select,{className:a.select,placeholder:e.placeholder,loadingMessage:qk.LOADING,closeMenuOnSelect:!1,value:null,onFocus:t,onKeyDown:r,onChange:n,onCloseMenu:i,options:e.items,isOpen:s,isLoading:e.isLoading,invalid:Boolean(e.error),noOptionsMessage:e.noOptionsMessage})}const $P=()=>{};function BP(){const e=(0,o.useStyles2)(MP);return $i().createElement(o.Select,{disabled:!0,className:e.select,placeholder:qk.FILTER_ADD,onChange:$P})}function VP({suggestions:e,onFocus:t,onKeyDown:n,onCloseMenu:r}){const i=(0,o.useStyles2)(zP),[a,s]=(0,Fi.useState)([]),l=(0,Fi.useCallback)((e=>{s(e.map((({value:e="",label:t=""})=>({value:e,label:t}))))}),[]),c=(0,Fi.useCallback)((e=>{n(e,a)}),[n,a]),u=(0,Fi.useCallback)((()=>{r(a)}),[r,a]);return $i().createElement(o.MultiSelect,{className:i.select,placeholder:e.placeholder,loadingMessage:qk.LOADING,closeMenuOnSelect:!1,hideSelectedOptions:!1,backspaceRemovesValue:!0,autoFocus:!0,value:a,onFocus:t,onKeyDown:c,onChange:l,onCloseMenu:u,options:e.items,isOpen:e.isVisible,isLoading:e.isLoading,invalid:Boolean(e.error),noOptionsMessage:e.noOptionsMessage})}const zP=()=>({select:i.css` [aria-label='Remove'] svg { display: none; } `}),UP=()=>({queryBuilder:i.css` display: flex; justify-content: flex-start; align-items: flex-end; flex-wrap: wrap; gap: 4px; width: 100%; `,controls:i.css` display: flex; align-self: flex-start; flex-grow: 1; `,executeButton:i.css` border-top-left-radius: 0; border-bottom-left-radius: 0; `});function qP(e){const t=(0,o.useStyles2)(UP),{actor:n,internalProps:r}=function({dataSourceUid:e,query:t,from:n,to:r,onChangeQuery:i}){const{actor:a,initialContext:o}=(0,Fi.useMemo)((()=>mP({query:t,from:n,to:r})),[]);(0,Fi.useEffect)((()=>{a.send({type:"CHANGE_INPUT_PARAMS",data:{dataSourceUid:e,query:t,from:n,to:r}})}),[a,e,t,n,r]);const[s,l]=(0,Fi.useState)(o);return(0,Fi.useEffect)((()=>(a.start(),a.subscribe((({event:e,context:t})=>{"EXECUTE_QUERY"===e.type&&i(t.query,t.filters),l(t)})),()=>{a.stop()})),[a]),{actor:a,internalProps:s}}(e),{filters:a,edition:s,isQueryUpToDate:l,suggestions:c}=r,{onClickChiclet:u,onRemoveChiclet:d}=function(e){const t=(0,Fi.useCallback)(((t,n,r)=>{e.send({type:"EDIT_FILTER",data:{filterId:n.id,part:r}})}),[e]),n=(0,Fi.useCallback)(((t,n)=>{e.send({type:"REMOVE_FILTER",data:n.id})}),[e]);return{onClickChiclet:t,onRemoveChiclet:n}}(n),{onFocus:p,onChangeSingleSuggestion:h,onSingleSelectKeyDown:f,onCloseSingleMenu:m,onMultipleSelectKeyDown:g,onCloseMultipleMenu:y}=function(e,t,n){const r=(0,Fi.useCallback)((()=>{e.send({type:"START_INPUT"})}),[e]),i=(0,Fi.useCallback)((t=>{const{value:n="",label:r=""}=t;e.send({type:"SELECT_SUGGESTION",data:{value:n,label:r}})}),[e]),a=(0,Fi.useCallback)((t=>{"Backspace"!==t.code||t.target.value||e.send({type:"REMOVE_LAST_FILTER"})}),[e]),o=(0,Fi.useCallback)((()=>{e.send({type:"DISCARD_SUGGESTIONS"})}),[e]),s=(0,Fi.useCallback)(((t,n)=>{"Backspace"!==t.code||t.target.value||n.length||e.send({type:"REMOVE_LAST_FILTER"})}),[e]),l=(0,Fi.useCallback)((t=>{t.length?e.send({type:"SELECT_SUGGESTION",data:{value:t.map((e=>e.value)).join("|"),label:t.map((e=>e.label)).join(", ")}}):e.send({type:"DISCARD_SUGGESTIONS"})}),[e]),c=function(e){const t=(0,Fi.useRef)();return(0,Fi.useEffect)((()=>{t.current=e})),t.current}(t.isVisible);return(0,Fi.useEffect)((()=>{var e;!t.isVisible&&c&&(null===(e=document.querySelector(`#${n} input`))||void 0===e||e.blur())}),[t.isVisible,c,n]),{onFocus:r,onChangeSingleSuggestion:i,onSingleSelectKeyDown:a,onMultipleSelectKeyDown:s,onCloseSingleMenu:o,onCloseMultipleMenu:l}}(n,c,e.id),b=(0,Fi.useCallback)((()=>{n.send({type:"EXECUTE_QUERY"})}),[n]);return(0,Fi.useEffect)((()=>{if(!e.autoExecute)return;const t=({value:e,context:t,event:r})=>{"idle"!==e||t.isQueryUpToDate||"EXECUTE_QUERY"===r.type||n.send({type:"EXECUTE_QUERY"})};return n.onTransition(t),()=>{n.off(t)}}),[n,e.autoExecute]),$i().createElement("div",{id:e.id,className:(0,i.cx)(t.queryBuilder,e.className)},a.length>0?$i().createElement(LP,{filters:a,onClickChiclet:u,onRemoveChiclet:d,edition:s,suggestions:c,onChangeSingleSuggestion:h,onCloseSingleSuggestionsMenu:m,onCloseMultipleSuggestionsMenu:y}):null,$i().createElement("div",{className:t.controls},s?$i().createElement(BP,null):c.multiple?$i().createElement(VP,{suggestions:c,onFocus:p,onKeyDown:g,onCloseMenu:y}):$i().createElement(FP,{suggestions:c,onFocus:p,onChange:h,onKeyDown:f,onCloseMenu:m}),!e.autoExecute&&$i().createElement(o.Button,{onClick:b,tooltip:l?"Nothing to execute, all filters applied":"Execute new query",className:t.executeButton,disabled:l},"Execute")))}const HP=(0,Fi.memo)(qP),GP=JSON.parse('{"block:contentions:count:contentions:count":{"id":"block:contentions:count:contentions:count","description":"Number of blocking contentions","type":"contentions","group":"block","unit":"short"},"block:delay:nanoseconds:contentions:count":{"id":"block:delay:nanoseconds:contentions:count","description":"Time spent in blocking delays","type":"delay","group":"block","unit":"ns"},"goroutine:goroutine:count:goroutine:count":{"id":"goroutine:goroutine:count:goroutine:count","description":"Number of goroutines","type":"goroutine","group":"goroutine","unit":"short"},"goroutines:goroutine:count:goroutine:count":{"id":"goroutines:goroutine:count:goroutine:count","description":"Number of goroutines","type":"goroutine","group":"goroutine","unit":"short"},"memory:alloc_in_new_tlab_bytes:bytes::":{"id":"memory:alloc_in_new_tlab_bytes:bytes::","description":"Size of memory allocated inside Thread-Local Allocation Buffers (TLAB)","type":"alloc_in_new_tlab_bytes","group":"memory","unit":"bytes"},"memory:alloc_in_new_tlab_objects:count::":{"id":"memory:alloc_in_new_tlab_objects:count::","description":"Number of objects allocated inside Thread-Local Allocation Buffers (TLAB)","type":"alloc_in_new_tlab_objects","group":"memory","unit":"short"},"memory:alloc_objects:count:space:bytes":{"id":"memory:alloc_objects:count:space:bytes","description":"Number of objects allocated","type":"alloc_objects","group":"memory","unit":"short"},"memory:alloc_space:bytes:space:bytes":{"id":"memory:alloc_space:bytes:space:bytes","description":"Size of memory allocated in the heap","type":"alloc_space","group":"memory","unit":"bytes"},"memory:inuse_objects:count:space:bytes":{"id":"memory:inuse_objects:count:space:bytes","description":"Number of objects currently in use","type":"inuse_objects","group":"memory","unit":"short"},"memory:inuse_space:bytes:space:bytes":{"id":"memory:inuse_space:bytes:space:bytes","description":"Size of memory currently in use","type":"inuse_space","group":"memory","unit":"bytes"},"mutex:contentions:count:contentions:count":{"id":"mutex:contentions:count:contentions:count","description":"Number of observed mutex contentions","type":"contentions","group":"mutex","unit":"short"},"mutex:delay:nanoseconds:contentions:count":{"id":"mutex:delay:nanoseconds:contentions:count","description":"Time spent waiting due to mutex contentions","type":"delay","group":"mutex","unit":"ns"},"process_cpu:alloc_samples:count:cpu:nanoseconds":{"id":"process_cpu:alloc_samples:count:cpu:nanoseconds","description":"Number of memory allocation samples during CPU time","type":"alloc_samples","group":"memory","unit":"short"},"process_cpu:alloc_size:bytes:cpu:nanoseconds":{"id":"process_cpu:alloc_size:bytes:cpu:nanoseconds","description":"Size of memory allocated during CPU time","type":"alloc_size","group":"alloc_size","unit":"bytes"},"process_cpu:cpu:nanoseconds:cpu:nanoseconds":{"id":"process_cpu:cpu:nanoseconds:cpu:nanoseconds","description":"CPU time consumed","type":"cpu","group":"process_cpu","unit":"ns"},"process_cpu:exception:count:cpu:nanoseconds":{"id":"process_cpu:exception:count:cpu:nanoseconds","description":"Number of exceptions within the sampled CPU time","type":"exceptions","group":"exceptions","unit":"short"},"process_cpu:lock_count:count:cpu:nanoseconds":{"id":"process_cpu:lock_count:count:cpu:nanoseconds","description":"Number of lock acquisitions attempted during CPU time","type":"lock_count","group":"locks","unit":"short"},"process_cpu:lock_time:nanoseconds:cpu:nanoseconds":{"id":"process_cpu:lock_time:nanoseconds:cpu:nanoseconds","description":"Cumulative time spent acquiring locks","type":"lock_time","group":"locks","unit":"ns"},"process_cpu:samples:count::milliseconds":{"id":"process_cpu:samples:count::milliseconds","description":"Number of process samples collected","type":"samples","group":"process_cpu","unit":"short"},"process_cpu:samples:count:cpu:nanoseconds":{"id":"process_cpu:samples:count:cpu:nanoseconds","description":"Number of samples collected over CPU time","type":"samples","group":"process_cpu","unit":"short"}}');function WP(e){if(GP[e])return GP[e];const[t="?",n="?"]=e?e.split(":"):[];return{id:e,description:"",type:n,group:t,unit:"short"}}const QP=Object.freeze({type:"grafana-pyroscope-datasource",uid:"$dataSource"}),KP=Object.freeze({type:"grafana-pyroscope-series-datasource",uid:"grafana-pyroscope-series-datasource"}),YP=Object.freeze({type:"grafana-pyroscope-favorites-datasource",uid:"grafana-pyroscope-favorites-datasource"}),XP=Object.freeze({type:"grafana-pyroscope-labels-datasource",uid:"grafana-pyroscope-labels-datasource"});function JP(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function ZP(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class eR extends _S{onActivate(){this.state.value||this.setState({value:eR.DEFAULT_VALUE})}update(e=!1){var t,n=this;return(t=function*(){if(!e&&n.state.loading)return;let t=[],r=null;n.setState({loading:!0,options:[],error:null});try{t=yield(0,qp.lastValueFrom)(n.getValueOptions({}))}catch(e){r=e}finally{n.setState({loading:!1,options:t,error:r})}},function(){var e=this,n=arguments;return new Promise((function(r,i){var a=t.apply(e,n);function o(e){JP(a,r,i,o,s,"next",e)}function s(e){JP(a,r,i,o,s,"throw",e)}o(void 0)}))})()}static buildCascaderOptions(e){const t=new Map;for(const{value:n}of e){const e=WP(n),{group:r,type:i}=e,a=t.get(r)||{value:r,label:r,items:[]},o=a.items||[];o.push({value:n,label:i}),a.items=o,t.set(r,a)}return Array.from(t.values()).sort(((e,t)=>gP(t.label,e.label)))}constructor(e){super(function(e){for(var t=1;t{Ts("g_pyroscope_app_profile_metric_selected"),this.state.skipUrlSync||M_(),this.changeValueTo(e)})),this.changeValueTo=this.changeValueTo.bind(this),this.addActivationHandler(this.onActivate.bind(this))}}ZP(eR,"DEFAULT_VALUE","process_cpu:cpu:nanoseconds:cpu:nanoseconds"),ZP(eR,"QUERY_DEFAULT","$dataSource and all profile metrics"),ZP(eR,"QUERY_SERVICE_NAME_DEPENDENT","$dataSource and only $serviceName profile metrics"),ZP(eR,"Component",(({model:e})=>{const t=(0,o.useStyles2)(tR),{loading:n,value:r,options:i,error:a}=e.useState(),s=(0,Fi.useMemo)((()=>eR.buildCascaderOptions(i)),[i]);return a?$i().createElement(o.Tooltip,{theme:"error",content:a.toString()},$i().createElement(o.Icon,{className:t.iconError,name:"exclamation-triangle",size:"xl"})):$i().createElement(o.Cascader,{key:GC(5),"aria-label":"Profile metrics list",width:24,separator:"/",displayAllSelectedLevels:!0,placeholder:n?"Loading...":`Select a profile metric (${i.length})`,options:s,initialValue:r,changeOnSelect:!1,onSelect:e.onSelect})}));const tR=e=>({iconError:i.css` height: 32px; align-self: center; color: ${e.colors.error.text}; `});function nR(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function rR(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class iR extends _S{onActivate(){const{serviceName:e}=ta.get(ta.KEYS.PROFILES_EXPLORER)||{};e&&!this.state.value&&this.setState({value:e}),this.subscribeToState(((e,t)=>{if(e.value&&e.value!==t.value){const t=ta.get(ta.KEYS.PROFILES_EXPLORER)||{};t.serviceName=e.value,ta.set(ta.KEYS.PROFILES_EXPLORER,t)}}))}update(){var e,t=this;return(e=function*(){if(t.state.loading)return;let e=[],n=null;t.setState({loading:!0,options:[],error:null});try{e=yield(0,qp.lastValueFrom)(t.getValueOptions({}))}catch(e){n=e}finally{t.setState({loading:!1,options:e,error:n})}},function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){nR(a,r,i,o,s,"next",e)}function s(e){nR(a,r,i,o,s,"throw",e)}o(void 0)}))})()}constructor(e){super(function(e){for(var t=1;t{Ts("g_pyroscope_app_service_name_selected"),this.state.skipUrlSync||M_(),this.changeValueTo(e)})),this.addActivationHandler(this.onActivate.bind(this))}}rR(iR,"QUERY_DEFAULT","$dataSource and all services"),rR(iR,"QUERY_PROFILE_METRIC_DEPENDENT","$dataSource and only $profileMetricId services"),rR(iR,"Component",(({model:e})=>{const t=(0,o.useStyles2)(aR),{loading:n,value:r,options:i,error:a}=e.useState(),s=(0,Fi.useMemo)((()=>function(e){const t=[];for(const n of e){const e=n.split("/");let r;const i=[];let a=t;for(let t=0;te.value===n));if(o)a=o.items;else{const i={value:n,label:r,items:te)))),[i]);return a?$i().createElement(o.Tooltip,{theme:"error",content:a.toString()},$i().createElement(o.Icon,{className:t.iconError,name:"exclamation-triangle",size:"xl"})):$i().createElement(o.Cascader,{key:GC(5),"aria-label":"Services list",width:32,separator:"/",displayAllSelectedLevels:!0,placeholder:n?"Loading services...":`Select a service (${i.length})`,options:s,initialValue:r,changeOnSelect:!1,onSelect:e.selectNewValue})}));const aR=e=>({iconError:i.css` height: 32px; align-self: center; color: ${e.colors.error.text}; `});function oR(e,t){const{value:n}=tm.findByKeyAndType(e,"serviceName",iR).useState(),{value:r}=tm.findByKeyAndType(e,"profileMetricId",eR).useState(),{filterExpression:i}=tm.findByKeyAndType(e,t,vR).useState();return(0,Fi.useMemo)((()=>`${r}{service_name="${n}",${i}}`),[i,r,n])}class sR extends Xw{onActivate(){this.setState({skipUrlSync:!1}),this.subscribeToState(((e,t)=>{if(e.value&&e.value!==t.value){const t=ta.get(ta.KEYS.PROFILES_EXPLORER)||{};t.dataSource=e.value,ta.set(ta.KEYS.PROFILES_EXPLORER,t)}}))}constructor(){super({pluginId:"grafana-pyroscope-datasource",key:"dataSource",name:"dataSource",label:"Data source",skipUrlSync:!0,value:ua.selectDefaultDataSource().uid}),this.addActivationHandler(this.onActivate.bind(this))}}function lR(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cR(e){for(var t=1;t{let t=e.operator.value;return e.operator.value===U_.in?t=U_["=~"]:e.operator.value===U_["not-in"]&&(t=U_["!~"]),{key:e.attribute.value,operator:t,value:e.value.value}};function pR(e,t){let n;const r=e.filter((e=>e.key!==t||(n=e,!1)));return{found:n,filtersWithoutFound:r}}const hR=(e,t)=>[...e,t];function fR(e,t){const{found:n,filtersWithoutFound:r}=pR(e,t.key);if(!n)return hR(e,uR(cR({},t),{operator:"=~"}));if(["!~","!="].includes(n.operator))return hR(r,uR(cR({},t),{operator:"=~"}));const i=new Set(n.value.split("|"));return"=~"===n.operator?hR(r,uR(cR({},n),{value:Array.from(i.add(t.value)).join("|")})):n.value===t.value?e:hR(r,uR(cR({},t),{operator:"=~",value:Array.from(i.add(t.value)).join("|")}))}function mR(e,t){const{found:n,filtersWithoutFound:r}=pR(e,t.key);if(!n)return hR(e,uR(cR({},t),{operator:"!~"}));if(["=~","="].includes(n.operator))return hR(r,uR(cR({},t),{operator:"!~"}));const i=new Set(n.value.split("|"));return"!~"===n.operator?hR(r,uR(cR({},n),{value:Array.from(i.add(t.value)).join("|")})):n.value===t.value?e:hR(r,uR(cR({},t),{operator:"!~",value:Array.from(i.add(t.value)).join("|")}))}function gR(e,t){const{found:n,filtersWithoutFound:r}=pR(e,t.key);if(!n)return e;const i=n.value.split("|").filter((e=>e!==t.value));return i.length>0?hR(r,uR(cR({},n),{value:i.join("|")})):[...r]}const yR=e=>e.operator in U_;function bR(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class vR extends Hg{reset(){this.setState({filters:vR.DEFAULT_VALUE})}static resetAll(e){["filters","filtersBaseline","filtersComparison"].forEach((t=>{tm.findByKeyAndType(e,t,vR).reset()}))}onActivate(){const e=tm.findByKeyAndType(this,"dataSource",sR).subscribeToState((()=>{this.reset()}));return()=>{e.unsubscribe()}}constructor({key:e}){super({key:e,name:e,label:"Filters",filters:vR.DEFAULT_VALUE,expressionBuilder:e=>e.filter(yR).map((({key:e,operator:t,value:n})=>t===U_["is-empty"]?`${e}=""`:`${e}${t}"${n}"`)).join(",")}),bR(this,"onChangeQuery",((e,t)=>{Ts("g_pyroscope_app_filters_changed",{name:this.state.name,count:t.length,operators:(0,$c.uniq)(t.map((e=>e.operator.label)))}),this.setState({filters:t.map(dR)})})),this.addActivationHandler(this.onActivate.bind(this))}}function wR(e,t){var n;return null===(n=tm.lookupVariable(t,e))||void 0===n?void 0:n.getValue()}function SR(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}bR(vR,"DEFAULT_VALUE",[]),bR(vR,"Component",(({model:e})=>{const{key:t}=e.useState(),n=oR(e,t),{value:r}=tm.findByKeyAndType(e,"dataSource",sR).useState(),{from:i,to:a}=tm.getTimeRange(e).state.value;return $i().createElement(HP,{id:`query-builder-${t}`,autoExecute:!0,dataSourceUid:r,query:n,from:1e3*i.unix(),to:1e3*a.unix(),onChangeQuery:e.onChangeQuery})}));var ER=function(e){return e.TIMESERIES="time-series",e.BARGAUGE="bar-gauge",e.TABLE="table",e.HISTOGRAM="histogram",e}({});class xR extends bh{getUrlState(){return{panelType:this.state.panelType}}updateFromUrl(e){const t={};"string"==typeof e.panelType&&e.panelType!==this.state.panelType&&(t.panelType=Object.values(ER).includes(e.panelType)?e.panelType:xR.DEFAULT_PANEL_TYPE),this.setState(t)}reset(){this.setState({panelType:xR.DEFAULT_PANEL_TYPE})}constructor(){super({key:"panel-type-switcher",panelType:xR.DEFAULT_PANEL_TYPE}),SR(this,"_urlSync",new Xh(this,{keys:["panelType"]})),SR(this,"onChange",(e=>{Ts("g_pyroscope_app_panel_type_changed",{panelType:e}),this.setState({panelType:e})}))}}function OR(e){const t=a.config.theme2.visualization;return t.getColorByName(t.palette[e%8])}SR(xR,"OPTIONS",[{label:"Time series",value:"time-series",icon:"heart-rate"},{label:"Totals",value:"bar-gauge",icon:"align-left"},{label:"Maxima",value:"table",icon:"angle-double-up"},{label:"Histograms",value:"histogram",icon:"graph-bar"}]),SR(xR,"DEFAULT_PANEL_TYPE","time-series"),SR(xR,"Component",(({model:e})=>{const{panelType:t}=e.useState();return $i().createElement(o.RadioButtonGroup,{"aria-label":"Panel type switcher",options:xR.OPTIONS,value:t,onChange:e.onChange,fullWidth:!1})}));const _R=(e,t)=>{var n;return(null===(n=e.labels)||void 0===n?void 0:n[t])||"(no value)"},TR=(e,t)=>{var n,r,i;return null===(i=e.meta)||void 0===i||null===(r=i.stats)||void 0===r||null===(n=r.find((e=>e.displayName===t)))||void 0===n?void 0:n.value};function CR(e){const[,t=""]=e.match(/.+\{.*service_name="([^"]+)".*\}/)||[],[,n=""]=e.match(/([^{]+)\{.*}/)||[],r=e.substring(e.indexOf("{")),i=r.replace(/(\{|\})/,"").split(",").map((e=>{var t;return null===(t=e.match(/\W*([^=!~]+)(=|!=|=~|!~)"(.*)"/))||void 0===t?void 0:t[0]})).filter((e=>e&&!e.includes("service_name")));return{serviceId:t,profileMetricId:n,labelsSelector:r,labels:i}}function kR(e){return e.addActivationHandler((()=>{const{profileTypeId:t,labelSelector:n}=e.state.queries[0];if(!t)return void e.setState({queries:[{refId:"null"}],data:PR(e,"Missing profile type!")});if(!n)return void e.setState({queries:[{refId:"null"}],data:PR(e,"Missing label selector!")});if(!tm.interpolate(e,"$profileMetricId"))return void e.setState({queries:[{refId:"null"}],data:PR(e,"Missing profile type!")});CR(tm.interpolate(e,`$profileTypeId${n})`)).serviceId||e.setState({queries:[{refId:"null"}],data:PR(e,"Missing service name!")})})),e}function PR(e,t){const n=new Error(t);return Xi.error(n),{state:r.LoadingState.Error,errors:[n],series:[],timeRange:tm.getTimeRange(e).state.value}}function RR({serviceName:e,profileMetricId:t,groupBy:n,filters:r},i){const a=r?[...r]:[];a.unshift({key:"service_name",operator:"=",value:e||"$serviceName"});const o=a.map((({key:e,operator:t,value:n})=>`${e}${t}"${n}"`)).join(",");return kR(new cy({datasource:QP,queries:[{refId:`${t||"$profileMetricId"}-${o}-${(null==n?void 0:n.label)||"no-group-by"}`,queryType:"metrics",profileTypeId:t||"$profileMetricId",labelSelector:`{${o},$filters}`,groupBy:(null==n?void 0:n.label)?[n.label]:[],limit:i}]}))}const AR=()=>e=>e.pipe((0,qp.map)((e=>null==e?void 0:e.map(((e,t)=>(0,$c.merge)(e,{refId:`${e.refId}-${t}`})))))),DR=()=>e=>e.pipe((0,qp.map)((e=>{const t=null==e?void 0:e.length;return null==e?void 0:e.map((e=>{var n,r;let i=Number.NEGATIVE_INFINITY;const a=null===(r=e.fields)||void 0===r||null===(n=r.find((e=>"number"===e.type)))||void 0===n?void 0:n.values.reduce(((e,t)=>(t>i&&(i=t),e+t)),0);return(0,$c.merge)(e,{meta:{stats:[{displayName:"totalSeriesCount",value:t},{displayName:"allValuesSum",value:a},{displayName:"maxValue",value:i}]}})}))})));class jR extends bh{onActivate(e){const{body:t}=this.state,n=t.state.$data.subscribeToState((n=>{var i;if((null===(i=n.data)||void 0===i?void 0:i.state)!==r.LoadingState.Done)return;const{series:a}=n.data;(null==a?void 0:a.length)&&t.setState(this.getConfig(e,a)),this.publishEvent(new F_({series:a}),!0)}));return()=>{n.unsubscribe()}}getConfig(e,t){var n;let i=Number.NEGATIVE_INFINITY;for(const e of t){const t=TR(e,"allValuesSum")||0;t>i&&(i=t)}const a=null===(n=e.queryRunnerParams.groupBy)||void 0===n?void 0:n.label,o=a?"This panel displays aggregate values over the current time period":void 0;return{title:t.length>1?`${e.label} (${t.length})`:e.label,description:o,options:{reduceOptions:{values:!1,calcs:["sum"]},orientation:r.VizOrientation.Horizontal,displayMode:Fh.Gradient,valueMode:$h.Text,showUnfilled:!0,sizing:Vh.Manual,text:{titleSize:13,valueSize:13},namePlacement:Bh.Top,minVizHeight:36,maxVizHeight:36,legend:{showLegend:!1}},fieldConfig:{defaults:{displayName:1===t.length?a:void 0,min:0,max:i,thresholds:{mode:r.ThresholdsMode.Percentage,steps:[]}},overrides:this.getOverrides(e,t)}}}getOverrides(e,t){var n;const{index:i,queryRunnerParams:a}=e,o=null===(n=a.groupBy)||void 0===n?void 0:n.label;return t.map(((e,t)=>({matcher:{id:r.FieldMatcherID.byFrameRefID,options:e.refId},properties:[{id:"displayName",value:_R(e.fields[1],o)},{id:"color",value:{mode:"fixed",fixedColor:OR(i+t)}}]})))}static Component({model:e}){const{body:t}=e.useState();return $i().createElement(t.Component,{model:t})}constructor({item:e,headerActions:t}){super({key:"bar-gauge-label-values",body:N_.bargauge().setTitle(e.label).setData(new Dw({$data:RR(e.queryRunnerParams),transformations:[AR,DR]})).setHeaderActions(t(e)).build()}),this.addActivationHandler(this.onActivate.bind(this,e))}}function IR(e,t){const n=t.fields[1].config.unit,i=TR(t,"allValuesSum")||0,a=(0,r.getValueFormat)(n)(i),o=TR(t,"maxValue")||0,s=(0,r.getValueFormat)(n)(o);return`total ${e} = ${a.text}${a.suffix} / max = ${s.text}${s.suffix}`}class NR extends bh{onActivate(e){const{body:t}=this.state,n=t.state.$data.subscribeToState((n=>{var i;if((null===(i=n.data)||void 0===i?void 0:i.state)!==r.LoadingState.Done)return;const{series:a}=n.data;(null==a?void 0:a.length)&&t.setState(this.getConfig(e,a)),this.publishEvent(new F_({series:a}),!0)}));return()=>{n.unsubscribe()}}getConfig(e,t){var n;const{legendPlacement:r}=this.state,i=null===(n=e.queryRunnerParams.groupBy)||void 0===n?void 0:n.label;return{title:t.length>1?`${e.label} (${t.length})`:e.label,options:{tooltip:{mode:o.TooltipDisplayMode.Single,sort:Mh.None},legend:{showLegend:!0,displayMode:o.LegendDisplayMode.List,placement:r,calcs:[]}},fieldConfig:{defaults:{displayName:1===t.length?i:void 0,custom:{lineWidth:1}},overrides:this.getOverrides(e,t)}}}getOverrides(e,t){var n;const{index:i,queryRunnerParams:a}=e,o=null===(n=a.groupBy)||void 0===n?void 0:n.label;return t.map(((e,n)=>{const a=e.fields[1];let s=o?_R(a,o):a.name;return 1===t.length&&(s=IR(s,e)),{matcher:{id:r.FieldMatcherID.byFrameRefID,options:e.refId},properties:[{id:"displayName",value:s},{id:"color",value:{mode:"fixed",fixedColor:OR(i+n)}}]}}))}static Component({model:e}){const{body:t}=e.useState();return $i().createElement(t.Component,{model:t})}constructor({item:e,headerActions:t,legendPlacement:n}){super({key:"histogram-label-values",legendPlacement:n||"bottom",body:N_.histogram().setTitle(e.label).setData(new Dw({$data:RR(e.queryRunnerParams),transformations:[AR,DR]})).setHeaderActions(t(e)).build()}),this.addActivationHandler(this.onActivate.bind(this,e))}}class LR extends bh{onActivate(e){const{body:t}=this.state,n=t.state.$data.subscribeToState((n=>{var i;if((null===(i=n.data)||void 0===i?void 0:i.state)!==r.LoadingState.Done)return;const{series:a}=n.data;(null==a?void 0:a.length)&&t.setState(this.getConfig(e,a)),this.publishEvent(new F_({series:a}),!0)}));return()=>{n.unsubscribe()}}getConfig(e,t){const n=t[0].fields[0].values.length,r=WP(tm.findByKeyAndType(this,"profileMetricId",eR).state.value).unit;return{title:n>1?`${e.label} (${n})`:e.label,fieldConfig:{defaults:{custom:{filterable:!0,cellOptions:{}}},overrides:[{matcher:{id:"byName",options:"max"},properties:[{id:"unit",value:r},{id:"custom.width",value:100}]}]}}}static Component({model:e}){const t=(0,o.useStyles2)(MR),{body:n}=e.useState();return $i().createElement("span",{className:t.container},$i().createElement(n.Component,{model:n}))}constructor({item:e,headerActions:t}){super({key:"table-label-values",body:N_.table().setTitle(e.label).setData(new Dw({$data:RR(e.queryRunnerParams),transformations:[{id:r.DataTransformerID.reduce,options:{reducers:["max"],labelsToFields:!0}},{id:r.DataTransformerID.filterFieldsByName,options:{exclude:{names:["Field"]}}},{id:r.DataTransformerID.renameByRegex,options:{regex:"Max",renamePattern:"max"}},{id:r.DataTransformerID.sortBy,options:{sort:[{field:"max",desc:!0}]}}]})).setHeaderActions(t(e)).build()}),this.addActivationHandler(this.onActivate.bind(this,e))}}const MR=()=>({container:i.css` [data-testid='data-testid table body'] [role='row']:first-child { color: ${OR(3)}; font-weight: 500; } `});class FR{value;next;constructor(e){this.value=e}}class $R{#G;#W;#Q;constructor(){this.clear()}enqueue(e){const t=new FR(e);this.#G?(this.#W.next=t,this.#W=t):(this.#G=t,this.#W=t),this.#Q++}dequeue(){const e=this.#G;if(e)return this.#G=this.#G.next,this.#Q--,e.value}peek(){if(this.#G)return this.#G.value}clear(){this.#G=void 0,this.#W=void 0,this.#Q=0}get size(){return this.#Q}*[Symbol.iterator](){let e=this.#G;for(;e;)yield e.value,e=e.next}}function BR(e){if(!Number.isInteger(e)&&e!==Number.POSITIVE_INFINITY||!(e>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up")}function VR(e){return{from:1e4*Math.floor((e.from.valueOf()||0)/1e4),to:1e4*Math.floor((e.to.valueOf()||0)/1e4)}}function zR(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function UR(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){zR(a,r,i,o,s,"next",e)}function s(e){zR(a,r,i,o,s,"throw",e)}o(void 0)}))}}function qR(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function HR(e){for(var t=1;t{n0&&(t.dequeue()(),n++)},i=async(e,t,i)=>{const a=(async()=>e(...i))();t(a);try{await a}catch{}n--,r()},a=(a,...o)=>new Promise((s=>{((a,o,s)=>{new Promise((e=>{t.enqueue(e)})).then(i.bind(void 0,a,o,s)),(async()=>{await Promise.resolve(),nn},pendingCount:{get:()=>t.size},clearQueue:{value(){t.clear()}},concurrency:{get:()=>e,set(i){BR(i),e=i,queueMicrotask((()=>{for(;n0;)r()}))}}}),a}(20);class QR extends Ph{query(){return UR((function*(){return{state:r.LoadingState.Done,data:[{name:"Labels",fields:[{name:"Label",type:r.FieldType.other,values:[],config:{}}],length:0}]}}))()}getParams(e){var t;const{scopedVars:n,range:r}=e,i=null==n||null===(t=n.__sceneObject)||void 0===t?void 0:t.value,a=tm.interpolate(i,"$dataSource"),o=tm.interpolate(i,"$serviceName"),s=tm.interpolate(i,"$profileMetricId"),l=`${s}{service_name="${o}"}`,{from:c,to:u}=VR(r);return{dataSourceUid:a,serviceName:o,profileMetricId:s,query:l,from:c,to:u}}fetchLabels(e,t,n,r,i){return UR((function*(){ck.setApiClient(new XC({dataSourceUid:e}));try{return yield ck.listLabels({query:t,from:n,to:r})}catch(e){throw Xi.error(e,{info:"Error while loading Pyroscope label names!",variableName:i||""}),e}}))()}fetchLabelValues(e,t,n,r,i,a){return UR((function*(){let e;try{e=yield ck.listLabelValues({query:t,from:n,to:r,label:i})}catch(e){Xi.error(e,{info:"Error while loading Pyroscope label values!",variableName:a||""})}const o=e?e.length:-1;return{value:{value:i,groupBy:{label:i,values:e||[]}},text:`${i} (${o>-1?o:"?"})`,count:o}}))()}metricFindQuery(e,t){var n=this;return UR((function*(){var e,r,i;if(!(null===(r=t.scopedVars)||void 0===r||null===(e=r.__sceneObject)||void 0===e?void 0:e.value).isActive)return[];const{dataSourceUid:a,serviceName:o,profileMetricId:s,query:l,from:c,to:u}=n.getParams(t);if(!o||!s)return Xi.warn('LabelsDataSource: either serviceName="%s" and/or profileMetricId="%s" is empty! Discarding request.',o,s),[];const d=yield n.fetchLabels(a,l,c,u,null===(i=t.variable)||void 0===i?void 0:i.name),p=yield Promise.all(d.filter((({value:e})=>!Fk(e))).map((({value:e},r)=>WR((()=>{var i;return n.fetchLabelValues(r,l,c,u,e,null===(i=t.variable)||void 0===i?void 0:i.name)}))))),h=p.sort(((e,t)=>t.count-e.count)).map((({value:e,text:t},n)=>({value:JSON.stringify(GR(HR({},e),{index:n})),text:t})));return[{value:"all",text:"All"},...h]}))()}testDatasource(){return UR((function*(){return{status:"success",message:"OK"}}))()}constructor(){super(XP.type,XP.uid)}}qR(QR,"MAX_TIMESERIES_LABEL_VALUES",10);const KR=__webpack_require__.p+"e6c722427cfa8715e19d.svg";function YR(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function XR(e){for(var t=1;t({text:`${n===e.scaleDistribution.type?"✔ ":""}${e.text}`,onClick:()=>this.onClickScaleOption(e)})))},{type:"divider",text:""},{iconClassName:"compass",text:"Open in Explore",onClick:()=>this.onClickExplore()}];if(e)r.push({iconClassName:"plus-square",text:"Add to investigation (beta)",onClick:()=>{e.onClick()}});else{const e=null==t?void 0:t.find((e=>e.text.includes("Add to investigation")));e&&r.push(tA({},e))}return r}onClickScaleOption(e){const{scaleDistribution:t,text:n}=e;(0,a.reportInteraction)("g_pyroscope_app_timeseries_scale_changed",{scale:t.type});tm.getAncestor(this,aA).changeScale(t,n),this.setState({scaleType:t.type,items:this.buildMenuItems()})}onClickExplore(){(0,a.reportInteraction)("g_pyroscope_app_open_in_explore_clicked");const e=function(e,t,n){const i=JSON.stringify({"pyroscope-explore":{range:(0,r.toURLRange)(e),queries:[JR(XR({},t),{datasource:n})],panelsState:{},datasource:n}});var o;const s=null!==(o=a.config.appSubUrl)&&void 0!==o?o:"";return r.urlUtil.renderUrl(`${s}/explore`,{panes:i,schemaVersion:1})}(tm.getTimeRange(this).state.value.raw,this.getInterpolatedQuery(),tm.interpolate(this,"${dataSource}"));window.open(e,"_blank")}getInterpolatedQuery(){var e;const t=null===(e=tm.getAncestor(this,aA).state.body.state.$data)||void 0===e?void 0:e.state.$data,n=null==t?void 0:t.state.queries[0];return Object.entries(n).map((([e,t])=>[e,"string"==typeof t?tm.interpolate(this,t):t])).reduce(((e,[t,n])=>nA(tA({},e),{[t]:n})),{})}useGetInvestigationPluginLinkContext(){const{refId:e,queryType:t,profileTypeId:n,labelSelector:r,groupBy:i}=this.getInterpolatedQuery(),a=CR(`${n}${r}`),o=[a.serviceId,ZR(a.profileMetricId)];(null==i?void 0:i.length)&&o.push(i[0]),a.labels.length&&o.push(a.labels.join(", "));const s=o.join(" · "),l=tm.interpolate(this,"${dataSource}"),c=tm.getTimeRange(this).state.value;return(0,Fi.useMemo)((()=>({id:GC(),origin:"Grafana Profiles Drilldown",url:window.location.href,logoPath:KR,title:s,type:"timeseries",timeRange:tA({},c),queries:[{refId:e,queryType:t,profileTypeId:n,labelSelector:r,groupBy:i}],datasource:l})),[l,i,r,n,t,e,c,s])}useUpdateMenuItems(){const e=function({extensionPointId:e,context:t,pluginId:n}){const r=(0,a.usePluginLinks)({extensionPointId:e,context:t}),[i]=r.links.filter((e=>e.pluginId===n));return i}({extensionPointId:"grafana-pyroscope-app/investigation/v1",context:this.useGetInvestigationPluginLinkContext(),pluginId:"grafana-investigations-app"});(0,Fi.useEffect)((()=>{e&&this.setState({items:this.buildMenuItems(e)})}),[e])}static Component({model:e}){return e.useUpdateMenuItems(),$i().createElement(YS.Component,{model:e})}constructor(e){super(tA({scaleType:Nh.Linear},e)),this.addActivationHandler(this.onActivate.bind(this))}}class aA extends bh{onActivate(){const{body:e}=this.state,t=e.state.$data.subscribeToState(((t,n)=>{var i,a,o,s;if((null===(i=t.data)||void 0===i?void 0:i.state)!==r.LoadingState.Done)return;!(null===(a=t.data.annotations)||void 0===a?void 0:a.length)&&(null===(s=n.data)||void 0===s||null===(o=s.annotations)||void 0===o?void 0:o.length)&&(t.data.annotations=n.data.annotations);const{series:l}=t.data;if(null==l?void 0:l.length){const t=this.state.displayAllValues?this.getAllValuesConfig(l):this.getConfig(l);e.setState((0,$c.merge)({},e.state,t))}this.publishEvent(new F_({series:l}),!0)}));return()=>{t.unsubscribe()}}getConfig(e){var t;const{body:n,item:r,legendPlacement:i}=this.state;let a,{title:o}=n.state;return(null===(t=r.queryRunnerParams.groupBy)||void 0===t?void 0:t.label)&&(o=e.length>1?`${r.label} (${e.length})`:r.label,a=this.buildDescription(r.queryRunnerParams.groupBy)),{title:o,description:a,options:{tooltip:{mode:"single",sort:"none"},legend:{showLegend:!0,displayMode:"list",placement:i}},fieldConfig:{defaults:{min:0,custom:{fillOpacity:e.length>=QR.MAX_TIMESERIES_LABEL_VALUES?0:9,gradientMode:1===e.length?Lh.None:Lh.Opacity,pointSize:3}},overrides:this.getOverrides(e)}}}buildDescription(e){return e?e.values?e.values.length>QR.MAX_TIMESERIES_LABEL_VALUES?`Showing only ${QR.MAX_TIMESERIES_LABEL_VALUES} out of ~${e.values.length} series to preserve readability. To view all the series for the current filters, click on the expand icon on this panel.`:"":`Showing only ${QR.MAX_TIMESERIES_LABEL_VALUES} series to preserve readability. To view all the series, click on the expand icon on this panel.`:""}getAllValuesConfig(e){const{legendPlacement:t}=this.state;return{options:{tooltip:{mode:o.TooltipDisplayMode.Single,sort:Mh.None},legend:{showLegend:!0,displayMode:o.LegendDisplayMode.List,placement:t,calcs:[]}},fieldConfig:{defaults:{min:0,custom:{fillOpacity:0,pointSize:5}},overrides:this.getOverrides(e)}}}getOverrides(e){var t;if(this.state.overrides)return this.state.overrides(e);const{item:n}=this.state,i=null===(t=n.queryRunnerParams.groupBy)||void 0===t?void 0:t.label;return e.map(((t,a)=>{const o=t.fields[1];let s=i?_R(o,i):o.name;return 1===e.length&&(s=IR(s,t)),{matcher:{id:r.FieldMatcherID.byFrameRefID,options:t.refId},properties:[{id:"displayName",value:s},{id:"color",value:{mode:"fixed",fixedColor:OR(n.index+a)}}]}}))}updateItem(e){var t,n;const{item:r,headerActions:i,body:a}=this.state,o=(0,$c.merge)({},r,e);if((null===(t=e.queryRunnerParams)||void 0===t?void 0:t.hasOwnProperty("groupBy"))&&(void 0===e.queryRunnerParams.groupBy?delete o.queryRunnerParams.groupBy:o.queryRunnerParams.groupBy=e.queryRunnerParams.groupBy),(null===(n=e.queryRunnerParams)||void 0===n?void 0:n.hasOwnProperty("filters"))&&void 0===e.queryRunnerParams.filters&&delete o.queryRunnerParams.filters,this.setState({item:o}),a.setState({title:e.label,description:this.buildDescription(o.queryRunnerParams.groupBy),headerActions:i(o)}),!(0,$c.isEqual)(r.queryRunnerParams,o.queryRunnerParams)){var s;const{queries:e}=RR(o.queryRunnerParams,QR.MAX_TIMESERIES_LABEL_VALUES).state,t=null===(s=a.state.$data)||void 0===s?void 0:s.state.$data;null==t||t.setState({queries:e}),null==t||t.runQueries()}}changeScale(e,t){const{body:n}=this.state;n.clearFieldConfigCache(),n.setState({fieldConfig:(0,$c.merge)({},n.state.fieldConfig,{defaults:{custom:{scaleDistribution:e,axisLabel:e.type!==Nh.Linear?t:""}}})})}static Component({model:e}){const{body:t}=e.useState();return $i().createElement(t.Component,{model:t})}constructor({item:e,headerActions:t,displayAllValues:n,legendPlacement:r,data:i,overrides:a}){super({key:"timeseries-label-values",item:e,headerActions:t,displayAllValues:Boolean(n),legendPlacement:r||"bottom",overrides:a,body:N_.timeseries().setTitle(e.label).setData(i||new Dw({$data:RR(e.queryRunnerParams,n?void 0:QR.MAX_TIMESERIES_LABEL_VALUES),transformations:[AR,DR]})).setHeaderActions(t(e)).setMenu(new iA({})).build()}),this.addActivationHandler(this.onActivate.bind(this))}}function oA(e,t){switch(e){case ER.BARGAUGE:return new jR(t);case ER.TABLE:return new LR(t);case ER.HISTOGRAM:return new NR(t);case ER.TIMESERIES:default:return new aA(t)}}var sA=e=>"string"!=typeof e?{}:e.split(/ ?; ?/).reduce(((e,t)=>{const[n,r]=t.split(/ ?: ?/).map(((e,t)=>0===t?e.replace(/\s+/g,""):e.trim()));if(n&&r){const t=n.replace(/(\w)-(\w)/g,((e,t,n)=>`${t}${n.toUpperCase()}`));let i=r.trim();Number.isNaN(Number(r))||(i=Number(r)),e[n.startsWith("-")?n:t]=i}return e}),{});var lA=["br","col","colgroup","dl","hr","iframe","img","input","link","menuitem","meta","ol","param","select","table","tbody","tfoot","thead","tr","ul","wbr"],cA={"accept-charset":"acceptCharset",acceptcharset:"acceptCharset",accesskey:"accessKey",allowfullscreen:"allowFullScreen",autocapitalize:"autoCapitalize",autocomplete:"autoComplete",autocorrect:"autoCorrect",autofocus:"autoFocus",autoplay:"autoPlay",autosave:"autoSave",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",classid:"classID",classname:"className",colspan:"colSpan",contenteditable:"contentEditable",contextmenu:"contextMenu",controlslist:"controlsList",crossorigin:"crossOrigin",dangerouslysetinnerhtml:"dangerouslySetInnerHTML",datetime:"dateTime",defaultchecked:"defaultChecked",defaultvalue:"defaultValue",enctype:"encType",for:"htmlFor",formmethod:"formMethod",formaction:"formAction",formenctype:"formEncType",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",htmlfor:"htmlFor",httpequiv:"httpEquiv","http-equiv":"httpEquiv",icon:"icon",innerhtml:"innerHTML",inputmode:"inputMode",itemid:"itemID",itemprop:"itemProp",itemref:"itemRef",itemscope:"itemScope",itemtype:"itemType",keyparams:"keyParams",keytype:"keyType",marginwidth:"marginWidth",marginheight:"marginHeight",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",nomodule:"noModule",novalidate:"noValidate",playsinline:"playsInline",radiogroup:"radioGroup",readonly:"readOnly",referrerpolicy:"referrerPolicy",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",typemustmatch:"typeMustMatch",usemap:"useMap",accentheight:"accentHeight","accent-height":"accentHeight",alignmentbaseline:"alignmentBaseline","alignment-baseline":"alignmentBaseline",allowreorder:"allowReorder",arabicform:"arabicForm","arabic-form":"arabicForm",attributename:"attributeName",attributetype:"attributeType",autoreverse:"autoReverse",basefrequency:"baseFrequency",baselineshift:"baselineShift","baseline-shift":"baselineShift",baseprofile:"baseProfile",calcmode:"calcMode",capheight:"capHeight","cap-height":"capHeight",clippath:"clipPath","clip-path":"clipPath",clippathunits:"clipPathUnits",cliprule:"clipRule","clip-rule":"clipRule",colorinterpolation:"colorInterpolation","color-interpolation":"colorInterpolation",colorinterpolationfilters:"colorInterpolationFilters","color-interpolation-filters":"colorInterpolationFilters",colorprofile:"colorProfile","color-profile":"colorProfile",colorrendering:"colorRendering","color-rendering":"colorRendering",contentscripttype:"contentScriptType",contentstyletype:"contentStyleType",diffuseconstant:"diffuseConstant",dominantbaseline:"dominantBaseline","dominant-baseline":"dominantBaseline",edgemode:"edgeMode",enablebackground:"enableBackground","enable-background":"enableBackground",externalresourcesrequired:"externalResourcesRequired",fillopacity:"fillOpacity","fill-opacity":"fillOpacity",fillrule:"fillRule","fill-rule":"fillRule",filterres:"filterRes",filterunits:"filterUnits",floodopacity:"floodOpacity","flood-opacity":"floodOpacity",floodcolor:"floodColor","flood-color":"floodColor",fontfamily:"fontFamily","font-family":"fontFamily",fontsize:"fontSize","font-size":"fontSize",fontsizeadjust:"fontSizeAdjust","font-size-adjust":"fontSizeAdjust",fontstretch:"fontStretch","font-stretch":"fontStretch",fontstyle:"fontStyle","font-style":"fontStyle",fontvariant:"fontVariant","font-variant":"fontVariant",fontweight:"fontWeight","font-weight":"fontWeight",glyphname:"glyphName","glyph-name":"glyphName",glyphorientationhorizontal:"glyphOrientationHorizontal","glyph-orientation-horizontal":"glyphOrientationHorizontal",glyphorientationvertical:"glyphOrientationVertical","glyph-orientation-vertical":"glyphOrientationVertical",glyphref:"glyphRef",gradienttransform:"gradientTransform",gradientunits:"gradientUnits",horizadvx:"horizAdvX","horiz-adv-x":"horizAdvX",horizoriginx:"horizOriginX","horiz-origin-x":"horizOriginX",imagerendering:"imageRendering","image-rendering":"imageRendering",kernelmatrix:"kernelMatrix",kernelunitlength:"kernelUnitLength",keypoints:"keyPoints",keysplines:"keySplines",keytimes:"keyTimes",lengthadjust:"lengthAdjust",letterspacing:"letterSpacing","letter-spacing":"letterSpacing",lightingcolor:"lightingColor","lighting-color":"lightingColor",limitingconeangle:"limitingConeAngle",markerend:"markerEnd","marker-end":"markerEnd",markerheight:"markerHeight",markermid:"markerMid","marker-mid":"markerMid",markerstart:"markerStart","marker-start":"markerStart",markerunits:"markerUnits",markerwidth:"markerWidth",maskcontentunits:"maskContentUnits",maskunits:"maskUnits",numoctaves:"numOctaves",overlineposition:"overlinePosition","overline-position":"overlinePosition",overlinethickness:"overlineThickness","overline-thickness":"overlineThickness",paintorder:"paintOrder","paint-order":"paintOrder","panose-1":"panose1",pathlength:"pathLength",patterncontentunits:"patternContentUnits",patterntransform:"patternTransform",patternunits:"patternUnits",pointerevents:"pointerEvents","pointer-events":"pointerEvents",pointsatx:"pointsAtX",pointsaty:"pointsAtY",pointsatz:"pointsAtZ",preservealpha:"preserveAlpha",preserveaspectratio:"preserveAspectRatio",primitiveunits:"primitiveUnits",refx:"refX",refy:"refY",renderingintent:"renderingIntent","rendering-intent":"renderingIntent",repeatcount:"repeatCount",repeatdur:"repeatDur",requiredextensions:"requiredExtensions",requiredfeatures:"requiredFeatures",shaperendering:"shapeRendering","shape-rendering":"shapeRendering",specularconstant:"specularConstant",specularexponent:"specularExponent",spreadmethod:"spreadMethod",startoffset:"startOffset",stddeviation:"stdDeviation",stitchtiles:"stitchTiles",stopcolor:"stopColor","stop-color":"stopColor",stopopacity:"stopOpacity","stop-opacity":"stopOpacity",strikethroughposition:"strikethroughPosition","strikethrough-position":"strikethroughPosition",strikethroughthickness:"strikethroughThickness","strikethrough-thickness":"strikethroughThickness",strokedasharray:"strokeDasharray","stroke-dasharray":"strokeDasharray",strokedashoffset:"strokeDashoffset","stroke-dashoffset":"strokeDashoffset",strokelinecap:"strokeLinecap","stroke-linecap":"strokeLinecap",strokelinejoin:"strokeLinejoin","stroke-linejoin":"strokeLinejoin",strokemiterlimit:"strokeMiterlimit","stroke-miterlimit":"strokeMiterlimit",strokewidth:"strokeWidth","stroke-width":"strokeWidth",strokeopacity:"strokeOpacity","stroke-opacity":"strokeOpacity",suppresscontenteditablewarning:"suppressContentEditableWarning",suppresshydrationwarning:"suppressHydrationWarning",surfacescale:"surfaceScale",systemlanguage:"systemLanguage",tablevalues:"tableValues",targetx:"targetX",targety:"targetY",textanchor:"textAnchor","text-anchor":"textAnchor",textdecoration:"textDecoration","text-decoration":"textDecoration",textlength:"textLength",textrendering:"textRendering","text-rendering":"textRendering",underlineposition:"underlinePosition","underline-position":"underlinePosition",underlinethickness:"underlineThickness","underline-thickness":"underlineThickness",unicodebidi:"unicodeBidi","unicode-bidi":"unicodeBidi",unicoderange:"unicodeRange","unicode-range":"unicodeRange",unitsperem:"unitsPerEm","units-per-em":"unitsPerEm",unselectable:"unselectable",valphabetic:"vAlphabetic","v-alphabetic":"vAlphabetic",vectoreffect:"vectorEffect","vector-effect":"vectorEffect",vertadvy:"vertAdvY","vert-adv-y":"vertAdvY",vertoriginx:"vertOriginX","vert-origin-x":"vertOriginX",vertoriginy:"vertOriginY","vert-origin-y":"vertOriginY",vhanging:"vHanging","v-hanging":"vHanging",videographic:"vIdeographic","v-ideographic":"vIdeographic",viewbox:"viewBox",viewtarget:"viewTarget",vmathematical:"vMathematical","v-mathematical":"vMathematical",wordspacing:"wordSpacing","word-spacing":"wordSpacing",writingmode:"writingMode","writing-mode":"writingMode",xchannelselector:"xChannelSelector",xheight:"xHeight","x-height":"xHeight",xlinkactuate:"xlinkActuate","xlink:actuate":"xlinkActuate",xlinkarcrole:"xlinkArcrole","xlink:arcrole":"xlinkArcrole",xlinkhref:"xlinkHref","xlink:href":"xlinkHref",xlinkrole:"xlinkRole","xlink:role":"xlinkRole",xlinkshow:"xlinkShow","xlink:show":"xlinkShow",xlinktitle:"xlinkTitle","xlink:title":"xlinkTitle",xlinktype:"xlinkType","xlink:type":"xlinkType",xmlbase:"xmlBase","xml:base":"xmlBase",xmllang:"xmlLang","xml:lang":"xmlLang","xml:space":"xmlSpace",xmlnsxlink:"xmlnsXlink","xmlns:xlink":"xmlnsXlink",xmlspace:"xmlSpace",ychannelselector:"yChannelSelector",zoomandpan:"zoomAndPan",onblur:"onBlur",onchange:"onChange",onclick:"onClick",oncontextmenu:"onContextMenu",ondoubleclick:"onDoubleClick",ondrag:"onDrag",ondragend:"onDragEnd",ondragenter:"onDragEnter",ondragexit:"onDragExit",ondragleave:"onDragLeave",ondragover:"onDragOver",ondragstart:"onDragStart",ondrop:"onDrop",onerror:"onError",onfocus:"onFocus",oninput:"onInput",oninvalid:"onInvalid",onkeydown:"onKeyDown",onkeypress:"onKeyPress",onkeyup:"onKeyUp",onload:"onLoad",onmousedown:"onMouseDown",onmouseenter:"onMouseEnter",onmouseleave:"onMouseLeave",onmousemove:"onMouseMove",onmouseout:"onMouseOut",onmouseover:"onMouseOver",onmouseup:"onMouseUp",onscroll:"onScroll",onsubmit:"onSubmit",ontouchcancel:"onTouchCancel",ontouchend:"onTouchEnd",ontouchmove:"onTouchMove",ontouchstart:"onTouchStart",onwheel:"onWheel"};function uA(e,t){const{key:n,level:r,...i}=t;switch(e.nodeType){case 1:return Fi.createElement(function(e){if(/[a-z]+[A-Z]+[a-z]+/.test(e))return e;return e.toLowerCase()}(e.nodeName),function(e,t){const n={key:t};if(e instanceof Element){const t=e.getAttribute("class");t&&(n.className=t),[...e.attributes].forEach((e=>{switch(e.name){case"class":break;case"style":n[e.name]=sA(e.value);break;case"allowfullscreen":case"allowpaymentrequest":case"async":case"autofocus":case"autoplay":case"checked":case"controls":case"default":case"defer":case"disabled":case"formnovalidate":case"hidden":case"ismap":case"itemscope":case"loop":case"multiple":case"muted":case"nomodule":case"novalidate":case"open":case"readonly":case"required":case"reversed":case"selected":case"typemustmatch":n[cA[e.name]||e.name]=!0;break;default:n[cA[e.name]||e.name]=e.value}}))}return n}(e,n),dA(e.childNodes,r,i));case 3:{const t=e.nodeValue?.toString()??"";if(!i.allowWhiteSpaces&&/^\s+$/.test(t)&&!/[\u00A0\u202F]/.test(t))return null;if(!e.parentNode)return t;const n=e.parentNode.nodeName.toLowerCase();return lA.includes(n)?(/\S/.test(t)&&console.warn(`A textNode is not allowed inside '${n}'. Your text "${t}" will be ignored`),null):t}case 8:default:return null;case 11:return dA(e.childNodes,r,t)}}function dA(e,t,n){const r=[...e].map(((e,r)=>pA(e,{...n,index:r,level:t+1}))).filter(Boolean);return r.length?r:null}function pA(e,t={}){if(!(e&&e instanceof Node))return null;const{actions:n=[],index:r=0,level:i=0,randomKey:a}=t;let o=e,s=`${i}-${r}`;const l=[];return a&&0===i&&(s=`${function(e=6){const t="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";let n="";for(let r=e;r>0;--r)n+=t[Math.round(61*Math.random())];return n}()}-${s}`),Array.isArray(n)&&n.forEach((t=>{t.condition(o,s,i)&&("function"==typeof t.pre&&(o=t.pre(o,s,i),o instanceof Node||(o=e)),"function"==typeof t.post&&l.push(t.post(o,s,i)))})),l.length?l:uA(o,{key:s,level:i,...t})}function hA(e,t={}){return"string"==typeof e?function(e,t={}){if(!e||"string"!=typeof e)return null;const{includeAllNodes:n=!1,nodeOnly:r=!1,selector:i="body > *",type:a="text/html"}=t;try{const o=(new DOMParser).parseFromString(e,a);if(n){const{childNodes:e}=o.body;return r?e:[...e].map((e=>pA(e,t)))}const s=o.querySelector(i)||o.body.childNodes[0];if(!(s instanceof Node))throw new TypeError("Error parsing input");return r?s:pA(s,t)}catch(e){}return null}(e,t):e instanceof Node?pA(e,t):null}var fA=Object.defineProperty,mA=(e,t,n)=>(((e,t,n)=>{t in e?fA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n),gA="react-inlinesvg",yA={IDLE:"idle",LOADING:"loading",LOADED:"loaded",FAILED:"failed",READY:"ready",UNSUPPORTED:"unsupported"};function bA(){return!("undefined"==typeof window||!window.document||!window.document.createElement)}function vA(){return function(){if(!document)return!1;const e=document.createElement("div");e.innerHTML="";const t=e.firstChild;return!!t&&"http://www.w3.org/2000/svg"===t.namespaceURI}()&&"undefined"!=typeof window&&null!==window}async function wA(e,t){const n=await fetch(e,t),r=n.headers.get("content-type"),[i]=(r??"").split(/ ?; ?/);if(n.status>299)throw new Error("Not found");if(!["image/svg+xml","text/plain"].some((e=>i.includes(e))))throw new Error(`Content type isn't valid: ${i}`);return n.text()}function SA(e=1){return new Promise((t=>{setTimeout(t,1e3*e)}))}var EA,xA=class{constructor(){mA(this,"cacheApi"),mA(this,"cacheStore"),mA(this,"subscribers",[]),mA(this,"isReady",!1),this.cacheStore=new Map;let e=gA,t=!1;bA()&&(e=window.REACT_INLINESVG_CACHE_NAME??gA,t=!!window.REACT_INLINESVG_PERSISTENT_CACHE&&"caches"in window),t?caches.open(e).then((e=>{this.cacheApi=e,this.isReady=!0,this.subscribers.forEach((e=>e()))})).catch((e=>{this.isReady=!0,console.error(`Failed to open cache: ${e.message}`)})):this.isReady=!0}onReady(e){this.isReady?e():this.subscribers.push(e)}async get(e,t){return await(this.cacheApi?this.fetchAndAddToPersistentCache(e,t):this.fetchAndAddToInternalCache(e,t)),this.cacheStore.get(e)?.content??""}set(e,t){this.cacheStore.set(e,t)}isCached(e){return this.cacheStore.get(e)?.status===yA.LOADED}async fetchAndAddToInternalCache(e,t){const n=this.cacheStore.get(e);if(n?.status!==yA.LOADING){if(!n?.content){this.cacheStore.set(e,{content:"",status:yA.LOADING});try{const n=await wA(e,t);this.cacheStore.set(e,{content:n,status:yA.LOADED})}catch(t){throw this.cacheStore.set(e,{content:"",status:yA.FAILED}),t}}}else await this.handleLoading(e,(async()=>{this.cacheStore.set(e,{content:"",status:yA.IDLE}),await this.fetchAndAddToInternalCache(e,t)}))}async fetchAndAddToPersistentCache(e,t){const n=this.cacheStore.get(e);if(n?.status===yA.LOADED)return;if(n?.status===yA.LOADING)return void await this.handleLoading(e,(async()=>{this.cacheStore.set(e,{content:"",status:yA.IDLE}),await this.fetchAndAddToPersistentCache(e,t)}));this.cacheStore.set(e,{content:"",status:yA.LOADING});const r=await(this.cacheApi?.match(e));if(r){const t=await r.text();this.cacheStore.set(e,{content:t,status:yA.LOADED})}else try{await(this.cacheApi?.add(new Request(e,t)));const n=await(this.cacheApi?.match(e)),r=await(n?.text())??"";this.cacheStore.set(e,{content:r,status:yA.LOADED})}catch(t){throw this.cacheStore.set(e,{content:"",status:yA.FAILED}),t}}async handleLoading(e,t){let n=0;for(;this.cacheStore.get(e)?.status===yA.LOADING&&n<10;)await SA(.1),n+=1;n>=10&&await t()}keys(){return[...this.cacheStore.keys()]}data(){return[...this.cacheStore.entries()].map((([e,t])=>({[e]:t})))}async delete(e){this.cacheApi&&await this.cacheApi.delete(e),this.cacheStore.delete(e)}async clear(){if(this.cacheApi){const e=await this.cacheApi.keys();for(const t of e)await this.cacheApi.delete(t)}this.cacheStore.clear()}};function OA(e){const t=(0,Fi.useRef)();return(0,Fi.useEffect)((()=>{t.current=e})),t.current}function _A(e){const{baseURL:t,content:n,description:r,handleError:i,hash:a,preProcessor:o,title:s,uniquifyIDs:l=!1}=e;try{const e=function(e,t){if(t)return t(e);return e}(n,o),i=hA(e,{nodeOnly:!0});if(!(i&&i instanceof SVGSVGElement))throw new Error("Could not convert the src to a DOM Node");const c=TA(i,{baseURL:t,hash:a,uniquifyIDs:l});if(r){const e=c.querySelector("desc");e?.parentNode&&e.parentNode.removeChild(e);const t=document.createElementNS("http://www.w3.org/2000/svg","desc");t.innerHTML=r,c.prepend(t)}if(void 0!==s){const e=c.querySelector("title");if(e?.parentNode&&e.parentNode.removeChild(e),s){const e=document.createElementNS("http://www.w3.org/2000/svg","title");e.innerHTML=s,c.prepend(e)}}return c}catch(e){return i(e)}}function TA(e,t){const{baseURL:n="",hash:r,uniquifyIDs:i}=t,a=["id","href","xlink:href","xlink:role","xlink:arcrole"],o=["href","xlink:href"];return i?([...e.children].forEach((e=>{if(e.attributes?.length){const t=Object.values(e.attributes).map((e=>{const t=e,i=/url\((.*?)\)/.exec(e.value);return i?.[1]&&(t.value=e.value.replace(i[0],`url(${n}${i[1]}__${r})`)),t}));a.forEach((e=>{const n=t.find((t=>t.name===e));n&&!((e,t)=>o.includes(e)&&!!t&&!t.includes("#"))(e,n.value)&&(n.value=`${n.value}__${r}`)}))}return e.children.length?TA(e,t):e})),e):e}function CA(e){const{cacheRequests:t=!0,children:n=null,description:r,fetchOptions:i,innerRef:a,loader:o=null,onError:s,onLoad:l,src:c,title:u,uniqueHash:d}=e,[p,h]=(0,Fi.useReducer)(((e,t)=>({...e,...t})),{content:"",element:null,isCached:t&&EA.isCached(e.src),status:yA.IDLE}),{content:f,element:m,isCached:g,status:y}=p,b=OA(e),v=OA(p),w=(0,Fi.useRef)(d??function(e){const t="abcdefghijklmnopqrstuvwxyz",n=`${t}${t.toUpperCase()}1234567890`;let r="";for(let t=0;t{S.current&&(h({status:"Browser does not support SVG"===e.message?yA.UNSUPPORTED:yA.FAILED}),s?.(e))}),[s]),O=(0,Fi.useCallback)(((e,t=!1)=>{S.current&&h({content:e,isCached:t,status:yA.LOADED})}),[]),_=(0,Fi.useCallback)((async()=>{const e=await wA(c,i);O(e)}),[i,O,c]),T=(0,Fi.useCallback)((()=>{try{const t=hA(_A({...e,handleError:x,hash:w.current,content:f}));if(!t||!(0,Fi.isValidElement)(t))throw new Error("Could not convert the src to a React element");h({element:t,status:yA.READY})}catch(e){x(new Error(e.message))}}),[f,x,e]),C=(0,Fi.useCallback)((async()=>{const e=/^data:image\/svg[^,]*?(;base64)?,(.*)/u.exec(c);let n;if(e?n=e[1]?window.atob(e[2]):decodeURIComponent(e[2]):c.includes("{S.current&&h({content:"",element:null,isCached:!1,status:yA.LOADING})}),[]);(0,Fi.useEffect)((()=>{if(S.current=!0,!bA()||E.current)return()=>{};try{if(y===yA.IDLE){if(!vA())throw new Error("Browser does not support SVG");if(!c)throw new Error("Missing src");k()}}catch(e){x(e)}return E.current=!0,()=>{S.current=!1}}),[]),(0,Fi.useEffect)((()=>{if(bA()&&b)if(b.src!==c){if(!c)return void x(new Error("Missing src"));k()}else b.title===u&&b.description===r||T()}),[r,T,x,k,b,c,u]),(0,Fi.useEffect)((()=>{v&&(v.status!==yA.LOADING&&y===yA.LOADING&&C(),v.status!==yA.LOADED&&y===yA.LOADED&&T(),v.status!==yA.READY&&y===yA.READY&&l?.(c,g))}),[C,T,g,l,v,c,y]);const P=function(e,...t){const n={};for(const r in e)({}).hasOwnProperty.call(e,r)&&(t.includes(r)||(n[r]=e[r]));return n}(e,"baseURL","cacheRequests","children","description","fetchOptions","innerRef","loader","onError","onLoad","preProcessor","src","title","uniqueHash","uniquifyIDs");return bA()?m?(0,Fi.cloneElement)(m,{ref:a,...P}):[yA.UNSUPPORTED,yA.FAILED].includes(y)?n:o:o}function kA(e){EA||(EA=new xA);const{loader:t}=e,n=(0,Fi.useRef)(!1),[r,i]=(0,Fi.useState)(EA.isReady);return(0,Fi.useEffect)((()=>{n.current||(EA.onReady((()=>{i(!0)})),n.current=!0)}),[]),r?(0,Bi.jsx)(CA,{...e}):t}const PA=__webpack_require__.p+"944c737f589d02ecf603.svg",RA=__webpack_require__.p+"e79edcfbe2068fae2364.svg",AA=(e=50)=>{const[t,n]=(0,Fi.useState)({x:null,y:null});return(0,Fi.useEffect)((()=>{const t=(0,$c.throttle)((e=>{n({x:e.clientX,y:e.clientY})}),e);return window.addEventListener("mousemove",t),()=>{window.removeEventListener("mousemove",t)}}),[e]),t},DA=({width:e="auto",height:t,show404:n=!1})=>{const r=(0,o.useTheme2)(),{x:i,y:a}=AA(),s=(0,o.useStyles2)(jA,i,a,n);return $i().createElement(kA,{src:r.isDark?PA:RA,className:s.svg,height:t,width:e})};DA.displayName="GrotNotFound";const jA=(e,t,n,r)=>{const{innerWidth:a,innerHeight:o}=window,s=n&&n/o,l=t&&t/a,c=null!==s?IA(s,-20,5):0,u=null!==l?IA(l,-5,5):0;return{svg:(0,i.css)({"#grot-404-arm, #grot-404-magnifier":{transform:`rotate(${c}deg) translateX(${u}%)`,transformOrigin:"center",transition:"transform 50ms linear"},"#grot-404-text":{display:r?"block":"none"}})}},IA=(e,t,n)=>e*(n-t)+t,NA=({message:e})=>{const t=(0,o.useStyles2)(LA);return $i().createElement("div",{className:t.container},$i().createElement(o.Box,{paddingY:8},$i().createElement(o.Stack,{direction:"column",alignItems:"center",gap:3},$i().createElement(DA,{width:300}),$i().createElement(o.Text,{variant:"h5"},e))))};function LA(){return{container:(0,i.css)({width:"100%",display:"flex",justifyContent:"space-evenly",flexDirection:"column"})}}NA.displayName="EmptyState";class MA extends bh{}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(MA,"Component",(({model:e})=>{const{message:t}=e.useState();return $i().createElement(NA,{message:t})}));class FA extends bh{}function $A(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(FA,"Component",(({model:e})=>{const{message:t}=e.useState();return $i().createElement(o.Alert,{title:"Query error!",severity:"error"},t)}));var BA=function(e){return e.GRID="grid",e.ROWS="rows",e}({});class VA extends bh{getUrlState(){return{layout:this.state.layout}}updateFromUrl(e){const t={};"string"==typeof e.layout&&e.layout!==this.state.layout&&(t.layout=Object.values(BA).includes(e.layout)?e.layout:VA.DEFAULT_LAYOUT),this.setState(t)}constructor(){super({key:"layout-switcher",layout:VA.DEFAULT_LAYOUT}),$A(this,"_urlSync",new Xh(this,{keys:["layout"]})),$A(this,"onChange",(e=>{Ts("g_pyroscope_app_layout_changed",{layout:e}),this.setState({layout:e})}))}}function zA(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}$A(VA,"OPTIONS",[{label:"Grid",value:"grid"},{label:"Rows",value:"rows"}]),$A(VA,"DEFAULT_LAYOUT","grid"),$A(VA,"Component",(({model:e})=>{const{layout:t}=e.useState();return $i().createElement(o.RadioButtonGroup,{"aria-label":"Layout switcher",options:VA.OPTIONS,value:t,onChange:e.onChange,fullWidth:!1})}));class UA extends bh{getUrlState(){return{hideNoData:this.state.hideNoData}}updateFromUrl(e){const t={};"string"==typeof e.hideNoData&&e.hideNoData!==this.state.hideNoData&&(t.hideNoData=["on","off"].includes(e.hideNoData)?e.hideNoData:UA.DEFAULT_VALUE),this.setState(t)}constructor(){super({key:"no-data-switcher",hideNoData:UA.DEFAULT_VALUE}),zA(this,"_urlSync",new Xh(this,{keys:["hideNoData"]})),zA(this,"onChange",(e=>{Ts("g_pyroscope_app_hide_no_data_changed",{hideNoData:e}),this.setState({hideNoData:e})}))}}function qA(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}zA(UA,"DEFAULT_VALUE","off"),zA(UA,"Component",(({model:e})=>{const{hideNoData:t}=e.useState();return $i().createElement(o.InlineSwitch,{"data-testid":"noDataSwitcher",showLabel:!0,label:"Hide panels without data",value:"on"===t,onChange:t=>e.onChange(t.target.checked?"on":"off")})}));class HA extends bh{setPlaceholder(e){this.setState({placeholder:e})}setResultsCount(e){this.setState({resultsCount:String(e)})}getUrlState(){return{searchText:this.state.searchText}}updateFromUrl(e){const t={};"string"==typeof e.searchText&&e.searchText!==this.state.searchText&&(t.searchText=e.searchText),this.setState(t)}reset(){this.setState({placeholder:"",searchText:"",resultsCount:""})}constructor({placeholder:e}){super({key:"quick-filter",placeholder:e,searchText:HA.DEFAULT_SEARCH_TEXT,resultsCount:""}),qA(this,"_urlSync",new Xh(this,{keys:["searchText"]})),qA(this,"onChange",(e=>{this.setState({searchText:e.target.value})})),qA(this,"clearSearchText",(()=>{this.setState({searchText:""})})),qA(this,"onFocus",(()=>{Ts("g_pyroscope_app_quick_filter_focused")}))}}qA(HA,"DEFAULT_SEARCH_TEXT",""),qA(HA,"DEBOUNCE_DELAY",250),qA(HA,"Component",(({model:e})=>{const t=(0,o.useStyles2)(GA),{placeholder:n,searchText:r,resultsCount:i}=e.useState();return $i().createElement(o.Input,{type:"text",className:"quick-filter","aria-label":"Quick filter",placeholder:n,value:r,prefix:$i().createElement(o.Icon,{name:"search"}),suffix:$i().createElement($i().Fragment,null,""!==i&&$i().createElement(o.Tag,{className:t.resultsCount,name:i,colorIndex:9,"data-testid":"quick-filter-results-count"}),$i().createElement(o.IconButton,{name:"times","aria-label":"Clear search",onClick:e.clearSearchText})),onChange:e.onChange,onKeyDown:t=>{"Escape"===t.key&&e.clearSearchText()},onFocus:e.onFocus})}));const GA=e=>({resultsCount:i.css` margin-right: ${e.spacing(1)}; border-radius: 11px; padding: 2px 8px; color: ${e.colors.text.primary}; background-color: ${e.colors.background.secondary}; `});function WA(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function QA(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){WA(a,r,i,o,s,"next",e)}function s(e){WA(a,r,i,o,s,"throw",e)}o(void 0)}))}}function KA(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function YA(e){for(var t=1;tXA.areFavoritesEqual(t,e)))}static addFavorite(e){const t=ta.get(ta.KEYS.PROFILES_EXPLORER);t.favorites.push(e),ta.set(ta.KEYS.PROFILES_EXPLORER,t)}static removeFavorite(e){const t=ta.get(ta.KEYS.PROFILES_EXPLORER);t.favorites=t.favorites.filter((t=>!XA.areFavoritesEqual(t,e))),ta.set(ta.KEYS.PROFILES_EXPLORER,t)}query(){return QA((function*(){return{state:r.LoadingState.Done,data:[{name:"Favories",fields:[{name:null,type:r.FieldType.other,values:[],config:{}}],length:0}]}}))()}metricFindQuery(){return QA((function*(){return XA.getAllFavorites().map((e=>{const{serviceName:t,profileMetricId:n,groupBy:r,filters:i}=e.queryRunnerParams||{},a=[t,ZR(n)];return(null==r?void 0:r.label)&&a.push(r.label),(null==i?void 0:i.length)&&a.push(i.map((({key:e,operator:t,value:n})=>`${e}${t}"${n}"`)).join(", ")),{value:JSON.stringify(YA({value:JSON.stringify(e)},e)),text:a.join(" · ")}}))}))()}testDatasource(){return QA((function*(){return{status:"success",message:"OK"}}))()}constructor(){var e;super(YP.type,YP.uid);const t=ta.get(ta.KEYS.PROFILES_EXPLORER)||{};(e=t).favorites||(e.favorites=[]),t.favorites=t.favorites.map((e=>YA({panelType:ER.TIMESERIES},e))),ta.set(ta.KEYS.PROFILES_EXPLORER,t)}}function JA(e,t){const{queryRunnerParams:n}=t,r=(0,$c.defaults)((0,$c.clone)(n),{serviceName:wR(e,"serviceName"),profileMetricId:wR(e,"profileMetricId")}),i=tm.lookupVariable("filters",e).state.filters.map((({key:e,operator:t,value:n})=>({key:e,operator:t,value:n})));return r.filters=(0,$c.uniqBy)([...r.filters||[],...i],(({key:e,operator:t,value:n})=>`${e}${t}${n}`)),r}function ZA(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class eD extends bh{update(){this.setState({isFav:this.isStored()})}isStored(){return XA.exists(this.buildFavorite())}static buildFavorite(e){var t;const{index:n,queryRunnerParams:r,panelType:i}=e,a={index:n,queryRunnerParams:{serviceName:r.serviceName,profileMetricId:r.profileMetricId},panelType:i};return r.groupBy&&(a.queryRunnerParams.groupBy={label:r.groupBy.label}),(null===(t=r.filters)||void 0===t?void 0:t.length)&&(a.queryRunnerParams.filters=r.filters),a}buildFavorite(){const{item:e,skipVariablesInterpolation:t}=this.state;return eD.buildFavorite({index:e.index,queryRunnerParams:t?e.queryRunnerParams:JA(this,e),panelType:e.panelType})}constructor(e){super(e),ZA(this,"_variableDependency",new im(this,{variableNames:["serviceName","profileMetricId","filters"],onReferencedVariableValueChanged:()=>{this.update()}})),ZA(this,"onClick",(()=>{Ts("g_pyroscope_app_fav_action_clicked",{favAfterClick:!this.state.isFav}),this.state.isFav?XA.removeFavorite(this.buildFavorite()):XA.addFavorite(this.buildFavorite()),this.setState({isFav:!this.state.isFav})})),this.addActivationHandler((()=>this.update()))}}ZA(eD,"Component",(({model:e})=>{const t=(0,o.useStyles2)(tD),{isFav:n}=e.useState();return $i().createElement(o.IconButton,{className:n?t.favedButton:t.notFavedbutton,name:n?"favorite":"star",variant:"secondary",size:"sm","aria-label":n?"Unfavorite":"Favorite",tooltip:n?"Unfavorite":"Favorite",tooltipPlacement:"top",onClick:e.onClick})}));const tD=()=>({favedButton:i.css` color: #f2cc0d; margin: 0; `,notFavedbutton:i.css` margin: 0; `}),nD=function(e,t){const n=XA.exists(eD.buildFavorite(e)),r=XA.exists(eD.buildFavorite(t));return n&&r?gP(e.label,t.label):r?1:n?-1:0},rD="240px";class iD extends bh{static buildGridItemKey(e){return`grid-item-${e.index}-${e.value}`}static getGridColumnsTemplate(e){return e===BA.ROWS?"1fr":"repeat(auto-fit, minmax(400px, 1fr))"}onActivate(){const e=tm.lookupVariable(this.state.variableName,this),t=e.subscribeToState(((e,t)=>{!e.loading&&t.loading&&this.renderGridItems()}));e.update();const n=this.subscribeToRefreshClick(),r=this.subscribeToQuickFilterChange(),i=this.subscribeToLayoutChange(),a=this.subscribeToHideNoDataChange(),o=this.subscribeToFiltersChange();return()=>{o.unsubscribe(),a.unsubscribe(),i.unsubscribe(),r.unsubscribe(),n.unsubscribe(),t.unsubscribe()}}subscribeToRefreshClick(){const e=tm.lookupVariable(this.state.variableName,this),t=e.state.refresh;e.setState({refresh:r.VariableRefresh.never});const n=()=>{e.update()},i=document.querySelector('[data-testid="data-testid RefreshPicker run button"]');return i||Xi.error(new Error("SceneByVariableRepeaterGrid: Refresh button not found! The list of items will never be updated.")),null==i||i.addEventListener("click",n),null==i||i.setAttribute("title","Click to completely refresh all the panels present on the screen"),{unsubscribe(){null==i||i.removeAttribute("title"),null==i||i.removeEventListener("click",n),e.setState({refresh:t})}}}subscribeToQuickFilterChange(){const e=tm.findByKeyAndType(this,"quick-filter",HA);this.subscribeToState(((t,n)=>{t.items.length!==n.items.length&&e.setResultsCount(t.items.length)}));return e.subscribeToState((0,$c.debounce)(((e,t)=>{e.searchText!==(null==t?void 0:t.searchText)&&this.renderGridItems()}),HA.DEBOUNCE_DELAY))}subscribeToLayoutChange(){const e=tm.findByKeyAndType(this,"layout-switcher",VA),t=this.state.body,n=(e,n)=>{e.layout!==(null==n?void 0:n.layout)&&t.setState({templateColumns:iD.getGridColumnsTemplate(e.layout)})};return n(e.state),e.subscribeToState(n)}subscribeToHideNoDataChange(){const e=tm.findByKeyAndType(this,"no-data-switcher",UA);if(!e.isActive)return this.setState({hideNoData:!1}),{unsubscribe:na};const t=(e,t)=>{e.hideNoData!==(null==t?void 0:t.hideNoData)&&(this.setState({hideNoData:"on"===e.hideNoData}),this.renderGridItems(!0))};return t(e.state),e.subscribeToState(t)}subscribeToFiltersChange(){const e=tm.findByKeyAndType(this,"filters",vR),t=tm.findByKeyAndType(this,"no-data-switcher",UA);return e.subscribeToState((()=>{"on"===t.state.hideNoData&&this.renderGridItems(!0)}))}buildItemsData(e){const{mapOptionToItem:t}=this.state,n={serviceName:wR(this,"serviceName"),profileMetricId:wR(this,"profileMetricId"),panelType:tm.findByKeyAndType(this,"panel-type-switcher",xR).state.panelType},r=e.state.options.map(((e,r)=>t(e,r,n))).filter(Boolean);return this.filterItems(r).sort(this.state.sortItemsFn)}shouldRenderItems(e){const{items:t}=this.state;return!e.length||t.length!==e.length||!(0,$c.isEqual)(t,e)}renderGridItems(e=!1){const t=tm.lookupVariable(this.state.variableName,this);if(t.state.loading)return;if(t.state.error)return void this.renderErrorState(t.state.error);const n=this.buildItemsData(t);if(!e&&!this.shouldRenderItems(n))return;if(this.setState({items:n}),!this.state.items.length)return void this.renderEmptyState();const r=this.state.items.map((e=>{const t=oA(e.panelType,{item:e,headerActions:this.state.headerActions.bind(null,e,this.state.items)});return this.state.hideNoData&&this.setupHideNoData(t),new Zx({key:iD.buildGridItemKey(e),body:t})}));this.state.body.setState({autoRows:rD,children:r})}setupHideNoData(e){const t=e.subscribeToEvent(F_,(t=>{var n;if(null===(n=t.payload.series)||void 0===n?void 0:n.length)return;const r=tm.getAncestor(e,Zx),{key:i}=r.state,a=tm.getAncestor(r,Jx),o=a.state.children.filter((e=>e.state.key!==i));o.length?a.setState({children:o}):this.renderEmptyState()}));e.addActivationHandler((()=>()=>{t.unsubscribe()}))}filterItems(e){const t=tm.findByKeyAndType(this,"quick-filter",HA),{searchText:n}=t.state;if(!n)return e;const r=n.split(",").map((e=>e.trim())).filter(Boolean).map((e=>{try{return new RegExp(e)}catch(e){return null}})).filter(Boolean);return e.filter((({label:e})=>r.some((t=>t.test(e)))))}renderEmptyState(){this.state.body.setState({autoRows:"480px",children:[new Zx({body:new MA({message:"No results"})})]})}renderErrorState(e){this.state.body.setState({autoRows:"480px",children:[new Zx({body:new FA({message:e.message||e.toString()})})]})}static Component({model:e}){var t;const{body:n,variableName:r}=e.useState(),{loading:i}=null===(t=tm.lookupVariable(r,e))||void 0===t?void 0:t.useState();return i?$i().createElement(o.Spinner,null):$i().createElement(n.Component,{model:n})}constructor({key:e,variableName:t,headerActions:n,mapOptionToItem:i,sortItemsFn:a}){super({key:e,variableName:t,items:[],headerActions:n,mapOptionToItem:i,sortItemsFn:a||nD,hideNoData:!1,body:new Jx({templateColumns:iD.getGridColumnsTemplate(VA.DEFAULT_LAYOUT),autoRows:rD,isLazy:!0,$behaviors:[new Ay({key:"metricCrosshairSync",sync:r.DashboardCursorSync.Crosshair})],children:[]})}),this.addActivationHandler(this.onActivate.bind(this))}}class aD extends r.BusEventWithPayload{}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(aD,"type","expand-panel");class oD extends r.BusEventWithPayload{}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(oD,"type","select-label");class sD extends r.BusEventWithPayload{}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(sD,"type","view-service-flame-graph");class lD extends r.BusEventWithPayload{}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(lD,"type","view-service-labels");class cD extends r.BusEventWithPayload{}function uD(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dD(e){for(var t=1;t"Expand this panel to view all the data for the current filters",EventConstructor:aD})],["select-label",Object.freeze({label:"Select",tooltip:({queryRunnerParams:e})=>{var t;return`View "${null===(t=e.groupBy)||void 0===t?void 0:t.label}" values breakdown`},EventConstructor:oD})],["view-flame-graph",Object.freeze({label:"Flame graph",tooltip:({queryRunnerParams:e},t)=>{const n=e.serviceName||wR(t,"serviceName");return`View the "${WP(e.profileMetricId||wR(t,"profileMetricId")).type}" flame graph of ${n}`},EventConstructor:sD})],["view-labels",Object.freeze({label:"Labels",tooltip:({queryRunnerParams:e},t)=>`Explore the labels of ${e.serviceName||wR(t,"serviceName")}`,EventConstructor:lD})],["view-profiles",Object.freeze({label:"Profile types",tooltip:({queryRunnerParams:e},t)=>`View the profile types of ${e.serviceName||wR(t,"serviceName")}`,EventConstructor:cD})]]);class fD extends bh{buildEvent(){const{EventConstructor:e,item:t,skipVariablesInterpolation:n}=this.state;return new e({item:pD(dD({},t),{queryRunnerParams:n?t.queryRunnerParams:JA(this,t)})})}constructor({type:e,item:t,tooltip:n,skipVariablesInterpolation:r}){const i=hD.get(e);if(!i)throw new TypeError(`Unknown event type="${e}"!`);super(dD({type:e,item:t},(0,$c.merge)({},i,{tooltip:n,skipVariablesInterpolation:r}))),uD(this,"onClick",(()=>{Ts("g_pyroscope_app_select_action_clicked",{type:this.state.type}),this.publishEvent(this.buildEvent(),!0)}))}}uD(fD,"Component",(({model:e})=>{const t=(0,o.useStyles2)(mD),{ariaLabel:n,label:r,icon:i,tooltip:a,item:s}=e.useState();return $i().createElement(o.Button,{className:t.selectButton,"aria-label":n||r,variant:"primary",size:"sm",fill:"text",onClick:e.onClick,icon:i,tooltip:null==a?void 0:a(s,e),tooltipPlacement:"top"},r)}));const mD=()=>({selectButton:i.css` margin: 0; padding: 0; `});class gD extends bh{onActivate(){tm.findByKeyAndType(this,"quick-filter",HA).setPlaceholder("Search services (comma-separated regexes are supported)")}getVariablesAndGridControls(){return{variables:[tm.findByKeyAndType(this,"profileMetricId",eR)],gridControls:[tm.findByKeyAndType(this,"quick-filter",HA),tm.findByKeyAndType(this,"layout-switcher",VA)]}}static Component({model:e}){const{body:t}=e.useState();return $i().createElement(t.Component,{model:t})}constructor(){super({key:"explore-all-services",$variables:new Mw({variables:[new iR({query:iR.QUERY_PROFILE_METRIC_DEPENDENT,skipUrlSync:!0})]}),body:new iD({key:"all-services-grid",variableName:"serviceName",mapOptionToItem:(e,t,{profileMetricId:n})=>({index:t,value:e.value,label:e.label,queryRunnerParams:{serviceName:e.value,profileMetricId:n},panelType:ER.TIMESERIES}),headerActions:e=>[new fD({type:"view-profiles",item:e}),new fD({type:"view-labels",item:e}),new fD({type:"view-flame-graph",item:e}),new eD({item:e})]})}),this.addActivationHandler(this.onActivate.bind(this))}}function yD(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function bD(e){for(var t=1;t{this.setState(vD(bD({},this.state),{isOpen:!0,title:e,subTitle:t,body:n}))})),yD(this,"close",(()=>{this.setState({isOpen:!1})}))}}function SD(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}yD(wD,"Component",(({model:e})=>{const{isOpen:t,title:n,subTitle:r,body:i}=e.useState();return $i().createElement($i().Fragment,null,i&&t&&$i().createElement(o.Drawer,{size:"lg",title:n,subtitle:r,closeOnMaskClick:!0,onClose:e.close},$i().createElement(i.Component,{model:i})))}));class ED extends _S{update(){var e,t=this;return(e=function*(){if(t.state.loading)return;let e=[],n=null;t.setState({loading:!0,options:[],error:null});try{e=yield(0,qp.lastValueFrom)(t.getValueOptions({}))}catch(e){n=e}finally{t.setState({loading:!1,options:e,error:n})}},function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){SD(a,r,i,o,s,"next",e)}function s(e){SD(a,r,i,o,s,"throw",e)}o(void 0)}))})()}constructor(){super({name:"favorite",label:"🔖 Favorite",datasource:YP,query:"$dataSource",loading:!0,refresh:r.VariableRefresh.never,skipUrlSync:!0})}}function xD(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}class OD extends bh{onActivate(){tm.findByKeyAndType(this,"quick-filter",HA).setPlaceholder("Search favorites (comma-separated regexes are supported)");var e=this;const t=this.subscribeToEvent(aD,function(){var t,n=(t=function*(t){e.openExpandedPanelDrawer(t.payload.item)},function(){var e=this,n=arguments;return new Promise((function(r,i){var a=t.apply(e,n);function o(e){xD(a,r,i,o,s,"next",e)}function s(e){xD(a,r,i,o,s,"throw",e)}o(void 0)}))});return function(e){return n.apply(this,arguments)}}());return()=>{t.unsubscribe()}}getVariablesAndGridControls(){return{variables:[],gridControls:[tm.findByKeyAndType(this,"quick-filter",HA),tm.findByKeyAndType(this,"layout-switcher",VA),tm.findByKeyAndType(this,"no-data-switcher",UA)]}}openExpandedPanelDrawer(e){this.state.drawer.open({title:e.label,body:oA(e.panelType,{displayAllValues:!0,legendPlacement:"right",item:e,headerActions:()=>[new fD({type:"view-labels",item:e}),new fD({type:"view-flame-graph",item:e})]})})}static Component({model:e}){const{body:t,drawer:n}=e.useState();return $i().createElement($i().Fragment,null,$i().createElement(t.Component,{model:t}),$i().createElement(n.Component,{model:n}))}constructor(){super({key:"explore-favorites",$variables:new Mw({variables:[new ED]}),body:new iD({key:"favorites-grid",variableName:"favorite",mapOptionToItem:e=>{const{index:t,value:n,panelType:r,queryRunnerParams:i}=JSON.parse(e.value);return{index:t,value:n,label:e.label,queryRunnerParams:i,panelType:r}},sortItemsFn:(e,t)=>gP(e.label,t.label),headerActions:e=>{const t=[new fD({type:"view-labels",item:e,skipVariablesInterpolation:!0}),new fD({type:"view-flame-graph",item:e,skipVariablesInterpolation:!0})];return e.queryRunnerParams.groupBy&&t.push(new fD({type:"expand-panel",item:e,tooltip:()=>"Expand panel to view all the data",skipVariablesInterpolation:!0})),t.push(new eD({item:e,skipVariablesInterpolation:!0})),t}}),drawer:new wD}),this.addActivationHandler(this.onActivate.bind(this))}}function _D(e){const{ref:t,box:n,onResize:r}=e;(0,Fi.useEffect)((()=>{let e=null==t?void 0:t.current;if(e){if(void 0===window.ResizeObserver)return window.addEventListener("resize",r,!1),()=>{window.removeEventListener("resize",r,!1)};{const t=new window.ResizeObserver((e=>{e.length&&r()}));return t.observe(e,{box:n}),()=>{e&&t.unobserve(e)}}}}),[r,t,n])}function TD({options:e,mainLabels:t,value:n,onChange:r,onRefresh:i}){const a=(0,o.useStyles2)(CD),s=(0,o.useTheme2)(),[l,c]=(0,Fi.useState)(0),[u,d]=(0,Fi.useState)(0),p=u>l,h=(0,Fi.useRef)(null);_D({ref:h,onResize:()=>{const e=h.current;e&&d(e.clientWidth)}});const f=e.filter((e=>t.includes(e.value))),m=e.filter((e=>!t.includes(e.value)));return(0,Fi.useEffect)((()=>{const{fontSize:e}=s.typography,t=f.map((e=>e.label||e.text||"")).join(" "),n=(0,o.measureText)(t,e).width;c(n+70*f.length)}),[f,s]),$i().createElement(o.Field,{label:"Group by labels"},$i().createElement("div",{ref:h,className:a.container},p?$i().createElement($i().Fragment,null,$i().createElement(o.RadioButtonGroup,{"aria-label":"Labels selector",options:f,value:n,onChange:r}),$i().createElement(o.Select,{"aria-label":"Other labels selector",className:a.select,placeholder:"Other labels",options:m,value:n&&m.some((e=>e.value===n))?n:null,onChange:e=>{var t;return r(null!==(t=null==e?void 0:e.value)&&void 0!==t?t:"all")},isClearable:!0})):$i().createElement(o.Select,{"aria-label":"Labels selector",className:a.select,value:n,placeholder:"Select label",options:e,onChange:e=>r((null==e?void 0:e.value)||AD.DEFAULT_VALUE),isClearable:!0}),$i().createElement(o.RefreshPicker,{noIntervalPicker:!0,onRefresh:i,isOnCanvas:!1,onIntervalChanged:na,tooltip:"Click to refresh all labels"})))}const CD=e=>({container:i.css` display: flex; gap: ${e.spacing(1)}; `,select:i.css` max-width: ${e.spacing(22)}; `});function kD(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function PD(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){kD(a,r,i,o,s,"next",e)}function s(e){kD(a,r,i,o,s,"throw",e)}o(void 0)}))}}function RD(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class AD extends _S{onActivate(){this.state.value||this.setState({value:AD.DEFAULT_VALUE})}findCurrentOption(){const{value:e}=this.state,t=this.state.options.filter((e=>"all"!==e.value)).find((t=>JSON.parse(t.value).value===e));if(t){const e=JSON.parse(t.value);return{index:e.index,value:e.value,label:e.value,groupBy:e.groupBy}}return{index:0,value:e,label:e,groupBy:void 0}}constructor(){var e;super({key:"groupBy",name:"groupBy",label:"Group by labels",datasource:XP,query:'$dataSource and $profileMetricId{service_name="$serviceName"}',loading:!0}),e=this,RD(this,"update",PD((function*(){if(e.state.loading)return;let t=[],n=null;e.setState({loading:!0,options:[],error:null});try{t=yield(0,qp.lastValueFrom)(e.getValueOptions({}))}catch(e){n=e}finally{e.setState({loading:!1,options:t,error:n})}}))),RD(this,"onChange",(e=>{Ts("g_pyroscope_app_group_by_label_clicked"),M_(),this.changeValueTo(e)})),this.changeValueTo=this.changeValueTo.bind(this),this.addActivationHandler(this.onActivate.bind(this))}}RD(AD,"DEFAULT_VALUE","all"),RD(AD,"MAX_MAIN_LABELS",8),RD(AD,"Component",(({model:e})=>{const t=(0,o.useStyles2)(DD),{loading:n,value:r,options:i,error:a}=e.useState(),s=(0,Fi.useMemo)((()=>i.map((({label:e,value:t})=>"all"===t?{label:e,value:t}:{label:e,value:JSON.parse(String(t)).value}))),[i]);if(n)return $i().createElement(o.Field,{label:"Group by labels"},$i().createElement(o.Spinner,{className:t.spinner}));if(a)return $i().createElement(o.Field,{label:"Group by labels"},$i().createElement("div",{className:t.groupByErrorContainer},$i().createElement(o.Tooltip,{theme:"error",content:a.toString()},$i().createElement(o.Icon,{className:t.iconError,name:"exclamation-triangle",size:"xl"})),$i().createElement(o.RefreshPicker,{noIntervalPicker:!0,onRefresh:e.update,isOnCanvas:!1,onIntervalChanged:na})));return $i().createElement(TD,{options:s,value:r,mainLabels:(e=>e.slice(0,AD.MAX_MAIN_LABELS).map((({value:e})=>e)))(s),onChange:e.onChange,onRefresh:e.update})}));const DD=e=>({spinner:i.css` height: 32px; line-height: 32px; `,groupByErrorContainer:i.css` display: flex; `,iconError:i.css` height: 32px; align-self: center; color: ${e.colors.error.text}; `});function jD(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class ID extends bh{onActivate(e,t){e&&this.initVariables(e),this.setState({body:this.buildTimeseries(e,t)}),t&&this.subscribeToGroupByStateChanges(e)}initVariables(e){const{serviceName:t,profileMetricId:n,filters:r}=e.queryRunnerParams;if(t){tm.findByKeyAndType(this,"serviceName",iR).changeValueTo(t)}if(n){tm.findByKeyAndType(this,"profileMetricId",eR).changeValueTo(n)}if(r){tm.findByKeyAndType(this,"filters",vR).setState({filters:r})}}buildTimeseries(e,t){const{headerActions:n}=this.state,r={index:0,value:"",queryRunnerParams:{},label:this.buildTitle(),panelType:ER.TIMESERIES};e&&t&&(r.queryRunnerParams.groupBy=e.queryRunnerParams.groupBy);const i=tm.findByKeyAndType(this,"groupBy",AD).state.value;return new aA({item:r,headerActions:n,data:!e&&t&&i&&"all"!==i?new Dw({$data:new cy({datasource:QP,queries:[]}),transformations:[AR,DR]}):void 0})}subscribeToGroupByStateChanges(e){const t=tm.findByKeyAndType(this,"groupBy",AD);this._subs.add(t.subscribeToState(((n,r)=>{!n.loading&&n.options.length&&(e||!r.loading?n.value!==r.value&&this.onGroupByChanged(t):this.onGroupByChanged(t))})))}onGroupByChanged(e){var t;if(!e.state.value||"all"===e.state.value)return void this.resetTimeseries();const{index:n,value:r,groupBy:i}=e.findCurrentOption();null===(t=this.state.body)||void 0===t||t.updateItem({index:n,label:`${this.buildTitle()}, grouped by ${r}`,queryRunnerParams:{groupBy:i}})}resetTimeseries(e=!1){var t;e&&tm.findByKeyAndType(this,"filters",vR).reset(),null===(t=this.state.body)||void 0===t||t.updateItem({index:0,label:this.buildTitle(),queryRunnerParams:{groupBy:void 0}})}buildTitle(){const e=wR(this,"profileMetricId"),{description:t}=WP(e);return t||ZR(e)}static Component({model:e}){const{body:t}=e.useState();return t&&$i().createElement(t.Component,{model:t})}constructor({item:e,headerActions:t,supportGroupBy:n}){super({headerActions:t,body:void 0}),jD(this,"_variableDependency",new im(this,{variableNames:["serviceName","profileMetricId"],onReferencedVariableValueChanged:e=>{this.resetTimeseries("serviceName"===e.state.name)}})),this.addActivationHandler(this.onActivate.bind(this,e,n))}}jD(ID,"MIN_HEIGHT",240);class ND extends r.BusEventWithPayload{}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(ND,"type","view-diff-flame-graph");class LD extends r.BusEventWithPayload{}function MD({option:e,checked:t,onChange:n}){var r;const a=(0,o.useStyles2)(FD),[s,l]=(0,Fi.useState)(!1),c=(0,Fi.useRef)(null),u=null===(r=c.current)||void 0===r?void 0:r.closest("label");return(0,Fi.useEffect)((()=>{if(!u||t)return void l(!1);const e=()=>{l(!0)},n=()=>{l(!1)};return u.addEventListener("mouseenter",e),u.addEventListener("mouseleave",n),()=>{u.removeEventListener("mouseleave",n),u.removeEventListener("mouseenter",e)}}),[t,u]),$i().createElement($i().Fragment,null,$i().createElement(o.Tooltip,{content:e.description,show:!t&&s,placement:"top"},$i().createElement("span",{className:a.tooltipAnchor})),$i().createElement(o.Checkbox,{ref:c,className:(0,i.cx)(a.checkbox,"checkbox",t&&"checked"),checked:t,label:e.label,onChange:()=>n(e.value)}))}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(LD,"type","select-for-compare");const FD=e=>({tooltipAnchor:i.css` position: relative; left: 42px; `,checkbox:i.css` column-gap: 4px; &:last-child { & :nth-child(1) { grid-column-start: 2; } & :nth-child(2) { grid-column-start: 1; } } span { color: ${e.colors.text.secondary}; } span:hover { color: ${e.colors.text.primary}; } &.checked span { color: ${e.colors.text.primary}; } `});function $D({item:e,itemStats:t,statsDescription:n,compareActionChecks:i,onChangeCompareTarget:a}){const s=(0,o.useStyles2)(BD),{index:l,value:c}=e,u=OR(l),d=(0,Fi.useMemo)((()=>{if(!t)return $i().createElement(o.Spinner,{inline:!0});const{allValuesSum:e,unit:n}=t,{text:i,suffix:a}=(0,r.getValueFormat)(n)(e);return`${i}${a}`}),[t]),p=(0,Fi.useMemo)((()=>[{label:"Baseline",value:np.BASELINE,description:i[0]?"":`Click to select "${c}" as baseline for comparison`},{label:"Comparison",value:np.COMPARISON,description:i[1]?"":`Click to select "${c}" as target for comparison`}]),[i,c]);return $i().createElement("div",{className:s.container,"data-testid":`stats-panel-${c}`},$i().createElement("h1",{style:{color:u},className:s.title,title:`${n}: ${d}`},d),$i().createElement("div",{className:s.compareActions},$i().createElement(MD,{option:p[0],checked:i[0],onChange:a}),$i().createElement(MD,{option:p[1],checked:i[1],onChange:a})))}const BD=e=>({container:i.css` display: flex; flex-direction: column; justify-content: space-between; width: 100%; background-color: ${e.colors.background.canvas}; padding: ${e.spacing(1)}; border: 1px solid ${e.colors.border.weak}; border-right: none; border-radius: 2px 0 0 2px; `,title:i.css` font-size: 24px; width: 100%; text-align: center; margin-top: ${e.spacing(5)}; `,compareActions:i.css` display: flex; justify-content: space-between; font-size: 11px; border-top: 1px solid ${e.colors.border.weak}; padding: ${e.spacing(1)} 0 0 0; & .checkbox:nth-child(2) { padding-right: 4px; border-right: 1px solid ${e.colors.border.strong}; } & .checkbox:nth-child(4) { padding-left: 4px; } `});function VD(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class zD extends bh{onActivate(){const e=tm.findByKeyAndType(this,"group-by-labels",oj).getCompare();this.updateCompareActions(e.get(np.BASELINE),e.get(np.COMPARISON)),this.setState({statsDescription:this.getStatsDescription()})}updateCompareActions(e,t){const{item:n}=this.state;this.setState({compareActionChecks:[(null==e?void 0:e.value)===n.value,(null==t?void 0:t.value)===n.value]})}getStatsDescription(){const e=wR(this,"profileMetricId"),{description:t}=WP(e);return t||ZR(e)}getStats(){return this.state.itemStats}updateStats(e){this.setState({itemStats:e})}static Component({model:e}){const{item:t,itemStats:n,statsDescription:r,compareActionChecks:i}=e.useState();return $i().createElement($D,{item:t,itemStats:n,statsDescription:r,compareActionChecks:i,onChangeCompareTarget:e.onChangeCompareTarget})}constructor({item:e}){super({item:e,itemStats:void 0,compareActionChecks:[!1,!1],statsDescription:""}),VD(this,"onChangeCompareTarget",(e=>{this.publishEvent(new LD({compareTarget:e,item:this.state.item}),!0)})),this.addActivationHandler(this.onActivate.bind(this))}}VD(zD,"WIDTH_IN_PIXELS",186);class UD extends bh{static buildPanelKey(e){return`compare-panel-${e.value}`}onActivate(){const{statsPanel:e,timeseriesPanel:t}=this.state,n=t.subscribeToEvent(F_,(t=>{var n,r;const i=null===(n=t.payload.series)||void 0===n?void 0:n[0];if(!i)return void e.updateStats({allValuesSum:0,unit:"short"});const a=TR(i,"allValuesSum")||0;(null===(r=e.getStats())||void 0===r?void 0:r.allValuesSum)!==a&&e.updateStats({allValuesSum:a,unit:i.fields[1].config.unit||"short"})}));return()=>{n.unsubscribe()}}static Component({model:e}){const t=(0,o.useStyles2)(qD),{statsPanel:n,timeseriesPanel:r}=e.useState(),{compareActionChecks:a}=n.useState(),s=a[0]||a[1];return $i().createElement("div",{className:(0,i.cx)(t.container,s&&"selected")},$i().createElement("div",{className:t.statsPanel},$i().createElement(n.Component,{model:n})),$i().createElement("div",{className:t.timeseriesPanel},$i().createElement(r.Component,{model:r})))}constructor({item:e,headerActions:t}){super({key:"label-value-panel",statsPanel:new zD({item:e}),timeseriesPanel:new aA({item:e,headerActions:t})}),this.addActivationHandler(this.onActivate.bind(this))}}const qD=e=>({container:i.css` display: flex; min-width: 0px; min-height: ${GD}; flex-flow: row; box-sizing: border-box; border: 1px solid transparent; &.selected { border: 1px solid ${e.colors.primary.main}; } & > div { display: flex; position: relative; flex-direction: row; align-self: stretch; min-height: ${GD}; } `,statsPanel:i.css` width: ${zD.WIDTH_IN_PIXELS}px; `,timeseriesPanel:i.css` flex-grow: 1; & [data-viz-panel-key] > * { border-top-left-radius: 0; border-bottom-left-radius: 0; } `});function HD({label:e}){const t='service_name="$serviceName"';return new cy({datasource:QP,queries:[{refId:`$profileMetricId-${t}-${e}`,queryType:"metrics",profileTypeId:"$profileMetricId",labelSelector:`{${t}}`,groupBy:[e]}]})}const GD="160px";class WD extends bh{static buildGridItemKey(e){return`grid-item-${e.index}-${e.value}`}onActivate(){this.subscribeOnceToDataChange();const e=this.subscribeToGroupByChange(),t=this.subscribeToRefreshClick(),n=this.subscribeToQuickFilterChange(),r=this.subscribeToLayoutChange(),i=this.subscribeToHideNoDataChange(),a=this.subscribeToFiltersChange();return()=>{a.unsubscribe(),i.unsubscribe(),r.unsubscribe(),n.unsubscribe(),t.unsubscribe(),e.unsubscribe()}}subscribeOnceToDataChange(e=!1){const t=this.state.$data.subscribeToState((n=>{var i;(null===(i=n.data)||void 0===i?void 0:i.state)!==r.LoadingState.Loading&&(t.unsubscribe(),this.renderGridItems(e),this.setState({isLoading:!1}))}))}subscribeToGroupByChange(){return tm.findByKeyAndType(this,"groupBy",AD).subscribeToState(((e,t)=>{!e.loading&&t.loading&&this.refetchData()}))}subscribeToRefreshClick(){const e=()=>{this.refetchData()},t=document.querySelector('[data-testid="data-testid RefreshPicker run button"]');return t||Xi.error(new Error("SceneByVariableRepeaterGrid: Refresh button not found! The list of items will never be updated.")),null==t||t.addEventListener("click",e),null==t||t.setAttribute("title","Click to completely refresh all the panels present on the screen"),{unsubscribe(){null==t||t.removeAttribute("title"),null==t||t.removeEventListener("click",e)}}}subscribeToQuickFilterChange(){const e=tm.findByKeyAndType(this,"quick-filter",HA);this.subscribeToState(((t,n)=>{t.items.length!==n.items.length&&e.setResultsCount(t.items.length)}));return e.subscribeToState((0,$c.debounce)(((e,t)=>{e.searchText!==(null==t?void 0:t.searchText)&&this.renderGridItems()}),HA.DEBOUNCE_DELAY))}subscribeToLayoutChange(){const e=tm.findByKeyAndType(this,"layout-switcher",VA),t=this.state.body,n=(e,n)=>{e.layout!==(null==n?void 0:n.layout)&&t.setState({templateColumns:e.layout===BA.ROWS?"1fr":"repeat(auto-fit, minmax(600px, 1fr))"})};return n(e.state),e.subscribeToState(n)}subscribeToHideNoDataChange(){const e=tm.findByKeyAndType(this,"no-data-switcher",UA);this.setState({hideNoData:"on"===e.state.hideNoData});return e.subscribeToState(((e,t)=>{e.hideNoData!==(null==t?void 0:t.hideNoData)&&(this.setState({hideNoData:"on"===e.hideNoData}),this.refetchData(!0))}))}subscribeToFiltersChange(){const e=tm.findByKeyAndType(this,"filters",vR),t=tm.findByKeyAndType(this,"no-data-switcher",UA);return e.subscribeToState((()=>{"on"===t.state.hideNoData&&this.refetchData()}))}refetchData(e=!1){this.setState({isLoading:!0,$data:new Dw({$data:HD({label:this.state.label}),transformations:[AR,DR]})}),this.subscribeOnceToDataChange(e)}shouldRenderItems(e){const{items:t}=this.state;return!e.length||t.length!==e.length||!(0,$c.isEqual)(t,e)}buildItemsData(e){const t=wR(this,"serviceName"),n=wR(this,"profileMetricId"),{label:r,startColorIndex:i,sortItemsFn:a}=this.state,o=e.map(((e,a)=>{var o;const s=e.fields[1],l=(null===(o=s.labels)||void 0===o?void 0:o[r])||"",c=_R(s,r);return{index:i+a,value:l,label:c,queryRunnerParams:{serviceName:t,profileMetricId:n,filters:[{key:r,operator:"=",value:l}]},panelType:ER.TIMESERIES}}));return this.filterItems(o).sort(a)}renderGridItems(e=!1){if(!this.state.$data.state.data)return;const{state:t,series:n,errors:i}=this.state.$data.state.data;if(t===r.LoadingState.Loading)return;if(t===r.LoadingState.Error)return void this.renderErrorState(null==i?void 0:i[0]);const a=this.buildItemsData(n);if(!e&&!this.shouldRenderItems(a))return;if(this.setState({items:a}),!this.state.items.length)return void this.renderEmptyState();const o=a.map((e=>new Zx({key:WD.buildGridItemKey(e),body:this.buildVizPanel(e)})));this.state.body.setState({autoRows:GD,children:o})}buildVizPanel(e){const t=new UD({item:e,headerActions:this.state.headerActions.bind(null,e,this.state.items)}),n=t.subscribeToEvent(F_,(e=>{var n;if(!this.state.hideNoData||(null===(n=e.payload.series)||void 0===n?void 0:n.length))return;const r=tm.getAncestor(t,Zx),{key:i}=r.state,a=tm.getAncestor(r,Jx),o=a.state.children.filter((e=>e.state.key!==i));o.length?a.setState({children:o}):this.renderEmptyState()}));return t.addActivationHandler((()=>()=>{n.unsubscribe()})),t}filterItems(e){const t=tm.findByKeyAndType(this,"quick-filter",HA),{searchText:n}=t.state;if(!n)return e;const r=n.split(",").map((e=>e.trim())).filter(Boolean).map((e=>{try{return new RegExp(e)}catch(e){return null}})).filter(Boolean);return e.filter((({label:e})=>r.some((t=>t.test(e)))))}renderEmptyState(){this.state.body.setState({autoRows:"480px",children:[new Zx({body:new MA({message:"No results"})})]})}renderErrorState(e){this.state.body.setState({autoRows:"480px",children:[new Zx({body:new FA({message:e.message||e.toString()})})]})}static Component({model:e}){const{body:t,isLoading:n}=e.useState();return n?$i().createElement(o.Spinner,null):$i().createElement("div",{style:{marginBottom:"2px"}},$i().createElement(t.Component,{model:t}))}constructor({key:e,label:t,startColorIndex:n,headerActions:i}){super({key:e,label:t,startColorIndex:n,items:[],isLoading:!0,$data:new Dw({$data:HD({label:t}),transformations:[AR,DR]}),hideNoData:!1,headerActions:i,sortItemsFn:nD,body:new Jx({templateColumns:"1fr",autoRows:GD,isLazy:!0,$behaviors:[new Ay({key:"metricCrosshairSync",sync:r.DashboardCursorSync.Crosshair})],children:[]})}),this.addActivationHandler(this.onActivate.bind(this))}}class QD extends r.BusEventWithPayload{}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(QD,"type","clear-label-from-filters");class KD extends r.BusEventWithPayload{}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(KD,"type","exclude-label-from-filters");class YD extends r.BusEventWithPayload{}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(YD,"type","include-label-in-filters");const XD=e=>{const t=(0,o.useStyles2)(ZD),{include:n,exclude:r}=function({status:e,label:t,onInclude:n,onExclude:r,onClear:i}){const a="included"===e,o="excluded"===e;return{include:{isSelected:a,tooltip:a?`Clear "${t}" from the filters`:`Include "${t}" in the filters`,onClick:a?i:n},exclude:{isSelected:o,tooltip:o?`Clear "${t}" from the filters`:`Exclude "${t}" in the filters`,onClick:o?i:r}}}(e);return $i().createElement("div",{className:t.container},$i().createElement(o.Button,{size:"sm",fill:"outline",variant:n.isSelected?"primary":"secondary","aria-selected":n.isSelected,className:(0,i.cx)(t.includeButton,n.isSelected&&"selected"),onClick:n.onClick,tooltip:n.tooltip,tooltipPlacement:"top","data-testid":"filter-button-include"},"Include"),$i().createElement(o.Button,{size:"sm",fill:"outline",variant:r.isSelected?"primary":"secondary","aria-selected":r.isSelected,className:(0,i.cx)(t.excludeButton,r.isSelected&&"selected"),onClick:r.onClick,tooltip:r.tooltip,tooltipPlacement:"top","data-testid":"filter-button-exclude"},"Exclude"))},JD=(0,Fi.memo)(XD),ZD=e=>({container:i.css` display: flex; justify-content: center; `,includeButton:i.css` border-radius: ${e.shape.radius.default} 0 0 ${e.shape.radius.default}; &:not(.selected) { border-right: none; } `,excludeButton:i.css` border-radius: 0 ${e.shape.radius.default} ${e.shape.radius.default} 0; &:not(.selected) { border-left: none; } `});function ej(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class tj extends bh{getStatus(e){const{key:t,value:n}=this.state.item.queryRunnerParams.filters[0],r=e.find((e=>e.key===t));return r?Hk(r.operator)&&r.value.split("|").includes(n)?"=~"===r.operator?"included":"excluded":r.value===n?"="===r.operator?"included":"excluded":"clear":"clear"}constructor({item:e}){super({item:e}),ej(this,"onInclude",(()=>{Ts("g_pyroscope_app_include_action_clicked"),this.publishEvent(new YD({item:this.state.item}),!0)})),ej(this,"onExclude",(()=>{Ts("g_pyroscope_app_exclude_action_clicked"),this.publishEvent(new KD({item:this.state.item}),!0)})),ej(this,"onClear",(()=>{this.publishEvent(new QD({item:this.state.item}),!0)}))}}function nj({compare:e,onClickCompare:t,onClickClear:n}){const r=(0,o.useStyles2)(rj),a=e.size<2,s=e.size>0,l=(0,Fi.useMemo)((()=>{var t,n,r,i;return 2===e.size?`Compare "${null===(r=e.get(np.BASELINE))||void 0===r?void 0:r.label}" vs "${null===(i=e.get(np.COMPARISON))||void 0===i?void 0:i.label}"`:0===e.size?"Select both a baseline and a comparison panel to compare their flame graphs":e.has(np.BASELINE)?`Select another panel to compare against "${null===(t=e.get(np.BASELINE))||void 0===t?void 0:t.label}"`:`Select another panel to compare against "${null===(n=e.get(np.COMPARISON))||void 0===n?void 0:n.label}"`}),[e]);return $i().createElement("div",{className:r.container},$i().createElement(o.Button,{"arial-label":"Compare",className:r.compareButton,variant:"primary",disabled:a,onClick:a?na:t,tooltip:l},"Compare (",e.size,"/2)"),$i().createElement(o.Button,{"data-testid":"clearComparison",className:(0,i.cx)(r.clearButton,a?void 0:r.clearButtonActive),icon:"times",variant:"secondary",tooltip:s?"Clear comparison selection":"",disabled:!s,onClick:s?n:na}))}ej(tj,"Component",(({model:e})=>{const{item:t}=e.useState(),{filters:n}=tm.findByKeyAndType(e,"filters",vR).useState(),r=(0,Fi.useMemo)((()=>e.getStatus(n)),[n,e]);return $i().createElement(JD,{label:t.value,status:r,onInclude:e.onInclude,onExclude:e.onExclude,onClear:e.onClear})}));const rj=e=>({container:i.css` display: flex; align-items: center; width: ${zD.WIDTH_IN_PIXELS}px; `,compareButton:i.css` width: ${zD.WIDTH_IN_PIXELS-32}px; border-right: none; border-top-right-radius: 0; border-bottom-right-radius: 0; `,clearButton:i.css` box-sizing: border-box; width: 32px !important; height: 32px !important; color: ${e.colors.text.secondary}; background-color: transparent; border-left: none !important; border-top-left-radius: 0; border-bottom-left-radius: 0; &:not([disabled]), &:not([disabled]):hover { background-color: transparent; box-shadow: none; } `,clearButtonActive:i.css` border-color: ${e.colors.border.medium}; &:hover { border-color: ${e.colors.border.medium}; } `});function ij(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function aj(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class oj extends bh{onActivate(e){var t,n=this;return(t=function*(){const t=tm.findByKeyAndType(n,"groupBy",AD);yield t.update(),e&&n.initVariablesAndControls(e),n.renderBody(t);const r=n.subscribeToGroupByChange(),i=n.subscribeToPanelEvents();return()=>{var e;i.unsubscribe(),r.unsubscribe(),null===(e=n.state.panelTypeChangeSub)||void 0===e||e.unsubscribe()}},function(){var e=this,n=arguments;return new Promise((function(r,i){var a=t.apply(e,n);function o(e){ij(a,r,i,o,s,"next",e)}function s(e){ij(a,r,i,o,s,"throw",e)}o(void 0)}))})()}initVariablesAndControls(e){const{queryRunnerParams:t,panelType:n}=e,{groupBy:r}=t;if(null==r?void 0:r.label){tm.findByKeyAndType(this,"groupBy",AD).changeValueTo(r.label)}if(n){tm.findByKeyAndType(this,"panel-type-switcher",xR).setState({panelType:n})}}subscribeToGroupByChange(){const e=tm.findByKeyAndType(this,"groupBy",AD),t=tm.findByKeyAndType(this,"quick-filter",HA);return e.subscribeToState(((n,r)=>{n.value!==(null==r?void 0:r.value)&&(t.clearSearchText(),this.renderBody(e))}))}subscribeToPanelEvents(){const e=this.subscribeToEvent(oD,(e=>{this.selectLabel(e.payload.item)})),t=this.subscribeToEvent(LD,(e=>{const{compareTarget:t,item:n}=e.payload;this.selectForCompare(t,n)})),n=this.subscribeToEvent(YD,(e=>{this.includeLabelValueInFilters(e.payload.item)})),r=this.subscribeToEvent(KD,(e=>{this.excludeLabelValueFromFilters(e.payload.item)})),i=this.subscribeToEvent(QD,(e=>{this.clearLabelValueFromFilters(e.payload.item)}));return{unsubscribe(){i.unsubscribe(),r.unsubscribe(),n.unsubscribe(),t.unsubscribe(),e.unsubscribe()}}}subscribeToPanelTypeChange(){return tm.findByKeyAndType(this,"panel-type-switcher",xR).subscribeToState(((e,t)=>{var n;e.panelType!==(null==t?void 0:t.panelType)&&(null===(n=this.state.body)||void 0===n||n.renderGridItems())}))}renderBody(e){var t;null===(t=this.state.panelTypeChangeSub)||void 0===t||t.unsubscribe(),"all"===e.state.value?(this.setState({panelTypeChangeSub:this.subscribeToPanelTypeChange()}),this.switchToLabelNamesGrid()):this.switchToLabelValuesGrid(e)}switchToLabelNamesGrid(){tm.findByKeyAndType(this,"quick-filter",HA).setPlaceholder("Search labels (comma-separated regexes are supported)"),this.setState({body:this.buildSceneLabelNamesGrid()})}buildSceneLabelNamesGrid(){return new iD({key:"service-labels-grid",variableName:"groupBy",mapOptionToItem:(e,t,{serviceName:n,profileMetricId:r,panelType:i})=>{if("all"===e.value)return null;const{value:a,groupBy:o}=JSON.parse(e.value);return{index:t-1,value:a,label:a,queryRunnerParams:{serviceName:n,profileMetricId:r,groupBy:o,filters:[]},panelType:i}},headerActions:e=>[new fD({type:"select-label",item:e}),new fD({type:"expand-panel",item:e}),new eD({item:e})]})}switchToLabelValuesGrid(e){tm.findByKeyAndType(this,"quick-filter",HA).setPlaceholder("Search label values (comma-separated regexes are supported)"),this.clearCompare();const{index:t,value:n}=e.findCurrentOption();this.setState({body:this.buildSceneLabelValuesGrid(n,t)})}buildSceneLabelValuesGrid(e,t){return new WD({key:"service-label-values-grid",startColorIndex:t,label:e,headerActions:e=>[new fD({type:"view-flame-graph",item:e,tooltip:(e,t)=>{const{queryRunnerParams:n,label:r}=e,i=n.profileMetricId||wR(t,"profileMetricId"),a=wR(t,"groupBy");return`View the "${WP(i).type}" flame graph for "${a}=${r}"`}}),new tj({item:e}),new eD({item:e})]})}selectLabel({queryRunnerParams:e}){const t=e.groupBy.label,n=tm.findByKeyAndType(this,"groupBy",AD);M_(),n.changeValueTo(t)}includeLabelValueInFilters(e){const[t]=e.queryRunnerParams.filters,n=tm.findByKeyAndType(this,"filters",vR);n.setState({filters:fR(n.state.filters,t)})}excludeLabelValueFromFilters(e){const t=tm.findByKeyAndType(this,"filters",vR),[n]=e.queryRunnerParams.filters;t.setState({filters:mR(t.state.filters,n)})}clearLabelValueFromFilters(e){const t=tm.findByKeyAndType(this,"filters",vR),[n]=e.queryRunnerParams.filters;t.setState({filters:gR(t.state.filters,n)})}selectForCompare(e,t){var n;const r=new Map(this.state.compare);(null===(n=r.get(e))||void 0===n?void 0:n.value)===t.value?r.delete(e):r.set(e,t),this.setState({compare:r}),this.updateStatsPanels()}updateStatsPanels(){const{compare:e}=this.state,t=e.get(np.BASELINE),n=e.get(np.COMPARISON),r=tm.findAllObjects(this,(e=>e instanceof zD));for(const e of r)e.updateCompareActions(t,n)}getCompare(){return this.state.compare}clearCompare(){this.setState({compare:new Map})}constructor({item:e}){super({key:"group-by-labels",body:void 0,compare:new Map,panelTypeChangeSub:void 0}),aj(this,"onClickCompareButton",(()=>{Ts("g_pyroscope_app_compare_link_clicked");const{compare:e}=this.state,{filters:t}=JA(this,e.get(np.BASELINE)),{filters:n}=JA(this,e.get(np.COMPARISON));this.publishEvent(new ND({useAncestorTimeRange:!0,clearDiffRange:!0,baselineFilters:t,comparisonFilters:n}),!0)})),aj(this,"onClickClearCompareButton",(()=>{this.clearCompare(),this.updateStatsPanels()})),this.addActivationHandler((()=>{this.onActivate(e)}))}}aj(oj,"Component",(({model:e})=>{const t=(0,o.useStyles2)(sj),{body:n,compare:r}=e.useState(),i=tm.findByKeyAndType(e,"groupBy",AD),{value:a}=i.useState(),s=(0,Fi.useMemo)((()=>"all"===a?tm.findByKeyAndType(e,"profiles-explorer",G$).state.gridControls:[tm.findByKeyAndType(e,"quick-filter",HA),tm.findByKeyAndType(e,"layout-switcher",VA),tm.findByKeyAndType(e,"no-data-switcher",UA)]),[a,e]);return $i().createElement("div",{className:t.container,"data-testid":"groupByLabelsContainer"},$i().createElement(i.Component,{model:i}),$i().createElement("div",{className:t.sceneControls},$i().createElement(o.Stack,{wrap:"wrap"},"all"!==a&&$i().createElement(nj,{compare:r,onClickCompare:e.onClickCompareButton,onClickClear:e.onClickClearCompareButton}),s.map((e=>$i().createElement(e.Component,{key:e.state.key,model:e}))))),n&&$i().createElement(n.Component,{model:n}))}));const sj=e=>({container:i.css` margin-top: ${e.spacing(1)}; `,sceneControls:i.css` margin-bottom: ${e.spacing(1)}; & .quick-filter { flex: 1; min-width: 112px; } `});function lj(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function cj(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function uj(e){for(var t=1;t{n.unsubscribe(),t.setState({query:eR.QUERY_DEFAULT}),t.update(!0)}}initVariables(e){const{queryRunnerParams:t}=e,{serviceName:n,profileMetricId:r,filters:i}=t;if(n){tm.findByKeyAndType(this,"serviceName",iR).changeValueTo(n)}if(r){tm.findByKeyAndType(this,"profileMetricId",eR).changeValueTo(r)}if(i){tm.findByKeyAndType(this,"filters",vR).setState({filters:i})}}subscribeToPanelEvents(){var e=this;const t=this.subscribeToEvent(aD,function(){var t,n=(t=function*(t){e.openExpandedPanelDrawer(t.payload.item)},function(){var e=this,n=arguments;return new Promise((function(r,i){var a=t.apply(e,n);function o(e){lj(a,r,i,o,s,"next",e)}function s(e){lj(a,r,i,o,s,"throw",e)}o(void 0)}))});return function(e){return n.apply(this,arguments)}}()),n=this.subscribeToEvent(oD,(()=>{this.state.drawer.close()}));return{unsubscribe(){n.unsubscribe(),t.unsubscribe()}}}getVariablesAndGridControls(){return{variables:[tm.findByKeyAndType(this,"serviceName",iR),tm.findByKeyAndType(this,"profileMetricId",eR),tm.findByKeyAndType(this,"filters",vR)],gridControls:[]}}openExpandedPanelDrawer(e){var t;const n=wR(this,"serviceName"),r=wR(this,"profileMetricId"),i=`${WP(r).description||ZR(r)}, grouped by ${(null===(t=e.queryRunnerParams.groupBy)||void 0===t?void 0:t.label)||"?"}`;this.state.drawer.open({title:n,body:oA(e.panelType,{displayAllValues:!0,legendPlacement:"right",item:dj(uj({},e),{label:i}),headerActions:()=>[new fD({type:"select-label",item:e}),new eD({item:e})]})})}static Component({model:e}){const{body:t,drawer:n}=e.useState();return $i().createElement($i().Fragment,null,$i().createElement(t.Component,{model:t}),$i().createElement(n.Component,{model:n}))}constructor({item:e}){super({key:"explore-service-labels",body:new qx({direction:"column",$behaviors:[new Ay({key:"metricCrosshairSync",sync:r.DashboardCursorSync.Crosshair})],children:[new Hx({minHeight:ID.MIN_HEIGHT,body:new ID({item:e,headerActions:e=>e.queryRunnerParams.groupBy?[new fD({type:"view-flame-graph",item:e}),new fD({type:"expand-panel",item:e}),new eD({item:e})]:[new fD({type:"view-flame-graph",item:e}),new eD({item:e})],supportGroupBy:!0})}),new Hx({body:new oj({item:e})})]}),drawer:new wD}),this.addActivationHandler(this.onActivate.bind(this,e))}}class hj extends bh{onActivate(e){tm.findByKeyAndType(this,"quick-filter",HA).setPlaceholder("Search profile types (comma-separated regexes are supported)"),e&&this.initVariables(e)}initVariables(e){if(e.queryRunnerParams.serviceName){tm.findByKeyAndType(this,"serviceName",iR).changeValueTo(e.queryRunnerParams.serviceName)}}getVariablesAndGridControls(){return{variables:[tm.findByKeyAndType(this,"serviceName",iR)],gridControls:[tm.findByKeyAndType(this,"quick-filter",HA),tm.findByKeyAndType(this,"layout-switcher",VA)]}}static Component({model:e}){const{body:t}=e.useState();return $i().createElement(t.Component,{model:t})}constructor({item:e}){super({key:"explore-service-profile-types",$variables:new Mw({variables:[new eR({query:eR.QUERY_SERVICE_NAME_DEPENDENT,skipUrlSync:!0})]}),body:new iD({key:"profile-metrics-grid",variableName:"profileMetricId",mapOptionToItem:(e,t,{serviceName:n})=>({index:t,value:e.value,label:e.label,queryRunnerParams:{serviceName:n,profileMetricId:e.value},panelType:ER.TIMESERIES}),headerActions:e=>[new fD({type:"view-labels",item:e}),new fD({type:"view-flame-graph",item:e}),new eD({item:e})]})}),this.addActivationHandler(this.onActivate.bind(this,e))}}function fj(e,t){return{from:e,to:t,value:{from:(0,r.dateTimeParse)(e),to:(0,r.dateTimeParse)(t),raw:{from:e,to:t}}}}const mj=()=>fj("now-30m","now");class gj extends Hw{reset(){this.setState({value:void 0})}constructor(){super({key:"spanSelector",name:"spanSelector",label:"Span selector",value:void 0})}}function yj(e,t){if(t){const n=e.services.get(t)||new Map;return Array.from(n.values()).sort(((e,t)=>gP(t.group,e.group))).map((({id:e,type:t,group:n})=>({value:e,text:`${t} (${n})`})))}return Array.from(e.profileMetrics.keys()).map((e=>WP(e))).sort(((e,t)=>gP(t.group,e.group))).map((({id:e,type:t,group:n})=>({value:e,text:`${t} (${n})`})))}function bj(e,t){if(t){const n=e.profileMetrics.get(t)||new Set;return Array.from(n).sort(gP).map((e=>({text:e,value:e})))}return Array.from(e.services.keys()).sort(gP).map((e=>({text:e,value:e})))}class vj{static build(e,t){const n=`${e}-${t.name}`,r=vj.cache.get(n);if(r instanceof t)return r;const i=new t({dataSourceUid:e});return vj.cache.set(n,i),i}}function wj(e){let t,n;for(const{name:r,value:i}of e)if("service_name"===r&&(t=i),"__profile_type__"===r&&(n=i),t&&n)return[t,n];return[]}function Sj(e){const t=new Map,n=new Map;if(!e.labelsSet)return Xi.warn("Pyroscope SeriesApiClient: no data received!"),{services:t,profileMetrics:n};for(const{labels:r}of e.labelsSet){const[e,i]=wj(r);if(!e||!i){Xi.warn('Pyroscope ServicesApiClient: "service_name" and/or "__profile_type__" are missing in the labels received!',r);continue}const a=t.get(e)||new Map;a.set(i,WP(i)),t.set(e,a);const o=n.get(i)||new Set;o.add(e),n.set(i,o)}return{services:t,profileMetrics:n}}function Ej(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(vj,"cache",new Map);class xj extends QC{list(e){var t,n=this;return(t=function*(){const{from:t,to:r}=e;return n.fetch("/querier.v1.QuerierService/Series",{method:"POST",body:JSON.stringify({start:t,end:r,labelNames:["service_name","__profile_type__"],matchers:[]})}).then((e=>e.json())).then(Sj)},function(){var e=this,n=arguments;return new Promise((function(r,i){var a=t.apply(e,n);function o(e){Ej(a,r,i,o,s,"next",e)}function s(e){Ej(a,r,i,o,s,"throw",e)}o(void 0)}))})()}constructor(e){super(e)}}function Oj(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}const _j=new class extends tk{list(e){var t,n=this;return(t=function*(){const{from:t,to:r}=VR(e.timeRange),i=[n.apiClient.baseUrl,t,r],a=n.cacheClient.get(i);if(a){const{services:e,profileMetrics:t}=yield a;return e.size||t.size||n.cacheClient.delete(i),{services:e,profileMetrics:t}}const o=n.apiClient.list({from:t,to:r});n.cacheClient.set(i,o);try{const{services:e,profileMetrics:t}=yield o;return{services:e,profileMetrics:t}}catch(e){throw n.cacheClient.delete(i),e}},function(){var e=this,n=arguments;return new Promise((function(r,i){var a=t.apply(e,n);function o(e){Oj(a,r,i,o,s,"next",e)}function s(e){Oj(a,r,i,o,s,"throw",e)}o(void 0)}))})()}constructor(e){super(e)}}({cacheClient:new JC});function Tj(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function Cj(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Tj(a,r,i,o,s,"next",e)}function s(e){Tj(a,r,i,o,s,"throw",e)}o(void 0)}))}}class kj extends Ph{fetchSeries(e,t,n){return Cj((function*(){_j.setApiClient(vj.build(e,xj));try{return yield _j.list({timeRange:t})}catch(e){throw Xi.error(e,{info:"Error while loading Pyroscope series!",variableName:n||""}),e}}))()}query(){return Cj((function*(){return{state:r.LoadingState.Done,data:[{name:"PyroscopeSeries",fields:[{name:"PyroscopeSeries",type:r.FieldType.other,values:[],config:{}}],length:0}]}}))()}metricFindQuery(e,t){var n=this;return Cj((function*(){var r,i,a;const o=null===(i=t.scopedVars)||void 0===i||null===(r=i.__sceneObject)||void 0===r?void 0:r.value,s=tm.interpolate(o,"$dataSource"),l=tm.interpolate(o,"$serviceName"),c=tm.interpolate(o,"$profileMetricId"),u=yield n.fetchSeries(s,t.range,null===(a=t.variable)||void 0===a?void 0:a.name);switch(e){case"$dataSource and all services":return bj(u);case"$dataSource and all profile metrics":return yj(u);case"$dataSource and only $profileMetricId services":return bj(u,c);case"$dataSource and only $serviceName profile metrics":return yj(u,l);default:throw new TypeError(`Unsupported query "${e}"!`)}}))()}testDatasource(){return Cj((function*(){return{status:"success",message:"OK"}}))()}constructor(){super(KP.type,KP.uid)}}class Pj extends r.BusEventWithPayload{}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(Pj,"type","enable-sync-timeranges");class Rj extends r.BusEventWithPayload{}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(Rj,"type","sync-refresh");class Aj extends r.BusEventWithPayload{}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(Aj,"type","sync-timeranges");class Dj extends fx{}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(Dj,"Component",(function({model:e}){const{hidePicker:t,isOnCanvas:n}=e.useState(),r=tm.getTimeRange(e),i=r.getTimeZone(),a=r.useState();return t?null:$i().createElement(o.TimeRangePicker,{isOnCanvas:null==n||n,value:a.value,onChange:r.onTimeRangeChange,timeZone:i,fiscalYearStartMonth:a.fiscalYearStartMonth,onMoveBackward:e.onMoveBackward,onMoveForward:e.onMoveForward,onZoom:e.onZoom,onChangeTimeZone:r.onTimeZoneChange,onChangeFiscalYearStartMonth:e.onChangeFiscalYearStartMonth,isSynced:!1})}));const jj=/^\d+[yYmMsSwWhHdD]$/;function Ij(e){if("string"!=typeof e)return null;if(-1!==e.indexOf("now"))return e;if(jj.test(e))return e;if(8===e.length){const t=(0,r.toUtc)(e,"YYYYMMDD");if(t.isValid())return t.toISOString()}else if(15===e.length){const t=(0,r.toUtc)(e,"YYYYMMDDTHHmmss");if(t.isValid())return t.toISOString()}else if(24===e.length){return(0,r.toUtc)(e).toISOString()}const t=parseInt(e,10);return isNaN(t)?null:(0,r.toUtc)(t).toISOString()}function Nj(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Lj(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}class Mj extends r.MutableDataFrame{addRange(e){this.add(Lj(function(e){for(var t=1;tthis.addField(e)))}}function Fj(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $j(e){for(var t=1;t{this.setState((0,$c.omit)(e,"key"))}))),this._subs.add(null===(e=this.getTimeseries().state.$data)||void 0===e?void 0:e.subscribeToState(((e,t)=>{var n,i,a,o,s,l;e.data&&e.data.state===r.LoadingState.Done&&((null===(n=e.data.annotations)||void 0===n?void 0:n.length)||(null===(a=t.data)||void 0===a||null===(i=a.annotations)||void 0===i?void 0:i.length)?!(null===(o=e.data.annotations)||void 0===o?void 0:o.length)&&(null===(l=t.data)||void 0===l||null===(s=l.annotations)||void 0===s?void 0:s.length)&&(e.data.annotations=t.data.annotations):this.updateTimeseriesAnnotation())})))}getAncestorTimeRange(){if(!this.parent||!this.parent.parent)throw new Error(typeof this+" must be used within $timeRange scope");return tm.getTimeRange(this.parent.parent)}getTimeseries(){try{const e=tm.getAncestor(this,_b);if("timeseries"!==e.state.pluginId)throw new TypeError("Incorrect VizPanel type!");return e}catch(e){throw new Error("Ancestor timeseries panel not found!")}}updateTimeseriesAnnotation(){const{annotationTimeRange:e,annotationColor:t,annotationTitle:n}=this.state,{$data:r}=this.getTimeseries().state,i=null==r?void 0:r.state.data;if(!i)return;const a=new Mj;a.addRange({color:t,text:n,time:1e3*e.from.unix(),timeEnd:1e3*e.to.unix()}),null==r||r.setState({data:Bj($j({},i),{annotations:[a]})})}setAnnotationTimeRange(e,t=!1){this.setState({annotationTimeRange:e}),t&&this.updateTimeseriesAnnotation()}nullifyAnnotationTimeRange(){this.setAnnotationTimeRange(zj)}getUrlState(){const{annotationTimeRange:e}=this.state;return{diffFrom:"string"==typeof e.raw.from?e.raw.from:e.raw.from.toISOString(),diffTo:"string"==typeof e.raw.to?e.raw.to:e.raw.to.toISOString()}}updateFromUrl(e){const{diffFrom:t,diffTo:n}=e;if(!n&&!t)return;const{annotationTimeRange:r}=this.state;var i,a;this.setAnnotationTimeRange(this.buildAnnotationTimeRange(null!==(i=Ij(t))&&void 0!==i?i:r.from,null!==(a=Ij(n))&&void 0!==a?a:r.to))}buildAnnotationTimeRange(e,t){return function(e,t,n,i,a){const o=a&&"now"===t;return{from:r.dateMath.parse(e,!1,n,i),to:r.dateMath.parse(o?"now-"+a:t,!0,n,i),raw:{from:e,to:t}}}(e,t,this.getTimeZone(),this.state.fiscalYearStartMonth,this.state.UNSAFE_nowDelay)}onTimeRangeChange(e){const{mode:t}=this.state;"default"!==t?this.setAnnotationTimeRange(e,!0):this.getAncestorTimeRange().onTimeRangeChange(e)}onTimeZoneChange(e){this.getAncestorTimeRange().onTimeZoneChange(e)}getTimeZone(){return this.getAncestorTimeRange().getTimeZone()}onRefresh(){this.getAncestorTimeRange().onRefresh()}constructor(e){super($j({from:zj.raw.from,to:zj.raw.to,value:zj,annotationTimeRange:zj},e)),Fj(this,"_variableDependency",new im(this,{variableNames:["dataSource","serviceName"],onReferencedVariableValueChanged:()=>{this.nullifyAnnotationTimeRange(),this.updateTimeseriesAnnotation()}})),Fj(this,"_urlSync",new Xh(this,{keys:["diffFrom","diffTo"]})),this.addActivationHandler(this.onActivate.bind(this))}}class qj extends r.BusEventWithPayload{}function Hj(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(qj,"type","switch-timerange-selection-mode");var Gj=function(e){return e.TIMEPICKER="timepicker",e.FLAMEGRAPH="flame-graph",e}({});class Wj extends bh{constructor(){super({mode:"flame-graph"}),Hj(this,"onChange",(e=>{this.setState({mode:e}),this.publishEvent(new qj({mode:e}),!0)}))}}Hj(Wj,"OPTIONS",[{label:"Time picker",value:"timepicker"},{label:"Flame graph",value:"flame-graph"}]),Hj(Wj,"Component",(({model:e})=>{const t=(0,o.useStyles2)(Qj),{mode:n}=e.useState();return $i().createElement("div",{className:t.container},$i().createElement("label",{className:t.label},$i().createElement("span",null,"Range selection mode "),$i().createElement(o.Tooltip,{content:$i().createElement("div",{className:t.tooltip},$i().createElement("div",null,"Use these buttons to change the behaviour when selecting a range with the mouse on the time series:"),$i().createElement("dl",null,$i().createElement("dt",null,"Time picker"),$i().createElement("dd",null,"Time range zoom in (default behaviour)"),$i().createElement("dt",null,"Flame graph"),$i().createElement("dd",null,"Time range for building the flame graph (the stack traces will be retrieved only for the selected range)"))),placement:"top"},$i().createElement(o.Icon,{name:"question-circle"}))),$i().createElement(o.RadioButtonGroup,{size:"sm",options:Wj.OPTIONS,value:n,onChange:e.onChange,"aria-label":"Range selection mode"}))}));const Qj=e=>({container:i.css` display: flex; flex-direction: column; `,tooltip:i.css` padding: ${e.spacing(1)}; & dl { margin-top: ${e.spacing(2)}; display: grid; grid-gap: ${e.spacing(1)} ${e.spacing(2)}; grid-template-columns: max-content; } & dt { font-weight: bold; } & dd { margin: 0; grid-column-start: 2; } `,label:i.css` font-size: 12px; text-align: right; margin-bottom: 2px; color: ${e.colors.text.secondary}; `});function Kj({filterKey:e}){return kR(new cy({datasource:QP,queries:[{refId:`$profileMetricId-$serviceName-${e}}`,queryType:"metrics",profileTypeId:"$profileMetricId",labelSelector:`{service_name="$serviceName",$${e}}`}]}))}var Yj=__webpack_require__(4308),Xj=__webpack_require__.n(Yj);const Jj={COLOR:Xj()("#d066d4"),OVERLAY:Xj()("#d066d4").alpha(.3)},Zj={COLOR:Xj()("#1398f6"),OVERLAY:Xj()("#1398f6").alpha(.3)};function eI(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tI(e){for(var t=1;t{o.unsubscribe()}}static buildTimeSeriesPanel({target:e,filterKey:t,title:n,color:i}){const a=new aA({item:{index:0,value:e,label:"",queryRunnerParams:{},panelType:ER.TIMESERIES},data:new Dw({$data:Kj({filterKey:t}),transformations:[AR,DR]}),overrides:e=>e.map((e=>{const t=e.fields[1],n=TR(e,"allValuesSum")||0,o=(0,r.getValueFormat)(t.config.unit)(n),s=`${o.text}${o.suffix}`,[l,c,u]=nI.getDiffRange(a),d=l&&c?`Total = ${s} / Flame graph range = ${(0,r.dateTimeFormat)(l,{format:r.systemDateFormats.fullDate,timeZone:u})} → ${(0,r.dateTimeFormat)(c,{format:r.systemDateFormats.fullDate,timeZone:u})}`:`Total = ${s}`;return{matcher:{id:r.FieldMatcherID.byFrameRefID,options:e.refId},properties:[{id:"displayName",value:d},{id:"color",value:{mode:"fixed",fixedColor:i}}]}})),headerActions:()=>[new Wj]});return a.state.body.setState({$timeRange:new Uj({key:`${e}-annotation-timerange`,mode:Vj.ANNOTATIONS,annotationColor:e===np.BASELINE?Jj.OVERLAY.toString():Zj.OVERLAY.toString(),annotationTitle:`${n} flame graph range`})}),a}static getDiffRange(e){var t,n,r,i;let a,o;const s=null===(r=e.state.body.state.$data)||void 0===r||null===(n=r.state.data)||void 0===n||null===(t=n.annotations)||void 0===t?void 0:t[0];return null==s||s.fields.some((({name:e,values:t})=>(a="time"===e?t[0]:a,o="timeEnd"===e?t[0]:o,a&&o))),[a,o,null===(i=e.state.$timeRange)||void 0===i?void 0:i.state.timeZone]}getAncestorTimeRange(){if(!this.parent||!this.parent.parent)throw new Error(typeof this+" must be used within $timeRange scope");return tm.getTimeRange(this.parent.parent)}subscribeToEvents(){const{target:e,timeseriesPanel:t,$timeRange:n}=this.state,r=t.state.body.state.$timeRange,i=this.subscribeToEvent(qj,(e=>{r.setState({mode:e.payload.mode===Gj.FLAMEGRAPH?Vj.ANNOTATIONS:Vj.DEFAULT})})),a=r.subscribeToState(((t,n)=>{this.state.timeRangeSyncEnabled&&t.annotationTimeRange!==n.annotationTimeRange&&this.publishEvent(new Aj({source:e,annotationTimeRange:t.annotationTimeRange}),!0)})),o=n.subscribeToState(((t,n)=>{t.from===n.from&&t.to===n.to||(this.updateTitle(""),this.state.timeRangeSyncEnabled&&this.publishEvent(new Aj({source:e,timeRange:t}),!0))}));return{unsubscribe(){o.unsubscribe(),a.unsubscribe(),i.unsubscribe()}}}buildTimeseriesTitle(){const e=wR(this,"profileMetricId"),{description:t}=WP(e);return t||ZR(e)}useDiffTimeRange(){return this.state.timeseriesPanel.state.body.state.$timeRange.useState()}applyPreset({from:e,to:t,diffFrom:n,diffTo:r,label:i}){this.setDiffRange({from:n,to:r}),this.setTimeRange(fj(e,t)),this.updateTitle(i)}setTimeRange(e){const{from:t,to:n}=this.state.$timeRange.state.value;t.isSame(e.value.from)&&n.isSame(e.value.to)||this.state.$timeRange.setState({from:e.from,to:e.to,value:e.value})}setDiffRange(e){const t=this.state.timeseriesPanel.state.body.state.$timeRange;if(null===e)return void t.nullifyAnnotationTimeRange();const{annotationTimeRange:n}=t.state,r=t.buildAnnotationTimeRange(e.from,e.to);n.from.isSame(r.from)&&n.to.isSame(r.to)||t.setAnnotationTimeRange(r,!0)}autoSelectDiffRange(e){const{$timeRange:t,target:n}=this.state,{from:i,to:a}=t.state.value;if(this.updateTitle(""),e)return void this.setDiffRange({from:i.toISOString(),to:a.toISOString()});const o=a.diff(i),s=Math.min(Math.round(.25*o),864e5);n===np.BASELINE?this.setDiffRange({from:i.toISOString(),to:(0,r.dateTime)(i).add(s).toISOString()}):this.setDiffRange({from:(0,r.dateTime)(a).subtract(s).toISOString(),to:a.toISOString()})}updateTitle(e=""){const t=this.state.target===np.BASELINE?"Baseline":"Comparison",n=e?`${t} (${e})`:t;this.setState({title:n})}toggleTimeRangeSync(e){this.setState({timeRangeSyncEnabled:e})}refreshTimeseries(){this.state.$timeRange.onRefresh()}constructor({target:e,useAncestorTimeRange:t,clearDiffRange:n,filters:r}){const i=e===np.BASELINE?"filtersBaseline":"filtersComparison",a=e===np.BASELINE?"Baseline":"Comparison",o=e===np.BASELINE?Jj.COLOR.toString():Zj.COLOR.toString();super({key:`${e}-panel`,target:e,filterKey:i,title:a,color:o,$timeRange:new sf(tI({key:`${e}-panel-timerange`},fj("now-1h","now"))),timePicker:new Dj({isOnCanvas:!0}),refreshPicker:new _x({isOnCanvas:!0}),timeseriesPanel:nI.buildTimeSeriesPanel({target:e,filterKey:i,title:a,color:o}),timeRangeSyncEnabled:!1}),eI(this,"_variableDependency",new im(this,{variableNames:["profileMetricId"],onReferencedVariableValueChanged:()=>{this.state.timeseriesPanel.updateItem({label:this.buildTimeseriesTitle()})}})),eI(this,"onClickTimeRangeSync",(()=>{const{target:e,timeRangeSyncEnabled:t,$timeRange:n,timeseriesPanel:r}=this.state,i=r.state.body.state.$timeRange;this.publishEvent(new Pj({source:e,enable:!t,timeRange:n.state,annotationTimeRange:i.state.annotationTimeRange}),!0)})),eI(this,"onClickRefresh",(()=>{this.publishEvent(new Rj({source:this.state.target}),!0)})),this.addActivationHandler(this.onActivate.bind(this,t,n,r))}}eI(nI,"Component",(({model:e})=>{const{target:t,color:n,title:r,timeseriesPanel:a,timePicker:s,refreshPicker:l,filterKey:c,timeRangeSyncEnabled:u}=e.useState(),d=(0,o.useStyles2)(rI,n),p=tm.findByKey(e,c);return $i().createElement("div",{className:d.panel,"data-testid":`panel-${t}`},$i().createElement("div",{className:d.panelHeader},$i().createElement("h6",null,$i().createElement("div",{className:d.colorCircle}),r),$i().createElement("div",{className:d.timeControls},$i().createElement(s.Component,{model:s}),$i().createElement("div",{onClick:e.onClickRefresh},$i().createElement(l.Component,{model:l})),$i().createElement(o.IconButton,{className:(0,i.cx)(d.syncButton,u&&"active"),name:"link","aria-label":u?"Unsync time ranges":"Sync time ranges",tooltip:u?"Unsync time ranges":"Sync time ranges",onClick:e.onClickTimeRangeSync}))),$i().createElement("div",{className:d.filter},$i().createElement(p.Component,{model:p})),$i().createElement("div",{className:d.timeseries},a&&$i().createElement(a.Component,{model:a})))}));const rI=(e,t)=>({panel:i.css` background-color: ${e.colors.background.primary}; padding: ${e.spacing(1)} ${e.spacing(1)} 0 ${e.spacing(1)}; border: 1px solid ${e.colors.border.weak}; border-radius: 2px; `,panelHeader:i.css` display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: ${e.spacing(2)}; flex-wrap: wrap; & > h6 { font-size: 15px; height: 32px; line-height: 32px; margin: 0 ${e.spacing(1)} 0 0; } `,colorCircle:i.css` display: inline-block; background-color: ${t}; border-radius: 50%; width: 9px; height: 9px; margin-right: 6px; `,timeControls:i.css` display: flex; justify-content: flex-end; gap: 4px; `,syncButton:i.css` z-index: unset; padding: ${e.spacing(0,1)}; margin: 0; background: ${e.colors.secondary.main}; border: 1px solid ${e.colors.secondary.border}; border-radius: ${e.shape.radius.default}; &:hover { background: ${e.colors.secondary.shade}; } &.active { color: ${e.colors.primary.text}; border: 1px solid ${e.colors.primary.text}; } `,filter:i.css` display: flex; margin-bottom: ${e.spacing(3)}; `,timeseries:i.css` height: 200px; & [data-viz-panel-key] > * { border: 0 none; } & [data-viz-panel-key] [data-testid='uplot-main-div'] { cursor: crosshair; } `});function iI(){const[e,t]=(0,Fi.useState)(null),[n,r]=(0,Fi.useState)();return{onOpen(e){r((()=>e))},isOpen:t=>t===e,open(e){t(e),null==n||n()},close(){t(null)}}}var aI=class extends P{#x;#C=void 0;#K;#Y;constructor(e,t){super(),this.#x=e,this.setOptions(t),this.bindMethods(),this.#X()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.#x.defaultMutationOptions(e),v(this.options,t)||this.#x.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#K,observer:this}),t?.mutationKey&&this.options.mutationKey&&g(t.mutationKey)!==g(this.options.mutationKey)?this.reset():"pending"===this.#K?.state.status&&this.#K.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#K?.removeObserver(this)}onMutationUpdate(e){this.#X(),this.#H(e)}getCurrentResult(){return this.#C}reset(){this.#K?.removeObserver(this),this.#K=void 0,this.#X(),this.#H()}mutate(e,t){return this.#Y=t,this.#K?.removeObserver(this),this.#K=this.#x.getMutationCache().build(this.#x,this.options),this.#K.addObserver(this),this.#K.execute(e)}#X(){const e=this.#K?.state??{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0};this.#C={...e,isPending:"pending"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset}}#H(e){k.batch((()=>{if(this.#Y&&this.hasListeners()){const t=this.#C.variables,n=this.#C.context;"success"===e?.type?(this.#Y.onSuccess?.(e.data,t,n),this.#Y.onSettled?.(e.data,null,t,n)):"error"===e?.type&&(this.#Y.onError?.(e.error,t,n),this.#Y.onSettled?.(void 0,e.error,t,n))}this.listeners.forEach((e=>{e(this.#C)}))}))}};const oI=Object.freeze({collapsedFlamegraphs:!1,maxNodes:16384,enableFlameGraphDotComExport:!0,enableFunctionDetails:!0});function sI(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function lI(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){sI(a,r,i,o,s,"next",e)}function s(e){sI(a,r,i,o,s,"throw",e)}o(void 0)}))}}class cI extends ua{get(){var e=this,t=()=>super.fetch;return lI((function*(){return t().call(e,"/settings.v1.SettingsService/Get",{method:"POST",body:JSON.stringify({})}).then((e=>e.json())).then((e=>{var t;const n=null===(t=e.settings)||void 0===t?void 0:t.find((({name:e})=>e===cI.PLUGIN_SETTING_NAME));return n?JSON.parse(n.value):{}}))}))()}set(e){var t=this,n=()=>super.fetch;return lI((function*(){return n().call(t,"/settings.v1.SettingsService/Set",{method:"POST",body:JSON.stringify({setting:{name:cI.PLUGIN_SETTING_NAME,value:JSON.stringify(e)}})}).then((e=>e.json()))}))()}}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(cI,"PLUGIN_SETTING_NAME","pluginSettings");const uI=new cI;function dI({enabled:e}={}){const{isFetching:t,error:n,data:r}=Pa({enabled:e,queryKey:["settings"],queryFn:()=>uI.get().then((e=>Object.keys(oI).reduce(((e,t)=>{var n,r,i;return null!==(i=(n=e)[r=t])&&void 0!==i||(n[r]=oI[t]),e}),e)))}),{mutateAsync:i}=function(e,t){const n=zi(t),[r]=Fi.useState((()=>new aI(n,e)));Fi.useEffect((()=>{r.setOptions(e)}),[r,e]);const i=Fi.useSyncExternalStore(Fi.useCallback((e=>r.subscribe(k.batchCalls(e))),[r]),(()=>r.getCurrentResult()),(()=>r.getCurrentResult())),a=Fi.useCallback(((e,t)=>{r.mutate(e,t).catch(Ea)}),[r]);if(i.error&&Sa(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}({mutationFn:e=>uI.set(e),networkMode:"always"});return{isFetching:t,error:uI.isAbortError(n)?null:n,settings:r,mutate:i}}function pI({severity:e,title:t,message:n,error:r,errorContext:i}){return r&&Xi.error(r,i),$i().createElement(o.Alert,{title:t,severity:e},r&&$i().createElement($i().Fragment,null,r.message,$i().createElement("br",null)),n)}const hI={RadioButton:{container:"data-testid radio-button"},Breadcrumbs:{breadcrumb:e=>`data-testid ${e} breadcrumb`},TimePicker:{openButton:"data-testid TimePicker Open Button",overlayContent:"data-testid TimePicker Overlay Content",fromField:"data-testid Time Range from field",toField:"data-testid Time Range to field",applyTimeRange:"data-testid TimePicker submit button",copyTimeRange:"data-testid TimePicker copy button",pasteTimeRange:"data-testid TimePicker paste button",calendar:{label:"data-testid Time Range calendar",openButton:"data-testid Open time range calendar",closeButton:"data-testid Close time range Calendar"},absoluteTimeRangeTitle:"data-testid-absolute-time-range-narrow"},DataSourcePermissions:{form:()=>'form[name="addPermission"]',roleType:"Role to add new permission to",rolePicker:"Built-in role picker",permissionLevel:"Permission Level"},DateTimePicker:{input:"data-testid date-time-input"},DataSource:{TestData:{QueryTab:{scenarioSelectContainer:"Test Data Query scenario select container",scenarioSelect:"Test Data Query scenario select",max:"TestData max",min:"TestData min",noise:"TestData noise",seriesCount:"TestData series count",spread:"TestData spread",startValue:"TestData start value",drop:"TestData drop values"}},DataSourceHttpSettings:{urlInput:"data-testid Datasource HTTP settings url"},Jaeger:{traceIDInput:"Trace ID"},Prometheus:{configPage:{connectionSettings:"Data source connection URL",manageAlerts:"prometheus-alerts-manager",scrapeInterval:"data-testid scrape interval",queryTimeout:"data-testid query timeout",defaultEditor:"data-testid default editor",disableMetricLookup:"disable-metric-lookup",prometheusType:"data-testid prometheus type",prometheusVersion:"data-testid prometheus version",cacheLevel:"data-testid cache level",incrementalQuerying:"prometheus-incremental-querying",queryOverlapWindow:"data-testid query overlap window",disableRecordingRules:"disable-recording-rules",customQueryParameters:"data-testid custom query parameters",httpMethod:"data-testid http method",exemplarsAddButton:"data-testid Add exemplar config button",internalLinkSwitch:"data-testid Internal link switch"},queryEditor:{explain:"data-testid prometheus explain switch wrapper",editorToggle:"data-testid QueryEditorModeToggle",options:"data-testid prometheus options",legend:"data-testid prometheus legend wrapper",format:"data-testid prometheus format",step:"prometheus-step",type:"data-testid prometheus type",exemplars:"prometheus-exemplars",builder:{metricSelect:"data-testid metric select",hints:"data-testid prometheus hints",metricsExplorer:"data-testid metrics explorer",queryAdvisor:"data-testid query advisor"},code:{queryField:"data-testid prometheus query field",metricsBrowser:{openButton:"data-testid open metrics browser",selectMetric:"data-testid select a metric",metricList:"data-testid metric list",labelNamesFilter:"data-testid label names filter",labelValuesFilter:"data-testid label values filter",useQuery:"data-testid use query",useAsRateQuery:"data-testid use as rate query",validateSelector:"data-testid validate selector",clear:"data-testid clear"}}},exemplarMarker:"data-testid Exemplar marker",variableQueryEditor:{queryType:"data-testid query type",labelnames:{metricRegex:"data-testid label names metric regex"},labelValues:{labelSelect:"data-testid label values label select"},metricNames:{metricRegex:"data-testid metric names metric regex"},varQueryResult:"data-testid variable query result",seriesQuery:"data-testid prometheus series query",classicQuery:"data-testid prometheus classic query"},annotations:{minStep:"prometheus-annotation-min-step",title:"data-testid prometheus annotation title",tags:"data-testid prometheus annotation tags",text:"data-testid prometheus annotation text",seriesValueAsTimestamp:"data-testid prometheus annotation series value as timestamp"}}},Menu:{MenuComponent:e=>`${e} menu`,MenuGroup:e=>`${e} menu group`,MenuItem:e=>`${e} menu item`,SubMenu:{container:"data-testid SubMenu container",icon:"data-testid SubMenu icon"}},Panels:{Panel:{title:e=>`data-testid Panel header ${e}`,headerItems:e=>`data-testid Panel header item ${e}`,menuItems:e=>`data-testid Panel menu item ${e}`,menu:e=>`data-testid Panel menu ${e}`,containerByTitle:e=>`${e} panel`,headerCornerInfo:e=>`Panel header ${e}`,status:e=>`data-testid Panel status ${e}`,loadingBar:()=>"Panel loading bar",HoverWidget:{container:"data-testid hover-header-container",dragIcon:"data-testid drag-icon"},PanelDataErrorMessage:"data-testid Panel data error message"},Visualization:{Graph:{container:"Graph container",VisualizationTab:{legendSection:"Legend section"},Legend:{legendItemAlias:e=>`gpl alias ${e}`,showLegendSwitch:"gpl show legend"},xAxis:{labels:()=>"div.flot-x-axis > div.flot-tick-label"}},BarGauge:{value:"Bar gauge value",valueV2:"data-testid Bar gauge value"},PieChart:{svgSlice:"data testid Pie Chart Slice"},Text:{container:()=>".markdown-html"},Table:{header:"table header",footer:"table-footer",body:"data-testid table body"}}},VizLegend:{seriesName:e=>`data-testid VizLegend series ${e}`},Drawer:{General:{title:e=>`Drawer title ${e}`,expand:"Drawer expand",contract:"Drawer contract",close:"data-testid Drawer close",rcContentWrapper:()=>".rc-drawer-content-wrapper",subtitle:"data-testid drawer subtitle"}},PanelEditor:{General:{content:"Panel editor content"},OptionsPane:{content:"Panel editor option pane content",select:"Panel editor option pane select",fieldLabel:e=>`${e} field property editor`},DataPane:{content:"Panel editor data pane content"},applyButton:"data-testid Apply changes and go back to dashboard",toggleVizPicker:"data-testid toggle-viz-picker",toggleVizOptions:"data-testid toggle-viz-options",toggleTableView:"toggle-table-view",showZoomField:"Map controls Show zoom control field property editor",showAttributionField:"Map controls Show attribution field property editor",showScaleField:"Map controls Show scale field property editor",showMeasureField:"Map controls Show measure tools field property editor",showDebugField:"Map controls Show debug field property editor",measureButton:"show measure tools"},PanelInspector:{Data:{content:"Panel inspector Data content"},Stats:{content:"Panel inspector Stats content"},Json:{content:"Panel inspector Json content"},Query:{content:"Panel inspector Query content",refreshButton:"Panel inspector Query refresh button",jsonObjectKeys:()=>".json-formatter-key"}},Tab:{title:e=>`Tab ${e}`,active:()=>'[class*="-activeTabStyle"]'},RefreshPicker:{runButton:"RefreshPicker run button",intervalButton:"RefreshPicker interval button",runButtonV2:"data-testid RefreshPicker run button",intervalButtonV2:"data-testid RefreshPicker interval button"},QueryTab:{content:"Query editor tab content",queryInspectorButton:"Query inspector button",queryHistoryButton:"data-testid query-history-button",addQuery:"data-testid query-tab-add-query"},QueryHistory:{queryText:"Query text"},QueryEditorRows:{rows:"Query editor row"},QueryEditorRow:{actionButton:e=>`data-testid ${e}`,title:e=>`Query editor row title ${e}`,container:e=>`Query editor row ${e}`},AlertTab:{content:"data-testid Alert editor tab content"},Alert:{alert:e=>`Alert ${e}`,alertV2:e=>`data-testid Alert ${e}`},TransformTab:{content:"data-testid Transform editor tab content",newTransform:e=>`data-testid New transform ${e}`,transformationEditor:e=>`data-testid Transformation editor ${e}`,transformationEditorDebugger:e=>`data-testid Transformation editor debugger ${e}`},Transforms:{card:e=>`data-testid New transform ${e}`,disableTransformationButton:"data-testid Disable transformation button",Reduce:{modeLabel:"data-testid Transform mode label",calculationsLabel:"data-testid Transform calculations label"},SpatialOperations:{actionLabel:"root Action field property editor",locationLabel:"root Location Mode field property editor",location:{autoOption:"Auto location option",coords:{option:"Coords location option",latitudeFieldLabel:"root Latitude field field property editor",longitudeFieldLabel:"root Longitude field field property editor"},geohash:{option:"Geohash location option",geohashFieldLabel:"root Geohash field field property editor"},lookup:{option:"Lookup location option",lookupFieldLabel:"root Lookup field field property editor",gazetteerFieldLabel:"root Gazetteer field property editor"}}},searchInput:"data-testid search transformations",noTransformationsMessage:"data-testid no transformations message",addTransformationButton:"data-testid add transformation button",removeAllTransformationsButton:"data-testid remove all transformations button"},NavBar:{Configuration:{button:"Configuration"},Toggle:{button:"data-testid Toggle menu"},Reporting:{button:"Reporting"}},NavMenu:{Menu:"data-testid navigation mega-menu",item:"data-testid Nav menu item"},NavToolbar:{container:"data-testid Nav toolbar"},PageToolbar:{container:()=>".page-toolbar",item:e=>`${e}`,itemButton:e=>`data-testid ${e}`},QueryEditorToolbarItem:{button:e=>`QueryEditor toolbar item button ${e}`},BackButton:{backArrow:"data-testid Go Back"},OptionsGroup:{group:e=>e?`Options group ${e}`:"Options group",toggle:e=>e?`Options group ${e} toggle`:"Options group toggle"},PluginVisualization:{item:e=>`Plugin visualization item ${e}`,current:()=>'[class*="-currentVisualizationItem"]'},Select:{option:"Select option",input:()=>'input[id*="time-options-input"]',singleValue:()=>'div[class*="-singleValue"]'},FieldConfigEditor:{content:"Field config editor content"},OverridesConfigEditor:{content:"Field overrides editor content"},FolderPicker:{container:"Folder picker select container",containerV2:"data-testid Folder picker select container",input:"data-testid folder-picker-input"},ReadonlyFolderPicker:{container:"data-testid Readonly folder picker select container"},DataSourcePicker:{container:"data-testid Data source picker select container",input:()=>'input[id="data-source-picker"]',inputV2:"data-testid Select a data source",dataSourceList:"data-testid Data source list dropdown",advancedModal:{dataSourceList:"data-testid Data source list",builtInDataSourceList:"data-testid Built in data source list"}},TimeZonePicker:{container:"Time zone picker select container",containerV2:"data-testid Time zone picker select container"},WeekStartPicker:{container:"Choose starting day of the week",containerV2:"data-testid Choose starting day of the week",placeholder:"Choose starting day of the week"},TraceViewer:{spanBar:"data-testid SpanBar--wrapper"},QueryField:{container:"data-testid Query field"},QueryBuilder:{queryPatterns:"data-testid Query patterns",labelSelect:"data-testid Select label",valueSelect:"data-testid Select value",matchOperatorSelect:"data-testid Select match operator"},ValuePicker:{button:e=>`data-testid Value picker button ${e}`,select:e=>`data-testid Value picker select ${e}`},Search:{section:"Search section",sectionV2:"data-testid Search section",items:"Search items",itemsV2:"data-testid Search items",cards:"data-testid Search cards",collapseFolder:e=>`data-testid Collapse folder ${e}`,expandFolder:e=>`data-testid Expand folder ${e}`,dashboardItem:e=>`${hI.Search.dashboardItems} ${e}`,dashboardCard:e=>`data-testid Search card ${e}`,folderHeader:e=>`data-testid Folder header ${e}`,folderContent:e=>`data-testid Folder content ${e}`,dashboardItems:"data-testid Dashboard search item"},DashboardLinks:{container:"data-testid Dashboard link container",dropDown:"data-testid Dashboard link dropdown",link:"data-testid Dashboard link"},LoadingIndicator:{icon:"data-testid Loading indicator"},CallToActionCard:{button:e=>`Call to action button ${e}`,buttonV2:e=>`data-testid Call to action button ${e}`},DataLinksContextMenu:{singleLink:"data-testid Data link"},CodeEditor:{container:"data-testid Code editor container"},DashboardImportPage:{textarea:"data-testid-import-dashboard-textarea",submit:"data-testid-load-dashboard"},ImportDashboardForm:{name:"data-testid-import-dashboard-title",submit:"data-testid-import-dashboard-submit"},PanelAlertTabContent:{content:"data-testid Unified alert editor tab content"},VisualizationPreview:{card:e=>`data-testid suggestion-${e}`},ColorSwatch:{name:"data-testid-colorswatch"},DashboardRow:{title:e=>`data-testid dashboard-row-title-${e}`},UserProfile:{profileSaveButton:"data-testid-user-profile-save",preferencesSaveButton:"data-testid-shared-prefs-save",orgsTable:"data-testid-user-orgs-table",sessionsTable:"data-testid-user-sessions-table",extensionPointTabs:"data-testid-extension-point-tabs",extensionPointTab:e=>`data-testid-extension-point-tab-${e}`},FileUpload:{inputField:"data-testid-file-upload-input-field",fileNameSpan:"data-testid-file-upload-file-name"},DebugOverlay:{wrapper:"debug-overlay"},OrgRolePicker:{input:"Role"},AnalyticsToolbarButton:{button:"Dashboard insights"},Variables:{variableOption:"data-testid variable-option"},Annotations:{annotationsTypeInput:"annotations-type-input",annotationsChoosePanelInput:"choose-panels-input"},Tooltip:{container:"data-testid tooltip"}},fI={pages:{Login:{url:"/login",username:"data-testid Username input field",password:"data-testid Password input field",submit:"data-testid Login button",skip:"data-testid Skip change password button"},Home:{url:"/"},DataSource:{name:"data-testid Data source settings page name input field",delete:"Data source settings page Delete button",readOnly:"data-testid Data source settings page read only message",saveAndTest:"data-testid Data source settings page Save and Test button",alert:"data-testid Data source settings page Alert"},DataSources:{url:"/datasources",dataSources:e=>`Data source list item ${e}`},EditDataSource:{url:e=>`/datasources/edit/${e}`,settings:"Datasource settings page basic settings"},AddDataSource:{url:"/datasources/new",dataSourcePlugins:e=>`Data source plugin item ${e}`,dataSourcePluginsV2:e=>`Add new data source ${e}`},ConfirmModal:{delete:"data-testid Confirm Modal Danger Button"},AddDashboard:{url:"/dashboard/new",itemButton:e=>`data-testid ${e}`,addNewPanel:"Add new panel",addNewRow:"Add new row",addNewPanelLibrary:"Add new panel from panel library"},Dashboard:{url:e=>`/d/${e}`,DashNav:{nav:"Dashboard navigation",navV2:"data-testid Dashboard navigation",publicDashboardTag:"data-testid public dashboard tag",shareButton:"data-testid share-button"},SubMenu:{submenu:"Dashboard submenu",submenuItem:"data-testid template variable",submenuItemLabels:e=>`data-testid Dashboard template variables submenu Label ${e}`,submenuItemValueDropDownValueLinkTexts:e=>`data-testid Dashboard template variables Variable Value DropDown value link text ${e}`,submenuItemValueDropDownDropDown:"Variable options",submenuItemValueDropDownOptionTexts:e=>`data-testid Dashboard template variables Variable Value DropDown option text ${e}`,Annotations:{annotationsWrapper:"data-testid annotation-wrapper",annotationLabel:e=>`data-testid Dashboard annotations submenu Label ${e}`,annotationToggle:e=>`data-testid Dashboard annotations submenu Toggle ${e}`}},Settings:{Actions:{close:"data-testid dashboard-settings-close"},General:{deleteDashBoard:"Dashboard settings page delete dashboard button",sectionItems:e=>`Dashboard settings section item ${e}`,saveDashBoard:"Dashboard settings aside actions Save button",saveAsDashBoard:"Dashboard settings aside actions Save As button",timezone:"Time zone picker select container",title:"Tab General"},Annotations:{List:{addAnnotationCTA:hI.CallToActionCard.button("Add annotation query"),addAnnotationCTAV2:hI.CallToActionCard.buttonV2("Add annotation query"),annotations:"data-testid list-annotations"},Settings:{name:"Annotations settings name input"},NewAnnotation:{panelFilterSelect:"data-testid annotations-panel-filter",showInLabel:"show-in-label",previewInDashboard:"data-testid annotations-preview",delete:"data-testid annotations-delete",apply:"data-testid annotations-apply",enable:"data-testid annotation-enable",hide:"data-testid annotation-hide"}},Variables:{List:{addVariableCTA:hI.CallToActionCard.button("Add variable"),addVariableCTAV2:hI.CallToActionCard.buttonV2("Add variable"),newButton:"Variable editor New variable button",table:"Variable editor Table",tableRowNameFields:e=>`Variable editor Table Name field ${e}`,tableRowDefinitionFields:e=>`Variable editor Table Definition field ${e}`,tableRowArrowUpButtons:e=>`Variable editor Table ArrowUp button ${e}`,tableRowArrowDownButtons:e=>`Variable editor Table ArrowDown button ${e}`,tableRowDuplicateButtons:e=>`Variable editor Table Duplicate button ${e}`,tableRowRemoveButtons:e=>`Variable editor Table Remove button ${e}`},Edit:{General:{headerLink:"Variable editor Header link",modeLabelNew:"Variable editor Header mode New",modeLabelEdit:"Variable editor Header mode Edit",generalNameInput:"Variable editor Form Name field",generalNameInputV2:"data-testid Variable editor Form Name field",generalTypeSelect:"Variable editor Form Type select",generalTypeSelectV2:"data-testid Variable editor Form Type select",generalLabelInput:"Variable editor Form Label field",generalLabelInputV2:"data-testid Variable editor Form Label field",generalHideSelect:"Variable editor Form Hide select",generalHideSelectV2:"data-testid Variable editor Form Hide select",selectionOptionsMultiSwitch:"data-testid Variable editor Form Multi switch",selectionOptionsIncludeAllSwitch:"data-testid Variable editor Form IncludeAll switch",selectionOptionsCustomAllInput:"data-testid Variable editor Form IncludeAll field",previewOfValuesOption:"data-testid Variable editor Preview of Values option",submitButton:"data-testid Variable editor Run Query button",applyButton:"data-testid Variable editor Apply button"},QueryVariable:{queryOptionsDataSourceSelect:hI.DataSourcePicker.inputV2,queryOptionsRefreshSelect:"Variable editor Form Query Refresh select",queryOptionsRefreshSelectV2:"data-testid Variable editor Form Query Refresh select",queryOptionsRegExInput:"Variable editor Form Query RegEx field",queryOptionsRegExInputV2:"data-testid Variable editor Form Query RegEx field",queryOptionsSortSelect:"Variable editor Form Query Sort select",queryOptionsSortSelectV2:"data-testid Variable editor Form Query Sort select",queryOptionsQueryInput:"data-testid Variable editor Form Default Variable Query Editor textarea",valueGroupsTagsEnabledSwitch:"Variable editor Form Query UseTags switch",valueGroupsTagsTagsQueryInput:"Variable editor Form Query TagsQuery field",valueGroupsTagsTagsValuesQueryInput:"Variable editor Form Query TagsValuesQuery field"},ConstantVariable:{constantOptionsQueryInput:"Variable editor Form Constant Query field",constantOptionsQueryInputV2:"data-testid Variable editor Form Constant Query field"},DatasourceVariable:{datasourceSelect:"data-testid datasource variable datasource type"},TextBoxVariable:{textBoxOptionsQueryInput:"Variable editor Form TextBox Query field",textBoxOptionsQueryInputV2:"data-testid Variable editor Form TextBox Query field"},CustomVariable:{customValueInput:"data-testid custom-variable-input"},IntervalVariable:{intervalsValueInput:"data-testid interval variable intervals input",autoEnabledCheckbox:"data-testid interval variable auto value checkbox",stepCountIntervalSelect:"data-testid interval variable step count input",minIntervalInput:"data-testid interval variable mininum interval input"},GroupByVariable:{dataSourceSelect:hI.DataSourcePicker.inputV2,infoText:"data-testid group by variable info text",modeToggle:"data-testid group by variable mode toggle"},AdHocFiltersVariable:{datasourceSelect:hI.DataSourcePicker.inputV2,infoText:"data-testid ad-hoc filters variable info text"}}}},Annotations:{marker:"data-testid annotation-marker"},Rows:{Repeated:{ConfigSection:{warningMessage:"data-testid Repeated rows warning message"}}}},Dashboards:{url:"/dashboards",dashboards:e=>`Dashboard search item ${e}`},SaveDashboardAsModal:{newName:"Save dashboard title field",save:"Save dashboard button"},SaveDashboardModal:{save:"Dashboard settings Save Dashboard Modal Save button",saveVariables:"Dashboard settings Save Dashboard Modal Save variables checkbox",saveTimerange:"Dashboard settings Save Dashboard Modal Save timerange checkbox"},SharePanelModal:{linkToRenderedImage:"Link to rendered image"},ShareDashboardModal:{PublicDashboard:{Tab:"Tab Public dashboard",WillBePublicCheckbox:"data-testid public dashboard will be public checkbox",LimitedDSCheckbox:"data-testid public dashboard limited datasources checkbox",CostIncreaseCheckbox:"data-testid public dashboard cost may increase checkbox",PauseSwitch:"data-testid public dashboard pause switch",EnableAnnotationsSwitch:"data-testid public dashboard on off switch for annotations",CreateButton:"data-testid public dashboard create button",DeleteButton:"data-testid public dashboard delete button",CopyUrlInput:"data-testid public dashboard copy url input",CopyUrlButton:"data-testid public dashboard copy url button",SettingsDropdown:"data-testid public dashboard settings dropdown",TemplateVariablesWarningAlert:"data-testid public dashboard disabled template variables alert",UnsupportedDataSourcesWarningAlert:"data-testid public dashboard unsupported data sources alert",NoUpsertPermissionsWarningAlert:"data-testid public dashboard no upsert permissions alert",EnableTimeRangeSwitch:"data-testid public dashboard on off switch for time range",EmailSharingConfiguration:{Container:"data-testid email sharing config container",ShareType:"data-testid public dashboard share type",EmailSharingInput:"data-testid public dashboard email sharing input",EmailSharingInviteButton:"data-testid public dashboard email sharing invite button",EmailSharingList:"data-testid public dashboard email sharing list",DeleteEmail:"data-testid public dashboard delete email button",ReshareLink:"data-testid public dashboard reshare link button"}}},PublicDashboard:{page:"public-dashboard-page",NotAvailable:{container:"public-dashboard-not-available",title:"public-dashboard-title",pausedDescription:"public-dashboard-paused-description"}},RequestViewAccess:{form:"request-view-access-form",recipientInput:"request-view-access-recipient-input",submitButton:"request-view-access-submit-button"},PublicDashboardConfirmAccess:{submitButton:"data-testid confirm-access-submit-button"},Explore:{url:"/explore",General:{container:"data-testid Explore",graph:"Explore Graph",table:"Explore Table",scrollView:"data-testid explorer scroll view"}},SoloPanel:{url:e=>`/d-solo/${e}`},PluginsList:{page:"Plugins list page",list:"Plugins list",listItem:"Plugins list item",signatureErrorNotice:"data-testid Unsigned plugins notice"},PluginPage:{page:"Plugin page",signatureInfo:"data-testid Plugin signature info",disabledInfo:"data-testid Plugin disabled info"},PlaylistForm:{name:"Playlist name",interval:"Playlist interval",itemDelete:"data-testid playlist-form-delete-item"},BrowseDashboards:{table:{body:"data-testid browse-dashboards-table",row:e=>`data-testid browse dashboards row ${e}`,checkbox:e=>`data-testid ${e} checkbox`},NewFolderForm:{form:"data-testid new folder form",nameInput:"data-testid new-folder-name-input",createButton:"data-testid new-folder-create-button"}},Search:{url:"/?search=openn",FolderView:{url:"/?search=open&layout=folders"}},PublicDashboards:{ListItem:{linkButton:"public-dashboard-link-button",configButton:"public-dashboard-configuration-button",trashcanButton:"public-dashboard-remove-button",pauseSwitch:"data-testid public dashboard pause switch"}},UserListPage:{tabs:{allUsers:"data-testid all-users-tab",orgUsers:"data-testid org-users-tab",anonUserDevices:"data-testid anon-user-devices-tab",publicDashboardsUsers:"data-testid public-dashboards-users-tab",users:"data-testid users-tab"},org:{url:"/org/users"},admin:{url:"/admin/users"},publicDashboards:{container:"data-testid public-dashboards-users-list"},UserListAdminPage:{container:"data-testid user-list-admin-page"},UsersListPage:{container:"data-testid users-list-page"},UserAnonListPage:{container:"data-testid user-anon-list-page"},UsersListPublicDashboardsPage:{container:"data-testid users-list-public-dashboards-page",DashboardsListModal:{listItem:e=>`data-testid dashboards-list-item-${e}`}}},ProfilePage:{url:"/profile"}},components:hI};function mI({children:e,delay:t}){const[n,r]=(0,Fi.useState)(!1);return(0,Fi.useEffect)((()=>{window.setTimeout((()=>{r(!0)}),t)}),[e,t]),$i().createElement($i().Fragment,null,n?e:null)}function gI({menu:e,title:t,placement:n="bottom",offset:r,dragClassCancel:a,menuButtonClass:s,onVisibleChange:l,onOpenMenu:c}){const u=t?fI.components.Panels.Panel.menu(t):"panel-menu-button",d=(0,Fi.useCallback)((e=>(e&&c&&c(),l)),[c,l]),p=t?`Menu for panel with title ${t}`:"Menu for panel with no title";return $i().createElement(o.Dropdown,{overlay:e,placement:n,offset:r,onVisibleChange:d},$i().createElement(o.ToolbarButton,{"aria-label":p,title:"Menu",icon:"ellipsis-v",iconSize:"md",narrow:!0,"data-testid":u,className:(0,i.cx)(s,a)}))}function yI({menu:e,title:t,dragClass:n,children:r,offset:a=-32,onOpenMenu:s}){const l=(0,o.useStyles2)(bI),c=(0,Fi.useRef)(null),u=fI.components.Panels.Panel.HoverWidget,d=(0,Fi.useCallback)((e=>{var t;null===(t=c.current)||void 0===t||t.setPointerCapture(e.pointerId)}),[]),p=(0,Fi.useCallback)((e=>{var t;null===(t=c.current)||void 0===t||t.releasePointerCapture(e.pointerId)}),[]),[h,f]=(0,Fi.useState)(!1);return void 0===r||0===$i().Children.count(r)?null:$i().createElement("div",{className:(0,i.cx)(l.container,{"show-on-hover":!h}),style:{top:`${a}px`},"data-testid":u.container},n&&$i().createElement("div",{className:(0,i.cx)(l.square,l.draggable,n),onPointerDown:d,onPointerUp:p,ref:c,"data-testid":u.dragIcon},$i().createElement(o.Icon,{name:"expand-arrows",className:l.draggableIcon})),!t&&$i().createElement("h6",{className:(0,i.cx)(l.untitled,{[l.draggable]:!!n},n)},"Untitled"),r,e&&$i().createElement(gI,{menu:e,title:t,placement:"bottom",menuButtonClass:l.menuButton,onVisibleChange:f,onOpenMenu:s}))}function bI(e){return{hidden:(0,i.css)({visibility:"hidden",opacity:"0"}),container:(0,i.css)({label:"hover-container-widget",transition:"all .1s linear",display:"flex",position:"absolute",zIndex:1,right:0,boxSizing:"content-box",alignItems:"center",background:e.colors.background.secondary,color:e.colors.text.primary,border:`1px solid ${e.colors.border.weak}`,borderRadius:e.shape.radius.default,height:e.spacing(4),boxShadow:e.shadows.z1}),square:(0,i.css)({display:"flex",justifyContent:"center",alignItems:"center",width:e.spacing(4),height:"100%"}),draggable:(0,i.css)({cursor:"move",[e.breakpoints.down("md")]:{display:"none"}}),menuButton:(0,i.css)({background:"inherit",border:"none","&:hover":{background:e.colors.secondary.main}}),untitled:(0,i.css)({color:e.colors.text.disabled,fontStyle:"italic",padding:e.spacing(0,1),marginBottom:0}),draggableIcon:(0,i.css)({transform:"rotate(45deg)",color:e.colors.text.secondary,"&:hover":{color:e.colors.text.primary}})}}function vI(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wI(e){for(var t=1;t=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}const xI=(0,Fi.forwardRef)(((e,t)=>{var{className:n,children:r,href:a,onClick:s,target:l,title:c}=e,u=EI(e,["className","children","href","onClick","target","title"]);const d=(0,o.useStyles2)(OI);return a?$i().createElement("a",wI({ref:t,href:a,onClick:s,target:l,title:c,className:(0,i.cx)(d.linkItem,n)},u),r):s?$i().createElement(o.Button,{ref:t,className:(0,i.cx)(d.item,n),variant:"secondary",fill:"text",onClick:s},r):$i().createElement("span",wI({ref:t,className:(0,i.cx)(d.item,n)},u),r)}));xI.displayName="TitleItem";const OI=e=>{const t=(0,i.css)({color:`${e.colors.text.secondary}`,label:"panel-header-item",cursor:"auto",border:"none",borderRadius:`${e.shape.radius.default}`,padding:`${e.spacing(0,1)}`,height:`${e.spacing(e.components.panel.headerHeight)}`,display:"flex",alignItems:"center",justifyContent:"center","&:focus, &:focus-visible":SI(wI({},_I(e)),{zIndex:1}),"&: focus:not(:focus-visible)":{outline:"none",boxShadow:"none"},"&:hover ":{boxShadow:`${e.shadows.z1}`,background:`${e.colors.background.secondary}`,color:`${e.colors.text.primary}`}});return{item:t,linkItem:(0,i.cx)(t,(0,i.css)({cursor:"pointer"}))}};function _I(e){return{outline:"2px dotted transparent",outlineOffset:"2px",boxShadow:`0 0 0 2px ${e.colors.background.canvas}, 0 0 0px 4px ${e.colors.primary.main}`,transitionTimingFunction:"cubic-bezier(0.19, 1, 0.22, 1)",transitionDuration:"0.2s",transitionProperty:"outline, outline-offset, box-shadow"}}function TI({description:e,className:t}){const n=(0,o.useStyles2)(CI);return""!==e?$i().createElement(o.Tooltip,{interactive:!0,content:()=>{const t="function"==typeof e?e():e;return $i().createElement("div",{className:"panel-info-content markdown-html"},$i().createElement("div",{dangerouslySetInnerHTML:{__html:t}}))}},$i().createElement(xI,{className:(0,i.cx)(t,n.description)},$i().createElement(o.Icon,{name:"info-circle",size:"md"}))):null}const CI=()=>({description:(0,i.css)({code:{whiteSpace:"normal",wordWrap:"break-word"},"pre > code":{display:"block"}})});function kI({message:e,onClick:t,ariaLabel:n="status"}){const r=(0,o.useStyles2)(PI);return $i().createElement(o.ToolbarButton,{className:r.buttonStyles,onClick:t,variant:"destructive",icon:"exclamation-triangle",iconSize:"md",tooltip:e||"","aria-label":n})}const PI=e=>{const{headerHeight:t,padding:n}=e.components.panel;return{buttonStyles:(0,i.css)({label:"panel-header-state-button",display:"flex",alignItems:"center",justifyContent:"center",padding:e.spacing(n),width:e.spacing(t),height:e.spacing(t),borderRadius:e.shape.radius.default})}};function RI({children:e,padding:t="md",title:n="",description:a="",displayMode:s="default",titleItems:l,menu:c,dragClass:u,dragClassCancel:d,hoverHeader:p=!1,hoverHeaderOffset:h,loadingState:f,statusMessage:m,statusMessageOnClick:g,actions:y,onCancelQuery:b,onOpenMenu:v}){const w=(0,o.useTheme2)(),S=(0,o.useStyles2)(II),[E,x]=(0,Fi.useState)(0),O=(0,Fi.useRef)(null);(0,Fi.useEffect)((()=>{O.current&&x(O.current.offsetWidth)}),[O]);const _=!p,T=DI(w,_),{contentStyle:C}=jI(t,w),k={height:T,cursor:u?"move":"auto"},P={};"transparent"===s&&(P.backgroundColor="transparent",P.border="none");const R=n?fI.components.Panels.Panel.title(n):"Panel",A=$i().createElement($i().Fragment,null,n&&$i().createElement("h6",{title:n,className:S.title},n),$i().createElement("div",{className:(0,i.cx)(S.titleItems,d),"data-testid":"title-items-container"},$i().createElement(TI,{description:a,className:d}),l),f===r.LoadingState.Streaming&&$i().createElement(o.Tooltip,{content:b?"Stop streaming":"Streaming"},$i().createElement(xI,{className:d,"data-testid":"panel-streaming",onClick:b},$i().createElement(o.Icon,{name:"circle-mono",size:"md",className:S.streaming}))),f===r.LoadingState.Loading&&b&&$i().createElement(mI,{delay:2e3},$i().createElement(o.Tooltip,{content:"Cancel query"},$i().createElement(xI,{className:(0,i.cx)(d,S.pointer),"data-testid":"panel-cancel-query",onClick:b},$i().createElement(o.Icon,{name:"sync-slash",size:"md"})))),$i().createElement("div",{className:S.rightAligned},y&&$i().createElement("div",{className:S.rightActions},AI(y,(e=>e)))));return $i().createElement("div",{className:S.container,style:P,"data-testid":R},$i().createElement("div",{className:S.loadingBarContainer},f===r.LoadingState.Loading?$i().createElement(o.LoadingBar,{width:E,ariaLabel:"Panel loading bar"}):null),p&&$i().createElement($i().Fragment,null,$i().createElement(yI,{menu:c,title:n,offset:h,dragClass:u,onOpenMenu:v},A),m&&$i().createElement("div",{className:S.errorContainerFloating},$i().createElement(kI,{message:m,onClick:g,ariaLabel:"Panel status"}))),_&&$i().createElement("div",{className:(0,i.cx)(S.headerContainer,u),style:k,"data-testid":"header-container"},m&&$i().createElement("div",{className:d},$i().createElement(kI,{message:m,onClick:g,ariaLabel:"Panel status"})),A,c&&$i().createElement(gI,{menu:c,title:n,placement:"bottom-end",menuButtonClass:(0,i.cx)(S.menuItem,d,"show-on-hover"),onOpenMenu:v})),$i().createElement("div",{className:S.content,style:C,ref:O},e))}const AI=(e,t)=>{const n=$i().Children.toArray(e).filter(Boolean);return n.length>0?t(n):null},DI=(e,t)=>t?e.spacing.gridSize*e.components.panel.headerHeight:0,jI=(e,t)=>({contentStyle:{padding:("md"===e?t.components.panel.padding:0)*t.spacing.gridSize}}),II=e=>{const{background:t,borderColor:n,padding:r}=e.components.panel;return{container:(0,i.css)({label:"panel-container",backgroundColor:t,border:`1px solid ${n}`,position:"relative",borderRadius:e.shape.radius.default,height:"100%",display:"flex",flexDirection:"column",".show-on-hover":{visibility:"hidden",opacity:"0"},"&:focus-visible, &:hover":{".show-on-hover":{visibility:"visible",opacity:"1"}},"&:focus-visible":{outline:`1px solid ${e.colors.action.focus}`},"&:focus-within":{".show-on-hover":{visibility:"visible",opacity:"1"}}}),loadingBarContainer:(0,i.css)({label:"panel-loading-bar-container",position:"absolute",top:0,width:"100%",overflow:"hidden"}),content:(0,i.css)({label:"panel-content",flexGrow:1}),headerContainer:(0,i.css)({label:"panel-header",display:"flex",alignItems:"center"}),pointer:(0,i.css)({cursor:"pointer"}),streaming:(0,i.css)({label:"panel-streaming",marginRight:0,color:e.colors.success.text,"&:hover":{color:e.colors.success.text}}),title:(0,i.css)({label:"panel-title",marginBottom:0,padding:e.spacing(0,r),textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",fontSize:e.typography.h6.fontSize,fontWeight:e.typography.h6.fontWeight}),items:(0,i.css)({display:"flex"}),item:(0,i.css)({display:"flex",justifyContent:"center",alignItems:"center"}),hiddenMenu:(0,i.css)({visibility:"hidden"}),menuItem:(0,i.css)({label:"panel-menu",border:"none",background:e.colors.secondary.main,"&:hover":{background:e.colors.secondary.shade}}),errorContainerFloating:(0,i.css)({label:"error-container",position:"absolute",left:0,top:0,zIndex:e.zIndex.tooltip}),rightActions:(0,i.css)({display:"flex",padding:e.spacing(0,r),gap:e.spacing(1)}),rightAligned:(0,i.css)({label:"right-aligned-container",marginLeft:"auto",display:"flex",alignItems:"center"}),titleItems:(0,i.css)({display:"flex",height:"100%"})}},NI=e=>({panelWrap:i.css` margin-bottom: ${e.spacing(1)}; `});function LI({isLoading:e,title:t,description:n,children:i,className:a="",headerActions:s,dataTestId:l}){const c=(0,o.useStyles2)(NI),u=e?r.LoadingState.Loading:r.LoadingState.Done;return $i().createElement("div",{className:`${a} ${c.panelWrap}`,"data-testid":l||"panel"},$i().createElement(RI,{loadingState:u,title:t,description:n,actions:s},i))}function MI(e,t){return Fb((function(n,r){var i=0;n.subscribe(yv(r,(function(n){return e.call(t,n,i++)&&r.next(n)})))}))}function FI(e,t){return Fb(function(e,t,n,r,i){return function(a,o){var s=n,l=t,c=0;a.subscribe(yv(o,(function(t){var n=c++;l=s?e(l,t,n):(s=!0,t),r&&o.next(l)}),i&&function(){s&&o.next(l),o.complete()}))}}(e,t,arguments.length>=2,!0))}const $I={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};var BI,VI=new Uint8Array(16);function zI(){if(!BI&&!(BI="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return BI(VI)}for(var UI=[],qI=0;qI<256;++qI)UI.push((qI+256).toString(16).slice(1));function HI(e,t=0){return(UI[e[t+0]]+UI[e[t+1]]+UI[e[t+2]]+UI[e[t+3]]+"-"+UI[e[t+4]]+UI[e[t+5]]+"-"+UI[e[t+6]]+UI[e[t+7]]+"-"+UI[e[t+8]]+UI[e[t+9]]+"-"+UI[e[t+10]]+UI[e[t+11]]+UI[e[t+12]]+UI[e[t+13]]+UI[e[t+14]]+UI[e[t+15]]).toLowerCase()}const GI=function(e,t,n){if($I.randomUUID&&!t&&!e)return $I.randomUUID();var r=(e=e||{}).random||(e.rng||zI)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return HI(r)};var WI=__webpack_require__(8449);const QI="grafana-llm-app",KI=`/api/plugins/${QI}`;let YI=new WI.SemVer("0.2.0");const XI="openai/v1/chat/completions";function JI(e){return"error"in e}function ZI(){return(0,qp.pipe)((0,qp.pipe)(MI((e=>"content"in e.choices[0].delta)),vv((e=>e.choices[0].delta.content))),FI(((e,t)=>e+t),""))}function eN(e){const t={scope:r.LiveChannelScope.Plugin,namespace:QI,path:XI+"/"+GI(),data:e};return(0,a.getGrafanaLiveSrv)().getStream(t).pipe(MI((e=>(0,r.isLiveChannelMessageEvent)(e)))).pipe(function(e,t,n){var r=Mb(e)||t||n?{next:e,error:t,complete:n}:e;return r?Fb((function(e,t){var n;null===(n=r.subscribe)||void 0===n||n.call(r);var i=!0;e.subscribe(yv(t,(function(e){var n;null===(n=r.next)||void 0===n||n.call(r,e),t.next(e)}),(function(){var e;i=!1,null===(e=r.complete)||void 0===e||e.call(r),t.complete()}),(function(e){var n;i=!1,null===(n=r.error)||void 0===n||n.call(r,e),t.error(e)}),(function(){var e,t;i&&(null===(e=r.unsubscribe)||void 0===e||e.call(r)),null===(t=r.finalize)||void 0===t||t.call(r)})))})):Ev}((e=>{if(JI(e.message))throw new Error(e.message.error)})),(n=e=>{return JI(e.message)||!("done"in(t=e.message.choices[0].delta)&&null!=t.done);var t},void 0===i&&(i=!1),Fb((function(e,t){var r=0;e.subscribe(yv(t,(function(e){var a=n(e,r++);(a||i)&&t.next(e),!a&&t.complete()})))}))),vv((e=>e.message)));var n,i}let tN=!1;const nN=async()=>{try{if(!(await(0,a.getBackendSrv)().get(`${KI}/settings`,void 0,void 0,{showSuccessAlert:!1,showErrorAlert:!1})).enabled)return{configured:!1,ok:!1,error:"The Grafana LLM plugin is not enabled."}}catch(e){return(0,a.logDebug)(String(e)),(0,a.logDebug)("Failed to check if OpenAI is enabled. This is expected if the Grafana LLM plugin is not installed, and the above error can be ignored."),tN=!0,{configured:!1,ok:!1,error:"The Grafana LLM plugin is not installed."}}let e;try{e=await(0,a.getBackendSrv)().get(`${KI}/health`,void 0,void 0,{showSuccessAlert:!1,showErrorAlert:!1})}catch(e){return tN||((0,a.logDebug)(String(e)),(0,a.logDebug)("Failed to check if OpenAI is enabled. This is expected if the Grafana LLM plugin is not installed, and the above error can be ignored."),tN=!0),{configured:!1,ok:!1,error:"The Grafana LLM plugin is not installed."}}const{details:t}=e;return void 0!==t?.version&&function(e){try{YI=new WI.SemVer(e)}catch(e){(0,a.logWarning)("Failed to parse version of grafana-llm-app; assuming old version is present.")}}(t.version),void 0===t?.openAI?{configured:!1,ok:!1,error:"The Grafana LLM plugin is outdated; please update it."}:"boolean"==typeof t.openAI?{configured:t.openAI,ok:t.openAI}:t.openAI},rN=async()=>{const e=await nN();return e.configured&&e.ok};function iN({children:e,onClick:t,disabled:n,interactionName:r}){const i=(0,o.useStyles2)(aN),{isEnabled:a,error:s,isFetching:l}=function(){const{data:e,isFetching:t,error:n}=Pa({queryKey:["llm"],queryFn:()=>rN()});return n&&Xi.error(n,{info:"Error while checking the status of the Grafana LLM plugin!"}),{isEnabled:Boolean(e),isFetching:t,error:n}}();let c="ai",u="";return l?(c="fa fa-spinner",u="Checking the status of the Grafana LLM plugin..."):s?(c="exclamation-triangle",u="Error while checking the status of the Grafana LLM plugin!"):a||(c="shield-exclamation",u="Grafana LLM plugin missing or not configured! Please check the plugins administration page."),$i().createElement(o.Button,{className:i.aiButton,size:"md",fill:"text",icon:c,disabled:!a||n,tooltip:u,tooltipPlacement:"top",onClick:e=>{Ts(r),t(e)}},e)}const aN=()=>({aiButton:i.css` padding: 0 4px; `});function oN(){return oN=Object.assign?Object.assign.bind():function(e){for(var t=1;t(e[t.toLowerCase()]=t,e)),{for:"htmlFor"}),dN={amp:"&",apos:"'",gt:">",lt:"<",nbsp:" ",quot:"“"},pN=["style","script"],hN=/([-A-Z0-9_:]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|(?:\{((?:\\.|{[^}]*?}|[^}])*)\})))?/gi,fN=/mailto:/i,mN=/\n{2,}$/,gN=/^(\s*>[\s\S]*?)(?=\n{2,})/,yN=/^ *> ?/gm,bN=/^ {2,}\n/,vN=/^(?:( *[-*_])){3,} *(?:\n *)+\n/,wN=/^\s*(`{3,}|~{3,}) *(\S+)?([^\n]*?)?\n([\s\S]+?)\s*\1 *(?:\n *)*\n?/,SN=/^(?: {4}[^\n]+\n*)+(?:\n *)+\n?/,EN=/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,xN=/^(?:\n *)*\n/,ON=/\r\n?/g,_N=/^\[\^([^\]]+)](:(.*)((\n+ {4,}.*)|(\n(?!\[\^).+))*)/,TN=/^\[\^([^\]]+)]/,CN=/\f/g,kN=/^---[ \t]*\n(.|\n)*\n---[ \t]*\n/,PN=/^\s*?\[(x|\s)\]/,RN=/^ *(#{1,6}) *([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/,AN=/^ *(#{1,6}) +([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/,DN=/^([^\n]+)\n *(=|-){3,} *(?:\n *)+\n/,jN=/^ *(?!<[a-z][^ >/]* ?\/>)<([a-z][^ >/]*) ?((?:[^>]*[^/])?)>\n?(\s*(?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1\b)[\s\S])*?)<\/\1>(?!<\/\1>)\n*/i,IN=/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/gi,NN=/^)/,LN=/^(data|aria|x)-[a-z_][a-z\d_.-]*$/,MN=/^ *<([a-z][a-z0-9:]*)(?:\s+((?:<.*?>|[^>])*))?\/?>(?!<\/\1>)(\s*\n)?/i,FN=/^\{.*\}$/,$N=/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,BN=/^<([^ >]+@[^ >]+)>/,VN=/^<([^ >]+:\/[^ >]+)>/,zN=/-([a-z])?/gi,UN=/^(.*\|.*)\n(?: *(\|? *[-:]+ *\|[-| :]*)\n((?:.*\|.*\n)*))?\n?/,qN=/^\[([^\]]*)\]:\s+]+)>?\s*("([^"]*)")?/,HN=/^!\[([^\]]*)\] ?\[([^\]]*)\]/,GN=/^\[([^\]]*)\] ?\[([^\]]*)\]/,WN=/(\[|\])/g,QN=/(\n|^[-*]\s|^#|^ {2,}|^-{2,}|^>\s)/,KN=/\t/g,YN=/(^ *\||\| *$)/g,XN=/^ *:-+: *$/,JN=/^ *:-+ *$/,ZN=/^ *-+: *$/,eL="((?:\\[.*?\\][([].*?[)\\]]|<.*?>(?:.*?<.*?>)?|`.*?`|~~.*?~~|==.*?==|.|\\n)*?)",tL=new RegExp(`^([*_])\\1${eL}\\1\\1(?!\\1)`),nL=new RegExp(`^([*_])${eL}\\1(?!\\1|\\w)`),rL=new RegExp(`^==${eL}==`),iL=new RegExp(`^~~${eL}~~`),aL=/^\\([^0-9A-Za-z\s])/,oL=/^[\s\S]+?(?=[^0-9A-Z\s\u00c0-\uffff&#;.()'"]|\d+\.|\n\n| {2,}\n|\w+:\S|$)/i,sL=/^\n+/,lL=/^([ \t]*)/,cL=/\\([^\\])/g,uL=/ *\n+$/,dL=/(?:^|\n)( *)$/,pL="(?:\\d+\\.)",hL="(?:[*+-])";function fL(e){return"( *)("+(1===e?pL:hL)+") +"}const mL=fL(1),gL=fL(2);function yL(e){return new RegExp("^"+(1===e?mL:gL))}const bL=yL(1),vL=yL(2);function wL(e){return new RegExp("^"+(1===e?mL:gL)+"[^\\n]*(?:\\n(?!\\1"+(1===e?pL:hL)+" )[^\\n]*)*(\\n|$)","gm")}const SL=wL(1),EL=wL(2);function xL(e){const t=1===e?pL:hL;return new RegExp("^( *)("+t+") [\\s\\S]+?(?:\\n{2,}(?! )(?!\\1"+t+" (?!"+t+" ))\\n*|\\s*\\n*$)")}const OL=xL(1),_L=xL(2);function TL(e,t){const n=1===t,r=n?OL:_L,i=n?SL:EL,a=n?bL:vL;return{match(e,t,n){const i=dL.exec(n);return i&&(t.list||!t.inline&&!t.simple)?r.exec(e=i[1]+e):null},order:1,parse(e,t,r){const o=n?+e[2]:void 0,s=e[0].replace(mN,"\n").match(i);let l=!1;return{items:s.map((function(e,n){const i=a.exec(e)[0].length,o=new RegExp("^ {1,"+i+"}","gm"),c=e.replace(o,"").replace(a,""),u=n===s.length-1,d=-1!==c.indexOf("\n\n")||u&&l;l=d;const p=r.inline,h=r.list;let f;r.list=!0,d?(r.inline=!1,f=c.replace(uL,"\n\n")):(r.inline=!0,f=c.replace(uL,""));const m=t(f,r);return r.inline=p,r.list=h,m})),ordered:n,start:o}},render:(t,n,r)=>e(t.ordered?"ol":"ul",{key:r.key,start:"20"===t.type?t.start:void 0},t.items.map((function(t,i){return e("li",{key:i},n(t,r))})))}}const CL=new RegExp("^\\[((?:\\[[^\\]]*\\]|[^\\[\\]]|\\](?=[^\\[]*\\]))*)\\]\\(\\s*?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*\\)"),kL=/^!\[(.*?)\]\( *((?:\([^)]*\)|[^() ])*) *"?([^)"]*)?"?\)/,PL=[gN,wN,SN,RN,DN,AN,NN,UN,SL,OL,EL,_L],RL=[...PL,/^[^\n]+(?: \n|\n{2,})/,jN,MN];function AL(e){return e.replace(/[ÀÁÂÃÄÅàáâãä忯]/g,"a").replace(/[çÇ]/g,"c").replace(/[ðÐ]/g,"d").replace(/[ÈÉÊËéèêë]/g,"e").replace(/[ÏïÎîÍíÌì]/g,"i").replace(/[Ññ]/g,"n").replace(/[øØœŒÕõÔôÓóÒò]/g,"o").replace(/[ÜüÛûÚúÙù]/g,"u").replace(/[ŸÿÝý]/g,"y").replace(/[^a-z0-9- ]/gi,"").replace(/ /gi,"-").toLowerCase()}function DL(e){return ZN.test(e)?"right":XN.test(e)?"center":JN.test(e)?"left":null}function jL(e,t,n,r){const i=n.inTable;n.inTable=!0;let a=e.trim().split(/( *(?:`[^`]*`|<.*?>.*?<\/.*?>(?!<\/.*?>)|\\\||\|) *)/).reduce(((e,i)=>("|"===i.trim()?e.push(r?{type:"26"}:{type:"27",text:i}):""!==i&&e.push.apply(e,t(i,n)),e)),[]);n.inTable=i;let o=[[]];return a.forEach((function(e,t){"26"===e.type?0!==t&&t!==a.length-1&&o.push([]):("27"!==e.type||null!=a[t+1]&&"26"!==a[t+1].type||(e.text=e.text.trimEnd()),o[o.length-1].push(e))})),o}function IL(e,t,n){n.inline=!0;const r=e[2]?e[2].replace(YN,"").split("|").map(DL):[],i=e[3]?function(e,t,n){return e.trim().split("\n").map((function(e){return jL(e,t,n,!0)}))}(e[3],t,n):[],a=jL(e[1],t,n,!!i.length);return n.inline=!1,i.length?{align:r,cells:i,header:a,type:"25"}:{children:a,type:"21"}}function NL(e,t){return null==e.align[t]?{}:{textAlign:e.align[t]}}function LL(e){return function(t,n){return n.inline?e.exec(t):null}}function ML(e){return function(t,n){return n.inline||n.simple?e.exec(t):null}}function FL(e){return function(t,n){return n.inline||n.simple?null:e.exec(t)}}function $L(e){return function(t){return e.exec(t)}}function BL(e,t,n){if(t.inline||t.simple)return null;if(n&&!n.endsWith("\n"))return null;let r="";e.split("\n").every((e=>!PL.some((t=>t.test(e)))&&(r+=e+"\n",e.trim())));const i=r.trimEnd();return""==i?null:[r,i]}function VL(e){try{if(decodeURIComponent(e).replace(/[^A-Za-z0-9/:]/g,"").match(/^\s*(javascript|vbscript|data(?!:image)):/i))return}catch(e){return null}return e}function zL(e){return e.replace(cL,"$1")}function UL(e,t,n){const r=n.inline||!1,i=n.simple||!1;n.inline=!0,n.simple=!0;const a=e(t,n);return n.inline=r,n.simple=i,a}function qL(e,t,n){const r=n.inline||!1,i=n.simple||!1;n.inline=!1,n.simple=!0;const a=e(t,n);return n.inline=r,n.simple=i,a}function HL(e,t,n){const r=n.inline||!1;n.inline=!1;const i=e(t,n);return n.inline=r,i}const GL=(e,t,n)=>({children:UL(t,e[1],n)});function WL(){return{}}function QL(){return null}function KL(...e){return e.filter(Boolean).join(" ")}function YL(e,t,n){let r=e;const i=t.split(".");for(;i.length&&(r=r[i[0]],void 0!==r);)i.shift();return r||n}const XL=e=>{let{children:t="",options:n}=e,r=function(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}(e,sN);return Fi.cloneElement(function(e="",t={}){t.overrides=t.overrides||{},t.slugify=t.slugify||AL,t.namedCodesToUnicode=t.namedCodesToUnicode?oN({},dN,t.namedCodesToUnicode):dN;const n=t.createElement||Fi.createElement;function r(e,r,...i){const a=YL(t.overrides,`${e}.props`,{});return n(function(e,t){const n=YL(t,e);return n?"function"==typeof n||"object"==typeof n&&"render"in n?n:YL(t,`${e}.component`,e):e}(e,t.overrides),oN({},r,a,{className:KL(null==r?void 0:r.className,a.className)||void 0}),...i)}function i(e){e=e.replace(kN,"");let n=!1;t.forceInline?n=!0:t.forceBlock||(n=!1===QN.test(e));const i=u(c(n?e:`${e.trimEnd().replace(sL,"")}\n\n`,{inline:n}));for(;"string"==typeof i[i.length-1]&&!i[i.length-1].trim();)i.pop();if(null===t.wrapper)return i;const a=t.wrapper||(n?"span":"div");let o;if(i.length>1||t.forceWrapper)o=i;else{if(1===i.length)return o=i[0],"string"==typeof o?r("span",{key:"outer"},o):o;o=null}return Fi.createElement(a,{key:"outer"},o)}function a(e){const t=e.match(hN);return t?t.reduce((function(e,t,n){const r=t.indexOf("=");if(-1!==r){const a=function(e){return-1!==e.indexOf("-")&&null===e.match(LN)&&(e=e.replace(zN,(function(e,t){return t.toUpperCase()}))),e}(t.slice(0,r)).trim(),o=function(e){const t=e[0];return('"'===t||"'"===t)&&e.length>=2&&e[e.length-1]===t?e.slice(1,-1):e}(t.slice(r+1).trim()),s=uN[a]||a,l=e[s]=function(e,t){return"style"===e?t.split(/;\s?/).reduce((function(e,t){const n=t.slice(0,t.indexOf(":"));return e[n.trim().replace(/(-[a-z])/g,(e=>e[1].toUpperCase()))]=t.slice(n.length+1).trim(),e}),{}):"href"===e||"src"===e?VL(t):(t.match(FN)&&(t=t.slice(1,t.length-1)),"true"===t||"false"!==t&&t)}(a,o);"string"==typeof l&&(jN.test(l)||MN.test(l))&&(e[s]=Fi.cloneElement(i(l.trim()),{key:n}))}else"style"!==t&&(e[uN[t]||t]=!0);return e}),{}):null}const o=[],s={},l={0:{match:FL(gN),order:1,parse:(e,t,n)=>({children:t(e[0].replace(yN,""),n)}),render:(e,t,n)=>r("blockquote",{key:n.key},t(e.children,n))},1:{match:$L(bN),order:1,parse:WL,render:(e,t,n)=>r("br",{key:n.key})},2:{match:FL(vN),order:1,parse:WL,render:(e,t,n)=>r("hr",{key:n.key})},3:{match:FL(SN),order:0,parse:e=>({lang:void 0,text:e[0].replace(/^ {4}/gm,"").replace(/\n+$/,"")}),render:(e,t,n)=>r("pre",{key:n.key},r("code",oN({},e.attrs,{className:e.lang?`lang-${e.lang}`:""}),e.text))},4:{match:FL(wN),order:0,parse:e=>({attrs:a(e[3]||""),lang:e[2]||void 0,text:e[4],type:"3"})},5:{match:ML(EN),order:3,parse:e=>({text:e[2]}),render:(e,t,n)=>r("code",{key:n.key},e.text)},6:{match:FL(_N),order:0,parse:e=>(o.push({footnote:e[2],identifier:e[1]}),{}),render:QL},7:{match:LL(TN),order:1,parse:e=>({target:`#${t.slugify(e[1])}`,text:e[1]}),render:(e,t,n)=>r("a",{key:n.key,href:VL(e.target)},r("sup",{key:n.key},e.text))},8:{match:LL(PN),order:1,parse:e=>({completed:"x"===e[1].toLowerCase()}),render:(e,t,n)=>r("input",{checked:e.completed,key:n.key,readOnly:!0,type:"checkbox"})},9:{match:FL(t.enforceAtxHeadings?AN:RN),order:1,parse:(e,n,r)=>({children:UL(n,e[2],r),id:t.slugify(e[2]),level:e[1].length}),render:(e,t,n)=>r(`h${e.level}`,{id:e.id,key:n.key},t(e.children,n))},10:{match:FL(DN),order:0,parse:(e,t,n)=>({children:UL(t,e[1],n),level:"="===e[2]?1:2,type:"9"})},11:{match:$L(jN),order:1,parse(e,t,n){const[,r]=e[3].match(lL),i=new RegExp(`^${r}`,"gm"),o=e[3].replace(i,""),s=(l=o,RL.some((e=>e.test(l)))?HL:UL);var l;const c=e[1].toLowerCase(),u=-1!==pN.indexOf(c),d={attrs:a(e[2]),noInnerParse:u,tag:(u?c:e[1]).trim()};return n.inAnchor=n.inAnchor||"a"===c,u?d.text=e[3]:d.children=s(t,o,n),n.inAnchor=!1,d},render:(e,t,n)=>r(e.tag,oN({key:n.key},e.attrs),e.text||t(e.children,n))},13:{match:$L(MN),order:1,parse:e=>({attrs:a(e[2]||""),tag:e[1].trim()}),render:(e,t,n)=>r(e.tag,oN({},e.attrs,{key:n.key}))},12:{match:$L(NN),order:1,parse:()=>({}),render:QL},14:{match:ML(kL),order:1,parse:e=>({alt:e[1],target:zL(e[2]),title:e[3]}),render:(e,t,n)=>r("img",{key:n.key,alt:e.alt||void 0,title:e.title||void 0,src:VL(e.target)})},15:{match:LL(CL),order:3,parse:(e,t,n)=>({children:qL(t,e[1],n),target:zL(e[2]),title:e[3]}),render:(e,t,n)=>r("a",{key:n.key,href:VL(e.target),title:e.title},t(e.children,n))},16:{match:LL(VN),order:0,parse:e=>({children:[{text:e[1],type:"27"}],target:e[1],type:"15"})},17:{match:(e,t)=>t.inAnchor?null:LL($N)(e,t),order:0,parse:e=>({children:[{text:e[1],type:"27"}],target:e[1],title:void 0,type:"15"})},18:{match:LL(BN),order:0,parse(e){let t=e[1],n=e[1];return fN.test(n)||(n="mailto:"+n),{children:[{text:t.replace("mailto:",""),type:"27"}],target:n,type:"15"}}},20:TL(r,1),33:TL(r,2),19:{match:FL(xN),order:3,parse:WL,render:()=>"\n"},21:{match:BL,order:3,parse:GL,render:(e,t,n)=>r("p",{key:n.key},t(e.children,n))},22:{match:LL(qN),order:0,parse:e=>(s[e[1]]={target:e[2],title:e[4]},{}),render:QL},23:{match:ML(HN),order:0,parse:e=>({alt:e[1]||void 0,ref:e[2]}),render:(e,t,n)=>s[e.ref]?r("img",{key:n.key,alt:e.alt,src:VL(s[e.ref].target),title:s[e.ref].title}):null},24:{match:LL(GN),order:0,parse:(e,t,n)=>({children:t(e[1],n),fallbackChildren:t(e[0].replace(WN,"\\$1"),n),ref:e[2]}),render:(e,t,n)=>s[e.ref]?r("a",{key:n.key,href:VL(s[e.ref].target),title:s[e.ref].title},t(e.children,n)):r("span",{key:n.key},t(e.fallbackChildren,n))},25:{match:FL(UN),order:1,parse:IL,render(e,t,n){const i=e;return r("table",{key:n.key},r("thead",null,r("tr",null,i.header.map((function(e,a){return r("th",{key:a,style:NL(i,a)},t(e,n))})))),r("tbody",null,i.cells.map((function(e,a){return r("tr",{key:a},e.map((function(e,a){return r("td",{key:a,style:NL(i,a)},t(e,n))})))}))))}},27:{match:$L(oL),order:4,parse:e=>({text:e[0].replace(IN,((e,n)=>t.namedCodesToUnicode[n]?t.namedCodesToUnicode[n]:e))}),render:e=>e.text},28:{match:ML(tL),order:2,parse:(e,t,n)=>({children:t(e[2],n)}),render:(e,t,n)=>r("strong",{key:n.key},t(e.children,n))},29:{match:ML(nL),order:3,parse:(e,t,n)=>({children:t(e[2],n)}),render:(e,t,n)=>r("em",{key:n.key},t(e.children,n))},30:{match:ML(aL),order:1,parse:e=>({text:e[1],type:"27"})},31:{match:ML(rL),order:3,parse:GL,render:(e,t,n)=>r("mark",{key:n.key},t(e.children,n))},32:{match:ML(iL),order:3,parse:GL,render:(e,t,n)=>r("del",{key:n.key},t(e.children,n))}};!0===t.disableParsingRawHTML&&(delete l[11],delete l[13]);const c=function(e){let t=Object.keys(e);function n(r,i){let a=[],o="";for(;r;){let s=0;for(;sa(n,r,i)),n,r,i):a(n,r,i)}}(l,t.renderRule),function e(t,n={}){if(Array.isArray(t)){const r=n.key,i=[];let a=!1;for(let r=0;r{const t=document.querySelector('[placeholder^="Search"]');if(null===t)return void Xi.error(new Error("Cannot find search input element!"));((e,t)=>{const n=Object.getOwnPropertyDescriptor(e,"value").set,r=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),"value").set;n&&n!==r?r.call(e,t):n.call(e,t)})(t,e.target.textContent.trim()),t.dispatchEvent(new Event("input",{bubbles:!0}))},ZL={overrides:{code:{component:({children:e})=>{const t=(0,o.useStyles2)(tM);return"string"==typeof e&&e.includes("\n")?$i().createElement("code",null,e):$i().createElement("code",{className:t.searchLink,title:"Search for this node",onClick:JL},e)}}}};function eM({reply:e}){var t;const n=(0,o.useStyles2)(tM);return $i().createElement("div",{className:n.container},null==e||null===(t=e.messages)||void 0===t?void 0:t.filter((e=>"system"!==e.role)).map((e=>$i().createElement($i().Fragment,null,$i().createElement("div",{className:n.reply},$i().createElement(XL,{options:ZL},e.content)),$i().createElement("hr",null)))),$i().createElement("div",{className:n.reply},$i().createElement(XL,{options:ZL},e.text)))}const tM=()=>({container:i.css` width: 100%; height: 100%; `,reply:i.css` font-size: 13px; & ol, & ul { margin: 0 0 16px 24px; } `,searchLink:i.css` color: rgb(255, 136, 51); border: 1px solid transparent; padding: 2px 4px; cursor: pointer; font-size: 13px; &:hover, &:focus, &:active { box-sizing: border-box; border: 1px solid rgb(255, 136, 51, 0.8); border-radius: 4px; } `}),nM=()=>({textarea:i.css` margin-bottom: 8px; `,sendButton:i.css` float: right; border-top-left-radius: 0; border-bottom-left-radius: 0; `});function rM({onSubmit:e}){const t=(0,o.useStyles2)(nM),{question:n,onChangeInput:r,onClickSend:i}=function(e){const[t,n]=(0,Fi.useState)(""),r=(0,Fi.useCallback)((e=>{n(e.target.value)}),[]),i=(0,Fi.useCallback)((()=>{const r=t.trim();r&&(e(r),n(""))}),[t,e]);return{question:t,onChangeInput:r,onClickSend:i}}(e);return $i().createElement("div",null,$i().createElement(o.TextArea,{className:t.textarea,placeholder:"Ask a follow-up question...",value:n,onChange:r,onKeyDown:e=>{"Enter"!==e.code||e.shiftKey||i()}}),$i().createElement(o.Button,{className:t.sendButton,onClick:i},"Send"))}const iM={system:{empty:()=>"\n You are a performance profiling expert and excel at analyzing profiles in the DOT format.\n In the DOT format, a row like N47 -> N61 means the function from N47 called the function from N61.\n"},user:{single:(e,t)=>`\n Analyze this flamegraph in DOT format and address these key aspects:\n - **Performance Bottleneck**: Identify the primary factors slowing down the process, consuming excessive memory, or causing a bottleneck in the system.\n - **Root Cause**: Explain clearly why these bottlenecks are occurring.\n - **Recommended Fix**: Suggest practical solutions for these issues.\n\n Guidelines:\n - Always use full function names without splitting them from package names.\n - Exclude numeric values, percentages, and node names (e.g., N1, N3, Node 1, Node 2).\n - Focus on user code over low-level runtime optimizations.\n - For standard library or runtime functions, explain their presence/function and link them to user code functions calling them. Avoid repetitive mentions from the same call chain.\n - Do not mention that the flamegraph profile is in DOT format.\n - Only use h5 and h6 markdown headers (e.g., ##### Performance Bottleneck, ###### Recommended Fix)\n - Do not use h1,h2,h3,h4 headers (e.g., ## Bottleneck, ### Root Cause, #### Recommended Fix)\n\n Format the response using markdown headers for each section corresponding to the key aspects.\n\n The profile type is: ${e}\n Profile in DOT format:\n ${t[0]}\n`,anton:(e,t)=>`\nGive me actionable feedback and suggestions on how I improve the application performance.\n\nDo not break function names.\nDo not show any numeric values, absolute or percents.\nDo not show node names like N1, N3, or Node 1, Node 2.\nDo not suggest low-level runtime optimisations, focus on the user code.\n\nAlways use full function names.\nNever split function and package name.\n\nRemove any numeric values, absolute or percents, from the output.\nRemove node names like N1, N3, or Node 1, Node 2 from the output.\n\nIf the function is widely known (e.g., a runtime or stdlib function), provide me concise explanation why the function is present in the profile and what could be the cause.\nIf a function is defined in the runtime or in the standard library, tell me which function in the user code calls it.\nAvoid mentioning functions from the same call-chain.\n\n5 suggestions is enough.\nThe profile type is ${e}\nBelow is the performance profile in DOT format:\n${t[0]}\n`,diff:(e,t)=>`\nAnalyze the differences between these two performance profiles presented in DOT format. Provide a detailed comparison focusing on the following aspects:\n\n- Performance Change: Determine how the performance has changed from the first profile to the second. Identify if there are new bottlenecks, improved or worsened performance areas, or significant changes in resource consumption.\n- Function Impact: Highlight no more than 3 specific functions that have undergone notable changes in their performance impact. Discuss any new functions that have appeared in the second profile or any existing functions that have significantly increased or decreased in resource usage.\n- Potential Causes: Discuss the possible reasons for these changes in performance, linking them to the differences in function execution or resource usage between the two profiles.\n\nGuidelines for Analysis:\n- Use full function names without separating them from their package names\n- Focus on user code rather than low-level runtime optimizations or standard library functions unless they are directly relevant to the user code's performance changes\n- Exclude numeric values, percentages, and node names (e.g., N1, N3, Node 1, Node 2) from the analysis\n- Format the response using markdown headers for each section to structure the analysis clearly\n\nThe profile type is: ${e}\n\nFirst performance profile in DOT format:\n${t[0]}\n\nSecond performance profile in DOT format:\n${t[1]}\n`}},aM=({system:e,user:t,profileType:n,profiles:r})=>{const i=iM.system[e];if("function"!=typeof i)throw new Error(`Cannot find system prompt "${e}"!`);const a=iM.user[t];if("function"!=typeof a)throw new Error(`Cannot find user prompt "${t}"!`);return{system:i(n,r),user:a(n,r)}};function oM(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}class sM extends QC{get(e){var t,n=this;return(t=function*(){const t=new URLSearchParams({query:e.query,from:String(1e3*e.timeRange.from.unix()),until:String(1e3*e.timeRange.to.unix()),format:e.format});e.maxNodes&&t.set("max-nodes",String(e.maxNodes));const r=yield n.fetch(`/pyroscope/render?${t.toString()}`);switch(e.format){case"dot":return r.text();case"json":return r.json();default:throw new TypeError(`Unknown format "${e.format}"!`)}},function(){var e=this,n=arguments;return new Promise((function(r,i){var a=t.apply(e,n);function o(e){oM(a,r,i,o,s,"next",e)}function s(e){oM(a,r,i,o,s,"throw",e)}o(void 0)}))})()}constructor(e){super(e)}}function lM(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class cM extends bh{validateFetchParams(e,t){let n,r=t;return e&&2!==t.length?(n=new Error(`Invalid number of fetch parameters for analyzing the diff flame graph (${t.length})!`),r=[]):e||1===t.length||(n=new Error(`Invalid number of fetch parameters for analyzing the flame graph (${t.length})!`),r=[]),{params:r,error:n}}constructor(){super({key:"ai-panel"}),lM(this,"useSceneAiPanel",((e,t)=>{const n=tm.findByKeyAndType(this,"dataSource",sR).useState().value,{params:r,error:i}=this.validateFetchParams(e,t),{error:a,isFetching:o,profiles:s}=function(e,t){const n=vj.build(e,sM),{isFetching:r,error:i,data:a}=Pa({queryKey:["dot-profiles",e,...t.flatMap((({query:e,timeRange:t})=>[e,t.from.unix(),t.to.unix()])),100],queryFn:()=>Promise.all(t.map((({query:e,timeRange:t})=>n.get({query:e,timeRange:t,format:"dot",maxNodes:100}).then((e=>e.replace(/fontsize=\d+ /g,"").replace(/id="node\d+" /g,"").replace(/labeltooltip=".*\)" /g,"").replace(/tooltip=".*\)" /g,"").replace(/(N\d+ -> N\d+).*/g,"$1").replace(/N\d+ \[label="other.*\n/,"").replace(/shape=box /g,"").replace(/fillcolor="#\w{6}"/g,"").replace(/color="#\w{6}" /g,""))))))});return{isFetching:r,error:i,profiles:a||[]}}(n,r),l=WP(wR(this,"profileMetricId")).type,{reply:c,error:u,retry:d}=function(e,t){const[n,r]=(0,Fi.useState)(""),[i,a]=(0,Fi.useState)(!1),[o,s]=(0,Fi.useState)(!1),[l,c]=(0,Fi.useState)([]),[u,d]=(0,Fi.useState)(null),[p,h]=(0,Fi.useState)(),f=(0,Fi.useCallback)((e=>{c(e),d(null),r(""),a(!0),s(!1);const t=eN({model:"gpt-4-1106-preview",messages:e}).pipe(ZI()).subscribe({next:r,error(e){d(e),a(!1),s(!0),h(void 0)},complete(){a(!1),s(!0),h(void 0)}});h(t)}),[]),m=(0,Fi.useCallback)((e=>{const t=[{role:"assistant",content:n},{role:"user",content:e}];try{f([...l,...t])}catch(e){d(e)}}),[l,n,f]);return(0,Fi.useEffect)((()=>{if(!t.length||l.length>0)return;const n=aM({system:"empty",user:2===t.length?"diff":"single",profileType:e,profiles:t});try{f([{role:"system",content:n.system},{role:"system",content:n.user}])}catch(e){d(e)}}),[l.length,e,t,t.length,f]),(0,Fi.useEffect)((()=>()=>{p&&(p.unsubscribe(),h(void 0))}),[p]),{reply:{text:n,hasStarted:i,hasFinished:o,messages:l,askFollowupQuestion:m},retry(){if(l.length>0)try{f(l)}catch(e){d(e)}},error:u}}(l,s);return{data:{validationError:i,isLoading:o||!o&&!a&&!u&&!c.text.trim(),fetchError:a,llmError:u,reply:c,shouldDisplayReply:Boolean((null==c?void 0:c.hasStarted)||(null==c?void 0:c.hasFinished)),shouldDisplayFollowUpForm:!a&&!u&&Boolean(null==c?void 0:c.hasFinished)},actions:{retry:d,submitFollowupQuestion(e){c.askFollowupQuestion(e)}}}}))}}lM(cM,"Component",(({model:e,isDiff:t,fetchParams:n,onClose:r})=>{const i=(0,o.useStyles2)(uM),{data:a,actions:s}=e.useSceneAiPanel(t,n);return $i().createElement(LI,{className:i.sidePanel,title:"Flame graph analysis",isLoading:a.isLoading,headerActions:$i().createElement(o.IconButton,{title:"Close panel",name:"times-circle",variant:"secondary","aria-label":"close",onClick:r}),dataTestId:"ai-panel"},$i().createElement("div",{className:i.content},a.validationError&&$i().createElement(pI,{severity:"error",title:"Validation error!",error:a.validationError}),a.fetchError&&$i().createElement(pI,{severity:"error",title:"Error while loading profile data!",message:"Sorry for any inconvenience, please try again later.",error:a.fetchError}),a.shouldDisplayReply&&$i().createElement(eM,{reply:a.reply}),a.isLoading&&$i().createElement($i().Fragment,null,$i().createElement(o.Spinner,{inline:!0})," Analyzing..."),a.llmError&&$i().createElement(o.Alert,{title:"An error occured while generating content using OpenAI!",severity:"warning"},$i().createElement("div",null,$i().createElement("div",null,$i().createElement("p",null,a.llmError.message),$i().createElement("p",null,"Sorry for any inconvenience, please retry or if the problem persists, contact your organization admin."))),$i().createElement(o.Button,{className:i.retryButton,variant:"secondary",fill:"outline",onClick:()=>s.retry()},"Retry")),a.shouldDisplayFollowUpForm&&$i().createElement(rM,{onSubmit:s.submitFollowupQuestion})))}));const uM=e=>({sidePanel:i.css` flex: 1 0 50%; margin-left: 8px; max-width: calc(50% - 4px); `,title:i.css` margin: -4px 0 4px 0; `,content:i.css` padding: ${e.spacing(1)}; `,retryButton:i.css` float: right; `});class dM extends r.BusEventWithPayload{}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(dM,"type","diff-auto-select");class pM extends r.BusEventWithPayload{}function hM(){const{searchParams:e,pushNewUrl:t}=function(){const e=(0,Es.useNavigate)(),t=(0,Es.useLocation)();return{searchParams:new URLSearchParams(t.search),pushNewUrl:t=>{const n=new URLSearchParams(window.location.search);for(const[e,r]of Object.entries(t))n.set(e,r);e({search:n.toString()},{replace:!0})}}}();var n;const r=Number(null!==(n=e.get("maxNodes"))&&void 0!==n?n:""),i=e=>{t({maxNodes:String(e)})};return function(e,t){const{isFetching:n,error:r,settings:i}=dI({enabled:!e});if(!e&&!n)r?(js(["Error while retrieving the plugin settings!","Some features might not work as expected (e.g. flame graph max nodes). Please try to reload the page, sorry for the inconvenience."]),Xi.error(r),t(oI.maxNodes)):t(i.maxNodes)}(r>0,i),[r,i]}function fM(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(pM,"type","diff-choose-preset");class mM extends QC{get(e){var t,n=this;return(t=function*(){const t=new URLSearchParams({leftQuery:e.leftQuery,leftFrom:String(1e3*e.leftTimeRange.from.unix()),leftUntil:String(1e3*e.leftTimeRange.to.unix()),rightQuery:e.rightQuery,rightFrom:String(1e3*e.rightTimeRange.from.unix()),rightUntil:String(1e3*e.rightTimeRange.to.unix())});e.maxNodes&&t.set("max-nodes",String(e.maxNodes));const r=yield n.fetch(`/pyroscope/render-diff?${t.toString()}`);return yield r.json()},function(){var e=this,n=arguments;return new Promise((function(r,i){var a=t.apply(e,n);function o(e){fM(a,r,i,o,s,"next",e)}function s(e){fM(a,r,i,o,s,"throw",e)}o(void 0)}))})()}constructor(e){super(e)}}function gM(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function yM(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function bM({enabled:e,dataSourceUid:t,baselineTimeRange:n,baselineQuery:r,comparisonTimeRange:i,comparisonQuery:a}){const[o]=hM(),s=vj.build(t,mM),{isFetching:l,error:c,data:u,refetch:d}=Pa({placeholderData:e=>e,enabled:Boolean(e&&o),queryKey:["diff-profile",t,r,n.from.unix(),n.to.unix(),a,i.from.unix(),i.to.unix(),o],queryFn:()=>{s.abort();const e={leftQuery:r,leftTimeRange:n,rightQuery:a,rightTimeRange:i,maxNodes:o};return s.get(e).then((e=>({profile:{version:e.version,flamebearer:e.flamebearer,metadata:e.metadata}})))}});return yM(function(e){for(var t=1;t{i||n(),a(!i)}},$i().createElement("div",{className:r.collapseContent},$i().createElement("ol",null,$i().createElement("li",null,"Ensure that the “Flame graph” range selection mode is selected"),$i().createElement("li",null,"Use your mouse to select the desired time ranges on both the baseline and the comparison time series")),$i().createElement("img",{src:"public/plugins/grafana-pyroscope-app/img/8cdf4d2e2df8326311ab.gif",alt:"How to view the diff flame graph"}))))})}const wM=e=>({infoMsg:i.css` padding: ${e.spacing(2)} 0 0 0; `,textButton:i.css` padding: 0; `,collapse:i.css` background: transparent; border: 0; `,collapseContent:i.css` padding: 0 ${e.spacing(5)}; & img { max-width: 100%; width: auto; margin-top: ${e.spacing(2)}; } `});function SM(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class EM extends bh{buildTitle(){const e=wR(this,"serviceName"),t=WP(wR(this,"profileMetricId")).type;return $i().createElement($i().Fragment,null,$i().createElement(Ko,{size:"small"}),"Diff flame graph for ",e," (",t,")")}constructor(){super({key:"diff-flame-graph",aiPanel:new cM}),SM(this,"useSceneDiffFlameGraph",(()=>{const{aiPanel:e}=this.useState(),{baselineTimeRange:t,comparisonTimeRange:n}=this.parent.useDiffTimeRanges(),r=oR(this,"filtersBaseline"),i=oR(this,"filtersComparison"),{settings:a,error:o}=dI(),s=tm.findByKeyAndType(this,"dataSource",sR).useState().value,l=Boolean(r&&i&&t.from.unix()&&t.to.unix()&&n.from.unix()&&n.to.unix()),{isFetching:c,error:u,profile:d}=bM({enabled:l,dataSourceUid:s,baselineTimeRange:t,baselineQuery:r,comparisonTimeRange:n,comparisonQuery:i}),p=l&&!c&&!u&&0===(null==d?void 0:d.flamebearer.numTicks),h=Boolean(l&&!u&&!p&&d),f=!l;return{data:{title:this.buildTitle(),isLoading:c,fetchProfileError:u,noProfileDataAvailable:p,shouldDisplayFlamegraph:h,hasMissingSelections:f,profile:d,settings:a,fetchSettingsError:o,ai:{panel:e,fetchParams:[{query:r,timeRange:t},{query:i,timeRange:n}]}},actions:{}}})),SM(this,"onClickAutoSelect",(()=>{Ts("g_pyroscope_app_diff_auto_select_clicked"),this.publishEvent(new dM({wholeRange:!1}),!0)})),SM(this,"onClickChoosePreset",(()=>{Ts("g_pyroscope_app_diff_choose_preset_clicked"),this.publishEvent(new pM({}),!0)})),SM(this,"onOpenLearnHow",(()=>{Ts("g_pyroscope_app_diff_learn_how_clicked")}))}}SM(EM,"Component",(({model:e})=>{var t,n;const r=(0,o.useStyles2)(xM),{data:i}=e.useSceneDiffFlameGraph(),a=iI(),s=i.isLoading||i.hasMissingSelections||i.noProfileDataAvailable;(0,Fi.useEffect)((()=>{s&&a.close()}),[s,a]),i.fetchSettingsError&&js(["Error while retrieving the plugin settings!","Some features might not work as expected (e.g. flamegraph export options). Please try to reload the page, sorry for the inconvenience."]);const l=(0,Fi.useMemo)((()=>$i().createElement($i().Fragment,null,i.title,i.isLoading&&$i().createElement(o.Spinner,{inline:!0,className:r.spinner}))),[i.isLoading,i.title,r.spinner]);return $i().createElement("div",{className:r.flex},$i().createElement(LI,{dataTestId:"diff-flame-graph-panel",className:r.flamegraphPanel,title:l,isLoading:i.isLoading,headerActions:$i().createElement(iN,{disabled:s||a.isOpen("ai"),onClick:()=>a.open("ai"),interactionName:"g_pyroscope_app_explain_flamegraph_clicked"},"Explain Flame Graph")},i.hasMissingSelections&&$i().createElement(vM,{onClickAutoSelect:e.onClickAutoSelect,onClickChoosePreset:e.onClickChoosePreset,onOpenLearnHow:e.onOpenLearnHow}),i.fetchProfileError&&$i().createElement(pI,{severity:"error",title:"Error while loading profile data!",error:i.fetchProfileError}),i.noProfileDataAvailable&&$i().createElement(pI,{severity:"warning",title:"No profile data available",message:"Please verify that you've selected adequate filters and time ranges."}),i.shouldDisplayFlamegraph&&$i().createElement(mp,{diff:!0,profile:i.profile,enableFlameGraphDotComExport:null===(t=i.settings)||void 0===t?void 0:t.enableFlameGraphDotComExport,collapsedFlamegraphs:null===(n=i.settings)||void 0===n?void 0:n.collapsedFlamegraphs})),a.isOpen("ai")&&$i().createElement(i.ai.panel.Component,{model:i.ai.panel,isDiff:!0,fetchParams:i.ai.fetchParams,onClose:a.close}))}));const xM=e=>({flex:i.css` display: flex; `,flamegraphPanel:i.css` min-width: 0; flex-grow: 1; `,sidePanel:i.css` flex: 1 0 50%; margin-left: 8px; max-width: calc(50% - 4px); `,spinner:i.css` margin-left: ${e.spacing(1)}; `,aiButton:i.css` margin-top: ${e.spacing(1)}; `}),OM="https://grafana.qualtrics.com/jfe/form/SV_6Gav4IUU6jcYfd4",_M=()=>{const e=(0,o.useStyles2)(TM);return $i().createElement("div",{className:e.wrapper},$i().createElement("a",{href:OM,className:e.feedback,title:"Share your thoughts about Profiles in Grafana.",target:"_blank",rel:"noreferrer noopener"},$i().createElement(o.Icon,{name:"comment-alt-message"})," Give feedback"))},TM=e=>({wrapper:(0,i.css)({display:"flex",gap:e.spacing(1),justifyContent:"flex-end",paddingTop:"4px"}),feedback:(0,i.css)({alignSelf:"center",color:e.colors.text.secondary,fontSize:e.typography.bodySmall.fontSize,"&:hover":{color:e.colors.text.link}})});function CM(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class kM extends bh{onActivate(){[np.BASELINE,np.COMPARISON].forEach((e=>{this._subs.add(tm.findByKeyAndType(this,`${e}-panel`,nI).state.$timeRange.subscribeToState(((e,t)=>{e.from===t.from&&e.to===t.to||this.setState({value:null})})))}))}openSelect(){this.setState({isSelectOpen:!0})}closeSelect(){this.setState({isSelectOpen:!1})}reset(){this.setState({value:null,isSelectOpen:!1,isModalOpen:!1})}static Component({model:e}){const t=(0,o.useStyles2)(PM),{value:n,isSelectOpen:r,isModalOpen:i}=e.useState();return $i().createElement($i().Fragment,null,$i().createElement("div",{className:t.presetsContainer},$i().createElement(o.Select,{className:t.select,placeholder:"Choose a preset",value:n,options:kM.PRESETS,onChange:e.onChangePreset,isOpen:r,onOpenMenu:e.onOpenSelect,onCloseMenu:e.onCloseSelect}),$i().createElement(o.Button,{icon:"save",variant:"secondary",tooltip:"Save the current time ranges and filters as a custom preset",onClick:e.onClickSave})),$i().createElement(o.Modal,{title:"Custom user presets",isOpen:i,closeOnEscape:!0,closeOnBackdropClick:!0,onDismiss:e.closeModal},$i().createElement("p",null,"This feature, which would allow you to save the current time ranges and filters, is currently not implemented."),$i().createElement("p",null,"Please let us know if you would be interested to use it by"," ",$i().createElement("a",{href:OM,target:"_blank",rel:"noreferrer noopener",className:t.link},"leaving us your feedback.")),$i().createElement("p",null,"Thank you!"),$i().createElement(o.Modal.ButtonRow,null,$i().createElement(o.Button,{variant:"secondary",fill:"outline",onClick:e.closeModal},"Cancel"),$i().createElement(o.Button,{onClick:e.closeModal,disabled:!0},"Save"))))}constructor(){super({name:"compare-presets",label:"Comparison presets",value:null,isModalOpen:!1,isSelectOpen:!1}),CM(this,"_variableDependency",new im(this,{variableNames:["dataSource","serviceName"],onReferencedVariableValueChanged:()=>{this.reset()}})),CM(this,"onChangePreset",(e=>{var t;if(Ts("g_pyroscope_app_diff_preset_selected",{value:e.value}),this.closeSelect(),"dummy"!==e.value){if(null===(t=e.value)||void 0===t?void 0:t.startsWith("auto-select-"))return this.setState({value:null}),void this.publishEvent(new dM({wholeRange:"auto-select-whole"===e.value}),!0);[np.BASELINE,np.COMPARISON].forEach((t=>{const n=tm.findByKeyAndType(this,`${t}-panel`,nI);n.toggleTimeRangeSync(!1),n.applyPreset(e[t])})),this.setState({value:e.value})}else this.setState({value:null,isModalOpen:!0})})),CM(this,"onClickSave",(()=>{Ts("g_pyroscope_app_diff_preset_save_clicked"),this.setState({isModalOpen:!0})})),CM(this,"closeModal",(()=>{this.setState({isModalOpen:!1})})),CM(this,"onOpenSelect",(()=>{setTimeout((()=>this.openSelect()),0)})),CM(this,"onCloseSelect",(()=>{this.closeSelect()})),this.addActivationHandler(this.onActivate.bind(this))}}CM(kM,"PRESETS",[{label:"Built-in presets",value:"built-in",options:[{value:"last hour (30m-window)",label:"Last hour (30m-window)",baseline:{from:"now-1h",to:"now",diffFrom:"now-1h",diffTo:"now-30m",label:"last hour"},comparison:{from:"now-1h",to:"now",diffFrom:"now-30m",diffTo:"now",label:"last hour"}},{value:"last hour (1h-window)",label:"Last hour (1h-window)",baseline:{from:"now-1h",to:"now",diffFrom:"now-1h",diffTo:"now",label:"last hour"},comparison:{from:"now-1h",to:"now",diffFrom:"now-1h",diffTo:"now",label:"last hour"}},{value:"6h ago vs now",label:"6h ago vs now (30m-window)",baseline:{from:"now-375m",to:"now-315m",diffFrom:"now-375m",diffTo:"now-345m",label:"6h ago"},comparison:{from:"now-1h",to:"now",diffFrom:"now-30m",diffTo:"now",label:"last hour"}},{value:"24h ago vs now",label:"24h ago vs now (30m-window)",baseline:{from:"now-1455m",to:"now-1395m",diffFrom:"now-1455m",diffTo:"now-1425m",label:"24h ago"},comparison:{from:"now-1h",to:"now",diffFrom:"now-30m",diffTo:"now",label:"last hour"}},{value:"auto-select-25",label:"Auto-select (25% range)"},{value:"auto-select-whole",label:"Auto-select (whole range)"}]},{label:"My presets",value:"custom",options:[{label:"Dummy preset saved earlier",value:"dummy"}]}]);const PM=e=>({presetsContainer:i.css` display: flex; `,select:i.css` min-width: ${e.spacing(24)}; text-align: left; `,link:i.css` color: ${e.colors.text.link}; `});function RM(){return e=>{const t=new Map,n=e.subscribeToEvent(F_,(n=>{var r;const i=null===(r=n.payload.series)||void 0===r?void 0:r[0];(null==i?void 0:i.refId)?(t.set(i.refId,Math.max(...i.fields[1].values)),function(e,t){const n=tm.findAllObjects(e,(e=>e instanceof _b&&"timeseries"===e.state.pluginId));for(const e of n)e.clearFieldConfigCache(),e.setState({fieldConfig:(0,$c.merge)((0,$c.cloneDeep)(e.state.fieldConfig),{defaults:{max:t}})})}(e,Math.max(...t.values()))):Xi.warn("Missing refId! Cannot sync y-axis on the timeseries.",n.payload.series)}));return()=>{n.unsubscribe()}}}class AM extends bh{onActivate(){a.locationService.partial({},!0);const e=tm.findByKeyAndType(this,"profileMetricId",eR);return e.setState({query:eR.QUERY_SERVICE_NAME_DEPENDENT}),e.update(!0),this.subscribeToEvents(),()=>{e.setState({query:eR.QUERY_DEFAULT}),e.update(!0)}}subscribeToEvents(){this._subs.add(this.subscribeToEvent(dM,(e=>{const t=e.payload.wholeRange,{baselinePanel:n,comparisonPanel:r}=this.state;n.toggleTimeRangeSync(!1),r.toggleTimeRangeSync(!1),n.autoSelectDiffRange(t),r.autoSelectDiffRange(t)}))),this._subs.add(this.subscribeToEvent(pM,(()=>{this.state.presetsPicker.openSelect()}))),this._subs.add(this.subscribeToEvent(Pj,(e=>{const{source:t,enable:n,timeRange:r,annotationTimeRange:i}=e.payload,{baselinePanel:a,comparisonPanel:o}=this.state,s=t===np.BASELINE?o:a;n&&this.syncTimeRanges(s,r,i),o.toggleTimeRangeSync(n),a.toggleTimeRangeSync(n)}))),this._subs.add(this.subscribeToEvent(Aj,(e=>{const{source:t,timeRange:n,annotationTimeRange:r}=e.payload,{baselinePanel:i,comparisonPanel:a}=this.state,o=t===np.BASELINE?a:i;this.syncTimeRanges(o,n,r)}))),this._subs.add(this.subscribeToEvent(Rj,(e=>{const{source:t}=e.payload,{baselinePanel:n,comparisonPanel:r}=this.state;(t===np.BASELINE?r:n).refreshTimeseries()})))}syncTimeRanges(e,t,n){t&&e.setTimeRange(t),n&&e.setDiffRange({from:n.from.toISOString(),to:n.to.toISOString()})}getVariablesAndGridControls(){return{variables:[tm.findByKeyAndType(this,"serviceName",iR),tm.findByKeyAndType(this,"profileMetricId",eR),this.state.presetsPicker],gridControls:[]}}static Component({model:e}){const t=(0,o.useStyles2)(DM),{baselinePanel:n,comparisonPanel:r,body:i}=e.useState();return $i().createElement("div",{className:t.container},$i().createElement("div",{className:t.columns},$i().createElement(n.Component,{model:n}),$i().createElement(r.Component,{model:r})),$i().createElement(i.Component,{model:i}))}constructor({useAncestorTimeRange:e,clearDiffRange:t,baselineFilters:n,comparisonFilters:i}){super({key:"explore-diff-flame-graph",baselinePanel:new nI({target:np.BASELINE,useAncestorTimeRange:Boolean(e),clearDiffRange:Boolean(t),filters:n||[]}),comparisonPanel:new nI({target:np.COMPARISON,useAncestorTimeRange:Boolean(e),clearDiffRange:Boolean(t),filters:i||[]}),$behaviors:[new Ay({key:"metricCrosshairSync",sync:r.DashboardCursorSync.Crosshair}),RM()],body:new EM,presetsPicker:new kM}),function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"useDiffTimeRanges",(()=>{const{baselinePanel:e,comparisonPanel:t}=this.state,{annotationTimeRange:n}=e.useDiffTimeRange(),{annotationTimeRange:r}=t.useDiffTimeRange();return{baselineTimeRange:n,comparisonTimeRange:r}})),this.addActivationHandler(this.onActivate.bind(this))}}const DM=e=>({container:i.css` width: 100%; display: flex; flex-direction: column; `,columns:i.css` display: flex; flex-direction: row; gap: ${e.spacing(1)}; margin-bottom: ${e.spacing(1)}; & > div { flex: 1 1 0; } `});function jM(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function IM(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){jM(a,r,i,o,s,"next",e)}function s(e){jM(a,r,i,o,s,"throw",e)}o(void 0)}))}}class NM extends QC{githubLogin(e){var t=this;return IM((function*(){const n=yield t.fetch("/vcs.v1.VCSService/GithubLogin",{method:"POST",body:JSON.stringify({authorizationCode:e})});return yield n.json()}))()}githubApp(){var e=this;return IM((function*(){const t=yield e.fetch("/vcs.v1.VCSService/GithubApp",{method:"POST",body:JSON.stringify({})});return(yield t.json()).clientID}))()}}function LM(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class MM{isUserTokenExpired(e=0){return Date.now()>=this.expiry.getTime()-e}static decode(e){if(void 0===e||""===e)return;let t;try{t=atob(e)}catch(e){return void Xi.error(e,{info:"Failed to base64 decode GitSession value"})}const{payload:n,isLegacy:r}=MM.tryDecode(t);return r?new MM(e,864e13):new MM(n.metadata,Number(n.expiry))}static tryDecode(e){try{return{payload:JSON.parse(e),isLegacy:!1}}catch(e){return{payload:void 0,isLegacy:!0}}}constructor(e,t){LM(this,"oauthTokenMetadata",void 0),LM(this,"expiry",void 0),this.oauthTokenMetadata=e,this.expiry=new Date(t)}}function FM(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const $M="pyroscope_git_session";class BM{getCookie(){return this.syncCookieWithBrowser(),this.sessionCookie}setCookie(e){e.startsWith(`${$M}=`)||(e=`${$M}=${e}`);const t=BM.getCookieFromJar(e,$M);void 0!==t&&(this.deleteLegacyCookie(),this.rawCookie=t,this.sessionCookie=MM.decode(t.value),document.cookie=`${e}; path=/`)}deleteCookie(){document.cookie=`${$M}=; Path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC;`,this.deleteLegacyCookie(),this.rawCookie=void 0,this.sessionCookie=void 0}deleteLegacyCookie(){document.cookie="GitSession=; Path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC;"}syncCookieWithBrowser(){var e,t;const n=BM.getCookieFromJar(document.cookie,$M);(null==n?void 0:n.key)===(null===(e=this.rawCookie)||void 0===e?void 0:e.key)&&(null==n?void 0:n.value)===(null===(t=this.rawCookie)||void 0===t?void 0:t.value)||(void 0!==n?this.setCookie(`${n.key}=${n.value}`):this.deleteCookie())}static getCookieFromJar(e,t){return e.split(";").map((e=>{const[t,...n]=e.trim().split("="),r=n.join("=");return{key:t.trim(),value:null==r?void 0:r.trim()}})).find((({key:e})=>e===t))}constructor(){FM(this,"rawCookie",void 0),FM(this,"sessionCookie",void 0)}}const VM=new BM;const zM=800,UM=950;function qM(e,t){const n=function(e,t){const n=new URL("/login/oauth/authorize","https://github.com");return n.searchParams.set("client_id",e),n.searchParams.set("scope","repo"),n.searchParams.set("state",btoa(JSON.stringify({redirect_uri:window.location.origin,nonce:t}))),n.toString()}(e,t),{top:r}=window;var i,a;const o=(null!==(i=null==r?void 0:r.outerWidth)&&void 0!==i?i:0)/2+(null!==(a=null==r?void 0:r.screenX)&&void 0!==a?a:0)-zM/2;var s,l;const c=(null!==(s=null==r?void 0:r.outerHeight)&&void 0!==s?s:0)/2+(null!==(l=null==r?void 0:r.screenY)&&void 0!==l?l:0)-UM/2;return window.open(n,"GitHub Login",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${zM}, height=${UM}, top=${c}, left=${o}`)}function HM(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function GM(){var e;return e=function*(e,t,n,r,i){if(r&&r.close(),null==n?void 0:n.isUserTokenExpired())try{return void(yield t.refresh())}catch(e){Xi.error(e,{info:"Failed to refresh GitHub user token"}),VM.deleteCookie()}try{i(qM(yield e.githubApp(),lF))}catch(e){Ds(e,["Failed to start login flow.",e.message])}},GM=function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){HM(a,r,i,o,s,"next",e)}function s(e){HM(a,r,i,o,s,"throw",e)}o(void 0)}))},GM.apply(this,arguments)}function WM(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function QM(){var e;return e=function*(e,t,n){const r=t.get("code");if(!r)return"";const i=t.get("state");if(!i)throw new Error("Invalid state parameter!");let a;try{a=JSON.parse(atob(i))}catch(e){throw new Error("Invalid state parameter!")}if(a.nonce!==n)throw new Error("Invalid nonce parameter!");return(yield e.githubLogin(r)).cookie},QM=function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){WM(a,r,i,o,s,"next",e)}function s(e){WM(a,r,i,o,s,"throw",e)}o(void 0)}))},QM.apply(this,arguments)}function KM(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function YM({vcsClient:e,externalWindow:t,setExternalWindow:n,setSessionCookie:r,nonce:i}){(0,Fi.useEffect)((()=>{const a=function(){var o,s=(o=function*(){if(t&&!t.closed){try{const a=function(e){try{return new URL(e.location.href).searchParams}catch(e){return null}}(t);if(null!==a){const o=yield function(e,t,n){return QM.apply(this,arguments)}(e,a,i);if(o)return r(o),t.close(),void n(null)}}catch(e){return Ds(e,["Error while login in with GitHub!",e.message]),t.close(),void n(null)}window.setTimeout(a,700)}else n(null)},function(){var e=this,t=arguments;return new Promise((function(n,r){var i=o.apply(e,t);function a(e){KM(i,n,r,a,s,"next",e)}function s(e){KM(i,n,r,a,s,"throw",e)}a(void 0)}))});return function(){return s.apply(this,arguments)}}();return t&&a(),()=>{t&&(t.close(),n(null))}}),[t,n,r,i,e])}function XM(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function JM(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){XM(a,r,i,o,s,"next",e)}function s(e){XM(a,r,i,o,s,"throw",e)}o(void 0)}))}}const ZM={isLoginInProgress:!1,isLoggedIn:!1,isSessionExpired:!1,login:JM((function*(){}))},eF=(0,Fi.createContext)(ZM);function tF(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function nF(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){tF(a,r,i,o,s,"next",e)}function s(e){tF(a,r,i,o,s,"throw",e)}o(void 0)}))}}function rF(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const iF=Object.freeze({sha:"",date:void 0,author:{login:"unknown author",avatarURL:""},message:"",URL:""});class aF extends QC{getFile(e,t,n,r){var i=this;return nF((function*(){return(yield i.postWithRefresh("/vcs.v1.VCSService/GetFile",JSON.stringify({repositoryURL:e,ref:t,localPath:n,rootPath:r}))).json()}))()}getCommits(e){var t=this;return nF((function*(){return yield Promise.all(e.map((({repositoryUrl:e,gitRef:n})=>e&&n?t.getCommit(e,n).catch((t=>(Xi.error(t,{info:`Error while fetching commit from repo "${e}" (${n})!'`}),iF))):iF)))}))()}refresh(){var e=this;return nF((function*(){return e.refreshSession()}))()}getCommit(e,t){var n=this;return nF((function*(){var r;const i=yield n.postWithRefresh("/vcs.v1.VCSService/GetCommit",JSON.stringify({repositoryURL:e,ref:t})),a=yield i.json();return(r=a).date&&(r.date=new Date(a.date)),a}))()}postWithRefresh(e,t){var n=this;return nF((function*(){var r;if(n.isRefreshing)return n.queueRequest(e,t);if(null===(r=n.sessionManager.getCookie())||void 0===r?void 0:r.isUserTokenExpired(aF.BIAS_MS)){n.isRefreshing=!0;try{yield n.refreshSession()}catch(e){n.sessionManager.deleteCookie(),n.flushQueue(e)}n.flushQueue(),n.isRefreshing=!1}return n.post(e,t)}))()}post(e,t){var n=this;return nF((function*(){return n.fetch(e,{method:"POST",body:t})}))()}refreshSession(){var e=this;return nF((function*(){const t=yield e.fetch("/vcs.v1.VCSService/GithubRefresh",{method:"POST",body:JSON.stringify({})}),n=yield t.json();e.sessionManager.setCookie(n.cookie)}))()}queueRequest(e,t){var n=this;return nF((function*(){return new Promise(((r,i)=>{n.pendingQueue.push((a=>{a?i(a):r(n.post(e,t))}))}))}))()}flushQueue(e=void 0){this.pendingQueue.forEach((t=>t(e))),this.pendingQueue=[]}constructor(e){super(e),rF(this,"sessionManager",void 0),rF(this,"pendingQueue",void 0),rF(this,"isRefreshing",void 0),this.sessionManager=VM,this.isRefreshing=!1,this.pendingQueue=[]}}function oF(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function sF(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){oF(a,r,i,o,s,"next",e)}function s(e){oF(a,r,i,o,s,"throw",e)}o(void 0)}))}}rF(aF,"BIAS_MS",3e5);const lF=btoa(String.fromCharCode(...crypto.getRandomValues(new Uint8Array(32))));function cF({dataSourceUid:e,children:t}){const n=vj.build(e,NM),r=vj.build(e,aF),[i,a]=(0,Fi.useState)(ZM.isLoginInProgress),[o,s]=function(){const[e,t]=(0,Fi.useState)(VM.getCookie());return[e,e=>{e?(VM.setCookie(e),t(VM.getCookie())):(VM.deleteCookie(),t(void 0))}]}(),[l,c]=(0,Fi.useState)();(0,Fi.useEffect)((()=>{s("")}),[e]),YM({vcsClient:n,externalWindow:l,setExternalWindow:c,setSessionCookie:s,nonce:lF});const u=!!l&&!l.closed;u!==i&&a(u);const d=(0,Fi.useCallback)(sF((function*(){try{yield function(e,t,n,r,i){return GM.apply(this,arguments)}(n,r,o,l,c)}catch(e){Ds(e,["Failed to login to GitHub",e.message])}})),[n,r,o,l]);return $i().createElement(eF.Provider,{value:{isLoginInProgress:i,isLoggedIn:Boolean(o&&!o.isUserTokenExpired()),isSessionExpired:Boolean(null==o?void 0:o.isUserTokenExpired()),login:d}},t)}class uF extends r.BusEventWithPayload{}function dF(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function pF(e){for(var t=1;t`${e}${t}"${n}"`)).join(",");return kR(new cy({datasource:QP,queries:[pF({refId:"profile",queryType:"profile",profileTypeId:"$profileMetricId",labelSelector:`{${i},$filters}`,maxNodes:t},n&&{spanSelector:[n]})]}))}!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(uF,"type","remove-span-selector");var fF=__webpack_require__(585);function mF(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gF(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}class yF extends fF.Message{constructor(e,t,n,r,i){super(),mF(this,"profile_typeID",void 0),mF(this,"label_selector",void 0),mF(this,"start",void 0),mF(this,"end",void 0),mF(this,"max_nodes",void 0),this.profile_typeID=e,this.label_selector=t,this.start=n,this.end=r,this.max_nodes=i}}function bF(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function vF(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){bF(a,r,i,o,s,"next",e)}function s(e){bF(a,r,i,o,s,"throw",e)}o(void 0)}))}}gF([fF.Field.d(1,"string")],yF.prototype,"profile_typeID",void 0),gF([fF.Field.d(2,"string")],yF.prototype,"label_selector",void 0),gF([fF.Field.d(3,"int64")],yF.prototype,"start",void 0),gF([fF.Field.d(4,"int64")],yF.prototype,"end",void 0),gF([fF.Field.d(5,"int64")],yF.prototype,"max_nodes",void 0);class wF extends QC{static buildPprofRequest(e,t,n){const{profileMetricId:r,labelsSelector:i}=CR(e),a=1e3*t.from.unix(),o=1e3*t.to.unix(),s=new yF(r,i,a,o,n);return yF.encode(s).finish()}selectMergeProfile({query:e,timeRange:t,maxNodes:n}){var r=this;return vF((function*(){return(yield r.fetch("/querier.v1.QuerierService/SelectMergeProfile",{method:"POST",headers:{"content-type":"application/proto"},body:new Blob([wF.buildPprofRequest(e,t,n)])})).blob()}))()}selectMergeProfileJson({profileMetricId:e,labelsSelector:t,start:n,end:r,stackTrace:i,maxNodes:a}){var o=this;return vF((function*(){return(yield o.fetch("/querier.v1.QuerierService/SelectMergeProfile",{method:"POST",body:JSON.stringify({profile_typeID:e,label_selector:t,start:1e3*n,end:1e3*r,stackTraceSelector:{call_site:i.map((e=>({name:e})))},maxNodes:a})})).json()}))()}}function SF(e,t){const{serviceId:n,profileMetricId:r}=CR(e),i=`${t.from.format("YYYY-MM-DD_HHmm")}-to-${t.to.format("YYYY-MM-DD_HHmm")}`;return`${n.replace(/\//g,"-")}_${r}_${i}`}function EF(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}const xF=new class extends ca{upload(e,t){var n,r=this;return(n=function*(){const n=yield r.fetch("/upload/v1",{method:"POST",body:JSON.stringify({name:e,profile:btoa(JSON.stringify(t)),fileTypeData:{units:t.metadata.units,spyName:t.metadata.spyName},type:"json"})});return yield n.json()},function(){var e=this,t=arguments;return new Promise((function(r,i){var a=n.apply(e,t);function o(e){EF(a,r,i,o,s,"next",e)}function s(e){EF(a,r,i,o,s,"throw",e)}o(void 0)}))})()}constructor(){super("https://flamegraph.com/api",{"content-type":"application/json"})}};function OF(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function _F(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){OF(a,r,i,o,s,"next",e)}function s(e){OF(a,r,i,o,s,"throw",e)}o(void 0)}))}}function TF(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class CF extends bh{fetchFlamebearerProfile({dataSourceUid:e,query:t,timeRange:n,maxNodes:r}){return _F((function*(){const i=vj.build(e,sM);let a;try{a=yield i.get({query:t,timeRange:n,format:"json",maxNodes:r||oI.maxNodes})}catch(e){return Ds(e,["Error while loading flamebearer profile data!",e.message]),null}return a}))()}fetchPprofProfile({dataSourceUid:e,query:t,timeRange:n,maxNodes:r}){return _F((function*(){const i=vj.build(e,wF);let a;try{const e=yield i.selectMergeProfile({query:t,timeRange:n,maxNodes:r||oI.maxNodes});a=yield new Response(e.stream().pipeThrough(new CompressionStream("gzip"))).blob()}catch(e){return Ds(e,["Failed to export to pprof!",e.message]),null}return a}))()}constructor(){super({key:"export-flame-graph-menu"}),TF(this,"useSceneExportMenu",(({query:e,timeRange:t})=>{const n=tm.findByKeyAndType(this,"dataSource",sR).useState().value,[r]=hM(),{settings:i}=dI();var a=this;const o=function(){var i=_F((function*(){Ts("g_pyroscope_app_export_profile",{format:"json"});const i=yield a.fetchFlamebearerProfile({dataSourceUid:n,query:e,timeRange:t,maxNodes:r});if(!i)return;const o=`${SF(e,t)}.json`,s=`data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(i))}`;Zd()(s,o)}));return function(){return i.apply(this,arguments)}}();var s=this;const l=function(){var i=_F((function*(){Ts("g_pyroscope_app_export_profile",{format:"pprof"});const i=yield s.fetchPprofProfile({dataSourceUid:n,query:e,timeRange:t,maxNodes:r});if(!i)return;const a=`${SF(e,t)}.pb.gz`;Zd()(i,a)}));return function(){return i.apply(this,arguments)}}();var c=this;const u=function(){var i=_F((function*(){Ts("g_pyroscope_app_export_profile",{format:"flamegraph.com"});const i=yield c.fetchFlamebearerProfile({dataSourceUid:n,query:e,timeRange:t,maxNodes:r});if(i)try{const n=yield xF.upload(SF(e,t),i);if(!n.url)throw new Error("Empty URL received.");const r=document.createElement("a");r.target="_blank",r.href=n.url,document.body.appendChild(r),r.click(),document.body.removeChild(r)}catch(e){return void Ds(e,["Failed to export to flamegraph.com!",e.message])}}));return function(){return i.apply(this,arguments)}}();return{data:{shouldDisplayFlamegraphDotCom:Boolean(null==i?void 0:i.enableFlameGraphDotComExport)},actions:{downloadPng:()=>{Ts("g_pyroscope_app_export_profile",{format:"png"});const n=`${SF(e,t)}.png`;document.querySelector('canvas[data-testid="flameGraph"]').toBlob((e=>{if(e)Zd()(e,n);else{const e=new Error("Error while creating the image, no blob.");Ds(e,["Failed to export to png!",e.message])}}),"image/png")},downloadJson:o,downloadPprof:l,uploadToFlamegraphDotCom:u}}}))}}function kF(){return(0,Fi.useContext)(eF)}function PF(e){const{login:t,isSessionExpired:n}=kF(),{settings:i}=dI(),a=null==i?void 0:i.enableFunctionDetails,[o,s]=(0,Fi.useState)([]),l=(0,Fi.useCallback)((({item:i},o)=>a&&0!==i.level?[{label:"Function details",icon:"info-circle",onClick:()=>{Ts("g_pyroscope_app_function_details_clicked"),s(function(e,t){let n=[];const i=t.fields.find((({name:e})=>"label"===e));if(!i)return n;const a=(0,r.getDisplayProcessor)({field:i,theme:(0,r.createTheme)()});let o=e;for(;o&&o.level>0;){var s;for(const e of o.itemIndexes)n.unshift(a(i.values[e]).text);o=null===(s=o.parents)||void 0===s?void 0:s[0]}return n}(i,o)),e.open("function-details"),n&&t()}}]:[]),[a,n,t,e]);return{data:{stacktrace:o},actions:{getExtraFlameGraphMenuItems:l}}}TF(CF,"Component",(({model:e,query:t,timeRange:n})=>{const{actions:r}=e.useSceneExportMenu({query:t,timeRange:n});return $i().createElement(o.Dropdown,{overlay:$i().createElement(o.Menu,null,$i().createElement(o.Menu.Item,{label:"png",onClick:r.downloadPng}),$i().createElement(o.Menu.Item,{label:"json",onClick:r.downloadJson}),$i().createElement(o.Menu.Item,{label:"pprof",onClick:r.downloadPprof}))},$i().createElement(o.Button,{icon:"download-alt",size:"sm",variant:"secondary",fill:"outline","aria-label":"Export profile data",tooltip:"Export profile data"}))}));const RF="gpt-4-1106-preview",AF=({functionDetails:e,lines:t})=>{const n=`\nYou are a code optimization expert. I will give you code, each line annotated with amount of time spent on a particular line (it's in the beginning of each line), and a function name.\n\nI want you to write back a new improved code for this function and explain why you made changes.\n\nMake sure to take annotations into strong consideration. If a suggested performance improvement isn't backed up by information from the annotations, do not include it.\n\nDo not mention the actual numbers from the annotations, users can already see how much time was spent on each line. Do not list various lines and their time spent. When you mention functions or lines, do not mention the time spent on them.\n\nIf you can't find any meaningful performance optimizations, say so. Ask for context if you think other context might help make decisions. If you think the problem is with user input and not the actual code itself, say so.\n\nWhen you output code in markdown, please don't specify language after 3 backticks (e.g instead of saying "\`\`\`go" say "\`\`\`"), and always add a new line after 3 backticks.\n\nFunction name is \`${e.name}\`. Do not mention the function name, users can already see it.\n\nWhen posting a response, follow the outline below:\n* give a brief explanation of things that could be improve\n* print new code if it's possible\n* explain each change in more details\n\n\nAnnotated code is below:\n\`\`\`\n${function(e,t){let n=t.map((t=>`(${t.cum} ${e.unit}) ${t.line}`)).join("\n");return n}(e,t)}\n\`\`\`\n`;return{system:"",user:n}};function DF(e){const{reply:t,error:n}=function(e){const[t,n]=(0,Fi.useState)(""),[r,i]=(0,Fi.useState)(!1),[a,o]=(0,Fi.useState)(!1),[s,l]=(0,Fi.useState)([]),[c,u]=(0,Fi.useState)(null),d=(0,Fi.useCallback)((e=>{l(e),u(null),n(""),i(!0),o(!1),eN({model:RF,messages:e}).pipe(ZI()).subscribe({next:n,error(e){u(e),i(!1),o(!0)},complete(){i(!1),o(!0)}})}),[]),p=(0,Fi.useCallback)((e=>{const n=[{role:"assistant",content:t},{role:"user",content:e}];try{d([...s,...n])}catch(e){u(e)}}),[s,t,d]);return(0,Fi.useEffect)((()=>{if(s.length>0)return;const t=AF(e);try{d([{role:"system",content:t.system},{role:"system",content:t.user}])}catch(e){u(e)}}),[s.length,e,d]),{reply:{text:t,hasStarted:r,hasFinished:a,messages:s,askFollowupQuestion:p},error:c}}(e);return{data:{isLoading:!n&&!t.text.trim(),llmError:n,reply:t,shouldDisplayReply:Boolean((null==t?void 0:t.hasStarted)||(null==t?void 0:t.hasFinished)),shouldDisplayFollowUpForm:!n&&Boolean(null==t?void 0:t.hasFinished)},actions:{submitFollowupQuestion(e){t.askFollowupQuestion(e)}}}}const jF=()=>({title:i.css` margin: -4px 0 4px 0; `,content:i.css``});function IF({suggestionPromptInputs:e}){const t=(0,o.useStyles2)(jF),{data:n,actions:r}=DF(e);return $i().createElement($i().Fragment,null,$i().createElement("h6",{className:t.title},"Code Optimization Suggestions"),$i().createElement("div",{className:t.content},n.isLoading&&$i().createElement($i().Fragment,null,$i().createElement(o.Spinner,{inline:!0})," Analyzing..."),n.fetchError&&$i().createElement(pI,{severity:"error",title:"Error while fetching profiles!",message:"Sorry for any inconvenience, please try again later."}),n.llmError&&$i().createElement(pI,{severity:"error",title:"Failed to generate content using OpenAI!",error:n.llmError,message:"Sorry for any inconvenience, please try again later or if the problem persists, contact your organization admin."}),n.shouldDisplayReply&&$i().createElement(eM,{reply:n.reply}),n.shouldDisplayFollowUpForm&&$i().createElement(rM,{onSubmit:r.submitFollowupQuestion})))}function NF(e,t){let n=e;const r=e.match(/raw\.githubusercontent\.com\/([^/]+)\/([^/]+)\/(.+)/);if(r){const[,e,t,i]=r;n=`https://github.com/${e}/${t}/blob/${i}`}return void 0===t||e.includes("#")||(n+=`#L${t}`),n}const LF=5;function MF(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function FF(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function $F(e,t){const{isLoggedIn:n}=kF(),{version:r}=t,[i,a]=(0,Fi.useState)(!1);var o,s,l;const{fileInfo:c,error:u,isFetching:d}=function({enabled:e,dataSourceUid:t,repository:n,gitRef:r,localPath:i,rootPath:a}){const o=vj.build(t,aF),{isFetching:s,error:l,data:c}=Pa({enabled:Boolean(e&&i),queryKey:["vcs-file",n,r,i,a],queryFn:()=>o.getFile(n,r,i,a).then((e=>({content:e.content,URL:e.URL}))).then((e=>({URL:e.URL,content:atob(e.content)})))});return{isFetching:s,error:o.isAbortError(l)?null:l,fileInfo:c}}({enabled:n,dataSourceUid:e,localPath:t.fileName,repository:null!==(o=null==r?void 0:r.repository)&&void 0!==o?o:"",gitRef:null!==(s=null==r?void 0:r.git_ref)&&void 0!==s?s:"",rootPath:null!==(l=null==r?void 0:r.root_path)&&void 0!==l?l:""}),p=(0,Fi.useMemo)((()=>(null==c?void 0:c.content)?function(e,t){if(!t.size)return[];const n=Array.from(t.values()).sort(((e,t)=>e.line-t.line)),r=e.split("\n"),i=Math.max(0,n[0].line-LF-1),a=Math.min(r.length,n[n.length-1].line+LF);return r.slice(i,a).map(((e,n)=>{const r=n+i+1,a=t.get(r);var o,s;return{line:e,number:r,cum:null!==(o=null==a?void 0:a.cum)&&void 0!==o?o:0,flat:null!==(s=null==a?void 0:a.flat)&&void 0!==s?s:0}}))}(c.content,t.callSites):function(e){if(!e.size)return[];const t=Array.from(e.values()).sort(((e,t)=>e.line-t.line)),n=Math.max(0,t[0].line-LF-1),r=t[t.length-1].line+LF+1,i=[];for(let t=n+1;t{var t;return FF(function(e){for(var t=1;te.line))},actions:{setOpenAiSuggestions:a}}}function BF(e){switch(e){case"nanoseconds":return(0,r.getValueFormat)("ns");case"microseconds":return(0,r.getValueFormat)("µs");case"milliseconds":return(0,r.getValueFormat)("ms");case"seconds":return(0,r.getValueFormat)("s");case"count":return(0,r.getValueFormat)("short");default:return(0,r.getValueFormat)(e)}}const VF=({lines:e,unit:t,githubUrl:n,isLoadingCode:r,noCodeAvailable:a,onOptimizeCodeClick:s})=>{const l=(0,o.useStyles2)(GF),c=BF(t),u=e=>{if(e<=0)return".";const t=c(e);return t.suffix?t.text+t.suffix:t.text};UF(e);const[d,p]=e.reduce((([e,t],{flat:n,cum:r})=>[e+n,t+r]),[0,0]);return $i().createElement("div",{"data-testid":"function-details-code-container"},$i().createElement("div",{className:l.container},$i().createElement("div",{className:l.header},$i().createElement("div",{className:l.breakdownLabel},$i().createElement("h6",null,"Breakdown per line"),$i().createElement("span",null,r&&$i().createElement(o.Spinner,{inline:!0}),!r&&a&&"(file information unavailable)")),$i().createElement("div",{className:l.buttons},$i().createElement(o.LinkButton,{disabled:Boolean(r||!n),href:n,target:"_blank",icon:"github",fill:"text"},"View on GitHub"),$i().createElement(iN,{onClick:s,disabled:r||a,interactionName:"g_pyroscope_app_optimize_code_clicked"},"Optimize Code")))),$i().createElement("pre",{className:l.codeBlock,"data-testid":"function-details-code"},$i().createElement("div",{className:(0,i.cx)(l.highlighted,l.codeBlockHeader)},zF("Total:",u(d),u(p)," (self, total)")),e.map((({line:e,number:t,cum:n,flat:r})=>$i().createElement("div",{key:e+t+n+r,className:r+n>0?l.highlighted:""},zF(`${t} `,u(r),u(n),e))))))},zF=(e,t,n,r)=>{const i=e.padStart(7," ")+t.padStart(12," ")+n.padStart(12," ");return r?`${i} ${r}`:i},UF=e=>{if(0===e.length)return;let t=qF(e[0].line);for(let n=1;n{const t=e.match(/^[ \t]*/);var n;return null!==(n=null==t?void 0:t[0])&&void 0!==n?n:""},HF=(e,t)=>{let n=0;for(let r=0;r({container:i.css` display: flex; flex-direction: row; align-items: flex-start; width: 100%; `,header:i.css` display: flex; justify-content: space-between; align-items: end; width: 100%; `,breakdownLabel:i.css` & > h6 { display: inline-block; margin-top: ${e.spacing(1)}; } & > span { margin-left: ${e.spacing(1)}; font-size: ${e.typography.bodySmall.fontSize}; } & > svg { margin-left: ${e.spacing(1)}; } `,buttons:i.css` display: flex; flex-wrap: no-wrap; `,codeBlock:i.css` position: relative; min-height: 240px; font-size: 12px; overflow-x: auto; white-space: pre; color: ${e.colors.text.secondary}; `,highlighted:i.css` color: ${e.colors.text.maxContrast}; `,codeBlockHeader:i.css` margin-bottom: 8px; `});function WF({dataSourceUid:e,functionDetails:t}){var n,r;const{data:i,actions:a}=$F(e,t);return i.fetchError&&404!==(null===(r=i.fetchError)||void 0===r||null===(n=r.response)||void 0===n?void 0:n.status)&&Ds(i.fetchError,["Failed to fetch file information!",i.fetchError.message]),$i().createElement($i().Fragment,null,$i().createElement(VF,{lines:i.lines,unit:i.unit,githubUrl:i.githubUrl,isLoadingCode:i.isLoadingCode,noCodeAvailable:i.noCodeAvailable,onOptimizeCodeClick:()=>{var e;a.setOpenAiSuggestions(!0),null===(e=document.getElementById("ai-suggestions-panel"))||void 0===e||e.scrollIntoView({behavior:"smooth"})}}),$i().createElement("h6",{id:"ai-suggestions-panel",style:{height:0,marginBottom:0}}),i.openAiSuggestions?$i().createElement(IF,{suggestionPromptInputs:{functionDetails:t,lines:i.lines}}):null)}const QF=e=>({ellipsis:i.css` color: ${e.colors.primary.text}; text-overflow: ellipsis; overflow: hidden; direction: rtl; white-space: nowrap; `}),KF=({enableIntegration:e,repository:t})=>{const n=(0,o.useStyles2)(QF),{isLoginInProgress:r,isLoggedIn:i,login:a}=kF();return e?r?$i().createElement($i().Fragment,null,$i().createElement(o.Spinner,null),$i().createElement("span",null,"Connecting to GitHub...")):i?$i().createElement($i().Fragment,null,$i().createElement(o.Icon,{name:"github",size:"lg"}),$i().createElement("a",{className:n.ellipsis,href:t.commitUrl,target:"_blank",rel:"noreferrer",title:"View commit"},$i().createElement(o.Icon,{name:"external-link-alt"})," ",t.commitName)):$i().createElement(o.Button,{icon:"github",variant:"primary",onClick:a,tooltip:"Once connected, the GitHub code will be accessible only from this browser session.",tooltipPlacement:"top"},"Connect to ",t.name):$i().createElement($i().Fragment,null,"-")};function YF(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function XF(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function JF(e,t){const n=e.map((e=>{var n;return XF(function(e){for(var t=1;te+t),0),total:t}})}));return n}const ZF="https://github.com/";function e$(e,t){if(!(null==t?void 0:t.repository))return null;const n=t.repository,r=n.replace(ZF,""),i=t.git_ref;return{isGitHub:e,url:n,name:r,commitUrl:i?`${n}/commit/${i}`:n,commitName:i?`${r}@${i.substring(0,7)}`:r}}const t$=(e,t,n)=>{let r;try{r=n?JSON.parse(e.stringTable[Number(n.buildId)]):void 0}catch(e){}return{name:e.stringTable[Number(t.name)],version:r,startLine:Number.isNaN(Number(t.startLine))?void 0:Number(t.startLine),fileName:e.stringTable[Number(t.filename)],callSites:new Map,unit:e.stringTable[Number(e.sampleType[0].unit)],commit:iF}};function n$(e,t,n,r,i,a,o){const s=new Set;a.locationId.forEach(((l,c)=>{const u=n.get(l);u&&u.line.forEach((n=>{const d=r.get(n.functionId);if(!d)return;if(t.stringTable[Number(d.name)]!==e)return;if(s.has(l))return;s.add(l);const p=o.get(u.mappingId)||t$(t,d,i.get(u.mappingId));o.set(u.mappingId,function(e,t,n,r){const i=Number(t.line),a=e.callSites.get(i)||{line:Number(t.line),flat:0,cum:0},o=0===r?n:0,s=n;return a.flat+=o,a.cum+=s,e.callSites.set(i,a),e}(p,n,Number(a.value[0]),c))}))}))}function r$(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function i$(){var e;return e=function*(e,t){const n=vj.build(e,aF),r=t.map((e=>{var t,n,r;return{repositoryUrl:(null==e||null===(t=e.version)||void 0===t?void 0:t.repository)||"",gitRef:(null==e||null===(n=e.version)||void 0===n?void 0:n.git_ref)||"HEAD",rootPath:(null==e||null===(r=e.version)||void 0===r?void 0:r.root_path)||""}}));return(yield n.getCommits(r)).forEach(((e,n)=>{t[n].commit=e})),t},i$=function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){r$(a,r,i,o,s,"next",e)}function s(e){r$(a,r,i,o,s,"throw",e)}o(void 0)}))},i$.apply(this,arguments)}const a$=e=>Array.from(e.callSites.values()).reduce(((e,{cum:t})=>e+t),0),o$=(e,t)=>a$(t)-a$(e);function s$(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function l$(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){s$(a,r,i,o,s,"next",e)}function s(e){s$(a,r,i,o,s,"throw",e)}o(void 0)}))}}function c$({dataSourceUid:e,query:t,timeRange:n,stackTrace:r}){const{profileMetricId:i,labelsSelector:a}=CR(t),[o,s]=[n.from.unix(),n.to.unix()],{isLoggedIn:l}=kF(),c=vj.build(e,wF),{isFetching:u,error:d,data:p}=Pa({enabled:Boolean(i&&a&&r.length>0&&o>0&&s>0),queryKey:["function-details",i,a,o,s,r,l],queryFn:l$((function*(){const t=yield c.selectMergeProfileJson({profileMetricId:i,labelsSelector:a,start:o,end:s,stackTrace:r,maxNodes:500}),n=function(e,t){var n,r,i,a;const o=new Map,s=new Map(null===(n=t.location)||void 0===n?void 0:n.map((e=>[e.id,e]))),l=new Map(null===(r=t.function)||void 0===r?void 0:r.map((e=>[e.id,e]))),c=new Map(null===(i=t.mapping)||void 0===i?void 0:i.map((e=>[e.id,e])));return null===(a=t.sample)||void 0===a||a.filter((e=>void 0!==e.locationId)).forEach((n=>n$(e,t,s,l,c,n,o))),Array.from(o.values())}(r[r.length-1],t).sort(o$);return l?function(e,t){return i$.apply(this,arguments)}(e,n):n}))}),h=(0,Fi.useMemo)((()=>(null==p?void 0:p.length)?p:[{name:r.at(-1),startLine:void 0,fileName:"",callSites:new Map,unit:"",commit:iF}]),[p,r]);return{isFetching:u,error:c.isAbortError(d)?null:d,functionsDetails:h}}const u$=[60,3600,86400,604800,2592e3,31536e3,1/0],d$=["second","minute","hour","day","week","month","year"],p$=new Intl.RelativeTimeFormat("en-US",{numeric:"auto"});const h$=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"2-digit"});function f$(e){return e?`${h$.format(e)} (${function(e){const t=e.getTime(),n=Math.round((t-Date.now())/1e3),r=u$.findIndex((e=>e>Math.abs(n))),i=r?u$[r-1]:1;return p$.format(Math.floor(n/i),d$[r])}(e)})`:"?"}const m$=e=>({container:i.css` display: flex; flex-direction: column; justify-content: flex-start; `,firstLine:i.css` display: flex; flex-direction: row; align-items: center; gap: 1em; `,sha:i.css` font-family: monospace; `,sample:i.css` font-size: 12px; `,secondLine:i.css` display: flex; flex-direction: row; align-items: center; font-size: 12px; color: ${e.colors.text.secondary}; `,avatar:i.css` display: inline-block; margin-right: 4px; border-radius: 50%; background: grey; width: 16px; height: 16px; `,message:i.css` font-size: 12px; color: ${e.colors.text.secondary}; `});function g$({commit:e}){const t=(0,o.useStyles2)(m$),{author:n,samples:r}=e,i=n.login,a=n.avatarURL,s=BF(r.unit)(r.current),l=Math.round(r.current/r.total*100);return $i().createElement("div",{className:t.container},$i().createElement("div",{className:t.firstLine},$i().createElement("span",{className:t.sha},S$(e.sha)),$i().createElement("span",{className:t.sample},s.text,s.suffix," (",l,"%)")),$i().createElement("div",{className:t.secondLine},a&&$i().createElement("img",{className:t.avatar,src:a,alt:i}),$i().createElement("span",null,i," on ",f$(e.date))),$i().createElement("span",{className:t.message},E$(e.message)))}const y$=e=>({container:i.css` display: flex; flex-direction: row; justify-content: flex-start; align-items: center; gap: 1em; `,sha:i.css` font-family: monospace; `,message:i.css` color: ${e.colors.text.secondary}; `});function b$({commit:e}){const t=(0,o.useStyles2)(y$);return $i().createElement("div",{className:t.container},$i().createElement("span",{className:t.sha},S$(e.sha)),$i().createElement("div",{className:t.message},$i().createElement("span",null,E$(e.message))))}function v$({commits:e,selectedCommit:t,onChange:n}){return $i().createElement(o.Select,{options:e.map((e=>({label:e.sha,value:e}))),value:{label:t.sha,value:t},hideSelectedOptions:!0,isSearchable:!1,noOptionsMessage:"No commits found",formatOptionLabel:w$,onChange:e=>{e.value&&n(e.value)}})}function w$(e,t){var n;const{value:r}=e;if(!r)return null;return(null===(n=t.selectValue[0])||void 0===n?void 0:n.value)===r?$i().createElement(b$,{commit:r}):$i().createElement(g$,{commit:r})}const S$=e=>e===iF.sha?e:e.substring(0,7),E$=e=>e.split("\n")[0],x$=({onDismiss:e})=>$i().createElement(o.Alert,{severity:"info",title:"Integrate with Github",buttonContent:"Dismiss",onRemove:e},$i().createElement("p",null,"This language supports integration with ",$i().createElement(o.Icon,{name:"github"})," GitHub."),$i().createElement("p",null,"To activate this feature, you will need to add two new labels when sending profiles"," ",$i().createElement("code",null,"service_repository")," and ",$i().createElement("code",null,"service_ref"),"."," "),$i().createElement("p",null,"They should respectively be set to the full repository GitHub URL and the current"," ",$i().createElement(o.TextLink,{href:"https://docs.github.com/en/rest/git/refs?apiVersion=2022-11-28#about-git-references",external:!0},"git ref")," ","of the running service."),$i().createElement(o.Icon,{name:"document-info"})," ",$i().createElement(o.TextLink,{href:"https://grafana.com/docs/grafana-cloud/monitor-applications/profiles/pyroscope-github-integration/",external:!0},"Learn more"));function O$({isLoading:e,children:t}){return e?$i().createElement(o.Spinner,{inline:!0}):$i().createElement($i().Fragment,null,t)}const _$=(0,Fi.memo)(O$);function T$(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function C$(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class k$ extends bh{constructor(){super({key:"function-details-panel"}),C$(this,"useSceneFunctionDetailsPanel",((e,t)=>{var n,r;const i=tm.findByKeyAndType(this,"dataSource",sR).useState().value,a=oR(this,"filters"),{functionsDetails:o,error:s,isFetching:l}=c$({dataSourceUid:i,query:a,timeRange:t,stackTrace:e}),[c,u]=(0,Fi.useState)(),[d,p]=(0,Fi.useState)(o[0]),[h,f]=(0,Fi.useState)(ta.has(ta.KEYS.GITHUB_INTEGRATION));o&&c!==o&&(u(o),d!==o[0]&&p(o[0]));const m=((null==d||null===(n=d.version)||void 0===n?void 0:n.repository)||"").startsWith(ZF);const g=null==d||null===(r=d.fileName)||void 0===r?void 0:r.endsWith(".go"),y=!h&&!m&&g,b=(0,Fi.useMemo)((()=>o.map((e=>Array.from(e.callSites.values()).reduce(((e,{cum:t})=>e+t),0))).reduce(((e,t)=>e+t),0)),[o]),v=JF(o,b),w=v.find((({sha:e})=>{var t;return e===(null==d||null===(t=d.commit)||void 0===t?void 0:t.sha)}));return{data:{isLoading:l,fetchFunctionDetailsError:s,functionDetails:d,repository:e$(m,null==d?void 0:d.version),commits:v,selectedCommit:w,isGitHubSupported:g,shouldDisplayGitHubBanner:y,dataSourceUid:i},actions:{selectCommit(e){const t=o.find((({commit:t})=>t.sha===e.sha));p(t)},copyFilePathToClipboard(){return(e=function*(){try{(null==d?void 0:d.fileName)&&(yield navigator.clipboard.writeText(d.fileName),Is(["File path copied to clipboard!"]))}catch(e){}},function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){T$(a,r,i,o,s,"next",e)}function s(e){T$(a,r,i,o,s,"throw",e)}o(void 0)}))})();var e},dismissGitHubBanner(){ta.set(ta.KEYS.GITHUB_INTEGRATION,{}),f(!0)}}}}))}}C$(k$,"LABEL_WIDTH",16),C$(k$,"Component",(({model:e,timeRange:t,stackTrace:n,onClose:r})=>{const i=(0,o.useStyles2)(P$),{data:a,actions:s}=e.useSceneFunctionDetailsPanel(n,t);return $i().createElement(LI,{className:i.sidePanel,title:"Function Details",isLoading:!1,headerActions:$i().createElement(o.IconButton,{name:"times-circle",variant:"secondary","aria-label":"close",onClick:r}),dataTestId:"function-details-panel"},$i().createElement("div",{className:i.content},a.fetchFunctionDetailsError&&$i().createElement(pI,{severity:"error",title:"Error while fetching function details!",error:a.fetchFunctionDetailsError}),$i().createElement("div",{className:i.container},$i().createElement("div",{className:i.row,"data-testid":"row-function-name"},$i().createElement(o.InlineLabel,{width:k$.LABEL_WIDTH},"Function name"),$i().createElement(o.Tooltip,{content:a.functionDetails.name,placement:"top"},$i().createElement("span",{className:i.textValue},a.functionDetails.name))),$i().createElement("div",{className:i.row,"data-testid":"row-start-line"},$i().createElement(o.InlineLabel,{tooltip:"The line where this function definition starts",width:k$.LABEL_WIDTH},"Start line"),$i().createElement("span",{className:i.textValue},$i().createElement(_$,{isLoading:a.isLoading},void 0!==a.functionDetails.startLine?a.functionDetails.startLine:"-"))),$i().createElement("div",{className:i.row,"data-testid":"row-file-path"},$i().createElement(o.InlineLabel,{tooltip:"File path where that function is defined",width:k$.LABEL_WIDTH},"File"),$i().createElement(_$,{isLoading:a.isLoading},a.functionDetails.fileName?$i().createElement($i().Fragment,null,$i().createElement(o.Tooltip,{content:a.functionDetails.fileName,placement:"top"},$i().createElement("span",{className:i.textValue},"‎","/"===(null==(l=a.functionDetails.fileName)?void 0:l[0])?l.substring(1)+"/":l)),$i().createElement(o.IconButton,{name:"clipboard-alt",tooltip:"Copy to clipboard",onClick:s.copyFilePathToClipboard})):"-")),a.shouldDisplayGitHubBanner&&$i().createElement("div",{className:i.row,"data-testid":"row-github-banner"},$i().createElement(x$,{onDismiss:s.dismissGitHubBanner})),$i().createElement("div",{className:i.row,"data-testid":"row-repository"},$i().createElement(o.InlineLabel,{tooltip:"The repository configured for the selected service",width:k$.LABEL_WIDTH},"Repository"),$i().createElement(_$,{isLoading:a.isLoading},a.repository?a.repository.isGitHub?$i().createElement(KF,{enableIntegration:a.isGitHubSupported,repository:a.repository}):$i().createElement(o.TextLink,{href:a.repository,external:!0},a.repository):"-")),$i().createElement("div",{className:i.row,"data-testid":"row-commit"},$i().createElement(o.InlineLabel,{width:k$.LABEL_WIDTH,tooltip:"The version of the application (commit) where the function is defined. Use the dropdown menu to target a specific commit."},"Commit"),$i().createElement(_$,{isLoading:a.isLoading},$i().createElement(v$,{commits:a.commits,selectedCommit:a.selectedCommit,onChange:s.selectCommit})))),$i().createElement(WF,{dataSourceUid:a.dataSourceUid,functionDetails:a.functionDetails})));var l}));const P$=e=>({sidePanel:i.css` flex: 1 0 50%; margin-left: 8px; max-width: calc(50% - 4px); `,title:i.css` margin: -4px 0 4px 0; `,content:i.css` padding: ${e.spacing(1)}; `,container:i.css` width: 100%; display: flex; flex-direction: column; align-items: flex-start; `,row:i.css` width: 100%; display: flex; flex-direction: row; align-items: center; padding-bottom: 10px; > * { margin-right: 10px !important; } `,textValue:i.css` // hack to have the ellipsis appear at the start of the string direction: rtl; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; `});function R$(e){const{spanSelector:t,removeSpanSelector:n}=e,r=(0,o.useStyles2)(A$);return $i().createElement("div",{className:r.container},$i().createElement(o.Tooltip,{content:`You have added a span selector to the flamegraph query (${t}).`,placement:"top"},$i().createElement("span",null,"Span selector added")),$i().createElement(o.Button,{size:"md",fill:"text",variant:"secondary",icon:"times",tooltip:"Remove span selector from query",tooltipPlacement:"top",onClick:()=>{n()}}))}const A$=()=>({container:i.css` padding: 0 4px; `});function D$(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class j$ extends bh{onActivate(){let e;const t=this.subscribeToState(((t,n)=>{var i;t.$data!==n.$data&&(e&&e.unsubscribe(),e=null===(i=t.$data)||void 0===i?void 0:i.subscribeToState((e=>{var t;(null===(t=e.data)||void 0===t?void 0:t.state)===r.LoadingState.Done&&this.setState({lastTimeRange:e.data.timeRange})})))}));return()=>{t.unsubscribe(),null==e||e.unsubscribe()}}buildTitle(){const e=wR(this,"serviceName"),t=WP(wR(this,"profileMetricId")).type;return $i().createElement($i().Fragment,null,$i().createElement(Ko,{size:"small"}),"Flame graph for ",e," (",t,")")}removeSpanSelector(){this.publishEvent(new uF({}),!0)}constructor(){super({key:"flame-graph",$data:new cy({datasource:QP,queries:[]}),lastTimeRange:void 0,exportMenu:new CF,aiPanel:new cM,functionDetailsPanel:new k$}),D$(this,"useSceneFlameGraph",(e=>{var t,n,i,a,s;const{isLight:l}=(0,o.useTheme2)(),c=(0,Fi.useMemo)((()=>()=>(0,r.createTheme)({colors:{mode:l?"light":"dark"}})),[l]),[u]=hM(),{settings:d,error:p}=dI(),{$data:h,lastTimeRange:f,exportMenu:m,aiPanel:g,functionDetailsPanel:y}=this.useState();p&&js(["Error while retrieving the plugin settings!","Some features might not work as expected (e.g. collapsed flame graphs). Please try to reload the page, sorry for the inconvenience."]),(0,Fi.useEffect)((()=>{u&&this.setState({$data:hF({maxNodes:u,spanSelector:e})})}),[u,e]);const b=h.useState(),v=null==b||null===(t=b.data)||void 0===t?void 0:t.state,w=v===r.LoadingState.Error?(null==b||null===(i=b.data)||void 0===i||null===(n=i.errors)||void 0===n?void 0:n[0])||new Error("Unknown error!"):null,S=v===r.LoadingState.Loading,E=null==b||null===(s=b.data)||void 0===s||null===(a=s.series)||void 0===a?void 0:a[0],x=Number(null==E?void 0:E.length)>1,O=oR(this,"filters");return{data:{title:this.buildTitle(),isLoading:S,isFetchingProfileData:S,hasProfileData:x,profileData:E,spanSelector:e,fetchProfileError:w,settings:d,export:{menu:m,query:O,timeRange:f},ai:{panel:g,fetchParams:[{query:O,timeRange:f}]},gitHub:{panel:y,timeRange:f}},actions:{getTheme:c}}})),this.addActivationHandler(this.onActivate.bind(this))}}D$(j$,"Component",(({model:e})=>{var t;const n=(0,o.useStyles2)(I$),r=wR(e,"spanSelector"),{data:i,actions:a}=e.useSceneFlameGraph(r),s=iI(),l=PF(s),c=i.isLoading||!i.hasProfileData;(0,Fi.useEffect)((()=>{c&&s.close()}),[c,s]);const u=(0,Fi.useMemo)((()=>$i().createElement($i().Fragment,null,i.title,i.isLoading&&$i().createElement(o.Spinner,{inline:!0,className:n.spinner}))),[i.isLoading,i.title,n.spinner]);return $i().createElement("div",{className:n.flex},$i().createElement(LI,{dataTestId:"flame-graph-panel",className:n.flamegraphPanel,title:u,isLoading:i.isLoading,headerActions:$i().createElement($i().Fragment,null,r&&$i().createElement(R$,{spanSelector:r,removeSpanSelector:()=>e.removeSpanSelector()}),$i().createElement(iN,{disabled:c||s.isOpen("ai"),onClick:()=>s.open("ai"),interactionName:"g_pyroscope_app_explain_flamegraph_clicked"},"Explain Flame Graph"))},i.fetchProfileError&&$i().createElement(pI,{severity:"error",title:"Error while loading profile data!",error:i.fetchProfileError}),!i.fetchProfileError&&$i().createElement(fu,{data:i.profileData,disableCollapsing:!(null===(t=i.settings)||void 0===t?void 0:t.collapsedFlamegraphs),getTheme:a.getTheme,getExtraContextMenuButtons:l.actions.getExtraFlameGraphMenuItems,extraHeaderElements:$i().createElement(i.export.menu.Component,{model:i.export.menu,query:i.export.query,timeRange:i.export.timeRange}),keepFocusOnDataChange:!0})),s.isOpen("ai")&&$i().createElement(i.ai.panel.Component,{model:i.ai.panel,fetchParams:i.ai.fetchParams,onClose:s.close}),s.isOpen("function-details")&&$i().createElement(i.gitHub.panel.Component,{model:i.gitHub.panel,timeRange:i.gitHub.timeRange,stackTrace:l.data.stacktrace,onClose:s.close}))}));const I$=e=>({flex:i.css` display: flex; `,flamegraphPanel:i.css` min-width: 0; flex-grow: 1; `,spinner:i.css` margin-left: ${e.spacing(1)}; `});class N$ extends bh{onActivate(e){e&&this.initVariables(e);const t=tm.findByKeyAndType(this,"profileMetricId",eR);return t.setState({query:eR.QUERY_SERVICE_NAME_DEPENDENT}),t.update(!0),()=>{t.setState({query:eR.QUERY_DEFAULT}),t.update(!0)}}initVariables(e){const{serviceName:t,profileMetricId:n,filters:r}=e.queryRunnerParams;if(t){tm.findByKeyAndType(this,"serviceName",iR).changeValueTo(t)}if(n){tm.findByKeyAndType(this,"profileMetricId",eR).changeValueTo(n)}if(r){tm.findByKeyAndType(this,"filters",vR).setState({filters:r})}}getVariablesAndGridControls(){return{variables:[tm.findByKeyAndType(this,"serviceName",iR),tm.findByKeyAndType(this,"profileMetricId",eR),tm.findByKeyAndType(this,"filters",vR)],gridControls:[]}}static Component({model:e}){const t=(0,o.useStyles2)(L$),{mainTimeseries:n,body:r}=e.useState();return $i().createElement("div",{className:t.flex},$i().createElement("div",{className:t.mainTimeseries},$i().createElement(n.Component,{model:n})),$i().createElement(r.Component,{model:r}))}constructor({item:e}){super({key:"explore-service-flame-graph",mainTimeseries:new ID({item:e,headerActions:e=>[new fD({type:"view-labels",item:e}),new eD({item:e})]}),body:new j$}),this.addActivationHandler(this.onActivate.bind(this,e))}}const L$=e=>({flex:i.css` display: flex; flex-direction: column; width: 100%; gap: ${e.spacing(1)}; `,mainTimeseries:i.css` height: ${ID.MIN_HEIGHT}px; `});function M$(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function F$(){return $$.apply(this,arguments)}function $$(){var e;return e=function*(){Ts("g_pyroscope_app_share_link_clicked");try{yield navigator.clipboard.writeText(function(){const e=new URL(window.location.toString()),{searchParams:t}=e;return t.get("from")||t.set("from",mj().from),t.get("to")||t.set("to",mj().to),["from","to","from-2","to-2","from-3","to-3","diffFrom","diffTo","diffFrom-2","diffTo-2"].forEach((e=>{const n=t.get(e);n&&t.set(e,String(r.dateMath.parse(n).valueOf()))})),e}().toString()),Is(["Link copied to clipboard!"])}catch(e){Xi.error(e,{info:"Error while creating the shareable link!"})}},$$=function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){M$(a,r,i,o,s,"next",e)}function s(e){M$(a,r,i,o,s,"throw",e)}o(void 0)}))},$$.apply(this,arguments)}function B$({options:e,value:t,onChange:n}){const r=(0,o.useStyles2)(V$),a=e.findIndex((e=>e.value===t));return $i().createElement("div",{className:r.explorationTypeContainer,"data-testid":"exploration-types"},$i().createElement("div",{className:r.label},"Exploration"),$i().createElement("div",{className:r.breadcrumb},e.map(((s,l)=>{const c=t===s.value,u=(d=l,a===e.length-1?d===a?"primary":"secondary":d<=a?"primary":"secondary");var d;const p=[c&&"active","primary"===u&&"primary"];return $i().createElement(Fi.Fragment,{key:s.value},$i().createElement(o.Button,{className:(0,i.cx)(r.button,...p),variant:u,size:"sm","aria-label":s.label,icon:s.icon,onClick:c?na:()=>n(s.value),tooltip:s.description,tooltipPlacement:"top","data-testid":c?"is-active":void 0},s.label),l({explorationTypeContainer:i.css` display: flex; align-items: center; `,label:i.css` display: flex; gap: 2px; align-items: center; font-size: 14px; margin-right: ${e.spacing(1)}; ${e.breakpoints.down("xxl")} { display: none; } `,breadcrumb:i.css` display: flex; align-items: center; height: 32px; line-height: 32px; .active { background-color: ${e.colors.primary.main}; } .arrow.primary { background-color: ${e.colors.primary.main}; } & button.primary:not(.active), & .arrow.primary:not(.active) { opacity: 0.7; } & button.primary:not(.active):hover { opacity: 1; background-color: ${e.colors.primary.main}; } `,button:i.css` height: 27px; line-height: 27px; border-radius: 15px; &:hover { border-color: ${e.colors.primary.main}; } &.active:hover { cursor: default; background-color: ${e.colors.primary.main}; } &:nth-last-child(2) { margin-left: ${e.spacing(1)}; } &:nth-last-child(1) { margin-left: ${e.spacing(2)}; } `,arrow:i.css` background-color: ${e.colors.text.disabled}; width: 10px; height: 2px; `});function z$(e){const t=null===a.useChromeHeaderHeight||void 0===a.useChromeHeaderHeight?void 0:(0,a.useChromeHeaderHeight)(),n=(0,o.useStyles2)(U$,null!=t?t:0),{data:r,actions:s}=function({explorationType:e,controls:t,body:n,$variables:r,onChangeExplorationType:i}){const[a,o]=e===H$.DIFF_FLAME_GRAPH?[]:t,s=r.state.variables[0],l=null==n?void 0:n.state.primary;if("function"!=typeof l.getVariablesAndGridControls)throw new Error(`Error while rendering "${l.constructor.name}": the "getVariablesAndGridControls" method is missing! Please implement it.`);const{variables:c,gridControls:u}=l.getVariablesAndGridControls(),d=s.useState().value,p=(0,Es.useNavigate)();return{data:{explorationType:e,dataSourceVariable:s,timePickerControl:a,refreshPickerControl:o,sceneVariables:c,gridControls:u,body:n,dataSourceUid:d},actions:{onChangeExplorationType:i,onClickShareLink:F$,onClickAdHoc:(0,Fi.useCallback)((()=>{Ts("g_pyroscope_app_upload_ad_hoc_clicked"),p(`${Ri}${Ai.ADHOC}`,{state:{referrer:window.location.href}})}),[p]),onClickUserSettings:(0,Fi.useCallback)((()=>{Ts("g_pyroscope_app_user_settings_clicked"),p(`${Ri}${Ai.SETTINGS}`,{state:{referrer:window.location.href}})}),[p])}}}(e),{explorationType:l,dataSourceVariable:c,timePickerControl:u,refreshPickerControl:d,sceneVariables:p,gridControls:h}=r;return $i().createElement("div",{className:n.header,"data-testid":"allControls"},$i().createElement(_M,null),$i().createElement("div",{className:n.appControls,"data-testid":"appControls"},$i().createElement("div",{className:n.appControlsLeft},$i().createElement(B$,{options:G$.EXPLORATION_TYPE_OPTIONS,value:l,onChange:s.onChangeExplorationType})),$i().createElement("div",{className:n.appControlsRight},u&&$i().createElement(u.Component,{key:u.state.key,model:u}),d&&$i().createElement(d.Component,{key:d.state.key,model:d}),$i().createElement("div",{className:n.appMiscButtons},$i().createElement(o.IconButton,{name:"upload",tooltip:"Upload ad hoc profiles",onClick:s.onClickAdHoc}),$i().createElement(o.IconButton,{name:"cog",tooltip:"View/edit tenant settings",onClick:s.onClickUserSettings}),$i().createElement(o.IconButton,{name:"share-alt",tooltip:"Copy shareable link to the clipboard",onClick:s.onClickShareLink}),$i().createElement(ns,null)))),$i().createElement("div",{id:`scene-controls-${l}`,className:n.sceneControls,"data-testid":"sceneControls"},$i().createElement(o.Field,{label:c.state.label,className:(0,i.cx)(n.sceneVariable,c.state.name),"data-testid":c.state.name},$i().createElement(c.Component,{model:c})),p.map((e=>$i().createElement(o.Field,{key:e.state.name,label:"Filters"===e.state.label?$i().createElement("div",{className:n.sceneVariableLabel},$i().createElement(o.Icon,{name:"filter",className:n.icon}),e.state.label):e.state.label,className:(0,i.cx)(n.sceneVariable,e.state.name),"data-testid":e.state.name},$i().createElement(e.Component,{model:e})))),h.map((e=>$i().createElement(o.Field,{key:e.state.key,id:e.state.key,className:n.gridControl,label:""},$i().createElement(e.Component,{model:e}))))))}const U$=(e,t)=>({header:i.css` background-color: ${e.colors.background.canvas}; position: sticky; top: ${t}px; z-index: 1; padding-bottom: ${e.spacing(2)}; `,appControls:i.css` display: flex; padding: ${e.spacing(1)} 0; justify-content: space-between; gap: ${e.spacing(2)}; `,appControlsLeft:i.css` display: flex; gap: ${e.spacing(1)}; `,appControlsRight:i.css` display: flex; gap: ${e.spacing(1)}; `,appMiscButtons:i.css` display: flex; align-items: center; gap: 4px; border: 1px solid ${e.colors.border.weak}; background-color: ${e.colors.background.secondary}; height: 32px; padding: 0 ${e.spacing(1)}; & svg { width: 18px; height: 18px; } `,sceneControls:i.css` display: flex; flex-wrap: wrap; gap: ${e.spacing(1)}; padding: 0; margin-top: 20px; `,sceneVariable:i.css` display: flex; margin-bottom: 0; & #dataSource { width: ${e.spacing(32)}; } &.filters { flex-grow: 1; } &.compare-presets { margin-left: auto; text-align: right; } `,sceneVariableLabel:i.css` font-size: 12px; font-weight: 500; line-height: 15px; height: 15px; margin-bottom: 4px; color: ${e.colors.text.primary}; max-width: 480px; `,icon:i.css` display: inline-block; margin-right: 4px; `,gridControl:i.css` margin-bottom: 0; &#quick-filter { flex: 1; min-width: 112px; } `});function q$(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var H$=function(e){return e.ALL_SERVICES="all",e.PROFILE_TYPES="profiles",e.LABELS="labels",e.FLAME_GRAPH="flame-graph",e.DIFF_FLAME_GRAPH="diff-flame-graph",e.FAVORITES="favorites",e}({});class G$ extends bh{onActivate(){const e=this.subscribeToVariableChanges(),t=this.subscribeToEvents();return this.state.explorationType||this.setExplorationType({type:G$.DEFAULT_EXPLORATION_TYPE}),()=>{t.unsubscribe(),e.unsubscribe()}}getUrlState(){return{explorationType:this.state.explorationType}}updateFromUrl(e){if("string"==typeof e.explorationType&&e.explorationType!==this.state.explorationType){const t=e.explorationType;this.setExplorationType({type:Object.values(H$).includes(t)?t:G$.DEFAULT_EXPLORATION_TYPE})}}registerRuntimeDataSources(){try{L_.registerRuntimeDataSource({dataSource:new kj}),L_.registerRuntimeDataSource({dataSource:new XA}),L_.registerRuntimeDataSource({dataSource:new QR})}catch(e){const{message:t}=e;/A runtime data source with uid (.+) has already been registered/.test(t)||Ds(e,["Fail to register all the runtime data sources!","The application cannot work as expected, please try reloading the page or if the problem persists, contact your organization admin."])}}subscribeToVariableChanges(){const e=tm.findByKeyAndType(this,"dataSource",sR).subscribeToState(((e,t)=>{e.value&&e.value!==t.value&&(vR.resetAll(this),this.resetSpanSelector())})),t=tm.findByKeyAndType(this,"serviceName",iR).subscribeToState(((e,t)=>{e.value&&e.value!==t.value&&(vR.resetAll(this),e.options.some((e=>e.value===t.value))&&this.resetSpanSelector())})),n=tm.findByKeyAndType(this,"profileMetricId",eR).subscribeToState(((e,t)=>{e.value&&e.value!==t.value&&this.resetSpanSelector()})),r=tm.findByKeyAndType(this,"filters",vR).subscribeToState(((e,t)=>{JSON.stringify(e.filters)!==JSON.stringify(t.filters)&&this.resetSpanSelector()}));return{unsubscribe(){t.unsubscribe(),e.unsubscribe(),r.unsubscribe(),n.unsubscribe()}}}subscribeToEvents(){const e=this.subscribeToEvent(cD,(e=>{this.setExplorationType({type:"profiles",comesFromUserAction:!0,item:e.payload.item})})),t=this.subscribeToEvent(lD,(e=>{this.setExplorationType({type:"labels",comesFromUserAction:!0,item:e.payload.item})})),n=this.subscribeToEvent(sD,(e=>{this.setExplorationType({type:"flame-graph",comesFromUserAction:!0,item:e.payload.item})})),r=this.subscribeToEvent(ND,(e=>{const{useAncestorTimeRange:t,clearDiffRange:n,baselineFilters:r,comparisonFilters:i}=e.payload;this.setExplorationType({type:"diff-flame-graph",comesFromUserAction:!0,bodySceneOptions:{useAncestorTimeRange:t,clearDiffRange:n,baselineFilters:r,comparisonFilters:i}})})),i=this.subscribeToEvent(uF,(()=>{this.resetSpanSelector()}));return{unsubscribe(){r.unsubscribe(),n.unsubscribe(),t.unsubscribe(),e.unsubscribe(),i.unsubscribe()}}}setExplorationType({type:e,comesFromUserAction:t,item:n,bodySceneOptions:r}){t&&(M_(),this.resetVariables(e)),this.setState({explorationType:e,body:this.buildBodyScene(e,n,r)})}resetSpanSelector(){tm.findByKeyAndType(this,"spanSelector",gj).reset()}resetVariables(e){tm.findByKeyAndType(this,"quick-filter",HA).reset(),tm.findByKeyAndType(this,"groupBy",AD).changeValueTo(AD.DEFAULT_VALUE),tm.findByKeyAndType(this,"panel-type-switcher",xR).reset(),this.resetSpanSelector(),["labels","flame-graph","diff-flame-graph"].includes(e)||tm.findByKeyAndType(this,"filters",vR).reset()}buildBodyScene(e,t,n){let r;switch(e){case"profiles":r=new hj({item:t});break;case"labels":r=new pj({item:t});break;case"flame-graph":r=new N$({item:t});break;case"diff-flame-graph":r=new AM(n||{});break;case"favorites":r=new OD;break;default:r=new gD}return new hO({direction:"column",primary:r})}static Component({model:e}){const t=(0,o.useStyles2)(W$),{data:n,actions:r}=e.useProfilesExplorer(),{explorationType:i,controls:a,body:s,$variables:l,dataSourceUid:c}=n;return $i().createElement(cF,{dataSourceUid:c},$i().createElement(z$,{explorationType:i,controls:a,body:s,$variables:l,onChangeExplorationType:r.onChangeExplorationType}),$i().createElement("div",{className:t.body,"data-testid":"sceneBody"},s&&$i().createElement(s.Component,{model:s})))}constructor(){super({key:"profiles-explorer",explorationType:void 0,body:void 0,$timeRange:new sf(mj()),$variables:new Mw({variables:[new sR,new iR,new eR,new vR({key:"filters"}),new vR({key:"filtersBaseline"}),new vR({key:"filtersComparison"}),new AD,new gj]}),controls:[new fx({isOnCanvas:!0}),new _x({isOnCanvas:!0})],gridControls:[new HA({placeholder:""}),new xR,new VA,new UA]}),q$(this,"_urlSync",new Xh(this,{keys:["explorationType"]})),q$(this,"onChangeExplorationType",(e=>{Ts("g_pyroscope_app_exploration_type_clicked",{explorationType:e}),this.setExplorationType({type:e,comesFromUserAction:!0})})),q$(this,"useProfilesExplorer",(()=>{const{explorationType:e,controls:t,body:n,$variables:r}=this.useState();return{data:{explorationType:e,controls:t,body:n,$variables:r,dataSourceUid:r.state.variables[0].useState().value},actions:{onChangeExplorationType:this.onChangeExplorationType}}})),WS().initSync(this),this.registerRuntimeDataSources(),this.addActivationHandler(this.onActivate.bind(this))}}q$(G$,"EXPLORATION_TYPE_OPTIONS",[{value:"all",label:"All services",description:"Overview of all services, for any given profile type"},{value:"profiles",label:"Profile types",description:"Overview of all the profile types for a single service"},{value:"labels",label:"Labels",description:"Single service label exploration and filtering"},{value:"flame-graph",label:"Flame graph",description:"Single service flame graph"},{value:"diff-flame-graph",label:"Diff flame graph",description:"Compare the differences between two flame graphs"},{value:"favorites",label:"Favorites",description:"Overview of favorited visualizations",icon:"favorite"}]),q$(G$,"DEFAULT_EXPLORATION_TYPE",G$.EXPLORATION_TYPE_OPTIONS[0].value);const W$=()=>({body:i.css` position: relative; z-index: 0; background: transparent; `});function Q$(){const e=(0,Fi.useMemo)((()=>new G$),[]);return Cs("explore"),$i().createElement(e.Component,{model:e})}function K$(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function Y$(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function X$(e){for(var t=1;t{t&&s(t)}),[t]),{data:J$(X$({},o),{fetchError:n}),actions:{toggleCollapsedFlamegraphs(){s((e=>J$(X$({},e),{collapsedFlamegraphs:!e.collapsedFlamegraphs})))},updateMaxNodes(e){s((t=>J$(X$({},t),{maxNodes:Number(e.target.value)})))},toggleEnableFlameGraphDotComExport(){s((e=>J$(X$({},e),{enableFlameGraphDotComExport:!e.enableFlameGraphDotComExport})))},toggleEnableFunctionDetails(){s((e=>J$(X$({},e),{enableFunctionDetails:!e.enableFunctionDetails})))},saveSettings(){return(e=function*(){a(o.maxNodes);try{yield r(o),Is(["Plugin settings successfully saved!"])}catch(e){Ds(e,["Error while saving the plugin settings!","Please try again later, sorry for the inconvenience."])}},function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){K$(a,r,i,o,s,"next",e)}function s(e){K$(a,r,i,o,s,"throw",e)}o(void 0)}))})();var e},goBack(){if(!u.current)return void l(`${Ri}${Ai.EXPLORE}`);const e=new URL(u.current);i&&e.searchParams.set("maxNodes",String(i)),l(`${e.pathname}${e.search}`)}}}}function eB(){const e=(0,o.useStyles2)(tB),{data:t,actions:n}=Z$();return t.fetchError&&Ds(t.fetchError,["Error while retrieving the plugin settings!","Please try to reload the page, sorry for the inconvenience."]),Cs("settings"),$i().createElement($i().Fragment,null,$i().createElement(os,{title:"Profiles settings (tenant)"}),$i().createElement("form",{className:e.settingsForm,onSubmit:function(e){e.preventDefault(),n.saveSettings()}},$i().createElement($i().Fragment,null,$i().createElement(o.FieldSet,{label:"Flame graph","data-testid":"flamegraph-settings"},$i().createElement(o.InlineFieldRow,null,$i().createElement(o.InlineField,{label:"Collapsed flame graphs",labelWidth:24},$i().createElement(o.InlineSwitch,{label:"Toggle collapsed flame graphs",name:"collapsed-flamegraphs",value:t.collapsedFlamegraphs,onChange:n.toggleCollapsedFlamegraphs}))),$i().createElement(o.InlineFieldRow,null,$i().createElement(o.InlineField,{label:"Maximum number of nodes",tooltip:"",labelWidth:24},$i().createElement(o.Input,{name:"max-nodes",type:"number",min:"1",value:t.maxNodes,onChange:n.updateMaxNodes})))),$i().createElement(o.FieldSet,{label:"Function details","data-testid":"function-details-settings"},$i().createElement(o.InlineFieldRow,null,$i().createElement(o.InlineField,{label:"Enable function details",labelWidth:24,tooltip:$i().createElement("div",{className:e.tooltip},$i().createElement("p",null,"The function details feature enables mapping of resource usage to lines of source code. If the GitHub integration is configured, then the source code will be downloaded from GitHub."),$i().createElement("p",null,$i().createElement("a",{href:"https://grafana.com/docs/grafana-cloud/monitor-applications/profiles/pyroscope-github-integration/",target:"_blank",rel:"noreferrer noopener"},"Learn more"))),interactive:!0},$i().createElement(o.InlineSwitch,{label:"Toggle function details",name:"function-details-feature",value:t.enableFunctionDetails,onChange:n.toggleEnableFunctionDetails})))),$i().createElement("div",{className:e.buttons},$i().createElement(o.Button,{variant:"primary",type:"submit"},"Save settings"),$i().createElement(o.Button,{variant:"secondary",onClick:n.goBack,"aria-label":"Back to Grafana Profiles Drilldown"},"Back to Grafana Profiles Drilldown")))))}const tB=e=>({settingsForm:i.css` & > fieldset { border: 0 none; border-bottom: 1px solid ${e.colors.border.weak}; padding-left: 0; } & > fieldset > legend { font-size: ${e.typography.h4.fontSize}; } `,buttons:i.css` display: flex; gap: ${e.spacing(1)}; `,tooltip:i.css` p { margin: ${e.spacing(1)}; } a { color: ${e.colors.text.link}; } em { font-style: normal; font-weight: ${e.typography.fontWeightBold}; } `});function nB(){return $i().createElement(Es.Routes,null,$i().createElement(Es.Route,{path:Ai.EXPLORE,element:$i().createElement(Q$,null)}),$i().createElement(Es.Route,{path:Ai.ADHOC,element:$i().createElement(Cp,null)}),$i().createElement(Es.Route,{path:Ai.SETTINGS,element:$i().createElement(eB,null)}),$i().createElement(Es.Route,{path:"/*",element:$i().createElement(Es.Navigate,{to:`${Ri}${Ai.EXPLORE}`,replace:!0})}))}function rB({error:e}){return $i().createElement(a.PluginPage,{layout:r.PageLayoutType.Canvas},$i().createElement("div",{className:"pyroscope-app"},$i().createElement(os,{title:"Grafana Profiles Drilldown"}),$i().createElement(pI,{severity:"error",title:"Fatal error!",message:"Please try reloading the page or, if the problem persists, contact your organization admin. Sorry for the inconvenience.",error:e,errorContext:{handheldBy:"React error boundary"}})))}!function(){if(Mi())return;const e=function(){const e=Ii();if(e&&Ni.has(e))return Ni.get(e)}();if(!e)return;const{environment:t,faroUrl:n,appName:r}=e,{apps:i,bootData:o,buildInfo:s}=a.config,l=i[Pi].version,c=o.user.email,u=`v${s.version} (${s.edition})`;var d;d=Ci({url:n,app:{name:r,release:l,version:Di,environment:t,namespace:u},user:{email:c},instrumentations:[...Ti({captureConsole:!1})],isolate:!0,beforeSend:e=>{var t,n,r;return(null!==(n=null===(t=e.meta.page)||void 0===t?void 0:t.url)&&void 0!==n?n:"").includes(Ri)?(e.meta.view={name:new URLSearchParams(null===(r=e.meta.page)||void 0===r?void 0:r.url).get("explorationType")||""},e):null}}),Li=d}();const iB=e=>({pageContainer:i.css` display: flex; flex-direction: column; padding: ${e.spacing(1)} ${e.spacing(2)} ${e.spacing(2)} ${e.spacing(2)}; flex-basis: 100%; flex-grow: 1; `});function aB(e){var t,n,r;const{timeRange:i,pyroscopeQuery:a}=e;let o="",s="",l="all",c=null===(n=e.pyroscopeQuery.labelSelector)||void 0===n||null===(t=n.match(/service_name="([^"]+)"/))||void 0===t?void 0:t[1];c&&(l="labels"),e.explorationType&&(l=e.explorationType);const u=`var-dataSource=${null===(r=a.datasource)||void 0===r?void 0:r.uid}`,d=c?`&var-serviceName=${c}`:"",p=`&var-profileMetricId=${a.profileTypeId}`,h=`&explorationType=${l}`;i&&(o=`&from=${i.from}&to=${i.to}`),a.spanSelector&&(s=`&var-spanSelector=${a.spanSelector}`);return`/a/grafana-pyroscope-app/explore?${new URLSearchParams(`${u}${d}${p}${o}${h}${s}`).toString()}`}const oB={targets:[r.PluginExtensionPoints.ExploreToolbarAction],title:"Open in Grafana Profiles Drilldown",icon:"fire",description:"Try our new queryless experience for profiles",path:"/a/grafana-pyroscope-app/explore",configure(e){if(!e||!e.targets||!e.timeRange||e.targets.length>1)return;const t=e.targets[0];return t.datasource&&"grafana-pyroscope-datasource"===t.datasource.type?{path:aB({pyroscopeQuery:t,timeRange:e.timeRange})}:void 0}},sB={targets:["grafana/traceview/details"],title:"Open in Grafana Profiles Drilldown",description:"Try our new queryless experience for profiles",path:"/a/grafana-pyroscope-app/explore",onClick:(e,{context:t})=>{if(!(t&&t.serviceName&&t.spanSelector&&t.profileTypeId&&t.timeRange))return;const n=t.serviceName,r=t.spanSelector,i=t.profileTypeId,a=t.timeRange,o={refId:"span-flamegraph-profiles-drilldown-refId",labelSelector:`service_name="${n}"`,profileTypeId:i,spanSelector:r,datasource:t.datasource,groupBy:["service_name"]};if(o.datasource){const e=aB({pyroscopeQuery:o,timeRange:a,explorationType:"flame-graph"});window.open(e,"_blank","noopener,noreferrer")}}},lB=(new r.AppPlugin).addLink(oB).addLink(sB).setRootPage((function(){const e=(0,o.useStyles2)(iB),[t,n]=(0,Fi.useState)();return t?$i().createElement(rB,{error:t}):$i().createElement(o.ErrorBoundary,{onError:n},(()=>$i().createElement(Ui,{client:W},$i().createElement(Ss,null,$i().createElement("div",{className:e.pageContainer},$i().createElement(a.PluginPage,{layout:r.PageLayoutType.Custom},$i().createElement("div",{className:"pyroscope-app"},$i().createElement(nB,null))))))))}))})(),__webpack_exports__})())); //# sourceMappingURL=module.js.map