"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.PageState = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _bexUtils = require("@wix/bex-utils");
var _mobx = require("mobx");
var _mobileDetection = require("../util/mobileDetection");
// CAIRO-3582: modify mobile detection to use user agent
// export const MOBILE_BREAKPOINT = 768;
class PageState {
  constructor() {
    (0, _defineProperty2.default)(this, "modalsContainerRef", void 0);
    (0, _defineProperty2.default)(this, "stackingRootRef", void 0);
    (0, _defineProperty2.default)(this, "scrollableContentRef", void 0);
    (0, _defineProperty2.default)(this, "_sidePanelOpen", (0, _bexUtils.reactive)(false));
    (0, _defineProperty2.default)(this, "_isMobile", false);
    this.modalsContainerRef = (0, _mobx.makeObservable)({
      current: null
    }, {
      current: _mobx.observable.ref
    });
    this.stackingRootRef = {
      current: null
    };
    this.scrollableContentRef = {
      current: null
    };
    (0, _mobx.makeObservable)(this, {
      _isMobile: _mobx.observable.ref
      // CAIRO-3582: modify mobile detection to use user agent
      // _updateIsMobile: action.bound,
    });
    this._isMobile = (0, _mobileDetection.isMobileDevice)();
  }

  // CAIRO-3582: modify mobile detection to use user agent
  // _updateIsMobile() {
  //   if (typeof window !== 'undefined') {
  //     this._isMobile = window.innerWidth <= MOBILE_BREAKPOINT;
  //   }
  // }

  get isMobile() {
    return this._isMobile;
  }
  set sidePanelOpen(value) {
    this._sidePanelOpen.value = value;
  }

  // CAIRO-3582: modify mobile detection to use user agent
  // init() {
  //   if (typeof window === 'undefined') {
  //     return;
  //   }
  //   this._updateIsMobile();
  //   const container = this.stackingRootRef.current ?? document.body;
  //   const disposers = [addResizeObserver(container, this._updateIsMobile)];
  //   return () => {
  //     disposers.forEach((d) => d?.());
  //   };
  // }
}
exports.PageState = PageState;
//# sourceMappingURL=PageState.js.map