{"version":3,"sources":["vendor/metrics-providers/consul.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2024, 2026\n * SPDX-License-Identifier: BUSL-1.1\n */\n\n(function(global) {\n  // Current interface is these three methods.\n  const requiredMethods = [\n    'init',\n    'serviceRecentSummarySeries',\n    'serviceRecentSummaryStats',\n    'upstreamRecentSummaryStats',\n    'downstreamRecentSummaryStats',\n  ];\n\n  // This is a bit gross but we want to support simple extensibility by\n  // including JS in the browser without forcing operators to setup a whole\n  // transpiling stack. So for now we use a window global as a thin registry for\n  // these providers.\n  class Consul {\n    constructor() {\n      this.registry = {};\n      this.providers = {};\n    }\n\n    registerMetricsProvider(name, provider) {\n      // Basic check that it matches the type we expect\n      for (var m of requiredMethods) {\n        if (typeof provider[m] !== 'function') {\n          throw new Error(`Can't register metrics provider '${name}': missing ${m} method.`);\n        }\n      }\n      this.registry[name] = provider;\n    }\n\n    getMetricsProvider(name, options) {\n      if (!(name in this.registry)) {\n        throw new Error(`Metrics Provider '${name}' is not registered.`);\n      }\n      if (name in this.providers) {\n        return this.providers[name];\n      }\n\n      this.providers[name] = Object.create(this.registry[name]);\n      this.providers[name].init(options);\n\n      return this.providers[name];\n    }\n  }\n\n  global.consul = new Consul();\n})(window);\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;","file":"consul.js"}