"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.CustomFieldsWidgetCard = void 0;
var _react = _interopRequireDefault(require("react"));
var _mobxReactLite = require("mobx-react-lite");
var _CardContainer = require("../CardContainer");
var _designSystem = require("@wix/design-system");
var _Heading = require("../Heading");
var _react2 = require("@wix/bex-core/react");
var _CustomFieldsWidgetContentLazy = require("./CustomFieldsWidgetContentLazy");
var _wixUiIconsCommon = require("@wix/wix-ui-icons-common");
var _useWidgetPageStatus = require("../useWidgetPageStatus");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/CustomFieldsWidget/CustomFieldsWidgetCard.tsx";
const _CustomFieldsWidgetCard = ({
  state,
  subtitle,
  dataHook,
  emptyStateOverrides = {},
  onChange
}) => {
  const {
    status
  } = (0, _useWidgetPageStatus.useWidgetPageStatus)(state.initTask.status.status);
  const container = (0, _react2.useWixPatternsContainer)();
  const {
    translate: t
  } = container;
  const headerSubtitle = subtitle || t('cairo.customFields.entityPage.subtitle');
  const headerTitle = /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    gap: "SP1",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 35,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react.default.createElement(_Heading.Heading, {
    size: "medium",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 36,
      columnNumber: 7
    }
  }, t('cairo.customFieldsWidget.entityPage.title')), state.widgetSize !== 'default' ? /*#__PURE__*/_react.default.createElement(_designSystem.InfoIcon, {
    dataHook: "subtitle-info-icon",
    content: headerSubtitle,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 40,
      columnNumber: 9
    }
  }) : null);
  const ActionsButton = state.ActionButtonsComponent;
  const suffix = ActionsButton ? /*#__PURE__*/_react.default.createElement(ActionsButton, {
    state: state,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 46,
      columnNumber: 34
    }
  }) : null;
  return /*#__PURE__*/_react.default.createElement(_CardContainer.CardContainer, {
    stretchVertically: true,
    dataHook: dataHook,
    status: status,
    errorState: {
      dataHook: 'error-state',
      title: t('cairo.customFields.technical.error.title'),
      subtitle: t('cairo.technical.error.text'),
      action: {
        text: t('cairo.error.tryAgain.cta'),
        prefixIcon: /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.Refresh, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 59,
            columnNumber: 23
          }
        }),
        onClick: state.retry
      }
    },
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 49,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.Card.Header, {
    dataHook: "custom-fields-widget-header",
    title: headerTitle,
    subtitle: state.widgetSize === 'default' ? headerSubtitle : null,
    suffix: suffix,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 64,
      columnNumber: 7
    }
  }), /*#__PURE__*/_react.default.createElement(_designSystem.Card.Divider, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 70,
      columnNumber: 7
    }
  }), /*#__PURE__*/_react.default.createElement(_designSystem.Card.Content, {
    dataHook: "custom-fields-widget-content",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 71,
      columnNumber: 7
    }
  }, /*#__PURE__*/_react.default.createElement(_CustomFieldsWidgetContentLazy.CustomFieldsWidgetContentLazy, {
    emptyStateOverrides: emptyStateOverrides,
    onChange: onChange,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 72,
      columnNumber: 9
    }
  })));
};
const CustomFieldsWidgetCard = exports.CustomFieldsWidgetCard = (0, _mobxReactLite.observer)(_CustomFieldsWidgetCard);
//# sourceMappingURL=CustomFieldsWidgetCard.js.map