import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import React, { useEffect, useState } from 'react';
import Loading from "../Loading";
import { TextWrap } from "./TextWrap";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var Text = function Text(_ref) {
  var media = _ref.media,
    mediaVisible = _ref.mediaVisible,
    _ref$isDetail = _ref.isDetail,
    isDetail = _ref$isDetail === void 0 ? true : _ref$isDetail;
  var _useState = useState(''),
    _useState2 = _slicedToArray(_useState, 2),
    content = _useState2[0],
    setContent = _useState2[1];
  useEffect(function () {
    fetch(media).then(function (r) {
      return r.text();
    }).then(function (r) {
      return setContent(r);
    });
  }, [media]);
  return /*#__PURE__*/_jsxs(TextWrap, {
    mediaVisible: mediaVisible,
    isDetail: isDetail,
    children: [/*#__PURE__*/_jsx(Loading, {
      cssStyle: "\n          display: ".concat(isDetail && content && 'none', ";\n        ")
    }), /*#__PURE__*/_jsx("div", {
      className: "hideScrollbar",
      children: content
    })]
  });
};
export default Text;