import React from 'react';
import SVG from '@teamix/svg';
import { usePrefixCls } from '@teamix/utils';
import { PagePlayground } from './playground';
import { PageMap, PageDefaultInitialValues } from '.';
var cls = usePrefixCls('teamix-pro-pager');
export var PageEditor = function PageEditor(props) {
  var type = props.type,
    initialValues = props.initialValues,
    field = props.field,
    configuratorMap = props.configuratorMap,
    pageMap = props.pageMap,
    pageDefaultInitialValues = props.pageDefaultInitialValues;
  var values = initialValues || PageDefaultInitialValues[type] || (pageDefaultInitialValues === null || pageDefaultInitialValues === void 0 ? void 0 : pageDefaultInitialValues[type]);
  React.useEffect(function () {
    field && field.setValues(values);
  }, []);
  var onValuesChange = function onValuesChange(values) {
    field && field.setValues(values);
  };
  var Page = PageMap[type] || (pageMap === null || pageMap === void 0 ? void 0 : pageMap[type]);
  if (!Page) {
    return /*#__PURE__*/React.createElement("div", {
      className: cls('empty')
    }, /*#__PURE__*/React.createElement(SVG.Status404, {
      width: 160,
      height: 160
    }), /*#__PURE__*/React.createElement("p", null, "\u9519\u8BEF\u7684\u9875\u9762\u7C7B\u578B"));
  }
  return /*#__PURE__*/React.createElement(PagePlayground, {
    page: Page,
    initialValues: values,
    onValuesChange: onValuesChange,
    configuratorMap: configuratorMap
  });
};