"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.DEFAULT_THREE_BLACK_CROWS_CONFIG = void 0;
exports.threeblackcrows = threeblackcrows;
var _CandlestickFinder = _interopRequireWildcard(require("./CandlestickFinder"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/**
 * Configuration interface for ThreeBlackCrows pattern.
 * Only uses the scale parameter for approximateEqual function precision.
 */

/**
 * Default configuration for ThreeBlackCrows pattern.
 */
const DEFAULT_THREE_BLACK_CROWS_CONFIG = exports.DEFAULT_THREE_BLACK_CROWS_CONFIG = {
  ..._CandlestickFinder.DEFAULT_CANDLESTICK_CONFIG
};
class ThreeBlackCrows extends _CandlestickFinder.default {
  constructor(config) {
    const finalConfig = {
      ...DEFAULT_THREE_BLACK_CROWS_CONFIG,
      ...config
    };
    super(finalConfig);
    this.name = 'ThreeBlackCrows';
    this.requiredCount = 3;
  }
  logic(data) {
    // First day (oldest) - index 0
    let firstOpen = data.open[0];
    let firstClose = data.close[0];
    let firstHigh = data.high[0];
    let firstLow = data.low[0];

    // Second day (middle) - index 1
    let secondOpen = data.open[1];
    let secondClose = data.close[1];
    let secondHigh = data.high[1];
    let secondLow = data.low[1];

    // Third day (most recent) - index 2
    let thirdOpen = data.open[2];
    let thirdClose = data.close[2];
    let thirdHigh = data.high[2];
    let thirdLow = data.low[2];

    // All three days should be bearish (black/red candles) - direct price comparisons
    let isAllBearish = firstClose < firstOpen && secondClose < secondOpen && thirdClose < thirdOpen;

    // Progressive downtrend - each day should have lower lows (no scale dependency)
    let isDownTrend = secondLow < firstLow && thirdLow < secondLow;

    // Each subsequent day should open within the previous day's body
    // and close lower than the previous day's close (direct price comparisons)
    let doesOpenWithinPreviousBody = secondOpen < firstOpen && secondOpen > firstClose && thirdOpen < secondOpen && thirdOpen > secondClose;
    return isDownTrend && isAllBearish && doesOpenWithinPreviousBody;
  }
}
exports.default = ThreeBlackCrows;
function threeblackcrows(data, config = DEFAULT_THREE_BLACK_CROWS_CONFIG) {
  return new ThreeBlackCrows(config).hasPattern(data);
}
//# sourceMappingURL=ThreeBlackCrows.js.map