(self.webpackChunkgrafana_metricsdrilldown_app=self.webpackChunkgrafana_metricsdrilldown_app||[]).push([[500],{20120:(e,t,r)=>{"use strict";r.d(t,{dM:()=>a,rw:()=>n,yV:()=>o});const n={allowCustomValue:!0,includeAll:!1,multi:!1,options:[],skipUrlSync:!1,staticOptions:[]};var a=(e=>(e.RangeToText="range",e.RegexToText="regex",e.SpecialValue="special",e.ValueToText="value",e))(a||{});var o=(e=>(e[e.Crosshair=1]="Crosshair",e[e.Off=0]="Off",e[e.Tooltip=2]="Tooltip",e))(o||{})},24626:(e,t,r)=>{"use strict";r.d(t,{AL:()=>c,K3:()=>s,MD:()=>l,Yw:()=>u});var n=r(11528);const a={json:1,logfmt:2,unpack:3,pattern:4,regexp:5,label_format:7,line_format:8,label_replace:9,vector:10,offset:11,bool:12,on:13,ignoring:14,group_left:15,group_right:16,unwrap:6,decolorize:17,drop:18,keep:19},o={by:20,without:21,and:22,or:23,unless:24,sum:25,avg:26,count:27,max:28,min:29,stddev:30,stdvar:31,bottomk:32,topk:33,sort:34,sort_desc:35},i={__proto__:null,ip:295,count_over_time:301,rate:303,rate_counter:305,bytes_over_time:307,bytes_rate:309,avg_over_time:311,sum_over_time:313,min_over_time:315,max_over_time:317,stddev_over_time:319,stdvar_over_time:321,quantile_over_time:323,first_over_time:325,last_over_time:327,absent_over_time:329,bytes:335,duration:337,duration_seconds:339},s=n.U1.deserialize({version:14,states:"EtOYQPOOO#cQPO'#DUOOQO'#ER'#ERO#hQPO'#ERO$}QPO'#DTOYQPO'#DTOOQO'#Ed'#EdO%[QPO'#EcOOQO'#FP'#FPO%aQPO'#FOQ%lQPOOO&mQPO'#F]O&rQPO'#F^OOQO'#Eb'#EbOOQO'#DS'#DSOOQO'#Ee'#EeOOQO'#Ef'#EfOOQO'#Eg'#EgOOQO'#Eh'#EhOOQO'#Ei'#EiOOQO'#Ej'#EjOOQO'#Ek'#EkOOQO'#El'#ElOOQO'#Em'#EmOOQO'#En'#EnOOQO'#Eo'#EoO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{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,u=(e,t)=>{for(var r in t||(t={}))s.call(t,r)&&c(e,r,t[r]);if(i)for(var r of i(t))l.call(t,r)&&c(e,r,t[r]);return e},d=(e,t)=>a(e,o(t)),O=(e,t,r)=>new Promise((n,a)=>{var o=e=>{try{s(r.next(e))}catch(e){a(e)}},i=e=>{try{s(r.throw(e))}catch(e){a(e)}},s=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,i);s((r=r.apply(e,t)).next())}),h=class{constructor(){this.data=new Map}set(e,t){this.data.set(e,t)}get(e){return this.data.get(e)}has(e){return this.data.has(e)}delete(e){return this.data.delete(e)}clear(){this.data.clear()}},p={STATIC:"STATIC",DEFAULT:"DEFAULT",TARGETING_MATCH:"TARGETING_MATCH",SPLIT:"SPLIT",CACHED:"CACHED",DISABLED:"DISABLED",UNKNOWN:"UNKNOWN",STALE:"STALE",ERROR:"ERROR"},f=(e=>(e.PROVIDER_NOT_READY="PROVIDER_NOT_READY",e.PROVIDER_FATAL="PROVIDER_FATAL",e.FLAG_NOT_FOUND="FLAG_NOT_FOUND",e.PARSE_ERROR="PARSE_ERROR",e.TYPE_MISMATCH="TYPE_MISMATCH",e.TARGETING_KEY_MISSING="TARGETING_KEY_MISSING",e.INVALID_CONTEXT="INVALID_CONTEXT",e.GENERAL="GENERAL",e))(f||{}),v=class e extends Error{constructor(t,r){super(t),Object.setPrototypeOf(this,e.prototype),this.name="OpenFeatureError",this.cause=null==r?void 0:r.cause}},g=class e extends v{constructor(t,r){super(t,r),Object.setPrototypeOf(this,e.prototype),this.name="FlagNotFoundError",this.code="FLAG_NOT_FOUND"}},m=class e extends v{constructor(t,r){super(t,r),Object.setPrototypeOf(this,e.prototype),this.name="GeneralError",this.code="GENERAL"}},$=class e extends v{constructor(t,r){super(t,r),Object.setPrototypeOf(this,e.prototype),this.name="InvalidContextError",this.code="INVALID_CONTEXT"}},P=class e extends v{constructor(t,r){super(t,r),Object.setPrototypeOf(this,e.prototype),this.name="ParseError",this.code="PARSE_ERROR"}},b=class e extends v{constructor(t,r){super(t,r),Object.setPrototypeOf(this,e.prototype),this.name="ProviderFatalError",this.code="PROVIDER_FATAL"}},y=class e extends v{constructor(t,r){super(t,r),Object.setPrototypeOf(this,e.prototype),this.name="ProviderNotReadyError",this.code="PROVIDER_NOT_READY"}},_=class e extends v{constructor(t,r){super(t,r),Object.setPrototypeOf(this,e.prototype),this.name="TargetingKeyMissingError",this.code="TARGETING_KEY_MISSING"}},E=class e extends v{constructor(t,r){super(t,r),Object.setPrototypeOf(this,e.prototype),this.name="TypeMismatchError",this.code="TYPE_MISMATCH"}},w=(e,t)=>{switch(e){case"FLAG_NOT_FOUND":return new g(t);case"PARSE_ERROR":return new P(t);case"TYPE_MISMATCH":return new E(t);case"TARGETING_KEY_MISSING":return new _(t);case"INVALID_CONTEXT":return new $(t);case"PROVIDER_NOT_READY":return new y(t);case"PROVIDER_FATAL":return new b(t);default:return new m(t)}},R=(e=>(e.NOT_READY="NOT_READY",e.READY="READY",e.ERROR="ERROR",e.STALE="STALE",e.FATAL="FATAL",e.RECONCILING="RECONCILING",e))(R||{}),Q=(e=>(e.Ready="PROVIDER_READY",e.Error="PROVIDER_ERROR",e.ConfigurationChanged="PROVIDER_CONFIGURATION_CHANGED",e.ContextChanged="PROVIDER_CONTEXT_CHANGED",e.Reconciling="PROVIDER_RECONCILING",e.Stale="PROVIDER_STALE",e))(Q||{}),x={READY:"PROVIDER_READY",ERROR:"PROVIDER_ERROR",FATAL:"PROVIDER_ERROR",STALE:"PROVIDER_STALE",RECONCILING:"PROVIDER_RECONCILING",NOT_READY:void 0},S=(e,t)=>!t&&"PROVIDER_READY"===e||x[t]===e,X=class{error(...e){console.error(...e)}warn(...e){console.warn(...e)}info(){}debug(){}},T=["error","warn","info","debug"],A=class{constructor(e){this.fallbackLogger=new X;try{for(const t of T)if(!e[t]||"function"!=typeof e[t])throw new Error(`The provided logger is missing the ${t} method.`);this.logger=e}catch(e){console.error(e),console.error("Falling back to the default logger."),this.logger=this.fallbackLogger}}error(...e){this.log("error",...e)}warn(...e){this.log("warn",...e)}info(...e){this.log("info",...e)}debug(...e){this.log("debug",...e)}log(e,...t){try{this.logger[e](...t)}catch(r){this.fallbackLogger[e](...t)}}},C=class{constructor(e){this.globalLogger=e,this._handlers={PROVIDER_CONFIGURATION_CHANGED:new WeakMap,PROVIDER_CONTEXT_CHANGED:new WeakMap,PROVIDER_READY:new WeakMap,PROVIDER_ERROR:new WeakMap,PROVIDER_STALE:new WeakMap,PROVIDER_RECONCILING:new WeakMap}}emit(e,t){this.eventEmitter.emit(e,t)}addHandler(e,t){const r=e=>O(this,null,function*(){var r;try{yield t(e)}catch(e){null==(r=this._logger)||r.error("Error running event handler:",e)}}),n=this._handlers[e].get(t);this._handlers[e].set(t,[...n||[],r]),this.eventEmitter.on(e,r)}removeHandler(e,t){const r=this._handlers[e].get(t);if(r){const t=r.pop();t&&this.eventEmitter.removeListener(e,t)}}removeAllHandlers(e){e?this.eventEmitter.removeAllListeners(e):this.eventEmitter.removeAllListeners()}getHandlers(e){return this.eventEmitter.listeners(e)}setLogger(e){return this._eventLogger=new A(e),this}get _logger(){var e,t;return null!=(t=this._eventLogger)?t:null==(e=this.globalLogger)?void 0:e.call(this)}};function k(e){return function(e){return"string"==typeof e}(e)?e:void 0}function N(e){return function(e){return"object"==typeof e}(e)?e:void 0}function I(e){return null!=e}var D=class{constructor(e,t,r){var n,a,o;this._provider=e,this._status=t,this._pendingContextChanges=0,null==(n=e.events)||n.addHandler("PROVIDER_READY",()=>{this._status=r.READY}),null==(a=e.events)||a.addHandler("PROVIDER_STALE",()=>{this._status=r.STALE}),null==(o=e.events)||o.addHandler("PROVIDER_ERROR",e=>{"PROVIDER_FATAL"===(null==e?void 0:e.errorCode)?this._status=r.FATAL:this._status=r.ERROR})}get provider(){return this._provider}set provider(e){this._provider=e}get status(){return this._status}set status(e){this._status=e}get allContextChangesSettled(){return 0===this._pendingContextChanges}incrementPendingContextChanges(){this._pendingContextChanges++}decrementPendingContextChanges(){this._pendingContextChanges--}},L=class{constructor(e){this._hooks=[],this._context={},this._logger=new X,this._clientEventHandlers=new Map,this._domainScopedContext=new Map,this._clientEvents=new Map,this._runsOn=e}addHooks(...e){return this._hooks=[...this._hooks,...e],this}getHooks(){return this._hooks}clearHooks(){return this._hooks=[],this}setLogger(e){return this._logger=new A(e),this}get providerMetadata(){return this.getProviderMetadata()}getProviderMetadata(e){return this.getProviderForClient(e).metadata}addHandler(e,t,r){[...new Map([[void 0,this._defaultProvider]]),...this._domainScopedProviders].forEach(r=>{var n;const a=r[0],o=r[1].provider,i=r[1].status;if(S(e,i))try{t({domain:a,providerName:o.metadata.name})}catch(e){null==(n=this._logger)||n.error("Error running event handler:",e)}}),this._apiEmitter.addHandler(e,t),(null==r?void 0:r.signal)&&"function"==typeof r.signal.addEventListener&&r.signal.addEventListener("abort",()=>{this.removeHandler(e,t)})}removeHandler(e,t){this._apiEmitter.removeHandler(e,t)}clearHandlers(){this._apiEmitter.removeAllHandlers()}getHandlers(e){return this._apiEmitter.getHandlers(e)}setAwaitableProvider(e,t){var r,n,a,o,i,s,l,c;const u=k(e),d=null!=(r=N(e))?r:N(t);if(!d)return void this._logger.debug("No provider defined, ignoring setProvider call");const O=this.getProviderForClient(u),h=d.metadata.name;if(O===d)return void this._logger.debug("Provider is already set, ignoring setProvider call");if(d.runsOn){if(d.runsOn!==this._runsOn)throw new m(`Provider '${d.metadata.name}' is intended for use on the ${d.runsOn}.`)}else this._logger.debug(`Provider '${d.metadata.name}' has not defined its intended use.`);const p=this.getAssociatedEventEmitters(u);let f;const v=new D(d,this._statusEnumType.NOT_READY,this._statusEnumType);return"function"!=typeof d.initialize||this.allProviders.includes(d)?(v.status=this._statusEnumType.READY,p.forEach(e=>{null==e||e.emit("PROVIDER_READY",{clientName:u,domain:u,providerName:h})}),null==(s=this._apiEmitter)||s.emit("PROVIDER_READY",{clientName:u,domain:u,providerName:h})):f=null==(i=null==(o=null==(a=d.initialize)?void 0:a.call(d,u&&null!=(n=this._domainScopedContext.get(u))?n:this._context))?void 0:o.then(()=>{var e;v.status=this._statusEnumType.READY,this.getAssociatedEventEmitters(u).forEach(e=>{null==e||e.emit("PROVIDER_READY",{clientName:u,domain:u,providerName:h})}),null==(e=this._apiEmitter)||e.emit("PROVIDER_READY",{clientName:u,domain:u,providerName:h})}))?void 0:i.catch(e=>{var t;throw"PROVIDER_FATAL"===(null==e?void 0:e.code)?v.status=this._statusEnumType.FATAL:v.status=this._statusEnumType.ERROR,this.getAssociatedEventEmitters(u).forEach(t=>{null==t||t.emit("PROVIDER_ERROR",{clientName:u,domain:u,providerName:h,message:null==e?void 0:e.message})}),null==(t=this._apiEmitter)||t.emit("PROVIDER_ERROR",{clientName:u,domain:u,providerName:h,message:null==e?void 0:e.message}),e}),u?this._domainScopedProviders.set(u,v):this._defaultProvider=v,this.transferListeners(O,d,u,p),this.allProviders.includes(O)||null==(c=null==(l=null==O?void 0:O.onClose)?void 0:l.call(O))||c.catch(e=>{this._logger.error(`error closing provider: ${null==e?void 0:e.message}, ${null==e?void 0:e.stack}`)}),f}getProviderForClient(e){var t,r;return e&&null!=(r=null==(t=this._domainScopedProviders.get(e))?void 0:t.provider)?r:this._defaultProvider.provider}buildAndCacheEventEmitterForClient(e){const t=this._clientEvents.get(e);if(t)return t;const r=this._createEventEmitter();this._clientEvents.set(e,r);const n=this.getProviderForClient(e);return Object.values(Q).forEach(t=>{var a;return null==(a=n.events)?void 0:a.addHandler(t,a=>O(this,null,function*(){r.emit(t,d(u({},a),{clientName:e,domain:e,providerName:n.metadata.name}))}))}),r}getUnboundEmitters(){const e=[...this._domainScopedProviders.keys()];return[...[...this._clientEvents.keys()].filter(I).filter(t=>!e.includes(t)).map(e=>this._clientEvents.get(e)),this._clientEvents.get(void 0)].filter(I)}getAssociatedEventEmitters(e){return e?[this.buildAndCacheEventEmitterForClient(e)]:this.getUnboundEmitters()}transferListeners(e,t,r,n){var a;null==(a=this._clientEventHandlers.get(r))||a.forEach(t=>{var r;return null==(r=e.events)?void 0:r.removeHandler(...t)});const o=Object.values(Q).map(e=>[e,a=>O(this,null,function*(){n.forEach(n=>{null==n||n.emit(e,d(u({},a),{clientName:r,domain:r,providerName:t.metadata.name}))}),this._apiEmitter.emit(e,d(u({},a),{clientName:r,domain:r,providerName:t.metadata.name}))})]);this._clientEventHandlers.set(r,o),o.forEach(e=>{var r;return null==(r=t.events)?void 0:r.addHandler(...e)})}close(){return O(this,null,function*(){var e,t;try{yield null==(t=null==(e=null==this?void 0:this._defaultProvider.provider)?void 0:e.onClose)?void 0:t.call(e)}catch(e){this.handleShutdownError(this._defaultProvider.provider,e)}const r=Array.from(this._domainScopedProviders);yield Promise.all(r.map(e=>O(this,[e],function*([,e]){var t,r;try{yield null==(r=null==e?void 0:(t=e.provider).onClose)?void 0:r.call(t)}catch(t){this.handleShutdownError(null==e?void 0:e.provider,t)}})))})}clearProvidersAndSetDefault(e){return O(this,null,function*(){try{yield this.close()}catch(e){this._logger.error("Unable to cleanly close providers. Resetting to the default configuration.")}finally{this._domainScopedProviders.clear(),this._defaultProvider=new D(e,this._statusEnumType.NOT_READY,this._statusEnumType)}})}get allProviders(){return[...[...this._domainScopedProviders.values()].map(e=>e.provider),this._defaultProvider.provider]}handleShutdownError(e,t){this._logger.error(`Error during shutdown of provider ${e.metadata.name}: ${t}`),this._logger.error(null==t?void 0:t.stack)}}},31904:(e,t,r)=>{"use strict";r.d(t,{$N:()=>a,xB:()=>o,yL:()=>n});var n=(e=>(e.Always="always",e.Auto="auto",e.Never="never",e))(n||{});var a=(e=>(e.Multi="multi",e.None="none",e.Single="single",e))(a||{}),o=(e=>(e.Ascending="asc",e.Descending="desc",e.None="none",e))(o||{})},33137:(e,t,r)=>{"use strict";r.d(t,{S:()=>b});var n=r(24888);class a extends Error{constructor(e,t,r,n){super(r,n),this.error=e,this.response=t,Object.setPrototypeOf(this,a.prototype),this.name=a.name}}class o extends a{constructor(e,t,r){super(e,void 0,t,r),Object.setPrototypeOf(this,o.prototype),this.name=o.name}}class i extends a{constructor(e,t,r){super(void 0,e,t,r),Object.setPrototypeOf(this,i.prototype),this.name=i.name}}class s extends a{constructor(e,t,r){super(void 0,e,t,r),Object.setPrototypeOf(this,s.prototype),this.name=s.name,this.message=null!=t?t:"OFREP request failed: unauthorized"}}class l extends a{constructor(e,t,r){super(void 0,e,t,r),Object.setPrototypeOf(this,l.prototype),this.name=l.name,this.message=null!=t?t:"OFREP request failed: forbidden"}}class c extends a{constructor(e,t,r){super(void 0,e,t,r),this.response=e,Object.setPrototypeOf(this,c.prototype),this.name=c.name,this.requestTime=new Date,this.message=(null!=t?t:this.retryAfterDate)?`rate limit exceeded, try again after ${this.retryAfterDate}`:"rate limit exceeded, try again later"}get retryAfterHeader(){return this.response.headers.get("Retry-After")}get retryAfterSeconds(){if(!this.retryAfterHeader)return null;const e=Number.parseInt(this.retryAfterHeader,10);return Number.isFinite(e)?e:null}get retryAfterDate(){if(!this.retryAfterHeader)return null;if(this.retryAfterSeconds){return this.retryAfterSeconds?new Date(this.requestTime.getTime()+1e3*this.retryAfterSeconds):null}const e=new Date(this.retryAfterHeader);return isNaN(e.valueOf())?null:e}}function u(e,t,r,n){return new(r||(r=Promise))(function(a,o){function i(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,s)}l((n=n.apply(e,t||[])).next())})}function d(e){return!(!e||"object"!=typeof e)&&("key"in e&&"string"==typeof e.key&&"errorCode"in e&&"string"==typeof e.errorCode)}"function"==typeof SuppressedError&&SuppressedError;const O=[400,404,500],h=[200];function p(e){return u(this,arguments,void 0,function*(e,t=null){var r;return new Headers([["Content-Type","application/json; charset=utf-8"],...(null==e?void 0:e.headers)||[],...(yield null===(r=null==e?void 0:e.headersFactory)||void 0===r?void 0:r.call(e))||[],...t?[["If-None-Match",t]]:[]])})}const f={[n.O4.FLAG_NOT_FOUND]:"Flag was not found",[n.O4.GENERAL]:"General error",[n.O4.INVALID_CONTEXT]:"Context is invalid or could be parsed",[n.O4.PARSE_ERROR]:"Flag or flag configuration could not be parsed",[n.O4.PROVIDER_FATAL]:"Provider is in a fatal error state",[n.O4.PROVIDER_NOT_READY]:"Provider is not yet ready",[n.O4.TARGETING_KEY_MISSING]:"Targeting key is missing",[n.O4.TYPE_MISMATCH]:"Flag is not of expected type"};class v{constructor(e,t=function(){return globalThis?globalThis.fetch.bind(globalThis):window?window.fetch.bind(window):(self&&self.fetch.bind(self),fetch)}()){this.baseOptions=e,this.fetchImplementation=t}isJsonMime(e){const t=e.headers.get("Content-Type");return!!t&&v.jsonRegex.test(t)}static isOFREFErrorHttpStatus(e){return O.includes(e)}static isOFREFSuccessHttpStatus(e){return h.includes(e)}doFetchRequest(e){return u(this,void 0,void 0,function*(){var t;let r;try{const n=null!==(t=this.baseOptions.timeoutMs)&&void 0!==t?t:1e4,a=new AbortController;setTimeout(()=>a.abort(new DOMException(`This signal is timeout in ${n}ms`,"TimeoutError")),n),r=yield this.fetchImplementation(e,{signal:a.signal})}catch(e){throw new o(e,"The OFREP request failed.",{cause:e})}if(401===r.status)throw new s(r);if(403===r.status)throw new l(r);if(429===r.status)throw new c(r);if(200===r.status&&!this.isJsonMime(r))throw new i(r,"OFREP did not respond with expected MIME application/json");try{return{response:r,body:yield r.json()}}catch(e){return{response:r}}})}postEvaluateFlag(e,t){return u(this,void 0,void 0,function*(){let r=`${this.baseOptions.baseUrl}/ofrep/v1/evaluate/flags/${e}`;this.baseOptions.query&&(r+=`?${this.baseOptions.query.toString()}`);const n=new Request(r,{headers:yield p(this.baseOptions),method:"POST",body:JSON.stringify(null!=t?t:{})}),{response:a,body:o}=yield this.doFetchRequest(n);if(200===a.status&&o&&!d(o))return{httpStatus:a.status,value:o,httpResponse:a};if(v.isOFREFErrorHttpStatus(a.status)&&d(o))return{httpStatus:a.status,value:o,httpResponse:a};throw new i(a,"The OFREP response does not match the expected format")})}postBulkEvaluateFlags(e){return u(this,arguments,void 0,function*(e,t=null){let r=`${this.baseOptions.baseUrl}/ofrep/v1/evaluate/flags`;this.baseOptions.query&&(r+=`?${this.baseOptions.query.toString()}`);const n=new Request(r,{headers:yield p(this.baseOptions,t),method:"POST",body:JSON.stringify(null!=e?e:{})}),{response:a,body:o}=yield this.doFetchRequest(n);if(200===a.status&&function(e){return!(!e||"object"!=typeof e)&&"flags"in e}(o))return{httpStatus:a.status,value:o,httpResponse:a};if(304===a.status)return{httpStatus:a.status,value:void 0,httpResponse:a};if(v.isOFREFErrorHttpStatus(a.status)&&function(e){return!(!e||"object"!=typeof e)&&"errorCode"in e}(o))return{httpStatus:a.status,value:o,httpResponse:a};throw new i(a,"The OFREP response does not match the expected format")})}}function g(e){if(!e)return;const t=Object.entries(e).filter(([,e])=>["string","number","boolean"].includes(typeof e));return Object.fromEntries(t)}v.jsonRegex=new RegExp(/application\/[^+]*[+]?(json);?.*/,"i");var m,$=r(38315);function P(e,t,r,n){return new(r||(r=Promise))(function(a,o){function i(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,s)}l((n=n.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError,function(e){e.SUCCESS_NO_CHANGES="SUCCESS_NO_CHANGES",e.SUCCESS_WITH_CHANGES="SUCCESS_WITH_CHANGES"}(m||(m={}));class b{constructor(e,t){var r;this.DEFAULT_POLL_INTERVAL=3e4,this.metadata={name:"OpenFeature Remote Evaluation Protocol Web Provider"},this.runsOn="client",this.events=new $.by,this._flagCache={},this._options=e,this._logger=t,this._etag=null,this._ofrepAPI=new v(this._options,this._options.fetchImplementation),this._pollingInterval=null!==(r=this._options.pollInterval)&&void 0!==r?r:this.DEFAULT_POLL_INTERVAL}get flagCache(){return Object.assign({},this._flagCache)}initialize(e){return P(this,void 0,void 0,function*(){var t;try{this._context=e,yield this._fetchFlags(e),this._pollingInterval>0&&this.startPolling(),null===(t=this._logger)||void 0===t||t.debug(`${this.metadata.name} initialized successfully`)}catch(e){if(e instanceof s||e instanceof l)throw new $.wh("Initialization failed",{cause:e});throw e}})}resolveBooleanEvaluation(e,t,r){return this._resolve(e,t)}resolveStringEvaluation(e,t,r){return this._resolve(e,t)}resolveNumberEvaluation(e,t,r){return this._resolve(e,t)}resolveObjectEvaluation(e,t,r){return this._resolve(e,t)}onContextChange(e,t){return P(this,void 0,void 0,function*(){var e,r,n;try{this._context=t;const e=new Date;if(void 0!==this._retryPollingAfter&&this._retryPollingAfter>e)return;yield this._fetchFlags(t)}catch(t){if(t instanceof c)return void(null===(e=this.events)||void 0===e||e.emit($.Uc.Stale,{message:`${t.name}: ${t.message}`}));if(t instanceof $.Lh||t instanceof o||t instanceof s||t instanceof l)return void(null===(r=this.events)||void 0===r||r.emit($.Uc.Error,{message:`${t.name}: ${t.message}`}));null===(n=this.events)||void 0===n||n.emit($.Uc.Error,{message:`Unknown error: ${t}`})}})}onClose(){return this.stopPolling(),Promise.resolve()}_fetchFlags(e){return P(this,void 0,void 0,function*(){var t;try{const r={context:e},n=yield this._ofrepAPI.postBulkEvaluateFlags(r,this._etag);if(304===n.httpStatus)return{status:m.SUCCESS_NO_CHANGES,flags:[]};if(200!==n.httpStatus)throw new $.$g(`Failed OFREP bulk evaluation request, status: ${n.httpStatus}`);const a=n.value;if(!("flags"in a)||!Array.isArray(a.flags))throw new Error("No flags in OFREP bulk evaluation response");const o=a.flags.reduce((e,t)=>(t.key&&(e[t.key]=t),e),{}),i=this._getListUpdatedFlags(this._flagCache,o);return this._flagCache=o,this._etag=null===(t=n.httpResponse)||void 0===t?void 0:t.headers.get("etag"),this._flagSetMetadataCache=g("object"==typeof a.metadata?a.metadata:{}),{status:m.SUCCESS_WITH_CHANGES,flags:i}}catch(e){throw e instanceof c&&null!==e.retryAfterDate&&(this._retryPollingAfter=e.retryAfterDate),e}})}_getListUpdatedFlags(e,t){const r=[],n=Object.keys(e),a=Object.keys(t);for(const a in t)-1!==n.indexOf(a)&&JSON.stringify(e[a])===JSON.stringify(t[a])||r.push(a);for(const t in e)-1===a.indexOf(t)&&r.push(t);return r}_resolve(e,t){const r=this._flagCache[e];return r?this.responseToResolutionDetails(r,t):{value:t,flagMetadata:this._flagSetMetadataCache,reason:$.$W.ERROR,errorCode:$.O4.FLAG_NOT_FOUND,errorMessage:f[$.O4.FLAG_NOT_FOUND]}}responseToResolutionDetails(e,t){return d(e)?function(e,t,r){var a,o,i;if(null==r||r(e),"errorCode"in e){const r=null!==(a=e.errorCode)&&void 0!==a?a:n.O4.GENERAL,s=null!==(i=null!==(o=e.errorDetails)&&void 0!==o?o:f[e.errorCode])&&void 0!==i?i:e.errorCode,l=g(e.metadata);return{value:t,reason:n.$W.ERROR,flagMetadata:l,errorCode:r,errorMessage:s}}throw e}(e,t):function(e,t){return void 0===e.value?{value:t,variant:e.variant,flagMetadata:e.metadata,reason:e.reason||n.$W.DEFAULT}:typeof e.value!=typeof t?{value:t,reason:n.$W.ERROR,flagMetadata:e.metadata,errorCode:n.O4.TYPE_MISMATCH,errorMessage:f[n.O4.TYPE_MISMATCH]}:{value:e.value,variant:e.variant,reason:e.reason,flagMetadata:g(e.metadata)}}(e,t)}startPolling(){this._pollingIntervalId=setInterval(()=>P(this,void 0,void 0,function*(){var e,t;try{const t=new Date;if(void 0!==this._retryPollingAfter&&this._retryPollingAfter>t)return;const r=yield this._fetchFlags(this._context);r.status===m.SUCCESS_WITH_CHANGES&&(null===(e=this.events)||void 0===e||e.emit($.Uc.ConfigurationChanged,{message:"Flags updated",flagsChanged:r.flags}))}catch(e){null===(t=this.events)||void 0===t||t.emit($.Uc.Stale,{message:`Error while polling: ${e}`})}}),this._pollingInterval)}stopPolling(){this._pollingIntervalId&&clearInterval(this._pollingIntervalId)}}},38315:(e,t,r)=>{"use strict";r.d(t,{$W:()=>o.$W,$g:()=>o.$g,$l:()=>o.$l,B0:()=>x,Lh:()=>o.Lh,Nm:()=>o.Uc,O4:()=>o.O4,Uc:()=>o.Uc,by:()=>E,wh:()=>o.wh});var n,a,o=r(24888),i=Object.create,s=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertyNames,O=Object.getOwnPropertySymbols,h=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,v=Reflect.get,g=(e,t,r)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,m=(e,t)=>{for(var r in t||(t={}))p.call(t,r)&&g(e,r,t[r]);if(O)for(var r of O(t))f.call(t,r)&&g(e,r,t[r]);return e},$=(e,t)=>l(e,u(t)),P=(e,t,r)=>new Promise((n,a)=>{var o=e=>{try{s(r.next(e))}catch(e){a(e)}},i=e=>{try{s(r.throw(e))}catch(e){a(e)}},s=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,i);s((r=r.apply(e,t)).next())}),b=(n={"../../node_modules/eventemitter3/index.js"(e,t){var r=Object.prototype.hasOwnProperty,n="~";function a(){}function o(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function i(e,t,r,a,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new o(r,a||e,i),l=n?n+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],s]:e._events[l].push(s):(e._events[l]=s,e._eventsCount++),e}function s(e,t){0===--e._eventsCount?e._events=new a:delete e._events[t]}function l(){this._events=new a,this._eventsCount=0}Object.create&&(a.prototype=Object.create(null),(new a).__proto__||(n=!1)),l.prototype.eventNames=function(){var e,t,a=[];if(0===this._eventsCount)return a;for(t in e=this._events)r.call(e,t)&&a.push(n?t.slice(1):t);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},l.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var a=0,o=r.length,i=new Array(o);a(r=null!=e?i(h(e)):{},((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of d(t))p.call(e,a)||a===r||s(e,a,{get:()=>t[a],enumerable:!(n=c(t,a))||n.enumerable});return e})(!t&&e&&e.__esModule?r:s(r,"default",{value:e,enumerable:!0}),e)))(b(),1),E=class extends o.sN{constructor(){super(),this.eventEmitter=new _.default}},w=(o.Lh,o.Lh,o.$g,class{constructor(e,t,r,n,a,o,i){this.providerAccessor=e,this.providerStatusAccessor=t,this.emitterAccessor=r,this.apiContextAccessor=n,this.apiHooksAccessor=a,this.globalLogger=o,this.options=i,this._hooks=[]}get metadata(){var e,t;return{name:null!=(e=this.options.domain)?e:this.options.name,domain:null!=(t=this.options.domain)?t:this.options.name,version:this.options.version,providerMetadata:this.providerAccessor().metadata}}get providerStatus(){return this.providerStatusAccessor()}addHandler(e,t,r){var n;this.emitterAccessor().addHandler(e,t);if((0,o._e)(e,this.providerStatus))try{t({clientName:this.metadata.name,domain:this.metadata.domain,providerName:this._provider.metadata.name})}catch(e){null==(n=this._logger)||n.error("Error running event handler:",e)}(null==r?void 0:r.signal)&&"function"==typeof r.signal.addEventListener&&r.signal.addEventListener("abort",()=>{this.removeHandler(e,t)})}removeHandler(e,t){this.emitterAccessor().removeHandler(e,t)}getHandlers(e){return this.emitterAccessor().getHandlers(e)}setLogger(e){return this._clientLogger=new o.qM(e),this}addHooks(...e){return this._hooks=[...this._hooks,...e],this}getHooks(){return this._hooks}clearHooks(){return this._hooks=[],this}getBooleanValue(e,t,r){return this.getBooleanDetails(e,t,r).value}getBooleanDetails(e,t,r){return this.evaluate(e,this._provider.resolveBooleanEvaluation,t,"boolean",r)}getStringValue(e,t,r){return this.getStringDetails(e,t,r).value}getStringDetails(e,t,r){return this.evaluate(e,this._provider.resolveStringEvaluation,t,"string",r)}getNumberValue(e,t,r){return this.getNumberDetails(e,t,r).value}getNumberDetails(e,t,r){return this.evaluate(e,this._provider.resolveNumberEvaluation,t,"number",r)}getObjectValue(e,t,r){return this.getObjectDetails(e,t,r).value}getObjectDetails(e,t,r){return this.evaluate(e,this._provider.resolveObjectEvaluation,t,"object",r)}track(e,t={}){var r,n,a;try{if(this.shortCircuitIfNotReady(),"function"==typeof this._provider.track){const o=Object.freeze(m({},this.apiContextAccessor(null==(r=null==this?void 0:this.options)?void 0:r.domain)));return null==(a=(n=this._provider).track)?void 0:a.call(n,e,o,t)}this._logger.debug("Provider does not support the track function; will no-op.")}catch(e){this._logger.debug("Error recording tracking event.",e)}}evaluate(e,t,r,n,a={}){var i,s;const l=[...this.apiHooksAccessor(),...this.getHooks(),...a.hooks||[],...this._provider.hooks||[]],c=[...l].reverse(),u=m({},this.apiContextAccessor(null==(i=null==this?void 0:this.options)?void 0:i.domain)),d=c.map(()=>Object.freeze({flagKey:e,defaultValue:r,flagValueType:n,clientMetadata:this.metadata,providerMetadata:this._provider.metadata,context:u,logger:this._logger,hookData:new o.eD}));let O;try{this.beforeHooks(l,d,a),this.shortCircuitIfNotReady();const n=t.call(this._provider,e,r,u,this._logger),i=$(m({},n),{flagMetadata:Object.freeze(null!=(s=n.flagMetadata)?s:{}),flagKey:e});if(i.errorCode){const t=(0,o.l6)(i.errorCode,i.errorMessage);this.errorHooks(c,d,t,a),O=this.getErrorEvaluationDetails(e,r,t,i.flagMetadata)}else this.afterHooks(c,d,i,a),O=i}catch(t){this.errorHooks(c,d,t,a),O=this.getErrorEvaluationDetails(e,r,t)}return this.finallyHooks(c,d,O,a),O}beforeHooks(e,t,r){var n;for(const[a,o]of e.entries()){const i=t[e.length-1-a];Object.freeze(i),Object.freeze(i.context),null==(n=null==o?void 0:o.before)||n.call(o,i,Object.freeze(r.hookHints))}}afterHooks(e,t,r,n){var a;for(const[o,i]of e.entries()){const e=t[o];null==(a=null==i?void 0:i.after)||a.call(i,e,r,n.hookHints)}}errorHooks(e,t,r,n){var a;for(const[o,i]of e.entries())try{const e=t[o];null==(a=null==i?void 0:i.error)||a.call(i,e,r,n.hookHints)}catch(e){this._logger.error(`Unhandled error during 'error' hook: ${e}`),e instanceof Error&&this._logger.error(e.stack),this._logger.error(null==e?void 0:e.stack)}}finallyHooks(e,t,r,n){var a;for(const[o,i]of e.entries())try{const e=t[o];null==(a=null==i?void 0:i.finally)||a.call(i,e,r,n.hookHints)}catch(e){this._logger.error(`Unhandled error during 'finally' hook: ${e}`),e instanceof Error&&this._logger.error(e.stack),this._logger.error(null==e?void 0:e.stack)}}get _provider(){return this.providerAccessor()}get _logger(){return this._clientLogger||this.globalLogger()}shortCircuitIfNotReady(){if(this.providerStatus===o.$l.NOT_READY)throw new o._V("provider has not yet initialized");if(this.providerStatus===o.$l.FATAL)throw new o.wh("provider is in an irrecoverable error state")}getErrorEvaluationDetails(e,t,r,n={}){const a=null==r?void 0:r.message;return{errorCode:(null==r?void 0:r.code)||o.O4.GENERAL,errorMessage:a,value:t,reason:o.$W.ERROR,flagMetadata:Object.freeze(n),flagKey:e}}}),R=Symbol.for("@openfeature/web-sdk/api"),Q=globalThis,x=class e extends o.g7{constructor(){super("client"),this._statusEnumType=o.$l,this._apiEmitter=new E,this._defaultProvider=new o.VL(y,o.$l.NOT_READY,this._statusEnumType),this._domainScopedProviders=new Map,this._createEventEmitter=()=>new E}static getInstance(){const t=Q[R];if(t)return t;const r=new e;return Q[R]=r,r}getProviderStatus(e){var t,r;return e&&null!=(r=null==(t=this._domainScopedProviders.get(e))?void 0:t.status)?r:this._defaultProvider.status}setProviderAndWait(e,t,r){return P(this,null,function*(){const n=(0,o.j)(e),a=n?(0,o.XD)(t):(0,o.XD)(e),i=n?(0,o.XD)(r):(0,o.XD)(t);i&&(n?this._domainScopedContext.set(n,i):this._context=i),yield this.setAwaitableProvider(n,a)})}setProvider(e,t,r){const n=(0,o.j)(e),a=n?(0,o.XD)(t):(0,o.XD)(e),i=n?(0,o.XD)(r):(0,o.XD)(t);i&&(n?this._domainScopedContext.set(n,i):this._context=i);const s=this.setAwaitableProvider(n,a);return Promise.resolve(s).catch(e=>{this._logger.error("Error during provider initialization:",e)}),this}getProvider(e){return this.getProviderForClient(e)}setContext(e,t){return P(this,null,function*(){var r,n;const a=(0,o.j)(e),i=null!=(n=null!=(r=(0,o.XD)(e))?r:(0,o.XD)(t))?n:{};if(a){const e=this._domainScopedProviders.get(a);if(e){const t=this.getContext(a);this._domainScopedContext.set(a,i),yield this.runProviderContextChangeHandler(a,e,t,i)}else this._domainScopedContext.set(a,i)}else{const e=this._context;this._context=i;const t=Array.from(this._domainScopedProviders.entries()).filter(([e])=>!this._domainScopedContext.has(e)).reduce((e,[t,r])=>(e.push({domain:t,wrapper:r}),e),[]),r=[{domain:void 0,wrapper:this._defaultProvider},...t];yield Promise.all(r.map(t=>this.runProviderContextChangeHandler(t.domain,t.wrapper,e,i)))}})}getContext(e){const t=(0,o.j)(e);if(t){const e=this._domainScopedContext.get(t);if(e)return e;this._logger.debug(`Unable to find context for '${t}'.`)}return this._context}clearContext(e){return P(this,null,function*(){const t=(0,o.j)(e);if(!t)return this.setContext({});{const e=this._domainScopedProviders.get(t);if(e){const r=this.getContext(t);this._domainScopedContext.delete(t);const n=this.getContext();yield this.runProviderContextChangeHandler(t,e,r,n)}else this._domainScopedContext.delete(t)}})}clearContexts(){return P(this,null,function*(){yield this.clearContext(),yield Promise.allSettled(Array.from(this._domainScopedProviders.keys()).map(e=>this.clearContext(e)))})}getClient(e,t){return new w(()=>this.getProviderForClient(e),()=>this.getProviderStatus(e),()=>this.buildAndCacheEventEmitterForClient(e),e=>this.getContext(e),()=>this.getHooks(),()=>this._logger,{domain:e,version:t})}clearProviders(){return P(this,null,function*(){var t,r,n;yield(t=e.prototype,r=this,n="clearProvidersAndSetDefault",v(h(t),n,r)).call(this,y),this._domainScopedContext.clear()})}runProviderContextChangeHandler(e,t,r,n){return P(this,null,function*(){var a,i,s,l,c,u;const d=(null==(i=null==(a=t.provider)?void 0:a.metadata)?void 0:i.name)||"unnamed-provider";try{if("function"==typeof t.provider.onContextChange){const a=t.provider.onContextChange(r,n);a&&"function"==typeof(null==a?void 0:a.then)&&(t.incrementPendingContextChanges(),t.status=this._statusEnumType.RECONCILING,this.getAssociatedEventEmitters(e).forEach(t=>{null==t||t.emit(o.Uc.Reconciling,{domain:e,providerName:d})}),null==(s=this._apiEmitter)||s.emit(o.Uc.Reconciling,{domain:e,providerName:d}),yield a,t.decrementPendingContextChanges())}t.status=this._statusEnumType.READY,t.allContextChangesSettled&&(this.getAssociatedEventEmitters(e).forEach(t=>{null==t||t.emit(o.Uc.ContextChanged,{clientName:e,domain:e,providerName:d})}),null==(l=this._apiEmitter)||l.emit(o.Uc.ContextChanged,{clientName:e,domain:e,providerName:d}))}catch(r){if(t.decrementPendingContextChanges(),t.status=this._statusEnumType.ERROR,t.allContextChangesSettled){const t=`Error running ${d}'s context change handler: ${null==r?void 0:r.message}`;null==(c=this._logger)||c.error(`${t}`,r),this.getAssociatedEventEmitters(e).forEach(r=>{null==r||r.emit(o.Uc.Error,{clientName:e,domain:e,providerName:d,message:t})}),null==(u=this._apiEmitter)||u.emit(o.Uc.Error,{clientName:e,domain:e,providerName:d,message:t})}}})}}.getInstance()},43209:(e,t,r)=>{"use strict";r.d(t,{w:()=>a});var n=r(85959);function a(e){const{ref:t,box:r,onResize:a}=e;(0,n.useEffect)(()=>{let e=null==t?void 0:t.current;if(e){if(void 0===window.ResizeObserver)return window.addEventListener("resize",a,!1),()=>{window.removeEventListener("resize",a,!1)};{const t=new window.ResizeObserver(e=>{e.length&&a()});return t.observe(e,{box:r}),()=>{e&&t.unobserve(e)}}}},[a,t,r])}},55835:(e,t,r)=>{(()=>{"use strict";var t={n:e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};function a(e){let t=5381;for(let r=0;r>>0).toString(16)}t.r(n),t.d(n,{AITextArea:()=>Wt,AITextInput:()=>zt,ASSISTANT_PLUGIN_ID:()=>M,ASSISTANT_PLUGIN_TITLE:()=>H,CALLBACK_EXTENSION_POINT:()=>F,ComponentNodeData:()=>E,DashboardNodeData:()=>Q,DatasourceNodeData:()=>S,EntityNodeData:()=>X,FolderNodeData:()=>x,InvestigationCreatedEvent:()=>j,LIMITS_UPDATED_EVENT:()=>er,LabelNameNodeData:()=>T,LabelValueNodeData:()=>A,OpenAssistantButton:()=>xt,OpenAssistantSplitButton:()=>Tt,PlaybookNodeData:()=>I,StructuredNodeData:()=>i,TERMS_AND_CONDITIONS_REFRESH_EVENT:()=>Mt,checkLimits:()=>rr,checkTerms:()=>Bt,closeAssistant:()=>oe,createAssistantContextItem:()=>N,createTool:()=>Jt,emitInvestigationCreated:()=>G,ensureInlineAssistantInitialized:()=>qt,getExposeAssistantFunctionsConfig:()=>Y,getInlineAssistantFactory:()=>Vt,isAssistantAvailable:()=>ee,newFunctionNamespace:()=>W,onInvestigationCreated:()=>z,openAssistant:()=>ae,provideComponents:()=>R,providePageContext:()=>m,provideQuestions:()=>D,setInlineAssistantFactory:()=>Dt,setInlineAssistantInitializer:()=>Lt,toggleAssistant:()=>ie,useAssistant:()=>se,useInlineAssistant:()=>Ut,useLimits:()=>nr,usePageComponents:()=>w,usePageContext:()=>b,useProvidePageContext:()=>P,useProvideQuestions:()=>L,useQuestions:()=>q,useTerms:()=>Kt});class o{constructor(e){this.params=e,this.text="",this.id=a(e.id),this.type=e.type}formatForLLM(e){var t,r;return{type:this.type,codeElementIds:e,data:{name:null!==(t=this.params.text)&&void 0!==t?t:"",text:null!==(r=this.params.text)&&void 0!==r?r:""}}}equals(e){return e instanceof o&&this.id===e.id&&this.type===e.type}}class i extends o{constructor(e){super({...e,id:a(JSON.stringify(e.data)),type:"structured"}),this.data=e.data}formatForLLM(e){return{type:this.type,codeElementIds:e,data:this.data}}}const s=r(18531),l=r(85959);var c=t.n(l);const u="__grafanaAssistantPageContextRegistry__",d="grafana-assistant:page-context-registry-changed",O="grafana-assistant:page-context-update",h="grafana-assistant:page-context-remove",p="grafana-assistant:page-context-sync";function f(){return window[u]}function v(e,t=!1){window[u]=e,window.dispatchEvent(new CustomEvent(d)),t||window.dispatchEvent(new CustomEvent(p,{detail:{registry:e}}))}window[u]||(window[u]=[]);let g=!1;function m(e,t){var r;(r=e)instanceof RegExp?r.source:"string"!=typeof r||r&&""!==r.trim()||console.warn("useProvidePageContext: Empty string passed as urlPattern. This will cause the context to not match any pages.");const n={id:y(),urlPattern:e,context:[...t]};v([...f(),n]),window.dispatchEvent(new CustomEvent(O,{detail:n}));const a=e=>{const t=f(),r=t.findIndex(e=>e.id===n.id);if(-1!==r){const n=[...t];n[r]={...n[r],context:[...e]},v(n),window.dispatchEvent(new CustomEvent(O,{detail:n[r]}))}};return a.unregister=()=>{const e=f(),t=e.findIndex(e=>e.id===n.id);-1!==t&&(v(e.filter((e,r)=>r!==t)),window.dispatchEvent(new CustomEvent(h,{detail:{id:n.id}})))},a}g||(g=!0,window.addEventListener(O,e=>{const t=e.detail;if(!t||!t.id)return;const r=f(),n=r.findIndex(e=>e.id===t.id);if(-1!==n){const e=[...r];e[n]=t,v(e,!0)}else v([...r,t],!0)}),window.addEventListener(h,e=>{var t;const r=null===(t=e.detail)||void 0===t?void 0:t.id;if(!r)return;const n=f(),a=n.findIndex(e=>e.id===r);-1!==a&&v(n.filter((e,t)=>t!==a),!0)}),window.addEventListener(p,e=>{var t;const r=null===(t=e.detail)||void 0===t?void 0:t.registry;if(!Array.isArray(r))return;const n=f(),a=new Set(n.map(e=>e.id)),o=r.filter(e=>!a.has(e.id));o.length>0&&v([...n,...o],!0)}));const $=[];function P(e,t=$){const r=(0,l.useRef)(void 0),n=(0,l.useRef)(void 0),a=(0,l.useRef)(!1);return(0,l.useEffect)(()=>{a.current=!1;const o=void 0!==n.current?n.current:t;return r.current=m(e,o),void 0!==n.current&&(n.current=void 0),()=>{var e;null===(e=r.current)||void 0===e||e.unregister(),r.current=void 0}},[e]),(0,l.useEffect)(()=>{!a.current&&r.current&&r.current(t)},[t]),(0,l.useCallback)(e=>{a.current=!0,r.current?r.current(e):n.current=e},[])}function b(e={allowQuestions:!1,allowComponents:!1}){const[t,r]=(0,l.useState)([]),n=(0,s.useLocationService)(),a=(0,l.useRef)("");(0,l.useEffect)(()=>{const e=()=>{const e=function(e){if(!e)return[];const t=[],r=f();for(const n of r)_(e,n.urlPattern)&&t.push(...n.context);return t}(n.getLocation().pathname);r(e)},t=()=>{e()},o=n.getLocationObservable().subscribe(t=>{const r=t.pathname;r!==a.current&&(a.current=r,e())});return window.addEventListener(d,t),window.addEventListener(O,t),window.addEventListener(h,t),window.addEventListener(p,t),e(),()=>{o.unsubscribe(),window.removeEventListener(d,t),window.removeEventListener(O,t),window.removeEventListener(h,t),window.removeEventListener(p,t)}},[n]);let o=t;return e.allowQuestions||(o=o.filter(e=>{var t;return"question"!==(null===(t=e.node.data)||void 0===t?void 0:t.type)})),e.allowComponents||(o=o.filter(e=>{var t;return"component"!==(null===(t=e.node.data)||void 0===t?void 0:t.type)})),o}function y(e="page-context"){return`${e}-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function _(e,t){if(t instanceof RegExp)return t.test(e);if("string"==typeof t){if(!t||""===t.trim())return!1;const r=t.replace(/\*\*/g,"\0DOUBLE_STAR\0").replace(/\*/g,"[^/]*").replace(/\u0000DOUBLE_STAR\u0000/g,".*").replace(/\?/g,".");return new RegExp(`^${r}$`).test(e)}return!1}class E extends o{constructor(e){const t=e.namespace||"components";super({...e,id:`${t}-${Object.keys(e.components).join("-")}`,type:"component"}),this.components=e.components,this.prompt=e.prompt,this.namespace=t}formatForLLM(e){return{type:this.type,codeElementIds:e,data:{name:`${this.namespace} components`,prompt:this.prompt,namespace:this.namespace}}}}function w(){const e=b({allowComponents:!0,allowQuestions:!1});return(0,l.useMemo)(()=>{const t={};return e.filter(e=>{var t;return null===(t=e.node.data)||void 0===t?void 0:t.components}).forEach(e=>{const r=e.node.data;if((null==r?void 0:r.components)&&Object.keys(r.components).length>0){const e=r.namespace||r.name||"components";Object.entries(r.components).forEach(([r,n])=>{t[`${e}_${r}`]=n})}}),t},[e])}function R(e,t,r,n=/.*/){if((a=n)instanceof RegExp?".*"===a.source&&""===a.flags:".*"===a||"/.*/"===a){const n=m(/.*/,[N("component",{components:r,prompt:e,namespace:t})]),a=(e,r)=>{n([N("component",{components:e,prompt:r,namespace:t})])};return a.unregister=n.unregister,a}var a;const o=m(/.*/,[N("component",{components:r,prompt:"",namespace:t})]),i=m(n,[N("component",{components:{},prompt:e,namespace:t})]),s=(e,r)=>{o([N("component",{components:e,prompt:"",namespace:t})]),i([N("component",{components:{},prompt:r,namespace:t})])};return s.unregister=()=>{o.unregister(),i.unregister()},s}class Q extends o{constructor(e){super({...e,id:e.dashboardUid,type:"dashboard"}),this.dashboardUid=e.dashboardUid,this.dashboardTitle=e.dashboardTitle,this.folderUid=e.folderUid,this.folderTitle=e.folderTitle,this.text=e.dashboardTitle}formatForLLM(e){return{type:this.type,codeElementIds:e,data:{name:this.dashboardTitle,dashboardUid:this.dashboardUid,dashboardTitle:this.dashboardTitle,folderUid:this.folderUid,folderTitle:this.folderTitle,text:this.text}}}}class x extends o{constructor(e){super({...e,id:e.folderUid,type:"dashboard_folder"}),this.text="",this.folderUid=e.folderUid,this.folderTitle=e.folderTitle,this.text=e.folderTitle}formatForLLM(e){return{type:this.type,codeElementIds:e,data:{name:this.folderTitle,folderUid:this.folderUid,folderTitle:this.folderTitle,text:this.text}}}}class S extends o{constructor(e){super({...e,id:e.datasourceUid,type:"datasource"}),this.datasourceUid=e.datasourceUid,this.datasourceType=e.datasourceType,this.datasourceName=e.datasourceName,this.img=e.img,this.text=e.datasourceName}formatForLLM(e){return{type:this.type,codeElementIds:e,data:{name:this.datasourceName,uid:this.datasourceUid,type:this.datasourceType,text:this.text,img:this.img}}}}class X extends o{constructor(e){var t,r,n;super({id:`${e.type}-${e.name}-${[null===(t=e.scope)||void 0===t?void 0:t.env,null===(r=e.scope)||void 0===r?void 0:r.site,null===(n=e.scope)||void 0===n?void 0:n.namespace].filter(Boolean).join("-")}`,type:"entity",title:e.title,hidden:e.hidden,img:e.img,icon:e.icon,text:e.name}),this.entityType=e.type,this.name=e.name,this.scope=e.scope,this.properties=e.properties,this.text=e.name}formatForLLM(e){return{type:"entity",codeElementIds:e,data:{name:this.name,text:this.text,type:this.entityType,scope:this.scope,properties:this.properties}}}}class T extends o{constructor(e){super({...e,id:`${e.datasourceUid}-${e.labelName}`,type:"label_name"}),this.datasourceUid=e.datasourceUid,this.datasourceType=e.datasourceType,this.datasourceName=e.datasourceName,this.labelName=e.labelName,this.text=e.labelName,this.img=e.img}formatForLLM(e){return{type:this.type,codeElementIds:e,data:{name:this.labelName,datasourceUid:this.datasourceUid,datasourceType:this.datasourceType,datasourceName:this.datasourceName,labelName:this.labelName,img:this.img,text:this.text}}}}class A extends o{constructor(e){super({...e,id:`${e.datasourceUid}-${e.labelName}-${e.labelValue}`,type:"label_value"}),this.datasourceUid=e.datasourceUid,this.datasourceType=e.datasourceType,this.datasourceName=e.datasourceName,this.labelName=e.labelName,this.labelValue=e.labelValue,this.text=e.labelValue,this.img=e.img}formatForLLM(e){return{type:this.type,codeElementIds:e,data:{name:this.labelValue,datasourceUid:this.datasourceUid,datasourceType:this.datasourceType,datasourceName:this.datasourceName,labelName:this.labelName,labelValue:this.labelValue,text:this.text,img:this.img}}}}function C(e){var t,r,n,a,o;const i=(0,s.getDataSourceSrv)().getInstanceSettings(e);return{datasourceType:null!==(t=null==i?void 0:i.type)&&void 0!==t?t:"unknown",datasourceName:null!==(r=null==i?void 0:i.name)&&void 0!==r?r:e,img:null===(o=null===(a=null===(n=null==i?void 0:i.meta)||void 0===n?void 0:n.info)||void 0===a?void 0:a.logos)||void 0===o?void 0:o.small}}const k={datasource:"database",label_name:"database",label_value:"database",dashboard:"dashboard",dashboard_folder:"folder",unknown:"circle-mono",structured:"gf-grid",component:"gf-grid",entity:"asserts",playbook:"play"};function N(e,t){var r,n,a;const s=function(e,t){switch(e){case"datasource":return new S({...t,...C(t.datasourceUid)});case"label_name":return new T({...t,...C(t.datasourceUid)});case"label_value":return new A({...t,...C(t.datasourceUid)});case"dashboard":return new Q(t);case"dashboard_folder":return new x(t);case"structured":return new i(t);case"component":return new E({...t,hidden:!0});case"entity":return new X(t);case"unknown":return new o(t);default:return console.error(`Unknown context type: ${e}`),new o(t)}}(e,t),l=null!==(r=t.title)&&void 0!==r?r:function(e){var t;return e instanceof i?e.formatForLLM().data.name:null!==(t=e.text)&&void 0!==t?t:"Given Context"}(s),c=null!==(n=t.img)&&void 0!==n?n:function(e){if("img"in e)return e.img}(s);return{node:{id:s.id,name:l,img:c,icon:null!==(a=t.icon)&&void 0!==a?a:k[e],navigable:!1,selectable:!0,data:s},occurrences:[]}}class I extends o{constructor(e){super({...e,id:e.playbookId,type:"playbook",text:e.playbookName}),this.playbookId=e.playbookId,this.playbookName=e.playbookName,this.text=e.playbookName}formatForLLM(e){return{type:this.type,codeElementIds:e,data:{name:this.playbookName,playbookId:this.playbookId,playbookName:this.playbookName,text:this.text}}}}function D(e,t){const r=y("question"),n=e=>e.map((e,t)=>({node:{id:`question-${r}-${t}`,name:e.title||e.prompt,navigable:!1,selectable:!0,icon:"question-circle",data:{type:"question",prompt:e.prompt,title:e.title,context:e.context||[]}},occurrences:[]})),a=m(e,n(t)),o=e=>{a(n(e))};return o.unregister=a.unregister,o}function L(e,t=[]){const r=(0,l.useMemo)(()=>y("question"),[]),n=e=>e.map((e,t)=>{var n;return{node:{id:`question-${r}-${t}`,name:null!==(n=e.title)&&void 0!==n?n:e.prompt,navigable:!1,selectable:!0,icon:"question-circle",data:{type:"question",prompt:e.prompt,title:e.title,context:e.context||[]}},occurrences:[]}}),a=P(e,n(t));return e=>{a(n(e))}}function q(){const e=b({allowQuestions:!0,allowComponents:!1});return V(e)}const V=e=>e.filter(e=>{var t;return"question"===(null===(t=e.node.data)||void 0===t?void 0:t.type)}).map(e=>{var t,r,n;return{prompt:(null===(t=e.node.data)||void 0===t?void 0:t.prompt)||e.node.name,title:null===(r=e.node.data)||void 0===r?void 0:r.title,context:(null===(n=e.node.data)||void 0===n?void 0:n.context)||[]}}),U=r(87781);class j extends U.BusEventWithPayload{}function G(e){const t=new j({investigationId:e});(0,s.getAppEvents)().publish(t)}function z(e){const t=(0,s.getAppEvents)().subscribe(j,t=>{e(t.payload)});return()=>t.unsubscribe()}j.type="grafana-assistant:investigation-created";const F="grafana-assistant-app/callback/v0-alpha";function W(e,t){return{namespace:e,functions:t}}function Y(e){return{title:"callback",targets:[F],fn:()=>e.map(e=>({namespace:e.namespace,functions:e.functions}))}}const Z=r(31269),M="grafana-assistant-app",H="Grafana Assistant",B=10,K=100,J=5e3;function ee(){return s.getObservablePluginLinks?(0,Z.defer)(()=>{try{return(0,s.getObservablePluginLinks)({extensionPointId:"grafana/extension-sidebar/v0-alpha"}).pipe((0,Z.map)(e=>e.some(e=>e.pluginId===M&&e.title===H)))}catch(e){return(0,Z.throwError)(()=>e)}}).pipe((0,Z.retry)({count:B,delay:(e,t)=>{var r;const n=(null===(r=null==e?void 0:e.message)||void 0===r?void 0:r.toLowerCase())||"";if(!(n.includes("can only be used after")||n.includes("grafana instance has started")||n.includes("not started")))throw e;const a=Math.min(K*Math.pow(2,t-1),J);return(0,Z.timer)(a)}}),(0,Z.catchError)(()=>(0,Z.of)(!1))):(0,Z.of)(!1)}class te extends U.BusEventWithPayload{}te.type="open-extension-sidebar";class re extends U.BusEventBase{}re.type="close-extension-sidebar";class ne extends U.BusEventWithPayload{}function ae(e){var t,r;(0,s.reportInteraction)("grafana_assistant_app_opened_sidebar",{from:e.origin,prompt:null!==(t=e.prompt)&&void 0!==t?t:""}),function(e,t,r){const n=new te({pluginId:e,componentTitle:t,props:r});(0,s.getAppEvents)().publish(n)}(M,H,{initialPrompt:e.prompt,initialContext:e.context,initialAutoSend:null===(r=e.autoSend)||void 0===r||r,origin:e.origin,initialMode:e.mode})}function oe(){!function(){const e=new re;(0,s.getAppEvents)().publish(e)}()}function ie(e){var t,r;(0,s.reportInteraction)("grafana_assistant_app_toggled_sidebar",{from:e.origin,prompt:null!==(t=e.prompt)&&void 0!==t?t:""}),function(e,t,r){const n=new ne({pluginId:e,componentTitle:t,props:r});(0,s.getAppEvents)().publish(n)}(M,H,{initialPrompt:e.prompt,initialContext:e.context,initialAutoSend:null===(r=e.autoSend)||void 0===r||r,origin:e.origin,initialMode:e.mode})}function se(){const[e,t]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{const e=ee().subscribe(e=>t(e));return()=>{e.unsubscribe()}},[]),{isAvailable:e,openAssistant:e?ae:void 0,closeAssistant:e?oe:void 0,toggleAssistant:e?ie:void 0}}ne.type="toggle-extension-sidebar";const le=r(82007);var ce=function(){function e(e){var t=this;this._insertTag=function(e){var r;r=0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling:t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling,t.container.insertBefore(e,r),t.tags.push(e)},this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)==0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t0?ve(Re,--Ee):0,ye--,10===we&&(ye=1,be--),we}function Xe(){return we=Ee<_e?ve(Re,Ee++):0,ye++,10===we&&(ye=1,be++),we}function Te(){return ve(Re,Ee)}function Ae(){return Ee}function Ce(e,t){return ge(Re,e,t)}function ke(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Ne(e){return be=ye=1,_e=me(Re=e),Ee=0,[]}function Ie(e){return Re="",e}function De(e){return he(Ce(Ee-1,Ve(91===e?e+2:40===e?e+1:e)))}function Le(e){for(;(we=Te())&&we<33;)Xe();return ke(e)>2||ke(we)>3?"":" "}function qe(e,t){for(;--t&&Xe()&&!(we<48||we>102||we>57&&we<65||we>70&&we<97););return Ce(e,Ae()+(t<6&&32==Te()&&32==Xe()))}function Ve(e){for(;Xe();)switch(we){case e:return Ee;case 34:case 39:34!==e&&39!==e&&Ve(we);break;case 40:41===e&&Ve(e);break;case 92:Xe()}return Ee}function Ue(e,t){for(;Xe()&&e+we!==57&&(e+we!==84||47!==Te()););return"/*"+Ce(t,Ee-1)+"*"+de(47===e?e:Xe())}function je(e){for(;!ke(Te());)Xe();return Ce(e,Ee)}var Ge="-ms-",ze="-moz-",Fe="-webkit-",We="comm",Ye="rule",Ze="decl",Me="@keyframes";function He(e,t){for(var r="",n=$e(e),a=0;a0&&me(_)-d&&Pe(h>32?rt(_+";",n,r,d-1):rt(pe(_," ","")+";",n,r,d-2),l);break;case 59:_+=";";default:if(Pe(y=et(_,t,r,c,u,a,s,$,P=[],b=[],d),o),123===m)if(0===u)Je(_,t,y,y,P,o,d,s,b);else switch(99===O&&110===ve(_,3)?100:O){case 100:case 108:case 109:case 115:Je(e,y,y,n&&Pe(et(e,y,y,0,0,a,s,$,a,P=[],d),b),a,b,d,s,n?P:b);break;default:Je(_,y,y,y,[""],b,0,s,b)}}c=u=h=0,f=g=1,$=_="",d=i;break;case 58:d=1+me(_),h=p;default:if(f<1)if(123==m)--f;else if(125==m&&0==f++&&125==Se())continue;switch(_+=de(m),m*f){case 38:g=u>0?1:(_+="\f",-1);break;case 44:s[c++]=(me(_)-1)*g,g=1;break;case 64:45===Te()&&(_+=De(Xe())),O=Te(),u=d=me($=_+=je(Ae())),m++;break;case 45:45===p&&2==me(_)&&(f=0)}}return o}function et(e,t,r,n,a,o,i,s,l,c,u){for(var d=a-1,O=0===a?o:[""],h=$e(O),p=0,f=0,v=0;p0?O[g]+" "+m:pe(m,/&\f/g,O[g])))&&(l[v++]=$);return Qe(e,t,r,0===a?Ye:s,l,c,u)}function tt(e,t,r){return Qe(e,t,r,We,de(we),ge(e,2,-2),0)}function rt(e,t,r,n){return Qe(e,t,r,Ze,ge(e,0,n),ge(e,n+1,-1),n)}var nt=function(e,t,r){for(var n=0,a=0;n=a,a=Te(),38===n&&12===a&&(t[r]=1),!ke(a);)Xe();return Ce(e,Ee)},at=new WeakMap,ot=function(e){if("rule"===e.type&&e.parent&&!(e.length<1)){for(var t=e.value,r=e.parent,n=e.column===r.column&&e.line===r.line;"rule"!==r.type;)if(!(r=r.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||at.get(r))&&!n){at.set(e,!0);for(var a=[],o=function(e,t){return Ie(function(e,t){var r=-1,n=44;do{switch(ke(n)){case 0:38===n&&12===Te()&&(t[r]=1),e[r]+=nt(Ee-1,t,r);break;case 2:e[r]+=De(n);break;case 4:if(44===n){e[++r]=58===Te()?"&\f":"",t[r]=e[r].length;break}default:e[r]+=de(n)}}while(n=Xe());return e}(Ne(e),t))}(t,a),i=r.props,s=0,l=0;s6)switch(ve(e,t+1)){case 109:if(45!==ve(e,t+4))break;case 102:return pe(e,/(.+:)(.+)-([^]+)/,"$1"+Fe+"$2-$3$1"+ze+(108==ve(e,t+3)?"$3":"$2-$3"))+e;case 115:return~fe(e,"stretch")?st(pe(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==ve(e,t+1))break;case 6444:switch(ve(e,me(e)-3-(~fe(e,"!important")&&10))){case 107:return pe(e,":",":"+Fe)+e;case 101:return pe(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Fe+(45===ve(e,14)?"inline-":"")+"box$3$1"+Fe+"$2$3$1"+Ge+"$2box$3")+e}break;case 5936:switch(ve(e,t+11)){case 114:return Fe+e+Ge+pe(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Fe+e+Ge+pe(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Fe+e+Ge+pe(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return Fe+e+Ge+e+e}return e}var lt=[function(e,t,r,n){if(e.length>-1&&!e.return)switch(e.type){case Ze:e.return=st(e.value,e.length);break;case Me:return He([xe(e,{value:pe(e.value,"@","@"+Fe)})],n);case Ye:if(e.length)return function(e,t){return e.map(t).join("")}(e.props,function(t){switch(function(e){return(e=/(::plac\w+|:read-\w+)/.exec(e))?e[0]:e}(t)){case":read-only":case":read-write":return He([xe(e,{props:[pe(t,/:(read-\w+)/,":-moz-$1")]})],n);case"::placeholder":return He([xe(e,{props:[pe(t,/:(plac\w+)/,":"+Fe+"input-$1")]}),xe(e,{props:[pe(t,/:(plac\w+)/,":-moz-$1")]}),xe(e,{props:[pe(t,/:(plac\w+)/,Ge+"input-$1")]})],n)}return""})}}],ct={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};var ut=/[A-Z]|^ms/g,dt=/_EMO_([^_]+?)_([^]*?)_EMO_/g,Ot=function(e){return 45===e.charCodeAt(1)},ht=function(e){return null!=e&&"boolean"!=typeof e},pt=function(e){var t=Object.create(null);return function(r){return void 0===t[r]&&(t[r]=e(r)),t[r]}}(function(e){return Ot(e)?e:e.replace(ut,"-$&").toLowerCase()}),ft=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(dt,function(e,t,r){return gt={name:t,styles:r,next:gt},t})}return 1===ct[e]||Ot(e)||"number"!=typeof t||0===t?t:t+"px"};function vt(e,t,r){if(null==r)return"";var n=r;if(void 0!==n.__emotion_styles)return n;switch(typeof r){case"boolean":return"";case"object":var a=r;if(1===a.anim)return gt={name:a.name,styles:a.styles,next:gt},a.name;var o=r;if(void 0!==o.styles){var i=o.next;if(void 0!==i)for(;void 0!==i;)gt={name:i.name,styles:i.styles,next:gt},i=i.next;return o.styles+";"}return function(e,t,r){var n="";if(Array.isArray(r))for(var a=0;a=4;++n,a-=4)t=1540483477*(65535&(t=255&e.charCodeAt(n)|(255&e.charCodeAt(++n))<<8|(255&e.charCodeAt(++n))<<16|(255&e.charCodeAt(++n))<<24))+(59797*(t>>>16)<<16),r=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&r)+(59797*(r>>>16)<<16);switch(a){case 3:r^=(255&e.charCodeAt(n+2))<<16;case 2:r^=(255&e.charCodeAt(n+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(n)))+(59797*(r>>>16)<<16)}return(((r=1540483477*(65535&(r^=r>>>13))+(59797*(r>>>16)<<16))^r>>>15)>>>0).toString(36)}(a)+l;return{name:c,styles:a,next:gt}}function Pt(e,t,r){var n="";return r.split(" ").forEach(function(r){void 0!==e[r]?t.push(e[r]+";"):r&&(n+=r+" ")}),n}function bt(e,t){if(void 0===e.inserted[t.name])return e.insert("",t,e.sheet,!0)}function yt(e,t,r){var n=[],a=Pt(e,n,r);return n.length<2?r:a+t(n)}var _t=function e(t){for(var r="",n=0;n{(0,s.reportInteraction)("grafana_assistant_app_open_sidebar_button_displayed",{from:t})},[t]),c().createElement(c().Fragment,null,i?c().createElement(le.IconButton,{name:"ai-sparkle",onClick:()=>{null==d||d(),u({prompt:e,context:r,autoSend:n,origin:t})},variant:"secondary",size:o,"aria-label":a,className:O.icon,tooltip:a,"data-testid":"assistant-icon-button"}):c().createElement(le.Button,{icon:"ai-sparkle",onClick:()=>{null==d||d(),u({prompt:e,context:r,autoSend:n,origin:t})},variant:"secondary",fill:"solid",size:o,title:a,"aria-label":a,className:O.button,"data-testid":"assistant-button"},a))}Et.sheet,Et.cache;const Xt=e=>{const t=e.colors.secondary.main,r=e.colors.emphasize(t,.05),n=e.colors.background.canvas,a=e.shape.radius.default,o=`max(calc(${a} - 1px), 1px)`,i={content:'""',position:"absolute",inset:0,borderRadius:a,cornerShape:"squircle",background:"linear-gradient(90deg, rgb(168, 85, 247), rgb(249, 115, 22))",zIndex:-2,pointerEvents:"none"},s=e=>({content:'""',position:"absolute",inset:"1px",borderRadius:o,cornerShape:"squircle",background:`linear-gradient(${e}, ${e}), ${n}`,zIndex:-1,transition:"none",pointerEvents:"none"});return{button:Qt({label:"assistant-button",position:"relative",isolation:"isolate",border:"none",transition:"none !important","&::before":i,"&::after":{...s(t),transition:"none"},"&:hover":{transition:"none !important"},"&:hover::after":{background:`linear-gradient(${r}, ${r}), ${n}`}}),icon:Qt({label:"assistant-icon",position:"relative",isolation:"isolate",border:"none",background:"none",padding:e.spacing(.5),"&::before":{...i,transition:"background 0.1s ease"},"&:hover::after":{...s(t),background:`linear-gradient(${r}, ${r}), ${n}`}})}};function Tt(e){const{isAvailable:t,openAssistant:r}=se();return t&&r?c().createElement(At,{...e,openAssistant:r}):null}function At({prompt:e,origin:t,context:r,autoSend:n=!0,title:a="Chat with Assistant",size:o="sm",onClick:i,menuItems:u,tooltip:d,openAssistant:O}){const h=(0,le.useStyles2)(Ct);(0,l.useEffect)(()=>{(0,s.reportInteraction)("grafana_assistant_app_open_sidebar_split_button_displayed",{from:t})},[t]);const p=c().createElement("div",{className:h.wrapper},c().createElement(le.ButtonGroup,{className:h.buttonGroup},c().createElement(le.Button,{icon:"ai-sparkle",onClick:()=>{null==i||i(),O({prompt:e,context:r,autoSend:n,origin:t})},variant:"secondary",fill:"solid",size:o,"aria-label":a,"data-testid":"assistant-split-button-main"},a),u&&c().createElement(le.Dropdown,{overlay:u},c().createElement(le.Button,{variant:"secondary",icon:"angle-down",size:o,"aria-label":"More AI actions",className:h.dropdownButton,"data-testid":"assistant-split-button-dropdown"}))));return d?c().createElement(le.Tooltip,{content:d},p):p}const Ct=e=>{const t=e.colors.secondary.main,r=e.colors.emphasize(t,.05),n=e.colors.background.canvas,a=e.shape.radius.default;return{wrapper:Qt({label:"assistant-split-button-wrapper",position:"relative",isolation:"isolate",display:"inline-block","&::before":{content:'""',position:"absolute",inset:0,borderRadius:a,cornerShape:"squircle",background:"linear-gradient(90deg, rgb(168, 85, 247), rgb(249, 115, 22))",zIndex:-1,pointerEvents:"none"},"&::after":{content:'""',position:"absolute",inset:"1px",borderRadius:`max(calc(${a} - 1px), 1px)`,cornerShape:"squircle",background:`linear-gradient(${t}, ${t}), ${n}`,zIndex:-1,pointerEvents:"none"},"&:hover::after":{background:`linear-gradient(${r}, ${r}), ${n}`}}),buttonGroup:Qt({label:"assistant-split-button-group",gap:0,position:"relative",zIndex:1,"& button":{border:"none",background:"transparent !important","&:hover":{background:"transparent !important"}}}),dropdownButton:Qt({padding:"0 6px"})}},kt="__grafanaAssistantInlineFactory__",Nt="__grafanaAssistantInlineInitializer__",It="__grafanaAssistantInlineInitPromise__";function Dt(e){const t=window[kt];t&&t!==e?console.warn("InlineAssistant factory already set; ignoring subsequent setInlineAssistantFactory call"):t||(window[kt]=e)}function Lt(e){const t=window[Nt];t&&t!==e?console.warn("InlineAssistant initializer already set; ignoring subsequent setInlineAssistantInitializer call"):t||(window[Nt]=e)}async function qt(){if(window[kt])return;const e=window[Nt];if(!e)throw new Error("InlineAssistant not initialized. Make sure the Grafana Assistant plugin is loaded and initialized.");const t=window[It];if(t)return t;const r=(async()=>{try{await e()}catch(e){throw window[It]=null,e}})();return window[It]=r,r}function Vt(){const e=window[kt];if(!e)throw new Error("InlineAssistant factory not initialized. Make sure the Grafana Assistant plugin is loaded.");return e}function Ut(){const[e,t]=(0,l.useState)(!1),[r,n]=(0,l.useState)(""),[a,o]=(0,l.useState)(null),i=(0,l.useRef)(null),s=(0,l.useCallback)(()=>{o(null),n("")},[]),c=(0,l.useCallback)(()=>{i.current&&i.current.cancel(),t(!1)},[]),u=(0,l.useCallback)(async e=>{var r;o(null),n(""),t(!0);try{await qt();const r=Vt();i.current||(i.current=await r(e.origin)),await i.current.sendPrompt({prompt:e.prompt,systemPrompt:e.systemPrompt,tools:e.tools,onStart:()=>{t(!0)},onDelta:t=>{var r;n(e=>e+t),null===(r=e.onDelta)||void 0===r||r.call(e,t)},onComplete:r=>{var a;n(r),t(!1),null===(a=e.onComplete)||void 0===a||a.call(e,r)},onError:r=>{var n;o(r),t(!1),null===(n=e.onError)||void 0===n||n.call(e,r)}})}catch(n){const a=n instanceof Error?n:new Error(String(n));o(a),t(!1),null===(r=e.onError)||void 0===r||r.call(e,a)}},[]);return(0,l.useEffect)(()=>()=>{i.current&&(i.current.cancel(),i.current.dispose(),i.current=null)},[]),{generate:u,isGenerating:e,content:r,error:a,cancel:c,reset:s}}const jt=e=>{const t=["rgb(168, 85, 247)","rgb(249, 115, 22)"];if("dark"===e.name.toLowerCase()||"light"===e.name.toLowerCase())return t;const r=e.colors.gradients.brandHorizontal.match(/#[0-9A-Fa-f]{6}/g);return!r||r.length<2?t:[r[0],r[1]]},Gt=(e,t,r,n)=>{const a=Array.from({length:101},(e,t)=>t),o={},[i,s]=jt(e),l=null!=r?r:i,c=null!=n?n:s;return a.forEach(e=>{o[`${e}%`]={backgroundImage:`\n linear-gradient(${t}, ${t}),\n conic-gradient(from ${3.6*e}deg, transparent 60%, ${l} 80%, ${c} 100%, transparent 15%)\n `}}),o};function zt({value:e,onChange:t,placeholder:r,origin:n,systemPrompt:a,onComplete:o,onError:i,onDelta:s,disabled:l=!1,className:u,"data-testid":d}){const{generate:O,isGenerating:h,error:p,reset:f}=Ut(),v=!e.trim()||l||h,g=(0,le.useStyles2)(Ft),m=async()=>{if(v)return;const t=e.trim();f(),await O({prompt:t,origin:n,systemPrompt:a,onComplete:e=>{null==o||o(e)},onError:e=>{null==i||i(e)},onDelta:e=>{null==s||s(e)}})},$=c().createElement(le.IconButton,{name:"ai-sparkle",onClick:m,disabled:v,tooltip:v?"Enter text to generate":"Generate with AI","data-testid":d?`${d}-send`:void 0});return c().createElement("div",{className:wt(g.wrapper,{[g.animatedWrapper]:h},u),"data-testid":d},c().createElement(le.Input,{value:e,onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),m())},onChange:e=>t(e.currentTarget.value),placeholder:null!=r?r:"Ask AI to generate...",disabled:l||h,suffix:$,invalid:!!p,"data-testid":d?`${d}-input`:void 0}))}const Ft=e=>{const t=e.colors.background.primary,r=Rt({label:"ai-input-border-animation",...Gt(e,t)}),[n,a]=jt(e);return{wrapper:Qt({label:"ai-text-input-wrapper",position:"relative",borderRadius:e.shape.radius.default,cornerShape:"squircle"}),animatedWrapper:Qt({label:"ai-text-input-animated",border:"1px solid transparent",backgroundImage:`\n linear-gradient(${t}, ${t}),\n conic-gradient(from 0deg, transparent 60%, ${n} 80%, ${a} 100%, transparent 15%)\n `,backgroundOrigin:"border-box",backgroundClip:"padding-box, border-box",animation:`${r} 2s linear infinite`,"& input":{border:"none !important"}})}};function Wt({value:e,onChange:t,placeholder:r,origin:n,systemPrompt:a,onComplete:o,onError:i,onDelta:s,disabled:l=!1,rows:u=4,className:d,"data-testid":O}){const{generate:h,isGenerating:p,error:f,reset:v}=Ut(),g=!e.trim()||l||p,m=(0,le.useStyles2)(Yt),$=async()=>{if(g)return;const t=e.trim();v(),await h({prompt:t,origin:n,systemPrompt:a,onComplete:e=>{null==o||o(e)},onError:e=>{null==i||i(e)},onDelta:e=>{null==s||s(e)}})};return c().createElement("div",{className:wt(m.textareaWrapper,{[m.animatedWrapper]:p},d),"data-testid":O},c().createElement(le.TextArea,{value:e,onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),$())},onChange:e=>t(e.currentTarget.value),placeholder:null!=r?r:"Ask AI to generate... (Cmd/Ctrl+Enter to send)",disabled:l||p,rows:u,className:m.textarea,invalid:!!f,"data-testid":O?`${O}-textarea`:void 0}),c().createElement(le.IconButton,{name:"ai-sparkle",onClick:$,disabled:g,className:m.sendButton,"aria-label":"Generate with AI",tooltip:g?"Enter text to generate":"Generate with AI (Cmd/Ctrl+Enter)","data-testid":O?`${O}-send`:void 0}))}const Yt=e=>{const t=e.colors.background.primary,r=Rt({label:"ai-textarea-border-animation",...Gt(e,t)}),[n,a]=jt(e);return{textareaWrapper:Qt({label:"ai-textarea-wrapper",position:"relative",borderRadius:e.shape.radius.default,cornerShape:"squircle"}),animatedWrapper:Qt({label:"ai-textarea-animated",border:"1px solid transparent",backgroundImage:`\n linear-gradient(${t}, ${t}),\n conic-gradient(from 0deg, transparent 60%, ${n} 80%, ${a} 100%, transparent 15%)\n `,backgroundOrigin:"border-box",backgroundClip:"padding-box, border-box",animation:`${r} 2s linear infinite`,"& textarea":{border:"none !important"}}),textarea:Qt({label:"ai-textarea",paddingRight:e.spacing(4),scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}}),sendButton:Qt({label:"ai-textarea-send",position:"absolute",right:e.spacing(1),top:e.spacing(1)})}};function Zt(e){const t=e.split("+")[0].split("-"),r=t[0],n=t.length>1?t.slice(1).join("-"):void 0,a=r.split(".").map(Number);return 3!==a.length||a.some(isNaN)?null:{major:a[0],minor:a[1],patch:a[2],prerelease:n}}const Mt="grafana-assistant-terms-and-conditions-refresh";async function Ht(){var e,t;const r=(0,s.getBackendSrv)(),n=`${null!==(e=null===s.config||void 0===s.config?void 0:s.config.appSubUrl)&&void 0!==e?e:""}/api/plugins/${M}/resources/api/v1/settings/terms`,a=(await(0,Z.lastValueFrom)(r.fetch({url:n,method:"GET"}))).data.data,o=null!==(t=a.acceptedTermsAndConditions)&&void 0!==t&&t,i=a.acceptedVersion,l=a.version,c=a.termsType;if("msa"===c)return{accepted:o,termsType:c};if(!o||!i||!l)return{accepted:!1,termsType:c};const u=1===function(e,t){const r=Zt(e),n=Zt(t);return r&&n?r.major!==n.major?r.major>n.major?1:-1:r.minor!==n.minor?r.minor>n.minor?1:-1:r.patch!==n.patch?r.patch>n.patch?1:-1:r.prerelease&&n.prerelease?r.prerelease===n.prerelease?0:r.prerelease>n.prerelease?1:-1:r.prerelease&&!n.prerelease?-1:!r.prerelease&&n.prerelease?1:0:null}(l,i);return{accepted:o&&!u,termsType:c}}async function Bt(){try{return(await Ht()).accepted}catch(e){throw new Error(`Failed to check terms requirements: ${e instanceof Error?e.message:String(e)}`)}}function Kt(){const[e,t]=(0,l.useState)(!1),[r,n]=(0,l.useState)(null),[a,o]=(0,l.useState)(!0),[i,s]=(0,l.useState)(null);return(0,l.useEffect)(()=>{!async function(){try{o(!0),s(null);const e=await Ht();t(e.accepted),n(e.termsType)}catch(e){const r=e instanceof Error?e.message:"Failed to check terms";s(r),t(!1),n(null)}finally{o(!1)}}()},[]),{accepted:e,termsType:r,loading:a,error:i}}function Jt(e,t){var r;const{explainer:n,...a}=null!==(r=t.metadata)&&void 0!==r?r:{},o={name:t.name,description:t.description,inputSchema:t.inputSchema,metadata:n?{...a,explainer:e=>n(e)}:a,responseFormat:t.responseFormat,verboseParsingErrors:t.verboseParsingErrors,async invoke(r,n){var a;try{if(null===(a=n.signal)||void 0===a?void 0:a.aborted)throw new Error(`Tool ${t.name} execution was aborted`);const o=t.validate(r),i=[e(o,n)];return n.signal&&i.push(new Promise((e,r)=>{var a;null===(a=n.signal)||void 0===a||a.addEventListener("abort",()=>{r(new Error(`Tool ${t.name} execution was aborted`))},{once:!0})})),n.timeout&&n.timeout>0&&i.push(new Promise((e,r)=>{setTimeout(()=>{r(new Error(`Tool ${t.name} execution timed out after ${n.timeout}ms`))},n.timeout)})),Promise.race(i)}catch(e){throw t.verboseParsingErrors&&console.error(`Error invoking tool ${t.name}:`,e,r),e}}};return o}const er="grafana-assistant-limits-updated";async function tr(){var e,t,r,n;const a=(0,s.getBackendSrv)(),o=`${null!==(e=null===s.config||void 0===s.config?void 0:s.config.appSubUrl)&&void 0!==e?e:""}/api/plugins/${M}/resources/api/v1/usage/limits/prompt`,i=(await(0,Z.lastValueFrom)(a.fetch({url:o,method:"GET"}))).data.data,l=null!==(t=i.total)&&void 0!==t?t:0,c=null!==(r=i.limit)&&void 0!==r?r:0;return{count:l,limit:c,month:null!==(n=i.month)&&void 0!==n?n:"",isLimitReached:c>0&&l>=c}}async function rr(){try{return await tr()}catch(e){throw new Error(`Failed to check limits: ${e instanceof Error?e.message:String(e)}`)}}function nr(){const[e,t]=(0,l.useState)(0),[r,n]=(0,l.useState)(0),[a,o]=(0,l.useState)(""),[i,s]=(0,l.useState)(!0),[c,u]=(0,l.useState)(null),d=(0,l.useCallback)(async()=>{try{s(!0),u(null);const e=await tr();t(e.count),n(e.limit),o(e.month)}catch(e){const r=e instanceof Error?e.message:"Failed to fetch limits";u(r),t(0),n(0),o("")}finally{s(!1)}},[]);return(0,l.useEffect)(()=>{d()},[d]),(0,l.useEffect)(()=>{const e=e=>{const r=e;r.detail&&(t(r.detail.count),n(r.detail.limit),u(null))};return window.addEventListener(er,e),()=>{window.removeEventListener(er,e)}},[]),{count:e,limit:r,month:a,isLimitReached:r>0&&e>=r,loading:i,error:c,refetch:d}}e.exports=n})()},64774:(e,t,r)=>{"use strict";r.d(t,{zL:()=>a});var n=r(20120),a=(e=>(e[e.dontHide=0]="dontHide",e[e.hideLabel=1]="hideLabel",e[e.hideVariable=2]="hideVariable",e[e.inControlsMenu=3]="inControlsMenu",e))(a||{});n.rw},70025:(e,t,r)=>{"use strict";r.d(t,{g:()=>i});class n{value;next;constructor(e){this.value=e}}class a{#e;#t;#r;constructor(){this.clear()}enqueue(e){const t=new n(e);this.#e?(this.#t.next=t,this.#t=t):(this.#e=t,this.#t=t),this.#r++}dequeue(){const e=this.#e;if(e)return this.#e=this.#e.next,this.#r--,this.#e||(this.#t=void 0),e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#t=void 0,this.#r=0}get size(){return this.#r}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}*drain(){for(;this.#e;)yield this.dequeue()}}function o(e){s(e);const t=new a;let r=0;const n=()=>{r0&&(t.dequeue()(),r++)},o=async(e,t,a)=>{const o=(async()=>e(...a))();t(o);try{await o}catch{}r--,n()},i=(a,...i)=>new Promise(s=>{((a,i,s)=>{new Promise(e=>{t.enqueue(e)}).then(o.bind(void 0,a,i,s)),(async()=>{await Promise.resolve(),rr},pendingCount:{get:()=>t.size},clearQueue:{value(){t.clear()}},concurrency:{get:()=>e,set(a){s(a),e=a,queueMicrotask(()=>{for(;r0;)n()})}}}),i}function i(e,t){const{concurrency:r}=t,n=o(r);return(...t)=>n(()=>e(...t))}function s(e){if(!Number.isInteger(e)&&e!==Number.POSITIVE_INFINITY||!(e>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up")}},76064:(e,t,r)=>{"use strict";r.d(t,{Nc:()=>n,Rq:()=>a});const n=e=>{if(""===e)return e;return a(e)?e:`"${e}"`},a=e=>{if(0===e.length)return!1;for(let t=0;t{const r=e.codePointAt(0);return void 0!==r&&(r>=97&&r<=122||r>=65&&r<=90||95===r||58===r||r>=48&&r<=57&&t>0)}},91719:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});const n=[],a=[];function o(e,t,r){if(e===t)return 0;const o=r?.maxDistance,i=e;e.length>t.length&&(e=t,t=i);let s=e.length,l=t.length;for(;s>0&&e.charCodeAt(~-s)===t.charCodeAt(~-l);)s--,l--;let c,u,d,O,h=0;for(;ho)return o;if(0===s)return void 0!==o&&l>o?o:l;let p=0,f=0;for(;pu?O>u?u+1:O:O>d?d+1:O;if(void 0!==o){let e=u;for(p=0;po)return o}}return n.length=s,a.length=s,void 0!==o&&u>o?o:u}},97666:(e,t,r)=>{"use strict";r.d(t,{r4:()=>a,md:()=>o,GH:()=>n});const n={x_over_time:(e,t,r="$__range",n="")=>`${e}_over_time((${t})[${r}:${n}])`,avg_over_time:({expr:e,range:t,interval:r})=>n.x_over_time("avg",e,t,r),count_over_time:({expr:e,range:t,interval:r})=>n.x_over_time("count",e,t,r),last_over_time:({expr:e,range:t,interval:r})=>n.x_over_time("last",e,t,r),max_over_time:({expr:e,range:t,interval:r})=>n.x_over_time("max",e,t,r),min_over_time:({expr:e,range:t,interval:r})=>n.x_over_time("min",e,t,r),present_over_time:({expr:e,range:t,interval:r})=>n.x_over_time("present",e,t,r),stddev_over_time:({expr:e,range:t,interval:r})=>n.x_over_time("stddev",e,t,r),stdvar_over_time:({expr:e,range:t,interval:r})=>n.x_over_time("stdvar",e,t,r),sum_over_time:({expr:e,range:t,interval:r})=>n.x_over_time("sum",e,t,r),quantile_over_time:({expr:e,range:t,interval:r})=>n.x_over_time("quantile",e,t,r),offset:({units:e})=>(e=>{let t="";for(const[r,n]of Object.entries(e))n>0&&(t+=`${n}${r}`);return t.length?`offset ${t}`:""})(e),by:e=>e?` by (${e.join(", ")}) `:"",without:e=>e?` without (${e.join(", ")}) `:"",byOrWithout:({by:e,without:t})=>e?n.by(e):n.without(t),sum:({expr:e,by:t,without:r})=>`sum${n.byOrWithout({by:t,without:r})}(${e})`,min:({expr:e,by:t,without:r})=>`min${n.byOrWithout({by:t,without:r})}(${e})`,max:({expr:e,by:t,without:r})=>`max${n.byOrWithout({by:t,without:r})}(${e})`,avg:({expr:e,by:t,without:r})=>`avg${n.byOrWithout({by:t,without:r})}(${e})`,group:({expr:e,by:t,without:r})=>`group${n.byOrWithout({by:t,without:r})}(${e})`,count:({expr:e,by:t,without:r})=>`count${n.byOrWithout({by:t,without:r})}(${e})`,stddev:({expr:e,by:t,without:r})=>`stddev${n.byOrWithout({by:t,without:r})}(${e})`,stdvar:({expr:e,by:t,without:r})=>`stdvar${n.byOrWithout({by:t,without:r})}(${e})`,count_values:({expr:e,by:t,without:r,parameter:a})=>`count_values${n.byOrWithout({by:t,without:r})}(${a}, ${e})`,bottomk:({expr:e,by:t,without:r,parameter:a})=>`bottomk${n.byOrWithout({by:t,without:r})}(${a}, ${e})`,topk:({expr:e,by:t,without:r,parameter:a})=>`topk${n.byOrWithout({by:t,without:r})}(${a}, ${e})`,quantile:({expr:e,by:t,without:r,parameter:a})=>`quantile${n.byOrWithout({by:t,without:r})}(${a}, ${e})`,and:({left:e,right:t})=>`${e} and ${t}`,or:({left:e,right:t})=>`${e} or ${t}`,unless:({left:e,right:t})=>`${e} unless ${t}`,rate:({expr:e,interval:t="$__rate_interval"})=>`rate(${e}[${t}])`,increase:({expr:e,interval:t="$__range"})=>`increase(${e}[${t}])`,label_replace:({expr:e,newLabel:t,existingLabel:r,replacement:n="$1",regex:a="(.*)"})=>`label_replace(${e}, "${t}", "${n}", "${r}", "${a}")`,label_join:({expr:e,newLabel:t,separator:r=",",labels:n})=>`label_join(${e}, "${t}", "${r}", ${n.map(e=>`"${e}"`).join(", ")})`};class a{metric;selectors=new Map;constructor(e){this.metric=e.metric,e.defaultSelectors?.forEach(e=>this.setSelector(e));for(const[t,r]of Object.entries(e.values))void 0!==r&&this.selectors.set(t,[{operator:e.defaultOperator,label:t,value:r}])}setSelector(e){const t=this.selectors.get(e.label)||[];return t.push(e),this.selectors.set(e.label,t),this}toString(){const e=Array.from(this.selectors).flatMap(([e,t])=>t.map(t=>`${e}${t.operator}"${t.value}"`)).join(", ");return`${this.metric}{${e}}`}}var o;!function(e){e.equal="=",e.notEqual="!=",e.regexMatch="=~",e.notRegexMatch="!~"}(o||(o={}))}}]); //# sourceMappingURL=500.js.map?_cache=47ac642be8c4049ade21