"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports._Type = exports.SummaryStateSym = exports.SummaryState = exports.MetricStateSym = exports.MetricState = exports.HistogramStateSym = exports.HistogramState = exports.GaugeStateSym = exports.GaugeState = exports.FrequencyStateSym = exports.FrequencyState = exports.CounterStateSym = exports.CounterState = exports.BaseMetricState = void 0;
exports.counter = counter;
exports.frequency = frequency;
exports.gauge = gauge;
exports.histogram = histogram;
exports.isSummaryState = exports.isHistogramState = exports.isGaugeState = exports.isFrequencyState = exports.isCounterState = void 0;
exports.summary = summary;

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

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

var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@tsplus/stdlib/collections/HashMap/_internal/hashMap"));

var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@tsplus/stdlib/collections/Chunk/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, _b, _c, _d, _e, _f;

const isCounterState = isCounterState_1;
exports.isCounterState = isCounterState;
const isGaugeState = isGaugeState_1;
exports.isGaugeState = isGaugeState;
const isFrequencyState = isFrequencyState_1;
exports.isFrequencyState = isFrequencyState;
const isHistogramState = isHistogramState_1;
exports.isHistogramState = isHistogramState;
const isSummaryState = isSummaryState_1;
exports.isSummaryState = isSummaryState;
const MetricStateSym = /*#__PURE__*/Symbol.for("@effect/core/io/Metrics/MetricState");
exports.MetricStateSym = MetricStateSym;

const _Type = /*#__PURE__*/Symbol.for("@effect/core/io/Metrics/MetricState/Type");

exports._Type = _Type;
const CounterStateSym = /*#__PURE__*/Symbol.for("@effect/core/io/Metrics/MetricState/Counter");
exports.CounterStateSym = CounterStateSym;
const GaugeStateSym = /*#__PURE__*/Symbol.for("@effect/core/io/Metrics/MetricState/Gauge");
exports.GaugeStateSym = GaugeStateSym;
const FrequencyStateSym = /*#__PURE__*/Symbol.for("@effect/core/io/Metrics/MetricState/Frequency");
exports.FrequencyStateSym = FrequencyStateSym;
const HistogramStateSym = /*#__PURE__*/Symbol.for("@effect/core/io/Metrics/MetricState/Histogram");
exports.HistogramStateSym = HistogramStateSym;
const SummaryStateSym = /*#__PURE__*/Symbol.for("@effect/core/io/Metrics/MetricState/Summary");
exports.SummaryStateSym = SummaryStateSym;
const MetricState = {};
exports.MetricState = MetricState;

class BaseMetricState {
  constructor() {
    this[_a] = MetricStateSym;
  }

}

exports.BaseMetricState = BaseMetricState;
_a = MetricStateSym;

class CounterState extends BaseMetricState {
  constructor(count) {
    super();
    this.count = count;
    this[_b] = CounterStateSym;
  }

  [(_b = CounterStateSym, tsplus_module_1.Hash.sym)]() {
    return tsplus_module_1.combine(tsplus_module_1.hashString("@effect/core/io/Metrics/MetricState/Counter"), tsplus_module_1.hashNumber(this.count));
  }

  [tsplus_module_2.Equals.sym](u) {
    return isCounterState_1(u) && this.count === u.count;
  }

}

exports.CounterState = CounterState;

class GaugeState extends BaseMetricState {
  constructor(value) {
    super();
    this.value = value;
    this[_c] = GaugeStateSym;
  }

  [(_c = GaugeStateSym, tsplus_module_1.Hash.sym)]() {
    return tsplus_module_1.combine(tsplus_module_1.hashString("@effect/core/io/Metrics/MetricState/Gauge"), tsplus_module_1.hashNumber(this.value));
  }

  [tsplus_module_2.Equals.sym](u) {
    return isGaugeState_1(u) && this.value === u.value;
  }

}

exports.GaugeState = GaugeState;

class FrequencyState extends BaseMetricState {
  constructor(occurrences) {
    super();
    this.occurrences = occurrences;
    this[_d] = FrequencyStateSym;
  }

  [(_d = FrequencyStateSym, tsplus_module_1.Hash.sym)]() {
    return tsplus_module_1.combine(tsplus_module_1.hashString("@effect/core/io/Metrics/MetricState/Frequency"), tsplus_module_1.hashIterator(this.occurrences[Symbol.iterator]()));
  }

  [tsplus_module_2.Equals.sym](u) {
    return isFrequencyState_1(u) && tsplus_module_3.equals_(this.occurrences, u.occurrences);
  }

}

exports.FrequencyState = FrequencyState;

class HistogramState extends BaseMetricState {
  constructor(buckets, count, min, max, sum) {
    super();
    this.buckets = buckets;
    this.count = count;
    this.min = min;
    this.max = max;
    this.sum = sum;
    this[_e] = HistogramStateSym;
  }

  [(_e = HistogramStateSym, tsplus_module_1.Hash.sym)]() {
    return tsplus_module_1.combine(tsplus_module_1.hashString("@effect/core/io/Metrics/MetricState/Histogram"), tsplus_module_1.combine(tsplus_module_1.hashUnknown(this.buckets), tsplus_module_1.combine(tsplus_module_1.hashNumber(this.count), tsplus_module_1.combine(tsplus_module_1.hashNumber(this.min), tsplus_module_1.combine(tsplus_module_1.hashNumber(this.max), tsplus_module_1.hashNumber(this.sum))))));
  }

  [tsplus_module_2.Equals.sym](u) {
    return isHistogramState_1(u) && tsplus_module_4.equals_(this.buckets, u.buckets) && this.count === u.count && this.min === u.min && this.max === u.max && this.sum === u.sum;
  }

}

exports.HistogramState = HistogramState;

class SummaryState extends BaseMetricState {
  constructor(error, quantiles, count, min, max, sum) {
    super();
    this.error = error;
    this.quantiles = quantiles;
    this.count = count;
    this.min = min;
    this.max = max;
    this.sum = sum;
    this[_f] = SummaryStateSym;
  }

  [(_f = SummaryStateSym, tsplus_module_1.Hash.sym)]() {
    return tsplus_module_1.combine(tsplus_module_1.hashString("@effect/core/io/Metrics/MetricState/Summary"), tsplus_module_1.combine(tsplus_module_1.hashNumber(this.error), tsplus_module_1.combine(tsplus_module_1.hashUnknown(this.quantiles), tsplus_module_1.combine(tsplus_module_1.hashNumber(this.count), tsplus_module_1.combine(tsplus_module_1.hashNumber(this.min), tsplus_module_1.combine(tsplus_module_1.hashNumber(this.max), tsplus_module_1.hashNumber(this.sum)))))));
  }

  [tsplus_module_2.Equals.sym](u) {
    return isSummaryState_1(u) && this.error === u.error && tsplus_module_4.equals_(this.quantiles, u.quantiles) && this.count === u.count && this.min === u.min && this.max === u.max && this.sum === u.sum;
  }

}
/**
 * @tsplus static ets/Metrics/MetricState/Ops Counter
 */


exports.SummaryState = SummaryState;

function counter(count) {
  return new CounterState(count);
}
/**
 * @tsplus static ets/Metrics/MetricState/Ops Gauge
 */


function gauge(value) {
  return new GaugeState(value);
}
/**
 * @tsplus static ets/Metrics/MetricState/Ops Frequency
 */


function frequency(occurrences) {
  return new FrequencyState(occurrences);
}
/**
 * @tsplus static ets/Metrics/MetricState/Ops Histogram
 */


function histogram(buckets, count, min, max, sum) {
  return new HistogramState(buckets, count, min, max, sum);
}
/**
 * @tsplus static ets/Metrics/MetricState/Ops Summary
 */


function summary(error, quantiles, count, min, max, sum) {
  return new SummaryState(error, quantiles, count, min, max, sum);
}
/**
 * @tsplus static ets/Metrics/MetricState/Ops isCounterState
 */


function isCounterState_1(u) {
  return typeof u === "object" && u != null && CounterStateSym in u;
}
/**
 * @tsplus static ets/Metrics/MetricState/Ops isGaugeState
 */


function isGaugeState_1(u) {
  return typeof u === "object" && u != null && GaugeStateSym in u;
}
/**
 * @tsplus static ets/Metrics/MetricState/Ops isFrequencyState
 */


function isFrequencyState_1(u) {
  return typeof u === "object" && u != null && FrequencyStateSym in u;
}
/**
 * @tsplus static ets/Metrics/MetricState/Ops isHistogramState
 */


function isHistogramState_1(u) {
  return typeof u === "object" && u != null && HistogramStateSym in u;
}
/**
 * @tsplus static ets/Metrics/MetricState/Ops isSummaryState
 */


function isSummaryState_1(u) {
  return typeof u === "object" && u != null && SummaryStateSym in u;
}
//# sourceMappingURL=MetricState.js.map