text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.createUseAuth = void 0;
  var react_1 = require("react");
  exports.createUseAuth = function (_a) {
      var getSessionState = _a.getSessionState, onHydratation = _a.onHydratation, listenersContainer = _a.listenersContainer;
      return function () {
          var _a = react_1.useState(null), session = _a[0], setSession = _a[1];
          var updateIsLoggedIn = function () {
              var actualSession = getSessionState();
              if (onHydratation) {
                  onHydratation(actualSession);
              }
              setSession(actualSession);
          };
          react_1.useEffect(function () {
              updateIsLoggedIn();
          }, []);
          var listener = react_1.useCallback(function () {
              updateIsLoggedIn();
          }, []);
          react_1.useEffect(function () {
              listenersContainer.subscribe(listener);
              return function () {
                  listenersContainer.unsubscribe(listener);
              };
          }, [listener]);
          return [isLoggedIn(session), session];
      };
  };
  var isLoggedIn = function (session) { return !!session; };
  