"use strict";

require("core-js/modules/es.symbol.js");
require("core-js/modules/es.array.filter.js");
require("core-js/modules/es.array.for-each.js");
require("core-js/modules/es.array.iterator.js");
require("core-js/modules/es.object.define-properties.js");
require("core-js/modules/es.object.define-property.js");
require("core-js/modules/es.object.get-own-property-descriptor.js");
require("core-js/modules/es.object.get-own-property-descriptors.js");
require("core-js/modules/es.object.keys.js");
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/es.string.iterator.js");
require("core-js/modules/es.weak-map.js");
require("core-js/modules/esnext.iterator.constructor.js");
require("core-js/modules/esnext.iterator.filter.js");
require("core-js/modules/esnext.iterator.for-each.js");
require("core-js/modules/esnext.weak-map.delete-all.js");
require("core-js/modules/esnext.weak-map.emplace.js");
require("core-js/modules/web.dom-collections.for-each.js");
require("core-js/modules/web.dom-collections.iterator.js");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.Basic = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
require("core-js/modules/es.array.push.js");
var _react = require("react");
var _ = _interopRequireWildcard(require("."));
var _button = require("../button");
var _icon = require("../icon");
var _type = require("../icon/type");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(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 (var _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); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var meta = {
  title: 'Components/Notification',
  tags: ['autodocs'],
  argTypes: {
    rootConfig: {
      type: 'NotificationConfig',
      description: 'Configuration for the notification root',
      defaultValue: {
        stack: true
      }
    }
  },
  args: {
    rootConfig: {
      stack: true
    }
  }
};
var key = 1;
var keys = [];
var openNotification = function openNotification(notification) {
  var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  keys.push(key);
  notification.open(_objectSpread(_objectSpread({
    title: '等候室' + key,
    message: 'ssss、ssss等在等候室',
    duration: 0,
    closable: true,
    placement: 'topLeft',
    onClose: function onClose() {
      console.log('Notification closed');
    },
    onClick: function onClick() {
      console.log('Notification clicked');
    },
    icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.FcrIcon, {
      type: _type.FcrIconType.FCR_WAITING_ROOM,
      size: 40
    }),
    iconStyle: {
      backgroundColor: 'var(--fcr_ui_scene_card2)'
    },
    actions: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
        size: "XXS",
        type: "text",
        styleType: "normal",
        children: "\u4E0D\u518D\u63D0\u793A"
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
        size: "XXS",
        type: "primary",
        styleType: "danger",
        children: "\u62D2\u7EDD"
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
        size: "XXS",
        type: "primary",
        children: "\u540C\u610F"
      })]
    })
  }, config), {}, {
    key: key++
  }));
};
var Basic = exports.Basic = {
  render: function render(_ref) {
    var rootConfig = _ref.rootConfig;
    (0, _react.useEffect)(function () {
      var dom = document.querySelector(".".concat(_.NOTIFICATION_ROOT_CLASS_NAME));
      if (!dom) {
        var div = document.createElement('div');
        div.className = _.NOTIFICATION_ROOT_CLASS_NAME;
        document.body.appendChild(div);
      }
    }, []);
    var _useFcrNotification = (0, _["default"])({
        className: function className(placement) {
          console.log('placement', placement);
          return "fcr-notification-".concat(placement);
        }
      }),
      _useFcrNotification2 = (0, _slicedToArray2["default"])(_useFcrNotification, 2),
      notification = _useFcrNotification2[0],
      contextHolder = _useFcrNotification2[1];
    return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
      style: {
        display: 'flex',
        flexDirection: 'column',
        alignItems: 'center',
        justifyContent: 'center',
        gap: '20px',
        width: '100%',
        height: '100%'
      },
      children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
          size: "S",
          onClick: function onClick() {
            openNotification(notification);
          },
          children: "topLeft"
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
          size: "S",
          onClick: function onClick() {
            openNotification(notification, {
              duration: 10,
              showProgress: true
            });
          },
          children: "topLeft, showProgress"
        })]
      }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
        style: {
          display: 'flex',
          gap: '10px'
        },
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
          size: "S",
          onClick: function onClick() {
            openNotification(notification, {
              placement: 'topRight',
              title: undefined,
              actions: /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
                size: "XXS",
                type: "primary",
                children: "\u67E5\u770B"
              })
            });
          },
          children: "topRight, not title"
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
          size: "S",
          onClick: function onClick() {
            openNotification(notification, {
              placement: 'topRight',
              message: undefined,
              actions: /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
                size: "XXS",
                type: "primary",
                children: "\u67E5\u770B"
              })
            });
          },
          children: "topRight, not message"
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
          size: "S",
          onClick: function onClick() {
            openNotification(notification, {
              placement: 'topRight',
              message: undefined,
              oneline: true,
              closable: false,
              actions: /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
                size: "XXS",
                type: "primary",
                children: "\u67E5\u770B"
              })
            });
          },
          children: "topRight, in one line"
        })]
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
        size: "S",
        type: "secondary-bordered",
        onClick: function onClick() {
          var key = keys.pop();
          key && notification.close(key);
        },
        children: "Close last opened Notification"
      })]
    });
  }
};
var _default = exports["default"] = meta;