"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.DEFAULT_BULLISH_INVERTED_HAMMER_STICK_CONFIG = void 0;
exports.bullishinvertedhammerstick = bullishinvertedhammerstick;
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 BullishInvertedHammerStick pattern.
 * Extends base config with hammer-specific threshold properties.
 */

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

    // Apply configuration with defaults
    this.shadowSizeThresholdPercent = finalConfig.shadowSizeThresholdPercent;
    this.minBodyComparisonPercent = finalConfig.minBodyComparisonPercent;
  }
  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 using the base class method
    if (!this.validateOHLC(daysOpen, daysHigh, daysLow, daysClose)) {
      return false;
    }

    // Must be a bullish candle (green candle)
    let isBullishInvertedHammer = daysClose > daysOpen;

    // Calculate sizes
    let bodySize = daysClose - daysOpen;
    let lowerShadow = daysOpen - daysLow;
    let upperShadow = daysHigh - daysClose;
    let totalRange = daysHigh - daysLow;

    // Ensure we have a meaningful range to work with
    if (totalRange <= 0) {
      return false;
    }

    // The lower shadow should be very small (low should be approximately equal to open)
    // For inverted hammer, we want minimal lower shadow
    isBullishInvertedHammer = isBullishInvertedHammer && (this.approximateEqual(daysOpen, daysLow) || lowerShadow <= bodySize * 0.1);

    // Handle very small bodies (doji-like inverted hammers)
    // Use direct threshold calculation instead of utility function
    let minBodyForComparison = Math.max(bodySize, totalRange * this.minBodyComparisonPercent);

    // The upper shadow should be at least twice the effective body size
    isBullishInvertedHammer = isBullishInvertedHammer && upperShadow >= 2 * minBodyForComparison;

    // Ensure there's a significant upper shadow relative to the total range
    // Use direct threshold calculations instead of utility functions
    let minShadowSize = Math.max(totalRange * this.shadowSizeThresholdPercent * 300,
    // Replaces: getShadowSizeThreshold(totalRange) * 300
    minBodyForComparison * 2 // At least twice the effective body size
    );
    isBullishInvertedHammer = isBullishInvertedHammer && upperShadow >= minShadowSize;
    return isBullishInvertedHammer;
  }
}
exports.default = BullishInvertedHammerStick;
function bullishinvertedhammerstick(data, config = DEFAULT_BULLISH_INVERTED_HAMMER_STICK_CONFIG) {
  return new BullishInvertedHammerStick(config).hasPattern(data);
}
//# sourceMappingURL=BullishInvertedHammerStick.js.map