function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var HolisticPoseValidator = /*#__PURE__*/function () {
  function HolisticPoseValidator() {
    _defineProperty(this, "_limit", 0.9);

    _defineProperty(this, "_legsLimit", 0.9);

    _defineProperty(this, "POSE_LANDMARKS", {
      NOSE: 0,
      LEFT_EYE_INNER: 1,
      LEFT_EYE: 2,
      LEFT_EYE_OUTER: 3,
      RIGHT_EYE_INNER: 4,
      RIGHT_EYE: 5,
      RIGHT_EYE_OUTER: 6,
      LEFT_EAR: 7,
      RIGHT_EAR: 8,
      LEFT_RIGHT: 9,
      RIGHT_LEFT: 10,
      LEFT_SHOULDER: 11,
      RIGHT_SHOULDER: 12,
      LEFT_ELBOW: 13,
      RIGHT_ELBOW: 14,
      LEFT_WRIST: 15,
      RIGHT_WRIST: 16,
      LEFT_PINKY: 17,
      RIGHT_PINKY: 18,
      LEFT_INDEX: 19,
      RIGHT_INDEX: 20,
      LEFT_THUMB: 21,
      RIGHT_THUMB: 22,
      LEFT_HIP: 23,
      RIGHT_HIP: 24,
      LEFT_KNEE: 25,
      RIGHT_KNEE: 26,
      LEFT_ANKLE: 27,
      RIGHT_ANKLE: 28,
      LEFT_HEEL: 29,
      RIGHT_HEEL: 30,
      LEFT_FOOT_INDEX: 31,
      RIGHT_FOOT_INDEX: 32
    });
  }

  var _proto = HolisticPoseValidator.prototype;

  _proto.getPartsValue = function getPartsValue(result, key) {
    var _result$poseLandmarks,
        _result$poseLandmarks2,
        _result$poseLandmarks3,
        _result$poseLandmarks4,
        _result$poseLandmarks5,
        _result$poseLandmarks6,
        _result$poseLandmarks7,
        _result$poseLandmarks8,
        _result$poseLandmarks9,
        _result$poseLandmarks10,
        _result$poseLandmarks11,
        _result$poseLandmarks12,
        _this = this;

    var rightElbow = (_result$poseLandmarks = result.poseLandmarks[this.POSE_LANDMARKS.RIGHT_ELBOW]) === null || _result$poseLandmarks === void 0 ? void 0 : _result$poseLandmarks.visibility,
        leftElbow = (_result$poseLandmarks2 = result.poseLandmarks[this.POSE_LANDMARKS.LEFT_ELBOW]) === null || _result$poseLandmarks2 === void 0 ? void 0 : _result$poseLandmarks2.visibility,
        rightShoulder = (_result$poseLandmarks3 = result.poseLandmarks[this.POSE_LANDMARKS.RIGHT_SHOULDER]) === null || _result$poseLandmarks3 === void 0 ? void 0 : _result$poseLandmarks3.visibility,
        leftSHoulder = (_result$poseLandmarks4 = result.poseLandmarks[this.POSE_LANDMARKS.LEFT_SHOULDER]) === null || _result$poseLandmarks4 === void 0 ? void 0 : _result$poseLandmarks4.visibility,
        rightHip = (_result$poseLandmarks5 = result.poseLandmarks[this.POSE_LANDMARKS.RIGHT_HIP]) === null || _result$poseLandmarks5 === void 0 ? void 0 : _result$poseLandmarks5.visibility,
        leftHip = (_result$poseLandmarks6 = result.poseLandmarks[this.POSE_LANDMARKS.LEFT_HIP]) === null || _result$poseLandmarks6 === void 0 ? void 0 : _result$poseLandmarks6.visibility,
        rightWrist = (_result$poseLandmarks7 = result.poseLandmarks[this.POSE_LANDMARKS.RIGHT_WRIST]) === null || _result$poseLandmarks7 === void 0 ? void 0 : _result$poseLandmarks7.visibility,
        leftWrist = (_result$poseLandmarks8 = result.poseLandmarks[this.POSE_LANDMARKS.LEFT_WRIST]) === null || _result$poseLandmarks8 === void 0 ? void 0 : _result$poseLandmarks8.visibility,
        rightKnee = (_result$poseLandmarks9 = result.poseLandmarks[this.POSE_LANDMARKS.RIGHT_KNEE]) === null || _result$poseLandmarks9 === void 0 ? void 0 : _result$poseLandmarks9.visibility,
        leftKnee = (_result$poseLandmarks10 = result.poseLandmarks[this.POSE_LANDMARKS.LEFT_KNEE]) === null || _result$poseLandmarks10 === void 0 ? void 0 : _result$poseLandmarks10.visibility,
        rightAnkle = (_result$poseLandmarks11 = result.poseLandmarks[this.POSE_LANDMARKS.RIGHT_ANKLE]) === null || _result$poseLandmarks11 === void 0 ? void 0 : _result$poseLandmarks11.visibility,
        leftAnkle = (_result$poseLandmarks12 = result.poseLandmarks[this.POSE_LANDMARKS.LEFT_ANKLE]) === null || _result$poseLandmarks12 === void 0 ? void 0 : _result$poseLandmarks12.visibility;
    var returnObject = {
      part1: false,
      part2: false,
      part3: false
    };

    var rShoulder = function rShoulder() {
      if (rightElbow > _this._limit) returnObject.part1 = true;
      if (rightShoulder > _this._limit) returnObject.part2 = true;
      if (rightHip > _this._limit) returnObject.part3 = true;
      return returnObject;
    };

    var lShoulder = function lShoulder() {
      if (leftElbow > _this._limit) returnObject.part1 = true;
      if (leftSHoulder > _this._limit) returnObject.part2 = true;
      if (leftHip > _this._limit) returnObject.part3 = true;
      return returnObject;
    };

    var rElbow = function rElbow() {
      if (rightShoulder > _this._limit) returnObject.part1 = true;
      if (rightElbow > _this._limit) returnObject.part2 = true;
      if (rightWrist > _this._limit) returnObject.part3 = true;
      return returnObject;
    };

    var lElbow = function lElbow() {
      if (leftSHoulder > _this._limit) returnObject.part1 = true;
      if (leftElbow > _this._limit) returnObject.part2 = true;
      if (leftWrist > _this._limit) returnObject.part3 = true;
      return returnObject;
    };

    var rHip = function rHip() {
      if (rightKnee > _this._limit) returnObject.part1 = true;
      if (rightHip > _this._limit) returnObject.part2 = true;
      if (rightShoulder > _this._limit) returnObject.part3 = true;
      return returnObject;
    };

    var lHip = function lHip() {
      if (leftKnee > _this._limit) returnObject.part1 = true;
      if (leftHip > _this._limit) returnObject.part2 = true;
      if (leftSHoulder > _this._limit) returnObject.part3 = true;
      return returnObject;
    };

    var rKnee = function rKnee() {
      if (rightAnkle > _this._limit) returnObject.part1 = true;
      if (rightKnee > _this._limit) returnObject.part2 = true;
      if (rightHip > _this._limit) returnObject.part3 = true;
      return returnObject;
    };

    var lKnee = function lKnee() {
      if (leftAnkle > _this._limit) returnObject.part1 = true;
      if (leftKnee > _this._limit) returnObject.part2 = true;
      if (leftHip > _this._limit) returnObject.part3 = true;
      return returnObject;
    };

    var rSide = function rSide() {
      if (rightAnkle > _this._limit) returnObject.part1 = true;
      if (rightHip > _this._limit) returnObject.part2 = true;
      if (rightShoulder > _this._limit) returnObject.part3 = true;
      return returnObject;
    };

    var lSide = function lSide() {
      if (leftAnkle > _this._limit) returnObject.part1 = true;
      if (leftHip > _this._limit) returnObject.part2 = true;
      if (leftSHoulder > _this._limit) returnObject.part3 = true;
      return returnObject;
    };

    var legs = function legs() {
      if (rightAnkle && rightAnkle > _this._legsLimit && rightKnee && rightKnee > _this._legsLimit && rightHip && rightHip > _this._legsLimit) {
        returnObject.part1 = true;
        returnObject.part2 = true;
        returnObject.part3 = true;
        return returnObject;
      }

      if (leftAnkle && leftAnkle > _this._legsLimit && leftKnee > _this._legsLimit && leftKnee && leftHip && leftHip > _this._legsLimit) {
        returnObject.part1 = true;
        returnObject.part2 = true;
        returnObject.part3 = true;
        return returnObject;
      }

      return returnObject;
    };

    var points = {
      rShoulder: rShoulder,
      lShoulder: lShoulder,
      rElbow: rElbow,
      lElbow: lElbow,
      rHip: rHip,
      lHip: lHip,
      rKnee: rKnee,
      lKnee: lKnee,
      rSide: rSide,
      lSide: lSide,
      legs: legs
    };
    return points[key]();
  };

  _proto.getSideValue = function getSideValue(result, key) {
    var _result$poseLandmarks13, _result$poseLandmarks14, _result$poseLandmarks15, _result$poseLandmarks16, _result$poseLandmarks17, _result$poseLandmarks18, _result$poseLandmarks19, _result$poseLandmarks20, _result$poseLandmarks21, _result$poseLandmarks22, _result$poseLandmarks23, _result$poseLandmarks24;

    var rightElbow = (_result$poseLandmarks13 = result.poseLandmarks[this.POSE_LANDMARKS.RIGHT_ELBOW]) === null || _result$poseLandmarks13 === void 0 ? void 0 : _result$poseLandmarks13.visibility,
        leftElbow = (_result$poseLandmarks14 = result.poseLandmarks[this.POSE_LANDMARKS.LEFT_ELBOW]) === null || _result$poseLandmarks14 === void 0 ? void 0 : _result$poseLandmarks14.visibility,
        rightShoulder = (_result$poseLandmarks15 = result.poseLandmarks[this.POSE_LANDMARKS.RIGHT_SHOULDER]) === null || _result$poseLandmarks15 === void 0 ? void 0 : _result$poseLandmarks15.visibility,
        leftSHoulder = (_result$poseLandmarks16 = result.poseLandmarks[this.POSE_LANDMARKS.LEFT_SHOULDER]) === null || _result$poseLandmarks16 === void 0 ? void 0 : _result$poseLandmarks16.visibility,
        rightHip = (_result$poseLandmarks17 = result.poseLandmarks[this.POSE_LANDMARKS.RIGHT_HIP]) === null || _result$poseLandmarks17 === void 0 ? void 0 : _result$poseLandmarks17.visibility,
        leftHip = (_result$poseLandmarks18 = result.poseLandmarks[this.POSE_LANDMARKS.LEFT_HIP]) === null || _result$poseLandmarks18 === void 0 ? void 0 : _result$poseLandmarks18.visibility,
        rightWrist = (_result$poseLandmarks19 = result.poseLandmarks[this.POSE_LANDMARKS.RIGHT_WRIST]) === null || _result$poseLandmarks19 === void 0 ? void 0 : _result$poseLandmarks19.visibility,
        leftWrist = (_result$poseLandmarks20 = result.poseLandmarks[this.POSE_LANDMARKS.LEFT_WRIST]) === null || _result$poseLandmarks20 === void 0 ? void 0 : _result$poseLandmarks20.visibility,
        rightKnee = (_result$poseLandmarks21 = result.poseLandmarks[this.POSE_LANDMARKS.RIGHT_KNEE]) === null || _result$poseLandmarks21 === void 0 ? void 0 : _result$poseLandmarks21.visibility,
        leftKnee = (_result$poseLandmarks22 = result.poseLandmarks[this.POSE_LANDMARKS.LEFT_KNEE]) === null || _result$poseLandmarks22 === void 0 ? void 0 : _result$poseLandmarks22.visibility,
        rightAnkle = (_result$poseLandmarks23 = result.poseLandmarks[this.POSE_LANDMARKS.RIGHT_ANKLE]) === null || _result$poseLandmarks23 === void 0 ? void 0 : _result$poseLandmarks23.visibility,
        leftAnkle = (_result$poseLandmarks24 = result.poseLandmarks[this.POSE_LANDMARKS.LEFT_ANKLE]) === null || _result$poseLandmarks24 === void 0 ? void 0 : _result$poseLandmarks24.visibility;

    var rShoulder = function rShoulder() {
      if (rightElbow < leftElbow && rightShoulder < leftSHoulder && rightHip < leftHip) {
        return true;
      }
    };

    var lShoulder = function lShoulder() {
      if (rightElbow > leftElbow && rightShoulder > leftSHoulder && rightHip > leftHip) {
        return true;
      }
    };

    var rElbow = function rElbow() {
      if (rightShoulder < leftSHoulder && rightElbow < leftElbow && rightWrist < leftWrist) {
        return true;
      }
    };

    var lElbow = function lElbow() {
      if (rightShoulder > leftSHoulder && rightElbow > leftElbow && rightWrist > leftWrist) {
        return true;
      }
    };

    var rHip = function rHip() {
      if (rightKnee < leftKnee && rightHip < leftHip && rightShoulder < leftSHoulder) {
        return true;
      }
    };

    var lHip = function lHip() {
      if (rightKnee > leftKnee && rightHip > leftHip && rightShoulder > leftSHoulder) {
        return true;
      }
    };

    var rKnee = function rKnee() {
      if (rightAnkle < leftAnkle && rightKnee < leftKnee && rightHip < leftHip) {
        return true;
      }
    };

    var lKnee = function lKnee() {
      if (rightAnkle > leftAnkle && rightKnee > leftKnee && rightHip > leftHip) {
        return true;
      }
    };

    var rSide = function rSide() {
      if (rightAnkle < leftAnkle && rightHip < leftHip && rightShoulder < leftSHoulder) {
        return true;
      }
    };

    var lSide = function lSide() {
      if (rightAnkle > leftAnkle && rightHip > leftHip && rightShoulder > leftSHoulder) {
        return true;
      }
    };

    var legs = function legs() {
      return false;
    };

    var points = {
      rShoulder: rShoulder,
      lShoulder: lShoulder,
      rElbow: rElbow,
      lElbow: lElbow,
      rHip: rHip,
      lHip: lHip,
      rKnee: rKnee,
      lKnee: lKnee,
      rSide: rSide,
      lSide: lSide,
      legs: legs
    };
    return points[key]();
  };

  _proto.visiblePoints = function visiblePoints(key, result) {
    try {
      var parts = this.getPartsValue(result, key);
      var incorrectSide = this.getSideValue(result, key);
      return {
        parts: parts,
        incorrectSide: incorrectSide
      };
    } catch (error) {
      throw new Error("error: " + error);
    }
  };

  return HolisticPoseValidator;
}();

export { HolisticPoseValidator as default };