UNPKG

142 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('react-dom')) :
3 typeof define === 'function' && define.amd ? define(['react', 'react-dom'], factory) :
4 (global.styled = factory(global.React,global.ReactDOM));
5}(this, (function (React,ReactDOM) { 'use strict';
6
7 var React__default = 'default' in React ? React['default'] : React;
8 ReactDOM = ReactDOM && ReactDOM.hasOwnProperty('default') ? ReactDOM['default'] : ReactDOM;
9
10 //
11 function isStyledComponent(target) {
12 return target && typeof target.styledComponentId === 'string';
13 }
14
15 //
16
17 var interleave = (function (strings, interpolations) {
18 var result = [strings[0]];
19
20 for (var i = 0, len = interpolations.length; i < len; i += 1) {
21 result.push(interpolations[i], strings[i + 1]);
22 }
23
24 return result;
25 });
26
27 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
28 return typeof obj;
29 } : function (obj) {
30 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
31 };
32
33 var classCallCheck = function (instance, Constructor) {
34 if (!(instance instanceof Constructor)) {
35 throw new TypeError("Cannot call a class as a function");
36 }
37 };
38
39 var createClass = function () {
40 function defineProperties(target, props) {
41 for (var i = 0; i < props.length; i++) {
42 var descriptor = props[i];
43 descriptor.enumerable = descriptor.enumerable || false;
44 descriptor.configurable = true;
45 if ("value" in descriptor) descriptor.writable = true;
46 Object.defineProperty(target, descriptor.key, descriptor);
47 }
48 }
49
50 return function (Constructor, protoProps, staticProps) {
51 if (protoProps) defineProperties(Constructor.prototype, protoProps);
52 if (staticProps) defineProperties(Constructor, staticProps);
53 return Constructor;
54 };
55 }();
56
57 var _extends = Object.assign || function (target) {
58 for (var i = 1; i < arguments.length; i++) {
59 var source = arguments[i];
60
61 for (var key in source) {
62 if (Object.prototype.hasOwnProperty.call(source, key)) {
63 target[key] = source[key];
64 }
65 }
66 }
67
68 return target;
69 };
70
71 var inherits = function (subClass, superClass) {
72 if (typeof superClass !== "function" && superClass !== null) {
73 throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
74 }
75
76 subClass.prototype = Object.create(superClass && superClass.prototype, {
77 constructor: {
78 value: subClass,
79 enumerable: false,
80 writable: true,
81 configurable: true
82 }
83 });
84 if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
85 };
86
87 var objectWithoutProperties = function (obj, keys) {
88 var target = {};
89
90 for (var i in obj) {
91 if (keys.indexOf(i) >= 0) continue;
92 if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
93 target[i] = obj[i];
94 }
95
96 return target;
97 };
98
99 var possibleConstructorReturn = function (self, call) {
100 if (!self) {
101 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
102 }
103
104 return call && (typeof call === "object" || typeof call === "function") ? call : self;
105 };
106
107 //
108 var isPlainObject = (function (x) {
109 return (typeof x === 'undefined' ? 'undefined' : _typeof(x)) === 'object' && x.constructor === Object;
110 });
111
112 //
113 var EMPTY_ARRAY = Object.freeze([]);
114 var EMPTY_OBJECT = Object.freeze({});
115
116 //
117 function isFunction(test) {
118 return typeof test === 'function';
119 }
120
121 function unwrapExports (x) {
122 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
123 }
124
125 function createCommonjsModule(fn, module) {
126 return module = { exports: {} }, fn(module, module.exports), module.exports;
127 }
128
129 var reactIs_production_min = createCommonjsModule(function (module, exports) {
130 Object.defineProperty(exports,"__esModule",{value:!0});
131 var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.concurrent_mode"):60111,m=b?Symbol.for("react.forward_ref"):60112,n=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.memo"):60115,r=b?Symbol.for("react.lazy"):
132 60116;function t(a){if("object"===typeof a&&null!==a){var p=a.$$typeof;switch(p){case c:switch(a=a.type,a){case l:case e:case g:case f:return a;default:switch(a=a&&a.$$typeof,a){case k:case m:case h:return a;default:return p}}case d:return p}}}function u(a){return t(a)===l}exports.typeOf=t;exports.AsyncMode=l;exports.ConcurrentMode=l;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=m;exports.Fragment=e;exports.Profiler=g;exports.Portal=d;
133 exports.StrictMode=f;exports.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===l||a===g||a===f||a===n||"object"===typeof a&&null!==a&&(a.$$typeof===r||a.$$typeof===q||a.$$typeof===h||a.$$typeof===k||a.$$typeof===m)};exports.isAsyncMode=function(a){return u(a)};exports.isConcurrentMode=u;exports.isContextConsumer=function(a){return t(a)===k};exports.isContextProvider=function(a){return t(a)===h};
134 exports.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return t(a)===m};exports.isFragment=function(a){return t(a)===e};exports.isProfiler=function(a){return t(a)===g};exports.isPortal=function(a){return t(a)===d};exports.isStrictMode=function(a){return t(a)===f};
135 });
136
137 unwrapExports(reactIs_production_min);
138 var reactIs_production_min_1 = reactIs_production_min.typeOf;
139 var reactIs_production_min_2 = reactIs_production_min.AsyncMode;
140 var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode;
141 var reactIs_production_min_4 = reactIs_production_min.ContextConsumer;
142 var reactIs_production_min_5 = reactIs_production_min.ContextProvider;
143 var reactIs_production_min_6 = reactIs_production_min.Element;
144 var reactIs_production_min_7 = reactIs_production_min.ForwardRef;
145 var reactIs_production_min_8 = reactIs_production_min.Fragment;
146 var reactIs_production_min_9 = reactIs_production_min.Profiler;
147 var reactIs_production_min_10 = reactIs_production_min.Portal;
148 var reactIs_production_min_11 = reactIs_production_min.StrictMode;
149 var reactIs_production_min_12 = reactIs_production_min.isValidElementType;
150 var reactIs_production_min_13 = reactIs_production_min.isAsyncMode;
151 var reactIs_production_min_14 = reactIs_production_min.isConcurrentMode;
152 var reactIs_production_min_15 = reactIs_production_min.isContextConsumer;
153 var reactIs_production_min_16 = reactIs_production_min.isContextProvider;
154 var reactIs_production_min_17 = reactIs_production_min.isElement;
155 var reactIs_production_min_18 = reactIs_production_min.isForwardRef;
156 var reactIs_production_min_19 = reactIs_production_min.isFragment;
157 var reactIs_production_min_20 = reactIs_production_min.isProfiler;
158 var reactIs_production_min_21 = reactIs_production_min.isPortal;
159 var reactIs_production_min_22 = reactIs_production_min.isStrictMode;
160
161 var reactIs_development = createCommonjsModule(function (module, exports) {
162
163
164
165 {
166 (function() {
167
168 Object.defineProperty(exports, '__esModule', { value: true });
169
170 // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
171 // nor polyfill, then a plain number is used for performance.
172 var hasSymbol = typeof Symbol === 'function' && Symbol.for;
173
174 var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
175 var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
176 var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
177 var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
178 var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
179 var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
180 var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
181 var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
182 var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
183 var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
184 var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
185 var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
186
187 function isValidElementType(type) {
188 return typeof type === 'string' || typeof type === 'function' ||
189 // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
190 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
191 }
192
193 /**
194 * Forked from fbjs/warning:
195 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
196 *
197 * Only change is we use console.warn instead of console.error,
198 * and do nothing when 'console' is not supported.
199 * This really simplifies the code.
200 * ---
201 * Similar to invariant but only logs a warning if the condition is not met.
202 * This can be used to log issues in development environments in critical
203 * paths. Removing the logging code for production environments will keep the
204 * same logic and follow the same code paths.
205 */
206
207 var lowPriorityWarning = function () {};
208
209 {
210 var printWarning = function (format) {
211 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
212 args[_key - 1] = arguments[_key];
213 }
214
215 var argIndex = 0;
216 var message = 'Warning: ' + format.replace(/%s/g, function () {
217 return args[argIndex++];
218 });
219 if (typeof console !== 'undefined') {
220 console.warn(message);
221 }
222 try {
223 // --- Welcome to debugging React ---
224 // This error was thrown as a convenience so that you can use this stack
225 // to find the callsite that caused this warning to fire.
226 throw new Error(message);
227 } catch (x) {}
228 };
229
230 lowPriorityWarning = function (condition, format) {
231 if (format === undefined) {
232 throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
233 }
234 if (!condition) {
235 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
236 args[_key2 - 2] = arguments[_key2];
237 }
238
239 printWarning.apply(undefined, [format].concat(args));
240 }
241 };
242 }
243
244 var lowPriorityWarning$1 = lowPriorityWarning;
245
246 function typeOf(object) {
247 if (typeof object === 'object' && object !== null) {
248 var $$typeof = object.$$typeof;
249
250 switch ($$typeof) {
251 case REACT_ELEMENT_TYPE:
252 var type = object.type;
253
254 switch (type) {
255 case REACT_CONCURRENT_MODE_TYPE:
256 case REACT_FRAGMENT_TYPE:
257 case REACT_PROFILER_TYPE:
258 case REACT_STRICT_MODE_TYPE:
259 return type;
260 default:
261 var $$typeofType = type && type.$$typeof;
262
263 switch ($$typeofType) {
264 case REACT_CONTEXT_TYPE:
265 case REACT_FORWARD_REF_TYPE:
266 case REACT_PROVIDER_TYPE:
267 return $$typeofType;
268 default:
269 return $$typeof;
270 }
271 }
272 case REACT_PORTAL_TYPE:
273 return $$typeof;
274 }
275 }
276
277 return undefined;
278 }
279
280 // AsyncMode alias is deprecated along with isAsyncMode
281 var AsyncMode = REACT_CONCURRENT_MODE_TYPE;
282 var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
283 var ContextConsumer = REACT_CONTEXT_TYPE;
284 var ContextProvider = REACT_PROVIDER_TYPE;
285 var Element = REACT_ELEMENT_TYPE;
286 var ForwardRef = REACT_FORWARD_REF_TYPE;
287 var Fragment = REACT_FRAGMENT_TYPE;
288 var Profiler = REACT_PROFILER_TYPE;
289 var Portal = REACT_PORTAL_TYPE;
290 var StrictMode = REACT_STRICT_MODE_TYPE;
291
292 var hasWarnedAboutDeprecatedIsAsyncMode = false;
293
294 // AsyncMode should be deprecated
295 function isAsyncMode(object) {
296 {
297 if (!hasWarnedAboutDeprecatedIsAsyncMode) {
298 hasWarnedAboutDeprecatedIsAsyncMode = true;
299 lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
300 }
301 }
302 return isConcurrentMode(object);
303 }
304 function isConcurrentMode(object) {
305 return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
306 }
307 function isContextConsumer(object) {
308 return typeOf(object) === REACT_CONTEXT_TYPE;
309 }
310 function isContextProvider(object) {
311 return typeOf(object) === REACT_PROVIDER_TYPE;
312 }
313 function isElement(object) {
314 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
315 }
316 function isForwardRef(object) {
317 return typeOf(object) === REACT_FORWARD_REF_TYPE;
318 }
319 function isFragment(object) {
320 return typeOf(object) === REACT_FRAGMENT_TYPE;
321 }
322 function isProfiler(object) {
323 return typeOf(object) === REACT_PROFILER_TYPE;
324 }
325 function isPortal(object) {
326 return typeOf(object) === REACT_PORTAL_TYPE;
327 }
328 function isStrictMode(object) {
329 return typeOf(object) === REACT_STRICT_MODE_TYPE;
330 }
331
332 exports.typeOf = typeOf;
333 exports.AsyncMode = AsyncMode;
334 exports.ConcurrentMode = ConcurrentMode;
335 exports.ContextConsumer = ContextConsumer;
336 exports.ContextProvider = ContextProvider;
337 exports.Element = Element;
338 exports.ForwardRef = ForwardRef;
339 exports.Fragment = Fragment;
340 exports.Profiler = Profiler;
341 exports.Portal = Portal;
342 exports.StrictMode = StrictMode;
343 exports.isValidElementType = isValidElementType;
344 exports.isAsyncMode = isAsyncMode;
345 exports.isConcurrentMode = isConcurrentMode;
346 exports.isContextConsumer = isContextConsumer;
347 exports.isContextProvider = isContextProvider;
348 exports.isElement = isElement;
349 exports.isForwardRef = isForwardRef;
350 exports.isFragment = isFragment;
351 exports.isProfiler = isProfiler;
352 exports.isPortal = isPortal;
353 exports.isStrictMode = isStrictMode;
354 })();
355 }
356 });
357
358 unwrapExports(reactIs_development);
359 var reactIs_development_1 = reactIs_development.typeOf;
360 var reactIs_development_2 = reactIs_development.AsyncMode;
361 var reactIs_development_3 = reactIs_development.ConcurrentMode;
362 var reactIs_development_4 = reactIs_development.ContextConsumer;
363 var reactIs_development_5 = reactIs_development.ContextProvider;
364 var reactIs_development_6 = reactIs_development.Element;
365 var reactIs_development_7 = reactIs_development.ForwardRef;
366 var reactIs_development_8 = reactIs_development.Fragment;
367 var reactIs_development_9 = reactIs_development.Profiler;
368 var reactIs_development_10 = reactIs_development.Portal;
369 var reactIs_development_11 = reactIs_development.StrictMode;
370 var reactIs_development_12 = reactIs_development.isValidElementType;
371 var reactIs_development_13 = reactIs_development.isAsyncMode;
372 var reactIs_development_14 = reactIs_development.isConcurrentMode;
373 var reactIs_development_15 = reactIs_development.isContextConsumer;
374 var reactIs_development_16 = reactIs_development.isContextProvider;
375 var reactIs_development_17 = reactIs_development.isElement;
376 var reactIs_development_18 = reactIs_development.isForwardRef;
377 var reactIs_development_19 = reactIs_development.isFragment;
378 var reactIs_development_20 = reactIs_development.isProfiler;
379 var reactIs_development_21 = reactIs_development.isPortal;
380 var reactIs_development_22 = reactIs_development.isStrictMode;
381
382 var reactIs = createCommonjsModule(function (module) {
383
384 {
385 module.exports = reactIs_development;
386 }
387 });
388 var reactIs_1 = reactIs.isElement;
389 var reactIs_2 = reactIs.isValidElementType;
390 var reactIs_3 = reactIs.ForwardRef;
391
392 //
393
394 function getComponentName(target) {
395 return target.displayName || target.name || 'Component';
396 }
397
398 //
399
400 var SC_ATTR = typeof process !== 'undefined' && process.env.SC_ATTR || 'data-styled';
401
402 var SC_VERSION_ATTR = 'data-styled-version';
403
404 var SC_STREAM_ATTR = 'data-styled-streamed';
405
406 var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
407
408 var DISABLE_SPEEDY = typeof SC_DISABLE_SPEEDY === 'boolean' && SC_DISABLE_SPEEDY || "development" !== 'production';
409
410 // Shared empty execution context when generating static styles
411 var STATIC_EXECUTION_CONTEXT = {};
412
413 //
414
415
416 /**
417 * Parse errors.md and turn it into a simple hash of code: message
418 */
419 var ERRORS = {
420 "1": "Cannot create styled-component for component: %s.\n\n",
421 "2": "Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\n\n- Are you trying to reuse it across renders?\n- Are you accidentally calling collectStyles twice?\n\n",
422 "3": "Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n",
423 "4": "The `StyleSheetManager` expects a valid target or sheet prop!\n\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n\n",
424 "5": "The clone method cannot be used on the client!\n\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n\n",
425 "6": "Trying to insert a new style tag, but the given Node is unmounted!\n\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n\n",
426 "7": "ThemeProvider: Please return an object from your \"theme\" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n",
427 "8": "ThemeProvider: Please make your \"theme\" prop an object.\n\n",
428 "9": "Missing document `<head>`\n\n",
429 "10": "Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\n\n",
430 "11": "_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\n\n",
431 "12": "It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper (see https://www.styled-components.com/docs/api#css), which ensures the styles are injected correctly.\n\n",
432 "13": "%s is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.\n"
433 };
434
435 /**
436 * super basic version of sprintf
437 */
438 function format() {
439 var a = arguments.length <= 0 ? undefined : arguments[0];
440 var b = [];
441
442 for (var c = 1, len = arguments.length; c < len; c += 1) {
443 b.push(arguments.length <= c ? undefined : arguments[c]);
444 }
445
446 b.forEach(function (d) {
447 a = a.replace(/%[a-z]/, d);
448 });
449
450 return a;
451 }
452
453 /**
454 * Create an error file out of errors.md for development and a simple web link to the full errors
455 * in production mode.
456 */
457
458 var StyledComponentsError = function (_Error) {
459 inherits(StyledComponentsError, _Error);
460
461 function StyledComponentsError(code) {
462 classCallCheck(this, StyledComponentsError);
463
464 for (var _len = arguments.length, interpolations = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
465 interpolations[_key - 1] = arguments[_key];
466 }
467
468 if (false) {
469 var _this;
470 } else {
471 var _this = possibleConstructorReturn(this, _Error.call(this, format.apply(undefined, [ERRORS[code]].concat(interpolations)).trim()));
472 }
473 return possibleConstructorReturn(_this);
474 }
475
476 return StyledComponentsError;
477 }(Error);
478
479 //
480 var SC_COMPONENT_ID = /^[^\S\n]*?\/\* sc-component-id:\s*(\S+)\s+\*\//gm;
481
482 var extractComps = (function (maybeCSS) {
483 var css = '' + (maybeCSS || ''); // Definitely a string, and a clone
484 var existingComponents = [];
485 css.replace(SC_COMPONENT_ID, function (match, componentId, matchIndex) {
486 existingComponents.push({ componentId: componentId, matchIndex: matchIndex });
487 return match;
488 });
489 return existingComponents.map(function (_ref, i) {
490 var componentId = _ref.componentId,
491 matchIndex = _ref.matchIndex;
492
493 var nextComp = existingComponents[i + 1];
494 var cssFromDOM = nextComp ? css.slice(matchIndex, nextComp.matchIndex) : css.slice(matchIndex);
495 return { componentId: componentId, cssFromDOM: cssFromDOM };
496 });
497 });
498
499 var stylis_min = createCommonjsModule(function (module, exports) {
500 !function(e){module.exports=e(null);}(function e(a){var c=/^\0+/g,r=/[\0\r\f]/g,s=/: */g,t=/zoo|gra/,i=/([,: ])(transform)/g,f=/,+\s*(?![^(]*[)])/g,n=/ +\s*(?![^(]*[)])/g,l=/ *[\0] */g,o=/,\r+?/g,h=/([\t\r\n ])*\f?&/g,u=/:global\(((?:[^\(\)\[\]]*|\[.*\]|\([^\(\)]*\))*)\)/g,d=/\W+/g,b=/@(k\w+)\s*(\S*)\s*/,k=/::(place)/g,p=/:(read-only)/g,g=/\s+(?=[{\];=:>])/g,A=/([[}=:>])\s+/g,C=/(\{[^{]+?);(?=\})/g,w=/\s{2,}/g,v=/([^\(])(:+) */g,m=/[svh]\w+-[tblr]{2}/,x=/\(\s*(.*)\s*\)/g,$=/([\s\S]*?);/g,y=/-self|flex-/g,O=/[^]*?(:[rp][el]a[\w-]+)[^]*/,j=/stretch|:\s*\w+\-(?:conte|avail)/,z=/([^-])(image-set\()/,F="-webkit-",N="-moz-",S="-ms-",B=59,W=125,q=123,D=40,E=41,G=91,H=93,I=10,J=13,K=9,L=64,M=32,P=38,Q=45,R=95,T=42,U=44,V=58,X=39,Y=34,Z=47,_=62,ee=43,ae=126,ce=0,re=12,se=11,te=107,ie=109,fe=115,ne=112,le=111,oe=105,he=99,ue=100,de=112,be=1,ke=1,pe=0,ge=1,Ae=1,Ce=1,we=0,ve=0,me=0,xe=[],$e=[],ye=0,Oe=null,je=-2,ze=-1,Fe=0,Ne=1,Se=2,Be=3,We=0,qe=1,De="",Ee="",Ge="";function He(e,a,s,t,i){for(var f,n,o=0,h=0,u=0,d=0,g=0,A=0,C=0,w=0,m=0,$=0,y=0,O=0,j=0,z=0,R=0,we=0,$e=0,Oe=0,je=0,ze=s.length,Je=ze-1,Re="",Te="",Ue="",Ve="",Xe="",Ye="";R<ze;){if(C=s.charCodeAt(R),R===Je)if(h+d+u+o!==0){if(0!==h)C=h===Z?I:Z;d=u=o=0,ze++,Je++;}if(h+d+u+o===0){if(R===Je){if(we>0)Te=Te.replace(r,"");if(Te.trim().length>0){switch(C){case M:case K:case B:case J:case I:break;default:Te+=s.charAt(R);}C=B;}}if(1===$e)switch(C){case q:case W:case B:case Y:case X:case D:case E:case U:$e=0;case K:case J:case I:case M:break;default:for($e=0,je=R,g=C,R--,C=B;je<ze;)switch(s.charCodeAt(je++)){case I:case J:case B:++R,C=g,je=ze;break;case V:if(we>0)++R,C=g;case q:je=ze;}}switch(C){case q:for(g=(Te=Te.trim()).charCodeAt(0),y=1,je=++R;R<ze;){switch(C=s.charCodeAt(R)){case q:y++;break;case W:y--;break;case Z:switch(A=s.charCodeAt(R+1)){case T:case Z:R=Qe(A,R,Je,s);}break;case G:C++;case D:C++;case Y:case X:for(;R++<Je&&s.charCodeAt(R)!==C;);}if(0===y)break;R++;}if(Ue=s.substring(je,R),g===ce)g=(Te=Te.replace(c,"").trim()).charCodeAt(0);switch(g){case L:if(we>0)Te=Te.replace(r,"");switch(A=Te.charCodeAt(1)){case ue:case ie:case fe:case Q:f=a;break;default:f=xe;}if(je=(Ue=He(a,f,Ue,A,i+1)).length,me>0&&0===je)je=Te.length;if(ye>0)if(f=Ie(xe,Te,Oe),n=Pe(Be,Ue,f,a,ke,be,je,A,i,t),Te=f.join(""),void 0!==n)if(0===(je=(Ue=n.trim()).length))A=0,Ue="";if(je>0)switch(A){case fe:Te=Te.replace(x,Me);case ue:case ie:case Q:Ue=Te+"{"+Ue+"}";break;case te:if(Ue=(Te=Te.replace(b,"$1 $2"+(qe>0?De:"")))+"{"+Ue+"}",1===Ae||2===Ae&&Le("@"+Ue,3))Ue="@"+F+Ue+"@"+Ue;else Ue="@"+Ue;break;default:if(Ue=Te+Ue,t===de)Ve+=Ue,Ue="";}else Ue="";break;default:Ue=He(a,Ie(a,Te,Oe),Ue,t,i+1);}Xe+=Ue,O=0,$e=0,z=0,we=0,Oe=0,j=0,Te="",Ue="",C=s.charCodeAt(++R);break;case W:case B:if((je=(Te=(we>0?Te.replace(r,""):Te).trim()).length)>1){if(0===z)if((g=Te.charCodeAt(0))===Q||g>96&&g<123)je=(Te=Te.replace(" ",":")).length;if(ye>0)if(void 0!==(n=Pe(Ne,Te,a,e,ke,be,Ve.length,t,i,t)))if(0===(je=(Te=n.trim()).length))Te="\0\0";switch(g=Te.charCodeAt(0),A=Te.charCodeAt(1),g){case ce:break;case L:if(A===oe||A===he){Ye+=Te+s.charAt(R);break}default:if(Te.charCodeAt(je-1)===V)break;Ve+=Ke(Te,g,A,Te.charCodeAt(2));}}O=0,$e=0,z=0,we=0,Oe=0,Te="",C=s.charCodeAt(++R);}}switch(C){case J:case I:if(h+d+u+o+ve===0)switch($){case E:case X:case Y:case L:case ae:case _:case T:case ee:case Z:case Q:case V:case U:case B:case q:case W:break;default:if(z>0)$e=1;}if(h===Z)h=0;else if(ge+O===0&&t!==te&&Te.length>0)we=1,Te+="\0";if(ye*We>0)Pe(Fe,Te,a,e,ke,be,Ve.length,t,i,t);be=1,ke++;break;case B:case W:if(h+d+u+o===0){be++;break}default:switch(be++,Re=s.charAt(R),C){case K:case M:if(d+o+h===0)switch(w){case U:case V:case K:case M:Re="";break;default:if(C!==M)Re=" ";}break;case ce:Re="\\0";break;case re:Re="\\f";break;case se:Re="\\v";break;case P:if(d+h+o===0&&ge>0)Oe=1,we=1,Re="\f"+Re;break;case 108:if(d+h+o+pe===0&&z>0)switch(R-z){case 2:if(w===ne&&s.charCodeAt(R-3)===V)pe=w;case 8:if(m===le)pe=m;}break;case V:if(d+h+o===0)z=R;break;case U:if(h+u+d+o===0)we=1,Re+="\r";break;case Y:case X:if(0===h)d=d===C?0:0===d?C:d;break;case G:if(d+h+u===0)o++;break;case H:if(d+h+u===0)o--;break;case E:if(d+h+o===0)u--;break;case D:if(d+h+o===0){if(0===O)switch(2*w+3*m){case 533:break;default:y=0,O=1;}u++;}break;case L:if(h+u+d+o+z+j===0)j=1;break;case T:case Z:if(d+o+u>0)break;switch(h){case 0:switch(2*C+3*s.charCodeAt(R+1)){case 235:h=Z;break;case 220:je=R,h=T;}break;case T:if(C===Z&&w===T&&je+2!==R){if(33===s.charCodeAt(je+2))Ve+=s.substring(je,R+1);Re="",h=0;}}}if(0===h){if(ge+d+o+j===0&&t!==te&&C!==B)switch(C){case U:case ae:case _:case ee:case E:case D:if(0===O){switch(w){case K:case M:case I:case J:Re+="\0";break;default:Re="\0"+Re+(C===U?"":"\0");}we=1;}else switch(C){case D:if(z+7===R&&108===w)z=0;O=++y;break;case E:if(0==(O=--y))we=1,Re+="\0";}break;case K:case M:switch(w){case ce:case q:case W:case B:case U:case re:case K:case M:case I:case J:break;default:if(0===O)we=1,Re+="\0";}}if(Te+=Re,C!==M&&C!==K)$=C;}}m=w,w=C,R++;}if(je=Ve.length,me>0)if(0===je&&0===Xe.length&&0===a[0].length==false)if(t!==ie||1===a.length&&(ge>0?Ee:Ge)===a[0])je=a.join(",").length+2;if(je>0){if(f=0===ge&&t!==te?function(e){for(var a,c,s=0,t=e.length,i=Array(t);s<t;++s){for(var f=e[s].split(l),n="",o=0,h=0,u=0,d=0,b=f.length;o<b;++o){if(0===(h=(c=f[o]).length)&&b>1)continue;if(u=n.charCodeAt(n.length-1),d=c.charCodeAt(0),a="",0!==o)switch(u){case T:case ae:case _:case ee:case M:case D:break;default:a=" ";}switch(d){case P:c=a+Ee;case ae:case _:case ee:case M:case E:case D:break;case G:c=a+c+Ee;break;case V:switch(2*c.charCodeAt(1)+3*c.charCodeAt(2)){case 530:if(Ce>0){c=a+c.substring(8,h-1);break}default:if(o<1||f[o-1].length<1)c=a+Ee+c;}break;case U:a="";default:if(h>1&&c.indexOf(":")>0)c=a+c.replace(v,"$1"+Ee+"$2");else c=a+c+Ee;}n+=c;}i[s]=n.replace(r,"").trim();}return i}(a):a,ye>0)if(void 0!==(n=Pe(Se,Ve,f,e,ke,be,je,t,i,t))&&0===(Ve=n).length)return Ye+Ve+Xe;if(Ve=f.join(",")+"{"+Ve+"}",Ae*pe!=0){if(2===Ae&&!Le(Ve,2))pe=0;switch(pe){case le:Ve=Ve.replace(p,":"+N+"$1")+Ve;break;case ne:Ve=Ve.replace(k,"::"+F+"input-$1")+Ve.replace(k,"::"+N+"$1")+Ve.replace(k,":"+S+"input-$1")+Ve;}pe=0;}}return Ye+Ve+Xe}function Ie(e,a,c){var r=a.trim().split(o),s=r,t=r.length,i=e.length;switch(i){case 0:case 1:for(var f=0,n=0===i?"":e[0]+" ";f<t;++f)s[f]=Je(n,s[f],c,i).trim();break;default:f=0;var l=0;for(s=[];f<t;++f)for(var h=0;h<i;++h)s[l++]=Je(e[h]+" ",r[f],c,i).trim();}return s}function Je(e,a,c,r){var s=a,t=s.charCodeAt(0);if(t<33)t=(s=s.trim()).charCodeAt(0);switch(t){case P:switch(ge+r){case 0:case 1:if(0===e.trim().length)break;default:return s.replace(h,"$1"+e.trim())}break;case V:switch(s.charCodeAt(1)){case 103:if(Ce>0&&ge>0)return s.replace(u,"$1").replace(h,"$1"+Ge);break;default:return e.trim()+s.replace(h,"$1"+e.trim())}default:if(c*ge>0&&s.indexOf("\f")>0)return s.replace(h,(e.charCodeAt(0)===V?"":"$1")+e.trim())}return e+s}function Ke(e,a,c,r){var l,o=0,h=e+";",u=2*a+3*c+4*r;if(944===u)return function(e){var a=e.length,c=e.indexOf(":",9)+1,r=e.substring(0,c).trim(),s=e.substring(c,a-1).trim();switch(e.charCodeAt(9)*qe){case 0:break;case Q:if(110!==e.charCodeAt(10))break;default:for(var t=s.split((s="",f)),i=0,c=0,a=t.length;i<a;c=0,++i){for(var l=t[i],o=l.split(n);l=o[c];){var h=l.charCodeAt(0);if(1===qe&&(h>L&&h<90||h>96&&h<123||h===R||h===Q&&l.charCodeAt(1)!==Q))switch(isNaN(parseFloat(l))+(-1!==l.indexOf("("))){case 1:switch(l){case"infinite":case"alternate":case"backwards":case"running":case"normal":case"forwards":case"both":case"none":case"linear":case"ease":case"ease-in":case"ease-out":case"ease-in-out":case"paused":case"reverse":case"alternate-reverse":case"inherit":case"initial":case"unset":case"step-start":case"step-end":break;default:l+=De;}}o[c++]=l;}s+=(0===i?"":",")+o.join(" ");}}if(s=r+s+";",1===Ae||2===Ae&&Le(s,1))return F+s+s;return s}(h);else if(0===Ae||2===Ae&&!Le(h,1))return h;switch(u){case 1015:return 97===h.charCodeAt(10)?F+h+h:h;case 951:return 116===h.charCodeAt(3)?F+h+h:h;case 963:return 110===h.charCodeAt(5)?F+h+h:h;case 1009:if(100!==h.charCodeAt(4))break;case 969:case 942:return F+h+h;case 978:return F+h+N+h+h;case 1019:case 983:return F+h+N+h+S+h+h;case 883:if(h.charCodeAt(8)===Q)return F+h+h;if(h.indexOf("image-set(",11)>0)return h.replace(z,"$1"+F+"$2")+h;return h;case 932:if(h.charCodeAt(4)===Q)switch(h.charCodeAt(5)){case 103:return F+"box-"+h.replace("-grow","")+F+h+S+h.replace("grow","positive")+h;case 115:return F+h+S+h.replace("shrink","negative")+h;case 98:return F+h+S+h.replace("basis","preferred-size")+h}return F+h+S+h+h;case 964:return F+h+S+"flex-"+h+h;case 1023:if(99!==h.charCodeAt(8))break;return l=h.substring(h.indexOf(":",15)).replace("flex-","").replace("space-between","justify"),F+"box-pack"+l+F+h+S+"flex-pack"+l+h;case 1005:return t.test(h)?h.replace(s,":"+F)+h.replace(s,":"+N)+h:h;case 1e3:switch(o=(l=h.substring(13).trim()).indexOf("-")+1,l.charCodeAt(0)+l.charCodeAt(o)){case 226:l=h.replace(m,"tb");break;case 232:l=h.replace(m,"tb-rl");break;case 220:l=h.replace(m,"lr");break;default:return h}return F+h+S+l+h;case 1017:if(-1===h.indexOf("sticky",9))return h;case 975:switch(o=(h=e).length-10,u=(l=(33===h.charCodeAt(o)?h.substring(0,o):h).substring(e.indexOf(":",7)+1).trim()).charCodeAt(0)+(0|l.charCodeAt(7))){case 203:if(l.charCodeAt(8)<111)break;case 115:h=h.replace(l,F+l)+";"+h;break;case 207:case 102:h=h.replace(l,F+(u>102?"inline-":"")+"box")+";"+h.replace(l,F+l)+";"+h.replace(l,S+l+"box")+";"+h;}return h+";";case 938:if(h.charCodeAt(5)===Q)switch(h.charCodeAt(6)){case 105:return l=h.replace("-items",""),F+h+F+"box-"+l+S+"flex-"+l+h;case 115:return F+h+S+"flex-item-"+h.replace(y,"")+h;default:return F+h+S+"flex-line-pack"+h.replace("align-content","").replace(y,"")+h}break;case 973:case 989:if(h.charCodeAt(3)!==Q||122===h.charCodeAt(4))break;case 931:case 953:if(true===j.test(e))if(115===(l=e.substring(e.indexOf(":")+1)).charCodeAt(0))return Ke(e.replace("stretch","fill-available"),a,c,r).replace(":fill-available",":stretch");else return h.replace(l,F+l)+h.replace(l,N+l.replace("fill-",""))+h;break;case 962:if(h=F+h+(102===h.charCodeAt(5)?S+h:"")+h,c+r===211&&105===h.charCodeAt(13)&&h.indexOf("transform",10)>0)return h.substring(0,h.indexOf(";",27)+1).replace(i,"$1"+F+"$2")+h}return h}function Le(e,a){var c=e.indexOf(1===a?":":"{"),r=e.substring(0,3!==a?c:10),s=e.substring(c+1,e.length-1);return Oe(2!==a?r:r.replace(O,"$1"),s,a)}function Me(e,a){var c=Ke(a,a.charCodeAt(0),a.charCodeAt(1),a.charCodeAt(2));return c!==a+";"?c.replace($," or ($1)").substring(4):"("+a+")"}function Pe(e,a,c,r,s,t,i,f,n,l){for(var o,h=0,u=a;h<ye;++h)switch(o=$e[h].call(Te,e,u,c,r,s,t,i,f,n,l)){case void 0:case false:case true:case null:break;default:u=o;}switch(u){case void 0:case false:case true:case null:case a:break;default:return u}}function Qe(e,a,c,r){for(var s=a+1;s<c;++s)switch(r.charCodeAt(s)){case Z:if(e===T)if(r.charCodeAt(s-1)===T&&a+2!==s)return s+1;break;case I:if(e===Z)return s+1}return s}function Re(e){for(var a in e){var c=e[a];switch(a){case"keyframe":qe=0|c;break;case"global":Ce=0|c;break;case"cascade":ge=0|c;break;case"compress":we=0|c;break;case"semicolon":ve=0|c;break;case"preserve":me=0|c;break;case"prefix":if(Oe=null,!c)Ae=0;else if("function"!=typeof c)Ae=1;else Ae=2,Oe=c;}}return Re}function Te(a,c){if(void 0!==this&&this.constructor===Te)return e(a);var s=a,t=s.charCodeAt(0);if(t<33)t=(s=s.trim()).charCodeAt(0);if(qe>0)De=s.replace(d,t===G?"":"-");if(t=1,1===ge)Ge=s;else Ee=s;var i,f=[Ge];if(ye>0)if(void 0!==(i=Pe(ze,c,f,f,ke,be,0,0,0,0))&&"string"==typeof i)c=i;var n=He(xe,f,c,0,0);if(ye>0)if(void 0!==(i=Pe(je,n,f,f,ke,be,n.length,0,0,0))&&"string"!=typeof(n=i))t=0;return De="",Ge="",Ee="",pe=0,ke=1,be=1,we*t==0?n:n.replace(r,"").replace(g,"").replace(A,"$1").replace(C,"$1").replace(w," ")}if(Te.use=function e(a){switch(a){case void 0:case null:ye=$e.length=0;break;default:switch(a.constructor){case Array:for(var c=0,r=a.length;c<r;++c)e(a[c]);break;case Function:$e[ye++]=a;break;case Boolean:We=0|!!a;}}return e},Te.set=Re,void 0!==a)Re(a);return Te});
501
502 });
503
504 var stylisRuleSheet = createCommonjsModule(function (module, exports) {
505 (function (factory) {
506 module['exports'] = factory();
507 }(function () {
508
509 return function (insertRule) {
510 var delimiter = '/*|*/';
511 var needle = delimiter+'}';
512
513 function toSheet (block) {
514 if (block)
515 try {
516 insertRule(block + '}');
517 } catch (e) {}
518 }
519
520 return function ruleSheet (context, content, selectors, parents, line, column, length, ns, depth, at) {
521 switch (context) {
522 // property
523 case 1:
524 // @import
525 if (depth === 0 && content.charCodeAt(0) === 64)
526 return insertRule(content+';'), ''
527 break
528 // selector
529 case 2:
530 if (ns === 0)
531 return content + delimiter
532 break
533 // at-rule
534 case 3:
535 switch (ns) {
536 // @font-face, @page
537 case 102:
538 case 112:
539 return insertRule(selectors[0]+content), ''
540 default:
541 return content + (at === 0 ? delimiter : '')
542 }
543 case -2:
544 content.split(needle).forEach(toSheet);
545 }
546 }
547 }
548 }));
549 });
550
551 //
552
553 var COMMENT_REGEX = /^\s*\/\/.*$/gm;
554
555 // NOTE: This stylis instance is only used to split rules from SSR'd style tags
556 var stylisSplitter = new stylis_min({
557 global: false,
558 cascade: true,
559 keyframe: false,
560 prefix: false,
561 compress: false,
562 semicolon: true
563 });
564
565 var stylis = new stylis_min({
566 global: false,
567 cascade: true,
568 keyframe: false,
569 prefix: true,
570 compress: false,
571 semicolon: false // NOTE: This means "autocomplete missing semicolons"
572 });
573
574 // Wrap `insertRulePlugin to build a list of rules,
575 // and then make our own plugin to return the rules. This
576 // makes it easier to hook into the existing SSR architecture
577
578 var parsingRules = [];
579
580 // eslint-disable-next-line consistent-return
581 var returnRulesPlugin = function returnRulesPlugin(context) {
582 if (context === -2) {
583 var parsedRules = parsingRules;
584 parsingRules = [];
585 return parsedRules;
586 }
587 };
588
589 var parseRulesPlugin = stylisRuleSheet(function (rule) {
590 parsingRules.push(rule);
591 });
592
593 var _componentId = void 0;
594 var _selector = void 0;
595 var _selectorRegexp = void 0;
596
597 var selfReferenceReplacer = function selfReferenceReplacer(match, offset, string) {
598 if (
599 // the first self-ref is always untouched
600 offset > 0 &&
601 // there should be at least two self-refs to do a replacement (.b > .b)
602 string.slice(0, offset).indexOf(_selector) !== -1 &&
603 // no consecutive self refs (.b.b); that is a precedence boost and treated differently
604 string.slice(offset - _selector.length, offset) !== _selector) {
605 return '.' + _componentId;
606 }
607
608 return match;
609 };
610
611 /**
612 * When writing a style like
613 *
614 * & + & {
615 * color: red;
616 * }
617 *
618 * The second ampersand should be a reference to the static component class. stylis
619 * has no knowledge of static class so we have to intelligently replace the base selector.
620 */
621 var selfReferenceReplacementPlugin = function selfReferenceReplacementPlugin(context, _, selectors) {
622 if (context === 2 && selectors.length && selectors[0].lastIndexOf(_selector) > 0) {
623 // eslint-disable-next-line no-param-reassign
624 selectors[0] = selectors[0].replace(_selectorRegexp, selfReferenceReplacer);
625 }
626 };
627
628 stylis.use([selfReferenceReplacementPlugin, parseRulesPlugin, returnRulesPlugin]);
629 stylisSplitter.use([parseRulesPlugin, returnRulesPlugin]);
630
631 var splitByRules = function splitByRules(css) {
632 return stylisSplitter('', css);
633 };
634
635 function stringifyRules(rules, selector, prefix) {
636 var componentId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '&';
637
638 var flatCSS = rules.join('').replace(COMMENT_REGEX, ''); // replace JS comments
639
640 var cssStr = selector && prefix ? prefix + ' ' + selector + ' { ' + flatCSS + ' }' : flatCSS;
641
642 // stylis has no concept of state to be passed to plugins
643 // but since JS is single=threaded, we can rely on that to ensure
644 // these properties stay in sync with the current stylis run
645 _componentId = componentId;
646 _selector = selector;
647 _selectorRegexp = new RegExp('\\' + _selector + '\\b', 'g');
648
649 return stylis(prefix || !selector ? '' : selector, cssStr);
650 }
651
652 //
653 /* eslint-disable camelcase, no-undef */
654
655 var getNonce = (function () {
656 return typeof __webpack_nonce__ !== 'undefined' ? __webpack_nonce__ : null;
657 });
658
659 //
660 /* These are helpers for the StyleTags to keep track of the injected
661 * rule names for each (component) ID that they're keeping track of.
662 * They're crucial for detecting whether a name has already been
663 * injected.
664 * (This excludes rehydrated names) */
665
666 /* adds a new ID:name pairing to a names dictionary */
667 var addNameForId = function addNameForId(names, id, name) {
668 if (name) {
669 // eslint-disable-next-line no-param-reassign
670 var namesForId = names[id] || (names[id] = Object.create(null));
671 namesForId[name] = true;
672 }
673 };
674
675 /* resets an ID entirely by overwriting it in the dictionary */
676 var resetIdNames = function resetIdNames(names, id) {
677 // eslint-disable-next-line no-param-reassign
678 names[id] = Object.create(null);
679 };
680
681 /* factory for a names dictionary checking the existance of an ID:name pairing */
682 var hasNameForId = function hasNameForId(names) {
683 return function (id, name) {
684 return names[id] !== undefined && names[id][name];
685 };
686 };
687
688 /* stringifies names for the html/element output */
689 var stringifyNames = function stringifyNames(names) {
690 var str = '';
691 // eslint-disable-next-line guard-for-in
692 for (var id in names) {
693 str += Object.keys(names[id]).join(' ') + ' ';
694 }
695 return str.trim();
696 };
697
698 /* clones the nested names dictionary */
699 var cloneNames = function cloneNames(names) {
700 var clone = Object.create(null);
701 // eslint-disable-next-line guard-for-in
702 for (var id in names) {
703 clone[id] = _extends({}, names[id]);
704 }
705 return clone;
706 };
707
708 //
709
710 /* These are helpers that deal with the insertRule (aka speedy) API
711 * They are used in the StyleTags and specifically the speedy tag
712 */
713
714 /* retrieve a sheet for a given style tag */
715 var sheetForTag = function sheetForTag(tag) {
716 // $FlowFixMe
717 if (tag.sheet) return tag.sheet;
718
719 /* Firefox quirk requires us to step through all stylesheets to find one owned by the given tag */
720 var size = document.styleSheets.length;
721 for (var i = 0; i < size; i += 1) {
722 var sheet = document.styleSheets[i];
723 // $FlowFixMe
724 if (sheet.ownerNode === tag) return sheet;
725 }
726
727 /* we should always be able to find a tag */
728 throw new StyledComponentsError(10);
729 };
730
731 /* insert a rule safely and return whether it was actually injected */
732 var safeInsertRule = function safeInsertRule(sheet, cssRule, index) {
733 /* abort early if cssRule string is falsy */
734 if (!cssRule) return false;
735
736 var maxIndex = sheet.cssRules.length;
737
738 try {
739 /* use insertRule and cap passed index with maxIndex (no of cssRules) */
740 sheet.insertRule(cssRule, index <= maxIndex ? index : maxIndex);
741 } catch (err) {
742 /* any error indicates an invalid rule */
743 return false;
744 }
745
746 return true;
747 };
748
749 /* deletes `size` rules starting from `removalIndex` */
750 var deleteRules = function deleteRules(sheet, removalIndex, size) {
751 var lowerBound = removalIndex - size;
752 for (var i = removalIndex; i > lowerBound; i -= 1) {
753 sheet.deleteRule(i);
754 }
755 };
756
757 //
758
759 /* this marker separates component styles and is important for rehydration */
760 var makeTextMarker = function makeTextMarker(id) {
761 return '\n/* sc-component-id: ' + id + ' */\n';
762 };
763
764 /* add up all numbers in array up until and including the index */
765 var addUpUntilIndex = function addUpUntilIndex(sizes, index) {
766 var totalUpToIndex = 0;
767 for (var i = 0; i <= index; i += 1) {
768 totalUpToIndex += sizes[i];
769 }
770
771 return totalUpToIndex;
772 };
773
774 /* create a new style tag after lastEl */
775 var makeStyleTag = function makeStyleTag(target, tagEl, insertBefore) {
776 var el = document.createElement('style');
777 el.setAttribute(SC_ATTR, '');
778 el.setAttribute(SC_VERSION_ATTR, "4.1.0");
779
780 var nonce = getNonce();
781 if (nonce) {
782 el.setAttribute('nonce', nonce);
783 }
784
785 /* Work around insertRule quirk in EdgeHTML */
786 el.appendChild(document.createTextNode(''));
787
788 if (target && !tagEl) {
789 /* Append to target when no previous element was passed */
790 target.appendChild(el);
791 } else {
792 if (!tagEl || !target || !tagEl.parentNode) {
793 throw new StyledComponentsError(6);
794 }
795
796 /* Insert new style tag after the previous one */
797 tagEl.parentNode.insertBefore(el, insertBefore ? tagEl : tagEl.nextSibling);
798 }
799
800 return el;
801 };
802
803 /* takes a css factory function and outputs an html styled tag factory */
804 var wrapAsHtmlTag = function wrapAsHtmlTag(css, names) {
805 return function (additionalAttrs) {
806 var nonce = getNonce();
807 var attrs = [nonce && 'nonce="' + nonce + '"', SC_ATTR + '="' + stringifyNames(names) + '"', SC_VERSION_ATTR + '="' + "4.1.0" + '"', additionalAttrs];
808
809 var htmlAttr = attrs.filter(Boolean).join(' ');
810 return '<style ' + htmlAttr + '>' + css() + '</style>';
811 };
812 };
813
814 /* takes a css factory function and outputs an element factory */
815 var wrapAsElement = function wrapAsElement(css, names) {
816 return function () {
817 var _props;
818
819 var props = (_props = {}, _props[SC_ATTR] = stringifyNames(names), _props[SC_VERSION_ATTR] = "4.1.0", _props);
820
821 var nonce = getNonce();
822 if (nonce) {
823 // $FlowFixMe
824 props.nonce = nonce;
825 }
826
827 // eslint-disable-next-line react/no-danger
828 return React__default.createElement('style', _extends({}, props, { dangerouslySetInnerHTML: { __html: css() } }));
829 };
830 };
831
832 var getIdsFromMarkersFactory = function getIdsFromMarkersFactory(markers) {
833 return function () {
834 return Object.keys(markers);
835 };
836 };
837
838 /* speedy tags utilise insertRule */
839 var makeSpeedyTag = function makeSpeedyTag(el, getImportRuleTag) {
840 var names = Object.create(null);
841 var markers = Object.create(null);
842 var sizes = [];
843
844 var extractImport = getImportRuleTag !== undefined;
845 /* indicates whther getImportRuleTag was called */
846 var usedImportRuleTag = false;
847
848 var insertMarker = function insertMarker(id) {
849 var prev = markers[id];
850 if (prev !== undefined) {
851 return prev;
852 }
853
854 markers[id] = sizes.length;
855 sizes.push(0);
856 resetIdNames(names, id);
857
858 return markers[id];
859 };
860
861 var insertRules = function insertRules(id, cssRules, name) {
862 var marker = insertMarker(id);
863 var sheet = sheetForTag(el);
864 var insertIndex = addUpUntilIndex(sizes, marker);
865
866 var injectedRules = 0;
867 var importRules = [];
868 var cssRulesSize = cssRules.length;
869
870 for (var i = 0; i < cssRulesSize; i += 1) {
871 var cssRule = cssRules[i];
872 var mayHaveImport = extractImport; /* @import rules are reordered to appear first */
873 if (mayHaveImport && cssRule.indexOf('@import') !== -1) {
874 importRules.push(cssRule);
875 } else if (safeInsertRule(sheet, cssRule, insertIndex + injectedRules)) {
876 mayHaveImport = false;
877 injectedRules += 1;
878 }
879 }
880
881 if (extractImport && importRules.length > 0) {
882 usedImportRuleTag = true;
883 // $FlowFixMe
884 getImportRuleTag().insertRules(id + '-import', importRules);
885 }
886
887 sizes[marker] += injectedRules; /* add up no of injected rules */
888 addNameForId(names, id, name);
889 };
890
891 var removeRules = function removeRules(id) {
892 var marker = markers[id];
893 if (marker === undefined) return;
894
895 var size = sizes[marker];
896 var sheet = sheetForTag(el);
897 var removalIndex = addUpUntilIndex(sizes, marker) - 1;
898 deleteRules(sheet, removalIndex, size);
899 sizes[marker] = 0;
900 resetIdNames(names, id);
901
902 if (extractImport && usedImportRuleTag) {
903 // $FlowFixMe
904 getImportRuleTag().removeRules(id + '-import');
905 }
906 };
907
908 var css = function css() {
909 var _sheetForTag = sheetForTag(el),
910 cssRules = _sheetForTag.cssRules;
911
912 var str = '';
913
914 // eslint-disable-next-line guard-for-in
915 for (var id in markers) {
916 str += makeTextMarker(id);
917 var marker = markers[id];
918 var end = addUpUntilIndex(sizes, marker);
919 var size = sizes[marker];
920 for (var i = end - size; i < end; i += 1) {
921 var rule = cssRules[i];
922 if (rule !== undefined) {
923 str += rule.cssText;
924 }
925 }
926 }
927
928 return str;
929 };
930
931 return {
932 clone: function clone() {
933 throw new StyledComponentsError(5);
934 },
935
936 css: css,
937 getIds: getIdsFromMarkersFactory(markers),
938 hasNameForId: hasNameForId(names),
939 insertMarker: insertMarker,
940 insertRules: insertRules,
941 removeRules: removeRules,
942 sealed: false,
943 styleTag: el,
944 toElement: wrapAsElement(css, names),
945 toHTML: wrapAsHtmlTag(css, names)
946 };
947 };
948
949 var makeTextNode = function makeTextNode(id) {
950 return document.createTextNode(makeTextMarker(id));
951 };
952
953 var makeBrowserTag = function makeBrowserTag(el, getImportRuleTag) {
954 var names = Object.create(null);
955 var markers = Object.create(null);
956
957 var extractImport = getImportRuleTag !== undefined;
958
959 /* indicates whther getImportRuleTag was called */
960 var usedImportRuleTag = false;
961
962 var insertMarker = function insertMarker(id) {
963 var prev = markers[id];
964 if (prev !== undefined) {
965 return prev;
966 }
967
968 markers[id] = makeTextNode(id);
969 el.appendChild(markers[id]);
970 names[id] = Object.create(null);
971
972 return markers[id];
973 };
974
975 var insertRules = function insertRules(id, cssRules, name) {
976 var marker = insertMarker(id);
977 var importRules = [];
978 var cssRulesSize = cssRules.length;
979
980 for (var i = 0; i < cssRulesSize; i += 1) {
981 var rule = cssRules[i];
982 var mayHaveImport = extractImport;
983 if (mayHaveImport && rule.indexOf('@import') !== -1) {
984 importRules.push(rule);
985 } else {
986 mayHaveImport = false;
987 var separator = i === cssRulesSize - 1 ? '' : ' ';
988 marker.appendData('' + rule + separator);
989 }
990 }
991
992 addNameForId(names, id, name);
993
994 if (extractImport && importRules.length > 0) {
995 usedImportRuleTag = true;
996 // $FlowFixMe
997 getImportRuleTag().insertRules(id + '-import', importRules);
998 }
999 };
1000
1001 var removeRules = function removeRules(id) {
1002 var marker = markers[id];
1003 if (marker === undefined) return;
1004
1005 /* create new empty text node and replace the current one */
1006 var newMarker = makeTextNode(id);
1007 el.replaceChild(newMarker, marker);
1008 markers[id] = newMarker;
1009 resetIdNames(names, id);
1010
1011 if (extractImport && usedImportRuleTag) {
1012 // $FlowFixMe
1013 getImportRuleTag().removeRules(id + '-import');
1014 }
1015 };
1016
1017 var css = function css() {
1018 var str = '';
1019
1020 // eslint-disable-next-line guard-for-in
1021 for (var id in markers) {
1022 str += markers[id].data;
1023 }
1024
1025 return str;
1026 };
1027
1028 return {
1029 clone: function clone() {
1030 throw new StyledComponentsError(5);
1031 },
1032
1033 css: css,
1034 getIds: getIdsFromMarkersFactory(markers),
1035 hasNameForId: hasNameForId(names),
1036 insertMarker: insertMarker,
1037 insertRules: insertRules,
1038 removeRules: removeRules,
1039 sealed: false,
1040 styleTag: el,
1041 toElement: wrapAsElement(css, names),
1042 toHTML: wrapAsHtmlTag(css, names)
1043 };
1044 };
1045
1046 var makeServerTag = function makeServerTag(namesArg, markersArg) {
1047 var names = namesArg === undefined ? Object.create(null) : namesArg;
1048 var markers = markersArg === undefined ? Object.create(null) : markersArg;
1049
1050 var insertMarker = function insertMarker(id) {
1051 var prev = markers[id];
1052 if (prev !== undefined) {
1053 return prev;
1054 }
1055
1056 return markers[id] = [''];
1057 };
1058
1059 var insertRules = function insertRules(id, cssRules, name) {
1060 var marker = insertMarker(id);
1061 marker[0] += cssRules.join(' ');
1062 addNameForId(names, id, name);
1063 };
1064
1065 var removeRules = function removeRules(id) {
1066 var marker = markers[id];
1067 if (marker === undefined) return;
1068 marker[0] = '';
1069 resetIdNames(names, id);
1070 };
1071
1072 var css = function css() {
1073 var str = '';
1074 // eslint-disable-next-line guard-for-in
1075 for (var id in markers) {
1076 var cssForId = markers[id][0];
1077 if (cssForId) {
1078 str += makeTextMarker(id) + cssForId;
1079 }
1080 }
1081 return str;
1082 };
1083
1084 var clone = function clone() {
1085 var namesClone = cloneNames(names);
1086 var markersClone = Object.create(null);
1087
1088 // eslint-disable-next-line guard-for-in
1089 for (var id in markers) {
1090 markersClone[id] = [markers[id][0]];
1091 }
1092
1093 return makeServerTag(namesClone, markersClone);
1094 };
1095
1096 var tag = {
1097 clone: clone,
1098 css: css,
1099 getIds: getIdsFromMarkersFactory(markers),
1100 hasNameForId: hasNameForId(names),
1101 insertMarker: insertMarker,
1102 insertRules: insertRules,
1103 removeRules: removeRules,
1104 sealed: false,
1105 styleTag: null,
1106 toElement: wrapAsElement(css, names),
1107 toHTML: wrapAsHtmlTag(css, names)
1108 };
1109
1110 return tag;
1111 };
1112
1113 var makeTag = function makeTag(target, tagEl, forceServer, insertBefore, getImportRuleTag) {
1114 if (IS_BROWSER && !forceServer) {
1115 var el = makeStyleTag(target, tagEl, insertBefore);
1116
1117 if (DISABLE_SPEEDY) {
1118 return makeBrowserTag(el, getImportRuleTag);
1119 } else {
1120 return makeSpeedyTag(el, getImportRuleTag);
1121 }
1122 }
1123
1124 return makeServerTag();
1125 };
1126
1127 var rehydrate = function rehydrate(tag, els, extracted) {
1128 /* add all extracted components to the new tag */
1129 for (var i = 0, len = extracted.length; i < len; i += 1) {
1130 var _extracted$i = extracted[i],
1131 componentId = _extracted$i.componentId,
1132 cssFromDOM = _extracted$i.cssFromDOM;
1133
1134 var cssRules = splitByRules(cssFromDOM);
1135 tag.insertRules(componentId, cssRules);
1136 }
1137
1138 /* remove old HTMLStyleElements, since they have been rehydrated */
1139 for (var _i = 0, _len = els.length; _i < _len; _i += 1) {
1140 var el = els[_i];
1141 if (el.parentNode) {
1142 el.parentNode.removeChild(el);
1143 }
1144 }
1145 };
1146
1147 //
1148
1149 var SPLIT_REGEX = /\s+/;
1150
1151 /* determine the maximum number of components before tags are sharded */
1152 var MAX_SIZE = void 0;
1153 if (IS_BROWSER) {
1154 /* in speedy mode we can keep a lot more rules in a sheet before a slowdown can be expected */
1155 MAX_SIZE = DISABLE_SPEEDY ? 40 : 1000;
1156 } else {
1157 /* for servers we do not need to shard at all */
1158 MAX_SIZE = -1;
1159 }
1160
1161 var sheetRunningId = 0;
1162 var master = void 0;
1163
1164 var StyleSheet = function () {
1165
1166 /* a map from ids to tags */
1167
1168 /* deferred rules for a given id */
1169
1170 /* this is used for not reinjecting rules via hasNameForId() */
1171
1172 /* when rules for an id are removed using remove() we have to ignore rehydratedNames for it */
1173
1174 /* a list of tags belonging to this StyleSheet */
1175
1176 /* a tag for import rules */
1177
1178 /* current capacity until a new tag must be created */
1179
1180 /* children (aka clones) of this StyleSheet inheriting all and future injections */
1181
1182 function StyleSheet() {
1183 var _this = this;
1184
1185 var target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : IS_BROWSER ? document.head : null;
1186 var forceServer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1187 classCallCheck(this, StyleSheet);
1188
1189 this.getImportRuleTag = function () {
1190 var importRuleTag = _this.importRuleTag;
1191
1192 if (importRuleTag !== undefined) {
1193 return importRuleTag;
1194 }
1195
1196 var firstTag = _this.tags[0];
1197 var insertBefore = true;
1198
1199 return _this.importRuleTag = makeTag(_this.target, firstTag ? firstTag.styleTag : null, _this.forceServer, insertBefore);
1200 };
1201
1202 sheetRunningId += 1;
1203 this.id = sheetRunningId;
1204 this.forceServer = forceServer;
1205 this.target = forceServer ? null : target;
1206 this.tagMap = {};
1207 this.deferred = {};
1208 this.rehydratedNames = {};
1209 this.ignoreRehydratedNames = {};
1210 this.tags = [];
1211 this.capacity = 1;
1212 this.clones = [];
1213 }
1214
1215 /* rehydrate all SSR'd style tags */
1216
1217
1218 StyleSheet.prototype.rehydrate = function rehydrate$$1() {
1219 if (!IS_BROWSER || this.forceServer) return this;
1220
1221 var els = [];
1222 var extracted = [];
1223 var isStreamed = false;
1224
1225 /* retrieve all of our SSR style elements from the DOM */
1226 var nodes = document.querySelectorAll('style[' + SC_ATTR + '][' + SC_VERSION_ATTR + '="' + "4.1.0" + '"]');
1227
1228 var nodesSize = nodes.length;
1229
1230 /* abort rehydration if no previous style tags were found */
1231 if (!nodesSize) return this;
1232
1233 for (var i = 0; i < nodesSize; i += 1) {
1234 var el = nodes[i];
1235
1236 /* check if style tag is a streamed tag */
1237 if (!isStreamed) isStreamed = !!el.getAttribute(SC_STREAM_ATTR);
1238
1239 /* retrieve all component names */
1240 var elNames = (el.getAttribute(SC_ATTR) || '').trim().split(SPLIT_REGEX);
1241 var elNamesSize = elNames.length;
1242 for (var j = 0, name; j < elNamesSize; j += 1) {
1243 name = elNames[j];
1244 /* add rehydrated name to sheet to avoid re-adding styles */
1245 this.rehydratedNames[name] = true;
1246 }
1247
1248 /* extract all components and their CSS */
1249 extracted.push.apply(extracted, extractComps(el.textContent));
1250
1251 /* store original HTMLStyleElement */
1252 els.push(el);
1253 }
1254
1255 /* abort rehydration if nothing was extracted */
1256 var extractedSize = extracted.length;
1257 if (!extractedSize) return this;
1258
1259 /* create a tag to be used for rehydration */
1260 var tag = this.makeTag(null);
1261
1262 rehydrate(tag, els, extracted);
1263
1264 /* reset capacity and adjust MAX_SIZE by the initial size of the rehydration */
1265 this.capacity = Math.max(1, MAX_SIZE - extractedSize);
1266 this.tags.push(tag);
1267
1268 /* retrieve all component ids */
1269 for (var _j = 0; _j < extractedSize; _j += 1) {
1270 this.tagMap[extracted[_j].componentId] = tag;
1271 }
1272
1273 return this;
1274 };
1275
1276 /* retrieve a "master" instance of StyleSheet which is typically used when no other is available
1277 * The master StyleSheet is targeted by createGlobalStyle, keyframes, and components outside of any
1278 * StyleSheetManager's context */
1279
1280
1281 /* reset the internal "master" instance */
1282 StyleSheet.reset = function reset() {
1283 var forceServer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1284
1285 master = new StyleSheet(undefined, forceServer).rehydrate();
1286 };
1287
1288 /* adds "children" to the StyleSheet that inherit all of the parents' rules
1289 * while their own rules do not affect the parent */
1290
1291
1292 StyleSheet.prototype.clone = function clone() {
1293 var sheet = new StyleSheet(this.target, this.forceServer);
1294
1295 /* add to clone array */
1296 this.clones.push(sheet);
1297
1298 /* clone all tags */
1299 sheet.tags = this.tags.map(function (tag) {
1300 var ids = tag.getIds();
1301 var newTag = tag.clone();
1302
1303 /* reconstruct tagMap */
1304 for (var i = 0; i < ids.length; i += 1) {
1305 sheet.tagMap[ids[i]] = newTag;
1306 }
1307
1308 return newTag;
1309 });
1310
1311 /* clone other maps */
1312 sheet.rehydratedNames = _extends({}, this.rehydratedNames);
1313 sheet.deferred = _extends({}, this.deferred);
1314
1315 return sheet;
1316 };
1317
1318 /* force StyleSheet to create a new tag on the next injection */
1319
1320
1321 StyleSheet.prototype.sealAllTags = function sealAllTags() {
1322 this.capacity = 1;
1323
1324 this.tags.forEach(function (tag) {
1325 // eslint-disable-next-line no-param-reassign
1326 tag.sealed = true;
1327 });
1328 };
1329
1330 StyleSheet.prototype.makeTag = function makeTag$$1(tag) {
1331 var lastEl = tag ? tag.styleTag : null;
1332 var insertBefore = false;
1333
1334 return makeTag(this.target, lastEl, this.forceServer, insertBefore, this.getImportRuleTag);
1335 };
1336
1337 /* get a tag for a given componentId, assign the componentId to one, or shard */
1338 StyleSheet.prototype.getTagForId = function getTagForId(id) {
1339 /* simply return a tag, when the componentId was already assigned one */
1340 var prev = this.tagMap[id];
1341 if (prev !== undefined && !prev.sealed) {
1342 return prev;
1343 }
1344
1345 var tag = this.tags[this.tags.length - 1];
1346
1347 /* shard (create a new tag) if the tag is exhausted (See MAX_SIZE) */
1348 this.capacity -= 1;
1349
1350 if (this.capacity === 0) {
1351 this.capacity = MAX_SIZE;
1352 tag = this.makeTag(tag);
1353 this.tags.push(tag);
1354 }
1355
1356 return this.tagMap[id] = tag;
1357 };
1358
1359 /* mainly for createGlobalStyle to check for its id */
1360
1361
1362 StyleSheet.prototype.hasId = function hasId(id) {
1363 return this.tagMap[id] !== undefined;
1364 };
1365
1366 /* caching layer checking id+name to already have a corresponding tag and injected rules */
1367
1368
1369 StyleSheet.prototype.hasNameForId = function hasNameForId(id, name) {
1370 /* exception for rehydrated names which are checked separately */
1371 if (this.ignoreRehydratedNames[id] === undefined && this.rehydratedNames[name]) {
1372 return true;
1373 }
1374
1375 var tag = this.tagMap[id];
1376 return tag !== undefined && tag.hasNameForId(id, name);
1377 };
1378
1379 /* registers a componentId and registers it on its tag */
1380
1381
1382 StyleSheet.prototype.deferredInject = function deferredInject(id, cssRules) {
1383 /* don't inject when the id is already registered */
1384 if (this.tagMap[id] !== undefined) return;
1385
1386 var clones = this.clones;
1387
1388 for (var i = 0; i < clones.length; i += 1) {
1389 clones[i].deferredInject(id, cssRules);
1390 }
1391
1392 this.getTagForId(id).insertMarker(id);
1393 this.deferred[id] = cssRules;
1394 };
1395
1396 /* injects rules for a given id with a name that will need to be cached */
1397
1398
1399 StyleSheet.prototype.inject = function inject(id, cssRules, name) {
1400 var clones = this.clones;
1401
1402
1403 for (var i = 0; i < clones.length; i += 1) {
1404 clones[i].inject(id, cssRules, name);
1405 }
1406
1407 var tag = this.getTagForId(id);
1408
1409 /* add deferred rules for component */
1410 if (this.deferred[id] !== undefined) {
1411 // Combine passed cssRules with previously deferred CSS rules
1412 // NOTE: We cannot mutate the deferred array itself as all clones
1413 // do the same (see clones[i].inject)
1414 var rules = this.deferred[id].concat(cssRules);
1415 tag.insertRules(id, rules, name);
1416
1417 this.deferred[id] = undefined;
1418 } else {
1419 tag.insertRules(id, cssRules, name);
1420 }
1421 };
1422
1423 /* removes all rules for a given id, which doesn't remove its marker but resets it */
1424
1425
1426 StyleSheet.prototype.remove = function remove(id) {
1427 var tag = this.tagMap[id];
1428 if (tag === undefined) return;
1429
1430 var clones = this.clones;
1431
1432 for (var i = 0; i < clones.length; i += 1) {
1433 clones[i].remove(id);
1434 }
1435
1436 /* remove all rules from the tag */
1437 tag.removeRules(id);
1438
1439 /* ignore possible rehydrated names */
1440 this.ignoreRehydratedNames[id] = true;
1441
1442 /* delete possible deferred rules */
1443 this.deferred[id] = undefined;
1444 };
1445
1446 StyleSheet.prototype.toHTML = function toHTML() {
1447 return this.tags.map(function (tag) {
1448 return tag.toHTML();
1449 }).join('');
1450 };
1451
1452 StyleSheet.prototype.toReactElements = function toReactElements() {
1453 var id = this.id;
1454
1455
1456 return this.tags.map(function (tag, i) {
1457 var key = 'sc-' + id + '-' + i;
1458 return React.cloneElement(tag.toElement(), { key: key });
1459 });
1460 };
1461
1462 createClass(StyleSheet, null, [{
1463 key: 'master',
1464 get: function get$$1() {
1465 return master || (master = new StyleSheet().rehydrate());
1466 }
1467
1468 /* NOTE: This is just for backwards-compatibility with jest-styled-components */
1469
1470 }, {
1471 key: 'instance',
1472 get: function get$$1() {
1473 return StyleSheet.master;
1474 }
1475 }]);
1476 return StyleSheet;
1477 }();
1478
1479 //
1480
1481 var Keyframes = function () {
1482 function Keyframes(name, rules) {
1483 var _this = this;
1484
1485 classCallCheck(this, Keyframes);
1486
1487 this.inject = function (styleSheet) {
1488 if (!styleSheet.hasNameForId(_this.id, _this.name)) {
1489 styleSheet.inject(_this.id, _this.rules, _this.name);
1490 }
1491 };
1492
1493 this.toString = function () {
1494 throw new StyledComponentsError(12, String(_this.name));
1495 };
1496
1497 this.name = name;
1498 this.rules = rules;
1499
1500 this.id = 'sc-keyframes-' + name;
1501 }
1502
1503 Keyframes.prototype.getName = function getName() {
1504 return this.name;
1505 };
1506
1507 return Keyframes;
1508 }();
1509
1510 //
1511
1512 /**
1513 * inlined version of
1514 * https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
1515 */
1516
1517 var uppercasePattern = /([A-Z])/g;
1518 var msPattern = /^ms-/;
1519
1520 /**
1521 * Hyphenates a camelcased CSS property name, for example:
1522 *
1523 * > hyphenateStyleName('backgroundColor')
1524 * < "background-color"
1525 * > hyphenateStyleName('MozTransition')
1526 * < "-moz-transition"
1527 * > hyphenateStyleName('msTransition')
1528 * < "-ms-transition"
1529 *
1530 * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
1531 * is converted to `-ms-`.
1532 *
1533 * @param {string} string
1534 * @return {string}
1535 */
1536 function hyphenateStyleName(string) {
1537 return string.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-');
1538 }
1539
1540 var unitlessKeys = {
1541 animationIterationCount: 1,
1542 borderImageOutset: 1,
1543 borderImageSlice: 1,
1544 borderImageWidth: 1,
1545 boxFlex: 1,
1546 boxFlexGroup: 1,
1547 boxOrdinalGroup: 1,
1548 columnCount: 1,
1549 columns: 1,
1550 flex: 1,
1551 flexGrow: 1,
1552 flexPositive: 1,
1553 flexShrink: 1,
1554 flexNegative: 1,
1555 flexOrder: 1,
1556 gridRow: 1,
1557 gridRowEnd: 1,
1558 gridRowSpan: 1,
1559 gridRowStart: 1,
1560 gridColumn: 1,
1561 gridColumnEnd: 1,
1562 gridColumnSpan: 1,
1563 gridColumnStart: 1,
1564 fontWeight: 1,
1565 lineHeight: 1,
1566 opacity: 1,
1567 order: 1,
1568 orphans: 1,
1569 tabSize: 1,
1570 widows: 1,
1571 zIndex: 1,
1572 zoom: 1,
1573 WebkitLineClamp: 1,
1574 // SVG-related properties
1575 fillOpacity: 1,
1576 floodOpacity: 1,
1577 stopOpacity: 1,
1578 strokeDasharray: 1,
1579 strokeDashoffset: 1,
1580 strokeMiterlimit: 1,
1581 strokeOpacity: 1,
1582 strokeWidth: 1
1583 };
1584
1585 //
1586
1587 // Taken from https://github.com/facebook/react/blob/b87aabdfe1b7461e7331abb3601d9e6bb27544bc/packages/react-dom/src/shared/dangerousStyleValue.js
1588 function addUnitIfNeeded(name, value) {
1589 // https://github.com/amilajack/eslint-plugin-flowtype-errors/issues/133
1590 // $FlowFixMe
1591 if (value == null || typeof value === 'boolean' || value === '') {
1592 return '';
1593 }
1594
1595 if (typeof value === 'number' && value !== 0 && !(name in unitlessKeys)) {
1596 return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers
1597 }
1598
1599 return String(value).trim();
1600 }
1601
1602 //
1603
1604 /**
1605 * It's falsish not falsy because 0 is allowed.
1606 */
1607 var isFalsish = function isFalsish(chunk) {
1608 return chunk === undefined || chunk === null || chunk === false || chunk === '';
1609 };
1610
1611 var objToCss = function objToCss(obj, prevKey) {
1612 var css = Object.keys(obj).filter(function (key) {
1613 return !isFalsish(obj[key]);
1614 }).map(function (key) {
1615 if (isPlainObject(obj[key])) return objToCss(obj[key], key);
1616 return hyphenateStyleName(key) + ': ' + addUnitIfNeeded(key, obj[key]) + ';';
1617 }).join(' ');
1618 return prevKey ? prevKey + ' {\n ' + css + '\n}' : css;
1619 };
1620
1621 function flatten(chunk, executionContext, styleSheet) {
1622 if (Array.isArray(chunk)) {
1623 var ruleSet = [];
1624
1625 for (var i = 0, len = chunk.length, result; i < len; i += 1) {
1626 result = flatten(chunk[i], executionContext, styleSheet);
1627
1628 if (result === null) continue;else if (Array.isArray(result)) ruleSet.push.apply(ruleSet, result);else ruleSet.push(result);
1629 }
1630
1631 return ruleSet;
1632 }
1633
1634 if (isFalsish(chunk)) {
1635 return null;
1636 }
1637
1638 /* Handle other components */
1639 if (isStyledComponent(chunk)) {
1640 return '.' + chunk.styledComponentId;
1641 }
1642
1643 /* Either execute or defer the function */
1644 if (isFunction(chunk)) {
1645 if (executionContext) {
1646 // eslint-disable-next-line new-cap
1647 if (reactIs_1(new chunk(executionContext))) {
1648 throw new StyledComponentsError(13, getComponentName(chunk));
1649 }
1650
1651 return flatten(chunk(executionContext), executionContext, styleSheet);
1652 } else return chunk;
1653 }
1654
1655 if (chunk instanceof Keyframes) {
1656 if (styleSheet) {
1657 chunk.inject(styleSheet);
1658 return chunk.getName();
1659 } else return chunk;
1660 }
1661
1662 /* Handle objects */
1663 return isPlainObject(chunk) ? objToCss(chunk) : chunk.toString();
1664 }
1665
1666 //
1667
1668 function css(styles) {
1669 for (var _len = arguments.length, interpolations = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1670 interpolations[_key - 1] = arguments[_key];
1671 }
1672
1673 if (isFunction(styles) || isPlainObject(styles)) {
1674 // $FlowFixMe
1675 return flatten(interleave(EMPTY_ARRAY, [styles].concat(interpolations)));
1676 }
1677
1678 // $FlowFixMe
1679 return flatten(interleave(styles, interpolations));
1680 }
1681
1682 /*
1683 object-assign
1684 (c) Sindre Sorhus
1685 @license MIT
1686 */
1687 /* eslint-disable no-unused-vars */
1688 var getOwnPropertySymbols = Object.getOwnPropertySymbols;
1689 var hasOwnProperty = Object.prototype.hasOwnProperty;
1690 var propIsEnumerable = Object.prototype.propertyIsEnumerable;
1691
1692 function toObject(val) {
1693 if (val === null || val === undefined) {
1694 throw new TypeError('Object.assign cannot be called with null or undefined');
1695 }
1696
1697 return Object(val);
1698 }
1699
1700 function shouldUseNative() {
1701 try {
1702 if (!Object.assign) {
1703 return false;
1704 }
1705
1706 // Detect buggy property enumeration order in older V8 versions.
1707
1708 // https://bugs.chromium.org/p/v8/issues/detail?id=4118
1709 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
1710 test1[5] = 'de';
1711 if (Object.getOwnPropertyNames(test1)[0] === '5') {
1712 return false;
1713 }
1714
1715 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
1716 var test2 = {};
1717 for (var i = 0; i < 10; i++) {
1718 test2['_' + String.fromCharCode(i)] = i;
1719 }
1720 var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
1721 return test2[n];
1722 });
1723 if (order2.join('') !== '0123456789') {
1724 return false;
1725 }
1726
1727 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
1728 var test3 = {};
1729 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
1730 test3[letter] = letter;
1731 });
1732 if (Object.keys(Object.assign({}, test3)).join('') !==
1733 'abcdefghijklmnopqrst') {
1734 return false;
1735 }
1736
1737 return true;
1738 } catch (err) {
1739 // We don't expect any of the above to throw, but better to be safe.
1740 return false;
1741 }
1742 }
1743
1744 var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
1745 var from;
1746 var to = toObject(target);
1747 var symbols;
1748
1749 for (var s = 1; s < arguments.length; s++) {
1750 from = Object(arguments[s]);
1751
1752 for (var key in from) {
1753 if (hasOwnProperty.call(from, key)) {
1754 to[key] = from[key];
1755 }
1756 }
1757
1758 if (getOwnPropertySymbols) {
1759 symbols = getOwnPropertySymbols(from);
1760 for (var i = 0; i < symbols.length; i++) {
1761 if (propIsEnumerable.call(from, symbols[i])) {
1762 to[symbols[i]] = from[symbols[i]];
1763 }
1764 }
1765 }
1766 }
1767
1768 return to;
1769 };
1770
1771 /**
1772 * Copyright (c) 2013-present, Facebook, Inc.
1773 *
1774 * This source code is licensed under the MIT license found in the
1775 * LICENSE file in the root directory of this source tree.
1776 */
1777
1778 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
1779
1780 var ReactPropTypesSecret_1 = ReactPropTypesSecret;
1781
1782 var printWarning = function() {};
1783
1784 {
1785 var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
1786 var loggedTypeFailures = {};
1787
1788 printWarning = function(text) {
1789 var message = 'Warning: ' + text;
1790 if (typeof console !== 'undefined') {
1791 console.error(message);
1792 }
1793 try {
1794 // --- Welcome to debugging React ---
1795 // This error was thrown as a convenience so that you can use this stack
1796 // to find the callsite that caused this warning to fire.
1797 throw new Error(message);
1798 } catch (x) {}
1799 };
1800 }
1801
1802 /**
1803 * Assert that the values match with the type specs.
1804 * Error messages are memorized and will only be shown once.
1805 *
1806 * @param {object} typeSpecs Map of name to a ReactPropType
1807 * @param {object} values Runtime values that need to be type-checked
1808 * @param {string} location e.g. "prop", "context", "child context"
1809 * @param {string} componentName Name of the component for error messages.
1810 * @param {?Function} getStack Returns the component stack.
1811 * @private
1812 */
1813 function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
1814 {
1815 for (var typeSpecName in typeSpecs) {
1816 if (typeSpecs.hasOwnProperty(typeSpecName)) {
1817 var error;
1818 // Prop type validation may throw. In case they do, we don't want to
1819 // fail the render phase where it didn't fail before. So we log it.
1820 // After these have been cleaned up, we'll let them throw.
1821 try {
1822 // This is intentionally an invariant that gets caught. It's the same
1823 // behavior as without this statement except with a better message.
1824 if (typeof typeSpecs[typeSpecName] !== 'function') {
1825 var err = Error(
1826 (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
1827 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
1828 );
1829 err.name = 'Invariant Violation';
1830 throw err;
1831 }
1832 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
1833 } catch (ex) {
1834 error = ex;
1835 }
1836 if (error && !(error instanceof Error)) {
1837 printWarning(
1838 (componentName || 'React class') + ': type specification of ' +
1839 location + ' `' + typeSpecName + '` is invalid; the type checker ' +
1840 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
1841 'You may have forgotten to pass an argument to the type checker ' +
1842 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
1843 'shape all require an argument).'
1844 );
1845
1846 }
1847 if (error instanceof Error && !(error.message in loggedTypeFailures)) {
1848 // Only monitor this failure once because there tends to be a lot of the
1849 // same error.
1850 loggedTypeFailures[error.message] = true;
1851
1852 var stack = getStack ? getStack() : '';
1853
1854 printWarning(
1855 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
1856 );
1857 }
1858 }
1859 }
1860 }
1861 }
1862
1863 var checkPropTypes_1 = checkPropTypes;
1864
1865 var printWarning$1 = function() {};
1866
1867 {
1868 printWarning$1 = function(text) {
1869 var message = 'Warning: ' + text;
1870 if (typeof console !== 'undefined') {
1871 console.error(message);
1872 }
1873 try {
1874 // --- Welcome to debugging React ---
1875 // This error was thrown as a convenience so that you can use this stack
1876 // to find the callsite that caused this warning to fire.
1877 throw new Error(message);
1878 } catch (x) {}
1879 };
1880 }
1881
1882 function emptyFunctionThatReturnsNull() {
1883 return null;
1884 }
1885
1886 var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
1887 /* global Symbol */
1888 var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
1889 var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
1890
1891 /**
1892 * Returns the iterator method function contained on the iterable object.
1893 *
1894 * Be sure to invoke the function with the iterable as context:
1895 *
1896 * var iteratorFn = getIteratorFn(myIterable);
1897 * if (iteratorFn) {
1898 * var iterator = iteratorFn.call(myIterable);
1899 * ...
1900 * }
1901 *
1902 * @param {?object} maybeIterable
1903 * @return {?function}
1904 */
1905 function getIteratorFn(maybeIterable) {
1906 var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
1907 if (typeof iteratorFn === 'function') {
1908 return iteratorFn;
1909 }
1910 }
1911
1912 /**
1913 * Collection of methods that allow declaration and validation of props that are
1914 * supplied to React components. Example usage:
1915 *
1916 * var Props = require('ReactPropTypes');
1917 * var MyArticle = React.createClass({
1918 * propTypes: {
1919 * // An optional string prop named "description".
1920 * description: Props.string,
1921 *
1922 * // A required enum prop named "category".
1923 * category: Props.oneOf(['News','Photos']).isRequired,
1924 *
1925 * // A prop named "dialog" that requires an instance of Dialog.
1926 * dialog: Props.instanceOf(Dialog).isRequired
1927 * },
1928 * render: function() { ... }
1929 * });
1930 *
1931 * A more formal specification of how these methods are used:
1932 *
1933 * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
1934 * decl := ReactPropTypes.{type}(.isRequired)?
1935 *
1936 * Each and every declaration produces a function with the same signature. This
1937 * allows the creation of custom validation functions. For example:
1938 *
1939 * var MyLink = React.createClass({
1940 * propTypes: {
1941 * // An optional string or URI prop named "href".
1942 * href: function(props, propName, componentName) {
1943 * var propValue = props[propName];
1944 * if (propValue != null && typeof propValue !== 'string' &&
1945 * !(propValue instanceof URI)) {
1946 * return new Error(
1947 * 'Expected a string or an URI for ' + propName + ' in ' +
1948 * componentName
1949 * );
1950 * }
1951 * }
1952 * },
1953 * render: function() {...}
1954 * });
1955 *
1956 * @internal
1957 */
1958
1959 var ANONYMOUS = '<<anonymous>>';
1960
1961 // Important!
1962 // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
1963 var ReactPropTypes = {
1964 array: createPrimitiveTypeChecker('array'),
1965 bool: createPrimitiveTypeChecker('boolean'),
1966 func: createPrimitiveTypeChecker('function'),
1967 number: createPrimitiveTypeChecker('number'),
1968 object: createPrimitiveTypeChecker('object'),
1969 string: createPrimitiveTypeChecker('string'),
1970 symbol: createPrimitiveTypeChecker('symbol'),
1971
1972 any: createAnyTypeChecker(),
1973 arrayOf: createArrayOfTypeChecker,
1974 element: createElementTypeChecker(),
1975 instanceOf: createInstanceTypeChecker,
1976 node: createNodeChecker(),
1977 objectOf: createObjectOfTypeChecker,
1978 oneOf: createEnumTypeChecker,
1979 oneOfType: createUnionTypeChecker,
1980 shape: createShapeTypeChecker,
1981 exact: createStrictShapeTypeChecker,
1982 };
1983
1984 /**
1985 * inlined Object.is polyfill to avoid requiring consumers ship their own
1986 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
1987 */
1988 /*eslint-disable no-self-compare*/
1989 function is(x, y) {
1990 // SameValue algorithm
1991 if (x === y) {
1992 // Steps 1-5, 7-10
1993 // Steps 6.b-6.e: +0 != -0
1994 return x !== 0 || 1 / x === 1 / y;
1995 } else {
1996 // Step 6.a: NaN == NaN
1997 return x !== x && y !== y;
1998 }
1999 }
2000 /*eslint-enable no-self-compare*/
2001
2002 /**
2003 * We use an Error-like object for backward compatibility as people may call
2004 * PropTypes directly and inspect their output. However, we don't use real
2005 * Errors anymore. We don't inspect their stack anyway, and creating them
2006 * is prohibitively expensive if they are created too often, such as what
2007 * happens in oneOfType() for any type before the one that matched.
2008 */
2009 function PropTypeError(message) {
2010 this.message = message;
2011 this.stack = '';
2012 }
2013 // Make `instanceof Error` still work for returned errors.
2014 PropTypeError.prototype = Error.prototype;
2015
2016 function createChainableTypeChecker(validate) {
2017 {
2018 var manualPropTypeCallCache = {};
2019 var manualPropTypeWarningCount = 0;
2020 }
2021 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
2022 componentName = componentName || ANONYMOUS;
2023 propFullName = propFullName || propName;
2024
2025 if (secret !== ReactPropTypesSecret_1) {
2026 if (throwOnDirectAccess) {
2027 // New behavior only for users of `prop-types` package
2028 var err = new Error(
2029 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
2030 'Use `PropTypes.checkPropTypes()` to call them. ' +
2031 'Read more at http://fb.me/use-check-prop-types'
2032 );
2033 err.name = 'Invariant Violation';
2034 throw err;
2035 } else if (typeof console !== 'undefined') {
2036 // Old behavior for people using React.PropTypes
2037 var cacheKey = componentName + ':' + propName;
2038 if (
2039 !manualPropTypeCallCache[cacheKey] &&
2040 // Avoid spamming the console because they are often not actionable except for lib authors
2041 manualPropTypeWarningCount < 3
2042 ) {
2043 printWarning$1(
2044 'You are manually calling a React.PropTypes validation ' +
2045 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
2046 'and will throw in the standalone `prop-types` package. ' +
2047 'You may be seeing this warning due to a third-party PropTypes ' +
2048 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
2049 );
2050 manualPropTypeCallCache[cacheKey] = true;
2051 manualPropTypeWarningCount++;
2052 }
2053 }
2054 }
2055 if (props[propName] == null) {
2056 if (isRequired) {
2057 if (props[propName] === null) {
2058 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
2059 }
2060 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
2061 }
2062 return null;
2063 } else {
2064 return validate(props, propName, componentName, location, propFullName);
2065 }
2066 }
2067
2068 var chainedCheckType = checkType.bind(null, false);
2069 chainedCheckType.isRequired = checkType.bind(null, true);
2070
2071 return chainedCheckType;
2072 }
2073
2074 function createPrimitiveTypeChecker(expectedType) {
2075 function validate(props, propName, componentName, location, propFullName, secret) {
2076 var propValue = props[propName];
2077 var propType = getPropType(propValue);
2078 if (propType !== expectedType) {
2079 // `propValue` being instance of, say, date/regexp, pass the 'object'
2080 // check, but we can offer a more precise error message here rather than
2081 // 'of type `object`'.
2082 var preciseType = getPreciseType(propValue);
2083
2084 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
2085 }
2086 return null;
2087 }
2088 return createChainableTypeChecker(validate);
2089 }
2090
2091 function createAnyTypeChecker() {
2092 return createChainableTypeChecker(emptyFunctionThatReturnsNull);
2093 }
2094
2095 function createArrayOfTypeChecker(typeChecker) {
2096 function validate(props, propName, componentName, location, propFullName) {
2097 if (typeof typeChecker !== 'function') {
2098 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
2099 }
2100 var propValue = props[propName];
2101 if (!Array.isArray(propValue)) {
2102 var propType = getPropType(propValue);
2103 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
2104 }
2105 for (var i = 0; i < propValue.length; i++) {
2106 var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
2107 if (error instanceof Error) {
2108 return error;
2109 }
2110 }
2111 return null;
2112 }
2113 return createChainableTypeChecker(validate);
2114 }
2115
2116 function createElementTypeChecker() {
2117 function validate(props, propName, componentName, location, propFullName) {
2118 var propValue = props[propName];
2119 if (!isValidElement(propValue)) {
2120 var propType = getPropType(propValue);
2121 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
2122 }
2123 return null;
2124 }
2125 return createChainableTypeChecker(validate);
2126 }
2127
2128 function createInstanceTypeChecker(expectedClass) {
2129 function validate(props, propName, componentName, location, propFullName) {
2130 if (!(props[propName] instanceof expectedClass)) {
2131 var expectedClassName = expectedClass.name || ANONYMOUS;
2132 var actualClassName = getClassName(props[propName]);
2133 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
2134 }
2135 return null;
2136 }
2137 return createChainableTypeChecker(validate);
2138 }
2139
2140 function createEnumTypeChecker(expectedValues) {
2141 if (!Array.isArray(expectedValues)) {
2142 printWarning$1('Invalid argument supplied to oneOf, expected an instance of array.');
2143 return emptyFunctionThatReturnsNull;
2144 }
2145
2146 function validate(props, propName, componentName, location, propFullName) {
2147 var propValue = props[propName];
2148 for (var i = 0; i < expectedValues.length; i++) {
2149 if (is(propValue, expectedValues[i])) {
2150 return null;
2151 }
2152 }
2153
2154 var valuesString = JSON.stringify(expectedValues);
2155 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
2156 }
2157 return createChainableTypeChecker(validate);
2158 }
2159
2160 function createObjectOfTypeChecker(typeChecker) {
2161 function validate(props, propName, componentName, location, propFullName) {
2162 if (typeof typeChecker !== 'function') {
2163 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
2164 }
2165 var propValue = props[propName];
2166 var propType = getPropType(propValue);
2167 if (propType !== 'object') {
2168 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
2169 }
2170 for (var key in propValue) {
2171 if (propValue.hasOwnProperty(key)) {
2172 var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
2173 if (error instanceof Error) {
2174 return error;
2175 }
2176 }
2177 }
2178 return null;
2179 }
2180 return createChainableTypeChecker(validate);
2181 }
2182
2183 function createUnionTypeChecker(arrayOfTypeCheckers) {
2184 if (!Array.isArray(arrayOfTypeCheckers)) {
2185 printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.');
2186 return emptyFunctionThatReturnsNull;
2187 }
2188
2189 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
2190 var checker = arrayOfTypeCheckers[i];
2191 if (typeof checker !== 'function') {
2192 printWarning$1(
2193 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
2194 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
2195 );
2196 return emptyFunctionThatReturnsNull;
2197 }
2198 }
2199
2200 function validate(props, propName, componentName, location, propFullName) {
2201 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
2202 var checker = arrayOfTypeCheckers[i];
2203 if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
2204 return null;
2205 }
2206 }
2207
2208 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
2209 }
2210 return createChainableTypeChecker(validate);
2211 }
2212
2213 function createNodeChecker() {
2214 function validate(props, propName, componentName, location, propFullName) {
2215 if (!isNode(props[propName])) {
2216 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
2217 }
2218 return null;
2219 }
2220 return createChainableTypeChecker(validate);
2221 }
2222
2223 function createShapeTypeChecker(shapeTypes) {
2224 function validate(props, propName, componentName, location, propFullName) {
2225 var propValue = props[propName];
2226 var propType = getPropType(propValue);
2227 if (propType !== 'object') {
2228 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
2229 }
2230 for (var key in shapeTypes) {
2231 var checker = shapeTypes[key];
2232 if (!checker) {
2233 continue;
2234 }
2235 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
2236 if (error) {
2237 return error;
2238 }
2239 }
2240 return null;
2241 }
2242 return createChainableTypeChecker(validate);
2243 }
2244
2245 function createStrictShapeTypeChecker(shapeTypes) {
2246 function validate(props, propName, componentName, location, propFullName) {
2247 var propValue = props[propName];
2248 var propType = getPropType(propValue);
2249 if (propType !== 'object') {
2250 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
2251 }
2252 // We need to check all keys in case some are required but missing from
2253 // props.
2254 var allKeys = objectAssign({}, props[propName], shapeTypes);
2255 for (var key in allKeys) {
2256 var checker = shapeTypes[key];
2257 if (!checker) {
2258 return new PropTypeError(
2259 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
2260 '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
2261 '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
2262 );
2263 }
2264 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
2265 if (error) {
2266 return error;
2267 }
2268 }
2269 return null;
2270 }
2271
2272 return createChainableTypeChecker(validate);
2273 }
2274
2275 function isNode(propValue) {
2276 switch (typeof propValue) {
2277 case 'number':
2278 case 'string':
2279 case 'undefined':
2280 return true;
2281 case 'boolean':
2282 return !propValue;
2283 case 'object':
2284 if (Array.isArray(propValue)) {
2285 return propValue.every(isNode);
2286 }
2287 if (propValue === null || isValidElement(propValue)) {
2288 return true;
2289 }
2290
2291 var iteratorFn = getIteratorFn(propValue);
2292 if (iteratorFn) {
2293 var iterator = iteratorFn.call(propValue);
2294 var step;
2295 if (iteratorFn !== propValue.entries) {
2296 while (!(step = iterator.next()).done) {
2297 if (!isNode(step.value)) {
2298 return false;
2299 }
2300 }
2301 } else {
2302 // Iterator will provide entry [k,v] tuples rather than values.
2303 while (!(step = iterator.next()).done) {
2304 var entry = step.value;
2305 if (entry) {
2306 if (!isNode(entry[1])) {
2307 return false;
2308 }
2309 }
2310 }
2311 }
2312 } else {
2313 return false;
2314 }
2315
2316 return true;
2317 default:
2318 return false;
2319 }
2320 }
2321
2322 function isSymbol(propType, propValue) {
2323 // Native Symbol.
2324 if (propType === 'symbol') {
2325 return true;
2326 }
2327
2328 // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
2329 if (propValue['@@toStringTag'] === 'Symbol') {
2330 return true;
2331 }
2332
2333 // Fallback for non-spec compliant Symbols which are polyfilled.
2334 if (typeof Symbol === 'function' && propValue instanceof Symbol) {
2335 return true;
2336 }
2337
2338 return false;
2339 }
2340
2341 // Equivalent of `typeof` but with special handling for array and regexp.
2342 function getPropType(propValue) {
2343 var propType = typeof propValue;
2344 if (Array.isArray(propValue)) {
2345 return 'array';
2346 }
2347 if (propValue instanceof RegExp) {
2348 // Old webkits (at least until Android 4.0) return 'function' rather than
2349 // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
2350 // passes PropTypes.object.
2351 return 'object';
2352 }
2353 if (isSymbol(propType, propValue)) {
2354 return 'symbol';
2355 }
2356 return propType;
2357 }
2358
2359 // This handles more types than `getPropType`. Only used for error messages.
2360 // See `createPrimitiveTypeChecker`.
2361 function getPreciseType(propValue) {
2362 if (typeof propValue === 'undefined' || propValue === null) {
2363 return '' + propValue;
2364 }
2365 var propType = getPropType(propValue);
2366 if (propType === 'object') {
2367 if (propValue instanceof Date) {
2368 return 'date';
2369 } else if (propValue instanceof RegExp) {
2370 return 'regexp';
2371 }
2372 }
2373 return propType;
2374 }
2375
2376 // Returns a string that is postfixed to a warning about an invalid type.
2377 // For example, "undefined" or "of type array"
2378 function getPostfixForTypeWarning(value) {
2379 var type = getPreciseType(value);
2380 switch (type) {
2381 case 'array':
2382 case 'object':
2383 return 'an ' + type;
2384 case 'boolean':
2385 case 'date':
2386 case 'regexp':
2387 return 'a ' + type;
2388 default:
2389 return type;
2390 }
2391 }
2392
2393 // Returns class name of the object, if any.
2394 function getClassName(propValue) {
2395 if (!propValue.constructor || !propValue.constructor.name) {
2396 return ANONYMOUS;
2397 }
2398 return propValue.constructor.name;
2399 }
2400
2401 ReactPropTypes.checkPropTypes = checkPropTypes_1;
2402 ReactPropTypes.PropTypes = ReactPropTypes;
2403
2404 return ReactPropTypes;
2405 };
2406
2407 var propTypes = createCommonjsModule(function (module) {
2408 /**
2409 * Copyright (c) 2013-present, Facebook, Inc.
2410 *
2411 * This source code is licensed under the MIT license found in the
2412 * LICENSE file in the root directory of this source tree.
2413 */
2414
2415 {
2416 var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
2417 Symbol.for &&
2418 Symbol.for('react.element')) ||
2419 0xeac7;
2420
2421 var isValidElement = function(object) {
2422 return typeof object === 'object' &&
2423 object !== null &&
2424 object.$$typeof === REACT_ELEMENT_TYPE;
2425 };
2426
2427 // By explicitly using `prop-types` you are opting into new development behavior.
2428 // http://fb.me/prop-types-in-prod
2429 var throwOnDirectAccess = true;
2430 module.exports = factoryWithTypeCheckers(isValidElement, throwOnDirectAccess);
2431 }
2432 });
2433
2434 //
2435
2436 function hasFunctionObjectKey(obj) {
2437 // eslint-disable-next-line guard-for-in, no-restricted-syntax
2438 for (var key in obj) {
2439 if (isFunction(obj[key])) {
2440 return true;
2441 }
2442 }
2443
2444 return false;
2445 }
2446
2447 function isStaticRules(rules, attrs) {
2448 for (var i = 0; i < rules.length; i += 1) {
2449 var rule = rules[i];
2450
2451 // recursive case
2452 if (Array.isArray(rule) && !isStaticRules(rule, attrs)) {
2453 return false;
2454 } else if (isFunction(rule) && !isStyledComponent(rule)) {
2455 // functions are allowed to be static if they're just being
2456 // used to get the classname of a nested styled component
2457 return false;
2458 }
2459 }
2460
2461 if (attrs.some(function (x) {
2462 return isFunction(x) || hasFunctionObjectKey(x);
2463 })) return false;
2464
2465 return true;
2466 }
2467
2468 //
2469
2470 var GlobalStyle = function () {
2471 function GlobalStyle(rules, componentId) {
2472 classCallCheck(this, GlobalStyle);
2473
2474 this.rules = rules;
2475 this.componentId = componentId;
2476 this.isStatic = isStaticRules(rules, EMPTY_ARRAY);
2477
2478 if (!StyleSheet.master.hasId(componentId)) {
2479 StyleSheet.master.deferredInject(componentId, []);
2480 }
2481 }
2482
2483 GlobalStyle.prototype.createStyles = function createStyles(executionContext, styleSheet) {
2484 var flatCSS = flatten(this.rules, executionContext, styleSheet);
2485 var css = stringifyRules(flatCSS, '');
2486
2487 styleSheet.inject(this.componentId, css);
2488 };
2489
2490 GlobalStyle.prototype.removeStyles = function removeStyles(styleSheet) {
2491 var componentId = this.componentId;
2492
2493 if (styleSheet.hasId(componentId)) {
2494 styleSheet.remove(componentId);
2495 }
2496 };
2497
2498 // TODO: overwrite in-place instead of remove+create?
2499
2500
2501 GlobalStyle.prototype.renderStyles = function renderStyles(executionContext, styleSheet) {
2502 this.removeStyles(styleSheet);
2503 this.createStyles(executionContext, styleSheet);
2504 };
2505
2506 return GlobalStyle;
2507 }();
2508
2509 var simpleIsEqual = function simpleIsEqual(a, b) {
2510 return a === b;
2511 };
2512
2513 function index (resultFn, isEqual) {
2514 if (isEqual === void 0) {
2515 isEqual = simpleIsEqual;
2516 }
2517
2518 var lastThis;
2519 var lastArgs = [];
2520 var lastResult;
2521 var calledOnce = false;
2522
2523 var isNewArgEqualToLast = function isNewArgEqualToLast(newArg, index) {
2524 return isEqual(newArg, lastArgs[index]);
2525 };
2526
2527 var result = function result() {
2528 for (var _len = arguments.length, newArgs = new Array(_len), _key = 0; _key < _len; _key++) {
2529 newArgs[_key] = arguments[_key];
2530 }
2531
2532 if (calledOnce && lastThis === this && newArgs.length === lastArgs.length && newArgs.every(isNewArgEqualToLast)) {
2533 return lastResult;
2534 }
2535
2536 lastResult = resultFn.apply(this, newArgs);
2537 calledOnce = true;
2538 lastThis = this;
2539 lastArgs = newArgs;
2540 return lastResult;
2541 };
2542
2543 return result;
2544 }
2545
2546 //
2547
2548 var ServerStyleSheet = function () {
2549 function ServerStyleSheet() {
2550 classCallCheck(this, ServerStyleSheet);
2551
2552 /* The master sheet might be reset, so keep a reference here */
2553 this.masterSheet = StyleSheet.master;
2554 this.instance = this.masterSheet.clone();
2555 this.sealed = false;
2556 }
2557
2558 /**
2559 * Mark the ServerStyleSheet as being fully emitted and manually GC it from the
2560 * StyleSheet singleton.
2561 */
2562
2563
2564 ServerStyleSheet.prototype.seal = function seal() {
2565 if (!this.sealed) {
2566 /* Remove sealed StyleSheets from the master sheet */
2567 var index = this.masterSheet.clones.indexOf(this.instance);
2568 this.masterSheet.clones.splice(index, 1);
2569 this.sealed = true;
2570 }
2571 };
2572
2573 ServerStyleSheet.prototype.collectStyles = function collectStyles(children) {
2574 if (this.sealed) {
2575 throw new StyledComponentsError(2);
2576 }
2577
2578 return React__default.createElement(
2579 StyleSheetManager,
2580 { sheet: this.instance },
2581 children
2582 );
2583 };
2584
2585 ServerStyleSheet.prototype.getStyleTags = function getStyleTags() {
2586 this.seal();
2587 return this.instance.toHTML();
2588 };
2589
2590 ServerStyleSheet.prototype.getStyleElement = function getStyleElement() {
2591 this.seal();
2592 return this.instance.toReactElements();
2593 };
2594
2595 ServerStyleSheet.prototype.interleaveWithNodeStream = function interleaveWithNodeStream(readableStream) {
2596 var _this = this;
2597
2598 {
2599 throw new StyledComponentsError(3);
2600 }
2601
2602 /* the tag index keeps track of which tags have already been emitted */
2603 var instance = this.instance;
2604
2605 var instanceTagIndex = 0;
2606
2607 var streamAttr = SC_STREAM_ATTR + '="true"';
2608
2609 var transformer = new stream.Transform({
2610 transform: function appendStyleChunks(chunk, /* encoding */_, callback) {
2611 var tags = instance.tags;
2612
2613 var html = '';
2614
2615 /* retrieve html for each new style tag */
2616 for (; instanceTagIndex < tags.length; instanceTagIndex += 1) {
2617 var tag = tags[instanceTagIndex];
2618 html += tag.toHTML(streamAttr);
2619 }
2620
2621 /* force our StyleSheets to emit entirely new tags */
2622 instance.sealAllTags();
2623
2624 /* prepend style html to chunk */
2625 this.push(html + chunk);
2626 callback();
2627 }
2628 });
2629
2630 readableStream.on('end', function () {
2631 return _this.seal();
2632 });
2633 readableStream.on('error', function (err) {
2634 _this.seal();
2635
2636 // forward the error to the transform stream
2637 transformer.emit('error', err);
2638 });
2639
2640 return readableStream.pipe(transformer);
2641 };
2642
2643 return ServerStyleSheet;
2644 }();
2645
2646 //
2647
2648 var StyleSheetContext = React.createContext();
2649
2650 var StyleSheetConsumer = StyleSheetContext.Consumer;
2651
2652 var StyleSheetManager = function (_Component) {
2653 inherits(StyleSheetManager, _Component);
2654
2655 function StyleSheetManager(props) {
2656 classCallCheck(this, StyleSheetManager);
2657
2658 var _this = possibleConstructorReturn(this, _Component.call(this, props));
2659
2660 _this.getContext = index(_this.getContext);
2661 return _this;
2662 }
2663
2664 StyleSheetManager.prototype.getContext = function getContext(sheet, target) {
2665 if (sheet) {
2666 return sheet;
2667 } else if (target) {
2668 return new StyleSheet(target);
2669 } else {
2670 throw new StyledComponentsError(4);
2671 }
2672 };
2673
2674 StyleSheetManager.prototype.render = function render() {
2675 var _props = this.props,
2676 children = _props.children,
2677 sheet = _props.sheet,
2678 target = _props.target;
2679
2680
2681 return React__default.createElement(
2682 StyleSheetContext.Provider,
2683 { value: this.getContext(sheet, target) },
2684 React__default.Children.only(children)
2685 );
2686 };
2687
2688 return StyleSheetManager;
2689 }(React.Component);
2690 StyleSheetManager.propTypes = {
2691 sheet: propTypes.oneOfType([propTypes.instanceOf(StyleSheet), propTypes.instanceOf(ServerStyleSheet)]),
2692
2693 target: propTypes.shape({
2694 appendChild: propTypes.func.isRequired
2695 })
2696 };
2697
2698 //
2699
2700 var determineTheme = (function (props, fallbackTheme) {
2701 var defaultProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : EMPTY_OBJECT;
2702
2703 // Props should take precedence over ThemeProvider, which should take precedence over
2704 // defaultProps, but React automatically puts defaultProps on props.
2705
2706 /* eslint-disable react/prop-types, flowtype-errors/show-errors */
2707 var isDefaultTheme = defaultProps ? props.theme === defaultProps.theme : false;
2708 var theme = props.theme && !isDefaultTheme ? props.theme : fallbackTheme || defaultProps.theme;
2709 /* eslint-enable */
2710
2711 return theme;
2712 });
2713
2714 //
2715
2716 var ThemeContext = React.createContext();
2717
2718 var ThemeConsumer = ThemeContext.Consumer;
2719
2720 /**
2721 * Provide a theme to an entire react component tree via context
2722 */
2723
2724 var ThemeProvider = function (_Component) {
2725 inherits(ThemeProvider, _Component);
2726
2727 function ThemeProvider(props) {
2728 classCallCheck(this, ThemeProvider);
2729
2730 var _this = possibleConstructorReturn(this, _Component.call(this, props));
2731
2732 _this.getContext = index(_this.getContext.bind(_this));
2733 _this.renderInner = _this.renderInner.bind(_this);
2734 return _this;
2735 }
2736
2737 ThemeProvider.prototype.render = function render() {
2738 if (!this.props.children) return null;
2739
2740 return React__default.createElement(
2741 ThemeContext.Consumer,
2742 null,
2743 this.renderInner
2744 );
2745 };
2746
2747 ThemeProvider.prototype.renderInner = function renderInner(outerTheme) {
2748 var context = this.getContext(this.props.theme, outerTheme);
2749
2750 return React__default.createElement(
2751 ThemeContext.Provider,
2752 { value: context },
2753 React__default.Children.only(this.props.children)
2754 );
2755 };
2756
2757 /**
2758 * Get the theme from the props, supporting both (outerTheme) => {}
2759 * as well as object notation
2760 */
2761
2762
2763 ThemeProvider.prototype.getTheme = function getTheme(theme, outerTheme) {
2764 if (isFunction(theme)) {
2765 var mergedTheme = theme(outerTheme);
2766
2767 if (mergedTheme === null || Array.isArray(mergedTheme) || (typeof mergedTheme === 'undefined' ? 'undefined' : _typeof(mergedTheme)) !== 'object') {
2768 throw new StyledComponentsError(7);
2769 }
2770
2771 return mergedTheme;
2772 }
2773
2774 if (theme === null || Array.isArray(theme) || (typeof theme === 'undefined' ? 'undefined' : _typeof(theme)) !== 'object') {
2775 throw new StyledComponentsError(8);
2776 }
2777
2778 return _extends({}, outerTheme, theme);
2779 };
2780
2781 ThemeProvider.prototype.getContext = function getContext(theme, outerTheme) {
2782 return this.getTheme(theme, outerTheme);
2783 };
2784
2785 return ThemeProvider;
2786 }(React.Component);
2787
2788 //
2789 // Source: https://github.com/garycourt/murmurhash-js/blob/master/murmurhash2_gc.js
2790 function murmurhash(c) {
2791 for (var e = c.length | 0, a = e | 0, d = 0, b; e >= 4;) {
2792 b = c.charCodeAt(d) & 255 | (c.charCodeAt(++d) & 255) << 8 | (c.charCodeAt(++d) & 255) << 16 | (c.charCodeAt(++d) & 255) << 24, b = 1540483477 * (b & 65535) + ((1540483477 * (b >>> 16) & 65535) << 16), b ^= b >>> 24, b = 1540483477 * (b & 65535) + ((1540483477 * (b >>> 16) & 65535) << 16), a = 1540483477 * (a & 65535) + ((1540483477 * (a >>> 16) & 65535) << 16) ^ b, e -= 4, ++d;
2793 }
2794 switch (e) {
2795 case 3:
2796 a ^= (c.charCodeAt(d + 2) & 255) << 16;
2797 case 2:
2798 a ^= (c.charCodeAt(d + 1) & 255) << 8;
2799 case 1:
2800 a ^= c.charCodeAt(d) & 255, a = 1540483477 * (a & 65535) + ((1540483477 * (a >>> 16) & 65535) << 16);
2801 }
2802 a ^= a >>> 13;
2803 a = 1540483477 * (a & 65535) + ((1540483477 * (a >>> 16) & 65535) << 16);
2804 return (a ^ a >>> 15) >>> 0;
2805 }
2806
2807 //
2808
2809 // place our cache into shared context so it'll persist between HMRs
2810 if (IS_BROWSER) {
2811 window.scCGSHMRCache = {};
2812 }
2813
2814 function createGlobalStyle(strings) {
2815 for (var _len = arguments.length, interpolations = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2816 interpolations[_key - 1] = arguments[_key];
2817 }
2818
2819 var rules = css.apply(undefined, [strings].concat(interpolations));
2820 var id = 'sc-global-' + murmurhash(JSON.stringify(rules));
2821 var style = new GlobalStyle(rules, id);
2822
2823 var GlobalStyleComponent = function (_React$Component) {
2824 inherits(GlobalStyleComponent, _React$Component);
2825
2826 function GlobalStyleComponent() {
2827 classCallCheck(this, GlobalStyleComponent);
2828
2829 var _this = possibleConstructorReturn(this, _React$Component.call(this));
2830
2831 var _this$constructor = _this.constructor,
2832 globalStyle = _this$constructor.globalStyle,
2833 styledComponentId = _this$constructor.styledComponentId;
2834
2835
2836 if (IS_BROWSER) {
2837 window.scCGSHMRCache[styledComponentId] = (window.scCGSHMRCache[styledComponentId] || 0) + 1;
2838 }
2839
2840 /**
2841 * This fixes HMR compatiblility. Don't ask me why, but this combination of
2842 * caching the closure variables via statics and then persisting the statics in
2843 * state works across HMR where no other combination did. ¯\_(ツ)_/¯
2844 */
2845 _this.state = {
2846 globalStyle: globalStyle,
2847 styledComponentId: styledComponentId
2848 };
2849 return _this;
2850 }
2851
2852 GlobalStyleComponent.prototype.componentDidMount = function componentDidMount() {
2853 if (IS_BROWSER && window.scCGSHMRCache[this.state.styledComponentId] > 1 && !this.props.suppressMultiMountWarning) {
2854 console.warn('The global style component ' + this.state.styledComponentId + ' was composed and rendered multiple times in your React component tree. Only the last-rendered copy will have its styles remain in <head> (or your StyleSheetManager target.)');
2855 }
2856 };
2857
2858 GlobalStyleComponent.prototype.componentWillUnmount = function componentWillUnmount() {
2859 if (window.scCGSHMRCache[this.state.styledComponentId]) {
2860 window.scCGSHMRCache[this.state.styledComponentId] -= 1;
2861 }
2862 /**
2863 * Depending on the order "render" is called this can cause the styles to be lost
2864 * until the next render pass of the remaining instance, which may
2865 * not be immediate.
2866 */
2867 if (window.scCGSHMRCache[this.state.styledComponentId] === 0) {
2868 this.state.globalStyle.removeStyles(this.styleSheet);
2869 }
2870 };
2871
2872 GlobalStyleComponent.prototype.render = function render() {
2873 var _this2 = this;
2874
2875 if (React__default.Children.count(this.props.children)) {
2876 console.warn('The global style component ' + this.state.styledComponentId + ' was given child JSX. createGlobalStyle does not render children.');
2877 }
2878
2879 return React__default.createElement(
2880 StyleSheetConsumer,
2881 null,
2882 function (styleSheet) {
2883 _this2.styleSheet = styleSheet || StyleSheet.master;
2884
2885 var globalStyle = _this2.state.globalStyle;
2886
2887
2888 if (globalStyle.isStatic) {
2889 globalStyle.renderStyles(STATIC_EXECUTION_CONTEXT, _this2.styleSheet);
2890
2891 return null;
2892 } else {
2893 return React__default.createElement(
2894 ThemeConsumer,
2895 null,
2896 function (theme) {
2897 var defaultProps = _this2.constructor.defaultProps;
2898
2899
2900 var context = _extends({}, _this2.props);
2901
2902 if (typeof theme !== 'undefined') {
2903 context.theme = determineTheme(_this2.props, theme, defaultProps);
2904 }
2905
2906 globalStyle.renderStyles(context, _this2.styleSheet);
2907
2908 return null;
2909 }
2910 );
2911 }
2912 }
2913 );
2914 };
2915
2916 return GlobalStyleComponent;
2917 }(React__default.Component);
2918
2919 GlobalStyleComponent.defaultProps = {
2920 suppressMultiMountWarning: false
2921 };
2922 GlobalStyleComponent.globalStyle = style;
2923 GlobalStyleComponent.styledComponentId = id;
2924 GlobalStyleComponent.propTypes = {
2925 suppressMultiMountWarning: propTypes.bool
2926 };
2927
2928
2929 return GlobalStyleComponent;
2930 }
2931
2932 //
2933 /* eslint-disable no-bitwise */
2934
2935 /* This is the "capacity" of our alphabet i.e. 2x26 for all letters plus their capitalised
2936 * counterparts */
2937 var charsLength = 52;
2938
2939 /* start at 75 for 'a' until 'z' (25) and then start at 65 for capitalised letters */
2940 var getAlphabeticChar = function getAlphabeticChar(code) {
2941 return String.fromCharCode(code + (code > 25 ? 39 : 97));
2942 };
2943
2944 /* input a number, usually a hash and convert it to base-52 */
2945 function generateAlphabeticName(code) {
2946 var name = '';
2947 var x = void 0;
2948
2949 /* get a char and divide by alphabet-length */
2950 for (x = code; x > charsLength; x = Math.floor(x / charsLength)) {
2951 name = getAlphabeticChar(x % charsLength) + name;
2952 }
2953
2954 return getAlphabeticChar(x % charsLength) + name;
2955 }
2956
2957 //
2958
2959 var replaceWhitespace = function replaceWhitespace(str) {
2960 return str.replace(/\s|\\n/g, '');
2961 };
2962
2963 function keyframes(strings) {
2964 /* Warning if you've used keyframes on React Native */
2965 if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
2966 console.warn('`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.');
2967 }
2968
2969 for (var _len = arguments.length, interpolations = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2970 interpolations[_key - 1] = arguments[_key];
2971 }
2972
2973 var rules = css.apply(undefined, [strings].concat(interpolations));
2974
2975 var name = generateAlphabeticName(murmurhash(replaceWhitespace(JSON.stringify(rules))));
2976
2977 return new Keyframes(name, stringifyRules(rules, name, '@keyframes'));
2978 }
2979
2980 var _TYPE_STATICS;
2981
2982 var REACT_STATICS = {
2983 childContextTypes: true,
2984 contextTypes: true,
2985 defaultProps: true,
2986 displayName: true,
2987 getDerivedStateFromProps: true,
2988 propTypes: true,
2989 type: true
2990 };
2991
2992 var KNOWN_STATICS = {
2993 name: true,
2994 length: true,
2995 prototype: true,
2996 caller: true,
2997 callee: true,
2998 arguments: true,
2999 arity: true
3000 };
3001
3002 var TYPE_STATICS = (_TYPE_STATICS = {}, _TYPE_STATICS[reactIs_3] = {
3003 $$typeof: true,
3004 render: true
3005 }, _TYPE_STATICS);
3006
3007 var defineProperty$1 = Object.defineProperty,
3008 getOwnPropertyNames = Object.getOwnPropertyNames,
3009 _Object$getOwnPropert = Object.getOwnPropertySymbols,
3010 getOwnPropertySymbols$1 = _Object$getOwnPropert === undefined ? function () {
3011 return [];
3012 } : _Object$getOwnPropert,
3013 getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor,
3014 getPrototypeOf = Object.getPrototypeOf,
3015 objectPrototype = Object.prototype;
3016 var arrayPrototype = Array.prototype;
3017
3018
3019 function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
3020 if (typeof sourceComponent !== 'string') {
3021 // don't hoist over string (html) components
3022
3023 var inheritedComponent = getPrototypeOf(sourceComponent);
3024
3025 if (inheritedComponent && inheritedComponent !== objectPrototype) {
3026 hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
3027 }
3028
3029 var keys = arrayPrototype.concat(getOwnPropertyNames(sourceComponent),
3030 // $FlowFixMe
3031 getOwnPropertySymbols$1(sourceComponent));
3032
3033 var targetStatics = TYPE_STATICS[targetComponent.$$typeof] || REACT_STATICS;
3034
3035 var sourceStatics = TYPE_STATICS[sourceComponent.$$typeof] || REACT_STATICS;
3036
3037 var i = keys.length;
3038 var descriptor = void 0;
3039 var key = void 0;
3040
3041 // eslint-disable-next-line no-plusplus
3042 while (i--) {
3043 key = keys[i];
3044
3045 if (
3046 // $FlowFixMe
3047 !KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) &&
3048 // $FlowFixMe
3049 !(targetStatics && targetStatics[key])) {
3050 descriptor = getOwnPropertyDescriptor(sourceComponent, key);
3051
3052 if (descriptor) {
3053 try {
3054 // Avoid failures from read-only properties
3055 defineProperty$1(targetComponent, key, descriptor);
3056 } catch (e) {
3057 /* fail silently */
3058 }
3059 }
3060 }
3061 }
3062
3063 return targetComponent;
3064 }
3065
3066 return targetComponent;
3067 }
3068
3069 //
3070
3071 var withTheme = (function (Component) {
3072 var WithTheme = React__default.forwardRef(function (props, ref) {
3073 return React__default.createElement(
3074 ThemeConsumer,
3075 null,
3076 function (theme) {
3077 // $FlowFixMe
3078 var defaultProps = Component.defaultProps;
3079
3080 var themeProp = determineTheme(props, theme, defaultProps);
3081
3082 if (themeProp === undefined) {
3083 // eslint-disable-next-line no-console
3084 console.warn('[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class "' + getComponentName(Component) + '"');
3085 }
3086
3087 return React__default.createElement(Component, _extends({}, props, { theme: themeProp, ref: ref }));
3088 }
3089 );
3090 });
3091
3092 hoistNonReactStatics(WithTheme, Component);
3093
3094 WithTheme.displayName = 'WithTheme(' + getComponentName(Component) + ')';
3095
3096 return WithTheme;
3097 });
3098
3099 //
3100
3101 /* eslint-disable */
3102 var __DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS = {
3103 StyleSheet: StyleSheet
3104 };
3105
3106 //
3107
3108 /* Warning if you've imported this file on React Native */
3109 if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
3110 // eslint-disable-next-line no-console
3111 console.warn("It looks like you've imported 'styled-components' on React Native.\n" + "Perhaps you're looking to import 'styled-components/native'?\n" + 'Read more about this at https://www.styled-components.com/docs/basics#react-native');
3112 }
3113
3114 /* Warning if there are several instances of styled-components */
3115 if (typeof window !== 'undefined' && typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Node.js') === -1 && navigator.userAgent.indexOf('jsdom') === -1) {
3116 window['__styled-components-init__'] = window['__styled-components-init__'] || 0;
3117
3118 if (window['__styled-components-init__'] === 1) {
3119 // eslint-disable-next-line no-console
3120 console.warn("It looks like there are several instances of 'styled-components' initialized in this application. " + 'This may cause dynamic styles not rendering properly, errors happening during rehydration process ' + 'and makes your application bigger without a good reason.\n\n' + 'See https://s-c.sh/2BAXzed for more info.');
3121 }
3122
3123 window['__styled-components-init__'] += 1;
3124 }
3125
3126 var secondary = /*#__PURE__*/Object.freeze({
3127 css: css,
3128 keyframes: keyframes,
3129 createGlobalStyle: createGlobalStyle,
3130 isStyledComponent: isStyledComponent,
3131 ThemeConsumer: ThemeConsumer,
3132 ThemeContext: ThemeContext,
3133 ThemeProvider: ThemeProvider,
3134 withTheme: withTheme,
3135 ServerStyleSheet: ServerStyleSheet,
3136 StyleSheetManager: StyleSheetManager,
3137 __DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS: __DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS
3138 });
3139
3140 //
3141
3142 function constructWithOptions(componentConstructor, tag) {
3143 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : EMPTY_OBJECT;
3144
3145 if (!reactIs_2(tag)) {
3146 throw new StyledComponentsError(1, String(tag));
3147 }
3148
3149 /* This is callable directly as a template function */
3150 // $FlowFixMe: Not typed to avoid destructuring arguments
3151 var templateFunction = function templateFunction() {
3152 return componentConstructor(tag, options, css.apply(undefined, arguments));
3153 };
3154
3155 /* If config methods are called, wrap up a new template function and merge options */
3156 templateFunction.withConfig = function (config) {
3157 return constructWithOptions(componentConstructor, tag, _extends({}, options, config));
3158 };
3159
3160 /* Modify/inject new props at runtime */
3161 templateFunction.attrs = function (attrs) {
3162 return constructWithOptions(componentConstructor, tag, _extends({}, options, {
3163 attrs: Array.prototype.concat(options.attrs, attrs).filter(Boolean)
3164 }));
3165 };
3166
3167 return templateFunction;
3168 }
3169
3170 function memoize(fn) {
3171 var cache = {};
3172 return function (arg) {
3173 if (cache[arg] === undefined) cache[arg] = fn(arg);
3174 return cache[arg];
3175 };
3176 }
3177
3178 var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|default|defer|dir|disabled|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|itemProp|itemScope|itemType|itemID|itemRef|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class)|(on[A-Z].*)|((data|aria|x)-.*))$/i;
3179 var index$1 = memoize(reactPropsRegex.test.bind(reactPropsRegex));
3180
3181 //
3182
3183 var isHMREnabled = typeof module !== 'undefined' && module.hot;
3184
3185 /* combines hashStr (murmurhash) and nameGenerator for convenience */
3186 var hasher = function hasher(str) {
3187 return generateAlphabeticName(murmurhash(str));
3188 };
3189
3190 /*
3191 ComponentStyle is all the CSS-specific stuff, not
3192 the React-specific stuff.
3193 */
3194
3195 var ComponentStyle = function () {
3196 function ComponentStyle(rules, attrs, componentId) {
3197 classCallCheck(this, ComponentStyle);
3198
3199 this.rules = rules;
3200 this.isStatic = !isHMREnabled && isStaticRules(rules, attrs);
3201 this.componentId = componentId;
3202
3203 if (!StyleSheet.master.hasId(componentId)) {
3204 StyleSheet.master.deferredInject(componentId, []);
3205 }
3206 }
3207
3208 /*
3209 * Flattens a rule set into valid CSS
3210 * Hashes it, wraps the whole chunk in a .hash1234 {}
3211 * Returns the hash to be injected on render()
3212 * */
3213
3214
3215 ComponentStyle.prototype.generateAndInjectStyles = function generateAndInjectStyles(executionContext, styleSheet) {
3216 var isStatic = this.isStatic,
3217 componentId = this.componentId,
3218 lastClassName = this.lastClassName;
3219
3220 if (IS_BROWSER && isStatic && typeof lastClassName === 'string' && styleSheet.hasNameForId(componentId, lastClassName)) {
3221 return lastClassName;
3222 }
3223
3224 var flatCSS = flatten(this.rules, executionContext, styleSheet);
3225 var name = hasher(this.componentId + flatCSS.join(''));
3226 if (!styleSheet.hasNameForId(componentId, name)) {
3227 styleSheet.inject(this.componentId, stringifyRules(flatCSS, '.' + name, undefined, componentId), name);
3228 }
3229
3230 this.lastClassName = name;
3231 return name;
3232 };
3233
3234 ComponentStyle.generateName = function generateName(str) {
3235 return hasher(str);
3236 };
3237
3238 return ComponentStyle;
3239 }();
3240
3241 //
3242
3243 var LIMIT = 200;
3244
3245 var createWarnTooManyClasses = (function (displayName) {
3246 var generatedClasses = {};
3247 var warningSeen = false;
3248
3249 return function (className) {
3250 if (!warningSeen) {
3251 generatedClasses[className] = true;
3252 if (Object.keys(generatedClasses).length >= LIMIT) {
3253 // Unable to find latestRule in test environment.
3254 /* eslint-disable no-console, prefer-template */
3255 console.warn('Over ' + LIMIT + ' classes were generated for component ' + displayName + '. \n' + 'Consider using the attrs method, together with a style object for frequently changed styles.\n' + 'Example:\n' + ' const Component = styled.div.attrs({\n' + ' style: ({ background }) => ({\n' + ' background,\n' + ' }),\n' + ' })`width: 100%;`\n\n' + ' <Component />');
3256 warningSeen = true;
3257 generatedClasses = {};
3258 }
3259 }
3260 };
3261 });
3262
3263 //
3264 var escapeRegex = /[[\].#*$><+~=|^:(),"'`-]+/g;
3265 var dashesAtEnds = /(^-|-$)/g;
3266
3267 /**
3268 * TODO: Explore using CSS.escape when it becomes more available
3269 * in evergreen browsers.
3270 */
3271 function escape(str) {
3272 return str
3273 // Replace all possible CSS selectors
3274 .replace(escapeRegex, '-')
3275
3276 // Remove extraneous hyphens at the start and end
3277 .replace(dashesAtEnds, '');
3278 }
3279
3280 //
3281
3282 function isTag(target) /* : %checks */{
3283 return typeof target === 'string';
3284 }
3285
3286 //
3287
3288 function generateDisplayName(target) {
3289 return isTag(target) ? 'styled.' + target : 'Styled(' + getComponentName(target) + ')';
3290 }
3291
3292 //
3293 function isDerivedReactComponent(fn) {
3294 return !!(fn && fn.prototype && fn.prototype.isReactComponent);
3295 }
3296
3297 //
3298 // Helper to call a given function, only once
3299 var once = (function (cb) {
3300 var called = false;
3301
3302 return function () {
3303 if (!called) {
3304 called = true;
3305 cb.apply(undefined, arguments);
3306 }
3307 };
3308 });
3309
3310 //
3311
3312 var didWarnAboutClassNameUsage = new Set();
3313
3314 var classNameUsageCheckInjector = (function (target) {
3315 var elementClassName = '';
3316
3317 var targetCDM = target.componentDidMount;
3318
3319 // eslint-disable-next-line no-param-reassign
3320 target.componentDidMount = function componentDidMount() {
3321 if (typeof targetCDM === 'function') {
3322 targetCDM.call(this);
3323 }
3324
3325 var forwardTarget = this.props.forwardedClass.target;
3326
3327 if (target.props && target.props.suppressClassNameWarning || target.attrs && target.attrs.suppressClassNameWarning || didWarnAboutClassNameUsage.has(forwardTarget)) {
3328 return;
3329 }
3330
3331 didWarnAboutClassNameUsage.add(forwardTarget);
3332
3333 var classNames = elementClassName.replace(/ +/g, ' ').trim().split(' ');
3334 // eslint-disable-next-line react/no-find-dom-node
3335 var node = ReactDOM.findDOMNode(this);
3336 var selector = classNames.map(function (s) {
3337 return '.' + s;
3338 }).join('');
3339
3340 if (node && node.nodeType === 1 && !classNames.every(function (className) {
3341 return node.classList && node.classList.contains(className);
3342 }) && !node.querySelector(selector)) {
3343 console.warn('It looks like you\'ve wrapped styled() around your React component (' + getComponentName(forwardTarget) + '), but the className prop is not being passed down to a child. No styles will be rendered unless className is composed within your React component.');
3344 }
3345 };
3346
3347 var prevRenderInner = target.renderInner;
3348
3349 // eslint-disable-next-line no-param-reassign
3350 target.renderInner = function renderInner() {
3351 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
3352 args[_key] = arguments[_key];
3353 }
3354
3355 var element = prevRenderInner.apply(this, args);
3356
3357 elementClassName = element.props.className;
3358
3359 return element;
3360 };
3361 });
3362
3363 //
3364
3365 var identifiers = {};
3366
3367 /* We depend on components having unique IDs */
3368 function generateId(_ComponentStyle, _displayName, parentComponentId) {
3369 var displayName = typeof _displayName !== 'string' ? 'sc' : escape(_displayName);
3370
3371 /**
3372 * This ensures uniqueness if two components happen to share
3373 * the same displayName.
3374 */
3375 var nr = (identifiers[displayName] || 0) + 1;
3376 identifiers[displayName] = nr;
3377
3378 var componentId = displayName + '-' + _ComponentStyle.generateName(displayName + nr);
3379
3380 return parentComponentId ? parentComponentId + '-' + componentId : componentId;
3381 }
3382
3383 var warnInnerRef = once(function () {
3384 return (
3385 // eslint-disable-next-line no-console
3386 console.warn('The "innerRef" API has been removed in styled-components v4 in favor of React 16 ref forwarding, use "ref" instead like a typical component.')
3387 );
3388 });
3389
3390 var warnAttrsFnObjectKeyDeprecated = once(function (key, displayName) {
3391 return (
3392 // eslint-disable-next-line no-console
3393 console.warn('Functions as object-form attrs({}) keys are now deprecated and will be removed in a future version of styled-components. Switch to the new attrs(props => ({})) syntax instead for easier and more powerful composition. The attrs key in question is "' + key + '" on component "' + displayName + '".')
3394 );
3395 });
3396
3397 var warnNonStyledComponentAttrsObjectKey = once(function (key, displayName) {
3398 return (
3399 // eslint-disable-next-line no-console
3400 console.warn('It looks like you\'ve used a non styled-component as the value for the "' + key + '" prop in an object-form attrs constructor of "' + displayName + '".\n' + 'You should use the new function-form attrs constructor which avoids this issue: attrs(props => ({ yourStuff }))\n' + "To continue using the deprecated object syntax, you'll need to wrap your component prop in a function to make it available inside the styled component (you'll still get the deprecation warning though.)\n" + ('For example, { ' + key + ': () => InnerComponent } instead of { ' + key + ': InnerComponent }'))
3401 );
3402 });
3403
3404 // $FlowFixMe
3405
3406 var StyledComponent = function (_Component) {
3407 inherits(StyledComponent, _Component);
3408
3409 function StyledComponent() {
3410 classCallCheck(this, StyledComponent);
3411
3412 var _this = possibleConstructorReturn(this, _Component.call(this));
3413
3414 _this.attrs = {};
3415
3416 _this.renderOuter = _this.renderOuter.bind(_this);
3417 _this.renderInner = _this.renderInner.bind(_this);
3418
3419 if (IS_BROWSER) {
3420 classNameUsageCheckInjector(_this);
3421 }
3422 return _this;
3423 }
3424
3425 StyledComponent.prototype.render = function render() {
3426 return React__default.createElement(
3427 StyleSheetConsumer,
3428 null,
3429 this.renderOuter
3430 );
3431 };
3432
3433 StyledComponent.prototype.renderOuter = function renderOuter(styleSheet) {
3434 this.styleSheet = styleSheet;
3435 var componentStyle = this.props.forwardedClass.componentStyle;
3436
3437 // No need to subscribe a static component to theme changes, it won't change anything
3438
3439 if (componentStyle.isStatic) return this.renderInner();
3440
3441 return React__default.createElement(
3442 ThemeConsumer,
3443 null,
3444 this.renderInner
3445 );
3446 };
3447
3448 StyledComponent.prototype.renderInner = function renderInner(theme) {
3449 var _props$forwardedClass = this.props.forwardedClass,
3450 componentStyle = _props$forwardedClass.componentStyle,
3451 defaultProps = _props$forwardedClass.defaultProps,
3452 styledComponentId = _props$forwardedClass.styledComponentId,
3453 target = _props$forwardedClass.target;
3454
3455
3456 var generatedClassName = void 0;
3457 if (componentStyle.isStatic) {
3458 generatedClassName = this.generateAndInjectStyles(EMPTY_OBJECT, this.props, this.styleSheet);
3459 } else if (theme !== undefined) {
3460 generatedClassName = this.generateAndInjectStyles(determineTheme(this.props, theme, defaultProps), this.props, this.styleSheet);
3461 } else {
3462 generatedClassName = this.generateAndInjectStyles(this.props.theme || EMPTY_OBJECT, this.props, this.styleSheet);
3463 }
3464 var elementToBeCreated = this.props.as || this.attrs.as || target;
3465 var isTargetTag = isTag(elementToBeCreated);
3466
3467 var propsForElement = {};
3468 var computedProps = _extends({}, this.attrs, this.props);
3469
3470 var key = void 0;
3471 // eslint-disable-next-line guard-for-in
3472 for (key in computedProps) {
3473 if (key === 'innerRef') {
3474 warnInnerRef();
3475 }
3476
3477 if (key === 'forwardedClass' || key === 'as') continue;else if (key === 'forwardedRef') propsForElement.ref = computedProps[key];else if (!isTargetTag || index$1(key)) {
3478 // Don't pass through non HTML tags through to HTML elements
3479 propsForElement[key] = computedProps[key];
3480 }
3481 }
3482
3483 if (this.props.style && this.attrs.style) {
3484 propsForElement.style = _extends({}, this.attrs.style, this.props.style);
3485 }
3486
3487 propsForElement.className = [this.props.className, styledComponentId, this.attrs.className, generatedClassName].filter(Boolean).join(' ');
3488
3489 return React.createElement(elementToBeCreated, propsForElement);
3490 };
3491
3492 StyledComponent.prototype.buildExecutionContext = function buildExecutionContext(theme, props, attrs) {
3493 var _this2 = this;
3494
3495 var context = _extends({}, props, { theme: theme });
3496
3497 if (!attrs.length) return context;
3498
3499 this.attrs = {};
3500
3501 attrs.forEach(function (attrDef) {
3502 var resolvedAttrDef = attrDef;
3503 var attrDefWasFn = false;
3504 var attr = void 0;
3505 var key = void 0;
3506
3507 if (isFunction(resolvedAttrDef)) {
3508 // $FlowFixMe
3509 resolvedAttrDef = resolvedAttrDef(props);
3510 attrDefWasFn = true;
3511 }
3512
3513 /* eslint-disable guard-for-in */
3514 // $FlowFixMe
3515 for (key in resolvedAttrDef) {
3516 attr = resolvedAttrDef[key];
3517
3518 if (!attrDefWasFn) {
3519 if (isFunction(attr) && !isDerivedReactComponent(attr) && !isStyledComponent(attr)) {
3520 if (warnAttrsFnObjectKeyDeprecated) {
3521 warnAttrsFnObjectKeyDeprecated(key, props.forwardedClass.displayName);
3522 }
3523
3524 attr = attr(context);
3525
3526 if (React__default.isValidElement(attr) && warnNonStyledComponentAttrsObjectKey) {
3527 warnNonStyledComponentAttrsObjectKey(key, props.forwardedClass.displayName);
3528 }
3529 }
3530 }
3531
3532 _this2.attrs[key] = attr;
3533 context[key] = attr;
3534 }
3535 /* eslint-enable */
3536 });
3537
3538 return context;
3539 };
3540
3541 StyledComponent.prototype.generateAndInjectStyles = function generateAndInjectStyles(theme, props) {
3542 var styleSheet = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : StyleSheet.master;
3543 var _props$forwardedClass2 = props.forwardedClass,
3544 attrs = _props$forwardedClass2.attrs,
3545 componentStyle = _props$forwardedClass2.componentStyle,
3546 warnTooManyClasses = _props$forwardedClass2.warnTooManyClasses;
3547
3548 // statically styled-components don't need to build an execution context object,
3549 // and shouldn't be increasing the number of class names
3550
3551 if (componentStyle.isStatic && !attrs.length) {
3552 return componentStyle.generateAndInjectStyles(EMPTY_OBJECT, styleSheet);
3553 }
3554
3555 var className = componentStyle.generateAndInjectStyles(this.buildExecutionContext(theme, props, attrs), styleSheet);
3556
3557 if (warnTooManyClasses) warnTooManyClasses(className);
3558
3559 return className;
3560 };
3561
3562 return StyledComponent;
3563 }(React.Component);
3564
3565 function createStyledComponent(target, options, rules) {
3566 var isTargetStyledComp = isStyledComponent(target);
3567 var isClass = !isTag(target);
3568
3569 var _options$displayName = options.displayName,
3570 displayName = _options$displayName === undefined ? generateDisplayName(target) : _options$displayName,
3571 _options$componentId = options.componentId,
3572 componentId = _options$componentId === undefined ? generateId(ComponentStyle, options.displayName, options.parentComponentId) : _options$componentId,
3573 _options$ParentCompon = options.ParentComponent,
3574 ParentComponent = _options$ParentCompon === undefined ? StyledComponent : _options$ParentCompon,
3575 _options$attrs = options.attrs,
3576 attrs = _options$attrs === undefined ? EMPTY_ARRAY : _options$attrs;
3577
3578
3579 var styledComponentId = options.displayName && options.componentId ? escape(options.displayName) + '-' + options.componentId : options.componentId || componentId;
3580
3581 // fold the underlying StyledComponent attrs up (implicit extend)
3582 var finalAttrs =
3583 // $FlowFixMe
3584 isTargetStyledComp && target.attrs ? Array.prototype.concat(target.attrs, attrs).filter(Boolean) : attrs;
3585
3586 var componentStyle = new ComponentStyle(isTargetStyledComp ? // fold the underlying StyledComponent rules up (implicit extend)
3587 // $FlowFixMe
3588 target.componentStyle.rules.concat(rules) : rules, finalAttrs, styledComponentId);
3589
3590 /**
3591 * forwardRef creates a new interim component, which we'll take advantage of
3592 * instead of extending ParentComponent to create _another_ interim class
3593 */
3594 var WrappedStyledComponent = React__default.forwardRef(function (props, ref) {
3595 return React__default.createElement(ParentComponent, _extends({}, props, { forwardedClass: WrappedStyledComponent, forwardedRef: ref }));
3596 });
3597
3598 // $FlowFixMe
3599 WrappedStyledComponent.attrs = finalAttrs;
3600 // $FlowFixMe
3601 WrappedStyledComponent.componentStyle = componentStyle;
3602 WrappedStyledComponent.displayName = displayName;
3603 // $FlowFixMe
3604 WrappedStyledComponent.styledComponentId = styledComponentId;
3605
3606 // fold the underlying StyledComponent target up since we folded the styles
3607 // $FlowFixMe
3608 WrappedStyledComponent.target = isTargetStyledComp ? target.target : target;
3609
3610 // $FlowFixMe
3611 WrappedStyledComponent.withComponent = function withComponent(tag) {
3612 var previousComponentId = options.componentId,
3613 optionsToCopy = objectWithoutProperties(options, ['componentId']);
3614
3615
3616 var newComponentId = previousComponentId && previousComponentId + '-' + (isTag(tag) ? tag : escape(getComponentName(tag)));
3617
3618 var newOptions = _extends({}, optionsToCopy, {
3619 attrs: finalAttrs,
3620 componentId: newComponentId,
3621 ParentComponent: ParentComponent
3622 });
3623
3624 return createStyledComponent(tag, newOptions, rules);
3625 };
3626
3627 {
3628 // $FlowFixMe
3629 WrappedStyledComponent.warnTooManyClasses = createWarnTooManyClasses(displayName);
3630 }
3631
3632 // $FlowFixMe
3633 WrappedStyledComponent.toString = function () {
3634 return '.' + WrappedStyledComponent.styledComponentId;
3635 };
3636
3637 if (isClass) {
3638 hoistNonReactStatics(WrappedStyledComponent, target, {
3639 // all SC-specific things should not be hoisted
3640 attrs: true,
3641 componentStyle: true,
3642 displayName: true,
3643 styledComponentId: true,
3644 target: true,
3645 withComponent: true
3646 });
3647 }
3648
3649 return WrappedStyledComponent;
3650 }
3651
3652 //
3653 // Thanks to ReactDOMFactories for this handy list!
3654
3655 var domElements = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr',
3656
3657 // SVG
3658 'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
3659
3660 //
3661
3662 var styled = function styled(tag) {
3663 return constructWithOptions(createStyledComponent, tag);
3664 };
3665
3666 // Shorthands for all valid HTML Elements
3667 domElements.forEach(function (domElement) {
3668 styled[domElement] = styled(domElement);
3669 });
3670
3671 //
3672
3673 /**
3674 * eliminates the need to do styled.default since the other APIs
3675 * are directly assigned as properties to the main function
3676 * */
3677 // eslint-disable-next-line guard-for-in
3678 for (var key in secondary) {
3679 styled[key] = secondary[key];
3680 }
3681
3682 return styled;
3683
3684})));
3685//# sourceMappingURL=styled-components.js.map