"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.WithLabelUsageLink = exports.WithLabelUsage = exports.OnClickToastMessages2 = exports.OnClickToastMessages = exports.HoverUsage = exports.DifferentVariantToastMessages = exports.ControlledTimeOut = void 0;
var _react = _interopRequireWildcard(require("react"));
var _addonActions = require("@storybook/addon-actions");
var _ToastMessage = _interopRequireDefault(require("./ToastMessage"));
var _Display = require("../../common/Display");
var _2 = require("../..");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
var _default = exports.default = {
  title: 'Molecules / ToastMessage ',
  parameters: {
    component: _ToastMessage.default
  }
};
var DifferentVariantToastMessages = exports.DifferentVariantToastMessages = {
  render: function render() {
    return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_Display.Display, {
      items: [{
        title: 'primary',
        component: _react.default.createElement(_ToastMessage.default, {
          label: "Link copied to clipboard",
          icon: _react.default.createElement(_2.Icon.CheckCircleFill24, {
            color: function color(t) {
              return t.colorTokens.positive.icon_default;
            }
          }),
          isVisible: true,
          linkButton: _react.default.createElement(_2.Button, {
            onClick: (0, _addonActions.action)('clicked'),
            variant: "neutral",
            color: function color(t) {
              return t.colorTokens.action.text_focus;
            }
          }, "View")
        })
      }]
    }));
  },
  name: 'Different variants'
};
var HoverUsage = exports.HoverUsage = {
  render: function render() {
    var Example = function Example() {
      var _useState = (0, _react.useState)(false),
        _useState2 = _slicedToArray(_useState, 2),
        visible = _useState2[0],
        setVisible = _useState2[1];
      return _react.default.createElement(_2.PageWrapper, {
        background: function background(t) {
          return t.colorTokens.neutral.background_brand_white;
        }
      }, _react.default.createElement(_2.Flexbox, null, _react.default.createElement(_2.Box, {
        onMouseEnter: function onMouseEnter() {
          return setVisible(!visible);
        },
        p: 4
      }, _react.default.createElement(_2.Badge.Status, {
        variant: "create",
        badgeSize: "xl",
        label: "Hover me"
      }))), _react.default.createElement(_2.Flexbox, {
        container: true,
        gap: 10
      }, _react.default.createElement(_ToastMessage.default, {
        label: "Link copied to clipboard",
        icon: _react.default.createElement(_2.Icon.CheckCircleFill24, {
          color: function color(t) {
            return t.colorTokens.positive.icon_default;
          }
        }),
        isVisible: visible,
        linkButton: _react.default.createElement(_2.Button, {
          onClick: (0, _addonActions.action)('clicked'),
          variant: "neutral",
          color: function color(t) {
            return t.colorTokens.action.text_focus;
          }
        }, "View")
      })));
    };
    return _react.default.createElement(Example, null);
  },
  name: 'With Hover'
};
var WithLabelUsage = exports.WithLabelUsage = {
  render: function render() {
    var Example = function Example() {
      var _useState3 = (0, _react.useState)(false),
        _useState4 = _slicedToArray(_useState3, 2),
        visible = _useState4[0],
        setVisible = _useState4[1];
      return _react.default.createElement(_2.PageWrapper, {
        background: function background(t) {
          return t.colorTokens.neutral.background_brand_white;
        }
      }, _react.default.createElement(_2.Flexbox, null, _react.default.createElement(_2.Button, {
        variant: "primary",
        onMouseEnter: function onMouseEnter() {
          return setVisible(!visible);
        }
      }, "Hover me")), _react.default.createElement(_2.Flexbox, {
        container: true,
        gap: 10
      }, _react.default.createElement(_ToastMessage.default, {
        label: "Saved to watchlist",
        isVisible: visible
      })));
    };
    return _react.default.createElement(Example, null);
  },
  name: 'With label'
};
var WithLabelUsageLink = exports.WithLabelUsageLink = {
  render: function render() {
    var Example = function Example() {
      var _useState5 = (0, _react.useState)(false),
        _useState6 = _slicedToArray(_useState5, 2),
        visible = _useState6[0],
        setVisible = _useState6[1];
      return _react.default.createElement(_2.PageWrapper, {
        background: function background(t) {
          return t.colorTokens.neutral.background_brand_white;
        }
      }, _react.default.createElement(_2.Flexbox, null, _react.default.createElement(_2.Button, {
        variant: "primary",
        onMouseEnter: function onMouseEnter() {
          return setVisible(true);
        }
      }, "Hover me")), _react.default.createElement(_2.Flexbox, {
        container: true,
        gap: 10
      }, _react.default.createElement(_ToastMessage.default, {
        label: "Saved to watchlist",
        isVisible: visible,
        linkButton: _react.default.createElement(_2.Button, {
          onClick: (0, _addonActions.action)('clicked'),
          variant: "neutral",
          color: function color(t) {
            return t.colorTokens.action.text_focus;
          }
        }, "View")
      })));
    };
    return _react.default.createElement(Example, null);
  },
  name: 'With label and link View'
};
var OnClickToastMessages = exports.OnClickToastMessages = {
  render: function render() {
    var Example = function Example() {
      var childRef = (0, _react.useRef)();
      var handleClick = function handleClick() {
        childRef.current.setVisible();
      };
      return _react.default.createElement(_2.PageWrapper, {
        background: function background(t) {
          return t.colorTokens.neutral.background_brand_white;
        }
      }, _react.default.createElement(_2.Flexbox, null, _react.default.createElement(_2.Button, {
        variant: "primary",
        onClick: function onClick() {
          return handleClick();
        }
      }, "use setVisible ref method")), _react.default.createElement(_ToastMessage.default, {
        ref: childRef,
        label: "Link copied to clipboard",
        icon: _react.default.createElement(_2.Icon.CheckCircleFill24, {
          color: function color(t) {
            return t.colorTokens.positive.icon_default;
          }
        }),
        linkButton: _react.default.createElement(_2.Button, {
          onClick: (0, _addonActions.action)('clicked'),
          variant: "neutral",
          color: function color(t) {
            return t.colorTokens.action.text_focus;
          }
        }, "View")
      }));
    };
    return _react.default.createElement(Example, null);
  },
  name: 'OnClick set ToastMessage'
};
var ControlledTimeOut = exports.ControlledTimeOut = {
  render: function render() {
    var Example = function Example() {
      var _useState7 = (0, _react.useState)(false),
        _useState8 = _slicedToArray(_useState7, 2),
        visible = _useState8[0],
        setVisible = _useState8[1];
      return _react.default.createElement(_2.PageWrapper, {
        background: function background(t) {
          return t.colorTokens.neutral.background_brand_white;
        }
      }, _react.default.createElement(_2.Flexbox, null, _react.default.createElement(_2.Button, {
        variant: "primary",
        onClick: function onClick() {
          return setVisible(!visible);
        }
      }, "Click me")), _react.default.createElement(_ToastMessage.default, {
        label: "Link copied to clipboard",
        icon: _react.default.createElement(_2.Icon.CheckCircleFill24, {
          color: function color(t) {
            return t.colorTokens.positive.icon_default;
          }
        }),
        isVisible: visible,
        timeout: 10000,
        linkButton: _react.default.createElement(_2.Button, {
          onClick: (0, _addonActions.action)('clicked'),
          variant: "neutral",
          color: function color(t) {
            return t.colorTokens.action.text_focus;
          }
        }, "View")
      }));
    };
    return _react.default.createElement(Example, null);
  },
  name: 'Controlled timeout ToastMessage'
};
var OnClickToastMessages2 = exports.OnClickToastMessages2 = {
  render: function render() {
    var Example = function Example() {
      var childRef = (0, _react.useRef)();
      var _useState9 = (0, _react.useState)(0),
        _useState10 = _slicedToArray(_useState9, 2),
        value = _useState10[0],
        setValue = _useState10[1];
      (0, _react.useEffect)(function () {
        if (value >= 3) {
          childRef.current.setVisible();
        }
      }, [value]);
      return _react.default.createElement(_2.PageWrapper, {
        background: function background(t) {
          return t.colorTokens.neutral.background_brand_white;
        }
      }, _react.default.createElement(_2.Flexbox, {
        container: true,
        direction: "column",
        gap: 3
      }, "Conditional call", _react.default.createElement(_2.Flexbox, {
        container: true,
        gap: 3
      }, Array.from({
        length: 5
      }).map(function (_, index) {
        return _react.default.createElement(_2.Button, {
          variant: "primary",
          onClick: function onClick() {
            return setValue(index + 1);
          }
        }, index + 1);
      })), "setVisible if value is 3 or more"), _react.default.createElement(_ToastMessage.default, {
        ref: childRef,
        label: "You have reached the maximum number of attempts",
        icon: _react.default.createElement(_2.Icon.Warning24, {
          color: function color(t) {
            return t.colorTokens.error.background_default;
          }
        }),
        linkButton: _react.default.createElement(_2.Button, {
          onClick: (0, _addonActions.action)('clicked'),
          variant: "neutral",
          color: function color(t) {
            return t.colorTokens.action.text_focus;
          }
        }, "View")
      }));
    };
    return _react.default.createElement(Example, null);
  },
  name: 'Conditional call to setVisible'
};