"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.DEFAULT_BEARISH_INVERTED_HAMMER_CONFIG = void 0;
exports.bearishinvertedhammerstick = bearishinvertedhammerstick;
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 BearishInvertedHammerStick pattern.
 * Includes thresholds for shadow size analysis.
 */

/**
 * Default configuration for BearishInvertedHammerStick pattern.
 */
const DEFAULT_BEARISH_INVERTED_HAMMER_CONFIG = exports.DEFAULT_BEARISH_INVERTED_HAMMER_CONFIG = {
  ..._CandlestickFinder.DEFAULT_CANDLESTICK_CONFIG,
  shadowSizeThresholdPercent: 0.001
};
class BearishInvertedHammerStick extends _CandlestickFinder.default {
  shadowSizeThresholdPercent;
  constructor(config) {
    const finalConfig = {
      ...DEFAULT_BEARISH_INVERTED_HAMMER_CONFIG,
      ...config
    };
    super(finalConfig);
    this.name = 'BearishInvertedHammerStick';
    this.requiredCount = 1;

    // Apply configuration with defaults
    this.shadowSizeThresholdPercent = finalConfig.shadowSizeThresholdPercent;
  }
  logic(data) {
    let daysOpen = data.open[0];
    let daysClose = data.close[0];
    let daysHigh = data.high[0];
    let daysLow = data.low[0];

    // Basic OHLC validation
    if (!this.validateOHLC(daysOpen, daysHigh, daysLow, daysClose)) {
      return false;
    }

    // Must be a bearish candle (red candle)
    let isBearishInvertedHammer = daysOpen > daysClose;

    // The close should be approximately equal to the low (small lower shadow)
    // Note: approximateEqual uses scale for price comparison precision
    isBearishInvertedHammer = isBearishInvertedHammer && this.approximateEqual(daysClose, daysLow);

    // The upper shadow should be at least twice the body size
    let bodySize = daysOpen - daysClose;
    let upperShadow = daysHigh - daysOpen;
    isBearishInvertedHammer = isBearishInvertedHammer && upperShadow >= bodySize * 2;

    // Ensure there's a significant upper shadow using direct threshold calculation
    let range = daysHigh - daysLow;
    let minShadowSize = range * this.shadowSizeThresholdPercent;
    isBearishInvertedHammer = isBearishInvertedHammer && upperShadow >= minShadowSize;
    return isBearishInvertedHammer;
  }
}
exports.default = BearishInvertedHammerStick;
function bearishinvertedhammerstick(data, config = DEFAULT_BEARISH_INVERTED_HAMMER_CONFIG) {
  return new BearishInvertedHammerStick(config).hasPattern(data);
}
//# sourceMappingURL=BearishInvertedHammerStick.js.map