"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.DEFAULT_DARK_CLOUD_COVER_CONFIG = void 0;
exports.darkcloudcover = darkcloudcover;
exports.default = void 0;
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 DarkCloudCover pattern.
 * Only requires scale parameter since this pattern uses direct price comparisons.
 */

/**
 * Default configuration for DarkCloudCover pattern.
 */
const DEFAULT_DARK_CLOUD_COVER_CONFIG = exports.DEFAULT_DARK_CLOUD_COVER_CONFIG = {
  ..._CandlestickFinder.DEFAULT_CANDLESTICK_CONFIG
};
class DarkCloudCover extends _CandlestickFinder.default {
  constructor(config) {
    const finalConfig = {
      ...DEFAULT_DARK_CLOUD_COVER_CONFIG,
      ...config
    };
    super(finalConfig);
    this.name = 'DarkCloudCover';
    this.requiredCount = 2;
  }
  logic(data) {
    // Previous day (older) - index 0
    let prevOpen = data.open[0];
    let prevClose = data.close[0];
    let prevHigh = data.high[0];
    let prevLow = data.low[0];

    // Current day (most recent) - index 1
    let currOpen = data.open[1];
    let currClose = data.close[1];
    let currHigh = data.high[1];
    let currLow = data.low[1];

    // Validate OHLC data integrity for both days
    if (!this.validateOHLC(prevOpen, prevHigh, prevLow, prevClose) || !this.validateOHLC(currOpen, currHigh, currLow, currClose)) {
      return false;
    }

    // Previous day should be bullish (green candle)
    let prevIsBullish = prevClose > prevOpen;

    // Current day should be bearish (red candle)
    let currIsBearish = currClose < currOpen;

    // Calculate the midpoint of previous day's body (no scale dependency)
    let prevMidpoint = (prevClose + prevOpen) / 2;

    // Dark cloud cover conditions (all use direct price comparisons):
    // 1. Current opens above previous day's high (gap up)
    // 2. Current close is below the midpoint of previous day's body
    // 3. Current close is still above previous day's open (not full engulfment)
    let isDarkCloudPattern = currOpen > prevHigh && currClose < prevMidpoint && currClose > prevOpen;
    return prevIsBullish && currIsBearish && isDarkCloudPattern;
  }
}
exports.default = DarkCloudCover;
function darkcloudcover(data, config = DEFAULT_DARK_CLOUD_COVER_CONFIG) {
  return new DarkCloudCover(config).hasPattern(data);
}
//# sourceMappingURL=DarkCloudCover.js.map