"use strict";

exports.__esModule = true;
exports.EmptyState = void 0;
var _react = _interopRequireWildcard(require("react"));
var _mobxReactLite = require("mobx-react-lite");
var _designSystem = require("@wix/design-system");
var _react2 = require("@wix/bex-core/react");
var _CreateTagButton = require("./CreateTagButton");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/Tags/BulkAssignTagsPopover/EmptyState.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const _EmptyState = ({
  state
}) => {
  const {
    translate: t
  } = (0, _react2.useWixPatternsContainer)();
  const handleEmptyStateSearchChange = (0, _react.useCallback)(e => {
    const value = e.target.value;
    state.handleSearchChange(value);
  }, [state.handleSearchChange]);
  const renderErrorState = (0, _react.useCallback)(() => {
    var _resolvedError$action, _resolvedError$action2, _resolvedError$action3;
    const resolvedError = state.error;
    return /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
      height: "100%",
      verticalAlign: "middle",
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 34,
        columnNumber: 7
      }
    }, /*#__PURE__*/_react.default.createElement(_designSystem.EmptyState, {
      dataHook: "bulk-assign-tags-error-state",
      theme: "page-no-border",
      subtitle: resolvedError == null ? void 0 : resolvedError.message,
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 35,
        columnNumber: 9
      }
    }, (resolvedError == null || (_resolvedError$action = resolvedError.action) == null ? void 0 : _resolvedError$action.onClick) && /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
      dataHook: "bulk-assign-tags-error-state-retry-button",
      onClick: resolvedError == null || (_resolvedError$action2 = resolvedError.action) == null ? void 0 : _resolvedError$action2.onClick,
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 41,
        columnNumber: 13
      }
    }, resolvedError == null || (_resolvedError$action3 = resolvedError.action) == null ? void 0 : _resolvedError$action3.text)));
  }, [state.error]);
  return /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    direction: "vertical",
    boxSizing: "border-box",
    height: "100%",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 54,
      columnNumber: 5
    }
  }, state.isInEmptyState && /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    direction: "vertical",
    padding: "SP5 SP5 0",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 56,
      columnNumber: 9
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 57,
      columnNumber: 11
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.Search, {
    dataHook: "bulk-assign-tags-empty-state-search",
    placeholder: t('cairo.tags.collectionPage.popover.emptyState.search.placeholder'),
    onChange: handleEmptyStateSearchChange,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 58,
      columnNumber: 13
    }
  })), !!state.searchValue && /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    marginTop: "SP4",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 67,
      columnNumber: 13
    }
  }, /*#__PURE__*/_react.default.createElement(_CreateTagButton.CreateTagButton, {
    state: state,
    searchValue: state.searchValue,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 68,
      columnNumber: 15
    }
  }))), state.isError && renderErrorState(), state.isInEmptyState && !state.searchValue && /*#__PURE__*/_react.default.createElement(_designSystem.EmptyState, {
    dataHook: "bulk-assign-tags-empty-state",
    theme: "page-no-border",
    subtitle: t('cairo.tags.collectionPage.popover.emptyState.body'),
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 75,
      columnNumber: 9
    }
  }));
};
const EmptyState = exports.EmptyState = (0, _mobxReactLite.observer)(_EmptyState);
//# sourceMappingURL=EmptyState.js.map