"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.PickerEmptyState = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _wixUiIconsCommon = require("@wix/wix-ui-icons-common");
var _react = _interopRequireDefault(require("react"));
var _designSystem = require("@wix/design-system");
var _CollectionEmptyStateBase = require("../CollectionEmptyStateBase");
var _mobxReactLite = require("mobx-react-lite");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/PickerEmptyState/PickerEmptyState.tsx";
function _PickerEmptyState(props) {
  const {
    state,
    hasFilterDropdown,
    ...rest
  } = props;
  const {
    collection
  } = state;
  const {
    result: {
      hasAvailableItems
    },
    translate: t
  } = collection;
  const showFilterOnlyEmptyState = Boolean(hasFilterDropdown && collection.query.search.isEmpty);
  const showFilterWithSearchEmptyState = Boolean(hasFilterDropdown && !collection.query.search.isEmpty);
  const searchOnlyNoResultsStateProps = {
    state: collection,
    dataHook: 'picker-no-results-state',
    title: t('cairo.search.nothingMatches.title', {
      term: collection.result.originQuery.rawSearch
    }),
    subtitle: /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
      direction: "vertical",
      gap: "18px",
      align: "center",
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 43,
        columnNumber: 7
      }
    }, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
      dataHook: "picker-no-results-state-subtitle",
      size: "small",
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 44,
        columnNumber: 9
      }
    }, t('cairo.search.nothingMatches.text')), /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
      dataHook: "picker-no-results-state-reset-button",
      prefixIcon: /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.Revert, {
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 49,
          columnNumber: 23
        }
      }),
      onClick: () => {
        var _collection$searchInp;
        collection.clearSearch();
        (_collection$searchInp = collection.searchInputRef) == null || _collection$searchInp.focus();
      },
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 47,
        columnNumber: 9
      }
    }, t('cairo.emptyState.reset.button')))
  };
  const filterOnlyEmptyStateProps = {
    state: collection,
    dataHook: 'picker-empty-state-only-filter',
    title: t('cairo.search.noresults.title'),
    subtitle: t('cairo.selectorModal.searchEmptyState.changeFilter.subtitle')
  };
  const filterWithSearchEmptyStateProps = {
    state: collection,
    dataHook: 'picker-empty-state-filter-with-search',
    title: t('cairo.search.nothingMatches.title', {
      term: collection.result.originQuery.rawSearch
    }),
    subtitle: /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
      direction: "vertical",
      gap: "18px",
      align: "center",
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 75,
        columnNumber: 7
      }
    }, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
      size: "small",
      dataHook: "picker-no-results-state-subtitle",
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 76,
        columnNumber: 9
      }
    }, t('cairo.selectorModal.searchEmptyState.subtitle')), /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
      dataHook: "picker-no-results-state-reset-button",
      prefixIcon: /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.Revert, {
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 81,
          columnNumber: 23
        }
      }),
      onClick: () => {
        var _collection$searchInp2;
        collection.clearSearch();
        (_collection$searchInp2 = collection.searchInputRef) == null || _collection$searchInp2.focus();
      },
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 79,
        columnNumber: 9
      }
    }, t('cairo.emptyState.reset.button')))
  };
  const getEmptyStateConfig = () => {
    if (!hasAvailableItems) {
      return {
        state: collection,
        dataHook: 'picker-empty-state'
      };
    }
    if (showFilterOnlyEmptyState) {
      return filterOnlyEmptyStateProps;
    }
    if (showFilterWithSearchEmptyState) {
      return filterWithSearchEmptyStateProps;
    }
    return searchOnlyNoResultsStateProps;
  };
  return /*#__PURE__*/_react.default.createElement(_CollectionEmptyStateBase.CollectionEmptyStateBase, (0, _extends2.default)({}, getEmptyStateConfig(), rest, {
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 110,
      columnNumber: 10
    }
  }));
}
const PickerEmptyState = exports.PickerEmptyState = (0, _mobxReactLite.observer)(_PickerEmptyState);
//# sourceMappingURL=PickerEmptyState.js.map