text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.useSyncState = useSyncState;
  
  var _document = _interopRequireDefault(require("part:@sanity/base/datastore/document"));
  
  var _useObservable = require("./utils/use-observable");
  
  var _operators = require("rxjs/operators");
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  var SYNCING = {
    isSyncing: true
  };
  var NOT_SYNCING = {
    isSyncing: false
  };
  
  function useSyncState(publishedId, typeName) {
    return (0, _useObservable.useObservable)((0, _useObservable.toObservable)(publishedId, props$ => props$.pipe((0, _operators.distinctUntilChanged)(), (0, _operators.switchMap)(publishedId => {
      return _document.default.pair.consistencyStatus(publishedId).pipe((0, _operators.map)(isConsistent => isConsistent ? NOT_SYNCING : SYNCING));
    }))), NOT_SYNCING);
  }