UNPKG

97.5 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) :
3 typeof define === 'function' && define.amd ? define(['react'], factory) :
4 (global = global || self, global.styled = factory(global.React));
5})(this, (function (React) { 'use strict';
6
7 var SC_ATTR = (typeof process !== 'undefined' &&
8 typeof process.env !== 'undefined' &&
9 (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
10 'data-styled';
11 var SC_ATTR_ACTIVE = 'active';
12 var SC_ATTR_VERSION = 'data-styled-version';
13 var SC_VERSION = "6.1.11";
14 var SPLITTER = '/*!sc*/\n';
15 var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
16 var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
17 ? SC_DISABLE_SPEEDY
18 : typeof process !== 'undefined' &&
19 typeof process.env !== 'undefined' &&
20 typeof process.env.REACT_APP_SC_DISABLE_SPEEDY !== 'undefined' &&
21 process.env.REACT_APP_SC_DISABLE_SPEEDY !== ''
22 ? process.env.REACT_APP_SC_DISABLE_SPEEDY === 'false'
23 ? false
24 : process.env.REACT_APP_SC_DISABLE_SPEEDY
25 : typeof process !== 'undefined' &&
26 typeof process.env !== 'undefined' &&
27 typeof process.env.SC_DISABLE_SPEEDY !== 'undefined' &&
28 process.env.SC_DISABLE_SPEEDY !== ''
29 ? process.env.SC_DISABLE_SPEEDY === 'false'
30 ? false
31 : process.env.SC_DISABLE_SPEEDY
32 : "development" !== 'production');
33 // Shared empty execution context when generating static styles
34 var STATIC_EXECUTION_CONTEXT = {};
35
36 /******************************************************************************
37 Copyright (c) Microsoft Corporation.
38
39 Permission to use, copy, modify, and/or distribute this software for any
40 purpose with or without fee is hereby granted.
41
42 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
43 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
44 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
45 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
46 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
47 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
48 PERFORMANCE OF THIS SOFTWARE.
49 ***************************************************************************** */
50 /* global Reflect, Promise, SuppressedError, Symbol */
51
52
53 var __assign = function() {
54 __assign = Object.assign || function __assign(t) {
55 for (var s, i = 1, n = arguments.length; i < n; i++) {
56 s = arguments[i];
57 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
58 }
59 return t;
60 };
61 return __assign.apply(this, arguments);
62 };
63
64 function __spreadArray(to, from, pack) {
65 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
66 if (ar || !(i in from)) {
67 if (!ar) ar = Array.prototype.slice.call(from, 0, i);
68 ar[i] = from[i];
69 }
70 }
71 return to.concat(ar || Array.prototype.slice.call(from));
72 }
73
74 typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
75 var e = new Error(message);
76 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
77 };
78
79 var EMPTY_ARRAY = Object.freeze([]);
80 var EMPTY_OBJECT = Object.freeze({});
81
82 /**
83 * If the Object prototype is frozen, the "toString" property is non-writable. This means that any objects which inherit this property
84 * cannot have the property changed using a "=" assignment operator. If using strict mode, attempting that will cause an error. If not using
85 * strict mode, attempting that will be silently ignored.
86 *
87 * If the Object prototype is frozen, inherited non-writable properties can still be shadowed using one of two mechanisms:
88 *
89 * 1. ES6 class methods: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#methods
90 * 2. Using the `Object.defineProperty()` static method:
91 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty
92 *
93 * However, this project uses Babel to transpile ES6 classes, and transforms ES6 class methods to use the assignment operator instead:
94 * https://babeljs.io/docs/babel-plugin-transform-class-properties#options
95 *
96 * Therefore, the most compatible way to shadow the prototype's "toString" property is to define a new "toString" property on this object.
97 */
98 function setToString(object, toStringFn) {
99 Object.defineProperty(object, 'toString', { value: toStringFn });
100 }
101
102 var errorMap = {
103 '1': 'Cannot create styled-component for component: %s.\n\n',
104 '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",
105 '3': 'Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n',
106 '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',
107 '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',
108 '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",
109 '7': 'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n',
110 '8': 'ThemeProvider: Please make your "theme" prop an object.\n\n',
111 '9': 'Missing document `<head>`\n\n',
112 '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',
113 '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',
114 '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 which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n',
115 '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\n',
116 '14': 'ThemeProvider: "theme" prop is required.\n\n',
117 '15': "A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to `<StyleSheetManager stylisPlugins={[]}>`, please make sure each plugin is uniquely-named, e.g.\n\n```js\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\n```\n\n",
118 '16': "Reached the limit of how many styled components may be created at group %s.\nYou may only create up to 1,073,741,824 components. If you're creating components dynamically,\nas for instance in your render method then you may be running into this limitation.\n\n",
119 '17': "CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n",
120 '18': 'ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`',
121 };
122
123 var ERRORS = errorMap ;
124 /**
125 * super basic version of sprintf
126 */
127 function format() {
128 var args = [];
129 for (var _i = 0; _i < arguments.length; _i++) {
130 args[_i] = arguments[_i];
131 }
132 var a = args[0];
133 var b = [];
134 for (var c = 1, len = args.length; c < len; c += 1) {
135 b.push(args[c]);
136 }
137 b.forEach(function (d) {
138 a = a.replace(/%[a-z]/, d);
139 });
140 return a;
141 }
142 /**
143 * Create an error file out of errors.md for development and a simple web link to the full errors
144 * in production mode.
145 */
146 function throwStyledComponentsError(code) {
147 var interpolations = [];
148 for (var _i = 1; _i < arguments.length; _i++) {
149 interpolations[_i - 1] = arguments[_i];
150 }
151 {
152 return new Error(format.apply(void 0, __spreadArray([ERRORS[code]], interpolations, false)).trim());
153 }
154 }
155
156 /** Create a GroupedTag with an underlying Tag implementation */
157 var makeGroupedTag = function (tag) {
158 return new DefaultGroupedTag(tag);
159 };
160 var BASE_SIZE = 1 << 9;
161 var DefaultGroupedTag = /** @class */ (function () {
162 function DefaultGroupedTag(tag) {
163 this.groupSizes = new Uint32Array(BASE_SIZE);
164 this.length = BASE_SIZE;
165 this.tag = tag;
166 }
167 DefaultGroupedTag.prototype.indexOfGroup = function (group) {
168 var index = 0;
169 for (var i = 0; i < group; i++) {
170 index += this.groupSizes[i];
171 }
172 return index;
173 };
174 DefaultGroupedTag.prototype.insertRules = function (group, rules) {
175 if (group >= this.groupSizes.length) {
176 var oldBuffer = this.groupSizes;
177 var oldSize = oldBuffer.length;
178 var newSize = oldSize;
179 while (group >= newSize) {
180 newSize <<= 1;
181 if (newSize < 0) {
182 throw throwStyledComponentsError(16, "".concat(group));
183 }
184 }
185 this.groupSizes = new Uint32Array(newSize);
186 this.groupSizes.set(oldBuffer);
187 this.length = newSize;
188 for (var i = oldSize; i < newSize; i++) {
189 this.groupSizes[i] = 0;
190 }
191 }
192 var ruleIndex = this.indexOfGroup(group + 1);
193 for (var i = 0, l = rules.length; i < l; i++) {
194 if (this.tag.insertRule(ruleIndex, rules[i])) {
195 this.groupSizes[group]++;
196 ruleIndex++;
197 }
198 }
199 };
200 DefaultGroupedTag.prototype.clearGroup = function (group) {
201 if (group < this.length) {
202 var length_1 = this.groupSizes[group];
203 var startIndex = this.indexOfGroup(group);
204 var endIndex = startIndex + length_1;
205 this.groupSizes[group] = 0;
206 for (var i = startIndex; i < endIndex; i++) {
207 this.tag.deleteRule(startIndex);
208 }
209 }
210 };
211 DefaultGroupedTag.prototype.getGroup = function (group) {
212 var css = '';
213 if (group >= this.length || this.groupSizes[group] === 0) {
214 return css;
215 }
216 var length = this.groupSizes[group];
217 var startIndex = this.indexOfGroup(group);
218 var endIndex = startIndex + length;
219 for (var i = startIndex; i < endIndex; i++) {
220 css += "".concat(this.tag.getRule(i)).concat(SPLITTER);
221 }
222 return css;
223 };
224 return DefaultGroupedTag;
225 }());
226
227 var MAX_SMI = 1 << (31 - 1);
228 var groupIDRegister = new Map();
229 var reverseRegister = new Map();
230 var nextFreeGroup = 1;
231 var getGroupForId = function (id) {
232 if (groupIDRegister.has(id)) {
233 return groupIDRegister.get(id);
234 }
235 while (reverseRegister.has(nextFreeGroup)) {
236 nextFreeGroup++;
237 }
238 var group = nextFreeGroup++;
239 if (((group | 0) < 0 || group > MAX_SMI)) {
240 throw throwStyledComponentsError(16, "".concat(group));
241 }
242 groupIDRegister.set(id, group);
243 reverseRegister.set(group, id);
244 return group;
245 };
246 var getIdForGroup = function (group) {
247 return reverseRegister.get(group);
248 };
249 var setGroupForId = function (id, group) {
250 // move pointer
251 nextFreeGroup = group + 1;
252 groupIDRegister.set(id, group);
253 reverseRegister.set(group, id);
254 };
255
256 var SELECTOR = "style[".concat(SC_ATTR, "][").concat(SC_ATTR_VERSION, "=\"").concat(SC_VERSION, "\"]");
257 var MARKER_RE = new RegExp("^".concat(SC_ATTR, "\\.g(\\d+)\\[id=\"([\\w\\d-]+)\"\\].*?\"([^\"]*)"));
258 var outputSheet = function (sheet) {
259 var tag = sheet.getTag();
260 var length = tag.length;
261 var css = '';
262 var _loop_1 = function (group) {
263 var id = getIdForGroup(group);
264 if (id === undefined)
265 return "continue";
266 var names = sheet.names.get(id);
267 var rules = tag.getGroup(group);
268 if (names === undefined || rules.length === 0)
269 return "continue";
270 var selector = "".concat(SC_ATTR, ".g").concat(group, "[id=\"").concat(id, "\"]");
271 var content = '';
272 if (names !== undefined) {
273 names.forEach(function (name) {
274 if (name.length > 0) {
275 content += "".concat(name, ",");
276 }
277 });
278 }
279 // NOTE: It's easier to collect rules and have the marker
280 // after the actual rules to simplify the rehydration
281 css += "".concat(rules).concat(selector, "{content:\"").concat(content, "\"}").concat(SPLITTER);
282 };
283 for (var group = 0; group < length; group++) {
284 _loop_1(group);
285 }
286 return css;
287 };
288 var rehydrateNamesFromContent = function (sheet, id, content) {
289 var names = content.split(',');
290 var name;
291 for (var i = 0, l = names.length; i < l; i++) {
292 if ((name = names[i])) {
293 sheet.registerName(id, name);
294 }
295 }
296 };
297 var rehydrateSheetFromTag = function (sheet, style) {
298 var _a;
299 var parts = ((_a = style.textContent) !== null && _a !== void 0 ? _a : '').split(SPLITTER);
300 var rules = [];
301 for (var i = 0, l = parts.length; i < l; i++) {
302 var part = parts[i].trim();
303 if (!part)
304 continue;
305 var marker = part.match(MARKER_RE);
306 if (marker) {
307 var group = parseInt(marker[1], 10) | 0;
308 var id = marker[2];
309 if (group !== 0) {
310 // Rehydrate componentId to group index mapping
311 setGroupForId(id, group);
312 // Rehydrate names and rules
313 // looks like: data-styled.g11[id="idA"]{content:"nameA,"}
314 rehydrateNamesFromContent(sheet, id, marker[3]);
315 sheet.getTag().insertRules(group, rules);
316 }
317 rules.length = 0;
318 }
319 else {
320 rules.push(part);
321 }
322 }
323 };
324 var rehydrateSheet = function (sheet) {
325 var nodes = document.querySelectorAll(SELECTOR);
326 for (var i = 0, l = nodes.length; i < l; i++) {
327 var node = nodes[i];
328 if (node && node.getAttribute(SC_ATTR) !== SC_ATTR_ACTIVE) {
329 rehydrateSheetFromTag(sheet, node);
330 if (node.parentNode) {
331 node.parentNode.removeChild(node);
332 }
333 }
334 }
335 };
336
337 function getNonce() {
338 return typeof __webpack_nonce__ !== 'undefined' ? __webpack_nonce__ : null;
339 }
340
341 /** Find last style element if any inside target */
342 var findLastStyleTag = function (target) {
343 var arr = Array.from(target.querySelectorAll("style[".concat(SC_ATTR, "]")));
344 return arr[arr.length - 1];
345 };
346 /** Create a style element inside `target` or <head> after the last */
347 var makeStyleTag = function (target) {
348 var head = document.head;
349 var parent = target || head;
350 var style = document.createElement('style');
351 var prevStyle = findLastStyleTag(parent);
352 var nextSibling = prevStyle !== undefined ? prevStyle.nextSibling : null;
353 style.setAttribute(SC_ATTR, SC_ATTR_ACTIVE);
354 style.setAttribute(SC_ATTR_VERSION, SC_VERSION);
355 var nonce = getNonce();
356 if (nonce)
357 style.setAttribute('nonce', nonce);
358 parent.insertBefore(style, nextSibling);
359 return style;
360 };
361 /** Get the CSSStyleSheet instance for a given style element */
362 var getSheet = function (tag) {
363 if (tag.sheet) {
364 return tag.sheet;
365 }
366 // Avoid Firefox quirk where the style element might not have a sheet property
367 var styleSheets = document.styleSheets;
368 for (var i = 0, l = styleSheets.length; i < l; i++) {
369 var sheet = styleSheets[i];
370 if (sheet.ownerNode === tag) {
371 return sheet;
372 }
373 }
374 throw throwStyledComponentsError(17);
375 };
376
377 /** Create a CSSStyleSheet-like tag depending on the environment */
378 var makeTag = function (_a) {
379 var isServer = _a.isServer, useCSSOMInjection = _a.useCSSOMInjection, target = _a.target;
380 if (isServer) {
381 return new VirtualTag(target);
382 }
383 else if (useCSSOMInjection) {
384 return new CSSOMTag(target);
385 }
386 else {
387 return new TextTag(target);
388 }
389 };
390 var CSSOMTag = /** @class */ (function () {
391 function CSSOMTag(target) {
392 this.element = makeStyleTag(target);
393 // Avoid Edge bug where empty style elements don't create sheets
394 this.element.appendChild(document.createTextNode(''));
395 this.sheet = getSheet(this.element);
396 this.length = 0;
397 }
398 CSSOMTag.prototype.insertRule = function (index, rule) {
399 try {
400 this.sheet.insertRule(rule, index);
401 this.length++;
402 return true;
403 }
404 catch (_error) {
405 return false;
406 }
407 };
408 CSSOMTag.prototype.deleteRule = function (index) {
409 this.sheet.deleteRule(index);
410 this.length--;
411 };
412 CSSOMTag.prototype.getRule = function (index) {
413 var rule = this.sheet.cssRules[index];
414 // Avoid IE11 quirk where cssText is inaccessible on some invalid rules
415 if (rule && rule.cssText) {
416 return rule.cssText;
417 }
418 else {
419 return '';
420 }
421 };
422 return CSSOMTag;
423 }());
424 /** A Tag that emulates the CSSStyleSheet API but uses text nodes */
425 var TextTag = /** @class */ (function () {
426 function TextTag(target) {
427 this.element = makeStyleTag(target);
428 this.nodes = this.element.childNodes;
429 this.length = 0;
430 }
431 TextTag.prototype.insertRule = function (index, rule) {
432 if (index <= this.length && index >= 0) {
433 var node = document.createTextNode(rule);
434 var refNode = this.nodes[index];
435 this.element.insertBefore(node, refNode || null);
436 this.length++;
437 return true;
438 }
439 else {
440 return false;
441 }
442 };
443 TextTag.prototype.deleteRule = function (index) {
444 this.element.removeChild(this.nodes[index]);
445 this.length--;
446 };
447 TextTag.prototype.getRule = function (index) {
448 if (index < this.length) {
449 return this.nodes[index].textContent;
450 }
451 else {
452 return '';
453 }
454 };
455 return TextTag;
456 }());
457 /** A completely virtual (server-side) Tag that doesn't manipulate the DOM */
458 var VirtualTag = /** @class */ (function () {
459 function VirtualTag(_target) {
460 this.rules = [];
461 this.length = 0;
462 }
463 VirtualTag.prototype.insertRule = function (index, rule) {
464 if (index <= this.length) {
465 this.rules.splice(index, 0, rule);
466 this.length++;
467 return true;
468 }
469 else {
470 return false;
471 }
472 };
473 VirtualTag.prototype.deleteRule = function (index) {
474 this.rules.splice(index, 1);
475 this.length--;
476 };
477 VirtualTag.prototype.getRule = function (index) {
478 if (index < this.length) {
479 return this.rules[index];
480 }
481 else {
482 return '';
483 }
484 };
485 return VirtualTag;
486 }());
487
488 var SHOULD_REHYDRATE = IS_BROWSER;
489 var defaultOptions = {
490 isServer: !IS_BROWSER,
491 useCSSOMInjection: !DISABLE_SPEEDY,
492 };
493 /** Contains the main stylesheet logic for stringification and caching */
494 var StyleSheet = /** @class */ (function () {
495 function StyleSheet(options, globalStyles, names) {
496 if (options === void 0) { options = EMPTY_OBJECT; }
497 if (globalStyles === void 0) { globalStyles = {}; }
498 var _this = this;
499 this.options = __assign(__assign({}, defaultOptions), options);
500 this.gs = globalStyles;
501 this.names = new Map(names);
502 this.server = !!options.isServer;
503 // We rehydrate only once and use the sheet that is created first
504 if (!this.server && IS_BROWSER && SHOULD_REHYDRATE) {
505 SHOULD_REHYDRATE = false;
506 rehydrateSheet(this);
507 }
508 setToString(this, function () { return outputSheet(_this); });
509 }
510 /** Register a group ID to give it an index */
511 StyleSheet.registerId = function (id) {
512 return getGroupForId(id);
513 };
514 StyleSheet.prototype.reconstructWithOptions = function (options, withNames) {
515 if (withNames === void 0) { withNames = true; }
516 return new StyleSheet(__assign(__assign({}, this.options), options), this.gs, (withNames && this.names) || undefined);
517 };
518 StyleSheet.prototype.allocateGSInstance = function (id) {
519 return (this.gs[id] = (this.gs[id] || 0) + 1);
520 };
521 /** Lazily initialises a GroupedTag for when it's actually needed */
522 StyleSheet.prototype.getTag = function () {
523 return this.tag || (this.tag = makeGroupedTag(makeTag(this.options)));
524 };
525 /** Check whether a name is known for caching */
526 StyleSheet.prototype.hasNameForId = function (id, name) {
527 return this.names.has(id) && this.names.get(id).has(name);
528 };
529 /** Mark a group's name as known for caching */
530 StyleSheet.prototype.registerName = function (id, name) {
531 getGroupForId(id);
532 if (!this.names.has(id)) {
533 var groupNames = new Set();
534 groupNames.add(name);
535 this.names.set(id, groupNames);
536 }
537 else {
538 this.names.get(id).add(name);
539 }
540 };
541 /** Insert new rules which also marks the name as known */
542 StyleSheet.prototype.insertRules = function (id, name, rules) {
543 this.registerName(id, name);
544 this.getTag().insertRules(getGroupForId(id), rules);
545 };
546 /** Clears all cached names for a given group ID */
547 StyleSheet.prototype.clearNames = function (id) {
548 if (this.names.has(id)) {
549 this.names.get(id).clear();
550 }
551 };
552 /** Clears all rules for a given group ID */
553 StyleSheet.prototype.clearRules = function (id) {
554 this.getTag().clearGroup(getGroupForId(id));
555 this.clearNames(id);
556 };
557 /** Clears the entire tag which deletes all rules but not its names */
558 StyleSheet.prototype.clearTag = function () {
559 // NOTE: This does not clear the names, since it's only used during SSR
560 // so that we can continuously output only new rules
561 this.tag = undefined;
562 };
563 return StyleSheet;
564 }());
565
566 //
567
568 var shallowequal = function shallowEqual(objA, objB, compare, compareContext) {
569 var ret = compare ? compare.call(compareContext, objA, objB) : void 0;
570
571 if (ret !== void 0) {
572 return !!ret;
573 }
574
575 if (objA === objB) {
576 return true;
577 }
578
579 if (typeof objA !== "object" || !objA || typeof objB !== "object" || !objB) {
580 return false;
581 }
582
583 var keysA = Object.keys(objA);
584 var keysB = Object.keys(objB);
585
586 if (keysA.length !== keysB.length) {
587 return false;
588 }
589
590 var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
591
592 // Test for A's keys different from B.
593 for (var idx = 0; idx < keysA.length; idx++) {
594 var key = keysA[idx];
595
596 if (!bHasOwnProperty(key)) {
597 return false;
598 }
599
600 var valueA = objA[key];
601 var valueB = objB[key];
602
603 ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
604
605 if (ret === false || (ret === void 0 && valueA !== valueB)) {
606 return false;
607 }
608 }
609
610 return true;
611 };
612
613 var e="-ms-";var r="-moz-";var a="-webkit-";var n="comm";var c="rule";var s="decl";var i="@import";var h="@keyframes";var g="@layer";var $=Math.abs;var m=String.fromCharCode;var x=Object.assign;function y(e,r){return A(e,0)^45?(((r<<2^A(e,0))<<2^A(e,1))<<2^A(e,2))<<2^A(e,3):0}function j(e){return e.trim()}function z(e,r){return (e=r.exec(e))?e[0]:e}function C(e,r,a){return e.replace(r,a)}function O(e,r,a){return e.indexOf(r,a)}function A(e,r){return e.charCodeAt(r)|0}function M(e,r,a){return e.slice(r,a)}function S(e){return e.length}function q(e){return e.length}function B(e,r){return r.push(e),e}function D(e,r){return e.map(r).join("")}function E(e,r){return e.filter((function(e){return !z(e,r)}))}var F=1;var G=1;var H=0;var I=0;var J=0;var K="";function L(e,r,a,n,c,s,t,u){return {value:e,root:r,parent:a,type:n,props:c,children:s,line:F,column:G,length:t,return:"",siblings:u}}function N(e,r){return x(L("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},r)}function P(e){while(e.root)e=N(e.root,{children:[e]});B(e,e.siblings);}function Q(){return J}function R(){J=I>0?A(K,--I):0;if(G--,J===10)G=1,F--;return J}function T(){J=I<H?A(K,I++):0;if(G++,J===10)G=1,F++;return J}function U(){return A(K,I)}function V(){return I}function W(e,r){return M(K,e,r)}function X(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Y(e){return F=G=1,H=S(K=e),I=0,[]}function Z(e){return K="",e}function _(e){return j(W(I-1,ce(e===91?e+2:e===40?e+1:e)))}function re(e){while(J=U())if(J<33)T();else break;return X(e)>2||X(J)>3?"":" "}function ne(e,r){while(--r&&T())if(J<48||J>102||J>57&&J<65||J>70&&J<97)break;return W(e,V()+(r<6&&U()==32&&T()==32))}function ce(e){while(T())switch(J){case e:return I;case 34:case 39:if(e!==34&&e!==39)ce(J);break;case 40:if(e===41)ce(e);break;case 92:T();break}return I}function se(e,r){while(T())if(e+J===47+10)break;else if(e+J===42+42&&U()===47)break;return "/*"+W(r,I-1)+"*"+m(e===47?e:T())}function te(e){while(!X(U()))T();return W(e,I)}function ue(e){return Z(ie("",null,null,null,[""],e=Y(e),0,[0],e))}function ie(e,r,a,n,c,s,t,u,i){var f=0;var o=0;var l=t;var v=0;var p=0;var h=0;var b=1;var w=1;var d=1;var g=0;var k="";var x=c;var y=s;var j=n;var z=k;while(w)switch(h=g,g=T()){case 40:if(h!=108&&A(z,l-1)==58){if(O(z+=C(_(g),"&","&\f"),"&\f",$(f?u[f-1]:0))!=-1)d=-1;break}case 34:case 39:case 91:z+=_(g);break;case 9:case 10:case 13:case 32:z+=re(h);break;case 92:z+=ne(V()-1,7);continue;case 47:switch(U()){case 42:case 47:B(oe(se(T(),V()),r,a,i),i);break;default:z+="/";}break;case 123*b:u[f++]=S(z)*d;case 125*b:case 59:case 0:switch(g){case 0:case 125:w=0;case 59+o:if(d==-1)z=C(z,/\f/g,"");if(p>0&&S(z)-l)B(p>32?le(z+";",n,a,l-1,i):le(C(z," ","")+";",n,a,l-2,i),i);break;case 59:z+=";";default:B(j=fe(z,r,a,f,o,c,u,k,x=[],y=[],l,s),s);if(g===123)if(o===0)ie(z,r,j,j,x,s,l,u,y);else switch(v===99&&A(z,3)===110?100:v){case 100:case 108:case 109:case 115:ie(e,j,j,n&&B(fe(e,j,j,0,0,c,u,k,c,x=[],l,y),y),c,y,l,u,n?x:y);break;default:ie(z,j,j,j,[""],y,0,u,y);}}f=o=p=0,b=d=1,k=z="",l=t;break;case 58:l=1+S(z),p=h;default:if(b<1)if(g==123)--b;else if(g==125&&b++==0&&R()==125)continue;switch(z+=m(g),g*b){case 38:d=o>0?1:(z+="\f",-1);break;case 44:u[f++]=(S(z)-1)*d,d=1;break;case 64:if(U()===45)z+=_(T());v=U(),o=l=S(k=z+=te(V())),g++;break;case 45:if(h===45&&S(z)==2)b=0;}}return s}function fe(e,r,a,n,s,t,u,i,f,o,l,v){var p=s-1;var h=s===0?t:[""];var b=q(h);for(var w=0,d=0,g=0;w<n;++w)for(var k=0,m=M(e,p+1,p=$(d=u[w])),x=e;k<b;++k)if(x=j(d>0?h[k]+" "+m:C(m,/&\f/g,h[k])))f[g++]=x;return L(e,r,a,s===0?c:i,f,o,l,v)}function oe(e,r,a,c){return L(e,r,a,n,m(Q()),M(e,2,-2),0,c)}function le(e,r,a,n,c){return L(e,r,a,s,M(e,0,n),M(e,n+1,-1),n,c)}function ve(n,c,s){switch(y(n,c)){case 5103:return a+"print-"+n+n;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return a+n+n;case 4789:return r+n+n;case 5349:case 4246:case 4810:case 6968:case 2756:return a+n+r+n+e+n+n;case 5936:switch(A(n,c+11)){case 114:return a+n+e+C(n,/[svh]\w+-[tblr]{2}/,"tb")+n;case 108:return a+n+e+C(n,/[svh]\w+-[tblr]{2}/,"tb-rl")+n;case 45:return a+n+e+C(n,/[svh]\w+-[tblr]{2}/,"lr")+n}case 6828:case 4268:case 2903:return a+n+e+n+n;case 6165:return a+n+e+"flex-"+n+n;case 5187:return a+n+C(n,/(\w+).+(:[^]+)/,a+"box-$1$2"+e+"flex-$1$2")+n;case 5443:return a+n+e+"flex-item-"+C(n,/flex-|-self/g,"")+(!z(n,/flex-|baseline/)?e+"grid-row-"+C(n,/flex-|-self/g,""):"")+n;case 4675:return a+n+e+"flex-line-pack"+C(n,/align-content|flex-|-self/g,"")+n;case 5548:return a+n+e+C(n,"shrink","negative")+n;case 5292:return a+n+e+C(n,"basis","preferred-size")+n;case 6060:return a+"box-"+C(n,"-grow","")+a+n+e+C(n,"grow","positive")+n;case 4554:return a+C(n,/([^-])(transform)/g,"$1"+a+"$2")+n;case 6187:return C(C(C(n,/(zoom-|grab)/,a+"$1"),/(image-set)/,a+"$1"),n,"")+n;case 5495:case 3959:return C(n,/(image-set\([^]*)/,a+"$1"+"$`$1");case 4968:return C(C(n,/(.+:)(flex-)?(.*)/,a+"box-pack:$3"+e+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+a+n+n;case 4200:if(!z(n,/flex-|baseline/))return e+"grid-column-align"+M(n,c)+n;break;case 2592:case 3360:return e+C(n,"template-","")+n;case 4384:case 3616:if(s&&s.some((function(e,r){return c=r,z(e.props,/grid-\w+-end/)}))){return ~O(n+(s=s[c].value),"span",0)?n:e+C(n,"-start","")+n+e+"grid-row-span:"+(~O(s,"span",0)?z(s,/\d+/):+z(s,/\d+/)-+z(n,/\d+/))+";"}return e+C(n,"-start","")+n;case 4896:case 4128:return s&&s.some((function(e){return z(e.props,/grid-\w+-start/)}))?n:e+C(C(n,"-end","-span"),"span ","")+n;case 4095:case 3583:case 4068:case 2532:return C(n,/(.+)-inline(.+)/,a+"$1$2")+n;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(S(n)-1-c>6)switch(A(n,c+1)){case 109:if(A(n,c+4)!==45)break;case 102:return C(n,/(.+:)(.+)-([^]+)/,"$1"+a+"$2-$3"+"$1"+r+(A(n,c+3)==108?"$3":"$2-$3"))+n;case 115:return ~O(n,"stretch",0)?ve(C(n,"stretch","fill-available"),c,s)+n:n}break;case 5152:case 5920:return C(n,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,(function(r,a,c,s,t,u,i){return e+a+":"+c+i+(s?e+a+"-span:"+(t?u:+u-+c)+i:"")+n}));case 4949:if(A(n,c+6)===121)return C(n,":",":"+a)+n;break;case 6444:switch(A(n,A(n,14)===45?18:11)){case 120:return C(n,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+a+(A(n,14)===45?"inline-":"")+"box$3"+"$1"+a+"$2$3"+"$1"+e+"$2box$3")+n;case 100:return C(n,":",":"+e)+n}break;case 5719:case 2647:case 2135:case 3927:case 2391:return C(n,"scroll-","scroll-snap-")+n}return n}function pe(e,r){var a="";for(var n=0;n<e.length;n++)a+=r(e[n],n,e,r)||"";return a}function he(e,r,a,t){switch(e.type){case g:if(e.children.length)break;case i:case s:return e.return=e.return||e.value;case n:return "";case h:return e.return=e.value+"{"+pe(e.children,t)+"}";case c:if(!S(e.value=e.props.join(",")))return ""}return S(a=pe(e.children,t))?e.return=e.value+"{"+a+"}":""}function be(e){var r=q(e);return function(a,n,c,s){var t="";for(var u=0;u<r;u++)t+=e[u](a,n,c,s)||"";return t}}function we(e){return function(r){if(!r.root)if(r=r.return)e(r);}}function de(n,t,u,i){if(n.length>-1)if(!n.return)switch(n.type){case s:n.return=ve(n.value,n.length,u);return;case h:return pe([N(n,{value:C(n.value,"@","@"+a)})],i);case c:if(n.length)return D(u=n.props,(function(c){switch(z(c,i=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":P(N(n,{props:[C(c,/:(read-\w+)/,":"+r+"$1")]}));P(N(n,{props:[c]}));x(n,{props:E(u,i)});break;case"::placeholder":P(N(n,{props:[C(c,/:(plac\w+)/,":"+a+"input-$1")]}));P(N(n,{props:[C(c,/:(plac\w+)/,":"+r+"$1")]}));P(N(n,{props:[C(c,/:(plac\w+)/,e+"input-$1")]}));P(N(n,{props:[c]}));x(n,{props:E(u,i)});break}return ""}))}}
614
615 var SEED$1 = 5381;
616 // When we have separate strings it's useful to run a progressive
617 // version of djb2 where we pretend that we're still looping over
618 // the same string
619 var phash = function (h, x) {
620 var i = x.length;
621 while (i) {
622 h = (h * 33) ^ x.charCodeAt(--i);
623 }
624 return h;
625 };
626 // This is a djb2 hashing function
627 var hash = function (x) {
628 return phash(SEED$1, x);
629 };
630
631 var AMP_REGEX = /&/g;
632 var COMMENT_REGEX = /^\s*\/\/.*$/gm;
633 /**
634 * Takes an element and recurses through it's rules added the namespace to the start of each selector.
635 * Takes into account media queries by recursing through child rules if they are present.
636 */
637 function recursivelySetNamepace(compiled, namespace) {
638 return compiled.map(function (rule) {
639 if (rule.type === 'rule') {
640 // add the namespace to the start
641 rule.value = "".concat(namespace, " ").concat(rule.value);
642 // add the namespace after each comma for subsequent selectors.
643 rule.value = rule.value.replaceAll(',', ",".concat(namespace, " "));
644 rule.props = rule.props.map(function (prop) {
645 return "".concat(namespace, " ").concat(prop);
646 });
647 }
648 if (Array.isArray(rule.children) && rule.type !== '@keyframes') {
649 rule.children = recursivelySetNamepace(rule.children, namespace);
650 }
651 return rule;
652 });
653 }
654 function createStylisInstance(_a) {
655 var _b = _a === void 0 ? EMPTY_OBJECT : _a, _c = _b.options, options = _c === void 0 ? EMPTY_OBJECT : _c, _d = _b.plugins, plugins = _d === void 0 ? EMPTY_ARRAY : _d;
656 var _componentId;
657 var _selector;
658 var _selectorRegexp;
659 var selfReferenceReplacer = function (match, offset, string) {
660 if (
661 /**
662 * We only want to refer to the static class directly if the selector is part of a
663 * self-reference selector `& + & { color: red; }`
664 */
665 string.startsWith(_selector) &&
666 string.endsWith(_selector) &&
667 string.replaceAll(_selector, '').length > 0) {
668 return ".".concat(_componentId);
669 }
670 return match;
671 };
672 /**
673 * When writing a style like
674 *
675 * & + & {
676 * color: red;
677 * }
678 *
679 * The second ampersand should be a reference to the static component class. stylis
680 * has no knowledge of static class so we have to intelligently replace the base selector.
681 *
682 * https://github.com/thysultan/stylis.js/tree/v4.0.2#abstract-syntax-structure
683 */
684 var selfReferenceReplacementPlugin = function (element) {
685 if (element.type === c && element.value.includes('&')) {
686 element.props[0] = element.props[0]
687 // catch any hanging references that stylis missed
688 .replace(AMP_REGEX, _selector)
689 .replace(_selectorRegexp, selfReferenceReplacer);
690 }
691 };
692 var middlewares = plugins.slice();
693 middlewares.push(selfReferenceReplacementPlugin);
694 /**
695 * Enables automatic vendor-prefixing for styles.
696 */
697 if (options.prefix) {
698 middlewares.push(de);
699 }
700 middlewares.push(he);
701 var stringifyRules = function (css, selector,
702 /**
703 * This "prefix" referes to a _selector_ prefix.
704 */
705 prefix, componentId) {
706 if (selector === void 0) { selector = ''; }
707 if (prefix === void 0) { prefix = ''; }
708 if (componentId === void 0) { componentId = '&'; }
709 // stylis has no concept of state to be passed to plugins
710 // but since JS is single-threaded, we can rely on that to ensure
711 // these properties stay in sync with the current stylis run
712 _componentId = componentId;
713 _selector = selector;
714 _selectorRegexp = new RegExp("\\".concat(_selector, "\\b"), 'g');
715 var flatCSS = css.replace(COMMENT_REGEX, '');
716 var compiled = ue(prefix || selector ? "".concat(prefix, " ").concat(selector, " { ").concat(flatCSS, " }") : flatCSS);
717 if (options.namespace) {
718 compiled = recursivelySetNamepace(compiled, options.namespace);
719 }
720 var stack = [];
721 pe(compiled, be(middlewares.concat(we(function (value) { return stack.push(value); }))));
722 return stack;
723 };
724 stringifyRules.hash = plugins.length
725 ? plugins
726 .reduce(function (acc, plugin) {
727 if (!plugin.name) {
728 throwStyledComponentsError(15);
729 }
730 return phash(acc, plugin.name);
731 }, SEED$1)
732 .toString()
733 : '';
734 return stringifyRules;
735 }
736
737 var mainSheet = new StyleSheet();
738 var mainStylis = createStylisInstance();
739 var StyleSheetContext = React.createContext({
740 shouldForwardProp: undefined,
741 styleSheet: mainSheet,
742 stylis: mainStylis,
743 });
744 var StyleSheetConsumer = StyleSheetContext.Consumer;
745 var StylisContext = React.createContext(undefined);
746 function useStyleSheetContext() {
747 return React.useContext(StyleSheetContext);
748 }
749 function StyleSheetManager(props) {
750 var _a = React.useState(props.stylisPlugins), plugins = _a[0], setPlugins = _a[1];
751 var styleSheet = useStyleSheetContext().styleSheet;
752 var resolvedStyleSheet = React.useMemo(function () {
753 var sheet = styleSheet;
754 if (props.sheet) {
755 sheet = props.sheet;
756 }
757 else if (props.target) {
758 sheet = sheet.reconstructWithOptions({ target: props.target }, false);
759 }
760 if (props.disableCSSOMInjection) {
761 sheet = sheet.reconstructWithOptions({ useCSSOMInjection: false });
762 }
763 return sheet;
764 }, [props.disableCSSOMInjection, props.sheet, props.target, styleSheet]);
765 var stylis = React.useMemo(function () {
766 return createStylisInstance({
767 options: { namespace: props.namespace, prefix: props.enableVendorPrefixes },
768 plugins: plugins,
769 });
770 }, [props.enableVendorPrefixes, props.namespace, plugins]);
771 React.useEffect(function () {
772 if (!shallowequal(plugins, props.stylisPlugins))
773 setPlugins(props.stylisPlugins);
774 }, [props.stylisPlugins]);
775 var styleSheetContextValue = React.useMemo(function () { return ({
776 shouldForwardProp: props.shouldForwardProp,
777 styleSheet: resolvedStyleSheet,
778 stylis: stylis,
779 }); }, [props.shouldForwardProp, resolvedStyleSheet, stylis]);
780 return (React.createElement(StyleSheetContext.Provider, { value: styleSheetContextValue },
781 React.createElement(StylisContext.Provider, { value: stylis }, props.children)));
782 }
783
784 var Keyframes = /** @class */ (function () {
785 function Keyframes(name, rules) {
786 var _this = this;
787 this.inject = function (styleSheet, stylisInstance) {
788 if (stylisInstance === void 0) { stylisInstance = mainStylis; }
789 var resolvedName = _this.name + stylisInstance.hash;
790 if (!styleSheet.hasNameForId(_this.id, resolvedName)) {
791 styleSheet.insertRules(_this.id, resolvedName, stylisInstance(_this.rules, resolvedName, '@keyframes'));
792 }
793 };
794 this.name = name;
795 this.id = "sc-keyframes-".concat(name);
796 this.rules = rules;
797 setToString(this, function () {
798 throw throwStyledComponentsError(12, String(_this.name));
799 });
800 }
801 Keyframes.prototype.getName = function (stylisInstance) {
802 if (stylisInstance === void 0) { stylisInstance = mainStylis; }
803 return this.name + stylisInstance.hash;
804 };
805 return Keyframes;
806 }());
807
808 var unitlessKeys = {
809 animationIterationCount: 1,
810 aspectRatio: 1,
811 borderImageOutset: 1,
812 borderImageSlice: 1,
813 borderImageWidth: 1,
814 boxFlex: 1,
815 boxFlexGroup: 1,
816 boxOrdinalGroup: 1,
817 columnCount: 1,
818 columns: 1,
819 flex: 1,
820 flexGrow: 1,
821 flexPositive: 1,
822 flexShrink: 1,
823 flexNegative: 1,
824 flexOrder: 1,
825 gridRow: 1,
826 gridRowEnd: 1,
827 gridRowSpan: 1,
828 gridRowStart: 1,
829 gridColumn: 1,
830 gridColumnEnd: 1,
831 gridColumnSpan: 1,
832 gridColumnStart: 1,
833 msGridRow: 1,
834 msGridRowSpan: 1,
835 msGridColumn: 1,
836 msGridColumnSpan: 1,
837 fontWeight: 1,
838 lineHeight: 1,
839 opacity: 1,
840 order: 1,
841 orphans: 1,
842 tabSize: 1,
843 widows: 1,
844 zIndex: 1,
845 zoom: 1,
846 WebkitLineClamp: 1,
847 // SVG-related properties
848 fillOpacity: 1,
849 floodOpacity: 1,
850 stopOpacity: 1,
851 strokeDasharray: 1,
852 strokeDashoffset: 1,
853 strokeMiterlimit: 1,
854 strokeOpacity: 1,
855 strokeWidth: 1
856 };
857
858 // Taken from https://github.com/facebook/react/blob/b87aabdfe1b7461e7331abb3601d9e6bb27544bc/packages/react-dom/src/shared/dangerousStyleValue.js
859 function addUnitIfNeeded(name, value) {
860 // https://github.com/amilajack/eslint-plugin-flowtype-errors/issues/133
861 if (value == null || typeof value === 'boolean' || value === '') {
862 return '';
863 }
864 if (typeof value === 'number' && value !== 0 && !(name in unitlessKeys) && !name.startsWith('--')) {
865 return "".concat(value, "px"); // Presumes implicit 'px' suffix for unitless numbers except for CSS variables
866 }
867 return String(value).trim();
868 }
869
870 function getComponentName(target) {
871 return ((typeof target === 'string' && target ) ||
872 target.displayName ||
873 target.name ||
874 'Component');
875 }
876
877 var isUpper = function (c) { return c >= 'A' && c <= 'Z'; };
878 /**
879 * Hyphenates a camelcased CSS property name, for example:
880 *
881 * > hyphenateStyleName('backgroundColor')
882 * < "background-color"
883 * > hyphenateStyleName('MozTransition')
884 * < "-moz-transition"
885 * > hyphenateStyleName('msTransition')
886 * < "-ms-transition"
887 *
888 * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
889 * is converted to `-ms-`.
890 */
891 function hyphenateStyleName(string) {
892 var output = '';
893 for (var i = 0; i < string.length; i++) {
894 var c = string[i];
895 // Check for CSS variable prefix
896 if (i === 1 && c === '-' && string[0] === '-') {
897 return string;
898 }
899 if (isUpper(c)) {
900 output += '-' + c.toLowerCase();
901 }
902 else {
903 output += c;
904 }
905 }
906 return output.startsWith('ms-') ? '-' + output : output;
907 }
908
909 function isFunction(test) {
910 return typeof test === 'function';
911 }
912
913 function isPlainObject(x) {
914 return (x !== null &&
915 typeof x === 'object' &&
916 x.constructor.name === Object.name &&
917 /* check for reasonable markers that the object isn't an element for react & preact/compat */
918 !('props' in x && x.$$typeof));
919 }
920
921 function isStatelessFunction(test) {
922 return isFunction(test) && !(test.prototype && test.prototype.isReactComponent);
923 }
924
925 function isStyledComponent(target) {
926 return typeof target === 'object' && 'styledComponentId' in target;
927 }
928
929 /**
930 * It's falsish not falsy because 0 is allowed.
931 */
932 var isFalsish = function (chunk) {
933 return chunk === undefined || chunk === null || chunk === false || chunk === '';
934 };
935 var objToCssArray = function (obj) {
936 var rules = [];
937 for (var key in obj) {
938 var val = obj[key];
939 if (!obj.hasOwnProperty(key) || isFalsish(val))
940 continue;
941 // @ts-expect-error Property 'isCss' does not exist on type 'any[]'
942 if ((Array.isArray(val) && val.isCss) || isFunction(val)) {
943 rules.push("".concat(hyphenateStyleName(key), ":"), val, ';');
944 }
945 else if (isPlainObject(val)) {
946 rules.push.apply(rules, __spreadArray(__spreadArray(["".concat(key, " {")], objToCssArray(val), false), ['}'], false));
947 }
948 else {
949 rules.push("".concat(hyphenateStyleName(key), ": ").concat(addUnitIfNeeded(key, val), ";"));
950 }
951 }
952 return rules;
953 };
954 function flatten(chunk, executionContext, styleSheet, stylisInstance) {
955 if (isFalsish(chunk)) {
956 return [];
957 }
958 /* Handle other components */
959 if (isStyledComponent(chunk)) {
960 return [".".concat(chunk.styledComponentId)];
961 }
962 /* Either execute or defer the function */
963 if (isFunction(chunk)) {
964 if (isStatelessFunction(chunk) && executionContext) {
965 var result = chunk(executionContext);
966 if (typeof result === 'object' &&
967 !Array.isArray(result) &&
968 !(result instanceof Keyframes) &&
969 !isPlainObject(result) &&
970 result !== null) {
971 console.error("".concat(getComponentName(chunk), " 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."));
972 }
973 return flatten(result, executionContext, styleSheet, stylisInstance);
974 }
975 else {
976 return [chunk];
977 }
978 }
979 if (chunk instanceof Keyframes) {
980 if (styleSheet) {
981 chunk.inject(styleSheet, stylisInstance);
982 return [chunk.getName(stylisInstance)];
983 }
984 else {
985 return [chunk];
986 }
987 }
988 /* Handle objects */
989 if (isPlainObject(chunk)) {
990 return objToCssArray(chunk);
991 }
992 if (!Array.isArray(chunk)) {
993 return [chunk.toString()];
994 }
995 return flatMap(chunk, function (chunklet) {
996 return flatten(chunklet, executionContext, styleSheet, stylisInstance);
997 });
998 }
999 function flatMap(array, transform) {
1000 return Array.prototype.concat.apply(EMPTY_ARRAY, array.map(transform));
1001 }
1002
1003 function isStaticRules(rules) {
1004 for (var i = 0; i < rules.length; i += 1) {
1005 var rule = rules[i];
1006 if (isFunction(rule) && !isStyledComponent(rule)) {
1007 // functions are allowed to be static if they're just being
1008 // used to get the classname of a nested styled component
1009 return false;
1010 }
1011 }
1012 return true;
1013 }
1014
1015 /**
1016 * Convenience function for joining strings to form className chains
1017 */
1018 function joinStrings(a, b) {
1019 return a && b ? "".concat(a, " ").concat(b) : a || b || '';
1020 }
1021 function joinStringArray(arr, sep) {
1022 if (arr.length === 0) {
1023 return '';
1024 }
1025 var result = arr[0];
1026 for (var i = 1; i < arr.length; i++) {
1027 result += sep ? sep + arr[i] : arr[i];
1028 }
1029 return result;
1030 }
1031
1032 var GlobalStyle = /** @class */ (function () {
1033 function GlobalStyle(rules, componentId) {
1034 this.rules = rules;
1035 this.componentId = componentId;
1036 this.isStatic = isStaticRules(rules);
1037 // pre-register the first instance to ensure global styles
1038 // load before component ones
1039 StyleSheet.registerId(this.componentId + 1);
1040 }
1041 GlobalStyle.prototype.createStyles = function (instance, executionContext, styleSheet, stylis) {
1042 var flatCSS = joinStringArray(flatten(this.rules, executionContext, styleSheet, stylis));
1043 var css = stylis(flatCSS, '');
1044 var id = this.componentId + instance;
1045 // NOTE: We use the id as a name as well, since these rules never change
1046 styleSheet.insertRules(id, id, css);
1047 };
1048 GlobalStyle.prototype.removeStyles = function (instance, styleSheet) {
1049 styleSheet.clearRules(this.componentId + instance);
1050 };
1051 GlobalStyle.prototype.renderStyles = function (instance, executionContext, styleSheet, stylis) {
1052 if (instance > 2)
1053 StyleSheet.registerId(this.componentId + instance);
1054 // NOTE: Remove old styles, then inject the new ones
1055 this.removeStyles(instance, styleSheet);
1056 this.createStyles(instance, executionContext, styleSheet, stylis);
1057 };
1058 return GlobalStyle;
1059 }());
1060
1061 var ThemeContext = React.createContext(undefined);
1062 var ThemeConsumer = ThemeContext.Consumer;
1063 function mergeTheme(theme, outerTheme) {
1064 if (!theme) {
1065 throw throwStyledComponentsError(14);
1066 }
1067 if (isFunction(theme)) {
1068 var themeFn = theme;
1069 var mergedTheme = themeFn(outerTheme);
1070 if ((mergedTheme === null || Array.isArray(mergedTheme) || typeof mergedTheme !== 'object')) {
1071 throw throwStyledComponentsError(7);
1072 }
1073 return mergedTheme;
1074 }
1075 if (Array.isArray(theme) || typeof theme !== 'object') {
1076 throw throwStyledComponentsError(8);
1077 }
1078 return outerTheme ? __assign(__assign({}, outerTheme), theme) : theme;
1079 }
1080 /**
1081 * Returns the current theme (as provided by the closest ancestor `ThemeProvider`.)
1082 *
1083 * If no `ThemeProvider` is found, the function will error. If you need access to the theme in an
1084 * uncertain composition scenario, `React.useContext(ThemeContext)` will not emit an error if there
1085 * is no `ThemeProvider` ancestor.
1086 */
1087 function useTheme() {
1088 var theme = React.useContext(ThemeContext);
1089 if (!theme) {
1090 throw throwStyledComponentsError(18);
1091 }
1092 return theme;
1093 }
1094 /**
1095 * Provide a theme to an entire react component tree via context
1096 */
1097 function ThemeProvider(props) {
1098 var outerTheme = React.useContext(ThemeContext);
1099 var themeContext = React.useMemo(function () { return mergeTheme(props.theme, outerTheme); }, [props.theme, outerTheme]);
1100 if (!props.children) {
1101 return null;
1102 }
1103 return React.createElement(ThemeContext.Provider, { value: themeContext }, props.children);
1104 }
1105
1106 var invalidHookCallRe = /invalid hook call/i;
1107 var seen = new Set();
1108 var checkDynamicCreation = function (displayName, componentId) {
1109 {
1110 var parsedIdString = componentId ? " with the id of \"".concat(componentId, "\"") : '';
1111 var message_1 = "The component ".concat(displayName).concat(parsedIdString, " has been created dynamically.\n") +
1112 "You may see this warning because you've called styled inside another component.\n" +
1113 'To resolve this only create new StyledComponents outside of any render method and function component.';
1114 // If a hook is called outside of a component:
1115 // React 17 and earlier throw an error
1116 // React 18 and above use console.error
1117 var originalConsoleError_1 = console.error;
1118 try {
1119 var didNotCallInvalidHook_1 = true;
1120 console.error = function (consoleErrorMessage) {
1121 var consoleErrorArgs = [];
1122 for (var _i = 1; _i < arguments.length; _i++) {
1123 consoleErrorArgs[_i - 1] = arguments[_i];
1124 }
1125 // The error here is expected, since we're expecting anything that uses `checkDynamicCreation` to
1126 // be called outside of a React component.
1127 if (invalidHookCallRe.test(consoleErrorMessage)) {
1128 didNotCallInvalidHook_1 = false;
1129 // This shouldn't happen, but resets `warningSeen` if we had this error happen intermittently
1130 seen.delete(message_1);
1131 }
1132 else {
1133 originalConsoleError_1.apply(void 0, __spreadArray([consoleErrorMessage], consoleErrorArgs, false));
1134 }
1135 };
1136 // We purposefully call `useRef` outside of a component and expect it to throw
1137 // If it doesn't, then we're inside another component.
1138 React.useRef();
1139 if (didNotCallInvalidHook_1 && !seen.has(message_1)) {
1140 console.warn(message_1);
1141 seen.add(message_1);
1142 }
1143 }
1144 catch (error) {
1145 // The error here is expected, since we're expecting anything that uses `checkDynamicCreation` to
1146 // be called outside of a React component.
1147 if (invalidHookCallRe.test(error.message)) {
1148 // This shouldn't happen, but resets `warningSeen` if we had this error happen intermittently
1149 seen.delete(message_1);
1150 }
1151 }
1152 finally {
1153 console.error = originalConsoleError_1;
1154 }
1155 }
1156 };
1157
1158 function determineTheme(props, providedTheme, defaultProps) {
1159 if (defaultProps === void 0) { defaultProps = EMPTY_OBJECT; }
1160 return (props.theme !== defaultProps.theme && props.theme) || providedTheme || defaultProps.theme;
1161 }
1162
1163 var AD_REPLACER_R = /(a)(d)/gi;
1164 /* This is the "capacity" of our alphabet i.e. 2x26 for all letters plus their capitalised
1165 * counterparts */
1166 var charsLength = 52;
1167 /* start at 75 for 'a' until 'z' (25) and then start at 65 for capitalised letters */
1168 var getAlphabeticChar = function (code) { return String.fromCharCode(code + (code > 25 ? 39 : 97)); };
1169 /* input a number, usually a hash and convert it to base-52 */
1170 function generateAlphabeticName(code) {
1171 var name = '';
1172 var x;
1173 /* get a char and divide by alphabet-length */
1174 for (x = Math.abs(code); x > charsLength; x = (x / charsLength) | 0) {
1175 name = getAlphabeticChar(x % charsLength) + name;
1176 }
1177 return (getAlphabeticChar(x % charsLength) + name).replace(AD_REPLACER_R, '$1-$2');
1178 }
1179
1180 function generateComponentId(str) {
1181 return generateAlphabeticName(hash(str) >>> 0);
1182 }
1183
1184 function interleave(strings, interpolations) {
1185 var result = [strings[0]];
1186 for (var i = 0, len = interpolations.length; i < len; i += 1) {
1187 result.push(interpolations[i], strings[i + 1]);
1188 }
1189 return result;
1190 }
1191
1192 /**
1193 * Used when flattening object styles to determine if we should
1194 * expand an array of styles.
1195 */
1196 var addTag = function (arg) {
1197 return Object.assign(arg, { isCss: true });
1198 };
1199 function css(styles) {
1200 var interpolations = [];
1201 for (var _i = 1; _i < arguments.length; _i++) {
1202 interpolations[_i - 1] = arguments[_i];
1203 }
1204 if (isFunction(styles) || isPlainObject(styles)) {
1205 var styleFunctionOrObject = styles;
1206 return addTag(flatten(interleave(EMPTY_ARRAY, __spreadArray([
1207 styleFunctionOrObject
1208 ], interpolations, true))));
1209 }
1210 var styleStringArray = styles;
1211 if (interpolations.length === 0 &&
1212 styleStringArray.length === 1 &&
1213 typeof styleStringArray[0] === 'string') {
1214 return flatten(styleStringArray);
1215 }
1216 return addTag(flatten(interleave(styleStringArray, interpolations)));
1217 }
1218
1219 function createGlobalStyle(strings) {
1220 var interpolations = [];
1221 for (var _i = 1; _i < arguments.length; _i++) {
1222 interpolations[_i - 1] = arguments[_i];
1223 }
1224 var rules = css.apply(void 0, __spreadArray([strings], interpolations, false));
1225 var styledComponentId = "sc-global-".concat(generateComponentId(JSON.stringify(rules)));
1226 var globalStyle = new GlobalStyle(rules, styledComponentId);
1227 {
1228 checkDynamicCreation(styledComponentId);
1229 }
1230 var GlobalStyleComponent = function (props) {
1231 var ssc = useStyleSheetContext();
1232 var theme = React.useContext(ThemeContext);
1233 var instanceRef = React.useRef(ssc.styleSheet.allocateGSInstance(styledComponentId));
1234 var instance = instanceRef.current;
1235 if (React.Children.count(props.children)) {
1236 console.warn("The global style component ".concat(styledComponentId, " was given child JSX. createGlobalStyle does not render children."));
1237 }
1238 if (rules.some(function (rule) { return typeof rule === 'string' && rule.indexOf('@import') !== -1; })) {
1239 console.warn("Please do not use @import CSS syntax in createGlobalStyle at this time, as the CSSOM APIs we use in production do not handle it well. Instead, we recommend using a library such as react-helmet to inject a typical <link> meta tag to the stylesheet, or simply embedding it manually in your index.html <head> section for a simpler app.");
1240 }
1241 if (ssc.styleSheet.server) {
1242 renderStyles(instance, props, ssc.styleSheet, theme, ssc.stylis);
1243 }
1244 {
1245 React.useLayoutEffect(function () {
1246 if (!ssc.styleSheet.server) {
1247 renderStyles(instance, props, ssc.styleSheet, theme, ssc.stylis);
1248 return function () { return globalStyle.removeStyles(instance, ssc.styleSheet); };
1249 }
1250 }, [instance, props, ssc.styleSheet, theme, ssc.stylis]);
1251 }
1252 return null;
1253 };
1254 function renderStyles(instance, props, styleSheet, theme, stylis) {
1255 if (globalStyle.isStatic) {
1256 globalStyle.renderStyles(instance, STATIC_EXECUTION_CONTEXT, styleSheet, stylis);
1257 }
1258 else {
1259 var context = __assign(__assign({}, props), { theme: determineTheme(props, theme, GlobalStyleComponent.defaultProps) });
1260 globalStyle.renderStyles(instance, context, styleSheet, stylis);
1261 }
1262 }
1263 return React.memo(GlobalStyleComponent);
1264 }
1265
1266 function keyframes(strings) {
1267 var interpolations = [];
1268 for (var _i = 1; _i < arguments.length; _i++) {
1269 interpolations[_i - 1] = arguments[_i];
1270 }
1271 /* Warning if you've used keyframes on React Native */
1272 if (typeof navigator !== 'undefined' &&
1273 navigator.product === 'ReactNative') {
1274 console.warn('`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.');
1275 }
1276 var rules = joinStringArray(css.apply(void 0, __spreadArray([strings], interpolations, false)));
1277 var name = generateComponentId(rules);
1278 return new Keyframes(name, rules);
1279 }
1280
1281 var _a;
1282 var hasSymbol = typeof Symbol === 'function' && Symbol.for;
1283 // copied from react-is
1284 var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
1285 var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
1286 /**
1287 * Adapted from hoist-non-react-statics to avoid the react-is dependency.
1288 */
1289 var REACT_STATICS = {
1290 childContextTypes: true,
1291 contextType: true,
1292 contextTypes: true,
1293 defaultProps: true,
1294 displayName: true,
1295 getDefaultProps: true,
1296 getDerivedStateFromError: true,
1297 getDerivedStateFromProps: true,
1298 mixins: true,
1299 propTypes: true,
1300 type: true,
1301 };
1302 var KNOWN_STATICS = {
1303 name: true,
1304 length: true,
1305 prototype: true,
1306 caller: true,
1307 callee: true,
1308 arguments: true,
1309 arity: true,
1310 };
1311 var FORWARD_REF_STATICS = {
1312 $$typeof: true,
1313 render: true,
1314 defaultProps: true,
1315 displayName: true,
1316 propTypes: true,
1317 };
1318 var MEMO_STATICS = {
1319 $$typeof: true,
1320 compare: true,
1321 defaultProps: true,
1322 displayName: true,
1323 propTypes: true,
1324 type: true,
1325 };
1326 var TYPE_STATICS = (_a = {},
1327 _a[REACT_FORWARD_REF_TYPE] = FORWARD_REF_STATICS,
1328 _a[REACT_MEMO_TYPE] = MEMO_STATICS,
1329 _a);
1330 // adapted from react-is
1331 function isMemo(object) {
1332 var $$typeofType = 'type' in object && object.type.$$typeof;
1333 return $$typeofType === REACT_MEMO_TYPE;
1334 }
1335 function getStatics(component) {
1336 // React v16.11 and below
1337 if (isMemo(component)) {
1338 return MEMO_STATICS;
1339 }
1340 // React v16.12 and above
1341 return '$$typeof' in component
1342 ? TYPE_STATICS[component['$$typeof']]
1343 : REACT_STATICS;
1344 }
1345 var defineProperty = Object.defineProperty;
1346 var getOwnPropertyNames = Object.getOwnPropertyNames;
1347 var getOwnPropertySymbols = Object.getOwnPropertySymbols;
1348 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
1349 var getPrototypeOf = Object.getPrototypeOf;
1350 var objectPrototype = Object.prototype;
1351 function hoistNonReactStatics(targetComponent, sourceComponent, excludelist) {
1352 if (typeof sourceComponent !== 'string') {
1353 // don't hoist over string (html) components
1354 if (objectPrototype) {
1355 var inheritedComponent = getPrototypeOf(sourceComponent);
1356 if (inheritedComponent && inheritedComponent !== objectPrototype) {
1357 hoistNonReactStatics(targetComponent, inheritedComponent, excludelist);
1358 }
1359 }
1360 var keys = getOwnPropertyNames(sourceComponent);
1361 if (getOwnPropertySymbols) {
1362 keys = keys.concat(getOwnPropertySymbols(sourceComponent));
1363 }
1364 var targetStatics = getStatics(targetComponent);
1365 var sourceStatics = getStatics(sourceComponent);
1366 for (var i = 0; i < keys.length; ++i) {
1367 var key = keys[i];
1368 if (!(key in KNOWN_STATICS) &&
1369 !(excludelist && excludelist[key]) &&
1370 !(sourceStatics && key in sourceStatics) &&
1371 !(targetStatics && key in targetStatics)) {
1372 var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
1373 try {
1374 // Avoid failures from read-only properties
1375 defineProperty(targetComponent, key, descriptor);
1376 }
1377 catch (e) {
1378 /* ignore */
1379 }
1380 }
1381 }
1382 }
1383 return targetComponent;
1384 }
1385
1386 function withTheme(Component) {
1387 var WithTheme = React.forwardRef(function (props, ref) {
1388 var theme = React.useContext(ThemeContext);
1389 var themeProp = determineTheme(props, theme, Component.defaultProps);
1390 if (themeProp === undefined) {
1391 console.warn("[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class \"".concat(getComponentName(Component), "\""));
1392 }
1393 return React.createElement(Component, __assign({}, props, { theme: themeProp, ref: ref }));
1394 });
1395 WithTheme.displayName = "WithTheme(".concat(getComponentName(Component), ")");
1396 return hoistNonReactStatics(WithTheme, Component);
1397 }
1398
1399 var ServerStyleSheet = /** @class */ (function () {
1400 function ServerStyleSheet() {
1401 var _this = this;
1402 this._emitSheetCSS = function () {
1403 var css = _this.instance.toString();
1404 var nonce = getNonce();
1405 var attrs = [
1406 nonce && "nonce=\"".concat(nonce, "\""),
1407 "".concat(SC_ATTR, "=\"true\""),
1408 "".concat(SC_ATTR_VERSION, "=\"").concat(SC_VERSION, "\""),
1409 ];
1410 var htmlAttr = joinStringArray(attrs.filter(Boolean), ' ');
1411 return "<style ".concat(htmlAttr, ">").concat(css, "</style>");
1412 };
1413 this.getStyleTags = function () {
1414 if (_this.sealed) {
1415 throw throwStyledComponentsError(2);
1416 }
1417 return _this._emitSheetCSS();
1418 };
1419 this.getStyleElement = function () {
1420 var _a;
1421 if (_this.sealed) {
1422 throw throwStyledComponentsError(2);
1423 }
1424 var props = (_a = {},
1425 _a[SC_ATTR] = '',
1426 _a[SC_ATTR_VERSION] = SC_VERSION,
1427 _a.dangerouslySetInnerHTML = {
1428 __html: _this.instance.toString(),
1429 },
1430 _a);
1431 var nonce = getNonce();
1432 if (nonce) {
1433 props.nonce = nonce;
1434 }
1435 // v4 returned an array for this fn, so we'll do the same for v5 for backward compat
1436 return [React.createElement("style", __assign({}, props, { key: "sc-0-0" }))];
1437 };
1438 this.seal = function () {
1439 _this.sealed = true;
1440 };
1441 this.instance = new StyleSheet({ isServer: true });
1442 this.sealed = false;
1443 }
1444 ServerStyleSheet.prototype.collectStyles = function (children) {
1445 if (this.sealed) {
1446 throw throwStyledComponentsError(2);
1447 }
1448 return React.createElement(StyleSheetManager, { sheet: this.instance }, children);
1449 };
1450 // @ts-expect-error alternate return types are not possible due to code transformation
1451 ServerStyleSheet.prototype.interleaveWithNodeStream = function (input) {
1452 {
1453 throw throwStyledComponentsError(3);
1454 }
1455 };
1456 return ServerStyleSheet;
1457 }());
1458
1459 var __PRIVATE__ = {
1460 StyleSheet: StyleSheet,
1461 mainSheet: mainSheet,
1462 };
1463
1464 /* Import singletons */
1465 /* Warning if you've imported this file on React Native */
1466 if (typeof navigator !== 'undefined' &&
1467 navigator.product === 'ReactNative') {
1468 console.warn("It looks like you've imported 'styled-components' on React Native.\nPerhaps you're looking to import 'styled-components/native'?\nRead more about this at https://www.styled-components.com/docs/basics#react-native");
1469 }
1470 var windowGlobalKey = "__sc-".concat(SC_ATTR, "__");
1471 /* Warning if there are several instances of styled-components */
1472 if (typeof window !== 'undefined') {
1473 // @ts-expect-error dynamic key not in window object
1474 window[windowGlobalKey] || (window[windowGlobalKey] = 0);
1475 // @ts-expect-error dynamic key not in window object
1476 if (window[windowGlobalKey] === 1) {
1477 console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://s-c.sh/2BAXzed for more info.");
1478 }
1479 // @ts-expect-error dynamic key not in window object
1480 window[windowGlobalKey] += 1;
1481 }
1482
1483 var secondary = /*#__PURE__*/Object.freeze({
1484 __proto__: null,
1485 ServerStyleSheet: ServerStyleSheet,
1486 StyleSheetConsumer: StyleSheetConsumer,
1487 StyleSheetContext: StyleSheetContext,
1488 StyleSheetManager: StyleSheetManager,
1489 ThemeConsumer: ThemeConsumer,
1490 ThemeContext: ThemeContext,
1491 ThemeProvider: ThemeProvider,
1492 __PRIVATE__: __PRIVATE__,
1493 createGlobalStyle: createGlobalStyle,
1494 css: css,
1495 isStyledComponent: isStyledComponent,
1496 keyframes: keyframes,
1497 useTheme: useTheme,
1498 version: SC_VERSION,
1499 withTheme: withTheme
1500 });
1501
1502 function memoize(fn) {
1503 var cache = Object.create(null);
1504 return function (arg) {
1505 if (cache[arg] === undefined) cache[arg] = fn(arg);
1506 return cache[arg];
1507 };
1508 }
1509
1510 var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|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|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|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|loading|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|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|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|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/; // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23
1511
1512 var isPropValid = /* #__PURE__ */memoize(function (prop) {
1513 return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111
1514 /* o */
1515 && prop.charCodeAt(1) === 110
1516 /* n */
1517 && prop.charCodeAt(2) < 91;
1518 }
1519 /* Z+1 */
1520 );
1521
1522 var LIMIT = 200;
1523 var createWarnTooManyClasses = (function (displayName, componentId) {
1524 var generatedClasses = {};
1525 var warningSeen = false;
1526 return function (className) {
1527 if (!warningSeen) {
1528 generatedClasses[className] = true;
1529 if (Object.keys(generatedClasses).length >= LIMIT) {
1530 // Unable to find latestRule in test environment.
1531 var parsedIdString = componentId ? " with the id of \"".concat(componentId, "\"") : '';
1532 console.warn("Over ".concat(LIMIT, " classes were generated for component ").concat(displayName).concat(parsedIdString, ".\n") +
1533 'Consider using the attrs method, together with a style object for frequently changed styles.\n' +
1534 'Example:\n' +
1535 ' const Component = styled.div.attrs(props => ({\n' +
1536 ' style: {\n' +
1537 ' background: props.background,\n' +
1538 ' },\n' +
1539 ' }))`width: 100%;`\n\n' +
1540 ' <Component />');
1541 warningSeen = true;
1542 generatedClasses = {};
1543 }
1544 }
1545 };
1546 });
1547
1548 // Thanks to ReactDOMFactories for this handy list!
1549 var elements = [
1550 'a',
1551 'abbr',
1552 'address',
1553 'area',
1554 'article',
1555 'aside',
1556 'audio',
1557 'b',
1558 'base',
1559 'bdi',
1560 'bdo',
1561 'big',
1562 'blockquote',
1563 'body',
1564 'br',
1565 'button',
1566 'canvas',
1567 'caption',
1568 'cite',
1569 'code',
1570 'col',
1571 'colgroup',
1572 'data',
1573 'datalist',
1574 'dd',
1575 'del',
1576 'details',
1577 'dfn',
1578 'dialog',
1579 'div',
1580 'dl',
1581 'dt',
1582 'em',
1583 'embed',
1584 'fieldset',
1585 'figcaption',
1586 'figure',
1587 'footer',
1588 'form',
1589 'h1',
1590 'h2',
1591 'h3',
1592 'h4',
1593 'h5',
1594 'h6',
1595 'header',
1596 'hgroup',
1597 'hr',
1598 'html',
1599 'i',
1600 'iframe',
1601 'img',
1602 'input',
1603 'ins',
1604 'kbd',
1605 'keygen',
1606 'label',
1607 'legend',
1608 'li',
1609 'link',
1610 'main',
1611 'map',
1612 'mark',
1613 'menu',
1614 'menuitem',
1615 'meta',
1616 'meter',
1617 'nav',
1618 'noscript',
1619 'object',
1620 'ol',
1621 'optgroup',
1622 'option',
1623 'output',
1624 'p',
1625 'param',
1626 'picture',
1627 'pre',
1628 'progress',
1629 'q',
1630 'rp',
1631 'rt',
1632 'ruby',
1633 's',
1634 'samp',
1635 'script',
1636 'section',
1637 'select',
1638 'small',
1639 'source',
1640 'span',
1641 'strong',
1642 'style',
1643 'sub',
1644 'summary',
1645 'sup',
1646 'table',
1647 'tbody',
1648 'td',
1649 'textarea',
1650 'tfoot',
1651 'th',
1652 'thead',
1653 'time',
1654 'tr',
1655 'track',
1656 'u',
1657 'ul',
1658 'use',
1659 'var',
1660 'video',
1661 'wbr', // SVG
1662 'circle',
1663 'clipPath',
1664 'defs',
1665 'ellipse',
1666 'foreignObject',
1667 'g',
1668 'image',
1669 'line',
1670 'linearGradient',
1671 'marker',
1672 'mask',
1673 'path',
1674 'pattern',
1675 'polygon',
1676 'polyline',
1677 'radialGradient',
1678 'rect',
1679 'stop',
1680 'svg',
1681 'text',
1682 'tspan',
1683 ];
1684 var domElements = new Set(elements);
1685
1686 // Source: https://www.w3.org/TR/cssom-1/#serialize-an-identifier
1687 // Control characters and non-letter first symbols are not supported
1688 var escapeRegex = /[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g;
1689 var dashesAtEnds = /(^-|-$)/g;
1690 /**
1691 * TODO: Explore using CSS.escape when it becomes more available
1692 * in evergreen browsers.
1693 */
1694 function escape(str) {
1695 return str // Replace all possible CSS selectors
1696 .replace(escapeRegex, '-') // Remove extraneous hyphens at the start and end
1697 .replace(dashesAtEnds, '');
1698 }
1699
1700 function isTag(target) {
1701 return (typeof target === 'string' &&
1702 (target.charAt(0) === target.charAt(0).toLowerCase()
1703 ));
1704 }
1705
1706 function generateDisplayName(target) {
1707 return isTag(target) ? "styled.".concat(target) : "Styled(".concat(getComponentName(target), ")");
1708 }
1709
1710 function mixinRecursively(target, source, forceMerge) {
1711 if (forceMerge === void 0) { forceMerge = false; }
1712 /* only merge into POJOs, Arrays, but for top level objects only
1713 * allow to merge into anything by passing forceMerge = true */
1714 if (!forceMerge && !isPlainObject(target) && !Array.isArray(target)) {
1715 return source;
1716 }
1717 if (Array.isArray(source)) {
1718 for (var key = 0; key < source.length; key++) {
1719 target[key] = mixinRecursively(target[key], source[key]);
1720 }
1721 }
1722 else if (isPlainObject(source)) {
1723 for (var key in source) {
1724 target[key] = mixinRecursively(target[key], source[key]);
1725 }
1726 }
1727 return target;
1728 }
1729 /**
1730 * Arrays & POJOs merged recursively, other objects and value types are overridden
1731 * If target is not a POJO or an Array, it will get source properties injected via shallow merge
1732 * Source objects applied left to right. Mutates & returns target. Similar to lodash merge.
1733 */
1734 function mixinDeep(target) {
1735 var sources = [];
1736 for (var _i = 1; _i < arguments.length; _i++) {
1737 sources[_i - 1] = arguments[_i];
1738 }
1739 for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) {
1740 var source = sources_1[_a];
1741 mixinRecursively(target, source, true);
1742 }
1743 return target;
1744 }
1745
1746 var SEED = hash(SC_VERSION);
1747 /**
1748 * ComponentStyle is all the CSS-specific stuff, not the React-specific stuff.
1749 */
1750 var ComponentStyle = /** @class */ (function () {
1751 function ComponentStyle(rules, componentId, baseStyle) {
1752 this.rules = rules;
1753 this.staticRulesId = '';
1754 this.isStatic =
1755 "development" === 'production' ;
1756 this.componentId = componentId;
1757 this.baseHash = phash(SEED, componentId);
1758 this.baseStyle = baseStyle;
1759 // NOTE: This registers the componentId, which ensures a consistent order
1760 // for this component's styles compared to others
1761 StyleSheet.registerId(componentId);
1762 }
1763 ComponentStyle.prototype.generateAndInjectStyles = function (executionContext, styleSheet, stylis) {
1764 var names = this.baseStyle
1765 ? this.baseStyle.generateAndInjectStyles(executionContext, styleSheet, stylis)
1766 : '';
1767 // force dynamic classnames if user-supplied stylis plugins are in use
1768 if (this.isStatic && !stylis.hash) {
1769 if (this.staticRulesId && styleSheet.hasNameForId(this.componentId, this.staticRulesId)) {
1770 names = joinStrings(names, this.staticRulesId);
1771 }
1772 else {
1773 var cssStatic = joinStringArray(flatten(this.rules, executionContext, styleSheet, stylis));
1774 var name_1 = generateAlphabeticName(phash(this.baseHash, cssStatic) >>> 0);
1775 if (!styleSheet.hasNameForId(this.componentId, name_1)) {
1776 var cssStaticFormatted = stylis(cssStatic, ".".concat(name_1), undefined, this.componentId);
1777 styleSheet.insertRules(this.componentId, name_1, cssStaticFormatted);
1778 }
1779 names = joinStrings(names, name_1);
1780 this.staticRulesId = name_1;
1781 }
1782 }
1783 else {
1784 var dynamicHash = phash(this.baseHash, stylis.hash);
1785 var css = '';
1786 for (var i = 0; i < this.rules.length; i++) {
1787 var partRule = this.rules[i];
1788 if (typeof partRule === 'string') {
1789 css += partRule;
1790 dynamicHash = phash(dynamicHash, partRule);
1791 }
1792 else if (partRule) {
1793 var partString = joinStringArray(flatten(partRule, executionContext, styleSheet, stylis));
1794 // The same value can switch positions in the array, so we include "i" in the hash.
1795 dynamicHash = phash(dynamicHash, partString + i);
1796 css += partString;
1797 }
1798 }
1799 if (css) {
1800 var name_2 = generateAlphabeticName(dynamicHash >>> 0);
1801 if (!styleSheet.hasNameForId(this.componentId, name_2)) {
1802 styleSheet.insertRules(this.componentId, name_2, stylis(css, ".".concat(name_2), undefined, this.componentId));
1803 }
1804 names = joinStrings(names, name_2);
1805 }
1806 }
1807 return names;
1808 };
1809 return ComponentStyle;
1810 }());
1811
1812 var identifiers = {};
1813 /* We depend on components having unique IDs */
1814 function generateId(displayName, parentComponentId) {
1815 var name = typeof displayName !== 'string' ? 'sc' : escape(displayName);
1816 // Ensure that no displayName can lead to duplicate componentIds
1817 identifiers[name] = (identifiers[name] || 0) + 1;
1818 var componentId = "".concat(name, "-").concat(generateComponentId(
1819 // SC_VERSION gives us isolation between multiple runtimes on the page at once
1820 // this is improved further with use of the babel plugin "namespace" feature
1821 SC_VERSION + name + identifiers[name]));
1822 return parentComponentId ? "".concat(parentComponentId, "-").concat(componentId) : componentId;
1823 }
1824 function useInjectedStyle(componentStyle, resolvedAttrs) {
1825 var ssc = useStyleSheetContext();
1826 var className = componentStyle.generateAndInjectStyles(resolvedAttrs, ssc.styleSheet, ssc.stylis);
1827 React.useDebugValue(className);
1828 return className;
1829 }
1830 function resolveContext(attrs, props, theme) {
1831 var context = __assign(__assign({}, props), {
1832 // unset, add `props.className` back at the end so props always "wins"
1833 className: undefined, theme: theme });
1834 var attrDef;
1835 for (var i = 0; i < attrs.length; i += 1) {
1836 attrDef = attrs[i];
1837 var resolvedAttrDef = isFunction(attrDef) ? attrDef(context) : attrDef;
1838 for (var key in resolvedAttrDef) {
1839 context[key] =
1840 key === 'className'
1841 ? joinStrings(context[key], resolvedAttrDef[key])
1842 : key === 'style'
1843 ? __assign(__assign({}, context[key]), resolvedAttrDef[key]) : resolvedAttrDef[key];
1844 }
1845 }
1846 if (props.className) {
1847 context.className = joinStrings(context.className, props.className);
1848 }
1849 return context;
1850 }
1851 var seenUnknownProps = new Set();
1852 function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
1853 var componentAttrs = forwardedComponent.attrs, componentStyle = forwardedComponent.componentStyle, defaultProps = forwardedComponent.defaultProps, foldedComponentIds = forwardedComponent.foldedComponentIds, styledComponentId = forwardedComponent.styledComponentId, target = forwardedComponent.target;
1854 var contextTheme = React.useContext(ThemeContext);
1855 var ssc = useStyleSheetContext();
1856 var shouldForwardProp = forwardedComponent.shouldForwardProp || ssc.shouldForwardProp;
1857 React.useDebugValue(styledComponentId);
1858 // NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
1859 // but that'd be against the rules-of-hooks. We could be naughty and do it anyway as it
1860 // should be an immutable value, but behave for now.
1861 var theme = determineTheme(props, contextTheme, defaultProps) || EMPTY_OBJECT;
1862 var context = resolveContext(componentAttrs, props, theme);
1863 var elementToBeCreated = context.as || target;
1864 var propsForElement = {};
1865 for (var key in context) {
1866 if (context[key] === undefined) ;
1867 else if (key[0] === '$' || key === 'as' || (key === 'theme' && context.theme === theme)) ;
1868 else if (key === 'forwardedAs') {
1869 propsForElement.as = context.forwardedAs;
1870 }
1871 else if (!shouldForwardProp || shouldForwardProp(key, elementToBeCreated)) {
1872 propsForElement[key] = context[key];
1873 if (!shouldForwardProp &&
1874 "development" === 'development' &&
1875 !isPropValid(key) &&
1876 !seenUnknownProps.has(key) &&
1877 // Only warn on DOM Element.
1878 domElements.has(elementToBeCreated)) {
1879 seenUnknownProps.add(key);
1880 console.warn("styled-components: it looks like an unknown prop \"".concat(key, "\" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)"));
1881 }
1882 }
1883 }
1884 var generatedClassName = useInjectedStyle(componentStyle, context);
1885 if (forwardedComponent.warnTooManyClasses) {
1886 forwardedComponent.warnTooManyClasses(generatedClassName);
1887 }
1888 var classString = joinStrings(foldedComponentIds, styledComponentId);
1889 if (generatedClassName) {
1890 classString += ' ' + generatedClassName;
1891 }
1892 if (context.className) {
1893 classString += ' ' + context.className;
1894 }
1895 propsForElement[
1896 // handle custom elements which React doesn't properly alias
1897 isTag(elementToBeCreated) &&
1898 !domElements.has(elementToBeCreated)
1899 ? 'class'
1900 : 'className'] = classString;
1901 propsForElement.ref = forwardedRef;
1902 return React.createElement(elementToBeCreated, propsForElement);
1903 }
1904 function createStyledComponent(target, options, rules) {
1905 var isTargetStyledComp = isStyledComponent(target);
1906 var styledComponentTarget = target;
1907 var isCompositeComponent = !isTag(target);
1908 var _a = options.attrs, attrs = _a === void 0 ? EMPTY_ARRAY : _a, _b = options.componentId, componentId = _b === void 0 ? generateId(options.displayName, options.parentComponentId) : _b, _c = options.displayName, displayName = _c === void 0 ? generateDisplayName(target) : _c;
1909 var styledComponentId = options.displayName && options.componentId
1910 ? "".concat(escape(options.displayName), "-").concat(options.componentId)
1911 : options.componentId || componentId;
1912 // fold the underlying StyledComponent attrs up (implicit extend)
1913 var finalAttrs = isTargetStyledComp && styledComponentTarget.attrs
1914 ? styledComponentTarget.attrs.concat(attrs).filter(Boolean)
1915 : attrs;
1916 var shouldForwardProp = options.shouldForwardProp;
1917 if (isTargetStyledComp && styledComponentTarget.shouldForwardProp) {
1918 var shouldForwardPropFn_1 = styledComponentTarget.shouldForwardProp;
1919 if (options.shouldForwardProp) {
1920 var passedShouldForwardPropFn_1 = options.shouldForwardProp;
1921 // compose nested shouldForwardProp calls
1922 shouldForwardProp = function (prop, elementToBeCreated) {
1923 return shouldForwardPropFn_1(prop, elementToBeCreated) &&
1924 passedShouldForwardPropFn_1(prop, elementToBeCreated);
1925 };
1926 }
1927 else {
1928 shouldForwardProp = shouldForwardPropFn_1;
1929 }
1930 }
1931 var componentStyle = new ComponentStyle(rules, styledComponentId, isTargetStyledComp ? styledComponentTarget.componentStyle : undefined);
1932 function forwardRefRender(props, ref) {
1933 return useStyledComponentImpl(WrappedStyledComponent, props, ref);
1934 }
1935 forwardRefRender.displayName = displayName;
1936 /**
1937 * forwardRef creates a new interim component, which we'll take advantage of
1938 * instead of extending ParentComponent to create _another_ interim class
1939 */
1940 var WrappedStyledComponent = React.forwardRef(forwardRefRender);
1941 WrappedStyledComponent.attrs = finalAttrs;
1942 WrappedStyledComponent.componentStyle = componentStyle;
1943 WrappedStyledComponent.displayName = displayName;
1944 WrappedStyledComponent.shouldForwardProp = shouldForwardProp;
1945 // this static is used to preserve the cascade of static classes for component selector
1946 // purposes; this is especially important with usage of the css prop
1947 WrappedStyledComponent.foldedComponentIds = isTargetStyledComp
1948 ? joinStrings(styledComponentTarget.foldedComponentIds, styledComponentTarget.styledComponentId)
1949 : '';
1950 WrappedStyledComponent.styledComponentId = styledComponentId;
1951 // fold the underlying StyledComponent target up since we folded the styles
1952 WrappedStyledComponent.target = isTargetStyledComp ? styledComponentTarget.target : target;
1953 Object.defineProperty(WrappedStyledComponent, 'defaultProps', {
1954 get: function () {
1955 return this._foldedDefaultProps;
1956 },
1957 set: function (obj) {
1958 this._foldedDefaultProps = isTargetStyledComp
1959 ? mixinDeep({}, styledComponentTarget.defaultProps, obj)
1960 : obj;
1961 },
1962 });
1963 {
1964 checkDynamicCreation(displayName, styledComponentId);
1965 WrappedStyledComponent.warnTooManyClasses = createWarnTooManyClasses(displayName, styledComponentId);
1966 }
1967 setToString(WrappedStyledComponent, function () { return ".".concat(WrappedStyledComponent.styledComponentId); });
1968 if (isCompositeComponent) {
1969 var compositeComponentTarget = target;
1970 hoistNonReactStatics(WrappedStyledComponent, compositeComponentTarget, {
1971 // all SC-specific things should not be hoisted
1972 attrs: true,
1973 componentStyle: true,
1974 displayName: true,
1975 foldedComponentIds: true,
1976 shouldForwardProp: true,
1977 styledComponentId: true,
1978 target: true,
1979 });
1980 }
1981 return WrappedStyledComponent;
1982 }
1983
1984 function constructWithOptions(componentConstructor, tag, options) {
1985 if (options === void 0) { options = EMPTY_OBJECT; }
1986 /**
1987 * We trust that the tag is a valid component as long as it isn't
1988 * falsish. Typically the tag here is a string or function (i.e.
1989 * class or pure function component), however a component may also be
1990 * an object if it uses another utility, e.g. React.memo. React will
1991 * output an appropriate warning however if the `tag` isn't valid.
1992 */
1993 if (!tag) {
1994 throw throwStyledComponentsError(1, tag);
1995 }
1996 /* This is callable directly as a template function */
1997 var templateFunction = function (initialStyles) {
1998 var interpolations = [];
1999 for (var _i = 1; _i < arguments.length; _i++) {
2000 interpolations[_i - 1] = arguments[_i];
2001 }
2002 return componentConstructor(tag, options, css.apply(void 0, __spreadArray([initialStyles], interpolations, false)));
2003 };
2004 /**
2005 * Attrs allows for accomplishing two goals:
2006 *
2007 * 1. Backfilling props at runtime more expressively than defaultProps
2008 * 2. Amending the prop interface of a wrapped styled component
2009 */
2010 templateFunction.attrs = function (attrs) {
2011 return constructWithOptions(componentConstructor, tag, __assign(__assign({}, options), { attrs: Array.prototype.concat(options.attrs, attrs).filter(Boolean) }));
2012 };
2013 /**
2014 * If config methods are called, wrap up a new template function
2015 * and merge options.
2016 */
2017 templateFunction.withConfig = function (config) {
2018 return constructWithOptions(componentConstructor, tag, __assign(__assign({}, options), config));
2019 };
2020 return templateFunction;
2021 }
2022
2023 var baseStyled = function (tag) {
2024 return constructWithOptions(createStyledComponent, tag);
2025 };
2026 var styled = baseStyled;
2027 // Shorthands for all valid HTML Elements
2028 domElements.forEach(function (domElement) {
2029 // @ts-expect-error some react typing bs
2030 styled[domElement] = baseStyled(domElement);
2031 });
2032
2033 /**
2034 * eliminates the need to do styled.default since the other APIs
2035 * are directly assigned as properties to the main function
2036 * */
2037 for (var key in secondary) {
2038 // @ts-expect-error shush
2039 styled[key] = secondary[key];
2040 }
2041
2042 return styled;
2043
2044}));
2045//# sourceMappingURL=styled-components.js.map