youtube-danmaku

Youtube livechat danmaku

目前为 2022-03-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name youtube-danmaku
  3. // @namespace https://github.com/IronKinoko/ytb-danmaku
  4. // @version 2.4.5
  5. // @icon https://www.youtube.com/favicon.ico
  6. // @license MIT
  7. // @description Youtube livechat danmaku
  8. // @author Ironkinoko
  9. // @match https://www.youtube.com/*
  10. // @exclude https://www.youtube.com/live_chat*
  11. // @grant none
  12. // @require https://cdn.jsdelivr.net/npm/react@16.14.0/umd/react.production.min.js
  13. // @require https://cdn.jsdelivr.net/npm/react-dom@16.14.0/umd/react-dom.production.min.js
  14. // @require https://cdn.jsdelivr.net/npm/mobx@6.3.2/dist/mobx.umd.production.min.js
  15. // @require https://cdn.jsdelivr.net/npm/mobx-react-lite@3.2.0/dist/mobxreactlite.umd.production.min.js
  16. // @require https://cdn.jsdelivr.net/npm/mobx-react@7.2.0/dist/mobxreact.umd.production.min.js
  17. // @require https://cdn.jsdelivr.net/npm/@ironkinoko/danmaku@1.2.6/dist/danmaku.min.js
  18. // ==/UserScript==
  19. (function (React$3, ReactDOM, mobxReact, mobx, Danmaku$2) {
  20. 'use strict';
  21.  
  22. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  23.  
  24. function _interopNamespace(e) {
  25. if (e && e.__esModule) return e;
  26. var n = Object.create(null);
  27. if (e) {
  28. Object.keys(e).forEach(function (k) {
  29. if (k !== 'default') {
  30. var d = Object.getOwnPropertyDescriptor(e, k);
  31. Object.defineProperty(n, k, d.get ? d : {
  32. enumerable: true,
  33. get: function () {
  34. return e[k];
  35. }
  36. });
  37. }
  38. });
  39. }
  40. n['default'] = e;
  41. return Object.freeze(n);
  42. }
  43.  
  44. var React__default = /*#__PURE__*/_interopDefaultLegacy(React$3);
  45. var React__namespace = /*#__PURE__*/_interopNamespace(React$3);
  46. var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
  47. var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
  48. var Danmaku__default = /*#__PURE__*/_interopDefaultLegacy(Danmaku$2);
  49.  
  50. var e$1 = [],
  51. t$1 = [];
  52.  
  53. function n$1(n, r) {
  54. if (n && "undefined" != typeof document) {
  55. var a,
  56. s = !0 === r.prepend ? "prepend" : "append",
  57. d = !0 === r.singleTag,
  58. i = "string" == typeof r.container ? document.querySelector(r.container) : document.getElementsByTagName("head")[0];
  59.  
  60. if (d) {
  61. var u = e$1.indexOf(i);
  62. -1 === u && (u = e$1.push(i) - 1, t$1[u] = {}), a = t$1[u] && t$1[u][s] ? t$1[u][s] : t$1[u][s] = c();
  63. } else a = c();
  64.  
  65. 65279 === n.charCodeAt(0) && (n = n.substring(1)), a.styleSheet ? a.styleSheet.cssText += n : a.appendChild(document.createTextNode(n));
  66. }
  67.  
  68. function c() {
  69. var e = document.createElement("style");
  70. if (e.setAttribute("type", "text/css"), r.attributes) for (var t = Object.keys(r.attributes), n = 0; n < t.length; n++) e.setAttribute(t[n], r.attributes[t[n]]);
  71. var a = "prepend" === s ? "afterbegin" : "beforeend";
  72. return i.insertAdjacentElement(a, e), e;
  73. }
  74. }
  75.  
  76. var css$2 = ".danmaku-stage {\n border: 0;\n bottom: 0;\n display: block;\n left: 0;\n margin: 0;\n overflow: hidden;\n position: absolute !important;\n right: 0;\n top: 0;\n -webkit-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);\n transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n pointer-events: none;\n z-index: 20;\n}\n\n.danmaku-stage > div {\n --size: var(--danmaku-font-size, 24px);\n pointer-events: none;\n color: #fff;\n font-family: SimHei, SimSun, Heiti, \"MS Mincho\", Meiryo, \"Microsoft YaHei\", monospace;\n font-size: var(--size);\n letter-spacing: 0;\n line-height: 100%;\n margin: 0;\n padding: 3px 0 0 0;\n position: absolute;\n text-decoration: none;\n text-shadow: -1px 0 #000, 0 1px #000, 1px 0 #000, 0 -1px #000;\n -webkit-text-size-adjust: none;\n -ms-text-size-adjust: none;\n text-size-adjust: none;\n -webkit-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);\n transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);\n -webkit-transform-origin: 0 0;\n -ms-transform-origin: 0 0;\n transform-origin: 0 0;\n white-space: pre;\n word-break: keep-all;\n}\n.danmaku-stage > div img {\n width: var(--size);\n height: var(--size);\n}";
  77. n$1(css$2,{});
  78.  
  79. var common = {
  80. black: '#000',
  81. white: '#fff'
  82. };
  83.  
  84. var red = {
  85. 50: '#ffebee',
  86. 100: '#ffcdd2',
  87. 200: '#ef9a9a',
  88. 300: '#e57373',
  89. 400: '#ef5350',
  90. 500: '#f44336',
  91. 600: '#e53935',
  92. 700: '#d32f2f',
  93. 800: '#c62828',
  94. 900: '#b71c1c',
  95. A100: '#ff8a80',
  96. A200: '#ff5252',
  97. A400: '#ff1744',
  98. A700: '#d50000'
  99. };
  100.  
  101. var pink = {
  102. 50: '#fce4ec',
  103. 100: '#f8bbd0',
  104. 200: '#f48fb1',
  105. 300: '#f06292',
  106. 400: '#ec407a',
  107. 500: '#e91e63',
  108. 600: '#d81b60',
  109. 700: '#c2185b',
  110. 800: '#ad1457',
  111. 900: '#880e4f',
  112. A100: '#ff80ab',
  113. A200: '#ff4081',
  114. A400: '#f50057',
  115. A700: '#c51162'
  116. };
  117.  
  118. var indigo = {
  119. 50: '#e8eaf6',
  120. 100: '#c5cae9',
  121. 200: '#9fa8da',
  122. 300: '#7986cb',
  123. 400: '#5c6bc0',
  124. 500: '#3f51b5',
  125. 600: '#3949ab',
  126. 700: '#303f9f',
  127. 800: '#283593',
  128. 900: '#1a237e',
  129. A100: '#8c9eff',
  130. A200: '#536dfe',
  131. A400: '#3d5afe',
  132. A700: '#304ffe'
  133. };
  134.  
  135. var blue = {
  136. 50: '#e3f2fd',
  137. 100: '#bbdefb',
  138. 200: '#90caf9',
  139. 300: '#64b5f6',
  140. 400: '#42a5f5',
  141. 500: '#2196f3',
  142. 600: '#1e88e5',
  143. 700: '#1976d2',
  144. 800: '#1565c0',
  145. 900: '#0d47a1',
  146. A100: '#82b1ff',
  147. A200: '#448aff',
  148. A400: '#2979ff',
  149. A700: '#2962ff'
  150. };
  151.  
  152. var green = {
  153. 50: '#e8f5e9',
  154. 100: '#c8e6c9',
  155. 200: '#a5d6a7',
  156. 300: '#81c784',
  157. 400: '#66bb6a',
  158. 500: '#4caf50',
  159. 600: '#43a047',
  160. 700: '#388e3c',
  161. 800: '#2e7d32',
  162. 900: '#1b5e20',
  163. A100: '#b9f6ca',
  164. A200: '#69f0ae',
  165. A400: '#00e676',
  166. A700: '#00c853'
  167. };
  168.  
  169. var orange = {
  170. 50: '#fff3e0',
  171. 100: '#ffe0b2',
  172. 200: '#ffcc80',
  173. 300: '#ffb74d',
  174. 400: '#ffa726',
  175. 500: '#ff9800',
  176. 600: '#fb8c00',
  177. 700: '#f57c00',
  178. 800: '#ef6c00',
  179. 900: '#e65100',
  180. A100: '#ffd180',
  181. A200: '#ffab40',
  182. A400: '#ff9100',
  183. A700: '#ff6d00'
  184. };
  185.  
  186. var grey = {
  187. 50: '#fafafa',
  188. 100: '#f5f5f5',
  189. 200: '#eeeeee',
  190. 300: '#e0e0e0',
  191. 400: '#bdbdbd',
  192. 500: '#9e9e9e',
  193. 600: '#757575',
  194. 700: '#616161',
  195. 800: '#424242',
  196. 900: '#212121',
  197. A100: '#d5d5d5',
  198. A200: '#aaaaaa',
  199. A400: '#303030',
  200. A700: '#616161'
  201. };
  202.  
  203. function _extends$1() {
  204. _extends$1 = Object.assign || function (target) {
  205. for (var i = 1; i < arguments.length; i++) {
  206. var source = arguments[i];
  207.  
  208. for (var key in source) {
  209. if (Object.prototype.hasOwnProperty.call(source, key)) {
  210. target[key] = source[key];
  211. }
  212. }
  213. }
  214.  
  215. return target;
  216. };
  217.  
  218. return _extends$1.apply(this, arguments);
  219. }
  220.  
  221. function _typeof$2(obj) {
  222. "@babel/helpers - typeof";
  223.  
  224. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  225. _typeof$2 = function _typeof(obj) {
  226. return typeof obj;
  227. };
  228. } else {
  229. _typeof$2 = function _typeof(obj) {
  230. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  231. };
  232. }
  233.  
  234. return _typeof$2(obj);
  235. }
  236.  
  237. function isPlainObject(item) {
  238. return item && _typeof$2(item) === 'object' && item.constructor === Object;
  239. }
  240. function deepmerge(target, source) {
  241. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
  242. clone: true
  243. };
  244. var output = options.clone ? _extends$1({}, target) : target;
  245.  
  246. if (isPlainObject(target) && isPlainObject(source)) {
  247. Object.keys(source).forEach(function (key) {
  248. // Avoid prototype pollution
  249. if (key === '__proto__') {
  250. return;
  251. }
  252.  
  253. if (isPlainObject(source[key]) && key in target) {
  254. output[key] = deepmerge(target[key], source[key], options);
  255. } else {
  256. output[key] = source[key];
  257. }
  258. });
  259. }
  260.  
  261. return output;
  262. }
  263.  
  264. function getAugmentedNamespace(n) {
  265. if (n.__esModule) return n;
  266. var a = Object.defineProperty({}, '__esModule', {value: true});
  267. Object.keys(n).forEach(function (k) {
  268. var d = Object.getOwnPropertyDescriptor(n, k);
  269. Object.defineProperty(a, k, d.get ? d : {
  270. enumerable: true,
  271. get: function () {
  272. return n[k];
  273. }
  274. });
  275. });
  276. return a;
  277. }
  278.  
  279. var reactIs$1 = {exports: {}};
  280.  
  281. var reactIs_production_min = {};
  282.  
  283. /** @license React v16.13.1
  284. * react-is.production.min.js
  285. *
  286. * Copyright (c) Facebook, Inc. and its affiliates.
  287. *
  288. * This source code is licensed under the MIT license found in the
  289. * LICENSE file in the root directory of this source tree.
  290. */
  291.  
  292. var b = "function" === typeof Symbol && Symbol.for,
  293. c = b ? Symbol.for("react.element") : 60103,
  294. d = b ? Symbol.for("react.portal") : 60106,
  295. e = b ? Symbol.for("react.fragment") : 60107,
  296. f = b ? Symbol.for("react.strict_mode") : 60108,
  297. g = b ? Symbol.for("react.profiler") : 60114,
  298. h = b ? Symbol.for("react.provider") : 60109,
  299. k = b ? Symbol.for("react.context") : 60110,
  300. l = b ? Symbol.for("react.async_mode") : 60111,
  301. m = b ? Symbol.for("react.concurrent_mode") : 60111,
  302. n = b ? Symbol.for("react.forward_ref") : 60112,
  303. p = b ? Symbol.for("react.suspense") : 60113,
  304. q = b ? Symbol.for("react.suspense_list") : 60120,
  305. r = b ? Symbol.for("react.memo") : 60115,
  306. t = b ? Symbol.for("react.lazy") : 60116,
  307. v = b ? Symbol.for("react.block") : 60121,
  308. w = b ? Symbol.for("react.fundamental") : 60117,
  309. x = b ? Symbol.for("react.responder") : 60118,
  310. y = b ? Symbol.for("react.scope") : 60119;
  311.  
  312. function z(a) {
  313. if ("object" === typeof a && null !== a) {
  314. var u = a.$$typeof;
  315.  
  316. switch (u) {
  317. case c:
  318. switch (a = a.type, a) {
  319. case l:
  320. case m:
  321. case e:
  322. case g:
  323. case f:
  324. case p:
  325. return a;
  326.  
  327. default:
  328. switch (a = a && a.$$typeof, a) {
  329. case k:
  330. case n:
  331. case t:
  332. case r:
  333. case h:
  334. return a;
  335.  
  336. default:
  337. return u;
  338. }
  339.  
  340. }
  341.  
  342. case d:
  343. return u;
  344. }
  345. }
  346. }
  347.  
  348. function A(a) {
  349. return z(a) === m;
  350. }
  351.  
  352. reactIs_production_min.AsyncMode = l;
  353. reactIs_production_min.ConcurrentMode = m;
  354. reactIs_production_min.ContextConsumer = k;
  355. reactIs_production_min.ContextProvider = h;
  356. reactIs_production_min.Element = c;
  357. reactIs_production_min.ForwardRef = n;
  358. reactIs_production_min.Fragment = e;
  359. reactIs_production_min.Lazy = t;
  360. reactIs_production_min.Memo = r;
  361. reactIs_production_min.Portal = d;
  362. reactIs_production_min.Profiler = g;
  363. reactIs_production_min.StrictMode = f;
  364. reactIs_production_min.Suspense = p;
  365.  
  366. reactIs_production_min.isAsyncMode = function (a) {
  367. return A(a) || z(a) === l;
  368. };
  369.  
  370. reactIs_production_min.isConcurrentMode = A;
  371.  
  372. reactIs_production_min.isContextConsumer = function (a) {
  373. return z(a) === k;
  374. };
  375.  
  376. reactIs_production_min.isContextProvider = function (a) {
  377. return z(a) === h;
  378. };
  379.  
  380. reactIs_production_min.isElement = function (a) {
  381. return "object" === typeof a && null !== a && a.$$typeof === c;
  382. };
  383.  
  384. reactIs_production_min.isForwardRef = function (a) {
  385. return z(a) === n;
  386. };
  387.  
  388. reactIs_production_min.isFragment = function (a) {
  389. return z(a) === e;
  390. };
  391.  
  392. reactIs_production_min.isLazy = function (a) {
  393. return z(a) === t;
  394. };
  395.  
  396. reactIs_production_min.isMemo = function (a) {
  397. return z(a) === r;
  398. };
  399.  
  400. reactIs_production_min.isPortal = function (a) {
  401. return z(a) === d;
  402. };
  403.  
  404. reactIs_production_min.isProfiler = function (a) {
  405. return z(a) === g;
  406. };
  407.  
  408. reactIs_production_min.isStrictMode = function (a) {
  409. return z(a) === f;
  410. };
  411.  
  412. reactIs_production_min.isSuspense = function (a) {
  413. return z(a) === p;
  414. };
  415.  
  416. reactIs_production_min.isValidElementType = function (a) {
  417. 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 || a.$$typeof === h || a.$$typeof === k || a.$$typeof === n || a.$$typeof === w || a.$$typeof === x || a.$$typeof === y || a.$$typeof === v);
  418. };
  419.  
  420. reactIs_production_min.typeOf = z;
  421.  
  422. {
  423. reactIs$1.exports = reactIs_production_min;
  424. }
  425.  
  426. /*
  427. object-assign
  428. (c) Sindre Sorhus
  429. @license MIT
  430. */
  431. /* eslint-disable no-unused-vars */
  432.  
  433. var getOwnPropertySymbols$1 = Object.getOwnPropertySymbols;
  434. var hasOwnProperty = Object.prototype.hasOwnProperty;
  435. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  436.  
  437. function toObject(val) {
  438. if (val === null || val === undefined) {
  439. throw new TypeError('Object.assign cannot be called with null or undefined');
  440. }
  441.  
  442. return Object(val);
  443. }
  444.  
  445. function shouldUseNative() {
  446. try {
  447. if (!Object.assign) {
  448. return false;
  449. } // Detect buggy property enumeration order in older V8 versions.
  450. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  451.  
  452.  
  453. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  454.  
  455. test1[5] = 'de';
  456.  
  457. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  458. return false;
  459. } // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  460.  
  461.  
  462. var test2 = {};
  463.  
  464. for (var i = 0; i < 10; i++) {
  465. test2['_' + String.fromCharCode(i)] = i;
  466. }
  467.  
  468. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  469. return test2[n];
  470. });
  471.  
  472. if (order2.join('') !== '0123456789') {
  473. return false;
  474. } // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  475.  
  476.  
  477. var test3 = {};
  478. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  479. test3[letter] = letter;
  480. });
  481.  
  482. if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') {
  483. return false;
  484. }
  485.  
  486. return true;
  487. } catch (err) {
  488. // We don't expect any of the above to throw, but better to be safe.
  489. return false;
  490. }
  491. }
  492.  
  493. shouldUseNative() ? Object.assign : function (target, source) {
  494. var from;
  495. var to = toObject(target);
  496. var symbols;
  497.  
  498. for (var s = 1; s < arguments.length; s++) {
  499. from = Object(arguments[s]);
  500.  
  501. for (var key in from) {
  502. if (hasOwnProperty.call(from, key)) {
  503. to[key] = from[key];
  504. }
  505. }
  506.  
  507. if (getOwnPropertySymbols$1) {
  508. symbols = getOwnPropertySymbols$1(from);
  509.  
  510. for (var i = 0; i < symbols.length; i++) {
  511. if (propIsEnumerable.call(from, symbols[i])) {
  512. to[symbols[i]] = from[symbols[i]];
  513. }
  514. }
  515. }
  516. }
  517.  
  518. return to;
  519. };
  520.  
  521. /**
  522. * Copyright (c) 2013-present, Facebook, Inc.
  523. *
  524. * This source code is licensed under the MIT license found in the
  525. * LICENSE file in the root directory of this source tree.
  526. */
  527.  
  528. var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  529. var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
  530.  
  531. /**
  532. * Copyright (c) 2013-present, Facebook, Inc.
  533. *
  534. * This source code is licensed under the MIT license found in the
  535. * LICENSE file in the root directory of this source tree.
  536. */
  537.  
  538. Function.call.bind(Object.prototype.hasOwnProperty);
  539.  
  540. /**
  541. * Copyright (c) 2013-present, Facebook, Inc.
  542. *
  543. * This source code is licensed under the MIT license found in the
  544. * LICENSE file in the root directory of this source tree.
  545. */
  546.  
  547. var ReactPropTypesSecret = ReactPropTypesSecret_1;
  548.  
  549. function emptyFunction() {}
  550.  
  551. function emptyFunctionWithReset() {}
  552.  
  553. emptyFunctionWithReset.resetWarningCache = emptyFunction;
  554.  
  555. var factoryWithThrowingShims = function () {
  556. function shim(props, propName, componentName, location, propFullName, secret) {
  557. if (secret === ReactPropTypesSecret) {
  558. // It is still safe when called from React.
  559. return;
  560. }
  561.  
  562. var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
  563. err.name = 'Invariant Violation';
  564. throw err;
  565. }
  566. shim.isRequired = shim;
  567.  
  568. function getShim() {
  569. return shim;
  570. }
  571. // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
  572.  
  573. var ReactPropTypes = {
  574. array: shim,
  575. bool: shim,
  576. func: shim,
  577. number: shim,
  578. object: shim,
  579. string: shim,
  580. symbol: shim,
  581. any: shim,
  582. arrayOf: getShim,
  583. element: shim,
  584. elementType: shim,
  585. instanceOf: getShim,
  586. node: shim,
  587. objectOf: getShim,
  588. oneOf: getShim,
  589. oneOfType: getShim,
  590. shape: getShim,
  591. exact: getShim,
  592. checkPropTypes: emptyFunctionWithReset,
  593. resetWarningCache: emptyFunction
  594. };
  595. ReactPropTypes.PropTypes = ReactPropTypes;
  596. return ReactPropTypes;
  597. };
  598.  
  599. /**
  600. * Copyright (c) 2013-present, Facebook, Inc.
  601. *
  602. * This source code is licensed under the MIT license found in the
  603. * LICENSE file in the root directory of this source tree.
  604. */
  605.  
  606. {
  607. // By explicitly using `prop-types` you are opting into new production behavior.
  608. // http://fb.me/prop-types-in-prod
  609. factoryWithThrowingShims();
  610. }
  611.  
  612. function _defineProperty$1(obj, key, value) {
  613. if (key in obj) {
  614. Object.defineProperty(obj, key, {
  615. value: value,
  616. enumerable: true,
  617. configurable: true,
  618. writable: true
  619. });
  620. } else {
  621. obj[key] = value;
  622. }
  623.  
  624. return obj;
  625. }
  626.  
  627. /**
  628. * WARNING: Don't import this directly.
  629. * Use `MuiError` from `@material-ui/utils/macros/MuiError.macro` instead.
  630. * @param {number} code
  631. */
  632. function formatMuiErrorMessage(code) {
  633. // Apply babel-plugin-transform-template-literals in loose mode
  634. // loose mode is safe iff we're concatenating primitives
  635. // see https://babeljs.io/docs/en/babel-plugin-transform-template-literals#loose
  636.  
  637. /* eslint-disable prefer-template */
  638. var url = 'https://material-ui.com/production-error/?code=' + code;
  639.  
  640. for (var i = 1; i < arguments.length; i += 1) {
  641. // rest params over-transpile for this case
  642. // eslint-disable-next-line prefer-rest-params
  643. url += '&args[]=' + encodeURIComponent(arguments[i]);
  644. }
  645.  
  646. return 'Minified Material-UI error #' + code + '; visit ' + url + ' for the full message.';
  647. /* eslint-enable prefer-template */
  648. }
  649.  
  650. /* eslint-disable no-use-before-define */
  651.  
  652. /**
  653. * Returns a number whose value is limited to the given range.
  654. *
  655. * @param {number} value The value to be clamped
  656. * @param {number} min The lower boundary of the output range
  657. * @param {number} max The upper boundary of the output range
  658. * @returns {number} A number in the range [min, max]
  659. */
  660.  
  661. function clamp$1(value) {
  662. var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  663. var max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
  664.  
  665. return Math.min(Math.max(min, value), max);
  666. }
  667. /**
  668. * Converts a color from CSS hex format to CSS rgb format.
  669. *
  670. * @param {string} color - Hex color, i.e. #nnn or #nnnnnn
  671. * @returns {string} A CSS rgb color string
  672. */
  673.  
  674.  
  675. function hexToRgb(color) {
  676. color = color.substr(1);
  677. var re = new RegExp(".{1,".concat(color.length >= 6 ? 2 : 1, "}"), 'g');
  678. var colors = color.match(re);
  679.  
  680. if (colors && colors[0].length === 1) {
  681. colors = colors.map(function (n) {
  682. return n + n;
  683. });
  684. }
  685.  
  686. return colors ? "rgb".concat(colors.length === 4 ? 'a' : '', "(").concat(colors.map(function (n, index) {
  687. return index < 3 ? parseInt(n, 16) : Math.round(parseInt(n, 16) / 255 * 1000) / 1000;
  688. }).join(', '), ")") : '';
  689. }
  690. /**
  691. * Converts a color from hsl format to rgb format.
  692. *
  693. * @param {string} color - HSL color values
  694. * @returns {string} rgb color values
  695. */
  696.  
  697. function hslToRgb(color) {
  698. color = decomposeColor(color);
  699. var _color = color,
  700. values = _color.values;
  701. var h = values[0];
  702. var s = values[1] / 100;
  703. var l = values[2] / 100;
  704. var a = s * Math.min(l, 1 - l);
  705.  
  706. var f = function f(n) {
  707. var k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (n + h / 30) % 12;
  708. return l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
  709. };
  710.  
  711. var type = 'rgb';
  712. var rgb = [Math.round(f(0) * 255), Math.round(f(8) * 255), Math.round(f(4) * 255)];
  713.  
  714. if (color.type === 'hsla') {
  715. type += 'a';
  716. rgb.push(values[3]);
  717. }
  718.  
  719. return recomposeColor({
  720. type: type,
  721. values: rgb
  722. });
  723. }
  724. /**
  725. * Returns an object with the type and values of a color.
  726. *
  727. * Note: Does not support rgb % values.
  728. *
  729. * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
  730. * @returns {object} - A MUI color object: {type: string, values: number[]}
  731. */
  732.  
  733. function decomposeColor(color) {
  734. // Idempotent
  735. if (color.type) {
  736. return color;
  737. }
  738.  
  739. if (color.charAt(0) === '#') {
  740. return decomposeColor(hexToRgb(color));
  741. }
  742.  
  743. var marker = color.indexOf('(');
  744. var type = color.substring(0, marker);
  745.  
  746. if (['rgb', 'rgba', 'hsl', 'hsla'].indexOf(type) === -1) {
  747. throw new Error(formatMuiErrorMessage(3, color));
  748. }
  749.  
  750. var values = color.substring(marker + 1, color.length - 1).split(',');
  751. values = values.map(function (value) {
  752. return parseFloat(value);
  753. });
  754. return {
  755. type: type,
  756. values: values
  757. };
  758. }
  759. /**
  760. * Converts a color object with type and values to a string.
  761. *
  762. * @param {object} color - Decomposed color
  763. * @param {string} color.type - One of: 'rgb', 'rgba', 'hsl', 'hsla'
  764. * @param {array} color.values - [n,n,n] or [n,n,n,n]
  765. * @returns {string} A CSS color string
  766. */
  767.  
  768. function recomposeColor(color) {
  769. var type = color.type;
  770. var values = color.values;
  771.  
  772. if (type.indexOf('rgb') !== -1) {
  773. // Only convert the first 3 values to int (i.e. not alpha)
  774. values = values.map(function (n, i) {
  775. return i < 3 ? parseInt(n, 10) : n;
  776. });
  777. } else if (type.indexOf('hsl') !== -1) {
  778. values[1] = "".concat(values[1], "%");
  779. values[2] = "".concat(values[2], "%");
  780. }
  781.  
  782. return "".concat(type, "(").concat(values.join(', '), ")");
  783. }
  784. /**
  785. * Calculates the contrast ratio between two colors.
  786. *
  787. * Formula: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
  788. *
  789. * @param {string} foreground - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
  790. * @param {string} background - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
  791. * @returns {number} A contrast ratio value in the range 0 - 21.
  792. */
  793.  
  794. function getContrastRatio(foreground, background) {
  795. var lumA = getLuminance(foreground);
  796. var lumB = getLuminance(background);
  797. return (Math.max(lumA, lumB) + 0.05) / (Math.min(lumA, lumB) + 0.05);
  798. }
  799. /**
  800. * The relative brightness of any point in a color space,
  801. * normalized to 0 for darkest black and 1 for lightest white.
  802. *
  803. * Formula: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
  804. *
  805. * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
  806. * @returns {number} The relative brightness of the color in the range 0 - 1
  807. */
  808.  
  809. function getLuminance(color) {
  810. color = decomposeColor(color);
  811. var rgb = color.type === 'hsl' ? decomposeColor(hslToRgb(color)).values : color.values;
  812. rgb = rgb.map(function (val) {
  813. val /= 255; // normalized
  814.  
  815. return val <= 0.03928 ? val / 12.92 : Math.pow((val + 0.055) / 1.055, 2.4);
  816. }); // Truncate at 3 digits
  817.  
  818. return Number((0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2]).toFixed(3));
  819. }
  820. /**
  821. * Set the absolute transparency of a color.
  822. * Any existing alpha values are overwritten.
  823. *
  824. * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
  825. * @param {number} value - value to set the alpha channel to in the range 0 -1
  826. * @returns {string} A CSS color string. Hex input values are returned as rgb
  827. */
  828.  
  829. function fade(color, value) {
  830. color = decomposeColor(color);
  831. value = clamp$1(value);
  832.  
  833. if (color.type === 'rgb' || color.type === 'hsl') {
  834. color.type += 'a';
  835. }
  836.  
  837. color.values[3] = value;
  838. return recomposeColor(color);
  839. }
  840. /**
  841. * Darkens a color.
  842. *
  843. * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
  844. * @param {number} coefficient - multiplier in the range 0 - 1
  845. * @returns {string} A CSS color string. Hex input values are returned as rgb
  846. */
  847.  
  848. function darken(color, coefficient) {
  849. color = decomposeColor(color);
  850. coefficient = clamp$1(coefficient);
  851.  
  852. if (color.type.indexOf('hsl') !== -1) {
  853. color.values[2] *= 1 - coefficient;
  854. } else if (color.type.indexOf('rgb') !== -1) {
  855. for (var i = 0; i < 3; i += 1) {
  856. color.values[i] *= 1 - coefficient;
  857. }
  858. }
  859.  
  860. return recomposeColor(color);
  861. }
  862. /**
  863. * Lightens a color.
  864. *
  865. * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
  866. * @param {number} coefficient - multiplier in the range 0 - 1
  867. * @returns {string} A CSS color string. Hex input values are returned as rgb
  868. */
  869.  
  870. function lighten(color, coefficient) {
  871. color = decomposeColor(color);
  872. coefficient = clamp$1(coefficient);
  873.  
  874. if (color.type.indexOf('hsl') !== -1) {
  875. color.values[2] += (100 - color.values[2]) * coefficient;
  876. } else if (color.type.indexOf('rgb') !== -1) {
  877. for (var i = 0; i < 3; i += 1) {
  878. color.values[i] += (255 - color.values[i]) * coefficient;
  879. }
  880. }
  881.  
  882. return recomposeColor(color);
  883. }
  884.  
  885. function _objectWithoutPropertiesLoose(source, excluded) {
  886. if (source == null) return {};
  887. var target = {};
  888. var sourceKeys = Object.keys(source);
  889. var key, i;
  890.  
  891. for (i = 0; i < sourceKeys.length; i++) {
  892. key = sourceKeys[i];
  893. if (excluded.indexOf(key) >= 0) continue;
  894. target[key] = source[key];
  895. }
  896.  
  897. return target;
  898. }
  899.  
  900. function _objectWithoutProperties(source, excluded) {
  901. if (source == null) return {};
  902. var target = _objectWithoutPropertiesLoose(source, excluded);
  903. var key, i;
  904.  
  905. if (Object.getOwnPropertySymbols) {
  906. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  907.  
  908. for (i = 0; i < sourceSymbolKeys.length; i++) {
  909. key = sourceSymbolKeys[i];
  910. if (excluded.indexOf(key) >= 0) continue;
  911. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  912. target[key] = source[key];
  913. }
  914. }
  915.  
  916. return target;
  917. }
  918.  
  919. // It can't be configured as it's used statically for propTypes.
  920.  
  921. var keys = ['xs', 'sm', 'md', 'lg', 'xl']; // Keep in mind that @media is inclusive by the CSS specification.
  922.  
  923. function createBreakpoints(breakpoints) {
  924. var _breakpoints$values = breakpoints.values,
  925. values = _breakpoints$values === void 0 ? {
  926. xs: 0,
  927. sm: 600,
  928. md: 960,
  929. lg: 1280,
  930. xl: 1920
  931. } : _breakpoints$values,
  932. _breakpoints$unit = breakpoints.unit,
  933. unit = _breakpoints$unit === void 0 ? 'px' : _breakpoints$unit,
  934. _breakpoints$step = breakpoints.step,
  935. step = _breakpoints$step === void 0 ? 5 : _breakpoints$step,
  936. other = _objectWithoutProperties(breakpoints, ["values", "unit", "step"]);
  937.  
  938. function up(key) {
  939. var value = typeof values[key] === 'number' ? values[key] : key;
  940. return "@media (min-width:".concat(value).concat(unit, ")");
  941. }
  942.  
  943. function down(key) {
  944. var endIndex = keys.indexOf(key) + 1;
  945. var upperbound = values[keys[endIndex]];
  946.  
  947. if (endIndex === keys.length) {
  948. // xl down applies to all sizes
  949. return up('xs');
  950. }
  951.  
  952. var value = typeof upperbound === 'number' && endIndex > 0 ? upperbound : key;
  953. return "@media (max-width:".concat(value - step / 100).concat(unit, ")");
  954. }
  955.  
  956. function between(start, end) {
  957. var endIndex = keys.indexOf(end);
  958.  
  959. if (endIndex === keys.length - 1) {
  960. return up(start);
  961. }
  962.  
  963. return "@media (min-width:".concat(typeof values[start] === 'number' ? values[start] : start).concat(unit, ") and ") + "(max-width:".concat((endIndex !== -1 && typeof values[keys[endIndex + 1]] === 'number' ? values[keys[endIndex + 1]] : end) - step / 100).concat(unit, ")");
  964. }
  965.  
  966. function only(key) {
  967. return between(key, key);
  968. }
  969.  
  970. function width(key) {
  971. return values[key];
  972. }
  973.  
  974. return _extends$1({
  975. keys: keys,
  976. values: values,
  977. up: up,
  978. down: down,
  979. between: between,
  980. only: only,
  981. width: width
  982. }, other);
  983. }
  984.  
  985. function createMixins(breakpoints, spacing, mixins) {
  986. var _toolbar;
  987.  
  988. return _extends$1({
  989. gutters: function gutters() {
  990. var styles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; // To deprecate in v4.1
  991. // warning(
  992. // false,
  993. // [
  994. // 'Material-UI: Theme.mixins.gutters() is deprecated.',
  995. // 'You can use the source of the mixin directly:',
  996. // `
  997. // paddingLeft: theme.spacing(2),
  998. // paddingRight: theme.spacing(2),
  999. // [theme.breakpoints.up('sm')]: {
  1000. // paddingLeft: theme.spacing(3),
  1001. // paddingRight: theme.spacing(3),
  1002. // },
  1003. // `,
  1004. // ].join('\n'),
  1005. // );
  1006.  
  1007. return _extends$1({
  1008. paddingLeft: spacing(2),
  1009. paddingRight: spacing(2)
  1010. }, styles, _defineProperty$1({}, breakpoints.up('sm'), _extends$1({
  1011. paddingLeft: spacing(3),
  1012. paddingRight: spacing(3)
  1013. }, styles[breakpoints.up('sm')])));
  1014. },
  1015. toolbar: (_toolbar = {
  1016. minHeight: 56
  1017. }, _defineProperty$1(_toolbar, "".concat(breakpoints.up('xs'), " and (orientation: landscape)"), {
  1018. minHeight: 48
  1019. }), _defineProperty$1(_toolbar, breakpoints.up('sm'), {
  1020. minHeight: 64
  1021. }), _toolbar)
  1022. }, mixins);
  1023. }
  1024.  
  1025. var light = {
  1026. // The colors used to style the text.
  1027. text: {
  1028. // The most important text.
  1029. primary: 'rgba(0, 0, 0, 0.87)',
  1030. // Secondary text.
  1031. secondary: 'rgba(0, 0, 0, 0.54)',
  1032. // Disabled text have even lower visual prominence.
  1033. disabled: 'rgba(0, 0, 0, 0.38)',
  1034. // Text hints.
  1035. hint: 'rgba(0, 0, 0, 0.38)'
  1036. },
  1037. // The color used to divide different elements.
  1038. divider: 'rgba(0, 0, 0, 0.12)',
  1039. // The background colors used to style the surfaces.
  1040. // Consistency between these values is important.
  1041. background: {
  1042. paper: common.white,
  1043. default: grey[50]
  1044. },
  1045. // The colors used to style the action elements.
  1046. action: {
  1047. // The color of an active action like an icon button.
  1048. active: 'rgba(0, 0, 0, 0.54)',
  1049. // The color of an hovered action.
  1050. hover: 'rgba(0, 0, 0, 0.04)',
  1051. hoverOpacity: 0.04,
  1052. // The color of a selected action.
  1053. selected: 'rgba(0, 0, 0, 0.08)',
  1054. selectedOpacity: 0.08,
  1055. // The color of a disabled action.
  1056. disabled: 'rgba(0, 0, 0, 0.26)',
  1057. // The background color of a disabled action.
  1058. disabledBackground: 'rgba(0, 0, 0, 0.12)',
  1059. disabledOpacity: 0.38,
  1060. focus: 'rgba(0, 0, 0, 0.12)',
  1061. focusOpacity: 0.12,
  1062. activatedOpacity: 0.12
  1063. }
  1064. };
  1065. var dark = {
  1066. text: {
  1067. primary: common.white,
  1068. secondary: 'rgba(255, 255, 255, 0.7)',
  1069. disabled: 'rgba(255, 255, 255, 0.5)',
  1070. hint: 'rgba(255, 255, 255, 0.5)',
  1071. icon: 'rgba(255, 255, 255, 0.5)'
  1072. },
  1073. divider: 'rgba(255, 255, 255, 0.12)',
  1074. background: {
  1075. paper: grey[800],
  1076. default: '#303030'
  1077. },
  1078. action: {
  1079. active: common.white,
  1080. hover: 'rgba(255, 255, 255, 0.08)',
  1081. hoverOpacity: 0.08,
  1082. selected: 'rgba(255, 255, 255, 0.16)',
  1083. selectedOpacity: 0.16,
  1084. disabled: 'rgba(255, 255, 255, 0.3)',
  1085. disabledBackground: 'rgba(255, 255, 255, 0.12)',
  1086. disabledOpacity: 0.38,
  1087. focus: 'rgba(255, 255, 255, 0.12)',
  1088. focusOpacity: 0.12,
  1089. activatedOpacity: 0.24
  1090. }
  1091. };
  1092.  
  1093. function addLightOrDark(intent, direction, shade, tonalOffset) {
  1094. var tonalOffsetLight = tonalOffset.light || tonalOffset;
  1095. var tonalOffsetDark = tonalOffset.dark || tonalOffset * 1.5;
  1096.  
  1097. if (!intent[direction]) {
  1098. if (intent.hasOwnProperty(shade)) {
  1099. intent[direction] = intent[shade];
  1100. } else if (direction === 'light') {
  1101. intent.light = lighten(intent.main, tonalOffsetLight);
  1102. } else if (direction === 'dark') {
  1103. intent.dark = darken(intent.main, tonalOffsetDark);
  1104. }
  1105. }
  1106. }
  1107.  
  1108. function createPalette(palette) {
  1109. var _palette$primary = palette.primary,
  1110. primary = _palette$primary === void 0 ? {
  1111. light: indigo[300],
  1112. main: indigo[500],
  1113. dark: indigo[700]
  1114. } : _palette$primary,
  1115. _palette$secondary = palette.secondary,
  1116. secondary = _palette$secondary === void 0 ? {
  1117. light: pink.A200,
  1118. main: pink.A400,
  1119. dark: pink.A700
  1120. } : _palette$secondary,
  1121. _palette$error = palette.error,
  1122. error = _palette$error === void 0 ? {
  1123. light: red[300],
  1124. main: red[500],
  1125. dark: red[700]
  1126. } : _palette$error,
  1127. _palette$warning = palette.warning,
  1128. warning = _palette$warning === void 0 ? {
  1129. light: orange[300],
  1130. main: orange[500],
  1131. dark: orange[700]
  1132. } : _palette$warning,
  1133. _palette$info = palette.info,
  1134. info = _palette$info === void 0 ? {
  1135. light: blue[300],
  1136. main: blue[500],
  1137. dark: blue[700]
  1138. } : _palette$info,
  1139. _palette$success = palette.success,
  1140. success = _palette$success === void 0 ? {
  1141. light: green[300],
  1142. main: green[500],
  1143. dark: green[700]
  1144. } : _palette$success,
  1145. _palette$type = palette.type,
  1146. type = _palette$type === void 0 ? 'light' : _palette$type,
  1147. _palette$contrastThre = palette.contrastThreshold,
  1148. contrastThreshold = _palette$contrastThre === void 0 ? 3 : _palette$contrastThre,
  1149. _palette$tonalOffset = palette.tonalOffset,
  1150. tonalOffset = _palette$tonalOffset === void 0 ? 0.2 : _palette$tonalOffset,
  1151. other = _objectWithoutProperties(palette, ["primary", "secondary", "error", "warning", "info", "success", "type", "contrastThreshold", "tonalOffset"]); // Use the same logic as
  1152. // Bootstrap: https://github.com/twbs/bootstrap/blob/1d6e3710dd447de1a200f29e8fa521f8a0908f70/scss/_functions.scss#L59
  1153. // and material-components-web https://github.com/material-components/material-components-web/blob/ac46b8863c4dab9fc22c4c662dc6bd1b65dd652f/packages/mdc-theme/_functions.scss#L54
  1154.  
  1155.  
  1156. function getContrastText(background) {
  1157. var contrastText = getContrastRatio(background, dark.text.primary) >= contrastThreshold ? dark.text.primary : light.text.primary;
  1158.  
  1159. return contrastText;
  1160. }
  1161.  
  1162. var augmentColor = function augmentColor(color) {
  1163. var mainShade = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
  1164. var lightShade = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 300;
  1165. var darkShade = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 700;
  1166. color = _extends$1({}, color);
  1167.  
  1168. if (!color.main && color[mainShade]) {
  1169. color.main = color[mainShade];
  1170. }
  1171.  
  1172. if (!color.main) {
  1173. throw new Error(formatMuiErrorMessage(4, mainShade));
  1174. }
  1175.  
  1176. if (typeof color.main !== 'string') {
  1177. throw new Error(formatMuiErrorMessage(5, JSON.stringify(color.main)));
  1178. }
  1179.  
  1180. addLightOrDark(color, 'light', lightShade, tonalOffset);
  1181. addLightOrDark(color, 'dark', darkShade, tonalOffset);
  1182.  
  1183. if (!color.contrastText) {
  1184. color.contrastText = getContrastText(color.main);
  1185. }
  1186.  
  1187. return color;
  1188. };
  1189.  
  1190. var types = {
  1191. dark: dark,
  1192. light: light
  1193. };
  1194.  
  1195. var paletteOutput = deepmerge(_extends$1({
  1196. // A collection of common colors.
  1197. common: common,
  1198. // The palette type, can be light or dark.
  1199. type: type,
  1200. // The colors used to represent primary interface elements for a user.
  1201. primary: augmentColor(primary),
  1202. // The colors used to represent secondary interface elements for a user.
  1203. secondary: augmentColor(secondary, 'A400', 'A200', 'A700'),
  1204. // The colors used to represent interface elements that the user should be made aware of.
  1205. error: augmentColor(error),
  1206. // The colors used to represent potentially dangerous actions or important messages.
  1207. warning: augmentColor(warning),
  1208. // The colors used to present information to the user that is neutral and not necessarily important.
  1209. info: augmentColor(info),
  1210. // The colors used to indicate the successful completion of an action that user triggered.
  1211. success: augmentColor(success),
  1212. // The grey colors.
  1213. grey: grey,
  1214. // Used by `getContrastText()` to maximize the contrast between
  1215. // the background and the text.
  1216. contrastThreshold: contrastThreshold,
  1217. // Takes a background color and returns the text color that maximizes the contrast.
  1218. getContrastText: getContrastText,
  1219. // Generate a rich color object.
  1220. augmentColor: augmentColor,
  1221. // Used by the functions below to shift a color's luminance by approximately
  1222. // two indexes within its tonal palette.
  1223. // E.g., shift from Red 500 to Red 300 or Red 700.
  1224. tonalOffset: tonalOffset
  1225. }, types[type]), other);
  1226. return paletteOutput;
  1227. }
  1228.  
  1229. function round$1(value) {
  1230. return Math.round(value * 1e5) / 1e5;
  1231. }
  1232.  
  1233. var caseAllCaps = {
  1234. textTransform: 'uppercase'
  1235. };
  1236. var defaultFontFamily = '"Roboto", "Helvetica", "Arial", sans-serif';
  1237. /**
  1238. * @see @link{https://material.io/design/typography/the-type-system.html}
  1239. * @see @link{https://material.io/design/typography/understanding-typography.html}
  1240. */
  1241.  
  1242. function createTypography(palette, typography) {
  1243. var _ref = typeof typography === 'function' ? typography(palette) : typography,
  1244. _ref$fontFamily = _ref.fontFamily,
  1245. fontFamily = _ref$fontFamily === void 0 ? defaultFontFamily : _ref$fontFamily,
  1246. _ref$fontSize = _ref.fontSize,
  1247. fontSize = _ref$fontSize === void 0 ? 14 : _ref$fontSize,
  1248. _ref$fontWeightLight = _ref.fontWeightLight,
  1249. fontWeightLight = _ref$fontWeightLight === void 0 ? 300 : _ref$fontWeightLight,
  1250. _ref$fontWeightRegula = _ref.fontWeightRegular,
  1251. fontWeightRegular = _ref$fontWeightRegula === void 0 ? 400 : _ref$fontWeightRegula,
  1252. _ref$fontWeightMedium = _ref.fontWeightMedium,
  1253. fontWeightMedium = _ref$fontWeightMedium === void 0 ? 500 : _ref$fontWeightMedium,
  1254. _ref$fontWeightBold = _ref.fontWeightBold,
  1255. fontWeightBold = _ref$fontWeightBold === void 0 ? 700 : _ref$fontWeightBold,
  1256. _ref$htmlFontSize = _ref.htmlFontSize,
  1257. htmlFontSize = _ref$htmlFontSize === void 0 ? 16 : _ref$htmlFontSize,
  1258. allVariants = _ref.allVariants,
  1259. pxToRem2 = _ref.pxToRem,
  1260. other = _objectWithoutProperties(_ref, ["fontFamily", "fontSize", "fontWeightLight", "fontWeightRegular", "fontWeightMedium", "fontWeightBold", "htmlFontSize", "allVariants", "pxToRem"]);
  1261.  
  1262. var coef = fontSize / 14;
  1263.  
  1264. var pxToRem = pxToRem2 || function (size) {
  1265. return "".concat(size / htmlFontSize * coef, "rem");
  1266. };
  1267.  
  1268. var buildVariant = function buildVariant(fontWeight, size, lineHeight, letterSpacing, casing) {
  1269. return _extends$1({
  1270. fontFamily: fontFamily,
  1271. fontWeight: fontWeight,
  1272. fontSize: pxToRem(size),
  1273. // Unitless following https://meyerweb.com/eric/thoughts/2006/02/08/unitless-line-heights/
  1274. lineHeight: lineHeight
  1275. }, fontFamily === defaultFontFamily ? {
  1276. letterSpacing: "".concat(round$1(letterSpacing / size), "em")
  1277. } : {}, casing, allVariants);
  1278. };
  1279.  
  1280. var variants = {
  1281. h1: buildVariant(fontWeightLight, 96, 1.167, -1.5),
  1282. h2: buildVariant(fontWeightLight, 60, 1.2, -0.5),
  1283. h3: buildVariant(fontWeightRegular, 48, 1.167, 0),
  1284. h4: buildVariant(fontWeightRegular, 34, 1.235, 0.25),
  1285. h5: buildVariant(fontWeightRegular, 24, 1.334, 0),
  1286. h6: buildVariant(fontWeightMedium, 20, 1.6, 0.15),
  1287. subtitle1: buildVariant(fontWeightRegular, 16, 1.75, 0.15),
  1288. subtitle2: buildVariant(fontWeightMedium, 14, 1.57, 0.1),
  1289. body1: buildVariant(fontWeightRegular, 16, 1.5, 0.15),
  1290. body2: buildVariant(fontWeightRegular, 14, 1.43, 0.15),
  1291. button: buildVariant(fontWeightMedium, 14, 1.75, 0.4, caseAllCaps),
  1292. caption: buildVariant(fontWeightRegular, 12, 1.66, 0.4),
  1293. overline: buildVariant(fontWeightRegular, 12, 2.66, 1, caseAllCaps)
  1294. };
  1295. return deepmerge(_extends$1({
  1296. htmlFontSize: htmlFontSize,
  1297. pxToRem: pxToRem,
  1298. round: round$1,
  1299. // TODO v5: remove
  1300. fontFamily: fontFamily,
  1301. fontSize: fontSize,
  1302. fontWeightLight: fontWeightLight,
  1303. fontWeightRegular: fontWeightRegular,
  1304. fontWeightMedium: fontWeightMedium,
  1305. fontWeightBold: fontWeightBold
  1306. }, variants), other, {
  1307. clone: false // No need to clone deep
  1308.  
  1309. });
  1310. }
  1311.  
  1312. var shadowKeyUmbraOpacity = 0.2;
  1313. var shadowKeyPenumbraOpacity = 0.14;
  1314. var shadowAmbientShadowOpacity = 0.12;
  1315.  
  1316. function createShadow() {
  1317. return ["".concat(arguments.length <= 0 ? undefined : arguments[0], "px ").concat(arguments.length <= 1 ? undefined : arguments[1], "px ").concat(arguments.length <= 2 ? undefined : arguments[2], "px ").concat(arguments.length <= 3 ? undefined : arguments[3], "px rgba(0,0,0,").concat(shadowKeyUmbraOpacity, ")"), "".concat(arguments.length <= 4 ? undefined : arguments[4], "px ").concat(arguments.length <= 5 ? undefined : arguments[5], "px ").concat(arguments.length <= 6 ? undefined : arguments[6], "px ").concat(arguments.length <= 7 ? undefined : arguments[7], "px rgba(0,0,0,").concat(shadowKeyPenumbraOpacity, ")"), "".concat(arguments.length <= 8 ? undefined : arguments[8], "px ").concat(arguments.length <= 9 ? undefined : arguments[9], "px ").concat(arguments.length <= 10 ? undefined : arguments[10], "px ").concat(arguments.length <= 11 ? undefined : arguments[11], "px rgba(0,0,0,").concat(shadowAmbientShadowOpacity, ")")].join(',');
  1318. } // Values from https://github.com/material-components/material-components-web/blob/be8747f94574669cb5e7add1a7c54fa41a89cec7/packages/mdc-elevation/_variables.scss
  1319.  
  1320.  
  1321. var shadows = ['none', createShadow(0, 2, 1, -1, 0, 1, 1, 0, 0, 1, 3, 0), createShadow(0, 3, 1, -2, 0, 2, 2, 0, 0, 1, 5, 0), createShadow(0, 3, 3, -2, 0, 3, 4, 0, 0, 1, 8, 0), createShadow(0, 2, 4, -1, 0, 4, 5, 0, 0, 1, 10, 0), createShadow(0, 3, 5, -1, 0, 5, 8, 0, 0, 1, 14, 0), createShadow(0, 3, 5, -1, 0, 6, 10, 0, 0, 1, 18, 0), createShadow(0, 4, 5, -2, 0, 7, 10, 1, 0, 2, 16, 1), createShadow(0, 5, 5, -3, 0, 8, 10, 1, 0, 3, 14, 2), createShadow(0, 5, 6, -3, 0, 9, 12, 1, 0, 3, 16, 2), createShadow(0, 6, 6, -3, 0, 10, 14, 1, 0, 4, 18, 3), createShadow(0, 6, 7, -4, 0, 11, 15, 1, 0, 4, 20, 3), createShadow(0, 7, 8, -4, 0, 12, 17, 2, 0, 5, 22, 4), createShadow(0, 7, 8, -4, 0, 13, 19, 2, 0, 5, 24, 4), createShadow(0, 7, 9, -4, 0, 14, 21, 2, 0, 5, 26, 4), createShadow(0, 8, 9, -5, 0, 15, 22, 2, 0, 6, 28, 5), createShadow(0, 8, 10, -5, 0, 16, 24, 2, 0, 6, 30, 5), createShadow(0, 8, 11, -5, 0, 17, 26, 2, 0, 6, 32, 5), createShadow(0, 9, 11, -5, 0, 18, 28, 2, 0, 7, 34, 6), createShadow(0, 9, 12, -6, 0, 19, 29, 2, 0, 7, 36, 6), createShadow(0, 10, 13, -6, 0, 20, 31, 3, 0, 8, 38, 7), createShadow(0, 10, 13, -6, 0, 21, 33, 3, 0, 8, 40, 7), createShadow(0, 10, 14, -6, 0, 22, 35, 3, 0, 8, 42, 7), createShadow(0, 11, 14, -7, 0, 23, 36, 3, 0, 9, 44, 8), createShadow(0, 11, 15, -7, 0, 24, 38, 3, 0, 9, 46, 8)];
  1322.  
  1323. var shape = {
  1324. borderRadius: 4
  1325. };
  1326.  
  1327. function _arrayLikeToArray(arr, len) {
  1328. if (len == null || len > arr.length) len = arr.length;
  1329.  
  1330. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  1331. arr2[i] = arr[i];
  1332. }
  1333.  
  1334. return arr2;
  1335. }
  1336.  
  1337. function _arrayWithoutHoles(arr) {
  1338. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  1339. }
  1340.  
  1341. function _iterableToArray(iter) {
  1342. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  1343. }
  1344.  
  1345. function _unsupportedIterableToArray(o, minLen) {
  1346. if (!o) return;
  1347. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  1348. var n = Object.prototype.toString.call(o).slice(8, -1);
  1349. if (n === "Object" && o.constructor) n = o.constructor.name;
  1350. if (n === "Map" || n === "Set") return Array.from(o);
  1351. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  1352. }
  1353.  
  1354. function _nonIterableSpread() {
  1355. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  1356. }
  1357.  
  1358. function _toConsumableArray(arr) {
  1359. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  1360. }
  1361.  
  1362. function merge(acc, item) {
  1363. if (!item) {
  1364. return acc;
  1365. }
  1366.  
  1367. return deepmerge(acc, item, {
  1368. clone: false // No need to clone deep, it's way faster.
  1369.  
  1370. });
  1371. }
  1372.  
  1373. // For instance with the first breakpoint xs: [xs, sm[.
  1374.  
  1375. var values$1 = {
  1376. xs: 0,
  1377. sm: 600,
  1378. md: 960,
  1379. lg: 1280,
  1380. xl: 1920
  1381. };
  1382. var defaultBreakpoints = {
  1383. // Sorted ASC by size. That's important.
  1384. // It can't be configured as it's used statically for propTypes.
  1385. keys: ['xs', 'sm', 'md', 'lg', 'xl'],
  1386. up: function up(key) {
  1387. return "@media (min-width:".concat(values$1[key], "px)");
  1388. }
  1389. };
  1390. function handleBreakpoints(props, propValue, styleFromPropValue) {
  1391.  
  1392. if (Array.isArray(propValue)) {
  1393. var themeBreakpoints = props.theme.breakpoints || defaultBreakpoints;
  1394. return propValue.reduce(function (acc, item, index) {
  1395. acc[themeBreakpoints.up(themeBreakpoints.keys[index])] = styleFromPropValue(propValue[index]);
  1396. return acc;
  1397. }, {});
  1398. }
  1399.  
  1400. if (_typeof$2(propValue) === 'object') {
  1401. var _themeBreakpoints = props.theme.breakpoints || defaultBreakpoints;
  1402.  
  1403. return Object.keys(propValue).reduce(function (acc, breakpoint) {
  1404. acc[_themeBreakpoints.up(breakpoint)] = styleFromPropValue(propValue[breakpoint]);
  1405. return acc;
  1406. }, {});
  1407. }
  1408.  
  1409. var output = styleFromPropValue(propValue);
  1410. return output;
  1411. }
  1412.  
  1413. function getPath(obj, path) {
  1414. if (!path || typeof path !== 'string') {
  1415. return null;
  1416. }
  1417.  
  1418. return path.split('.').reduce(function (acc, item) {
  1419. return acc && acc[item] ? acc[item] : null;
  1420. }, obj);
  1421. }
  1422.  
  1423. function style$1(options) {
  1424. var prop = options.prop,
  1425. _options$cssProperty = options.cssProperty,
  1426. cssProperty = _options$cssProperty === void 0 ? options.prop : _options$cssProperty,
  1427. themeKey = options.themeKey,
  1428. transform = options.transform;
  1429.  
  1430. var fn = function fn(props) {
  1431. if (props[prop] == null) {
  1432. return null;
  1433. }
  1434.  
  1435. var propValue = props[prop];
  1436. var theme = props.theme;
  1437. var themeMapping = getPath(theme, themeKey) || {};
  1438.  
  1439. var styleFromPropValue = function styleFromPropValue(propValueFinal) {
  1440. var value;
  1441.  
  1442. if (typeof themeMapping === 'function') {
  1443. value = themeMapping(propValueFinal);
  1444. } else if (Array.isArray(themeMapping)) {
  1445. value = themeMapping[propValueFinal] || propValueFinal;
  1446. } else {
  1447. value = getPath(themeMapping, propValueFinal) || propValueFinal;
  1448.  
  1449. if (transform) {
  1450. value = transform(value);
  1451. }
  1452. }
  1453.  
  1454. if (cssProperty === false) {
  1455. return value;
  1456. }
  1457.  
  1458. return _defineProperty$1({}, cssProperty, value);
  1459. };
  1460.  
  1461. return handleBreakpoints(props, propValue, styleFromPropValue);
  1462. };
  1463.  
  1464. fn.propTypes = {};
  1465. fn.filterProps = [prop];
  1466. return fn;
  1467. }
  1468.  
  1469. function compose() {
  1470. for (var _len = arguments.length, styles = new Array(_len), _key = 0; _key < _len; _key++) {
  1471. styles[_key] = arguments[_key];
  1472. }
  1473.  
  1474. var fn = function fn(props) {
  1475. return styles.reduce(function (acc, style) {
  1476. var output = style(props);
  1477.  
  1478. if (output) {
  1479. return merge(acc, output);
  1480. }
  1481.  
  1482. return acc;
  1483. }, {});
  1484. }; // Alternative approach that doesn't yield any performance gain.
  1485. // const handlers = styles.reduce((acc, style) => {
  1486. // style.filterProps.forEach(prop => {
  1487. // acc[prop] = style;
  1488. // });
  1489. // return acc;
  1490. // }, {});
  1491. // const fn = props => {
  1492. // return Object.keys(props).reduce((acc, prop) => {
  1493. // if (handlers[prop]) {
  1494. // return merge(acc, handlers[prop](props));
  1495. // }
  1496. // return acc;
  1497. // }, {});
  1498. // };
  1499.  
  1500.  
  1501. fn.propTypes = {};
  1502. fn.filterProps = styles.reduce(function (acc, style) {
  1503. return acc.concat(style.filterProps);
  1504. }, []);
  1505. return fn;
  1506. }
  1507.  
  1508. function getBorder(value) {
  1509. if (typeof value !== 'number') {
  1510. return value;
  1511. }
  1512.  
  1513. return "".concat(value, "px solid");
  1514. }
  1515.  
  1516. var border = style$1({
  1517. prop: 'border',
  1518. themeKey: 'borders',
  1519. transform: getBorder
  1520. });
  1521. var borderTop = style$1({
  1522. prop: 'borderTop',
  1523. themeKey: 'borders',
  1524. transform: getBorder
  1525. });
  1526. var borderRight = style$1({
  1527. prop: 'borderRight',
  1528. themeKey: 'borders',
  1529. transform: getBorder
  1530. });
  1531. var borderBottom = style$1({
  1532. prop: 'borderBottom',
  1533. themeKey: 'borders',
  1534. transform: getBorder
  1535. });
  1536. var borderLeft = style$1({
  1537. prop: 'borderLeft',
  1538. themeKey: 'borders',
  1539. transform: getBorder
  1540. });
  1541. var borderColor = style$1({
  1542. prop: 'borderColor',
  1543. themeKey: 'palette'
  1544. });
  1545. var borderRadius = style$1({
  1546. prop: 'borderRadius',
  1547. themeKey: 'shape'
  1548. });
  1549. var borders = compose(border, borderTop, borderRight, borderBottom, borderLeft, borderColor, borderRadius);
  1550.  
  1551. function omit$1(input, fields) {
  1552. var output = {};
  1553. Object.keys(input).forEach(function (prop) {
  1554. if (fields.indexOf(prop) === -1) {
  1555. output[prop] = input[prop];
  1556. }
  1557. });
  1558. return output;
  1559. }
  1560.  
  1561. function css$1(styleFunction) {
  1562. var newStyleFunction = function newStyleFunction(props) {
  1563. var output = styleFunction(props);
  1564.  
  1565. if (props.css) {
  1566. return _extends$1({}, merge(output, styleFunction(_extends$1({
  1567. theme: props.theme
  1568. }, props.css))), omit$1(props.css, [styleFunction.filterProps]));
  1569. }
  1570.  
  1571. return output;
  1572. };
  1573.  
  1574. newStyleFunction.propTypes = {};
  1575. newStyleFunction.filterProps = ['css'].concat(_toConsumableArray(styleFunction.filterProps));
  1576. return newStyleFunction;
  1577. }
  1578.  
  1579. var displayPrint = style$1({
  1580. prop: 'displayPrint',
  1581. cssProperty: false,
  1582. transform: function transform(value) {
  1583. return {
  1584. '@media print': {
  1585. display: value
  1586. }
  1587. };
  1588. }
  1589. });
  1590. var displayRaw = style$1({
  1591. prop: 'display'
  1592. });
  1593. var overflow = style$1({
  1594. prop: 'overflow'
  1595. });
  1596. var textOverflow = style$1({
  1597. prop: 'textOverflow'
  1598. });
  1599. var visibility = style$1({
  1600. prop: 'visibility'
  1601. });
  1602. var whiteSpace = style$1({
  1603. prop: 'whiteSpace'
  1604. });
  1605. var display = compose(displayPrint, displayRaw, overflow, textOverflow, visibility, whiteSpace);
  1606.  
  1607. var flexBasis = style$1({
  1608. prop: 'flexBasis'
  1609. });
  1610. var flexDirection = style$1({
  1611. prop: 'flexDirection'
  1612. });
  1613. var flexWrap = style$1({
  1614. prop: 'flexWrap'
  1615. });
  1616. var justifyContent = style$1({
  1617. prop: 'justifyContent'
  1618. });
  1619. var alignItems = style$1({
  1620. prop: 'alignItems'
  1621. });
  1622. var alignContent = style$1({
  1623. prop: 'alignContent'
  1624. });
  1625. var order = style$1({
  1626. prop: 'order'
  1627. });
  1628. var flex = style$1({
  1629. prop: 'flex'
  1630. });
  1631. var flexGrow = style$1({
  1632. prop: 'flexGrow'
  1633. });
  1634. var flexShrink = style$1({
  1635. prop: 'flexShrink'
  1636. });
  1637. var alignSelf = style$1({
  1638. prop: 'alignSelf'
  1639. });
  1640. var justifyItems = style$1({
  1641. prop: 'justifyItems'
  1642. });
  1643. var justifySelf = style$1({
  1644. prop: 'justifySelf'
  1645. });
  1646. var flexbox = compose(flexBasis, flexDirection, flexWrap, justifyContent, alignItems, alignContent, order, flex, flexGrow, flexShrink, alignSelf, justifyItems, justifySelf);
  1647.  
  1648. var gridGap = style$1({
  1649. prop: 'gridGap'
  1650. });
  1651. var gridColumnGap = style$1({
  1652. prop: 'gridColumnGap'
  1653. });
  1654. var gridRowGap = style$1({
  1655. prop: 'gridRowGap'
  1656. });
  1657. var gridColumn = style$1({
  1658. prop: 'gridColumn'
  1659. });
  1660. var gridRow = style$1({
  1661. prop: 'gridRow'
  1662. });
  1663. var gridAutoFlow = style$1({
  1664. prop: 'gridAutoFlow'
  1665. });
  1666. var gridAutoColumns = style$1({
  1667. prop: 'gridAutoColumns'
  1668. });
  1669. var gridAutoRows = style$1({
  1670. prop: 'gridAutoRows'
  1671. });
  1672. var gridTemplateColumns = style$1({
  1673. prop: 'gridTemplateColumns'
  1674. });
  1675. var gridTemplateRows = style$1({
  1676. prop: 'gridTemplateRows'
  1677. });
  1678. var gridTemplateAreas = style$1({
  1679. prop: 'gridTemplateAreas'
  1680. });
  1681. var gridArea = style$1({
  1682. prop: 'gridArea'
  1683. });
  1684. var grid = compose(gridGap, gridColumnGap, gridRowGap, gridColumn, gridRow, gridAutoFlow, gridAutoColumns, gridAutoRows, gridTemplateColumns, gridTemplateRows, gridTemplateAreas, gridArea);
  1685.  
  1686. var color = style$1({
  1687. prop: 'color',
  1688. themeKey: 'palette'
  1689. });
  1690. var bgcolor = style$1({
  1691. prop: 'bgcolor',
  1692. cssProperty: 'backgroundColor',
  1693. themeKey: 'palette'
  1694. });
  1695. var palette = compose(color, bgcolor);
  1696.  
  1697. var position = style$1({
  1698. prop: 'position'
  1699. });
  1700. var zIndex$1 = style$1({
  1701. prop: 'zIndex',
  1702. themeKey: 'zIndex'
  1703. });
  1704. var top = style$1({
  1705. prop: 'top'
  1706. });
  1707. var right = style$1({
  1708. prop: 'right'
  1709. });
  1710. var bottom = style$1({
  1711. prop: 'bottom'
  1712. });
  1713. var left = style$1({
  1714. prop: 'left'
  1715. });
  1716. var positions = compose(position, zIndex$1, top, right, bottom, left);
  1717.  
  1718. var boxShadow = style$1({
  1719. prop: 'boxShadow',
  1720. themeKey: 'shadows'
  1721. });
  1722.  
  1723. function transform$1(value) {
  1724. return value <= 1 ? "".concat(value * 100, "%") : value;
  1725. }
  1726.  
  1727. var width = style$1({
  1728. prop: 'width',
  1729. transform: transform$1
  1730. });
  1731. var maxWidth = style$1({
  1732. prop: 'maxWidth',
  1733. transform: transform$1
  1734. });
  1735. var minWidth = style$1({
  1736. prop: 'minWidth',
  1737. transform: transform$1
  1738. });
  1739. var height = style$1({
  1740. prop: 'height',
  1741. transform: transform$1
  1742. });
  1743. var maxHeight = style$1({
  1744. prop: 'maxHeight',
  1745. transform: transform$1
  1746. });
  1747. var minHeight = style$1({
  1748. prop: 'minHeight',
  1749. transform: transform$1
  1750. });
  1751. style$1({
  1752. prop: 'size',
  1753. cssProperty: 'width',
  1754. transform: transform$1
  1755. });
  1756. style$1({
  1757. prop: 'size',
  1758. cssProperty: 'height',
  1759. transform: transform$1
  1760. });
  1761. var boxSizing = style$1({
  1762. prop: 'boxSizing'
  1763. });
  1764. var sizing = compose(width, maxWidth, minWidth, height, maxHeight, minHeight, boxSizing);
  1765.  
  1766. function _arrayWithHoles(arr) {
  1767. if (Array.isArray(arr)) return arr;
  1768. }
  1769.  
  1770. function _iterableToArrayLimit(arr, i) {
  1771. var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]);
  1772.  
  1773. if (_i == null) return;
  1774. var _arr = [];
  1775. var _n = true;
  1776. var _d = false;
  1777.  
  1778. var _s, _e;
  1779.  
  1780. try {
  1781. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  1782. _arr.push(_s.value);
  1783.  
  1784. if (i && _arr.length === i) break;
  1785. }
  1786. } catch (err) {
  1787. _d = true;
  1788. _e = err;
  1789. } finally {
  1790. try {
  1791. if (!_n && _i["return"] != null) _i["return"]();
  1792. } finally {
  1793. if (_d) throw _e;
  1794. }
  1795. }
  1796.  
  1797. return _arr;
  1798. }
  1799.  
  1800. function _nonIterableRest() {
  1801. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  1802. }
  1803.  
  1804. function _slicedToArray(arr, i) {
  1805. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  1806. }
  1807.  
  1808. function memoize$1(fn) {
  1809. var cache = {};
  1810. return function (arg) {
  1811. if (cache[arg] === undefined) {
  1812. cache[arg] = fn(arg);
  1813. }
  1814.  
  1815. return cache[arg];
  1816. };
  1817. }
  1818.  
  1819. var properties = {
  1820. m: 'margin',
  1821. p: 'padding'
  1822. };
  1823. var directions = {
  1824. t: 'Top',
  1825. r: 'Right',
  1826. b: 'Bottom',
  1827. l: 'Left',
  1828. x: ['Left', 'Right'],
  1829. y: ['Top', 'Bottom']
  1830. };
  1831. var aliases = {
  1832. marginX: 'mx',
  1833. marginY: 'my',
  1834. paddingX: 'px',
  1835. paddingY: 'py'
  1836. }; // memoize() impact:
  1837. // From 300,000 ops/sec
  1838. // To 350,000 ops/sec
  1839.  
  1840. var getCssProperties = memoize$1(function (prop) {
  1841. // It's not a shorthand notation.
  1842. if (prop.length > 2) {
  1843. if (aliases[prop]) {
  1844. prop = aliases[prop];
  1845. } else {
  1846. return [prop];
  1847. }
  1848. }
  1849.  
  1850. var _prop$split = prop.split(''),
  1851. _prop$split2 = _slicedToArray(_prop$split, 2),
  1852. a = _prop$split2[0],
  1853. b = _prop$split2[1];
  1854.  
  1855. var property = properties[a];
  1856. var direction = directions[b] || '';
  1857. return Array.isArray(direction) ? direction.map(function (dir) {
  1858. return property + dir;
  1859. }) : [property + direction];
  1860. });
  1861. var spacingKeys = ['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginX', 'marginY', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingX', 'paddingY'];
  1862. function createUnarySpacing(theme) {
  1863. var themeSpacing = theme.spacing || 8;
  1864.  
  1865. if (typeof themeSpacing === 'number') {
  1866. return function (abs) {
  1867.  
  1868. return themeSpacing * abs;
  1869. };
  1870. }
  1871.  
  1872. if (Array.isArray(themeSpacing)) {
  1873. return function (abs) {
  1874.  
  1875. return themeSpacing[abs];
  1876. };
  1877. }
  1878.  
  1879. if (typeof themeSpacing === 'function') {
  1880. return themeSpacing;
  1881. }
  1882.  
  1883. return function () {
  1884. return undefined;
  1885. };
  1886. }
  1887.  
  1888. function getValue(transformer, propValue) {
  1889. if (typeof propValue === 'string' || propValue == null) {
  1890. return propValue;
  1891. }
  1892.  
  1893. var abs = Math.abs(propValue);
  1894. var transformed = transformer(abs);
  1895.  
  1896. if (propValue >= 0) {
  1897. return transformed;
  1898. }
  1899.  
  1900. if (typeof transformed === 'number') {
  1901. return -transformed;
  1902. }
  1903.  
  1904. return "-".concat(transformed);
  1905. }
  1906.  
  1907. function getStyleFromPropValue(cssProperties, transformer) {
  1908. return function (propValue) {
  1909. return cssProperties.reduce(function (acc, cssProperty) {
  1910. acc[cssProperty] = getValue(transformer, propValue);
  1911. return acc;
  1912. }, {});
  1913. };
  1914. }
  1915.  
  1916. function spacing(props) {
  1917. var theme = props.theme;
  1918. var transformer = createUnarySpacing(theme);
  1919. return Object.keys(props).map(function (prop) {
  1920. // Using a hash computation over an array iteration could be faster, but with only 28 items,
  1921. // it's doesn't worth the bundle size.
  1922. if (spacingKeys.indexOf(prop) === -1) {
  1923. return null;
  1924. }
  1925.  
  1926. var cssProperties = getCssProperties(prop);
  1927. var styleFromPropValue = getStyleFromPropValue(cssProperties, transformer);
  1928. var propValue = props[prop];
  1929. return handleBreakpoints(props, propValue, styleFromPropValue);
  1930. }).reduce(merge, {});
  1931. }
  1932.  
  1933. spacing.propTypes = {};
  1934. spacing.filterProps = spacingKeys;
  1935.  
  1936. var fontFamily = style$1({
  1937. prop: 'fontFamily',
  1938. themeKey: 'typography'
  1939. });
  1940. var fontSize = style$1({
  1941. prop: 'fontSize',
  1942. themeKey: 'typography'
  1943. });
  1944. var fontStyle = style$1({
  1945. prop: 'fontStyle',
  1946. themeKey: 'typography'
  1947. });
  1948. var fontWeight = style$1({
  1949. prop: 'fontWeight',
  1950. themeKey: 'typography'
  1951. });
  1952. var letterSpacing = style$1({
  1953. prop: 'letterSpacing'
  1954. });
  1955. var lineHeight = style$1({
  1956. prop: 'lineHeight'
  1957. });
  1958. var textAlign = style$1({
  1959. prop: 'textAlign'
  1960. });
  1961. var typography = compose(fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textAlign);
  1962.  
  1963. function createSpacing() {
  1964. var spacingInput = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 8; // Already transformed.
  1965.  
  1966. if (spacingInput.mui) {
  1967. return spacingInput;
  1968. } // Material Design layouts are visually balanced. Most measurements align to an 8dp grid applied, which aligns both spacing and the overall layout.
  1969. // Smaller components, such as icons and type, can align to a 4dp grid.
  1970. // https://material.io/design/layout/understanding-layout.html#usage
  1971.  
  1972.  
  1973. var transform = createUnarySpacing({
  1974. spacing: spacingInput
  1975. });
  1976.  
  1977. var spacing = function spacing() {
  1978. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1979. args[_key] = arguments[_key];
  1980. }
  1981.  
  1982. if (args.length === 0) {
  1983. return transform(1);
  1984. }
  1985.  
  1986. if (args.length === 1) {
  1987. return transform(args[0]);
  1988. }
  1989.  
  1990. return args.map(function (argument) {
  1991. if (typeof argument === 'string') {
  1992. return argument;
  1993. }
  1994.  
  1995. var output = transform(argument);
  1996. return typeof output === 'number' ? "".concat(output, "px") : output;
  1997. }).join(' ');
  1998. }; // Backward compatibility, to remove in v5.
  1999.  
  2000.  
  2001. Object.defineProperty(spacing, 'unit', {
  2002. get: function get() {
  2003.  
  2004. return spacingInput;
  2005. }
  2006. });
  2007. spacing.mui = true;
  2008. return spacing;
  2009. }
  2010.  
  2011. // to learn the context in which each easing should be used.
  2012.  
  2013. var easing = {
  2014. // This is the most common easing curve.
  2015. easeInOut: 'cubic-bezier(0.4, 0, 0.2, 1)',
  2016. // Objects enter the screen at full velocity from off-screen and
  2017. // slowly decelerate to a resting point.
  2018. easeOut: 'cubic-bezier(0.0, 0, 0.2, 1)',
  2019. // Objects leave the screen at full velocity. They do not decelerate when off-screen.
  2020. easeIn: 'cubic-bezier(0.4, 0, 1, 1)',
  2021. // The sharp curve is used by objects that may return to the screen at any time.
  2022. sharp: 'cubic-bezier(0.4, 0, 0.6, 1)'
  2023. }; // Follow https://material.io/guidelines/motion/duration-easing.html#duration-easing-common-durations
  2024. // to learn when use what timing
  2025.  
  2026. var duration = {
  2027. shortest: 150,
  2028. shorter: 200,
  2029. short: 250,
  2030. // most basic recommended timing
  2031. standard: 300,
  2032. // this is to be used in complex animations
  2033. complex: 375,
  2034. // recommended when something is entering screen
  2035. enteringScreen: 225,
  2036. // recommended when something is leaving screen
  2037. leavingScreen: 195
  2038. };
  2039.  
  2040. function formatMs(milliseconds) {
  2041. return "".concat(Math.round(milliseconds), "ms");
  2042. }
  2043. /**
  2044. * @param {string|Array} props
  2045. * @param {object} param
  2046. * @param {string} param.prop
  2047. * @param {number} param.duration
  2048. * @param {string} param.easing
  2049. * @param {number} param.delay
  2050. */
  2051.  
  2052.  
  2053. var transitions = {
  2054. easing: easing,
  2055. duration: duration,
  2056. create: function create() {
  2057. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['all'];
  2058. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2059.  
  2060. var _options$duration = options.duration,
  2061. durationOption = _options$duration === void 0 ? duration.standard : _options$duration,
  2062. _options$easing = options.easing,
  2063. easingOption = _options$easing === void 0 ? easing.easeInOut : _options$easing,
  2064. _options$delay = options.delay,
  2065. delay = _options$delay === void 0 ? 0 : _options$delay;
  2066. _objectWithoutProperties(options, ["duration", "easing", "delay"]);
  2067.  
  2068. return (Array.isArray(props) ? props : [props]).map(function (animatedProp) {
  2069. return "".concat(animatedProp, " ").concat(typeof durationOption === 'string' ? durationOption : formatMs(durationOption), " ").concat(easingOption, " ").concat(typeof delay === 'string' ? delay : formatMs(delay));
  2070. }).join(',');
  2071. },
  2072. getAutoHeightDuration: function getAutoHeightDuration(height) {
  2073. if (!height) {
  2074. return 0;
  2075. }
  2076.  
  2077. var constant = height / 36; // https://www.wolframalpha.com/input/?i=(4+%2B+15+*+(x+%2F+36+)+**+0.25+%2B+(x+%2F+36)+%2F+5)+*+10
  2078.  
  2079. return Math.round((4 + 15 * Math.pow(constant, 0.25) + constant / 5) * 10);
  2080. }
  2081. };
  2082.  
  2083. // We need to centralize the zIndex definitions as they work
  2084. // like global values in the browser.
  2085. var zIndex = {
  2086. mobileStepper: 1000,
  2087. speedDial: 1050,
  2088. appBar: 1100,
  2089. drawer: 1200,
  2090. modal: 1300,
  2091. snackbar: 1400,
  2092. tooltip: 1500
  2093. };
  2094.  
  2095. function createMuiTheme() {
  2096. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2097.  
  2098. var _options$breakpoints = options.breakpoints,
  2099. breakpointsInput = _options$breakpoints === void 0 ? {} : _options$breakpoints,
  2100. _options$mixins = options.mixins,
  2101. mixinsInput = _options$mixins === void 0 ? {} : _options$mixins,
  2102. _options$palette = options.palette,
  2103. paletteInput = _options$palette === void 0 ? {} : _options$palette,
  2104. spacingInput = options.spacing,
  2105. _options$typography = options.typography,
  2106. typographyInput = _options$typography === void 0 ? {} : _options$typography,
  2107. other = _objectWithoutProperties(options, ["breakpoints", "mixins", "palette", "spacing", "typography"]);
  2108.  
  2109. var palette = createPalette(paletteInput);
  2110. var breakpoints = createBreakpoints(breakpointsInput);
  2111. var spacing = createSpacing(spacingInput);
  2112. var muiTheme = deepmerge({
  2113. breakpoints: breakpoints,
  2114. direction: 'ltr',
  2115. mixins: createMixins(breakpoints, spacing, mixinsInput),
  2116. overrides: {},
  2117. // Inject custom styles
  2118. palette: palette,
  2119. props: {},
  2120. // Provide default props
  2121. shadows: shadows,
  2122. typography: createTypography(palette, typographyInput),
  2123. spacing: spacing,
  2124. shape: shape,
  2125. transitions: transitions,
  2126. zIndex: zIndex
  2127. }, other);
  2128.  
  2129. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  2130. args[_key - 1] = arguments[_key];
  2131. }
  2132.  
  2133. muiTheme = args.reduce(function (acc, argument) {
  2134. return deepmerge(acc, argument);
  2135. }, muiTheme);
  2136.  
  2137. return muiTheme;
  2138. }
  2139.  
  2140. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  2141. var nested = hasSymbol ? Symbol.for('mui.nested') : '__THEME_NESTED__';
  2142.  
  2143. /**
  2144. * This is the list of the style rule name we use as drop in replacement for the built-in
  2145. * pseudo classes (:checked, :disabled, :focused, etc.).
  2146. *
  2147. * Why do they exist in the first place?
  2148. * These classes are used at a specificity of 2.
  2149. * It allows them to override previously definied styles as well as
  2150. * being untouched by simple user overrides.
  2151. */
  2152.  
  2153. var pseudoClasses = ['checked', 'disabled', 'error', 'focused', 'focusVisible', 'required', 'expanded', 'selected']; // Returns a function which generates unique class names based on counters.
  2154. // When new generator function is created, rule counter is reset.
  2155. // We need to reset the rule counter for SSR for each request.
  2156. //
  2157. // It's inspired by
  2158. // https://github.com/cssinjs/jss/blob/4e6a05dd3f7b6572fdd3ab216861d9e446c20331/src/utils/createGenerateClassName.js
  2159.  
  2160. function createGenerateClassName() {
  2161. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2162. var _options$disableGloba = options.disableGlobal,
  2163. disableGlobal = _options$disableGloba === void 0 ? false : _options$disableGloba,
  2164. _options$productionPr = options.productionPrefix,
  2165. productionPrefix = _options$productionPr === void 0 ? 'jss' : _options$productionPr,
  2166. _options$seed = options.seed,
  2167. seed = _options$seed === void 0 ? '' : _options$seed;
  2168. var seedPrefix = seed === '' ? '' : "".concat(seed, "-");
  2169. var ruleCounter = 0;
  2170.  
  2171. var getNextCounterId = function getNextCounterId() {
  2172. ruleCounter += 1;
  2173.  
  2174. return ruleCounter;
  2175. };
  2176.  
  2177. return function (rule, styleSheet) {
  2178. var name = styleSheet.options.name; // Is a global static MUI style?
  2179.  
  2180. if (name && name.indexOf('Mui') === 0 && !styleSheet.options.link && !disableGlobal) {
  2181. // We can use a shorthand class name, we never use the keys to style the components.
  2182. if (pseudoClasses.indexOf(rule.key) !== -1) {
  2183. return "Mui-".concat(rule.key);
  2184. }
  2185.  
  2186. var prefix = "".concat(seedPrefix).concat(name, "-").concat(rule.key);
  2187.  
  2188. if (!styleSheet.options.theme[nested] || seed !== '') {
  2189. return prefix;
  2190. }
  2191.  
  2192. return "".concat(prefix, "-").concat(getNextCounterId());
  2193. }
  2194.  
  2195. {
  2196. return "".concat(seedPrefix).concat(productionPrefix).concat(getNextCounterId());
  2197. }
  2198. };
  2199. }
  2200.  
  2201. function createStyles$1(styles) {
  2202. return styles;
  2203. }
  2204.  
  2205. /* eslint-disable no-restricted-syntax */
  2206. function getThemeProps(params) {
  2207. var theme = params.theme,
  2208. name = params.name,
  2209. props = params.props;
  2210.  
  2211. if (!theme || !theme.props || !theme.props[name]) {
  2212. return props;
  2213. } // Resolve default props, code borrow from React source.
  2214. // https://github.com/facebook/react/blob/15a8f031838a553e41c0b66eb1bcf1da8448104d/packages/react/src/ReactElement.js#L221
  2215.  
  2216.  
  2217. var defaultProps = theme.props[name];
  2218. var propName;
  2219.  
  2220. for (propName in defaultProps) {
  2221. if (props[propName] === undefined) {
  2222. props[propName] = defaultProps[propName];
  2223. }
  2224. }
  2225.  
  2226. return props;
  2227. }
  2228.  
  2229. var _typeof$1 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
  2230. return typeof obj;
  2231. } : function (obj) {
  2232. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  2233. };
  2234.  
  2235. var isBrowser$1 = (typeof window === "undefined" ? "undefined" : _typeof$1(window)) === "object" && (typeof document === "undefined" ? "undefined" : _typeof$1(document)) === 'object' && document.nodeType === 9;
  2236.  
  2237. function _defineProperties(target, props) {
  2238. for (var i = 0; i < props.length; i++) {
  2239. var descriptor = props[i];
  2240. descriptor.enumerable = descriptor.enumerable || false;
  2241. descriptor.configurable = true;
  2242. if ("value" in descriptor) descriptor.writable = true;
  2243. Object.defineProperty(target, descriptor.key, descriptor);
  2244. }
  2245. }
  2246.  
  2247. function _createClass(Constructor, protoProps, staticProps) {
  2248. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  2249. if (staticProps) _defineProperties(Constructor, staticProps);
  2250. return Constructor;
  2251. }
  2252.  
  2253. function _setPrototypeOf(o, p) {
  2254. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  2255. o.__proto__ = p;
  2256. return o;
  2257. };
  2258.  
  2259. return _setPrototypeOf(o, p);
  2260. }
  2261.  
  2262. function _inheritsLoose(subClass, superClass) {
  2263. subClass.prototype = Object.create(superClass.prototype);
  2264. subClass.prototype.constructor = subClass;
  2265. _setPrototypeOf(subClass, superClass);
  2266. }
  2267.  
  2268. function _assertThisInitialized(self) {
  2269. if (self === void 0) {
  2270. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  2271. }
  2272.  
  2273. return self;
  2274. }
  2275.  
  2276. var plainObjectConstrurctor = {}.constructor;
  2277.  
  2278. function cloneStyle(style) {
  2279. if (style == null || typeof style !== 'object') return style;
  2280. if (Array.isArray(style)) return style.map(cloneStyle);
  2281. if (style.constructor !== plainObjectConstrurctor) return style;
  2282. var newStyle = {};
  2283.  
  2284. for (var name in style) {
  2285. newStyle[name] = cloneStyle(style[name]);
  2286. }
  2287.  
  2288. return newStyle;
  2289. }
  2290. /**
  2291. * Create a rule instance.
  2292. */
  2293.  
  2294.  
  2295. function createRule(name, decl, options) {
  2296. if (name === void 0) {
  2297. name = 'unnamed';
  2298. }
  2299.  
  2300. var jss = options.jss;
  2301. var declCopy = cloneStyle(decl);
  2302. var rule = jss.plugins.onCreateRule(name, declCopy, options);
  2303. if (rule) return rule; // It is an at-rule and it has no instance.
  2304.  
  2305. if (name[0] === '@') ;
  2306.  
  2307. return null;
  2308. }
  2309.  
  2310. var join = function join(value, by) {
  2311. var result = '';
  2312.  
  2313. for (var i = 0; i < value.length; i++) {
  2314. // Remove !important from the value, it will be readded later.
  2315. if (value[i] === '!important') break;
  2316. if (result) result += by;
  2317. result += value[i];
  2318. }
  2319.  
  2320. return result;
  2321. };
  2322. /**
  2323. * Converts array values to string.
  2324. *
  2325. * `margin: [['5px', '10px']]` > `margin: 5px 10px;`
  2326. * `border: ['1px', '2px']` > `border: 1px, 2px;`
  2327. * `margin: [['5px', '10px'], '!important']` > `margin: 5px 10px !important;`
  2328. * `color: ['red', !important]` > `color: red !important;`
  2329. */
  2330.  
  2331.  
  2332. var toCssValue = function toCssValue(value, ignoreImportant) {
  2333. if (ignoreImportant === void 0) {
  2334. ignoreImportant = false;
  2335. }
  2336.  
  2337. if (!Array.isArray(value)) return value;
  2338. var cssValue = ''; // Support space separated values via `[['5px', '10px']]`.
  2339.  
  2340. if (Array.isArray(value[0])) {
  2341. for (var i = 0; i < value.length; i++) {
  2342. if (value[i] === '!important') break;
  2343. if (cssValue) cssValue += ', ';
  2344. cssValue += join(value[i], ' ');
  2345. }
  2346. } else cssValue = join(value, ', '); // Add !important, because it was ignored.
  2347.  
  2348.  
  2349. if (!ignoreImportant && value[value.length - 1] === '!important') {
  2350. cssValue += ' !important';
  2351. }
  2352.  
  2353. return cssValue;
  2354. };
  2355. /**
  2356. * Indent a string.
  2357. * http://jsperf.com/array-join-vs-for
  2358. */
  2359.  
  2360.  
  2361. function indentStr(str, indent) {
  2362. var result = '';
  2363.  
  2364. for (var index = 0; index < indent; index++) {
  2365. result += ' ';
  2366. }
  2367.  
  2368. return result + str;
  2369. }
  2370. /**
  2371. * Converts a Rule to CSS string.
  2372. */
  2373.  
  2374.  
  2375. function toCss(selector, style, options) {
  2376. if (options === void 0) {
  2377. options = {};
  2378. }
  2379.  
  2380. var result = '';
  2381. if (!style) return result;
  2382. var _options = options,
  2383. _options$indent = _options.indent,
  2384. indent = _options$indent === void 0 ? 0 : _options$indent;
  2385. var fallbacks = style.fallbacks;
  2386. if (selector) indent++; // Apply fallbacks first.
  2387.  
  2388. if (fallbacks) {
  2389. // Array syntax {fallbacks: [{prop: value}]}
  2390. if (Array.isArray(fallbacks)) {
  2391. for (var index = 0; index < fallbacks.length; index++) {
  2392. var fallback = fallbacks[index];
  2393.  
  2394. for (var prop in fallback) {
  2395. var value = fallback[prop];
  2396.  
  2397. if (value != null) {
  2398. if (result) result += '\n';
  2399. result += "" + indentStr(prop + ": " + toCssValue(value) + ";", indent);
  2400. }
  2401. }
  2402. }
  2403. } else {
  2404. // Object syntax {fallbacks: {prop: value}}
  2405. for (var _prop in fallbacks) {
  2406. var _value = fallbacks[_prop];
  2407.  
  2408. if (_value != null) {
  2409. if (result) result += '\n';
  2410. result += "" + indentStr(_prop + ": " + toCssValue(_value) + ";", indent);
  2411. }
  2412. }
  2413. }
  2414. }
  2415.  
  2416. for (var _prop2 in style) {
  2417. var _value2 = style[_prop2];
  2418.  
  2419. if (_value2 != null && _prop2 !== 'fallbacks') {
  2420. if (result) result += '\n';
  2421. result += "" + indentStr(_prop2 + ": " + toCssValue(_value2) + ";", indent);
  2422. }
  2423. } // Allow empty style in this case, because properties will be added dynamically.
  2424.  
  2425.  
  2426. if (!result && !options.allowEmpty) return result; // When rule is being stringified before selector was defined.
  2427.  
  2428. if (!selector) return result;
  2429. indent--;
  2430. if (result) result = "\n" + result + "\n";
  2431. return indentStr(selector + " {" + result, indent) + indentStr('}', indent);
  2432. }
  2433.  
  2434. var escapeRegex = /([[\].#*$><+~=|^:(),"'`\s])/g;
  2435. var nativeEscape = typeof CSS !== 'undefined' && CSS.escape;
  2436.  
  2437. var escape = function (str) {
  2438. return nativeEscape ? nativeEscape(str) : str.replace(escapeRegex, '\\$1');
  2439. };
  2440.  
  2441. var BaseStyleRule = /*#__PURE__*/function () {
  2442. function BaseStyleRule(key, style, options) {
  2443. this.type = 'style';
  2444. this.key = void 0;
  2445. this.isProcessed = false;
  2446. this.style = void 0;
  2447. this.renderer = void 0;
  2448. this.renderable = void 0;
  2449. this.options = void 0;
  2450. var sheet = options.sheet,
  2451. Renderer = options.Renderer;
  2452. this.key = key;
  2453. this.options = options;
  2454. this.style = style;
  2455. if (sheet) this.renderer = sheet.renderer;else if (Renderer) this.renderer = new Renderer();
  2456. }
  2457. /**
  2458. * Get or set a style property.
  2459. */
  2460.  
  2461.  
  2462. var _proto = BaseStyleRule.prototype;
  2463.  
  2464. _proto.prop = function prop(name, value, options) {
  2465. // It's a getter.
  2466. if (value === undefined) return this.style[name]; // Don't do anything if the value has not changed.
  2467.  
  2468. var force = options ? options.force : false;
  2469. if (!force && this.style[name] === value) return this;
  2470. var newValue = value;
  2471.  
  2472. if (!options || options.process !== false) {
  2473. newValue = this.options.jss.plugins.onChangeValue(value, name, this);
  2474. }
  2475.  
  2476. var isEmpty = newValue == null || newValue === false;
  2477. var isDefined = (name in this.style); // Value is empty and wasn't defined before.
  2478.  
  2479. if (isEmpty && !isDefined && !force) return this; // We are going to remove this value.
  2480.  
  2481. var remove = isEmpty && isDefined;
  2482. if (remove) delete this.style[name];else this.style[name] = newValue; // Renderable is defined if StyleSheet option `link` is true.
  2483.  
  2484. if (this.renderable && this.renderer) {
  2485. if (remove) this.renderer.removeProperty(this.renderable, name);else this.renderer.setProperty(this.renderable, name, newValue);
  2486. return this;
  2487. }
  2488.  
  2489. var sheet = this.options.sheet;
  2490.  
  2491. if (sheet && sheet.attached) ;
  2492.  
  2493. return this;
  2494. };
  2495.  
  2496. return BaseStyleRule;
  2497. }();
  2498.  
  2499. var StyleRule = /*#__PURE__*/function (_BaseStyleRule) {
  2500. _inheritsLoose(StyleRule, _BaseStyleRule);
  2501.  
  2502. function StyleRule(key, style, options) {
  2503. var _this;
  2504.  
  2505. _this = _BaseStyleRule.call(this, key, style, options) || this;
  2506. _this.selectorText = void 0;
  2507. _this.id = void 0;
  2508. _this.renderable = void 0;
  2509. var selector = options.selector,
  2510. scoped = options.scoped,
  2511. sheet = options.sheet,
  2512. generateId = options.generateId;
  2513.  
  2514. if (selector) {
  2515. _this.selectorText = selector;
  2516. } else if (scoped !== false) {
  2517. _this.id = generateId(_assertThisInitialized(_assertThisInitialized(_this)), sheet);
  2518. _this.selectorText = "." + escape(_this.id);
  2519. }
  2520.  
  2521. return _this;
  2522. }
  2523. /**
  2524. * Set selector string.
  2525. * Attention: use this with caution. Most browsers didn't implement
  2526. * selectorText setter, so this may result in rerendering of entire Style Sheet.
  2527. */
  2528.  
  2529.  
  2530. var _proto2 = StyleRule.prototype;
  2531. /**
  2532. * Apply rule to an element inline.
  2533. */
  2534.  
  2535. _proto2.applyTo = function applyTo(renderable) {
  2536. var renderer = this.renderer;
  2537.  
  2538. if (renderer) {
  2539. var json = this.toJSON();
  2540.  
  2541. for (var prop in json) {
  2542. renderer.setProperty(renderable, prop, json[prop]);
  2543. }
  2544. }
  2545.  
  2546. return this;
  2547. }
  2548. /**
  2549. * Returns JSON representation of the rule.
  2550. * Fallbacks are not supported.
  2551. * Useful for inline styles.
  2552. */
  2553. ;
  2554.  
  2555. _proto2.toJSON = function toJSON() {
  2556. var json = {};
  2557.  
  2558. for (var prop in this.style) {
  2559. var value = this.style[prop];
  2560. if (typeof value !== 'object') json[prop] = value;else if (Array.isArray(value)) json[prop] = toCssValue(value);
  2561. }
  2562.  
  2563. return json;
  2564. }
  2565. /**
  2566. * Generates a CSS string.
  2567. */
  2568. ;
  2569.  
  2570. _proto2.toString = function toString(options) {
  2571. var sheet = this.options.sheet;
  2572. var link = sheet ? sheet.options.link : false;
  2573. var opts = link ? _extends$1({}, options, {
  2574. allowEmpty: true
  2575. }) : options;
  2576. return toCss(this.selectorText, this.style, opts);
  2577. };
  2578.  
  2579. _createClass(StyleRule, [{
  2580. key: "selector",
  2581. set: function set(selector) {
  2582. if (selector === this.selectorText) return;
  2583. this.selectorText = selector;
  2584. var renderer = this.renderer,
  2585. renderable = this.renderable;
  2586. if (!renderable || !renderer) return;
  2587. var hasChanged = renderer.setSelector(renderable, selector); // If selector setter is not implemented, rerender the rule.
  2588.  
  2589. if (!hasChanged) {
  2590. renderer.replaceRule(renderable, this);
  2591. }
  2592. }
  2593. /**
  2594. * Get selector string.
  2595. */
  2596. ,
  2597. get: function get() {
  2598. return this.selectorText;
  2599. }
  2600. }]);
  2601.  
  2602. return StyleRule;
  2603. }(BaseStyleRule);
  2604.  
  2605. var pluginStyleRule = {
  2606. onCreateRule: function onCreateRule(name, style, options) {
  2607. if (name[0] === '@' || options.parent && options.parent.type === 'keyframes') {
  2608. return null;
  2609. }
  2610.  
  2611. return new StyleRule(name, style, options);
  2612. }
  2613. };
  2614. var defaultToStringOptions = {
  2615. indent: 1,
  2616. children: true
  2617. };
  2618. var atRegExp = /@([\w-]+)/;
  2619. /**
  2620. * Conditional rule for @media, @supports
  2621. */
  2622.  
  2623. var ConditionalRule = /*#__PURE__*/function () {
  2624. function ConditionalRule(key, styles, options) {
  2625. this.type = 'conditional';
  2626. this.at = void 0;
  2627. this.key = void 0;
  2628. this.query = void 0;
  2629. this.rules = void 0;
  2630. this.options = void 0;
  2631. this.isProcessed = false;
  2632. this.renderable = void 0;
  2633. this.key = key;
  2634. var atMatch = key.match(atRegExp);
  2635. this.at = atMatch ? atMatch[1] : 'unknown'; // Key might contain a unique suffix in case the `name` passed by user was duplicate.
  2636.  
  2637. this.query = options.name || "@" + this.at;
  2638. this.options = options;
  2639. this.rules = new RuleList(_extends$1({}, options, {
  2640. parent: this
  2641. }));
  2642.  
  2643. for (var name in styles) {
  2644. this.rules.add(name, styles[name]);
  2645. }
  2646.  
  2647. this.rules.process();
  2648. }
  2649. /**
  2650. * Get a rule.
  2651. */
  2652.  
  2653.  
  2654. var _proto = ConditionalRule.prototype;
  2655.  
  2656. _proto.getRule = function getRule(name) {
  2657. return this.rules.get(name);
  2658. }
  2659. /**
  2660. * Get index of a rule.
  2661. */
  2662. ;
  2663.  
  2664. _proto.indexOf = function indexOf(rule) {
  2665. return this.rules.indexOf(rule);
  2666. }
  2667. /**
  2668. * Create and register rule, run plugins.
  2669. */
  2670. ;
  2671.  
  2672. _proto.addRule = function addRule(name, style, options) {
  2673. var rule = this.rules.add(name, style, options);
  2674. if (!rule) return null;
  2675. this.options.jss.plugins.onProcessRule(rule);
  2676. return rule;
  2677. }
  2678. /**
  2679. * Generates a CSS string.
  2680. */
  2681. ;
  2682.  
  2683. _proto.toString = function toString(options) {
  2684. if (options === void 0) {
  2685. options = defaultToStringOptions;
  2686. }
  2687.  
  2688. if (options.indent == null) options.indent = defaultToStringOptions.indent;
  2689. if (options.children == null) options.children = defaultToStringOptions.children;
  2690.  
  2691. if (options.children === false) {
  2692. return this.query + " {}";
  2693. }
  2694.  
  2695. var children = this.rules.toString(options);
  2696. return children ? this.query + " {\n" + children + "\n}" : '';
  2697. };
  2698.  
  2699. return ConditionalRule;
  2700. }();
  2701.  
  2702. var keyRegExp = /@media|@supports\s+/;
  2703. var pluginConditionalRule = {
  2704. onCreateRule: function onCreateRule(key, styles, options) {
  2705. return keyRegExp.test(key) ? new ConditionalRule(key, styles, options) : null;
  2706. }
  2707. };
  2708. var defaultToStringOptions$1 = {
  2709. indent: 1,
  2710. children: true
  2711. };
  2712. var nameRegExp = /@keyframes\s+([\w-]+)/;
  2713. /**
  2714. * Rule for @keyframes
  2715. */
  2716.  
  2717. var KeyframesRule = /*#__PURE__*/function () {
  2718. function KeyframesRule(key, frames, options) {
  2719. this.type = 'keyframes';
  2720. this.at = '@keyframes';
  2721. this.key = void 0;
  2722. this.name = void 0;
  2723. this.id = void 0;
  2724. this.rules = void 0;
  2725. this.options = void 0;
  2726. this.isProcessed = false;
  2727. this.renderable = void 0;
  2728. var nameMatch = key.match(nameRegExp);
  2729.  
  2730. if (nameMatch && nameMatch[1]) {
  2731. this.name = nameMatch[1];
  2732. } else {
  2733. this.name = 'noname';
  2734. }
  2735.  
  2736. this.key = this.type + "-" + this.name;
  2737. this.options = options;
  2738. var scoped = options.scoped,
  2739. sheet = options.sheet,
  2740. generateId = options.generateId;
  2741. this.id = scoped === false ? this.name : escape(generateId(this, sheet));
  2742. this.rules = new RuleList(_extends$1({}, options, {
  2743. parent: this
  2744. }));
  2745.  
  2746. for (var name in frames) {
  2747. this.rules.add(name, frames[name], _extends$1({}, options, {
  2748. parent: this
  2749. }));
  2750. }
  2751.  
  2752. this.rules.process();
  2753. }
  2754. /**
  2755. * Generates a CSS string.
  2756. */
  2757.  
  2758.  
  2759. var _proto = KeyframesRule.prototype;
  2760.  
  2761. _proto.toString = function toString(options) {
  2762. if (options === void 0) {
  2763. options = defaultToStringOptions$1;
  2764. }
  2765.  
  2766. if (options.indent == null) options.indent = defaultToStringOptions$1.indent;
  2767. if (options.children == null) options.children = defaultToStringOptions$1.children;
  2768.  
  2769. if (options.children === false) {
  2770. return this.at + " " + this.id + " {}";
  2771. }
  2772.  
  2773. var children = this.rules.toString(options);
  2774. if (children) children = "\n" + children + "\n";
  2775. return this.at + " " + this.id + " {" + children + "}";
  2776. };
  2777.  
  2778. return KeyframesRule;
  2779. }();
  2780.  
  2781. var keyRegExp$1 = /@keyframes\s+/;
  2782. var refRegExp$1 = /\$([\w-]+)/g;
  2783.  
  2784. var findReferencedKeyframe = function findReferencedKeyframe(val, keyframes) {
  2785. if (typeof val === 'string') {
  2786. return val.replace(refRegExp$1, function (match, name) {
  2787. if (name in keyframes) {
  2788. return keyframes[name];
  2789. }
  2790. return match;
  2791. });
  2792. }
  2793.  
  2794. return val;
  2795. };
  2796. /**
  2797. * Replace the reference for a animation name.
  2798. */
  2799.  
  2800.  
  2801. var replaceRef = function replaceRef(style, prop, keyframes) {
  2802. var value = style[prop];
  2803. var refKeyframe = findReferencedKeyframe(value, keyframes);
  2804.  
  2805. if (refKeyframe !== value) {
  2806. style[prop] = refKeyframe;
  2807. }
  2808. };
  2809.  
  2810. var plugin = {
  2811. onCreateRule: function onCreateRule(key, frames, options) {
  2812. return typeof key === 'string' && keyRegExp$1.test(key) ? new KeyframesRule(key, frames, options) : null;
  2813. },
  2814. // Animation name ref replacer.
  2815. onProcessStyle: function onProcessStyle(style, rule, sheet) {
  2816. if (rule.type !== 'style' || !sheet) return style;
  2817. if ('animation-name' in style) replaceRef(style, 'animation-name', sheet.keyframes);
  2818. if ('animation' in style) replaceRef(style, 'animation', sheet.keyframes);
  2819. return style;
  2820. },
  2821. onChangeValue: function onChangeValue(val, prop, rule) {
  2822. var sheet = rule.options.sheet;
  2823.  
  2824. if (!sheet) {
  2825. return val;
  2826. }
  2827.  
  2828. switch (prop) {
  2829. case 'animation':
  2830. return findReferencedKeyframe(val, sheet.keyframes);
  2831.  
  2832. case 'animation-name':
  2833. return findReferencedKeyframe(val, sheet.keyframes);
  2834.  
  2835. default:
  2836. return val;
  2837. }
  2838. }
  2839. };
  2840.  
  2841. var KeyframeRule = /*#__PURE__*/function (_BaseStyleRule) {
  2842. _inheritsLoose(KeyframeRule, _BaseStyleRule);
  2843.  
  2844. function KeyframeRule() {
  2845. var _this;
  2846.  
  2847. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2848. args[_key] = arguments[_key];
  2849. }
  2850.  
  2851. _this = _BaseStyleRule.call.apply(_BaseStyleRule, [this].concat(args)) || this;
  2852. _this.renderable = void 0;
  2853. return _this;
  2854. }
  2855.  
  2856. var _proto = KeyframeRule.prototype;
  2857. /**
  2858. * Generates a CSS string.
  2859. */
  2860.  
  2861. _proto.toString = function toString(options) {
  2862. var sheet = this.options.sheet;
  2863. var link = sheet ? sheet.options.link : false;
  2864. var opts = link ? _extends$1({}, options, {
  2865. allowEmpty: true
  2866. }) : options;
  2867. return toCss(this.key, this.style, opts);
  2868. };
  2869.  
  2870. return KeyframeRule;
  2871. }(BaseStyleRule);
  2872.  
  2873. var pluginKeyframeRule = {
  2874. onCreateRule: function onCreateRule(key, style, options) {
  2875. if (options.parent && options.parent.type === 'keyframes') {
  2876. return new KeyframeRule(key, style, options);
  2877. }
  2878.  
  2879. return null;
  2880. }
  2881. };
  2882.  
  2883. var FontFaceRule = /*#__PURE__*/function () {
  2884. function FontFaceRule(key, style, options) {
  2885. this.type = 'font-face';
  2886. this.at = '@font-face';
  2887. this.key = void 0;
  2888. this.style = void 0;
  2889. this.options = void 0;
  2890. this.isProcessed = false;
  2891. this.renderable = void 0;
  2892. this.key = key;
  2893. this.style = style;
  2894. this.options = options;
  2895. }
  2896. /**
  2897. * Generates a CSS string.
  2898. */
  2899.  
  2900.  
  2901. var _proto = FontFaceRule.prototype;
  2902.  
  2903. _proto.toString = function toString(options) {
  2904. if (Array.isArray(this.style)) {
  2905. var str = '';
  2906.  
  2907. for (var index = 0; index < this.style.length; index++) {
  2908. str += toCss(this.at, this.style[index]);
  2909. if (this.style[index + 1]) str += '\n';
  2910. }
  2911.  
  2912. return str;
  2913. }
  2914.  
  2915. return toCss(this.at, this.style, options);
  2916. };
  2917.  
  2918. return FontFaceRule;
  2919. }();
  2920.  
  2921. var keyRegExp$2 = /@font-face/;
  2922. var pluginFontFaceRule = {
  2923. onCreateRule: function onCreateRule(key, style, options) {
  2924. return keyRegExp$2.test(key) ? new FontFaceRule(key, style, options) : null;
  2925. }
  2926. };
  2927.  
  2928. var ViewportRule = /*#__PURE__*/function () {
  2929. function ViewportRule(key, style, options) {
  2930. this.type = 'viewport';
  2931. this.at = '@viewport';
  2932. this.key = void 0;
  2933. this.style = void 0;
  2934. this.options = void 0;
  2935. this.isProcessed = false;
  2936. this.renderable = void 0;
  2937. this.key = key;
  2938. this.style = style;
  2939. this.options = options;
  2940. }
  2941. /**
  2942. * Generates a CSS string.
  2943. */
  2944.  
  2945.  
  2946. var _proto = ViewportRule.prototype;
  2947.  
  2948. _proto.toString = function toString(options) {
  2949. return toCss(this.key, this.style, options);
  2950. };
  2951.  
  2952. return ViewportRule;
  2953. }();
  2954.  
  2955. var pluginViewportRule = {
  2956. onCreateRule: function onCreateRule(key, style, options) {
  2957. return key === '@viewport' || key === '@-ms-viewport' ? new ViewportRule(key, style, options) : null;
  2958. }
  2959. };
  2960.  
  2961. var SimpleRule = /*#__PURE__*/function () {
  2962. function SimpleRule(key, value, options) {
  2963. this.type = 'simple';
  2964. this.key = void 0;
  2965. this.value = void 0;
  2966. this.options = void 0;
  2967. this.isProcessed = false;
  2968. this.renderable = void 0;
  2969. this.key = key;
  2970. this.value = value;
  2971. this.options = options;
  2972. }
  2973. /**
  2974. * Generates a CSS string.
  2975. */
  2976. // eslint-disable-next-line no-unused-vars
  2977.  
  2978.  
  2979. var _proto = SimpleRule.prototype;
  2980.  
  2981. _proto.toString = function toString(options) {
  2982. if (Array.isArray(this.value)) {
  2983. var str = '';
  2984.  
  2985. for (var index = 0; index < this.value.length; index++) {
  2986. str += this.key + " " + this.value[index] + ";";
  2987. if (this.value[index + 1]) str += '\n';
  2988. }
  2989.  
  2990. return str;
  2991. }
  2992.  
  2993. return this.key + " " + this.value + ";";
  2994. };
  2995.  
  2996. return SimpleRule;
  2997. }();
  2998.  
  2999. var keysMap = {
  3000. '@charset': true,
  3001. '@import': true,
  3002. '@namespace': true
  3003. };
  3004. var pluginSimpleRule = {
  3005. onCreateRule: function onCreateRule(key, value, options) {
  3006. return key in keysMap ? new SimpleRule(key, value, options) : null;
  3007. }
  3008. };
  3009. var plugins$1 = [pluginStyleRule, pluginConditionalRule, plugin, pluginKeyframeRule, pluginFontFaceRule, pluginViewportRule, pluginSimpleRule];
  3010. var defaultUpdateOptions = {
  3011. process: true
  3012. };
  3013. var forceUpdateOptions = {
  3014. force: true,
  3015. process: true
  3016. /**
  3017. * Contains rules objects and allows adding/removing etc.
  3018. * Is used for e.g. by `StyleSheet` or `ConditionalRule`.
  3019. */
  3020.  
  3021. };
  3022.  
  3023. var RuleList = /*#__PURE__*/function () {
  3024. // Rules registry for access by .get() method.
  3025. // It contains the same rule registered by name and by selector.
  3026. // Original styles object.
  3027. // Used to ensure correct rules order.
  3028. function RuleList(options) {
  3029. this.map = {};
  3030. this.raw = {};
  3031. this.index = [];
  3032. this.counter = 0;
  3033. this.options = void 0;
  3034. this.classes = void 0;
  3035. this.keyframes = void 0;
  3036. this.options = options;
  3037. this.classes = options.classes;
  3038. this.keyframes = options.keyframes;
  3039. }
  3040. /**
  3041. * Create and register rule.
  3042. *
  3043. * Will not render after Style Sheet was rendered the first time.
  3044. */
  3045.  
  3046.  
  3047. var _proto = RuleList.prototype;
  3048.  
  3049. _proto.add = function add(name, decl, ruleOptions) {
  3050. var _this$options = this.options,
  3051. parent = _this$options.parent,
  3052. sheet = _this$options.sheet,
  3053. jss = _this$options.jss,
  3054. Renderer = _this$options.Renderer,
  3055. generateId = _this$options.generateId,
  3056. scoped = _this$options.scoped;
  3057.  
  3058. var options = _extends$1({
  3059. classes: this.classes,
  3060. parent: parent,
  3061. sheet: sheet,
  3062. jss: jss,
  3063. Renderer: Renderer,
  3064. generateId: generateId,
  3065. scoped: scoped,
  3066. name: name,
  3067. keyframes: this.keyframes,
  3068. selector: undefined
  3069. }, ruleOptions); // When user uses .createStyleSheet(), duplicate names are not possible, but
  3070. // `sheet.addRule()` opens the door for any duplicate rule name. When this happens
  3071. // we need to make the key unique within this RuleList instance scope.
  3072.  
  3073.  
  3074. var key = name;
  3075.  
  3076. if (name in this.raw) {
  3077. key = name + "-d" + this.counter++;
  3078. } // We need to save the original decl before creating the rule
  3079. // because cache plugin needs to use it as a key to return a cached rule.
  3080.  
  3081.  
  3082. this.raw[key] = decl;
  3083.  
  3084. if (key in this.classes) {
  3085. // E.g. rules inside of @media container
  3086. options.selector = "." + escape(this.classes[key]);
  3087. }
  3088.  
  3089. var rule = createRule(key, decl, options);
  3090. if (!rule) return null;
  3091. this.register(rule);
  3092. var index = options.index === undefined ? this.index.length : options.index;
  3093. this.index.splice(index, 0, rule);
  3094. return rule;
  3095. }
  3096. /**
  3097. * Get a rule.
  3098. */
  3099. ;
  3100.  
  3101. _proto.get = function get(name) {
  3102. return this.map[name];
  3103. }
  3104. /**
  3105. * Delete a rule.
  3106. */
  3107. ;
  3108.  
  3109. _proto.remove = function remove(rule) {
  3110. this.unregister(rule);
  3111. delete this.raw[rule.key];
  3112. this.index.splice(this.index.indexOf(rule), 1);
  3113. }
  3114. /**
  3115. * Get index of a rule.
  3116. */
  3117. ;
  3118.  
  3119. _proto.indexOf = function indexOf(rule) {
  3120. return this.index.indexOf(rule);
  3121. }
  3122. /**
  3123. * Run `onProcessRule()` plugins on every rule.
  3124. */
  3125. ;
  3126.  
  3127. _proto.process = function process() {
  3128. var plugins = this.options.jss.plugins; // We need to clone array because if we modify the index somewhere else during a loop
  3129. // we end up with very hard-to-track-down side effects.
  3130.  
  3131. this.index.slice(0).forEach(plugins.onProcessRule, plugins);
  3132. }
  3133. /**
  3134. * Register a rule in `.map`, `.classes` and `.keyframes` maps.
  3135. */
  3136. ;
  3137.  
  3138. _proto.register = function register(rule) {
  3139. this.map[rule.key] = rule;
  3140.  
  3141. if (rule instanceof StyleRule) {
  3142. this.map[rule.selector] = rule;
  3143. if (rule.id) this.classes[rule.key] = rule.id;
  3144. } else if (rule instanceof KeyframesRule && this.keyframes) {
  3145. this.keyframes[rule.name] = rule.id;
  3146. }
  3147. }
  3148. /**
  3149. * Unregister a rule.
  3150. */
  3151. ;
  3152.  
  3153. _proto.unregister = function unregister(rule) {
  3154. delete this.map[rule.key];
  3155.  
  3156. if (rule instanceof StyleRule) {
  3157. delete this.map[rule.selector];
  3158. delete this.classes[rule.key];
  3159. } else if (rule instanceof KeyframesRule) {
  3160. delete this.keyframes[rule.name];
  3161. }
  3162. }
  3163. /**
  3164. * Update the function values with a new data.
  3165. */
  3166. ;
  3167.  
  3168. _proto.update = function update() {
  3169. var name;
  3170. var data;
  3171. var options;
  3172.  
  3173. if (typeof (arguments.length <= 0 ? undefined : arguments[0]) === 'string') {
  3174. name = arguments.length <= 0 ? undefined : arguments[0]; // $FlowFixMe[invalid-tuple-index]
  3175.  
  3176. data = arguments.length <= 1 ? undefined : arguments[1]; // $FlowFixMe[invalid-tuple-index]
  3177.  
  3178. options = arguments.length <= 2 ? undefined : arguments[2];
  3179. } else {
  3180. data = arguments.length <= 0 ? undefined : arguments[0]; // $FlowFixMe[invalid-tuple-index]
  3181.  
  3182. options = arguments.length <= 1 ? undefined : arguments[1];
  3183. name = null;
  3184. }
  3185.  
  3186. if (name) {
  3187. this.updateOne(this.map[name], data, options);
  3188. } else {
  3189. for (var index = 0; index < this.index.length; index++) {
  3190. this.updateOne(this.index[index], data, options);
  3191. }
  3192. }
  3193. }
  3194. /**
  3195. * Execute plugins, update rule props.
  3196. */
  3197. ;
  3198.  
  3199. _proto.updateOne = function updateOne(rule, data, options) {
  3200. if (options === void 0) {
  3201. options = defaultUpdateOptions;
  3202. }
  3203.  
  3204. var _this$options2 = this.options,
  3205. plugins = _this$options2.jss.plugins,
  3206. sheet = _this$options2.sheet; // It is a rules container like for e.g. ConditionalRule.
  3207.  
  3208. if (rule.rules instanceof RuleList) {
  3209. rule.rules.update(data, options);
  3210. return;
  3211. }
  3212.  
  3213. var styleRule = rule;
  3214. var style = styleRule.style;
  3215. plugins.onUpdate(data, rule, sheet, options); // We rely on a new `style` ref in case it was mutated during onUpdate hook.
  3216.  
  3217. if (options.process && style && style !== styleRule.style) {
  3218. // We need to run the plugins in case new `style` relies on syntax plugins.
  3219. plugins.onProcessStyle(styleRule.style, styleRule, sheet); // Update and add props.
  3220.  
  3221. for (var prop in styleRule.style) {
  3222. var nextValue = styleRule.style[prop];
  3223. var prevValue = style[prop]; // We need to use `force: true` because `rule.style` has been updated during onUpdate hook, so `rule.prop()` will not update the CSSOM rule.
  3224. // We do this comparison to avoid unneeded `rule.prop()` calls, since we have the old `style` object here.
  3225.  
  3226. if (nextValue !== prevValue) {
  3227. styleRule.prop(prop, nextValue, forceUpdateOptions);
  3228. }
  3229. } // Remove props.
  3230.  
  3231.  
  3232. for (var _prop in style) {
  3233. var _nextValue = styleRule.style[_prop];
  3234. var _prevValue = style[_prop]; // We need to use `force: true` because `rule.style` has been updated during onUpdate hook, so `rule.prop()` will not update the CSSOM rule.
  3235. // We do this comparison to avoid unneeded `rule.prop()` calls, since we have the old `style` object here.
  3236.  
  3237. if (_nextValue == null && _nextValue !== _prevValue) {
  3238. styleRule.prop(_prop, null, forceUpdateOptions);
  3239. }
  3240. }
  3241. }
  3242. }
  3243. /**
  3244. * Convert rules to a CSS string.
  3245. */
  3246. ;
  3247.  
  3248. _proto.toString = function toString(options) {
  3249. var str = '';
  3250. var sheet = this.options.sheet;
  3251. var link = sheet ? sheet.options.link : false;
  3252.  
  3253. for (var index = 0; index < this.index.length; index++) {
  3254. var rule = this.index[index];
  3255. var css = rule.toString(options); // No need to render an empty rule.
  3256.  
  3257. if (!css && !link) continue;
  3258. if (str) str += '\n';
  3259. str += css;
  3260. }
  3261.  
  3262. return str;
  3263. };
  3264.  
  3265. return RuleList;
  3266. }();
  3267.  
  3268. var StyleSheet = /*#__PURE__*/function () {
  3269. function StyleSheet(styles, options) {
  3270. this.options = void 0;
  3271. this.deployed = void 0;
  3272. this.attached = void 0;
  3273. this.rules = void 0;
  3274. this.renderer = void 0;
  3275. this.classes = void 0;
  3276. this.keyframes = void 0;
  3277. this.queue = void 0;
  3278. this.attached = false;
  3279. this.deployed = false;
  3280. this.classes = {};
  3281. this.keyframes = {};
  3282. this.options = _extends$1({}, options, {
  3283. sheet: this,
  3284. parent: this,
  3285. classes: this.classes,
  3286. keyframes: this.keyframes
  3287. });
  3288.  
  3289. if (options.Renderer) {
  3290. this.renderer = new options.Renderer(this);
  3291. }
  3292.  
  3293. this.rules = new RuleList(this.options);
  3294.  
  3295. for (var name in styles) {
  3296. this.rules.add(name, styles[name]);
  3297. }
  3298.  
  3299. this.rules.process();
  3300. }
  3301. /**
  3302. * Attach renderable to the render tree.
  3303. */
  3304.  
  3305.  
  3306. var _proto = StyleSheet.prototype;
  3307.  
  3308. _proto.attach = function attach() {
  3309. if (this.attached) return this;
  3310. if (this.renderer) this.renderer.attach();
  3311. this.attached = true; // Order is important, because we can't use insertRule API if style element is not attached.
  3312.  
  3313. if (!this.deployed) this.deploy();
  3314. return this;
  3315. }
  3316. /**
  3317. * Remove renderable from render tree.
  3318. */
  3319. ;
  3320.  
  3321. _proto.detach = function detach() {
  3322. if (!this.attached) return this;
  3323. if (this.renderer) this.renderer.detach();
  3324. this.attached = false;
  3325. return this;
  3326. }
  3327. /**
  3328. * Add a rule to the current stylesheet.
  3329. * Will insert a rule also after the stylesheet has been rendered first time.
  3330. */
  3331. ;
  3332.  
  3333. _proto.addRule = function addRule(name, decl, options) {
  3334. var queue = this.queue; // Plugins can create rules.
  3335. // In order to preserve the right order, we need to queue all `.addRule` calls,
  3336. // which happen after the first `rules.add()` call.
  3337.  
  3338. if (this.attached && !queue) this.queue = [];
  3339. var rule = this.rules.add(name, decl, options);
  3340. if (!rule) return null;
  3341. this.options.jss.plugins.onProcessRule(rule);
  3342.  
  3343. if (this.attached) {
  3344. if (!this.deployed) return rule; // Don't insert rule directly if there is no stringified version yet.
  3345. // It will be inserted all together when .attach is called.
  3346.  
  3347. if (queue) queue.push(rule);else {
  3348. this.insertRule(rule);
  3349.  
  3350. if (this.queue) {
  3351. this.queue.forEach(this.insertRule, this);
  3352. this.queue = undefined;
  3353. }
  3354. }
  3355. return rule;
  3356. } // We can't add rules to a detached style node.
  3357. // We will redeploy the sheet once user will attach it.
  3358.  
  3359.  
  3360. this.deployed = false;
  3361. return rule;
  3362. }
  3363. /**
  3364. * Insert rule into the StyleSheet
  3365. */
  3366. ;
  3367.  
  3368. _proto.insertRule = function insertRule(rule) {
  3369. if (this.renderer) {
  3370. this.renderer.insertRule(rule);
  3371. }
  3372. }
  3373. /**
  3374. * Create and add rules.
  3375. * Will render also after Style Sheet was rendered the first time.
  3376. */
  3377. ;
  3378.  
  3379. _proto.addRules = function addRules(styles, options) {
  3380. var added = [];
  3381.  
  3382. for (var name in styles) {
  3383. var rule = this.addRule(name, styles[name], options);
  3384. if (rule) added.push(rule);
  3385. }
  3386.  
  3387. return added;
  3388. }
  3389. /**
  3390. * Get a rule by name.
  3391. */
  3392. ;
  3393.  
  3394. _proto.getRule = function getRule(name) {
  3395. return this.rules.get(name);
  3396. }
  3397. /**
  3398. * Delete a rule by name.
  3399. * Returns `true`: if rule has been deleted from the DOM.
  3400. */
  3401. ;
  3402.  
  3403. _proto.deleteRule = function deleteRule(name) {
  3404. var rule = typeof name === 'object' ? name : this.rules.get(name);
  3405.  
  3406. if (!rule || // Style sheet was created without link: true and attached, in this case we
  3407. // won't be able to remove the CSS rule from the DOM.
  3408. this.attached && !rule.renderable) {
  3409. return false;
  3410. }
  3411.  
  3412. this.rules.remove(rule);
  3413.  
  3414. if (this.attached && rule.renderable && this.renderer) {
  3415. return this.renderer.deleteRule(rule.renderable);
  3416. }
  3417.  
  3418. return true;
  3419. }
  3420. /**
  3421. * Get index of a rule.
  3422. */
  3423. ;
  3424.  
  3425. _proto.indexOf = function indexOf(rule) {
  3426. return this.rules.indexOf(rule);
  3427. }
  3428. /**
  3429. * Deploy pure CSS string to a renderable.
  3430. */
  3431. ;
  3432.  
  3433. _proto.deploy = function deploy() {
  3434. if (this.renderer) this.renderer.deploy();
  3435. this.deployed = true;
  3436. return this;
  3437. }
  3438. /**
  3439. * Update the function values with a new data.
  3440. */
  3441. ;
  3442.  
  3443. _proto.update = function update() {
  3444. var _this$rules;
  3445.  
  3446. (_this$rules = this.rules).update.apply(_this$rules, arguments);
  3447.  
  3448. return this;
  3449. }
  3450. /**
  3451. * Updates a single rule.
  3452. */
  3453. ;
  3454.  
  3455. _proto.updateOne = function updateOne(rule, data, options) {
  3456. this.rules.updateOne(rule, data, options);
  3457. return this;
  3458. }
  3459. /**
  3460. * Convert rules to a CSS string.
  3461. */
  3462. ;
  3463.  
  3464. _proto.toString = function toString(options) {
  3465. return this.rules.toString(options);
  3466. };
  3467.  
  3468. return StyleSheet;
  3469. }();
  3470.  
  3471. var PluginsRegistry = /*#__PURE__*/function () {
  3472. function PluginsRegistry() {
  3473. this.plugins = {
  3474. internal: [],
  3475. external: []
  3476. };
  3477. this.registry = void 0;
  3478. }
  3479.  
  3480. var _proto = PluginsRegistry.prototype;
  3481. /**
  3482. * Call `onCreateRule` hooks and return an object if returned by a hook.
  3483. */
  3484.  
  3485. _proto.onCreateRule = function onCreateRule(name, decl, options) {
  3486. for (var i = 0; i < this.registry.onCreateRule.length; i++) {
  3487. var rule = this.registry.onCreateRule[i](name, decl, options);
  3488. if (rule) return rule;
  3489. }
  3490.  
  3491. return null;
  3492. }
  3493. /**
  3494. * Call `onProcessRule` hooks.
  3495. */
  3496. ;
  3497.  
  3498. _proto.onProcessRule = function onProcessRule(rule) {
  3499. if (rule.isProcessed) return;
  3500. var sheet = rule.options.sheet;
  3501.  
  3502. for (var i = 0; i < this.registry.onProcessRule.length; i++) {
  3503. this.registry.onProcessRule[i](rule, sheet);
  3504. }
  3505.  
  3506. if (rule.style) this.onProcessStyle(rule.style, rule, sheet);
  3507. rule.isProcessed = true;
  3508. }
  3509. /**
  3510. * Call `onProcessStyle` hooks.
  3511. */
  3512. ;
  3513.  
  3514. _proto.onProcessStyle = function onProcessStyle(style, rule, sheet) {
  3515. for (var i = 0; i < this.registry.onProcessStyle.length; i++) {
  3516. // $FlowFixMe[prop-missing]
  3517. rule.style = this.registry.onProcessStyle[i](rule.style, rule, sheet);
  3518. }
  3519. }
  3520. /**
  3521. * Call `onProcessSheet` hooks.
  3522. */
  3523. ;
  3524.  
  3525. _proto.onProcessSheet = function onProcessSheet(sheet) {
  3526. for (var i = 0; i < this.registry.onProcessSheet.length; i++) {
  3527. this.registry.onProcessSheet[i](sheet);
  3528. }
  3529. }
  3530. /**
  3531. * Call `onUpdate` hooks.
  3532. */
  3533. ;
  3534.  
  3535. _proto.onUpdate = function onUpdate(data, rule, sheet, options) {
  3536. for (var i = 0; i < this.registry.onUpdate.length; i++) {
  3537. this.registry.onUpdate[i](data, rule, sheet, options);
  3538. }
  3539. }
  3540. /**
  3541. * Call `onChangeValue` hooks.
  3542. */
  3543. ;
  3544.  
  3545. _proto.onChangeValue = function onChangeValue(value, prop, rule) {
  3546. var processedValue = value;
  3547.  
  3548. for (var i = 0; i < this.registry.onChangeValue.length; i++) {
  3549. processedValue = this.registry.onChangeValue[i](processedValue, prop, rule);
  3550. }
  3551.  
  3552. return processedValue;
  3553. }
  3554. /**
  3555. * Register a plugin.
  3556. */
  3557. ;
  3558.  
  3559. _proto.use = function use(newPlugin, options) {
  3560. if (options === void 0) {
  3561. options = {
  3562. queue: 'external'
  3563. };
  3564. }
  3565.  
  3566. var plugins = this.plugins[options.queue]; // Avoids applying same plugin twice, at least based on ref.
  3567.  
  3568. if (plugins.indexOf(newPlugin) !== -1) {
  3569. return;
  3570. }
  3571.  
  3572. plugins.push(newPlugin);
  3573. this.registry = [].concat(this.plugins.external, this.plugins.internal).reduce(function (registry, plugin) {
  3574. for (var name in plugin) {
  3575. if (name in registry) {
  3576. registry[name].push(plugin[name]);
  3577. }
  3578. }
  3579.  
  3580. return registry;
  3581. }, {
  3582. onCreateRule: [],
  3583. onProcessRule: [],
  3584. onProcessStyle: [],
  3585. onProcessSheet: [],
  3586. onChangeValue: [],
  3587. onUpdate: []
  3588. });
  3589. };
  3590.  
  3591. return PluginsRegistry;
  3592. }();
  3593. /**
  3594. * Sheets registry to access them all at one place.
  3595. */
  3596.  
  3597.  
  3598. var SheetsRegistry = /*#__PURE__*/function () {
  3599. function SheetsRegistry() {
  3600. this.registry = [];
  3601. }
  3602.  
  3603. var _proto = SheetsRegistry.prototype;
  3604. /**
  3605. * Register a Style Sheet.
  3606. */
  3607.  
  3608. _proto.add = function add(sheet) {
  3609. var registry = this.registry;
  3610. var index = sheet.options.index;
  3611. if (registry.indexOf(sheet) !== -1) return;
  3612.  
  3613. if (registry.length === 0 || index >= this.index) {
  3614. registry.push(sheet);
  3615. return;
  3616. } // Find a position.
  3617.  
  3618.  
  3619. for (var i = 0; i < registry.length; i++) {
  3620. if (registry[i].options.index > index) {
  3621. registry.splice(i, 0, sheet);
  3622. return;
  3623. }
  3624. }
  3625. }
  3626. /**
  3627. * Reset the registry.
  3628. */
  3629. ;
  3630.  
  3631. _proto.reset = function reset() {
  3632. this.registry = [];
  3633. }
  3634. /**
  3635. * Remove a Style Sheet.
  3636. */
  3637. ;
  3638.  
  3639. _proto.remove = function remove(sheet) {
  3640. var index = this.registry.indexOf(sheet);
  3641. this.registry.splice(index, 1);
  3642. }
  3643. /**
  3644. * Convert all attached sheets to a CSS string.
  3645. */
  3646. ;
  3647.  
  3648. _proto.toString = function toString(_temp) {
  3649. var _ref = _temp === void 0 ? {} : _temp,
  3650. attached = _ref.attached,
  3651. options = _objectWithoutPropertiesLoose(_ref, ["attached"]);
  3652.  
  3653. var css = '';
  3654.  
  3655. for (var i = 0; i < this.registry.length; i++) {
  3656. var sheet = this.registry[i];
  3657.  
  3658. if (attached != null && sheet.attached !== attached) {
  3659. continue;
  3660. }
  3661.  
  3662. if (css) css += '\n';
  3663. css += sheet.toString(options);
  3664. }
  3665.  
  3666. return css;
  3667. };
  3668.  
  3669. _createClass(SheetsRegistry, [{
  3670. key: "index",
  3671.  
  3672. /**
  3673. * Current highest index number.
  3674. */
  3675. get: function get() {
  3676. return this.registry.length === 0 ? 0 : this.registry[this.registry.length - 1].options.index;
  3677. }
  3678. }]);
  3679.  
  3680. return SheetsRegistry;
  3681. }();
  3682. /**
  3683. * This is a global sheets registry. Only DomRenderer will add sheets to it.
  3684. * On the server one should use an own SheetsRegistry instance and add the
  3685. * sheets to it, because you need to make sure to create a new registry for
  3686. * each request in order to not leak sheets across requests.
  3687. */
  3688.  
  3689.  
  3690. var registry = new SheetsRegistry();
  3691. /* eslint-disable */
  3692.  
  3693. /**
  3694. * Now that `globalThis` is available on most platforms
  3695. * (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#browser_compatibility)
  3696. * we check for `globalThis` first. `globalThis` is necessary for jss
  3697. * to run in Agoric's secure version of JavaScript (SES). Under SES,
  3698. * `globalThis` exists, but `window`, `self`, and `Function('return
  3699. * this')()` are all undefined for security reasons.
  3700. *
  3701. * https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  3702. */
  3703.  
  3704. var globalThis$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' && window.Math === Math ? window : typeof self !== 'undefined' && self.Math === Math ? self : Function('return this')();
  3705. var ns = '2f1acc6c3a606b082e5eef5e54414ffb';
  3706. if (globalThis$1[ns] == null) globalThis$1[ns] = 0; // Bundle may contain multiple JSS versions at the same time. In order to identify
  3707. // the current version with just one short number and use it for classes generation
  3708. // we use a counter. Also it is more accurate, because user can manually reevaluate
  3709. // the module.
  3710.  
  3711. var moduleId = globalThis$1[ns]++;
  3712. /**
  3713. * Returns a function which generates unique class names based on counters.
  3714. * When new generator function is created, rule counter is reseted.
  3715. * We need to reset the rule counter for SSR for each request.
  3716. */
  3717.  
  3718. var createGenerateId = function createGenerateId(options) {
  3719. if (options === void 0) {
  3720. options = {};
  3721. }
  3722.  
  3723. var ruleCounter = 0;
  3724. return function (rule, sheet) {
  3725. ruleCounter += 1;
  3726.  
  3727. var jssId = '';
  3728. var prefix = '';
  3729.  
  3730. if (sheet) {
  3731. if (sheet.options.classNamePrefix) {
  3732. prefix = sheet.options.classNamePrefix;
  3733. }
  3734.  
  3735. if (sheet.options.jss.id != null) {
  3736. jssId = String(sheet.options.jss.id);
  3737. }
  3738. }
  3739.  
  3740. if (options.minify) {
  3741. // Using "c" because a number can't be the first char in a class name.
  3742. return "" + (prefix || 'c') + moduleId + jssId + ruleCounter;
  3743. }
  3744.  
  3745. return prefix + rule.key + "-" + moduleId + (jssId ? "-" + jssId : '') + "-" + ruleCounter;
  3746. };
  3747. };
  3748. /**
  3749. * Cache the value from the first time a function is called.
  3750. */
  3751.  
  3752.  
  3753. var memoize = function memoize(fn) {
  3754. var value;
  3755. return function () {
  3756. if (!value) value = fn();
  3757. return value;
  3758. };
  3759. };
  3760. /**
  3761. * Get a style property value.
  3762. */
  3763.  
  3764.  
  3765. var getPropertyValue = function getPropertyValue(cssRule, prop) {
  3766. try {
  3767. // Support CSSTOM.
  3768. if (cssRule.attributeStyleMap) {
  3769. return cssRule.attributeStyleMap.get(prop);
  3770. }
  3771.  
  3772. return cssRule.style.getPropertyValue(prop);
  3773. } catch (err) {
  3774. // IE may throw if property is unknown.
  3775. return '';
  3776. }
  3777. };
  3778. /**
  3779. * Set a style property.
  3780. */
  3781.  
  3782.  
  3783. var setProperty = function setProperty(cssRule, prop, value) {
  3784. try {
  3785. var cssValue = value;
  3786.  
  3787. if (Array.isArray(value)) {
  3788. cssValue = toCssValue(value, true);
  3789.  
  3790. if (value[value.length - 1] === '!important') {
  3791. cssRule.style.setProperty(prop, cssValue, 'important');
  3792. return true;
  3793. }
  3794. } // Support CSSTOM.
  3795.  
  3796.  
  3797. if (cssRule.attributeStyleMap) {
  3798. cssRule.attributeStyleMap.set(prop, cssValue);
  3799. } else {
  3800. cssRule.style.setProperty(prop, cssValue);
  3801. }
  3802. } catch (err) {
  3803. // IE may throw if property is unknown.
  3804. return false;
  3805. }
  3806.  
  3807. return true;
  3808. };
  3809. /**
  3810. * Remove a style property.
  3811. */
  3812.  
  3813.  
  3814. var removeProperty = function removeProperty(cssRule, prop) {
  3815. try {
  3816. // Support CSSTOM.
  3817. if (cssRule.attributeStyleMap) {
  3818. cssRule.attributeStyleMap.delete(prop);
  3819. } else {
  3820. cssRule.style.removeProperty(prop);
  3821. }
  3822. } catch (err) {
  3823. }
  3824. };
  3825. /**
  3826. * Set the selector.
  3827. */
  3828.  
  3829.  
  3830. var setSelector = function setSelector(cssRule, selectorText) {
  3831. cssRule.selectorText = selectorText; // Return false if setter was not successful.
  3832. // Currently works in chrome only.
  3833.  
  3834. return cssRule.selectorText === selectorText;
  3835. };
  3836. /**
  3837. * Gets the `head` element upon the first call and caches it.
  3838. * We assume it can't be null.
  3839. */
  3840.  
  3841.  
  3842. var getHead = memoize(function () {
  3843. return document.querySelector('head');
  3844. });
  3845. /**
  3846. * Find attached sheet with an index higher than the passed one.
  3847. */
  3848.  
  3849. function findHigherSheet(registry, options) {
  3850. for (var i = 0; i < registry.length; i++) {
  3851. var sheet = registry[i];
  3852.  
  3853. if (sheet.attached && sheet.options.index > options.index && sheet.options.insertionPoint === options.insertionPoint) {
  3854. return sheet;
  3855. }
  3856. }
  3857.  
  3858. return null;
  3859. }
  3860. /**
  3861. * Find attached sheet with the highest index.
  3862. */
  3863.  
  3864.  
  3865. function findHighestSheet(registry, options) {
  3866. for (var i = registry.length - 1; i >= 0; i--) {
  3867. var sheet = registry[i];
  3868.  
  3869. if (sheet.attached && sheet.options.insertionPoint === options.insertionPoint) {
  3870. return sheet;
  3871. }
  3872. }
  3873.  
  3874. return null;
  3875. }
  3876. /**
  3877. * Find a comment with "jss" inside.
  3878. */
  3879.  
  3880.  
  3881. function findCommentNode(text) {
  3882. var head = getHead();
  3883.  
  3884. for (var i = 0; i < head.childNodes.length; i++) {
  3885. var node = head.childNodes[i];
  3886.  
  3887. if (node.nodeType === 8 && node.nodeValue.trim() === text) {
  3888. return node;
  3889. }
  3890. }
  3891.  
  3892. return null;
  3893. }
  3894. /**
  3895. * Find a node before which we can insert the sheet.
  3896. */
  3897.  
  3898.  
  3899. function findPrevNode(options) {
  3900. var registry$1 = registry.registry;
  3901.  
  3902. if (registry$1.length > 0) {
  3903. // Try to insert before the next higher sheet.
  3904. var sheet = findHigherSheet(registry$1, options);
  3905.  
  3906. if (sheet && sheet.renderer) {
  3907. return {
  3908. parent: sheet.renderer.element.parentNode,
  3909. node: sheet.renderer.element
  3910. };
  3911. } // Otherwise insert after the last attached.
  3912.  
  3913.  
  3914. sheet = findHighestSheet(registry$1, options);
  3915.  
  3916. if (sheet && sheet.renderer) {
  3917. return {
  3918. parent: sheet.renderer.element.parentNode,
  3919. node: sheet.renderer.element.nextSibling
  3920. };
  3921. }
  3922. } // Try to find a comment placeholder if registry is empty.
  3923.  
  3924.  
  3925. var insertionPoint = options.insertionPoint;
  3926.  
  3927. if (insertionPoint && typeof insertionPoint === 'string') {
  3928. var comment = findCommentNode(insertionPoint);
  3929.  
  3930. if (comment) {
  3931. return {
  3932. parent: comment.parentNode,
  3933. node: comment.nextSibling
  3934. };
  3935. } // If user specifies an insertion point and it can't be found in the document -
  3936. }
  3937.  
  3938. return false;
  3939. }
  3940. /**
  3941. * Insert style element into the DOM.
  3942. */
  3943.  
  3944.  
  3945. function insertStyle(style, options) {
  3946. var insertionPoint = options.insertionPoint;
  3947. var nextNode = findPrevNode(options);
  3948.  
  3949. if (nextNode !== false && nextNode.parent) {
  3950. nextNode.parent.insertBefore(style, nextNode.node);
  3951. return;
  3952. } // Works with iframes and any node types.
  3953.  
  3954.  
  3955. if (insertionPoint && typeof insertionPoint.nodeType === 'number') {
  3956. // https://stackoverflow.com/questions/41328728/force-casting-in-flow
  3957. var insertionPointElement = insertionPoint;
  3958. var parentNode = insertionPointElement.parentNode;
  3959. if (parentNode) parentNode.insertBefore(style, insertionPointElement.nextSibling);
  3960. return;
  3961. }
  3962.  
  3963. getHead().appendChild(style);
  3964. }
  3965. /**
  3966. * Read jss nonce setting from the page if the user has set it.
  3967. */
  3968.  
  3969.  
  3970. var getNonce = memoize(function () {
  3971. var node = document.querySelector('meta[property="csp-nonce"]');
  3972. return node ? node.getAttribute('content') : null;
  3973. });
  3974.  
  3975. var _insertRule = function insertRule(container, rule, index) {
  3976. try {
  3977. if ('insertRule' in container) {
  3978. var c = container;
  3979. c.insertRule(rule, index);
  3980. } // Keyframes rule.
  3981. else if ('appendRule' in container) {
  3982. var _c = container;
  3983.  
  3984. _c.appendRule(rule);
  3985. }
  3986. } catch (err) {
  3987. return false;
  3988. }
  3989.  
  3990. return container.cssRules[index];
  3991. };
  3992.  
  3993. var getValidRuleInsertionIndex = function getValidRuleInsertionIndex(container, index) {
  3994. var maxIndex = container.cssRules.length; // In case previous insertion fails, passed index might be wrong
  3995.  
  3996. if (index === undefined || index > maxIndex) {
  3997. // eslint-disable-next-line no-param-reassign
  3998. return maxIndex;
  3999. }
  4000.  
  4001. return index;
  4002. };
  4003.  
  4004. var createStyle = function createStyle() {
  4005. var el = document.createElement('style'); // Without it, IE will have a broken source order specificity if we
  4006. // insert rules after we insert the style tag.
  4007. // It seems to kick-off the source order specificity algorithm.
  4008.  
  4009. el.textContent = '\n';
  4010. return el;
  4011. };
  4012.  
  4013. var DomRenderer = /*#__PURE__*/function () {
  4014. // HTMLStyleElement needs fixing https://github.com/facebook/flow/issues/2696
  4015. // Will be empty if link: true option is not set, because
  4016. // it is only for use together with insertRule API.
  4017. function DomRenderer(sheet) {
  4018. this.getPropertyValue = getPropertyValue;
  4019. this.setProperty = setProperty;
  4020. this.removeProperty = removeProperty;
  4021. this.setSelector = setSelector;
  4022. this.element = void 0;
  4023. this.sheet = void 0;
  4024. this.hasInsertedRules = false;
  4025. this.cssRules = []; // There is no sheet when the renderer is used from a standalone StyleRule.
  4026.  
  4027. if (sheet) registry.add(sheet);
  4028. this.sheet = sheet;
  4029.  
  4030. var _ref = this.sheet ? this.sheet.options : {},
  4031. media = _ref.media,
  4032. meta = _ref.meta,
  4033. element = _ref.element;
  4034.  
  4035. this.element = element || createStyle();
  4036. this.element.setAttribute('data-jss', '');
  4037. if (media) this.element.setAttribute('media', media);
  4038. if (meta) this.element.setAttribute('data-meta', meta);
  4039. var nonce = getNonce();
  4040. if (nonce) this.element.setAttribute('nonce', nonce);
  4041. }
  4042. /**
  4043. * Insert style element into render tree.
  4044. */
  4045.  
  4046.  
  4047. var _proto = DomRenderer.prototype;
  4048.  
  4049. _proto.attach = function attach() {
  4050. // In the case the element node is external and it is already in the DOM.
  4051. if (this.element.parentNode || !this.sheet) return;
  4052. insertStyle(this.element, this.sheet.options); // When rules are inserted using `insertRule` API, after `sheet.detach().attach()`
  4053. // most browsers create a new CSSStyleSheet, except of all IEs.
  4054.  
  4055. var deployed = Boolean(this.sheet && this.sheet.deployed);
  4056.  
  4057. if (this.hasInsertedRules && deployed) {
  4058. this.hasInsertedRules = false;
  4059. this.deploy();
  4060. }
  4061. }
  4062. /**
  4063. * Remove style element from render tree.
  4064. */
  4065. ;
  4066.  
  4067. _proto.detach = function detach() {
  4068. if (!this.sheet) return;
  4069. var parentNode = this.element.parentNode;
  4070. if (parentNode) parentNode.removeChild(this.element); // In the most browsers, rules inserted using insertRule() API will be lost when style element is removed.
  4071. // Though IE will keep them and we need a consistent behavior.
  4072.  
  4073. if (this.sheet.options.link) {
  4074. this.cssRules = [];
  4075. this.element.textContent = '\n';
  4076. }
  4077. }
  4078. /**
  4079. * Inject CSS string into element.
  4080. */
  4081. ;
  4082.  
  4083. _proto.deploy = function deploy() {
  4084. var sheet = this.sheet;
  4085. if (!sheet) return;
  4086.  
  4087. if (sheet.options.link) {
  4088. this.insertRules(sheet.rules);
  4089. return;
  4090. }
  4091.  
  4092. this.element.textContent = "\n" + sheet.toString() + "\n";
  4093. }
  4094. /**
  4095. * Insert RuleList into an element.
  4096. */
  4097. ;
  4098.  
  4099. _proto.insertRules = function insertRules(rules, nativeParent) {
  4100. for (var i = 0; i < rules.index.length; i++) {
  4101. this.insertRule(rules.index[i], i, nativeParent);
  4102. }
  4103. }
  4104. /**
  4105. * Insert a rule into element.
  4106. */
  4107. ;
  4108.  
  4109. _proto.insertRule = function insertRule(rule, index, nativeParent) {
  4110. if (nativeParent === void 0) {
  4111. nativeParent = this.element.sheet;
  4112. }
  4113.  
  4114. if (rule.rules) {
  4115. var parent = rule;
  4116. var latestNativeParent = nativeParent;
  4117.  
  4118. if (rule.type === 'conditional' || rule.type === 'keyframes') {
  4119. var _insertionIndex = getValidRuleInsertionIndex(nativeParent, index); // We need to render the container without children first.
  4120.  
  4121.  
  4122. latestNativeParent = _insertRule(nativeParent, parent.toString({
  4123. children: false
  4124. }), _insertionIndex);
  4125.  
  4126. if (latestNativeParent === false) {
  4127. return false;
  4128. }
  4129.  
  4130. this.refCssRule(rule, _insertionIndex, latestNativeParent);
  4131. }
  4132.  
  4133. this.insertRules(parent.rules, latestNativeParent);
  4134. return latestNativeParent;
  4135. }
  4136.  
  4137. var ruleStr = rule.toString();
  4138. if (!ruleStr) return false;
  4139. var insertionIndex = getValidRuleInsertionIndex(nativeParent, index);
  4140.  
  4141. var nativeRule = _insertRule(nativeParent, ruleStr, insertionIndex);
  4142.  
  4143. if (nativeRule === false) {
  4144. return false;
  4145. }
  4146.  
  4147. this.hasInsertedRules = true;
  4148. this.refCssRule(rule, insertionIndex, nativeRule);
  4149. return nativeRule;
  4150. };
  4151.  
  4152. _proto.refCssRule = function refCssRule(rule, index, cssRule) {
  4153. rule.renderable = cssRule; // We only want to reference the top level rules, deleteRule API doesn't support removing nested rules
  4154. // like rules inside media queries or keyframes
  4155.  
  4156. if (rule.options.parent instanceof StyleSheet) {
  4157. this.cssRules[index] = cssRule;
  4158. }
  4159. }
  4160. /**
  4161. * Delete a rule.
  4162. */
  4163. ;
  4164.  
  4165. _proto.deleteRule = function deleteRule(cssRule) {
  4166. var sheet = this.element.sheet;
  4167. var index = this.indexOf(cssRule);
  4168. if (index === -1) return false;
  4169. sheet.deleteRule(index);
  4170. this.cssRules.splice(index, 1);
  4171. return true;
  4172. }
  4173. /**
  4174. * Get index of a CSS Rule.
  4175. */
  4176. ;
  4177.  
  4178. _proto.indexOf = function indexOf(cssRule) {
  4179. return this.cssRules.indexOf(cssRule);
  4180. }
  4181. /**
  4182. * Generate a new CSS rule and replace the existing one.
  4183. *
  4184. * Only used for some old browsers because they can't set a selector.
  4185. */
  4186. ;
  4187.  
  4188. _proto.replaceRule = function replaceRule(cssRule, rule) {
  4189. var index = this.indexOf(cssRule);
  4190. if (index === -1) return false;
  4191. this.element.sheet.deleteRule(index);
  4192. this.cssRules.splice(index, 1);
  4193. return this.insertRule(rule, index);
  4194. }
  4195. /**
  4196. * Get all rules elements.
  4197. */
  4198. ;
  4199.  
  4200. _proto.getRules = function getRules() {
  4201. return this.element.sheet.cssRules;
  4202. };
  4203.  
  4204. return DomRenderer;
  4205. }();
  4206.  
  4207. var instanceCounter = 0;
  4208.  
  4209. var Jss = /*#__PURE__*/function () {
  4210. function Jss(options) {
  4211. this.id = instanceCounter++;
  4212. this.version = "10.6.0";
  4213. this.plugins = new PluginsRegistry();
  4214. this.options = {
  4215. id: {
  4216. minify: false
  4217. },
  4218. createGenerateId: createGenerateId,
  4219. Renderer: isBrowser$1 ? DomRenderer : null,
  4220. plugins: []
  4221. };
  4222. this.generateId = createGenerateId({
  4223. minify: false
  4224. });
  4225.  
  4226. for (var i = 0; i < plugins$1.length; i++) {
  4227. this.plugins.use(plugins$1[i], {
  4228. queue: 'internal'
  4229. });
  4230. }
  4231.  
  4232. this.setup(options);
  4233. }
  4234. /**
  4235. * Prepares various options, applies plugins.
  4236. * Should not be used twice on the same instance, because there is no plugins
  4237. * deduplication logic.
  4238. */
  4239.  
  4240.  
  4241. var _proto = Jss.prototype;
  4242.  
  4243. _proto.setup = function setup(options) {
  4244. if (options === void 0) {
  4245. options = {};
  4246. }
  4247.  
  4248. if (options.createGenerateId) {
  4249. this.options.createGenerateId = options.createGenerateId;
  4250. }
  4251.  
  4252. if (options.id) {
  4253. this.options.id = _extends$1({}, this.options.id, options.id);
  4254. }
  4255.  
  4256. if (options.createGenerateId || options.id) {
  4257. this.generateId = this.options.createGenerateId(this.options.id);
  4258. }
  4259.  
  4260. if (options.insertionPoint != null) this.options.insertionPoint = options.insertionPoint;
  4261.  
  4262. if ('Renderer' in options) {
  4263. this.options.Renderer = options.Renderer;
  4264. } // eslint-disable-next-line prefer-spread
  4265.  
  4266.  
  4267. if (options.plugins) this.use.apply(this, options.plugins);
  4268. return this;
  4269. }
  4270. /**
  4271. * Create a Style Sheet.
  4272. */
  4273. ;
  4274.  
  4275. _proto.createStyleSheet = function createStyleSheet(styles, options) {
  4276. if (options === void 0) {
  4277. options = {};
  4278. }
  4279.  
  4280. var _options = options,
  4281. index = _options.index;
  4282.  
  4283. if (typeof index !== 'number') {
  4284. index = registry.index === 0 ? 0 : registry.index + 1;
  4285. }
  4286.  
  4287. var sheet = new StyleSheet(styles, _extends$1({}, options, {
  4288. jss: this,
  4289. generateId: options.generateId || this.generateId,
  4290. insertionPoint: this.options.insertionPoint,
  4291. Renderer: this.options.Renderer,
  4292. index: index
  4293. }));
  4294. this.plugins.onProcessSheet(sheet);
  4295. return sheet;
  4296. }
  4297. /**
  4298. * Detach the Style Sheet and remove it from the registry.
  4299. */
  4300. ;
  4301.  
  4302. _proto.removeStyleSheet = function removeStyleSheet(sheet) {
  4303. sheet.detach();
  4304. registry.remove(sheet);
  4305. return this;
  4306. }
  4307. /**
  4308. * Create a rule without a Style Sheet.
  4309. * [Deprecated] will be removed in the next major version.
  4310. */
  4311. ;
  4312.  
  4313. _proto.createRule = function createRule$1(name, style, options) {
  4314. if (style === void 0) {
  4315. style = {};
  4316. }
  4317.  
  4318. if (options === void 0) {
  4319. options = {};
  4320. } // Enable rule without name for inline styles.
  4321.  
  4322.  
  4323. if (typeof name === 'object') {
  4324. // $FlowFixMe[incompatible-call]
  4325. return this.createRule(undefined, name, style);
  4326. } // $FlowFixMe[incompatible-type]
  4327.  
  4328.  
  4329. var ruleOptions = _extends$1({}, options, {
  4330. name: name,
  4331. jss: this,
  4332. Renderer: this.options.Renderer
  4333. });
  4334.  
  4335. if (!ruleOptions.generateId) ruleOptions.generateId = this.generateId;
  4336. if (!ruleOptions.classes) ruleOptions.classes = {};
  4337. if (!ruleOptions.keyframes) ruleOptions.keyframes = {};
  4338. var rule = createRule(name, style, ruleOptions);
  4339. if (rule) this.plugins.onProcessRule(rule);
  4340. return rule;
  4341. }
  4342. /**
  4343. * Register plugin. Passed function will be invoked with a rule instance.
  4344. */
  4345. ;
  4346.  
  4347. _proto.use = function use() {
  4348. var _this = this;
  4349.  
  4350. for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
  4351. plugins[_key] = arguments[_key];
  4352. }
  4353.  
  4354. plugins.forEach(function (plugin) {
  4355. _this.plugins.use(plugin);
  4356. });
  4357. return this;
  4358. };
  4359.  
  4360. return Jss;
  4361. }();
  4362. /**
  4363. * Extracts a styles object with only props that contain function values.
  4364. */
  4365.  
  4366.  
  4367. function getDynamicStyles(styles) {
  4368. var to = null;
  4369.  
  4370. for (var key in styles) {
  4371. var value = styles[key];
  4372. var type = typeof value;
  4373.  
  4374. if (type === 'function') {
  4375. if (!to) to = {};
  4376. to[key] = value;
  4377. } else if (type === 'object' && value !== null && !Array.isArray(value)) {
  4378. var extracted = getDynamicStyles(value);
  4379.  
  4380. if (extracted) {
  4381. if (!to) to = {};
  4382. to[key] = extracted;
  4383. }
  4384. }
  4385. }
  4386.  
  4387. return to;
  4388. }
  4389. /**
  4390. * A better abstraction over CSS.
  4391. *
  4392. * @copyright Oleg Isonen (Slobodskoi) / Isonen 2014-present
  4393. * @website https://github.com/cssinjs/jss
  4394. * @license MIT
  4395. */
  4396.  
  4397. /**
  4398. * Export a constant indicating if this browser has CSSTOM support.
  4399. * https://developers.google.com/web/updates/2018/03/cssom
  4400. */
  4401.  
  4402.  
  4403. var hasCSSTOMSupport = typeof CSS === 'object' && CSS != null && 'number' in CSS;
  4404. /**
  4405. * Creates a new instance of Jss.
  4406. */
  4407.  
  4408. var create = function create(options) {
  4409. return new Jss(options);
  4410. };
  4411. /**
  4412. * A global Jss instance.
  4413. */
  4414.  
  4415.  
  4416. create();
  4417.  
  4418. var now = Date.now();
  4419. var fnValuesNs = "fnValues" + now;
  4420. var fnRuleNs = "fnStyle" + ++now;
  4421.  
  4422. var functionPlugin = function functionPlugin() {
  4423. return {
  4424. onCreateRule: function onCreateRule(name, decl, options) {
  4425. if (typeof decl !== 'function') return null;
  4426. var rule = createRule(name, {}, options);
  4427. rule[fnRuleNs] = decl;
  4428. return rule;
  4429. },
  4430. onProcessStyle: function onProcessStyle(style, rule) {
  4431. // We need to extract function values from the declaration, so that we can keep core unaware of them.
  4432. // We need to do that only once.
  4433. // We don't need to extract functions on each style update, since this can happen only once.
  4434. // We don't support function values inside of function rules.
  4435. if (fnValuesNs in rule || fnRuleNs in rule) return style;
  4436. var fnValues = {};
  4437.  
  4438. for (var prop in style) {
  4439. var value = style[prop];
  4440. if (typeof value !== 'function') continue;
  4441. delete style[prop];
  4442. fnValues[prop] = value;
  4443. } // $FlowFixMe[prop-missing]
  4444.  
  4445.  
  4446. rule[fnValuesNs] = fnValues;
  4447. return style;
  4448. },
  4449. onUpdate: function onUpdate(data, rule, sheet, options) {
  4450. var styleRule = rule; // $FlowFixMe[prop-missing]
  4451.  
  4452. var fnRule = styleRule[fnRuleNs]; // If we have a style function, the entire rule is dynamic and style object
  4453. // will be returned from that function.
  4454.  
  4455. if (fnRule) {
  4456. // Empty object will remove all currently defined props
  4457. // in case function rule returns a falsy value.
  4458. styleRule.style = fnRule(data) || {};
  4459. } // $FlowFixMe[prop-missing]
  4460.  
  4461.  
  4462. var fnValues = styleRule[fnValuesNs]; // If we have a fn values map, it is a rule with function values.
  4463.  
  4464. if (fnValues) {
  4465. for (var _prop in fnValues) {
  4466. styleRule.prop(_prop, fnValues[_prop](data), options);
  4467. }
  4468. }
  4469. }
  4470. };
  4471. };
  4472.  
  4473. var at = '@global';
  4474. var atPrefix = '@global ';
  4475.  
  4476. var GlobalContainerRule = /*#__PURE__*/function () {
  4477. function GlobalContainerRule(key, styles, options) {
  4478. this.type = 'global';
  4479. this.at = at;
  4480. this.rules = void 0;
  4481. this.options = void 0;
  4482. this.key = void 0;
  4483. this.isProcessed = false;
  4484. this.key = key;
  4485. this.options = options;
  4486. this.rules = new RuleList(_extends$1({}, options, {
  4487. parent: this
  4488. }));
  4489.  
  4490. for (var selector in styles) {
  4491. this.rules.add(selector, styles[selector]);
  4492. }
  4493.  
  4494. this.rules.process();
  4495. }
  4496. /**
  4497. * Get a rule.
  4498. */
  4499.  
  4500.  
  4501. var _proto = GlobalContainerRule.prototype;
  4502.  
  4503. _proto.getRule = function getRule(name) {
  4504. return this.rules.get(name);
  4505. }
  4506. /**
  4507. * Create and register rule, run plugins.
  4508. */
  4509. ;
  4510.  
  4511. _proto.addRule = function addRule(name, style, options) {
  4512. var rule = this.rules.add(name, style, options);
  4513. if (rule) this.options.jss.plugins.onProcessRule(rule);
  4514. return rule;
  4515. }
  4516. /**
  4517. * Get index of a rule.
  4518. */
  4519. ;
  4520.  
  4521. _proto.indexOf = function indexOf(rule) {
  4522. return this.rules.indexOf(rule);
  4523. }
  4524. /**
  4525. * Generates a CSS string.
  4526. */
  4527. ;
  4528.  
  4529. _proto.toString = function toString() {
  4530. return this.rules.toString();
  4531. };
  4532.  
  4533. return GlobalContainerRule;
  4534. }();
  4535.  
  4536. var GlobalPrefixedRule = /*#__PURE__*/function () {
  4537. function GlobalPrefixedRule(key, style, options) {
  4538. this.type = 'global';
  4539. this.at = at;
  4540. this.options = void 0;
  4541. this.rule = void 0;
  4542. this.isProcessed = false;
  4543. this.key = void 0;
  4544. this.key = key;
  4545. this.options = options;
  4546. var selector = key.substr(atPrefix.length);
  4547. this.rule = options.jss.createRule(selector, style, _extends$1({}, options, {
  4548. parent: this
  4549. }));
  4550. }
  4551.  
  4552. var _proto2 = GlobalPrefixedRule.prototype;
  4553.  
  4554. _proto2.toString = function toString(options) {
  4555. return this.rule ? this.rule.toString(options) : '';
  4556. };
  4557.  
  4558. return GlobalPrefixedRule;
  4559. }();
  4560.  
  4561. var separatorRegExp$1 = /\s*,\s*/g;
  4562.  
  4563. function addScope(selector, scope) {
  4564. var parts = selector.split(separatorRegExp$1);
  4565. var scoped = '';
  4566.  
  4567. for (var i = 0; i < parts.length; i++) {
  4568. scoped += scope + " " + parts[i].trim();
  4569. if (parts[i + 1]) scoped += ', ';
  4570. }
  4571.  
  4572. return scoped;
  4573. }
  4574.  
  4575. function handleNestedGlobalContainerRule(rule, sheet) {
  4576. var options = rule.options,
  4577. style = rule.style;
  4578. var rules = style ? style[at] : null;
  4579. if (!rules) return;
  4580.  
  4581. for (var name in rules) {
  4582. sheet.addRule(name, rules[name], _extends$1({}, options, {
  4583. selector: addScope(name, rule.selector)
  4584. }));
  4585. }
  4586.  
  4587. delete style[at];
  4588. }
  4589.  
  4590. function handlePrefixedGlobalRule(rule, sheet) {
  4591. var options = rule.options,
  4592. style = rule.style;
  4593.  
  4594. for (var prop in style) {
  4595. if (prop[0] !== '@' || prop.substr(0, at.length) !== at) continue;
  4596. var selector = addScope(prop.substr(at.length), rule.selector);
  4597. sheet.addRule(selector, style[prop], _extends$1({}, options, {
  4598. selector: selector
  4599. }));
  4600. delete style[prop];
  4601. }
  4602. }
  4603. /**
  4604. * Convert nested rules to separate, remove them from original styles.
  4605. *
  4606. * @param {Rule} rule
  4607. * @api public
  4608. */
  4609.  
  4610.  
  4611. function jssGlobal() {
  4612. function onCreateRule(name, styles, options) {
  4613. if (!name) return null;
  4614.  
  4615. if (name === at) {
  4616. return new GlobalContainerRule(name, styles, options);
  4617. }
  4618.  
  4619. if (name[0] === '@' && name.substr(0, atPrefix.length) === atPrefix) {
  4620. return new GlobalPrefixedRule(name, styles, options);
  4621. }
  4622.  
  4623. var parent = options.parent;
  4624.  
  4625. if (parent) {
  4626. if (parent.type === 'global' || parent.options.parent && parent.options.parent.type === 'global') {
  4627. options.scoped = false;
  4628. }
  4629. }
  4630.  
  4631. if (options.scoped === false) {
  4632. options.selector = name;
  4633. }
  4634.  
  4635. return null;
  4636. }
  4637.  
  4638. function onProcessRule(rule, sheet) {
  4639. if (rule.type !== 'style' || !sheet) return;
  4640. handleNestedGlobalContainerRule(rule, sheet);
  4641. handlePrefixedGlobalRule(rule, sheet);
  4642. }
  4643.  
  4644. return {
  4645. onCreateRule: onCreateRule,
  4646. onProcessRule: onProcessRule
  4647. };
  4648. }
  4649.  
  4650. var separatorRegExp = /\s*,\s*/g;
  4651. var parentRegExp = /&/g;
  4652. var refRegExp = /\$([\w-]+)/g;
  4653. /**
  4654. * Convert nested rules to separate, remove them from original styles.
  4655. *
  4656. * @param {Rule} rule
  4657. * @api public
  4658. */
  4659.  
  4660. function jssNested() {
  4661. // Get a function to be used for $ref replacement.
  4662. function getReplaceRef(container, sheet) {
  4663. return function (match, key) {
  4664. var rule = container.getRule(key) || sheet && sheet.getRule(key);
  4665.  
  4666. if (rule) {
  4667. rule = rule;
  4668. return rule.selector;
  4669. }
  4670. return key;
  4671. };
  4672. }
  4673.  
  4674. function replaceParentRefs(nestedProp, parentProp) {
  4675. var parentSelectors = parentProp.split(separatorRegExp);
  4676. var nestedSelectors = nestedProp.split(separatorRegExp);
  4677. var result = '';
  4678.  
  4679. for (var i = 0; i < parentSelectors.length; i++) {
  4680. var parent = parentSelectors[i];
  4681.  
  4682. for (var j = 0; j < nestedSelectors.length; j++) {
  4683. var nested = nestedSelectors[j];
  4684. if (result) result += ', '; // Replace all & by the parent or prefix & with the parent.
  4685.  
  4686. result += nested.indexOf('&') !== -1 ? nested.replace(parentRegExp, parent) : parent + " " + nested;
  4687. }
  4688. }
  4689.  
  4690. return result;
  4691. }
  4692.  
  4693. function getOptions(rule, container, prevOptions) {
  4694. // Options has been already created, now we only increase index.
  4695. if (prevOptions) return _extends$1({}, prevOptions, {
  4696. index: prevOptions.index + 1 // $FlowFixMe[prop-missing]
  4697.  
  4698. });
  4699. var nestingLevel = rule.options.nestingLevel;
  4700. nestingLevel = nestingLevel === undefined ? 1 : nestingLevel + 1;
  4701.  
  4702. var options = _extends$1({}, rule.options, {
  4703. nestingLevel: nestingLevel,
  4704. index: container.indexOf(rule) + 1 // We don't need the parent name to be set options for chlid.
  4705.  
  4706. });
  4707.  
  4708. delete options.name;
  4709. return options;
  4710. }
  4711.  
  4712. function onProcessStyle(style, rule, sheet) {
  4713. if (rule.type !== 'style') return style;
  4714. var styleRule = rule;
  4715. var container = styleRule.options.parent;
  4716. var options;
  4717. var replaceRef;
  4718.  
  4719. for (var prop in style) {
  4720. var isNested = prop.indexOf('&') !== -1;
  4721. var isNestedConditional = prop[0] === '@';
  4722. if (!isNested && !isNestedConditional) continue;
  4723. options = getOptions(styleRule, container, options);
  4724.  
  4725. if (isNested) {
  4726. var selector = replaceParentRefs(prop, styleRule.selector); // Lazily create the ref replacer function just once for
  4727. // all nested rules within the sheet.
  4728.  
  4729. if (!replaceRef) replaceRef = getReplaceRef(container, sheet); // Replace all $refs.
  4730.  
  4731. selector = selector.replace(refRegExp, replaceRef);
  4732. container.addRule(selector, style[prop], _extends$1({}, options, {
  4733. selector: selector
  4734. }));
  4735. } else if (isNestedConditional) {
  4736. // Place conditional right after the parent rule to ensure right ordering.
  4737. container.addRule(prop, {}, options) // Flow expects more options but they aren't required
  4738. // And flow doesn't know this will always be a StyleRule which has the addRule method
  4739. // $FlowFixMe[incompatible-use]
  4740. // $FlowFixMe[prop-missing]
  4741. .addRule(styleRule.key, style[prop], {
  4742. selector: styleRule.selector
  4743. });
  4744. }
  4745.  
  4746. delete style[prop];
  4747. }
  4748.  
  4749. return style;
  4750. }
  4751.  
  4752. return {
  4753. onProcessStyle: onProcessStyle
  4754. };
  4755. }
  4756.  
  4757. /* eslint-disable no-var, prefer-template */
  4758. var uppercasePattern = /[A-Z]/g;
  4759. var msPattern = /^ms-/;
  4760. var cache$2 = {};
  4761.  
  4762. function toHyphenLower(match) {
  4763. return '-' + match.toLowerCase();
  4764. }
  4765.  
  4766. function hyphenateStyleName(name) {
  4767. if (cache$2.hasOwnProperty(name)) {
  4768. return cache$2[name];
  4769. }
  4770.  
  4771. var hName = name.replace(uppercasePattern, toHyphenLower);
  4772. return cache$2[name] = msPattern.test(hName) ? '-' + hName : hName;
  4773. }
  4774.  
  4775. /**
  4776. * Convert camel cased property names to dash separated.
  4777. *
  4778. * @param {Object} style
  4779. * @return {Object}
  4780. */
  4781.  
  4782. function convertCase(style) {
  4783. var converted = {};
  4784.  
  4785. for (var prop in style) {
  4786. var key = prop.indexOf('--') === 0 ? prop : hyphenateStyleName(prop);
  4787. converted[key] = style[prop];
  4788. }
  4789.  
  4790. if (style.fallbacks) {
  4791. if (Array.isArray(style.fallbacks)) converted.fallbacks = style.fallbacks.map(convertCase);else converted.fallbacks = convertCase(style.fallbacks);
  4792. }
  4793.  
  4794. return converted;
  4795. }
  4796. /**
  4797. * Allow camel cased property names by converting them back to dasherized.
  4798. *
  4799. * @param {Rule} rule
  4800. */
  4801.  
  4802.  
  4803. function camelCase() {
  4804. function onProcessStyle(style) {
  4805. if (Array.isArray(style)) {
  4806. // Handle rules like @font-face, which can have multiple styles in an array
  4807. for (var index = 0; index < style.length; index++) {
  4808. style[index] = convertCase(style[index]);
  4809. }
  4810.  
  4811. return style;
  4812. }
  4813.  
  4814. return convertCase(style);
  4815. }
  4816.  
  4817. function onChangeValue(value, prop, rule) {
  4818. if (prop.indexOf('--') === 0) {
  4819. return value;
  4820. }
  4821.  
  4822. var hyphenatedProp = hyphenateStyleName(prop); // There was no camel case in place
  4823.  
  4824. if (prop === hyphenatedProp) return value;
  4825. rule.prop(hyphenatedProp, value); // Core will ignore that property value we set the proper one above.
  4826.  
  4827. return null;
  4828. }
  4829.  
  4830. return {
  4831. onProcessStyle: onProcessStyle,
  4832. onChangeValue: onChangeValue
  4833. };
  4834. }
  4835.  
  4836. var px = hasCSSTOMSupport && CSS ? CSS.px : 'px';
  4837. var ms = hasCSSTOMSupport && CSS ? CSS.ms : 'ms';
  4838. var percent = hasCSSTOMSupport && CSS ? CSS.percent : '%';
  4839. /**
  4840. * Generated jss-plugin-default-unit CSS property units
  4841. *
  4842. * @type object
  4843. */
  4844.  
  4845. var defaultUnits = {
  4846. // Animation properties
  4847. 'animation-delay': ms,
  4848. 'animation-duration': ms,
  4849. // Background properties
  4850. 'background-position': px,
  4851. 'background-position-x': px,
  4852. 'background-position-y': px,
  4853. 'background-size': px,
  4854. // Border Properties
  4855. border: px,
  4856. 'border-bottom': px,
  4857. 'border-bottom-left-radius': px,
  4858. 'border-bottom-right-radius': px,
  4859. 'border-bottom-width': px,
  4860. 'border-left': px,
  4861. 'border-left-width': px,
  4862. 'border-radius': px,
  4863. 'border-right': px,
  4864. 'border-right-width': px,
  4865. 'border-top': px,
  4866. 'border-top-left-radius': px,
  4867. 'border-top-right-radius': px,
  4868. 'border-top-width': px,
  4869. 'border-width': px,
  4870. 'border-block': px,
  4871. 'border-block-end': px,
  4872. 'border-block-end-width': px,
  4873. 'border-block-start': px,
  4874. 'border-block-start-width': px,
  4875. 'border-block-width': px,
  4876. 'border-inline': px,
  4877. 'border-inline-end': px,
  4878. 'border-inline-end-width': px,
  4879. 'border-inline-start': px,
  4880. 'border-inline-start-width': px,
  4881. 'border-inline-width': px,
  4882. 'border-start-start-radius': px,
  4883. 'border-start-end-radius': px,
  4884. 'border-end-start-radius': px,
  4885. 'border-end-end-radius': px,
  4886. // Margin properties
  4887. margin: px,
  4888. 'margin-bottom': px,
  4889. 'margin-left': px,
  4890. 'margin-right': px,
  4891. 'margin-top': px,
  4892. 'margin-block': px,
  4893. 'margin-block-end': px,
  4894. 'margin-block-start': px,
  4895. 'margin-inline': px,
  4896. 'margin-inline-end': px,
  4897. 'margin-inline-start': px,
  4898. // Padding properties
  4899. padding: px,
  4900. 'padding-bottom': px,
  4901. 'padding-left': px,
  4902. 'padding-right': px,
  4903. 'padding-top': px,
  4904. 'padding-block': px,
  4905. 'padding-block-end': px,
  4906. 'padding-block-start': px,
  4907. 'padding-inline': px,
  4908. 'padding-inline-end': px,
  4909. 'padding-inline-start': px,
  4910. // Mask properties
  4911. 'mask-position-x': px,
  4912. 'mask-position-y': px,
  4913. 'mask-size': px,
  4914. // Width and height properties
  4915. height: px,
  4916. width: px,
  4917. 'min-height': px,
  4918. 'max-height': px,
  4919. 'min-width': px,
  4920. 'max-width': px,
  4921. // Position properties
  4922. bottom: px,
  4923. left: px,
  4924. top: px,
  4925. right: px,
  4926. inset: px,
  4927. 'inset-block': px,
  4928. 'inset-block-end': px,
  4929. 'inset-block-start': px,
  4930. 'inset-inline': px,
  4931. 'inset-inline-end': px,
  4932. 'inset-inline-start': px,
  4933. // Shadow properties
  4934. 'box-shadow': px,
  4935. 'text-shadow': px,
  4936. // Column properties
  4937. 'column-gap': px,
  4938. 'column-rule': px,
  4939. 'column-rule-width': px,
  4940. 'column-width': px,
  4941. // Font and text properties
  4942. 'font-size': px,
  4943. 'font-size-delta': px,
  4944. 'letter-spacing': px,
  4945. 'text-decoration-thickness': px,
  4946. 'text-indent': px,
  4947. 'text-stroke': px,
  4948. 'text-stroke-width': px,
  4949. 'word-spacing': px,
  4950. // Motion properties
  4951. motion: px,
  4952. 'motion-offset': px,
  4953. // Outline properties
  4954. outline: px,
  4955. 'outline-offset': px,
  4956. 'outline-width': px,
  4957. // Perspective properties
  4958. perspective: px,
  4959. 'perspective-origin-x': percent,
  4960. 'perspective-origin-y': percent,
  4961. // Transform properties
  4962. 'transform-origin': percent,
  4963. 'transform-origin-x': percent,
  4964. 'transform-origin-y': percent,
  4965. 'transform-origin-z': percent,
  4966. // Transition properties
  4967. 'transition-delay': ms,
  4968. 'transition-duration': ms,
  4969. // Alignment properties
  4970. 'vertical-align': px,
  4971. 'flex-basis': px,
  4972. // Some random properties
  4973. 'shape-margin': px,
  4974. size: px,
  4975. gap: px,
  4976. // Grid properties
  4977. grid: px,
  4978. 'grid-gap': px,
  4979. 'row-gap': px,
  4980. 'grid-row-gap': px,
  4981. 'grid-column-gap': px,
  4982. 'grid-template-rows': px,
  4983. 'grid-template-columns': px,
  4984. 'grid-auto-rows': px,
  4985. 'grid-auto-columns': px,
  4986. // Not existing properties.
  4987. // Used to avoid issues with jss-plugin-expand integration.
  4988. 'box-shadow-x': px,
  4989. 'box-shadow-y': px,
  4990. 'box-shadow-blur': px,
  4991. 'box-shadow-spread': px,
  4992. 'font-line-height': px,
  4993. 'text-shadow-x': px,
  4994. 'text-shadow-y': px,
  4995. 'text-shadow-blur': px
  4996. };
  4997. /**
  4998. * Clones the object and adds a camel cased property version.
  4999. */
  5000.  
  5001. function addCamelCasedVersion(obj) {
  5002. var regExp = /(-[a-z])/g;
  5003.  
  5004. var replace = function replace(str) {
  5005. return str[1].toUpperCase();
  5006. };
  5007.  
  5008. var newObj = {};
  5009.  
  5010. for (var _key in obj) {
  5011. newObj[_key] = obj[_key];
  5012. newObj[_key.replace(regExp, replace)] = obj[_key];
  5013. }
  5014.  
  5015. return newObj;
  5016. }
  5017.  
  5018. var units = addCamelCasedVersion(defaultUnits);
  5019. /**
  5020. * Recursive deep style passing function
  5021. */
  5022.  
  5023. function iterate(prop, value, options) {
  5024. if (value == null) return value;
  5025.  
  5026. if (Array.isArray(value)) {
  5027. for (var i = 0; i < value.length; i++) {
  5028. value[i] = iterate(prop, value[i], options);
  5029. }
  5030. } else if (typeof value === 'object') {
  5031. if (prop === 'fallbacks') {
  5032. for (var innerProp in value) {
  5033. value[innerProp] = iterate(innerProp, value[innerProp], options);
  5034. }
  5035. } else {
  5036. for (var _innerProp in value) {
  5037. value[_innerProp] = iterate(prop + "-" + _innerProp, value[_innerProp], options);
  5038. }
  5039. } // eslint-disable-next-line no-restricted-globals
  5040.  
  5041. } else if (typeof value === 'number' && isNaN(value) === false) {
  5042. var unit = options[prop] || units[prop]; // Add the unit if available, except for the special case of 0px.
  5043.  
  5044. if (unit && !(value === 0 && unit === px)) {
  5045. return typeof unit === 'function' ? unit(value).toString() : "" + value + unit;
  5046. }
  5047.  
  5048. return value.toString();
  5049. }
  5050.  
  5051. return value;
  5052. }
  5053. /**
  5054. * Add unit to numeric values.
  5055. */
  5056.  
  5057.  
  5058. function defaultUnit(options) {
  5059. if (options === void 0) {
  5060. options = {};
  5061. }
  5062.  
  5063. var camelCasedOptions = addCamelCasedVersion(options);
  5064.  
  5065. function onProcessStyle(style, rule) {
  5066. if (rule.type !== 'style') return style;
  5067.  
  5068. for (var prop in style) {
  5069. style[prop] = iterate(prop, style[prop], camelCasedOptions);
  5070. }
  5071.  
  5072. return style;
  5073. }
  5074.  
  5075. function onChangeValue(value, prop) {
  5076. return iterate(prop, value, camelCasedOptions);
  5077. }
  5078.  
  5079. return {
  5080. onProcessStyle: onProcessStyle,
  5081. onChangeValue: onChangeValue
  5082. };
  5083. }
  5084.  
  5085. var js = '';
  5086. var css = '';
  5087. var vendor = '';
  5088. var browser = '';
  5089. var isTouch = isBrowser$1 && 'ontouchstart' in document.documentElement; // We should not do anything if required serverside.
  5090.  
  5091. if (isBrowser$1) {
  5092. // Order matters. We need to check Webkit the last one because
  5093. // other vendors use to add Webkit prefixes to some properties
  5094. var jsCssMap = {
  5095. Moz: '-moz-',
  5096. ms: '-ms-',
  5097. O: '-o-',
  5098. Webkit: '-webkit-'
  5099. };
  5100.  
  5101. var _document$createEleme = document.createElement('p'),
  5102. style = _document$createEleme.style;
  5103.  
  5104. var testProp = 'Transform';
  5105.  
  5106. for (var key in jsCssMap) {
  5107. if (key + testProp in style) {
  5108. js = key;
  5109. css = jsCssMap[key];
  5110. break;
  5111. }
  5112. } // Correctly detect the Edge browser.
  5113.  
  5114.  
  5115. if (js === 'Webkit' && 'msHyphens' in style) {
  5116. js = 'ms';
  5117. css = jsCssMap.ms;
  5118. browser = 'edge';
  5119. } // Correctly detect the Safari browser.
  5120.  
  5121.  
  5122. if (js === 'Webkit' && '-apple-trailing-word' in style) {
  5123. vendor = 'apple';
  5124. }
  5125. }
  5126. /**
  5127. * Vendor prefix string for the current browser.
  5128. *
  5129. * @type {{js: String, css: String, vendor: String, browser: String}}
  5130. * @api public
  5131. */
  5132.  
  5133.  
  5134. var prefix = {
  5135. js: js,
  5136. css: css,
  5137. vendor: vendor,
  5138. browser: browser,
  5139. isTouch: isTouch
  5140. };
  5141. /**
  5142. * Test if a keyframe at-rule should be prefixed or not
  5143. *
  5144. * @param {String} vendor prefix string for the current browser.
  5145. * @return {String}
  5146. * @api public
  5147. */
  5148.  
  5149. function supportedKeyframes(key) {
  5150. // Keyframes is already prefixed. e.g. key = '@-webkit-keyframes a'
  5151. if (key[1] === '-') return key; // No need to prefix IE/Edge. Older browsers will ignore unsupported rules.
  5152. // https://caniuse.com/#search=keyframes
  5153.  
  5154. if (prefix.js === 'ms') return key;
  5155. return "@" + prefix.css + "keyframes" + key.substr(10);
  5156. } // https://caniuse.com/#search=appearance
  5157.  
  5158.  
  5159. var appearence = {
  5160. noPrefill: ['appearance'],
  5161. supportedProperty: function supportedProperty(prop) {
  5162. if (prop !== 'appearance') return false;
  5163. if (prefix.js === 'ms') return "-webkit-" + prop;
  5164. return prefix.css + prop;
  5165. }
  5166. }; // https://caniuse.com/#search=color-adjust
  5167.  
  5168. var colorAdjust = {
  5169. noPrefill: ['color-adjust'],
  5170. supportedProperty: function supportedProperty(prop) {
  5171. if (prop !== 'color-adjust') return false;
  5172. if (prefix.js === 'Webkit') return prefix.css + "print-" + prop;
  5173. return prop;
  5174. }
  5175. };
  5176. var regExp = /[-\s]+(.)?/g;
  5177. /**
  5178. * Replaces the letter with the capital letter
  5179. *
  5180. * @param {String} match
  5181. * @param {String} c
  5182. * @return {String}
  5183. * @api private
  5184. */
  5185.  
  5186. function toUpper(match, c) {
  5187. return c ? c.toUpperCase() : '';
  5188. }
  5189. /**
  5190. * Convert dash separated strings to camel-cased.
  5191. *
  5192. * @param {String} str
  5193. * @return {String}
  5194. * @api private
  5195. */
  5196.  
  5197.  
  5198. function camelize(str) {
  5199. return str.replace(regExp, toUpper);
  5200. }
  5201. /**
  5202. * Convert dash separated strings to pascal cased.
  5203. *
  5204. * @param {String} str
  5205. * @return {String}
  5206. * @api private
  5207. */
  5208.  
  5209.  
  5210. function pascalize(str) {
  5211. return camelize("-" + str);
  5212. } // but we can use a longhand property instead.
  5213. // https://caniuse.com/#search=mask
  5214.  
  5215.  
  5216. var mask = {
  5217. noPrefill: ['mask'],
  5218. supportedProperty: function supportedProperty(prop, style) {
  5219. if (!/^mask/.test(prop)) return false;
  5220.  
  5221. if (prefix.js === 'Webkit') {
  5222. var longhand = 'mask-image';
  5223.  
  5224. if (camelize(longhand) in style) {
  5225. return prop;
  5226. }
  5227.  
  5228. if (prefix.js + pascalize(longhand) in style) {
  5229. return prefix.css + prop;
  5230. }
  5231. }
  5232.  
  5233. return prop;
  5234. }
  5235. }; // https://caniuse.com/#search=text-orientation
  5236.  
  5237. var textOrientation = {
  5238. noPrefill: ['text-orientation'],
  5239. supportedProperty: function supportedProperty(prop) {
  5240. if (prop !== 'text-orientation') return false;
  5241.  
  5242. if (prefix.vendor === 'apple' && !prefix.isTouch) {
  5243. return prefix.css + prop;
  5244. }
  5245.  
  5246. return prop;
  5247. }
  5248. }; // https://caniuse.com/#search=transform
  5249.  
  5250. var transform = {
  5251. noPrefill: ['transform'],
  5252. supportedProperty: function supportedProperty(prop, style, options) {
  5253. if (prop !== 'transform') return false;
  5254.  
  5255. if (options.transform) {
  5256. return prop;
  5257. }
  5258.  
  5259. return prefix.css + prop;
  5260. }
  5261. }; // https://caniuse.com/#search=transition
  5262.  
  5263. var transition = {
  5264. noPrefill: ['transition'],
  5265. supportedProperty: function supportedProperty(prop, style, options) {
  5266. if (prop !== 'transition') return false;
  5267.  
  5268. if (options.transition) {
  5269. return prop;
  5270. }
  5271.  
  5272. return prefix.css + prop;
  5273. }
  5274. }; // https://caniuse.com/#search=writing-mode
  5275.  
  5276. var writingMode = {
  5277. noPrefill: ['writing-mode'],
  5278. supportedProperty: function supportedProperty(prop) {
  5279. if (prop !== 'writing-mode') return false;
  5280.  
  5281. if (prefix.js === 'Webkit' || prefix.js === 'ms' && prefix.browser !== 'edge') {
  5282. return prefix.css + prop;
  5283. }
  5284.  
  5285. return prop;
  5286. }
  5287. }; // https://caniuse.com/#search=user-select
  5288.  
  5289. var userSelect = {
  5290. noPrefill: ['user-select'],
  5291. supportedProperty: function supportedProperty(prop) {
  5292. if (prop !== 'user-select') return false;
  5293.  
  5294. if (prefix.js === 'Moz' || prefix.js === 'ms' || prefix.vendor === 'apple') {
  5295. return prefix.css + prop;
  5296. }
  5297.  
  5298. return prop;
  5299. }
  5300. }; // https://caniuse.com/#search=multicolumn
  5301. // https://github.com/postcss/autoprefixer/issues/491
  5302. // https://github.com/postcss/autoprefixer/issues/177
  5303.  
  5304. var breakPropsOld = {
  5305. supportedProperty: function supportedProperty(prop, style) {
  5306. if (!/^break-/.test(prop)) return false;
  5307.  
  5308. if (prefix.js === 'Webkit') {
  5309. var jsProp = "WebkitColumn" + pascalize(prop);
  5310. return jsProp in style ? prefix.css + "column-" + prop : false;
  5311. }
  5312.  
  5313. if (prefix.js === 'Moz') {
  5314. var _jsProp = "page" + pascalize(prop);
  5315.  
  5316. return _jsProp in style ? "page-" + prop : false;
  5317. }
  5318.  
  5319. return false;
  5320. }
  5321. }; // See https://github.com/postcss/autoprefixer/issues/324.
  5322.  
  5323. var inlineLogicalOld = {
  5324. supportedProperty: function supportedProperty(prop, style) {
  5325. if (!/^(border|margin|padding)-inline/.test(prop)) return false;
  5326. if (prefix.js === 'Moz') return prop;
  5327. var newProp = prop.replace('-inline', '');
  5328. return prefix.js + pascalize(newProp) in style ? prefix.css + newProp : false;
  5329. }
  5330. }; // Camelization is required because we can't test using.
  5331. // CSS syntax for e.g. in FF.
  5332.  
  5333. var unprefixed = {
  5334. supportedProperty: function supportedProperty(prop, style) {
  5335. return camelize(prop) in style ? prop : false;
  5336. }
  5337. };
  5338. var prefixed = {
  5339. supportedProperty: function supportedProperty(prop, style) {
  5340. var pascalized = pascalize(prop); // Return custom CSS variable without prefixing.
  5341.  
  5342. if (prop[0] === '-') return prop; // Return already prefixed value without prefixing.
  5343.  
  5344. if (prop[0] === '-' && prop[1] === '-') return prop;
  5345. if (prefix.js + pascalized in style) return prefix.css + prop; // Try webkit fallback.
  5346.  
  5347. if (prefix.js !== 'Webkit' && "Webkit" + pascalized in style) return "-webkit-" + prop;
  5348. return false;
  5349. }
  5350. }; // https://caniuse.com/#search=scroll-snap
  5351.  
  5352. var scrollSnap = {
  5353. supportedProperty: function supportedProperty(prop) {
  5354. if (prop.substring(0, 11) !== 'scroll-snap') return false;
  5355.  
  5356. if (prefix.js === 'ms') {
  5357. return "" + prefix.css + prop;
  5358. }
  5359.  
  5360. return prop;
  5361. }
  5362. }; // https://caniuse.com/#search=overscroll-behavior
  5363.  
  5364. var overscrollBehavior = {
  5365. supportedProperty: function supportedProperty(prop) {
  5366. if (prop !== 'overscroll-behavior') return false;
  5367.  
  5368. if (prefix.js === 'ms') {
  5369. return prefix.css + "scroll-chaining";
  5370. }
  5371.  
  5372. return prop;
  5373. }
  5374. };
  5375. var propMap = {
  5376. 'flex-grow': 'flex-positive',
  5377. 'flex-shrink': 'flex-negative',
  5378. 'flex-basis': 'flex-preferred-size',
  5379. 'justify-content': 'flex-pack',
  5380. order: 'flex-order',
  5381. 'align-items': 'flex-align',
  5382. 'align-content': 'flex-line-pack' // 'align-self' is handled by 'align-self' plugin.
  5383.  
  5384. }; // Support old flex spec from 2012.
  5385.  
  5386. var flex2012 = {
  5387. supportedProperty: function supportedProperty(prop, style) {
  5388. var newProp = propMap[prop];
  5389. if (!newProp) return false;
  5390. return prefix.js + pascalize(newProp) in style ? prefix.css + newProp : false;
  5391. }
  5392. };
  5393. var propMap$1 = {
  5394. flex: 'box-flex',
  5395. 'flex-grow': 'box-flex',
  5396. 'flex-direction': ['box-orient', 'box-direction'],
  5397. order: 'box-ordinal-group',
  5398. 'align-items': 'box-align',
  5399. 'flex-flow': ['box-orient', 'box-direction'],
  5400. 'justify-content': 'box-pack'
  5401. };
  5402. var propKeys = Object.keys(propMap$1);
  5403.  
  5404. var prefixCss = function prefixCss(p) {
  5405. return prefix.css + p;
  5406. }; // Support old flex spec from 2009.
  5407.  
  5408.  
  5409. var flex2009 = {
  5410. supportedProperty: function supportedProperty(prop, style, _ref) {
  5411. var multiple = _ref.multiple;
  5412.  
  5413. if (propKeys.indexOf(prop) > -1) {
  5414. var newProp = propMap$1[prop];
  5415.  
  5416. if (!Array.isArray(newProp)) {
  5417. return prefix.js + pascalize(newProp) in style ? prefix.css + newProp : false;
  5418. }
  5419.  
  5420. if (!multiple) return false;
  5421.  
  5422. for (var i = 0; i < newProp.length; i++) {
  5423. if (!(prefix.js + pascalize(newProp[0]) in style)) {
  5424. return false;
  5425. }
  5426. }
  5427.  
  5428. return newProp.map(prefixCss);
  5429. }
  5430.  
  5431. return false;
  5432. }
  5433. }; // plugins = [
  5434. // ...plugins,
  5435. // breakPropsOld,
  5436. // inlineLogicalOld,
  5437. // unprefixed,
  5438. // prefixed,
  5439. // scrollSnap,
  5440. // flex2012,
  5441. // flex2009
  5442. // ]
  5443. // Plugins without 'noPrefill' value, going last.
  5444. // 'flex-*' plugins should be at the bottom.
  5445. // 'flex2009' going after 'flex2012'.
  5446. // 'prefixed' going after 'unprefixed'
  5447.  
  5448. var plugins = [appearence, colorAdjust, mask, textOrientation, transform, transition, writingMode, userSelect, breakPropsOld, inlineLogicalOld, unprefixed, prefixed, scrollSnap, overscrollBehavior, flex2012, flex2009];
  5449. var propertyDetectors = plugins.filter(function (p) {
  5450. return p.supportedProperty;
  5451. }).map(function (p) {
  5452. return p.supportedProperty;
  5453. });
  5454. var noPrefill = plugins.filter(function (p) {
  5455. return p.noPrefill;
  5456. }).reduce(function (a, p) {
  5457. a.push.apply(a, _toConsumableArray(p.noPrefill));
  5458. return a;
  5459. }, []);
  5460. var el;
  5461. var cache = {};
  5462.  
  5463. if (isBrowser$1) {
  5464. el = document.createElement('p'); // We test every property on vendor prefix requirement.
  5465. // Once tested, result is cached. It gives us up to 70% perf boost.
  5466. // http://jsperf.com/element-style-object-access-vs-plain-object
  5467. //
  5468. // Prefill cache with known css properties to reduce amount of
  5469. // properties we need to feature test at runtime.
  5470. // http://davidwalsh.name/vendor-prefix
  5471.  
  5472. var computed = window.getComputedStyle(document.documentElement, '');
  5473.  
  5474. for (var key$1 in computed) {
  5475. // eslint-disable-next-line no-restricted-globals
  5476. if (!isNaN(key$1)) cache[computed[key$1]] = computed[key$1];
  5477. } // Properties that cannot be correctly detected using the
  5478. // cache prefill method.
  5479.  
  5480.  
  5481. noPrefill.forEach(function (x) {
  5482. return delete cache[x];
  5483. });
  5484. }
  5485. /**
  5486. * Test if a property is supported, returns supported property with vendor
  5487. * prefix if required. Returns `false` if not supported.
  5488. *
  5489. * @param {String} prop dash separated
  5490. * @param {Object} [options]
  5491. * @return {String|Boolean}
  5492. * @api public
  5493. */
  5494.  
  5495.  
  5496. function supportedProperty(prop, options) {
  5497. if (options === void 0) {
  5498. options = {};
  5499. } // For server-side rendering.
  5500.  
  5501.  
  5502. if (!el) return prop; // Remove cache for benchmark tests or return property from the cache.
  5503.  
  5504. if (cache[prop] != null) {
  5505. return cache[prop];
  5506. } // Check if 'transition' or 'transform' natively supported in browser.
  5507.  
  5508.  
  5509. if (prop === 'transition' || prop === 'transform') {
  5510. options[prop] = prop in el.style;
  5511. } // Find a plugin for current prefix property.
  5512.  
  5513.  
  5514. for (var i = 0; i < propertyDetectors.length; i++) {
  5515. cache[prop] = propertyDetectors[i](prop, el.style, options); // Break loop, if value found.
  5516.  
  5517. if (cache[prop]) break;
  5518. } // Reset styles for current property.
  5519. // Firefox can even throw an error for invalid properties, e.g., "0".
  5520.  
  5521.  
  5522. try {
  5523. el.style[prop] = '';
  5524. } catch (err) {
  5525. return false;
  5526. }
  5527.  
  5528. return cache[prop];
  5529. }
  5530.  
  5531. var cache$1 = {};
  5532. var transitionProperties = {
  5533. transition: 1,
  5534. 'transition-property': 1,
  5535. '-webkit-transition': 1,
  5536. '-webkit-transition-property': 1
  5537. };
  5538. var transPropsRegExp = /(^\s*[\w-]+)|, (\s*[\w-]+)(?![^()]*\))/g;
  5539. var el$1;
  5540. /**
  5541. * Returns prefixed value transition/transform if needed.
  5542. *
  5543. * @param {String} match
  5544. * @param {String} p1
  5545. * @param {String} p2
  5546. * @return {String}
  5547. * @api private
  5548. */
  5549.  
  5550. function prefixTransitionCallback(match, p1, p2) {
  5551. if (p1 === 'var') return 'var';
  5552. if (p1 === 'all') return 'all';
  5553. if (p2 === 'all') return ', all';
  5554. var prefixedValue = p1 ? supportedProperty(p1) : ", " + supportedProperty(p2);
  5555. if (!prefixedValue) return p1 || p2;
  5556. return prefixedValue;
  5557. }
  5558.  
  5559. if (isBrowser$1) el$1 = document.createElement('p');
  5560. /**
  5561. * Returns prefixed value if needed. Returns `false` if value is not supported.
  5562. *
  5563. * @param {String} property
  5564. * @param {String} value
  5565. * @return {String|Boolean}
  5566. * @api public
  5567. */
  5568.  
  5569. function supportedValue(property, value) {
  5570. // For server-side rendering.
  5571. var prefixedValue = value;
  5572. if (!el$1 || property === 'content') return value; // It is a string or a number as a string like '1'.
  5573. // We want only prefixable values here.
  5574. // eslint-disable-next-line no-restricted-globals
  5575.  
  5576. if (typeof prefixedValue !== 'string' || !isNaN(parseInt(prefixedValue, 10))) {
  5577. return prefixedValue;
  5578. } // Create cache key for current value.
  5579.  
  5580.  
  5581. var cacheKey = property + prefixedValue; // Remove cache for benchmark tests or return value from cache.
  5582.  
  5583. if (cache$1[cacheKey] != null) {
  5584. return cache$1[cacheKey];
  5585. } // IE can even throw an error in some cases, for e.g. style.content = 'bar'.
  5586.  
  5587.  
  5588. try {
  5589. // Test value as it is.
  5590. el$1.style[property] = prefixedValue;
  5591. } catch (err) {
  5592. // Return false if value not supported.
  5593. cache$1[cacheKey] = false;
  5594. return false;
  5595. } // If 'transition' or 'transition-property' property.
  5596.  
  5597.  
  5598. if (transitionProperties[property]) {
  5599. prefixedValue = prefixedValue.replace(transPropsRegExp, prefixTransitionCallback);
  5600. } else if (el$1.style[property] === '') {
  5601. // Value with a vendor prefix.
  5602. prefixedValue = prefix.css + prefixedValue; // Hardcode test to convert "flex" to "-ms-flexbox" for IE10.
  5603.  
  5604. if (prefixedValue === '-ms-flex') el$1.style[property] = '-ms-flexbox'; // Test prefixed value.
  5605.  
  5606. el$1.style[property] = prefixedValue; // Return false if value not supported.
  5607.  
  5608. if (el$1.style[property] === '') {
  5609. cache$1[cacheKey] = false;
  5610. return false;
  5611. }
  5612. } // Reset styles for current property.
  5613.  
  5614.  
  5615. el$1.style[property] = ''; // Write current value to cache.
  5616.  
  5617. cache$1[cacheKey] = prefixedValue;
  5618. return cache$1[cacheKey];
  5619. }
  5620.  
  5621. /**
  5622. * Add vendor prefix to a property name when needed.
  5623. *
  5624. * @api public
  5625. */
  5626.  
  5627. function jssVendorPrefixer() {
  5628. function onProcessRule(rule) {
  5629. if (rule.type === 'keyframes') {
  5630. var atRule = rule;
  5631. atRule.at = supportedKeyframes(atRule.at);
  5632. }
  5633. }
  5634.  
  5635. function prefixStyle(style) {
  5636. for (var prop in style) {
  5637. var value = style[prop];
  5638.  
  5639. if (prop === 'fallbacks' && Array.isArray(value)) {
  5640. style[prop] = value.map(prefixStyle);
  5641. continue;
  5642. }
  5643.  
  5644. var changeProp = false;
  5645. var supportedProp = supportedProperty(prop);
  5646. if (supportedProp && supportedProp !== prop) changeProp = true;
  5647. var changeValue = false;
  5648. var supportedValue$1 = supportedValue(supportedProp, toCssValue(value));
  5649. if (supportedValue$1 && supportedValue$1 !== value) changeValue = true;
  5650.  
  5651. if (changeProp || changeValue) {
  5652. if (changeProp) delete style[prop];
  5653. style[supportedProp || prop] = supportedValue$1 || value;
  5654. }
  5655. }
  5656.  
  5657. return style;
  5658. }
  5659.  
  5660. function onProcessStyle(style, rule) {
  5661. if (rule.type !== 'style') return style;
  5662. return prefixStyle(style);
  5663. }
  5664.  
  5665. function onChangeValue(value, prop) {
  5666. return supportedValue(prop, toCssValue(value)) || value;
  5667. }
  5668.  
  5669. return {
  5670. onProcessRule: onProcessRule,
  5671. onProcessStyle: onProcessStyle,
  5672. onChangeValue: onChangeValue
  5673. };
  5674. }
  5675.  
  5676. /**
  5677. * Sort props by length.
  5678. */
  5679. function jssPropsSort() {
  5680. var sort = function sort(prop0, prop1) {
  5681. if (prop0.length === prop1.length) {
  5682. return prop0 > prop1 ? 1 : -1;
  5683. }
  5684.  
  5685. return prop0.length - prop1.length;
  5686. };
  5687.  
  5688. return {
  5689. onProcessStyle: function onProcessStyle(style, rule) {
  5690. if (rule.type !== 'style') return style;
  5691. var newStyle = {};
  5692. var props = Object.keys(style).sort(sort);
  5693.  
  5694. for (var i = 0; i < props.length; i++) {
  5695. newStyle[props[i]] = style[props[i]];
  5696. }
  5697.  
  5698. return newStyle;
  5699. }
  5700. };
  5701. }
  5702.  
  5703. function jssPreset() {
  5704. return {
  5705. plugins: [functionPlugin(), jssGlobal(), jssNested(), camelCase(), defaultUnit(), // Disable the vendor prefixer server-side, it does nothing.
  5706. // This way, we can get a performance boost.
  5707. // In the documentation, we are using `autoprefixer` to solve this problem.
  5708. typeof window === 'undefined' ? null : jssVendorPrefixer(), jssPropsSort()]
  5709. };
  5710. }
  5711.  
  5712. function mergeClasses() {
  5713. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5714. var baseClasses = options.baseClasses,
  5715. newClasses = options.newClasses;
  5716. options.Component;
  5717.  
  5718. if (!newClasses) {
  5719. return baseClasses;
  5720. }
  5721.  
  5722. var nextClasses = _extends$1({}, baseClasses);
  5723.  
  5724. Object.keys(newClasses).forEach(function (key) {
  5725.  
  5726. if (newClasses[key]) {
  5727. nextClasses[key] = "".concat(baseClasses[key], " ").concat(newClasses[key]);
  5728. }
  5729. });
  5730. return nextClasses;
  5731. }
  5732.  
  5733. // Used https://github.com/thinkloop/multi-key-cache as inspiration
  5734. var multiKeyStore = {
  5735. set: function set(cache, key1, key2, value) {
  5736. var subCache = cache.get(key1);
  5737.  
  5738. if (!subCache) {
  5739. subCache = new Map();
  5740. cache.set(key1, subCache);
  5741. }
  5742.  
  5743. subCache.set(key2, value);
  5744. },
  5745. get: function get(cache, key1, key2) {
  5746. var subCache = cache.get(key1);
  5747. return subCache ? subCache.get(key2) : undefined;
  5748. },
  5749. delete: function _delete(cache, key1, key2) {
  5750. var subCache = cache.get(key1);
  5751. subCache.delete(key2);
  5752. }
  5753. };
  5754.  
  5755. var ThemeContext = /*#__PURE__*/React__default['default'].createContext(null);
  5756.  
  5757. function useTheme$1() {
  5758. var theme = React__default['default'].useContext(ThemeContext);
  5759.  
  5760. return theme;
  5761. }
  5762.  
  5763. var jss = create(jssPreset()); // Use a singleton or the provided one by the context.
  5764. //
  5765. // The counter-based approach doesn't tolerate any mistake.
  5766. // It's much safer to use the same counter everywhere.
  5767.  
  5768. var generateClassName = createGenerateClassName(); // Exported for test purposes
  5769.  
  5770. var sheetsManager = new Map();
  5771. var defaultOptions = {
  5772. disableGeneration: false,
  5773. generateClassName: generateClassName,
  5774. jss: jss,
  5775. sheetsCache: null,
  5776. sheetsManager: sheetsManager,
  5777. sheetsRegistry: null
  5778. };
  5779. var StylesContext = /*#__PURE__*/React__default['default'].createContext(defaultOptions);
  5780.  
  5781. /* eslint-disable import/prefer-default-export */
  5782. // Global index counter to preserve source order.
  5783. // We create the style sheet during the creation of the component,
  5784. // children are handled after the parents, so the order of style elements would be parent->child.
  5785. // It is a problem though when a parent passes a className
  5786. // which needs to override any child's styles.
  5787. // StyleSheet of the child has a higher specificity, because of the source order.
  5788. // So our solution is to render sheets them in the reverse order child->sheet, so
  5789. // that parent has a higher specificity.
  5790. var indexCounter = -1e9;
  5791. function increment() {
  5792. indexCounter += 1;
  5793.  
  5794. return indexCounter;
  5795. }
  5796.  
  5797. // We use the same empty object to ref count the styles that don't need a theme object.
  5798. var noopTheme = {};
  5799.  
  5800. function getStylesCreator(stylesOrCreator) {
  5801. var themingEnabled = typeof stylesOrCreator === 'function';
  5802.  
  5803. return {
  5804. create: function create(theme, name) {
  5805. var styles;
  5806.  
  5807. try {
  5808. styles = themingEnabled ? stylesOrCreator(theme) : stylesOrCreator;
  5809. } catch (err) {
  5810.  
  5811. throw err;
  5812. }
  5813.  
  5814. if (!name || !theme.overrides || !theme.overrides[name]) {
  5815. return styles;
  5816. }
  5817.  
  5818. var overrides = theme.overrides[name];
  5819.  
  5820. var stylesWithOverrides = _extends$1({}, styles);
  5821.  
  5822. Object.keys(overrides).forEach(function (key) {
  5823.  
  5824. stylesWithOverrides[key] = deepmerge(stylesWithOverrides[key], overrides[key]);
  5825. });
  5826. return stylesWithOverrides;
  5827. },
  5828. options: {}
  5829. };
  5830. }
  5831.  
  5832. function getClasses(_ref, classes, Component) {
  5833. var state = _ref.state,
  5834. stylesOptions = _ref.stylesOptions;
  5835.  
  5836. if (stylesOptions.disableGeneration) {
  5837. return classes || {};
  5838. }
  5839.  
  5840. if (!state.cacheClasses) {
  5841. state.cacheClasses = {
  5842. // Cache for the finalized classes value.
  5843. value: null,
  5844. // Cache for the last used classes prop pointer.
  5845. lastProp: null,
  5846. // Cache for the last used rendered classes pointer.
  5847. lastJSS: {}
  5848. };
  5849. } // Tracks if either the rendered classes or classes prop has changed,
  5850. // requiring the generation of a new finalized classes object.
  5851.  
  5852.  
  5853. var generate = false;
  5854.  
  5855. if (state.classes !== state.cacheClasses.lastJSS) {
  5856. state.cacheClasses.lastJSS = state.classes;
  5857. generate = true;
  5858. }
  5859.  
  5860. if (classes !== state.cacheClasses.lastProp) {
  5861. state.cacheClasses.lastProp = classes;
  5862. generate = true;
  5863. }
  5864.  
  5865. if (generate) {
  5866. state.cacheClasses.value = mergeClasses({
  5867. baseClasses: state.cacheClasses.lastJSS,
  5868. newClasses: classes,
  5869. Component: Component
  5870. });
  5871. }
  5872.  
  5873. return state.cacheClasses.value;
  5874. }
  5875.  
  5876. function attach(_ref2, props) {
  5877. var state = _ref2.state,
  5878. theme = _ref2.theme,
  5879. stylesOptions = _ref2.stylesOptions,
  5880. stylesCreator = _ref2.stylesCreator,
  5881. name = _ref2.name;
  5882.  
  5883. if (stylesOptions.disableGeneration) {
  5884. return;
  5885. }
  5886.  
  5887. var sheetManager = multiKeyStore.get(stylesOptions.sheetsManager, stylesCreator, theme);
  5888.  
  5889. if (!sheetManager) {
  5890. sheetManager = {
  5891. refs: 0,
  5892. staticSheet: null,
  5893. dynamicStyles: null
  5894. };
  5895. multiKeyStore.set(stylesOptions.sheetsManager, stylesCreator, theme, sheetManager);
  5896. }
  5897.  
  5898. var options = _extends$1({}, stylesCreator.options, stylesOptions, {
  5899. theme: theme,
  5900. flip: typeof stylesOptions.flip === 'boolean' ? stylesOptions.flip : theme.direction === 'rtl'
  5901. });
  5902.  
  5903. options.generateId = options.serverGenerateClassName || options.generateClassName;
  5904. var sheetsRegistry = stylesOptions.sheetsRegistry;
  5905.  
  5906. if (sheetManager.refs === 0) {
  5907. var staticSheet;
  5908.  
  5909. if (stylesOptions.sheetsCache) {
  5910. staticSheet = multiKeyStore.get(stylesOptions.sheetsCache, stylesCreator, theme);
  5911. }
  5912.  
  5913. var styles = stylesCreator.create(theme, name);
  5914.  
  5915. if (!staticSheet) {
  5916. staticSheet = stylesOptions.jss.createStyleSheet(styles, _extends$1({
  5917. link: false
  5918. }, options));
  5919. staticSheet.attach();
  5920.  
  5921. if (stylesOptions.sheetsCache) {
  5922. multiKeyStore.set(stylesOptions.sheetsCache, stylesCreator, theme, staticSheet);
  5923. }
  5924. }
  5925.  
  5926. if (sheetsRegistry) {
  5927. sheetsRegistry.add(staticSheet);
  5928. }
  5929.  
  5930. sheetManager.staticSheet = staticSheet;
  5931. sheetManager.dynamicStyles = getDynamicStyles(styles);
  5932. }
  5933.  
  5934. if (sheetManager.dynamicStyles) {
  5935. var dynamicSheet = stylesOptions.jss.createStyleSheet(sheetManager.dynamicStyles, _extends$1({
  5936. link: true
  5937. }, options));
  5938. dynamicSheet.update(props);
  5939. dynamicSheet.attach();
  5940. state.dynamicSheet = dynamicSheet;
  5941. state.classes = mergeClasses({
  5942. baseClasses: sheetManager.staticSheet.classes,
  5943. newClasses: dynamicSheet.classes
  5944. });
  5945.  
  5946. if (sheetsRegistry) {
  5947. sheetsRegistry.add(dynamicSheet);
  5948. }
  5949. } else {
  5950. state.classes = sheetManager.staticSheet.classes;
  5951. }
  5952.  
  5953. sheetManager.refs += 1;
  5954. }
  5955.  
  5956. function update$1(_ref3, props) {
  5957. var state = _ref3.state;
  5958.  
  5959. if (state.dynamicSheet) {
  5960. state.dynamicSheet.update(props);
  5961. }
  5962. }
  5963.  
  5964. function detach(_ref4) {
  5965. var state = _ref4.state,
  5966. theme = _ref4.theme,
  5967. stylesOptions = _ref4.stylesOptions,
  5968. stylesCreator = _ref4.stylesCreator;
  5969.  
  5970. if (stylesOptions.disableGeneration) {
  5971. return;
  5972. }
  5973.  
  5974. var sheetManager = multiKeyStore.get(stylesOptions.sheetsManager, stylesCreator, theme);
  5975. sheetManager.refs -= 1;
  5976. var sheetsRegistry = stylesOptions.sheetsRegistry;
  5977.  
  5978. if (sheetManager.refs === 0) {
  5979. multiKeyStore.delete(stylesOptions.sheetsManager, stylesCreator, theme);
  5980. stylesOptions.jss.removeStyleSheet(sheetManager.staticSheet);
  5981.  
  5982. if (sheetsRegistry) {
  5983. sheetsRegistry.remove(sheetManager.staticSheet);
  5984. }
  5985. }
  5986.  
  5987. if (state.dynamicSheet) {
  5988. stylesOptions.jss.removeStyleSheet(state.dynamicSheet);
  5989.  
  5990. if (sheetsRegistry) {
  5991. sheetsRegistry.remove(state.dynamicSheet);
  5992. }
  5993. }
  5994. }
  5995.  
  5996. function useSynchronousEffect(func, values) {
  5997. var key = React__default['default'].useRef([]);
  5998. var output; // Store "generation" key. Just returns a new object every time
  5999.  
  6000. var currentKey = React__default['default'].useMemo(function () {
  6001. return {};
  6002. }, values); // eslint-disable-line react-hooks/exhaustive-deps
  6003. // "the first render", or "memo dropped the value"
  6004.  
  6005. if (key.current !== currentKey) {
  6006. key.current = currentKey;
  6007. output = func();
  6008. }
  6009.  
  6010. React__default['default'].useEffect(function () {
  6011. return function () {
  6012. if (output) {
  6013. output();
  6014. }
  6015. };
  6016. }, [currentKey] // eslint-disable-line react-hooks/exhaustive-deps
  6017. );
  6018. }
  6019.  
  6020. function makeStyles$1(stylesOrCreator) {
  6021. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6022.  
  6023. var name = options.name,
  6024. classNamePrefixOption = options.classNamePrefix,
  6025. Component = options.Component,
  6026. _options$defaultTheme = options.defaultTheme,
  6027. defaultTheme = _options$defaultTheme === void 0 ? noopTheme : _options$defaultTheme,
  6028. stylesOptions2 = _objectWithoutProperties(options, ["name", "classNamePrefix", "Component", "defaultTheme"]);
  6029.  
  6030. var stylesCreator = getStylesCreator(stylesOrCreator);
  6031. var classNamePrefix = name || classNamePrefixOption || 'makeStyles';
  6032. stylesCreator.options = {
  6033. index: increment(),
  6034. name: name,
  6035. meta: classNamePrefix,
  6036. classNamePrefix: classNamePrefix
  6037. };
  6038.  
  6039. var useStyles = function useStyles() {
  6040. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  6041. var theme = useTheme$1() || defaultTheme;
  6042.  
  6043. var stylesOptions = _extends$1({}, React__default['default'].useContext(StylesContext), stylesOptions2);
  6044.  
  6045. var instance = React__default['default'].useRef();
  6046. var shouldUpdate = React__default['default'].useRef();
  6047. useSynchronousEffect(function () {
  6048. var current = {
  6049. name: name,
  6050. state: {},
  6051. stylesCreator: stylesCreator,
  6052. stylesOptions: stylesOptions,
  6053. theme: theme
  6054. };
  6055. attach(current, props);
  6056. shouldUpdate.current = false;
  6057. instance.current = current;
  6058. return function () {
  6059. detach(current);
  6060. };
  6061. }, [theme, stylesCreator]);
  6062. React__default['default'].useEffect(function () {
  6063. if (shouldUpdate.current) {
  6064. update$1(instance.current, props);
  6065. }
  6066.  
  6067. shouldUpdate.current = true;
  6068. });
  6069. var classes = getClasses(instance.current, props.classes, Component);
  6070.  
  6071. return classes;
  6072. };
  6073.  
  6074. return useStyles;
  6075. }
  6076.  
  6077. function toVal(mix) {
  6078. var k,
  6079. y,
  6080. str = '';
  6081.  
  6082. if (typeof mix === 'string' || typeof mix === 'number') {
  6083. str += mix;
  6084. } else if (typeof mix === 'object') {
  6085. if (Array.isArray(mix)) {
  6086. for (k = 0; k < mix.length; k++) {
  6087. if (mix[k]) {
  6088. if (y = toVal(mix[k])) {
  6089. str && (str += ' ');
  6090. str += y;
  6091. }
  6092. }
  6093. }
  6094. } else {
  6095. for (k in mix) {
  6096. if (mix[k]) {
  6097. str && (str += ' ');
  6098. str += k;
  6099. }
  6100. }
  6101. }
  6102. }
  6103.  
  6104. return str;
  6105. }
  6106.  
  6107. function clsx () {
  6108. var i = 0,
  6109. tmp,
  6110. x,
  6111. str = '';
  6112.  
  6113. while (i < arguments.length) {
  6114. if (tmp = arguments[i++]) {
  6115. if (x = toVal(tmp)) {
  6116. str && (str += ' ');
  6117. str += x;
  6118. }
  6119. }
  6120. }
  6121.  
  6122. return str;
  6123. }
  6124.  
  6125. var reactIs = reactIs$1.exports;
  6126. /**
  6127. * Copyright 2015, Yahoo! Inc.
  6128. * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
  6129. */
  6130.  
  6131.  
  6132. var REACT_STATICS = {
  6133. childContextTypes: true,
  6134. contextType: true,
  6135. contextTypes: true,
  6136. defaultProps: true,
  6137. displayName: true,
  6138. getDefaultProps: true,
  6139. getDerivedStateFromError: true,
  6140. getDerivedStateFromProps: true,
  6141. mixins: true,
  6142. propTypes: true,
  6143. type: true
  6144. };
  6145. var KNOWN_STATICS = {
  6146. name: true,
  6147. length: true,
  6148. prototype: true,
  6149. caller: true,
  6150. callee: true,
  6151. arguments: true,
  6152. arity: true
  6153. };
  6154. var FORWARD_REF_STATICS = {
  6155. '$$typeof': true,
  6156. render: true,
  6157. defaultProps: true,
  6158. displayName: true,
  6159. propTypes: true
  6160. };
  6161. var MEMO_STATICS = {
  6162. '$$typeof': true,
  6163. compare: true,
  6164. defaultProps: true,
  6165. displayName: true,
  6166. propTypes: true,
  6167. type: true
  6168. };
  6169. var TYPE_STATICS = {};
  6170. TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
  6171. TYPE_STATICS[reactIs.Memo] = MEMO_STATICS;
  6172.  
  6173. function getStatics(component) {
  6174. // React v16.11 and below
  6175. if (reactIs.isMemo(component)) {
  6176. return MEMO_STATICS;
  6177. } // React v16.12 and above
  6178.  
  6179.  
  6180. return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
  6181. }
  6182.  
  6183. var defineProperty$1 = Object.defineProperty;
  6184. var getOwnPropertyNames = Object.getOwnPropertyNames;
  6185. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  6186. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  6187. var getPrototypeOf = Object.getPrototypeOf;
  6188. var objectPrototype = Object.prototype;
  6189.  
  6190. function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
  6191. if (typeof sourceComponent !== 'string') {
  6192. // don't hoist over string (html) components
  6193. if (objectPrototype) {
  6194. var inheritedComponent = getPrototypeOf(sourceComponent);
  6195.  
  6196. if (inheritedComponent && inheritedComponent !== objectPrototype) {
  6197. hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
  6198. }
  6199. }
  6200.  
  6201. var keys = getOwnPropertyNames(sourceComponent);
  6202.  
  6203. if (getOwnPropertySymbols) {
  6204. keys = keys.concat(getOwnPropertySymbols(sourceComponent));
  6205. }
  6206.  
  6207. var targetStatics = getStatics(targetComponent);
  6208. var sourceStatics = getStatics(sourceComponent);
  6209.  
  6210. for (var i = 0; i < keys.length; ++i) {
  6211. var key = keys[i];
  6212.  
  6213. if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
  6214. var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
  6215.  
  6216. try {
  6217. // Avoid failures from read-only properties
  6218. defineProperty$1(targetComponent, key, descriptor);
  6219. } catch (e) {}
  6220. }
  6221. }
  6222. }
  6223.  
  6224. return targetComponent;
  6225. }
  6226.  
  6227. var hoistNonReactStatics_cjs = hoistNonReactStatics;
  6228.  
  6229. function omit(input, fields) {
  6230. var output = {};
  6231. Object.keys(input).forEach(function (prop) {
  6232. if (fields.indexOf(prop) === -1) {
  6233. output[prop] = input[prop];
  6234. }
  6235. });
  6236. return output;
  6237. } // styled-components's API removes the mapping between components and styles.
  6238. // Using components as a low-level styling construct can be simpler.
  6239.  
  6240.  
  6241. function styled$1(Component) {
  6242. var componentCreator = function componentCreator(style) {
  6243. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6244.  
  6245. var name = options.name,
  6246. stylesOptions = _objectWithoutProperties(options, ["name"]);
  6247.  
  6248. var classNamePrefix = name;
  6249.  
  6250. var stylesOrCreator = typeof style === 'function' ? function (theme) {
  6251. return {
  6252. root: function root(props) {
  6253. return style(_extends$1({
  6254. theme: theme
  6255. }, props));
  6256. }
  6257. };
  6258. } : {
  6259. root: style
  6260. };
  6261. var useStyles = makeStyles$1(stylesOrCreator, _extends$1({
  6262. Component: Component,
  6263. name: name || Component.displayName,
  6264. classNamePrefix: classNamePrefix
  6265. }, stylesOptions));
  6266. var filterProps;
  6267.  
  6268. if (style.filterProps) {
  6269. filterProps = style.filterProps;
  6270. delete style.filterProps;
  6271. }
  6272. /* eslint-disable react/forbid-foreign-prop-types */
  6273.  
  6274.  
  6275. if (style.propTypes) {
  6276. delete style.propTypes;
  6277. }
  6278. /* eslint-enable react/forbid-foreign-prop-types */
  6279.  
  6280.  
  6281. var StyledComponent = /*#__PURE__*/React__default['default'].forwardRef(function StyledComponent(props, ref) {
  6282. var children = props.children,
  6283. classNameProp = props.className,
  6284. clone = props.clone,
  6285. ComponentProp = props.component,
  6286. other = _objectWithoutProperties(props, ["children", "className", "clone", "component"]);
  6287.  
  6288. var classes = useStyles(props);
  6289. var className = clsx(classes.root, classNameProp);
  6290. var spread = other;
  6291.  
  6292. if (filterProps) {
  6293. spread = omit(spread, filterProps);
  6294. }
  6295.  
  6296. if (clone) {
  6297. return /*#__PURE__*/React__default['default'].cloneElement(children, _extends$1({
  6298. className: clsx(children.props.className, className)
  6299. }, spread));
  6300. }
  6301.  
  6302. if (typeof children === 'function') {
  6303. return children(_extends$1({
  6304. className: className
  6305. }, spread));
  6306. }
  6307.  
  6308. var FinalComponent = ComponentProp || Component;
  6309. return /*#__PURE__*/React__default['default'].createElement(FinalComponent, _extends$1({
  6310. ref: ref,
  6311. className: className
  6312. }, spread), children);
  6313. });
  6314.  
  6315. hoistNonReactStatics_cjs(StyledComponent, Component);
  6316. return StyledComponent;
  6317. };
  6318.  
  6319. return componentCreator;
  6320. }
  6321.  
  6322. function mergeOuterLocalTheme(outerTheme, localTheme) {
  6323. if (typeof localTheme === 'function') {
  6324. var mergedTheme = localTheme(outerTheme);
  6325.  
  6326. return mergedTheme;
  6327. }
  6328.  
  6329. return _extends$1({}, outerTheme, localTheme);
  6330. }
  6331. /**
  6332. * This component takes a `theme` prop.
  6333. * It makes the `theme` available down the React tree thanks to React context.
  6334. * This component should preferably be used at **the root of your component tree**.
  6335. */
  6336.  
  6337.  
  6338. function ThemeProvider(props) {
  6339. var children = props.children,
  6340. localTheme = props.theme;
  6341. var outerTheme = useTheme$1();
  6342.  
  6343. var theme = React__default['default'].useMemo(function () {
  6344. var output = outerTheme === null ? localTheme : mergeOuterLocalTheme(outerTheme, localTheme);
  6345.  
  6346. if (output != null) {
  6347. output[nested] = outerTheme !== null;
  6348. }
  6349.  
  6350. return output;
  6351. }, [localTheme, outerTheme]);
  6352. return /*#__PURE__*/React__default['default'].createElement(ThemeContext.Provider, {
  6353. value: theme
  6354. }, children);
  6355. }
  6356.  
  6357. // It does not modify the component passed to it;
  6358. // instead, it returns a new component, with a `classes` property.
  6359.  
  6360. var withStyles$1 = function withStyles(stylesOrCreator) {
  6361. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6362. return function (Component) {
  6363. var defaultTheme = options.defaultTheme,
  6364. _options$withTheme = options.withTheme,
  6365. withTheme = _options$withTheme === void 0 ? false : _options$withTheme,
  6366. name = options.name,
  6367. stylesOptions = _objectWithoutProperties(options, ["defaultTheme", "withTheme", "name"]);
  6368.  
  6369. var classNamePrefix = name;
  6370.  
  6371. var useStyles = makeStyles$1(stylesOrCreator, _extends$1({
  6372. defaultTheme: defaultTheme,
  6373. Component: Component,
  6374. name: name || Component.displayName,
  6375. classNamePrefix: classNamePrefix
  6376. }, stylesOptions));
  6377. var WithStyles = /*#__PURE__*/React__default['default'].forwardRef(function WithStyles(props, ref) {
  6378. props.classes;
  6379. var innerRef = props.innerRef,
  6380. other = _objectWithoutProperties(props, ["classes", "innerRef"]); // The wrapper receives only user supplied props, which could be a subset of
  6381. // the actual props Component might receive due to merging with defaultProps.
  6382. // So copying it here would give us the same result in the wrapper as well.
  6383.  
  6384.  
  6385. var classes = useStyles(_extends$1({}, Component.defaultProps, props));
  6386. var theme;
  6387. var more = other;
  6388.  
  6389. if (typeof name === 'string' || withTheme) {
  6390. // name and withTheme are invariant in the outer scope
  6391. // eslint-disable-next-line react-hooks/rules-of-hooks
  6392. theme = useTheme$1() || defaultTheme;
  6393.  
  6394. if (name) {
  6395. more = getThemeProps({
  6396. theme: theme,
  6397. name: name,
  6398. props: other
  6399. });
  6400. } // Provide the theme to the wrapped component.
  6401. // So we don't have to use the `withTheme()` Higher-order Component.
  6402.  
  6403.  
  6404. if (withTheme && !more.theme) {
  6405. more.theme = theme;
  6406. }
  6407. }
  6408.  
  6409. return /*#__PURE__*/React__default['default'].createElement(Component, _extends$1({
  6410. ref: innerRef || ref,
  6411. classes: classes
  6412. }, more));
  6413. });
  6414.  
  6415. hoistNonReactStatics_cjs(WithStyles, Component);
  6416.  
  6417. return WithStyles;
  6418. };
  6419. };
  6420.  
  6421. // To remove in v5
  6422.  
  6423. function createStyles(styles) {
  6424. // warning(
  6425. // warnOnce,
  6426. // [
  6427. // 'Material-UI: createStyles from @material-ui/core/styles is deprecated.',
  6428. // 'Please use @material-ui/styles/createStyles',
  6429. // ].join('\n'),
  6430. // );
  6431. // warnOnce = true;
  6432. return createStyles$1(styles);
  6433. }
  6434.  
  6435. var defaultTheme = createMuiTheme();
  6436.  
  6437. function makeStyles(stylesOrCreator) {
  6438. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6439. return makeStyles$1(stylesOrCreator, _extends$1({
  6440. defaultTheme: defaultTheme
  6441. }, options));
  6442. }
  6443.  
  6444. var styled = function styled(Component) {
  6445. var componentCreator = styled$1(Component);
  6446. return function (style, options) {
  6447. return componentCreator(style, _extends$1({
  6448. defaultTheme: defaultTheme
  6449. }, options));
  6450. };
  6451. };
  6452.  
  6453. function useTheme() {
  6454. var theme = useTheme$1() || defaultTheme;
  6455.  
  6456. return theme;
  6457. }
  6458.  
  6459. function withStyles(stylesOrCreator, options) {
  6460. return withStyles$1(stylesOrCreator, _extends$1({
  6461. defaultTheme: defaultTheme
  6462. }, options));
  6463. }
  6464.  
  6465. //
  6466. // A strict capitalization should uppercase the first letter of each word a the sentence.
  6467. // We only handle the first word.
  6468.  
  6469. function capitalize(string) {
  6470. if (typeof string !== 'string') {
  6471. throw new Error(formatMuiErrorMessage(7));
  6472. }
  6473.  
  6474. return string.charAt(0).toUpperCase() + string.slice(1);
  6475. }
  6476.  
  6477. /**
  6478. * Safe chained function
  6479. *
  6480. * Will only create a new function if needed,
  6481. * otherwise will pass back existing functions or null.
  6482. *
  6483. * @param {function} functions to chain
  6484. * @returns {function|null}
  6485. */
  6486. function createChainedFunction() {
  6487. for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
  6488. funcs[_key] = arguments[_key];
  6489. }
  6490.  
  6491. return funcs.reduce(function (acc, func) {
  6492. if (func == null) {
  6493. return acc;
  6494. }
  6495.  
  6496. return function chainedFunction() {
  6497. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  6498. args[_key2] = arguments[_key2];
  6499. }
  6500.  
  6501. acc.apply(this, args);
  6502. func.apply(this, args);
  6503. };
  6504. }, function () {});
  6505. }
  6506.  
  6507. var styles$g = function styles(theme) {
  6508. return {
  6509. /* Styles applied to the root element. */
  6510. root: {
  6511. userSelect: 'none',
  6512. width: '1em',
  6513. height: '1em',
  6514. display: 'inline-block',
  6515. fill: 'currentColor',
  6516. flexShrink: 0,
  6517. fontSize: theme.typography.pxToRem(24),
  6518. transition: theme.transitions.create('fill', {
  6519. duration: theme.transitions.duration.shorter
  6520. })
  6521. },
  6522.  
  6523. /* Styles applied to the root element if `color="primary"`. */
  6524. colorPrimary: {
  6525. color: theme.palette.primary.main
  6526. },
  6527.  
  6528. /* Styles applied to the root element if `color="secondary"`. */
  6529. colorSecondary: {
  6530. color: theme.palette.secondary.main
  6531. },
  6532.  
  6533. /* Styles applied to the root element if `color="action"`. */
  6534. colorAction: {
  6535. color: theme.palette.action.active
  6536. },
  6537.  
  6538. /* Styles applied to the root element if `color="error"`. */
  6539. colorError: {
  6540. color: theme.palette.error.main
  6541. },
  6542.  
  6543. /* Styles applied to the root element if `color="disabled"`. */
  6544. colorDisabled: {
  6545. color: theme.palette.action.disabled
  6546. },
  6547.  
  6548. /* Styles applied to the root element if `fontSize="inherit"`. */
  6549. fontSizeInherit: {
  6550. fontSize: 'inherit'
  6551. },
  6552.  
  6553. /* Styles applied to the root element if `fontSize="small"`. */
  6554. fontSizeSmall: {
  6555. fontSize: theme.typography.pxToRem(20)
  6556. },
  6557.  
  6558. /* Styles applied to the root element if `fontSize="large"`. */
  6559. fontSizeLarge: {
  6560. fontSize: theme.typography.pxToRem(35)
  6561. }
  6562. };
  6563. };
  6564. var SvgIcon = /*#__PURE__*/React__namespace.forwardRef(function SvgIcon(props, ref) {
  6565. var children = props.children,
  6566. classes = props.classes,
  6567. className = props.className,
  6568. _props$color = props.color,
  6569. color = _props$color === void 0 ? 'inherit' : _props$color,
  6570. _props$component = props.component,
  6571. Component = _props$component === void 0 ? 'svg' : _props$component,
  6572. _props$fontSize = props.fontSize,
  6573. fontSize = _props$fontSize === void 0 ? 'default' : _props$fontSize,
  6574. htmlColor = props.htmlColor,
  6575. titleAccess = props.titleAccess,
  6576. _props$viewBox = props.viewBox,
  6577. viewBox = _props$viewBox === void 0 ? '0 0 24 24' : _props$viewBox,
  6578. other = _objectWithoutProperties(props, ["children", "classes", "className", "color", "component", "fontSize", "htmlColor", "titleAccess", "viewBox"]);
  6579.  
  6580. return /*#__PURE__*/React__namespace.createElement(Component, _extends$1({
  6581. className: clsx(classes.root, className, color !== 'inherit' && classes["color".concat(capitalize(color))], fontSize !== 'default' && classes["fontSize".concat(capitalize(fontSize))]),
  6582. focusable: "false",
  6583. viewBox: viewBox,
  6584. color: htmlColor,
  6585. "aria-hidden": titleAccess ? undefined : true,
  6586. role: titleAccess ? 'img' : undefined,
  6587. ref: ref
  6588. }, other), children, titleAccess ? /*#__PURE__*/React__namespace.createElement("title", null, titleAccess) : null);
  6589. });
  6590. SvgIcon.muiName = 'SvgIcon';
  6591. var SvgIcon$1 = withStyles(styles$g, {
  6592. name: 'MuiSvgIcon'
  6593. })(SvgIcon);
  6594.  
  6595. /**
  6596. * Private module reserved for @material-ui/x packages.
  6597. */
  6598.  
  6599. function createSvgIcon$1(path, displayName) {
  6600. var Component = function Component(props, ref) {
  6601. return /*#__PURE__*/React__default['default'].createElement(SvgIcon$1, _extends$1({
  6602. ref: ref
  6603. }, props), path);
  6604. };
  6605.  
  6606. Component.muiName = SvgIcon$1.muiName;
  6607. return /*#__PURE__*/React__default['default'].memo( /*#__PURE__*/React__default['default'].forwardRef(Component));
  6608. }
  6609.  
  6610. // Corresponds to 10 frames at 60 Hz.
  6611. // A few bytes payload overhead when lodash/debounce is ~3 kB and debounce ~300 B.
  6612. function debounce$1(func) {
  6613. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 166;
  6614. var timeout;
  6615.  
  6616. function debounced() {
  6617. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  6618. args[_key] = arguments[_key];
  6619. } // eslint-disable-next-line consistent-this
  6620.  
  6621.  
  6622. var that = this;
  6623.  
  6624. var later = function later() {
  6625. func.apply(that, args);
  6626. };
  6627.  
  6628. clearTimeout(timeout);
  6629. timeout = setTimeout(later, wait);
  6630. }
  6631.  
  6632. debounced.clear = function () {
  6633. clearTimeout(timeout);
  6634. };
  6635.  
  6636. return debounced;
  6637. }
  6638.  
  6639. function deprecatedPropType(validator, reason) {
  6640. {
  6641. return function () {
  6642. return null;
  6643. };
  6644. }
  6645. }
  6646.  
  6647. function isMuiElement(element, muiNames) {
  6648. return /*#__PURE__*/ /*#__PURE__*/React__namespace.isValidElement(element) && muiNames.indexOf(element.type.muiName) !== -1;
  6649. }
  6650.  
  6651. function ownerDocument(node) {
  6652. return node && node.ownerDocument || document;
  6653. }
  6654.  
  6655. function ownerWindow(node) {
  6656. var doc = ownerDocument(node);
  6657. return doc.defaultView || window;
  6658. }
  6659.  
  6660. function requirePropFactory(componentNameInError) {
  6661. {
  6662. return function () {
  6663. return null;
  6664. };
  6665. }
  6666. }
  6667.  
  6668. // TODO v5: consider to make it private
  6669. function setRef(ref, value) {
  6670. if (typeof ref === 'function') {
  6671. ref(value);
  6672. } else if (ref) {
  6673. ref.current = value;
  6674. }
  6675. }
  6676.  
  6677. function unsupportedProp(props, propName, componentName, location, propFullName) {
  6678. {
  6679. return null;
  6680. }
  6681. }
  6682.  
  6683. /* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */
  6684. function useControlled(_ref) {
  6685. var controlled = _ref.controlled,
  6686. defaultProp = _ref.default;
  6687. _ref.name;
  6688. _ref.state;
  6689.  
  6690. var _React$useRef = React__namespace.useRef(controlled !== undefined),
  6691. isControlled = _React$useRef.current;
  6692.  
  6693. var _React$useState = React__namespace.useState(defaultProp),
  6694. valueState = _React$useState[0],
  6695. setValue = _React$useState[1];
  6696.  
  6697. var value = isControlled ? controlled : valueState;
  6698.  
  6699. var setValueIfUncontrolled = React__namespace.useCallback(function (newValue) {
  6700. if (!isControlled) {
  6701. setValue(newValue);
  6702. }
  6703. }, []);
  6704. return [value, setValueIfUncontrolled];
  6705. }
  6706.  
  6707. var useEnhancedEffect$4 = typeof window !== 'undefined' ? React__namespace.useLayoutEffect : React__namespace.useEffect;
  6708. /**
  6709. * https://github.com/facebook/react/issues/14099#issuecomment-440013892
  6710. *
  6711. * @param {function} fn
  6712. */
  6713.  
  6714. function useEventCallback(fn) {
  6715. var ref = React__namespace.useRef(fn);
  6716. useEnhancedEffect$4(function () {
  6717. ref.current = fn;
  6718. });
  6719. return React__namespace.useCallback(function () {
  6720. return (ref.current).apply(void 0, arguments);
  6721. }, []);
  6722. }
  6723.  
  6724. function useForkRef(refA, refB) {
  6725. /**
  6726. * This will create a new function if the ref props change and are defined.
  6727. * This means react will call the old forkRef with `null` and the new forkRef
  6728. * with the ref. Cleanup naturally emerges from this behavior
  6729. */
  6730. return React__namespace.useMemo(function () {
  6731. if (refA == null && refB == null) {
  6732. return null;
  6733. }
  6734.  
  6735. return function (refValue) {
  6736. setRef(refA, refValue);
  6737. setRef(refB, refValue);
  6738. };
  6739. }, [refA, refB]);
  6740. }
  6741.  
  6742. /**
  6743. * Private module reserved for @material-ui/x packages.
  6744. */
  6745.  
  6746. function useId(idOverride) {
  6747. var _React$useState = React__namespace.useState(idOverride),
  6748. defaultId = _React$useState[0],
  6749. setDefaultId = _React$useState[1];
  6750.  
  6751. var id = idOverride || defaultId;
  6752. React__namespace.useEffect(function () {
  6753. if (defaultId == null) {
  6754. // Fallback to this default id when possible.
  6755. // Use the random value for client-side rendering only.
  6756. // We can't use it server-side.
  6757. setDefaultId("mui-".concat(Math.round(Math.random() * 1e5)));
  6758. }
  6759. }, [defaultId]);
  6760. return id;
  6761. }
  6762.  
  6763. // based on https://github.com/WICG/focus-visible/blob/v4.1.5/src/focus-visible.js
  6764. var hadKeyboardEvent = true;
  6765. var hadFocusVisibleRecently = false;
  6766. var hadFocusVisibleRecentlyTimeout = null;
  6767. var inputTypesWhitelist = {
  6768. text: true,
  6769. search: true,
  6770. url: true,
  6771. tel: true,
  6772. email: true,
  6773. password: true,
  6774. number: true,
  6775. date: true,
  6776. month: true,
  6777. week: true,
  6778. time: true,
  6779. datetime: true,
  6780. 'datetime-local': true
  6781. };
  6782. /**
  6783. * Computes whether the given element should automatically trigger the
  6784. * `focus-visible` class being added, i.e. whether it should always match
  6785. * `:focus-visible` when focused.
  6786. * @param {Element} node
  6787. * @return {boolean}
  6788. */
  6789.  
  6790. function focusTriggersKeyboardModality(node) {
  6791. var type = node.type,
  6792. tagName = node.tagName;
  6793.  
  6794. if (tagName === 'INPUT' && inputTypesWhitelist[type] && !node.readOnly) {
  6795. return true;
  6796. }
  6797.  
  6798. if (tagName === 'TEXTAREA' && !node.readOnly) {
  6799. return true;
  6800. }
  6801.  
  6802. if (node.isContentEditable) {
  6803. return true;
  6804. }
  6805.  
  6806. return false;
  6807. }
  6808. /**
  6809. * Keep track of our keyboard modality state with `hadKeyboardEvent`.
  6810. * If the most recent user interaction was via the keyboard;
  6811. * and the key press did not include a meta, alt/option, or control key;
  6812. * then the modality is keyboard. Otherwise, the modality is not keyboard.
  6813. * @param {KeyboardEvent} event
  6814. */
  6815.  
  6816.  
  6817. function handleKeyDown(event) {
  6818. if (event.metaKey || event.altKey || event.ctrlKey) {
  6819. return;
  6820. }
  6821.  
  6822. hadKeyboardEvent = true;
  6823. }
  6824. /**
  6825. * If at any point a user clicks with a pointing device, ensure that we change
  6826. * the modality away from keyboard.
  6827. * This avoids the situation where a user presses a key on an already focused
  6828. * element, and then clicks on a different element, focusing it with a
  6829. * pointing device, while we still think we're in keyboard modality.
  6830. */
  6831.  
  6832.  
  6833. function handlePointerDown() {
  6834. hadKeyboardEvent = false;
  6835. }
  6836.  
  6837. function handleVisibilityChange() {
  6838. if (this.visibilityState === 'hidden') {
  6839. // If the tab becomes active again, the browser will handle calling focus
  6840. // on the element (Safari actually calls it twice).
  6841. // If this tab change caused a blur on an element with focus-visible,
  6842. // re-apply the class when the user switches back to the tab.
  6843. if (hadFocusVisibleRecently) {
  6844. hadKeyboardEvent = true;
  6845. }
  6846. }
  6847. }
  6848.  
  6849. function prepare(doc) {
  6850. doc.addEventListener('keydown', handleKeyDown, true);
  6851. doc.addEventListener('mousedown', handlePointerDown, true);
  6852. doc.addEventListener('pointerdown', handlePointerDown, true);
  6853. doc.addEventListener('touchstart', handlePointerDown, true);
  6854. doc.addEventListener('visibilitychange', handleVisibilityChange, true);
  6855. }
  6856.  
  6857. function isFocusVisible(event) {
  6858. var target = event.target;
  6859.  
  6860. try {
  6861. return target.matches(':focus-visible');
  6862. } catch (error) {} // browsers not implementing :focus-visible will throw a SyntaxError
  6863. // we use our own heuristic for those browsers
  6864. // rethrow might be better if it's not the expected error but do we really
  6865. // want to crash if focus-visible malfunctioned?
  6866. // no need for validFocusTarget check. the user does that by attaching it to
  6867. // focusable events only
  6868.  
  6869.  
  6870. return hadKeyboardEvent || focusTriggersKeyboardModality(target);
  6871. }
  6872. /**
  6873. * Should be called if a blur event is fired on a focus-visible element
  6874. */
  6875.  
  6876.  
  6877. function handleBlurVisible() {
  6878. // To detect a tab/window switch, we look for a blur event followed
  6879. // rapidly by a visibility change.
  6880. // If we don't see a visibility change within 100ms, it's probably a
  6881. // regular focus change.
  6882. hadFocusVisibleRecently = true;
  6883. window.clearTimeout(hadFocusVisibleRecentlyTimeout);
  6884. hadFocusVisibleRecentlyTimeout = window.setTimeout(function () {
  6885. hadFocusVisibleRecently = false;
  6886. }, 100);
  6887. }
  6888.  
  6889. function useIsFocusVisible() {
  6890. var ref = React__namespace.useCallback(function (instance) {
  6891. var node = ReactDOM__namespace.findDOMNode(instance);
  6892.  
  6893. if (node != null) {
  6894. prepare(node.ownerDocument);
  6895. }
  6896. }, []);
  6897.  
  6898. return {
  6899. isFocusVisible: isFocusVisible,
  6900. onBlurVisible: handleBlurVisible,
  6901. ref: ref
  6902. };
  6903. }
  6904.  
  6905. var utils = /*#__PURE__*/Object.freeze({
  6906. __proto__: null,
  6907. capitalize: capitalize,
  6908. createChainedFunction: createChainedFunction,
  6909. createSvgIcon: createSvgIcon$1,
  6910. debounce: debounce$1,
  6911. deprecatedPropType: deprecatedPropType,
  6912. isMuiElement: isMuiElement,
  6913. ownerDocument: ownerDocument,
  6914. ownerWindow: ownerWindow,
  6915. requirePropFactory: requirePropFactory,
  6916. setRef: setRef,
  6917. unsupportedProp: unsupportedProp,
  6918. useControlled: useControlled,
  6919. useEventCallback: useEventCallback,
  6920. useForkRef: useForkRef,
  6921. unstable_useId: useId,
  6922. useIsFocusVisible: useIsFocusVisible
  6923. });
  6924.  
  6925. var config$1 = {
  6926. disabled: false
  6927. };
  6928.  
  6929. var TransitionGroupContext = /*#__PURE__*/React__default['default'].createContext(null);
  6930.  
  6931. var UNMOUNTED = 'unmounted';
  6932. var EXITED = 'exited';
  6933. var ENTERING = 'entering';
  6934. var ENTERED = 'entered';
  6935. var EXITING = 'exiting';
  6936. /**
  6937. * The Transition component lets you describe a transition from one component
  6938. * state to another _over time_ with a simple declarative API. Most commonly
  6939. * it's used to animate the mounting and unmounting of a component, but can also
  6940. * be used to describe in-place transition states as well.
  6941. *
  6942. * ---
  6943. *
  6944. * **Note**: `Transition` is a platform-agnostic base component. If you're using
  6945. * transitions in CSS, you'll probably want to use
  6946. * [`CSSTransition`](https://reactcommunity.org/react-transition-group/css-transition)
  6947. * instead. It inherits all the features of `Transition`, but contains
  6948. * additional features necessary to play nice with CSS transitions (hence the
  6949. * name of the component).
  6950. *
  6951. * ---
  6952. *
  6953. * By default the `Transition` component does not alter the behavior of the
  6954. * component it renders, it only tracks "enter" and "exit" states for the
  6955. * components. It's up to you to give meaning and effect to those states. For
  6956. * example we can add styles to a component when it enters or exits:
  6957. *
  6958. * ```jsx
  6959. * import { Transition } from 'react-transition-group';
  6960. *
  6961. * const duration = 300;
  6962. *
  6963. * const defaultStyle = {
  6964. * transition: `opacity ${duration}ms ease-in-out`,
  6965. * opacity: 0,
  6966. * }
  6967. *
  6968. * const transitionStyles = {
  6969. * entering: { opacity: 1 },
  6970. * entered: { opacity: 1 },
  6971. * exiting: { opacity: 0 },
  6972. * exited: { opacity: 0 },
  6973. * };
  6974. *
  6975. * const Fade = ({ in: inProp }) => (
  6976. * <Transition in={inProp} timeout={duration}>
  6977. * {state => (
  6978. * <div style={{
  6979. * ...defaultStyle,
  6980. * ...transitionStyles[state]
  6981. * }}>
  6982. * I'm a fade Transition!
  6983. * </div>
  6984. * )}
  6985. * </Transition>
  6986. * );
  6987. * ```
  6988. *
  6989. * There are 4 main states a Transition can be in:
  6990. * - `'entering'`
  6991. * - `'entered'`
  6992. * - `'exiting'`
  6993. * - `'exited'`
  6994. *
  6995. * Transition state is toggled via the `in` prop. When `true` the component
  6996. * begins the "Enter" stage. During this stage, the component will shift from
  6997. * its current transition state, to `'entering'` for the duration of the
  6998. * transition and then to the `'entered'` stage once it's complete. Let's take
  6999. * the following example (we'll use the
  7000. * [useState](https://reactjs.org/docs/hooks-reference.html#usestate) hook):
  7001. *
  7002. * ```jsx
  7003. * function App() {
  7004. * const [inProp, setInProp] = useState(false);
  7005. * return (
  7006. * <div>
  7007. * <Transition in={inProp} timeout={500}>
  7008. * {state => (
  7009. * // ...
  7010. * )}
  7011. * </Transition>
  7012. * <button onClick={() => setInProp(true)}>
  7013. * Click to Enter
  7014. * </button>
  7015. * </div>
  7016. * );
  7017. * }
  7018. * ```
  7019. *
  7020. * When the button is clicked the component will shift to the `'entering'` state
  7021. * and stay there for 500ms (the value of `timeout`) before it finally switches
  7022. * to `'entered'`.
  7023. *
  7024. * When `in` is `false` the same thing happens except the state moves from
  7025. * `'exiting'` to `'exited'`.
  7026. */
  7027.  
  7028. var Transition = /*#__PURE__*/function (_React$Component) {
  7029. _inheritsLoose(Transition, _React$Component);
  7030.  
  7031. function Transition(props, context) {
  7032. var _this;
  7033.  
  7034. _this = _React$Component.call(this, props, context) || this;
  7035. var parentGroup = context; // In the context of a TransitionGroup all enters are really appears
  7036.  
  7037. var appear = parentGroup && !parentGroup.isMounting ? props.enter : props.appear;
  7038. var initialStatus;
  7039. _this.appearStatus = null;
  7040.  
  7041. if (props.in) {
  7042. if (appear) {
  7043. initialStatus = EXITED;
  7044. _this.appearStatus = ENTERING;
  7045. } else {
  7046. initialStatus = ENTERED;
  7047. }
  7048. } else {
  7049. if (props.unmountOnExit || props.mountOnEnter) {
  7050. initialStatus = UNMOUNTED;
  7051. } else {
  7052. initialStatus = EXITED;
  7053. }
  7054. }
  7055.  
  7056. _this.state = {
  7057. status: initialStatus
  7058. };
  7059. _this.nextCallback = null;
  7060. return _this;
  7061. }
  7062.  
  7063. Transition.getDerivedStateFromProps = function getDerivedStateFromProps(_ref, prevState) {
  7064. var nextIn = _ref.in;
  7065.  
  7066. if (nextIn && prevState.status === UNMOUNTED) {
  7067. return {
  7068. status: EXITED
  7069. };
  7070. }
  7071.  
  7072. return null;
  7073. } // getSnapshotBeforeUpdate(prevProps) {
  7074. // let nextStatus = null
  7075. // if (prevProps !== this.props) {
  7076. // const { status } = this.state
  7077. // if (this.props.in) {
  7078. // if (status !== ENTERING && status !== ENTERED) {
  7079. // nextStatus = ENTERING
  7080. // }
  7081. // } else {
  7082. // if (status === ENTERING || status === ENTERED) {
  7083. // nextStatus = EXITING
  7084. // }
  7085. // }
  7086. // }
  7087. // return { nextStatus }
  7088. // }
  7089. ;
  7090.  
  7091. var _proto = Transition.prototype;
  7092.  
  7093. _proto.componentDidMount = function componentDidMount() {
  7094. this.updateStatus(true, this.appearStatus);
  7095. };
  7096.  
  7097. _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
  7098. var nextStatus = null;
  7099.  
  7100. if (prevProps !== this.props) {
  7101. var status = this.state.status;
  7102.  
  7103. if (this.props.in) {
  7104. if (status !== ENTERING && status !== ENTERED) {
  7105. nextStatus = ENTERING;
  7106. }
  7107. } else {
  7108. if (status === ENTERING || status === ENTERED) {
  7109. nextStatus = EXITING;
  7110. }
  7111. }
  7112. }
  7113.  
  7114. this.updateStatus(false, nextStatus);
  7115. };
  7116.  
  7117. _proto.componentWillUnmount = function componentWillUnmount() {
  7118. this.cancelNextCallback();
  7119. };
  7120.  
  7121. _proto.getTimeouts = function getTimeouts() {
  7122. var timeout = this.props.timeout;
  7123. var exit, enter, appear;
  7124. exit = enter = appear = timeout;
  7125.  
  7126. if (timeout != null && typeof timeout !== 'number') {
  7127. exit = timeout.exit;
  7128. enter = timeout.enter; // TODO: remove fallback for next major
  7129.  
  7130. appear = timeout.appear !== undefined ? timeout.appear : enter;
  7131. }
  7132.  
  7133. return {
  7134. exit: exit,
  7135. enter: enter,
  7136. appear: appear
  7137. };
  7138. };
  7139.  
  7140. _proto.updateStatus = function updateStatus(mounting, nextStatus) {
  7141. if (mounting === void 0) {
  7142. mounting = false;
  7143. }
  7144.  
  7145. if (nextStatus !== null) {
  7146. // nextStatus will always be ENTERING or EXITING.
  7147. this.cancelNextCallback();
  7148.  
  7149. if (nextStatus === ENTERING) {
  7150. this.performEnter(mounting);
  7151. } else {
  7152. this.performExit();
  7153. }
  7154. } else if (this.props.unmountOnExit && this.state.status === EXITED) {
  7155. this.setState({
  7156. status: UNMOUNTED
  7157. });
  7158. }
  7159. };
  7160.  
  7161. _proto.performEnter = function performEnter(mounting) {
  7162. var _this2 = this;
  7163.  
  7164. var enter = this.props.enter;
  7165. var appearing = this.context ? this.context.isMounting : mounting;
  7166.  
  7167. var _ref2 = this.props.nodeRef ? [appearing] : [ReactDOM__default['default'].findDOMNode(this), appearing],
  7168. maybeNode = _ref2[0],
  7169. maybeAppearing = _ref2[1];
  7170.  
  7171. var timeouts = this.getTimeouts();
  7172. var enterTimeout = appearing ? timeouts.appear : timeouts.enter; // no enter animation skip right to ENTERED
  7173. // if we are mounting and running this it means appear _must_ be set
  7174.  
  7175. if (!mounting && !enter || config$1.disabled) {
  7176. this.safeSetState({
  7177. status: ENTERED
  7178. }, function () {
  7179. _this2.props.onEntered(maybeNode);
  7180. });
  7181. return;
  7182. }
  7183.  
  7184. this.props.onEnter(maybeNode, maybeAppearing);
  7185. this.safeSetState({
  7186. status: ENTERING
  7187. }, function () {
  7188. _this2.props.onEntering(maybeNode, maybeAppearing);
  7189.  
  7190. _this2.onTransitionEnd(enterTimeout, function () {
  7191. _this2.safeSetState({
  7192. status: ENTERED
  7193. }, function () {
  7194. _this2.props.onEntered(maybeNode, maybeAppearing);
  7195. });
  7196. });
  7197. });
  7198. };
  7199.  
  7200. _proto.performExit = function performExit() {
  7201. var _this3 = this;
  7202.  
  7203. var exit = this.props.exit;
  7204. var timeouts = this.getTimeouts();
  7205. var maybeNode = this.props.nodeRef ? undefined : ReactDOM__default['default'].findDOMNode(this); // no exit animation skip right to EXITED
  7206.  
  7207. if (!exit || config$1.disabled) {
  7208. this.safeSetState({
  7209. status: EXITED
  7210. }, function () {
  7211. _this3.props.onExited(maybeNode);
  7212. });
  7213. return;
  7214. }
  7215.  
  7216. this.props.onExit(maybeNode);
  7217. this.safeSetState({
  7218. status: EXITING
  7219. }, function () {
  7220. _this3.props.onExiting(maybeNode);
  7221.  
  7222. _this3.onTransitionEnd(timeouts.exit, function () {
  7223. _this3.safeSetState({
  7224. status: EXITED
  7225. }, function () {
  7226. _this3.props.onExited(maybeNode);
  7227. });
  7228. });
  7229. });
  7230. };
  7231.  
  7232. _proto.cancelNextCallback = function cancelNextCallback() {
  7233. if (this.nextCallback !== null) {
  7234. this.nextCallback.cancel();
  7235. this.nextCallback = null;
  7236. }
  7237. };
  7238.  
  7239. _proto.safeSetState = function safeSetState(nextState, callback) {
  7240. // This shouldn't be necessary, but there are weird race conditions with
  7241. // setState callbacks and unmounting in testing, so always make sure that
  7242. // we can cancel any pending setState callbacks after we unmount.
  7243. callback = this.setNextCallback(callback);
  7244. this.setState(nextState, callback);
  7245. };
  7246.  
  7247. _proto.setNextCallback = function setNextCallback(callback) {
  7248. var _this4 = this;
  7249.  
  7250. var active = true;
  7251.  
  7252. this.nextCallback = function (event) {
  7253. if (active) {
  7254. active = false;
  7255. _this4.nextCallback = null;
  7256. callback(event);
  7257. }
  7258. };
  7259.  
  7260. this.nextCallback.cancel = function () {
  7261. active = false;
  7262. };
  7263.  
  7264. return this.nextCallback;
  7265. };
  7266.  
  7267. _proto.onTransitionEnd = function onTransitionEnd(timeout, handler) {
  7268. this.setNextCallback(handler);
  7269. var node = this.props.nodeRef ? this.props.nodeRef.current : ReactDOM__default['default'].findDOMNode(this);
  7270. var doesNotHaveTimeoutOrListener = timeout == null && !this.props.addEndListener;
  7271.  
  7272. if (!node || doesNotHaveTimeoutOrListener) {
  7273. setTimeout(this.nextCallback, 0);
  7274. return;
  7275. }
  7276.  
  7277. if (this.props.addEndListener) {
  7278. var _ref3 = this.props.nodeRef ? [this.nextCallback] : [node, this.nextCallback],
  7279. maybeNode = _ref3[0],
  7280. maybeNextCallback = _ref3[1];
  7281.  
  7282. this.props.addEndListener(maybeNode, maybeNextCallback);
  7283. }
  7284.  
  7285. if (timeout != null) {
  7286. setTimeout(this.nextCallback, timeout);
  7287. }
  7288. };
  7289.  
  7290. _proto.render = function render() {
  7291. var status = this.state.status;
  7292.  
  7293. if (status === UNMOUNTED) {
  7294. return null;
  7295. }
  7296.  
  7297. var _this$props = this.props,
  7298. children = _this$props.children;
  7299. _this$props.in;
  7300. _this$props.mountOnEnter;
  7301. _this$props.unmountOnExit;
  7302. _this$props.appear;
  7303. _this$props.enter;
  7304. _this$props.exit;
  7305. _this$props.timeout;
  7306. _this$props.addEndListener;
  7307. _this$props.onEnter;
  7308. _this$props.onEntering;
  7309. _this$props.onEntered;
  7310. _this$props.onExit;
  7311. _this$props.onExiting;
  7312. _this$props.onExited;
  7313. _this$props.nodeRef;
  7314. var childProps = _objectWithoutPropertiesLoose(_this$props, ["children", "in", "mountOnEnter", "unmountOnExit", "appear", "enter", "exit", "timeout", "addEndListener", "onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "nodeRef"]);
  7315.  
  7316. return (
  7317. /*#__PURE__*/
  7318. // allows for nested Transitions
  7319. React__default['default'].createElement(TransitionGroupContext.Provider, {
  7320. value: null
  7321. }, typeof children === 'function' ? children(status, childProps) : /*#__PURE__*/React__default['default'].cloneElement(React__default['default'].Children.only(children), childProps))
  7322. );
  7323. };
  7324.  
  7325. return Transition;
  7326. }(React__default['default'].Component);
  7327.  
  7328. Transition.contextType = TransitionGroupContext;
  7329. Transition.propTypes = {}; // Name the function so it is clearer in the documentation
  7330.  
  7331. function noop() {}
  7332.  
  7333. Transition.defaultProps = {
  7334. in: false,
  7335. mountOnEnter: false,
  7336. unmountOnExit: false,
  7337. appear: false,
  7338. enter: true,
  7339. exit: true,
  7340. onEnter: noop,
  7341. onEntering: noop,
  7342. onEntered: noop,
  7343. onExit: noop,
  7344. onExiting: noop,
  7345. onExited: noop
  7346. };
  7347. Transition.UNMOUNTED = UNMOUNTED;
  7348. Transition.EXITED = EXITED;
  7349. Transition.ENTERING = ENTERING;
  7350. Transition.ENTERED = ENTERED;
  7351. Transition.EXITING = EXITING;
  7352.  
  7353. /**
  7354. * Given `this.props.children`, return an object mapping key to child.
  7355. *
  7356. * @param {*} children `this.props.children`
  7357. * @return {object} Mapping of key to child
  7358. */
  7359.  
  7360. function getChildMapping(children, mapFn) {
  7361. var mapper = function mapper(child) {
  7362. return mapFn && /*#__PURE__*/React$3.isValidElement(child) ? mapFn(child) : child;
  7363. };
  7364.  
  7365. var result = Object.create(null);
  7366. if (children) React$3.Children.map(children, function (c) {
  7367. return c;
  7368. }).forEach(function (child) {
  7369. // run the map function here instead so that the key is the computed one
  7370. result[child.key] = mapper(child);
  7371. });
  7372. return result;
  7373. }
  7374. /**
  7375. * When you're adding or removing children some may be added or removed in the
  7376. * same render pass. We want to show *both* since we want to simultaneously
  7377. * animate elements in and out. This function takes a previous set of keys
  7378. * and a new set of keys and merges them with its best guess of the correct
  7379. * ordering. In the future we may expose some of the utilities in
  7380. * ReactMultiChild to make this easy, but for now React itself does not
  7381. * directly have this concept of the union of prevChildren and nextChildren
  7382. * so we implement it here.
  7383. *
  7384. * @param {object} prev prev children as returned from
  7385. * `ReactTransitionChildMapping.getChildMapping()`.
  7386. * @param {object} next next children as returned from
  7387. * `ReactTransitionChildMapping.getChildMapping()`.
  7388. * @return {object} a key set that contains all keys in `prev` and all keys
  7389. * in `next` in a reasonable order.
  7390. */
  7391.  
  7392. function mergeChildMappings(prev, next) {
  7393. prev = prev || {};
  7394. next = next || {};
  7395.  
  7396. function getValueForKey(key) {
  7397. return key in next ? next[key] : prev[key];
  7398. } // For each key of `next`, the list of keys to insert before that key in
  7399. // the combined list
  7400.  
  7401.  
  7402. var nextKeysPending = Object.create(null);
  7403. var pendingKeys = [];
  7404.  
  7405. for (var prevKey in prev) {
  7406. if (prevKey in next) {
  7407. if (pendingKeys.length) {
  7408. nextKeysPending[prevKey] = pendingKeys;
  7409. pendingKeys = [];
  7410. }
  7411. } else {
  7412. pendingKeys.push(prevKey);
  7413. }
  7414. }
  7415.  
  7416. var i;
  7417. var childMapping = {};
  7418.  
  7419. for (var nextKey in next) {
  7420. if (nextKeysPending[nextKey]) {
  7421. for (i = 0; i < nextKeysPending[nextKey].length; i++) {
  7422. var pendingNextKey = nextKeysPending[nextKey][i];
  7423. childMapping[nextKeysPending[nextKey][i]] = getValueForKey(pendingNextKey);
  7424. }
  7425. }
  7426.  
  7427. childMapping[nextKey] = getValueForKey(nextKey);
  7428. } // Finally, add the keys which didn't appear before any key in `next`
  7429.  
  7430.  
  7431. for (i = 0; i < pendingKeys.length; i++) {
  7432. childMapping[pendingKeys[i]] = getValueForKey(pendingKeys[i]);
  7433. }
  7434.  
  7435. return childMapping;
  7436. }
  7437.  
  7438. function getProp(child, prop, props) {
  7439. return props[prop] != null ? props[prop] : child.props[prop];
  7440. }
  7441.  
  7442. function getInitialChildMapping(props, onExited) {
  7443. return getChildMapping(props.children, function (child) {
  7444. return /*#__PURE__*/React$3.cloneElement(child, {
  7445. onExited: onExited.bind(null, child),
  7446. in: true,
  7447. appear: getProp(child, 'appear', props),
  7448. enter: getProp(child, 'enter', props),
  7449. exit: getProp(child, 'exit', props)
  7450. });
  7451. });
  7452. }
  7453. function getNextChildMapping(nextProps, prevChildMapping, onExited) {
  7454. var nextChildMapping = getChildMapping(nextProps.children);
  7455. var children = mergeChildMappings(prevChildMapping, nextChildMapping);
  7456. Object.keys(children).forEach(function (key) {
  7457. var child = children[key];
  7458. if (! /*#__PURE__*/React$3.isValidElement(child)) return;
  7459. var hasPrev = (key in prevChildMapping);
  7460. var hasNext = (key in nextChildMapping);
  7461. var prevChild = prevChildMapping[key];
  7462. var isLeaving = /*#__PURE__*/React$3.isValidElement(prevChild) && !prevChild.props.in; // item is new (entering)
  7463.  
  7464. if (hasNext && (!hasPrev || isLeaving)) {
  7465. // console.log('entering', key)
  7466. children[key] = /*#__PURE__*/React$3.cloneElement(child, {
  7467. onExited: onExited.bind(null, child),
  7468. in: true,
  7469. exit: getProp(child, 'exit', nextProps),
  7470. enter: getProp(child, 'enter', nextProps)
  7471. });
  7472. } else if (!hasNext && hasPrev && !isLeaving) {
  7473. // item is old (exiting)
  7474. // console.log('leaving', key)
  7475. children[key] = /*#__PURE__*/React$3.cloneElement(child, {
  7476. in: false
  7477. });
  7478. } else if (hasNext && hasPrev && /*#__PURE__*/React$3.isValidElement(prevChild)) {
  7479. // item hasn't changed transition states
  7480. // copy over the last transition props;
  7481. // console.log('unchanged', key)
  7482. children[key] = /*#__PURE__*/React$3.cloneElement(child, {
  7483. onExited: onExited.bind(null, child),
  7484. in: prevChild.props.in,
  7485. exit: getProp(child, 'exit', nextProps),
  7486. enter: getProp(child, 'enter', nextProps)
  7487. });
  7488. }
  7489. });
  7490. return children;
  7491. }
  7492.  
  7493. var values = Object.values || function (obj) {
  7494. return Object.keys(obj).map(function (k) {
  7495. return obj[k];
  7496. });
  7497. };
  7498.  
  7499. var defaultProps = {
  7500. component: 'div',
  7501. childFactory: function childFactory(child) {
  7502. return child;
  7503. }
  7504. };
  7505. /**
  7506. * The `<TransitionGroup>` component manages a set of transition components
  7507. * (`<Transition>` and `<CSSTransition>`) in a list. Like with the transition
  7508. * components, `<TransitionGroup>` is a state machine for managing the mounting
  7509. * and unmounting of components over time.
  7510. *
  7511. * Consider the example below. As items are removed or added to the TodoList the
  7512. * `in` prop is toggled automatically by the `<TransitionGroup>`.
  7513. *
  7514. * Note that `<TransitionGroup>` does not define any animation behavior!
  7515. * Exactly _how_ a list item animates is up to the individual transition
  7516. * component. This means you can mix and match animations across different list
  7517. * items.
  7518. */
  7519.  
  7520. var TransitionGroup = /*#__PURE__*/function (_React$Component) {
  7521. _inheritsLoose(TransitionGroup, _React$Component);
  7522.  
  7523. function TransitionGroup(props, context) {
  7524. var _this;
  7525.  
  7526. _this = _React$Component.call(this, props, context) || this;
  7527.  
  7528. var handleExited = _this.handleExited.bind(_assertThisInitialized(_this)); // Initial children should all be entering, dependent on appear
  7529.  
  7530.  
  7531. _this.state = {
  7532. contextValue: {
  7533. isMounting: true
  7534. },
  7535. handleExited: handleExited,
  7536. firstRender: true
  7537. };
  7538. return _this;
  7539. }
  7540.  
  7541. var _proto = TransitionGroup.prototype;
  7542.  
  7543. _proto.componentDidMount = function componentDidMount() {
  7544. this.mounted = true;
  7545. this.setState({
  7546. contextValue: {
  7547. isMounting: false
  7548. }
  7549. });
  7550. };
  7551.  
  7552. _proto.componentWillUnmount = function componentWillUnmount() {
  7553. this.mounted = false;
  7554. };
  7555.  
  7556. TransitionGroup.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, _ref) {
  7557. var prevChildMapping = _ref.children,
  7558. handleExited = _ref.handleExited,
  7559. firstRender = _ref.firstRender;
  7560. return {
  7561. children: firstRender ? getInitialChildMapping(nextProps, handleExited) : getNextChildMapping(nextProps, prevChildMapping, handleExited),
  7562. firstRender: false
  7563. };
  7564. } // node is `undefined` when user provided `nodeRef` prop
  7565. ;
  7566.  
  7567. _proto.handleExited = function handleExited(child, node) {
  7568. var currentChildMapping = getChildMapping(this.props.children);
  7569. if (child.key in currentChildMapping) return;
  7570.  
  7571. if (child.props.onExited) {
  7572. child.props.onExited(node);
  7573. }
  7574.  
  7575. if (this.mounted) {
  7576. this.setState(function (state) {
  7577. var children = _extends$1({}, state.children);
  7578.  
  7579. delete children[child.key];
  7580. return {
  7581. children: children
  7582. };
  7583. });
  7584. }
  7585. };
  7586.  
  7587. _proto.render = function render() {
  7588. var _this$props = this.props,
  7589. Component = _this$props.component,
  7590. childFactory = _this$props.childFactory,
  7591. props = _objectWithoutPropertiesLoose(_this$props, ["component", "childFactory"]);
  7592.  
  7593. var contextValue = this.state.contextValue;
  7594. var children = values(this.state.children).map(childFactory);
  7595. delete props.appear;
  7596. delete props.enter;
  7597. delete props.exit;
  7598.  
  7599. if (Component === null) {
  7600. return /*#__PURE__*/React__default['default'].createElement(TransitionGroupContext.Provider, {
  7601. value: contextValue
  7602. }, children);
  7603. }
  7604.  
  7605. return /*#__PURE__*/React__default['default'].createElement(TransitionGroupContext.Provider, {
  7606. value: contextValue
  7607. }, /*#__PURE__*/React__default['default'].createElement(Component, props, children));
  7608. };
  7609.  
  7610. return TransitionGroup;
  7611. }(React__default['default'].Component);
  7612.  
  7613. TransitionGroup.propTypes = {};
  7614. TransitionGroup.defaultProps = defaultProps;
  7615.  
  7616. var reflow = function reflow(node) {
  7617. return node.scrollTop;
  7618. };
  7619. function getTransitionProps(props, options) {
  7620. var timeout = props.timeout,
  7621. _props$style = props.style,
  7622. style = _props$style === void 0 ? {} : _props$style;
  7623. return {
  7624. duration: style.transitionDuration || typeof timeout === 'number' ? timeout : timeout[options.mode] || 0,
  7625. delay: style.transitionDelay
  7626. };
  7627. }
  7628.  
  7629. var useEnhancedEffect$3 = typeof window === 'undefined' ? React__namespace.useEffect : React__namespace.useLayoutEffect;
  7630. /**
  7631. * @ignore - internal component.
  7632. */
  7633.  
  7634. function Ripple(props) {
  7635. var classes = props.classes,
  7636. _props$pulsate = props.pulsate,
  7637. pulsate = _props$pulsate === void 0 ? false : _props$pulsate,
  7638. rippleX = props.rippleX,
  7639. rippleY = props.rippleY,
  7640. rippleSize = props.rippleSize,
  7641. inProp = props.in,
  7642. _props$onExited = props.onExited,
  7643. onExited = _props$onExited === void 0 ? function () {} : _props$onExited,
  7644. timeout = props.timeout;
  7645.  
  7646. var _React$useState = React__namespace.useState(false),
  7647. leaving = _React$useState[0],
  7648. setLeaving = _React$useState[1];
  7649.  
  7650. var rippleClassName = clsx(classes.ripple, classes.rippleVisible, pulsate && classes.ripplePulsate);
  7651. var rippleStyles = {
  7652. width: rippleSize,
  7653. height: rippleSize,
  7654. top: -(rippleSize / 2) + rippleY,
  7655. left: -(rippleSize / 2) + rippleX
  7656. };
  7657. var childClassName = clsx(classes.child, leaving && classes.childLeaving, pulsate && classes.childPulsate);
  7658. var handleExited = useEventCallback(onExited); // Ripple is used for user feedback (e.g. click or press) so we want to apply styles with the highest priority
  7659.  
  7660. useEnhancedEffect$3(function () {
  7661. if (!inProp) {
  7662. // react-transition-group#onExit
  7663. setLeaving(true); // react-transition-group#onExited
  7664.  
  7665. var timeoutId = setTimeout(handleExited, timeout);
  7666. return function () {
  7667. clearTimeout(timeoutId);
  7668. };
  7669. }
  7670.  
  7671. return undefined;
  7672. }, [handleExited, inProp, timeout]);
  7673. return /*#__PURE__*/React__namespace.createElement("span", {
  7674. className: rippleClassName,
  7675. style: rippleStyles
  7676. }, /*#__PURE__*/React__namespace.createElement("span", {
  7677. className: childClassName
  7678. }));
  7679. }
  7680.  
  7681. var DURATION = 550;
  7682. var DELAY_RIPPLE = 80;
  7683. var styles$f = function styles(theme) {
  7684. return {
  7685. /* Styles applied to the root element. */
  7686. root: {
  7687. overflow: 'hidden',
  7688. pointerEvents: 'none',
  7689. position: 'absolute',
  7690. zIndex: 0,
  7691. top: 0,
  7692. right: 0,
  7693. bottom: 0,
  7694. left: 0,
  7695. borderRadius: 'inherit'
  7696. },
  7697.  
  7698. /* Styles applied to the internal `Ripple` components `ripple` class. */
  7699. ripple: {
  7700. opacity: 0,
  7701. position: 'absolute'
  7702. },
  7703.  
  7704. /* Styles applied to the internal `Ripple` components `rippleVisible` class. */
  7705. rippleVisible: {
  7706. opacity: 0.3,
  7707. transform: 'scale(1)',
  7708. animation: "$enter ".concat(DURATION, "ms ").concat(theme.transitions.easing.easeInOut)
  7709. },
  7710.  
  7711. /* Styles applied to the internal `Ripple` components `ripplePulsate` class. */
  7712. ripplePulsate: {
  7713. animationDuration: "".concat(theme.transitions.duration.shorter, "ms")
  7714. },
  7715.  
  7716. /* Styles applied to the internal `Ripple` components `child` class. */
  7717. child: {
  7718. opacity: 1,
  7719. display: 'block',
  7720. width: '100%',
  7721. height: '100%',
  7722. borderRadius: '50%',
  7723. backgroundColor: 'currentColor'
  7724. },
  7725.  
  7726. /* Styles applied to the internal `Ripple` components `childLeaving` class. */
  7727. childLeaving: {
  7728. opacity: 0,
  7729. animation: "$exit ".concat(DURATION, "ms ").concat(theme.transitions.easing.easeInOut)
  7730. },
  7731.  
  7732. /* Styles applied to the internal `Ripple` components `childPulsate` class. */
  7733. childPulsate: {
  7734. position: 'absolute',
  7735. left: 0,
  7736. top: 0,
  7737. animation: "$pulsate 2500ms ".concat(theme.transitions.easing.easeInOut, " 200ms infinite")
  7738. },
  7739. '@keyframes enter': {
  7740. '0%': {
  7741. transform: 'scale(0)',
  7742. opacity: 0.1
  7743. },
  7744. '100%': {
  7745. transform: 'scale(1)',
  7746. opacity: 0.3
  7747. }
  7748. },
  7749. '@keyframes exit': {
  7750. '0%': {
  7751. opacity: 1
  7752. },
  7753. '100%': {
  7754. opacity: 0
  7755. }
  7756. },
  7757. '@keyframes pulsate': {
  7758. '0%': {
  7759. transform: 'scale(1)'
  7760. },
  7761. '50%': {
  7762. transform: 'scale(0.92)'
  7763. },
  7764. '100%': {
  7765. transform: 'scale(1)'
  7766. }
  7767. }
  7768. };
  7769. };
  7770. /**
  7771. * @ignore - internal component.
  7772. *
  7773. * TODO v5: Make private
  7774. */
  7775.  
  7776. var TouchRipple = /*#__PURE__*/React__namespace.forwardRef(function TouchRipple(props, ref) {
  7777. var _props$center = props.center,
  7778. centerProp = _props$center === void 0 ? false : _props$center,
  7779. classes = props.classes,
  7780. className = props.className,
  7781. other = _objectWithoutProperties(props, ["center", "classes", "className"]);
  7782.  
  7783. var _React$useState = React__namespace.useState([]),
  7784. ripples = _React$useState[0],
  7785. setRipples = _React$useState[1];
  7786.  
  7787. var nextKey = React__namespace.useRef(0);
  7788. var rippleCallback = React__namespace.useRef(null);
  7789. React__namespace.useEffect(function () {
  7790. if (rippleCallback.current) {
  7791. rippleCallback.current();
  7792. rippleCallback.current = null;
  7793. }
  7794. }, [ripples]); // Used to filter out mouse emulated events on mobile.
  7795.  
  7796. var ignoringMouseDown = React__namespace.useRef(false); // We use a timer in order to only show the ripples for touch "click" like events.
  7797. // We don't want to display the ripple for touch scroll events.
  7798.  
  7799. var startTimer = React__namespace.useRef(null); // This is the hook called once the previous timeout is ready.
  7800.  
  7801. var startTimerCommit = React__namespace.useRef(null);
  7802. var container = React__namespace.useRef(null);
  7803. React__namespace.useEffect(function () {
  7804. return function () {
  7805. clearTimeout(startTimer.current);
  7806. };
  7807. }, []);
  7808. var startCommit = React__namespace.useCallback(function (params) {
  7809. var pulsate = params.pulsate,
  7810. rippleX = params.rippleX,
  7811. rippleY = params.rippleY,
  7812. rippleSize = params.rippleSize,
  7813. cb = params.cb;
  7814. setRipples(function (oldRipples) {
  7815. return [].concat(_toConsumableArray(oldRipples), [/*#__PURE__*/React__namespace.createElement(Ripple, {
  7816. key: nextKey.current,
  7817. classes: classes,
  7818. timeout: DURATION,
  7819. pulsate: pulsate,
  7820. rippleX: rippleX,
  7821. rippleY: rippleY,
  7822. rippleSize: rippleSize
  7823. })]);
  7824. });
  7825. nextKey.current += 1;
  7826. rippleCallback.current = cb;
  7827. }, [classes]);
  7828. var start = React__namespace.useCallback(function () {
  7829. var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7830. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  7831. var cb = arguments.length > 2 ? arguments[2] : undefined;
  7832. var _options$pulsate = options.pulsate,
  7833. pulsate = _options$pulsate === void 0 ? false : _options$pulsate,
  7834. _options$center = options.center,
  7835. center = _options$center === void 0 ? centerProp || options.pulsate : _options$center,
  7836. _options$fakeElement = options.fakeElement,
  7837. fakeElement = _options$fakeElement === void 0 ? false : _options$fakeElement;
  7838.  
  7839. if (event.type === 'mousedown' && ignoringMouseDown.current) {
  7840. ignoringMouseDown.current = false;
  7841. return;
  7842. }
  7843.  
  7844. if (event.type === 'touchstart') {
  7845. ignoringMouseDown.current = true;
  7846. }
  7847.  
  7848. var element = fakeElement ? null : container.current;
  7849. var rect = element ? element.getBoundingClientRect() : {
  7850. width: 0,
  7851. height: 0,
  7852. left: 0,
  7853. top: 0
  7854. }; // Get the size of the ripple
  7855.  
  7856. var rippleX;
  7857. var rippleY;
  7858. var rippleSize;
  7859.  
  7860. if (center || event.clientX === 0 && event.clientY === 0 || !event.clientX && !event.touches) {
  7861. rippleX = Math.round(rect.width / 2);
  7862. rippleY = Math.round(rect.height / 2);
  7863. } else {
  7864. var _ref = event.touches ? event.touches[0] : event,
  7865. clientX = _ref.clientX,
  7866. clientY = _ref.clientY;
  7867.  
  7868. rippleX = Math.round(clientX - rect.left);
  7869. rippleY = Math.round(clientY - rect.top);
  7870. }
  7871.  
  7872. if (center) {
  7873. rippleSize = Math.sqrt((2 * Math.pow(rect.width, 2) + Math.pow(rect.height, 2)) / 3); // For some reason the animation is broken on Mobile Chrome if the size if even.
  7874.  
  7875. if (rippleSize % 2 === 0) {
  7876. rippleSize += 1;
  7877. }
  7878. } else {
  7879. var sizeX = Math.max(Math.abs((element ? element.clientWidth : 0) - rippleX), rippleX) * 2 + 2;
  7880. var sizeY = Math.max(Math.abs((element ? element.clientHeight : 0) - rippleY), rippleY) * 2 + 2;
  7881. rippleSize = Math.sqrt(Math.pow(sizeX, 2) + Math.pow(sizeY, 2));
  7882. } // Touche devices
  7883.  
  7884.  
  7885. if (event.touches) {
  7886. // check that this isn't another touchstart due to multitouch
  7887. // otherwise we will only clear a single timer when unmounting while two
  7888. // are running
  7889. if (startTimerCommit.current === null) {
  7890. // Prepare the ripple effect.
  7891. startTimerCommit.current = function () {
  7892. startCommit({
  7893. pulsate: pulsate,
  7894. rippleX: rippleX,
  7895. rippleY: rippleY,
  7896. rippleSize: rippleSize,
  7897. cb: cb
  7898. });
  7899. }; // Delay the execution of the ripple effect.
  7900.  
  7901.  
  7902. startTimer.current = setTimeout(function () {
  7903. if (startTimerCommit.current) {
  7904. startTimerCommit.current();
  7905. startTimerCommit.current = null;
  7906. }
  7907. }, DELAY_RIPPLE); // We have to make a tradeoff with this value.
  7908. }
  7909. } else {
  7910. startCommit({
  7911. pulsate: pulsate,
  7912. rippleX: rippleX,
  7913. rippleY: rippleY,
  7914. rippleSize: rippleSize,
  7915. cb: cb
  7916. });
  7917. }
  7918. }, [centerProp, startCommit]);
  7919. var pulsate = React__namespace.useCallback(function () {
  7920. start({}, {
  7921. pulsate: true
  7922. });
  7923. }, [start]);
  7924. var stop = React__namespace.useCallback(function (event, cb) {
  7925. clearTimeout(startTimer.current); // The touch interaction occurs too quickly.
  7926. // We still want to show ripple effect.
  7927.  
  7928. if (event.type === 'touchend' && startTimerCommit.current) {
  7929. event.persist();
  7930. startTimerCommit.current();
  7931. startTimerCommit.current = null;
  7932. startTimer.current = setTimeout(function () {
  7933. stop(event, cb);
  7934. });
  7935. return;
  7936. }
  7937.  
  7938. startTimerCommit.current = null;
  7939. setRipples(function (oldRipples) {
  7940. if (oldRipples.length > 0) {
  7941. return oldRipples.slice(1);
  7942. }
  7943.  
  7944. return oldRipples;
  7945. });
  7946. rippleCallback.current = cb;
  7947. }, []);
  7948. React__namespace.useImperativeHandle(ref, function () {
  7949. return {
  7950. pulsate: pulsate,
  7951. start: start,
  7952. stop: stop
  7953. };
  7954. }, [pulsate, start, stop]);
  7955. return /*#__PURE__*/React__namespace.createElement("span", _extends$1({
  7956. className: clsx(classes.root, className),
  7957. ref: container
  7958. }, other), /*#__PURE__*/React__namespace.createElement(TransitionGroup, {
  7959. component: null,
  7960. exit: true
  7961. }, ripples));
  7962. });
  7963. var TouchRipple$1 = withStyles(styles$f, {
  7964. flip: false,
  7965. name: 'MuiTouchRipple'
  7966. })( /*#__PURE__*/React__namespace.memo(TouchRipple));
  7967.  
  7968. var styles$e = {
  7969. /* Styles applied to the root element. */
  7970. root: {
  7971. display: 'inline-flex',
  7972. alignItems: 'center',
  7973. justifyContent: 'center',
  7974. position: 'relative',
  7975. WebkitTapHighlightColor: 'transparent',
  7976. backgroundColor: 'transparent',
  7977. // Reset default value
  7978. // We disable the focus ring for mouse, touch and keyboard users.
  7979. outline: 0,
  7980. border: 0,
  7981. margin: 0,
  7982. // Remove the margin in Safari
  7983. borderRadius: 0,
  7984. padding: 0,
  7985. // Remove the padding in Firefox
  7986. cursor: 'pointer',
  7987. userSelect: 'none',
  7988. verticalAlign: 'middle',
  7989. '-moz-appearance': 'none',
  7990. // Reset
  7991. '-webkit-appearance': 'none',
  7992. // Reset
  7993. textDecoration: 'none',
  7994. // So we take precedent over the style of a native <a /> element.
  7995. color: 'inherit',
  7996. '&::-moz-focus-inner': {
  7997. borderStyle: 'none' // Remove Firefox dotted outline.
  7998.  
  7999. },
  8000. '&$disabled': {
  8001. pointerEvents: 'none',
  8002. // Disable link interactions
  8003. cursor: 'default'
  8004. },
  8005. '@media print': {
  8006. colorAdjust: 'exact'
  8007. }
  8008. },
  8009.  
  8010. /* Pseudo-class applied to the root element if `disabled={true}`. */
  8011. disabled: {},
  8012.  
  8013. /* Pseudo-class applied to the root element if keyboard focused. */
  8014. focusVisible: {}
  8015. };
  8016. /**
  8017. * `ButtonBase` contains as few styles as possible.
  8018. * It aims to be a simple building block for creating a button.
  8019. * It contains a load of style reset and some focus/ripple logic.
  8020. */
  8021.  
  8022. var ButtonBase = /*#__PURE__*/React__namespace.forwardRef(function ButtonBase(props, ref) {
  8023. var action = props.action,
  8024. buttonRefProp = props.buttonRef,
  8025. _props$centerRipple = props.centerRipple,
  8026. centerRipple = _props$centerRipple === void 0 ? false : _props$centerRipple,
  8027. children = props.children,
  8028. classes = props.classes,
  8029. className = props.className,
  8030. _props$component = props.component,
  8031. component = _props$component === void 0 ? 'button' : _props$component,
  8032. _props$disabled = props.disabled,
  8033. disabled = _props$disabled === void 0 ? false : _props$disabled,
  8034. _props$disableRipple = props.disableRipple,
  8035. disableRipple = _props$disableRipple === void 0 ? false : _props$disableRipple,
  8036. _props$disableTouchRi = props.disableTouchRipple,
  8037. disableTouchRipple = _props$disableTouchRi === void 0 ? false : _props$disableTouchRi,
  8038. _props$focusRipple = props.focusRipple,
  8039. focusRipple = _props$focusRipple === void 0 ? false : _props$focusRipple,
  8040. focusVisibleClassName = props.focusVisibleClassName,
  8041. onBlur = props.onBlur,
  8042. onClick = props.onClick,
  8043. onFocus = props.onFocus,
  8044. onFocusVisible = props.onFocusVisible,
  8045. onKeyDown = props.onKeyDown,
  8046. onKeyUp = props.onKeyUp,
  8047. onMouseDown = props.onMouseDown,
  8048. onMouseLeave = props.onMouseLeave,
  8049. onMouseUp = props.onMouseUp,
  8050. onTouchEnd = props.onTouchEnd,
  8051. onTouchMove = props.onTouchMove,
  8052. onTouchStart = props.onTouchStart,
  8053. onDragLeave = props.onDragLeave,
  8054. _props$tabIndex = props.tabIndex,
  8055. tabIndex = _props$tabIndex === void 0 ? 0 : _props$tabIndex,
  8056. TouchRippleProps = props.TouchRippleProps,
  8057. _props$type = props.type,
  8058. type = _props$type === void 0 ? 'button' : _props$type,
  8059. other = _objectWithoutProperties(props, ["action", "buttonRef", "centerRipple", "children", "classes", "className", "component", "disabled", "disableRipple", "disableTouchRipple", "focusRipple", "focusVisibleClassName", "onBlur", "onClick", "onFocus", "onFocusVisible", "onKeyDown", "onKeyUp", "onMouseDown", "onMouseLeave", "onMouseUp", "onTouchEnd", "onTouchMove", "onTouchStart", "onDragLeave", "tabIndex", "TouchRippleProps", "type"]);
  8060.  
  8061. var buttonRef = React__namespace.useRef(null);
  8062.  
  8063. function getButtonNode() {
  8064. // #StrictMode ready
  8065. return ReactDOM__namespace.findDOMNode(buttonRef.current);
  8066. }
  8067.  
  8068. var rippleRef = React__namespace.useRef(null);
  8069.  
  8070. var _React$useState = React__namespace.useState(false),
  8071. focusVisible = _React$useState[0],
  8072. setFocusVisible = _React$useState[1];
  8073.  
  8074. if (disabled && focusVisible) {
  8075. setFocusVisible(false);
  8076. }
  8077.  
  8078. var _useIsFocusVisible = useIsFocusVisible(),
  8079. isFocusVisible = _useIsFocusVisible.isFocusVisible,
  8080. onBlurVisible = _useIsFocusVisible.onBlurVisible,
  8081. focusVisibleRef = _useIsFocusVisible.ref;
  8082.  
  8083. React__namespace.useImperativeHandle(action, function () {
  8084. return {
  8085. focusVisible: function focusVisible() {
  8086. setFocusVisible(true);
  8087. buttonRef.current.focus();
  8088. }
  8089. };
  8090. }, []);
  8091. React__namespace.useEffect(function () {
  8092. if (focusVisible && focusRipple && !disableRipple) {
  8093. rippleRef.current.pulsate();
  8094. }
  8095. }, [disableRipple, focusRipple, focusVisible]);
  8096.  
  8097. function useRippleHandler(rippleAction, eventCallback) {
  8098. var skipRippleAction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : disableTouchRipple;
  8099. return useEventCallback(function (event) {
  8100. if (eventCallback) {
  8101. eventCallback(event);
  8102. }
  8103.  
  8104. var ignore = skipRippleAction;
  8105.  
  8106. if (!ignore && rippleRef.current) {
  8107. rippleRef.current[rippleAction](event);
  8108. }
  8109.  
  8110. return true;
  8111. });
  8112. }
  8113.  
  8114. var handleMouseDown = useRippleHandler('start', onMouseDown);
  8115. var handleDragLeave = useRippleHandler('stop', onDragLeave);
  8116. var handleMouseUp = useRippleHandler('stop', onMouseUp);
  8117. var handleMouseLeave = useRippleHandler('stop', function (event) {
  8118. if (focusVisible) {
  8119. event.preventDefault();
  8120. }
  8121.  
  8122. if (onMouseLeave) {
  8123. onMouseLeave(event);
  8124. }
  8125. });
  8126. var handleTouchStart = useRippleHandler('start', onTouchStart);
  8127. var handleTouchEnd = useRippleHandler('stop', onTouchEnd);
  8128. var handleTouchMove = useRippleHandler('stop', onTouchMove);
  8129. var handleBlur = useRippleHandler('stop', function (event) {
  8130. if (focusVisible) {
  8131. onBlurVisible(event);
  8132. setFocusVisible(false);
  8133. }
  8134.  
  8135. if (onBlur) {
  8136. onBlur(event);
  8137. }
  8138. }, false);
  8139. var handleFocus = useEventCallback(function (event) {
  8140. // Fix for https://github.com/facebook/react/issues/7769
  8141. if (!buttonRef.current) {
  8142. buttonRef.current = event.currentTarget;
  8143. }
  8144.  
  8145. if (isFocusVisible(event)) {
  8146. setFocusVisible(true);
  8147.  
  8148. if (onFocusVisible) {
  8149. onFocusVisible(event);
  8150. }
  8151. }
  8152.  
  8153. if (onFocus) {
  8154. onFocus(event);
  8155. }
  8156. });
  8157.  
  8158. var isNonNativeButton = function isNonNativeButton() {
  8159. var button = getButtonNode();
  8160. return component && component !== 'button' && !(button.tagName === 'A' && button.href);
  8161. };
  8162. /**
  8163. * IE 11 shim for https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat
  8164. */
  8165.  
  8166.  
  8167. var keydownRef = React__namespace.useRef(false);
  8168. var handleKeyDown = useEventCallback(function (event) {
  8169. // Check if key is already down to avoid repeats being counted as multiple activations
  8170. if (focusRipple && !keydownRef.current && focusVisible && rippleRef.current && event.key === ' ') {
  8171. keydownRef.current = true;
  8172. event.persist();
  8173. rippleRef.current.stop(event, function () {
  8174. rippleRef.current.start(event);
  8175. });
  8176. }
  8177.  
  8178. if (event.target === event.currentTarget && isNonNativeButton() && event.key === ' ') {
  8179. event.preventDefault();
  8180. }
  8181.  
  8182. if (onKeyDown) {
  8183. onKeyDown(event);
  8184. } // Keyboard accessibility for non interactive elements
  8185.  
  8186.  
  8187. if (event.target === event.currentTarget && isNonNativeButton() && event.key === 'Enter' && !disabled) {
  8188. event.preventDefault();
  8189.  
  8190. if (onClick) {
  8191. onClick(event);
  8192. }
  8193. }
  8194. });
  8195. var handleKeyUp = useEventCallback(function (event) {
  8196. // calling preventDefault in keyUp on a <button> will not dispatch a click event if Space is pressed
  8197. // https://codesandbox.io/s/button-keyup-preventdefault-dn7f0
  8198. if (focusRipple && event.key === ' ' && rippleRef.current && focusVisible && !event.defaultPrevented) {
  8199. keydownRef.current = false;
  8200. event.persist();
  8201. rippleRef.current.stop(event, function () {
  8202. rippleRef.current.pulsate(event);
  8203. });
  8204. }
  8205.  
  8206. if (onKeyUp) {
  8207. onKeyUp(event);
  8208. } // Keyboard accessibility for non interactive elements
  8209.  
  8210.  
  8211. if (onClick && event.target === event.currentTarget && isNonNativeButton() && event.key === ' ' && !event.defaultPrevented) {
  8212. onClick(event);
  8213. }
  8214. });
  8215. var ComponentProp = component;
  8216.  
  8217. if (ComponentProp === 'button' && other.href) {
  8218. ComponentProp = 'a';
  8219. }
  8220.  
  8221. var buttonProps = {};
  8222.  
  8223. if (ComponentProp === 'button') {
  8224. buttonProps.type = type;
  8225. buttonProps.disabled = disabled;
  8226. } else {
  8227. if (ComponentProp !== 'a' || !other.href) {
  8228. buttonProps.role = 'button';
  8229. }
  8230.  
  8231. buttonProps['aria-disabled'] = disabled;
  8232. }
  8233.  
  8234. var handleUserRef = useForkRef(buttonRefProp, ref);
  8235. var handleOwnRef = useForkRef(focusVisibleRef, buttonRef);
  8236. var handleRef = useForkRef(handleUserRef, handleOwnRef);
  8237.  
  8238. var _React$useState2 = React__namespace.useState(false),
  8239. mountedState = _React$useState2[0],
  8240. setMountedState = _React$useState2[1];
  8241.  
  8242. React__namespace.useEffect(function () {
  8243. setMountedState(true);
  8244. }, []);
  8245. var enableTouchRipple = mountedState && !disableRipple && !disabled;
  8246.  
  8247. return /*#__PURE__*/React__namespace.createElement(ComponentProp, _extends$1({
  8248. className: clsx(classes.root, className, focusVisible && [classes.focusVisible, focusVisibleClassName], disabled && classes.disabled),
  8249. onBlur: handleBlur,
  8250. onClick: onClick,
  8251. onFocus: handleFocus,
  8252. onKeyDown: handleKeyDown,
  8253. onKeyUp: handleKeyUp,
  8254. onMouseDown: handleMouseDown,
  8255. onMouseLeave: handleMouseLeave,
  8256. onMouseUp: handleMouseUp,
  8257. onDragLeave: handleDragLeave,
  8258. onTouchEnd: handleTouchEnd,
  8259. onTouchMove: handleTouchMove,
  8260. onTouchStart: handleTouchStart,
  8261. ref: handleRef,
  8262. tabIndex: disabled ? -1 : tabIndex
  8263. }, buttonProps, other), children, enableTouchRipple ?
  8264. /*#__PURE__*/
  8265.  
  8266. /* TouchRipple is only needed client-side, x2 boost on the server. */
  8267. React__namespace.createElement(TouchRipple$1, _extends$1({
  8268. ref: rippleRef,
  8269. center: centerRipple
  8270. }, TouchRippleProps)) : null);
  8271. });
  8272. var ButtonBase$1 = withStyles(styles$e, {
  8273. name: 'MuiButtonBase'
  8274. })(ButtonBase);
  8275.  
  8276. var styles$d = function styles(theme) {
  8277. return {
  8278. /* Styles applied to the root element. */
  8279. root: {
  8280. textAlign: 'center',
  8281. flex: '0 0 auto',
  8282. fontSize: theme.typography.pxToRem(24),
  8283. padding: 12,
  8284. borderRadius: '50%',
  8285. overflow: 'visible',
  8286. // Explicitly set the default value to solve a bug on IE 11.
  8287. color: theme.palette.action.active,
  8288. transition: theme.transitions.create('background-color', {
  8289. duration: theme.transitions.duration.shortest
  8290. }),
  8291. '&:hover': {
  8292. backgroundColor: fade(theme.palette.action.active, theme.palette.action.hoverOpacity),
  8293. // Reset on touch devices, it doesn't add specificity
  8294. '@media (hover: none)': {
  8295. backgroundColor: 'transparent'
  8296. }
  8297. },
  8298. '&$disabled': {
  8299. backgroundColor: 'transparent',
  8300. color: theme.palette.action.disabled
  8301. }
  8302. },
  8303.  
  8304. /* Styles applied to the root element if `edge="start"`. */
  8305. edgeStart: {
  8306. marginLeft: -12,
  8307. '$sizeSmall&': {
  8308. marginLeft: -3
  8309. }
  8310. },
  8311.  
  8312. /* Styles applied to the root element if `edge="end"`. */
  8313. edgeEnd: {
  8314. marginRight: -12,
  8315. '$sizeSmall&': {
  8316. marginRight: -3
  8317. }
  8318. },
  8319.  
  8320. /* Styles applied to the root element if `color="inherit"`. */
  8321. colorInherit: {
  8322. color: 'inherit'
  8323. },
  8324.  
  8325. /* Styles applied to the root element if `color="primary"`. */
  8326. colorPrimary: {
  8327. color: theme.palette.primary.main,
  8328. '&:hover': {
  8329. backgroundColor: fade(theme.palette.primary.main, theme.palette.action.hoverOpacity),
  8330. // Reset on touch devices, it doesn't add specificity
  8331. '@media (hover: none)': {
  8332. backgroundColor: 'transparent'
  8333. }
  8334. }
  8335. },
  8336.  
  8337. /* Styles applied to the root element if `color="secondary"`. */
  8338. colorSecondary: {
  8339. color: theme.palette.secondary.main,
  8340. '&:hover': {
  8341. backgroundColor: fade(theme.palette.secondary.main, theme.palette.action.hoverOpacity),
  8342. // Reset on touch devices, it doesn't add specificity
  8343. '@media (hover: none)': {
  8344. backgroundColor: 'transparent'
  8345. }
  8346. }
  8347. },
  8348.  
  8349. /* Pseudo-class applied to the root element if `disabled={true}`. */
  8350. disabled: {},
  8351.  
  8352. /* Styles applied to the root element if `size="small"`. */
  8353. sizeSmall: {
  8354. padding: 3,
  8355. fontSize: theme.typography.pxToRem(18)
  8356. },
  8357.  
  8358. /* Styles applied to the children container element. */
  8359. label: {
  8360. width: '100%',
  8361. display: 'flex',
  8362. alignItems: 'inherit',
  8363. justifyContent: 'inherit'
  8364. }
  8365. };
  8366. };
  8367. /**
  8368. * Refer to the [Icons](/components/icons/) section of the documentation
  8369. * regarding the available icon options.
  8370. */
  8371.  
  8372. var IconButton = /*#__PURE__*/React__namespace.forwardRef(function IconButton(props, ref) {
  8373. var _props$edge = props.edge,
  8374. edge = _props$edge === void 0 ? false : _props$edge,
  8375. children = props.children,
  8376. classes = props.classes,
  8377. className = props.className,
  8378. _props$color = props.color,
  8379. color = _props$color === void 0 ? 'default' : _props$color,
  8380. _props$disabled = props.disabled,
  8381. disabled = _props$disabled === void 0 ? false : _props$disabled,
  8382. _props$disableFocusRi = props.disableFocusRipple,
  8383. disableFocusRipple = _props$disableFocusRi === void 0 ? false : _props$disableFocusRi,
  8384. _props$size = props.size,
  8385. size = _props$size === void 0 ? 'medium' : _props$size,
  8386. other = _objectWithoutProperties(props, ["edge", "children", "classes", "className", "color", "disabled", "disableFocusRipple", "size"]);
  8387.  
  8388. return /*#__PURE__*/React__namespace.createElement(ButtonBase$1, _extends$1({
  8389. className: clsx(classes.root, className, color !== 'default' && classes["color".concat(capitalize(color))], disabled && classes.disabled, size === "small" && classes["size".concat(capitalize(size))], {
  8390. 'start': classes.edgeStart,
  8391. 'end': classes.edgeEnd
  8392. }[edge]),
  8393. centerRipple: true,
  8394. focusRipple: !disableFocusRipple,
  8395. disabled: disabled,
  8396. ref: ref
  8397. }, other), /*#__PURE__*/React__namespace.createElement("span", {
  8398. className: classes.label
  8399. }, children));
  8400. });
  8401. var IconButton$1 = withStyles(styles$d, {
  8402. name: 'MuiIconButton'
  8403. })(IconButton);
  8404.  
  8405. var styles$c = {
  8406. entering: {
  8407. opacity: 1
  8408. },
  8409. entered: {
  8410. opacity: 1
  8411. }
  8412. };
  8413. var defaultTimeout = {
  8414. enter: duration.enteringScreen,
  8415. exit: duration.leavingScreen
  8416. };
  8417. /**
  8418. * The Fade transition is used by the [Modal](/components/modal/) component.
  8419. * It uses [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
  8420. */
  8421.  
  8422. var Fade = /*#__PURE__*/React__namespace.forwardRef(function Fade(props, ref) {
  8423. var children = props.children,
  8424. _props$disableStrictM = props.disableStrictModeCompat,
  8425. disableStrictModeCompat = _props$disableStrictM === void 0 ? false : _props$disableStrictM,
  8426. inProp = props.in,
  8427. onEnter = props.onEnter,
  8428. onEntered = props.onEntered,
  8429. onEntering = props.onEntering,
  8430. onExit = props.onExit,
  8431. onExited = props.onExited,
  8432. onExiting = props.onExiting,
  8433. style = props.style,
  8434. _props$TransitionComp = props.TransitionComponent,
  8435. TransitionComponent = _props$TransitionComp === void 0 ? Transition : _props$TransitionComp,
  8436. _props$timeout = props.timeout,
  8437. timeout = _props$timeout === void 0 ? defaultTimeout : _props$timeout,
  8438. other = _objectWithoutProperties(props, ["children", "disableStrictModeCompat", "in", "onEnter", "onEntered", "onEntering", "onExit", "onExited", "onExiting", "style", "TransitionComponent", "timeout"]);
  8439.  
  8440. var theme = useTheme();
  8441. var enableStrictModeCompat = theme.unstable_strictMode && !disableStrictModeCompat;
  8442. var nodeRef = React__namespace.useRef(null);
  8443. var foreignRef = useForkRef(children.ref, ref);
  8444. var handleRef = useForkRef(enableStrictModeCompat ? nodeRef : undefined, foreignRef);
  8445.  
  8446. var normalizedTransitionCallback = function normalizedTransitionCallback(callback) {
  8447. return function (nodeOrAppearing, maybeAppearing) {
  8448. if (callback) {
  8449. var _ref = enableStrictModeCompat ? [nodeRef.current, nodeOrAppearing] : [nodeOrAppearing, maybeAppearing],
  8450. _ref2 = _slicedToArray(_ref, 2),
  8451. node = _ref2[0],
  8452. isAppearing = _ref2[1]; // onEnterXxx and onExitXxx callbacks have a different arguments.length value.
  8453.  
  8454.  
  8455. if (isAppearing === undefined) {
  8456. callback(node);
  8457. } else {
  8458. callback(node, isAppearing);
  8459. }
  8460. }
  8461. };
  8462. };
  8463.  
  8464. var handleEntering = normalizedTransitionCallback(onEntering);
  8465. var handleEnter = normalizedTransitionCallback(function (node, isAppearing) {
  8466. reflow(node); // So the animation always start from the start.
  8467.  
  8468. var transitionProps = getTransitionProps({
  8469. style: style,
  8470. timeout: timeout
  8471. }, {
  8472. mode: 'enter'
  8473. });
  8474. node.style.webkitTransition = theme.transitions.create('opacity', transitionProps);
  8475. node.style.transition = theme.transitions.create('opacity', transitionProps);
  8476.  
  8477. if (onEnter) {
  8478. onEnter(node, isAppearing);
  8479. }
  8480. });
  8481. var handleEntered = normalizedTransitionCallback(onEntered);
  8482. var handleExiting = normalizedTransitionCallback(onExiting);
  8483. var handleExit = normalizedTransitionCallback(function (node) {
  8484. var transitionProps = getTransitionProps({
  8485. style: style,
  8486. timeout: timeout
  8487. }, {
  8488. mode: 'exit'
  8489. });
  8490. node.style.webkitTransition = theme.transitions.create('opacity', transitionProps);
  8491. node.style.transition = theme.transitions.create('opacity', transitionProps);
  8492.  
  8493. if (onExit) {
  8494. onExit(node);
  8495. }
  8496. });
  8497. var handleExited = normalizedTransitionCallback(onExited);
  8498. return /*#__PURE__*/React__namespace.createElement(TransitionComponent, _extends$1({
  8499. appear: true,
  8500. in: inProp,
  8501. nodeRef: enableStrictModeCompat ? nodeRef : undefined,
  8502. onEnter: handleEnter,
  8503. onEntered: handleEntered,
  8504. onEntering: handleEntering,
  8505. onExit: handleExit,
  8506. onExited: handleExited,
  8507. onExiting: handleExiting,
  8508. timeout: timeout
  8509. }, other), function (state, childProps) {
  8510. return /*#__PURE__*/React__namespace.cloneElement(children, _extends$1({
  8511. style: _extends$1({
  8512. opacity: 0,
  8513. visibility: state === 'exited' && !inProp ? 'hidden' : undefined
  8514. }, styles$c[state], style, children.props.style),
  8515. ref: handleRef
  8516. }, childProps));
  8517. });
  8518. });
  8519.  
  8520. var styleFunction = css$1(compose(borders, display, flexbox, grid, positions, palette, boxShadow, sizing, spacing, typography));
  8521. /**
  8522. * @ignore - do not document.
  8523. */
  8524.  
  8525. var Box = styled('div')(styleFunction, {
  8526. name: 'MuiBox'
  8527. });
  8528.  
  8529. var styles$b = function styles(theme) {
  8530. return {
  8531. /* Styles applied to the root element. */
  8532. root: {
  8533. margin: 0
  8534. },
  8535.  
  8536. /* Styles applied to the root element if `variant="body2"`. */
  8537. body2: theme.typography.body2,
  8538.  
  8539. /* Styles applied to the root element if `variant="body1"`. */
  8540. body1: theme.typography.body1,
  8541.  
  8542. /* Styles applied to the root element if `variant="caption"`. */
  8543. caption: theme.typography.caption,
  8544.  
  8545. /* Styles applied to the root element if `variant="button"`. */
  8546. button: theme.typography.button,
  8547.  
  8548. /* Styles applied to the root element if `variant="h1"`. */
  8549. h1: theme.typography.h1,
  8550.  
  8551. /* Styles applied to the root element if `variant="h2"`. */
  8552. h2: theme.typography.h2,
  8553.  
  8554. /* Styles applied to the root element if `variant="h3"`. */
  8555. h3: theme.typography.h3,
  8556.  
  8557. /* Styles applied to the root element if `variant="h4"`. */
  8558. h4: theme.typography.h4,
  8559.  
  8560. /* Styles applied to the root element if `variant="h5"`. */
  8561. h5: theme.typography.h5,
  8562.  
  8563. /* Styles applied to the root element if `variant="h6"`. */
  8564. h6: theme.typography.h6,
  8565.  
  8566. /* Styles applied to the root element if `variant="subtitle1"`. */
  8567. subtitle1: theme.typography.subtitle1,
  8568.  
  8569. /* Styles applied to the root element if `variant="subtitle2"`. */
  8570. subtitle2: theme.typography.subtitle2,
  8571.  
  8572. /* Styles applied to the root element if `variant="overline"`. */
  8573. overline: theme.typography.overline,
  8574.  
  8575. /* Styles applied to the root element if `variant="srOnly"`. Only accessible to screen readers. */
  8576. srOnly: {
  8577. position: 'absolute',
  8578. height: 1,
  8579. width: 1,
  8580. overflow: 'hidden'
  8581. },
  8582.  
  8583. /* Styles applied to the root element if `align="left"`. */
  8584. alignLeft: {
  8585. textAlign: 'left'
  8586. },
  8587.  
  8588. /* Styles applied to the root element if `align="center"`. */
  8589. alignCenter: {
  8590. textAlign: 'center'
  8591. },
  8592.  
  8593. /* Styles applied to the root element if `align="right"`. */
  8594. alignRight: {
  8595. textAlign: 'right'
  8596. },
  8597.  
  8598. /* Styles applied to the root element if `align="justify"`. */
  8599. alignJustify: {
  8600. textAlign: 'justify'
  8601. },
  8602.  
  8603. /* Styles applied to the root element if `nowrap={true}`. */
  8604. noWrap: {
  8605. overflow: 'hidden',
  8606. textOverflow: 'ellipsis',
  8607. whiteSpace: 'nowrap'
  8608. },
  8609.  
  8610. /* Styles applied to the root element if `gutterBottom={true}`. */
  8611. gutterBottom: {
  8612. marginBottom: '0.35em'
  8613. },
  8614.  
  8615. /* Styles applied to the root element if `paragraph={true}`. */
  8616. paragraph: {
  8617. marginBottom: 16
  8618. },
  8619.  
  8620. /* Styles applied to the root element if `color="inherit"`. */
  8621. colorInherit: {
  8622. color: 'inherit'
  8623. },
  8624.  
  8625. /* Styles applied to the root element if `color="primary"`. */
  8626. colorPrimary: {
  8627. color: theme.palette.primary.main
  8628. },
  8629.  
  8630. /* Styles applied to the root element if `color="secondary"`. */
  8631. colorSecondary: {
  8632. color: theme.palette.secondary.main
  8633. },
  8634.  
  8635. /* Styles applied to the root element if `color="textPrimary"`. */
  8636. colorTextPrimary: {
  8637. color: theme.palette.text.primary
  8638. },
  8639.  
  8640. /* Styles applied to the root element if `color="textSecondary"`. */
  8641. colorTextSecondary: {
  8642. color: theme.palette.text.secondary
  8643. },
  8644.  
  8645. /* Styles applied to the root element if `color="error"`. */
  8646. colorError: {
  8647. color: theme.palette.error.main
  8648. },
  8649.  
  8650. /* Styles applied to the root element if `display="inline"`. */
  8651. displayInline: {
  8652. display: 'inline'
  8653. },
  8654.  
  8655. /* Styles applied to the root element if `display="block"`. */
  8656. displayBlock: {
  8657. display: 'block'
  8658. }
  8659. };
  8660. };
  8661. var defaultVariantMapping = {
  8662. h1: 'h1',
  8663. h2: 'h2',
  8664. h3: 'h3',
  8665. h4: 'h4',
  8666. h5: 'h5',
  8667. h6: 'h6',
  8668. subtitle1: 'h6',
  8669. subtitle2: 'h6',
  8670. body1: 'p',
  8671. body2: 'p'
  8672. };
  8673. var Typography = /*#__PURE__*/React__namespace.forwardRef(function Typography(props, ref) {
  8674. var _props$align = props.align,
  8675. align = _props$align === void 0 ? 'inherit' : _props$align,
  8676. classes = props.classes,
  8677. className = props.className,
  8678. _props$color = props.color,
  8679. color = _props$color === void 0 ? 'initial' : _props$color,
  8680. component = props.component,
  8681. _props$display = props.display,
  8682. display = _props$display === void 0 ? 'initial' : _props$display,
  8683. _props$gutterBottom = props.gutterBottom,
  8684. gutterBottom = _props$gutterBottom === void 0 ? false : _props$gutterBottom,
  8685. _props$noWrap = props.noWrap,
  8686. noWrap = _props$noWrap === void 0 ? false : _props$noWrap,
  8687. _props$paragraph = props.paragraph,
  8688. paragraph = _props$paragraph === void 0 ? false : _props$paragraph,
  8689. _props$variant = props.variant,
  8690. variant = _props$variant === void 0 ? 'body1' : _props$variant,
  8691. _props$variantMapping = props.variantMapping,
  8692. variantMapping = _props$variantMapping === void 0 ? defaultVariantMapping : _props$variantMapping,
  8693. other = _objectWithoutProperties(props, ["align", "classes", "className", "color", "component", "display", "gutterBottom", "noWrap", "paragraph", "variant", "variantMapping"]);
  8694.  
  8695. var Component = component || (paragraph ? 'p' : variantMapping[variant] || defaultVariantMapping[variant]) || 'span';
  8696. return /*#__PURE__*/React__namespace.createElement(Component, _extends$1({
  8697. className: clsx(classes.root, className, variant !== 'inherit' && classes[variant], color !== 'initial' && classes["color".concat(capitalize(color))], noWrap && classes.noWrap, gutterBottom && classes.gutterBottom, paragraph && classes.paragraph, align !== 'inherit' && classes["align".concat(capitalize(align))], display !== 'initial' && classes["display".concat(capitalize(display))]),
  8698. ref: ref
  8699. }, other));
  8700. });
  8701. var Typography$1 = withStyles(styles$b, {
  8702. name: 'MuiTypography'
  8703. })(Typography);
  8704.  
  8705. /**
  8706. * @ignore - internal component.
  8707. */
  8708.  
  8709. var FormControlContext = /*#__PURE__*/React__namespace.createContext();
  8710.  
  8711. function useFormControl() {
  8712. return React__namespace.useContext(FormControlContext);
  8713. }
  8714.  
  8715. var styles$a = {
  8716. root: {
  8717. padding: 9
  8718. },
  8719. checked: {},
  8720. disabled: {},
  8721. input: {
  8722. cursor: 'inherit',
  8723. position: 'absolute',
  8724. opacity: 0,
  8725. width: '100%',
  8726. height: '100%',
  8727. top: 0,
  8728. left: 0,
  8729. margin: 0,
  8730. padding: 0,
  8731. zIndex: 1
  8732. }
  8733. };
  8734. /**
  8735. * @ignore - internal component.
  8736. */
  8737.  
  8738. var SwitchBase = /*#__PURE__*/React__namespace.forwardRef(function SwitchBase(props, ref) {
  8739. var autoFocus = props.autoFocus,
  8740. checkedProp = props.checked,
  8741. checkedIcon = props.checkedIcon,
  8742. classes = props.classes,
  8743. className = props.className,
  8744. defaultChecked = props.defaultChecked,
  8745. disabledProp = props.disabled,
  8746. icon = props.icon,
  8747. id = props.id,
  8748. inputProps = props.inputProps,
  8749. inputRef = props.inputRef,
  8750. name = props.name,
  8751. onBlur = props.onBlur,
  8752. onChange = props.onChange,
  8753. onFocus = props.onFocus,
  8754. readOnly = props.readOnly,
  8755. required = props.required,
  8756. tabIndex = props.tabIndex,
  8757. type = props.type,
  8758. value = props.value,
  8759. other = _objectWithoutProperties(props, ["autoFocus", "checked", "checkedIcon", "classes", "className", "defaultChecked", "disabled", "icon", "id", "inputProps", "inputRef", "name", "onBlur", "onChange", "onFocus", "readOnly", "required", "tabIndex", "type", "value"]);
  8760.  
  8761. var _useControlled = useControlled({
  8762. controlled: checkedProp,
  8763. default: Boolean(defaultChecked),
  8764. name: 'SwitchBase',
  8765. state: 'checked'
  8766. }),
  8767. _useControlled2 = _slicedToArray(_useControlled, 2),
  8768. checked = _useControlled2[0],
  8769. setCheckedState = _useControlled2[1];
  8770.  
  8771. var muiFormControl = useFormControl();
  8772.  
  8773. var handleFocus = function handleFocus(event) {
  8774. if (onFocus) {
  8775. onFocus(event);
  8776. }
  8777.  
  8778. if (muiFormControl && muiFormControl.onFocus) {
  8779. muiFormControl.onFocus(event);
  8780. }
  8781. };
  8782.  
  8783. var handleBlur = function handleBlur(event) {
  8784. if (onBlur) {
  8785. onBlur(event);
  8786. }
  8787.  
  8788. if (muiFormControl && muiFormControl.onBlur) {
  8789. muiFormControl.onBlur(event);
  8790. }
  8791. };
  8792.  
  8793. var handleInputChange = function handleInputChange(event) {
  8794. var newChecked = event.target.checked;
  8795. setCheckedState(newChecked);
  8796.  
  8797. if (onChange) {
  8798. // TODO v5: remove the second argument.
  8799. onChange(event, newChecked);
  8800. }
  8801. };
  8802.  
  8803. var disabled = disabledProp;
  8804.  
  8805. if (muiFormControl) {
  8806. if (typeof disabled === 'undefined') {
  8807. disabled = muiFormControl.disabled;
  8808. }
  8809. }
  8810.  
  8811. var hasLabelFor = type === 'checkbox' || type === 'radio';
  8812. return /*#__PURE__*/React__namespace.createElement(IconButton$1, _extends$1({
  8813. component: "span",
  8814. className: clsx(classes.root, className, checked && classes.checked, disabled && classes.disabled),
  8815. disabled: disabled,
  8816. tabIndex: null,
  8817. role: undefined,
  8818. onFocus: handleFocus,
  8819. onBlur: handleBlur,
  8820. ref: ref
  8821. }, other), /*#__PURE__*/React__namespace.createElement("input", _extends$1({
  8822. autoFocus: autoFocus,
  8823. checked: checkedProp,
  8824. defaultChecked: defaultChecked,
  8825. className: classes.input,
  8826. disabled: disabled,
  8827. id: hasLabelFor && id,
  8828. name: name,
  8829. onChange: handleInputChange,
  8830. readOnly: readOnly,
  8831. ref: inputRef,
  8832. required: required,
  8833. tabIndex: tabIndex,
  8834. type: type,
  8835. value: value
  8836. }, inputProps)), checked ? checkedIcon : icon);
  8837. }); // NB: If changed, please update Checkbox, Switch and Radio
  8838. var SwitchBase$1 = withStyles(styles$a, {
  8839. name: 'PrivateSwitchBase'
  8840. })(SwitchBase);
  8841.  
  8842. function mapEventPropToEvent(eventProp) {
  8843. return eventProp.substring(2).toLowerCase();
  8844. }
  8845.  
  8846. function clickedRootScrollbar(event) {
  8847. return document.documentElement.clientWidth < event.clientX || document.documentElement.clientHeight < event.clientY;
  8848. }
  8849. /**
  8850. * Listen for click events that occur somewhere in the document, outside of the element itself.
  8851. * For instance, if you need to hide a menu when people click anywhere else on your page.
  8852. */
  8853.  
  8854.  
  8855. function ClickAwayListener(props) {
  8856. var children = props.children,
  8857. _props$disableReactTr = props.disableReactTree,
  8858. disableReactTree = _props$disableReactTr === void 0 ? false : _props$disableReactTr,
  8859. _props$mouseEvent = props.mouseEvent,
  8860. mouseEvent = _props$mouseEvent === void 0 ? 'onClick' : _props$mouseEvent,
  8861. onClickAway = props.onClickAway,
  8862. _props$touchEvent = props.touchEvent,
  8863. touchEvent = _props$touchEvent === void 0 ? 'onTouchEnd' : _props$touchEvent;
  8864. var movedRef = React__namespace.useRef(false);
  8865. var nodeRef = React__namespace.useRef(null);
  8866. var activatedRef = React__namespace.useRef(false);
  8867. var syntheticEventRef = React__namespace.useRef(false);
  8868. React__namespace.useEffect(function () {
  8869. // Ensure that this component is not "activated" synchronously.
  8870. // https://github.com/facebook/react/issues/20074
  8871. setTimeout(function () {
  8872. activatedRef.current = true;
  8873. }, 0);
  8874. return function () {
  8875. activatedRef.current = false;
  8876. };
  8877. }, []); // can be removed once we drop support for non ref forwarding class components
  8878.  
  8879. var handleOwnRef = React__namespace.useCallback(function (instance) {
  8880. // #StrictMode ready
  8881. nodeRef.current = ReactDOM__namespace.findDOMNode(instance);
  8882. }, []);
  8883. var handleRef = useForkRef(children.ref, handleOwnRef); // The handler doesn't take event.defaultPrevented into account:
  8884. //
  8885. // event.preventDefault() is meant to stop default behaviours like
  8886. // clicking a checkbox to check it, hitting a button to submit a form,
  8887. // and hitting left arrow to move the cursor in a text input etc.
  8888. // Only special HTML elements have these default behaviors.
  8889.  
  8890. var handleClickAway = useEventCallback(function (event) {
  8891. // Given developers can stop the propagation of the synthetic event,
  8892. // we can only be confident with a positive value.
  8893. var insideReactTree = syntheticEventRef.current;
  8894. syntheticEventRef.current = false; // 1. IE 11 support, which trigger the handleClickAway even after the unbind
  8895. // 2. The child might render null.
  8896. // 3. Behave like a blur listener.
  8897.  
  8898. if (!activatedRef.current || !nodeRef.current || clickedRootScrollbar(event)) {
  8899. return;
  8900. } // Do not act if user performed touchmove
  8901.  
  8902.  
  8903. if (movedRef.current) {
  8904. movedRef.current = false;
  8905. return;
  8906. }
  8907.  
  8908. var insideDOM; // If not enough, can use https://github.com/DieterHolvoet/event-propagation-path/blob/master/propagationPath.js
  8909.  
  8910. if (event.composedPath) {
  8911. insideDOM = event.composedPath().indexOf(nodeRef.current) > -1;
  8912. } else {
  8913. // TODO v6 remove dead logic https://caniuse.com/#search=composedPath.
  8914. var doc = ownerDocument(nodeRef.current);
  8915. insideDOM = !doc.documentElement.contains(event.target) || nodeRef.current.contains(event.target);
  8916. }
  8917.  
  8918. if (!insideDOM && (disableReactTree || !insideReactTree)) {
  8919. onClickAway(event);
  8920. }
  8921. }); // Keep track of mouse/touch events that bubbled up through the portal.
  8922.  
  8923. var createHandleSynthetic = function createHandleSynthetic(handlerName) {
  8924. return function (event) {
  8925. syntheticEventRef.current = true;
  8926. var childrenPropsHandler = children.props[handlerName];
  8927.  
  8928. if (childrenPropsHandler) {
  8929. childrenPropsHandler(event);
  8930. }
  8931. };
  8932. };
  8933.  
  8934. var childrenProps = {
  8935. ref: handleRef
  8936. };
  8937.  
  8938. if (touchEvent !== false) {
  8939. childrenProps[touchEvent] = createHandleSynthetic(touchEvent);
  8940. }
  8941.  
  8942. React__namespace.useEffect(function () {
  8943. if (touchEvent !== false) {
  8944. var mappedTouchEvent = mapEventPropToEvent(touchEvent);
  8945. var doc = ownerDocument(nodeRef.current);
  8946.  
  8947. var handleTouchMove = function handleTouchMove() {
  8948. movedRef.current = true;
  8949. };
  8950.  
  8951. doc.addEventListener(mappedTouchEvent, handleClickAway);
  8952. doc.addEventListener('touchmove', handleTouchMove);
  8953. return function () {
  8954. doc.removeEventListener(mappedTouchEvent, handleClickAway);
  8955. doc.removeEventListener('touchmove', handleTouchMove);
  8956. };
  8957. }
  8958.  
  8959. return undefined;
  8960. }, [handleClickAway, touchEvent]);
  8961.  
  8962. if (mouseEvent !== false) {
  8963. childrenProps[mouseEvent] = createHandleSynthetic(mouseEvent);
  8964. }
  8965.  
  8966. React__namespace.useEffect(function () {
  8967. if (mouseEvent !== false) {
  8968. var mappedMouseEvent = mapEventPropToEvent(mouseEvent);
  8969. var doc = ownerDocument(nodeRef.current);
  8970. doc.addEventListener(mappedMouseEvent, handleClickAway);
  8971. return function () {
  8972. doc.removeEventListener(mappedMouseEvent, handleClickAway);
  8973. };
  8974. }
  8975.  
  8976. return undefined;
  8977. }, [handleClickAway, mouseEvent]);
  8978. return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.cloneElement(children, childrenProps));
  8979. }
  8980.  
  8981. function getContainer(container) {
  8982. container = typeof container === 'function' ? container() : container; // #StrictMode ready
  8983.  
  8984. return ReactDOM__namespace.findDOMNode(container);
  8985. }
  8986.  
  8987. var useEnhancedEffect$2 = typeof window !== 'undefined' ? React__namespace.useLayoutEffect : React__namespace.useEffect;
  8988. /**
  8989. * Portals provide a first-class way to render children into a DOM node
  8990. * that exists outside the DOM hierarchy of the parent component.
  8991. */
  8992.  
  8993. var Portal = /*#__PURE__*/React__namespace.forwardRef(function Portal(props, ref) {
  8994. var children = props.children,
  8995. container = props.container,
  8996. _props$disablePortal = props.disablePortal,
  8997. disablePortal = _props$disablePortal === void 0 ? false : _props$disablePortal,
  8998. onRendered = props.onRendered;
  8999.  
  9000. var _React$useState = React__namespace.useState(null),
  9001. mountNode = _React$useState[0],
  9002. setMountNode = _React$useState[1];
  9003.  
  9004. var handleRef = useForkRef( /*#__PURE__*/ /*#__PURE__*/React__namespace.isValidElement(children) ? children.ref : null, ref);
  9005. useEnhancedEffect$2(function () {
  9006. if (!disablePortal) {
  9007. setMountNode(getContainer(container) || document.body);
  9008. }
  9009. }, [container, disablePortal]);
  9010. useEnhancedEffect$2(function () {
  9011. if (mountNode && !disablePortal) {
  9012. setRef(ref, mountNode);
  9013. return function () {
  9014. setRef(ref, null);
  9015. };
  9016. }
  9017.  
  9018. return undefined;
  9019. }, [ref, mountNode, disablePortal]);
  9020. useEnhancedEffect$2(function () {
  9021. if (onRendered && (mountNode || disablePortal)) {
  9022. onRendered();
  9023. }
  9024. }, [onRendered, mountNode, disablePortal]);
  9025.  
  9026. if (disablePortal) {
  9027. if ( /*#__PURE__*/React__namespace.isValidElement(children)) {
  9028. return /*#__PURE__*/React__namespace.cloneElement(children, {
  9029. ref: handleRef
  9030. });
  9031. }
  9032.  
  9033. return children;
  9034. }
  9035.  
  9036. return mountNode ? /*#__PURE__*/ReactDOM__namespace.createPortal(children, mountNode) : mountNode;
  9037. });
  9038.  
  9039. var styles$9 = function styles(theme) {
  9040. return {
  9041. /* Styles applied to the root element. */
  9042. root: {
  9043. height: 1,
  9044. margin: 0,
  9045. // Reset browser default style.
  9046. border: 'none',
  9047. flexShrink: 0,
  9048. backgroundColor: theme.palette.divider
  9049. },
  9050.  
  9051. /* Styles applied to the root element if `absolute={true}`. */
  9052. absolute: {
  9053. position: 'absolute',
  9054. bottom: 0,
  9055. left: 0,
  9056. width: '100%'
  9057. },
  9058.  
  9059. /* Styles applied to the root element if `variant="inset"`. */
  9060. inset: {
  9061. marginLeft: 72
  9062. },
  9063.  
  9064. /* Styles applied to the root element if `light={true}`. */
  9065. light: {
  9066. backgroundColor: fade(theme.palette.divider, 0.08)
  9067. },
  9068.  
  9069. /* Styles applied to the root element if `variant="middle"`. */
  9070. middle: {
  9071. marginLeft: theme.spacing(2),
  9072. marginRight: theme.spacing(2)
  9073. },
  9074.  
  9075. /* Styles applied to the root element if `orientation="vertical"`. */
  9076. vertical: {
  9077. height: '100%',
  9078. width: 1
  9079. },
  9080.  
  9081. /* Styles applied to the root element if `flexItem={true}`. */
  9082. flexItem: {
  9083. alignSelf: 'stretch',
  9084. height: 'auto'
  9085. }
  9086. };
  9087. };
  9088. var Divider = /*#__PURE__*/React__namespace.forwardRef(function Divider(props, ref) {
  9089. var _props$absolute = props.absolute,
  9090. absolute = _props$absolute === void 0 ? false : _props$absolute,
  9091. classes = props.classes,
  9092. className = props.className,
  9093. _props$component = props.component,
  9094. Component = _props$component === void 0 ? 'hr' : _props$component,
  9095. _props$flexItem = props.flexItem,
  9096. flexItem = _props$flexItem === void 0 ? false : _props$flexItem,
  9097. _props$light = props.light,
  9098. light = _props$light === void 0 ? false : _props$light,
  9099. _props$orientation = props.orientation,
  9100. orientation = _props$orientation === void 0 ? 'horizontal' : _props$orientation,
  9101. _props$role = props.role,
  9102. role = _props$role === void 0 ? Component !== 'hr' ? 'separator' : undefined : _props$role,
  9103. _props$variant = props.variant,
  9104. variant = _props$variant === void 0 ? 'fullWidth' : _props$variant,
  9105. other = _objectWithoutProperties(props, ["absolute", "classes", "className", "component", "flexItem", "light", "orientation", "role", "variant"]);
  9106.  
  9107. return /*#__PURE__*/React__namespace.createElement(Component, _extends$1({
  9108. className: clsx(classes.root, className, variant !== 'fullWidth' && classes[variant], absolute && classes.absolute, flexItem && classes.flexItem, light && classes.light, orientation === 'vertical' && classes.vertical),
  9109. role: role,
  9110. ref: ref
  9111. }, other));
  9112. });
  9113. var Divider$1 = withStyles(styles$9, {
  9114. name: 'MuiDivider'
  9115. })(Divider);
  9116.  
  9117. function getScale(value) {
  9118. return "scale(".concat(value, ", ").concat(Math.pow(value, 2), ")");
  9119. }
  9120.  
  9121. var styles$8 = {
  9122. entering: {
  9123. opacity: 1,
  9124. transform: getScale(1)
  9125. },
  9126. entered: {
  9127. opacity: 1,
  9128. transform: 'none'
  9129. }
  9130. };
  9131. /**
  9132. * The Grow transition is used by the [Tooltip](/components/tooltips/) and
  9133. * [Popover](/components/popover/) components.
  9134. * It uses [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
  9135. */
  9136.  
  9137. var Grow = /*#__PURE__*/React__namespace.forwardRef(function Grow(props, ref) {
  9138. var children = props.children,
  9139. _props$disableStrictM = props.disableStrictModeCompat,
  9140. disableStrictModeCompat = _props$disableStrictM === void 0 ? false : _props$disableStrictM,
  9141. inProp = props.in,
  9142. onEnter = props.onEnter,
  9143. onEntered = props.onEntered,
  9144. onEntering = props.onEntering,
  9145. onExit = props.onExit,
  9146. onExited = props.onExited,
  9147. onExiting = props.onExiting,
  9148. style = props.style,
  9149. _props$timeout = props.timeout,
  9150. timeout = _props$timeout === void 0 ? 'auto' : _props$timeout,
  9151. _props$TransitionComp = props.TransitionComponent,
  9152. TransitionComponent = _props$TransitionComp === void 0 ? Transition : _props$TransitionComp,
  9153. other = _objectWithoutProperties(props, ["children", "disableStrictModeCompat", "in", "onEnter", "onEntered", "onEntering", "onExit", "onExited", "onExiting", "style", "timeout", "TransitionComponent"]);
  9154.  
  9155. var timer = React__namespace.useRef();
  9156. var autoTimeout = React__namespace.useRef();
  9157. var theme = useTheme();
  9158. var enableStrictModeCompat = theme.unstable_strictMode && !disableStrictModeCompat;
  9159. var nodeRef = React__namespace.useRef(null);
  9160. var foreignRef = useForkRef(children.ref, ref);
  9161. var handleRef = useForkRef(enableStrictModeCompat ? nodeRef : undefined, foreignRef);
  9162.  
  9163. var normalizedTransitionCallback = function normalizedTransitionCallback(callback) {
  9164. return function (nodeOrAppearing, maybeAppearing) {
  9165. if (callback) {
  9166. var _ref = enableStrictModeCompat ? [nodeRef.current, nodeOrAppearing] : [nodeOrAppearing, maybeAppearing],
  9167. _ref2 = _slicedToArray(_ref, 2),
  9168. node = _ref2[0],
  9169. isAppearing = _ref2[1]; // onEnterXxx and onExitXxx callbacks have a different arguments.length value.
  9170.  
  9171.  
  9172. if (isAppearing === undefined) {
  9173. callback(node);
  9174. } else {
  9175. callback(node, isAppearing);
  9176. }
  9177. }
  9178. };
  9179. };
  9180.  
  9181. var handleEntering = normalizedTransitionCallback(onEntering);
  9182. var handleEnter = normalizedTransitionCallback(function (node, isAppearing) {
  9183. reflow(node); // So the animation always start from the start.
  9184.  
  9185. var _getTransitionProps = getTransitionProps({
  9186. style: style,
  9187. timeout: timeout
  9188. }, {
  9189. mode: 'enter'
  9190. }),
  9191. transitionDuration = _getTransitionProps.duration,
  9192. delay = _getTransitionProps.delay;
  9193.  
  9194. var duration;
  9195.  
  9196. if (timeout === 'auto') {
  9197. duration = theme.transitions.getAutoHeightDuration(node.clientHeight);
  9198. autoTimeout.current = duration;
  9199. } else {
  9200. duration = transitionDuration;
  9201. }
  9202.  
  9203. node.style.transition = [theme.transitions.create('opacity', {
  9204. duration: duration,
  9205. delay: delay
  9206. }), theme.transitions.create('transform', {
  9207. duration: duration * 0.666,
  9208. delay: delay
  9209. })].join(',');
  9210.  
  9211. if (onEnter) {
  9212. onEnter(node, isAppearing);
  9213. }
  9214. });
  9215. var handleEntered = normalizedTransitionCallback(onEntered);
  9216. var handleExiting = normalizedTransitionCallback(onExiting);
  9217. var handleExit = normalizedTransitionCallback(function (node) {
  9218. var _getTransitionProps2 = getTransitionProps({
  9219. style: style,
  9220. timeout: timeout
  9221. }, {
  9222. mode: 'exit'
  9223. }),
  9224. transitionDuration = _getTransitionProps2.duration,
  9225. delay = _getTransitionProps2.delay;
  9226.  
  9227. var duration;
  9228.  
  9229. if (timeout === 'auto') {
  9230. duration = theme.transitions.getAutoHeightDuration(node.clientHeight);
  9231. autoTimeout.current = duration;
  9232. } else {
  9233. duration = transitionDuration;
  9234. }
  9235.  
  9236. node.style.transition = [theme.transitions.create('opacity', {
  9237. duration: duration,
  9238. delay: delay
  9239. }), theme.transitions.create('transform', {
  9240. duration: duration * 0.666,
  9241. delay: delay || duration * 0.333
  9242. })].join(',');
  9243. node.style.opacity = '0';
  9244. node.style.transform = getScale(0.75);
  9245.  
  9246. if (onExit) {
  9247. onExit(node);
  9248. }
  9249. });
  9250. var handleExited = normalizedTransitionCallback(onExited);
  9251.  
  9252. var addEndListener = function addEndListener(nodeOrNext, maybeNext) {
  9253. var next = enableStrictModeCompat ? nodeOrNext : maybeNext;
  9254.  
  9255. if (timeout === 'auto') {
  9256. timer.current = setTimeout(next, autoTimeout.current || 0);
  9257. }
  9258. };
  9259.  
  9260. React__namespace.useEffect(function () {
  9261. return function () {
  9262. clearTimeout(timer.current);
  9263. };
  9264. }, []);
  9265. return /*#__PURE__*/React__namespace.createElement(TransitionComponent, _extends$1({
  9266. appear: true,
  9267. in: inProp,
  9268. nodeRef: enableStrictModeCompat ? nodeRef : undefined,
  9269. onEnter: handleEnter,
  9270. onEntered: handleEntered,
  9271. onEntering: handleEntering,
  9272. onExit: handleExit,
  9273. onExited: handleExited,
  9274. onExiting: handleExiting,
  9275. addEndListener: addEndListener,
  9276. timeout: timeout === 'auto' ? null : timeout
  9277. }, other), function (state, childProps) {
  9278. return /*#__PURE__*/React__namespace.cloneElement(children, _extends$1({
  9279. style: _extends$1({
  9280. opacity: 0,
  9281. transform: getScale(0.75),
  9282. visibility: state === 'exited' && !inProp ? 'hidden' : undefined
  9283. }, styles$8[state], style, children.props.style),
  9284. ref: handleRef
  9285. }, childProps));
  9286. });
  9287. });
  9288. Grow.muiSupportAuto = true;
  9289.  
  9290. /**
  9291. * @ignore - internal component.
  9292. */
  9293.  
  9294. var ListContext = /*#__PURE__*/React__namespace.createContext({});
  9295.  
  9296. var styles$7 = {
  9297. /* Styles applied to the root element. */
  9298. root: {
  9299. listStyle: 'none',
  9300. margin: 0,
  9301. padding: 0,
  9302. position: 'relative'
  9303. },
  9304.  
  9305. /* Styles applied to the root element if `disablePadding={false}`. */
  9306. padding: {
  9307. paddingTop: 8,
  9308. paddingBottom: 8
  9309. },
  9310.  
  9311. /* Styles applied to the root element if dense. */
  9312. dense: {},
  9313.  
  9314. /* Styles applied to the root element if a `subheader` is provided. */
  9315. subheader: {
  9316. paddingTop: 0
  9317. }
  9318. };
  9319. var List = /*#__PURE__*/React__namespace.forwardRef(function List(props, ref) {
  9320. var children = props.children,
  9321. classes = props.classes,
  9322. className = props.className,
  9323. _props$component = props.component,
  9324. Component = _props$component === void 0 ? 'ul' : _props$component,
  9325. _props$dense = props.dense,
  9326. dense = _props$dense === void 0 ? false : _props$dense,
  9327. _props$disablePadding = props.disablePadding,
  9328. disablePadding = _props$disablePadding === void 0 ? false : _props$disablePadding,
  9329. subheader = props.subheader,
  9330. other = _objectWithoutProperties(props, ["children", "classes", "className", "component", "dense", "disablePadding", "subheader"]);
  9331.  
  9332. var context = React__namespace.useMemo(function () {
  9333. return {
  9334. dense: dense
  9335. };
  9336. }, [dense]);
  9337. return /*#__PURE__*/React__namespace.createElement(ListContext.Provider, {
  9338. value: context
  9339. }, /*#__PURE__*/React__namespace.createElement(Component, _extends$1({
  9340. className: clsx(classes.root, className, dense && classes.dense, !disablePadding && classes.padding, subheader && classes.subheader),
  9341. ref: ref
  9342. }, other), subheader, children));
  9343. });
  9344. var List$1 = withStyles(styles$7, {
  9345. name: 'MuiList'
  9346. })(List);
  9347.  
  9348. var styles$6 = function styles(theme) {
  9349. return {
  9350. /* Styles applied to the (normally root) `component` element. May be wrapped by a `container`. */
  9351. root: {
  9352. display: 'flex',
  9353. justifyContent: 'flex-start',
  9354. alignItems: 'center',
  9355. position: 'relative',
  9356. textDecoration: 'none',
  9357. width: '100%',
  9358. boxSizing: 'border-box',
  9359. textAlign: 'left',
  9360. paddingTop: 8,
  9361. paddingBottom: 8,
  9362. '&$focusVisible': {
  9363. backgroundColor: theme.palette.action.selected
  9364. },
  9365. '&$selected, &$selected:hover': {
  9366. backgroundColor: theme.palette.action.selected
  9367. },
  9368. '&$disabled': {
  9369. opacity: 0.5
  9370. }
  9371. },
  9372.  
  9373. /* Styles applied to the `container` element if `children` includes `ListItemSecondaryAction`. */
  9374. container: {
  9375. position: 'relative'
  9376. },
  9377.  
  9378. /* Pseudo-class applied to the `component`'s `focusVisibleClassName` prop if `button={true}`. */
  9379. focusVisible: {},
  9380.  
  9381. /* Styles applied to the `component` element if dense. */
  9382. dense: {
  9383. paddingTop: 4,
  9384. paddingBottom: 4
  9385. },
  9386.  
  9387. /* Styles applied to the `component` element if `alignItems="flex-start"`. */
  9388. alignItemsFlexStart: {
  9389. alignItems: 'flex-start'
  9390. },
  9391.  
  9392. /* Pseudo-class applied to the inner `component` element if `disabled={true}`. */
  9393. disabled: {},
  9394.  
  9395. /* Styles applied to the inner `component` element if `divider={true}`. */
  9396. divider: {
  9397. borderBottom: "1px solid ".concat(theme.palette.divider),
  9398. backgroundClip: 'padding-box'
  9399. },
  9400.  
  9401. /* Styles applied to the inner `component` element if `disableGutters={false}`. */
  9402. gutters: {
  9403. paddingLeft: 16,
  9404. paddingRight: 16
  9405. },
  9406.  
  9407. /* Styles applied to the inner `component` element if `button={true}`. */
  9408. button: {
  9409. transition: theme.transitions.create('background-color', {
  9410. duration: theme.transitions.duration.shortest
  9411. }),
  9412. '&:hover': {
  9413. textDecoration: 'none',
  9414. backgroundColor: theme.palette.action.hover,
  9415. // Reset on touch devices, it doesn't add specificity
  9416. '@media (hover: none)': {
  9417. backgroundColor: 'transparent'
  9418. }
  9419. }
  9420. },
  9421.  
  9422. /* Styles applied to the `component` element if `children` includes `ListItemSecondaryAction`. */
  9423. secondaryAction: {
  9424. // Add some space to avoid collision as `ListItemSecondaryAction`
  9425. // is absolutely positioned.
  9426. paddingRight: 48
  9427. },
  9428.  
  9429. /* Pseudo-class applied to the root element if `selected={true}`. */
  9430. selected: {}
  9431. };
  9432. };
  9433. var useEnhancedEffect$1 = typeof window === 'undefined' ? React__namespace.useEffect : React__namespace.useLayoutEffect;
  9434. /**
  9435. * Uses an additional container component if `ListItemSecondaryAction` is the last child.
  9436. */
  9437.  
  9438. var ListItem = /*#__PURE__*/React__namespace.forwardRef(function ListItem(props, ref) {
  9439. var _props$alignItems = props.alignItems,
  9440. alignItems = _props$alignItems === void 0 ? 'center' : _props$alignItems,
  9441. _props$autoFocus = props.autoFocus,
  9442. autoFocus = _props$autoFocus === void 0 ? false : _props$autoFocus,
  9443. _props$button = props.button,
  9444. button = _props$button === void 0 ? false : _props$button,
  9445. childrenProp = props.children,
  9446. classes = props.classes,
  9447. className = props.className,
  9448. componentProp = props.component,
  9449. _props$ContainerCompo = props.ContainerComponent,
  9450. ContainerComponent = _props$ContainerCompo === void 0 ? 'li' : _props$ContainerCompo,
  9451. _props$ContainerProps = props.ContainerProps;
  9452. _props$ContainerProps = _props$ContainerProps === void 0 ? {} : _props$ContainerProps;
  9453.  
  9454. var ContainerClassName = _props$ContainerProps.className,
  9455. ContainerProps = _objectWithoutProperties(_props$ContainerProps, ["className"]),
  9456. _props$dense = props.dense,
  9457. dense = _props$dense === void 0 ? false : _props$dense,
  9458. _props$disabled = props.disabled,
  9459. disabled = _props$disabled === void 0 ? false : _props$disabled,
  9460. _props$disableGutters = props.disableGutters,
  9461. disableGutters = _props$disableGutters === void 0 ? false : _props$disableGutters,
  9462. _props$divider = props.divider,
  9463. divider = _props$divider === void 0 ? false : _props$divider,
  9464. focusVisibleClassName = props.focusVisibleClassName,
  9465. _props$selected = props.selected,
  9466. selected = _props$selected === void 0 ? false : _props$selected,
  9467. other = _objectWithoutProperties(props, ["alignItems", "autoFocus", "button", "children", "classes", "className", "component", "ContainerComponent", "ContainerProps", "dense", "disabled", "disableGutters", "divider", "focusVisibleClassName", "selected"]);
  9468.  
  9469. var context = React__namespace.useContext(ListContext);
  9470. var childContext = {
  9471. dense: dense || context.dense || false,
  9472. alignItems: alignItems
  9473. };
  9474. var listItemRef = React__namespace.useRef(null);
  9475. useEnhancedEffect$1(function () {
  9476. if (autoFocus) {
  9477. if (listItemRef.current) {
  9478. listItemRef.current.focus();
  9479. }
  9480. }
  9481. }, [autoFocus]);
  9482. var children = React__namespace.Children.toArray(childrenProp);
  9483. var hasSecondaryAction = children.length && isMuiElement(children[children.length - 1], ['ListItemSecondaryAction']);
  9484. var handleOwnRef = React__namespace.useCallback(function (instance) {
  9485. // #StrictMode ready
  9486. listItemRef.current = ReactDOM__namespace.findDOMNode(instance);
  9487. }, []);
  9488. var handleRef = useForkRef(handleOwnRef, ref);
  9489.  
  9490. var componentProps = _extends$1({
  9491. className: clsx(classes.root, className, childContext.dense && classes.dense, !disableGutters && classes.gutters, divider && classes.divider, disabled && classes.disabled, button && classes.button, alignItems !== "center" && classes.alignItemsFlexStart, hasSecondaryAction && classes.secondaryAction, selected && classes.selected),
  9492. disabled: disabled
  9493. }, other);
  9494.  
  9495. var Component = componentProp || 'li';
  9496.  
  9497. if (button) {
  9498. componentProps.component = componentProp || 'div';
  9499. componentProps.focusVisibleClassName = clsx(classes.focusVisible, focusVisibleClassName);
  9500. Component = ButtonBase$1;
  9501. }
  9502.  
  9503. if (hasSecondaryAction) {
  9504. // Use div by default.
  9505. Component = !componentProps.component && !componentProp ? 'div' : Component; // Avoid nesting of li > li.
  9506.  
  9507. if (ContainerComponent === 'li') {
  9508. if (Component === 'li') {
  9509. Component = 'div';
  9510. } else if (componentProps.component === 'li') {
  9511. componentProps.component = 'div';
  9512. }
  9513. }
  9514.  
  9515. return /*#__PURE__*/React__namespace.createElement(ListContext.Provider, {
  9516. value: childContext
  9517. }, /*#__PURE__*/React__namespace.createElement(ContainerComponent, _extends$1({
  9518. className: clsx(classes.container, ContainerClassName),
  9519. ref: handleRef
  9520. }, ContainerProps), /*#__PURE__*/React__namespace.createElement(Component, componentProps, children), children.pop()));
  9521. }
  9522.  
  9523. return /*#__PURE__*/React__namespace.createElement(ListContext.Provider, {
  9524. value: childContext
  9525. }, /*#__PURE__*/React__namespace.createElement(Component, _extends$1({
  9526. ref: handleRef
  9527. }, componentProps), children));
  9528. });
  9529. var ListItem$1 = withStyles(styles$6, {
  9530. name: 'MuiListItem'
  9531. })(ListItem);
  9532.  
  9533. var styles$5 = {
  9534. /* Styles applied to the root element. */
  9535. root: {
  9536. position: 'absolute',
  9537. right: 16,
  9538. top: '50%',
  9539. transform: 'translateY(-50%)'
  9540. }
  9541. };
  9542. /**
  9543. * Must be used as the last child of ListItem to function properly.
  9544. */
  9545.  
  9546. var ListItemSecondaryAction = /*#__PURE__*/React__namespace.forwardRef(function ListItemSecondaryAction(props, ref) {
  9547. var classes = props.classes,
  9548. className = props.className,
  9549. other = _objectWithoutProperties(props, ["classes", "className"]);
  9550.  
  9551. return /*#__PURE__*/React__namespace.createElement("div", _extends$1({
  9552. className: clsx(classes.root, className),
  9553. ref: ref
  9554. }, other));
  9555. });
  9556. ListItemSecondaryAction.muiName = 'ListItemSecondaryAction';
  9557. var ListItemSecondaryAction$1 = withStyles(styles$5, {
  9558. name: 'MuiListItemSecondaryAction'
  9559. })(ListItemSecondaryAction);
  9560.  
  9561. var styles$4 = {
  9562. /* Styles applied to the root element. */
  9563. root: {
  9564. flex: '1 1 auto',
  9565. minWidth: 0,
  9566. marginTop: 4,
  9567. marginBottom: 4
  9568. },
  9569.  
  9570. /* Styles applied to the `Typography` components if primary and secondary are set. */
  9571. multiline: {
  9572. marginTop: 6,
  9573. marginBottom: 6
  9574. },
  9575.  
  9576. /* Styles applied to the `Typography` components if dense. */
  9577. dense: {},
  9578.  
  9579. /* Styles applied to the root element if `inset={true}`. */
  9580. inset: {
  9581. paddingLeft: 56
  9582. },
  9583.  
  9584. /* Styles applied to the primary `Typography` component. */
  9585. primary: {},
  9586.  
  9587. /* Styles applied to the secondary `Typography` component. */
  9588. secondary: {}
  9589. };
  9590. var ListItemText = /*#__PURE__*/React__namespace.forwardRef(function ListItemText(props, ref) {
  9591. var children = props.children,
  9592. classes = props.classes,
  9593. className = props.className,
  9594. _props$disableTypogra = props.disableTypography,
  9595. disableTypography = _props$disableTypogra === void 0 ? false : _props$disableTypogra,
  9596. _props$inset = props.inset,
  9597. inset = _props$inset === void 0 ? false : _props$inset,
  9598. primaryProp = props.primary,
  9599. primaryTypographyProps = props.primaryTypographyProps,
  9600. secondaryProp = props.secondary,
  9601. secondaryTypographyProps = props.secondaryTypographyProps,
  9602. other = _objectWithoutProperties(props, ["children", "classes", "className", "disableTypography", "inset", "primary", "primaryTypographyProps", "secondary", "secondaryTypographyProps"]);
  9603.  
  9604. var _React$useContext = React__namespace.useContext(ListContext),
  9605. dense = _React$useContext.dense;
  9606.  
  9607. var primary = primaryProp != null ? primaryProp : children;
  9608.  
  9609. if (primary != null && primary.type !== Typography$1 && !disableTypography) {
  9610. primary = /*#__PURE__*/React__namespace.createElement(Typography$1, _extends$1({
  9611. variant: dense ? 'body2' : 'body1',
  9612. className: classes.primary,
  9613. component: "span",
  9614. display: "block"
  9615. }, primaryTypographyProps), primary);
  9616. }
  9617.  
  9618. var secondary = secondaryProp;
  9619.  
  9620. if (secondary != null && secondary.type !== Typography$1 && !disableTypography) {
  9621. secondary = /*#__PURE__*/React__namespace.createElement(Typography$1, _extends$1({
  9622. variant: "body2",
  9623. className: classes.secondary,
  9624. color: "textSecondary",
  9625. display: "block"
  9626. }, secondaryTypographyProps), secondary);
  9627. }
  9628.  
  9629. return /*#__PURE__*/React__namespace.createElement("div", _extends$1({
  9630. className: clsx(classes.root, className, dense && classes.dense, inset && classes.inset, primary && secondary && classes.multiline),
  9631. ref: ref
  9632. }, other), primary, secondary);
  9633. });
  9634. var ListItemText$1 = withStyles(styles$4, {
  9635. name: 'MuiListItemText'
  9636. })(ListItemText);
  9637.  
  9638. /**!
  9639. * @fileOverview Kickass library to create and place poppers near their reference elements.
  9640. * @version 1.16.1-lts
  9641. * @license
  9642. * Copyright (c) 2016 Federico Zivolo and contributors
  9643. *
  9644. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9645. * of this software and associated documentation files (the "Software"), to deal
  9646. * in the Software without restriction, including without limitation the rights
  9647. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9648. * copies of the Software, and to permit persons to whom the Software is
  9649. * furnished to do so, subject to the following conditions:
  9650. *
  9651. * The above copyright notice and this permission notice shall be included in all
  9652. * copies or substantial portions of the Software.
  9653. *
  9654. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9655. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9656. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9657. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9658. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9659. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  9660. * SOFTWARE.
  9661. */
  9662. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  9663.  
  9664. var timeoutDuration = function () {
  9665. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  9666.  
  9667. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  9668. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  9669. return 1;
  9670. }
  9671. }
  9672.  
  9673. return 0;
  9674. }();
  9675.  
  9676. function microtaskDebounce(fn) {
  9677. var called = false;
  9678. return function () {
  9679. if (called) {
  9680. return;
  9681. }
  9682.  
  9683. called = true;
  9684. window.Promise.resolve().then(function () {
  9685. called = false;
  9686. fn();
  9687. });
  9688. };
  9689. }
  9690.  
  9691. function taskDebounce(fn) {
  9692. var scheduled = false;
  9693. return function () {
  9694. if (!scheduled) {
  9695. scheduled = true;
  9696. setTimeout(function () {
  9697. scheduled = false;
  9698. fn();
  9699. }, timeoutDuration);
  9700. }
  9701. };
  9702. }
  9703.  
  9704. var supportsMicroTasks = isBrowser && window.Promise;
  9705. /**
  9706. * Create a debounced version of a method, that's asynchronously deferred
  9707. * but called in the minimum time possible.
  9708. *
  9709. * @method
  9710. * @memberof Popper.Utils
  9711. * @argument {Function} fn
  9712. * @returns {Function}
  9713. */
  9714.  
  9715. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  9716. /**
  9717. * Check if the given variable is a function
  9718. * @method
  9719. * @memberof Popper.Utils
  9720. * @argument {Any} functionToCheck - variable to check
  9721. * @returns {Boolean} answer to: is a function?
  9722. */
  9723.  
  9724. function isFunction(functionToCheck) {
  9725. var getType = {};
  9726. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  9727. }
  9728. /**
  9729. * Get CSS computed property of the given element
  9730. * @method
  9731. * @memberof Popper.Utils
  9732. * @argument {Eement} element
  9733. * @argument {String} property
  9734. */
  9735.  
  9736.  
  9737. function getStyleComputedProperty(element, property) {
  9738. if (element.nodeType !== 1) {
  9739. return [];
  9740. } // NOTE: 1 DOM access here
  9741.  
  9742.  
  9743. var window = element.ownerDocument.defaultView;
  9744. var css = window.getComputedStyle(element, null);
  9745. return property ? css[property] : css;
  9746. }
  9747. /**
  9748. * Returns the parentNode or the host of the element
  9749. * @method
  9750. * @memberof Popper.Utils
  9751. * @argument {Element} element
  9752. * @returns {Element} parent
  9753. */
  9754.  
  9755.  
  9756. function getParentNode(element) {
  9757. if (element.nodeName === 'HTML') {
  9758. return element;
  9759. }
  9760.  
  9761. return element.parentNode || element.host;
  9762. }
  9763. /**
  9764. * Returns the scrolling parent of the given element
  9765. * @method
  9766. * @memberof Popper.Utils
  9767. * @argument {Element} element
  9768. * @returns {Element} scroll parent
  9769. */
  9770.  
  9771.  
  9772. function getScrollParent(element) {
  9773. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  9774. if (!element) {
  9775. return document.body;
  9776. }
  9777.  
  9778. switch (element.nodeName) {
  9779. case 'HTML':
  9780. case 'BODY':
  9781. return element.ownerDocument.body;
  9782.  
  9783. case '#document':
  9784. return element.body;
  9785. } // Firefox want us to check `-x` and `-y` variations as well
  9786.  
  9787.  
  9788. var _getStyleComputedProp = getStyleComputedProperty(element),
  9789. overflow = _getStyleComputedProp.overflow,
  9790. overflowX = _getStyleComputedProp.overflowX,
  9791. overflowY = _getStyleComputedProp.overflowY;
  9792.  
  9793. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  9794. return element;
  9795. }
  9796.  
  9797. return getScrollParent(getParentNode(element));
  9798. }
  9799. /**
  9800. * Returns the reference node of the reference object, or the reference object itself.
  9801. * @method
  9802. * @memberof Popper.Utils
  9803. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  9804. * @returns {Element} parent
  9805. */
  9806.  
  9807.  
  9808. function getReferenceNode(reference) {
  9809. return reference && reference.referenceNode ? reference.referenceNode : reference;
  9810. }
  9811.  
  9812. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  9813. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  9814. /**
  9815. * Determines if the browser is Internet Explorer
  9816. * @method
  9817. * @memberof Popper.Utils
  9818. * @param {Number} version to check
  9819. * @returns {Boolean} isIE
  9820. */
  9821.  
  9822. function isIE(version) {
  9823. if (version === 11) {
  9824. return isIE11;
  9825. }
  9826.  
  9827. if (version === 10) {
  9828. return isIE10;
  9829. }
  9830.  
  9831. return isIE11 || isIE10;
  9832. }
  9833. /**
  9834. * Returns the offset parent of the given element
  9835. * @method
  9836. * @memberof Popper.Utils
  9837. * @argument {Element} element
  9838. * @returns {Element} offset parent
  9839. */
  9840.  
  9841.  
  9842. function getOffsetParent(element) {
  9843. if (!element) {
  9844. return document.documentElement;
  9845. }
  9846.  
  9847. var noOffsetParent = isIE(10) ? document.body : null; // NOTE: 1 DOM access here
  9848.  
  9849. var offsetParent = element.offsetParent || null; // Skip hidden elements which don't have an offsetParent
  9850.  
  9851. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  9852. offsetParent = (element = element.nextElementSibling).offsetParent;
  9853. }
  9854.  
  9855. var nodeName = offsetParent && offsetParent.nodeName;
  9856.  
  9857. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  9858. return element ? element.ownerDocument.documentElement : document.documentElement;
  9859. } // .offsetParent will return the closest TH, TD or TABLE in case
  9860. // no offsetParent is present, I hate this job...
  9861.  
  9862.  
  9863. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  9864. return getOffsetParent(offsetParent);
  9865. }
  9866.  
  9867. return offsetParent;
  9868. }
  9869.  
  9870. function isOffsetContainer(element) {
  9871. var nodeName = element.nodeName;
  9872.  
  9873. if (nodeName === 'BODY') {
  9874. return false;
  9875. }
  9876.  
  9877. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  9878. }
  9879. /**
  9880. * Finds the root node (document, shadowDOM root) of the given element
  9881. * @method
  9882. * @memberof Popper.Utils
  9883. * @argument {Element} node
  9884. * @returns {Element} root node
  9885. */
  9886.  
  9887.  
  9888. function getRoot(node) {
  9889. if (node.parentNode !== null) {
  9890. return getRoot(node.parentNode);
  9891. }
  9892.  
  9893. return node;
  9894. }
  9895. /**
  9896. * Finds the offset parent common to the two provided nodes
  9897. * @method
  9898. * @memberof Popper.Utils
  9899. * @argument {Element} element1
  9900. * @argument {Element} element2
  9901. * @returns {Element} common offset parent
  9902. */
  9903.  
  9904.  
  9905. function findCommonOffsetParent(element1, element2) {
  9906. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  9907. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  9908. return document.documentElement;
  9909. } // Here we make sure to give as "start" the element that comes first in the DOM
  9910.  
  9911.  
  9912. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  9913. var start = order ? element1 : element2;
  9914. var end = order ? element2 : element1; // Get common ancestor container
  9915.  
  9916. var range = document.createRange();
  9917. range.setStart(start, 0);
  9918. range.setEnd(end, 0);
  9919. var commonAncestorContainer = range.commonAncestorContainer; // Both nodes are inside #document
  9920.  
  9921. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  9922. if (isOffsetContainer(commonAncestorContainer)) {
  9923. return commonAncestorContainer;
  9924. }
  9925.  
  9926. return getOffsetParent(commonAncestorContainer);
  9927. } // one of the nodes is inside shadowDOM, find which one
  9928.  
  9929.  
  9930. var element1root = getRoot(element1);
  9931.  
  9932. if (element1root.host) {
  9933. return findCommonOffsetParent(element1root.host, element2);
  9934. } else {
  9935. return findCommonOffsetParent(element1, getRoot(element2).host);
  9936. }
  9937. }
  9938. /**
  9939. * Gets the scroll value of the given element in the given side (top and left)
  9940. * @method
  9941. * @memberof Popper.Utils
  9942. * @argument {Element} element
  9943. * @argument {String} side `top` or `left`
  9944. * @returns {number} amount of scrolled pixels
  9945. */
  9946.  
  9947.  
  9948. function getScroll(element) {
  9949. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  9950. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  9951. var nodeName = element.nodeName;
  9952.  
  9953. if (nodeName === 'BODY' || nodeName === 'HTML') {
  9954. var html = element.ownerDocument.documentElement;
  9955. var scrollingElement = element.ownerDocument.scrollingElement || html;
  9956. return scrollingElement[upperSide];
  9957. }
  9958.  
  9959. return element[upperSide];
  9960. }
  9961. /*
  9962. * Sum or subtract the element scroll values (left and top) from a given rect object
  9963. * @method
  9964. * @memberof Popper.Utils
  9965. * @param {Object} rect - Rect object you want to change
  9966. * @param {HTMLElement} element - The element from the function reads the scroll values
  9967. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  9968. * @return {Object} rect - The modifier rect object
  9969. */
  9970.  
  9971.  
  9972. function includeScroll(rect, element) {
  9973. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9974. var scrollTop = getScroll(element, 'top');
  9975. var scrollLeft = getScroll(element, 'left');
  9976. var modifier = subtract ? -1 : 1;
  9977. rect.top += scrollTop * modifier;
  9978. rect.bottom += scrollTop * modifier;
  9979. rect.left += scrollLeft * modifier;
  9980. rect.right += scrollLeft * modifier;
  9981. return rect;
  9982. }
  9983. /*
  9984. * Helper to detect borders of a given element
  9985. * @method
  9986. * @memberof Popper.Utils
  9987. * @param {CSSStyleDeclaration} styles
  9988. * Result of `getStyleComputedProperty` on the given element
  9989. * @param {String} axis - `x` or `y`
  9990. * @return {number} borders - The borders size of the given axis
  9991. */
  9992.  
  9993.  
  9994. function getBordersSize(styles, axis) {
  9995. var sideA = axis === 'x' ? 'Left' : 'Top';
  9996. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  9997. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  9998. }
  9999.  
  10000. function getSize(axis, body, html, computedStyle) {
  10001. return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0);
  10002. }
  10003.  
  10004. function getWindowSizes(document) {
  10005. var body = document.body;
  10006. var html = document.documentElement;
  10007. var computedStyle = isIE(10) && getComputedStyle(html);
  10008. return {
  10009. height: getSize('Height', body, html, computedStyle),
  10010. width: getSize('Width', body, html, computedStyle)
  10011. };
  10012. }
  10013.  
  10014. var classCallCheck = function (instance, Constructor) {
  10015. if (!(instance instanceof Constructor)) {
  10016. throw new TypeError("Cannot call a class as a function");
  10017. }
  10018. };
  10019.  
  10020. var createClass = function () {
  10021. function defineProperties(target, props) {
  10022. for (var i = 0; i < props.length; i++) {
  10023. var descriptor = props[i];
  10024. descriptor.enumerable = descriptor.enumerable || false;
  10025. descriptor.configurable = true;
  10026. if ("value" in descriptor) descriptor.writable = true;
  10027. Object.defineProperty(target, descriptor.key, descriptor);
  10028. }
  10029. }
  10030.  
  10031. return function (Constructor, protoProps, staticProps) {
  10032. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  10033. if (staticProps) defineProperties(Constructor, staticProps);
  10034. return Constructor;
  10035. };
  10036. }();
  10037.  
  10038. var defineProperty = function (obj, key, value) {
  10039. if (key in obj) {
  10040. Object.defineProperty(obj, key, {
  10041. value: value,
  10042. enumerable: true,
  10043. configurable: true,
  10044. writable: true
  10045. });
  10046. } else {
  10047. obj[key] = value;
  10048. }
  10049.  
  10050. return obj;
  10051. };
  10052.  
  10053. var _extends = Object.assign || function (target) {
  10054. for (var i = 1; i < arguments.length; i++) {
  10055. var source = arguments[i];
  10056.  
  10057. for (var key in source) {
  10058. if (Object.prototype.hasOwnProperty.call(source, key)) {
  10059. target[key] = source[key];
  10060. }
  10061. }
  10062. }
  10063.  
  10064. return target;
  10065. };
  10066. /**
  10067. * Given element offsets, generate an output similar to getBoundingClientRect
  10068. * @method
  10069. * @memberof Popper.Utils
  10070. * @argument {Object} offsets
  10071. * @returns {Object} ClientRect like output
  10072. */
  10073.  
  10074.  
  10075. function getClientRect(offsets) {
  10076. return _extends({}, offsets, {
  10077. right: offsets.left + offsets.width,
  10078. bottom: offsets.top + offsets.height
  10079. });
  10080. }
  10081. /**
  10082. * Get bounding client rect of given element
  10083. * @method
  10084. * @memberof Popper.Utils
  10085. * @param {HTMLElement} element
  10086. * @return {Object} client rect
  10087. */
  10088.  
  10089.  
  10090. function getBoundingClientRect(element) {
  10091. var rect = {}; // IE10 10 FIX: Please, don't ask, the element isn't
  10092. // considered in DOM in some circumstances...
  10093. // This isn't reproducible in IE10 compatibility mode of IE11
  10094.  
  10095. try {
  10096. if (isIE(10)) {
  10097. rect = element.getBoundingClientRect();
  10098. var scrollTop = getScroll(element, 'top');
  10099. var scrollLeft = getScroll(element, 'left');
  10100. rect.top += scrollTop;
  10101. rect.left += scrollLeft;
  10102. rect.bottom += scrollTop;
  10103. rect.right += scrollLeft;
  10104. } else {
  10105. rect = element.getBoundingClientRect();
  10106. }
  10107. } catch (e) {}
  10108.  
  10109. var result = {
  10110. left: rect.left,
  10111. top: rect.top,
  10112. width: rect.right - rect.left,
  10113. height: rect.bottom - rect.top
  10114. }; // subtract scrollbar size from sizes
  10115.  
  10116. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  10117. var width = sizes.width || element.clientWidth || result.width;
  10118. var height = sizes.height || element.clientHeight || result.height;
  10119. var horizScrollbar = element.offsetWidth - width;
  10120. var vertScrollbar = element.offsetHeight - height; // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  10121. // we make this check conditional for performance reasons
  10122.  
  10123. if (horizScrollbar || vertScrollbar) {
  10124. var styles = getStyleComputedProperty(element);
  10125. horizScrollbar -= getBordersSize(styles, 'x');
  10126. vertScrollbar -= getBordersSize(styles, 'y');
  10127. result.width -= horizScrollbar;
  10128. result.height -= vertScrollbar;
  10129. }
  10130.  
  10131. return getClientRect(result);
  10132. }
  10133.  
  10134. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  10135. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  10136. var isIE10 = isIE(10);
  10137. var isHTML = parent.nodeName === 'HTML';
  10138. var childrenRect = getBoundingClientRect(children);
  10139. var parentRect = getBoundingClientRect(parent);
  10140. var scrollParent = getScrollParent(children);
  10141. var styles = getStyleComputedProperty(parent);
  10142. var borderTopWidth = parseFloat(styles.borderTopWidth);
  10143. var borderLeftWidth = parseFloat(styles.borderLeftWidth); // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  10144.  
  10145. if (fixedPosition && isHTML) {
  10146. parentRect.top = Math.max(parentRect.top, 0);
  10147. parentRect.left = Math.max(parentRect.left, 0);
  10148. }
  10149.  
  10150. var offsets = getClientRect({
  10151. top: childrenRect.top - parentRect.top - borderTopWidth,
  10152. left: childrenRect.left - parentRect.left - borderLeftWidth,
  10153. width: childrenRect.width,
  10154. height: childrenRect.height
  10155. });
  10156. offsets.marginTop = 0;
  10157. offsets.marginLeft = 0; // Subtract margins of documentElement in case it's being used as parent
  10158. // we do this only on HTML because it's the only element that behaves
  10159. // differently when margins are applied to it. The margins are included in
  10160. // the box of the documentElement, in the other cases not.
  10161.  
  10162. if (!isIE10 && isHTML) {
  10163. var marginTop = parseFloat(styles.marginTop);
  10164. var marginLeft = parseFloat(styles.marginLeft);
  10165. offsets.top -= borderTopWidth - marginTop;
  10166. offsets.bottom -= borderTopWidth - marginTop;
  10167. offsets.left -= borderLeftWidth - marginLeft;
  10168. offsets.right -= borderLeftWidth - marginLeft; // Attach marginTop and marginLeft because in some circumstances we may need them
  10169.  
  10170. offsets.marginTop = marginTop;
  10171. offsets.marginLeft = marginLeft;
  10172. }
  10173.  
  10174. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  10175. offsets = includeScroll(offsets, parent);
  10176. }
  10177.  
  10178. return offsets;
  10179. }
  10180.  
  10181. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  10182. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10183. var html = element.ownerDocument.documentElement;
  10184. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  10185. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  10186. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  10187. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  10188. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  10189. var offset = {
  10190. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  10191. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  10192. width: width,
  10193. height: height
  10194. };
  10195. return getClientRect(offset);
  10196. }
  10197. /**
  10198. * Check if the given element is fixed or is inside a fixed parent
  10199. * @method
  10200. * @memberof Popper.Utils
  10201. * @argument {Element} element
  10202. * @argument {Element} customContainer
  10203. * @returns {Boolean} answer to "isFixed?"
  10204. */
  10205.  
  10206.  
  10207. function isFixed(element) {
  10208. var nodeName = element.nodeName;
  10209.  
  10210. if (nodeName === 'BODY' || nodeName === 'HTML') {
  10211. return false;
  10212. }
  10213.  
  10214. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  10215. return true;
  10216. }
  10217.  
  10218. var parentNode = getParentNode(element);
  10219.  
  10220. if (!parentNode) {
  10221. return false;
  10222. }
  10223.  
  10224. return isFixed(parentNode);
  10225. }
  10226. /**
  10227. * Finds the first parent of an element that has a transformed property defined
  10228. * @method
  10229. * @memberof Popper.Utils
  10230. * @argument {Element} element
  10231. * @returns {Element} first transformed parent or documentElement
  10232. */
  10233.  
  10234.  
  10235. function getFixedPositionOffsetParent(element) {
  10236. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  10237. if (!element || !element.parentElement || isIE()) {
  10238. return document.documentElement;
  10239. }
  10240.  
  10241. var el = element.parentElement;
  10242.  
  10243. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  10244. el = el.parentElement;
  10245. }
  10246.  
  10247. return el || document.documentElement;
  10248. }
  10249. /**
  10250. * Computed the boundaries limits and return them
  10251. * @method
  10252. * @memberof Popper.Utils
  10253. * @param {HTMLElement} popper
  10254. * @param {HTMLElement} reference
  10255. * @param {number} padding
  10256. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  10257. * @param {Boolean} fixedPosition - Is in fixed position mode
  10258. * @returns {Object} Coordinates of the boundaries
  10259. */
  10260.  
  10261.  
  10262. function getBoundaries(popper, reference, padding, boundariesElement) {
  10263. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; // NOTE: 1 DOM access here
  10264.  
  10265. var boundaries = {
  10266. top: 0,
  10267. left: 0
  10268. };
  10269. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference)); // Handle viewport case
  10270.  
  10271. if (boundariesElement === 'viewport') {
  10272. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  10273. } else {
  10274. // Handle other cases based on DOM element used as boundaries
  10275. var boundariesNode = void 0;
  10276.  
  10277. if (boundariesElement === 'scrollParent') {
  10278. boundariesNode = getScrollParent(getParentNode(reference));
  10279.  
  10280. if (boundariesNode.nodeName === 'BODY') {
  10281. boundariesNode = popper.ownerDocument.documentElement;
  10282. }
  10283. } else if (boundariesElement === 'window') {
  10284. boundariesNode = popper.ownerDocument.documentElement;
  10285. } else {
  10286. boundariesNode = boundariesElement;
  10287. }
  10288.  
  10289. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition); // In case of HTML, we need a different computation
  10290.  
  10291. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  10292. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  10293. height = _getWindowSizes.height,
  10294. width = _getWindowSizes.width;
  10295.  
  10296. boundaries.top += offsets.top - offsets.marginTop;
  10297. boundaries.bottom = height + offsets.top;
  10298. boundaries.left += offsets.left - offsets.marginLeft;
  10299. boundaries.right = width + offsets.left;
  10300. } else {
  10301. // for all the other DOM elements, this one is good
  10302. boundaries = offsets;
  10303. }
  10304. } // Add paddings
  10305.  
  10306.  
  10307. padding = padding || 0;
  10308. var isPaddingNumber = typeof padding === 'number';
  10309. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  10310. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  10311. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  10312. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  10313. return boundaries;
  10314. }
  10315.  
  10316. function getArea(_ref) {
  10317. var width = _ref.width,
  10318. height = _ref.height;
  10319. return width * height;
  10320. }
  10321. /**
  10322. * Utility used to transform the `auto` placement to the placement with more
  10323. * available space.
  10324. * @method
  10325. * @memberof Popper.Utils
  10326. * @argument {Object} data - The data object generated by update method
  10327. * @argument {Object} options - Modifiers configuration and options
  10328. * @returns {Object} The data object, properly modified
  10329. */
  10330.  
  10331.  
  10332. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  10333. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  10334.  
  10335. if (placement.indexOf('auto') === -1) {
  10336. return placement;
  10337. }
  10338.  
  10339. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  10340. var rects = {
  10341. top: {
  10342. width: boundaries.width,
  10343. height: refRect.top - boundaries.top
  10344. },
  10345. right: {
  10346. width: boundaries.right - refRect.right,
  10347. height: boundaries.height
  10348. },
  10349. bottom: {
  10350. width: boundaries.width,
  10351. height: boundaries.bottom - refRect.bottom
  10352. },
  10353. left: {
  10354. width: refRect.left - boundaries.left,
  10355. height: boundaries.height
  10356. }
  10357. };
  10358. var sortedAreas = Object.keys(rects).map(function (key) {
  10359. return _extends({
  10360. key: key
  10361. }, rects[key], {
  10362. area: getArea(rects[key])
  10363. });
  10364. }).sort(function (a, b) {
  10365. return b.area - a.area;
  10366. });
  10367. var filteredAreas = sortedAreas.filter(function (_ref2) {
  10368. var width = _ref2.width,
  10369. height = _ref2.height;
  10370. return width >= popper.clientWidth && height >= popper.clientHeight;
  10371. });
  10372. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  10373. var variation = placement.split('-')[1];
  10374. return computedPlacement + (variation ? '-' + variation : '');
  10375. }
  10376. /**
  10377. * Get offsets to the reference element
  10378. * @method
  10379. * @memberof Popper.Utils
  10380. * @param {Object} state
  10381. * @param {Element} popper - the popper element
  10382. * @param {Element} reference - the reference element (the popper will be relative to this)
  10383. * @param {Element} fixedPosition - is in fixed position mode
  10384. * @returns {Object} An object containing the offsets which will be applied to the popper
  10385. */
  10386.  
  10387.  
  10388. function getReferenceOffsets(state, popper, reference) {
  10389. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  10390. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  10391. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  10392. }
  10393. /**
  10394. * Get the outer sizes of the given element (offset size + margins)
  10395. * @method
  10396. * @memberof Popper.Utils
  10397. * @argument {Element} element
  10398. * @returns {Object} object containing width and height properties
  10399. */
  10400.  
  10401.  
  10402. function getOuterSizes(element) {
  10403. var window = element.ownerDocument.defaultView;
  10404. var styles = window.getComputedStyle(element);
  10405. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  10406. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  10407. var result = {
  10408. width: element.offsetWidth + y,
  10409. height: element.offsetHeight + x
  10410. };
  10411. return result;
  10412. }
  10413. /**
  10414. * Get the opposite placement of the given one
  10415. * @method
  10416. * @memberof Popper.Utils
  10417. * @argument {String} placement
  10418. * @returns {String} flipped placement
  10419. */
  10420.  
  10421.  
  10422. function getOppositePlacement(placement) {
  10423. var hash = {
  10424. left: 'right',
  10425. right: 'left',
  10426. bottom: 'top',
  10427. top: 'bottom'
  10428. };
  10429. return placement.replace(/left|right|bottom|top/g, function (matched) {
  10430. return hash[matched];
  10431. });
  10432. }
  10433. /**
  10434. * Get offsets to the popper
  10435. * @method
  10436. * @memberof Popper.Utils
  10437. * @param {Object} position - CSS position the Popper will get applied
  10438. * @param {HTMLElement} popper - the popper element
  10439. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  10440. * @param {String} placement - one of the valid placement options
  10441. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  10442. */
  10443.  
  10444.  
  10445. function getPopperOffsets(popper, referenceOffsets, placement) {
  10446. placement = placement.split('-')[0]; // Get popper node sizes
  10447.  
  10448. var popperRect = getOuterSizes(popper); // Add position, width and height to our offsets object
  10449.  
  10450. var popperOffsets = {
  10451. width: popperRect.width,
  10452. height: popperRect.height
  10453. }; // depending by the popper placement we have to compute its offsets slightly differently
  10454.  
  10455. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  10456. var mainSide = isHoriz ? 'top' : 'left';
  10457. var secondarySide = isHoriz ? 'left' : 'top';
  10458. var measurement = isHoriz ? 'height' : 'width';
  10459. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  10460. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  10461.  
  10462. if (placement === secondarySide) {
  10463. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  10464. } else {
  10465. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  10466. }
  10467.  
  10468. return popperOffsets;
  10469. }
  10470. /**
  10471. * Mimics the `find` method of Array
  10472. * @method
  10473. * @memberof Popper.Utils
  10474. * @argument {Array} arr
  10475. * @argument prop
  10476. * @argument value
  10477. * @returns index or -1
  10478. */
  10479.  
  10480.  
  10481. function find(arr, check) {
  10482. // use native find if supported
  10483. if (Array.prototype.find) {
  10484. return arr.find(check);
  10485. } // use `filter` to obtain the same behavior of `find`
  10486.  
  10487.  
  10488. return arr.filter(check)[0];
  10489. }
  10490. /**
  10491. * Return the index of the matching object
  10492. * @method
  10493. * @memberof Popper.Utils
  10494. * @argument {Array} arr
  10495. * @argument prop
  10496. * @argument value
  10497. * @returns index or -1
  10498. */
  10499.  
  10500.  
  10501. function findIndex(arr, prop, value) {
  10502. // use native findIndex if supported
  10503. if (Array.prototype.findIndex) {
  10504. return arr.findIndex(function (cur) {
  10505. return cur[prop] === value;
  10506. });
  10507. } // use `find` + `indexOf` if `findIndex` isn't supported
  10508.  
  10509.  
  10510. var match = find(arr, function (obj) {
  10511. return obj[prop] === value;
  10512. });
  10513. return arr.indexOf(match);
  10514. }
  10515. /**
  10516. * Loop trough the list of modifiers and run them in order,
  10517. * each of them will then edit the data object.
  10518. * @method
  10519. * @memberof Popper.Utils
  10520. * @param {dataObject} data
  10521. * @param {Array} modifiers
  10522. * @param {String} ends - Optional modifier name used as stopper
  10523. * @returns {dataObject}
  10524. */
  10525.  
  10526.  
  10527. function runModifiers(modifiers, data, ends) {
  10528. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  10529. modifiersToRun.forEach(function (modifier) {
  10530. if (modifier['function']) {
  10531. // eslint-disable-line dot-notation
  10532. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  10533. }
  10534.  
  10535. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  10536.  
  10537. if (modifier.enabled && isFunction(fn)) {
  10538. // Add properties to offsets to make them a complete clientRect object
  10539. // we do this before each modifier to make sure the previous one doesn't
  10540. // mess with these values
  10541. data.offsets.popper = getClientRect(data.offsets.popper);
  10542. data.offsets.reference = getClientRect(data.offsets.reference);
  10543. data = fn(data, modifier);
  10544. }
  10545. });
  10546. return data;
  10547. }
  10548. /**
  10549. * Updates the position of the popper, computing the new offsets and applying
  10550. * the new style.<br />
  10551. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  10552. * @method
  10553. * @memberof Popper
  10554. */
  10555.  
  10556.  
  10557. function update() {
  10558. // if popper is destroyed, don't perform any further update
  10559. if (this.state.isDestroyed) {
  10560. return;
  10561. }
  10562.  
  10563. var data = {
  10564. instance: this,
  10565. styles: {},
  10566. arrowStyles: {},
  10567. attributes: {},
  10568. flipped: false,
  10569. offsets: {}
  10570. }; // compute reference element offsets
  10571.  
  10572. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed); // compute auto placement, store placement inside the data object,
  10573. // modifiers will be able to edit `placement` if needed
  10574. // and refer to originalPlacement to know the original value
  10575.  
  10576. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding); // store the computed placement inside `originalPlacement`
  10577.  
  10578. data.originalPlacement = data.placement;
  10579. data.positionFixed = this.options.positionFixed; // compute the popper offsets
  10580.  
  10581. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  10582. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute'; // run the modifiers
  10583.  
  10584. data = runModifiers(this.modifiers, data); // the first `update` will call `onCreate` callback
  10585. // the other ones will call `onUpdate` callback
  10586.  
  10587. if (!this.state.isCreated) {
  10588. this.state.isCreated = true;
  10589. this.options.onCreate(data);
  10590. } else {
  10591. this.options.onUpdate(data);
  10592. }
  10593. }
  10594. /**
  10595. * Helper used to know if the given modifier is enabled.
  10596. * @method
  10597. * @memberof Popper.Utils
  10598. * @returns {Boolean}
  10599. */
  10600.  
  10601.  
  10602. function isModifierEnabled(modifiers, modifierName) {
  10603. return modifiers.some(function (_ref) {
  10604. var name = _ref.name,
  10605. enabled = _ref.enabled;
  10606. return enabled && name === modifierName;
  10607. });
  10608. }
  10609. /**
  10610. * Get the prefixed supported property name
  10611. * @method
  10612. * @memberof Popper.Utils
  10613. * @argument {String} property (camelCase)
  10614. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  10615. */
  10616.  
  10617.  
  10618. function getSupportedPropertyName(property) {
  10619. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  10620. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  10621.  
  10622. for (var i = 0; i < prefixes.length; i++) {
  10623. var prefix = prefixes[i];
  10624. var toCheck = prefix ? '' + prefix + upperProp : property;
  10625.  
  10626. if (typeof document.body.style[toCheck] !== 'undefined') {
  10627. return toCheck;
  10628. }
  10629. }
  10630.  
  10631. return null;
  10632. }
  10633. /**
  10634. * Destroys the popper.
  10635. * @method
  10636. * @memberof Popper
  10637. */
  10638.  
  10639.  
  10640. function destroy() {
  10641. this.state.isDestroyed = true; // touch DOM only if `applyStyle` modifier is enabled
  10642.  
  10643. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  10644. this.popper.removeAttribute('x-placement');
  10645. this.popper.style.position = '';
  10646. this.popper.style.top = '';
  10647. this.popper.style.left = '';
  10648. this.popper.style.right = '';
  10649. this.popper.style.bottom = '';
  10650. this.popper.style.willChange = '';
  10651. this.popper.style[getSupportedPropertyName('transform')] = '';
  10652. }
  10653.  
  10654. this.disableEventListeners(); // remove the popper if user explicitly asked for the deletion on destroy
  10655. // do not use `remove` because IE11 doesn't support it
  10656.  
  10657. if (this.options.removeOnDestroy) {
  10658. this.popper.parentNode.removeChild(this.popper);
  10659. }
  10660.  
  10661. return this;
  10662. }
  10663. /**
  10664. * Get the window associated with the element
  10665. * @argument {Element} element
  10666. * @returns {Window}
  10667. */
  10668.  
  10669.  
  10670. function getWindow(element) {
  10671. var ownerDocument = element.ownerDocument;
  10672. return ownerDocument ? ownerDocument.defaultView : window;
  10673. }
  10674.  
  10675. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  10676. var isBody = scrollParent.nodeName === 'BODY';
  10677. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  10678. target.addEventListener(event, callback, {
  10679. passive: true
  10680. });
  10681.  
  10682. if (!isBody) {
  10683. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  10684. }
  10685.  
  10686. scrollParents.push(target);
  10687. }
  10688. /**
  10689. * Setup needed event listeners used to update the popper position
  10690. * @method
  10691. * @memberof Popper.Utils
  10692. * @private
  10693. */
  10694.  
  10695.  
  10696. function setupEventListeners(reference, options, state, updateBound) {
  10697. // Resize event listener on window
  10698. state.updateBound = updateBound;
  10699. getWindow(reference).addEventListener('resize', state.updateBound, {
  10700. passive: true
  10701. }); // Scroll event listener on scroll parents
  10702.  
  10703. var scrollElement = getScrollParent(reference);
  10704. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  10705. state.scrollElement = scrollElement;
  10706. state.eventsEnabled = true;
  10707. return state;
  10708. }
  10709. /**
  10710. * It will add resize/scroll events and start recalculating
  10711. * position of the popper element when they are triggered.
  10712. * @method
  10713. * @memberof Popper
  10714. */
  10715.  
  10716.  
  10717. function enableEventListeners() {
  10718. if (!this.state.eventsEnabled) {
  10719. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  10720. }
  10721. }
  10722. /**
  10723. * Remove event listeners used to update the popper position
  10724. * @method
  10725. * @memberof Popper.Utils
  10726. * @private
  10727. */
  10728.  
  10729.  
  10730. function removeEventListeners(reference, state) {
  10731. // Remove resize event listener on window
  10732. getWindow(reference).removeEventListener('resize', state.updateBound); // Remove scroll event listener on scroll parents
  10733.  
  10734. state.scrollParents.forEach(function (target) {
  10735. target.removeEventListener('scroll', state.updateBound);
  10736. }); // Reset state
  10737.  
  10738. state.updateBound = null;
  10739. state.scrollParents = [];
  10740. state.scrollElement = null;
  10741. state.eventsEnabled = false;
  10742. return state;
  10743. }
  10744. /**
  10745. * It will remove resize/scroll events and won't recalculate popper position
  10746. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  10747. * unless you call `update` method manually.
  10748. * @method
  10749. * @memberof Popper
  10750. */
  10751.  
  10752.  
  10753. function disableEventListeners() {
  10754. if (this.state.eventsEnabled) {
  10755. cancelAnimationFrame(this.scheduleUpdate);
  10756. this.state = removeEventListeners(this.reference, this.state);
  10757. }
  10758. }
  10759. /**
  10760. * Tells if a given input is a number
  10761. * @method
  10762. * @memberof Popper.Utils
  10763. * @param {*} input to check
  10764. * @return {Boolean}
  10765. */
  10766.  
  10767.  
  10768. function isNumeric(n) {
  10769. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  10770. }
  10771. /**
  10772. * Set the style to the given popper
  10773. * @method
  10774. * @memberof Popper.Utils
  10775. * @argument {Element} element - Element to apply the style to
  10776. * @argument {Object} styles
  10777. * Object with a list of properties and values which will be applied to the element
  10778. */
  10779.  
  10780.  
  10781. function setStyles(element, styles) {
  10782. Object.keys(styles).forEach(function (prop) {
  10783. var unit = ''; // add unit if the value is numeric and is one of the following
  10784.  
  10785. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  10786. unit = 'px';
  10787. }
  10788.  
  10789. element.style[prop] = styles[prop] + unit;
  10790. });
  10791. }
  10792. /**
  10793. * Set the attributes to the given popper
  10794. * @method
  10795. * @memberof Popper.Utils
  10796. * @argument {Element} element - Element to apply the attributes to
  10797. * @argument {Object} styles
  10798. * Object with a list of properties and values which will be applied to the element
  10799. */
  10800.  
  10801.  
  10802. function setAttributes(element, attributes) {
  10803. Object.keys(attributes).forEach(function (prop) {
  10804. var value = attributes[prop];
  10805.  
  10806. if (value !== false) {
  10807. element.setAttribute(prop, attributes[prop]);
  10808. } else {
  10809. element.removeAttribute(prop);
  10810. }
  10811. });
  10812. }
  10813. /**
  10814. * @function
  10815. * @memberof Modifiers
  10816. * @argument {Object} data - The data object generated by `update` method
  10817. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  10818. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  10819. * @argument {Object} options - Modifiers configuration and options
  10820. * @returns {Object} The same data object
  10821. */
  10822.  
  10823.  
  10824. function applyStyle(data) {
  10825. // any property present in `data.styles` will be applied to the popper,
  10826. // in this way we can make the 3rd party modifiers add custom styles to it
  10827. // Be aware, modifiers could override the properties defined in the previous
  10828. // lines of this modifier!
  10829. setStyles(data.instance.popper, data.styles); // any property present in `data.attributes` will be applied to the popper,
  10830. // they will be set as HTML attributes of the element
  10831.  
  10832. setAttributes(data.instance.popper, data.attributes); // if arrowElement is defined and arrowStyles has some properties
  10833.  
  10834. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  10835. setStyles(data.arrowElement, data.arrowStyles);
  10836. }
  10837.  
  10838. return data;
  10839. }
  10840. /**
  10841. * Set the x-placement attribute before everything else because it could be used
  10842. * to add margins to the popper margins needs to be calculated to get the
  10843. * correct popper offsets.
  10844. * @method
  10845. * @memberof Popper.modifiers
  10846. * @param {HTMLElement} reference - The reference element used to position the popper
  10847. * @param {HTMLElement} popper - The HTML element used as popper
  10848. * @param {Object} options - Popper.js options
  10849. */
  10850.  
  10851.  
  10852. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  10853. // compute reference element offsets
  10854. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed); // compute auto placement, store placement inside the data object,
  10855. // modifiers will be able to edit `placement` if needed
  10856. // and refer to originalPlacement to know the original value
  10857.  
  10858. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  10859. popper.setAttribute('x-placement', placement); // Apply `position` to popper before anything else because
  10860. // without the position applied we can't guarantee correct computations
  10861.  
  10862. setStyles(popper, {
  10863. position: options.positionFixed ? 'fixed' : 'absolute'
  10864. });
  10865. return options;
  10866. }
  10867. /**
  10868. * @function
  10869. * @memberof Popper.Utils
  10870. * @argument {Object} data - The data object generated by `update` method
  10871. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  10872. * @returns {Object} The popper's position offsets rounded
  10873. *
  10874. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  10875. * good as it can be within reason.
  10876. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  10877. *
  10878. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  10879. * as well on High DPI screens).
  10880. *
  10881. * Firefox prefers no rounding for positioning and does not have blurriness on
  10882. * high DPI screens.
  10883. *
  10884. * Only horizontal placement and left/right values need to be considered.
  10885. */
  10886.  
  10887.  
  10888. function getRoundedOffsets(data, shouldRound) {
  10889. var _data$offsets = data.offsets,
  10890. popper = _data$offsets.popper,
  10891. reference = _data$offsets.reference;
  10892. var round = Math.round,
  10893. floor = Math.floor;
  10894.  
  10895. var noRound = function noRound(v) {
  10896. return v;
  10897. };
  10898.  
  10899. var referenceWidth = round(reference.width);
  10900. var popperWidth = round(popper.width);
  10901. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  10902. var isVariation = data.placement.indexOf('-') !== -1;
  10903. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  10904. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  10905. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  10906. var verticalToInteger = !shouldRound ? noRound : round;
  10907. return {
  10908. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  10909. top: verticalToInteger(popper.top),
  10910. bottom: verticalToInteger(popper.bottom),
  10911. right: horizontalToInteger(popper.right)
  10912. };
  10913. }
  10914.  
  10915. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  10916. /**
  10917. * @function
  10918. * @memberof Modifiers
  10919. * @argument {Object} data - The data object generated by `update` method
  10920. * @argument {Object} options - Modifiers configuration and options
  10921. * @returns {Object} The data object, properly modified
  10922. */
  10923.  
  10924. function computeStyle(data, options) {
  10925. var x = options.x,
  10926. y = options.y;
  10927. var popper = data.offsets.popper; // Remove this legacy support in Popper.js v2
  10928.  
  10929. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  10930. return modifier.name === 'applyStyle';
  10931. }).gpuAcceleration;
  10932.  
  10933. if (legacyGpuAccelerationOption !== undefined) {
  10934. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  10935. }
  10936.  
  10937. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  10938. var offsetParent = getOffsetParent(data.instance.popper);
  10939. var offsetParentRect = getBoundingClientRect(offsetParent); // Styles
  10940.  
  10941. var styles = {
  10942. position: popper.position
  10943. };
  10944. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  10945. var sideA = x === 'bottom' ? 'top' : 'bottom';
  10946. var sideB = y === 'right' ? 'left' : 'right'; // if gpuAcceleration is set to `true` and transform is supported,
  10947. // we use `translate3d` to apply the position to the popper we
  10948. // automatically use the supported prefixed version if needed
  10949.  
  10950. var prefixedProperty = getSupportedPropertyName('transform'); // now, let's make a step back and look at this code closely (wtf?)
  10951. // If the content of the popper grows once it's been positioned, it
  10952. // may happen that the popper gets misplaced because of the new content
  10953. // overflowing its reference element
  10954. // To avoid this problem, we provide two options (x and y), which allow
  10955. // the consumer to define the offset origin.
  10956. // If we position a popper on top of a reference element, we can set
  10957. // `x` to `top` to make the popper grow towards its top instead of
  10958. // its bottom.
  10959.  
  10960. var left = void 0,
  10961. top = void 0;
  10962.  
  10963. if (sideA === 'bottom') {
  10964. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  10965. // and not the bottom of the html element
  10966. if (offsetParent.nodeName === 'HTML') {
  10967. top = -offsetParent.clientHeight + offsets.bottom;
  10968. } else {
  10969. top = -offsetParentRect.height + offsets.bottom;
  10970. }
  10971. } else {
  10972. top = offsets.top;
  10973. }
  10974.  
  10975. if (sideB === 'right') {
  10976. if (offsetParent.nodeName === 'HTML') {
  10977. left = -offsetParent.clientWidth + offsets.right;
  10978. } else {
  10979. left = -offsetParentRect.width + offsets.right;
  10980. }
  10981. } else {
  10982. left = offsets.left;
  10983. }
  10984.  
  10985. if (gpuAcceleration && prefixedProperty) {
  10986. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  10987. styles[sideA] = 0;
  10988. styles[sideB] = 0;
  10989. styles.willChange = 'transform';
  10990. } else {
  10991. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  10992. var invertTop = sideA === 'bottom' ? -1 : 1;
  10993. var invertLeft = sideB === 'right' ? -1 : 1;
  10994. styles[sideA] = top * invertTop;
  10995. styles[sideB] = left * invertLeft;
  10996. styles.willChange = sideA + ', ' + sideB;
  10997. } // Attributes
  10998.  
  10999.  
  11000. var attributes = {
  11001. 'x-placement': data.placement
  11002. }; // Update `data` attributes, styles and arrowStyles
  11003.  
  11004. data.attributes = _extends({}, attributes, data.attributes);
  11005. data.styles = _extends({}, styles, data.styles);
  11006. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  11007. return data;
  11008. }
  11009. /**
  11010. * Helper used to know if the given modifier depends from another one.<br />
  11011. * It checks if the needed modifier is listed and enabled.
  11012. * @method
  11013. * @memberof Popper.Utils
  11014. * @param {Array} modifiers - list of modifiers
  11015. * @param {String} requestingName - name of requesting modifier
  11016. * @param {String} requestedName - name of requested modifier
  11017. * @returns {Boolean}
  11018. */
  11019.  
  11020.  
  11021. function isModifierRequired(modifiers, requestingName, requestedName) {
  11022. var requesting = find(modifiers, function (_ref) {
  11023. var name = _ref.name;
  11024. return name === requestingName;
  11025. });
  11026. var isRequired = !!requesting && modifiers.some(function (modifier) {
  11027. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  11028. });
  11029.  
  11030. if (!isRequired) {
  11031. var _requesting = '`' + requestingName + '`';
  11032.  
  11033. var requested = '`' + requestedName + '`';
  11034. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  11035. }
  11036.  
  11037. return isRequired;
  11038. }
  11039. /**
  11040. * @function
  11041. * @memberof Modifiers
  11042. * @argument {Object} data - The data object generated by update method
  11043. * @argument {Object} options - Modifiers configuration and options
  11044. * @returns {Object} The data object, properly modified
  11045. */
  11046.  
  11047.  
  11048. function arrow(data, options) {
  11049. var _data$offsets$arrow; // arrow depends on keepTogether in order to work
  11050.  
  11051.  
  11052. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  11053. return data;
  11054. }
  11055.  
  11056. var arrowElement = options.element; // if arrowElement is a string, suppose it's a CSS selector
  11057.  
  11058. if (typeof arrowElement === 'string') {
  11059. arrowElement = data.instance.popper.querySelector(arrowElement); // if arrowElement is not found, don't run the modifier
  11060.  
  11061. if (!arrowElement) {
  11062. return data;
  11063. }
  11064. } else {
  11065. // if the arrowElement isn't a query selector we must check that the
  11066. // provided DOM node is child of its popper node
  11067. if (!data.instance.popper.contains(arrowElement)) {
  11068. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  11069. return data;
  11070. }
  11071. }
  11072.  
  11073. var placement = data.placement.split('-')[0];
  11074. var _data$offsets = data.offsets,
  11075. popper = _data$offsets.popper,
  11076. reference = _data$offsets.reference;
  11077. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  11078. var len = isVertical ? 'height' : 'width';
  11079. var sideCapitalized = isVertical ? 'Top' : 'Left';
  11080. var side = sideCapitalized.toLowerCase();
  11081. var altSide = isVertical ? 'left' : 'top';
  11082. var opSide = isVertical ? 'bottom' : 'right';
  11083. var arrowElementSize = getOuterSizes(arrowElement)[len]; //
  11084. // extends keepTogether behavior making sure the popper and its
  11085. // reference have enough pixels in conjunction
  11086. //
  11087. // top/left side
  11088.  
  11089. if (reference[opSide] - arrowElementSize < popper[side]) {
  11090. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  11091. } // bottom/right side
  11092.  
  11093.  
  11094. if (reference[side] + arrowElementSize > popper[opSide]) {
  11095. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  11096. }
  11097.  
  11098. data.offsets.popper = getClientRect(data.offsets.popper); // compute center of the popper
  11099.  
  11100. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2; // Compute the sideValue using the updated popper offsets
  11101. // take popper margin in account because we don't have this info available
  11102.  
  11103. var css = getStyleComputedProperty(data.instance.popper);
  11104. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  11105. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  11106. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide; // prevent arrowElement from being placed not contiguously to its popper
  11107.  
  11108. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  11109. data.arrowElement = arrowElement;
  11110. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  11111. return data;
  11112. }
  11113. /**
  11114. * Get the opposite placement variation of the given one
  11115. * @method
  11116. * @memberof Popper.Utils
  11117. * @argument {String} placement variation
  11118. * @returns {String} flipped placement variation
  11119. */
  11120.  
  11121.  
  11122. function getOppositeVariation(variation) {
  11123. if (variation === 'end') {
  11124. return 'start';
  11125. } else if (variation === 'start') {
  11126. return 'end';
  11127. }
  11128.  
  11129. return variation;
  11130. }
  11131. /**
  11132. * List of accepted placements to use as values of the `placement` option.<br />
  11133. * Valid placements are:
  11134. * - `auto`
  11135. * - `top`
  11136. * - `right`
  11137. * - `bottom`
  11138. * - `left`
  11139. *
  11140. * Each placement can have a variation from this list:
  11141. * - `-start`
  11142. * - `-end`
  11143. *
  11144. * Variations are interpreted easily if you think of them as the left to right
  11145. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  11146. * is right.<br />
  11147. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  11148. *
  11149. * Some valid examples are:
  11150. * - `top-end` (on top of reference, right aligned)
  11151. * - `right-start` (on right of reference, top aligned)
  11152. * - `bottom` (on bottom, centered)
  11153. * - `auto-end` (on the side with more space available, alignment depends by placement)
  11154. *
  11155. * @static
  11156. * @type {Array}
  11157. * @enum {String}
  11158. * @readonly
  11159. * @method placements
  11160. * @memberof Popper
  11161. */
  11162.  
  11163.  
  11164. var placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start']; // Get rid of `auto` `auto-start` and `auto-end`
  11165.  
  11166. var validPlacements = placements.slice(3);
  11167. /**
  11168. * Given an initial placement, returns all the subsequent placements
  11169. * clockwise (or counter-clockwise).
  11170. *
  11171. * @method
  11172. * @memberof Popper.Utils
  11173. * @argument {String} placement - A valid placement (it accepts variations)
  11174. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  11175. * @returns {Array} placements including their variations
  11176. */
  11177.  
  11178. function clockwise(placement) {
  11179. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  11180. var index = validPlacements.indexOf(placement);
  11181. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  11182. return counter ? arr.reverse() : arr;
  11183. }
  11184.  
  11185. var BEHAVIORS = {
  11186. FLIP: 'flip',
  11187. CLOCKWISE: 'clockwise',
  11188. COUNTERCLOCKWISE: 'counterclockwise'
  11189. };
  11190. /**
  11191. * @function
  11192. * @memberof Modifiers
  11193. * @argument {Object} data - The data object generated by update method
  11194. * @argument {Object} options - Modifiers configuration and options
  11195. * @returns {Object} The data object, properly modified
  11196. */
  11197.  
  11198. function flip(data, options) {
  11199. // if `inner` modifier is enabled, we can't use the `flip` modifier
  11200. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  11201. return data;
  11202. }
  11203.  
  11204. if (data.flipped && data.placement === data.originalPlacement) {
  11205. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  11206. return data;
  11207. }
  11208.  
  11209. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  11210. var placement = data.placement.split('-')[0];
  11211. var placementOpposite = getOppositePlacement(placement);
  11212. var variation = data.placement.split('-')[1] || '';
  11213. var flipOrder = [];
  11214.  
  11215. switch (options.behavior) {
  11216. case BEHAVIORS.FLIP:
  11217. flipOrder = [placement, placementOpposite];
  11218. break;
  11219.  
  11220. case BEHAVIORS.CLOCKWISE:
  11221. flipOrder = clockwise(placement);
  11222. break;
  11223.  
  11224. case BEHAVIORS.COUNTERCLOCKWISE:
  11225. flipOrder = clockwise(placement, true);
  11226. break;
  11227.  
  11228. default:
  11229. flipOrder = options.behavior;
  11230. }
  11231.  
  11232. flipOrder.forEach(function (step, index) {
  11233. if (placement !== step || flipOrder.length === index + 1) {
  11234. return data;
  11235. }
  11236.  
  11237. placement = data.placement.split('-')[0];
  11238. placementOpposite = getOppositePlacement(placement);
  11239. var popperOffsets = data.offsets.popper;
  11240. var refOffsets = data.offsets.reference; // using floor because the reference offsets may contain decimals we are not going to consider here
  11241.  
  11242. var floor = Math.floor;
  11243. var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom);
  11244. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  11245. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  11246. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  11247. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  11248. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom; // flip the variation if required
  11249.  
  11250. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1; // flips variation if reference element overflows boundaries
  11251.  
  11252. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom); // flips variation if popper content overflows boundaries
  11253.  
  11254. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  11255. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  11256.  
  11257. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  11258. // this boolean to detect any flip loop
  11259. data.flipped = true;
  11260.  
  11261. if (overlapsRef || overflowsBoundaries) {
  11262. placement = flipOrder[index + 1];
  11263. }
  11264.  
  11265. if (flippedVariation) {
  11266. variation = getOppositeVariation(variation);
  11267. }
  11268.  
  11269. data.placement = placement + (variation ? '-' + variation : ''); // this object contains `position`, we want to preserve it along with
  11270. // any additional property we may add in the future
  11271.  
  11272. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  11273. data = runModifiers(data.instance.modifiers, data, 'flip');
  11274. }
  11275. });
  11276. return data;
  11277. }
  11278. /**
  11279. * @function
  11280. * @memberof Modifiers
  11281. * @argument {Object} data - The data object generated by update method
  11282. * @argument {Object} options - Modifiers configuration and options
  11283. * @returns {Object} The data object, properly modified
  11284. */
  11285.  
  11286.  
  11287. function keepTogether(data) {
  11288. var _data$offsets = data.offsets,
  11289. popper = _data$offsets.popper,
  11290. reference = _data$offsets.reference;
  11291. var placement = data.placement.split('-')[0];
  11292. var floor = Math.floor;
  11293. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  11294. var side = isVertical ? 'right' : 'bottom';
  11295. var opSide = isVertical ? 'left' : 'top';
  11296. var measurement = isVertical ? 'width' : 'height';
  11297.  
  11298. if (popper[side] < floor(reference[opSide])) {
  11299. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  11300. }
  11301.  
  11302. if (popper[opSide] > floor(reference[side])) {
  11303. data.offsets.popper[opSide] = floor(reference[side]);
  11304. }
  11305.  
  11306. return data;
  11307. }
  11308. /**
  11309. * Converts a string containing value + unit into a px value number
  11310. * @function
  11311. * @memberof {modifiers~offset}
  11312. * @private
  11313. * @argument {String} str - Value + unit string
  11314. * @argument {String} measurement - `height` or `width`
  11315. * @argument {Object} popperOffsets
  11316. * @argument {Object} referenceOffsets
  11317. * @returns {Number|String}
  11318. * Value in pixels, or original string if no values were extracted
  11319. */
  11320.  
  11321.  
  11322. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  11323. // separate value from unit
  11324. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  11325. var value = +split[1];
  11326. var unit = split[2]; // If it's not a number it's an operator, I guess
  11327.  
  11328. if (!value) {
  11329. return str;
  11330. }
  11331.  
  11332. if (unit.indexOf('%') === 0) {
  11333. var element = void 0;
  11334.  
  11335. switch (unit) {
  11336. case '%p':
  11337. element = popperOffsets;
  11338. break;
  11339.  
  11340. case '%':
  11341. case '%r':
  11342. default:
  11343. element = referenceOffsets;
  11344. }
  11345.  
  11346. var rect = getClientRect(element);
  11347. return rect[measurement] / 100 * value;
  11348. } else if (unit === 'vh' || unit === 'vw') {
  11349. // if is a vh or vw, we calculate the size based on the viewport
  11350. var size = void 0;
  11351.  
  11352. if (unit === 'vh') {
  11353. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  11354. } else {
  11355. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  11356. }
  11357.  
  11358. return size / 100 * value;
  11359. } else {
  11360. // if is an explicit pixel unit, we get rid of the unit and keep the value
  11361. // if is an implicit unit, it's px, and we return just the value
  11362. return value;
  11363. }
  11364. }
  11365. /**
  11366. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  11367. * @function
  11368. * @memberof {modifiers~offset}
  11369. * @private
  11370. * @argument {String} offset
  11371. * @argument {Object} popperOffsets
  11372. * @argument {Object} referenceOffsets
  11373. * @argument {String} basePlacement
  11374. * @returns {Array} a two cells array with x and y offsets in numbers
  11375. */
  11376.  
  11377.  
  11378. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  11379. var offsets = [0, 0]; // Use height if placement is left or right and index is 0 otherwise use width
  11380. // in this way the first offset will use an axis and the second one
  11381. // will use the other one
  11382.  
  11383. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1; // Split the offset string to obtain a list of values and operands
  11384. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  11385.  
  11386. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  11387. return frag.trim();
  11388. }); // Detect if the offset string contains a pair of values or a single one
  11389. // they could be separated by comma or space
  11390.  
  11391. var divider = fragments.indexOf(find(fragments, function (frag) {
  11392. return frag.search(/,|\s/) !== -1;
  11393. }));
  11394.  
  11395. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  11396. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  11397. } // If divider is found, we divide the list of values and operands to divide
  11398. // them by ofset X and Y.
  11399.  
  11400.  
  11401. var splitRegex = /\s*,\s*|\s+/;
  11402. var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments]; // Convert the values with units to absolute pixels to allow our computations
  11403.  
  11404. ops = ops.map(function (op, index) {
  11405. // Most of the units rely on the orientation of the popper
  11406. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  11407. var mergeWithPrevious = false;
  11408. return op // This aggregates any `+` or `-` sign that aren't considered operators
  11409. // e.g.: 10 + +5 => [10, +, +5]
  11410. .reduce(function (a, b) {
  11411. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  11412. a[a.length - 1] = b;
  11413. mergeWithPrevious = true;
  11414. return a;
  11415. } else if (mergeWithPrevious) {
  11416. a[a.length - 1] += b;
  11417. mergeWithPrevious = false;
  11418. return a;
  11419. } else {
  11420. return a.concat(b);
  11421. }
  11422. }, []) // Here we convert the string values into number values (in px)
  11423. .map(function (str) {
  11424. return toValue(str, measurement, popperOffsets, referenceOffsets);
  11425. });
  11426. }); // Loop trough the offsets arrays and execute the operations
  11427.  
  11428. ops.forEach(function (op, index) {
  11429. op.forEach(function (frag, index2) {
  11430. if (isNumeric(frag)) {
  11431. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  11432. }
  11433. });
  11434. });
  11435. return offsets;
  11436. }
  11437. /**
  11438. * @function
  11439. * @memberof Modifiers
  11440. * @argument {Object} data - The data object generated by update method
  11441. * @argument {Object} options - Modifiers configuration and options
  11442. * @argument {Number|String} options.offset=0
  11443. * The offset value as described in the modifier description
  11444. * @returns {Object} The data object, properly modified
  11445. */
  11446.  
  11447.  
  11448. function offset(data, _ref) {
  11449. var offset = _ref.offset;
  11450. var placement = data.placement,
  11451. _data$offsets = data.offsets,
  11452. popper = _data$offsets.popper,
  11453. reference = _data$offsets.reference;
  11454. var basePlacement = placement.split('-')[0];
  11455. var offsets = void 0;
  11456.  
  11457. if (isNumeric(+offset)) {
  11458. offsets = [+offset, 0];
  11459. } else {
  11460. offsets = parseOffset(offset, popper, reference, basePlacement);
  11461. }
  11462.  
  11463. if (basePlacement === 'left') {
  11464. popper.top += offsets[0];
  11465. popper.left -= offsets[1];
  11466. } else if (basePlacement === 'right') {
  11467. popper.top += offsets[0];
  11468. popper.left += offsets[1];
  11469. } else if (basePlacement === 'top') {
  11470. popper.left += offsets[0];
  11471. popper.top -= offsets[1];
  11472. } else if (basePlacement === 'bottom') {
  11473. popper.left += offsets[0];
  11474. popper.top += offsets[1];
  11475. }
  11476.  
  11477. data.popper = popper;
  11478. return data;
  11479. }
  11480. /**
  11481. * @function
  11482. * @memberof Modifiers
  11483. * @argument {Object} data - The data object generated by `update` method
  11484. * @argument {Object} options - Modifiers configuration and options
  11485. * @returns {Object} The data object, properly modified
  11486. */
  11487.  
  11488.  
  11489. function preventOverflow(data, options) {
  11490. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper); // If offsetParent is the reference element, we really want to
  11491. // go one step up and use the next offsetParent as reference to
  11492. // avoid to make this modifier completely useless and look like broken
  11493.  
  11494. if (data.instance.reference === boundariesElement) {
  11495. boundariesElement = getOffsetParent(boundariesElement);
  11496. } // NOTE: DOM access here
  11497. // resets the popper's position so that the document size can be calculated excluding
  11498. // the size of the popper element itself
  11499.  
  11500.  
  11501. var transformProp = getSupportedPropertyName('transform');
  11502. var popperStyles = data.instance.popper.style; // assignment to help minification
  11503.  
  11504. var top = popperStyles.top,
  11505. left = popperStyles.left,
  11506. transform = popperStyles[transformProp];
  11507. popperStyles.top = '';
  11508. popperStyles.left = '';
  11509. popperStyles[transformProp] = '';
  11510. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed); // NOTE: DOM access here
  11511. // restores the original style properties after the offsets have been computed
  11512.  
  11513. popperStyles.top = top;
  11514. popperStyles.left = left;
  11515. popperStyles[transformProp] = transform;
  11516. options.boundaries = boundaries;
  11517. var order = options.priority;
  11518. var popper = data.offsets.popper;
  11519. var check = {
  11520. primary: function primary(placement) {
  11521. var value = popper[placement];
  11522.  
  11523. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  11524. value = Math.max(popper[placement], boundaries[placement]);
  11525. }
  11526.  
  11527. return defineProperty({}, placement, value);
  11528. },
  11529. secondary: function secondary(placement) {
  11530. var mainSide = placement === 'right' ? 'left' : 'top';
  11531. var value = popper[mainSide];
  11532.  
  11533. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  11534. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  11535. }
  11536.  
  11537. return defineProperty({}, mainSide, value);
  11538. }
  11539. };
  11540. order.forEach(function (placement) {
  11541. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  11542. popper = _extends({}, popper, check[side](placement));
  11543. });
  11544. data.offsets.popper = popper;
  11545. return data;
  11546. }
  11547. /**
  11548. * @function
  11549. * @memberof Modifiers
  11550. * @argument {Object} data - The data object generated by `update` method
  11551. * @argument {Object} options - Modifiers configuration and options
  11552. * @returns {Object} The data object, properly modified
  11553. */
  11554.  
  11555.  
  11556. function shift(data) {
  11557. var placement = data.placement;
  11558. var basePlacement = placement.split('-')[0];
  11559. var shiftvariation = placement.split('-')[1]; // if shift shiftvariation is specified, run the modifier
  11560.  
  11561. if (shiftvariation) {
  11562. var _data$offsets = data.offsets,
  11563. reference = _data$offsets.reference,
  11564. popper = _data$offsets.popper;
  11565. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  11566. var side = isVertical ? 'left' : 'top';
  11567. var measurement = isVertical ? 'width' : 'height';
  11568. var shiftOffsets = {
  11569. start: defineProperty({}, side, reference[side]),
  11570. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  11571. };
  11572. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  11573. }
  11574.  
  11575. return data;
  11576. }
  11577. /**
  11578. * @function
  11579. * @memberof Modifiers
  11580. * @argument {Object} data - The data object generated by update method
  11581. * @argument {Object} options - Modifiers configuration and options
  11582. * @returns {Object} The data object, properly modified
  11583. */
  11584.  
  11585.  
  11586. function hide(data) {
  11587. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  11588. return data;
  11589. }
  11590.  
  11591. var refRect = data.offsets.reference;
  11592. var bound = find(data.instance.modifiers, function (modifier) {
  11593. return modifier.name === 'preventOverflow';
  11594. }).boundaries;
  11595.  
  11596. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  11597. // Avoid unnecessary DOM access if visibility hasn't changed
  11598. if (data.hide === true) {
  11599. return data;
  11600. }
  11601.  
  11602. data.hide = true;
  11603. data.attributes['x-out-of-boundaries'] = '';
  11604. } else {
  11605. // Avoid unnecessary DOM access if visibility hasn't changed
  11606. if (data.hide === false) {
  11607. return data;
  11608. }
  11609.  
  11610. data.hide = false;
  11611. data.attributes['x-out-of-boundaries'] = false;
  11612. }
  11613.  
  11614. return data;
  11615. }
  11616. /**
  11617. * @function
  11618. * @memberof Modifiers
  11619. * @argument {Object} data - The data object generated by `update` method
  11620. * @argument {Object} options - Modifiers configuration and options
  11621. * @returns {Object} The data object, properly modified
  11622. */
  11623.  
  11624.  
  11625. function inner(data) {
  11626. var placement = data.placement;
  11627. var basePlacement = placement.split('-')[0];
  11628. var _data$offsets = data.offsets,
  11629. popper = _data$offsets.popper,
  11630. reference = _data$offsets.reference;
  11631. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  11632. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  11633. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  11634. data.placement = getOppositePlacement(placement);
  11635. data.offsets.popper = getClientRect(popper);
  11636. return data;
  11637. }
  11638. /**
  11639. * Modifier function, each modifier can have a function of this type assigned
  11640. * to its `fn` property.<br />
  11641. * These functions will be called on each update, this means that you must
  11642. * make sure they are performant enough to avoid performance bottlenecks.
  11643. *
  11644. * @function ModifierFn
  11645. * @argument {dataObject} data - The data object generated by `update` method
  11646. * @argument {Object} options - Modifiers configuration and options
  11647. * @returns {dataObject} The data object, properly modified
  11648. */
  11649.  
  11650. /**
  11651. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  11652. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  11653. * needed by the library.
  11654. *
  11655. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  11656. * All the other properties are configurations that could be tweaked.
  11657. * @namespace modifiers
  11658. */
  11659.  
  11660.  
  11661. var modifiers = {
  11662. /**
  11663. * Modifier used to shift the popper on the start or end of its reference
  11664. * element.<br />
  11665. * It will read the variation of the `placement` property.<br />
  11666. * It can be one either `-end` or `-start`.
  11667. * @memberof modifiers
  11668. * @inner
  11669. */
  11670. shift: {
  11671. /** @prop {number} order=100 - Index used to define the order of execution */
  11672. order: 100,
  11673.  
  11674. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  11675. enabled: true,
  11676.  
  11677. /** @prop {ModifierFn} */
  11678. fn: shift
  11679. },
  11680.  
  11681. /**
  11682. * The `offset` modifier can shift your popper on both its axis.
  11683. *
  11684. * It accepts the following units:
  11685. * - `px` or unit-less, interpreted as pixels
  11686. * - `%` or `%r`, percentage relative to the length of the reference element
  11687. * - `%p`, percentage relative to the length of the popper element
  11688. * - `vw`, CSS viewport width unit
  11689. * - `vh`, CSS viewport height unit
  11690. *
  11691. * For length is intended the main axis relative to the placement of the popper.<br />
  11692. * This means that if the placement is `top` or `bottom`, the length will be the
  11693. * `width`. In case of `left` or `right`, it will be the `height`.
  11694. *
  11695. * You can provide a single value (as `Number` or `String`), or a pair of values
  11696. * as `String` divided by a comma or one (or more) white spaces.<br />
  11697. * The latter is a deprecated method because it leads to confusion and will be
  11698. * removed in v2.<br />
  11699. * Additionally, it accepts additions and subtractions between different units.
  11700. * Note that multiplications and divisions aren't supported.
  11701. *
  11702. * Valid examples are:
  11703. * ```
  11704. * 10
  11705. * '10%'
  11706. * '10, 10'
  11707. * '10%, 10'
  11708. * '10 + 10%'
  11709. * '10 - 5vh + 3%'
  11710. * '-10px + 5vh, 5px - 6%'
  11711. * ```
  11712. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  11713. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  11714. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  11715. *
  11716. * @memberof modifiers
  11717. * @inner
  11718. */
  11719. offset: {
  11720. /** @prop {number} order=200 - Index used to define the order of execution */
  11721. order: 200,
  11722.  
  11723. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  11724. enabled: true,
  11725.  
  11726. /** @prop {ModifierFn} */
  11727. fn: offset,
  11728.  
  11729. /** @prop {Number|String} offset=0
  11730. * The offset value as described in the modifier description
  11731. */
  11732. offset: 0
  11733. },
  11734.  
  11735. /**
  11736. * Modifier used to prevent the popper from being positioned outside the boundary.
  11737. *
  11738. * A scenario exists where the reference itself is not within the boundaries.<br />
  11739. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  11740. * In this case we need to decide whether the popper should either:
  11741. *
  11742. * - detach from the reference and remain "trapped" in the boundaries, or
  11743. * - if it should ignore the boundary and "escape with its reference"
  11744. *
  11745. * When `escapeWithReference` is set to`true` and reference is completely
  11746. * outside its boundaries, the popper will overflow (or completely leave)
  11747. * the boundaries in order to remain attached to the edge of the reference.
  11748. *
  11749. * @memberof modifiers
  11750. * @inner
  11751. */
  11752. preventOverflow: {
  11753. /** @prop {number} order=300 - Index used to define the order of execution */
  11754. order: 300,
  11755.  
  11756. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  11757. enabled: true,
  11758.  
  11759. /** @prop {ModifierFn} */
  11760. fn: preventOverflow,
  11761.  
  11762. /**
  11763. * @prop {Array} [priority=['left','right','top','bottom']]
  11764. * Popper will try to prevent overflow following these priorities by default,
  11765. * then, it could overflow on the left and on top of the `boundariesElement`
  11766. */
  11767. priority: ['left', 'right', 'top', 'bottom'],
  11768.  
  11769. /**
  11770. * @prop {number} padding=5
  11771. * Amount of pixel used to define a minimum distance between the boundaries
  11772. * and the popper. This makes sure the popper always has a little padding
  11773. * between the edges of its container
  11774. */
  11775. padding: 5,
  11776.  
  11777. /**
  11778. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  11779. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  11780. * `viewport` or any DOM element.
  11781. */
  11782. boundariesElement: 'scrollParent'
  11783. },
  11784.  
  11785. /**
  11786. * Modifier used to make sure the reference and its popper stay near each other
  11787. * without leaving any gap between the two. Especially useful when the arrow is
  11788. * enabled and you want to ensure that it points to its reference element.
  11789. * It cares only about the first axis. You can still have poppers with margin
  11790. * between the popper and its reference element.
  11791. * @memberof modifiers
  11792. * @inner
  11793. */
  11794. keepTogether: {
  11795. /** @prop {number} order=400 - Index used to define the order of execution */
  11796. order: 400,
  11797.  
  11798. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  11799. enabled: true,
  11800.  
  11801. /** @prop {ModifierFn} */
  11802. fn: keepTogether
  11803. },
  11804.  
  11805. /**
  11806. * This modifier is used to move the `arrowElement` of the popper to make
  11807. * sure it is positioned between the reference element and its popper element.
  11808. * It will read the outer size of the `arrowElement` node to detect how many
  11809. * pixels of conjunction are needed.
  11810. *
  11811. * It has no effect if no `arrowElement` is provided.
  11812. * @memberof modifiers
  11813. * @inner
  11814. */
  11815. arrow: {
  11816. /** @prop {number} order=500 - Index used to define the order of execution */
  11817. order: 500,
  11818.  
  11819. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  11820. enabled: true,
  11821.  
  11822. /** @prop {ModifierFn} */
  11823. fn: arrow,
  11824.  
  11825. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  11826. element: '[x-arrow]'
  11827. },
  11828.  
  11829. /**
  11830. * Modifier used to flip the popper's placement when it starts to overlap its
  11831. * reference element.
  11832. *
  11833. * Requires the `preventOverflow` modifier before it in order to work.
  11834. *
  11835. * **NOTE:** this modifier will interrupt the current update cycle and will
  11836. * restart it if it detects the need to flip the placement.
  11837. * @memberof modifiers
  11838. * @inner
  11839. */
  11840. flip: {
  11841. /** @prop {number} order=600 - Index used to define the order of execution */
  11842. order: 600,
  11843.  
  11844. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  11845. enabled: true,
  11846.  
  11847. /** @prop {ModifierFn} */
  11848. fn: flip,
  11849.  
  11850. /**
  11851. * @prop {String|Array} behavior='flip'
  11852. * The behavior used to change the popper's placement. It can be one of
  11853. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  11854. * placements (with optional variations)
  11855. */
  11856. behavior: 'flip',
  11857.  
  11858. /**
  11859. * @prop {number} padding=5
  11860. * The popper will flip if it hits the edges of the `boundariesElement`
  11861. */
  11862. padding: 5,
  11863.  
  11864. /**
  11865. * @prop {String|HTMLElement} boundariesElement='viewport'
  11866. * The element which will define the boundaries of the popper position.
  11867. * The popper will never be placed outside of the defined boundaries
  11868. * (except if `keepTogether` is enabled)
  11869. */
  11870. boundariesElement: 'viewport',
  11871.  
  11872. /**
  11873. * @prop {Boolean} flipVariations=false
  11874. * The popper will switch placement variation between `-start` and `-end` when
  11875. * the reference element overlaps its boundaries.
  11876. *
  11877. * The original placement should have a set variation.
  11878. */
  11879. flipVariations: false,
  11880.  
  11881. /**
  11882. * @prop {Boolean} flipVariationsByContent=false
  11883. * The popper will switch placement variation between `-start` and `-end` when
  11884. * the popper element overlaps its reference boundaries.
  11885. *
  11886. * The original placement should have a set variation.
  11887. */
  11888. flipVariationsByContent: false
  11889. },
  11890.  
  11891. /**
  11892. * Modifier used to make the popper flow toward the inner of the reference element.
  11893. * By default, when this modifier is disabled, the popper will be placed outside
  11894. * the reference element.
  11895. * @memberof modifiers
  11896. * @inner
  11897. */
  11898. inner: {
  11899. /** @prop {number} order=700 - Index used to define the order of execution */
  11900. order: 700,
  11901.  
  11902. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  11903. enabled: false,
  11904.  
  11905. /** @prop {ModifierFn} */
  11906. fn: inner
  11907. },
  11908.  
  11909. /**
  11910. * Modifier used to hide the popper when its reference element is outside of the
  11911. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  11912. * be used to hide with a CSS selector the popper when its reference is
  11913. * out of boundaries.
  11914. *
  11915. * Requires the `preventOverflow` modifier before it in order to work.
  11916. * @memberof modifiers
  11917. * @inner
  11918. */
  11919. hide: {
  11920. /** @prop {number} order=800 - Index used to define the order of execution */
  11921. order: 800,
  11922.  
  11923. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  11924. enabled: true,
  11925.  
  11926. /** @prop {ModifierFn} */
  11927. fn: hide
  11928. },
  11929.  
  11930. /**
  11931. * Computes the style that will be applied to the popper element to gets
  11932. * properly positioned.
  11933. *
  11934. * Note that this modifier will not touch the DOM, it just prepares the styles
  11935. * so that `applyStyle` modifier can apply it. This separation is useful
  11936. * in case you need to replace `applyStyle` with a custom implementation.
  11937. *
  11938. * This modifier has `850` as `order` value to maintain backward compatibility
  11939. * with previous versions of Popper.js. Expect the modifiers ordering method
  11940. * to change in future major versions of the library.
  11941. *
  11942. * @memberof modifiers
  11943. * @inner
  11944. */
  11945. computeStyle: {
  11946. /** @prop {number} order=850 - Index used to define the order of execution */
  11947. order: 850,
  11948.  
  11949. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  11950. enabled: true,
  11951.  
  11952. /** @prop {ModifierFn} */
  11953. fn: computeStyle,
  11954.  
  11955. /**
  11956. * @prop {Boolean} gpuAcceleration=true
  11957. * If true, it uses the CSS 3D transformation to position the popper.
  11958. * Otherwise, it will use the `top` and `left` properties
  11959. */
  11960. gpuAcceleration: true,
  11961.  
  11962. /**
  11963. * @prop {string} [x='bottom']
  11964. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  11965. * Change this if your popper should grow in a direction different from `bottom`
  11966. */
  11967. x: 'bottom',
  11968.  
  11969. /**
  11970. * @prop {string} [x='left']
  11971. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  11972. * Change this if your popper should grow in a direction different from `right`
  11973. */
  11974. y: 'right'
  11975. },
  11976.  
  11977. /**
  11978. * Applies the computed styles to the popper element.
  11979. *
  11980. * All the DOM manipulations are limited to this modifier. This is useful in case
  11981. * you want to integrate Popper.js inside a framework or view library and you
  11982. * want to delegate all the DOM manipulations to it.
  11983. *
  11984. * Note that if you disable this modifier, you must make sure the popper element
  11985. * has its position set to `absolute` before Popper.js can do its work!
  11986. *
  11987. * Just disable this modifier and define your own to achieve the desired effect.
  11988. *
  11989. * @memberof modifiers
  11990. * @inner
  11991. */
  11992. applyStyle: {
  11993. /** @prop {number} order=900 - Index used to define the order of execution */
  11994. order: 900,
  11995.  
  11996. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  11997. enabled: true,
  11998.  
  11999. /** @prop {ModifierFn} */
  12000. fn: applyStyle,
  12001.  
  12002. /** @prop {Function} */
  12003. onLoad: applyStyleOnLoad,
  12004.  
  12005. /**
  12006. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  12007. * @prop {Boolean} gpuAcceleration=true
  12008. * If true, it uses the CSS 3D transformation to position the popper.
  12009. * Otherwise, it will use the `top` and `left` properties
  12010. */
  12011. gpuAcceleration: undefined
  12012. }
  12013. };
  12014. /**
  12015. * The `dataObject` is an object containing all the information used by Popper.js.
  12016. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  12017. * @name dataObject
  12018. * @property {Object} data.instance The Popper.js instance
  12019. * @property {String} data.placement Placement applied to popper
  12020. * @property {String} data.originalPlacement Placement originally defined on init
  12021. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  12022. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  12023. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  12024. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  12025. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  12026. * @property {Object} data.boundaries Offsets of the popper boundaries
  12027. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  12028. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  12029. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  12030. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  12031. */
  12032.  
  12033. /**
  12034. * Default options provided to Popper.js constructor.<br />
  12035. * These can be overridden using the `options` argument of Popper.js.<br />
  12036. * To override an option, simply pass an object with the same
  12037. * structure of the `options` object, as the 3rd argument. For example:
  12038. * ```
  12039. * new Popper(ref, pop, {
  12040. * modifiers: {
  12041. * preventOverflow: { enabled: false }
  12042. * }
  12043. * })
  12044. * ```
  12045. * @type {Object}
  12046. * @static
  12047. * @memberof Popper
  12048. */
  12049.  
  12050. var Defaults = {
  12051. /**
  12052. * Popper's placement.
  12053. * @prop {Popper.placements} placement='bottom'
  12054. */
  12055. placement: 'bottom',
  12056.  
  12057. /**
  12058. * Set this to true if you want popper to position it self in 'fixed' mode
  12059. * @prop {Boolean} positionFixed=false
  12060. */
  12061. positionFixed: false,
  12062.  
  12063. /**
  12064. * Whether events (resize, scroll) are initially enabled.
  12065. * @prop {Boolean} eventsEnabled=true
  12066. */
  12067. eventsEnabled: true,
  12068.  
  12069. /**
  12070. * Set to true if you want to automatically remove the popper when
  12071. * you call the `destroy` method.
  12072. * @prop {Boolean} removeOnDestroy=false
  12073. */
  12074. removeOnDestroy: false,
  12075.  
  12076. /**
  12077. * Callback called when the popper is created.<br />
  12078. * By default, it is set to no-op.<br />
  12079. * Access Popper.js instance with `data.instance`.
  12080. * @prop {onCreate}
  12081. */
  12082. onCreate: function onCreate() {},
  12083.  
  12084. /**
  12085. * Callback called when the popper is updated. This callback is not called
  12086. * on the initialization/creation of the popper, but only on subsequent
  12087. * updates.<br />
  12088. * By default, it is set to no-op.<br />
  12089. * Access Popper.js instance with `data.instance`.
  12090. * @prop {onUpdate}
  12091. */
  12092. onUpdate: function onUpdate() {},
  12093.  
  12094. /**
  12095. * List of modifiers used to modify the offsets before they are applied to the popper.
  12096. * They provide most of the functionalities of Popper.js.
  12097. * @prop {modifiers}
  12098. */
  12099. modifiers: modifiers
  12100. };
  12101. /**
  12102. * @callback onCreate
  12103. * @param {dataObject} data
  12104. */
  12105.  
  12106. /**
  12107. * @callback onUpdate
  12108. * @param {dataObject} data
  12109. */
  12110. // Utils
  12111. // Methods
  12112.  
  12113. var Popper$1 = function () {
  12114. /**
  12115. * Creates a new Popper.js instance.
  12116. * @class Popper
  12117. * @param {Element|referenceObject} reference - The reference element used to position the popper
  12118. * @param {Element} popper - The HTML / XML element used as the popper
  12119. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  12120. * @return {Object} instance - The generated Popper.js instance
  12121. */
  12122. function Popper(reference, popper) {
  12123. var _this = this;
  12124.  
  12125. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  12126. classCallCheck(this, Popper);
  12127.  
  12128. this.scheduleUpdate = function () {
  12129. return requestAnimationFrame(_this.update);
  12130. }; // make update() debounced, so that it only runs at most once-per-tick
  12131.  
  12132.  
  12133. this.update = debounce(this.update.bind(this)); // with {} we create a new object with the options inside it
  12134.  
  12135. this.options = _extends({}, Popper.Defaults, options); // init state
  12136.  
  12137. this.state = {
  12138. isDestroyed: false,
  12139. isCreated: false,
  12140. scrollParents: []
  12141. }; // get reference and popper elements (allow jQuery wrappers)
  12142.  
  12143. this.reference = reference && reference.jquery ? reference[0] : reference;
  12144. this.popper = popper && popper.jquery ? popper[0] : popper; // Deep merge modifiers options
  12145.  
  12146. this.options.modifiers = {};
  12147. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  12148. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  12149. }); // Refactoring modifiers' list (Object => Array)
  12150.  
  12151. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  12152. return _extends({
  12153. name: name
  12154. }, _this.options.modifiers[name]);
  12155. }) // sort the modifiers by order
  12156. .sort(function (a, b) {
  12157. return a.order - b.order;
  12158. }); // modifiers have the ability to execute arbitrary code when Popper.js get inited
  12159. // such code is executed in the same order of its modifier
  12160. // they could add new properties to their options configuration
  12161. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  12162.  
  12163. this.modifiers.forEach(function (modifierOptions) {
  12164. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  12165. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  12166. }
  12167. }); // fire the first update to position the popper in the right place
  12168.  
  12169. this.update();
  12170. var eventsEnabled = this.options.eventsEnabled;
  12171.  
  12172. if (eventsEnabled) {
  12173. // setup event listeners, they will take care of update the position in specific situations
  12174. this.enableEventListeners();
  12175. }
  12176.  
  12177. this.state.eventsEnabled = eventsEnabled;
  12178. } // We can't use class properties because they don't get listed in the
  12179. // class prototype and break stuff like Sinon stubs
  12180.  
  12181.  
  12182. createClass(Popper, [{
  12183. key: 'update',
  12184. value: function update$$1() {
  12185. return update.call(this);
  12186. }
  12187. }, {
  12188. key: 'destroy',
  12189. value: function destroy$$1() {
  12190. return destroy.call(this);
  12191. }
  12192. }, {
  12193. key: 'enableEventListeners',
  12194. value: function enableEventListeners$$1() {
  12195. return enableEventListeners.call(this);
  12196. }
  12197. }, {
  12198. key: 'disableEventListeners',
  12199. value: function disableEventListeners$$1() {
  12200. return disableEventListeners.call(this);
  12201. }
  12202. /**
  12203. * Schedules an update. It will run on the next UI update available.
  12204. * @method scheduleUpdate
  12205. * @memberof Popper
  12206. */
  12207.  
  12208. /**
  12209. * Collection of utilities useful when writing custom modifiers.
  12210. * Starting from version 1.7, this method is available only if you
  12211. * include `popper-utils.js` before `popper.js`.
  12212. *
  12213. * **DEPRECATION**: This way to access PopperUtils is deprecated
  12214. * and will be removed in v2! Use the PopperUtils module directly instead.
  12215. * Due to the high instability of the methods contained in Utils, we can't
  12216. * guarantee them to follow semver. Use them at your own risk!
  12217. * @static
  12218. * @private
  12219. * @type {Object}
  12220. * @deprecated since version 1.8
  12221. * @member Utils
  12222. * @memberof Popper
  12223. */
  12224.  
  12225. }]);
  12226. return Popper;
  12227. }();
  12228. /**
  12229. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  12230. * and lets you use it as replacement of a real DOM node.<br />
  12231. * You can use this method to position a popper relatively to a set of coordinates
  12232. * in case you don't have a DOM node to use as reference.
  12233. *
  12234. * ```
  12235. * new Popper(referenceObject, popperNode);
  12236. * ```
  12237. *
  12238. * NB: This feature isn't supported in Internet Explorer 10.
  12239. * @name referenceObject
  12240. * @property {Function} data.getBoundingClientRect
  12241. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  12242. * @property {number} data.clientWidth
  12243. * An ES6 getter that will return the width of the virtual reference element.
  12244. * @property {number} data.clientHeight
  12245. * An ES6 getter that will return the height of the virtual reference element.
  12246. */
  12247.  
  12248.  
  12249. Popper$1.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  12250. Popper$1.placements = placements;
  12251. Popper$1.Defaults = Defaults;
  12252.  
  12253. function flipPlacement(placement, theme) {
  12254. var direction = theme && theme.direction || 'ltr';
  12255.  
  12256. if (direction === 'ltr') {
  12257. return placement;
  12258. }
  12259.  
  12260. switch (placement) {
  12261. case 'bottom-end':
  12262. return 'bottom-start';
  12263.  
  12264. case 'bottom-start':
  12265. return 'bottom-end';
  12266.  
  12267. case 'top-end':
  12268. return 'top-start';
  12269.  
  12270. case 'top-start':
  12271. return 'top-end';
  12272.  
  12273. default:
  12274. return placement;
  12275. }
  12276. }
  12277.  
  12278. function getAnchorEl(anchorEl) {
  12279. return typeof anchorEl === 'function' ? anchorEl() : anchorEl;
  12280. }
  12281.  
  12282. var useEnhancedEffect = typeof window !== 'undefined' ? React__namespace.useLayoutEffect : React__namespace.useEffect;
  12283. var defaultPopperOptions = {};
  12284. /**
  12285. * Poppers rely on the 3rd party library [Popper.js](https://popper.js.org/docs/v1/) for positioning.
  12286. */
  12287.  
  12288. var Popper = /*#__PURE__*/React__namespace.forwardRef(function Popper(props, ref) {
  12289. var anchorEl = props.anchorEl,
  12290. children = props.children,
  12291. container = props.container,
  12292. _props$disablePortal = props.disablePortal,
  12293. disablePortal = _props$disablePortal === void 0 ? false : _props$disablePortal,
  12294. _props$keepMounted = props.keepMounted,
  12295. keepMounted = _props$keepMounted === void 0 ? false : _props$keepMounted,
  12296. modifiers = props.modifiers,
  12297. open = props.open,
  12298. _props$placement = props.placement,
  12299. initialPlacement = _props$placement === void 0 ? 'bottom' : _props$placement,
  12300. _props$popperOptions = props.popperOptions,
  12301. popperOptions = _props$popperOptions === void 0 ? defaultPopperOptions : _props$popperOptions,
  12302. popperRefProp = props.popperRef,
  12303. style = props.style,
  12304. _props$transition = props.transition,
  12305. transition = _props$transition === void 0 ? false : _props$transition,
  12306. other = _objectWithoutProperties(props, ["anchorEl", "children", "container", "disablePortal", "keepMounted", "modifiers", "open", "placement", "popperOptions", "popperRef", "style", "transition"]);
  12307.  
  12308. var tooltipRef = React__namespace.useRef(null);
  12309. var ownRef = useForkRef(tooltipRef, ref);
  12310. var popperRef = React__namespace.useRef(null);
  12311. var handlePopperRef = useForkRef(popperRef, popperRefProp);
  12312. var handlePopperRefRef = React__namespace.useRef(handlePopperRef);
  12313. useEnhancedEffect(function () {
  12314. handlePopperRefRef.current = handlePopperRef;
  12315. }, [handlePopperRef]);
  12316. React__namespace.useImperativeHandle(popperRefProp, function () {
  12317. return popperRef.current;
  12318. }, []);
  12319.  
  12320. var _React$useState = React__namespace.useState(true),
  12321. exited = _React$useState[0],
  12322. setExited = _React$useState[1];
  12323.  
  12324. var theme = useTheme$1();
  12325. var rtlPlacement = flipPlacement(initialPlacement, theme);
  12326. /**
  12327. * placement initialized from prop but can change during lifetime if modifiers.flip.
  12328. * modifiers.flip is essentially a flip for controlled/uncontrolled behavior
  12329. */
  12330.  
  12331. var _React$useState2 = React__namespace.useState(rtlPlacement),
  12332. placement = _React$useState2[0],
  12333. setPlacement = _React$useState2[1];
  12334.  
  12335. React__namespace.useEffect(function () {
  12336. if (popperRef.current) {
  12337. popperRef.current.update();
  12338. }
  12339. });
  12340. var handleOpen = React__namespace.useCallback(function () {
  12341. if (!tooltipRef.current || !anchorEl || !open) {
  12342. return;
  12343. }
  12344.  
  12345. if (popperRef.current) {
  12346. popperRef.current.destroy();
  12347. handlePopperRefRef.current(null);
  12348. }
  12349.  
  12350. var handlePopperUpdate = function handlePopperUpdate(data) {
  12351. setPlacement(data.placement);
  12352. };
  12353.  
  12354. getAnchorEl(anchorEl);
  12355.  
  12356. var popper = new Popper$1(getAnchorEl(anchorEl), tooltipRef.current, _extends$1({
  12357. placement: rtlPlacement
  12358. }, popperOptions, {
  12359. modifiers: _extends$1({}, disablePortal ? {} : {
  12360. // It's using scrollParent by default, we can use the viewport when using a portal.
  12361. preventOverflow: {
  12362. boundariesElement: 'window'
  12363. }
  12364. }, modifiers, popperOptions.modifiers),
  12365. // We could have been using a custom modifier like react-popper is doing.
  12366. // But it seems this is the best public API for this use case.
  12367. onCreate: createChainedFunction(handlePopperUpdate, popperOptions.onCreate),
  12368. onUpdate: createChainedFunction(handlePopperUpdate, popperOptions.onUpdate)
  12369. }));
  12370. handlePopperRefRef.current(popper);
  12371. }, [anchorEl, disablePortal, modifiers, open, rtlPlacement, popperOptions]);
  12372. var handleRef = React__namespace.useCallback(function (node) {
  12373. setRef(ownRef, node);
  12374. handleOpen();
  12375. }, [ownRef, handleOpen]);
  12376.  
  12377. var handleEnter = function handleEnter() {
  12378. setExited(false);
  12379. };
  12380.  
  12381. var handleClose = function handleClose() {
  12382. if (!popperRef.current) {
  12383. return;
  12384. }
  12385.  
  12386. popperRef.current.destroy();
  12387. handlePopperRefRef.current(null);
  12388. };
  12389.  
  12390. var handleExited = function handleExited() {
  12391. setExited(true);
  12392. handleClose();
  12393. };
  12394.  
  12395. React__namespace.useEffect(function () {
  12396. return function () {
  12397. handleClose();
  12398. };
  12399. }, []);
  12400. React__namespace.useEffect(function () {
  12401. if (!open && !transition) {
  12402. // Otherwise handleExited will call this.
  12403. handleClose();
  12404. }
  12405. }, [open, transition]);
  12406.  
  12407. if (!keepMounted && !open && (!transition || exited)) {
  12408. return null;
  12409. }
  12410.  
  12411. var childProps = {
  12412. placement: placement
  12413. };
  12414.  
  12415. if (transition) {
  12416. childProps.TransitionProps = {
  12417. in: open,
  12418. onEnter: handleEnter,
  12419. onExited: handleExited
  12420. };
  12421. }
  12422.  
  12423. return /*#__PURE__*/React__namespace.createElement(Portal, {
  12424. disablePortal: disablePortal,
  12425. container: container
  12426. }, /*#__PURE__*/React__namespace.createElement("div", _extends$1({
  12427. ref: handleRef,
  12428. role: "tooltip"
  12429. }, other, {
  12430. style: _extends$1({
  12431. // Prevents scroll issue, waiting for Popper.js to add this style once initiated.
  12432. position: 'fixed',
  12433. // Fix Popper.js display issue
  12434. top: 0,
  12435. left: 0,
  12436. display: !open && keepMounted && !transition ? 'none' : null
  12437. }, style)
  12438. }), typeof children === 'function' ? children(childProps) : children));
  12439. });
  12440.  
  12441. var styles$3 = function styles(theme) {
  12442. return {
  12443. thumb: {
  12444. '&$open': {
  12445. '& $offset': {
  12446. transform: 'scale(1) translateY(-10px)'
  12447. }
  12448. }
  12449. },
  12450. open: {},
  12451. offset: _extends$1({
  12452. zIndex: 1
  12453. }, theme.typography.body2, {
  12454. fontSize: theme.typography.pxToRem(12),
  12455. lineHeight: 1.2,
  12456. transition: theme.transitions.create(['transform'], {
  12457. duration: theme.transitions.duration.shortest
  12458. }),
  12459. top: -34,
  12460. transformOrigin: 'bottom center',
  12461. transform: 'scale(0)',
  12462. position: 'absolute'
  12463. }),
  12464. circle: {
  12465. display: 'flex',
  12466. alignItems: 'center',
  12467. justifyContent: 'center',
  12468. width: 32,
  12469. height: 32,
  12470. borderRadius: '50% 50% 50% 0',
  12471. backgroundColor: 'currentColor',
  12472. transform: 'rotate(-45deg)'
  12473. },
  12474. label: {
  12475. color: theme.palette.primary.contrastText,
  12476. transform: 'rotate(45deg)'
  12477. }
  12478. };
  12479. };
  12480. /**
  12481. * @ignore - internal component.
  12482. */
  12483.  
  12484.  
  12485. function ValueLabel(props) {
  12486. var children = props.children,
  12487. classes = props.classes,
  12488. className = props.className,
  12489. open = props.open,
  12490. value = props.value,
  12491. valueLabelDisplay = props.valueLabelDisplay;
  12492.  
  12493. if (valueLabelDisplay === 'off') {
  12494. return children;
  12495. }
  12496.  
  12497. return /*#__PURE__*/React__namespace.cloneElement(children, {
  12498. className: clsx(children.props.className, (open || valueLabelDisplay === 'on') && classes.open, classes.thumb)
  12499. }, /*#__PURE__*/React__namespace.createElement("span", {
  12500. className: clsx(classes.offset, className)
  12501. }, /*#__PURE__*/React__namespace.createElement("span", {
  12502. className: classes.circle
  12503. }, /*#__PURE__*/React__namespace.createElement("span", {
  12504. className: classes.label
  12505. }, value))));
  12506. }
  12507.  
  12508. var ValueLabel$1 = withStyles(styles$3, {
  12509. name: 'PrivateValueLabel'
  12510. })(ValueLabel);
  12511.  
  12512. function asc(a, b) {
  12513. return a - b;
  12514. }
  12515.  
  12516. function clamp(value, min, max) {
  12517. return Math.min(Math.max(min, value), max);
  12518. }
  12519.  
  12520. function findClosest(values, currentValue) {
  12521. var _values$reduce = values.reduce(function (acc, value, index) {
  12522. var distance = Math.abs(currentValue - value);
  12523.  
  12524. if (acc === null || distance < acc.distance || distance === acc.distance) {
  12525. return {
  12526. distance: distance,
  12527. index: index
  12528. };
  12529. }
  12530.  
  12531. return acc;
  12532. }, null),
  12533. closestIndex = _values$reduce.index;
  12534.  
  12535. return closestIndex;
  12536. }
  12537.  
  12538. function trackFinger(event, touchId) {
  12539. if (touchId.current !== undefined && event.changedTouches) {
  12540. for (var i = 0; i < event.changedTouches.length; i += 1) {
  12541. var touch = event.changedTouches[i];
  12542.  
  12543. if (touch.identifier === touchId.current) {
  12544. return {
  12545. x: touch.clientX,
  12546. y: touch.clientY
  12547. };
  12548. }
  12549. }
  12550.  
  12551. return false;
  12552. }
  12553.  
  12554. return {
  12555. x: event.clientX,
  12556. y: event.clientY
  12557. };
  12558. }
  12559.  
  12560. function valueToPercent(value, min, max) {
  12561. return (value - min) * 100 / (max - min);
  12562. }
  12563.  
  12564. function percentToValue(percent, min, max) {
  12565. return (max - min) * percent + min;
  12566. }
  12567.  
  12568. function getDecimalPrecision(num) {
  12569. // This handles the case when num is very small (0.00000001), js will turn this into 1e-8.
  12570. // When num is bigger than 1 or less than -1 it won't get converted to this notation so it's fine.
  12571. if (Math.abs(num) < 1) {
  12572. var parts = num.toExponential().split('e-');
  12573. var matissaDecimalPart = parts[0].split('.')[1];
  12574. return (matissaDecimalPart ? matissaDecimalPart.length : 0) + parseInt(parts[1], 10);
  12575. }
  12576.  
  12577. var decimalPart = num.toString().split('.')[1];
  12578. return decimalPart ? decimalPart.length : 0;
  12579. }
  12580.  
  12581. function roundValueToStep(value, step, min) {
  12582. var nearest = Math.round((value - min) / step) * step + min;
  12583. return Number(nearest.toFixed(getDecimalPrecision(step)));
  12584. }
  12585.  
  12586. function setValueIndex(_ref) {
  12587. var values = _ref.values,
  12588. source = _ref.source,
  12589. newValue = _ref.newValue,
  12590. index = _ref.index; // Performance shortcut
  12591.  
  12592. if (values[index] === newValue) {
  12593. return source;
  12594. }
  12595.  
  12596. var output = values.slice();
  12597. output[index] = newValue;
  12598. return output;
  12599. }
  12600.  
  12601. function focusThumb(_ref2) {
  12602. var sliderRef = _ref2.sliderRef,
  12603. activeIndex = _ref2.activeIndex,
  12604. setActive = _ref2.setActive;
  12605.  
  12606. if (!sliderRef.current.contains(document.activeElement) || Number(document.activeElement.getAttribute('data-index')) !== activeIndex) {
  12607. sliderRef.current.querySelector("[role=\"slider\"][data-index=\"".concat(activeIndex, "\"]")).focus();
  12608. }
  12609.  
  12610. if (setActive) {
  12611. setActive(activeIndex);
  12612. }
  12613. }
  12614.  
  12615. var axisProps = {
  12616. horizontal: {
  12617. offset: function offset(percent) {
  12618. return {
  12619. left: "".concat(percent, "%")
  12620. };
  12621. },
  12622. leap: function leap(percent) {
  12623. return {
  12624. width: "".concat(percent, "%")
  12625. };
  12626. }
  12627. },
  12628. 'horizontal-reverse': {
  12629. offset: function offset(percent) {
  12630. return {
  12631. right: "".concat(percent, "%")
  12632. };
  12633. },
  12634. leap: function leap(percent) {
  12635. return {
  12636. width: "".concat(percent, "%")
  12637. };
  12638. }
  12639. },
  12640. vertical: {
  12641. offset: function offset(percent) {
  12642. return {
  12643. bottom: "".concat(percent, "%")
  12644. };
  12645. },
  12646. leap: function leap(percent) {
  12647. return {
  12648. height: "".concat(percent, "%")
  12649. };
  12650. }
  12651. }
  12652. };
  12653.  
  12654. var Identity = function Identity(x) {
  12655. return x;
  12656. };
  12657.  
  12658. var styles$2 = function styles(theme) {
  12659. return {
  12660. /* Styles applied to the root element. */
  12661. root: {
  12662. height: 2,
  12663. width: '100%',
  12664. boxSizing: 'content-box',
  12665. padding: '13px 0',
  12666. display: 'inline-block',
  12667. position: 'relative',
  12668. cursor: 'pointer',
  12669. touchAction: 'none',
  12670. color: theme.palette.primary.main,
  12671. WebkitTapHighlightColor: 'transparent',
  12672. '&$disabled': {
  12673. pointerEvents: 'none',
  12674. cursor: 'default',
  12675. color: theme.palette.grey[400]
  12676. },
  12677. '&$vertical': {
  12678. width: 2,
  12679. height: '100%',
  12680. padding: '0 13px'
  12681. },
  12682. // The primary input mechanism of the device includes a pointing device of limited accuracy.
  12683. '@media (pointer: coarse)': {
  12684. // Reach 42px touch target, about ~8mm on screen.
  12685. padding: '20px 0',
  12686. '&$vertical': {
  12687. padding: '0 20px'
  12688. }
  12689. },
  12690. '@media print': {
  12691. colorAdjust: 'exact'
  12692. }
  12693. },
  12694.  
  12695. /* Styles applied to the root element if `color="primary"`. */
  12696. colorPrimary: {// TODO v5: move the style here
  12697. },
  12698.  
  12699. /* Styles applied to the root element if `color="secondary"`. */
  12700. colorSecondary: {
  12701. color: theme.palette.secondary.main
  12702. },
  12703.  
  12704. /* Styles applied to the root element if `marks` is provided with at least one label. */
  12705. marked: {
  12706. marginBottom: 20,
  12707. '&$vertical': {
  12708. marginBottom: 'auto',
  12709. marginRight: 20
  12710. }
  12711. },
  12712.  
  12713. /* Pseudo-class applied to the root element if `orientation="vertical"`. */
  12714. vertical: {},
  12715.  
  12716. /* Pseudo-class applied to the root and thumb element if `disabled={true}`. */
  12717. disabled: {},
  12718.  
  12719. /* Styles applied to the rail element. */
  12720. rail: {
  12721. display: 'block',
  12722. position: 'absolute',
  12723. width: '100%',
  12724. height: 2,
  12725. borderRadius: 1,
  12726. backgroundColor: 'currentColor',
  12727. opacity: 0.38,
  12728. '$vertical &': {
  12729. height: '100%',
  12730. width: 2
  12731. }
  12732. },
  12733.  
  12734. /* Styles applied to the track element. */
  12735. track: {
  12736. display: 'block',
  12737. position: 'absolute',
  12738. height: 2,
  12739. borderRadius: 1,
  12740. backgroundColor: 'currentColor',
  12741. '$vertical &': {
  12742. width: 2
  12743. }
  12744. },
  12745.  
  12746. /* Styles applied to the track element if `track={false}`. */
  12747. trackFalse: {
  12748. '& $track': {
  12749. display: 'none'
  12750. }
  12751. },
  12752.  
  12753. /* Styles applied to the track element if `track="inverted"`. */
  12754. trackInverted: {
  12755. '& $track': {
  12756. backgroundColor: // Same logic as the LinearProgress track color
  12757. theme.palette.type === 'light' ? lighten(theme.palette.primary.main, 0.62) : darken(theme.palette.primary.main, 0.5)
  12758. },
  12759. '& $rail': {
  12760. opacity: 1
  12761. }
  12762. },
  12763.  
  12764. /* Styles applied to the thumb element. */
  12765. thumb: {
  12766. position: 'absolute',
  12767. width: 12,
  12768. height: 12,
  12769. marginLeft: -6,
  12770. marginTop: -5,
  12771. boxSizing: 'border-box',
  12772. borderRadius: '50%',
  12773. outline: 0,
  12774. backgroundColor: 'currentColor',
  12775. display: 'flex',
  12776. alignItems: 'center',
  12777. justifyContent: 'center',
  12778. transition: theme.transitions.create(['box-shadow'], {
  12779. duration: theme.transitions.duration.shortest
  12780. }),
  12781. '&::after': {
  12782. position: 'absolute',
  12783. content: '""',
  12784. borderRadius: '50%',
  12785. // reach 42px hit target (2 * 15 + thumb diameter)
  12786. left: -15,
  12787. top: -15,
  12788. right: -15,
  12789. bottom: -15
  12790. },
  12791. '&$focusVisible,&:hover': {
  12792. boxShadow: "0px 0px 0px 8px ".concat(fade(theme.palette.primary.main, 0.16)),
  12793. '@media (hover: none)': {
  12794. boxShadow: 'none'
  12795. }
  12796. },
  12797. '&$active': {
  12798. boxShadow: "0px 0px 0px 14px ".concat(fade(theme.palette.primary.main, 0.16))
  12799. },
  12800. '&$disabled': {
  12801. width: 8,
  12802. height: 8,
  12803. marginLeft: -4,
  12804. marginTop: -3,
  12805. '&:hover': {
  12806. boxShadow: 'none'
  12807. }
  12808. },
  12809. '$vertical &': {
  12810. marginLeft: -5,
  12811. marginBottom: -6
  12812. },
  12813. '$vertical &$disabled': {
  12814. marginLeft: -3,
  12815. marginBottom: -4
  12816. }
  12817. },
  12818.  
  12819. /* Styles applied to the thumb element if `color="primary"`. */
  12820. thumbColorPrimary: {// TODO v5: move the style here
  12821. },
  12822.  
  12823. /* Styles applied to the thumb element if `color="secondary"`. */
  12824. thumbColorSecondary: {
  12825. '&$focusVisible,&:hover': {
  12826. boxShadow: "0px 0px 0px 8px ".concat(fade(theme.palette.secondary.main, 0.16))
  12827. },
  12828. '&$active': {
  12829. boxShadow: "0px 0px 0px 14px ".concat(fade(theme.palette.secondary.main, 0.16))
  12830. }
  12831. },
  12832.  
  12833. /* Pseudo-class applied to the thumb element if it's active. */
  12834. active: {},
  12835.  
  12836. /* Pseudo-class applied to the thumb element if keyboard focused. */
  12837. focusVisible: {},
  12838.  
  12839. /* Styles applied to the thumb label element. */
  12840. valueLabel: {
  12841. // IE 11 centering bug, to remove from the customization demos once no longer supported
  12842. left: 'calc(-50% - 4px)'
  12843. },
  12844.  
  12845. /* Styles applied to the mark element. */
  12846. mark: {
  12847. position: 'absolute',
  12848. width: 2,
  12849. height: 2,
  12850. borderRadius: 1,
  12851. backgroundColor: 'currentColor'
  12852. },
  12853.  
  12854. /* Styles applied to the mark element if active (depending on the value). */
  12855. markActive: {
  12856. backgroundColor: theme.palette.background.paper,
  12857. opacity: 0.8
  12858. },
  12859.  
  12860. /* Styles applied to the mark label element. */
  12861. markLabel: _extends$1({}, theme.typography.body2, {
  12862. color: theme.palette.text.secondary,
  12863. position: 'absolute',
  12864. top: 26,
  12865. transform: 'translateX(-50%)',
  12866. whiteSpace: 'nowrap',
  12867. '$vertical &': {
  12868. top: 'auto',
  12869. left: 26,
  12870. transform: 'translateY(50%)'
  12871. },
  12872. '@media (pointer: coarse)': {
  12873. top: 40,
  12874. '$vertical &': {
  12875. left: 31
  12876. }
  12877. }
  12878. }),
  12879.  
  12880. /* Styles applied to the mark label element if active (depending on the value). */
  12881. markLabelActive: {
  12882. color: theme.palette.text.primary
  12883. }
  12884. };
  12885. };
  12886. var Slider = /*#__PURE__*/React__namespace.forwardRef(function Slider(props, ref) {
  12887. var ariaLabel = props['aria-label'],
  12888. ariaLabelledby = props['aria-labelledby'],
  12889. ariaValuetext = props['aria-valuetext'],
  12890. classes = props.classes,
  12891. className = props.className,
  12892. _props$color = props.color,
  12893. color = _props$color === void 0 ? 'primary' : _props$color,
  12894. _props$component = props.component,
  12895. Component = _props$component === void 0 ? 'span' : _props$component,
  12896. defaultValue = props.defaultValue,
  12897. _props$disabled = props.disabled,
  12898. disabled = _props$disabled === void 0 ? false : _props$disabled,
  12899. getAriaLabel = props.getAriaLabel,
  12900. getAriaValueText = props.getAriaValueText,
  12901. _props$marks = props.marks,
  12902. marksProp = _props$marks === void 0 ? false : _props$marks,
  12903. _props$max = props.max,
  12904. max = _props$max === void 0 ? 100 : _props$max,
  12905. _props$min = props.min,
  12906. min = _props$min === void 0 ? 0 : _props$min,
  12907. name = props.name,
  12908. onChange = props.onChange,
  12909. onChangeCommitted = props.onChangeCommitted,
  12910. onMouseDown = props.onMouseDown,
  12911. _props$orientation = props.orientation,
  12912. orientation = _props$orientation === void 0 ? 'horizontal' : _props$orientation,
  12913. _props$scale = props.scale,
  12914. scale = _props$scale === void 0 ? Identity : _props$scale,
  12915. _props$step = props.step,
  12916. step = _props$step === void 0 ? 1 : _props$step,
  12917. _props$ThumbComponent = props.ThumbComponent,
  12918. ThumbComponent = _props$ThumbComponent === void 0 ? 'span' : _props$ThumbComponent,
  12919. _props$track = props.track,
  12920. track = _props$track === void 0 ? 'normal' : _props$track,
  12921. valueProp = props.value,
  12922. _props$ValueLabelComp = props.ValueLabelComponent,
  12923. ValueLabelComponent = _props$ValueLabelComp === void 0 ? ValueLabel$1 : _props$ValueLabelComp,
  12924. _props$valueLabelDisp = props.valueLabelDisplay,
  12925. valueLabelDisplay = _props$valueLabelDisp === void 0 ? 'off' : _props$valueLabelDisp,
  12926. _props$valueLabelForm = props.valueLabelFormat,
  12927. valueLabelFormat = _props$valueLabelForm === void 0 ? Identity : _props$valueLabelForm,
  12928. other = _objectWithoutProperties(props, ["aria-label", "aria-labelledby", "aria-valuetext", "classes", "className", "color", "component", "defaultValue", "disabled", "getAriaLabel", "getAriaValueText", "marks", "max", "min", "name", "onChange", "onChangeCommitted", "onMouseDown", "orientation", "scale", "step", "ThumbComponent", "track", "value", "ValueLabelComponent", "valueLabelDisplay", "valueLabelFormat"]);
  12929.  
  12930. var theme = useTheme();
  12931. var touchId = React__namespace.useRef(); // We can't use the :active browser pseudo-classes.
  12932. // - The active state isn't triggered when clicking on the rail.
  12933. // - The active state isn't transfered when inversing a range slider.
  12934.  
  12935. var _React$useState = React__namespace.useState(-1),
  12936. active = _React$useState[0],
  12937. setActive = _React$useState[1];
  12938.  
  12939. var _React$useState2 = React__namespace.useState(-1),
  12940. open = _React$useState2[0],
  12941. setOpen = _React$useState2[1];
  12942.  
  12943. var _useControlled = useControlled({
  12944. controlled: valueProp,
  12945. default: defaultValue,
  12946. name: 'Slider'
  12947. }),
  12948. _useControlled2 = _slicedToArray(_useControlled, 2),
  12949. valueDerived = _useControlled2[0],
  12950. setValueState = _useControlled2[1];
  12951.  
  12952. var range = Array.isArray(valueDerived);
  12953. var values = range ? valueDerived.slice().sort(asc) : [valueDerived];
  12954. values = values.map(function (value) {
  12955. return clamp(value, min, max);
  12956. });
  12957. var marks = marksProp === true && step !== null ? _toConsumableArray(Array(Math.floor((max - min) / step) + 1)).map(function (_, index) {
  12958. return {
  12959. value: min + step * index
  12960. };
  12961. }) : marksProp || [];
  12962.  
  12963. var _useIsFocusVisible = useIsFocusVisible(),
  12964. isFocusVisible = _useIsFocusVisible.isFocusVisible,
  12965. onBlurVisible = _useIsFocusVisible.onBlurVisible,
  12966. focusVisibleRef = _useIsFocusVisible.ref;
  12967.  
  12968. var _React$useState3 = React__namespace.useState(-1),
  12969. focusVisible = _React$useState3[0],
  12970. setFocusVisible = _React$useState3[1];
  12971.  
  12972. var sliderRef = React__namespace.useRef();
  12973. var handleFocusRef = useForkRef(focusVisibleRef, sliderRef);
  12974. var handleRef = useForkRef(ref, handleFocusRef);
  12975. var handleFocus = useEventCallback(function (event) {
  12976. var index = Number(event.currentTarget.getAttribute('data-index'));
  12977.  
  12978. if (isFocusVisible(event)) {
  12979. setFocusVisible(index);
  12980. }
  12981.  
  12982. setOpen(index);
  12983. });
  12984. var handleBlur = useEventCallback(function () {
  12985. if (focusVisible !== -1) {
  12986. setFocusVisible(-1);
  12987. onBlurVisible();
  12988. }
  12989.  
  12990. setOpen(-1);
  12991. });
  12992. var handleMouseOver = useEventCallback(function (event) {
  12993. var index = Number(event.currentTarget.getAttribute('data-index'));
  12994. setOpen(index);
  12995. });
  12996. var handleMouseLeave = useEventCallback(function () {
  12997. setOpen(-1);
  12998. });
  12999. var isRtl = theme.direction === 'rtl';
  13000. var handleKeyDown = useEventCallback(function (event) {
  13001. var index = Number(event.currentTarget.getAttribute('data-index'));
  13002. var value = values[index];
  13003. var tenPercents = (max - min) / 10;
  13004. var marksValues = marks.map(function (mark) {
  13005. return mark.value;
  13006. });
  13007. var marksIndex = marksValues.indexOf(value);
  13008. var newValue;
  13009. var increaseKey = isRtl ? 'ArrowLeft' : 'ArrowRight';
  13010. var decreaseKey = isRtl ? 'ArrowRight' : 'ArrowLeft';
  13011.  
  13012. switch (event.key) {
  13013. case 'Home':
  13014. newValue = min;
  13015. break;
  13016.  
  13017. case 'End':
  13018. newValue = max;
  13019. break;
  13020.  
  13021. case 'PageUp':
  13022. if (step) {
  13023. newValue = value + tenPercents;
  13024. }
  13025.  
  13026. break;
  13027.  
  13028. case 'PageDown':
  13029. if (step) {
  13030. newValue = value - tenPercents;
  13031. }
  13032.  
  13033. break;
  13034.  
  13035. case increaseKey:
  13036. case 'ArrowUp':
  13037. if (step) {
  13038. newValue = value + step;
  13039. } else {
  13040. newValue = marksValues[marksIndex + 1] || marksValues[marksValues.length - 1];
  13041. }
  13042.  
  13043. break;
  13044.  
  13045. case decreaseKey:
  13046. case 'ArrowDown':
  13047. if (step) {
  13048. newValue = value - step;
  13049. } else {
  13050. newValue = marksValues[marksIndex - 1] || marksValues[0];
  13051. }
  13052.  
  13053. break;
  13054.  
  13055. default:
  13056. return;
  13057. } // Prevent scroll of the page
  13058.  
  13059.  
  13060. event.preventDefault();
  13061.  
  13062. if (step) {
  13063. newValue = roundValueToStep(newValue, step, min);
  13064. }
  13065.  
  13066. newValue = clamp(newValue, min, max);
  13067.  
  13068. if (range) {
  13069. var previousValue = newValue;
  13070. newValue = setValueIndex({
  13071. values: values,
  13072. source: valueDerived,
  13073. newValue: newValue,
  13074. index: index
  13075. }).sort(asc);
  13076. focusThumb({
  13077. sliderRef: sliderRef,
  13078. activeIndex: newValue.indexOf(previousValue)
  13079. });
  13080. }
  13081.  
  13082. setValueState(newValue);
  13083. setFocusVisible(index);
  13084.  
  13085. if (onChange) {
  13086. onChange(event, newValue);
  13087. }
  13088.  
  13089. if (onChangeCommitted) {
  13090. onChangeCommitted(event, newValue);
  13091. }
  13092. });
  13093. var previousIndex = React__namespace.useRef();
  13094. var axis = orientation;
  13095.  
  13096. if (isRtl && orientation !== "vertical") {
  13097. axis += '-reverse';
  13098. }
  13099.  
  13100. var getFingerNewValue = function getFingerNewValue(_ref3) {
  13101. var finger = _ref3.finger,
  13102. _ref3$move = _ref3.move,
  13103. move = _ref3$move === void 0 ? false : _ref3$move,
  13104. values2 = _ref3.values,
  13105. source = _ref3.source;
  13106. var slider = sliderRef.current;
  13107.  
  13108. var _slider$getBoundingCl = slider.getBoundingClientRect(),
  13109. width = _slider$getBoundingCl.width,
  13110. height = _slider$getBoundingCl.height,
  13111. bottom = _slider$getBoundingCl.bottom,
  13112. left = _slider$getBoundingCl.left;
  13113.  
  13114. var percent;
  13115.  
  13116. if (axis.indexOf('vertical') === 0) {
  13117. percent = (bottom - finger.y) / height;
  13118. } else {
  13119. percent = (finger.x - left) / width;
  13120. }
  13121.  
  13122. if (axis.indexOf('-reverse') !== -1) {
  13123. percent = 1 - percent;
  13124. }
  13125.  
  13126. var newValue;
  13127. newValue = percentToValue(percent, min, max);
  13128.  
  13129. if (step) {
  13130. newValue = roundValueToStep(newValue, step, min);
  13131. } else {
  13132. var marksValues = marks.map(function (mark) {
  13133. return mark.value;
  13134. });
  13135. var closestIndex = findClosest(marksValues, newValue);
  13136. newValue = marksValues[closestIndex];
  13137. }
  13138.  
  13139. newValue = clamp(newValue, min, max);
  13140. var activeIndex = 0;
  13141.  
  13142. if (range) {
  13143. if (!move) {
  13144. activeIndex = findClosest(values2, newValue);
  13145. } else {
  13146. activeIndex = previousIndex.current;
  13147. }
  13148.  
  13149. var previousValue = newValue;
  13150. newValue = setValueIndex({
  13151. values: values2,
  13152. source: source,
  13153. newValue: newValue,
  13154. index: activeIndex
  13155. }).sort(asc);
  13156. activeIndex = newValue.indexOf(previousValue);
  13157. previousIndex.current = activeIndex;
  13158. }
  13159.  
  13160. return {
  13161. newValue: newValue,
  13162. activeIndex: activeIndex
  13163. };
  13164. };
  13165.  
  13166. var handleTouchMove = useEventCallback(function (event) {
  13167. var finger = trackFinger(event, touchId);
  13168.  
  13169. if (!finger) {
  13170. return;
  13171. }
  13172.  
  13173. var _getFingerNewValue = getFingerNewValue({
  13174. finger: finger,
  13175. move: true,
  13176. values: values,
  13177. source: valueDerived
  13178. }),
  13179. newValue = _getFingerNewValue.newValue,
  13180. activeIndex = _getFingerNewValue.activeIndex;
  13181.  
  13182. focusThumb({
  13183. sliderRef: sliderRef,
  13184. activeIndex: activeIndex,
  13185. setActive: setActive
  13186. });
  13187. setValueState(newValue);
  13188.  
  13189. if (onChange) {
  13190. onChange(event, newValue);
  13191. }
  13192. });
  13193. var handleTouchEnd = useEventCallback(function (event) {
  13194. var finger = trackFinger(event, touchId);
  13195.  
  13196. if (!finger) {
  13197. return;
  13198. }
  13199.  
  13200. var _getFingerNewValue2 = getFingerNewValue({
  13201. finger: finger,
  13202. values: values,
  13203. source: valueDerived
  13204. }),
  13205. newValue = _getFingerNewValue2.newValue;
  13206.  
  13207. setActive(-1);
  13208.  
  13209. if (event.type === 'touchend') {
  13210. setOpen(-1);
  13211. }
  13212.  
  13213. if (onChangeCommitted) {
  13214. onChangeCommitted(event, newValue);
  13215. }
  13216.  
  13217. touchId.current = undefined;
  13218. var doc = ownerDocument(sliderRef.current);
  13219. doc.removeEventListener('mousemove', handleTouchMove);
  13220. doc.removeEventListener('mouseup', handleTouchEnd);
  13221. doc.removeEventListener('touchmove', handleTouchMove);
  13222. doc.removeEventListener('touchend', handleTouchEnd);
  13223. });
  13224. var handleTouchStart = useEventCallback(function (event) {
  13225. // Workaround as Safari has partial support for touchAction: 'none'.
  13226. event.preventDefault();
  13227. var touch = event.changedTouches[0];
  13228.  
  13229. if (touch != null) {
  13230. // A number that uniquely identifies the current finger in the touch session.
  13231. touchId.current = touch.identifier;
  13232. }
  13233.  
  13234. var finger = trackFinger(event, touchId);
  13235.  
  13236. var _getFingerNewValue3 = getFingerNewValue({
  13237. finger: finger,
  13238. values: values,
  13239. source: valueDerived
  13240. }),
  13241. newValue = _getFingerNewValue3.newValue,
  13242. activeIndex = _getFingerNewValue3.activeIndex;
  13243.  
  13244. focusThumb({
  13245. sliderRef: sliderRef,
  13246. activeIndex: activeIndex,
  13247. setActive: setActive
  13248. });
  13249. setValueState(newValue);
  13250.  
  13251. if (onChange) {
  13252. onChange(event, newValue);
  13253. }
  13254.  
  13255. var doc = ownerDocument(sliderRef.current);
  13256. doc.addEventListener('touchmove', handleTouchMove);
  13257. doc.addEventListener('touchend', handleTouchEnd);
  13258. });
  13259. React__namespace.useEffect(function () {
  13260. var slider = sliderRef.current;
  13261. slider.addEventListener('touchstart', handleTouchStart);
  13262. var doc = ownerDocument(slider);
  13263. return function () {
  13264. slider.removeEventListener('touchstart', handleTouchStart);
  13265. doc.removeEventListener('mousemove', handleTouchMove);
  13266. doc.removeEventListener('mouseup', handleTouchEnd);
  13267. doc.removeEventListener('touchmove', handleTouchMove);
  13268. doc.removeEventListener('touchend', handleTouchEnd);
  13269. };
  13270. }, [handleTouchEnd, handleTouchMove, handleTouchStart]);
  13271. var handleMouseDown = useEventCallback(function (event) {
  13272. if (onMouseDown) {
  13273. onMouseDown(event);
  13274. }
  13275.  
  13276. event.preventDefault();
  13277. var finger = trackFinger(event, touchId);
  13278.  
  13279. var _getFingerNewValue4 = getFingerNewValue({
  13280. finger: finger,
  13281. values: values,
  13282. source: valueDerived
  13283. }),
  13284. newValue = _getFingerNewValue4.newValue,
  13285. activeIndex = _getFingerNewValue4.activeIndex;
  13286.  
  13287. focusThumb({
  13288. sliderRef: sliderRef,
  13289. activeIndex: activeIndex,
  13290. setActive: setActive
  13291. });
  13292. setValueState(newValue);
  13293.  
  13294. if (onChange) {
  13295. onChange(event, newValue);
  13296. }
  13297.  
  13298. var doc = ownerDocument(sliderRef.current);
  13299. doc.addEventListener('mousemove', handleTouchMove);
  13300. doc.addEventListener('mouseup', handleTouchEnd);
  13301. });
  13302. var trackOffset = valueToPercent(range ? values[0] : min, min, max);
  13303. var trackLeap = valueToPercent(values[values.length - 1], min, max) - trackOffset;
  13304.  
  13305. var trackStyle = _extends$1({}, axisProps[axis].offset(trackOffset), axisProps[axis].leap(trackLeap));
  13306.  
  13307. return /*#__PURE__*/React__namespace.createElement(Component, _extends$1({
  13308. ref: handleRef,
  13309. className: clsx(classes.root, classes["color".concat(capitalize(color))], className, disabled && classes.disabled, marks.length > 0 && marks.some(function (mark) {
  13310. return mark.label;
  13311. }) && classes.marked, track === false && classes.trackFalse, orientation === 'vertical' && classes.vertical, track === 'inverted' && classes.trackInverted),
  13312. onMouseDown: handleMouseDown
  13313. }, other), /*#__PURE__*/React__namespace.createElement("span", {
  13314. className: classes.rail
  13315. }), /*#__PURE__*/React__namespace.createElement("span", {
  13316. className: classes.track,
  13317. style: trackStyle
  13318. }), /*#__PURE__*/React__namespace.createElement("input", {
  13319. value: values.join(','),
  13320. name: name,
  13321. type: "hidden"
  13322. }), marks.map(function (mark, index) {
  13323. var percent = valueToPercent(mark.value, min, max);
  13324. var style = axisProps[axis].offset(percent);
  13325. var markActive;
  13326.  
  13327. if (track === false) {
  13328. markActive = values.indexOf(mark.value) !== -1;
  13329. } else {
  13330. markActive = track === 'normal' && (range ? mark.value >= values[0] && mark.value <= values[values.length - 1] : mark.value <= values[0]) || track === 'inverted' && (range ? mark.value <= values[0] || mark.value >= values[values.length - 1] : mark.value >= values[0]);
  13331. }
  13332.  
  13333. return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, {
  13334. key: mark.value
  13335. }, /*#__PURE__*/React__namespace.createElement("span", {
  13336. style: style,
  13337. "data-index": index,
  13338. className: clsx(classes.mark, markActive && classes.markActive)
  13339. }), mark.label != null ? /*#__PURE__*/React__namespace.createElement("span", {
  13340. "aria-hidden": true,
  13341. "data-index": index,
  13342. style: style,
  13343. className: clsx(classes.markLabel, markActive && classes.markLabelActive)
  13344. }, mark.label) : null);
  13345. }), values.map(function (value, index) {
  13346. var percent = valueToPercent(value, min, max);
  13347. var style = axisProps[axis].offset(percent);
  13348. return /*#__PURE__*/React__namespace.createElement(ValueLabelComponent, {
  13349. key: index,
  13350. valueLabelFormat: valueLabelFormat,
  13351. valueLabelDisplay: valueLabelDisplay,
  13352. className: classes.valueLabel,
  13353. value: typeof valueLabelFormat === 'function' ? valueLabelFormat(scale(value), index) : valueLabelFormat,
  13354. index: index,
  13355. open: open === index || active === index || valueLabelDisplay === 'on',
  13356. disabled: disabled
  13357. }, /*#__PURE__*/React__namespace.createElement(ThumbComponent, {
  13358. className: clsx(classes.thumb, classes["thumbColor".concat(capitalize(color))], active === index && classes.active, disabled && classes.disabled, focusVisible === index && classes.focusVisible),
  13359. tabIndex: disabled ? null : 0,
  13360. role: "slider",
  13361. style: style,
  13362. "data-index": index,
  13363. "aria-label": getAriaLabel ? getAriaLabel(index) : ariaLabel,
  13364. "aria-labelledby": ariaLabelledby,
  13365. "aria-orientation": orientation,
  13366. "aria-valuemax": scale(max),
  13367. "aria-valuemin": scale(min),
  13368. "aria-valuenow": scale(value),
  13369. "aria-valuetext": getAriaValueText ? getAriaValueText(scale(value), index) : ariaValuetext,
  13370. onKeyDown: handleKeyDown,
  13371. onFocus: handleFocus,
  13372. onBlur: handleBlur,
  13373. onMouseOver: handleMouseOver,
  13374. onMouseLeave: handleMouseLeave
  13375. }));
  13376. }));
  13377. });
  13378. var Slider$1 = withStyles(styles$2, {
  13379. name: 'MuiSlider'
  13380. })(Slider);
  13381.  
  13382. var styles$1 = function styles(theme) {
  13383. return {
  13384. /* Styles applied to the root element. */
  13385. root: {
  13386. display: 'inline-flex',
  13387. width: 34 + 12 * 2,
  13388. height: 14 + 12 * 2,
  13389. overflow: 'hidden',
  13390. padding: 12,
  13391. boxSizing: 'border-box',
  13392. position: 'relative',
  13393. flexShrink: 0,
  13394. zIndex: 0,
  13395. // Reset the stacking context.
  13396. verticalAlign: 'middle',
  13397. // For correct alignment with the text.
  13398. '@media print': {
  13399. colorAdjust: 'exact'
  13400. }
  13401. },
  13402.  
  13403. /* Styles applied to the root element if `edge="start"`. */
  13404. edgeStart: {
  13405. marginLeft: -8
  13406. },
  13407.  
  13408. /* Styles applied to the root element if `edge="end"`. */
  13409. edgeEnd: {
  13410. marginRight: -8
  13411. },
  13412.  
  13413. /* Styles applied to the internal `SwitchBase` component's `root` class. */
  13414. switchBase: {
  13415. position: 'absolute',
  13416. top: 0,
  13417. left: 0,
  13418. zIndex: 1,
  13419. // Render above the focus ripple.
  13420. color: theme.palette.type === 'light' ? theme.palette.grey[50] : theme.palette.grey[400],
  13421. transition: theme.transitions.create(['left', 'transform'], {
  13422. duration: theme.transitions.duration.shortest
  13423. }),
  13424. '&$checked': {
  13425. transform: 'translateX(20px)'
  13426. },
  13427. '&$disabled': {
  13428. color: theme.palette.type === 'light' ? theme.palette.grey[400] : theme.palette.grey[800]
  13429. },
  13430. '&$checked + $track': {
  13431. opacity: 0.5
  13432. },
  13433. '&$disabled + $track': {
  13434. opacity: theme.palette.type === 'light' ? 0.12 : 0.1
  13435. }
  13436. },
  13437.  
  13438. /* Styles applied to the internal SwitchBase component's root element if `color="primary"`. */
  13439. colorPrimary: {
  13440. '&$checked': {
  13441. color: theme.palette.primary.main,
  13442. '&:hover': {
  13443. backgroundColor: fade(theme.palette.primary.main, theme.palette.action.hoverOpacity),
  13444. '@media (hover: none)': {
  13445. backgroundColor: 'transparent'
  13446. }
  13447. }
  13448. },
  13449. '&$disabled': {
  13450. color: theme.palette.type === 'light' ? theme.palette.grey[400] : theme.palette.grey[800]
  13451. },
  13452. '&$checked + $track': {
  13453. backgroundColor: theme.palette.primary.main
  13454. },
  13455. '&$disabled + $track': {
  13456. backgroundColor: theme.palette.type === 'light' ? theme.palette.common.black : theme.palette.common.white
  13457. }
  13458. },
  13459.  
  13460. /* Styles applied to the internal SwitchBase component's root element if `color="secondary"`. */
  13461. colorSecondary: {
  13462. '&$checked': {
  13463. color: theme.palette.secondary.main,
  13464. '&:hover': {
  13465. backgroundColor: fade(theme.palette.secondary.main, theme.palette.action.hoverOpacity),
  13466. '@media (hover: none)': {
  13467. backgroundColor: 'transparent'
  13468. }
  13469. }
  13470. },
  13471. '&$disabled': {
  13472. color: theme.palette.type === 'light' ? theme.palette.grey[400] : theme.palette.grey[800]
  13473. },
  13474. '&$checked + $track': {
  13475. backgroundColor: theme.palette.secondary.main
  13476. },
  13477. '&$disabled + $track': {
  13478. backgroundColor: theme.palette.type === 'light' ? theme.palette.common.black : theme.palette.common.white
  13479. }
  13480. },
  13481.  
  13482. /* Styles applied to the root element if `size="small"`. */
  13483. sizeSmall: {
  13484. width: 40,
  13485. height: 24,
  13486. padding: 7,
  13487. '& $thumb': {
  13488. width: 16,
  13489. height: 16
  13490. },
  13491. '& $switchBase': {
  13492. padding: 4,
  13493. '&$checked': {
  13494. transform: 'translateX(16px)'
  13495. }
  13496. }
  13497. },
  13498.  
  13499. /* Pseudo-class applied to the internal `SwitchBase` component's `checked` class. */
  13500. checked: {},
  13501.  
  13502. /* Pseudo-class applied to the internal SwitchBase component's disabled class. */
  13503. disabled: {},
  13504.  
  13505. /* Styles applied to the internal SwitchBase component's input element. */
  13506. input: {
  13507. left: '-100%',
  13508. width: '300%'
  13509. },
  13510.  
  13511. /* Styles used to create the thumb passed to the internal `SwitchBase` component `icon` prop. */
  13512. thumb: {
  13513. boxShadow: theme.shadows[1],
  13514. backgroundColor: 'currentColor',
  13515. width: 20,
  13516. height: 20,
  13517. borderRadius: '50%'
  13518. },
  13519.  
  13520. /* Styles applied to the track element. */
  13521. track: {
  13522. height: '100%',
  13523. width: '100%',
  13524. borderRadius: 14 / 2,
  13525. zIndex: -1,
  13526. transition: theme.transitions.create(['opacity', 'background-color'], {
  13527. duration: theme.transitions.duration.shortest
  13528. }),
  13529. backgroundColor: theme.palette.type === 'light' ? theme.palette.common.black : theme.palette.common.white,
  13530. opacity: theme.palette.type === 'light' ? 0.38 : 0.3
  13531. }
  13532. };
  13533. };
  13534. var Switch = /*#__PURE__*/React__namespace.forwardRef(function Switch(props, ref) {
  13535. var classes = props.classes,
  13536. className = props.className,
  13537. _props$color = props.color,
  13538. color = _props$color === void 0 ? 'secondary' : _props$color,
  13539. _props$edge = props.edge,
  13540. edge = _props$edge === void 0 ? false : _props$edge,
  13541. _props$size = props.size,
  13542. size = _props$size === void 0 ? 'medium' : _props$size,
  13543. other = _objectWithoutProperties(props, ["classes", "className", "color", "edge", "size"]);
  13544.  
  13545. var icon = /*#__PURE__*/React__namespace.createElement("span", {
  13546. className: classes.thumb
  13547. });
  13548. return /*#__PURE__*/React__namespace.createElement("span", {
  13549. className: clsx(classes.root, className, {
  13550. 'start': classes.edgeStart,
  13551. 'end': classes.edgeEnd
  13552. }[edge], size === "small" && classes["size".concat(capitalize(size))])
  13553. }, /*#__PURE__*/React__namespace.createElement(SwitchBase$1, _extends$1({
  13554. type: "checkbox",
  13555. icon: icon,
  13556. checkedIcon: icon,
  13557. classes: {
  13558. root: clsx(classes.switchBase, classes["color".concat(capitalize(color))]),
  13559. input: classes.input,
  13560. checked: classes.checked,
  13561. disabled: classes.disabled
  13562. },
  13563. ref: ref
  13564. }, other)), /*#__PURE__*/React__namespace.createElement("span", {
  13565. className: classes.track
  13566. }));
  13567. });
  13568. var Switch$1 = withStyles(styles$1, {
  13569. name: 'MuiSwitch'
  13570. })(Switch);
  13571.  
  13572. function round(value) {
  13573. return Math.round(value * 1e5) / 1e5;
  13574. }
  13575.  
  13576. function arrowGenerator() {
  13577. return {
  13578. '&[x-placement*="bottom"] $arrow': {
  13579. top: 0,
  13580. left: 0,
  13581. marginTop: '-0.71em',
  13582. marginLeft: 4,
  13583. marginRight: 4,
  13584. '&::before': {
  13585. transformOrigin: '0 100%'
  13586. }
  13587. },
  13588. '&[x-placement*="top"] $arrow': {
  13589. bottom: 0,
  13590. left: 0,
  13591. marginBottom: '-0.71em',
  13592. marginLeft: 4,
  13593. marginRight: 4,
  13594. '&::before': {
  13595. transformOrigin: '100% 0'
  13596. }
  13597. },
  13598. '&[x-placement*="right"] $arrow': {
  13599. left: 0,
  13600. marginLeft: '-0.71em',
  13601. height: '1em',
  13602. width: '0.71em',
  13603. marginTop: 4,
  13604. marginBottom: 4,
  13605. '&::before': {
  13606. transformOrigin: '100% 100%'
  13607. }
  13608. },
  13609. '&[x-placement*="left"] $arrow': {
  13610. right: 0,
  13611. marginRight: '-0.71em',
  13612. height: '1em',
  13613. width: '0.71em',
  13614. marginTop: 4,
  13615. marginBottom: 4,
  13616. '&::before': {
  13617. transformOrigin: '0 0'
  13618. }
  13619. }
  13620. };
  13621. }
  13622.  
  13623. var styles = function styles(theme) {
  13624. return {
  13625. /* Styles applied to the Popper component. */
  13626. popper: {
  13627. zIndex: theme.zIndex.tooltip,
  13628. pointerEvents: 'none' // disable jss-rtl plugin
  13629.  
  13630. },
  13631.  
  13632. /* Styles applied to the Popper component if `interactive={true}`. */
  13633. popperInteractive: {
  13634. pointerEvents: 'auto'
  13635. },
  13636.  
  13637. /* Styles applied to the Popper component if `arrow={true}`. */
  13638. popperArrow: arrowGenerator(),
  13639.  
  13640. /* Styles applied to the tooltip (label wrapper) element. */
  13641. tooltip: {
  13642. backgroundColor: fade(theme.palette.grey[700], 0.9),
  13643. borderRadius: theme.shape.borderRadius,
  13644. color: theme.palette.common.white,
  13645. fontFamily: theme.typography.fontFamily,
  13646. padding: '4px 8px',
  13647. fontSize: theme.typography.pxToRem(10),
  13648. lineHeight: "".concat(round(14 / 10), "em"),
  13649. maxWidth: 300,
  13650. wordWrap: 'break-word',
  13651. fontWeight: theme.typography.fontWeightMedium
  13652. },
  13653.  
  13654. /* Styles applied to the tooltip (label wrapper) element if `arrow={true}`. */
  13655. tooltipArrow: {
  13656. position: 'relative',
  13657. margin: '0'
  13658. },
  13659.  
  13660. /* Styles applied to the arrow element. */
  13661. arrow: {
  13662. overflow: 'hidden',
  13663. position: 'absolute',
  13664. width: '1em',
  13665. height: '0.71em'
  13666. /* = width / sqrt(2) = (length of the hypotenuse) */
  13667. ,
  13668. boxSizing: 'border-box',
  13669. color: fade(theme.palette.grey[700], 0.9),
  13670. '&::before': {
  13671. content: '""',
  13672. margin: 'auto',
  13673. display: 'block',
  13674. width: '100%',
  13675. height: '100%',
  13676. backgroundColor: 'currentColor',
  13677. transform: 'rotate(45deg)'
  13678. }
  13679. },
  13680.  
  13681. /* Styles applied to the tooltip (label wrapper) element if the tooltip is opened by touch. */
  13682. touch: {
  13683. padding: '8px 16px',
  13684. fontSize: theme.typography.pxToRem(14),
  13685. lineHeight: "".concat(round(16 / 14), "em"),
  13686. fontWeight: theme.typography.fontWeightRegular
  13687. },
  13688.  
  13689. /* Styles applied to the tooltip (label wrapper) element if `placement` contains "left". */
  13690. tooltipPlacementLeft: _defineProperty$1({
  13691. transformOrigin: 'right center',
  13692. margin: '0 24px '
  13693. }, theme.breakpoints.up('sm'), {
  13694. margin: '0 14px'
  13695. }),
  13696.  
  13697. /* Styles applied to the tooltip (label wrapper) element if `placement` contains "right". */
  13698. tooltipPlacementRight: _defineProperty$1({
  13699. transformOrigin: 'left center',
  13700. margin: '0 24px'
  13701. }, theme.breakpoints.up('sm'), {
  13702. margin: '0 14px'
  13703. }),
  13704.  
  13705. /* Styles applied to the tooltip (label wrapper) element if `placement` contains "top". */
  13706. tooltipPlacementTop: _defineProperty$1({
  13707. transformOrigin: 'center bottom',
  13708. margin: '24px 0'
  13709. }, theme.breakpoints.up('sm'), {
  13710. margin: '14px 0'
  13711. }),
  13712.  
  13713. /* Styles applied to the tooltip (label wrapper) element if `placement` contains "bottom". */
  13714. tooltipPlacementBottom: _defineProperty$1({
  13715. transformOrigin: 'center top',
  13716. margin: '24px 0'
  13717. }, theme.breakpoints.up('sm'), {
  13718. margin: '14px 0'
  13719. })
  13720. };
  13721. };
  13722. var hystersisOpen = false;
  13723. var hystersisTimer = null;
  13724. var Tooltip = /*#__PURE__*/React__namespace.forwardRef(function Tooltip(props, ref) {
  13725. var _props$arrow = props.arrow,
  13726. arrow = _props$arrow === void 0 ? false : _props$arrow,
  13727. children = props.children,
  13728. classes = props.classes,
  13729. _props$disableFocusLi = props.disableFocusListener,
  13730. disableFocusListener = _props$disableFocusLi === void 0 ? false : _props$disableFocusLi,
  13731. _props$disableHoverLi = props.disableHoverListener,
  13732. disableHoverListener = _props$disableHoverLi === void 0 ? false : _props$disableHoverLi,
  13733. _props$disableTouchLi = props.disableTouchListener,
  13734. disableTouchListener = _props$disableTouchLi === void 0 ? false : _props$disableTouchLi,
  13735. _props$enterDelay = props.enterDelay,
  13736. enterDelay = _props$enterDelay === void 0 ? 100 : _props$enterDelay,
  13737. _props$enterNextDelay = props.enterNextDelay,
  13738. enterNextDelay = _props$enterNextDelay === void 0 ? 0 : _props$enterNextDelay,
  13739. _props$enterTouchDela = props.enterTouchDelay,
  13740. enterTouchDelay = _props$enterTouchDela === void 0 ? 700 : _props$enterTouchDela,
  13741. idProp = props.id,
  13742. _props$interactive = props.interactive,
  13743. interactive = _props$interactive === void 0 ? false : _props$interactive,
  13744. _props$leaveDelay = props.leaveDelay,
  13745. leaveDelay = _props$leaveDelay === void 0 ? 0 : _props$leaveDelay,
  13746. _props$leaveTouchDela = props.leaveTouchDelay,
  13747. leaveTouchDelay = _props$leaveTouchDela === void 0 ? 1500 : _props$leaveTouchDela,
  13748. onClose = props.onClose,
  13749. onOpen = props.onOpen,
  13750. openProp = props.open,
  13751. _props$placement = props.placement,
  13752. placement = _props$placement === void 0 ? 'bottom' : _props$placement,
  13753. _props$PopperComponen = props.PopperComponent,
  13754. PopperComponent = _props$PopperComponen === void 0 ? Popper : _props$PopperComponen,
  13755. PopperProps = props.PopperProps,
  13756. title = props.title,
  13757. _props$TransitionComp = props.TransitionComponent,
  13758. TransitionComponent = _props$TransitionComp === void 0 ? Grow : _props$TransitionComp,
  13759. TransitionProps = props.TransitionProps,
  13760. other = _objectWithoutProperties(props, ["arrow", "children", "classes", "disableFocusListener", "disableHoverListener", "disableTouchListener", "enterDelay", "enterNextDelay", "enterTouchDelay", "id", "interactive", "leaveDelay", "leaveTouchDelay", "onClose", "onOpen", "open", "placement", "PopperComponent", "PopperProps", "title", "TransitionComponent", "TransitionProps"]);
  13761.  
  13762. var theme = useTheme();
  13763.  
  13764. var _React$useState = React__namespace.useState(),
  13765. childNode = _React$useState[0],
  13766. setChildNode = _React$useState[1];
  13767.  
  13768. var _React$useState2 = React__namespace.useState(null),
  13769. arrowRef = _React$useState2[0],
  13770. setArrowRef = _React$useState2[1];
  13771.  
  13772. var ignoreNonTouchEvents = React__namespace.useRef(false);
  13773. var closeTimer = React__namespace.useRef();
  13774. var enterTimer = React__namespace.useRef();
  13775. var leaveTimer = React__namespace.useRef();
  13776. var touchTimer = React__namespace.useRef();
  13777.  
  13778. var _useControlled = useControlled({
  13779. controlled: openProp,
  13780. default: false,
  13781. name: 'Tooltip',
  13782. state: 'open'
  13783. }),
  13784. _useControlled2 = _slicedToArray(_useControlled, 2),
  13785. openState = _useControlled2[0],
  13786. setOpenState = _useControlled2[1];
  13787.  
  13788. var open = openState;
  13789.  
  13790. var id = useId(idProp);
  13791. React__namespace.useEffect(function () {
  13792. return function () {
  13793. clearTimeout(closeTimer.current);
  13794. clearTimeout(enterTimer.current);
  13795. clearTimeout(leaveTimer.current);
  13796. clearTimeout(touchTimer.current);
  13797. };
  13798. }, []);
  13799.  
  13800. var handleOpen = function handleOpen(event) {
  13801. clearTimeout(hystersisTimer);
  13802. hystersisOpen = true; // The mouseover event will trigger for every nested element in the tooltip.
  13803. // We can skip rerendering when the tooltip is already open.
  13804. // We are using the mouseover event instead of the mouseenter event to fix a hide/show issue.
  13805.  
  13806. setOpenState(true);
  13807.  
  13808. if (onOpen) {
  13809. onOpen(event);
  13810. }
  13811. };
  13812.  
  13813. var handleEnter = function handleEnter() {
  13814. var forward = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  13815. return function (event) {
  13816. var childrenProps = children.props;
  13817.  
  13818. if (event.type === 'mouseover' && childrenProps.onMouseOver && forward) {
  13819. childrenProps.onMouseOver(event);
  13820. }
  13821.  
  13822. if (ignoreNonTouchEvents.current && event.type !== 'touchstart') {
  13823. return;
  13824. } // Remove the title ahead of time.
  13825. // We don't want to wait for the next render commit.
  13826. // We would risk displaying two tooltips at the same time (native + this one).
  13827.  
  13828.  
  13829. if (childNode) {
  13830. childNode.removeAttribute('title');
  13831. }
  13832.  
  13833. clearTimeout(enterTimer.current);
  13834. clearTimeout(leaveTimer.current);
  13835.  
  13836. if (enterDelay || hystersisOpen && enterNextDelay) {
  13837. event.persist();
  13838. enterTimer.current = setTimeout(function () {
  13839. handleOpen(event);
  13840. }, hystersisOpen ? enterNextDelay : enterDelay);
  13841. } else {
  13842. handleOpen(event);
  13843. }
  13844. };
  13845. };
  13846.  
  13847. var _useIsFocusVisible = useIsFocusVisible(),
  13848. isFocusVisible = _useIsFocusVisible.isFocusVisible,
  13849. onBlurVisible = _useIsFocusVisible.onBlurVisible,
  13850. focusVisibleRef = _useIsFocusVisible.ref;
  13851.  
  13852. var _React$useState3 = React__namespace.useState(false),
  13853. childIsFocusVisible = _React$useState3[0],
  13854. setChildIsFocusVisible = _React$useState3[1];
  13855.  
  13856. var handleBlur = function handleBlur() {
  13857. if (childIsFocusVisible) {
  13858. setChildIsFocusVisible(false);
  13859. onBlurVisible();
  13860. }
  13861. };
  13862.  
  13863. var handleFocus = function handleFocus() {
  13864. var forward = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  13865. return function (event) {
  13866. // Workaround for https://github.com/facebook/react/issues/7769
  13867. // The autoFocus of React might trigger the event before the componentDidMount.
  13868. // We need to account for this eventuality.
  13869. if (!childNode) {
  13870. setChildNode(event.currentTarget);
  13871. }
  13872.  
  13873. if (isFocusVisible(event)) {
  13874. setChildIsFocusVisible(true);
  13875. handleEnter()(event);
  13876. }
  13877.  
  13878. var childrenProps = children.props;
  13879.  
  13880. if (childrenProps.onFocus && forward) {
  13881. childrenProps.onFocus(event);
  13882. }
  13883. };
  13884. };
  13885.  
  13886. var handleClose = function handleClose(event) {
  13887. clearTimeout(hystersisTimer);
  13888. hystersisTimer = setTimeout(function () {
  13889. hystersisOpen = false;
  13890. }, 800 + leaveDelay);
  13891. setOpenState(false);
  13892.  
  13893. if (onClose) {
  13894. onClose(event);
  13895. }
  13896.  
  13897. clearTimeout(closeTimer.current);
  13898. closeTimer.current = setTimeout(function () {
  13899. ignoreNonTouchEvents.current = false;
  13900. }, theme.transitions.duration.shortest);
  13901. };
  13902.  
  13903. var handleLeave = function handleLeave() {
  13904. var forward = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  13905. return function (event) {
  13906. var childrenProps = children.props;
  13907.  
  13908. if (event.type === 'blur') {
  13909. if (childrenProps.onBlur && forward) {
  13910. childrenProps.onBlur(event);
  13911. }
  13912.  
  13913. handleBlur();
  13914. }
  13915.  
  13916. if (event.type === 'mouseleave' && childrenProps.onMouseLeave && event.currentTarget === childNode) {
  13917. childrenProps.onMouseLeave(event);
  13918. }
  13919.  
  13920. clearTimeout(enterTimer.current);
  13921. clearTimeout(leaveTimer.current);
  13922. event.persist();
  13923. leaveTimer.current = setTimeout(function () {
  13924. handleClose(event);
  13925. }, leaveDelay);
  13926. };
  13927. };
  13928.  
  13929. var detectTouchStart = function detectTouchStart(event) {
  13930. ignoreNonTouchEvents.current = true;
  13931. var childrenProps = children.props;
  13932.  
  13933. if (childrenProps.onTouchStart) {
  13934. childrenProps.onTouchStart(event);
  13935. }
  13936. };
  13937.  
  13938. var handleTouchStart = function handleTouchStart(event) {
  13939. detectTouchStart(event);
  13940. clearTimeout(leaveTimer.current);
  13941. clearTimeout(closeTimer.current);
  13942. clearTimeout(touchTimer.current);
  13943. event.persist();
  13944. touchTimer.current = setTimeout(function () {
  13945. handleEnter()(event);
  13946. }, enterTouchDelay);
  13947. };
  13948.  
  13949. var handleTouchEnd = function handleTouchEnd(event) {
  13950. if (children.props.onTouchEnd) {
  13951. children.props.onTouchEnd(event);
  13952. }
  13953.  
  13954. clearTimeout(touchTimer.current);
  13955. clearTimeout(leaveTimer.current);
  13956. event.persist();
  13957. leaveTimer.current = setTimeout(function () {
  13958. handleClose(event);
  13959. }, leaveTouchDelay);
  13960. };
  13961.  
  13962. var handleUseRef = useForkRef(setChildNode, ref);
  13963. var handleFocusRef = useForkRef(focusVisibleRef, handleUseRef); // can be removed once we drop support for non ref forwarding class components
  13964.  
  13965. var handleOwnRef = React__namespace.useCallback(function (instance) {
  13966. // #StrictMode ready
  13967. setRef(handleFocusRef, ReactDOM__namespace.findDOMNode(instance));
  13968. }, [handleFocusRef]);
  13969. var handleRef = useForkRef(children.ref, handleOwnRef); // There is no point in displaying an empty tooltip.
  13970.  
  13971. if (title === '') {
  13972. open = false;
  13973. } // For accessibility and SEO concerns, we render the title to the DOM node when
  13974. // the tooltip is hidden. However, we have made a tradeoff when
  13975. // `disableHoverListener` is set. This title logic is disabled.
  13976. // It's allowing us to keep the implementation size minimal.
  13977. // We are open to change the tradeoff.
  13978.  
  13979.  
  13980. var shouldShowNativeTitle = !open && !disableHoverListener;
  13981.  
  13982. var childrenProps = _extends$1({
  13983. 'aria-describedby': open ? id : null,
  13984. title: shouldShowNativeTitle && typeof title === 'string' ? title : null
  13985. }, other, children.props, {
  13986. className: clsx(other.className, children.props.className),
  13987. onTouchStart: detectTouchStart,
  13988. ref: handleRef
  13989. });
  13990.  
  13991. var interactiveWrapperListeners = {};
  13992.  
  13993. if (!disableTouchListener) {
  13994. childrenProps.onTouchStart = handleTouchStart;
  13995. childrenProps.onTouchEnd = handleTouchEnd;
  13996. }
  13997.  
  13998. if (!disableHoverListener) {
  13999. childrenProps.onMouseOver = handleEnter();
  14000. childrenProps.onMouseLeave = handleLeave();
  14001.  
  14002. if (interactive) {
  14003. interactiveWrapperListeners.onMouseOver = handleEnter(false);
  14004. interactiveWrapperListeners.onMouseLeave = handleLeave(false);
  14005. }
  14006. }
  14007.  
  14008. if (!disableFocusListener) {
  14009. childrenProps.onFocus = handleFocus();
  14010. childrenProps.onBlur = handleLeave();
  14011.  
  14012. if (interactive) {
  14013. interactiveWrapperListeners.onFocus = handleFocus(false);
  14014. interactiveWrapperListeners.onBlur = handleLeave(false);
  14015. }
  14016. }
  14017.  
  14018. var mergedPopperProps = React__namespace.useMemo(function () {
  14019. return deepmerge({
  14020. popperOptions: {
  14021. modifiers: {
  14022. arrow: {
  14023. enabled: Boolean(arrowRef),
  14024. element: arrowRef
  14025. }
  14026. }
  14027. }
  14028. }, PopperProps);
  14029. }, [arrowRef, PopperProps]);
  14030. return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.cloneElement(children, childrenProps), /*#__PURE__*/React__namespace.createElement(PopperComponent, _extends$1({
  14031. className: clsx(classes.popper, interactive && classes.popperInteractive, arrow && classes.popperArrow),
  14032. placement: placement,
  14033. anchorEl: childNode,
  14034. open: childNode ? open : false,
  14035. id: childrenProps['aria-describedby'],
  14036. transition: true
  14037. }, interactiveWrapperListeners, mergedPopperProps), function (_ref) {
  14038. var placementInner = _ref.placement,
  14039. TransitionPropsInner = _ref.TransitionProps;
  14040. return /*#__PURE__*/React__namespace.createElement(TransitionComponent, _extends$1({
  14041. timeout: theme.transitions.duration.shorter
  14042. }, TransitionPropsInner, TransitionProps), /*#__PURE__*/React__namespace.createElement("div", {
  14043. className: clsx(classes.tooltip, classes["tooltipPlacement".concat(capitalize(placementInner.split('-')[0]))], ignoreNonTouchEvents.current && classes.touch, arrow && classes.tooltipArrow)
  14044. }, title, arrow ? /*#__PURE__*/React__namespace.createElement("span", {
  14045. className: classes.arrow,
  14046. ref: setArrowRef
  14047. }) : null));
  14048. }));
  14049. });
  14050. var Tooltip$1 = withStyles(styles, {
  14051. name: 'MuiTooltip',
  14052. flip: false
  14053. })(Tooltip);
  14054.  
  14055. /**
  14056. *
  14057. * @export
  14058. * @param {HTMLElement} panel
  14059. */
  14060. function getPanelSize(panel) {
  14061. const clone = panel.cloneNode(true);
  14062. clone.style.opacity = 0;
  14063. clone.style.position = 'absolute';
  14064. clone.removeAttribute('hidden');
  14065. panel.parentNode.appendChild(clone);
  14066. const width = clone.scrollWidth;
  14067. const height = clone.scrollHeight;
  14068. clone.remove();
  14069. return {
  14070. width,
  14071. height
  14072. };
  14073. }
  14074. function getQueryString(name) {
  14075. var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
  14076. var r = location.search.substr(1).match(reg);
  14077. if (r != null) return unescape(decodeURI(r[2]));
  14078. return null;
  14079. }
  14080.  
  14081. var ArrowForwardIos = {};
  14082.  
  14083. var interopRequireDefault = {exports: {}};
  14084.  
  14085. (function (module) {
  14086. function _interopRequireDefault(obj) {
  14087. return obj && obj.__esModule ? obj : {
  14088. "default": obj
  14089. };
  14090. }
  14091.  
  14092. module.exports = _interopRequireDefault;
  14093. module.exports["default"] = module.exports, module.exports.__esModule = true;
  14094. }(interopRequireDefault));
  14095.  
  14096. var interopRequireWildcard = {exports: {}};
  14097.  
  14098. var _typeof = {exports: {}};
  14099.  
  14100. (function (module) {
  14101. function _typeof(obj) {
  14102. "@babel/helpers - typeof";
  14103.  
  14104. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  14105. module.exports = _typeof = function _typeof(obj) {
  14106. return typeof obj;
  14107. };
  14108.  
  14109. module.exports["default"] = module.exports, module.exports.__esModule = true;
  14110. } else {
  14111. module.exports = _typeof = function _typeof(obj) {
  14112. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  14113. };
  14114.  
  14115. module.exports["default"] = module.exports, module.exports.__esModule = true;
  14116. }
  14117.  
  14118. return _typeof(obj);
  14119. }
  14120.  
  14121. module.exports = _typeof;
  14122. module.exports["default"] = module.exports, module.exports.__esModule = true;
  14123. }(_typeof));
  14124.  
  14125. (function (module) {
  14126. var _typeof$1 = _typeof.exports["default"];
  14127.  
  14128. function _getRequireWildcardCache(nodeInterop) {
  14129. if (typeof WeakMap !== "function") return null;
  14130. var cacheBabelInterop = new WeakMap();
  14131. var cacheNodeInterop = new WeakMap();
  14132. return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {
  14133. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  14134. })(nodeInterop);
  14135. }
  14136.  
  14137. function _interopRequireWildcard(obj, nodeInterop) {
  14138. if (!nodeInterop && obj && obj.__esModule) {
  14139. return obj;
  14140. }
  14141.  
  14142. if (obj === null || _typeof$1(obj) !== "object" && typeof obj !== "function") {
  14143. return {
  14144. "default": obj
  14145. };
  14146. }
  14147.  
  14148. var cache = _getRequireWildcardCache(nodeInterop);
  14149.  
  14150. if (cache && cache.has(obj)) {
  14151. return cache.get(obj);
  14152. }
  14153.  
  14154. var newObj = {};
  14155. var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
  14156.  
  14157. for (var key in obj) {
  14158. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  14159. var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
  14160.  
  14161. if (desc && (desc.get || desc.set)) {
  14162. Object.defineProperty(newObj, key, desc);
  14163. } else {
  14164. newObj[key] = obj[key];
  14165. }
  14166. }
  14167. }
  14168.  
  14169. newObj["default"] = obj;
  14170.  
  14171. if (cache) {
  14172. cache.set(obj, newObj);
  14173. }
  14174.  
  14175. return newObj;
  14176. }
  14177.  
  14178. module.exports = _interopRequireWildcard;
  14179. module.exports["default"] = module.exports, module.exports.__esModule = true;
  14180. }(interopRequireWildcard));
  14181.  
  14182. var createSvgIcon = {};
  14183.  
  14184. var require$$0 = /*@__PURE__*/getAugmentedNamespace(utils);
  14185.  
  14186. (function (exports) {
  14187.  
  14188. Object.defineProperty(exports, "__esModule", {
  14189. value: true
  14190. });
  14191. Object.defineProperty(exports, "default", {
  14192. enumerable: true,
  14193. get: function get() {
  14194. return _utils.createSvgIcon;
  14195. }
  14196. });
  14197.  
  14198. var _utils = require$$0;
  14199. }(createSvgIcon));
  14200.  
  14201. var _interopRequireDefault$2 = interopRequireDefault.exports;
  14202.  
  14203. var _interopRequireWildcard$2 = interopRequireWildcard.exports;
  14204.  
  14205. Object.defineProperty(ArrowForwardIos, "__esModule", {
  14206. value: true
  14207. });
  14208. var default_1$2 = ArrowForwardIos.default = void 0;
  14209.  
  14210. var React$2 = _interopRequireWildcard$2(React__default['default']);
  14211.  
  14212. var _createSvgIcon$2 = _interopRequireDefault$2(createSvgIcon);
  14213.  
  14214. var _default$2 = (0, _createSvgIcon$2.default)( /*#__PURE__*/React$2.createElement("path", {
  14215. d: "M5.88 4.12L13.76 12l-7.88 7.88L8 22l10-10L8 2z"
  14216. }), 'ArrowForwardIos');
  14217.  
  14218. default_1$2 = ArrowForwardIos.default = _default$2;
  14219.  
  14220. function _defineProperty(obj, key, value) {
  14221. if (key in obj) {
  14222. Object.defineProperty(obj, key, {
  14223. value: value,
  14224. enumerable: true,
  14225. configurable: true,
  14226. writable: true
  14227. });
  14228. } else {
  14229. obj[key] = value;
  14230. }
  14231.  
  14232. return obj;
  14233. }
  14234.  
  14235. let sendDanmakuLock = false;
  14236. let playing = false;
  14237. let prevID = [];
  14238. /** @type {Danmaku} */
  14239.  
  14240. let core;
  14241. /**
  14242. * @type {MutationObserver}
  14243. */
  14244.  
  14245. let videoObserver;
  14246. /**
  14247. * @type {MutationObserver}
  14248. */
  14249.  
  14250. let bodyObserver;
  14251.  
  14252. class DanmakuOptions {
  14253. constructor() {
  14254. _defineProperty(this, "use", true);
  14255.  
  14256. _defineProperty(this, "opacity", 0.7);
  14257.  
  14258. _defineProperty(this, "showSuperChat", false);
  14259.  
  14260. _defineProperty(this, "showStickers", true);
  14261.  
  14262. _defineProperty(this, "scale", 0.5);
  14263.  
  14264. _defineProperty(this, "fontSize", 24);
  14265.  
  14266. _defineProperty(this, "filterList", []);
  14267.  
  14268. _defineProperty(this, "filterUse", false);
  14269.  
  14270. mobx.makeAutoObservable(this);
  14271. Object.assign(this, {
  14272. use: true,
  14273. showStickers: true,
  14274. showSuperChat: false,
  14275. scale: 1,
  14276. opacity: 0.7,
  14277. filterList: [],
  14278. filterUse: false,
  14279. fontSize: 24
  14280. }, JSON.parse(localStorage.getItem('ytb-danmaku-config')));
  14281. }
  14282. /**
  14283. * @param {boolean} use
  14284. */
  14285.  
  14286.  
  14287. toggleDanmaku(use) {
  14288. config.use = use;
  14289.  
  14290. if (use) {
  14291. playing = true;
  14292. core.show();
  14293. rAFDanmaku();
  14294. } else {
  14295. playing = false;
  14296. core.hide();
  14297. }
  14298. }
  14299. /**
  14300. * @param {number} scale
  14301. */
  14302.  
  14303.  
  14304. changeDanmakuSpeed(scale) {
  14305. this.scale = scale;
  14306. core.speed = 144 * scale;
  14307. }
  14308. /**
  14309. * @param {number} opacity
  14310. */
  14311.  
  14312.  
  14313. changeDanmakuOpacity(opacity) {
  14314. this.opacity = opacity;
  14315. core.opacity = opacity;
  14316. }
  14317. /**
  14318. * @param {number} fontSize
  14319. */
  14320.  
  14321.  
  14322. changeDanmakuFontSize(fontSize) {
  14323. var _document$querySelect;
  14324.  
  14325. this.fontSize = fontSize;
  14326. (_document$querySelect = document.querySelector('.danmaku-stage')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.style.setProperty('--danmaku-font-size', `${fontSize}px`);
  14327. }
  14328. /**
  14329. * @param {boolean} showStickers
  14330. */
  14331.  
  14332.  
  14333. toggleShowSticker(showStickers) {
  14334. this.showStickers = showStickers;
  14335. }
  14336. /**
  14337. * @param {boolean} showSuperChat
  14338. */
  14339.  
  14340.  
  14341. toggleShowSuperChat(showSuperChat) {
  14342. this.showSuperChat = showSuperChat;
  14343. }
  14344. /**
  14345. * @param {string} content
  14346. */
  14347.  
  14348.  
  14349. addFilter(content) {
  14350. if (content.trim().length === 0) return;
  14351. config.filterList.push({
  14352. content,
  14353. isuse: true,
  14354. id: Math.random().toString(16).slice(2)
  14355. });
  14356. }
  14357.  
  14358. changeFilterUse(id) {
  14359. const target = config.filterList.find(o => o.id === id);
  14360. target.isuse = !target.isuse;
  14361. }
  14362.  
  14363. deleteFilter(id) {
  14364. config.filterList = config.filterList.filter(o => o.id !== id);
  14365. }
  14366.  
  14367. toggleFilterUse(bool) {
  14368. config.filterUse = bool;
  14369. }
  14370.  
  14371. }
  14372.  
  14373. const config = new DanmakuOptions();
  14374. mobx.autorun(() => {
  14375. localStorage.setItem('ytb-danmaku-config', JSON.stringify(config));
  14376. });
  14377.  
  14378. function init(cb) {
  14379.  
  14380. let prevVID;
  14381. let inited = false;
  14382. if (bodyObserver) bodyObserver.disconnect();
  14383. bodyObserver = new MutationObserver(() => {
  14384. if (location.pathname === '/watch') {
  14385. const VID = getQueryString('v');
  14386.  
  14387. if (prevVID !== VID) {
  14388. prevVID = VID;
  14389. inited = true;
  14390. inject(cb);
  14391. } else {
  14392. if (!inited) {
  14393. inited = true;
  14394. inject(cb);
  14395. }
  14396. }
  14397. } else {
  14398. inited = false;
  14399. prevVID = null;
  14400. playing = false;
  14401. }
  14402. });
  14403. bodyObserver.observe(document.body, {
  14404. childList: true,
  14405. subtree: true
  14406. });
  14407. }
  14408.  
  14409. function inject(cb) {
  14410. try {
  14411. var _core;
  14412.  
  14413. console.trace('ytb-danmaku-inited');
  14414. const player = document.getElementById('movie_player');
  14415. if (!player) throw new Error('not find player');
  14416. document.querySelector('div.ytp-left-controls').setAttribute('style', 'overflow: unset;');
  14417. (_core = core) === null || _core === void 0 ? void 0 : _core.destroy();
  14418. core = new Danmaku__default['default']({
  14419. container: player
  14420. });
  14421. document.querySelector('#movie_player').prepend(core._.stage);
  14422. config.changeDanmakuSpeed(config.scale);
  14423. config.changeDanmakuOpacity(config.opacity);
  14424. config.changeDanmakuFontSize(config.fontSize);
  14425. buildControls();
  14426. subEvent();
  14427. config.toggleDanmaku(config.use);
  14428. cb && cb();
  14429. } catch (e) {
  14430. console.error(e);
  14431. setTimeout(() => {
  14432. inject(cb);
  14433. }, 3000);
  14434. }
  14435. }
  14436.  
  14437. function getDanmaku() {
  14438. const iframe = document.querySelector('iframe#chatframe');
  14439.  
  14440. if (iframe) {
  14441. /**
  14442. * @type {Document}
  14443. */
  14444. const idoc = iframe.contentDocument;
  14445. const messagesNode = Array.from(idoc.querySelectorAll(config.showSuperChat ? 'yt-live-chat-paid-message-renderer,yt-live-chat-text-message-renderer' : 'yt-live-chat-text-message-renderer'));
  14446. const lastMessageNodes = messagesNode.slice(-10);
  14447. lastMessageNodes.forEach(lastMessageNode => {
  14448. const nextID = lastMessageNode.id;
  14449. if (!playing || prevID.includes(nextID)) return;
  14450. prevID = [...prevID, nextID].slice(-20);
  14451.  
  14452. if (config.filterUse) {
  14453. const filterList = config.filterList.filter(o => o.isuse);
  14454. const messageText = lastMessageNode.querySelector('#message').innerText || '';
  14455. if (filterList.some(o => messageText.includes(o.content))) return;
  14456. }
  14457.  
  14458. const message = config.showStickers ? lastMessageNode.querySelector('#message').innerHTML : lastMessageNode.querySelector('#message').innerText;
  14459. const isPaidMessage = lastMessageNode.tagName.toLowerCase() === 'yt-live-chat-paid-message-renderer';
  14460. const color = isPaidMessage ? getComputedStyle(lastMessageNode).getPropertyValue('--yt-live-chat-paid-message-primary-color') : 'white';
  14461. core.emit({
  14462. mode: 'rtl',
  14463. style: {
  14464. color
  14465. },
  14466. ...(config.showStickers ? {
  14467. render: () => {
  14468. const div = document.createElement('div');
  14469. div.innerHTML = message;
  14470. div.style.color = color;
  14471. return div;
  14472. }
  14473. } : {
  14474. text: message
  14475. })
  14476. });
  14477. });
  14478. }
  14479. }
  14480.  
  14481. function rAFDanmaku() {
  14482. if (playing) requestAnimationFrame(rAFDanmaku);
  14483. if (sendDanmakuLock) return;
  14484. sendDanmakuLock = true;
  14485. getDanmaku();
  14486. sendDanmakuLock = false;
  14487. }
  14488.  
  14489. function buildControls() {
  14490. if (document.getElementById('ytb-danmaku-config')) return;
  14491. const div = document.createElement('div');
  14492. div.style.width = 'auto';
  14493. div.id = 'ytb-danmaku-config';
  14494. document.querySelector('.ytp-left-controls').append(div);
  14495. }
  14496.  
  14497. function subEvent() {
  14498. const video = document.querySelector('video');
  14499. video.addEventListener('pause', () => {
  14500. if (!config.use) return;
  14501. playing = false;
  14502. core.hide();
  14503. });
  14504. video.addEventListener('play', () => {
  14505. if (!config.use) return;
  14506. playing = true;
  14507. core.show();
  14508. rAFDanmaku();
  14509. });
  14510. window.addEventListener('resize', () => {
  14511. core.resize();
  14512. });
  14513. if (videoObserver) videoObserver.disconnect();
  14514. videoObserver = new MutationObserver(() => {
  14515. setTimeout(() => {
  14516. core.resize();
  14517. }, 500);
  14518. });
  14519. videoObserver.observe(video, {
  14520. attributes: true
  14521. });
  14522. }
  14523.  
  14524. const useStyles$1 = makeStyles(theme => createStyles({
  14525. sliderRoot: {
  14526. display: 'flex',
  14527. alignItems: 'center'
  14528. },
  14529. slider: {
  14530. margin: theme.spacing(0, 1, 0, 2),
  14531. flex: 1
  14532. },
  14533. listButton: {
  14534. '&:hover': {
  14535. backgroundColor: 'rgba(255,255,255,.1)'
  14536. }
  14537. }
  14538. }));
  14539.  
  14540. const BaseConfig = ({
  14541. switchPanel
  14542. }) => {
  14543. const classes = useStyles$1();
  14544.  
  14545. const handleUse = () => {
  14546. config.toggleDanmaku(!config.use);
  14547. };
  14548.  
  14549. const handleShowSticker = () => {
  14550. config.toggleShowSticker(!config.showStickers);
  14551. };
  14552.  
  14553. const handleShowSuperChat = () => {
  14554. config.toggleShowSuperChat(!config.showSuperChat);
  14555. };
  14556.  
  14557. return /*#__PURE__*/React__default['default'].createElement(List$1, {
  14558. id: "k-base"
  14559. }, /*#__PURE__*/React__default['default'].createElement(ListItem$1, {
  14560. button: true,
  14561. className: classes.listButton,
  14562. onClick: handleUse
  14563. }, /*#__PURE__*/React__default['default'].createElement(ListItemText$1, {
  14564. primary: "\u5F39\u5E55\u5F00\u5173",
  14565. primaryTypographyProps: {
  14566. className: 'ytp-menuitem-label',
  14567. style: {
  14568. fontWeight: 500
  14569. }
  14570. }
  14571. }), /*#__PURE__*/React__default['default'].createElement(ListItemSecondaryAction$1, null, /*#__PURE__*/React__default['default'].createElement(Switch$1, {
  14572. checked: config.use,
  14573. onClick: handleUse
  14574. }))), /*#__PURE__*/React__default['default'].createElement(ListItem$1, {
  14575. button: true,
  14576. className: classes.listButton,
  14577. onClick: handleShowSticker
  14578. }, /*#__PURE__*/React__default['default'].createElement(ListItemText$1, {
  14579. primary: "\u663E\u793A\u8D34\u7EB8",
  14580. primaryTypographyProps: {
  14581. className: 'ytp-menuitem-label',
  14582. style: {
  14583. fontWeight: 500
  14584. }
  14585. }
  14586. }), /*#__PURE__*/React__default['default'].createElement(ListItemSecondaryAction$1, null, /*#__PURE__*/React__default['default'].createElement(Switch$1, {
  14587. checked: config.showStickers,
  14588. onClick: handleShowSticker
  14589. }))), /*#__PURE__*/React__default['default'].createElement(ListItem$1, {
  14590. button: true,
  14591. className: classes.listButton,
  14592. onClick: handleShowSuperChat
  14593. }, /*#__PURE__*/React__default['default'].createElement(ListItemText$1, {
  14594. primary: "\u663E\u793ASuper Chat",
  14595. primaryTypographyProps: {
  14596. className: 'ytp-menuitem-label',
  14597. style: {
  14598. fontWeight: 500
  14599. }
  14600. }
  14601. }), /*#__PURE__*/React__default['default'].createElement(ListItemSecondaryAction$1, null, /*#__PURE__*/React__default['default'].createElement(Switch$1, {
  14602. checked: config.showSuperChat,
  14603. onClick: handleShowSuperChat
  14604. }))), /*#__PURE__*/React__default['default'].createElement(ListItem$1, {
  14605. className: classes.listButton
  14606. }, /*#__PURE__*/React__default['default'].createElement(ListItemText$1, {
  14607. primary: /*#__PURE__*/React__default['default'].createElement("div", {
  14608. className: classes.sliderRoot
  14609. }, /*#__PURE__*/React__default['default'].createElement("div", {
  14610. className: "ytp-menuitem-label"
  14611. }, "\u5B57\u4F53\u5927\u5C0F"), /*#__PURE__*/React__default['default'].createElement(Slider$1, {
  14612. color: "secondary",
  14613. max: 40,
  14614. step: 1,
  14615. min: 12,
  14616. value: config.fontSize,
  14617. valueLabelDisplay: "auto",
  14618. className: classes.slider,
  14619. onChange: (e, v) => {
  14620. config.changeDanmakuFontSize(v);
  14621. }
  14622. }))
  14623. })), /*#__PURE__*/React__default['default'].createElement(ListItem$1, {
  14624. className: classes.listButton
  14625. }, /*#__PURE__*/React__default['default'].createElement(ListItemText$1, {
  14626. primary: /*#__PURE__*/React__default['default'].createElement("div", {
  14627. className: classes.sliderRoot
  14628. }, /*#__PURE__*/React__default['default'].createElement("div", {
  14629. className: "ytp-menuitem-label"
  14630. }, "\u5F39\u5E55\u901F\u5EA6"), /*#__PURE__*/React__default['default'].createElement(Slider$1, {
  14631. color: "secondary",
  14632. max: 2,
  14633. step: 0.1,
  14634. min: 0.1,
  14635. value: config.scale,
  14636. valueLabelDisplay: "auto",
  14637. className: classes.slider,
  14638. onChange: (e, v) => {
  14639. config.changeDanmakuSpeed(v);
  14640. }
  14641. }))
  14642. })), /*#__PURE__*/React__default['default'].createElement(ListItem$1, {
  14643. className: classes.listButton
  14644. }, /*#__PURE__*/React__default['default'].createElement(ListItemText$1, {
  14645. primary: /*#__PURE__*/React__default['default'].createElement("div", {
  14646. className: classes.sliderRoot
  14647. }, /*#__PURE__*/React__default['default'].createElement("div", {
  14648. className: "ytp-menuitem-label"
  14649. }, "\u4E0D\u900F\u660E\u5EA6"), /*#__PURE__*/React__default['default'].createElement(Slider$1, {
  14650. color: "secondary",
  14651. max: 1,
  14652. step: 0.1,
  14653. min: 0,
  14654. value: config.opacity,
  14655. valueLabelDisplay: "auto",
  14656. className: classes.slider,
  14657. onChange: (e, v) => {
  14658. config.changeDanmakuOpacity(v);
  14659. }
  14660. }))
  14661. })), /*#__PURE__*/React__default['default'].createElement(ListItem$1, {
  14662. className: classes.listButton,
  14663. button: true,
  14664. onClick: () => switchPanel('filter')
  14665. }, /*#__PURE__*/React__default['default'].createElement(ListItemText$1, {
  14666. primary: "\u5F39\u5E55\u5C4F\u853D"
  14667. }), /*#__PURE__*/React__default['default'].createElement(ListItemSecondaryAction$1, null, /*#__PURE__*/React__default['default'].createElement(default_1$2, null))));
  14668. };
  14669.  
  14670. var BaseConfig$1 = mobxReact.observer(BaseConfig);
  14671.  
  14672. var ArrowBackIos = {};
  14673.  
  14674. var _interopRequireDefault$1 = interopRequireDefault.exports;
  14675.  
  14676. var _interopRequireWildcard$1 = interopRequireWildcard.exports;
  14677.  
  14678. Object.defineProperty(ArrowBackIos, "__esModule", {
  14679. value: true
  14680. });
  14681. var default_1$1 = ArrowBackIos.default = void 0;
  14682.  
  14683. var React$1 = _interopRequireWildcard$1(React__default['default']);
  14684.  
  14685. var _createSvgIcon$1 = _interopRequireDefault$1(createSvgIcon);
  14686.  
  14687. var _default$1 = (0, _createSvgIcon$1.default)( /*#__PURE__*/React$1.createElement("path", {
  14688. d: "M11.67 3.87L9.9 2.1 0 12l9.9 9.9 1.77-1.77L3.54 12z"
  14689. }), 'ArrowBackIos');
  14690.  
  14691. default_1$1 = ArrowBackIos.default = _default$1;
  14692.  
  14693. var Delete = {};
  14694.  
  14695. var _interopRequireDefault = interopRequireDefault.exports;
  14696.  
  14697. var _interopRequireWildcard = interopRequireWildcard.exports;
  14698.  
  14699. Object.defineProperty(Delete, "__esModule", {
  14700. value: true
  14701. });
  14702. var default_1 = Delete.default = void 0;
  14703.  
  14704. var React = _interopRequireWildcard(React__default['default']);
  14705.  
  14706. var _createSvgIcon = _interopRequireDefault(createSvgIcon);
  14707.  
  14708. var _default = (0, _createSvgIcon.default)( /*#__PURE__*/React.createElement("path", {
  14709. d: "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"
  14710. }), 'Delete');
  14711.  
  14712. default_1 = Delete.default = _default;
  14713.  
  14714. const useFilterStyles = makeStyles(theme => createStyles({
  14715. root: {
  14716. width: '100%',
  14717. display: 'flex',
  14718. flexDirection: 'column',
  14719. height: 350
  14720. },
  14721. filterRoot: {
  14722. flex: 1,
  14723. overflow: 'hidden',
  14724. textAlign: 'left',
  14725. padding: theme.spacing(1, 2),
  14726. boxSizing: 'border-box',
  14727. display: 'flex',
  14728. flexDirection: 'column'
  14729. },
  14730. inputContainer: {
  14731. display: 'flex'
  14732. },
  14733. input: {
  14734. padding: theme.spacing(0.25, 1),
  14735. border: '1px solid rgba(255,255,255,.4)',
  14736. borderRadius: 2,
  14737. flex: 1,
  14738. '&:focus': {
  14739. outline: 0
  14740. }
  14741. },
  14742. addbtn: {
  14743. border: '1px solid rgba(255,255,255,.4)',
  14744. borderRadius: 2,
  14745. marginLeft: 8,
  14746. backgroundColor: 'transparent',
  14747. padding: theme.spacing(0.25, 1),
  14748. color: 'white'
  14749. },
  14750. table: {
  14751. fontSize: 12,
  14752. marginTop: theme.spacing(1),
  14753. flex: 1,
  14754. display: 'flex',
  14755. flexDirection: 'column',
  14756. overflow: 'hidden'
  14757. },
  14758. thead: {
  14759. marginBottom: theme.spacing(0.5)
  14760. },
  14761. row: {
  14762. display: 'flex',
  14763. padding: theme.spacing(0.25, 0)
  14764. },
  14765. op: {
  14766. flex: 1,
  14767. display: 'flex',
  14768. justifyContent: 'space-between',
  14769. '& > :last-child': {
  14770. marginLeft: theme.spacing(1)
  14771. },
  14772. '& > div': {
  14773. cursor: 'pointer'
  14774. }
  14775. },
  14776. delete: {
  14777. marginRight: 4
  14778. },
  14779. content: {
  14780. width: '100%',
  14781. maxWidth: 200,
  14782. paddingRight: theme.spacing(1),
  14783. overflow: 'hidden',
  14784. textOverflow: 'ellipsis',
  14785. whiteSpace: 'nowrap'
  14786. },
  14787. listContainer: {
  14788. flex: 1,
  14789. overflow: 'hidden'
  14790. },
  14791. list: {
  14792. height: '100%',
  14793. overflow: 'auto',
  14794. '&::-webkit-scrollbar': {
  14795. width: 0
  14796. }
  14797. },
  14798. sliderRoot: {
  14799. display: 'flex',
  14800. alignItems: 'center'
  14801. },
  14802. slider: {
  14803. margin: theme.spacing(0, 1, 0, 2),
  14804. flex: 1
  14805. },
  14806. listButton: {
  14807. '&:hover': {
  14808. backgroundColor: 'rgba(255,255,255,.1)'
  14809. }
  14810. }
  14811. }));
  14812.  
  14813. const FilterDanmaku = ({
  14814. switchPanel
  14815. }) => {
  14816. const classes = useFilterStyles();
  14817. const [state, setState] = React$3.useState('');
  14818.  
  14819. const handleAdd = () => {
  14820. config.addFilter(state);
  14821. setState('');
  14822. };
  14823.  
  14824. const handleFilterUse = () => {
  14825. config.toggleFilterUse(!config.filterUse);
  14826. };
  14827.  
  14828. return /*#__PURE__*/React__default['default'].createElement("div", {
  14829. id: "k-filter",
  14830. className: classes.root
  14831. }, /*#__PURE__*/React__default['default'].createElement(List$1, null, /*#__PURE__*/React__default['default'].createElement(ListItem$1, {
  14832. className: classes.listButton,
  14833. button: true,
  14834. onClick: () => switchPanel('base', true)
  14835. }, /*#__PURE__*/React__default['default'].createElement(default_1$1, {
  14836. color: "inherit"
  14837. }), /*#__PURE__*/React__default['default'].createElement(ListItemText$1, {
  14838. primary: "\u5F39\u5E55\u5C4F\u853D"
  14839. }), /*#__PURE__*/React__default['default'].createElement(ListItemSecondaryAction$1, null, /*#__PURE__*/React__default['default'].createElement(Switch$1, {
  14840. checked: config.filterUse,
  14841. onClick: handleFilterUse
  14842. }))), /*#__PURE__*/React__default['default'].createElement(Divider$1, {
  14843. style: {
  14844. backgroundColor: '#444'
  14845. }
  14846. })), /*#__PURE__*/React__default['default'].createElement(Fade, {
  14847. in: config.filterUse,
  14848. unmountOnExit: true
  14849. }, /*#__PURE__*/React__default['default'].createElement("div", {
  14850. className: classes.filterRoot
  14851. }, /*#__PURE__*/React__default['default'].createElement("div", {
  14852. className: classes.inputContainer
  14853. }, /*#__PURE__*/React__default['default'].createElement("input", {
  14854. placeholder: "\u5C4F\u853D\u5185\u5BB9...",
  14855. className: classes.input,
  14856. value: state,
  14857. onChange: e => setState(e.target.value),
  14858. onKeyPress: e => {
  14859. if (e.key === 'Enter') {
  14860. handleAdd();
  14861. }
  14862. }
  14863. }), /*#__PURE__*/React__default['default'].createElement("button", {
  14864. className: classes.addbtn,
  14865. onClick: handleAdd
  14866. }, "\u6DFB\u52A0")), /*#__PURE__*/React__default['default'].createElement("div", {
  14867. className: classes.table
  14868. }, /*#__PURE__*/React__default['default'].createElement("div", {
  14869. className: `${classes.row} ${classes.thead}`
  14870. }, /*#__PURE__*/React__default['default'].createElement("div", {
  14871. className: classes.content
  14872. }, "\u5185\u5BB9( ", config.filterList.length, " )"), /*#__PURE__*/React__default['default'].createElement("div", {
  14873. className: classes.op
  14874. }, /*#__PURE__*/React__default['default'].createElement("div", null, "\u72B6\u6001"), /*#__PURE__*/React__default['default'].createElement("div", null, "\u64CD\u4F5C"))), /*#__PURE__*/React__default['default'].createElement("div", {
  14875. className: classes.listContainer
  14876. }, /*#__PURE__*/React__default['default'].createElement("div", {
  14877. className: classes.list
  14878. }, config.filterList.map(o => /*#__PURE__*/React__default['default'].createElement("div", {
  14879. className: classes.row,
  14880. key: o.id
  14881. }, /*#__PURE__*/React__default['default'].createElement("div", {
  14882. className: classes.content
  14883. }, o.content), /*#__PURE__*/React__default['default'].createElement("div", {
  14884. className: classes.op
  14885. }, /*#__PURE__*/React__default['default'].createElement("div", {
  14886. onClick: () => config.changeFilterUse(o.id)
  14887. }, o.isuse ? '启用' : '禁用'), /*#__PURE__*/React__default['default'].createElement("div", {
  14888. className: classes.delete,
  14889. onClick: () => {
  14890. config.deleteFilter(o.id);
  14891. }
  14892. }, /*#__PURE__*/React__default['default'].createElement(default_1, {
  14893. style: {
  14894. fontSize: 16
  14895. }
  14896. })))))))))));
  14897. };
  14898.  
  14899. var FilterDanmaku$1 = mobxReact.observer(FilterDanmaku);
  14900.  
  14901. const muiTheme = createMuiTheme({
  14902. palette: {
  14903. secondary: {
  14904. main: '#f00'
  14905. }
  14906. },
  14907. overrides: {
  14908. MuiSwitch: {
  14909. thumb: {
  14910. backgroundColor: 'white'
  14911. },
  14912. track: {
  14913. opacity: '1 !important'
  14914. }
  14915. }
  14916. }
  14917. });
  14918. const useStyles = makeStyles(theme => createStyles({
  14919. root: {
  14920. position: 'relative'
  14921. },
  14922. controls: {
  14923. backgroundColor: 'rgba(28,28,28,0.9)',
  14924. position: 'absolute',
  14925. bottom: 40,
  14926. color: 'white',
  14927. left: '50%',
  14928. transform: 'translateX(-50%)',
  14929. zIndex: theme.zIndex.tooltip,
  14930. width: 300
  14931. },
  14932. tooltip: {
  14933. padding: theme.spacing(0.5, 1),
  14934. backgroundColor: 'rgba(28,28,28,0.9)',
  14935. fontSize: 13,
  14936. borderRadius: 2,
  14937. fontWeight: 400
  14938. },
  14939. container: {
  14940. width: 300,
  14941. '&>div': {
  14942. width: 300,
  14943. display: 'flex',
  14944. overflow: 'hidden',
  14945. transition: theme.transitions.create(['height']),
  14946. '&>*': {
  14947. flexShrink: 0,
  14948. width: 300
  14949. }
  14950. }
  14951. }
  14952. }));
  14953.  
  14954. const Danmaku = () => {
  14955. const [open, setOpen] = React$3.useState(false);
  14956. const classes = useStyles();
  14957. const containerRef = React$3.useRef();
  14958. const theme = useTheme();
  14959. React$3.useEffect(() => {
  14960. if (open) {
  14961. Array.from(containerRef.current.children).forEach((o, i) => o.hidden = i !== 0);
  14962. }
  14963. }, [open]);
  14964. const switchPanel = React$3.useCallback((key, isBack) => {
  14965. const target = document.getElementById(`k-${key}`);
  14966. const current = Array.from(containerRef.current.children).find(o => !o.hidden);
  14967. const currentSize = current.getBoundingClientRect();
  14968. containerRef.current.style.height = `${currentSize.height}px`;
  14969.  
  14970. const restore = e => {
  14971. if (e.target !== containerRef.current && !['height'].includes(e.propertyName)) return;
  14972. containerRef.current.style.height = '';
  14973. [current, target].forEach(o => {
  14974. o.style.transform = '';
  14975. o.style.transition = '';
  14976. });
  14977. current.hidden = true;
  14978. containerRef.current.removeEventListener('transitionend', restore);
  14979. };
  14980.  
  14981. containerRef.current.addEventListener('transitionend', restore);
  14982. const size = getPanelSize(target);
  14983. containerRef.current.style.height = `${size.height}px`;
  14984. target.hidden = false;
  14985. Array.from(containerRef.current.children).forEach(o => {
  14986. o.style.transform = `translateX(${isBack ? '-300' : '0'}px)`;
  14987. requestAnimationFrame(() => {
  14988. o.style.transform = `translateX(${isBack ? '0' : '-300'}px)`;
  14989. o.style.transition = theme.transitions.create(['transform']);
  14990. });
  14991. });
  14992. }, []);
  14993. return /*#__PURE__*/React__default['default'].createElement(ThemeProvider, {
  14994. theme: muiTheme
  14995. }, /*#__PURE__*/React__default['default'].createElement("style", {
  14996. jsx: true
  14997. }, `
  14998. [hidden] {
  14999. display: none !important;
  15000. }
  15001. `), /*#__PURE__*/React__default['default'].createElement("span", {
  15002. className: classes.root
  15003. }, /*#__PURE__*/React__default['default'].createElement(Tooltip$1, {
  15004. title: "\u5F39\u5E55",
  15005. placement: "top",
  15006. classes: {
  15007. tooltip: classes.tooltip
  15008. }
  15009. }, /*#__PURE__*/React__default['default'].createElement("button", {
  15010. style: {
  15011. textAlign: 'center'
  15012. },
  15013. onClick: () => setOpen(true),
  15014. className: "ytp-button"
  15015. }, "\u5F39\u5E55")), /*#__PURE__*/React__default['default'].createElement(Fade, {
  15016. in: open,
  15017. unmountOnExit: true
  15018. }, /*#__PURE__*/React__default['default'].createElement(Box, {
  15019. className: classes.controls
  15020. }, /*#__PURE__*/React__default['default'].createElement(ClickAwayListener, {
  15021. onClickAway: () => setOpen(false)
  15022. }, /*#__PURE__*/React__default['default'].createElement("div", {
  15023. className: classes.container
  15024. }, /*#__PURE__*/React__default['default'].createElement("div", {
  15025. ref: containerRef
  15026. }, /*#__PURE__*/React__default['default'].createElement(BaseConfig$1, {
  15027. switchPanel: switchPanel
  15028. }), /*#__PURE__*/React__default['default'].createElement(FilterDanmaku$1, {
  15029. switchPanel: switchPanel
  15030. }))))))));
  15031. };
  15032.  
  15033. var Danmaku$1 = mobxReact.observer(Danmaku);
  15034.  
  15035. window.addEventListener('load', () => {
  15036. console.log('[ytb-danmaku] init');
  15037. init(() => {
  15038. ReactDOM__default['default'].render( /*#__PURE__*/React__default['default'].createElement(Danmaku$1, null), document.getElementById('ytb-danmaku-config'));
  15039. });
  15040. });
  15041.  
  15042. }(React, ReactDOM, mobxReact, mobx, Danmaku));