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); }
import React from "react";
import { Icon } from "@blueprintjs/core";
import ToolbarItem from "./ToolbarItem";
import { connectToEditor, handleSave } from "../withEditorProps";
import { withHandlers } from "recompose";
import { compose } from "redux";
export default compose(connectToEditor(function (_ref) {
  var readOnly = _ref.readOnly,
    _ref$sequenceData = _ref.sequenceData,
    sequenceData = _ref$sequenceData === void 0 ? {} : _ref$sequenceData,
    _ref$lastSavedId = _ref.lastSavedId,
    lastSavedId = _ref$lastSavedId === void 0 ? "134%!@#%!@#%!@%" : _ref$lastSavedId;
  return {
    readOnly: readOnly,
    sequenceData: sequenceData,
    hasBeenSaved: sequenceData.stateTrackingId === "initialLoadId" || sequenceData.stateTrackingId === lastSavedId
  };
}), withHandlers({
  handleSave: handleSave
}))(function (_ref2) {
  var toolbarItemProps = _ref2.toolbarItemProps,
    alwaysAllowSave = _ref2.alwaysAllowSave,
    handleSave = _ref2.handleSave,
    readOnly = _ref2.readOnly,
    hasBeenSaved = _ref2.hasBeenSaved,
    onSave = _ref2.onSave;
  return /*#__PURE__*/React.createElement(ToolbarItem, _extends({
    Icon: /*#__PURE__*/React.createElement(Icon, {
      "data-test": "saveTool",
      icon: "floppy-disk"
    }),
    onIconClick: handleSave,
    disabled: alwaysAllowSave ? false : !onSave || hasBeenSaved || readOnly,
    tooltip: /*#__PURE__*/React.createElement("span", null, "Save ", /*#__PURE__*/React.createElement("span", {
      style: {
        fontSize: 10
      }
    }, "(Cmd/Ctrl+S)"))
  }, toolbarItemProps));
});