"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.TaskButton = void 0;
var _react = _interopRequireWildcard(require("react"));
var _react2 = require("@chakra-ui/react");
var _icons = require("@chakra-ui/icons");
var _index = require("../index.js");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
const TaskButton = _ref => {
  var _task$result, _task$result2, _task$result3, _task$result4;
  let {
    children,
    task_id,
    ...p
  } = _ref;
  const task = (0, _index.useAnvilSelector)(state => state.task[task_id]);
  return /*#__PURE__*/_react.default.createElement(_react2.Tooltip, {
    label: task === null || task === void 0 ? void 0 : (_task$result = task.result) === null || _task$result === void 0 ? void 0 : _task$result.msg,
    placement: "top",
    isOpen: task !== null && task !== void 0 && (_task$result2 = task.result) !== null && _task$result2 !== void 0 && _task$result2.msg ? true : false,
    bg: task !== null && task !== void 0 && (_task$result3 = task.result) !== null && _task$result3 !== void 0 && _task$result3.err ? "pink.600" : "green.600",
    color: task !== null && task !== void 0 && (_task$result4 = task.result) !== null && _task$result4 !== void 0 && _task$result4.err ? "pink.100" : "green.100",
    hasArrow: true
  }, /*#__PURE__*/_react.default.createElement(_react2.Button, _extends({}, p, {
    isLoading: !!task,
    spinner: task !== null && task !== void 0 && task.result ? task.result.err ? /*#__PURE__*/_react.default.createElement(_icons.WarningTwoIcon, {
      color: "pink.300"
    }) : /*#__PURE__*/_react.default.createElement(_icons.CheckIcon, {
      color: "green.300"
    }) : undefined
  }), children));
};
exports.TaskButton = TaskButton;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJUYXNrQnV0dG9uIiwiY2hpbGRyZW4iLCJ0YXNrX2lkIiwicCIsInRhc2siLCJ1c2VTZWxlY3RvciIsInN0YXRlIiwicmVzdWx0IiwibXNnIiwiZXJyIiwidW5kZWZpbmVkIl0sInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbXBvbmVudHMvVGFza0J1dHRvbi5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgUmVhY3QsIHsgdXNlRWZmZWN0LCB1c2VTdGF0ZSB9IGZyb20gXCJyZWFjdFwiO1xuXG5pbXBvcnQgeyBUb29sdGlwLCBCdXR0b24gfSBmcm9tIFwiQGNoYWtyYS11aS9yZWFjdFwiO1xuaW1wb3J0IHsgV2FybmluZ1R3b0ljb24sIENoZWNrSWNvbiB9IGZyb20gXCJAY2hha3JhLXVpL2ljb25zXCI7XG5pbXBvcnQge1xuICB1c2VBbnZpbFNlbGVjdG9yIGFzIHVzZVNlbGVjdG9yLFxuICB1c2VBbnZpbERpc3BhdGNoIGFzIHVzZURpc3BhdGNoLFxufSBmcm9tIFwiLi4vaW5kZXguanNcIjtcblxuZXhwb3J0IGNvbnN0IFRhc2tCdXR0b24gPSAoeyBjaGlsZHJlbiwgdGFza19pZC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