"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.isMetricLabel = exports.MetricLabelSym = exports.MetricLabel = void 0;
exports.make = make;

var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@tsplus/stdlib/structure/Hash"));

var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@tsplus/stdlib/structure/Equals"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var _a;

const isMetricLabel = isMetricLabel_1;
exports.isMetricLabel = isMetricLabel;
const MetricLabelSym = /*#__PURE__*/Symbol.for("@effect/core/io/Metrics/MetricLabel");
/**
 * A `MetricLabel` represents a key value pair that allows analyzing metrics at
 * an additional level of granularity.
 *
 * For example if a metric tracks the response time of a service labels could
 * be used to create separate versions that track response times for different
 * clients.
 *
 * @tsplus type ets/Metrics/MetricLabel
 * @tsplus companion ets/Metrics/MetricLabel/Ops
 */

exports.MetricLabelSym = MetricLabelSym;

class MetricLabel {
  constructor(key, value) {
    this.key = key;
    this.value = value;
    this[_a] = MetricLabelSym;
  }

  [(_a = MetricLabelSym, tsplus_module_1.Hash.sym)]() {
    return tsplus_module_1.combine(tsplus_module_1.hashString(this.key), tsplus_module_1.hashString(this.value));
  }

  [tsplus_module_2.Equals.sym](that) {
    return isMetricLabel_1(that) && this[tsplus_module_1.Hash.sym]() === that[tsplus_module_1.Hash.sym]();
  }

}
/**
 * @tsplus static ets/Metrics/MetricLabel/Ops __call
 */


exports.MetricLabel = MetricLabel;

function make(key, value) {
  return new MetricLabel(key, value);
}
/**
 * @tsplus static ets/Metrics/MetricLabel/Ops isMetricLabel
 */


function isMetricLabel_1(u) {
  return typeof u === "object" && u != null && MetricLabelSym in u;
}
//# sourceMappingURL=MetricLabel.js.map