react-sync-board 0.5.6 → 0.6.2

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.
package/dist/cjs/index.js CHANGED
@@ -7,6 +7,27 @@ var recoil = require('recoil');
7
7
 
8
8
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
9
 
10
+ function _interopNamespace(e) {
11
+ if (e && e.__esModule) return e;
12
+ var n = Object.create(null);
13
+ if (e) {
14
+ Object.keys(e).forEach(function (k) {
15
+ if (k !== 'default') {
16
+ var d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: function () {
20
+ return e[k];
21
+ }
22
+ });
23
+ }
24
+ });
25
+ }
26
+ n['default'] = e;
27
+ return Object.freeze(n);
28
+ }
29
+
30
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
10
31
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
32
 
12
33
  function ownKeys(object, enumerableOnly) {
@@ -468,26 +489,17 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
468
489
  };
469
490
  }
470
491
 
471
- // This file replaces `index.js` in bundlers like webpack or Rollup,
472
-
473
492
  var nanoid = function nanoid() {
474
493
  var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 21;
475
494
  var id = '';
476
- var bytes = crypto.getRandomValues(new Uint8Array(size)); // A compact alternative for `for (var i = 0; i < step; i++)`.
495
+ var bytes = crypto.getRandomValues(new Uint8Array(size));
477
496
 
478
497
  while (size--) {
479
- // It is incorrect to use bytes exceeding the alphabet size.
480
- // The following mask reduces the random byte in the 0-255 value
481
- // range to the 0-63 value range. Therefore, adding hacks, such
482
- // as empty string fallback or magic numbers, is unneccessary because
483
- // the bitmask trims bytes down to the alphabet size.
484
498
  var _byte = bytes[size] & 63;
485
499
 
486
500
  if (_byte < 36) {
487
- // `0-9a-z`
488
501
  id += _byte.toString(36);
489
502
  } else if (_byte < 62) {
490
- // `A-Z`
491
503
  id += (_byte - 26).toString(36).toUpperCase();
492
504
  } else if (_byte < 63) {
493
505
  id += '_';
@@ -779,7 +791,7 @@ function memoize(fn) {
779
791
  };
780
792
  }
781
793
 
782
- var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|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|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|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|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
794
+ 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|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
783
795
 
784
796
  var isPropValid = /* #__PURE__ */memoize(function (prop) {
785
797
  return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111
@@ -852,7 +864,13 @@ var StyleSheet = /*#__PURE__*/function () {
852
864
  var before;
853
865
 
854
866
  if (_this.tags.length === 0) {
855
- before = _this.prepend ? _this.container.firstChild : _this.before;
867
+ if (_this.insertionPoint) {
868
+ before = _this.insertionPoint.nextSibling;
869
+ } else if (_this.prepend) {
870
+ before = _this.container.firstChild;
871
+ } else {
872
+ before = _this.before;
873
+ }
856
874
  } else {
857
875
  before = _this.tags[_this.tags.length - 1].nextSibling;
858
876
  }
@@ -870,6 +888,7 @@ var StyleSheet = /*#__PURE__*/function () {
870
888
  this.key = options.key;
871
889
  this.container = options.container;
872
890
  this.prepend = options.prepend;
891
+ this.insertionPoint = options.insertionPoint;
873
892
  this.before = null;
874
893
  }
875
894
 
@@ -910,7 +929,7 @@ var StyleSheet = /*#__PURE__*/function () {
910
929
  // the big drawback is that the css won't be editable in devtools
911
930
  sheet.insertRule(rule, sheet.cssRules.length);
912
931
  } catch (e) {
913
- if (process.env.NODE_ENV !== 'production' && !/:(-moz-placeholder|-ms-input-placeholder|-moz-read-write|-moz-read-only){/.test(rule)) {
932
+ if (process.env.NODE_ENV !== 'production' && !/:(-moz-placeholder|-moz-focus-inner|-moz-focusring|-ms-input-placeholder|-moz-read-write|-moz-read-only|-ms-clear){/.test(rule)) {
914
933
  console.error("There was a problem inserting the following rule: \"" + rule + "\"", e);
915
934
  }
916
935
  }
@@ -924,7 +943,7 @@ var StyleSheet = /*#__PURE__*/function () {
924
943
  _proto.flush = function flush() {
925
944
  // $FlowFixMe
926
945
  this.tags.forEach(function (tag) {
927
- return tag.parentNode.removeChild(tag);
946
+ return tag.parentNode && tag.parentNode.removeChild(tag);
928
947
  });
929
948
  this.tags = [];
930
949
  this.ctr = 0;
@@ -957,13 +976,19 @@ var abs = Math.abs;
957
976
  */
958
977
 
959
978
  var from = String.fromCharCode;
979
+ /**
980
+ * @param {object}
981
+ * @return {object}
982
+ */
983
+
984
+ var assign = Object.assign;
960
985
  /**
961
986
  * @param {string} value
962
987
  * @param {number} length
963
988
  * @return {number}
964
989
  */
965
990
 
966
- function hash(value, length) {
991
+ function hash$1(value, length) {
967
992
  return (((length << 2 ^ charat(value, 0)) << 2 ^ charat(value, 1)) << 2 ^ charat(value, 2)) << 2 ^ charat(value, 3);
968
993
  }
969
994
  /**
@@ -995,7 +1020,7 @@ function replace(value, pattern, replacement) {
995
1020
  }
996
1021
  /**
997
1022
  * @param {string} value
998
- * @param {string} value
1023
+ * @param {string} search
999
1024
  * @return {number}
1000
1025
  */
1001
1026
 
@@ -1064,11 +1089,11 @@ var character = 0;
1064
1089
  var characters = '';
1065
1090
  /**
1066
1091
  * @param {string} value
1067
- * @param {object} root
1068
- * @param {object?} parent
1092
+ * @param {object | null} root
1093
+ * @param {object | null} parent
1069
1094
  * @param {string} type
1070
- * @param {string[]} props
1071
- * @param {object[]} children
1095
+ * @param {string[] | string} props
1096
+ * @param {object[] | string} children
1072
1097
  * @param {number} length
1073
1098
  */
1074
1099
 
@@ -1087,13 +1112,15 @@ function node(value, root, parent, type, props, children, length) {
1087
1112
  };
1088
1113
  }
1089
1114
  /**
1090
- * @param {string} value
1091
1115
  * @param {object} root
1092
- * @param {string} type
1116
+ * @param {object} props
1117
+ * @return {object}
1093
1118
  */
1094
1119
 
1095
- function copy(value, root, type) {
1096
- return node(value, root.root, root.parent, type, root.props, root.children, 0);
1120
+ function copy(root, props) {
1121
+ return assign(node('', null, null, '', null, null, 0), root, {
1122
+ length: -root.length
1123
+ }, props);
1097
1124
  }
1098
1125
  /**
1099
1126
  * @return {number}
@@ -1252,7 +1279,8 @@ function delimiter(type) {
1252
1279
 
1253
1280
  case 34:
1254
1281
  case 39:
1255
- return delimiter(type === 34 || type === 39 ? type : character);
1282
+ if (type !== 34 && type !== 39) delimiter(character);
1283
+ break;
1256
1284
  // (
1257
1285
 
1258
1286
  case 40:
@@ -1336,11 +1364,18 @@ function parse(value, root, parent, rule, rules, rulesets, pseudo, points, decla
1336
1364
 
1337
1365
  while (scanning) {
1338
1366
  switch (previous = character, character = next()) {
1339
- // " ' [ (
1367
+ // (
1368
+ case 40:
1369
+ if (previous != 108 && characters.charCodeAt(length - 1) == 58) {
1370
+ if (indexof(characters += replace(delimit(character), '&', '&\f'), '&\f') != -1) ampersand = -1;
1371
+ break;
1372
+ }
1373
+
1374
+ // " ' [
1375
+
1340
1376
  case 34:
1341
1377
  case 39:
1342
1378
  case 91:
1343
- case 40:
1344
1379
  characters += delimit(character);
1345
1380
  break;
1346
1381
  // \t \n \r \s
@@ -1406,7 +1441,7 @@ function parse(value, root, parent, rule, rules, rulesets, pseudo, points, decla
1406
1441
  break;
1407
1442
 
1408
1443
  default:
1409
- parse(characters, reference, reference, reference, [''], children, length, points, children);
1444
+ parse(characters, reference, reference, reference, [''], children, 0, points, children);
1410
1445
  }
1411
1446
  }
1412
1447
 
@@ -1435,7 +1470,7 @@ function parse(value, root, parent, rule, rules, rulesets, pseudo, points, decla
1435
1470
  case 64:
1436
1471
  // -
1437
1472
  if (peek() === 45) characters += delimit(next());
1438
- atrule = peek(), offset = strlen(type = characters += identifier(caret())), character++;
1473
+ atrule = peek(), offset = length = strlen(type = characters += identifier(caret())), character++;
1439
1474
  break;
1440
1475
  // -
1441
1476
 
@@ -1505,7 +1540,7 @@ function declaration(value, root, parent, length) {
1505
1540
  */
1506
1541
 
1507
1542
  function prefix(value, length) {
1508
- switch (hash(value, length)) {
1543
+ switch (hash$1(value, length)) {
1509
1544
  // color-adjust
1510
1545
  case 5103:
1511
1546
  return WEBKIT + 'print-' + value + value;
@@ -1710,6 +1745,9 @@ function stringify(element, index, children, callback) {
1710
1745
  case COMMENT:
1711
1746
  return '';
1712
1747
 
1748
+ case KEYFRAMES:
1749
+ return element["return"] = element.value + '{' + serialize(element.children, callback) + '}';
1750
+
1713
1751
  case RULESET:
1714
1752
  element.value = element.props.join(',');
1715
1753
  }
@@ -1752,13 +1790,15 @@ function rulesheet(callback) {
1752
1790
  */
1753
1791
 
1754
1792
  function prefixer(element, index, children, callback) {
1755
- if (!element["return"]) switch (element.type) {
1793
+ if (element.length > -1) if (!element["return"]) switch (element.type) {
1756
1794
  case DECLARATION:
1757
1795
  element["return"] = prefix(element.value, element.length);
1758
1796
  break;
1759
1797
 
1760
1798
  case KEYFRAMES:
1761
- return serialize([copy(replace(element.value, '@', '@' + WEBKIT), element, '')], callback);
1799
+ return serialize([copy(element, {
1800
+ value: replace(element.value, '@', '@' + WEBKIT)
1801
+ })], callback);
1762
1802
 
1763
1803
  case RULESET:
1764
1804
  if (element.length) return combine(element.props, function (value) {
@@ -1766,11 +1806,19 @@ function prefixer(element, index, children, callback) {
1766
1806
  // :read-(only|write)
1767
1807
  case ':read-only':
1768
1808
  case ':read-write':
1769
- return serialize([copy(replace(value, /:(read-\w+)/, ':' + MOZ + '$1'), element, '')], callback);
1809
+ return serialize([copy(element, {
1810
+ props: [replace(value, /:(read-\w+)/, ':' + MOZ + '$1')]
1811
+ })], callback);
1770
1812
  // :placeholder
1771
1813
 
1772
1814
  case '::placeholder':
1773
- return serialize([copy(replace(value, /:(plac\w+)/, ':' + WEBKIT + 'input-$1'), element, ''), copy(replace(value, /:(plac\w+)/, ':' + MOZ + '$1'), element, ''), copy(replace(value, /:(plac\w+)/, MS + 'input-$1'), element, '')], callback);
1815
+ return serialize([copy(element, {
1816
+ props: [replace(value, /:(plac\w+)/, ':' + WEBKIT + 'input-$1')]
1817
+ }), copy(element, {
1818
+ props: [replace(value, /:(plac\w+)/, ':' + MOZ + '$1')]
1819
+ }), copy(element, {
1820
+ props: [replace(value, /:(plac\w+)/, MS + 'input-$1')]
1821
+ })], callback);
1774
1822
  }
1775
1823
 
1776
1824
  return '';
@@ -1780,6 +1828,29 @@ function prefixer(element, index, children, callback) {
1780
1828
 
1781
1829
  var last = function last(arr) {
1782
1830
  return arr.length ? arr[arr.length - 1] : null;
1831
+ }; // based on https://github.com/thysultan/stylis.js/blob/e6843c373ebcbbfade25ebcc23f540ed8508da0a/src/Tokenizer.js#L239-L244
1832
+
1833
+
1834
+ var identifierWithPointTracking = function identifierWithPointTracking(begin, points, index) {
1835
+ var previous = 0;
1836
+ var character = 0;
1837
+
1838
+ while (true) {
1839
+ previous = character;
1840
+ character = peek(); // &\f
1841
+
1842
+ if (previous === 38 && character === 12) {
1843
+ points[index] = 1;
1844
+ }
1845
+
1846
+ if (token(character)) {
1847
+ break;
1848
+ }
1849
+
1850
+ next();
1851
+ }
1852
+
1853
+ return slice(begin, position);
1783
1854
  };
1784
1855
 
1785
1856
  var toRules = function toRules(parsed, points) {
@@ -1799,7 +1870,7 @@ var toRules = function toRules(parsed, points) {
1799
1870
  points[index] = 1;
1800
1871
  }
1801
1872
 
1802
- parsed[index] += identifier(position - 1);
1873
+ parsed[index] += identifierWithPointTracking(position - 1, points, index);
1803
1874
  break;
1804
1875
 
1805
1876
  case 2:
@@ -1833,8 +1904,9 @@ var getRules = function getRules(value, points) {
1833
1904
  var fixedElements = /* #__PURE__ */new WeakMap();
1834
1905
 
1835
1906
  var compat = function compat(element) {
1836
- if (element.type !== 'rule' || !element.parent || // .length indicates if this rule contains pseudo or not
1837
- !element.length) {
1907
+ if (element.type !== 'rule' || !element.parent || // positive .length indicates that this rule contains pseudo
1908
+ // negative .length indicates that this rule has been already prefixed
1909
+ element.length < 1) {
1838
1910
  return;
1839
1911
  }
1840
1912
 
@@ -2070,7 +2142,8 @@ var createCache = function createCache(options) {
2070
2142
  container: container,
2071
2143
  nonce: options.nonce,
2072
2144
  speedy: options.speedy,
2073
- prepend: options.prepend
2145
+ prepend: options.prepend,
2146
+ insertionPoint: options.insertionPoint
2074
2147
  }),
2075
2148
  nonce: options.nonce,
2076
2149
  inserted: inserted,
@@ -2088,22 +2161,22 @@ var reactIs$1 = {exports: {}};
2088
2161
  var reactIs_production_min = {};
2089
2162
 
2090
2163
  var b = "function" === typeof Symbol && Symbol["for"],
2091
- c$1 = b ? Symbol["for"]("react.element") : 60103,
2164
+ c = b ? Symbol["for"]("react.element") : 60103,
2092
2165
  d = b ? Symbol["for"]("react.portal") : 60106,
2093
- e$1 = b ? Symbol["for"]("react.fragment") : 60107,
2094
- f$1 = b ? Symbol["for"]("react.strict_mode") : 60108,
2166
+ e = b ? Symbol["for"]("react.fragment") : 60107,
2167
+ f = b ? Symbol["for"]("react.strict_mode") : 60108,
2095
2168
  g = b ? Symbol["for"]("react.profiler") : 60114,
2096
2169
  h = b ? Symbol["for"]("react.provider") : 60109,
2097
2170
  k = b ? Symbol["for"]("react.context") : 60110,
2098
- l$1 = b ? Symbol["for"]("react.async_mode") : 60111,
2171
+ l = b ? Symbol["for"]("react.async_mode") : 60111,
2099
2172
  m = b ? Symbol["for"]("react.concurrent_mode") : 60111,
2100
- n$1 = b ? Symbol["for"]("react.forward_ref") : 60112,
2173
+ n = b ? Symbol["for"]("react.forward_ref") : 60112,
2101
2174
  p = b ? Symbol["for"]("react.suspense") : 60113,
2102
2175
  q = b ? Symbol["for"]("react.suspense_list") : 60120,
2103
2176
  r$1 = b ? Symbol["for"]("react.memo") : 60115,
2104
- t$1 = b ? Symbol["for"]("react.lazy") : 60116,
2177
+ t = b ? Symbol["for"]("react.lazy") : 60116,
2105
2178
  v = b ? Symbol["for"]("react.block") : 60121,
2106
- w$1 = b ? Symbol["for"]("react.fundamental") : 60117,
2179
+ w = b ? Symbol["for"]("react.fundamental") : 60117,
2107
2180
  x = b ? Symbol["for"]("react.responder") : 60118,
2108
2181
  y = b ? Symbol["for"]("react.scope") : 60119;
2109
2182
 
@@ -2112,21 +2185,21 @@ function z(a) {
2112
2185
  var u = a.$$typeof;
2113
2186
 
2114
2187
  switch (u) {
2115
- case c$1:
2188
+ case c:
2116
2189
  switch (a = a.type, a) {
2117
- case l$1:
2190
+ case l:
2118
2191
  case m:
2119
- case e$1:
2192
+ case e:
2120
2193
  case g:
2121
- case f$1:
2194
+ case f:
2122
2195
  case p:
2123
2196
  return a;
2124
2197
 
2125
2198
  default:
2126
2199
  switch (a = a && a.$$typeof, a) {
2127
2200
  case k:
2128
- case n$1:
2129
- case t$1:
2201
+ case n:
2202
+ case t:
2130
2203
  case r$1:
2131
2204
  case h:
2132
2205
  return a;
@@ -2147,22 +2220,22 @@ function A(a) {
2147
2220
  return z(a) === m;
2148
2221
  }
2149
2222
 
2150
- reactIs_production_min.AsyncMode = l$1;
2223
+ reactIs_production_min.AsyncMode = l;
2151
2224
  reactIs_production_min.ConcurrentMode = m;
2152
2225
  reactIs_production_min.ContextConsumer = k;
2153
2226
  reactIs_production_min.ContextProvider = h;
2154
- reactIs_production_min.Element = c$1;
2155
- reactIs_production_min.ForwardRef = n$1;
2156
- reactIs_production_min.Fragment = e$1;
2157
- reactIs_production_min.Lazy = t$1;
2227
+ reactIs_production_min.Element = c;
2228
+ reactIs_production_min.ForwardRef = n;
2229
+ reactIs_production_min.Fragment = e;
2230
+ reactIs_production_min.Lazy = t;
2158
2231
  reactIs_production_min.Memo = r$1;
2159
2232
  reactIs_production_min.Portal = d;
2160
2233
  reactIs_production_min.Profiler = g;
2161
- reactIs_production_min.StrictMode = f$1;
2234
+ reactIs_production_min.StrictMode = f;
2162
2235
  reactIs_production_min.Suspense = p;
2163
2236
 
2164
2237
  reactIs_production_min.isAsyncMode = function (a) {
2165
- return A(a) || z(a) === l$1;
2238
+ return A(a) || z(a) === l;
2166
2239
  };
2167
2240
 
2168
2241
  reactIs_production_min.isConcurrentMode = A;
@@ -2176,19 +2249,19 @@ reactIs_production_min.isContextProvider = function (a) {
2176
2249
  };
2177
2250
 
2178
2251
  reactIs_production_min.isElement = function (a) {
2179
- return "object" === _typeof(a) && null !== a && a.$$typeof === c$1;
2252
+ return "object" === _typeof(a) && null !== a && a.$$typeof === c;
2180
2253
  };
2181
2254
 
2182
2255
  reactIs_production_min.isForwardRef = function (a) {
2183
- return z(a) === n$1;
2256
+ return z(a) === n;
2184
2257
  };
2185
2258
 
2186
2259
  reactIs_production_min.isFragment = function (a) {
2187
- return z(a) === e$1;
2260
+ return z(a) === e;
2188
2261
  };
2189
2262
 
2190
2263
  reactIs_production_min.isLazy = function (a) {
2191
- return z(a) === t$1;
2264
+ return z(a) === t;
2192
2265
  };
2193
2266
 
2194
2267
  reactIs_production_min.isMemo = function (a) {
@@ -2204,7 +2277,7 @@ reactIs_production_min.isProfiler = function (a) {
2204
2277
  };
2205
2278
 
2206
2279
  reactIs_production_min.isStrictMode = function (a) {
2207
- return z(a) === f$1;
2280
+ return z(a) === f;
2208
2281
  };
2209
2282
 
2210
2283
  reactIs_production_min.isSuspense = function (a) {
@@ -2212,7 +2285,7 @@ reactIs_production_min.isSuspense = function (a) {
2212
2285
  };
2213
2286
 
2214
2287
  reactIs_production_min.isValidElementType = function (a) {
2215
- return "string" === typeof a || "function" === typeof a || a === e$1 || a === m || a === g || a === f$1 || a === p || a === q || "object" === _typeof(a) && null !== a && (a.$$typeof === t$1 || a.$$typeof === r$1 || a.$$typeof === h || a.$$typeof === k || a.$$typeof === n$1 || a.$$typeof === w$1 || a.$$typeof === x || a.$$typeof === y || a.$$typeof === v);
2288
+ return "string" === typeof a || "function" === typeof a || a === e || a === m || a === g || a === f || a === p || a === q || "object" === _typeof(a) && null !== a && (a.$$typeof === t || a.$$typeof === r$1 || a.$$typeof === h || a.$$typeof === k || a.$$typeof === n || a.$$typeof === w || a.$$typeof === x || a.$$typeof === y || a.$$typeof === v);
2216
2289
  };
2217
2290
 
2218
2291
  reactIs_production_min.typeOf = z;
@@ -2438,7 +2511,7 @@ function getRegisteredStyles$1(registered, registeredStyles, classNames) {
2438
2511
  return rawClassName;
2439
2512
  }
2440
2513
 
2441
- var insertStyles$1 = function insertStyles(cache, serialized, isStringTag) {
2514
+ var registerStyles$1 = function registerStyles(cache, serialized, isStringTag) {
2442
2515
  var className = cache.key + "-" + serialized.name;
2443
2516
 
2444
2517
  if ( // we only need to add the styles to the registered cache if the
@@ -2453,6 +2526,11 @@ var insertStyles$1 = function insertStyles(cache, serialized, isStringTag) {
2453
2526
  isBrowser$3 === false) && cache.registered[className] === undefined) {
2454
2527
  cache.registered[className] = serialized.styles;
2455
2528
  }
2529
+ };
2530
+
2531
+ var insertStyles$1 = function insertStyles(cache, serialized, isStringTag) {
2532
+ registerStyles$1(cache, serialized, isStringTag);
2533
+ var className = cache.key + "-" + serialized.name;
2456
2534
 
2457
2535
  if (cache.inserted[serialized.name] === undefined) {
2458
2536
  var current = serialized;
@@ -2610,7 +2688,7 @@ var processStyleValue$1 = function processStyleValue(key, value) {
2610
2688
  };
2611
2689
 
2612
2690
  if (process.env.NODE_ENV !== 'production') {
2613
- var contentValuePattern$1 = /(attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/;
2691
+ var contentValuePattern$1 = /(var|attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/;
2614
2692
  var contentValues$1 = ['normal', 'none', 'initial', 'inherit', 'unset'];
2615
2693
  var oldProcessStyleValue$1 = processStyleValue$1;
2616
2694
  var msPattern$1 = /^-ms-/;
@@ -2877,7 +2955,7 @@ var serializeStyles$1 = function serializeStyles(args, registered, mergedProps)
2877
2955
  };
2878
2956
  };
2879
2957
 
2880
- var hasOwnProperty = Object.prototype.hasOwnProperty;
2958
+ var hasOwnProperty = {}.hasOwnProperty;
2881
2959
  var EmotionCacheContext = /* #__PURE__ */React.createContext( // we're doing this to avoid preconstruct's dead code elimination in this one case
2882
2960
  // because this module is primarily intended for the browser and node
2883
2961
  // but it's also required in react native and similar environments sometimes
@@ -2887,6 +2965,11 @@ var EmotionCacheContext = /* #__PURE__ */React.createContext( // we're doing thi
2887
2965
  typeof HTMLElement !== 'undefined' ? /* #__PURE__ */createCache({
2888
2966
  key: 'css'
2889
2967
  }) : null);
2968
+
2969
+ if (process.env.NODE_ENV !== 'production') {
2970
+ EmotionCacheContext.displayName = 'EmotionCacheContext';
2971
+ }
2972
+
2890
2973
  EmotionCacheContext.Provider;
2891
2974
 
2892
2975
  var withEmotionCache = function withEmotionCache(func) {
@@ -2900,9 +2983,32 @@ var withEmotionCache = function withEmotionCache(func) {
2900
2983
 
2901
2984
  var ThemeContext = /* #__PURE__ */React.createContext({});
2902
2985
 
2986
+ if (process.env.NODE_ENV !== 'production') {
2987
+ ThemeContext.displayName = 'EmotionThemeContext';
2988
+ }
2989
+
2990
+ var useInsertionEffect$2 = React__namespace['useInsertion' + 'Effect'] ? React__namespace['useInsertion' + 'Effect'] : function useInsertionEffect(create) {
2991
+ create();
2992
+ };
2993
+
2994
+ function useInsertionEffectMaybe$1(create) {
2995
+ useInsertionEffect$2(create);
2996
+ }
2997
+
2903
2998
  var typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__';
2904
2999
  var labelPropName = '__EMOTION_LABEL_PLEASE_DO_NOT_USE__';
2905
3000
 
3001
+ var Insertion$2 = function Insertion(_ref) {
3002
+ var cache = _ref.cache,
3003
+ serialized = _ref.serialized,
3004
+ isStringTag = _ref.isStringTag;
3005
+ registerStyles$1(cache, serialized, isStringTag);
3006
+ useInsertionEffectMaybe$1(function () {
3007
+ return insertStyles$1(cache, serialized, isStringTag);
3008
+ });
3009
+ return null;
3010
+ };
3011
+
2906
3012
  var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
2907
3013
  var cssProp = props.css; // so that using `css` from `emotion` and passing the result to the css prop works
2908
3014
  // not passing the registered cache to serializeStyles because it would
@@ -2912,7 +3018,7 @@ var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
2912
3018
  cssProp = cache.registered[cssProp];
2913
3019
  }
2914
3020
 
2915
- var type = props[typePropName];
3021
+ var WrappedComponent = props[typePropName];
2916
3022
  var registeredStyles = [cssProp];
2917
3023
  var className = '';
2918
3024
 
@@ -2922,7 +3028,7 @@ var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
2922
3028
  className = props.className + " ";
2923
3029
  }
2924
3030
 
2925
- var serialized = serializeStyles$1(registeredStyles, undefined, typeof cssProp === 'function' || Array.isArray(cssProp) ? React.useContext(ThemeContext) : undefined);
3031
+ var serialized = serializeStyles$1(registeredStyles, undefined, React.useContext(ThemeContext));
2926
3032
 
2927
3033
  if (process.env.NODE_ENV !== 'production' && serialized.name.indexOf('-') === -1) {
2928
3034
  var labelFromStack = props[labelPropName];
@@ -2932,7 +3038,6 @@ var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
2932
3038
  }
2933
3039
  }
2934
3040
 
2935
- insertStyles$1(cache, serialized, typeof type === 'string');
2936
3041
  className += cache.key + "-" + serialized.name;
2937
3042
  var newProps = {};
2938
3043
 
@@ -2944,8 +3049,11 @@ var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
2944
3049
 
2945
3050
  newProps.ref = ref;
2946
3051
  newProps.className = className;
2947
- var ele = /*#__PURE__*/React.createElement(type, newProps);
2948
- return ele;
3052
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion$2, {
3053
+ cache: cache,
3054
+ serialized: serialized,
3055
+ isStringTag: typeof WrappedComponent === 'string'
3056
+ }), /*#__PURE__*/React.createElement(WrappedComponent, newProps));
2949
3057
  });
2950
3058
 
2951
3059
  if (process.env.NODE_ENV !== 'production') {
@@ -2954,7 +3062,7 @@ if (process.env.NODE_ENV !== 'production') {
2954
3062
 
2955
3063
  var pkg = {
2956
3064
  name: "@emotion/react",
2957
- version: "11.4.0",
3065
+ version: "11.9.0",
2958
3066
  main: "dist/emotion-react.cjs.js",
2959
3067
  module: "dist/emotion-react.esm.js",
2960
3068
  browser: {
@@ -2962,19 +3070,19 @@ var pkg = {
2962
3070
  "./dist/emotion-react.esm.js": "./dist/emotion-react.browser.esm.js"
2963
3071
  },
2964
3072
  types: "types/index.d.ts",
2965
- files: ["src", "dist", "jsx-runtime", "jsx-dev-runtime", "isolated-hoist-non-react-statics-do-not-use-this-in-your-code", "types/*.d.ts", "macro.js", "macro.d.ts", "macro.js.flow"],
3073
+ files: ["src", "dist", "jsx-runtime", "jsx-dev-runtime", "_isolated-hnrs", "types/*.d.ts", "macro.js", "macro.d.ts", "macro.js.flow"],
2966
3074
  sideEffects: false,
2967
- author: "mitchellhamilton <mitchell@mitchellhamilton.me>",
3075
+ author: "Emotion Contributors",
2968
3076
  license: "MIT",
2969
3077
  scripts: {
2970
3078
  "test:typescript": "dtslint types"
2971
3079
  },
2972
3080
  dependencies: {
2973
3081
  "@babel/runtime": "^7.13.10",
2974
- "@emotion/cache": "^11.4.0",
2975
- "@emotion/serialize": "^1.0.2",
2976
- "@emotion/sheet": "^1.0.1",
2977
- "@emotion/utils": "^1.0.0",
3082
+ "@emotion/babel-plugin": "^11.7.1",
3083
+ "@emotion/cache": "^11.7.1",
3084
+ "@emotion/serialize": "^1.0.3",
3085
+ "@emotion/utils": "^1.1.0",
2978
3086
  "@emotion/weak-memoize": "^0.2.5",
2979
3087
  "hoist-non-react-statics": "^3.3.1"
2980
3088
  },
@@ -2992,15 +3100,16 @@ var pkg = {
2992
3100
  },
2993
3101
  devDependencies: {
2994
3102
  "@babel/core": "^7.13.10",
2995
- "@emotion/css": "11.1.3",
2996
- "@emotion/css-prettifier": "1.0.0",
3103
+ "@emotion/css": "11.9.0",
3104
+ "@emotion/css-prettifier": "1.0.1",
2997
3105
  "@emotion/server": "11.4.0",
2998
- "@emotion/styled": "11.3.0",
3106
+ "@emotion/styled": "11.8.1",
2999
3107
  "@types/react": "^16.9.11",
3000
- dtslint: "^0.3.0",
3108
+ dtslint: "^4.2.1",
3001
3109
  "html-tag-names": "^1.1.2",
3002
3110
  react: "16.14.0",
3003
- "svg-tag-names": "^1.1.1"
3111
+ "svg-tag-names": "^1.1.1",
3112
+ typescript: "^4.5.5"
3004
3113
  },
3005
3114
  repository: "https://github.com/emotion-js/emotion/tree/main/packages/react",
3006
3115
  publishConfig: {
@@ -3008,11 +3117,12 @@ var pkg = {
3008
3117
  },
3009
3118
  "umd:main": "dist/emotion-react.umd.min.js",
3010
3119
  preconstruct: {
3011
- entrypoints: ["./index.js", "./jsx-runtime.js", "./jsx-dev-runtime.js", "./isolated-hoist-non-react-statics-do-not-use-this-in-your-code.js"],
3120
+ entrypoints: ["./index.js", "./jsx-runtime.js", "./jsx-dev-runtime.js", "./_isolated-hnrs.js"],
3012
3121
  umdName: "emotionReact"
3013
3122
  }
3014
3123
  };
3015
3124
 
3125
+ var useInsertionEffect$1 = React__namespace['useInsertion' + 'Effect'] ? React__namespace['useInsertion' + 'Effect'] : React.useLayoutEffect;
3016
3126
  var warnedAboutCssPropForGlobal = false; // maintain place over rerenders.
3017
3127
  // initial render from browser, insertBefore context.sheet.tags[0] or if a style hasn't been inserted there yet, appendChild
3018
3128
  // initial client-side render from SSR, use place of hydrating tag
@@ -3028,14 +3138,15 @@ var Global = /* #__PURE__ */withEmotionCache(function (props, cache) {
3028
3138
  }
3029
3139
 
3030
3140
  var styles = props.styles;
3031
- var serialized = serializeStyles$1([styles], undefined, typeof styles === 'function' || Array.isArray(styles) ? React.useContext(ThemeContext) : undefined); // but it is based on a constant that will never change at runtime
3141
+ var serialized = serializeStyles$1([styles], undefined, React.useContext(ThemeContext)); // but it is based on a constant that will never change at runtime
3032
3142
  // it's effectively like having two implementations and switching them out
3033
3143
  // so it's not actually breaking anything
3034
3144
 
3035
3145
  var sheetRef = React.useRef();
3036
- React.useLayoutEffect(function () {
3037
- var key = cache.key + "-global";
3038
- var sheet = new StyleSheet({
3146
+ useInsertionEffect$1(function () {
3147
+ var key = cache.key + "-global"; // use case of https://github.com/emotion-js/emotion/issues/2675
3148
+
3149
+ var sheet = new cache.sheet.constructor({
3039
3150
  key: key,
3040
3151
  nonce: cache.sheet.nonce,
3041
3152
  container: cache.sheet.container,
@@ -3061,7 +3172,7 @@ var Global = /* #__PURE__ */withEmotionCache(function (props, cache) {
3061
3172
  sheet.flush();
3062
3173
  };
3063
3174
  }, [cache]);
3064
- React.useLayoutEffect(function () {
3175
+ useInsertionEffect$1(function () {
3065
3176
  var sheetRefCurrent = sheetRef.current;
3066
3177
  var sheet = sheetRefCurrent[0],
3067
3178
  rehydrating = sheetRefCurrent[1];
@@ -3176,8 +3287,20 @@ function merge(registered, css, className) {
3176
3287
  return rawClassName + css(registeredStyles);
3177
3288
  }
3178
3289
 
3290
+ var Insertion$1 = function Insertion(_ref) {
3291
+ var cache = _ref.cache,
3292
+ serializedArr = _ref.serializedArr;
3293
+ useInsertionEffectMaybe$1(function () {
3294
+ for (var i = 0; i < serializedArr.length; i++) {
3295
+ insertStyles$1(cache, serializedArr[i], false);
3296
+ }
3297
+ });
3298
+ return null;
3299
+ };
3300
+
3179
3301
  var ClassNames = /* #__PURE__ */withEmotionCache(function (props, cache) {
3180
3302
  var hasRendered = false;
3303
+ var serializedArr = [];
3181
3304
 
3182
3305
  var css = function css() {
3183
3306
  if (hasRendered && process.env.NODE_ENV !== 'production') {
@@ -3189,9 +3312,9 @@ var ClassNames = /* #__PURE__ */withEmotionCache(function (props, cache) {
3189
3312
  }
3190
3313
 
3191
3314
  var serialized = serializeStyles$1(args, cache.registered);
3192
- {
3193
- insertStyles$1(cache, serialized, false);
3194
- }
3315
+ serializedArr.push(serialized); // registration has to happen here as the result of this might get consumed by `cx`
3316
+
3317
+ registerStyles$1(cache, serialized, false);
3195
3318
  return cache.key + "-" + serialized.name;
3196
3319
  };
3197
3320
 
@@ -3214,7 +3337,10 @@ var ClassNames = /* #__PURE__ */withEmotionCache(function (props, cache) {
3214
3337
  };
3215
3338
  var ele = props.children(content);
3216
3339
  hasRendered = true;
3217
- return ele;
3340
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion$1, {
3341
+ cache: cache,
3342
+ serializedArr: serializedArr
3343
+ }), ele);
3218
3344
  });
3219
3345
 
3220
3346
  if (process.env.NODE_ENV !== 'production') {
@@ -3227,7 +3353,10 @@ if (process.env.NODE_ENV !== 'production') {
3227
3353
  var isJest = typeof jest !== 'undefined';
3228
3354
 
3229
3355
  if (isBrowser$2 && !isJest) {
3230
- var globalContext = isBrowser$2 ? window : global;
3356
+ // globalThis has wide browser support - https://caniuse.com/?search=globalThis, Node.js 12 and later
3357
+ var globalContext = // $FlowIgnore
3358
+ typeof globalThis !== 'undefined' ? globalThis // eslint-disable-line no-undef
3359
+ : isBrowser$2 ? window : global;
3231
3360
  var globalKey = "__EMOTION_REACT_" + pkg.version.split('.')[0] + "__";
3232
3361
 
3233
3362
  if (globalContext[globalKey]) {
@@ -3252,7 +3381,7 @@ function getRegisteredStyles(registered, registeredStyles, classNames) {
3252
3381
  return rawClassName;
3253
3382
  }
3254
3383
 
3255
- var insertStyles = function insertStyles(cache, serialized, isStringTag) {
3384
+ var registerStyles = function registerStyles(cache, serialized, isStringTag) {
3256
3385
  var className = cache.key + "-" + serialized.name;
3257
3386
 
3258
3387
  if ( // we only need to add the styles to the registered cache if the
@@ -3267,6 +3396,11 @@ var insertStyles = function insertStyles(cache, serialized, isStringTag) {
3267
3396
  isBrowser$1 === false) && cache.registered[className] === undefined) {
3268
3397
  cache.registered[className] = serialized.styles;
3269
3398
  }
3399
+ };
3400
+
3401
+ var insertStyles = function insertStyles(cache, serialized, isStringTag) {
3402
+ registerStyles(cache, serialized, isStringTag);
3403
+ var className = cache.key + "-" + serialized.name;
3270
3404
 
3271
3405
  if (cache.inserted[serialized.name] === undefined) {
3272
3406
  var current = serialized;
@@ -3618,8 +3752,27 @@ var composeShouldForwardProps = function composeShouldForwardProps(tag, options,
3618
3752
  return shouldForwardProp;
3619
3753
  };
3620
3754
 
3755
+ var useInsertionEffect = React__namespace['useInsertion' + 'Effect'] ? React__namespace['useInsertion' + 'Effect'] : function useInsertionEffect(create) {
3756
+ create();
3757
+ };
3758
+
3759
+ function useInsertionEffectMaybe(create) {
3760
+ useInsertionEffect(create);
3761
+ }
3762
+
3621
3763
  var ILLEGAL_ESCAPE_SEQUENCE_ERROR = "You have illegal escape sequence in your template literal, most likely inside content's property value.\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \"content: '\\00d7';\" should become \"content: '\\\\00d7';\".\nYou can read more about this here:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences";
3622
3764
 
3765
+ var Insertion = function Insertion(_ref) {
3766
+ var cache = _ref.cache,
3767
+ serialized = _ref.serialized,
3768
+ isStringTag = _ref.isStringTag;
3769
+ registerStyles(cache, serialized, isStringTag);
3770
+ useInsertionEffectMaybe(function () {
3771
+ return insertStyles(cache, serialized, isStringTag);
3772
+ });
3773
+ return null;
3774
+ };
3775
+
3623
3776
  var createStyled = function createStyled(tag, options) {
3624
3777
  if (process.env.NODE_ENV !== 'production') {
3625
3778
  if (tag === undefined) {
@@ -3670,7 +3823,7 @@ var createStyled = function createStyled(tag, options) {
3670
3823
 
3671
3824
 
3672
3825
  var Styled = withEmotionCache(function (props, cache, ref) {
3673
- var finalTag = shouldUseAs && props.as || baseTag;
3826
+ var FinalTag = shouldUseAs && props.as || baseTag;
3674
3827
  var className = '';
3675
3828
  var classInterpolations = [];
3676
3829
  var mergedProps = props;
@@ -3692,14 +3845,13 @@ var createStyled = function createStyled(tag, options) {
3692
3845
  }
3693
3846
 
3694
3847
  var serialized = serializeStyles(styles.concat(classInterpolations), cache.registered, mergedProps);
3695
- insertStyles(cache, serialized, typeof finalTag === 'string');
3696
3848
  className += cache.key + "-" + serialized.name;
3697
3849
 
3698
3850
  if (targetClassName !== undefined) {
3699
3851
  className += " " + targetClassName;
3700
3852
  }
3701
3853
 
3702
- var finalShouldForwardProp = shouldUseAs && shouldForwardProp === undefined ? getDefaultShouldForwardProp(finalTag) : defaultShouldForwardProp;
3854
+ var finalShouldForwardProp = shouldUseAs && shouldForwardProp === undefined ? getDefaultShouldForwardProp(FinalTag) : defaultShouldForwardProp;
3703
3855
  var newProps = {};
3704
3856
 
3705
3857
  for (var _key in props) {
@@ -3713,8 +3865,11 @@ var createStyled = function createStyled(tag, options) {
3713
3865
 
3714
3866
  newProps.className = className;
3715
3867
  newProps.ref = ref;
3716
- var ele = /*#__PURE__*/React.createElement(finalTag, newProps);
3717
- return ele;
3868
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion, {
3869
+ cache: cache,
3870
+ serialized: serialized,
3871
+ isStringTag: typeof FinalTag === 'string'
3872
+ }), /*#__PURE__*/React.createElement(FinalTag, newProps));
3718
3873
  });
3719
3874
  Styled.displayName = identifierName !== undefined ? identifierName : "Styled(" + (typeof baseTag === 'string' ? baseTag : baseTag.displayName || baseTag.name || 'Component') + ")";
3720
3875
  Styled.defaultProps = tag.defaultProps;
@@ -3983,10 +4138,6 @@ var useItemList = function useItemList() {
3983
4138
  return items;
3984
4139
  };
3985
4140
 
3986
- var useSelectedItems = function useSelectedItems() {
3987
- return recoil.useRecoilValue(SelectedItemsAtom);
3988
- };
3989
-
3990
4141
  /**
3991
4142
  * Run effect only when component is unmounted.
3992
4143
  *
@@ -4174,6 +4325,28 @@ function useThrottledCallback(callback, deps, delay, noTrailing) {
4174
4325
  }, __spreadArray([delay, noTrailing], deps, true));
4175
4326
  }
4176
4327
 
4328
+ /* eslint-disable @typescript-eslint/no-explicit-any */
4329
+ /**
4330
+ * Like `useEffect`, but passed function is debounced.
4331
+ *
4332
+ * @param callback Callback like for `useEffect`, but without ability to return
4333
+ * a cleanup function.
4334
+ * @param deps Dependencies list that will be passed to underlying `useEffect`
4335
+ * and `useDebouncedCallback`.
4336
+ * @param delay Debounce delay.
4337
+ * @param maxWait Maximum amount of milliseconds that function can be delayed
4338
+ * before it's force execution. 0 means no max wait.
4339
+ */
4340
+
4341
+ function useDebouncedEffect(callback, deps, delay, maxWait) {
4342
+ if (maxWait === void 0) {
4343
+ maxWait = 0;
4344
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
4345
+
4346
+
4347
+ React.useEffect(useDebouncedCallback(callback, deps, delay, maxWait), deps);
4348
+ }
4349
+
4177
4350
  /* eslint-disable @typescript-eslint/no-explicit-any */
4178
4351
  /**
4179
4352
  * Like `useEffect`, but passed function is throttled.
@@ -4318,6 +4491,45 @@ function useResizeObserver(target, callback, enabled) {
4318
4491
  }, [target, ro]);
4319
4492
  }
4320
4493
 
4494
+ var useDebouncedItems = function useDebouncedItems() {
4495
+ var items = recoil.useRecoilValue(AllItemsSelector);
4496
+
4497
+ var _React$useState = React__default['default'].useState(items),
4498
+ _React$useState2 = _slicedToArray(_React$useState, 2),
4499
+ debouncedItems = _React$useState2[0],
4500
+ setDebouncedItems = _React$useState2[1];
4501
+
4502
+ var updateDebouncedItems = recoil.useRecoilCallback(function (_ref) {
4503
+ var snapshot = _ref.snapshot;
4504
+ return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
4505
+ var currentItemMap;
4506
+ return regeneratorRuntime.wrap(function _callee$(_context) {
4507
+ while (1) {
4508
+ switch (_context.prev = _context.next) {
4509
+ case 0:
4510
+ _context.next = 2;
4511
+ return snapshot.getPromise(AllItemsSelector);
4512
+
4513
+ case 2:
4514
+ currentItemMap = _context.sent;
4515
+ setDebouncedItems(currentItemMap);
4516
+
4517
+ case 4:
4518
+ case "end":
4519
+ return _context.stop();
4520
+ }
4521
+ }
4522
+ }, _callee);
4523
+ }));
4524
+ }, []);
4525
+ useDebouncedEffect(updateDebouncedItems, [items], 300);
4526
+ return debouncedItems;
4527
+ };
4528
+
4529
+ var useSelectedItems = function useSelectedItems() {
4530
+ return recoil.useRecoilValue(SelectedItemsAtom);
4531
+ };
4532
+
4321
4533
  var isMacOS = function isMacOS() {
4322
4534
  var userAgent = navigator.userAgent.toLowerCase();
4323
4535
  return /mac os ?x 10/.test(userAgent);
@@ -4822,15 +5034,15 @@ var Gesture = function Gesture(_ref6) {
4822
5034
  stateRef.current.noTap = false;
4823
5035
  } // Send tap event only if time less than 300ms
4824
5036
  else if (stateRef.current.timeStart - now < 300) {
4825
- queue(onTap, {
4826
- clientX: clientX,
4827
- clientY: clientY,
4828
- altKey: altKey,
4829
- ctrlKey: ctrlKey,
4830
- metaKey: metaKey,
4831
- target: target
4832
- });
4833
- }
5037
+ queue(onTap, {
5038
+ clientX: clientX,
5039
+ clientY: clientY,
5040
+ altKey: altKey,
5041
+ ctrlKey: ctrlKey,
5042
+ metaKey: metaKey,
5043
+ target: target
5044
+ });
5045
+ }
4834
5046
  }
4835
5047
  }, [onDragEnd, onTap, queue]);
4836
5048
  var onDoubleTapHandler = React__default['default'].useCallback(function (event) {
@@ -4906,7 +5118,7 @@ var _excluded$2 = ["type", "rotation", "id", "locked", "layer"],
4906
5118
  _excluded3 = ["x", "y", "layer", "moving"];
4907
5119
 
4908
5120
  var _templateObject$2;
4909
- var ItemWrapper = newStyled.div(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\n display: inline-block;\n transition: transform 150ms;\n user-select: none;\n padding: 2px;\n box-sizing: border-box;\n transform: rotate(", "deg);\n\n & .corner {\n position: absolute;\n width: 0px;\n height: 0px;\n }\n\n & .top-left {\n top: 0;\n left: 0;\n }\n & .top-right {\n top: 0;\n right: 0;\n }\n & .bottom-left {\n bottom: 0;\n left: 0;\n }\n & .bottom-right {\n bottom: 0;\n right: 0;\n }\n\n &.selected {\n border: 2px dashed #db5034;\n padding: 0px;\n cursor: pointer;\n }\n\n &.locked::after {\n content: \"\";\n position: absolute;\n width: 24px;\n height: 30px;\n top: 4px;\n right: 4px;\n opacity: 0.1;\n background-image: url(\"", "\");\n background-size: cover;\n user-select: none;\n }\n\n &.locked:hover::after {\n opacity: 0.3;\n }\n\n & .resize {\n position: absolute;\n\n width: 10px;\n height: 10px;\n border: 2px solid #db5034;\n background-color: #db5034;\n cursor: move;\n\n &.resize-width {\n cursor: ew-resize;\n right: -6px;\n top: calc(50% - 5px);\n }\n &.resize-height {\n cursor: ns-resize;\n bottom: -6px;\n left: calc(50% - 5px);\n }\n &.resize-ratio {\n cursor: nwse-resize;\n bottom: -6px;\n right: -6px;\n }\n }\n"])), function (_ref) {
5121
+ var ItemWrapper = newStyled.div(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\n display: inline-block;\n transition: transform 150ms;\n user-select: none;\n padding: 2px;\n box-sizing: border-box;\n transform: rotate(", "deg);\n\n & .corner {\n position: absolute;\n width: 0px;\n height: 0px;\n }\n\n & .top-left {\n top: 0;\n left: 0;\n }\n & .top-right {\n top: 0;\n right: 0;\n }\n & .bottom-left {\n bottom: 0;\n left: 0;\n }\n & .bottom-right {\n bottom: 0;\n right: 0;\n }\n\n & .center {\n position: absolute;\n width: 0px;\n height: 0px;\n top: 50%;\n left: 50%;\n }\n\n &.selected {\n border: 2px dashed #db5034;\n padding: 0px;\n cursor: pointer;\n }\n\n &.locked::after {\n content: \"\";\n position: absolute;\n width: 24px;\n height: 30px;\n top: 4px;\n right: 4px;\n opacity: 0.1;\n background-image: url(\"", "\");\n background-size: cover;\n user-select: none;\n }\n\n &.locked:hover::after {\n opacity: 0.3;\n }\n\n & .resize {\n position: absolute;\n\n width: 10px;\n height: 10px;\n border: 2px solid #db5034;\n background-color: #db5034;\n cursor: move;\n\n &.resize-width {\n cursor: ew-resize;\n right: -6px;\n top: calc(50% - 5px);\n }\n &.resize-height {\n cursor: ns-resize;\n bottom: -6px;\n left: calc(50% - 5px);\n }\n &.resize-ratio {\n cursor: nwse-resize;\n bottom: -6px;\n right: -6px;\n }\n }\n"])), function (_ref) {
4910
5122
  var rotation = _ref.rotation;
4911
5123
  return rotation;
4912
5124
  }, img);
@@ -5156,10 +5368,12 @@ var Item = function Item(_ref5) {
5156
5368
  className: "corner top-left"
5157
5369
  }), /*#__PURE__*/React__default['default'].createElement("div", {
5158
5370
  className: "corner top-right"
5371
+ }), /*#__PURE__*/React__default['default'].createElement("div", {
5372
+ className: "corner bottom-right"
5159
5373
  }), /*#__PURE__*/React__default['default'].createElement("div", {
5160
5374
  className: "corner bottom-left"
5161
5375
  }), /*#__PURE__*/React__default['default'].createElement("div", {
5162
- className: "corner bottom-right"
5376
+ className: "center"
5163
5377
  }), isSelected && showResizeHandle && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, resizeDirections.b && /*#__PURE__*/React__default['default'].createElement(ResizeHandler, {
5164
5378
  className: "resize resize-ratio",
5165
5379
  onResize: onResizeRatio
@@ -5192,8 +5406,6 @@ var PositionedItem = function PositionedItem(_ref12) {
5192
5406
  rest = _objectWithoutProperties(_ref12, _excluded2);
5193
5407
 
5194
5408
  if (!rest.itemMap[state.type]) {
5195
- // eslint-disable-next-line no-console
5196
- console.warn("Item type ".concat(state.type, " not recognized!"));
5197
5409
  return null;
5198
5410
  }
5199
5411
 
@@ -6219,154 +6431,223 @@ var ActionPane = function ActionPane(_ref) {
6219
6431
  }, children);
6220
6432
  };
6221
6433
 
6222
- function t(t, n, r) {
6223
- return Math.min(Math.max(t, r), n);
6434
+ /**
6435
+ * A simple guard function:
6436
+ *
6437
+ * ```js
6438
+ * Math.min(Math.max(low, value), high)
6439
+ * ```
6440
+ */
6441
+ function guard(low, high, value) {
6442
+ return Math.min(Math.max(low, value), high);
6224
6443
  }
6225
6444
 
6226
- var n = /*#__PURE__*/function (_Error) {
6227
- _inherits(n, _Error);
6445
+ var ColorError = /*#__PURE__*/function (_Error) {
6446
+ _inherits(ColorError, _Error);
6228
6447
 
6229
- var _super = _createSuper(n);
6448
+ var _super = _createSuper(ColorError);
6230
6449
 
6231
- function n(t) {
6232
- _classCallCheck(this, n);
6450
+ function ColorError(color) {
6451
+ _classCallCheck(this, ColorError);
6233
6452
 
6234
- return _super.call(this, "Failed to parse color: \"".concat(t, "\""));
6453
+ return _super.call(this, "Failed to parse color: \"".concat(color, "\""));
6235
6454
  }
6236
6455
 
6237
- return n;
6456
+ return ColorError;
6238
6457
  }( /*#__PURE__*/_wrapNativeSuper(Error));
6239
6458
 
6240
- function r(r) {
6241
- if ("string" != typeof r) throw new n(r);
6242
- if ("transparent" === r.trim().toLowerCase()) return [0, 0, 0, 0];
6243
- var e = r.trim();
6244
- e = u.test(r) ? function (t) {
6245
- var r = t.toLowerCase().trim(),
6246
- e = o[function (t) {
6247
- var n = 5381,
6248
- r = t.length;
6249
-
6250
- for (; r;) {
6251
- n = 33 * n ^ t.charCodeAt(--r);
6252
- }
6253
-
6254
- return (n >>> 0) % 2341;
6255
- }(r)];
6256
-
6257
- if (!e) throw new n(t);
6258
- return "#".concat(e);
6259
- }(r) : r;
6260
- var f = s.exec(e);
6261
-
6262
- if (f) {
6263
- var _t = Array.from(f).slice(1);
6459
+ var ColorError$1 = ColorError;
6460
+ /**
6461
+ * Parses a color into red, gree, blue, alpha parts
6462
+ *
6463
+ * @param color the input color. Can be a RGB, RBGA, HSL, HSLA, or named color
6464
+ */
6264
6465
 
6265
- return [].concat(_toConsumableArray(_t.slice(0, 3).map(function (t) {
6266
- return parseInt(_(t, 2), 16);
6267
- })), [parseInt(_(_t[3] || "f", 2), 16) / 255]);
6466
+ function parseToRgba(color) {
6467
+ if (typeof color !== 'string') throw new ColorError$1(color);
6468
+ if (color.trim().toLowerCase() === 'transparent') return [0, 0, 0, 0];
6469
+ var normalizedColor = color.trim();
6470
+ normalizedColor = namedColorRegex.test(color) ? nameToHex(color) : color;
6471
+ var reducedHexMatch = reducedHexRegex.exec(normalizedColor);
6472
+
6473
+ if (reducedHexMatch) {
6474
+ var arr = Array.from(reducedHexMatch).slice(1);
6475
+ return [].concat(_toConsumableArray(arr.slice(0, 3).map(function (x) {
6476
+ return parseInt(r(x, 2), 16);
6477
+ })), [parseInt(r(arr[3] || 'f', 2), 16) / 255]);
6268
6478
  }
6269
6479
 
6270
- var p = i.exec(e);
6480
+ var hexMatch = hexRegex.exec(normalizedColor);
6271
6481
 
6272
- if (p) {
6273
- var _t2 = Array.from(p).slice(1);
6482
+ if (hexMatch) {
6483
+ var _arr = Array.from(hexMatch).slice(1);
6274
6484
 
6275
- return [].concat(_toConsumableArray(_t2.slice(0, 3).map(function (t) {
6276
- return parseInt(t, 16);
6277
- })), [parseInt(_t2[3] || "ff", 16) / 255]);
6485
+ return [].concat(_toConsumableArray(_arr.slice(0, 3).map(function (x) {
6486
+ return parseInt(x, 16);
6487
+ })), [parseInt(_arr[3] || 'ff', 16) / 255]);
6278
6488
  }
6279
6489
 
6280
- var z = a.exec(e);
6490
+ var rgbaMatch = rgbaRegex.exec(normalizedColor);
6281
6491
 
6282
- if (z) {
6283
- var _t3 = Array.from(z).slice(1);
6492
+ if (rgbaMatch) {
6493
+ var _arr2 = Array.from(rgbaMatch).slice(1);
6284
6494
 
6285
- return [].concat(_toConsumableArray(_t3.slice(0, 3).map(function (t) {
6286
- return parseInt(t, 10);
6287
- })), [parseFloat(_t3[3] || "1")]);
6495
+ return [].concat(_toConsumableArray(_arr2.slice(0, 3).map(function (x) {
6496
+ return parseInt(x, 10);
6497
+ })), [parseFloat(_arr2[3] || '1')]);
6288
6498
  }
6289
6499
 
6290
- var h = c.exec(e);
6500
+ var hslaMatch = hslaRegex.exec(normalizedColor);
6291
6501
 
6292
- if (h) {
6293
- var _Array$from$slice$map = Array.from(h).slice(1).map(parseFloat),
6502
+ if (hslaMatch) {
6503
+ var _Array$from$slice$map = Array.from(hslaMatch).slice(1).map(parseFloat),
6294
6504
  _Array$from$slice$map2 = _slicedToArray(_Array$from$slice$map, 4),
6295
- _e = _Array$from$slice$map2[0],
6296
- _o = _Array$from$slice$map2[1],
6297
- _2 = _Array$from$slice$map2[2],
6298
- _s = _Array$from$slice$map2[3];
6299
-
6300
- if (t(0, 100, _o) !== _o) throw new n(r);
6301
- if (t(0, 100, _2) !== _2) throw new n(r);
6302
- return [].concat(_toConsumableArray(l(_e, _o, _2)), [_s || 1]);
6505
+ h = _Array$from$slice$map2[0],
6506
+ s = _Array$from$slice$map2[1],
6507
+ l = _Array$from$slice$map2[2],
6508
+ a = _Array$from$slice$map2[3];
6509
+
6510
+ if (guard(0, 100, s) !== s) throw new ColorError$1(color);
6511
+ if (guard(0, 100, l) !== l) throw new ColorError$1(color);
6512
+ return [].concat(_toConsumableArray(hslToRgb(h, s, l)), [a || 1]);
6303
6513
  }
6304
6514
 
6305
- throw new n(r);
6515
+ throw new ColorError$1(color);
6306
6516
  }
6307
6517
 
6308
- var e = function e(t) {
6309
- return parseInt(t.replace(/_/g, ""), 36);
6310
- },
6311
- o = "1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce(function (t, n) {
6312
- var r = e(n.substring(0, 3)),
6313
- o = e(n.substring(3)).toString(16);
6314
- var _ = "";
6518
+ function hash(str) {
6519
+ var hash = 5381;
6520
+ var i = str.length;
6315
6521
 
6316
- for (var _t4 = 0; _t4 < 6 - o.length; _t4++) {
6317
- _ += "0";
6522
+ while (i) {
6523
+ hash = hash * 33 ^ str.charCodeAt(--i);
6318
6524
  }
6525
+ /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
6526
+ * integers. Since we want the results to be always positive, convert the
6527
+ * signed int to an unsigned by doing an unsigned bitshift. */
6319
6528
 
6320
- return t[r] = "".concat(_).concat(o), t;
6321
- }, {}),
6322
- _ = function _(t, n) {
6323
- return Array.from(Array(n)).map(function () {
6324
- return t;
6325
- }).join("");
6326
- },
6327
- s = new RegExp("^#".concat(_("([a-f0-9])", 3), "([a-f0-9])?$"), "i"),
6328
- i = new RegExp("^#".concat(_("([a-f0-9]{2})", 3), "([a-f0-9]{2})?$"), "i"),
6329
- a = new RegExp("^rgba?\\(\\s*(\\d+)\\s*".concat(_(",\\s*(\\d+)\\s*", 2), "(?:,\\s*([\\d.]+))?\\s*\\)$"), "i"),
6330
- c = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i,
6331
- u = /^[a-z]+$/i,
6332
- f = function f(t) {
6333
- return Math.round(255 * t);
6334
- },
6335
- l = function l(t, n, r) {
6336
- var e = r / 100;
6337
- if (0 === n) return [e, e, e].map(f);
6338
-
6339
- var o = (t % 360 + 360) % 360 / 60,
6340
- _ = (1 - Math.abs(2 * e - 1)) * (n / 100),
6341
- s = _ * (1 - Math.abs(o % 2 - 1));
6342
-
6343
- var i = 0,
6344
- a = 0,
6345
- c = 0;
6346
- o >= 0 && o < 1 ? (i = _, a = s) : o >= 1 && o < 2 ? (i = s, a = _) : o >= 2 && o < 3 ? (a = _, c = s) : o >= 3 && o < 4 ? (a = s, c = _) : o >= 4 && o < 5 ? (i = s, c = _) : o >= 5 && o < 6 && (i = _, c = s);
6347
- var u = e - _ / 2;
6348
- return [i + u, a + u, c + u].map(f);
6529
+
6530
+ return (hash >>> 0) % 2341;
6531
+ }
6532
+
6533
+ var colorToInt = function colorToInt(x) {
6534
+ return parseInt(x.replace(/_/g, ''), 36);
6349
6535
  };
6350
6536
 
6351
- function w(t) {
6352
- if ("transparent" === t) return 0;
6537
+ var compressedColorMap = '1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm'.split(' ').reduce(function (acc, next) {
6538
+ var key = colorToInt(next.substring(0, 3));
6539
+ var hex = colorToInt(next.substring(3)).toString(16); // NOTE: padStart could be used here but it breaks Node 6 compat
6540
+ // https://github.com/ricokahler/color2k/issues/351
6541
+
6542
+ var prefix = '';
6353
6543
 
6354
- function n(t) {
6355
- var n = t / 255;
6356
- return n <= .03928 ? n / 12.92 : Math.pow((n + .055) / 1.055, 2.4);
6544
+ for (var i = 0; i < 6 - hex.length; i++) {
6545
+ prefix += '0';
6357
6546
  }
6358
6547
 
6359
- var _r = r(t),
6360
- _r2 = _slicedToArray(_r, 3),
6361
- e = _r2[0],
6362
- o = _r2[1],
6363
- _ = _r2[2];
6548
+ acc[key] = "".concat(prefix).concat(hex);
6549
+ return acc;
6550
+ }, {});
6551
+ /**
6552
+ * Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
6553
+ */
6364
6554
 
6365
- return .2126 * n(e) + .7152 * n(o) + .0722 * n(_);
6555
+ function nameToHex(color) {
6556
+ var normalizedColorName = color.toLowerCase().trim();
6557
+ var result = compressedColorMap[hash(normalizedColorName)];
6558
+ if (!result) throw new ColorError$1(color);
6559
+ return "#".concat(result);
6366
6560
  }
6367
6561
 
6368
- function F(t) {
6369
- return w(t) > .179;
6562
+ var r = function r(str, amount) {
6563
+ return Array.from(Array(amount)).map(function () {
6564
+ return str;
6565
+ }).join('');
6566
+ };
6567
+
6568
+ var reducedHexRegex = new RegExp("^#".concat(r('([a-f0-9])', 3), "([a-f0-9])?$"), 'i');
6569
+ var hexRegex = new RegExp("^#".concat(r('([a-f0-9]{2})', 3), "([a-f0-9]{2})?$"), 'i');
6570
+ var rgbaRegex = new RegExp("^rgba?\\(\\s*(\\d+)\\s*".concat(r(',\\s*(\\d+)\\s*', 2), "(?:,\\s*([\\d.]+))?\\s*\\)$"), 'i');
6571
+ var hslaRegex = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i;
6572
+ var namedColorRegex = /^[a-z]+$/i;
6573
+
6574
+ var roundColor = function roundColor(color) {
6575
+ return Math.round(color * 255);
6576
+ };
6577
+
6578
+ var hslToRgb = function hslToRgb(hue, saturation, lightness) {
6579
+ var l = lightness / 100;
6580
+
6581
+ if (saturation === 0) {
6582
+ // achromatic
6583
+ return [l, l, l].map(roundColor);
6584
+ } // formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
6585
+
6586
+
6587
+ var huePrime = (hue % 360 + 360) % 360 / 60;
6588
+ var chroma = (1 - Math.abs(2 * l - 1)) * (saturation / 100);
6589
+ var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
6590
+ var red = 0;
6591
+ var green = 0;
6592
+ var blue = 0;
6593
+
6594
+ if (huePrime >= 0 && huePrime < 1) {
6595
+ red = chroma;
6596
+ green = secondComponent;
6597
+ } else if (huePrime >= 1 && huePrime < 2) {
6598
+ red = secondComponent;
6599
+ green = chroma;
6600
+ } else if (huePrime >= 2 && huePrime < 3) {
6601
+ green = chroma;
6602
+ blue = secondComponent;
6603
+ } else if (huePrime >= 3 && huePrime < 4) {
6604
+ green = secondComponent;
6605
+ blue = chroma;
6606
+ } else if (huePrime >= 4 && huePrime < 5) {
6607
+ red = secondComponent;
6608
+ blue = chroma;
6609
+ } else if (huePrime >= 5 && huePrime < 6) {
6610
+ red = chroma;
6611
+ blue = secondComponent;
6612
+ }
6613
+
6614
+ var lightnessModification = l - chroma / 2;
6615
+ var finalRed = red + lightnessModification;
6616
+ var finalGreen = green + lightnessModification;
6617
+ var finalBlue = blue + lightnessModification;
6618
+ return [finalRed, finalGreen, finalBlue].map(roundColor);
6619
+ }; // taken from:
6620
+
6621
+ /**
6622
+ * Returns a number (float) representing the luminance of a color.
6623
+ */
6624
+
6625
+
6626
+ function getLuminance(color) {
6627
+ if (color === 'transparent') return 0;
6628
+
6629
+ function f(x) {
6630
+ var channel = x / 255;
6631
+ return channel <= 0.03928 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);
6632
+ }
6633
+
6634
+ var _parseToRgba = parseToRgba(color),
6635
+ _parseToRgba2 = _slicedToArray(_parseToRgba, 3),
6636
+ r = _parseToRgba2[0],
6637
+ g = _parseToRgba2[1],
6638
+ b = _parseToRgba2[2];
6639
+
6640
+ return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b);
6641
+ } // taken from:
6642
+ /**
6643
+ * An alternative function to `readableColor`. Returns whether or not the
6644
+ * readable color (i.e. the color to be place on top the input color) should be
6645
+ * black.
6646
+ */
6647
+
6648
+
6649
+ function readableColorIsBlack(color) {
6650
+ return getLuminance(color) > 0.179;
6370
6651
  }
6371
6652
 
6372
6653
  var _excluded$1 = ["pos"];
@@ -6387,7 +6668,7 @@ var Cursor = function Cursor(_ref3) {
6387
6668
  _ref3$size = _ref3.size,
6388
6669
  size = _ref3$size === void 0 ? 40 : _ref3$size,
6389
6670
  text = _ref3.text;
6390
- var textColor = F(color) ? "#222" : "#EEE";
6671
+ var textColor = readableColorIsBlack(color) ? "#222" : "#EEE";
6391
6672
  return /*#__PURE__*/React__default['default'].createElement(StyledCursor, null, /*#__PURE__*/React__default['default'].createElement("svg", {
6392
6673
  version: "1.1",
6393
6674
  id: "Layer_1",
@@ -8462,8 +8743,10 @@ var getActionsFromItem = function getActionsFromItem(item, itemMap) {
8462
8743
  };
8463
8744
 
8464
8745
  var useAvailableActions = function useAvailableActions() {
8746
+ var itemMap = recoil.useRecoilValue(ItemMapAtom);
8747
+
8465
8748
  var _useRecoilValue = recoil.useRecoilValue(ConfigurationAtom),
8466
- itemMap = _useRecoilValue.itemTemplates;
8749
+ itemTemplates = _useRecoilValue.itemTemplates;
8467
8750
 
8468
8751
  var selected = recoil.useRecoilValue(SelectedItemsAtom);
8469
8752
 
@@ -8473,6 +8756,13 @@ var useAvailableActions = function useAvailableActions() {
8473
8756
  setAvailableActions = _React$useState2[1];
8474
8757
 
8475
8758
  var isMountedRef = React__default['default'].useRef(false);
8759
+ React__default['default'].useEffect(function () {
8760
+ // Mounted guard
8761
+ isMountedRef.current = true;
8762
+ return function () {
8763
+ isMountedRef.current = false;
8764
+ };
8765
+ }, []);
8476
8766
  var getItemListOrSelected = recoil.useRecoilCallback(function (_ref) {
8477
8767
  var snapshot = _ref.snapshot;
8478
8768
  return /*#__PURE__*/function () {
@@ -8520,19 +8810,12 @@ var useAvailableActions = function useAvailableActions() {
8520
8810
  };
8521
8811
  }();
8522
8812
  }, []);
8523
- React__default['default'].useEffect(function () {
8524
- // Mounted guard
8525
- isMountedRef.current = true;
8526
- return function () {
8527
- isMountedRef.current = false;
8528
- };
8529
- }, []);
8530
8813
  /**
8531
8814
  * Returns available actions for selected items. An action is kept only if all
8532
8815
  * items have this exact same action with same parameters.
8533
8816
  */
8534
8817
 
8535
- var updateAvailableActions = React__default['default'].useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
8818
+ var updateAvailableActions = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
8536
8819
  var _yield$getItemListOrS, _yield$getItemListOrS2, selectedItemIds, selectedItemList, allActions;
8537
8820
 
8538
8821
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
@@ -8562,13 +8845,13 @@ var useAvailableActions = function useAvailableActions() {
8562
8845
 
8563
8846
  case 9:
8564
8847
  allActions = selectedItemList.reduce(function (acc, item) {
8565
- var itemActions = getActionsFromItem(item, itemMap);
8848
+ var itemActions = getActionsFromItem(item, itemTemplates);
8566
8849
  return acc.filter(function (value) {
8567
8850
  return itemActions.some(function (itemAction) {
8568
8851
  return es6(value, itemAction);
8569
8852
  });
8570
8853
  });
8571
- }, getActionsFromItem(selectedItemList[0], itemMap));
8854
+ }, getActionsFromItem(selectedItemList[0], itemTemplates));
8572
8855
  setAvailableActions(allActions);
8573
8856
  _context2.next = 14;
8574
8857
  break;
@@ -8582,11 +8865,11 @@ var useAvailableActions = function useAvailableActions() {
8582
8865
  }
8583
8866
  }
8584
8867
  }, _callee2);
8585
- })), [getItemListOrSelected, itemMap]); // Update available actions when selection change
8868
+ })), [getItemListOrSelected, itemTemplates]); // Update available actions when selection change
8586
8869
 
8587
- React__default['default'].useEffect(function () {
8588
- updateAvailableActions();
8589
- }, [updateAvailableActions, selected]);
8870
+ React__default['default'].useEffect(updateAvailableActions, [updateAvailableActions, selected]); // Debounced update available actions when items change
8871
+
8872
+ useDebouncedEffect(updateAvailableActions, [itemMap, updateAvailableActions], 300);
8590
8873
  return {
8591
8874
  availableActions: availableActions
8592
8875
  };
@@ -8705,22 +8988,29 @@ var dayjs_min = {exports: {}};
8705
8988
  return void 0 === t;
8706
8989
  }
8707
8990
  },
8708
- D = "en",
8709
- v = {};
8991
+ v = "en",
8992
+ D = {};
8710
8993
 
8711
- v[D] = M;
8994
+ D[v] = M;
8712
8995
 
8713
8996
  var p = function p(t) {
8714
8997
  return t instanceof _;
8715
8998
  },
8716
- S = function S(t, e, n) {
8717
- var r;
8718
- if (!t) return D;
8719
- if ("string" == typeof t) v[t] && (r = t), e && (v[t] = e, r = t);else {
8720
- var i = t.name;
8721
- v[i] = t, r = i;
8999
+ S = function t(e, n, r) {
9000
+ var i;
9001
+ if (!e) return v;
9002
+
9003
+ if ("string" == typeof e) {
9004
+ var s = e.toLowerCase();
9005
+ D[s] && (i = s), n && (D[s] = n, i = s);
9006
+ var u = e.split("-");
9007
+ if (!i && u.length > 1) return t(u[0]);
9008
+ } else {
9009
+ var a = e.name;
9010
+ D[a] = e, i = a;
8722
9011
  }
8723
- return !n && r && (D = r), r || !n && D;
9012
+
9013
+ return !r && i && (v = i), i || !r && v;
8724
9014
  },
8725
9015
  w = function w(t, e) {
8726
9016
  if (p(t)) return t.clone();
@@ -8808,9 +9098,9 @@ var dayjs_min = {exports: {}};
8808
9098
  return r ? $(1, M) : $(0, M + 1);
8809
9099
 
8810
9100
  case o:
8811
- var D = this.$locale().weekStart || 0,
8812
- v = (y < D ? y + 7 : y) - D;
8813
- return $(r ? m - v : m + (6 - v), M);
9101
+ var v = this.$locale().weekStart || 0,
9102
+ D = (y < v ? y + 7 : y) - v;
9103
+ return $(r ? m - D : m + (6 - D), M);
8814
9104
 
8815
9105
  case a:
8816
9106
  case d:
@@ -8927,12 +9217,12 @@ var dayjs_min = {exports: {}};
8927
9217
  M = w(r),
8928
9218
  m = (M.utcOffset() - this.utcOffset()) * e,
8929
9219
  g = this - M,
8930
- D = O.m(this, M);
8931
- return D = (l = {}, l[c] = D / 12, l[f] = D, l[h] = D / 3, l[o] = (g - m) / 6048e5, l[a] = (g - m) / 864e5, l[u] = g / n, l[s] = g / e, l[i] = g / t, l)[y] || g, $ ? D : O.a(D);
9220
+ v = O.m(this, M);
9221
+ return v = (l = {}, l[c] = v / 12, l[f] = v, l[h] = v / 3, l[o] = (g - m) / 6048e5, l[a] = (g - m) / 864e5, l[u] = g / n, l[s] = g / e, l[i] = g / t, l)[y] || g, $ ? v : O.a(v);
8932
9222
  }, m.daysInMonth = function () {
8933
9223
  return this.endOf(f).$D;
8934
9224
  }, m.$locale = function () {
8935
- return v[this.$L];
9225
+ return D[this.$L];
8936
9226
  }, m.locale = function (t, e) {
8937
9227
  if (!t) return this.$L;
8938
9228
  var n = this.clone(),
@@ -8960,7 +9250,7 @@ var dayjs_min = {exports: {}};
8960
9250
  return t.$i || (t(e, _, w), t.$i = !0), w;
8961
9251
  }, w.locale = S, w.isDayjs = p, w.unix = function (t) {
8962
9252
  return w(1e3 * t);
8963
- }, w.en = v[D], w.Ls = v, w.p = {}, w;
9253
+ }, w.en = D[v], w.Ls = D, w.p = {}, w;
8964
9254
  });
8965
9255
  })(dayjs_min);
8966
9256
 
@@ -9164,7 +9454,11 @@ var SyncBoard = function SyncBoard(_ref) {
9164
9454
  });
9165
9455
  }, [setConfiguration, uid]);
9166
9456
  useResizeObserver(boardWrapperRef, function () {
9167
- return setConfiguration(function (prev) {
9457
+ if (!boardWrapperRef.current) {
9458
+ return;
9459
+ }
9460
+
9461
+ setConfiguration(function (prev) {
9168
9462
  return _objectSpread2(_objectSpread2({}, prev), {}, {
9169
9463
  boardWrapperRect: boardWrapperRef.current.getBoundingClientRect()
9170
9464
  });
@@ -9239,6 +9533,7 @@ exports.useAvailableActions = useAvailableActions;
9239
9533
  exports.useBoardConfig = useBoardConfig;
9240
9534
  exports.useBoardPosition = useDim;
9241
9535
  exports.useBoardState = useBoardState;
9536
+ exports.useDebouncedItems = useDebouncedItems;
9242
9537
  exports.useItemActions = useItemActions;
9243
9538
  exports.useItemInteraction = useItemInteraction;
9244
9539
  exports.useItems = useItemList;