UNPKG

108 kBJavaScriptView Raw
1System.register(['react', 'styled-components', 'lodash', 'rxjs'], function (exports) {
2 'use strict';
3 var React, useRef, useEffect, useMemo, useReducer, useState, useContext, styled, debounce, BehaviorSubject;
4 return {
5 setters: [function (module) {
6 React = module.default;
7 useRef = module.useRef;
8 useEffect = module.useEffect;
9 useMemo = module.useMemo;
10 useReducer = module.useReducer;
11 useState = module.useState;
12 useContext = module.useContext;
13 }, function (module) {
14 styled = module.default;
15 }, function (module) {
16 debounce = module.debounce;
17 }, function (module) {
18 BehaviorSubject = module.BehaviorSubject;
19 }],
20 execute: function () {
21
22 exports({
23 NamedThemeProvider: NamedThemeProvider,
24 createContainer: createContainer,
25 createSubscriptionContainer: createSubscriptionContainer,
26 useAsyncEffect: useAsyncEffect,
27 useConstant: useConstant,
28 useContainer: useContainer,
29 useDebounceEffect: useDebounceEffect,
30 useEffectOnce: useEffectOnce,
31 useFetchEffect: useFetchEffect,
32 useForceRender: useForceRender,
33 useInterval: useInterval,
34 useMounted: useMounted,
35 useNamedTheme: useNamedTheme,
36 useOnlineEffect: useOnlineEffect,
37 usePromiseEffect: usePromiseEffect,
38 withProps: withProps
39 });
40
41 function _typeof(obj) {
42 "@babel/helpers - typeof";
43
44 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
45 _typeof = function (obj) {
46 return typeof obj;
47 };
48 } else {
49 _typeof = function (obj) {
50 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
51 };
52 }
53
54 return _typeof(obj);
55 }
56
57 function _defineProperty(obj, key, value) {
58 if (key in obj) {
59 Object.defineProperty(obj, key, {
60 value: value,
61 enumerable: true,
62 configurable: true,
63 writable: true
64 });
65 } else {
66 obj[key] = value;
67 }
68
69 return obj;
70 }
71
72 function ownKeys(object, enumerableOnly) {
73 var keys = Object.keys(object);
74
75 if (Object.getOwnPropertySymbols) {
76 var symbols = Object.getOwnPropertySymbols(object);
77 if (enumerableOnly) symbols = symbols.filter(function (sym) {
78 return Object.getOwnPropertyDescriptor(object, sym).enumerable;
79 });
80 keys.push.apply(keys, symbols);
81 }
82
83 return keys;
84 }
85
86 function _objectSpread2(target) {
87 for (var i = 1; i < arguments.length; i++) {
88 var source = arguments[i] != null ? arguments[i] : {};
89
90 if (i % 2) {
91 ownKeys(Object(source), true).forEach(function (key) {
92 _defineProperty(target, key, source[key]);
93 });
94 } else if (Object.getOwnPropertyDescriptors) {
95 Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
96 } else {
97 ownKeys(Object(source)).forEach(function (key) {
98 Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
99 });
100 }
101 }
102
103 return target;
104 }
105
106 function _taggedTemplateLiteral(strings, raw) {
107 if (!raw) {
108 raw = strings.slice(0);
109 }
110
111 return Object.freeze(Object.defineProperties(strings, {
112 raw: {
113 value: Object.freeze(raw)
114 }
115 }));
116 }
117
118 function _slicedToArray(arr, i) {
119 return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
120 }
121
122 function _arrayWithHoles(arr) {
123 if (Array.isArray(arr)) return arr;
124 }
125
126 function _iterableToArrayLimit(arr, i) {
127 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
128 var _arr = [];
129 var _n = true;
130 var _d = false;
131 var _e = undefined;
132
133 try {
134 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
135 _arr.push(_s.value);
136
137 if (i && _arr.length === i) break;
138 }
139 } catch (err) {
140 _d = true;
141 _e = err;
142 } finally {
143 try {
144 if (!_n && _i["return"] != null) _i["return"]();
145 } finally {
146 if (_d) throw _e;
147 }
148 }
149
150 return _arr;
151 }
152
153 function _unsupportedIterableToArray(o, minLen) {
154 if (!o) return;
155 if (typeof o === "string") return _arrayLikeToArray(o, minLen);
156 var n = Object.prototype.toString.call(o).slice(8, -1);
157 if (n === "Object" && o.constructor) n = o.constructor.name;
158 if (n === "Map" || n === "Set") return Array.from(o);
159 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
160 }
161
162 function _arrayLikeToArray(arr, len) {
163 if (len == null || len > arr.length) len = arr.length;
164
165 for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
166
167 return arr2;
168 }
169
170 function _nonIterableRest() {
171 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
172 }
173
174 function _templateObject5() {
175 var data = _taggedTemplateLiteral(["\n .leo {\n position: absolute;\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: 50%;\n }\n\n .blue-orbit {\n width: 165px;\n height: 165px;\n border: 1px solid #91daffa5;\n -webkit-animation: spin3D 3s linear 0.2s infinite;\n }\n\n .green-orbit {\n width: 120px;\n height: 120px;\n border: 1px solid #91ffbfa5;\n -webkit-animation: spin3D 2s linear 0s infinite;\n }\n\n .red-orbit {\n width: 90px;\n height: 90px;\n border: 1px solid #ffca91a5;\n -webkit-animation: spin3D 1s linear 0s infinite;\n }\n\n .white-orbit {\n width: 60px;\n height: 60px;\n border: 2px solid #ffffff;\n -webkit-animation: spin3D 10s linear 0s infinite;\n }\n\n .w1 {\n transform: rotate3D(1, 1, 1, 90deg);\n }\n\n .w2 {\n transform: rotate3D(1, 2, 0.5, 90deg);\n }\n\n .w3 {\n transform: rotate3D(0.5, 1, 2, 90deg);\n }\n\n @keyframes spin {\n from {\n transform: rotate(0);\n }\n to {\n transform: rotate(359deg);\n }\n }\n\n @keyframes spin3D {\n from {\n transform: rotate3d(0.5, 0.5, 0.5, 360deg);\n }\n to {\n transform: rotate3d(0deg);\n }\n }\n"]);
176
177 _templateObject5 = function _templateObject5() {
178 return data;
179 };
180
181 return data;
182 }
183
184 function _templateObject4() {
185 var data = _taggedTemplateLiteral(["\n .solar-system {\n width: 250px;\n height: 250px;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n .orbit {\n position: relative;\n display: flex;\n justify-content: center;\n align-items: center;\n border: 1px solid #ffffffa5;\n border-radius: 50%;\n }\n\n .earth-orbit {\n width: 165px;\n height: 165px;\n animation: spin 12s linear 0s infinite;\n }\n\n .venus-orbit {\n width: 120px;\n height: 120px;\n animation: spin 7.4s linear 0s infinite;\n }\n\n .mercury-orbit {\n width: 90px;\n height: 90px;\n animation: spin 3s linear 0s infinite;\n }\n\n .planet {\n position: absolute;\n top: -5px;\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background-color: #3ff9dc;\n }\n\n .sun {\n width: 35px;\n height: 35px;\n border-radius: 50%;\n background-color: #ffab91;\n }\n"]);
186
187 _templateObject4 = function _templateObject4() {
188 return data;
189 };
190
191 return data;
192 }
193
194 function _templateObject3() {
195 var data = _taggedTemplateLiteral(["\n .pulse-container {\n width: 120px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n\n .pulse-bubble {\n width: 20px;\n height: 20px;\n border-radius: 50%;\n background-color: #3ff9dc;\n }\n\n .pulse-bubble-1 {\n animation: pulse 0.4s ease 0s infinite alternate;\n }\n .pulse-bubble-2 {\n animation: pulse 0.4s ease 0.2s infinite alternate;\n }\n .pulse-bubble-3 {\n animation: pulse 0.4s ease 0.4s infinite alternate;\n }\n @keyframes pulse {\n from {\n opacity: 1;\n transform: scale(1);\n }\n to {\n opacity: 0.25;\n transform: scale(0.75);\n }\n }\n"]);
196
197 _templateObject3 = function _templateObject3() {
198 return data;
199 };
200
201 return data;
202 }
203
204 function _templateObject2() {
205 var data = _taggedTemplateLiteral(["\n .circle-border {\n width: 150px;\n height: 150px;\n padding: 3px;\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: 50%;\n background: rgb(63, 249, 220);\n background: linear-gradient(0deg, rgba(63, 249, 220, 0.1) 33%, rgba(63, 249, 220, 1) 100%);\n animation: spin 0.8s linear 0s infinite;\n }\n\n .circle-core {\n width: 100%;\n height: 100%;\n background-color: #37474f;\n border-radius: 50%;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0);\n }\n to {\n transform: rotate(359deg);\n }\n }\n"]);
206
207 _templateObject2 = function _templateObject2() {
208 return data;
209 };
210
211 return data;
212 }
213
214 function _templateObject() {
215 var data = _taggedTemplateLiteral(["\n width: 300px;\n height: 300px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: transparent;\n"]);
216
217 _templateObject = function _templateObject() {
218 return data;
219 };
220
221 return data;
222 }
223
224 var SpinnerBox = styled.div(_templateObject());
225 var GradientSpinnerBox = styled(SpinnerBox)(_templateObject2());
226 var PulseBubbleBox = styled(SpinnerBox)(_templateObject3());
227 var GradientSpinner = exports('GradientSpinner', function GradientSpinner() {
228 return /*#__PURE__*/React.createElement(GradientSpinnerBox, null, /*#__PURE__*/React.createElement("div", {
229 className: "circle-border"
230 }, /*#__PURE__*/React.createElement("div", {
231 className: "circle-core"
232 })));
233 });
234 var PulseBubble = exports('PulseBubble', function PulseBubble() {
235 return /*#__PURE__*/React.createElement(PulseBubbleBox, null, /*#__PURE__*/React.createElement("div", {
236 className: "pulse-container"
237 }, /*#__PURE__*/React.createElement("div", {
238 className: "pulse-bubble pulse-bubble-1"
239 }), /*#__PURE__*/React.createElement("div", {
240 className: "pulse-bubble pulse-bubble-2"
241 }), /*#__PURE__*/React.createElement("div", {
242 className: "pulse-bubble pulse-bubble-3"
243 })));
244 });
245 var SolarSystemBox = styled(SpinnerBox)(_templateObject4());
246 var SolarSystemSpinner = exports('SolarSystemSpinner', function SolarSystemSpinner() {
247 return /*#__PURE__*/React.createElement(SolarSystemBox, null, /*#__PURE__*/React.createElement("div", {
248 className: "solar-system"
249 }, /*#__PURE__*/React.createElement("div", {
250 className: "earth-orbit orbit"
251 }, /*#__PURE__*/React.createElement("div", {
252 className: "planet earth"
253 }), /*#__PURE__*/React.createElement("div", {
254 className: "venus-orbit orbit"
255 }, /*#__PURE__*/React.createElement("div", {
256 className: "planet venus"
257 }), /*#__PURE__*/React.createElement("div", {
258 className: "mercury-orbit orbit"
259 }, /*#__PURE__*/React.createElement("div", {
260 className: "planet mercury"
261 }), /*#__PURE__*/React.createElement("div", {
262 className: "sun"
263 }))))));
264 });
265 var PlanetRotatingBox = exports('PlanetRotatingBox', styled(SpinnerBox)(_templateObject5()));
266 var PlantRotating = exports('PlantRotating', function PlantRotating() {
267 return /*#__PURE__*/React.createElement(PlanetRotatingBox, null, /*#__PURE__*/React.createElement("div", {
268 className: "blue-orbit leo"
269 }), /*#__PURE__*/React.createElement("div", {
270 className: "green-orbit leo"
271 }), /*#__PURE__*/React.createElement("div", {
272 className: "red-orbit leo"
273 }), /*#__PURE__*/React.createElement("div", {
274 className: "white-orbit w1 leo"
275 }), /*#__PURE__*/React.createElement("div", {
276 className: "white-orbit w2 leo"
277 }), /*#__PURE__*/React.createElement("div", {
278 className: "white-orbit w3 leo"
279 }));
280 });
281
282 function _templateObject$1() {
283 var data = _taggedTemplateLiteral(["\n position: absolute;\n width: 35px;\n height: 35px;\n left: 50%;\n top: 50%;\n & > div {\n position: absolute;\n width: 2px;\n height: 8px;\n background-color: #25363f;\n opacity: 0.05;\n animation: fadeit 0.8s linear infinite;\n }\n\n ", "\n\n @keyframes fadeit {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n"]);
284
285 _templateObject$1 = function _templateObject() {
286 return data;
287 };
288
289 return data;
290 }
291
292 var BarsSpinnerBox = styled.div(_templateObject$1(), function (_ref) {
293 var bars = _ref.bars;
294 return Array(bars).fill(null).map(function (_, i) {
295 return "\n & > div:nth-child(".concat(i + 1, ") {\n transform: rotate(").concat((360 / bars * i).toFixed(2), "deg) translate(0, -12px);\n animation-delay:").concat((0.8 / bars * (i + 1)).toFixed(2), "s;\n }\n ");
296 });
297 });
298 var BarsSpinner = exports('BarsSpinner', function BarsSpinner(_ref2) {
299 var _ref2$bars = _ref2.bars,
300 bars = _ref2$bars === void 0 ? 16 : _ref2$bars;
301 return /*#__PURE__*/React.createElement(BarsSpinnerBox, {
302 bars: bars
303 }, Array(bars).fill(null).map(function (_, i) {
304 return /*#__PURE__*/React.createElement("div", {
305 key: i
306 });
307 }));
308 });
309
310 function _extends() {
311 _extends = Object.assign || function (target) {
312 for (var i = 1; i < arguments.length; i++) {
313 var source = arguments[i];
314
315 for (var key in source) {
316 if (Object.prototype.hasOwnProperty.call(source, key)) {
317 target[key] = source[key];
318 }
319 }
320 }
321
322 return target;
323 };
324
325 return _extends.apply(this, arguments);
326 }
327
328 function _assertThisInitialized(self) {
329 if (self === void 0) {
330 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
331 }
332
333 return self;
334 }
335
336 function _inheritsLoose(subClass, superClass) {
337 subClass.prototype = Object.create(superClass.prototype);
338 subClass.prototype.constructor = subClass;
339 subClass.__proto__ = superClass;
340 }
341
342 function _getPrototypeOf(o) {
343 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
344 return o.__proto__ || Object.getPrototypeOf(o);
345 };
346 return _getPrototypeOf(o);
347 }
348
349 function _setPrototypeOf(o, p) {
350 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
351 o.__proto__ = p;
352 return o;
353 };
354
355 return _setPrototypeOf(o, p);
356 }
357
358 function _isNativeFunction(fn) {
359 return Function.toString.call(fn).indexOf("[native code]") !== -1;
360 }
361
362 function _isNativeReflectConstruct() {
363 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
364 if (Reflect.construct.sham) return false;
365 if (typeof Proxy === "function") return true;
366
367 try {
368 Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
369 return true;
370 } catch (e) {
371 return false;
372 }
373 }
374
375 function _construct(Parent, args, Class) {
376 if (_isNativeReflectConstruct()) {
377 _construct = Reflect.construct;
378 } else {
379 _construct = function _construct(Parent, args, Class) {
380 var a = [null];
381 a.push.apply(a, args);
382 var Constructor = Function.bind.apply(Parent, a);
383 var instance = new Constructor();
384 if (Class) _setPrototypeOf(instance, Class.prototype);
385 return instance;
386 };
387 }
388
389 return _construct.apply(null, arguments);
390 }
391
392 function _wrapNativeSuper(Class) {
393 var _cache = typeof Map === "function" ? new Map() : undefined;
394
395 _wrapNativeSuper = function _wrapNativeSuper(Class) {
396 if (Class === null || !_isNativeFunction(Class)) return Class;
397
398 if (typeof Class !== "function") {
399 throw new TypeError("Super expression must either be null or a function");
400 }
401
402 if (typeof _cache !== "undefined") {
403 if (_cache.has(Class)) return _cache.get(Class);
404
405 _cache.set(Class, Wrapper);
406 }
407
408 function Wrapper() {
409 return _construct(Class, arguments, _getPrototypeOf(this).constructor);
410 }
411
412 Wrapper.prototype = Object.create(Class.prototype, {
413 constructor: {
414 value: Wrapper,
415 enumerable: false,
416 writable: true,
417 configurable: true
418 }
419 });
420 return _setPrototypeOf(Wrapper, Class);
421 };
422
423 return _wrapNativeSuper(Class);
424 }
425
426 /**
427 * Parse errors.md and turn it into a simple hash of code: message
428 * @private
429 */
430
431 var ERRORS = {
432 "1": "Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",
433 "2": "Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",
434 "3": "Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",
435 "4": "Couldn't generate valid rgb string from %s, it returned %s.\n\n",
436 "5": "Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",
437 "6": "Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",
438 "7": "Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",
439 "8": "Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",
440 "9": "Please provide a number of steps to the modularScale helper.\n\n",
441 "10": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
442 "11": "Invalid value passed as base to modularScale, expected number or em string but got \"%s\"\n\n",
443 "12": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got \"%s\" instead.\n\n",
444 "13": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got \"%s\" instead.\n\n",
445 "14": "Passed invalid pixel value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
446 "15": "Passed invalid base value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
447 "16": "You must provide a template to this method.\n\n",
448 "17": "You passed an unsupported selector state to this method.\n\n",
449 "18": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
450 "19": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
451 "20": "expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
452 "21": "expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
453 "22": "expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
454 "23": "fontFace expects a name of a font-family.\n\n",
455 "24": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
456 "25": "fontFace expects localFonts to be an array.\n\n",
457 "26": "fontFace expects fileFormats to be an array.\n\n",
458 "27": "radialGradient requries at least 2 color-stops to properly render.\n\n",
459 "28": "Please supply a filename to retinaImage() as the first argument.\n\n",
460 "29": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
461 "30": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
462 "31": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",
463 "32": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",
464 "33": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",
465 "34": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
466 "35": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
467 "36": "Property must be a string value.\n\n",
468 "37": "Syntax Error at %s.\n\n",
469 "38": "Formula contains a function that needs parentheses at %s.\n\n",
470 "39": "Formula is missing closing parenthesis at %s.\n\n",
471 "40": "Formula has too many closing parentheses at %s.\n\n",
472 "41": "All values in a formula must have the same unit or be unitless.\n\n",
473 "42": "Please provide a number of steps to the modularScale helper.\n\n",
474 "43": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
475 "44": "Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",
476 "45": "Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",
477 "46": "Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",
478 "47": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
479 "48": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
480 "49": "Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
481 "50": "Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",
482 "51": "Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",
483 "52": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
484 "53": "fontFace expects localFonts to be an array.\n\n",
485 "54": "fontFace expects fileFormats to be an array.\n\n",
486 "55": "fontFace expects a name of a font-family.\n\n",
487 "56": "linearGradient requries at least 2 color-stops to properly render.\n\n",
488 "57": "radialGradient requries at least 2 color-stops to properly render.\n\n",
489 "58": "Please supply a filename to retinaImage() as the first argument.\n\n",
490 "59": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
491 "60": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
492 "61": "Property must be a string value.\n\n",
493 "62": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
494 "63": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
495 "64": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",
496 "65": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",
497 "66": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",
498 "67": "You must provide a template to this method.\n\n",
499 "68": "You passed an unsupported selector state to this method.\n\n",
500 "69": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got %s instead.\n\n",
501 "70": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got %s instead.\n\n",
502 "71": "Passed invalid pixel value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
503 "72": "Passed invalid base value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
504 "73": "Please provide a valid CSS variable.\n\n",
505 "74": "CSS variable not found.\n"
506 };
507 /**
508 * super basic version of sprintf
509 * @private
510 */
511
512 function format() {
513 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
514 args[_key] = arguments[_key];
515 }
516
517 var a = args[0];
518 var b = [];
519 var c;
520
521 for (c = 1; c < args.length; c += 1) {
522 b.push(args[c]);
523 }
524
525 b.forEach(function (d) {
526 a = a.replace(/%[a-z]/, d);
527 });
528 return a;
529 }
530 /**
531 * Create an error file out of errors.md for development and a simple web link to the full errors
532 * in production mode.
533 * @private
534 */
535
536
537 var PolishedError = /*#__PURE__*/function (_Error) {
538 _inheritsLoose(PolishedError, _Error);
539
540 function PolishedError(code) {
541 var _this;
542
543 if (process.env.NODE_ENV === 'production') {
544 _this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/master/src/internalHelpers/errors.md#" + code + " for more information.") || this;
545 } else {
546 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
547 args[_key2 - 1] = arguments[_key2];
548 }
549
550 _this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
551 }
552
553 return _assertThisInitialized(_this);
554 }
555
556 return PolishedError;
557 }( /*#__PURE__*/_wrapNativeSuper(Error));
558
559 function colorToInt(color) {
560 return Math.round(color * 255);
561 }
562
563 function convertToInt(red, green, blue) {
564 return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
565 }
566
567 function hslToRgb(hue, saturation, lightness, convert) {
568 if (convert === void 0) {
569 convert = convertToInt;
570 }
571
572 if (saturation === 0) {
573 // achromatic
574 return convert(lightness, lightness, lightness);
575 } // formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
576
577
578 var huePrime = (hue % 360 + 360) % 360 / 60;
579 var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
580 var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
581 var red = 0;
582 var green = 0;
583 var blue = 0;
584
585 if (huePrime >= 0 && huePrime < 1) {
586 red = chroma;
587 green = secondComponent;
588 } else if (huePrime >= 1 && huePrime < 2) {
589 red = secondComponent;
590 green = chroma;
591 } else if (huePrime >= 2 && huePrime < 3) {
592 green = chroma;
593 blue = secondComponent;
594 } else if (huePrime >= 3 && huePrime < 4) {
595 green = secondComponent;
596 blue = chroma;
597 } else if (huePrime >= 4 && huePrime < 5) {
598 red = secondComponent;
599 blue = chroma;
600 } else if (huePrime >= 5 && huePrime < 6) {
601 red = chroma;
602 blue = secondComponent;
603 }
604
605 var lightnessModification = lightness - chroma / 2;
606 var finalRed = red + lightnessModification;
607 var finalGreen = green + lightnessModification;
608 var finalBlue = blue + lightnessModification;
609 return convert(finalRed, finalGreen, finalBlue);
610 }
611
612 var namedColorMap = {
613 aliceblue: 'f0f8ff',
614 antiquewhite: 'faebd7',
615 aqua: '00ffff',
616 aquamarine: '7fffd4',
617 azure: 'f0ffff',
618 beige: 'f5f5dc',
619 bisque: 'ffe4c4',
620 black: '000',
621 blanchedalmond: 'ffebcd',
622 blue: '0000ff',
623 blueviolet: '8a2be2',
624 brown: 'a52a2a',
625 burlywood: 'deb887',
626 cadetblue: '5f9ea0',
627 chartreuse: '7fff00',
628 chocolate: 'd2691e',
629 coral: 'ff7f50',
630 cornflowerblue: '6495ed',
631 cornsilk: 'fff8dc',
632 crimson: 'dc143c',
633 cyan: '00ffff',
634 darkblue: '00008b',
635 darkcyan: '008b8b',
636 darkgoldenrod: 'b8860b',
637 darkgray: 'a9a9a9',
638 darkgreen: '006400',
639 darkgrey: 'a9a9a9',
640 darkkhaki: 'bdb76b',
641 darkmagenta: '8b008b',
642 darkolivegreen: '556b2f',
643 darkorange: 'ff8c00',
644 darkorchid: '9932cc',
645 darkred: '8b0000',
646 darksalmon: 'e9967a',
647 darkseagreen: '8fbc8f',
648 darkslateblue: '483d8b',
649 darkslategray: '2f4f4f',
650 darkslategrey: '2f4f4f',
651 darkturquoise: '00ced1',
652 darkviolet: '9400d3',
653 deeppink: 'ff1493',
654 deepskyblue: '00bfff',
655 dimgray: '696969',
656 dimgrey: '696969',
657 dodgerblue: '1e90ff',
658 firebrick: 'b22222',
659 floralwhite: 'fffaf0',
660 forestgreen: '228b22',
661 fuchsia: 'ff00ff',
662 gainsboro: 'dcdcdc',
663 ghostwhite: 'f8f8ff',
664 gold: 'ffd700',
665 goldenrod: 'daa520',
666 gray: '808080',
667 green: '008000',
668 greenyellow: 'adff2f',
669 grey: '808080',
670 honeydew: 'f0fff0',
671 hotpink: 'ff69b4',
672 indianred: 'cd5c5c',
673 indigo: '4b0082',
674 ivory: 'fffff0',
675 khaki: 'f0e68c',
676 lavender: 'e6e6fa',
677 lavenderblush: 'fff0f5',
678 lawngreen: '7cfc00',
679 lemonchiffon: 'fffacd',
680 lightblue: 'add8e6',
681 lightcoral: 'f08080',
682 lightcyan: 'e0ffff',
683 lightgoldenrodyellow: 'fafad2',
684 lightgray: 'd3d3d3',
685 lightgreen: '90ee90',
686 lightgrey: 'd3d3d3',
687 lightpink: 'ffb6c1',
688 lightsalmon: 'ffa07a',
689 lightseagreen: '20b2aa',
690 lightskyblue: '87cefa',
691 lightslategray: '789',
692 lightslategrey: '789',
693 lightsteelblue: 'b0c4de',
694 lightyellow: 'ffffe0',
695 lime: '0f0',
696 limegreen: '32cd32',
697 linen: 'faf0e6',
698 magenta: 'f0f',
699 maroon: '800000',
700 mediumaquamarine: '66cdaa',
701 mediumblue: '0000cd',
702 mediumorchid: 'ba55d3',
703 mediumpurple: '9370db',
704 mediumseagreen: '3cb371',
705 mediumslateblue: '7b68ee',
706 mediumspringgreen: '00fa9a',
707 mediumturquoise: '48d1cc',
708 mediumvioletred: 'c71585',
709 midnightblue: '191970',
710 mintcream: 'f5fffa',
711 mistyrose: 'ffe4e1',
712 moccasin: 'ffe4b5',
713 navajowhite: 'ffdead',
714 navy: '000080',
715 oldlace: 'fdf5e6',
716 olive: '808000',
717 olivedrab: '6b8e23',
718 orange: 'ffa500',
719 orangered: 'ff4500',
720 orchid: 'da70d6',
721 palegoldenrod: 'eee8aa',
722 palegreen: '98fb98',
723 paleturquoise: 'afeeee',
724 palevioletred: 'db7093',
725 papayawhip: 'ffefd5',
726 peachpuff: 'ffdab9',
727 peru: 'cd853f',
728 pink: 'ffc0cb',
729 plum: 'dda0dd',
730 powderblue: 'b0e0e6',
731 purple: '800080',
732 rebeccapurple: '639',
733 red: 'f00',
734 rosybrown: 'bc8f8f',
735 royalblue: '4169e1',
736 saddlebrown: '8b4513',
737 salmon: 'fa8072',
738 sandybrown: 'f4a460',
739 seagreen: '2e8b57',
740 seashell: 'fff5ee',
741 sienna: 'a0522d',
742 silver: 'c0c0c0',
743 skyblue: '87ceeb',
744 slateblue: '6a5acd',
745 slategray: '708090',
746 slategrey: '708090',
747 snow: 'fffafa',
748 springgreen: '00ff7f',
749 steelblue: '4682b4',
750 tan: 'd2b48c',
751 teal: '008080',
752 thistle: 'd8bfd8',
753 tomato: 'ff6347',
754 turquoise: '40e0d0',
755 violet: 'ee82ee',
756 wheat: 'f5deb3',
757 white: 'fff',
758 whitesmoke: 'f5f5f5',
759 yellow: 'ff0',
760 yellowgreen: '9acd32'
761 };
762 /**
763 * Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
764 * @private
765 */
766
767 function nameToHex(color) {
768 if (typeof color !== 'string') return color;
769 var normalizedColorName = color.toLowerCase();
770 return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color;
771 }
772
773 var hexRegex = /^#[a-fA-F0-9]{6}$/;
774 var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
775 var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
776 var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
777 var rgbRegex = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i;
778 var rgbaRegex = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i;
779 var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
780 var hslaRegex = /^hsla\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i;
781 /**
782 * Returns an RgbColor or RgbaColor object. This utility function is only useful
783 * if want to extract a color component. With the color util `toColorString` you
784 * can convert a RgbColor or RgbaColor object back to a string.
785 *
786 * @example
787 * // Assigns `{ red: 255, green: 0, blue: 0 }` to color1
788 * const color1 = parseToRgb('rgb(255, 0, 0)');
789 * // Assigns `{ red: 92, green: 102, blue: 112, alpha: 0.75 }` to color2
790 * const color2 = parseToRgb('hsla(210, 10%, 40%, 0.75)');
791 */
792
793 function parseToRgb(color) {
794 if (typeof color !== 'string') {
795 throw new PolishedError(3);
796 }
797
798 var normalizedColor = nameToHex(color);
799
800 if (normalizedColor.match(hexRegex)) {
801 return {
802 red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
803 green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
804 blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
805 };
806 }
807
808 if (normalizedColor.match(hexRgbaRegex)) {
809 var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
810 return {
811 red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
812 green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
813 blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16),
814 alpha: alpha
815 };
816 }
817
818 if (normalizedColor.match(reducedHexRegex)) {
819 return {
820 red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
821 green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
822 blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
823 };
824 }
825
826 if (normalizedColor.match(reducedRgbaHexRegex)) {
827 var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
828
829 return {
830 red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
831 green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
832 blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16),
833 alpha: _alpha
834 };
835 }
836
837 var rgbMatched = rgbRegex.exec(normalizedColor);
838
839 if (rgbMatched) {
840 return {
841 red: parseInt("" + rgbMatched[1], 10),
842 green: parseInt("" + rgbMatched[2], 10),
843 blue: parseInt("" + rgbMatched[3], 10)
844 };
845 }
846
847 var rgbaMatched = rgbaRegex.exec(normalizedColor);
848
849 if (rgbaMatched) {
850 return {
851 red: parseInt("" + rgbaMatched[1], 10),
852 green: parseInt("" + rgbaMatched[2], 10),
853 blue: parseInt("" + rgbaMatched[3], 10),
854 alpha: parseFloat("" + rgbaMatched[4])
855 };
856 }
857
858 var hslMatched = hslRegex.exec(normalizedColor);
859
860 if (hslMatched) {
861 var hue = parseInt("" + hslMatched[1], 10);
862 var saturation = parseInt("" + hslMatched[2], 10) / 100;
863 var lightness = parseInt("" + hslMatched[3], 10) / 100;
864 var rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")";
865 var hslRgbMatched = rgbRegex.exec(rgbColorString);
866
867 if (!hslRgbMatched) {
868 throw new PolishedError(4, normalizedColor, rgbColorString);
869 }
870
871 return {
872 red: parseInt("" + hslRgbMatched[1], 10),
873 green: parseInt("" + hslRgbMatched[2], 10),
874 blue: parseInt("" + hslRgbMatched[3], 10)
875 };
876 }
877
878 var hslaMatched = hslaRegex.exec(normalizedColor);
879
880 if (hslaMatched) {
881 var _hue = parseInt("" + hslaMatched[1], 10);
882
883 var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
884
885 var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
886
887 var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
888
889 var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
890
891 if (!_hslRgbMatched) {
892 throw new PolishedError(4, normalizedColor, _rgbColorString);
893 }
894
895 return {
896 red: parseInt("" + _hslRgbMatched[1], 10),
897 green: parseInt("" + _hslRgbMatched[2], 10),
898 blue: parseInt("" + _hslRgbMatched[3], 10),
899 alpha: parseFloat("" + hslaMatched[4])
900 };
901 }
902
903 throw new PolishedError(5);
904 }
905
906 function rgbToHsl(color) {
907 // make sure rgb are contained in a set of [0, 255]
908 var red = color.red / 255;
909 var green = color.green / 255;
910 var blue = color.blue / 255;
911 var max = Math.max(red, green, blue);
912 var min = Math.min(red, green, blue);
913 var lightness = (max + min) / 2;
914
915 if (max === min) {
916 // achromatic
917 if (color.alpha !== undefined) {
918 return {
919 hue: 0,
920 saturation: 0,
921 lightness: lightness,
922 alpha: color.alpha
923 };
924 } else {
925 return {
926 hue: 0,
927 saturation: 0,
928 lightness: lightness
929 };
930 }
931 }
932
933 var hue;
934 var delta = max - min;
935 var saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
936
937 switch (max) {
938 case red:
939 hue = (green - blue) / delta + (green < blue ? 6 : 0);
940 break;
941
942 case green:
943 hue = (blue - red) / delta + 2;
944 break;
945
946 default:
947 // blue case
948 hue = (red - green) / delta + 4;
949 break;
950 }
951
952 hue *= 60;
953
954 if (color.alpha !== undefined) {
955 return {
956 hue: hue,
957 saturation: saturation,
958 lightness: lightness,
959 alpha: color.alpha
960 };
961 }
962
963 return {
964 hue: hue,
965 saturation: saturation,
966 lightness: lightness
967 };
968 }
969 /**
970 * Returns an HslColor or HslaColor object. This utility function is only useful
971 * if want to extract a color component. With the color util `toColorString` you
972 * can convert a HslColor or HslaColor object back to a string.
973 *
974 * @example
975 * // Assigns `{ hue: 0, saturation: 1, lightness: 0.5 }` to color1
976 * const color1 = parseToHsl('rgb(255, 0, 0)');
977 * // Assigns `{ hue: 128, saturation: 1, lightness: 0.5, alpha: 0.75 }` to color2
978 * const color2 = parseToHsl('hsla(128, 100%, 50%, 0.75)');
979 */
980
981
982 function parseToHsl(color) {
983 // Note: At a later stage we can optimize this function as right now a hsl
984 // color would be parsed converted to rgb values and converted back to hsl.
985 return rgbToHsl(parseToRgb(color));
986 }
987 /**
988 * Reduces hex values if possible e.g. #ff8866 to #f86
989 * @private
990 */
991
992
993 var reduceHexValue = function reduceHexValue(value) {
994 if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
995 return "#" + value[1] + value[3] + value[5];
996 }
997
998 return value;
999 };
1000
1001 function numberToHex(value) {
1002 var hex = value.toString(16);
1003 return hex.length === 1 ? "0" + hex : hex;
1004 }
1005
1006 function colorToHex(color) {
1007 return numberToHex(Math.round(color * 255));
1008 }
1009
1010 function convertToHex(red, green, blue) {
1011 return reduceHexValue("#" + colorToHex(red) + colorToHex(green) + colorToHex(blue));
1012 }
1013
1014 function hslToHex(hue, saturation, lightness) {
1015 return hslToRgb(hue, saturation, lightness, convertToHex);
1016 }
1017 /**
1018 * Returns a string value for the color. The returned result is the smallest possible hex notation.
1019 *
1020 * @example
1021 * // Styles as object usage
1022 * const styles = {
1023 * background: hsl(359, 0.75, 0.4),
1024 * background: hsl({ hue: 360, saturation: 0.75, lightness: 0.4 }),
1025 * }
1026 *
1027 * // styled-components usage
1028 * const div = styled.div`
1029 * background: ${hsl(359, 0.75, 0.4)};
1030 * background: ${hsl({ hue: 360, saturation: 0.75, lightness: 0.4 })};
1031 * `
1032 *
1033 * // CSS in JS Output
1034 *
1035 * element {
1036 * background: "#b3191c";
1037 * background: "#b3191c";
1038 * }
1039 */
1040
1041
1042 function hsl(value, saturation, lightness) {
1043 if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number') {
1044 return hslToHex(value, saturation, lightness);
1045 } else if (_typeof(value) === 'object' && saturation === undefined && lightness === undefined) {
1046 return hslToHex(value.hue, value.saturation, value.lightness);
1047 }
1048
1049 throw new PolishedError(1);
1050 }
1051 /**
1052 * Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
1053 *
1054 * @example
1055 * // Styles as object usage
1056 * const styles = {
1057 * background: hsla(359, 0.75, 0.4, 0.7),
1058 * background: hsla({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0,7 }),
1059 * background: hsla(359, 0.75, 0.4, 1),
1060 * }
1061 *
1062 * // styled-components usage
1063 * const div = styled.div`
1064 * background: ${hsla(359, 0.75, 0.4, 0.7)};
1065 * background: ${hsla({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0,7 })};
1066 * background: ${hsla(359, 0.75, 0.4, 1)};
1067 * `
1068 *
1069 * // CSS in JS Output
1070 *
1071 * element {
1072 * background: "rgba(179,25,28,0.7)";
1073 * background: "rgba(179,25,28,0.7)";
1074 * background: "#b3191c";
1075 * }
1076 */
1077
1078
1079 function hsla(value, saturation, lightness, alpha) {
1080 if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number' && typeof alpha === 'number') {
1081 return alpha >= 1 ? hslToHex(value, saturation, lightness) : "rgba(" + hslToRgb(value, saturation, lightness) + "," + alpha + ")";
1082 } else if (_typeof(value) === 'object' && saturation === undefined && lightness === undefined && alpha === undefined) {
1083 return value.alpha >= 1 ? hslToHex(value.hue, value.saturation, value.lightness) : "rgba(" + hslToRgb(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
1084 }
1085
1086 throw new PolishedError(2);
1087 }
1088 /**
1089 * Returns a string value for the color. The returned result is the smallest possible hex notation.
1090 *
1091 * @example
1092 * // Styles as object usage
1093 * const styles = {
1094 * background: rgb(255, 205, 100),
1095 * background: rgb({ red: 255, green: 205, blue: 100 }),
1096 * }
1097 *
1098 * // styled-components usage
1099 * const div = styled.div`
1100 * background: ${rgb(255, 205, 100)};
1101 * background: ${rgb({ red: 255, green: 205, blue: 100 })};
1102 * `
1103 *
1104 * // CSS in JS Output
1105 *
1106 * element {
1107 * background: "#ffcd64";
1108 * background: "#ffcd64";
1109 * }
1110 */
1111
1112
1113 function rgb(value, green, blue) {
1114 if (typeof value === 'number' && typeof green === 'number' && typeof blue === 'number') {
1115 return reduceHexValue("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
1116 } else if (_typeof(value) === 'object' && green === undefined && blue === undefined) {
1117 return reduceHexValue("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
1118 }
1119
1120 throw new PolishedError(6);
1121 }
1122 /**
1123 * Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
1124 *
1125 * Can also be used to fade a color by passing a hex value or named CSS color along with an alpha value.
1126 *
1127 * @example
1128 * // Styles as object usage
1129 * const styles = {
1130 * background: rgba(255, 205, 100, 0.7),
1131 * background: rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 }),
1132 * background: rgba(255, 205, 100, 1),
1133 * background: rgba('#ffffff', 0.4),
1134 * background: rgba('black', 0.7),
1135 * }
1136 *
1137 * // styled-components usage
1138 * const div = styled.div`
1139 * background: ${rgba(255, 205, 100, 0.7)};
1140 * background: ${rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 })};
1141 * background: ${rgba(255, 205, 100, 1)};
1142 * background: ${rgba('#ffffff', 0.4)};
1143 * background: ${rgba('black', 0.7)};
1144 * `
1145 *
1146 * // CSS in JS Output
1147 *
1148 * element {
1149 * background: "rgba(255,205,100,0.7)";
1150 * background: "rgba(255,205,100,0.7)";
1151 * background: "#ffcd64";
1152 * background: "rgba(255,255,255,0.4)";
1153 * background: "rgba(0,0,0,0.7)";
1154 * }
1155 */
1156
1157
1158 function rgba(firstValue, secondValue, thirdValue, fourthValue) {
1159 if (typeof firstValue === 'string' && typeof secondValue === 'number') {
1160 var rgbValue = parseToRgb(firstValue);
1161 return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
1162 } else if (typeof firstValue === 'number' && typeof secondValue === 'number' && typeof thirdValue === 'number' && typeof fourthValue === 'number') {
1163 return fourthValue >= 1 ? rgb(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
1164 } else if (_typeof(firstValue) === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
1165 return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
1166 }
1167
1168 throw new PolishedError(7);
1169 }
1170
1171 var isRgb = function isRgb(color) {
1172 return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
1173 };
1174
1175 var isRgba = function isRgba(color) {
1176 return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && typeof color.alpha === 'number';
1177 };
1178
1179 var isHsl = function isHsl(color) {
1180 return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
1181 };
1182
1183 var isHsla = function isHsla(color) {
1184 return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && typeof color.alpha === 'number';
1185 };
1186 /**
1187 * Converts a RgbColor, RgbaColor, HslColor or HslaColor object to a color string.
1188 * This util is useful in case you only know on runtime which color object is
1189 * used. Otherwise we recommend to rely on `rgb`, `rgba`, `hsl` or `hsla`.
1190 *
1191 * @example
1192 * // Styles as object usage
1193 * const styles = {
1194 * background: toColorString({ red: 255, green: 205, blue: 100 }),
1195 * background: toColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 }),
1196 * background: toColorString({ hue: 240, saturation: 1, lightness: 0.5 }),
1197 * background: toColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 }),
1198 * }
1199 *
1200 * // styled-components usage
1201 * const div = styled.div`
1202 * background: ${toColorString({ red: 255, green: 205, blue: 100 })};
1203 * background: ${toColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 })};
1204 * background: ${toColorString({ hue: 240, saturation: 1, lightness: 0.5 })};
1205 * background: ${toColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 })};
1206 * `
1207 *
1208 * // CSS in JS Output
1209 * element {
1210 * background: "#ffcd64";
1211 * background: "rgba(255,205,100,0.72)";
1212 * background: "#00f";
1213 * background: "rgba(179,25,25,0.72)";
1214 * }
1215 */
1216
1217
1218 function toColorString(color) {
1219 if (_typeof(color) !== 'object') throw new PolishedError(8);
1220 if (isRgba(color)) return rgba(color);
1221 if (isRgb(color)) return rgb(color);
1222 if (isHsla(color)) return hsla(color);
1223 if (isHsl(color)) return hsl(color);
1224 throw new PolishedError(8);
1225 } // Type definitions taken from https://github.com/gcanti/flow-static-land/blob/master/src/Fun.js
1226 // eslint-disable-next-line no-unused-vars
1227 // eslint-disable-next-line no-unused-vars
1228 // eslint-disable-next-line no-redeclare
1229
1230
1231 function curried(f, length, acc) {
1232 return function fn() {
1233 // eslint-disable-next-line prefer-rest-params
1234 var combined = acc.concat(Array.prototype.slice.call(arguments));
1235 return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
1236 };
1237 } // eslint-disable-next-line no-redeclare
1238
1239
1240 function curry(f) {
1241 // eslint-disable-line no-redeclare
1242 return curried(f, f.length, []);
1243 }
1244
1245 function guard(lowerBoundary, upperBoundary, value) {
1246 return Math.max(lowerBoundary, Math.min(upperBoundary, value));
1247 }
1248 /**
1249 * Returns a string value for the darkened color.
1250 *
1251 * @example
1252 * // Styles as object usage
1253 * const styles = {
1254 * background: darken(0.2, '#FFCD64'),
1255 * background: darken('0.2', 'rgba(255,205,100,0.7)'),
1256 * }
1257 *
1258 * // styled-components usage
1259 * const div = styled.div`
1260 * background: ${darken(0.2, '#FFCD64')};
1261 * background: ${darken('0.2', 'rgba(255,205,100,0.7)')};
1262 * `
1263 *
1264 * // CSS in JS Output
1265 *
1266 * element {
1267 * background: "#ffbd31";
1268 * background: "rgba(255,189,49,0.7)";
1269 * }
1270 */
1271
1272
1273 function darken(amount, color) {
1274 if (color === 'transparent') return color;
1275 var hslColor = parseToHsl(color);
1276 return toColorString(_extends({}, hslColor, {
1277 lightness: guard(0, 1, hslColor.lightness - parseFloat(amount))
1278 }));
1279 } // prettier-ignore
1280
1281
1282 var curriedDarken = /*#__PURE__*/curry
1283 /* ::<number | string, string, string> */
1284 (darken);
1285
1286 function _templateObject$2() {
1287 var data = _taggedTemplateLiteral(["\n --size: ", ";\n\n .container {\n ", ";\n transform-style: preserve-3d;\n perspective: 2000px;\n transform: rotateX(-30deg) rotateY(-45deg);\n\n *,\n *:before,\n *:after {\n box-sizing: border-box;\n }\n }\n\n .holder {\n ", ";\n transform-style: preserve-3d;\n transform: translate3d(0em, var(--size), calc(var(--size) * 0.5));\n &:nth-child(3) {\n transform: rotateY(-90deg) rotateX(90deg) translate3d(0, var(--size), calc(var(--size) * 0.5));\n }\n &:first-child {\n transform: rotateZ(-90deg) rotateX(-90deg) translate3d(0, var(--size), calc(var(--size) * 0.5));\n }\n }\n\n ", "\n\n .info {\n ", ";\n padding-top: 180px;\n\n .title {\n font-size: 20px;\n font-weight: 400;\n text-align: center;\n color: #212121;\n }\n\n .detail {\n font-size: 14px;\n font-weight: 200;\n text-align: center;\n }\n }\n\n .box {\n ", ";\n transform-style: preserve-3d;\n animation: ani-box 6s infinite;\n width: var(--size);\n height: var(--size);\n //opacity: .9;\n &:before,\n &:after {\n position: absolute;\n width: 100%;\n height: 100%;\n content: '';\n }\n &:before {\n left: 100%;\n bottom: 0;\n transform: rotateY(90deg);\n transform-origin: 0 50%;\n }\n &:after {\n left: 0;\n bottom: 100%;\n transform: rotateX(90deg);\n transform-origin: 0 100%;\n }\n }\n\n @keyframes ani-box {\n 8.33% {\n transform: translate3d(-50%, -50%, 0) scaleZ(2);\n }\n 16.7% {\n transform: translate3d(-50%, -50%, calc(-1 * var(--size))) scaleZ(1);\n }\n 25% {\n transform: translate3d(-50%, -100%, calc(-1 * var(--size))) scaleY(2);\n }\n 33.3% {\n transform: translate3d(-50%, -150%, calc(-1 * var(--size))) scaleY(1);\n }\n 41.7% {\n transform: translate3d(-100%, -150%, calc(-1 * var(--size))) scaleX(2);\n }\n 50% {\n transform: translate3d(-150%, -150%, calc(-1 * var(--size))) scaleX(1);\n }\n 58.3% {\n transform: translate3d(-150%, -150%, 0) scaleZ(2);\n }\n 66.7% {\n transform: translate3d(-150%, -150%, 0) scaleZ(1);\n }\n 75% {\n transform: translate3d(-150%, -100%, 0) scaleY(2);\n }\n 83.3% {\n transform: translate3d(-150%, -50%, 0) scaleY(1);\n }\n 91.7% {\n transform: translate3d(-100%, -50%, 0) scaleX(2);\n }\n 100% {\n transform: translate3d(-50%, -50%, 0) scaleX(1);\n }\n }\n"]);
1288
1289 _templateObject$2 = function _templateObject() {
1290 return data;
1291 };
1292
1293 return data;
1294 }
1295
1296 var cbox = function cbox(props) {
1297 return "\nposition: absolute;\ntop: 50%;\nleft: 50%;\ntransform: translate(-50%, -50%);\n";
1298 };
1299
1300 var BoxShuffleContainer = styled.div(_templateObject$2(), function (props) {
1301 return props['size'] || '3em';
1302 }, cbox, cbox, function (props) {
1303 return (props.colors || ['#1FBCD3', '#CBE2B4', '#F6B6CA']).map(function (color, i) {
1304 return "\n .holder:nth-child(".concat(i + 1, "){\n .box{\n background-color: ").concat(color, ";\n &:before{\n background-color: ").concat(curriedDarken(0.2, color), ";\n }\n &:after{\n background-color: ").concat(curriedDarken(0.1, color), ";\n }\n }\n }\n }\n");
1305 });
1306 }, cbox, cbox);
1307 var BoxShuffle = exports('BoxShuffle', function BoxShuffle(props) {
1308 var title = props.title,
1309 detail = props.detail;
1310 return /*#__PURE__*/React.createElement(BoxShuffleContainer, null, /*#__PURE__*/React.createElement("div", {
1311 className: "container"
1312 }, /*#__PURE__*/React.createElement("div", {
1313 className: "holder"
1314 }, /*#__PURE__*/React.createElement("div", {
1315 className: "box"
1316 })), /*#__PURE__*/React.createElement("div", {
1317 className: "holder"
1318 }, /*#__PURE__*/React.createElement("div", {
1319 className: "box"
1320 })), /*#__PURE__*/React.createElement("div", {
1321 className: "holder"
1322 }, /*#__PURE__*/React.createElement("div", {
1323 className: "box"
1324 }))), /*#__PURE__*/React.createElement("div", {
1325 className: "info"
1326 }, /*#__PURE__*/React.createElement("div", {
1327 className: "title"
1328 }, title), /*#__PURE__*/React.createElement("div", {
1329 className: "detail"
1330 }, detail)));
1331 });
1332
1333 function _templateObject$3() {
1334 var data = _taggedTemplateLiteral(["\n width: 200px;\n height: 200px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n margin: auto;\n filter: url('#gooey-loader-filter');\n animation: rotate-move 2s ease-in-out infinite;\n\n .dot {\n width: 70px;\n height: 70px;\n border-radius: 50%;\n background-color: #000;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n margin: auto;\n }\n\n .dot-3 {\n background-color: #f74d75;\n animation: dot-3-move 2s ease infinite, index 6s ease infinite;\n }\n\n .dot-2 {\n background-color: #10beae;\n animation: dot-2-move 2s ease infinite, index 6s -4s ease infinite;\n }\n\n .dot-1 {\n background-color: #ffe386;\n animation: dot-1-move 2s ease infinite, index 6s -2s ease infinite;\n }\n\n @keyframes dot-3-move {\n 20% {\n transform: scale(1);\n }\n 45% {\n transform: translateY(-18px) scale(0.45);\n }\n 60% {\n transform: translateY(-90px) scale(0.45);\n }\n 80% {\n transform: translateY(-90px) scale(0.45);\n }\n 100% {\n transform: translateY(0px) scale(1);\n }\n }\n\n @keyframes dot-2-move {\n 20% {\n transform: scale(1);\n }\n 45% {\n transform: translate(-16px, 12px) scale(0.45);\n }\n 60% {\n transform: translate(-80px, 60px) scale(0.45);\n }\n 80% {\n transform: translate(-80px, 60px) scale(0.45);\n }\n 100% {\n transform: translateY(0px) scale(1);\n }\n }\n\n @keyframes dot-1-move {\n 20% {\n transform: scale(1);\n }\n 45% {\n transform: translate(16px, 12px) scale(0.45);\n }\n 60% {\n transform: translate(80px, 60px) scale(0.45);\n }\n 80% {\n transform: translate(80px, 60px) scale(0.45);\n }\n 100% {\n transform: translateY(0px) scale(1);\n }\n }\n\n @keyframes rotate-move {\n 55% {\n transform: translate(-50%, -50%) rotate(0deg);\n }\n 80% {\n transform: translate(-50%, -50%) rotate(360deg);\n }\n 100% {\n transform: translate(-50%, -50%) rotate(360deg);\n }\n }\n\n @keyframes index {\n 0%,\n 100% {\n z-index: 3;\n }\n 33.3% {\n z-index: 2;\n }\n 66.6% {\n z-index: 1;\n }\n }\n"]);
1335
1336 _templateObject$3 = function _templateObject() {
1337 return data;
1338 };
1339
1340 return data;
1341 }
1342 var GooeyLoaderContainer = styled.div(_templateObject$3());
1343
1344 function loadSvgFilter() {
1345 if (typeof window === 'undefined') {
1346 return;
1347 }
1348
1349 if (document.querySelector('#GooeyLoaderSvgFilter')) {
1350 return;
1351 }
1352
1353 var el = document.createElement('div');
1354 el.id = 'GooeyLoaderSvgFilter';
1355 el.innerHTML = "\n<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n <defs>\n <filter id=\"gooey-loader-filter\">\n <feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"10\" result=\"blur\" />\n <feColorMatrix in=\"blur\" mode=\"matrix\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 21 -7\"/>\n </filter>\n </defs>\n</svg>\n";
1356 document.body.appendChild(el);
1357 }
1358 /**
1359 * GooeyLoader
1360 *
1361 * @see https://codepen.io/Izumenko/pen/MpWyXK
1362 */
1363
1364
1365 var GooeyLoader = exports('GooeyLoader', function GooeyLoader() {
1366 loadSvgFilter();
1367 return /*#__PURE__*/React.createElement(GooeyLoaderContainer, null, /*#__PURE__*/React.createElement("div", {
1368 className: "dot dot-1"
1369 }), /*#__PURE__*/React.createElement("div", {
1370 className: "dot dot-2"
1371 }), /*#__PURE__*/React.createElement("div", {
1372 className: "dot dot-3"
1373 }));
1374 });
1375
1376 function useAsyncEffect(effect, deps) {
1377 var ref = useRef();
1378 useEffect(function () {
1379 effect({
1380 setCloser: function setCloser(v) {
1381 return ref.current = v;
1382 }
1383 }).then(function (v) {
1384 return typeof v === 'function' ? ref.current = v : null;
1385 })["catch"](function (e) {
1386 console.trace("useAsyncEffect error", deps, e);
1387 });
1388 return function () {
1389 var _ref$current;
1390
1391 return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.call(ref);
1392 };
1393 }, deps);
1394 }
1395
1396 /**
1397 * create only once
1398 *
1399 * @see https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily
1400 * @see https://github.com/Andarist/use-constant/blob/master/src/index.ts
1401 */
1402 function useConstant(fn) {
1403 var ref = React.useRef();
1404
1405 if (!ref.current) {
1406 ref.current = {
1407 v: fn()
1408 };
1409 }
1410
1411 return ref.current.v;
1412 }
1413
1414 function useDebounceEffect(cb, deps, wait) {
1415 var bounce = useMemo(function () {
1416 return debounce(function () {
1417 cb === null || cb === void 0 ? void 0 : cb();
1418 }, wait);
1419 }, [cb, wait]);
1420 useEffect(function () {
1421 bounce();
1422 return function () {
1423 return bounce.cancel();
1424 };
1425 }, deps);
1426 }
1427
1428 function useForceRender() {
1429 // const [, set] = useState();
1430 // return () => set({});
1431 var _useReducer = useReducer(function (s) {
1432 return s + 1;
1433 }, 0),
1434 _useReducer2 = _slicedToArray(_useReducer, 2),
1435 forceRender = _useReducer2[1];
1436
1437 return forceRender;
1438 }
1439
1440 function useInterval(handler, interval) {
1441 var ref = useRef(); // const [count, setCount] = useState(0);
1442 // useEffect(handler, [count]);
1443
1444 useEffect(function () {
1445 // ref.current = setInterval(() => setCount(v => v + 1), interval);
1446 ref.current = setInterval(handler, interval);
1447 return function () {
1448 return clearInterval(ref.current);
1449 };
1450 }, [interval]);
1451 }
1452
1453 /**
1454 * 配合 nextjs 可以实现只有客户端才渲染的组件
1455 * @see https://github.com/zeit/next.js/blob/canary/examples/progressive-render/pages/index.js
1456 */
1457
1458 function useMounted() {
1459 var _useState = useState(false),
1460 _useState2 = _slicedToArray(_useState, 2),
1461 mounted = _useState2[0],
1462 setMounted = _useState2[1];
1463
1464 useEffect(function () {
1465 return setMounted(true);
1466 }, []);
1467 return mounted;
1468 }
1469
1470 function useOnlineEffect() {
1471 var _window, _window$navigator;
1472
1473 var _useState = useState((_window = window) === null || _window === void 0 ? void 0 : (_window$navigator = _window.navigator) === null || _window$navigator === void 0 ? void 0 : _window$navigator.onLine),
1474 _useState2 = _slicedToArray(_useState, 2),
1475 online = _useState2[0],
1476 setOnline = _useState2[1];
1477
1478 useEffect(function () {
1479 var handler = function handler(e) {
1480 return setOnline(e.type === 'online');
1481 };
1482
1483 window.addEventListener('online', handler);
1484 window.addEventListener('offline', handler);
1485 return function () {
1486 window.removeEventListener('online', handler);
1487 window.removeEventListener('offline', handler);
1488 };
1489 }, []);
1490 return online;
1491 }
1492
1493 var NamedThemeContext = /*#__PURE__*/React.createContext(new BehaviorSubject(null));
1494 function NamedThemeProvider(_ref) {
1495 var children = _ref.children,
1496 initialTheme = _ref.initialTheme;
1497 var state = useConstant(function () {
1498 return new BehaviorSubject(typeof initialTheme === 'function' ? initialTheme() : initialTheme);
1499 });
1500 useEffect(function () {
1501 return function () {
1502 return state.complete();
1503 };
1504 }, []);
1505 return /*#__PURE__*/React.createElement(NamedThemeContext.Provider, {
1506 value: state
1507 }, children);
1508 }
1509 function useNamedTheme() {
1510 var state = useContext(NamedThemeContext);
1511
1512 var _useState = useState(state.value),
1513 _useState2 = _slicedToArray(_useState, 2),
1514 theme = _useState2[0],
1515 setTheme = _useState2[1];
1516
1517 useEffect(function () {
1518 var subscribe = state.subscribe(setTheme);
1519 return subscribe.unsubscribe.bind(subscribe);
1520 }, [state]);
1521 return [theme, function (v) {
1522 return state.next(v);
1523 }];
1524 }
1525
1526 function useEffectOnce(effect) {
1527 React.useEffect(effect, []);
1528 }
1529
1530 function isPromise(v) {
1531 return v && v.then && v["catch"];
1532 }
1533
1534 function usePromiseEffect(v) {
1535 var _React$useState = React.useState(function () {
1536 if (isPromise(v)) {
1537 return {
1538 loading: true
1539 };
1540 }
1541
1542 return {
1543 loading: false,
1544 data: v
1545 };
1546 }),
1547 _React$useState2 = _slicedToArray(_React$useState, 2),
1548 state = _React$useState2[0],
1549 setState = _React$useState2[1];
1550
1551 React.useEffect(function () {
1552 if (isPromise(v)) {
1553 setState(function (state) {
1554 return _objectSpread2(_objectSpread2({}, state), {}, {
1555 loading: true,
1556 error: undefined
1557 });
1558 });
1559 v.then(function (data) {
1560 return setState({
1561 loading: false,
1562 data: data
1563 });
1564 })["catch"](function (error) {
1565 return setState({
1566 loading: false,
1567 error: error
1568 });
1569 });
1570 } else {
1571 // prevent useless state change
1572 setState(function (state) {
1573 if (state.data === v) {
1574 return state;
1575 }
1576
1577 return {
1578 loading: false,
1579 data: v
1580 };
1581 });
1582 }
1583 }, [v]);
1584 return state;
1585 }
1586
1587 function useFetchEffect(fetcher, deps) {
1588 var _React$useState = React.useState(function () {
1589 try {
1590 return fetcher();
1591 } catch (error) {
1592 return Promise.reject(error);
1593 }
1594 }),
1595 _React$useState2 = _slicedToArray(_React$useState, 2),
1596 result = _React$useState2[0],
1597 setResult = _React$useState2[1];
1598
1599 var initial = React.useRef(true);
1600 React.useEffect(function () {
1601 if (initial.current) {
1602 initial.current = false;
1603 return;
1604 }
1605
1606 try {
1607 setResult(fetcher());
1608 } catch (error) {
1609 setResult(Promise.reject(error));
1610 }
1611 }, deps);
1612 return usePromiseEffect(result);
1613 }
1614
1615 /*! *****************************************************************************
1616 Copyright (c) Microsoft Corporation.
1617
1618 Permission to use, copy, modify, and/or distribute this software for any
1619 purpose with or without fee is hereby granted.
1620
1621 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1622 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1623 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1624 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1625 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1626 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1627 PERFORMANCE OF THIS SOFTWARE.
1628 ***************************************************************************** */
1629
1630 /* global Reflect, Promise */
1631 var _extendStatics = function extendStatics(d, b) {
1632 _extendStatics = Object.setPrototypeOf || {
1633 __proto__: []
1634 } instanceof Array && function (d, b) {
1635 d.__proto__ = b;
1636 } || function (d, b) {
1637 for (var p in b) {
1638 if (b.hasOwnProperty(p)) d[p] = b[p];
1639 }
1640 };
1641
1642 return _extendStatics(d, b);
1643 };
1644
1645 function __extends(d, b) {
1646 _extendStatics(d, b);
1647
1648 function __() {
1649 this.constructor = d;
1650 }
1651
1652 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1653 }
1654
1655 /** PURE_IMPORTS_START PURE_IMPORTS_END */
1656 function isFunction(x) {
1657 return typeof x === 'function';
1658 }
1659
1660 /** PURE_IMPORTS_START PURE_IMPORTS_END */
1661 var _enable_super_gross_mode_that_will_cause_bad_things = false;
1662 var config = {
1663 Promise: undefined,
1664
1665 set useDeprecatedSynchronousErrorHandling(value) {
1666 if (value) {
1667 var error = /*@__PURE__*/new Error();
1668 /*@__PURE__*/
1669
1670 console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
1671 }
1672
1673 _enable_super_gross_mode_that_will_cause_bad_things = value;
1674 },
1675
1676 get useDeprecatedSynchronousErrorHandling() {
1677 return _enable_super_gross_mode_that_will_cause_bad_things;
1678 }
1679
1680 };
1681
1682 /** PURE_IMPORTS_START PURE_IMPORTS_END */
1683 function hostReportError(err) {
1684 setTimeout(function () {
1685 throw err;
1686 }, 0);
1687 }
1688
1689 /** PURE_IMPORTS_START _config,_util_hostReportError PURE_IMPORTS_END */
1690 var empty = {
1691 closed: true,
1692 next: function next(value) {},
1693 error: function error(err) {
1694 if (config.useDeprecatedSynchronousErrorHandling) {
1695 throw err;
1696 } else {
1697 hostReportError(err);
1698 }
1699 },
1700 complete: function complete() {}
1701 };
1702
1703 /** PURE_IMPORTS_START PURE_IMPORTS_END */
1704 var isArray = /*@__PURE__*/function () {
1705 return Array.isArray || function (x) {
1706 return x && typeof x.length === 'number';
1707 };
1708 }();
1709
1710 /** PURE_IMPORTS_START PURE_IMPORTS_END */
1711 function isObject(x) {
1712 return x !== null && _typeof(x) === 'object';
1713 }
1714
1715 /** PURE_IMPORTS_START PURE_IMPORTS_END */
1716 var UnsubscriptionErrorImpl = /*@__PURE__*/function () {
1717 function UnsubscriptionErrorImpl(errors) {
1718 Error.call(this);
1719 this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) {
1720 return i + 1 + ") " + err.toString();
1721 }).join('\n ') : '';
1722 this.name = 'UnsubscriptionError';
1723 this.errors = errors;
1724 return this;
1725 }
1726
1727 UnsubscriptionErrorImpl.prototype = /*@__PURE__*/Object.create(Error.prototype);
1728 return UnsubscriptionErrorImpl;
1729 }();
1730
1731 var UnsubscriptionError = UnsubscriptionErrorImpl;
1732
1733 var Subscription = /*@__PURE__*/function () {
1734 function Subscription(unsubscribe) {
1735 this.closed = false;
1736 this._parentOrParents = null;
1737 this._subscriptions = null;
1738
1739 if (unsubscribe) {
1740 this._unsubscribe = unsubscribe;
1741 }
1742 }
1743
1744 Subscription.prototype.unsubscribe = function () {
1745 var errors;
1746
1747 if (this.closed) {
1748 return;
1749 }
1750
1751 var _a = this,
1752 _parentOrParents = _a._parentOrParents,
1753 _unsubscribe = _a._unsubscribe,
1754 _subscriptions = _a._subscriptions;
1755
1756 this.closed = true;
1757 this._parentOrParents = null;
1758 this._subscriptions = null;
1759
1760 if (_parentOrParents instanceof Subscription) {
1761 _parentOrParents.remove(this);
1762 } else if (_parentOrParents !== null) {
1763 for (var index = 0; index < _parentOrParents.length; ++index) {
1764 var parent_1 = _parentOrParents[index];
1765 parent_1.remove(this);
1766 }
1767 }
1768
1769 if (isFunction(_unsubscribe)) {
1770 try {
1771 _unsubscribe.call(this);
1772 } catch (e) {
1773 errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
1774 }
1775 }
1776
1777 if (isArray(_subscriptions)) {
1778 var index = -1;
1779 var len = _subscriptions.length;
1780
1781 while (++index < len) {
1782 var sub = _subscriptions[index];
1783
1784 if (isObject(sub)) {
1785 try {
1786 sub.unsubscribe();
1787 } catch (e) {
1788 errors = errors || [];
1789
1790 if (e instanceof UnsubscriptionError) {
1791 errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
1792 } else {
1793 errors.push(e);
1794 }
1795 }
1796 }
1797 }
1798 }
1799
1800 if (errors) {
1801 throw new UnsubscriptionError(errors);
1802 }
1803 };
1804
1805 Subscription.prototype.add = function (teardown) {
1806 var subscription = teardown;
1807
1808 if (!teardown) {
1809 return Subscription.EMPTY;
1810 }
1811
1812 switch (_typeof(teardown)) {
1813 case 'function':
1814 subscription = new Subscription(teardown);
1815
1816 case 'object':
1817 if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
1818 return subscription;
1819 } else if (this.closed) {
1820 subscription.unsubscribe();
1821 return subscription;
1822 } else if (!(subscription instanceof Subscription)) {
1823 var tmp = subscription;
1824 subscription = new Subscription();
1825 subscription._subscriptions = [tmp];
1826 }
1827
1828 break;
1829
1830 default:
1831 {
1832 throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
1833 }
1834 }
1835
1836 var _parentOrParents = subscription._parentOrParents;
1837
1838 if (_parentOrParents === null) {
1839 subscription._parentOrParents = this;
1840 } else if (_parentOrParents instanceof Subscription) {
1841 if (_parentOrParents === this) {
1842 return subscription;
1843 }
1844
1845 subscription._parentOrParents = [_parentOrParents, this];
1846 } else if (_parentOrParents.indexOf(this) === -1) {
1847 _parentOrParents.push(this);
1848 } else {
1849 return subscription;
1850 }
1851
1852 var subscriptions = this._subscriptions;
1853
1854 if (subscriptions === null) {
1855 this._subscriptions = [subscription];
1856 } else {
1857 subscriptions.push(subscription);
1858 }
1859
1860 return subscription;
1861 };
1862
1863 Subscription.prototype.remove = function (subscription) {
1864 var subscriptions = this._subscriptions;
1865
1866 if (subscriptions) {
1867 var subscriptionIndex = subscriptions.indexOf(subscription);
1868
1869 if (subscriptionIndex !== -1) {
1870 subscriptions.splice(subscriptionIndex, 1);
1871 }
1872 }
1873 };
1874
1875 Subscription.EMPTY = function (empty) {
1876 empty.closed = true;
1877 return empty;
1878 }(new Subscription());
1879
1880 return Subscription;
1881 }();
1882
1883 function flattenUnsubscriptionErrors(errors) {
1884 return errors.reduce(function (errs, err) {
1885 return errs.concat(err instanceof UnsubscriptionError ? err.errors : err);
1886 }, []);
1887 }
1888
1889 /** PURE_IMPORTS_START PURE_IMPORTS_END */
1890 var rxSubscriber = /*@__PURE__*/function () {
1891 return typeof Symbol === 'function' ? /*@__PURE__*/Symbol('rxSubscriber') : '@@rxSubscriber_' + /*@__PURE__*/Math.random();
1892 }();
1893
1894 var Subscriber = /*@__PURE__*/function (_super) {
1895 __extends(Subscriber, _super);
1896
1897 function Subscriber(destinationOrNext, error, complete) {
1898 var _this = _super.call(this) || this;
1899
1900 _this.syncErrorValue = null;
1901 _this.syncErrorThrown = false;
1902 _this.syncErrorThrowable = false;
1903 _this.isStopped = false;
1904
1905 switch (arguments.length) {
1906 case 0:
1907 _this.destination = empty;
1908 break;
1909
1910 case 1:
1911 if (!destinationOrNext) {
1912 _this.destination = empty;
1913 break;
1914 }
1915
1916 if (_typeof(destinationOrNext) === 'object') {
1917 if (destinationOrNext instanceof Subscriber) {
1918 _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
1919 _this.destination = destinationOrNext;
1920 destinationOrNext.add(_this);
1921 } else {
1922 _this.syncErrorThrowable = true;
1923 _this.destination = new SafeSubscriber(_this, destinationOrNext);
1924 }
1925
1926 break;
1927 }
1928
1929 default:
1930 _this.syncErrorThrowable = true;
1931 _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
1932 break;
1933 }
1934
1935 return _this;
1936 }
1937
1938 Subscriber.prototype[rxSubscriber] = function () {
1939 return this;
1940 };
1941
1942 Subscriber.create = function (next, error, complete) {
1943 var subscriber = new Subscriber(next, error, complete);
1944 subscriber.syncErrorThrowable = false;
1945 return subscriber;
1946 };
1947
1948 Subscriber.prototype.next = function (value) {
1949 if (!this.isStopped) {
1950 this._next(value);
1951 }
1952 };
1953
1954 Subscriber.prototype.error = function (err) {
1955 if (!this.isStopped) {
1956 this.isStopped = true;
1957
1958 this._error(err);
1959 }
1960 };
1961
1962 Subscriber.prototype.complete = function () {
1963 if (!this.isStopped) {
1964 this.isStopped = true;
1965
1966 this._complete();
1967 }
1968 };
1969
1970 Subscriber.prototype.unsubscribe = function () {
1971 if (this.closed) {
1972 return;
1973 }
1974
1975 this.isStopped = true;
1976
1977 _super.prototype.unsubscribe.call(this);
1978 };
1979
1980 Subscriber.prototype._next = function (value) {
1981 this.destination.next(value);
1982 };
1983
1984 Subscriber.prototype._error = function (err) {
1985 this.destination.error(err);
1986 this.unsubscribe();
1987 };
1988
1989 Subscriber.prototype._complete = function () {
1990 this.destination.complete();
1991 this.unsubscribe();
1992 };
1993
1994 Subscriber.prototype._unsubscribeAndRecycle = function () {
1995 var _parentOrParents = this._parentOrParents;
1996 this._parentOrParents = null;
1997 this.unsubscribe();
1998 this.closed = false;
1999 this.isStopped = false;
2000 this._parentOrParents = _parentOrParents;
2001 return this;
2002 };
2003
2004 return Subscriber;
2005 }(Subscription);
2006
2007 var SafeSubscriber = /*@__PURE__*/function (_super) {
2008 __extends(SafeSubscriber, _super);
2009
2010 function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
2011 var _this = _super.call(this) || this;
2012
2013 _this._parentSubscriber = _parentSubscriber;
2014 var next;
2015 var context = _this;
2016
2017 if (isFunction(observerOrNext)) {
2018 next = observerOrNext;
2019 } else if (observerOrNext) {
2020 next = observerOrNext.next;
2021 error = observerOrNext.error;
2022 complete = observerOrNext.complete;
2023
2024 if (observerOrNext !== empty) {
2025 context = Object.create(observerOrNext);
2026
2027 if (isFunction(context.unsubscribe)) {
2028 _this.add(context.unsubscribe.bind(context));
2029 }
2030
2031 context.unsubscribe = _this.unsubscribe.bind(_this);
2032 }
2033 }
2034
2035 _this._context = context;
2036 _this._next = next;
2037 _this._error = error;
2038 _this._complete = complete;
2039 return _this;
2040 }
2041
2042 SafeSubscriber.prototype.next = function (value) {
2043 if (!this.isStopped && this._next) {
2044 var _parentSubscriber = this._parentSubscriber;
2045
2046 if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
2047 this.__tryOrUnsub(this._next, value);
2048 } else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
2049 this.unsubscribe();
2050 }
2051 }
2052 };
2053
2054 SafeSubscriber.prototype.error = function (err) {
2055 if (!this.isStopped) {
2056 var _parentSubscriber = this._parentSubscriber;
2057 var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
2058
2059 if (this._error) {
2060 if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
2061 this.__tryOrUnsub(this._error, err);
2062
2063 this.unsubscribe();
2064 } else {
2065 this.__tryOrSetError(_parentSubscriber, this._error, err);
2066
2067 this.unsubscribe();
2068 }
2069 } else if (!_parentSubscriber.syncErrorThrowable) {
2070 this.unsubscribe();
2071
2072 if (useDeprecatedSynchronousErrorHandling) {
2073 throw err;
2074 }
2075
2076 hostReportError(err);
2077 } else {
2078 if (useDeprecatedSynchronousErrorHandling) {
2079 _parentSubscriber.syncErrorValue = err;
2080 _parentSubscriber.syncErrorThrown = true;
2081 } else {
2082 hostReportError(err);
2083 }
2084
2085 this.unsubscribe();
2086 }
2087 }
2088 };
2089
2090 SafeSubscriber.prototype.complete = function () {
2091 var _this = this;
2092
2093 if (!this.isStopped) {
2094 var _parentSubscriber = this._parentSubscriber;
2095
2096 if (this._complete) {
2097 var wrappedComplete = function wrappedComplete() {
2098 return _this._complete.call(_this._context);
2099 };
2100
2101 if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
2102 this.__tryOrUnsub(wrappedComplete);
2103
2104 this.unsubscribe();
2105 } else {
2106 this.__tryOrSetError(_parentSubscriber, wrappedComplete);
2107
2108 this.unsubscribe();
2109 }
2110 } else {
2111 this.unsubscribe();
2112 }
2113 }
2114 };
2115
2116 SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
2117 try {
2118 fn.call(this._context, value);
2119 } catch (err) {
2120 this.unsubscribe();
2121
2122 if (config.useDeprecatedSynchronousErrorHandling) {
2123 throw err;
2124 } else {
2125 hostReportError(err);
2126 }
2127 }
2128 };
2129
2130 SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
2131 if (!config.useDeprecatedSynchronousErrorHandling) {
2132 throw new Error('bad call');
2133 }
2134
2135 try {
2136 fn.call(this._context, value);
2137 } catch (err) {
2138 if (config.useDeprecatedSynchronousErrorHandling) {
2139 parent.syncErrorValue = err;
2140 parent.syncErrorThrown = true;
2141 return true;
2142 } else {
2143 hostReportError(err);
2144 return true;
2145 }
2146 }
2147
2148 return false;
2149 };
2150
2151 SafeSubscriber.prototype._unsubscribe = function () {
2152 var _parentSubscriber = this._parentSubscriber;
2153 this._context = null;
2154 this._parentSubscriber = null;
2155
2156 _parentSubscriber.unsubscribe();
2157 };
2158
2159 return SafeSubscriber;
2160 }(Subscriber);
2161
2162 /** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */
2163 function skip(count) {
2164 return function (source) {
2165 return source.lift(new SkipOperator(count));
2166 };
2167 }
2168
2169 var SkipOperator = /*@__PURE__*/function () {
2170 function SkipOperator(total) {
2171 this.total = total;
2172 }
2173
2174 SkipOperator.prototype.call = function (subscriber, source) {
2175 return source.subscribe(new SkipSubscriber(subscriber, this.total));
2176 };
2177
2178 return SkipOperator;
2179 }();
2180
2181 var SkipSubscriber = /*@__PURE__*/function (_super) {
2182 __extends(SkipSubscriber, _super);
2183
2184 function SkipSubscriber(destination, total) {
2185 var _this = _super.call(this, destination) || this;
2186
2187 _this.total = total;
2188 _this.count = 0;
2189 return _this;
2190 }
2191
2192 SkipSubscriber.prototype._next = function (x) {
2193 if (++this.count > this.total) {
2194 this.destination.next(x);
2195 }
2196 };
2197
2198 return SkipSubscriber;
2199 }(Subscriber);
2200
2201 function n(n) {
2202 for (var t = arguments.length, r = Array(t > 1 ? t - 1 : 0), e = 1; e < t; e++) {
2203 r[e - 1] = arguments[e];
2204 }
2205
2206 if ("production" !== process.env.NODE_ENV) {
2207 var i = L[n],
2208 o = i ? "function" == typeof i ? i.apply(null, r) : i : "unknown error nr: " + n;
2209 throw Error("[Immer] " + o);
2210 }
2211
2212 throw Error("[Immer] minified error nr: " + n + (r.length ? " " + r.join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf");
2213 }
2214
2215 function t(n) {
2216 return !!n && !!n[G];
2217 }
2218
2219 function r(n) {
2220 return !!n && (function (n) {
2221 if (!n || "object" != _typeof(n)) return !1;
2222 var t = Object.getPrototypeOf(n);
2223 return !t || t === Object.prototype;
2224 }(n) || Array.isArray(n) || !!n[B] || !!n.constructor[B] || c(n) || s(n));
2225 }
2226
2227 function i(n, t, r) {
2228 void 0 === r && (r = !1), 0 === o(n) ? (r ? Object.keys : Q)(n).forEach(function (r) {
2229 return t(r, n[r], n);
2230 }) : n.forEach(function (r, e) {
2231 return t(e, r, n);
2232 });
2233 }
2234
2235 function o(n) {
2236 var t = n[G];
2237 return t ? t.i > 3 ? t.i - 4 : t.i : Array.isArray(n) ? 1 : c(n) ? 2 : s(n) ? 3 : 0;
2238 }
2239
2240 function u(n, t) {
2241 return 2 === o(n) ? n.has(t) : Object.prototype.hasOwnProperty.call(n, t);
2242 }
2243
2244 function a(n, t) {
2245 return 2 === o(n) ? n.get(t) : n[t];
2246 }
2247
2248 function f(n, t) {
2249 return n === t ? 0 !== n || 1 / n == 1 / t : n != n && t != t;
2250 }
2251
2252 function c(n) {
2253 return U && n instanceof Map;
2254 }
2255
2256 function s(n) {
2257 return W && n instanceof Set;
2258 }
2259
2260 function v(n) {
2261 return n.o || n.t;
2262 }
2263
2264 function p(t, r) {
2265 if (void 0 === r && (r = !1), Array.isArray(t)) return t.slice();
2266 var e = Object.create(Object.getPrototypeOf(t));
2267 return i(t, function (i) {
2268 if (i !== G) {
2269 var o = Object.getOwnPropertyDescriptor(t, i),
2270 u = o.value;
2271 o.get && (r || n(1), u = o.get.call(t)), o.enumerable ? e[i] = u : Object.defineProperty(e, i, {
2272 value: u,
2273 writable: !0,
2274 configurable: !0
2275 });
2276 }
2277 }), e;
2278 }
2279
2280 function d(n, e) {
2281 t(n) || h(n) || !r(n) || (o(n) > 1 && (n.set = n.add = n.clear = n["delete"] = l), Object.freeze(n), e && i(n, function (n, t) {
2282 return d(t, !0);
2283 }, !0));
2284 }
2285
2286 function l() {
2287 n(2);
2288 }
2289
2290 function h(n) {
2291 return null == n || "object" != _typeof(n) || Object.isFrozen(n);
2292 }
2293
2294 function y(t) {
2295 var r = V[t];
2296 return r || n("production" !== process.env.NODE_ENV ? 18 : 19, t), r;
2297 }
2298
2299 function m() {
2300 return "production" === process.env.NODE_ENV || K || n(0), K;
2301 }
2302
2303 function _(n, t) {
2304 t && (y("Patches"), n.u = [], n.s = [], n.v = t);
2305 }
2306
2307 function j(n) {
2308 O(n), n.p.forEach(w), n.p = null;
2309 }
2310
2311 function O(n) {
2312 n === K && (K = n.l);
2313 }
2314
2315 function g(n) {
2316 return K = {
2317 p: [],
2318 l: K,
2319 h: n,
2320 m: !0,
2321 _: 0
2322 };
2323 }
2324
2325 function w(n) {
2326 var t = n[G];
2327 0 === t.i || 1 === t.i ? t.j() : t.O = !0;
2328 }
2329
2330 function S(t, e) {
2331 e._ = e.p.length;
2332 var i = e.p[0],
2333 o = void 0 !== t && t !== i;
2334 return e.h.g || y("ES5").S(e, t, o), o ? (i[G].P && (j(e), n(4)), r(t) && (t = P(e, t), e.l || A(e, t)), e.u && y("Patches").M(i[G], t, e.u, e.s)) : t = P(e, i, []), j(e), e.u && e.v(e.u, e.s), t !== q ? t : void 0;
2335 }
2336
2337 function P(n, t, r) {
2338 if (h(t)) return t;
2339 var e = t[G];
2340 if (!e) return i(t, function (i, o) {
2341 return M(n, e, t, i, o, r);
2342 }, !0), t;
2343 if (e.A !== n) return t;
2344 if (!e.P) return A(n, e.t, !0), e.t;
2345
2346 if (!e.I) {
2347 e.I = !0, e.A._--;
2348 var o = 4 === e.i || 5 === e.i ? e.o = p(e.k, !0) : e.o;
2349 i(o, function (t, i) {
2350 return M(n, e, o, t, i, r);
2351 }), A(n, o, !1), r && n.u && y("Patches").R(e, r, n.u, n.s);
2352 }
2353
2354 return e.o;
2355 }
2356
2357 function M(e, i, c, s, v, p) {
2358 if ("production" !== process.env.NODE_ENV && v === c && n(5), t(v)) {
2359 var d = P(e, v, p && i && 3 !== i.i && !u(i.D, s) ? p.concat(s) : void 0);
2360 if (h = s, y = d, 2 === (b = o(l = c)) ? l.set(h, y) : 3 === b ? (l["delete"](h), l.add(y)) : l[h] = y, !t(d)) return;
2361 e.m = !1;
2362 }
2363
2364 var l, h, y, b;
2365
2366 if ((!i || !f(v, a(i.t, s))) && r(v)) {
2367 if (!e.h.N && e._ < 1) return;
2368 P(e, v), i && i.A.l || A(e, v);
2369 }
2370 }
2371
2372 function A(n, t, r) {
2373 void 0 === r && (r = !1), n.h.N && n.m && d(t, r);
2374 }
2375
2376 function x(n, t) {
2377 var r = n[G],
2378 e = Reflect.getOwnPropertyDescriptor(r ? v(r) : n, t);
2379 return e && e.value;
2380 }
2381
2382 function z(n) {
2383 if (!n.P) {
2384 if (n.P = !0, 0 === n.i || 1 === n.i) {
2385 var t = n.o = p(n.t);
2386 i(n.p, function (n, r) {
2387 t[n] = r;
2388 }), n.p = void 0;
2389 }
2390
2391 n.l && z(n.l);
2392 }
2393 }
2394
2395 function I(n) {
2396 n.o || (n.o = p(n.t));
2397 }
2398
2399 function E(n, t, r) {
2400 var e = c(t) ? y("MapSet").T(t, r) : s(t) ? y("MapSet").F(t, r) : n.g ? function (n, t) {
2401 var r = Array.isArray(n),
2402 e = {
2403 i: r ? 1 : 0,
2404 A: t ? t.A : m(),
2405 P: !1,
2406 I: !1,
2407 D: {},
2408 l: t,
2409 t: n,
2410 k: null,
2411 p: {},
2412 o: null,
2413 j: null,
2414 C: !1
2415 },
2416 i = e,
2417 o = Y;
2418 r && (i = [e], o = Z);
2419 var u = Proxy.revocable(i, o),
2420 a = u.revoke,
2421 f = u.proxy;
2422 return e.k = f, e.j = a, f;
2423 }(t, r) : y("ES5").J(t, r);
2424 return (r ? r.A : m()).p.push(e), e;
2425 }
2426
2427 var J,
2428 K,
2429 $ = "undefined" != typeof Symbol && "symbol" == _typeof(Symbol("x")),
2430 U = "undefined" != typeof Map,
2431 W = "undefined" != typeof Set,
2432 X = "undefined" != typeof Proxy && void 0 !== Proxy.revocable && "undefined" != typeof Reflect,
2433 q = $ ? Symbol("immer-nothing") : ((J = {})["immer-nothing"] = !0, J),
2434 B = $ ? Symbol("immer-draftable") : "__$immer_draftable",
2435 G = $ ? Symbol("immer-state") : "__$immer_state",
2436 L = {
2437 0: "Illegal state",
2438 1: "Immer drafts cannot have computed properties",
2439 2: "This object has been frozen and should not be mutated",
2440 3: function _(n) {
2441 return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + n;
2442 },
2443 4: "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
2444 5: "Immer forbids circular references",
2445 6: "The first or second argument to `produce` must be a function",
2446 7: "The third argument to `produce` must be a function or undefined",
2447 8: "First argument to `createDraft` must be a plain object, an array, or an immerable object",
2448 9: "First argument to `finishDraft` must be a draft returned by `createDraft`",
2449 10: "The given draft is already finalized",
2450 11: "Object.defineProperty() cannot be used on an Immer draft",
2451 12: "Object.setPrototypeOf() cannot be used on an Immer draft",
2452 13: "Immer only supports deleting array indices",
2453 14: "Immer only supports setting array indices and the 'length' property",
2454 15: function _(n) {
2455 return "Cannot apply patch, path doesn't resolve: " + n;
2456 },
2457 16: 'Sets cannot have "replace" patches.',
2458 17: function _(n) {
2459 return "Unsupported patch operation: " + n;
2460 },
2461 18: function _(n) {
2462 return "The plugin for '" + n + "' has not been loaded into Immer. To enable the plugin, import and call `enable" + n + "()` when initializing your application.";
2463 },
2464 19: function _(n) {
2465 return "plugin not loaded: " + n;
2466 },
2467 20: "Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available"
2468 },
2469 Q = "undefined" != typeof Reflect && Reflect.ownKeys ? Reflect.ownKeys : void 0 !== Object.getOwnPropertySymbols ? function (n) {
2470 return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n));
2471 } : Object.getOwnPropertyNames,
2472 V = {},
2473 Y = {
2474 get: function get(n, t) {
2475 if (t === G) return n;
2476 var e = n.p;
2477 if (!n.P && u(e, t)) return e[t];
2478 var i = v(n)[t];
2479 if (n.I || !r(i)) return i;
2480
2481 if (n.P) {
2482 if (i !== x(n.t, t)) return i;
2483 e = n.o;
2484 }
2485
2486 return e[t] = E(n.A.h, i, n);
2487 },
2488 has: function has(n, t) {
2489 return t in v(n);
2490 },
2491 ownKeys: function ownKeys(n) {
2492 return Reflect.ownKeys(v(n));
2493 },
2494 set: function set(n, t, r) {
2495 if (!n.P) {
2496 var e = x(n.t, t);
2497 if (r ? f(e, r) || r === n.p[t] : f(e, r) && t in n.t) return !0;
2498 I(n), z(n);
2499 }
2500
2501 return n.D[t] = !0, n.o[t] = r, !0;
2502 },
2503 deleteProperty: function deleteProperty(n, t) {
2504 return void 0 !== x(n.t, t) || t in n.t ? (n.D[t] = !1, I(n), z(n)) : n.D[t] && delete n.D[t], n.o && delete n.o[t], !0;
2505 },
2506 getOwnPropertyDescriptor: function getOwnPropertyDescriptor(n, t) {
2507 var r = v(n),
2508 e = Reflect.getOwnPropertyDescriptor(r, t);
2509 return e && (e.writable = !0, e.configurable = 1 !== n.i || "length" !== t), e;
2510 },
2511 defineProperty: function defineProperty() {
2512 n(11);
2513 },
2514 getPrototypeOf: function getPrototypeOf(n) {
2515 return Object.getPrototypeOf(n.t);
2516 },
2517 setPrototypeOf: function setPrototypeOf() {
2518 n(12);
2519 }
2520 },
2521 Z = {};
2522
2523 i(Y, function (n, t) {
2524 Z[n] = function () {
2525 return arguments[0] = arguments[0][0], t.apply(this, arguments);
2526 };
2527 }), Z.deleteProperty = function (t, r) {
2528 return "production" !== process.env.NODE_ENV && isNaN(parseInt(r)) && n(13), Y.deleteProperty.call(this, t[0], r);
2529 }, Z.set = function (t, r, e) {
2530 return "production" !== process.env.NODE_ENV && "length" !== r && isNaN(parseInt(r)) && n(14), Y.set.call(this, t[0], r, e, t[0]);
2531 };
2532
2533 var nn = function () {
2534 function e(n) {
2535 this.g = X, this.N = "production" !== process.env.NODE_ENV, "boolean" == typeof (null == n ? void 0 : n.useProxies) && this.setUseProxies(n.useProxies), "boolean" == typeof (null == n ? void 0 : n.autoFreeze) && this.setAutoFreeze(n.autoFreeze), this.produce = this.produce.bind(this), this.produceWithPatches = this.produceWithPatches.bind(this);
2536 }
2537
2538 var i = e.prototype;
2539 return i.produce = function (t, e, i) {
2540 if ("function" == typeof t && "function" != typeof e) {
2541 var o = e;
2542 e = t;
2543 var u = this;
2544 return function (n) {
2545 var t = this;
2546 void 0 === n && (n = o);
2547
2548 for (var r = arguments.length, i = Array(r > 1 ? r - 1 : 0), a = 1; a < r; a++) {
2549 i[a - 1] = arguments[a];
2550 }
2551
2552 return u.produce(n, function (n) {
2553 var r;
2554 return (r = e).call.apply(r, [t, n].concat(i));
2555 });
2556 };
2557 }
2558
2559 var a;
2560
2561 if ("function" != typeof e && n(6), void 0 !== i && "function" != typeof i && n(7), r(t)) {
2562 var f = g(this),
2563 c = E(this, t, void 0),
2564 s = !0;
2565
2566 try {
2567 a = e(c), s = !1;
2568 } finally {
2569 s ? j(f) : O(f);
2570 }
2571
2572 return "undefined" != typeof Promise && a instanceof Promise ? a.then(function (n) {
2573 return _(f, i), S(n, f);
2574 }, function (n) {
2575 throw j(f), n;
2576 }) : (_(f, i), S(a, f));
2577 }
2578
2579 if ((a = e(t)) !== q) return void 0 === a && (a = t), this.N && d(a, !0), a;
2580 }, i.produceWithPatches = function (n, t) {
2581 var r,
2582 e,
2583 i = this;
2584 return "function" == typeof n ? function (t) {
2585 for (var r = arguments.length, e = Array(r > 1 ? r - 1 : 0), o = 1; o < r; o++) {
2586 e[o - 1] = arguments[o];
2587 }
2588
2589 return i.produceWithPatches(t, function (t) {
2590 return n.apply(void 0, [t].concat(e));
2591 });
2592 } : [this.produce(n, t, function (n, t) {
2593 r = n, e = t;
2594 }), r, e];
2595 }, i.createDraft = function (t) {
2596 r(t) || n(8);
2597 var e = g(this),
2598 i = E(this, t, void 0);
2599 return i[G].C = !0, O(e), i;
2600 }, i.finishDraft = function (t, r) {
2601 var e = t && t[G];
2602 "production" !== process.env.NODE_ENV && (e && e.C || n(9), e.I && n(10));
2603 var i = e.A;
2604 return _(i, r), S(void 0, i);
2605 }, i.setAutoFreeze = function (n) {
2606 this.N = n;
2607 }, i.setUseProxies = function (t) {
2608 X || n(20), this.g = t;
2609 }, i.applyPatches = function (n, r) {
2610 var e;
2611
2612 for (e = r.length - 1; e >= 0; e--) {
2613 var i = r[e];
2614
2615 if (0 === i.path.length && "replace" === i.op) {
2616 n = i.value;
2617 break;
2618 }
2619 }
2620
2621 var o = y("Patches").U;
2622 return t(n) ? o(n, r) : this.produce(n, function (n) {
2623 return o(n, r.slice(e + 1));
2624 });
2625 }, e;
2626 }(),
2627 tn = new nn(),
2628 rn = tn.produce,
2629 en = tn.produceWithPatches.bind(tn),
2630 on = tn.setAutoFreeze.bind(tn),
2631 un = tn.setUseProxies.bind(tn),
2632 an = tn.applyPatches.bind(tn),
2633 fn = tn.createDraft.bind(tn),
2634 cn = tn.finishDraft.bind(tn);
2635
2636 var EMPTY = Symbol();
2637 function createSubscriptionContainer(useHook) {
2638 var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
2639 isEqual: function isEqual(a, b) {
2640 return a === b;
2641 }
2642 },
2643 isEqual = _ref.isEqual;
2644
2645 var Context = /*#__PURE__*/React.createContext(EMPTY);
2646
2647 function Provider(props) {
2648 var subject = useConstant(function () {
2649 var initialState = props.initialState; // type fixing
2650
2651 return new BehaviorSubject(typeof initialState === 'function' ? initialState() : initialState);
2652 });
2653 var container = useConstant(function () {
2654 var setStateReal = function setStateReal(state) {
2655 var next;
2656
2657 if (typeof state === 'function') {
2658 next = state(subject.getValue());
2659 } else {
2660 next = state;
2661 }
2662
2663 subject.next(next);
2664 }; // handle change state when subscribe
2665
2666
2667 var changing = false;
2668
2669 var setState = function setState(state) {
2670 if (changing) {
2671 setTimeout(function () {
2672 return setState(state);
2673 }, 0);
2674 return;
2675 }
2676
2677 changing = true;
2678
2679 try {
2680 setStateReal(state);
2681 } finally {
2682 changing = false;
2683 }
2684 };
2685
2686 var options = {
2687 getState: function getState() {
2688 return subject.getValue();
2689 },
2690 setState: setState,
2691 updateState: function updateState(fn) {
2692 // todo produced is immutable
2693 setState(rn(function (v) {
2694 fn(v); // ensure return void
2695 }));
2696 },
2697 subscribe: function subscribe(cb) {
2698 var subscription = subject.subscribe(cb);
2699 return subscription.unsubscribe.bind(subscription);
2700 }
2701 };
2702 return useHook(options);
2703 });
2704 return /*#__PURE__*/React.createElement(Context.Provider, {
2705 value: {
2706 container: container,
2707 subject: subject
2708 }
2709 }, props.children);
2710 }
2711
2712 function useContainer() {
2713 var context = React.useContext(Context);
2714
2715 if (context === EMPTY) {
2716 throw new Error('Component must be wrapped with <SubscriptionContainer.Provider>');
2717 }
2718
2719 return context.container;
2720 }
2721
2722 function useSelector(selector) {
2723 var eq = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : isEqual;
2724 var context = React.useContext(Context);
2725
2726 if (context === EMPTY) {
2727 throw new Error('Component must be wrapped with <SubscriptionContainer.Provider>');
2728 }
2729
2730 var subject = context.subject;
2731
2732 var _React$useState = React.useState(function () {
2733 return selector(subject.getValue());
2734 }),
2735 _React$useState2 = _slicedToArray(_React$useState, 2),
2736 state = _React$useState2[0],
2737 setState = _React$useState2[1];
2738
2739 useEffect(function () {
2740 var subscription = subject.pipe(skip(1)).subscribe(function (s) {
2741 setState(function (old) {
2742 var next = selector(s);
2743
2744 if (eq(old, next)) {
2745 return old;
2746 }
2747
2748 return next;
2749 });
2750 });
2751 return function () {
2752 return subscription.unsubscribe();
2753 };
2754 }, []);
2755 return state;
2756 }
2757
2758 function useState() {
2759 return useSelector(function (v) {
2760 return v;
2761 });
2762 }
2763
2764 function useWhenValueChange(selector, cb) {
2765 var eq = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : isEqual;
2766 var context = React.useContext(Context);
2767
2768 if (context === EMPTY) {
2769 throw new Error('Component must be wrapped with <SubscriptionContainer.Provider>');
2770 }
2771
2772 var subject = context.subject;
2773 var ref = React.useRef();
2774 useEffect(function () {
2775 ref.current = selector(subject.getValue());
2776 var subscription = subject.subscribe(function (s) {
2777 var old = ref.current;
2778 var next = selector(s);
2779
2780 if (!eq(old, next)) {
2781 cb(next);
2782 ref.current = next;
2783 }
2784 });
2785 return function () {
2786 return subscription.unsubscribe();
2787 };
2788 }, []);
2789 }
2790
2791 return {
2792 Provider: Provider,
2793 useContainer: useContainer,
2794 useSelector: useSelector,
2795 useState: useState,
2796 useWhenValueChange: useWhenValueChange
2797 };
2798 }
2799
2800 /// https://github.com/jamiebuilds/unstated-next/blob/master/src/unstated-next.tsx
2801 var EMPTY$1 = Symbol();
2802 function createContainer(useHook) {
2803 var Context = /*#__PURE__*/React.createContext(EMPTY$1);
2804
2805 function Provider(props) {
2806 var value = useHook(props.initialState);
2807 return /*#__PURE__*/React.createElement(Context.Provider, {
2808 value: value
2809 }, props.children);
2810 }
2811
2812 function useContainer() {
2813 var value = React.useContext(Context);
2814
2815 if (value === EMPTY$1) {
2816 throw new Error('Component must be wrapped with <Container.Provider>');
2817 }
2818
2819 return value;
2820 }
2821
2822 return {
2823 Provider: Provider,
2824 useContainer: useContainer
2825 };
2826 }
2827 function useContainer(container) {
2828 return container.useContainer();
2829 }
2830
2831 function withProps(WrappedComponent, extra) {
2832 return function (props) {
2833 return /*#__PURE__*/React.createElement(WrappedComponent, Object.assign({}, props, extra));
2834 };
2835 }
2836
2837 }
2838 };
2839});
2840//# sourceMappingURL=wener-ui.system.js.map