import React from 'react';
import PropTypes from 'prop-types';
import { Alert, Input, Popover, Button } from 'antd';
import { jsxs as _jsxs } from "react/jsx-runtime";
import { jsx as _jsx } from "react/jsx-runtime";
export default function ErrorAlert({
  json,
  error,
  tplStr,
  record
}) {
  return /*#__PURE__*/_jsx(Alert, {
    message: /*#__PURE__*/_jsxs("div", {
      children: [`Failed to parse JSON generated from template, fallback to render plain text. `, /*#__PURE__*/_jsx(Popover, {
        content: /*#__PURE__*/_jsxs("div", {
          style: {
            width: '800px'
          },
          children: [/*#__PURE__*/_jsxs("div", {
            children: ["Error: ", error.message]
          }), /*#__PURE__*/_jsxs("div", {
            children: [`The generated JSON (Copy the JSON to do the validation):`, /*#__PURE__*/_jsx(Input.TextArea, {
              defaultValue: json
            })]
          }), /*#__PURE__*/_jsxs("div", {
            children: ["tplStr: ", /*#__PURE__*/_jsx(Input.TextArea, {
              defaultValue: tplStr
            })]
          }), /*#__PURE__*/_jsxs("div", {
            children: ["record:", ' ', /*#__PURE__*/_jsx(Input.TextArea, {
              rows: 7,
              defaultValue: JSON.stringify(record, null, 2)
            })]
          })]
        }),
        title: "Debug Info",
        trigger: "click",
        children: /*#__PURE__*/_jsx(Button, {
          size: "small",
          danger: true,
          children: "Debug Info"
        })
      })]
    }),
    type: "error",
    closable: true
  });
}
ErrorAlert.propTypes = {
  json: PropTypes.string.isRequired,
  error: PropTypes.shape({
    message: PropTypes.string
  }).isRequired,
  tplStr: PropTypes.string.isRequired,
  record: PropTypes.string.isRequired
};
//# sourceMappingURL=ErrorAlert.js.map