"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _foundation = _interopRequireDefault(require("../base/foundation"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
var lottie = undefined;
if (typeof document !== "undefined") {
  lottie = require("lottie-web");
  if (lottie && lottie.__esModule) lottie = lottie.default;
}
class LottieFoundation extends _foundation.default {
  constructor(adapter) {
    super(Object.assign(Object.assign({}, LottieFoundation.defaultAdapter), adapter));
    this.animation = null;
    this.handleParamsUpdate = () => {
      var _a;
      if (!this.animation) return;
      this.animation.destroy();
      this.animation = lottie.loadAnimation(this._adapter.getLoadParams());
      (_a = this.getProp("getAnimationInstance")) === null || _a === void 0 ? void 0 : _a(this.animation);
    };
  }
  init(lifecycle) {
    var _a, _b;
    super.init(lifecycle);
    if (!lottie) return;
    this.animation = lottie.loadAnimation(this._adapter.getLoadParams());
    (_a = this.getProp("getAnimationInstance")) === null || _a === void 0 ? void 0 : _a(this.animation);
    (_b = this.getProp("getLottie")) === null || _b === void 0 ? void 0 : _b(LottieFoundation.getLottie());
  }
  destroy() {
    super.destroy();
    if (!this.animation) return;
    this.animation.destroy();
  }
}
LottieFoundation.getLottie = () => {
  return lottie;
};
var _default = exports.default = LottieFoundation;