(function (global, factory) {
  if (typeof define === "function" && define.amd) {
    define(["exports", "lodash/pick", "lodash/isNil", "rxjs", "rxjs/operators", "./recall", "./precision"], factory);
  } else if (typeof exports !== "undefined") {
    factory(exports, require("lodash/pick"), require("lodash/isNil"), require("rxjs"), require("rxjs/operators"), require("./recall"), require("./precision"));
  } else {
    var mod = {
      exports: {}
    };
    factory(mod.exports, global.pick, global.isNil, global.rxjs, global.operators, global.recall, global.precision);
    global.f1 = mod.exports;
  }
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _pick, _isNil, _rxjs, _operators, _recall, _precision) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _pick = _interopRequireDefault(_pick);
  _isNil = _interopRequireDefault(_isNil);
  _recall = _interopRequireDefault(_recall);
  _precision = _interopRequireDefault(_precision);

  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

  function computeF1(recallScore, precisionScore) {
    const f1 = 2 * (recallScore * precisionScore) / (recallScore + precisionScore);
    return f1;
  }

  const f1 = function f1(initialState = {
    truePositives: 0,
    falseNegatives: 0,
    falsePositives: 0
  }) {
    return source$ => {
      const sub$ = source$.pipe((0, _operators.share)());
      const recall$ = sub$.pipe((0, _recall.default)((0, _pick.default)(initialState, 'truePositives', 'falseNegatives')));
      const precision$ = sub$.pipe((0, _precision.default)((0, _pick.default)(initialState, 'truePositives', 'falsePositives')));
      const f1$ = (0, _rxjs.zip)(recall$, precision$).pipe((0, _operators.map)(([recallVal, precisionVal]) => computeF1(recallVal, precisionVal)), (0, _operators.filter)(score => !(0, _isNil.default)(score)));
      return f1$;
    };
  };

  var _default = f1;
  _exports.default = _default;
});
//# sourceMappingURL=f1.js.map