"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Input = exports.AttachScreen = void 0;
var _react = _interopRequireWildcard(require("react"));
var _bottomSheet = _interopRequireWildcard(require("../../components/bottomSheet/bottom-sheet"));
var _ChatStore = _interopRequireDefault(require("./ChatStore"));
var _cameraRollPicker = _interopRequireDefault(require("../../components/cameraRollPicker"));
var _mobxReactLite = require("mobx-react-lite");
var _utils = require("../../utils");
var _reactNative = require("react-native");
var _components = require("../../components");
var _reactNativePermissions = require("react-native-permissions");
var _Styles = _interopRequireDefault(require("../../Styles"));
var _AppStore = _interopRequireDefault(require("../AppStore"));
var _reactNativeMaps = _interopRequireWildcard(require("react-native-maps"));
var _documentPicker = _interopRequireWildcard(require("../../components/documentPicker"));
var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
var _reactNativeGeolocationService = _interopRequireDefault(require("react-native-geolocation-service"));
var _QuickMessageStore = _interopRequireDefault(require("./QuickMessageStore"));
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
var _InputStore = _interopRequireDefault(require("./InputStore"));
var _reactNativeModal = _interopRequireDefault(require("react-native-modal"));
var _mobx = require("mobx");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const QuickMessageModal = (0, _mobxReactLite.observer)(function QuickMessageModal(props) {
  const inputRef = (0, _react.useRef)(null);
  const [isFocus, setIsFocus] = (0, _react.useState)(false);
  const [isModalVisible, setModalVisible] = (0, _react.useState)(false);
  const updateQuickMessage = () => {
    if (!(_QuickMessageStore.default.currentMessage.text && _QuickMessageStore.default.currentMessage.text.trim() !== '')) {
      return;
    }
    if (_QuickMessageStore.default.currentMessage._id) {
      _QuickMessageStore.default.update({
        ..._QuickMessageStore.default.currentMessage,
        ...{
          text: _QuickMessageStore.default.currentMessage.text
        }
      }, () => {
        _QuickMessageStore.default.showModal = false;
        _QuickMessageStore.default.currentMessage = {};
      });
    } else {
      _QuickMessageStore.default.create({
        text: _QuickMessageStore.default.currentMessage.text,
        type: "MESSAGE"
      }, () => {
        _QuickMessageStore.default.showModal = false;
        _QuickMessageStore.default.currentMessage = {};
      });
    }
  };
  const deleteQuickMessage = () => {
    _QuickMessageStore.default.delete(_QuickMessageStore.default.currentMessage, () => {
      _QuickMessageStore.default.showModal = false;
      _QuickMessageStore.default.currentMessage = {};
    });
  };
  return /*#__PURE__*/_react.default.createElement(_reactNative.Modal, {
    visible: _QuickMessageStore.default.showModal,
    transparent: true,
    animationType: 'fade',
    onShow: () => {
      console.log(inputRef.current);
      inputRef.current.focus();
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.KeyboardAvoidingView, {
    style: {
      flex: 1
    },
    behavior: _reactNative.Platform.OS === 'ios' ? 'padding' : ''
  }, /*#__PURE__*/_react.default.createElement(_reactNative.SafeAreaView, {
    style: {
      flex: 1,
      backgroundColor: '#00000059',
      justifyContent: 'flex-end'
    }
  }, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: {
      height: 56,
      flexDirection: 'row',
      alignItems: 'center',
      backgroundColor: '#F8F8FA'
    }
  }, /*#__PURE__*/_react.default.createElement(_components.MText, {
    style: {
      position: 'absolute',
      width: '100%',
      textAlign: 'center',
      fontWeight: '600',
      fontSize: 17,
      color: '#44494D'
    }
  }, _QuickMessageStore.default.currentMessage._id ? 'Sửa' : 'Tạo', " tin chat nhanh"), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    onPress: () => {
      _QuickMessageStore.default.showModal = false;
    },
    style: {
      width: 56,
      height: 56,
      alignItems: 'center',
      justifyContent: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
    source: require('../../assets/ic_close.png'),
    style: {
      width: 24,
      height: 24,
      resizeMode: 'contain'
    },
    resizeMode: 'contain'
  })), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: {
      flex: 1
    }
  })), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: {
      backgroundColor: 'white'
    }
  }, /*#__PURE__*/_react.default.createElement(_components.MTextInput, {
    ref: inputRef,
    value: _QuickMessageStore.default.currentMessage.text,
    multiline: true
    // autoFocus={true}
    ,
    onFocus: () => setIsFocus(true),
    onBlur: () => setIsFocus(false),
    placeholder: 'Nhập nội dung tin nhắn',
    placeholderTextColor: '#B5B4B8'
    // numberOfLines={10}
    ,
    style: {
      textAlignVertical: 'top',
      fontWeight: '500',
      height: 132,
      margin: 16,
      lineHeight: 20,
      borderColor: isFocus ? '#B1C1D1' : '#DCE6F0',
      borderWidth: 1,
      borderRadius: 10,
      padding: 12
    },
    onChangeText: text => {
      _QuickMessageStore.default.currentMessage = {
        ..._QuickMessageStore.default.currentMessage,
        ...{
          text
        }
      };
    }
  }), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    onPress: updateQuickMessage,
    style: {
      margin: 16,
      marginBottom: 4,
      alignItems: 'center',
      justifyContent: 'center',
      padding: 16,
      backgroundColor: _Styles.default.primary,
      borderRadius: 10
    }
  }, /*#__PURE__*/_react.default.createElement(_components.MText, {
    style: {
      color: 'white',
      fontWeight: '600',
      fontSize: 15
    }
  }, _QuickMessageStore.default.currentMessage._id ? 'Lưu chỉnh sửa' : 'Lưu chat nhanh')), _QuickMessageStore.default.currentMessage._id && /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    onPress: () => setModalVisible(true),
    style: {
      margin: 16,
      marginTop: 0,
      alignItems: 'center',
      justifyContent: 'center',
      padding: 16,
      backgroundColor: 'white',
      borderRadius: 10
    }
  }, /*#__PURE__*/_react.default.createElement(_components.MText, {
    style: {
      color: _Styles.default.primary,
      fontWeight: '600',
      fontSize: 15
    }
  }, 'Xoá tin chat')))))), /*#__PURE__*/_react.default.createElement(_reactNative.Modal, {
    visible: isModalVisible,
    animationType: 'fade',
    transparent: true,
    onModalShow: () => input.current.focus()
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: {
      flex: 1,
      justifyContent: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: {
      padding: 16,
      backgroundColor: 'white',
      justifyContent: 'center',
      borderRadius: 16
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    onPress: () => setModalVisible(false),
    style: {
      width: 36,
      height: 36,
      alignItems: 'center',
      justifyContent: 'center',
      position: 'absolute',
      left: 16,
      top: 16
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
    source: require('../../assets/ic_close.png'),
    style: {
      width: 24,
      height: 24,
      resizeMode: 'contain'
    }
  })), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: {
      flexDirection: 'row',
      justifyContent: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: {
      padding: 16,
      borderRadius: 35,
      backgroundColor: _Styles.default.primary,
      marginTop: 20,
      marginBottom: 35,
      alignItems: 'center',
      justifyContent: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
    source: require('../../assets/ic_trash.png'),
    style: {
      width: 38,
      height: 38,
      resizeMode: 'contain'
    }
  }))), /*#__PURE__*/_react.default.createElement(_components.MText, {
    style: {
      fontSize: 17,
      lineHeight: 24,
      fontWeight: '600',
      color: _Styles.default.primaryText,
      marginBottom: 50,
      textAlign: 'center'
    }
  }, "Qu\xFD kh\xE1ch c\xF3 ch\u1EAFc ch\u1EAFn mu\u1ED1n xo\xE1 tin chat nhanh n\xE0y kh\xF4ng?"), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: {
      flexDirection: 'row',
      alignItems: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    onPress: () => setModalVisible(false),
    style: {
      flex: 1,
      marginRight: 12,
      paddingVertical: 10,
      borderRadius: 4,
      borderColor: _Styles.default.primary,
      borderWidth: 1,
      alignItems: 'center',
      justifyContent: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_components.MText, {
    style: {
      fontSize: 15,
      lineHeight: 24,
      fontWeight: '600',
      color: _Styles.default.primary
    }
  }, "B\u1ECF qua")), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    onPress: () => {
      setModalVisible(false);
      deleteQuickMessage();
    },
    style: {
      flex: 1,
      paddingVertical: 10,
      backgroundColor: _Styles.default.primary,
      borderRadius: 4,
      alignItems: 'center',
      justifyContent: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_components.MText, {
    style: {
      fontSize: 15,
      lineHeight: 24,
      fontWeight: '600',
      color: 'white'
    }
  }, "Xo\xE1 tin")))))));
});
const QuickMessage = (0, _mobxReactLite.observer)(function QuickMessage(props) {
  const snapPoints = (0, _react.useMemo)(() => ['48%', '80%'], []);
  const bottomSheetModalRef = (0, _react.useRef)();
  const insets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
  (0, _react.useEffect)(() => {
    var _bottomSheetModalRef$;
    _QuickMessageStore.default.getData({});
    (_bottomSheetModalRef$ = bottomSheetModalRef.current) === null || _bottomSheetModalRef$ === void 0 ? void 0 : _bottomSheetModalRef$.present();
    return () => {
      var _bottomSheetModalRef$2;
      (_bottomSheetModalRef$2 = bottomSheetModalRef.current) === null || _bottomSheetModalRef$2 === void 0 ? void 0 : _bottomSheetModalRef$2.dismiss();
    };
  }, []);
  const showUpdate = message => {
    _QuickMessageStore.default.currentMessage = message;
    _QuickMessageStore.default.showModal = true;
  };
  const sendMessage = msg => {
    _InputStore.default.input = msg.text;
    _ChatStore.default.showAttachModal = false;
    _ChatStore.default.tab = 1;
    try {
      _InputStore.default.inputRef();
    } catch (e) {
      (0, _utils.Log)(e);
    }
  };
  const renderItem = _ref => {
    let {
      item,
      index
    } = _ref;
    return /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
      onPress: () => sendMessage(item),
      style: {
        flexDirection: 'row',
        alignItems: 'center',
        paddingHorizontal: 16,
        paddingVertical: 8,
        borderBottomWidth: 1,
        borderColor: '#EEEEEE'
      }
    }, /*#__PURE__*/_react.default.createElement(_components.MText, {
      numberOfLines: 3,
      style: {
        flex: 1,
        flexWrap: 'wrap',
        fontWeight: '500',
        fontSize: 15,
        color: _Styles.default.neutralText
      }
    }, item.text), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
      onPress: () => showUpdate(item),
      style: {
        width: 40,
        height: 40,
        alignItems: 'center',
        justifyContent: 'center'
      }
    }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
      source: require('../../assets/ic_edit_quick_message.png'),
      style: {
        width: 16,
        height: 16,
        resizeMode: 'contain'
      },
      resizeMode: 'contain'
    })));
  };
  return /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetModal, {
    ref: bottomSheetModalRef,
    index: 0,
    bottomInset: 77 + insets.bottom,
    snapPoints: snapPoints,
    onDismiss: () => {
      if (_ChatStore.default.tab === 1) {
        _ChatStore.default.showAttachModal = false;
      }
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: {
      height: 56,
      flexDirection: 'row',
      alignItems: 'center',
      backgroundColor: '#F8F8FA',
      borderTopLeftRadius: 10,
      borderTopRightRadius: 10
    }
  }, /*#__PURE__*/_react.default.createElement(_components.MText, {
    style: {
      position: 'absolute',
      width: '100%',
      textAlign: 'center',
      fontWeight: '600',
      fontSize: 17,
      color: '#44494D'
    }
  }, "Chat nhanh"), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    onPress: () => {
      _ChatStore.default.showAttachModal = false;
    },
    style: {
      width: 56,
      height: 56,
      alignItems: 'center',
      justifyContent: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
    source: require('../../assets/ic_close.png'),
    style: {
      width: 24,
      height: 24,
      resizeMode: 'contain'
    },
    resizeMode: 'contain'
  })), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: {
      flex: 1
    }
  }), _QuickMessageStore.default.data.length > 0 ? /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    onPress: () => {
      _QuickMessageStore.default.currentMessage = {};
      _QuickMessageStore.default.showModal = true;
    },
    style: {
      paddingHorizontal: 16,
      height: 56,
      alignItems: 'center',
      justifyContent: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_components.MText, {
    style: {
      fontSize: 15,
      fontWeight: '600',
      color: '#3B7CEC'
    }
  }, "Th\xEAm m\u1EDBi")) : /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: {
      paddingHorizontal: 16,
      height: 56
    }
  })), _QuickMessageStore.default.data.length === 0 ? /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: {
      flex: 1
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
    source: require('../../assets/ic_quick_message_empty.png'),
    style: {
      width: 124,
      height: 99,
      alignSelf: 'center'
    }
  }), /*#__PURE__*/_react.default.createElement(_components.MText, {
    style: {
      color: _Styles.default.neutralText,
      fontSize: 15,
      fontWeight: '500',
      textAlign: 'center'
    }
  }, "B\u1EA1n ch\u01B0a c\xF3 tin nh\u1EAFn chat nhanh"), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    onPress: () => {
      _QuickMessageStore.default.showModal = true;
    },
    style: {
      marginHorizontal: 16,
      marginTop: 36,
      alignItems: 'center',
      justifyContent: 'center',
      marginBottom: 16,
      padding: 16,
      backgroundColor: _Styles.default.primary,
      borderRadius: 10
    }
  }, /*#__PURE__*/_react.default.createElement(_components.MText, {
    style: {
      color: 'white',
      fontWeight: '600',
      fontSize: 15
    }
  }, "T\u1EA1o tin nh\u1EAFn nhanh"))) : /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetFlatList, {
    data: _QuickMessageStore.default.data,
    renderItem: renderItem,
    ItemSeparatorComponent: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        height: 1,
        backgroundColor: ''
      }
    })
  }), /*#__PURE__*/_react.default.createElement(QuickMessageModal, null));
});
const ImageMessage = (0, _mobxReactLite.observer)(function ImageMessage(props) {
  const insets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
  const snapPoints = (0, _react.useMemo)(() => ['50%', '80%'], []);
  const bottomSheetModalRef = (0, _react.useRef)();
  (0, _react.useEffect)(() => {
    var _bottomSheetModalRef$3;
    (_bottomSheetModalRef$3 = bottomSheetModalRef.current) === null || _bottomSheetModalRef$3 === void 0 ? void 0 : _bottomSheetModalRef$3.present();
    return () => {
      var _bottomSheetModalRef$4;
      (_bottomSheetModalRef$4 = bottomSheetModalRef.current) === null || _bottomSheetModalRef$4 === void 0 ? void 0 : _bottomSheetModalRef$4.dismiss();
    };
  }, []);
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetModal, {
    ref: bottomSheetModalRef,
    index: 0,
    bottomInset: 77 + insets.bottom,
    snapPoints: snapPoints
    // onChange={handleSheetChanges}
    ,
    onDismiss: () => {
      _ChatStore.default.images = [];
      if (_ChatStore.default.tab === 0) {
        _ChatStore.default.showAttachModal = false;
        _ChatStore.default.tab = 1;
      }
    }
  }, /*#__PURE__*/_react.default.createElement(_cameraRollPicker.default, {
    assetType: 'All',
    groupTypes: "All",
    include: ['playableDuration', 'filename', 'fileExtension'],
    selected: _ChatStore.default.images,
    callback: images => {
      _ChatStore.default.images = images;
    }
  })));
});
const LocationMessage = (0, _mobxReactLite.observer)(function LocationMessage(props) {
  const bottomSheetModalRef = (0, _react.useRef)();
  const insets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
  const mapRef = (0, _react.useRef)();
  const [currentPosition, setCurrentPosition] = (0, _react.useState)({
    latitude: 0,
    longitude: 0
  });
  const requestPermission = callback => {
    const permission = _reactNative.Platform.OS === 'android' ? _reactNativePermissions.PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION : _reactNativePermissions.PERMISSIONS.IOS.LOCATION_WHEN_IN_USE;
    (0, _reactNativePermissions.request)(permission).then(result => {
      switch (result) {
        case _reactNativePermissions.RESULTS.UNAVAILABLE:
          break;
        case _reactNativePermissions.RESULTS.DENIED:
          break;
        case _reactNativePermissions.RESULTS.LIMITED:
          break;
        case _reactNativePermissions.RESULTS.GRANTED:
          callback();
          break;
        case _reactNativePermissions.RESULTS.BLOCKED:
          break;
      }
    });
  };
  (0, _react.useEffect)(() => {
    var _bottomSheetModalRef$5;
    (_bottomSheetModalRef$5 = bottomSheetModalRef.current) === null || _bottomSheetModalRef$5 === void 0 ? void 0 : _bottomSheetModalRef$5.present();
    requestPermission(() => {
      _reactNativeGeolocationService.default.getCurrentPosition(position => {
        setCurrentPosition({
          longitude: position.coords.longitude,
          latitude: position.coords.latitude
        });
        _ChatStore.default.location = {
          longitude: position.coords.longitude,
          latitude: position.coords.latitude
        };
      }, error => {
        // See error code charts below.
      }, {
        enableHighAccuracy: true,
        timeout: 15000,
        maximumAge: 10000
      });
    });
    return () => {
      var _bottomSheetModalRef$6;
      (_bottomSheetModalRef$6 = bottomSheetModalRef.current) === null || _bottomSheetModalRef$6 === void 0 ? void 0 : _bottomSheetModalRef$6.dismiss();
    };
  }, []);
  const sendMap = async () => {
    try {
      _ChatStore.default.showAttachModal = false;
      _ChatStore.default.tab = 1;
      const message = {
        id: _reactNativeUuid.default.v4(),
        type: "LOCATION",
        location: {
          latitude: _ChatStore.default.location.latitude,
          longitude: _ChatStore.default.location.longitude
        },
        status: "sending",
        sender: _AppStore.default.user.type + '_' + _AppStore.default.user.user_id,
        conversation_id: _ChatStore.default.conversation_id
      };
      _ChatStore.default.data = [message, ..._ChatStore.default.data];
      _ChatStore.default.sendMessage(message);
    } catch (e) {
      console.log(e);
    }
  };
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetModal, {
    ref: bottomSheetModalRef,
    index: 0,
    bottomInset: 77 + insets.bottom,
    snapPoints: ['80%'],
    onDismiss: () => {
      if (_ChatStore.default.tab === 3) {
        _ChatStore.default.showAttachModal = false;
        _ChatStore.default.tab = 1;
      }
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: {
      backgroundColor: 'white',
      height: '100%',
      width: '100%'
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNativeMaps.default, {
    ref: mapRef,
    zoomTapEnabled: false,
    scrollEnabled: false,
    provider: _reactNativeMaps.PROVIDER_GOOGLE // remove if not using Google Maps
    ,
    style: {
      height: '100%',
      width: '100%'
    },
    region: {
      latitude: currentPosition.latitude,
      longitude: currentPosition.longitude,
      latitudeDelta: 0.015,
      longitudeDelta: 0.0121
    },
    onRegionChangeComplete: (region, gesture) => {
      if (!(gesture !== null && gesture !== void 0 && gesture.isGesture) && _AppStore.default.appId === 'VTPost') {
        return;
      }
      _ChatStore.default.location = region;
    }
  }), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    style: {
      width: 56,
      height: 56,
      position: 'absolute',
      top: 8,
      right: 8
    },
    onPress: () => {
      var _mapRef$current;
      (_mapRef$current = mapRef.current) === null || _mapRef$current === void 0 ? void 0 : _mapRef$current.animateCamera({
        center: (0, _mobx.toJS)(currentPosition)
      });
      // setCurrentPosition(currentPosition)
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
    source: require('../../assets/ic_location.png'),
    style: {
      width: 56,
      height: 56,
      resizeMode: 'contain'
    },
    resizeMode: "contain"
  })), /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
    source: require('../../assets/ic_map_pin.png'),
    style: {
      width: 30,
      height: 30,
      resizeMode: 'contain',
      position: 'absolute',
      top: '50%',
      left: '50%',
      marginLeft: -15,
      marginTop: -30
    },
    resizeMode: "contain"
  })), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    onPress: sendMap,
    style: {
      position: 'absolute',
      zIndex: 99999,
      bottom: 16,
      left: 16,
      right: 16,
      alignItems: 'center',
      justifyContent: 'center',
      padding: 16,
      backgroundColor: _Styles.default.primary,
      borderRadius: 10
    }
  }, /*#__PURE__*/_react.default.createElement(_components.MText, {
    style: {
      color: 'white',
      fontWeight: '600',
      fontSize: 15
    }
  }, "Chia s\u1EBB v\u1ECB tr\xED"))));
});
const AttachScreen = (0, _mobxReactLite.observer)(function AttachScreen(props) {
  const handleDocumentSelection = async () => {
    try {
      const response = await _documentPicker.default.pick({
        presentationStyle: 'fullScreen',
        type: [_documentPicker.types.pdf, _documentPicker.types.xls, _documentPicker.types.docx, _documentPicker.types.xlsx, _documentPicker.types.docx, _documentPicker.types.doc, _documentPicker.types.xls]
      });
      console.log(response);
      _ChatStore.default.showAttachModal = false;
      const message = {
        id: _reactNativeUuid.default.v4(),
        "type": "FILE",
        attachmentLocal: response,
        has_attachment: true,
        "text": '',
        "status": "sending",
        sender: _AppStore.default.user.type + '_' + _AppStore.default.user.user_id,
        conversation_id: props.data._id
      };
      _ChatStore.default.data = [message, ..._ChatStore.default.data];
      _ChatStore.default.sendMessage(message);
    } catch (err) {
      console.warn(err);
    }
  };
  const requestCameraPermission = async callback => {
    try {
      let permission = '';
      if (_reactNative.Platform.OS === 'android') {
        if (_reactNative.Platform.Version >= 33) {
          const res = _reactNative.PermissionsAndroid.requestMultiple(['android.permission.READ_MEDIA_IMAGES', 'android.permission.READ_MEDIA_VIDEO', 'android.permission.READ_EXTERNAL_STORAGE']).then(statuses => {
            console.log(statuses);
            return statuses['android.permission.READ_MEDIA_IMAGES'] === _reactNative.PermissionsAndroid.RESULTS.GRANTED && statuses['android.permission.READ_MEDIA_VIDEO'] === _reactNative.PermissionsAndroid.RESULTS.GRANTED && statuses['android.permission.READ_EXTERNAL_STORAGE'] === _reactNative.PermissionsAndroid.RESULTS.GRANTED;
          });
          res.then(res => {
            if (res) {
              callback();
            }
          });
          return;
        }
        permission = _reactNativePermissions.PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE;
      } else {
        permission = _reactNativePermissions.PERMISSIONS.IOS.PHOTO_LIBRARY;
      }
      const result = await (0, _reactNativePermissions.request)(permission);
      switch (result) {
        case _reactNativePermissions.RESULTS.UNAVAILABLE:
          break;
        case _reactNativePermissions.RESULTS.DENIED:
          break;
        case _reactNativePermissions.RESULTS.LIMITED:
          break;
        case _reactNativePermissions.RESULTS.GRANTED:
          //
          // bottomSheetRef.current?.present();
          callback();
          break;
        case _reactNativePermissions.RESULTS.BLOCKED:
          break;
      }
    } catch (err) {
      (0, _utils.Log)(err);
    }
  };
  const getImageMessage = () => {
    if (_ChatStore.default.tab === 0) {
      if (!_ChatStore.default.tabImage) {
        _ChatStore.default.tabImage = /*#__PURE__*/_react.default.createElement(ImageMessage, props);
      }
      return _ChatStore.default.tabImage;
    } else {
      return /*#__PURE__*/_react.default.createElement(_reactNative.View, null);
    }
  };
  const getQuickMessage = () => {
    if (_ChatStore.default.tab === 1) {
      if (!_ChatStore.default.tabQuickMessage) {
        _ChatStore.default.tabQuickMessage = /*#__PURE__*/_react.default.createElement(QuickMessage, props);
      }
      return _ChatStore.default.tabQuickMessage;
    } else {
      return /*#__PURE__*/_react.default.createElement(_reactNative.View, null);
    }
  };
  const getLocationMessage = () => {
    if (_ChatStore.default.tab === 3) {
      if (!_ChatStore.default.tabLocationMessage) {
        _ChatStore.default.tabLocationMessage = /*#__PURE__*/_react.default.createElement(LocationMessage, props);
      }
      return _ChatStore.default.tabLocationMessage;
    } else {
      return /*#__PURE__*/_react.default.createElement(_reactNative.View, null);
    }
  };
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, _ChatStore.default.showAttachModal && /*#__PURE__*/_react.default.createElement(_reactNative.SafeAreaView, null, getImageMessage(), getQuickMessage(), getLocationMessage(), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: {
      bottom: 0,
      width: '100%',
      height: 77,
      position: 'absolute',
      backgroundColor: 'white',
      flexDirection: 'row',
      borderTopWidth: 1,
      borderColor: '#DCE6F0'
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    onPress: () => {
      requestCameraPermission(() => {
        _ChatStore.default.tab = 0;
      });
    },
    style: {
      flex: 1,
      alignItems: 'center',
      justifyContent: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
    source: _ChatStore.default.tab === 0 ? require('../../assets/nav_photo_video_active.png') : require('../../assets/nav_photo_video.png'),
    style: {
      width: 28,
      height: 28,
      resizeMode: 'contain'
    },
    resizeMode: 'contain'
  }), /*#__PURE__*/_react.default.createElement(_components.MText, {
    style: {
      color: _ChatStore.default.tab === 0 ? _Styles.default.primary : _Styles.default.neutralText,
      fontSize: 13,
      fontWeight: _ChatStore.default.tab === 0 ? '600' : '500',
      paddingTop: 6
    }
  }, "\u1EA2nh, video")), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    onPress: () => {
      _ChatStore.default.tab = 1;
    },
    style: {
      flex: 1,
      alignItems: 'center',
      justifyContent: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
    source: _ChatStore.default.tab === 1 ? require('../../assets/nav_quick_message_active.png') : require('../../assets/nav_quick_message_active.png'),
    style: {
      width: 28,
      height: 28,
      resizeMode: 'contain',
      tintColor: _ChatStore.default.tab === 1 ? _Styles.default.primary : _Styles.default.sending
    },
    resizeMode: 'contain'
  }), /*#__PURE__*/_react.default.createElement(_components.MText, {
    style: {
      color: _ChatStore.default.tab === 1 ? _Styles.default.primary : _Styles.default.neutralText,
      fontSize: 13,
      fontWeight: _ChatStore.default.tab === 1 ? '600' : '500',
      paddingTop: 6
    }
  }, "Chat nhanh")), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    onPress: handleDocumentSelection,
    style: {
      flex: 1,
      alignItems: 'center',
      justifyContent: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
    source: _ChatStore.default.tab === 2 ? require('../../assets/nav_document.png') : require('../../assets/nav_document.png'),
    style: {
      width: 28,
      height: 28,
      resizeMode: 'contain'
    },
    resizeMode: 'contain'
  }), /*#__PURE__*/_react.default.createElement(_components.MText, {
    style: {
      color: _ChatStore.default.tab === 2 ? _Styles.default.primary : _Styles.default.neutralText,
      fontSize: 13,
      fontWeight: _ChatStore.default.tab === 2 ? '600' : '500',
      paddingTop: 6
    }
  }, "T\xE0i li\u1EC7u")), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    onPress: () => {
      _ChatStore.default.tab = 3;
    },
    style: {
      flex: 1,
      alignItems: 'center',
      justifyContent: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
    source: _ChatStore.default.tab === 3 ? require('../../assets/nav_location_active.png') : require('../../assets/nav_location.png'),
    style: {
      width: 28,
      height: 28,
      resizeMode: 'contain'
    },
    resizeMode: 'contain'
  }), /*#__PURE__*/_react.default.createElement(_components.MText, {
    style: {
      color: _ChatStore.default.tab === 3 ? _Styles.default.primary : _Styles.default.neutralText,
      fontSize: 13,
      fontWeight: _ChatStore.default.tab === 3 ? '600' : '500',
      paddingTop: 6
    }
  }, "G\u1EEDi v\u1ECB tr\xED")))));
});
exports.AttachScreen = AttachScreen;
const Input = (0, _mobxReactLite.observer)(function Input() {
  const inputRef = (0, _react.useRef)(null);
  (0, _react.useEffect)(() => {
    _InputStore.default.inputRef = () => {
      try {
        var _inputRef$current;
        (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
      } catch (e) {
        (0, _utils.Log)(e);
      }
    };
  }, []);
  return /*#__PURE__*/_react.default.createElement(_components.MTextInput, {
    editable: _ChatStore.default.canSend,
    ref: inputRef,
    placeholder: _AppStore.default.lang.chat.input_message,
    placeholderTextColor: '#B5B4B8',
    multiline: true,
    onChangeText: text => {
      _InputStore.default.input = text;
    },
    value: _InputStore.default.input,
    style: {
      fontSize: 15,
      color: _Styles.default.primaryText,
      flex: 1,
      minHeight: 56,
      paddingTop: 18,
      padding: 12,
      fontFamily: 'SVN-GilroyMedium',
      maxHeight: 250
    }
  });
});
exports.Input = Input;
//# sourceMappingURL=Attach.js.map