ani2mpv

讓動畫瘋跳轉到 MPV

  1. // ==UserScript==
  2. // @name ani2mpv
  3. // @namespace npm/vite-plugin-monkey
  4. // @version 2.0.0
  5. // @author Yotsuba
  6. // @description 讓動畫瘋跳轉到 MPV
  7. // @license MIT
  8. // @icon https://vitejs.dev/logo.svg
  9. // @match https://ani.gamer.com.tw/animeVideo.php?sn=*
  10. // @require https://cdn.jsdelivr.net/npm/react@18.3.1/umd/react.production.min.js
  11. // @require https://cdn.jsdelivr.net/npm/react-dom@18.3.1/umd/react-dom.production.min.js
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. (function (React, ReactDOM) {
  16. 'use strict';
  17.  
  18. function _interopNamespaceDefault(e) {
  19. const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
  20. if (e) {
  21. for (const k in e) {
  22. if (k !== 'default') {
  23. const d = Object.getOwnPropertyDescriptor(e, k);
  24. Object.defineProperty(n, k, d.get ? d : {
  25. enumerable: true,
  26. get: () => e[k]
  27. });
  28. }
  29. }
  30. }
  31. n.default = e;
  32. return Object.freeze(n);
  33. }
  34.  
  35. const React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
  36.  
  37. var __defProp = Object.defineProperty;
  38. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  39. var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  40. var jsxRuntime = { exports: {} };
  41. var reactJsxRuntime_production_min = {};
  42. /**
  43. * @license React
  44. * react-jsx-runtime.production.min.js
  45. *
  46. * Copyright (c) Facebook, Inc. and its affiliates.
  47. *
  48. * This source code is licensed under the MIT license found in the
  49. * LICENSE file in the root directory of this source tree.
  50. */
  51. var f$1 = React, k$1 = Symbol.for("react.element"), l$1 = Symbol.for("react.fragment"), m$2 = Object.prototype.hasOwnProperty, n$1 = f$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p$1 = { key: true, ref: true, __self: true, __source: true };
  52. function q$1(c2, a, g2) {
  53. var b2, d2 = {}, e2 = null, h2 = null;
  54. void 0 !== g2 && (e2 = "" + g2);
  55. void 0 !== a.key && (e2 = "" + a.key);
  56. void 0 !== a.ref && (h2 = a.ref);
  57. for (b2 in a) m$2.call(a, b2) && !p$1.hasOwnProperty(b2) && (d2[b2] = a[b2]);
  58. if (c2 && c2.defaultProps) for (b2 in a = c2.defaultProps, a) void 0 === d2[b2] && (d2[b2] = a[b2]);
  59. return { $$typeof: k$1, type: c2, key: e2, ref: h2, props: d2, _owner: n$1.current };
  60. }
  61. reactJsxRuntime_production_min.Fragment = l$1;
  62. reactJsxRuntime_production_min.jsx = q$1;
  63. reactJsxRuntime_production_min.jsxs = q$1;
  64. {
  65. jsxRuntime.exports = reactJsxRuntime_production_min;
  66. }
  67. var jsxRuntimeExports = jsxRuntime.exports;
  68. var client = {};
  69. var m$1 = ReactDOM;
  70. {
  71. client.createRoot = m$1.createRoot;
  72. client.hydrateRoot = m$1.hydrateRoot;
  73. }
  74. function formatMuiErrorMessage(code, ...args) {
  75. const url = new URL(`https://mui.com/production-error/?code=${code}`);
  76. args.forEach((arg2) => url.searchParams.append("args[]", arg2));
  77. return `Minified MUI error #${code}; visit ${url} for the full message.`;
  78. }
  79. function _extends() {
  80. return _extends = Object.assign ? Object.assign.bind() : function(n2) {
  81. for (var e2 = 1; e2 < arguments.length; e2++) {
  82. var t2 = arguments[e2];
  83. for (var r2 in t2) ({}).hasOwnProperty.call(t2, r2) && (n2[r2] = t2[r2]);
  84. }
  85. return n2;
  86. }, _extends.apply(null, arguments);
  87. }
  88. function memoize$1(fn) {
  89. var cache = /* @__PURE__ */ Object.create(null);
  90. return function(arg2) {
  91. if (cache[arg2] === void 0) cache[arg2] = fn(arg2);
  92. return cache[arg2];
  93. };
  94. }
  95. var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/;
  96. var isPropValid = /* @__PURE__ */ memoize$1(
  97. function(prop) {
  98. return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110 && prop.charCodeAt(2) < 91;
  99. }
  100. /* Z+1 */
  101. );
  102. var isDevelopment$2 = false;
  103. function sheetForTag(tag) {
  104. if (tag.sheet) {
  105. return tag.sheet;
  106. }
  107. for (var i = 0; i < document.styleSheets.length; i++) {
  108. if (document.styleSheets[i].ownerNode === tag) {
  109. return document.styleSheets[i];
  110. }
  111. }
  112. return void 0;
  113. }
  114. function createStyleElement(options) {
  115. var tag = document.createElement("style");
  116. tag.setAttribute("data-emotion", options.key);
  117. if (options.nonce !== void 0) {
  118. tag.setAttribute("nonce", options.nonce);
  119. }
  120. tag.appendChild(document.createTextNode(""));
  121. tag.setAttribute("data-s", "");
  122. return tag;
  123. }
  124. var StyleSheet = /* @__PURE__ */ function() {
  125. function StyleSheet2(options) {
  126. var _this = this;
  127. this._insertTag = function(tag) {
  128. var before;
  129. if (_this.tags.length === 0) {
  130. if (_this.insertionPoint) {
  131. before = _this.insertionPoint.nextSibling;
  132. } else if (_this.prepend) {
  133. before = _this.container.firstChild;
  134. } else {
  135. before = _this.before;
  136. }
  137. } else {
  138. before = _this.tags[_this.tags.length - 1].nextSibling;
  139. }
  140. _this.container.insertBefore(tag, before);
  141. _this.tags.push(tag);
  142. };
  143. this.isSpeedy = options.speedy === void 0 ? !isDevelopment$2 : options.speedy;
  144. this.tags = [];
  145. this.ctr = 0;
  146. this.nonce = options.nonce;
  147. this.key = options.key;
  148. this.container = options.container;
  149. this.prepend = options.prepend;
  150. this.insertionPoint = options.insertionPoint;
  151. this.before = null;
  152. }
  153. var _proto = StyleSheet2.prototype;
  154. _proto.hydrate = function hydrate(nodes) {
  155. nodes.forEach(this._insertTag);
  156. };
  157. _proto.insert = function insert(rule) {
  158. if (this.ctr % (this.isSpeedy ? 65e3 : 1) === 0) {
  159. this._insertTag(createStyleElement(this));
  160. }
  161. var tag = this.tags[this.tags.length - 1];
  162. if (this.isSpeedy) {
  163. var sheet = sheetForTag(tag);
  164. try {
  165. sheet.insertRule(rule, sheet.cssRules.length);
  166. } catch (e2) {
  167. }
  168. } else {
  169. tag.appendChild(document.createTextNode(rule));
  170. }
  171. this.ctr++;
  172. };
  173. _proto.flush = function flush() {
  174. this.tags.forEach(function(tag) {
  175. var _tag$parentNode;
  176. return (_tag$parentNode = tag.parentNode) == null ? void 0 : _tag$parentNode.removeChild(tag);
  177. });
  178. this.tags = [];
  179. this.ctr = 0;
  180. };
  181. return StyleSheet2;
  182. }();
  183. var MS = "-ms-";
  184. var MOZ = "-moz-";
  185. var WEBKIT = "-webkit-";
  186. var COMMENT = "comm";
  187. var RULESET = "rule";
  188. var DECLARATION = "decl";
  189. var IMPORT = "@import";
  190. var KEYFRAMES = "@keyframes";
  191. var LAYER = "@layer";
  192. var abs = Math.abs;
  193. var from = String.fromCharCode;
  194. var assign = Object.assign;
  195. function hash(value, length2) {
  196. return charat(value, 0) ^ 45 ? (((length2 << 2 ^ charat(value, 0)) << 2 ^ charat(value, 1)) << 2 ^ charat(value, 2)) << 2 ^ charat(value, 3) : 0;
  197. }
  198. function trim$1(value) {
  199. return value.trim();
  200. }
  201. function match(value, pattern) {
  202. return (value = pattern.exec(value)) ? value[0] : value;
  203. }
  204. function replace(value, pattern, replacement) {
  205. return value.replace(pattern, replacement);
  206. }
  207. function indexof(value, search) {
  208. return value.indexOf(search);
  209. }
  210. function charat(value, index) {
  211. return value.charCodeAt(index) | 0;
  212. }
  213. function substr(value, begin, end) {
  214. return value.slice(begin, end);
  215. }
  216. function strlen(value) {
  217. return value.length;
  218. }
  219. function sizeof(value) {
  220. return value.length;
  221. }
  222. function append(value, array) {
  223. return array.push(value), value;
  224. }
  225. function combine(array, callback) {
  226. return array.map(callback).join("");
  227. }
  228. var line = 1;
  229. var column = 1;
  230. var length = 0;
  231. var position = 0;
  232. var character = 0;
  233. var characters = "";
  234. function node(value, root, parent, type, props, children, length2) {
  235. return { value, root, parent, type, props, children, line, column, length: length2, return: "" };
  236. }
  237. function copy(root, props) {
  238. return assign(node("", null, null, "", null, null, 0), root, { length: -root.length }, props);
  239. }
  240. function char() {
  241. return character;
  242. }
  243. function prev() {
  244. character = position > 0 ? charat(characters, --position) : 0;
  245. if (column--, character === 10)
  246. column = 1, line--;
  247. return character;
  248. }
  249. function next() {
  250. character = position < length ? charat(characters, position++) : 0;
  251. if (column++, character === 10)
  252. column = 1, line++;
  253. return character;
  254. }
  255. function peek() {
  256. return charat(characters, position);
  257. }
  258. function caret() {
  259. return position;
  260. }
  261. function slice(begin, end) {
  262. return substr(characters, begin, end);
  263. }
  264. function token(type) {
  265. switch (type) {
  266. case 0:
  267. case 9:
  268. case 10:
  269. case 13:
  270. case 32:
  271. return 5;
  272. case 33:
  273. case 43:
  274. case 44:
  275. case 47:
  276. case 62:
  277. case 64:
  278. case 126:
  279. case 59:
  280. case 123:
  281. case 125:
  282. return 4;
  283. case 58:
  284. return 3;
  285. case 34:
  286. case 39:
  287. case 40:
  288. case 91:
  289. return 2;
  290. case 41:
  291. case 93:
  292. return 1;
  293. }
  294. return 0;
  295. }
  296. function alloc(value) {
  297. return line = column = 1, length = strlen(characters = value), position = 0, [];
  298. }
  299. function dealloc(value) {
  300. return characters = "", value;
  301. }
  302. function delimit(type) {
  303. return trim$1(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)));
  304. }
  305. function whitespace(type) {
  306. while (character = peek())
  307. if (character < 33)
  308. next();
  309. else
  310. break;
  311. return token(type) > 2 || token(character) > 3 ? "" : " ";
  312. }
  313. function escaping(index, count) {
  314. while (--count && next())
  315. if (character < 48 || character > 102 || character > 57 && character < 65 || character > 70 && character < 97)
  316. break;
  317. return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32));
  318. }
  319. function delimiter(type) {
  320. while (next())
  321. switch (character) {
  322. case type:
  323. return position;
  324. case 34:
  325. case 39:
  326. if (type !== 34 && type !== 39)
  327. delimiter(character);
  328. break;
  329. case 40:
  330. if (type === 41)
  331. delimiter(type);
  332. break;
  333. case 92:
  334. next();
  335. break;
  336. }
  337. return position;
  338. }
  339. function commenter(type, index) {
  340. while (next())
  341. if (type + character === 47 + 10)
  342. break;
  343. else if (type + character === 42 + 42 && peek() === 47)
  344. break;
  345. return "/*" + slice(index, position - 1) + "*" + from(type === 47 ? type : next());
  346. }
  347. function identifier(index) {
  348. while (!token(peek()))
  349. next();
  350. return slice(index, position);
  351. }
  352. function compile(value) {
  353. return dealloc(parse("", null, null, null, [""], value = alloc(value), 0, [0], value));
  354. }
  355. function parse(value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {
  356. var index = 0;
  357. var offset = 0;
  358. var length2 = pseudo;
  359. var atrule = 0;
  360. var property = 0;
  361. var previous = 0;
  362. var variable = 1;
  363. var scanning = 1;
  364. var ampersand = 1;
  365. var character2 = 0;
  366. var type = "";
  367. var props = rules;
  368. var children = rulesets;
  369. var reference = rule;
  370. var characters2 = type;
  371. while (scanning)
  372. switch (previous = character2, character2 = next()) {
  373. case 40:
  374. if (previous != 108 && charat(characters2, length2 - 1) == 58) {
  375. if (indexof(characters2 += replace(delimit(character2), "&", "&\f"), "&\f") != -1)
  376. ampersand = -1;
  377. break;
  378. }
  379. case 34:
  380. case 39:
  381. case 91:
  382. characters2 += delimit(character2);
  383. break;
  384. case 9:
  385. case 10:
  386. case 13:
  387. case 32:
  388. characters2 += whitespace(previous);
  389. break;
  390. case 92:
  391. characters2 += escaping(caret() - 1, 7);
  392. continue;
  393. case 47:
  394. switch (peek()) {
  395. case 42:
  396. case 47:
  397. append(comment(commenter(next(), caret()), root, parent), declarations);
  398. break;
  399. default:
  400. characters2 += "/";
  401. }
  402. break;
  403. case 123 * variable:
  404. points[index++] = strlen(characters2) * ampersand;
  405. case 125 * variable:
  406. case 59:
  407. case 0:
  408. switch (character2) {
  409. case 0:
  410. case 125:
  411. scanning = 0;
  412. case 59 + offset:
  413. if (ampersand == -1) characters2 = replace(characters2, /\f/g, "");
  414. if (property > 0 && strlen(characters2) - length2)
  415. append(property > 32 ? declaration(characters2 + ";", rule, parent, length2 - 1) : declaration(replace(characters2, " ", "") + ";", rule, parent, length2 - 2), declarations);
  416. break;
  417. case 59:
  418. characters2 += ";";
  419. default:
  420. append(reference = ruleset(characters2, root, parent, index, offset, rules, points, type, props = [], children = [], length2), rulesets);
  421. if (character2 === 123)
  422. if (offset === 0)
  423. parse(characters2, root, reference, reference, props, rulesets, length2, points, children);
  424. else
  425. switch (atrule === 99 && charat(characters2, 3) === 110 ? 100 : atrule) {
  426. case 100:
  427. case 108:
  428. case 109:
  429. case 115:
  430. parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length2), children), rules, children, length2, points, rule ? props : children);
  431. break;
  432. default:
  433. parse(characters2, reference, reference, reference, [""], children, 0, points, children);
  434. }
  435. }
  436. index = offset = property = 0, variable = ampersand = 1, type = characters2 = "", length2 = pseudo;
  437. break;
  438. case 58:
  439. length2 = 1 + strlen(characters2), property = previous;
  440. default:
  441. if (variable < 1) {
  442. if (character2 == 123)
  443. --variable;
  444. else if (character2 == 125 && variable++ == 0 && prev() == 125)
  445. continue;
  446. }
  447. switch (characters2 += from(character2), character2 * variable) {
  448. case 38:
  449. ampersand = offset > 0 ? 1 : (characters2 += "\f", -1);
  450. break;
  451. case 44:
  452. points[index++] = (strlen(characters2) - 1) * ampersand, ampersand = 1;
  453. break;
  454. case 64:
  455. if (peek() === 45)
  456. characters2 += delimit(next());
  457. atrule = peek(), offset = length2 = strlen(type = characters2 += identifier(caret())), character2++;
  458. break;
  459. case 45:
  460. if (previous === 45 && strlen(characters2) == 2)
  461. variable = 0;
  462. }
  463. }
  464. return rulesets;
  465. }
  466. function ruleset(value, root, parent, index, offset, rules, points, type, props, children, length2) {
  467. var post = offset - 1;
  468. var rule = offset === 0 ? rules : [""];
  469. var size = sizeof(rule);
  470. for (var i = 0, j = 0, k2 = 0; i < index; ++i)
  471. for (var x2 = 0, y2 = substr(value, post + 1, post = abs(j = points[i])), z2 = value; x2 < size; ++x2)
  472. if (z2 = trim$1(j > 0 ? rule[x2] + " " + y2 : replace(y2, /&\f/g, rule[x2])))
  473. props[k2++] = z2;
  474. return node(value, root, parent, offset === 0 ? RULESET : type, props, children, length2);
  475. }
  476. function comment(value, root, parent) {
  477. return node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0);
  478. }
  479. function declaration(value, root, parent, length2) {
  480. return node(value, root, parent, DECLARATION, substr(value, 0, length2), substr(value, length2 + 1, -1), length2);
  481. }
  482. function serialize(children, callback) {
  483. var output = "";
  484. var length2 = sizeof(children);
  485. for (var i = 0; i < length2; i++)
  486. output += callback(children[i], i, children, callback) || "";
  487. return output;
  488. }
  489. function stringify(element, index, children, callback) {
  490. switch (element.type) {
  491. case LAYER:
  492. if (element.children.length) break;
  493. case IMPORT:
  494. case DECLARATION:
  495. return element.return = element.return || element.value;
  496. case COMMENT:
  497. return "";
  498. case KEYFRAMES:
  499. return element.return = element.value + "{" + serialize(element.children, callback) + "}";
  500. case RULESET:
  501. element.value = element.props.join(",");
  502. }
  503. return strlen(children = serialize(element.children, callback)) ? element.return = element.value + "{" + children + "}" : "";
  504. }
  505. function middleware(collection) {
  506. var length2 = sizeof(collection);
  507. return function(element, index, children, callback) {
  508. var output = "";
  509. for (var i = 0; i < length2; i++)
  510. output += collection[i](element, index, children, callback) || "";
  511. return output;
  512. };
  513. }
  514. function rulesheet(callback) {
  515. return function(element) {
  516. if (!element.root) {
  517. if (element = element.return)
  518. callback(element);
  519. }
  520. };
  521. }
  522. var identifierWithPointTracking = function identifierWithPointTracking2(begin, points, index) {
  523. var previous = 0;
  524. var character2 = 0;
  525. while (true) {
  526. previous = character2;
  527. character2 = peek();
  528. if (previous === 38 && character2 === 12) {
  529. points[index] = 1;
  530. }
  531. if (token(character2)) {
  532. break;
  533. }
  534. next();
  535. }
  536. return slice(begin, position);
  537. };
  538. var toRules = function toRules2(parsed, points) {
  539. var index = -1;
  540. var character2 = 44;
  541. do {
  542. switch (token(character2)) {
  543. case 0:
  544. if (character2 === 38 && peek() === 12) {
  545. points[index] = 1;
  546. }
  547. parsed[index] += identifierWithPointTracking(position - 1, points, index);
  548. break;
  549. case 2:
  550. parsed[index] += delimit(character2);
  551. break;
  552. case 4:
  553. if (character2 === 44) {
  554. parsed[++index] = peek() === 58 ? "&\f" : "";
  555. points[index] = parsed[index].length;
  556. break;
  557. }
  558. default:
  559. parsed[index] += from(character2);
  560. }
  561. } while (character2 = next());
  562. return parsed;
  563. };
  564. var getRules = function getRules2(value, points) {
  565. return dealloc(toRules(alloc(value), points));
  566. };
  567. var fixedElements = /* @__PURE__ */ new WeakMap();
  568. var compat = function compat2(element) {
  569. if (element.type !== "rule" || !element.parent || // positive .length indicates that this rule contains pseudo
  570. // negative .length indicates that this rule has been already prefixed
  571. element.length < 1) {
  572. return;
  573. }
  574. var value = element.value, parent = element.parent;
  575. var isImplicitRule = element.column === parent.column && element.line === parent.line;
  576. while (parent.type !== "rule") {
  577. parent = parent.parent;
  578. if (!parent) return;
  579. }
  580. if (element.props.length === 1 && value.charCodeAt(0) !== 58 && !fixedElements.get(parent)) {
  581. return;
  582. }
  583. if (isImplicitRule) {
  584. return;
  585. }
  586. fixedElements.set(element, true);
  587. var points = [];
  588. var rules = getRules(value, points);
  589. var parentRules = parent.props;
  590. for (var i = 0, k2 = 0; i < rules.length; i++) {
  591. for (var j = 0; j < parentRules.length; j++, k2++) {
  592. element.props[k2] = points[i] ? rules[i].replace(/&\f/g, parentRules[j]) : parentRules[j] + " " + rules[i];
  593. }
  594. }
  595. };
  596. var removeLabel = function removeLabel2(element) {
  597. if (element.type === "decl") {
  598. var value = element.value;
  599. if (
  600. // charcode for l
  601. value.charCodeAt(0) === 108 && // charcode for b
  602. value.charCodeAt(2) === 98
  603. ) {
  604. element["return"] = "";
  605. element.value = "";
  606. }
  607. }
  608. };
  609. function prefix(value, length2) {
  610. switch (hash(value, length2)) {
  611. case 5103:
  612. return WEBKIT + "print-" + value + value;
  613. case 5737:
  614. case 4201:
  615. case 3177:
  616. case 3433:
  617. case 1641:
  618. case 4457:
  619. case 2921:
  620. case 5572:
  621. case 6356:
  622. case 5844:
  623. case 3191:
  624. case 6645:
  625. case 3005:
  626. case 6391:
  627. case 5879:
  628. case 5623:
  629. case 6135:
  630. case 4599:
  631. case 4855:
  632. case 4215:
  633. case 6389:
  634. case 5109:
  635. case 5365:
  636. case 5621:
  637. case 3829:
  638. return WEBKIT + value + value;
  639. case 5349:
  640. case 4246:
  641. case 4810:
  642. case 6968:
  643. case 2756:
  644. return WEBKIT + value + MOZ + value + MS + value + value;
  645. case 6828:
  646. case 4268:
  647. return WEBKIT + value + MS + value + value;
  648. case 6165:
  649. return WEBKIT + value + MS + "flex-" + value + value;
  650. case 5187:
  651. return WEBKIT + value + replace(value, /(\w+).+(:[^]+)/, WEBKIT + "box-$1$2" + MS + "flex-$1$2") + value;
  652. case 5443:
  653. return WEBKIT + value + MS + "flex-item-" + replace(value, /flex-|-self/, "") + value;
  654. case 4675:
  655. return WEBKIT + value + MS + "flex-line-pack" + replace(value, /align-content|flex-|-self/, "") + value;
  656. case 5548:
  657. return WEBKIT + value + MS + replace(value, "shrink", "negative") + value;
  658. case 5292:
  659. return WEBKIT + value + MS + replace(value, "basis", "preferred-size") + value;
  660. case 6060:
  661. return WEBKIT + "box-" + replace(value, "-grow", "") + WEBKIT + value + MS + replace(value, "grow", "positive") + value;
  662. case 4554:
  663. return WEBKIT + replace(value, /([^-])(transform)/g, "$1" + WEBKIT + "$2") + value;
  664. case 6187:
  665. return replace(replace(replace(value, /(zoom-|grab)/, WEBKIT + "$1"), /(image-set)/, WEBKIT + "$1"), value, "") + value;
  666. case 5495:
  667. case 3959:
  668. return replace(value, /(image-set\([^]*)/, WEBKIT + "$1$`$1");
  669. case 4968:
  670. return replace(replace(value, /(.+:)(flex-)?(.*)/, WEBKIT + "box-pack:$3" + MS + "flex-pack:$3"), /s.+-b[^;]+/, "justify") + WEBKIT + value + value;
  671. case 4095:
  672. case 3583:
  673. case 4068:
  674. case 2532:
  675. return replace(value, /(.+)-inline(.+)/, WEBKIT + "$1$2") + value;
  676. case 8116:
  677. case 7059:
  678. case 5753:
  679. case 5535:
  680. case 5445:
  681. case 5701:
  682. case 4933:
  683. case 4677:
  684. case 5533:
  685. case 5789:
  686. case 5021:
  687. case 4765:
  688. if (strlen(value) - 1 - length2 > 6) switch (charat(value, length2 + 1)) {
  689. case 109:
  690. if (charat(value, length2 + 4) !== 45) break;
  691. case 102:
  692. return replace(value, /(.+:)(.+)-([^]+)/, "$1" + WEBKIT + "$2-$3$1" + MOZ + (charat(value, length2 + 3) == 108 ? "$3" : "$2-$3")) + value;
  693. case 115:
  694. return ~indexof(value, "stretch") ? prefix(replace(value, "stretch", "fill-available"), length2) + value : value;
  695. }
  696. break;
  697. case 4949:
  698. if (charat(value, length2 + 1) !== 115) break;
  699. case 6444:
  700. switch (charat(value, strlen(value) - 3 - (~indexof(value, "!important") && 10))) {
  701. case 107:
  702. return replace(value, ":", ":" + WEBKIT) + value;
  703. case 101:
  704. return replace(value, /(.+:)([^;!]+)(;|!.+)?/, "$1" + WEBKIT + (charat(value, 14) === 45 ? "inline-" : "") + "box$3$1" + WEBKIT + "$2$3$1" + MS + "$2box$3") + value;
  705. }
  706. break;
  707. case 5936:
  708. switch (charat(value, length2 + 11)) {
  709. case 114:
  710. return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb") + value;
  711. case 108:
  712. return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb-rl") + value;
  713. case 45:
  714. return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "lr") + value;
  715. }
  716. return WEBKIT + value + MS + value + value;
  717. }
  718. return value;
  719. }
  720. var prefixer = function prefixer2(element, index, children, callback) {
  721. if (element.length > -1) {
  722. if (!element["return"]) switch (element.type) {
  723. case DECLARATION:
  724. element["return"] = prefix(element.value, element.length);
  725. break;
  726. case KEYFRAMES:
  727. return serialize([copy(element, {
  728. value: replace(element.value, "@", "@" + WEBKIT)
  729. })], callback);
  730. case RULESET:
  731. if (element.length) return combine(element.props, function(value) {
  732. switch (match(value, /(::plac\w+|:read-\w+)/)) {
  733. case ":read-only":
  734. case ":read-write":
  735. return serialize([copy(element, {
  736. props: [replace(value, /:(read-\w+)/, ":" + MOZ + "$1")]
  737. })], callback);
  738. case "::placeholder":
  739. return serialize([copy(element, {
  740. props: [replace(value, /:(plac\w+)/, ":" + WEBKIT + "input-$1")]
  741. }), copy(element, {
  742. props: [replace(value, /:(plac\w+)/, ":" + MOZ + "$1")]
  743. }), copy(element, {
  744. props: [replace(value, /:(plac\w+)/, MS + "input-$1")]
  745. })], callback);
  746. }
  747. return "";
  748. });
  749. }
  750. }
  751. };
  752. var defaultStylisPlugins = [prefixer];
  753. var createCache = function createCache2(options) {
  754. var key = options.key;
  755. if (key === "css") {
  756. var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])");
  757. Array.prototype.forEach.call(ssrStyles, function(node2) {
  758. var dataEmotionAttribute = node2.getAttribute("data-emotion");
  759. if (dataEmotionAttribute.indexOf(" ") === -1) {
  760. return;
  761. }
  762. document.head.appendChild(node2);
  763. node2.setAttribute("data-s", "");
  764. });
  765. }
  766. var stylisPlugins = options.stylisPlugins || defaultStylisPlugins;
  767. var inserted = {};
  768. var container;
  769. var nodesToHydrate = [];
  770. {
  771. container = options.container || document.head;
  772. Array.prototype.forEach.call(
  773. // this means we will ignore elements which don't have a space in them which
  774. // means that the style elements we're looking at are only Emotion 11 server-rendered style elements
  775. document.querySelectorAll('style[data-emotion^="' + key + ' "]'),
  776. function(node2) {
  777. var attrib = node2.getAttribute("data-emotion").split(" ");
  778. for (var i = 1; i < attrib.length; i++) {
  779. inserted[attrib[i]] = true;
  780. }
  781. nodesToHydrate.push(node2);
  782. }
  783. );
  784. }
  785. var _insert;
  786. var omnipresentPlugins = [compat, removeLabel];
  787. {
  788. var currentSheet;
  789. var finalizingPlugins = [stringify, rulesheet(function(rule) {
  790. currentSheet.insert(rule);
  791. })];
  792. var serializer = middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins));
  793. var stylis = function stylis2(styles) {
  794. return serialize(compile(styles), serializer);
  795. };
  796. _insert = function insert(selector, serialized, sheet, shouldCache) {
  797. currentSheet = sheet;
  798. stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
  799. if (shouldCache) {
  800. cache.inserted[serialized.name] = true;
  801. }
  802. };
  803. }
  804. var cache = {
  805. key,
  806. sheet: new StyleSheet({
  807. key,
  808. container,
  809. nonce: options.nonce,
  810. speedy: options.speedy,
  811. prepend: options.prepend,
  812. insertionPoint: options.insertionPoint
  813. }),
  814. nonce: options.nonce,
  815. inserted,
  816. registered: {},
  817. insert: _insert
  818. };
  819. cache.sheet.hydrate(nodesToHydrate);
  820. return cache;
  821. };
  822. var reactIs$1 = { exports: {} };
  823. var reactIs_production_min = {};
  824. /** @license React v16.13.1
  825. * react-is.production.min.js
  826. *
  827. * Copyright (c) Facebook, Inc. and its affiliates.
  828. *
  829. * This source code is licensed under the MIT license found in the
  830. * LICENSE file in the root directory of this source tree.
  831. */
  832. var b = "function" === typeof Symbol && Symbol.for, c = b ? Symbol.for("react.element") : 60103, d = b ? Symbol.for("react.portal") : 60106, e = b ? Symbol.for("react.fragment") : 60107, f = b ? Symbol.for("react.strict_mode") : 60108, g = b ? Symbol.for("react.profiler") : 60114, h = b ? Symbol.for("react.provider") : 60109, k = b ? Symbol.for("react.context") : 60110, l = b ? Symbol.for("react.async_mode") : 60111, m = b ? Symbol.for("react.concurrent_mode") : 60111, n = b ? Symbol.for("react.forward_ref") : 60112, p = b ? Symbol.for("react.suspense") : 60113, q = b ? Symbol.for("react.suspense_list") : 60120, r$1 = b ? Symbol.for("react.memo") : 60115, t = b ? Symbol.for("react.lazy") : 60116, v = b ? Symbol.for("react.block") : 60121, w = b ? Symbol.for("react.fundamental") : 60117, x = b ? Symbol.for("react.responder") : 60118, y = b ? Symbol.for("react.scope") : 60119;
  833. function z(a) {
  834. if ("object" === typeof a && null !== a) {
  835. var u = a.$$typeof;
  836. switch (u) {
  837. case c:
  838. switch (a = a.type, a) {
  839. case l:
  840. case m:
  841. case e:
  842. case g:
  843. case f:
  844. case p:
  845. return a;
  846. default:
  847. switch (a = a && a.$$typeof, a) {
  848. case k:
  849. case n:
  850. case t:
  851. case r$1:
  852. case h:
  853. return a;
  854. default:
  855. return u;
  856. }
  857. }
  858. case d:
  859. return u;
  860. }
  861. }
  862. }
  863. function A(a) {
  864. return z(a) === m;
  865. }
  866. reactIs_production_min.AsyncMode = l;
  867. reactIs_production_min.ConcurrentMode = m;
  868. reactIs_production_min.ContextConsumer = k;
  869. reactIs_production_min.ContextProvider = h;
  870. reactIs_production_min.Element = c;
  871. reactIs_production_min.ForwardRef = n;
  872. reactIs_production_min.Fragment = e;
  873. reactIs_production_min.Lazy = t;
  874. reactIs_production_min.Memo = r$1;
  875. reactIs_production_min.Portal = d;
  876. reactIs_production_min.Profiler = g;
  877. reactIs_production_min.StrictMode = f;
  878. reactIs_production_min.Suspense = p;
  879. reactIs_production_min.isAsyncMode = function(a) {
  880. return A(a) || z(a) === l;
  881. };
  882. reactIs_production_min.isConcurrentMode = A;
  883. reactIs_production_min.isContextConsumer = function(a) {
  884. return z(a) === k;
  885. };
  886. reactIs_production_min.isContextProvider = function(a) {
  887. return z(a) === h;
  888. };
  889. reactIs_production_min.isElement = function(a) {
  890. return "object" === typeof a && null !== a && a.$$typeof === c;
  891. };
  892. reactIs_production_min.isForwardRef = function(a) {
  893. return z(a) === n;
  894. };
  895. reactIs_production_min.isFragment = function(a) {
  896. return z(a) === e;
  897. };
  898. reactIs_production_min.isLazy = function(a) {
  899. return z(a) === t;
  900. };
  901. reactIs_production_min.isMemo = function(a) {
  902. return z(a) === r$1;
  903. };
  904. reactIs_production_min.isPortal = function(a) {
  905. return z(a) === d;
  906. };
  907. reactIs_production_min.isProfiler = function(a) {
  908. return z(a) === g;
  909. };
  910. reactIs_production_min.isStrictMode = function(a) {
  911. return z(a) === f;
  912. };
  913. reactIs_production_min.isSuspense = function(a) {
  914. return z(a) === p;
  915. };
  916. reactIs_production_min.isValidElementType = function(a) {
  917. return "string" === typeof a || "function" === typeof a || a === e || a === m || a === g || a === f || a === p || a === q || "object" === typeof a && null !== a && (a.$$typeof === t || a.$$typeof === r$1 || a.$$typeof === h || a.$$typeof === k || a.$$typeof === n || a.$$typeof === w || a.$$typeof === x || a.$$typeof === y || a.$$typeof === v);
  918. };
  919. reactIs_production_min.typeOf = z;
  920. {
  921. reactIs$1.exports = reactIs_production_min;
  922. }
  923. var reactIsExports = reactIs$1.exports;
  924. var reactIs = reactIsExports;
  925. var FORWARD_REF_STATICS = {
  926. "$$typeof": true,
  927. render: true,
  928. defaultProps: true,
  929. displayName: true,
  930. propTypes: true
  931. };
  932. var MEMO_STATICS = {
  933. "$$typeof": true,
  934. compare: true,
  935. defaultProps: true,
  936. displayName: true,
  937. propTypes: true,
  938. type: true
  939. };
  940. var TYPE_STATICS = {};
  941. TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
  942. TYPE_STATICS[reactIs.Memo] = MEMO_STATICS;
  943. var isBrowser = true;
  944. function getRegisteredStyles(registered, registeredStyles, classNames) {
  945. var rawClassName = "";
  946. classNames.split(" ").forEach(function(className) {
  947. if (registered[className] !== void 0) {
  948. registeredStyles.push(registered[className] + ";");
  949. } else if (className) {
  950. rawClassName += className + " ";
  951. }
  952. });
  953. return rawClassName;
  954. }
  955. var registerStyles = function registerStyles2(cache, serialized, isStringTag2) {
  956. var className = cache.key + "-" + serialized.name;
  957. if (
  958. // we only need to add the styles to the registered cache if the
  959. // class name could be used further down
  960. // the tree but if it's a string tag, we know it won't
  961. // so we don't have to add it to registered cache.
  962. // this improves memory usage since we can avoid storing the whole style string
  963. (isStringTag2 === false || // we need to always store it if we're in compat mode and
  964. // in node since emotion-server relies on whether a style is in
  965. // the registered cache to know whether a style is global or not
  966. // also, note that this check will be dead code eliminated in the browser
  967. isBrowser === false) && cache.registered[className] === void 0
  968. ) {
  969. cache.registered[className] = serialized.styles;
  970. }
  971. };
  972. var insertStyles = function insertStyles2(cache, serialized, isStringTag2) {
  973. registerStyles(cache, serialized, isStringTag2);
  974. var className = cache.key + "-" + serialized.name;
  975. if (cache.inserted[serialized.name] === void 0) {
  976. var current = serialized;
  977. do {
  978. cache.insert(serialized === current ? "." + className : "", current, cache.sheet, true);
  979. current = current.next;
  980. } while (current !== void 0);
  981. }
  982. };
  983. function murmur2(str) {
  984. var h2 = 0;
  985. var k2, i = 0, len = str.length;
  986. for (; len >= 4; ++i, len -= 4) {
  987. k2 = str.charCodeAt(i) & 255 | (str.charCodeAt(++i) & 255) << 8 | (str.charCodeAt(++i) & 255) << 16 | (str.charCodeAt(++i) & 255) << 24;
  988. k2 = /* Math.imul(k, m): */
  989. (k2 & 65535) * 1540483477 + ((k2 >>> 16) * 59797 << 16);
  990. k2 ^= /* k >>> r: */
  991. k2 >>> 24;
  992. h2 = /* Math.imul(k, m): */
  993. (k2 & 65535) * 1540483477 + ((k2 >>> 16) * 59797 << 16) ^ /* Math.imul(h, m): */
  994. (h2 & 65535) * 1540483477 + ((h2 >>> 16) * 59797 << 16);
  995. }
  996. switch (len) {
  997. case 3:
  998. h2 ^= (str.charCodeAt(i + 2) & 255) << 16;
  999. case 2:
  1000. h2 ^= (str.charCodeAt(i + 1) & 255) << 8;
  1001. case 1:
  1002. h2 ^= str.charCodeAt(i) & 255;
  1003. h2 = /* Math.imul(h, m): */
  1004. (h2 & 65535) * 1540483477 + ((h2 >>> 16) * 59797 << 16);
  1005. }
  1006. h2 ^= h2 >>> 13;
  1007. h2 = /* Math.imul(h, m): */
  1008. (h2 & 65535) * 1540483477 + ((h2 >>> 16) * 59797 << 16);
  1009. return ((h2 ^ h2 >>> 15) >>> 0).toString(36);
  1010. }
  1011. var unitlessKeys = {
  1012. animationIterationCount: 1,
  1013. aspectRatio: 1,
  1014. borderImageOutset: 1,
  1015. borderImageSlice: 1,
  1016. borderImageWidth: 1,
  1017. boxFlex: 1,
  1018. boxFlexGroup: 1,
  1019. boxOrdinalGroup: 1,
  1020. columnCount: 1,
  1021. columns: 1,
  1022. flex: 1,
  1023. flexGrow: 1,
  1024. flexPositive: 1,
  1025. flexShrink: 1,
  1026. flexNegative: 1,
  1027. flexOrder: 1,
  1028. gridRow: 1,
  1029. gridRowEnd: 1,
  1030. gridRowSpan: 1,
  1031. gridRowStart: 1,
  1032. gridColumn: 1,
  1033. gridColumnEnd: 1,
  1034. gridColumnSpan: 1,
  1035. gridColumnStart: 1,
  1036. msGridRow: 1,
  1037. msGridRowSpan: 1,
  1038. msGridColumn: 1,
  1039. msGridColumnSpan: 1,
  1040. fontWeight: 1,
  1041. lineHeight: 1,
  1042. opacity: 1,
  1043. order: 1,
  1044. orphans: 1,
  1045. scale: 1,
  1046. tabSize: 1,
  1047. widows: 1,
  1048. zIndex: 1,
  1049. zoom: 1,
  1050. WebkitLineClamp: 1,
  1051. // SVG-related properties
  1052. fillOpacity: 1,
  1053. floodOpacity: 1,
  1054. stopOpacity: 1,
  1055. strokeDasharray: 1,
  1056. strokeDashoffset: 1,
  1057. strokeMiterlimit: 1,
  1058. strokeOpacity: 1,
  1059. strokeWidth: 1
  1060. };
  1061. var isDevelopment$1 = false;
  1062. var hyphenateRegex = /[A-Z]|^ms/g;
  1063. var animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g;
  1064. var isCustomProperty = function isCustomProperty2(property) {
  1065. return property.charCodeAt(1) === 45;
  1066. };
  1067. var isProcessableValue = function isProcessableValue2(value) {
  1068. return value != null && typeof value !== "boolean";
  1069. };
  1070. var processStyleName = /* @__PURE__ */ memoize$1(function(styleName) {
  1071. return isCustomProperty(styleName) ? styleName : styleName.replace(hyphenateRegex, "-$&").toLowerCase();
  1072. });
  1073. var processStyleValue = function processStyleValue2(key, value) {
  1074. switch (key) {
  1075. case "animation":
  1076. case "animationName": {
  1077. if (typeof value === "string") {
  1078. return value.replace(animationRegex, function(match2, p1, p2) {
  1079. cursor = {
  1080. name: p1,
  1081. styles: p2,
  1082. next: cursor
  1083. };
  1084. return p1;
  1085. });
  1086. }
  1087. }
  1088. }
  1089. if (unitlessKeys[key] !== 1 && !isCustomProperty(key) && typeof value === "number" && value !== 0) {
  1090. return value + "px";
  1091. }
  1092. return value;
  1093. };
  1094. var noComponentSelectorMessage = "Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.";
  1095. function handleInterpolation(mergedProps, registered, interpolation) {
  1096. if (interpolation == null) {
  1097. return "";
  1098. }
  1099. var componentSelector = interpolation;
  1100. if (componentSelector.__emotion_styles !== void 0) {
  1101. return componentSelector;
  1102. }
  1103. switch (typeof interpolation) {
  1104. case "boolean": {
  1105. return "";
  1106. }
  1107. case "object": {
  1108. var keyframes3 = interpolation;
  1109. if (keyframes3.anim === 1) {
  1110. cursor = {
  1111. name: keyframes3.name,
  1112. styles: keyframes3.styles,
  1113. next: cursor
  1114. };
  1115. return keyframes3.name;
  1116. }
  1117. var serializedStyles = interpolation;
  1118. if (serializedStyles.styles !== void 0) {
  1119. var next2 = serializedStyles.next;
  1120. if (next2 !== void 0) {
  1121. while (next2 !== void 0) {
  1122. cursor = {
  1123. name: next2.name,
  1124. styles: next2.styles,
  1125. next: cursor
  1126. };
  1127. next2 = next2.next;
  1128. }
  1129. }
  1130. var styles = serializedStyles.styles + ";";
  1131. return styles;
  1132. }
  1133. return createStringFromObject(mergedProps, registered, interpolation);
  1134. }
  1135. case "function": {
  1136. if (mergedProps !== void 0) {
  1137. var previousCursor = cursor;
  1138. var result = interpolation(mergedProps);
  1139. cursor = previousCursor;
  1140. return handleInterpolation(mergedProps, registered, result);
  1141. }
  1142. break;
  1143. }
  1144. }
  1145. var asString = interpolation;
  1146. if (registered == null) {
  1147. return asString;
  1148. }
  1149. var cached = registered[asString];
  1150. return cached !== void 0 ? cached : asString;
  1151. }
  1152. function createStringFromObject(mergedProps, registered, obj) {
  1153. var string = "";
  1154. if (Array.isArray(obj)) {
  1155. for (var i = 0; i < obj.length; i++) {
  1156. string += handleInterpolation(mergedProps, registered, obj[i]) + ";";
  1157. }
  1158. } else {
  1159. for (var key in obj) {
  1160. var value = obj[key];
  1161. if (typeof value !== "object") {
  1162. var asString = value;
  1163. if (registered != null && registered[asString] !== void 0) {
  1164. string += key + "{" + registered[asString] + "}";
  1165. } else if (isProcessableValue(asString)) {
  1166. string += processStyleName(key) + ":" + processStyleValue(key, asString) + ";";
  1167. }
  1168. } else {
  1169. if (key === "NO_COMPONENT_SELECTOR" && isDevelopment$1) {
  1170. throw new Error(noComponentSelectorMessage);
  1171. }
  1172. if (Array.isArray(value) && typeof value[0] === "string" && (registered == null || registered[value[0]] === void 0)) {
  1173. for (var _i = 0; _i < value.length; _i++) {
  1174. if (isProcessableValue(value[_i])) {
  1175. string += processStyleName(key) + ":" + processStyleValue(key, value[_i]) + ";";
  1176. }
  1177. }
  1178. } else {
  1179. var interpolated = handleInterpolation(mergedProps, registered, value);
  1180. switch (key) {
  1181. case "animation":
  1182. case "animationName": {
  1183. string += processStyleName(key) + ":" + interpolated + ";";
  1184. break;
  1185. }
  1186. default: {
  1187. string += key + "{" + interpolated + "}";
  1188. }
  1189. }
  1190. }
  1191. }
  1192. }
  1193. }
  1194. return string;
  1195. }
  1196. var labelPattern = /label:\s*([^\s;{]+)\s*(;|$)/g;
  1197. var cursor;
  1198. function serializeStyles(args, registered, mergedProps) {
  1199. if (args.length === 1 && typeof args[0] === "object" && args[0] !== null && args[0].styles !== void 0) {
  1200. return args[0];
  1201. }
  1202. var stringMode = true;
  1203. var styles = "";
  1204. cursor = void 0;
  1205. var strings = args[0];
  1206. if (strings == null || strings.raw === void 0) {
  1207. stringMode = false;
  1208. styles += handleInterpolation(mergedProps, registered, strings);
  1209. } else {
  1210. var asTemplateStringsArr = strings;
  1211. styles += asTemplateStringsArr[0];
  1212. }
  1213. for (var i = 1; i < args.length; i++) {
  1214. styles += handleInterpolation(mergedProps, registered, args[i]);
  1215. if (stringMode) {
  1216. var templateStringsArr = strings;
  1217. styles += templateStringsArr[i];
  1218. }
  1219. }
  1220. labelPattern.lastIndex = 0;
  1221. var identifierName = "";
  1222. var match2;
  1223. while ((match2 = labelPattern.exec(styles)) !== null) {
  1224. identifierName += "-" + match2[1];
  1225. }
  1226. var name = murmur2(styles) + identifierName;
  1227. return {
  1228. name,
  1229. styles,
  1230. next: cursor
  1231. };
  1232. }
  1233. var syncFallback = function syncFallback2(create) {
  1234. return create();
  1235. };
  1236. var useInsertionEffect = React__namespace["useInsertionEffect"] ? React__namespace["useInsertionEffect"] : false;
  1237. var useInsertionEffectAlwaysWithSyncFallback = useInsertionEffect || syncFallback;
  1238. var EmotionCacheContext = /* @__PURE__ */ React__namespace.createContext(
  1239. // we're doing this to avoid preconstruct's dead code elimination in this one case
  1240. // because this module is primarily intended for the browser and node
  1241. // but it's also required in react native and similar environments sometimes
  1242. // and we could have a special build just for that
  1243. // but this is much easier and the native packages
  1244. // might use a different theme context in the future anyway
  1245. typeof HTMLElement !== "undefined" ? /* @__PURE__ */ createCache({
  1246. key: "css"
  1247. }) : null
  1248. );
  1249. EmotionCacheContext.Provider;
  1250. var withEmotionCache = function withEmotionCache2(func) {
  1251. return /* @__PURE__ */ React.forwardRef(function(props, ref) {
  1252. var cache = React.useContext(EmotionCacheContext);
  1253. return func(props, cache, ref);
  1254. });
  1255. };
  1256. var ThemeContext = /* @__PURE__ */ React__namespace.createContext({});
  1257. function css() {
  1258. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1259. args[_key] = arguments[_key];
  1260. }
  1261. return serializeStyles(args);
  1262. }
  1263. var keyframes = function keyframes2() {
  1264. var insertable = css.apply(void 0, arguments);
  1265. var name = "animation-" + insertable.name;
  1266. return {
  1267. name,
  1268. styles: "@keyframes " + name + "{" + insertable.styles + "}",
  1269. anim: 1,
  1270. toString: function toString3() {
  1271. return "_EMO_" + this.name + "_" + this.styles + "_EMO_";
  1272. }
  1273. };
  1274. };
  1275. var testOmitPropsOnStringTag = isPropValid;
  1276. var testOmitPropsOnComponent = function testOmitPropsOnComponent2(key) {
  1277. return key !== "theme";
  1278. };
  1279. var getDefaultShouldForwardProp = function getDefaultShouldForwardProp2(tag) {
  1280. return typeof tag === "string" && // 96 is one less than the char code
  1281. // for "a" so this is checking that
  1282. // it's a lowercase character
  1283. tag.charCodeAt(0) > 96 ? testOmitPropsOnStringTag : testOmitPropsOnComponent;
  1284. };
  1285. var composeShouldForwardProps = function composeShouldForwardProps2(tag, options, isReal) {
  1286. var shouldForwardProp2;
  1287. if (options) {
  1288. var optionsShouldForwardProp = options.shouldForwardProp;
  1289. shouldForwardProp2 = tag.__emotion_forwardProp && optionsShouldForwardProp ? function(propName) {
  1290. return tag.__emotion_forwardProp(propName) && optionsShouldForwardProp(propName);
  1291. } : optionsShouldForwardProp;
  1292. }
  1293. if (typeof shouldForwardProp2 !== "function" && isReal) {
  1294. shouldForwardProp2 = tag.__emotion_forwardProp;
  1295. }
  1296. return shouldForwardProp2;
  1297. };
  1298. var isDevelopment = false;
  1299. var Insertion = function Insertion2(_ref) {
  1300. var cache = _ref.cache, serialized = _ref.serialized, isStringTag2 = _ref.isStringTag;
  1301. registerStyles(cache, serialized, isStringTag2);
  1302. useInsertionEffectAlwaysWithSyncFallback(function() {
  1303. return insertStyles(cache, serialized, isStringTag2);
  1304. });
  1305. return null;
  1306. };
  1307. var createStyled$1 = function createStyled(tag, options) {
  1308. var isReal = tag.__emotion_real === tag;
  1309. var baseTag = isReal && tag.__emotion_base || tag;
  1310. var identifierName;
  1311. var targetClassName;
  1312. if (options !== void 0) {
  1313. identifierName = options.label;
  1314. targetClassName = options.target;
  1315. }
  1316. var shouldForwardProp2 = composeShouldForwardProps(tag, options, isReal);
  1317. var defaultShouldForwardProp = shouldForwardProp2 || getDefaultShouldForwardProp(baseTag);
  1318. var shouldUseAs = !defaultShouldForwardProp("as");
  1319. return function() {
  1320. var args = arguments;
  1321. var styles = isReal && tag.__emotion_styles !== void 0 ? tag.__emotion_styles.slice(0) : [];
  1322. if (identifierName !== void 0) {
  1323. styles.push("label:" + identifierName + ";");
  1324. }
  1325. if (args[0] == null || args[0].raw === void 0) {
  1326. styles.push.apply(styles, args);
  1327. } else {
  1328. styles.push(args[0][0]);
  1329. var len = args.length;
  1330. var i = 1;
  1331. for (; i < len; i++) {
  1332. styles.push(args[i], args[0][i]);
  1333. }
  1334. }
  1335. var Styled = withEmotionCache(function(props, cache, ref) {
  1336. var FinalTag = shouldUseAs && props.as || baseTag;
  1337. var className = "";
  1338. var classInterpolations = [];
  1339. var mergedProps = props;
  1340. if (props.theme == null) {
  1341. mergedProps = {};
  1342. for (var key in props) {
  1343. mergedProps[key] = props[key];
  1344. }
  1345. mergedProps.theme = React__namespace.useContext(ThemeContext);
  1346. }
  1347. if (typeof props.className === "string") {
  1348. className = getRegisteredStyles(cache.registered, classInterpolations, props.className);
  1349. } else if (props.className != null) {
  1350. className = props.className + " ";
  1351. }
  1352. var serialized = serializeStyles(styles.concat(classInterpolations), cache.registered, mergedProps);
  1353. className += cache.key + "-" + serialized.name;
  1354. if (targetClassName !== void 0) {
  1355. className += " " + targetClassName;
  1356. }
  1357. var finalShouldForwardProp = shouldUseAs && shouldForwardProp2 === void 0 ? getDefaultShouldForwardProp(FinalTag) : defaultShouldForwardProp;
  1358. var newProps = {};
  1359. for (var _key in props) {
  1360. if (shouldUseAs && _key === "as") continue;
  1361. if (finalShouldForwardProp(_key)) {
  1362. newProps[_key] = props[_key];
  1363. }
  1364. }
  1365. newProps.className = className;
  1366. if (ref) {
  1367. newProps.ref = ref;
  1368. }
  1369. return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(Insertion, {
  1370. cache,
  1371. serialized,
  1372. isStringTag: typeof FinalTag === "string"
  1373. }), /* @__PURE__ */ React__namespace.createElement(FinalTag, newProps));
  1374. });
  1375. Styled.displayName = identifierName !== void 0 ? identifierName : "Styled(" + (typeof baseTag === "string" ? baseTag : baseTag.displayName || baseTag.name || "Component") + ")";
  1376. Styled.defaultProps = tag.defaultProps;
  1377. Styled.__emotion_real = Styled;
  1378. Styled.__emotion_base = baseTag;
  1379. Styled.__emotion_styles = styles;
  1380. Styled.__emotion_forwardProp = shouldForwardProp2;
  1381. Object.defineProperty(Styled, "toString", {
  1382. value: function value() {
  1383. if (targetClassName === void 0 && isDevelopment) {
  1384. return "NO_COMPONENT_SELECTOR";
  1385. }
  1386. return "." + targetClassName;
  1387. }
  1388. });
  1389. Styled.withComponent = function(nextTag, nextOptions) {
  1390. return createStyled(nextTag, _extends({}, options, nextOptions, {
  1391. shouldForwardProp: composeShouldForwardProps(Styled, nextOptions, true)
  1392. })).apply(void 0, styles);
  1393. };
  1394. return Styled;
  1395. };
  1396. };
  1397. var tags = [
  1398. "a",
  1399. "abbr",
  1400. "address",
  1401. "area",
  1402. "article",
  1403. "aside",
  1404. "audio",
  1405. "b",
  1406. "base",
  1407. "bdi",
  1408. "bdo",
  1409. "big",
  1410. "blockquote",
  1411. "body",
  1412. "br",
  1413. "button",
  1414. "canvas",
  1415. "caption",
  1416. "cite",
  1417. "code",
  1418. "col",
  1419. "colgroup",
  1420. "data",
  1421. "datalist",
  1422. "dd",
  1423. "del",
  1424. "details",
  1425. "dfn",
  1426. "dialog",
  1427. "div",
  1428. "dl",
  1429. "dt",
  1430. "em",
  1431. "embed",
  1432. "fieldset",
  1433. "figcaption",
  1434. "figure",
  1435. "footer",
  1436. "form",
  1437. "h1",
  1438. "h2",
  1439. "h3",
  1440. "h4",
  1441. "h5",
  1442. "h6",
  1443. "head",
  1444. "header",
  1445. "hgroup",
  1446. "hr",
  1447. "html",
  1448. "i",
  1449. "iframe",
  1450. "img",
  1451. "input",
  1452. "ins",
  1453. "kbd",
  1454. "keygen",
  1455. "label",
  1456. "legend",
  1457. "li",
  1458. "link",
  1459. "main",
  1460. "map",
  1461. "mark",
  1462. "marquee",
  1463. "menu",
  1464. "menuitem",
  1465. "meta",
  1466. "meter",
  1467. "nav",
  1468. "noscript",
  1469. "object",
  1470. "ol",
  1471. "optgroup",
  1472. "option",
  1473. "output",
  1474. "p",
  1475. "param",
  1476. "picture",
  1477. "pre",
  1478. "progress",
  1479. "q",
  1480. "rp",
  1481. "rt",
  1482. "ruby",
  1483. "s",
  1484. "samp",
  1485. "script",
  1486. "section",
  1487. "select",
  1488. "small",
  1489. "source",
  1490. "span",
  1491. "strong",
  1492. "style",
  1493. "sub",
  1494. "summary",
  1495. "sup",
  1496. "table",
  1497. "tbody",
  1498. "td",
  1499. "textarea",
  1500. "tfoot",
  1501. "th",
  1502. "thead",
  1503. "time",
  1504. "title",
  1505. "tr",
  1506. "track",
  1507. "u",
  1508. "ul",
  1509. "var",
  1510. "video",
  1511. "wbr",
  1512. // SVG
  1513. "circle",
  1514. "clipPath",
  1515. "defs",
  1516. "ellipse",
  1517. "foreignObject",
  1518. "g",
  1519. "image",
  1520. "line",
  1521. "linearGradient",
  1522. "mask",
  1523. "path",
  1524. "pattern",
  1525. "polygon",
  1526. "polyline",
  1527. "radialGradient",
  1528. "rect",
  1529. "stop",
  1530. "svg",
  1531. "text",
  1532. "tspan"
  1533. ];
  1534. var newStyled = createStyled$1.bind();
  1535. tags.forEach(function(tagName) {
  1536. newStyled[tagName] = newStyled(tagName);
  1537. });
  1538. /**
  1539. * @mui/styled-engine v6.1.5
  1540. *
  1541. * @license MIT
  1542. * This source code is licensed under the MIT license found in the
  1543. * LICENSE file in the root directory of this source tree.
  1544. */
  1545. function styled$1(tag, options) {
  1546. const stylesFactory = newStyled(tag, options);
  1547. return stylesFactory;
  1548. }
  1549. function internal_mutateStyles(tag, processor) {
  1550. if (Array.isArray(tag.__emotion_styles)) {
  1551. tag.__emotion_styles = processor(tag.__emotion_styles);
  1552. }
  1553. }
  1554. const wrapper = [];
  1555. function internal_serializeStyles(styles) {
  1556. wrapper[0] = styles;
  1557. return serializeStyles(wrapper);
  1558. }
  1559. function isPlainObject$1(item) {
  1560. if (typeof item !== "object" || item === null) {
  1561. return false;
  1562. }
  1563. const prototype2 = Object.getPrototypeOf(item);
  1564. return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(Symbol.toStringTag in item) && !(Symbol.iterator in item);
  1565. }
  1566. function deepClone(source) {
  1567. if (!isPlainObject$1(source)) {
  1568. return source;
  1569. }
  1570. const output = {};
  1571. Object.keys(source).forEach((key) => {
  1572. output[key] = deepClone(source[key]);
  1573. });
  1574. return output;
  1575. }
  1576. function deepmerge(target, source, options = {
  1577. clone: true
  1578. }) {
  1579. const output = options.clone ? {
  1580. ...target
  1581. } : target;
  1582. if (isPlainObject$1(target) && isPlainObject$1(source)) {
  1583. Object.keys(source).forEach((key) => {
  1584. if (isPlainObject$1(source[key]) && // Avoid prototype pollution
  1585. Object.prototype.hasOwnProperty.call(target, key) && isPlainObject$1(target[key])) {
  1586. output[key] = deepmerge(target[key], source[key], options);
  1587. } else if (options.clone) {
  1588. output[key] = isPlainObject$1(source[key]) ? deepClone(source[key]) : source[key];
  1589. } else {
  1590. output[key] = source[key];
  1591. }
  1592. });
  1593. }
  1594. return output;
  1595. }
  1596. const sortBreakpointsValues = (values2) => {
  1597. const breakpointsAsArray = Object.keys(values2).map((key) => ({
  1598. key,
  1599. val: values2[key]
  1600. })) || [];
  1601. breakpointsAsArray.sort((breakpoint1, breakpoint2) => breakpoint1.val - breakpoint2.val);
  1602. return breakpointsAsArray.reduce((acc, obj) => {
  1603. return {
  1604. ...acc,
  1605. [obj.key]: obj.val
  1606. };
  1607. }, {});
  1608. };
  1609. function createBreakpoints(breakpoints) {
  1610. const {
  1611. // The breakpoint **start** at this value.
  1612. // For instance with the first breakpoint xs: [xs, sm).
  1613. values: values2 = {
  1614. xs: 0,
  1615. // phone
  1616. sm: 600,
  1617. // tablet
  1618. md: 900,
  1619. // small laptop
  1620. lg: 1200,
  1621. // desktop
  1622. xl: 1536
  1623. // large screen
  1624. },
  1625. unit = "px",
  1626. step = 5,
  1627. ...other
  1628. } = breakpoints;
  1629. const sortedValues = sortBreakpointsValues(values2);
  1630. const keys = Object.keys(sortedValues);
  1631. function up(key) {
  1632. const value = typeof values2[key] === "number" ? values2[key] : key;
  1633. return `@media (min-width:${value}${unit})`;
  1634. }
  1635. function down(key) {
  1636. const value = typeof values2[key] === "number" ? values2[key] : key;
  1637. return `@media (max-width:${value - step / 100}${unit})`;
  1638. }
  1639. function between(start, end) {
  1640. const endIndex = keys.indexOf(end);
  1641. return `@media (min-width:${typeof values2[start] === "number" ? values2[start] : start}${unit}) and (max-width:${(endIndex !== -1 && typeof values2[keys[endIndex]] === "number" ? values2[keys[endIndex]] : end) - step / 100}${unit})`;
  1642. }
  1643. function only(key) {
  1644. if (keys.indexOf(key) + 1 < keys.length) {
  1645. return between(key, keys[keys.indexOf(key) + 1]);
  1646. }
  1647. return up(key);
  1648. }
  1649. function not(key) {
  1650. const keyIndex = keys.indexOf(key);
  1651. if (keyIndex === 0) {
  1652. return up(keys[1]);
  1653. }
  1654. if (keyIndex === keys.length - 1) {
  1655. return down(keys[keyIndex]);
  1656. }
  1657. return between(key, keys[keys.indexOf(key) + 1]).replace("@media", "@media not all and");
  1658. }
  1659. return {
  1660. keys,
  1661. values: sortedValues,
  1662. up,
  1663. down,
  1664. between,
  1665. only,
  1666. not,
  1667. unit,
  1668. ...other
  1669. };
  1670. }
  1671. function sortContainerQueries(theme, css2) {
  1672. if (!theme.containerQueries) {
  1673. return css2;
  1674. }
  1675. const sorted = Object.keys(css2).filter((key) => key.startsWith("@container")).sort((a, b2) => {
  1676. var _a, _b;
  1677. const regex = /min-width:\s*([0-9.]+)/;
  1678. return +(((_a = a.match(regex)) == null ? void 0 : _a[1]) || 0) - +(((_b = b2.match(regex)) == null ? void 0 : _b[1]) || 0);
  1679. });
  1680. if (!sorted.length) {
  1681. return css2;
  1682. }
  1683. return sorted.reduce((acc, key) => {
  1684. const value = css2[key];
  1685. delete acc[key];
  1686. acc[key] = value;
  1687. return acc;
  1688. }, {
  1689. ...css2
  1690. });
  1691. }
  1692. function isCqShorthand(breakpointKeys, value) {
  1693. return value === "@" || value.startsWith("@") && (breakpointKeys.some((key) => value.startsWith(`@${key}`)) || !!value.match(/^@\d/));
  1694. }
  1695. function getContainerQuery(theme, shorthand) {
  1696. const matches = shorthand.match(/^@([^/]+)?\/?(.+)?$/);
  1697. if (!matches) {
  1698. return null;
  1699. }
  1700. const [, containerQuery, containerName] = matches;
  1701. const value = Number.isNaN(+containerQuery) ? containerQuery || 0 : +containerQuery;
  1702. return theme.containerQueries(containerName).up(value);
  1703. }
  1704. function cssContainerQueries(themeInput) {
  1705. const toContainerQuery = (mediaQuery, name) => mediaQuery.replace("@media", name ? `@container ${name}` : "@container");
  1706. function attachCq(node22, name) {
  1707. node22.up = (...args) => toContainerQuery(themeInput.breakpoints.up(...args), name);
  1708. node22.down = (...args) => toContainerQuery(themeInput.breakpoints.down(...args), name);
  1709. node22.between = (...args) => toContainerQuery(themeInput.breakpoints.between(...args), name);
  1710. node22.only = (...args) => toContainerQuery(themeInput.breakpoints.only(...args), name);
  1711. node22.not = (...args) => {
  1712. const result = toContainerQuery(themeInput.breakpoints.not(...args), name);
  1713. if (result.includes("not all and")) {
  1714. return result.replace("not all and ", "").replace("min-width:", "width<").replace("max-width:", "width>").replace("and", "or");
  1715. }
  1716. return result;
  1717. };
  1718. }
  1719. const node2 = {};
  1720. const containerQueries = (name) => {
  1721. attachCq(node2, name);
  1722. return node2;
  1723. };
  1724. attachCq(containerQueries);
  1725. return {
  1726. ...themeInput,
  1727. containerQueries
  1728. };
  1729. }
  1730. const shape = {
  1731. borderRadius: 4
  1732. };
  1733. function merge$1(acc, item) {
  1734. if (!item) {
  1735. return acc;
  1736. }
  1737. return deepmerge(acc, item, {
  1738. clone: false
  1739. // No need to clone deep, it's way faster.
  1740. });
  1741. }
  1742. const values$1 = {
  1743. xs: 0,
  1744. // phone
  1745. sm: 600,
  1746. // tablet
  1747. md: 900,
  1748. // small laptop
  1749. lg: 1200,
  1750. // desktop
  1751. xl: 1536
  1752. // large screen
  1753. };
  1754. const defaultBreakpoints = {
  1755. // Sorted ASC by size. That's important.
  1756. // It can't be configured as it's used statically for propTypes.
  1757. keys: ["xs", "sm", "md", "lg", "xl"],
  1758. up: (key) => `@media (min-width:${values$1[key]}px)`
  1759. };
  1760. const defaultContainerQueries = {
  1761. containerQueries: (containerName) => ({
  1762. up: (key) => {
  1763. let result = typeof key === "number" ? key : values$1[key] || key;
  1764. if (typeof result === "number") {
  1765. result = `${result}px`;
  1766. }
  1767. return containerName ? `@container ${containerName} (min-width:${result})` : `@container (min-width:${result})`;
  1768. }
  1769. })
  1770. };
  1771. function handleBreakpoints(props, propValue, styleFromPropValue) {
  1772. const theme = props.theme || {};
  1773. if (Array.isArray(propValue)) {
  1774. const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
  1775. return propValue.reduce((acc, item, index) => {
  1776. acc[themeBreakpoints.up(themeBreakpoints.keys[index])] = styleFromPropValue(propValue[index]);
  1777. return acc;
  1778. }, {});
  1779. }
  1780. if (typeof propValue === "object") {
  1781. const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
  1782. return Object.keys(propValue).reduce((acc, breakpoint) => {
  1783. if (isCqShorthand(themeBreakpoints.keys, breakpoint)) {
  1784. const containerKey = getContainerQuery(theme.containerQueries ? theme : defaultContainerQueries, breakpoint);
  1785. if (containerKey) {
  1786. acc[containerKey] = styleFromPropValue(propValue[breakpoint], breakpoint);
  1787. }
  1788. } else if (Object.keys(themeBreakpoints.values || values$1).includes(breakpoint)) {
  1789. const mediaKey = themeBreakpoints.up(breakpoint);
  1790. acc[mediaKey] = styleFromPropValue(propValue[breakpoint], breakpoint);
  1791. } else {
  1792. const cssKey = breakpoint;
  1793. acc[cssKey] = propValue[cssKey];
  1794. }
  1795. return acc;
  1796. }, {});
  1797. }
  1798. const output = styleFromPropValue(propValue);
  1799. return output;
  1800. }
  1801. function createEmptyBreakpointObject(breakpointsInput = {}) {
  1802. var _a;
  1803. const breakpointsInOrder = (_a = breakpointsInput.keys) == null ? void 0 : _a.reduce((acc, key) => {
  1804. const breakpointStyleKey = breakpointsInput.up(key);
  1805. acc[breakpointStyleKey] = {};
  1806. return acc;
  1807. }, {});
  1808. return breakpointsInOrder || {};
  1809. }
  1810. function removeUnusedBreakpoints(breakpointKeys, style2) {
  1811. return breakpointKeys.reduce((acc, key) => {
  1812. const breakpointOutput = acc[key];
  1813. const isBreakpointUnused = !breakpointOutput || Object.keys(breakpointOutput).length === 0;
  1814. if (isBreakpointUnused) {
  1815. delete acc[key];
  1816. }
  1817. return acc;
  1818. }, style2);
  1819. }
  1820. function capitalize(string) {
  1821. if (typeof string !== "string") {
  1822. throw new Error(formatMuiErrorMessage(7));
  1823. }
  1824. return string.charAt(0).toUpperCase() + string.slice(1);
  1825. }
  1826. function getPath(obj, path, checkVars = true) {
  1827. if (!path || typeof path !== "string") {
  1828. return null;
  1829. }
  1830. if (obj && obj.vars && checkVars) {
  1831. const val = `vars.${path}`.split(".").reduce((acc, item) => acc && acc[item] ? acc[item] : null, obj);
  1832. if (val != null) {
  1833. return val;
  1834. }
  1835. }
  1836. return path.split(".").reduce((acc, item) => {
  1837. if (acc && acc[item] != null) {
  1838. return acc[item];
  1839. }
  1840. return null;
  1841. }, obj);
  1842. }
  1843. function getStyleValue(themeMapping, transform, propValueFinal, userValue = propValueFinal) {
  1844. let value;
  1845. if (typeof themeMapping === "function") {
  1846. value = themeMapping(propValueFinal);
  1847. } else if (Array.isArray(themeMapping)) {
  1848. value = themeMapping[propValueFinal] || userValue;
  1849. } else {
  1850. value = getPath(themeMapping, propValueFinal) || userValue;
  1851. }
  1852. if (transform) {
  1853. value = transform(value, userValue, themeMapping);
  1854. }
  1855. return value;
  1856. }
  1857. function style$1(options) {
  1858. const {
  1859. prop,
  1860. cssProperty = options.prop,
  1861. themeKey,
  1862. transform
  1863. } = options;
  1864. const fn = (props) => {
  1865. if (props[prop] == null) {
  1866. return null;
  1867. }
  1868. const propValue = props[prop];
  1869. const theme = props.theme;
  1870. const themeMapping = getPath(theme, themeKey) || {};
  1871. const styleFromPropValue = (propValueFinal) => {
  1872. let value = getStyleValue(themeMapping, transform, propValueFinal);
  1873. if (propValueFinal === value && typeof propValueFinal === "string") {
  1874. value = getStyleValue(themeMapping, transform, `${prop}${propValueFinal === "default" ? "" : capitalize(propValueFinal)}`, propValueFinal);
  1875. }
  1876. if (cssProperty === false) {
  1877. return value;
  1878. }
  1879. return {
  1880. [cssProperty]: value
  1881. };
  1882. };
  1883. return handleBreakpoints(props, propValue, styleFromPropValue);
  1884. };
  1885. fn.propTypes = {};
  1886. fn.filterProps = [prop];
  1887. return fn;
  1888. }
  1889. function memoize(fn) {
  1890. const cache = {};
  1891. return (arg2) => {
  1892. if (cache[arg2] === void 0) {
  1893. cache[arg2] = fn(arg2);
  1894. }
  1895. return cache[arg2];
  1896. };
  1897. }
  1898. const properties = {
  1899. m: "margin",
  1900. p: "padding"
  1901. };
  1902. const directions = {
  1903. t: "Top",
  1904. r: "Right",
  1905. b: "Bottom",
  1906. l: "Left",
  1907. x: ["Left", "Right"],
  1908. y: ["Top", "Bottom"]
  1909. };
  1910. const aliases = {
  1911. marginX: "mx",
  1912. marginY: "my",
  1913. paddingX: "px",
  1914. paddingY: "py"
  1915. };
  1916. const getCssProperties = memoize((prop) => {
  1917. if (prop.length > 2) {
  1918. if (aliases[prop]) {
  1919. prop = aliases[prop];
  1920. } else {
  1921. return [prop];
  1922. }
  1923. }
  1924. const [a, b2] = prop.split("");
  1925. const property = properties[a];
  1926. const direction = directions[b2] || "";
  1927. return Array.isArray(direction) ? direction.map((dir) => property + dir) : [property + direction];
  1928. });
  1929. const marginKeys = ["m", "mt", "mr", "mb", "ml", "mx", "my", "margin", "marginTop", "marginRight", "marginBottom", "marginLeft", "marginX", "marginY", "marginInline", "marginInlineStart", "marginInlineEnd", "marginBlock", "marginBlockStart", "marginBlockEnd"];
  1930. const paddingKeys = ["p", "pt", "pr", "pb", "pl", "px", "py", "padding", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "paddingX", "paddingY", "paddingInline", "paddingInlineStart", "paddingInlineEnd", "paddingBlock", "paddingBlockStart", "paddingBlockEnd"];
  1931. [...marginKeys, ...paddingKeys];
  1932. function createUnaryUnit(theme, themeKey, defaultValue, propName) {
  1933. const themeSpacing = getPath(theme, themeKey, true) ?? defaultValue;
  1934. if (typeof themeSpacing === "number" || typeof themeSpacing === "string") {
  1935. return (val) => {
  1936. if (typeof val === "string") {
  1937. return val;
  1938. }
  1939. if (typeof themeSpacing === "string") {
  1940. return `calc(${val} * ${themeSpacing})`;
  1941. }
  1942. return themeSpacing * val;
  1943. };
  1944. }
  1945. if (Array.isArray(themeSpacing)) {
  1946. return (val) => {
  1947. if (typeof val === "string") {
  1948. return val;
  1949. }
  1950. const abs2 = Math.abs(val);
  1951. const transformed = themeSpacing[abs2];
  1952. if (val >= 0) {
  1953. return transformed;
  1954. }
  1955. if (typeof transformed === "number") {
  1956. return -transformed;
  1957. }
  1958. return `-${transformed}`;
  1959. };
  1960. }
  1961. if (typeof themeSpacing === "function") {
  1962. return themeSpacing;
  1963. }
  1964. return () => void 0;
  1965. }
  1966. function createUnarySpacing(theme) {
  1967. return createUnaryUnit(theme, "spacing", 8);
  1968. }
  1969. function getValue(transformer, propValue) {
  1970. if (typeof propValue === "string" || propValue == null) {
  1971. return propValue;
  1972. }
  1973. return transformer(propValue);
  1974. }
  1975. function getStyleFromPropValue(cssProperties, transformer) {
  1976. return (propValue) => cssProperties.reduce((acc, cssProperty) => {
  1977. acc[cssProperty] = getValue(transformer, propValue);
  1978. return acc;
  1979. }, {});
  1980. }
  1981. function resolveCssProperty(props, keys, prop, transformer) {
  1982. if (!keys.includes(prop)) {
  1983. return null;
  1984. }
  1985. const cssProperties = getCssProperties(prop);
  1986. const styleFromPropValue = getStyleFromPropValue(cssProperties, transformer);
  1987. const propValue = props[prop];
  1988. return handleBreakpoints(props, propValue, styleFromPropValue);
  1989. }
  1990. function style(props, keys) {
  1991. const transformer = createUnarySpacing(props.theme);
  1992. return Object.keys(props).map((prop) => resolveCssProperty(props, keys, prop, transformer)).reduce(merge$1, {});
  1993. }
  1994. function margin(props) {
  1995. return style(props, marginKeys);
  1996. }
  1997. margin.propTypes = {};
  1998. margin.filterProps = marginKeys;
  1999. function padding(props) {
  2000. return style(props, paddingKeys);
  2001. }
  2002. padding.propTypes = {};
  2003. padding.filterProps = paddingKeys;
  2004. function createSpacing(spacingInput = 8, transform = createUnarySpacing({
  2005. spacing: spacingInput
  2006. })) {
  2007. if (spacingInput.mui) {
  2008. return spacingInput;
  2009. }
  2010. const spacing = (...argsInput) => {
  2011. const args = argsInput.length === 0 ? [1] : argsInput;
  2012. return args.map((argument) => {
  2013. const output = transform(argument);
  2014. return typeof output === "number" ? `${output}px` : output;
  2015. }).join(" ");
  2016. };
  2017. spacing.mui = true;
  2018. return spacing;
  2019. }
  2020. function compose(...styles) {
  2021. const handlers = styles.reduce((acc, style2) => {
  2022. style2.filterProps.forEach((prop) => {
  2023. acc[prop] = style2;
  2024. });
  2025. return acc;
  2026. }, {});
  2027. const fn = (props) => {
  2028. return Object.keys(props).reduce((acc, prop) => {
  2029. if (handlers[prop]) {
  2030. return merge$1(acc, handlers[prop](props));
  2031. }
  2032. return acc;
  2033. }, {});
  2034. };
  2035. fn.propTypes = {};
  2036. fn.filterProps = styles.reduce((acc, style2) => acc.concat(style2.filterProps), []);
  2037. return fn;
  2038. }
  2039. function borderTransform(value) {
  2040. if (typeof value !== "number") {
  2041. return value;
  2042. }
  2043. return `${value}px solid`;
  2044. }
  2045. function createBorderStyle(prop, transform) {
  2046. return style$1({
  2047. prop,
  2048. themeKey: "borders",
  2049. transform
  2050. });
  2051. }
  2052. const border = createBorderStyle("border", borderTransform);
  2053. const borderTop = createBorderStyle("borderTop", borderTransform);
  2054. const borderRight = createBorderStyle("borderRight", borderTransform);
  2055. const borderBottom = createBorderStyle("borderBottom", borderTransform);
  2056. const borderLeft = createBorderStyle("borderLeft", borderTransform);
  2057. const borderColor = createBorderStyle("borderColor");
  2058. const borderTopColor = createBorderStyle("borderTopColor");
  2059. const borderRightColor = createBorderStyle("borderRightColor");
  2060. const borderBottomColor = createBorderStyle("borderBottomColor");
  2061. const borderLeftColor = createBorderStyle("borderLeftColor");
  2062. const outline = createBorderStyle("outline", borderTransform);
  2063. const outlineColor = createBorderStyle("outlineColor");
  2064. const borderRadius = (props) => {
  2065. if (props.borderRadius !== void 0 && props.borderRadius !== null) {
  2066. const transformer = createUnaryUnit(props.theme, "shape.borderRadius", 4);
  2067. const styleFromPropValue = (propValue) => ({
  2068. borderRadius: getValue(transformer, propValue)
  2069. });
  2070. return handleBreakpoints(props, props.borderRadius, styleFromPropValue);
  2071. }
  2072. return null;
  2073. };
  2074. borderRadius.propTypes = {};
  2075. borderRadius.filterProps = ["borderRadius"];
  2076. compose(border, borderTop, borderRight, borderBottom, borderLeft, borderColor, borderTopColor, borderRightColor, borderBottomColor, borderLeftColor, borderRadius, outline, outlineColor);
  2077. const gap = (props) => {
  2078. if (props.gap !== void 0 && props.gap !== null) {
  2079. const transformer = createUnaryUnit(props.theme, "spacing", 8);
  2080. const styleFromPropValue = (propValue) => ({
  2081. gap: getValue(transformer, propValue)
  2082. });
  2083. return handleBreakpoints(props, props.gap, styleFromPropValue);
  2084. }
  2085. return null;
  2086. };
  2087. gap.propTypes = {};
  2088. gap.filterProps = ["gap"];
  2089. const columnGap = (props) => {
  2090. if (props.columnGap !== void 0 && props.columnGap !== null) {
  2091. const transformer = createUnaryUnit(props.theme, "spacing", 8);
  2092. const styleFromPropValue = (propValue) => ({
  2093. columnGap: getValue(transformer, propValue)
  2094. });
  2095. return handleBreakpoints(props, props.columnGap, styleFromPropValue);
  2096. }
  2097. return null;
  2098. };
  2099. columnGap.propTypes = {};
  2100. columnGap.filterProps = ["columnGap"];
  2101. const rowGap = (props) => {
  2102. if (props.rowGap !== void 0 && props.rowGap !== null) {
  2103. const transformer = createUnaryUnit(props.theme, "spacing", 8);
  2104. const styleFromPropValue = (propValue) => ({
  2105. rowGap: getValue(transformer, propValue)
  2106. });
  2107. return handleBreakpoints(props, props.rowGap, styleFromPropValue);
  2108. }
  2109. return null;
  2110. };
  2111. rowGap.propTypes = {};
  2112. rowGap.filterProps = ["rowGap"];
  2113. const gridColumn = style$1({
  2114. prop: "gridColumn"
  2115. });
  2116. const gridRow = style$1({
  2117. prop: "gridRow"
  2118. });
  2119. const gridAutoFlow = style$1({
  2120. prop: "gridAutoFlow"
  2121. });
  2122. const gridAutoColumns = style$1({
  2123. prop: "gridAutoColumns"
  2124. });
  2125. const gridAutoRows = style$1({
  2126. prop: "gridAutoRows"
  2127. });
  2128. const gridTemplateColumns = style$1({
  2129. prop: "gridTemplateColumns"
  2130. });
  2131. const gridTemplateRows = style$1({
  2132. prop: "gridTemplateRows"
  2133. });
  2134. const gridTemplateAreas = style$1({
  2135. prop: "gridTemplateAreas"
  2136. });
  2137. const gridArea = style$1({
  2138. prop: "gridArea"
  2139. });
  2140. compose(gap, columnGap, rowGap, gridColumn, gridRow, gridAutoFlow, gridAutoColumns, gridAutoRows, gridTemplateColumns, gridTemplateRows, gridTemplateAreas, gridArea);
  2141. function paletteTransform(value, userValue) {
  2142. if (userValue === "grey") {
  2143. return userValue;
  2144. }
  2145. return value;
  2146. }
  2147. const color = style$1({
  2148. prop: "color",
  2149. themeKey: "palette",
  2150. transform: paletteTransform
  2151. });
  2152. const bgcolor = style$1({
  2153. prop: "bgcolor",
  2154. cssProperty: "backgroundColor",
  2155. themeKey: "palette",
  2156. transform: paletteTransform
  2157. });
  2158. const backgroundColor = style$1({
  2159. prop: "backgroundColor",
  2160. themeKey: "palette",
  2161. transform: paletteTransform
  2162. });
  2163. compose(color, bgcolor, backgroundColor);
  2164. function sizingTransform(value) {
  2165. return value <= 1 && value !== 0 ? `${value * 100}%` : value;
  2166. }
  2167. const width = style$1({
  2168. prop: "width",
  2169. transform: sizingTransform
  2170. });
  2171. const maxWidth = (props) => {
  2172. if (props.maxWidth !== void 0 && props.maxWidth !== null) {
  2173. const styleFromPropValue = (propValue) => {
  2174. var _a, _b, _c, _d, _e;
  2175. const breakpoint = ((_c = (_b = (_a = props.theme) == null ? void 0 : _a.breakpoints) == null ? void 0 : _b.values) == null ? void 0 : _c[propValue]) || values$1[propValue];
  2176. if (!breakpoint) {
  2177. return {
  2178. maxWidth: sizingTransform(propValue)
  2179. };
  2180. }
  2181. if (((_e = (_d = props.theme) == null ? void 0 : _d.breakpoints) == null ? void 0 : _e.unit) !== "px") {
  2182. return {
  2183. maxWidth: `${breakpoint}${props.theme.breakpoints.unit}`
  2184. };
  2185. }
  2186. return {
  2187. maxWidth: breakpoint
  2188. };
  2189. };
  2190. return handleBreakpoints(props, props.maxWidth, styleFromPropValue);
  2191. }
  2192. return null;
  2193. };
  2194. maxWidth.filterProps = ["maxWidth"];
  2195. const minWidth = style$1({
  2196. prop: "minWidth",
  2197. transform: sizingTransform
  2198. });
  2199. const height = style$1({
  2200. prop: "height",
  2201. transform: sizingTransform
  2202. });
  2203. const maxHeight = style$1({
  2204. prop: "maxHeight",
  2205. transform: sizingTransform
  2206. });
  2207. const minHeight = style$1({
  2208. prop: "minHeight",
  2209. transform: sizingTransform
  2210. });
  2211. style$1({
  2212. prop: "size",
  2213. cssProperty: "width",
  2214. transform: sizingTransform
  2215. });
  2216. style$1({
  2217. prop: "size",
  2218. cssProperty: "height",
  2219. transform: sizingTransform
  2220. });
  2221. const boxSizing = style$1({
  2222. prop: "boxSizing"
  2223. });
  2224. compose(width, maxWidth, minWidth, height, maxHeight, minHeight, boxSizing);
  2225. const defaultSxConfig = {
  2226. // borders
  2227. border: {
  2228. themeKey: "borders",
  2229. transform: borderTransform
  2230. },
  2231. borderTop: {
  2232. themeKey: "borders",
  2233. transform: borderTransform
  2234. },
  2235. borderRight: {
  2236. themeKey: "borders",
  2237. transform: borderTransform
  2238. },
  2239. borderBottom: {
  2240. themeKey: "borders",
  2241. transform: borderTransform
  2242. },
  2243. borderLeft: {
  2244. themeKey: "borders",
  2245. transform: borderTransform
  2246. },
  2247. borderColor: {
  2248. themeKey: "palette"
  2249. },
  2250. borderTopColor: {
  2251. themeKey: "palette"
  2252. },
  2253. borderRightColor: {
  2254. themeKey: "palette"
  2255. },
  2256. borderBottomColor: {
  2257. themeKey: "palette"
  2258. },
  2259. borderLeftColor: {
  2260. themeKey: "palette"
  2261. },
  2262. outline: {
  2263. themeKey: "borders",
  2264. transform: borderTransform
  2265. },
  2266. outlineColor: {
  2267. themeKey: "palette"
  2268. },
  2269. borderRadius: {
  2270. themeKey: "shape.borderRadius",
  2271. style: borderRadius
  2272. },
  2273. // palette
  2274. color: {
  2275. themeKey: "palette",
  2276. transform: paletteTransform
  2277. },
  2278. bgcolor: {
  2279. themeKey: "palette",
  2280. cssProperty: "backgroundColor",
  2281. transform: paletteTransform
  2282. },
  2283. backgroundColor: {
  2284. themeKey: "palette",
  2285. transform: paletteTransform
  2286. },
  2287. // spacing
  2288. p: {
  2289. style: padding
  2290. },
  2291. pt: {
  2292. style: padding
  2293. },
  2294. pr: {
  2295. style: padding
  2296. },
  2297. pb: {
  2298. style: padding
  2299. },
  2300. pl: {
  2301. style: padding
  2302. },
  2303. px: {
  2304. style: padding
  2305. },
  2306. py: {
  2307. style: padding
  2308. },
  2309. padding: {
  2310. style: padding
  2311. },
  2312. paddingTop: {
  2313. style: padding
  2314. },
  2315. paddingRight: {
  2316. style: padding
  2317. },
  2318. paddingBottom: {
  2319. style: padding
  2320. },
  2321. paddingLeft: {
  2322. style: padding
  2323. },
  2324. paddingX: {
  2325. style: padding
  2326. },
  2327. paddingY: {
  2328. style: padding
  2329. },
  2330. paddingInline: {
  2331. style: padding
  2332. },
  2333. paddingInlineStart: {
  2334. style: padding
  2335. },
  2336. paddingInlineEnd: {
  2337. style: padding
  2338. },
  2339. paddingBlock: {
  2340. style: padding
  2341. },
  2342. paddingBlockStart: {
  2343. style: padding
  2344. },
  2345. paddingBlockEnd: {
  2346. style: padding
  2347. },
  2348. m: {
  2349. style: margin
  2350. },
  2351. mt: {
  2352. style: margin
  2353. },
  2354. mr: {
  2355. style: margin
  2356. },
  2357. mb: {
  2358. style: margin
  2359. },
  2360. ml: {
  2361. style: margin
  2362. },
  2363. mx: {
  2364. style: margin
  2365. },
  2366. my: {
  2367. style: margin
  2368. },
  2369. margin: {
  2370. style: margin
  2371. },
  2372. marginTop: {
  2373. style: margin
  2374. },
  2375. marginRight: {
  2376. style: margin
  2377. },
  2378. marginBottom: {
  2379. style: margin
  2380. },
  2381. marginLeft: {
  2382. style: margin
  2383. },
  2384. marginX: {
  2385. style: margin
  2386. },
  2387. marginY: {
  2388. style: margin
  2389. },
  2390. marginInline: {
  2391. style: margin
  2392. },
  2393. marginInlineStart: {
  2394. style: margin
  2395. },
  2396. marginInlineEnd: {
  2397. style: margin
  2398. },
  2399. marginBlock: {
  2400. style: margin
  2401. },
  2402. marginBlockStart: {
  2403. style: margin
  2404. },
  2405. marginBlockEnd: {
  2406. style: margin
  2407. },
  2408. // display
  2409. displayPrint: {
  2410. cssProperty: false,
  2411. transform: (value) => ({
  2412. "@media print": {
  2413. display: value
  2414. }
  2415. })
  2416. },
  2417. display: {},
  2418. overflow: {},
  2419. textOverflow: {},
  2420. visibility: {},
  2421. whiteSpace: {},
  2422. // flexbox
  2423. flexBasis: {},
  2424. flexDirection: {},
  2425. flexWrap: {},
  2426. justifyContent: {},
  2427. alignItems: {},
  2428. alignContent: {},
  2429. order: {},
  2430. flex: {},
  2431. flexGrow: {},
  2432. flexShrink: {},
  2433. alignSelf: {},
  2434. justifyItems: {},
  2435. justifySelf: {},
  2436. // grid
  2437. gap: {
  2438. style: gap
  2439. },
  2440. rowGap: {
  2441. style: rowGap
  2442. },
  2443. columnGap: {
  2444. style: columnGap
  2445. },
  2446. gridColumn: {},
  2447. gridRow: {},
  2448. gridAutoFlow: {},
  2449. gridAutoColumns: {},
  2450. gridAutoRows: {},
  2451. gridTemplateColumns: {},
  2452. gridTemplateRows: {},
  2453. gridTemplateAreas: {},
  2454. gridArea: {},
  2455. // positions
  2456. position: {},
  2457. zIndex: {
  2458. themeKey: "zIndex"
  2459. },
  2460. top: {},
  2461. right: {},
  2462. bottom: {},
  2463. left: {},
  2464. // shadows
  2465. boxShadow: {
  2466. themeKey: "shadows"
  2467. },
  2468. // sizing
  2469. width: {
  2470. transform: sizingTransform
  2471. },
  2472. maxWidth: {
  2473. style: maxWidth
  2474. },
  2475. minWidth: {
  2476. transform: sizingTransform
  2477. },
  2478. height: {
  2479. transform: sizingTransform
  2480. },
  2481. maxHeight: {
  2482. transform: sizingTransform
  2483. },
  2484. minHeight: {
  2485. transform: sizingTransform
  2486. },
  2487. boxSizing: {},
  2488. // typography
  2489. font: {
  2490. themeKey: "font"
  2491. },
  2492. fontFamily: {
  2493. themeKey: "typography"
  2494. },
  2495. fontSize: {
  2496. themeKey: "typography"
  2497. },
  2498. fontStyle: {
  2499. themeKey: "typography"
  2500. },
  2501. fontWeight: {
  2502. themeKey: "typography"
  2503. },
  2504. letterSpacing: {},
  2505. textTransform: {},
  2506. lineHeight: {},
  2507. textAlign: {},
  2508. typography: {
  2509. cssProperty: false,
  2510. themeKey: "typography"
  2511. }
  2512. };
  2513. function objectsHaveSameKeys(...objects) {
  2514. const allKeys = objects.reduce((keys, object) => keys.concat(Object.keys(object)), []);
  2515. const union = new Set(allKeys);
  2516. return objects.every((object) => union.size === Object.keys(object).length);
  2517. }
  2518. function callIfFn(maybeFn, arg2) {
  2519. return typeof maybeFn === "function" ? maybeFn(arg2) : maybeFn;
  2520. }
  2521. function unstable_createStyleFunctionSx() {
  2522. function getThemeValue(prop, val, theme, config) {
  2523. const props = {
  2524. [prop]: val,
  2525. theme
  2526. };
  2527. const options = config[prop];
  2528. if (!options) {
  2529. return {
  2530. [prop]: val
  2531. };
  2532. }
  2533. const {
  2534. cssProperty = prop,
  2535. themeKey,
  2536. transform,
  2537. style: style2
  2538. } = options;
  2539. if (val == null) {
  2540. return null;
  2541. }
  2542. if (themeKey === "typography" && val === "inherit") {
  2543. return {
  2544. [prop]: val
  2545. };
  2546. }
  2547. const themeMapping = getPath(theme, themeKey) || {};
  2548. if (style2) {
  2549. return style2(props);
  2550. }
  2551. const styleFromPropValue = (propValueFinal) => {
  2552. let value = getStyleValue(themeMapping, transform, propValueFinal);
  2553. if (propValueFinal === value && typeof propValueFinal === "string") {
  2554. value = getStyleValue(themeMapping, transform, `${prop}${propValueFinal === "default" ? "" : capitalize(propValueFinal)}`, propValueFinal);
  2555. }
  2556. if (cssProperty === false) {
  2557. return value;
  2558. }
  2559. return {
  2560. [cssProperty]: value
  2561. };
  2562. };
  2563. return handleBreakpoints(props, val, styleFromPropValue);
  2564. }
  2565. function styleFunctionSx2(props) {
  2566. const {
  2567. sx,
  2568. theme = {}
  2569. } = props || {};
  2570. if (!sx) {
  2571. return null;
  2572. }
  2573. const config = theme.unstable_sxConfig ?? defaultSxConfig;
  2574. function traverse(sxInput) {
  2575. let sxObject = sxInput;
  2576. if (typeof sxInput === "function") {
  2577. sxObject = sxInput(theme);
  2578. } else if (typeof sxInput !== "object") {
  2579. return sxInput;
  2580. }
  2581. if (!sxObject) {
  2582. return null;
  2583. }
  2584. const emptyBreakpoints = createEmptyBreakpointObject(theme.breakpoints);
  2585. const breakpointsKeys = Object.keys(emptyBreakpoints);
  2586. let css2 = emptyBreakpoints;
  2587. Object.keys(sxObject).forEach((styleKey) => {
  2588. const value = callIfFn(sxObject[styleKey], theme);
  2589. if (value !== null && value !== void 0) {
  2590. if (typeof value === "object") {
  2591. if (config[styleKey]) {
  2592. css2 = merge$1(css2, getThemeValue(styleKey, value, theme, config));
  2593. } else {
  2594. const breakpointsValues = handleBreakpoints({
  2595. theme
  2596. }, value, (x2) => ({
  2597. [styleKey]: x2
  2598. }));
  2599. if (objectsHaveSameKeys(breakpointsValues, value)) {
  2600. css2[styleKey] = styleFunctionSx2({
  2601. sx: value,
  2602. theme
  2603. });
  2604. } else {
  2605. css2 = merge$1(css2, breakpointsValues);
  2606. }
  2607. }
  2608. } else {
  2609. css2 = merge$1(css2, getThemeValue(styleKey, value, theme, config));
  2610. }
  2611. }
  2612. });
  2613. return sortContainerQueries(theme, removeUnusedBreakpoints(breakpointsKeys, css2));
  2614. }
  2615. return Array.isArray(sx) ? sx.map(traverse) : traverse(sx);
  2616. }
  2617. return styleFunctionSx2;
  2618. }
  2619. const styleFunctionSx = unstable_createStyleFunctionSx();
  2620. styleFunctionSx.filterProps = ["sx"];
  2621. function applyStyles(key, styles) {
  2622. var _a;
  2623. const theme = this;
  2624. if (theme.vars) {
  2625. if (!((_a = theme.colorSchemes) == null ? void 0 : _a[key]) || typeof theme.getColorSchemeSelector !== "function") {
  2626. return {};
  2627. }
  2628. let selector = theme.getColorSchemeSelector(key);
  2629. if (selector === "&") {
  2630. return styles;
  2631. }
  2632. if (selector.includes("data-") || selector.includes(".")) {
  2633. selector = `*:where(${selector.replace(/\s*&$/, "")}) &`;
  2634. }
  2635. return {
  2636. [selector]: styles
  2637. };
  2638. }
  2639. if (theme.palette.mode === key) {
  2640. return styles;
  2641. }
  2642. return {};
  2643. }
  2644. function createTheme$1(options = {}, ...args) {
  2645. const {
  2646. breakpoints: breakpointsInput = {},
  2647. palette: paletteInput = {},
  2648. spacing: spacingInput,
  2649. shape: shapeInput = {},
  2650. ...other
  2651. } = options;
  2652. const breakpoints = createBreakpoints(breakpointsInput);
  2653. const spacing = createSpacing(spacingInput);
  2654. let muiTheme = deepmerge({
  2655. breakpoints,
  2656. direction: "ltr",
  2657. components: {},
  2658. // Inject component definitions.
  2659. palette: {
  2660. mode: "light",
  2661. ...paletteInput
  2662. },
  2663. spacing,
  2664. shape: {
  2665. ...shape,
  2666. ...shapeInput
  2667. }
  2668. }, other);
  2669. muiTheme = cssContainerQueries(muiTheme);
  2670. muiTheme.applyStyles = applyStyles;
  2671. muiTheme = args.reduce((acc, argument) => deepmerge(acc, argument), muiTheme);
  2672. muiTheme.unstable_sxConfig = {
  2673. ...defaultSxConfig,
  2674. ...other == null ? void 0 : other.unstable_sxConfig
  2675. };
  2676. muiTheme.unstable_sx = function sx(props) {
  2677. return styleFunctionSx({
  2678. sx: props,
  2679. theme: this
  2680. });
  2681. };
  2682. return muiTheme;
  2683. }
  2684. function isObjectEmpty$1(obj) {
  2685. return Object.keys(obj).length === 0;
  2686. }
  2687. function useTheme$1(defaultTheme2 = null) {
  2688. const contextTheme = React__namespace.useContext(ThemeContext);
  2689. return !contextTheme || isObjectEmpty$1(contextTheme) ? defaultTheme2 : contextTheme;
  2690. }
  2691. const systemDefaultTheme$1 = createTheme$1();
  2692. function useTheme(defaultTheme2 = systemDefaultTheme$1) {
  2693. return useTheme$1(defaultTheme2);
  2694. }
  2695. const splitProps = (props) => {
  2696. var _a;
  2697. const result = {
  2698. systemProps: {},
  2699. otherProps: {}
  2700. };
  2701. const config = ((_a = props == null ? void 0 : props.theme) == null ? void 0 : _a.unstable_sxConfig) ?? defaultSxConfig;
  2702. Object.keys(props).forEach((prop) => {
  2703. if (config[prop]) {
  2704. result.systemProps[prop] = props[prop];
  2705. } else {
  2706. result.otherProps[prop] = props[prop];
  2707. }
  2708. });
  2709. return result;
  2710. };
  2711. function extendSxProp(props) {
  2712. const {
  2713. sx: inSx,
  2714. ...other
  2715. } = props;
  2716. const {
  2717. systemProps,
  2718. otherProps
  2719. } = splitProps(other);
  2720. let finalSx;
  2721. if (Array.isArray(inSx)) {
  2722. finalSx = [systemProps, ...inSx];
  2723. } else if (typeof inSx === "function") {
  2724. finalSx = (...args) => {
  2725. const result = inSx(...args);
  2726. if (!isPlainObject$1(result)) {
  2727. return systemProps;
  2728. }
  2729. return {
  2730. ...systemProps,
  2731. ...result
  2732. };
  2733. };
  2734. } else {
  2735. finalSx = {
  2736. ...systemProps,
  2737. ...inSx
  2738. };
  2739. }
  2740. return {
  2741. ...otherProps,
  2742. sx: finalSx
  2743. };
  2744. }
  2745. const defaultGenerator = (componentName) => componentName;
  2746. const createClassNameGenerator = () => {
  2747. let generate = defaultGenerator;
  2748. return {
  2749. configure(generator) {
  2750. generate = generator;
  2751. },
  2752. generate(componentName) {
  2753. return generate(componentName);
  2754. },
  2755. reset() {
  2756. generate = defaultGenerator;
  2757. }
  2758. };
  2759. };
  2760. const ClassNameGenerator = createClassNameGenerator();
  2761. function r(e2) {
  2762. var t2, f2, n2 = "";
  2763. if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
  2764. else if ("object" == typeof e2) if (Array.isArray(e2)) {
  2765. var o = e2.length;
  2766. for (t2 = 0; t2 < o; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
  2767. } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
  2768. return n2;
  2769. }
  2770. function clsx() {
  2771. for (var e2, t2, f2 = 0, n2 = "", o = arguments.length; f2 < o; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
  2772. return n2;
  2773. }
  2774. function createBox(options = {}) {
  2775. const {
  2776. themeId,
  2777. defaultTheme: defaultTheme2,
  2778. defaultClassName = "MuiBox-root",
  2779. generateClassName
  2780. } = options;
  2781. const BoxRoot = styled$1("div", {
  2782. shouldForwardProp: (prop) => prop !== "theme" && prop !== "sx" && prop !== "as"
  2783. })(styleFunctionSx);
  2784. const Box2 = /* @__PURE__ */ React__namespace.forwardRef(function Box3(inProps, ref) {
  2785. const theme = useTheme(defaultTheme2);
  2786. const {
  2787. className,
  2788. component = "div",
  2789. ...other
  2790. } = extendSxProp(inProps);
  2791. return /* @__PURE__ */ jsxRuntimeExports.jsx(BoxRoot, {
  2792. as: component,
  2793. ref,
  2794. className: clsx(className, generateClassName ? generateClassName(defaultClassName) : defaultClassName),
  2795. theme: themeId ? theme[themeId] || theme : theme,
  2796. ...other
  2797. });
  2798. });
  2799. return Box2;
  2800. }
  2801. const globalStateClasses = {
  2802. active: "active",
  2803. checked: "checked",
  2804. completed: "completed",
  2805. disabled: "disabled",
  2806. error: "error",
  2807. expanded: "expanded",
  2808. focused: "focused",
  2809. focusVisible: "focusVisible",
  2810. open: "open",
  2811. readOnly: "readOnly",
  2812. required: "required",
  2813. selected: "selected"
  2814. };
  2815. function generateUtilityClass(componentName, slot, globalStatePrefix = "Mui") {
  2816. const globalStateClass = globalStateClasses[slot];
  2817. return globalStateClass ? `${globalStatePrefix}-${globalStateClass}` : `${ClassNameGenerator.generate(componentName)}-${slot}`;
  2818. }
  2819. function generateUtilityClasses(componentName, slots, globalStatePrefix = "Mui") {
  2820. const result = {};
  2821. slots.forEach((slot) => {
  2822. result[slot] = generateUtilityClass(componentName, slot, globalStatePrefix);
  2823. });
  2824. return result;
  2825. }
  2826. function preprocessStyles(input) {
  2827. const {
  2828. variants,
  2829. ...style2
  2830. } = input;
  2831. const result = {
  2832. variants,
  2833. style: internal_serializeStyles(style2),
  2834. isProcessed: true
  2835. };
  2836. if (result.style === style2) {
  2837. return result;
  2838. }
  2839. if (variants) {
  2840. variants.forEach((variant) => {
  2841. if (typeof variant.style !== "function") {
  2842. variant.style = internal_serializeStyles(variant.style);
  2843. }
  2844. });
  2845. }
  2846. return result;
  2847. }
  2848. const systemDefaultTheme = createTheme$1();
  2849. function shouldForwardProp(prop) {
  2850. return prop !== "ownerState" && prop !== "theme" && prop !== "sx" && prop !== "as";
  2851. }
  2852. function defaultOverridesResolver(slot) {
  2853. if (!slot) {
  2854. return null;
  2855. }
  2856. return (_props, styles) => styles[slot];
  2857. }
  2858. function attachTheme(props, themeId, defaultTheme2) {
  2859. props.theme = isObjectEmpty(props.theme) ? defaultTheme2 : props.theme[themeId] || props.theme;
  2860. }
  2861. function processStyle(props, style2) {
  2862. const resolvedStyle = typeof style2 === "function" ? style2(props) : style2;
  2863. if (Array.isArray(resolvedStyle)) {
  2864. return resolvedStyle.flatMap((subStyle) => processStyle(props, subStyle));
  2865. }
  2866. if (Array.isArray(resolvedStyle == null ? void 0 : resolvedStyle.variants)) {
  2867. let rootStyle;
  2868. if (resolvedStyle.isProcessed) {
  2869. rootStyle = resolvedStyle.style;
  2870. } else {
  2871. const {
  2872. variants,
  2873. ...otherStyles
  2874. } = resolvedStyle;
  2875. rootStyle = otherStyles;
  2876. }
  2877. return processStyleVariants(props, resolvedStyle.variants, [rootStyle]);
  2878. }
  2879. if (resolvedStyle == null ? void 0 : resolvedStyle.isProcessed) {
  2880. return resolvedStyle.style;
  2881. }
  2882. return resolvedStyle;
  2883. }
  2884. function processStyleVariants(props, variants, results = []) {
  2885. var _a;
  2886. let mergedState;
  2887. variantLoop: for (let i = 0; i < variants.length; i += 1) {
  2888. const variant = variants[i];
  2889. if (typeof variant.props === "function") {
  2890. mergedState ?? (mergedState = {
  2891. ...props,
  2892. ...props.ownerState,
  2893. ownerState: props.ownerState
  2894. });
  2895. if (!variant.props(mergedState)) {
  2896. continue;
  2897. }
  2898. } else {
  2899. for (const key in variant.props) {
  2900. if (props[key] !== variant.props[key] && ((_a = props.ownerState) == null ? void 0 : _a[key]) !== variant.props[key]) {
  2901. continue variantLoop;
  2902. }
  2903. }
  2904. }
  2905. if (typeof variant.style === "function") {
  2906. mergedState ?? (mergedState = {
  2907. ...props,
  2908. ...props.ownerState,
  2909. ownerState: props.ownerState
  2910. });
  2911. results.push(variant.style(mergedState));
  2912. } else {
  2913. results.push(variant.style);
  2914. }
  2915. }
  2916. return results;
  2917. }
  2918. function createStyled2(input = {}) {
  2919. const {
  2920. themeId,
  2921. defaultTheme: defaultTheme2 = systemDefaultTheme,
  2922. rootShouldForwardProp: rootShouldForwardProp2 = shouldForwardProp,
  2923. slotShouldForwardProp: slotShouldForwardProp2 = shouldForwardProp
  2924. } = input;
  2925. function styleAttachTheme(props) {
  2926. attachTheme(props, themeId, defaultTheme2);
  2927. }
  2928. const styled2 = (tag, inputOptions = {}) => {
  2929. internal_mutateStyles(tag, (styles) => styles.filter((style2) => style2 !== styleFunctionSx));
  2930. const {
  2931. name: componentName,
  2932. slot: componentSlot,
  2933. skipVariantsResolver: inputSkipVariantsResolver,
  2934. skipSx: inputSkipSx,
  2935. // TODO v6: remove `lowercaseFirstLetter()` in the next major release
  2936. // For more details: https://github.com/mui/material-ui/pull/37908
  2937. overridesResolver = defaultOverridesResolver(lowercaseFirstLetter(componentSlot)),
  2938. ...options
  2939. } = inputOptions;
  2940. const skipVariantsResolver = inputSkipVariantsResolver !== void 0 ? inputSkipVariantsResolver : (
  2941. // TODO v6: remove `Root` in the next major release
  2942. // For more details: https://github.com/mui/material-ui/pull/37908
  2943. componentSlot && componentSlot !== "Root" && componentSlot !== "root" || false
  2944. );
  2945. const skipSx = inputSkipSx || false;
  2946. let shouldForwardPropOption = shouldForwardProp;
  2947. if (componentSlot === "Root" || componentSlot === "root") {
  2948. shouldForwardPropOption = rootShouldForwardProp2;
  2949. } else if (componentSlot) {
  2950. shouldForwardPropOption = slotShouldForwardProp2;
  2951. } else if (isStringTag(tag)) {
  2952. shouldForwardPropOption = void 0;
  2953. }
  2954. const defaultStyledResolver = styled$1(tag, {
  2955. shouldForwardProp: shouldForwardPropOption,
  2956. label: generateStyledLabel(),
  2957. ...options
  2958. });
  2959. const transformStyle = (style2) => {
  2960. if (typeof style2 === "function" && style2.__emotion_real !== style2) {
  2961. return function styleFunctionProcessor(props) {
  2962. return processStyle(props, style2);
  2963. };
  2964. }
  2965. if (isPlainObject$1(style2)) {
  2966. const serialized = preprocessStyles(style2);
  2967. if (!serialized.variants) {
  2968. return serialized.style;
  2969. }
  2970. return function styleObjectProcessor(props) {
  2971. return processStyle(props, serialized);
  2972. };
  2973. }
  2974. return style2;
  2975. };
  2976. const muiStyledResolver = (...expressionsInput) => {
  2977. const expressionsHead = [];
  2978. const expressionsBody = expressionsInput.map(transformStyle);
  2979. const expressionsTail = [];
  2980. expressionsHead.push(styleAttachTheme);
  2981. if (componentName && overridesResolver) {
  2982. expressionsTail.push(function styleThemeOverrides(props) {
  2983. var _a, _b;
  2984. const theme = props.theme;
  2985. const styleOverrides = (_b = (_a = theme.components) == null ? void 0 : _a[componentName]) == null ? void 0 : _b.styleOverrides;
  2986. if (!styleOverrides) {
  2987. return null;
  2988. }
  2989. const resolvedStyleOverrides = {};
  2990. for (const slotKey in styleOverrides) {
  2991. resolvedStyleOverrides[slotKey] = processStyle(props, styleOverrides[slotKey]);
  2992. }
  2993. return overridesResolver(props, resolvedStyleOverrides);
  2994. });
  2995. }
  2996. if (componentName && !skipVariantsResolver) {
  2997. expressionsTail.push(function styleThemeVariants(props) {
  2998. var _a, _b;
  2999. const theme = props.theme;
  3000. const themeVariants = (_b = (_a = theme == null ? void 0 : theme.components) == null ? void 0 : _a[componentName]) == null ? void 0 : _b.variants;
  3001. if (!themeVariants) {
  3002. return null;
  3003. }
  3004. return processStyleVariants(props, themeVariants);
  3005. });
  3006. }
  3007. if (!skipSx) {
  3008. expressionsTail.push(styleFunctionSx);
  3009. }
  3010. if (Array.isArray(expressionsBody[0])) {
  3011. const inputStrings = expressionsBody.shift();
  3012. const placeholdersHead = new Array(expressionsHead.length).fill("");
  3013. const placeholdersTail = new Array(expressionsTail.length).fill("");
  3014. let outputStrings;
  3015. {
  3016. outputStrings = [...placeholdersHead, ...inputStrings, ...placeholdersTail];
  3017. outputStrings.raw = [...placeholdersHead, ...inputStrings.raw, ...placeholdersTail];
  3018. }
  3019. expressionsHead.unshift(outputStrings);
  3020. }
  3021. const expressions = [...expressionsHead, ...expressionsBody, ...expressionsTail];
  3022. const Component = defaultStyledResolver(...expressions);
  3023. if (tag.muiName) {
  3024. Component.muiName = tag.muiName;
  3025. }
  3026. return Component;
  3027. };
  3028. if (defaultStyledResolver.withConfig) {
  3029. muiStyledResolver.withConfig = defaultStyledResolver.withConfig;
  3030. }
  3031. return muiStyledResolver;
  3032. };
  3033. return styled2;
  3034. }
  3035. function generateStyledLabel(componentName, componentSlot) {
  3036. let label;
  3037. return label;
  3038. }
  3039. function isObjectEmpty(object) {
  3040. for (const _ in object) {
  3041. return false;
  3042. }
  3043. return true;
  3044. }
  3045. function isStringTag(tag) {
  3046. return typeof tag === "string" && // 96 is one less than the char code
  3047. // for "a" so this is checking that
  3048. // it's a lowercase character
  3049. tag.charCodeAt(0) > 96;
  3050. }
  3051. function lowercaseFirstLetter(string) {
  3052. if (!string) {
  3053. return string;
  3054. }
  3055. return string.charAt(0).toLowerCase() + string.slice(1);
  3056. }
  3057. function resolveProps(defaultProps2, props) {
  3058. const output = {
  3059. ...props
  3060. };
  3061. for (const key in defaultProps2) {
  3062. if (Object.prototype.hasOwnProperty.call(defaultProps2, key)) {
  3063. const propName = key;
  3064. if (propName === "components" || propName === "slots") {
  3065. output[propName] = {
  3066. ...defaultProps2[propName],
  3067. ...output[propName]
  3068. };
  3069. } else if (propName === "componentsProps" || propName === "slotProps") {
  3070. const defaultSlotProps = defaultProps2[propName];
  3071. const slotProps = props[propName];
  3072. if (!slotProps) {
  3073. output[propName] = defaultSlotProps || {};
  3074. } else if (!defaultSlotProps) {
  3075. output[propName] = slotProps;
  3076. } else {
  3077. output[propName] = {
  3078. ...slotProps
  3079. };
  3080. for (const slotKey in defaultSlotProps) {
  3081. if (Object.prototype.hasOwnProperty.call(defaultSlotProps, slotKey)) {
  3082. const slotPropName = slotKey;
  3083. output[propName][slotPropName] = resolveProps(defaultSlotProps[slotPropName], slotProps[slotPropName]);
  3084. }
  3085. }
  3086. }
  3087. } else if (output[propName] === void 0) {
  3088. output[propName] = defaultProps2[propName];
  3089. }
  3090. }
  3091. }
  3092. return output;
  3093. }
  3094. const useEnhancedEffect = typeof window !== "undefined" ? React__namespace.useLayoutEffect : React__namespace.useEffect;
  3095. function clamp(val, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
  3096. return Math.max(min, Math.min(val, max));
  3097. }
  3098. function clampWrapper(value, min = 0, max = 1) {
  3099. return clamp(value, min, max);
  3100. }
  3101. function hexToRgb(color2) {
  3102. color2 = color2.slice(1);
  3103. const re = new RegExp(`.{1,${color2.length >= 6 ? 2 : 1}}`, "g");
  3104. let colors = color2.match(re);
  3105. if (colors && colors[0].length === 1) {
  3106. colors = colors.map((n2) => n2 + n2);
  3107. }
  3108. return colors ? `rgb${colors.length === 4 ? "a" : ""}(${colors.map((n2, index) => {
  3109. return index < 3 ? parseInt(n2, 16) : Math.round(parseInt(n2, 16) / 255 * 1e3) / 1e3;
  3110. }).join(", ")})` : "";
  3111. }
  3112. function decomposeColor(color2) {
  3113. if (color2.type) {
  3114. return color2;
  3115. }
  3116. if (color2.charAt(0) === "#") {
  3117. return decomposeColor(hexToRgb(color2));
  3118. }
  3119. const marker = color2.indexOf("(");
  3120. const type = color2.substring(0, marker);
  3121. if (!["rgb", "rgba", "hsl", "hsla", "color"].includes(type)) {
  3122. throw new Error(formatMuiErrorMessage(9, color2));
  3123. }
  3124. let values2 = color2.substring(marker + 1, color2.length - 1);
  3125. let colorSpace;
  3126. if (type === "color") {
  3127. values2 = values2.split(" ");
  3128. colorSpace = values2.shift();
  3129. if (values2.length === 4 && values2[3].charAt(0) === "/") {
  3130. values2[3] = values2[3].slice(1);
  3131. }
  3132. if (!["srgb", "display-p3", "a98-rgb", "prophoto-rgb", "rec-2020"].includes(colorSpace)) {
  3133. throw new Error(formatMuiErrorMessage(10, colorSpace));
  3134. }
  3135. } else {
  3136. values2 = values2.split(",");
  3137. }
  3138. values2 = values2.map((value) => parseFloat(value));
  3139. return {
  3140. type,
  3141. values: values2,
  3142. colorSpace
  3143. };
  3144. }
  3145. const colorChannel = (color2) => {
  3146. const decomposedColor = decomposeColor(color2);
  3147. return decomposedColor.values.slice(0, 3).map((val, idx) => decomposedColor.type.includes("hsl") && idx !== 0 ? `${val}%` : val).join(" ");
  3148. };
  3149. const private_safeColorChannel = (color2, warning) => {
  3150. try {
  3151. return colorChannel(color2);
  3152. } catch (error) {
  3153. if (warning && false) {
  3154. console.warn(warning);
  3155. }
  3156. return color2;
  3157. }
  3158. };
  3159. function recomposeColor(color2) {
  3160. const {
  3161. type,
  3162. colorSpace
  3163. } = color2;
  3164. let {
  3165. values: values2
  3166. } = color2;
  3167. if (type.includes("rgb")) {
  3168. values2 = values2.map((n2, i) => i < 3 ? parseInt(n2, 10) : n2);
  3169. } else if (type.includes("hsl")) {
  3170. values2[1] = `${values2[1]}%`;
  3171. values2[2] = `${values2[2]}%`;
  3172. }
  3173. if (type.includes("color")) {
  3174. values2 = `${colorSpace} ${values2.join(" ")}`;
  3175. } else {
  3176. values2 = `${values2.join(", ")}`;
  3177. }
  3178. return `${type}(${values2})`;
  3179. }
  3180. function hslToRgb(color2) {
  3181. color2 = decomposeColor(color2);
  3182. const {
  3183. values: values2
  3184. } = color2;
  3185. const h2 = values2[0];
  3186. const s = values2[1] / 100;
  3187. const l2 = values2[2] / 100;
  3188. const a = s * Math.min(l2, 1 - l2);
  3189. const f2 = (n2, k2 = (n2 + h2 / 30) % 12) => l2 - a * Math.max(Math.min(k2 - 3, 9 - k2, 1), -1);
  3190. let type = "rgb";
  3191. const rgb = [Math.round(f2(0) * 255), Math.round(f2(8) * 255), Math.round(f2(4) * 255)];
  3192. if (color2.type === "hsla") {
  3193. type += "a";
  3194. rgb.push(values2[3]);
  3195. }
  3196. return recomposeColor({
  3197. type,
  3198. values: rgb
  3199. });
  3200. }
  3201. function getLuminance(color2) {
  3202. color2 = decomposeColor(color2);
  3203. let rgb = color2.type === "hsl" || color2.type === "hsla" ? decomposeColor(hslToRgb(color2)).values : color2.values;
  3204. rgb = rgb.map((val) => {
  3205. if (color2.type !== "color") {
  3206. val /= 255;
  3207. }
  3208. return val <= 0.03928 ? val / 12.92 : ((val + 0.055) / 1.055) ** 2.4;
  3209. });
  3210. return Number((0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2]).toFixed(3));
  3211. }
  3212. function getContrastRatio(foreground, background) {
  3213. const lumA = getLuminance(foreground);
  3214. const lumB = getLuminance(background);
  3215. return (Math.max(lumA, lumB) + 0.05) / (Math.min(lumA, lumB) + 0.05);
  3216. }
  3217. function alpha(color2, value) {
  3218. color2 = decomposeColor(color2);
  3219. value = clampWrapper(value);
  3220. if (color2.type === "rgb" || color2.type === "hsl") {
  3221. color2.type += "a";
  3222. }
  3223. if (color2.type === "color") {
  3224. color2.values[3] = `/${value}`;
  3225. } else {
  3226. color2.values[3] = value;
  3227. }
  3228. return recomposeColor(color2);
  3229. }
  3230. function private_safeAlpha(color2, value, warning) {
  3231. try {
  3232. return alpha(color2, value);
  3233. } catch (error) {
  3234. return color2;
  3235. }
  3236. }
  3237. function darken(color2, coefficient) {
  3238. color2 = decomposeColor(color2);
  3239. coefficient = clampWrapper(coefficient);
  3240. if (color2.type.includes("hsl")) {
  3241. color2.values[2] *= 1 - coefficient;
  3242. } else if (color2.type.includes("rgb") || color2.type.includes("color")) {
  3243. for (let i = 0; i < 3; i += 1) {
  3244. color2.values[i] *= 1 - coefficient;
  3245. }
  3246. }
  3247. return recomposeColor(color2);
  3248. }
  3249. function private_safeDarken(color2, coefficient, warning) {
  3250. try {
  3251. return darken(color2, coefficient);
  3252. } catch (error) {
  3253. return color2;
  3254. }
  3255. }
  3256. function lighten(color2, coefficient) {
  3257. color2 = decomposeColor(color2);
  3258. coefficient = clampWrapper(coefficient);
  3259. if (color2.type.includes("hsl")) {
  3260. color2.values[2] += (100 - color2.values[2]) * coefficient;
  3261. } else if (color2.type.includes("rgb")) {
  3262. for (let i = 0; i < 3; i += 1) {
  3263. color2.values[i] += (255 - color2.values[i]) * coefficient;
  3264. }
  3265. } else if (color2.type.includes("color")) {
  3266. for (let i = 0; i < 3; i += 1) {
  3267. color2.values[i] += (1 - color2.values[i]) * coefficient;
  3268. }
  3269. }
  3270. return recomposeColor(color2);
  3271. }
  3272. function private_safeLighten(color2, coefficient, warning) {
  3273. try {
  3274. return lighten(color2, coefficient);
  3275. } catch (error) {
  3276. return color2;
  3277. }
  3278. }
  3279. function emphasize(color2, coefficient = 0.15) {
  3280. return getLuminance(color2) > 0.5 ? darken(color2, coefficient) : lighten(color2, coefficient);
  3281. }
  3282. function private_safeEmphasize(color2, coefficient, warning) {
  3283. try {
  3284. return emphasize(color2, coefficient);
  3285. } catch (error) {
  3286. return color2;
  3287. }
  3288. }
  3289. function setRef(ref, value) {
  3290. if (typeof ref === "function") {
  3291. ref(value);
  3292. } else if (ref) {
  3293. ref.current = value;
  3294. }
  3295. }
  3296. function useEventCallback(fn) {
  3297. const ref = React__namespace.useRef(fn);
  3298. useEnhancedEffect(() => {
  3299. ref.current = fn;
  3300. });
  3301. return React__namespace.useRef((...args) => (
  3302. // @ts-expect-error hide `this`
  3303. (0, ref.current)(...args)
  3304. )).current;
  3305. }
  3306. function useForkRef(...refs) {
  3307. return React__namespace.useMemo(() => {
  3308. if (refs.every((ref) => ref == null)) {
  3309. return null;
  3310. }
  3311. return (instance) => {
  3312. refs.forEach((ref) => {
  3313. setRef(ref, instance);
  3314. });
  3315. };
  3316. }, refs);
  3317. }
  3318. const UNINITIALIZED = {};
  3319. function useLazyRef(init, initArg) {
  3320. const ref = React__namespace.useRef(UNINITIALIZED);
  3321. if (ref.current === UNINITIALIZED) {
  3322. ref.current = init(initArg);
  3323. }
  3324. return ref;
  3325. }
  3326. const EMPTY = [];
  3327. function useOnMount(fn) {
  3328. React__namespace.useEffect(fn, EMPTY);
  3329. }
  3330. class Timeout {
  3331. constructor() {
  3332. __publicField(this, "currentId", null);
  3333. __publicField(this, "clear", () => {
  3334. if (this.currentId !== null) {
  3335. clearTimeout(this.currentId);
  3336. this.currentId = null;
  3337. }
  3338. });
  3339. __publicField(this, "disposeEffect", () => {
  3340. return this.clear;
  3341. });
  3342. }
  3343. static create() {
  3344. return new Timeout();
  3345. }
  3346. /**
  3347. * Executes `fn` after `delay`, clearing any previously scheduled call.
  3348. */
  3349. start(delay, fn) {
  3350. this.clear();
  3351. this.currentId = setTimeout(() => {
  3352. this.currentId = null;
  3353. fn();
  3354. }, delay);
  3355. }
  3356. }
  3357. function useTimeout() {
  3358. const timeout = useLazyRef(Timeout.create).current;
  3359. useOnMount(timeout.disposeEffect);
  3360. return timeout;
  3361. }
  3362. function isFocusVisible(element) {
  3363. try {
  3364. return element.matches(":focus-visible");
  3365. } catch (error) {
  3366. }
  3367. return false;
  3368. }
  3369. function composeClasses(slots, getUtilityClass, classes = void 0) {
  3370. const output = {};
  3371. for (const slotName in slots) {
  3372. const slot = slots[slotName];
  3373. let buffer = "";
  3374. let start = true;
  3375. for (let i = 0; i < slot.length; i += 1) {
  3376. const value = slot[i];
  3377. if (value) {
  3378. buffer += (start === true ? "" : " ") + getUtilityClass(value);
  3379. start = false;
  3380. if (classes && classes[value]) {
  3381. buffer += " " + classes[value];
  3382. }
  3383. }
  3384. }
  3385. output[slotName] = buffer;
  3386. }
  3387. return output;
  3388. }
  3389. const PropsContext = /* @__PURE__ */ React__namespace.createContext(void 0);
  3390. function getThemeProps(params) {
  3391. const {
  3392. theme,
  3393. name,
  3394. props
  3395. } = params;
  3396. if (!theme || !theme.components || !theme.components[name]) {
  3397. return props;
  3398. }
  3399. const config = theme.components[name];
  3400. if (config.defaultProps) {
  3401. return resolveProps(config.defaultProps, props);
  3402. }
  3403. if (!config.styleOverrides && !config.variants) {
  3404. return resolveProps(config, props);
  3405. }
  3406. return props;
  3407. }
  3408. function useDefaultProps$1({
  3409. props,
  3410. name
  3411. }) {
  3412. const ctx = React__namespace.useContext(PropsContext);
  3413. return getThemeProps({
  3414. props,
  3415. name,
  3416. theme: {
  3417. components: ctx
  3418. }
  3419. });
  3420. }
  3421. const arg = {
  3422. theme: void 0
  3423. };
  3424. function unstable_memoTheme(styleFn) {
  3425. let lastValue;
  3426. let lastTheme;
  3427. return function styleMemoized(props) {
  3428. let value = lastValue;
  3429. if (value === void 0 || props.theme !== lastTheme) {
  3430. arg.theme = props.theme;
  3431. value = preprocessStyles(styleFn(arg));
  3432. lastValue = value;
  3433. lastTheme = props.theme;
  3434. }
  3435. return value;
  3436. };
  3437. }
  3438. function createGetCssVar$1(prefix2 = "") {
  3439. function appendVar(...vars) {
  3440. if (!vars.length) {
  3441. return "";
  3442. }
  3443. const value = vars[0];
  3444. if (typeof value === "string" && !value.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))|^(-?(\d*\.)?\d+)$|(\d+ \d+ \d+)/)) {
  3445. return `, var(--${prefix2 ? `${prefix2}-` : ""}${value}${appendVar(...vars.slice(1))})`;
  3446. }
  3447. return `, ${value}`;
  3448. }
  3449. const getCssVar = (field, ...fallbacks) => {
  3450. return `var(--${prefix2 ? `${prefix2}-` : ""}${field}${appendVar(...fallbacks)})`;
  3451. };
  3452. return getCssVar;
  3453. }
  3454. const assignNestedKeys = (obj, keys, value, arrayKeys = []) => {
  3455. let temp = obj;
  3456. keys.forEach((k2, index) => {
  3457. if (index === keys.length - 1) {
  3458. if (Array.isArray(temp)) {
  3459. temp[Number(k2)] = value;
  3460. } else if (temp && typeof temp === "object") {
  3461. temp[k2] = value;
  3462. }
  3463. } else if (temp && typeof temp === "object") {
  3464. if (!temp[k2]) {
  3465. temp[k2] = arrayKeys.includes(k2) ? [] : {};
  3466. }
  3467. temp = temp[k2];
  3468. }
  3469. });
  3470. };
  3471. const walkObjectDeep = (obj, callback, shouldSkipPaths) => {
  3472. function recurse(object, parentKeys = [], arrayKeys = []) {
  3473. Object.entries(object).forEach(([key, value]) => {
  3474. if (!shouldSkipPaths || shouldSkipPaths && !shouldSkipPaths([...parentKeys, key])) {
  3475. if (value !== void 0 && value !== null) {
  3476. if (typeof value === "object" && Object.keys(value).length > 0) {
  3477. recurse(value, [...parentKeys, key], Array.isArray(value) ? [...arrayKeys, key] : arrayKeys);
  3478. } else {
  3479. callback([...parentKeys, key], value, arrayKeys);
  3480. }
  3481. }
  3482. }
  3483. });
  3484. }
  3485. recurse(obj);
  3486. };
  3487. const getCssValue = (keys, value) => {
  3488. if (typeof value === "number") {
  3489. if (["lineHeight", "fontWeight", "opacity", "zIndex"].some((prop) => keys.includes(prop))) {
  3490. return value;
  3491. }
  3492. const lastKey = keys[keys.length - 1];
  3493. if (lastKey.toLowerCase().includes("opacity")) {
  3494. return value;
  3495. }
  3496. return `${value}px`;
  3497. }
  3498. return value;
  3499. };
  3500. function cssVarsParser(theme, options) {
  3501. const {
  3502. prefix: prefix2,
  3503. shouldSkipGeneratingVar: shouldSkipGeneratingVar2
  3504. } = options || {};
  3505. const css2 = {};
  3506. const vars = {};
  3507. const varsWithDefaults = {};
  3508. walkObjectDeep(
  3509. theme,
  3510. (keys, value, arrayKeys) => {
  3511. if (typeof value === "string" || typeof value === "number") {
  3512. if (!shouldSkipGeneratingVar2 || !shouldSkipGeneratingVar2(keys, value)) {
  3513. const cssVar = `--${prefix2 ? `${prefix2}-` : ""}${keys.join("-")}`;
  3514. const resolvedValue = getCssValue(keys, value);
  3515. Object.assign(css2, {
  3516. [cssVar]: resolvedValue
  3517. });
  3518. assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);
  3519. assignNestedKeys(varsWithDefaults, keys, `var(${cssVar}, ${resolvedValue})`, arrayKeys);
  3520. }
  3521. }
  3522. },
  3523. (keys) => keys[0] === "vars"
  3524. // skip 'vars/*' paths
  3525. );
  3526. return {
  3527. css: css2,
  3528. vars,
  3529. varsWithDefaults
  3530. };
  3531. }
  3532. function prepareCssVars(theme, parserConfig = {}) {
  3533. const {
  3534. getSelector = defaultGetSelector2,
  3535. disableCssColorScheme,
  3536. colorSchemeSelector: selector
  3537. } = parserConfig;
  3538. const {
  3539. colorSchemes = {},
  3540. components,
  3541. defaultColorScheme = "light",
  3542. ...otherTheme
  3543. } = theme;
  3544. const {
  3545. vars: rootVars,
  3546. css: rootCss,
  3547. varsWithDefaults: rootVarsWithDefaults
  3548. } = cssVarsParser(otherTheme, parserConfig);
  3549. let themeVars = rootVarsWithDefaults;
  3550. const colorSchemesMap = {};
  3551. const {
  3552. [defaultColorScheme]: defaultScheme,
  3553. ...otherColorSchemes
  3554. } = colorSchemes;
  3555. Object.entries(otherColorSchemes || {}).forEach(([key, scheme]) => {
  3556. const {
  3557. vars,
  3558. css: css2,
  3559. varsWithDefaults
  3560. } = cssVarsParser(scheme, parserConfig);
  3561. themeVars = deepmerge(themeVars, varsWithDefaults);
  3562. colorSchemesMap[key] = {
  3563. css: css2,
  3564. vars
  3565. };
  3566. });
  3567. if (defaultScheme) {
  3568. const {
  3569. css: css2,
  3570. vars,
  3571. varsWithDefaults
  3572. } = cssVarsParser(defaultScheme, parserConfig);
  3573. themeVars = deepmerge(themeVars, varsWithDefaults);
  3574. colorSchemesMap[defaultColorScheme] = {
  3575. css: css2,
  3576. vars
  3577. };
  3578. }
  3579. function defaultGetSelector2(colorScheme, cssObject) {
  3580. var _a, _b;
  3581. let rule = selector;
  3582. if (selector === "class") {
  3583. rule = ".%s";
  3584. }
  3585. if (selector === "data") {
  3586. rule = "[data-%s]";
  3587. }
  3588. if ((selector == null ? void 0 : selector.startsWith("data-")) && !selector.includes("%s")) {
  3589. rule = `[${selector}="%s"]`;
  3590. }
  3591. if (colorScheme) {
  3592. if (rule === "media") {
  3593. if (theme.defaultColorScheme === colorScheme) {
  3594. return ":root";
  3595. }
  3596. const mode = ((_b = (_a = colorSchemes[colorScheme]) == null ? void 0 : _a.palette) == null ? void 0 : _b.mode) || colorScheme;
  3597. return {
  3598. [`@media (prefers-color-scheme: ${mode})`]: {
  3599. ":root": cssObject
  3600. }
  3601. };
  3602. }
  3603. if (rule) {
  3604. if (theme.defaultColorScheme === colorScheme) {
  3605. return `:root, ${rule.replace("%s", String(colorScheme))}`;
  3606. }
  3607. return rule.replace("%s", String(colorScheme));
  3608. }
  3609. }
  3610. return ":root";
  3611. }
  3612. const generateThemeVars = () => {
  3613. let vars = {
  3614. ...rootVars
  3615. };
  3616. Object.entries(colorSchemesMap).forEach(([, {
  3617. vars: schemeVars
  3618. }]) => {
  3619. vars = deepmerge(vars, schemeVars);
  3620. });
  3621. return vars;
  3622. };
  3623. const generateStyleSheets = () => {
  3624. var _a, _b;
  3625. const stylesheets = [];
  3626. const colorScheme = theme.defaultColorScheme || "light";
  3627. function insertStyleSheet(key, css2) {
  3628. if (Object.keys(css2).length) {
  3629. stylesheets.push(typeof key === "string" ? {
  3630. [key]: {
  3631. ...css2
  3632. }
  3633. } : key);
  3634. }
  3635. }
  3636. insertStyleSheet(getSelector(void 0, {
  3637. ...rootCss
  3638. }), rootCss);
  3639. const {
  3640. [colorScheme]: defaultSchemeVal,
  3641. ...other
  3642. } = colorSchemesMap;
  3643. if (defaultSchemeVal) {
  3644. const {
  3645. css: css2
  3646. } = defaultSchemeVal;
  3647. const cssColorSheme = (_b = (_a = colorSchemes[colorScheme]) == null ? void 0 : _a.palette) == null ? void 0 : _b.mode;
  3648. const finalCss = !disableCssColorScheme && cssColorSheme ? {
  3649. colorScheme: cssColorSheme,
  3650. ...css2
  3651. } : {
  3652. ...css2
  3653. };
  3654. insertStyleSheet(getSelector(colorScheme, {
  3655. ...finalCss
  3656. }), finalCss);
  3657. }
  3658. Object.entries(other).forEach(([key, {
  3659. css: css2
  3660. }]) => {
  3661. var _a2, _b2;
  3662. const cssColorSheme = (_b2 = (_a2 = colorSchemes[key]) == null ? void 0 : _a2.palette) == null ? void 0 : _b2.mode;
  3663. const finalCss = !disableCssColorScheme && cssColorSheme ? {
  3664. colorScheme: cssColorSheme,
  3665. ...css2
  3666. } : {
  3667. ...css2
  3668. };
  3669. insertStyleSheet(getSelector(key, {
  3670. ...finalCss
  3671. }), finalCss);
  3672. });
  3673. return stylesheets;
  3674. };
  3675. return {
  3676. vars: themeVars,
  3677. generateThemeVars,
  3678. generateStyleSheets
  3679. };
  3680. }
  3681. function createGetColorSchemeSelector(selector) {
  3682. return function getColorSchemeSelector(colorScheme) {
  3683. if (selector === "media") {
  3684. return `@media (prefers-color-scheme: ${colorScheme})`;
  3685. }
  3686. if (selector) {
  3687. if (selector.startsWith("data-") && !selector.includes("%s")) {
  3688. return `[${selector}="${colorScheme}"] &`;
  3689. }
  3690. if (selector === "class") {
  3691. return `.${colorScheme} &`;
  3692. }
  3693. if (selector === "data") {
  3694. return `[data-${colorScheme}] &`;
  3695. }
  3696. return `${selector.replace("%s", colorScheme)} &`;
  3697. }
  3698. return "&";
  3699. };
  3700. }
  3701. const THEME_ID = "$$material";
  3702. const common = {
  3703. black: "#000",
  3704. white: "#fff"
  3705. };
  3706. const grey = {
  3707. 50: "#fafafa",
  3708. 100: "#f5f5f5",
  3709. 200: "#eeeeee",
  3710. 300: "#e0e0e0",
  3711. 400: "#bdbdbd",
  3712. 500: "#9e9e9e",
  3713. 600: "#757575",
  3714. 700: "#616161",
  3715. 800: "#424242",
  3716. 900: "#212121",
  3717. A100: "#f5f5f5",
  3718. A200: "#eeeeee",
  3719. A400: "#bdbdbd",
  3720. A700: "#616161"
  3721. };
  3722. const purple = {
  3723. 50: "#f3e5f5",
  3724. 100: "#e1bee7",
  3725. 200: "#ce93d8",
  3726. 300: "#ba68c8",
  3727. 400: "#ab47bc",
  3728. 500: "#9c27b0",
  3729. 600: "#8e24aa",
  3730. 700: "#7b1fa2",
  3731. 800: "#6a1b9a",
  3732. 900: "#4a148c",
  3733. A100: "#ea80fc",
  3734. A200: "#e040fb",
  3735. A400: "#d500f9",
  3736. A700: "#aa00ff"
  3737. };
  3738. const red = {
  3739. 50: "#ffebee",
  3740. 100: "#ffcdd2",
  3741. 200: "#ef9a9a",
  3742. 300: "#e57373",
  3743. 400: "#ef5350",
  3744. 500: "#f44336",
  3745. 600: "#e53935",
  3746. 700: "#d32f2f",
  3747. 800: "#c62828",
  3748. 900: "#b71c1c",
  3749. A100: "#ff8a80",
  3750. A200: "#ff5252",
  3751. A400: "#ff1744",
  3752. A700: "#d50000"
  3753. };
  3754. const orange = {
  3755. 50: "#fff3e0",
  3756. 100: "#ffe0b2",
  3757. 200: "#ffcc80",
  3758. 300: "#ffb74d",
  3759. 400: "#ffa726",
  3760. 500: "#ff9800",
  3761. 600: "#fb8c00",
  3762. 700: "#f57c00",
  3763. 800: "#ef6c00",
  3764. 900: "#e65100",
  3765. A100: "#ffd180",
  3766. A200: "#ffab40",
  3767. A400: "#ff9100",
  3768. A700: "#ff6d00"
  3769. };
  3770. const blue = {
  3771. 50: "#e3f2fd",
  3772. 100: "#bbdefb",
  3773. 200: "#90caf9",
  3774. 300: "#64b5f6",
  3775. 400: "#42a5f5",
  3776. 500: "#2196f3",
  3777. 600: "#1e88e5",
  3778. 700: "#1976d2",
  3779. 800: "#1565c0",
  3780. 900: "#0d47a1",
  3781. A100: "#82b1ff",
  3782. A200: "#448aff",
  3783. A400: "#2979ff",
  3784. A700: "#2962ff"
  3785. };
  3786. const lightBlue = {
  3787. 50: "#e1f5fe",
  3788. 100: "#b3e5fc",
  3789. 200: "#81d4fa",
  3790. 300: "#4fc3f7",
  3791. 400: "#29b6f6",
  3792. 500: "#03a9f4",
  3793. 600: "#039be5",
  3794. 700: "#0288d1",
  3795. 800: "#0277bd",
  3796. 900: "#01579b",
  3797. A100: "#80d8ff",
  3798. A200: "#40c4ff",
  3799. A400: "#00b0ff",
  3800. A700: "#0091ea"
  3801. };
  3802. const green = {
  3803. 50: "#e8f5e9",
  3804. 100: "#c8e6c9",
  3805. 200: "#a5d6a7",
  3806. 300: "#81c784",
  3807. 400: "#66bb6a",
  3808. 500: "#4caf50",
  3809. 600: "#43a047",
  3810. 700: "#388e3c",
  3811. 800: "#2e7d32",
  3812. 900: "#1b5e20",
  3813. A100: "#b9f6ca",
  3814. A200: "#69f0ae",
  3815. A400: "#00e676",
  3816. A700: "#00c853"
  3817. };
  3818. function getLight() {
  3819. return {
  3820. // The colors used to style the text.
  3821. text: {
  3822. // The most important text.
  3823. primary: "rgba(0, 0, 0, 0.87)",
  3824. // Secondary text.
  3825. secondary: "rgba(0, 0, 0, 0.6)",
  3826. // Disabled text have even lower visual prominence.
  3827. disabled: "rgba(0, 0, 0, 0.38)"
  3828. },
  3829. // The color used to divide different elements.
  3830. divider: "rgba(0, 0, 0, 0.12)",
  3831. // The background colors used to style the surfaces.
  3832. // Consistency between these values is important.
  3833. background: {
  3834. paper: common.white,
  3835. default: common.white
  3836. },
  3837. // The colors used to style the action elements.
  3838. action: {
  3839. // The color of an active action like an icon button.
  3840. active: "rgba(0, 0, 0, 0.54)",
  3841. // The color of an hovered action.
  3842. hover: "rgba(0, 0, 0, 0.04)",
  3843. hoverOpacity: 0.04,
  3844. // The color of a selected action.
  3845. selected: "rgba(0, 0, 0, 0.08)",
  3846. selectedOpacity: 0.08,
  3847. // The color of a disabled action.
  3848. disabled: "rgba(0, 0, 0, 0.26)",
  3849. // The background color of a disabled action.
  3850. disabledBackground: "rgba(0, 0, 0, 0.12)",
  3851. disabledOpacity: 0.38,
  3852. focus: "rgba(0, 0, 0, 0.12)",
  3853. focusOpacity: 0.12,
  3854. activatedOpacity: 0.12
  3855. }
  3856. };
  3857. }
  3858. const light = getLight();
  3859. function getDark() {
  3860. return {
  3861. text: {
  3862. primary: common.white,
  3863. secondary: "rgba(255, 255, 255, 0.7)",
  3864. disabled: "rgba(255, 255, 255, 0.5)",
  3865. icon: "rgba(255, 255, 255, 0.5)"
  3866. },
  3867. divider: "rgba(255, 255, 255, 0.12)",
  3868. background: {
  3869. paper: "#121212",
  3870. default: "#121212"
  3871. },
  3872. action: {
  3873. active: common.white,
  3874. hover: "rgba(255, 255, 255, 0.08)",
  3875. hoverOpacity: 0.08,
  3876. selected: "rgba(255, 255, 255, 0.16)",
  3877. selectedOpacity: 0.16,
  3878. disabled: "rgba(255, 255, 255, 0.3)",
  3879. disabledBackground: "rgba(255, 255, 255, 0.12)",
  3880. disabledOpacity: 0.38,
  3881. focus: "rgba(255, 255, 255, 0.12)",
  3882. focusOpacity: 0.12,
  3883. activatedOpacity: 0.24
  3884. }
  3885. };
  3886. }
  3887. const dark = getDark();
  3888. function addLightOrDark(intent, direction, shade, tonalOffset) {
  3889. const tonalOffsetLight = tonalOffset.light || tonalOffset;
  3890. const tonalOffsetDark = tonalOffset.dark || tonalOffset * 1.5;
  3891. if (!intent[direction]) {
  3892. if (intent.hasOwnProperty(shade)) {
  3893. intent[direction] = intent[shade];
  3894. } else if (direction === "light") {
  3895. intent.light = lighten(intent.main, tonalOffsetLight);
  3896. } else if (direction === "dark") {
  3897. intent.dark = darken(intent.main, tonalOffsetDark);
  3898. }
  3899. }
  3900. }
  3901. function getDefaultPrimary(mode = "light") {
  3902. if (mode === "dark") {
  3903. return {
  3904. main: blue[200],
  3905. light: blue[50],
  3906. dark: blue[400]
  3907. };
  3908. }
  3909. return {
  3910. main: blue[700],
  3911. light: blue[400],
  3912. dark: blue[800]
  3913. };
  3914. }
  3915. function getDefaultSecondary(mode = "light") {
  3916. if (mode === "dark") {
  3917. return {
  3918. main: purple[200],
  3919. light: purple[50],
  3920. dark: purple[400]
  3921. };
  3922. }
  3923. return {
  3924. main: purple[500],
  3925. light: purple[300],
  3926. dark: purple[700]
  3927. };
  3928. }
  3929. function getDefaultError(mode = "light") {
  3930. if (mode === "dark") {
  3931. return {
  3932. main: red[500],
  3933. light: red[300],
  3934. dark: red[700]
  3935. };
  3936. }
  3937. return {
  3938. main: red[700],
  3939. light: red[400],
  3940. dark: red[800]
  3941. };
  3942. }
  3943. function getDefaultInfo(mode = "light") {
  3944. if (mode === "dark") {
  3945. return {
  3946. main: lightBlue[400],
  3947. light: lightBlue[300],
  3948. dark: lightBlue[700]
  3949. };
  3950. }
  3951. return {
  3952. main: lightBlue[700],
  3953. light: lightBlue[500],
  3954. dark: lightBlue[900]
  3955. };
  3956. }
  3957. function getDefaultSuccess(mode = "light") {
  3958. if (mode === "dark") {
  3959. return {
  3960. main: green[400],
  3961. light: green[300],
  3962. dark: green[700]
  3963. };
  3964. }
  3965. return {
  3966. main: green[800],
  3967. light: green[500],
  3968. dark: green[900]
  3969. };
  3970. }
  3971. function getDefaultWarning(mode = "light") {
  3972. if (mode === "dark") {
  3973. return {
  3974. main: orange[400],
  3975. light: orange[300],
  3976. dark: orange[700]
  3977. };
  3978. }
  3979. return {
  3980. main: "#ed6c02",
  3981. // closest to orange[800] that pass 3:1.
  3982. light: orange[500],
  3983. dark: orange[900]
  3984. };
  3985. }
  3986. function createPalette(palette) {
  3987. const {
  3988. mode = "light",
  3989. contrastThreshold = 3,
  3990. tonalOffset = 0.2,
  3991. ...other
  3992. } = palette;
  3993. const primary = palette.primary || getDefaultPrimary(mode);
  3994. const secondary = palette.secondary || getDefaultSecondary(mode);
  3995. const error = palette.error || getDefaultError(mode);
  3996. const info = palette.info || getDefaultInfo(mode);
  3997. const success = palette.success || getDefaultSuccess(mode);
  3998. const warning = palette.warning || getDefaultWarning(mode);
  3999. function getContrastText(background) {
  4000. const contrastText = getContrastRatio(background, dark.text.primary) >= contrastThreshold ? dark.text.primary : light.text.primary;
  4001. return contrastText;
  4002. }
  4003. const augmentColor = ({
  4004. color: color2,
  4005. name,
  4006. mainShade = 500,
  4007. lightShade = 300,
  4008. darkShade = 700
  4009. }) => {
  4010. color2 = {
  4011. ...color2
  4012. };
  4013. if (!color2.main && color2[mainShade]) {
  4014. color2.main = color2[mainShade];
  4015. }
  4016. if (!color2.hasOwnProperty("main")) {
  4017. throw new Error(formatMuiErrorMessage(11, name ? ` (${name})` : "", mainShade));
  4018. }
  4019. if (typeof color2.main !== "string") {
  4020. throw new Error(formatMuiErrorMessage(12, name ? ` (${name})` : "", JSON.stringify(color2.main)));
  4021. }
  4022. addLightOrDark(color2, "light", lightShade, tonalOffset);
  4023. addLightOrDark(color2, "dark", darkShade, tonalOffset);
  4024. if (!color2.contrastText) {
  4025. color2.contrastText = getContrastText(color2.main);
  4026. }
  4027. return color2;
  4028. };
  4029. let modeHydrated;
  4030. if (mode === "light") {
  4031. modeHydrated = getLight();
  4032. } else if (mode === "dark") {
  4033. modeHydrated = getDark();
  4034. }
  4035. const paletteOutput = deepmerge({
  4036. // A collection of common colors.
  4037. common: {
  4038. ...common
  4039. },
  4040. // prevent mutable object.
  4041. // The palette mode, can be light or dark.
  4042. mode,
  4043. // The colors used to represent primary interface elements for a user.
  4044. primary: augmentColor({
  4045. color: primary,
  4046. name: "primary"
  4047. }),
  4048. // The colors used to represent secondary interface elements for a user.
  4049. secondary: augmentColor({
  4050. color: secondary,
  4051. name: "secondary",
  4052. mainShade: "A400",
  4053. lightShade: "A200",
  4054. darkShade: "A700"
  4055. }),
  4056. // The colors used to represent interface elements that the user should be made aware of.
  4057. error: augmentColor({
  4058. color: error,
  4059. name: "error"
  4060. }),
  4061. // The colors used to represent potentially dangerous actions or important messages.
  4062. warning: augmentColor({
  4063. color: warning,
  4064. name: "warning"
  4065. }),
  4066. // The colors used to present information to the user that is neutral and not necessarily important.
  4067. info: augmentColor({
  4068. color: info,
  4069. name: "info"
  4070. }),
  4071. // The colors used to indicate the successful completion of an action that user triggered.
  4072. success: augmentColor({
  4073. color: success,
  4074. name: "success"
  4075. }),
  4076. // The grey colors.
  4077. grey,
  4078. // Used by `getContrastText()` to maximize the contrast between
  4079. // the background and the text.
  4080. contrastThreshold,
  4081. // Takes a background color and returns the text color that maximizes the contrast.
  4082. getContrastText,
  4083. // Generate a rich color object.
  4084. augmentColor,
  4085. // Used by the functions below to shift a color's luminance by approximately
  4086. // two indexes within its tonal palette.
  4087. // E.g., shift from Red 500 to Red 300 or Red 700.
  4088. tonalOffset,
  4089. // The light and dark mode object.
  4090. ...modeHydrated
  4091. }, other);
  4092. return paletteOutput;
  4093. }
  4094. function prepareTypographyVars(typography) {
  4095. const vars = {};
  4096. const entries = Object.entries(typography);
  4097. entries.forEach((entry) => {
  4098. const [key, value] = entry;
  4099. if (typeof value === "object") {
  4100. vars[key] = `${value.fontStyle ? `${value.fontStyle} ` : ""}${value.fontVariant ? `${value.fontVariant} ` : ""}${value.fontWeight ? `${value.fontWeight} ` : ""}${value.fontStretch ? `${value.fontStretch} ` : ""}${value.fontSize || ""}${value.lineHeight ? `/${value.lineHeight} ` : ""}${value.fontFamily || ""}`;
  4101. }
  4102. });
  4103. return vars;
  4104. }
  4105. function createMixins(breakpoints, mixins) {
  4106. return {
  4107. toolbar: {
  4108. minHeight: 56,
  4109. [breakpoints.up("xs")]: {
  4110. "@media (orientation: landscape)": {
  4111. minHeight: 48
  4112. }
  4113. },
  4114. [breakpoints.up("sm")]: {
  4115. minHeight: 64
  4116. }
  4117. },
  4118. ...mixins
  4119. };
  4120. }
  4121. function round(value) {
  4122. return Math.round(value * 1e5) / 1e5;
  4123. }
  4124. const caseAllCaps = {
  4125. textTransform: "uppercase"
  4126. };
  4127. const defaultFontFamily = '"Roboto", "Helvetica", "Arial", sans-serif';
  4128. function createTypography(palette, typography) {
  4129. const {
  4130. fontFamily = defaultFontFamily,
  4131. // The default font size of the Material Specification.
  4132. fontSize = 14,
  4133. // px
  4134. fontWeightLight = 300,
  4135. fontWeightRegular = 400,
  4136. fontWeightMedium = 500,
  4137. fontWeightBold = 700,
  4138. // Tell MUI what's the font-size on the html element.
  4139. // 16px is the default font-size used by browsers.
  4140. htmlFontSize = 16,
  4141. // Apply the CSS properties to all the variants.
  4142. allVariants,
  4143. pxToRem: pxToRem2,
  4144. ...other
  4145. } = typeof typography === "function" ? typography(palette) : typography;
  4146. const coef = fontSize / 14;
  4147. const pxToRem = pxToRem2 || ((size) => `${size / htmlFontSize * coef}rem`);
  4148. const buildVariant = (fontWeight, size, lineHeight, letterSpacing, casing) => ({
  4149. fontFamily,
  4150. fontWeight,
  4151. fontSize: pxToRem(size),
  4152. // Unitless following https://meyerweb.com/eric/thoughts/2006/02/08/unitless-line-heights/
  4153. lineHeight,
  4154. // The letter spacing was designed for the Roboto font-family. Using the same letter-spacing
  4155. // across font-families can cause issues with the kerning.
  4156. ...fontFamily === defaultFontFamily ? {
  4157. letterSpacing: `${round(letterSpacing / size)}em`
  4158. } : {},
  4159. ...casing,
  4160. ...allVariants
  4161. });
  4162. const variants = {
  4163. h1: buildVariant(fontWeightLight, 96, 1.167, -1.5),
  4164. h2: buildVariant(fontWeightLight, 60, 1.2, -0.5),
  4165. h3: buildVariant(fontWeightRegular, 48, 1.167, 0),
  4166. h4: buildVariant(fontWeightRegular, 34, 1.235, 0.25),
  4167. h5: buildVariant(fontWeightRegular, 24, 1.334, 0),
  4168. h6: buildVariant(fontWeightMedium, 20, 1.6, 0.15),
  4169. subtitle1: buildVariant(fontWeightRegular, 16, 1.75, 0.15),
  4170. subtitle2: buildVariant(fontWeightMedium, 14, 1.57, 0.1),
  4171. body1: buildVariant(fontWeightRegular, 16, 1.5, 0.15),
  4172. body2: buildVariant(fontWeightRegular, 14, 1.43, 0.15),
  4173. button: buildVariant(fontWeightMedium, 14, 1.75, 0.4, caseAllCaps),
  4174. caption: buildVariant(fontWeightRegular, 12, 1.66, 0.4),
  4175. overline: buildVariant(fontWeightRegular, 12, 2.66, 1, caseAllCaps),
  4176. // TODO v6: Remove handling of 'inherit' variant from the theme as it is already handled in Material UI's Typography component. Also, remember to remove the associated types.
  4177. inherit: {
  4178. fontFamily: "inherit",
  4179. fontWeight: "inherit",
  4180. fontSize: "inherit",
  4181. lineHeight: "inherit",
  4182. letterSpacing: "inherit"
  4183. }
  4184. };
  4185. return deepmerge({
  4186. htmlFontSize,
  4187. pxToRem,
  4188. fontFamily,
  4189. fontSize,
  4190. fontWeightLight,
  4191. fontWeightRegular,
  4192. fontWeightMedium,
  4193. fontWeightBold,
  4194. ...variants
  4195. }, other, {
  4196. clone: false
  4197. // No need to clone deep
  4198. });
  4199. }
  4200. const shadowKeyUmbraOpacity = 0.2;
  4201. const shadowKeyPenumbraOpacity = 0.14;
  4202. const shadowAmbientShadowOpacity = 0.12;
  4203. function createShadow(...px) {
  4204. return [`${px[0]}px ${px[1]}px ${px[2]}px ${px[3]}px rgba(0,0,0,${shadowKeyUmbraOpacity})`, `${px[4]}px ${px[5]}px ${px[6]}px ${px[7]}px rgba(0,0,0,${shadowKeyPenumbraOpacity})`, `${px[8]}px ${px[9]}px ${px[10]}px ${px[11]}px rgba(0,0,0,${shadowAmbientShadowOpacity})`].join(",");
  4205. }
  4206. const 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)];
  4207. const easing = {
  4208. // This is the most common easing curve.
  4209. easeInOut: "cubic-bezier(0.4, 0, 0.2, 1)",
  4210. // Objects enter the screen at full velocity from off-screen and
  4211. // slowly decelerate to a resting point.
  4212. easeOut: "cubic-bezier(0.0, 0, 0.2, 1)",
  4213. // Objects leave the screen at full velocity. They do not decelerate when off-screen.
  4214. easeIn: "cubic-bezier(0.4, 0, 1, 1)",
  4215. // The sharp curve is used by objects that may return to the screen at any time.
  4216. sharp: "cubic-bezier(0.4, 0, 0.6, 1)"
  4217. };
  4218. const duration = {
  4219. shortest: 150,
  4220. shorter: 200,
  4221. short: 250,
  4222. // most basic recommended timing
  4223. standard: 300,
  4224. // this is to be used in complex animations
  4225. complex: 375,
  4226. // recommended when something is entering screen
  4227. enteringScreen: 225,
  4228. // recommended when something is leaving screen
  4229. leavingScreen: 195
  4230. };
  4231. function formatMs(milliseconds) {
  4232. return `${Math.round(milliseconds)}ms`;
  4233. }
  4234. function getAutoHeightDuration(height2) {
  4235. if (!height2) {
  4236. return 0;
  4237. }
  4238. const constant = height2 / 36;
  4239. return Math.min(Math.round((4 + 15 * constant ** 0.25 + constant / 5) * 10), 3e3);
  4240. }
  4241. function createTransitions(inputTransitions) {
  4242. const mergedEasing = {
  4243. ...easing,
  4244. ...inputTransitions.easing
  4245. };
  4246. const mergedDuration = {
  4247. ...duration,
  4248. ...inputTransitions.duration
  4249. };
  4250. const create = (props = ["all"], options = {}) => {
  4251. const {
  4252. duration: durationOption = mergedDuration.standard,
  4253. easing: easingOption = mergedEasing.easeInOut,
  4254. delay = 0,
  4255. ...other
  4256. } = options;
  4257. return (Array.isArray(props) ? props : [props]).map((animatedProp) => `${animatedProp} ${typeof durationOption === "string" ? durationOption : formatMs(durationOption)} ${easingOption} ${typeof delay === "string" ? delay : formatMs(delay)}`).join(",");
  4258. };
  4259. return {
  4260. getAutoHeightDuration,
  4261. create,
  4262. ...inputTransitions,
  4263. easing: mergedEasing,
  4264. duration: mergedDuration
  4265. };
  4266. }
  4267. const zIndex = {
  4268. mobileStepper: 1e3,
  4269. fab: 1050,
  4270. speedDial: 1050,
  4271. appBar: 1100,
  4272. drawer: 1200,
  4273. modal: 1300,
  4274. snackbar: 1400,
  4275. tooltip: 1500
  4276. };
  4277. function isSerializable(val) {
  4278. return isPlainObject$1(val) || typeof val === "undefined" || typeof val === "string" || typeof val === "boolean" || typeof val === "number" || Array.isArray(val);
  4279. }
  4280. function stringifyTheme(baseTheme = {}) {
  4281. const serializableTheme = {
  4282. ...baseTheme
  4283. };
  4284. function serializeTheme(object) {
  4285. const array = Object.entries(object);
  4286. for (let index = 0; index < array.length; index++) {
  4287. const [key, value] = array[index];
  4288. if (!isSerializable(value) || key.startsWith("unstable_")) {
  4289. delete object[key];
  4290. } else if (isPlainObject$1(value)) {
  4291. object[key] = {
  4292. ...value
  4293. };
  4294. serializeTheme(object[key]);
  4295. }
  4296. }
  4297. }
  4298. serializeTheme(serializableTheme);
  4299. return `import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
  4300.  
  4301. const theme = ${JSON.stringify(serializableTheme, null, 2)};
  4302.  
  4303. theme.breakpoints = createBreakpoints(theme.breakpoints || {});
  4304. theme.transitions = createTransitions(theme.transitions || {});
  4305.  
  4306. export default theme;`;
  4307. }
  4308. function createThemeNoVars(options = {}, ...args) {
  4309. const {
  4310. breakpoints: breakpointsInput,
  4311. mixins: mixinsInput = {},
  4312. spacing: spacingInput,
  4313. palette: paletteInput = {},
  4314. transitions: transitionsInput = {},
  4315. typography: typographyInput = {},
  4316. shape: shapeInput,
  4317. ...other
  4318. } = options;
  4319. if (options.vars) {
  4320. throw new Error(formatMuiErrorMessage(20));
  4321. }
  4322. const palette = createPalette(paletteInput);
  4323. const systemTheme = createTheme$1(options);
  4324. let muiTheme = deepmerge(systemTheme, {
  4325. mixins: createMixins(systemTheme.breakpoints, mixinsInput),
  4326. palette,
  4327. // Don't use [...shadows] until you've verified its transpiled code is not invoking the iterator protocol.
  4328. shadows: shadows.slice(),
  4329. typography: createTypography(palette, typographyInput),
  4330. transitions: createTransitions(transitionsInput),
  4331. zIndex: {
  4332. ...zIndex
  4333. }
  4334. });
  4335. muiTheme = deepmerge(muiTheme, other);
  4336. muiTheme = args.reduce((acc, argument) => deepmerge(acc, argument), muiTheme);
  4337. muiTheme.unstable_sxConfig = {
  4338. ...defaultSxConfig,
  4339. ...other == null ? void 0 : other.unstable_sxConfig
  4340. };
  4341. muiTheme.unstable_sx = function sx(props) {
  4342. return styleFunctionSx({
  4343. sx: props,
  4344. theme: this
  4345. });
  4346. };
  4347. muiTheme.toRuntimeSource = stringifyTheme;
  4348. return muiTheme;
  4349. }
  4350. function getOverlayAlpha(elevation) {
  4351. let alphaValue;
  4352. if (elevation < 1) {
  4353. alphaValue = 5.11916 * elevation ** 2;
  4354. } else {
  4355. alphaValue = 4.5 * Math.log(elevation + 1) + 2;
  4356. }
  4357. return Math.round(alphaValue * 10) / 1e3;
  4358. }
  4359. const defaultDarkOverlays = [...Array(25)].map((_, index) => {
  4360. if (index === 0) {
  4361. return "none";
  4362. }
  4363. const overlay = getOverlayAlpha(index);
  4364. return `linear-gradient(rgba(255 255 255 / ${overlay}), rgba(255 255 255 / ${overlay}))`;
  4365. });
  4366. function getOpacity(mode) {
  4367. return {
  4368. inputPlaceholder: mode === "dark" ? 0.5 : 0.42,
  4369. inputUnderline: mode === "dark" ? 0.7 : 0.42,
  4370. switchTrackDisabled: mode === "dark" ? 0.2 : 0.12,
  4371. switchTrack: mode === "dark" ? 0.3 : 0.38
  4372. };
  4373. }
  4374. function getOverlays(mode) {
  4375. return mode === "dark" ? defaultDarkOverlays : [];
  4376. }
  4377. function createColorScheme(options) {
  4378. const {
  4379. palette: paletteInput = {
  4380. mode: "light"
  4381. },
  4382. // need to cast to avoid module augmentation test
  4383. opacity,
  4384. overlays,
  4385. ...rest
  4386. } = options;
  4387. const palette = createPalette(paletteInput);
  4388. return {
  4389. palette,
  4390. opacity: {
  4391. ...getOpacity(palette.mode),
  4392. ...opacity
  4393. },
  4394. overlays: overlays || getOverlays(palette.mode),
  4395. ...rest
  4396. };
  4397. }
  4398. function shouldSkipGeneratingVar(keys) {
  4399. var _a;
  4400. return !!keys[0].match(/(cssVarPrefix|colorSchemeSelector|rootSelector|typography|mixins|breakpoints|direction|transitions)/) || !!keys[0].match(/sxConfig$/) || // ends with sxConfig
  4401. keys[0] === "palette" && !!((_a = keys[1]) == null ? void 0 : _a.match(/(mode|contrastThreshold|tonalOffset)/));
  4402. }
  4403. const excludeVariablesFromRoot = (cssVarPrefix) => [...[...Array(25)].map((_, index) => `--${cssVarPrefix ? `${cssVarPrefix}-` : ""}overlays-${index}`), `--${cssVarPrefix ? `${cssVarPrefix}-` : ""}palette-AppBar-darkBg`, `--${cssVarPrefix ? `${cssVarPrefix}-` : ""}palette-AppBar-darkColor`];
  4404. const defaultGetSelector = (theme) => (colorScheme, css2) => {
  4405. const root = theme.rootSelector || ":root";
  4406. const selector = theme.colorSchemeSelector;
  4407. let rule = selector;
  4408. if (selector === "class") {
  4409. rule = ".%s";
  4410. }
  4411. if (selector === "data") {
  4412. rule = "[data-%s]";
  4413. }
  4414. if ((selector == null ? void 0 : selector.startsWith("data-")) && !selector.includes("%s")) {
  4415. rule = `[${selector}="%s"]`;
  4416. }
  4417. if (theme.defaultColorScheme === colorScheme) {
  4418. if (colorScheme === "dark") {
  4419. const excludedVariables = {};
  4420. excludeVariablesFromRoot(theme.cssVarPrefix).forEach((cssVar) => {
  4421. excludedVariables[cssVar] = css2[cssVar];
  4422. delete css2[cssVar];
  4423. });
  4424. if (rule === "media") {
  4425. return {
  4426. [root]: css2,
  4427. [`@media (prefers-color-scheme: dark)`]: {
  4428. [root]: excludedVariables
  4429. }
  4430. };
  4431. }
  4432. if (rule) {
  4433. return {
  4434. [rule.replace("%s", colorScheme)]: excludedVariables,
  4435. [`${root}, ${rule.replace("%s", colorScheme)}`]: css2
  4436. };
  4437. }
  4438. return {
  4439. [root]: {
  4440. ...css2,
  4441. ...excludedVariables
  4442. }
  4443. };
  4444. }
  4445. if (rule && rule !== "media") {
  4446. return `${root}, ${rule.replace("%s", String(colorScheme))}`;
  4447. }
  4448. } else if (colorScheme) {
  4449. if (rule === "media") {
  4450. return {
  4451. [`@media (prefers-color-scheme: ${String(colorScheme)})`]: {
  4452. [root]: css2
  4453. }
  4454. };
  4455. }
  4456. if (rule) {
  4457. return rule.replace("%s", String(colorScheme));
  4458. }
  4459. }
  4460. return root;
  4461. };
  4462. function assignNode(obj, keys) {
  4463. keys.forEach((k2) => {
  4464. if (!obj[k2]) {
  4465. obj[k2] = {};
  4466. }
  4467. });
  4468. }
  4469. function setColor(obj, key, defaultValue) {
  4470. if (!obj[key] && defaultValue) {
  4471. obj[key] = defaultValue;
  4472. }
  4473. }
  4474. function toRgb(color2) {
  4475. if (!color2 || !color2.startsWith("hsl")) {
  4476. return color2;
  4477. }
  4478. return hslToRgb(color2);
  4479. }
  4480. function setColorChannel(obj, key) {
  4481. if (!(`${key}Channel` in obj)) {
  4482. obj[`${key}Channel`] = private_safeColorChannel(toRgb(obj[key]), `MUI: Can't create \`palette.${key}Channel\` because \`palette.${key}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
  4483. To suppress this warning, you need to explicitly provide the \`palette.${key}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`);
  4484. }
  4485. }
  4486. function getSpacingVal(spacingInput) {
  4487. if (typeof spacingInput === "number") {
  4488. return `${spacingInput}px`;
  4489. }
  4490. if (typeof spacingInput === "string" || typeof spacingInput === "function" || Array.isArray(spacingInput)) {
  4491. return spacingInput;
  4492. }
  4493. return "8px";
  4494. }
  4495. const silent = (fn) => {
  4496. try {
  4497. return fn();
  4498. } catch (error) {
  4499. }
  4500. return void 0;
  4501. };
  4502. const createGetCssVar = (cssVarPrefix = "mui") => createGetCssVar$1(cssVarPrefix);
  4503. function attachColorScheme$1(colorSchemes, scheme, restTheme, colorScheme) {
  4504. if (!scheme) {
  4505. return void 0;
  4506. }
  4507. scheme = scheme === true ? {} : scheme;
  4508. const mode = colorScheme === "dark" ? "dark" : "light";
  4509. if (!restTheme) {
  4510. colorSchemes[colorScheme] = createColorScheme({
  4511. ...scheme,
  4512. palette: {
  4513. mode,
  4514. ...scheme == null ? void 0 : scheme.palette
  4515. }
  4516. });
  4517. return void 0;
  4518. }
  4519. const {
  4520. palette,
  4521. ...muiTheme
  4522. } = createThemeNoVars({
  4523. ...restTheme,
  4524. palette: {
  4525. mode,
  4526. ...scheme == null ? void 0 : scheme.palette
  4527. }
  4528. });
  4529. colorSchemes[colorScheme] = {
  4530. ...scheme,
  4531. palette,
  4532. opacity: {
  4533. ...getOpacity(mode),
  4534. ...scheme == null ? void 0 : scheme.opacity
  4535. },
  4536. overlays: (scheme == null ? void 0 : scheme.overlays) || getOverlays(mode)
  4537. };
  4538. return muiTheme;
  4539. }
  4540. function createThemeWithVars(options = {}, ...args) {
  4541. const {
  4542. colorSchemes: colorSchemesInput = {
  4543. light: true
  4544. },
  4545. defaultColorScheme: defaultColorSchemeInput,
  4546. disableCssColorScheme = false,
  4547. cssVarPrefix = "mui",
  4548. shouldSkipGeneratingVar: shouldSkipGeneratingVar$1 = shouldSkipGeneratingVar,
  4549. colorSchemeSelector: selector = colorSchemesInput.light && colorSchemesInput.dark ? "media" : void 0,
  4550. rootSelector = ":root",
  4551. ...input
  4552. } = options;
  4553. const firstColorScheme = Object.keys(colorSchemesInput)[0];
  4554. const defaultColorScheme = defaultColorSchemeInput || (colorSchemesInput.light && firstColorScheme !== "light" ? "light" : firstColorScheme);
  4555. const getCssVar = createGetCssVar(cssVarPrefix);
  4556. const {
  4557. [defaultColorScheme]: defaultSchemeInput,
  4558. light: builtInLight,
  4559. dark: builtInDark,
  4560. ...customColorSchemes
  4561. } = colorSchemesInput;
  4562. const colorSchemes = {
  4563. ...customColorSchemes
  4564. };
  4565. let defaultScheme = defaultSchemeInput;
  4566. if (defaultColorScheme === "dark" && !("dark" in colorSchemesInput) || defaultColorScheme === "light" && !("light" in colorSchemesInput)) {
  4567. defaultScheme = true;
  4568. }
  4569. if (!defaultScheme) {
  4570. throw new Error(formatMuiErrorMessage(21, defaultColorScheme));
  4571. }
  4572. const muiTheme = attachColorScheme$1(colorSchemes, defaultScheme, input, defaultColorScheme);
  4573. if (builtInLight && !colorSchemes.light) {
  4574. attachColorScheme$1(colorSchemes, builtInLight, void 0, "light");
  4575. }
  4576. if (builtInDark && !colorSchemes.dark) {
  4577. attachColorScheme$1(colorSchemes, builtInDark, void 0, "dark");
  4578. }
  4579. let theme = {
  4580. defaultColorScheme,
  4581. ...muiTheme,
  4582. cssVarPrefix,
  4583. colorSchemeSelector: selector,
  4584. rootSelector,
  4585. getCssVar,
  4586. colorSchemes,
  4587. font: {
  4588. ...prepareTypographyVars(muiTheme.typography),
  4589. ...muiTheme.font
  4590. },
  4591. spacing: getSpacingVal(input.spacing)
  4592. };
  4593. Object.keys(theme.colorSchemes).forEach((key) => {
  4594. const palette = theme.colorSchemes[key].palette;
  4595. const setCssVarColor = (cssVar) => {
  4596. const tokens = cssVar.split("-");
  4597. const color2 = tokens[1];
  4598. const colorToken = tokens[2];
  4599. return getCssVar(cssVar, palette[color2][colorToken]);
  4600. };
  4601. if (palette.mode === "light") {
  4602. setColor(palette.common, "background", "#fff");
  4603. setColor(palette.common, "onBackground", "#000");
  4604. }
  4605. if (palette.mode === "dark") {
  4606. setColor(palette.common, "background", "#000");
  4607. setColor(palette.common, "onBackground", "#fff");
  4608. }
  4609. assignNode(palette, ["Alert", "AppBar", "Avatar", "Button", "Chip", "FilledInput", "LinearProgress", "Skeleton", "Slider", "SnackbarContent", "SpeedDialAction", "StepConnector", "StepContent", "Switch", "TableCell", "Tooltip"]);
  4610. if (palette.mode === "light") {
  4611. setColor(palette.Alert, "errorColor", private_safeDarken(palette.error.light, 0.6));
  4612. setColor(palette.Alert, "infoColor", private_safeDarken(palette.info.light, 0.6));
  4613. setColor(palette.Alert, "successColor", private_safeDarken(palette.success.light, 0.6));
  4614. setColor(palette.Alert, "warningColor", private_safeDarken(palette.warning.light, 0.6));
  4615. setColor(palette.Alert, "errorFilledBg", setCssVarColor("palette-error-main"));
  4616. setColor(palette.Alert, "infoFilledBg", setCssVarColor("palette-info-main"));
  4617. setColor(palette.Alert, "successFilledBg", setCssVarColor("palette-success-main"));
  4618. setColor(palette.Alert, "warningFilledBg", setCssVarColor("palette-warning-main"));
  4619. setColor(palette.Alert, "errorFilledColor", silent(() => palette.getContrastText(palette.error.main)));
  4620. setColor(palette.Alert, "infoFilledColor", silent(() => palette.getContrastText(palette.info.main)));
  4621. setColor(palette.Alert, "successFilledColor", silent(() => palette.getContrastText(palette.success.main)));
  4622. setColor(palette.Alert, "warningFilledColor", silent(() => palette.getContrastText(palette.warning.main)));
  4623. setColor(palette.Alert, "errorStandardBg", private_safeLighten(palette.error.light, 0.9));
  4624. setColor(palette.Alert, "infoStandardBg", private_safeLighten(palette.info.light, 0.9));
  4625. setColor(palette.Alert, "successStandardBg", private_safeLighten(palette.success.light, 0.9));
  4626. setColor(palette.Alert, "warningStandardBg", private_safeLighten(palette.warning.light, 0.9));
  4627. setColor(palette.Alert, "errorIconColor", setCssVarColor("palette-error-main"));
  4628. setColor(palette.Alert, "infoIconColor", setCssVarColor("palette-info-main"));
  4629. setColor(palette.Alert, "successIconColor", setCssVarColor("palette-success-main"));
  4630. setColor(palette.Alert, "warningIconColor", setCssVarColor("palette-warning-main"));
  4631. setColor(palette.AppBar, "defaultBg", setCssVarColor("palette-grey-100"));
  4632. setColor(palette.Avatar, "defaultBg", setCssVarColor("palette-grey-400"));
  4633. setColor(palette.Button, "inheritContainedBg", setCssVarColor("palette-grey-300"));
  4634. setColor(palette.Button, "inheritContainedHoverBg", setCssVarColor("palette-grey-A100"));
  4635. setColor(palette.Chip, "defaultBorder", setCssVarColor("palette-grey-400"));
  4636. setColor(palette.Chip, "defaultAvatarColor", setCssVarColor("palette-grey-700"));
  4637. setColor(palette.Chip, "defaultIconColor", setCssVarColor("palette-grey-700"));
  4638. setColor(palette.FilledInput, "bg", "rgba(0, 0, 0, 0.06)");
  4639. setColor(palette.FilledInput, "hoverBg", "rgba(0, 0, 0, 0.09)");
  4640. setColor(palette.FilledInput, "disabledBg", "rgba(0, 0, 0, 0.12)");
  4641. setColor(palette.LinearProgress, "primaryBg", private_safeLighten(palette.primary.main, 0.62));
  4642. setColor(palette.LinearProgress, "secondaryBg", private_safeLighten(palette.secondary.main, 0.62));
  4643. setColor(palette.LinearProgress, "errorBg", private_safeLighten(palette.error.main, 0.62));
  4644. setColor(palette.LinearProgress, "infoBg", private_safeLighten(palette.info.main, 0.62));
  4645. setColor(palette.LinearProgress, "successBg", private_safeLighten(palette.success.main, 0.62));
  4646. setColor(palette.LinearProgress, "warningBg", private_safeLighten(palette.warning.main, 0.62));
  4647. setColor(palette.Skeleton, "bg", `rgba(${setCssVarColor("palette-text-primaryChannel")} / 0.11)`);
  4648. setColor(palette.Slider, "primaryTrack", private_safeLighten(palette.primary.main, 0.62));
  4649. setColor(palette.Slider, "secondaryTrack", private_safeLighten(palette.secondary.main, 0.62));
  4650. setColor(palette.Slider, "errorTrack", private_safeLighten(palette.error.main, 0.62));
  4651. setColor(palette.Slider, "infoTrack", private_safeLighten(palette.info.main, 0.62));
  4652. setColor(palette.Slider, "successTrack", private_safeLighten(palette.success.main, 0.62));
  4653. setColor(palette.Slider, "warningTrack", private_safeLighten(palette.warning.main, 0.62));
  4654. const snackbarContentBackground = private_safeEmphasize(palette.background.default, 0.8);
  4655. setColor(palette.SnackbarContent, "bg", snackbarContentBackground);
  4656. setColor(palette.SnackbarContent, "color", silent(() => palette.getContrastText(snackbarContentBackground)));
  4657. setColor(palette.SpeedDialAction, "fabHoverBg", private_safeEmphasize(palette.background.paper, 0.15));
  4658. setColor(palette.StepConnector, "border", setCssVarColor("palette-grey-400"));
  4659. setColor(palette.StepContent, "border", setCssVarColor("palette-grey-400"));
  4660. setColor(palette.Switch, "defaultColor", setCssVarColor("palette-common-white"));
  4661. setColor(palette.Switch, "defaultDisabledColor", setCssVarColor("palette-grey-100"));
  4662. setColor(palette.Switch, "primaryDisabledColor", private_safeLighten(palette.primary.main, 0.62));
  4663. setColor(palette.Switch, "secondaryDisabledColor", private_safeLighten(palette.secondary.main, 0.62));
  4664. setColor(palette.Switch, "errorDisabledColor", private_safeLighten(palette.error.main, 0.62));
  4665. setColor(palette.Switch, "infoDisabledColor", private_safeLighten(palette.info.main, 0.62));
  4666. setColor(palette.Switch, "successDisabledColor", private_safeLighten(palette.success.main, 0.62));
  4667. setColor(palette.Switch, "warningDisabledColor", private_safeLighten(palette.warning.main, 0.62));
  4668. setColor(palette.TableCell, "border", private_safeLighten(private_safeAlpha(palette.divider, 1), 0.88));
  4669. setColor(palette.Tooltip, "bg", private_safeAlpha(palette.grey[700], 0.92));
  4670. }
  4671. if (palette.mode === "dark") {
  4672. setColor(palette.Alert, "errorColor", private_safeLighten(palette.error.light, 0.6));
  4673. setColor(palette.Alert, "infoColor", private_safeLighten(palette.info.light, 0.6));
  4674. setColor(palette.Alert, "successColor", private_safeLighten(palette.success.light, 0.6));
  4675. setColor(palette.Alert, "warningColor", private_safeLighten(palette.warning.light, 0.6));
  4676. setColor(palette.Alert, "errorFilledBg", setCssVarColor("palette-error-dark"));
  4677. setColor(palette.Alert, "infoFilledBg", setCssVarColor("palette-info-dark"));
  4678. setColor(palette.Alert, "successFilledBg", setCssVarColor("palette-success-dark"));
  4679. setColor(palette.Alert, "warningFilledBg", setCssVarColor("palette-warning-dark"));
  4680. setColor(palette.Alert, "errorFilledColor", silent(() => palette.getContrastText(palette.error.dark)));
  4681. setColor(palette.Alert, "infoFilledColor", silent(() => palette.getContrastText(palette.info.dark)));
  4682. setColor(palette.Alert, "successFilledColor", silent(() => palette.getContrastText(palette.success.dark)));
  4683. setColor(palette.Alert, "warningFilledColor", silent(() => palette.getContrastText(palette.warning.dark)));
  4684. setColor(palette.Alert, "errorStandardBg", private_safeDarken(palette.error.light, 0.9));
  4685. setColor(palette.Alert, "infoStandardBg", private_safeDarken(palette.info.light, 0.9));
  4686. setColor(palette.Alert, "successStandardBg", private_safeDarken(palette.success.light, 0.9));
  4687. setColor(palette.Alert, "warningStandardBg", private_safeDarken(palette.warning.light, 0.9));
  4688. setColor(palette.Alert, "errorIconColor", setCssVarColor("palette-error-main"));
  4689. setColor(palette.Alert, "infoIconColor", setCssVarColor("palette-info-main"));
  4690. setColor(palette.Alert, "successIconColor", setCssVarColor("palette-success-main"));
  4691. setColor(palette.Alert, "warningIconColor", setCssVarColor("palette-warning-main"));
  4692. setColor(palette.AppBar, "defaultBg", setCssVarColor("palette-grey-900"));
  4693. setColor(palette.AppBar, "darkBg", setCssVarColor("palette-background-paper"));
  4694. setColor(palette.AppBar, "darkColor", setCssVarColor("palette-text-primary"));
  4695. setColor(palette.Avatar, "defaultBg", setCssVarColor("palette-grey-600"));
  4696. setColor(palette.Button, "inheritContainedBg", setCssVarColor("palette-grey-800"));
  4697. setColor(palette.Button, "inheritContainedHoverBg", setCssVarColor("palette-grey-700"));
  4698. setColor(palette.Chip, "defaultBorder", setCssVarColor("palette-grey-700"));
  4699. setColor(palette.Chip, "defaultAvatarColor", setCssVarColor("palette-grey-300"));
  4700. setColor(palette.Chip, "defaultIconColor", setCssVarColor("palette-grey-300"));
  4701. setColor(palette.FilledInput, "bg", "rgba(255, 255, 255, 0.09)");
  4702. setColor(palette.FilledInput, "hoverBg", "rgba(255, 255, 255, 0.13)");
  4703. setColor(palette.FilledInput, "disabledBg", "rgba(255, 255, 255, 0.12)");
  4704. setColor(palette.LinearProgress, "primaryBg", private_safeDarken(palette.primary.main, 0.5));
  4705. setColor(palette.LinearProgress, "secondaryBg", private_safeDarken(palette.secondary.main, 0.5));
  4706. setColor(palette.LinearProgress, "errorBg", private_safeDarken(palette.error.main, 0.5));
  4707. setColor(palette.LinearProgress, "infoBg", private_safeDarken(palette.info.main, 0.5));
  4708. setColor(palette.LinearProgress, "successBg", private_safeDarken(palette.success.main, 0.5));
  4709. setColor(palette.LinearProgress, "warningBg", private_safeDarken(palette.warning.main, 0.5));
  4710. setColor(palette.Skeleton, "bg", `rgba(${setCssVarColor("palette-text-primaryChannel")} / 0.13)`);
  4711. setColor(palette.Slider, "primaryTrack", private_safeDarken(palette.primary.main, 0.5));
  4712. setColor(palette.Slider, "secondaryTrack", private_safeDarken(palette.secondary.main, 0.5));
  4713. setColor(palette.Slider, "errorTrack", private_safeDarken(palette.error.main, 0.5));
  4714. setColor(palette.Slider, "infoTrack", private_safeDarken(palette.info.main, 0.5));
  4715. setColor(palette.Slider, "successTrack", private_safeDarken(palette.success.main, 0.5));
  4716. setColor(palette.Slider, "warningTrack", private_safeDarken(palette.warning.main, 0.5));
  4717. const snackbarContentBackground = private_safeEmphasize(palette.background.default, 0.98);
  4718. setColor(palette.SnackbarContent, "bg", snackbarContentBackground);
  4719. setColor(palette.SnackbarContent, "color", silent(() => palette.getContrastText(snackbarContentBackground)));
  4720. setColor(palette.SpeedDialAction, "fabHoverBg", private_safeEmphasize(palette.background.paper, 0.15));
  4721. setColor(palette.StepConnector, "border", setCssVarColor("palette-grey-600"));
  4722. setColor(palette.StepContent, "border", setCssVarColor("palette-grey-600"));
  4723. setColor(palette.Switch, "defaultColor", setCssVarColor("palette-grey-300"));
  4724. setColor(palette.Switch, "defaultDisabledColor", setCssVarColor("palette-grey-600"));
  4725. setColor(palette.Switch, "primaryDisabledColor", private_safeDarken(palette.primary.main, 0.55));
  4726. setColor(palette.Switch, "secondaryDisabledColor", private_safeDarken(palette.secondary.main, 0.55));
  4727. setColor(palette.Switch, "errorDisabledColor", private_safeDarken(palette.error.main, 0.55));
  4728. setColor(palette.Switch, "infoDisabledColor", private_safeDarken(palette.info.main, 0.55));
  4729. setColor(palette.Switch, "successDisabledColor", private_safeDarken(palette.success.main, 0.55));
  4730. setColor(palette.Switch, "warningDisabledColor", private_safeDarken(palette.warning.main, 0.55));
  4731. setColor(palette.TableCell, "border", private_safeDarken(private_safeAlpha(palette.divider, 1), 0.68));
  4732. setColor(palette.Tooltip, "bg", private_safeAlpha(palette.grey[700], 0.92));
  4733. }
  4734. setColorChannel(palette.background, "default");
  4735. setColorChannel(palette.background, "paper");
  4736. setColorChannel(palette.common, "background");
  4737. setColorChannel(palette.common, "onBackground");
  4738. setColorChannel(palette, "divider");
  4739. Object.keys(palette).forEach((color2) => {
  4740. const colors = palette[color2];
  4741. if (colors && typeof colors === "object") {
  4742. if (colors.main) {
  4743. setColor(palette[color2], "mainChannel", private_safeColorChannel(toRgb(colors.main)));
  4744. }
  4745. if (colors.light) {
  4746. setColor(palette[color2], "lightChannel", private_safeColorChannel(toRgb(colors.light)));
  4747. }
  4748. if (colors.dark) {
  4749. setColor(palette[color2], "darkChannel", private_safeColorChannel(toRgb(colors.dark)));
  4750. }
  4751. if (colors.contrastText) {
  4752. setColor(palette[color2], "contrastTextChannel", private_safeColorChannel(toRgb(colors.contrastText)));
  4753. }
  4754. if (color2 === "text") {
  4755. setColorChannel(palette[color2], "primary");
  4756. setColorChannel(palette[color2], "secondary");
  4757. }
  4758. if (color2 === "action") {
  4759. if (colors.active) {
  4760. setColorChannel(palette[color2], "active");
  4761. }
  4762. if (colors.selected) {
  4763. setColorChannel(palette[color2], "selected");
  4764. }
  4765. }
  4766. }
  4767. });
  4768. });
  4769. theme = args.reduce((acc, argument) => deepmerge(acc, argument), theme);
  4770. const parserConfig = {
  4771. prefix: cssVarPrefix,
  4772. disableCssColorScheme,
  4773. shouldSkipGeneratingVar: shouldSkipGeneratingVar$1,
  4774. getSelector: defaultGetSelector(theme)
  4775. };
  4776. const {
  4777. vars,
  4778. generateThemeVars,
  4779. generateStyleSheets
  4780. } = prepareCssVars(theme, parserConfig);
  4781. theme.vars = vars;
  4782. Object.entries(theme.colorSchemes[theme.defaultColorScheme]).forEach(([key, value]) => {
  4783. theme[key] = value;
  4784. });
  4785. theme.generateThemeVars = generateThemeVars;
  4786. theme.generateStyleSheets = generateStyleSheets;
  4787. theme.generateSpacing = function generateSpacing() {
  4788. return createSpacing(input.spacing, createUnarySpacing(this));
  4789. };
  4790. theme.getColorSchemeSelector = createGetColorSchemeSelector(selector);
  4791. theme.spacing = theme.generateSpacing();
  4792. theme.shouldSkipGeneratingVar = shouldSkipGeneratingVar$1;
  4793. theme.unstable_sxConfig = {
  4794. ...defaultSxConfig,
  4795. ...input == null ? void 0 : input.unstable_sxConfig
  4796. };
  4797. theme.unstable_sx = function sx(props) {
  4798. return styleFunctionSx({
  4799. sx: props,
  4800. theme: this
  4801. });
  4802. };
  4803. theme.toRuntimeSource = stringifyTheme;
  4804. return theme;
  4805. }
  4806. function attachColorScheme(theme, scheme, colorScheme) {
  4807. if (!theme.colorSchemes) {
  4808. return void 0;
  4809. }
  4810. if (colorScheme) {
  4811. theme.colorSchemes[scheme] = {
  4812. ...colorScheme !== true && colorScheme,
  4813. palette: createPalette({
  4814. ...colorScheme === true ? {} : colorScheme.palette,
  4815. mode: scheme
  4816. })
  4817. // cast type to skip module augmentation test
  4818. };
  4819. }
  4820. }
  4821. function createTheme(options = {}, ...args) {
  4822. const {
  4823. palette,
  4824. cssVariables = false,
  4825. colorSchemes: initialColorSchemes = !palette ? {
  4826. light: true
  4827. } : void 0,
  4828. defaultColorScheme: initialDefaultColorScheme = palette == null ? void 0 : palette.mode,
  4829. ...rest
  4830. } = options;
  4831. const defaultColorSchemeInput = initialDefaultColorScheme || "light";
  4832. const defaultScheme = initialColorSchemes == null ? void 0 : initialColorSchemes[defaultColorSchemeInput];
  4833. const colorSchemesInput = {
  4834. ...initialColorSchemes,
  4835. ...palette ? {
  4836. [defaultColorSchemeInput]: {
  4837. ...typeof defaultScheme !== "boolean" && defaultScheme,
  4838. palette
  4839. }
  4840. } : void 0
  4841. };
  4842. if (cssVariables === false) {
  4843. if (!("colorSchemes" in options)) {
  4844. return createThemeNoVars(options, ...args);
  4845. }
  4846. let paletteOptions = palette;
  4847. if (!("palette" in options)) {
  4848. if (colorSchemesInput[defaultColorSchemeInput]) {
  4849. if (colorSchemesInput[defaultColorSchemeInput] !== true) {
  4850. paletteOptions = colorSchemesInput[defaultColorSchemeInput].palette;
  4851. } else if (defaultColorSchemeInput === "dark") {
  4852. paletteOptions = {
  4853. mode: "dark"
  4854. };
  4855. }
  4856. }
  4857. }
  4858. const theme = createThemeNoVars({
  4859. ...options,
  4860. palette: paletteOptions
  4861. }, ...args);
  4862. theme.defaultColorScheme = defaultColorSchemeInput;
  4863. theme.colorSchemes = colorSchemesInput;
  4864. if (theme.palette.mode === "light") {
  4865. theme.colorSchemes.light = {
  4866. ...colorSchemesInput.light !== true && colorSchemesInput.light,
  4867. palette: theme.palette
  4868. };
  4869. attachColorScheme(theme, "dark", colorSchemesInput.dark);
  4870. }
  4871. if (theme.palette.mode === "dark") {
  4872. theme.colorSchemes.dark = {
  4873. ...colorSchemesInput.dark !== true && colorSchemesInput.dark,
  4874. palette: theme.palette
  4875. };
  4876. attachColorScheme(theme, "light", colorSchemesInput.light);
  4877. }
  4878. return theme;
  4879. }
  4880. if (!palette && !("light" in colorSchemesInput) && defaultColorSchemeInput === "light") {
  4881. colorSchemesInput.light = true;
  4882. }
  4883. return createThemeWithVars({
  4884. ...rest,
  4885. colorSchemes: colorSchemesInput,
  4886. defaultColorScheme: defaultColorSchemeInput,
  4887. ...typeof cssVariables !== "boolean" && cssVariables
  4888. }, ...args);
  4889. }
  4890. const defaultTheme$1 = createTheme();
  4891. function slotShouldForwardProp(prop) {
  4892. return prop !== "ownerState" && prop !== "theme" && prop !== "sx" && prop !== "as";
  4893. }
  4894. const rootShouldForwardProp = (prop) => slotShouldForwardProp(prop) && prop !== "classes";
  4895. const styled = createStyled2({
  4896. themeId: THEME_ID,
  4897. defaultTheme: defaultTheme$1,
  4898. rootShouldForwardProp
  4899. });
  4900. const boxClasses = generateUtilityClasses("MuiBox", ["root"]);
  4901. const defaultTheme = createTheme();
  4902. const Box = createBox({
  4903. themeId: THEME_ID,
  4904. defaultTheme,
  4905. defaultClassName: boxClasses.root,
  4906. generateClassName: ClassNameGenerator.generate
  4907. });
  4908. const memoTheme = unstable_memoTheme;
  4909. function useDefaultProps(params) {
  4910. return useDefaultProps$1(params);
  4911. }
  4912. class LazyRipple {
  4913. constructor() {
  4914. __publicField(this, "mountEffect", () => {
  4915. if (this.shouldMount && !this.didMount) {
  4916. if (this.ref.current !== null) {
  4917. this.didMount = true;
  4918. this.mounted.resolve();
  4919. }
  4920. }
  4921. });
  4922. this.ref = {
  4923. current: null
  4924. };
  4925. this.mounted = null;
  4926. this.didMount = false;
  4927. this.shouldMount = false;
  4928. this.setShouldMount = null;
  4929. }
  4930. /** React ref to the ripple instance */
  4931. /** If the ripple component should be mounted */
  4932. /** Promise that resolves when the ripple component is mounted */
  4933. /** If the ripple component has been mounted */
  4934. /** React state hook setter */
  4935. static create() {
  4936. return new LazyRipple();
  4937. }
  4938. static use() {
  4939. const ripple = useLazyRef(LazyRipple.create).current;
  4940. const [shouldMount, setShouldMount] = React__namespace.useState(false);
  4941. ripple.shouldMount = shouldMount;
  4942. ripple.setShouldMount = setShouldMount;
  4943. React__namespace.useEffect(ripple.mountEffect, [shouldMount]);
  4944. return ripple;
  4945. }
  4946. mount() {
  4947. if (!this.mounted) {
  4948. this.mounted = createControlledPromise();
  4949. this.shouldMount = true;
  4950. this.setShouldMount(this.shouldMount);
  4951. }
  4952. return this.mounted;
  4953. }
  4954. /* Ripple API */
  4955. start(...args) {
  4956. this.mount().then(() => {
  4957. var _a;
  4958. return (_a = this.ref.current) == null ? void 0 : _a.start(...args);
  4959. });
  4960. }
  4961. stop(...args) {
  4962. this.mount().then(() => {
  4963. var _a;
  4964. return (_a = this.ref.current) == null ? void 0 : _a.stop(...args);
  4965. });
  4966. }
  4967. pulsate(...args) {
  4968. this.mount().then(() => {
  4969. var _a;
  4970. return (_a = this.ref.current) == null ? void 0 : _a.pulsate(...args);
  4971. });
  4972. }
  4973. }
  4974. function useLazyRipple() {
  4975. return LazyRipple.use();
  4976. }
  4977. function createControlledPromise() {
  4978. let resolve;
  4979. let reject;
  4980. const p2 = new Promise((resolveFn, rejectFn) => {
  4981. resolve = resolveFn;
  4982. reject = rejectFn;
  4983. });
  4984. p2.resolve = resolve;
  4985. p2.reject = reject;
  4986. return p2;
  4987. }
  4988. function _objectWithoutPropertiesLoose(r2, e2) {
  4989. if (null == r2) return {};
  4990. var t2 = {};
  4991. for (var n2 in r2) if ({}.hasOwnProperty.call(r2, n2)) {
  4992. if (e2.includes(n2)) continue;
  4993. t2[n2] = r2[n2];
  4994. }
  4995. return t2;
  4996. }
  4997. function _setPrototypeOf(t2, e2) {
  4998. return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t3, e3) {
  4999. return t3.__proto__ = e3, t3;
  5000. }, _setPrototypeOf(t2, e2);
  5001. }
  5002. function _inheritsLoose(t2, o) {
  5003. t2.prototype = Object.create(o.prototype), t2.prototype.constructor = t2, _setPrototypeOf(t2, o);
  5004. }
  5005. const TransitionGroupContext = React.createContext(null);
  5006. function _assertThisInitialized(e2) {
  5007. if (void 0 === e2) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  5008. return e2;
  5009. }
  5010. function getChildMapping(children, mapFn) {
  5011. var mapper = function mapper2(child) {
  5012. return mapFn && React.isValidElement(child) ? mapFn(child) : child;
  5013. };
  5014. var result = /* @__PURE__ */ Object.create(null);
  5015. if (children) React.Children.map(children, function(c2) {
  5016. return c2;
  5017. }).forEach(function(child) {
  5018. result[child.key] = mapper(child);
  5019. });
  5020. return result;
  5021. }
  5022. function mergeChildMappings(prev2, next2) {
  5023. prev2 = prev2 || {};
  5024. next2 = next2 || {};
  5025. function getValueForKey(key) {
  5026. return key in next2 ? next2[key] : prev2[key];
  5027. }
  5028. var nextKeysPending = /* @__PURE__ */ Object.create(null);
  5029. var pendingKeys = [];
  5030. for (var prevKey in prev2) {
  5031. if (prevKey in next2) {
  5032. if (pendingKeys.length) {
  5033. nextKeysPending[prevKey] = pendingKeys;
  5034. pendingKeys = [];
  5035. }
  5036. } else {
  5037. pendingKeys.push(prevKey);
  5038. }
  5039. }
  5040. var i;
  5041. var childMapping = {};
  5042. for (var nextKey in next2) {
  5043. if (nextKeysPending[nextKey]) {
  5044. for (i = 0; i < nextKeysPending[nextKey].length; i++) {
  5045. var pendingNextKey = nextKeysPending[nextKey][i];
  5046. childMapping[nextKeysPending[nextKey][i]] = getValueForKey(pendingNextKey);
  5047. }
  5048. }
  5049. childMapping[nextKey] = getValueForKey(nextKey);
  5050. }
  5051. for (i = 0; i < pendingKeys.length; i++) {
  5052. childMapping[pendingKeys[i]] = getValueForKey(pendingKeys[i]);
  5053. }
  5054. return childMapping;
  5055. }
  5056. function getProp(child, prop, props) {
  5057. return props[prop] != null ? props[prop] : child.props[prop];
  5058. }
  5059. function getInitialChildMapping(props, onExited) {
  5060. return getChildMapping(props.children, function(child) {
  5061. return React.cloneElement(child, {
  5062. onExited: onExited.bind(null, child),
  5063. in: true,
  5064. appear: getProp(child, "appear", props),
  5065. enter: getProp(child, "enter", props),
  5066. exit: getProp(child, "exit", props)
  5067. });
  5068. });
  5069. }
  5070. function getNextChildMapping(nextProps, prevChildMapping, onExited) {
  5071. var nextChildMapping = getChildMapping(nextProps.children);
  5072. var children = mergeChildMappings(prevChildMapping, nextChildMapping);
  5073. Object.keys(children).forEach(function(key) {
  5074. var child = children[key];
  5075. if (!React.isValidElement(child)) return;
  5076. var hasPrev = key in prevChildMapping;
  5077. var hasNext = key in nextChildMapping;
  5078. var prevChild = prevChildMapping[key];
  5079. var isLeaving = React.isValidElement(prevChild) && !prevChild.props.in;
  5080. if (hasNext && (!hasPrev || isLeaving)) {
  5081. children[key] = React.cloneElement(child, {
  5082. onExited: onExited.bind(null, child),
  5083. in: true,
  5084. exit: getProp(child, "exit", nextProps),
  5085. enter: getProp(child, "enter", nextProps)
  5086. });
  5087. } else if (!hasNext && hasPrev && !isLeaving) {
  5088. children[key] = React.cloneElement(child, {
  5089. in: false
  5090. });
  5091. } else if (hasNext && hasPrev && React.isValidElement(prevChild)) {
  5092. children[key] = React.cloneElement(child, {
  5093. onExited: onExited.bind(null, child),
  5094. in: prevChild.props.in,
  5095. exit: getProp(child, "exit", nextProps),
  5096. enter: getProp(child, "enter", nextProps)
  5097. });
  5098. }
  5099. });
  5100. return children;
  5101. }
  5102. var values = Object.values || function(obj) {
  5103. return Object.keys(obj).map(function(k2) {
  5104. return obj[k2];
  5105. });
  5106. };
  5107. var defaultProps = {
  5108. component: "div",
  5109. childFactory: function childFactory(child) {
  5110. return child;
  5111. }
  5112. };
  5113. var TransitionGroup = /* @__PURE__ */ function(_React$Component) {
  5114. _inheritsLoose(TransitionGroup2, _React$Component);
  5115. function TransitionGroup2(props, context) {
  5116. var _this;
  5117. _this = _React$Component.call(this, props, context) || this;
  5118. var handleExited = _this.handleExited.bind(_assertThisInitialized(_this));
  5119. _this.state = {
  5120. contextValue: {
  5121. isMounting: true
  5122. },
  5123. handleExited,
  5124. firstRender: true
  5125. };
  5126. return _this;
  5127. }
  5128. var _proto = TransitionGroup2.prototype;
  5129. _proto.componentDidMount = function componentDidMount() {
  5130. this.mounted = true;
  5131. this.setState({
  5132. contextValue: {
  5133. isMounting: false
  5134. }
  5135. });
  5136. };
  5137. _proto.componentWillUnmount = function componentWillUnmount() {
  5138. this.mounted = false;
  5139. };
  5140. TransitionGroup2.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, _ref) {
  5141. var prevChildMapping = _ref.children, handleExited = _ref.handleExited, firstRender = _ref.firstRender;
  5142. return {
  5143. children: firstRender ? getInitialChildMapping(nextProps, handleExited) : getNextChildMapping(nextProps, prevChildMapping, handleExited),
  5144. firstRender: false
  5145. };
  5146. };
  5147. _proto.handleExited = function handleExited(child, node2) {
  5148. var currentChildMapping = getChildMapping(this.props.children);
  5149. if (child.key in currentChildMapping) return;
  5150. if (child.props.onExited) {
  5151. child.props.onExited(node2);
  5152. }
  5153. if (this.mounted) {
  5154. this.setState(function(state) {
  5155. var children = _extends({}, state.children);
  5156. delete children[child.key];
  5157. return {
  5158. children
  5159. };
  5160. });
  5161. }
  5162. };
  5163. _proto.render = function render() {
  5164. var _this$props = this.props, Component = _this$props.component, childFactory2 = _this$props.childFactory, props = _objectWithoutPropertiesLoose(_this$props, ["component", "childFactory"]);
  5165. var contextValue = this.state.contextValue;
  5166. var children = values(this.state.children).map(childFactory2);
  5167. delete props.appear;
  5168. delete props.enter;
  5169. delete props.exit;
  5170. if (Component === null) {
  5171. return /* @__PURE__ */ React.createElement(TransitionGroupContext.Provider, {
  5172. value: contextValue
  5173. }, children);
  5174. }
  5175. return /* @__PURE__ */ React.createElement(TransitionGroupContext.Provider, {
  5176. value: contextValue
  5177. }, /* @__PURE__ */ React.createElement(Component, props, children));
  5178. };
  5179. return TransitionGroup2;
  5180. }(React.Component);
  5181. TransitionGroup.propTypes = {};
  5182. TransitionGroup.defaultProps = defaultProps;
  5183. function Ripple(props) {
  5184. const {
  5185. className,
  5186. classes,
  5187. pulsate = false,
  5188. rippleX,
  5189. rippleY,
  5190. rippleSize,
  5191. in: inProp,
  5192. onExited,
  5193. timeout
  5194. } = props;
  5195. const [leaving, setLeaving] = React__namespace.useState(false);
  5196. const rippleClassName = clsx(className, classes.ripple, classes.rippleVisible, pulsate && classes.ripplePulsate);
  5197. const rippleStyles = {
  5198. width: rippleSize,
  5199. height: rippleSize,
  5200. top: -(rippleSize / 2) + rippleY,
  5201. left: -(rippleSize / 2) + rippleX
  5202. };
  5203. const childClassName = clsx(classes.child, leaving && classes.childLeaving, pulsate && classes.childPulsate);
  5204. if (!inProp && !leaving) {
  5205. setLeaving(true);
  5206. }
  5207. React__namespace.useEffect(() => {
  5208. if (!inProp && onExited != null) {
  5209. const timeoutId = setTimeout(onExited, timeout);
  5210. return () => {
  5211. clearTimeout(timeoutId);
  5212. };
  5213. }
  5214. return void 0;
  5215. }, [onExited, inProp, timeout]);
  5216. return /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
  5217. className: rippleClassName,
  5218. style: rippleStyles,
  5219. children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
  5220. className: childClassName
  5221. })
  5222. });
  5223. }
  5224. const touchRippleClasses = generateUtilityClasses("MuiTouchRipple", ["root", "ripple", "rippleVisible", "ripplePulsate", "child", "childLeaving", "childPulsate"]);
  5225. const DURATION = 550;
  5226. const DELAY_RIPPLE = 80;
  5227. const enterKeyframe = keyframes`
  5228. 0% {
  5229. transform: scale(0);
  5230. opacity: 0.1;
  5231. }
  5232.  
  5233. 100% {
  5234. transform: scale(1);
  5235. opacity: 0.3;
  5236. }
  5237. `;
  5238. const exitKeyframe = keyframes`
  5239. 0% {
  5240. opacity: 1;
  5241. }
  5242.  
  5243. 100% {
  5244. opacity: 0;
  5245. }
  5246. `;
  5247. const pulsateKeyframe = keyframes`
  5248. 0% {
  5249. transform: scale(1);
  5250. }
  5251.  
  5252. 50% {
  5253. transform: scale(0.92);
  5254. }
  5255.  
  5256. 100% {
  5257. transform: scale(1);
  5258. }
  5259. `;
  5260. const TouchRippleRoot = styled("span", {
  5261. name: "MuiTouchRipple",
  5262. slot: "Root"
  5263. })({
  5264. overflow: "hidden",
  5265. pointerEvents: "none",
  5266. position: "absolute",
  5267. zIndex: 0,
  5268. top: 0,
  5269. right: 0,
  5270. bottom: 0,
  5271. left: 0,
  5272. borderRadius: "inherit"
  5273. });
  5274. const TouchRippleRipple = styled(Ripple, {
  5275. name: "MuiTouchRipple",
  5276. slot: "Ripple"
  5277. })`
  5278. opacity: 0;
  5279. position: absolute;
  5280.  
  5281. &.${touchRippleClasses.rippleVisible} {
  5282. opacity: 0.3;
  5283. transform: scale(1);
  5284. animation-name: ${enterKeyframe};
  5285. animation-duration: ${DURATION}ms;
  5286. animation-timing-function: ${({
  5287. theme
  5288. }) => theme.transitions.easing.easeInOut};
  5289. }
  5290.  
  5291. &.${touchRippleClasses.ripplePulsate} {
  5292. animation-duration: ${({
  5293. theme
  5294. }) => theme.transitions.duration.shorter}ms;
  5295. }
  5296.  
  5297. & .${touchRippleClasses.child} {
  5298. opacity: 1;
  5299. display: block;
  5300. width: 100%;
  5301. height: 100%;
  5302. border-radius: 50%;
  5303. background-color: currentColor;
  5304. }
  5305.  
  5306. & .${touchRippleClasses.childLeaving} {
  5307. opacity: 0;
  5308. animation-name: ${exitKeyframe};
  5309. animation-duration: ${DURATION}ms;
  5310. animation-timing-function: ${({
  5311. theme
  5312. }) => theme.transitions.easing.easeInOut};
  5313. }
  5314.  
  5315. & .${touchRippleClasses.childPulsate} {
  5316. position: absolute;
  5317. /* @noflip */
  5318. left: 0px;
  5319. top: 0;
  5320. animation-name: ${pulsateKeyframe};
  5321. animation-duration: 2500ms;
  5322. animation-timing-function: ${({
  5323. theme
  5324. }) => theme.transitions.easing.easeInOut};
  5325. animation-iteration-count: infinite;
  5326. animation-delay: 200ms;
  5327. }
  5328. `;
  5329. const TouchRipple = /* @__PURE__ */ React__namespace.forwardRef(function TouchRipple2(inProps, ref) {
  5330. const props = useDefaultProps({
  5331. props: inProps,
  5332. name: "MuiTouchRipple"
  5333. });
  5334. const {
  5335. center: centerProp = false,
  5336. classes = {},
  5337. className,
  5338. ...other
  5339. } = props;
  5340. const [ripples, setRipples] = React__namespace.useState([]);
  5341. const nextKey = React__namespace.useRef(0);
  5342. const rippleCallback = React__namespace.useRef(null);
  5343. React__namespace.useEffect(() => {
  5344. if (rippleCallback.current) {
  5345. rippleCallback.current();
  5346. rippleCallback.current = null;
  5347. }
  5348. }, [ripples]);
  5349. const ignoringMouseDown = React__namespace.useRef(false);
  5350. const startTimer = useTimeout();
  5351. const startTimerCommit = React__namespace.useRef(null);
  5352. const container = React__namespace.useRef(null);
  5353. const startCommit = React__namespace.useCallback((params) => {
  5354. const {
  5355. pulsate: pulsate2,
  5356. rippleX,
  5357. rippleY,
  5358. rippleSize,
  5359. cb
  5360. } = params;
  5361. setRipples((oldRipples) => [...oldRipples, /* @__PURE__ */ jsxRuntimeExports.jsx(TouchRippleRipple, {
  5362. classes: {
  5363. ripple: clsx(classes.ripple, touchRippleClasses.ripple),
  5364. rippleVisible: clsx(classes.rippleVisible, touchRippleClasses.rippleVisible),
  5365. ripplePulsate: clsx(classes.ripplePulsate, touchRippleClasses.ripplePulsate),
  5366. child: clsx(classes.child, touchRippleClasses.child),
  5367. childLeaving: clsx(classes.childLeaving, touchRippleClasses.childLeaving),
  5368. childPulsate: clsx(classes.childPulsate, touchRippleClasses.childPulsate)
  5369. },
  5370. timeout: DURATION,
  5371. pulsate: pulsate2,
  5372. rippleX,
  5373. rippleY,
  5374. rippleSize
  5375. }, nextKey.current)]);
  5376. nextKey.current += 1;
  5377. rippleCallback.current = cb;
  5378. }, [classes]);
  5379. const start = React__namespace.useCallback((event = {}, options = {}, cb = () => {
  5380. }) => {
  5381. const {
  5382. pulsate: pulsate2 = false,
  5383. center = centerProp || options.pulsate,
  5384. fakeElement = false
  5385. // For test purposes
  5386. } = options;
  5387. if ((event == null ? void 0 : event.type) === "mousedown" && ignoringMouseDown.current) {
  5388. ignoringMouseDown.current = false;
  5389. return;
  5390. }
  5391. if ((event == null ? void 0 : event.type) === "touchstart") {
  5392. ignoringMouseDown.current = true;
  5393. }
  5394. const element = fakeElement ? null : container.current;
  5395. const rect = element ? element.getBoundingClientRect() : {
  5396. width: 0,
  5397. height: 0,
  5398. left: 0,
  5399. top: 0
  5400. };
  5401. let rippleX;
  5402. let rippleY;
  5403. let rippleSize;
  5404. if (center || event === void 0 || event.clientX === 0 && event.clientY === 0 || !event.clientX && !event.touches) {
  5405. rippleX = Math.round(rect.width / 2);
  5406. rippleY = Math.round(rect.height / 2);
  5407. } else {
  5408. const {
  5409. clientX,
  5410. clientY
  5411. } = event.touches && event.touches.length > 0 ? event.touches[0] : event;
  5412. rippleX = Math.round(clientX - rect.left);
  5413. rippleY = Math.round(clientY - rect.top);
  5414. }
  5415. if (center) {
  5416. rippleSize = Math.sqrt((2 * rect.width ** 2 + rect.height ** 2) / 3);
  5417. if (rippleSize % 2 === 0) {
  5418. rippleSize += 1;
  5419. }
  5420. } else {
  5421. const sizeX = Math.max(Math.abs((element ? element.clientWidth : 0) - rippleX), rippleX) * 2 + 2;
  5422. const sizeY = Math.max(Math.abs((element ? element.clientHeight : 0) - rippleY), rippleY) * 2 + 2;
  5423. rippleSize = Math.sqrt(sizeX ** 2 + sizeY ** 2);
  5424. }
  5425. if (event == null ? void 0 : event.touches) {
  5426. if (startTimerCommit.current === null) {
  5427. startTimerCommit.current = () => {
  5428. startCommit({
  5429. pulsate: pulsate2,
  5430. rippleX,
  5431. rippleY,
  5432. rippleSize,
  5433. cb
  5434. });
  5435. };
  5436. startTimer.start(DELAY_RIPPLE, () => {
  5437. if (startTimerCommit.current) {
  5438. startTimerCommit.current();
  5439. startTimerCommit.current = null;
  5440. }
  5441. });
  5442. }
  5443. } else {
  5444. startCommit({
  5445. pulsate: pulsate2,
  5446. rippleX,
  5447. rippleY,
  5448. rippleSize,
  5449. cb
  5450. });
  5451. }
  5452. }, [centerProp, startCommit, startTimer]);
  5453. const pulsate = React__namespace.useCallback(() => {
  5454. start({}, {
  5455. pulsate: true
  5456. });
  5457. }, [start]);
  5458. const stop = React__namespace.useCallback((event, cb) => {
  5459. startTimer.clear();
  5460. if ((event == null ? void 0 : event.type) === "touchend" && startTimerCommit.current) {
  5461. startTimerCommit.current();
  5462. startTimerCommit.current = null;
  5463. startTimer.start(0, () => {
  5464. stop(event, cb);
  5465. });
  5466. return;
  5467. }
  5468. startTimerCommit.current = null;
  5469. setRipples((oldRipples) => {
  5470. if (oldRipples.length > 0) {
  5471. return oldRipples.slice(1);
  5472. }
  5473. return oldRipples;
  5474. });
  5475. rippleCallback.current = cb;
  5476. }, [startTimer]);
  5477. React__namespace.useImperativeHandle(ref, () => ({
  5478. pulsate,
  5479. start,
  5480. stop
  5481. }), [pulsate, start, stop]);
  5482. return /* @__PURE__ */ jsxRuntimeExports.jsx(TouchRippleRoot, {
  5483. className: clsx(touchRippleClasses.root, classes.root, className),
  5484. ref: container,
  5485. ...other,
  5486. children: /* @__PURE__ */ jsxRuntimeExports.jsx(TransitionGroup, {
  5487. component: null,
  5488. exit: true,
  5489. children: ripples
  5490. })
  5491. });
  5492. });
  5493. function getButtonBaseUtilityClass(slot) {
  5494. return generateUtilityClass("MuiButtonBase", slot);
  5495. }
  5496. const buttonBaseClasses = generateUtilityClasses("MuiButtonBase", ["root", "disabled", "focusVisible"]);
  5497. const useUtilityClasses$1 = (ownerState) => {
  5498. const {
  5499. disabled,
  5500. focusVisible,
  5501. focusVisibleClassName,
  5502. classes
  5503. } = ownerState;
  5504. const slots = {
  5505. root: ["root", disabled && "disabled", focusVisible && "focusVisible"]
  5506. };
  5507. const composedClasses = composeClasses(slots, getButtonBaseUtilityClass, classes);
  5508. if (focusVisible && focusVisibleClassName) {
  5509. composedClasses.root += ` ${focusVisibleClassName}`;
  5510. }
  5511. return composedClasses;
  5512. };
  5513. const ButtonBaseRoot = styled("button", {
  5514. name: "MuiButtonBase",
  5515. slot: "Root",
  5516. overridesResolver: (props, styles) => styles.root
  5517. })({
  5518. display: "inline-flex",
  5519. alignItems: "center",
  5520. justifyContent: "center",
  5521. position: "relative",
  5522. boxSizing: "border-box",
  5523. WebkitTapHighlightColor: "transparent",
  5524. backgroundColor: "transparent",
  5525. // Reset default value
  5526. // We disable the focus ring for mouse, touch and keyboard users.
  5527. outline: 0,
  5528. border: 0,
  5529. margin: 0,
  5530. // Remove the margin in Safari
  5531. borderRadius: 0,
  5532. padding: 0,
  5533. // Remove the padding in Firefox
  5534. cursor: "pointer",
  5535. userSelect: "none",
  5536. verticalAlign: "middle",
  5537. MozAppearance: "none",
  5538. // Reset
  5539. WebkitAppearance: "none",
  5540. // Reset
  5541. textDecoration: "none",
  5542. // So we take precedent over the style of a native <a /> element.
  5543. color: "inherit",
  5544. "&::-moz-focus-inner": {
  5545. borderStyle: "none"
  5546. // Remove Firefox dotted outline.
  5547. },
  5548. [`&.${buttonBaseClasses.disabled}`]: {
  5549. pointerEvents: "none",
  5550. // Disable link interactions
  5551. cursor: "default"
  5552. },
  5553. "@media print": {
  5554. colorAdjust: "exact"
  5555. }
  5556. });
  5557. const ButtonBase = /* @__PURE__ */ React__namespace.forwardRef(function ButtonBase2(inProps, ref) {
  5558. const props = useDefaultProps({
  5559. props: inProps,
  5560. name: "MuiButtonBase"
  5561. });
  5562. const {
  5563. action,
  5564. centerRipple = false,
  5565. children,
  5566. className,
  5567. component = "button",
  5568. disabled = false,
  5569. disableRipple = false,
  5570. disableTouchRipple = false,
  5571. focusRipple = false,
  5572. focusVisibleClassName,
  5573. LinkComponent = "a",
  5574. onBlur,
  5575. onClick,
  5576. onContextMenu,
  5577. onDragLeave,
  5578. onFocus,
  5579. onFocusVisible,
  5580. onKeyDown,
  5581. onKeyUp,
  5582. onMouseDown,
  5583. onMouseLeave,
  5584. onMouseUp,
  5585. onTouchEnd,
  5586. onTouchMove,
  5587. onTouchStart,
  5588. tabIndex = 0,
  5589. TouchRippleProps,
  5590. touchRippleRef,
  5591. type,
  5592. ...other
  5593. } = props;
  5594. const buttonRef = React__namespace.useRef(null);
  5595. const ripple = useLazyRipple();
  5596. const handleRippleRef = useForkRef(ripple.ref, touchRippleRef);
  5597. const [focusVisible, setFocusVisible] = React__namespace.useState(false);
  5598. if (disabled && focusVisible) {
  5599. setFocusVisible(false);
  5600. }
  5601. React__namespace.useImperativeHandle(action, () => ({
  5602. focusVisible: () => {
  5603. setFocusVisible(true);
  5604. buttonRef.current.focus();
  5605. }
  5606. }), []);
  5607. const enableTouchRipple = ripple.shouldMount && !disableRipple && !disabled;
  5608. React__namespace.useEffect(() => {
  5609. if (focusVisible && focusRipple && !disableRipple) {
  5610. ripple.pulsate();
  5611. }
  5612. }, [disableRipple, focusRipple, focusVisible, ripple]);
  5613. function useRippleHandler(rippleAction, eventCallback, skipRippleAction = disableTouchRipple) {
  5614. return useEventCallback((event) => {
  5615. if (eventCallback) {
  5616. eventCallback(event);
  5617. }
  5618. const ignore = skipRippleAction;
  5619. if (!ignore) {
  5620. ripple[rippleAction](event);
  5621. }
  5622. return true;
  5623. });
  5624. }
  5625. const handleMouseDown = useRippleHandler("start", onMouseDown);
  5626. const handleContextMenu = useRippleHandler("stop", onContextMenu);
  5627. const handleDragLeave = useRippleHandler("stop", onDragLeave);
  5628. const handleMouseUp = useRippleHandler("stop", onMouseUp);
  5629. const handleMouseLeave = useRippleHandler("stop", (event) => {
  5630. if (focusVisible) {
  5631. event.preventDefault();
  5632. }
  5633. if (onMouseLeave) {
  5634. onMouseLeave(event);
  5635. }
  5636. });
  5637. const handleTouchStart = useRippleHandler("start", onTouchStart);
  5638. const handleTouchEnd = useRippleHandler("stop", onTouchEnd);
  5639. const handleTouchMove = useRippleHandler("stop", onTouchMove);
  5640. const handleBlur = useRippleHandler("stop", (event) => {
  5641. if (!isFocusVisible(event.target)) {
  5642. setFocusVisible(false);
  5643. }
  5644. if (onBlur) {
  5645. onBlur(event);
  5646. }
  5647. }, false);
  5648. const handleFocus = useEventCallback((event) => {
  5649. if (!buttonRef.current) {
  5650. buttonRef.current = event.currentTarget;
  5651. }
  5652. if (isFocusVisible(event.target)) {
  5653. setFocusVisible(true);
  5654. if (onFocusVisible) {
  5655. onFocusVisible(event);
  5656. }
  5657. }
  5658. if (onFocus) {
  5659. onFocus(event);
  5660. }
  5661. });
  5662. const isNonNativeButton = () => {
  5663. const button = buttonRef.current;
  5664. return component && component !== "button" && !(button.tagName === "A" && button.href);
  5665. };
  5666. const handleKeyDown = useEventCallback((event) => {
  5667. if (focusRipple && !event.repeat && focusVisible && event.key === " ") {
  5668. ripple.stop(event, () => {
  5669. ripple.start(event);
  5670. });
  5671. }
  5672. if (event.target === event.currentTarget && isNonNativeButton() && event.key === " ") {
  5673. event.preventDefault();
  5674. }
  5675. if (onKeyDown) {
  5676. onKeyDown(event);
  5677. }
  5678. if (event.target === event.currentTarget && isNonNativeButton() && event.key === "Enter" && !disabled) {
  5679. event.preventDefault();
  5680. if (onClick) {
  5681. onClick(event);
  5682. }
  5683. }
  5684. });
  5685. const handleKeyUp = useEventCallback((event) => {
  5686. if (focusRipple && event.key === " " && focusVisible && !event.defaultPrevented) {
  5687. ripple.stop(event, () => {
  5688. ripple.pulsate(event);
  5689. });
  5690. }
  5691. if (onKeyUp) {
  5692. onKeyUp(event);
  5693. }
  5694. if (onClick && event.target === event.currentTarget && isNonNativeButton() && event.key === " " && !event.defaultPrevented) {
  5695. onClick(event);
  5696. }
  5697. });
  5698. let ComponentProp = component;
  5699. if (ComponentProp === "button" && (other.href || other.to)) {
  5700. ComponentProp = LinkComponent;
  5701. }
  5702. const buttonProps = {};
  5703. if (ComponentProp === "button") {
  5704. buttonProps.type = type === void 0 ? "button" : type;
  5705. buttonProps.disabled = disabled;
  5706. } else {
  5707. if (!other.href && !other.to) {
  5708. buttonProps.role = "button";
  5709. }
  5710. if (disabled) {
  5711. buttonProps["aria-disabled"] = disabled;
  5712. }
  5713. }
  5714. const handleRef = useForkRef(ref, buttonRef);
  5715. const ownerState = {
  5716. ...props,
  5717. centerRipple,
  5718. component,
  5719. disabled,
  5720. disableRipple,
  5721. disableTouchRipple,
  5722. focusRipple,
  5723. tabIndex,
  5724. focusVisible
  5725. };
  5726. const classes = useUtilityClasses$1(ownerState);
  5727. return /* @__PURE__ */ jsxRuntimeExports.jsxs(ButtonBaseRoot, {
  5728. as: ComponentProp,
  5729. className: clsx(classes.root, className),
  5730. ownerState,
  5731. onBlur: handleBlur,
  5732. onClick,
  5733. onContextMenu: handleContextMenu,
  5734. onFocus: handleFocus,
  5735. onKeyDown: handleKeyDown,
  5736. onKeyUp: handleKeyUp,
  5737. onMouseDown: handleMouseDown,
  5738. onMouseLeave: handleMouseLeave,
  5739. onMouseUp: handleMouseUp,
  5740. onDragLeave: handleDragLeave,
  5741. onTouchEnd: handleTouchEnd,
  5742. onTouchMove: handleTouchMove,
  5743. onTouchStart: handleTouchStart,
  5744. ref: handleRef,
  5745. tabIndex: disabled ? -1 : tabIndex,
  5746. type,
  5747. ...buttonProps,
  5748. ...other,
  5749. children: [children, enableTouchRipple ? /* @__PURE__ */ jsxRuntimeExports.jsx(TouchRipple, {
  5750. ref: handleRippleRef,
  5751. center: centerRipple,
  5752. ...TouchRippleProps
  5753. }) : null]
  5754. });
  5755. });
  5756. function hasCorrectMainProperty(obj) {
  5757. return typeof obj.main === "string";
  5758. }
  5759. function checkSimplePaletteColorValues(obj, additionalPropertiesToCheck = []) {
  5760. if (!hasCorrectMainProperty(obj)) {
  5761. return false;
  5762. }
  5763. for (const value of additionalPropertiesToCheck) {
  5764. if (!obj.hasOwnProperty(value) || typeof obj[value] !== "string") {
  5765. return false;
  5766. }
  5767. }
  5768. return true;
  5769. }
  5770. function createSimplePaletteValueFilter(additionalPropertiesToCheck = []) {
  5771. return ([, value]) => value && checkSimplePaletteColorValues(value, additionalPropertiesToCheck);
  5772. }
  5773. function getButtonUtilityClass(slot) {
  5774. return generateUtilityClass("MuiButton", slot);
  5775. }
  5776. const buttonClasses = generateUtilityClasses("MuiButton", ["root", "text", "textInherit", "textPrimary", "textSecondary", "textSuccess", "textError", "textInfo", "textWarning", "outlined", "outlinedInherit", "outlinedPrimary", "outlinedSecondary", "outlinedSuccess", "outlinedError", "outlinedInfo", "outlinedWarning", "contained", "containedInherit", "containedPrimary", "containedSecondary", "containedSuccess", "containedError", "containedInfo", "containedWarning", "disableElevation", "focusVisible", "disabled", "colorInherit", "colorPrimary", "colorSecondary", "colorSuccess", "colorError", "colorInfo", "colorWarning", "textSizeSmall", "textSizeMedium", "textSizeLarge", "outlinedSizeSmall", "outlinedSizeMedium", "outlinedSizeLarge", "containedSizeSmall", "containedSizeMedium", "containedSizeLarge", "sizeMedium", "sizeSmall", "sizeLarge", "fullWidth", "startIcon", "endIcon", "icon", "iconSizeSmall", "iconSizeMedium", "iconSizeLarge"]);
  5777. const ButtonGroupContext = /* @__PURE__ */ React__namespace.createContext({});
  5778. const ButtonGroupButtonContext = /* @__PURE__ */ React__namespace.createContext(void 0);
  5779. const useUtilityClasses = (ownerState) => {
  5780. const {
  5781. color: color2,
  5782. disableElevation,
  5783. fullWidth,
  5784. size,
  5785. variant,
  5786. classes
  5787. } = ownerState;
  5788. const slots = {
  5789. root: ["root", variant, `${variant}${capitalize(color2)}`, `size${capitalize(size)}`, `${variant}Size${capitalize(size)}`, `color${capitalize(color2)}`, disableElevation && "disableElevation", fullWidth && "fullWidth"],
  5790. label: ["label"],
  5791. startIcon: ["icon", "startIcon", `iconSize${capitalize(size)}`],
  5792. endIcon: ["icon", "endIcon", `iconSize${capitalize(size)}`]
  5793. };
  5794. const composedClasses = composeClasses(slots, getButtonUtilityClass, classes);
  5795. return {
  5796. ...classes,
  5797. // forward the focused, disabled, etc. classes to the ButtonBase
  5798. ...composedClasses
  5799. };
  5800. };
  5801. const commonIconStyles = [{
  5802. props: {
  5803. size: "small"
  5804. },
  5805. style: {
  5806. "& > *:nth-of-type(1)": {
  5807. fontSize: 18
  5808. }
  5809. }
  5810. }, {
  5811. props: {
  5812. size: "medium"
  5813. },
  5814. style: {
  5815. "& > *:nth-of-type(1)": {
  5816. fontSize: 20
  5817. }
  5818. }
  5819. }, {
  5820. props: {
  5821. size: "large"
  5822. },
  5823. style: {
  5824. "& > *:nth-of-type(1)": {
  5825. fontSize: 22
  5826. }
  5827. }
  5828. }];
  5829. const ButtonRoot = styled(ButtonBase, {
  5830. shouldForwardProp: (prop) => rootShouldForwardProp(prop) || prop === "classes",
  5831. name: "MuiButton",
  5832. slot: "Root",
  5833. overridesResolver: (props, styles) => {
  5834. const {
  5835. ownerState
  5836. } = props;
  5837. return [styles.root, styles[ownerState.variant], styles[`${ownerState.variant}${capitalize(ownerState.color)}`], styles[`size${capitalize(ownerState.size)}`], styles[`${ownerState.variant}Size${capitalize(ownerState.size)}`], ownerState.color === "inherit" && styles.colorInherit, ownerState.disableElevation && styles.disableElevation, ownerState.fullWidth && styles.fullWidth];
  5838. }
  5839. })(memoTheme(({
  5840. theme
  5841. }) => {
  5842. const inheritContainedBackgroundColor = theme.palette.mode === "light" ? theme.palette.grey[300] : theme.palette.grey[800];
  5843. const inheritContainedHoverBackgroundColor = theme.palette.mode === "light" ? theme.palette.grey.A100 : theme.palette.grey[700];
  5844. return {
  5845. ...theme.typography.button,
  5846. minWidth: 64,
  5847. padding: "6px 16px",
  5848. border: 0,
  5849. borderRadius: (theme.vars || theme).shape.borderRadius,
  5850. transition: theme.transitions.create(["background-color", "box-shadow", "border-color", "color"], {
  5851. duration: theme.transitions.duration.short
  5852. }),
  5853. "&:hover": {
  5854. textDecoration: "none"
  5855. },
  5856. [`&.${buttonClasses.disabled}`]: {
  5857. color: (theme.vars || theme).palette.action.disabled
  5858. },
  5859. variants: [{
  5860. props: {
  5861. variant: "contained"
  5862. },
  5863. style: {
  5864. color: `var(--variant-containedColor)`,
  5865. backgroundColor: `var(--variant-containedBg)`,
  5866. boxShadow: (theme.vars || theme).shadows[2],
  5867. "&:hover": {
  5868. boxShadow: (theme.vars || theme).shadows[4],
  5869. // Reset on touch devices, it doesn't add specificity
  5870. "@media (hover: none)": {
  5871. boxShadow: (theme.vars || theme).shadows[2]
  5872. }
  5873. },
  5874. "&:active": {
  5875. boxShadow: (theme.vars || theme).shadows[8]
  5876. },
  5877. [`&.${buttonClasses.focusVisible}`]: {
  5878. boxShadow: (theme.vars || theme).shadows[6]
  5879. },
  5880. [`&.${buttonClasses.disabled}`]: {
  5881. color: (theme.vars || theme).palette.action.disabled,
  5882. boxShadow: (theme.vars || theme).shadows[0],
  5883. backgroundColor: (theme.vars || theme).palette.action.disabledBackground
  5884. }
  5885. }
  5886. }, {
  5887. props: {
  5888. variant: "outlined"
  5889. },
  5890. style: {
  5891. padding: "5px 15px",
  5892. border: "1px solid currentColor",
  5893. borderColor: `var(--variant-outlinedBorder, currentColor)`,
  5894. backgroundColor: `var(--variant-outlinedBg)`,
  5895. color: `var(--variant-outlinedColor)`,
  5896. [`&.${buttonClasses.disabled}`]: {
  5897. border: `1px solid ${(theme.vars || theme).palette.action.disabledBackground}`
  5898. }
  5899. }
  5900. }, {
  5901. props: {
  5902. variant: "text"
  5903. },
  5904. style: {
  5905. padding: "6px 8px",
  5906. color: `var(--variant-textColor)`,
  5907. backgroundColor: `var(--variant-textBg)`
  5908. }
  5909. }, ...Object.entries(theme.palette).filter(createSimplePaletteValueFilter()).map(([color2]) => ({
  5910. props: {
  5911. color: color2
  5912. },
  5913. style: {
  5914. "--variant-textColor": (theme.vars || theme).palette[color2].main,
  5915. "--variant-outlinedColor": (theme.vars || theme).palette[color2].main,
  5916. "--variant-outlinedBorder": theme.vars ? `rgba(${theme.vars.palette[color2].mainChannel} / 0.5)` : alpha(theme.palette[color2].main, 0.5),
  5917. "--variant-containedColor": (theme.vars || theme).palette[color2].contrastText,
  5918. "--variant-containedBg": (theme.vars || theme).palette[color2].main,
  5919. "@media (hover: hover)": {
  5920. "&:hover": {
  5921. "--variant-containedBg": (theme.vars || theme).palette[color2].dark,
  5922. "--variant-textBg": theme.vars ? `rgba(${theme.vars.palette[color2].mainChannel} / ${theme.vars.palette.action.hoverOpacity})` : alpha(theme.palette[color2].main, theme.palette.action.hoverOpacity),
  5923. "--variant-outlinedBorder": (theme.vars || theme).palette[color2].main,
  5924. "--variant-outlinedBg": theme.vars ? `rgba(${theme.vars.palette[color2].mainChannel} / ${theme.vars.palette.action.hoverOpacity})` : alpha(theme.palette[color2].main, theme.palette.action.hoverOpacity)
  5925. }
  5926. }
  5927. }
  5928. })), {
  5929. props: {
  5930. color: "inherit"
  5931. },
  5932. style: {
  5933. color: "inherit",
  5934. borderColor: "currentColor",
  5935. "--variant-containedBg": theme.vars ? theme.vars.palette.Button.inheritContainedBg : inheritContainedBackgroundColor,
  5936. "@media (hover: hover)": {
  5937. "&:hover": {
  5938. "--variant-containedBg": theme.vars ? theme.vars.palette.Button.inheritContainedHoverBg : inheritContainedHoverBackgroundColor,
  5939. "--variant-textBg": theme.vars ? `rgba(${theme.vars.palette.text.primaryChannel} / ${theme.vars.palette.action.hoverOpacity})` : alpha(theme.palette.text.primary, theme.palette.action.hoverOpacity),
  5940. "--variant-outlinedBg": theme.vars ? `rgba(${theme.vars.palette.text.primaryChannel} / ${theme.vars.palette.action.hoverOpacity})` : alpha(theme.palette.text.primary, theme.palette.action.hoverOpacity)
  5941. }
  5942. }
  5943. }
  5944. }, {
  5945. props: {
  5946. size: "small",
  5947. variant: "text"
  5948. },
  5949. style: {
  5950. padding: "4px 5px",
  5951. fontSize: theme.typography.pxToRem(13)
  5952. }
  5953. }, {
  5954. props: {
  5955. size: "large",
  5956. variant: "text"
  5957. },
  5958. style: {
  5959. padding: "8px 11px",
  5960. fontSize: theme.typography.pxToRem(15)
  5961. }
  5962. }, {
  5963. props: {
  5964. size: "small",
  5965. variant: "outlined"
  5966. },
  5967. style: {
  5968. padding: "3px 9px",
  5969. fontSize: theme.typography.pxToRem(13)
  5970. }
  5971. }, {
  5972. props: {
  5973. size: "large",
  5974. variant: "outlined"
  5975. },
  5976. style: {
  5977. padding: "7px 21px",
  5978. fontSize: theme.typography.pxToRem(15)
  5979. }
  5980. }, {
  5981. props: {
  5982. size: "small",
  5983. variant: "contained"
  5984. },
  5985. style: {
  5986. padding: "4px 10px",
  5987. fontSize: theme.typography.pxToRem(13)
  5988. }
  5989. }, {
  5990. props: {
  5991. size: "large",
  5992. variant: "contained"
  5993. },
  5994. style: {
  5995. padding: "8px 22px",
  5996. fontSize: theme.typography.pxToRem(15)
  5997. }
  5998. }, {
  5999. props: {
  6000. disableElevation: true
  6001. },
  6002. style: {
  6003. boxShadow: "none",
  6004. "&:hover": {
  6005. boxShadow: "none"
  6006. },
  6007. [`&.${buttonClasses.focusVisible}`]: {
  6008. boxShadow: "none"
  6009. },
  6010. "&:active": {
  6011. boxShadow: "none"
  6012. },
  6013. [`&.${buttonClasses.disabled}`]: {
  6014. boxShadow: "none"
  6015. }
  6016. }
  6017. }, {
  6018. props: {
  6019. fullWidth: true
  6020. },
  6021. style: {
  6022. width: "100%"
  6023. }
  6024. }]
  6025. };
  6026. }));
  6027. const ButtonStartIcon = styled("span", {
  6028. name: "MuiButton",
  6029. slot: "StartIcon",
  6030. overridesResolver: (props, styles) => {
  6031. const {
  6032. ownerState
  6033. } = props;
  6034. return [styles.startIcon, styles[`iconSize${capitalize(ownerState.size)}`]];
  6035. }
  6036. })({
  6037. display: "inherit",
  6038. marginRight: 8,
  6039. marginLeft: -4,
  6040. variants: [{
  6041. props: {
  6042. size: "small"
  6043. },
  6044. style: {
  6045. marginLeft: -2
  6046. }
  6047. }, ...commonIconStyles]
  6048. });
  6049. const ButtonEndIcon = styled("span", {
  6050. name: "MuiButton",
  6051. slot: "EndIcon",
  6052. overridesResolver: (props, styles) => {
  6053. const {
  6054. ownerState
  6055. } = props;
  6056. return [styles.endIcon, styles[`iconSize${capitalize(ownerState.size)}`]];
  6057. }
  6058. })({
  6059. display: "inherit",
  6060. marginRight: -4,
  6061. marginLeft: 8,
  6062. variants: [{
  6063. props: {
  6064. size: "small"
  6065. },
  6066. style: {
  6067. marginRight: -2
  6068. }
  6069. }, ...commonIconStyles]
  6070. });
  6071. const Button = /* @__PURE__ */ React__namespace.forwardRef(function Button2(inProps, ref) {
  6072. const contextProps = React__namespace.useContext(ButtonGroupContext);
  6073. const buttonGroupButtonContextPositionClassName = React__namespace.useContext(ButtonGroupButtonContext);
  6074. const resolvedProps = resolveProps(contextProps, inProps);
  6075. const props = useDefaultProps({
  6076. props: resolvedProps,
  6077. name: "MuiButton"
  6078. });
  6079. const {
  6080. children,
  6081. color: color2 = "primary",
  6082. component = "button",
  6083. className,
  6084. disabled = false,
  6085. disableElevation = false,
  6086. disableFocusRipple = false,
  6087. endIcon: endIconProp,
  6088. focusVisibleClassName,
  6089. fullWidth = false,
  6090. size = "medium",
  6091. startIcon: startIconProp,
  6092. type,
  6093. variant = "text",
  6094. ...other
  6095. } = props;
  6096. const ownerState = {
  6097. ...props,
  6098. color: color2,
  6099. component,
  6100. disabled,
  6101. disableElevation,
  6102. disableFocusRipple,
  6103. fullWidth,
  6104. size,
  6105. type,
  6106. variant
  6107. };
  6108. const classes = useUtilityClasses(ownerState);
  6109. const startIcon = startIconProp && /* @__PURE__ */ jsxRuntimeExports.jsx(ButtonStartIcon, {
  6110. className: classes.startIcon,
  6111. ownerState,
  6112. children: startIconProp
  6113. });
  6114. const endIcon = endIconProp && /* @__PURE__ */ jsxRuntimeExports.jsx(ButtonEndIcon, {
  6115. className: classes.endIcon,
  6116. ownerState,
  6117. children: endIconProp
  6118. });
  6119. const positionClassName = buttonGroupButtonContextPositionClassName || "";
  6120. return /* @__PURE__ */ jsxRuntimeExports.jsxs(ButtonRoot, {
  6121. ownerState,
  6122. className: clsx(contextProps.className, classes.root, className, positionClassName),
  6123. component,
  6124. disabled,
  6125. focusRipple: !disableFocusRipple,
  6126. focusVisibleClassName: clsx(classes.focusVisible, focusVisibleClassName),
  6127. ref,
  6128. type,
  6129. ...other,
  6130. classes,
  6131. children: [startIcon, children, endIcon]
  6132. });
  6133. });
  6134. function MpvButton({ onClick }) {
  6135. return /* @__PURE__ */ jsxRuntimeExports.jsx(
  6136. Box,
  6137. {
  6138. sx: {
  6139. color: "white",
  6140. backgroundColor: "black",
  6141. marginTop: "20px",
  6142. border: "2px solid white",
  6143. borderRadius: "5px",
  6144. fontSize: "20px",
  6145. "&:hover": {
  6146. backgroundColor: "#00B4D8"
  6147. }
  6148. },
  6149. children: /* @__PURE__ */ jsxRuntimeExports.jsx(
  6150. Button,
  6151. {
  6152. variant: "text",
  6153. onClick,
  6154. fullWidth: true,
  6155. sx: { padding: "10px 50px" },
  6156. children: "用 MPV 播放"
  6157. }
  6158. )
  6159. }
  6160. );
  6161. }
  6162. function MessageBox({ text }) {
  6163. return /* @__PURE__ */ jsxRuntimeExports.jsx(
  6164. Box,
  6165. {
  6166. sx: {
  6167. color: "white",
  6168. marginTop: "20px",
  6169. fontSize: "15px",
  6170. fontWeight: "bold",
  6171. whiteSpace: "nowrap"
  6172. },
  6173. children: text
  6174. }
  6175. );
  6176. }
  6177. function Page({ onClick, text }) {
  6178. return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
  6179. /* @__PURE__ */ jsxRuntimeExports.jsx(MpvButton, { onClick }),
  6180. /* @__PURE__ */ jsxRuntimeExports.jsx(MessageBox, { text })
  6181. ] });
  6182. }
  6183. function bind(fn, thisArg) {
  6184. return function wrap() {
  6185. return fn.apply(thisArg, arguments);
  6186. };
  6187. }
  6188. const { toString } = Object.prototype;
  6189. const { getPrototypeOf } = Object;
  6190. const kindOf = /* @__PURE__ */ ((cache) => (thing) => {
  6191. const str = toString.call(thing);
  6192. return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
  6193. })(/* @__PURE__ */ Object.create(null));
  6194. const kindOfTest = (type) => {
  6195. type = type.toLowerCase();
  6196. return (thing) => kindOf(thing) === type;
  6197. };
  6198. const typeOfTest = (type) => (thing) => typeof thing === type;
  6199. const { isArray } = Array;
  6200. const isUndefined = typeOfTest("undefined");
  6201. function isBuffer(val) {
  6202. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
  6203. }
  6204. const isArrayBuffer = kindOfTest("ArrayBuffer");
  6205. function isArrayBufferView(val) {
  6206. let result;
  6207. if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
  6208. result = ArrayBuffer.isView(val);
  6209. } else {
  6210. result = val && val.buffer && isArrayBuffer(val.buffer);
  6211. }
  6212. return result;
  6213. }
  6214. const isString = typeOfTest("string");
  6215. const isFunction = typeOfTest("function");
  6216. const isNumber = typeOfTest("number");
  6217. const isObject = (thing) => thing !== null && typeof thing === "object";
  6218. const isBoolean = (thing) => thing === true || thing === false;
  6219. const isPlainObject = (val) => {
  6220. if (kindOf(val) !== "object") {
  6221. return false;
  6222. }
  6223. const prototype2 = getPrototypeOf(val);
  6224. return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
  6225. };
  6226. const isDate = kindOfTest("Date");
  6227. const isFile = kindOfTest("File");
  6228. const isBlob = kindOfTest("Blob");
  6229. const isFileList = kindOfTest("FileList");
  6230. const isStream = (val) => isObject(val) && isFunction(val.pipe);
  6231. const isFormData = (thing) => {
  6232. let kind;
  6233. return thing && (typeof FormData === "function" && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === "formdata" || // detect form-data instance
  6234. kind === "object" && isFunction(thing.toString) && thing.toString() === "[object FormData]"));
  6235. };
  6236. const isURLSearchParams = kindOfTest("URLSearchParams");
  6237. const [isReadableStream, isRequest, isResponse, isHeaders] = ["ReadableStream", "Request", "Response", "Headers"].map(kindOfTest);
  6238. const trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
  6239. function forEach(obj, fn, { allOwnKeys = false } = {}) {
  6240. if (obj === null || typeof obj === "undefined") {
  6241. return;
  6242. }
  6243. let i;
  6244. let l2;
  6245. if (typeof obj !== "object") {
  6246. obj = [obj];
  6247. }
  6248. if (isArray(obj)) {
  6249. for (i = 0, l2 = obj.length; i < l2; i++) {
  6250. fn.call(null, obj[i], i, obj);
  6251. }
  6252. } else {
  6253. const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
  6254. const len = keys.length;
  6255. let key;
  6256. for (i = 0; i < len; i++) {
  6257. key = keys[i];
  6258. fn.call(null, obj[key], key, obj);
  6259. }
  6260. }
  6261. }
  6262. function findKey(obj, key) {
  6263. key = key.toLowerCase();
  6264. const keys = Object.keys(obj);
  6265. let i = keys.length;
  6266. let _key;
  6267. while (i-- > 0) {
  6268. _key = keys[i];
  6269. if (key === _key.toLowerCase()) {
  6270. return _key;
  6271. }
  6272. }
  6273. return null;
  6274. }
  6275. const _global = (() => {
  6276. if (typeof globalThis !== "undefined") return globalThis;
  6277. return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
  6278. })();
  6279. const isContextDefined = (context) => !isUndefined(context) && context !== _global;
  6280. function merge() {
  6281. const { caseless } = isContextDefined(this) && this || {};
  6282. const result = {};
  6283. const assignValue = (val, key) => {
  6284. const targetKey = caseless && findKey(result, key) || key;
  6285. if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
  6286. result[targetKey] = merge(result[targetKey], val);
  6287. } else if (isPlainObject(val)) {
  6288. result[targetKey] = merge({}, val);
  6289. } else if (isArray(val)) {
  6290. result[targetKey] = val.slice();
  6291. } else {
  6292. result[targetKey] = val;
  6293. }
  6294. };
  6295. for (let i = 0, l2 = arguments.length; i < l2; i++) {
  6296. arguments[i] && forEach(arguments[i], assignValue);
  6297. }
  6298. return result;
  6299. }
  6300. const extend = (a, b2, thisArg, { allOwnKeys } = {}) => {
  6301. forEach(b2, (val, key) => {
  6302. if (thisArg && isFunction(val)) {
  6303. a[key] = bind(val, thisArg);
  6304. } else {
  6305. a[key] = val;
  6306. }
  6307. }, { allOwnKeys });
  6308. return a;
  6309. };
  6310. const stripBOM = (content) => {
  6311. if (content.charCodeAt(0) === 65279) {
  6312. content = content.slice(1);
  6313. }
  6314. return content;
  6315. };
  6316. const inherits = (constructor, superConstructor, props, descriptors2) => {
  6317. constructor.prototype = Object.create(superConstructor.prototype, descriptors2);
  6318. constructor.prototype.constructor = constructor;
  6319. Object.defineProperty(constructor, "super", {
  6320. value: superConstructor.prototype
  6321. });
  6322. props && Object.assign(constructor.prototype, props);
  6323. };
  6324. const toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
  6325. let props;
  6326. let i;
  6327. let prop;
  6328. const merged = {};
  6329. destObj = destObj || {};
  6330. if (sourceObj == null) return destObj;
  6331. do {
  6332. props = Object.getOwnPropertyNames(sourceObj);
  6333. i = props.length;
  6334. while (i-- > 0) {
  6335. prop = props[i];
  6336. if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
  6337. destObj[prop] = sourceObj[prop];
  6338. merged[prop] = true;
  6339. }
  6340. }
  6341. sourceObj = filter2 !== false && getPrototypeOf(sourceObj);
  6342. } while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
  6343. return destObj;
  6344. };
  6345. const endsWith = (str, searchString, position2) => {
  6346. str = String(str);
  6347. if (position2 === void 0 || position2 > str.length) {
  6348. position2 = str.length;
  6349. }
  6350. position2 -= searchString.length;
  6351. const lastIndex = str.indexOf(searchString, position2);
  6352. return lastIndex !== -1 && lastIndex === position2;
  6353. };
  6354. const toArray = (thing) => {
  6355. if (!thing) return null;
  6356. if (isArray(thing)) return thing;
  6357. let i = thing.length;
  6358. if (!isNumber(i)) return null;
  6359. const arr = new Array(i);
  6360. while (i-- > 0) {
  6361. arr[i] = thing[i];
  6362. }
  6363. return arr;
  6364. };
  6365. const isTypedArray = /* @__PURE__ */ ((TypedArray) => {
  6366. return (thing) => {
  6367. return TypedArray && thing instanceof TypedArray;
  6368. };
  6369. })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
  6370. const forEachEntry = (obj, fn) => {
  6371. const generator = obj && obj[Symbol.iterator];
  6372. const iterator = generator.call(obj);
  6373. let result;
  6374. while ((result = iterator.next()) && !result.done) {
  6375. const pair = result.value;
  6376. fn.call(obj, pair[0], pair[1]);
  6377. }
  6378. };
  6379. const matchAll = (regExp, str) => {
  6380. let matches;
  6381. const arr = [];
  6382. while ((matches = regExp.exec(str)) !== null) {
  6383. arr.push(matches);
  6384. }
  6385. return arr;
  6386. };
  6387. const isHTMLForm = kindOfTest("HTMLFormElement");
  6388. const toCamelCase = (str) => {
  6389. return str.toLowerCase().replace(
  6390. /[-_\s]([a-z\d])(\w*)/g,
  6391. function replacer(m2, p1, p2) {
  6392. return p1.toUpperCase() + p2;
  6393. }
  6394. );
  6395. };
  6396. const hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
  6397. const isRegExp = kindOfTest("RegExp");
  6398. const reduceDescriptors = (obj, reducer) => {
  6399. const descriptors2 = Object.getOwnPropertyDescriptors(obj);
  6400. const reducedDescriptors = {};
  6401. forEach(descriptors2, (descriptor, name) => {
  6402. let ret;
  6403. if ((ret = reducer(descriptor, name, obj)) !== false) {
  6404. reducedDescriptors[name] = ret || descriptor;
  6405. }
  6406. });
  6407. Object.defineProperties(obj, reducedDescriptors);
  6408. };
  6409. const freezeMethods = (obj) => {
  6410. reduceDescriptors(obj, (descriptor, name) => {
  6411. if (isFunction(obj) && ["arguments", "caller", "callee"].indexOf(name) !== -1) {
  6412. return false;
  6413. }
  6414. const value = obj[name];
  6415. if (!isFunction(value)) return;
  6416. descriptor.enumerable = false;
  6417. if ("writable" in descriptor) {
  6418. descriptor.writable = false;
  6419. return;
  6420. }
  6421. if (!descriptor.set) {
  6422. descriptor.set = () => {
  6423. throw Error("Can not rewrite read-only method '" + name + "'");
  6424. };
  6425. }
  6426. });
  6427. };
  6428. const toObjectSet = (arrayOrString, delimiter2) => {
  6429. const obj = {};
  6430. const define = (arr) => {
  6431. arr.forEach((value) => {
  6432. obj[value] = true;
  6433. });
  6434. };
  6435. isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter2));
  6436. return obj;
  6437. };
  6438. const noop = () => {
  6439. };
  6440. const toFiniteNumber = (value, defaultValue) => {
  6441. return value != null && Number.isFinite(value = +value) ? value : defaultValue;
  6442. };
  6443. const ALPHA = "abcdefghijklmnopqrstuvwxyz";
  6444. const DIGIT = "0123456789";
  6445. const ALPHABET = {
  6446. DIGIT,
  6447. ALPHA,
  6448. ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
  6449. };
  6450. const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
  6451. let str = "";
  6452. const { length: length2 } = alphabet;
  6453. while (size--) {
  6454. str += alphabet[Math.random() * length2 | 0];
  6455. }
  6456. return str;
  6457. };
  6458. function isSpecCompliantForm(thing) {
  6459. return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === "FormData" && thing[Symbol.iterator]);
  6460. }
  6461. const toJSONObject = (obj) => {
  6462. const stack = new Array(10);
  6463. const visit = (source, i) => {
  6464. if (isObject(source)) {
  6465. if (stack.indexOf(source) >= 0) {
  6466. return;
  6467. }
  6468. if (!("toJSON" in source)) {
  6469. stack[i] = source;
  6470. const target = isArray(source) ? [] : {};
  6471. forEach(source, (value, key) => {
  6472. const reducedValue = visit(value, i + 1);
  6473. !isUndefined(reducedValue) && (target[key] = reducedValue);
  6474. });
  6475. stack[i] = void 0;
  6476. return target;
  6477. }
  6478. }
  6479. return source;
  6480. };
  6481. return visit(obj, 0);
  6482. };
  6483. const isAsyncFn = kindOfTest("AsyncFunction");
  6484. const isThenable = (thing) => thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
  6485. const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
  6486. if (setImmediateSupported) {
  6487. return setImmediate;
  6488. }
  6489. return postMessageSupported ? ((token2, callbacks) => {
  6490. _global.addEventListener("message", ({ source, data }) => {
  6491. if (source === _global && data === token2) {
  6492. callbacks.length && callbacks.shift()();
  6493. }
  6494. }, false);
  6495. return (cb) => {
  6496. callbacks.push(cb);
  6497. _global.postMessage(token2, "*");
  6498. };
  6499. })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
  6500. })(
  6501. typeof setImmediate === "function",
  6502. isFunction(_global.postMessage)
  6503. );
  6504. const asap = typeof queueMicrotask !== "undefined" ? queueMicrotask.bind(_global) : typeof process !== "undefined" && process.nextTick || _setImmediate;
  6505. const utils$1 = {
  6506. isArray,
  6507. isArrayBuffer,
  6508. isBuffer,
  6509. isFormData,
  6510. isArrayBufferView,
  6511. isString,
  6512. isNumber,
  6513. isBoolean,
  6514. isObject,
  6515. isPlainObject,
  6516. isReadableStream,
  6517. isRequest,
  6518. isResponse,
  6519. isHeaders,
  6520. isUndefined,
  6521. isDate,
  6522. isFile,
  6523. isBlob,
  6524. isRegExp,
  6525. isFunction,
  6526. isStream,
  6527. isURLSearchParams,
  6528. isTypedArray,
  6529. isFileList,
  6530. forEach,
  6531. merge,
  6532. extend,
  6533. trim,
  6534. stripBOM,
  6535. inherits,
  6536. toFlatObject,
  6537. kindOf,
  6538. kindOfTest,
  6539. endsWith,
  6540. toArray,
  6541. forEachEntry,
  6542. matchAll,
  6543. isHTMLForm,
  6544. hasOwnProperty,
  6545. hasOwnProp: hasOwnProperty,
  6546. // an alias to avoid ESLint no-prototype-builtins detection
  6547. reduceDescriptors,
  6548. freezeMethods,
  6549. toObjectSet,
  6550. toCamelCase,
  6551. noop,
  6552. toFiniteNumber,
  6553. findKey,
  6554. global: _global,
  6555. isContextDefined,
  6556. ALPHABET,
  6557. generateString,
  6558. isSpecCompliantForm,
  6559. toJSONObject,
  6560. isAsyncFn,
  6561. isThenable,
  6562. setImmediate: _setImmediate,
  6563. asap
  6564. };
  6565. function AxiosError(message, code, config, request, response) {
  6566. Error.call(this);
  6567. if (Error.captureStackTrace) {
  6568. Error.captureStackTrace(this, this.constructor);
  6569. } else {
  6570. this.stack = new Error().stack;
  6571. }
  6572. this.message = message;
  6573. this.name = "AxiosError";
  6574. code && (this.code = code);
  6575. config && (this.config = config);
  6576. request && (this.request = request);
  6577. if (response) {
  6578. this.response = response;
  6579. this.status = response.status ? response.status : null;
  6580. }
  6581. }
  6582. utils$1.inherits(AxiosError, Error, {
  6583. toJSON: function toJSON() {
  6584. return {
  6585. // Standard
  6586. message: this.message,
  6587. name: this.name,
  6588. // Microsoft
  6589. description: this.description,
  6590. number: this.number,
  6591. // Mozilla
  6592. fileName: this.fileName,
  6593. lineNumber: this.lineNumber,
  6594. columnNumber: this.columnNumber,
  6595. stack: this.stack,
  6596. // Axios
  6597. config: utils$1.toJSONObject(this.config),
  6598. code: this.code,
  6599. status: this.status
  6600. };
  6601. }
  6602. });
  6603. const prototype$1 = AxiosError.prototype;
  6604. const descriptors = {};
  6605. [
  6606. "ERR_BAD_OPTION_VALUE",
  6607. "ERR_BAD_OPTION",
  6608. "ECONNABORTED",
  6609. "ETIMEDOUT",
  6610. "ERR_NETWORK",
  6611. "ERR_FR_TOO_MANY_REDIRECTS",
  6612. "ERR_DEPRECATED",
  6613. "ERR_BAD_RESPONSE",
  6614. "ERR_BAD_REQUEST",
  6615. "ERR_CANCELED",
  6616. "ERR_NOT_SUPPORT",
  6617. "ERR_INVALID_URL"
  6618. // eslint-disable-next-line func-names
  6619. ].forEach((code) => {
  6620. descriptors[code] = { value: code };
  6621. });
  6622. Object.defineProperties(AxiosError, descriptors);
  6623. Object.defineProperty(prototype$1, "isAxiosError", { value: true });
  6624. AxiosError.from = (error, code, config, request, response, customProps) => {
  6625. const axiosError = Object.create(prototype$1);
  6626. utils$1.toFlatObject(error, axiosError, function filter2(obj) {
  6627. return obj !== Error.prototype;
  6628. }, (prop) => {
  6629. return prop !== "isAxiosError";
  6630. });
  6631. AxiosError.call(axiosError, error.message, code, config, request, response);
  6632. axiosError.cause = error;
  6633. axiosError.name = error.name;
  6634. customProps && Object.assign(axiosError, customProps);
  6635. return axiosError;
  6636. };
  6637. const httpAdapter = null;
  6638. function isVisitable(thing) {
  6639. return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
  6640. }
  6641. function removeBrackets(key) {
  6642. return utils$1.endsWith(key, "[]") ? key.slice(0, -2) : key;
  6643. }
  6644. function renderKey(path, key, dots) {
  6645. if (!path) return key;
  6646. return path.concat(key).map(function each(token2, i) {
  6647. token2 = removeBrackets(token2);
  6648. return !dots && i ? "[" + token2 + "]" : token2;
  6649. }).join(dots ? "." : "");
  6650. }
  6651. function isFlatArray(arr) {
  6652. return utils$1.isArray(arr) && !arr.some(isVisitable);
  6653. }
  6654. const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
  6655. return /^is[A-Z]/.test(prop);
  6656. });
  6657. function toFormData(obj, formData, options) {
  6658. if (!utils$1.isObject(obj)) {
  6659. throw new TypeError("target must be an object");
  6660. }
  6661. formData = formData || new FormData();
  6662. options = utils$1.toFlatObject(options, {
  6663. metaTokens: true,
  6664. dots: false,
  6665. indexes: false
  6666. }, false, function defined(option, source) {
  6667. return !utils$1.isUndefined(source[option]);
  6668. });
  6669. const metaTokens = options.metaTokens;
  6670. const visitor = options.visitor || defaultVisitor;
  6671. const dots = options.dots;
  6672. const indexes = options.indexes;
  6673. const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
  6674. const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
  6675. if (!utils$1.isFunction(visitor)) {
  6676. throw new TypeError("visitor must be a function");
  6677. }
  6678. function convertValue(value) {
  6679. if (value === null) return "";
  6680. if (utils$1.isDate(value)) {
  6681. return value.toISOString();
  6682. }
  6683. if (!useBlob && utils$1.isBlob(value)) {
  6684. throw new AxiosError("Blob is not supported. Use a Buffer instead.");
  6685. }
  6686. if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
  6687. return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
  6688. }
  6689. return value;
  6690. }
  6691. function defaultVisitor(value, key, path) {
  6692. let arr = value;
  6693. if (value && !path && typeof value === "object") {
  6694. if (utils$1.endsWith(key, "{}")) {
  6695. key = metaTokens ? key : key.slice(0, -2);
  6696. value = JSON.stringify(value);
  6697. } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) && (arr = utils$1.toArray(value))) {
  6698. key = removeBrackets(key);
  6699. arr.forEach(function each(el, index) {
  6700. !(utils$1.isUndefined(el) || el === null) && formData.append(
  6701. // eslint-disable-next-line no-nested-ternary
  6702. indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + "[]",
  6703. convertValue(el)
  6704. );
  6705. });
  6706. return false;
  6707. }
  6708. }
  6709. if (isVisitable(value)) {
  6710. return true;
  6711. }
  6712. formData.append(renderKey(path, key, dots), convertValue(value));
  6713. return false;
  6714. }
  6715. const stack = [];
  6716. const exposedHelpers = Object.assign(predicates, {
  6717. defaultVisitor,
  6718. convertValue,
  6719. isVisitable
  6720. });
  6721. function build(value, path) {
  6722. if (utils$1.isUndefined(value)) return;
  6723. if (stack.indexOf(value) !== -1) {
  6724. throw Error("Circular reference detected in " + path.join("."));
  6725. }
  6726. stack.push(value);
  6727. utils$1.forEach(value, function each(el, key) {
  6728. const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
  6729. formData,
  6730. el,
  6731. utils$1.isString(key) ? key.trim() : key,
  6732. path,
  6733. exposedHelpers
  6734. );
  6735. if (result === true) {
  6736. build(el, path ? path.concat(key) : [key]);
  6737. }
  6738. });
  6739. stack.pop();
  6740. }
  6741. if (!utils$1.isObject(obj)) {
  6742. throw new TypeError("data must be an object");
  6743. }
  6744. build(obj);
  6745. return formData;
  6746. }
  6747. function encode$2(str) {
  6748. const charMap = {
  6749. "!": "%21",
  6750. "'": "%27",
  6751. "(": "%28",
  6752. ")": "%29",
  6753. "~": "%7E",
  6754. "%20": "+",
  6755. "%00": "\0"
  6756. };
  6757. return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match2) {
  6758. return charMap[match2];
  6759. });
  6760. }
  6761. function AxiosURLSearchParams(params, options) {
  6762. this._pairs = [];
  6763. params && toFormData(params, this, options);
  6764. }
  6765. const prototype = AxiosURLSearchParams.prototype;
  6766. prototype.append = function append2(name, value) {
  6767. this._pairs.push([name, value]);
  6768. };
  6769. prototype.toString = function toString2(encoder) {
  6770. const _encode2 = encoder ? function(value) {
  6771. return encoder.call(this, value, encode$2);
  6772. } : encode$2;
  6773. return this._pairs.map(function each(pair) {
  6774. return _encode2(pair[0]) + "=" + _encode2(pair[1]);
  6775. }, "").join("&");
  6776. };
  6777. function encode$1(val) {
  6778. return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
  6779. }
  6780. function buildURL(url, params, options) {
  6781. if (!params) {
  6782. return url;
  6783. }
  6784. const _encode2 = options && options.encode || encode$1;
  6785. const serializeFn = options && options.serialize;
  6786. let serializedParams;
  6787. if (serializeFn) {
  6788. serializedParams = serializeFn(params, options);
  6789. } else {
  6790. serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode2);
  6791. }
  6792. if (serializedParams) {
  6793. const hashmarkIndex = url.indexOf("#");
  6794. if (hashmarkIndex !== -1) {
  6795. url = url.slice(0, hashmarkIndex);
  6796. }
  6797. url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
  6798. }
  6799. return url;
  6800. }
  6801. class InterceptorManager {
  6802. constructor() {
  6803. this.handlers = [];
  6804. }
  6805. /**
  6806. * Add a new interceptor to the stack
  6807. *
  6808. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  6809. * @param {Function} rejected The function to handle `reject` for a `Promise`
  6810. *
  6811. * @return {Number} An ID used to remove interceptor later
  6812. */
  6813. use(fulfilled, rejected, options) {
  6814. this.handlers.push({
  6815. fulfilled,
  6816. rejected,
  6817. synchronous: options ? options.synchronous : false,
  6818. runWhen: options ? options.runWhen : null
  6819. });
  6820. return this.handlers.length - 1;
  6821. }
  6822. /**
  6823. * Remove an interceptor from the stack
  6824. *
  6825. * @param {Number} id The ID that was returned by `use`
  6826. *
  6827. * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
  6828. */
  6829. eject(id) {
  6830. if (this.handlers[id]) {
  6831. this.handlers[id] = null;
  6832. }
  6833. }
  6834. /**
  6835. * Clear all interceptors from the stack
  6836. *
  6837. * @returns {void}
  6838. */
  6839. clear() {
  6840. if (this.handlers) {
  6841. this.handlers = [];
  6842. }
  6843. }
  6844. /**
  6845. * Iterate over all the registered interceptors
  6846. *
  6847. * This method is particularly useful for skipping over any
  6848. * interceptors that may have become `null` calling `eject`.
  6849. *
  6850. * @param {Function} fn The function to call for each interceptor
  6851. *
  6852. * @returns {void}
  6853. */
  6854. forEach(fn) {
  6855. utils$1.forEach(this.handlers, function forEachHandler(h2) {
  6856. if (h2 !== null) {
  6857. fn(h2);
  6858. }
  6859. });
  6860. }
  6861. }
  6862. const transitionalDefaults = {
  6863. silentJSONParsing: true,
  6864. forcedJSONParsing: true,
  6865. clarifyTimeoutError: false
  6866. };
  6867. const URLSearchParams$1 = typeof URLSearchParams !== "undefined" ? URLSearchParams : AxiosURLSearchParams;
  6868. const FormData$1 = typeof FormData !== "undefined" ? FormData : null;
  6869. const Blob$1 = typeof Blob !== "undefined" ? Blob : null;
  6870. const platform$1 = {
  6871. isBrowser: true,
  6872. classes: {
  6873. URLSearchParams: URLSearchParams$1,
  6874. FormData: FormData$1,
  6875. Blob: Blob$1
  6876. },
  6877. protocols: ["http", "https", "file", "blob", "url", "data"]
  6878. };
  6879. const hasBrowserEnv = typeof window !== "undefined" && typeof document !== "undefined";
  6880. const _navigator = typeof navigator === "object" && navigator || void 0;
  6881. const hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ["ReactNative", "NativeScript", "NS"].indexOf(_navigator.product) < 0);
  6882. const hasStandardBrowserWebWorkerEnv = (() => {
  6883. return typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
  6884. self instanceof WorkerGlobalScope && typeof self.importScripts === "function";
  6885. })();
  6886. const origin = hasBrowserEnv && window.location.href || "http://localhost";
  6887. const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  6888. __proto__: null,
  6889. hasBrowserEnv,
  6890. hasStandardBrowserEnv,
  6891. hasStandardBrowserWebWorkerEnv,
  6892. navigator: _navigator,
  6893. origin
  6894. }, Symbol.toStringTag, { value: "Module" }));
  6895. const platform = {
  6896. ...utils,
  6897. ...platform$1
  6898. };
  6899. function toURLEncodedForm(data, options) {
  6900. return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
  6901. visitor: function(value, key, path, helpers) {
  6902. if (platform.isNode && utils$1.isBuffer(value)) {
  6903. this.append(key, value.toString("base64"));
  6904. return false;
  6905. }
  6906. return helpers.defaultVisitor.apply(this, arguments);
  6907. }
  6908. }, options));
  6909. }
  6910. function parsePropPath(name) {
  6911. return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match2) => {
  6912. return match2[0] === "[]" ? "" : match2[1] || match2[0];
  6913. });
  6914. }
  6915. function arrayToObject(arr) {
  6916. const obj = {};
  6917. const keys = Object.keys(arr);
  6918. let i;
  6919. const len = keys.length;
  6920. let key;
  6921. for (i = 0; i < len; i++) {
  6922. key = keys[i];
  6923. obj[key] = arr[key];
  6924. }
  6925. return obj;
  6926. }
  6927. function formDataToJSON(formData) {
  6928. function buildPath(path, value, target, index) {
  6929. let name = path[index++];
  6930. if (name === "__proto__") return true;
  6931. const isNumericKey = Number.isFinite(+name);
  6932. const isLast = index >= path.length;
  6933. name = !name && utils$1.isArray(target) ? target.length : name;
  6934. if (isLast) {
  6935. if (utils$1.hasOwnProp(target, name)) {
  6936. target[name] = [target[name], value];
  6937. } else {
  6938. target[name] = value;
  6939. }
  6940. return !isNumericKey;
  6941. }
  6942. if (!target[name] || !utils$1.isObject(target[name])) {
  6943. target[name] = [];
  6944. }
  6945. const result = buildPath(path, value, target[name], index);
  6946. if (result && utils$1.isArray(target[name])) {
  6947. target[name] = arrayToObject(target[name]);
  6948. }
  6949. return !isNumericKey;
  6950. }
  6951. if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
  6952. const obj = {};
  6953. utils$1.forEachEntry(formData, (name, value) => {
  6954. buildPath(parsePropPath(name), value, obj, 0);
  6955. });
  6956. return obj;
  6957. }
  6958. return null;
  6959. }
  6960. function stringifySafely(rawValue, parser, encoder) {
  6961. if (utils$1.isString(rawValue)) {
  6962. try {
  6963. (parser || JSON.parse)(rawValue);
  6964. return utils$1.trim(rawValue);
  6965. } catch (e2) {
  6966. if (e2.name !== "SyntaxError") {
  6967. throw e2;
  6968. }
  6969. }
  6970. }
  6971. return (0, JSON.stringify)(rawValue);
  6972. }
  6973. const defaults = {
  6974. transitional: transitionalDefaults,
  6975. adapter: ["xhr", "http", "fetch"],
  6976. transformRequest: [function transformRequest(data, headers) {
  6977. const contentType = headers.getContentType() || "";
  6978. const hasJSONContentType = contentType.indexOf("application/json") > -1;
  6979. const isObjectPayload = utils$1.isObject(data);
  6980. if (isObjectPayload && utils$1.isHTMLForm(data)) {
  6981. data = new FormData(data);
  6982. }
  6983. const isFormData2 = utils$1.isFormData(data);
  6984. if (isFormData2) {
  6985. return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
  6986. }
  6987. if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
  6988. return data;
  6989. }
  6990. if (utils$1.isArrayBufferView(data)) {
  6991. return data.buffer;
  6992. }
  6993. if (utils$1.isURLSearchParams(data)) {
  6994. headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", false);
  6995. return data.toString();
  6996. }
  6997. let isFileList2;
  6998. if (isObjectPayload) {
  6999. if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
  7000. return toURLEncodedForm(data, this.formSerializer).toString();
  7001. }
  7002. if ((isFileList2 = utils$1.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
  7003. const _FormData = this.env && this.env.FormData;
  7004. return toFormData(
  7005. isFileList2 ? { "files[]": data } : data,
  7006. _FormData && new _FormData(),
  7007. this.formSerializer
  7008. );
  7009. }
  7010. }
  7011. if (isObjectPayload || hasJSONContentType) {
  7012. headers.setContentType("application/json", false);
  7013. return stringifySafely(data);
  7014. }
  7015. return data;
  7016. }],
  7017. transformResponse: [function transformResponse(data) {
  7018. const transitional2 = this.transitional || defaults.transitional;
  7019. const forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
  7020. const JSONRequested = this.responseType === "json";
  7021. if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
  7022. return data;
  7023. }
  7024. if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
  7025. const silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
  7026. const strictJSONParsing = !silentJSONParsing && JSONRequested;
  7027. try {
  7028. return JSON.parse(data);
  7029. } catch (e2) {
  7030. if (strictJSONParsing) {
  7031. if (e2.name === "SyntaxError") {
  7032. throw AxiosError.from(e2, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
  7033. }
  7034. throw e2;
  7035. }
  7036. }
  7037. }
  7038. return data;
  7039. }],
  7040. /**
  7041. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  7042. * timeout is not created.
  7043. */
  7044. timeout: 0,
  7045. xsrfCookieName: "XSRF-TOKEN",
  7046. xsrfHeaderName: "X-XSRF-TOKEN",
  7047. maxContentLength: -1,
  7048. maxBodyLength: -1,
  7049. env: {
  7050. FormData: platform.classes.FormData,
  7051. Blob: platform.classes.Blob
  7052. },
  7053. validateStatus: function validateStatus(status) {
  7054. return status >= 200 && status < 300;
  7055. },
  7056. headers: {
  7057. common: {
  7058. "Accept": "application/json, text/plain, */*",
  7059. "Content-Type": void 0
  7060. }
  7061. }
  7062. };
  7063. utils$1.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
  7064. defaults.headers[method] = {};
  7065. });
  7066. const ignoreDuplicateOf = utils$1.toObjectSet([
  7067. "age",
  7068. "authorization",
  7069. "content-length",
  7070. "content-type",
  7071. "etag",
  7072. "expires",
  7073. "from",
  7074. "host",
  7075. "if-modified-since",
  7076. "if-unmodified-since",
  7077. "last-modified",
  7078. "location",
  7079. "max-forwards",
  7080. "proxy-authorization",
  7081. "referer",
  7082. "retry-after",
  7083. "user-agent"
  7084. ]);
  7085. const parseHeaders = (rawHeaders) => {
  7086. const parsed = {};
  7087. let key;
  7088. let val;
  7089. let i;
  7090. rawHeaders && rawHeaders.split("\n").forEach(function parser(line2) {
  7091. i = line2.indexOf(":");
  7092. key = line2.substring(0, i).trim().toLowerCase();
  7093. val = line2.substring(i + 1).trim();
  7094. if (!key || parsed[key] && ignoreDuplicateOf[key]) {
  7095. return;
  7096. }
  7097. if (key === "set-cookie") {
  7098. if (parsed[key]) {
  7099. parsed[key].push(val);
  7100. } else {
  7101. parsed[key] = [val];
  7102. }
  7103. } else {
  7104. parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
  7105. }
  7106. });
  7107. return parsed;
  7108. };
  7109. const $internals = Symbol("internals");
  7110. function normalizeHeader(header) {
  7111. return header && String(header).trim().toLowerCase();
  7112. }
  7113. function normalizeValue(value) {
  7114. if (value === false || value == null) {
  7115. return value;
  7116. }
  7117. return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
  7118. }
  7119. function parseTokens(str) {
  7120. const tokens = /* @__PURE__ */ Object.create(null);
  7121. const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
  7122. let match2;
  7123. while (match2 = tokensRE.exec(str)) {
  7124. tokens[match2[1]] = match2[2];
  7125. }
  7126. return tokens;
  7127. }
  7128. const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
  7129. function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
  7130. if (utils$1.isFunction(filter2)) {
  7131. return filter2.call(this, value, header);
  7132. }
  7133. if (isHeaderNameFilter) {
  7134. value = header;
  7135. }
  7136. if (!utils$1.isString(value)) return;
  7137. if (utils$1.isString(filter2)) {
  7138. return value.indexOf(filter2) !== -1;
  7139. }
  7140. if (utils$1.isRegExp(filter2)) {
  7141. return filter2.test(value);
  7142. }
  7143. }
  7144. function formatHeader(header) {
  7145. return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w2, char2, str) => {
  7146. return char2.toUpperCase() + str;
  7147. });
  7148. }
  7149. function buildAccessors(obj, header) {
  7150. const accessorName = utils$1.toCamelCase(" " + header);
  7151. ["get", "set", "has"].forEach((methodName) => {
  7152. Object.defineProperty(obj, methodName + accessorName, {
  7153. value: function(arg1, arg2, arg3) {
  7154. return this[methodName].call(this, header, arg1, arg2, arg3);
  7155. },
  7156. configurable: true
  7157. });
  7158. });
  7159. }
  7160. class AxiosHeaders {
  7161. constructor(headers) {
  7162. headers && this.set(headers);
  7163. }
  7164. set(header, valueOrRewrite, rewrite) {
  7165. const self2 = this;
  7166. function setHeader(_value, _header, _rewrite) {
  7167. const lHeader = normalizeHeader(_header);
  7168. if (!lHeader) {
  7169. throw new Error("header name must be a non-empty string");
  7170. }
  7171. const key = utils$1.findKey(self2, lHeader);
  7172. if (!key || self2[key] === void 0 || _rewrite === true || _rewrite === void 0 && self2[key] !== false) {
  7173. self2[key || _header] = normalizeValue(_value);
  7174. }
  7175. }
  7176. const setHeaders = (headers, _rewrite) => utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
  7177. if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
  7178. setHeaders(header, valueOrRewrite);
  7179. } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
  7180. setHeaders(parseHeaders(header), valueOrRewrite);
  7181. } else if (utils$1.isHeaders(header)) {
  7182. for (const [key, value] of header.entries()) {
  7183. setHeader(value, key, rewrite);
  7184. }
  7185. } else {
  7186. header != null && setHeader(valueOrRewrite, header, rewrite);
  7187. }
  7188. return this;
  7189. }
  7190. get(header, parser) {
  7191. header = normalizeHeader(header);
  7192. if (header) {
  7193. const key = utils$1.findKey(this, header);
  7194. if (key) {
  7195. const value = this[key];
  7196. if (!parser) {
  7197. return value;
  7198. }
  7199. if (parser === true) {
  7200. return parseTokens(value);
  7201. }
  7202. if (utils$1.isFunction(parser)) {
  7203. return parser.call(this, value, key);
  7204. }
  7205. if (utils$1.isRegExp(parser)) {
  7206. return parser.exec(value);
  7207. }
  7208. throw new TypeError("parser must be boolean|regexp|function");
  7209. }
  7210. }
  7211. }
  7212. has(header, matcher) {
  7213. header = normalizeHeader(header);
  7214. if (header) {
  7215. const key = utils$1.findKey(this, header);
  7216. return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
  7217. }
  7218. return false;
  7219. }
  7220. delete(header, matcher) {
  7221. const self2 = this;
  7222. let deleted = false;
  7223. function deleteHeader(_header) {
  7224. _header = normalizeHeader(_header);
  7225. if (_header) {
  7226. const key = utils$1.findKey(self2, _header);
  7227. if (key && (!matcher || matchHeaderValue(self2, self2[key], key, matcher))) {
  7228. delete self2[key];
  7229. deleted = true;
  7230. }
  7231. }
  7232. }
  7233. if (utils$1.isArray(header)) {
  7234. header.forEach(deleteHeader);
  7235. } else {
  7236. deleteHeader(header);
  7237. }
  7238. return deleted;
  7239. }
  7240. clear(matcher) {
  7241. const keys = Object.keys(this);
  7242. let i = keys.length;
  7243. let deleted = false;
  7244. while (i--) {
  7245. const key = keys[i];
  7246. if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
  7247. delete this[key];
  7248. deleted = true;
  7249. }
  7250. }
  7251. return deleted;
  7252. }
  7253. normalize(format) {
  7254. const self2 = this;
  7255. const headers = {};
  7256. utils$1.forEach(this, (value, header) => {
  7257. const key = utils$1.findKey(headers, header);
  7258. if (key) {
  7259. self2[key] = normalizeValue(value);
  7260. delete self2[header];
  7261. return;
  7262. }
  7263. const normalized = format ? formatHeader(header) : String(header).trim();
  7264. if (normalized !== header) {
  7265. delete self2[header];
  7266. }
  7267. self2[normalized] = normalizeValue(value);
  7268. headers[normalized] = true;
  7269. });
  7270. return this;
  7271. }
  7272. concat(...targets) {
  7273. return this.constructor.concat(this, ...targets);
  7274. }
  7275. toJSON(asStrings) {
  7276. const obj = /* @__PURE__ */ Object.create(null);
  7277. utils$1.forEach(this, (value, header) => {
  7278. value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(", ") : value);
  7279. });
  7280. return obj;
  7281. }
  7282. [Symbol.iterator]() {
  7283. return Object.entries(this.toJSON())[Symbol.iterator]();
  7284. }
  7285. toString() {
  7286. return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
  7287. }
  7288. get [Symbol.toStringTag]() {
  7289. return "AxiosHeaders";
  7290. }
  7291. static from(thing) {
  7292. return thing instanceof this ? thing : new this(thing);
  7293. }
  7294. static concat(first, ...targets) {
  7295. const computed = new this(first);
  7296. targets.forEach((target) => computed.set(target));
  7297. return computed;
  7298. }
  7299. static accessor(header) {
  7300. const internals = this[$internals] = this[$internals] = {
  7301. accessors: {}
  7302. };
  7303. const accessors = internals.accessors;
  7304. const prototype2 = this.prototype;
  7305. function defineAccessor(_header) {
  7306. const lHeader = normalizeHeader(_header);
  7307. if (!accessors[lHeader]) {
  7308. buildAccessors(prototype2, _header);
  7309. accessors[lHeader] = true;
  7310. }
  7311. }
  7312. utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
  7313. return this;
  7314. }
  7315. }
  7316. AxiosHeaders.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
  7317. utils$1.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
  7318. let mapped = key[0].toUpperCase() + key.slice(1);
  7319. return {
  7320. get: () => value,
  7321. set(headerValue) {
  7322. this[mapped] = headerValue;
  7323. }
  7324. };
  7325. });
  7326. utils$1.freezeMethods(AxiosHeaders);
  7327. function transformData(fns, response) {
  7328. const config = this || defaults;
  7329. const context = response || config;
  7330. const headers = AxiosHeaders.from(context.headers);
  7331. let data = context.data;
  7332. utils$1.forEach(fns, function transform(fn) {
  7333. data = fn.call(config, data, headers.normalize(), response ? response.status : void 0);
  7334. });
  7335. headers.normalize();
  7336. return data;
  7337. }
  7338. function isCancel(value) {
  7339. return !!(value && value.__CANCEL__);
  7340. }
  7341. function CanceledError(message, config, request) {
  7342. AxiosError.call(this, message == null ? "canceled" : message, AxiosError.ERR_CANCELED, config, request);
  7343. this.name = "CanceledError";
  7344. }
  7345. utils$1.inherits(CanceledError, AxiosError, {
  7346. __CANCEL__: true
  7347. });
  7348. function settle(resolve, reject, response) {
  7349. const validateStatus2 = response.config.validateStatus;
  7350. if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
  7351. resolve(response);
  7352. } else {
  7353. reject(new AxiosError(
  7354. "Request failed with status code " + response.status,
  7355. [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
  7356. response.config,
  7357. response.request,
  7358. response
  7359. ));
  7360. }
  7361. }
  7362. function parseProtocol(url) {
  7363. const match2 = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
  7364. return match2 && match2[1] || "";
  7365. }
  7366. function speedometer(samplesCount, min) {
  7367. samplesCount = samplesCount || 10;
  7368. const bytes = new Array(samplesCount);
  7369. const timestamps = new Array(samplesCount);
  7370. let head = 0;
  7371. let tail = 0;
  7372. let firstSampleTS;
  7373. min = min !== void 0 ? min : 1e3;
  7374. return function push(chunkLength) {
  7375. const now = Date.now();
  7376. const startedAt = timestamps[tail];
  7377. if (!firstSampleTS) {
  7378. firstSampleTS = now;
  7379. }
  7380. bytes[head] = chunkLength;
  7381. timestamps[head] = now;
  7382. let i = tail;
  7383. let bytesCount = 0;
  7384. while (i !== head) {
  7385. bytesCount += bytes[i++];
  7386. i = i % samplesCount;
  7387. }
  7388. head = (head + 1) % samplesCount;
  7389. if (head === tail) {
  7390. tail = (tail + 1) % samplesCount;
  7391. }
  7392. if (now - firstSampleTS < min) {
  7393. return;
  7394. }
  7395. const passed = startedAt && now - startedAt;
  7396. return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
  7397. };
  7398. }
  7399. function throttle(fn, freq) {
  7400. let timestamp = 0;
  7401. let threshold = 1e3 / freq;
  7402. let lastArgs;
  7403. let timer;
  7404. const invoke = (args, now = Date.now()) => {
  7405. timestamp = now;
  7406. lastArgs = null;
  7407. if (timer) {
  7408. clearTimeout(timer);
  7409. timer = null;
  7410. }
  7411. fn.apply(null, args);
  7412. };
  7413. const throttled = (...args) => {
  7414. const now = Date.now();
  7415. const passed = now - timestamp;
  7416. if (passed >= threshold) {
  7417. invoke(args, now);
  7418. } else {
  7419. lastArgs = args;
  7420. if (!timer) {
  7421. timer = setTimeout(() => {
  7422. timer = null;
  7423. invoke(lastArgs);
  7424. }, threshold - passed);
  7425. }
  7426. }
  7427. };
  7428. const flush = () => lastArgs && invoke(lastArgs);
  7429. return [throttled, flush];
  7430. }
  7431. const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
  7432. let bytesNotified = 0;
  7433. const _speedometer = speedometer(50, 250);
  7434. return throttle((e2) => {
  7435. const loaded = e2.loaded;
  7436. const total = e2.lengthComputable ? e2.total : void 0;
  7437. const progressBytes = loaded - bytesNotified;
  7438. const rate = _speedometer(progressBytes);
  7439. const inRange = loaded <= total;
  7440. bytesNotified = loaded;
  7441. const data = {
  7442. loaded,
  7443. total,
  7444. progress: total ? loaded / total : void 0,
  7445. bytes: progressBytes,
  7446. rate: rate ? rate : void 0,
  7447. estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
  7448. event: e2,
  7449. lengthComputable: total != null,
  7450. [isDownloadStream ? "download" : "upload"]: true
  7451. };
  7452. listener(data);
  7453. }, freq);
  7454. };
  7455. const progressEventDecorator = (total, throttled) => {
  7456. const lengthComputable = total != null;
  7457. return [(loaded) => throttled[0]({
  7458. lengthComputable,
  7459. total,
  7460. loaded
  7461. }), throttled[1]];
  7462. };
  7463. const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
  7464. const isURLSameOrigin = platform.hasStandardBrowserEnv ? (
  7465. // Standard browser envs have full support of the APIs needed to test
  7466. // whether the request URL is of the same origin as current location.
  7467. function standardBrowserEnv() {
  7468. const msie = platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent);
  7469. const urlParsingNode = document.createElement("a");
  7470. let originURL;
  7471. function resolveURL(url) {
  7472. let href = url;
  7473. if (msie) {
  7474. urlParsingNode.setAttribute("href", href);
  7475. href = urlParsingNode.href;
  7476. }
  7477. urlParsingNode.setAttribute("href", href);
  7478. return {
  7479. href: urlParsingNode.href,
  7480. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
  7481. host: urlParsingNode.host,
  7482. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
  7483. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
  7484. hostname: urlParsingNode.hostname,
  7485. port: urlParsingNode.port,
  7486. pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
  7487. };
  7488. }
  7489. originURL = resolveURL(window.location.href);
  7490. return function isURLSameOrigin2(requestURL) {
  7491. const parsed = utils$1.isString(requestURL) ? resolveURL(requestURL) : requestURL;
  7492. return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
  7493. };
  7494. }()
  7495. ) : (
  7496. // Non standard browser envs (web workers, react-native) lack needed support.
  7497. /* @__PURE__ */ function nonStandardBrowserEnv() {
  7498. return function isURLSameOrigin2() {
  7499. return true;
  7500. };
  7501. }()
  7502. );
  7503. const cookies = platform.hasStandardBrowserEnv ? (
  7504. // Standard browser envs support document.cookie
  7505. {
  7506. write(name, value, expires, path, domain, secure) {
  7507. const cookie = [name + "=" + encodeURIComponent(value)];
  7508. utils$1.isNumber(expires) && cookie.push("expires=" + new Date(expires).toGMTString());
  7509. utils$1.isString(path) && cookie.push("path=" + path);
  7510. utils$1.isString(domain) && cookie.push("domain=" + domain);
  7511. secure === true && cookie.push("secure");
  7512. document.cookie = cookie.join("; ");
  7513. },
  7514. read(name) {
  7515. const match2 = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
  7516. return match2 ? decodeURIComponent(match2[3]) : null;
  7517. },
  7518. remove(name) {
  7519. this.write(name, "", Date.now() - 864e5);
  7520. }
  7521. }
  7522. ) : (
  7523. // Non-standard browser env (web workers, react-native) lack needed support.
  7524. {
  7525. write() {
  7526. },
  7527. read() {
  7528. return null;
  7529. },
  7530. remove() {
  7531. }
  7532. }
  7533. );
  7534. function isAbsoluteURL(url) {
  7535. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  7536. }
  7537. function combineURLs(baseURL, relativeURL) {
  7538. return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
  7539. }
  7540. function buildFullPath(baseURL, requestedURL) {
  7541. if (baseURL && !isAbsoluteURL(requestedURL)) {
  7542. return combineURLs(baseURL, requestedURL);
  7543. }
  7544. return requestedURL;
  7545. }
  7546. const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
  7547. function mergeConfig(config1, config2) {
  7548. config2 = config2 || {};
  7549. const config = {};
  7550. function getMergedValue(target, source, caseless) {
  7551. if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
  7552. return utils$1.merge.call({ caseless }, target, source);
  7553. } else if (utils$1.isPlainObject(source)) {
  7554. return utils$1.merge({}, source);
  7555. } else if (utils$1.isArray(source)) {
  7556. return source.slice();
  7557. }
  7558. return source;
  7559. }
  7560. function mergeDeepProperties(a, b2, caseless) {
  7561. if (!utils$1.isUndefined(b2)) {
  7562. return getMergedValue(a, b2, caseless);
  7563. } else if (!utils$1.isUndefined(a)) {
  7564. return getMergedValue(void 0, a, caseless);
  7565. }
  7566. }
  7567. function valueFromConfig2(a, b2) {
  7568. if (!utils$1.isUndefined(b2)) {
  7569. return getMergedValue(void 0, b2);
  7570. }
  7571. }
  7572. function defaultToConfig2(a, b2) {
  7573. if (!utils$1.isUndefined(b2)) {
  7574. return getMergedValue(void 0, b2);
  7575. } else if (!utils$1.isUndefined(a)) {
  7576. return getMergedValue(void 0, a);
  7577. }
  7578. }
  7579. function mergeDirectKeys(a, b2, prop) {
  7580. if (prop in config2) {
  7581. return getMergedValue(a, b2);
  7582. } else if (prop in config1) {
  7583. return getMergedValue(void 0, a);
  7584. }
  7585. }
  7586. const mergeMap = {
  7587. url: valueFromConfig2,
  7588. method: valueFromConfig2,
  7589. data: valueFromConfig2,
  7590. baseURL: defaultToConfig2,
  7591. transformRequest: defaultToConfig2,
  7592. transformResponse: defaultToConfig2,
  7593. paramsSerializer: defaultToConfig2,
  7594. timeout: defaultToConfig2,
  7595. timeoutMessage: defaultToConfig2,
  7596. withCredentials: defaultToConfig2,
  7597. withXSRFToken: defaultToConfig2,
  7598. adapter: defaultToConfig2,
  7599. responseType: defaultToConfig2,
  7600. xsrfCookieName: defaultToConfig2,
  7601. xsrfHeaderName: defaultToConfig2,
  7602. onUploadProgress: defaultToConfig2,
  7603. onDownloadProgress: defaultToConfig2,
  7604. decompress: defaultToConfig2,
  7605. maxContentLength: defaultToConfig2,
  7606. maxBodyLength: defaultToConfig2,
  7607. beforeRedirect: defaultToConfig2,
  7608. transport: defaultToConfig2,
  7609. httpAgent: defaultToConfig2,
  7610. httpsAgent: defaultToConfig2,
  7611. cancelToken: defaultToConfig2,
  7612. socketPath: defaultToConfig2,
  7613. responseEncoding: defaultToConfig2,
  7614. validateStatus: mergeDirectKeys,
  7615. headers: (a, b2) => mergeDeepProperties(headersToObject(a), headersToObject(b2), true)
  7616. };
  7617. utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
  7618. const merge2 = mergeMap[prop] || mergeDeepProperties;
  7619. const configValue = merge2(config1[prop], config2[prop], prop);
  7620. utils$1.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
  7621. });
  7622. return config;
  7623. }
  7624. const resolveConfig = (config) => {
  7625. const newConfig = mergeConfig({}, config);
  7626. let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
  7627. newConfig.headers = headers = AxiosHeaders.from(headers);
  7628. newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
  7629. if (auth) {
  7630. headers.set(
  7631. "Authorization",
  7632. "Basic " + btoa((auth.username || "") + ":" + (auth.password ? unescape(encodeURIComponent(auth.password)) : ""))
  7633. );
  7634. }
  7635. let contentType;
  7636. if (utils$1.isFormData(data)) {
  7637. if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
  7638. headers.setContentType(void 0);
  7639. } else if ((contentType = headers.getContentType()) !== false) {
  7640. const [type, ...tokens] = contentType ? contentType.split(";").map((token2) => token2.trim()).filter(Boolean) : [];
  7641. headers.setContentType([type || "multipart/form-data", ...tokens].join("; "));
  7642. }
  7643. }
  7644. if (platform.hasStandardBrowserEnv) {
  7645. withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
  7646. if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
  7647. const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
  7648. if (xsrfValue) {
  7649. headers.set(xsrfHeaderName, xsrfValue);
  7650. }
  7651. }
  7652. }
  7653. return newConfig;
  7654. };
  7655. const isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
  7656. const xhrAdapter = isXHRAdapterSupported && function(config) {
  7657. return new Promise(function dispatchXhrRequest(resolve, reject) {
  7658. const _config = resolveConfig(config);
  7659. let requestData = _config.data;
  7660. const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
  7661. let { responseType, onUploadProgress, onDownloadProgress } = _config;
  7662. let onCanceled;
  7663. let uploadThrottled, downloadThrottled;
  7664. let flushUpload, flushDownload;
  7665. function done() {
  7666. flushUpload && flushUpload();
  7667. flushDownload && flushDownload();
  7668. _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
  7669. _config.signal && _config.signal.removeEventListener("abort", onCanceled);
  7670. }
  7671. let request = new XMLHttpRequest();
  7672. request.open(_config.method.toUpperCase(), _config.url, true);
  7673. request.timeout = _config.timeout;
  7674. function onloadend() {
  7675. if (!request) {
  7676. return;
  7677. }
  7678. const responseHeaders = AxiosHeaders.from(
  7679. "getAllResponseHeaders" in request && request.getAllResponseHeaders()
  7680. );
  7681. const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
  7682. const response = {
  7683. data: responseData,
  7684. status: request.status,
  7685. statusText: request.statusText,
  7686. headers: responseHeaders,
  7687. config,
  7688. request
  7689. };
  7690. settle(function _resolve(value) {
  7691. resolve(value);
  7692. done();
  7693. }, function _reject(err) {
  7694. reject(err);
  7695. done();
  7696. }, response);
  7697. request = null;
  7698. }
  7699. if ("onloadend" in request) {
  7700. request.onloadend = onloadend;
  7701. } else {
  7702. request.onreadystatechange = function handleLoad() {
  7703. if (!request || request.readyState !== 4) {
  7704. return;
  7705. }
  7706. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0)) {
  7707. return;
  7708. }
  7709. setTimeout(onloadend);
  7710. };
  7711. }
  7712. request.onabort = function handleAbort() {
  7713. if (!request) {
  7714. return;
  7715. }
  7716. reject(new AxiosError("Request aborted", AxiosError.ECONNABORTED, config, request));
  7717. request = null;
  7718. };
  7719. request.onerror = function handleError() {
  7720. reject(new AxiosError("Network Error", AxiosError.ERR_NETWORK, config, request));
  7721. request = null;
  7722. };
  7723. request.ontimeout = function handleTimeout() {
  7724. let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
  7725. const transitional2 = _config.transitional || transitionalDefaults;
  7726. if (_config.timeoutErrorMessage) {
  7727. timeoutErrorMessage = _config.timeoutErrorMessage;
  7728. }
  7729. reject(new AxiosError(
  7730. timeoutErrorMessage,
  7731. transitional2.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
  7732. config,
  7733. request
  7734. ));
  7735. request = null;
  7736. };
  7737. requestData === void 0 && requestHeaders.setContentType(null);
  7738. if ("setRequestHeader" in request) {
  7739. utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
  7740. request.setRequestHeader(key, val);
  7741. });
  7742. }
  7743. if (!utils$1.isUndefined(_config.withCredentials)) {
  7744. request.withCredentials = !!_config.withCredentials;
  7745. }
  7746. if (responseType && responseType !== "json") {
  7747. request.responseType = _config.responseType;
  7748. }
  7749. if (onDownloadProgress) {
  7750. [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
  7751. request.addEventListener("progress", downloadThrottled);
  7752. }
  7753. if (onUploadProgress && request.upload) {
  7754. [uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
  7755. request.upload.addEventListener("progress", uploadThrottled);
  7756. request.upload.addEventListener("loadend", flushUpload);
  7757. }
  7758. if (_config.cancelToken || _config.signal) {
  7759. onCanceled = (cancel) => {
  7760. if (!request) {
  7761. return;
  7762. }
  7763. reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
  7764. request.abort();
  7765. request = null;
  7766. };
  7767. _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
  7768. if (_config.signal) {
  7769. _config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
  7770. }
  7771. }
  7772. const protocol = parseProtocol(_config.url);
  7773. if (protocol && platform.protocols.indexOf(protocol) === -1) {
  7774. reject(new AxiosError("Unsupported protocol " + protocol + ":", AxiosError.ERR_BAD_REQUEST, config));
  7775. return;
  7776. }
  7777. request.send(requestData || null);
  7778. });
  7779. };
  7780. const composeSignals = (signals, timeout) => {
  7781. const { length: length2 } = signals = signals ? signals.filter(Boolean) : [];
  7782. if (timeout || length2) {
  7783. let controller = new AbortController();
  7784. let aborted;
  7785. const onabort = function(reason) {
  7786. if (!aborted) {
  7787. aborted = true;
  7788. unsubscribe();
  7789. const err = reason instanceof Error ? reason : this.reason;
  7790. controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
  7791. }
  7792. };
  7793. let timer = timeout && setTimeout(() => {
  7794. timer = null;
  7795. onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
  7796. }, timeout);
  7797. const unsubscribe = () => {
  7798. if (signals) {
  7799. timer && clearTimeout(timer);
  7800. timer = null;
  7801. signals.forEach((signal2) => {
  7802. signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
  7803. });
  7804. signals = null;
  7805. }
  7806. };
  7807. signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
  7808. const { signal } = controller;
  7809. signal.unsubscribe = () => utils$1.asap(unsubscribe);
  7810. return signal;
  7811. }
  7812. };
  7813. const streamChunk = function* (chunk, chunkSize) {
  7814. let len = chunk.byteLength;
  7815. if (len < chunkSize) {
  7816. yield chunk;
  7817. return;
  7818. }
  7819. let pos = 0;
  7820. let end;
  7821. while (pos < len) {
  7822. end = pos + chunkSize;
  7823. yield chunk.slice(pos, end);
  7824. pos = end;
  7825. }
  7826. };
  7827. const readBytes = async function* (iterable, chunkSize) {
  7828. for await (const chunk of readStream(iterable)) {
  7829. yield* streamChunk(chunk, chunkSize);
  7830. }
  7831. };
  7832. const readStream = async function* (stream) {
  7833. if (stream[Symbol.asyncIterator]) {
  7834. yield* stream;
  7835. return;
  7836. }
  7837. const reader = stream.getReader();
  7838. try {
  7839. for (; ; ) {
  7840. const { done, value } = await reader.read();
  7841. if (done) {
  7842. break;
  7843. }
  7844. yield value;
  7845. }
  7846. } finally {
  7847. await reader.cancel();
  7848. }
  7849. };
  7850. const trackStream = (stream, chunkSize, onProgress, onFinish) => {
  7851. const iterator = readBytes(stream, chunkSize);
  7852. let bytes = 0;
  7853. let done;
  7854. let _onFinish = (e2) => {
  7855. if (!done) {
  7856. done = true;
  7857. onFinish && onFinish(e2);
  7858. }
  7859. };
  7860. return new ReadableStream({
  7861. async pull(controller) {
  7862. try {
  7863. const { done: done2, value } = await iterator.next();
  7864. if (done2) {
  7865. _onFinish();
  7866. controller.close();
  7867. return;
  7868. }
  7869. let len = value.byteLength;
  7870. if (onProgress) {
  7871. let loadedBytes = bytes += len;
  7872. onProgress(loadedBytes);
  7873. }
  7874. controller.enqueue(new Uint8Array(value));
  7875. } catch (err) {
  7876. _onFinish(err);
  7877. throw err;
  7878. }
  7879. },
  7880. cancel(reason) {
  7881. _onFinish(reason);
  7882. return iterator.return();
  7883. }
  7884. }, {
  7885. highWaterMark: 2
  7886. });
  7887. };
  7888. const isFetchSupported = typeof fetch === "function" && typeof Request === "function" && typeof Response === "function";
  7889. const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === "function";
  7890. const encodeText = isFetchSupported && (typeof TextEncoder === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : async (str) => new Uint8Array(await new Response(str).arrayBuffer()));
  7891. const test = (fn, ...args) => {
  7892. try {
  7893. return !!fn(...args);
  7894. } catch (e2) {
  7895. return false;
  7896. }
  7897. };
  7898. const supportsRequestStream = isReadableStreamSupported && test(() => {
  7899. let duplexAccessed = false;
  7900. const hasContentType = new Request(platform.origin, {
  7901. body: new ReadableStream(),
  7902. method: "POST",
  7903. get duplex() {
  7904. duplexAccessed = true;
  7905. return "half";
  7906. }
  7907. }).headers.has("Content-Type");
  7908. return duplexAccessed && !hasContentType;
  7909. });
  7910. const DEFAULT_CHUNK_SIZE = 64 * 1024;
  7911. const supportsResponseStream = isReadableStreamSupported && test(() => utils$1.isReadableStream(new Response("").body));
  7912. const resolvers = {
  7913. stream: supportsResponseStream && ((res) => res.body)
  7914. };
  7915. isFetchSupported && ((res) => {
  7916. ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
  7917. !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res2) => res2[type]() : (_, config) => {
  7918. throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
  7919. });
  7920. });
  7921. })(new Response());
  7922. const getBodyLength = async (body) => {
  7923. if (body == null) {
  7924. return 0;
  7925. }
  7926. if (utils$1.isBlob(body)) {
  7927. return body.size;
  7928. }
  7929. if (utils$1.isSpecCompliantForm(body)) {
  7930. const _request = new Request(platform.origin, {
  7931. method: "POST",
  7932. body
  7933. });
  7934. return (await _request.arrayBuffer()).byteLength;
  7935. }
  7936. if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
  7937. return body.byteLength;
  7938. }
  7939. if (utils$1.isURLSearchParams(body)) {
  7940. body = body + "";
  7941. }
  7942. if (utils$1.isString(body)) {
  7943. return (await encodeText(body)).byteLength;
  7944. }
  7945. };
  7946. const resolveBodyLength = async (headers, body) => {
  7947. const length2 = utils$1.toFiniteNumber(headers.getContentLength());
  7948. return length2 == null ? getBodyLength(body) : length2;
  7949. };
  7950. const fetchAdapter = isFetchSupported && (async (config) => {
  7951. let {
  7952. url,
  7953. method,
  7954. data,
  7955. signal,
  7956. cancelToken,
  7957. timeout,
  7958. onDownloadProgress,
  7959. onUploadProgress,
  7960. responseType,
  7961. headers,
  7962. withCredentials = "same-origin",
  7963. fetchOptions
  7964. } = resolveConfig(config);
  7965. responseType = responseType ? (responseType + "").toLowerCase() : "text";
  7966. let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
  7967. let request;
  7968. const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
  7969. composedSignal.unsubscribe();
  7970. });
  7971. let requestContentLength;
  7972. try {
  7973. if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
  7974. let _request = new Request(url, {
  7975. method: "POST",
  7976. body: data,
  7977. duplex: "half"
  7978. });
  7979. let contentTypeHeader;
  7980. if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
  7981. headers.setContentType(contentTypeHeader);
  7982. }
  7983. if (_request.body) {
  7984. const [onProgress, flush] = progressEventDecorator(
  7985. requestContentLength,
  7986. progressEventReducer(asyncDecorator(onUploadProgress))
  7987. );
  7988. data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
  7989. }
  7990. }
  7991. if (!utils$1.isString(withCredentials)) {
  7992. withCredentials = withCredentials ? "include" : "omit";
  7993. }
  7994. const isCredentialsSupported = "credentials" in Request.prototype;
  7995. request = new Request(url, {
  7996. ...fetchOptions,
  7997. signal: composedSignal,
  7998. method: method.toUpperCase(),
  7999. headers: headers.normalize().toJSON(),
  8000. body: data,
  8001. duplex: "half",
  8002. credentials: isCredentialsSupported ? withCredentials : void 0
  8003. });
  8004. let response = await fetch(request);
  8005. const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
  8006. if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
  8007. const options = {};
  8008. ["status", "statusText", "headers"].forEach((prop) => {
  8009. options[prop] = response[prop];
  8010. });
  8011. const responseContentLength = utils$1.toFiniteNumber(response.headers.get("content-length"));
  8012. const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
  8013. responseContentLength,
  8014. progressEventReducer(asyncDecorator(onDownloadProgress), true)
  8015. ) || [];
  8016. response = new Response(
  8017. trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
  8018. flush && flush();
  8019. unsubscribe && unsubscribe();
  8020. }),
  8021. options
  8022. );
  8023. }
  8024. responseType = responseType || "text";
  8025. let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || "text"](response, config);
  8026. !isStreamResponse && unsubscribe && unsubscribe();
  8027. return await new Promise((resolve, reject) => {
  8028. settle(resolve, reject, {
  8029. data: responseData,
  8030. headers: AxiosHeaders.from(response.headers),
  8031. status: response.status,
  8032. statusText: response.statusText,
  8033. config,
  8034. request
  8035. });
  8036. });
  8037. } catch (err) {
  8038. unsubscribe && unsubscribe();
  8039. if (err && err.name === "TypeError" && /fetch/i.test(err.message)) {
  8040. throw Object.assign(
  8041. new AxiosError("Network Error", AxiosError.ERR_NETWORK, config, request),
  8042. {
  8043. cause: err.cause || err
  8044. }
  8045. );
  8046. }
  8047. throw AxiosError.from(err, err && err.code, config, request);
  8048. }
  8049. });
  8050. const knownAdapters = {
  8051. http: httpAdapter,
  8052. xhr: xhrAdapter,
  8053. fetch: fetchAdapter
  8054. };
  8055. utils$1.forEach(knownAdapters, (fn, value) => {
  8056. if (fn) {
  8057. try {
  8058. Object.defineProperty(fn, "name", { value });
  8059. } catch (e2) {
  8060. }
  8061. Object.defineProperty(fn, "adapterName", { value });
  8062. }
  8063. });
  8064. const renderReason = (reason) => `- ${reason}`;
  8065. const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
  8066. const adapters = {
  8067. getAdapter: (adapters2) => {
  8068. adapters2 = utils$1.isArray(adapters2) ? adapters2 : [adapters2];
  8069. const { length: length2 } = adapters2;
  8070. let nameOrAdapter;
  8071. let adapter;
  8072. const rejectedReasons = {};
  8073. for (let i = 0; i < length2; i++) {
  8074. nameOrAdapter = adapters2[i];
  8075. let id;
  8076. adapter = nameOrAdapter;
  8077. if (!isResolvedHandle(nameOrAdapter)) {
  8078. adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
  8079. if (adapter === void 0) {
  8080. throw new AxiosError(`Unknown adapter '${id}'`);
  8081. }
  8082. }
  8083. if (adapter) {
  8084. break;
  8085. }
  8086. rejectedReasons[id || "#" + i] = adapter;
  8087. }
  8088. if (!adapter) {
  8089. const reasons = Object.entries(rejectedReasons).map(
  8090. ([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
  8091. );
  8092. let s = length2 ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
  8093. throw new AxiosError(
  8094. `There is no suitable adapter to dispatch the request ` + s,
  8095. "ERR_NOT_SUPPORT"
  8096. );
  8097. }
  8098. return adapter;
  8099. },
  8100. adapters: knownAdapters
  8101. };
  8102. function throwIfCancellationRequested(config) {
  8103. if (config.cancelToken) {
  8104. config.cancelToken.throwIfRequested();
  8105. }
  8106. if (config.signal && config.signal.aborted) {
  8107. throw new CanceledError(null, config);
  8108. }
  8109. }
  8110. function dispatchRequest(config) {
  8111. throwIfCancellationRequested(config);
  8112. config.headers = AxiosHeaders.from(config.headers);
  8113. config.data = transformData.call(
  8114. config,
  8115. config.transformRequest
  8116. );
  8117. if (["post", "put", "patch"].indexOf(config.method) !== -1) {
  8118. config.headers.setContentType("application/x-www-form-urlencoded", false);
  8119. }
  8120. const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
  8121. return adapter(config).then(function onAdapterResolution(response) {
  8122. throwIfCancellationRequested(config);
  8123. response.data = transformData.call(
  8124. config,
  8125. config.transformResponse,
  8126. response
  8127. );
  8128. response.headers = AxiosHeaders.from(response.headers);
  8129. return response;
  8130. }, function onAdapterRejection(reason) {
  8131. if (!isCancel(reason)) {
  8132. throwIfCancellationRequested(config);
  8133. if (reason && reason.response) {
  8134. reason.response.data = transformData.call(
  8135. config,
  8136. config.transformResponse,
  8137. reason.response
  8138. );
  8139. reason.response.headers = AxiosHeaders.from(reason.response.headers);
  8140. }
  8141. }
  8142. return Promise.reject(reason);
  8143. });
  8144. }
  8145. const VERSION$1 = "1.7.7";
  8146. const validators$1 = {};
  8147. ["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
  8148. validators$1[type] = function validator2(thing) {
  8149. return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
  8150. };
  8151. });
  8152. const deprecatedWarnings = {};
  8153. validators$1.transitional = function transitional(validator2, version2, message) {
  8154. function formatMessage(opt, desc) {
  8155. return "[Axios v" + VERSION$1 + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
  8156. }
  8157. return (value, opt, opts) => {
  8158. if (validator2 === false) {
  8159. throw new AxiosError(
  8160. formatMessage(opt, " has been removed" + (version2 ? " in " + version2 : "")),
  8161. AxiosError.ERR_DEPRECATED
  8162. );
  8163. }
  8164. if (version2 && !deprecatedWarnings[opt]) {
  8165. deprecatedWarnings[opt] = true;
  8166. console.warn(
  8167. formatMessage(
  8168. opt,
  8169. " has been deprecated since v" + version2 + " and will be removed in the near future"
  8170. )
  8171. );
  8172. }
  8173. return validator2 ? validator2(value, opt, opts) : true;
  8174. };
  8175. };
  8176. function assertOptions(options, schema, allowUnknown) {
  8177. if (typeof options !== "object") {
  8178. throw new AxiosError("options must be an object", AxiosError.ERR_BAD_OPTION_VALUE);
  8179. }
  8180. const keys = Object.keys(options);
  8181. let i = keys.length;
  8182. while (i-- > 0) {
  8183. const opt = keys[i];
  8184. const validator2 = schema[opt];
  8185. if (validator2) {
  8186. const value = options[opt];
  8187. const result = value === void 0 || validator2(value, opt, options);
  8188. if (result !== true) {
  8189. throw new AxiosError("option " + opt + " must be " + result, AxiosError.ERR_BAD_OPTION_VALUE);
  8190. }
  8191. continue;
  8192. }
  8193. if (allowUnknown !== true) {
  8194. throw new AxiosError("Unknown option " + opt, AxiosError.ERR_BAD_OPTION);
  8195. }
  8196. }
  8197. }
  8198. const validator = {
  8199. assertOptions,
  8200. validators: validators$1
  8201. };
  8202. const validators = validator.validators;
  8203. class Axios {
  8204. constructor(instanceConfig) {
  8205. this.defaults = instanceConfig;
  8206. this.interceptors = {
  8207. request: new InterceptorManager(),
  8208. response: new InterceptorManager()
  8209. };
  8210. }
  8211. /**
  8212. * Dispatch a request
  8213. *
  8214. * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
  8215. * @param {?Object} config
  8216. *
  8217. * @returns {Promise} The Promise to be fulfilled
  8218. */
  8219. async request(configOrUrl, config) {
  8220. try {
  8221. return await this._request(configOrUrl, config);
  8222. } catch (err) {
  8223. if (err instanceof Error) {
  8224. let dummy;
  8225. Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : dummy = new Error();
  8226. const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, "") : "";
  8227. try {
  8228. if (!err.stack) {
  8229. err.stack = stack;
  8230. } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ""))) {
  8231. err.stack += "\n" + stack;
  8232. }
  8233. } catch (e2) {
  8234. }
  8235. }
  8236. throw err;
  8237. }
  8238. }
  8239. _request(configOrUrl, config) {
  8240. if (typeof configOrUrl === "string") {
  8241. config = config || {};
  8242. config.url = configOrUrl;
  8243. } else {
  8244. config = configOrUrl || {};
  8245. }
  8246. config = mergeConfig(this.defaults, config);
  8247. const { transitional: transitional2, paramsSerializer, headers } = config;
  8248. if (transitional2 !== void 0) {
  8249. validator.assertOptions(transitional2, {
  8250. silentJSONParsing: validators.transitional(validators.boolean),
  8251. forcedJSONParsing: validators.transitional(validators.boolean),
  8252. clarifyTimeoutError: validators.transitional(validators.boolean)
  8253. }, false);
  8254. }
  8255. if (paramsSerializer != null) {
  8256. if (utils$1.isFunction(paramsSerializer)) {
  8257. config.paramsSerializer = {
  8258. serialize: paramsSerializer
  8259. };
  8260. } else {
  8261. validator.assertOptions(paramsSerializer, {
  8262. encode: validators.function,
  8263. serialize: validators.function
  8264. }, true);
  8265. }
  8266. }
  8267. config.method = (config.method || this.defaults.method || "get").toLowerCase();
  8268. let contextHeaders = headers && utils$1.merge(
  8269. headers.common,
  8270. headers[config.method]
  8271. );
  8272. headers && utils$1.forEach(
  8273. ["delete", "get", "head", "post", "put", "patch", "common"],
  8274. (method) => {
  8275. delete headers[method];
  8276. }
  8277. );
  8278. config.headers = AxiosHeaders.concat(contextHeaders, headers);
  8279. const requestInterceptorChain = [];
  8280. let synchronousRequestInterceptors = true;
  8281. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  8282. if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
  8283. return;
  8284. }
  8285. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  8286. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  8287. });
  8288. const responseInterceptorChain = [];
  8289. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  8290. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  8291. });
  8292. let promise;
  8293. let i = 0;
  8294. let len;
  8295. if (!synchronousRequestInterceptors) {
  8296. const chain = [dispatchRequest.bind(this), void 0];
  8297. chain.unshift.apply(chain, requestInterceptorChain);
  8298. chain.push.apply(chain, responseInterceptorChain);
  8299. len = chain.length;
  8300. promise = Promise.resolve(config);
  8301. while (i < len) {
  8302. promise = promise.then(chain[i++], chain[i++]);
  8303. }
  8304. return promise;
  8305. }
  8306. len = requestInterceptorChain.length;
  8307. let newConfig = config;
  8308. i = 0;
  8309. while (i < len) {
  8310. const onFulfilled = requestInterceptorChain[i++];
  8311. const onRejected = requestInterceptorChain[i++];
  8312. try {
  8313. newConfig = onFulfilled(newConfig);
  8314. } catch (error) {
  8315. onRejected.call(this, error);
  8316. break;
  8317. }
  8318. }
  8319. try {
  8320. promise = dispatchRequest.call(this, newConfig);
  8321. } catch (error) {
  8322. return Promise.reject(error);
  8323. }
  8324. i = 0;
  8325. len = responseInterceptorChain.length;
  8326. while (i < len) {
  8327. promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
  8328. }
  8329. return promise;
  8330. }
  8331. getUri(config) {
  8332. config = mergeConfig(this.defaults, config);
  8333. const fullPath = buildFullPath(config.baseURL, config.url);
  8334. return buildURL(fullPath, config.params, config.paramsSerializer);
  8335. }
  8336. }
  8337. utils$1.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
  8338. Axios.prototype[method] = function(url, config) {
  8339. return this.request(mergeConfig(config || {}, {
  8340. method,
  8341. url,
  8342. data: (config || {}).data
  8343. }));
  8344. };
  8345. });
  8346. utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
  8347. function generateHTTPMethod(isForm) {
  8348. return function httpMethod(url, data, config) {
  8349. return this.request(mergeConfig(config || {}, {
  8350. method,
  8351. headers: isForm ? {
  8352. "Content-Type": "multipart/form-data"
  8353. } : {},
  8354. url,
  8355. data
  8356. }));
  8357. };
  8358. }
  8359. Axios.prototype[method] = generateHTTPMethod();
  8360. Axios.prototype[method + "Form"] = generateHTTPMethod(true);
  8361. });
  8362. class CancelToken {
  8363. constructor(executor) {
  8364. if (typeof executor !== "function") {
  8365. throw new TypeError("executor must be a function.");
  8366. }
  8367. let resolvePromise;
  8368. this.promise = new Promise(function promiseExecutor(resolve) {
  8369. resolvePromise = resolve;
  8370. });
  8371. const token2 = this;
  8372. this.promise.then((cancel) => {
  8373. if (!token2._listeners) return;
  8374. let i = token2._listeners.length;
  8375. while (i-- > 0) {
  8376. token2._listeners[i](cancel);
  8377. }
  8378. token2._listeners = null;
  8379. });
  8380. this.promise.then = (onfulfilled) => {
  8381. let _resolve;
  8382. const promise = new Promise((resolve) => {
  8383. token2.subscribe(resolve);
  8384. _resolve = resolve;
  8385. }).then(onfulfilled);
  8386. promise.cancel = function reject() {
  8387. token2.unsubscribe(_resolve);
  8388. };
  8389. return promise;
  8390. };
  8391. executor(function cancel(message, config, request) {
  8392. if (token2.reason) {
  8393. return;
  8394. }
  8395. token2.reason = new CanceledError(message, config, request);
  8396. resolvePromise(token2.reason);
  8397. });
  8398. }
  8399. /**
  8400. * Throws a `CanceledError` if cancellation has been requested.
  8401. */
  8402. throwIfRequested() {
  8403. if (this.reason) {
  8404. throw this.reason;
  8405. }
  8406. }
  8407. /**
  8408. * Subscribe to the cancel signal
  8409. */
  8410. subscribe(listener) {
  8411. if (this.reason) {
  8412. listener(this.reason);
  8413. return;
  8414. }
  8415. if (this._listeners) {
  8416. this._listeners.push(listener);
  8417. } else {
  8418. this._listeners = [listener];
  8419. }
  8420. }
  8421. /**
  8422. * Unsubscribe from the cancel signal
  8423. */
  8424. unsubscribe(listener) {
  8425. if (!this._listeners) {
  8426. return;
  8427. }
  8428. const index = this._listeners.indexOf(listener);
  8429. if (index !== -1) {
  8430. this._listeners.splice(index, 1);
  8431. }
  8432. }
  8433. toAbortSignal() {
  8434. const controller = new AbortController();
  8435. const abort = (err) => {
  8436. controller.abort(err);
  8437. };
  8438. this.subscribe(abort);
  8439. controller.signal.unsubscribe = () => this.unsubscribe(abort);
  8440. return controller.signal;
  8441. }
  8442. /**
  8443. * Returns an object that contains a new `CancelToken` and a function that, when called,
  8444. * cancels the `CancelToken`.
  8445. */
  8446. static source() {
  8447. let cancel;
  8448. const token2 = new CancelToken(function executor(c2) {
  8449. cancel = c2;
  8450. });
  8451. return {
  8452. token: token2,
  8453. cancel
  8454. };
  8455. }
  8456. }
  8457. function spread(callback) {
  8458. return function wrap(arr) {
  8459. return callback.apply(null, arr);
  8460. };
  8461. }
  8462. function isAxiosError(payload) {
  8463. return utils$1.isObject(payload) && payload.isAxiosError === true;
  8464. }
  8465. const HttpStatusCode = {
  8466. Continue: 100,
  8467. SwitchingProtocols: 101,
  8468. Processing: 102,
  8469. EarlyHints: 103,
  8470. Ok: 200,
  8471. Created: 201,
  8472. Accepted: 202,
  8473. NonAuthoritativeInformation: 203,
  8474. NoContent: 204,
  8475. ResetContent: 205,
  8476. PartialContent: 206,
  8477. MultiStatus: 207,
  8478. AlreadyReported: 208,
  8479. ImUsed: 226,
  8480. MultipleChoices: 300,
  8481. MovedPermanently: 301,
  8482. Found: 302,
  8483. SeeOther: 303,
  8484. NotModified: 304,
  8485. UseProxy: 305,
  8486. Unused: 306,
  8487. TemporaryRedirect: 307,
  8488. PermanentRedirect: 308,
  8489. BadRequest: 400,
  8490. Unauthorized: 401,
  8491. PaymentRequired: 402,
  8492. Forbidden: 403,
  8493. NotFound: 404,
  8494. MethodNotAllowed: 405,
  8495. NotAcceptable: 406,
  8496. ProxyAuthenticationRequired: 407,
  8497. RequestTimeout: 408,
  8498. Conflict: 409,
  8499. Gone: 410,
  8500. LengthRequired: 411,
  8501. PreconditionFailed: 412,
  8502. PayloadTooLarge: 413,
  8503. UriTooLong: 414,
  8504. UnsupportedMediaType: 415,
  8505. RangeNotSatisfiable: 416,
  8506. ExpectationFailed: 417,
  8507. ImATeapot: 418,
  8508. MisdirectedRequest: 421,
  8509. UnprocessableEntity: 422,
  8510. Locked: 423,
  8511. FailedDependency: 424,
  8512. TooEarly: 425,
  8513. UpgradeRequired: 426,
  8514. PreconditionRequired: 428,
  8515. TooManyRequests: 429,
  8516. RequestHeaderFieldsTooLarge: 431,
  8517. UnavailableForLegalReasons: 451,
  8518. InternalServerError: 500,
  8519. NotImplemented: 501,
  8520. BadGateway: 502,
  8521. ServiceUnavailable: 503,
  8522. GatewayTimeout: 504,
  8523. HttpVersionNotSupported: 505,
  8524. VariantAlsoNegotiates: 506,
  8525. InsufficientStorage: 507,
  8526. LoopDetected: 508,
  8527. NotExtended: 510,
  8528. NetworkAuthenticationRequired: 511
  8529. };
  8530. Object.entries(HttpStatusCode).forEach(([key, value]) => {
  8531. HttpStatusCode[value] = key;
  8532. });
  8533. function createInstance(defaultConfig) {
  8534. const context = new Axios(defaultConfig);
  8535. const instance = bind(Axios.prototype.request, context);
  8536. utils$1.extend(instance, Axios.prototype, context, { allOwnKeys: true });
  8537. utils$1.extend(instance, context, null, { allOwnKeys: true });
  8538. instance.create = function create(instanceConfig) {
  8539. return createInstance(mergeConfig(defaultConfig, instanceConfig));
  8540. };
  8541. return instance;
  8542. }
  8543. const axios = createInstance(defaults);
  8544. axios.Axios = Axios;
  8545. axios.CanceledError = CanceledError;
  8546. axios.CancelToken = CancelToken;
  8547. axios.isCancel = isCancel;
  8548. axios.VERSION = VERSION$1;
  8549. axios.toFormData = toFormData;
  8550. axios.AxiosError = AxiosError;
  8551. axios.Cancel = axios.CanceledError;
  8552. axios.all = function all(promises) {
  8553. return Promise.all(promises);
  8554. };
  8555. axios.spread = spread;
  8556. axios.isAxiosError = isAxiosError;
  8557. axios.mergeConfig = mergeConfig;
  8558. axios.AxiosHeaders = AxiosHeaders;
  8559. axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
  8560. axios.getAdapter = adapters.getAdapter;
  8561. axios.HttpStatusCode = HttpStatusCode;
  8562. axios.default = axios;
  8563. function apiBase(onSuccess, onError, method, urlPath, data = null, contentType = "application/json") {
  8564. const apiRoot = "https://ani.gamer.com.tw";
  8565. const url = `${apiRoot}${urlPath}`;
  8566. const headers = {
  8567. "Content-Type": contentType
  8568. };
  8569. const config = { headers };
  8570. {
  8571. config.params = data;
  8572. axios[method.toLowerCase()](url, config).then((response) => {
  8573. onSuccess(response);
  8574. }).catch((error) => {
  8575. onError(error);
  8576. });
  8577. }
  8578. }
  8579. const __vite_import_meta_env__$2 = { "BASE_URL": "/", "DEV": false, "MODE": "production", "PROD": true, "SSR": false };
  8580. const isSelfAtom = (atom2, a) => atom2.unstable_is ? atom2.unstable_is(a) : a === atom2;
  8581. const hasInitialValue = (atom2) => "init" in atom2;
  8582. const isActuallyWritableAtom = (atom2) => !!atom2.write;
  8583. const isAtomStateInitialized = (atomState) => "v" in atomState || "e" in atomState;
  8584. const returnAtomValue = (atomState) => {
  8585. if ("e" in atomState) {
  8586. throw atomState.e;
  8587. }
  8588. if ((__vite_import_meta_env__$2 ? "production" : void 0) !== "production" && !("v" in atomState)) {
  8589. throw new Error("[Bug] atom state is not initialized");
  8590. }
  8591. return atomState.v;
  8592. };
  8593. const PROMISE_STATE = Symbol();
  8594. const getPromiseState = (promise) => promise[PROMISE_STATE];
  8595. const isPendingPromise = (value) => {
  8596. var _a;
  8597. return isPromiseLike$1(value) && !((_a = getPromiseState(value)) == null ? void 0 : _a[1]);
  8598. };
  8599. const cancelPromise = (promise, nextValue) => {
  8600. const promiseState = getPromiseState(promise);
  8601. if (promiseState) {
  8602. promiseState[1] = true;
  8603. promiseState[0].forEach((fn) => fn(nextValue));
  8604. } else if ((__vite_import_meta_env__$2 ? "production" : void 0) !== "production") {
  8605. throw new Error("[Bug] cancelable promise not found");
  8606. }
  8607. };
  8608. const patchPromiseForCancelability = (promise) => {
  8609. if (getPromiseState(promise)) {
  8610. return;
  8611. }
  8612. const promiseState = [/* @__PURE__ */ new Set(), false];
  8613. promise[PROMISE_STATE] = promiseState;
  8614. const settle2 = () => {
  8615. promiseState[1] = true;
  8616. };
  8617. promise.then(settle2, settle2);
  8618. promise.onCancel = (fn) => {
  8619. promiseState[0].add(fn);
  8620. };
  8621. };
  8622. const isPromiseLike$1 = (p2) => typeof (p2 == null ? void 0 : p2.then) === "function";
  8623. const addPendingPromiseToDependency = (atom2, promise, dependencyAtomState) => {
  8624. if (!dependencyAtomState.p.has(atom2)) {
  8625. dependencyAtomState.p.add(atom2);
  8626. promise.then(
  8627. () => {
  8628. dependencyAtomState.p.delete(atom2);
  8629. },
  8630. () => {
  8631. dependencyAtomState.p.delete(atom2);
  8632. }
  8633. );
  8634. }
  8635. };
  8636. const setAtomStateValueOrPromise = (atom2, valueOrPromise, ensureAtomState) => {
  8637. const atomState = ensureAtomState(atom2);
  8638. const hasPrevValue = "v" in atomState;
  8639. const prevValue = atomState.v;
  8640. const pendingPromise = isPendingPromise(atomState.v) ? atomState.v : null;
  8641. if (isPromiseLike$1(valueOrPromise)) {
  8642. patchPromiseForCancelability(valueOrPromise);
  8643. for (const a of atomState.d.keys()) {
  8644. addPendingPromiseToDependency(atom2, valueOrPromise, ensureAtomState(a));
  8645. }
  8646. }
  8647. atomState.v = valueOrPromise;
  8648. delete atomState.e;
  8649. if (!hasPrevValue || !Object.is(prevValue, atomState.v)) {
  8650. ++atomState.n;
  8651. if (pendingPromise) {
  8652. cancelPromise(pendingPromise, valueOrPromise);
  8653. }
  8654. }
  8655. };
  8656. const getMountedOrPendingDependents = (atom2, atomState, mountedMap) => {
  8657. var _a;
  8658. const dependents = /* @__PURE__ */ new Set();
  8659. for (const a of ((_a = mountedMap.get(atom2)) == null ? void 0 : _a.t) || []) {
  8660. if (mountedMap.has(a)) {
  8661. dependents.add(a);
  8662. }
  8663. }
  8664. for (const atomWithPendingPromise of atomState.p) {
  8665. dependents.add(atomWithPendingPromise);
  8666. }
  8667. return dependents;
  8668. };
  8669. const createStoreHook = () => {
  8670. const callbacks = /* @__PURE__ */ new Set();
  8671. const notify = () => {
  8672. callbacks.forEach((fn) => fn());
  8673. };
  8674. notify.add = (fn) => {
  8675. callbacks.add(fn);
  8676. return () => {
  8677. callbacks.delete(fn);
  8678. };
  8679. };
  8680. return notify;
  8681. };
  8682. const createStoreHookForAtoms = () => {
  8683. const all2 = {};
  8684. const callbacks = /* @__PURE__ */ new WeakMap();
  8685. const notify = (atom2) => {
  8686. var _a, _b;
  8687. (_a = callbacks.get(all2)) == null ? void 0 : _a.forEach((fn) => fn(atom2));
  8688. (_b = callbacks.get(atom2)) == null ? void 0 : _b.forEach((fn) => fn());
  8689. };
  8690. notify.add = (atom2, fn) => {
  8691. const key = atom2 || all2;
  8692. const fns = (callbacks.has(key) ? callbacks : callbacks.set(key, /* @__PURE__ */ new Set())).get(key);
  8693. fns.add(fn);
  8694. return () => {
  8695. fns == null ? void 0 : fns.delete(fn);
  8696. if (!fns.size) {
  8697. callbacks.delete(key);
  8698. }
  8699. };
  8700. };
  8701. return notify;
  8702. };
  8703. const initializeStoreHooks = (storeHooks) => {
  8704. storeHooks.c || (storeHooks.c = createStoreHookForAtoms());
  8705. storeHooks.m || (storeHooks.m = createStoreHookForAtoms());
  8706. storeHooks.u || (storeHooks.u = createStoreHookForAtoms());
  8707. storeHooks.f || (storeHooks.f = createStoreHook());
  8708. return storeHooks;
  8709. };
  8710. const BUILDING_BLOCKS = Symbol();
  8711. const buildStore = (atomStateMap = /* @__PURE__ */ new WeakMap(), mountedMap = /* @__PURE__ */ new WeakMap(), invalidatedAtoms = /* @__PURE__ */ new WeakMap(), changedAtoms = /* @__PURE__ */ new Set(), mountCallbacks = /* @__PURE__ */ new Set(), unmountCallbacks = /* @__PURE__ */ new Set(), storeHooks = {}, atomRead = (atom2, ...params) => atom2.read(...params), atomWrite = (atom2, ...params) => atom2.write(...params), atomOnInit = (atom2, store2) => {
  8712. var _a;
  8713. return (_a = atom2.unstable_onInit) == null ? void 0 : _a.call(atom2, store2);
  8714. }, atomOnMount = (atom2, setAtom) => {
  8715. var _a;
  8716. return (_a = atom2.onMount) == null ? void 0 : _a.call(atom2, setAtom);
  8717. }, ...buildingBlockFunctions) => {
  8718. const ensureAtomState = buildingBlockFunctions[0] || ((atom2) => {
  8719. if ((__vite_import_meta_env__$2 ? "production" : void 0) !== "production" && !atom2) {
  8720. throw new Error("Atom is undefined or null");
  8721. }
  8722. let atomState = atomStateMap.get(atom2);
  8723. if (!atomState) {
  8724. atomState = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 };
  8725. atomStateMap.set(atom2, atomState);
  8726. atomOnInit == null ? void 0 : atomOnInit(atom2, store2);
  8727. }
  8728. return atomState;
  8729. });
  8730. const flushCallbacks = buildingBlockFunctions[1] || (() => {
  8731. let hasError;
  8732. let error;
  8733. const call = (fn) => {
  8734. try {
  8735. fn();
  8736. } catch (e2) {
  8737. if (!hasError) {
  8738. hasError = true;
  8739. error = e2;
  8740. }
  8741. }
  8742. };
  8743. do {
  8744. if (storeHooks.f) {
  8745. call(storeHooks.f);
  8746. }
  8747. const callbacks = /* @__PURE__ */ new Set();
  8748. const add = callbacks.add.bind(callbacks);
  8749. changedAtoms.forEach((atom2) => {
  8750. var _a;
  8751. return (_a = mountedMap.get(atom2)) == null ? void 0 : _a.l.forEach(add);
  8752. });
  8753. changedAtoms.clear();
  8754. unmountCallbacks.forEach(add);
  8755. unmountCallbacks.clear();
  8756. mountCallbacks.forEach(add);
  8757. mountCallbacks.clear();
  8758. callbacks.forEach(call);
  8759. if (changedAtoms.size) {
  8760. recomputeInvalidatedAtoms();
  8761. }
  8762. } while (changedAtoms.size || unmountCallbacks.size || mountCallbacks.size);
  8763. if (hasError) {
  8764. throw error;
  8765. }
  8766. });
  8767. const recomputeInvalidatedAtoms = buildingBlockFunctions[2] || (() => {
  8768. var _a;
  8769. const topSortedReversed = [];
  8770. const visiting = /* @__PURE__ */ new WeakSet();
  8771. const visited = /* @__PURE__ */ new WeakSet();
  8772. const stack = Array.from(changedAtoms);
  8773. while (stack.length) {
  8774. const a = stack[stack.length - 1];
  8775. const aState = ensureAtomState(a);
  8776. if (visited.has(a)) {
  8777. stack.pop();
  8778. continue;
  8779. }
  8780. if (visiting.has(a)) {
  8781. if (invalidatedAtoms.get(a) === aState.n) {
  8782. topSortedReversed.push([a, aState, aState.n]);
  8783. } else if ((__vite_import_meta_env__$2 ? "production" : void 0) !== "production" && invalidatedAtoms.has(a)) {
  8784. throw new Error("[Bug] invalidated atom exists");
  8785. }
  8786. visited.add(a);
  8787. stack.pop();
  8788. continue;
  8789. }
  8790. visiting.add(a);
  8791. for (const d2 of getMountedOrPendingDependents(a, aState, mountedMap)) {
  8792. if (!visiting.has(d2)) {
  8793. stack.push(d2);
  8794. }
  8795. }
  8796. }
  8797. for (let i = topSortedReversed.length - 1; i >= 0; --i) {
  8798. const [a, aState, prevEpochNumber] = topSortedReversed[i];
  8799. let hasChangedDeps = false;
  8800. for (const dep of aState.d.keys()) {
  8801. if (dep !== a && changedAtoms.has(dep)) {
  8802. hasChangedDeps = true;
  8803. break;
  8804. }
  8805. }
  8806. if (hasChangedDeps) {
  8807. readAtomState(a);
  8808. mountDependencies(a);
  8809. if (prevEpochNumber !== aState.n) {
  8810. changedAtoms.add(a);
  8811. (_a = storeHooks.c) == null ? void 0 : _a.call(storeHooks, a);
  8812. }
  8813. }
  8814. invalidatedAtoms.delete(a);
  8815. }
  8816. });
  8817. const readAtomState = buildingBlockFunctions[3] || ((atom2) => {
  8818. var _a, _b;
  8819. const atomState = ensureAtomState(atom2);
  8820. if (isAtomStateInitialized(atomState)) {
  8821. if (mountedMap.has(atom2) && invalidatedAtoms.get(atom2) !== atomState.n) {
  8822. return atomState;
  8823. }
  8824. if (Array.from(atomState.d).every(
  8825. ([a, n2]) => (
  8826. // Recursively, read the atom state of the dependency, and
  8827. // check if the atom epoch number is unchanged
  8828. readAtomState(a).n === n2
  8829. )
  8830. )) {
  8831. return atomState;
  8832. }
  8833. }
  8834. atomState.d.clear();
  8835. let isSync = true;
  8836. const mountDependenciesIfAsync = () => {
  8837. if (mountedMap.has(atom2)) {
  8838. mountDependencies(atom2);
  8839. recomputeInvalidatedAtoms();
  8840. flushCallbacks();
  8841. }
  8842. };
  8843. const getter = (a) => {
  8844. var _a2;
  8845. if (isSelfAtom(atom2, a)) {
  8846. const aState2 = ensureAtomState(a);
  8847. if (!isAtomStateInitialized(aState2)) {
  8848. if (hasInitialValue(a)) {
  8849. setAtomStateValueOrPromise(a, a.init, ensureAtomState);
  8850. } else {
  8851. throw new Error("no atom init");
  8852. }
  8853. }
  8854. return returnAtomValue(aState2);
  8855. }
  8856. const aState = readAtomState(a);
  8857. try {
  8858. return returnAtomValue(aState);
  8859. } finally {
  8860. atomState.d.set(a, aState.n);
  8861. if (isPendingPromise(atomState.v)) {
  8862. addPendingPromiseToDependency(atom2, atomState.v, aState);
  8863. }
  8864. (_a2 = mountedMap.get(a)) == null ? void 0 : _a2.t.add(atom2);
  8865. if (!isSync) {
  8866. mountDependenciesIfAsync();
  8867. }
  8868. }
  8869. };
  8870. let controller;
  8871. let setSelf;
  8872. const options = {
  8873. get signal() {
  8874. if (!controller) {
  8875. controller = new AbortController();
  8876. }
  8877. return controller.signal;
  8878. },
  8879. get setSelf() {
  8880. if ((__vite_import_meta_env__$2 ? "production" : void 0) !== "production" && !isActuallyWritableAtom(atom2)) {
  8881. console.warn("setSelf function cannot be used with read-only atom");
  8882. }
  8883. if (!setSelf && isActuallyWritableAtom(atom2)) {
  8884. setSelf = (...args) => {
  8885. if ((__vite_import_meta_env__$2 ? "production" : void 0) !== "production" && isSync) {
  8886. console.warn("setSelf function cannot be called in sync");
  8887. }
  8888. if (!isSync) {
  8889. try {
  8890. return writeAtomState(atom2, ...args);
  8891. } finally {
  8892. recomputeInvalidatedAtoms();
  8893. flushCallbacks();
  8894. }
  8895. }
  8896. };
  8897. }
  8898. return setSelf;
  8899. }
  8900. };
  8901. const prevEpochNumber = atomState.n;
  8902. try {
  8903. const valueOrPromise = atomRead(atom2, getter, options);
  8904. setAtomStateValueOrPromise(atom2, valueOrPromise, ensureAtomState);
  8905. if (isPromiseLike$1(valueOrPromise)) {
  8906. (_a = valueOrPromise.onCancel) == null ? void 0 : _a.call(valueOrPromise, () => controller == null ? void 0 : controller.abort());
  8907. valueOrPromise.then(
  8908. mountDependenciesIfAsync,
  8909. mountDependenciesIfAsync
  8910. );
  8911. }
  8912. return atomState;
  8913. } catch (error) {
  8914. delete atomState.v;
  8915. atomState.e = error;
  8916. ++atomState.n;
  8917. return atomState;
  8918. } finally {
  8919. isSync = false;
  8920. if (prevEpochNumber !== atomState.n && invalidatedAtoms.get(atom2) === prevEpochNumber) {
  8921. invalidatedAtoms.set(atom2, atomState.n);
  8922. changedAtoms.add(atom2);
  8923. (_b = storeHooks.c) == null ? void 0 : _b.call(storeHooks, atom2);
  8924. }
  8925. }
  8926. });
  8927. const invalidateDependents = buildingBlockFunctions[4] || ((atom2) => {
  8928. const stack = [atom2];
  8929. while (stack.length) {
  8930. const a = stack.pop();
  8931. const aState = ensureAtomState(a);
  8932. for (const d2 of getMountedOrPendingDependents(a, aState, mountedMap)) {
  8933. const dState = ensureAtomState(d2);
  8934. invalidatedAtoms.set(d2, dState.n);
  8935. stack.push(d2);
  8936. }
  8937. }
  8938. });
  8939. const writeAtomState = buildingBlockFunctions[5] || ((atom2, ...args) => {
  8940. let isSync = true;
  8941. const getter = (a) => returnAtomValue(readAtomState(a));
  8942. const setter = (a, ...args2) => {
  8943. var _a;
  8944. const aState = ensureAtomState(a);
  8945. try {
  8946. if (isSelfAtom(atom2, a)) {
  8947. if (!hasInitialValue(a)) {
  8948. throw new Error("atom not writable");
  8949. }
  8950. const prevEpochNumber = aState.n;
  8951. const v2 = args2[0];
  8952. setAtomStateValueOrPromise(a, v2, ensureAtomState);
  8953. mountDependencies(a);
  8954. if (prevEpochNumber !== aState.n) {
  8955. changedAtoms.add(a);
  8956. (_a = storeHooks.c) == null ? void 0 : _a.call(storeHooks, a);
  8957. invalidateDependents(a);
  8958. }
  8959. return void 0;
  8960. } else {
  8961. return writeAtomState(a, ...args2);
  8962. }
  8963. } finally {
  8964. if (!isSync) {
  8965. recomputeInvalidatedAtoms();
  8966. flushCallbacks();
  8967. }
  8968. }
  8969. };
  8970. try {
  8971. return atomWrite(atom2, getter, setter, ...args);
  8972. } finally {
  8973. isSync = false;
  8974. }
  8975. });
  8976. const mountDependencies = buildingBlockFunctions[6] || ((atom2) => {
  8977. var _a;
  8978. const atomState = ensureAtomState(atom2);
  8979. const mounted = mountedMap.get(atom2);
  8980. if (mounted && !isPendingPromise(atomState.v)) {
  8981. for (const [a, n2] of atomState.d) {
  8982. if (!mounted.d.has(a)) {
  8983. const aState = ensureAtomState(a);
  8984. const aMounted = mountAtom(a);
  8985. aMounted.t.add(atom2);
  8986. mounted.d.add(a);
  8987. if (n2 !== aState.n) {
  8988. changedAtoms.add(a);
  8989. (_a = storeHooks.c) == null ? void 0 : _a.call(storeHooks, a);
  8990. invalidateDependents(a);
  8991. }
  8992. }
  8993. }
  8994. for (const a of mounted.d || []) {
  8995. if (!atomState.d.has(a)) {
  8996. mounted.d.delete(a);
  8997. const aMounted = unmountAtom(a);
  8998. aMounted == null ? void 0 : aMounted.t.delete(atom2);
  8999. }
  9000. }
  9001. }
  9002. });
  9003. const mountAtom = buildingBlockFunctions[7] || ((atom2) => {
  9004. var _a;
  9005. const atomState = ensureAtomState(atom2);
  9006. let mounted = mountedMap.get(atom2);
  9007. if (!mounted) {
  9008. readAtomState(atom2);
  9009. for (const a of atomState.d.keys()) {
  9010. const aMounted = mountAtom(a);
  9011. aMounted.t.add(atom2);
  9012. }
  9013. mounted = {
  9014. l: /* @__PURE__ */ new Set(),
  9015. d: new Set(atomState.d.keys()),
  9016. t: /* @__PURE__ */ new Set()
  9017. };
  9018. mountedMap.set(atom2, mounted);
  9019. (_a = storeHooks.m) == null ? void 0 : _a.call(storeHooks, atom2);
  9020. if (isActuallyWritableAtom(atom2)) {
  9021. const processOnMount = () => {
  9022. let isSync = true;
  9023. const setAtom = (...args) => {
  9024. try {
  9025. return writeAtomState(atom2, ...args);
  9026. } finally {
  9027. if (!isSync) {
  9028. recomputeInvalidatedAtoms();
  9029. flushCallbacks();
  9030. }
  9031. }
  9032. };
  9033. try {
  9034. const onUnmount = atomOnMount(atom2, setAtom);
  9035. if (onUnmount) {
  9036. mounted.u = () => {
  9037. isSync = true;
  9038. try {
  9039. onUnmount();
  9040. } finally {
  9041. isSync = false;
  9042. }
  9043. };
  9044. }
  9045. } finally {
  9046. isSync = false;
  9047. }
  9048. };
  9049. mountCallbacks.add(processOnMount);
  9050. }
  9051. }
  9052. return mounted;
  9053. });
  9054. const unmountAtom = buildingBlockFunctions[8] || ((atom2) => {
  9055. var _a;
  9056. const atomState = ensureAtomState(atom2);
  9057. let mounted = mountedMap.get(atom2);
  9058. if (mounted && !mounted.l.size && !Array.from(mounted.t).some((a) => {
  9059. var _a2;
  9060. return (_a2 = mountedMap.get(a)) == null ? void 0 : _a2.d.has(atom2);
  9061. })) {
  9062. if (mounted.u) {
  9063. unmountCallbacks.add(mounted.u);
  9064. }
  9065. mounted = void 0;
  9066. mountedMap.delete(atom2);
  9067. (_a = storeHooks.u) == null ? void 0 : _a.call(storeHooks, atom2);
  9068. for (const a of atomState.d.keys()) {
  9069. const aMounted = unmountAtom(a);
  9070. aMounted == null ? void 0 : aMounted.t.delete(atom2);
  9071. }
  9072. return void 0;
  9073. }
  9074. return mounted;
  9075. });
  9076. const buildingBlocks = [
  9077. // store state
  9078. atomStateMap,
  9079. mountedMap,
  9080. invalidatedAtoms,
  9081. changedAtoms,
  9082. mountCallbacks,
  9083. unmountCallbacks,
  9084. storeHooks,
  9085. // atom intercepters
  9086. atomRead,
  9087. atomWrite,
  9088. atomOnInit,
  9089. atomOnMount,
  9090. // building-block functions
  9091. ensureAtomState,
  9092. flushCallbacks,
  9093. recomputeInvalidatedAtoms,
  9094. readAtomState,
  9095. invalidateDependents,
  9096. writeAtomState,
  9097. mountDependencies,
  9098. mountAtom,
  9099. unmountAtom
  9100. ];
  9101. const store2 = {
  9102. get: (atom2) => returnAtomValue(readAtomState(atom2)),
  9103. set: (atom2, ...args) => {
  9104. try {
  9105. return writeAtomState(atom2, ...args);
  9106. } finally {
  9107. recomputeInvalidatedAtoms();
  9108. flushCallbacks();
  9109. }
  9110. },
  9111. sub: (atom2, listener) => {
  9112. const mounted = mountAtom(atom2);
  9113. const listeners = mounted.l;
  9114. listeners.add(listener);
  9115. flushCallbacks();
  9116. return () => {
  9117. listeners.delete(listener);
  9118. unmountAtom(atom2);
  9119. flushCallbacks();
  9120. };
  9121. }
  9122. };
  9123. Object.defineProperty(store2, BUILDING_BLOCKS, { value: buildingBlocks });
  9124. return store2;
  9125. };
  9126. const INTERNAL_buildStoreRev1 = buildStore;
  9127. const INTERNAL_initializeStoreHooks = initializeStoreHooks;
  9128. const __vite_import_meta_env__$1 = { "BASE_URL": "/", "DEV": false, "MODE": "production", "PROD": true, "SSR": false };
  9129. let keyCount = 0;
  9130. function atom(read, write) {
  9131. const key = `atom${++keyCount}`;
  9132. const config = {
  9133. toString() {
  9134. return (__vite_import_meta_env__$1 ? "production" : void 0) !== "production" && this.debugLabel ? key + ":" + this.debugLabel : key;
  9135. }
  9136. };
  9137. {
  9138. config.init = read;
  9139. config.read = defaultRead;
  9140. config.write = defaultWrite;
  9141. }
  9142. return config;
  9143. }
  9144. function defaultRead(get) {
  9145. return get(this);
  9146. }
  9147. function defaultWrite(get, set, arg2) {
  9148. return set(
  9149. this,
  9150. typeof arg2 === "function" ? arg2(get(this)) : arg2
  9151. );
  9152. }
  9153. const createDevStoreRev4 = () => {
  9154. let inRestoreAtom = 0;
  9155. const storeHooks = INTERNAL_initializeStoreHooks({});
  9156. const atomStateMap = /* @__PURE__ */ new WeakMap();
  9157. const mountedAtoms = /* @__PURE__ */ new WeakMap();
  9158. const store2 = INTERNAL_buildStoreRev1(
  9159. atomStateMap,
  9160. mountedAtoms,
  9161. void 0,
  9162. void 0,
  9163. void 0,
  9164. void 0,
  9165. storeHooks,
  9166. void 0,
  9167. (atom2, get, set, ...args) => {
  9168. if (inRestoreAtom) {
  9169. return set(atom2, ...args);
  9170. }
  9171. return atom2.write(get, set, ...args);
  9172. }
  9173. );
  9174. const debugMountedAtoms = /* @__PURE__ */ new Set();
  9175. storeHooks.m.add(void 0, (atom2) => {
  9176. debugMountedAtoms.add(atom2);
  9177. const atomState = atomStateMap.get(atom2);
  9178. atomState.m = mountedAtoms.get(atom2);
  9179. });
  9180. storeHooks.u.add(void 0, (atom2) => {
  9181. debugMountedAtoms.delete(atom2);
  9182. const atomState = atomStateMap.get(atom2);
  9183. delete atomState.m;
  9184. });
  9185. const devStore = {
  9186. // store dev methods (these are tentative and subject to change without notice)
  9187. dev4_get_internal_weak_map: () => atomStateMap,
  9188. dev4_get_mounted_atoms: () => debugMountedAtoms,
  9189. dev4_restore_atoms: (values2) => {
  9190. const restoreAtom = {
  9191. read: () => null,
  9192. write: (_get, set) => {
  9193. ++inRestoreAtom;
  9194. try {
  9195. for (const [atom2, value] of values2) {
  9196. if ("init" in atom2) {
  9197. set(atom2, value);
  9198. }
  9199. }
  9200. } finally {
  9201. --inRestoreAtom;
  9202. }
  9203. }
  9204. };
  9205. store2.set(restoreAtom);
  9206. }
  9207. };
  9208. return Object.assign(store2, devStore);
  9209. };
  9210. const createStore = () => {
  9211. if ((__vite_import_meta_env__$1 ? "production" : void 0) !== "production") {
  9212. return createDevStoreRev4();
  9213. }
  9214. const store2 = INTERNAL_buildStoreRev1();
  9215. return store2;
  9216. };
  9217. let defaultStore;
  9218. const getDefaultStore = () => {
  9219. if (!defaultStore) {
  9220. defaultStore = createStore();
  9221. if ((__vite_import_meta_env__$1 ? "production" : void 0) !== "production") {
  9222. globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = defaultStore);
  9223. if (globalThis.__JOTAI_DEFAULT_STORE__ !== defaultStore) {
  9224. console.warn(
  9225. "Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
  9226. );
  9227. }
  9228. }
  9229. }
  9230. return defaultStore;
  9231. };
  9232. const __vite_import_meta_env__ = { "BASE_URL": "/", "DEV": false, "MODE": "production", "PROD": true, "SSR": false };
  9233. const StoreContext = React.createContext(
  9234. void 0
  9235. );
  9236. const useStore = (options) => {
  9237. const store2 = React.useContext(StoreContext);
  9238. return store2 || getDefaultStore();
  9239. };
  9240. const isPromiseLike = (x2) => typeof (x2 == null ? void 0 : x2.then) === "function";
  9241. const attachPromiseMeta = (promise) => {
  9242. promise.status = "pending";
  9243. promise.then(
  9244. (v2) => {
  9245. promise.status = "fulfilled";
  9246. promise.value = v2;
  9247. },
  9248. (e2) => {
  9249. promise.status = "rejected";
  9250. promise.reason = e2;
  9251. }
  9252. );
  9253. };
  9254. const use = React.use || ((promise) => {
  9255. if (promise.status === "pending") {
  9256. throw promise;
  9257. } else if (promise.status === "fulfilled") {
  9258. return promise.value;
  9259. } else if (promise.status === "rejected") {
  9260. throw promise.reason;
  9261. } else {
  9262. attachPromiseMeta(promise);
  9263. throw promise;
  9264. }
  9265. });
  9266. const continuablePromiseMap = /* @__PURE__ */ new WeakMap();
  9267. const createContinuablePromise = (promise) => {
  9268. let continuablePromise = continuablePromiseMap.get(promise);
  9269. if (!continuablePromise) {
  9270. continuablePromise = new Promise((resolve, reject) => {
  9271. let curr = promise;
  9272. const onFulfilled = (me) => (v2) => {
  9273. if (curr === me) {
  9274. resolve(v2);
  9275. }
  9276. };
  9277. const onRejected = (me) => (e2) => {
  9278. if (curr === me) {
  9279. reject(e2);
  9280. }
  9281. };
  9282. const registerCancelHandler = (p2) => {
  9283. if ("onCancel" in p2 && typeof p2.onCancel === "function") {
  9284. p2.onCancel((nextValue) => {
  9285. if ((__vite_import_meta_env__ ? "production" : void 0) !== "production" && nextValue === p2) {
  9286. throw new Error("[Bug] p is not updated even after cancelation");
  9287. }
  9288. if (isPromiseLike(nextValue)) {
  9289. continuablePromiseMap.set(nextValue, continuablePromise);
  9290. curr = nextValue;
  9291. nextValue.then(onFulfilled(nextValue), onRejected(nextValue));
  9292. registerCancelHandler(nextValue);
  9293. } else {
  9294. resolve(nextValue);
  9295. }
  9296. });
  9297. }
  9298. };
  9299. promise.then(onFulfilled(promise), onRejected(promise));
  9300. registerCancelHandler(promise);
  9301. });
  9302. continuablePromiseMap.set(promise, continuablePromise);
  9303. }
  9304. return continuablePromise;
  9305. };
  9306. function useAtomValue(atom2, options) {
  9307. const store2 = useStore();
  9308. const [[valueFromReducer, storeFromReducer, atomFromReducer], rerender] = React.useReducer(
  9309. (prev2) => {
  9310. const nextValue = store2.get(atom2);
  9311. if (Object.is(prev2[0], nextValue) && prev2[1] === store2 && prev2[2] === atom2) {
  9312. return prev2;
  9313. }
  9314. return [nextValue, store2, atom2];
  9315. },
  9316. void 0,
  9317. () => [store2.get(atom2), store2, atom2]
  9318. );
  9319. let value = valueFromReducer;
  9320. if (storeFromReducer !== store2 || atomFromReducer !== atom2) {
  9321. rerender();
  9322. value = store2.get(atom2);
  9323. }
  9324. const delay = void 0;
  9325. React.useEffect(() => {
  9326. const unsub = store2.sub(atom2, () => {
  9327. rerender();
  9328. });
  9329. rerender();
  9330. return unsub;
  9331. }, [store2, atom2, delay]);
  9332. React.useDebugValue(value);
  9333. if (isPromiseLike(value)) {
  9334. const promise = createContinuablePromise(value);
  9335. return use(promise);
  9336. }
  9337. return value;
  9338. }
  9339. function useSetAtom(atom2, options) {
  9340. const store2 = useStore();
  9341. const setAtom = React.useCallback(
  9342. (...args) => {
  9343. if ((__vite_import_meta_env__ ? "production" : void 0) !== "production" && !("write" in atom2)) {
  9344. throw new Error("not writable atom");
  9345. }
  9346. return store2.set(atom2, ...args);
  9347. },
  9348. [store2, atom2]
  9349. );
  9350. return setAtom;
  9351. }
  9352. function useAtom(atom2, options) {
  9353. return [
  9354. useAtomValue(atom2),
  9355. // We do wrong type assertion here, which results in throwing an error.
  9356. useSetAtom(atom2)
  9357. ];
  9358. }
  9359. const vipAtom = atom(null);
  9360. const videoUnlockedAtom = atom(null);
  9361. const videoUrlAtom = atom(null);
  9362. const videoSnAtom = atom(null);
  9363. const videoTitleAtom = atom(null);
  9364. const store$4 = getDefaultStore();
  9365. const device = animefun.getdeviceid();
  9366. function apiStartAd(onSuccess, onError) {
  9367. apiBase(onSuccess, onError, "GET", "/ajax/videoCastcishu.php", {
  9368. s: getAd()[0],
  9369. sn: store$4.get(videoSnAtom)
  9370. });
  9371. }
  9372. function apiEndAd(onSuccess, onError) {
  9373. apiBase(onSuccess, onError, "GET", "/ajax/videoCastcishu.php", {
  9374. s: getAd()[0],
  9375. sn: store$4.get(videoSnAtom),
  9376. ad: "end"
  9377. });
  9378. }
  9379. function apiGetM3U8(onSuccess, onError) {
  9380. apiBase(onSuccess, onError, "GET", "/ajax/m3u8.php", {
  9381. sn: store$4.get(videoSnAtom),
  9382. device
  9383. });
  9384. }
  9385. function apiGetToken(onSuccess, onError) {
  9386. apiBase(onSuccess, onError, "GET", "/ajax/token.php", {
  9387. sn: store$4.get(videoSnAtom),
  9388. device
  9389. });
  9390. }
  9391. function useAnime() {
  9392. const [videoSn, setVideoSn] = useAtom(videoSnAtom);
  9393. const [videoTitle, setVideoTitle] = useAtom(videoTitleAtom);
  9394. React.useEffect(() => {
  9395. if (videoSn == null) {
  9396. setVideoSn(animefun.videoSn);
  9397. }
  9398. if (videoTitle == null) {
  9399. setVideoTitle(animefun.title);
  9400. }
  9401. }, []);
  9402. }
  9403. function useAdTimer(countToZeroCallback) {
  9404. const [timer, setTimer] = React.useState(null);
  9405. React.useEffect(() => {
  9406. if (timer !== null) {
  9407. if (timer > 0) {
  9408. setTimeout(() => {
  9409. console.log(`ani2mpv: 廣告播放中,還剩下 ${timer - 1} 秒`);
  9410. setTimer(timer - 1);
  9411. }, 1e3);
  9412. } else {
  9413. countToZeroCallback();
  9414. }
  9415. }
  9416. }, [timer]);
  9417. return { timer, setTimer };
  9418. }
  9419. function useVipStatus() {
  9420. const [vip, setVip] = useAtom(vipAtom);
  9421. React.useEffect(() => {
  9422. if (vip == null) {
  9423. apiGetToken(
  9424. (response) => {
  9425. setVip(response.data.vip);
  9426. },
  9427. (error) => {
  9428. }
  9429. );
  9430. }
  9431. }, [vip]);
  9432. return { vip, setVip };
  9433. }
  9434. const version = "3.7.7";
  9435. const VERSION = version;
  9436. const _hasBuffer = typeof Buffer === "function";
  9437. const _TD = typeof TextDecoder === "function" ? new TextDecoder() : void 0;
  9438. const _TE = typeof TextEncoder === "function" ? new TextEncoder() : void 0;
  9439. const b64ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  9440. const b64chs = Array.prototype.slice.call(b64ch);
  9441. const b64tab = ((a) => {
  9442. let tab = {};
  9443. a.forEach((c2, i) => tab[c2] = i);
  9444. return tab;
  9445. })(b64chs);
  9446. const b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
  9447. const _fromCC = String.fromCharCode.bind(String);
  9448. const _U8Afrom = typeof Uint8Array.from === "function" ? Uint8Array.from.bind(Uint8Array) : (it) => new Uint8Array(Array.prototype.slice.call(it, 0));
  9449. const _mkUriSafe = (src) => src.replace(/=/g, "").replace(/[+\/]/g, (m0) => m0 == "+" ? "-" : "_");
  9450. const _tidyB64 = (s) => s.replace(/[^A-Za-z0-9\+\/]/g, "");
  9451. const btoaPolyfill = (bin) => {
  9452. let u32, c0, c1, c2, asc = "";
  9453. const pad = bin.length % 3;
  9454. for (let i = 0; i < bin.length; ) {
  9455. if ((c0 = bin.charCodeAt(i++)) > 255 || (c1 = bin.charCodeAt(i++)) > 255 || (c2 = bin.charCodeAt(i++)) > 255)
  9456. throw new TypeError("invalid character found");
  9457. u32 = c0 << 16 | c1 << 8 | c2;
  9458. asc += b64chs[u32 >> 18 & 63] + b64chs[u32 >> 12 & 63] + b64chs[u32 >> 6 & 63] + b64chs[u32 & 63];
  9459. }
  9460. return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc;
  9461. };
  9462. const _btoa = typeof btoa === "function" ? (bin) => btoa(bin) : _hasBuffer ? (bin) => Buffer.from(bin, "binary").toString("base64") : btoaPolyfill;
  9463. const _fromUint8Array = _hasBuffer ? (u8a) => Buffer.from(u8a).toString("base64") : (u8a) => {
  9464. const maxargs = 4096;
  9465. let strs = [];
  9466. for (let i = 0, l2 = u8a.length; i < l2; i += maxargs) {
  9467. strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
  9468. }
  9469. return _btoa(strs.join(""));
  9470. };
  9471. const fromUint8Array = (u8a, urlsafe = false) => urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a);
  9472. const cb_utob = (c2) => {
  9473. if (c2.length < 2) {
  9474. var cc = c2.charCodeAt(0);
  9475. return cc < 128 ? c2 : cc < 2048 ? _fromCC(192 | cc >>> 6) + _fromCC(128 | cc & 63) : _fromCC(224 | cc >>> 12 & 15) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
  9476. } else {
  9477. var cc = 65536 + (c2.charCodeAt(0) - 55296) * 1024 + (c2.charCodeAt(1) - 56320);
  9478. return _fromCC(240 | cc >>> 18 & 7) + _fromCC(128 | cc >>> 12 & 63) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
  9479. }
  9480. };
  9481. const re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
  9482. const utob = (u) => u.replace(re_utob, cb_utob);
  9483. const _encode = _hasBuffer ? (s) => Buffer.from(s, "utf8").toString("base64") : _TE ? (s) => _fromUint8Array(_TE.encode(s)) : (s) => _btoa(utob(s));
  9484. const encode = (src, urlsafe = false) => urlsafe ? _mkUriSafe(_encode(src)) : _encode(src);
  9485. const encodeURI = (src) => encode(src, true);
  9486. const re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
  9487. const cb_btou = (cccc) => {
  9488. switch (cccc.length) {
  9489. case 4:
  9490. var cp = (7 & cccc.charCodeAt(0)) << 18 | (63 & cccc.charCodeAt(1)) << 12 | (63 & cccc.charCodeAt(2)) << 6 | 63 & cccc.charCodeAt(3), offset = cp - 65536;
  9491. return _fromCC((offset >>> 10) + 55296) + _fromCC((offset & 1023) + 56320);
  9492. case 3:
  9493. return _fromCC((15 & cccc.charCodeAt(0)) << 12 | (63 & cccc.charCodeAt(1)) << 6 | 63 & cccc.charCodeAt(2));
  9494. default:
  9495. return _fromCC((31 & cccc.charCodeAt(0)) << 6 | 63 & cccc.charCodeAt(1));
  9496. }
  9497. };
  9498. const btou = (b2) => b2.replace(re_btou, cb_btou);
  9499. const atobPolyfill = (asc) => {
  9500. asc = asc.replace(/\s+/g, "");
  9501. if (!b64re.test(asc))
  9502. throw new TypeError("malformed base64.");
  9503. asc += "==".slice(2 - (asc.length & 3));
  9504. let u24, bin = "", r1, r2;
  9505. for (let i = 0; i < asc.length; ) {
  9506. u24 = b64tab[asc.charAt(i++)] << 18 | b64tab[asc.charAt(i++)] << 12 | (r1 = b64tab[asc.charAt(i++)]) << 6 | (r2 = b64tab[asc.charAt(i++)]);
  9507. bin += r1 === 64 ? _fromCC(u24 >> 16 & 255) : r2 === 64 ? _fromCC(u24 >> 16 & 255, u24 >> 8 & 255) : _fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255);
  9508. }
  9509. return bin;
  9510. };
  9511. const _atob = typeof atob === "function" ? (asc) => atob(_tidyB64(asc)) : _hasBuffer ? (asc) => Buffer.from(asc, "base64").toString("binary") : atobPolyfill;
  9512. const _toUint8Array = _hasBuffer ? (a) => _U8Afrom(Buffer.from(a, "base64")) : (a) => _U8Afrom(_atob(a).split("").map((c2) => c2.charCodeAt(0)));
  9513. const toUint8Array = (a) => _toUint8Array(_unURI(a));
  9514. const _decode = _hasBuffer ? (a) => Buffer.from(a, "base64").toString("utf8") : _TD ? (a) => _TD.decode(_toUint8Array(a)) : (a) => btou(_atob(a));
  9515. const _unURI = (a) => _tidyB64(a.replace(/[-_]/g, (m0) => m0 == "-" ? "+" : "/"));
  9516. const decode = (src) => _decode(_unURI(src));
  9517. const isValid = (src) => {
  9518. if (typeof src !== "string")
  9519. return false;
  9520. const s = src.replace(/\s+/g, "").replace(/={0,2}$/, "");
  9521. return !/[^\s0-9a-zA-Z\+/]/.test(s) || !/[^\s0-9a-zA-Z\-_]/.test(s);
  9522. };
  9523. const _noEnum = (v2) => {
  9524. return {
  9525. value: v2,
  9526. enumerable: false,
  9527. writable: true,
  9528. configurable: true
  9529. };
  9530. };
  9531. const extendString = function() {
  9532. const _add = (name, body) => Object.defineProperty(String.prototype, name, _noEnum(body));
  9533. _add("fromBase64", function() {
  9534. return decode(this);
  9535. });
  9536. _add("toBase64", function(urlsafe) {
  9537. return encode(this, urlsafe);
  9538. });
  9539. _add("toBase64URI", function() {
  9540. return encode(this, true);
  9541. });
  9542. _add("toBase64URL", function() {
  9543. return encode(this, true);
  9544. });
  9545. _add("toUint8Array", function() {
  9546. return toUint8Array(this);
  9547. });
  9548. };
  9549. const extendUint8Array = function() {
  9550. const _add = (name, body) => Object.defineProperty(Uint8Array.prototype, name, _noEnum(body));
  9551. _add("toBase64", function(urlsafe) {
  9552. return fromUint8Array(this, urlsafe);
  9553. });
  9554. _add("toBase64URI", function() {
  9555. return fromUint8Array(this, true);
  9556. });
  9557. _add("toBase64URL", function() {
  9558. return fromUint8Array(this, true);
  9559. });
  9560. };
  9561. const extendBuiltins = () => {
  9562. extendString();
  9563. extendUint8Array();
  9564. };
  9565. const gBase64 = {
  9566. version,
  9567. VERSION,
  9568. atob: _atob,
  9569. atobPolyfill,
  9570. btoa: _btoa,
  9571. btoaPolyfill,
  9572. fromBase64: decode,
  9573. toBase64: encode,
  9574. encode,
  9575. encodeURI,
  9576. encodeURL: encodeURI,
  9577. utob,
  9578. btou,
  9579. decode,
  9580. isValid,
  9581. fromUint8Array,
  9582. toUint8Array,
  9583. extendString,
  9584. extendUint8Array,
  9585. extendBuiltins
  9586. };
  9587. const store$3 = getDefaultStore();
  9588. const animeToMpv = (url) => {
  9589. const title = `巴哈姆特動畫瘋 | ${store$3.get(
  9590. videoTitleAtom
  9591. )} | ani2mpv Yotsuba`;
  9592. const mpv = `mpv://play/${gBase64.encodeURI(
  9593. url
  9594. )}/?v_title=${gBase64.encodeURI(title)}`;
  9595. window.location.href = mpv;
  9596. };
  9597. function useVideoAlert() {
  9598. const [videoUrl, setVideoUrl] = useAtom(videoUrlAtom);
  9599. React.useEffect(() => {
  9600. if (videoUrl !== null) {
  9601. animeToMpv(videoUrl);
  9602. }
  9603. }, [videoUrl]);
  9604. const getM3U8 = () => {
  9605. apiGetM3U8(
  9606. (response) => {
  9607. console.log(`ani2mpv: 影片 M3U8 ${response.data.src}`);
  9608. setVideoUrl(response.data.src);
  9609. },
  9610. (error) => {
  9611. }
  9612. );
  9613. };
  9614. return { videoUrl, setVideoUrl, getM3U8 };
  9615. }
  9616. function useVideoSnEffect() {
  9617. const [videoSn, setVideoSn] = useAtom(videoSnAtom);
  9618. const [videoUrl, setVideoUrl] = useAtom(videoUrlAtom);
  9619. React.useEffect(() => {
  9620. console.log("ani2mpv: 偵測到換頁,videoSn 變更為", videoSn);
  9621. setVideoUrl(null);
  9622. }, [videoSn]);
  9623. }
  9624. function Ani2Mpv() {
  9625. useAnime();
  9626. useVideoSnEffect();
  9627. const { timer, setTimer } = useAdTimer(() => {
  9628. apiEndAd(
  9629. (response) => {
  9630. console.log("ani2mpv: 廣告結束");
  9631. getM3U8();
  9632. },
  9633. (error) => {
  9634. }
  9635. );
  9636. });
  9637. const { vip } = useVipStatus();
  9638. const { videoUrl, getM3U8 } = useVideoAlert();
  9639. const [videoUnlocked, setVideoUnlocked] = useAtom(videoUnlockedAtom);
  9640. const onClick = () => {
  9641. if (videoUrl) {
  9642. animeToMpv();
  9643. return;
  9644. }
  9645. if (vip || videoUnlocked) {
  9646. getM3U8();
  9647. return;
  9648. }
  9649. apiStartAd(
  9650. (response) => {
  9651. console.log("ani2mpv: 廣告開始");
  9652. setTimer(25);
  9653. },
  9654. (error) => {
  9655. }
  9656. );
  9657. };
  9658. if (vip == true) {
  9659. var text = `你是付費會員!`;
  9660. } else if (videoUnlocked) {
  9661. var text = `不用觀看廣告即可播放`;
  9662. } else if (vip == false && timer == null) {
  9663. var text = `按下按鈕後自動觀看廣告`;
  9664. } else if (vip == false && timer > 0) {
  9665. var text = `廣告播放中,還剩下 ${timer} 秒`;
  9666. } else if (vip == false && timer == 0) {
  9667. var text = `廣告播放完畢`;
  9668. } else {
  9669. var text = `取得會員資訊中 ...`;
  9670. }
  9671. return /* @__PURE__ */ jsxRuntimeExports.jsx(Page, { onClick, text });
  9672. }
  9673. function App() {
  9674. return /* @__PURE__ */ jsxRuntimeExports.jsx(Ani2Mpv, {});
  9675. }
  9676. const store$2 = getDefaultStore();
  9677. (function overrideFetch() {
  9678. const originalFetch = window.fetch;
  9679. window.fetch = async function(input, init) {
  9680. let url;
  9681. if (typeof input === "string") {
  9682. url = new URL(input, location.origin);
  9683. } else if (input instanceof Request) {
  9684. url = new URL(input.url, location.origin);
  9685. } else {
  9686. return originalFetch(input, init);
  9687. }
  9688. if (url.pathname === "/ajax/token.php") {
  9689. console.log("ani2mpv: 攔截到 /ajax/token.php");
  9690. try {
  9691. const response = await originalFetch(input, init);
  9692. const clonedResponse = response.clone();
  9693. const responseData = await clonedResponse.json();
  9694. if (responseData && typeof responseData.vip !== "undefined") {
  9695. store$2.set(vipAtom, responseData.vip);
  9696. store$2.set(videoUnlockedAtom, responseData.time);
  9697. console.log("ani2mpv: VIP 狀態為", responseData.vip);
  9698. console.log("ani2mpv: time 狀態為", responseData.time);
  9699. }
  9700. return response;
  9701. } catch (error) {
  9702. console.error("ani2mpv: ", error);
  9703. throw error;
  9704. }
  9705. }
  9706. return originalFetch(input, init);
  9707. };
  9708. })();
  9709. const store$1 = getDefaultStore();
  9710. (function monitorUrlChange() {
  9711. let lastSn = null;
  9712. function getSnFromQuery() {
  9713. const params = new URLSearchParams(window.location.search);
  9714. return params.get("sn") || null;
  9715. }
  9716. function updateVideoSn() {
  9717. const newSn = getSnFromQuery();
  9718. if (newSn !== lastSn) {
  9719. lastSn = newSn;
  9720. store$1.set(videoSnAtom, newSn);
  9721. }
  9722. }
  9723. const originalPushState = history.pushState;
  9724. const originalReplaceState = history.replaceState;
  9725. history.pushState = function(...args) {
  9726. originalPushState.apply(this, args);
  9727. updateVideoSn();
  9728. };
  9729. history.replaceState = function(...args) {
  9730. originalReplaceState.apply(this, args);
  9731. updateVideoSn();
  9732. };
  9733. window.addEventListener("popstate", updateVideoSn);
  9734. updateVideoSn();
  9735. })();
  9736. const store = getDefaultStore();
  9737. (function monitorVideoTitle() {
  9738. function updateAnimeTitle() {
  9739. const titleElement = document.querySelector(".anime_name h1");
  9740. if (titleElement) {
  9741. const titleText = titleElement.textContent.trim();
  9742. console.log("ani2mpv: 影片標題更新為", titleText);
  9743. store.set(videoTitleAtom, titleText);
  9744. }
  9745. }
  9746. updateAnimeTitle();
  9747. const observer2 = new MutationObserver(updateAnimeTitle);
  9748. const targetNode = document.querySelector(".anime_name");
  9749. if (targetNode) {
  9750. observer2.observe(targetNode, { childList: true, subtree: true });
  9751. }
  9752. const globalObserver = new MutationObserver(() => {
  9753. const newTarget = document.querySelector(".anime_name");
  9754. if (newTarget) {
  9755. observer2.observe(newTarget, { childList: true, subtree: true });
  9756. globalObserver.disconnect();
  9757. updateAnimeTitle();
  9758. }
  9759. });
  9760. globalObserver.observe(document.body, { childList: true, subtree: true });
  9761. })();
  9762. console.log("ani2mpv: 載入 main.jsx");
  9763. let appContainer = null;
  9764. const targetSelector = ".ncc-choose-btn";
  9765. const observer = new MutationObserver(() => {
  9766. const target = document.querySelector(targetSelector);
  9767. if (target) {
  9768. if (appContainer && document.body.contains(appContainer)) {
  9769. return;
  9770. }
  9771. appContainer = document.createElement("div");
  9772. appContainer.id = "ani2mpv-root";
  9773. target.after(appContainer);
  9774. client.createRoot(appContainer).render(/* @__PURE__ */ jsxRuntimeExports.jsx(App, {}));
  9775. }
  9776. });
  9777. observer.observe(document.body, { childList: true, subtree: true });
  9778.  
  9779. })(React, ReactDOM);