import React, { useState } from 'react';
import { Button, Modal } from 'antd';
import { ComponentDemoRouter } from '../layout/ComponentDemo';
import { jsx as _jsx } from "react/jsx-runtime";
import { Fragment as _Fragment } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
const getComponentName = renderArg => {
  let componentName = '';
  if (typeof renderArg === 'string') {
    componentName = renderArg;
  } else if (typeof renderArg[0] === 'string') {
    componentName = renderArg[0];
  }
  return componentName;
};
const ComponentDemoModal = ({
  renderArg
}) => {
  const [isModalOpen, setIsModalOpen] = useState(false);
  const showModal = () => {
    setIsModalOpen(true);
  };
  const handleOk = () => {
    setIsModalOpen(false);
  };
  const handleCancel = () => {
    setIsModalOpen(false);
  };
  return /*#__PURE__*/_jsxs(_Fragment, {
    children: [typeof renderArg === 'string' ? renderArg : JSON.stringify(renderArg), ' ', /*#__PURE__*/_jsx(Button, {
      type: "primary",
      size: "small",
      onClick: showModal,
      children: "demo"
    }), /*#__PURE__*/_jsx(Modal, {
      title: "Component Demo",
      open: isModalOpen,
      onOk: handleOk,
      onCancel: handleCancel,
      children: /*#__PURE__*/_jsx(ComponentDemoRouter, {
        componentName: getComponentName(renderArg)
      })
    })]
  });
};
export default ComponentDemoModal;
//# sourceMappingURL=ComponentDemoModal.js.map