"use strict";

import { CommonActions, StackActions } from '@react-navigation/native';
class Navigator {
  constructor(data) {
    this.ref = data.ref;
    this.loadingRef = data.loadingRef;
    this.toastRef = data.toastRef;
  }
  push = params => {
    if (this.ref.current?.isReady()) {
      this.ref.current?.dispatch(StackActions.push('Stack', params));
    }
  };
  replace = params => {
    if (this.ref.current?.isReady()) {
      this.ref.current?.dispatch(StackActions.replace('Stack', params));
    }
  };
  reset = params => {
    if (this.ref.current?.isReady()) {
      this.ref.current?.dispatch(CommonActions.reset({
        index: 0,
        routes: [{
          name: 'Stack',
          key: `Stack_${new Date().getTime()}`,
          params
        }]
      }));
    }
  };
  pop = count => {
    if (this.ref.current?.isReady()) {
      this.ref.current?.dispatch(StackActions.pop(count ?? 1));
    }
  };
  present = params => {
    if (this.ref.current?.isReady()) {
      this.ref.current?.dispatch(StackActions.push('Dialog', params));
    }
  };
  showModal = params => {
    if (this.ref.current?.isReady()) {
      this.ref.current?.dispatch(StackActions.push('Modal', params));
    }
  };
  showBottomSheet = params => {
    if (this.ref.current?.isReady()) {
      this.ref.current?.dispatch(StackActions.push('Modal', {
        ...params,
        isBottomSheet: true
      }));
    }
  };
  popToTop = () => {
    if (this.ref.current?.isReady()) {
      this.ref.current?.dispatch(StackActions.popToTop());
    }
  };
  showLoading = params => {
    this.loadingRef.current?.showLoading(params ?? {});
  };
  hideLoading = () => {
    this.loadingRef.current?.hideLoading();
  };
  showToast = params => {
    this.toastRef.current?.showToast(params);
  };
  hideToast = () => {
    this.toastRef.current?.hideToast();
  };
}
export default Navigator;
//# sourceMappingURL=Navigator.js.map