styled-components 6.0.0-beta.13 → 6.0.0-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/base.d.ts +1 -2
  2. package/dist/models/ComponentStyle.d.ts +0 -1
  3. package/dist/models/StyleSheetManager.d.ts +6 -7
  4. package/dist/models/ThemeProvider.d.ts +1 -0
  5. package/dist/native/index.d.ts +1 -2
  6. package/dist/sheet/GroupedTag.d.ts +1 -1
  7. package/dist/styled-components.browser.cjs.js +1 -1862
  8. package/dist/styled-components.browser.cjs.js.map +1 -1
  9. package/dist/styled-components.browser.esm.js +1 -1836
  10. package/dist/styled-components.browser.esm.js.map +1 -1
  11. package/dist/styled-components.cjs.js +1 -1886
  12. package/dist/styled-components.cjs.js.map +1 -1
  13. package/dist/styled-components.esm.js +1 -1860
  14. package/dist/styled-components.esm.js.map +1 -1
  15. package/dist/styled-components.js +185 -185
  16. package/dist/styled-components.js.map +1 -1
  17. package/dist/styled-components.min.js +1 -1
  18. package/dist/styled-components.min.js.map +1 -1
  19. package/dist/tsconfig.tsbuildinfo +1 -1
  20. package/dist/types.d.ts +1 -1
  21. package/dist/utils/determineTheme.d.ts +4 -2
  22. package/dist/utils/domElements.d.ts +1 -1
  23. package/dist/utils/flatten.d.ts +1 -1
  24. package/dist/utils/isFunction.d.ts +1 -1
  25. package/dist/utils/isPlainObject.d.ts +1 -1
  26. package/dist/utils/isStatelessFunction.d.ts +1 -1
  27. package/dist/utils/joinStrings.d.ts +2 -1
  28. package/native/dist/base.d.ts +1 -2
  29. package/native/dist/models/ComponentStyle.d.ts +0 -1
  30. package/native/dist/models/StyleSheetManager.d.ts +6 -7
  31. package/native/dist/models/ThemeProvider.d.ts +1 -0
  32. package/native/dist/native/index.d.ts +1 -2
  33. package/native/dist/sheet/GroupedTag.d.ts +1 -1
  34. package/native/dist/styled-components.native.cjs.js +1 -1324
  35. package/native/dist/styled-components.native.cjs.js.map +1 -1
  36. package/native/dist/styled-components.native.esm.js +1 -1306
  37. package/native/dist/styled-components.native.esm.js.map +1 -1
  38. package/native/dist/types.d.ts +1 -1
  39. package/native/dist/utils/determineTheme.d.ts +4 -2
  40. package/native/dist/utils/domElements.d.ts +1 -1
  41. package/native/dist/utils/flatten.d.ts +1 -1
  42. package/native/dist/utils/isFunction.d.ts +1 -1
  43. package/native/dist/utils/isPlainObject.d.ts +1 -1
  44. package/native/dist/utils/isStatelessFunction.d.ts +1 -1
  45. package/native/dist/utils/joinStrings.d.ts +2 -1
  46. package/package.json +1 -1
  47. package/dist/hooks/useTheme.d.ts +0 -3
@@ -1,1307 +1,2 @@
1
- import { __spreadArray, __assign } from 'tslib';
2
- import React, { useContext, useMemo, createElement } from 'react';
3
- import 'shallowequal';
4
- import { prefixer, stringify, compile, middleware, RULESET } from 'stylis';
5
- import unitless from '@emotion/unitless';
6
- import transformDeclPairs from 'css-to-react-native';
7
- import { parse } from 'postcss';
8
-
9
- var EMPTY_ARRAY = Object.freeze([]);
10
- var EMPTY_OBJECT = Object.freeze({});
11
-
12
- var errorMap = {
13
- '1': 'Cannot create styled-component for component: %s.\n\n',
14
- '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",
15
- '3': 'Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n',
16
- '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',
17
- '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',
18
- '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",
19
- '7': 'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n',
20
- '8': 'ThemeProvider: Please make your "theme" prop an object.\n\n',
21
- '9': 'Missing document `<head>`\n\n',
22
- '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',
23
- '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',
24
- '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',
25
- '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',
26
- '14': 'ThemeProvider: "theme" prop is required.\n\n',
27
- '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",
28
- '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",
29
- '17': "CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n",
30
- };
31
-
32
- var ERRORS = process.env.NODE_ENV !== 'production' ? errorMap : {};
33
- /**
34
- * super basic version of sprintf
35
- */
36
- function format() {
37
- var args = [];
38
- for (var _i = 0; _i < arguments.length; _i++) {
39
- args[_i] = arguments[_i];
40
- }
41
- var a = args[0];
42
- var b = [];
43
- for (var c = 1, len = args.length; c < len; c += 1) {
44
- b.push(args[c]);
45
- }
46
- b.forEach(function (d) {
47
- a = a.replace(/%[a-z]/, d);
48
- });
49
- return a;
50
- }
51
- /**
52
- * Create an error file out of errors.md for development and a simple web link to the full errors
53
- * in production mode.
54
- */
55
- function throwStyledComponentsError(code) {
56
- var interpolations = [];
57
- for (var _i = 1; _i < arguments.length; _i++) {
58
- interpolations[_i - 1] = arguments[_i];
59
- }
60
- if (process.env.NODE_ENV === 'production') {
61
- return new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(code, " for more information.").concat(interpolations.length > 0 ? " Args: ".concat(interpolations.join(', ')) : ''));
62
- }
63
- else {
64
- return new Error(format.apply(void 0, __spreadArray([ERRORS[code]], interpolations, false)).trim());
65
- }
66
- }
67
-
68
- var SC_ATTR = (typeof process !== 'undefined' && typeof process.env !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
69
- 'data-styled';
70
- var SC_ATTR_ACTIVE = 'active';
71
- var SC_ATTR_VERSION = 'data-styled-version';
72
- var SC_VERSION = "6.0.0-beta.13";
73
- var SPLITTER = '/*!sc*/\n';
74
- var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
75
- var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
76
- ? SC_DISABLE_SPEEDY
77
- : typeof process !== 'undefined' &&
78
- typeof process.env !== 'undefined' &&
79
- typeof process.env.REACT_APP_SC_DISABLE_SPEEDY !== 'undefined' &&
80
- process.env.REACT_APP_SC_DISABLE_SPEEDY !== ''
81
- ? process.env.REACT_APP_SC_DISABLE_SPEEDY === 'false'
82
- ? false
83
- : process.env.REACT_APP_SC_DISABLE_SPEEDY
84
- : typeof process !== 'undefined' &&
85
- typeof process.env !== 'undefined' &&
86
- typeof process.env.SC_DISABLE_SPEEDY !== 'undefined' &&
87
- process.env.SC_DISABLE_SPEEDY !== ''
88
- ? process.env.SC_DISABLE_SPEEDY === 'false'
89
- ? false
90
- : process.env.SC_DISABLE_SPEEDY
91
- : process.env.NODE_ENV !== 'production');
92
-
93
- /** Create a GroupedTag with an underlying Tag implementation */
94
- var makeGroupedTag = function (tag) {
95
- return new DefaultGroupedTag(tag);
96
- };
97
- var BASE_SIZE = 1 << 9;
98
- var DefaultGroupedTag = /** @class */ (function () {
99
- function DefaultGroupedTag(tag) {
100
- this.groupSizes = new Uint32Array(BASE_SIZE);
101
- this.length = BASE_SIZE;
102
- this.tag = tag;
103
- }
104
- DefaultGroupedTag.prototype.indexOfGroup = function (group) {
105
- var index = 0;
106
- for (var i = 0; i < group; i++) {
107
- index += this.groupSizes[i];
108
- }
109
- return index;
110
- };
111
- DefaultGroupedTag.prototype.insertRules = function (group, rules) {
112
- if (group >= this.groupSizes.length) {
113
- var oldBuffer = this.groupSizes;
114
- var oldSize = oldBuffer.length;
115
- var newSize = oldSize;
116
- while (group >= newSize) {
117
- newSize <<= 1;
118
- if (newSize < 0) {
119
- throw throwStyledComponentsError(16, "".concat(group));
120
- }
121
- }
122
- this.groupSizes = new Uint32Array(newSize);
123
- this.groupSizes.set(oldBuffer);
124
- this.length = newSize;
125
- for (var i = oldSize; i < newSize; i++) {
126
- this.groupSizes[i] = 0;
127
- }
128
- }
129
- var ruleIndex = this.indexOfGroup(group + 1);
130
- if (Array.isArray(rules)) {
131
- for (var i = 0, l = rules.length; i < l; i++) {
132
- if (this.tag.insertRule(ruleIndex, rules[i])) {
133
- this.groupSizes[group]++;
134
- ruleIndex++;
135
- }
136
- }
137
- }
138
- else {
139
- if (this.tag.insertRule(ruleIndex, rules)) {
140
- this.groupSizes[group]++;
141
- }
142
- }
143
- };
144
- DefaultGroupedTag.prototype.clearGroup = function (group) {
145
- if (group < this.length) {
146
- var length_1 = this.groupSizes[group];
147
- var startIndex = this.indexOfGroup(group);
148
- var endIndex = startIndex + length_1;
149
- this.groupSizes[group] = 0;
150
- for (var i = startIndex; i < endIndex; i++) {
151
- this.tag.deleteRule(startIndex);
152
- }
153
- }
154
- };
155
- DefaultGroupedTag.prototype.getGroup = function (group) {
156
- var css = '';
157
- if (group >= this.length || this.groupSizes[group] === 0) {
158
- return css;
159
- }
160
- var length = this.groupSizes[group];
161
- var startIndex = this.indexOfGroup(group);
162
- var endIndex = startIndex + length;
163
- for (var i = startIndex; i < endIndex; i++) {
164
- css += "".concat(this.tag.getRule(i)).concat(SPLITTER);
165
- }
166
- return css;
167
- };
168
- return DefaultGroupedTag;
169
- }());
170
-
171
- var MAX_SMI = 1 << (31 - 1);
172
- var groupIDRegister = new Map();
173
- var reverseRegister = new Map();
174
- var nextFreeGroup = 1;
175
- var getGroupForId = function (id) {
176
- if (groupIDRegister.has(id)) {
177
- return groupIDRegister.get(id);
178
- }
179
- while (reverseRegister.has(nextFreeGroup)) {
180
- nextFreeGroup++;
181
- }
182
- var group = nextFreeGroup++;
183
- if (process.env.NODE_ENV !== 'production' && ((group | 0) < 0 || group > MAX_SMI)) {
184
- throw throwStyledComponentsError(16, "".concat(group));
185
- }
186
- groupIDRegister.set(id, group);
187
- reverseRegister.set(group, id);
188
- return group;
189
- };
190
- var getIdForGroup = function (group) {
191
- return reverseRegister.get(group);
192
- };
193
- var setGroupForId = function (id, group) {
194
- groupIDRegister.set(id, group);
195
- reverseRegister.set(group, id);
196
- };
197
-
198
- var SELECTOR = "style[".concat(SC_ATTR, "][").concat(SC_ATTR_VERSION, "=\"").concat(SC_VERSION, "\"]");
199
- var MARKER_RE = new RegExp("^".concat(SC_ATTR, "\\.g(\\d+)\\[id=\"([\\w\\d-]+)\"\\].*?\"([^\"]*)"));
200
- var outputSheet = function (sheet) {
201
- var tag = sheet.getTag();
202
- var length = tag.length;
203
- var css = '';
204
- var _loop_1 = function (group) {
205
- var id = getIdForGroup(group);
206
- if (id === undefined)
207
- return "continue";
208
- var names = sheet.names.get(id);
209
- var rules = tag.getGroup(group);
210
- if (names === undefined || rules.length === 0)
211
- return "continue";
212
- var selector = "".concat(SC_ATTR, ".g").concat(group, "[id=\"").concat(id, "\"]");
213
- var content = '';
214
- if (names !== undefined) {
215
- names.forEach(function (name) {
216
- if (name.length > 0) {
217
- content += "".concat(name, ",");
218
- }
219
- });
220
- }
221
- // NOTE: It's easier to collect rules and have the marker
222
- // after the actual rules to simplify the rehydration
223
- css += "".concat(rules).concat(selector, "{content:\"").concat(content, "\"}").concat(SPLITTER);
224
- };
225
- for (var group = 0; group < length; group++) {
226
- _loop_1(group);
227
- }
228
- return css;
229
- };
230
- var rehydrateNamesFromContent = function (sheet, id, content) {
231
- var names = content.split(',');
232
- var name;
233
- for (var i = 0, l = names.length; i < l; i++) {
234
- if ((name = names[i])) {
235
- sheet.registerName(id, name);
236
- }
237
- }
238
- };
239
- var rehydrateSheetFromTag = function (sheet, style) {
240
- var _a;
241
- var parts = ((_a = style.textContent) !== null && _a !== void 0 ? _a : '').split(SPLITTER);
242
- var rules = [];
243
- for (var i = 0, l = parts.length; i < l; i++) {
244
- var part = parts[i].trim();
245
- if (!part)
246
- continue;
247
- var marker = part.match(MARKER_RE);
248
- if (marker) {
249
- var group = parseInt(marker[1], 10) | 0;
250
- var id = marker[2];
251
- if (group !== 0) {
252
- // Rehydrate componentId to group index mapping
253
- setGroupForId(id, group);
254
- // Rehydrate names and rules
255
- // looks like: data-styled.g11[id="idA"]{content:"nameA,"}
256
- rehydrateNamesFromContent(sheet, id, marker[3]);
257
- sheet.getTag().insertRules(group, rules);
258
- }
259
- rules.length = 0;
260
- }
261
- else {
262
- rules.push(part);
263
- }
264
- }
265
- };
266
- var rehydrateSheet = function (sheet) {
267
- var nodes = document.querySelectorAll(SELECTOR);
268
- for (var i = 0, l = nodes.length; i < l; i++) {
269
- var node = nodes[i];
270
- if (node && node.getAttribute(SC_ATTR) !== SC_ATTR_ACTIVE) {
271
- rehydrateSheetFromTag(sheet, node);
272
- if (node.parentNode) {
273
- node.parentNode.removeChild(node);
274
- }
275
- }
276
- }
277
- };
278
-
279
- function getNonce() {
280
- return typeof __webpack_nonce__ !== 'undefined' ? __webpack_nonce__ : null;
281
- }
282
-
283
- var ELEMENT_TYPE = 1;
284
- /* Node.ELEMENT_TYPE */
285
- /** Find last style element if any inside target */
286
- var findLastStyleTag = function (target) {
287
- var childNodes = target.childNodes;
288
- for (var i = childNodes.length; i >= 0; i--) {
289
- var child = childNodes[i];
290
- if (child && child.nodeType === ELEMENT_TYPE && child.hasAttribute(SC_ATTR)) {
291
- return child;
292
- }
293
- }
294
- return undefined;
295
- };
296
- /** Create a style element inside `target` or <head> after the last */
297
- var makeStyleTag = function (target) {
298
- var head = document.head;
299
- var parent = target || head;
300
- var style = document.createElement('style');
301
- var prevStyle = findLastStyleTag(parent);
302
- var nextSibling = prevStyle !== undefined ? prevStyle.nextSibling : null;
303
- style.setAttribute(SC_ATTR, SC_ATTR_ACTIVE);
304
- style.setAttribute(SC_ATTR_VERSION, SC_VERSION);
305
- var nonce = getNonce();
306
- if (nonce)
307
- style.setAttribute('nonce', nonce);
308
- parent.insertBefore(style, nextSibling);
309
- return style;
310
- };
311
- /** Get the CSSStyleSheet instance for a given style element */
312
- var getSheet = function (tag) {
313
- if (tag.sheet) {
314
- return tag.sheet;
315
- }
316
- // Avoid Firefox quirk where the style element might not have a sheet property
317
- var styleSheets = document.styleSheets;
318
- for (var i = 0, l = styleSheets.length; i < l; i++) {
319
- var sheet = styleSheets[i];
320
- if (sheet.ownerNode === tag) {
321
- return sheet;
322
- }
323
- }
324
- throw throwStyledComponentsError(17);
325
- };
326
-
327
- /** Create a CSSStyleSheet-like tag depending on the environment */
328
- var makeTag = function (_a) {
329
- var isServer = _a.isServer, useCSSOMInjection = _a.useCSSOMInjection, target = _a.target;
330
- if (isServer) {
331
- return new VirtualTag(target);
332
- }
333
- else if (useCSSOMInjection) {
334
- return new CSSOMTag(target);
335
- }
336
- else {
337
- return new TextTag(target);
338
- }
339
- };
340
- var CSSOMTag = /** @class */ (function () {
341
- function CSSOMTag(target) {
342
- var element = (this.element = makeStyleTag(target));
343
- // Avoid Edge bug where empty style elements don't create sheets
344
- element.appendChild(document.createTextNode(''));
345
- this.sheet = getSheet(element);
346
- this.length = 0;
347
- }
348
- CSSOMTag.prototype.insertRule = function (index, rule) {
349
- try {
350
- this.sheet.insertRule(rule, index);
351
- this.length++;
352
- return true;
353
- }
354
- catch (_error) {
355
- return false;
356
- }
357
- };
358
- CSSOMTag.prototype.deleteRule = function (index) {
359
- this.sheet.deleteRule(index);
360
- this.length--;
361
- };
362
- CSSOMTag.prototype.getRule = function (index) {
363
- var rule = this.sheet.cssRules[index];
364
- // Avoid IE11 quirk where cssText is inaccessible on some invalid rules
365
- if (rule !== undefined && typeof rule.cssText === 'string') {
366
- return rule.cssText;
367
- }
368
- else {
369
- return '';
370
- }
371
- };
372
- return CSSOMTag;
373
- }());
374
- /** A Tag that emulates the CSSStyleSheet API but uses text nodes */
375
- var TextTag = /** @class */ (function () {
376
- function TextTag(target) {
377
- var element = (this.element = makeStyleTag(target));
378
- this.nodes = element.childNodes;
379
- this.length = 0;
380
- }
381
- TextTag.prototype.insertRule = function (index, rule) {
382
- if (index <= this.length && index >= 0) {
383
- var node = document.createTextNode(rule);
384
- var refNode = this.nodes[index];
385
- this.element.insertBefore(node, refNode || null);
386
- this.length++;
387
- return true;
388
- }
389
- else {
390
- return false;
391
- }
392
- };
393
- TextTag.prototype.deleteRule = function (index) {
394
- this.element.removeChild(this.nodes[index]);
395
- this.length--;
396
- };
397
- TextTag.prototype.getRule = function (index) {
398
- if (index < this.length) {
399
- return this.nodes[index].textContent;
400
- }
401
- else {
402
- return '';
403
- }
404
- };
405
- return TextTag;
406
- }());
407
- /** A completely virtual (server-side) Tag that doesn't manipulate the DOM */
408
- var VirtualTag = /** @class */ (function () {
409
- function VirtualTag(_target) {
410
- this.rules = [];
411
- this.length = 0;
412
- }
413
- VirtualTag.prototype.insertRule = function (index, rule) {
414
- if (index <= this.length) {
415
- this.rules.splice(index, 0, rule);
416
- this.length++;
417
- return true;
418
- }
419
- else {
420
- return false;
421
- }
422
- };
423
- VirtualTag.prototype.deleteRule = function (index) {
424
- this.rules.splice(index, 1);
425
- this.length--;
426
- };
427
- VirtualTag.prototype.getRule = function (index) {
428
- if (index < this.length) {
429
- return this.rules[index];
430
- }
431
- else {
432
- return '';
433
- }
434
- };
435
- return VirtualTag;
436
- }());
437
-
438
- var SHOULD_REHYDRATE = IS_BROWSER;
439
- var defaultOptions = {
440
- isServer: !IS_BROWSER,
441
- useCSSOMInjection: !DISABLE_SPEEDY,
442
- };
443
- /** Contains the main stylesheet logic for stringification and caching */
444
- var StyleSheet = /** @class */ (function () {
445
- function StyleSheet(options, globalStyles, names) {
446
- if (options === void 0) { options = EMPTY_OBJECT; }
447
- if (globalStyles === void 0) { globalStyles = {}; }
448
- this.options = __assign(__assign({}, defaultOptions), options);
449
- this.gs = globalStyles;
450
- this.names = new Map(names);
451
- this.server = !!options.isServer;
452
- // We rehydrate only once and use the sheet that is created first
453
- if (!this.server && IS_BROWSER && SHOULD_REHYDRATE) {
454
- SHOULD_REHYDRATE = false;
455
- rehydrateSheet(this);
456
- }
457
- }
458
- /** Register a group ID to give it an index */
459
- StyleSheet.registerId = function (id) {
460
- return getGroupForId(id);
461
- };
462
- StyleSheet.prototype.reconstructWithOptions = function (options, withNames) {
463
- if (withNames === void 0) { withNames = true; }
464
- return new StyleSheet(__assign(__assign({}, this.options), options), this.gs, (withNames && this.names) || undefined);
465
- };
466
- StyleSheet.prototype.allocateGSInstance = function (id) {
467
- return (this.gs[id] = (this.gs[id] || 0) + 1);
468
- };
469
- /** Lazily initialises a GroupedTag for when it's actually needed */
470
- StyleSheet.prototype.getTag = function () {
471
- return this.tag || (this.tag = makeGroupedTag(makeTag(this.options)));
472
- };
473
- /** Check whether a name is known for caching */
474
- StyleSheet.prototype.hasNameForId = function (id, name) {
475
- return this.names.has(id) && this.names.get(id).has(name);
476
- };
477
- /** Mark a group's name as known for caching */
478
- StyleSheet.prototype.registerName = function (id, name) {
479
- getGroupForId(id);
480
- if (!this.names.has(id)) {
481
- var groupNames = new Set();
482
- groupNames.add(name);
483
- this.names.set(id, groupNames);
484
- }
485
- else {
486
- this.names.get(id).add(name);
487
- }
488
- };
489
- /** Insert new rules which also marks the name as known */
490
- StyleSheet.prototype.insertRules = function (id, name, rules) {
491
- this.registerName(id, name);
492
- this.getTag().insertRules(getGroupForId(id), rules);
493
- };
494
- /** Clears all cached names for a given group ID */
495
- StyleSheet.prototype.clearNames = function (id) {
496
- if (this.names.has(id)) {
497
- this.names.get(id).clear();
498
- }
499
- };
500
- /** Clears all rules for a given group ID */
501
- StyleSheet.prototype.clearRules = function (id) {
502
- this.getTag().clearGroup(getGroupForId(id));
503
- this.clearNames(id);
504
- };
505
- /** Clears the entire tag which deletes all rules but not its names */
506
- StyleSheet.prototype.clearTag = function () {
507
- // NOTE: This does not clear the names, since it's only used during SSR
508
- // so that we can continuously output only new rules
509
- this.tag = undefined;
510
- };
511
- /** Outputs the current sheet as a CSS string with markers for SSR */
512
- StyleSheet.prototype.toString = function () {
513
- return outputSheet(this);
514
- };
515
- return StyleSheet;
516
- }());
517
-
518
- var SEED = 5381;
519
- // When we have separate strings it's useful to run a progressive
520
- // version of djb2 where we pretend that we're still looping over
521
- // the same string
522
- var phash = function (h, x) {
523
- var i = x.length;
524
- while (i) {
525
- h = (h * 33) ^ x.charCodeAt(--i);
526
- }
527
- return h;
528
- };
529
- // This is a djb2 hashing function
530
- var hash = function (x) {
531
- return phash(SEED, x);
532
- };
533
-
534
- var COMMENT_REGEX = /^\s*\/\/.*$/gm;
535
- var COMPLEX_SELECTOR_PREFIX = [':', '[', '.', '#'];
536
- /**
537
- * Serialize stylis output as an array of css strings. It is important that rules are
538
- * separated when using CSSOM injection.
539
- */
540
- function serialize(children, callback) {
541
- return children.map(function (c, i) { return callback(c, i, children, callback); }).filter(Boolean);
542
- }
543
- /**
544
- * Takes an element and recurses through it's rules added the namespace to the start of each selector.
545
- * Takes into account media queries by recursing through child rules if they are present.
546
- */
547
- function recursivelySetNamepace(compiled, namespace) {
548
- return compiled.map(function (rule) {
549
- if (rule.type === 'rule') {
550
- // add the namespace to the start
551
- rule.value = "".concat(namespace, " ").concat(rule.value);
552
- // add the namespace after each comma for subsequent selectors.
553
- // @ts-expect-error we target modern browsers but intentionally transpile to ES5 for speed
554
- rule.value = rule.value.replaceAll(',', ",".concat(namespace, " "));
555
- rule.props = rule.props.map(function (prop) {
556
- return "".concat(namespace, " ").concat(prop);
557
- });
558
- }
559
- if (Array.isArray(rule.children)) {
560
- rule.children = recursivelySetNamepace(rule.children, namespace);
561
- }
562
- return rule;
563
- });
564
- }
565
- function createStylisInstance(_a) {
566
- 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;
567
- var _componentId;
568
- var _selector;
569
- var _selectorRegexp;
570
- var _consecutiveSelfRefRegExp;
571
- var selfReferenceReplacer = function (match, offset, string) {
572
- if (
573
- // do not replace the first occurrence if it is complex (has a modifier)
574
- (offset === 0 ? !COMPLEX_SELECTOR_PREFIX.includes(string[_selector.length]) : true) && // no consecutive self refs (.b.b); that is a precedence boost and treated differently
575
- !string.match(_consecutiveSelfRefRegExp)) {
576
- return ".".concat(_componentId);
577
- }
578
- return match;
579
- };
580
- /**
581
- * When writing a style like
582
- *
583
- * & + & {
584
- * color: red;
585
- * }
586
- *
587
- * The second ampersand should be a reference to the static component class. stylis
588
- * has no knowledge of static class so we have to intelligently replace the base selector.
589
- *
590
- * https://github.com/thysultan/stylis.js/tree/v4.0.2#abstract-syntax-structure
591
- */
592
- var selfReferenceReplacementPlugin = function (element) {
593
- if (element.type === RULESET && element.value.includes('&')) {
594
- var props = element.props;
595
- props[0] = props[0].replace(_selectorRegexp, selfReferenceReplacer);
596
- }
597
- };
598
- var stringifyRules = function (css, selector,
599
- /**
600
- * This "prefix" referes to a _selector_ prefix.
601
- */
602
- prefix, componentId) {
603
- if (selector === void 0) { selector = ''; }
604
- if (prefix === void 0) { prefix = ''; }
605
- if (componentId === void 0) { componentId = '&'; }
606
- var flatCSS = css.replace(COMMENT_REGEX, '');
607
- // stylis has no concept of state to be passed to plugins
608
- // but since JS is single-threaded, we can rely on that to ensure
609
- // these properties stay in sync with the current stylis run
610
- _componentId = componentId;
611
- _selector = selector;
612
- _selectorRegexp = new RegExp("\\".concat(_selector, "\\b"), 'g');
613
- _consecutiveSelfRefRegExp = new RegExp("(\\".concat(_selector, "\\b){2,}"));
614
- var middlewares = plugins.slice();
615
- /**
616
- * Enables automatic vendor-prefixing for styles.
617
- */
618
- if (options.prefix || options.prefix === undefined) {
619
- middlewares.unshift(prefixer);
620
- }
621
- middlewares.push(selfReferenceReplacementPlugin, stringify);
622
- var compiled = compile(prefix || selector ? "".concat(prefix, " ").concat(selector, " { ").concat(flatCSS, " }") : flatCSS);
623
- if (options.namespace) {
624
- compiled = recursivelySetNamepace(compiled, options.namespace);
625
- }
626
- return serialize(compiled, middleware(middlewares));
627
- };
628
- stringifyRules.hash = plugins.length
629
- ? plugins
630
- .reduce(function (acc, plugin) {
631
- if (!plugin.name) {
632
- throwStyledComponentsError(15);
633
- }
634
- return phash(acc, plugin.name);
635
- }, SEED)
636
- .toString()
637
- : '';
638
- return stringifyRules;
639
- }
640
-
641
- var StyleSheetContext = React.createContext({
642
- shouldForwardProp: undefined,
643
- styleSheet: undefined,
644
- });
645
- StyleSheetContext.Consumer;
646
- var StylisContext = React.createContext(undefined);
647
- StylisContext.Consumer;
648
- new StyleSheet();
649
- var mainStylis = createStylisInstance();
650
-
651
- var Keyframes = /** @class */ (function () {
652
- function Keyframes(name, rules) {
653
- var _this = this;
654
- this.inject = function (styleSheet, stylisInstance) {
655
- if (stylisInstance === void 0) { stylisInstance = mainStylis; }
656
- var resolvedName = _this.name + stylisInstance.hash;
657
- if (!styleSheet.hasNameForId(_this.id, resolvedName)) {
658
- styleSheet.insertRules(_this.id, resolvedName, stylisInstance(_this.rules, resolvedName, '@keyframes'));
659
- }
660
- };
661
- this.toString = function () {
662
- throw throwStyledComponentsError(12, String(_this.name));
663
- };
664
- this.name = name;
665
- this.id = "sc-keyframes-".concat(name);
666
- this.rules = rules;
667
- }
668
- Keyframes.prototype.getName = function (stylisInstance) {
669
- if (stylisInstance === void 0) { stylisInstance = mainStylis; }
670
- return this.name + stylisInstance.hash;
671
- };
672
- return Keyframes;
673
- }());
674
-
675
- // Taken from https://github.com/facebook/react/blob/b87aabdfe1b7461e7331abb3601d9e6bb27544bc/packages/react-dom/src/shared/dangerousStyleValue.js
676
- function addUnitIfNeeded(name, value) {
677
- // https://github.com/amilajack/eslint-plugin-flowtype-errors/issues/133
678
- if (value == null || typeof value === 'boolean' || value === '') {
679
- return '';
680
- }
681
- if (typeof value === 'number' && value !== 0 && !(name in unitless)) {
682
- return "".concat(value, "px"); // Presumes implicit 'px' suffix for unitless numbers
683
- }
684
- return String(value).trim();
685
- }
686
-
687
- function getComponentName(target) {
688
- return ((process.env.NODE_ENV !== 'production' ? typeof target === 'string' && target : false) ||
689
- target.displayName ||
690
- target.name ||
691
- 'Component');
692
- }
693
-
694
- /**
695
- * inlined version of
696
- * https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
697
- */
698
- var uppercaseCheck = /[A-Z]/;
699
- var uppercasePattern = /[A-Z]/g;
700
- var msPattern = /^ms-/;
701
- var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase()); };
702
- /**
703
- * Hyphenates a camelcased CSS property name, for example:
704
- *
705
- * > hyphenateStyleName('backgroundColor')
706
- * < "background-color"
707
- * > hyphenateStyleName('MozTransition')
708
- * < "-moz-transition"
709
- * > hyphenateStyleName('msTransition')
710
- * < "-ms-transition"
711
- *
712
- * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
713
- * is converted to `-ms-`.
714
- */
715
- function hyphenateStyleName(string) {
716
- return uppercaseCheck.test(string) && !string.startsWith('--')
717
- ? string.replace(uppercasePattern, prefixAndLowerCase).replace(msPattern, '-ms-')
718
- : string;
719
- }
720
-
721
- function isFunction(test) {
722
- return typeof test === 'function';
723
- }
724
-
725
- function isPlainObject(x) {
726
- return (x !== null &&
727
- typeof x === 'object' &&
728
- /* a check for empty prototype would be more typical, but that
729
- doesn't play well with objects created in different vm contexts */
730
- (!x.constructor || x.constructor.name === 'Object') &&
731
- (x.toString ? x.toString() : Object.prototype.toString.call(x)) === '[object Object]' &&
732
- /* check for reasonable markers that the object isn't an element for react & preact/compat */
733
- !('props' in x && (x.$$typeof || x.constructor === undefined)));
734
- }
735
-
736
- function isStatelessFunction(test) {
737
- return typeof test === 'function' && !(test.prototype && test.prototype.isReactComponent);
738
- }
739
-
740
- function isStyledComponent(target) {
741
- return typeof target === 'object' && 'styledComponentId' in target;
742
- }
743
-
744
- /**
745
- * It's falsish not falsy because 0 is allowed.
746
- */
747
- var isFalsish = function (chunk) {
748
- return chunk === undefined || chunk === null || chunk === false || chunk === '';
749
- };
750
- var objToCssArray = function (obj, prevKey) {
751
- var rules = [];
752
- for (var key in obj) {
753
- if (!obj.hasOwnProperty(key) || isFalsish(obj[key]))
754
- continue;
755
- if ((Array.isArray(obj[key]) && obj[key].isCss) || isFunction(obj[key])) {
756
- rules.push("".concat(hyphenateStyleName(key), ":"), obj[key], ';');
757
- }
758
- else if (isPlainObject(obj[key])) {
759
- rules.push.apply(rules, objToCssArray(obj[key], key));
760
- }
761
- else {
762
- rules.push("".concat(hyphenateStyleName(key), ": ").concat(addUnitIfNeeded(key, obj[key]), ";"));
763
- }
764
- }
765
- return prevKey ? __spreadArray(__spreadArray(["".concat(prevKey, " {")], rules, true), ['}'], false) : rules;
766
- };
767
- function flatten(chunk, executionContext, styleSheet, stylisInstance) {
768
- if (Array.isArray(chunk)) {
769
- var ruleSet = [];
770
- for (var i = 0, len = chunk.length, result = void 0; i < len; i += 1) {
771
- result = flatten(chunk[i], executionContext, styleSheet, stylisInstance);
772
- if (result.length === 0)
773
- continue;
774
- ruleSet.push.apply(ruleSet, result);
775
- }
776
- return ruleSet;
777
- }
778
- if (isFalsish(chunk)) {
779
- return [];
780
- }
781
- /* Handle other components */
782
- if (isStyledComponent(chunk)) {
783
- return [".".concat(chunk.styledComponentId)];
784
- }
785
- /* Either execute or defer the function */
786
- if (isFunction(chunk)) {
787
- if (isStatelessFunction(chunk) && executionContext) {
788
- var chunkFn = chunk;
789
- var result = chunkFn(executionContext);
790
- if (process.env.NODE_ENV !== 'production' &&
791
- typeof result === 'object' &&
792
- !Array.isArray(result) &&
793
- !(result instanceof Keyframes) &&
794
- !isPlainObject(result) &&
795
- result !== null) {
796
- console.error("".concat(getComponentName(chunkFn), " 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."));
797
- }
798
- return flatten(result, executionContext, styleSheet, stylisInstance);
799
- }
800
- else {
801
- return [chunk];
802
- }
803
- }
804
- if (chunk instanceof Keyframes) {
805
- if (styleSheet) {
806
- chunk.inject(styleSheet, stylisInstance);
807
- return [chunk.getName(stylisInstance)];
808
- }
809
- else {
810
- return [chunk];
811
- }
812
- }
813
- /* Handle objects */
814
- return isPlainObject(chunk) ? objToCssArray(chunk) : [chunk.toString()];
815
- }
816
-
817
- function interleave(strings, interpolations) {
818
- var result = [strings[0]];
819
- for (var i = 0, len = interpolations.length; i < len; i += 1) {
820
- result.push(interpolations[i], strings[i + 1]);
821
- }
822
- return result;
823
- }
824
-
825
- /**
826
- * Used when flattening object styles to determine if we should
827
- * expand an array of styles.
828
- */
829
- var addTag = function (arg) {
830
- return Object.assign(arg, { isCss: true });
831
- };
832
- function css(styles) {
833
- var interpolations = [];
834
- for (var _i = 1; _i < arguments.length; _i++) {
835
- interpolations[_i - 1] = arguments[_i];
836
- }
837
- if (isFunction(styles) || isPlainObject(styles)) {
838
- var styleFunctionOrObject = styles;
839
- return addTag(flatten(interleave(EMPTY_ARRAY, __spreadArray([
840
- styleFunctionOrObject
841
- ], interpolations, true))));
842
- }
843
- var styleStringArray = styles;
844
- if (interpolations.length === 0 &&
845
- styleStringArray.length === 1 &&
846
- typeof styleStringArray[0] === 'string') {
847
- return flatten(styleStringArray);
848
- }
849
- return addTag(flatten(interleave(styleStringArray, interpolations)));
850
- }
851
-
852
- function constructWithOptions(componentConstructor, tag, options) {
853
- if (options === void 0) { options = EMPTY_OBJECT; }
854
- // We trust that the tag is a valid component as long as it isn't falsish
855
- // Typically the tag here is a string or function (i.e. class or pure function component)
856
- // However a component may also be an object if it uses another utility, e.g. React.memo
857
- // React will output an appropriate warning however if the `tag` isn't valid
858
- if (!tag) {
859
- throw throwStyledComponentsError(1, tag);
860
- }
861
- /* This is callable directly as a template function */
862
- var templateFunction = function (initialStyles) {
863
- var interpolations = [];
864
- for (var _i = 1; _i < arguments.length; _i++) {
865
- interpolations[_i - 1] = arguments[_i];
866
- }
867
- return componentConstructor(tag, options, css.apply(void 0, __spreadArray([initialStyles], interpolations, false)));
868
- };
869
- /* Modify/inject new props at runtime */
870
- templateFunction.attrs = function (attrs) {
871
- return constructWithOptions(componentConstructor, tag, __assign(__assign({}, options), { attrs: Array.prototype.concat(options.attrs, attrs).filter(Boolean) }));
872
- };
873
- /**
874
- * If config methods are called, wrap up a new template function and merge options */
875
- templateFunction.withConfig = function (config) {
876
- return constructWithOptions(componentConstructor, tag, __assign(__assign({}, options), config));
877
- };
878
- return templateFunction;
879
- }
880
-
881
- var ThemeContext = React.createContext(undefined);
882
- var ThemeConsumer = ThemeContext.Consumer;
883
- function mergeTheme(theme, outerTheme) {
884
- if (!theme) {
885
- throw throwStyledComponentsError(14);
886
- }
887
- if (isFunction(theme)) {
888
- var themeFn = theme;
889
- var mergedTheme = themeFn(outerTheme);
890
- if (process.env.NODE_ENV !== 'production' &&
891
- (mergedTheme === null || Array.isArray(mergedTheme) || typeof mergedTheme !== 'object')) {
892
- throw throwStyledComponentsError(7);
893
- }
894
- return mergedTheme;
895
- }
896
- if (Array.isArray(theme) || typeof theme !== 'object') {
897
- throw throwStyledComponentsError(8);
898
- }
899
- return outerTheme ? __assign(__assign({}, outerTheme), theme) : theme;
900
- }
901
- /**
902
- * Provide a theme to an entire react component tree via context
903
- */
904
- function ThemeProvider(props) {
905
- var outerTheme = useContext(ThemeContext);
906
- var themeContext = useMemo(function () { return mergeTheme(props.theme, outerTheme); }, [props.theme, outerTheme]);
907
- if (!props.children) {
908
- return null;
909
- }
910
- return React.createElement(ThemeContext.Provider, { value: themeContext }, props.children);
911
- }
912
-
913
- function determineTheme(props, providedTheme, defaultProps) {
914
- if (defaultProps === void 0) { defaultProps = EMPTY_OBJECT; }
915
- return (props.theme !== defaultProps.theme && props.theme) || providedTheme || defaultProps.theme;
916
- }
917
-
918
- var _a;
919
- var hasSymbol = typeof Symbol === 'function' && Symbol.for;
920
- // copied from react-is
921
- var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
922
- var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
923
- /**
924
- * Adapted from hoist-non-react-statics to avoid the react-is dependency.
925
- */
926
- var REACT_STATICS = {
927
- childContextTypes: true,
928
- contextType: true,
929
- contextTypes: true,
930
- defaultProps: true,
931
- displayName: true,
932
- getDefaultProps: true,
933
- getDerivedStateFromError: true,
934
- getDerivedStateFromProps: true,
935
- mixins: true,
936
- propTypes: true,
937
- type: true,
938
- };
939
- var KNOWN_STATICS = {
940
- name: true,
941
- length: true,
942
- prototype: true,
943
- caller: true,
944
- callee: true,
945
- arguments: true,
946
- arity: true,
947
- };
948
- var FORWARD_REF_STATICS = {
949
- $$typeof: true,
950
- render: true,
951
- defaultProps: true,
952
- displayName: true,
953
- propTypes: true,
954
- };
955
- var MEMO_STATICS = {
956
- $$typeof: true,
957
- compare: true,
958
- defaultProps: true,
959
- displayName: true,
960
- propTypes: true,
961
- type: true,
962
- };
963
- var TYPE_STATICS = (_a = {},
964
- _a[REACT_FORWARD_REF_TYPE] = FORWARD_REF_STATICS,
965
- _a[REACT_MEMO_TYPE] = MEMO_STATICS,
966
- _a);
967
- // adapted from react-is
968
- function isMemo(object) {
969
- var $$typeofType = 'type' in object && object.type.$$typeof;
970
- return $$typeofType === REACT_MEMO_TYPE;
971
- }
972
- function getStatics(component) {
973
- // React v16.11 and below
974
- if (isMemo(component)) {
975
- return MEMO_STATICS;
976
- }
977
- // React v16.12 and above
978
- return '$$typeof' in component
979
- ? TYPE_STATICS[component['$$typeof']]
980
- : REACT_STATICS;
981
- }
982
- var defineProperty = Object.defineProperty;
983
- var getOwnPropertyNames = Object.getOwnPropertyNames;
984
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
985
- var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
986
- var getPrototypeOf = Object.getPrototypeOf;
987
- var objectPrototype = Object.prototype;
988
- function hoistNonReactStatics(targetComponent, sourceComponent, excludelist) {
989
- if (typeof sourceComponent !== 'string') {
990
- // don't hoist over string (html) components
991
- if (objectPrototype) {
992
- var inheritedComponent = getPrototypeOf(sourceComponent);
993
- if (inheritedComponent && inheritedComponent !== objectPrototype) {
994
- hoistNonReactStatics(targetComponent, inheritedComponent, excludelist);
995
- }
996
- }
997
- var keys = getOwnPropertyNames(sourceComponent);
998
- if (getOwnPropertySymbols) {
999
- keys = keys.concat(getOwnPropertySymbols(sourceComponent));
1000
- }
1001
- var targetStatics = getStatics(targetComponent);
1002
- var sourceStatics = getStatics(sourceComponent);
1003
- for (var i = 0; i < keys.length; ++i) {
1004
- var key = keys[i];
1005
- if (!(key in KNOWN_STATICS) &&
1006
- !(excludelist && excludelist[key]) &&
1007
- !(sourceStatics && key in sourceStatics) &&
1008
- !(targetStatics && key in targetStatics)) {
1009
- var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
1010
- try {
1011
- // Avoid failures from read-only properties
1012
- defineProperty(targetComponent, key, descriptor);
1013
- }
1014
- catch (e) {
1015
- /* ignore */
1016
- }
1017
- }
1018
- }
1019
- }
1020
- return targetComponent;
1021
- }
1022
-
1023
- function withTheme(Component) {
1024
- var WithTheme = React.forwardRef(function (props, ref) {
1025
- var theme = React.useContext(ThemeContext);
1026
- var themeProp = determineTheme(props, theme, Component.defaultProps);
1027
- if (process.env.NODE_ENV !== 'production' && themeProp === undefined) {
1028
- 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), "\""));
1029
- }
1030
- return React.createElement(Component, __assign({}, props, { theme: themeProp, ref: ref }));
1031
- });
1032
- WithTheme.displayName = "WithTheme(".concat(getComponentName(Component), ")");
1033
- return hoistNonReactStatics(WithTheme, Component);
1034
- }
1035
-
1036
- var useTheme = function () { return useContext(ThemeContext); };
1037
-
1038
- var AD_REPLACER_R = /(a)(d)/gi;
1039
- /* This is the "capacity" of our alphabet i.e. 2x26 for all letters plus their capitalised
1040
- * counterparts */
1041
- var charsLength = 52;
1042
- /* start at 75 for 'a' until 'z' (25) and then start at 65 for capitalised letters */
1043
- var getAlphabeticChar = function (code) { return String.fromCharCode(code + (code > 25 ? 39 : 97)); };
1044
- /* input a number, usually a hash and convert it to base-52 */
1045
- function generateAlphabeticName(code) {
1046
- var name = '';
1047
- var x;
1048
- /* get a char and divide by alphabet-length */
1049
- for (x = Math.abs(code); x > charsLength; x = (x / charsLength) | 0) {
1050
- name = getAlphabeticChar(x % charsLength) + name;
1051
- }
1052
- return (getAlphabeticChar(x % charsLength) + name).replace(AD_REPLACER_R, '$1-$2');
1053
- }
1054
-
1055
- function generateComponentId(str) {
1056
- return generateAlphabeticName(hash(str) >>> 0);
1057
- }
1058
-
1059
- var generated = {};
1060
- /**
1061
- * InlineStyle takes arbitrary CSS and generates a flat object
1062
- */
1063
- function makeInlineStyleClass(styleSheet) {
1064
- var InlineStyle = /** @class */ (function () {
1065
- function InlineStyle(rules) {
1066
- this.rules = rules;
1067
- }
1068
- InlineStyle.prototype.generateStyleObject = function (executionContext) {
1069
- // keyframes, functions, and component selectors are not allowed for React Native
1070
- var flatCSS = flatten(this.rules, executionContext).join('');
1071
- var hash = generateComponentId(flatCSS);
1072
- if (!generated[hash]) {
1073
- var root = parse(flatCSS);
1074
- var declPairs_1 = [];
1075
- root.each(function (node) {
1076
- if (node.type === 'decl') {
1077
- declPairs_1.push([node.prop, node.value]);
1078
- }
1079
- else if (process.env.NODE_ENV !== 'production' && node.type !== 'comment') {
1080
- console.warn("Node of type ".concat(node.type, " not supported as an inline style"));
1081
- }
1082
- });
1083
- var styleObject = transformDeclPairs(declPairs_1);
1084
- var styles = styleSheet.create({
1085
- generated: styleObject,
1086
- });
1087
- generated[hash] = styles.generated;
1088
- }
1089
- return generated[hash];
1090
- };
1091
- return InlineStyle;
1092
- }());
1093
- return InlineStyle;
1094
- }
1095
-
1096
- function isTag(target) {
1097
- return (typeof target === 'string' &&
1098
- (process.env.NODE_ENV !== 'production'
1099
- ? target.charAt(0) === target.charAt(0).toLowerCase()
1100
- : true));
1101
- }
1102
-
1103
- function generateDisplayName(target) {
1104
- return isTag(target) ? "styled.".concat(target) : "Styled(".concat(getComponentName(target), ")");
1105
- }
1106
-
1107
- function mixinRecursively(target, source, forceMerge) {
1108
- if (forceMerge === void 0) { forceMerge = false; }
1109
- /* only merge into POJOs, Arrays, but for top level objects only
1110
- * allow to merge into anything by passing forceMerge = true */
1111
- if (!forceMerge && !isPlainObject(target) && !Array.isArray(target)) {
1112
- return source;
1113
- }
1114
- if (Array.isArray(source)) {
1115
- for (var key = 0; key < source.length; key++) {
1116
- target[key] = mixinRecursively(target[key], source[key]);
1117
- }
1118
- }
1119
- else if (isPlainObject(source)) {
1120
- for (var key in source) {
1121
- target[key] = mixinRecursively(target[key], source[key]);
1122
- }
1123
- }
1124
- return target;
1125
- }
1126
- /**
1127
- * Arrays & POJOs merged recursively, other objects and value types are overridden
1128
- * If target is not a POJO or an Array, it will get source properties injected via shallow merge
1129
- * Source objects applied left to right. Mutates & returns target. Similar to lodash merge.
1130
- */
1131
- function mixinDeep(target) {
1132
- var sources = [];
1133
- for (var _i = 1; _i < arguments.length; _i++) {
1134
- sources[_i - 1] = arguments[_i];
1135
- }
1136
- for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) {
1137
- var source = sources_1[_a];
1138
- mixinRecursively(target, source, true);
1139
- }
1140
- return target;
1141
- }
1142
-
1143
- function useResolvedAttrs(theme, props, attrs) {
1144
- if (theme === void 0) { theme = EMPTY_OBJECT; }
1145
- // NOTE: can't memoize this
1146
- // returns [context, resolvedAttrs]
1147
- // where resolvedAttrs is only the things injected by the attrs themselves
1148
- var context = __assign(__assign({}, props), { theme: theme });
1149
- var resolvedAttrs = {};
1150
- attrs.forEach(function (attrDef) {
1151
- var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(context) : attrDef;
1152
- var key;
1153
- for (key in resolvedAttrDef) {
1154
- // @ts-expect-error bad types
1155
- context[key] = resolvedAttrs[key] = resolvedAttrDef[key];
1156
- }
1157
- });
1158
- return [context, resolvedAttrs];
1159
- }
1160
- function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
1161
- var componentAttrs = forwardedComponent.attrs, inlineStyle = forwardedComponent.inlineStyle, defaultProps = forwardedComponent.defaultProps, shouldForwardProp = forwardedComponent.shouldForwardProp, target = forwardedComponent.target;
1162
- // NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
1163
- // but that'd be against the rules-of-hooks. We could be naughty and do it anyway as it
1164
- // should be an immutable value, but behave for now.
1165
- var theme = determineTheme(props, useContext(ThemeContext), defaultProps);
1166
- var _a = useResolvedAttrs(theme || EMPTY_OBJECT, props, componentAttrs), context = _a[0], attrs = _a[1];
1167
- var generatedStyles = inlineStyle.generateStyleObject(context);
1168
- var refToForward = forwardedRef;
1169
- var elementToBeCreated = attrs.as || props.as || target;
1170
- var computedProps = attrs !== props ? __assign(__assign({}, props), attrs) : props;
1171
- var propsForElement = {};
1172
- for (var key in computedProps) {
1173
- if (key[0] === '$' || key === 'as')
1174
- continue;
1175
- else if (key === 'forwardedAs') {
1176
- propsForElement.as = computedProps[key];
1177
- }
1178
- else if (!shouldForwardProp || shouldForwardProp(key, elementToBeCreated)) {
1179
- propsForElement[key] = computedProps[key];
1180
- }
1181
- }
1182
- propsForElement.style = useMemo(function () {
1183
- return typeof props.style === 'function'
1184
- ? function (state) { return [generatedStyles].concat(props.style(state)); }
1185
- : props.style
1186
- ? [generatedStyles].concat(props.style)
1187
- : generatedStyles;
1188
- }, [props.style, generatedStyles]);
1189
- propsForElement.ref = refToForward;
1190
- return createElement(elementToBeCreated, propsForElement);
1191
- }
1192
- var _StyledNativeComponent = (function (InlineStyle) {
1193
- var createStyledNativeComponent = function (target, options, rules) {
1194
- var isTargetStyledComp = isStyledComponent(target);
1195
- var styledComponentTarget = target;
1196
- var _a = options.displayName, displayName = _a === void 0 ? generateDisplayName(target) : _a, _b = options.attrs, attrs = _b === void 0 ? EMPTY_ARRAY : _b;
1197
- // fold the underlying StyledComponent attrs up (implicit extend)
1198
- var finalAttrs = isTargetStyledComp && styledComponentTarget.attrs
1199
- ? styledComponentTarget.attrs.concat(attrs).filter(Boolean)
1200
- : attrs;
1201
- var shouldForwardProp = options.shouldForwardProp;
1202
- if (isTargetStyledComp && styledComponentTarget.shouldForwardProp) {
1203
- var shouldForwardPropFn_1 = styledComponentTarget.shouldForwardProp;
1204
- if (options.shouldForwardProp) {
1205
- var passedShouldForwardPropFn_1 = options.shouldForwardProp;
1206
- // compose nested shouldForwardProp calls
1207
- shouldForwardProp = function (prop, elementToBeCreated) {
1208
- return shouldForwardPropFn_1(prop, elementToBeCreated) &&
1209
- passedShouldForwardPropFn_1(prop, elementToBeCreated);
1210
- };
1211
- }
1212
- else {
1213
- shouldForwardProp = shouldForwardPropFn_1;
1214
- }
1215
- }
1216
- var forwardRef = function (props, ref) {
1217
- return useStyledComponentImpl(WrappedStyledComponent, props, ref);
1218
- };
1219
- forwardRef.displayName = displayName;
1220
- /**
1221
- * forwardRef creates a new interim component, which we'll take advantage of
1222
- * instead of extending ParentComponent to create _another_ interim class
1223
- */
1224
- var WrappedStyledComponent = React.forwardRef(forwardRef);
1225
- WrappedStyledComponent.attrs = finalAttrs;
1226
- WrappedStyledComponent.inlineStyle = new InlineStyle(isTargetStyledComp ? styledComponentTarget.inlineStyle.rules.concat(rules) : rules);
1227
- WrappedStyledComponent.displayName = displayName;
1228
- WrappedStyledComponent.shouldForwardProp = shouldForwardProp;
1229
- // @ts-expect-error we don't actually need this for anything other than detection of a styled-component
1230
- WrappedStyledComponent.styledComponentId = true;
1231
- // fold the underlying StyledComponent target up since we folded the styles
1232
- WrappedStyledComponent.target = isTargetStyledComp ? styledComponentTarget.target : target;
1233
- Object.defineProperty(WrappedStyledComponent, 'defaultProps', {
1234
- get: function () {
1235
- return this._foldedDefaultProps;
1236
- },
1237
- set: function (obj) {
1238
- this._foldedDefaultProps = isTargetStyledComp
1239
- ? mixinDeep({}, styledComponentTarget.defaultProps, obj)
1240
- : obj;
1241
- },
1242
- });
1243
- hoistNonReactStatics(WrappedStyledComponent, target, {
1244
- // all SC-specific things should not be hoisted
1245
- attrs: true,
1246
- inlineStyle: true,
1247
- displayName: true,
1248
- shouldForwardProp: true,
1249
- target: true,
1250
- });
1251
- return WrappedStyledComponent;
1252
- };
1253
- return createStyledNativeComponent;
1254
- });
1255
-
1256
- var reactNative = require('react-native');
1257
- var InlineStyle = makeInlineStyleClass(reactNative.StyleSheet);
1258
- var StyledNativeComponent = _StyledNativeComponent(InlineStyle);
1259
- var baseStyled = function (tag) {
1260
- return constructWithOptions(StyledNativeComponent, tag);
1261
- };
1262
- /* React native lazy-requires each of these modules for some reason, so let's
1263
- * assume it's for a good reason and not eagerly load them all */
1264
- var aliases = [
1265
- 'ActivityIndicator',
1266
- 'Button',
1267
- 'DatePickerIOS',
1268
- 'DrawerLayoutAndroid',
1269
- 'FlatList',
1270
- 'Image',
1271
- 'ImageBackground',
1272
- 'KeyboardAvoidingView',
1273
- 'Modal',
1274
- 'Pressable',
1275
- 'ProgressBarAndroid',
1276
- 'ProgressViewIOS',
1277
- 'RefreshControl',
1278
- 'SafeAreaView',
1279
- 'ScrollView',
1280
- 'SectionList',
1281
- 'Slider',
1282
- 'Switch',
1283
- 'Text',
1284
- 'TextInput',
1285
- 'TouchableHighlight',
1286
- 'TouchableOpacity',
1287
- 'View',
1288
- 'VirtualizedList',
1289
- ];
1290
- var styled = baseStyled;
1291
- /* Define a getter for each alias which simply gets the reactNative component
1292
- * and passes it to styled */
1293
- aliases.forEach(function (alias) {
1294
- return Object.defineProperty(styled, alias, {
1295
- enumerable: true,
1296
- configurable: false,
1297
- get: function () {
1298
- if (alias in reactNative && reactNative[alias]) {
1299
- return styled(reactNative[alias]);
1300
- }
1301
- throw new Error("".concat(alias, " is not available in the currently-installed version of react-native"));
1302
- },
1303
- });
1304
- });
1305
-
1306
- export { ThemeConsumer, ThemeContext, ThemeProvider, css, styled as default, isStyledComponent, styled, useTheme, withTheme };
1
+ import{__spreadArray as e,__assign as t}from"tslib";import n,{useMemo as r,useContext as o,createElement as i}from"react";import"shallowequal";import{prefixer as s,stringify as a,RULESET as c,compile as u,middleware as l}from"stylis";import p from"@emotion/unitless";import h from"css-to-react-native";import{parse as f}from"postcss";var d=Object.freeze([]),y=Object.freeze({}),m="production"!==process.env.NODE_ENV?{1:"Cannot create styled-component for component: %s.\n\n",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",3:"Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n",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",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",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",7:'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n',8:'ThemeProvider: Please make your "theme" prop an object.\n\n',9:"Missing document `<head>`\n\n",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",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",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",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",14:'ThemeProvider: "theme" prop is required.\n\n',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",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",17:"CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n"}:{};function v(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=e[0],r=[],o=1,i=e.length;o<i;o+=1)r.push(e[o]);return r.forEach(function(e){n=n.replace(/%[a-z]/,e)}),n}function g(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return"production"===process.env.NODE_ENV?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(n.length>0?" Args: ".concat(n.join(", ")):"")):new Error(v.apply(void 0,e([m[t]],n,!1)).trim())}var S="undefined"!=typeof process&&void 0!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",w="undefined"!=typeof window&&"HTMLElement"in window,b=Boolean("boolean"==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&""!==process.env.REACT_APP_SC_DISABLE_SPEEDY?"false"!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&process.env.REACT_APP_SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.SC_DISABLE_SPEEDY&&""!==process.env.SC_DISABLE_SPEEDY?"false"!==process.env.SC_DISABLE_SPEEDY&&process.env.SC_DISABLE_SPEEDY:"production"!==process.env.NODE_ENV),E=function(){function e(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e}return e.prototype.indexOfGroup=function(e){for(var t=0,n=0;n<e;n++)t+=this.groupSizes[n];return t},e.prototype.insertRules=function(e,t){if(e>=this.groupSizes.length){for(var n=this.groupSizes,r=n.length,o=r;e>=o;)if((o<<=1)<0)throw g(16,"".concat(e));this.groupSizes=new Uint32Array(o),this.groupSizes.set(n),this.length=o;for(var i=r;i<o;i++)this.groupSizes[i]=0}for(var s=this.indexOfGroup(e+1),a=(i=0,t.length);i<a;i++)this.tag.insertRule(s,t[i])&&(this.groupSizes[e]++,s++)},e.prototype.clearGroup=function(e){if(e<this.length){var t=this.groupSizes[e],n=this.indexOfGroup(e),r=n+t;this.groupSizes[e]=0;for(var o=n;o<r;o++)this.tag.deleteRule(n)}},e.prototype.getGroup=function(e){var t="";if(e>=this.length||0===this.groupSizes[e])return t;for(var n=this.groupSizes[e],r=this.indexOfGroup(e),o=r+n,i=r;i<o;i++)t+="".concat(this.tag.getRule(i)).concat("/*!sc*/\n");return t},e}(),A=new Map,P=new Map,_=1,N=function(e){if(A.has(e))return A.get(e);for(;P.has(_);)_++;var t=_++;if("production"!==process.env.NODE_ENV&&((0|t)<0||t>1073741824))throw g(16,"".concat(t));return A.set(e,t),P.set(t,e),t},C=function(e,t){A.set(e,t),P.set(t,e)},T="style[".concat(S,"][").concat("data-styled-version",'="').concat("6.0.0-beta.14",'"]'),D=new RegExp("^".concat(S,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),O=function(e,t,n){for(var r,o=n.split(","),i=0,s=o.length;i<s;i++)(r=o[i])&&e.registerName(t,r)},R=function(e,t){for(var n,r=(null!==(n=t.textContent)&&void 0!==n?n:"").split("/*!sc*/\n"),o=[],i=0,s=r.length;i<s;i++){var a=r[i].trim();if(a){var c=a.match(D);if(c){var u=0|parseInt(c[1],10),l=c[2];0!==u&&(C(l,u),O(e,l,c[3]),e.getTag().insertRules(u,o)),o.length=0}else o.push(a)}}},j=function(e){var t=document.head,n=e||t,r=document.createElement("style"),o=function(e){for(var t=e.childNodes,n=t.length;n>=0;n--){var r=t[n];if(r&&1===r.nodeType&&r.hasAttribute(S))return r}}(n),i=void 0!==o?o.nextSibling:null;r.setAttribute(S,"active"),r.setAttribute("data-styled-version","6.0.0-beta.14");var s="undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null;return s&&r.setAttribute("nonce",s),n.insertBefore(r,i),r},x=function(){function e(e){this.element=j(e),this.element.appendChild(document.createTextNode("")),this.sheet=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets,n=0,r=t.length;n<r;n++){var o=t[n];if(o.ownerNode===e)return o}throw g(17)}(this.element),this.length=0}return e.prototype.insertRule=function(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return!1}},e.prototype.deleteRule=function(e){this.sheet.deleteRule(e),this.length--},e.prototype.getRule=function(e){var t=this.sheet.cssRules[e];return t&&t.cssText?t.cssText:""},e}(),I=function(){function e(e){this.element=j(e),this.nodes=this.element.childNodes,this.length=0}return e.prototype.insertRule=function(e,t){if(e<=this.length&&e>=0){var n=document.createTextNode(t);return this.element.insertBefore(n,this.nodes[e]||null),this.length++,!0}return!1},e.prototype.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--},e.prototype.getRule=function(e){return e<this.length?this.nodes[e].textContent:""},e}(),B=function(){function e(e){this.rules=[],this.length=0}return e.prototype.insertRule=function(e,t){return e<=this.length&&(this.rules.splice(e,0,t),this.length++,!0)},e.prototype.deleteRule=function(e){this.rules.splice(e,1),this.length--},e.prototype.getRule=function(e){return e<this.length?this.rules[e]:""},e}(),L=w,z={isServer:!w,useCSSOMInjection:!b},V=function(){function e(e,n,r){void 0===e&&(e=y),void 0===n&&(n={}),this.options=t(t({},z),e),this.gs=n,this.names=new Map(r),this.server=!!e.isServer,!this.server&&w&&L&&(L=!1,function(e){for(var t=document.querySelectorAll(T),n=0,r=t.length;n<r;n++){var o=t[n];o&&"active"!==o.getAttribute(S)&&(R(e,o),o.parentNode&&o.parentNode.removeChild(o))}}(this))}return e.registerId=function(e){return N(e)},e.prototype.reconstructWithOptions=function(n,r){return void 0===r&&(r=!0),new e(t(t({},this.options),n),this.gs,r&&this.names||void 0)},e.prototype.allocateGSInstance=function(e){return this.gs[e]=(this.gs[e]||0)+1},e.prototype.getTag=function(){return this.tag||(this.tag=(e=function(e){var t=e.useCSSOMInjection,n=e.target;return e.isServer?new B(n):t?new x(n):new I(n)}(this.options),new E(e)));var e},e.prototype.hasNameForId=function(e,t){return this.names.has(e)&&this.names.get(e).has(t)},e.prototype.registerName=function(e,t){if(N(e),this.names.has(e))this.names.get(e).add(t);else{var n=new Set;n.add(t),this.names.set(e,n)}},e.prototype.insertRules=function(e,t,n){this.registerName(e,t),this.getTag().insertRules(N(e),n)},e.prototype.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},e.prototype.clearRules=function(e){this.getTag().clearGroup(N(e)),this.clearNames(e)},e.prototype.clearTag=function(){this.tag=void 0},e.prototype.toString=function(){return function(e){for(var t=e.getTag(),n=t.length,r="",o=function(n){var o=function(e){return P.get(e)}(n);if(void 0===o)return"continue";var i=e.names.get(o),s=t.getGroup(n);if(void 0===i||0===s.length)return"continue";var a="".concat(S,".g").concat(n,'[id="').concat(o,'"]'),c="";void 0!==i&&i.forEach(function(e){e.length>0&&(c+="".concat(e,","))}),r+="".concat(s).concat(a,'{content:"').concat(c,'"}').concat("/*!sc*/\n")},i=0;i<n;i++)o(i);return r}(this)},e}(),$=function(e,t){for(var n=t.length;n;)e=33*e^t.charCodeAt(--n);return e},F=/^\s*\/\/.*$/gm,k=[":","[",".","#"];function M(e,t){return e.map(function(e){return"rule"===e.type&&(e.value="".concat(t," ").concat(e.value),e.value=e.value.replaceAll(",",",".concat(t," ")),e.props=e.props.map(function(e){return"".concat(t," ").concat(e)})),Array.isArray(e.children)&&(e.children=M(e.children,t)),e})}var Y=new V,G=function(e){var t,n,r,o,i=y.options,p=void 0===i?y:i,h=y.plugins,f=void 0===h?d:h,m=function(e,r,i){return 0===r&&k.includes(i[n.length])||i.match(o)?e:".".concat(t)},v=f.slice();p.prefix&&v.unshift(s),v.push(function(e){e.type===c&&e.value.includes("&")&&(e.props[0]=e.props[0].replace(r,m))},a);var S=function(e,i,s,a){void 0===i&&(i=""),void 0===s&&(s=""),void 0===a&&(a="&"),t=a,n=i,r=new RegExp("\\".concat(n,"\\b"),"g"),o=new RegExp("(\\".concat(n,"\\b){2,}"));var c=e.replace(F,""),h=u(s||i?"".concat(s," ").concat(i," { ").concat(c," }"):c);return p.namespace&&(h=M(h,p.namespace)),function(e,t){for(var n=[],r=0,o=void 0;r<e.length;r+=1)(o=t(e[r],r,e,t))&&n.push(o);return n}(h,l(v))};return S.hash=f.length?f.reduce(function(e,t){return t.name||g(15),$(e,t.name)},5381).toString():"",S}(),q=(n.createContext({shouldForwardProp:void 0,styleSheet:Y,stylis:G}),n.createContext(void 0),function(){function e(e,t){var n=this;this.inject=function(e,t){void 0===t&&(t=G);var r=n.name+t.hash;e.hasNameForId(n.id,r)||e.insertRules(n.id,r,t(n.rules,r,"@keyframes"))},this.toString=function(){throw g(12,String(n.name))},this.name=e,this.id="sc-keyframes-".concat(e),this.rules=t}return e.prototype.getName=function(e){return void 0===e&&(e=G),this.name+e.hash},e}());function H(e){return"production"!==process.env.NODE_ENV&&"string"==typeof e&&e||e.displayName||e.name||"Component"}var W=function(e){return e>="A"&&e<="Z"};function U(e){for(var t="",n=0;n<e.length;n++){var r=e[n];if(1===n&&"-"===r&&"-"===e[0])return e;W(r)?t+="-"+r.toLowerCase():t+=r}return t.startsWith("ms-")?"-"+t:t}function K(e){return"function"==typeof e}function Z(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function J(e){return"object"==typeof e&&"styledComponentId"in e}var Q=function(e){return null==e||!1===e||""===e},X=function(t){var n,r=[];for(var o in t){var i=t[o];t.hasOwnProperty(o)&&!Q(i)&&(Array.isArray(i)&&i.isCss||K(i)?r.push("".concat(U(o),":"),i,";"):Z(i)?r.push.apply(r,e(e(["".concat(o," {")],X(i),!1),["}"],!1)):r.push("".concat(U(o),": ").concat(null==(n=i)||"boolean"==typeof n||""===n?"":"number"!=typeof n||0===n||o in p?String(n).trim():"".concat(n,"px"),";")))}return r};function ee(e,t,n,r){if(Q(e))return[];if(J(e))return[".".concat(e.styledComponentId)];if(K(e)){if(!K(i=e)||i.prototype&&i.prototype.isReactComponent||!t)return[e];var o=e(t);return"production"===process.env.NODE_ENV||"object"!=typeof o||Array.isArray(o)||o instanceof q||Z(o)||null===o||console.error("".concat(H(e)," 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.")),ee(o,t,n,r)}var i;return e instanceof q?n?(e.inject(n,r),[e.getName(r)]):[e]:Z(e)?X(e):Array.isArray(e)?e.flatMap(function(e){return ee(e,t,n,r)}):[e.toString()]}function te(e,t){for(var n=[e[0]],r=0,o=t.length;r<o;r+=1)n.push(t[r],e[r+1]);return n}var ne=function(e){return Object.assign(e,{isCss:!0})};function re(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if(K(t)||Z(t)){var o=t;return ne(ee(te(d,e([o],n,!0))))}var i=t;return 0===n.length&&1===i.length&&"string"==typeof i[0]?ee(i):ne(ee(te(i,n)))}function oe(n,r,o){if(void 0===o&&(o=y),!r)throw g(1,r);var i=function(t){for(var i=[],s=1;s<arguments.length;s++)i[s-1]=arguments[s];return n(r,o,re.apply(void 0,e([t],i,!1)))};return i.attrs=function(e){return oe(n,r,t(t({},o),{attrs:Array.prototype.concat(o.attrs,e).filter(Boolean)}))},i.withConfig=function(e){return oe(n,r,t(t({},o),e))},i}var ie,se=n.createContext(void 0),ae=se.Consumer;function ce(){return o(se)}function ue(e){var o=ce(),i=r(function(){return function(e,n){if(!e)throw g(14);if(K(e)){var r=e(n);if("production"!==process.env.NODE_ENV&&(null===r||Array.isArray(r)||"object"!=typeof r))throw g(7);return r}if(Array.isArray(e)||"object"!=typeof e)throw g(8);return n?t(t({},n),e):e}(e.theme,o)},[e.theme,o]);return e.children?n.createElement(se.Provider,{value:i},e.children):null}function le(e,t,n){return void 0===n&&(n=y),e.theme!==n.theme&&e.theme||t||n.theme}var pe="function"==typeof Symbol&&Symbol.for,he=pe?Symbol.for("react.memo"):60115,fe=pe?Symbol.for("react.forward_ref"):60112,de={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},ye={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},me={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},ve=((ie={})[fe]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},ie[he]=me,ie);function ge(e){return("type"in(t=e)&&t.type.$$typeof)===he?me:"$$typeof"in e?ve[e.$$typeof]:de;var t}var Se=Object.defineProperty,we=Object.getOwnPropertyNames,be=Object.getOwnPropertySymbols,Ee=Object.getOwnPropertyDescriptor,Ae=Object.getPrototypeOf,Pe=Object.prototype;function _e(e,t,n){if("string"!=typeof t){if(Pe){var r=Ae(t);r&&r!==Pe&&_e(e,r,n)}var o=we(t);be&&(o=o.concat(be(t)));for(var i=ge(e),s=ge(t),a=0;a<o.length;++a){var c=o[a];if(!(c in ye||n&&n[c]||s&&c in s||i&&c in i)){var u=Ee(t,c);try{Se(e,c,u)}catch(e){}}}}return e}function Ne(e){var r=n.forwardRef(function(r,o){var i=le(r,ce(),e.defaultProps);return"production"!==process.env.NODE_ENV&&void 0===i&&console.warn('[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class "'.concat(H(e),'"')),n.createElement(e,t({},r,{theme:i,ref:o}))});return r.displayName="WithTheme(".concat(H(e),")"),_e(r,e)}var Ce=/(a)(d)/gi,Te=function(e){return String.fromCharCode(e+(e>25?39:97))},De={};function Oe(e,t,n){if(void 0===n&&(n=!1),!n&&!Z(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var r=0;r<t.length;r++)e[r]=Oe(e[r],t[r]);else if(Z(t))for(var r in t)e[r]=Oe(e[r],t[r]);return e}var Re,je,xe=require("react-native"),Ie=(Re=xe.StyleSheet,je=function(){function e(e){this.rules=e}return e.prototype.generateStyleObject=function(e){var t=function(e,t){if(0===e.length)return"";for(var n=e[0],r=1;r<e.length;r++)n+=e[r];return n}(ee(this.rules,e)),n=function(e){var t,n="";for(t=Math.abs(e);t>52;t=t/52|0)n=Te(t%52)+n;return(Te(t%52)+n).replace(Ce,"$1-$2")}($(5381,t)>>>0);if(!De[n]){var r=f(t),o=[];r.each(function(e){"decl"===e.type?o.push([e.prop,e.value]):"production"!==process.env.NODE_ENV&&"comment"!==e.type&&console.warn("Node of type ".concat(e.type," not supported as an inline style"))});var i=h(o),s=Re.create({generated:i});De[n]=s.generated}return De[n]},e}(),function(e,o,s){var a=J(e),c=e,u=o.displayName,l=void 0===u?function(e){return function(e){return"string"==typeof e&&("production"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}(e)?"styled.".concat(e):"Styled(".concat(H(e),")")}(e):u,p=o.attrs,h=void 0===p?d:p,f=a&&c.attrs?c.attrs.concat(h).filter(Boolean):h,m=o.shouldForwardProp;if(a&&c.shouldForwardProp){var v=c.shouldForwardProp;if(o.shouldForwardProp){var g=o.shouldForwardProp;m=function(e,t){return v(e,t)&&g(e,t)}}else m=v}var S=function(e,n){return function(e,n,o){var s=e.attrs,a=e.inlineStyle,c=e.defaultProps,u=e.shouldForwardProp,l=e.target,p=ce(),h=function(e,n,r){void 0===e&&(e=y);var o=t(t({},n),{theme:e}),i={};return r.forEach(function(e){var t,n=K(e)?e(o):e;for(t in n)o[t]=i[t]=n[t]}),[o,i]}(le(n,p,c)||y,n,s),f=h[1],d=a.generateStyleObject(h[0]),m=o,v=f.as||n.as||l,g=f!==n?t(t({},n),f):n,S={};for(var w in g)"$"!==w[0]&&"as"!==w&&("forwardedAs"===w?S.as=g[w]:u&&!u(w,v)||(S[w]=g[w]));return S.style=r(function(){return K(n.style)?function(e){return[d].concat(n.style(e))}:n.style?[d].concat(n.style):d},[n.style,d]),S.ref=m,i(v,S)}(w,e,n)};S.displayName=l;var w=n.forwardRef(S);return w.attrs=f,w.inlineStyle=new je(a?c.inlineStyle.rules.concat(s):s),w.displayName=l,w.shouldForwardProp=m,w.styledComponentId=!0,w.target=a?c.target:e,Object.defineProperty(w,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(e){this._foldedDefaultProps=a?function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0,o=t;r<o.length;r++)Oe(e,o[r],!0);return e}({},c.defaultProps,e):e}}),_e(w,e,{attrs:!0,inlineStyle:!0,displayName:!0,shouldForwardProp:!0,target:!0}),w}),Be=function(e){return oe(Ie,e)};["ActivityIndicator","Button","DatePickerIOS","DrawerLayoutAndroid","FlatList","Image","ImageBackground","KeyboardAvoidingView","Modal","Pressable","ProgressBarAndroid","ProgressViewIOS","RefreshControl","SafeAreaView","ScrollView","SectionList","Slider","Switch","Text","TextInput","TouchableHighlight","TouchableOpacity","View","VirtualizedList"].forEach(function(e){return Object.defineProperty(Be,e,{enumerable:!0,configurable:!1,get:function(){if(e in xe&&xe[e])return Be(xe[e]);throw new Error("".concat(e," is not available in the currently-installed version of react-native"))}})});export{ae as ThemeConsumer,se as ThemeContext,ue as ThemeProvider,re as css,Be as default,J as isStyledComponent,Be as styled,ce as useTheme,Ne as withTheme};
1307
2
  //# sourceMappingURL=styled-components.native.esm.js.map