function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import React from 'react';
import { ActivityIndicator, SafeAreaView } from 'react-native';
import { EventRegister } from 'react-native-event-listeners';
import WebView from 'react-native-webview';
const MainWebView = props => {
  const {
    url,
    source,
    loading,
    isError,
    webviewRef,
    handleMessage,
    runBeforeFirst,
    platform,
    setCanGoBack
  } = props; // Get the URL and other parameters from the route

  return /*#__PURE__*/React.createElement(SafeAreaView, {
    style: {
      flex: 1
    }
  }, (isError || loading) && /*#__PURE__*/React.createElement(LoadingIndicator, null), source && !isError && !loading ? /*#__PURE__*/React.createElement(WebView, _extends({
    ref: webviewRef,
    source: {
      uri: source,
      headers: {
        platform: platform
      }
    },
    onMessage: handleMessage
  }, runBeforeFirst && {
    injectedJavaScriptBeforeContentLoaded: runBeforeFirst
  }, {
    javaScriptEnabled: true,
    onLoadProgress: event => setCanGoBack(event.nativeEvent.canGoBack),
    onError: errorMessage => {
      EventRegister.emitEvent('mytatva-event', {
        message: 'web-view-error',
        errorMessage: errorMessage
      });
    }
  })) : null);
};
export default MainWebView;
const LoadingIndicator = () => {
  return /*#__PURE__*/React.createElement(ActivityIndicator, {
    color: "#000",
    size: "large"
    // eslint-disable-next-line react-native/no-inline-styles
    ,
    style: {
      flex: 1,
      zIndex: 100,
      position: 'absolute',
      backgroundColor: '#fff',
      opacity: 0.4,
      width: '100%',
      height: '100%',
      justifyContent: 'center',
      alignItems: 'center'
    }
  });
};
//# sourceMappingURL=MainWebView.js.map