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/esm/index.js CHANGED
@@ -1,4 +1,5 @@
1
- import React, { forwardRef, useContext, createContext, createElement, useRef, useLayoutEffect, useEffect, useMemo, memo } from 'react';
1
+ import * as React from 'react';
2
+ import React__default, { forwardRef, useContext, createContext, createElement, Fragment, useRef, useLayoutEffect, useEffect, useMemo, memo, useCallback } from 'react';
2
3
  import { atom, selector, useRecoilValue, useRecoilCallback, useRecoilState, useSetRecoilState, RecoilRoot } from 'recoil';
3
4
 
4
5
  function ownKeys(object, enumerableOnly) {
@@ -460,26 +461,17 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
460
461
  };
461
462
  }
462
463
 
463
- // This file replaces `index.js` in bundlers like webpack or Rollup,
464
-
465
464
  var nanoid = function nanoid() {
466
465
  var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 21;
467
466
  var id = '';
468
- var bytes = crypto.getRandomValues(new Uint8Array(size)); // A compact alternative for `for (var i = 0; i < step; i++)`.
467
+ var bytes = crypto.getRandomValues(new Uint8Array(size));
469
468
 
470
469
  while (size--) {
471
- // It is incorrect to use bytes exceeding the alphabet size.
472
- // The following mask reduces the random byte in the 0-255 value
473
- // range to the 0-63 value range. Therefore, adding hacks, such
474
- // as empty string fallback or magic numbers, is unneccessary because
475
- // the bitmask trims bytes down to the alphabet size.
476
470
  var _byte = bytes[size] & 63;
477
471
 
478
472
  if (_byte < 36) {
479
- // `0-9a-z`
480
473
  id += _byte.toString(36);
481
474
  } else if (_byte < 62) {
482
- // `A-Z`
483
475
  id += (_byte - 26).toString(36).toUpperCase();
484
476
  } else if (_byte < 63) {
485
477
  id += '_';
@@ -771,7 +763,7 @@ function memoize(fn) {
771
763
  };
772
764
  }
773
765
 
774
- 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
766
+ 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
775
767
 
776
768
  var isPropValid = /* #__PURE__ */memoize(function (prop) {
777
769
  return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111
@@ -844,7 +836,13 @@ var StyleSheet = /*#__PURE__*/function () {
844
836
  var before;
845
837
 
846
838
  if (_this.tags.length === 0) {
847
- before = _this.prepend ? _this.container.firstChild : _this.before;
839
+ if (_this.insertionPoint) {
840
+ before = _this.insertionPoint.nextSibling;
841
+ } else if (_this.prepend) {
842
+ before = _this.container.firstChild;
843
+ } else {
844
+ before = _this.before;
845
+ }
848
846
  } else {
849
847
  before = _this.tags[_this.tags.length - 1].nextSibling;
850
848
  }
@@ -862,6 +860,7 @@ var StyleSheet = /*#__PURE__*/function () {
862
860
  this.key = options.key;
863
861
  this.container = options.container;
864
862
  this.prepend = options.prepend;
863
+ this.insertionPoint = options.insertionPoint;
865
864
  this.before = null;
866
865
  }
867
866
 
@@ -902,7 +901,7 @@ var StyleSheet = /*#__PURE__*/function () {
902
901
  // the big drawback is that the css won't be editable in devtools
903
902
  sheet.insertRule(rule, sheet.cssRules.length);
904
903
  } catch (e) {
905
- if (process.env.NODE_ENV !== 'production' && !/:(-moz-placeholder|-ms-input-placeholder|-moz-read-write|-moz-read-only){/.test(rule)) {
904
+ 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)) {
906
905
  console.error("There was a problem inserting the following rule: \"" + rule + "\"", e);
907
906
  }
908
907
  }
@@ -916,7 +915,7 @@ var StyleSheet = /*#__PURE__*/function () {
916
915
  _proto.flush = function flush() {
917
916
  // $FlowFixMe
918
917
  this.tags.forEach(function (tag) {
919
- return tag.parentNode.removeChild(tag);
918
+ return tag.parentNode && tag.parentNode.removeChild(tag);
920
919
  });
921
920
  this.tags = [];
922
921
  this.ctr = 0;
@@ -949,13 +948,19 @@ var abs = Math.abs;
949
948
  */
950
949
 
951
950
  var from = String.fromCharCode;
951
+ /**
952
+ * @param {object}
953
+ * @return {object}
954
+ */
955
+
956
+ var assign = Object.assign;
952
957
  /**
953
958
  * @param {string} value
954
959
  * @param {number} length
955
960
  * @return {number}
956
961
  */
957
962
 
958
- function hash(value, length) {
963
+ function hash$1(value, length) {
959
964
  return (((length << 2 ^ charat(value, 0)) << 2 ^ charat(value, 1)) << 2 ^ charat(value, 2)) << 2 ^ charat(value, 3);
960
965
  }
961
966
  /**
@@ -987,7 +992,7 @@ function replace(value, pattern, replacement) {
987
992
  }
988
993
  /**
989
994
  * @param {string} value
990
- * @param {string} value
995
+ * @param {string} search
991
996
  * @return {number}
992
997
  */
993
998
 
@@ -1056,11 +1061,11 @@ var character = 0;
1056
1061
  var characters = '';
1057
1062
  /**
1058
1063
  * @param {string} value
1059
- * @param {object} root
1060
- * @param {object?} parent
1064
+ * @param {object | null} root
1065
+ * @param {object | null} parent
1061
1066
  * @param {string} type
1062
- * @param {string[]} props
1063
- * @param {object[]} children
1067
+ * @param {string[] | string} props
1068
+ * @param {object[] | string} children
1064
1069
  * @param {number} length
1065
1070
  */
1066
1071
 
@@ -1079,13 +1084,15 @@ function node(value, root, parent, type, props, children, length) {
1079
1084
  };
1080
1085
  }
1081
1086
  /**
1082
- * @param {string} value
1083
1087
  * @param {object} root
1084
- * @param {string} type
1088
+ * @param {object} props
1089
+ * @return {object}
1085
1090
  */
1086
1091
 
1087
- function copy(value, root, type) {
1088
- return node(value, root.root, root.parent, type, root.props, root.children, 0);
1092
+ function copy(root, props) {
1093
+ return assign(node('', null, null, '', null, null, 0), root, {
1094
+ length: -root.length
1095
+ }, props);
1089
1096
  }
1090
1097
  /**
1091
1098
  * @return {number}
@@ -1244,7 +1251,8 @@ function delimiter(type) {
1244
1251
 
1245
1252
  case 34:
1246
1253
  case 39:
1247
- return delimiter(type === 34 || type === 39 ? type : character);
1254
+ if (type !== 34 && type !== 39) delimiter(character);
1255
+ break;
1248
1256
  // (
1249
1257
 
1250
1258
  case 40:
@@ -1328,11 +1336,18 @@ function parse(value, root, parent, rule, rules, rulesets, pseudo, points, decla
1328
1336
 
1329
1337
  while (scanning) {
1330
1338
  switch (previous = character, character = next()) {
1331
- // " ' [ (
1339
+ // (
1340
+ case 40:
1341
+ if (previous != 108 && characters.charCodeAt(length - 1) == 58) {
1342
+ if (indexof(characters += replace(delimit(character), '&', '&\f'), '&\f') != -1) ampersand = -1;
1343
+ break;
1344
+ }
1345
+
1346
+ // " ' [
1347
+
1332
1348
  case 34:
1333
1349
  case 39:
1334
1350
  case 91:
1335
- case 40:
1336
1351
  characters += delimit(character);
1337
1352
  break;
1338
1353
  // \t \n \r \s
@@ -1398,7 +1413,7 @@ function parse(value, root, parent, rule, rules, rulesets, pseudo, points, decla
1398
1413
  break;
1399
1414
 
1400
1415
  default:
1401
- parse(characters, reference, reference, reference, [''], children, length, points, children);
1416
+ parse(characters, reference, reference, reference, [''], children, 0, points, children);
1402
1417
  }
1403
1418
  }
1404
1419
 
@@ -1427,7 +1442,7 @@ function parse(value, root, parent, rule, rules, rulesets, pseudo, points, decla
1427
1442
  case 64:
1428
1443
  // -
1429
1444
  if (peek() === 45) characters += delimit(next());
1430
- atrule = peek(), offset = strlen(type = characters += identifier(caret())), character++;
1445
+ atrule = peek(), offset = length = strlen(type = characters += identifier(caret())), character++;
1431
1446
  break;
1432
1447
  // -
1433
1448
 
@@ -1497,7 +1512,7 @@ function declaration(value, root, parent, length) {
1497
1512
  */
1498
1513
 
1499
1514
  function prefix(value, length) {
1500
- switch (hash(value, length)) {
1515
+ switch (hash$1(value, length)) {
1501
1516
  // color-adjust
1502
1517
  case 5103:
1503
1518
  return WEBKIT + 'print-' + value + value;
@@ -1702,6 +1717,9 @@ function stringify(element, index, children, callback) {
1702
1717
  case COMMENT:
1703
1718
  return '';
1704
1719
 
1720
+ case KEYFRAMES:
1721
+ return element["return"] = element.value + '{' + serialize(element.children, callback) + '}';
1722
+
1705
1723
  case RULESET:
1706
1724
  element.value = element.props.join(',');
1707
1725
  }
@@ -1744,13 +1762,15 @@ function rulesheet(callback) {
1744
1762
  */
1745
1763
 
1746
1764
  function prefixer(element, index, children, callback) {
1747
- if (!element["return"]) switch (element.type) {
1765
+ if (element.length > -1) if (!element["return"]) switch (element.type) {
1748
1766
  case DECLARATION:
1749
1767
  element["return"] = prefix(element.value, element.length);
1750
1768
  break;
1751
1769
 
1752
1770
  case KEYFRAMES:
1753
- return serialize([copy(replace(element.value, '@', '@' + WEBKIT), element, '')], callback);
1771
+ return serialize([copy(element, {
1772
+ value: replace(element.value, '@', '@' + WEBKIT)
1773
+ })], callback);
1754
1774
 
1755
1775
  case RULESET:
1756
1776
  if (element.length) return combine(element.props, function (value) {
@@ -1758,11 +1778,19 @@ function prefixer(element, index, children, callback) {
1758
1778
  // :read-(only|write)
1759
1779
  case ':read-only':
1760
1780
  case ':read-write':
1761
- return serialize([copy(replace(value, /:(read-\w+)/, ':' + MOZ + '$1'), element, '')], callback);
1781
+ return serialize([copy(element, {
1782
+ props: [replace(value, /:(read-\w+)/, ':' + MOZ + '$1')]
1783
+ })], callback);
1762
1784
  // :placeholder
1763
1785
 
1764
1786
  case '::placeholder':
1765
- 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);
1787
+ return serialize([copy(element, {
1788
+ props: [replace(value, /:(plac\w+)/, ':' + WEBKIT + 'input-$1')]
1789
+ }), copy(element, {
1790
+ props: [replace(value, /:(plac\w+)/, ':' + MOZ + '$1')]
1791
+ }), copy(element, {
1792
+ props: [replace(value, /:(plac\w+)/, MS + 'input-$1')]
1793
+ })], callback);
1766
1794
  }
1767
1795
 
1768
1796
  return '';
@@ -1772,6 +1800,29 @@ function prefixer(element, index, children, callback) {
1772
1800
 
1773
1801
  var last = function last(arr) {
1774
1802
  return arr.length ? arr[arr.length - 1] : null;
1803
+ }; // based on https://github.com/thysultan/stylis.js/blob/e6843c373ebcbbfade25ebcc23f540ed8508da0a/src/Tokenizer.js#L239-L244
1804
+
1805
+
1806
+ var identifierWithPointTracking = function identifierWithPointTracking(begin, points, index) {
1807
+ var previous = 0;
1808
+ var character = 0;
1809
+
1810
+ while (true) {
1811
+ previous = character;
1812
+ character = peek(); // &\f
1813
+
1814
+ if (previous === 38 && character === 12) {
1815
+ points[index] = 1;
1816
+ }
1817
+
1818
+ if (token(character)) {
1819
+ break;
1820
+ }
1821
+
1822
+ next();
1823
+ }
1824
+
1825
+ return slice(begin, position);
1775
1826
  };
1776
1827
 
1777
1828
  var toRules = function toRules(parsed, points) {
@@ -1791,7 +1842,7 @@ var toRules = function toRules(parsed, points) {
1791
1842
  points[index] = 1;
1792
1843
  }
1793
1844
 
1794
- parsed[index] += identifier(position - 1);
1845
+ parsed[index] += identifierWithPointTracking(position - 1, points, index);
1795
1846
  break;
1796
1847
 
1797
1848
  case 2:
@@ -1825,8 +1876,9 @@ var getRules = function getRules(value, points) {
1825
1876
  var fixedElements = /* #__PURE__ */new WeakMap();
1826
1877
 
1827
1878
  var compat = function compat(element) {
1828
- if (element.type !== 'rule' || !element.parent || // .length indicates if this rule contains pseudo or not
1829
- !element.length) {
1879
+ if (element.type !== 'rule' || !element.parent || // positive .length indicates that this rule contains pseudo
1880
+ // negative .length indicates that this rule has been already prefixed
1881
+ element.length < 1) {
1830
1882
  return;
1831
1883
  }
1832
1884
 
@@ -2062,7 +2114,8 @@ var createCache = function createCache(options) {
2062
2114
  container: container,
2063
2115
  nonce: options.nonce,
2064
2116
  speedy: options.speedy,
2065
- prepend: options.prepend
2117
+ prepend: options.prepend,
2118
+ insertionPoint: options.insertionPoint
2066
2119
  }),
2067
2120
  nonce: options.nonce,
2068
2121
  inserted: inserted,
@@ -2080,22 +2133,22 @@ var reactIs$1 = {exports: {}};
2080
2133
  var reactIs_production_min = {};
2081
2134
 
2082
2135
  var b = "function" === typeof Symbol && Symbol["for"],
2083
- c$1 = b ? Symbol["for"]("react.element") : 60103,
2136
+ c = b ? Symbol["for"]("react.element") : 60103,
2084
2137
  d = b ? Symbol["for"]("react.portal") : 60106,
2085
- e$1 = b ? Symbol["for"]("react.fragment") : 60107,
2086
- f$1 = b ? Symbol["for"]("react.strict_mode") : 60108,
2138
+ e = b ? Symbol["for"]("react.fragment") : 60107,
2139
+ f = b ? Symbol["for"]("react.strict_mode") : 60108,
2087
2140
  g = b ? Symbol["for"]("react.profiler") : 60114,
2088
2141
  h = b ? Symbol["for"]("react.provider") : 60109,
2089
2142
  k = b ? Symbol["for"]("react.context") : 60110,
2090
- l$1 = b ? Symbol["for"]("react.async_mode") : 60111,
2143
+ l = b ? Symbol["for"]("react.async_mode") : 60111,
2091
2144
  m = b ? Symbol["for"]("react.concurrent_mode") : 60111,
2092
- n$1 = b ? Symbol["for"]("react.forward_ref") : 60112,
2145
+ n = b ? Symbol["for"]("react.forward_ref") : 60112,
2093
2146
  p = b ? Symbol["for"]("react.suspense") : 60113,
2094
2147
  q = b ? Symbol["for"]("react.suspense_list") : 60120,
2095
2148
  r$1 = b ? Symbol["for"]("react.memo") : 60115,
2096
- t$1 = b ? Symbol["for"]("react.lazy") : 60116,
2149
+ t = b ? Symbol["for"]("react.lazy") : 60116,
2097
2150
  v = b ? Symbol["for"]("react.block") : 60121,
2098
- w$1 = b ? Symbol["for"]("react.fundamental") : 60117,
2151
+ w = b ? Symbol["for"]("react.fundamental") : 60117,
2099
2152
  x = b ? Symbol["for"]("react.responder") : 60118,
2100
2153
  y = b ? Symbol["for"]("react.scope") : 60119;
2101
2154
 
@@ -2104,21 +2157,21 @@ function z(a) {
2104
2157
  var u = a.$$typeof;
2105
2158
 
2106
2159
  switch (u) {
2107
- case c$1:
2160
+ case c:
2108
2161
  switch (a = a.type, a) {
2109
- case l$1:
2162
+ case l:
2110
2163
  case m:
2111
- case e$1:
2164
+ case e:
2112
2165
  case g:
2113
- case f$1:
2166
+ case f:
2114
2167
  case p:
2115
2168
  return a;
2116
2169
 
2117
2170
  default:
2118
2171
  switch (a = a && a.$$typeof, a) {
2119
2172
  case k:
2120
- case n$1:
2121
- case t$1:
2173
+ case n:
2174
+ case t:
2122
2175
  case r$1:
2123
2176
  case h:
2124
2177
  return a;
@@ -2139,22 +2192,22 @@ function A(a) {
2139
2192
  return z(a) === m;
2140
2193
  }
2141
2194
 
2142
- reactIs_production_min.AsyncMode = l$1;
2195
+ reactIs_production_min.AsyncMode = l;
2143
2196
  reactIs_production_min.ConcurrentMode = m;
2144
2197
  reactIs_production_min.ContextConsumer = k;
2145
2198
  reactIs_production_min.ContextProvider = h;
2146
- reactIs_production_min.Element = c$1;
2147
- reactIs_production_min.ForwardRef = n$1;
2148
- reactIs_production_min.Fragment = e$1;
2149
- reactIs_production_min.Lazy = t$1;
2199
+ reactIs_production_min.Element = c;
2200
+ reactIs_production_min.ForwardRef = n;
2201
+ reactIs_production_min.Fragment = e;
2202
+ reactIs_production_min.Lazy = t;
2150
2203
  reactIs_production_min.Memo = r$1;
2151
2204
  reactIs_production_min.Portal = d;
2152
2205
  reactIs_production_min.Profiler = g;
2153
- reactIs_production_min.StrictMode = f$1;
2206
+ reactIs_production_min.StrictMode = f;
2154
2207
  reactIs_production_min.Suspense = p;
2155
2208
 
2156
2209
  reactIs_production_min.isAsyncMode = function (a) {
2157
- return A(a) || z(a) === l$1;
2210
+ return A(a) || z(a) === l;
2158
2211
  };
2159
2212
 
2160
2213
  reactIs_production_min.isConcurrentMode = A;
@@ -2168,19 +2221,19 @@ reactIs_production_min.isContextProvider = function (a) {
2168
2221
  };
2169
2222
 
2170
2223
  reactIs_production_min.isElement = function (a) {
2171
- return "object" === _typeof(a) && null !== a && a.$$typeof === c$1;
2224
+ return "object" === _typeof(a) && null !== a && a.$$typeof === c;
2172
2225
  };
2173
2226
 
2174
2227
  reactIs_production_min.isForwardRef = function (a) {
2175
- return z(a) === n$1;
2228
+ return z(a) === n;
2176
2229
  };
2177
2230
 
2178
2231
  reactIs_production_min.isFragment = function (a) {
2179
- return z(a) === e$1;
2232
+ return z(a) === e;
2180
2233
  };
2181
2234
 
2182
2235
  reactIs_production_min.isLazy = function (a) {
2183
- return z(a) === t$1;
2236
+ return z(a) === t;
2184
2237
  };
2185
2238
 
2186
2239
  reactIs_production_min.isMemo = function (a) {
@@ -2196,7 +2249,7 @@ reactIs_production_min.isProfiler = function (a) {
2196
2249
  };
2197
2250
 
2198
2251
  reactIs_production_min.isStrictMode = function (a) {
2199
- return z(a) === f$1;
2252
+ return z(a) === f;
2200
2253
  };
2201
2254
 
2202
2255
  reactIs_production_min.isSuspense = function (a) {
@@ -2204,7 +2257,7 @@ reactIs_production_min.isSuspense = function (a) {
2204
2257
  };
2205
2258
 
2206
2259
  reactIs_production_min.isValidElementType = function (a) {
2207
- 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);
2260
+ 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);
2208
2261
  };
2209
2262
 
2210
2263
  reactIs_production_min.typeOf = z;
@@ -2430,7 +2483,7 @@ function getRegisteredStyles$1(registered, registeredStyles, classNames) {
2430
2483
  return rawClassName;
2431
2484
  }
2432
2485
 
2433
- var insertStyles$1 = function insertStyles(cache, serialized, isStringTag) {
2486
+ var registerStyles$1 = function registerStyles(cache, serialized, isStringTag) {
2434
2487
  var className = cache.key + "-" + serialized.name;
2435
2488
 
2436
2489
  if ( // we only need to add the styles to the registered cache if the
@@ -2445,6 +2498,11 @@ var insertStyles$1 = function insertStyles(cache, serialized, isStringTag) {
2445
2498
  isBrowser$3 === false) && cache.registered[className] === undefined) {
2446
2499
  cache.registered[className] = serialized.styles;
2447
2500
  }
2501
+ };
2502
+
2503
+ var insertStyles$1 = function insertStyles(cache, serialized, isStringTag) {
2504
+ registerStyles$1(cache, serialized, isStringTag);
2505
+ var className = cache.key + "-" + serialized.name;
2448
2506
 
2449
2507
  if (cache.inserted[serialized.name] === undefined) {
2450
2508
  var current = serialized;
@@ -2602,7 +2660,7 @@ var processStyleValue$1 = function processStyleValue(key, value) {
2602
2660
  };
2603
2661
 
2604
2662
  if (process.env.NODE_ENV !== 'production') {
2605
- var contentValuePattern$1 = /(attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/;
2663
+ var contentValuePattern$1 = /(var|attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/;
2606
2664
  var contentValues$1 = ['normal', 'none', 'initial', 'inherit', 'unset'];
2607
2665
  var oldProcessStyleValue$1 = processStyleValue$1;
2608
2666
  var msPattern$1 = /^-ms-/;
@@ -2869,7 +2927,7 @@ var serializeStyles$1 = function serializeStyles(args, registered, mergedProps)
2869
2927
  };
2870
2928
  };
2871
2929
 
2872
- var hasOwnProperty = Object.prototype.hasOwnProperty;
2930
+ var hasOwnProperty = {}.hasOwnProperty;
2873
2931
  var EmotionCacheContext = /* #__PURE__ */createContext( // we're doing this to avoid preconstruct's dead code elimination in this one case
2874
2932
  // because this module is primarily intended for the browser and node
2875
2933
  // but it's also required in react native and similar environments sometimes
@@ -2879,6 +2937,11 @@ var EmotionCacheContext = /* #__PURE__ */createContext( // we're doing this to a
2879
2937
  typeof HTMLElement !== 'undefined' ? /* #__PURE__ */createCache({
2880
2938
  key: 'css'
2881
2939
  }) : null);
2940
+
2941
+ if (process.env.NODE_ENV !== 'production') {
2942
+ EmotionCacheContext.displayName = 'EmotionCacheContext';
2943
+ }
2944
+
2882
2945
  EmotionCacheContext.Provider;
2883
2946
 
2884
2947
  var withEmotionCache = function withEmotionCache(func) {
@@ -2892,9 +2955,32 @@ var withEmotionCache = function withEmotionCache(func) {
2892
2955
 
2893
2956
  var ThemeContext = /* #__PURE__ */createContext({});
2894
2957
 
2958
+ if (process.env.NODE_ENV !== 'production') {
2959
+ ThemeContext.displayName = 'EmotionThemeContext';
2960
+ }
2961
+
2962
+ var useInsertionEffect$2 = React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : function useInsertionEffect(create) {
2963
+ create();
2964
+ };
2965
+
2966
+ function useInsertionEffectMaybe$1(create) {
2967
+ useInsertionEffect$2(create);
2968
+ }
2969
+
2895
2970
  var typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__';
2896
2971
  var labelPropName = '__EMOTION_LABEL_PLEASE_DO_NOT_USE__';
2897
2972
 
2973
+ var Insertion$2 = function Insertion(_ref) {
2974
+ var cache = _ref.cache,
2975
+ serialized = _ref.serialized,
2976
+ isStringTag = _ref.isStringTag;
2977
+ registerStyles$1(cache, serialized, isStringTag);
2978
+ useInsertionEffectMaybe$1(function () {
2979
+ return insertStyles$1(cache, serialized, isStringTag);
2980
+ });
2981
+ return null;
2982
+ };
2983
+
2898
2984
  var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
2899
2985
  var cssProp = props.css; // so that using `css` from `emotion` and passing the result to the css prop works
2900
2986
  // not passing the registered cache to serializeStyles because it would
@@ -2904,7 +2990,7 @@ var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
2904
2990
  cssProp = cache.registered[cssProp];
2905
2991
  }
2906
2992
 
2907
- var type = props[typePropName];
2993
+ var WrappedComponent = props[typePropName];
2908
2994
  var registeredStyles = [cssProp];
2909
2995
  var className = '';
2910
2996
 
@@ -2914,7 +3000,7 @@ var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
2914
3000
  className = props.className + " ";
2915
3001
  }
2916
3002
 
2917
- var serialized = serializeStyles$1(registeredStyles, undefined, typeof cssProp === 'function' || Array.isArray(cssProp) ? useContext(ThemeContext) : undefined);
3003
+ var serialized = serializeStyles$1(registeredStyles, undefined, useContext(ThemeContext));
2918
3004
 
2919
3005
  if (process.env.NODE_ENV !== 'production' && serialized.name.indexOf('-') === -1) {
2920
3006
  var labelFromStack = props[labelPropName];
@@ -2924,7 +3010,6 @@ var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
2924
3010
  }
2925
3011
  }
2926
3012
 
2927
- insertStyles$1(cache, serialized, typeof type === 'string');
2928
3013
  className += cache.key + "-" + serialized.name;
2929
3014
  var newProps = {};
2930
3015
 
@@ -2936,8 +3021,11 @@ var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
2936
3021
 
2937
3022
  newProps.ref = ref;
2938
3023
  newProps.className = className;
2939
- var ele = /*#__PURE__*/createElement(type, newProps);
2940
- return ele;
3024
+ return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(Insertion$2, {
3025
+ cache: cache,
3026
+ serialized: serialized,
3027
+ isStringTag: typeof WrappedComponent === 'string'
3028
+ }), /*#__PURE__*/createElement(WrappedComponent, newProps));
2941
3029
  });
2942
3030
 
2943
3031
  if (process.env.NODE_ENV !== 'production') {
@@ -2946,7 +3034,7 @@ if (process.env.NODE_ENV !== 'production') {
2946
3034
 
2947
3035
  var pkg = {
2948
3036
  name: "@emotion/react",
2949
- version: "11.4.0",
3037
+ version: "11.9.0",
2950
3038
  main: "dist/emotion-react.cjs.js",
2951
3039
  module: "dist/emotion-react.esm.js",
2952
3040
  browser: {
@@ -2954,19 +3042,19 @@ var pkg = {
2954
3042
  "./dist/emotion-react.esm.js": "./dist/emotion-react.browser.esm.js"
2955
3043
  },
2956
3044
  types: "types/index.d.ts",
2957
- 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"],
3045
+ files: ["src", "dist", "jsx-runtime", "jsx-dev-runtime", "_isolated-hnrs", "types/*.d.ts", "macro.js", "macro.d.ts", "macro.js.flow"],
2958
3046
  sideEffects: false,
2959
- author: "mitchellhamilton <mitchell@mitchellhamilton.me>",
3047
+ author: "Emotion Contributors",
2960
3048
  license: "MIT",
2961
3049
  scripts: {
2962
3050
  "test:typescript": "dtslint types"
2963
3051
  },
2964
3052
  dependencies: {
2965
3053
  "@babel/runtime": "^7.13.10",
2966
- "@emotion/cache": "^11.4.0",
2967
- "@emotion/serialize": "^1.0.2",
2968
- "@emotion/sheet": "^1.0.1",
2969
- "@emotion/utils": "^1.0.0",
3054
+ "@emotion/babel-plugin": "^11.7.1",
3055
+ "@emotion/cache": "^11.7.1",
3056
+ "@emotion/serialize": "^1.0.3",
3057
+ "@emotion/utils": "^1.1.0",
2970
3058
  "@emotion/weak-memoize": "^0.2.5",
2971
3059
  "hoist-non-react-statics": "^3.3.1"
2972
3060
  },
@@ -2984,15 +3072,16 @@ var pkg = {
2984
3072
  },
2985
3073
  devDependencies: {
2986
3074
  "@babel/core": "^7.13.10",
2987
- "@emotion/css": "11.1.3",
2988
- "@emotion/css-prettifier": "1.0.0",
3075
+ "@emotion/css": "11.9.0",
3076
+ "@emotion/css-prettifier": "1.0.1",
2989
3077
  "@emotion/server": "11.4.0",
2990
- "@emotion/styled": "11.3.0",
3078
+ "@emotion/styled": "11.8.1",
2991
3079
  "@types/react": "^16.9.11",
2992
- dtslint: "^0.3.0",
3080
+ dtslint: "^4.2.1",
2993
3081
  "html-tag-names": "^1.1.2",
2994
3082
  react: "16.14.0",
2995
- "svg-tag-names": "^1.1.1"
3083
+ "svg-tag-names": "^1.1.1",
3084
+ typescript: "^4.5.5"
2996
3085
  },
2997
3086
  repository: "https://github.com/emotion-js/emotion/tree/main/packages/react",
2998
3087
  publishConfig: {
@@ -3000,11 +3089,12 @@ var pkg = {
3000
3089
  },
3001
3090
  "umd:main": "dist/emotion-react.umd.min.js",
3002
3091
  preconstruct: {
3003
- entrypoints: ["./index.js", "./jsx-runtime.js", "./jsx-dev-runtime.js", "./isolated-hoist-non-react-statics-do-not-use-this-in-your-code.js"],
3092
+ entrypoints: ["./index.js", "./jsx-runtime.js", "./jsx-dev-runtime.js", "./_isolated-hnrs.js"],
3004
3093
  umdName: "emotionReact"
3005
3094
  }
3006
3095
  };
3007
3096
 
3097
+ var useInsertionEffect$1 = React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : useLayoutEffect;
3008
3098
  var warnedAboutCssPropForGlobal = false; // maintain place over rerenders.
3009
3099
  // initial render from browser, insertBefore context.sheet.tags[0] or if a style hasn't been inserted there yet, appendChild
3010
3100
  // initial client-side render from SSR, use place of hydrating tag
@@ -3020,14 +3110,15 @@ var Global = /* #__PURE__ */withEmotionCache(function (props, cache) {
3020
3110
  }
3021
3111
 
3022
3112
  var styles = props.styles;
3023
- var serialized = serializeStyles$1([styles], undefined, typeof styles === 'function' || Array.isArray(styles) ? useContext(ThemeContext) : undefined); // but it is based on a constant that will never change at runtime
3113
+ var serialized = serializeStyles$1([styles], undefined, useContext(ThemeContext)); // but it is based on a constant that will never change at runtime
3024
3114
  // it's effectively like having two implementations and switching them out
3025
3115
  // so it's not actually breaking anything
3026
3116
 
3027
3117
  var sheetRef = useRef();
3028
- useLayoutEffect(function () {
3029
- var key = cache.key + "-global";
3030
- var sheet = new StyleSheet({
3118
+ useInsertionEffect$1(function () {
3119
+ var key = cache.key + "-global"; // use case of https://github.com/emotion-js/emotion/issues/2675
3120
+
3121
+ var sheet = new cache.sheet.constructor({
3031
3122
  key: key,
3032
3123
  nonce: cache.sheet.nonce,
3033
3124
  container: cache.sheet.container,
@@ -3053,7 +3144,7 @@ var Global = /* #__PURE__ */withEmotionCache(function (props, cache) {
3053
3144
  sheet.flush();
3054
3145
  };
3055
3146
  }, [cache]);
3056
- useLayoutEffect(function () {
3147
+ useInsertionEffect$1(function () {
3057
3148
  var sheetRefCurrent = sheetRef.current;
3058
3149
  var sheet = sheetRefCurrent[0],
3059
3150
  rehydrating = sheetRefCurrent[1];
@@ -3168,8 +3259,20 @@ function merge(registered, css, className) {
3168
3259
  return rawClassName + css(registeredStyles);
3169
3260
  }
3170
3261
 
3262
+ var Insertion$1 = function Insertion(_ref) {
3263
+ var cache = _ref.cache,
3264
+ serializedArr = _ref.serializedArr;
3265
+ useInsertionEffectMaybe$1(function () {
3266
+ for (var i = 0; i < serializedArr.length; i++) {
3267
+ insertStyles$1(cache, serializedArr[i], false);
3268
+ }
3269
+ });
3270
+ return null;
3271
+ };
3272
+
3171
3273
  var ClassNames = /* #__PURE__ */withEmotionCache(function (props, cache) {
3172
3274
  var hasRendered = false;
3275
+ var serializedArr = [];
3173
3276
 
3174
3277
  var css = function css() {
3175
3278
  if (hasRendered && process.env.NODE_ENV !== 'production') {
@@ -3181,9 +3284,9 @@ var ClassNames = /* #__PURE__ */withEmotionCache(function (props, cache) {
3181
3284
  }
3182
3285
 
3183
3286
  var serialized = serializeStyles$1(args, cache.registered);
3184
- {
3185
- insertStyles$1(cache, serialized, false);
3186
- }
3287
+ serializedArr.push(serialized); // registration has to happen here as the result of this might get consumed by `cx`
3288
+
3289
+ registerStyles$1(cache, serialized, false);
3187
3290
  return cache.key + "-" + serialized.name;
3188
3291
  };
3189
3292
 
@@ -3206,7 +3309,10 @@ var ClassNames = /* #__PURE__ */withEmotionCache(function (props, cache) {
3206
3309
  };
3207
3310
  var ele = props.children(content);
3208
3311
  hasRendered = true;
3209
- return ele;
3312
+ return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(Insertion$1, {
3313
+ cache: cache,
3314
+ serializedArr: serializedArr
3315
+ }), ele);
3210
3316
  });
3211
3317
 
3212
3318
  if (process.env.NODE_ENV !== 'production') {
@@ -3219,7 +3325,10 @@ if (process.env.NODE_ENV !== 'production') {
3219
3325
  var isJest = typeof jest !== 'undefined';
3220
3326
 
3221
3327
  if (isBrowser$2 && !isJest) {
3222
- var globalContext = isBrowser$2 ? window : global;
3328
+ // globalThis has wide browser support - https://caniuse.com/?search=globalThis, Node.js 12 and later
3329
+ var globalContext = // $FlowIgnore
3330
+ typeof globalThis !== 'undefined' ? globalThis // eslint-disable-line no-undef
3331
+ : isBrowser$2 ? window : global;
3223
3332
  var globalKey = "__EMOTION_REACT_" + pkg.version.split('.')[0] + "__";
3224
3333
 
3225
3334
  if (globalContext[globalKey]) {
@@ -3244,7 +3353,7 @@ function getRegisteredStyles(registered, registeredStyles, classNames) {
3244
3353
  return rawClassName;
3245
3354
  }
3246
3355
 
3247
- var insertStyles = function insertStyles(cache, serialized, isStringTag) {
3356
+ var registerStyles = function registerStyles(cache, serialized, isStringTag) {
3248
3357
  var className = cache.key + "-" + serialized.name;
3249
3358
 
3250
3359
  if ( // we only need to add the styles to the registered cache if the
@@ -3259,6 +3368,11 @@ var insertStyles = function insertStyles(cache, serialized, isStringTag) {
3259
3368
  isBrowser$1 === false) && cache.registered[className] === undefined) {
3260
3369
  cache.registered[className] = serialized.styles;
3261
3370
  }
3371
+ };
3372
+
3373
+ var insertStyles = function insertStyles(cache, serialized, isStringTag) {
3374
+ registerStyles(cache, serialized, isStringTag);
3375
+ var className = cache.key + "-" + serialized.name;
3262
3376
 
3263
3377
  if (cache.inserted[serialized.name] === undefined) {
3264
3378
  var current = serialized;
@@ -3610,8 +3724,27 @@ var composeShouldForwardProps = function composeShouldForwardProps(tag, options,
3610
3724
  return shouldForwardProp;
3611
3725
  };
3612
3726
 
3727
+ var useInsertionEffect = React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : function useInsertionEffect(create) {
3728
+ create();
3729
+ };
3730
+
3731
+ function useInsertionEffectMaybe(create) {
3732
+ useInsertionEffect(create);
3733
+ }
3734
+
3613
3735
  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";
3614
3736
 
3737
+ var Insertion = function Insertion(_ref) {
3738
+ var cache = _ref.cache,
3739
+ serialized = _ref.serialized,
3740
+ isStringTag = _ref.isStringTag;
3741
+ registerStyles(cache, serialized, isStringTag);
3742
+ useInsertionEffectMaybe(function () {
3743
+ return insertStyles(cache, serialized, isStringTag);
3744
+ });
3745
+ return null;
3746
+ };
3747
+
3615
3748
  var createStyled = function createStyled(tag, options) {
3616
3749
  if (process.env.NODE_ENV !== 'production') {
3617
3750
  if (tag === undefined) {
@@ -3662,7 +3795,7 @@ var createStyled = function createStyled(tag, options) {
3662
3795
 
3663
3796
 
3664
3797
  var Styled = withEmotionCache(function (props, cache, ref) {
3665
- var finalTag = shouldUseAs && props.as || baseTag;
3798
+ var FinalTag = shouldUseAs && props.as || baseTag;
3666
3799
  var className = '';
3667
3800
  var classInterpolations = [];
3668
3801
  var mergedProps = props;
@@ -3684,14 +3817,13 @@ var createStyled = function createStyled(tag, options) {
3684
3817
  }
3685
3818
 
3686
3819
  var serialized = serializeStyles(styles.concat(classInterpolations), cache.registered, mergedProps);
3687
- insertStyles(cache, serialized, typeof finalTag === 'string');
3688
3820
  className += cache.key + "-" + serialized.name;
3689
3821
 
3690
3822
  if (targetClassName !== undefined) {
3691
3823
  className += " " + targetClassName;
3692
3824
  }
3693
3825
 
3694
- var finalShouldForwardProp = shouldUseAs && shouldForwardProp === undefined ? getDefaultShouldForwardProp(finalTag) : defaultShouldForwardProp;
3826
+ var finalShouldForwardProp = shouldUseAs && shouldForwardProp === undefined ? getDefaultShouldForwardProp(FinalTag) : defaultShouldForwardProp;
3695
3827
  var newProps = {};
3696
3828
 
3697
3829
  for (var _key in props) {
@@ -3705,8 +3837,11 @@ var createStyled = function createStyled(tag, options) {
3705
3837
 
3706
3838
  newProps.className = className;
3707
3839
  newProps.ref = ref;
3708
- var ele = /*#__PURE__*/createElement(finalTag, newProps);
3709
- return ele;
3840
+ return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(Insertion, {
3841
+ cache: cache,
3842
+ serialized: serialized,
3843
+ isStringTag: typeof FinalTag === 'string'
3844
+ }), /*#__PURE__*/createElement(FinalTag, newProps));
3710
3845
  });
3711
3846
  Styled.displayName = identifierName !== undefined ? identifierName : "Styled(" + (typeof baseTag === 'string' ? baseTag : baseTag.displayName || baseTag.name || 'Component') + ")";
3712
3847
  Styled.defaultProps = tag.defaultProps;
@@ -3783,12 +3918,12 @@ var StyledSpinner = newStyled.div(_templateObject2$1 || (_templateObject2$1 = _t
3783
3918
  var Spinner = function Spinner(_ref12) {
3784
3919
  var _ref12$size = _ref12.size,
3785
3920
  size = _ref12$size === void 0 ? 100 : _ref12$size;
3786
- return /*#__PURE__*/React.createElement(StyledSpinner, {
3921
+ return /*#__PURE__*/React__default.createElement(StyledSpinner, {
3787
3922
  size: size
3788
3923
  });
3789
3924
  };
3790
3925
 
3791
- var Context = /*#__PURE__*/React.createContext();
3926
+ var Context = /*#__PURE__*/React__default.createContext();
3792
3927
  var WireProvider = function WireProvider(_ref) {
3793
3928
  var socket = _ref.socket,
3794
3929
  room = _ref.room,
@@ -3796,31 +3931,31 @@ var WireProvider = function WireProvider(_ref) {
3796
3931
  channel = _ref$channel === void 0 ? "default" : _ref$channel,
3797
3932
  children = _ref.children;
3798
3933
 
3799
- var _React$useState = React.useState(false),
3934
+ var _React$useState = React__default.useState(false),
3800
3935
  _React$useState2 = _slicedToArray(_React$useState, 2),
3801
3936
  joined = _React$useState2[0],
3802
3937
  setJoined = _React$useState2[1];
3803
3938
 
3804
- var _React$useState3 = React.useState(false),
3939
+ var _React$useState3 = React__default.useState(false),
3805
3940
  _React$useState4 = _slicedToArray(_React$useState3, 2),
3806
3941
  isMaster = _React$useState4[0],
3807
3942
  setIsMaster = _React$useState4[1];
3808
3943
 
3809
- var _React$useState5 = React.useState(null),
3944
+ var _React$useState5 = React__default.useState(null),
3810
3945
  _React$useState6 = _slicedToArray(_React$useState5, 2),
3811
3946
  wire = _React$useState6[0],
3812
3947
  setWire = _React$useState6[1];
3813
3948
 
3814
- var roomRef = React.useRef(null);
3815
- var mountedRef = React.useRef(false);
3949
+ var roomRef = React__default.useRef(null);
3950
+ var mountedRef = React__default.useRef(false);
3816
3951
  var existingC2C = useContext(Context);
3817
- React.useEffect(function () {
3952
+ React__default.useEffect(function () {
3818
3953
  mountedRef.current = true;
3819
3954
  return function () {
3820
3955
  mountedRef.current = false;
3821
3956
  };
3822
3957
  }, []);
3823
- React.useEffect(function () {
3958
+ React__default.useEffect(function () {
3824
3959
  if (!socket) {
3825
3960
  return null;
3826
3961
  }
@@ -3837,7 +3972,7 @@ var WireProvider = function WireProvider(_ref) {
3837
3972
  socket.off("disconnect", disconnect);
3838
3973
  };
3839
3974
  }, [channel, socket]);
3840
- React.useEffect(function () {
3975
+ React__default.useEffect(function () {
3841
3976
  // Connect
3842
3977
  if (!socket) {
3843
3978
  return null;
@@ -3872,7 +4007,7 @@ var WireProvider = function WireProvider(_ref) {
3872
4007
  }, [channel, room, socket]);
3873
4008
 
3874
4009
  if (!joined || !wire) {
3875
- return /*#__PURE__*/React.createElement("div", {
4010
+ return /*#__PURE__*/React__default.createElement("div", {
3876
4011
  style: {
3877
4012
  position: "absolute",
3878
4013
  top: "0",
@@ -3882,10 +4017,10 @@ var WireProvider = function WireProvider(_ref) {
3882
4017
  justifyContent: "center",
3883
4018
  alignItems: "center"
3884
4019
  }
3885
- }, /*#__PURE__*/React.createElement(Spinner, null));
4020
+ }, /*#__PURE__*/React__default.createElement(Spinner, null));
3886
4021
  }
3887
4022
 
3888
- return /*#__PURE__*/React.createElement(Context.Provider, {
4023
+ return /*#__PURE__*/React__default.createElement(Context.Provider, {
3889
4024
  value: _objectSpread2(_objectSpread2({}, existingC2C), {}, _defineProperty({}, channel, {
3890
4025
  wire: wire,
3891
4026
  joined: joined,
@@ -3975,10 +4110,6 @@ var useItemList = function useItemList() {
3975
4110
  return items;
3976
4111
  };
3977
4112
 
3978
- var useSelectedItems = function useSelectedItems() {
3979
- return useRecoilValue(SelectedItemsAtom);
3980
- };
3981
-
3982
4113
  /**
3983
4114
  * Run effect only when component is unmounted.
3984
4115
  *
@@ -4166,6 +4297,28 @@ function useThrottledCallback(callback, deps, delay, noTrailing) {
4166
4297
  }, __spreadArray([delay, noTrailing], deps, true));
4167
4298
  }
4168
4299
 
4300
+ /* eslint-disable @typescript-eslint/no-explicit-any */
4301
+ /**
4302
+ * Like `useEffect`, but passed function is debounced.
4303
+ *
4304
+ * @param callback Callback like for `useEffect`, but without ability to return
4305
+ * a cleanup function.
4306
+ * @param deps Dependencies list that will be passed to underlying `useEffect`
4307
+ * and `useDebouncedCallback`.
4308
+ * @param delay Debounce delay.
4309
+ * @param maxWait Maximum amount of milliseconds that function can be delayed
4310
+ * before it's force execution. 0 means no max wait.
4311
+ */
4312
+
4313
+ function useDebouncedEffect(callback, deps, delay, maxWait) {
4314
+ if (maxWait === void 0) {
4315
+ maxWait = 0;
4316
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
4317
+
4318
+
4319
+ useEffect(useDebouncedCallback(callback, deps, delay, maxWait), deps);
4320
+ }
4321
+
4169
4322
  /* eslint-disable @typescript-eslint/no-explicit-any */
4170
4323
  /**
4171
4324
  * Like `useEffect`, but passed function is throttled.
@@ -4310,6 +4463,45 @@ function useResizeObserver(target, callback, enabled) {
4310
4463
  }, [target, ro]);
4311
4464
  }
4312
4465
 
4466
+ var useDebouncedItems = function useDebouncedItems() {
4467
+ var items = useRecoilValue(AllItemsSelector);
4468
+
4469
+ var _React$useState = React__default.useState(items),
4470
+ _React$useState2 = _slicedToArray(_React$useState, 2),
4471
+ debouncedItems = _React$useState2[0],
4472
+ setDebouncedItems = _React$useState2[1];
4473
+
4474
+ var updateDebouncedItems = useRecoilCallback(function (_ref) {
4475
+ var snapshot = _ref.snapshot;
4476
+ return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
4477
+ var currentItemMap;
4478
+ return regeneratorRuntime.wrap(function _callee$(_context) {
4479
+ while (1) {
4480
+ switch (_context.prev = _context.next) {
4481
+ case 0:
4482
+ _context.next = 2;
4483
+ return snapshot.getPromise(AllItemsSelector);
4484
+
4485
+ case 2:
4486
+ currentItemMap = _context.sent;
4487
+ setDebouncedItems(currentItemMap);
4488
+
4489
+ case 4:
4490
+ case "end":
4491
+ return _context.stop();
4492
+ }
4493
+ }
4494
+ }, _callee);
4495
+ }));
4496
+ }, []);
4497
+ useDebouncedEffect(updateDebouncedItems, [items], 300);
4498
+ return debouncedItems;
4499
+ };
4500
+
4501
+ var useSelectedItems = function useSelectedItems() {
4502
+ return useRecoilValue(SelectedItemsAtom);
4503
+ };
4504
+
4313
4505
  var isMacOS = function isMacOS() {
4314
4506
  var userAgent = navigator.userAgent.toLowerCase();
4315
4507
  return /mac os ?x 10/.test(userAgent);
@@ -4405,15 +4597,15 @@ var Gesture = function Gesture(_ref6) {
4405
4597
  _ref6$onDoubleTap = _ref6.onDoubleTap,
4406
4598
  onDoubleTap = _ref6$onDoubleTap === void 0 ? empty : _ref6$onDoubleTap,
4407
4599
  onZoom = _ref6.onZoom;
4408
- var wrapperRef = React.useRef(null);
4409
- var stateRef = React.useRef({
4600
+ var wrapperRef = React__default.useRef(null);
4601
+ var stateRef = React__default.useRef({
4410
4602
  moving: false,
4411
4603
  pointers: {},
4412
4604
  mainPointer: undefined
4413
4605
  });
4414
- var queueRef = React.useRef([]); // Queue event to avoid async mess
4606
+ var queueRef = React__default.useRef([]); // Queue event to avoid async mess
4415
4607
 
4416
- var queue = React.useCallback(function (callback, args) {
4608
+ var queue = React__default.useCallback(function (callback, args) {
4417
4609
  queueRef.current.push( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
4418
4610
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
4419
4611
  while (1) {
@@ -4445,7 +4637,7 @@ var Gesture = function Gesture(_ref6) {
4445
4637
  protect(queueRef.current[0])();
4446
4638
  }
4447
4639
  }, []);
4448
- var onWheel = React.useCallback(function (e) {
4640
+ var onWheel = React__default.useCallback(function (e) {
4449
4641
  var deltaX = e.deltaX,
4450
4642
  deltaY = e.deltaY,
4451
4643
  clientX = e.clientX,
@@ -4504,7 +4696,7 @@ var Gesture = function Gesture(_ref6) {
4504
4696
  });
4505
4697
  }
4506
4698
  }, [onPan, onZoom, queue]);
4507
- var onPointerDown = React.useCallback(function (_ref8) {
4699
+ var onPointerDown = React__default.useCallback(function (_ref8) {
4508
4700
  var target = _ref8.target,
4509
4701
  button = _ref8.button,
4510
4702
  clientX = _ref8.clientX,
@@ -4604,7 +4796,7 @@ var Gesture = function Gesture(_ref6) {
4604
4796
  console.log("Fail to capture pointer", e);
4605
4797
  }
4606
4798
  }, [onLongTap, queue]);
4607
- var onPointerMove = React.useCallback(function (e) {
4799
+ var onPointerMove = React__default.useCallback(function (e) {
4608
4800
  if (stateRef.current.pressed) {
4609
4801
  var pointerId = e.pointerId,
4610
4802
  eventClientX = e.clientX,
@@ -4745,7 +4937,7 @@ var Gesture = function Gesture(_ref6) {
4745
4937
  stateRef.current.prevY = clientY;
4746
4938
  }
4747
4939
  }, [onDrag, onDragStart, onPan, onZoom, queue]);
4748
- var onPointerUp = React.useCallback(function (e) {
4940
+ var onPointerUp = React__default.useCallback(function (e) {
4749
4941
  var clientX = e.clientX,
4750
4942
  clientY = e.clientY,
4751
4943
  altKey = e.altKey,
@@ -4814,21 +5006,21 @@ var Gesture = function Gesture(_ref6) {
4814
5006
  stateRef.current.noTap = false;
4815
5007
  } // Send tap event only if time less than 300ms
4816
5008
  else if (stateRef.current.timeStart - now < 300) {
4817
- queue(onTap, {
4818
- clientX: clientX,
4819
- clientY: clientY,
4820
- altKey: altKey,
4821
- ctrlKey: ctrlKey,
4822
- metaKey: metaKey,
4823
- target: target
4824
- });
4825
- }
5009
+ queue(onTap, {
5010
+ clientX: clientX,
5011
+ clientY: clientY,
5012
+ altKey: altKey,
5013
+ ctrlKey: ctrlKey,
5014
+ metaKey: metaKey,
5015
+ target: target
5016
+ });
5017
+ }
4826
5018
  }
4827
5019
  }, [onDragEnd, onTap, queue]);
4828
- var onDoubleTapHandler = React.useCallback(function (event) {
5020
+ var onDoubleTapHandler = React__default.useCallback(function (event) {
4829
5021
  queue(onDoubleTap, event);
4830
5022
  }, [onDoubleTap, queue]);
4831
- return /*#__PURE__*/React.createElement("div", {
5023
+ return /*#__PURE__*/React__default.createElement("div", {
4832
5024
  onWheel: onWheel,
4833
5025
  onPointerDown: onPointerDown,
4834
5026
  onPointerMove: onPointerMove,
@@ -4886,9 +5078,9 @@ var ResizeHandler = function ResizeHandler(_ref) {
4886
5078
  };
4887
5079
  }();
4888
5080
  }, [onResize]);
4889
- return /*#__PURE__*/React.createElement(Gesture, {
5081
+ return /*#__PURE__*/React__default.createElement(Gesture, {
4890
5082
  onDrag: onDrag
4891
- }, /*#__PURE__*/React.createElement("div", rest));
5083
+ }, /*#__PURE__*/React__default.createElement("div", rest));
4892
5084
  };
4893
5085
 
4894
5086
  var img = "data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8' standalone='no'%3f%3e%3csvg xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:cc='http://creativecommons.org/ns%23' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns%23' xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd' xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape' version='1.1' x='0px' y='0px' viewBox='0 0 75.601318 94.9' xml:space='preserve' id='svg26' sodipodi:docname='lock.svg' width='75.601318' height='94.900002' inkscape:version='0.92.5 (2060ec1f9f%2c 2020-04-08)'%3e%3cmetadata id='metadata32'%3e%3crdf:RDF%3e%3ccc:Work rdf:about=''%3e%3cdc:format%3eimage/svg%2bxml%3c/dc:format%3e%3cdc:type rdf:resource='http://purl.org/dc/dcmitype/StillImage' /%3e%3cdc:title%3e%3c/dc:title%3e%3c/cc:Work%3e%3c/rdf:RDF%3e%3c/metadata%3e%3cdefs id='defs30' /%3e%3csodipodi:namedview pagecolor='black' bordercolor='%23666666' borderopacity='1' objecttolerance='10' gridtolerance='10' guidetolerance='10' inkscape:pageopacity='0' inkscape:pageshadow='2' inkscape:window-width='1848' inkscape:window-height='1016' id='namedview28' showgrid='false' fit-margin-top='0' fit-margin-left='0' fit-margin-right='0' fit-margin-bottom='0' inkscape:zoom='5.3400704' inkscape:cx='3.2640013' inkscape:cy='45.072152' inkscape:window-x='1512' inkscape:window-y='27' inkscape:window-maximized='1' inkscape:current-layer='g16' /%3e%3cg id='g16' transform='translate(-12.2%2c-2.5)'%3e%3cpath d='M 75.4%2c36.8 H 34.1 V 24.6 c 0%2c-8.8 7.1%2c-15.9 15.9%2c-15.9 8.8%2c0 15.9%2c7.1 15.9%2c15.9 0%2c1.7 1.4%2c3.1 3.1%2c3.1 1.7%2c0 3.1%2c-1.4 3.1%2c-3.1 C 72.1%2c12.4 62.2%2c2.5 50%2c2.5 37.8%2c2.5 27.9%2c12.4 27.9%2c24.6 v 12.2 h -3.3 c -6.9%2c0 -12.4%2c5.6 -12.4%2c12.4 V 85 c 0%2c6.9 5.6%2c12.4 12.4%2c12.4 h 50.8 c 6.9%2c0 12.4%2c-5.6 12.4%2c-12.4 V 49.2 C 87.9%2c42.3 82.3%2c36.8 75.4%2c36.8 Z m 6.2%2c48.3 c 0%2c3.4 -2.8%2c6.2 -6.2%2c6.2 H 24.6 c -3.4%2c0 -6.2%2c-2.8 -6.2%2c-6.2 V 49.2 c 0%2c-3.4 2.8%2c-6.2 6.2%2c-6.2 h 50.8 c 3.4%2c0 6.2%2c2.8 6.2%2c6.2 z' id='path12' inkscape:connector-curvature='0' style='fill:white%3bfill-opacity:1' /%3e%3cpath d='m 59.8%2c57.6 -12.5%2c12.5 -7%2c-7 c -1.2%2c-1.2 -3.2%2c-1.2 -4.4%2c0 -1.2%2c1.2 -1.2%2c3.2 0%2c4.4 l 9.2%2c9.2 c 0.6%2c0.6 1.4%2c0.9 2.2%2c0.9 0.8%2c0 1.6%2c-0.3 2.2%2c-0.9 L 64.2%2c62 c 1.2%2c-1.2 1.2%2c-3.2 0%2c-4.4 -1.2%2c-1.2 -3.2%2c-1.2 -4.4%2c0 z' id='path14' inkscape:connector-curvature='0' style='fill:white%3bfill-opacity:1' /%3e%3c/g%3e%3c/svg%3e";
@@ -4898,7 +5090,7 @@ var _excluded$2 = ["type", "rotation", "id", "locked", "layer"],
4898
5090
  _excluded3 = ["x", "y", "layer", "moving"];
4899
5091
 
4900
5092
  var _templateObject$2;
4901
- 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) {
5093
+ 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) {
4902
5094
  var rotation = _ref.rotation;
4903
5095
  return rotation;
4904
5096
  }, img);
@@ -4909,7 +5101,7 @@ var identity = function identity(x) {
4909
5101
 
4910
5102
  var DefaultErrorComponent = function DefaultErrorComponent(_ref2) {
4911
5103
  var onReload = _ref2.onReload;
4912
- return /*#__PURE__*/React.createElement("div", {
5104
+ return /*#__PURE__*/React__default.createElement("div", {
4913
5105
  style: {
4914
5106
  width: "100px",
4915
5107
  display: "flex",
@@ -4919,7 +5111,7 @@ var DefaultErrorComponent = function DefaultErrorComponent(_ref2) {
4919
5111
  color: "red"
4920
5112
  },
4921
5113
  className: "syncboard-error-item"
4922
- }, "Sorry, this item seems broken.", /*#__PURE__*/React.createElement("button", {
5114
+ }, "Sorry, this item seems broken.", /*#__PURE__*/React__default.createElement("button", {
4923
5115
  onClick: onReload
4924
5116
  }, "Reload it"));
4925
5117
  };
@@ -4964,7 +5156,7 @@ var ItemErrorBoundary = /*#__PURE__*/function (_React$Component) {
4964
5156
  var ErrorComponent = this.props.ErrorComponent;
4965
5157
 
4966
5158
  if (this.state.hasError) {
4967
- return /*#__PURE__*/React.createElement(ErrorComponent, {
5159
+ return /*#__PURE__*/React__default.createElement(ErrorComponent, {
4968
5160
  onReload: this.onReload
4969
5161
  });
4970
5162
  }
@@ -4981,7 +5173,7 @@ var ItemErrorBoundary = /*#__PURE__*/function (_React$Component) {
4981
5173
  }]);
4982
5174
 
4983
5175
  return ItemErrorBoundary;
4984
- }(React.Component);
5176
+ }(React__default.Component);
4985
5177
 
4986
5178
  var removeClass = function removeClass(e) {
4987
5179
  e.target.className = "";
@@ -5050,7 +5242,7 @@ var Item = function Item(_ref5) {
5050
5242
  _ref5$showResizeHandl = _ref5.showResizeHandle,
5051
5243
  showResizeHandle = _ref5$showResizeHandl === void 0 ? false : _ref5$showResizeHandl;
5052
5244
 
5053
- var itemWrapperRef = React.useRef(null);
5245
+ var itemWrapperRef = React__default.useRef(null);
5054
5246
  var _itemMap$type = itemMap[type],
5055
5247
  _itemMap$type$compone = _itemMap$type.component,
5056
5248
  Component = _itemMap$type$compone === void 0 ? function () {
@@ -5060,11 +5252,11 @@ var Item = function Item(_ref5) {
5060
5252
  resizeDirections = _itemMap$type$resizeD === void 0 ? defaultResizeDirection : _itemMap$type$resizeD,
5061
5253
  _itemMap$type$resize = _itemMap$type.resize,
5062
5254
  resize = _itemMap$type$resize === void 0 ? defaultResize : _itemMap$type$resize;
5063
- var updateState = React.useCallback(function (callbackOrItem) {
5255
+ var updateState = React__default.useCallback(function (callbackOrItem) {
5064
5256
  var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
5065
5257
  return setState(id, callbackOrItem, sync);
5066
5258
  }, [setState, id]);
5067
- React.useEffect(function () {
5259
+ React__default.useEffect(function () {
5068
5260
  itemWrapperRef.current.className = animate;
5069
5261
  }, [animate]);
5070
5262
  var className = "item ".concat(id);
@@ -5077,7 +5269,7 @@ var Item = function Item(_ref5) {
5077
5269
  className += " selected";
5078
5270
  }
5079
5271
 
5080
- var onResize = React.useCallback(function (_ref6) {
5272
+ var onResize = React__default.useCallback(function (_ref6) {
5081
5273
  var _ref6$width = _ref6.width,
5082
5274
  width = _ref6$width === void 0 ? 0 : _ref6$width,
5083
5275
  _ref6$height = _ref6.height,
@@ -5097,19 +5289,19 @@ var Item = function Item(_ref5) {
5097
5289
  });
5098
5290
  });
5099
5291
  }, [resize, updateState]);
5100
- var onResizeWidth = React.useCallback(function (_ref7) {
5292
+ var onResizeWidth = React__default.useCallback(function (_ref7) {
5101
5293
  var width = _ref7.width;
5102
5294
  onResize({
5103
5295
  width: width
5104
5296
  });
5105
5297
  }, [onResize]);
5106
- var onResizeHeight = React.useCallback(function (_ref8) {
5298
+ var onResizeHeight = React__default.useCallback(function (_ref8) {
5107
5299
  var height = _ref8.height;
5108
5300
  onResize({
5109
5301
  height: height
5110
5302
  });
5111
5303
  }, [onResize]);
5112
- var onResizeRatio = React.useCallback(function (_ref9) {
5304
+ var onResizeRatio = React__default.useCallback(function (_ref9) {
5113
5305
  var width = _ref9.width;
5114
5306
  onResize({
5115
5307
  height: width,
@@ -5117,14 +5309,14 @@ var Item = function Item(_ref5) {
5117
5309
  keepRatio: true
5118
5310
  });
5119
5311
  }, [onResize]);
5120
- return /*#__PURE__*/React.createElement(ItemWrapper, {
5312
+ return /*#__PURE__*/React__default.createElement(ItemWrapper, {
5121
5313
  rotation: rotation,
5122
5314
  locked: locked,
5123
5315
  selected: isSelected,
5124
5316
  layer: layer,
5125
5317
  "data-id": id,
5126
5318
  className: className
5127
- }, /*#__PURE__*/React.createElement("div", {
5319
+ }, /*#__PURE__*/React__default.createElement("div", {
5128
5320
  style: {
5129
5321
  display: "flex"
5130
5322
  },
@@ -5136,29 +5328,31 @@ var Item = function Item(_ref5) {
5136
5328
  onKeyUp: function onKeyUp(e) {
5137
5329
  return e.stopPropagation();
5138
5330
  }
5139
- }, /*#__PURE__*/React.createElement(ItemErrorBoundary, {
5331
+ }, /*#__PURE__*/React__default.createElement(ItemErrorBoundary, {
5140
5332
  itemId: id,
5141
5333
  state: rest,
5142
5334
  setState: updateState,
5143
5335
  ErrorComponent: (itemMap === null || itemMap === void 0 ? void 0 : (_itemMap$error = itemMap.error) === null || _itemMap$error === void 0 ? void 0 : _itemMap$error.component) || DefaultErrorComponent
5144
- }, /*#__PURE__*/React.createElement(Component, _extends$1({}, rest, {
5336
+ }, /*#__PURE__*/React__default.createElement(Component, _extends$1({}, rest, {
5145
5337
  id: id,
5146
5338
  setState: updateState
5147
- }))), /*#__PURE__*/React.createElement("div", {
5339
+ }))), /*#__PURE__*/React__default.createElement("div", {
5148
5340
  className: "corner top-left"
5149
- }), /*#__PURE__*/React.createElement("div", {
5341
+ }), /*#__PURE__*/React__default.createElement("div", {
5150
5342
  className: "corner top-right"
5151
- }), /*#__PURE__*/React.createElement("div", {
5152
- className: "corner bottom-left"
5153
- }), /*#__PURE__*/React.createElement("div", {
5343
+ }), /*#__PURE__*/React__default.createElement("div", {
5154
5344
  className: "corner bottom-right"
5155
- }), isSelected && showResizeHandle && /*#__PURE__*/React.createElement(React.Fragment, null, resizeDirections.b && /*#__PURE__*/React.createElement(ResizeHandler, {
5345
+ }), /*#__PURE__*/React__default.createElement("div", {
5346
+ className: "corner bottom-left"
5347
+ }), /*#__PURE__*/React__default.createElement("div", {
5348
+ className: "center"
5349
+ }), isSelected && showResizeHandle && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, resizeDirections.b && /*#__PURE__*/React__default.createElement(ResizeHandler, {
5156
5350
  className: "resize resize-ratio",
5157
5351
  onResize: onResizeRatio
5158
- }), resizeDirections.h && /*#__PURE__*/React.createElement(ResizeHandler, {
5352
+ }), resizeDirections.h && /*#__PURE__*/React__default.createElement(ResizeHandler, {
5159
5353
  className: "resize resize-height",
5160
5354
  onResize: onResizeHeight
5161
- }), resizeDirections.w && /*#__PURE__*/React.createElement(ResizeHandler, {
5355
+ }), resizeDirections.w && /*#__PURE__*/React__default.createElement(ResizeHandler, {
5162
5356
  className: "resize resize-width",
5163
5357
  onResize: onResizeWidth
5164
5358
  }))));
@@ -5184,8 +5378,6 @@ var PositionedItem = function PositionedItem(_ref12) {
5184
5378
  rest = _objectWithoutProperties(_ref12, _excluded2);
5185
5379
 
5186
5380
  if (!rest.itemMap[state.type]) {
5187
- // eslint-disable-next-line no-console
5188
- console.warn("Item type ".concat(state.type, " not recognized!"));
5189
5381
  return null;
5190
5382
  }
5191
5383
 
@@ -5204,7 +5396,7 @@ var PositionedItem = function PositionedItem(_ref12) {
5204
5396
  moving = _stateHook.moving,
5205
5397
  stateRest = _objectWithoutProperties(_stateHook, _excluded3);
5206
5398
 
5207
- return /*#__PURE__*/React.createElement("div", {
5399
+ return /*#__PURE__*/React__default.createElement("div", {
5208
5400
  style: {
5209
5401
  position: "absolute",
5210
5402
  top: "".concat(boardSize / 2, "px"),
@@ -5214,7 +5406,7 @@ var PositionedItem = function PositionedItem(_ref12) {
5214
5406
  zIndex: (layer + 4) * 10 + 100 + (moving ? 5 : 0) // Items z-index between 100 and 200
5215
5407
 
5216
5408
  }
5217
- }, /*#__PURE__*/React.createElement(MemoizedItem, _extends$1({}, rest, {
5409
+ }, /*#__PURE__*/React__default.createElement(MemoizedItem, _extends$1({}, rest, {
5218
5410
  // Helps to prevent render
5219
5411
  showResizeHandle: rest.isSelected && rest.showResizeHandle,
5220
5412
  state: stateRest
@@ -5288,7 +5480,7 @@ var useUsers = function useUsers() {
5288
5480
 
5289
5481
  var users = useRecoilValue(usersAtom);
5290
5482
  var localUsers = useRecoilValue(localUsersAtom);
5291
- var setCurrentUser = React.useCallback(function (callbackOrUser) {
5483
+ var setCurrentUser = React__default.useCallback(function (callbackOrUser) {
5292
5484
  var callback = callbackOrUser;
5293
5485
 
5294
5486
  if (_typeof(callbackOrUser) === "object") {
@@ -5316,7 +5508,7 @@ var useUsers = function useUsers() {
5316
5508
  };
5317
5509
 
5318
5510
  var SubscribeUserEvents = function SubscribeUserEvents() {
5319
- var usersRef = React.useRef([]);
5511
+ var usersRef = React__default.useRef([]);
5320
5512
  var setUsers = useSetRecoilState(usersAtom);
5321
5513
 
5322
5514
  var _useRecoilState = useRecoilState(userAtom),
@@ -5329,7 +5521,7 @@ var SubscribeUserEvents = function SubscribeUserEvents() {
5329
5521
  isMaster = _useWire.isMaster,
5330
5522
  roomSpace = _useWire.room;
5331
5523
 
5332
- React.useEffect(function () {
5524
+ React__default.useEffect(function () {
5333
5525
  setCurrentUserState(function (prevUser) {
5334
5526
  return _objectSpread2(_objectSpread2({}, prevUser), {}, {
5335
5527
  id: wire.userId,
@@ -5345,7 +5537,7 @@ var SubscribeUserEvents = function SubscribeUserEvents() {
5345
5537
  });
5346
5538
  };
5347
5539
  }, [wire.userId, roomSpace, setCurrentUserState]);
5348
- React.useEffect(function () {
5540
+ React__default.useEffect(function () {
5349
5541
  if (!isMaster) {
5350
5542
  var onGetUserList = function onGetUserList(userList) {
5351
5543
  usersRef.current = userList;
@@ -5367,12 +5559,12 @@ var SubscribeUserEvents = function SubscribeUserEvents() {
5367
5559
  var debouncedEmitUpdateUser = useDebouncedCallback(function (newUser) {
5368
5560
  wire.publish("userUpdate", newUser, true);
5369
5561
  }, [wire], 500);
5370
- React.useEffect(function () {
5562
+ React__default.useEffect(function () {
5371
5563
  if (currentUser && currentUser.id) {
5372
5564
  debouncedEmitUpdateUser(currentUser);
5373
5565
  }
5374
5566
  }, [currentUser, debouncedEmitUpdateUser]);
5375
- React.useEffect(function () {
5567
+ React__default.useEffect(function () {
5376
5568
  var unsub = [];
5377
5569
 
5378
5570
  if (isMaster) {
@@ -5441,7 +5633,7 @@ var ItemList = function ItemList() {
5441
5633
  currentUser = _useUsers.currentUser;
5442
5634
 
5443
5635
  return itemList.map(function (itemId) {
5444
- return /*#__PURE__*/React.createElement(MemoizedPositionedItem, {
5636
+ return /*#__PURE__*/React__default.createElement(MemoizedPositionedItem, {
5445
5637
  key: itemId,
5446
5638
  state: itemMap[itemId],
5447
5639
  setState: updateItem,
@@ -5466,18 +5658,18 @@ var SubcribeItemEvents = function SubcribeItemEvents() {
5466
5658
  removeItems = _useItemActions.removeItems,
5467
5659
  pushItem = _useItemActions.pushItem;
5468
5660
 
5469
- var batchUpdate = React.useCallback(function (updatedItems) {
5661
+ var batchUpdate = React__default.useCallback(function (updatedItems) {
5470
5662
  setItemMap(function (prevItemMap) {
5471
5663
  return _objectSpread2(_objectSpread2({}, prevItemMap), updatedItems);
5472
5664
  });
5473
5665
  }, [setItemMap]);
5474
- React.useEffect(function () {
5666
+ React__default.useEffect(function () {
5475
5667
  var unsub = wire.subscribe("batchItemsUpdate", function (updatedItems) {
5476
5668
  batchUpdate(updatedItems);
5477
5669
  });
5478
5670
  return unsub;
5479
5671
  }, [wire, batchUpdate]);
5480
- React.useEffect(function () {
5672
+ React__default.useEffect(function () {
5481
5673
  var unsub = wire.subscribe("selectedItemsMove", function (_ref) {
5482
5674
  var itemIds = _ref.itemIds,
5483
5675
  posDelta = _ref.posDelta;
@@ -5485,19 +5677,19 @@ var SubcribeItemEvents = function SubcribeItemEvents() {
5485
5677
  });
5486
5678
  return unsub;
5487
5679
  }, [wire, moveItems]);
5488
- React.useEffect(function () {
5680
+ React__default.useEffect(function () {
5489
5681
  var unsub = wire.subscribe("updateItemListOrder", function (itemIds) {
5490
5682
  updateItemOrder(itemIds, false);
5491
5683
  });
5492
5684
  return unsub;
5493
5685
  }, [wire, updateItemOrder]);
5494
- React.useEffect(function () {
5686
+ React__default.useEffect(function () {
5495
5687
  var unsub = wire.subscribe("pushItem", function (newItem) {
5496
5688
  pushItem(newItem, null, false);
5497
5689
  });
5498
5690
  return unsub;
5499
5691
  }, [wire, pushItem]);
5500
- React.useEffect(function () {
5692
+ React__default.useEffect(function () {
5501
5693
  var unsub = wire.subscribe("insertItemBefore", function (_ref2) {
5502
5694
  var _ref3 = _slicedToArray(_ref2, 2),
5503
5695
  newItem = _ref3[0],
@@ -5507,7 +5699,7 @@ var SubcribeItemEvents = function SubcribeItemEvents() {
5507
5699
  });
5508
5700
  return unsub;
5509
5701
  }, [wire, pushItem]);
5510
- React.useEffect(function () {
5702
+ React__default.useEffect(function () {
5511
5703
  var unsub = wire.subscribe("removeItems", function (itemIds) {
5512
5704
  removeItems(itemIds, false);
5513
5705
  });
@@ -5656,17 +5848,17 @@ var Selector = function Selector(_ref) {
5656
5848
  var _useItemActions = useItemActions(),
5657
5849
  findElementUnderPointer = _useItemActions.findElementUnderPointer;
5658
5850
 
5659
- var _React$useState = React.useState({}),
5851
+ var _React$useState = React__default.useState({}),
5660
5852
  _React$useState2 = _slicedToArray(_React$useState, 2),
5661
5853
  selector = _React$useState2[0],
5662
5854
  setSelector = _React$useState2[1];
5663
5855
 
5664
- var wrapperRef = React.useRef(null);
5665
- var stateRef = React.useRef({
5856
+ var wrapperRef = React__default.useRef(null);
5857
+ var stateRef = React__default.useRef({
5666
5858
  moving: false
5667
5859
  }); // Reset selection on board loading
5668
5860
 
5669
- React.useEffect(function () {
5861
+ React__default.useEffect(function () {
5670
5862
  setSelected(function (prev) {
5671
5863
  return prev.length === 0 ? prev : [];
5672
5864
  });
@@ -5837,7 +6029,7 @@ var Selector = function Selector(_ref) {
5837
6029
  }
5838
6030
  };
5839
6031
 
5840
- var onLongTap = React.useCallback(function (_ref8) {
6032
+ var onLongTap = React__default.useCallback(function (_ref8) {
5841
6033
  var target = _ref8.target;
5842
6034
  var foundElement = insideClass(target, "item");
5843
6035
 
@@ -5912,15 +6104,15 @@ var Selector = function Selector(_ref) {
5912
6104
  };
5913
6105
  }();
5914
6106
  }, [findElementUnderPointer, setSelected]);
5915
- return /*#__PURE__*/React.createElement(Gesture, {
6107
+ return /*#__PURE__*/React__default.createElement(Gesture, {
5916
6108
  onDragStart: onDragStart,
5917
6109
  onDrag: onDrag,
5918
6110
  onDragEnd: onDragEnd,
5919
6111
  onTap: onTap,
5920
6112
  onLongTap: onLongTap
5921
- }, /*#__PURE__*/React.createElement("div", {
6113
+ }, /*#__PURE__*/React__default.createElement("div", {
5922
6114
  ref: wrapperRef
5923
- }, selector.moving && /*#__PURE__*/React.createElement("div", {
6115
+ }, selector.moving && /*#__PURE__*/React__default.createElement("div", {
5924
6116
  style: _objectSpread2(_objectSpread2({}, defaultSelectorStyle), {}, {
5925
6117
  transform: "translate(".concat(selector.left, "px, ").concat(selector.top, "px)"),
5926
6118
  height: "".concat(selector.height, "px"),
@@ -5940,9 +6132,9 @@ var ActionPane = function ActionPane(_ref) {
5940
6132
 
5941
6133
  var setSelectedItems = useSetRecoilState(SelectedItemsAtom);
5942
6134
  var setBoardState = useSetRecoilState(BoardStateAtom);
5943
- var actionRef = React.useRef({}); // Use ref because pointer events are faster than react state management
6135
+ var actionRef = React__default.useRef({}); // Use ref because pointer events are faster than react state management
5944
6136
 
5945
- var selectedItemRef = React.useRef({
6137
+ var selectedItemRef = React__default.useRef({
5946
6138
  items: []
5947
6139
  });
5948
6140
  var onDragStart = useRecoilCallback(function (_ref2) {
@@ -6198,167 +6390,236 @@ var ActionPane = function ActionPane(_ref) {
6198
6390
  };
6199
6391
  }();
6200
6392
  }, [moveItems, placeItems]);
6201
- React.useEffect(function () {
6393
+ React__default.useEffect(function () {
6202
6394
  document.addEventListener("keydown", onKeyDown);
6203
6395
  return function () {
6204
6396
  document.removeEventListener("keydown", onKeyDown);
6205
6397
  };
6206
6398
  }, [onKeyDown]);
6207
- return /*#__PURE__*/React.createElement(Gesture, {
6399
+ return /*#__PURE__*/React__default.createElement(Gesture, {
6208
6400
  onDragStart: onDragStart,
6209
6401
  onDrag: onDrag,
6210
6402
  onDragEnd: onDragEnd
6211
6403
  }, children);
6212
6404
  };
6213
6405
 
6214
- function t(t, n, r) {
6215
- return Math.min(Math.max(t, r), n);
6406
+ /**
6407
+ * A simple guard function:
6408
+ *
6409
+ * ```js
6410
+ * Math.min(Math.max(low, value), high)
6411
+ * ```
6412
+ */
6413
+ function guard(low, high, value) {
6414
+ return Math.min(Math.max(low, value), high);
6216
6415
  }
6217
6416
 
6218
- var n = /*#__PURE__*/function (_Error) {
6219
- _inherits(n, _Error);
6417
+ var ColorError = /*#__PURE__*/function (_Error) {
6418
+ _inherits(ColorError, _Error);
6220
6419
 
6221
- var _super = _createSuper(n);
6420
+ var _super = _createSuper(ColorError);
6222
6421
 
6223
- function n(t) {
6224
- _classCallCheck(this, n);
6422
+ function ColorError(color) {
6423
+ _classCallCheck(this, ColorError);
6225
6424
 
6226
- return _super.call(this, "Failed to parse color: \"".concat(t, "\""));
6425
+ return _super.call(this, "Failed to parse color: \"".concat(color, "\""));
6227
6426
  }
6228
6427
 
6229
- return n;
6428
+ return ColorError;
6230
6429
  }( /*#__PURE__*/_wrapNativeSuper(Error));
6231
6430
 
6232
- function r(r) {
6233
- if ("string" != typeof r) throw new n(r);
6234
- if ("transparent" === r.trim().toLowerCase()) return [0, 0, 0, 0];
6235
- var e = r.trim();
6236
- e = u.test(r) ? function (t) {
6237
- var r = t.toLowerCase().trim(),
6238
- e = o[function (t) {
6239
- var n = 5381,
6240
- r = t.length;
6241
-
6242
- for (; r;) {
6243
- n = 33 * n ^ t.charCodeAt(--r);
6244
- }
6245
-
6246
- return (n >>> 0) % 2341;
6247
- }(r)];
6248
-
6249
- if (!e) throw new n(t);
6250
- return "#".concat(e);
6251
- }(r) : r;
6252
- var f = s.exec(e);
6253
-
6254
- if (f) {
6255
- var _t = Array.from(f).slice(1);
6431
+ var ColorError$1 = ColorError;
6432
+ /**
6433
+ * Parses a color into red, gree, blue, alpha parts
6434
+ *
6435
+ * @param color the input color. Can be a RGB, RBGA, HSL, HSLA, or named color
6436
+ */
6256
6437
 
6257
- return [].concat(_toConsumableArray(_t.slice(0, 3).map(function (t) {
6258
- return parseInt(_(t, 2), 16);
6259
- })), [parseInt(_(_t[3] || "f", 2), 16) / 255]);
6438
+ function parseToRgba(color) {
6439
+ if (typeof color !== 'string') throw new ColorError$1(color);
6440
+ if (color.trim().toLowerCase() === 'transparent') return [0, 0, 0, 0];
6441
+ var normalizedColor = color.trim();
6442
+ normalizedColor = namedColorRegex.test(color) ? nameToHex(color) : color;
6443
+ var reducedHexMatch = reducedHexRegex.exec(normalizedColor);
6444
+
6445
+ if (reducedHexMatch) {
6446
+ var arr = Array.from(reducedHexMatch).slice(1);
6447
+ return [].concat(_toConsumableArray(arr.slice(0, 3).map(function (x) {
6448
+ return parseInt(r(x, 2), 16);
6449
+ })), [parseInt(r(arr[3] || 'f', 2), 16) / 255]);
6260
6450
  }
6261
6451
 
6262
- var p = i.exec(e);
6452
+ var hexMatch = hexRegex.exec(normalizedColor);
6263
6453
 
6264
- if (p) {
6265
- var _t2 = Array.from(p).slice(1);
6454
+ if (hexMatch) {
6455
+ var _arr = Array.from(hexMatch).slice(1);
6266
6456
 
6267
- return [].concat(_toConsumableArray(_t2.slice(0, 3).map(function (t) {
6268
- return parseInt(t, 16);
6269
- })), [parseInt(_t2[3] || "ff", 16) / 255]);
6457
+ return [].concat(_toConsumableArray(_arr.slice(0, 3).map(function (x) {
6458
+ return parseInt(x, 16);
6459
+ })), [parseInt(_arr[3] || 'ff', 16) / 255]);
6270
6460
  }
6271
6461
 
6272
- var z = a.exec(e);
6462
+ var rgbaMatch = rgbaRegex.exec(normalizedColor);
6273
6463
 
6274
- if (z) {
6275
- var _t3 = Array.from(z).slice(1);
6464
+ if (rgbaMatch) {
6465
+ var _arr2 = Array.from(rgbaMatch).slice(1);
6276
6466
 
6277
- return [].concat(_toConsumableArray(_t3.slice(0, 3).map(function (t) {
6278
- return parseInt(t, 10);
6279
- })), [parseFloat(_t3[3] || "1")]);
6467
+ return [].concat(_toConsumableArray(_arr2.slice(0, 3).map(function (x) {
6468
+ return parseInt(x, 10);
6469
+ })), [parseFloat(_arr2[3] || '1')]);
6280
6470
  }
6281
6471
 
6282
- var h = c.exec(e);
6472
+ var hslaMatch = hslaRegex.exec(normalizedColor);
6283
6473
 
6284
- if (h) {
6285
- var _Array$from$slice$map = Array.from(h).slice(1).map(parseFloat),
6474
+ if (hslaMatch) {
6475
+ var _Array$from$slice$map = Array.from(hslaMatch).slice(1).map(parseFloat),
6286
6476
  _Array$from$slice$map2 = _slicedToArray(_Array$from$slice$map, 4),
6287
- _e = _Array$from$slice$map2[0],
6288
- _o = _Array$from$slice$map2[1],
6289
- _2 = _Array$from$slice$map2[2],
6290
- _s = _Array$from$slice$map2[3];
6291
-
6292
- if (t(0, 100, _o) !== _o) throw new n(r);
6293
- if (t(0, 100, _2) !== _2) throw new n(r);
6294
- return [].concat(_toConsumableArray(l(_e, _o, _2)), [_s || 1]);
6477
+ h = _Array$from$slice$map2[0],
6478
+ s = _Array$from$slice$map2[1],
6479
+ l = _Array$from$slice$map2[2],
6480
+ a = _Array$from$slice$map2[3];
6481
+
6482
+ if (guard(0, 100, s) !== s) throw new ColorError$1(color);
6483
+ if (guard(0, 100, l) !== l) throw new ColorError$1(color);
6484
+ return [].concat(_toConsumableArray(hslToRgb(h, s, l)), [a || 1]);
6295
6485
  }
6296
6486
 
6297
- throw new n(r);
6487
+ throw new ColorError$1(color);
6298
6488
  }
6299
6489
 
6300
- var e = function e(t) {
6301
- return parseInt(t.replace(/_/g, ""), 36);
6302
- },
6303
- 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) {
6304
- var r = e(n.substring(0, 3)),
6305
- o = e(n.substring(3)).toString(16);
6306
- var _ = "";
6490
+ function hash(str) {
6491
+ var hash = 5381;
6492
+ var i = str.length;
6307
6493
 
6308
- for (var _t4 = 0; _t4 < 6 - o.length; _t4++) {
6309
- _ += "0";
6494
+ while (i) {
6495
+ hash = hash * 33 ^ str.charCodeAt(--i);
6310
6496
  }
6497
+ /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
6498
+ * integers. Since we want the results to be always positive, convert the
6499
+ * signed int to an unsigned by doing an unsigned bitshift. */
6311
6500
 
6312
- return t[r] = "".concat(_).concat(o), t;
6313
- }, {}),
6314
- _ = function _(t, n) {
6315
- return Array.from(Array(n)).map(function () {
6316
- return t;
6317
- }).join("");
6318
- },
6319
- s = new RegExp("^#".concat(_("([a-f0-9])", 3), "([a-f0-9])?$"), "i"),
6320
- i = new RegExp("^#".concat(_("([a-f0-9]{2})", 3), "([a-f0-9]{2})?$"), "i"),
6321
- a = new RegExp("^rgba?\\(\\s*(\\d+)\\s*".concat(_(",\\s*(\\d+)\\s*", 2), "(?:,\\s*([\\d.]+))?\\s*\\)$"), "i"),
6322
- c = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i,
6323
- u = /^[a-z]+$/i,
6324
- f = function f(t) {
6325
- return Math.round(255 * t);
6326
- },
6327
- l = function l(t, n, r) {
6328
- var e = r / 100;
6329
- if (0 === n) return [e, e, e].map(f);
6330
-
6331
- var o = (t % 360 + 360) % 360 / 60,
6332
- _ = (1 - Math.abs(2 * e - 1)) * (n / 100),
6333
- s = _ * (1 - Math.abs(o % 2 - 1));
6334
-
6335
- var i = 0,
6336
- a = 0,
6337
- c = 0;
6338
- 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);
6339
- var u = e - _ / 2;
6340
- return [i + u, a + u, c + u].map(f);
6501
+
6502
+ return (hash >>> 0) % 2341;
6503
+ }
6504
+
6505
+ var colorToInt = function colorToInt(x) {
6506
+ return parseInt(x.replace(/_/g, ''), 36);
6341
6507
  };
6342
6508
 
6343
- function w(t) {
6344
- if ("transparent" === t) return 0;
6509
+ 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) {
6510
+ var key = colorToInt(next.substring(0, 3));
6511
+ var hex = colorToInt(next.substring(3)).toString(16); // NOTE: padStart could be used here but it breaks Node 6 compat
6512
+ // https://github.com/ricokahler/color2k/issues/351
6513
+
6514
+ var prefix = '';
6345
6515
 
6346
- function n(t) {
6347
- var n = t / 255;
6348
- return n <= .03928 ? n / 12.92 : Math.pow((n + .055) / 1.055, 2.4);
6516
+ for (var i = 0; i < 6 - hex.length; i++) {
6517
+ prefix += '0';
6349
6518
  }
6350
6519
 
6351
- var _r = r(t),
6352
- _r2 = _slicedToArray(_r, 3),
6353
- e = _r2[0],
6354
- o = _r2[1],
6355
- _ = _r2[2];
6520
+ acc[key] = "".concat(prefix).concat(hex);
6521
+ return acc;
6522
+ }, {});
6523
+ /**
6524
+ * Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
6525
+ */
6356
6526
 
6357
- return .2126 * n(e) + .7152 * n(o) + .0722 * n(_);
6527
+ function nameToHex(color) {
6528
+ var normalizedColorName = color.toLowerCase().trim();
6529
+ var result = compressedColorMap[hash(normalizedColorName)];
6530
+ if (!result) throw new ColorError$1(color);
6531
+ return "#".concat(result);
6358
6532
  }
6359
6533
 
6360
- function F(t) {
6361
- return w(t) > .179;
6534
+ var r = function r(str, amount) {
6535
+ return Array.from(Array(amount)).map(function () {
6536
+ return str;
6537
+ }).join('');
6538
+ };
6539
+
6540
+ var reducedHexRegex = new RegExp("^#".concat(r('([a-f0-9])', 3), "([a-f0-9])?$"), 'i');
6541
+ var hexRegex = new RegExp("^#".concat(r('([a-f0-9]{2})', 3), "([a-f0-9]{2})?$"), 'i');
6542
+ var rgbaRegex = new RegExp("^rgba?\\(\\s*(\\d+)\\s*".concat(r(',\\s*(\\d+)\\s*', 2), "(?:,\\s*([\\d.]+))?\\s*\\)$"), 'i');
6543
+ var hslaRegex = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i;
6544
+ var namedColorRegex = /^[a-z]+$/i;
6545
+
6546
+ var roundColor = function roundColor(color) {
6547
+ return Math.round(color * 255);
6548
+ };
6549
+
6550
+ var hslToRgb = function hslToRgb(hue, saturation, lightness) {
6551
+ var l = lightness / 100;
6552
+
6553
+ if (saturation === 0) {
6554
+ // achromatic
6555
+ return [l, l, l].map(roundColor);
6556
+ } // formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
6557
+
6558
+
6559
+ var huePrime = (hue % 360 + 360) % 360 / 60;
6560
+ var chroma = (1 - Math.abs(2 * l - 1)) * (saturation / 100);
6561
+ var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
6562
+ var red = 0;
6563
+ var green = 0;
6564
+ var blue = 0;
6565
+
6566
+ if (huePrime >= 0 && huePrime < 1) {
6567
+ red = chroma;
6568
+ green = secondComponent;
6569
+ } else if (huePrime >= 1 && huePrime < 2) {
6570
+ red = secondComponent;
6571
+ green = chroma;
6572
+ } else if (huePrime >= 2 && huePrime < 3) {
6573
+ green = chroma;
6574
+ blue = secondComponent;
6575
+ } else if (huePrime >= 3 && huePrime < 4) {
6576
+ green = secondComponent;
6577
+ blue = chroma;
6578
+ } else if (huePrime >= 4 && huePrime < 5) {
6579
+ red = secondComponent;
6580
+ blue = chroma;
6581
+ } else if (huePrime >= 5 && huePrime < 6) {
6582
+ red = chroma;
6583
+ blue = secondComponent;
6584
+ }
6585
+
6586
+ var lightnessModification = l - chroma / 2;
6587
+ var finalRed = red + lightnessModification;
6588
+ var finalGreen = green + lightnessModification;
6589
+ var finalBlue = blue + lightnessModification;
6590
+ return [finalRed, finalGreen, finalBlue].map(roundColor);
6591
+ }; // taken from:
6592
+
6593
+ /**
6594
+ * Returns a number (float) representing the luminance of a color.
6595
+ */
6596
+
6597
+
6598
+ function getLuminance(color) {
6599
+ if (color === 'transparent') return 0;
6600
+
6601
+ function f(x) {
6602
+ var channel = x / 255;
6603
+ return channel <= 0.03928 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);
6604
+ }
6605
+
6606
+ var _parseToRgba = parseToRgba(color),
6607
+ _parseToRgba2 = _slicedToArray(_parseToRgba, 3),
6608
+ r = _parseToRgba2[0],
6609
+ g = _parseToRgba2[1],
6610
+ b = _parseToRgba2[2];
6611
+
6612
+ return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b);
6613
+ } // taken from:
6614
+ /**
6615
+ * An alternative function to `readableColor`. Returns whether or not the
6616
+ * readable color (i.e. the color to be place on top the input color) should be
6617
+ * black.
6618
+ */
6619
+
6620
+
6621
+ function readableColorIsBlack(color) {
6622
+ return getLuminance(color) > 0.179;
6362
6623
  }
6363
6624
 
6364
6625
  var _excluded$1 = ["pos"];
@@ -6379,39 +6640,39 @@ var Cursor = function Cursor(_ref3) {
6379
6640
  _ref3$size = _ref3.size,
6380
6641
  size = _ref3$size === void 0 ? 40 : _ref3$size,
6381
6642
  text = _ref3.text;
6382
- var textColor = F(color) ? "#222" : "#EEE";
6383
- return /*#__PURE__*/React.createElement(StyledCursor, null, /*#__PURE__*/React.createElement("svg", {
6643
+ var textColor = readableColorIsBlack(color) ? "#222" : "#EEE";
6644
+ return /*#__PURE__*/React__default.createElement(StyledCursor, null, /*#__PURE__*/React__default.createElement("svg", {
6384
6645
  version: "1.1",
6385
6646
  id: "Layer_1",
6386
6647
  xmlns: "http://www.w3.org/2000/svg",
6387
6648
  viewBox: "1064.7701 445.5539 419.8101 717.0565",
6388
6649
  width: size,
6389
6650
  height: size
6390
- }, /*#__PURE__*/React.createElement("path", {
6651
+ }, /*#__PURE__*/React__default.createElement("path", {
6391
6652
  d: "m 1197.1015,869.718 -62.2719,-154.49286 133.3276,-9.05842 -257.6915,-253.12748 1.2392,356.98609 88.2465,-79.47087 61.702,152.78366 z",
6392
6653
  style: {
6393
6654
  fill: textColor
6394
6655
  }
6395
- }), /*#__PURE__*/React.createElement("path", {
6656
+ }), /*#__PURE__*/React__default.createElement("path", {
6396
6657
  d: "m 1193.0939,861.12419 -62.2719,-154.49286 133.3276,-9.05842 -257.6915,-253.12748 1.2392,356.98609 88.2465,-79.47087 61.702,152.78366 z",
6397
6658
  style: {
6398
6659
  fill: "white",
6399
6660
  stroke: "#111",
6400
6661
  strokeWidth: 20
6401
6662
  }
6402
- })), /*#__PURE__*/React.createElement(CursorName, {
6663
+ })), /*#__PURE__*/React__default.createElement(CursorName, {
6403
6664
  color: color,
6404
6665
  textColor: textColor
6405
6666
  }, text));
6406
6667
  };
6407
6668
 
6408
- var MemoizedCursor = /*#__PURE__*/React.memo(Cursor);
6669
+ var MemoizedCursor = /*#__PURE__*/React__default.memo(Cursor);
6409
6670
 
6410
6671
  var PositionnedCursor = function PositionnedCursor(_ref4) {
6411
6672
  var pos = _ref4.pos,
6412
6673
  rest = _objectWithoutProperties(_ref4, _excluded$1);
6413
6674
 
6414
- return /*#__PURE__*/React.createElement("div", {
6675
+ return /*#__PURE__*/React__default.createElement("div", {
6415
6676
  style: {
6416
6677
  transform: "translate(".concat(pos.x - 5, "px, ").concat(pos.y - 3, "px)"),
6417
6678
  top: 0,
@@ -6420,7 +6681,7 @@ var PositionnedCursor = function PositionnedCursor(_ref4) {
6420
6681
  position: "fixed",
6421
6682
  pointerEvents: "none"
6422
6683
  }
6423
- }, /*#__PURE__*/React.createElement(MemoizedCursor, rest));
6684
+ }, /*#__PURE__*/React__default.createElement(MemoizedCursor, rest));
6424
6685
  };
6425
6686
 
6426
6687
  var Cursors = function Cursors(_ref) {
@@ -6429,20 +6690,20 @@ var Cursors = function Cursors(_ref) {
6429
6690
  var _useWire = useWire("board"),
6430
6691
  wire = _useWire.wire;
6431
6692
 
6432
- var _React$useState = React.useState({}),
6693
+ var _React$useState = React__default.useState({}),
6433
6694
  _React$useState2 = _slicedToArray(_React$useState, 2),
6434
6695
  cursors = _React$useState2[0],
6435
6696
  setCursors = _React$useState2[1];
6436
6697
 
6437
- var preventRef = React.useRef(false);
6438
- var usersById = React.useMemo(function () {
6698
+ var preventRef = React__default.useRef(false);
6699
+ var usersById = React__default.useMemo(function () {
6439
6700
  return users.reduce(function (acc, user) {
6440
6701
  acc[user.id] = user;
6441
6702
  return acc;
6442
6703
  }, {});
6443
6704
  }, [users]); // Prevent race condition when removing user
6444
6705
 
6445
- var currentCursor = React.useMemo(function () {
6706
+ var currentCursor = React__default.useMemo(function () {
6446
6707
  return users.reduce(function (acc, user) {
6447
6708
  if (cursors[user.id]) {
6448
6709
  acc[user.id] = cursors[user.id];
@@ -6451,7 +6712,7 @@ var Cursors = function Cursors(_ref) {
6451
6712
  return acc;
6452
6713
  }, {});
6453
6714
  }, [users, cursors]);
6454
- React.useEffect(function () {
6715
+ React__default.useEffect(function () {
6455
6716
  setCursors(function (prevCursors) {
6456
6717
  return users.reduce(function (acc, user) {
6457
6718
  if (prevCursors[user.id]) {
@@ -6462,7 +6723,7 @@ var Cursors = function Cursors(_ref) {
6462
6723
  }, {});
6463
6724
  });
6464
6725
  }, [users]);
6465
- React.useEffect(function () {
6726
+ React__default.useEffect(function () {
6466
6727
  var unsub = [];
6467
6728
  unsub.push(wire.subscribe("cursorMove", function (_ref2) {
6468
6729
  var userId = _ref2.userId,
@@ -6493,12 +6754,12 @@ var Cursors = function Cursors(_ref) {
6493
6754
  });
6494
6755
  };
6495
6756
  }, [wire]);
6496
- return /*#__PURE__*/React.createElement("div", null, Object.entries(currentCursor).map(function (_ref4) {
6757
+ return /*#__PURE__*/React__default.createElement("div", null, Object.entries(currentCursor).map(function (_ref4) {
6497
6758
  var _ref5 = _slicedToArray(_ref4, 2),
6498
6759
  userId = _ref5[0],
6499
6760
  pos = _ref5[1];
6500
6761
 
6501
- return /*#__PURE__*/React.createElement(PositionnedCursor, {
6762
+ return /*#__PURE__*/React__default.createElement(PositionnedCursor, {
6502
6763
  key: userId,
6503
6764
  pos: pos,
6504
6765
  text: usersById[userId].name,
@@ -6517,7 +6778,7 @@ var CursorPane = function CursorPane(_ref) {
6517
6778
  user = _useUsers.currentUser,
6518
6779
  users = _useUsers.users;
6519
6780
 
6520
- var publish = React.useCallback(function (newPos) {
6781
+ var publish = React__default.useCallback(function (newPos) {
6521
6782
  wire.publish("cursorMove", {
6522
6783
  userId: user.id,
6523
6784
  pos: newPos
@@ -6575,33 +6836,33 @@ var CursorPane = function CursorPane(_ref) {
6575
6836
  });
6576
6837
  };
6577
6838
 
6578
- return /*#__PURE__*/React.createElement("div", {
6839
+ return /*#__PURE__*/React__default.createElement("div", {
6579
6840
  onPointerMove: onMouseMove,
6580
6841
  onPointerLeave: onLeave
6581
- }, children, /*#__PURE__*/React.createElement(Cursors, {
6842
+ }, children, /*#__PURE__*/React__default.createElement(Cursors, {
6582
6843
  users: users
6583
6844
  }));
6584
6845
  };
6585
6846
 
6586
6847
  var useMousePosition = function useMousePosition(ref) {
6587
- var mouseRef = React.useRef({
6848
+ var mouseRef = React__default.useRef({
6588
6849
  hover: false,
6589
6850
  x: 0,
6590
6851
  y: 0
6591
6852
  });
6592
- var onMouseMove = React.useCallback(function (e) {
6853
+ var onMouseMove = React__default.useCallback(function (e) {
6593
6854
  var clientX = e.clientX,
6594
6855
  clientY = e.clientY;
6595
6856
  mouseRef.current.x = clientX;
6596
6857
  mouseRef.current.y = clientY;
6597
6858
  }, []);
6598
- var onMouseEnter = React.useCallback(function () {
6859
+ var onMouseEnter = React__default.useCallback(function () {
6599
6860
  mouseRef.current.hover = true;
6600
6861
  }, []);
6601
- var onMouseLeave = React.useCallback(function () {
6862
+ var onMouseLeave = React__default.useCallback(function () {
6602
6863
  mouseRef.current.hover = false;
6603
6864
  }, []);
6604
- React.useEffect(function () {
6865
+ React__default.useEffect(function () {
6605
6866
  var current = ref.current;
6606
6867
 
6607
6868
  if (current) {
@@ -6617,7 +6878,7 @@ var useMousePosition = function useMousePosition(ref) {
6617
6878
 
6618
6879
  return null; // eslint-disable-next-line react-hooks/exhaustive-deps
6619
6880
  }, [ref, ref.current, onMouseMove, onMouseEnter, onMouseLeave]);
6620
- var getMouseInfo = React.useCallback(function () {
6881
+ var getMouseInfo = React__default.useCallback(function () {
6621
6882
  return mouseRef.current;
6622
6883
  }, []);
6623
6884
  return getMouseInfo;
@@ -6628,7 +6889,7 @@ var digitCodes = _toConsumableArray(Array(5).keys()).map(function (id) {
6628
6889
  });
6629
6890
 
6630
6891
  var usePositionNavigator = function usePositionNavigator() {
6631
- var _React$useState = React.useState({}),
6892
+ var _React$useState = React__default.useState({}),
6632
6893
  _React$useState2 = _slicedToArray(_React$useState, 2),
6633
6894
  positions = _React$useState2[0],
6634
6895
  setPositions = _React$useState2[1];
@@ -6688,7 +6949,7 @@ var usePositionNavigator = function usePositionNavigator() {
6688
6949
  };
6689
6950
  }();
6690
6951
  }, [positions]);
6691
- React.useEffect(function () {
6952
+ React__default.useEffect(function () {
6692
6953
  document.addEventListener("keydown", onKeyDown);
6693
6954
  return function () {
6694
6955
  document.removeEventListener("keydown", onKeyDown);
@@ -6703,7 +6964,7 @@ var PanZoom = function PanZoom(_ref) {
6703
6964
  var children = _ref.children,
6704
6965
  _ref$moveFirst = _ref.moveFirst,
6705
6966
  moveFirst = _ref$moveFirst === void 0 ? false : _ref$moveFirst;
6706
- var wrappedRef = React.useRef(null);
6967
+ var wrappedRef = React__default.useRef(null);
6707
6968
  var dim = useRecoilValue(BoardTransformAtom);
6708
6969
 
6709
6970
  var _useDim = useDim(),
@@ -6713,13 +6974,13 @@ var PanZoom = function PanZoom(_ref) {
6713
6974
  var _useRecoilValue = useRecoilValue(ConfigurationAtom),
6714
6975
  itemExtentGlobal = _useRecoilValue.itemExtent;
6715
6976
 
6716
- var _React$useState = React.useState(false),
6977
+ var _React$useState = React__default.useState(false),
6717
6978
  _React$useState2 = _slicedToArray(_React$useState, 2),
6718
6979
  centered = _React$useState2[0],
6719
6980
  setCentered = _React$useState2[1];
6720
6981
 
6721
6982
  var setBoardState = useSetRecoilState(BoardStateAtom);
6722
- var timeoutRef = React.useRef({}); // Get mouse position and hover status
6983
+ var timeoutRef = React__default.useRef({}); // Get mouse position and hover status
6723
6984
 
6724
6985
  var getMouseInfo = useMousePosition(wrappedRef); // Hooks to save/restore position
6725
6986
 
@@ -6766,14 +7027,14 @@ var PanZoom = function PanZoom(_ref) {
6766
7027
  }, _callee);
6767
7028
  }));
6768
7029
  }, [setDim]);
6769
- React.useEffect(function () {
7030
+ React__default.useEffect(function () {
6770
7031
  if (!centered && itemExtentGlobal.left) {
6771
7032
  // Center board on first valid extent
6772
7033
  centerBoard();
6773
7034
  setCentered(true);
6774
7035
  }
6775
7036
  }, [centerBoard, centered, itemExtentGlobal]);
6776
- var onZoom = React.useCallback(function (_ref4) {
7037
+ var onZoom = React__default.useCallback(function (_ref4) {
6777
7038
  var clientX = _ref4.clientX,
6778
7039
  clientY = _ref4.clientY,
6779
7040
  scale = _ref4.scale;
@@ -6796,7 +7057,7 @@ var PanZoom = function PanZoom(_ref) {
6796
7057
  }) : prev;
6797
7058
  });
6798
7059
  }, [setBoardState, zoomTo]);
6799
- var onPan = React.useCallback( /*#__PURE__*/function () {
7060
+ var onPan = React__default.useCallback( /*#__PURE__*/function () {
6800
7061
  var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref5) {
6801
7062
  var deltaX, deltaY;
6802
7063
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
@@ -6837,7 +7098,7 @@ var PanZoom = function PanZoom(_ref) {
6837
7098
  return _ref6.apply(this, arguments);
6838
7099
  };
6839
7100
  }(), [setBoardState, setDim]);
6840
- var onDrag = React.useCallback(function (state) {
7101
+ var onDrag = React__default.useCallback(function (state) {
6841
7102
  var target = state.target;
6842
7103
  var outsideItem = !insideClass(target, "item") || insideClass(target, "locked");
6843
7104
 
@@ -6953,7 +7214,7 @@ var PanZoom = function PanZoom(_ref) {
6953
7214
  };
6954
7215
  }();
6955
7216
  }, [setDim, zoomTo, getMouseInfo]);
6956
- var onKeyUp = React.useCallback(function (e) {
7217
+ var onKeyUp = React__default.useCallback(function (e) {
6957
7218
  // Ignore text in Input or Textarea
6958
7219
  if (["INPUT", "TEXTAREA"].includes(e.target.tagName)) return; // Zoom out on release
6959
7220
 
@@ -6961,7 +7222,7 @@ var PanZoom = function PanZoom(_ref) {
6961
7222
  zoomTo(1 / 3, getMouseInfo());
6962
7223
  }
6963
7224
  }, [getMouseInfo, zoomTo]);
6964
- React.useEffect(function () {
7225
+ React__default.useEffect(function () {
6965
7226
  document.addEventListener("keydown", onKeyDown);
6966
7227
  document.addEventListener("keyup", onKeyUp);
6967
7228
  return function () {
@@ -6969,11 +7230,11 @@ var PanZoom = function PanZoom(_ref) {
6969
7230
  document.removeEventListener("keyup", onKeyUp);
6970
7231
  };
6971
7232
  }, [onKeyDown, onKeyUp]);
6972
- return /*#__PURE__*/React.createElement(Gesture, {
7233
+ return /*#__PURE__*/React__default.createElement(Gesture, {
6973
7234
  onPan: onPan,
6974
7235
  onZoom: onZoom,
6975
7236
  onDrag: onDrag
6976
- }, /*#__PURE__*/React.createElement("div", {
7237
+ }, /*#__PURE__*/React__default.createElement("div", {
6977
7238
  style: {
6978
7239
  display: "inline-block",
6979
7240
  transformOrigin: "top left",
@@ -7073,13 +7334,13 @@ var BoundingBox = function BoundingBox() {
7073
7334
  // eslint-disable-next-line react-hooks/exhaustive-deps
7074
7335
 
7075
7336
  var updateBoxDelay = useDebouncedCallback(updateBox, [updateBox], 300);
7076
- React.useEffect(function () {
7337
+ React__default.useEffect(function () {
7077
7338
  // Update selected elements bounding box
7078
7339
  updateBox();
7079
7340
  updateBoxDelay(); // Delay to update after board item animation like tap/untap.
7080
7341
  }, [selectedItems, itemMap, boardTransform, updateBox, updateBoxDelay]);
7081
7342
  if (!boundingBoxLast || selectedItems.length < 2) return null;
7082
- return /*#__PURE__*/React.createElement("div", {
7343
+ return /*#__PURE__*/React__default.createElement("div", {
7083
7344
  style: _objectSpread2(_objectSpread2({}, defaultZoneStyle), {}, {
7084
7345
  transform: "translate(".concat(boundingBoxLast.left, "px, ").concat(boundingBoxLast.top, "px)"),
7085
7346
  height: "".concat(boundingBoxLast.height, "px"),
@@ -7096,7 +7357,7 @@ var Selection = function Selection() {
7096
7357
  return null;
7097
7358
  }
7098
7359
 
7099
- return /*#__PURE__*/React.createElement(BoundingBox, null);
7360
+ return /*#__PURE__*/React__default.createElement(BoundingBox, null);
7100
7361
  };
7101
7362
 
7102
7363
  var Board = function Board(_ref) {
@@ -7115,7 +7376,7 @@ var Board = function Board(_ref) {
7115
7376
  var _useDim = useDim(),
7116
7377
  updateItemExtent = _useDim.updateItemExtent;
7117
7378
 
7118
- var boardStyle = React.useMemo(function () {
7379
+ var boardStyle = React__default.useMemo(function () {
7119
7380
  return _objectSpread2({
7120
7381
  userSelect: "none",
7121
7382
  width: "".concat(boardSize, "px"),
@@ -7123,7 +7384,7 @@ var Board = function Board(_ref) {
7123
7384
  backgroundColor: "#333"
7124
7385
  }, style);
7125
7386
  }, [boardSize, style]);
7126
- React.useEffect(function () {
7387
+ React__default.useEffect(function () {
7127
7388
  setConfiguration(function (prev) {
7128
7389
  return _objectSpread2(_objectSpread2({}, prev), {}, {
7129
7390
  itemTemplates: itemTemplates,
@@ -7132,21 +7393,21 @@ var Board = function Board(_ref) {
7132
7393
  });
7133
7394
  });
7134
7395
  }, [itemTemplates, setConfiguration, boardSize, showResizeHandle]);
7135
- React.useEffect(function () {
7396
+ React__default.useEffect(function () {
7136
7397
  updateItemExtent();
7137
7398
  setTimeout(updateItemExtent, 2000);
7138
7399
  }, [updateItemExtent]);
7139
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SubcribeItemEvents, null), /*#__PURE__*/React.createElement(PanZoom, {
7400
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(SubcribeItemEvents, null), /*#__PURE__*/React__default.createElement(PanZoom, {
7140
7401
  moveFirst: moveFirst
7141
- }, /*#__PURE__*/React.createElement(Selector, {
7402
+ }, /*#__PURE__*/React__default.createElement(Selector, {
7142
7403
  moveFirst: moveFirst
7143
- }, /*#__PURE__*/React.createElement(ActionPane, null, /*#__PURE__*/React.createElement(CursorPane, null, /*#__PURE__*/React.createElement("div", {
7404
+ }, /*#__PURE__*/React__default.createElement(ActionPane, null, /*#__PURE__*/React__default.createElement(CursorPane, null, /*#__PURE__*/React__default.createElement("div", {
7144
7405
  onContextMenu: function onContextMenu(e) {
7145
7406
  e.preventDefault();
7146
7407
  },
7147
7408
  style: boardStyle,
7148
7409
  className: "board"
7149
- }, /*#__PURE__*/React.createElement(ItemList, null), children))))), /*#__PURE__*/React.createElement(Selection, null));
7410
+ }, /*#__PURE__*/React__default.createElement(ItemList, null), children))))), /*#__PURE__*/React__default.createElement(Selection, null));
7150
7411
  };
7151
7412
 
7152
7413
  var TOLERANCE = 100;
@@ -7178,7 +7439,7 @@ var translateBoundaries = function translateBoundaries(_ref) {
7178
7439
 
7179
7440
  var useDim = function useDim() {
7180
7441
  var setDim = useSetRecoilState(BoardTransformAtom);
7181
- var scaleBoundariesRef = React.useRef([0.1, 8]);
7442
+ var scaleBoundariesRef = React__default.useRef([0.1, 8]);
7182
7443
 
7183
7444
  var _useRecoilValue = useRecoilValue(ConfigurationAtom),
7184
7445
  itemExtentGlobal = _useRecoilValue.itemExtent;
@@ -7490,7 +7751,7 @@ var useDim = function useDim() {
7490
7751
  }));
7491
7752
  }, []);
7492
7753
  var debouncedUpdateItemExtent = useDebouncedCallback(updateItemExtent, [], 300);
7493
- React.useEffect(function () {
7754
+ React__default.useEffect(function () {
7494
7755
  if (itemExtentGlobal.left) {
7495
7756
  updateScaleBoundaries();
7496
7757
  }
@@ -7506,7 +7767,7 @@ var useDim = function useDim() {
7506
7767
 
7507
7768
  var useItemInteraction = function useItemInteraction(interaction) {
7508
7769
  var setInteractions = useSetRecoilState(ItemInteractionsAtom);
7509
- var register = React.useCallback(function (callback) {
7770
+ var register = React__default.useCallback(function (callback) {
7510
7771
  setInteractions(function (prev) {
7511
7772
  var newInter = Array.isArray(prev[interaction]) ? [].concat(_toConsumableArray(prev[interaction]), [callback]) : [callback];
7512
7773
  return _objectSpread2(_objectSpread2({}, prev), {}, _defineProperty({}, interaction, newInter));
@@ -7641,7 +7902,7 @@ var useItemActions = function useItemActions() {
7641
7902
  };
7642
7903
  }();
7643
7904
  }, [setItemMap, updateItemExtent, wire]);
7644
- var setItemListFull = React.useCallback(function (items) {
7905
+ var setItemListFull = React__default.useCallback(function (items) {
7645
7906
  setItemMap(items.reduce(function (acc, item) {
7646
7907
  if (item && item.id) {
7647
7908
  acc[item.id] = item;
@@ -7657,11 +7918,11 @@ var useItemActions = function useItemActions() {
7657
7918
  setSelectItems([]);
7658
7919
  updateItemExtent();
7659
7920
  }, [setItemList, setItemMap, setSelectItems, updateItemExtent]);
7660
- var updateItem = React.useCallback(function (id, callbackOrItem) {
7921
+ var updateItem = React__default.useCallback(function (id, callbackOrItem) {
7661
7922
  var sync = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
7662
7923
  batchUpdateItems([id], callbackOrItem, sync);
7663
7924
  }, [batchUpdateItems]);
7664
- var moveItems = React.useCallback(function (itemIds, posDelta) {
7925
+ var moveItems = React__default.useCallback(function (itemIds, posDelta) {
7665
7926
  var sync = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
7666
7927
  setItemMap(function (prevItemMap) {
7667
7928
  var result = _objectSpread2({}, prevItemMap);
@@ -7691,7 +7952,7 @@ var useItemActions = function useItemActions() {
7691
7952
 
7692
7953
  updateItemExtent();
7693
7954
  }, [setItemMap, updateItemExtent, wire]);
7694
- var putItemsOnTop = React.useCallback(function (itemIdsToMove) {
7955
+ var putItemsOnTop = React__default.useCallback(function (itemIdsToMove) {
7695
7956
  var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
7696
7957
  setItemList(function (prevItemList) {
7697
7958
  var filtered = prevItemList.filter(function (id) {
@@ -7855,7 +8116,7 @@ var useItemActions = function useItemActions() {
7855
8116
  };
7856
8117
  }();
7857
8118
  }, [wire, setItemMap]);
7858
- var placeItems = React.useCallback( /*#__PURE__*/function () {
8119
+ var placeItems = React__default.useCallback( /*#__PURE__*/function () {
7859
8120
  var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(itemIds, gridConfig) {
7860
8121
  var sync,
7861
8122
  _args3 = arguments;
@@ -7889,7 +8150,7 @@ var useItemActions = function useItemActions() {
7889
8150
  return _ref8.apply(this, arguments);
7890
8151
  };
7891
8152
  }(), [batchUpdateItems, callPlaceInteractions, putItemsOnTop, stickOnGrid, updateItemExtent]);
7892
- var updateItemOrder = React.useCallback(function (newOrder) {
8153
+ var updateItemOrder = React__default.useCallback(function (newOrder) {
7893
8154
  var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
7894
8155
  setItemList(newOrder);
7895
8156
 
@@ -7897,7 +8158,7 @@ var useItemActions = function useItemActions() {
7897
8158
  wire.publish("updateItemListOrder", newOrder);
7898
8159
  }
7899
8160
  }, [wire, setItemList]);
7900
- var reverseItemsOrder = React.useCallback(function (itemIdsToReverse) {
8161
+ var reverseItemsOrder = React__default.useCallback(function (itemIdsToReverse) {
7901
8162
  var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
7902
8163
  setItemList(function (prevItemList) {
7903
8164
  var toBeReversed = prevItemList.filter(function (id) {
@@ -8011,7 +8272,7 @@ var useItemActions = function useItemActions() {
8011
8272
  };
8012
8273
  }();
8013
8274
  }, [wire, setItemList, setItemMap]);
8014
- var pushItems = React.useCallback( /*#__PURE__*/function () {
8275
+ var pushItems = React__default.useCallback( /*#__PURE__*/function () {
8015
8276
  var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(itemsToInsert, beforeId) {
8016
8277
  var sync,
8017
8278
  _args6 = arguments;
@@ -8087,11 +8348,11 @@ var useItemActions = function useItemActions() {
8087
8348
  return _ref11.apply(this, arguments);
8088
8349
  };
8089
8350
  }(), [updateItemExtent, getCenter, setItemMap, setItemList, wire]);
8090
- var pushItem = React.useCallback(function (itemToInsert, beforeId) {
8351
+ var pushItem = React__default.useCallback(function (itemToInsert, beforeId) {
8091
8352
  var sync = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
8092
8353
  pushItems([itemToInsert], beforeId, sync);
8093
8354
  }, [pushItems]);
8094
- var removeItems = React.useCallback(function (itemsIdToRemove) {
8355
+ var removeItems = React__default.useCallback(function (itemsIdToRemove) {
8095
8356
  var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
8096
8357
  // Remove from selected items first
8097
8358
  setSelectItems(function (prevList) {
@@ -8454,17 +8715,26 @@ var getActionsFromItem = function getActionsFromItem(item, itemMap) {
8454
8715
  };
8455
8716
 
8456
8717
  var useAvailableActions = function useAvailableActions() {
8718
+ var itemMap = useRecoilValue(ItemMapAtom);
8719
+
8457
8720
  var _useRecoilValue = useRecoilValue(ConfigurationAtom),
8458
- itemMap = _useRecoilValue.itemTemplates;
8721
+ itemTemplates = _useRecoilValue.itemTemplates;
8459
8722
 
8460
8723
  var selected = useRecoilValue(SelectedItemsAtom);
8461
8724
 
8462
- var _React$useState = React.useState([]),
8725
+ var _React$useState = React__default.useState([]),
8463
8726
  _React$useState2 = _slicedToArray(_React$useState, 2),
8464
8727
  availableActions = _React$useState2[0],
8465
8728
  setAvailableActions = _React$useState2[1];
8466
8729
 
8467
- var isMountedRef = React.useRef(false);
8730
+ var isMountedRef = React__default.useRef(false);
8731
+ React__default.useEffect(function () {
8732
+ // Mounted guard
8733
+ isMountedRef.current = true;
8734
+ return function () {
8735
+ isMountedRef.current = false;
8736
+ };
8737
+ }, []);
8468
8738
  var getItemListOrSelected = useRecoilCallback(function (_ref) {
8469
8739
  var snapshot = _ref.snapshot;
8470
8740
  return /*#__PURE__*/function () {
@@ -8512,19 +8782,12 @@ var useAvailableActions = function useAvailableActions() {
8512
8782
  };
8513
8783
  }();
8514
8784
  }, []);
8515
- React.useEffect(function () {
8516
- // Mounted guard
8517
- isMountedRef.current = true;
8518
- return function () {
8519
- isMountedRef.current = false;
8520
- };
8521
- }, []);
8522
8785
  /**
8523
8786
  * Returns available actions for selected items. An action is kept only if all
8524
8787
  * items have this exact same action with same parameters.
8525
8788
  */
8526
8789
 
8527
- var updateAvailableActions = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
8790
+ var updateAvailableActions = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
8528
8791
  var _yield$getItemListOrS, _yield$getItemListOrS2, selectedItemIds, selectedItemList, allActions;
8529
8792
 
8530
8793
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
@@ -8554,13 +8817,13 @@ var useAvailableActions = function useAvailableActions() {
8554
8817
 
8555
8818
  case 9:
8556
8819
  allActions = selectedItemList.reduce(function (acc, item) {
8557
- var itemActions = getActionsFromItem(item, itemMap);
8820
+ var itemActions = getActionsFromItem(item, itemTemplates);
8558
8821
  return acc.filter(function (value) {
8559
8822
  return itemActions.some(function (itemAction) {
8560
8823
  return es6(value, itemAction);
8561
8824
  });
8562
8825
  });
8563
- }, getActionsFromItem(selectedItemList[0], itemMap));
8826
+ }, getActionsFromItem(selectedItemList[0], itemTemplates));
8564
8827
  setAvailableActions(allActions);
8565
8828
  _context2.next = 14;
8566
8829
  break;
@@ -8574,11 +8837,11 @@ var useAvailableActions = function useAvailableActions() {
8574
8837
  }
8575
8838
  }
8576
8839
  }, _callee2);
8577
- })), [getItemListOrSelected, itemMap]); // Update available actions when selection change
8840
+ })), [getItemListOrSelected, itemTemplates]); // Update available actions when selection change
8841
+
8842
+ React__default.useEffect(updateAvailableActions, [updateAvailableActions, selected]); // Debounced update available actions when items change
8578
8843
 
8579
- React.useEffect(function () {
8580
- updateAvailableActions();
8581
- }, [updateAvailableActions, selected]);
8844
+ useDebouncedEffect(updateAvailableActions, [itemMap, updateAvailableActions], 300);
8582
8845
  return {
8583
8846
  availableActions: availableActions
8584
8847
  };
@@ -8600,7 +8863,7 @@ var useBoardConfig = function useBoardConfig() {
8600
8863
  var debouncedPublishUpdate = useDebouncedCallback(function (newConfig) {
8601
8864
  wire.publish("updateBoardConfig", newConfig);
8602
8865
  }, [wire], 1000);
8603
- var setSyncBoardConfig = React.useCallback(function (callbackOrConfig) {
8866
+ var setSyncBoardConfig = React__default.useCallback(function (callbackOrConfig) {
8604
8867
  var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
8605
8868
  var callback = callbackOrConfig;
8606
8869
 
@@ -8697,22 +8960,29 @@ var dayjs_min = {exports: {}};
8697
8960
  return void 0 === t;
8698
8961
  }
8699
8962
  },
8700
- D = "en",
8701
- v = {};
8963
+ v = "en",
8964
+ D = {};
8702
8965
 
8703
- v[D] = M;
8966
+ D[v] = M;
8704
8967
 
8705
8968
  var p = function p(t) {
8706
8969
  return t instanceof _;
8707
8970
  },
8708
- S = function S(t, e, n) {
8709
- var r;
8710
- if (!t) return D;
8711
- if ("string" == typeof t) v[t] && (r = t), e && (v[t] = e, r = t);else {
8712
- var i = t.name;
8713
- v[i] = t, r = i;
8971
+ S = function t(e, n, r) {
8972
+ var i;
8973
+ if (!e) return v;
8974
+
8975
+ if ("string" == typeof e) {
8976
+ var s = e.toLowerCase();
8977
+ D[s] && (i = s), n && (D[s] = n, i = s);
8978
+ var u = e.split("-");
8979
+ if (!i && u.length > 1) return t(u[0]);
8980
+ } else {
8981
+ var a = e.name;
8982
+ D[a] = e, i = a;
8714
8983
  }
8715
- return !n && r && (D = r), r || !n && D;
8984
+
8985
+ return !r && i && (v = i), i || !r && v;
8716
8986
  },
8717
8987
  w = function w(t, e) {
8718
8988
  if (p(t)) return t.clone();
@@ -8800,9 +9070,9 @@ var dayjs_min = {exports: {}};
8800
9070
  return r ? $(1, M) : $(0, M + 1);
8801
9071
 
8802
9072
  case o:
8803
- var D = this.$locale().weekStart || 0,
8804
- v = (y < D ? y + 7 : y) - D;
8805
- return $(r ? m - v : m + (6 - v), M);
9073
+ var v = this.$locale().weekStart || 0,
9074
+ D = (y < v ? y + 7 : y) - v;
9075
+ return $(r ? m - D : m + (6 - D), M);
8806
9076
 
8807
9077
  case a:
8808
9078
  case d:
@@ -8919,12 +9189,12 @@ var dayjs_min = {exports: {}};
8919
9189
  M = w(r),
8920
9190
  m = (M.utcOffset() - this.utcOffset()) * e,
8921
9191
  g = this - M,
8922
- D = O.m(this, M);
8923
- 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);
9192
+ v = O.m(this, M);
9193
+ 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);
8924
9194
  }, m.daysInMonth = function () {
8925
9195
  return this.endOf(f).$D;
8926
9196
  }, m.$locale = function () {
8927
- return v[this.$L];
9197
+ return D[this.$L];
8928
9198
  }, m.locale = function (t, e) {
8929
9199
  if (!t) return this.$L;
8930
9200
  var n = this.clone(),
@@ -8952,7 +9222,7 @@ var dayjs_min = {exports: {}};
8952
9222
  return t.$i || (t(e, _, w), t.$i = !0), w;
8953
9223
  }, w.locale = S, w.isDayjs = p, w.unix = function (t) {
8954
9224
  return w(1e3 * t);
8955
- }, w.en = v[D], w.Ls = v, w.p = {}, w;
9225
+ }, w.en = D[v], w.Ls = D, w.p = {}, w;
8956
9226
  });
8957
9227
  })(dayjs_min);
8958
9228
 
@@ -9037,12 +9307,12 @@ var useMessage = function useMessage() {
9037
9307
  }, _callee);
9038
9308
  }));
9039
9309
  }, []);
9040
- var setMessages = React.useCallback(function (newMessages) {
9310
+ var setMessages = React__default.useCallback(function (newMessages) {
9041
9311
  setMessagesState(newMessages.map(function (m) {
9042
9312
  return parseMessage(m);
9043
9313
  }));
9044
9314
  }, [setMessagesState]);
9045
- var initEvents = React.useCallback(function (unsub) {
9315
+ var initEvents = React__default.useCallback(function (unsub) {
9046
9316
  unsub.push(wire.subscribe("newMessage", function (newMessage) {
9047
9317
  setMessagesState(function (prevMessages) {
9048
9318
  return [].concat(_toConsumableArray(prevMessages), [parseMessage(newMessage)]);
@@ -9062,7 +9332,7 @@ var useMessage = function useMessage() {
9062
9332
 
9063
9333
  return unsub;
9064
9334
  }, [wire, getMessage, isMaster, onMessage, setMessages, setMessagesState]);
9065
- React.useEffect(function () {
9335
+ React__default.useEffect(function () {
9066
9336
  var unsub = [];
9067
9337
 
9068
9338
  if (subscribeEvents) {
@@ -9075,7 +9345,7 @@ var useMessage = function useMessage() {
9075
9345
  });
9076
9346
  };
9077
9347
  }, [initEvents, subscribeEvents]);
9078
- var sendMessage = React.useCallback(function (messageContent) {
9348
+ var sendMessage = React__default.useCallback(function (messageContent) {
9079
9349
  var newMessage = generateMsg({
9080
9350
  user: currentUser,
9081
9351
  content: messageContent
@@ -9097,7 +9367,7 @@ var StyledBoardView = newStyled.div(_templateObject || (_templateObject = _tagge
9097
9367
  var SyncBoard = function SyncBoard(_ref) {
9098
9368
  var children = _ref.children,
9099
9369
  style = _ref.style;
9100
- var boardWrapperRef = React.useRef(null);
9370
+ var boardWrapperRef = React__default.useRef(null);
9101
9371
  var setCurrentUserState = useSetRecoilState(userAtom);
9102
9372
 
9103
9373
  var _useWire = useWire("board"),
@@ -9108,7 +9378,7 @@ var SyncBoard = function SyncBoard(_ref) {
9108
9378
  uid = _useRecoilState2[0].uid,
9109
9379
  setConfiguration = _useRecoilState2[1];
9110
9380
 
9111
- React.useEffect(function () {
9381
+ React__default.useEffect(function () {
9112
9382
  // Chrome-related issue.
9113
9383
  // Making the wheel event non-passive, which allows to use preventDefault() to prevent
9114
9384
  // the browser original zoom and therefore allowing our custom one.
@@ -9125,7 +9395,7 @@ var SyncBoard = function SyncBoard(_ref) {
9125
9395
  };
9126
9396
  }, []); // Set user space
9127
9397
 
9128
- React.useEffect(function () {
9398
+ React__default.useEffect(function () {
9129
9399
  setCurrentUserState(function (prevUser) {
9130
9400
  return _objectSpread2(_objectSpread2({}, prevUser), {}, {
9131
9401
  space: session
@@ -9139,7 +9409,7 @@ var SyncBoard = function SyncBoard(_ref) {
9139
9409
  });
9140
9410
  };
9141
9411
  }, [session, setCurrentUserState]);
9142
- React.useEffect(function () {
9412
+ React__default.useEffect(function () {
9143
9413
  if (!uid) {
9144
9414
  setConfiguration(function (prev) {
9145
9415
  return _objectSpread2(_objectSpread2({}, prev), {}, {
@@ -9148,7 +9418,7 @@ var SyncBoard = function SyncBoard(_ref) {
9148
9418
  });
9149
9419
  }
9150
9420
  }, [setConfiguration, uid]);
9151
- React.useEffect(function () {
9421
+ React__default.useEffect(function () {
9152
9422
  setConfiguration(function (prev) {
9153
9423
  return _objectSpread2(_objectSpread2({}, prev), {}, {
9154
9424
  boardWrapper: boardWrapperRef.current
@@ -9156,13 +9426,17 @@ var SyncBoard = function SyncBoard(_ref) {
9156
9426
  });
9157
9427
  }, [setConfiguration, uid]);
9158
9428
  useResizeObserver(boardWrapperRef, function () {
9159
- return setConfiguration(function (prev) {
9429
+ if (!boardWrapperRef.current) {
9430
+ return;
9431
+ }
9432
+
9433
+ setConfiguration(function (prev) {
9160
9434
  return _objectSpread2(_objectSpread2({}, prev), {}, {
9161
9435
  boardWrapperRect: boardWrapperRef.current.getBoundingClientRect()
9162
9436
  });
9163
9437
  });
9164
9438
  });
9165
- return /*#__PURE__*/React.createElement(StyledBoardView, {
9439
+ return /*#__PURE__*/React__default.createElement(StyledBoardView, {
9166
9440
  ref: boardWrapperRef,
9167
9441
  id: uid,
9168
9442
  className: "sync-board",
@@ -9176,11 +9450,11 @@ var ConnectedSyncBoard = function ConnectedSyncBoard(_ref2) {
9176
9450
  session = _ref2.session,
9177
9451
  props = _objectWithoutProperties(_ref2, _excluded);
9178
9452
 
9179
- var _React$useState = React.useState(room || nanoid()),
9453
+ var _React$useState = React__default.useState(room || nanoid()),
9180
9454
  _React$useState2 = _slicedToArray(_React$useState, 1),
9181
9455
  stableRoom = _React$useState2[0];
9182
9456
 
9183
- var _React$useState3 = React.useState(session || nanoid()),
9457
+ var _React$useState3 = React__default.useState(session || nanoid()),
9184
9458
  _React$useState4 = _slicedToArray(_React$useState3, 1),
9185
9459
  stableSession = _React$useState4[0];
9186
9460
 
@@ -9188,22 +9462,22 @@ var ConnectedSyncBoard = function ConnectedSyncBoard(_ref2) {
9188
9462
 
9189
9463
  if (!roomChannel) {
9190
9464
  // No room declared so we create one
9191
- return /*#__PURE__*/React.createElement(RecoilRoot, null, /*#__PURE__*/React.createElement(WireProvider, {
9465
+ return /*#__PURE__*/React__default.createElement(RecoilRoot, null, /*#__PURE__*/React__default.createElement(WireProvider, {
9192
9466
  room: stableRoom,
9193
9467
  channel: "room",
9194
9468
  socket: socket
9195
- }, /*#__PURE__*/React.createElement(SubscribeUserEvents, null), /*#__PURE__*/React.createElement(WireProvider, {
9469
+ }, /*#__PURE__*/React__default.createElement(SubscribeUserEvents, null), /*#__PURE__*/React__default.createElement(WireProvider, {
9196
9470
  room: stableSession,
9197
9471
  channel: "board",
9198
9472
  socket: socket
9199
- }, /*#__PURE__*/React.createElement(SyncBoard, props))));
9473
+ }, /*#__PURE__*/React__default.createElement(SyncBoard, props))));
9200
9474
  }
9201
9475
 
9202
- return /*#__PURE__*/React.createElement(WireProvider, {
9476
+ return /*#__PURE__*/React__default.createElement(WireProvider, {
9203
9477
  room: stableSession,
9204
9478
  channel: "board",
9205
9479
  socket: socket
9206
- }, /*#__PURE__*/React.createElement(SyncBoard, props));
9480
+ }, /*#__PURE__*/React__default.createElement(SyncBoard, props));
9207
9481
  };
9208
9482
 
9209
9483
  var ConnectedSyncRoom = function ConnectedSyncRoom(_ref) {
@@ -9211,18 +9485,18 @@ var ConnectedSyncRoom = function ConnectedSyncRoom(_ref) {
9211
9485
  givenRoom = _ref.room,
9212
9486
  children = _ref.children;
9213
9487
 
9214
- var _React$useState = React.useState(function () {
9488
+ var _React$useState = React__default.useState(function () {
9215
9489
  return givenRoom || nanoid();
9216
9490
  }),
9217
9491
  _React$useState2 = _slicedToArray(_React$useState, 1),
9218
9492
  room = _React$useState2[0];
9219
9493
 
9220
- return /*#__PURE__*/React.createElement(RecoilRoot, null, /*#__PURE__*/React.createElement(WireProvider, {
9494
+ return /*#__PURE__*/React__default.createElement(RecoilRoot, null, /*#__PURE__*/React__default.createElement(WireProvider, {
9221
9495
  room: room,
9222
9496
  channel: "room",
9223
9497
  socket: socket
9224
- }, /*#__PURE__*/React.createElement(SubscribeUserEvents, null), children));
9498
+ }, /*#__PURE__*/React__default.createElement(SubscribeUserEvents, null), children));
9225
9499
  };
9226
9500
 
9227
- export { Board, ConnectedSyncBoard as BoardWrapper, ConnectedSyncRoom as RoomWrapper, useAvailableActions, useBoardConfig, useDim as useBoardPosition, useBoardState, useItemActions, useItemInteraction, useItemList as useItems, useMessage, useSelectedItems, useSelectionBox, useUsers, useWire };
9501
+ export { Board, ConnectedSyncBoard as BoardWrapper, ConnectedSyncRoom as RoomWrapper, useAvailableActions, useBoardConfig, useDim as useBoardPosition, useBoardState, useDebouncedItems, useItemActions, useItemInteraction, useItemList as useItems, useMessage, useSelectedItems, useSelectionBox, useUsers, useWire };
9228
9502
  //# sourceMappingURL=index.js.map