"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _Detail = _interopRequireDefault(require("../../features/post/Detail"));
var _native = require("@react-navigation/native");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function PostDetail({
  defaultPostId
}) {
  var _route$params, _route$params2, _route$params3, _route$params4;
  const route = (0, _native.useRoute)();
  const navigation = (0, _native.useNavigation)();
  const postIdFromRoute = route === null || route === void 0 || (_route$params = route.params) === null || _route$params === void 0 ? void 0 : _route$params.postId;
  const [postId, setPostId] = (0, _react.useState)('');
  (0, _react.useEffect)(() => {
    const routes = navigation.getState().routes;
    if (defaultPostId && routes.length === 1) {
      setPostId(defaultPostId);
    } else if (postIdFromRoute) {
      setPostId(postIdFromRoute);
    }
    return () => {
      setPostId('');
    };
  }, [defaultPostId, navigation, postIdFromRoute]);
  return /*#__PURE__*/React.createElement(_Detail.default, {
    showEndPopup: route === null || route === void 0 || (_route$params2 = route.params) === null || _route$params2 === void 0 ? void 0 : _route$params2.showEndPopup,
    isFromComponent: !!defaultPostId && !postIdFromRoute,
    postId: postId,
    category: route === null || route === void 0 || (_route$params3 = route.params) === null || _route$params3 === void 0 ? void 0 : _route$params3.category,
    isDeleted: route === null || route === void 0 || (_route$params4 = route.params) === null || _route$params4 === void 0 ? void 0 : _route$params4.isDeleted
  });
}
var _default = exports.default = PostDetail;
//# sourceMappingURL=index.js.map