const fileName_1 = "(@effect/core) _src/io/Metrics/operations/trackDefectWith.ts";
import * as tsplus_module_1 from "@tsplus/stdlib/collections/HashSet/empty";
import * as tsplus_module_2 from "@effect/core/io/Cause/operations/defects";
import * as tsplus_module_3 from "@tsplus/stdlib/collections/List/forEach";
import * as tsplus_module_4 from "@effect/core/io/Effect/operations/succeed";
import * as tsplus_module_5 from "@effect/core/io/Effect/operations/tapDefect";
/**
 * Returns an aspect that will update this metric with the result of applying
 * the specified function to the defect throwables of the effects that the
 * aspect is applied to.
 *
 * @tsplus fluent ets/Metrics/Metric trackDefectWith
 */

export function trackDefectWith_(self, f) {
  const updater = defect => self.unsafeUpdate(f(defect), tsplus_module_1.empty());

  return (effect, __tsplusTrace) => tsplus_module_5.tapDefect_(effect, cause => tsplus_module_4.succeed(() => tsplus_module_3.forEach_(tsplus_module_2.defects(cause), updater), fileName_1 + ":11:47"), fileName_1 + ":11:21");
}
/**
 * Returns an aspect that will update this metric with the result of applying
 * the specified function to the defect throwables of the effects that the
 * aspect is applied to.
 *
 * @tsplus static ets/Metrics/Metric/Aspects trackDefectWith
 */

export const trackDefectWith = f => self => trackDefectWith_(self, f);
//# sourceMappingURL=trackDefectWith.mjs.map