PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0
Elementor Website Builder – more than just a page builder v4.3.0
4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 All 455 releases
elementor / assets / js / packages / editor-notifications / editor-notifications.js

editor-notifications.js in Elementor Website Builder – more than just a page builder 4.3.0, at assets/js/packages/editor-notifications/editor-notifications.js

1,656 lines 58.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function(_elementor_editor, _elementor_store, react, react_dom, _elementor_icons, _elementor_ui) {
2
3 //#region \0rolldown/runtime.js
4 var __create = Object.create;
5 var __defProp = Object.defineProperty;
6 var __name = (target, value) => __defProp(target, "name", {
7 value,
8 configurable: true
9 });
10 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11 var __getOwnPropNames = Object.getOwnPropertyNames;
12 var __getProtoOf = Object.getPrototypeOf;
13 var __hasOwnProp = Object.prototype.hasOwnProperty;
14 var __exportAll = (all, no_symbols) => {
15 let target = {};
16 for (var name in all) {
17 __defProp(target, name, {
18 get: all[name],
19 enumerable: true
20 });
21 }
22 if (!no_symbols) {
23 __defProp(target, Symbol.toStringTag, { value: "Module" });
24 }
25 return target;
26 };
27 var __copyProps = (to, from, except, desc) => {
28 if (from && typeof from === "object" || typeof from === "function") {
29 for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
30 key = keys[i];
31 if (!__hasOwnProp.call(to, key) && key !== except) {
32 __defProp(to, key, {
33 get: ((k) => from[k]).bind(null, key),
34 enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
35 });
36 }
37 }
38 }
39 return to;
40 };
41 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
42 value: mod,
43 enumerable: true
44 }) : target, mod));
45
46 //#endregion
47 react = __toESM(react);
48
49 //#region node_modules/notistack/node_modules/clsx/dist/clsx.m.js
50 function r(e) {
51 var t;
52 var f;
53 var n = "";
54 if ("string" == typeof e || "number" == typeof e) n += e;
55 else if ("object" == typeof e) if (Array.isArray(e)) for (t = 0; t < e.length; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
56 else for (t in e) e[t] && (n && (n += " "), n += t);
57 return n;
58 }
59 function clsx() {
60 for (var e, t, f = 0, n = ""; f < arguments.length;) (e = arguments[f++]) && (t = r(e)) && (n && (n += " "), n += t);
61 return n;
62 }
63
64 //#endregion
65 //#region node_modules/goober/dist/goober.modern.js
66 var e = { data: "" };
67 var t = (t) => {
68 if ("object" == typeof window) {
69 let e = (t ? t.querySelector("#_goober") : window._goober) || Object.assign(document.createElement("style"), {
70 innerHTML: " ",
71 id: "_goober"
72 });
73 return e.nonce = window.__nonce__, e.parentNode || (t || document.head).appendChild(e), e.firstChild;
74 }
75 return t || e;
76 };
77 var l = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
78 var a = /\/\*[^]*?\*\/| +/g;
79 var n = /\n+/g;
80 var o = (e, t) => {
81 let r = "";
82 let l = "";
83 let a = "";
84 for (let n in e) {
85 let c = e[n];
86 "@" == n[0] ? "i" == n[1] ? r = n + " " + c + ";" : l += "f" == n[1] ? o(c, n) : n + "{" + o(c, "k" == n[1] ? "" : t) + "}" : "object" == typeof c ? l += o(c, t ? t.replace(/([^,])+/g, (e) => n.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g, (t) => /&/.test(t) ? t.replace(/&/g, e) : e ? e + " " + t : t)) : n) : null != c && (n = /^--/.test(n) ? n : n.replace(/[A-Z]/g, "-$&").toLowerCase(), a += o.p ? o.p(n, c) : n + ":" + c + ";");
87 }
88 return r + (t && a ? t + "{" + a + "}" : a) + l;
89 };
90 var c = {};
91 var s = (e) => {
92 if ("object" == typeof e) {
93 let t = "";
94 for (let r in e) t += r + s(e[r]);
95 return t;
96 }
97 return e;
98 };
99 var i = (e, t, r, i, p) => {
100 let u = s(e);
101 let d = c[u] || (c[u] = ((e) => {
102 let t = 0;
103 let r = 11;
104 for (; t < e.length;) r = 101 * r + e.charCodeAt(t++) >>> 0;
105 return "go" + r;
106 })(u));
107 if (!c[d]) {
108 let t = u !== e ? e : ((e) => {
109 let t;
110 let r;
111 let o = [{}];
112 for (; t = l.exec(e.replace(a, ""));) t[4] ? o.shift() : t[3] ? (r = t[3].replace(n, " ").trim(), o.unshift(o[0][r] = o[0][r] || {})) : o[0][t[1]] = t[2].replace(n, " ").trim();
113 return o[0];
114 })(e);
115 c[d] = o(p ? { ["@keyframes " + d]: t } : t, r ? "" : "." + d);
116 }
117 let f = r && c.g ? c.g : null;
118 return r && (c.g = c[d]), ((e, t, r, l) => {
119 l ? t.data = t.data.replace(l, e) : -1 === t.data.indexOf(e) && (t.data = r ? e + t.data : t.data + e);
120 })(c[d], t, i, f), d;
121 };
122 var p = (e, t, r) => e.reduce((e, l, a) => {
123 let n = t[a];
124 if (n && n.call) {
125 let e = n(r);
126 let t = e && e.props && e.props.className || /^go/.test(e) && e;
127 n = t ? "." + t : e && "object" == typeof e ? e.props ? "" : o(e, "") : !1 === e ? "" : e;
128 }
129 return e + l + (null == n ? "" : n);
130 }, "");
131 function u(e) {
132 let r = this || {};
133 let l = e.call ? e(r.p) : e;
134 return i(l.unshift ? l.raw ? p(l, [].slice.call(arguments, 1), r.p) : l.reduce((e, t) => Object.assign(e, t && t.call ? t(r.p) : t), {}) : l, t(r.target), r.g, r.o, r.k);
135 }
136 var b = u.bind({ g: 1 });
137 var h = u.bind({ k: 1 });
138
139 //#endregion
140 //#region node_modules/notistack/notistack.esm.js
141 function _defineProperties(target, props) {
142 for (var i = 0; i < props.length; i++) {
143 var descriptor = props[i];
144 descriptor.enumerable = descriptor.enumerable || false;
145 descriptor.configurable = true;
146 if ("value" in descriptor) descriptor.writable = true;
147 Object.defineProperty(target, descriptor.key, descriptor);
148 }
149 }
150 function _createClass(Constructor, protoProps, staticProps) {
151 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
152 if (staticProps) _defineProperties(Constructor, staticProps);
153 return Constructor;
154 }
155 function _extends() {
156 _extends = Object.assign || function(target) {
157 for (var i = 1; i < arguments.length; i++) {
158 var source = arguments[i];
159 for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
160 }
161 return target;
162 };
163 return _extends.apply(this, arguments);
164 }
165 function _inheritsLoose(subClass, superClass) {
166 subClass.prototype = Object.create(superClass.prototype);
167 subClass.prototype.constructor = subClass;
168 subClass.__proto__ = superClass;
169 }
170 function _objectWithoutPropertiesLoose(source, excluded) {
171 if (source == null) return {};
172 var target = {};
173 var sourceKeys = Object.keys(source);
174 var key;
175 var i;
176 for (i = 0; i < sourceKeys.length; i++) {
177 key = sourceKeys[i];
178 if (excluded.indexOf(key) >= 0) continue;
179 target[key] = source[key];
180 }
181 return target;
182 }
183 function _assertThisInitialized(self) {
184 if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
185 return self;
186 }
187 var noOp = function noOp() {
188 return "";
189 };
190 var SnackbarContext = /*#__PURE__*/ react.default.createContext({
191 enqueueSnackbar: noOp,
192 closeSnackbar: noOp
193 });
194 var breakpoints = {
195 downXs: "@media (max-width:599.95px)",
196 upSm: "@media (min-width:600px)"
197 };
198 var capitalise = function capitalise(text) {
199 return text.charAt(0).toUpperCase() + text.slice(1);
200 };
201 var originKeyExtractor = function originKeyExtractor(anchor) {
202 return "" + capitalise(anchor.vertical) + capitalise(anchor.horizontal);
203 };
204 var isDefined = function isDefined(value) {
205 return !!value || value === 0;
206 };
207 var UNMOUNTED = "unmounted";
208 var EXITED = "exited";
209 var ENTERING = "entering";
210 var ENTERED = "entered";
211 var EXITING = "exiting";
212 var Transition = /*#__PURE__*/ function(_React$Component) {
213 _inheritsLoose(Transition, _React$Component);
214 function Transition(props) {
215 var _this = _React$Component.call(this, props) || this;
216 var appear = props.appear;
217 var initialStatus;
218 _this.appearStatus = null;
219 if (props["in"]) if (appear) {
220 initialStatus = EXITED;
221 _this.appearStatus = ENTERING;
222 } else initialStatus = ENTERED;
223 else if (props.unmountOnExit || props.mountOnEnter) initialStatus = UNMOUNTED;
224 else initialStatus = EXITED;
225 _this.state = { status: initialStatus };
226 _this.nextCallback = null;
227 return _this;
228 }
229 Transition.getDerivedStateFromProps = function getDerivedStateFromProps(_ref, prevState) {
230 if (_ref["in"] && prevState.status === UNMOUNTED) return { status: EXITED };
231 return null;
232 };
233 var _proto = Transition.prototype;
234 _proto.componentDidMount = function componentDidMount() {
235 this.updateStatus(true, this.appearStatus);
236 };
237 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
238 var nextStatus = null;
239 if (prevProps !== this.props) {
240 var status = this.state.status;
241 if (this.props["in"]) {
242 if (status !== ENTERING && status !== ENTERED) nextStatus = ENTERING;
243 } else if (status === ENTERING || status === ENTERED) nextStatus = EXITING;
244 }
245 this.updateStatus(false, nextStatus);
246 };
247 _proto.componentWillUnmount = function componentWillUnmount() {
248 this.cancelNextCallback();
249 };
250 _proto.getTimeouts = function getTimeouts() {
251 var timeout = this.props.timeout;
252 var enter = timeout;
253 var exit = timeout;
254 if (timeout != null && typeof timeout !== "number" && typeof timeout !== "string") {
255 exit = timeout.exit;
256 enter = timeout.enter;
257 }
258 return {
259 exit,
260 enter
261 };
262 };
263 _proto.updateStatus = function updateStatus(mounting, nextStatus) {
264 if (mounting === void 0) mounting = false;
265 if (nextStatus !== null) {
266 this.cancelNextCallback();
267 if (nextStatus === ENTERING) this.performEnter(mounting);
268 else this.performExit();
269 } else if (this.props.unmountOnExit && this.state.status === EXITED) this.setState({ status: UNMOUNTED });
270 };
271 _proto.performEnter = function performEnter(mounting) {
272 var _this2 = this;
273 var enter = this.props.enter;
274 var isAppearing = mounting;
275 var timeouts = this.getTimeouts();
276 if (!mounting && !enter) {
277 this.safeSetState({ status: ENTERED }, function() {
278 if (_this2.props.onEntered) _this2.props.onEntered(_this2.node, isAppearing);
279 });
280 return;
281 }
282 if (this.props.onEnter) this.props.onEnter(this.node, isAppearing);
283 this.safeSetState({ status: ENTERING }, function() {
284 if (_this2.props.onEntering) _this2.props.onEntering(_this2.node, isAppearing);
285 _this2.onTransitionEnd(timeouts.enter, function() {
286 _this2.safeSetState({ status: ENTERED }, function() {
287 if (_this2.props.onEntered) _this2.props.onEntered(_this2.node, isAppearing);
288 });
289 });
290 });
291 };
292 _proto.performExit = function performExit() {
293 var _this3 = this;
294 var exit = this.props.exit;
295 var timeouts = this.getTimeouts();
296 if (!exit) {
297 this.safeSetState({ status: EXITED }, function() {
298 if (_this3.props.onExited) _this3.props.onExited(_this3.node);
299 });
300 return;
301 }
302 if (this.props.onExit) this.props.onExit(this.node);
303 this.safeSetState({ status: EXITING }, function() {
304 if (_this3.props.onExiting) _this3.props.onExiting(_this3.node);
305 _this3.onTransitionEnd(timeouts.exit, function() {
306 _this3.safeSetState({ status: EXITED }, function() {
307 if (_this3.props.onExited) _this3.props.onExited(_this3.node);
308 });
309 });
310 });
311 };
312 _proto.cancelNextCallback = function cancelNextCallback() {
313 if (this.nextCallback !== null && this.nextCallback.cancel) {
314 this.nextCallback.cancel();
315 this.nextCallback = null;
316 }
317 };
318 _proto.safeSetState = function safeSetState(nextState, callback) {
319 callback = this.setNextCallback(callback);
320 this.setState(nextState, callback);
321 };
322 _proto.setNextCallback = function setNextCallback(callback) {
323 var _this4 = this;
324 var active = true;
325 this.nextCallback = function() {
326 if (active) {
327 active = false;
328 _this4.nextCallback = null;
329 callback();
330 }
331 };
332 this.nextCallback.cancel = function() {
333 active = false;
334 };
335 return this.nextCallback;
336 };
337 _proto.onTransitionEnd = function onTransitionEnd(timeout, handler) {
338 this.setNextCallback(handler);
339 var doesNotHaveTimeoutOrListener = timeout == null && !this.props.addEndListener;
340 if (!this.node || doesNotHaveTimeoutOrListener) {
341 setTimeout(this.nextCallback, 0);
342 return;
343 }
344 if (this.props.addEndListener) this.props.addEndListener(this.node, this.nextCallback);
345 if (timeout != null) setTimeout(this.nextCallback, timeout);
346 };
347 _proto.render = function render() {
348 var status = this.state.status;
349 if (status === UNMOUNTED) return null;
350 var _this$props = this.props;
351 var children = _this$props.children;
352 return children(status, _objectWithoutPropertiesLoose(_this$props, [
353 "children",
354 "in",
355 "mountOnEnter",
356 "unmountOnExit",
357 "appear",
358 "enter",
359 "exit",
360 "timeout",
361 "addEndListener",
362 "onEnter",
363 "onEntering",
364 "onEntered",
365 "onExit",
366 "onExiting",
367 "onExited",
368 "nodeRef"
369 ]));
370 };
371 _createClass(Transition, [{
372 key: "node",
373 get: function get() {
374 var _this$props$nodeRef;
375 var node = (_this$props$nodeRef = this.props.nodeRef) === null || _this$props$nodeRef === void 0 ? void 0 : _this$props$nodeRef.current;
376 if (!node) throw new Error("notistack - Custom snackbar is not refForwarding");
377 return node;
378 }
379 }]);
380 return Transition;
381 }(react.default.Component);
382 function noop() {}
383 Transition.defaultProps = {
384 "in": false,
385 mountOnEnter: false,
386 unmountOnExit: false,
387 appear: false,
388 enter: true,
389 exit: true,
390 onEnter: noop,
391 onEntering: noop,
392 onEntered: noop,
393 onExit: noop,
394 onExiting: noop,
395 onExited: noop
396 };
397 /**
398 * Credit to MUI team @ https://mui.com
399 */
400 /**
401 * passes {value} to {ref}
402 *
403 * Useful if you want to expose the ref of an inner component to the public API
404 * while still using it inside the component.
405 * @param ref A ref callback or ref object. If anything falsy, this is a no-op.
406 */
407 function setRef(ref, value) {
408 if (typeof ref === "function") ref(value);
409 else if (ref) ref.current = value;
410 }
411 function useForkRef(refA, refB) {
412 /**
413 * This will create a new function if the ref props change and are defined.
414 * This means react will call the old forkRef with `null` and the new forkRef
415 * with the ref. Cleanup naturally emerges from this behavior.
416 */
417 return (0, react.useMemo)(function() {
418 if (refA == null && refB == null) return null;
419 return function(refValue) {
420 setRef(refA, refValue);
421 setRef(refB, refValue);
422 };
423 }, [refA, refB]);
424 }
425 function getTransitionProps(props) {
426 var timeout = props.timeout;
427 var _props$style = props.style;
428 var style = _props$style === void 0 ? {} : _props$style;
429 var mode = props.mode;
430 return {
431 duration: typeof timeout === "object" ? timeout[mode] || 0 : timeout,
432 easing: style.transitionTimingFunction,
433 delay: style.transitionDelay
434 };
435 }
436 /**
437 * Credit to MUI team @ https://mui.com
438 */
439 var defaultEasing = {
440 easeInOut: "cubic-bezier(0.4, 0, 0.2, 1)",
441 easeOut: "cubic-bezier(0.0, 0, 0.2, 1)",
442 easeIn: "cubic-bezier(0.4, 0, 1, 1)",
443 sharp: "cubic-bezier(0.4, 0, 0.6, 1)"
444 };
445 /**
446 * CSS hack to force a repaint
447 */
448 var reflow = function reflow(node) {
449 node.scrollTop = node.scrollTop;
450 };
451 var formatMs = function formatMs(milliseconds) {
452 return Math.round(milliseconds) + "ms";
453 };
454 function createTransition(props, options) {
455 if (props === void 0) props = ["all"];
456 var _ref = options || {};
457 var _ref$duration = _ref.duration;
458 var duration = _ref$duration === void 0 ? 300 : _ref$duration;
459 var _ref$easing = _ref.easing;
460 var easing = _ref$easing === void 0 ? defaultEasing.easeInOut : _ref$easing;
461 var _ref$delay = _ref.delay;
462 var delay = _ref$delay === void 0 ? 0 : _ref$delay;
463 return (Array.isArray(props) ? props : [props]).map(function(animatedProp) {
464 var formattedDuration = typeof duration === "string" ? duration : formatMs(duration);
465 var formattedDelay = typeof delay === "string" ? delay : formatMs(delay);
466 return animatedProp + " " + formattedDuration + " " + easing + " " + formattedDelay;
467 }).join(",");
468 }
469 function ownerDocument(node) {
470 return node && node.ownerDocument || document;
471 }
472 function ownerWindow(node) {
473 return ownerDocument(node).defaultView || window;
474 }
475 /**
476 * Corresponds to 10 frames at 60 Hz.
477 * A few bytes payload overhead when lodash/debounce is ~3 kB and debounce ~300 B.
478 */
479 function debounce(func, wait) {
480 if (wait === void 0) wait = 166;
481 var timeout;
482 function debounced() {
483 var _this = this;
484 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
485 var later = function later() {
486 func.apply(_this, args);
487 };
488 clearTimeout(timeout);
489 timeout = setTimeout(later, wait);
490 }
491 debounced.clear = function() {
492 clearTimeout(timeout);
493 };
494 return debounced;
495 }
496 /**
497 * Translate the node so it can't be seen on the screen.
498 * Later, we're going to translate the node back to its original location with `none`.
499 */
500 function getTranslateValue(direction, node) {
501 var rect = node.getBoundingClientRect();
502 var containerWindow = ownerWindow(node);
503 var transform;
504 if (node.fakeTransform) transform = node.fakeTransform;
505 else {
506 var computedStyle = containerWindow.getComputedStyle(node);
507 transform = computedStyle.getPropertyValue("-webkit-transform") || computedStyle.getPropertyValue("transform");
508 }
509 var offsetX = 0;
510 var offsetY = 0;
511 if (transform && transform !== "none" && typeof transform === "string") {
512 var transformValues = transform.split("(")[1].split(")")[0].split(",");
513 offsetX = parseInt(transformValues[4], 10);
514 offsetY = parseInt(transformValues[5], 10);
515 }
516 switch (direction) {
517 case "left": return "translateX(" + (containerWindow.innerWidth + offsetX - rect.left) + "px)";
518 case "right": return "translateX(-" + (rect.left + rect.width - offsetX) + "px)";
519 case "up": return "translateY(" + (containerWindow.innerHeight + offsetY - rect.top) + "px)";
520 default: return "translateY(-" + (rect.top + rect.height - offsetY) + "px)";
521 }
522 }
523 function setTranslateValue(direction, node) {
524 if (!node) return;
525 var transform = getTranslateValue(direction, node);
526 if (transform) {
527 node.style.webkitTransform = transform;
528 node.style.transform = transform;
529 }
530 }
531 var Slide = /*#__PURE__*/ (0, react.forwardRef)(function(props, ref) {
532 var children = props.children;
533 var _props$direction = props.direction;
534 var direction = _props$direction === void 0 ? "down" : _props$direction;
535 var inProp = props["in"];
536 var style = props.style;
537 var _props$timeout = props.timeout;
538 var timeout = _props$timeout === void 0 ? 0 : _props$timeout;
539 var onEnter = props.onEnter;
540 var onEntered = props.onEntered;
541 var onExit = props.onExit;
542 var onExited = props.onExited;
543 var other = _objectWithoutPropertiesLoose(props, [
544 "children",
545 "direction",
546 "in",
547 "style",
548 "timeout",
549 "onEnter",
550 "onEntered",
551 "onExit",
552 "onExited"
553 ]);
554 var nodeRef = (0, react.useRef)(null);
555 var handleRef = useForkRef(useForkRef(children.ref, nodeRef), ref);
556 var handleEnter = function handleEnter(node, isAppearing) {
557 setTranslateValue(direction, node);
558 reflow(node);
559 if (onEnter) onEnter(node, isAppearing);
560 };
561 var handleEntering = function handleEntering(node) {
562 var easing = (style === null || style === void 0 ? void 0 : style.transitionTimingFunction) || defaultEasing.easeOut;
563 var transitionProps = getTransitionProps({
564 timeout,
565 mode: "enter",
566 style: _extends({}, style, { transitionTimingFunction: easing })
567 });
568 node.style.webkitTransition = createTransition("-webkit-transform", transitionProps);
569 node.style.transition = createTransition("transform", transitionProps);
570 node.style.webkitTransform = "none";
571 node.style.transform = "none";
572 };
573 var handleExit = function handleExit(node) {
574 var easing = (style === null || style === void 0 ? void 0 : style.transitionTimingFunction) || defaultEasing.sharp;
575 var transitionProps = getTransitionProps({
576 timeout,
577 mode: "exit",
578 style: _extends({}, style, { transitionTimingFunction: easing })
579 });
580 node.style.webkitTransition = createTransition("-webkit-transform", transitionProps);
581 node.style.transition = createTransition("transform", transitionProps);
582 setTranslateValue(direction, node);
583 if (onExit) onExit(node);
584 };
585 var handleExited = function handleExited(node) {
586 node.style.webkitTransition = "";
587 node.style.transition = "";
588 if (onExited) onExited(node);
589 };
590 var updatePosition = (0, react.useCallback)(function() {
591 if (nodeRef.current) setTranslateValue(direction, nodeRef.current);
592 }, [direction]);
593 (0, react.useEffect)(function() {
594 if (inProp || direction === "down" || direction === "right") return;
595 var handleResize = debounce(function() {
596 if (nodeRef.current) setTranslateValue(direction, nodeRef.current);
597 });
598 var containerWindow = ownerWindow(nodeRef.current);
599 containerWindow.addEventListener("resize", handleResize);
600 return function() {
601 handleResize.clear();
602 containerWindow.removeEventListener("resize", handleResize);
603 };
604 }, [direction, inProp]);
605 (0, react.useEffect)(function() {
606 if (!inProp) updatePosition();
607 }, [inProp, updatePosition]);
608 return (0, react.createElement)(Transition, Object.assign({
609 appear: true,
610 nodeRef,
611 onEnter: handleEnter,
612 onEntered,
613 onEntering: handleEntering,
614 onExit: handleExit,
615 onExited: handleExited,
616 "in": inProp,
617 timeout
618 }, other), function(state, childProps) {
619 return (0, react.cloneElement)(children, _extends({
620 ref: handleRef,
621 style: _extends({ visibility: state === "exited" && !inProp ? "hidden" : void 0 }, style, {}, children.props.style)
622 }, childProps));
623 });
624 });
625 Slide.displayName = "Slide";
626 var SvgIcon = function SvgIcon(props) {
627 return react.default.createElement("svg", Object.assign({
628 viewBox: "0 0 24 24",
629 focusable: "false",
630 style: {
631 fontSize: 20,
632 marginInlineEnd: 8,
633 userSelect: "none",
634 width: "1em",
635 height: "1em",
636 display: "inline-block",
637 fill: "currentColor",
638 flexShrink: 0
639 }
640 }, props));
641 };
642 var defaults = {
643 maxSnack: 3,
644 persist: false,
645 hideIconVariant: false,
646 disableWindowBlurListener: false,
647 variant: "default",
648 autoHideDuration: 5e3,
649 iconVariant: {
650 "default": void 0,
651 success: /*#__PURE__*/ react.default.createElement(function CheckIcon() {
652 return react.default.createElement(SvgIcon, null, react.default.createElement("path", { d: "M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M10 17L5 12L6.41\n 10.59L10 14.17L17.59 6.58L19 8L10 17Z" }));
653 }, null),
654 warning: /*#__PURE__*/ react.default.createElement(function WarningIcon() {
655 return react.default.createElement(SvgIcon, null, react.default.createElement("path", { d: "M13,14H11V10H13M13,18H11V16H13M1,21H23L12,2L1,21Z" }));
656 }, null),
657 error: /*#__PURE__*/ react.default.createElement(function ErrorIcon() {
658 return react.default.createElement(SvgIcon, null, react.default.createElement("path", { d: "M12,2C17.53,2 22,6.47 22,12C22,17.53 17.53,22 12,22C6.47,22 2,17.53 2,12C2,\n 6.47 6.47,2 12,2M15.59,7L12,10.59L8.41,7L7,8.41L10.59,12L7,15.59L8.41,17L12,\n 13.41L15.59,17L17,15.59L13.41,12L17,8.41L15.59,7Z" }));
659 }, null),
660 info: /*#__PURE__*/ react.default.createElement(function InfoIcon() {
661 return react.default.createElement(SvgIcon, null, react.default.createElement("path", { d: "M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,\n 0 22,12A10,10 0 0,0 12,2Z" }));
662 }, null)
663 },
664 anchorOrigin: {
665 vertical: "bottom",
666 horizontal: "left"
667 },
668 TransitionComponent: Slide,
669 transitionDuration: {
670 enter: 225,
671 exit: 195
672 }
673 };
674 /**
675 * Derives the right autoHideDuration taking into account the following
676 * prority order: 1: Options, 2: Props, 3: default fallback
677 */
678 var getAutoHideDuration = function getAutoHideDuration(optionsDuration, propsDuration) {
679 var isNumberOrNull = function isNumberOrNull(numberish) {
680 return typeof numberish === "number" || numberish === null;
681 };
682 if (isNumberOrNull(optionsDuration)) return optionsDuration;
683 if (isNumberOrNull(propsDuration)) return propsDuration;
684 return defaults.autoHideDuration;
685 };
686 /**
687 * Derives the right transitionDuration taking into account the following
688 * prority order: 1: Options, 2: Props, 3: default fallback
689 */
690 var getTransitionDuration = function getTransitionDuration(optionsDuration, propsDuration) {
691 var is = function is(item, types) {
692 return types.some(function(t) {
693 return typeof item === t;
694 });
695 };
696 if (is(optionsDuration, ["string", "number"])) return optionsDuration;
697 if (is(optionsDuration, ["object"])) return _extends({}, defaults.transitionDuration, {}, is(propsDuration, ["object"]) && propsDuration, {}, optionsDuration);
698 if (is(propsDuration, ["string", "number"])) return propsDuration;
699 if (is(propsDuration, ["object"])) return _extends({}, defaults.transitionDuration, {}, propsDuration);
700 return defaults.transitionDuration;
701 };
702 var merge = function merge(options, props) {
703 return function(name, shouldObjectMerge) {
704 if (shouldObjectMerge === void 0) shouldObjectMerge = false;
705 if (shouldObjectMerge) return _extends({}, defaults[name], {}, props[name], {}, options[name]);
706 if (name === "autoHideDuration") return getAutoHideDuration(options.autoHideDuration, props.autoHideDuration);
707 if (name === "transitionDuration") return getTransitionDuration(options.transitionDuration, props.transitionDuration);
708 return options[name] || props[name] || defaults[name];
709 };
710 };
711 function makeStyles(styles) {
712 return Object.entries(styles).reduce(function(acc, _ref) {
713 var _extends2;
714 var key = _ref[0];
715 var value = _ref[1];
716 return _extends({}, acc, (_extends2 = {}, _extends2[key] = u(value), _extends2));
717 }, {});
718 }
719 var ComponentClasses = {
720 SnackbarContainer: "notistack-SnackbarContainer",
721 Snackbar: "notistack-Snackbar",
722 CollapseWrapper: "notistack-CollapseWrapper",
723 MuiContent: "notistack-MuiContent",
724 MuiContentVariant: function MuiContentVariant(variant) {
725 return "notistack-MuiContent-" + variant;
726 }
727 };
728 var classes = /*#__PURE__*/ makeStyles({
729 root: { height: 0 },
730 entered: { height: "auto" }
731 });
732 var collapsedSize = "0px";
733 var timeout = 175;
734 var Collapse = /*#__PURE__*/ (0, react.forwardRef)(function(props, ref) {
735 var children = props.children;
736 var inProp = props["in"];
737 var onExited = props.onExited;
738 var wrapperRef = (0, react.useRef)(null);
739 var nodeRef = (0, react.useRef)(null);
740 var handleRef = useForkRef(ref, nodeRef);
741 var getWrapperSize = function getWrapperSize() {
742 return wrapperRef.current ? wrapperRef.current.clientHeight : 0;
743 };
744 return (0, react.createElement)(Transition, {
745 "in": inProp,
746 unmountOnExit: true,
747 onEnter: function handleEnter(node) {
748 node.style.height = collapsedSize;
749 },
750 onEntered: function handleEntered(node) {
751 node.style.height = "auto";
752 },
753 onEntering: function handleEntering(node) {
754 var wrapperSize = getWrapperSize();
755 var _getTransitionProps = getTransitionProps({
756 timeout,
757 mode: "enter"
758 });
759 var transitionDuration = _getTransitionProps.duration;
760 var easing = _getTransitionProps.easing;
761 node.style.transitionDuration = typeof transitionDuration === "string" ? transitionDuration : transitionDuration + "ms";
762 node.style.height = wrapperSize + "px";
763 node.style.transitionTimingFunction = easing || "";
764 },
765 onExit: function handleExit(node) {
766 node.style.height = getWrapperSize() + "px";
767 },
768 onExited,
769 onExiting: function handleExiting(node) {
770 reflow(node);
771 var _getTransitionProps2 = getTransitionProps({
772 timeout,
773 mode: "exit"
774 });
775 var transitionDuration = _getTransitionProps2.duration;
776 var easing = _getTransitionProps2.easing;
777 node.style.transitionDuration = typeof transitionDuration === "string" ? transitionDuration : transitionDuration + "ms";
778 node.style.height = collapsedSize;
779 node.style.transitionTimingFunction = easing || "";
780 },
781 nodeRef,
782 timeout
783 }, function(state, childProps) {
784 return (0, react.createElement)("div", Object.assign({
785 ref: handleRef,
786 className: clsx(classes.root, state === "entered" && classes.entered),
787 style: _extends({
788 pointerEvents: "all",
789 overflow: "hidden",
790 minHeight: collapsedSize,
791 transition: createTransition("height")
792 }, state === "entered" && { overflow: "visible" }, {}, state === "exited" && !inProp && { visibility: "hidden" })
793 }, childProps), (0, react.createElement)("div", {
794 ref: wrapperRef,
795 className: ComponentClasses.CollapseWrapper,
796 style: {
797 display: "flex",
798 width: "100%"
799 }
800 }, children));
801 });
802 });
803 Collapse.displayName = "Collapse";
804 var direction = {
805 right: "left",
806 left: "right",
807 bottom: "up",
808 top: "down"
809 };
810 var getSlideDirection = function getSlideDirection(anchorOrigin) {
811 if (anchorOrigin.horizontal !== "center") return direction[anchorOrigin.horizontal];
812 return direction[anchorOrigin.vertical];
813 };
814 /** Tranforms classes name */
815 var toSnackbarAnchorOrigin = function toSnackbarAnchorOrigin(anchorOrigin) {
816 return "anchorOrigin" + originKeyExtractor(anchorOrigin);
817 };
818 /**
819 * Omit SnackbarContainer class keys that are not needed for SnackbarItem
820 */
821 var keepSnackbarClassKeys = function keepSnackbarClassKeys(classes) {
822 if (classes === void 0) classes = {};
823 var containerClasses = {
824 containerRoot: true,
825 containerAnchorOriginTopCenter: true,
826 containerAnchorOriginBottomCenter: true,
827 containerAnchorOriginTopRight: true,
828 containerAnchorOriginBottomRight: true,
829 containerAnchorOriginTopLeft: true,
830 containerAnchorOriginBottomLeft: true
831 };
832 return Object.keys(classes).filter(function(key) {
833 return !containerClasses[key];
834 }).reduce(function(obj, key) {
835 var _extends2;
836 return _extends({}, obj, (_extends2 = {}, _extends2[key] = classes[key], _extends2));
837 }, {});
838 };
839 var noOp$1 = function noOp() {};
840 /**
841 * Credit to MUI team @ https://mui.com
842 * Safe chained function.
843 *
844 * Will only create a new function if needed,
845 * otherwise will pass back existing functions or null.
846 */
847 function createChainedFunction(funcs, snackbarId) {
848 return funcs.reduce(function(acc, func) {
849 if (func === null || func === void 0) return acc;
850 return function chainedFunction() {
851 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
852 var argums = [].concat(args);
853 if (snackbarId && argums.indexOf(snackbarId) === -1) argums.push(snackbarId);
854 acc.apply(this, argums);
855 func.apply(this, argums);
856 };
857 }, noOp$1);
858 }
859 /**
860 * Credit to MUI team @ https://mui.com
861 * https://github.com/facebook/react/issues/14099#issuecomment-440013892
862 */
863 var useEnhancedEffect = typeof window !== "undefined" ? react.useLayoutEffect : react.useEffect;
864 function useEventCallback(fn) {
865 var ref = (0, react.useRef)(fn);
866 useEnhancedEffect(function() {
867 ref.current = fn;
868 });
869 return (0, react.useCallback)(function() {
870 return ref.current.apply(void 0, arguments);
871 }, []);
872 }
873 /**
874 * Credit to MUI team @ https://mui.com
875 */
876 var Snackbar = /*#__PURE__*/ (0, react.forwardRef)(function(props, ref) {
877 var children = props.children;
878 var className = props.className;
879 var autoHideDuration = props.autoHideDuration;
880 var _props$disableWindowB = props.disableWindowBlurListener;
881 var disableWindowBlurListener = _props$disableWindowB === void 0 ? false : _props$disableWindowB;
882 var onClose = props.onClose;
883 var id = props.id;
884 var open = props.open;
885 var _props$SnackbarProps = props.SnackbarProps;
886 var SnackbarProps = _props$SnackbarProps === void 0 ? {} : _props$SnackbarProps;
887 var timerAutoHide = (0, react.useRef)();
888 var handleClose = useEventCallback(function() {
889 if (onClose) onClose.apply(void 0, arguments);
890 });
891 var setAutoHideTimer = useEventCallback(function(autoHideDurationParam) {
892 if (!onClose || autoHideDurationParam == null) return;
893 if (timerAutoHide.current) clearTimeout(timerAutoHide.current);
894 timerAutoHide.current = setTimeout(function() {
895 handleClose(null, "timeout", id);
896 }, autoHideDurationParam);
897 });
898 (0, react.useEffect)(function() {
899 if (open) setAutoHideTimer(autoHideDuration);
900 return function() {
901 if (timerAutoHide.current) clearTimeout(timerAutoHide.current);
902 };
903 }, [
904 open,
905 autoHideDuration,
906 setAutoHideTimer
907 ]);
908 /**
909 * Pause the timer when the user is interacting with the Snackbar
910 * or when the user hide the window.
911 */
912 var handlePause = function handlePause() {
913 if (timerAutoHide.current) clearTimeout(timerAutoHide.current);
914 };
915 /**
916 * Restart the timer when the user is no longer interacting with the Snackbar
917 * or when the window is shown back.
918 */
919 var handleResume = (0, react.useCallback)(function() {
920 if (autoHideDuration != null) setAutoHideTimer(autoHideDuration * .5);
921 }, [autoHideDuration, setAutoHideTimer]);
922 var handleMouseEnter = function handleMouseEnter(event) {
923 if (SnackbarProps.onMouseEnter) SnackbarProps.onMouseEnter(event);
924 handlePause();
925 };
926 var handleMouseLeave = function handleMouseLeave(event) {
927 if (SnackbarProps.onMouseLeave) SnackbarProps.onMouseLeave(event);
928 handleResume();
929 };
930 (0, react.useEffect)(function() {
931 if (!disableWindowBlurListener && open) {
932 window.addEventListener("focus", handleResume);
933 window.addEventListener("blur", handlePause);
934 return function() {
935 window.removeEventListener("focus", handleResume);
936 window.removeEventListener("blur", handlePause);
937 };
938 }
939 }, [
940 disableWindowBlurListener,
941 handleResume,
942 open
943 ]);
944 return (0, react.createElement)("div", Object.assign({ ref }, SnackbarProps, {
945 className: clsx(ComponentClasses.Snackbar, className),
946 onMouseEnter: handleMouseEnter,
947 onMouseLeave: handleMouseLeave
948 }), children);
949 });
950 Snackbar.displayName = "Snackbar";
951 var _root;
952 var classes$1 = /*#__PURE__*/ makeStyles({ root: (_root = {
953 display: "flex",
954 flexWrap: "wrap",
955 flexGrow: 1
956 }, _root[breakpoints.upSm] = {
957 flexGrow: "initial",
958 minWidth: "288px"
959 }, _root) });
960 var SnackbarContent$1 = /*#__PURE__*/ (0, react.forwardRef)(function(_ref, ref) {
961 var className = _ref.className;
962 var props = _objectWithoutPropertiesLoose(_ref, ["className"]);
963 return react.default.createElement("div", Object.assign({
964 ref,
965 className: clsx(classes$1.root, className)
966 }, props));
967 });
968 SnackbarContent$1.displayName = "SnackbarContent";
969 var classes$2 = /*#__PURE__*/ makeStyles({
970 root: {
971 backgroundColor: "#313131",
972 fontSize: "0.875rem",
973 lineHeight: 1.43,
974 letterSpacing: "0.01071em",
975 color: "#fff",
976 alignItems: "center",
977 padding: "6px 16px",
978 borderRadius: "4px",
979 boxShadow: "0px 3px 5px -1px rgba(0,0,0,0.2),0px 6px 10px 0px rgba(0,0,0,0.14),0px 1px 18px 0px rgba(0,0,0,0.12)"
980 },
981 lessPadding: { paddingLeft: "20px" },
982 "default": { backgroundColor: "#313131" },
983 success: { backgroundColor: "#43a047" },
984 error: { backgroundColor: "#d32f2f" },
985 warning: { backgroundColor: "#ff9800" },
986 info: { backgroundColor: "#2196f3" },
987 message: {
988 display: "flex",
989 alignItems: "center",
990 padding: "8px 0"
991 },
992 action: {
993 display: "flex",
994 alignItems: "center",
995 marginLeft: "auto",
996 paddingLeft: "16px",
997 marginRight: "-8px"
998 }
999 });
1000 var ariaDescribedby = "notistack-snackbar";
1001 var MaterialDesignContent = /*#__PURE__*/ (0, react.forwardRef)(function(props, forwardedRef) {
1002 var id = props.id;
1003 var message = props.message;
1004 var componentOrFunctionAction = props.action;
1005 var iconVariant = props.iconVariant;
1006 var variant = props.variant;
1007 var hideIconVariant = props.hideIconVariant;
1008 var style = props.style;
1009 var className = props.className;
1010 var icon = iconVariant[variant];
1011 var action = componentOrFunctionAction;
1012 if (typeof action === "function") action = action(id);
1013 return react.default.createElement(SnackbarContent$1, {
1014 ref: forwardedRef,
1015 role: "alert",
1016 "aria-describedby": ariaDescribedby,
1017 style,
1018 className: clsx(ComponentClasses.MuiContent, ComponentClasses.MuiContentVariant(variant), classes$2.root, classes$2[variant], className, !hideIconVariant && icon && classes$2.lessPadding)
1019 }, react.default.createElement("div", {
1020 id: ariaDescribedby,
1021 className: classes$2.message
1022 }, !hideIconVariant ? icon : null, message), action && react.default.createElement("div", { className: classes$2.action }, action));
1023 });
1024 MaterialDesignContent.displayName = "MaterialDesignContent";
1025 var MaterialDesignContent$1 = /*#__PURE__*/ (0, react.memo)(MaterialDesignContent);
1026 var styles = /*#__PURE__*/ makeStyles({ wrappedRoot: {
1027 width: "100%",
1028 position: "relative",
1029 transform: "translateX(0)",
1030 top: 0,
1031 right: 0,
1032 bottom: 0,
1033 left: 0,
1034 minWidth: "288px"
1035 } });
1036 var SnackbarItem = function SnackbarItem(props) {
1037 var timeout = (0, react.useRef)();
1038 var _useState = (0, react.useState)(true);
1039 var collapsed = _useState[0];
1040 var setCollapsed = _useState[1];
1041 var handleClose = createChainedFunction([props.snack.onClose, props.onClose]);
1042 var handleEntered = function handleEntered() {
1043 if (props.snack.requestClose) handleClose(null, "instructed", props.snack.id);
1044 };
1045 var handleExitedScreen = (0, react.useCallback)(function() {
1046 timeout.current = setTimeout(function() {
1047 setCollapsed(function(col) {
1048 return !col;
1049 });
1050 }, 125);
1051 }, []);
1052 (0, react.useEffect)(function() {
1053 return function() {
1054 if (timeout.current) clearTimeout(timeout.current);
1055 };
1056 }, []);
1057 var snack = props.snack;
1058 var allClasses = props.classes;
1059 var _props$Component = props.Component;
1060 var Component = _props$Component === void 0 ? MaterialDesignContent$1 : _props$Component;
1061 var classes = (0, react.useMemo)(function() {
1062 return keepSnackbarClassKeys(allClasses);
1063 }, [allClasses]);
1064 var open = snack.open;
1065 var SnackbarProps = snack.SnackbarProps;
1066 var TransitionComponent = snack.TransitionComponent;
1067 var TransitionProps = snack.TransitionProps;
1068 var transitionDuration = snack.transitionDuration;
1069 var disableWindowBlurListener = snack.disableWindowBlurListener;
1070 var componentOrFunctionContent = snack.content;
1071 var otherSnack = _objectWithoutPropertiesLoose(snack, [
1072 "open",
1073 "SnackbarProps",
1074 "TransitionComponent",
1075 "TransitionProps",
1076 "transitionDuration",
1077 "disableWindowBlurListener",
1078 "content",
1079 "entered",
1080 "requestClose",
1081 "onEnter",
1082 "onEntered",
1083 "onExit",
1084 "onExited"
1085 ]);
1086 var transitionProps = _extends({
1087 direction: getSlideDirection(otherSnack.anchorOrigin),
1088 timeout: transitionDuration
1089 }, TransitionProps);
1090 var content = componentOrFunctionContent;
1091 if (typeof content === "function") content = content(otherSnack.id, otherSnack.message);
1092 var callbacks = [
1093 "onEnter",
1094 "onEntered",
1095 "onExit",
1096 "onExited"
1097 ].reduce(function(acc, cbName) {
1098 var _extends2;
1099 return _extends({}, acc, (_extends2 = {}, _extends2[cbName] = createChainedFunction([props.snack[cbName], props[cbName]], otherSnack.id), _extends2));
1100 }, {});
1101 return react.default.createElement(Collapse, {
1102 "in": collapsed,
1103 onExited: callbacks.onExited
1104 }, react.default.createElement(Snackbar, {
1105 open,
1106 id: otherSnack.id,
1107 disableWindowBlurListener,
1108 autoHideDuration: otherSnack.autoHideDuration,
1109 className: clsx(styles.wrappedRoot, classes.root, classes[toSnackbarAnchorOrigin(otherSnack.anchorOrigin)]),
1110 SnackbarProps,
1111 onClose: handleClose
1112 }, react.default.createElement(TransitionComponent, Object.assign({}, transitionProps, {
1113 appear: true,
1114 "in": open,
1115 onExit: callbacks.onExit,
1116 onExited: handleExitedScreen,
1117 onEnter: callbacks.onEnter,
1118 onEntered: createChainedFunction([callbacks.onEntered, handleEntered], otherSnack.id)
1119 }), content || react.default.createElement(Component, Object.assign({}, otherSnack)))));
1120 };
1121 var _root$1;
1122 var _rootDense;
1123 var _left;
1124 var _right;
1125 var _center;
1126 var indents = {
1127 view: {
1128 "default": 20,
1129 dense: 4
1130 },
1131 snackbar: {
1132 "default": 6,
1133 dense: 2
1134 }
1135 };
1136 var collapseWrapper = "." + ComponentClasses.CollapseWrapper;
1137 var xsWidthMargin = 16;
1138 var styles$1 = /*#__PURE__*/ makeStyles({
1139 root: (_root$1 = {
1140 boxSizing: "border-box",
1141 display: "flex",
1142 maxHeight: "100%",
1143 position: "fixed",
1144 zIndex: 1400,
1145 height: "auto",
1146 width: "auto",
1147 transition: /*#__PURE__*/ createTransition([
1148 "top",
1149 "right",
1150 "bottom",
1151 "left",
1152 "max-width"
1153 ], {
1154 duration: 300,
1155 easing: "ease"
1156 }),
1157 pointerEvents: "none"
1158 }, _root$1[collapseWrapper] = {
1159 padding: indents.snackbar["default"] + "px 0px",
1160 transition: "padding 300ms ease 0ms"
1161 }, _root$1.maxWidth = "calc(100% - " + indents.view["default"] * 2 + "px)", _root$1[breakpoints.downXs] = {
1162 width: "100%",
1163 maxWidth: "calc(100% - " + xsWidthMargin * 2 + "px)"
1164 }, _root$1),
1165 rootDense: (_rootDense = {}, _rootDense[collapseWrapper] = { padding: indents.snackbar.dense + "px 0px" }, _rootDense),
1166 top: {
1167 top: indents.view["default"] - indents.snackbar["default"] + "px",
1168 flexDirection: "column"
1169 },
1170 bottom: {
1171 bottom: indents.view["default"] - indents.snackbar["default"] + "px",
1172 flexDirection: "column-reverse"
1173 },
1174 left: (_left = { left: indents.view["default"] + "px" }, _left[breakpoints.upSm] = { alignItems: "flex-start" }, _left[breakpoints.downXs] = { left: xsWidthMargin + "px" }, _left),
1175 right: (_right = { right: indents.view["default"] + "px" }, _right[breakpoints.upSm] = { alignItems: "flex-end" }, _right[breakpoints.downXs] = { right: xsWidthMargin + "px" }, _right),
1176 center: (_center = {
1177 left: "50%",
1178 transform: "translateX(-50%)"
1179 }, _center[breakpoints.upSm] = { alignItems: "center" }, _center)
1180 });
1181 var SnackbarContainer$1 = /*#__PURE__*/ (0, react.memo)(function SnackbarContainer(props) {
1182 var _props$classes = props.classes;
1183 var classes = _props$classes === void 0 ? {} : _props$classes;
1184 var anchorOrigin = props.anchorOrigin;
1185 var dense = props.dense;
1186 var children = props.children;
1187 var combinedClassname = clsx(ComponentClasses.SnackbarContainer, styles$1[anchorOrigin.vertical], styles$1[anchorOrigin.horizontal], styles$1.root, classes.containerRoot, classes["containerAnchorOrigin" + originKeyExtractor(anchorOrigin)], dense && styles$1.rootDense);
1188 return react.default.createElement("div", { className: combinedClassname }, children);
1189 });
1190 var __DEV__ = true;
1191 var messages = { NO_PERSIST_ALL: "Reached maxSnack while all enqueued snackbars have 'persist' flag. Notistack will dismiss the oldest snackbar anyway to allow other ones in the queue to be presented." };
1192 var warning = (function(messageKey) {
1193 if (!__DEV__) return;
1194 var message = messages[messageKey];
1195 if (typeof console !== "undefined") console.error("WARNING - notistack: " + message);
1196 try {
1197 throw new Error(message);
1198 } catch (x) {}
1199 });
1200 var isOptions = function isOptions(messageOrOptions) {
1201 return !(typeof messageOrOptions === "string" || (0, react.isValidElement)(messageOrOptions));
1202 };
1203 var enqueueSnackbar;
1204 var closeSnackbar;
1205 var SnackbarProvider = /*#__PURE__*/ function(_Component) {
1206 _inheritsLoose(SnackbarProvider, _Component);
1207 function SnackbarProvider(props) {
1208 var _this = _Component.call(this, props) || this;
1209 /**
1210 * Adds a new snackbar to the queue to be presented.
1211 * Returns generated or user defined key referencing the new snackbar or null
1212 */
1213 _this.enqueueSnackbar = function(messageOrOptions, optsOrUndefined) {
1214 if (optsOrUndefined === void 0) optsOrUndefined = {};
1215 if (messageOrOptions === void 0 || messageOrOptions === null) throw new Error("enqueueSnackbar called with invalid argument");
1216 var opts = isOptions(messageOrOptions) ? messageOrOptions : optsOrUndefined;
1217 var message = isOptions(messageOrOptions) ? messageOrOptions.message : messageOrOptions;
1218 var key = opts.key;
1219 var preventDuplicate = opts.preventDuplicate;
1220 var options = _objectWithoutPropertiesLoose(opts, ["key", "preventDuplicate"]);
1221 var hasSpecifiedKey = isDefined(key);
1222 var id = hasSpecifiedKey ? key : (/* @__PURE__ */ new Date()).getTime() + Math.random();
1223 var merger = merge(options, _this.props);
1224 var snack = _extends({ id }, options, {
1225 message,
1226 open: true,
1227 entered: false,
1228 requestClose: false,
1229 persist: merger("persist"),
1230 action: merger("action"),
1231 content: merger("content"),
1232 variant: merger("variant"),
1233 anchorOrigin: merger("anchorOrigin"),
1234 disableWindowBlurListener: merger("disableWindowBlurListener"),
1235 autoHideDuration: merger("autoHideDuration"),
1236 hideIconVariant: merger("hideIconVariant"),
1237 TransitionComponent: merger("TransitionComponent"),
1238 transitionDuration: merger("transitionDuration"),
1239 TransitionProps: merger("TransitionProps", true),
1240 iconVariant: merger("iconVariant", true),
1241 style: merger("style", true),
1242 SnackbarProps: merger("SnackbarProps", true),
1243 className: clsx(_this.props.className, options.className)
1244 });
1245 if (snack.persist) snack.autoHideDuration = void 0;
1246 _this.setState(function(state) {
1247 if (preventDuplicate === void 0 && _this.props.preventDuplicate || preventDuplicate) {
1248 var compareFunction = function compareFunction(item) {
1249 return hasSpecifiedKey ? item.id === id : item.message === message;
1250 };
1251 var inQueue = state.queue.findIndex(compareFunction) > -1;
1252 var inView = state.snacks.findIndex(compareFunction) > -1;
1253 if (inQueue || inView) return state;
1254 }
1255 return _this.handleDisplaySnack(_extends({}, state, { queue: [].concat(state.queue, [snack]) }));
1256 });
1257 return id;
1258 };
1259 /**
1260 * Reducer: Display snack if there's space for it. Otherwise, immediately
1261 * begin dismissing the oldest message to start showing the new one.
1262 */
1263 _this.handleDisplaySnack = function(state) {
1264 if (state.snacks.length >= _this.maxSnack) return _this.handleDismissOldest(state);
1265 return _this.processQueue(state);
1266 };
1267 /**
1268 * Reducer: Display items (notifications) in the queue if there's space for them.
1269 */
1270 _this.processQueue = function(state) {
1271 var queue = state.queue;
1272 var snacks = state.snacks;
1273 if (queue.length > 0) return _extends({}, state, {
1274 snacks: [].concat(snacks, [queue[0]]),
1275 queue: queue.slice(1, queue.length)
1276 });
1277 return state;
1278 };
1279 /**
1280 * Reducer: Hide oldest snackbar on the screen because there exists a new one which we have to display.
1281 * (ignoring the one with 'persist' flag. i.e. explicitly told by user not to get dismissed).
1282 *
1283 * Note 1: If there is already a message leaving the screen, no new messages are dismissed.
1284 * Note 2: If the oldest message has not yet entered the screen, only a request to close the
1285 * snackbar is made. Once it entered the screen, it will be immediately dismissed.
1286 */
1287 _this.handleDismissOldest = function(state) {
1288 if (state.snacks.some(function(item) {
1289 return !item.open || item.requestClose;
1290 })) return state;
1291 var popped = false;
1292 var ignore = false;
1293 if (state.snacks.reduce(function(acc, current) {
1294 return acc + (current.open && current.persist ? 1 : 0);
1295 }, 0) === _this.maxSnack) {
1296 warning("NO_PERSIST_ALL");
1297 ignore = true;
1298 }
1299 var snacks = state.snacks.map(function(item) {
1300 if (!popped && (!item.persist || ignore)) {
1301 popped = true;
1302 if (!item.entered) return _extends({}, item, { requestClose: true });
1303 if (item.onClose) item.onClose(null, "maxsnack", item.id);
1304 if (_this.props.onClose) _this.props.onClose(null, "maxsnack", item.id);
1305 return _extends({}, item, { open: false });
1306 }
1307 return _extends({}, item);
1308 });
1309 return _extends({}, state, { snacks });
1310 };
1311 /**
1312 * Set the entered state of the snackbar with the given key.
1313 */
1314 _this.handleEnteredSnack = function(node, isAppearing, key) {
1315 if (!isDefined(key)) throw new Error("handleEnteredSnack Cannot be called with undefined key");
1316 _this.setState(function(_ref) {
1317 return { snacks: _ref.snacks.map(function(item) {
1318 return item.id === key ? _extends({}, item, { entered: true }) : _extends({}, item);
1319 }) };
1320 });
1321 };
1322 /**
1323 * Hide a snackbar after its timeout.
1324 */
1325 _this.handleCloseSnack = function(event, reason, key) {
1326 if (_this.props.onClose) _this.props.onClose(event, reason, key);
1327 var shouldCloseAll = key === void 0;
1328 _this.setState(function(_ref2) {
1329 var snacks = _ref2.snacks;
1330 var queue = _ref2.queue;
1331 return {
1332 snacks: snacks.map(function(item) {
1333 if (!shouldCloseAll && item.id !== key) return _extends({}, item);
1334 return item.entered ? _extends({}, item, { open: false }) : _extends({}, item, { requestClose: true });
1335 }),
1336 queue: queue.filter(function(item) {
1337 return item.id !== key;
1338 })
1339 };
1340 });
1341 };
1342 /**
1343 * Close snackbar with the given key
1344 */
1345 _this.closeSnackbar = function(key) {
1346 var toBeClosed = _this.state.snacks.find(function(item) {
1347 return item.id === key;
1348 });
1349 if (isDefined(key) && toBeClosed && toBeClosed.onClose) toBeClosed.onClose(null, "instructed", key);
1350 _this.handleCloseSnack(null, "instructed", key);
1351 };
1352 /**
1353 * When we set open attribute of a snackbar to false (i.e. after we hide a snackbar),
1354 * it leaves the screen and immediately after leaving animation is done, this method
1355 * gets called. We remove the hidden snackbar from state and then display notifications
1356 * waiting in the queue (if any). If after this process the queue is not empty, the
1357 * oldest message is dismissed.
1358 */
1359 _this.handleExitedSnack = function(node, key) {
1360 if (!isDefined(key)) throw new Error("handleExitedSnack Cannot be called with undefined key");
1361 _this.setState(function(state) {
1362 var newState = _this.processQueue(_extends({}, state, { snacks: state.snacks.filter(function(item) {
1363 return item.id !== key;
1364 }) }));
1365 if (newState.queue.length === 0) return newState;
1366 return _this.handleDismissOldest(newState);
1367 });
1368 };
1369 enqueueSnackbar = _this.enqueueSnackbar;
1370 closeSnackbar = _this.closeSnackbar;
1371 _this.state = {
1372 snacks: [],
1373 queue: [],
1374 contextValue: {
1375 enqueueSnackbar: _this.enqueueSnackbar.bind(_assertThisInitialized(_this)),
1376 closeSnackbar: _this.closeSnackbar.bind(_assertThisInitialized(_this))
1377 }
1378 };
1379 return _this;
1380 }
1381 var _proto = SnackbarProvider.prototype;
1382 _proto.render = function render() {
1383 var _this2 = this;
1384 var contextValue = this.state.contextValue;
1385 var _this$props = this.props;
1386 var domRoot = _this$props.domRoot;
1387 var children = _this$props.children;
1388 var _this$props$dense = _this$props.dense;
1389 var dense = _this$props$dense === void 0 ? false : _this$props$dense;
1390 var _this$props$Component = _this$props.Components;
1391 var Components = _this$props$Component === void 0 ? {} : _this$props$Component;
1392 var classes = _this$props.classes;
1393 var categ = this.state.snacks.reduce(function(acc, current) {
1394 var _extends2;
1395 var category = originKeyExtractor(current.anchorOrigin);
1396 var existingOfCategory = acc[category] || [];
1397 return _extends({}, acc, (_extends2 = {}, _extends2[category] = [].concat(existingOfCategory, [current]), _extends2));
1398 }, {});
1399 var snackbars = Object.keys(categ).map(function(origin) {
1400 var snacks = categ[origin];
1401 var nomineeSnack = snacks[0];
1402 return react.default.createElement(SnackbarContainer$1, {
1403 key: origin,
1404 dense,
1405 anchorOrigin: nomineeSnack.anchorOrigin,
1406 classes
1407 }, snacks.map(function(snack) {
1408 return react.default.createElement(SnackbarItem, {
1409 key: snack.id,
1410 snack,
1411 classes,
1412 Component: Components[snack.variant],
1413 onClose: _this2.handleCloseSnack,
1414 onEnter: _this2.props.onEnter,
1415 onExit: _this2.props.onExit,
1416 onExited: createChainedFunction([_this2.handleExitedSnack, _this2.props.onExited], snack.id),
1417 onEntered: createChainedFunction([_this2.handleEnteredSnack, _this2.props.onEntered], snack.id)
1418 });
1419 }));
1420 });
1421 return react.default.createElement(SnackbarContext.Provider, { value: contextValue }, children, domRoot ? (0, react_dom.createPortal)(snackbars, domRoot) : snackbars);
1422 };
1423 _createClass(SnackbarProvider, [{
1424 key: "maxSnack",
1425 get: function get() {
1426 return this.props.maxSnack || defaults.maxSnack;
1427 }
1428 }]);
1429 return SnackbarProvider;
1430 }(react.Component);
1431 var useSnackbar = (function() {
1432 return (0, react.useContext)(SnackbarContext);
1433 });
1434
1435 //#endregion
1436 //#region packages/packages/core/editor-notifications/src/slice.ts
1437 var notificationsSlice = (0, _elementor_store.__createSlice)({
1438 name: "notifications",
1439 initialState: {},
1440 reducers: {
1441 notifyAction: (state, action) => {
1442 const newState = { ...state };
1443 if (!newState[action.payload.id]) newState[action.payload.id] = action.payload;
1444 return newState;
1445 },
1446 clearAction: (state, action) => {
1447 const newState = { ...state };
1448 if (newState[action.payload.id]) delete newState[action.payload.id];
1449 return newState;
1450 }
1451 }
1452 });
1453 var { notifyAction, clearAction } = notificationsSlice.actions;
1454
1455 //#endregion
1456 //#region packages/packages/core/editor-notifications/src/hooks/use-enqueue-notifications.tsx
1457 var AUTO_HIDE_DURATION$1 = 8e3;
1458 function createDefaultAction(notification, onDismiss) {
1459 return /* @__PURE__ */ react.createElement(react.Fragment, { key: notification.id }, notification.additionalActionProps?.map((additionalAction, index) => /* @__PURE__ */ react.createElement(_elementor_ui.Button, {
1460 key: `${index}`,
1461 ...additionalAction
1462 })), /* @__PURE__ */ react.createElement(_elementor_ui.CloseButton, {
1463 "aria-label": "close",
1464 color: "inherit",
1465 onClick: onDismiss
1466 }));
1467 }
1468 function createPromotionAction(notification) {
1469 return /* @__PURE__ */ react.createElement(react.Fragment, { key: notification.id }, notification.additionalActionProps?.map((additionalAction, index) => /* @__PURE__ */ react.createElement(_elementor_ui.Button, {
1470 key: `${index}`,
1471 ...additionalAction
1472 })));
1473 }
1474 var useEnqueueNotification = (notifications) => {
1475 const { enqueueSnackbar } = useSnackbar();
1476 const dispatch = (0, _elementor_store.__useDispatch)();
1477 (0, react.useEffect)(() => {
1478 Object.values(notifications).forEach((notification) => {
1479 const dismiss = () => {
1480 closeSnackbar(notification.id);
1481 dispatch(clearAction({ id: notification.id }));
1482 };
1483 const action = [
1484 "promotion",
1485 "info",
1486 "success",
1487 "error"
1488 ].includes(notification.type) ? createPromotionAction(notification) : createDefaultAction(notification, dismiss);
1489 enqueueSnackbar(notification.message, {
1490 variant: notification.type,
1491 key: notification.id,
1492 onClose: () => dispatch(clearAction({ id: notification.id })),
1493 preventDuplicate: true,
1494 action,
1495 autoHideDuration: notification.autoHideDuration ?? AUTO_HIDE_DURATION$1
1496 });
1497 });
1498 }, [
1499 notifications,
1500 enqueueSnackbar,
1501 dispatch
1502 ]);
1503 };
1504
1505 //#endregion
1506 //#region packages/packages/core/editor-notifications/src/sync/get-app-bar-height.ts
1507 var EDITOR_APP_BAR_WRAPPER_ID = "elementor-editor-wrapper-v2";
1508 function getAppBarHeight() {
1509 return document.getElementById(EDITOR_APP_BAR_WRAPPER_ID)?.getBoundingClientRect().height ?? 0;
1510 }
1511
1512 //#endregion
1513 //#region packages/packages/core/editor-notifications/src/sync/get-editing-panel-width.ts
1514 function getEditingPanelWidth() {
1515 return document.querySelector(".elementor-panel")?.clientWidth || 0;
1516 }
1517
1518 //#endregion
1519 //#region packages/packages/core/editor-notifications/src/components/notifications.tsx
1520 var AUTO_HIDE_DURATION = 8e3;
1521 var DefaultCustomSnackbar = (0, react.forwardRef)((props, ref) => {
1522 const filteredProps = getFilteredSnackbarProps(props);
1523 const panelWidth = getEditingPanelWidth();
1524 const appBarHeight = getAppBarHeight();
1525 return /* @__PURE__ */ react.createElement(_elementor_ui.ThemeProvider, { palette: "unstable" }, /* @__PURE__ */ react.createElement(_elementor_ui.SnackbarContent, {
1526 ref,
1527 ...filteredProps,
1528 sx: {
1529 "&.MuiPaper-root": { minWidth: "max-content" },
1530 ml: panelWidth + "px",
1531 mt: `-${appBarHeight}px`
1532 }
1533 }));
1534 });
1535 var AlertSnackbar = (0, react.forwardRef)(({ color, icon, ...props }, ref) => {
1536 const panelWidth = getEditingPanelWidth();
1537 const appBarHeight = getAppBarHeight();
1538 return /* @__PURE__ */ react.createElement(_elementor_ui.ThemeProvider, {
1539 colorScheme: "light",
1540 palette: "unstable"
1541 }, /* @__PURE__ */ react.createElement(_elementor_ui.Alert, {
1542 ref,
1543 variant: "standard",
1544 color,
1545 icon,
1546 role: "alert",
1547 action: props.action,
1548 onClose: () => closeSnackbar(props.id),
1549 sx: {
1550 ml: panelWidth + "px",
1551 mt: `-${appBarHeight}px`,
1552 "& .MuiAlert-message": {
1553 display: "flex",
1554 flexWrap: "nowrap",
1555 alignItems: "center"
1556 },
1557 "& .MuiAlert-content": { whiteSpace: "nowrap" }
1558 }
1559 }, props.message));
1560 });
1561 var muiToEuiMapper = {
1562 default: DefaultCustomSnackbar,
1563 promotion: (0, react.forwardRef)((props, ref) => /* @__PURE__ */ react.createElement(AlertSnackbar, {
1564 ref,
1565 color: "promotion",
1566 icon: /* @__PURE__ */ react.createElement(_elementor_icons.CrownFilledIcon, null),
1567 ...props
1568 })),
1569 info: (0, react.forwardRef)((props, ref) => /* @__PURE__ */ react.createElement(AlertSnackbar, {
1570 ref,
1571 color: "info",
1572 icon: /* @__PURE__ */ react.createElement(_elementor_icons.InfoCircleFilledIcon, null),
1573 ...props
1574 })),
1575 success: (0, react.forwardRef)((props, ref) => /* @__PURE__ */ react.createElement(AlertSnackbar, {
1576 ref,
1577 color: "success",
1578 icon: /* @__PURE__ */ react.createElement(_elementor_icons.CircleCheckFilledIcon, null),
1579 ...props
1580 })),
1581 error: (0, react.forwardRef)((props, ref) => /* @__PURE__ */ react.createElement(AlertSnackbar, {
1582 ref,
1583 color: "error",
1584 icon: /* @__PURE__ */ react.createElement(_elementor_icons.AlertCircleFilled, null),
1585 ...props
1586 }))
1587 };
1588 var Handler = () => {
1589 useEnqueueNotification((0, _elementor_store.__useSelector)((state) => state.notifications));
1590 return null;
1591 };
1592 var Wrapper = () => {
1593 return /* @__PURE__ */ react.createElement(SnackbarProvider, {
1594 maxSnack: 3,
1595 autoHideDuration: AUTO_HIDE_DURATION,
1596 disableWindowBlurListener: true,
1597 anchorOrigin: {
1598 horizontal: "center",
1599 vertical: "bottom"
1600 },
1601 Components: muiToEuiMapper,
1602 domRoot: document.body
1603 }, /* @__PURE__ */ react.createElement(Handler, null));
1604 };
1605 function notify(notification) {
1606 (0, _elementor_store.__getStore)()?.dispatch(notifyAction(notification));
1607 }
1608 function dismissNotification(id) {
1609 const store = (0, _elementor_store.__getStore)();
1610 closeSnackbar(id);
1611 store?.dispatch(clearAction({ id }));
1612 }
1613 function NotifyReact(notification) {
1614 (0, _elementor_store.__useDispatch)()(notifyAction(notification));
1615 }
1616 function getFilteredSnackbarProps(props) {
1617 const forbiddenProps = [
1618 "autoHideDuration",
1619 "persist",
1620 "hideIconVariant",
1621 "iconVariant",
1622 "anchorOrigin"
1623 ];
1624 return Object.entries(props).reduce((filteredProps, [key, value]) => {
1625 if (!forbiddenProps.includes(key)) filteredProps[key] = value;
1626 return filteredProps;
1627 }, {});
1628 }
1629
1630 //#endregion
1631 //#region packages/packages/core/editor-notifications/src/init.ts
1632 function init() {
1633 (0, _elementor_store.__registerSlice)(notificationsSlice);
1634 (0, _elementor_editor.injectIntoTop)({
1635 id: "notifications",
1636 component: Wrapper
1637 });
1638 }
1639
1640 //#endregion
1641 //#region packages/packages/core/editor-notifications/src/index.ts
1642 var src_exports = /* @__PURE__ */ __exportAll({
1643 NotifyReact: () => NotifyReact,
1644 dismissNotification: () => dismissNotification,
1645 init: () => init,
1646 notify: () => notify
1647 });
1648
1649 //#endregion
1650 //#region \0elementor-package-library-entry
1651 (window.elementorV2 = window.elementorV2 || {}).editorNotifications = src_exports;
1652
1653 //#endregion
1654 })(elementorV2.editor, elementorV2.store, React, ReactDOM, elementorV2.icons, elementorV2.ui);
1655 window.elementorV2.editorNotifications?.init?.();
1656 //# sourceMappingURL=editor-notifications.js.map