"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.WixPatternsRouterState = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _mobx = require("mobx");
var _getCollectionComponentUniqueId = require("../utils/getCollectionComponentUniqueId");
class WixPatternsRouterState {
  constructor(params) {
    (0, _defineProperty2.default)(this, "stateRefs", new Map());
    (0, _defineProperty2.default)(this, "container", void 0);
    (0, _defineProperty2.default)(this, "_navigate", void 0);
    (0, _defineProperty2.default)(this, "currentState", null);
    (0, _defineProperty2.default)(this, "isUsingCache", false);
    (0, _defineProperty2.default)(this, "isCollectionStale", false);
    this.container = params.container;
    this._navigate = params.navigate;
    (0, _mobx.makeObservable)(this, {
      currentState: _mobx.observable.ref,
      setCurrentState: _mobx.action,
      isCollectionStale: _mobx.observable
    });
  }
  setCurrentState(state) {
    this.currentState = state;
  }
  saveState(state) {
    const uniqueId = (0, _getCollectionComponentUniqueId.getCollectionComponentUniqueId)(state);
    this.stateRefs.set(uniqueId, state);
  }
  navigate(to, options) {
    var _this$_navigate;
    this.setCurrentState(options.state);
    (_this$_navigate = this._navigate) == null || _this$_navigate.call(this, to, options);
  }
}
exports.WixPatternsRouterState = WixPatternsRouterState;
//# sourceMappingURL=WixPatternsRouterState.js.map